Search code examples
unixmakefileaixmultiplatform

Conditional sections in AIX Makefiles


How do I make a makefile that works on AIX, Linux and SunOS and has the ability to provide different compiler options for each environment?

I have access to an environment variable which describes the OS, but the AIX make utility does not like ifeq, so I can't do something like:

ifeq($(OS), AIX)
    CFLAGS = $(CFLAGS) <IBM compiler options>
endif

Solution

  • You can use a construct like this:

    CFLAGS_AIX = AIX flags
    CFLAGS_Linux = Linux flags
    CFLAGS_SunOS = SunOS flags
    CFLAGS = $(CFLAGS_$(OS))