LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 10-25-2012, 04:14 AM   #1
rambolinuxbuddy
LQ Newbie
 
Registered: Sep 2012
Posts: 16

Rep: Reputation: Disabled
.PHONY in makefile


hello all,

SUBDIRS = foo bar baz

.PHONY: dirs $(SUBDIRS)

dirs: $(SUBDIRS)

$(SUBDIRS):
@echo $@
@ls $@

any body can just help me out to understand this make-file as soon as possible.
If possible explain me each statment(why do we need it? , what is the purpose? etc.)

and how exactly this make-file works?

Last edited by rambolinuxbuddy; 10-25-2012 at 04:21 AM.
 
Old 10-25-2012, 05:56 AM   #2
pan64
Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian i686 (solaris)
Posts: 5,035

Rep: Reputation: 1336Reputation: 1336Reputation: 1336Reputation: 1336Reputation: 1336Reputation: 1336Reputation: 1336Reputation: 1336Reputation: 1336Reputation: 1336
http://www.gnu.org/software/make/man...y-Targets.html
 
Old 10-25-2012, 06:23 AM   #3
rambolinuxbuddy
LQ Newbie
 
Registered: Sep 2012
Posts: 16

Original Poster
Rep: Reputation: Disabled
I had that link already.
anyways I tried it with myself and I found out the solution how exactly it works.

---------- Post added 10-25-12 at 05:24 AM ----------

explanation of code is as below:-

first line assignes list "foo bar baz" to variable named SUBDIRS

second line is special command that makes all specified targets 'phonetical' - you can invoke "make dirs" or "make foo", and it will find target with that name and execute it, but it's no actual file with this name (like usual non-phony targets)

third one - creates target named 'dirs' which depends on value of SUBDIRS variable. space-separated list. this target have no real actions

fourth line creates rules for SUBRIDS variable contents, with no dependencies. The rest of text is actions that have to be performed to 'make' this target (so, in your case - if you just call "make", it will call "make dirs" (because it's the first target), which depends on foo, bar and baz - so these targets will be invoked. to perform each of these targets, make will call echo and ls - so eventually you'll get these three directory names and list of their files)
 
  


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
[SOLVED] need of makefile info ? how the linux make file is different from simple c makefile ? rpittala Linux - Newbie 2 05-07-2012 09:04 PM
LXer: Phony SSL Certificates issued for Google, Yahoo, Skype, Others LXer Syndicated Linux News 0 03-25-2011 10:10 AM
Phony Yahoo Webcam janedthompson General 2 03-16-2007 05:49 AM
makefile (.PHONY) blackzone Programming 1 03-03-2005 05:39 AM


All times are GMT -5. The time now is 06:44 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