Files
secondo/makefile.env

437 lines
10 KiB
Bash
Raw Permalink Normal View History

2026-01-23 17:03:45 +08:00
# 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.
#
#######################################################################
SHELL = /bin/bash
# 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
ifndef SECONDO_JAVAH
JAVAH := javah
else
JAVAH := $(SECONDO_JAVAH)
endif
#set the standard classpath
CLASSPATH = .
# define directories
INCLUDEDIR := $(BUILDDIR)/include
LIBDIR := $(BUILDDIR)/lib
BINDIR := $(BUILDDIR)/bin
OPTDIR := $(BUILDDIR)/Optimizer
# generic rules for calculating dependency files
# and for generating objects from cpp files.
CPP_FILES = $(wildcard *.cpp)
DEP_FILES = $(patsubst %.cpp, %.dep, $(CPP_FILES))
OBJECTS = $(patsubst %.dep, %.$(OBJEXT), $(DEP_FILES))
# 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
include $(BUILDDIR)/makefile.$(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)
# the macro below should be used in local makefiles to
# add specific flags
DEFAULTCCFLAGS += -I$(BUILDDIR)
CCFLAGS = $(DEFAULTCCFLAGS)
# Storage Manager suffix
SMIUP:=BDB
SMILOW:=bdb
# load algebra definitions
alg := auto
HAS_ALGDEF := $(shell if [ -f $(BUILDDIR)/makefile.algebras ]; then echo "true"; fi)
ifeq ($(HAS_ALGDEF),true)
include $(BUILDDIR)/makefile.algebras
else
include $(BUILDDIR)/makefile.algebras.sample
endif
# create dependencies from include directives
%.dep: %.cpp
$(CC) -MM $(CCFLAGS) $(CPPSTDOPTION) $< -o $@
# compile object
%.o: %.cpp
$(CC) -c -o $@ $< $(CCFLAGS) $(CPPSTDOPTION)
ifdef SECONDO_ACTIVATE_ALL_ALGEBRAS
ALGEBRA_ARCHIVES := $(subst lib,,$(subst Algebra.a,,$(shell find $(BUILDDIR)/lib -name "lib*Algebra*" -printf "%f ")))
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
ifneq ($(platform),android)
ifndef SECONDO_HAS_RECODE
SECONDO_HAS_RECODE = $(shell $(SECONDO_BUILD_DIR)/CM-Scripts/checkRecode $(CPPC))
export SECONDO_HAS_RECODE
endif
ifeq ($(SECONDO_HAS_RECODE),true)
DEFAULTLIB += -lrecode
CCFLAGS += -DRECODE
endif
endif
ALGEBRA_ARCHIVES := $(ALGEBRA_DIRS)
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 = $(shell echo -n $(CURDIR) | sed -E "s|^$(SECONDO_BUILD_DIR)/Algebras/([^/]+).*|\1|g")
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
ifeq ($(platform),mac_osx)
MAC_LDF := -lsdbnl -lsmibdb -lsdbutils -lsdbsys
endif
SECLIBS_ALG := $(XOPEN) -lsdbsys $(ALGLIBS) $(ALGDEPS) $(ALGLINKFLAGS) -lsdbnl -lsmi$(SMILOW) -lsdbutils $(MAC_LDF) -lsdbsocket $(XCLOSE)
SECLIBS := $(XOPEN) -lsdbsys -lsdbnl -lsmi$(SMILOW) -lsdbutils $(MAC_LDF) -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)
ifndef ALL_ALGEBRA_DIRS
ALL_ALGEBRA_DIRS := $(shell find $(BUILDDIR)/Algebras -maxdepth 1 -type d $(EXCLUDE_ALGEBRA_DIRS) ! -name "Algebras" ! -name "Management" ! -name "CVS" -printf "%f ")
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" ! -name "CVS" -printf "-I%p ")
export ALL_ALGEBRA_DIR_INCLUDE_FLAGS
endif
ifndef SPECFILES
SPECFILES := $(shell find $(BUILDDIR)/Algebras -maxdepth 2 -mindepth 2 -type f -iname "*.spec" -printf "%p ")
export SPECFILES
endif