-
Notifications
You must be signed in to change notification settings - Fork 235
/
Makefile
266 lines (234 loc) · 8.95 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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
# See what Lua versions are installed
# order of preference: LuaJIT, any generic Lua, then versions from 5.4 down
PLATFORM_PATH := /usr/local
# First, find what the Lua executable is called
# - when a new Lua is released, then add it before 5.4 here
LUA_CMD := $(shell luajit -e 'print("luajit")' 2> /dev/null || lua -e 'print("lua")' 2> /dev/null || lua5.4 -e 'print("lua5.4")' 2> /dev/null || lua5.3 -e 'print("lua5.3")' 2> /dev/null || lua5.2 -e 'print("lua5.2")' 2> /dev/null || lua5.1 -e 'print("lua5.1")' 2> /dev/null)
ifeq ($(LUA_CMD),"")
$(error Couldn't find Lua interpreter)
endif
$(info Using ${LUA_CMD})
# Find the language version
LUA_LANGV := $(shell ${LUA_CMD} -e 'print(string.match(_VERSION, "%d+.%d+"))')
$(info - Lua language version ${LUA_LANGV})
# Find the directory where Lua might be
ifeq ($(LUA_CMD),luajit)
# We need the LuaJIT version (2.0/2.1) to find this
LUA_JITV := $(shell luajit -e 'a,b,c=string.find(jit.version,"LuaJIT (%d.%d)");print(c)')
$(info - LuaJIT version ${LUA_JITV})
LUA_DIR := luajit-${LUA_JITV}
LUA_LIBS := -lluajit-${LUA_LANGV}
else
LUA_DIR := $(LUA_CMD)
LUA_LIBS := -l${LUA_CMD}
endif
# Find the include path by looking in the most likely locations
ifneq ('$(wildcard /usr/local/include/${LUA_DIR}/lua.h)','')
LUA_CFLAGS := -I/usr/local/include/${LUA_DIR}
else ifneq ('$(wildcard /usr/local/include/${LUA_DIR}${LUA_LANGV}/lua.h)','')
LUA_CFLAGS := -I/usr/local/include/${LUA_DIR}${LUA_LANGV}
LUA_LIBS := -l${LUA_CMD}${LUA_LANGV}
else ifneq ('$(wildcard /usr/include/${LUA_DIR}/lua.h)','')
LUA_CFLAGS := -I/usr/include/${LUA_DIR}
else ifneq ('$(wildcard /usr/include/${LUA_DIR}${LUA_LANGV}/lua.h)','')
LUA_CFLAGS := -I/usr/include/${LUA_DIR}${LUA_LANGV}
LUA_LIBS := -l${LUA_CMD}${LUA_LANGV}
else ifneq ('$(wildcard /usr/include/lua.h)','')
LUA_CFLAGS := -I/usr/include
else ifneq ('$(wildcard /opt/homebrew/include/${LUA_DIR}/lua.h)','')
LUA_CFLAGS := -I/opt/homebrew/include/${LUA_DIR}
PLATFORM_PATH := /opt/homebrew
else ifneq ('$(wildcard /opt/homebrew/include/${LUA_DIR}${LUA_LANGV}/lua.h)','')
LUA_CFLAGS := -I/opt/homebrew/include/${LUA_DIR}${LUA_LANGV}
LUA_LIBS := -l${LUA_CMD}${LUA_LANGV}
PLATFORM_PATH := /opt/homebrew
else
$(error Couldn't find Lua libraries)
endif
# Append LuaJIT-specific flags if needed
ifeq ($(LUA_CMD),luajit)
LUA_CFLAGS := ${LUA_CFLAGS} -DLUAJIT
ifneq ($(OS),Windows_NT)
ifeq ($(shell uname -s), Darwin)
ifeq ($(LUA_JITV),2.0)
LDFLAGS := -pagezero_size 10000 -image_base 100000000
$(info - with MacOS LuaJIT linking)
endif
endif
endif
endif
# Report success
$(info - include path is ${LUA_CFLAGS})
$(info - library path is ${LUA_LIBS})
# Main includes
prefix = /usr/local
MANPREFIX := /usr/share/man
TM_VERSION ?= $(shell git describe --tags --abbrev=0)
CXXFLAGS ?= -O3 -Wall -Wno-unknown-pragmas -Wno-sign-compare -std=c++14 -pthread -fPIE -DTM_VERSION=$(TM_VERSION) $(CONFIG)
CFLAGS ?= -O3 -Wall -Wno-unknown-pragmas -Wno-sign-compare -std=c99 -fPIE -DTM_VERSION=$(TM_VERSION) $(CONFIG)
LIB := -L$(PLATFORM_PATH)/lib $(LUA_LIBS) -lboost_program_options -lsqlite3 -lboost_filesystem -lboost_system -lshp -pthread
INC := -I$(PLATFORM_PATH)/include -isystem ./include -I./src $(LUA_CFLAGS)
# Targets
.PHONY: test
all: tilemaker server
tilemaker: \
src/attribute_store.o \
src/coordinates_geom.o \
src/coordinates.o \
src/external/streamvbyte_decode.o \
src/external/streamvbyte_encode.o \
src/external/streamvbyte_zigzag.o \
src/external/libdeflate/lib/adler32.o \
src/external/libdeflate/lib/arm/cpu_features.o \
src/external/libdeflate/lib/crc32.o \
src/external/libdeflate/lib/deflate_compress.o \
src/external/libdeflate/lib/deflate_decompress.o \
src/external/libdeflate/lib/gzip_compress.o \
src/external/libdeflate/lib/gzip_decompress.o \
src/external/libdeflate/lib/utils.o \
src/external/libdeflate/lib/x86/cpu_features.o \
src/external/libdeflate/lib/zlib_compress.o \
src/external/libdeflate/lib/zlib_decompress.o \
src/geojson_processor.o \
src/geom.o \
src/helpers.o \
src/mbtiles.o \
src/mmap_allocator.o \
src/node_stores.o \
src/options_parser.o \
src/osm_lua_processing.o \
src/osm_mem_tiles.o \
src/osm_store.o \
src/output_object.o \
src/pbf_processor.o \
src/pbf_reader.o \
src/pmtiles.o \
src/pooled_string.o \
src/relation_roles.o \
src/sharded_node_store.o \
src/sharded_way_store.o \
src/shared_data.o \
src/shp_mem_tiles.o \
src/shp_processor.o \
src/significant_tags.o \
src/sorted_node_store.o \
src/sorted_way_store.o \
src/tag_map.o \
src/tile_coordinates_set.o \
src/tile_data.o \
src/tilemaker.o \
src/tile_worker.o \
src/visvalingam.o \
src/way_stores.o
$(CXX) $(CXXFLAGS) -o tilemaker $^ $(INC) $(LIB) $(LDFLAGS)
test: \
test_append_vector \
test_attribute_store \
test_deque_map \
test_helpers \
test_options_parser \
test_pbf_reader \
test_pooled_string \
test_relation_roles \
test_significant_tags \
test_sorted_node_store \
test_sorted_way_store \
test_tile_coordinates_set
test_append_vector: \
src/mmap_allocator.o \
test/append_vector.test.o
$(CXX) $(CXXFLAGS) -o test.append_vector $^ $(INC) $(LIB) $(LDFLAGS) && ./test.append_vector
test_attribute_store: \
src/mmap_allocator.o \
src/attribute_store.o \
src/pooled_string.o \
test/attribute_store.test.o
$(CXX) $(CXXFLAGS) -o test.attribute_store $^ $(INC) $(LIB) $(LDFLAGS) && ./test.attribute_store
test_deque_map: \
test/deque_map.test.o
$(CXX) $(CXXFLAGS) -o test.deque_map $^ $(INC) $(LIB) $(LDFLAGS) && ./test.deque_map
test_helpers: \
src/helpers.o \
src/external/libdeflate/lib/adler32.o \
src/external/libdeflate/lib/arm/cpu_features.o \
src/external/libdeflate/lib/crc32.o \
src/external/libdeflate/lib/deflate_compress.o \
src/external/libdeflate/lib/deflate_decompress.o \
src/external/libdeflate/lib/gzip_compress.o \
src/external/libdeflate/lib/gzip_decompress.o \
src/external/libdeflate/lib/utils.o \
src/external/libdeflate/lib/x86/cpu_features.o \
src/external/libdeflate/lib/zlib_compress.o \
src/external/libdeflate/lib/zlib_decompress.o \
test/helpers.test.o
$(CXX) $(CXXFLAGS) -o test.helpers $^ $(INC) $(LIB) $(LDFLAGS) && ./test.helpers
test_options_parser: \
src/options_parser.o \
test/options_parser.test.o
$(CXX) $(CXXFLAGS) -o test.options_parser $^ $(INC) $(LIB) $(LDFLAGS) && ./test.options_parser
test_pooled_string: \
src/mmap_allocator.o \
src/pooled_string.o \
test/pooled_string.test.o
$(CXX) $(CXXFLAGS) -o test.pooled_string $^ $(INC) $(LIB) $(LDFLAGS) && ./test.pooled_string
test_relation_roles: \
src/relation_roles.o \
test/relation_roles.test.o
$(CXX) $(CXXFLAGS) -o test.relation_roles $^ $(INC) $(LIB) $(LDFLAGS) && ./test.relation_roles
test_significant_tags: \
src/significant_tags.o \
src/tag_map.o \
test/significant_tags.test.o
$(CXX) $(CXXFLAGS) -o test.significant_tags $^ $(INC) $(LIB) $(LDFLAGS) && ./test.significant_tags
test_sorted_node_store: \
src/external/streamvbyte_decode.o \
src/external/streamvbyte_encode.o \
src/external/streamvbyte_zigzag.o \
src/mmap_allocator.o \
src/sorted_node_store.o \
test/sorted_node_store.test.o
$(CXX) $(CXXFLAGS) -o test.sorted_node_store $^ $(INC) $(LIB) $(LDFLAGS) && ./test.sorted_node_store
test_sorted_way_store: \
src/external/streamvbyte_decode.o \
src/external/streamvbyte_encode.o \
src/external/streamvbyte_zigzag.o \
src/mmap_allocator.o \
src/sorted_way_store.o \
test/sorted_way_store.test.o
$(CXX) $(CXXFLAGS) -o test.sorted_way_store $^ $(INC) $(LIB) $(LDFLAGS) && ./test.sorted_way_store
test_tile_coordinates_set: \
src/tile_coordinates_set.o \
test/tile_coordinates_set.test.o
$(CXX) $(CXXFLAGS) -o test.tile_coordinates_set $^ $(INC) $(LIB) $(LDFLAGS) && ./test.tile_coordinates_set
test_pbf_reader: \
src/helpers.o \
src/pbf_reader.o \
src/external/libdeflate/lib/adler32.o \
src/external/libdeflate/lib/arm/cpu_features.o \
src/external/libdeflate/lib/crc32.o \
src/external/libdeflate/lib/deflate_compress.o \
src/external/libdeflate/lib/deflate_decompress.o \
src/external/libdeflate/lib/gzip_compress.o \
src/external/libdeflate/lib/gzip_decompress.o \
src/external/libdeflate/lib/utils.o \
src/external/libdeflate/lib/x86/cpu_features.o \
src/external/libdeflate/lib/zlib_compress.o \
src/external/libdeflate/lib/zlib_decompress.o \
test/pbf_reader.test.o
$(CXX) $(CXXFLAGS) -o test.pbf_reader $^ $(INC) $(LIB) $(LDFLAGS) && ./test.pbf_reader
server: \
server/server.o
$(CXX) $(CXXFLAGS) -o tilemaker-server $^ $(INC) $(LIB) $(LDFLAGS)
%.o: %.cpp
$(CXX) $(CXXFLAGS) -o $@ -c $< $(INC)
%.o: %.c
$(CC) $(CFLAGS) -o $@ -c $< $(INC)
install:
install -m 0755 -d $(DESTDIR)$(prefix)/bin/
install -m 0755 tilemaker $(DESTDIR)$(prefix)/bin/
install -m 0755 tilemaker-server $(DESTDIR)$(prefix)/bin/
@install -m 0755 -d ${DESTDIR}${MANPREFIX}/man1/ || true
@install docs/man/tilemaker.1 ${DESTDIR}${MANPREFIX}/man1/ || true
clean:
rm -f tilemaker tilemaker-server src/*.o src/external/*.o src/external/libdeflate/lib/*.o src/external/libdeflate/lib/*/*.o include/*.o include/*.pb.h server/*.o test/*.o
.PHONY: install