-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
149 lines (113 loc) · 3.83 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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
PRODUCT := uk
TEST_PROD := test_uk
BIN := bin
INC := include
GEN := gen
GEN_SRC := $(GEN)/src
GEN_INC := $(GEN)/include
RES := res
SRC := src
TEST := test
OBJ := obj
IDL := idl
CXX := g++
CXXFLAGS := -Wall -Wextra -Werror -std=c++14 \
`fltk-config --cxxflags` \
-g -O0
DEBUG_FLAGS := -DDEBUG_ALL
LINKER := g++
LFLAGS := -L${OSPL_HOME}/lib \
-lpthread -lddskernel -ldcpssacpp \
-lboost_system -lboost_thread \
`fltk-config --ldflags`
INCLUDE := -I$(INC) -I$(GEN_INC) -I. \
-I${OSPL_HOME}/include/dcps/C++/SACPP/ \
-I${OSPL_HOME}/include/sys \
EXT := cpp
MAIN := $(SRC)/main.$(EXT)
TEST_FMT := test_%
TEST_MAIN := $(TEST)/main.$(EXT)
IDLS := $(wildcard $(IDL)/*.idl)
SRCS := $(wildcard $(SRC)/*.$(EXT))
SRCS := $(filter-out $(MAIN), $(SRCS))
GEN_SRCS := $(GEN_SRC)/UberCasino.cpp \
$(GEN_SRC)/UberCasinoDcps.cpp \
$(GEN_SRC)/UberCasinoDcps_impl.cpp \
$(GEN_SRC)/UberCasinoSplDcps.cpp
TEST_SRCS := $(wildcard $(TEST)/*.$(EXT))
TEST_SRCS := $(filter-out $(TEST_MAIN), $(TEST_SRCS))
OBJS := $(patsubst $(SRC)/%.$(EXT), $(OBJ)/%.o, $(SRCS))
GEN_OBJS := $(patsubst $(GEN_SRC)/%.$(EXT), $(OBJ)/%.o, $(GEN_SRCS))
OBJS := $(GEN_OBJS) $(OBJS)
TEST_OBJS := $(patsubst $(TEST)/%.$(EXT), $(OBJ)/$(TEST_FMT), $(TEST_SRCS))
MAIN_OBJ := $(patsubst $(SRC)/%.$(EXT), $(OBJ)/%.o, $(MAIN))
TEST_OBJ := $(patsubst $(TEST)/%.$(EXT), $(OBJ)/$(TEST_FMT).o, $(TEST_MAIN))
################################################################################
# EXECUTABLES #
################################################################################
test: test_build
./$(BIN)/$(TEST_PROD)
.PHONY: test
run: build
./$(BIN)/$(PRODUCT)
.PHONY: run
debug: $(CXXFLAGS) += $(DEBUG_FLAGS)
debug: build
gdb $(BIN)/$(PRODUCT)
.PHONY: run
################################################################################
# BUILDING #
################################################################################
test_build: prebuild $(BIN)/$(TEST_PROD)
.PHONY: test_build
build: prebuild $(BIN)/$(PRODUCT)
.PHONY: build
$(BIN)/$(PRODUCT): $(OBJS) $(MAIN_OBJ)
$(LINKER) $(OBJS) $(MAIN_OBJ) -o $@ $(LFLAGS)
$(MAIN_OBJ): $(MAIN)
$(CXX) $(CXXFLAGS) $(INCLUDE) -c $< -o $@
$(OBJ)/%.o: $(SRC)/%.$(EXT)
$(CXX) $(CXXFLAGS) $(INCLUDE) -c $< -o $@
# Test Objects
$(BIN)/$(TEST_PROD): $(OBJS) $(TEST_OBJS) $(TEST_OBJ)
$(LINKER) $(OBJS) $(TEST_OBJS) $(TEST_OBJ) -o $@ $(LFLAGS)
$(TEST_OBJ): $(TEST_MAIN)
$(CXX) $(CXXFLAGS) $(INCLUDE) -c $< -o $@
$(OBJ)/$(TEST_FMT): $(TEST)/%.$(EXT)
$(CXX) $(CXXFLAGS) $(INCLUDE) -c $< -o $@
# IDL shit
$(GEN_SRCS): $(IDLS)
${OSPL_HOME}/bin/idlpp -d $(GEN) -l cpp $(IDLS)
mv $(GEN)/*.cpp $(GEN_SRC)
mv $(GEN)/*.h $(GEN_INC)
$(OBJ)/%.o: $(GEN_SRC)/%.$(EXT)
sed -i 's/#include "\(.*\)"/#include <\1>/' $<
$(CXX) $(CXXFLAGS) $(INCLUDE) -c $< -o $@
################################################################################
# Miscellaneous #
################################################################################
DIRS := $(BIN) $(OBJ) $(GEN_INC) $(GEN_SRC) $(GEN)
CATCH := "https://github.com/catchorg/Catch2/releases/download/v2.2.2/catch.hpp"
CATCH_FILE := $(TEST)/catch.hpp
prebuild: makedirs $(CATCH_FILE)
.PHONY: prebuild
$(CATCH_FILE):
wget $(CATCH) -O $(CATCH_FILE)
makedirs:
@mkdir -p $(DIRS)
.PHONY: makedirs
clean:
rm -rf $(DIRS)
mkdir -p $(DIRS)
rm -f $(CATCH_FILE)
.PHONY: clean
echo:
@echo "SRCS = $(SRCS)"
@echo "GEN_SRCS = $(GEN_SRCS)"
@echo "TEST_SRCS = $(TEST_SRCS)"
@echo "FLTK_SRCS = $(FLTK_SRCS)"
@echo "OBJS = $(OBJS)"
@echo "TEST_OBJS = $(TEST_OBJS)"
.PHONY: echo
@mkdir -p $(BIN) $(OBJ)
.PHONY: makedirs