Advertisement

Make files confuse me

Started by November 02, 2004 01:06 AM
4 comments, last by jbm 20 years ago
well this is my Makefile:

CC = gcc -Wall -std=c99
editor:  
        $(CC) editor/main.c -oedit `sdl-config --cflags --libs` -s -O4
all:
        $(CC) editor/main.c -oedit `sdl-config --cflags --libs` -s -O4

Why is it that it works when I go make all, but when I go make editor it goes: make: `editor' is up to date.
After the colon in a rul should be listed the dependencies for that target. If a dependency gets modified, the target gets rebuilt.

For example:
CC = gcc -Wall -std=c99all:    editoreditor: editor/main.c         $(CC) editor/main.c -oedit `sdl-config --cflags --libs` -s -O4


The first rule is the one that gets selected if you just do make (as opposed to, say, make editor).

Using GNU make, there are a number of ways you can simplify your makefile: check out the info pages (info make), or the manual.
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
Advertisement
Maybe a bit of tweaking:

CC=gccCFLAGS= -Wall -std=c99 `sdl-config --cflags` -s -O4LDFLAGS= `sdl-config --libs`all: editedit: editor/main.c        $(CC) -oedit main.c $(CFLAGS) $(LDFLAGS)


Anyway the reason why its not updating is that it see the directory 'editor' already exists with no dependencies, so it doesnt bother trying to compile it.

You might want to peek at This Thread for some other ideas.

-oddbot
Consider Jam (http://www.perforce.com/jam/jam.html) if you're not such a big fan of make.


"There is no dark side of the moon really,
As a matter of fact, its all dark."
Or you could try SCons:
http://www.scons.org
I second the recommendation of SCons. It has made life a LOT easier for me.

This topic is closed to new replies.

Advertisement