forked from hoxnox/cro2sql
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile.mingw
executable file
·77 lines (67 loc) · 1.97 KB
/
Makefile.mingw
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
#
# 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 = del /Q
DEL_DIR = rmdir /Q /S
CHK_DIR_NEXISTS = if not exist
CHK_DIR_EXISTS = if exist
MKDIR = mkdir
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:
-@$(CHK_DIR_NEXISTS) $(OBJECTS_DIR) $(MKDIR) $(OBJECTS_DIR)
clean:
-@$(CHK_DIR_EXISTS) $(OBJECTS_DIR) $(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