-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
executable file
·51 lines (38 loc) · 1.21 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
# names of the basic deriectories
SRC_DIR = src
INC_DIR = include
LIB_DIR = libs
BUILD_DIR = build
LIB_INCLUDE = -I$(LIB_DIR)/tclap-1.2.1/include
LIB_LINK = -L/usr/lib64 -Wl,-Bstatic -llua -Wl,-Bdynamic
#list all source files in SRC_DIR
SRC_FILES += $(wildcard $(SRC_DIR)/*.cpp)
# set the flags for the compilers
CXX_FLAGS := -g -O0 -Wall -pedantic -std=c++11
CC_FLAGS := -g -O0 -Wall -pedantic
ifdef OPT
CXX_FLAGS := -O3 -Wall -pedantic -std=c++11
CC_FLAGS := -O3 -Wall -pedantic
endif
CXX := g++
CC := gcc
#cpu dco
OBJ_FILES_T = $(patsubst $(SRC_DIR)/%.cpp,$(BUILD_DIR)/%.o,$(SRC_FILES))
OBJ_FILES = $(patsubst $(SRC_DIR)/%.c,$(BUILD_DIR)/%.o,$(OBJ_FILES_T))
INC = -I$(INC_DIR) $(LIB_INCLUDE)
FactorioViewer: $(OBJ_FILES)
$(CXX) $(CXX_FLAGS) -o FactorioViewer $(OBJ_FILES) $(LIB_LINK)
$(BUILD_DIR)/%.o : $(SRC_DIR)/%.c
@mkdir -p $(@D)
$(CC) $(CC_FLAGS) -c $< -o $@ $(INC)
@$(CC) $(CC_FLAGS) -MM $< -MP -MT $@ -MF $(@:.o=.d) $(INC)
$(BUILD_DIR)/%.o : $(SRC_DIR)/%.cpp
@mkdir -p $(@D)
$(CXX) $(CXX_FLAGS) -c $< -o $@ $(INC)
@$(CXX) $(CXX_FLAGS) -MM $< -MP -MT $@ -MF $(@:.o=.d) $(INC)
.PHONY: clean
clean:
rm -f FactorioViewer
rm -r build/*
#include the dependencie files
-include $(OBJ_FILES:.o=.d)