[news.software.b] Configuring make

flee@shire.cs.psu.edu (Felix Lee) (02/02/90)

Systems I know let you say something like
	make -f ../conf/make.defs -f ./Makefile
This is flexible enough to handle mildly complex configuration
problems.  Are there systems where this will not work?
--
Felix Lee	flee@shire.cs.psu.edu	*!psuvax1!flee

gam@netcom.UUCP (Gordon Moffett) (02/02/90)

In smail 3.1 all the Makefiles use common defs.sh to set environment
variables, then refer to them in the same line, like so:

	. defs.sh ; cc $$CFLAGS -c foo.c

... CFLAGS is set from defs.sh rather than in the Makefile itself.
How's that?
-- 
Gordon Moffett                            gam@netcom.UUCP
                                          {apple,amdahl}!netcom!gam

henry@utzoo.uucp (Henry Spencer) (02/03/90)

In article <Csic,52@cs.psu.edu> flee@shire.cs.psu.edu (Felix Lee) writes:
>Systems I know let you say something like
>	make -f ../conf/make.defs -f ./Makefile
>This is flexible enough to handle mildly complex configuration
>problems.  Are there systems where this will not work?

We *think* this is fairly universal -- it was in the V7 manual, so anyone
who hasn't implemented it *really* wasn't paying attention -- and it's the
leading candidate mechanism for dealing with the problem.
-- 
1972: Saturn V #15 flight-ready|     Henry Spencer at U of Toronto Zoology
1990: birds nesting in engines | uunet!attcan!utzoo!henry henry@zoo.toronto.edu

henry@utzoo.uucp (Henry Spencer) (02/03/90)

In article <6481@netcom.UUCP> gam@netcom.UUCP (Gordon Moffett) writes:
>In smail 3.1 all the Makefiles use common defs.sh to set environment
>variables, then refer to them in the same line, like so:
>	. defs.sh ; cc $$CFLAGS -c foo.c

Trouble is, we'd have to modify a *lot* of lines of makefiles to do this.
I'd prefer a less intrusive approach.
-- 
1972: Saturn V #15 flight-ready|     Henry Spencer at U of Toronto Zoology
1990: birds nesting in engines | uunet!attcan!utzoo!henry henry@zoo.toronto.edu

sean@ms.uky.edu (Sean Casey) (02/03/90)

|In article <Csic,52@cs.psu.edu> flee@shire.cs.psu.edu (Felix Lee) writes:
|>Systems I know let you say something like
|>	make -f ../conf/make.defs -f ./Makefile
|>This is flexible enough to handle mildly complex configuration
|>problems.  Are there systems where this will not work?

This is precisely the system I use for large software packages.

I stole the idea from the MMDFII sources.

Sean
-- 
***  Sean Casey          sean@ms.uky.edu, sean@ukma.bitnet, ukma!sean
***  "May I take this opportunity of emphasizing that there is no cannibalism
***  in the British Navy. Absolutely none, and when I say none, I mean there
***  is a certain amount, more than we are prepared to admit." -MP

rick@pcrat.uucp (Rick Richardson) (02/06/90)

In article <1990Feb2.164229.16968@utzoo.uucp> henry@utzoo.uucp (Henry Spencer) writes:
>In article <Csic,52@cs.psu.edu> flee@shire.cs.psu.edu (Felix Lee) writes:
>>Systems I know let you say something like
>>	make -f ../conf/make.defs -f ./Makefile
>
>We *think* this is fairly universal -- it was in the V7 manual, so anyone
>who hasn't implemented it *really* wasn't paying attention -- and it's the
>leading candidate mechanism for dealing with the problem.

[ Sorry, I had to delete a lot of Refs to followup to this.
  rn gave me interp buffer overflow -Rick ]

One way to accomplish this without having to teach a new command
or even to require an alias be set up is to use the make-ism
of looking first for "makefile" before "Makefile". E.G.:

========makefile=========
	.c .sh \
	.c~ sh~ \
	.c.o .c.a .l.c .l.o .y.c .y.o \
	.c~.c .sh~.sh .y~.y .l~.l .h~.h .c~.a .c~.o .l~,c .l~.o .y~.c .y~.o \
	all install clean clobber lint:
		make -f ../config/Makefile.lcl -f Makefile $@
========../config/Makefile.lcl=========
	CFLAGS=-c -g -DSVR4
========Makefile=========
	all: xxx

	xxx:	xxx.o
		$(CC) $(CFLAGS)	xxx.o -o $@
	...etc...
=========================

The "makefile" is a little cumbersome because you have to explicitly
list all of the targets that you want the user to be allowed to make.
But you do have the advantage that "Makefile" looks conventional,
all of the local settings can be in one file, and typing "make" in
a directory does what you'd expect.  You can also make the
targets in "makefile" depend on "../config/Makefile.lcl" (or whatever)
and force execution of whatever it is that makes "Makefile.lcl"
in the first place.

-Rick Richardson