I have a makefile
that works transparently for Linux (x86_64
) and OS X Intel (x86_64
). This uses 64-bit specific GCC options.
Is there a way to adjust the makefile so that I could build for 32-bit and 64-bit OS X PPC (ppc
, ppc64
) without having to maintain separate, arch-specific makefiles — perhaps something like a pre-processor directive that can determine the architecture before building?
Try file inclusion. This is not part of the standard Makefile syntax (the one in the Single Unix v3 specification) but is widely supported. With GNU make, this looks like this:
With this, you could have an x86 Makefile like this:
and a PowerPC Makefile:
and the bulk of your compilation rules will be in one file (
common.mk
), using$(ARCHFLAGS)
where necessary.Have a look at this:
http://mad-scientist.net/make/multi-arch.html
It is somewhat dated but has good info that could be useful for you I suppose.
One way to work this is to:
posix
,win32
,win32-gcc
, etc.I've used this in small-to-medium size projects (2 or 3 persons working on code for a few years), and it fits the bill well.
I think that you would achieve your goals with less work (and pain) by employing some kind of a build system such as cmake or GNU autotools.