[comp.unix.programmer] make difficulties

levisonm@qucis.queensu.CA (Mark Levison) (01/12/91)

   I have a problem with make on a Sun 3/80 running SunOs 4.0.3 that I
have spent the past two days trying to solve. The makefile in my main
working directory must be capabale of building 30+ different executables
from about 45 common source files and 1 uniques source file per
executable. Make has handled of all this nicely with just one command
line arguement. Recently I decided it would be advantageous to have my
makefile manage separate directories for each of debugabble, profiled
and clean object files and executables. I would like to add a second
command line option an addition target or a macro to choose which class
of compilation will occur each time. So far the best I have managed to
come up with is to have a separate macro DIR defined on the command
line. I define DIR to be the profile, debug or clean and then use a
pattern dependancy rule for each directory which gets the various flags
set correctly for each source compilation. The problem comes from the
fact that this requires 3 sets of rules for each executable

profiles/pr:~$(PR_OBJECTS) $(LIB_DEP)
~gcc -pg $(OPT) -o $@ $(PR_OBJECTS) $(LIB_PATH) $(LIBS)
~beep

debug/pr:~$(PR_DB_OBJECTS)
~cc -g -o $@ $(PR_DB_OBJECTS) $(DB_LIB_PATH) $(DB_LIBS)
~beep

clean/pr:~$(PR_OBJECTS) $(LIB_DEP)
~gcc $(OPT) -o $@ $(PR_OBJECTS) $(LIB_PATH) $(LIBS)
~beep

note that the important difference between debug and profiles, clean is
that for profiles and clean of source files except the one containing
the main function are placed in library, while the debugabble version
just links all of the object files. So I guess what I need is based on
the value of the second parameter to make be able to set the values for
a number of macros. Short of writing a C program or using make to call
make with all the right macros defined does anyone have any good ideas?

Mark Levison
levisonm@qucis.queensu.ca

allbery@NCoast.ORG (Brandon S. Allbery KB8JRR) (01/12/91)

As quoted from <1050@maestro.queensu.CA> by levisonm@qucis.queensu.CA (Mark Levison):
+---------------
| set correctly for each source compilation. The problem comes from the
| fact that this requires 3 sets of rules for each executable
| 
| profiles/pr:~$(PR_OBJECTS) $(LIB_DEP)
| ~gcc -pg $(OPT) -o $@ $(PR_OBJECTS) $(LIB_PATH) $(LIBS)
| ~beep
| 
| debug/pr:~$(PR_DB_OBJECTS)
| ~cc -g -o $@ $(PR_DB_OBJECTS) $(DB_LIB_PATH) $(DB_LIBS)
| ~beep
| 
| clean/pr:~$(PR_OBJECTS) $(LIB_DEP)
| ~gcc $(OPT) -o $@ $(PR_OBJECTS) $(LIB_PATH) $(LIBS)
| ~beep
+---------------

Make doesn't handle this sort of thing too well.  Two possibilities:

(1) Use four Makefiles --- one each for profiles, debug, and clean, which
define macros, and a fourth which is included into the other three and defines
the actual rules in terms of those macros.  "make -f profiles.mk", for
example, would build the profiling version.  Drawback:  since make doesn't
realize you're playing games, you must "touch" the sourrce files to force
recompilation from one form to another.

(2) Get the "shape" distribution from the comp.sources.unix archives.  It has
built-in support for this sort of thing, as well as many other features.

++Brandon
-- 
Me: Brandon S. Allbery			    VHF/UHF: KB8JRR on 220, 2m, 440
Internet: allbery@NCoast.ORG		    Packet: KB8JRR @ WA8BXN
America OnLine: KB8JRR			    AMPR: KB8JRR.AmPR.ORG [44.70.4.88]
uunet!usenet.ins.cwru.edu!ncoast!allbery    Delphi: ALLBERY

wolfgang@coma.cs.tu-berlin.de (Wolfgang Obst) (01/17/91)

In article <1991Jan12.035033.29535@NCoast.ORG> allbery@ncoast.ORG (Brandon S. Allbery KB8JRR) writes:
>
>(2) Get the "shape" distribution from the comp.sources.unix archives.  It has
>built-in support for this sort of thing, as well as many other features.
>

I'd rather recommend version 1.1 of the shape toolkit, than the
version posted to comp.sources.unix. It is available via anonymous ftp
from scam.berkeley.edu. It resides within the directory
src/netware/shape1.1/, the file is  shape-1.1pl5.tar.Z

From Europe it is available from coma.cs.tu-berlin.de, within the
directory pub.

-Wolfgang

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Wolfgang Obst  					TU Berlin FB-20 Sekr. FR 5-6
UUCP: {unido!}coma!wolfgang			Franklinstr. 28/29
BITNET: wolfgang@db0tui62		 	D-1000 Berlin (West) 10
INTERNET: wolfgang@coma.cs.tu-berlin.de
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
-- 

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Wolfgang Obst  					TU Berlin FB-20 Sekr. FR 5-6
UUCP: {unido!}coma!wolfgang			Franklinstr. 28/29