Solved

About Makefile

Posted on 2004-04-09
12
331 Views
Last Modified: 2010-04-15
I have to include certain library paths only is a particular condition is true.
for example,
i need to include file.h,
INCLUDE_HEADER = file1.h file.h
only if s=1
otherwise
i need only INCLUDE_HEADER = file1.h

How can i test this condition in a Makefile.

0
Comment
Question by:aishwaria
  • 4
  • 4
  • 3
  • +1
12 Comments
 
LVL 9

Expert Comment

by:ankuratvb
ID: 10796209
0
 
LVL 11

Accepted Solution

by:
avizit earned 50 total points
ID: 10796219
ref to

http://www.gnu.org/software/make/manual/html_mono/make.html#SEC79


there is a example given which matches your requrements.

basically you have to check

ifeq($(s), 1)
 INCLUDE_HEADER = file1.h file.h
else
 etc etc etc etc ..

read the link , that should be sufficient for your purpose.

/abhijit/


0
 
LVL 11

Expert Comment

by:avizit
ID: 10796223
ankuratvb slipped in,

anyway what i said is for GNU "make"

I don't know if that will work in microsoft environ

-/abhijit/
0
 

Author Comment

by:aishwaria
ID: 10796239
Can i get the s value as a command line argument
0
 
LVL 9

Expert Comment

by:ankuratvb
ID: 10796264
>Can i get the s value as a command line argument

I am not sure about that.

Another Option.You could write a shell script for this.
0
 

Author Comment

by:aishwaria
ID: 10796274
Can you give me some examples for this.
0
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
LVL 9

Expert Comment

by:ankuratvb
ID: 10796289
#!/bin/bash
S=1
SS=$1 #first command line argument

if [ $S -eq $SS ]      
then
#ur makefile command here      
else
#ur other makefile command here
fi

Save as:urfilename.sh

Execute as:bash urfilename.sh 2
where 2 is the value of S
0
 

Author Comment

by:aishwaria
ID: 10796312
but then the makefile is executed as
make -f Makefile

So i wish if it is done something like,

make -f Makefile -d 2

where 2 is the argument

can you suggest me some way to do like this.

-aishwaria
0
 
LVL 11

Expert Comment

by:avizit
ID: 10796823
Just as a sidenote , if your makefile is named "Makefile" or "makefile"
you dont need the "-f  Makefile"

make by default looks for a file called "Makefile" failing which it looks for "makefile"

/abhijit/
0
 
LVL 9

Expert Comment

by:ankuratvb
ID: 10796885
You could do this:

#!/bin/bash
S=1
SS=$1 #first command line argument

if [ $S -eq $SS ]    
then
make -f Makefile1
else
make -f Makefile2
fi


where Makefile1 is the makefile with the first include option
and MakeFile2 is the makefile with the other option.
Hope this helps.
0
 
LVL 8

Expert Comment

by:ssnkumar
ID: 10803564
You can set some environment variables and export them.
This can be processed from inside the Makefile.

-ssnkumar
0
 
LVL 11

Expert Comment

by:avizit
ID: 10810928
from what i have gathered

using "autoconf" and "automake" sounds like a good idea but I am not good at those but if someone knows he/she can help.

/abhijit/
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Dll Dynamic way c/c++ 9 134
Which checksum is this? 7 136
C language IDE – Compilers installation 14 58
Unable to start eclipse ? 17 83
Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
An Outlet in Cocoa is a persistent reference to a GUI control; it connects a property (a variable) to a control.  For example, it is common to create an Outlet for the text field GUI control and change the text that appears in this field via that Ou…
The goal of this video is to provide viewers with basic examples to understand and use structures in the C programming language.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use for-loops in the C programming language.

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now