views:

39

answers:

2

I would like to have the same Makefile for building on Linux and on Windows. I use the default GNU make on Linux and the mingw32-make (also GNU make) on Windows.

I want the Makefile to detect whether it operates on Windows or Linux.


For example make clean command on Windows looks like:

clean:
    del $(DESTDIR_TARGET)

But on Linux:

clean:
    rm $(DESTDIR_TARGET)

Also I would like to use different directory separator on Windows (\) and Linux (/).


It is possible to detect Windows operating system in Makefile?

PS: I do not want to emulate Linux on Windows (cygwin etc.)

There is similiar question: OS detecting makefile, but I didn't find the answer here.

+1  A: 

You should probably use the $(RM) variable to remove some files.

Antoine Pelisse
+1  A: 

I would like to have the same Makefile for building on Linux and on Windows.

Maybe you will like CMake

Mads Elvheim
CMake looks interesting, thanks.
tomp