Help with Makefile
Kemp at DOCKMASTER.NCSC.MIL
Kemp at DOCKMASTER.NCSC.MIL
Sat Aug 5 01:50:20 AEST 1989
micky at cunixc.cc.columbia.edu (Micky Liu) writes:
> I am trying to build a Makefile for sources that have to be built
> for different architectures. So let's say I have my sources at
> the root and I want to place the objects in their subdirectories
> under the root like:
>
> /src
> /src/vax
> /src/sun3
> /src/sun4
> [ ... ]
> Let's say I'm on the vax, and I type make. It figures out that
> I'm on the vax and then IT does something like:
>
> make CCFLAGS=-DVAX
>
I recently got a GREAT suggestion from a Sun employee on how to do
just that, which I posted to sun-spots. Basically you define variables
(oops - make calls them macros) for each architecture and then select
the macro you need using a nested macro. For example:
CFLAGS= $(CFLAGS$(TARGET_ARCH))
CFLAGS-vax= -Dvax
CFLAGS-sun3= -f68881
The macro $(TARGET_ARCH) is replaced by a string such as "-sun3", which
is then used as the name of the macro you are using for the particular
architecture. There is no need for make to invoke itself recursively to
achieve this substitution.
Dave Kemp <Kemp at dockmaster.ncsc.mil>
Quote: "Pave the Bay" --- bumper sticker on a J-24 at Hampton Yacht Club
More information about the Comp.unix.questions
mailing list