12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055 |
- %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 is_absl_lib(target_name):
- return target_name.startswith("absl/");
- sources_that_need_openssl = set()
- sources_that_don_t_need_openssl = set()
- # warnings we'd like, but that don't exist in all compilers
- PREFERRED_WARNINGS=['extra-semi']
- CHECK_WARNINGS=PREFERRED_WARNINGS + ['no-shift-negative-value', 'no-unused-but-set-variable', 'no-maybe-uninitialized', 'no-unknown-warning-option']
- def warning_var(fmt, warning):
- return fmt % warning.replace('-', '_').replace('+', 'X').upper()
- def neg_warning(warning):
- if warning[0:3] == 'no-':
- return warning[3:]
- else:
- return 'no-' + warning
- lang_to_var = {
- 'c': 'CORE',
- 'c++': 'CPP',
- 'csharp': 'CSHARP'
- }
- %>
- <%
- # 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.
- # TODO(jtattermusch): Figure out how to avoid the need to list the dependencies explicitly.
- # Currently it is necessary because some dependencies are marked as "build: private" in build.yaml
- # (which itself is correct, as they are not "public" libraries from our perspective and cmake
- # needs to have them marked as such)
- filtered_libs = [lib for lib in libs if (lib.build in ['all'] and lib.language != 'c++') or lib.name in ['ares', 'boringssl', 're2', 'upb', 'z']]
- filtered_targets = [tgt for tgt in targets if tgt.build in ['all'] and lib.language != 'c++']
- %>
- 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
- ifndef VALID_CONFIG_$(CONFIG)
- $(error Invalid CONFIG value '$(CONFIG)')
- endif
- ifeq ($(SYSTEM),Linux)
- TMPOUT = /dev/null
- else
- TMPOUT = `mktemp /tmp/test-out-XXXXXX`
- endif
- CHECK_NO_CXX14_COMPAT_WORKS_CMD = $(CC) -std=c++11 -Werror -Wno-c++14-compat -o $(TMPOUT) -c test/build/no-c++14-compat.cc
- HAS_WORKING_NO_CXX14_COMPAT = $(shell $(CHECK_NO_CXX14_COMPAT_WORKS_CMD) 2> /dev/null && echo true || echo false)
- ifeq ($(HAS_WORKING_NO_CXX14_COMPAT),true)
- W_NO_CXX14_COMPAT=-Wno-c++14-compat
- endif
- %for warning in CHECK_WARNINGS:
- ${warning_var('CHECK_%s_WORKS_CMD', warning)} = $(CC) -std=c99 -Werror -W${warning} -o $(TMPOUT) -c test/build/${warning}.c
- ${warning_var('HAS_WORKING_%s', warning)} = $(shell $(${warning_var('CHECK_%s_WORKS_CMD', warning)}) 2> /dev/null && echo true || echo false)
- ifeq ($(${warning_var('HAS_WORKING_%s', warning)}),true)
- ${warning_var('W_%s', warning)}=-W${warning}
- ${warning_var('NO_W_%s', warning)}=-W${neg_warning(warning)}
- endif
- %endfor
- # 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=c99 ${' '.join(warning_var('$(W_%s)', warning) for warning in PREFERRED_WARNINGS)}
- CXXFLAGS += -std=c++11
- 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 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
- # To build tests, go to third_party/gflags and follow its ccmake instructions
- # 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}
- CSHARP_VERSION = ${settings.csharp_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_EXT_CSHARP = dll
- SHARED_PREFIX =
- SHARED_VERSION_CORE = -${settings.core_version.major}
- SHARED_VERSION_CPP = -${settings.cpp_version.major}
- SHARED_VERSION_CSHARP = -${settings.csharp_version.major}
- else ifeq ($(SYSTEM),Darwin)
- EXECUTABLE_SUFFIX =
- SHARED_EXT_CORE = dylib
- SHARED_EXT_CPP = dylib
- SHARED_EXT_CSHARP = dylib
- SHARED_PREFIX = lib
- SHARED_VERSION_CORE =
- SHARED_VERSION_CPP =
- SHARED_VERSION_CSHARP =
- else
- EXECUTABLE_SUFFIX =
- SHARED_EXT_CORE = so.$(CORE_VERSION)
- SHARED_EXT_CPP = so.$(CPP_VERSION)
- SHARED_EXT_CSHARP = so.$(CSHARP_VERSION)
- SHARED_PREFIX = lib
- SHARED_VERSION_CORE =
- SHARED_VERSION_CPP =
- SHARED_VERSION_CSHARP =
- 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 c-ares dependency
- ifeq ($(wildcard third_party/cares/cares/include/ares.h),)
- HAS_EMBEDDED_CARES = false
- else
- HAS_EMBEDDED_CARES = true
- endif
-
- ifeq ($(HAS_EMBEDDED_CARES),true)
- EMBED_CARES ?= true
- else
- # only building with c-ares from submodule is supported
- DEP_MISSING += cares
- EMBED_CARES ?= broken
- endif
- ifeq ($(EMBED_CARES),true)
- CARES_DEP = $(LIBDIR)/$(CONFIG)/libares.a
- CARES_MERGE_OBJS = $(LIBARES_OBJS)
- CARES_MERGE_LIBS = $(LIBDIR)/$(CONFIG)/libares.a
- CPPFLAGS := -Ithird_party/cares/cares/include -Ithird_party/cares -Ithird_party/cares/cares $(CPPFLAGS)
- endif
- # Setup address_sorting dependency
- ADDRESS_SORTING_DEP = $(LIBDIR)/$(CONFIG)/libaddress_sorting.a
- ADDRESS_SORTING_MERGE_OBJS = $(LIBADDRESS_SORTING_OBJS)
- ADDRESS_SORTING_MERGE_LIBS = $(LIBDIR)/$(CONFIG)/libaddress_sorting.a
- CPPFLAGS := -Ithird_party/address_sorting/include $(CPPFLAGS)
- # Setup abseil dependency
- GRPC_ABSEIL_DEP = $(LIBDIR)/$(CONFIG)/libgrpc_abseil.a
- GRPC_ABSEIL_MERGE_LIBS = $(LIBDIR)/$(CONFIG)/libgrpc_abseil.a
- # Setup re2 dependency
- RE2_DEP = $(LIBDIR)/$(CONFIG)/libre2.a
- RE2_MERGE_OBJS = $(LIBRE2_OBJS)
- RE2_MERGE_LIBS = $(LIBDIR)/$(CONFIG)/libre2.a
- # Setup upb dependency
- UPB_DEP = $(LIBDIR)/$(CONFIG)/libupb.a
- UPB_MERGE_OBJS = $(LIBUPB_OBJS)
- UPB_MERGE_LIBS = $(LIBDIR)/$(CONFIG)/libupb.a
- # 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
- .SECONDARY = %.pb.h %.pb.cc
- ifeq ($(DEP_MISSING),)
- all: static shared\
- % for tgt in filtered_targets:
- % if tgt.build == 'all':
- $(BINDIR)/$(CONFIG)/${tgt.name}\
- % endif
- % endfor
- 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)' configutation, 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
- % for tgt in filtered_targets:
- ${tgt.name}: $(BINDIR)/$(CONFIG)/${tgt.name}
- % endfor
- 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
- static_csharp: static_c \
- % for lib in filtered_libs:
- % if 'Makefile' in lib.get('build_system', ['Makefile']):
- % if lib.build == 'all' and lib.language == 'csharp':
- $(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
- shared_csharp: shared_c \
- % for lib in filtered_libs:
- % if 'Makefile' in lib.get('build_system', ['Makefile']):
- % if lib.build == 'all' and lib.language == 'csharp':
- $(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)${lib.name}$(SHARED_VERSION_CSHARP).$(SHARED_EXT_CSHARP)\
- % endif
- % endif
- % endfor
- grpc_csharp_ext: shared_csharp
- 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
- strip-shared_csharp: shared_csharp
- ifeq ($(CONFIG),opt)
- % for lib in filtered_libs:
- % if 'Makefile' in lib.get('build_system', ['Makefile']):
- % if lib.language == "csharp":
- % if lib.build == "all":
- $(E) "[STRIP] Stripping $(SHARED_PREFIX)${lib.name}$(SHARED_VERSION_CSHARP).$(SHARED_EXT_CSHARP)"
- $(Q) $(STRIP) $(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)${lib.name}$(SHARED_VERSION_CSHARP).$(SHARED_EXT_CSHARP)
- % endif
- % endif
- % endif
- % endfor
- endif
- cache.mk::
- $(E) "[MAKE] Generating $@"
- $(Q) echo "$(CACHE_MK)" | tr , '\n' >$@
- ifeq ($(CONFIG),stapprof)
- src/core/profiling/stap_timers.c: $(GENDIR)/src/core/profiling/stap_probes.h
- ifeq ($(HAS_SYSTEMTAP),true)
- $(GENDIR)/src/core/profiling/stap_probes.h: src/core/profiling/stap_probes.d
- $(E) "[DTRACE] Compiling $<"
- $(Q) mkdir -p `dirname $@`
- $(Q) $(DTRACE) -C -h -s $< -o $@
- else
- $(GENDIR)/src/core/profiling/stap_probes.h: systemtap_dep_error stop
- endif
- endif
- $(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)/test/core/%.o : test/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_csharp: 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
- # Add private ABSEIL target which contains all sources used by all baselib libraries.
- <%
- # Collect all abseil source and header files used by gpr, grpc, so on.
- used_abseil_rules = set()
- for lib in libs:
- if lib.get("baselib"):
- for dep in lib.transitive_deps:
- if is_absl_lib(dep):
- used_abseil_rules.add(dep)
- used_abseil_srcs = []
- used_abseil_hdrs = []
- for lib in libs:
- if lib.name in used_abseil_rules:
- used_abseil_srcs.extend(lib.get("src", []))
- used_abseil_hdrs.extend(lib.get("hdr", []))
- # Create `grpc_abseil` rule with collected files.
- lib_type = type(libs[0])
- grpc_abseil_lib = lib_type({
- "name": "grpc_abseil",
- "build": "private",
- "language": "c",
- "defaults": "abseil",
- "src": sorted(used_abseil_srcs),
- "hdr": sorted(used_abseil_hdrs),
- })
- %>
- ${makelib(grpc_abseil_lib)}
- <%def name="makelib(lib)">
- # start of build recipe for library "${lib.name}" (generated by makelib(lib) template function)
- LIB${lib.name.upper()}_SRC = \\
- % for src in lib.src:
- ${src} \\
- % endfor
- % if "public_headers" in lib:
- % if lib.language == "c++":
- PUBLIC_HEADERS_CXX += \\
- % else:
- PUBLIC_HEADERS_C += \\
- % endif
- % for hdr in 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('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
- $(LIBDIR)/$(CONFIG)/lib${lib.name}.a: $(ZLIB_DEP) $(OPENSSL_DEP) $(CARES_DEP) $(ADDRESS_SORTING_DEP) $(RE2_DEP) $(UPB_DEP) $(GRPC_ABSEIL_DEP) \
- ## The else here corresponds to the if secure earlier.
- % else:
- $(LIBDIR)/$(CONFIG)/lib${lib.name}.a: \
- % if lib.name not in ['z', 'ares', 'address_sorting', 're2', 'upb', 'grpc_abseil']:
- $(ZLIB_DEP) \
- $(CARES_DEP) \
- $(ADDRESS_SORTING_DEP) \
- $(RE2_DEP) \
- $(UPB_DEP) \
- $(GRPC_ABSEIL_DEP) \
- % endif
- % endif
- $(LIB${lib.name.upper()}_OBJS) \
- % if lib.get('baselib', False):
- $(LIBGPR_OBJS) \
- $(LIBGRPC_ABSEIL_OBJS) \
- $(ZLIB_MERGE_OBJS) \
- $(CARES_MERGE_OBJS) \
- $(ADDRESS_SORTING_MERGE_OBJS) \
- $(RE2_MERGE_OBJS) \
- $(UPB_MERGE_OBJS) \
- % if 'libssl' in lib.get('deps', []):
- $(OPENSSL_MERGE_OBJS) \
- % endif
- % endif
- $(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) \
- % if lib.get('baselib', False):
- $(LIBGPR_OBJS) \
- $(LIBGRPC_ABSEIL_OBJS) \
- $(ZLIB_MERGE_OBJS) \
- $(CARES_MERGE_OBJS) \
- $(ADDRESS_SORTING_MERGE_OBJS) \
- $(RE2_MERGE_OBJS) \
- $(UPB_MERGE_OBJS) \
- % if 'libssl' in lib.get('deps', []):
- $(OPENSSL_MERGE_OBJS) \
- % endif
- % endif
- ifeq ($(SYSTEM),Darwin)
- $(Q) ranlib -no_warning_for_no_symbols $(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] + ')'
- common = '$(LIB' + lib.name.upper() + '_OBJS)'
- link_libs = ''
- lib_deps = ' $(ZLIB_DEP) $(CARES_DEP) $(ADDRESS_SORTING_DEP) $(RE2_DEP) $(UPB_DEP) $(GRPC_ABSEIL_DEP)'
- mingw_libs = ''
- mingw_lib_deps = ' $(ZLIB_DEP) $(CARES_DEP) $(ADDRESS_SORTING_DEP) $(RE2_DEP) $(UPB_DEP) $(GRPC_ABSEIL_DEP)'
- for dep in lib.get('deps', []):
- if is_absl_lib(dep): continue
- if 'libssl' == dep: continue
- lib_archive = '$(LIBDIR)/$(CONFIG)/lib' + dep + '.a'
- common = common + ' ' + lib_archive
- lib_deps = lib_deps + ' ' + lib_archive
- mingw_lib_deps = mingw_lib_deps + ' ' + lib_archive
- security = 'libssl' in lib.get('deps', [])
- if security == True:
- common = common + ' $(OPENSSL_MERGE_LIBS) $(LDLIBS_SECURE)'
- common = common + ' $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(RE2_MERGE_LIBS) $(UPB_MERGE_LIBS) $(GRPC_ABSEIL_MERGE_LIBS)'
- if security in [True, 'check']:
- for src in lib.src:
- sources_that_need_openssl.add(src)
- else:
- for src in lib.src:
- sources_that_don_t_need_openssl.add(src)
- if 'libssl' in lib.get('deps', []):
- lib_deps = lib_deps + ' $(OPENSSL_DEP)'
- mingw_lib_deps = mingw_lib_deps + ' $(OPENSSL_DEP)'
- ldflags = '$(LDFLAGS)'
- if lib.get('LDFLAGS', None):
- ldflags += ' ' + lib['LDFLAGS']
- common = common + ' $(LDLIBS)'
- %>
- % if lib.build == "all":
- ifeq ($(SYSTEM),MINGW32)
- ${out_mingbase}.$(SHARED_EXT_${lang_to_var[lib.language]}): $(LIB${lib.name.upper()}_OBJS) ${mingw_lib_deps}
- $(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]}) ${common}${mingw_libs}
- else
- ${out_libbase}.$(SHARED_EXT_${lang_to_var[lib.language]}): $(LIB${lib.name.upper()}_OBJS) ${lib_deps}
- $(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]}) ${common}${link_libs}
- 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]}) ${common}${link_libs}
- $(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('deps', []):
- ## If the lib was secure, we have to close the Makefile's if that tested
- ## the presence of OpenSSL.
- endif
- % endif
- % if 'libssl' in lib.get('deps', []):
- ifneq ($(NO_SECURE),true)
- % endif
- ifneq ($(NO_DEPS),true)
- -include $(LIB${lib.name.upper()}_OBJS:.o=.dep)
- endif
- % if 'libssl' in lib.get('deps', []):
- endif
- % endif
- # end of build recipe for library "${lib.name}"
- </%def>
- # TODO(jtattermusch): is there a way to get around this hack?
- ifneq ($(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 sorted(sources_that_need_openssl):
- % if src not in sources_that_don_t_need_openssl:
- ${src}: $(OPENSSL_DEP)
- % endif
- % endfor
- endif
- .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_csharp 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)))))
|