Makefile.template 59 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926
  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-2016, Google Inc.
  10. # All rights reserved.
  11. #
  12. # Redistribution and use in source and binary forms, with or without
  13. # modification, are permitted provided that the following conditions are
  14. # met:
  15. #
  16. # * Redistributions of source code must retain the above copyright
  17. # notice, this list of conditions and the following disclaimer.
  18. # * Redistributions in binary form must reproduce the above
  19. # copyright notice, this list of conditions and the following disclaimer
  20. # in the documentation and/or other materials provided with the
  21. # distribution.
  22. # * Neither the name of Google Inc. nor the names of its
  23. # contributors may be used to endorse or promote products derived from
  24. # this software without specific prior written permission.
  25. #
  26. # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  27. # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  28. # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  29. # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  30. # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  31. # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  32. # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  33. # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  34. # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  35. # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  36. # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  37. <%!
  38. import re
  39. import os
  40. proto_re = re.compile('(.*)\\.proto')
  41. def proto_to_cc(filename):
  42. m = proto_re.match(filename)
  43. if not m:
  44. return filename
  45. return '$(GENDIR)/' + m.group(1) + '.pb.cc $(GENDIR)/' + m.group(1) + '.grpc.pb.cc'
  46. sources_that_need_openssl = set()
  47. sources_that_don_t_need_openssl = set()
  48. %>
  49. comma := ,
  50. # Basic platform detection
  51. HOST_SYSTEM = $(shell uname | cut -f 1 -d_)
  52. ifeq ($(SYSTEM),)
  53. SYSTEM = $(HOST_SYSTEM)
  54. endif
  55. ifeq ($(SYSTEM),MSYS)
  56. SYSTEM = MINGW32
  57. endif
  58. ifeq ($(SYSTEM),MINGW64)
  59. SYSTEM = MINGW32
  60. endif
  61. MAKEFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST)))
  62. ifndef BUILDDIR
  63. BUILDDIR_ABSOLUTE = $(patsubst %/,%,$(dir $(MAKEFILE_PATH)))
  64. else
  65. BUILDDIR_ABSOLUTE = $(abspath $(BUILDDIR))
  66. endif
  67. HAS_GCC = $(shell which gcc > /dev/null 2> /dev/null && echo true || echo false)
  68. HAS_CC = $(shell which cc > /dev/null 2> /dev/null && echo true || echo false)
  69. HAS_CLANG = $(shell which clang > /dev/null 2> /dev/null && echo true || echo false)
  70. ifeq ($(HAS_CC),true)
  71. DEFAULT_CC = cc
  72. DEFAULT_CXX = c++
  73. else
  74. ifeq ($(HAS_GCC),true)
  75. DEFAULT_CC = gcc
  76. DEFAULT_CXX = g++
  77. else
  78. ifeq ($(HAS_CLANG),true)
  79. DEFAULT_CC = clang
  80. DEFAULT_CXX = clang++
  81. else
  82. DEFAULT_CC = no_c_compiler
  83. DEFAULT_CXX = no_c++_compiler
  84. endif
  85. endif
  86. endif
  87. BINDIR = $(BUILDDIR_ABSOLUTE)/bins
  88. OBJDIR = $(BUILDDIR_ABSOLUTE)/objs
  89. LIBDIR = $(BUILDDIR_ABSOLUTE)/libs
  90. GENDIR = $(BUILDDIR_ABSOLUTE)/gens
  91. # Configurations
  92. VALID_CONFIG_opt = 1
  93. CC_opt = $(DEFAULT_CC)
  94. CXX_opt = $(DEFAULT_CXX)
  95. LD_opt = $(DEFAULT_CC)
  96. LDXX_opt = $(DEFAULT_CXX)
  97. CPPFLAGS_opt = -O2
  98. LDFLAGS_opt = -rdynamic
  99. DEFINES_opt = NDEBUG
  100. VALID_CONFIG_basicprof = 1
  101. CC_basicprof = $(DEFAULT_CC)
  102. CXX_basicprof = $(DEFAULT_CXX)
  103. LD_basicprof = $(DEFAULT_CC)
  104. LDXX_basicprof = $(DEFAULT_CXX)
  105. CPPFLAGS_basicprof = -O2 -DGRPC_BASIC_PROFILER -DGRPC_TIMERS_RDTSC
  106. LDFLAGS_basicprof =
  107. DEFINES_basicprof = NDEBUG
  108. VALID_CONFIG_stapprof = 1
  109. CC_stapprof = $(DEFAULT_CC)
  110. CXX_stapprof = $(DEFAULT_CXX)
  111. LD_stapprof = $(DEFAULT_CC)
  112. LDXX_stapprof = $(DEFAULT_CXX)
  113. CPPFLAGS_stapprof = -O2 -DGRPC_STAP_PROFILER
  114. LDFLAGS_stapprof =
  115. DEFINES_stapprof = NDEBUG
  116. VALID_CONFIG_dbg = 1
  117. CC_dbg = $(DEFAULT_CC)
  118. CXX_dbg = $(DEFAULT_CXX)
  119. LD_dbg = $(DEFAULT_CC)
  120. LDXX_dbg = $(DEFAULT_CXX)
  121. CPPFLAGS_dbg = -O0
  122. LDFLAGS_dbg = -rdynamic
  123. DEFINES_dbg = _DEBUG DEBUG
  124. VALID_CONFIG_mutrace = 1
  125. CC_mutrace = $(DEFAULT_CC)
  126. CXX_mutrace = $(DEFAULT_CXX)
  127. LD_mutrace = $(DEFAULT_CC)
  128. LDXX_mutrace = $(DEFAULT_CXX)
  129. CPPFLAGS_mutrace = -O0
  130. LDFLAGS_mutrace = -rdynamic
  131. DEFINES_mutrace = _DEBUG DEBUG
  132. VALID_CONFIG_valgrind = 1
  133. REQUIRE_CUSTOM_LIBRARIES_valgrind = 1
  134. CC_valgrind = $(DEFAULT_CC)
  135. CXX_valgrind = $(DEFAULT_CXX)
  136. LD_valgrind = $(DEFAULT_CC)
  137. LDXX_valgrind = $(DEFAULT_CXX)
  138. CPPFLAGS_valgrind = -O0
  139. LDFLAGS_valgrind = -rdynamic
  140. DEFINES_valgrind = _DEBUG DEBUG GRPC_TEST_SLOWDOWN_BUILD_FACTOR=20
  141. VALID_CONFIG_tsan = 1
  142. REQUIRE_CUSTOM_LIBRARIES_tsan = 1
  143. CC_tsan = clang
  144. CXX_tsan = clang++
  145. LD_tsan = clang
  146. LDXX_tsan = clang++
  147. CFLAGS_tsan = -O0 -fsanitize=thread -fno-omit-frame-pointer -Wno-unused-command-line-argument -fPIE -pie
  148. CXXFLAGS_tsan = -O0 -fsanitize=thread -fno-omit-frame-pointer -Wno-unused-command-line-argument -fPIE -pie
  149. LDFLAGS_tsan = -fsanitize=thread -fPIE -pie $(if $(JENKINS_BUILD),-Wl$(comma)-Ttext-segment=0x7e0000000000,)
  150. DEFINES_tsan = NDEBUG GRPC_TEST_SLOWDOWN_BUILD_FACTOR=10
  151. VALID_CONFIG_asan = 1
  152. REQUIRE_CUSTOM_LIBRARIES_asan = 1
  153. CC_asan = clang
  154. CXX_asan = clang++
  155. LD_asan = clang
  156. LDXX_asan = clang++
  157. CFLAGS_asan = -O0 -fsanitize=address -fno-omit-frame-pointer -Wno-unused-command-line-argument
  158. CXXFLAGS_asan = -O0 -fsanitize=address -fno-omit-frame-pointer -Wno-unused-command-line-argument
  159. LDFLAGS_asan = -fsanitize=address
  160. DEFINES_asan = GRPC_TEST_SLOWDOWN_BUILD_FACTOR=3
  161. VALID_CONFIG_msan = 1
  162. REQUIRE_CUSTOM_LIBRARIES_msan = 1
  163. CC_msan = clang
  164. CXX_msan = clang++-libc++
  165. LD_msan = clang
  166. LDXX_msan = clang++-libc++
  167. CFLAGS_msan = -O0 -fsanitize=memory -fsanitize-memory-track-origins -fno-omit-frame-pointer -DGTEST_HAS_TR1_TUPLE=0 -DGTEST_USE_OWN_TR1_TUPLE=1 -Wno-unused-command-line-argument -fPIE -pie
  168. CXXFLAGS_msan = -O0 -fsanitize=memory -fsanitize-memory-track-origins -fno-omit-frame-pointer -DGTEST_HAS_TR1_TUPLE=0 -DGTEST_USE_OWN_TR1_TUPLE=1 -Wno-unused-command-line-argument -fPIE -pie
  169. LDFLAGS_msan = -fsanitize=memory -DGTEST_HAS_TR1_TUPLE=0 -DGTEST_USE_OWN_TR1_TUPLE=1 -fPIE -pie $(if $(JENKINS_BUILD),-Wl$(comma)-Ttext-segment=0x7e0000000000,)
  170. DEFINES_msan = NDEBUG GRPC_TEST_SLOWDOWN_BUILD_FACTOR=4
  171. VALID_CONFIG_ubsan = 1
  172. REQUIRE_CUSTOM_LIBRARIES_ubsan = 1
  173. CC_ubsan = clang
  174. CXX_ubsan = clang++
  175. LD_ubsan = clang
  176. LDXX_ubsan = clang++
  177. CFLAGS_ubsan = -O1 -fsanitize=undefined -fno-omit-frame-pointer -Wno-unused-command-line-argument
  178. CXXFLAGS_ubsan = -O1 -fsanitize=undefined -fno-omit-frame-pointer -Wno-unused-command-line-argument
  179. LDFLAGS_ubsan = -fsanitize=undefined
  180. DEFINES_ubsan = NDEBUG GRPC_TEST_SLOWDOWN_BUILD_FACTOR=3
  181. VALID_CONFIG_gcov = 1
  182. CC_gcov = gcc
  183. CXX_gcov = g++
  184. LD_gcov = gcc
  185. LDXX_gcov = g++
  186. CFLAGS_gcov = -O0 -fprofile-arcs -ftest-coverage -Wno-return-type
  187. CXXFLAGS_gcov = -O0 -fprofile-arcs -ftest-coverage -Wno-return-type
  188. LDFLAGS_gcov = -fprofile-arcs -ftest-coverage -rdynamic
  189. DEFINES_gcov = _DEBUG DEBUG GPR_GCOV
  190. # General settings.
  191. # You may want to change these depending on your system.
  192. prefix ?= /usr/local
  193. PROTOC = protoc
  194. DTRACE = dtrace
  195. CONFIG ?= opt
  196. CC = $(CC_$(CONFIG))
  197. CXX = $(CXX_$(CONFIG))
  198. LD = $(LD_$(CONFIG))
  199. LDXX = $(LDXX_$(CONFIG))
  200. AR = ar
  201. ifeq ($(SYSTEM),Linux)
  202. STRIP = strip --strip-unneeded
  203. else
  204. ifeq ($(SYSTEM),Darwin)
  205. STRIP = strip -x
  206. else
  207. STRIP = strip
  208. endif
  209. endif
  210. INSTALL = install
  211. RM = rm -f
  212. PKG_CONFIG = pkg-config
  213. ifndef VALID_CONFIG_$(CONFIG)
  214. $(error Invalid CONFIG value '$(CONFIG)')
  215. endif
  216. ifeq ($(SYSTEM),Linux)
  217. TMPOUT = /dev/null
  218. else
  219. TMPOUT = `mktemp /tmp/test-out-XXXXXX`
  220. endif
  221. # Detect if we can use C++11
  222. CXX11_CHECK_CMD = $(CXX) -std=c++11 -o $(TMPOUT) -c test/build/c++11.cc
  223. HAS_CXX11 = $(shell $(CXX11_CHECK_CMD) 2> /dev/null && echo true || echo false)
  224. # The HOST compiler settings are used to compile the protoc plugins.
  225. # In most cases, you won't have to change anything, but if you are
  226. # cross-compiling, you can override these variables from GNU make's
  227. # command line: make CC=cross-gcc HOST_CC=gcc
  228. HOST_CC = $(CC)
  229. HOST_CXX = $(CXX)
  230. HOST_LD = $(LD)
  231. HOST_LDXX = $(LDXX)
  232. ifdef EXTRA_DEFINES
  233. DEFINES += $(EXTRA_DEFINES)
  234. endif
  235. CFLAGS += -std=c99 -Wsign-conversion -Wconversion -Wshadow
  236. ifeq ($(HAS_CXX11),true)
  237. CXXFLAGS += -std=c++11
  238. else
  239. CXXFLAGS += -std=c++0x
  240. endif
  241. CFLAGS += -g -Wall -Wextra -Werror -Wno-long-long -Wno-unused-parameter
  242. CXXFLAGS += -g -Wall -Wextra -Werror -Wno-long-long -Wno-unused-parameter
  243. LDFLAGS += -g
  244. CPPFLAGS += $(CPPFLAGS_$(CONFIG))
  245. CFLAGS += $(CFLAGS_$(CONFIG))
  246. CXXFLAGS += $(CXXFLAGS_$(CONFIG))
  247. DEFINES += $(DEFINES_$(CONFIG)) INSTALL_PREFIX=\"$(prefix)\"
  248. LDFLAGS += $(LDFLAGS_$(CONFIG))
  249. ifneq ($(SYSTEM),MINGW32)
  250. PIC_CPPFLAGS = -fPIC
  251. CPPFLAGS += -fPIC
  252. LDFLAGS += -fPIC
  253. endif
  254. INCLUDES = . include $(GENDIR)
  255. LDFLAGS += -Llibs/$(CONFIG)
  256. ifeq ($(SYSTEM),Darwin)
  257. ifneq ($(wildcard /usr/local/ssl/include),)
  258. INCLUDES += /usr/local/ssl/include
  259. endif
  260. ifneq ($(wildcard /opt/local/include),)
  261. INCLUDES += /opt/local/include
  262. endif
  263. ifneq ($(wildcard /usr/local/include),)
  264. INCLUDES += /usr/local/include
  265. endif
  266. LIBS = m z
  267. ifneq ($(wildcard /usr/local/ssl/lib),)
  268. LDFLAGS += -L/usr/local/ssl/lib
  269. endif
  270. ifneq ($(wildcard /opt/local/lib),)
  271. LDFLAGS += -L/opt/local/lib
  272. endif
  273. ifneq ($(wildcard /usr/local/lib),)
  274. LDFLAGS += -L/usr/local/lib
  275. endif
  276. endif
  277. ifeq ($(SYSTEM),Linux)
  278. LIBS = rt m pthread
  279. LDFLAGS += -pthread
  280. endif
  281. ifeq ($(SYSTEM),MINGW32)
  282. LIBS = m pthread
  283. LDFLAGS += -pthread
  284. endif
  285. GTEST_LIB = -Ithird_party/googletest/include -Ithird_party/googletest third_party/googletest/src/gtest-all.cc
  286. GTEST_LIB += -lgflags
  287. ifeq ($(V),1)
  288. E = @:
  289. Q =
  290. else
  291. E = @echo
  292. Q = @
  293. endif
  294. VERSION = ${settings.version.major}.${settings.version.minor}.${settings.version.micro}.${settings.version.build}
  295. CPPFLAGS_NO_ARCH += $(addprefix -I, $(INCLUDES)) $(addprefix -D, $(DEFINES))
  296. CPPFLAGS += $(CPPFLAGS_NO_ARCH) $(ARCH_FLAGS)
  297. LDFLAGS += $(ARCH_FLAGS)
  298. LDLIBS += $(addprefix -l, $(LIBS))
  299. LDLIBSXX += $(addprefix -l, $(LIBSXX))
  300. HOST_CPPFLAGS = $(CPPFLAGS)
  301. HOST_CFLAGS = $(CFLAGS)
  302. HOST_CXXFLAGS = $(CXXFLAGS)
  303. HOST_LDFLAGS = $(LDFLAGS)
  304. HOST_LDLIBS = $(LDLIBS)
  305. # These are automatically computed variables.
  306. # There shouldn't be any need to change anything from now on.
  307. -include cache.mk
  308. CACHE_MK =
  309. HAS_PKG_CONFIG ?= $(shell command -v $(PKG_CONFIG) >/dev/null 2>&1 && echo true || echo false)
  310. ifeq ($(HAS_PKG_CONFIG), true)
  311. CACHE_MK += HAS_PKG_CONFIG = true,
  312. endif
  313. PC_TEMPLATE = prefix=$(prefix),\
  314. exec_prefix=${'\$${prefix}'},\
  315. includedir=${'\$${prefix}'}/include,\
  316. libdir=${'\$${exec_prefix}'}/lib,\
  317. ,\
  318. Name: $(PC_NAME),\
  319. Description: $(PC_DESCRIPTION),\
  320. Version: $(VERSION),\
  321. Cflags: -I${'\$${includedir}'} $(PC_CFLAGS),\
  322. Requires.private: $(PC_REQUIRES_PRIVATE),\
  323. Libs: -L${'\$${libdir}'} $(PC_LIB),\
  324. Libs.private: $(PC_LIBS_PRIVATE)
  325. # gpr .pc file
  326. PC_NAME = gRPC Portable Runtime
  327. PC_DESCRIPTION = gRPC Portable Runtime
  328. PC_CFLAGS = -pthread
  329. PC_REQUIRES_PRIVATE =
  330. PC_LIBS_PRIVATE = -lpthread
  331. PC_LIB = -lgpr
  332. ifneq ($(SYSTEM),Darwin)
  333. PC_LIBS_PRIVATE += -lrt
  334. endif
  335. GPR_PC_FILE := $(PC_TEMPLATE)
  336. ifeq ($(SYSTEM),MINGW32)
  337. SHARED_EXT = dll
  338. endif
  339. ifeq ($(SYSTEM),Darwin)
  340. SHARED_EXT = dylib
  341. endif
  342. ifeq ($(SHARED_EXT),)
  343. SHARED_EXT = so.$(VERSION)
  344. endif
  345. ifeq ($(wildcard .git),)
  346. IS_GIT_FOLDER = false
  347. else
  348. IS_GIT_FOLDER = true
  349. endif
  350. ifeq ($(SYSTEM),Linux)
  351. OPENSSL_REQUIRES_DL = true
  352. endif
  353. ifeq ($(SYSTEM),Darwin)
  354. OPENSSL_REQUIRES_DL = true
  355. endif
  356. ifeq ($(HAS_PKG_CONFIG),true)
  357. OPENSSL_ALPN_CHECK_CMD = $(PKG_CONFIG) --atleast-version=1.0.2 openssl
  358. OPENSSL_NPN_CHECK_CMD = $(PKG_CONFIG) --atleast-version=1.0.1 openssl
  359. ZLIB_CHECK_CMD = $(PKG_CONFIG) --exists zlib
  360. PROTOBUF_CHECK_CMD = $(PKG_CONFIG) --atleast-version=3.0.0-alpha-3 protobuf
  361. else # HAS_PKG_CONFIG
  362. ifeq ($(SYSTEM),MINGW32)
  363. OPENSSL_LIBS = ssl32 eay32
  364. else
  365. OPENSSL_LIBS = ssl crypto
  366. endif
  367. OPENSSL_ALPN_CHECK_CMD = $(CC) $(CFLAGS) $(CPPFLAGS) -o $(TMPOUT) test/build/openssl-alpn.c $(addprefix -l, $(OPENSSL_LIBS)) $(LDFLAGS)
  368. OPENSSL_NPN_CHECK_CMD = $(CC) $(CFLAGS) $(CPPFLAGS) -o $(TMPOUT) test/build/openssl-npn.c $(addprefix -l, $(OPENSSL_LIBS)) $(LDFLAGS)
  369. ZLIB_CHECK_CMD = $(CC) $(CFLAGS) $(CPPFLAGS) -o $(TMPOUT) test/build/zlib.c -lz $(LDFLAGS)
  370. PROTOBUF_CHECK_CMD = $(CXX) $(CXXFLAGS) $(CPPFLAGS) -o $(TMPOUT) test/build/protobuf.cc -lprotobuf $(LDFLAGS)
  371. ifeq ($(OPENSSL_REQUIRES_DL),true)
  372. OPENSSL_ALPN_CHECK_CMD += -ldl
  373. OPENSSL_NPN_CHECK_CMD += -ldl
  374. endif
  375. endif # HAS_PKG_CONFIG
  376. PERFTOOLS_CHECK_CMD = $(CC) $(CFLAGS) $(CPPFLAGS) -o $(TMPOUT) test/build/perftools.c -lprofiler $(LDFLAGS)
  377. PROTOC_CHECK_CMD = which protoc > /dev/null
  378. PROTOC_CHECK_VERSION_CMD = protoc --version | grep -q libprotoc.3
  379. DTRACE_CHECK_CMD = which dtrace > /dev/null
  380. SYSTEMTAP_HEADERS_CHECK_CMD = $(CC) $(CFLAGS) $(CPPFLAGS) -o $(TMPOUT) test/build/systemtap.c $(LDFLAGS)
  381. ZOOKEEPER_CHECK_CMD = $(CC) $(CFLAGS) $(CPPFLAGS) -o $(TMPOUT) test/build/zookeeper.c $(LDFLAGS) -lzookeeper_mt
  382. ifndef REQUIRE_CUSTOM_LIBRARIES_$(CONFIG)
  383. HAS_SYSTEM_PERFTOOLS ?= $(shell $(PERFTOOLS_CHECK_CMD) 2> /dev/null && echo true || echo false)
  384. ifeq ($(HAS_SYSTEM_PERFTOOLS),true)
  385. DEFINES += GRPC_HAVE_PERFTOOLS
  386. LIBS += profiler
  387. CACHE_MK += HAS_SYSTEM_PERFTOOLS = true,
  388. endif
  389. endif
  390. HAS_SYSTEM_PROTOBUF_VERIFY = $(shell $(PROTOBUF_CHECK_CMD) 2> /dev/null && echo true || echo false)
  391. ifndef REQUIRE_CUSTOM_LIBRARIES_$(CONFIG)
  392. HAS_SYSTEM_OPENSSL_ALPN ?= $(shell $(OPENSSL_ALPN_CHECK_CMD) 2> /dev/null && echo true || echo false)
  393. ifeq ($(HAS_SYSTEM_OPENSSL_ALPN),true)
  394. HAS_SYSTEM_OPENSSL_NPN = true
  395. CACHE_MK += HAS_SYSTEM_OPENSSL_ALPN = true,
  396. else
  397. HAS_SYSTEM_OPENSSL_NPN ?= $(shell $(OPENSSL_NPN_CHECK_CMD) 2> /dev/null && echo true || echo false)
  398. endif
  399. ifeq ($(HAS_SYSTEM_OPENSSL_NPN),true)
  400. CACHE_MK += HAS_SYSTEM_OPENSSL_NPN = true,
  401. endif
  402. HAS_SYSTEM_ZLIB ?= $(shell $(ZLIB_CHECK_CMD) 2> /dev/null && echo true || echo false)
  403. ifeq ($(HAS_SYSTEM_ZLIB),true)
  404. CACHE_MK += HAS_SYSTEM_ZLIB = true,
  405. endif
  406. HAS_SYSTEM_PROTOBUF ?= $(HAS_SYSTEM_PROTOBUF_VERIFY)
  407. ifeq ($(HAS_SYSTEM_PROTOBUF),true)
  408. CACHE_MK += HAS_SYSTEM_PROTOBUF = true,
  409. endif
  410. else
  411. # override system libraries if the config requires a custom compiled library
  412. HAS_SYSTEM_OPENSSL_ALPN = false
  413. HAS_SYSTEM_OPENSSL_NPN = false
  414. HAS_SYSTEM_ZLIB = false
  415. HAS_SYSTEM_PROTOBUF = false
  416. endif
  417. HAS_PROTOC ?= $(shell $(PROTOC_CHECK_CMD) 2> /dev/null && echo true || echo false)
  418. ifeq ($(HAS_PROTOC),true)
  419. CACHE_MK += HAS_PROTOC = true,
  420. HAS_VALID_PROTOC ?= $(shell $(PROTOC_CHECK_VERSION_CMD) 2> /dev/null && echo true || echo false)
  421. ifeq ($(HAS_VALID_PROTOC),true)
  422. CACHE_MK += HAS_VALID_PROTOC = true,
  423. endif
  424. else
  425. HAS_VALID_PROTOC = false
  426. endif
  427. # Check for Systemtap (https://sourceware.org/systemtap/), first by making sure <sys/sdt.h> is present
  428. # in the system and secondly by checking for the "dtrace" binary (on Linux, this is part of the Systemtap
  429. # distribution. It's part of the base system on BSD/Solaris machines).
  430. ifndef HAS_SYSTEMTAP
  431. HAS_SYSTEMTAP_HEADERS = $(shell $(SYSTEMTAP_HEADERS_CHECK_CMD) 2> /dev/null && echo true || echo false)
  432. HAS_DTRACE = $(shell $(DTRACE_CHECK_CMD) 2> /dev/null && echo true || echo false)
  433. HAS_SYSTEMTAP = false
  434. ifeq ($(HAS_SYSTEMTAP_HEADERS),true)
  435. ifeq ($(HAS_DTRACE),true)
  436. HAS_SYSTEMTAP = true
  437. endif
  438. endif
  439. endif
  440. ifeq ($(HAS_SYSTEMTAP),true)
  441. CACHE_MK += HAS_SYSTEMTAP = true,
  442. endif
  443. HAS_ZOOKEEPER = $(shell $(ZOOKEEPER_CHECK_CMD) 2> /dev/null && echo true || echo false)
  444. # Note that for testing purposes, one can do:
  445. # make HAS_EMBEDDED_OPENSSL_ALPN=false
  446. # to emulate the fact we do not have OpenSSL in the third_party folder.
  447. ifeq ($(wildcard third_party/boringssl/include/openssl/ssl.h),)
  448. HAS_EMBEDDED_OPENSSL_ALPN = false
  449. else
  450. HAS_EMBEDDED_OPENSSL_ALPN = true
  451. endif
  452. ifeq ($(wildcard third_party/zlib/zlib.h),)
  453. HAS_EMBEDDED_ZLIB = false
  454. else
  455. HAS_EMBEDDED_ZLIB = true
  456. endif
  457. ifeq ($(wildcard third_party/protobuf/src/google/protobuf/descriptor.pb.h),)
  458. HAS_EMBEDDED_PROTOBUF = false
  459. ifneq ($(HAS_VALID_PROTOC),true)
  460. NO_PROTOC = true
  461. endif
  462. else
  463. HAS_EMBEDDED_PROTOBUF = true
  464. endif
  465. PC_REQUIRES_GRPC = gpr
  466. PC_LIBS_GRPC =
  467. ifeq ($(HAS_SYSTEM_ZLIB),false)
  468. ifeq ($(HAS_EMBEDDED_ZLIB),true)
  469. ZLIB_DEP = $(LIBDIR)/$(CONFIG)/zlib/libz.a
  470. ZLIB_MERGE_LIBS = $(LIBDIR)/$(CONFIG)/zlib/libz.a
  471. CPPFLAGS += -Ithird_party/zlib
  472. LDFLAGS += -L$(LIBDIR)/$(CONFIG)/zlib
  473. else
  474. DEP_MISSING += zlib
  475. endif
  476. else
  477. ifeq ($(HAS_PKG_CONFIG),true)
  478. CPPFLAGS += $(shell $(PKG_CONFIG) --cflags zlib)
  479. LDFLAGS += $(shell $(PKG_CONFIG) --libs-only-L zlib)
  480. LIBS += $(patsubst -l%,%,$(shell $(PKG_CONFIG) --libs-only-l zlib))
  481. PC_REQUIRES_GRPC += zlib
  482. else
  483. PC_LIBS_GRPC += -lz
  484. LIBS += z
  485. endif
  486. endif
  487. OPENSSL_PKG_CONFIG = false
  488. PC_REQUIRES_SECURE =
  489. PC_LIBS_SECURE =
  490. ifeq ($(HAS_SYSTEM_OPENSSL_ALPN),true)
  491. EMBED_OPENSSL ?= false
  492. NO_SECURE ?= false
  493. else # HAS_SYSTEM_OPENSSL_ALPN=false
  494. ifeq ($(HAS_EMBEDDED_OPENSSL_ALPN),true)
  495. EMBED_OPENSSL ?= true
  496. NO_SECURE ?= false
  497. else # HAS_EMBEDDED_OPENSSL_ALPN=false
  498. ifeq ($(HAS_SYSTEM_OPENSSL_NPN),true)
  499. EMBED_OPENSSL ?= false
  500. NO_SECURE ?= false
  501. else
  502. NO_SECURE ?= true
  503. endif # HAS_SYSTEM_OPENSSL_NPN=true
  504. endif # HAS_EMBEDDED_OPENSSL_ALPN
  505. endif # HAS_SYSTEM_OPENSSL_ALPN
  506. OPENSSL_DEP :=
  507. OPENSSL_MERGE_LIBS :=
  508. ifeq ($(NO_SECURE),false)
  509. ifeq ($(EMBED_OPENSSL),true)
  510. OPENSSL_DEP += $(LIBDIR)/$(CONFIG)/libboringssl.a
  511. OPENSSL_MERGE_LIBS += $(LIBDIR)/$(CONFIG)/libboringssl.a
  512. # need to prefix these to ensure overriding system libraries
  513. CPPFLAGS := -Ithird_party/boringssl/include $(CPPFLAGS)
  514. ifeq ($(OPENSSL_REQUIRES_DL),true)
  515. LIBS_SECURE = dl
  516. endif # OPENSSL_REQUIRES_DL
  517. else # EMBED_OPENSSL=false
  518. ifeq ($(HAS_PKG_CONFIG),true)
  519. OPENSSL_PKG_CONFIG = true
  520. PC_REQUIRES_SECURE = openssl
  521. CPPFLAGS := $(shell $(PKG_CONFIG) --cflags openssl) $(CPPFLAGS)
  522. LDFLAGS_OPENSSL_PKG_CONFIG = $(shell $(PKG_CONFIG) --libs-only-L openssl)
  523. ifeq ($(SYSTEM),Linux)
  524. ifneq ($(LDFLAGS_OPENSSL_PKG_CONFIG),)
  525. LDFLAGS_OPENSSL_PKG_CONFIG += $(shell $(PKG_CONFIG) --libs-only-L openssl | sed s/L/Wl,-rpath,/)
  526. endif # LDFLAGS_OPENSSL_PKG_CONFIG=''
  527. endif # System=Linux
  528. LDFLAGS := $(LDFLAGS_OPENSSL_PKG_CONFIG) $(LDFLAGS)
  529. else # HAS_PKG_CONFIG=false
  530. LIBS_SECURE = $(OPENSSL_LIBS)
  531. endif # HAS_PKG_CONFIG
  532. ifeq ($(HAS_SYSTEM_OPENSSL_NPN),true)
  533. CPPFLAGS += -DTSI_OPENSSL_ALPN_SUPPORT=0
  534. LIBS_SECURE = $(OPENSSL_LIBS)
  535. endif # HAS_SYSTEM_OPENSSL_NPN
  536. ifeq ($(OPENSSL_REQUIRES_DL),true)
  537. LIBS_SECURE += dl
  538. PC_LIBS_SECURE = $(addprefix -l, $(LIBS_SECURE))
  539. endif # OPENSSL_REQUIRES_DL=true
  540. endif # EMBED_OPENSSL
  541. endif # NO_SECURE
  542. ifeq ($(OPENSSL_PKG_CONFIG),true)
  543. LDLIBS_SECURE += $(shell $(PKG_CONFIG) --libs-only-l openssl)
  544. else
  545. LDLIBS_SECURE += $(addprefix -l, $(LIBS_SECURE))
  546. endif
  547. # grpc .pc file
  548. PC_NAME = gRPC
  549. PC_DESCRIPTION = high performance general RPC framework
  550. PC_CFLAGS =
  551. PC_REQUIRES_PRIVATE = $(PC_REQUIRES_GRPC) $(PC_REQUIRES_SECURE)
  552. PC_LIBS_PRIVATE = $(PC_LIBS_GRPC) $(PC_LIBS_SECURE)
  553. PC_LIB = -lgrpc
  554. GRPC_PC_FILE := $(PC_TEMPLATE)
  555. # gprc_unsecure .pc file
  556. PC_NAME = gRPC unsecure
  557. PC_DESCRIPTION = high performance general RPC framework without SSL
  558. PC_CFLAGS =
  559. PC_REQUIRES_PRIVATE = $(PC_REQUIRES_GRPC)
  560. PC_LIBS_PRIVATE = $(PC_LIBS_GRPC)
  561. PC_LIB = -lgrpc
  562. GRPC_UNSECURE_PC_FILE := $(PC_TEMPLATE)
  563. # gprc_zookeeper .pc file
  564. PC_NAME = gRPC zookeeper
  565. PC_DESCRIPTION = gRPC's zookeeper plugin
  566. PC_CFLAGS =
  567. PC_REQUIRES_PRIVATE =
  568. PC_LIBS_PRIVATE = -lzookeeper_mt
  569. GRPC_ZOOKEEPER_PC_FILE := $(PC_TEMPLATE)
  570. PROTOBUF_PKG_CONFIG = false
  571. PC_REQUIRES_GRPCXX =
  572. PC_LIBS_GRPCXX =
  573. CPPFLAGS := -Ithird_party/googletest/include $(CPPFLAGS)
  574. ifeq ($(HAS_SYSTEM_PROTOBUF),true)
  575. ifeq ($(HAS_PKG_CONFIG),true)
  576. PROTOBUF_PKG_CONFIG = true
  577. PC_REQUIRES_GRPCXX = protobuf
  578. CPPFLAGS := $(shell $(PKG_CONFIG) --cflags protobuf) $(CPPFLAGS)
  579. LDFLAGS_PROTOBUF_PKG_CONFIG = $(shell $(PKG_CONFIG) --libs-only-L protobuf)
  580. ifeq ($(SYSTEM),Linux)
  581. ifneq ($(LDFLAGS_PROTOBUF_PKG_CONFIG),)
  582. LDFLAGS_PROTOBUF_PKG_CONFIG += $(shell $(PKG_CONFIG) --libs-only-L protobuf | sed s/L/Wl,-rpath,/)
  583. endif
  584. endif
  585. else
  586. PC_LIBS_GRPCXX = -lprotobuf
  587. endif
  588. else
  589. ifeq ($(HAS_EMBEDDED_PROTOBUF),true)
  590. PROTOBUF_DEP = $(LIBDIR)/$(CONFIG)/protobuf/libprotobuf.a
  591. CPPFLAGS := -Ithird_party/protobuf/src $(CPPFLAGS)
  592. LDFLAGS := -L$(LIBDIR)/$(CONFIG)/protobuf $(LDFLAGS)
  593. PROTOC = $(BINDIR)/$(CONFIG)/protobuf/protoc
  594. else
  595. NO_PROTOBUF = true
  596. endif
  597. endif
  598. LIBS_PROTOBUF = protobuf
  599. LIBS_PROTOC = protoc protobuf
  600. HOST_LDLIBS_PROTOC += $(addprefix -l, $(LIBS_PROTOC))
  601. ifeq ($(PROTOBUF_PKG_CONFIG),true)
  602. LDLIBS_PROTOBUF += $(shell $(PKG_CONFIG) --libs-only-l protobuf)
  603. else
  604. LDLIBS_PROTOBUF += $(addprefix -l, $(LIBS_PROTOBUF))
  605. endif
  606. # grpc++ .pc file
  607. PC_NAME = gRPC++
  608. PC_DESCRIPTION = C++ wrapper for gRPC
  609. PC_CFLAGS =
  610. PC_REQUIRES_PRIVATE = grpc $(PC_REQUIRES_GRPCXX)
  611. PC_LIBS_PRIVATE = $(PC_LIBS_GRPCXX)
  612. PC_LIB = -lgrpc++
  613. GRPCXX_PC_FILE := $(PC_TEMPLATE)
  614. # grpc++_unsecure .pc file
  615. PC_NAME = gRPC++ unsecure
  616. PC_DESCRIPTION = C++ wrapper for gRPC without SSL
  617. PC_CFLAGS =
  618. PC_REQUIRES_PRIVATE = grpc_unsecure $(PC_REQUIRES_GRPCXX)
  619. PC_LIBS_PRIVATE = $(PC_LIBS_GRPCXX)
  620. PC_LIB = -lgrpc++
  621. GRPCXX_UNSECURE_PC_FILE := $(PC_TEMPLATE)
  622. ifeq ($(MAKECMDGOALS),clean)
  623. NO_DEPS = true
  624. endif
  625. INSTALL_OK = false
  626. ifeq ($(HAS_VALID_PROTOC),true)
  627. ifeq ($(HAS_SYSTEM_PROTOBUF_VERIFY),true)
  628. INSTALL_OK = true
  629. endif
  630. endif
  631. .SECONDARY = %.pb.h %.pb.cc
  632. PROTOC_PLUGINS =\
  633. % for tgt in targets:
  634. % if tgt.build == 'protoc':
  635. $(BINDIR)/$(CONFIG)/${tgt.name}\
  636. % endif
  637. % endfor
  638. ifeq ($(DEP_MISSING),)
  639. all: static shared plugins\
  640. % for tgt in targets:
  641. % if tgt.build == 'all':
  642. $(BINDIR)/$(CONFIG)/${tgt.name}\
  643. % endif
  644. % endfor
  645. dep_error:
  646. @echo "You shouldn't see this message - all of your dependencies are correct."
  647. else
  648. all: dep_error git_update stop
  649. dep_error:
  650. @echo
  651. @echo "DEPENDENCY ERROR"
  652. @echo
  653. @echo "You are missing system dependencies that are essential to build grpc,"
  654. @echo "and the third_party directory doesn't have them:"
  655. @echo
  656. @echo " $(DEP_MISSING)"
  657. @echo
  658. @echo "Installing the development packages for your system will solve"
  659. @echo "this issue. Please consult INSTALL to get more information."
  660. @echo
  661. @echo "If you need information about why these tests failed, run:"
  662. @echo
  663. @echo " make run_dep_checks"
  664. @echo
  665. endif
  666. git_update:
  667. ifeq ($(IS_GIT_FOLDER),true)
  668. @echo "Additionally, since you are in a git clone, you can download the"
  669. @echo "missing dependencies in third_party by running the following command:"
  670. @echo
  671. @echo " git submodule update --init"
  672. @echo
  673. endif
  674. openssl_dep_error: openssl_dep_message git_update stop
  675. protobuf_dep_error: protobuf_dep_message git_update stop
  676. protoc_dep_error: protoc_dep_message git_update stop
  677. openssl_dep_message:
  678. @echo
  679. @echo "DEPENDENCY ERROR"
  680. @echo
  681. @echo "The target you are trying to run requires OpenSSL."
  682. @echo "Your system doesn't have it, and neither does the third_party directory."
  683. @echo
  684. @echo "Please consult INSTALL to get more information."
  685. @echo
  686. @echo "If you need information about why these tests failed, run:"
  687. @echo
  688. @echo " make run_dep_checks"
  689. @echo
  690. protobuf_dep_message:
  691. @echo
  692. @echo "DEPENDENCY ERROR"
  693. @echo
  694. @echo "The target you are trying to run requires protobuf 3.0.0+"
  695. @echo "Your system doesn't have it, and neither does the third_party directory."
  696. @echo
  697. @echo "Please consult INSTALL to get more information."
  698. @echo
  699. @echo "If you need information about why these tests failed, run:"
  700. @echo
  701. @echo " make run_dep_checks"
  702. @echo
  703. protoc_dep_message:
  704. @echo
  705. @echo "DEPENDENCY ERROR"
  706. @echo
  707. @echo "The target you are trying to run requires protobuf-compiler 3.0.0+"
  708. @echo "Your system doesn't have it, and neither does the third_party directory."
  709. @echo
  710. @echo "Please consult INSTALL to get more information."
  711. @echo
  712. @echo "If you need information about why these tests failed, run:"
  713. @echo
  714. @echo " make run_dep_checks"
  715. @echo
  716. systemtap_dep_error:
  717. @echo
  718. @echo "DEPENDENCY ERROR"
  719. @echo
  720. @echo "Under the '$(CONFIG)' configutation, the target you are trying "
  721. @echo "to build requires systemtap 2.7+ (on Linux) or dtrace (on other "
  722. @echo "platforms such as Solaris and *BSD). "
  723. @echo
  724. @echo "Please consult INSTALL to get more information."
  725. @echo
  726. stop:
  727. @false
  728. % for tgt in targets:
  729. ${tgt.name}: $(BINDIR)/$(CONFIG)/${tgt.name}
  730. % endfor
  731. run_dep_checks:
  732. $(OPENSSL_ALPN_CHECK_CMD) || true
  733. $(OPENSSL_NPN_CHECK_CMD) || true
  734. $(ZLIB_CHECK_CMD) || true
  735. $(PERFTOOLS_CHECK_CMD) || true
  736. $(PROTOBUF_CHECK_CMD) || true
  737. $(PROTOC_CHECK_VERSION_CMD) || true
  738. $(ZOOKEEPER_CHECK_CMD) || true
  739. $(LIBDIR)/$(CONFIG)/zlib/libz.a:
  740. $(E) "[MAKE] Building zlib"
  741. $(Q)(cd third_party/zlib ; CC="$(CC)" CFLAGS="$(CFLAGS_$(CONFIG)) $(PIC_CPPFLAGS) -fvisibility=hidden $(CPPFLAGS_$(CONFIG)) $(ZLIB_CFLAGS_EXTRA)" ./configure --static)
  742. $(Q)$(MAKE) -C third_party/zlib clean
  743. $(Q)$(MAKE) -C third_party/zlib
  744. $(Q)mkdir -p $(LIBDIR)/$(CONFIG)/zlib
  745. $(Q)cp third_party/zlib/libz.a $(LIBDIR)/$(CONFIG)/zlib
  746. third_party/protobuf/configure:
  747. $(E) "[AUTOGEN] Preparing protobuf"
  748. $(Q)(cd third_party/protobuf ; autoreconf -f -i -Wall,no-obsolete)
  749. $(LIBDIR)/$(CONFIG)/protobuf/libprotobuf.a: third_party/protobuf/configure
  750. $(E) "[MAKE] Building protobuf"
  751. $(Q)(cd third_party/protobuf ; CC="$(CC)" CXX="$(CXX)" LDFLAGS="$(LDFLAGS_$(CONFIG)) -g $(PROTOBUF_LDFLAGS_EXTRA)" CPPFLAGS="$(PIC_CPPFLAGS) $(CPPFLAGS_$(CONFIG)) -g $(PROTOBUF_CPPFLAGS_EXTRA)" ./configure --disable-shared --enable-static)
  752. $(Q)$(MAKE) -C third_party/protobuf clean
  753. $(Q)$(MAKE) -C third_party/protobuf
  754. $(Q)mkdir -p $(LIBDIR)/$(CONFIG)/protobuf
  755. $(Q)mkdir -p $(BINDIR)/$(CONFIG)/protobuf
  756. $(Q)cp third_party/protobuf/src/.libs/libprotoc.a $(LIBDIR)/$(CONFIG)/protobuf
  757. $(Q)cp third_party/protobuf/src/.libs/libprotobuf.a $(LIBDIR)/$(CONFIG)/protobuf
  758. $(Q)cp third_party/protobuf/src/protoc $(BINDIR)/$(CONFIG)/protobuf
  759. static: static_c static_cxx
  760. static_c: pc_c pc_c_unsecure cache.mk pc_gpr pc_c_zookeeper\
  761. % for lib in libs:
  762. % if lib.build == 'all' and lib.language == 'c' and not lib.get('external_deps', None):
  763. $(LIBDIR)/$(CONFIG)/lib${lib.name}.a\
  764. % endif
  765. % endfor
  766. static_zookeeper_libs
  767. static_cxx: pc_cxx pc_cxx_unsecure pc_gpr cache.mk \
  768. % for lib in libs:
  769. % if lib.build == 'all' and lib.language == 'c++':
  770. $(LIBDIR)/$(CONFIG)/lib${lib.name}.a\
  771. % endif
  772. % endfor
  773. shared: shared_c shared_cxx
  774. shared_c: pc_c pc_c_unsecure pc_gpr cache.mk pc_c_zookeeper\
  775. % for lib in libs:
  776. % if lib.build == 'all' and lib.language == 'c' and not lib.get('external_deps', None):
  777. $(LIBDIR)/$(CONFIG)/lib${lib.name}.$(SHARED_EXT)\
  778. % endif
  779. % endfor
  780. shared_zookeeper_libs
  781. shared_cxx: pc_cxx pc_cxx_unsecure cache.mk\
  782. % for lib in libs:
  783. % if lib.build == 'all' and lib.language == 'c++':
  784. $(LIBDIR)/$(CONFIG)/lib${lib.name}.$(SHARED_EXT)\
  785. % endif
  786. % endfor
  787. shared_csharp: shared_c \
  788. % for lib in libs:
  789. % if lib.build == 'all' and lib.language == 'csharp':
  790. $(LIBDIR)/$(CONFIG)/lib${lib.name}.$(SHARED_EXT)\
  791. % endif
  792. % endfor
  793. ifeq ($(HAS_ZOOKEEPER),true)
  794. static_zookeeper_libs:\
  795. % for lib in libs:
  796. % if lib.build == 'all' and lib.language == 'c' and 'zookeeper' in lib.get('external_deps', []):
  797. $(LIBDIR)/$(CONFIG)/lib${lib.name}.a\
  798. % endif
  799. % endfor
  800. shared_zookeeper_libs:\
  801. % for lib in libs:
  802. % if lib.build == 'all' and lib.language == 'c' and 'zookeeper' in lib.get('external_deps', []):
  803. $(LIBDIR)/$(CONFIG)/lib${lib.name}.$(SHARED_EXT)\
  804. % endif
  805. % endfor
  806. else
  807. static_zookeeper_libs:
  808. shared_zookeeper_libs:
  809. endif
  810. grpc_csharp_ext: shared_csharp
  811. plugins: $(PROTOC_PLUGINS)
  812. privatelibs: privatelibs_c privatelibs_cxx
  813. privatelibs_c: \
  814. % for lib in libs:
  815. % if lib.build == 'private' and lib.language == 'c' and not lib.get('external_deps', None) and not lib.boringssl:
  816. $(LIBDIR)/$(CONFIG)/lib${lib.name}.a\
  817. % endif
  818. % endfor
  819. pc_gpr: $(LIBDIR)/$(CONFIG)/pkgconfig/gpr.pc
  820. pc_c: $(LIBDIR)/$(CONFIG)/pkgconfig/grpc.pc
  821. pc_c_unsecure: $(LIBDIR)/$(CONFIG)/pkgconfig/grpc_unsecure.pc
  822. ifeq ($(HAS_ZOOKEEPER),true)
  823. pc_c_zookeeper: $(LIBDIR)/$(CONFIG)/pkgconfig/grpc_zookeeper.pc
  824. else
  825. pc_c_zookeeper:
  826. endif
  827. pc_cxx: $(LIBDIR)/$(CONFIG)/pkgconfig/grpc++.pc
  828. pc_cxx_unsecure: $(LIBDIR)/$(CONFIG)/pkgconfig/grpc++_unsecure.pc
  829. privatelibs_cxx: \
  830. % for lib in libs:
  831. % if lib.build == 'private' and lib.language == 'c++' and not lib.get('external_deps', None):
  832. $(LIBDIR)/$(CONFIG)/lib${lib.name}.a\
  833. % endif
  834. % endfor
  835. ifeq ($(HAS_ZOOKEEPER),true)
  836. privatelibs_zookeeper: \
  837. % for lib in libs:
  838. % if lib.build == 'private' and lib.language == 'c++' and zookeeper in lib.get('external_deps', []):
  839. $(LIBDIR)/$(CONFIG)/lib${lib.name}.a\
  840. % endif
  841. % endfor
  842. else
  843. privatelibs_zookeeper:
  844. endif
  845. buildtests: buildtests_c buildtests_cxx buildtests_zookeeper
  846. buildtests_c: privatelibs_c <%text>\</%text>
  847. % for tgt in targets:
  848. % if tgt.build == 'test' and not tgt.language == 'c++' and not tgt.get('external_deps', None):
  849. $(BINDIR)/$(CONFIG)/${tgt.name} <%text>\</%text>
  850. % endif
  851. % endfor
  852. buildtests_cxx: buildtests_zookeeper privatelibs_cxx <%text>\</%text>
  853. % for tgt in targets:
  854. % if tgt.build == 'test' and tgt.language == 'c++' and not tgt.get('external_deps', None):
  855. $(BINDIR)/$(CONFIG)/${tgt.name} <%text>\</%text>
  856. % endif
  857. % endfor
  858. ifeq ($(HAS_ZOOKEEPER),true)
  859. buildtests_zookeeper: privatelibs_zookeeper <%text>\</%text>
  860. % for tgt in targets:
  861. % if tgt.build == 'test' and tgt.language == 'c++' and 'zookeeper' in tgt.get('external_deps', []):
  862. $(BINDIR)/$(CONFIG)/${tgt.name} <%text>\</%text>
  863. % endif
  864. % endfor
  865. else
  866. buildtests_zookeeper:
  867. endif
  868. test: test_c test_cxx test_zookeeper
  869. flaky_test: flaky_test_c flaky_test_cxx flaky_test_zookeeper
  870. test_c: buildtests_c
  871. % for tgt in targets:
  872. % if tgt.build == 'test' and tgt.get('run', True) and not tgt.language == 'c++' and not tgt.get('flaky', False) and not tgt.get('external_deps', None):
  873. $(E) "[RUN] Testing ${tgt.name}"
  874. $(Q) $(BINDIR)/$(CONFIG)/${tgt.name} || ( echo test ${tgt.name} failed ; exit 1 )
  875. % endif
  876. % endfor
  877. flaky_test_c: buildtests_c
  878. % for tgt in targets:
  879. % if tgt.build == 'test' and tgt.get('run', True) and not tgt.language == 'c++' and tgt.get('flaky', False) and not tgt.get('external_deps', None):
  880. $(E) "[RUN] Testing ${tgt.name}"
  881. $(Q) $(BINDIR)/$(CONFIG)/${tgt.name} || ( echo test ${tgt.name} failed ; exit 1 )
  882. % endif
  883. % endfor
  884. test_cxx: test_zookeeper buildtests_cxx
  885. % for tgt in targets:
  886. % if tgt.build == 'test' and tgt.get('run', True) and tgt.language == 'c++' and not tgt.get('flaky', False) and not tgt.get('external_deps', None):
  887. $(E) "[RUN] Testing ${tgt.name}"
  888. $(Q) $(BINDIR)/$(CONFIG)/${tgt.name} || ( echo test ${tgt.name} failed ; exit 1 )
  889. % endif
  890. % endfor
  891. flaky_test_cxx: buildtests_cxx
  892. % for tgt in targets:
  893. % if tgt.build == 'test' and tgt.get('run', True) and tgt.language == 'c++' and tgt.get('flaky', False) and not tgt.get('external_deps', None):
  894. $(E) "[RUN] Testing ${tgt.name}"
  895. $(Q) $(BINDIR)/$(CONFIG)/${tgt.name} || ( echo test ${tgt.name} failed ; exit 1 )
  896. % endif
  897. % endfor
  898. ifeq ($(HAS_ZOOKEEPER),true)
  899. test_zookeeper: buildtests_zookeeper
  900. % for tgt in targets:
  901. % if tgt.build == 'test' and tgt.get('run', True) and tgt.language == 'c++' and not tgt.get('flaky', False) and 'zookeeper' in tgt.get('external_deps', []):
  902. $(E) "[RUN] Testing ${tgt.name}"
  903. $(Q) $(BINDIR)/$(CONFIG)/${tgt.name} || ( echo test ${tgt.name} failed ; exit 1 )
  904. % endif
  905. % endfor
  906. flaky_test_zookeeper: buildtests_zookeeper
  907. % for tgt in targets:
  908. % if tgt.build == 'test' and tgt.get('run', True) and tgt.language == 'c++' and tgt.get('flaky', False) and 'zookeeper' in tgt.get('external_deps', []):
  909. $(E) "[RUN] Testing ${tgt.name}"
  910. $(Q) $(BINDIR)/$(CONFIG)/${tgt.name} || ( echo test ${tgt.name} failed ; exit 1 )
  911. % endif
  912. % endfor
  913. else
  914. test_zookeeper:
  915. flaky_test_zookeeper:
  916. endif
  917. test_python: static_c
  918. $(E) "[RUN] Testing python code"
  919. $(Q) tools/run_tests/run_tests.py -lpython -c$(CONFIG)
  920. tools: tools_c tools_cxx
  921. tools_c: privatelibs_c\
  922. % for tgt in targets:
  923. % if tgt.build == 'tool' and not tgt.language=='c++':
  924. $(BINDIR)/$(CONFIG)/${tgt.name}\
  925. % endif
  926. % endfor
  927. tools_cxx: privatelibs_cxx\
  928. % for tgt in targets:
  929. % if tgt.build == 'tool' and tgt.language=='c++':
  930. $(BINDIR)/$(CONFIG)/${tgt.name}\
  931. % endif
  932. % endfor
  933. buildbenchmarks: privatelibs\
  934. % for tgt in targets:
  935. % if tgt.build == 'benchmark':
  936. $(BINDIR)/$(CONFIG)/${tgt.name}\
  937. % endif
  938. % endfor
  939. benchmarks: buildbenchmarks
  940. strip: strip-static strip-shared
  941. strip-static: strip-static_c strip-static_cxx
  942. strip-shared: strip-shared_c strip-shared_cxx
  943. # TODO(nnoble): the strip target is stripping in-place, instead
  944. # of copying files in a temporary folder.
  945. # This prevents proper debugging after running make install.
  946. strip-static_c: static_c
  947. ifeq ($(CONFIG),opt)
  948. % for lib in libs:
  949. % if lib.language == "c":
  950. % if lib.build == "all":
  951. % if not lib.get('external_deps', None):
  952. $(E) "[STRIP] Stripping lib${lib.name}.a"
  953. $(Q) $(STRIP) $(LIBDIR)/$(CONFIG)/lib${lib.name}.a
  954. % endif
  955. % endif
  956. % endif
  957. % endfor
  958. ifeq ($(HAS_ZOOKEEPER),true)
  959. % for lib in libs:
  960. % if lib.language == "c":
  961. % if lib.build == "all":
  962. % if 'zookeeper' in lib.get('external_deps', []):
  963. $(E) "[STRIP] Stripping lib${lib.name}.a"
  964. $(Q) $(STRIP) $(LIBDIR)/$(CONFIG)/lib${lib.name}.a
  965. % endif
  966. % endif
  967. % endif
  968. % endfor
  969. endif
  970. endif
  971. strip-static_cxx: static_cxx
  972. ifeq ($(CONFIG),opt)
  973. % for lib in libs:
  974. % if lib.language == "c++":
  975. % if lib.build == "all":
  976. $(E) "[STRIP] Stripping lib${lib.name}.a"
  977. $(Q) $(STRIP) $(LIBDIR)/$(CONFIG)/lib${lib.name}.a
  978. % endif
  979. % endif
  980. % endfor
  981. endif
  982. strip-shared_c: shared_c
  983. ifeq ($(CONFIG),opt)
  984. % for lib in libs:
  985. % if lib.language == "c":
  986. % if lib.build == "all":
  987. % if not lib.get('external_deps', None):
  988. $(E) "[STRIP] Stripping lib${lib.name}.so"
  989. $(Q) $(STRIP) $(LIBDIR)/$(CONFIG)/lib${lib.name}.$(SHARED_EXT)
  990. % endif
  991. % endif
  992. % endif
  993. % endfor
  994. ifeq ($(HAS_ZOOKEEPER),true)
  995. % for lib in libs:
  996. % if lib.language == "c":
  997. % if lib.build == "all":
  998. % if 'zookeeper' in lib.get('external_deps', []):
  999. $(E) "[STRIP] Stripping lib${lib.name}.so"
  1000. $(Q) $(STRIP) $(LIBDIR)/$(CONFIG)/lib${lib.name}.$(SHARED_EXT)
  1001. % endif
  1002. % endif
  1003. % endif
  1004. % endfor
  1005. endif
  1006. endif
  1007. strip-shared_cxx: shared_cxx
  1008. ifeq ($(CONFIG),opt)
  1009. % for lib in libs:
  1010. % if lib.language == "c++":
  1011. % if lib.build == "all":
  1012. $(E) "[STRIP] Stripping lib${lib.name}.so"
  1013. $(Q) $(STRIP) $(LIBDIR)/$(CONFIG)/lib${lib.name}.$(SHARED_EXT)
  1014. % endif
  1015. % endif
  1016. % endfor
  1017. endif
  1018. strip-shared_csharp: shared_csharp
  1019. ifeq ($(CONFIG),opt)
  1020. % for lib in libs:
  1021. % if lib.language == "csharp":
  1022. % if lib.build == "all":
  1023. $(E) "[STRIP] Stripping lib${lib.name}.so"
  1024. $(Q) $(STRIP) $(LIBDIR)/$(CONFIG)/lib${lib.name}.$(SHARED_EXT)
  1025. % endif
  1026. % endif
  1027. % endfor
  1028. endif
  1029. cache.mk::
  1030. $(E) "[MAKE] Generating $@"
  1031. $(Q) echo "$(CACHE_MK)" | tr , '\n' >$@
  1032. $(LIBDIR)/$(CONFIG)/pkgconfig/gpr.pc:
  1033. $(E) "[MAKE] Generating $@"
  1034. $(Q) mkdir -p $(@D)
  1035. $(Q) echo "$(GPR_PC_FILE)" | tr , '\n' >$@
  1036. $(LIBDIR)/$(CONFIG)/pkgconfig/grpc.pc:
  1037. $(E) "[MAKE] Generating $@"
  1038. $(Q) mkdir -p $(@D)
  1039. $(Q) echo "$(GRPC_PC_FILE)" | tr , '\n' >$@
  1040. $(LIBDIR)/$(CONFIG)/pkgconfig/grpc_unsecure.pc:
  1041. $(E) "[MAKE] Generating $@"
  1042. $(Q) mkdir -p $(@D)
  1043. $(Q) echo "$(GRPC_UNSECURE_PC_FILE)" | tr , '\n' >$@
  1044. $(LIBDIR)/$(CONFIG)/pkgconfig/grpc_zookeeper.pc:
  1045. $(E) "[MAKE] Generating $@"
  1046. $(Q) mkdir -p $(@D)
  1047. $(Q) echo -e "$(GRPC_ZOOKEEPER_PC_FILE)" >$@
  1048. $(LIBDIR)/$(CONFIG)/pkgconfig/grpc++.pc:
  1049. $(E) "[MAKE] Generating $@"
  1050. $(Q) mkdir -p $(@D)
  1051. $(Q) echo "$(GRPCXX_PC_FILE)" | tr , '\n' >$@
  1052. $(LIBDIR)/$(CONFIG)/pkgconfig/grpc++_unsecure.pc:
  1053. $(E) "[MAKE] Generating $@"
  1054. $(Q) mkdir -p $(@D)
  1055. $(Q) echo "$(GRPCXX_UNSECURE_PC_FILE)" | tr , '\n' >$@
  1056. % for p in protos:
  1057. ifeq ($(NO_PROTOC),true)
  1058. $(GENDIR)/${p}.pb.cc: protoc_dep_error
  1059. $(GENDIR)/${p}.grpc.pb.cc: protoc_dep_error
  1060. else
  1061. $(GENDIR)/${p}.pb.cc: ${p}.proto $(PROTOBUF_DEP) $(PROTOC_PLUGINS) ${' '.join('$(GENDIR)/%s.pb.cc' % q for q in proto_deps.get(p, []))}
  1062. $(E) "[PROTOC] Generating protobuf CC file from $<"
  1063. $(Q) mkdir -p `dirname $@`
  1064. $(Q) $(PROTOC) --cpp_out=$(GENDIR) $<
  1065. $(GENDIR)/${p}.grpc.pb.cc: ${p}.proto $(PROTOBUF_DEP) $(PROTOC_PLUGINS) ${' '.join('$(GENDIR)/%s.pb.cc $(GENDIR)/%s.grpc.pb.cc' % (q,q) for q in proto_deps.get(p, []))}
  1066. $(E) "[GRPC] Generating gRPC's protobuf service CC file from $<"
  1067. $(Q) mkdir -p `dirname $@`
  1068. $(Q) $(PROTOC) --grpc_out=$(GENDIR) --plugin=protoc-gen-grpc=$(BINDIR)/$(CONFIG)/grpc_cpp_plugin $<
  1069. endif
  1070. % endfor
  1071. ifeq ($(CONFIG),stapprof)
  1072. src/core/profiling/stap_timers.c: $(GENDIR)/src/core/profiling/stap_probes.h
  1073. ifeq ($(HAS_SYSTEMTAP),true)
  1074. $(GENDIR)/src/core/profiling/stap_probes.h: src/core/profiling/stap_probes.d
  1075. $(E) "[DTRACE] Compiling $<"
  1076. $(Q) mkdir -p `dirname $@`
  1077. $(Q) $(DTRACE) -C -h -s $< -o $@
  1078. else
  1079. $(GENDIR)/src/core/profiling/stap_probes.h: systemtap_dep_error stop
  1080. endif
  1081. endif
  1082. $(OBJDIR)/$(CONFIG)/%.o : %.c
  1083. $(E) "[C] Compiling $<"
  1084. $(Q) mkdir -p `dirname $@`
  1085. $(Q) $(CC) $(CFLAGS) $(CPPFLAGS) -MMD -MF $(addsuffix .dep, $(basename $@)) -c -o $@ $<
  1086. $(OBJDIR)/$(CONFIG)/%.o : $(GENDIR)/%.pb.cc
  1087. $(E) "[CXX] Compiling $<"
  1088. $(Q) mkdir -p `dirname $@`
  1089. $(Q) $(CXX) $(CXXFLAGS) $(CPPFLAGS) -MMD -MF $(addsuffix .dep, $(basename $@)) -c -o $@ $<
  1090. $(OBJDIR)/$(CONFIG)/src/compiler/%.o : src/compiler/%.cc
  1091. $(E) "[HOSTCXX] Compiling $<"
  1092. $(Q) mkdir -p `dirname $@`
  1093. $(Q) $(HOST_CXX) $(HOST_CXXFLAGS) $(HOST_CPPFLAGS) -MMD -MF $(addsuffix .dep, $(basename $@)) -c -o $@ $<
  1094. $(OBJDIR)/$(CONFIG)/%.o : %.cc
  1095. $(E) "[CXX] Compiling $<"
  1096. $(Q) mkdir -p `dirname $@`
  1097. $(Q) $(CXX) $(CXXFLAGS) $(CPPFLAGS) -MMD -MF $(addsuffix .dep, $(basename $@)) -c -o $@ $<
  1098. install: install_c install_cxx install-plugins install-certs verify-install
  1099. install_c: install-headers_c install-static_c install-shared_c
  1100. install_cxx: install-headers_cxx install-static_cxx install-shared_cxx
  1101. install_csharp: install-shared_csharp install_c
  1102. install_grpc_csharp_ext: install_csharp
  1103. install-headers: install-headers_c install-headers_cxx
  1104. install-headers_c:
  1105. $(E) "[INSTALL] Installing public C headers"
  1106. $(Q) $(foreach h, $(PUBLIC_HEADERS_C), $(INSTALL) -d $(prefix)/$(dir $(h)) && ) exit 0 || exit 1
  1107. $(Q) $(foreach h, $(PUBLIC_HEADERS_C), $(INSTALL) $(h) $(prefix)/$(h) && ) exit 0 || exit 1
  1108. install-headers_cxx:
  1109. $(E) "[INSTALL] Installing public C++ headers"
  1110. $(Q) $(foreach h, $(PUBLIC_HEADERS_CXX), $(INSTALL) -d $(prefix)/$(dir $(h)) && ) exit 0 || exit 1
  1111. $(Q) $(foreach h, $(PUBLIC_HEADERS_CXX), $(INSTALL) $(h) $(prefix)/$(h) && ) exit 0 || exit 1
  1112. install-static: install-static_c install-static_cxx
  1113. install-static_c: static_c strip-static_c install-pkg-config_c
  1114. % for lib in libs:
  1115. % if lib.language == "c":
  1116. % if lib.build == "all":
  1117. % if not lib.get('external_deps', None):
  1118. $(E) "[INSTALL] Installing lib${lib.name}.a"
  1119. $(Q) $(INSTALL) -d $(prefix)/lib
  1120. $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/lib${lib.name}.a $(prefix)/lib/lib${lib.name}.a
  1121. % endif
  1122. % endif
  1123. % endif
  1124. % endfor
  1125. ifeq ($(HAS_ZOOKEEPER),true)
  1126. % for lib in libs:
  1127. % if lib.language == "c":
  1128. % if lib.build == "all":
  1129. % if 'zookeeper' in lib.get('external_deps', []):
  1130. $(E) "[INSTALL] Installing lib${lib.name}.a"
  1131. $(Q) $(INSTALL) -d $(prefix)/lib
  1132. $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/lib${lib.name}.a $(prefix)/lib/lib${lib.name}.a
  1133. % endif
  1134. % endif
  1135. % endif
  1136. % endfor
  1137. endif
  1138. install-static_cxx: static_cxx strip-static_cxx install-pkg-config_cxx
  1139. % for lib in libs:
  1140. % if lib.language == "c++":
  1141. % if lib.build == "all":
  1142. $(E) "[INSTALL] Installing lib${lib.name}.a"
  1143. $(Q) $(INSTALL) -d $(prefix)/lib
  1144. $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/lib${lib.name}.a $(prefix)/lib/lib${lib.name}.a
  1145. % endif
  1146. % endif
  1147. % endfor
  1148. <%def name="install_shared(lang_filter)">\
  1149. % for lib in libs:
  1150. % if lib.language == lang_filter:
  1151. % if lib.build == "all":
  1152. % if not lib.get('external_deps', None):
  1153. ifeq ($(SYSTEM),MINGW32)
  1154. $(E) "[INSTALL] Installing ${lib.name}.$(SHARED_EXT)"
  1155. $(Q) $(INSTALL) -d $(prefix)/lib
  1156. $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/${lib.name}.$(SHARED_EXT) $(prefix)/lib/${lib.name}.$(SHARED_EXT)
  1157. $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/lib${lib.name}-imp.a $(prefix)/lib/lib${lib.name}-imp.a
  1158. else
  1159. $(E) "[INSTALL] Installing lib${lib.name}.$(SHARED_EXT)"
  1160. $(Q) $(INSTALL) -d $(prefix)/lib
  1161. $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/lib${lib.name}.$(SHARED_EXT) $(prefix)/lib/lib${lib.name}.$(SHARED_EXT)
  1162. ifneq ($(SYSTEM),Darwin)
  1163. $(Q) ln -sf lib${lib.name}.$(SHARED_EXT) $(prefix)/lib/lib${lib.name}.so.${settings.version.major}
  1164. $(Q) ln -sf lib${lib.name}.$(SHARED_EXT) $(prefix)/lib/lib${lib.name}.so
  1165. endif
  1166. endif
  1167. % endif
  1168. % endif
  1169. % endif
  1170. % endfor
  1171. ifeq ($(HAS_ZOOKEEPER),true)
  1172. % for lib in libs:
  1173. % if lib.language == lang_filter:
  1174. % if lib.build == "all":
  1175. % if 'zookeeper' in lib.get('external_deps', []):
  1176. ifeq ($(SYSTEM),MINGW32)
  1177. $(E) "[INSTALL] Installing ${lib.name}.$(SHARED_EXT)"
  1178. $(Q) $(INSTALL) -d $(prefix)/lib
  1179. $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/${lib.name}.$(SHARED_EXT) $(prefix)/lib/${lib.name}.$(SHARED_EXT)
  1180. $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/lib${lib.name}-imp.a $(prefix)/lib/lib${lib.name}-imp.a
  1181. else
  1182. $(E) "[INSTALL] Installing lib${lib.name}.$(SHARED_EXT)"
  1183. $(Q) $(INSTALL) -d $(prefix)/lib
  1184. $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/lib${lib.name}.$(SHARED_EXT) $(prefix)/lib/lib${lib.name}.$(SHARED_EXT)
  1185. ifneq ($(SYSTEM),Darwin)
  1186. $(Q) ln -sf lib${lib.name}.$(SHARED_EXT) $(prefix)/lib/lib${lib.name}.so.${settings.version.major}
  1187. $(Q) ln -sf lib${lib.name}.$(SHARED_EXT) $(prefix)/lib/lib${lib.name}.so
  1188. endif
  1189. endif
  1190. % endif
  1191. % endif
  1192. % endif
  1193. % endfor
  1194. endif
  1195. ifneq ($(SYSTEM),MINGW32)
  1196. ifneq ($(SYSTEM),Darwin)
  1197. $(Q) ldconfig || true
  1198. endif
  1199. endif
  1200. </%def>
  1201. install-shared_c: shared_c strip-shared_c install-pkg-config_c
  1202. ${install_shared("c")}
  1203. install-shared_cxx: shared_cxx strip-shared_cxx install-shared_c install-pkg-config_cxx
  1204. ${install_shared("c++")}
  1205. install-shared_csharp: shared_csharp strip-shared_csharp
  1206. ${install_shared("csharp")}
  1207. install-plugins: $(PROTOC_PLUGINS)
  1208. ifeq ($(SYSTEM),MINGW32)
  1209. $(Q) false
  1210. else
  1211. $(E) "[INSTALL] Installing grpc protoc plugins"
  1212. % for tgt in targets:
  1213. % if tgt.build == 'protoc':
  1214. $(Q) $(INSTALL) -d $(prefix)/bin
  1215. $(Q) $(INSTALL) $(BINDIR)/$(CONFIG)/${tgt.name} $(prefix)/bin/${tgt.name}
  1216. % endif
  1217. % endfor
  1218. endif
  1219. install-pkg-config_c: pc_gpr pc_c pc_c_unsecure pc_c_zookeeper
  1220. $(E) "[INSTALL] Installing C pkg-config files"
  1221. $(Q) $(INSTALL) -d $(prefix)/lib/pkgconfig
  1222. $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/pkgconfig/gpr.pc $(prefix)/lib/pkgconfig/gpr.pc
  1223. $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/pkgconfig/grpc.pc $(prefix)/lib/pkgconfig/grpc.pc
  1224. $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/pkgconfig/grpc_unsecure.pc $(prefix)/lib/pkgconfig/grpc_unsecure.pc
  1225. ifeq ($(HAS_ZOOKEEPER),true)
  1226. $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/pkgconfig/grpc_zookeeper.pc $(prefix)/lib/pkgconfig/grpc_zookeeper.pc
  1227. endif
  1228. install-pkg-config_cxx: pc_cxx pc_cxx_unsecure
  1229. $(E) "[INSTALL] Installing C++ pkg-config files"
  1230. $(Q) $(INSTALL) -d $(prefix)/lib/pkgconfig
  1231. $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/pkgconfig/grpc++.pc $(prefix)/lib/pkgconfig/grpc++.pc
  1232. $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/pkgconfig/grpc++_unsecure.pc $(prefix)/lib/pkgconfig/grpc++_unsecure.pc
  1233. install-certs: etc/roots.pem
  1234. $(E) "[INSTALL] Installing root certificates"
  1235. $(Q) $(INSTALL) -d $(prefix)/share/grpc
  1236. $(Q) $(INSTALL) etc/roots.pem $(prefix)/share/grpc/roots.pem
  1237. verify-install:
  1238. ifeq ($(INSTALL_OK),true)
  1239. @echo "Your system looks ready to go."
  1240. @echo
  1241. else
  1242. @echo "We couldn't find protoc 3.0.0+ installed on your system. While this"
  1243. @echo "won't prevent grpc from working, you won't be able to compile"
  1244. @echo "and run any meaningful code with it."
  1245. @echo
  1246. @echo
  1247. @echo "Please download and install protobuf 3.0.0+ from:"
  1248. @echo
  1249. @echo " https://github.com/google/protobuf/releases"
  1250. @echo
  1251. @echo "Once you've done so, or if you think this message is in error,"
  1252. @echo "you can re-run this check by doing:"
  1253. @echo
  1254. @echo " make verify-install"
  1255. endif
  1256. clean:
  1257. $(E) "[CLEAN] Cleaning build directories."
  1258. $(Q) $(RM) -rf $(OBJDIR) $(LIBDIR) $(BINDIR) $(GENDIR) cache.mk
  1259. # The various libraries
  1260. % for lib in libs:
  1261. ${makelib(lib)}
  1262. % endfor
  1263. # All of the test targets, and protoc plugins
  1264. % for tgt in targets:
  1265. ${maketarget(tgt)}
  1266. % endfor
  1267. <%def name="makelib(lib)">
  1268. LIB${lib.name.upper()}_SRC = \\
  1269. % for src in lib.src:
  1270. ${proto_to_cc(src)} \\
  1271. % endfor
  1272. % if "public_headers" in lib:
  1273. % if lib.language == "c++":
  1274. PUBLIC_HEADERS_CXX += \\
  1275. % else:
  1276. PUBLIC_HEADERS_C += \\
  1277. % endif
  1278. % for hdr in lib.public_headers:
  1279. ${hdr} \\
  1280. % endfor
  1281. % endif
  1282. LIB${lib.name.upper()}_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(LIB${lib.name.upper()}_SRC))))
  1283. % if lib.boringssl:
  1284. # boringssl needs an override to ensure that it does not include
  1285. # system openssl headers regardless of other configuration
  1286. # we do so here with a target specific variable assignment
  1287. $(LIB${lib.name.upper()}_OBJS): CFLAGS := -Ithird_party/boringssl/include $(CFLAGS) -Wno-sign-conversion -Wno-conversion -Wno-unused-value -fvisibility=hidden
  1288. $(LIB${lib.name.upper()}_OBJS): CXXFLAGS := -Ithird_party/boringssl/include $(CXXFLAGS) -fvisibility=hidden
  1289. $(LIB${lib.name.upper()}_OBJS): CPPFLAGS += -DOPENSSL_NO_ASM -D_GNU_SOURCE
  1290. % else:
  1291. % endif
  1292. ## If the library requires OpenSSL, let's add some restrictions.
  1293. % if lib.get('secure', 'check') == True or lib.get('secure', 'check') == 'check':
  1294. ifeq ($(NO_SECURE),true)
  1295. # You can't build secure libraries if you don't have OpenSSL.
  1296. $(LIBDIR)/$(CONFIG)/lib${lib.name}.a: openssl_dep_error
  1297. % if lib.build == "all":
  1298. ifeq ($(SYSTEM),MINGW32)
  1299. $(LIBDIR)/$(CONFIG)/${lib.name}.$(SHARED_EXT): openssl_dep_error
  1300. else
  1301. $(LIBDIR)/$(CONFIG)/lib${lib.name}.$(SHARED_EXT): openssl_dep_error
  1302. endif
  1303. % endif
  1304. else
  1305. % if lib.language == 'c++':
  1306. ifeq ($(NO_PROTOBUF),true)
  1307. # You can't build a C++ library if you don't have protobuf - a bit overreached, but still okay.
  1308. $(LIBDIR)/$(CONFIG)/lib${lib.name}.a: protobuf_dep_error
  1309. % if lib.build == "all":
  1310. ifeq ($(SYSTEM),MINGW32)
  1311. $(LIBDIR)/$(CONFIG)/${lib.name}.$(SHARED_EXT): protobuf_dep_error
  1312. else
  1313. $(LIBDIR)/$(CONFIG)/lib${lib.name}.$(SHARED_EXT): protobuf_dep_error
  1314. endif
  1315. % endif
  1316. else
  1317. % endif
  1318. $(LIBDIR)/$(CONFIG)/lib${lib.name}.a: $(ZLIB_DEP) $(OPENSSL_DEP)\
  1319. ## The else here corresponds to the if secure earlier.
  1320. % else:
  1321. % if lib.language == 'c++':
  1322. ifeq ($(NO_PROTOBUF),true)
  1323. # You can't build a C++ library if you don't have protobuf - a bit overreached, but still okay.
  1324. $(LIBDIR)/$(CONFIG)/lib${lib.name}.a: protobuf_dep_error
  1325. % if lib.build == "all":
  1326. ifeq ($(SYSTEM),MINGW32)
  1327. $(LIBDIR)/$(CONFIG)/${lib.name}.$(SHARED_EXT): protobuf_dep_error
  1328. else
  1329. $(LIBDIR)/$(CONFIG)/lib${lib.name}.$(SHARED_EXT): protobuf_dep_error
  1330. endif
  1331. % endif
  1332. else
  1333. % endif
  1334. $(LIBDIR)/$(CONFIG)/lib${lib.name}.a: $(ZLIB_DEP) $(OPENSSL_DEP) \
  1335. % endif
  1336. % if lib.language == 'c++':
  1337. $(PROTOBUF_DEP)\
  1338. % endif
  1339. $(LIB${lib.name.upper()}_OBJS)
  1340. $(E) "[AR] Creating $@"
  1341. $(Q) mkdir -p `dirname $@`
  1342. $(Q) rm -f $(LIBDIR)/$(CONFIG)/lib${lib.name}.a
  1343. $(Q) $(AR) rcs $(LIBDIR)/$(CONFIG)/lib${lib.name}.a $(LIB${lib.name.upper()}_OBJS)
  1344. % if lib.get('baselib', False):
  1345. $(Q) rm -rf $(BUILDDIR_ABSOLUTE)/tmp-merge-${lib.name}
  1346. $(Q) ( mkdir -p $(BUILDDIR_ABSOLUTE)/tmp-merge-${lib.name}/grpc ; <%text>\</%text>
  1347. cd $(BUILDDIR_ABSOLUTE)/tmp-merge-${lib.name}/grpc ; <%text>\</%text>
  1348. $(AR) x $(LIBDIR)/$(CONFIG)/lib${lib.name}.a )
  1349. $(Q) for l in $(ZLIB_MERGE_LIBS) ; do ( <%text>\</%text>
  1350. mkdir -p $(BUILDDIR_ABSOLUTE)/tmp-merge-${lib.name}/zlib ; <%text>\</%text>
  1351. cd $(BUILDDIR_ABSOLUTE)/tmp-merge-${lib.name}/zlib ; <%text>\</%text>
  1352. <%text>$(AR) x $${l}</%text> ) ; done
  1353. $(Q) for l in $(ZLIB_MERGE_LIBS) ; do ( <%text>\</%text>
  1354. mkdir -p $(BUILDDIR_ABSOLUTE)/tmp-merge-${lib.name}/zlib ; <%text>\</%text>
  1355. cd $(BUILDDIR_ABSOLUTE)/tmp-merge-${lib.name}/zlib ; <%text>\</%text>
  1356. <%text>$(AR) x $${l}</%text> ) ; done
  1357. % if lib.get('secure', 'check') == True:
  1358. $(Q) for l in $(OPENSSL_MERGE_LIBS) ; do ( <%text>\</%text>
  1359. mkdir -p $(BUILDDIR_ABSOLUTE)/tmp-merge-${lib.name}/ssl ; <%text>\</%text>
  1360. cd $(BUILDDIR_ABSOLUTE)/tmp-merge-${lib.name}/ssl ; <%text>\</%text>
  1361. <%text>$(AR) x $${l}</%text> ) ; done
  1362. $(Q) for l in $(OPENSSL_MERGE_LIBS) ; do ( <%text>\</%text>
  1363. mkdir -p $(BUILDDIR_ABSOLUTE)/tmp-merge-${lib.name}/ssl ; <%text>\</%text>
  1364. cd $(BUILDDIR_ABSOLUTE)/tmp-merge-${lib.name}/ssl ; <%text>\</%text>
  1365. <%text>$(AR) x $${l}</%text> ) ; done
  1366. % endif
  1367. $(Q) rm -f $(LIBDIR)/$(CONFIG)/lib${lib.name}.a $(BUILDDIR_ABSOLUTE)/tmp-merge-${lib.name}/*/__.SYMDEF*
  1368. $(Q) ar rcs $(LIBDIR)/$(CONFIG)/lib${lib.name}.a $(BUILDDIR_ABSOLUTE)/tmp-merge-${lib.name}/*/*
  1369. $(Q) rm -rf $(BUILDDIR_ABSOLUTE)/tmp-merge-${lib.name}
  1370. % endif
  1371. ifeq ($(SYSTEM),Darwin)
  1372. $(Q) ranlib $(LIBDIR)/$(CONFIG)/lib${lib.name}.a
  1373. endif
  1374. <%
  1375. if lib.language == 'c++':
  1376. ld = '$(LDXX)'
  1377. else:
  1378. ld = '$(LD)'
  1379. out_base = '$(LIBDIR)/$(CONFIG)/' + lib.name
  1380. out_libbase = '$(LIBDIR)/$(CONFIG)/lib' + lib.name
  1381. common = '$(LIB' + lib.name.upper() + '_OBJS) $(LDLIBS)'
  1382. libs = ''
  1383. lib_deps = ' $(ZLIB_DEP)'
  1384. mingw_libs = ''
  1385. mingw_lib_deps = ' $(ZLIB_DEP)'
  1386. if lib.language == 'c++':
  1387. lib_deps += ' $(PROTOBUF_DEP)'
  1388. mingw_lib_deps += ' $(PROTOBUF_DEP)'
  1389. if lib.get('deps_linkage', None) == 'static':
  1390. for dep in lib.get('deps', []):
  1391. lib_archive = '$(LIBDIR)/$(CONFIG)/lib' + dep + '.a'
  1392. common = common + ' ' + lib_archive
  1393. lib_deps = lib_deps + ' ' + lib_archive
  1394. mingw_lib_deps = mingw_lib_deps + ' ' + lib_archive
  1395. else:
  1396. for dep in lib.get('deps', []):
  1397. libs = libs + ' -l' + dep
  1398. lib_deps = lib_deps + ' $(LIBDIR)/$(CONFIG)/lib' + dep + '.$(SHARED_EXT)'
  1399. mingw_libs = mingw_libs + ' -l' + dep + '-imp'
  1400. mingw_lib_deps = mingw_lib_deps + ' $(LIBDIR)/$(CONFIG)/' + dep + '.$(SHARED_EXT)'
  1401. security = lib.get('secure', 'check')
  1402. if security == True:
  1403. common = common + ' $(OPENSSL_MERGE_LIBS) $(LDLIBS_SECURE)'
  1404. common = common + ' $(ZLIB_MERGE_LIBS)'
  1405. if security in [True, 'check']:
  1406. for src in lib.src:
  1407. if not proto_re.match(src):
  1408. sources_that_need_openssl.add(src)
  1409. else:
  1410. for src in lib.src:
  1411. sources_that_don_t_need_openssl.add(src)
  1412. if 'zookeeper' in lib.get('external_deps', []):
  1413. libs = libs + ' -lzookeeper_mt'
  1414. if lib.get('secure', 'check') == True or lib.get('secure', 'check') == 'check':
  1415. lib_deps = lib_deps + ' $(OPENSSL_DEP)'
  1416. mingw_lib_deps = mingw_lib_deps + ' $(OPENSSL_DEP)'
  1417. if lib.language == 'c++':
  1418. common = common + ' $(LDLIBSXX) $(LDLIBS_PROTOBUF)'
  1419. %>
  1420. % if lib.build == "all":
  1421. ifeq ($(SYSTEM),MINGW32)
  1422. ${out_base}.$(SHARED_EXT): $(LIB${lib.name.upper()}_OBJS) ${mingw_lib_deps}
  1423. $(E) "[LD] Linking $@"
  1424. $(Q) mkdir -p `dirname $@`
  1425. $(Q) ${ld} $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,--output-def=${out_base}.def -Wl,--out-implib=${out_libbase}-imp.a -o ${out_base}.$(SHARED_EXT) ${common}${mingw_libs}
  1426. else
  1427. ${out_libbase}.$(SHARED_EXT): $(LIB${lib.name.upper()}_OBJS) ${lib_deps}
  1428. $(E) "[LD] Linking $@"
  1429. $(Q) mkdir -p `dirname $@`
  1430. ifeq ($(SYSTEM),Darwin)
  1431. $(Q) ${ld} $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -install_name lib${lib.name}.$(SHARED_EXT) -dynamiclib -o ${out_libbase}.$(SHARED_EXT) ${common}${libs}
  1432. else
  1433. $(Q) ${ld} $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,-soname,lib${lib.name}.so.${settings.version.major} -o ${out_libbase}.$(SHARED_EXT) ${common}${libs}
  1434. $(Q) ln -sf lib${lib.name}.$(SHARED_EXT) ${out_libbase}.so.${settings.version.major}
  1435. $(Q) ln -sf lib${lib.name}.$(SHARED_EXT) ${out_libbase}.so
  1436. endif
  1437. endif
  1438. % endif
  1439. % if lib.get('secure', 'check') == True or lib.get('secure', 'check') == 'check':
  1440. ## If the lib was secure, we have to close the Makefile's if that tested
  1441. ## the presence of OpenSSL.
  1442. endif
  1443. % endif
  1444. % if lib.language == 'c++':
  1445. ## If the lib was C++, we have to close the Makefile's if that tested
  1446. ## the presence of protobuf 3.0.0+
  1447. endif
  1448. % endif
  1449. % if lib.get('secure', 'check') == True or lib.get('secure', 'check') == 'check':
  1450. ifneq ($(NO_SECURE),true)
  1451. % endif
  1452. ifneq ($(NO_DEPS),true)
  1453. -include $(LIB${lib.name.upper()}_OBJS:.o=.dep)
  1454. endif
  1455. % if lib.get('secure', 'check') == True or lib.get('secure', 'check') == 'check':
  1456. endif
  1457. % endif
  1458. % for src in lib.src:
  1459. % if not proto_re.match(src) and any(proto_re.match(src2) for src2 in lib.src):
  1460. $(OBJDIR)/$(CONFIG)/${os.path.splitext(src)[0]}.o: ${' '.join(proto_to_cc(src2) for src2 in lib.src if proto_re.match(src2))}
  1461. % endif
  1462. % endfor
  1463. </%def>
  1464. <%def name="maketarget(tgt)"><% has_no_sources = not tgt.src %>
  1465. % if not has_no_sources:
  1466. ${tgt.name.upper()}_SRC = \\
  1467. % for src in tgt.src:
  1468. ${proto_to_cc(src)} \\
  1469. % endfor
  1470. ${tgt.name.upper()}_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(${tgt.name.upper()}_SRC))))
  1471. % endif
  1472. % if tgt.get('secure', 'check') == True or tgt.get('secure', 'check') == 'check':
  1473. ifeq ($(NO_SECURE),true)
  1474. # You can't build secure targets if you don't have OpenSSL.
  1475. $(BINDIR)/$(CONFIG)/${tgt.name}: openssl_dep_error
  1476. else
  1477. % endif
  1478. % if tgt.boringssl:
  1479. # boringssl needs an override to ensure that it does not include
  1480. # system openssl headers regardless of other configuration
  1481. # we do so here with a target specific variable assignment
  1482. $(${tgt.name.upper()}_OBJS): CFLAGS := -Ithird_party/boringssl/include $(CFLAGS) -Wno-sign-conversion -Wno-conversion -Wno-unused-value
  1483. $(${tgt.name.upper()}_OBJS): CXXFLAGS := -Ithird_party/boringssl/include $(CXXFLAGS)
  1484. $(${tgt.name.upper()}_OBJS): CPPFLAGS += -DOPENSSL_NO_ASM -D_GNU_SOURCE
  1485. % else:
  1486. % endif
  1487. ##
  1488. ## We're not trying to add a dependency on building zlib and openssl here,
  1489. ## as it's already done in the libraries. We're assuming that the build
  1490. ## trickles down, and that a secure target requires a secure version of
  1491. ## a library.
  1492. ##
  1493. ## That simplifies the codegen a bit, but prevents a fully defined Makefile.
  1494. ## I can live with that.
  1495. ##
  1496. % if tgt.build == 'protoc' or tgt.language == 'c++':
  1497. ifeq ($(NO_PROTOBUF),true)
  1498. # You can't build the protoc plugins or protobuf-enabled targets if you don't have protobuf 3.0.0+.
  1499. $(BINDIR)/$(CONFIG)/${tgt.name}: protobuf_dep_error
  1500. else
  1501. $(BINDIR)/$(CONFIG)/${tgt.name}: \
  1502. % if not has_no_sources:
  1503. $(PROTOBUF_DEP) $(${tgt.name.upper()}_OBJS)\
  1504. % endif
  1505. % else:
  1506. $(BINDIR)/$(CONFIG)/${tgt.name}: \
  1507. % if not has_no_sources:
  1508. $(${tgt.name.upper()}_OBJS)\
  1509. % endif
  1510. % endif
  1511. % for dep in tgt.deps:
  1512. $(LIBDIR)/$(CONFIG)/lib${dep}.a\
  1513. % endfor
  1514. % if tgt.language == "c++" or tgt.boringssl:
  1515. ## C++ targets specificies.
  1516. % if tgt.build == 'protoc':
  1517. $(E) "[HOSTLD] Linking $@"
  1518. $(Q) mkdir -p `dirname $@`
  1519. $(Q) $(HOST_LDXX) $(HOST_LDFLAGS) \
  1520. % if not has_no_sources:
  1521. $(${tgt.name.upper()}_OBJS)\
  1522. % endif
  1523. % else:
  1524. $(E) "[LD] Linking $@"
  1525. $(Q) mkdir -p `dirname $@`
  1526. $(Q) $(LDXX) $(LDFLAGS) \
  1527. % if not has_no_sources:
  1528. $(${tgt.name.upper()}_OBJS)\
  1529. % endif
  1530. % endif
  1531. % else:
  1532. ## C-only targets specificities.
  1533. $(E) "[LD] Linking $@"
  1534. $(Q) mkdir -p `dirname $@`
  1535. $(Q) $(LD) $(LDFLAGS) \
  1536. % if not has_no_sources:
  1537. $(${tgt.name.upper()}_OBJS)\
  1538. % endif
  1539. % endif
  1540. % for dep in tgt.deps:
  1541. $(LIBDIR)/$(CONFIG)/lib${dep}.a\
  1542. % endfor
  1543. % if 'zookeeper' in tgt.get('external_deps', []):
  1544. -lzookeeper_mt\
  1545. % endif
  1546. % if tgt.language == "c++":
  1547. % if tgt.build == 'protoc':
  1548. $(HOST_LDLIBSXX) $(HOST_LDLIBS_PROTOC)\
  1549. % else:
  1550. $(LDLIBSXX) $(LDLIBS_PROTOBUF)\
  1551. % endif
  1552. % endif
  1553. % if tgt.build == 'protoc':
  1554. $(HOST_LDLIBS)\
  1555. % else:
  1556. $(LDLIBS)\
  1557. % endif
  1558. % if tgt.build == 'protoc':
  1559. $(HOST_LDLIBS_PROTOC)\
  1560. % elif tgt.get('secure', 'check') == True or tgt.get('secure', 'check') == 'check':
  1561. $(LDLIBS_SECURE)\
  1562. % endif
  1563. % if tgt.language == 'c++' and tgt.build == 'test':
  1564. $(GTEST_LIB)\
  1565. % elif tgt.language == 'c++' and tgt.build == 'benchmark':
  1566. $(GTEST_LIB)\
  1567. % endif
  1568. -o $(BINDIR)/$(CONFIG)/${tgt.name}
  1569. % if tgt.build == 'protoc' or tgt.language == 'c++':
  1570. endif
  1571. % endif
  1572. % if tgt.get('secure', 'check') == True or tgt.get('secure', 'check') == 'check':
  1573. endif
  1574. % endif
  1575. % for src in tgt.src:
  1576. $(OBJDIR)/$(CONFIG)/${os.path.splitext(src)[0]}.o: \
  1577. % for dep in tgt.deps:
  1578. $(LIBDIR)/$(CONFIG)/lib${dep}.a\
  1579. % endfor
  1580. % if tgt.language == 'c89':
  1581. % for src in tgt.src:
  1582. $(OBJDIR)/$(CONFIG)/${os.path.splitext(src)[0]}.o : ${src}
  1583. $(E) "[C] Compiling $<"
  1584. $(Q) mkdir -p `dirname $@`
  1585. $(Q) $(CC) $(CFLAGS) $(CPPFLAGS) -std=c89 -pedantic -MMD -MF $(addsuffix .dep, $(basename $@)) -c -o $@ $<
  1586. % endfor
  1587. % endif
  1588. % endfor
  1589. % if not has_no_sources:
  1590. deps_${tgt.name}: $(${tgt.name.upper()}_OBJS:.o=.dep)
  1591. % endif
  1592. % if not has_no_sources:
  1593. % if tgt.get('secure', 'check') == True or tgt.get('secure', 'check') == 'check':
  1594. ifneq ($(NO_SECURE),true)
  1595. % endif
  1596. ifneq ($(NO_DEPS),true)
  1597. -include $(${tgt.name.upper()}_OBJS:.o=.dep)
  1598. endif
  1599. % if tgt.get('secure', 'check') == True or tgt.get('secure', 'check') == 'check':
  1600. endif
  1601. % endif
  1602. % endif
  1603. % for src in tgt.src:
  1604. % if not proto_re.match(src) and any(proto_re.match(src2) for src2 in tgt.src):
  1605. $(OBJDIR)/$(CONFIG)/${os.path.splitext(src)[0]}.o: ${' '.join(proto_to_cc(src2) for src2 in tgt.src if proto_re.match(src2))}
  1606. % endif
  1607. % endfor
  1608. </%def>
  1609. ifneq ($(OPENSSL_DEP),)
  1610. # This is to ensure the embedded OpenSSL is built beforehand, properly
  1611. # installing headers to their final destination on the drive. We need this
  1612. # otherwise parallel compilation will fail if a source is compiled first.
  1613. % for src in sorted(sources_that_need_openssl):
  1614. % if src not in sources_that_don_t_need_openssl:
  1615. ${src}: $(OPENSSL_DEP)
  1616. % endif
  1617. % endfor
  1618. endif
  1619. .PHONY: all strip tools \
  1620. dep_error openssl_dep_error openssl_dep_message git_update stop \
  1621. buildtests buildtests_c buildtests_cxx \
  1622. test test_c test_cxx \
  1623. install install_c install_cxx \
  1624. install-headers install-headers_c install-headers_cxx \
  1625. install-shared install-shared_c install-shared_cxx \
  1626. install-static install-static_c install-static_cxx \
  1627. strip strip-shared strip-static \
  1628. strip_c strip-shared_c strip-static_c \
  1629. strip_cxx strip-shared_cxx strip-static_cxx \
  1630. dep_c dep_cxx bins_dep_c bins_dep_cxx \
  1631. clean