Skip to content

Commit 39d4404

Browse files
committed
Makefile for static linking.
1 parent 66a113e commit 39d4404

1 file changed

Lines changed: 51 additions & 0 deletions

File tree

Makefile

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# names of the basic deriectories
2+
SRC_DIR = src
3+
INC_DIR = include
4+
LIB_DIR = libs
5+
BUILD_DIR = build
6+
7+
LIB_INCLUDE = -I$(LIB_DIR)/tclap-1.2.1/include
8+
LIB_LINK = -L/usr/lib64 -Wl,-Bstatic -llua -Wl,-Bdynamic
9+
10+
#list all source files in SRC_DIR
11+
SRC_FILES += $(wildcard $(SRC_DIR)/*.cpp)
12+
13+
# set the flags for the compilers
14+
CXX_FLAGS := -g -O0 -Wall -pedantic -std=c++11
15+
CC_FLAGS := -g -O0 -Wall -pedantic
16+
17+
ifdef OPT
18+
CXX_FLAGS := -O3 -Wall -pedantic -std=c++11
19+
CC_FLAGS := -O3 -Wall -pedantic
20+
endif
21+
22+
CXX := g++
23+
CC := gcc
24+
25+
#cpu dco
26+
OBJ_FILES_T = $(patsubst $(SRC_DIR)/%.cpp,$(BUILD_DIR)/%.o,$(SRC_FILES))
27+
OBJ_FILES = $(patsubst $(SRC_DIR)/%.c,$(BUILD_DIR)/%.o,$(OBJ_FILES_T))
28+
29+
30+
INC = -I$(INC_DIR) $(LIB_INCLUDE)
31+
32+
FactorioViewer: $(OBJ_FILES)
33+
$(CXX) $(CXX_FLAGS) -o FactorioViewer $(OBJ_FILES) $(LIB_LINK)
34+
35+
$(BUILD_DIR)/%.o : $(SRC_DIR)/%.c
36+
@mkdir -p $(@D)
37+
$(CC) $(CC_FLAGS) -c $< -o $@ $(INC)
38+
@$(CC) $(CC_FLAGS) -MM $< -MP -MT $@ -MF $(@:.o=.d) $(INC)
39+
40+
$(BUILD_DIR)/%.o : $(SRC_DIR)/%.cpp
41+
@mkdir -p $(@D)
42+
$(CXX) $(CXX_FLAGS) -c $< -o $@ $(INC)
43+
@$(CXX) $(CXX_FLAGS) -MM $< -MP -MT $@ -MF $(@:.o=.d) $(INC)
44+
45+
.PHONY: clean
46+
clean:
47+
rm -f FactorioViewer
48+
rm -r build/*
49+
50+
#include the dependencie files
51+
-include $(OBJ_FILES:.o=.d)

0 commit comments

Comments
 (0)