-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
43 lines (35 loc) · 1007 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
42
43
SOURCES = $(wildcard *.cpp)
ifeq ($(CXX),)
CXX = g++
endif
MODENAME = posix
SDEFINEFLAG = -std=c++11
SLINKFLAG =
OBJDIRNAME = $(MODENAME)_out
OBJECTS = $(SOURCES:%.cpp=$(OBJDIRNAME)/%.o)
MAINFLAG = -o
TARGETNAME = out
TARGET = $(OBJDIRNAME)/$(TARGETNAME)
DEPFLAG = -MM -MT
DEPENDFILE = $(OBJDIRNAME)/dependfile.tlist
$(TARGET) : $(OBJECTS)
@`[ -d $(OBJDIRNAME) ] || mkdir $(OBJDIRNAME)`
$(CXX) $(MAINFLAG) $(TARGET) $(OBJECTS) $(SDEFINEFLAG) $(SLINKFLAG)
dep :
ifeq ($(wildcard $(OBJDIRNAME)),)
mkdir $(OBJDIRNAME)
endif
ifneq ($(wildcard $(DEPENDFILE)),)
rm $(DEPENDFILE)
endif
for FILE in $(SOURCES:%.cpp=%); do \
$(CXX) $(DEPFLAG) $(OBJDIRNAME)/$$FILE.o $$FILE.cpp >> $(DEPENDFILE); \
done
clean :
ifneq ($(wildcard $(OBJDIRNAME)),)
rm -r $(OBJDIRNAME)
endif
$(OBJDIRNAME)/%.o : %.cpp
@`[ -d $(OBJDIRNAME) ] || mkdir $(OBJDIRNAME)`
$(CXX) -c $(MAINFLAG) $@ $< $(SDEFINEFLAG)
-include $(DEPENDFILE)