-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
41 lines (30 loc) · 785 Bytes
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
.SUFFIXES:
.SUFFIXES: .o .cpp .h .d
CXX := g++
RM := rm
SED := sed
MV := mv
TARGET := termshooter
LIBRARY := -lncurses
CXXFLAGS := -std=c++1y -I/usr/include/ncurses -Wall -Wextra -Wno-unused-parameter -O2
SRC_DIR += src
SRC += $(foreach dir,$(SRC_DIR), $(wildcard $(dir)/*.cpp))
OBJECT := $(subst .cpp,.o,$(filter %.cpp,$(SRC)))
DEP_FILE := $(OBJECT:.o=.d)
.PHONY : all
all: $(TARGET)
$(TARGET): $(OBJECT)
$(CXX) $(CXXFLAGS) -o $@ $(OBJECT) $(LIBRARY)
.PHONY : clean
clean:
-$(RM) -fr $(TARGET) $(OBJECT) $(DEP_FILE)
.cpp.o:
$(CXX) $(CXXFLAGS) -c -o $@ $<
%.d: %.c
ifneq "$(MAKECMDGOALS)" "clean"
-include $(DEP_FILE)
endif
.cpp.d:
$(CXX) $(CXXFLAGS) -MM $< | \
$(SED) 's,\($(notdir $*)\.o\) *:,$(dir $@)\1 $@: ,' >[email protected]
$(MV) [email protected] $@