Stefan Schuermans
improve build system
Stefan Schuermans commited 6ce6057 at 2017-09-24 09:33:21
TARGET := Blinker
CXX := g++
CONFIG :=
DEFINE :=
INCLUDE := -Icommon -Ilinux
CFLAGS := -Wall -Wextra -Werror -O2
LDFLAGS :=
LIBS := -lBlinkenLib
CFGS := $(wildcard config/*.cfg.sh)
CFGS_BASE := $(patsubst %.cfg.sh,%,$(CFGS))
CFGS_MK := $(addsuffix .cfg.mk,$(CFGS_BASE))
SRCS := $(wildcard common/*.cpp) $(wildcard linux/*.cpp)
SRCS_BASE := $(patsubst %.cpp,%,$(SRCS))
DEPS := $(addprefix obj/,$(addsuffix .d,$(SRCS_BASE)))
OBJS := $(addprefix obj/,$(addsuffix .o,$(SRCS_BASE)))
.PHONY: all clean distclean
.SUFFIXES:
.SECONDARY:
all: $(DEPS) $(TARGET)
ifneq ($(MAKECMDGOALS),clean)
ifneq ($(MAKECMDGOALS),distclean)
include config.mk
-include $(DEPS)
endif
endif
DEFINE += -DBLINKER_CONFIG="\"$(CONFIG)\""
config.mk: $(CFGS_MK)
cat /dev/null $^ >$@
%.cfg.mk: %.cfg.sh
sh $< >$@
obj:
mkdir $@ $@/common $@/linux
obj/%.d: %.cpp Makefile config.mk | obj
$(CXX) $(DEFINE) $(INCLUDE) $(CFLAGS) -MM -MT $(@:.d=.o) -o $@ $<
obj/%.o: %.cpp Makefile | obj
$(CXX) $(DEFINE) $(INCLUDE) $(CFLAGS) -c -o $@ $<
$(TARGET): $(OBJS)
$(CXX) $(LDFLAGS) -o $@ $+ $(LIBS)
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX