Add Makefile example

This makefile check file dependecies (.h)
Idea from
5c644cfd35/Makefile
This commit is contained in:
Mathieu Maret 2016-10-05 16:02:13 +02:00
parent 8149222a45
commit d212b6089d

20
Makefile/Makefile Normal file
View File

@ -0,0 +1,20 @@
CXXFLAGS ?= -Werr -Wall
program = test
sources = $(wildcard *.c)
objects = $(sources:%.c=%.o)
depends = $(sources:%.c=%.d)
%.d: %.c
@$(CPP) $(CPPFLAGS) -c -MP -MM -MT "$@ $*.o" $< >$@
$(program): $(objects)
$(CXX) -o $@ $^ $(LDFLAGS) $(LDLIBS)
.PHONY: clean
clean:
rm -f $(program) $(objects) $(depends)
ifneq ($(MAKECMDGOALS),clean)
-include $(depends)
endif