-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
58 lines (45 loc) · 1.58 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
CC := g++
CXXFLAGS := -std=c++17 -Wall -Wextra -g
BIN := bin
SRC := src
INCLUDE := include /usr/include/python3.8
LIB := lib
LIBRARIES := -lrt -lpthread -lmysqlclient -lpython3.8
EXECUTABLE1 := server
EXECUTABLE2 := cgi
EXECUTABLE3 := stress
SOURCEDIRS := $(SRC)
SOURCEDIRS1 := $(shell find $(SRC)/server -type d)
SOURCEDIRS2 := $(shell find $(SRC)/cgi -type d)
SOURCEDIRS3 := $(shell find $(SRC)/stress -type d)
INCLUDEDIRS := $(shell find $(INCLUDE) -type d)
LIBDIRS := $(shell find $(LIB) -type d)
CINCLUDES := $(patsubst %,-I%, $(INCLUDEDIRS:%/=%))
CLIBS := $(patsubst %,-L%, $(LIBDIRS:%/=%))
SOURCES := $(wildcard $(patsubst %,%/*.cpp, $(SOURCEDIRS)))
SOURCES1 := $(wildcard $(patsubst %,%/*.cpp, $(SOURCEDIRS1)))
SOURCES2 := $(wildcard $(patsubst %,%/*.cpp, $(SOURCEDIRS2)))
SOURCES3 := $(wildcard $(patsubst %,%/*.cpp, $(SOURCEDIRS3)))
OBJECTS1 := $(SOURCES:.cpp=.o) $(SOURCES1:.cpp=.o)
OBJECTS2 := $(SOURCES:.cpp=.o) $(SOURCES2:.cpp=.o)
OBJECTS3 := $(SOURCES:.cpp=.o) $(SOURCES3:.cpp=.o)
all: $(BIN)/$(EXECUTABLE1) $(BIN)/$(EXECUTABLE2) $(BIN)/$(EXECUTABLE3)
.PHONY: all
.PHONY: clean
clean:
-$(RM) $(BIN)/$(EXECUTABLE1)
-$(RM) $(BIN)/$(EXECUTABLE2)
-$(RM) $(BIN)/$(EXECUTABLE3)
-$(RM) $(OBJECTS1)
-$(RM) $(OBJECTS2)
-$(RM) $(OBJECTS3)
run: all
./$(BIN)/$(EXECUTABLE)
$(BIN)/$(EXECUTABLE1): $(OBJECTS1)
$(CC) $(CXXFLAGS) $(CLIBS) $^ -o $@ $(LIBRARIES)
$(BIN)/$(EXECUTABLE2): $(OBJECTS2)
$(CC) $(CXXFLAGS) $(CLIBS) $^ -o $@ $(LIBRARIES)
$(BIN)/$(EXECUTABLE3): $(OBJECTS3)
$(CC) $(CXXFLAGS) $(CLIBS) $^ -o $@ $(LIBRARIES)
%.o: %.cpp
$(CC) $(CXXFLAGS) $(CINCLUDES) -c -o $@ $<