LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
Search this Thread
Old 10-20-2009, 01:54 PM   #1
xoham
LQ Newbie
 
Registered: Jun 2009
Posts: 5

Rep: Reputation: 0
changing variables in Makefiles


Hello,

I'd like to be able to set variables to certain values depending on what the initial build target is:

> make abc
... set variables appropriate for building abc

> make cde
... set variables appropriate for building cde

The reason I want to do this is to share common functions in the makefile.

Any help is appreciated, thanks.
 
Old 10-20-2009, 03:42 PM   #2
TB0ne
Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 14,405

Rep: Reputation: 2529Reputation: 2529Reputation: 2529Reputation: 2529Reputation: 2529Reputation: 2529Reputation: 2529Reputation: 2529Reputation: 2529Reputation: 2529Reputation: 2529
Quote:
Originally Posted by xoham View Post
Hello,

I'd like to be able to set variables to certain values depending on what the initial build target is:

> make abc
... set variables appropriate for building abc

> make cde
... set variables appropriate for building cde

The reason I want to do this is to share common functions in the makefile.

Any help is appreciated, thanks.
Not a problem...alot of programs out there have install/configure scripts. Have you looked at any of them?

I'd set up a "configure" script, and have it take a command line variable, and spit out the Makefile accordingly. Post what you've written so far, and where you're getting stuck, and we can help.
 
Old 10-21-2009, 09:25 AM   #3
xoham
LQ Newbie
 
Registered: Jun 2009
Posts: 5

Original Poster
Rep: Reputation: 0
more

I'd like to do it all in the Makefile if possible.

In the Makefile:


abc:
DEST_DIR = $(ABC_DEST_DIR)
make copyfiles

xyz:
DEST_DIR = $(XYZ_DEST_DIR)
make copyfiles

copyfiles:
mkdir -p $(DEST_DIR)
cp * $(DEST_DIR)



What I've found is that any variables I set in abc only have scope within abc. But I'd like to have common build targets like copyfiles. Assume correct indentation (it doesn't want to show up).

Last edited by xoham; 10-21-2009 at 09:27 AM.
 
  


Reply

Tags
makefile


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
changing variables using user-input Kai' Linux - General 3 04-29-2008 06:04 PM
changing environment variables. Geminias Linux - Newbie 2 01-04-2006 06:02 PM
changing variables from background job bobwall Programming 2 06-18-2005 02:28 PM
changing php info variables?? vickr1z Linux - Newbie 1 10-26-2004 10:16 AM
Makefiles and shell variables Snabber Linux - Software 1 08-05-2003 11:23 PM


All times are GMT -5. The time now is 09:22 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration