LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 08-27-2006, 05:03 AM   #1
George2
Member
 
Registered: Oct 2003
Posts: 354

Rep: Reputation: 30
a strange make rule


Hello everyone,


Here is a sample make file.

SRC=foo.c
PROC=$(SRC:%.c=%.o)
TARGET=$(PROC:%.o=$(TARGET_DIR)/%.o)

I know the first two lines mean compile *.c defined in SRC to *.o. But what does the 3rd line mean? Convert *.o generated by PROC to *.o? I am confused that why convert *.o to *.o itself?


thanks in advance,
George
 
Old 08-27-2006, 09:34 AM   #2
tuxdev
Senior Member
 
Registered: Jul 2005
Distribution: Slackware
Posts: 2,012

Rep: Reputation: 111Reputation: 111
Note the "$(TARGET_DIR)". Many build systems want the object files in a seperate directory because then the object files aren't cluttering up the src directory. It is easier to work in the source when you don't have object files around. "make clean" is really simple too.
 
Old 08-28-2006, 02:52 AM   #3
George2
Member
 
Registered: Oct 2003
Posts: 354

Original Poster
Rep: Reputation: 30
Thank you tuxdev,


Quote:
Originally Posted by tuxdev
Note the "$(TARGET_DIR)". Many build systems want the object files in a seperate directory because then the object files aren't cluttering up the src directory. It is easier to work in the source when you don't have object files around. "make clean" is really simple too.
I have also made some tests on this case. I think in my case, TARGET macro simply prefix $(TARGET_DIR) to each string items in PROC macro. Am I correct?


regards,
George
 
Old 08-28-2006, 12:30 PM   #4
tuxdev
Senior Member
 
Registered: Jul 2005
Distribution: Slackware
Posts: 2,012

Rep: Reputation: 111Reputation: 111
That is what I think it does as well. I'm not entirely certain about the make-foo, but it makes sense. I have yet to find decent online docs with an explanation of all the neat make features nobody knows about.
 
  


Reply


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
make: *** No rule to make target `mrproper'. Stop. dauphinfay Linux - General 6 10-16-2009 12:29 AM
lopster v1.2.2 make error: No rule to make target `m4/glibc21.m4' Kropotkin Fedora 0 10-31-2004 11:19 AM
make: *** No rule to make target 'gconfig'. Stop. cswake Slackware 4 10-10-2004 12:13 PM
How to make rule for make install and make uninstall melinda_sayang Programming 1 06-14-2004 05:58 AM
strange rule about this website moeminhtun LQ Suggestions & Feedback 10 01-21-2003 07:30 PM


All times are GMT -5. The time now is 11:16 AM.

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