[comp.sys.hp] makefile macros from ext. source?

bmiddleb@speclab.bgp-usgs.gov (Barry J. Middlebrook) (06/07/89)

Here's the problem:  We need a clean way of executing make files so
that regardless of the system configuration and type of UNIX the 
appropriate options are used.  We are currently using an HP 9000
series 825 and a Sun 3 w/floating point accelerator.  The method
that seems most appropriate to us is to have the compiler options
specific to the machine stored as a string in an ASCII file called,
for instance, /usr/local/include/make.FFLAGS.  Inside the make file
is the command structure to assign that string to a macro.  As an
example, we would have the string
-ffpa -O -C
in the make.FFLAGS file and we wish to assign that string to the
macro FFLAGS in the make file so that the command
f77 $(FFLAGS) -c filename.f

is interpreted as
f77 -ffpa -O -C -c filename.f

Some of the unsuccessful ways we have attempted to do this are
structures in the make file as follows:

all:
	(sh FFLAGS="'cat /usr/local/include/make.FFLAGS'"; export FFLAGS)

Another attempt (which also didn't work) was

all:
	sh export FFLAGS\; $${FFLAGS:-"'cat /usr/local/include/make.FFLAGS'"}

We have also tried many variations on these themes with no success.
Sometimes it assigns the macro but then bombs because it tries to
execute the option string as a shell command and at other times
won't assign the macro at all or only part of the string.  If you
have any ideas on how we can solve this problem please reply.

fkittred@bbn.com (Fletcher Kittredge) (06/09/89)

In article <210014@speclab.bgp-usgs.gov> bmiddleb@speclab.bgp-usgs.gov (Barry J. Middlebrook) writes:
>Here's the problem:  We need a clean way of executing make files so
>that regardless of the system configuration and type of UNIX the 
>appropriate options are used.  We are currently using an HP 9000
>series 825 and a Sun 3 w/floating point accelerator.

Three methods:

1) Do what we do and make the macro definition on the command line:

make FFLAGS="+bfpa" ...

2) or use gnumake and include files.  Gnumake runs on both systems and
   is available via anonymous ftp from prep.ai.mit.edu.

3) or use the make -e flag to have the value of environmental
   variables override the value of variables in the makefile.
Fletcher E. Kittredge  fkittred@bbn.com