LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-13-2011, 05:50 AM   #1
josecolella
Member
 
Registered: Nov 2010
Location: Milan, Italy
Distribution: Linux Mint 13, Debian 6.0
Posts: 62

Rep: Reputation: 3
Question Compiling programs: makefile need help understanding this concept


# Filename: makefile2
# Usage: make-f makefile2
# Description: Maintains all the dependencies between modules using the
# Agenda1.

CC=g++
CFLAGS=-c -Wall
LDFLAGS=
SOURCE_MODULES=main.cpp factorial.cpp hello.cpp
OBJECT_MODULES=$(SOURCE_MODULES:.cpp=.o)
EXECUTABLE=programa1
all: $(OBJECT_MODULES) $(EXECUTABLE)
$(EXECUTABLE): $(OBJECT_MODULES)
$(CC) $(LDFLAGS) $^ -o $@
.o: .cpp
$(CC) $(CFLAGS) $< -o $@


I am suppose to explain the dependencies that exist and each of the following lines of makefile. Lists
orders to be executed as a result of running the make utility on it.
Can anyone provide a guide or good information on this subject before I embark on this question
 
Old 01-13-2011, 10:16 AM   #2
Snark1994
Senior Member
 
Registered: Sep 2010
Distribution: Debian
Posts: 1,632
Blog Entries: 3

Rep: Reputation: 346Reputation: 346Reputation: 346Reputation: 346
Especially given it's a homework question, you're doing it the wrong way round... A better way to do this would be to look for the information, then say "I don't understand X" (ie, I can't understand exactly what the CC variable is/does). This is better for lots of reasons:
I) People are normally happier to help people if they think the person's made some effort in solving the problem themselves - this could either "If they can't be bothered then neither can I" or "I think they'll learn more if they discover it for themselves"
II) Your question is rather wide - the subject of makefiles is rather big, and even if we're only talking about using them for compiling C++ programmes, then there are still lots of things you can do with it. Providing a specific enquiry can be helpful just to know where to start and for getting answers that target the question you want answered, rather than what the poster thinks you want answered.
III) You will have learnt a lot more, both in the way of skills and information that lasts, by reading and searching for it for yourself than being spoon-fed by members

That said, try typing "Introduction to makefiles" into Google - the first two hits are from the GNU project "make" documentation, and explain all questions I could think that you would want to ask about the subject...
 
1 members found this post helpful.
Old 01-13-2011, 04:05 PM   #3
josecolella
Member
 
Registered: Nov 2010
Location: Milan, Italy
Distribution: Linux Mint 13, Debian 6.0
Posts: 62

Original Poster
Rep: Reputation: 3
Thanks for your help, I know its a homework question, I need to understand the concept before I take a shot at the questions
 
Old 01-13-2011, 04:17 PM   #4
Snark1994
Senior Member
 
Registered: Sep 2010
Distribution: Debian
Posts: 1,632
Blog Entries: 3

Rep: Reputation: 346Reputation: 346Reputation: 346Reputation: 346
I know you know that... Hehe, all I was saying was that doing the research before asking is good

The basic concept, as I hope you will pick up, is that you tell "make" what it needs to do to build each file, and crucially which files each file depends upon. So then it only rebuilds files whose dependencies and/or source have changed - it saves time. Of course, it can be applied to many more things (I've mostly seen it used for compiling things like java/C/C++/LaTeX, but I do remember seeing some rather incredible uses for it... I forget exactly what they are now :/)
 
  


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
Understanding compiling sephstorm Linux - General 7 09-21-2010 10:57 AM
Need help understanding Makefile(s) jdkorreck Linux - Newbie 1 03-16-2009 01:50 AM
Help in understanding Makefile rules cranium2004 Programming 2 03-11-2005 06:06 AM
Require a Makefile for kernel module programs b123coder Linux - Newbie 1 12-28-2004 10:11 AM
Understanding compiling procedure BACTRATE Mandriva 1 02-16-2004 07:57 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:58 AM.

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