The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Child Killing Parent mark007 UNIX for Advanced & Expert Users 4 03-09-2009 01:57 PM
How to export a variable from a child process running in background to the parent aixjadoo Shell Programming and Scripting 3 11-14-2008 05:35 AM
Parent child Relation !! using awk/sed ??? varungupta UNIX for Advanced & Expert Users 0 01-29-2008 02:24 PM
Parent/Child Processes yoi2hot4ya Shell Programming and Scripting 2 05-31-2006 02:27 PM
kill parent and child larry UNIX for Dummies Questions & Answers 4 01-12-2003 12:18 AM

 
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 09-30-2009
Shompis Shompis is offline
Registered User
  
 

Join Date: Sep 2009
Posts: 8
Makefile: Parent - Child Inheritance and export

Hi,

I have a number of Makefiles, including a couple of files that I include in Makefiles, a few scripts that are executed through Makefiles, and I have problems with environment variables that are not inherited to the scripts properly.

Simplified scenario:

rootdir/Makefile:

Code:

all:
     ${MAKE} -C mk alla
rootdir/mk/Makefile:

Code:

export TARGET:= x86

include rootdir/mk/common.mk

alla:
       @echo I am in mk/Makefile
rootdir/mk/common.mk

Code:

$(shell ./print_target.sh)
rootdir/mk/print_target.sh

Code:

#/bin/bash

echo Target is: $TARGET  1>&2
And when I run rootdir/Makefile

I get

Target is:
I am in mk/Makefile


that is, the shell script did not inherit the TARGET environment variable.
However, if I put the export TARGET:= x86 in the root/Makefile instead, then the shell script does inherit the TARGET environment variable, i.e.

Target is: x86
I am in mk/Makefile


Why is that? And what is the solution?

I think I do understand that export will spawn a new child process, thus the makefile where the export is in, can not see it, which is also true for the include as it expands the common.mk.. But I thought that when you run a script, it will also create a child process and it will inherit the export environment variable??

Thanks in advance!
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 05:25 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0