Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > What are makefiles useful for?

Reply
Thread Tools

What are makefiles useful for?

 
 
djake@excite.it
Guest
Posts: n/a
 
      11-12-2004
Someone can explain me what are makefiles useful for? Couldn't i write
shell script instead of makefiles? (*.sh in unix; *.cmd in win32)

Moreover i really doesn't understand what dependencies are useful
for? Except when i need to compile different files with different
compile options, i doesn't need to declare explicitly dependecies.
Infact the compiler already find dependecies looking for header files
included into the sources.

Can you explain me circumstances in which dependecies are useful?

Thanks
 
Reply With Quote
 
 
 
 
Victor Bazarov
Guest
Posts: n/a
 
      11-12-2004
wrote:
> Someone can explain me what are makefiles useful for? Couldn't i write
> shell script instead of makefiles? (*.sh in unix; *.cmd in win32)


Makefiles are used to keep dependencies between different parts of the
project. You can do it all using shell script, of course.

> Moreover i really doesn't understand what dependencies are useful
> for?


They are useful if you don't want to keep track of what needs to be
rebuilt (recompiled/relinked/rearchived) when a file is updated. Also,
the importance of the dependencies is that they propagate.

> Except when i need to compile different files with different
> compile options, i doesn't need to declare explicitly dependecies.


Well, it's your right to think so.

> Infact the compiler already find dependecies looking for header files
> included into the sources.


Your compiler probably does. Many don't.

> Can you explain me circumstances in which dependecies are useful?


See above.

One thing I have to mention, though. Your inquiry is OFF-TOPIC. Please
take the further discussion to comp.software-eng. Follow-ups set.

V
 
Reply With Quote
 
 
 
 
Karl Heinz Buchegger
Guest
Posts: n/a
 
      11-12-2004
"" wrote:
>
> Someone can explain me what are makefiles useful for? Couldn't i write
> shell script instead of makefiles? (*.sh in unix; *.cmd in win32)
>
> Moreover i really doesn't understand what dependencies are useful
> for? Except when i need to compile different files with different
> compile options, i doesn't need to declare explicitly dependecies.
> Infact the compiler already find dependecies looking for header files
> included into the sources.
>
> Can you explain me circumstances in which dependecies are useful?
>


In short:
Whenever your project consists of more then 1 source file. In practice
this means: always

Consider your project consists of 4 files:
a.cpp, b.cpp, c.cpp, inc.h

Now a.cpp includes inc.h, so does b.cpp
But c.cpp does not include inc.h

So whenever inc.h changes, what needs to be done?
a.cpp needs to be recompiled
b.cpp needs to be recompiled
but for c.cpp the linker can simply use the object
file generated in a previous compiler run for c.cpp. No
recompile is necessary, since nothing in inc.h can influence
anything in c.cpp

And that is the job of the makefile to describe this:
when inc.h changes, recompile a.cpp, b.cpp and link
the object files a.o, b.o, c.o to form the new, updated
final executable.

With shell scripts you don't get that flexibility to just recompile
what is needed to be compiled. You can only recompile everything.
And that can make a difference: Eg. I currently do a recompile of
everything in the program system I am involved in. The system consists
of roughly more then 1500 files with lots of dependencies. I started
the 'compile all' at 16:05. Current time is 18:16. The rebuild is
nearly through ......

--
Karl Heinz Buchegger

 
Reply With Quote
 
Default User
Guest
Posts: n/a
 
      11-12-2004
wrote:

> Someone can explain me what are makefiles useful for? Couldn't i write
> shell script instead of makefiles? (*.sh in unix; *.cmd in win32)


That's because . . .

> Moreover i really doesn't understand what dependencies are useful
> for?



Do a bit of elementary research and stop posting off-topic stuff to
newsgroups.




Brian
 
Reply With Quote
 
E. Robert Tisdale
Guest
Posts: n/a
 
      11-12-2004
wrote:

> Someone can explain me what are makefiles useful for? Couldn't i write
> shell script instead of makefiles? (*.sh in unix; *.cmd in win32)
>
> Moreover i really doesn't understand what dependencies are useful
> for? Except when i need to compile different files with different
> compile options, i doesn't need to declare explicitly dependecies.
> Infact the compiler already find dependecies looking for header files
> included into the sources.
>
> Can you explain me circumstances in which dependecies are useful?


I used Google

http://www.google.com/

to search for

+"make tutorial"

and I found lots of stuff.
 
Reply With Quote
 
Cristiano Sadun
Guest
Posts: n/a
 
      11-15-2004
() wrote in
news: om:

> Someone can explain me what are makefiles useful for? Couldn't i write
> shell script instead of makefiles? (*.sh in unix; *.cmd in win32)


Yes, but you'd end up writing the same script with different parameters
every time.

makefiles are just that script.
 
Reply With Quote
 
 
 
Reply

Thread Tools

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
useful setting in device manager (may be useful to know!) jameshanley39@yahoo.co.uk Computer Information 2 07-07-2008 04:28 PM
Ant vs Makefiles Harris L Java 20 12-02-2004 10:35 AM
Can someone make winvn makefiles tith Digital MarsMars (DMC) IDDE Janne Naukkarinen C++ 1 01-15-2004 03:43 AM
Makefiles for JAVA sasquatch Java 5 11-12-2003 08:12 PM
Making of Makefiles dharmesh Gupta C++ 2 08-26-2003 06:54 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57