DESTDIR usage

Bob Proulx bob at proulx.com
Wed Jun 11 02:51:58 EST 2008


Matthew L. Creech wrote:
> > make DESTDIR=/tmp/foo install
> 
> Oh, I thought "DESTDIR=/tmp/foo make install" was equivalent, but
> apparently not.

The 'make VARIABLE=value' form is interpreted by make itself as a
variable and overrides variables in the Makefile.  The other form
'VARIABLE=value command' is a shell variable assignment for just that
one specific command.  In this case since 'make' is the command this
would modify the environment passed to make.  The shell interprets the
assignment and sets up a modified environment for that command.  But
it is only an environment variable at that point and not yet a make
variable.  There is an option to force environment variables to
override Makefile variables but since that isn't what you want to do
here I won't mention it by name and possibly distract someone.

Note that 'VARIABLE=value command' is a Bourne/POSIX syntax and
doesn't work for csh users.  Therefore it isn't considered a universal
syntax.  The 'env' command is used when instructions to set
environment variables for a single command need to be shell
independent.  With 'env VARIABLE=value command' then the env command
interprets the assignment and creates an environment to pass along to
the command process and is independent of whichever shell the user is
running at the time.

In summary: You really did want the 'make VARIABLE=value' form.

Bob


More information about the openssh-unix-dev mailing list