Commit b0541348 authored by Mathieu Maret's avatar Mathieu Maret

Makefile: simplification and improvment

Default target is the main program.
Use implicit rule for main program.
Generate .d file at compilation time instead of using specific rules
Fix CFLAGS CPPFLAGS usage
parent 5f29edd6
CPPFLAGS ?= -Werror -Wall
# Preproc options
# -MMD is used to generate .d files for header dependencies
CPPFLAGS = -MMD
# main compilation
CFLAGS ?= -Werror -Wall
#Linker flags
LDFLAGS =
#Linker path
LDLIBS =
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)
$(RM) $(program) $(objects) $(depends)
ifneq ($(MAKECMDGOALS),clean)
-include $(depends)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment