Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!uunet!bischeops!nick From: nick@bischeops.UUCP (Nick Bender) Newsgroups: comp.unix.questions Subject: Re: Make: Compiling source code from a different directory. Summary: Slightly different approach using symbolic links Message-ID: <384@bischeops.UUCP> Date: 29 Nov 89 16:22:55 GMT References: <404@massey.ac.nz> Lines: 54 In article <404@massey.ac.nz>, KSpagnol@massey.ac.nz (Ken Spagnolo) writes: > We have several machines that all need to run the same code. Rather > than keep the source on each and worry about keeping them up to date, > I set up the makefile on our Sun 386i to access the source kept on > our Pyramid..... I use a slightly different approach. I keep source in one directory with subdirectories for each object type eg: # ls HP/ Makefile PYRAMID/ SUN/ main.c # I have a makefile, a source file, and three platform-specific directories. The makefile contains the following: # cat Makefile SRCS = main.c OBJS = main.o hello: $(OBJS) $(CC) -o $@ $(CFLAGS) $(OBJS) $(LIBS) $(SRCS): ln -s ../$@ . # Each subdir gets a munged version of this makefile which defines various flags and things (see below) so that it looks like: # ls SUN Makefile # Then when I do make I get: # cd SUN # make ln -s ../main.c . cc -O -c main.c cc -o hello -O main.o # ls Makefile hello* main.c@ main.o # Whenever editing takes place in the parent directory the make dependencies still work through the link (at least on our Suns, HPs, and pyramid). The platform specific makefiles are generated using a shell script and pre-defined prepend and append makefile fragments. -Nick ...!uunet!bischeops!nick nick%bischeops@uunet.uu.net