Processing Arguments pased to Makefile


 
Thread Tools Search this Thread
Top Forums Programming Processing Arguments pased to Makefile
# 1  
Old 02-08-2013
Processing Arguments pased to Makefile

I have a makefile and want to allow passing -01 -02 -03 for the user to define
the level of optimization he wants. Doing this gets make to send an error.

Code:
make -03
make: invalid option -- '0'
make: invalid option -- '3'
Usage: make [options] [target] ...

# 2  
Old 02-08-2013
Try setting an environment variable you can test in a makefile to modify the make variable that goes on compile lines.
Else, define different targets and set the variable differently in each, like 'make unopt' and 'make optimum'.

You can also remove debugging support (-g in some compilers) and strip the objects when you optimize harder.

Last edited by DGPickett; 02-08-2013 at 05:05 PM..
# 3  
Old 02-08-2013
I am trying to check if the environment variable is O2 and make is
complaining when I use the following:

Code:
ifeq ($(OPMZ), O2)
 @echo "OPTIMIZATION_LEVEL = $(OPMZ)"
endif

# 4  
Old 02-08-2013
Did you export it?
# 5  
Old 02-08-2013
This is the error

Code:
ifeq (02, O2)
/bin/sh: -c: line 0: syntax error near unexpected token `02,'
/bin/sh: -c: line 0: `ifeq (02, O2)'
make: *** [help] Error 2

---------- Post updated at 05:57 PM ---------- Previous update was at 05:12 PM ----------

Fixed it. Needed tab

---------- Post updated at 10:59 PM ---------- Previous update was at 05:57 PM ----------

I want to set OPMZ to O2 if the value of OPMZ is not
in O1, O2, or O3.

The following is not working

Code:
ifeq ($(OPMZ), O1)
# do nothing
else ifeq ($(OPMZ), O2)
# do nothing
else ifeq ($(OPMZ), O3)
# do nothing
else
OPMZ = 02
endif


Last edited by kristinu; 02-09-2013 at 12:21 AM..
# 6  
Old 02-11-2013
Is this gnu make? You might want quoting on the constant, but gnu make seem pretty free-wheeling: GNU make - Conditional Parts of Makefiles

Normally, you just put the optimization arguments in an exported environment variable, and put them in the CFLAGS line. No optimization is a blank or unset variable. Either that, or a different make target name as I mentioned above.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Processing arguments in a string

Hi The following code works when reading the arguments from the command line but fails when I try to read from a string. So this works while ; do case $1 in -dbversion) if '`" ]; then { echo "ERROR: missing value for '$1' (seen '$2')"; usage; exit 1; } else { shift;... (6 Replies)
Discussion started by: user052009
6 Replies

2. Programming

Passing arguments to customized makefile

Hello, How to pass arguments to make thru command line? Have read this and that threads, but still not clear. My customized Makefile as: # convert_program.mk: run: bash bash_srcipt.sh clean: rm ${OUT_PATH}/result.txtWhat I intend is to run like this: $ make -f convert_progam.mk... (4 Replies)
Discussion started by: yifangt
4 Replies

3. Shell Programming and Scripting

Processing Multiple Arguments in Command Line Options

Hi All, I am new to scripting. Could you please assist me . Here is my requirement. I have written a script that has 2 option flags defined. -l) calls some function with the arguments passed in front of -l -r) calls second function with the arguments passed in front of -r *) calls the... (7 Replies)
Discussion started by: Jay Deshpande
7 Replies

4. Programming

awk processing / Shell Script Processing to remove columns text file

Hello, I extracted a list of files in a directory with the command ls . However this is not my computer, so the ls functionality has been revamped so that it gives the filesizes in front like this : This is the output of ls command : I stored the output in a file filelist 1.1M... (5 Replies)
Discussion started by: ajayram
5 Replies

5. Shell Programming and Scripting

To pass arguments to makefile using script

Hi, I want to run a target of makfile using script by passing different arguments to it again n again. I i need to grep certain things from the log file. eg make abc KAB=8 BAC=8 >& KAB_BAC.log grep "timeA" KAB_BAC.log grep "timeB" KAB_BAC.log (i want to store the difference of the two time... (0 Replies)
Discussion started by: vdhingra123
0 Replies

6. Shell Programming and Scripting

grep with two arguments to arguments to surch for

Hello, is it possible to give grep two documents to surche for? like grep "test" /home/one.txt AND /home/two.txt ? thanks (1 Reply)
Discussion started by: Cybertron
1 Replies

7. Homework & Coursework Questions

Help with Simple Multi-Level Makefile (Extremely New at Makefile)

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: Basically, the prompt is make a makefile with various sub makefiles in their respective subdirectories. All code... (1 Reply)
Discussion started by: Tatl
1 Replies

8. Shell Programming and Scripting

How to make parallel processing rather than serial processing ??

Hello everybody, I have a little problem with one of my program. I made a plugin for collectd (a stats collector for my servers) but I have a problem to make it run in parallel. My program gathers stats from logs, so it needs to run in background waiting for any new lines added in the log... (0 Replies)
Discussion started by: Samb95
0 Replies

9. UNIX for Advanced & Expert Users

Makefile executing another Makefile first?

I have 2 libraries in 2 different directories that I build with Makefiles. library B depends on library A. If I modify a .cpp file in library A and run lib B's Makefile can I have B's makefile to automatically rebuild library A? I am now rebuilding A, followed by B... but I'd like B to... (0 Replies)
Discussion started by: wwuster
0 Replies

10. UNIX for Advanced & Expert Users

Makefile problem - How to run module load in a Makefile

Hi, I'm trying to run the module load command in a Makefile and i'm getting the following error: make: module: command not found Why is this? Is there any way to run this command in a Makefile? NOTE: command - module load msjava/sunjdk/1.5.0 works fine outside of the Makefile (2 Replies)
Discussion started by: hernandinho
2 Replies
Login or Register to Ask a Question