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

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Help in Setting Environment variables in TCSH kssandeep Shell Programming and Scripting 1 02-18-2008 05:16 AM
Setting environment variables within cron jobs!! atheek SUN Solaris 1 10-09-2006 04:26 AM
help..Environment variables... sekar sundaram UNIX for Dummies Questions & Answers 3 08-30-2005 12:35 AM
Setting up Environment Variables rpandey Shell Programming and Scripting 6 06-06-2005 06:28 AM
setting environment variables ??? Gargamel UNIX for Dummies Questions & Answers 5 06-13-2002 08:12 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 05-19-2006
Registered User
 

Join Date: May 2006
Posts: 11
Setting environment variables in Makefile

I've seen a few other threads like this, but they either went unanswered or failed to answer my question.

How do I set an environment variable in a Makefile?

What I'm trying to do is use GNU make to automate an ant build.
In order to run ant, I've got to first set a few environment variables.. ie ANT_HOME, JAVA_HOME and alter PATH.

Here's what I have in the makefile:
Code:
tinker:
        ANT_HOME=/usr/local/ant
        PATH=$${PATH}:$${ANT_HOME}/bin
        JAVA_HOME=/usr/jdk/jdk1.5.0_06
        export ANT_HOME JAVA_HOME PATH
        echo $$ANT_HOME
        echo $$JAVA_HOME
        echo $$PATH
        ant
When I run it:
Code:
> make tinker
ANT_HOME=/usr/local/ant
PATH=${PATH}:${ANT_HOME}/bin
JAVA_HOME=/usr/jdk/jdk1.5.0_06
export ANT_HOME JAVA_HOME PATH
echo $ANT_HOME

echo $JAVA_HOME

echo $PATH
.:/bin:/usr/bin:/usr/sbin:/usr/openwin/bin:/usr/dt/bin:/sbin:/usr/ucb:/usr/local/bin:/usr/local/sbin:/usr/ccs/bin
ant
make: ant: Command not found
make: *** [setdown] Error 127
As you can see via the Echo statements, my variable declarations aren't doing the trick..

Thanks for any help you can give.
Reply With Quote
Forum Sponsor
  #2  
Old 05-19-2006
Registered User
 

Join Date: May 2006
Posts: 11
The solution is:
Code:
ANT_HOME := /usr/local/ant
JAVA_HOME := /usr/jdk/jdk1.5.0_06
PATH := ${PATH}:${ANT_HOME}/bin

tinker:
        @echo ${ANT_HOME}
        @echo ${JAVA_HOME}
        @echo ${PATH}
        ant
Enjoy.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 11:56 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0