-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathmakefile.env
More file actions
executable file
·517 lines (395 loc) · 15.3 KB
/
Copy pathmakefile.env
File metadata and controls
executable file
·517 lines (395 loc) · 15.3 KB
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
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
# This file is part of SECONDO.
#
# Copyright (C) 2004, University in Hagen, Department of Computer Science,
# Database Systems for New Applications.
#
# SECONDO is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# SECONDO is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with SECONDO; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
########################################################################
#
# SECONDO makefile.env - definition of global macro values included by
# every other makefile.
#
#######################################################################
# Derive the build environment -- platform, SWI-Prolog, JDK, Berkeley DB, the
# macOS keg-only prefixes, optional libraries -- from the tools installed on
# this machine.
SECONDO_ENV_DIR := $(patsubst %/,%,$(dir $(lastword $(MAKEFILE_LIST))))
include $(SECONDO_ENV_DIR)/makefile.detect
SHELL = /bin/bash
# Abort a recipe at the first failing command. Without -e, only the exit status
# of the *last* command in a multi-line continued recipe is checked, so an
# intermediate failure was silently ignored and the build carried on with a
# half-produced result.
.SHELLFLAGS := -ec
# OS-Type
platform := $(SECONDO_PLATFORM)
ifndef platform
$(error Variable SECONDO_PLATFORM not defined. Set it to linux, linux64, android, win32 or mac_osx!)
endif
# Berkeley DB library
ifdef BERKELEY_DB_LIB
BDB_LIB := -l$(BERKELEY_DB_LIB)
else
BDB_LIB := -ldb_cxx
endif
# Secondo build directory
BUILDDIR := $(SECONDO_BUILD_DIR)
TYPEMAPLIB=$(BUILDDIR)/lib/libTypeMapper.a
TYPEMAPFLAG=-lTypeMapper
ifndef BUILDDIR
$(error Variable SECONDO_BUILD_DIR not defined. I do not know the root directory of the SECONDO source tree!)
endif
ifeq ($(platform),android)
CFLAGS += -I $(HOME)/toolchain-standalone/include
endif
ifdef BERKELEY_DB_DIR
ifndef BDB_INCLUDE_DIR
BDB_INCLUDE_DIR := $(BERKELEY_DB_DIR)/include
endif
ifndef BDB_LIB_DIR
BDB_LIB_DIR := $(BERKELEY_DB_DIR)/lib
endif
else
ifndef BDB_INCLUDE_DIR
BDB_INCLUDE_DIR := $(SECONDO_SDK)/include
endif
ifndef BDB_LIB_DIR
BDB_LIB_DIR := $(SECONDO_SDK)/lib
endif
endif
# macros for some frequently used commands
ifeq ($(platform),android)
#CC := $(HOME)/toolchain-standalone/bin/arm-linux-androideabi-gcc
CPPC := $(HOME)/toolchain-standalone/bin/arm-linux-androideabi-g++
LD := $(HOME)/toolchain-standalone/bin/arm-linux-androideabi-ld
AR := $(HOME)/toolchain-standalone/bin/arm-linux-androideabi-ar
RANLIB := $(HOME)/toolchain-standalone/bin/arm-linux-androideabi-ranlib
else
CC := gcc
CPPC := g++
LD := gcc
AR := ar
RANLIB := ranlib
endif
ifdef SECONDO_CC
CC := $(SECONDO_CC)
endif
ifdef SECONDO_CPP
CPPC := $(SECONDO_CPP)
endif
ifdef SECONDO_AR
AR := $(SECONDO_AR)
endif
ifdef SECONDO_LD
LD := $(SECONDO_LD)
endif
ifdef SECONDO_RANLIB
RANLIB := $(SECONDO_RANLIB)
endif
CP := cp
RM := rm -f
RC := windres
ifndef SECONDO_LEX
LEX := flex
else
LEX := $(SECONDO_LEX)
endif
ifndef SECONDO_YACC
YACC := bison
else
YACC := $(SECONDO_YACC)
endif
# Check if optimizer should be compiled
include $(BUILDDIR)/makefile.optimizer
# set the java compiler
ifndef SECONDO_JAVAC
JAVAC := javac
else
JAVAC := $(SECONDO_JAVAC)
endif
#set the standard classpath
CLASSPATH = .
# define directories
INCLUDEDIR := $(BUILDDIR)/include
LIBDIR := $(BUILDDIR)/lib
BINDIR := $(BUILDDIR)/bin
OPTDIR := $(BUILDDIR)/Optimizer
# The objects and dependency files built from the *.cpp in this directory.
CPP_FILES = $(wildcard *.cpp)
OBJECTS = $(CPP_FILES:.cpp=.$(OBJEXT))
DEP_FILES = $(CPP_FILES:.cpp=.dep)
# add directories with template classes here. Don't forget
# to add an dependency between .h and .cpp file in the file
# include.dep.
TEMPLATES := \
Tools/ListsAndTables
TEMPLATEFLAGS := $(addprefix -I$(BUILDDIR)/,$(TEMPLATES))
TEMPLATEDIRS := $(strip $(foreach dir,$(TEMPLATES), $(BUILDDIR)/$(dir):))
# directories where make searches for prerequisites
VPATH := $(INCLUDEDIR):$(TEMPLATEDIRS)$(LIBDIR):$(BINDIR)
# compilation options for the PROLOG shell
ifdef PL_INCLUDE_DIR
PLINCLUDEFLAGS := -I$(PL_INCLUDE_DIR)
else
$(info switch off optimizer)
DEFAULTCCFLAGS += -DNO_OPTIMIZER
endif
# load Platform specific definitions.
# "linux" and "linux64" are both valid platforms but need identical settings
include $(BUILDDIR)/makefile.$(subst linux64,linux,$(platform))
# load options
include $(BUILDDIR)/makefile.options
# Set up directory search
ifdef BDB_INCLUDE_DIR
DEFAULTCCFLAGS += -I$(BDB_INCLUDE_DIR)
endif
ifdef SECONDO_LIB_INCLUDE_FLAGS
DEFAULTCCFLAGS += $(SECONDO_LIB_INCLUDE_FLAGS)
endif
ifdef SECONDO_ADDITIONAL_DEFAULTCCFLAGS
DEFAULTCCFLAGS += $(SECONDO_ADDITIONAL_DEFAULTCCFLAGS)
endif
#DEFAULTCCFLAGS += -std=c++17
# DEFAULTCCFLAGS += -DSM_FILE_ID
# when commenting out or in the SM_FILE_ID flag,
# the involved files should be recompiled
# otherwise it may lead to runtime errors.
# This can be done by running "make clean; make"
# note that using this flag required an installed boost library
# (developer version)
# THREAD_SAFE switches on the locks in the classes that the client library and
# the kernel share -- NestedList, NLParser, MessageCenter. It is not merely a
# matter of losing those locks when it is off: the flag adds a mutex *member*
# to NestedList (see include/NestedList.h), so it changes the class layout. A
# library and a consumer that disagree about it do not fail to link, they
# corrupt memory.
DEFAULTCCFLAGS += -pthread -DTHREAD_SAFE
COMMON_LD_FLAGS += -lboost_thread
# Build with ThreadSanitizer: "make SECONDO_TSAN=1". Meant for a whole tree
# build -- the kernel, every algebra and the server processes -- which is what
# the build-linux-tsan CI job does. Instrumenting only part of a binary is what
# produces phantom reports, so there is no supported way to sanitize a subset.
#
# Both link variables are set because neither reaches every binary on its own:
# COMMON_LD_FLAGS covers the ClientServer daemons, the UserInterfaces apps,
# Tests/ and SpecParser, while a handful of makefiles (Algebras/Temporal2,
# Raster2/Import, HadoopParallel/askFlob, Optimizer/MemoryAllocation,
# InteractiveQueryEditor) name only LDFLAGS. Appending to LDFLAGS is safe only
# here, below the include of makefile.$(platform), which assigns it with ":=".
#
# -O1 rather than -O2 because TSan keeps more of the stack frames that make a
# report readable, and the sanitizer dominates the run time anyway. Note that
# the tree is otherwise built without any -O, so this changes every object --
# and objects built with and without it must not be mixed: build into a clean
# tree, or "make clean" first.
ifdef SECONDO_TSAN
DEFAULTCCFLAGS += -fsanitize=thread -fno-omit-frame-pointer -g -O1
COMMON_LD_FLAGS += -fsanitize=thread
LDFLAGS += -fsanitize=thread
endif
# the macro below should be used in local makefiles to
# add specific flags
DEFAULTCCFLAGS += -I$(BUILDDIR)
# The platform a binary was built for
DEFAULTCCFLAGS += -DSECONDO_PLATFORM_NAME=\"$(platform)\"
CCFLAGS = $(DEFAULTCCFLAGS)
# Storage Manager suffix
SMIUP:=BDB
SMILOW:=bdb
# load algebra definitions
alg := auto
# $(wildcard) rather than a shell test: this file is read by ~260 makefiles
# and again by every recursive $(MAKE), so a fork here is a fork per sub-make.
HAS_ALGDEF := $(wildcard $(BUILDDIR)/makefile.algebras)
ifneq ($(HAS_ALGDEF),)
include $(BUILDDIR)/makefile.algebras
else
include $(BUILDDIR)/makefile.algebras.sample
endif
# The GeneralTree algebra registers additional distance functions and distance
# data types for the MP3 and ImageSimilarity attribute types, but only when
# those algebras are part of the build. Derive the flags from the algebra list
# instead of asking for a second, manually maintained switch that would silently
# drift from it.
ifneq (,$(findstring MP3Algebra,$(ALGEBRAS)))
CCFLAGS += -DHAS_MP3
endif
ifneq (,$(findstring ImageSimilarityAlgebra,$(ALGEBRAS)))
CCFLAGS += -DHAS_IMAGESIMILARITY
endif
# Delete a target if its recipe fails (non-zero exit) or is interrupted, so a
# half-written object, archive or generated source is never left behind and
# mistaken for up to date on the next build.
.DELETE_ON_ERROR:
# compile object and, as a side effect, generate the dependency file
# (%.dep) via -MMD. -MP emits a phony target for each header so that a
# later removed or renamed header does not break the build.
%.o: %.cpp
$(CC) -c -o $@ $< $(CCFLAGS) $(CPPSTDOPTION) -MMD -MP -MF $*.dep
# SECONDO always links executables from objects. Cancel make's built-in rules
# that compile a source straight to a binary, so an executable target is built
# from its object (with the proper CCFLAGS) instead of via the built-in rule.
%: %.cpp
%: %.c
%: %.cc
# Pull in the auto-generated header dependencies for this directory (each %.dep
# is written as a side effect of the %.o rule above). Reading a .dep file would
# otherwise make its first object the default goal; save and restore
# .DEFAULT_GOAL so the local makefile's first target (e.g. "all") stays the
# default when "make" is run with no arguments.
__saved_default_goal := $(.DEFAULT_GOAL)
ifneq ($(MAKECMDGOALS),clean)
-include $(DEP_FILES)
endif
.DEFAULT_GOAL := $(__saved_default_goal)
ifdef SECONDO_ACTIVATE_ALL_ALGEBRAS
ALGEBRA_ARCHIVES := $(subst lib,,$(subst Algebra.a,,$(shell find $(BUILDDIR)/lib -name "lib*Algebra*" | sed 's|.*/||')))
JNIALGEBRAS :=
JNIALGEBRA_DIRS :=
USE_JNI := "true"
include $(BUILDDIR)/makefile.jni
LDFLAGS += $(JNILDFLAGS)
else
# check if JNI algebras are used
ifdef JNIALGEBRAS
ALGEBRA_DIRS += $(JNI_ALGEBRA_DIRS)
ALGEBRAS += $(JNIALGEBRAS)
LDFLAGS += $(JNILDFLAGS)
USE_JNI := "true"
include $(BUILDDIR)/makefile.jni
endif
ifdef SECONDO_LIB_LD_FLAGS
LDFLAGS += $(SECONDO_LIB_LD_FLAGS)
endif
ALGEBRA_ARCHIVES := $(ALGEBRA_DIRS)
endif
# GNU recode support. Detected in makefile.detect, consumed here.
ifeq ($(SECONDO_HAS_RECODE),yes)
DEFAULTLIB += -lrecode
CCFLAGS += -DHAS_RECODE
endif
# define standard rule for creating configuration files by
# copying the sample files.
define cp-config-file
@([ ! -f $@ ] && (cp $< $@; echo ; echo "Make created $@ as a copy of $<")) \
|| (echo ; echo "* Warning: Example file $< is newer than $@"; sleep 2)
endef
SDB_LIBRARIES = \
sdbsys \
sdbnl \
sdbutils \
smi$(SMILOW) \
sdbsocket
# In order to make the managment of linking libraries easier two macros which are used in the linker command are defined.
# This files mainly cover all cases of linkage. Some libraries are not necessary for all applications but
# writing specific rules for every application is more complicated and error prone.
ALGBASE := $(addsuffix Algebra, $(ALGEBRA_ARCHIVES))
ALGLIBS := $(addprefix -l, $(ALGBASE))
ALGDEPS := $(addprefix -L, $(ALGEBRA_DEP_DIRS)) $(addprefix -l, $(ALGEBRA_DEPS))
ALGINCLUDES := $(addprefix -I, $(ALGEBRA_INCLUDE_DIRS))
ALGLINKFLAGS := $(ALGEBRA_LINK_FLAGS)
CCFLAGS += $(ALGINCLUDES)
# The variables below will be used in makefiles at the algebra level. The
# define the name of the library file based on the directory name of the algebra
# without sub directories. For exmaple:
#
# Algebras/Pregel will be ALGEBRA_NAME=Pregel
# Algebras/Pregel/Helper will be ALGEBRA_NAME=Pregel
# Algebras/Pregel/Helper/Helpers will be ALGEBRA_NAME=Pregel
ALGEBRA_NAME := $(firstword $(subst /, ,$(patsubst $(BUILDDIR)/Algebras/%,%,$(CURDIR))))
LIBNAME = lib$(ALGEBRA_NAME)Algebra
LIBOBJ = $(LIBDIR)/$(LIBNAME).$(LIBEXT)
# generic rule for creating an algebra library
ifeq ($(shared),yes)
# ... as shared object
define create-lib
$(LD) $(LDFLAGS) -o $(LIBOBJ) $(TUPLEMANAGER) -L$(LIBDIR) -lStandardAlgebra -lRelationAlgebra $(SMILIB) $(SDBLIB) $(TOOLLIB) $(DEFAULTLIB)
endef
else
# ... as static library
define create-lib
$(AR) -rs $@ $^
endef
endif
# generic rule for cleaning an algebra directory
define clean-algebra
$(RM) $(DEP_FILES) $(OBJECTS) $(LIBOBJ)
endef
#rule for checking for additional algebra dependencies
define check-algebra-dependencies
@for d in $(ALGEBRA_DEPENDENCIES) ; \
do \
if [[ ! "$(ALGEBRAS)" == *$$d* ]];\
then \
echo "Algebras required by $(CURRENT_ALGEBRA) are:"; \
echo "$(ALGEBRA_DEPENDENCIES)" ;\
echo ; \
echo "In $(CURRENT_ALGEBRA) is a dependency to algebra $$d, but this algebra is not included."; \
echo "Please correct your makefile.algebras to be consistent."; \
echo ; \
exit 1; \
fi\
done;
endef
ALGLIBFILES := $(addprefix lib, $(addsuffix .$(LIBEXT),$(ALGBASE)))
ALGLIBFILES += $(JVMINIT_O_FILE)
SECLIBFILES := $(addprefix lib, $(addsuffix .$(LIBEXT),$(SDB_LIBRARIES)))
# There are some circular dependencies between the libraries.
# By putting them into groups with the linker
# options -( -la1 .. -lan -) the archives will be read multiple times. But some
# linkers don't support it.
ifneq ($(platform),mac_osx)
XOPEN := -Xlinker -\(
XCLOSE := -Xlinker -\)
endif
SECLIBS_ALG := $(XOPEN) -lsdbsys $(ALGLIBS) $(ALGDEPS) $(ALGLINKFLAGS) -lsdbnl -lsmi$(SMILOW) -lsdbutils -lsdbsocket $(XCLOSE)
SECLIBS := $(XOPEN) -lsdbsys -lsdbnl -lsmi$(SMILOW) -lsdbutils -lsdbsocket $(XCLOSE)
LIB_FLAGS := -L$(LIBDIR)
ifdef BDB_LIB_DIR
LIB_FLAGS += -L$(BDB_LIB_DIR)
endif
ifdef SECONDO_LIBFLAGS
LIB_FLAGS += $(SECONDO_LIBFLAGS)
endif
LD_LINK_LIBS_ALG := $(SECONDO_LDFLAGS) $(LIB_FLAGS) $(SECLIBS_ALG) $(BDB_LIB) $(DEFAULTLIB) $(JNILINKOPTS) $(TYPEMAPFLAG)
LD_LINK_LIBS := $(SECONDO_LDFLAGS) $(LIB_FLAGS) $(SECLIBS) $(BDB_LIB) $(DEFAULTLIB) $(TYPEMAPFLAG)
# DEFAULTLIB names the C++ standard library explicitly because most links here
# are driven by $(CC), which does not add it. A link driven by $(CPPC) does add
# it, so naming it again is what makes Apple's linker report a duplicate. Use
# this variant wherever the link goes through the C++ driver.
DEFAULTLIB_CXX := $(filter-out -lc++ -lstdc++,$(DEFAULTLIB))
# Every algebra block in makefile.algebras lists the libraries that algebra
# needs, so a library required by several of them lands in COMMON_LD_FLAGS
# several times -- and Apple's linker warns about each repetition. The blocks
# have to stay self contained (the enabled set of algebras varies), so the
# duplicates are removed here instead. It is the last occurrence that is kept:
# with static archives a library has to be listed after the ones using it.
butlast = $(wordlist 2,$(words $1),x $1)
uniq-tail = $(filter-out $(lastword $1),$(call butlast,$1))
uniq-last = $(if $1,$(call uniq-last,$(call uniq-tail,$1)) $(lastword $1))
COMMON_LD_FLAGS := $(strip $(call uniq-last,$(COMMON_LD_FLAGS)))
ifndef ALL_ALGEBRA_DIRS
ALL_ALGEBRA_DIRS := $(shell find $(BUILDDIR)/Algebras -maxdepth 1 -type d $(EXCLUDE_ALGEBRA_DIRS) ! -name "Algebras" ! -name "Management" | sed 's|.*/||')
export ALL_ALGEBRA_DIRS
endif
ifndef ALL_ALGEBRA_DIR_INCLUDE_FLAGS
ALL_ALGEBRA_DIR_INCLUDE_FLAGS := $(shell find $(BUILDDIR)/Algebras -maxdepth 1 -type d $(EXCLUDE_ALGEBRA_DIRS) ! -name "Algebras" ! -name "Management" | sed 's|^|-I|')
export ALL_ALGEBRA_DIR_INCLUDE_FLAGS
endif
ifndef SPECFILES
SPECFILES := $(shell find $(BUILDDIR)/Algebras -maxdepth 2 -mindepth 2 -type f -iname "*.spec")
export SPECFILES
endif