My Makefile is not deleting intermediate files. I’ve set .INTERMEDIATE. Here is my Makefile:
OBJECTS=prefixer.o stack.o
CFLAGS=-Werror -Wmissing-prototypes -g
LIBS=-lm
CC=gcc
prefixer : $(OBJECTS)
$(CC) -o prefixer $(OBJECTS) $(LIBS)
prefixer.o : stack.h
$(CC) -c prefixer.c -o $@ $(CFLAGS)
stack.o : stack.c stack.h
$(CC) -c stack.c -o $@ $(CFLAGS)
.INTERMEDIATE: %.o
.PHONY: clean
clean :
-rm prefixer *.o
What is wrong with .INTERMEDIATE?
See Gnu make special targets for role of
.INTERMEDIATEYou probably mean
because I think that if you put
.INTERMEDIATEthen the objects will always be removed, and you probably don’t want that. I don’t think you can meaningfully put%.oas prerequisites of special targets.I would suggest to keep the object files so you don’t waste time recompiling them.
Running once
make -pwill teach you a lot about the rules thatmakeknows about.Using
remake -x(i.e. remake) is very helpful, at least to debug complexMakefile-s. You could also usemake -dbut I find it too verbose.You may want to use better builders than
makee.g. omake.