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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
12-22-2004, 05:25 AM
|
#1
|
|
Member
Registered: Oct 2003
Location: Pico
Distribution: SUSE 9.1
Posts: 83
Rep:
|
Bash for loop
Code:
for i in `find | grep .cpp`; \
do \
gcc -c $$i; \
# check for compilation errors
if [ $? -ne 0 ]; then \
echo "compilation aborted"; \
exit; \
fi; \
done;
actually in a Makefile, anyone tell me whats wrong with my syntax and how can i get rid of the backslashes?
Last edited by Genjix; 12-22-2004 at 05:59 AM.
|
|
|
|
12-22-2004, 06:52 AM
|
#2
|
|
Senior Member
Registered: Mar 2004
Location: england
Distribution: FreeBSD, Debian, Mint, Puppy
Posts: 3,211
Rep: 
|
why is it in a makefile?
If all you are doing is compiling all sources
regardless of dependencies etc.
why not just in a script?
This sort of thing should not ideally be in a makefile.
regards billy
|
|
|
|
12-22-2004, 10:58 AM
|
#3
|
|
Member
Registered: Oct 2003
Location: Pico
Distribution: SUSE 9.1
Posts: 83
Original Poster
Rep:
|
ok, its just that people are so used to typing make that its the accepted standard, and to be honest this method is alot quicker if i simply follow the rule of making all object files end in cpp
|
|
|
|
12-22-2004, 12:22 PM
|
#4
|
|
Senior Member
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: ubuntu
Posts: 2,530
Rep: 
|
Sorry, that doesn't make sense (to me).
|
|
|
|
12-22-2004, 12:43 PM
|
#5
|
|
Moderator
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris10, Solaris 11, Ubuntu, OL
Posts: 9,311
|
You can still have the users type make, and have the Makefile call your external shell script.
That would be far more easier to maintain.
|
|
|
|
12-23-2004, 02:56 AM
|
#6
|
|
Senior Member
Registered: Mar 2004
Location: england
Distribution: FreeBSD, Debian, Mint, Puppy
Posts: 3,211
Rep: 
|
I Wasn't being rude. ;-)
incidentally
Code:
find . -name '*.cpp'
is better
Are your .cpp files in multiple subdirectories?
if not you can do
It's probably better to construct a proper makefile though.
It's worth learning make well.
regards billy
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 07:38 AM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|