LinuxQuestions.org
Help answer threads with 0 replies.
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 09-22-2003, 04:00 PM   #1
Yamakaze
LQ Newbie
 
Registered: Sep 2003
Distribution: SuSE 8.2 Pro
Posts: 9

Rep: Reputation: 0
Trouble with makefiles...


I'm a heavy C programmer, so I made a makefile from scratch to handle the simple stuff; here's the initial file:

object : *.c
gcc -c *.c

$@ : *.o
gcc -o $@ *.o

clean :
rm -f *.o
EOF

This is just about all I really need, but I figured out another function that would be useful. I'd like to be able to simply delete the executables WITHOUT deleting everything else in the folder. I tried to create a "make new" rule that would rm anything NOT ending in an extension (except for the makefile, of course), but had no luck. I tried something like this:

new :
ls | grep '.*[^\..*]' | rm -f
(Yes, I know that rule would delete the makefile as well... I'm still working on that part as well.)

Any help?
 
Old 09-22-2003, 11:20 PM   #2
crabboy
Senior Member
 
Registered: Feb 2001
Location: Atlanta, GA
Distribution: Slackware
Posts: 1,821

Rep: Reputation: 121Reputation: 121
From the looks of your Makefile every .c source file is its own executable. So the following new target would work if this is the case:

Code:
new:
    ls *.c | sed 's/\.c//' | xargs rm -f
 
Old 09-23-2003, 01:56 AM   #3
SaTaN
Member
 
Registered: Aug 2003
Location: Suprisingly in Heaven
Posts: 223

Rep: Reputation: 33
rm -f `ls -l | grep -v "^d" | awk '{print $9}' | grep -v "\." | awk '{if($1!="makefile"){print $1}}'`

I suppose this should do it for you

Last edited by SaTaN; 09-23-2003 at 02:01 AM.
 
  


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
makefiles wmoti Programming 5 09-21-2005 03:26 AM
Makefiles deveshs Linux - Software 2 05-02-2005 05: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
MAKEFILEs shinpadsmt Linux - Newbie 3 02-21-2004 02:52 AM

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

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