LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 11-25-2010, 04:05 PM   #1
littlebigman
Member
 
Registered: Aug 2008
Location: France
Posts: 658

Rep: Reputation: 35
Question [Makefile] Run command conditionally in target?


Hello

I'm learning about how to write Makefiles, and am a bit lost at how to run a command in a target depending on the value of a variable.

What I'm trying to do, is run "strip" only if the user is running a given version of a C compiler.

Here's the code:
Code:
$(LUA_T): $(LUA_O) $(LUA_A)
        $(CC) -o $@ $(MYLDFLAGS) $(LUA_O) $(LUA_A) $(LIBS)
        #FDPIC ELF binaries can be stripped, but not FLAT binaries
        $(if($(CROSS),bfin-linux-uclibc-), \
         $(STRIP) $@
        ;)
Does someone know the correct way to do this?

Thank you.
 
Old 11-25-2010, 04:27 PM   #2
ntubski
Senior Member
 
Registered: Nov 2005
Distribution: Debian, Arch
Posts: 3,780

Rep: Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081
Code:
$(LUA_T): $(LUA_O) $(LUA_A)
        $(CC) -o $@ $(MYLDFLAGS) $(LUA_O) $(LUA_A) $(LIBS)
ifeq ($(CROSS),bfin-linux-uclibc-)
        #FDPIC ELF binaries can be stripped, but not FLAT binaries
        $(STRIP) $@
endif
See Conditional Parts of Makefiles
 
Old 11-25-2010, 05:09 PM   #3
littlebigman
Member
 
Registered: Aug 2008
Location: France
Posts: 658

Original Poster
Rep: Reputation: 35
Thanks!
 
  


Reply



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
Makefile debug target StevenR Programming 1 01-11-2009 07:47 PM
makefile subdirectory target sancho1980 Linux - General 1 08-18-2008 05:25 PM
duplicated definition for a target in Makefile George2 Programming 2 05-07-2006 04:01 AM
strange target name containing % in Makefile George2 Programming 2 04-25-2006 06:28 AM
Trying to install kwvdial ,no target specified an no makefile found mtnhigh Linux - Software 0 09-27-2004 01:38 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:35 AM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration