-
Notifications
You must be signed in to change notification settings - Fork 10
/
Makefile
95 lines (70 loc) · 1.99 KB
/
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
SRC := src
BUILD := build
LIBNAME := libsge.a
LIB := $(BUILD)/$(LIBNAME)
TARNAME := sge.tgz
TARBALL := $(BUILD)/$(TARNAME)
TARCONTENTS := $(TARNAME) $(LIBNAME) include
GLFW := glfw
GLFWBUILD := $(BUILD)/$(GLFW)
LIBGLFW := $(GLFWBUILD)/src/libglfw3.a
SOIL := SOIL
SOILBUILD := $(BUILD)/SOIL
SOILSRCS := $(wildcard $(SOIL)/*.c)
SOILOBJS := $(notdir $(SOILSRCS:.c=.o))
SOILBUILT := $(addprefix $(SOILBUILD)/, $(SOILOBJS))
SRCS := $(wildcard $(SRC)/*.cpp)
OBJS := $(notdir $(SRCS:.cpp=.o))
BUILT := $(addprefix $(BUILD)/, $(OBJS))
OBJS += $(SOILOBJS)
BUILT += $(SOILBUILT)
DIRS := $(BUILD) $(SOILBUILD) $(GLFWBUILD) $(BUILD)/include
HEADERS := $(wildcard include/*.h) $(GLFW)/include/GLFW
CXXFLAGS := -Wall \
-Wextra \
-Wwrite-strings \
-Winit-self \
-Wcast-align \
-Wcast-qual \
-Wpointer-arith \
-Wstrict-aliasing \
-Wformat=2 \
-Wmissing-declarations \
-Wmissing-include-dirs \
-Wno-unused-parameter \
-Wuninitialized \
-Wno-reorder \
-Wno-unknown-pragmas
override CXXFLAGS += -std=c++11 -I. -I./include -I./$(GLFW)/include
DOC_CONFIG := doxygen_config
all: $(LIB) headers
dist: $(TARBALL)
docdist: $(LIB) headers doc
cd $(BUILD) && tar czf $(TARCONTENTS) doc
$(TARBALL): $(LIB) headers
cd $(BUILD) && tar czf $(TARCONTENTS)
headers: $(HEADERS) | $(BUILD) $(BUILD)/include
cp -r $^ $(BUILD)/include
mkdir -p $(BUILD)/include/SOIL
cp $(wildcard $(SOIL)/*.h) $(BUILD)/include/SOIL
$(DIRS):
mkdir -p $@
$(LIBGLFW): | $(GLFWBUILD)
cd $(GLFWBUILD); cmake $(CMAKEFLAGS) ../../$(GLFW); cmake --build . -- glfw
glfwobjs: $(LIBGLFW) | $(BUILD)
$(eval ARCHIVED := $(filter %.o %.obj, $(shell $(AR) -t $<)))
$(AR) -x $< $(ARCHIVED)
$(AR) -cruS $(LIB) $(ARCHIVED)
$(RM) $(ARCHIVED)
$(LIB): $(BUILT) | glfwobjs
$(AR) -crus $@ $?
$(SOILBUILD)/%.o: $(SOIL)/%.c | $(SOILBUILD)
$(CC) $(CFLAGS) -c -o $@ $<
$(BUILD)/%.o: $(SRC)/%.cpp | $(BUILD)
$(CXX) $(CXXFLAGS) -c -o $@ $<
doc: $(DOC_CONFIG)
mkdir -p $(BUILD)/doc
doxygen $<
clean:
rm -rf $(BUILD)
.PHONY: all clean dist doc docdist glfwobjs headers