Help answer threads with 0 replies.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 11-17-2005, 11:11 PM   #1
LQ Newbie
Registered: Oct 2005
Posts: 8

Rep: Reputation: 0
Question about makefiles

How could I make a command that would remove all the executables in the current directory without listing all of the executables explicitly?
Old 11-18-2005, 12:05 AM   #2
Senior Member
Registered: Jan 2003
Posts: 2,786

Rep: Reputation: 374Reputation: 374Reputation: 374Reputation: 374
Two ways come to mind. The first is not a Makefile-ish style:
find . -type f -perm +111 -maxdepth 1 -exec rm -f {} \;
Of course, man find for details on the options, but that basically just deletes any file in the current directory (not sub-directories) that has any execute permission bit set (owner, group, or other). You can slap that command into the Makefile just like you would any other command. I'd personally verify its accuracy before using it though... Try using it on a backup copy of your development environment until you're confident it works as expected.

The second would be more in line with Makefile standards/form/guidelines. Create a TARGETS variable or something like that. Put in the explicit list of executable to delete in that variable. Then do an "rm $(TARGETS)" later. Depending on your setup, you might be able to do clever things such as automatic extension swapping. What I mean is, I've seen some Makefiles store all the object files into an OBJS variable, and then create a TARGETS (or similarly named variable) by using a Makefile syntax that dropped the ".o" extension from the OBJS variable. I'm no Makefile expert and can't tell you what the syntax is, but I know it's possible.
Old 11-18-2005, 12:08 AM   #3
LQ Newbie
Registered: Oct 2005
Posts: 8

Original Poster
Rep: Reputation: 0
Thanks a bunch, I will give it a try.


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
makefiles wmoti Programming 5 09-21-2005 03:26 AM
Those makefiles... boku Programming 10 03-01-2005 08:19 AM
Makefiles and Me dpottinger Linux - Newbie 5 07-24-2004 11:14 PM
Question about Makefiles xailer Linux - Newbie 5 11-24-2003 10:43 AM
Why makefiles parthi4u Programming 4 03-08-2003 03:14 PM > Forums > Linux Forums > Linux - Newbie

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

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration