473,384 Members | 1,854 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,384 software developers and data experts.

What are makefiles useful for?

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
Jul 22 '05 #1
5 1936
dj***@excite.it 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
Jul 22 '05 #2
"dj***@excite.it" 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
kb******@gascad.at
Jul 22 '05 #3
dj***@excite.it 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
Jul 22 '05 #4
dj***@excite.it 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.
Jul 22 '05 #5
dj***@excite.it (dj***@excite.it) wrote in
news:66**************************@posting.google.c 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.
Jul 22 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: dharmesh Gupta | last post by:
Dear All, can anyone pls tell me how to make a makefile with a small example. i am very confused. Thanks to all
1
by: Janne Naukkarinen | last post by:
Have someone commercial Digital Mars (DMC) IDDE? I need help making makefiles, it is easier with IDDE. However, IDDE is not freely distributed on net. There is current WinVN WIP:
15
by: Jonathan Turkanis | last post by:
Hi All, I hope this is not too far off topic here, but I can't think off any place where it would be exactly on topic. I'd like to get some sense of how widely used certain IDEs are. I'm...
121
by: typingcat | last post by:
First of all, I'm an Asian and I need to input Japanese, Korean and so on. I've tried many PHP IDEs today, but almost non of them supported Unicode (UTF-8) file. I've found that the only Unicode...
10
by: JS | last post by:
I have two Makefiles in two different directories. How do I know which of these Makefiles make will use and is there some way to specify which Makefile that should be run.
19
by: milkyway | last post by:
Hello, I am running under Suse Linux and am putting together some code written in C. I am not clear on how to create makefiles and was wondering if there were any "makefile tools" out there. If...
2
by: barcaroller | last post by:
Not sure whether this is the right newsgroup but... is there any way I can tell lint (or one of its derivates) to pick up DEFINE statements/macros and header file INCLUDE paths from Makefiles so...
22
by: =?ISO-8859-1?Q?Tom=E1s_=D3_h=C9ilidhe?= | last post by:
I already understand how program compilation works (i.e. the preprocessor produces individual translation units which get compiled separately, and then the linker links the object files together),...
3
by: tvnaidu | last post by:
porting windows static libs and dll into linux static lib abd shared lib, any tool to convert vcproj files to Linux makefiles? porting windows static libs and dll into linux static lib abd shared...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.