NOTE: I am not interested in dealing with autotools/autogen yet. I want to focus on learning about make/gmake.
I have seen this subject posted on the web, but have not found a solution for myself yet.
I want users to be able to compile from my Makefile on Linux, BSD, and Windows systems. The Makefile tests if the target platform is Win32 using conditional directives. I much prefer BSD as the GNU syntax is confusing to me:
However this is not compatible with GNU make:
For GNU make it needs to be something like this:
or I think I can use something like this (though this example doesn't work as intented):
Neither of which are compatible with BSD make.
My base question is how to make my Makefile both GNU and BSD compatible. Is it possible to do within a single file or do I need to separate them? Can I have a base Makefile that imports another of either GNU or BSD standards? Or, do I just need to make two completely separate files?
NOTE: I have also posted this to the Unix.com forums.
I have seen this subject posted on the web, but have not found a solution for myself yet.
I want users to be able to compile from my Makefile on Linux, BSD, and Windows systems. The Makefile tests if the target platform is Win32 using conditional directives. I much prefer BSD as the GNU syntax is confusing to me:
Code:
...
EXESUFFIX=
ICON=myabcs.xpm
.if defined(WIN32) || defined(__WIN32__)
EXESUFFIX=.exe
ICON=myabcs.ico
.endif
...
However this is not compatible with GNU make:
Code:
$ gmake
Makefile:20: *** missing separator. Stop.
For GNU make it needs to be something like this:
Code:
...
EXESUFFIX=
ICON=myabcs.xpm
ifdef WIN32 # don't know how to use logical "or" (||) here
EXESUFFIX=.exe
ICON=myabcs.ico
endif
ifdef __WIN32__
EXESUFFIX=.exe
ICON=myabcs.ico
endif
...
or I think I can use something like this (though this example doesn't work as intented):
Code:
...
EXESUFFIX=
ICON=myabcs.xpm
ifeq (,$(filter "",$(WIN32) $(__WIN32__)))
EXESUFFIX=.exe
ICON=myabcs.ico
endif
...
Neither of which are compatible with BSD make.
My base question is how to make my Makefile both GNU and BSD compatible. Is it possible to do within a single file or do I need to separate them? Can I have a base Makefile that imports another of either GNU or BSD standards? Or, do I just need to make two completely separate files?
NOTE: I have also posted this to the Unix.com forums.