|
|
|
|
||||||
| comp.unix.shell Using and programming the Unix shell. |
![]() |
|
|
LinkBack | Outils de la discussion |
|
|
#1 |
|
Messages: n/a
Hébergeur: |
I'm stymied. What is the difference between makefile variables from the
makefile and from the commandline? [albook:~/Software/tst] %% cat Makefile NAME = LIB LIB_DIR = $HOME tst : DIR_NAME=${NAME}_DIR ; echo $${DIR_NAME} ; \ eval DIR=\$${$${DIR_NAME}} ; echo $$DIR [albook:~/Software/tst] %% make DIR_NAME=LIB_DIR ; echo ${DIR_NAME} ; \ eval DIR=\${${DIR_NAME}} ; echo $DIR LIB_DIR [albook:~/Software/tst] %% make LIB_DIR=$HOME DIR_NAME=LIB_DIR ; echo ${DIR_NAME} ; \ eval DIR=\${${DIR_NAME}} ; echo $DIR LIB_DIR /Users/eijkhout It looks wrong to me. I tried this with GNU make, both on Linux and OS X, and IBM's AIX make. Victor. -- Victor Eijkhout -- eijkhout at tacc utexas edu |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
On Sat, 02 Dec 2006 20:58:48 -0600, Victor Eijkhout wrote:
> [albook:~/Software/tst] %% cat Makefile > NAME = LIB > LIB_DIR = $HOME Try LIB_DIR = ${HOME} -- Tong (remove underscore(s) to reply) http://xpt.sourceforge.net/ -- Posted via a free Usenet account from http://www.teranews.com |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
* Tong * <sun_tong_001@users.sourceforge.net> wrote:
> On Sat, 02 Dec 2006 20:58:48 -0600, Victor Eijkhout wrote: > > > [albook:~/Software/tst] %% cat Makefile > > NAME = LIB > > LIB_DIR = $HOME > > Try > > LIB_DIR = ${HOME} Makes no difference. It produces no output; I was expecting it to output the value of HOME, or, with the missing braces "OME". Victor. -- Victor Eijkhout -- eijkhout at tacc utexas edu |
|
|
|
#4 |
|
Messages: n/a
Hébergeur: |
In article <1hpqksd.1bkdpylrnuvdnN%see@sig.for.address>,
Victor Eijkhout <see@sig.for.address> wrote: >I'm stymied. What is the difference between makefile variables from the >makefile and from the commandline? > >[albook:~/Software/tst] %% cat Makefile >NAME = LIB >LIB_DIR = $HOME > >tst : > DIR_NAME=${NAME}_DIR ; echo $${DIR_NAME} ; \ > eval DIR=\$${$${DIR_NAME}} ; echo $$DIR > ${LIB_DIR} is neither exported to the environment nor created as a shell variable, so the shell doesn't know about it. When you override LIB_DIR on the make command line, it gets exported. This behavior is mandated by http://www.opengroup.org/onlinepubs/...ies/make.html: Before the makefile(s) are read, all of the make utility command line macro definitions (except the MAKEFLAGS macro or the SHELL macro) shall be added to the environment of make. Other implementation-defined variables may also be added to the environment of make. and in the rationale: Macros are not exported to the environment of commands to be run. This was never the case in any historical make and would have serious consequences. The environment is the same as the environment to make except that MAKEFLAGS and macros defined on the make command line are added. GNU make offers the "export" command or the magical .EXPORT_ALL_VARIABLES target which you could use here, but the portable way would be an explicit assignment to a shell variable like this: tst : LIB_DIR="${LIB_DIR}" ; \ DIR_NAME=${NAME}_DIR ; echo $${DIR_NAME} ; \ eval DIR=\$${$${DIR_NAME}} ; echo $$DIR Of course this does introduce quoting problems if ${LIB_DIR} expands to something containing quote characters, but you already have problems in the case that ${NAME} expands to something containing nasty characters so I assume that's not a problem. -- The attacker\x92s overall goal would very probably be to convince other users to run an unsafe program, by using the digital signature to convince them that it is actually bona fide Microsoft software and therefore safe to run. -- security bulletin MS01-017 ushers in a new definition of "safe" |
|
|
|
#5 |
|
Messages: n/a
Hébergeur: |
Alan Curry <pacman@TheWorld.com> wrote:
> ${LIB_DIR} is neither exported to the environment nor created as a shell > variable, so the shell doesn't know about it. When you override LIB_DIR on > the make command line, it gets exported. That's it. Thanks very much. Victor. -- Victor Eijkhout -- eijkhout at tacc utexas edu |
|
|
|
#6 |
|
Messages: n/a
Hébergeur: |
Victor Eijkhout wrote:
> I'm stymied. What is the difference between makefile variables from the > makefile and from the commandline? Straight from the GNU Make manual: ``When `make' is invoked recursively, variables defined in the outer invocation can be passed to inner invocations through the environment (*note Recursive Use of `make': Recursion.). By default, only variables that came from the environment or the command line are passed to recursive invocations. You can use the `export' directive to pass other variables.'' |
|
![]() |
| Outils de la discussion | |
|
|