Help with Makefile
Root Boy Jim
rbj at dsys.ncsl.nist.gov
Sat Sep 2 02:09:39 AEST 1989
? From: Micky Liu <micky at cunixc.cc.columbia.edu>
? 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
? But I only want to keep one Makefile in the my /src directory.
? I have already made a method to determine the architecture and
? then it invokes itself with the proper flags. The problem is
? that I cannot seem to get the implicit rules to work anymore.
? 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
? but when it actually gets to a target it says that it doesn't know
? how to make vax/hello.o, or omething like that. I ended up making
? explicit rules for each source file, but would really like to be
? able to use the implicit rules...
? Any clues, or other methods of maintaining a single source tree for
? different architectures?
This is just a WAG, I haven't tried it. Code you Makefile as if you were
in the subdirectory. Then add the following entry at the beginning:
vax sun3 sun4 whatever:
(cd $@; make -f ../Makefile all)
Where the target `all' builds your program. Just type `make vax' to
build the program for the vax. The targets for clean and install are
more complex.
Another way to do it is by using the `arch' command.
all clean install:
(cd `arch`; make -f ../Makefile ARCH=-D`arch | tr a-z A-Z` real$@)
Of course, there is also the VPATH variable, which may or may not work.
? Thanx!
? Micky Liu
? arpa: micky at cunixc.cc.columbia.edu
? uucp: ...!rutgers!columbia!cunixc!micky
? bitnet: malua at cuvmc
Root Boy Jim and
the GNU Bohemians
More information about the Comp.unix.questions
mailing list