PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Forums Hébergement > Forum Serveur - Sécurité et techniques > comp.unix.shell > Makefile variables
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
comp.unix.shell Using and programming the Unix shell.

Makefile variables

Réponse
 
LinkBack Outils de la discussion
Vieux 03/12/2006, 02h58   #1
Victor Eijkhout
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Makefile variables

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
  Réponse avec citation
Vieux 03/12/2006, 03h45   #2
* Tong *
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Makefile variables

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

  Réponse avec citation
Vieux 03/12/2006, 04h56   #3
Victor Eijkhout
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Makefile variables

* 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
  Réponse avec citation
Vieux 03/12/2006, 06h20   #4
Alan Curry
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Makefile variables

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"
  Réponse avec citation
Vieux 03/12/2006, 17h33   #5
Victor Eijkhout
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Makefile variables

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
  Réponse avec citation
Vieux 04/12/2006, 00h39   #6
Kaz Kylheku
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Makefile variables

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.''

  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 13h47.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,14276 seconds with 14 queries