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 12-22-2004, 05:25 AM   #1
Genjix
Member
 
Registered: Oct 2003
Location: Pico
Distribution: SUSE 9.1
Posts: 83

Rep: Reputation: 15
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.
 
Old 12-22-2004, 06:52 AM   #2
bigearsbilly
Senior Member
 
Registered: Mar 2004
Location: england
Distribution: Mint, Armbian, NetBSD, Puppy, Raspbian
Posts: 3,515

Rep: Reputation: 239Reputation: 239Reputation: 239
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
 
Old 12-22-2004, 10:58 AM   #3
Genjix
Member
 
Registered: Oct 2003
Location: Pico
Distribution: SUSE 9.1
Posts: 83

Original Poster
Rep: Reputation: 15
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
 
Old 12-22-2004, 12:22 PM   #4
Hko
Senior Member
 
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: Debian
Posts: 2,536

Rep: Reputation: 111Reputation: 111
Sorry, that doesn't make sense (to me).
 
Old 12-22-2004, 12:43 PM   #5
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris 11.4, Oracle Linux, Mint, Debian/WSL
Posts: 9,789

Rep: Reputation: 492Reputation: 492Reputation: 492Reputation: 492Reputation: 492
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.
 
Old 12-23-2004, 02:56 AM   #6
bigearsbilly
Senior Member
 
Registered: Mar 2004
Location: england
Distribution: Mint, Armbian, NetBSD, Puppy, Raspbian
Posts: 3,515

Rep: Reputation: 239Reputation: 239Reputation: 239
I Wasn't being rude. ;-)

incidentally
Code:
find . -name '*.cpp'
is better
Are your .cpp files in multiple subdirectories?
if not you can do
Code:
for i in  *.cpp
It's probably better to construct a proper makefile though.
It's worth learning make well.

regards billy
 
  


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
bash script loop bong.mau Programming 6 09-14-2005 07:38 PM
compiling bash 3.0 results in a loop bucovaina78 Linux - Software 2 05-26-2005 04:04 AM
BASH variables getting unset outside of loop trevelluk Programming 2 03-25-2005 07:14 AM
bash script for loop drisay Programming 5 12-25-2004 12:32 AM
bash for loop problem deadlock Programming 5 09-04-2003 04:32 AM

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

All times are GMT -5. The time now is 05:51 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
Open Source Consulting | Domain Registration