~skeeto/public-inbox

Re: A Tutorial on Portable Makefiles

Dominique Crétel
Details
Message ID
<cc406689-f475-b273-d0d5-85c3f33a5056@free.fr>
DKIM signature
missing
Download raw message
Hello !

Good rticle about posix makefiles.

I am in a special case where folders are src, obj and include, then, two 
more folders than in the article.

Something like:

obj/graphics.o: src/graphics.c

obj/physics.o : src/physics.c

                 obj/input.o: src/input.c

This first Makefile is okay:

.POSIX:

.SUFFIXES:

CC     = cc

CFLAGS = -O -I include

LDLIBS = -lm

all: pipo_test

pipo_test: obj/pipo.o obj/pipo_test.o

         $(CC) $(LDFLAGS) -o pipo_test obj/pipo.o obj/pipo_test.o $(LDLIBS)

obj/pipo.o: source/pipo.c include/pipo.h

         $(CC) -o $@ -c $(CFLAGS) source/$(@F:.o=.c

obj/pipo_test.o: source/pipo_test.c include/pipo.h

         $(CC) -o $@ -c $(CFLAGS) source/$(@F:.o=.c)

clean:

         rm -f pipo_test obj/pipo.o obj/pipo_test.o

but this next step is not ok:

.POSIX:

.SUFFIXES:

CC     = cc

CFLAGS = -O -I include

LDLIBS = -lm

all: pipo_test

pipo_test: obj/pipo.o obj/pipo_test.o

         $(CC) $(LDFLAGS) -o pipo_test obj/pipo.o obj/pipo_test.o $(LDLIBS)

obj/pipo.o: source/pipo.c include/pipo.h

obj/pipo_test.o: source/pipo_test.c include/pipo.h

clean:

         rm -f pipo_test obj/pipo.o obj/pipo_test.o

.SUFFIXES: .c .o

obj/%.o: source/%.c

        $(CC) -o $@ -c $(CFLAGS) source/$(@F:.o=.c)

Can you help me please ?

Thank you.

Dominique CRETEL
Export thread (mbox)