-
Notifications
You must be signed in to change notification settings - Fork 9
/
Makefile
76 lines (65 loc) · 1.84 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
#
# compile release: ./make
# compile debug: ./make --debug
#
first: all
#### Defige release/debug dependent vars
ifdef debug
OBJECTS_DIR := Debug
CXXFLAGS = -Wall -ggdb -g3 -DDEBUG
else
OBJECTS_DIR := Release
CXXFLAGS = -Wall -O2
endif
#### SOURCES
SRC_DIR = ./src
OBJ_DIR := $(OBJECTS_DIR)
SRC := dataparser.cpp \
dbstruct.cpp \
freader.cpp \
getopt.cpp \
misc.cpp
HDR = dataparser.h \
dbstruct.h \
freader.h \
misc.h \
getopt.hpp \
messager.hpp
### Define compile variables
MAKEFILE = Makefile
CC = gcc
CXX = g++
INCPATH = -I"." \
-I"./src"
LINK = g++
LFLAGS =
LIBS =
DEL_FILE = rm -f
DEL_DIR = rm -rf
MKDIR = mkdir -p
CXXOUTPUT = -o
### SOURCES TRANSLATION
HDR = $(addprefix $(SRC_DIR)/,$(HDR))
OBJ := $(addprefix $(OBJ_DIR)/,$(addsuffix .obj,$(basename $(SRC))))
SRC = $(addprefix $(SRC_DIR)/,$(SRC))
### Build directory creation/deletion
mk_dir:
-@$(MKDIR) $(OBJECTS_DIR)
clean:
-@$(DEL_DIR) $(OBJECTS_DIR)
#### Implicit rules
$(OBJ_DIR)/%.obj: $(SRC_DIR)/%.cpp
$(CXX) $(CXXFLAGS) $(INCPATH) $(CXXOUTPUT)$@ -c $<
all: mk_dir cro2sql.exe test
without_test: mk_dir cro2sql.exe
$(OBJECTS_DIR)/main.obj : $(SRC_DIR)/main.cpp
$(CXX) $(CXXFLAGS) $(INCPATH) $(CXXOUTPUT)$@ -c $<
cro2sql.exe : $(OBJ) $(OBJECTS_DIR)/main.obj
$(LINK) $(LFLAGS) -o $(OBJECTS_DIR)/cro2sql.exe $(OBJ) $(OBJECTS_DIR)/main.obj $(LIBS)
test: mk_dir test.exe
# test
$(OBJECTS_DIR)/test.obj : test/test.cpp
$(CXX) $(CXXFLAGS) $(INCPATH) $(CXXOUTPUT)$@ -c $<
test.exe: $(OBJ) $(OBJECTS_DIR)/test.obj
$(LINK) $(LFLAGS) -o $(OBJECTS_DIR)/test.exe $(OBJ) $(OBJECTS_DIR)/test.obj $(LIBS)
.PHONY: all first test without_test