Help me understand this Makefile


 
Thread Tools Search this Thread
Top Forums Programming Help me understand this Makefile
# 1  
Old 03-28-2009
Java Help me understand this Makefile

Code:
PROGOBJS=lab10.o face.o
all:	lab10 clean
lab10:	$(PROGOBJS)
	gcc -o lab10 $(PROGOBJS)
lab10.o:	lab10.c face.h
	gcc -c lab10.c 
face.o:	face.c 
	gcc -c face.c
very-clean:	clean
	rm *.*~ lab10
clean:	
	rm *.o

I need a bit of help understanding what's going on back here. What does that first line mean? I read that when you use all, it was like the holy grail command, that should cover everything, but at the same time it seems this makefile is making a file called PROGOBJS? And what does the $(PROGOBJS) do and mean?

The reason is fairly easy, but this PROGOBJS business has me stumped :c. Thanks for any help in advance!
# 2  
Old 03-28-2009
I added code tags so we can read it. Please do this yourself next time.
PROGOBJS=lab10.o face.o
just defines what make calls a "macro". It is just like a variable. This one has a value of those two .o files. This doesn't do much by itself. But now we can do:
gcc -o lab10 $(PROGOBJS)
and this magicly becomes:
gcc -o lab10 lab10.o face.o
# 3  
Old 03-28-2009
thank you! That makes everything click just right!
# 4  
Old 03-30-2009
Quote:
Originally Posted by MaestroRage
I read that when you use all, it was like the holy grail command, that should cover everything
That is just a convention, by the way. 'make' doesn't actually have a special meaning for it.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

can't understand!

Hi All, can you please help me to figured out what's the meaning of this. ${SERVER_DATABASE} -b << EOF 2>>/dev/null THanks, (3 Replies)
Discussion started by: nikki1200
3 Replies

2. Shell Programming and Scripting

help can't understand the code

Hi All, Good day, i'm just wondering what is the meaning of this code? COUNT_EXTRACTED_FILE=`${ECHO_CMD} "${SE_IN_PATH}${SE_IN_FILE}" | ${AWK_CMD} -F"__" '{print $2}'` Thanks, -niks(newbie) (2 Replies)
Discussion started by: nikki1200
2 Replies

3. Homework & Coursework Questions

Help with Simple Multi-Level Makefile (Extremely New at Makefile)

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: Basically, the prompt is make a makefile with various sub makefiles in their respective subdirectories. All code... (1 Reply)
Discussion started by: Tatl
1 Replies

4. Shell Programming and Scripting

Help to understand the script

Hi All; Is there anybody can explain this script please? trap 'C_logmsg "F" "CNTL/c OS signal trapped, Script ${G_SCRIPTNAME] terminated"; exit 1' 2 trap 'C_logmsg "F" "Kill Job Event sent from the Console, Script ${G_SCRIPTNAME] terminated"; exit 1' 15 (3 Replies)
Discussion started by: thankbe
3 Replies

5. UNIX for Advanced & Expert Users

Makefile executing another Makefile first?

I have 2 libraries in 2 different directories that I build with Makefiles. library B depends on library A. If I modify a .cpp file in library A and run lib B's Makefile can I have B's makefile to automatically rebuild library A? I am now rebuilding A, followed by B... but I'd like B to... (0 Replies)
Discussion started by: wwuster
0 Replies

6. UNIX for Advanced & Expert Users

Makefile problem - How to run module load in a Makefile

Hi, I'm trying to run the module load command in a Makefile and i'm getting the following error: make: module: command not found Why is this? Is there any way to run this command in a Makefile? NOTE: command - module load msjava/sunjdk/1.5.0 works fine outside of the Makefile (2 Replies)
Discussion started by: hernandinho
2 Replies

7. Red Hat

Trying to understand how to use vim

Hi there. I'm new at UNIX, but want to learn and understand it. I'm reading the Fedora and RHEL book, but I'm not sure how to use vim to create an alias in my .bash_profile. Can you point me in the right direction please? ;) (2 Replies)
Discussion started by: hrh0901
2 Replies

8. UNIX for Dummies Questions & Answers

can't understand this at all.

Ok, i've been trying to write some shell scripts. nothing challenging, but just automating All of the tutorials i read say to start the file with #!/bin/bash or whatever your path to bash is. So i do it, and all of my scripts error out saying ./nameofscript:command not found when i... (4 Replies)
Discussion started by: severndigital
4 Replies

9. UNIX for Dummies Questions & Answers

can't understand

how i can download this game n start it :S (5 Replies)
Discussion started by: BoyArcher
5 Replies
Login or Register to Ask a Question