Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > C > Re: using a she...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 15 of 17 Topic 26125 of 26972
Post > Topic >>

Re: using a shell script to compile your C programs

by pereges <Broli00@[EMAIL PROTECTED] > May 9, 2008 at 04:16 AM

On May 9, 3:52 pm, "Joachim Schmitz" <nospam.j...@[EMAIL PROTECTED]
>
wrote:



> More than a decade ago we had to the same thing (defelop a makefile
> generator)  as there were enough members in the team who coudn't be
bothered
> to learn how to write makefiles. Not to speak of configuring the much
more
> complex automake...

Anyway, why is it such a big issue for most people to write a simple
makefile ? I have been reading a tutorial for the last hour and it
does not seem that hard to write simple makefiles.

eg. if there are files main.c, file1.c, file2.c

main.c includes file1.h and file2.h. file1.c includes file1.h and
file2.c includes file2.h

One can write a makefile for such a program:

# top-level rule to compile the whole program.
all: prog

# program is made of several source files.
prog: main.o file1.o file2.o
        gcc main.o file1.o file2.o -o prog

# rule for file "main.o".
main.o: main.c file1.h file2.h
        gcc -g -Wall -c main.c

# rule for file "file1.o".
file1.o: file1.c file1.h
        gcc -g -Wall -c file1.c

# rule for file "file2.o".
file2.o: file2.c file2.h
        gcc -g -Wall -c file2.c

# rule for cleaning files generated during compilations.
clean:
        /bin/rm -f prog main.o file1.o file2.o



Howver, the problem that I see with this approach that one has to keep
track of all the dependencies. It will get ***bersome with huge
projects but I believe there is a way out.
 




 17 Posts in Topic:
using a shell script to compile your C programs
pereges <Broli00@[EMAI  2008-05-09 00:10:09 
Re: using a shell script to compile your C programs
"Joachim Schmitz&quo  2008-05-09 09:14:45 
Re: using a shell script to compile your C programs
Spiros Bousbouras <spi  2008-05-09 00:21:25 
Re: using a shell script to compile your C programs
"Default User"   2008-05-09 17:44:58 
Re: using a shell script to compile your C programs
Richard Heathfield <rj  2008-05-09 07:37:22 
Re: using a shell script to compile your C programs
"Dan" <voids  2008-05-09 17:37:58 
Re: using a shell script to compile your C programs
Spiros Bousbouras <spi  2008-05-09 00:39:30 
Re: using a shell script to compile your C programs
pereges <Broli00@[EMAI  2008-05-09 00:49:32 
Re: using a shell script to compile your C programs
Richard Heathfield <rj  2008-05-09 08:28:56 
Re: using a shell script to compile your C programs
"Joachim Schmitz&quo  2008-05-09 12:33:07 
Re: using a shell script to compile your C programs
pereges <Broli00@[EMAI  2008-05-09 00:56:56 
Re: using a shell script to compile your C programs
Eligiusz Narutowicz<el  2008-05-09 11:50:17 
Re: using a shell script to compile your C programs
Antoninus Twink <nospa  2008-05-09 12:12:35 
Re: using a shell script to compile your C programs
"Joachim Schmitz&quo  2008-05-09 12:52:42 
Re: using a shell script to compile your C programs
pereges <Broli00@[EMAI  2008-05-09 04:16:40 
Re: using a shell script to compile your C programs
"Joachim Schmitz&quo  2008-05-09 13:26:47 
Re: using a shell script to compile your C programs
Bart <bc@[EMAIL PROTEC  2008-05-09 06:04:02 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Fri Jul 25 21:38:21 CDT 2008.