Makefile.template 33 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081
  1. %YAML 1.2
  2. --- |
  3. # GRPC global makefile
  4. # This currently builds C and C++ code.
  5. # This file has been automatically generated from a template file.
  6. # Please look at the templates directory instead.
  7. # This file can be regenerated from the template by running
  8. # tools/buildgen/generate_projects.sh
  9. # Copyright 2015 gRPC authors.
  10. #
  11. # Licensed under the Apache License, Version 2.0 (the "License");
  12. # you may not use this file except in compliance with the License.
  13. # You may obtain a copy of the License at
  14. #
  15. # http://www.apache.org/licenses/LICENSE-2.0
  16. #
  17. # Unless required by applicable law or agreed to in writing, software
  18. # distributed under the License is distributed on an "AS IS" BASIS,
  19. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  20. # See the License for the specific language governing permissions and
  21. # limitations under the License.
  22. <%!
  23. import re
  24. import os
  25. def is_absl_lib(target_name):
  26. return target_name.startswith("absl/");
  27. sources_that_need_openssl = set()
  28. sources_that_don_t_need_openssl = set()
  29. # warnings we'd like, but that don't exist in all compilers
  30. PREFERRED_WARNINGS=['extra-semi']
  31. CHECK_WARNINGS=PREFERRED_WARNINGS + ['no-shift-negative-value', 'no-unused-but-set-variable', 'no-maybe-uninitialized', 'no-unknown-warning-option']
  32. def warning_var(fmt, warning):
  33. return fmt % warning.replace('-', '_').replace('+', 'X').upper()
  34. def neg_warning(warning):
  35. if warning[0:3] == 'no-':
  36. return warning[3:]
  37. else:
  38. return 'no-' + warning
  39. lang_to_var = {
  40. 'c': 'CORE',
  41. 'c++': 'CPP',
  42. 'csharp': 'CSHARP'
  43. }
  44. %>
  45. <%
  46. # Makefile is only intended for internal needs (building distribution artifacts etc.)
  47. # so we can restrict the number of libraries/targets that are buildable using the Makefile.
  48. # Other targets can be built with cmake or bazel.
  49. # TODO(jtattermusch): Figure out how to avoid the need to list the dependencies explicitly.
  50. # Currently it is necessary because some dependencies are marked as "build: private" in build.yaml
  51. # (which itself is correct, as they are not "public" libraries from our perspective and cmake
  52. # needs to have them marked as such)
  53. 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']]
  54. filtered_targets = [tgt for tgt in targets if tgt.build in ['all'] and lib.language != 'c++']
  55. %>
  56. comma := ,
  57. # Basic platform detection
  58. HOST_SYSTEM = $(shell uname | cut -f 1 -d_)
  59. SYSTEM ?= $(HOST_SYSTEM)
  60. ifeq ($(SYSTEM),MSYS)
  61. SYSTEM = MINGW32
  62. endif
  63. ifeq ($(SYSTEM),MINGW64)
  64. SYSTEM = MINGW32
  65. endif
  66. # Basic machine detection
  67. HOST_MACHINE = $(shell uname -m)
  68. ifeq ($(HOST_MACHINE),x86_64)
  69. HOST_IS_X86_64 = true
  70. else
  71. HOST_IS_X86_64 = false
  72. endif
  73. MAKEFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST)))
  74. ifndef BUILDDIR
  75. BUILDDIR_ABSOLUTE = $(patsubst %/,%,$(dir $(MAKEFILE_PATH)))
  76. else
  77. BUILDDIR_ABSOLUTE = $(abspath $(BUILDDIR))
  78. endif
  79. HAS_GCC = $(shell which gcc > /dev/null 2> /dev/null && echo true || echo false)
  80. HAS_CC = $(shell which cc > /dev/null 2> /dev/null && echo true || echo false)
  81. HAS_CLANG = $(shell which clang > /dev/null 2> /dev/null && echo true || echo false)
  82. ifeq ($(HAS_CC),true)
  83. DEFAULT_CC = cc
  84. DEFAULT_CXX = c++
  85. else
  86. ifeq ($(HAS_GCC),true)
  87. DEFAULT_CC = gcc
  88. DEFAULT_CXX = g++
  89. else
  90. ifeq ($(HAS_CLANG),true)
  91. DEFAULT_CC = clang
  92. DEFAULT_CXX = clang++
  93. else
  94. DEFAULT_CC = no_c_compiler
  95. DEFAULT_CXX = no_c++_compiler
  96. endif
  97. endif
  98. endif
  99. BINDIR = $(BUILDDIR_ABSOLUTE)/bins
  100. OBJDIR = $(BUILDDIR_ABSOLUTE)/objs
  101. LIBDIR = $(BUILDDIR_ABSOLUTE)/libs
  102. GENDIR = $(BUILDDIR_ABSOLUTE)/gens
  103. # Configurations (as defined under "configs" section in build_handwritten.yaml)
  104. % for name, args in configs.items():
  105. VALID_CONFIG_${name} = 1
  106. % if args.get('compile_the_world', False):
  107. REQUIRE_CUSTOM_LIBRARIES_${name} = 1
  108. % endif
  109. % for tool, default in [('CC', 'CC'), ('CXX', 'CXX'), ('LD', 'CC'), ('LDXX', 'CXX')]:
  110. ${tool}_${name} = ${args.get(tool, '$(DEFAULT_%s)' % default)}
  111. % endfor
  112. % for arg in ['CFLAGS', 'CXXFLAGS', 'CPPFLAGS', 'LDFLAGS', 'DEFINES']:
  113. % if args.get(arg, None) is not None:
  114. ${arg}_${name} = ${args.get(arg)}
  115. % endif
  116. % endfor
  117. % endfor
  118. # General settings.
  119. # You may want to change these depending on your system.
  120. prefix ?= /usr/local
  121. DTRACE ?= dtrace
  122. CONFIG ?= opt
  123. # Doing X ?= Y is the same as:
  124. # ifeq ($(origin X), undefined)
  125. # X = Y
  126. # endif
  127. # but some variables, such as CC, CXX, LD or AR, have defaults.
  128. # So instead of using ?= on them, we need to check their origin.
  129. # See:
  130. # https://www.gnu.org/software/make/manual/html_node/Implicit-Variables.html
  131. # https://www.gnu.org/software/make/manual/html_node/Flavors.html#index-_003f_003d
  132. # https://www.gnu.org/software/make/manual/html_node/Origin-Function.html
  133. ifeq ($(origin CC), default)
  134. CC = $(CC_$(CONFIG))
  135. endif
  136. ifeq ($(origin CXX), default)
  137. CXX = $(CXX_$(CONFIG))
  138. endif
  139. ifeq ($(origin LD), default)
  140. LD = $(LD_$(CONFIG))
  141. endif
  142. LDXX ?= $(LDXX_$(CONFIG))
  143. ARFLAGS ?= rcs
  144. ifeq ($(SYSTEM),Linux)
  145. ifeq ($(origin AR), default)
  146. AR = ar
  147. endif
  148. STRIP ?= strip --strip-unneeded
  149. else
  150. ifeq ($(SYSTEM),Darwin)
  151. ifeq ($(origin AR), default)
  152. AR = libtool
  153. ARFLAGS = -no_warning_for_no_symbols -o
  154. endif
  155. STRIP ?= strip -x
  156. else
  157. ifeq ($(SYSTEM),MINGW32)
  158. ifeq ($(origin AR), default)
  159. AR = ar
  160. endif
  161. STRIP ?= strip --strip-unneeded
  162. else
  163. ifeq ($(origin AR), default)
  164. AR = ar
  165. endif
  166. STRIP ?= strip
  167. endif
  168. endif
  169. endif
  170. INSTALL ?= install
  171. RM ?= rm -f
  172. PKG_CONFIG ?= pkg-config
  173. ifndef VALID_CONFIG_$(CONFIG)
  174. $(error Invalid CONFIG value '$(CONFIG)')
  175. endif
  176. ifeq ($(SYSTEM),Linux)
  177. TMPOUT = /dev/null
  178. else
  179. TMPOUT = `mktemp /tmp/test-out-XXXXXX`
  180. endif
  181. 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
  182. HAS_WORKING_NO_CXX14_COMPAT = $(shell $(CHECK_NO_CXX14_COMPAT_WORKS_CMD) 2> /dev/null && echo true || echo false)
  183. ifeq ($(HAS_WORKING_NO_CXX14_COMPAT),true)
  184. W_NO_CXX14_COMPAT=-Wno-c++14-compat
  185. endif
  186. %for warning in CHECK_WARNINGS:
  187. ${warning_var('CHECK_%s_WORKS_CMD', warning)} = $(CC) -std=c99 -Werror -W${warning} -o $(TMPOUT) -c test/build/${warning}.c
  188. ${warning_var('HAS_WORKING_%s', warning)} = $(shell $(${warning_var('CHECK_%s_WORKS_CMD', warning)}) 2> /dev/null && echo true || echo false)
  189. ifeq ($(${warning_var('HAS_WORKING_%s', warning)}),true)
  190. ${warning_var('W_%s', warning)}=-W${warning}
  191. ${warning_var('NO_W_%s', warning)}=-W${neg_warning(warning)}
  192. endif
  193. %endfor
  194. # The HOST compiler settings are used to compile the protoc plugins.
  195. # In most cases, you won't have to change anything, but if you are
  196. # cross-compiling, you can override these variables from GNU make's
  197. # command line: make CC=cross-gcc HOST_CC=gcc
  198. HOST_CC ?= $(CC)
  199. HOST_CXX ?= $(CXX)
  200. HOST_LD ?= $(LD)
  201. HOST_LDXX ?= $(LDXX)
  202. CFLAGS += -std=c99 ${' '.join(warning_var('$(W_%s)', warning) for warning in PREFERRED_WARNINGS)}
  203. CXXFLAGS += -std=c++11
  204. ifeq ($(SYSTEM),Darwin)
  205. CXXFLAGS += -stdlib=libc++
  206. LDFLAGS += -framework CoreFoundation
  207. endif
  208. % for arg in ['CFLAGS', 'CXXFLAGS', 'CPPFLAGS', 'COREFLAGS', 'LDFLAGS', 'DEFINES']:
  209. % if defaults.get('global', []).get(arg, None) is not None:
  210. ${arg} += ${defaults.get('global').get(arg)}
  211. % endif
  212. % endfor
  213. CPPFLAGS += $(CPPFLAGS_$(CONFIG))
  214. CFLAGS += $(CFLAGS_$(CONFIG))
  215. CXXFLAGS += $(CXXFLAGS_$(CONFIG))
  216. DEFINES += $(DEFINES_$(CONFIG)) INSTALL_PREFIX=\"$(prefix)\"
  217. LDFLAGS += $(LDFLAGS_$(CONFIG))
  218. ifneq ($(SYSTEM),MINGW32)
  219. PIC_CPPFLAGS = -fPIC
  220. CPPFLAGS += -fPIC
  221. LDFLAGS += -fPIC
  222. endif
  223. INCLUDES = . include $(GENDIR)
  224. LDFLAGS += -Llibs/$(CONFIG)
  225. ifeq ($(SYSTEM),Darwin)
  226. ifneq ($(wildcard /usr/local/ssl/include),)
  227. INCLUDES += /usr/local/ssl/include
  228. endif
  229. ifneq ($(wildcard /opt/local/include),)
  230. INCLUDES += /opt/local/include
  231. endif
  232. ifneq ($(wildcard /usr/local/include),)
  233. INCLUDES += /usr/local/include
  234. endif
  235. LIBS = m z
  236. ifneq ($(wildcard /usr/local/ssl/lib),)
  237. LDFLAGS += -L/usr/local/ssl/lib
  238. endif
  239. ifneq ($(wildcard /opt/local/lib),)
  240. LDFLAGS += -L/opt/local/lib
  241. endif
  242. ifneq ($(wildcard /usr/local/lib),)
  243. LDFLAGS += -L/usr/local/lib
  244. endif
  245. endif
  246. ifeq ($(SYSTEM),Linux)
  247. LIBS = dl rt m pthread
  248. LDFLAGS += -pthread
  249. endif
  250. ifeq ($(SYSTEM),MINGW32)
  251. LIBS = m pthread ws2_32 dbghelp
  252. LDFLAGS += -pthread
  253. endif
  254. #
  255. # The steps for cross-compiling are as follows:
  256. # First, clone and make install of grpc using the native compilers for the host.
  257. # Also, install protoc (e.g., from a package like apt-get)
  258. # Then clone a fresh grpc for the actual cross-compiled build
  259. # Set the environment variable GRPC_CROSS_COMPILE to true
  260. # Set CC, CXX, LD, LDXX, AR, and STRIP to the cross-compiling binaries
  261. # Also set PROTOBUF_CONFIG_OPTS to indicate cross-compilation to protobuf (e.g.,
  262. # PROTOBUF_CONFIG_OPTS="--host=arm-linux --with-protoc=/usr/local/bin/protoc" )
  263. # Set HAS_PKG_CONFIG=false
  264. # To build tests, go to third_party/gflags and follow its ccmake instructions
  265. # Make sure that you enable building shared libraries and set your prefix to
  266. # something useful like /usr/local/cross
  267. # You will also need to set GRPC_CROSS_LDOPTS and GRPC_CROSS_AROPTS to hold
  268. # additional required arguments for LD and AR (examples below)
  269. # Then you can do a make from the cross-compiling fresh clone!
  270. #
  271. ifeq ($(GRPC_CROSS_COMPILE),true)
  272. LDFLAGS += $(GRPC_CROSS_LDOPTS) # e.g. -L/usr/local/lib -L/usr/local/cross/lib
  273. ARFLAGS += $(GRPC_CROSS_AROPTS) # e.g., rc --target=elf32-little
  274. USE_BUILT_PROTOC = false
  275. endif
  276. # V=1 can be used to print commands run by make
  277. ifeq ($(V),1)
  278. E = @:
  279. Q =
  280. else
  281. E = @echo
  282. Q = @
  283. endif
  284. CORE_VERSION = ${settings.core_version}
  285. CPP_VERSION = ${settings.cpp_version}
  286. CSHARP_VERSION = ${settings.csharp_version}
  287. CPPFLAGS_NO_ARCH += $(addprefix -I, $(INCLUDES)) $(addprefix -D, $(DEFINES))
  288. CPPFLAGS += $(CPPFLAGS_NO_ARCH) $(ARCH_FLAGS)
  289. LDFLAGS += $(ARCH_FLAGS)
  290. LDLIBS += $(addprefix -l, $(LIBS))
  291. LDLIBSXX += $(addprefix -l, $(LIBSXX))
  292. % for arg in ['CFLAGS', 'CXXFLAGS', 'CPPFLAGS', 'LDFLAGS', 'DEFINES', 'LDLIBS']:
  293. ${arg} += $(EXTRA_${arg})
  294. % endfor
  295. HOST_CPPFLAGS += $(CPPFLAGS)
  296. HOST_CFLAGS += $(CFLAGS)
  297. HOST_CXXFLAGS += $(CXXFLAGS)
  298. HOST_LDFLAGS += $(LDFLAGS)
  299. HOST_LDLIBS += $(LDLIBS)
  300. # These are automatically computed variables.
  301. # There shouldn't be any need to change anything from now on.
  302. -include cache.mk
  303. CACHE_MK =
  304. ifeq ($(SYSTEM),MINGW32)
  305. EXECUTABLE_SUFFIX = .exe
  306. SHARED_EXT_CORE = dll
  307. SHARED_EXT_CPP = dll
  308. SHARED_EXT_CSHARP = dll
  309. SHARED_PREFIX =
  310. SHARED_VERSION_CORE = -${settings.core_version.major}
  311. SHARED_VERSION_CPP = -${settings.cpp_version.major}
  312. SHARED_VERSION_CSHARP = -${settings.csharp_version.major}
  313. else ifeq ($(SYSTEM),Darwin)
  314. EXECUTABLE_SUFFIX =
  315. SHARED_EXT_CORE = dylib
  316. SHARED_EXT_CPP = dylib
  317. SHARED_EXT_CSHARP = dylib
  318. SHARED_PREFIX = lib
  319. SHARED_VERSION_CORE =
  320. SHARED_VERSION_CPP =
  321. SHARED_VERSION_CSHARP =
  322. else
  323. EXECUTABLE_SUFFIX =
  324. SHARED_EXT_CORE = so.$(CORE_VERSION)
  325. SHARED_EXT_CPP = so.$(CPP_VERSION)
  326. SHARED_EXT_CSHARP = so.$(CSHARP_VERSION)
  327. SHARED_PREFIX = lib
  328. SHARED_VERSION_CORE =
  329. SHARED_VERSION_CPP =
  330. SHARED_VERSION_CSHARP =
  331. endif
  332. ifeq ($(wildcard .git),)
  333. IS_GIT_FOLDER = false
  334. else
  335. IS_GIT_FOLDER = true
  336. endif
  337. # Setup zlib dependency
  338. ifeq ($(wildcard third_party/zlib/zlib.h),)
  339. HAS_EMBEDDED_ZLIB = false
  340. else
  341. HAS_EMBEDDED_ZLIB = true
  342. endif
  343. # for zlib, we support building both from submodule
  344. # and from system-installed zlib. In some builds,
  345. # embedding zlib is not desirable.
  346. # By default we use the system zlib (to match legacy behavior)
  347. EMBED_ZLIB ?= false
  348. ifeq ($(EMBED_ZLIB),true)
  349. ZLIB_DEP = $(LIBDIR)/$(CONFIG)/libz.a
  350. ZLIB_MERGE_LIBS = $(LIBDIR)/$(CONFIG)/libz.a
  351. ZLIB_MERGE_OBJS = $(LIBZ_OBJS)
  352. CPPFLAGS += -Ithird_party/zlib
  353. else
  354. LIBS += z
  355. endif
  356. # Setup c-ares dependency
  357. ifeq ($(wildcard third_party/cares/cares/ares.h),)
  358. HAS_EMBEDDED_CARES = false
  359. else
  360. HAS_EMBEDDED_CARES = true
  361. endif
  362. ifeq ($(HAS_EMBEDDED_CARES),true)
  363. EMBED_CARES ?= true
  364. else
  365. # only building with c-ares from submodule is supported
  366. DEP_MISSING += cares
  367. EMBED_CARES ?= broken
  368. endif
  369. ifeq ($(EMBED_CARES),true)
  370. CARES_DEP = $(LIBDIR)/$(CONFIG)/libares.a
  371. CARES_MERGE_OBJS = $(LIBARES_OBJS)
  372. CARES_MERGE_LIBS = $(LIBDIR)/$(CONFIG)/libares.a
  373. CPPFLAGS := -Ithird_party/cares -Ithird_party/cares/cares $(CPPFLAGS)
  374. endif
  375. # Setup address_sorting dependency
  376. ADDRESS_SORTING_DEP = $(LIBDIR)/$(CONFIG)/libaddress_sorting.a
  377. ADDRESS_SORTING_MERGE_OBJS = $(LIBADDRESS_SORTING_OBJS)
  378. ADDRESS_SORTING_MERGE_LIBS = $(LIBDIR)/$(CONFIG)/libaddress_sorting.a
  379. CPPFLAGS := -Ithird_party/address_sorting/include $(CPPFLAGS)
  380. # Setup abseil dependency
  381. GRPC_ABSEIL_DEP = $(LIBDIR)/$(CONFIG)/libgrpc_abseil.a
  382. GRPC_ABSEIL_MERGE_LIBS = $(LIBDIR)/$(CONFIG)/libgrpc_abseil.a
  383. ifeq ($(HOST_IS_X86_64),true)
  384. ABSL_RANDOM_HWAES_FLAGS = -maes -msse4
  385. else
  386. ABSL_RANDOM_HWAES_FLAGS =
  387. endif
  388. # Setup re2 dependency
  389. RE2_DEP = $(LIBDIR)/$(CONFIG)/libre2.a
  390. RE2_MERGE_OBJS = $(LIBRE2_OBJS)
  391. RE2_MERGE_LIBS = $(LIBDIR)/$(CONFIG)/libre2.a
  392. # Setup upb dependency
  393. UPB_DEP = $(LIBDIR)/$(CONFIG)/libupb.a
  394. UPB_MERGE_OBJS = $(LIBUPB_OBJS)
  395. UPB_MERGE_LIBS = $(LIBDIR)/$(CONFIG)/libupb.a
  396. # Setup boringssl dependency
  397. ifeq ($(wildcard third_party/boringssl-with-bazel/src/include/openssl/ssl.h),)
  398. HAS_EMBEDDED_OPENSSL = false
  399. else
  400. HAS_EMBEDDED_OPENSSL = true
  401. endif
  402. ifeq ($(HAS_EMBEDDED_OPENSSL),true)
  403. EMBED_OPENSSL ?= true
  404. else
  405. # only support building boringssl from submodule
  406. DEP_MISSING += openssl
  407. EMBED_OPENSSL ?= broken
  408. endif
  409. ifeq ($(EMBED_OPENSSL),true)
  410. OPENSSL_DEP += $(LIBDIR)/$(CONFIG)/libboringssl.a
  411. OPENSSL_MERGE_LIBS += $(LIBDIR)/$(CONFIG)/libboringssl.a
  412. OPENSSL_MERGE_OBJS += $(LIBBORINGSSL_OBJS)
  413. # need to prefix these to ensure overriding system libraries
  414. CPPFLAGS := -Ithird_party/boringssl-with-bazel/src/include $(CPPFLAGS)
  415. ifeq ($(DISABLE_ALPN),true)
  416. CPPFLAGS += -DTSI_OPENSSL_ALPN_SUPPORT=0
  417. LIBS_SECURE = $(OPENSSL_LIBS)
  418. endif # DISABLE_ALPN
  419. endif # EMBED_OPENSSL
  420. LDLIBS_SECURE += $(addprefix -l, $(LIBS_SECURE))
  421. ifeq ($(MAKECMDGOALS),clean)
  422. NO_DEPS = true
  423. endif
  424. .SECONDARY = %.pb.h %.pb.cc
  425. ifeq ($(DEP_MISSING),)
  426. all: static shared\
  427. % for tgt in filtered_targets:
  428. % if tgt.build == 'all':
  429. $(BINDIR)/$(CONFIG)/${tgt.name}\
  430. % endif
  431. % endfor
  432. dep_error:
  433. @echo "You shouldn't see this message - all of your dependencies are correct."
  434. else
  435. all: dep_error git_update stop
  436. dep_error:
  437. @echo
  438. @echo "DEPENDENCY ERROR"
  439. @echo
  440. @echo "You are missing system dependencies that are essential to build grpc,"
  441. @echo "and the third_party directory doesn't have them:"
  442. @echo
  443. @echo " $(DEP_MISSING)"
  444. @echo
  445. @echo "Installing the development packages for your system will solve"
  446. @echo "this issue. Please consult INSTALL to get more information."
  447. @echo
  448. @echo "If you need information about why these tests failed, run:"
  449. @echo
  450. @echo " make run_dep_checks"
  451. @echo
  452. endif
  453. git_update:
  454. ifeq ($(IS_GIT_FOLDER),true)
  455. @echo "Additionally, since you are in a git clone, you can download the"
  456. @echo "missing dependencies in third_party by running the following command:"
  457. @echo
  458. @echo " git submodule update --init"
  459. @echo
  460. endif
  461. openssl_dep_error: openssl_dep_message git_update stop
  462. openssl_dep_message:
  463. @echo
  464. @echo "DEPENDENCY ERROR"
  465. @echo
  466. @echo "The target you are trying to run requires an OpenSSL implementation."
  467. @echo "Your system doesn't have one, and either the third_party directory"
  468. @echo "doesn't have it, or your compiler can't build BoringSSL."
  469. @echo
  470. @echo "Please consult BUILDING.md to get more information."
  471. @echo
  472. @echo "If you need information about why these tests failed, run:"
  473. @echo
  474. @echo " make run_dep_checks"
  475. @echo
  476. systemtap_dep_error:
  477. @echo
  478. @echo "DEPENDENCY ERROR"
  479. @echo
  480. @echo "Under the '$(CONFIG)' configutation, the target you are trying "
  481. @echo "to build requires systemtap 2.7+ (on Linux) or dtrace (on other "
  482. @echo "platforms such as Solaris and *BSD). "
  483. @echo
  484. @echo "Please consult BUILDING.md to get more information."
  485. @echo
  486. install_not_supported_message:
  487. @echo
  488. @echo "Installing via 'make' is no longer supported. Use cmake or bazel instead."
  489. @echo
  490. @echo "Please consult BUILDING.md to get more information."
  491. @echo
  492. install_not_supported_error: install_not_supported_message stop
  493. stop:
  494. @false
  495. % for tgt in filtered_targets:
  496. ${tgt.name}: $(BINDIR)/$(CONFIG)/${tgt.name}
  497. % endfor
  498. run_dep_checks:
  499. @echo "run_dep_checks target has been deprecated."
  500. static: static_c static_cxx
  501. static_c: cache.mk \
  502. % for lib in filtered_libs:
  503. % if 'Makefile' in lib.get('build_system', ['Makefile']):
  504. % if lib.build == 'all' and lib.language == 'c' and not lib.get('external_deps', None):
  505. $(LIBDIR)/$(CONFIG)/lib${lib.name}.a\
  506. % endif
  507. % endif
  508. % endfor
  509. static_cxx: cache.mk \
  510. % for lib in filtered_libs:
  511. % if 'Makefile' in lib.get('build_system', ['Makefile']):
  512. % if lib.build == 'all' and lib.language == 'c++':
  513. $(LIBDIR)/$(CONFIG)/lib${lib.name}.a\
  514. % endif
  515. % endif
  516. % endfor
  517. static_csharp: static_c \
  518. % for lib in filtered_libs:
  519. % if 'Makefile' in lib.get('build_system', ['Makefile']):
  520. % if lib.build == 'all' and lib.language == 'csharp':
  521. $(LIBDIR)/$(CONFIG)/lib${lib.name}.a\
  522. % endif
  523. % endif
  524. % endfor
  525. shared: shared_c shared_cxx
  526. shared_c: cache.mk\
  527. % for lib in filtered_libs:
  528. % if 'Makefile' in lib.get('build_system', ['Makefile']):
  529. % if lib.build == 'all' and lib.language == 'c' and not lib.get('external_deps', None):
  530. $(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)${lib.name}$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE)\
  531. % endif
  532. % endif
  533. % endfor
  534. shared_cxx: cache.mk\
  535. % for lib in filtered_libs:
  536. % if 'Makefile' in lib.get('build_system', ['Makefile']):
  537. % if lib.build == 'all' and lib.language == 'c++':
  538. $(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)${lib.name}$(SHARED_VERSION_CPP).$(SHARED_EXT_CPP)\
  539. % endif
  540. % endif
  541. % endfor
  542. shared_csharp: shared_c \
  543. % for lib in filtered_libs:
  544. % if 'Makefile' in lib.get('build_system', ['Makefile']):
  545. % if lib.build == 'all' and lib.language == 'csharp':
  546. $(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)${lib.name}$(SHARED_VERSION_CSHARP).$(SHARED_EXT_CSHARP)\
  547. % endif
  548. % endif
  549. % endfor
  550. grpc_csharp_ext: shared_csharp
  551. privatelibs: privatelibs_c privatelibs_cxx
  552. privatelibs_c: \
  553. % for lib in filtered_libs:
  554. % if 'Makefile' in lib.get('build_system', ['Makefile']):
  555. % if lib.build == 'private' and lib.language == 'c' and not lib.get('external_deps', None) and not lib.boringssl:
  556. $(LIBDIR)/$(CONFIG)/lib${lib.name}.a\
  557. % endif
  558. % endif
  559. % endfor
  560. ifeq ($(EMBED_OPENSSL),true)
  561. privatelibs_cxx: \
  562. % for lib in filtered_libs:
  563. % if 'Makefile' in lib.get('build_system', ['Makefile']):
  564. % if lib.build == 'private' and lib.language == 'c++' and not lib.get('external_deps', None):
  565. $(LIBDIR)/$(CONFIG)/lib${lib.name}.a\
  566. % endif
  567. % endif
  568. % endfor
  569. else
  570. privatelibs_cxx: \
  571. % for lib in filtered_libs:
  572. % if 'Makefile' in lib.get('build_system', ['Makefile']):
  573. % if lib.build == 'private' and lib.language == 'c++' and not lib.get('external_deps', None) and not lib.boringssl:
  574. $(LIBDIR)/$(CONFIG)/lib${lib.name}.a\
  575. % endif
  576. % endif
  577. % endfor
  578. endif
  579. strip: strip-static strip-shared
  580. strip-static: strip-static_c strip-static_cxx
  581. strip-shared: strip-shared_c strip-shared_cxx
  582. strip-static_c: static_c
  583. ifeq ($(CONFIG),opt)
  584. % for lib in filtered_libs:
  585. % if 'Makefile' in lib.get('build_system', ['Makefile']):
  586. % if lib.language == "c":
  587. % if lib.build == "all":
  588. % if not lib.get('external_deps', None):
  589. $(E) "[STRIP] Stripping lib${lib.name}.a"
  590. $(Q) $(STRIP) $(LIBDIR)/$(CONFIG)/lib${lib.name}.a
  591. % endif
  592. % endif
  593. % endif
  594. % endif
  595. % endfor
  596. endif
  597. strip-static_cxx: static_cxx
  598. ifeq ($(CONFIG),opt)
  599. % for lib in filtered_libs:
  600. % if 'Makefile' in lib.get('build_system', ['Makefile']):
  601. % if lib.language == "c++":
  602. % if lib.build == "all":
  603. $(E) "[STRIP] Stripping lib${lib.name}.a"
  604. $(Q) $(STRIP) $(LIBDIR)/$(CONFIG)/lib${lib.name}.a
  605. % endif
  606. % endif
  607. % endif
  608. % endfor
  609. endif
  610. strip-shared_c: shared_c
  611. ifeq ($(CONFIG),opt)
  612. % for lib in filtered_libs:
  613. % if 'Makefile' in lib.get('build_system', ['Makefile']):
  614. % if lib.language == "c":
  615. % if lib.build == "all":
  616. % if not lib.get('external_deps', None):
  617. $(E) "[STRIP] Stripping $(SHARED_PREFIX)${lib.name}$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE)"
  618. $(Q) $(STRIP) $(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)${lib.name}$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE)
  619. % endif
  620. % endif
  621. % endif
  622. % endif
  623. % endfor
  624. endif
  625. strip-shared_cxx: shared_cxx
  626. ifeq ($(CONFIG),opt)
  627. % for lib in filtered_libs:
  628. % if 'Makefile' in lib.get('build_system', ['Makefile']):
  629. % if lib.language == "c++":
  630. % if lib.build == "all":
  631. $(E) "[STRIP] Stripping $(SHARED_PREFIX)${lib.name}$(SHARED_VERSION_CPP).$(SHARED_EXT_CPP)"
  632. $(Q) $(STRIP) $(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)${lib.name}$(SHARED_VERSION_CPP).$(SHARED_EXT_CPP)
  633. % endif
  634. % endif
  635. % endif
  636. % endfor
  637. endif
  638. strip-shared_csharp: shared_csharp
  639. ifeq ($(CONFIG),opt)
  640. % for lib in filtered_libs:
  641. % if 'Makefile' in lib.get('build_system', ['Makefile']):
  642. % if lib.language == "csharp":
  643. % if lib.build == "all":
  644. $(E) "[STRIP] Stripping $(SHARED_PREFIX)${lib.name}$(SHARED_VERSION_CSHARP).$(SHARED_EXT_CSHARP)"
  645. $(Q) $(STRIP) $(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)${lib.name}$(SHARED_VERSION_CSHARP).$(SHARED_EXT_CSHARP)
  646. % endif
  647. % endif
  648. % endif
  649. % endfor
  650. endif
  651. cache.mk::
  652. $(E) "[MAKE] Generating $@"
  653. $(Q) echo "$(CACHE_MK)" | tr , '\n' >$@
  654. ifeq ($(CONFIG),stapprof)
  655. src/core/profiling/stap_timers.c: $(GENDIR)/src/core/profiling/stap_probes.h
  656. ifeq ($(HAS_SYSTEMTAP),true)
  657. $(GENDIR)/src/core/profiling/stap_probes.h: src/core/profiling/stap_probes.d
  658. $(E) "[DTRACE] Compiling $<"
  659. $(Q) mkdir -p `dirname $@`
  660. $(Q) $(DTRACE) -C -h -s $< -o $@
  661. else
  662. $(GENDIR)/src/core/profiling/stap_probes.h: systemtap_dep_error stop
  663. endif
  664. endif
  665. $(OBJDIR)/$(CONFIG)/%.o : %.c
  666. $(E) "[C] Compiling $<"
  667. $(Q) mkdir -p `dirname $@`
  668. $(Q) $(CC) $(CPPFLAGS) $(CFLAGS) -MMD -MF $(addsuffix .dep, $(basename $@)) -c -o $@ $<
  669. $(OBJDIR)/$(CONFIG)/%.o : $(GENDIR)/%.pb.cc
  670. $(E) "[CXX] Compiling $<"
  671. $(Q) mkdir -p `dirname $@`
  672. $(Q) $(CXX) $(CPPFLAGS) $(CXXFLAGS) -MMD -MF $(addsuffix .dep, $(basename $@)) -c -o $@ $<
  673. $(OBJDIR)/$(CONFIG)/src/compiler/%.o : src/compiler/%.cc
  674. $(E) "[HOSTCXX] Compiling $<"
  675. $(Q) mkdir -p `dirname $@`
  676. $(Q) $(HOST_CXX) $(HOST_CXXFLAGS) $(HOST_CPPFLAGS) -MMD -MF $(addsuffix .dep, $(basename $@)) -c -o $@ $<
  677. $(OBJDIR)/$(CONFIG)/src/core/%.o : src/core/%.cc
  678. $(E) "[CXX] Compiling $<"
  679. $(Q) mkdir -p `dirname $@`
  680. $(Q) $(CXX) $(CPPFLAGS) $(CXXFLAGS) $(COREFLAGS) -MMD -MF $(addsuffix .dep, $(basename $@)) -c -o $@ $<
  681. $(OBJDIR)/$(CONFIG)/test/core/%.o : test/core/%.cc
  682. $(E) "[CXX] Compiling $<"
  683. $(Q) mkdir -p `dirname $@`
  684. $(Q) $(CXX) $(CPPFLAGS) $(CXXFLAGS) $(COREFLAGS) -MMD -MF $(addsuffix .dep, $(basename $@)) -c -o $@ $<
  685. $(OBJDIR)/$(CONFIG)/%.o : %.cc
  686. $(E) "[CXX] Compiling $<"
  687. $(Q) mkdir -p `dirname $@`
  688. $(Q) $(CXX) $(CPPFLAGS) $(CXXFLAGS) -MMD -MF $(addsuffix .dep, $(basename $@)) -c -o $@ $<
  689. $(OBJDIR)/$(CONFIG)/%.o : %.cpp
  690. $(E) "[CXX] Compiling $<"
  691. $(Q) mkdir -p `dirname $@`
  692. $(Q) $(CXX) $(CPPFLAGS) $(CXXFLAGS) -MMD -MF $(addsuffix .dep, $(basename $@)) -c -o $@ $<
  693. install: install_not_supported_error
  694. install_c: install_not_supported_error
  695. install_cxx: install_not_supported_error
  696. install_csharp: install_not_supported_error
  697. install-static: install_not_supported_error
  698. install-certs: install_not_supported_error
  699. clean:
  700. $(E) "[CLEAN] Cleaning build directories."
  701. $(Q) $(RM) -rf $(OBJDIR) $(LIBDIR) $(BINDIR) $(GENDIR) cache.mk
  702. # The various libraries
  703. % for lib in filtered_libs:
  704. % if 'Makefile' in lib.get('build_system', ['Makefile']):
  705. ${makelib(lib)}
  706. % endif
  707. % endfor
  708. # Add private ABSEIL target which contains all sources used by all baselib libraries.
  709. <%
  710. # Collect all abseil source and header files used by gpr, grpc, so on.
  711. used_abseil_rules = set()
  712. for lib in libs:
  713. if lib.get("baselib"):
  714. for dep in lib.transitive_deps:
  715. if is_absl_lib(dep):
  716. used_abseil_rules.add(dep)
  717. used_abseil_srcs = []
  718. used_abseil_hdrs = []
  719. for lib in libs:
  720. if lib.name in used_abseil_rules:
  721. used_abseil_srcs.extend(lib.get("src", []))
  722. used_abseil_hdrs.extend(lib.get("hdr", []))
  723. # Create `grpc_abseil` rule with collected files.
  724. lib_type = type(libs[0])
  725. grpc_abseil_lib = lib_type({
  726. "name": "grpc_abseil",
  727. "build": "private",
  728. "language": "c",
  729. "defaults": "abseil",
  730. "src": sorted(used_abseil_srcs),
  731. "hdr": sorted(used_abseil_hdrs),
  732. "secure": False,
  733. })
  734. %>
  735. ${makelib(grpc_abseil_lib)}
  736. <%def name="makelib(lib)">
  737. # start of build recipe for library "${lib.name}" (generated by makelib(lib) template function)
  738. LIB${lib.name.upper()}_SRC = \\
  739. % for src in lib.src:
  740. ${src} \\
  741. % endfor
  742. % if "public_headers" in lib:
  743. % if lib.language == "c++":
  744. PUBLIC_HEADERS_CXX += \\
  745. % else:
  746. PUBLIC_HEADERS_C += \\
  747. % endif
  748. % for hdr in lib.public_headers:
  749. ${hdr} \\
  750. % endfor
  751. % endif
  752. LIB${lib.name.upper()}_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(LIB${lib.name.upper()}_SRC))))
  753. % if lib.get('defaults', None):
  754. % for name, value in defaults.get(lib.defaults).items():
  755. $(LIB${lib.name.upper()}_OBJS): ${name} += ${value}
  756. % endfor
  757. % endif
  758. ## If the library requires OpenSSL, let's add some restrictions.
  759. % if lib.get('secure', 'check') == True or lib.get('secure', 'check') == 'check':
  760. ifeq ($(NO_SECURE),true)
  761. # You can't build secure libraries if you don't have OpenSSL.
  762. $(LIBDIR)/$(CONFIG)/lib${lib.name}.a: openssl_dep_error
  763. % if lib.build == "all":
  764. $(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)${lib.name}$(SHARED_VERSION_${lang_to_var[lib.language]}).$(SHARED_EXT_${lang_to_var[lib.language]}): openssl_dep_error
  765. % endif
  766. else
  767. $(LIBDIR)/$(CONFIG)/lib${lib.name}.a: $(ZLIB_DEP) $(OPENSSL_DEP) $(CARES_DEP) $(ADDRESS_SORTING_DEP) $(RE2_DEP) $(UPB_DEP) $(GRPC_ABSEIL_DEP) \
  768. ## The else here corresponds to the if secure earlier.
  769. % else:
  770. $(LIBDIR)/$(CONFIG)/lib${lib.name}.a: \
  771. % if lib.name not in ['z', 'ares', 'address_sorting', 're2', 'upb', 'grpc_abseil']:
  772. $(ZLIB_DEP) \
  773. $(CARES_DEP) \
  774. $(ADDRESS_SORTING_DEP) \
  775. $(RE2_DEP) \
  776. $(UPB_DEP) \
  777. $(GRPC_ABSEIL_DEP) \
  778. % endif
  779. % endif
  780. $(LIB${lib.name.upper()}_OBJS) \
  781. % if lib.get('baselib', False):
  782. $(LIBGPR_OBJS) \
  783. $(LIBGRPC_ABSEIL_OBJS) \
  784. $(ZLIB_MERGE_OBJS) \
  785. $(CARES_MERGE_OBJS) \
  786. $(ADDRESS_SORTING_MERGE_OBJS) \
  787. $(RE2_MERGE_OBJS) \
  788. $(UPB_MERGE_OBJS) \
  789. % if lib.get('secure', 'check') == True:
  790. $(OPENSSL_MERGE_OBJS) \
  791. % endif
  792. % endif
  793. $(E) "[AR] Creating $@"
  794. $(Q) mkdir -p `dirname $@`
  795. $(Q) rm -f $(LIBDIR)/$(CONFIG)/lib${lib.name}.a
  796. $(Q) $(AR) $(ARFLAGS) $(LIBDIR)/$(CONFIG)/lib${lib.name}.a $(LIB${lib.name.upper()}_OBJS) \
  797. % if lib.get('baselib', False):
  798. $(LIBGPR_OBJS) \
  799. $(LIBGRPC_ABSEIL_OBJS) \
  800. $(ZLIB_MERGE_OBJS) \
  801. $(CARES_MERGE_OBJS) \
  802. $(ADDRESS_SORTING_MERGE_OBJS) \
  803. $(RE2_MERGE_OBJS) \
  804. $(UPB_MERGE_OBJS) \
  805. % if lib.get('secure', 'check') == True:
  806. $(OPENSSL_MERGE_OBJS) \
  807. % endif
  808. % endif
  809. ifeq ($(SYSTEM),Darwin)
  810. $(Q) ranlib -no_warning_for_no_symbols $(LIBDIR)/$(CONFIG)/lib${lib.name}.a
  811. endif
  812. <%
  813. ld = '$(LDXX)'
  814. out_mingbase = '$(LIBDIR)/$(CONFIG)/' + lib.name + '$(SHARED_VERSION_' + lang_to_var[lib.language] + ')'
  815. out_libbase = '$(LIBDIR)/$(CONFIG)/lib' + lib.name + '$(SHARED_VERSION_' + lang_to_var[lib.language] + ')'
  816. common = '$(LIB' + lib.name.upper() + '_OBJS)'
  817. link_libs = ''
  818. lib_deps = ' $(ZLIB_DEP) $(CARES_DEP) $(ADDRESS_SORTING_DEP) $(RE2_DEP) $(UPB_DEP) $(GRPC_ABSEIL_DEP)'
  819. mingw_libs = ''
  820. mingw_lib_deps = ' $(ZLIB_DEP) $(CARES_DEP) $(ADDRESS_SORTING_DEP) $(RE2_DEP) $(UPB_DEP) $(GRPC_ABSEIL_DEP)'
  821. if lib.get('deps_linkage', None) == 'static':
  822. for dep in lib.get('deps', []):
  823. if is_absl_lib(dep): continue
  824. lib_archive = '$(LIBDIR)/$(CONFIG)/lib' + dep + '.a'
  825. common = common + ' ' + lib_archive
  826. lib_deps = lib_deps + ' ' + lib_archive
  827. mingw_lib_deps = mingw_lib_deps + ' ' + lib_archive
  828. else:
  829. for dep in lib.get('deps', []):
  830. if is_absl_lib(dep): continue
  831. dep_lib = None
  832. for dl in libs:
  833. if dl.name == dep:
  834. dep_lib = dl
  835. assert dep_lib, 'lib %s not found (in %s)' % (dep, lib.name)
  836. link_libs = link_libs + ' -l' + dep
  837. lib_deps = lib_deps + ' $(LIBDIR)/$(CONFIG)/lib' + dep + '.$(SHARED_EXT_' + lang_to_var[dep_lib.language] + ')'
  838. mingw_libs = mingw_libs + ' -l' + dep + '$(SHARED_VERSION_' + lang_to_var[dep_lib.language] + ')-dll'
  839. mingw_lib_deps = mingw_lib_deps + ' $(LIBDIR)/$(CONFIG)/' + dep + '$(SHARED_VERSION_' + lang_to_var[dep_lib.language] + ').$(SHARED_EXT_' + lang_to_var[dep_lib.language] + ')'
  840. security = lib.get('secure', 'check')
  841. if security == True:
  842. common = common + ' $(OPENSSL_MERGE_LIBS) $(LDLIBS_SECURE)'
  843. common = common + ' $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(RE2_MERGE_LIBS) $(UPB_MERGE_LIBS) $(GRPC_ABSEIL_MERGE_LIBS)'
  844. if security in [True, 'check']:
  845. for src in lib.src:
  846. sources_that_need_openssl.add(src)
  847. else:
  848. for src in lib.src:
  849. sources_that_don_t_need_openssl.add(src)
  850. if lib.get('secure', 'check') == True or lib.get('secure', 'check') == 'check':
  851. lib_deps = lib_deps + ' $(OPENSSL_DEP)'
  852. mingw_lib_deps = mingw_lib_deps + ' $(OPENSSL_DEP)'
  853. ldflags = '$(LDFLAGS)'
  854. if lib.get('LDFLAGS', None):
  855. ldflags += ' ' + lib['LDFLAGS']
  856. common = common + ' $(LDLIBS)'
  857. %>
  858. % if lib.build == "all":
  859. ifeq ($(SYSTEM),MINGW32)
  860. ${out_mingbase}.$(SHARED_EXT_${lang_to_var[lib.language]}): $(LIB${lib.name.upper()}_OBJS) ${mingw_lib_deps}
  861. $(E) "[LD] Linking $@"
  862. $(Q) mkdir -p `dirname $@`
  863. $(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}
  864. else
  865. ${out_libbase}.$(SHARED_EXT_${lang_to_var[lib.language]}): $(LIB${lib.name.upper()}_OBJS) ${lib_deps}
  866. $(E) "[LD] Linking $@"
  867. $(Q) mkdir -p `dirname $@`
  868. ifeq ($(SYSTEM),Darwin)
  869. $(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}
  870. else
  871. $(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}
  872. $(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}
  873. $(Q) ln -sf $(SHARED_PREFIX)${lib.name}$(SHARED_VERSION_${lang_to_var[lib.language]}).$(SHARED_EXT_${lang_to_var[lib.language]}) ${out_libbase}.so
  874. endif
  875. endif
  876. % endif
  877. % if lib.get('secure', 'check') == True or lib.get('secure', 'check') == 'check':
  878. ## If the lib was secure, we have to close the Makefile's if that tested
  879. ## the presence of OpenSSL.
  880. endif
  881. % endif
  882. % if lib.get('secure', 'check') == True or lib.get('secure', 'check') == 'check':
  883. ifneq ($(NO_SECURE),true)
  884. % endif
  885. ifneq ($(NO_DEPS),true)
  886. -include $(LIB${lib.name.upper()}_OBJS:.o=.dep)
  887. endif
  888. % if lib.get('secure', 'check') == True or lib.get('secure', 'check') == 'check':
  889. endif
  890. % endif
  891. # end of build recipe for library "${lib.name}"
  892. </%def>
  893. # TODO(jtattermusch): is there a way to get around this hack?
  894. ifneq ($(OPENSSL_DEP),)
  895. # This is to ensure the embedded OpenSSL is built beforehand, properly
  896. # installing headers to their final destination on the drive. We need this
  897. # otherwise parallel compilation will fail if a source is compiled first.
  898. % for src in sorted(sources_that_need_openssl):
  899. % if src not in sources_that_don_t_need_openssl:
  900. ${src}: $(OPENSSL_DEP)
  901. % endif
  902. % endfor
  903. endif
  904. .PHONY: all strip tools \
  905. dep_error openssl_dep_error openssl_dep_message git_update stop \
  906. buildtests buildtests_c buildtests_cxx \
  907. test test_c test_cxx \
  908. install install_c install_cxx install_csharp install-static install-certs \
  909. strip strip-shared strip-static \
  910. strip_c strip-shared_c strip-static_c \
  911. strip_cxx strip-shared_cxx strip-static_cxx \
  912. dep_c dep_cxx bins_dep_c bins_dep_cxx \
  913. clean
  914. .PHONY: printvars
  915. printvars:
  916. @$(foreach V,$(sort $(.VARIABLES)), \
  917. $(if $(filter-out environment% default automatic, \
  918. $(origin $V)),$(warning $V=$($V) ($(value $V)))))