Stefan Schuermans commited on 2017-09-24 09:33:21
Showing 4 changed files, with 16 additions and 16 deletions.
| ... | ... |
@@ -1,5 +1,3 @@ |
| 1 |
-CFGS := $(wildcard config/*.cfg.sh) |
|
| 2 |
-SRCS := $(wildcard common/*.cpp) $(wildcard linux/*.cpp) |
|
| 3 | 1 |
TARGET := Blinker |
| 4 | 2 |
|
| 5 | 3 |
CXX := g++ |
| ... | ... |
@@ -10,11 +8,14 @@ CFLAGS := -Wall -Wextra -Werror -O2 |
| 10 | 8 |
LDFLAGS := |
| 11 | 9 |
LIBS := -lBlinkenLib |
| 12 | 10 |
|
| 11 |
+CFGS := $(wildcard config/*.cfg.sh) |
|
| 13 | 12 |
CFGS_BASE := $(patsubst %.cfg.sh,%,$(CFGS)) |
| 14 | 13 |
CFGS_MK := $(addsuffix .cfg.mk,$(CFGS_BASE)) |
| 14 |
+ |
|
| 15 |
+SRCS := $(wildcard common/*.cpp) $(wildcard linux/*.cpp) |
|
| 15 | 16 |
SRCS_BASE := $(patsubst %.cpp,%,$(SRCS)) |
| 16 |
-DEPS := $(addsuffix .d,$(SRCS_BASE)) |
|
| 17 |
-OBJS := $(addsuffix .o,$(SRCS_BASE)) |
|
| 17 |
+DEPS := $(addprefix obj/,$(addsuffix .d,$(SRCS_BASE))) |
|
| 18 |
+OBJS := $(addprefix obj/,$(addsuffix .o,$(SRCS_BASE))) |
|
| 18 | 19 |
|
| 19 | 20 |
.PHONY: all clean distclean |
| 20 | 21 |
.SUFFIXES: |
| ... | ... |
@@ -37,17 +38,20 @@ config.mk: $(CFGS_MK) |
| 37 | 38 |
%.cfg.mk: %.cfg.sh |
| 38 | 39 |
sh $< >$@ |
| 39 | 40 |
|
| 40 |
-%.d: %.cpp Makefile config.mk |
|
| 41 |
- $(CXX) $(DEFINE) $(INCLUDE) $(CFLAGS) -MM -MF $@ -MT $(@:.d=.o) $< |
|
| 41 |
+obj: |
|
| 42 |
+ mkdir $@ $@/common $@/linux |
|
| 43 |
+ |
|
| 44 |
+obj/%.d: %.cpp Makefile config.mk | obj |
|
| 45 |
+ $(CXX) $(DEFINE) $(INCLUDE) $(CFLAGS) -MM -MT $(@:.d=.o) -o $@ $< |
|
| 42 | 46 |
|
| 43 |
-%.o: %.cpp Makefile |
|
| 47 |
+obj/%.o: %.cpp Makefile | obj |
|
| 44 | 48 |
$(CXX) $(DEFINE) $(INCLUDE) $(CFLAGS) -c -o $@ $< |
| 45 | 49 |
|
| 46 | 50 |
$(TARGET): $(OBJS) |
| 47 | 51 |
$(CXX) $(LDFLAGS) -o $@ $+ $(LIBS) |
| 48 | 52 |
|
| 49 | 53 |
clean: |
| 50 |
- rm -f $(DEPS) $(OBJS) $(TARGET) |
|
| 54 |
+ rm -f obj $(TARGET) |
|
| 51 | 55 |
|
| 52 | 56 |
distclean: clean |
| 53 | 57 |
rm -f config.mk $(CFGS_MK) |