LinuxQuestions.org
Review your favorite Linux distribution.
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 02-14-2011, 06:25 AM   #1
HarryBoy
Member
 
Registered: Apr 2008
Distribution: MontaVista Linux Version 4.0.1, Professional Edition
Posts: 215

Rep: Reputation: 16
make clean question


When I run:
make -f mymakefile clean I get:
rm -f mybinary *.so.* *.dep *.o mybinary.sym

and all the above files are removed from the current directory.

But I have a directory /src/ where I have all my source files located. The *.o file in this directory are not removed?

How can I get these to be removed when I do a clean?
 
Old 02-14-2011, 06:27 AM   #2
Aquarius_Girl
Senior Member
 
Registered: Dec 2008
Posts: 4,731
Blog Entries: 29

Rep: Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940
Have you tried make distclean?
 
Old 02-14-2011, 06:32 AM   #3
HarryBoy
Member
 
Registered: Apr 2008
Distribution: MontaVista Linux Version 4.0.1, Professional Edition
Posts: 215

Original Poster
Rep: Reputation: 16
make -f mymakefile distclean

gives me this error:
make: *** No rule to make target `distclean'. Stop.

Is there no way to do it simply with 'clean'??
Can I put someting in my make file to tell it to recurse into my /src/ folder???
 
Old 02-14-2011, 06:53 AM   #4
dwhitney67
Senior Member
 
Registered: Jun 2006
Location: Maryland
Distribution: Kubuntu, Fedora, RHEL
Posts: 1,541

Rep: Reputation: 335Reputation: 335Reputation: 335Reputation: 335
Try something extremely basic like:
Code:
clean :
        $(RM) src/*.o
However, I'm a bit surprised that your Makefile does not have an alias for the object files that you want removed. Here's a real simple Makefile (for a C project) where the source code is in the src/ directory:
Code:
APP     = myapp

SRCS    = $(wildcard src/*.c)
OBJS    = $(SRCS:.c=.o)

CFLAGS  = -Wall -pedantic -c

LDFLAGS =

.PHONY: all clean distclean


all : $(APP)

$(APP) : $(OBJS)
        $(CC) $^ $(LDFLAGS) -o $@

%.o : %.c
        $(CC) $(CFLAGS) $^ -o $@

clean :
        $(RM) $(OBJS)

distclean : clean
        $(RM) $(APP)

Last edited by dwhitney67; 02-14-2011 at 06:54 AM.
 
Old 02-14-2011, 07:01 AM   #5
HarryBoy
Member
 
Registered: Apr 2008
Distribution: MontaVista Linux Version 4.0.1, Professional Edition
Posts: 215

Original Poster
Rep: Reputation: 16
I added:
CLEANFILES= src/*.o

to my make file and it now works:

make -f mymakefile clean
rm -f mybinary *.so.* *.dep *.o mybinary.sym src/*.o

thanks, your comments helped me understand this.
 
  


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
Difference between make mrproper and make clean? hottdogg Slackware 5 03-11-2013 02:31 PM
what is the difference between make distclean and make clean? alice95089 Linux - Software 3 08-28-2008 01:22 AM
Use of 'make mrproper' and 'make clean'.... fenice1976 Linux - Software 6 05-25-2004 05:18 PM
make clean, make dep problem carscht Linux - Newbie 2 02-21-2004 10:32 AM
make dep,make clean,make bzImage problem Babba Linux - Newbie 2 01-08-2003 03:49 AM

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

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