%YAML 1.2 --- | # GRPC global makefile # This currently builds C and C++ code. # This file has been automatically generated from a template file. # Please look at the templates directory instead. # This file can be regenerated from the template by running # tools/buildgen/generate_projects.sh # Copyright 2015 gRPC authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. <%! import re import os def get_dep_expression(dep): """For given dependency, return the expression to be used in Makefile rule dependencies.""" if dep == 'z': return "$(ZLIB_DEP)" elif dep == 'libssl': return "$(OPENSSL_DEP)" else: return "$(LIBDIR)/$(CONFIG)/lib%s.a" % dep def get_merge_libs_expression(dep): """For given dependency, return the lib archive expression to be used when linking.""" if dep == 'z': return "$(ZLIB_MERGE_LIBS)" elif dep == 'libssl': return "$(OPENSSL_MERGE_LIBS)" else: return "$(LIBDIR)/$(CONFIG)/lib%s.a" % dep def get_objs_expression(dep): """For given dependency, return the expression with variable that has list of all object files.""" if dep == 'z': return "$(ZLIB_MERGE_OBJS)" elif dep == 'libssl': return "$(OPENSSL_MERGE_OBJS)" else: return "$(LIB%s_OBJS)" % dep.upper() def get_make_rule_static_lib_deps(lib): """Generate make rule dependency list for given library, when building as static.""" make_rule_deps = [] collapsed_deps = lib.get('transitive_deps', []) # depend on static libraries for dep in collapsed_deps: make_rule_deps.append(get_dep_expression(dep)) # depend of obj files of this library itself make_rule_deps.append(get_objs_expression(lib.name)) # depend on obj files of dependencies for dep in collapsed_deps: make_rule_deps.append(get_objs_expression(dep)) return " ".join(make_rule_deps) def get_merge_objs_for_deps(lib): """Get list of merge objs for all deps of a given library.""" result = [] collapsed_deps = lib.get('transitive_deps', []) for dep in collapsed_deps: result.append(get_objs_expression(dep)) return " ".join(result) def get_make_rule_shared_lib_deps(lib): """Generate make rule dependency list given library, when built as shared.""" make_rule_deps = [] collapsed_deps = lib.get('transitive_deps', []) # depend of obj files of this library itself make_rule_deps.append(get_objs_expression(lib.name)) # depend on static libraries for dep in collapsed_deps: make_rule_deps.append(get_dep_expression(dep)) return " ".join(make_rule_deps) def get_shared_lib_linklibs(lib): """Generate list of libraries to link given library, when built as shared.""" result = [] collapsed_deps = lib.get('transitive_deps', []) # depend of obj files of this library itself result.append(get_objs_expression(lib.name)) # depend on static libraries for dep in collapsed_deps: result.append(get_merge_libs_expression(dep)) if 'libssl' in collapsed_deps: result.append("$(LDLIBS_SECURE)") result.append("$(LDLIBS)") return " ".join(result) lang_to_var = { 'c': 'CORE', 'c++': 'CPP', } %> <% lib_maps = {lib.name: lib for lib in libs} sys_libs = ['boringssl', 'cares', 'libssl', 'z'] # Build a new gRPC target which embeds sources of all dependencies except system libraries such as libz grpc_lib = lib_maps.get('grpc', None) for dep in set(grpc_lib.transitive_deps) - set(sys_libs): dep_lib = lib_maps.get(dep, None) if dep_lib: grpc_lib.src += dep_lib.src grpc_lib.headers += dep_lib.headers grpc_lib.src = list(sorted(set(grpc_lib.src))) grpc_lib.headers = list(sorted(set(grpc_lib.headers))) grpc_lib.deps = list(sorted(list(set(grpc_lib.deps) & set(sys_libs)))) grpc_lib.transitive_deps = list(sorted(list(set(grpc_lib.transitive_deps) & set(sys_libs)))) # Makefile is only intended for internal needs (building distribution artifacts etc.) # so we can restrict the number of libraries/targets that are buildable using the Makefile. # Other targets can be built with cmake or bazel. filtered_libs = [grpc_lib, ] + [lib_maps[lib] for lib in sys_libs if lib != 'libssl'] %> comma := , # Basic platform detection HOST_SYSTEM = $(shell uname | cut -f 1 -d_) SYSTEM ?= $(HOST_SYSTEM) ifeq ($(SYSTEM),MSYS) SYSTEM = MINGW32 endif ifeq ($(SYSTEM),MINGW64) SYSTEM = MINGW32 endif MAKEFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST))) ifndef BUILDDIR BUILDDIR_ABSOLUTE = $(patsubst %/,%,$(dir $(MAKEFILE_PATH))) else BUILDDIR_ABSOLUTE = $(abspath $(BUILDDIR)) endif HAS_GCC = $(shell which gcc > /dev/null 2> /dev/null && echo true || echo false) HAS_CC = $(shell which cc > /dev/null 2> /dev/null && echo true || echo false) HAS_CLANG = $(shell which clang > /dev/null 2> /dev/null && echo true || echo false) ifeq ($(HAS_CC),true) DEFAULT_CC = cc DEFAULT_CXX = c++ else ifeq ($(HAS_GCC),true) DEFAULT_CC = gcc DEFAULT_CXX = g++ else ifeq ($(HAS_CLANG),true) DEFAULT_CC = clang DEFAULT_CXX = clang++ else DEFAULT_CC = no_c_compiler DEFAULT_CXX = no_c++_compiler endif endif endif BINDIR = $(BUILDDIR_ABSOLUTE)/bins OBJDIR = $(BUILDDIR_ABSOLUTE)/objs LIBDIR = $(BUILDDIR_ABSOLUTE)/libs GENDIR = $(BUILDDIR_ABSOLUTE)/gens # Configurations (as defined under "configs" section in build_handwritten.yaml) % for name, args in configs.items(): VALID_CONFIG_${name} = 1 % if args.get('compile_the_world', False): REQUIRE_CUSTOM_LIBRARIES_${name} = 1 % endif % for tool, default in [('CC', 'CC'), ('CXX', 'CXX'), ('LD', 'CC'), ('LDXX', 'CXX')]: ${tool}_${name} = ${args.get(tool, '$(DEFAULT_%s)' % default)} % endfor % for arg in ['CFLAGS', 'CXXFLAGS', 'CPPFLAGS', 'LDFLAGS', 'DEFINES']: % if args.get(arg, None) is not None: ${arg}_${name} = ${args.get(arg)} % endif % endfor % endfor # General settings. # You may want to change these depending on your system. prefix ?= /usr/local DTRACE ?= dtrace CONFIG ?= opt # Doing X ?= Y is the same as: # ifeq ($(origin X), undefined) # X = Y # endif # but some variables, such as CC, CXX, LD or AR, have defaults. # So instead of using ?= on them, we need to check their origin. # See: # https://www.gnu.org/software/make/manual/html_node/Implicit-Variables.html # https://www.gnu.org/software/make/manual/html_node/Flavors.html#index-_003f_003d # https://www.gnu.org/software/make/manual/html_node/Origin-Function.html ifeq ($(origin CC), default) CC = $(CC_$(CONFIG)) endif ifeq ($(origin CXX), default) CXX = $(CXX_$(CONFIG)) endif ifeq ($(origin LD), default) LD = $(LD_$(CONFIG)) endif LDXX ?= $(LDXX_$(CONFIG)) ARFLAGS ?= rcs ifeq ($(SYSTEM),Linux) ifeq ($(origin AR), default) AR = ar endif STRIP ?= strip --strip-unneeded else ifeq ($(SYSTEM),Darwin) ifeq ($(origin AR), default) AR = libtool ARFLAGS = -no_warning_for_no_symbols -o endif STRIP ?= strip -x else ifeq ($(SYSTEM),MINGW32) ifeq ($(origin AR), default) AR = ar endif STRIP ?= strip --strip-unneeded else ifeq ($(origin AR), default) AR = ar endif STRIP ?= strip endif endif endif INSTALL ?= install RM ?= rm -f PKG_CONFIG ?= pkg-config RANLIB ?= ranlib ifeq ($(SYSTEM),Darwin) APPLE_RANLIB = $(shell [[ "`$(RANLIB) -V 2>/dev/null`" == "Apple Inc."* ]]; echo $$?) ifeq ($(APPLE_RANLIB),0) RANLIBFLAGS = -no_warning_for_no_symbols endif endif ifndef VALID_CONFIG_$(CONFIG) $(error Invalid CONFIG value '$(CONFIG)') endif # The HOST compiler settings are used to compile the protoc plugins. # In most cases, you won't have to change anything, but if you are # cross-compiling, you can override these variables from GNU make's # command line: make CC=cross-gcc HOST_CC=gcc HOST_CC ?= $(CC) HOST_CXX ?= $(CXX) HOST_LD ?= $(LD) HOST_LDXX ?= $(LDXX) CFLAGS += -std=c11 CXXFLAGS += -std=c++14 ifeq ($(SYSTEM),Darwin) CXXFLAGS += -stdlib=libc++ LDFLAGS += -framework CoreFoundation endif % for arg in ['CFLAGS', 'CXXFLAGS', 'CPPFLAGS', 'COREFLAGS', 'LDFLAGS', 'DEFINES']: % if defaults.get('global', []).get(arg, None) is not None: ${arg} += ${defaults.get('global').get(arg)} % endif % endfor CPPFLAGS += $(CPPFLAGS_$(CONFIG)) CFLAGS += $(CFLAGS_$(CONFIG)) CXXFLAGS += $(CXXFLAGS_$(CONFIG)) DEFINES += $(DEFINES_$(CONFIG)) INSTALL_PREFIX=\"$(prefix)\" LDFLAGS += $(LDFLAGS_$(CONFIG)) ifneq ($(SYSTEM),MINGW32) PIC_CPPFLAGS = -fPIC CPPFLAGS += -fPIC LDFLAGS += -fPIC endif INCLUDES = . include $(GENDIR) LDFLAGS += -Llibs/$(CONFIG) ifeq ($(SYSTEM),Darwin) ifneq ($(wildcard /usr/local/ssl/include),) INCLUDES += /usr/local/ssl/include endif ifneq ($(wildcard /opt/local/include),) INCLUDES += /opt/local/include endif ifneq ($(wildcard /usr/local/include),) INCLUDES += /usr/local/include endif LIBS = m z ifneq ($(wildcard /usr/local/ssl/lib),) LDFLAGS += -L/usr/local/ssl/lib endif ifneq ($(wildcard /opt/local/lib),) LDFLAGS += -L/opt/local/lib endif ifneq ($(wildcard /usr/local/lib),) LDFLAGS += -L/usr/local/lib endif endif ifeq ($(SYSTEM),Linux) LIBS = dl rt m pthread LDFLAGS += -pthread endif ifeq ($(SYSTEM),MINGW32) LIBS = m pthread ws2_32 crypt32 iphlpapi dbghelp bcrypt LDFLAGS += -pthread endif # # The steps for cross-compiling are as follows: # First, clone and make install of grpc using the native compilers for the host. # Also, install protoc (e.g., from a package like apt-get) # Then clone a fresh grpc for the actual cross-compiled build # Set the environment variable GRPC_CROSS_COMPILE to true # Set CC, CXX, LD, LDXX, AR, and STRIP to the cross-compiling binaries # Also set PROTOBUF_CONFIG_OPTS to indicate cross-compilation to protobuf (e.g., # PROTOBUF_CONFIG_OPTS="--host=arm-linux --with-protoc=/usr/local/bin/protoc" ) # Set HAS_PKG_CONFIG=false # Make sure that you enable building shared libraries and set your prefix to # something useful like /usr/local/cross # You will also need to set GRPC_CROSS_LDOPTS and GRPC_CROSS_AROPTS to hold # additional required arguments for LD and AR (examples below) # Then you can do a make from the cross-compiling fresh clone! # ifeq ($(GRPC_CROSS_COMPILE),true) LDFLAGS += $(GRPC_CROSS_LDOPTS) # e.g. -L/usr/local/lib -L/usr/local/cross/lib ARFLAGS += $(GRPC_CROSS_AROPTS) # e.g., rc --target=elf32-little USE_BUILT_PROTOC = false endif # V=1 can be used to print commands run by make ifeq ($(V),1) E = @: Q = else E = @echo Q = @ endif CORE_VERSION = ${settings.core_version} CPP_VERSION = ${settings.cpp_version} CPPFLAGS_NO_ARCH += $(addprefix -I, $(INCLUDES)) $(addprefix -D, $(DEFINES)) CPPFLAGS += $(CPPFLAGS_NO_ARCH) $(ARCH_FLAGS) LDFLAGS += $(ARCH_FLAGS) LDLIBS += $(addprefix -l, $(LIBS)) LDLIBSXX += $(addprefix -l, $(LIBSXX)) % for arg in ['CFLAGS', 'CXXFLAGS', 'CPPFLAGS', 'LDFLAGS', 'DEFINES', 'LDLIBS']: ${arg} += $(EXTRA_${arg}) % endfor HOST_CPPFLAGS += $(CPPFLAGS) HOST_CFLAGS += $(CFLAGS) HOST_CXXFLAGS += $(CXXFLAGS) HOST_LDFLAGS += $(LDFLAGS) HOST_LDLIBS += $(LDLIBS) # These are automatically computed variables. # There shouldn't be any need to change anything from now on. -include cache.mk CACHE_MK = ifeq ($(SYSTEM),MINGW32) EXECUTABLE_SUFFIX = .exe SHARED_EXT_CORE = dll SHARED_EXT_CPP = dll SHARED_PREFIX = SHARED_VERSION_CORE = -${settings.core_version.major} SHARED_VERSION_CPP = -${settings.cpp_version.major} else ifeq ($(SYSTEM),Darwin) EXECUTABLE_SUFFIX = SHARED_EXT_CORE = dylib SHARED_EXT_CPP = dylib SHARED_PREFIX = lib SHARED_VERSION_CORE = SHARED_VERSION_CPP = else EXECUTABLE_SUFFIX = SHARED_EXT_CORE = so.$(CORE_VERSION) SHARED_EXT_CPP = so.$(CPP_VERSION) SHARED_PREFIX = lib SHARED_VERSION_CORE = SHARED_VERSION_CPP = endif ifeq ($(wildcard .git),) IS_GIT_FOLDER = false else IS_GIT_FOLDER = true endif # Setup zlib dependency ifeq ($(wildcard third_party/zlib/zlib.h),) HAS_EMBEDDED_ZLIB = false else HAS_EMBEDDED_ZLIB = true endif # for zlib, we support building both from submodule # and from system-installed zlib. In some builds, # embedding zlib is not desirable. # By default we use the system zlib (to match legacy behavior) EMBED_ZLIB ?= false ifeq ($(EMBED_ZLIB),true) ZLIB_DEP = $(LIBDIR)/$(CONFIG)/libz.a ZLIB_MERGE_LIBS = $(LIBDIR)/$(CONFIG)/libz.a ZLIB_MERGE_OBJS = $(LIBZ_OBJS) CPPFLAGS += -Ithird_party/zlib else LIBS += z endif # Setup boringssl dependency ifeq ($(wildcard third_party/boringssl-with-bazel/src/include/openssl/ssl.h),) HAS_EMBEDDED_OPENSSL = false else HAS_EMBEDDED_OPENSSL = true endif ifeq ($(HAS_EMBEDDED_OPENSSL),true) EMBED_OPENSSL ?= true else # only support building boringssl from submodule DEP_MISSING += openssl EMBED_OPENSSL ?= broken endif ifeq ($(EMBED_OPENSSL),true) OPENSSL_DEP += $(LIBDIR)/$(CONFIG)/libboringssl.a OPENSSL_MERGE_LIBS += $(LIBDIR)/$(CONFIG)/libboringssl.a OPENSSL_MERGE_OBJS += $(LIBBORINGSSL_OBJS) # need to prefix these to ensure overriding system libraries CPPFLAGS := -Ithird_party/boringssl-with-bazel/src/include $(CPPFLAGS) ifeq ($(DISABLE_ALPN),true) CPPFLAGS += -DTSI_OPENSSL_ALPN_SUPPORT=0 LIBS_SECURE = $(OPENSSL_LIBS) endif # DISABLE_ALPN endif # EMBED_OPENSSL LDLIBS_SECURE += $(addprefix -l, $(LIBS_SECURE)) ifeq ($(MAKECMDGOALS),clean) NO_DEPS = true endif ifeq ($(DEP_MISSING),) all: static shared dep_error: @echo "You shouldn't see this message - all of your dependencies are correct." else all: dep_error git_update stop dep_error: @echo @echo "DEPENDENCY ERROR" @echo @echo "You are missing system dependencies that are essential to build grpc," @echo "and the third_party directory doesn't have them:" @echo @echo " $(DEP_MISSING)" @echo @echo "Installing the development packages for your system will solve" @echo "this issue. 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 endif git_update: ifeq ($(IS_GIT_FOLDER),true) @echo "Additionally, since you are in a git clone, you can download the" @echo "missing dependencies in third_party by running the following command:" @echo @echo " git submodule update --init" @echo endif openssl_dep_error: openssl_dep_message git_update stop openssl_dep_message: @echo @echo "DEPENDENCY ERROR" @echo @echo "The target you are trying to run requires an OpenSSL implementation." @echo "Your system doesn't have one, and either the third_party directory" @echo "doesn't have it, or your compiler can't build BoringSSL." @echo @echo "Please consult BUILDING.md to get more information." @echo @echo "If you need information about why these tests failed, run:" @echo @echo " make run_dep_checks" @echo systemtap_dep_error: @echo @echo "DEPENDENCY ERROR" @echo @echo "Under the '$(CONFIG)' configuration, the target you are trying " @echo "to build requires systemtap 2.7+ (on Linux) or dtrace (on other " @echo "platforms such as Solaris and *BSD). " @echo @echo "Please consult BUILDING.md to get more information." @echo install_not_supported_message: @echo @echo "Installing via 'make' is no longer supported. Use cmake or bazel instead." @echo @echo "Please consult BUILDING.md to get more information." @echo install_not_supported_error: install_not_supported_message stop stop: @false run_dep_checks: @echo "run_dep_checks target has been deprecated." static: static_c static_cxx static_c: cache.mk \ % for lib in filtered_libs: % if 'Makefile' in lib.get('build_system', ['Makefile']): % if lib.build == 'all' and lib.language == 'c' and not lib.get('external_deps', None): $(LIBDIR)/$(CONFIG)/lib${lib.name}.a\ % endif % endif % endfor static_cxx: cache.mk \ % for lib in filtered_libs: % if 'Makefile' in lib.get('build_system', ['Makefile']): % if lib.build == 'all' and lib.language == 'c++': $(LIBDIR)/$(CONFIG)/lib${lib.name}.a\ % endif % endif % endfor shared: shared_c shared_cxx shared_c: cache.mk\ % for lib in filtered_libs: % if 'Makefile' in lib.get('build_system', ['Makefile']): % if lib.build == 'all' and lib.language == 'c' and not lib.get('external_deps', None): $(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)${lib.name}$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE)\ % endif % endif % endfor shared_cxx: cache.mk\ % for lib in filtered_libs: % if 'Makefile' in lib.get('build_system', ['Makefile']): % if lib.build == 'all' and lib.language == 'c++': $(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)${lib.name}$(SHARED_VERSION_CPP).$(SHARED_EXT_CPP)\ % endif % endif % endfor privatelibs: privatelibs_c privatelibs_cxx privatelibs_c: \ % for lib in filtered_libs: % if 'Makefile' in lib.get('build_system', ['Makefile']): % if lib.build == 'private' and lib.language == 'c' and not lib.get('external_deps', None) and not lib.boringssl: $(LIBDIR)/$(CONFIG)/lib${lib.name}.a\ % endif % endif % endfor ifeq ($(EMBED_OPENSSL),true) privatelibs_cxx: \ % for lib in filtered_libs: % if 'Makefile' in lib.get('build_system', ['Makefile']): % if lib.build == 'private' and lib.language == 'c++' and not lib.get('external_deps', None): $(LIBDIR)/$(CONFIG)/lib${lib.name}.a\ % endif % endif % endfor else privatelibs_cxx: \ % for lib in filtered_libs: % if 'Makefile' in lib.get('build_system', ['Makefile']): % if lib.build == 'private' and lib.language == 'c++' and not lib.get('external_deps', None) and not lib.boringssl: $(LIBDIR)/$(CONFIG)/lib${lib.name}.a\ % endif % endif % endfor endif strip: strip-static strip-shared strip-static: strip-static_c strip-static_cxx strip-shared: strip-shared_c strip-shared_cxx strip-static_c: static_c ifeq ($(CONFIG),opt) % for lib in filtered_libs: % if 'Makefile' in lib.get('build_system', ['Makefile']): % if lib.language == "c": % if lib.build == "all": % if not lib.get('external_deps', None): $(E) "[STRIP] Stripping lib${lib.name}.a" $(Q) $(STRIP) $(LIBDIR)/$(CONFIG)/lib${lib.name}.a % endif % endif % endif % endif % endfor endif strip-static_cxx: static_cxx ifeq ($(CONFIG),opt) % for lib in filtered_libs: % if 'Makefile' in lib.get('build_system', ['Makefile']): % if lib.language == "c++": % if lib.build == "all": $(E) "[STRIP] Stripping lib${lib.name}.a" $(Q) $(STRIP) $(LIBDIR)/$(CONFIG)/lib${lib.name}.a % endif % endif % endif % endfor endif strip-shared_c: shared_c ifeq ($(CONFIG),opt) % for lib in filtered_libs: % if 'Makefile' in lib.get('build_system', ['Makefile']): % if lib.language == "c": % if lib.build == "all": % if not lib.get('external_deps', None): $(E) "[STRIP] Stripping $(SHARED_PREFIX)${lib.name}$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE)" $(Q) $(STRIP) $(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)${lib.name}$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) % endif % endif % endif % endif % endfor endif strip-shared_cxx: shared_cxx ifeq ($(CONFIG),opt) % for lib in filtered_libs: % if 'Makefile' in lib.get('build_system', ['Makefile']): % if lib.language == "c++": % if lib.build == "all": $(E) "[STRIP] Stripping $(SHARED_PREFIX)${lib.name}$(SHARED_VERSION_CPP).$(SHARED_EXT_CPP)" $(Q) $(STRIP) $(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)${lib.name}$(SHARED_VERSION_CPP).$(SHARED_EXT_CPP) % endif % endif % endif % endfor endif cache.mk:: $(E) "[MAKE] Generating $@" $(Q) echo "$(CACHE_MK)" | tr , '\n' >$@ $(OBJDIR)/$(CONFIG)/%.o : %.c $(E) "[C] Compiling $<" $(Q) mkdir -p `dirname $@` $(Q) $(CC) $(CPPFLAGS) $(CFLAGS) -MMD -MF $(addsuffix .dep, $(basename $@)) -c -o $@ $< $(OBJDIR)/$(CONFIG)/%.o : $(GENDIR)/%.pb.cc $(E) "[CXX] Compiling $<" $(Q) mkdir -p `dirname $@` $(Q) $(CXX) $(CPPFLAGS) $(CXXFLAGS) -MMD -MF $(addsuffix .dep, $(basename $@)) -c -o $@ $< $(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 $@ $< $(OBJDIR)/$(CONFIG)/src/core/%.o : src/core/%.cc $(E) "[CXX] Compiling $<" $(Q) mkdir -p `dirname $@` $(Q) $(CXX) $(CPPFLAGS) $(CXXFLAGS) $(COREFLAGS) -MMD -MF $(addsuffix .dep, $(basename $@)) -c -o $@ $< $(OBJDIR)/$(CONFIG)/%.o : %.cc $(E) "[CXX] Compiling $<" $(Q) mkdir -p `dirname $@` $(Q) $(CXX) $(CPPFLAGS) $(CXXFLAGS) -MMD -MF $(addsuffix .dep, $(basename $@)) -c -o $@ $< $(OBJDIR)/$(CONFIG)/%.o : %.cpp $(E) "[CXX] Compiling $<" $(Q) mkdir -p `dirname $@` $(Q) $(CXX) $(CPPFLAGS) $(CXXFLAGS) -MMD -MF $(addsuffix .dep, $(basename $@)) -c -o $@ $< install: install_not_supported_error install_c: install_not_supported_error install_cxx: install_not_supported_error install-static: install_not_supported_error install-certs: install_not_supported_error clean: $(E) "[CLEAN] Cleaning build directories." $(Q) $(RM) -rf $(OBJDIR) $(LIBDIR) $(BINDIR) $(GENDIR) cache.mk # The various libraries % for lib in filtered_libs: % if 'Makefile' in lib.get('build_system', ['Makefile']): ${makelib(lib)} % endif % endfor <%def name="makelib(lib)"> # start of build recipe for library "${lib.name}" (generated by makelib(lib) template function) # deps: ${lib.get('deps', [])} # transitive_deps: ${lib.get('transitive_deps', [])} LIB${lib.name.upper()}_SRC = \\ % for src in sorted(lib.src): ${src} \\ % endfor % if "public_headers" in lib: % if lib.language == "c++": PUBLIC_HEADERS_CXX += \\ % else: PUBLIC_HEADERS_C += \\ % endif % for hdr in sorted(lib.public_headers): ${hdr} \\ % endfor % endif LIB${lib.name.upper()}_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(LIB${lib.name.upper()}_SRC)))) % if lib.get('defaults', None): % for name, value in defaults.get(lib.defaults).items(): $(LIB${lib.name.upper()}_OBJS): ${name} += ${value} % endfor % endif ## If the library requires OpenSSL, let's add some restrictions. % if 'libssl' in lib.get('transitive_deps', []): ifeq ($(NO_SECURE),true) # You can't build secure libraries if you don't have OpenSSL. $(LIBDIR)/$(CONFIG)/lib${lib.name}.a: openssl_dep_error % if lib.build == "all": $(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)${lib.name}$(SHARED_VERSION_${lang_to_var[lib.language]}).$(SHARED_EXT_${lang_to_var[lib.language]}): openssl_dep_error % endif else ## The following endif corresponds to the "If the library requires OpenSSL" above % endif # static library for "${lib.name}" $(LIBDIR)/$(CONFIG)/lib${lib.name}.a: ${get_make_rule_static_lib_deps(lib)} $(E) "[AR] Creating $@" $(Q) mkdir -p `dirname $@` $(Q) rm -f $(LIBDIR)/$(CONFIG)/lib${lib.name}.a $(Q) $(AR) $(ARFLAGS) $(LIBDIR)/$(CONFIG)/lib${lib.name}.a $(LIB${lib.name.upper()}_OBJS) ${get_merge_objs_for_deps(lib)} ifeq ($(SYSTEM),Darwin) $(Q) $(RANLIB) $(RANLIBFLAGS) $(LIBDIR)/$(CONFIG)/lib${lib.name}.a endif <% ld = '$(LDXX)' out_mingbase = '$(LIBDIR)/$(CONFIG)/' + lib.name + '$(SHARED_VERSION_' + lang_to_var[lib.language] + ')' out_libbase = '$(LIBDIR)/$(CONFIG)/lib' + lib.name + '$(SHARED_VERSION_' + lang_to_var[lib.language] + ')' ldflags = '$(LDFLAGS)' if lib.get('LDFLAGS', None): ldflags += ' ' + lib['LDFLAGS'] %> # shared library for "${lib.name}" % if lib.build == "all": ifeq ($(SYSTEM),MINGW32) ${out_mingbase}.$(SHARED_EXT_${lang_to_var[lib.language]}): ${get_make_rule_shared_lib_deps(lib)} $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` $(Q) ${ld} ${ldflags} -L$(LIBDIR)/$(CONFIG) -shared -Wl,--output-def=${out_mingbase}.def -Wl,--out-implib=${out_libbase}-dll.a -o ${out_mingbase}.$(SHARED_EXT_${lang_to_var[lib.language]}) ${get_shared_lib_linklibs(lib)} else ${out_libbase}.$(SHARED_EXT_${lang_to_var[lib.language]}): ${get_make_rule_shared_lib_deps(lib)} $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` ifeq ($(SYSTEM),Darwin) $(Q) ${ld} ${ldflags} -L$(LIBDIR)/$(CONFIG) -install_name $(SHARED_PREFIX)${lib.name}$(SHARED_VERSION_${lang_to_var[lib.language]}).$(SHARED_EXT_${lang_to_var[lib.language]}) -dynamiclib -o ${out_libbase}.$(SHARED_EXT_${lang_to_var[lib.language]}) ${get_shared_lib_linklibs(lib)} else $(Q) ${ld} ${ldflags} -L$(LIBDIR)/$(CONFIG) -shared -Wl,-soname,lib${lib.name}.so.${settings.get(lang_to_var[lib.language].lower() + '_version').major} -o ${out_libbase}.$(SHARED_EXT_${lang_to_var[lib.language]}) ${get_shared_lib_linklibs(lib)} $(Q) ln -sf $(SHARED_PREFIX)${lib.name}$(SHARED_VERSION_${lang_to_var[lib.language]}).$(SHARED_EXT_${lang_to_var[lib.language]}) ${out_libbase}.so.${settings.get(lang_to_var[lib.language].lower() + '_version').major} $(Q) ln -sf $(SHARED_PREFIX)${lib.name}$(SHARED_VERSION_${lang_to_var[lib.language]}).$(SHARED_EXT_${lang_to_var[lib.language]}) ${out_libbase}.so endif endif % endif % if 'libssl' in lib.get('transitive_deps', []): ## If the lib was secure, we have to close the Makefile's ifeq that tested ## the presence of OpenSSL. endif # corresponds to the "ifeq ($(NO_SECURE),true)" above % endif % if 'libssl' in lib.get('transitive_deps', []): ifneq ($(NO_SECURE),true) % endif ifneq ($(NO_DEPS),true) -include $(LIB${lib.name.upper()}_OBJS:.o=.dep) endif % if 'libssl' in lib.get('transitive_deps', []): endif % endif # end of build recipe for library "${lib.name}" .PHONY: all strip tools \ dep_error openssl_dep_error openssl_dep_message git_update stop \ buildtests buildtests_c buildtests_cxx \ test test_c test_cxx \ install install_c install_cxx install-static install-certs \ strip strip-shared strip-static \ strip_c strip-shared_c strip-static_c \ strip_cxx strip-shared_cxx strip-static_cxx \ dep_c dep_cxx bins_dep_c bins_dep_cxx \ clean .PHONY: printvars printvars: @$(foreach V,$(sort $(.VARIABLES)), \ $(if $(filter-out environment% default automatic, \ $(origin $V)),$(warning $V=$($V) ($(value $V)))))