blob: 7aa463f58ca3929946ce1374f9e9fa7cc2d6d282 [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
murgatroid993466c4b2016-01-12 10:26:04 -080010 # Copyright 2015-2016, 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()
52 %>
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -080053
Craig Tiller96b49552015-01-21 16:29:01 -080054
Craig Tiller71a86042016-01-15 14:59:58 -080055 comma := ,
56
57
Craig Tiller841c8802015-09-10 13:06:37 -070058 # Basic platform detection
59 HOST_SYSTEM = $(shell uname | cut -f 1 -d_)
Nicolas "Pixel" Noblec4e57e32016-01-30 21:05:35 +010060 SYSTEM ?= $(HOST_SYSTEM)
Craig Tiller841c8802015-09-10 13:06:37 -070061 ifeq ($(SYSTEM),MSYS)
62 SYSTEM = MINGW32
63 endif
64 ifeq ($(SYSTEM),MINGW64)
65 SYSTEM = MINGW32
66 endif
Craig Tiller96b49552015-01-21 16:29:01 -080067
68
Nicolas "Pixel" Noble6dad9b02015-09-23 18:32:26 +020069 MAKEFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST)))
Craig Tiller841c8802015-09-10 13:06:37 -070070 ifndef BUILDDIR
Nicolas "Pixel" Noble42b4c282015-09-17 23:57:08 +020071 BUILDDIR_ABSOLUTE = $(patsubst %/,%,$(dir $(MAKEFILE_PATH)))
72 else
73 BUILDDIR_ABSOLUTE = $(abspath $(BUILDDIR))
Craig Tiller841c8802015-09-10 13:06:37 -070074 endif
Craig Tiller61b910f2015-02-15 10:54:07 -080075
Craig Tiller841c8802015-09-10 13:06:37 -070076 HAS_GCC = $(shell which gcc > /dev/null 2> /dev/null && echo true || echo false)
77 HAS_CC = $(shell which cc > /dev/null 2> /dev/null && echo true || echo false)
78 HAS_CLANG = $(shell which clang > /dev/null 2> /dev/null && echo true || echo false)
Nicolas Noblef8681182015-03-18 14:25:44 -070079
Craig Tiller841c8802015-09-10 13:06:37 -070080 ifeq ($(HAS_CC),true)
81 DEFAULT_CC = cc
82 DEFAULT_CXX = c++
83 else
84 ifeq ($(HAS_GCC),true)
85 DEFAULT_CC = gcc
86 DEFAULT_CXX = g++
87 else
88 ifeq ($(HAS_CLANG),true)
89 DEFAULT_CC = clang
90 DEFAULT_CXX = clang++
91 else
92 DEFAULT_CC = no_c_compiler
93 DEFAULT_CXX = no_c++_compiler
94 endif
95 endif
96 endif
Nicolas Noblef8681182015-03-18 14:25:44 -070097
98
Nicolas "Pixel" Noble42b4c282015-09-17 23:57:08 +020099 BINDIR = $(BUILDDIR_ABSOLUTE)/bins
100 OBJDIR = $(BUILDDIR_ABSOLUTE)/objs
101 LIBDIR = $(BUILDDIR_ABSOLUTE)/libs
102 GENDIR = $(BUILDDIR_ABSOLUTE)/gens
Craig Tiller61b910f2015-02-15 10:54:07 -0800103
Craig Tiller841c8802015-09-10 13:06:37 -0700104 # Configurations
ctiller8cfebb92015-01-06 15:02:12 -0800105
Craig Tillera0f85172016-01-20 15:56:06 -0800106 % for name, args in configs.iteritems():
107 VALID_CONFIG_${name} = 1
108 % if args.get('compile_the_world', False):
109 REQUIRE_CUSTOM_LIBRARIES_${name} = 1
110 % endif
Craig Tilleraff3d502016-01-20 15:59:31 -0800111 % for tool, default in [('CC', 'CC'), ('CXX', 'CXX'), ('LD', 'CC'), ('LDXX', 'CXX')]:
Craig Tillera0f85172016-01-20 15:56:06 -0800112 ${tool}_${name} = ${args.get(tool, '$(DEFAULT_%s)' % default)}
113 % endfor
114 % for arg in ['CFLAGS', 'CXXFLAGS', 'CPPFLAGS', 'LDFLAGS', 'DEFINES']:
115 % if args.get(arg, None) is not None:
116 ${arg}_${name} = ${args.get(arg)}
117 % endif
118 % endfor
119 % if args.get('timeout_multiplier', 1) != 1:
120 DEFINES_${name} += GRPC_TEST_SLOWDOWN_BUILD_FACTOR=${args.timeout_multiplier}
121 % endif
ctiller8cfebb92015-01-06 15:02:12 -0800122
Craig Tillera0f85172016-01-20 15:56:06 -0800123 % endfor
Craig Tiller699ba212015-01-13 17:02:20 -0800124
Nicolas Noble047b7272015-01-16 13:55:05 -0800125
Craig Tiller841c8802015-09-10 13:06:37 -0700126 # General settings.
127 # You may want to change these depending on your system.
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800128
Craig Tiller841c8802015-09-10 13:06:37 -0700129 prefix ?= /usr/local
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800130
Nicolas "Pixel" Noble1a8eb852016-01-26 22:33:19 +0100131 PROTOC ?= protoc
132 DTRACE ?= dtrace
Craig Tiller841c8802015-09-10 13:06:37 -0700133 CONFIG ?= opt
Nicolas "Pixel" Noblefba36bc2016-01-27 03:24:03 +0100134 # Doing X ?= Y is the same as:
135 # ifeq ($(origin X), undefined)
136 # X = Y
137 # endif
138 # but some variables, such as CC, CXX, LD or AR, have defaults.
139 # So instead of using ?= on them, we need to check their origin.
140 # See:
141 # https://www.gnu.org/software/make/manual/html_node/Implicit-Variables.html
142 # https://www.gnu.org/software/make/manual/html_node/Flavors.html#index-_003f_003d
143 # https://www.gnu.org/software/make/manual/html_node/Origin-Function.html
144 ifeq ($(origin CC), default)
145 CC = $(CC_$(CONFIG))
146 endif
147 ifeq ($(origin CXX), default)
148 CXX = $(CXX_$(CONFIG))
149 endif
150 ifeq ($(origin LD), default)
151 LD = $(LD_$(CONFIG))
152 endif
Nicolas "Pixel" Noble1a8eb852016-01-26 22:33:19 +0100153 LDXX ?= $(LDXX_$(CONFIG))
Craig Tiller841c8802015-09-10 13:06:37 -0700154 ifeq ($(SYSTEM),Linux)
Nicolas "Pixel" Noble6e72dae2016-02-03 04:23:08 +0100155 ifeq ($(origin AR), default)
156 AR = ar rcs
157 endif
Nicolas "Pixel" Noble1a8eb852016-01-26 22:33:19 +0100158 STRIP ?= strip --strip-unneeded
Craig Tiller841c8802015-09-10 13:06:37 -0700159 else
160 ifeq ($(SYSTEM),Darwin)
Nicolas "Pixel" Noble6e72dae2016-02-03 04:23:08 +0100161 ifeq ($(origin AR), default)
162 AR = libtool -o
163 endif
Nicolas "Pixel" Noble1a8eb852016-01-26 22:33:19 +0100164 STRIP ?= strip -x
Craig Tiller841c8802015-09-10 13:06:37 -0700165 else
Nicolas "Pixel" Noble6e72dae2016-02-03 04:23:08 +0100166 ifeq ($(origin AR), default)
167 AR = ar rcs
168 endif
Nicolas "Pixel" Noble1a8eb852016-01-26 22:33:19 +0100169 STRIP ?= strip
Craig Tiller841c8802015-09-10 13:06:37 -0700170 endif
171 endif
Nicolas "Pixel" Noble1a8eb852016-01-26 22:33:19 +0100172 INSTALL ?= install
173 RM ?= rm -f
174 PKG_CONFIG ?= pkg-config
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800175
Craig Tiller841c8802015-09-10 13:06:37 -0700176 ifndef VALID_CONFIG_$(CONFIG)
177 $(error Invalid CONFIG value '$(CONFIG)')
178 endif
yangg102e4fe2015-01-06 16:02:50 -0800179
Craig Tiller841c8802015-09-10 13:06:37 -0700180 ifeq ($(SYSTEM),Linux)
181 TMPOUT = /dev/null
182 else
183 TMPOUT = `mktemp /tmp/test-out-XXXXXX`
184 endif
Nicolas Noble047b7272015-01-16 13:55:05 -0800185
Craig Tiller841c8802015-09-10 13:06:37 -0700186 # Detect if we can use C++11
187 CXX11_CHECK_CMD = $(CXX) -std=c++11 -o $(TMPOUT) -c test/build/c++11.cc
188 HAS_CXX11 = $(shell $(CXX11_CHECK_CMD) 2> /dev/null && echo true || echo false)
Craig Tillercf133f42015-02-26 14:05:56 -0800189
Craig Tiller82f3f0d2016-01-25 11:27:42 -0800190 CHECK_NO_SHIFT_NEGATIVE_VALUE_CMD = $(CC) -std=c99 -Werror -Wno-shift-negative-value -o $(TMPOUT) -c test/build/empty.c
Craig Tiller16872b82016-01-25 10:55:20 -0800191 HAS_NO_SHIFT_NEGATIVE_VALUE = $(shell $(CHECK_NO_SHIFT_NEGATIVE_VALUE_CMD) 2> /dev/null && echo true || echo false)
192 ifeq ($(HAS_NO_SHIFT_NEGATIVE_VALUE),true)
193 W_NO_SHIFT_NEGATIVE_VALUE=-Wno-shift-negative-value
194 endif
195
Craig Tiller841c8802015-09-10 13:06:37 -0700196 # The HOST compiler settings are used to compile the protoc plugins.
197 # In most cases, you won't have to change anything, but if you are
198 # cross-compiling, you can override these variables from GNU make's
199 # command line: make CC=cross-gcc HOST_CC=gcc
Nicolas Noble047b7272015-01-16 13:55:05 -0800200
Nicolas "Pixel" Noble1a8eb852016-01-26 22:33:19 +0100201 HOST_CC ?= $(CC)
202 HOST_CXX ?= $(CXX)
203 HOST_LD ?= $(LD)
204 HOST_LDXX ?= $(LDXX)
nnoble72309c62014-12-12 11:42:26 -0800205
Craig Tiller841c8802015-09-10 13:06:37 -0700206 ifdef EXTRA_DEFINES
207 DEFINES += $(EXTRA_DEFINES)
208 endif
Craig Tiller86fa1c52015-02-27 09:57:58 -0800209
Craig Tiller0fe5ee72015-12-22 12:50:36 -0800210 CFLAGS += -std=c99 -Wsign-conversion -Wconversion -Wshadow
Craig Tiller841c8802015-09-10 13:06:37 -0700211 ifeq ($(HAS_CXX11),true)
212 CXXFLAGS += -std=c++11
213 else
214 CXXFLAGS += -std=c++0x
215 endif
Nicolas "Pixel" Noble51b1aee2016-01-28 01:14:58 +0100216 % for arg in ['CFLAGS', 'CXXFLAGS', 'CPPFLAGS', 'LDFLAGS', 'DEFINES']:
217 % if defaults.get('global', []).get(arg, None) is not None:
218 ${arg} += ${defaults.get('global').get(arg)}
219 % endif
220 % endfor
Nicolas Noblef8681182015-03-18 14:25:44 -0700221
Craig Tiller841c8802015-09-10 13:06:37 -0700222 CPPFLAGS += $(CPPFLAGS_$(CONFIG))
Craig Tiller0fe5ee72015-12-22 12:50:36 -0800223 CFLAGS += $(CFLAGS_$(CONFIG))
224 CXXFLAGS += $(CXXFLAGS_$(CONFIG))
Craig Tiller841c8802015-09-10 13:06:37 -0700225 DEFINES += $(DEFINES_$(CONFIG)) INSTALL_PREFIX=\"$(prefix)\"
226 LDFLAGS += $(LDFLAGS_$(CONFIG))
Nicolas "Pixel" Noble482d7612015-07-16 23:43:30 +0200227
Craig Tiller841c8802015-09-10 13:06:37 -0700228 ifneq ($(SYSTEM),MINGW32)
229 PIC_CPPFLAGS = -fPIC
230 CPPFLAGS += -fPIC
231 LDFLAGS += -fPIC
232 endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800233
Craig Tiller841c8802015-09-10 13:06:37 -0700234 INCLUDES = . include $(GENDIR)
235 LDFLAGS += -Llibs/$(CONFIG)
Nicolas "Pixel" Noble3adab742015-06-02 00:33:06 +0200236
Craig Tiller841c8802015-09-10 13:06:37 -0700237 ifeq ($(SYSTEM),Darwin)
238 ifneq ($(wildcard /usr/local/ssl/include),)
239 INCLUDES += /usr/local/ssl/include
240 endif
241 ifneq ($(wildcard /opt/local/include),)
242 INCLUDES += /opt/local/include
243 endif
244 ifneq ($(wildcard /usr/local/include),)
245 INCLUDES += /usr/local/include
246 endif
247 LIBS = m z
248 ifneq ($(wildcard /usr/local/ssl/lib),)
249 LDFLAGS += -L/usr/local/ssl/lib
250 endif
251 ifneq ($(wildcard /opt/local/lib),)
252 LDFLAGS += -L/opt/local/lib
253 endif
254 ifneq ($(wildcard /usr/local/lib),)
255 LDFLAGS += -L/usr/local/lib
256 endif
257 endif
Nicolas Noblef8681182015-03-18 14:25:44 -0700258
Craig Tiller841c8802015-09-10 13:06:37 -0700259 ifeq ($(SYSTEM),Linux)
Craig Tiller1b1e2382016-02-03 07:33:56 -0800260 LIBS = dl rt m pthread
Craig Tiller841c8802015-09-10 13:06:37 -0700261 LDFLAGS += -pthread
262 endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800263
Craig Tiller841c8802015-09-10 13:06:37 -0700264 ifeq ($(SYSTEM),MINGW32)
Nicolas "Pixel" Noblec4e57e32016-01-30 21:05:35 +0100265 LIBS = m pthread ws2_32
Craig Tiller841c8802015-09-10 13:06:37 -0700266 LDFLAGS += -pthread
267 endif
Nicolas Noblef8681182015-03-18 14:25:44 -0700268
Craig Tiller841c8802015-09-10 13:06:37 -0700269 GTEST_LIB = -Ithird_party/googletest/include -Ithird_party/googletest third_party/googletest/src/gtest-all.cc
270 GTEST_LIB += -lgflags
271 ifeq ($(V),1)
272 E = @:
273 Q =
274 else
275 E = @echo
276 Q = @
277 endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800278
Craig Tillerf008f062016-02-08 12:48:03 -0800279 VERSION = ${settings.core_version}
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800280
Craig Tiller841c8802015-09-10 13:06:37 -0700281 CPPFLAGS_NO_ARCH += $(addprefix -I, $(INCLUDES)) $(addprefix -D, $(DEFINES))
282 CPPFLAGS += $(CPPFLAGS_NO_ARCH) $(ARCH_FLAGS)
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800283
Craig Tiller841c8802015-09-10 13:06:37 -0700284 LDFLAGS += $(ARCH_FLAGS)
285 LDLIBS += $(addprefix -l, $(LIBS))
286 LDLIBSXX += $(addprefix -l, $(LIBSXX))
nnoble72309c62014-12-12 11:42:26 -0800287
Craig Tiller841c8802015-09-10 13:06:37 -0700288 HOST_CPPFLAGS = $(CPPFLAGS)
289 HOST_CFLAGS = $(CFLAGS)
290 HOST_CXXFLAGS = $(CXXFLAGS)
291 HOST_LDFLAGS = $(LDFLAGS)
292 HOST_LDLIBS = $(LDLIBS)
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800293
Craig Tiller841c8802015-09-10 13:06:37 -0700294 # These are automatically computed variables.
295 # There shouldn't be any need to change anything from now on.
nnoble69ac39f2014-12-12 15:43:38 -0800296
Craig Tiller841c8802015-09-10 13:06:37 -0700297 -include cache.mk
murgatroid9924e2f4a2015-06-29 11:12:01 -0700298
Craig Tiller841c8802015-09-10 13:06:37 -0700299 CACHE_MK =
murgatroid99aa521572015-07-10 14:49:12 -0700300
Craig Tiller841c8802015-09-10 13:06:37 -0700301 HAS_PKG_CONFIG ?= $(shell command -v $(PKG_CONFIG) >/dev/null 2>&1 && echo true || echo false)
murgatroid99aa521572015-07-10 14:49:12 -0700302
Craig Tiller841c8802015-09-10 13:06:37 -0700303 ifeq ($(HAS_PKG_CONFIG), true)
304 CACHE_MK += HAS_PKG_CONFIG = true,
305 endif
nnoble69ac39f2014-12-12 15:43:38 -0800306
Craig Tiller841c8802015-09-10 13:06:37 -0700307 PC_TEMPLATE = prefix=$(prefix),\
308 exec_prefix=${'\$${prefix}'},\
309 includedir=${'\$${prefix}'}/include,\
310 libdir=${'\$${exec_prefix}'}/lib,\
311 ,\
312 Name: $(PC_NAME),\
313 Description: $(PC_DESCRIPTION),\
314 Version: $(VERSION),\
315 Cflags: -I${'\$${includedir}'} $(PC_CFLAGS),\
316 Requires.private: $(PC_REQUIRES_PRIVATE),\
317 Libs: -L${'\$${libdir}'} $(PC_LIB),\
318 Libs.private: $(PC_LIBS_PRIVATE)
murgatroid998faab232015-06-30 17:24:21 -0700319
Craig Tiller841c8802015-09-10 13:06:37 -0700320 ifeq ($(SYSTEM),MINGW32)
321 SHARED_EXT = dll
Nicolas "Pixel" Noblec4e57e32016-01-30 21:05:35 +0100322 SHARED_PREFIX =
Craig Tillerf008f062016-02-08 12:48:03 -0800323 SHARED_VERSION = -${settings.core_version.major}
Nicolas "Pixel" Noblec4e57e32016-01-30 21:05:35 +0100324 else ifeq ($(SYSTEM),Darwin)
Craig Tiller841c8802015-09-10 13:06:37 -0700325 SHARED_EXT = dylib
Nicolas "Pixel" Noblec4e57e32016-01-30 21:05:35 +0100326 SHARED_PREFIX = lib
327 SHARED_VERSION =
328 else
Craig Tiller841c8802015-09-10 13:06:37 -0700329 SHARED_EXT = so.$(VERSION)
Nicolas "Pixel" Noblec4e57e32016-01-30 21:05:35 +0100330 SHARED_PREFIX = lib
331 SHARED_VERSION =
Craig Tiller841c8802015-09-10 13:06:37 -0700332 endif
nnoble5b7f32a2014-12-22 08:12:44 -0800333
Craig Tiller841c8802015-09-10 13:06:37 -0700334 ifeq ($(wildcard .git),)
335 IS_GIT_FOLDER = false
336 else
337 IS_GIT_FOLDER = true
338 endif
nnoble69ac39f2014-12-12 15:43:38 -0800339
Craig Tiller841c8802015-09-10 13:06:37 -0700340 ifeq ($(HAS_PKG_CONFIG),true)
341 OPENSSL_ALPN_CHECK_CMD = $(PKG_CONFIG) --atleast-version=1.0.2 openssl
342 OPENSSL_NPN_CHECK_CMD = $(PKG_CONFIG) --atleast-version=1.0.1 openssl
343 ZLIB_CHECK_CMD = $(PKG_CONFIG) --exists zlib
344 PROTOBUF_CHECK_CMD = $(PKG_CONFIG) --atleast-version=3.0.0-alpha-3 protobuf
345 else # HAS_PKG_CONFIG
murgatroid9924e2f4a2015-06-29 11:12:01 -0700346
Craig Tiller841c8802015-09-10 13:06:37 -0700347 ifeq ($(SYSTEM),MINGW32)
348 OPENSSL_LIBS = ssl32 eay32
349 else
350 OPENSSL_LIBS = ssl crypto
351 endif
Nicolas Noblef8681182015-03-18 14:25:44 -0700352
Nicolas "Pixel" Noble45000342016-01-28 05:04:45 +0100353 OPENSSL_ALPN_CHECK_CMD = $(CC) $(CPPFLAGS) $(CFLAGS) -o $(TMPOUT) test/build/openssl-alpn.c $(addprefix -l, $(OPENSSL_LIBS)) $(LDFLAGS)
354 OPENSSL_NPN_CHECK_CMD = $(CC) $(CPPFLAGS) $(CFLAGS) -o $(TMPOUT) test/build/openssl-npn.c $(addprefix -l, $(OPENSSL_LIBS)) $(LDFLAGS)
355 ZLIB_CHECK_CMD = $(CC) $(CPPFLAGS) $(CFLAGS) -o $(TMPOUT) test/build/zlib.c -lz $(LDFLAGS)
356 PROTOBUF_CHECK_CMD = $(CXX) $(CPPFLAGS) $(CXXFLAGS) -o $(TMPOUT) test/build/protobuf.cc -lprotobuf $(LDFLAGS)
Craig Tiller297fafa2015-01-15 15:46:39 -0800357
Craig Tiller841c8802015-09-10 13:06:37 -0700358 endif # HAS_PKG_CONFIG
murgatroid9924e2f4a2015-06-29 11:12:01 -0700359
Nicolas "Pixel" Noble45000342016-01-28 05:04:45 +0100360 PERFTOOLS_CHECK_CMD = $(CC) $(CPPFLAGS) $(CFLAGS) -o $(TMPOUT) test/build/perftools.c -lprofiler $(LDFLAGS)
murgatroid996d9e4012015-07-08 10:22:45 -0700361
Craig Tiller841c8802015-09-10 13:06:37 -0700362 PROTOC_CHECK_CMD = which protoc > /dev/null
363 PROTOC_CHECK_VERSION_CMD = protoc --version | grep -q libprotoc.3
364 DTRACE_CHECK_CMD = which dtrace > /dev/null
Nicolas "Pixel" Noble45000342016-01-28 05:04:45 +0100365 SYSTEMTAP_HEADERS_CHECK_CMD = $(CC) $(CPPFLAGS) $(CFLAGS) -o $(TMPOUT) test/build/systemtap.c $(LDFLAGS)
366 ZOOKEEPER_CHECK_CMD = $(CC) $(CPPFLAGS) $(CFLAGS) -o $(TMPOUT) test/build/zookeeper.c $(LDFLAGS) -lzookeeper_mt
murgatroid9924e2f4a2015-06-29 11:12:01 -0700367
Craig Tiller841c8802015-09-10 13:06:37 -0700368 ifndef REQUIRE_CUSTOM_LIBRARIES_$(CONFIG)
369 HAS_SYSTEM_PERFTOOLS ?= $(shell $(PERFTOOLS_CHECK_CMD) 2> /dev/null && echo true || echo false)
370 ifeq ($(HAS_SYSTEM_PERFTOOLS),true)
371 DEFINES += GRPC_HAVE_PERFTOOLS
372 LIBS += profiler
373 CACHE_MK += HAS_SYSTEM_PERFTOOLS = true,
374 endif
375 endif
nnoble69ac39f2014-12-12 15:43:38 -0800376
Craig Tiller841c8802015-09-10 13:06:37 -0700377 HAS_SYSTEM_PROTOBUF_VERIFY = $(shell $(PROTOBUF_CHECK_CMD) 2> /dev/null && echo true || echo false)
378 ifndef REQUIRE_CUSTOM_LIBRARIES_$(CONFIG)
379 HAS_SYSTEM_OPENSSL_ALPN ?= $(shell $(OPENSSL_ALPN_CHECK_CMD) 2> /dev/null && echo true || echo false)
380 ifeq ($(HAS_SYSTEM_OPENSSL_ALPN),true)
381 HAS_SYSTEM_OPENSSL_NPN = true
382 CACHE_MK += HAS_SYSTEM_OPENSSL_ALPN = true,
383 else
384 HAS_SYSTEM_OPENSSL_NPN ?= $(shell $(OPENSSL_NPN_CHECK_CMD) 2> /dev/null && echo true || echo false)
385 endif
386 ifeq ($(HAS_SYSTEM_OPENSSL_NPN),true)
387 CACHE_MK += HAS_SYSTEM_OPENSSL_NPN = true,
388 endif
389 HAS_SYSTEM_ZLIB ?= $(shell $(ZLIB_CHECK_CMD) 2> /dev/null && echo true || echo false)
390 ifeq ($(HAS_SYSTEM_ZLIB),true)
391 CACHE_MK += HAS_SYSTEM_ZLIB = true,
392 endif
393 HAS_SYSTEM_PROTOBUF ?= $(HAS_SYSTEM_PROTOBUF_VERIFY)
394 ifeq ($(HAS_SYSTEM_PROTOBUF),true)
395 CACHE_MK += HAS_SYSTEM_PROTOBUF = true,
396 endif
397 else
398 # override system libraries if the config requires a custom compiled library
399 HAS_SYSTEM_OPENSSL_ALPN = false
400 HAS_SYSTEM_OPENSSL_NPN = false
401 HAS_SYSTEM_ZLIB = false
402 HAS_SYSTEM_PROTOBUF = false
403 endif
nnoble69ac39f2014-12-12 15:43:38 -0800404
Craig Tiller841c8802015-09-10 13:06:37 -0700405 HAS_PROTOC ?= $(shell $(PROTOC_CHECK_CMD) 2> /dev/null && echo true || echo false)
406 ifeq ($(HAS_PROTOC),true)
407 CACHE_MK += HAS_PROTOC = true,
408 HAS_VALID_PROTOC ?= $(shell $(PROTOC_CHECK_VERSION_CMD) 2> /dev/null && echo true || echo false)
409 ifeq ($(HAS_VALID_PROTOC),true)
410 CACHE_MK += HAS_VALID_PROTOC = true,
411 endif
412 else
413 HAS_VALID_PROTOC = false
414 endif
Nicolas Noble53830622015-02-12 16:56:38 -0800415
Craig Tiller841c8802015-09-10 13:06:37 -0700416 # Check for Systemtap (https://sourceware.org/systemtap/), first by making sure <sys/sdt.h> is present
417 # in the system and secondly by checking for the "dtrace" binary (on Linux, this is part of the Systemtap
418 # distribution. It's part of the base system on BSD/Solaris machines).
419 ifndef HAS_SYSTEMTAP
420 HAS_SYSTEMTAP_HEADERS = $(shell $(SYSTEMTAP_HEADERS_CHECK_CMD) 2> /dev/null && echo true || echo false)
421 HAS_DTRACE = $(shell $(DTRACE_CHECK_CMD) 2> /dev/null && echo true || echo false)
422 HAS_SYSTEMTAP = false
423 ifeq ($(HAS_SYSTEMTAP_HEADERS),true)
424 ifeq ($(HAS_DTRACE),true)
425 HAS_SYSTEMTAP = true
426 endif
427 endif
428 endif
David Garcia Quintas611b7362015-04-27 15:49:31 -0700429
Craig Tiller841c8802015-09-10 13:06:37 -0700430 ifeq ($(HAS_SYSTEMTAP),true)
431 CACHE_MK += HAS_SYSTEMTAP = true,
432 endif
nnoble69ac39f2014-12-12 15:43:38 -0800433
Craig Tiller841c8802015-09-10 13:06:37 -0700434 HAS_ZOOKEEPER = $(shell $(ZOOKEEPER_CHECK_CMD) 2> /dev/null && echo true || echo false)
Hongwei Wanga8cc4392015-07-16 17:37:47 -0700435
Craig Tiller841c8802015-09-10 13:06:37 -0700436 # Note that for testing purposes, one can do:
437 # make HAS_EMBEDDED_OPENSSL_ALPN=false
438 # to emulate the fact we do not have OpenSSL in the third_party folder.
Craig Tiller0fe5ee72015-12-22 12:50:36 -0800439 ifeq ($(wildcard third_party/boringssl/include/openssl/ssl.h),)
Craig Tiller841c8802015-09-10 13:06:37 -0700440 HAS_EMBEDDED_OPENSSL_ALPN = false
441 else
442 HAS_EMBEDDED_OPENSSL_ALPN = true
443 endif
nnoble69ac39f2014-12-12 15:43:38 -0800444
Craig Tiller841c8802015-09-10 13:06:37 -0700445 ifeq ($(wildcard third_party/zlib/zlib.h),)
446 HAS_EMBEDDED_ZLIB = false
447 else
448 HAS_EMBEDDED_ZLIB = true
449 endif
nnoble69ac39f2014-12-12 15:43:38 -0800450
Craig Tiller841c8802015-09-10 13:06:37 -0700451 ifeq ($(wildcard third_party/protobuf/src/google/protobuf/descriptor.pb.h),)
452 HAS_EMBEDDED_PROTOBUF = false
453 ifneq ($(HAS_VALID_PROTOC),true)
454 NO_PROTOC = true
455 endif
456 else
457 HAS_EMBEDDED_PROTOBUF = true
458 endif
Nicolas Noble53830622015-02-12 16:56:38 -0800459
Nicolas "Pixel" Noble09121792016-01-30 09:01:53 +0100460 PC_REQUIRES_GRPC =
Craig Tiller841c8802015-09-10 13:06:37 -0700461 PC_LIBS_GRPC =
murgatroid998faab232015-06-30 17:24:21 -0700462
Craig Tiller841c8802015-09-10 13:06:37 -0700463 ifeq ($(HAS_SYSTEM_ZLIB),false)
Craig Tiller3dca23a2016-01-21 11:44:55 -0800464 ifeq ($(HAS_EMBEDDED_ZLIB), true)
465 EMBED_ZLIB ?= true
Craig Tiller841c8802015-09-10 13:06:37 -0700466 else
467 DEP_MISSING += zlib
Craig Tiller3dca23a2016-01-21 11:44:55 -0800468 EMBED_ZLIB ?= broken
Craig Tiller841c8802015-09-10 13:06:37 -0700469 endif
470 else
Craig Tiller3dca23a2016-01-21 11:44:55 -0800471 EMBED_ZLIB ?= false
472 endif
473
474 ifeq ($(EMBED_ZLIB),true)
475 ZLIB_DEP = $(LIBDIR)/$(CONFIG)/libz.a
476 ZLIB_MERGE_LIBS = $(LIBDIR)/$(CONFIG)/libz.a
Nicolas "Pixel" Noblef51a9012016-02-03 07:39:43 +0100477 ZLIB_MERGE_OBJS = $(LIBZ_OBJS)
Craig Tiller3dca23a2016-01-21 11:44:55 -0800478 CPPFLAGS += -Ithird_party/zlib
479 LDFLAGS += -L$(LIBDIR)/$(CONFIG)/zlib
480 else
Craig Tiller841c8802015-09-10 13:06:37 -0700481 ifeq ($(HAS_PKG_CONFIG),true)
482 CPPFLAGS += $(shell $(PKG_CONFIG) --cflags zlib)
483 LDFLAGS += $(shell $(PKG_CONFIG) --libs-only-L zlib)
Craig Tiller0fe5ee72015-12-22 12:50:36 -0800484 LIBS += $(patsubst -l%,%,$(shell $(PKG_CONFIG) --libs-only-l zlib))
Craig Tiller841c8802015-09-10 13:06:37 -0700485 PC_REQUIRES_GRPC += zlib
486 else
487 PC_LIBS_GRPC += -lz
Craig Tiller0fe5ee72015-12-22 12:50:36 -0800488 LIBS += z
Craig Tiller841c8802015-09-10 13:06:37 -0700489 endif
490 endif
nnoble69ac39f2014-12-12 15:43:38 -0800491
Craig Tiller841c8802015-09-10 13:06:37 -0700492 OPENSSL_PKG_CONFIG = false
murgatroid99da7a9942015-06-29 14:57:37 -0700493
Craig Tiller841c8802015-09-10 13:06:37 -0700494 PC_REQUIRES_SECURE =
495 PC_LIBS_SECURE =
murgatroid998faab232015-06-30 17:24:21 -0700496
Craig Tiller841c8802015-09-10 13:06:37 -0700497 ifeq ($(HAS_SYSTEM_OPENSSL_ALPN),true)
Craig Tiller0fe5ee72015-12-22 12:50:36 -0800498 EMBED_OPENSSL ?= false
499 NO_SECURE ?= false
500 else # HAS_SYSTEM_OPENSSL_ALPN=false
501 ifeq ($(HAS_EMBEDDED_OPENSSL_ALPN),true)
502 EMBED_OPENSSL ?= true
503 NO_SECURE ?= false
504 else # HAS_EMBEDDED_OPENSSL_ALPN=false
505 ifeq ($(HAS_SYSTEM_OPENSSL_NPN),true)
506 EMBED_OPENSSL ?= false
507 NO_SECURE ?= false
508 else
509 NO_SECURE ?= true
510 endif # HAS_SYSTEM_OPENSSL_NPN=true
511 endif # HAS_EMBEDDED_OPENSSL_ALPN
512 endif # HAS_SYSTEM_OPENSSL_ALPN
513
514 OPENSSL_DEP :=
515 OPENSSL_MERGE_LIBS :=
516 ifeq ($(NO_SECURE),false)
517 ifeq ($(EMBED_OPENSSL),true)
518 OPENSSL_DEP += $(LIBDIR)/$(CONFIG)/libboringssl.a
519 OPENSSL_MERGE_LIBS += $(LIBDIR)/$(CONFIG)/libboringssl.a
Nicolas "Pixel" Noblef51a9012016-02-03 07:39:43 +0100520 OPENSSL_MERGE_OBJS += $(LIBBORINGSSL_OBJS)
Craig Tiller0fe5ee72015-12-22 12:50:36 -0800521 # need to prefix these to ensure overriding system libraries
522 CPPFLAGS := -Ithird_party/boringssl/include $(CPPFLAGS)
Craig Tiller0fe5ee72015-12-22 12:50:36 -0800523 else # EMBED_OPENSSL=false
Craig Tiller841c8802015-09-10 13:06:37 -0700524 ifeq ($(HAS_PKG_CONFIG),true)
525 OPENSSL_PKG_CONFIG = true
526 PC_REQUIRES_SECURE = openssl
527 CPPFLAGS := $(shell $(PKG_CONFIG) --cflags openssl) $(CPPFLAGS)
528 LDFLAGS_OPENSSL_PKG_CONFIG = $(shell $(PKG_CONFIG) --libs-only-L openssl)
529 ifeq ($(SYSTEM),Linux)
530 ifneq ($(LDFLAGS_OPENSSL_PKG_CONFIG),)
531 LDFLAGS_OPENSSL_PKG_CONFIG += $(shell $(PKG_CONFIG) --libs-only-L openssl | sed s/L/Wl,-rpath,/)
Craig Tiller0fe5ee72015-12-22 12:50:36 -0800532 endif # LDFLAGS_OPENSSL_PKG_CONFIG=''
533 endif # System=Linux
Craig Tiller841c8802015-09-10 13:06:37 -0700534 LDFLAGS := $(LDFLAGS_OPENSSL_PKG_CONFIG) $(LDFLAGS)
Craig Tiller0fe5ee72015-12-22 12:50:36 -0800535 else # HAS_PKG_CONFIG=false
Craig Tiller841c8802015-09-10 13:06:37 -0700536 LIBS_SECURE = $(OPENSSL_LIBS)
Craig Tiller0fe5ee72015-12-22 12:50:36 -0800537 endif # HAS_PKG_CONFIG
538 ifeq ($(HAS_SYSTEM_OPENSSL_NPN),true)
539 CPPFLAGS += -DTSI_OPENSSL_ALPN_SUPPORT=0
540 LIBS_SECURE = $(OPENSSL_LIBS)
541 endif # HAS_SYSTEM_OPENSSL_NPN
Craig Tiller841c8802015-09-10 13:06:37 -0700542 PC_LIBS_SECURE = $(addprefix -l, $(LIBS_SECURE))
Craig Tiller0fe5ee72015-12-22 12:50:36 -0800543 endif # EMBED_OPENSSL
544 endif # NO_SECURE
nnoble69ac39f2014-12-12 15:43:38 -0800545
Craig Tiller841c8802015-09-10 13:06:37 -0700546 ifeq ($(OPENSSL_PKG_CONFIG),true)
547 LDLIBS_SECURE += $(shell $(PKG_CONFIG) --libs-only-l openssl)
548 else
549 LDLIBS_SECURE += $(addprefix -l, $(LIBS_SECURE))
550 endif
nnoble5b7f32a2014-12-22 08:12:44 -0800551
Craig Tiller841c8802015-09-10 13:06:37 -0700552 # grpc .pc file
553 PC_NAME = gRPC
Craig Tillerda179ce2016-02-09 12:01:53 -0800554 PC_DESCRIPTION = high performance general RPC framework
555 PC_CFLAGS =
556 PC_REQUIRES_PRIVATE = $(PC_REQUIRES_GRPC) $(PC_REQUIRES_SECURE)
Craig Tiller841c8802015-09-10 13:06:37 -0700557 PC_LIBS_PRIVATE = $(PC_LIBS_GRPC) $(PC_LIBS_SECURE)
558 PC_LIB = -lgrpc
559 GRPC_PC_FILE := $(PC_TEMPLATE)
murgatroid998faab232015-06-30 17:24:21 -0700560
Craig Tiller841c8802015-09-10 13:06:37 -0700561 # gprc_unsecure .pc file
562 PC_NAME = gRPC unsecure
Craig Tillerda179ce2016-02-09 12:01:53 -0800563 PC_DESCRIPTION = high performance general RPC framework without SSL
564 PC_CFLAGS =
565 PC_REQUIRES_PRIVATE = $(PC_REQUIRES_GRPC)
Craig Tiller841c8802015-09-10 13:06:37 -0700566 PC_LIBS_PRIVATE = $(PC_LIBS_GRPC)
567 PC_LIB = -lgrpc
568 GRPC_UNSECURE_PC_FILE := $(PC_TEMPLATE)
murgatroid998faab232015-06-30 17:24:21 -0700569
Craig Tillerda179ce2016-02-09 12:01:53 -0800570 # gprc_zookeeper .pc file
Craig Tiller841c8802015-09-10 13:06:37 -0700571 PC_NAME = gRPC zookeeper
572 PC_DESCRIPTION = gRPC's zookeeper plugin
573 PC_CFLAGS =
574 PC_REQUIRES_PRIVATE =
575 PC_LIBS_PRIVATE = -lzookeeper_mt
576 GRPC_ZOOKEEPER_PC_FILE := $(PC_TEMPLATE)
Hongwei Wanga8cc4392015-07-16 17:37:47 -0700577
Craig Tiller841c8802015-09-10 13:06:37 -0700578 PROTOBUF_PKG_CONFIG = false
murgatroid99da7a9942015-06-29 14:57:37 -0700579
Craig Tiller841c8802015-09-10 13:06:37 -0700580 PC_REQUIRES_GRPCXX =
581 PC_LIBS_GRPCXX =
murgatroid998faab232015-06-30 17:24:21 -0700582
Craig Tiller841c8802015-09-10 13:06:37 -0700583 CPPFLAGS := -Ithird_party/googletest/include $(CPPFLAGS)
Craig Tiller16f6dac2015-08-24 17:00:04 -0700584
Craig Tiller841c8802015-09-10 13:06:37 -0700585 ifeq ($(HAS_SYSTEM_PROTOBUF),true)
586 ifeq ($(HAS_PKG_CONFIG),true)
587 PROTOBUF_PKG_CONFIG = true
588 PC_REQUIRES_GRPCXX = protobuf
589 CPPFLAGS := $(shell $(PKG_CONFIG) --cflags protobuf) $(CPPFLAGS)
590 LDFLAGS_PROTOBUF_PKG_CONFIG = $(shell $(PKG_CONFIG) --libs-only-L protobuf)
591 ifeq ($(SYSTEM),Linux)
592 ifneq ($(LDFLAGS_PROTOBUF_PKG_CONFIG),)
593 LDFLAGS_PROTOBUF_PKG_CONFIG += $(shell $(PKG_CONFIG) --libs-only-L protobuf | sed s/L/Wl,-rpath,/)
594 endif
595 endif
596 else
597 PC_LIBS_GRPCXX = -lprotobuf
598 endif
599 else
600 ifeq ($(HAS_EMBEDDED_PROTOBUF),true)
601 PROTOBUF_DEP = $(LIBDIR)/$(CONFIG)/protobuf/libprotobuf.a
602 CPPFLAGS := -Ithird_party/protobuf/src $(CPPFLAGS)
603 LDFLAGS := -L$(LIBDIR)/$(CONFIG)/protobuf $(LDFLAGS)
604 PROTOC = $(BINDIR)/$(CONFIG)/protobuf/protoc
605 else
606 NO_PROTOBUF = true
607 endif
608 endif
Nicolas Noble53830622015-02-12 16:56:38 -0800609
Craig Tiller841c8802015-09-10 13:06:37 -0700610 LIBS_PROTOBUF = protobuf
611 LIBS_PROTOC = protoc protobuf
Nicolas Noble53830622015-02-12 16:56:38 -0800612
Craig Tiller841c8802015-09-10 13:06:37 -0700613 HOST_LDLIBS_PROTOC += $(addprefix -l, $(LIBS_PROTOC))
Nicolas Noble53830622015-02-12 16:56:38 -0800614
Craig Tiller841c8802015-09-10 13:06:37 -0700615 ifeq ($(PROTOBUF_PKG_CONFIG),true)
616 LDLIBS_PROTOBUF += $(shell $(PKG_CONFIG) --libs-only-l protobuf)
617 else
618 LDLIBS_PROTOBUF += $(addprefix -l, $(LIBS_PROTOBUF))
619 endif
murgatroid9924e2f4a2015-06-29 11:12:01 -0700620
Craig Tiller841c8802015-09-10 13:06:37 -0700621 # grpc++ .pc file
622 PC_NAME = gRPC++
623 PC_DESCRIPTION = C++ wrapper for gRPC
624 PC_CFLAGS =
625 PC_REQUIRES_PRIVATE = grpc $(PC_REQUIRES_GRPCXX)
626 PC_LIBS_PRIVATE = $(PC_LIBS_GRPCXX)
627 PC_LIB = -lgrpc++
628 GRPCXX_PC_FILE := $(PC_TEMPLATE)
murgatroid998faab232015-06-30 17:24:21 -0700629
Craig Tiller841c8802015-09-10 13:06:37 -0700630 # grpc++_unsecure .pc file
631 PC_NAME = gRPC++ unsecure
632 PC_DESCRIPTION = C++ wrapper for gRPC without SSL
633 PC_CFLAGS =
634 PC_REQUIRES_PRIVATE = grpc_unsecure $(PC_REQUIRES_GRPCXX)
635 PC_LIBS_PRIVATE = $(PC_LIBS_GRPCXX)
636 PC_LIB = -lgrpc++
637 GRPCXX_UNSECURE_PC_FILE := $(PC_TEMPLATE)
murgatroid998faab232015-06-30 17:24:21 -0700638
Craig Tiller841c8802015-09-10 13:06:37 -0700639 ifeq ($(MAKECMDGOALS),clean)
640 NO_DEPS = true
641 endif
nnoble69ac39f2014-12-12 15:43:38 -0800642
Craig Tiller841c8802015-09-10 13:06:37 -0700643 INSTALL_OK = false
644 ifeq ($(HAS_VALID_PROTOC),true)
645 ifeq ($(HAS_SYSTEM_PROTOBUF_VERIFY),true)
646 INSTALL_OK = true
647 endif
648 endif
Nicolas "Pixel" Noble98ab9982015-02-21 04:22:16 +0100649
Craig Tiller841c8802015-09-10 13:06:37 -0700650 .SECONDARY = %.pb.h %.pb.cc
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800651
Craig Tiller841c8802015-09-10 13:06:37 -0700652 PROTOC_PLUGINS =\
653 % for tgt in targets:
654 % if tgt.build == 'protoc':
655 $(BINDIR)/$(CONFIG)/${tgt.name}\
656 % endif
657 % endfor
Craig Tillerf58b9ef2015-01-15 09:09:12 -0800658
Craig Tiller841c8802015-09-10 13:06:37 -0700659 ifeq ($(DEP_MISSING),)
660 all: static shared plugins\
661 % for tgt in targets:
662 % if tgt.build == 'all':
663 $(BINDIR)/$(CONFIG)/${tgt.name}\
664 % endif
665 % endfor
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800666
Craig Tiller841c8802015-09-10 13:06:37 -0700667 dep_error:
668 @echo "You shouldn't see this message - all of your dependencies are correct."
669 else
670 all: dep_error git_update stop
nnoble69ac39f2014-12-12 15:43:38 -0800671
Craig Tiller841c8802015-09-10 13:06:37 -0700672 dep_error:
673 @echo
674 @echo "DEPENDENCY ERROR"
675 @echo
676 @echo "You are missing system dependencies that are essential to build grpc,"
677 @echo "and the third_party directory doesn't have them:"
678 @echo
679 @echo " $(DEP_MISSING)"
680 @echo
681 @echo "Installing the development packages for your system will solve"
682 @echo "this issue. Please consult INSTALL to get more information."
683 @echo
684 @echo "If you need information about why these tests failed, run:"
685 @echo
686 @echo " make run_dep_checks"
687 @echo
688 endif
nnoble69ac39f2014-12-12 15:43:38 -0800689
Craig Tiller841c8802015-09-10 13:06:37 -0700690 git_update:
691 ifeq ($(IS_GIT_FOLDER),true)
692 @echo "Additionally, since you are in a git clone, you can download the"
693 @echo "missing dependencies in third_party by running the following command:"
694 @echo
695 @echo " git submodule update --init"
696 @echo
697 endif
nnoble69ac39f2014-12-12 15:43:38 -0800698
Craig Tiller841c8802015-09-10 13:06:37 -0700699 openssl_dep_error: openssl_dep_message git_update stop
nnoble69ac39f2014-12-12 15:43:38 -0800700
Craig Tiller841c8802015-09-10 13:06:37 -0700701 protobuf_dep_error: protobuf_dep_message git_update stop
Nicolas Noble53830622015-02-12 16:56:38 -0800702
Craig Tiller841c8802015-09-10 13:06:37 -0700703 protoc_dep_error: protoc_dep_message git_update stop
Nicolas Noble53830622015-02-12 16:56:38 -0800704
Craig Tiller841c8802015-09-10 13:06:37 -0700705 openssl_dep_message:
706 @echo
707 @echo "DEPENDENCY ERROR"
708 @echo
709 @echo "The target you are trying to run requires OpenSSL."
710 @echo "Your system doesn't have it, and neither does the third_party directory."
711 @echo
712 @echo "Please consult INSTALL to get more information."
713 @echo
714 @echo "If you need information about why these tests failed, run:"
715 @echo
716 @echo " make run_dep_checks"
717 @echo
nnoble69ac39f2014-12-12 15:43:38 -0800718
Craig Tiller841c8802015-09-10 13:06:37 -0700719 protobuf_dep_message:
720 @echo
721 @echo "DEPENDENCY ERROR"
722 @echo
723 @echo "The target you are trying to run requires protobuf 3.0.0+"
724 @echo "Your system doesn't have it, and neither does the third_party directory."
725 @echo
726 @echo "Please consult INSTALL to get more information."
727 @echo
728 @echo "If you need information about why these tests failed, run:"
729 @echo
730 @echo " make run_dep_checks"
731 @echo
Nicolas Noble53830622015-02-12 16:56:38 -0800732
Craig Tiller841c8802015-09-10 13:06:37 -0700733 protoc_dep_message:
734 @echo
735 @echo "DEPENDENCY ERROR"
736 @echo
737 @echo "The target you are trying to run requires protobuf-compiler 3.0.0+"
738 @echo "Your system doesn't have it, and neither does the third_party directory."
739 @echo
740 @echo "Please consult INSTALL to get more information."
741 @echo
742 @echo "If you need information about why these tests failed, run:"
743 @echo
744 @echo " make run_dep_checks"
745 @echo
Nicolas Noble53830622015-02-12 16:56:38 -0800746
Craig Tiller841c8802015-09-10 13:06:37 -0700747 systemtap_dep_error:
748 @echo
749 @echo "DEPENDENCY ERROR"
750 @echo
751 @echo "Under the '$(CONFIG)' configutation, the target you are trying "
752 @echo "to build requires systemtap 2.7+ (on Linux) or dtrace (on other "
753 @echo "platforms such as Solaris and *BSD). "
754 @echo
755 @echo "Please consult INSTALL to get more information."
756 @echo
David Garcia Quintas8954e902015-04-29 09:46:33 -0700757
Craig Tiller841c8802015-09-10 13:06:37 -0700758 stop:
759 @false
nnoble69ac39f2014-12-12 15:43:38 -0800760
Craig Tiller841c8802015-09-10 13:06:37 -0700761 % for tgt in targets:
762 ${tgt.name}: $(BINDIR)/$(CONFIG)/${tgt.name}
763 % endfor
ctiller09cb6d52014-12-19 17:38:22 -0800764
Craig Tiller841c8802015-09-10 13:06:37 -0700765 run_dep_checks:
766 $(OPENSSL_ALPN_CHECK_CMD) || true
767 $(OPENSSL_NPN_CHECK_CMD) || true
768 $(ZLIB_CHECK_CMD) || true
769 $(PERFTOOLS_CHECK_CMD) || true
770 $(PROTOBUF_CHECK_CMD) || true
771 $(PROTOC_CHECK_VERSION_CMD) || true
772 $(ZOOKEEPER_CHECK_CMD) || true
nnoble69ac39f2014-12-12 15:43:38 -0800773
Craig Tiller841c8802015-09-10 13:06:37 -0700774 third_party/protobuf/configure:
775 $(E) "[AUTOGEN] Preparing protobuf"
776 $(Q)(cd third_party/protobuf ; autoreconf -f -i -Wall,no-obsolete)
Nicolas Noble53830622015-02-12 16:56:38 -0800777
Craig Tiller841c8802015-09-10 13:06:37 -0700778 $(LIBDIR)/$(CONFIG)/protobuf/libprotobuf.a: third_party/protobuf/configure
779 $(E) "[MAKE] Building protobuf"
780 $(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)
781 $(Q)$(MAKE) -C third_party/protobuf clean
782 $(Q)$(MAKE) -C third_party/protobuf
783 $(Q)mkdir -p $(LIBDIR)/$(CONFIG)/protobuf
784 $(Q)mkdir -p $(BINDIR)/$(CONFIG)/protobuf
785 $(Q)cp third_party/protobuf/src/.libs/libprotoc.a $(LIBDIR)/$(CONFIG)/protobuf
786 $(Q)cp third_party/protobuf/src/.libs/libprotobuf.a $(LIBDIR)/$(CONFIG)/protobuf
787 $(Q)cp third_party/protobuf/src/protoc $(BINDIR)/$(CONFIG)/protobuf
Nicolas Noble53830622015-02-12 16:56:38 -0800788
Craig Tiller841c8802015-09-10 13:06:37 -0700789 static: static_c static_cxx
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800790
Nicolas "Pixel" Noble09121792016-01-30 09:01:53 +0100791 static_c: pc_c pc_c_unsecure cache.mk pc_c_zookeeper\
Craig Tiller841c8802015-09-10 13:06:37 -0700792 % for lib in libs:
793 % if lib.build == 'all' and lib.language == 'c' and not lib.get('external_deps', None):
794 $(LIBDIR)/$(CONFIG)/lib${lib.name}.a\
795 % endif
796 % endfor
797 static_zookeeper_libs
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800798
799
Nicolas "Pixel" Noble09121792016-01-30 09:01:53 +0100800 static_cxx: pc_cxx pc_cxx_unsecure cache.mk \
Craig Tiller841c8802015-09-10 13:06:37 -0700801 % for lib in libs:
802 % if lib.build == 'all' and lib.language == 'c++':
803 $(LIBDIR)/$(CONFIG)/lib${lib.name}.a\
804 % endif
805 % endfor
nnoble29e1d292014-12-01 10:27:40 -0800806
807
Craig Tiller841c8802015-09-10 13:06:37 -0700808 shared: shared_c shared_cxx
nnoble29e1d292014-12-01 10:27:40 -0800809
Nicolas "Pixel" Noble09121792016-01-30 09:01:53 +0100810 shared_c: pc_c pc_c_unsecure cache.mk pc_c_zookeeper\
Craig Tiller841c8802015-09-10 13:06:37 -0700811 % for lib in libs:
812 % if lib.build == 'all' and lib.language == 'c' and not lib.get('external_deps', None):
Nicolas "Pixel" Noblec4e57e32016-01-30 21:05:35 +0100813 $(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)${lib.name}$(SHARED_VERSION).$(SHARED_EXT)\
Craig Tiller841c8802015-09-10 13:06:37 -0700814 % endif
815 % endfor
816 shared_zookeeper_libs
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800817
Craig Tiller841c8802015-09-10 13:06:37 -0700818 shared_cxx: pc_cxx pc_cxx_unsecure cache.mk\
819 % for lib in libs:
820 % if lib.build == 'all' and lib.language == 'c++':
Nicolas "Pixel" Noblec4e57e32016-01-30 21:05:35 +0100821 $(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)${lib.name}$(SHARED_VERSION).$(SHARED_EXT)\
Craig Tiller841c8802015-09-10 13:06:37 -0700822 % endif
823 % endfor
nnoble29e1d292014-12-01 10:27:40 -0800824
825
Craig Tiller841c8802015-09-10 13:06:37 -0700826 shared_csharp: shared_c \
827 % for lib in libs:
828 % if lib.build == 'all' and lib.language == 'csharp':
Nicolas "Pixel" Noblec4e57e32016-01-30 21:05:35 +0100829 $(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)${lib.name}$(SHARED_VERSION).$(SHARED_EXT)\
Craig Tiller841c8802015-09-10 13:06:37 -0700830 % endif
831 % endfor
Jan Tattermusch2ec0b3e2015-02-18 15:03:12 -0800832
Craig Tiller841c8802015-09-10 13:06:37 -0700833 ifeq ($(HAS_ZOOKEEPER),true)
834 static_zookeeper_libs:\
835 % for lib in libs:
836 % if lib.build == 'all' and lib.language == 'c' and 'zookeeper' in lib.get('external_deps', []):
837 $(LIBDIR)/$(CONFIG)/lib${lib.name}.a\
838 % endif
839 % endfor
Hongwei Wanga8cc4392015-07-16 17:37:47 -0700840
Craig Tiller841c8802015-09-10 13:06:37 -0700841 shared_zookeeper_libs:\
842 % for lib in libs:
843 % if lib.build == 'all' and lib.language == 'c' and 'zookeeper' in lib.get('external_deps', []):
Nicolas "Pixel" Noblec4e57e32016-01-30 21:05:35 +0100844 $(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)${lib.name}$(SHARED_VERSION).$(SHARED_EXT)\
Craig Tiller841c8802015-09-10 13:06:37 -0700845 % endif
846 % endfor
Hongwei Wanga8cc4392015-07-16 17:37:47 -0700847
Craig Tiller841c8802015-09-10 13:06:37 -0700848 else
Hongwei Wanga8cc4392015-07-16 17:37:47 -0700849
Craig Tiller841c8802015-09-10 13:06:37 -0700850 static_zookeeper_libs:
Hongwei Wanga8cc4392015-07-16 17:37:47 -0700851
Craig Tiller841c8802015-09-10 13:06:37 -0700852 shared_zookeeper_libs:
Hongwei Wanga8cc4392015-07-16 17:37:47 -0700853
Craig Tiller841c8802015-09-10 13:06:37 -0700854 endif
Hongwei Wanga8cc4392015-07-16 17:37:47 -0700855
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:
Craig Tiller0fe5ee72015-12-22 12:50:36 -0800864 % 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 -0700865 $(LIBDIR)/$(CONFIG)/lib${lib.name}.a\
866 % endif
867 % endfor
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800868
Craig Tiller841c8802015-09-10 13:06:37 -0700869 pc_c: $(LIBDIR)/$(CONFIG)/pkgconfig/grpc.pc
murgatroid998faab232015-06-30 17:24:21 -0700870
Craig Tiller841c8802015-09-10 13:06:37 -0700871 pc_c_unsecure: $(LIBDIR)/$(CONFIG)/pkgconfig/grpc_unsecure.pc
murgatroid998faab232015-06-30 17:24:21 -0700872
Craig Tiller841c8802015-09-10 13:06:37 -0700873 ifeq ($(HAS_ZOOKEEPER),true)
874 pc_c_zookeeper: $(LIBDIR)/$(CONFIG)/pkgconfig/grpc_zookeeper.pc
875 else
876 pc_c_zookeeper:
877 endif
Hongwei Wanga3780a82015-07-17 15:27:18 -0700878
Craig Tiller841c8802015-09-10 13:06:37 -0700879 pc_cxx: $(LIBDIR)/$(CONFIG)/pkgconfig/grpc++.pc
murgatroid998faab232015-06-30 17:24:21 -0700880
Craig Tiller841c8802015-09-10 13:06:37 -0700881 pc_cxx_unsecure: $(LIBDIR)/$(CONFIG)/pkgconfig/grpc++_unsecure.pc
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800882
Craig Tiller841c8802015-09-10 13:06:37 -0700883 privatelibs_cxx: \
884 % for lib in libs:
885 % if lib.build == 'private' and lib.language == 'c++' and not lib.get('external_deps', None):
886 $(LIBDIR)/$(CONFIG)/lib${lib.name}.a\
887 % endif
888 % endfor
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800889
890
Craig Tiller841c8802015-09-10 13:06:37 -0700891 ifeq ($(HAS_ZOOKEEPER),true)
892 privatelibs_zookeeper: \
893 % for lib in libs:
894 % if lib.build == 'private' and lib.language == 'c++' and zookeeper in lib.get('external_deps', []):
895 $(LIBDIR)/$(CONFIG)/lib${lib.name}.a\
896 % endif
897 % endfor
Hongwei Wang8e04d412015-07-31 15:12:51 -0700898
Craig Tiller841c8802015-09-10 13:06:37 -0700899 else
900 privatelibs_zookeeper:
901 endif
Hongwei Wang8e04d412015-07-31 15:12:51 -0700902
903
Craig Tiller841c8802015-09-10 13:06:37 -0700904 buildtests: buildtests_c buildtests_cxx buildtests_zookeeper
nnoble29e1d292014-12-01 10:27:40 -0800905
Craig Tiller3824b6e2015-12-09 11:19:59 -0800906 buildtests_c: privatelibs_c <%text>\</%text>
Craig Tiller841c8802015-09-10 13:06:37 -0700907 % for tgt in targets:
908 % if tgt.build == 'test' and not tgt.language == 'c++' and not tgt.get('external_deps', None):
Craig Tiller3824b6e2015-12-09 11:19:59 -0800909 $(BINDIR)/$(CONFIG)/${tgt.name} <%text>\</%text>
Craig Tiller841c8802015-09-10 13:06:37 -0700910 % endif
911 % endfor
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800912
913
Craig Tiller3824b6e2015-12-09 11:19:59 -0800914 buildtests_cxx: buildtests_zookeeper privatelibs_cxx <%text>\</%text>
Craig Tiller841c8802015-09-10 13:06:37 -0700915 % for tgt in targets:
916 % if tgt.build == 'test' and tgt.language == 'c++' and not tgt.get('external_deps', None):
Craig Tiller3824b6e2015-12-09 11:19:59 -0800917 $(BINDIR)/$(CONFIG)/${tgt.name} <%text>\</%text>
Craig Tiller841c8802015-09-10 13:06:37 -0700918 % endif
919 % endfor
nnoble29e1d292014-12-01 10:27:40 -0800920
921
Craig Tiller841c8802015-09-10 13:06:37 -0700922 ifeq ($(HAS_ZOOKEEPER),true)
Craig Tiller3824b6e2015-12-09 11:19:59 -0800923 buildtests_zookeeper: privatelibs_zookeeper <%text>\</%text>
Craig Tiller841c8802015-09-10 13:06:37 -0700924 % for tgt in targets:
925 % if tgt.build == 'test' and tgt.language == 'c++' and 'zookeeper' in tgt.get('external_deps', []):
Craig Tiller3824b6e2015-12-09 11:19:59 -0800926 $(BINDIR)/$(CONFIG)/${tgt.name} <%text>\</%text>
Craig Tiller841c8802015-09-10 13:06:37 -0700927 % endif
928 % endfor
nnoble29e1d292014-12-01 10:27:40 -0800929
Craig Tiller841c8802015-09-10 13:06:37 -0700930 else
931 buildtests_zookeeper:
932 endif
Hongwei Wang8e04d412015-07-31 15:12:51 -0700933
934
Craig Tiller841c8802015-09-10 13:06:37 -0700935 test: test_c test_cxx test_zookeeper
Hongwei Wang8e04d412015-07-31 15:12:51 -0700936
Craig Tiller841c8802015-09-10 13:06:37 -0700937 flaky_test: flaky_test_c flaky_test_cxx flaky_test_zookeeper
Nicolas "Pixel" Noble4251d562015-05-22 19:43:39 +0200938
Craig Tiller841c8802015-09-10 13:06:37 -0700939 test_c: buildtests_c
940 % for tgt in targets:
941 % 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):
942 $(E) "[RUN] Testing ${tgt.name}"
943 $(Q) $(BINDIR)/$(CONFIG)/${tgt.name} || ( echo test ${tgt.name} failed ; exit 1 )
944 % endif
945 % endfor
Nicolas "Pixel" Noble4251d562015-05-22 19:43:39 +0200946
947
Craig Tiller841c8802015-09-10 13:06:37 -0700948 flaky_test_c: buildtests_c
949 % for tgt in targets:
950 % 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):
951 $(E) "[RUN] Testing ${tgt.name}"
952 $(Q) $(BINDIR)/$(CONFIG)/${tgt.name} || ( echo test ${tgt.name} failed ; exit 1 )
953 % endif
954 % endfor
nnoble29e1d292014-12-01 10:27:40 -0800955
956
Craig Tiller841c8802015-09-10 13:06:37 -0700957 test_cxx: test_zookeeper buildtests_cxx
958 % for tgt in targets:
959 % 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):
960 $(E) "[RUN] Testing ${tgt.name}"
961 $(Q) $(BINDIR)/$(CONFIG)/${tgt.name} || ( echo test ${tgt.name} failed ; exit 1 )
962 % endif
963 % endfor
Nicolas "Pixel" Noble4251d562015-05-22 19:43:39 +0200964
965
Craig Tiller841c8802015-09-10 13:06:37 -0700966 flaky_test_cxx: buildtests_cxx
967 % for tgt in targets:
968 % 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):
969 $(E) "[RUN] Testing ${tgt.name}"
970 $(Q) $(BINDIR)/$(CONFIG)/${tgt.name} || ( echo test ${tgt.name} failed ; exit 1 )
971 % endif
972 % endfor
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800973
974
Craig Tiller841c8802015-09-10 13:06:37 -0700975 ifeq ($(HAS_ZOOKEEPER),true)
976 test_zookeeper: buildtests_zookeeper
977 % for tgt in targets:
978 % if tgt.build == 'test' and tgt.get('run', True) and tgt.language == 'c++' and not tgt.get('flaky', False) and 'zookeeper' in tgt.get('external_deps', []):
979 $(E) "[RUN] Testing ${tgt.name}"
980 $(Q) $(BINDIR)/$(CONFIG)/${tgt.name} || ( echo test ${tgt.name} failed ; exit 1 )
981 % endif
982 % endfor
Hongwei Wang8e04d412015-07-31 15:12:51 -0700983
984
Craig Tiller841c8802015-09-10 13:06:37 -0700985 flaky_test_zookeeper: buildtests_zookeeper
986 % for tgt in targets:
987 % if tgt.build == 'test' and tgt.get('run', True) and tgt.language == 'c++' and tgt.get('flaky', False) and 'zookeeper' in tgt.get('external_deps', []):
988 $(E) "[RUN] Testing ${tgt.name}"
989 $(Q) $(BINDIR)/$(CONFIG)/${tgt.name} || ( echo test ${tgt.name} failed ; exit 1 )
990 % endif
991 % endfor
Hongwei Wang8e04d412015-07-31 15:12:51 -0700992
Craig Tiller841c8802015-09-10 13:06:37 -0700993 else
994 test_zookeeper:
995 flaky_test_zookeeper:
996 endif
Hongwei Wang8e04d412015-07-31 15:12:51 -0700997
998
Craig Tiller841c8802015-09-10 13:06:37 -0700999 test_python: static_c
1000 $(E) "[RUN] Testing python code"
1001 $(Q) tools/run_tests/run_tests.py -lpython -c$(CONFIG)
Nicolas "Pixel" Noble051a28f2015-03-17 22:54:54 +01001002
1003
Craig Tiller841c8802015-09-10 13:06:37 -07001004 tools: tools_c tools_cxx
Craig Tiller7552f0f2015-06-19 17:46:20 -07001005
1006
Craig Tiller841c8802015-09-10 13:06:37 -07001007 tools_c: privatelibs_c\
1008 % for tgt in targets:
1009 % if tgt.build == 'tool' and not tgt.language=='c++':
1010 $(BINDIR)/$(CONFIG)/${tgt.name}\
1011 % endif
1012 % endfor
Craig Tiller7552f0f2015-06-19 17:46:20 -07001013
1014
Craig Tiller841c8802015-09-10 13:06:37 -07001015 tools_cxx: privatelibs_cxx\
1016 % for tgt in targets:
1017 % if tgt.build == 'tool' and tgt.language=='c++':
1018 $(BINDIR)/$(CONFIG)/${tgt.name}\
1019 % endif
1020 % endfor
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001021
1022
Craig Tiller841c8802015-09-10 13:06:37 -07001023 buildbenchmarks: privatelibs\
1024 % for tgt in targets:
1025 % if tgt.build == 'benchmark':
1026 $(BINDIR)/$(CONFIG)/${tgt.name}\
1027 % endif
1028 % endfor
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001029
1030
Craig Tiller841c8802015-09-10 13:06:37 -07001031 benchmarks: buildbenchmarks
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001032
Craig Tiller841c8802015-09-10 13:06:37 -07001033 strip: strip-static strip-shared
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001034
Craig Tiller841c8802015-09-10 13:06:37 -07001035 strip-static: strip-static_c strip-static_cxx
nnoble20e2e3f2014-12-16 15:37:57 -08001036
Craig Tiller841c8802015-09-10 13:06:37 -07001037 strip-shared: strip-shared_c strip-shared_cxx
nnoble20e2e3f2014-12-16 15:37:57 -08001038
Nicolas Noble047b7272015-01-16 13:55:05 -08001039
Craig Tiller841c8802015-09-10 13:06:37 -07001040 # TODO(nnoble): the strip target is stripping in-place, instead
1041 # of copying files in a temporary folder.
1042 # This prevents proper debugging after running make install.
Nicolas Noble047b7272015-01-16 13:55:05 -08001043
Craig Tiller841c8802015-09-10 13:06:37 -07001044 strip-static_c: static_c
1045 ifeq ($(CONFIG),opt)
1046 % for lib in libs:
1047 % if lib.language == "c":
1048 % if lib.build == "all":
1049 % if not lib.get('external_deps', None):
1050 $(E) "[STRIP] Stripping lib${lib.name}.a"
1051 $(Q) $(STRIP) $(LIBDIR)/$(CONFIG)/lib${lib.name}.a
1052 % endif
1053 % endif
1054 % endif
1055 % endfor
1056 ifeq ($(HAS_ZOOKEEPER),true)
1057 % for lib in libs:
1058 % if lib.language == "c":
1059 % if lib.build == "all":
1060 % if 'zookeeper' in lib.get('external_deps', []):
1061 $(E) "[STRIP] Stripping lib${lib.name}.a"
1062 $(Q) $(STRIP) $(LIBDIR)/$(CONFIG)/lib${lib.name}.a
1063 % endif
1064 % endif
1065 % endif
1066 % endfor
1067 endif
1068 endif
nnoble85a49262014-12-08 18:14:03 -08001069
Craig Tiller841c8802015-09-10 13:06:37 -07001070 strip-static_cxx: static_cxx
1071 ifeq ($(CONFIG),opt)
1072 % for lib in libs:
1073 % if lib.language == "c++":
1074 % if lib.build == "all":
1075 $(E) "[STRIP] Stripping lib${lib.name}.a"
1076 $(Q) $(STRIP) $(LIBDIR)/$(CONFIG)/lib${lib.name}.a
1077 % endif
1078 % endif
1079 % endfor
1080 endif
Nicolas "Pixel" Noble4ef9b862015-08-14 19:35:24 +02001081
Craig Tiller841c8802015-09-10 13:06:37 -07001082 strip-shared_c: shared_c
1083 ifeq ($(CONFIG),opt)
1084 % for lib in libs:
1085 % if lib.language == "c":
1086 % if lib.build == "all":
1087 % if not lib.get('external_deps', None):
Nicolas "Pixel" Noblec4e57e32016-01-30 21:05:35 +01001088 $(E) "[STRIP] Stripping $(SHARED_PREFIX)${lib.name}$(SHARED_VERSION).$(SHARED_EXT)"
1089 $(Q) $(STRIP) $(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)${lib.name}$(SHARED_VERSION).$(SHARED_EXT)
Craig Tiller841c8802015-09-10 13:06:37 -07001090 % endif
1091 % endif
1092 % endif
1093 % endfor
1094 ifeq ($(HAS_ZOOKEEPER),true)
1095 % for lib in libs:
1096 % if lib.language == "c":
1097 % if lib.build == "all":
1098 % if 'zookeeper' in lib.get('external_deps', []):
Nicolas "Pixel" Noblec4e57e32016-01-30 21:05:35 +01001099 $(E) "[STRIP] Stripping $(SHARED_PREFIX)${lib.name}$(SHARED_VERSION).$(SHARED_EXT)"
1100 $(Q) $(STRIP) $(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)${lib.name}$(SHARED_VERSION).$(SHARED_EXT)
Craig Tiller841c8802015-09-10 13:06:37 -07001101 % endif
1102 % endif
1103 % endif
1104 % endfor
1105 endif
1106 endif
nnoble85a49262014-12-08 18:14:03 -08001107
Craig Tiller841c8802015-09-10 13:06:37 -07001108 strip-shared_cxx: shared_cxx
1109 ifeq ($(CONFIG),opt)
1110 % for lib in libs:
1111 % if lib.language == "c++":
1112 % if lib.build == "all":
Nicolas "Pixel" Noblec4e57e32016-01-30 21:05:35 +01001113 $(E) "[STRIP] Stripping $(SHARED_PREFIX)${lib.name}$(SHARED_VERSION).$(SHARED_EXT)"
1114 $(Q) $(STRIP) $(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)${lib.name}$(SHARED_VERSION).$(SHARED_EXT)
Craig Tiller841c8802015-09-10 13:06:37 -07001115 % endif
1116 % endif
1117 % endfor
1118 endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001119
Craig Tiller841c8802015-09-10 13:06:37 -07001120 strip-shared_csharp: shared_csharp
1121 ifeq ($(CONFIG),opt)
1122 % for lib in libs:
1123 % if lib.language == "csharp":
1124 % if lib.build == "all":
Nicolas "Pixel" Noblec4e57e32016-01-30 21:05:35 +01001125 $(E) "[STRIP] Stripping $(SHARED_PREFIX)${lib.name}$(SHARED_VERSION).$(SHARED_EXT)"
1126 $(Q) $(STRIP) $(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)${lib.name}$(SHARED_VERSION).$(SHARED_EXT)
Craig Tiller841c8802015-09-10 13:06:37 -07001127 % endif
1128 % endif
1129 % endfor
1130 endif
Jan Tattermusch2ec0b3e2015-02-18 15:03:12 -08001131
Craig Tiller841c8802015-09-10 13:06:37 -07001132 cache.mk::
1133 $(E) "[MAKE] Generating $@"
1134 $(Q) echo "$(CACHE_MK)" | tr , '\n' >$@
murgatroid99aa521572015-07-10 14:49:12 -07001135
Craig Tiller841c8802015-09-10 13:06:37 -07001136 $(LIBDIR)/$(CONFIG)/pkgconfig/grpc.pc:
1137 $(E) "[MAKE] Generating $@"
1138 $(Q) mkdir -p $(@D)
1139 $(Q) echo "$(GRPC_PC_FILE)" | tr , '\n' >$@
murgatroid998faab232015-06-30 17:24:21 -07001140
Craig Tiller841c8802015-09-10 13:06:37 -07001141 $(LIBDIR)/$(CONFIG)/pkgconfig/grpc_unsecure.pc:
1142 $(E) "[MAKE] Generating $@"
1143 $(Q) mkdir -p $(@D)
1144 $(Q) echo "$(GRPC_UNSECURE_PC_FILE)" | tr , '\n' >$@
murgatroid998faab232015-06-30 17:24:21 -07001145
Craig Tiller841c8802015-09-10 13:06:37 -07001146 $(LIBDIR)/$(CONFIG)/pkgconfig/grpc_zookeeper.pc:
1147 $(E) "[MAKE] Generating $@"
1148 $(Q) mkdir -p $(@D)
1149 $(Q) echo -e "$(GRPC_ZOOKEEPER_PC_FILE)" >$@
Hongwei Wanga8cc4392015-07-16 17:37:47 -07001150
Craig Tiller841c8802015-09-10 13:06:37 -07001151 $(LIBDIR)/$(CONFIG)/pkgconfig/grpc++.pc:
1152 $(E) "[MAKE] Generating $@"
1153 $(Q) mkdir -p $(@D)
1154 $(Q) echo "$(GRPCXX_PC_FILE)" | tr , '\n' >$@
murgatroid998faab232015-06-30 17:24:21 -07001155
Craig Tiller841c8802015-09-10 13:06:37 -07001156 $(LIBDIR)/$(CONFIG)/pkgconfig/grpc++_unsecure.pc:
1157 $(E) "[MAKE] Generating $@"
1158 $(Q) mkdir -p $(@D)
1159 $(Q) echo "$(GRPCXX_UNSECURE_PC_FILE)" | tr , '\n' >$@
murgatroid998faab232015-06-30 17:24:21 -07001160
Craig Tiller841c8802015-09-10 13:06:37 -07001161 % for p in protos:
1162 ifeq ($(NO_PROTOC),true)
1163 $(GENDIR)/${p}.pb.cc: protoc_dep_error
1164 $(GENDIR)/${p}.grpc.pb.cc: protoc_dep_error
1165 else
Craig Tiller1b4e3302015-12-17 16:35:00 -08001166 $(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 -07001167 $(E) "[PROTOC] Generating protobuf CC file from $<"
1168 $(Q) mkdir -p `dirname $@`
1169 $(Q) $(PROTOC) --cpp_out=$(GENDIR) $<
Nicolas "Pixel" Noble0caebbf2015-04-09 23:08:51 +02001170
Craig Tiller1b4e3302015-12-17 16:35:00 -08001171 $(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 -07001172 $(E) "[GRPC] Generating gRPC's protobuf service CC file from $<"
1173 $(Q) mkdir -p `dirname $@`
1174 $(Q) $(PROTOC) --grpc_out=$(GENDIR) --plugin=protoc-gen-grpc=$(BINDIR)/$(CONFIG)/grpc_cpp_plugin $<
1175 endif
nnoble72309c62014-12-12 11:42:26 -08001176
Craig Tiller841c8802015-09-10 13:06:37 -07001177 % endfor
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001178
Craig Tiller841c8802015-09-10 13:06:37 -07001179 ifeq ($(CONFIG),stapprof)
1180 src/core/profiling/stap_timers.c: $(GENDIR)/src/core/profiling/stap_probes.h
1181 ifeq ($(HAS_SYSTEMTAP),true)
1182 $(GENDIR)/src/core/profiling/stap_probes.h: src/core/profiling/stap_probes.d
1183 $(E) "[DTRACE] Compiling $<"
1184 $(Q) mkdir -p `dirname $@`
1185 $(Q) $(DTRACE) -C -h -s $< -o $@
1186 else
1187 $(GENDIR)/src/core/profiling/stap_probes.h: systemtap_dep_error stop
1188 endif
1189 endif
David Garcia Quintas611b7362015-04-27 15:49:31 -07001190
Craig Tiller841c8802015-09-10 13:06:37 -07001191 $(OBJDIR)/$(CONFIG)/%.o : %.c
1192 $(E) "[C] Compiling $<"
1193 $(Q) mkdir -p `dirname $@`
Nicolas "Pixel" Noble45000342016-01-28 05:04:45 +01001194 $(Q) $(CC) $(CPPFLAGS) $(CFLAGS) -MMD -MF $(addsuffix .dep, $(basename $@)) -c -o $@ $<
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001195
Craig Tiller841c8802015-09-10 13:06:37 -07001196 $(OBJDIR)/$(CONFIG)/%.o : $(GENDIR)/%.pb.cc
1197 $(E) "[CXX] Compiling $<"
1198 $(Q) mkdir -p `dirname $@`
Nicolas "Pixel" Noble45000342016-01-28 05:04:45 +01001199 $(Q) $(CXX) $(CPPFLAGS) $(CXXFLAGS) -MMD -MF $(addsuffix .dep, $(basename $@)) -c -o $@ $<
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001200
Craig Tiller841c8802015-09-10 13:06:37 -07001201 $(OBJDIR)/$(CONFIG)/src/compiler/%.o : src/compiler/%.cc
1202 $(E) "[HOSTCXX] Compiling $<"
1203 $(Q) mkdir -p `dirname $@`
1204 $(Q) $(HOST_CXX) $(HOST_CXXFLAGS) $(HOST_CPPFLAGS) -MMD -MF $(addsuffix .dep, $(basename $@)) -c -o $@ $<
nnoble72309c62014-12-12 11:42:26 -08001205
Craig Tiller841c8802015-09-10 13:06:37 -07001206 $(OBJDIR)/$(CONFIG)/%.o : %.cc
1207 $(E) "[CXX] Compiling $<"
1208 $(Q) mkdir -p `dirname $@`
Nicolas "Pixel" Noble45000342016-01-28 05:04:45 +01001209 $(Q) $(CXX) $(CPPFLAGS) $(CXXFLAGS) -MMD -MF $(addsuffix .dep, $(basename $@)) -c -o $@ $<
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001210
Craig Tiller841c8802015-09-10 13:06:37 -07001211 install: install_c install_cxx install-plugins install-certs verify-install
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001212
Craig Tiller841c8802015-09-10 13:06:37 -07001213 install_c: install-headers_c install-static_c install-shared_c
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001214
Craig Tiller841c8802015-09-10 13:06:37 -07001215 install_cxx: install-headers_cxx install-static_cxx install-shared_cxx
nnoble85a49262014-12-08 18:14:03 -08001216
Craig Tiller841c8802015-09-10 13:06:37 -07001217 install_csharp: install-shared_csharp install_c
Jan Tattermusch2ec0b3e2015-02-18 15:03:12 -08001218
Craig Tiller841c8802015-09-10 13:06:37 -07001219 install_grpc_csharp_ext: install_csharp
Jan Tattermusch2ec0b3e2015-02-18 15:03:12 -08001220
Craig Tiller841c8802015-09-10 13:06:37 -07001221 install-headers: install-headers_c install-headers_cxx
nnoble85a49262014-12-08 18:14:03 -08001222
Craig Tiller841c8802015-09-10 13:06:37 -07001223 install-headers_c:
1224 $(E) "[INSTALL] Installing public C headers"
1225 $(Q) $(foreach h, $(PUBLIC_HEADERS_C), $(INSTALL) -d $(prefix)/$(dir $(h)) && ) exit 0 || exit 1
1226 $(Q) $(foreach h, $(PUBLIC_HEADERS_C), $(INSTALL) $(h) $(prefix)/$(h) && ) exit 0 || exit 1
nnoble85a49262014-12-08 18:14:03 -08001227
Craig Tiller841c8802015-09-10 13:06:37 -07001228 install-headers_cxx:
1229 $(E) "[INSTALL] Installing public C++ headers"
1230 $(Q) $(foreach h, $(PUBLIC_HEADERS_CXX), $(INSTALL) -d $(prefix)/$(dir $(h)) && ) exit 0 || exit 1
1231 $(Q) $(foreach h, $(PUBLIC_HEADERS_CXX), $(INSTALL) $(h) $(prefix)/$(h) && ) exit 0 || exit 1
nnoble85a49262014-12-08 18:14:03 -08001232
Craig Tiller841c8802015-09-10 13:06:37 -07001233 install-static: install-static_c install-static_cxx
nnoble85a49262014-12-08 18:14:03 -08001234
Craig Tiller841c8802015-09-10 13:06:37 -07001235 install-static_c: static_c strip-static_c install-pkg-config_c
1236 % for lib in libs:
1237 % if lib.language == "c":
1238 % if lib.build == "all":
1239 % if not lib.get('external_deps', None):
1240 $(E) "[INSTALL] Installing lib${lib.name}.a"
1241 $(Q) $(INSTALL) -d $(prefix)/lib
1242 $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/lib${lib.name}.a $(prefix)/lib/lib${lib.name}.a
1243 % endif
1244 % endif
1245 % endif
1246 % endfor
1247 ifeq ($(HAS_ZOOKEEPER),true)
1248 % for lib in libs:
1249 % if lib.language == "c":
1250 % if lib.build == "all":
1251 % if 'zookeeper' in lib.get('external_deps', []):
1252 $(E) "[INSTALL] Installing lib${lib.name}.a"
1253 $(Q) $(INSTALL) -d $(prefix)/lib
1254 $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/lib${lib.name}.a $(prefix)/lib/lib${lib.name}.a
1255 % endif
1256 % endif
1257 % endif
1258 % endfor
1259 endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001260
Craig Tiller841c8802015-09-10 13:06:37 -07001261 install-static_cxx: static_cxx strip-static_cxx install-pkg-config_cxx
1262 % for lib in libs:
1263 % if lib.language == "c++":
1264 % if lib.build == "all":
1265 $(E) "[INSTALL] Installing lib${lib.name}.a"
1266 $(Q) $(INSTALL) -d $(prefix)/lib
1267 $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/lib${lib.name}.a $(prefix)/lib/lib${lib.name}.a
1268 % endif
1269 % endif
1270 % endfor
nnoble85a49262014-12-08 18:14:03 -08001271
Craig Tiller841c8802015-09-10 13:06:37 -07001272 <%def name="install_shared(lang_filter)">\
1273 % for lib in libs:
1274 % if lib.language == lang_filter:
1275 % if lib.build == "all":
1276 % if not lib.get('external_deps', None):
Nicolas "Pixel" Noblec4e57e32016-01-30 21:05:35 +01001277 $(E) "[INSTALL] Installing $(SHARED_PREFIX)${lib.name}$(SHARED_VERSION).$(SHARED_EXT)"
1278 $(Q) $(INSTALL) -d $(prefix)/lib
1279 $(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 -07001280 ifeq ($(SYSTEM),MINGW32)
Craig Tiller841c8802015-09-10 13:06:37 -07001281 $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/lib${lib.name}-imp.a $(prefix)/lib/lib${lib.name}-imp.a
Nicolas "Pixel" Noblec4e57e32016-01-30 21:05:35 +01001282 else ifneq ($(SYSTEM),Darwin)
Craig Tillerf008f062016-02-08 12:48:03 -08001283 $(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 +01001284 $(Q) ln -sf $(SHARED_PREFIX)${lib.name}$(SHARED_VERSION).$(SHARED_EXT) $(prefix)/lib/lib${lib.name}.so
Craig Tiller841c8802015-09-10 13:06:37 -07001285 endif
1286 % endif
1287 % endif
1288 % endif
1289 % endfor
1290 ifeq ($(HAS_ZOOKEEPER),true)
1291 % for lib in libs:
1292 % if lib.language == lang_filter:
1293 % if lib.build == "all":
1294 % if 'zookeeper' in lib.get('external_deps', []):
Nicolas "Pixel" Noblec4e57e32016-01-30 21:05:35 +01001295 $(E) "[INSTALL] Installing $(SHARED_PREFIX)${lib.name}$(SHARED_VERSION).$(SHARED_EXT)"
1296 $(Q) $(INSTALL) -d $(prefix)/lib
1297 $(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 -07001298 ifeq ($(SYSTEM),MINGW32)
Craig Tiller841c8802015-09-10 13:06:37 -07001299 $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/lib${lib.name}-imp.a $(prefix)/lib/lib${lib.name}-imp.a
Nicolas "Pixel" Noblec4e57e32016-01-30 21:05:35 +01001300 else ifneq ($(SYSTEM),Darwin)
Craig Tillerf008f062016-02-08 12:48:03 -08001301 $(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 +01001302 $(Q) ln -sf $(SHARED_PREFIX)${lib.name}$(SHARED_VERSION).$(SHARED_EXT) $(prefix)/lib/lib${lib.name}.so
Craig Tiller841c8802015-09-10 13:06:37 -07001303 endif
1304 % endif
1305 % endif
1306 % endif
1307 % endfor
1308 endif
1309 ifneq ($(SYSTEM),MINGW32)
1310 ifneq ($(SYSTEM),Darwin)
1311 $(Q) ldconfig || true
1312 endif
1313 endif
1314 </%def>
nnoble85a49262014-12-08 18:14:03 -08001315
Craig Tiller841c8802015-09-10 13:06:37 -07001316 install-shared_c: shared_c strip-shared_c install-pkg-config_c
1317 ${install_shared("c")}
Nicolas "Pixel" Noble522d7122015-02-19 01:28:02 +01001318
Craig Tiller841c8802015-09-10 13:06:37 -07001319 install-shared_cxx: shared_cxx strip-shared_cxx install-shared_c install-pkg-config_cxx
1320 ${install_shared("c++")}
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001321
Craig Tiller841c8802015-09-10 13:06:37 -07001322 install-shared_csharp: shared_csharp strip-shared_csharp
1323 ${install_shared("csharp")}
Nicolas "Pixel" Noble522d7122015-02-19 01:28:02 +01001324
Craig Tiller841c8802015-09-10 13:06:37 -07001325 install-plugins: $(PROTOC_PLUGINS)
1326 ifeq ($(SYSTEM),MINGW32)
1327 $(Q) false
1328 else
1329 $(E) "[INSTALL] Installing grpc protoc plugins"
1330 % for tgt in targets:
1331 % if tgt.build == 'protoc':
1332 $(Q) $(INSTALL) -d $(prefix)/bin
1333 $(Q) $(INSTALL) $(BINDIR)/$(CONFIG)/${tgt.name} $(prefix)/bin/${tgt.name}
1334 % endif
1335 % endfor
1336 endif
Jan Tattermusch2ec0b3e2015-02-18 15:03:12 -08001337
yang-g2908d632016-02-04 09:46:51 -08001338 install-pkg-config_c: pc_c pc_c_unsecure pc_c_zookeeper
Craig Tiller841c8802015-09-10 13:06:37 -07001339 $(E) "[INSTALL] Installing C pkg-config files"
1340 $(Q) $(INSTALL) -d $(prefix)/lib/pkgconfig
Craig Tiller841c8802015-09-10 13:06:37 -07001341 $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/pkgconfig/grpc.pc $(prefix)/lib/pkgconfig/grpc.pc
1342 $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/pkgconfig/grpc_unsecure.pc $(prefix)/lib/pkgconfig/grpc_unsecure.pc
1343 ifeq ($(HAS_ZOOKEEPER),true)
1344 $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/pkgconfig/grpc_zookeeper.pc $(prefix)/lib/pkgconfig/grpc_zookeeper.pc
1345 endif
murgatroid998faab232015-06-30 17:24:21 -07001346
Craig Tiller841c8802015-09-10 13:06:37 -07001347 install-pkg-config_cxx: pc_cxx pc_cxx_unsecure
1348 $(E) "[INSTALL] Installing C++ pkg-config files"
1349 $(Q) $(INSTALL) -d $(prefix)/lib/pkgconfig
1350 $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/pkgconfig/grpc++.pc $(prefix)/lib/pkgconfig/grpc++.pc
1351 $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/pkgconfig/grpc++_unsecure.pc $(prefix)/lib/pkgconfig/grpc++_unsecure.pc
murgatroid998faab232015-06-30 17:24:21 -07001352
Craig Tiller841c8802015-09-10 13:06:37 -07001353 install-certs: etc/roots.pem
1354 $(E) "[INSTALL] Installing root certificates"
1355 $(Q) $(INSTALL) -d $(prefix)/share/grpc
1356 $(Q) $(INSTALL) etc/roots.pem $(prefix)/share/grpc/roots.pem
Nicolas "Pixel" Noble161ea232015-02-22 05:48:53 +01001357
Craig Tiller841c8802015-09-10 13:06:37 -07001358 verify-install:
1359 ifeq ($(INSTALL_OK),true)
1360 @echo "Your system looks ready to go."
1361 @echo
1362 else
1363 @echo "We couldn't find protoc 3.0.0+ installed on your system. While this"
1364 @echo "won't prevent grpc from working, you won't be able to compile"
1365 @echo "and run any meaningful code with it."
1366 @echo
1367 @echo
1368 @echo "Please download and install protobuf 3.0.0+ from:"
1369 @echo
1370 @echo " https://github.com/google/protobuf/releases"
1371 @echo
1372 @echo "Once you've done so, or if you think this message is in error,"
1373 @echo "you can re-run this check by doing:"
1374 @echo
1375 @echo " make verify-install"
1376 endif
Nicolas "Pixel" Noble98ab9982015-02-21 04:22:16 +01001377
Craig Tiller841c8802015-09-10 13:06:37 -07001378 clean:
1379 $(E) "[CLEAN] Cleaning build directories."
1380 $(Q) $(RM) -rf $(OBJDIR) $(LIBDIR) $(BINDIR) $(GENDIR) cache.mk
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001381
1382
Craig Tiller841c8802015-09-10 13:06:37 -07001383 # The various libraries
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001384
Craig Tiller841c8802015-09-10 13:06:37 -07001385 % for lib in libs:
1386 ${makelib(lib)}
1387 % endfor
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001388
1389
Craig Tiller841c8802015-09-10 13:06:37 -07001390 # All of the test targets, and protoc plugins
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001391
Craig Tiller841c8802015-09-10 13:06:37 -07001392 % for tgt in targets:
1393 ${maketarget(tgt)}
1394 % endfor
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001395
Craig Tiller841c8802015-09-10 13:06:37 -07001396 <%def name="makelib(lib)">
1397 LIB${lib.name.upper()}_SRC = \\
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001398
Craig Tiller841c8802015-09-10 13:06:37 -07001399 % for src in lib.src:
1400 ${proto_to_cc(src)} \\
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001401
Craig Tiller841c8802015-09-10 13:06:37 -07001402 % endfor
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001403
Craig Tiller841c8802015-09-10 13:06:37 -07001404 % if "public_headers" in lib:
1405 % if lib.language == "c++":
1406 PUBLIC_HEADERS_CXX += \\
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001407
Craig Tiller841c8802015-09-10 13:06:37 -07001408 % else:
1409 PUBLIC_HEADERS_C += \\
nnoble85a49262014-12-08 18:14:03 -08001410
Craig Tiller841c8802015-09-10 13:06:37 -07001411 % endif
1412 % for hdr in lib.public_headers:
1413 ${hdr} \\
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001414
Craig Tiller841c8802015-09-10 13:06:37 -07001415 % endfor
1416 % endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001417
Craig Tiller841c8802015-09-10 13:06:37 -07001418 LIB${lib.name.upper()}_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(LIB${lib.name.upper()}_SRC))))
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001419
Nicolas "Pixel" Noble51b1aee2016-01-28 01:14:58 +01001420 % if lib.get('defaults', None):
1421 % for name, value in defaults.get(lib.defaults).iteritems():
1422 $(LIB${lib.name.upper()}_OBJS): ${name} += ${value}
1423 % endfor
Craig Tiller0fe5ee72015-12-22 12:50:36 -08001424 % endif
1425
Craig Tiller841c8802015-09-10 13:06:37 -07001426 ## If the library requires OpenSSL, let's add some restrictions.
1427 % if lib.get('secure', 'check') == True or lib.get('secure', 'check') == 'check':
1428 ifeq ($(NO_SECURE),true)
nnoble69ac39f2014-12-12 15:43:38 -08001429
Craig Tiller841c8802015-09-10 13:06:37 -07001430 # You can't build secure libraries if you don't have OpenSSL.
Nicolas Noble047b7272015-01-16 13:55:05 -08001431
Craig Tiller841c8802015-09-10 13:06:37 -07001432 $(LIBDIR)/$(CONFIG)/lib${lib.name}.a: openssl_dep_error
nnoble69ac39f2014-12-12 15:43:38 -08001433
Craig Tiller841c8802015-09-10 13:06:37 -07001434 % if lib.build == "all":
Nicolas "Pixel" Noblec4e57e32016-01-30 21:05:35 +01001435 $(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)${lib.name}$(SHARED_VERSION).$(SHARED_EXT): openssl_dep_error
Craig Tiller841c8802015-09-10 13:06:37 -07001436 % endif
nnoble5b7f32a2014-12-22 08:12:44 -08001437
Craig Tiller841c8802015-09-10 13:06:37 -07001438 else
nnoble69ac39f2014-12-12 15:43:38 -08001439
Craig Tiller841c8802015-09-10 13:06:37 -07001440 % if lib.language == 'c++':
1441 ifeq ($(NO_PROTOBUF),true)
Nicolas Noble53830622015-02-12 16:56:38 -08001442
Craig Tiller841c8802015-09-10 13:06:37 -07001443 # 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 -08001444
Craig Tiller841c8802015-09-10 13:06:37 -07001445 $(LIBDIR)/$(CONFIG)/lib${lib.name}.a: protobuf_dep_error
Nicolas Noble53830622015-02-12 16:56:38 -08001446
Craig Tiller841c8802015-09-10 13:06:37 -07001447 % if lib.build == "all":
Nicolas "Pixel" Noblec4e57e32016-01-30 21:05:35 +01001448 $(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)${lib.name}$(SHARED_VERSION).$(SHARED_EXT): protobuf_dep_error
Craig Tiller841c8802015-09-10 13:06:37 -07001449 % endif
Nicolas Noble53830622015-02-12 16:56:38 -08001450
Craig Tiller841c8802015-09-10 13:06:37 -07001451 else
1452 % endif
Nicolas Noble53830622015-02-12 16:56:38 -08001453
Craig Tiller841c8802015-09-10 13:06:37 -07001454 $(LIBDIR)/$(CONFIG)/lib${lib.name}.a: $(ZLIB_DEP) $(OPENSSL_DEP)\
1455 ## The else here corresponds to the if secure earlier.
1456 % else:
1457 % if lib.language == 'c++':
1458 ifeq ($(NO_PROTOBUF),true)
Nicolas Noble53830622015-02-12 16:56:38 -08001459
Craig Tiller841c8802015-09-10 13:06:37 -07001460 # 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 -08001461
Craig Tiller841c8802015-09-10 13:06:37 -07001462 $(LIBDIR)/$(CONFIG)/lib${lib.name}.a: protobuf_dep_error
Nicolas Noble53830622015-02-12 16:56:38 -08001463
Craig Tiller841c8802015-09-10 13:06:37 -07001464 % if lib.build == "all":
Nicolas "Pixel" Noblec4e57e32016-01-30 21:05:35 +01001465 $(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)${lib.name}$(SHARED_VERSION).$(SHARED_EXT): protobuf_dep_error
Craig Tiller841c8802015-09-10 13:06:37 -07001466 % endif
Nicolas Noble53830622015-02-12 16:56:38 -08001467
Craig Tiller841c8802015-09-10 13:06:37 -07001468 else
Nicolas Noble53830622015-02-12 16:56:38 -08001469
Craig Tiller841c8802015-09-10 13:06:37 -07001470 % endif
Nicolas "Pixel" Nobled649c212016-01-27 20:27:30 +01001471 $(LIBDIR)/$(CONFIG)/lib${lib.name}.a: \
1472 % if lib.name != 'z':
1473 $(ZLIB_DEP) \
1474 % endif
Craig Tiller841c8802015-09-10 13:06:37 -07001475 % endif
1476 % if lib.language == 'c++':
1477 $(PROTOBUF_DEP)\
1478 % endif
Nicolas "Pixel" Noblef51a9012016-02-03 07:39:43 +01001479 $(LIB${lib.name.upper()}_OBJS) \
1480 % if lib.get('baselib', False):
1481 $(ZLIB_MERGE_OBJS) \
1482 % if lib.get('secure', 'check') == True:
1483 $(OPENSSL_MERGE_OBJS) \
1484 % endif
1485 % endif
1486
Craig Tiller841c8802015-09-10 13:06:37 -07001487 $(E) "[AR] Creating $@"
1488 $(Q) mkdir -p `dirname $@`
1489 $(Q) rm -f $(LIBDIR)/$(CONFIG)/lib${lib.name}.a
Nicolas "Pixel" Noblef51a9012016-02-03 07:39:43 +01001490 $(Q) $(AR) $(LIBDIR)/$(CONFIG)/lib${lib.name}.a $(LIB${lib.name.upper()}_OBJS) \
Craig Tiller841c8802015-09-10 13:06:37 -07001491 % if lib.get('baselib', False):
Nicolas "Pixel" Noblef51a9012016-02-03 07:39:43 +01001492 $(ZLIB_MERGE_OBJS) \
Craig Tiller841c8802015-09-10 13:06:37 -07001493 % if lib.get('secure', 'check') == True:
Nicolas "Pixel" Noblef51a9012016-02-03 07:39:43 +01001494 $(OPENSSL_MERGE_OBJS) \
Craig Tiller841c8802015-09-10 13:06:37 -07001495 % endif
1496 % endif
Nicolas "Pixel" Noblef51a9012016-02-03 07:39:43 +01001497
Craig Tiller841c8802015-09-10 13:06:37 -07001498 ifeq ($(SYSTEM),Darwin)
1499 $(Q) ranlib $(LIBDIR)/$(CONFIG)/lib${lib.name}.a
1500 endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001501
Craig Tiller841c8802015-09-10 13:06:37 -07001502 <%
Nicolas "Pixel" Noble010f1e72015-04-23 02:23:49 +02001503
Craig Tiller841c8802015-09-10 13:06:37 -07001504 if lib.language == 'c++':
1505 ld = '$(LDXX)'
1506 else:
1507 ld = '$(LD)'
nnoble5b7f32a2014-12-22 08:12:44 -08001508
Nicolas "Pixel" Noblec4e57e32016-01-30 21:05:35 +01001509 out_mingbase = '$(LIBDIR)/$(CONFIG)/' + lib.name + '$(SHARED_VERSION)'
1510 out_libbase = '$(LIBDIR)/$(CONFIG)/lib' + lib.name + '$(SHARED_VERSION)'
nnoble5b7f32a2014-12-22 08:12:44 -08001511
Craig Tiller841c8802015-09-10 13:06:37 -07001512 common = '$(LIB' + lib.name.upper() + '_OBJS) $(LDLIBS)'
nnoble5b7f32a2014-12-22 08:12:44 -08001513
Craig Tiller841c8802015-09-10 13:06:37 -07001514 libs = ''
1515 lib_deps = ' $(ZLIB_DEP)'
1516 mingw_libs = ''
1517 mingw_lib_deps = ' $(ZLIB_DEP)'
1518 if lib.language == 'c++':
1519 lib_deps += ' $(PROTOBUF_DEP)'
1520 mingw_lib_deps += ' $(PROTOBUF_DEP)'
Jan Tattermusch324140c2016-01-12 08:54:01 -08001521 if lib.get('deps_linkage', None) == 'static':
1522 for dep in lib.get('deps', []):
1523 lib_archive = '$(LIBDIR)/$(CONFIG)/lib' + dep + '.a'
1524 common = common + ' ' + lib_archive
1525 lib_deps = lib_deps + ' ' + lib_archive
1526 mingw_lib_deps = mingw_lib_deps + ' ' + lib_archive
1527 else:
1528 for dep in lib.get('deps', []):
1529 libs = libs + ' -l' + dep
1530 lib_deps = lib_deps + ' $(LIBDIR)/$(CONFIG)/lib' + dep + '.$(SHARED_EXT)'
1531 mingw_libs = mingw_libs + ' -l' + dep + '-imp'
1532 mingw_lib_deps = mingw_lib_deps + ' $(LIBDIR)/$(CONFIG)/' + dep + '.$(SHARED_EXT)'
nnoble5b7f32a2014-12-22 08:12:44 -08001533
Craig Tiller841c8802015-09-10 13:06:37 -07001534 security = lib.get('secure', 'check')
1535 if security == True:
1536 common = common + ' $(OPENSSL_MERGE_LIBS) $(LDLIBS_SECURE)'
Craig Tiller0fe5ee72015-12-22 12:50:36 -08001537 common = common + ' $(ZLIB_MERGE_LIBS)'
Nicolas "Pixel" Noblea7c162c2015-07-24 20:21:51 +02001538
Craig Tiller841c8802015-09-10 13:06:37 -07001539 if security in [True, 'check']:
1540 for src in lib.src:
1541 if not proto_re.match(src):
1542 sources_that_need_openssl.add(src)
1543 else:
1544 for src in lib.src:
1545 sources_that_don_t_need_openssl.add(src)
Nicolas "Pixel" Noble061690d2015-03-06 22:58:58 +01001546
Craig Tiller841c8802015-09-10 13:06:37 -07001547 if 'zookeeper' in lib.get('external_deps', []):
1548 libs = libs + ' -lzookeeper_mt'
Hongwei Wanga8cc4392015-07-16 17:37:47 -07001549
Craig Tiller841c8802015-09-10 13:06:37 -07001550 if lib.get('secure', 'check') == True or lib.get('secure', 'check') == 'check':
1551 lib_deps = lib_deps + ' $(OPENSSL_DEP)'
1552 mingw_lib_deps = mingw_lib_deps + ' $(OPENSSL_DEP)'
Nicolas "Pixel" Nobledda049c2015-02-21 00:39:32 +01001553
Craig Tiller841c8802015-09-10 13:06:37 -07001554 if lib.language == 'c++':
1555 common = common + ' $(LDLIBSXX) $(LDLIBS_PROTOBUF)'
Craig Tiller4bef7ce2016-02-02 08:38:43 -08001556
1557 ldflags = '$(LDFLAGS)'
1558 if lib.get('LDFLAGS', None):
1559 ldflags += ' ' + lib['LDFLAGS']
Craig Tiller841c8802015-09-10 13:06:37 -07001560 %>
nnoble5b7f32a2014-12-22 08:12:44 -08001561
Craig Tiller841c8802015-09-10 13:06:37 -07001562 % if lib.build == "all":
1563 ifeq ($(SYSTEM),MINGW32)
Nicolas "Pixel" Noblec4e57e32016-01-30 21:05:35 +01001564 ${out_mingbase}.$(SHARED_EXT): $(LIB${lib.name.upper()}_OBJS) ${mingw_lib_deps}
Craig Tiller841c8802015-09-10 13:06:37 -07001565 $(E) "[LD] Linking $@"
1566 $(Q) mkdir -p `dirname $@`
Nicolas "Pixel" Noble89d8ed12016-02-03 01:12:14 +01001567 $(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 -07001568 else
1569 ${out_libbase}.$(SHARED_EXT): $(LIB${lib.name.upper()}_OBJS) ${lib_deps}
1570 $(E) "[LD] Linking $@"
1571 $(Q) mkdir -p `dirname $@`
1572 ifeq ($(SYSTEM),Darwin)
Nicolas "Pixel" Noble89d8ed12016-02-03 01:12:14 +01001573 $(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 -07001574 else
Craig Tillerf008f062016-02-08 12:48:03 -08001575 $(Q) ${ld} ${ldflags} -L$(LIBDIR)/$(CONFIG) -shared -Wl,-soname,lib${lib.name}.so.${settings.core_version.major} -o ${out_libbase}.$(SHARED_EXT) ${common}${libs}
1576 $(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 +01001577 $(Q) ln -sf $(SHARED_PREFIX)${lib.name}$(SHARED_VERSION).$(SHARED_EXT) ${out_libbase}.so
Craig Tiller841c8802015-09-10 13:06:37 -07001578 endif
1579 endif
1580 % endif
1581 % if lib.get('secure', 'check') == True or lib.get('secure', 'check') == 'check':
1582 ## If the lib was secure, we have to close the Makefile's if that tested
1583 ## the presence of OpenSSL.
Nicolas Noble53830622015-02-12 16:56:38 -08001584
Craig Tiller841c8802015-09-10 13:06:37 -07001585 endif
1586 % endif
1587 % if lib.language == 'c++':
1588 ## If the lib was C++, we have to close the Makefile's if that tested
1589 ## the presence of protobuf 3.0.0+
nnoble69ac39f2014-12-12 15:43:38 -08001590
Craig Tiller841c8802015-09-10 13:06:37 -07001591 endif
1592 % endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001593
Craig Tiller841c8802015-09-10 13:06:37 -07001594 % if lib.get('secure', 'check') == True or lib.get('secure', 'check') == 'check':
1595 ifneq ($(NO_SECURE),true)
1596 % endif
1597 ifneq ($(NO_DEPS),true)
1598 -include $(LIB${lib.name.upper()}_OBJS:.o=.dep)
1599 endif
1600 % if lib.get('secure', 'check') == True or lib.get('secure', 'check') == 'check':
1601 endif
1602 % endif
1603 % for src in lib.src:
1604 % if not proto_re.match(src) and any(proto_re.match(src2) for src2 in lib.src):
1605 $(OBJDIR)/$(CONFIG)/${os.path.splitext(src)[0]}.o: ${' '.join(proto_to_cc(src2) for src2 in lib.src if proto_re.match(src2))}
1606 % endif
1607 % endfor
1608 </%def>
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001609
Craig Tiller841c8802015-09-10 13:06:37 -07001610 <%def name="maketarget(tgt)"><% has_no_sources = not tgt.src %>
1611 % if not has_no_sources:
1612 ${tgt.name.upper()}_SRC = \\
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001613
Craig Tiller841c8802015-09-10 13:06:37 -07001614 % for src in tgt.src:
1615 ${proto_to_cc(src)} \\
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001616
Craig Tiller841c8802015-09-10 13:06:37 -07001617 % endfor
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001618
Craig Tiller841c8802015-09-10 13:06:37 -07001619 ${tgt.name.upper()}_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(${tgt.name.upper()}_SRC))))
1620 % endif
1621 % if tgt.get('secure', 'check') == True or tgt.get('secure', 'check') == 'check':
1622 ifeq ($(NO_SECURE),true)
nnoble69ac39f2014-12-12 15:43:38 -08001623
Craig Tiller841c8802015-09-10 13:06:37 -07001624 # You can't build secure targets if you don't have OpenSSL.
Nicolas Noble047b7272015-01-16 13:55:05 -08001625
Craig Tiller841c8802015-09-10 13:06:37 -07001626 $(BINDIR)/$(CONFIG)/${tgt.name}: openssl_dep_error
nnoble69ac39f2014-12-12 15:43:38 -08001627
Craig Tiller841c8802015-09-10 13:06:37 -07001628 else
nnoble69ac39f2014-12-12 15:43:38 -08001629
Craig Tiller841c8802015-09-10 13:06:37 -07001630 % endif
Craig Tiller0fe5ee72015-12-22 12:50:36 -08001631
1632 % if tgt.boringssl:
1633 # boringssl needs an override to ensure that it does not include
1634 # system openssl headers regardless of other configuration
1635 # we do so here with a target specific variable assignment
1636 $(${tgt.name.upper()}_OBJS): CFLAGS := -Ithird_party/boringssl/include $(CFLAGS) -Wno-sign-conversion -Wno-conversion -Wno-unused-value
1637 $(${tgt.name.upper()}_OBJS): CXXFLAGS := -Ithird_party/boringssl/include $(CXXFLAGS)
1638 $(${tgt.name.upper()}_OBJS): CPPFLAGS += -DOPENSSL_NO_ASM -D_GNU_SOURCE
1639 % else:
1640 % endif
1641
Craig Tiller841c8802015-09-10 13:06:37 -07001642 ##
1643 ## We're not trying to add a dependency on building zlib and openssl here,
1644 ## as it's already done in the libraries. We're assuming that the build
1645 ## trickles down, and that a secure target requires a secure version of
1646 ## a library.
1647 ##
1648 ## That simplifies the codegen a bit, but prevents a fully defined Makefile.
1649 ## I can live with that.
1650 ##
1651 % if tgt.build == 'protoc' or tgt.language == 'c++':
Nicolas Noble53830622015-02-12 16:56:38 -08001652
Craig Tiller841c8802015-09-10 13:06:37 -07001653 ifeq ($(NO_PROTOBUF),true)
Nicolas Noble53830622015-02-12 16:56:38 -08001654
Craig Tiller841c8802015-09-10 13:06:37 -07001655 # 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 -08001656
Craig Tiller841c8802015-09-10 13:06:37 -07001657 $(BINDIR)/$(CONFIG)/${tgt.name}: protobuf_dep_error
Nicolas Noble53830622015-02-12 16:56:38 -08001658
Craig Tiller841c8802015-09-10 13:06:37 -07001659 else
Nicolas Noble53830622015-02-12 16:56:38 -08001660
Craig Tiller841c8802015-09-10 13:06:37 -07001661 $(BINDIR)/$(CONFIG)/${tgt.name}: \
1662 % if not has_no_sources:
1663 $(PROTOBUF_DEP) $(${tgt.name.upper()}_OBJS)\
1664 % endif
1665 % else:
1666 $(BINDIR)/$(CONFIG)/${tgt.name}: \
1667 % if not has_no_sources:
1668 $(${tgt.name.upper()}_OBJS)\
1669 % endif
1670 % endif
1671 % for dep in tgt.deps:
1672 $(LIBDIR)/$(CONFIG)/lib${dep}.a\
1673 % endfor
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001674
Craig Tiller0fe5ee72015-12-22 12:50:36 -08001675 % if tgt.language == "c++" or tgt.boringssl:
Craig Tiller841c8802015-09-10 13:06:37 -07001676 ## C++ targets specificies.
1677 % if tgt.build == 'protoc':
1678 $(E) "[HOSTLD] Linking $@"
1679 $(Q) mkdir -p `dirname $@`
1680 $(Q) $(HOST_LDXX) $(HOST_LDFLAGS) \
1681 % if not has_no_sources:
1682 $(${tgt.name.upper()}_OBJS)\
1683 % endif
1684 % else:
1685 $(E) "[LD] Linking $@"
1686 $(Q) mkdir -p `dirname $@`
1687 $(Q) $(LDXX) $(LDFLAGS) \
1688 % if not has_no_sources:
1689 $(${tgt.name.upper()}_OBJS)\
1690 % endif
1691 % endif
1692 % else:
1693 ## C-only targets specificities.
1694 $(E) "[LD] Linking $@"
1695 $(Q) mkdir -p `dirname $@`
1696 $(Q) $(LD) $(LDFLAGS) \
1697 % if not has_no_sources:
1698 $(${tgt.name.upper()}_OBJS)\
1699 % endif
1700 % endif
1701 % for dep in tgt.deps:
1702 $(LIBDIR)/$(CONFIG)/lib${dep}.a\
1703 % endfor
1704 % if 'zookeeper' in tgt.get('external_deps', []):
1705 -lzookeeper_mt\
1706 % endif
1707 % if tgt.language == "c++":
1708 % if tgt.build == 'protoc':
1709 $(HOST_LDLIBSXX) $(HOST_LDLIBS_PROTOC)\
1710 % else:
1711 $(LDLIBSXX) $(LDLIBS_PROTOBUF)\
1712 % endif
1713 % endif
1714 % if tgt.build == 'protoc':
1715 $(HOST_LDLIBS)\
1716 % else:
1717 $(LDLIBS)\
1718 % endif
1719 % if tgt.build == 'protoc':
1720 $(HOST_LDLIBS_PROTOC)\
1721 % elif tgt.get('secure', 'check') == True or tgt.get('secure', 'check') == 'check':
1722 $(LDLIBS_SECURE)\
1723 % endif
1724 % if tgt.language == 'c++' and tgt.build == 'test':
1725 $(GTEST_LIB)\
1726 % elif tgt.language == 'c++' and tgt.build == 'benchmark':
1727 $(GTEST_LIB)\
1728 % endif
1729 -o $(BINDIR)/$(CONFIG)/${tgt.name}
1730 % if tgt.build == 'protoc' or tgt.language == 'c++':
Nicolas Noble53830622015-02-12 16:56:38 -08001731
Craig Tiller841c8802015-09-10 13:06:37 -07001732 endif
1733 % endif
1734 % if tgt.get('secure', 'check') == True or tgt.get('secure', 'check') == 'check':
nnoble69ac39f2014-12-12 15:43:38 -08001735
Craig Tiller841c8802015-09-10 13:06:37 -07001736 endif
1737 % endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001738
Craig Tiller841c8802015-09-10 13:06:37 -07001739 % for src in tgt.src:
1740 $(OBJDIR)/$(CONFIG)/${os.path.splitext(src)[0]}.o: \
1741 % for dep in tgt.deps:
1742 $(LIBDIR)/$(CONFIG)/lib${dep}.a\
1743 % endfor
Craig Tillerf5371ef2015-01-12 16:40:18 -08001744
Craig Tillerab230452016-01-04 08:18:43 -08001745 % if tgt.language == 'c89':
1746 % for src in tgt.src:
Craig Tillerea21ca22016-01-04 12:34:29 -08001747 $(OBJDIR)/$(CONFIG)/${os.path.splitext(src)[0]}.o : ${src}
1748 $(E) "[C] Compiling $<"
1749 $(Q) mkdir -p `dirname $@`
Nicolas "Pixel" Noble45000342016-01-28 05:04:45 +01001750 $(Q) $(CC) $(CPPFLAGS) $(CFLAGS) -std=c89 -pedantic -MMD -MF $(addsuffix .dep, $(basename $@)) -c -o $@ $<
Craig Tillerab230452016-01-04 08:18:43 -08001751 % endfor
1752 % endif
1753
Craig Tiller841c8802015-09-10 13:06:37 -07001754 % endfor
1755 % if not has_no_sources:
1756 deps_${tgt.name}: $(${tgt.name.upper()}_OBJS:.o=.dep)
1757 % endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001758
Craig Tiller841c8802015-09-10 13:06:37 -07001759 % if not has_no_sources:
1760 % if tgt.get('secure', 'check') == True or tgt.get('secure', 'check') == 'check':
1761 ifneq ($(NO_SECURE),true)
1762 % endif
1763 ifneq ($(NO_DEPS),true)
1764 -include $(${tgt.name.upper()}_OBJS:.o=.dep)
1765 endif
1766 % if tgt.get('secure', 'check') == True or tgt.get('secure', 'check') == 'check':
1767 endif
1768 % endif
1769 % endif
Nicolas "Pixel" Noble472bb682015-11-03 19:09:01 +01001770 % for src in tgt.src:
1771 % if not proto_re.match(src) and any(proto_re.match(src2) for src2 in tgt.src):
1772 $(OBJDIR)/$(CONFIG)/${os.path.splitext(src)[0]}.o: ${' '.join(proto_to_cc(src2) for src2 in tgt.src if proto_re.match(src2))}
1773 % endif
1774 % endfor
Craig Tiller841c8802015-09-10 13:06:37 -07001775 </%def>
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001776
Craig Tiller841c8802015-09-10 13:06:37 -07001777 ifneq ($(OPENSSL_DEP),)
1778 # This is to ensure the embedded OpenSSL is built beforehand, properly
1779 # installing headers to their final destination on the drive. We need this
1780 # otherwise parallel compilation will fail if a source is compiled first.
1781 % for src in sorted(sources_that_need_openssl):
1782 % if src not in sources_that_don_t_need_openssl:
1783 ${src}: $(OPENSSL_DEP)
1784 % endif
1785 % endfor
1786 endif
Nicolas "Pixel" Noble010f1e72015-04-23 02:23:49 +02001787
Craig Tiller841c8802015-09-10 13:06:37 -07001788 .PHONY: all strip tools \
1789 dep_error openssl_dep_error openssl_dep_message git_update stop \
1790 buildtests buildtests_c buildtests_cxx \
1791 test test_c test_cxx \
1792 install install_c install_cxx \
1793 install-headers install-headers_c install-headers_cxx \
1794 install-shared install-shared_c install-shared_cxx \
1795 install-static install-static_c install-static_cxx \
1796 strip strip-shared strip-static \
1797 strip_c strip-shared_c strip-static_c \
1798 strip_cxx strip-shared_cxx strip-static_cxx \
1799 dep_c dep_cxx bins_dep_c bins_dep_cxx \
1800 clean