SLUG Mailing List Archives
Re: [SLUG] Using $HOME inside Makefile
- To: Michael Lake <Mike.Lake@xxxxxxxxxx>
- Subject: Re: [SLUG] Using $HOME inside Makefile
- From: John Clarke <johnc@xxxxxxxxxxxxxxxxxx>
- Date: Mon Jul 24 14:53:54 2000
- Cc: SLUG@xxxxxxxxxxx
- User-agent: Mutt/1.1.3i
On Mon, Jul 24, 2000 at 02:10:56PM +1000, Michael Lake wrote:
> cp backup $HOME/bin
> @echo 'Setting executable status...'
> chmod 750 $HOME/bin/backup
> make install is trying to do this:
> cp backup OME/bin
Change $HOME to $(HOME) or $$HOME
$(var) is the syntax for referring to make variables (or $x for single
letter or symbol variables). The variable is expanded by make before
passing it to the shell. make interprets $HOME as $(H)OME, and since $H
has no value, the result is "OME". You don't have to explicitly set
$(HOME) in your makefile. make inherits some variables from the
environment, $(HOME) is one of these.
"$$" escapes the '$' and prevents make from expanding the variable. make
passes a single '$' to the shell. So "$$HOME" becomes "$HOME". The shell
then expands the variable.