blob: 0cbd8bfdd552d5928efa1afdc172381411f1aa6e [file] [log] [blame]
Craig Tiller841c8802015-09-10 13:06:37 -07001%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
Craig Tiller3b935482015-02-16 12:15:48 -08009
Craig Tiller6169d5f2016-03-31 07:46:18 -070010 # Copyright 2015, Google Inc.
Craig Tiller841c8802015-09-10 13:06:37 -070011 # All rights reserved.
12 #
13 # Redistribution and use in source and binary forms, with or without
14 # modification, are permitted provided that the following conditions are
15 # met:
16 #
17 # * Redistributions of source code must retain the above copyright
18 # notice, this list of conditions and the following disclaimer.
19 # * Redistributions in binary form must reproduce the above
20 # copyright notice, this list of conditions and the following disclaimer
21 # in the documentation and/or other materials provided with the
22 # distribution.
23 # * Neither the name of Google Inc. nor the names of its
24 # contributors may be used to endorse or promote products derived from
25 # this software without specific prior written permission.
26 #
27 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
28 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
29 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
30 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
31 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
32 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
33 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
34 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
35 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
36 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
37 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38 <%!
39 import re
40 import os
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -080041
Craig Tiller841c8802015-09-10 13:06:37 -070042 proto_re = re.compile('(.*)\\.proto')
nnoble72309c62014-12-12 11:42:26 -080043
Craig Tiller841c8802015-09-10 13:06:37 -070044 def proto_to_cc(filename):
45 m = proto_re.match(filename)
46 if not m:
47 return filename
48 return '$(GENDIR)/' + m.group(1) + '.pb.cc $(GENDIR)/' + m.group(1) + '.grpc.pb.cc'
Nicolas "Pixel" Noble010f1e72015-04-23 02:23:49 +020049
Craig Tiller841c8802015-09-10 13:06:37 -070050 sources_that_need_openssl = set()
51 sources_that_don_t_need_openssl = set()
Craig Tiller78222f72016-05-10 09:55:38 -070052
53 # warnings we'd like, but that dont exist in all compilers
54 PREFERRED_WARNINGS=['shadow', 'extra-semi']
55 CHECK_WARNINGS=PREFERRED_WARNINGS + ['no-shift-negative-value']
56
57 def warning_var(fmt, warning):
58 return fmt % warning.replace('-', '_').upper()
59
60 def neg_warning(warning):
61 if warning[0:3] == 'no-':
62 return warning[3:]
63 else:
64 return 'no-' + warning
Craig Tiller841c8802015-09-10 13:06:37 -070065 %>
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -080066
Craig Tiller96b49552015-01-21 16:29:01 -080067
Craig Tiller71a86042016-01-15 14:59:58 -080068 comma := ,
69
70
Craig Tiller841c8802015-09-10 13:06:37 -070071 # Basic platform detection
72 HOST_SYSTEM = $(shell uname | cut -f 1 -d_)
Nicolas "Pixel" Noblec4e57e32016-01-30 21:05:35 +010073 SYSTEM ?= $(HOST_SYSTEM)
Craig Tiller841c8802015-09-10 13:06:37 -070074 ifeq ($(SYSTEM),MSYS)
75 SYSTEM = MINGW32
76 endif
77 ifeq ($(SYSTEM),MINGW64)
78 SYSTEM = MINGW32
79 endif
Craig Tiller96b49552015-01-21 16:29:01 -080080
81
Nicolas "Pixel" Noble6dad9b02015-09-23 18:32:26 +020082 MAKEFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST)))
Craig Tiller841c8802015-09-10 13:06:37 -070083 ifndef BUILDDIR
Nicolas "Pixel" Noble42b4c282015-09-17 23:57:08 +020084 BUILDDIR_ABSOLUTE = $(patsubst %/,%,$(dir $(MAKEFILE_PATH)))
85 else
86 BUILDDIR_ABSOLUTE = $(abspath $(BUILDDIR))
Craig Tiller841c8802015-09-10 13:06:37 -070087 endif
Craig Tiller61b910f2015-02-15 10:54:07 -080088
Craig Tiller841c8802015-09-10 13:06:37 -070089 HAS_GCC = $(shell which gcc > /dev/null 2> /dev/null && echo true || echo false)
90 HAS_CC = $(shell which cc > /dev/null 2> /dev/null && echo true || echo false)
91 HAS_CLANG = $(shell which clang > /dev/null 2> /dev/null && echo true || echo false)
Nicolas Noblef8681182015-03-18 14:25:44 -070092
Craig Tiller841c8802015-09-10 13:06:37 -070093 ifeq ($(HAS_CC),true)
94 DEFAULT_CC = cc
95 DEFAULT_CXX = c++
96 else
97 ifeq ($(HAS_GCC),true)
98 DEFAULT_CC = gcc
99 DEFAULT_CXX = g++
100 else
101 ifeq ($(HAS_CLANG),true)
102 DEFAULT_CC = clang
103 DEFAULT_CXX = clang++
104 else
105 DEFAULT_CC = no_c_compiler
106 DEFAULT_CXX = no_c++_compiler
107 endif
108 endif
109 endif
Nicolas Noblef8681182015-03-18 14:25:44 -0700110
111
Nicolas "Pixel" Noble42b4c282015-09-17 23:57:08 +0200112 BINDIR = $(BUILDDIR_ABSOLUTE)/bins
113 OBJDIR = $(BUILDDIR_ABSOLUTE)/objs
114 LIBDIR = $(BUILDDIR_ABSOLUTE)/libs
115 GENDIR = $(BUILDDIR_ABSOLUTE)/gens
Craig Tiller61b910f2015-02-15 10:54:07 -0800116
Craig Tiller841c8802015-09-10 13:06:37 -0700117 # Configurations
ctiller8cfebb92015-01-06 15:02:12 -0800118
Craig Tillera0f85172016-01-20 15:56:06 -0800119 % for name, args in configs.iteritems():
120 VALID_CONFIG_${name} = 1
121 % if args.get('compile_the_world', False):
122 REQUIRE_CUSTOM_LIBRARIES_${name} = 1
123 % endif
Craig Tilleraff3d502016-01-20 15:59:31 -0800124 % for tool, default in [('CC', 'CC'), ('CXX', 'CXX'), ('LD', 'CC'), ('LDXX', 'CXX')]:
Craig Tillera0f85172016-01-20 15:56:06 -0800125 ${tool}_${name} = ${args.get(tool, '$(DEFAULT_%s)' % default)}
126 % endfor
127 % for arg in ['CFLAGS', 'CXXFLAGS', 'CPPFLAGS', 'LDFLAGS', 'DEFINES']:
128 % if args.get(arg, None) is not None:
129 ${arg}_${name} = ${args.get(arg)}
130 % endif
131 % endfor
132 % if args.get('timeout_multiplier', 1) != 1:
133 DEFINES_${name} += GRPC_TEST_SLOWDOWN_BUILD_FACTOR=${args.timeout_multiplier}
134 % endif
ctiller8cfebb92015-01-06 15:02:12 -0800135
Craig Tillera0f85172016-01-20 15:56:06 -0800136 % endfor
Craig Tiller699ba212015-01-13 17:02:20 -0800137
Nicolas Noble047b7272015-01-16 13:55:05 -0800138
Craig Tiller841c8802015-09-10 13:06:37 -0700139 # General settings.
140 # You may want to change these depending on your system.
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800141
Craig Tiller841c8802015-09-10 13:06:37 -0700142 prefix ?= /usr/local
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800143
Nicolas "Pixel" Noble1a8eb852016-01-26 22:33:19 +0100144 PROTOC ?= protoc
145 DTRACE ?= dtrace
Craig Tiller841c8802015-09-10 13:06:37 -0700146 CONFIG ?= opt
Nicolas "Pixel" Noblefba36bc2016-01-27 03:24:03 +0100147 # Doing X ?= Y is the same as:
148 # ifeq ($(origin X), undefined)
149 # X = Y
150 # endif
151 # but some variables, such as CC, CXX, LD or AR, have defaults.
152 # So instead of using ?= on them, we need to check their origin.
153 # See:
154 # https://www.gnu.org/software/make/manual/html_node/Implicit-Variables.html
155 # https://www.gnu.org/software/make/manual/html_node/Flavors.html#index-_003f_003d
156 # https://www.gnu.org/software/make/manual/html_node/Origin-Function.html
157 ifeq ($(origin CC), default)
158 CC = $(CC_$(CONFIG))
159 endif
160 ifeq ($(origin CXX), default)
161 CXX = $(CXX_$(CONFIG))
162 endif
163 ifeq ($(origin LD), default)
164 LD = $(LD_$(CONFIG))
165 endif
Nicolas "Pixel" Noble1a8eb852016-01-26 22:33:19 +0100166 LDXX ?= $(LDXX_$(CONFIG))
Craig Tiller841c8802015-09-10 13:06:37 -0700167 ifeq ($(SYSTEM),Linux)
Nicolas "Pixel" Noble6e72dae2016-02-03 04:23:08 +0100168 ifeq ($(origin AR), default)
169 AR = ar rcs
170 endif
Nicolas "Pixel" Noble1a8eb852016-01-26 22:33:19 +0100171 STRIP ?= strip --strip-unneeded
Craig Tiller841c8802015-09-10 13:06:37 -0700172 else
173 ifeq ($(SYSTEM),Darwin)
Nicolas "Pixel" Noble6e72dae2016-02-03 04:23:08 +0100174 ifeq ($(origin AR), default)
Nicolas "Pixel" Noblee0dbd3f2016-02-23 00:21:38 +0100175 AR = libtool -no_warning_for_no_symbols -o
Nicolas "Pixel" Noble6e72dae2016-02-03 04:23:08 +0100176 endif
Nicolas "Pixel" Noble1a8eb852016-01-26 22:33:19 +0100177 STRIP ?= strip -x
Craig Tiller841c8802015-09-10 13:06:37 -0700178 else
Nicolas "Pixel" Noble6e72dae2016-02-03 04:23:08 +0100179 ifeq ($(origin AR), default)
180 AR = ar rcs
181 endif
Nicolas "Pixel" Noble1a8eb852016-01-26 22:33:19 +0100182 STRIP ?= strip
Craig Tiller841c8802015-09-10 13:06:37 -0700183 endif
184 endif
Nicolas "Pixel" Noble1a8eb852016-01-26 22:33:19 +0100185 INSTALL ?= install
186 RM ?= rm -f
187 PKG_CONFIG ?= pkg-config
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800188
Craig Tiller841c8802015-09-10 13:06:37 -0700189 ifndef VALID_CONFIG_$(CONFIG)
190 $(error Invalid CONFIG value '$(CONFIG)')
191 endif
yangg102e4fe2015-01-06 16:02:50 -0800192
Craig Tiller841c8802015-09-10 13:06:37 -0700193 ifeq ($(SYSTEM),Linux)
194 TMPOUT = /dev/null
195 else
196 TMPOUT = `mktemp /tmp/test-out-XXXXXX`
197 endif
Nicolas Noble047b7272015-01-16 13:55:05 -0800198
Craig Tiller841c8802015-09-10 13:06:37 -0700199 # Detect if we can use C++11
200 CXX11_CHECK_CMD = $(CXX) -std=c++11 -o $(TMPOUT) -c test/build/c++11.cc
201 HAS_CXX11 = $(shell $(CXX11_CHECK_CMD) 2> /dev/null && echo true || echo false)
Craig Tillercf133f42015-02-26 14:05:56 -0800202
Craig Tiller78222f72016-05-10 09:55:38 -0700203 %for warning in CHECK_WARNINGS:
204 ${warning_var('CHECK_%s_WORKS_CMD', warning)} = $(CC) -std=c99 -Werror -W${warning} -o $(TMPOUT) -c test/build/${warning}.c
205 ${warning_var('HAS_WORKING_%s', warning)} = $(shell $(${warning_var('CHECK_%s_WORKS_CMD', warning)}) 2> /dev/null && echo true || echo false)
206 ifeq ($(${warning_var('HAS_WORKING_%s', warning)}),true)
207 ${warning_var('W_%s', warning)}=-W${warning}
208 ${warning_var('NO_W_%s', warning)}=-W${neg_warning(warning)}
Craig Tiller804b8552016-02-23 16:50:24 -0800209 endif
Craig Tiller78222f72016-05-10 09:55:38 -0700210 %endfor
Craig Tiller16872b82016-01-25 10:55:20 -0800211
Craig Tiller841c8802015-09-10 13:06:37 -0700212 # The HOST compiler settings are used to compile the protoc plugins.
213 # In most cases, you won't have to change anything, but if you are
214 # cross-compiling, you can override these variables from GNU make's
215 # command line: make CC=cross-gcc HOST_CC=gcc
Nicolas Noble047b7272015-01-16 13:55:05 -0800216
Nicolas "Pixel" Noble1a8eb852016-01-26 22:33:19 +0100217 HOST_CC ?= $(CC)
218 HOST_CXX ?= $(CXX)
219 HOST_LD ?= $(LD)
220 HOST_LDXX ?= $(LDXX)
nnoble72309c62014-12-12 11:42:26 -0800221
Craig Tiller841c8802015-09-10 13:06:37 -0700222 ifdef EXTRA_DEFINES
223 DEFINES += $(EXTRA_DEFINES)
224 endif
Craig Tiller86fa1c52015-02-27 09:57:58 -0800225
Craig Tiller78222f72016-05-10 09:55:38 -0700226 CFLAGS += -std=c99 -Wsign-conversion -Wconversion ${' '.join(warning_var('$(W_%s)', warning) for warning in PREFERRED_WARNINGS)}
Craig Tiller841c8802015-09-10 13:06:37 -0700227 ifeq ($(HAS_CXX11),true)
228 CXXFLAGS += -std=c++11
229 else
230 CXXFLAGS += -std=c++0x
231 endif
Nicolas "Pixel" Noble51b1aee2016-01-28 01:14:58 +0100232 % for arg in ['CFLAGS', 'CXXFLAGS', 'CPPFLAGS', 'LDFLAGS', 'DEFINES']:
233 % if defaults.get('global', []).get(arg, None) is not None:
234 ${arg} += ${defaults.get('global').get(arg)}
235 % endif
236 % endfor
Nicolas Noblef8681182015-03-18 14:25:44 -0700237
Craig Tiller841c8802015-09-10 13:06:37 -0700238 CPPFLAGS += $(CPPFLAGS_$(CONFIG))
Craig Tiller0fe5ee72015-12-22 12:50:36 -0800239 CFLAGS += $(CFLAGS_$(CONFIG))
240 CXXFLAGS += $(CXXFLAGS_$(CONFIG))
Craig Tiller841c8802015-09-10 13:06:37 -0700241 DEFINES += $(DEFINES_$(CONFIG)) INSTALL_PREFIX=\"$(prefix)\"
242 LDFLAGS += $(LDFLAGS_$(CONFIG))
Nicolas "Pixel" Noble482d7612015-07-16 23:43:30 +0200243
Craig Tiller841c8802015-09-10 13:06:37 -0700244 ifneq ($(SYSTEM),MINGW32)
245 PIC_CPPFLAGS = -fPIC
246 CPPFLAGS += -fPIC
247 LDFLAGS += -fPIC
248 endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800249
Craig Tiller841c8802015-09-10 13:06:37 -0700250 INCLUDES = . include $(GENDIR)
251 LDFLAGS += -Llibs/$(CONFIG)
Nicolas "Pixel" Noble3adab742015-06-02 00:33:06 +0200252
Craig Tiller841c8802015-09-10 13:06:37 -0700253 ifeq ($(SYSTEM),Darwin)
254 ifneq ($(wildcard /usr/local/ssl/include),)
255 INCLUDES += /usr/local/ssl/include
256 endif
257 ifneq ($(wildcard /opt/local/include),)
258 INCLUDES += /opt/local/include
259 endif
260 ifneq ($(wildcard /usr/local/include),)
261 INCLUDES += /usr/local/include
262 endif
263 LIBS = m z
264 ifneq ($(wildcard /usr/local/ssl/lib),)
265 LDFLAGS += -L/usr/local/ssl/lib
266 endif
267 ifneq ($(wildcard /opt/local/lib),)
268 LDFLAGS += -L/opt/local/lib
269 endif
270 ifneq ($(wildcard /usr/local/lib),)
271 LDFLAGS += -L/usr/local/lib
272 endif
273 endif
Nicolas Noblef8681182015-03-18 14:25:44 -0700274
Craig Tiller841c8802015-09-10 13:06:37 -0700275 ifeq ($(SYSTEM),Linux)
Craig Tiller1b1e2382016-02-03 07:33:56 -0800276 LIBS = dl rt m pthread
Craig Tiller841c8802015-09-10 13:06:37 -0700277 LDFLAGS += -pthread
278 endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800279
Craig Tiller841c8802015-09-10 13:06:37 -0700280 ifeq ($(SYSTEM),MINGW32)
Nicolas "Pixel" Noblec4e57e32016-01-30 21:05:35 +0100281 LIBS = m pthread ws2_32
Craig Tiller841c8802015-09-10 13:06:37 -0700282 LDFLAGS += -pthread
283 endif
Nicolas Noblef8681182015-03-18 14:25:44 -0700284
Craig Tiller841c8802015-09-10 13:06:37 -0700285 GTEST_LIB = -Ithird_party/googletest/include -Ithird_party/googletest third_party/googletest/src/gtest-all.cc
286 GTEST_LIB += -lgflags
287 ifeq ($(V),1)
288 E = @:
289 Q =
290 else
291 E = @echo
292 Q = @
293 endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800294
Craig Tillerf008f062016-02-08 12:48:03 -0800295 VERSION = ${settings.core_version}
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800296
Craig Tiller841c8802015-09-10 13:06:37 -0700297 CPPFLAGS_NO_ARCH += $(addprefix -I, $(INCLUDES)) $(addprefix -D, $(DEFINES))
298 CPPFLAGS += $(CPPFLAGS_NO_ARCH) $(ARCH_FLAGS)
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800299
Craig Tiller841c8802015-09-10 13:06:37 -0700300 LDFLAGS += $(ARCH_FLAGS)
301 LDLIBS += $(addprefix -l, $(LIBS))
302 LDLIBSXX += $(addprefix -l, $(LIBSXX))
nnoble72309c62014-12-12 11:42:26 -0800303
Craig Tiller841c8802015-09-10 13:06:37 -0700304 HOST_CPPFLAGS = $(CPPFLAGS)
305 HOST_CFLAGS = $(CFLAGS)
306 HOST_CXXFLAGS = $(CXXFLAGS)
307 HOST_LDFLAGS = $(LDFLAGS)
308 HOST_LDLIBS = $(LDLIBS)
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800309
Craig Tiller841c8802015-09-10 13:06:37 -0700310 # These are automatically computed variables.
311 # There shouldn't be any need to change anything from now on.
nnoble69ac39f2014-12-12 15:43:38 -0800312
Craig Tiller841c8802015-09-10 13:06:37 -0700313 -include cache.mk
murgatroid9924e2f4a2015-06-29 11:12:01 -0700314
Craig Tiller841c8802015-09-10 13:06:37 -0700315 CACHE_MK =
murgatroid99aa521572015-07-10 14:49:12 -0700316
Craig Tiller841c8802015-09-10 13:06:37 -0700317 HAS_PKG_CONFIG ?= $(shell command -v $(PKG_CONFIG) >/dev/null 2>&1 && echo true || echo false)
murgatroid99aa521572015-07-10 14:49:12 -0700318
Craig Tiller841c8802015-09-10 13:06:37 -0700319 ifeq ($(HAS_PKG_CONFIG), true)
320 CACHE_MK += HAS_PKG_CONFIG = true,
321 endif
nnoble69ac39f2014-12-12 15:43:38 -0800322
Craig Tiller841c8802015-09-10 13:06:37 -0700323 PC_TEMPLATE = prefix=$(prefix),\
324 exec_prefix=${'\$${prefix}'},\
325 includedir=${'\$${prefix}'}/include,\
326 libdir=${'\$${exec_prefix}'}/lib,\
327 ,\
328 Name: $(PC_NAME),\
329 Description: $(PC_DESCRIPTION),\
330 Version: $(VERSION),\
331 Cflags: -I${'\$${includedir}'} $(PC_CFLAGS),\
332 Requires.private: $(PC_REQUIRES_PRIVATE),\
333 Libs: -L${'\$${libdir}'} $(PC_LIB),\
334 Libs.private: $(PC_LIBS_PRIVATE)
murgatroid998faab232015-06-30 17:24:21 -0700335
Craig Tiller841c8802015-09-10 13:06:37 -0700336 ifeq ($(SYSTEM),MINGW32)
337 SHARED_EXT = dll
Nicolas "Pixel" Noblec4e57e32016-01-30 21:05:35 +0100338 SHARED_PREFIX =
Craig Tillerf008f062016-02-08 12:48:03 -0800339 SHARED_VERSION = -${settings.core_version.major}
Nicolas "Pixel" Noblec4e57e32016-01-30 21:05:35 +0100340 else ifeq ($(SYSTEM),Darwin)
Craig Tiller841c8802015-09-10 13:06:37 -0700341 SHARED_EXT = dylib
Nicolas "Pixel" Noblec4e57e32016-01-30 21:05:35 +0100342 SHARED_PREFIX = lib
343 SHARED_VERSION =
344 else
Craig Tiller841c8802015-09-10 13:06:37 -0700345 SHARED_EXT = so.$(VERSION)
Nicolas "Pixel" Noblec4e57e32016-01-30 21:05:35 +0100346 SHARED_PREFIX = lib
347 SHARED_VERSION =
Craig Tiller841c8802015-09-10 13:06:37 -0700348 endif
nnoble5b7f32a2014-12-22 08:12:44 -0800349
Craig Tiller841c8802015-09-10 13:06:37 -0700350 ifeq ($(wildcard .git),)
351 IS_GIT_FOLDER = false
352 else
353 IS_GIT_FOLDER = true
354 endif
nnoble69ac39f2014-12-12 15:43:38 -0800355
Craig Tiller841c8802015-09-10 13:06:37 -0700356 ifeq ($(HAS_PKG_CONFIG),true)
357 OPENSSL_ALPN_CHECK_CMD = $(PKG_CONFIG) --atleast-version=1.0.2 openssl
358 OPENSSL_NPN_CHECK_CMD = $(PKG_CONFIG) --atleast-version=1.0.1 openssl
359 ZLIB_CHECK_CMD = $(PKG_CONFIG) --exists zlib
360 PROTOBUF_CHECK_CMD = $(PKG_CONFIG) --atleast-version=3.0.0-alpha-3 protobuf
361 else # HAS_PKG_CONFIG
murgatroid9924e2f4a2015-06-29 11:12:01 -0700362
Craig Tiller841c8802015-09-10 13:06:37 -0700363 ifeq ($(SYSTEM),MINGW32)
364 OPENSSL_LIBS = ssl32 eay32
365 else
366 OPENSSL_LIBS = ssl crypto
367 endif
Nicolas Noblef8681182015-03-18 14:25:44 -0700368
Nicolas "Pixel" Noble45000342016-01-28 05:04:45 +0100369 OPENSSL_ALPN_CHECK_CMD = $(CC) $(CPPFLAGS) $(CFLAGS) -o $(TMPOUT) test/build/openssl-alpn.c $(addprefix -l, $(OPENSSL_LIBS)) $(LDFLAGS)
370 OPENSSL_NPN_CHECK_CMD = $(CC) $(CPPFLAGS) $(CFLAGS) -o $(TMPOUT) test/build/openssl-npn.c $(addprefix -l, $(OPENSSL_LIBS)) $(LDFLAGS)
Craig Tillerb79c1e12016-02-23 10:00:58 -0800371 BORINGSSL_COMPILE_CHECK_CMD = $(CC) $(CPPFLAGS) ${defaults.boringssl.CPPFLAGS} $(CFLAGS) ${defaults.boringssl.CFLAGS} -o $(TMPOUT) test/build/boringssl.c $(LDFLAGS)
Nicolas "Pixel" Noble45000342016-01-28 05:04:45 +0100372 ZLIB_CHECK_CMD = $(CC) $(CPPFLAGS) $(CFLAGS) -o $(TMPOUT) test/build/zlib.c -lz $(LDFLAGS)
373 PROTOBUF_CHECK_CMD = $(CXX) $(CPPFLAGS) $(CXXFLAGS) -o $(TMPOUT) test/build/protobuf.cc -lprotobuf $(LDFLAGS)
Craig Tiller297fafa2015-01-15 15:46:39 -0800374
Craig Tiller841c8802015-09-10 13:06:37 -0700375 endif # HAS_PKG_CONFIG
murgatroid9924e2f4a2015-06-29 11:12:01 -0700376
Nicolas "Pixel" Noble45000342016-01-28 05:04:45 +0100377 PERFTOOLS_CHECK_CMD = $(CC) $(CPPFLAGS) $(CFLAGS) -o $(TMPOUT) test/build/perftools.c -lprofiler $(LDFLAGS)
murgatroid996d9e4012015-07-08 10:22:45 -0700378
Craig Tiller841c8802015-09-10 13:06:37 -0700379 PROTOC_CHECK_CMD = which protoc > /dev/null
380 PROTOC_CHECK_VERSION_CMD = protoc --version | grep -q libprotoc.3
381 DTRACE_CHECK_CMD = which dtrace > /dev/null
Nicolas "Pixel" Noble45000342016-01-28 05:04:45 +0100382 SYSTEMTAP_HEADERS_CHECK_CMD = $(CC) $(CPPFLAGS) $(CFLAGS) -o $(TMPOUT) test/build/systemtap.c $(LDFLAGS)
murgatroid9924e2f4a2015-06-29 11:12:01 -0700383
Craig Tiller841c8802015-09-10 13:06:37 -0700384 ifndef REQUIRE_CUSTOM_LIBRARIES_$(CONFIG)
385 HAS_SYSTEM_PERFTOOLS ?= $(shell $(PERFTOOLS_CHECK_CMD) 2> /dev/null && echo true || echo false)
386 ifeq ($(HAS_SYSTEM_PERFTOOLS),true)
387 DEFINES += GRPC_HAVE_PERFTOOLS
388 LIBS += profiler
389 CACHE_MK += HAS_SYSTEM_PERFTOOLS = true,
390 endif
391 endif
nnoble69ac39f2014-12-12 15:43:38 -0800392
Craig Tiller841c8802015-09-10 13:06:37 -0700393 HAS_SYSTEM_PROTOBUF_VERIFY = $(shell $(PROTOBUF_CHECK_CMD) 2> /dev/null && echo true || echo false)
394 ifndef REQUIRE_CUSTOM_LIBRARIES_$(CONFIG)
395 HAS_SYSTEM_OPENSSL_ALPN ?= $(shell $(OPENSSL_ALPN_CHECK_CMD) 2> /dev/null && echo true || echo false)
396 ifeq ($(HAS_SYSTEM_OPENSSL_ALPN),true)
397 HAS_SYSTEM_OPENSSL_NPN = true
398 CACHE_MK += HAS_SYSTEM_OPENSSL_ALPN = true,
399 else
400 HAS_SYSTEM_OPENSSL_NPN ?= $(shell $(OPENSSL_NPN_CHECK_CMD) 2> /dev/null && echo true || echo false)
401 endif
402 ifeq ($(HAS_SYSTEM_OPENSSL_NPN),true)
403 CACHE_MK += HAS_SYSTEM_OPENSSL_NPN = true,
404 endif
405 HAS_SYSTEM_ZLIB ?= $(shell $(ZLIB_CHECK_CMD) 2> /dev/null && echo true || echo false)
406 ifeq ($(HAS_SYSTEM_ZLIB),true)
407 CACHE_MK += HAS_SYSTEM_ZLIB = true,
408 endif
409 HAS_SYSTEM_PROTOBUF ?= $(HAS_SYSTEM_PROTOBUF_VERIFY)
410 ifeq ($(HAS_SYSTEM_PROTOBUF),true)
411 CACHE_MK += HAS_SYSTEM_PROTOBUF = true,
412 endif
413 else
414 # override system libraries if the config requires a custom compiled library
415 HAS_SYSTEM_OPENSSL_ALPN = false
416 HAS_SYSTEM_OPENSSL_NPN = false
417 HAS_SYSTEM_ZLIB = false
418 HAS_SYSTEM_PROTOBUF = false
419 endif
nnoble69ac39f2014-12-12 15:43:38 -0800420
Craig Tiller841c8802015-09-10 13:06:37 -0700421 HAS_PROTOC ?= $(shell $(PROTOC_CHECK_CMD) 2> /dev/null && echo true || echo false)
422 ifeq ($(HAS_PROTOC),true)
423 CACHE_MK += HAS_PROTOC = true,
424 HAS_VALID_PROTOC ?= $(shell $(PROTOC_CHECK_VERSION_CMD) 2> /dev/null && echo true || echo false)
425 ifeq ($(HAS_VALID_PROTOC),true)
426 CACHE_MK += HAS_VALID_PROTOC = true,
427 endif
428 else
429 HAS_VALID_PROTOC = false
430 endif
Nicolas Noble53830622015-02-12 16:56:38 -0800431
Craig Tiller841c8802015-09-10 13:06:37 -0700432 # Check for Systemtap (https://sourceware.org/systemtap/), first by making sure <sys/sdt.h> is present
433 # in the system and secondly by checking for the "dtrace" binary (on Linux, this is part of the Systemtap
434 # distribution. It's part of the base system on BSD/Solaris machines).
435 ifndef HAS_SYSTEMTAP
436 HAS_SYSTEMTAP_HEADERS = $(shell $(SYSTEMTAP_HEADERS_CHECK_CMD) 2> /dev/null && echo true || echo false)
437 HAS_DTRACE = $(shell $(DTRACE_CHECK_CMD) 2> /dev/null && echo true || echo false)
438 HAS_SYSTEMTAP = false
439 ifeq ($(HAS_SYSTEMTAP_HEADERS),true)
440 ifeq ($(HAS_DTRACE),true)
441 HAS_SYSTEMTAP = true
442 endif
443 endif
444 endif
David Garcia Quintas611b7362015-04-27 15:49:31 -0700445
Craig Tiller841c8802015-09-10 13:06:37 -0700446 ifeq ($(HAS_SYSTEMTAP),true)
447 CACHE_MK += HAS_SYSTEMTAP = true,
448 endif
nnoble69ac39f2014-12-12 15:43:38 -0800449
Craig Tiller841c8802015-09-10 13:06:37 -0700450 # Note that for testing purposes, one can do:
451 # make HAS_EMBEDDED_OPENSSL_ALPN=false
452 # to emulate the fact we do not have OpenSSL in the third_party folder.
Craig Tillerb79c1e12016-02-23 10:00:58 -0800453 ifneq ($(wildcard third_party/${openssl_fallback.extraction_dir}/libssl.a),)
454 HAS_EMBEDDED_OPENSSL_ALPN = third_party/${openssl_fallback.extraction_dir}
455 else ifeq ($(wildcard third_party/boringssl/include/openssl/ssl.h),)
Craig Tiller841c8802015-09-10 13:06:37 -0700456 HAS_EMBEDDED_OPENSSL_ALPN = false
457 else
Craig Tillerb79c1e12016-02-23 10:00:58 -0800458 CAN_COMPILE_EMBEDDED_OPENSSL ?= $(shell $(BORINGSSL_COMPILE_CHECK_CMD) 2> /dev/null && echo true || echo false)
459 HAS_EMBEDDED_OPENSSL_ALPN = $(CAN_COMPILE_EMBEDDED_OPENSSL)
Craig Tiller841c8802015-09-10 13:06:37 -0700460 endif
nnoble69ac39f2014-12-12 15:43:38 -0800461
Craig Tiller841c8802015-09-10 13:06:37 -0700462 ifeq ($(wildcard third_party/zlib/zlib.h),)
463 HAS_EMBEDDED_ZLIB = false
464 else
465 HAS_EMBEDDED_ZLIB = true
466 endif
nnoble69ac39f2014-12-12 15:43:38 -0800467
Craig Tiller841c8802015-09-10 13:06:37 -0700468 ifeq ($(wildcard third_party/protobuf/src/google/protobuf/descriptor.pb.h),)
469 HAS_EMBEDDED_PROTOBUF = false
470 ifneq ($(HAS_VALID_PROTOC),true)
471 NO_PROTOC = true
472 endif
473 else
474 HAS_EMBEDDED_PROTOBUF = true
475 endif
Nicolas Noble53830622015-02-12 16:56:38 -0800476
Nicolas "Pixel" Noble09121792016-01-30 09:01:53 +0100477 PC_REQUIRES_GRPC =
Craig Tiller841c8802015-09-10 13:06:37 -0700478 PC_LIBS_GRPC =
murgatroid998faab232015-06-30 17:24:21 -0700479
Craig Tiller841c8802015-09-10 13:06:37 -0700480 ifeq ($(HAS_SYSTEM_ZLIB),false)
Craig Tiller3dca23a2016-01-21 11:44:55 -0800481 ifeq ($(HAS_EMBEDDED_ZLIB), true)
482 EMBED_ZLIB ?= true
Craig Tiller841c8802015-09-10 13:06:37 -0700483 else
484 DEP_MISSING += zlib
Craig Tiller3dca23a2016-01-21 11:44:55 -0800485 EMBED_ZLIB ?= broken
Craig Tiller841c8802015-09-10 13:06:37 -0700486 endif
487 else
Craig Tiller3dca23a2016-01-21 11:44:55 -0800488 EMBED_ZLIB ?= false
489 endif
490
491 ifeq ($(EMBED_ZLIB),true)
492 ZLIB_DEP = $(LIBDIR)/$(CONFIG)/libz.a
493 ZLIB_MERGE_LIBS = $(LIBDIR)/$(CONFIG)/libz.a
Nicolas "Pixel" Noblef51a9012016-02-03 07:39:43 +0100494 ZLIB_MERGE_OBJS = $(LIBZ_OBJS)
Craig Tiller3dca23a2016-01-21 11:44:55 -0800495 CPPFLAGS += -Ithird_party/zlib
496 LDFLAGS += -L$(LIBDIR)/$(CONFIG)/zlib
497 else
Craig Tiller841c8802015-09-10 13:06:37 -0700498 ifeq ($(HAS_PKG_CONFIG),true)
499 CPPFLAGS += $(shell $(PKG_CONFIG) --cflags zlib)
500 LDFLAGS += $(shell $(PKG_CONFIG) --libs-only-L zlib)
Craig Tiller0fe5ee72015-12-22 12:50:36 -0800501 LIBS += $(patsubst -l%,%,$(shell $(PKG_CONFIG) --libs-only-l zlib))
Craig Tiller841c8802015-09-10 13:06:37 -0700502 PC_REQUIRES_GRPC += zlib
503 else
504 PC_LIBS_GRPC += -lz
Craig Tiller0fe5ee72015-12-22 12:50:36 -0800505 LIBS += z
Craig Tiller841c8802015-09-10 13:06:37 -0700506 endif
507 endif
nnoble69ac39f2014-12-12 15:43:38 -0800508
Craig Tiller841c8802015-09-10 13:06:37 -0700509 OPENSSL_PKG_CONFIG = false
murgatroid99da7a9942015-06-29 14:57:37 -0700510
Craig Tiller841c8802015-09-10 13:06:37 -0700511 PC_REQUIRES_SECURE =
512 PC_LIBS_SECURE =
murgatroid998faab232015-06-30 17:24:21 -0700513
Craig Tiller841c8802015-09-10 13:06:37 -0700514 ifeq ($(HAS_SYSTEM_OPENSSL_ALPN),true)
Craig Tiller0fe5ee72015-12-22 12:50:36 -0800515 EMBED_OPENSSL ?= false
516 NO_SECURE ?= false
517 else # HAS_SYSTEM_OPENSSL_ALPN=false
Craig Tillerb79c1e12016-02-23 10:00:58 -0800518 ifneq ($(HAS_EMBEDDED_OPENSSL_ALPN),false)
519 EMBED_OPENSSL ?= $(HAS_EMBEDDED_OPENSSL_ALPN)
Craig Tiller0fe5ee72015-12-22 12:50:36 -0800520 NO_SECURE ?= false
521 else # HAS_EMBEDDED_OPENSSL_ALPN=false
522 ifeq ($(HAS_SYSTEM_OPENSSL_NPN),true)
523 EMBED_OPENSSL ?= false
524 NO_SECURE ?= false
525 else
526 NO_SECURE ?= true
527 endif # HAS_SYSTEM_OPENSSL_NPN=true
528 endif # HAS_EMBEDDED_OPENSSL_ALPN
529 endif # HAS_SYSTEM_OPENSSL_ALPN
530
531 OPENSSL_DEP :=
532 OPENSSL_MERGE_LIBS :=
533 ifeq ($(NO_SECURE),false)
534 ifeq ($(EMBED_OPENSSL),true)
535 OPENSSL_DEP += $(LIBDIR)/$(CONFIG)/libboringssl.a
536 OPENSSL_MERGE_LIBS += $(LIBDIR)/$(CONFIG)/libboringssl.a
Nicolas "Pixel" Noblef51a9012016-02-03 07:39:43 +0100537 OPENSSL_MERGE_OBJS += $(LIBBORINGSSL_OBJS)
Craig Tiller0fe5ee72015-12-22 12:50:36 -0800538 # need to prefix these to ensure overriding system libraries
539 CPPFLAGS := -Ithird_party/boringssl/include $(CPPFLAGS)
Craig Tillerb79c1e12016-02-23 10:00:58 -0800540 else ifneq ($(EMBED_OPENSSL),false)
541 OPENSSL_DEP += $(EMBED_OPENSSL)/libssl.a $(EMBED_OPENSSL)/libcrypto.a
542 OPENSSL_MERGE_LIBS += $(EMBED_OPENSSL)/libssl.a $(EMBED_OPENSSL)/libcrypto.a
543 OPENSSL_MERGE_OBJS += $(wildcard $(EMBED_OPENSSL)/grpc_obj/*.o)
544 # need to prefix these to ensure overriding system libraries
545 CPPFLAGS := -I$(EMBED_OPENSSL)/include $(CPPFLAGS)
Craig Tiller0fe5ee72015-12-22 12:50:36 -0800546 else # EMBED_OPENSSL=false
Craig Tiller841c8802015-09-10 13:06:37 -0700547 ifeq ($(HAS_PKG_CONFIG),true)
548 OPENSSL_PKG_CONFIG = true
549 PC_REQUIRES_SECURE = openssl
550 CPPFLAGS := $(shell $(PKG_CONFIG) --cflags openssl) $(CPPFLAGS)
551 LDFLAGS_OPENSSL_PKG_CONFIG = $(shell $(PKG_CONFIG) --libs-only-L openssl)
552 ifeq ($(SYSTEM),Linux)
553 ifneq ($(LDFLAGS_OPENSSL_PKG_CONFIG),)
554 LDFLAGS_OPENSSL_PKG_CONFIG += $(shell $(PKG_CONFIG) --libs-only-L openssl | sed s/L/Wl,-rpath,/)
Craig Tiller0fe5ee72015-12-22 12:50:36 -0800555 endif # LDFLAGS_OPENSSL_PKG_CONFIG=''
556 endif # System=Linux
Craig Tiller841c8802015-09-10 13:06:37 -0700557 LDFLAGS := $(LDFLAGS_OPENSSL_PKG_CONFIG) $(LDFLAGS)
Craig Tiller0fe5ee72015-12-22 12:50:36 -0800558 else # HAS_PKG_CONFIG=false
Craig Tiller841c8802015-09-10 13:06:37 -0700559 LIBS_SECURE = $(OPENSSL_LIBS)
Craig Tiller0fe5ee72015-12-22 12:50:36 -0800560 endif # HAS_PKG_CONFIG
561 ifeq ($(HAS_SYSTEM_OPENSSL_NPN),true)
562 CPPFLAGS += -DTSI_OPENSSL_ALPN_SUPPORT=0
563 LIBS_SECURE = $(OPENSSL_LIBS)
564 endif # HAS_SYSTEM_OPENSSL_NPN
Craig Tiller841c8802015-09-10 13:06:37 -0700565 PC_LIBS_SECURE = $(addprefix -l, $(LIBS_SECURE))
Craig Tiller0fe5ee72015-12-22 12:50:36 -0800566 endif # EMBED_OPENSSL
567 endif # NO_SECURE
nnoble69ac39f2014-12-12 15:43:38 -0800568
Craig Tiller841c8802015-09-10 13:06:37 -0700569 ifeq ($(OPENSSL_PKG_CONFIG),true)
570 LDLIBS_SECURE += $(shell $(PKG_CONFIG) --libs-only-l openssl)
571 else
572 LDLIBS_SECURE += $(addprefix -l, $(LIBS_SECURE))
573 endif
nnoble5b7f32a2014-12-22 08:12:44 -0800574
Craig Tiller841c8802015-09-10 13:06:37 -0700575 # grpc .pc file
576 PC_NAME = gRPC
Craig Tillerda179ce2016-02-09 12:01:53 -0800577 PC_DESCRIPTION = high performance general RPC framework
578 PC_CFLAGS =
579 PC_REQUIRES_PRIVATE = $(PC_REQUIRES_GRPC) $(PC_REQUIRES_SECURE)
Craig Tiller841c8802015-09-10 13:06:37 -0700580 PC_LIBS_PRIVATE = $(PC_LIBS_GRPC) $(PC_LIBS_SECURE)
581 PC_LIB = -lgrpc
582 GRPC_PC_FILE := $(PC_TEMPLATE)
murgatroid998faab232015-06-30 17:24:21 -0700583
Craig Tiller4a67be42016-02-09 12:40:32 -0800584 # grpc_unsecure .pc file
Craig Tiller841c8802015-09-10 13:06:37 -0700585 PC_NAME = gRPC unsecure
Craig Tillerda179ce2016-02-09 12:01:53 -0800586 PC_DESCRIPTION = high performance general RPC framework without SSL
587 PC_CFLAGS =
588 PC_REQUIRES_PRIVATE = $(PC_REQUIRES_GRPC)
Craig Tiller841c8802015-09-10 13:06:37 -0700589 PC_LIBS_PRIVATE = $(PC_LIBS_GRPC)
590 PC_LIB = -lgrpc
591 GRPC_UNSECURE_PC_FILE := $(PC_TEMPLATE)
murgatroid998faab232015-06-30 17:24:21 -0700592
Craig Tiller841c8802015-09-10 13:06:37 -0700593 PROTOBUF_PKG_CONFIG = false
murgatroid99da7a9942015-06-29 14:57:37 -0700594
Craig Tiller841c8802015-09-10 13:06:37 -0700595 PC_REQUIRES_GRPCXX =
596 PC_LIBS_GRPCXX =
murgatroid998faab232015-06-30 17:24:21 -0700597
Craig Tiller841c8802015-09-10 13:06:37 -0700598 CPPFLAGS := -Ithird_party/googletest/include $(CPPFLAGS)
Craig Tiller16f6dac2015-08-24 17:00:04 -0700599
Craig Tiller841c8802015-09-10 13:06:37 -0700600 ifeq ($(HAS_SYSTEM_PROTOBUF),true)
601 ifeq ($(HAS_PKG_CONFIG),true)
602 PROTOBUF_PKG_CONFIG = true
603 PC_REQUIRES_GRPCXX = protobuf
604 CPPFLAGS := $(shell $(PKG_CONFIG) --cflags protobuf) $(CPPFLAGS)
605 LDFLAGS_PROTOBUF_PKG_CONFIG = $(shell $(PKG_CONFIG) --libs-only-L protobuf)
606 ifeq ($(SYSTEM),Linux)
607 ifneq ($(LDFLAGS_PROTOBUF_PKG_CONFIG),)
608 LDFLAGS_PROTOBUF_PKG_CONFIG += $(shell $(PKG_CONFIG) --libs-only-L protobuf | sed s/L/Wl,-rpath,/)
609 endif
610 endif
611 else
612 PC_LIBS_GRPCXX = -lprotobuf
613 endif
614 else
615 ifeq ($(HAS_EMBEDDED_PROTOBUF),true)
616 PROTOBUF_DEP = $(LIBDIR)/$(CONFIG)/protobuf/libprotobuf.a
617 CPPFLAGS := -Ithird_party/protobuf/src $(CPPFLAGS)
618 LDFLAGS := -L$(LIBDIR)/$(CONFIG)/protobuf $(LDFLAGS)
619 PROTOC = $(BINDIR)/$(CONFIG)/protobuf/protoc
620 else
621 NO_PROTOBUF = true
622 endif
623 endif
Nicolas Noble53830622015-02-12 16:56:38 -0800624
Craig Tiller841c8802015-09-10 13:06:37 -0700625 LIBS_PROTOBUF = protobuf
626 LIBS_PROTOC = protoc protobuf
Nicolas Noble53830622015-02-12 16:56:38 -0800627
Craig Tiller841c8802015-09-10 13:06:37 -0700628 HOST_LDLIBS_PROTOC += $(addprefix -l, $(LIBS_PROTOC))
Nicolas Noble53830622015-02-12 16:56:38 -0800629
Craig Tiller841c8802015-09-10 13:06:37 -0700630 ifeq ($(PROTOBUF_PKG_CONFIG),true)
631 LDLIBS_PROTOBUF += $(shell $(PKG_CONFIG) --libs-only-l protobuf)
632 else
633 LDLIBS_PROTOBUF += $(addprefix -l, $(LIBS_PROTOBUF))
634 endif
murgatroid9924e2f4a2015-06-29 11:12:01 -0700635
Craig Tiller841c8802015-09-10 13:06:37 -0700636 # grpc++ .pc file
637 PC_NAME = gRPC++
638 PC_DESCRIPTION = C++ wrapper for gRPC
639 PC_CFLAGS =
640 PC_REQUIRES_PRIVATE = grpc $(PC_REQUIRES_GRPCXX)
641 PC_LIBS_PRIVATE = $(PC_LIBS_GRPCXX)
642 PC_LIB = -lgrpc++
643 GRPCXX_PC_FILE := $(PC_TEMPLATE)
murgatroid998faab232015-06-30 17:24:21 -0700644
Craig Tiller841c8802015-09-10 13:06:37 -0700645 # grpc++_unsecure .pc file
646 PC_NAME = gRPC++ unsecure
647 PC_DESCRIPTION = C++ wrapper for gRPC without SSL
648 PC_CFLAGS =
649 PC_REQUIRES_PRIVATE = grpc_unsecure $(PC_REQUIRES_GRPCXX)
650 PC_LIBS_PRIVATE = $(PC_LIBS_GRPCXX)
651 PC_LIB = -lgrpc++
652 GRPCXX_UNSECURE_PC_FILE := $(PC_TEMPLATE)
murgatroid998faab232015-06-30 17:24:21 -0700653
Craig Tiller841c8802015-09-10 13:06:37 -0700654 ifeq ($(MAKECMDGOALS),clean)
655 NO_DEPS = true
656 endif
nnoble69ac39f2014-12-12 15:43:38 -0800657
Craig Tiller841c8802015-09-10 13:06:37 -0700658 INSTALL_OK = false
659 ifeq ($(HAS_VALID_PROTOC),true)
660 ifeq ($(HAS_SYSTEM_PROTOBUF_VERIFY),true)
661 INSTALL_OK = true
662 endif
663 endif
Nicolas "Pixel" Noble98ab9982015-02-21 04:22:16 +0100664
Craig Tiller841c8802015-09-10 13:06:37 -0700665 .SECONDARY = %.pb.h %.pb.cc
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800666
Craig Tiller841c8802015-09-10 13:06:37 -0700667 PROTOC_PLUGINS =\
668 % for tgt in targets:
669 % if tgt.build == 'protoc':
670 $(BINDIR)/$(CONFIG)/${tgt.name}\
671 % endif
672 % endfor
Craig Tillerf58b9ef2015-01-15 09:09:12 -0800673
Craig Tiller841c8802015-09-10 13:06:37 -0700674 ifeq ($(DEP_MISSING),)
675 all: static shared plugins\
676 % for tgt in targets:
677 % if tgt.build == 'all':
678 $(BINDIR)/$(CONFIG)/${tgt.name}\
679 % endif
680 % endfor
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800681
Craig Tiller841c8802015-09-10 13:06:37 -0700682 dep_error:
683 @echo "You shouldn't see this message - all of your dependencies are correct."
684 else
685 all: dep_error git_update stop
nnoble69ac39f2014-12-12 15:43:38 -0800686
Craig Tiller841c8802015-09-10 13:06:37 -0700687 dep_error:
688 @echo
689 @echo "DEPENDENCY ERROR"
690 @echo
691 @echo "You are missing system dependencies that are essential to build grpc,"
692 @echo "and the third_party directory doesn't have them:"
693 @echo
694 @echo " $(DEP_MISSING)"
695 @echo
696 @echo "Installing the development packages for your system will solve"
697 @echo "this issue. Please consult INSTALL to get more information."
698 @echo
699 @echo "If you need information about why these tests failed, run:"
700 @echo
701 @echo " make run_dep_checks"
702 @echo
703 endif
nnoble69ac39f2014-12-12 15:43:38 -0800704
Craig Tiller841c8802015-09-10 13:06:37 -0700705 git_update:
706 ifeq ($(IS_GIT_FOLDER),true)
707 @echo "Additionally, since you are in a git clone, you can download the"
708 @echo "missing dependencies in third_party by running the following command:"
709 @echo
710 @echo " git submodule update --init"
711 @echo
712 endif
nnoble69ac39f2014-12-12 15:43:38 -0800713
Craig Tiller841c8802015-09-10 13:06:37 -0700714 openssl_dep_error: openssl_dep_message git_update stop
nnoble69ac39f2014-12-12 15:43:38 -0800715
Craig Tiller841c8802015-09-10 13:06:37 -0700716 protobuf_dep_error: protobuf_dep_message git_update stop
Nicolas Noble53830622015-02-12 16:56:38 -0800717
Craig Tiller841c8802015-09-10 13:06:37 -0700718 protoc_dep_error: protoc_dep_message git_update stop
Nicolas Noble53830622015-02-12 16:56:38 -0800719
Craig Tiller841c8802015-09-10 13:06:37 -0700720 openssl_dep_message:
721 @echo
722 @echo "DEPENDENCY ERROR"
723 @echo
Craig Tillerb79c1e12016-02-23 10:00:58 -0800724 @echo "The target you are trying to run requires an OpenSSL implementation."
725 @echo "Your system doesn't have one, and either the third_party directory"
726 @echo "doesn't have it, or your compiler can't build BoringSSL."
Craig Tiller841c8802015-09-10 13:06:37 -0700727 @echo
728 @echo "Please consult INSTALL to get more information."
729 @echo
730 @echo "If you need information about why these tests failed, run:"
731 @echo
732 @echo " make run_dep_checks"
733 @echo
nnoble69ac39f2014-12-12 15:43:38 -0800734
Craig Tiller841c8802015-09-10 13:06:37 -0700735 protobuf_dep_message:
736 @echo
737 @echo "DEPENDENCY ERROR"
738 @echo
739 @echo "The target you are trying to run requires protobuf 3.0.0+"
740 @echo "Your system doesn't have it, and neither does the third_party directory."
741 @echo
742 @echo "Please consult INSTALL to get more information."
743 @echo
744 @echo "If you need information about why these tests failed, run:"
745 @echo
746 @echo " make run_dep_checks"
747 @echo
Nicolas Noble53830622015-02-12 16:56:38 -0800748
Craig Tiller841c8802015-09-10 13:06:37 -0700749 protoc_dep_message:
750 @echo
751 @echo "DEPENDENCY ERROR"
752 @echo
753 @echo "The target you are trying to run requires protobuf-compiler 3.0.0+"
754 @echo "Your system doesn't have it, and neither does the third_party directory."
755 @echo
756 @echo "Please consult INSTALL to get more information."
757 @echo
758 @echo "If you need information about why these tests failed, run:"
759 @echo
760 @echo " make run_dep_checks"
761 @echo
Nicolas Noble53830622015-02-12 16:56:38 -0800762
Craig Tiller841c8802015-09-10 13:06:37 -0700763 systemtap_dep_error:
764 @echo
765 @echo "DEPENDENCY ERROR"
766 @echo
767 @echo "Under the '$(CONFIG)' configutation, the target you are trying "
768 @echo "to build requires systemtap 2.7+ (on Linux) or dtrace (on other "
769 @echo "platforms such as Solaris and *BSD). "
770 @echo
771 @echo "Please consult INSTALL to get more information."
772 @echo
David Garcia Quintas8954e902015-04-29 09:46:33 -0700773
Craig Tiller841c8802015-09-10 13:06:37 -0700774 stop:
775 @false
nnoble69ac39f2014-12-12 15:43:38 -0800776
Craig Tiller841c8802015-09-10 13:06:37 -0700777 % for tgt in targets:
778 ${tgt.name}: $(BINDIR)/$(CONFIG)/${tgt.name}
779 % endfor
ctiller09cb6d52014-12-19 17:38:22 -0800780
Craig Tiller841c8802015-09-10 13:06:37 -0700781 run_dep_checks:
782 $(OPENSSL_ALPN_CHECK_CMD) || true
783 $(OPENSSL_NPN_CHECK_CMD) || true
784 $(ZLIB_CHECK_CMD) || true
785 $(PERFTOOLS_CHECK_CMD) || true
786 $(PROTOBUF_CHECK_CMD) || true
787 $(PROTOC_CHECK_VERSION_CMD) || true
nnoble69ac39f2014-12-12 15:43:38 -0800788
Craig Tiller841c8802015-09-10 13:06:37 -0700789 third_party/protobuf/configure:
790 $(E) "[AUTOGEN] Preparing protobuf"
791 $(Q)(cd third_party/protobuf ; autoreconf -f -i -Wall,no-obsolete)
Nicolas Noble53830622015-02-12 16:56:38 -0800792
Craig Tiller841c8802015-09-10 13:06:37 -0700793 $(LIBDIR)/$(CONFIG)/protobuf/libprotobuf.a: third_party/protobuf/configure
794 $(E) "[MAKE] Building protobuf"
795 $(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)
796 $(Q)$(MAKE) -C third_party/protobuf clean
797 $(Q)$(MAKE) -C third_party/protobuf
798 $(Q)mkdir -p $(LIBDIR)/$(CONFIG)/protobuf
799 $(Q)mkdir -p $(BINDIR)/$(CONFIG)/protobuf
800 $(Q)cp third_party/protobuf/src/.libs/libprotoc.a $(LIBDIR)/$(CONFIG)/protobuf
801 $(Q)cp third_party/protobuf/src/.libs/libprotobuf.a $(LIBDIR)/$(CONFIG)/protobuf
802 $(Q)cp third_party/protobuf/src/protoc $(BINDIR)/$(CONFIG)/protobuf
Nicolas Noble53830622015-02-12 16:56:38 -0800803
Craig Tiller841c8802015-09-10 13:06:37 -0700804 static: static_c static_cxx
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800805
Craig Tillereda85c62016-07-01 12:45:19 -0700806 static_c: pc_c pc_c_unsecure cache.mk \
Craig Tiller841c8802015-09-10 13:06:37 -0700807 % for lib in libs:
Nicolas "Pixel" Noblee0dbd3f2016-02-23 00:21:38 +0100808 % if 'Makefile' in lib.get('build_system', ['Makefile']):
Craig Tiller841c8802015-09-10 13:06:37 -0700809 % if lib.build == 'all' and lib.language == 'c' and not lib.get('external_deps', None):
810 $(LIBDIR)/$(CONFIG)/lib${lib.name}.a\
811 % endif
Nicolas "Pixel" Noblee0dbd3f2016-02-23 00:21:38 +0100812 % endif
Craig Tiller841c8802015-09-10 13:06:37 -0700813 % endfor
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800814
815
Nicolas "Pixel" Noble09121792016-01-30 09:01:53 +0100816 static_cxx: pc_cxx pc_cxx_unsecure cache.mk \
Craig Tiller841c8802015-09-10 13:06:37 -0700817 % for lib in libs:
Nicolas "Pixel" Noblee0dbd3f2016-02-23 00:21:38 +0100818 % if 'Makefile' in lib.get('build_system', ['Makefile']):
Craig Tiller841c8802015-09-10 13:06:37 -0700819 % if lib.build == 'all' and lib.language == 'c++':
820 $(LIBDIR)/$(CONFIG)/lib${lib.name}.a\
821 % endif
Nicolas "Pixel" Noblee0dbd3f2016-02-23 00:21:38 +0100822 % endif
Craig Tiller841c8802015-09-10 13:06:37 -0700823 % endfor
nnoble29e1d292014-12-01 10:27:40 -0800824
825
Craig Tiller841c8802015-09-10 13:06:37 -0700826 shared: shared_c shared_cxx
nnoble29e1d292014-12-01 10:27:40 -0800827
Craig Tillereda85c62016-07-01 12:45:19 -0700828 shared_c: pc_c pc_c_unsecure cache.mk\
Craig Tiller841c8802015-09-10 13:06:37 -0700829 % for lib in libs:
Nicolas "Pixel" Noblee0dbd3f2016-02-23 00:21:38 +0100830 % if 'Makefile' in lib.get('build_system', ['Makefile']):
Craig Tiller841c8802015-09-10 13:06:37 -0700831 % if lib.build == 'all' and lib.language == 'c' and not lib.get('external_deps', None):
Nicolas "Pixel" Noblec4e57e32016-01-30 21:05:35 +0100832 $(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)${lib.name}$(SHARED_VERSION).$(SHARED_EXT)\
Craig Tiller841c8802015-09-10 13:06:37 -0700833 % endif
Nicolas "Pixel" Noblee0dbd3f2016-02-23 00:21:38 +0100834 % endif
Craig Tiller841c8802015-09-10 13:06:37 -0700835 % endfor
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800836
Craig Tiller841c8802015-09-10 13:06:37 -0700837 shared_cxx: pc_cxx pc_cxx_unsecure cache.mk\
838 % for lib in libs:
Nicolas "Pixel" Noblee0dbd3f2016-02-23 00:21:38 +0100839 % if 'Makefile' in lib.get('build_system', ['Makefile']):
Craig Tiller841c8802015-09-10 13:06:37 -0700840 % if lib.build == 'all' and lib.language == 'c++':
Nicolas "Pixel" Noblec4e57e32016-01-30 21:05:35 +0100841 $(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)${lib.name}$(SHARED_VERSION).$(SHARED_EXT)\
Craig Tiller841c8802015-09-10 13:06:37 -0700842 % endif
Nicolas "Pixel" Noblee0dbd3f2016-02-23 00:21:38 +0100843 % endif
Craig Tiller841c8802015-09-10 13:06:37 -0700844 % endfor
nnoble29e1d292014-12-01 10:27:40 -0800845
846
Craig Tiller841c8802015-09-10 13:06:37 -0700847 shared_csharp: shared_c \
848 % for lib in libs:
Nicolas "Pixel" Noblee0dbd3f2016-02-23 00:21:38 +0100849 % if 'Makefile' in lib.get('build_system', ['Makefile']):
Craig Tiller841c8802015-09-10 13:06:37 -0700850 % if lib.build == 'all' and lib.language == 'csharp':
Nicolas "Pixel" Noblec4e57e32016-01-30 21:05:35 +0100851 $(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)${lib.name}$(SHARED_VERSION).$(SHARED_EXT)\
Craig Tiller841c8802015-09-10 13:06:37 -0700852 % endif
Nicolas "Pixel" Noblee0dbd3f2016-02-23 00:21:38 +0100853 % endif
Craig Tiller841c8802015-09-10 13:06:37 -0700854 % endfor
Jan Tattermusch2ec0b3e2015-02-18 15:03:12 -0800855
Craig Tiller841c8802015-09-10 13:06:37 -0700856 grpc_csharp_ext: shared_csharp
Jan Tattermusch2ec0b3e2015-02-18 15:03:12 -0800857
Craig Tiller841c8802015-09-10 13:06:37 -0700858 plugins: $(PROTOC_PLUGINS)
Nicolas "Pixel" Noble522d7122015-02-19 01:28:02 +0100859
Craig Tiller841c8802015-09-10 13:06:37 -0700860 privatelibs: privatelibs_c privatelibs_cxx
nnoble29e1d292014-12-01 10:27:40 -0800861
Craig Tiller841c8802015-09-10 13:06:37 -0700862 privatelibs_c: \
863 % for lib in libs:
Nicolas "Pixel" Noblee0dbd3f2016-02-23 00:21:38 +0100864 % if 'Makefile' in lib.get('build_system', ['Makefile']):
Craig Tiller0fe5ee72015-12-22 12:50:36 -0800865 % if lib.build == 'private' and lib.language == 'c' and not lib.get('external_deps', None) and not lib.boringssl:
Craig Tiller841c8802015-09-10 13:06:37 -0700866 $(LIBDIR)/$(CONFIG)/lib${lib.name}.a\
867 % endif
Nicolas "Pixel" Noblee0dbd3f2016-02-23 00:21:38 +0100868 % endif
Craig Tiller841c8802015-09-10 13:06:37 -0700869 % endfor
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800870
Craig Tiller841c8802015-09-10 13:06:37 -0700871 pc_c: $(LIBDIR)/$(CONFIG)/pkgconfig/grpc.pc
murgatroid998faab232015-06-30 17:24:21 -0700872
Craig Tiller841c8802015-09-10 13:06:37 -0700873 pc_c_unsecure: $(LIBDIR)/$(CONFIG)/pkgconfig/grpc_unsecure.pc
murgatroid998faab232015-06-30 17:24:21 -0700874
Craig Tiller841c8802015-09-10 13:06:37 -0700875 pc_cxx: $(LIBDIR)/$(CONFIG)/pkgconfig/grpc++.pc
murgatroid998faab232015-06-30 17:24:21 -0700876
Craig Tiller841c8802015-09-10 13:06:37 -0700877 pc_cxx_unsecure: $(LIBDIR)/$(CONFIG)/pkgconfig/grpc++_unsecure.pc
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800878
vjpai20410922016-06-15 09:21:42 -0700879 ifeq ($(EMBED_OPENSSL),true)
Craig Tiller841c8802015-09-10 13:06:37 -0700880 privatelibs_cxx: \
881 % for lib in libs:
Nicolas "Pixel" Noblee0dbd3f2016-02-23 00:21:38 +0100882 % if 'Makefile' in lib.get('build_system', ['Makefile']):
Craig Tiller841c8802015-09-10 13:06:37 -0700883 % if lib.build == 'private' and lib.language == 'c++' and not lib.get('external_deps', None):
884 $(LIBDIR)/$(CONFIG)/lib${lib.name}.a\
885 % endif
Nicolas "Pixel" Noblee0dbd3f2016-02-23 00:21:38 +0100886 % endif
Craig Tiller841c8802015-09-10 13:06:37 -0700887 % endfor
Craig Tillereda85c62016-07-01 12:45:19 -0700888
vjpai20410922016-06-15 09:21:42 -0700889 else
890 privatelibs_cxx: \
891 % for lib in libs:
892 % if 'Makefile' in lib.get('build_system', ['Makefile']):
893 % if lib.build == 'private' and lib.language == 'c++' and not lib.get('external_deps', None) and not lib.boringssl:
894 $(LIBDIR)/$(CONFIG)/lib${lib.name}.a\
895 % endif
896 % endif
897 % endfor
Craig Tillereda85c62016-07-01 12:45:19 -0700898
vjpai20410922016-06-15 09:21:42 -0700899 endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800900
901
Craig Tillereda85c62016-07-01 12:45:19 -0700902 buildtests: buildtests_c buildtests_cxx
nnoble29e1d292014-12-01 10:27:40 -0800903
Craig Tiller3824b6e2015-12-09 11:19:59 -0800904 buildtests_c: privatelibs_c <%text>\</%text>
Craig Tiller841c8802015-09-10 13:06:37 -0700905 % for tgt in targets:
906 % if tgt.build == 'test' and not tgt.language == 'c++' and not tgt.get('external_deps', None):
Craig Tiller3824b6e2015-12-09 11:19:59 -0800907 $(BINDIR)/$(CONFIG)/${tgt.name} <%text>\</%text>
Craig Tiller841c8802015-09-10 13:06:37 -0700908 % endif
909 % endfor
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800910
911
vjpai20410922016-06-15 09:21:42 -0700912 ifeq ($(EMBED_OPENSSL),true)
Craig Tillereda85c62016-07-01 12:45:19 -0700913 buildtests_cxx: privatelibs_cxx <%text>\</%text>
Craig Tiller841c8802015-09-10 13:06:37 -0700914 % for tgt in targets:
915 % if tgt.build == 'test' and tgt.language == 'c++' and not tgt.get('external_deps', None):
Craig Tiller3824b6e2015-12-09 11:19:59 -0800916 $(BINDIR)/$(CONFIG)/${tgt.name} <%text>\</%text>
Craig Tiller841c8802015-09-10 13:06:37 -0700917 % endif
918 % endfor
Craig Tillereda85c62016-07-01 12:45:19 -0700919
vjpai20410922016-06-15 09:21:42 -0700920 else
Craig Tillereda85c62016-07-01 12:45:19 -0700921 buildtests_cxx: privatelibs_cxx <%text>\</%text>
vjpai20410922016-06-15 09:21:42 -0700922 % for tgt in targets:
923 % if tgt.build == 'test' and tgt.language == 'c++' and not tgt.get('external_deps', None) and not tgt.boringssl:
924 $(BINDIR)/$(CONFIG)/${tgt.name} <%text>\</%text>
925 % endif
926 % endfor
Craig Tillereda85c62016-07-01 12:45:19 -0700927
vjpai20410922016-06-15 09:21:42 -0700928 endif
nnoble29e1d292014-12-01 10:27:40 -0800929
930
Craig Tillereda85c62016-07-01 12:45:19 -0700931 test: test_c test_cxx
nnoble29e1d292014-12-01 10:27:40 -0800932
Craig Tillereda85c62016-07-01 12:45:19 -0700933 flaky_test: flaky_test_c flaky_test_cxx
Nicolas "Pixel" Noble4251d562015-05-22 19:43:39 +0200934
Craig Tiller841c8802015-09-10 13:06:37 -0700935 test_c: buildtests_c
936 % for tgt in targets:
937 % 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):
938 $(E) "[RUN] Testing ${tgt.name}"
939 $(Q) $(BINDIR)/$(CONFIG)/${tgt.name} || ( echo test ${tgt.name} failed ; exit 1 )
940 % endif
941 % endfor
Nicolas "Pixel" Noble4251d562015-05-22 19:43:39 +0200942
943
Craig Tiller841c8802015-09-10 13:06:37 -0700944 flaky_test_c: buildtests_c
945 % for tgt in targets:
946 % 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):
947 $(E) "[RUN] Testing ${tgt.name}"
948 $(Q) $(BINDIR)/$(CONFIG)/${tgt.name} || ( echo test ${tgt.name} failed ; exit 1 )
949 % endif
950 % endfor
nnoble29e1d292014-12-01 10:27:40 -0800951
952
Craig Tillereda85c62016-07-01 12:45:19 -0700953 test_cxx: buildtests_cxx
Craig Tiller841c8802015-09-10 13:06:37 -0700954 % for tgt in targets:
955 % 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):
956 $(E) "[RUN] Testing ${tgt.name}"
957 $(Q) $(BINDIR)/$(CONFIG)/${tgt.name} || ( echo test ${tgt.name} failed ; exit 1 )
958 % endif
959 % endfor
Nicolas "Pixel" Noble4251d562015-05-22 19:43:39 +0200960
961
Craig Tiller841c8802015-09-10 13:06:37 -0700962 flaky_test_cxx: buildtests_cxx
963 % for tgt in targets:
964 % 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):
965 $(E) "[RUN] Testing ${tgt.name}"
966 $(Q) $(BINDIR)/$(CONFIG)/${tgt.name} || ( echo test ${tgt.name} failed ; exit 1 )
967 % endif
968 % endfor
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800969
970
Craig Tiller841c8802015-09-10 13:06:37 -0700971 test_python: static_c
972 $(E) "[RUN] Testing python code"
973 $(Q) tools/run_tests/run_tests.py -lpython -c$(CONFIG)
Nicolas "Pixel" Noble051a28f2015-03-17 22:54:54 +0100974
975
Craig Tiller841c8802015-09-10 13:06:37 -0700976 tools: tools_c tools_cxx
Craig Tiller7552f0f2015-06-19 17:46:20 -0700977
978
Craig Tiller841c8802015-09-10 13:06:37 -0700979 tools_c: privatelibs_c\
980 % for tgt in targets:
981 % if tgt.build == 'tool' and not tgt.language=='c++':
982 $(BINDIR)/$(CONFIG)/${tgt.name}\
983 % endif
984 % endfor
Craig Tiller7552f0f2015-06-19 17:46:20 -0700985
986
Craig Tiller841c8802015-09-10 13:06:37 -0700987 tools_cxx: privatelibs_cxx\
988 % for tgt in targets:
989 % if tgt.build == 'tool' and tgt.language=='c++':
990 $(BINDIR)/$(CONFIG)/${tgt.name}\
991 % endif
992 % endfor
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800993
994
Craig Tiller841c8802015-09-10 13:06:37 -0700995 buildbenchmarks: privatelibs\
996 % for tgt in targets:
997 % if tgt.build == 'benchmark':
998 $(BINDIR)/$(CONFIG)/${tgt.name}\
999 % endif
1000 % endfor
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001001
1002
Craig Tiller841c8802015-09-10 13:06:37 -07001003 benchmarks: buildbenchmarks
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001004
Craig Tiller841c8802015-09-10 13:06:37 -07001005 strip: strip-static strip-shared
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001006
Craig Tiller841c8802015-09-10 13:06:37 -07001007 strip-static: strip-static_c strip-static_cxx
nnoble20e2e3f2014-12-16 15:37:57 -08001008
Craig Tiller841c8802015-09-10 13:06:37 -07001009 strip-shared: strip-shared_c strip-shared_cxx
nnoble20e2e3f2014-12-16 15:37:57 -08001010
Nicolas Noble047b7272015-01-16 13:55:05 -08001011
Craig Tiller841c8802015-09-10 13:06:37 -07001012 # TODO(nnoble): the strip target is stripping in-place, instead
1013 # of copying files in a temporary folder.
1014 # This prevents proper debugging after running make install.
Nicolas Noble047b7272015-01-16 13:55:05 -08001015
Craig Tiller841c8802015-09-10 13:06:37 -07001016 strip-static_c: static_c
1017 ifeq ($(CONFIG),opt)
1018 % for lib in libs:
Nicolas "Pixel" Noblee0dbd3f2016-02-23 00:21:38 +01001019 % if 'Makefile' in lib.get('build_system', ['Makefile']):
Craig Tiller841c8802015-09-10 13:06:37 -07001020 % if lib.language == "c":
1021 % if lib.build == "all":
1022 % if not lib.get('external_deps', None):
1023 $(E) "[STRIP] Stripping lib${lib.name}.a"
1024 $(Q) $(STRIP) $(LIBDIR)/$(CONFIG)/lib${lib.name}.a
1025 % endif
1026 % endif
1027 % endif
Nicolas "Pixel" Noblee0dbd3f2016-02-23 00:21:38 +01001028 % endif
Craig Tiller841c8802015-09-10 13:06:37 -07001029 % endfor
Craig Tiller841c8802015-09-10 13:06:37 -07001030 endif
nnoble85a49262014-12-08 18:14:03 -08001031
Craig Tiller841c8802015-09-10 13:06:37 -07001032 strip-static_cxx: static_cxx
1033 ifeq ($(CONFIG),opt)
1034 % for lib in libs:
Nicolas "Pixel" Noblee0dbd3f2016-02-23 00:21:38 +01001035 % if 'Makefile' in lib.get('build_system', ['Makefile']):
Craig Tiller841c8802015-09-10 13:06:37 -07001036 % if lib.language == "c++":
1037 % if lib.build == "all":
1038 $(E) "[STRIP] Stripping lib${lib.name}.a"
1039 $(Q) $(STRIP) $(LIBDIR)/$(CONFIG)/lib${lib.name}.a
1040 % endif
1041 % endif
Nicolas "Pixel" Noblee0dbd3f2016-02-23 00:21:38 +01001042 % endif
Craig Tiller841c8802015-09-10 13:06:37 -07001043 % endfor
1044 endif
Nicolas "Pixel" Noble4ef9b862015-08-14 19:35:24 +02001045
Craig Tiller841c8802015-09-10 13:06:37 -07001046 strip-shared_c: shared_c
1047 ifeq ($(CONFIG),opt)
1048 % for lib in libs:
Nicolas "Pixel" Noblee0dbd3f2016-02-23 00:21:38 +01001049 % if 'Makefile' in lib.get('build_system', ['Makefile']):
Craig Tiller841c8802015-09-10 13:06:37 -07001050 % if lib.language == "c":
1051 % if lib.build == "all":
1052 % if not lib.get('external_deps', None):
Nicolas "Pixel" Noblec4e57e32016-01-30 21:05:35 +01001053 $(E) "[STRIP] Stripping $(SHARED_PREFIX)${lib.name}$(SHARED_VERSION).$(SHARED_EXT)"
1054 $(Q) $(STRIP) $(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)${lib.name}$(SHARED_VERSION).$(SHARED_EXT)
Craig Tiller841c8802015-09-10 13:06:37 -07001055 % endif
1056 % endif
1057 % endif
Nicolas "Pixel" Noblee0dbd3f2016-02-23 00:21:38 +01001058 % endif
Craig Tiller841c8802015-09-10 13:06:37 -07001059 % endfor
Craig Tiller841c8802015-09-10 13:06:37 -07001060 endif
nnoble85a49262014-12-08 18:14:03 -08001061
Craig Tiller841c8802015-09-10 13:06:37 -07001062 strip-shared_cxx: shared_cxx
1063 ifeq ($(CONFIG),opt)
1064 % for lib in libs:
Nicolas "Pixel" Noblee0dbd3f2016-02-23 00:21:38 +01001065 % if 'Makefile' in lib.get('build_system', ['Makefile']):
Craig Tiller841c8802015-09-10 13:06:37 -07001066 % if lib.language == "c++":
1067 % if lib.build == "all":
Nicolas "Pixel" Noblec4e57e32016-01-30 21:05:35 +01001068 $(E) "[STRIP] Stripping $(SHARED_PREFIX)${lib.name}$(SHARED_VERSION).$(SHARED_EXT)"
1069 $(Q) $(STRIP) $(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)${lib.name}$(SHARED_VERSION).$(SHARED_EXT)
Craig Tiller841c8802015-09-10 13:06:37 -07001070 % endif
1071 % endif
Nicolas "Pixel" Noblee0dbd3f2016-02-23 00:21:38 +01001072 % endif
Craig Tiller841c8802015-09-10 13:06:37 -07001073 % endfor
1074 endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001075
Craig Tiller841c8802015-09-10 13:06:37 -07001076 strip-shared_csharp: shared_csharp
1077 ifeq ($(CONFIG),opt)
1078 % for lib in libs:
Nicolas "Pixel" Noblee0dbd3f2016-02-23 00:21:38 +01001079 % if 'Makefile' in lib.get('build_system', ['Makefile']):
Craig Tiller841c8802015-09-10 13:06:37 -07001080 % if lib.language == "csharp":
1081 % if lib.build == "all":
Nicolas "Pixel" Noblec4e57e32016-01-30 21:05:35 +01001082 $(E) "[STRIP] Stripping $(SHARED_PREFIX)${lib.name}$(SHARED_VERSION).$(SHARED_EXT)"
1083 $(Q) $(STRIP) $(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)${lib.name}$(SHARED_VERSION).$(SHARED_EXT)
Craig Tiller841c8802015-09-10 13:06:37 -07001084 % endif
1085 % endif
Nicolas "Pixel" Noblee0dbd3f2016-02-23 00:21:38 +01001086 % endif
Craig Tiller841c8802015-09-10 13:06:37 -07001087 % endfor
1088 endif
Jan Tattermusch2ec0b3e2015-02-18 15:03:12 -08001089
Craig Tiller841c8802015-09-10 13:06:37 -07001090 cache.mk::
1091 $(E) "[MAKE] Generating $@"
1092 $(Q) echo "$(CACHE_MK)" | tr , '\n' >$@
murgatroid99aa521572015-07-10 14:49:12 -07001093
Craig Tiller841c8802015-09-10 13:06:37 -07001094 $(LIBDIR)/$(CONFIG)/pkgconfig/grpc.pc:
1095 $(E) "[MAKE] Generating $@"
1096 $(Q) mkdir -p $(@D)
1097 $(Q) echo "$(GRPC_PC_FILE)" | tr , '\n' >$@
murgatroid998faab232015-06-30 17:24:21 -07001098
Craig Tiller841c8802015-09-10 13:06:37 -07001099 $(LIBDIR)/$(CONFIG)/pkgconfig/grpc_unsecure.pc:
1100 $(E) "[MAKE] Generating $@"
1101 $(Q) mkdir -p $(@D)
1102 $(Q) echo "$(GRPC_UNSECURE_PC_FILE)" | tr , '\n' >$@
murgatroid998faab232015-06-30 17:24:21 -07001103
Craig Tiller841c8802015-09-10 13:06:37 -07001104 $(LIBDIR)/$(CONFIG)/pkgconfig/grpc++.pc:
1105 $(E) "[MAKE] Generating $@"
1106 $(Q) mkdir -p $(@D)
1107 $(Q) echo "$(GRPCXX_PC_FILE)" | tr , '\n' >$@
murgatroid998faab232015-06-30 17:24:21 -07001108
Craig Tiller841c8802015-09-10 13:06:37 -07001109 $(LIBDIR)/$(CONFIG)/pkgconfig/grpc++_unsecure.pc:
1110 $(E) "[MAKE] Generating $@"
1111 $(Q) mkdir -p $(@D)
1112 $(Q) echo "$(GRPCXX_UNSECURE_PC_FILE)" | tr , '\n' >$@
murgatroid998faab232015-06-30 17:24:21 -07001113
Craig Tiller841c8802015-09-10 13:06:37 -07001114 % for p in protos:
1115 ifeq ($(NO_PROTOC),true)
1116 $(GENDIR)/${p}.pb.cc: protoc_dep_error
1117 $(GENDIR)/${p}.grpc.pb.cc: protoc_dep_error
1118 else
Craig Tiller1b4e3302015-12-17 16:35:00 -08001119 $(GENDIR)/${p}.pb.cc: ${p}.proto $(PROTOBUF_DEP) $(PROTOC_PLUGINS) ${' '.join('$(GENDIR)/%s.pb.cc' % q for q in proto_deps.get(p, []))}
Craig Tiller841c8802015-09-10 13:06:37 -07001120 $(E) "[PROTOC] Generating protobuf CC file from $<"
1121 $(Q) mkdir -p `dirname $@`
David Garcia Quintase68ed6f2016-06-17 12:49:14 -07001122 $(Q) $(PROTOC) -Ithird_party/protobuf/src -I. --cpp_out=$(GENDIR) $<
Nicolas "Pixel" Noble0caebbf2015-04-09 23:08:51 +02001123
Craig Tiller1b4e3302015-12-17 16:35:00 -08001124 $(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, []))}
Craig Tiller841c8802015-09-10 13:06:37 -07001125 $(E) "[GRPC] Generating gRPC's protobuf service CC file from $<"
1126 $(Q) mkdir -p `dirname $@`
David Garcia Quintase68ed6f2016-06-17 12:49:14 -07001127 $(Q) $(PROTOC) -Ithird_party/protobuf/src -I. --grpc_out=$(GENDIR) --plugin=protoc-gen-grpc=$(BINDIR)/$(CONFIG)/grpc_cpp_plugin $<
Craig Tiller841c8802015-09-10 13:06:37 -07001128 endif
nnoble72309c62014-12-12 11:42:26 -08001129
Craig Tiller841c8802015-09-10 13:06:37 -07001130 % endfor
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001131
Craig Tiller841c8802015-09-10 13:06:37 -07001132 ifeq ($(CONFIG),stapprof)
1133 src/core/profiling/stap_timers.c: $(GENDIR)/src/core/profiling/stap_probes.h
1134 ifeq ($(HAS_SYSTEMTAP),true)
1135 $(GENDIR)/src/core/profiling/stap_probes.h: src/core/profiling/stap_probes.d
1136 $(E) "[DTRACE] Compiling $<"
1137 $(Q) mkdir -p `dirname $@`
1138 $(Q) $(DTRACE) -C -h -s $< -o $@
1139 else
1140 $(GENDIR)/src/core/profiling/stap_probes.h: systemtap_dep_error stop
1141 endif
1142 endif
David Garcia Quintas611b7362015-04-27 15:49:31 -07001143
Craig Tiller841c8802015-09-10 13:06:37 -07001144 $(OBJDIR)/$(CONFIG)/%.o : %.c
1145 $(E) "[C] Compiling $<"
1146 $(Q) mkdir -p `dirname $@`
Nicolas "Pixel" Noble45000342016-01-28 05:04:45 +01001147 $(Q) $(CC) $(CPPFLAGS) $(CFLAGS) -MMD -MF $(addsuffix .dep, $(basename $@)) -c -o $@ $<
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001148
Craig Tiller841c8802015-09-10 13:06:37 -07001149 $(OBJDIR)/$(CONFIG)/%.o : $(GENDIR)/%.pb.cc
1150 $(E) "[CXX] Compiling $<"
1151 $(Q) mkdir -p `dirname $@`
Nicolas "Pixel" Noble45000342016-01-28 05:04:45 +01001152 $(Q) $(CXX) $(CPPFLAGS) $(CXXFLAGS) -MMD -MF $(addsuffix .dep, $(basename $@)) -c -o $@ $<
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001153
Craig Tiller841c8802015-09-10 13:06:37 -07001154 $(OBJDIR)/$(CONFIG)/src/compiler/%.o : src/compiler/%.cc
1155 $(E) "[HOSTCXX] Compiling $<"
1156 $(Q) mkdir -p `dirname $@`
1157 $(Q) $(HOST_CXX) $(HOST_CXXFLAGS) $(HOST_CPPFLAGS) -MMD -MF $(addsuffix .dep, $(basename $@)) -c -o $@ $<
nnoble72309c62014-12-12 11:42:26 -08001158
Craig Tiller841c8802015-09-10 13:06:37 -07001159 $(OBJDIR)/$(CONFIG)/%.o : %.cc
1160 $(E) "[CXX] Compiling $<"
1161 $(Q) mkdir -p `dirname $@`
Nicolas "Pixel" Noble45000342016-01-28 05:04:45 +01001162 $(Q) $(CXX) $(CPPFLAGS) $(CXXFLAGS) -MMD -MF $(addsuffix .dep, $(basename $@)) -c -o $@ $<
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001163
Craig Tiller841c8802015-09-10 13:06:37 -07001164 install: install_c install_cxx install-plugins install-certs verify-install
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001165
Craig Tiller841c8802015-09-10 13:06:37 -07001166 install_c: install-headers_c install-static_c install-shared_c
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001167
Craig Tiller841c8802015-09-10 13:06:37 -07001168 install_cxx: install-headers_cxx install-static_cxx install-shared_cxx
nnoble85a49262014-12-08 18:14:03 -08001169
Craig Tiller841c8802015-09-10 13:06:37 -07001170 install_csharp: install-shared_csharp install_c
Jan Tattermusch2ec0b3e2015-02-18 15:03:12 -08001171
Craig Tiller841c8802015-09-10 13:06:37 -07001172 install_grpc_csharp_ext: install_csharp
Jan Tattermusch2ec0b3e2015-02-18 15:03:12 -08001173
Craig Tiller841c8802015-09-10 13:06:37 -07001174 install-headers: install-headers_c install-headers_cxx
nnoble85a49262014-12-08 18:14:03 -08001175
Craig Tiller841c8802015-09-10 13:06:37 -07001176 install-headers_c:
1177 $(E) "[INSTALL] Installing public C headers"
1178 $(Q) $(foreach h, $(PUBLIC_HEADERS_C), $(INSTALL) -d $(prefix)/$(dir $(h)) && ) exit 0 || exit 1
1179 $(Q) $(foreach h, $(PUBLIC_HEADERS_C), $(INSTALL) $(h) $(prefix)/$(h) && ) exit 0 || exit 1
nnoble85a49262014-12-08 18:14:03 -08001180
Craig Tiller841c8802015-09-10 13:06:37 -07001181 install-headers_cxx:
1182 $(E) "[INSTALL] Installing public C++ headers"
1183 $(Q) $(foreach h, $(PUBLIC_HEADERS_CXX), $(INSTALL) -d $(prefix)/$(dir $(h)) && ) exit 0 || exit 1
1184 $(Q) $(foreach h, $(PUBLIC_HEADERS_CXX), $(INSTALL) $(h) $(prefix)/$(h) && ) exit 0 || exit 1
nnoble85a49262014-12-08 18:14:03 -08001185
Craig Tiller841c8802015-09-10 13:06:37 -07001186 install-static: install-static_c install-static_cxx
nnoble85a49262014-12-08 18:14:03 -08001187
Craig Tiller841c8802015-09-10 13:06:37 -07001188 install-static_c: static_c strip-static_c install-pkg-config_c
1189 % for lib in libs:
Nicolas "Pixel" Noblee0dbd3f2016-02-23 00:21:38 +01001190 % if 'Makefile' in lib.get('build_system', ['Makefile']):
Craig Tiller841c8802015-09-10 13:06:37 -07001191 % if lib.language == "c":
1192 % if lib.build == "all":
1193 % if not lib.get('external_deps', None):
1194 $(E) "[INSTALL] Installing lib${lib.name}.a"
1195 $(Q) $(INSTALL) -d $(prefix)/lib
1196 $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/lib${lib.name}.a $(prefix)/lib/lib${lib.name}.a
1197 % endif
1198 % endif
1199 % endif
Nicolas "Pixel" Noblee0dbd3f2016-02-23 00:21:38 +01001200 % endif
Craig Tiller841c8802015-09-10 13:06:37 -07001201 % endfor
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001202
Craig Tiller841c8802015-09-10 13:06:37 -07001203 install-static_cxx: static_cxx strip-static_cxx install-pkg-config_cxx
1204 % for lib in libs:
Nicolas "Pixel" Noblee0dbd3f2016-02-23 00:21:38 +01001205 % if 'Makefile' in lib.get('build_system', ['Makefile']):
Craig Tiller841c8802015-09-10 13:06:37 -07001206 % if lib.language == "c++":
1207 % if lib.build == "all":
1208 $(E) "[INSTALL] Installing lib${lib.name}.a"
1209 $(Q) $(INSTALL) -d $(prefix)/lib
1210 $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/lib${lib.name}.a $(prefix)/lib/lib${lib.name}.a
1211 % endif
1212 % endif
Nicolas "Pixel" Noblee0dbd3f2016-02-23 00:21:38 +01001213 % endif
Craig Tiller841c8802015-09-10 13:06:37 -07001214 % endfor
nnoble85a49262014-12-08 18:14:03 -08001215
Craig Tiller841c8802015-09-10 13:06:37 -07001216 <%def name="install_shared(lang_filter)">\
1217 % for lib in libs:
Nicolas "Pixel" Noblee0dbd3f2016-02-23 00:21:38 +01001218 % if 'Makefile' in lib.get('build_system', ['Makefile']):
Craig Tiller841c8802015-09-10 13:06:37 -07001219 % if lib.language == lang_filter:
1220 % if lib.build == "all":
1221 % if not lib.get('external_deps', None):
Nicolas "Pixel" Noblec4e57e32016-01-30 21:05:35 +01001222 $(E) "[INSTALL] Installing $(SHARED_PREFIX)${lib.name}$(SHARED_VERSION).$(SHARED_EXT)"
1223 $(Q) $(INSTALL) -d $(prefix)/lib
1224 $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)${lib.name}$(SHARED_VERSION).$(SHARED_EXT) $(prefix)/lib/$(SHARED_PREFIX)${lib.name}$(SHARED_VERSION).$(SHARED_EXT)
Craig Tiller841c8802015-09-10 13:06:37 -07001225 ifeq ($(SYSTEM),MINGW32)
Craig Tiller841c8802015-09-10 13:06:37 -07001226 $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/lib${lib.name}-imp.a $(prefix)/lib/lib${lib.name}-imp.a
Nicolas "Pixel" Noblec4e57e32016-01-30 21:05:35 +01001227 else ifneq ($(SYSTEM),Darwin)
Craig Tillerf008f062016-02-08 12:48:03 -08001228 $(Q) ln -sf $(SHARED_PREFIX)${lib.name}$(SHARED_VERSION).$(SHARED_EXT) $(prefix)/lib/lib${lib.name}.so.${settings.core_version.major}
Nicolas "Pixel" Noblec4e57e32016-01-30 21:05:35 +01001229 $(Q) ln -sf $(SHARED_PREFIX)${lib.name}$(SHARED_VERSION).$(SHARED_EXT) $(prefix)/lib/lib${lib.name}.so
Craig Tiller841c8802015-09-10 13:06:37 -07001230 endif
1231 % endif
1232 % endif
1233 % endif
Nicolas "Pixel" Noblee0dbd3f2016-02-23 00:21:38 +01001234 % endif
Craig Tiller841c8802015-09-10 13:06:37 -07001235 % endfor
Craig Tiller841c8802015-09-10 13:06:37 -07001236 ifneq ($(SYSTEM),MINGW32)
1237 ifneq ($(SYSTEM),Darwin)
1238 $(Q) ldconfig || true
1239 endif
1240 endif
1241 </%def>
nnoble85a49262014-12-08 18:14:03 -08001242
Craig Tiller841c8802015-09-10 13:06:37 -07001243 install-shared_c: shared_c strip-shared_c install-pkg-config_c
1244 ${install_shared("c")}
Nicolas "Pixel" Noble522d7122015-02-19 01:28:02 +01001245
Craig Tiller841c8802015-09-10 13:06:37 -07001246 install-shared_cxx: shared_cxx strip-shared_cxx install-shared_c install-pkg-config_cxx
1247 ${install_shared("c++")}
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001248
Craig Tiller841c8802015-09-10 13:06:37 -07001249 install-shared_csharp: shared_csharp strip-shared_csharp
1250 ${install_shared("csharp")}
Nicolas "Pixel" Noble522d7122015-02-19 01:28:02 +01001251
Craig Tiller841c8802015-09-10 13:06:37 -07001252 install-plugins: $(PROTOC_PLUGINS)
1253 ifeq ($(SYSTEM),MINGW32)
1254 $(Q) false
1255 else
1256 $(E) "[INSTALL] Installing grpc protoc plugins"
1257 % for tgt in targets:
1258 % if tgt.build == 'protoc':
1259 $(Q) $(INSTALL) -d $(prefix)/bin
1260 $(Q) $(INSTALL) $(BINDIR)/$(CONFIG)/${tgt.name} $(prefix)/bin/${tgt.name}
1261 % endif
1262 % endfor
1263 endif
Jan Tattermusch2ec0b3e2015-02-18 15:03:12 -08001264
Craig Tillereda85c62016-07-01 12:45:19 -07001265 install-pkg-config_c: pc_c pc_c_unsecure
Craig Tiller841c8802015-09-10 13:06:37 -07001266 $(E) "[INSTALL] Installing C pkg-config files"
1267 $(Q) $(INSTALL) -d $(prefix)/lib/pkgconfig
Craig Tiller841c8802015-09-10 13:06:37 -07001268 $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/pkgconfig/grpc.pc $(prefix)/lib/pkgconfig/grpc.pc
1269 $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/pkgconfig/grpc_unsecure.pc $(prefix)/lib/pkgconfig/grpc_unsecure.pc
murgatroid998faab232015-06-30 17:24:21 -07001270
Craig Tiller841c8802015-09-10 13:06:37 -07001271 install-pkg-config_cxx: pc_cxx pc_cxx_unsecure
1272 $(E) "[INSTALL] Installing C++ pkg-config files"
1273 $(Q) $(INSTALL) -d $(prefix)/lib/pkgconfig
1274 $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/pkgconfig/grpc++.pc $(prefix)/lib/pkgconfig/grpc++.pc
1275 $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/pkgconfig/grpc++_unsecure.pc $(prefix)/lib/pkgconfig/grpc++_unsecure.pc
murgatroid998faab232015-06-30 17:24:21 -07001276
Craig Tiller841c8802015-09-10 13:06:37 -07001277 install-certs: etc/roots.pem
1278 $(E) "[INSTALL] Installing root certificates"
1279 $(Q) $(INSTALL) -d $(prefix)/share/grpc
1280 $(Q) $(INSTALL) etc/roots.pem $(prefix)/share/grpc/roots.pem
Nicolas "Pixel" Noble161ea232015-02-22 05:48:53 +01001281
Craig Tiller841c8802015-09-10 13:06:37 -07001282 verify-install:
1283 ifeq ($(INSTALL_OK),true)
1284 @echo "Your system looks ready to go."
1285 @echo
1286 else
murgatroid9973563262016-05-24 13:53:24 -07001287 @echo "Warning: it looks like protoc 3.0.0+ isn't installed on your system,"
1288 @echo "which means that you won't be able to compile .proto files for use"
1289 @echo "with gRPC."
Craig Tiller841c8802015-09-10 13:06:37 -07001290 @echo
murgatroid9973563262016-05-24 13:53:24 -07001291 @echo "If you are just using pre-compiled protocol buffers, or you otherwise"
1292 @echo "have no need to compile .proto files, you can ignore this."
Craig Tiller841c8802015-09-10 13:06:37 -07001293 @echo
murgatroid9973563262016-05-24 13:53:24 -07001294 @echo "If you do need protobuf for some reason, you can download and install"
1295 @echo "it from:"
Craig Tiller841c8802015-09-10 13:06:37 -07001296 @echo
1297 @echo " https://github.com/google/protobuf/releases"
1298 @echo
murgatroid9973563262016-05-24 13:53:24 -07001299 @echo "Once you've done so, you can re-run this check by doing:"
Craig Tiller841c8802015-09-10 13:06:37 -07001300 @echo
1301 @echo " make verify-install"
1302 endif
Nicolas "Pixel" Noble98ab9982015-02-21 04:22:16 +01001303
Craig Tiller841c8802015-09-10 13:06:37 -07001304 clean:
1305 $(E) "[CLEAN] Cleaning build directories."
1306 $(Q) $(RM) -rf $(OBJDIR) $(LIBDIR) $(BINDIR) $(GENDIR) cache.mk
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001307
1308
Craig Tiller841c8802015-09-10 13:06:37 -07001309 # The various libraries
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001310
Craig Tiller841c8802015-09-10 13:06:37 -07001311 % for lib in libs:
Nicolas "Pixel" Noblee0dbd3f2016-02-23 00:21:38 +01001312 % if 'Makefile' in lib.get('build_system', ['Makefile']):
Craig Tiller841c8802015-09-10 13:06:37 -07001313 ${makelib(lib)}
Nicolas "Pixel" Noblee0dbd3f2016-02-23 00:21:38 +01001314 % endif
Craig Tiller841c8802015-09-10 13:06:37 -07001315 % endfor
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001316
1317
Craig Tiller841c8802015-09-10 13:06:37 -07001318 # All of the test targets, and protoc plugins
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001319
Craig Tiller841c8802015-09-10 13:06:37 -07001320 % for tgt in targets:
1321 ${maketarget(tgt)}
1322 % endfor
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001323
Craig Tiller841c8802015-09-10 13:06:37 -07001324 <%def name="makelib(lib)">
1325 LIB${lib.name.upper()}_SRC = \\
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001326
Craig Tiller841c8802015-09-10 13:06:37 -07001327 % for src in lib.src:
1328 ${proto_to_cc(src)} \\
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001329
Craig Tiller841c8802015-09-10 13:06:37 -07001330 % endfor
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001331
Craig Tiller841c8802015-09-10 13:06:37 -07001332 % if "public_headers" in lib:
1333 % if lib.language == "c++":
1334 PUBLIC_HEADERS_CXX += \\
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001335
Craig Tiller841c8802015-09-10 13:06:37 -07001336 % else:
1337 PUBLIC_HEADERS_C += \\
nnoble85a49262014-12-08 18:14:03 -08001338
Craig Tiller841c8802015-09-10 13:06:37 -07001339 % endif
1340 % for hdr in lib.public_headers:
1341 ${hdr} \\
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001342
Craig Tiller841c8802015-09-10 13:06:37 -07001343 % endfor
1344 % endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001345
Craig Tiller841c8802015-09-10 13:06:37 -07001346 LIB${lib.name.upper()}_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(LIB${lib.name.upper()}_SRC))))
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001347
Nicolas "Pixel" Noble51b1aee2016-01-28 01:14:58 +01001348 % if lib.get('defaults', None):
1349 % for name, value in defaults.get(lib.defaults).iteritems():
1350 $(LIB${lib.name.upper()}_OBJS): ${name} += ${value}
1351 % endfor
Craig Tiller0fe5ee72015-12-22 12:50:36 -08001352 % endif
1353
Craig Tiller841c8802015-09-10 13:06:37 -07001354 ## If the library requires OpenSSL, let's add some restrictions.
1355 % if lib.get('secure', 'check') == True or lib.get('secure', 'check') == 'check':
1356 ifeq ($(NO_SECURE),true)
nnoble69ac39f2014-12-12 15:43:38 -08001357
Craig Tiller841c8802015-09-10 13:06:37 -07001358 # You can't build secure libraries if you don't have OpenSSL.
Nicolas Noble047b7272015-01-16 13:55:05 -08001359
Craig Tiller841c8802015-09-10 13:06:37 -07001360 $(LIBDIR)/$(CONFIG)/lib${lib.name}.a: openssl_dep_error
nnoble69ac39f2014-12-12 15:43:38 -08001361
Craig Tiller841c8802015-09-10 13:06:37 -07001362 % if lib.build == "all":
Nicolas "Pixel" Noblec4e57e32016-01-30 21:05:35 +01001363 $(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)${lib.name}$(SHARED_VERSION).$(SHARED_EXT): openssl_dep_error
Craig Tiller841c8802015-09-10 13:06:37 -07001364 % endif
nnoble5b7f32a2014-12-22 08:12:44 -08001365
Craig Tiller841c8802015-09-10 13:06:37 -07001366 else
nnoble69ac39f2014-12-12 15:43:38 -08001367
Craig Tiller841c8802015-09-10 13:06:37 -07001368 % if lib.language == 'c++':
1369 ifeq ($(NO_PROTOBUF),true)
Nicolas Noble53830622015-02-12 16:56:38 -08001370
Craig Tiller841c8802015-09-10 13:06:37 -07001371 # You can't build a C++ library if you don't have protobuf - a bit overreached, but still okay.
Nicolas Noble53830622015-02-12 16:56:38 -08001372
Craig Tiller841c8802015-09-10 13:06:37 -07001373 $(LIBDIR)/$(CONFIG)/lib${lib.name}.a: protobuf_dep_error
Nicolas Noble53830622015-02-12 16:56:38 -08001374
Craig Tiller841c8802015-09-10 13:06:37 -07001375 % if lib.build == "all":
Nicolas "Pixel" Noblec4e57e32016-01-30 21:05:35 +01001376 $(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)${lib.name}$(SHARED_VERSION).$(SHARED_EXT): protobuf_dep_error
Craig Tiller841c8802015-09-10 13:06:37 -07001377 % endif
Nicolas Noble53830622015-02-12 16:56:38 -08001378
Craig Tiller841c8802015-09-10 13:06:37 -07001379 else
1380 % endif
Nicolas Noble53830622015-02-12 16:56:38 -08001381
Craig Tiller841c8802015-09-10 13:06:37 -07001382 $(LIBDIR)/$(CONFIG)/lib${lib.name}.a: $(ZLIB_DEP) $(OPENSSL_DEP)\
1383 ## The else here corresponds to the if secure earlier.
1384 % else:
1385 % if lib.language == 'c++':
1386 ifeq ($(NO_PROTOBUF),true)
Nicolas Noble53830622015-02-12 16:56:38 -08001387
Craig Tiller841c8802015-09-10 13:06:37 -07001388 # You can't build a C++ library if you don't have protobuf - a bit overreached, but still okay.
Nicolas Noble53830622015-02-12 16:56:38 -08001389
Craig Tiller841c8802015-09-10 13:06:37 -07001390 $(LIBDIR)/$(CONFIG)/lib${lib.name}.a: protobuf_dep_error
Nicolas Noble53830622015-02-12 16:56:38 -08001391
Craig Tiller841c8802015-09-10 13:06:37 -07001392 % if lib.build == "all":
Nicolas "Pixel" Noblec4e57e32016-01-30 21:05:35 +01001393 $(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)${lib.name}$(SHARED_VERSION).$(SHARED_EXT): protobuf_dep_error
Craig Tiller841c8802015-09-10 13:06:37 -07001394 % endif
Nicolas Noble53830622015-02-12 16:56:38 -08001395
Craig Tiller841c8802015-09-10 13:06:37 -07001396 else
Nicolas Noble53830622015-02-12 16:56:38 -08001397
Craig Tiller841c8802015-09-10 13:06:37 -07001398 % endif
Nicolas "Pixel" Nobled649c212016-01-27 20:27:30 +01001399 $(LIBDIR)/$(CONFIG)/lib${lib.name}.a: \
1400 % if lib.name != 'z':
1401 $(ZLIB_DEP) \
1402 % endif
Craig Tiller841c8802015-09-10 13:06:37 -07001403 % endif
1404 % if lib.language == 'c++':
1405 $(PROTOBUF_DEP)\
1406 % endif
Nicolas "Pixel" Noblef51a9012016-02-03 07:39:43 +01001407 $(LIB${lib.name.upper()}_OBJS) \
1408 % if lib.get('baselib', False):
Craig Tiller1298afd2016-02-09 12:29:17 -08001409 $(LIBGPR_OBJS) \
Nicolas "Pixel" Noblef51a9012016-02-03 07:39:43 +01001410 $(ZLIB_MERGE_OBJS) \
1411 % if lib.get('secure', 'check') == True:
1412 $(OPENSSL_MERGE_OBJS) \
1413 % endif
1414 % endif
1415
Craig Tiller841c8802015-09-10 13:06:37 -07001416 $(E) "[AR] Creating $@"
1417 $(Q) mkdir -p `dirname $@`
1418 $(Q) rm -f $(LIBDIR)/$(CONFIG)/lib${lib.name}.a
Nicolas "Pixel" Noblef51a9012016-02-03 07:39:43 +01001419 $(Q) $(AR) $(LIBDIR)/$(CONFIG)/lib${lib.name}.a $(LIB${lib.name.upper()}_OBJS) \
Craig Tiller841c8802015-09-10 13:06:37 -07001420 % if lib.get('baselib', False):
Craig Tiller1298afd2016-02-09 12:29:17 -08001421 $(LIBGPR_OBJS) \
Nicolas "Pixel" Noblef51a9012016-02-03 07:39:43 +01001422 $(ZLIB_MERGE_OBJS) \
Craig Tiller841c8802015-09-10 13:06:37 -07001423 % if lib.get('secure', 'check') == True:
Nicolas "Pixel" Noblef51a9012016-02-03 07:39:43 +01001424 $(OPENSSL_MERGE_OBJS) \
Craig Tiller841c8802015-09-10 13:06:37 -07001425 % endif
1426 % endif
Nicolas "Pixel" Noblef51a9012016-02-03 07:39:43 +01001427
Craig Tiller841c8802015-09-10 13:06:37 -07001428 ifeq ($(SYSTEM),Darwin)
Nicolas "Pixel" Noblee0dbd3f2016-02-23 00:21:38 +01001429 $(Q) ranlib -no_warning_for_no_symbols $(LIBDIR)/$(CONFIG)/lib${lib.name}.a
Craig Tiller841c8802015-09-10 13:06:37 -07001430 endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001431
Craig Tiller841c8802015-09-10 13:06:37 -07001432 <%
Nicolas "Pixel" Noble010f1e72015-04-23 02:23:49 +02001433
Craig Tiller841c8802015-09-10 13:06:37 -07001434 if lib.language == 'c++':
1435 ld = '$(LDXX)'
1436 else:
1437 ld = '$(LD)'
nnoble5b7f32a2014-12-22 08:12:44 -08001438
Nicolas "Pixel" Noblec4e57e32016-01-30 21:05:35 +01001439 out_mingbase = '$(LIBDIR)/$(CONFIG)/' + lib.name + '$(SHARED_VERSION)'
1440 out_libbase = '$(LIBDIR)/$(CONFIG)/lib' + lib.name + '$(SHARED_VERSION)'
nnoble5b7f32a2014-12-22 08:12:44 -08001441
Craig Tiller841c8802015-09-10 13:06:37 -07001442 common = '$(LIB' + lib.name.upper() + '_OBJS) $(LDLIBS)'
nnoble5b7f32a2014-12-22 08:12:44 -08001443
Craig Tiller841c8802015-09-10 13:06:37 -07001444 libs = ''
1445 lib_deps = ' $(ZLIB_DEP)'
1446 mingw_libs = ''
1447 mingw_lib_deps = ' $(ZLIB_DEP)'
1448 if lib.language == 'c++':
1449 lib_deps += ' $(PROTOBUF_DEP)'
1450 mingw_lib_deps += ' $(PROTOBUF_DEP)'
Jan Tattermusch324140c2016-01-12 08:54:01 -08001451 if lib.get('deps_linkage', None) == 'static':
1452 for dep in lib.get('deps', []):
1453 lib_archive = '$(LIBDIR)/$(CONFIG)/lib' + dep + '.a'
1454 common = common + ' ' + lib_archive
1455 lib_deps = lib_deps + ' ' + lib_archive
1456 mingw_lib_deps = mingw_lib_deps + ' ' + lib_archive
1457 else:
1458 for dep in lib.get('deps', []):
1459 libs = libs + ' -l' + dep
1460 lib_deps = lib_deps + ' $(LIBDIR)/$(CONFIG)/lib' + dep + '.$(SHARED_EXT)'
1461 mingw_libs = mingw_libs + ' -l' + dep + '-imp'
1462 mingw_lib_deps = mingw_lib_deps + ' $(LIBDIR)/$(CONFIG)/' + dep + '.$(SHARED_EXT)'
nnoble5b7f32a2014-12-22 08:12:44 -08001463
Craig Tiller841c8802015-09-10 13:06:37 -07001464 security = lib.get('secure', 'check')
1465 if security == True:
1466 common = common + ' $(OPENSSL_MERGE_LIBS) $(LDLIBS_SECURE)'
Craig Tiller0fe5ee72015-12-22 12:50:36 -08001467 common = common + ' $(ZLIB_MERGE_LIBS)'
Nicolas "Pixel" Noblea7c162c2015-07-24 20:21:51 +02001468
Craig Tiller841c8802015-09-10 13:06:37 -07001469 if security in [True, 'check']:
1470 for src in lib.src:
1471 if not proto_re.match(src):
1472 sources_that_need_openssl.add(src)
1473 else:
1474 for src in lib.src:
1475 sources_that_don_t_need_openssl.add(src)
Nicolas "Pixel" Noble061690d2015-03-06 22:58:58 +01001476
Craig Tiller841c8802015-09-10 13:06:37 -07001477 if lib.get('secure', 'check') == True or lib.get('secure', 'check') == 'check':
1478 lib_deps = lib_deps + ' $(OPENSSL_DEP)'
1479 mingw_lib_deps = mingw_lib_deps + ' $(OPENSSL_DEP)'
Nicolas "Pixel" Nobledda049c2015-02-21 00:39:32 +01001480
Craig Tiller841c8802015-09-10 13:06:37 -07001481 if lib.language == 'c++':
1482 common = common + ' $(LDLIBSXX) $(LDLIBS_PROTOBUF)'
Craig Tiller4bef7ce2016-02-02 08:38:43 -08001483
1484 ldflags = '$(LDFLAGS)'
1485 if lib.get('LDFLAGS', None):
1486 ldflags += ' ' + lib['LDFLAGS']
Craig Tiller841c8802015-09-10 13:06:37 -07001487 %>
nnoble5b7f32a2014-12-22 08:12:44 -08001488
Craig Tiller841c8802015-09-10 13:06:37 -07001489 % if lib.build == "all":
1490 ifeq ($(SYSTEM),MINGW32)
Nicolas "Pixel" Noblec4e57e32016-01-30 21:05:35 +01001491 ${out_mingbase}.$(SHARED_EXT): $(LIB${lib.name.upper()}_OBJS) ${mingw_lib_deps}
Craig Tiller841c8802015-09-10 13:06:37 -07001492 $(E) "[LD] Linking $@"
1493 $(Q) mkdir -p `dirname $@`
Nicolas "Pixel" Noble89d8ed12016-02-03 01:12:14 +01001494 $(Q) ${ld} ${ldflags} -L$(LIBDIR)/$(CONFIG) -shared ${lib.name}.def -Wl,--output-def=${out_mingbase}.def -Wl,--out-implib=${out_libbase}-dll.a -o ${out_mingbase}.$(SHARED_EXT) ${common}${mingw_libs}
Craig Tiller841c8802015-09-10 13:06:37 -07001495 else
1496 ${out_libbase}.$(SHARED_EXT): $(LIB${lib.name.upper()}_OBJS) ${lib_deps}
1497 $(E) "[LD] Linking $@"
1498 $(Q) mkdir -p `dirname $@`
1499 ifeq ($(SYSTEM),Darwin)
Nicolas "Pixel" Noble89d8ed12016-02-03 01:12:14 +01001500 $(Q) ${ld} ${ldflags} -L$(LIBDIR)/$(CONFIG) -install_name $(SHARED_PREFIX)${lib.name}$(SHARED_VERSION).$(SHARED_EXT) -dynamiclib -o ${out_libbase}.$(SHARED_EXT) ${common}${libs}
Craig Tiller841c8802015-09-10 13:06:37 -07001501 else
Craig Tillerf008f062016-02-08 12:48:03 -08001502 $(Q) ${ld} ${ldflags} -L$(LIBDIR)/$(CONFIG) -shared -Wl,-soname,lib${lib.name}.so.${settings.core_version.major} -o ${out_libbase}.$(SHARED_EXT) ${common}${libs}
1503 $(Q) ln -sf $(SHARED_PREFIX)${lib.name}$(SHARED_VERSION).$(SHARED_EXT) ${out_libbase}.so.${settings.core_version.major}
Nicolas "Pixel" Noblec4e57e32016-01-30 21:05:35 +01001504 $(Q) ln -sf $(SHARED_PREFIX)${lib.name}$(SHARED_VERSION).$(SHARED_EXT) ${out_libbase}.so
Craig Tiller841c8802015-09-10 13:06:37 -07001505 endif
1506 endif
1507 % endif
1508 % if lib.get('secure', 'check') == True or lib.get('secure', 'check') == 'check':
1509 ## If the lib was secure, we have to close the Makefile's if that tested
1510 ## the presence of OpenSSL.
Nicolas Noble53830622015-02-12 16:56:38 -08001511
Craig Tiller841c8802015-09-10 13:06:37 -07001512 endif
1513 % endif
1514 % if lib.language == 'c++':
1515 ## If the lib was C++, we have to close the Makefile's if that tested
1516 ## the presence of protobuf 3.0.0+
nnoble69ac39f2014-12-12 15:43:38 -08001517
Craig Tiller841c8802015-09-10 13:06:37 -07001518 endif
1519 % endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001520
Craig Tiller841c8802015-09-10 13:06:37 -07001521 % if lib.get('secure', 'check') == True or lib.get('secure', 'check') == 'check':
1522 ifneq ($(NO_SECURE),true)
1523 % endif
1524 ifneq ($(NO_DEPS),true)
1525 -include $(LIB${lib.name.upper()}_OBJS:.o=.dep)
1526 endif
1527 % if lib.get('secure', 'check') == True or lib.get('secure', 'check') == 'check':
1528 endif
1529 % endif
1530 % for src in lib.src:
1531 % if not proto_re.match(src) and any(proto_re.match(src2) for src2 in lib.src):
1532 $(OBJDIR)/$(CONFIG)/${os.path.splitext(src)[0]}.o: ${' '.join(proto_to_cc(src2) for src2 in lib.src if proto_re.match(src2))}
1533 % endif
1534 % endfor
1535 </%def>
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001536
Craig Tiller841c8802015-09-10 13:06:37 -07001537 <%def name="maketarget(tgt)"><% has_no_sources = not tgt.src %>
1538 % if not has_no_sources:
1539 ${tgt.name.upper()}_SRC = \\
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001540
Craig Tiller841c8802015-09-10 13:06:37 -07001541 % for src in tgt.src:
1542 ${proto_to_cc(src)} \\
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001543
Craig Tiller841c8802015-09-10 13:06:37 -07001544 % endfor
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001545
Craig Tiller841c8802015-09-10 13:06:37 -07001546 ${tgt.name.upper()}_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(${tgt.name.upper()}_SRC))))
1547 % endif
1548 % if tgt.get('secure', 'check') == True or tgt.get('secure', 'check') == 'check':
1549 ifeq ($(NO_SECURE),true)
nnoble69ac39f2014-12-12 15:43:38 -08001550
Craig Tiller841c8802015-09-10 13:06:37 -07001551 # You can't build secure targets if you don't have OpenSSL.
Nicolas Noble047b7272015-01-16 13:55:05 -08001552
Craig Tiller841c8802015-09-10 13:06:37 -07001553 $(BINDIR)/$(CONFIG)/${tgt.name}: openssl_dep_error
nnoble69ac39f2014-12-12 15:43:38 -08001554
Craig Tiller841c8802015-09-10 13:06:37 -07001555 else
nnoble69ac39f2014-12-12 15:43:38 -08001556
Craig Tiller841c8802015-09-10 13:06:37 -07001557 % endif
Craig Tiller0fe5ee72015-12-22 12:50:36 -08001558
1559 % if tgt.boringssl:
1560 # boringssl needs an override to ensure that it does not include
1561 # system openssl headers regardless of other configuration
1562 # we do so here with a target specific variable assignment
Craig Tiller78222f72016-05-10 09:55:38 -07001563 $(${tgt.name.upper()}_OBJS): CFLAGS := -Ithird_party/boringssl/include $(CFLAGS) -Wno-sign-conversion -Wno-conversion -Wno-unused-value $(NO_W_EXTRA_SEMI)
Craig Tiller0fe5ee72015-12-22 12:50:36 -08001564 $(${tgt.name.upper()}_OBJS): CXXFLAGS := -Ithird_party/boringssl/include $(CXXFLAGS)
1565 $(${tgt.name.upper()}_OBJS): CPPFLAGS += -DOPENSSL_NO_ASM -D_GNU_SOURCE
1566 % else:
1567 % endif
1568
Craig Tiller841c8802015-09-10 13:06:37 -07001569 ##
1570 ## We're not trying to add a dependency on building zlib and openssl here,
1571 ## as it's already done in the libraries. We're assuming that the build
1572 ## trickles down, and that a secure target requires a secure version of
1573 ## a library.
1574 ##
1575 ## That simplifies the codegen a bit, but prevents a fully defined Makefile.
1576 ## I can live with that.
1577 ##
1578 % if tgt.build == 'protoc' or tgt.language == 'c++':
Nicolas Noble53830622015-02-12 16:56:38 -08001579
Craig Tiller841c8802015-09-10 13:06:37 -07001580 ifeq ($(NO_PROTOBUF),true)
Nicolas Noble53830622015-02-12 16:56:38 -08001581
Craig Tiller841c8802015-09-10 13:06:37 -07001582 # You can't build the protoc plugins or protobuf-enabled targets if you don't have protobuf 3.0.0+.
Nicolas Noble53830622015-02-12 16:56:38 -08001583
Craig Tiller841c8802015-09-10 13:06:37 -07001584 $(BINDIR)/$(CONFIG)/${tgt.name}: protobuf_dep_error
Nicolas Noble53830622015-02-12 16:56:38 -08001585
Craig Tiller841c8802015-09-10 13:06:37 -07001586 else
Nicolas Noble53830622015-02-12 16:56:38 -08001587
Craig Tiller841c8802015-09-10 13:06:37 -07001588 $(BINDIR)/$(CONFIG)/${tgt.name}: \
1589 % if not has_no_sources:
1590 $(PROTOBUF_DEP) $(${tgt.name.upper()}_OBJS)\
1591 % endif
1592 % else:
1593 $(BINDIR)/$(CONFIG)/${tgt.name}: \
1594 % if not has_no_sources:
1595 $(${tgt.name.upper()}_OBJS)\
1596 % endif
1597 % endif
1598 % for dep in tgt.deps:
1599 $(LIBDIR)/$(CONFIG)/lib${dep}.a\
1600 % endfor
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001601
Craig Tiller32173c52016-03-17 14:12:45 -07001602 % if tgt.language == "c++" or tgt.boringssl or tgt.build == 'fuzzer':
Craig Tiller841c8802015-09-10 13:06:37 -07001603 ## C++ targets specificies.
1604 % if tgt.build == 'protoc':
1605 $(E) "[HOSTLD] Linking $@"
1606 $(Q) mkdir -p `dirname $@`
1607 $(Q) $(HOST_LDXX) $(HOST_LDFLAGS) \
1608 % if not has_no_sources:
1609 $(${tgt.name.upper()}_OBJS)\
1610 % endif
1611 % else:
1612 $(E) "[LD] Linking $@"
1613 $(Q) mkdir -p `dirname $@`
1614 $(Q) $(LDXX) $(LDFLAGS) \
1615 % if not has_no_sources:
1616 $(${tgt.name.upper()}_OBJS)\
1617 % endif
1618 % endif
1619 % else:
1620 ## C-only targets specificities.
1621 $(E) "[LD] Linking $@"
1622 $(Q) mkdir -p `dirname $@`
1623 $(Q) $(LD) $(LDFLAGS) \
1624 % if not has_no_sources:
1625 $(${tgt.name.upper()}_OBJS)\
1626 % endif
1627 % endif
1628 % for dep in tgt.deps:
1629 $(LIBDIR)/$(CONFIG)/lib${dep}.a\
1630 % endfor
Craig Tiller841c8802015-09-10 13:06:37 -07001631 % if tgt.language == "c++":
1632 % if tgt.build == 'protoc':
1633 $(HOST_LDLIBSXX) $(HOST_LDLIBS_PROTOC)\
1634 % else:
1635 $(LDLIBSXX) $(LDLIBS_PROTOBUF)\
1636 % endif
1637 % endif
1638 % if tgt.build == 'protoc':
1639 $(HOST_LDLIBS)\
1640 % else:
1641 $(LDLIBS)\
1642 % endif
1643 % if tgt.build == 'protoc':
1644 $(HOST_LDLIBS_PROTOC)\
1645 % elif tgt.get('secure', 'check') == True or tgt.get('secure', 'check') == 'check':
1646 $(LDLIBS_SECURE)\
1647 % endif
1648 % if tgt.language == 'c++' and tgt.build == 'test':
1649 $(GTEST_LIB)\
1650 % elif tgt.language == 'c++' and tgt.build == 'benchmark':
1651 $(GTEST_LIB)\
1652 % endif
Craig Tiller32173c52016-03-17 14:12:45 -07001653 % if tgt.build == 'fuzzer':
1654 -lFuzzer\
1655 % endif
Craig Tiller841c8802015-09-10 13:06:37 -07001656 -o $(BINDIR)/$(CONFIG)/${tgt.name}
1657 % if tgt.build == 'protoc' or tgt.language == 'c++':
Nicolas Noble53830622015-02-12 16:56:38 -08001658
Craig Tiller841c8802015-09-10 13:06:37 -07001659 endif
1660 % endif
1661 % if tgt.get('secure', 'check') == True or tgt.get('secure', 'check') == 'check':
nnoble69ac39f2014-12-12 15:43:38 -08001662
Craig Tiller841c8802015-09-10 13:06:37 -07001663 endif
1664 % endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001665
Craig Tiller841c8802015-09-10 13:06:37 -07001666 % for src in tgt.src:
1667 $(OBJDIR)/$(CONFIG)/${os.path.splitext(src)[0]}.o: \
1668 % for dep in tgt.deps:
1669 $(LIBDIR)/$(CONFIG)/lib${dep}.a\
1670 % endfor
Craig Tillerf5371ef2015-01-12 16:40:18 -08001671
Craig Tillerab230452016-01-04 08:18:43 -08001672 % if tgt.language == 'c89':
1673 % for src in tgt.src:
Craig Tillerea21ca22016-01-04 12:34:29 -08001674 $(OBJDIR)/$(CONFIG)/${os.path.splitext(src)[0]}.o : ${src}
1675 $(E) "[C] Compiling $<"
1676 $(Q) mkdir -p `dirname $@`
Nicolas "Pixel" Noble45000342016-01-28 05:04:45 +01001677 $(Q) $(CC) $(CPPFLAGS) $(CFLAGS) -std=c89 -pedantic -MMD -MF $(addsuffix .dep, $(basename $@)) -c -o $@ $<
Craig Tillerab230452016-01-04 08:18:43 -08001678 % endfor
1679 % endif
1680
Craig Tiller841c8802015-09-10 13:06:37 -07001681 % endfor
1682 % if not has_no_sources:
1683 deps_${tgt.name}: $(${tgt.name.upper()}_OBJS:.o=.dep)
1684 % endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001685
Craig Tiller841c8802015-09-10 13:06:37 -07001686 % if not has_no_sources:
1687 % if tgt.get('secure', 'check') == True or tgt.get('secure', 'check') == 'check':
1688 ifneq ($(NO_SECURE),true)
1689 % endif
1690 ifneq ($(NO_DEPS),true)
1691 -include $(${tgt.name.upper()}_OBJS:.o=.dep)
1692 endif
1693 % if tgt.get('secure', 'check') == True or tgt.get('secure', 'check') == 'check':
1694 endif
1695 % endif
1696 % endif
Nicolas "Pixel" Noble472bb682015-11-03 19:09:01 +01001697 % for src in tgt.src:
1698 % if not proto_re.match(src) and any(proto_re.match(src2) for src2 in tgt.src):
1699 $(OBJDIR)/$(CONFIG)/${os.path.splitext(src)[0]}.o: ${' '.join(proto_to_cc(src2) for src2 in tgt.src if proto_re.match(src2))}
1700 % endif
1701 % endfor
Craig Tiller841c8802015-09-10 13:06:37 -07001702 </%def>
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001703
Craig Tiller841c8802015-09-10 13:06:37 -07001704 ifneq ($(OPENSSL_DEP),)
1705 # This is to ensure the embedded OpenSSL is built beforehand, properly
1706 # installing headers to their final destination on the drive. We need this
1707 # otherwise parallel compilation will fail if a source is compiled first.
1708 % for src in sorted(sources_that_need_openssl):
1709 % if src not in sources_that_don_t_need_openssl:
1710 ${src}: $(OPENSSL_DEP)
1711 % endif
1712 % endfor
1713 endif
Nicolas "Pixel" Noble010f1e72015-04-23 02:23:49 +02001714
Craig Tiller841c8802015-09-10 13:06:37 -07001715 .PHONY: all strip tools \
1716 dep_error openssl_dep_error openssl_dep_message git_update stop \
1717 buildtests buildtests_c buildtests_cxx \
1718 test test_c test_cxx \
1719 install install_c install_cxx \
1720 install-headers install-headers_c install-headers_cxx \
1721 install-shared install-shared_c install-shared_cxx \
1722 install-static install-static_c install-static_cxx \
1723 strip strip-shared strip-static \
1724 strip_c strip-shared_c strip-static_c \
1725 strip_cxx strip-shared_cxx strip-static_cxx \
1726 dep_c dep_cxx bins_dep_c bins_dep_cxx \
1727 clean
Craig Tillerb79c1e12016-02-23 10:00:58 -08001728
1729 .PHONY: printvars
1730 printvars:
1731 @$(foreach V,$(sort $(.VARIABLES)), \
1732 $(if $(filter-out environment% default automatic, \
1733 $(origin $V)),$(warning $V=$($V) ($(value $V)))))