I want to know a parameter which is an indicator of the current OS. If am supporting Windows and Linux, how can I get a system parameter which differentiates the OS types. This for an OS independent makefile which runs both in Windows and Linux by checking the parameter in an ‘if’.
Share
In the past I’ve checked the value of the environment variable OS. This is set on Windows. For other platforms I’ve explicitly set it in the environment. This then lets you push platform specific settings into makefiles called …
In my main makefile I then just do
This all works because I can pull in the platform specific settings via makefile.$(OS)
That’s the sum total of my main makefile and it compiles for seven different platforms. You could make the detection cleverer but that would reduce comprehensability.
In each makefile.WHATEVER I provide definitions of things like
Obviously this is quite a C/C++ focus makefile but it proves that you can abstract away all of the platform specifics.
Chris