2f48e1fcc24b67026de9f3949284004b928621a0
Stefan Schuermans expand during assignment

Stefan Schuermans authored 7 years ago

1) CFGS := $(wildcard config/*.cfg.sh)
2) SRCS := $(wildcard common/*.cpp) $(wildcard linux/*.cpp)
3) TARGET := Blinker
4) 
5) CPP := g++
6) CONFIG :=
7) DEFINE :=
8) INCLUDE := -Icommon -Ilinux
Stefan Schuermans improve auto dependencies

Stefan Schuermans authored 7 years ago

9) CFLAGS := -Wall -Wextra -Werror -O2
Stefan Schuermans expand during assignment

Stefan Schuermans authored 7 years ago

10) LDFLAGS :=
11) LIBS := -lBlinkenLib
12) 
13) CFGS_BASE := $(patsubst %.cfg.sh,%,$(CFGS))
14) CFGS_MK := $(addsuffix .cfg.mk,$(CFGS_BASE))
15) SRCS_BASE := $(patsubst %.cpp,%,$(SRCS))
16) DEPS := $(addsuffix .d,$(SRCS_BASE))
17) OBJS := $(addsuffix .o,$(SRCS_BASE))
Stefan Schuermans first version, plays videos...

Stefan Schuermans authored 13 years ago

18) 
Stefan Schuermans added flexipix output suppo...

Stefan Schuermans authored 13 years ago

19) .PHONY: all clean distclean
Stefan Schuermans first version, plays videos...

Stefan Schuermans authored 13 years ago

20) .SUFFIXES:
21) .SECONDARY:
22) 
Stefan Schuermans improve auto dependencies

Stefan Schuermans authored 7 years ago

23) all: $(DEPS) $(TARGET)
Stefan Schuermans first version, plays videos...

Stefan Schuermans authored 13 years ago

24) 
25) ifneq ($(MAKECMDGOALS),clean)
Stefan Schuermans added flexipix output suppo...

Stefan Schuermans authored 13 years ago

26)   ifneq ($(MAKECMDGOALS),distclean)
27)     include config.mk
Stefan Schuermans improve auto dependencies

Stefan Schuermans authored 7 years ago

28)     -include $(DEPS)
Stefan Schuermans added flexipix output suppo...

Stefan Schuermans authored 13 years ago

29)   endif
Stefan Schuermans first version, plays videos...

Stefan Schuermans authored 13 years ago

30) endif
31) 
Stefan Schuermans expand during assignment

Stefan Schuermans authored 7 years ago

32) DEFINE += -DBLINKER_CONFIG="\"$(CONFIG)\""
33) 
Stefan Schuermans added flexipix output suppo...

Stefan Schuermans authored 13 years ago

34) config.mk: $(CFGS_MK)
35) 	cat /dev/null $^ >$@
36) 
37) %.cfg.mk: %.cfg.sh
38) 	sh $< >$@
39) 
40) %.d: %.cpp Makefile config.mk
Stefan Schuermans improve auto dependencies

Stefan Schuermans authored 7 years ago

41) 	$(CPP) $(DEFINE) $(INCLUDE) $(CFLAGS) -MM -MF $@ -MT $(@:.d=.o) $<
Stefan Schuermans first version, plays videos...

Stefan Schuermans authored 13 years ago

42) 
43) %.o: %.cpp Makefile
Stefan Schuermans added flexipix output suppo...

Stefan Schuermans authored 13 years ago

44) 	$(CPP) $(DEFINE) $(INCLUDE) $(CFLAGS) -c -o $@ $<
Stefan Schuermans first version, plays videos...

Stefan Schuermans authored 13 years ago

45) 
46) $(TARGET): $(OBJS)
47) 	$(CPP) $(LDFLAGS) -o $@ $+ $(LIBS)
48) 
49) clean:
Stefan Schuermans improve auto dependencies

Stefan Schuermans authored 7 years ago

50) 	rm -f $(DEPS) $(OBJS) $(TARGET)
Stefan Schuermans first version, plays videos...

Stefan Schuermans authored 13 years ago

51)