Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!apple!bionet!ames!purdue!haven!adm!xadmx!Kemp@DOCKMASTER.NCSC.MIL From: Kemp@DOCKMASTER.NCSC.MIL Newsgroups: comp.unix.questions Subject: Re: Help with Makefile Message-ID: <20501@adm.BRL.MIL> Date: 4 Aug 89 15:50:20 GMT Sender: news@adm.BRL.MIL Lines: 34 micky@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 Quote: "Pave the Bay" --- bumper sticker on a J-24 at Hampton Yacht Club