2017-05-26 04:48:44 +08:00
|
|
|
export
|
|
|
|
PLATFORM := $(shell uname)
|
|
|
|
ARCH := $(shell uname -m)
|
2019-02-28 00:18:29 +08:00
|
|
|
ifeq ("$(wildcard /etc/centos-release)", "")
|
|
|
|
LIBSTDCPP_HACK = 1
|
|
|
|
else
|
|
|
|
LIBSTDCPP_HACK = 0
|
|
|
|
endif
|
2017-05-26 04:48:44 +08:00
|
|
|
|
|
|
|
TOPDIR := $(shell pwd)
|
|
|
|
|
|
|
|
ifeq ($(ARCH),x86_64)
|
|
|
|
ARCH := x64
|
|
|
|
else
|
|
|
|
$(error Not prepared to compile on $(ARCH))
|
|
|
|
endif
|
|
|
|
|
|
|
|
MONO := $(shell which mono)
|
|
|
|
ifeq ($(MONO),)
|
|
|
|
MONO := /usr/bin/mono
|
|
|
|
endif
|
|
|
|
|
2018-05-03 04:52:32 +08:00
|
|
|
MCS := $(shell which mcs)
|
2018-12-29 10:09:22 +08:00
|
|
|
ifeq ($(MCS),)
|
|
|
|
MCS := $(shell which dmcs)
|
2018-05-03 04:52:32 +08:00
|
|
|
endif
|
2017-05-26 04:48:44 +08:00
|
|
|
ifeq ($(MCS),)
|
2018-12-29 10:09:22 +08:00
|
|
|
MCS := /usr/bin/mcs
|
2017-05-26 04:48:44 +08:00
|
|
|
endif
|
|
|
|
|
2017-10-14 05:15:41 +08:00
|
|
|
CFLAGS := -Werror -Wno-error=format -fPIC -DNO_INTELLISENSE -fvisibility=hidden -DNDEBUG=1 -Wreturn-type -fno-omit-frame-pointer
|
2017-05-26 04:48:44 +08:00
|
|
|
ifeq ($(RELEASE),true)
|
|
|
|
CFLAGS += -DFDB_CLEAN_BUILD
|
|
|
|
endif
|
|
|
|
ifeq ($(NIGHTLY),true)
|
|
|
|
CFLAGS += -DFDB_CLEAN_BUILD
|
|
|
|
endif
|
|
|
|
|
2019-01-26 03:41:27 +08:00
|
|
|
BOOST_BASENAME ?= boost_1_67_0
|
2017-05-26 04:48:44 +08:00
|
|
|
ifeq ($(PLATFORM),Linux)
|
|
|
|
PLATFORM := linux
|
|
|
|
|
|
|
|
CC ?= gcc
|
|
|
|
CXX ?= g++
|
|
|
|
|
|
|
|
CXXFLAGS += -std=c++0x
|
|
|
|
|
2019-01-25 09:51:09 +08:00
|
|
|
BOOST_BASEDIR ?= /opt
|
2018-07-06 04:21:10 +08:00
|
|
|
TLS_LIBDIR ?= /usr/local/lib
|
2017-05-26 04:48:44 +08:00
|
|
|
DLEXT := so
|
|
|
|
java_DLEXT := so
|
|
|
|
TARGET_LIBC_VERSION ?= 2.11
|
|
|
|
else ifeq ($(PLATFORM),Darwin)
|
|
|
|
PLATFORM := osx
|
|
|
|
|
|
|
|
CC := /usr/bin/clang
|
|
|
|
CXX := /usr/bin/clang
|
|
|
|
|
|
|
|
CFLAGS += -mmacosx-version-min=10.7 -stdlib=libc++
|
2017-07-19 02:09:10 +08:00
|
|
|
CXXFLAGS += -mmacosx-version-min=10.7 -std=c++11 -stdlib=libc++ -msse4.2 -Wno-undefined-var-template -Wno-unknown-warning-option
|
2017-05-26 04:48:44 +08:00
|
|
|
|
|
|
|
.LIBPATTERNS := lib%.dylib lib%.a
|
|
|
|
|
2019-01-25 09:51:09 +08:00
|
|
|
BOOST_BASEDIR ?= ${HOME}
|
2018-07-06 04:21:10 +08:00
|
|
|
TLS_LIBDIR ?= /usr/local/lib
|
2017-05-26 04:48:44 +08:00
|
|
|
DLEXT := dylib
|
|
|
|
java_DLEXT := jnilib
|
|
|
|
else
|
|
|
|
$(error Not prepared to compile on platform $(PLATFORM))
|
|
|
|
endif
|
2019-01-25 09:51:09 +08:00
|
|
|
BOOSTDIR ?= ${BOOST_BASEDIR}/${BOOST_BASENAME}
|
2017-05-26 04:48:44 +08:00
|
|
|
|
|
|
|
CCACHE := $(shell which ccache)
|
|
|
|
ifneq ($(CCACHE),)
|
|
|
|
CCACHE_CC := $(CCACHE) $(CC)
|
|
|
|
CCACHE_CXX := $(CCACHE) $(CXX)
|
|
|
|
else
|
|
|
|
CCACHE_CC := $(CC)
|
|
|
|
CCACHE_CXX := $(CXX)
|
|
|
|
endif
|
|
|
|
|
2019-03-01 06:50:22 +08:00
|
|
|
# Default variables don't get pushed into the environment, but scripts in build/
|
|
|
|
# rely on the existence of CC in the environment.
|
|
|
|
ifeq ($(origin CC), default)
|
|
|
|
CC := $(CC)
|
|
|
|
endif
|
|
|
|
|
2017-05-26 04:48:44 +08:00
|
|
|
ACTORCOMPILER := bin/actorcompiler.exe
|
|
|
|
|
|
|
|
# UNSTRIPPED := 1
|
|
|
|
|
|
|
|
# Normal optimization level
|
|
|
|
CFLAGS += -O2
|
|
|
|
|
|
|
|
# Or turn off optimization entirely
|
|
|
|
# CFLAGS += -O0
|
|
|
|
|
|
|
|
# Debugging symbols are a good thing (and harmless, since we keep them
|
|
|
|
# in external debug files)
|
|
|
|
CFLAGS += -g
|
|
|
|
|
|
|
|
# valgrind-compatibile builds are enabled by uncommenting lines in valgind.mk
|
|
|
|
|
2018-07-04 00:01:01 +08:00
|
|
|
# Define the TLS compilation and link variables
|
2018-07-02 13:49:39 +08:00
|
|
|
ifdef TLS_DISABLED
|
|
|
|
CFLAGS += -DTLS_DISABLED
|
2018-07-06 04:21:10 +08:00
|
|
|
FDB_TLS_LIB :=
|
2018-07-02 13:49:39 +08:00
|
|
|
TLS_LIBS :=
|
|
|
|
else
|
2018-07-06 04:21:10 +08:00
|
|
|
FDB_TLS_LIB := lib/libFDBLibTLS.a
|
2018-07-04 00:01:01 +08:00
|
|
|
TLS_LIBS += $(addprefix $(TLS_LIBDIR)/,libtls.a libssl.a libcrypto.a)
|
2018-07-02 13:49:39 +08:00
|
|
|
endif
|
|
|
|
|
2019-03-14 16:55:49 +08:00
|
|
|
CXXFLAGS += -Wno-deprecated -DBOOST_ERROR_CODE_HEADER_ONLY -DBOOST_SYSTEM_NO_DEPRECATED
|
2017-12-12 09:09:32 +08:00
|
|
|
LDFLAGS :=
|
2017-05-26 04:48:44 +08:00
|
|
|
LIBS :=
|
|
|
|
STATIC_LIBS :=
|
|
|
|
|
|
|
|
# Add library search paths (that aren't -Llib) to the VPATH
|
|
|
|
VPATH += $(addprefix :,$(filter-out lib,$(patsubst -L%,%,$(filter -L%,$(LDFLAGS)))))
|
|
|
|
|
|
|
|
CS_PROJECTS := flow/actorcompiler flow/coveragetool fdbclient/vexillographer
|
2018-07-31 08:15:40 +08:00
|
|
|
CPP_PROJECTS := flow fdbrpc fdbclient fdbbackup fdbserver fdbcli bindings/c bindings/java fdbmonitor bindings/flow/tester bindings/flow
|
|
|
|
ifndef TLS_DISABLED
|
|
|
|
CPP_PROJECTS += FDBLibTLS
|
|
|
|
endif
|
2018-04-07 08:17:41 +08:00
|
|
|
OTHER_PROJECTS := bindings/python bindings/ruby bindings/go
|
2017-05-26 04:48:44 +08:00
|
|
|
|
|
|
|
CS_MK_GENERATED := $(CS_PROJECTS:=/generated.mk)
|
|
|
|
CPP_MK_GENERATED := $(CPP_PROJECTS:=/generated.mk)
|
|
|
|
|
|
|
|
MK_GENERATED := $(CS_MK_GENERATED) $(CPP_MK_GENERATED)
|
|
|
|
|
|
|
|
# build/valgrind.mk needs to be included before any _MK_GENERATED (which in turn includes local.mk)
|
|
|
|
MK_INCLUDE := build/scver.mk build/valgrind.mk $(CS_MK_GENERATED) $(CPP_MK_GENERATED) $(OTHER_PROJECTS:=/include.mk) build/packages.mk
|
|
|
|
|
|
|
|
ALL_MAKEFILES := Makefile $(MK_INCLUDE) $(patsubst %/generated.mk,%/local.mk,$(MK_GENERATED))
|
|
|
|
|
|
|
|
TARGETS =
|
|
|
|
|
|
|
|
.PHONY: clean all Makefiles
|
|
|
|
|
|
|
|
default: fdbserver fdbbackup fdbcli fdb_c fdb_python fdb_python_sdist
|
|
|
|
|
|
|
|
all: $(CS_PROJECTS) $(CPP_PROJECTS) $(OTHER_PROJECTS)
|
|
|
|
|
|
|
|
# These are always defined and ready to use. Any target that uses them and needs them up to date
|
|
|
|
# should depend on versions.target
|
|
|
|
VERSION := $(shell cat versions.target | grep '<Version>' | sed -e 's,^[^>]*>,,' -e 's,<.*,,')
|
|
|
|
PACKAGE_NAME := $(shell cat versions.target | grep '<PackageName>' | sed -e 's,^[^>]*>,,' -e 's,<.*,,')
|
|
|
|
|
|
|
|
versions.h: Makefile versions.target
|
|
|
|
@rm -f $@
|
|
|
|
ifeq ($(RELEASE),true)
|
|
|
|
@echo "#define FDB_VT_VERSION \"$(VERSION)\"" >> $@
|
|
|
|
else
|
|
|
|
@echo "#define FDB_VT_VERSION \"$(VERSION)-PRERELEASE\"" >> $@
|
|
|
|
endif
|
|
|
|
@echo "#define FDB_VT_PACKAGE_NAME \"$(PACKAGE_NAME)\"" >> $@
|
|
|
|
|
2018-09-18 04:41:55 +08:00
|
|
|
bindings: fdb_c fdb_python fdb_ruby fdb_java fdb_flow fdb_flow_tester fdb_go fdb_go_tester fdb_c_tests
|
2017-05-26 04:48:44 +08:00
|
|
|
|
|
|
|
Makefiles: $(MK_GENERATED)
|
|
|
|
|
|
|
|
$(CS_MK_GENERATED): build/csprojtom4.py build/csproj.mk Makefile
|
|
|
|
@echo "Creating $@"
|
|
|
|
@python build/csprojtom4.py $(@D)/*.csproj | m4 -DGENDIR="$(@D)" -DGENNAME=`basename $(@D)/*.csproj .csproj` - build/csproj.mk > $(@D)/generated.mk
|
|
|
|
|
|
|
|
$(CPP_MK_GENERATED): build/vcxprojtom4.py build/vcxproj.mk Makefile
|
|
|
|
@echo "Creating $@"
|
|
|
|
@python build/vcxprojtom4.py $(@D)/*.vcxproj | m4 -DGENDIR="$(@D)" -DGENNAME=`basename $(@D)/*.vcxproj .vcxproj` - build/vcxproj.mk > $(@D)/generated.mk
|
|
|
|
|
|
|
|
DEPSDIR := .deps
|
|
|
|
OBJDIR := .objs
|
2018-08-11 06:16:19 +08:00
|
|
|
CMDDIR := .cmds
|
|
|
|
|
|
|
|
COMPILE_COMMANDS_JSONS := $(addprefix $(CMDDIR)/,$(addsuffix /compile_commands.json,${CPP_PROJECTS}))
|
|
|
|
compile_commands.json: build/concatinate_jsons.py ${COMPILE_COMMANDS_JSONS}
|
|
|
|
@build/concatinate_jsons.py ${COMPILE_COMMANDS_JSONS}
|
2017-05-26 04:48:44 +08:00
|
|
|
|
|
|
|
include $(MK_INCLUDE)
|
|
|
|
|
2018-03-14 04:02:45 +08:00
|
|
|
clean: $(CLEAN_TARGETS) docpreview_clean
|
2017-05-26 04:48:44 +08:00
|
|
|
@echo "Cleaning toplevel"
|
|
|
|
@rm -rf $(OBJDIR)
|
|
|
|
@rm -rf $(DEPSDIR)
|
2018-04-13 03:59:51 +08:00
|
|
|
@rm -rf lib/
|
2017-05-26 04:48:44 +08:00
|
|
|
@rm -rf bin/coverage.*.xml
|
2018-08-11 06:16:19 +08:00
|
|
|
@rm -rf $(CMDDIR) compile_commands.json
|
2018-06-22 08:19:29 +08:00
|
|
|
@find . -name "*.g.cpp" -exec rm -f {} \; -or -name "*.g.h" -exec rm -f {} \;
|
2017-05-26 04:48:44 +08:00
|
|
|
|
|
|
|
targets:
|
|
|
|
@echo "Available targets:"
|
|
|
|
@for i in $(sort $(TARGETS)); do echo " $$i" ; done
|
|
|
|
@echo "Append _clean to clean specific target."
|
|
|
|
|
2019-02-28 00:18:29 +08:00
|
|
|
lib/libstdc++.a: $(shell $(CC) -print-file-name=libstdc++_pic.a)
|
|
|
|
@echo "Frobnicating $@"
|
|
|
|
@mkdir -p lib
|
|
|
|
@rm -rf .libstdc++
|
|
|
|
@mkdir .libstdc++
|
|
|
|
@(cd .libstdc++ && ar x $<)
|
|
|
|
@for i in .libstdc++/*.o ; do \
|
|
|
|
nm $$i | grep -q \@ || continue ; \
|
|
|
|
nm $$i | awk '$$3 ~ /@@/ { COPY = $$3; sub(/@@.*/, "", COPY); print $$3, COPY; }' > .libstdc++/replacements ; \
|
|
|
|
objcopy --redefine-syms=.libstdc++/replacements $$i $$i.new && mv $$i.new $$i ; \
|
|
|
|
rm .libstdc++/replacements ; \
|
|
|
|
nm $$i | awk '$$3 ~ /@/ { print $$3; }' > .libstdc++/deletes ; \
|
|
|
|
objcopy --strip-symbols=.libstdc++/deletes $$i $$i.new && mv $$i.new $$i ; \
|
|
|
|
rm .libstdc++/deletes ; \
|
|
|
|
done
|
|
|
|
@ar rcs $@ .libstdc++/*.o
|
|
|
|
@rm -r .libstdc++
|
|
|
|
|
|
|
|
|
2018-03-31 02:16:19 +08:00
|
|
|
docpreview: javadoc
|
2018-09-07 04:13:37 +08:00
|
|
|
@echo "Generating docpreview"
|
|
|
|
@TARGETS= $(MAKE) -C documentation docpreview
|
2017-05-26 04:48:44 +08:00
|
|
|
|
2018-03-14 04:02:45 +08:00
|
|
|
docpreview_clean:
|
2018-09-07 04:13:37 +08:00
|
|
|
@echo "Cleaning docpreview"
|
|
|
|
@CLEAN_TARGETS= $(MAKE) -C documentation -s --no-print-directory docpreview_clean
|
2018-03-14 04:02:45 +08:00
|
|
|
|
2018-03-31 02:16:19 +08:00
|
|
|
packages/foundationdb-docs-$(VERSION).tar.gz: FORCE javadoc
|
2018-09-07 04:13:37 +08:00
|
|
|
@echo "Packaging documentation"
|
|
|
|
@TARGETS= $(MAKE) -C documentation docpackage
|
2018-03-16 07:07:23 +08:00
|
|
|
@mkdir -p packages
|
2018-03-22 01:55:43 +08:00
|
|
|
@rm -f packages/foundationdb-docs-$(VERSION).tar.gz
|
2018-03-22 22:50:56 +08:00
|
|
|
@cp documentation/sphinx/.dist/foundationdb-docs-$(VERSION).tar.gz packages/foundationdb-docs-$(VERSION).tar.gz
|
2018-03-16 07:07:23 +08:00
|
|
|
|
2018-03-22 01:55:43 +08:00
|
|
|
docpackage: packages/foundationdb-docs-$(VERSION).tar.gz
|
2018-03-16 07:07:23 +08:00
|
|
|
|
|
|
|
FORCE:
|
2017-05-26 04:48:44 +08:00
|
|
|
|
|
|
|
.SECONDEXPANSION:
|
|
|
|
|
|
|
|
bin/coverage.%.xml: bin/coveragetool.exe $$(%_ALL_SOURCES)
|
|
|
|
@echo "Creating $@"
|
|
|
|
@$(MONO) bin/coveragetool.exe $@ $(filter-out $<,$^) >/dev/null
|
|
|
|
|
|
|
|
$(CPP_MK_GENERATED): $$(@D)/*.vcxproj
|
|
|
|
|
|
|
|
$(CS_MK_GENERATED): $$(@D)/*.csproj
|