Detecting host OS in Gnu make

Is this possible? Right now I'm developing some code for Linux, Windows and OS X. To build on each of the systems I've currently got separate build targets for each platform. Ideally I'd like to set up a single make rule that can detect the appropriate target and build it.

I know this is correctly done via autoconf for distribution but that is overkill for my purposes.

Perhaps use uname(1) to find out OS, e.g.

OS := $(shell uname -o)
ifeq $(OS) GNU/Linux
# set variables for Linux 
else
# check for other OSs and set variables appropriately
endif

You would need to check what uname gives you on each of your build platforms.

Cheers for that. It works if I use 'uname -s', OS X doesn't have the -o option. It seems to make me dependent on MinGW for windows since 'uname -s' gives 'MINGW32_NT-5.1' but that isn't a problem.