Firstly, I would like to apologize if this is not the appropriate sub-forum to post about GNU/BSD makefile scripting. Though my code is in C++, because I am focusing on the makefile I thought it would go better in shell scripting. Please correct me if I am wrong.
Secondly, 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, & 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:
...
EXESUFFIX=
ICON=myabcs.xpm
.if defined(WIN32) || defined(__WIN32__)
EXESUFFIX=.exe
ICON=myabcs.ico
.endif
...
However this is not compatible with GNU make:
For GNU make it needs to be something like this:
...
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):
...
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 & 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 2 completely separate files?