@ -16,7 +16,7 @@
m = proto_re.match( filename)
if not m:
return filename
return 'gens /' + m.group( 1) + '.pb.cc'
return '$(GENDIR) /' + m.group( 1) + '.pb.cc'
% >
@ -27,6 +27,15 @@ SYSTEM = $(HOST_SYSTEM)
e n d i f
i f n d e f B U I L D D I R
BUILDDIR = .
e n d i f
BINDIR = $( BUILDDIR) /bins
OBJDIR = $( BUILDDIR) /objs
LIBDIR = $( BUILDDIR) /libs
GENDIR = $( BUILDDIR) /gens
# Configurations
VALID_CONFIG_opt = 1
@ -83,15 +92,27 @@ DEFINES_asan = NDEBUG
VALID_CONFIG_msan = 1
REQUIRE_CUSTOM_LIBRARIES_msan = 1
CC_msan = clang
CXX_msan = clang++
CXX_msan = clang++-libc++
LD_msan = clang
LDXX_msan = clang++
CPPFLAGS_msan = -O1 -fsanitize= memory -fno-omit-frame-pointer
LDXX_msan = clang++-libc++
CPPFLAGS_msan = -O1 -fsanitize= memory -fsanitize-memory-track-origins -f no-omit-frame-pointer -DGTEST_HAS_TR1_TUPLE= 0 -DGTEST_USE_OWN_TR1_TUPLE= 1
OPENSSL_CFLAGS_msan = -DPURIFY
OPENSSL_CONFIG_msan = no-asm
LDFLAGS_msan = -fsanitize= memory
LDFLAGS_msan = -fsanitize= memory -DGTEST_HAS_TR1_TUPLE= 0 -DGTEST_USE_OWN_TR1_TUPLE= 1
DEFINES_msan = NDEBUG
VALID_CONFIG_ubsan = 1
REQUIRE_CUSTOM_LIBRARIES_ubsan = 1
CC_ubsan = clang
CXX_ubsan = clang++
LD_ubsan = clang
LDXX_ubsan = clang++
CPPFLAGS_ubsan = -O1 -fsanitize= undefined -fno-omit-frame-pointer
OPENSSL_CFLAGS_ubsan = -DPURIFY
OPENSSL_CONFIG_ubsan = no-asm
LDFLAGS_ubsan = -fsanitize= undefined
DEFINES_ubsan = NDEBUG
VALID_CONFIG_gcov = 1
CC_gcov = gcc
CXX_gcov = g++
@ -142,15 +163,13 @@ CXXFLAGS += -std=c++11
CPPFLAGS += -g -fPIC -Wall -Wextra -Werror -Wno-long-long -Wno-unused-parameter
LDFLAGS += -g -fPIC
INCLUDES = . include gens
INCLUDES = . include $( GENDIR)
i f e q ( $( SYSTEM ) , D a r w i n )
LIBS = m z
e l s e
LIBS = rt m z pthread
LDFLAGS += -pthread
e n d i f
LIBSXX = protobuf
LIBS_PROTOC = protoc protobuf
i f n e q ( $( wildcard /usr /src /gtest /src /gtest -all .cc ) , )
GTEST_LIB = /usr/src/gtest/src/gtest-all.cc -I/usr/src/gtest
@ -174,7 +193,6 @@ CPPFLAGS += $(CPPFLAGS_NO_ARCH) $(ARCH_FLAGS)
LDFLAGS += $( ARCH_FLAGS)
LDLIBS += $( addprefix -l, $( LIBS) )
LDLIBSXX += $( addprefix -l, $( LIBSXX) )
HOST_LDLIBS_PROTOC += $( addprefix -l, $( LIBS_PROTOC) )
HOST_CPPFLAGS = $( CPPFLAGS)
HOST_CFLAGS = $( CFLAGS)
@ -205,6 +223,8 @@ endif
OPENSSL_ALPN_CHECK_CMD = $( CC) $( CFLAGS) $( CPPFLAGS) -o /dev/null test/build/openssl-alpn.c -lssl -lcrypto -ldl $( LDFLAGS)
ZLIB_CHECK_CMD = $( CC) $( CFLAGS) $( CPPFLAGS) -o /dev/null test/build/zlib.c -lz $( LDFLAGS)
PERFTOOLS_CHECK_CMD = $( CC) $( CFLAGS) $( CPPFLAGS) -o /dev/null test/build/perftools.c -lprofiler $( LDFLAGS)
PROTOBUF_CHECK_CMD = $( CXX) $( CXXFLAGS) $( CPPFLAGS) -o /dev/null test/build/protobuf.cc -lprotobuf $( LDFLAGS)
PROTOC_CHECK_CMD = protoc --version | grep -q libprotoc.3
i f n d e f R E Q U I R E _ C U S T O M _ L I B R A R I E S _ $( CONFIG )
HAS_SYSTEM_PERFTOOLS = $( shell $( PERFTOOLS_CHECK_CMD) 2> /dev/null && echo true || echo false )
@ -217,12 +237,16 @@ endif
i f n d e f R E Q U I R E _ C U S T O M _ L I B R A R I E S _ $( CONFIG )
HAS_SYSTEM_OPENSSL_ALPN = $( shell $( OPENSSL_ALPN_CHECK_CMD) 2> /dev/null && echo true || echo false )
HAS_SYSTEM_ZLIB = $( shell $( ZLIB_CHECK_CMD) 2> /dev/null && echo true || echo false )
HAS_SYSTEM_PROTOBUF = $( shell $( PROTOBUF_CHECK_CMD) 2> /dev/null && echo true || echo false )
e l s e
# override system libraries if the config requires a custom compiled library
HAS_SYSTEM_OPENSSL_ALPN = false
HAS_SYSTEM_ZLIB = false
HAS_SYSTEM_PROTOBUF = false
e n d i f
HAS_VALID_PROTOC = $( shell $( PROTOC_CHECK_CMD) 2> /dev/null && echo true || echo false )
i f e q ( $( wildcard third_party /openssl /ssl /ssl .h ) , )
HAS_EMBEDDED_OPENSSL_ALPN = false
e l s e
@ -235,11 +259,20 @@ else
HAS_EMBEDDED_ZLIB = true
e n d i f
i f e q ( $( wildcard third_party /protobuf /src /google /protobuf /descriptor .pb .h ) , )
HAS_EMBEDDED_PROTOBUF = false
i f n e q ( $( HAS_VALID_PROTOC ) , t r u e )
NO_PROTOC = true
e n d i f
e l s e
HAS_EMBEDDED_PROTOBUF = true
e n d i f
i f e q ( $( HAS_SYSTEM_ZLIB ) , f a l s e )
i f e q ( $( HAS_EMBEDDED_ZLIB ) , t r u e )
ZLIB_DEP = libs/$( CONFIG) /zlib/libz.a
ZLIB_DEP = $( LIBDIR) /$( CONFIG) /zlib/libz.a
CPPFLAGS += -Ithird_party/zlib
LDFLAGS += -Lthird_party/zlib
LDFLAGS += -L$( LIBDIR) /$( CONFIG) /zlib
e l s e
DEP_MISSING += zlib
e n d i f
@ -247,10 +280,10 @@ endif
i f e q ( $( HAS_SYSTEM_OPENSSL_ALPN ) , f a l s e )
i f e q ( $( HAS_EMBEDDED_OPENSSL_ALPN ) , t r u e )
OPENSSL_DEP = libs /$( CONFIG) /openssl/libssl.a
OPENSSL_MERGE_LIBS += libs/$( CONFIG) /openssl/libssl.a libs /$( CONFIG) /openssl/libcrypto.a
OPENSSL_DEP = $( LIBDIR) /$( CONFIG) /openssl/libssl.a
OPENSSL_MERGE_LIBS += $( LIBDIR) /$( CONFIG) /openssl/libssl.a $( LIBDIR) /$( CONFIG) /openssl/libcrypto.a
CPPFLAGS += -Ithird_party/openssl/include
LDFLAGS += -Llibs /$( CONFIG) /openssl
LDFLAGS += -L$( LIBDIR) /$( CONFIG) /openssl
LIBS_SECURE = dl
e l s e
NO_SECURE = true
@ -261,6 +294,24 @@ endif
LDLIBS_SECURE += $( addprefix -l, $( LIBS_SECURE) )
i f e q ( $( HAS_SYSTEM_PROTOBUF ) , f a l s e )
i f e q ( $( HAS_EMBEDDED_PROTOBUF ) , t r u e )
PROTOBUF_DEP = $( LIBDIR) /$( CONFIG) /protobuf/libprotobuf.a
CPPFLAGS += -Ithird_party/protobuf/src
LDFLAGS += -L$( LIBDIR) /$( CONFIG) /protobuf
PROTOC = $( BINDIR) /$( CONFIG) /protobuf/protoc
e l s e
NO_PROTOBUF = true
e n d i f
e l s e
e n d i f
LIBS_PROTOBUF = protobuf
LIBS_PROTOC = protoc protobuf
LDLIBS_PROTOBUF += $( addprefix -l, $( LIBS_PROTOBUF) )
HOST_LDLIBS_PROTOC += $( addprefix -l, $( LIBS_PROTOC) )
i f e q ( $( MAKECMDGOALS ) , c l e a n )
NO_DEPS = true
e n d i f
@ -270,7 +321,7 @@ endif
PROTOC_PLUGINS = \
% for tgt in targets :
% if tgt.build == 'protoc' :
bins /$( CONFIG) /${ tgt .name } \
$( BINDIR) /$( CONFIG) /${ tgt .name } \
% e n d i f
% e n d f o r
@ -278,7 +329,7 @@ ifeq ($(DEP_MISSING),)
all : static shared \
% for tgt in targets :
% if tgt.build == 'all' :
bins /$( CONFIG) /${ tgt .name } \
$( BINDIR) /$( CONFIG) /${ tgt .name } \
% e n d i f
% e n d f o r
@ -316,6 +367,10 @@ endif
openssl_dep_error : openssl_dep_message git_update stop
protobuf_dep_error : protobuf_dep_message git_update stop
protoc_dep_error : protoc_dep_message git_update stop
openssl_dep_message :
@echo
@echo "DEPENDENCY ERROR"
@ -330,26 +385,57 @@ openssl_dep_message:
@echo " make run_dep_checks"
@echo
protobuf_dep_message :
@echo
@echo "DEPENDENCY ERROR"
@echo
@echo "The target you are trying to run requires protobuf 3.0.0+"
@echo "Your system doesn't have it, and neither does the third_party directory."
@echo
@echo "Please consult INSTALL to get more information."
@echo
@echo "If you need information about why these tests failed, run:"
@echo
@echo " make run_dep_checks"
@echo
protoc_dep_message :
@echo
@echo "DEPENDENCY ERROR"
@echo
@echo "The target you are trying to run requires protobuf-compiler 3.0.0+"
@echo "Your system doesn't have it, and neither does the third_party directory."
@echo
@echo "Please consult INSTALL to get more information."
@echo
@echo "If you need information about why these tests failed, run:"
@echo
@echo " make run_dep_checks"
@echo
stop :
@false
% for tgt in targets :
${tgt.name} : bins /$( CONFIG ) /${tgt .name }
${tgt.name} : $( BINDIR ) /$( CONFIG ) /${tgt .name }
% e n d f o r
run_dep_checks :
$( OPENSSL_ALPN_CHECK_CMD) || true
$( ZLIB_CHECK_CMD) || true
$( PERFTOOLS_CHECK_CMD) || true
$( PROTOBUF_CHECK_CMD) || true
$( PROTOC_CHECK_CMD) || true
libs/$(CONFIG)/zlib/libz.a :
$(LIBDIR) /$(CONFIG)/zlib/libz.a:
$( E) "[MAKE] Building zlib"
$( Q) ( cd third_party/zlib ; CC = " $( CC) " CFLAGS = " -fPIC -fvisibility=hidden $( CPPFLAGS_$( CONFIG) ) " ./configure --static)
$( Q) $( MAKE) -C third_party/zlib clean
$( Q) $( MAKE) -C third_party/zlib
$( Q) mkdir -p libs/$( CONFIG) /zlib
$( Q) cp third_party/zlib/libz.a libs/$( CONFIG) /zlib
$( Q) mkdir -p $( LIBDIR) /$( CONFIG) /zlib
$( Q) cp third_party/zlib/libz.a $( LIBDIR) /$( CONFIG) /zlib
libs/$(CONFIG)/openssl/libssl.a :
$(LIBDIR) /$(CONFIG)/openssl/libssl.a:
$( E) " [MAKE] Building openssl for $( SYSTEM) "
i f e q ( $( SYSTEM ) , D a r w i n )
$( Q) ( cd third_party/openssl ; CC = " $( CC) -fPIC -fvisibility=hidden $( CPPFLAGS_$( CONFIG) ) $( OPENSSL_CFLAGS_$( CONFIG) ) " ./Configure darwin64-x86_64-cc $( OPENSSL_CONFIG_$( CONFIG) ) )
@ -358,15 +444,30 @@ else
e n d i f
$( Q) $( MAKE) -C third_party/openssl clean
$( Q) $( MAKE) -C third_party/openssl build_crypto build_ssl
$( Q) mkdir -p libs/$( CONFIG) /openssl
$( Q) cp third_party/openssl/libssl.a third_party/openssl/libcrypto.a libs/$( CONFIG) /openssl
$( Q) mkdir -p $( LIBDIR) /$( CONFIG) /openssl
$( Q) cp third_party/openssl/libssl.a third_party/openssl/libcrypto.a $( LIBDIR) /$( CONFIG) /openssl
third_party/protobuf/configure :
$( E) "[AUTOGEN] Preparing protobuf"
$( Q) ( cd third_party/protobuf ; autoreconf -f -i -Wall,no-obsolete)
$(LIBDIR)/$(CONFIG)/protobuf/libprotobuf.a : third_party /protobuf /configure
$( E) "[MAKE] Building protobuf"
$( Q) ( cd third_party/protobuf ; CC = " $( CC) " CXX = " $( CXX) " LDFLAGS = " $( LDFLAGS_$( CONFIG) ) -g " CXXFLAGS = "-DLANG_CXX11 -std=c++11" CPPFLAGS = " $( CPPFLAGS_$( CONFIG) ) -g " ./configure --disable-shared --enable-static)
$( Q) $( MAKE) -C third_party/protobuf clean
$( Q) $( MAKE) -C third_party/protobuf
$( Q) mkdir -p $( LIBDIR) /$( CONFIG) /protobuf
$( Q) mkdir -p $( BINDIR) /$( CONFIG) /protobuf
$( Q) cp third_party/protobuf/src/.libs/libprotoc.a $( LIBDIR) /$( CONFIG) /protobuf
$( Q) cp third_party/protobuf/src/.libs/libprotobuf.a $( LIBDIR) /$( CONFIG) /protobuf
$( Q) cp third_party/protobuf/src/protoc $( BINDIR) /$( CONFIG) /protobuf
static : static_c static_cxx
static_c : \
% for lib in libs :
% if lib.build == 'all' and lib.language == 'c' :
libs/$( CONFIG) /lib${ lib .name } .a\
$( LIBDIR) /$( CONFIG) /lib${ lib .name } .a\
% e n d i f
% e n d f o r
@ -374,7 +475,7 @@ static_c: \
static_cxx : \
% for lib in libs :
% if lib.build == 'all' and lib.language == 'c++' :
libs /$( CONFIG) /lib${ lib .name } .a\
$( LIBDIR) /$( CONFIG) /lib${ lib .name } .a\
% e n d i f
% e n d f o r
@ -384,7 +485,7 @@ shared: shared_c shared_cxx
shared_c : \
% for lib in libs :
% if lib.build == 'all' and lib.language == 'c' :
libs /$( CONFIG) /lib${ lib .name } .$( SHARED_EXT) \
$( LIBDIR) /$( CONFIG) /lib${ lib .name } .$( SHARED_EXT) \
% e n d i f
% e n d f o r
@ -392,7 +493,7 @@ shared_c: \
shared_cxx : \
% for lib in libs :
% if lib.build == 'all' and lib.language == 'c++' :
libs /$( CONFIG) /lib${ lib .name } .$( SHARED_EXT) \
$( LIBDIR) /$( CONFIG) /lib${ lib .name } .$( SHARED_EXT) \
% e n d i f
% e n d f o r
@ -402,7 +503,7 @@ privatelibs: privatelibs_c privatelibs_cxx
privatelibs_c : \
% for lib in libs :
% if lib.build == 'private' and lib.language == 'c' :
libs /$( CONFIG) /lib${ lib .name } .a\
$( LIBDIR) /$( CONFIG) /lib${ lib .name } .a\
% e n d i f
% e n d f o r
@ -410,7 +511,7 @@ privatelibs_c: \
privatelibs_cxx : \
% for lib in libs :
% if lib.build == 'private' and lib.language == 'c++' :
libs /$( CONFIG) /lib${ lib .name } .a\
$( LIBDIR) /$( CONFIG) /lib${ lib .name } .a\
% e n d i f
% e n d f o r
@ -420,7 +521,7 @@ buildtests: buildtests_c buildtests_cxx
buildtests_c : privatelibs_c \
% for tgt in targets :
% if tgt.build == 'test' and not tgt.language == 'c++' :
bins /$( CONFIG) /${ tgt .name } \
$( BINDIR) /$( CONFIG) /${ tgt .name } \
% e n d i f
% e n d f o r
@ -428,7 +529,7 @@ buildtests_c: privatelibs_c\
buildtests_cxx : privatelibs_cxx \
% for tgt in targets :
% if tgt.build == 'test' and tgt.language == 'c++' :
bins /$( CONFIG) /${ tgt .name } \
$( BINDIR) /$( CONFIG) /${ tgt .name } \
% e n d i f
% e n d f o r
@ -439,7 +540,7 @@ test_c: buildtests_c
% for tgt in targets :
% if tgt.build == 'test' and tgt.get('run', True) and not tgt.language == 'c++' :
$( E) " [RUN] Testing ${ tgt .name } "
$( Q) ./bins /$( CONFIG) /${ tgt .name } || ( echo test ${ tgt .name } failed ; exit 1 )
$( Q) $( BINDIR) /$( CONFIG) /${ tgt .name } || ( echo test ${ tgt .name } failed ; exit 1 )
% e n d i f
% e n d f o r
@ -448,7 +549,7 @@ test_cxx: buildtests_cxx
% for tgt in targets :
% if tgt.build == 'test' and tgt.get('run', True) and tgt.language == 'c++' :
$( E) " [RUN] Testing ${ tgt .name } "
$( Q) ./bins /$( CONFIG) /${ tgt .name } || ( echo test ${ tgt .name } failed ; exit 1 )
$( Q) $( BINDIR) /$( CONFIG) /${ tgt .name } || ( echo test ${ tgt .name } failed ; exit 1 )
% e n d i f
% e n d f o r
@ -456,7 +557,7 @@ test_cxx: buildtests_cxx
tools : privatelibs \
% for tgt in targets :
% if tgt.build == 'tool' :
bins /$( CONFIG) /${ tgt .name } \
$( BINDIR) /$( CONFIG) /${ tgt .name } \
% e n d i f
% e n d f o r
@ -464,7 +565,7 @@ tools: privatelibs\
buildbenchmarks : privatelibs \
% for tgt in targets :
% if tgt.build == 'benchmark' :
bins /$( CONFIG) /${ tgt .name } \
$( BINDIR) /$( CONFIG) /${ tgt .name } \
% e n d i f
% e n d f o r
@ -488,7 +589,7 @@ ifeq ($(CONFIG),opt)
% if lib.language == "c" :
% if lib.build == "all" :
$( E) " [STRIP] Stripping lib ${ lib .name } .a "
$( Q) $( STRIP) libs /$( CONFIG) /lib${ lib .name } .a
$( Q) $( STRIP) $( LIBDIR) /$( CONFIG) /lib${ lib .name } .a
% e n d i f
% e n d i f
% e n d f o r
@ -500,7 +601,7 @@ ifeq ($(CONFIG),opt)
% if lib.language == "c++" :
% if lib.build == "all" :
$( E) " [STRIP] Stripping lib ${ lib .name } .a "
$( Q) $( STRIP) libs /$( CONFIG) /lib${ lib .name } .a
$( Q) $( STRIP) $( LIBDIR) /$( CONFIG) /lib${ lib .name } .a
% e n d i f
% e n d i f
% e n d f o r
@ -512,7 +613,7 @@ ifeq ($(CONFIG),opt)
% if lib.language == "c" :
% if lib.build == "all" :
$( E) " [STRIP] Stripping lib ${ lib .name } .so "
$( Q) $( STRIP) libs /$( CONFIG) /lib${ lib .name } .$( SHARED_EXT)
$( Q) $( STRIP) $( LIBDIR) /$( CONFIG) /lib${ lib .name } .$( SHARED_EXT)
% e n d i f
% e n d i f
% e n d f o r
@ -524,36 +625,40 @@ ifeq ($(CONFIG),opt)
% if lib.language == "c++" :
% if lib.build == "all" :
$( E) " [STRIP] Stripping lib ${ lib .name } .so "
$( Q) $( STRIP) libs /$( CONFIG) /lib${ lib .name } .$( SHARED_EXT)
$( Q) $( STRIP) $( LIBDIR) /$( CONFIG) /lib${ lib .name } .$( SHARED_EXT)
% e n d i f
% e n d i f
% e n d f o r
e n d i f
% for p in protos :
gens/${p}.pb.cc : ${p }.proto $( PROTOC_PLUGINS )
i f e q ( $( NO_PROTOC ) , t r u e )
$(GENDIR)/${p}.pb.cc : protoc_dep_error
e l s e
$(GENDIR)/${p}.pb.cc : ${p }.proto $( PROTOBUF_DEP ) $( PROTOC_PLUGINS )
$( E) " [PROTOC] Generating protobuf CC file from $< "
$( Q) mkdir -p ` dirname $@ `
$( Q) $( PROTOC) --cpp_out= gens --grpc_out= gens --plugin= protoc-gen-grpc= bins/$( CONFIG) /cpp_plugin $<
$( Q) $( PROTOC) --cpp_out= $( GENDIR) --grpc_out= $( GENDIR) --plugin= protoc-gen-grpc= $( BINDIR) /$( CONFIG) /cpp_plugin $<
e n d i f
% e n d f o r
objs /$(CONFIG)/%.o : %.c
$(OBJDIR) /$(CONFIG)/%.o : %.c
$( E) " [C] Compiling $< "
$( Q) mkdir -p ` dirname $@ `
$( Q) $( CC) $( CFLAGS) $( CPPFLAGS) -MMD -MF $( addsuffix .dep, $( basename $@ ) ) -c -o $@ $<
objs/$(CONFIG)/%.o : gens /%.pb .cc
$(OBJDIR)/$(CONFIG)/%.o : $( GENDIR ) /%.pb .cc
$( E) " [CXX] Compiling $< "
$( Q) mkdir -p ` dirname $@ `
$( Q) $( CXX) $( CXXFLAGS) $( CPPFLAGS) -MMD -MF $( addsuffix .dep, $( basename $@ ) ) -c -o $@ $<
objs /$(CONFIG)/src/compiler/%.o : src /compiler /%.cc
$(OBJDIR) /$(CONFIG)/src/compiler/%.o : src /compiler /%.cc
$( E) " [HOSTCXX] Compiling $< "
$( Q) mkdir -p ` dirname $@ `
$( Q) $( HOST_CXX) $( HOST_CXXFLAGS) $( HOST_CPPFLAGS) -MMD -MF $( addsuffix .dep, $( basename $@ ) ) -c -o $@ $<
objs /$(CONFIG)/%.o : %.cc
$(OBJDIR) /$(CONFIG)/%.o : %.cc
$( E) " [CXX] Compiling $< "
$( Q) mkdir -p ` dirname $@ `
$( Q) $( CXX) $( CXXFLAGS) $( CPPFLAGS) -MMD -MF $( addsuffix .dep, $( basename $@ ) ) -c -o $@ $<
@ -582,7 +687,7 @@ install-static_c: static_c strip-static_c
% if lib.language == "c" :
% if lib.build == "all" :
$( E) " [INSTALL] Installing lib ${ lib .name } .a "
$( Q) $( INSTALL) libs /$( CONFIG) /lib${ lib .name } .a $( prefix) /lib/lib${ lib .name } .a
$( Q) $( INSTALL) $( LIBDIR) /$( CONFIG) /lib${ lib .name } .a $( prefix) /lib/lib${ lib .name } .a
% e n d i f
% e n d i f
% e n d f o r
@ -592,7 +697,7 @@ install-static_cxx: static_cxx strip-static_cxx
% if lib.language == "c++" :
% if lib.build == "all" :
$( E) " [INSTALL] Installing lib ${ lib .name } .a "
$( Q) $( INSTALL) libs /$( CONFIG) /lib${ lib .name } .a $( prefix) /lib/lib${ lib .name } .a
$( Q) $( INSTALL) $( LIBDIR) /$( CONFIG) /lib${ lib .name } .a $( prefix) /lib/lib${ lib .name } .a
% e n d i f
% e n d i f
% e n d f o r
@ -603,11 +708,11 @@ install-shared_c: shared_c strip-shared_c
% if lib.build == "all" :
i f e q ( $( SYSTEM ) , M I N G W 3 2 )
$( E) " [INSTALL] Installing ${ lib .name } . $( SHARED_EXT) "
$( Q) $( INSTALL) libs /$( CONFIG) /${ lib .name } .$( SHARED_EXT) $( prefix) /lib/${ lib .name } .$( SHARED_EXT)
$( Q) $( INSTALL) libs /$( CONFIG) /lib${ lib .name } -imp.a $( prefix) /lib/lib${ lib .name } -imp.a
$( Q) $( INSTALL) $( LIBDIR) /$( CONFIG) /${ lib .name } .$( SHARED_EXT) $( prefix) /lib/${ lib .name } .$( SHARED_EXT)
$( Q) $( INSTALL) $( LIBDIR) /$( CONFIG) /lib${ lib .name } -imp.a $( prefix) /lib/lib${ lib .name } -imp.a
e l s e
$( E) " [INSTALL] Installing lib ${ lib .name } . $( SHARED_EXT) "
$( Q) $( INSTALL) libs /$( CONFIG) /lib${ lib .name } .$( SHARED_EXT) $( prefix) /lib/lib${ lib .name } .$( SHARED_EXT)
$( Q) $( INSTALL) $( LIBDIR) /$( CONFIG) /lib${ lib .name } .$( SHARED_EXT) $( prefix) /lib/lib${ lib .name } .$( SHARED_EXT)
i f n e q ( $( SYSTEM ) , D a r w i n )
$( Q) ln -sf lib${ lib .name } .$( SHARED_EXT) $( prefix) /lib/lib${ lib .name } .so
e n d i f
@ -627,11 +732,11 @@ install-shared_cxx: shared_cxx strip-shared_cxx
% if lib.build == "all" :
i f e q ( $( SYSTEM ) , M I N G W 3 2 )
$( E) " [INSTALL] Installing ${ lib .name } . $( SHARED_EXT) "
$( Q) $( INSTALL) libs /$( CONFIG) /${ lib .name } .$( SHARED_EXT) $( prefix) /lib/${ lib .name } .$( SHARED_EXT)
$( Q) $( INSTALL) libs /$( CONFIG) /lib${ lib .name } -imp.a $( prefix) /lib/lib${ lib .name } -imp.a
$( Q) $( INSTALL) $( LIBDIR) /$( CONFIG) /${ lib .name } .$( SHARED_EXT) $( prefix) /lib/${ lib .name } .$( SHARED_EXT)
$( Q) $( INSTALL) $( LIBDIR) /$( CONFIG) /lib${ lib .name } -imp.a $( prefix) /lib/lib${ lib .name } -imp.a
e l s e
$( E) " [INSTALL] Installing lib ${ lib .name } . $( SHARED_EXT) "
$( Q) $( INSTALL) libs /$( CONFIG) /lib${ lib .name } .$( SHARED_EXT) $( prefix) /lib/lib${ lib .name } .$( SHARED_EXT)
$( Q) $( INSTALL) $( LIBDIR) /$( CONFIG) /lib${ lib .name } .$( SHARED_EXT) $( prefix) /lib/lib${ lib .name } .$( SHARED_EXT)
i f n e q ( $( SYSTEM ) , D a r w i n )
$( Q) ln -sf lib${ lib .name } .$( SHARED_EXT) $( prefix) /lib/lib${ lib .name } .so
e n d i f
@ -646,7 +751,7 @@ endif
e n d i f
clean :
$( Q) $( RM) -rf objs libs bins gens
$( Q) $( RM) -rf $( OBJDIR) $( LIBDIR) $( BINDIR) $( GENDIR)
# The various libraries
@ -684,7 +789,7 @@ PUBLIC_HEADERS_C += \\
% e n d f o r
% e n d i f
LIB${lib.name.upper()}_OBJS = $( addprefix objs /$( CONFIG) /, $( addsuffix .o, $( basename $( LIB${ lib .name.upper() } _SRC) ) ) )
LIB${lib.name.upper()}_OBJS = $( addprefix $( OBJDIR) /$( CONFIG) /, $( addsuffix .o, $( basename $( LIB${ lib .name.upper() } _SRC) ) ) )
## If the library requires OpenSSL with ALPN, let's add some restrictions.
% if lib.get('secure', True) :
@ -692,46 +797,89 @@ ifeq ($(NO_SECURE),true)
# You can't build secure libraries if you don't have OpenSSL with ALPN.
libs /$(CONFIG)/lib${lib.name}.a: openssl_dep_error
$(LIBDIR) /$(CONFIG)/lib${lib.name}.a: openssl_dep_error
% if lib.build == "all" :
i f e q ( $( SYSTEM ) , M I N G W 3 2 )
libs /$(CONFIG)/${lib.name}.$(SHARED_EXT): openssl_dep_error
$(LIBDIR) /$(CONFIG)/${lib.name}.$(SHARED_EXT): openssl_dep_error
e l s e
libs /$(CONFIG)/lib${lib.name}.$(SHARED_EXT): openssl_dep_error
$(LIBDIR) /$(CONFIG)/lib${lib.name}.$(SHARED_EXT): openssl_dep_error
e n d i f
% e n d i f
e l s e
% if lib.language == 'c++' :
i f e q ( $( NO_PROTOBUF ) , t r u e )
# You can't build a C++ library if you don't have protobuf - a bit overreached, but still okay.
$(LIBDIR)/$(CONFIG)/lib${lib.name}.a : protobuf_dep_error
% if lib.build == "all" :
i f e q ( $( SYSTEM ) , M I N G W 3 2 )
$(LIBDIR)/$(CONFIG)/${lib.name}.$(SHARED_EXT) : protobuf_dep_error
e l s e
$(LIBDIR)/$(CONFIG)/lib${lib.name}.$(SHARED_EXT) : protobuf_dep_error
e n d i f
% e n d i f
e l s e
% e n d i f
i f n e q ( $( OPENSSL_DEP ) , )
# This is to ensure the embedded OpenSSL is built beforehand, properly
# installing headers to their final destination on the drive. We need this
# otherwise parallel compilation will fail if a source is compiled first.
% for src in lib.src :
${src} : $( OPENSSL_DEP )
% e n d f o r
e n d i f
libs/$(CONFIG)/lib${lib.name}.a : $( ZLIB_DEP ) $( OPENSSL_DEP ) $( LIB $ {lib .name .upper ( ) }_OBJS )
$(LIBDIR) /$(CONFIG)/lib${lib.name}.a: $( ZLIB_DEP ) $( OPENSSL_DEP ) \
## The else here corresponds to the if secure earlier.
% else :
libs/$(CONFIG)/lib${lib.name}.a : $( ZLIB_DEP ) $( LIB $ {lib .name .upper ( ) }_OBJS )
% if lib.language == 'c++' :
i f e q ( $( NO_PROTOBUF ) , t r u e )
# You can't build a C++ library if you don't have protobuf - a bit overreached, but still okay.
$(LIBDIR)/$(CONFIG)/lib${lib.name}.a : protobuf_dep_error
% if lib.build == "all" :
i f e q ( $( SYSTEM ) , M I N G W 3 2 )
$(LIBDIR)/$(CONFIG)/${lib.name}.$(SHARED_EXT) : protobuf_dep_error
e l s e
$(LIBDIR)/$(CONFIG)/lib${lib.name}.$(SHARED_EXT) : protobuf_dep_error
e n d i f
% e n d i f
e l s e
% e n d i f
$(LIBDIR)/$(CONFIG)/lib${lib.name}.a : $( ZLIB_DEP ) \
% e n d i f
% if lib.language == 'c++' :
$( PROTOBUF_DEP) \
% e n d i f
$( LIB${ lib .name.upper() } _OBJS)
$( E) " [AR] Creating $@ "
$( Q) mkdir -p ` dirname $@ `
$( Q) rm -f libs/$( CONFIG) /lib${ lib .name } .a
$( Q) $( AR) rcs libs/$( CONFIG) /lib${ lib .name } .a $( LIB${ lib .name.upper() } _OBJS)
$( Q) rm -f $( LIBDIR) /$( CONFIG) /lib${ lib .name } .a
$( Q) $( AR) rcs $( LIBDIR) /$( CONFIG) /lib${ lib .name } .a $( LIB${ lib .name.upper() } _OBJS)
% if lib.get('baselib', False) :
% if lib.get('secure', True) :
$( Q) rm -rf tmp-merge
$( Q) mkdir tmp-merge
$( Q) ( cd tmp-merge ; $( AR) x ../libs/$( CONFIG) /lib${ lib .name } .a )
$( Q) ( cd tmp-merge ; $( AR) x ../$( LIBDIR) /$( CONFIG) /lib${ lib .name } .a )
$( Q) for l in $( OPENSSL_MERGE_LIBS) ; do ( cd tmp-merge ; <%text>ar x ../$$ { l} </%text> ) ; done
$( Q) rm -f libs/$( CONFIG) /lib${ lib .name } .a tmp-merge/__.SYMDEF*
$( Q) ar rcs libs/$( CONFIG) /lib${ lib .name } .a tmp-merge/*
$( Q) rm -f $( LIBDIR) /$( CONFIG) /lib${ lib .name } .a tmp-merge/__.SYMDEF*
$( Q) ar rcs $( LIBDIR) /$( CONFIG) /lib${ lib .name } .a tmp-merge/*
$( Q) rm -rf tmp-merge
% e n d i f
% e n d i f
i f e q ( $( SYSTEM ) , D a r w i n )
$( Q) ranlib libs/$( CONFIG) /lib${ lib .name } .a
$( Q) ranlib $( LIBDIR) /$( CONFIG) /lib${ lib .name } .a
e n d i f
< %
@ -740,8 +888,8 @@ endif
else :
ld = '$(LD)'
out_base = 'libs /$(CONFIG)/' + lib.name
out_libbase = 'libs /$(CONFIG)/lib' + lib.name
out_base = '$(LIBDIR) /$(CONFIG)/' + lib.name
out_libbase = '$(LIBDIR) /$(CONFIG)/lib' + lib.name
common = '$(LIB' + lib.name.upper( ) + '_OBJS) $(LDLIBS)'
@ -751,9 +899,9 @@ endif
mingw_lib_deps = ' $(ZLIB_DEP)'
for dep in lib.get( 'deps' , [ ] ) :
libs = libs + ' -l' + dep
lib_deps = lib_deps + ' libs /$(CONFIG)/lib' + dep + '.$(SHARED_EXT)'
lib_deps = lib_deps + ' $(LIBDIR) /$(CONFIG)/lib' + dep + '.$(SHARED_EXT)'
mingw_libs = mingw_libs + ' -l' + dep + '-imp'
mingw_lib_deps = mingw_lib_deps + 'libs /$(CONFIG)/' + dep + '.$(SHARED_EXT)'
mingw_lib_deps = mingw_lib_deps + '$(LIBDIR) /$(CONFIG)/' + dep + '.$(SHARED_EXT)'
if lib.get( 'secure' , True) :
common = common + ' $(LDLIBS_SECURE) $(OPENSSL_MERGE_LIBS)'
@ -766,24 +914,29 @@ ifeq ($(SYSTEM),MINGW32)
${out_base}.$(SHARED_EXT) : $( LIB $ {lib .name .upper ( ) }_OBJS ) ${mingw_lib_deps }
$( E) " [LD] Linking $@ "
$( Q) mkdir -p ` dirname $@ `
$( Q) ${ ld } $( LDFLAGS) -Llibs /$( CONFIG) -shared -Wl,--output-def= ${ out_base } .def -Wl,--out-implib= ${ out_libbase } -imp.a -o ${ out_base } .$( SHARED_EXT) ${ common } ${ mingw_libs }
$( Q) ${ ld } $( LDFLAGS) -L$( LIBDIR) /$( CONFIG) -shared -Wl,--output-def= ${ out_base } .def -Wl,--out-implib= ${ out_libbase } -imp.a -o ${ out_base } .$( SHARED_EXT) ${ common } ${ mingw_libs }
e l s e
${out_libbase}.$(SHARED_EXT) : $( LIB $ {lib .name .upper ( ) }_OBJS ) ${lib_deps }
$( E) " [LD] Linking $@ "
$( Q) mkdir -p ` dirname $@ `
i f e q ( $( SYSTEM ) , D a r w i n )
$( Q) ${ ld } $( LDFLAGS) -Llibs /$( CONFIG) -dynamiclib -o ${ out_libbase } .$( SHARED_EXT) ${ common } ${ libs }
$( Q) ${ ld } $( LDFLAGS) -L$( LIBDIR) /$( CONFIG) -dynamiclib -o ${ out_libbase } .$( SHARED_EXT) ${ common } ${ libs }
e l s e
$( Q) ${ ld } $( LDFLAGS) -Llibs /$( CONFIG) -shared -Wl,-soname,lib${ lib .name } .so.${ settings .version.major } -o ${ out_libbase } .$( SHARED_EXT) ${ common } ${ libs }
$( Q) ${ ld } $( LDFLAGS) -L$( LIBDIR) /$( CONFIG) -shared -Wl,-soname,lib${ lib .name } .so.${ settings .version.major } -o ${ out_libbase } .$( SHARED_EXT) ${ common } ${ libs }
$( Q) ln -sf lib${ lib .name } .$( SHARED_EXT) ${ out_libbase } .so.${ settings .version.major }
$( Q) ln -sf lib${ lib .name } .$( SHARED_EXT) ${ out_libbase } .so
e n d i f
e n d i f
% e n d i f
% if lib.get('secure', True) :
## If the lib was secure, we have to close the Makefile's if that tested
## the presence of an ALPN-capable OpenSSL.
% if lib.get('secure', True) :
e n d i f
% e n d i f
% if lib.language == 'c++' :
## If the lib was C++, we have to close the Makefile's if that tested
## the presence of protobuf 3.0.0+
e n d i f
% e n d i f
@ -800,7 +953,7 @@ endif
% for src in lib.src :
% if not proto_re.match(src) :
objs /$(CONFIG)/${os.path.splitext(src)[0]}.o: \
$(OBJDIR) /$(CONFIG)/${os.path.splitext(src)[0]}.o: \
% for src2 in lib.src :
% if proto_re.match(src2) :
${ proto_to_cc (src2) } \
@ -819,14 +972,14 @@ ${tgt.name.upper()}_SRC = \\
% e n d f o r
${tgt.name.upper()}_OBJS = $( addprefix objs /$( CONFIG) /, $( addsuffix .o, $( basename $( ${ tgt .name.upper() } _SRC) ) ) )
${tgt.name.upper()}_OBJS = $( addprefix $( OBJDIR) /$( CONFIG) /, $( addsuffix .o, $( basename $( ${ tgt .name.upper() } _SRC) ) ) )
% if tgt.get('secure', True) :
i f e q ( $( NO_SECURE ) , t r u e )
# You can't build secure targets if you don't have OpenSSL with ALPN.
bins /$(CONFIG)/${tgt.name}: openssl_dep_error
$(BINDIR) /$(CONFIG)/${tgt.name}: openssl_dep_error
e l s e
@ -840,9 +993,22 @@ else
## That simplifies the codegen a bit, but prevents a fully defined Makefile.
## I can live with that.
##
bins/$(CONFIG)/${tgt.name} : $( $ {tgt .name .upper ( ) }_OBJS ) \
% if tgt.build == 'protoc' :
i f e q ( $( NO_PROTOBUF ) , t r u e )
# You can't build the protoc plugins if you don't have protobuf 3.0.0+.
$(BINDIR)/$(CONFIG)/${tgt.name} : protobuf_dep_error
e l s e
$(BINDIR)/$(CONFIG)/${tgt.name} : $( PROTOBUF_DEP ) $( $ {tgt .name .upper ( ) }_OBJS ) \
% else :
$(BINDIR)/$(CONFIG)/${tgt.name} : $( $ {tgt .name .upper ( ) }_OBJS ) \
% e n d i f
% for dep in tgt.deps :
libs/$( CONFIG) /lib${ dep } .a\
$( LIBDIR) /$( CONFIG) /lib${ dep } .a\
% e n d f o r
% if tgt.language == "c++" :
@ -866,13 +1032,13 @@ bins/$(CONFIG)/${tgt.name}: $(${tgt.name.upper()}_OBJS)\
$( Q) $( LD) $( LDFLAGS) $( ${ tgt .name.upper() } _OBJS) \
% e n d i f
% for dep in tgt.deps :
libs /$( CONFIG) /lib${ dep } .a\
$( LIBDIR) /$( CONFIG) /lib${ dep } .a\
% e n d f o r
% if tgt.language == "c++" :
% if tgt.build == 'protoc' :
$( HOST_LDLIBSXX) \
$( HOST_LDLIBSXX) $( HOST_LDLIBS_PROTOC) \
% else :
$( LDLIBSXX) \
$( LDLIBSXX) $( LDLIBS_PROTOBUF) \
% e n d i f
% e n d i f
% if tgt.build == 'protoc' :
@ -885,16 +1051,20 @@ bins/$(CONFIG)/${tgt.name}: $(${tgt.name.upper()}_OBJS)\
% elif tgt.get('secure', True) :
$( LDLIBS_SECURE) \
% e n d i f
-o bins/$( CONFIG) /${ tgt .name }
-o $( BINDIR) /$( CONFIG) /${ tgt .name }
% if tgt.build == 'protoc' :
e n d i f
% e n d i f
% if tgt.get('secure', True) :
e n d i f
% e n d i f
% for src in tgt.src :
objs /$(CONFIG)/${os.path.splitext(src)[0]}.o: \
$(OBJDIR) /$(CONFIG)/${os.path.splitext(src)[0]}.o: \
% for dep in tgt.deps :
libs /$( CONFIG) /lib${ dep } .a\
$( LIBDIR) /$( CONFIG) /lib${ dep } .a\
% e n d f o r
% e n d f o r