Makefile.template 30 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127
  1. # GRPC global makefile
  2. # This currently builds C and C++ code.
  3. # Copyright 2014, Google Inc.
  4. # All rights reserved.
  5. #
  6. # Redistribution and use in source and binary forms, with or without
  7. # modification, are permitted provided that the following conditions are
  8. # met:
  9. #
  10. # * Redistributions of source code must retain the above copyright
  11. # notice, this list of conditions and the following disclaimer.
  12. # * Redistributions in binary form must reproduce the above
  13. # copyright notice, this list of conditions and the following disclaimer
  14. # in the documentation and/or other materials provided with the
  15. # distribution.
  16. # * Neither the name of Google Inc. nor the names of its
  17. # contributors may be used to endorse or promote products derived from
  18. # this software without specific prior written permission.
  19. #
  20. # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  21. # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  22. # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  23. # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  24. # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  25. # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  26. # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  27. # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  28. # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  29. # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  30. # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  31. <%!
  32. import re
  33. import os
  34. proto_re = re.compile('(.*)\\.proto')
  35. def excluded(filename, exclude_res):
  36. for r in exclude_res:
  37. if r.match(filename):
  38. return True
  39. return False
  40. def proto_to_cc(filename):
  41. m = proto_re.match(filename)
  42. if not m:
  43. return filename
  44. return '$(GENDIR)/' + m.group(1) + '.pb.cc'
  45. %>
  46. # Basic platform detection
  47. HOST_SYSTEM = $(shell uname | cut -f 1 -d_)
  48. ifeq ($(SYSTEM),)
  49. SYSTEM = $(HOST_SYSTEM)
  50. endif
  51. ifndef BUILDDIR
  52. BUILDDIR = .
  53. endif
  54. BINDIR = $(BUILDDIR)/bins
  55. OBJDIR = $(BUILDDIR)/objs
  56. LIBDIR = $(BUILDDIR)/libs
  57. GENDIR = $(BUILDDIR)/gens
  58. # Configurations
  59. VALID_CONFIG_opt = 1
  60. CC_opt = gcc
  61. CXX_opt = g++
  62. LD_opt = gcc
  63. LDXX_opt = g++
  64. CPPFLAGS_opt = -O2
  65. LDFLAGS_opt =
  66. DEFINES_opt = NDEBUG
  67. VALID_CONFIG_dbg = 1
  68. CC_dbg = gcc
  69. CXX_dbg = g++
  70. LD_dbg = gcc
  71. LDXX_dbg = g++
  72. CPPFLAGS_dbg = -O0
  73. LDFLAGS_dbg =
  74. DEFINES_dbg = _DEBUG DEBUG
  75. VALID_CONFIG_valgrind = 1
  76. REQUIRE_CUSTOM_LIBRARIES_valgrind = 1
  77. CC_valgrind = gcc
  78. CXX_valgrind = g++
  79. LD_valgrind = gcc
  80. LDXX_valgrind = g++
  81. CPPFLAGS_valgrind = -O0
  82. OPENSSL_CFLAGS_valgrind = -DPURIFY
  83. LDFLAGS_valgrind =
  84. DEFINES_valgrind = _DEBUG DEBUG
  85. VALID_CONFIG_tsan = 1
  86. REQUIRE_CUSTOM_LIBRARIES_tsan = 1
  87. CC_tsan = clang
  88. CXX_tsan = clang++
  89. LD_tsan = clang
  90. LDXX_tsan = clang++
  91. CPPFLAGS_tsan = -O1 -fsanitize=thread -fno-omit-frame-pointer
  92. OPENSSL_CONFIG_tsan = no-asm
  93. LDFLAGS_tsan = -fsanitize=thread
  94. DEFINES_tsan = NDEBUG
  95. VALID_CONFIG_asan = 1
  96. REQUIRE_CUSTOM_LIBRARIES_asan = 1
  97. CC_asan = clang
  98. CXX_asan = clang++
  99. LD_asan = clang
  100. LDXX_asan = clang++
  101. CPPFLAGS_asan = -O1 -fsanitize=address -fno-omit-frame-pointer
  102. OPENSSL_CONFIG_asan = no-asm
  103. LDFLAGS_asan = -fsanitize=address
  104. DEFINES_asan = NDEBUG
  105. VALID_CONFIG_msan = 1
  106. REQUIRE_CUSTOM_LIBRARIES_msan = 1
  107. CC_msan = clang
  108. CXX_msan = clang++-libc++
  109. LD_msan = clang
  110. LDXX_msan = clang++-libc++
  111. CPPFLAGS_msan = -O1 -fsanitize=memory -fsanitize-memory-track-origins -fno-omit-frame-pointer -DGTEST_HAS_TR1_TUPLE=0 -DGTEST_USE_OWN_TR1_TUPLE=1
  112. OPENSSL_CFLAGS_msan = -DPURIFY
  113. OPENSSL_CONFIG_msan = no-asm
  114. LDFLAGS_msan = -fsanitize=memory -DGTEST_HAS_TR1_TUPLE=0 -DGTEST_USE_OWN_TR1_TUPLE=1
  115. DEFINES_msan = NDEBUG
  116. VALID_CONFIG_ubsan = 1
  117. REQUIRE_CUSTOM_LIBRARIES_ubsan = 1
  118. CC_ubsan = clang
  119. CXX_ubsan = clang++
  120. LD_ubsan = clang
  121. LDXX_ubsan = clang++
  122. CPPFLAGS_ubsan = -O1 -fsanitize=undefined -fno-omit-frame-pointer
  123. OPENSSL_CFLAGS_ubsan = -DPURIFY
  124. OPENSSL_CONFIG_ubsan = no-asm
  125. LDFLAGS_ubsan = -fsanitize=undefined
  126. DEFINES_ubsan = NDEBUG
  127. VALID_CONFIG_gcov = 1
  128. CC_gcov = gcc
  129. CXX_gcov = g++
  130. LD_gcov = gcc
  131. LDXX_gcov = g++
  132. CPPFLAGS_gcov = -O0 -fprofile-arcs -ftest-coverage
  133. LDFLAGS_gcov = -fprofile-arcs -ftest-coverage
  134. DEFINES_gcov = NDEBUG
  135. # General settings.
  136. # You may want to change these depending on your system.
  137. prefix ?= /usr/local
  138. PROTOC = protoc
  139. CONFIG ?= opt
  140. CC = $(CC_$(CONFIG))
  141. CXX = $(CXX_$(CONFIG))
  142. LD = $(LD_$(CONFIG))
  143. LDXX = $(LDXX_$(CONFIG))
  144. AR = ar
  145. STRIP = strip --strip-unneeded
  146. INSTALL = install -D
  147. RM = rm -f
  148. ifndef VALID_CONFIG_$(CONFIG)
  149. $(error Invalid CONFIG value '$(CONFIG)')
  150. endif
  151. # The HOST compiler settings are used to compile the protoc plugins.
  152. # In most cases, you won't have to change anything, but if you are
  153. # cross-compiling, you can override these variables from GNU make's
  154. # command line: make CC=cross-gcc HOST_CC=gcc
  155. HOST_CC = $(CC)
  156. HOST_CXX = $(CXX)
  157. HOST_LD = $(LD)
  158. HOST_LDXX = $(LDXX)
  159. CPPFLAGS += $(CPPFLAGS_$(CONFIG))
  160. DEFINES += $(DEFINES_$(CONFIG))
  161. LDFLAGS += $(LDFLAGS_$(CONFIG))
  162. CFLAGS += -std=c89 -pedantic
  163. CXXFLAGS += -std=c++11
  164. CPPFLAGS += -g -fPIC -Wall -Wextra -Werror -Wno-long-long -Wno-unused-parameter
  165. LDFLAGS += -g -fPIC
  166. INCLUDES = . include $(GENDIR)
  167. ifeq ($(SYSTEM),Darwin)
  168. LIBS = m z
  169. else
  170. LIBS = rt m z pthread
  171. LDFLAGS += -pthread
  172. endif
  173. ifneq ($(wildcard /usr/src/gtest/src/gtest-all.cc),)
  174. GTEST_LIB = /usr/src/gtest/src/gtest-all.cc -I/usr/src/gtest
  175. else
  176. GTEST_LIB = -lgtest
  177. endif
  178. GTEST_LIB += -lgflags
  179. ifeq ($(V),1)
  180. E = @:
  181. Q =
  182. else
  183. E = @echo
  184. Q = @
  185. endif
  186. VERSION = ${settings.version.major}.${settings.version.minor}.${settings.version.micro}.${settings.version.build}
  187. CPPFLAGS_NO_ARCH += $(addprefix -I, $(INCLUDES)) $(addprefix -D, $(DEFINES))
  188. CPPFLAGS += $(CPPFLAGS_NO_ARCH) $(ARCH_FLAGS)
  189. LDFLAGS += $(ARCH_FLAGS)
  190. LDLIBS += $(addprefix -l, $(LIBS))
  191. LDLIBSXX += $(addprefix -l, $(LIBSXX))
  192. HOST_CPPFLAGS = $(CPPFLAGS)
  193. HOST_CFLAGS = $(CFLAGS)
  194. HOST_CXXFLAGS = $(CXXFLAGS)
  195. HOST_LDFLAGS = $(LDFLAGS)
  196. HOST_LDLIBS = $(LDLIBS)
  197. # These are automatically computed variables.
  198. # There shouldn't be any need to change anything from now on.
  199. ifeq ($(SYSTEM),MINGW32)
  200. SHARED_EXT = dll
  201. endif
  202. ifeq ($(SYSTEM),Darwin)
  203. SHARED_EXT = dylib
  204. endif
  205. ifeq ($(SHARED_EXT),)
  206. SHARED_EXT = so.$(VERSION)
  207. endif
  208. ifeq ($(wildcard .git),)
  209. IS_GIT_FOLDER = false
  210. else
  211. IS_GIT_FOLDER = true
  212. endif
  213. OPENSSL_ALPN_CHECK_CMD = $(CC) $(CFLAGS) $(CPPFLAGS) -o /dev/null test/build/openssl-alpn.c -lssl -lcrypto -ldl $(LDFLAGS)
  214. ZLIB_CHECK_CMD = $(CC) $(CFLAGS) $(CPPFLAGS) -o /dev/null test/build/zlib.c -lz $(LDFLAGS)
  215. PERFTOOLS_CHECK_CMD = $(CC) $(CFLAGS) $(CPPFLAGS) -o /dev/null test/build/perftools.c -lprofiler $(LDFLAGS)
  216. PROTOBUF_CHECK_CMD = $(CXX) $(CXXFLAGS) $(CPPFLAGS) -o /dev/null test/build/protobuf.cc -lprotobuf $(LDFLAGS)
  217. PROTOC_CHECK_CMD = protoc --version | grep -q libprotoc.3
  218. ifndef REQUIRE_CUSTOM_LIBRARIES_$(CONFIG)
  219. HAS_SYSTEM_PERFTOOLS = $(shell $(PERFTOOLS_CHECK_CMD) 2> /dev/null && echo true || echo false)
  220. ifeq ($(HAS_SYSTEM_PERFTOOLS),true)
  221. DEFINES += GRPC_HAVE_PERFTOOLS
  222. LIBS += profiler
  223. endif
  224. endif
  225. ifndef REQUIRE_CUSTOM_LIBRARIES_$(CONFIG)
  226. HAS_SYSTEM_OPENSSL_ALPN = $(shell $(OPENSSL_ALPN_CHECK_CMD) 2> /dev/null && echo true || echo false)
  227. HAS_SYSTEM_ZLIB = $(shell $(ZLIB_CHECK_CMD) 2> /dev/null && echo true || echo false)
  228. HAS_SYSTEM_PROTOBUF = $(shell $(PROTOBUF_CHECK_CMD) 2> /dev/null && echo true || echo false)
  229. else
  230. # override system libraries if the config requires a custom compiled library
  231. HAS_SYSTEM_OPENSSL_ALPN = false
  232. HAS_SYSTEM_ZLIB = false
  233. HAS_SYSTEM_PROTOBUF = false
  234. endif
  235. HAS_VALID_PROTOC = $(shell $(PROTOC_CHECK_CMD) 2> /dev/null && echo true || echo false)
  236. ifeq ($(wildcard third_party/openssl/ssl/ssl.h),)
  237. HAS_EMBEDDED_OPENSSL_ALPN = false
  238. else
  239. HAS_EMBEDDED_OPENSSL_ALPN = true
  240. endif
  241. ifeq ($(wildcard third_party/zlib/zlib.h),)
  242. HAS_EMBEDDED_ZLIB = false
  243. else
  244. HAS_EMBEDDED_ZLIB = true
  245. endif
  246. ifeq ($(wildcard third_party/protobuf/src/google/protobuf/descriptor.pb.h),)
  247. HAS_EMBEDDED_PROTOBUF = false
  248. ifneq ($(HAS_VALID_PROTOC),true)
  249. NO_PROTOC = true
  250. endif
  251. else
  252. HAS_EMBEDDED_PROTOBUF = true
  253. endif
  254. ifeq ($(HAS_SYSTEM_ZLIB),false)
  255. ifeq ($(HAS_EMBEDDED_ZLIB),true)
  256. ZLIB_DEP = $(LIBDIR)/$(CONFIG)/zlib/libz.a
  257. CPPFLAGS += -Ithird_party/zlib
  258. LDFLAGS += -L$(LIBDIR)/$(CONFIG)/zlib
  259. else
  260. DEP_MISSING += zlib
  261. endif
  262. endif
  263. ifeq ($(HAS_SYSTEM_OPENSSL_ALPN),false)
  264. ifeq ($(HAS_EMBEDDED_OPENSSL_ALPN),true)
  265. OPENSSL_DEP = $(LIBDIR)/$(CONFIG)/openssl/libssl.a
  266. OPENSSL_MERGE_LIBS += $(LIBDIR)/$(CONFIG)/openssl/libssl.a $(LIBDIR)/$(CONFIG)/openssl/libcrypto.a
  267. CPPFLAGS += -Ithird_party/openssl/include
  268. LDFLAGS += -L$(LIBDIR)/$(CONFIG)/openssl
  269. LIBS_SECURE = dl
  270. else
  271. NO_SECURE = true
  272. endif
  273. else
  274. LIBS_SECURE = ssl crypto dl
  275. endif
  276. LDLIBS_SECURE += $(addprefix -l, $(LIBS_SECURE))
  277. ifeq ($(HAS_SYSTEM_PROTOBUF),false)
  278. ifeq ($(HAS_EMBEDDED_PROTOBUF),true)
  279. PROTOBUF_DEP = $(LIBDIR)/$(CONFIG)/protobuf/libprotobuf.a
  280. CPPFLAGS += -Ithird_party/protobuf/src
  281. LDFLAGS += -L$(LIBDIR)/$(CONFIG)/protobuf
  282. PROTOC = $(BINDIR)/$(CONFIG)/protobuf/protoc
  283. else
  284. NO_PROTOBUF = true
  285. endif
  286. else
  287. endif
  288. LIBS_PROTOBUF = protobuf
  289. LIBS_PROTOC = protoc protobuf
  290. LDLIBS_PROTOBUF += $(addprefix -l, $(LIBS_PROTOBUF))
  291. HOST_LDLIBS_PROTOC += $(addprefix -l, $(LIBS_PROTOC))
  292. ifeq ($(MAKECMDGOALS),clean)
  293. NO_DEPS = true
  294. endif
  295. .SECONDARY = %.pb.h %.pb.cc
  296. PROTOC_PLUGINS=\
  297. % for tgt in targets:
  298. % if tgt.build == 'protoc':
  299. $(BINDIR)/$(CONFIG)/${tgt.name}\
  300. % endif
  301. % endfor
  302. ifeq ($(DEP_MISSING),)
  303. all: static shared\
  304. % for tgt in targets:
  305. % if tgt.build == 'all':
  306. $(BINDIR)/$(CONFIG)/${tgt.name}\
  307. % endif
  308. % endfor
  309. dep_error:
  310. @echo "You shouldn't see this message - all of your dependencies are correct."
  311. else
  312. all: dep_error git_update stop
  313. dep_error:
  314. @echo
  315. @echo "DEPENDENCY ERROR"
  316. @echo
  317. @echo "You are missing system dependencies that are essential to build grpc,"
  318. @echo "and the third_party directory doesn't have them:"
  319. @echo
  320. @echo " $(DEP_MISSING)"
  321. @echo
  322. @echo "Installing the development packages for your system will solve"
  323. @echo "this issue. Please consult INSTALL to get more information."
  324. @echo
  325. @echo "If you need information about why these tests failed, run:"
  326. @echo
  327. @echo " make run_dep_checks"
  328. @echo
  329. endif
  330. git_update:
  331. ifeq ($(IS_GIT_FOLDER),true)
  332. @echo "Additionally, since you are in a git clone, you can download the"
  333. @echo "missing dependencies in third_party by running the following command:"
  334. @echo
  335. @echo " git submodule update --init"
  336. @echo
  337. endif
  338. openssl_dep_error: openssl_dep_message git_update stop
  339. protobuf_dep_error: protobuf_dep_message git_update stop
  340. protoc_dep_error: protoc_dep_message git_update stop
  341. openssl_dep_message:
  342. @echo
  343. @echo "DEPENDENCY ERROR"
  344. @echo
  345. @echo "The target you are trying to run requires OpenSSL with ALPN support."
  346. @echo "Your system doesn't have it, and neither does the third_party directory."
  347. @echo
  348. @echo "Please consult INSTALL to get more information."
  349. @echo
  350. @echo "If you need information about why these tests failed, run:"
  351. @echo
  352. @echo " make run_dep_checks"
  353. @echo
  354. protobuf_dep_message:
  355. @echo
  356. @echo "DEPENDENCY ERROR"
  357. @echo
  358. @echo "The target you are trying to run requires protobuf 3.0.0+"
  359. @echo "Your system doesn't have it, and neither does the third_party directory."
  360. @echo
  361. @echo "Please consult INSTALL to get more information."
  362. @echo
  363. @echo "If you need information about why these tests failed, run:"
  364. @echo
  365. @echo " make run_dep_checks"
  366. @echo
  367. protoc_dep_message:
  368. @echo
  369. @echo "DEPENDENCY ERROR"
  370. @echo
  371. @echo "The target you are trying to run requires protobuf-compiler 3.0.0+"
  372. @echo "Your system doesn't have it, and neither does the third_party directory."
  373. @echo
  374. @echo "Please consult INSTALL to get more information."
  375. @echo
  376. @echo "If you need information about why these tests failed, run:"
  377. @echo
  378. @echo " make run_dep_checks"
  379. @echo
  380. stop:
  381. @false
  382. % for tgt in targets:
  383. ${tgt.name}: $(BINDIR)/$(CONFIG)/${tgt.name}
  384. % endfor
  385. run_dep_checks:
  386. $(OPENSSL_ALPN_CHECK_CMD) || true
  387. $(ZLIB_CHECK_CMD) || true
  388. $(PERFTOOLS_CHECK_CMD) || true
  389. $(PROTOBUF_CHECK_CMD) || true
  390. $(PROTOC_CHECK_CMD) || true
  391. $(LIBDIR)/$(CONFIG)/zlib/libz.a:
  392. $(E) "[MAKE] Building zlib"
  393. $(Q)(cd third_party/zlib ; CC="$(CC)" CFLAGS="-fPIC -fvisibility=hidden $(CPPFLAGS_$(CONFIG))" ./configure --static)
  394. $(Q)$(MAKE) -C third_party/zlib clean
  395. $(Q)$(MAKE) -C third_party/zlib
  396. $(Q)mkdir -p $(LIBDIR)/$(CONFIG)/zlib
  397. $(Q)cp third_party/zlib/libz.a $(LIBDIR)/$(CONFIG)/zlib
  398. $(LIBDIR)/$(CONFIG)/openssl/libssl.a:
  399. $(E) "[MAKE] Building openssl for $(SYSTEM)"
  400. ifeq ($(SYSTEM),Darwin)
  401. $(Q)(cd third_party/openssl ; CC="$(CC) -fPIC -fvisibility=hidden $(CPPFLAGS_$(CONFIG)) $(OPENSSL_CFLAGS_$(CONFIG))" ./Configure darwin64-x86_64-cc $(OPENSSL_CONFIG_$(CONFIG)))
  402. else
  403. $(Q)(cd third_party/openssl ; CC="$(CC) -fPIC -fvisibility=hidden $(CPPFLAGS_$(CONFIG)) $(OPENSSL_CFLAGS_$(CONFIG))" ./config $(OPENSSL_CONFIG_$(CONFIG)))
  404. endif
  405. $(Q)$(MAKE) -C third_party/openssl clean
  406. $(Q)$(MAKE) -C third_party/openssl build_crypto build_ssl
  407. $(Q)mkdir -p $(LIBDIR)/$(CONFIG)/openssl
  408. $(Q)cp third_party/openssl/libssl.a third_party/openssl/libcrypto.a $(LIBDIR)/$(CONFIG)/openssl
  409. third_party/protobuf/configure:
  410. $(E) "[AUTOGEN] Preparing protobuf"
  411. $(Q)(cd third_party/protobuf ; autoreconf -f -i -Wall,no-obsolete)
  412. $(LIBDIR)/$(CONFIG)/protobuf/libprotobuf.a: third_party/protobuf/configure
  413. $(E) "[MAKE] Building protobuf"
  414. $(Q)(cd third_party/protobuf ; CC="$(CC)" CXX="$(CXX)" LDFLAGS="$(LDFLAGS_$(CONFIG)) -g" CXXFLAGS="-DLANG_CXX11 -std=c++11" CPPFLAGS="$(CPPFLAGS_$(CONFIG)) -g" ./configure --disable-shared --enable-static)
  415. $(Q)$(MAKE) -C third_party/protobuf clean
  416. $(Q)$(MAKE) -C third_party/protobuf
  417. $(Q)mkdir -p $(LIBDIR)/$(CONFIG)/protobuf
  418. $(Q)mkdir -p $(BINDIR)/$(CONFIG)/protobuf
  419. $(Q)cp third_party/protobuf/src/.libs/libprotoc.a $(LIBDIR)/$(CONFIG)/protobuf
  420. $(Q)cp third_party/protobuf/src/.libs/libprotobuf.a $(LIBDIR)/$(CONFIG)/protobuf
  421. $(Q)cp third_party/protobuf/src/protoc $(BINDIR)/$(CONFIG)/protobuf
  422. static: static_c static_cxx
  423. static_c: \
  424. % for lib in libs:
  425. % if lib.build == 'all' and lib.language == 'c':
  426. $(LIBDIR)/$(CONFIG)/lib${lib.name}.a\
  427. % endif
  428. % endfor
  429. static_cxx: \
  430. % for lib in libs:
  431. % if lib.build == 'all' and lib.language == 'c++':
  432. $(LIBDIR)/$(CONFIG)/lib${lib.name}.a\
  433. % endif
  434. % endfor
  435. shared: shared_c shared_cxx
  436. shared_c: \
  437. % for lib in libs:
  438. % if lib.build == 'all' and lib.language == 'c':
  439. $(LIBDIR)/$(CONFIG)/lib${lib.name}.$(SHARED_EXT)\
  440. % endif
  441. % endfor
  442. shared_cxx: \
  443. % for lib in libs:
  444. % if lib.build == 'all' and lib.language == 'c++':
  445. $(LIBDIR)/$(CONFIG)/lib${lib.name}.$(SHARED_EXT)\
  446. % endif
  447. % endfor
  448. privatelibs: privatelibs_c privatelibs_cxx
  449. privatelibs_c: \
  450. % for lib in libs:
  451. % if lib.build == 'private' and lib.language == 'c':
  452. $(LIBDIR)/$(CONFIG)/lib${lib.name}.a\
  453. % endif
  454. % endfor
  455. privatelibs_cxx: \
  456. % for lib in libs:
  457. % if lib.build == 'private' and lib.language == 'c++':
  458. $(LIBDIR)/$(CONFIG)/lib${lib.name}.a\
  459. % endif
  460. % endfor
  461. buildtests: buildtests_c buildtests_cxx
  462. buildtests_c: privatelibs_c\
  463. % for tgt in targets:
  464. % if tgt.build == 'test' and not tgt.language == 'c++':
  465. $(BINDIR)/$(CONFIG)/${tgt.name}\
  466. % endif
  467. % endfor
  468. buildtests_cxx: privatelibs_cxx\
  469. % for tgt in targets:
  470. % if tgt.build == 'test' and tgt.language == 'c++':
  471. $(BINDIR)/$(CONFIG)/${tgt.name}\
  472. % endif
  473. % endfor
  474. test: test_c test_cxx
  475. test_c: buildtests_c
  476. % for tgt in targets:
  477. % if tgt.build == 'test' and tgt.get('run', True) and not tgt.language == 'c++':
  478. $(E) "[RUN] Testing ${tgt.name}"
  479. $(Q) $(BINDIR)/$(CONFIG)/${tgt.name} || ( echo test ${tgt.name} failed ; exit 1 )
  480. % endif
  481. % endfor
  482. test_cxx: buildtests_cxx
  483. % for tgt in targets:
  484. % if tgt.build == 'test' and tgt.get('run', True) and tgt.language == 'c++':
  485. $(E) "[RUN] Testing ${tgt.name}"
  486. $(Q) $(BINDIR)/$(CONFIG)/${tgt.name} || ( echo test ${tgt.name} failed ; exit 1 )
  487. % endif
  488. % endfor
  489. tools: privatelibs\
  490. % for tgt in targets:
  491. % if tgt.build == 'tool':
  492. $(BINDIR)/$(CONFIG)/${tgt.name}\
  493. % endif
  494. % endfor
  495. buildbenchmarks: privatelibs\
  496. % for tgt in targets:
  497. % if tgt.build == 'benchmark':
  498. $(BINDIR)/$(CONFIG)/${tgt.name}\
  499. % endif
  500. % endfor
  501. benchmarks: buildbenchmarks
  502. strip: strip-static strip-shared
  503. strip-static: strip-static_c strip-static_cxx
  504. strip-shared: strip-shared_c strip-shared_cxx
  505. # TODO(nnoble): the strip target is stripping in-place, instead
  506. # of copying files in a temporary folder.
  507. # This prevents proper debugging after running make install.
  508. strip-static_c: static_c
  509. ifeq ($(CONFIG),opt)
  510. % for lib in libs:
  511. % if lib.language == "c":
  512. % if lib.build == "all":
  513. $(E) "[STRIP] Stripping lib${lib.name}.a"
  514. $(Q) $(STRIP) $(LIBDIR)/$(CONFIG)/lib${lib.name}.a
  515. % endif
  516. % endif
  517. % endfor
  518. endif
  519. strip-static_cxx: static_cxx
  520. ifeq ($(CONFIG),opt)
  521. % for lib in libs:
  522. % if lib.language == "c++":
  523. % if lib.build == "all":
  524. $(E) "[STRIP] Stripping lib${lib.name}.a"
  525. $(Q) $(STRIP) $(LIBDIR)/$(CONFIG)/lib${lib.name}.a
  526. % endif
  527. % endif
  528. % endfor
  529. endif
  530. strip-shared_c: shared_c
  531. ifeq ($(CONFIG),opt)
  532. % for lib in libs:
  533. % if lib.language == "c":
  534. % if lib.build == "all":
  535. $(E) "[STRIP] Stripping lib${lib.name}.so"
  536. $(Q) $(STRIP) $(LIBDIR)/$(CONFIG)/lib${lib.name}.$(SHARED_EXT)
  537. % endif
  538. % endif
  539. % endfor
  540. endif
  541. strip-shared_cxx: shared_cxx
  542. ifeq ($(CONFIG),opt)
  543. % for lib in libs:
  544. % if lib.language == "c++":
  545. % if lib.build == "all":
  546. $(E) "[STRIP] Stripping lib${lib.name}.so"
  547. $(Q) $(STRIP) $(LIBDIR)/$(CONFIG)/lib${lib.name}.$(SHARED_EXT)
  548. % endif
  549. % endif
  550. % endfor
  551. endif
  552. % for p in protos:
  553. ifeq ($(NO_PROTOC),true)
  554. $(GENDIR)/${p}.pb.cc: protoc_dep_error
  555. else
  556. $(GENDIR)/${p}.pb.cc: ${p}.proto $(PROTOBUF_DEP) $(PROTOC_PLUGINS)
  557. $(E) "[PROTOC] Generating protobuf CC file from $<"
  558. $(Q) mkdir -p `dirname $@`
  559. $(Q) $(PROTOC) --cpp_out=$(GENDIR) --grpc_out=$(GENDIR) --plugin=protoc-gen-grpc=$(BINDIR)/$(CONFIG)/cpp_plugin $<
  560. endif
  561. % endfor
  562. $(OBJDIR)/$(CONFIG)/%.o : %.c
  563. $(E) "[C] Compiling $<"
  564. $(Q) mkdir -p `dirname $@`
  565. $(Q) $(CC) $(CFLAGS) $(CPPFLAGS) -MMD -MF $(addsuffix .dep, $(basename $@)) -c -o $@ $<
  566. $(OBJDIR)/$(CONFIG)/%.o : $(GENDIR)/%.pb.cc
  567. $(E) "[CXX] Compiling $<"
  568. $(Q) mkdir -p `dirname $@`
  569. $(Q) $(CXX) $(CXXFLAGS) $(CPPFLAGS) -MMD -MF $(addsuffix .dep, $(basename $@)) -c -o $@ $<
  570. $(OBJDIR)/$(CONFIG)/src/compiler/%.o : src/compiler/%.cc
  571. $(E) "[HOSTCXX] Compiling $<"
  572. $(Q) mkdir -p `dirname $@`
  573. $(Q) $(HOST_CXX) $(HOST_CXXFLAGS) $(HOST_CPPFLAGS) -MMD -MF $(addsuffix .dep, $(basename $@)) -c -o $@ $<
  574. $(OBJDIR)/$(CONFIG)/%.o : %.cc
  575. $(E) "[CXX] Compiling $<"
  576. $(Q) mkdir -p `dirname $@`
  577. $(Q) $(CXX) $(CXXFLAGS) $(CPPFLAGS) -MMD -MF $(addsuffix .dep, $(basename $@)) -c -o $@ $<
  578. install: install_c install_cxx
  579. install_c: install-headers_c install-static_c install-shared_c
  580. install_cxx: install-headers_cxx install-static_cxx install-shared_cxx
  581. install-headers: install-headers_c install-headers_cxx
  582. install-headers_c:
  583. $(E) "[INSTALL] Installing public C headers"
  584. $(Q) $(foreach h, $(PUBLIC_HEADERS_C), $(INSTALL) $(h) $(prefix)/$(h) && ) exit 0 || exit 1
  585. install-headers_cxx:
  586. $(E) "[INSTALL] Installing public C++ headers"
  587. $(Q) $(foreach h, $(PUBLIC_HEADERS_CXX), $(INSTALL) $(h) $(prefix)/$(h) && ) exit 0 || exit 1
  588. install-static: install-static_c install-static_cxx
  589. install-static_c: static_c strip-static_c
  590. % for lib in libs:
  591. % if lib.language == "c":
  592. % if lib.build == "all":
  593. $(E) "[INSTALL] Installing lib${lib.name}.a"
  594. $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/lib${lib.name}.a $(prefix)/lib/lib${lib.name}.a
  595. % endif
  596. % endif
  597. % endfor
  598. install-static_cxx: static_cxx strip-static_cxx
  599. % for lib in libs:
  600. % if lib.language == "c++":
  601. % if lib.build == "all":
  602. $(E) "[INSTALL] Installing lib${lib.name}.a"
  603. $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/lib${lib.name}.a $(prefix)/lib/lib${lib.name}.a
  604. % endif
  605. % endif
  606. % endfor
  607. install-shared_c: shared_c strip-shared_c
  608. % for lib in libs:
  609. % if lib.language == "c":
  610. % if lib.build == "all":
  611. ifeq ($(SYSTEM),MINGW32)
  612. $(E) "[INSTALL] Installing ${lib.name}.$(SHARED_EXT)"
  613. $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/${lib.name}.$(SHARED_EXT) $(prefix)/lib/${lib.name}.$(SHARED_EXT)
  614. $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/lib${lib.name}-imp.a $(prefix)/lib/lib${lib.name}-imp.a
  615. else
  616. $(E) "[INSTALL] Installing lib${lib.name}.$(SHARED_EXT)"
  617. $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/lib${lib.name}.$(SHARED_EXT) $(prefix)/lib/lib${lib.name}.$(SHARED_EXT)
  618. ifneq ($(SYSTEM),Darwin)
  619. $(Q) ln -sf lib${lib.name}.$(SHARED_EXT) $(prefix)/lib/lib${lib.name}.so
  620. endif
  621. endif
  622. % endif
  623. % endif
  624. % endfor
  625. ifneq ($(SYSTEM),MINGW32)
  626. ifneq ($(SYSTEM),Darwin)
  627. $(Q) ldconfig
  628. endif
  629. endif
  630. install-shared_cxx: shared_cxx strip-shared_cxx
  631. % for lib in libs:
  632. % if lib.language == "c++":
  633. % if lib.build == "all":
  634. ifeq ($(SYSTEM),MINGW32)
  635. $(E) "[INSTALL] Installing ${lib.name}.$(SHARED_EXT)"
  636. $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/${lib.name}.$(SHARED_EXT) $(prefix)/lib/${lib.name}.$(SHARED_EXT)
  637. $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/lib${lib.name}-imp.a $(prefix)/lib/lib${lib.name}-imp.a
  638. else
  639. $(E) "[INSTALL] Installing lib${lib.name}.$(SHARED_EXT)"
  640. $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/lib${lib.name}.$(SHARED_EXT) $(prefix)/lib/lib${lib.name}.$(SHARED_EXT)
  641. ifneq ($(SYSTEM),Darwin)
  642. $(Q) ln -sf lib${lib.name}.$(SHARED_EXT) $(prefix)/lib/lib${lib.name}.so
  643. endif
  644. endif
  645. % endif
  646. % endif
  647. % endfor
  648. ifneq ($(SYSTEM),MINGW32)
  649. ifneq ($(SYSTEM),Darwin)
  650. $(Q) ldconfig
  651. endif
  652. endif
  653. clean:
  654. $(Q) $(RM) -rf $(OBJDIR) $(LIBDIR) $(BINDIR) $(GENDIR)
  655. # The various libraries
  656. % for lib in libs:
  657. ${makelib(lib)}
  658. % endfor
  659. # All of the test targets, and protoc plugins
  660. % for tgt in targets:
  661. ${maketarget(tgt)}
  662. % endfor
  663. <%def name="makelib(lib)">
  664. LIB${lib.name.upper()}_SRC = \\
  665. % for src in lib.src:
  666. ${proto_to_cc(src)} \\
  667. % endfor
  668. % if "public_headers" in lib:
  669. % if lib.language == "c++":
  670. PUBLIC_HEADERS_CXX += \\
  671. % else:
  672. PUBLIC_HEADERS_C += \\
  673. % endif
  674. % for hdr in lib.public_headers:
  675. ${hdr} \\
  676. % endfor
  677. % endif
  678. LIB${lib.name.upper()}_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(LIB${lib.name.upper()}_SRC))))
  679. ## If the library requires OpenSSL with ALPN, let's add some restrictions.
  680. % if lib.get('secure', True):
  681. ifeq ($(NO_SECURE),true)
  682. # You can't build secure libraries if you don't have OpenSSL with ALPN.
  683. $(LIBDIR)/$(CONFIG)/lib${lib.name}.a: openssl_dep_error
  684. % if lib.build == "all":
  685. ifeq ($(SYSTEM),MINGW32)
  686. $(LIBDIR)/$(CONFIG)/${lib.name}.$(SHARED_EXT): openssl_dep_error
  687. else
  688. $(LIBDIR)/$(CONFIG)/lib${lib.name}.$(SHARED_EXT): openssl_dep_error
  689. endif
  690. % endif
  691. else
  692. % if lib.language == 'c++':
  693. ifeq ($(NO_PROTOBUF),true)
  694. # You can't build a C++ library if you don't have protobuf - a bit overreached, but still okay.
  695. $(LIBDIR)/$(CONFIG)/lib${lib.name}.a: protobuf_dep_error
  696. % if lib.build == "all":
  697. ifeq ($(SYSTEM),MINGW32)
  698. $(LIBDIR)/$(CONFIG)/${lib.name}.$(SHARED_EXT): protobuf_dep_error
  699. else
  700. $(LIBDIR)/$(CONFIG)/lib${lib.name}.$(SHARED_EXT): protobuf_dep_error
  701. endif
  702. % endif
  703. else
  704. % endif
  705. ifneq ($(OPENSSL_DEP),)
  706. # This is to ensure the embedded OpenSSL is built beforehand, properly
  707. # installing headers to their final destination on the drive. We need this
  708. # otherwise parallel compilation will fail if a source is compiled first.
  709. % for src in lib.src:
  710. ${src}: $(OPENSSL_DEP)
  711. % endfor
  712. endif
  713. $(LIBDIR)/$(CONFIG)/lib${lib.name}.a: $(ZLIB_DEP) $(OPENSSL_DEP)\
  714. ## The else here corresponds to the if secure earlier.
  715. % else:
  716. % if lib.language == 'c++':
  717. ifeq ($(NO_PROTOBUF),true)
  718. # You can't build a C++ library if you don't have protobuf - a bit overreached, but still okay.
  719. $(LIBDIR)/$(CONFIG)/lib${lib.name}.a: protobuf_dep_error
  720. % if lib.build == "all":
  721. ifeq ($(SYSTEM),MINGW32)
  722. $(LIBDIR)/$(CONFIG)/${lib.name}.$(SHARED_EXT): protobuf_dep_error
  723. else
  724. $(LIBDIR)/$(CONFIG)/lib${lib.name}.$(SHARED_EXT): protobuf_dep_error
  725. endif
  726. % endif
  727. else
  728. % endif
  729. $(LIBDIR)/$(CONFIG)/lib${lib.name}.a: $(ZLIB_DEP)\
  730. % endif
  731. % if lib.language == 'c++':
  732. $(PROTOBUF_DEP)\
  733. % endif
  734. $(LIB${lib.name.upper()}_OBJS)
  735. $(E) "[AR] Creating $@"
  736. $(Q) mkdir -p `dirname $@`
  737. $(Q) rm -f $(LIBDIR)/$(CONFIG)/lib${lib.name}.a
  738. $(Q) $(AR) rcs $(LIBDIR)/$(CONFIG)/lib${lib.name}.a $(LIB${lib.name.upper()}_OBJS)
  739. % if lib.get('baselib', False):
  740. % if lib.get('secure', True):
  741. $(Q) rm -rf tmp-merge
  742. $(Q) mkdir tmp-merge
  743. $(Q) ( cd tmp-merge ; $(AR) x ../$(LIBDIR)/$(CONFIG)/lib${lib.name}.a )
  744. $(Q) for l in $(OPENSSL_MERGE_LIBS) ; do ( cd tmp-merge ; <%text>ar x ../$${l}</%text> ) ; done
  745. $(Q) rm -f $(LIBDIR)/$(CONFIG)/lib${lib.name}.a tmp-merge/__.SYMDEF*
  746. $(Q) ar rcs $(LIBDIR)/$(CONFIG)/lib${lib.name}.a tmp-merge/*
  747. $(Q) rm -rf tmp-merge
  748. % endif
  749. % endif
  750. ifeq ($(SYSTEM),Darwin)
  751. $(Q) ranlib $(LIBDIR)/$(CONFIG)/lib${lib.name}.a
  752. endif
  753. <%
  754. if lib.language == 'c++':
  755. ld = '$(LDXX)'
  756. else:
  757. ld = '$(LD)'
  758. out_base = '$(LIBDIR)/$(CONFIG)/' + lib.name
  759. out_libbase = '$(LIBDIR)/$(CONFIG)/lib' + lib.name
  760. common = '$(LIB' + lib.name.upper() + '_OBJS) $(LDLIBS)'
  761. libs = ''
  762. lib_deps = ' $(ZLIB_DEP)'
  763. mingw_libs = ''
  764. mingw_lib_deps = ' $(ZLIB_DEP)'
  765. for dep in lib.get('deps', []):
  766. libs = libs + ' -l' + dep
  767. lib_deps = lib_deps + ' $(LIBDIR)/$(CONFIG)/lib' + dep + '.$(SHARED_EXT)'
  768. mingw_libs = mingw_libs + ' -l' + dep + '-imp'
  769. mingw_lib_deps = mingw_lib_deps + '$(LIBDIR)/$(CONFIG)/' + dep + '.$(SHARED_EXT)'
  770. if lib.get('secure', True):
  771. common = common + ' $(LDLIBS_SECURE) $(OPENSSL_MERGE_LIBS)'
  772. lib_deps = lib_deps + ' $(OPENSSL_DEP)'
  773. mingw_lib_deps = mingw_lib_deps + ' $(OPENSSL_DEP)'
  774. %>
  775. % if lib.build == "all":
  776. ifeq ($(SYSTEM),MINGW32)
  777. ${out_base}.$(SHARED_EXT): $(LIB${lib.name.upper()}_OBJS) ${mingw_lib_deps}
  778. $(E) "[LD] Linking $@"
  779. $(Q) mkdir -p `dirname $@`
  780. $(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}
  781. else
  782. ${out_libbase}.$(SHARED_EXT): $(LIB${lib.name.upper()}_OBJS) ${lib_deps}
  783. $(E) "[LD] Linking $@"
  784. $(Q) mkdir -p `dirname $@`
  785. ifeq ($(SYSTEM),Darwin)
  786. $(Q) ${ld} $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -dynamiclib -o ${out_libbase}.$(SHARED_EXT) ${common}${libs}
  787. else
  788. $(Q) ${ld} $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,-soname,lib${lib.name}.so.${settings.version.major} -o ${out_libbase}.$(SHARED_EXT) ${common}${libs}
  789. $(Q) ln -sf lib${lib.name}.$(SHARED_EXT) ${out_libbase}.so.${settings.version.major}
  790. $(Q) ln -sf lib${lib.name}.$(SHARED_EXT) ${out_libbase}.so
  791. endif
  792. endif
  793. % endif
  794. % if lib.get('secure', True):
  795. ## If the lib was secure, we have to close the Makefile's if that tested
  796. ## the presence of an ALPN-capable OpenSSL.
  797. endif
  798. % endif
  799. % if lib.language == 'c++':
  800. ## If the lib was C++, we have to close the Makefile's if that tested
  801. ## the presence of protobuf 3.0.0+
  802. endif
  803. % endif
  804. % if lib.get('secure', True):
  805. ifneq ($(NO_SECURE),true)
  806. % endif
  807. ifneq ($(NO_DEPS),true)
  808. -include $(LIB${lib.name.upper()}_OBJS:.o=.dep)
  809. endif
  810. % if lib.get('secure', True):
  811. endif
  812. % endif
  813. % for src in lib.src:
  814. % if not proto_re.match(src):
  815. $(OBJDIR)/$(CONFIG)/${os.path.splitext(src)[0]}.o: \
  816. % for src2 in lib.src:
  817. % if proto_re.match(src2):
  818. ${proto_to_cc(src2)}\
  819. % endif
  820. % endfor
  821. % endif
  822. % endfor
  823. </%def>
  824. <%def name="maketarget(tgt)">
  825. ${tgt.name.upper()}_SRC = \\
  826. % for src in tgt.src:
  827. ${proto_to_cc(src)} \\
  828. % endfor
  829. ${tgt.name.upper()}_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(${tgt.name.upper()}_SRC))))
  830. % if tgt.get('secure', True):
  831. ifeq ($(NO_SECURE),true)
  832. # You can't build secure targets if you don't have OpenSSL with ALPN.
  833. $(BINDIR)/$(CONFIG)/${tgt.name}: openssl_dep_error
  834. else
  835. % endif
  836. ##
  837. ## We're not trying to add a dependency on building zlib and openssl here,
  838. ## as it's already done in the libraries. We're assuming that the build
  839. ## trickles down, and that a secure target requires a secure version of
  840. ## a library.
  841. ##
  842. ## That simplifies the codegen a bit, but prevents a fully defined Makefile.
  843. ## I can live with that.
  844. ##
  845. % if tgt.build == 'protoc':
  846. ifeq ($(NO_PROTOBUF),true)
  847. # You can't build the protoc plugins if you don't have protobuf 3.0.0+.
  848. $(BINDIR)/$(CONFIG)/${tgt.name}: protobuf_dep_error
  849. else
  850. $(BINDIR)/$(CONFIG)/${tgt.name}: $(PROTOBUF_DEP) $(${tgt.name.upper()}_OBJS)\
  851. % else:
  852. $(BINDIR)/$(CONFIG)/${tgt.name}: $(${tgt.name.upper()}_OBJS)\
  853. % endif
  854. % for dep in tgt.deps:
  855. $(LIBDIR)/$(CONFIG)/lib${dep}.a\
  856. % endfor
  857. % if tgt.language == "c++":
  858. ## C++ targets specificies.
  859. % if tgt.build == 'protoc':
  860. $(E) "[HOSTLD] Linking $@"
  861. $(Q) mkdir -p `dirname $@`
  862. $(Q) $(HOST_LDXX) $(HOST_LDFLAGS) $(${tgt.name.upper()}_OBJS)\
  863. % else:
  864. $(E) "[LD] Linking $@"
  865. $(Q) mkdir -p `dirname $@`
  866. $(Q) $(LDXX) $(LDFLAGS) $(${tgt.name.upper()}_OBJS)\
  867. % endif
  868. % if tgt.build == 'test':
  869. $(GTEST_LIB)\
  870. % endif
  871. % else:
  872. ## C-only targets specificities.
  873. $(E) "[LD] Linking $@"
  874. $(Q) mkdir -p `dirname $@`
  875. $(Q) $(LD) $(LDFLAGS) $(${tgt.name.upper()}_OBJS)\
  876. % endif
  877. % for dep in tgt.deps:
  878. $(LIBDIR)/$(CONFIG)/lib${dep}.a\
  879. % endfor
  880. % if tgt.language == "c++":
  881. % if tgt.build == 'protoc':
  882. $(HOST_LDLIBSXX) $(HOST_LDLIBS_PROTOC)\
  883. % else:
  884. $(LDLIBSXX) $(LDLIBS_PROTOBUF)\
  885. % endif
  886. % endif
  887. % if tgt.build == 'protoc':
  888. $(HOST_LDLIBS)\
  889. % else:
  890. $(LDLIBS)\
  891. % endif
  892. % if tgt.build == 'protoc':
  893. $(HOST_LDLIBS_PROTOC)\
  894. % elif tgt.get('secure', True):
  895. $(LDLIBS_SECURE)\
  896. % endif
  897. -o $(BINDIR)/$(CONFIG)/${tgt.name}
  898. % if tgt.build == 'protoc':
  899. endif
  900. % endif
  901. % if tgt.get('secure', True):
  902. endif
  903. % endif
  904. % for src in tgt.src:
  905. $(OBJDIR)/$(CONFIG)/${os.path.splitext(src)[0]}.o: \
  906. % for dep in tgt.deps:
  907. $(LIBDIR)/$(CONFIG)/lib${dep}.a\
  908. % endfor
  909. % endfor
  910. deps_${tgt.name}: $(${tgt.name.upper()}_OBJS:.o=.dep)
  911. % if tgt.get('secure', True):
  912. ifneq ($(NO_SECURE),true)
  913. % endif
  914. ifneq ($(NO_DEPS),true)
  915. -include $(${tgt.name.upper()}_OBJS:.o=.dep)
  916. endif
  917. % if tgt.get('secure', True):
  918. endif
  919. % endif
  920. </%def>
  921. .PHONY: all strip tools \
  922. dep_error openssl_dep_error openssl_dep_message git_update stop \
  923. buildtests buildtests_c buildtests_cxx \
  924. test test_c test_cxx \
  925. install install_c install_cxx \
  926. install-headers install-headers_c install-headers_cxx \
  927. install-shared install-shared_c install-shared_cxx \
  928. install-static install-static_c install-static_cxx \
  929. strip strip-shared strip-static \
  930. strip_c strip-shared_c strip-static_c \
  931. strip_cxx strip-shared_cxx strip-static_cxx \
  932. dep_c dep_cxx bins_dep_c bins_dep_cxx \
  933. clean