-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathMakefile
146 lines (99 loc) · 3.9 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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
# Name of the app executable to build
DXAPI_LIB_FULL=lib$(DXAPI_LIB).a
TEST_APP=dxapi-cpp-unit-tests
BUILD_TARGETS=$(DXAPI_LIB_FULL) $(TEST_APP)
BUILD_TARGET_PATHS=$(DXAPI_LIB_PATH) $(BINDIR)/$(TEST_APP)
CLEAN_TARGETS=clean-$(DXAPI_LIB_FULL) clean-$(TEST_APP)
# Names of C/C++ source files to build, without path/extension
OBJ_LIB=data_reader data_writer loader_manager session_handler symbol_translator tickstream_cache tickdb\
tickstream_impl tickstream_properties qqlstate schema instrument_identity interval\
data_reader_http tickcursor_http tickcursor_subscriptions tickdb_http tickdb_stream_requests tickloader_http uri\
get_server_time_request list_streams_request load_streams_request selection_options_impl stream_options_impl\
list_entities_request lock_stream_request periodicity_request schema_request timerange_request list_spaces_request rename_space_request delete_spaces_request describe_stream_request bg_proc_info_impl\
tickdb_class_descriptor validate_qql_request bg_process_request xml_request charbuffer\
platform streams tcp qpc_timer tinyxml2
# schema_change_request
OBJ_TEST_APP=unit-tests-main tests-common\
test-xmloutput session-handler tickstream-basic srw-locks misc-strings data-reader-unchunk timebase_starter
OBJ=$(OBJ_LIB) $(OBJ_TEST_APP)
# Source files inside $(SRCDIR)
SRCDIRS=tickdb tickdb/http tickdb/http/xml tickdb/http/xml/stream tickdb/http/xml/cursor platform util io xml/tinyxml2 ../../dxapi-unit-tests ../../
# Include directories
INCLUDES=include/native src/dxapi/native
# Library files
# LIBS=lib1 lib2
LIBS=
# Common preprocessor flags
COMMONPFLAGS=
# Platforms
PLATFORM=x64
#build Release by default
DEBUG?=0
ifeq ($(DEBUG),1)
# C preprocessor flags to define
PFLAGS=$(COMMONPFLAGS) _DEBUG DEBUG
# C/C++ compiler flags
CFLAGS=-O0 -g
DXAPI_LIB=dxapi-$(PLATFORM)d
else
# Note that NDEBUG will disable assertions
PFLAGS=$(COMMONPFLAGS) NDEBUG
CFLAGS=-O3
DXAPI_LIB=dxapi-$(PLATFORM)
endif
# Example: rebuild with clang in Debug mode
# CC=clang;make clean;make DEBUG=1
#==============================================================================
# Binary files are put here
BINDIR=bin
# Temporary object files are put here
OBJDIR=obj
# C/C++ source code files and internal includes are here
SRCDIR=src/dxapi/native
#==============================================================================
# Default C/C++ compiler
CC?=clang
#==============================================================================
# Choose C++ compiler from C compiler
ifeq ($(CC),gcc)
CXX=g++
endif
ifeq ($(CC),clang)
CXX=clang++
endif
EMPTY:=
SPACE:= $(EMPTY) $(EMPTY)
CWARNINGS=-Wall -Wno-multichar -Wno-unused-function -Wno-unused-value
CINCLUDES=-I. $(INCLUDES:%=-I%)
# Some more advanced perf. flags
# FL = -m64 -msse2 -fno-exceptions -fno-unwind-tables
CCFLAGS=-fPIC $(CFLAGS) $(CINCLUDES) $(CWARNINGS) $(PFLAGS:%=-D %)
CXXFLAGS=-std=c++11 $(CCFLAGS)
DEFLIBS=stdc++ c m pthread
# Popular libs: rt-realtime extensions, pcap-packet capture, pthread-Posix threads
LDFLAGS=$(patsubst %, -l%, $(DEFLIBS) $(LIBS))
OUTDIRS=$(OBJDIR) $(BINDIR)
VPATH=$(SRCDIR):$(SRCDIRS:%=$(SRCDIR)/%)
#==============================================================================
build: dirs $(BUILD_TARGET_PATHS)
clean: $(CLEAN_TARGETS)
-rm obj/*.o
$(OUTDIRS):
mkdir $@
dirs: $(OUTDIRS)
$(OBJDIR)/%.o: %.cpp
$(CXX) -c $(CXXFLAGS) -o $@ $<
$(OBJDIR)/%.o: %.c
$(CC) -c $(CFLAGS) -o $@ $<
.PHONY: build clean dirs
#==============================================================================
DXAPI_LIB_PATH=$(BINDIR)/$(DXAPI_LIB_FULL)
DXAPI_LIB_OBJ_PATHS=$(OBJ_LIB:%=$(OBJDIR)/%.o)
TEST_APP_OBJ_PATHS=$(OBJ_TEST_APP:%=$(OBJDIR)/%.o)
$(DXAPI_LIB_PATH): $(OBJ_LIB:%=$(OBJDIR)/%.o)
$(AR) rcs $@ $^
$(BINDIR)/$(TEST_APP): $(TEST_APP_OBJ_PATHS) $(DXAPI_LIB_PATH)
$(CXX) -o $@ $(TEST_APP_OBJ_PATHS) $(LDFLAGS) -L$(BINDIR)/ -l$(DXAPI_LIB)
$(CLEAN_TARGETS):
-rm $(@:clean-%=$(BINDIR)/%)
.PHONY: $(CLEAN_TARGETS)