[comp.unix.wizards] How to get $

jwm@renoir.Berkeley.EDU (Jeff Mc Carrell) (07/01/87)

    We run SunOS 3.x and BSD 4.3 around here and I have a number of
programs that I compile just for my bin.  I'd like to have an incantation
that is portable across these 2 systems that will expand to my home
directory.  Currently I use:

HDIR	      = $${HOME}

which expands to ${HOME} which when passed directly to the shell works
just fine.  This is fine for things like:

install:	$(PROGRAM)
		@install -c -s $(HDIR)/bin foo

but doesn't work in something like:

DEST	      = $(HDIR)/bin

install:	$(DEST)/$(PROGRAM)

because $(DEST) expands to $(HDIR)/bin expands to ${HOME}/bin and BSD
make doesn't know how to evaluate that.  SunOS make works fine because it
reads all of the environment variables, so ${HOME} is known.

Has anyone thought of a good solution for this problem?

						jeff
						jwm@renoir.Berkeley.EDU
						...!ucbvax!jwm

chris@mimsy.UUCP (Chris Torek) (07/01/87)

In article <19550@ucbvax.BERKELEY.EDU> jwm@renoir.Berkeley.EDU (Jeff
Mc Carrell) writes:
>... I'd like to have an incantation that is portable across these 2
>systems that will expand to my home directory.  [With the omitted
>definitions,] $(DEST) expands to $(HDIR)/bin expands to ${HOME}/bin
>and BSD make doesn't know how to evaluate that.  SunOS make works
>fine because it reads all of the environment variables, so ${HOME}
>is known.

The trick, then, is to pass all environment variables into make,
without changing make.  Surprise, this is easy.  Arthur Olson's
script to the rescue:

	% cat bin/make
	#! /bin/csh -f
	exec /bin/make $*:q "`printenv`"
	% 

This does slow make noticeably on, e.g., 750s.  I use it anyway.
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7690)
Domain:	chris@mimsy.umd.edu	Path:	seismo!mimsy!chrs l

hasch@siemens.UUCP (Harald Schaefer) (07/01/87)

One way i can see is to path the value of $HOME on the command line.

	make HOME=$HOME ....

You can set an alias for this kind of make invokation.

Harald