Makefile.template 59 KB

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