LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
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 01-20-2004, 11:02 AM   #1
clockworks
Member
 
Registered: Dec 2003
Location: texas
Distribution: fedora core 1, fedora core 2
Posts: 37

Rep: Reputation: 15
how to write a recursive "make clean"?


lets say i have a Makefile that looks like this:
Code:
SUBDIRS = src lib doc man

default: $(SUBDIRS)

$(SUBDIRS):
ifeq ($(ARCH),LINUX)
        @echo ARCH=LINUX
endif
ifeq ($(ARCH),SUN)
        @echo ARCH=SUN
endif
        cd $@ && $(MAKE)

clean:

.PHONY: $(SUBDIRS)
how would i flesh out the "clean" target? i tried writing a for loop, but it didn't work...

thanks for the help.
 
Old 01-20-2004, 11:49 AM   #2
jtshaw
Senior Member
 
Registered: Nov 2000
Location: Seattle, WA USA
Distribution: Ubuntu @ Home, RHEL @ Work
Posts: 3,892
Blog Entries: 1

Rep: Reputation: 66
What I usually do is write a Makefile in each sub directory that gets properties from the main makefile. So the main Makefile sets up the variables and calls the other Makefiles. The make clean would simply call the make clean in each subdirectory and the individual make files handle deleting the object code and such.
 
Old 01-20-2004, 12:19 PM   #3
clockworks
Member
 
Registered: Dec 2003
Location: texas
Distribution: fedora core 1, fedora core 2
Posts: 37

Original Poster
Rep: Reputation: 15
Quote:
Originally posted by jtshaw
What I usually do is write a Makefile in each sub directory that gets properties from the main makefile. So the main Makefile sets up the variables and calls the other Makefiles. The make clean would simply call the make clean in each subdirectory and the individual make files handle deleting the object code and such.
right. i'm sorry, but could you show me a small example. i'm just having a hard time with the syntax. thank you.
 
  


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
How to write a bash script to replace all "KH" to "K" in file ABC??? cqmyg5 Slackware 4 07-24-2007 10:00 AM
"make clean" caused system freeze, kernel panic on reboot jwhill2000 Linux - General 3 02-08-2005 08:59 PM
what is difference between "reset" and "clean " commands? zameer_india Linux - Newbie 2 01-10-2005 07:23 AM
When "make install clean" ports fails everytime! Devboy *BSD 9 08-11-2004 08:46 PM
Compiling Error "make: *** [all-recursive-am] Error 2" Jadewolf Linux - Software 5 10-02-2003 04:06 AM


All times are GMT -5. The time now is 09:54 PM.

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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration