[net.unix-wizards] Making makefiles portable

jon@csvax.caltech.edu (04/18/86)

	Does anyone have suggestions on producing makefiles which
are portable between BSD and Sys{III,V}? I am stuggling with this
due to our recent acquisition of some Sys V machines. The most
obvious problems I have found are:
	use of MFLAGS in BSD as opposed to MAKEFLAGS 
	different options accepted by lint, cc, etc.
	need to define SHELL= or SHELL=/bin/sh to Sys V make
		(if the environment variable SHELL is not sh)
		in order to get sh constructs in make targets
		to work

	The obvious approach is to put #ifdefs in makefiles just
like in C code and run makefiles through cpp, but this is inelegant
(especially to the person who receives a copy of your code and just
wants to type 'make'). In addition, there's no guarantee cpp will
be available everywhere (say if the functionality is built into the
C compiler).

    Jon Leech (jon@csvax.caltech.edu || ...seismo!cit-vax!jon)
    Caltech Computer Science Graphics Group
    __@/

moss@BRL.ARPA (04/18/86)

	What I do, is set things up in the Makefile like so:

BSD_CFLAGS=-g -O -DBSD
S52_CFLAGS=-O
BSD_LIBES=-lfb -lrt
S52_LIBES=${S5_LIBDIR}/libfb.a ${S5_LIBDIR}/librt.a
CFLAGS=${S52_CFLAGS}	#default is System V Rev. 2
LIBES=${S52_LIBES}
SHELL=/usr/5bin/sh
...
	Then I have a shell script called "make_bsd" which looks like:
#!/bin/sh
make CC=/bin/cc LIBES=\${BSD_LIBES} CFLAGS=\${BSD_CFLAGS} SHELL=/bin/sh $*

	If BSD make doesn't recognize MAKEFLAGS, and MFLAGS isn't recognized
by Sys V, it shouldn't hurt to define both in the makefile.

	My complaint is that the Gould UTX loader requires a "-m" option to
increase the stack allocation, and other loaders barf on it.  This makes
things even messier.

-moss