![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Help understanding a program | Toxic | Shell Programming and Scripting | 1 | 03-19-2006 09:50 PM |
| A little help understanding FIFOs? | deckard | Linux | 0 | 11-01-2005 09:46 AM |
| Understanding traceroutes | Bobby | IP Networking | 2 | 03-14-2005 01:35 PM |
| need further understanding of init.d | jigarlakhani | UNIX for Advanced & Expert Users | 1 | 09-20-2002 12:11 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
|||
|
Understanding this Makefile
I have this program which has lots of source files in the directories
Code:
src src/dir1 src/dir2 src/dir3... and so on Code:
CC = gcc
CFLAGS= -g -c -D_REENTRANT
SOURCES = src/main.c src/dir1/a.c src/dir1/b.c src/dir2/x.c src/dir2/y.c ...and so on
OBJS = src/main.o src/dir1/a.o src/dir1/b.o src/dir2/x.o src/dir2/y.o ...and so on
TARGETS = prog.exe
%.o : %.c
$(CC) $(CFLAGS) -o $@ $?
${TARGETS}: ${OBJS}
$(CC) ${OBJS} -o ${TARGETS}
And, since I have a lot of source files spread out in multiple directories and lots of corresponding directories.. the macros SOURCES and OBJS are getting quite ugly.. is there any way around this ? (I couldve also used macros for the directory names, but it is still getting very ugly) |
| Forum Sponsor | ||
|
|
|
|||
|
$@ is the target of the dependancy
$? are the prequisites for each dependancy rule The %.o: %.c means in order to build a file with this extension from a file of this extension follow this rule. Personally I think wild cards are bad news in Makefiles. You want to know exactly what you are building. While we are at it, I also I don't recommend requiring gmake. Also, personally, I think that objects should be built in a totally different tree to the source. |
|
||||
|
This article will help you to understand "make".
An Introduction to the UNIX Make Utility Best regards, Iliyan Varshilov Last edited by ilko_partizan; 06-18-2007 at 05:18 AM. |
||||
| Google The UNIX and Linux Forums |