Results 1 to 5 of 5
Hi. I'm new to make.
How do I make the variable defined in shell script to be visible to the rest of makefile?
Here is a simplified makefile:
---------------------------------
aaa ...
- 07-03-2007 #1Just Joined!
- Join Date
- Jul 2007
- Posts
- 7
help with makefile
Hi. I'm new to make.
How do I make the variable defined in shell script to be visible to the rest of makefile?
Here is a simplified makefile:
---------------------------------
aaa = mypc
all:
.PHONY: foo
foo:
var=foo1
@echo "0var is:" $(var)
@echo "1var is:" $$var
@echo "2var is:" $${var}
@echo "localhost:" $(aaa)
-------------------------------
Variable 'var' is defined as foo1 in shell script. In contrast, if I define variable 'aaa' as in the beginning, then this is visible everywhere.
Is there a way to make 'var' visible throughtout make?
Thanks
- 07-03-2007 #2Linux Engineer
- Join Date
- Apr 2006
- Location
- Saint Paul, MN, USA / CentOS, Debian, Solaris, SuSE
- Posts
- 1,117
Hi.
Make desired variables environment variables:
producing:Code:#!/bin/sh # @(#) s1 Demonstrate existence of environment shell variables in make. echo " sh version: $BASH_VERSION" >&2 cat >Makefile <<'EOF' target: @ echo " Hello, world." @ echo var1 is $(var1) @ echo var2 is $(var2) EOF echo echo " Makefile:" cat Makefile echo echo ----- echo " Results of make:" export var1="/media" make exit 0
cheers, drlCode:% ./s1 sh version: 2.05b.0(1)-release Makefile: target: @ echo " Hello, world." @ echo var1 is $(var1) @ echo var2 is $(var2) ----- Results of make: Hello, world. var1 is /media var2 isWelcome - get the most out of the forum by reading forum basics and guidelines: click here.
90% of questions can be answered by using man pages, Quick Search, Advanced Search, Google search, Wikipedia.
We look forward to helping you with the challenge of the other 10%.
( Mn, 2.6.n, AMD-64 3000+, ASUS A8V Deluxe, 1 GB, SATA + IDE, Matrox G400 AGP )
- 07-03-2007 #3Just Joined!
- Join Date
- Jul 2007
- Posts
- 7
- 07-04-2007 #4Linux Engineer
- Join Date
- Apr 2006
- Location
- Saint Paul, MN, USA / CentOS, Debian, Solaris, SuSE
- Posts
- 1,117
Hi.
If you are talking in terms of processes, a child inherits the environment from the parent, including the names and values of those variables marked as exported. A child cannot pass values back up to the parent.
If that's not substance of your question, then please provide an example of what you mean, what actually happens, and what you expect or want to happen ... cheers, drlWelcome - get the most out of the forum by reading forum basics and guidelines: click here.
90% of questions can be answered by using man pages, Quick Search, Advanced Search, Google search, Wikipedia.
We look forward to helping you with the challenge of the other 10%.
( Mn, 2.6.n, AMD-64 3000+, ASUS A8V Deluxe, 1 GB, SATA + IDE, Matrox G400 AGP )
- 09-20-2007 #5Just Joined!
- Join Date
- Apr 2007
- Posts
- 59
other way?
My requirement is same as ploceus.
But I already have a big Makefile in my clearcase vobs. So may be I can't use the method suggested by drl. to create the Makefile using shell script.
Is there any other way to achieve this ?


Reply With Quote
