blob: 994251421165020e3857f7beeef5eb20996529ff [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
Nicolas "Pixel" Noble09121792016-01-30 09:01:53 +0100554 PC_DESCRIPTION = High performance general RPC framework
555 PC_CFLAGS = -pthread
556 PC_REQUIRES_PRIVATE = $(PC_REQUIRES_GRPC) $(PC_REQUIRES_SECURE) -lpthread
Craig Tiller841c8802015-09-10 13:06:37 -0700557 PC_LIBS_PRIVATE = $(PC_LIBS_GRPC) $(PC_LIBS_SECURE)
558 PC_LIB = -lgrpc
Nicolas "Pixel" Noble09121792016-01-30 09:01:53 +0100559 ifneq ($(SYSTEM),Darwin)
560 PC_LIBS_PRIVATE += -lrt
561 endif
Craig Tiller841c8802015-09-10 13:06:37 -0700562 GRPC_PC_FILE := $(PC_TEMPLATE)
murgatroid998faab232015-06-30 17:24:21 -0700563
Craig Tiller841c8802015-09-10 13:06:37 -0700564 # gprc_unsecure .pc file
565 PC_NAME = gRPC unsecure
Nicolas "Pixel" Noble09121792016-01-30 09:01:53 +0100566 PC_DESCRIPTION = High performance general RPC framework without SSL
567 PC_CFLAGS = -pthread
568 PC_REQUIRES_PRIVATE = $(PC_REQUIRES_GRPC) -lpthread
Craig Tiller841c8802015-09-10 13:06:37 -0700569 PC_LIBS_PRIVATE = $(PC_LIBS_GRPC)
570 PC_LIB = -lgrpc
Nicolas "Pixel" Noble09121792016-01-30 09:01:53 +0100571 ifneq ($(SYSTEM),Darwin)
572 PC_LIBS_PRIVATE += -lrt
573 endif
Craig Tiller841c8802015-09-10 13:06:37 -0700574 GRPC_UNSECURE_PC_FILE := $(PC_TEMPLATE)
murgatroid998faab232015-06-30 17:24:21 -0700575
Nicolas "Pixel" Noble09121792016-01-30 09:01:53 +0100576 # grpc_zookeeper .pc file
Craig Tiller841c8802015-09-10 13:06:37 -0700577 PC_NAME = gRPC zookeeper
578 PC_DESCRIPTION = gRPC's zookeeper plugin
579 PC_CFLAGS =
580 PC_REQUIRES_PRIVATE =
581 PC_LIBS_PRIVATE = -lzookeeper_mt
582 GRPC_ZOOKEEPER_PC_FILE := $(PC_TEMPLATE)
Hongwei Wanga8cc4392015-07-16 17:37:47 -0700583
Craig Tiller841c8802015-09-10 13:06:37 -0700584 PROTOBUF_PKG_CONFIG = false
murgatroid99da7a9942015-06-29 14:57:37 -0700585
Craig Tiller841c8802015-09-10 13:06:37 -0700586 PC_REQUIRES_GRPCXX =
587 PC_LIBS_GRPCXX =
murgatroid998faab232015-06-30 17:24:21 -0700588
Craig Tiller841c8802015-09-10 13:06:37 -0700589 CPPFLAGS := -Ithird_party/googletest/include $(CPPFLAGS)
Craig Tiller16f6dac2015-08-24 17:00:04 -0700590
Craig Tiller841c8802015-09-10 13:06:37 -0700591 ifeq ($(HAS_SYSTEM_PROTOBUF),true)
592 ifeq ($(HAS_PKG_CONFIG),true)
593 PROTOBUF_PKG_CONFIG = true
594 PC_REQUIRES_GRPCXX = protobuf
595 CPPFLAGS := $(shell $(PKG_CONFIG) --cflags protobuf) $(CPPFLAGS)
596 LDFLAGS_PROTOBUF_PKG_CONFIG = $(shell $(PKG_CONFIG) --libs-only-L protobuf)
597 ifeq ($(SYSTEM),Linux)
598 ifneq ($(LDFLAGS_PROTOBUF_PKG_CONFIG),)
599 LDFLAGS_PROTOBUF_PKG_CONFIG += $(shell $(PKG_CONFIG) --libs-only-L protobuf | sed s/L/Wl,-rpath,/)
600 endif
601 endif
602 else
603 PC_LIBS_GRPCXX = -lprotobuf
604 endif
605 else
606 ifeq ($(HAS_EMBEDDED_PROTOBUF),true)
607 PROTOBUF_DEP = $(LIBDIR)/$(CONFIG)/protobuf/libprotobuf.a
608 CPPFLAGS := -Ithird_party/protobuf/src $(CPPFLAGS)
609 LDFLAGS := -L$(LIBDIR)/$(CONFIG)/protobuf $(LDFLAGS)
610 PROTOC = $(BINDIR)/$(CONFIG)/protobuf/protoc
611 else
612 NO_PROTOBUF = true
613 endif
614 endif
Nicolas Noble53830622015-02-12 16:56:38 -0800615
Craig Tiller841c8802015-09-10 13:06:37 -0700616 LIBS_PROTOBUF = protobuf
617 LIBS_PROTOC = protoc protobuf
Nicolas Noble53830622015-02-12 16:56:38 -0800618
Craig Tiller841c8802015-09-10 13:06:37 -0700619 HOST_LDLIBS_PROTOC += $(addprefix -l, $(LIBS_PROTOC))
Nicolas Noble53830622015-02-12 16:56:38 -0800620
Craig Tiller841c8802015-09-10 13:06:37 -0700621 ifeq ($(PROTOBUF_PKG_CONFIG),true)
622 LDLIBS_PROTOBUF += $(shell $(PKG_CONFIG) --libs-only-l protobuf)
623 else
624 LDLIBS_PROTOBUF += $(addprefix -l, $(LIBS_PROTOBUF))
625 endif
murgatroid9924e2f4a2015-06-29 11:12:01 -0700626
Craig Tiller841c8802015-09-10 13:06:37 -0700627 # grpc++ .pc file
628 PC_NAME = gRPC++
629 PC_DESCRIPTION = C++ wrapper for gRPC
630 PC_CFLAGS =
631 PC_REQUIRES_PRIVATE = grpc $(PC_REQUIRES_GRPCXX)
632 PC_LIBS_PRIVATE = $(PC_LIBS_GRPCXX)
633 PC_LIB = -lgrpc++
634 GRPCXX_PC_FILE := $(PC_TEMPLATE)
murgatroid998faab232015-06-30 17:24:21 -0700635
Craig Tiller841c8802015-09-10 13:06:37 -0700636 # grpc++_unsecure .pc file
637 PC_NAME = gRPC++ unsecure
638 PC_DESCRIPTION = C++ wrapper for gRPC without SSL
639 PC_CFLAGS =
640 PC_REQUIRES_PRIVATE = grpc_unsecure $(PC_REQUIRES_GRPCXX)
641 PC_LIBS_PRIVATE = $(PC_LIBS_GRPCXX)
642 PC_LIB = -lgrpc++
643 GRPCXX_UNSECURE_PC_FILE := $(PC_TEMPLATE)
murgatroid998faab232015-06-30 17:24:21 -0700644
Craig Tiller841c8802015-09-10 13:06:37 -0700645 ifeq ($(MAKECMDGOALS),clean)
646 NO_DEPS = true
647 endif
nnoble69ac39f2014-12-12 15:43:38 -0800648
Craig Tiller841c8802015-09-10 13:06:37 -0700649 INSTALL_OK = false
650 ifeq ($(HAS_VALID_PROTOC),true)
651 ifeq ($(HAS_SYSTEM_PROTOBUF_VERIFY),true)
652 INSTALL_OK = true
653 endif
654 endif
Nicolas "Pixel" Noble98ab9982015-02-21 04:22:16 +0100655
Craig Tiller841c8802015-09-10 13:06:37 -0700656 .SECONDARY = %.pb.h %.pb.cc
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800657
Craig Tiller841c8802015-09-10 13:06:37 -0700658 PROTOC_PLUGINS =\
659 % for tgt in targets:
660 % if tgt.build == 'protoc':
661 $(BINDIR)/$(CONFIG)/${tgt.name}\
662 % endif
663 % endfor
Craig Tillerf58b9ef2015-01-15 09:09:12 -0800664
Craig Tiller841c8802015-09-10 13:06:37 -0700665 ifeq ($(DEP_MISSING),)
666 all: static shared plugins\
667 % for tgt in targets:
668 % if tgt.build == 'all':
669 $(BINDIR)/$(CONFIG)/${tgt.name}\
670 % endif
671 % endfor
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800672
Craig Tiller841c8802015-09-10 13:06:37 -0700673 dep_error:
674 @echo "You shouldn't see this message - all of your dependencies are correct."
675 else
676 all: dep_error git_update stop
nnoble69ac39f2014-12-12 15:43:38 -0800677
Craig Tiller841c8802015-09-10 13:06:37 -0700678 dep_error:
679 @echo
680 @echo "DEPENDENCY ERROR"
681 @echo
682 @echo "You are missing system dependencies that are essential to build grpc,"
683 @echo "and the third_party directory doesn't have them:"
684 @echo
685 @echo " $(DEP_MISSING)"
686 @echo
687 @echo "Installing the development packages for your system will solve"
688 @echo "this issue. Please consult INSTALL to get more information."
689 @echo
690 @echo "If you need information about why these tests failed, run:"
691 @echo
692 @echo " make run_dep_checks"
693 @echo
694 endif
nnoble69ac39f2014-12-12 15:43:38 -0800695
Craig Tiller841c8802015-09-10 13:06:37 -0700696 git_update:
697 ifeq ($(IS_GIT_FOLDER),true)
698 @echo "Additionally, since you are in a git clone, you can download the"
699 @echo "missing dependencies in third_party by running the following command:"
700 @echo
701 @echo " git submodule update --init"
702 @echo
703 endif
nnoble69ac39f2014-12-12 15:43:38 -0800704
Craig Tiller841c8802015-09-10 13:06:37 -0700705 openssl_dep_error: openssl_dep_message git_update stop
nnoble69ac39f2014-12-12 15:43:38 -0800706
Craig Tiller841c8802015-09-10 13:06:37 -0700707 protobuf_dep_error: protobuf_dep_message git_update stop
Nicolas Noble53830622015-02-12 16:56:38 -0800708
Craig Tiller841c8802015-09-10 13:06:37 -0700709 protoc_dep_error: protoc_dep_message git_update stop
Nicolas Noble53830622015-02-12 16:56:38 -0800710
Craig Tiller841c8802015-09-10 13:06:37 -0700711 openssl_dep_message:
712 @echo
713 @echo "DEPENDENCY ERROR"
714 @echo
715 @echo "The target you are trying to run requires OpenSSL."
716 @echo "Your system doesn't have it, and neither does the third_party directory."
717 @echo
718 @echo "Please consult INSTALL to get more information."
719 @echo
720 @echo "If you need information about why these tests failed, run:"
721 @echo
722 @echo " make run_dep_checks"
723 @echo
nnoble69ac39f2014-12-12 15:43:38 -0800724
Craig Tiller841c8802015-09-10 13:06:37 -0700725 protobuf_dep_message:
726 @echo
727 @echo "DEPENDENCY ERROR"
728 @echo
729 @echo "The target you are trying to run requires protobuf 3.0.0+"
730 @echo "Your system doesn't have it, and neither does the third_party directory."
731 @echo
732 @echo "Please consult INSTALL to get more information."
733 @echo
734 @echo "If you need information about why these tests failed, run:"
735 @echo
736 @echo " make run_dep_checks"
737 @echo
Nicolas Noble53830622015-02-12 16:56:38 -0800738
Craig Tiller841c8802015-09-10 13:06:37 -0700739 protoc_dep_message:
740 @echo
741 @echo "DEPENDENCY ERROR"
742 @echo
743 @echo "The target you are trying to run requires protobuf-compiler 3.0.0+"
744 @echo "Your system doesn't have it, and neither does the third_party directory."
745 @echo
746 @echo "Please consult INSTALL to get more information."
747 @echo
748 @echo "If you need information about why these tests failed, run:"
749 @echo
750 @echo " make run_dep_checks"
751 @echo
Nicolas Noble53830622015-02-12 16:56:38 -0800752
Craig Tiller841c8802015-09-10 13:06:37 -0700753 systemtap_dep_error:
754 @echo
755 @echo "DEPENDENCY ERROR"
756 @echo
757 @echo "Under the '$(CONFIG)' configutation, the target you are trying "
758 @echo "to build requires systemtap 2.7+ (on Linux) or dtrace (on other "
759 @echo "platforms such as Solaris and *BSD). "
760 @echo
761 @echo "Please consult INSTALL to get more information."
762 @echo
David Garcia Quintas8954e902015-04-29 09:46:33 -0700763
Craig Tiller841c8802015-09-10 13:06:37 -0700764 stop:
765 @false
nnoble69ac39f2014-12-12 15:43:38 -0800766
Craig Tiller841c8802015-09-10 13:06:37 -0700767 % for tgt in targets:
768 ${tgt.name}: $(BINDIR)/$(CONFIG)/${tgt.name}
769 % endfor
ctiller09cb6d52014-12-19 17:38:22 -0800770
Craig Tiller841c8802015-09-10 13:06:37 -0700771 run_dep_checks:
772 $(OPENSSL_ALPN_CHECK_CMD) || true
773 $(OPENSSL_NPN_CHECK_CMD) || true
774 $(ZLIB_CHECK_CMD) || true
775 $(PERFTOOLS_CHECK_CMD) || true
776 $(PROTOBUF_CHECK_CMD) || true
777 $(PROTOC_CHECK_VERSION_CMD) || true
778 $(ZOOKEEPER_CHECK_CMD) || true
nnoble69ac39f2014-12-12 15:43:38 -0800779
Craig Tiller841c8802015-09-10 13:06:37 -0700780 third_party/protobuf/configure:
781 $(E) "[AUTOGEN] Preparing protobuf"
782 $(Q)(cd third_party/protobuf ; autoreconf -f -i -Wall,no-obsolete)
Nicolas Noble53830622015-02-12 16:56:38 -0800783
Craig Tiller841c8802015-09-10 13:06:37 -0700784 $(LIBDIR)/$(CONFIG)/protobuf/libprotobuf.a: third_party/protobuf/configure
785 $(E) "[MAKE] Building protobuf"
786 $(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)
787 $(Q)$(MAKE) -C third_party/protobuf clean
788 $(Q)$(MAKE) -C third_party/protobuf
789 $(Q)mkdir -p $(LIBDIR)/$(CONFIG)/protobuf
790 $(Q)mkdir -p $(BINDIR)/$(CONFIG)/protobuf
791 $(Q)cp third_party/protobuf/src/.libs/libprotoc.a $(LIBDIR)/$(CONFIG)/protobuf
792 $(Q)cp third_party/protobuf/src/.libs/libprotobuf.a $(LIBDIR)/$(CONFIG)/protobuf
793 $(Q)cp third_party/protobuf/src/protoc $(BINDIR)/$(CONFIG)/protobuf
Nicolas Noble53830622015-02-12 16:56:38 -0800794
Craig Tiller841c8802015-09-10 13:06:37 -0700795 static: static_c static_cxx
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800796
Nicolas "Pixel" Noble09121792016-01-30 09:01:53 +0100797 static_c: pc_c pc_c_unsecure cache.mk pc_c_zookeeper\
Craig Tiller841c8802015-09-10 13:06:37 -0700798 % for lib in libs:
799 % if lib.build == 'all' and lib.language == 'c' and not lib.get('external_deps', None):
800 $(LIBDIR)/$(CONFIG)/lib${lib.name}.a\
801 % endif
802 % endfor
803 static_zookeeper_libs
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800804
805
Nicolas "Pixel" Noble09121792016-01-30 09:01:53 +0100806 static_cxx: pc_cxx pc_cxx_unsecure cache.mk \
Craig Tiller841c8802015-09-10 13:06:37 -0700807 % for lib in libs:
808 % if lib.build == 'all' and lib.language == 'c++':
809 $(LIBDIR)/$(CONFIG)/lib${lib.name}.a\
810 % endif
811 % endfor
nnoble29e1d292014-12-01 10:27:40 -0800812
813
Craig Tiller841c8802015-09-10 13:06:37 -0700814 shared: shared_c shared_cxx
nnoble29e1d292014-12-01 10:27:40 -0800815
Nicolas "Pixel" Noble09121792016-01-30 09:01:53 +0100816 shared_c: pc_c pc_c_unsecure cache.mk pc_c_zookeeper\
Craig Tiller841c8802015-09-10 13:06:37 -0700817 % for lib in libs:
818 % if lib.build == 'all' and lib.language == 'c' and not lib.get('external_deps', None):
Nicolas "Pixel" Noblec4e57e32016-01-30 21:05:35 +0100819 $(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)${lib.name}$(SHARED_VERSION).$(SHARED_EXT)\
Craig Tiller841c8802015-09-10 13:06:37 -0700820 % endif
821 % endfor
822 shared_zookeeper_libs
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800823
Craig Tiller841c8802015-09-10 13:06:37 -0700824 shared_cxx: pc_cxx pc_cxx_unsecure cache.mk\
825 % for lib in libs:
826 % if lib.build == 'all' and lib.language == 'c++':
Nicolas "Pixel" Noblec4e57e32016-01-30 21:05:35 +0100827 $(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)${lib.name}$(SHARED_VERSION).$(SHARED_EXT)\
Craig Tiller841c8802015-09-10 13:06:37 -0700828 % endif
829 % endfor
nnoble29e1d292014-12-01 10:27:40 -0800830
831
Craig Tiller841c8802015-09-10 13:06:37 -0700832 shared_csharp: shared_c \
833 % for lib in libs:
834 % if lib.build == 'all' and lib.language == 'csharp':
Nicolas "Pixel" Noblec4e57e32016-01-30 21:05:35 +0100835 $(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)${lib.name}$(SHARED_VERSION).$(SHARED_EXT)\
Craig Tiller841c8802015-09-10 13:06:37 -0700836 % endif
837 % endfor
Jan Tattermusch2ec0b3e2015-02-18 15:03:12 -0800838
Craig Tiller841c8802015-09-10 13:06:37 -0700839 ifeq ($(HAS_ZOOKEEPER),true)
840 static_zookeeper_libs:\
841 % for lib in libs:
842 % if lib.build == 'all' and lib.language == 'c' and 'zookeeper' in lib.get('external_deps', []):
843 $(LIBDIR)/$(CONFIG)/lib${lib.name}.a\
844 % endif
845 % endfor
Hongwei Wanga8cc4392015-07-16 17:37:47 -0700846
Craig Tiller841c8802015-09-10 13:06:37 -0700847 shared_zookeeper_libs:\
848 % for lib in libs:
849 % if lib.build == 'all' and lib.language == 'c' and 'zookeeper' in lib.get('external_deps', []):
Nicolas "Pixel" Noblec4e57e32016-01-30 21:05:35 +0100850 $(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)${lib.name}$(SHARED_VERSION).$(SHARED_EXT)\
Craig Tiller841c8802015-09-10 13:06:37 -0700851 % endif
852 % endfor
Hongwei Wanga8cc4392015-07-16 17:37:47 -0700853
Craig Tiller841c8802015-09-10 13:06:37 -0700854 else
Hongwei Wanga8cc4392015-07-16 17:37:47 -0700855
Craig Tiller841c8802015-09-10 13:06:37 -0700856 static_zookeeper_libs:
Hongwei Wanga8cc4392015-07-16 17:37:47 -0700857
Craig Tiller841c8802015-09-10 13:06:37 -0700858 shared_zookeeper_libs:
Hongwei Wanga8cc4392015-07-16 17:37:47 -0700859
Craig Tiller841c8802015-09-10 13:06:37 -0700860 endif
Hongwei Wanga8cc4392015-07-16 17:37:47 -0700861
Craig Tiller841c8802015-09-10 13:06:37 -0700862 grpc_csharp_ext: shared_csharp
Jan Tattermusch2ec0b3e2015-02-18 15:03:12 -0800863
Craig Tiller841c8802015-09-10 13:06:37 -0700864 plugins: $(PROTOC_PLUGINS)
Nicolas "Pixel" Noble522d7122015-02-19 01:28:02 +0100865
Craig Tiller841c8802015-09-10 13:06:37 -0700866 privatelibs: privatelibs_c privatelibs_cxx
nnoble29e1d292014-12-01 10:27:40 -0800867
Craig Tiller841c8802015-09-10 13:06:37 -0700868 privatelibs_c: \
869 % for lib in libs:
Craig Tiller0fe5ee72015-12-22 12:50:36 -0800870 % 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 -0700871 $(LIBDIR)/$(CONFIG)/lib${lib.name}.a\
872 % endif
873 % endfor
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800874
Craig Tiller841c8802015-09-10 13:06:37 -0700875 pc_c: $(LIBDIR)/$(CONFIG)/pkgconfig/grpc.pc
murgatroid998faab232015-06-30 17:24:21 -0700876
Craig Tiller841c8802015-09-10 13:06:37 -0700877 pc_c_unsecure: $(LIBDIR)/$(CONFIG)/pkgconfig/grpc_unsecure.pc
murgatroid998faab232015-06-30 17:24:21 -0700878
Craig Tiller841c8802015-09-10 13:06:37 -0700879 ifeq ($(HAS_ZOOKEEPER),true)
880 pc_c_zookeeper: $(LIBDIR)/$(CONFIG)/pkgconfig/grpc_zookeeper.pc
881 else
882 pc_c_zookeeper:
883 endif
Hongwei Wanga3780a82015-07-17 15:27:18 -0700884
Craig Tiller841c8802015-09-10 13:06:37 -0700885 pc_cxx: $(LIBDIR)/$(CONFIG)/pkgconfig/grpc++.pc
murgatroid998faab232015-06-30 17:24:21 -0700886
Craig Tiller841c8802015-09-10 13:06:37 -0700887 pc_cxx_unsecure: $(LIBDIR)/$(CONFIG)/pkgconfig/grpc++_unsecure.pc
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800888
Craig Tiller841c8802015-09-10 13:06:37 -0700889 privatelibs_cxx: \
890 % for lib in libs:
891 % if lib.build == 'private' and lib.language == 'c++' and not lib.get('external_deps', None):
892 $(LIBDIR)/$(CONFIG)/lib${lib.name}.a\
893 % endif
894 % endfor
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800895
896
Craig Tiller841c8802015-09-10 13:06:37 -0700897 ifeq ($(HAS_ZOOKEEPER),true)
898 privatelibs_zookeeper: \
899 % for lib in libs:
900 % if lib.build == 'private' and lib.language == 'c++' and zookeeper in lib.get('external_deps', []):
901 $(LIBDIR)/$(CONFIG)/lib${lib.name}.a\
902 % endif
903 % endfor
Hongwei Wang8e04d412015-07-31 15:12:51 -0700904
Craig Tiller841c8802015-09-10 13:06:37 -0700905 else
906 privatelibs_zookeeper:
907 endif
Hongwei Wang8e04d412015-07-31 15:12:51 -0700908
909
Craig Tiller841c8802015-09-10 13:06:37 -0700910 buildtests: buildtests_c buildtests_cxx buildtests_zookeeper
nnoble29e1d292014-12-01 10:27:40 -0800911
Craig Tiller3824b6e2015-12-09 11:19:59 -0800912 buildtests_c: privatelibs_c <%text>\</%text>
Craig Tiller841c8802015-09-10 13:06:37 -0700913 % for tgt in targets:
914 % if tgt.build == 'test' and not tgt.language == 'c++' and not tgt.get('external_deps', None):
Craig Tiller3824b6e2015-12-09 11:19:59 -0800915 $(BINDIR)/$(CONFIG)/${tgt.name} <%text>\</%text>
Craig Tiller841c8802015-09-10 13:06:37 -0700916 % endif
917 % endfor
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800918
919
Craig Tiller3824b6e2015-12-09 11:19:59 -0800920 buildtests_cxx: buildtests_zookeeper privatelibs_cxx <%text>\</%text>
Craig Tiller841c8802015-09-10 13:06:37 -0700921 % for tgt in targets:
922 % if tgt.build == 'test' and tgt.language == 'c++' and not tgt.get('external_deps', None):
Craig Tiller3824b6e2015-12-09 11:19:59 -0800923 $(BINDIR)/$(CONFIG)/${tgt.name} <%text>\</%text>
Craig Tiller841c8802015-09-10 13:06:37 -0700924 % endif
925 % endfor
nnoble29e1d292014-12-01 10:27:40 -0800926
927
Craig Tiller841c8802015-09-10 13:06:37 -0700928 ifeq ($(HAS_ZOOKEEPER),true)
Craig Tiller3824b6e2015-12-09 11:19:59 -0800929 buildtests_zookeeper: privatelibs_zookeeper <%text>\</%text>
Craig Tiller841c8802015-09-10 13:06:37 -0700930 % for tgt in targets:
931 % if tgt.build == 'test' and tgt.language == 'c++' and 'zookeeper' in tgt.get('external_deps', []):
Craig Tiller3824b6e2015-12-09 11:19:59 -0800932 $(BINDIR)/$(CONFIG)/${tgt.name} <%text>\</%text>
Craig Tiller841c8802015-09-10 13:06:37 -0700933 % endif
934 % endfor
nnoble29e1d292014-12-01 10:27:40 -0800935
Craig Tiller841c8802015-09-10 13:06:37 -0700936 else
937 buildtests_zookeeper:
938 endif
Hongwei Wang8e04d412015-07-31 15:12:51 -0700939
940
Craig Tiller841c8802015-09-10 13:06:37 -0700941 test: test_c test_cxx test_zookeeper
Hongwei Wang8e04d412015-07-31 15:12:51 -0700942
Craig Tiller841c8802015-09-10 13:06:37 -0700943 flaky_test: flaky_test_c flaky_test_cxx flaky_test_zookeeper
Nicolas "Pixel" Noble4251d562015-05-22 19:43:39 +0200944
Craig Tiller841c8802015-09-10 13:06:37 -0700945 test_c: buildtests_c
946 % for tgt in targets:
947 % 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):
948 $(E) "[RUN] Testing ${tgt.name}"
949 $(Q) $(BINDIR)/$(CONFIG)/${tgt.name} || ( echo test ${tgt.name} failed ; exit 1 )
950 % endif
951 % endfor
Nicolas "Pixel" Noble4251d562015-05-22 19:43:39 +0200952
953
Craig Tiller841c8802015-09-10 13:06:37 -0700954 flaky_test_c: buildtests_c
955 % for tgt in targets:
956 % 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):
957 $(E) "[RUN] Testing ${tgt.name}"
958 $(Q) $(BINDIR)/$(CONFIG)/${tgt.name} || ( echo test ${tgt.name} failed ; exit 1 )
959 % endif
960 % endfor
nnoble29e1d292014-12-01 10:27:40 -0800961
962
Craig Tiller841c8802015-09-10 13:06:37 -0700963 test_cxx: test_zookeeper buildtests_cxx
964 % for tgt in targets:
965 % 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):
966 $(E) "[RUN] Testing ${tgt.name}"
967 $(Q) $(BINDIR)/$(CONFIG)/${tgt.name} || ( echo test ${tgt.name} failed ; exit 1 )
968 % endif
969 % endfor
Nicolas "Pixel" Noble4251d562015-05-22 19:43:39 +0200970
971
Craig Tiller841c8802015-09-10 13:06:37 -0700972 flaky_test_cxx: buildtests_cxx
973 % for tgt in targets:
974 % 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):
975 $(E) "[RUN] Testing ${tgt.name}"
976 $(Q) $(BINDIR)/$(CONFIG)/${tgt.name} || ( echo test ${tgt.name} failed ; exit 1 )
977 % endif
978 % endfor
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800979
980
Craig Tiller841c8802015-09-10 13:06:37 -0700981 ifeq ($(HAS_ZOOKEEPER),true)
982 test_zookeeper: buildtests_zookeeper
983 % for tgt in targets:
984 % 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', []):
985 $(E) "[RUN] Testing ${tgt.name}"
986 $(Q) $(BINDIR)/$(CONFIG)/${tgt.name} || ( echo test ${tgt.name} failed ; exit 1 )
987 % endif
988 % endfor
Hongwei Wang8e04d412015-07-31 15:12:51 -0700989
990
Craig Tiller841c8802015-09-10 13:06:37 -0700991 flaky_test_zookeeper: buildtests_zookeeper
992 % for tgt in targets:
993 % 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', []):
994 $(E) "[RUN] Testing ${tgt.name}"
995 $(Q) $(BINDIR)/$(CONFIG)/${tgt.name} || ( echo test ${tgt.name} failed ; exit 1 )
996 % endif
997 % endfor
Hongwei Wang8e04d412015-07-31 15:12:51 -0700998
Craig Tiller841c8802015-09-10 13:06:37 -0700999 else
1000 test_zookeeper:
1001 flaky_test_zookeeper:
1002 endif
Hongwei Wang8e04d412015-07-31 15:12:51 -07001003
1004
Craig Tiller841c8802015-09-10 13:06:37 -07001005 test_python: static_c
1006 $(E) "[RUN] Testing python code"
1007 $(Q) tools/run_tests/run_tests.py -lpython -c$(CONFIG)
Nicolas "Pixel" Noble051a28f2015-03-17 22:54:54 +01001008
1009
Craig Tiller841c8802015-09-10 13:06:37 -07001010 tools: tools_c tools_cxx
Craig Tiller7552f0f2015-06-19 17:46:20 -07001011
1012
Craig Tiller841c8802015-09-10 13:06:37 -07001013 tools_c: privatelibs_c\
1014 % for tgt in targets:
1015 % if tgt.build == 'tool' and not tgt.language=='c++':
1016 $(BINDIR)/$(CONFIG)/${tgt.name}\
1017 % endif
1018 % endfor
Craig Tiller7552f0f2015-06-19 17:46:20 -07001019
1020
Craig Tiller841c8802015-09-10 13:06:37 -07001021 tools_cxx: privatelibs_cxx\
1022 % for tgt in targets:
1023 % if tgt.build == 'tool' and tgt.language=='c++':
1024 $(BINDIR)/$(CONFIG)/${tgt.name}\
1025 % endif
1026 % endfor
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001027
1028
Craig Tiller841c8802015-09-10 13:06:37 -07001029 buildbenchmarks: privatelibs\
1030 % for tgt in targets:
1031 % if tgt.build == 'benchmark':
1032 $(BINDIR)/$(CONFIG)/${tgt.name}\
1033 % endif
1034 % endfor
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001035
1036
Craig Tiller841c8802015-09-10 13:06:37 -07001037 benchmarks: buildbenchmarks
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001038
Craig Tiller841c8802015-09-10 13:06:37 -07001039 strip: strip-static strip-shared
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001040
Craig Tiller841c8802015-09-10 13:06:37 -07001041 strip-static: strip-static_c strip-static_cxx
nnoble20e2e3f2014-12-16 15:37:57 -08001042
Craig Tiller841c8802015-09-10 13:06:37 -07001043 strip-shared: strip-shared_c strip-shared_cxx
nnoble20e2e3f2014-12-16 15:37:57 -08001044
Nicolas Noble047b7272015-01-16 13:55:05 -08001045
Craig Tiller841c8802015-09-10 13:06:37 -07001046 # TODO(nnoble): the strip target is stripping in-place, instead
1047 # of copying files in a temporary folder.
1048 # This prevents proper debugging after running make install.
Nicolas Noble047b7272015-01-16 13:55:05 -08001049
Craig Tiller841c8802015-09-10 13:06:37 -07001050 strip-static_c: static_c
1051 ifeq ($(CONFIG),opt)
1052 % for lib in libs:
1053 % if lib.language == "c":
1054 % if lib.build == "all":
1055 % if not lib.get('external_deps', None):
1056 $(E) "[STRIP] Stripping lib${lib.name}.a"
1057 $(Q) $(STRIP) $(LIBDIR)/$(CONFIG)/lib${lib.name}.a
1058 % endif
1059 % endif
1060 % endif
1061 % endfor
1062 ifeq ($(HAS_ZOOKEEPER),true)
1063 % for lib in libs:
1064 % if lib.language == "c":
1065 % if lib.build == "all":
1066 % if 'zookeeper' in lib.get('external_deps', []):
1067 $(E) "[STRIP] Stripping lib${lib.name}.a"
1068 $(Q) $(STRIP) $(LIBDIR)/$(CONFIG)/lib${lib.name}.a
1069 % endif
1070 % endif
1071 % endif
1072 % endfor
1073 endif
1074 endif
nnoble85a49262014-12-08 18:14:03 -08001075
Craig Tiller841c8802015-09-10 13:06:37 -07001076 strip-static_cxx: static_cxx
1077 ifeq ($(CONFIG),opt)
1078 % for lib in libs:
1079 % if lib.language == "c++":
1080 % if lib.build == "all":
1081 $(E) "[STRIP] Stripping lib${lib.name}.a"
1082 $(Q) $(STRIP) $(LIBDIR)/$(CONFIG)/lib${lib.name}.a
1083 % endif
1084 % endif
1085 % endfor
1086 endif
Nicolas "Pixel" Noble4ef9b862015-08-14 19:35:24 +02001087
Craig Tiller841c8802015-09-10 13:06:37 -07001088 strip-shared_c: shared_c
1089 ifeq ($(CONFIG),opt)
1090 % for lib in libs:
1091 % if lib.language == "c":
1092 % if lib.build == "all":
1093 % if not lib.get('external_deps', None):
Nicolas "Pixel" Noblec4e57e32016-01-30 21:05:35 +01001094 $(E) "[STRIP] Stripping $(SHARED_PREFIX)${lib.name}$(SHARED_VERSION).$(SHARED_EXT)"
1095 $(Q) $(STRIP) $(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)${lib.name}$(SHARED_VERSION).$(SHARED_EXT)
Craig Tiller841c8802015-09-10 13:06:37 -07001096 % endif
1097 % endif
1098 % endif
1099 % endfor
1100 ifeq ($(HAS_ZOOKEEPER),true)
1101 % for lib in libs:
1102 % if lib.language == "c":
1103 % if lib.build == "all":
1104 % if 'zookeeper' in lib.get('external_deps', []):
Nicolas "Pixel" Noblec4e57e32016-01-30 21:05:35 +01001105 $(E) "[STRIP] Stripping $(SHARED_PREFIX)${lib.name}$(SHARED_VERSION).$(SHARED_EXT)"
1106 $(Q) $(STRIP) $(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)${lib.name}$(SHARED_VERSION).$(SHARED_EXT)
Craig Tiller841c8802015-09-10 13:06:37 -07001107 % endif
1108 % endif
1109 % endif
1110 % endfor
1111 endif
1112 endif
nnoble85a49262014-12-08 18:14:03 -08001113
Craig Tiller841c8802015-09-10 13:06:37 -07001114 strip-shared_cxx: shared_cxx
1115 ifeq ($(CONFIG),opt)
1116 % for lib in libs:
1117 % if lib.language == "c++":
1118 % if lib.build == "all":
Nicolas "Pixel" Noblec4e57e32016-01-30 21:05:35 +01001119 $(E) "[STRIP] Stripping $(SHARED_PREFIX)${lib.name}$(SHARED_VERSION).$(SHARED_EXT)"
1120 $(Q) $(STRIP) $(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)${lib.name}$(SHARED_VERSION).$(SHARED_EXT)
Craig Tiller841c8802015-09-10 13:06:37 -07001121 % endif
1122 % endif
1123 % endfor
1124 endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001125
Craig Tiller841c8802015-09-10 13:06:37 -07001126 strip-shared_csharp: shared_csharp
1127 ifeq ($(CONFIG),opt)
1128 % for lib in libs:
1129 % if lib.language == "csharp":
1130 % if lib.build == "all":
Nicolas "Pixel" Noblec4e57e32016-01-30 21:05:35 +01001131 $(E) "[STRIP] Stripping $(SHARED_PREFIX)${lib.name}$(SHARED_VERSION).$(SHARED_EXT)"
1132 $(Q) $(STRIP) $(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)${lib.name}$(SHARED_VERSION).$(SHARED_EXT)
Craig Tiller841c8802015-09-10 13:06:37 -07001133 % endif
1134 % endif
1135 % endfor
1136 endif
Jan Tattermusch2ec0b3e2015-02-18 15:03:12 -08001137
Craig Tiller841c8802015-09-10 13:06:37 -07001138 cache.mk::
1139 $(E) "[MAKE] Generating $@"
1140 $(Q) echo "$(CACHE_MK)" | tr , '\n' >$@
murgatroid99aa521572015-07-10 14:49:12 -07001141
Craig Tiller841c8802015-09-10 13:06:37 -07001142 $(LIBDIR)/$(CONFIG)/pkgconfig/grpc.pc:
1143 $(E) "[MAKE] Generating $@"
1144 $(Q) mkdir -p $(@D)
1145 $(Q) echo "$(GRPC_PC_FILE)" | tr , '\n' >$@
murgatroid998faab232015-06-30 17:24:21 -07001146
Craig Tiller841c8802015-09-10 13:06:37 -07001147 $(LIBDIR)/$(CONFIG)/pkgconfig/grpc_unsecure.pc:
1148 $(E) "[MAKE] Generating $@"
1149 $(Q) mkdir -p $(@D)
1150 $(Q) echo "$(GRPC_UNSECURE_PC_FILE)" | tr , '\n' >$@
murgatroid998faab232015-06-30 17:24:21 -07001151
Craig Tiller841c8802015-09-10 13:06:37 -07001152 $(LIBDIR)/$(CONFIG)/pkgconfig/grpc_zookeeper.pc:
1153 $(E) "[MAKE] Generating $@"
1154 $(Q) mkdir -p $(@D)
1155 $(Q) echo -e "$(GRPC_ZOOKEEPER_PC_FILE)" >$@
Hongwei Wanga8cc4392015-07-16 17:37:47 -07001156
Craig Tiller841c8802015-09-10 13:06:37 -07001157 $(LIBDIR)/$(CONFIG)/pkgconfig/grpc++.pc:
1158 $(E) "[MAKE] Generating $@"
1159 $(Q) mkdir -p $(@D)
1160 $(Q) echo "$(GRPCXX_PC_FILE)" | tr , '\n' >$@
murgatroid998faab232015-06-30 17:24:21 -07001161
Craig Tiller841c8802015-09-10 13:06:37 -07001162 $(LIBDIR)/$(CONFIG)/pkgconfig/grpc++_unsecure.pc:
1163 $(E) "[MAKE] Generating $@"
1164 $(Q) mkdir -p $(@D)
1165 $(Q) echo "$(GRPCXX_UNSECURE_PC_FILE)" | tr , '\n' >$@
murgatroid998faab232015-06-30 17:24:21 -07001166
Craig Tiller841c8802015-09-10 13:06:37 -07001167 % for p in protos:
1168 ifeq ($(NO_PROTOC),true)
1169 $(GENDIR)/${p}.pb.cc: protoc_dep_error
1170 $(GENDIR)/${p}.grpc.pb.cc: protoc_dep_error
1171 else
Craig Tiller1b4e3302015-12-17 16:35:00 -08001172 $(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 -07001173 $(E) "[PROTOC] Generating protobuf CC file from $<"
1174 $(Q) mkdir -p `dirname $@`
1175 $(Q) $(PROTOC) --cpp_out=$(GENDIR) $<
Nicolas "Pixel" Noble0caebbf2015-04-09 23:08:51 +02001176
Craig Tiller1b4e3302015-12-17 16:35:00 -08001177 $(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 -07001178 $(E) "[GRPC] Generating gRPC's protobuf service CC file from $<"
1179 $(Q) mkdir -p `dirname $@`
1180 $(Q) $(PROTOC) --grpc_out=$(GENDIR) --plugin=protoc-gen-grpc=$(BINDIR)/$(CONFIG)/grpc_cpp_plugin $<
1181 endif
nnoble72309c62014-12-12 11:42:26 -08001182
Craig Tiller841c8802015-09-10 13:06:37 -07001183 % endfor
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001184
Craig Tiller841c8802015-09-10 13:06:37 -07001185 ifeq ($(CONFIG),stapprof)
1186 src/core/profiling/stap_timers.c: $(GENDIR)/src/core/profiling/stap_probes.h
1187 ifeq ($(HAS_SYSTEMTAP),true)
1188 $(GENDIR)/src/core/profiling/stap_probes.h: src/core/profiling/stap_probes.d
1189 $(E) "[DTRACE] Compiling $<"
1190 $(Q) mkdir -p `dirname $@`
1191 $(Q) $(DTRACE) -C -h -s $< -o $@
1192 else
1193 $(GENDIR)/src/core/profiling/stap_probes.h: systemtap_dep_error stop
1194 endif
1195 endif
David Garcia Quintas611b7362015-04-27 15:49:31 -07001196
Craig Tiller841c8802015-09-10 13:06:37 -07001197 $(OBJDIR)/$(CONFIG)/%.o : %.c
1198 $(E) "[C] Compiling $<"
1199 $(Q) mkdir -p `dirname $@`
Nicolas "Pixel" Noble45000342016-01-28 05:04:45 +01001200 $(Q) $(CC) $(CPPFLAGS) $(CFLAGS) -MMD -MF $(addsuffix .dep, $(basename $@)) -c -o $@ $<
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001201
Craig Tiller841c8802015-09-10 13:06:37 -07001202 $(OBJDIR)/$(CONFIG)/%.o : $(GENDIR)/%.pb.cc
1203 $(E) "[CXX] Compiling $<"
1204 $(Q) mkdir -p `dirname $@`
Nicolas "Pixel" Noble45000342016-01-28 05:04:45 +01001205 $(Q) $(CXX) $(CPPFLAGS) $(CXXFLAGS) -MMD -MF $(addsuffix .dep, $(basename $@)) -c -o $@ $<
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001206
Craig Tiller841c8802015-09-10 13:06:37 -07001207 $(OBJDIR)/$(CONFIG)/src/compiler/%.o : src/compiler/%.cc
1208 $(E) "[HOSTCXX] Compiling $<"
1209 $(Q) mkdir -p `dirname $@`
1210 $(Q) $(HOST_CXX) $(HOST_CXXFLAGS) $(HOST_CPPFLAGS) -MMD -MF $(addsuffix .dep, $(basename $@)) -c -o $@ $<
nnoble72309c62014-12-12 11:42:26 -08001211
Craig Tiller841c8802015-09-10 13:06:37 -07001212 $(OBJDIR)/$(CONFIG)/%.o : %.cc
1213 $(E) "[CXX] Compiling $<"
1214 $(Q) mkdir -p `dirname $@`
Nicolas "Pixel" Noble45000342016-01-28 05:04:45 +01001215 $(Q) $(CXX) $(CPPFLAGS) $(CXXFLAGS) -MMD -MF $(addsuffix .dep, $(basename $@)) -c -o $@ $<
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001216
Craig Tiller841c8802015-09-10 13:06:37 -07001217 install: install_c install_cxx install-plugins install-certs verify-install
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001218
Craig Tiller841c8802015-09-10 13:06:37 -07001219 install_c: install-headers_c install-static_c install-shared_c
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001220
Craig Tiller841c8802015-09-10 13:06:37 -07001221 install_cxx: install-headers_cxx install-static_cxx install-shared_cxx
nnoble85a49262014-12-08 18:14:03 -08001222
Craig Tiller841c8802015-09-10 13:06:37 -07001223 install_csharp: install-shared_csharp install_c
Jan Tattermusch2ec0b3e2015-02-18 15:03:12 -08001224
Craig Tiller841c8802015-09-10 13:06:37 -07001225 install_grpc_csharp_ext: install_csharp
Jan Tattermusch2ec0b3e2015-02-18 15:03:12 -08001226
Craig Tiller841c8802015-09-10 13:06:37 -07001227 install-headers: install-headers_c install-headers_cxx
nnoble85a49262014-12-08 18:14:03 -08001228
Craig Tiller841c8802015-09-10 13:06:37 -07001229 install-headers_c:
1230 $(E) "[INSTALL] Installing public C headers"
1231 $(Q) $(foreach h, $(PUBLIC_HEADERS_C), $(INSTALL) -d $(prefix)/$(dir $(h)) && ) exit 0 || exit 1
1232 $(Q) $(foreach h, $(PUBLIC_HEADERS_C), $(INSTALL) $(h) $(prefix)/$(h) && ) exit 0 || exit 1
nnoble85a49262014-12-08 18:14:03 -08001233
Craig Tiller841c8802015-09-10 13:06:37 -07001234 install-headers_cxx:
1235 $(E) "[INSTALL] Installing public C++ headers"
1236 $(Q) $(foreach h, $(PUBLIC_HEADERS_CXX), $(INSTALL) -d $(prefix)/$(dir $(h)) && ) exit 0 || exit 1
1237 $(Q) $(foreach h, $(PUBLIC_HEADERS_CXX), $(INSTALL) $(h) $(prefix)/$(h) && ) exit 0 || exit 1
nnoble85a49262014-12-08 18:14:03 -08001238
Craig Tiller841c8802015-09-10 13:06:37 -07001239 install-static: install-static_c install-static_cxx
nnoble85a49262014-12-08 18:14:03 -08001240
Craig Tiller841c8802015-09-10 13:06:37 -07001241 install-static_c: static_c strip-static_c install-pkg-config_c
1242 % for lib in libs:
1243 % if lib.language == "c":
1244 % if lib.build == "all":
1245 % if not lib.get('external_deps', None):
1246 $(E) "[INSTALL] Installing lib${lib.name}.a"
1247 $(Q) $(INSTALL) -d $(prefix)/lib
1248 $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/lib${lib.name}.a $(prefix)/lib/lib${lib.name}.a
1249 % endif
1250 % endif
1251 % endif
1252 % endfor
1253 ifeq ($(HAS_ZOOKEEPER),true)
1254 % for lib in libs:
1255 % if lib.language == "c":
1256 % if lib.build == "all":
1257 % if 'zookeeper' in lib.get('external_deps', []):
1258 $(E) "[INSTALL] Installing lib${lib.name}.a"
1259 $(Q) $(INSTALL) -d $(prefix)/lib
1260 $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/lib${lib.name}.a $(prefix)/lib/lib${lib.name}.a
1261 % endif
1262 % endif
1263 % endif
1264 % endfor
1265 endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001266
Craig Tiller841c8802015-09-10 13:06:37 -07001267 install-static_cxx: static_cxx strip-static_cxx install-pkg-config_cxx
1268 % for lib in libs:
1269 % if lib.language == "c++":
1270 % if lib.build == "all":
1271 $(E) "[INSTALL] Installing lib${lib.name}.a"
1272 $(Q) $(INSTALL) -d $(prefix)/lib
1273 $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/lib${lib.name}.a $(prefix)/lib/lib${lib.name}.a
1274 % endif
1275 % endif
1276 % endfor
nnoble85a49262014-12-08 18:14:03 -08001277
Craig Tiller841c8802015-09-10 13:06:37 -07001278 <%def name="install_shared(lang_filter)">\
1279 % for lib in libs:
1280 % if lib.language == lang_filter:
1281 % if lib.build == "all":
1282 % if not lib.get('external_deps', None):
Nicolas "Pixel" Noblec4e57e32016-01-30 21:05:35 +01001283 $(E) "[INSTALL] Installing $(SHARED_PREFIX)${lib.name}$(SHARED_VERSION).$(SHARED_EXT)"
1284 $(Q) $(INSTALL) -d $(prefix)/lib
1285 $(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 -07001286 ifeq ($(SYSTEM),MINGW32)
Craig Tiller841c8802015-09-10 13:06:37 -07001287 $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/lib${lib.name}-imp.a $(prefix)/lib/lib${lib.name}-imp.a
Nicolas "Pixel" Noblec4e57e32016-01-30 21:05:35 +01001288 else ifneq ($(SYSTEM),Darwin)
Craig Tillerf008f062016-02-08 12:48:03 -08001289 $(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 +01001290 $(Q) ln -sf $(SHARED_PREFIX)${lib.name}$(SHARED_VERSION).$(SHARED_EXT) $(prefix)/lib/lib${lib.name}.so
Craig Tiller841c8802015-09-10 13:06:37 -07001291 endif
1292 % endif
1293 % endif
1294 % endif
1295 % endfor
1296 ifeq ($(HAS_ZOOKEEPER),true)
1297 % for lib in libs:
1298 % if lib.language == lang_filter:
1299 % if lib.build == "all":
1300 % if 'zookeeper' in lib.get('external_deps', []):
Nicolas "Pixel" Noblec4e57e32016-01-30 21:05:35 +01001301 $(E) "[INSTALL] Installing $(SHARED_PREFIX)${lib.name}$(SHARED_VERSION).$(SHARED_EXT)"
1302 $(Q) $(INSTALL) -d $(prefix)/lib
1303 $(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 -07001304 ifeq ($(SYSTEM),MINGW32)
Craig Tiller841c8802015-09-10 13:06:37 -07001305 $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/lib${lib.name}-imp.a $(prefix)/lib/lib${lib.name}-imp.a
Nicolas "Pixel" Noblec4e57e32016-01-30 21:05:35 +01001306 else ifneq ($(SYSTEM),Darwin)
Craig Tillerf008f062016-02-08 12:48:03 -08001307 $(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 +01001308 $(Q) ln -sf $(SHARED_PREFIX)${lib.name}$(SHARED_VERSION).$(SHARED_EXT) $(prefix)/lib/lib${lib.name}.so
Craig Tiller841c8802015-09-10 13:06:37 -07001309 endif
1310 % endif
1311 % endif
1312 % endif
1313 % endfor
1314 endif
1315 ifneq ($(SYSTEM),MINGW32)
1316 ifneq ($(SYSTEM),Darwin)
1317 $(Q) ldconfig || true
1318 endif
1319 endif
1320 </%def>
nnoble85a49262014-12-08 18:14:03 -08001321
Craig Tiller841c8802015-09-10 13:06:37 -07001322 install-shared_c: shared_c strip-shared_c install-pkg-config_c
1323 ${install_shared("c")}
Nicolas "Pixel" Noble522d7122015-02-19 01:28:02 +01001324
Craig Tiller841c8802015-09-10 13:06:37 -07001325 install-shared_cxx: shared_cxx strip-shared_cxx install-shared_c install-pkg-config_cxx
1326 ${install_shared("c++")}
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001327
Craig Tiller841c8802015-09-10 13:06:37 -07001328 install-shared_csharp: shared_csharp strip-shared_csharp
1329 ${install_shared("csharp")}
Nicolas "Pixel" Noble522d7122015-02-19 01:28:02 +01001330
Craig Tiller841c8802015-09-10 13:06:37 -07001331 install-plugins: $(PROTOC_PLUGINS)
1332 ifeq ($(SYSTEM),MINGW32)
1333 $(Q) false
1334 else
1335 $(E) "[INSTALL] Installing grpc protoc plugins"
1336 % for tgt in targets:
1337 % if tgt.build == 'protoc':
1338 $(Q) $(INSTALL) -d $(prefix)/bin
1339 $(Q) $(INSTALL) $(BINDIR)/$(CONFIG)/${tgt.name} $(prefix)/bin/${tgt.name}
1340 % endif
1341 % endfor
1342 endif
Jan Tattermusch2ec0b3e2015-02-18 15:03:12 -08001343
yang-g2908d632016-02-04 09:46:51 -08001344 install-pkg-config_c: pc_c pc_c_unsecure pc_c_zookeeper
Craig Tiller841c8802015-09-10 13:06:37 -07001345 $(E) "[INSTALL] Installing C pkg-config files"
1346 $(Q) $(INSTALL) -d $(prefix)/lib/pkgconfig
Craig Tiller841c8802015-09-10 13:06:37 -07001347 $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/pkgconfig/grpc.pc $(prefix)/lib/pkgconfig/grpc.pc
1348 $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/pkgconfig/grpc_unsecure.pc $(prefix)/lib/pkgconfig/grpc_unsecure.pc
1349 ifeq ($(HAS_ZOOKEEPER),true)
1350 $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/pkgconfig/grpc_zookeeper.pc $(prefix)/lib/pkgconfig/grpc_zookeeper.pc
1351 endif
murgatroid998faab232015-06-30 17:24:21 -07001352
Craig Tiller841c8802015-09-10 13:06:37 -07001353 install-pkg-config_cxx: pc_cxx pc_cxx_unsecure
1354 $(E) "[INSTALL] Installing C++ pkg-config files"
1355 $(Q) $(INSTALL) -d $(prefix)/lib/pkgconfig
1356 $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/pkgconfig/grpc++.pc $(prefix)/lib/pkgconfig/grpc++.pc
1357 $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/pkgconfig/grpc++_unsecure.pc $(prefix)/lib/pkgconfig/grpc++_unsecure.pc
murgatroid998faab232015-06-30 17:24:21 -07001358
Craig Tiller841c8802015-09-10 13:06:37 -07001359 install-certs: etc/roots.pem
1360 $(E) "[INSTALL] Installing root certificates"
1361 $(Q) $(INSTALL) -d $(prefix)/share/grpc
1362 $(Q) $(INSTALL) etc/roots.pem $(prefix)/share/grpc/roots.pem
Nicolas "Pixel" Noble161ea232015-02-22 05:48:53 +01001363
Craig Tiller841c8802015-09-10 13:06:37 -07001364 verify-install:
1365 ifeq ($(INSTALL_OK),true)
1366 @echo "Your system looks ready to go."
1367 @echo
1368 else
1369 @echo "We couldn't find protoc 3.0.0+ installed on your system. While this"
1370 @echo "won't prevent grpc from working, you won't be able to compile"
1371 @echo "and run any meaningful code with it."
1372 @echo
1373 @echo
1374 @echo "Please download and install protobuf 3.0.0+ from:"
1375 @echo
1376 @echo " https://github.com/google/protobuf/releases"
1377 @echo
1378 @echo "Once you've done so, or if you think this message is in error,"
1379 @echo "you can re-run this check by doing:"
1380 @echo
1381 @echo " make verify-install"
1382 endif
Nicolas "Pixel" Noble98ab9982015-02-21 04:22:16 +01001383
Craig Tiller841c8802015-09-10 13:06:37 -07001384 clean:
1385 $(E) "[CLEAN] Cleaning build directories."
1386 $(Q) $(RM) -rf $(OBJDIR) $(LIBDIR) $(BINDIR) $(GENDIR) cache.mk
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001387
1388
Craig Tiller841c8802015-09-10 13:06:37 -07001389 # The various libraries
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001390
Craig Tiller841c8802015-09-10 13:06:37 -07001391 % for lib in libs:
1392 ${makelib(lib)}
1393 % endfor
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001394
1395
Craig Tiller841c8802015-09-10 13:06:37 -07001396 # All of the test targets, and protoc plugins
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001397
Craig Tiller841c8802015-09-10 13:06:37 -07001398 % for tgt in targets:
1399 ${maketarget(tgt)}
1400 % endfor
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001401
Craig Tiller841c8802015-09-10 13:06:37 -07001402 <%def name="makelib(lib)">
1403 LIB${lib.name.upper()}_SRC = \\
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001404
Craig Tiller841c8802015-09-10 13:06:37 -07001405 % for src in lib.src:
1406 ${proto_to_cc(src)} \\
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001407
Craig Tiller841c8802015-09-10 13:06:37 -07001408 % endfor
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001409
Craig Tiller841c8802015-09-10 13:06:37 -07001410 % if "public_headers" in lib:
1411 % if lib.language == "c++":
1412 PUBLIC_HEADERS_CXX += \\
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001413
Craig Tiller841c8802015-09-10 13:06:37 -07001414 % else:
1415 PUBLIC_HEADERS_C += \\
nnoble85a49262014-12-08 18:14:03 -08001416
Craig Tiller841c8802015-09-10 13:06:37 -07001417 % endif
1418 % for hdr in lib.public_headers:
1419 ${hdr} \\
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001420
Craig Tiller841c8802015-09-10 13:06:37 -07001421 % endfor
1422 % endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001423
Craig Tiller841c8802015-09-10 13:06:37 -07001424 LIB${lib.name.upper()}_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(LIB${lib.name.upper()}_SRC))))
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001425
Nicolas "Pixel" Noble51b1aee2016-01-28 01:14:58 +01001426 % if lib.get('defaults', None):
1427 % for name, value in defaults.get(lib.defaults).iteritems():
1428 $(LIB${lib.name.upper()}_OBJS): ${name} += ${value}
1429 % endfor
Craig Tiller0fe5ee72015-12-22 12:50:36 -08001430 % endif
1431
Craig Tiller841c8802015-09-10 13:06:37 -07001432 ## If the library requires OpenSSL, let's add some restrictions.
1433 % if lib.get('secure', 'check') == True or lib.get('secure', 'check') == 'check':
1434 ifeq ($(NO_SECURE),true)
nnoble69ac39f2014-12-12 15:43:38 -08001435
Craig Tiller841c8802015-09-10 13:06:37 -07001436 # You can't build secure libraries if you don't have OpenSSL.
Nicolas Noble047b7272015-01-16 13:55:05 -08001437
Craig Tiller841c8802015-09-10 13:06:37 -07001438 $(LIBDIR)/$(CONFIG)/lib${lib.name}.a: openssl_dep_error
nnoble69ac39f2014-12-12 15:43:38 -08001439
Craig Tiller841c8802015-09-10 13:06:37 -07001440 % if lib.build == "all":
Nicolas "Pixel" Noblec4e57e32016-01-30 21:05:35 +01001441 $(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)${lib.name}$(SHARED_VERSION).$(SHARED_EXT): openssl_dep_error
Craig Tiller841c8802015-09-10 13:06:37 -07001442 % endif
nnoble5b7f32a2014-12-22 08:12:44 -08001443
Craig Tiller841c8802015-09-10 13:06:37 -07001444 else
nnoble69ac39f2014-12-12 15:43:38 -08001445
Craig Tiller841c8802015-09-10 13:06:37 -07001446 % if lib.language == 'c++':
1447 ifeq ($(NO_PROTOBUF),true)
Nicolas Noble53830622015-02-12 16:56:38 -08001448
Craig Tiller841c8802015-09-10 13:06:37 -07001449 # 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 -08001450
Craig Tiller841c8802015-09-10 13:06:37 -07001451 $(LIBDIR)/$(CONFIG)/lib${lib.name}.a: protobuf_dep_error
Nicolas Noble53830622015-02-12 16:56:38 -08001452
Craig Tiller841c8802015-09-10 13:06:37 -07001453 % if lib.build == "all":
Nicolas "Pixel" Noblec4e57e32016-01-30 21:05:35 +01001454 $(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)${lib.name}$(SHARED_VERSION).$(SHARED_EXT): protobuf_dep_error
Craig Tiller841c8802015-09-10 13:06:37 -07001455 % endif
Nicolas Noble53830622015-02-12 16:56:38 -08001456
Craig Tiller841c8802015-09-10 13:06:37 -07001457 else
1458 % endif
Nicolas Noble53830622015-02-12 16:56:38 -08001459
Craig Tiller841c8802015-09-10 13:06:37 -07001460 $(LIBDIR)/$(CONFIG)/lib${lib.name}.a: $(ZLIB_DEP) $(OPENSSL_DEP)\
1461 ## The else here corresponds to the if secure earlier.
1462 % else:
1463 % if lib.language == 'c++':
1464 ifeq ($(NO_PROTOBUF),true)
Nicolas Noble53830622015-02-12 16:56:38 -08001465
Craig Tiller841c8802015-09-10 13:06:37 -07001466 # 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 -08001467
Craig Tiller841c8802015-09-10 13:06:37 -07001468 $(LIBDIR)/$(CONFIG)/lib${lib.name}.a: protobuf_dep_error
Nicolas Noble53830622015-02-12 16:56:38 -08001469
Craig Tiller841c8802015-09-10 13:06:37 -07001470 % if lib.build == "all":
Nicolas "Pixel" Noblec4e57e32016-01-30 21:05:35 +01001471 $(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)${lib.name}$(SHARED_VERSION).$(SHARED_EXT): protobuf_dep_error
Craig Tiller841c8802015-09-10 13:06:37 -07001472 % endif
Nicolas Noble53830622015-02-12 16:56:38 -08001473
Craig Tiller841c8802015-09-10 13:06:37 -07001474 else
Nicolas Noble53830622015-02-12 16:56:38 -08001475
Craig Tiller841c8802015-09-10 13:06:37 -07001476 % endif
Nicolas "Pixel" Nobled649c212016-01-27 20:27:30 +01001477 $(LIBDIR)/$(CONFIG)/lib${lib.name}.a: \
1478 % if lib.name != 'z':
1479 $(ZLIB_DEP) \
1480 % endif
Craig Tiller841c8802015-09-10 13:06:37 -07001481 % endif
1482 % if lib.language == 'c++':
1483 $(PROTOBUF_DEP)\
1484 % endif
Nicolas "Pixel" Noblef51a9012016-02-03 07:39:43 +01001485 $(LIB${lib.name.upper()}_OBJS) \
1486 % if lib.get('baselib', False):
1487 $(ZLIB_MERGE_OBJS) \
1488 % if lib.get('secure', 'check') == True:
1489 $(OPENSSL_MERGE_OBJS) \
1490 % endif
1491 % endif
1492
Craig Tiller841c8802015-09-10 13:06:37 -07001493 $(E) "[AR] Creating $@"
1494 $(Q) mkdir -p `dirname $@`
1495 $(Q) rm -f $(LIBDIR)/$(CONFIG)/lib${lib.name}.a
Nicolas "Pixel" Noblef51a9012016-02-03 07:39:43 +01001496 $(Q) $(AR) $(LIBDIR)/$(CONFIG)/lib${lib.name}.a $(LIB${lib.name.upper()}_OBJS) \
Craig Tiller841c8802015-09-10 13:06:37 -07001497 % if lib.get('baselib', False):
Nicolas "Pixel" Noblef51a9012016-02-03 07:39:43 +01001498 $(ZLIB_MERGE_OBJS) \
Craig Tiller841c8802015-09-10 13:06:37 -07001499 % if lib.get('secure', 'check') == True:
Nicolas "Pixel" Noblef51a9012016-02-03 07:39:43 +01001500 $(OPENSSL_MERGE_OBJS) \
Craig Tiller841c8802015-09-10 13:06:37 -07001501 % endif
1502 % endif
Nicolas "Pixel" Noblef51a9012016-02-03 07:39:43 +01001503
Craig Tiller841c8802015-09-10 13:06:37 -07001504 ifeq ($(SYSTEM),Darwin)
1505 $(Q) ranlib $(LIBDIR)/$(CONFIG)/lib${lib.name}.a
1506 endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001507
Craig Tiller841c8802015-09-10 13:06:37 -07001508 <%
Nicolas "Pixel" Noble010f1e72015-04-23 02:23:49 +02001509
Craig Tiller841c8802015-09-10 13:06:37 -07001510 if lib.language == 'c++':
1511 ld = '$(LDXX)'
1512 else:
1513 ld = '$(LD)'
nnoble5b7f32a2014-12-22 08:12:44 -08001514
Nicolas "Pixel" Noblec4e57e32016-01-30 21:05:35 +01001515 out_mingbase = '$(LIBDIR)/$(CONFIG)/' + lib.name + '$(SHARED_VERSION)'
1516 out_libbase = '$(LIBDIR)/$(CONFIG)/lib' + lib.name + '$(SHARED_VERSION)'
nnoble5b7f32a2014-12-22 08:12:44 -08001517
Craig Tiller841c8802015-09-10 13:06:37 -07001518 common = '$(LIB' + lib.name.upper() + '_OBJS) $(LDLIBS)'
nnoble5b7f32a2014-12-22 08:12:44 -08001519
Craig Tiller841c8802015-09-10 13:06:37 -07001520 libs = ''
1521 lib_deps = ' $(ZLIB_DEP)'
1522 mingw_libs = ''
1523 mingw_lib_deps = ' $(ZLIB_DEP)'
1524 if lib.language == 'c++':
1525 lib_deps += ' $(PROTOBUF_DEP)'
1526 mingw_lib_deps += ' $(PROTOBUF_DEP)'
Jan Tattermusch324140c2016-01-12 08:54:01 -08001527 if lib.get('deps_linkage', None) == 'static':
1528 for dep in lib.get('deps', []):
1529 lib_archive = '$(LIBDIR)/$(CONFIG)/lib' + dep + '.a'
1530 common = common + ' ' + lib_archive
1531 lib_deps = lib_deps + ' ' + lib_archive
1532 mingw_lib_deps = mingw_lib_deps + ' ' + lib_archive
1533 else:
1534 for dep in lib.get('deps', []):
1535 libs = libs + ' -l' + dep
1536 lib_deps = lib_deps + ' $(LIBDIR)/$(CONFIG)/lib' + dep + '.$(SHARED_EXT)'
1537 mingw_libs = mingw_libs + ' -l' + dep + '-imp'
1538 mingw_lib_deps = mingw_lib_deps + ' $(LIBDIR)/$(CONFIG)/' + dep + '.$(SHARED_EXT)'
nnoble5b7f32a2014-12-22 08:12:44 -08001539
Craig Tiller841c8802015-09-10 13:06:37 -07001540 security = lib.get('secure', 'check')
1541 if security == True:
1542 common = common + ' $(OPENSSL_MERGE_LIBS) $(LDLIBS_SECURE)'
Craig Tiller0fe5ee72015-12-22 12:50:36 -08001543 common = common + ' $(ZLIB_MERGE_LIBS)'
Nicolas "Pixel" Noblea7c162c2015-07-24 20:21:51 +02001544
Craig Tiller841c8802015-09-10 13:06:37 -07001545 if security in [True, 'check']:
1546 for src in lib.src:
1547 if not proto_re.match(src):
1548 sources_that_need_openssl.add(src)
1549 else:
1550 for src in lib.src:
1551 sources_that_don_t_need_openssl.add(src)
Nicolas "Pixel" Noble061690d2015-03-06 22:58:58 +01001552
Craig Tiller841c8802015-09-10 13:06:37 -07001553 if 'zookeeper' in lib.get('external_deps', []):
1554 libs = libs + ' -lzookeeper_mt'
Hongwei Wanga8cc4392015-07-16 17:37:47 -07001555
Craig Tiller841c8802015-09-10 13:06:37 -07001556 if lib.get('secure', 'check') == True or lib.get('secure', 'check') == 'check':
1557 lib_deps = lib_deps + ' $(OPENSSL_DEP)'
1558 mingw_lib_deps = mingw_lib_deps + ' $(OPENSSL_DEP)'
Nicolas "Pixel" Nobledda049c2015-02-21 00:39:32 +01001559
Craig Tiller841c8802015-09-10 13:06:37 -07001560 if lib.language == 'c++':
1561 common = common + ' $(LDLIBSXX) $(LDLIBS_PROTOBUF)'
Craig Tiller4bef7ce2016-02-02 08:38:43 -08001562
1563 ldflags = '$(LDFLAGS)'
1564 if lib.get('LDFLAGS', None):
1565 ldflags += ' ' + lib['LDFLAGS']
Craig Tiller841c8802015-09-10 13:06:37 -07001566 %>
nnoble5b7f32a2014-12-22 08:12:44 -08001567
Craig Tiller841c8802015-09-10 13:06:37 -07001568 % if lib.build == "all":
1569 ifeq ($(SYSTEM),MINGW32)
Nicolas "Pixel" Noblec4e57e32016-01-30 21:05:35 +01001570 ${out_mingbase}.$(SHARED_EXT): $(LIB${lib.name.upper()}_OBJS) ${mingw_lib_deps}
Craig Tiller841c8802015-09-10 13:06:37 -07001571 $(E) "[LD] Linking $@"
1572 $(Q) mkdir -p `dirname $@`
Nicolas "Pixel" Noble89d8ed12016-02-03 01:12:14 +01001573 $(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 -07001574 else
1575 ${out_libbase}.$(SHARED_EXT): $(LIB${lib.name.upper()}_OBJS) ${lib_deps}
1576 $(E) "[LD] Linking $@"
1577 $(Q) mkdir -p `dirname $@`
1578 ifeq ($(SYSTEM),Darwin)
Nicolas "Pixel" Noble89d8ed12016-02-03 01:12:14 +01001579 $(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 -07001580 else
Craig Tillerf008f062016-02-08 12:48:03 -08001581 $(Q) ${ld} ${ldflags} -L$(LIBDIR)/$(CONFIG) -shared -Wl,-soname,lib${lib.name}.so.${settings.core_version.major} -o ${out_libbase}.$(SHARED_EXT) ${common}${libs}
1582 $(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 +01001583 $(Q) ln -sf $(SHARED_PREFIX)${lib.name}$(SHARED_VERSION).$(SHARED_EXT) ${out_libbase}.so
Craig Tiller841c8802015-09-10 13:06:37 -07001584 endif
1585 endif
1586 % endif
1587 % if lib.get('secure', 'check') == True or lib.get('secure', 'check') == 'check':
1588 ## If the lib was secure, we have to close the Makefile's if that tested
1589 ## the presence of OpenSSL.
Nicolas Noble53830622015-02-12 16:56:38 -08001590
Craig Tiller841c8802015-09-10 13:06:37 -07001591 endif
1592 % endif
1593 % if lib.language == 'c++':
1594 ## If the lib was C++, we have to close the Makefile's if that tested
1595 ## the presence of protobuf 3.0.0+
nnoble69ac39f2014-12-12 15:43:38 -08001596
Craig Tiller841c8802015-09-10 13:06:37 -07001597 endif
1598 % endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001599
Craig Tiller841c8802015-09-10 13:06:37 -07001600 % if lib.get('secure', 'check') == True or lib.get('secure', 'check') == 'check':
1601 ifneq ($(NO_SECURE),true)
1602 % endif
1603 ifneq ($(NO_DEPS),true)
1604 -include $(LIB${lib.name.upper()}_OBJS:.o=.dep)
1605 endif
1606 % if lib.get('secure', 'check') == True or lib.get('secure', 'check') == 'check':
1607 endif
1608 % endif
1609 % for src in lib.src:
1610 % if not proto_re.match(src) and any(proto_re.match(src2) for src2 in lib.src):
1611 $(OBJDIR)/$(CONFIG)/${os.path.splitext(src)[0]}.o: ${' '.join(proto_to_cc(src2) for src2 in lib.src if proto_re.match(src2))}
1612 % endif
1613 % endfor
1614 </%def>
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001615
Craig Tiller841c8802015-09-10 13:06:37 -07001616 <%def name="maketarget(tgt)"><% has_no_sources = not tgt.src %>
1617 % if not has_no_sources:
1618 ${tgt.name.upper()}_SRC = \\
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001619
Craig Tiller841c8802015-09-10 13:06:37 -07001620 % for src in tgt.src:
1621 ${proto_to_cc(src)} \\
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001622
Craig Tiller841c8802015-09-10 13:06:37 -07001623 % endfor
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001624
Craig Tiller841c8802015-09-10 13:06:37 -07001625 ${tgt.name.upper()}_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(${tgt.name.upper()}_SRC))))
1626 % endif
1627 % if tgt.get('secure', 'check') == True or tgt.get('secure', 'check') == 'check':
1628 ifeq ($(NO_SECURE),true)
nnoble69ac39f2014-12-12 15:43:38 -08001629
Craig Tiller841c8802015-09-10 13:06:37 -07001630 # You can't build secure targets if you don't have OpenSSL.
Nicolas Noble047b7272015-01-16 13:55:05 -08001631
Craig Tiller841c8802015-09-10 13:06:37 -07001632 $(BINDIR)/$(CONFIG)/${tgt.name}: openssl_dep_error
nnoble69ac39f2014-12-12 15:43:38 -08001633
Craig Tiller841c8802015-09-10 13:06:37 -07001634 else
nnoble69ac39f2014-12-12 15:43:38 -08001635
Craig Tiller841c8802015-09-10 13:06:37 -07001636 % endif
Craig Tiller0fe5ee72015-12-22 12:50:36 -08001637
1638 % if tgt.boringssl:
1639 # boringssl needs an override to ensure that it does not include
1640 # system openssl headers regardless of other configuration
1641 # we do so here with a target specific variable assignment
1642 $(${tgt.name.upper()}_OBJS): CFLAGS := -Ithird_party/boringssl/include $(CFLAGS) -Wno-sign-conversion -Wno-conversion -Wno-unused-value
1643 $(${tgt.name.upper()}_OBJS): CXXFLAGS := -Ithird_party/boringssl/include $(CXXFLAGS)
1644 $(${tgt.name.upper()}_OBJS): CPPFLAGS += -DOPENSSL_NO_ASM -D_GNU_SOURCE
1645 % else:
1646 % endif
1647
Craig Tiller841c8802015-09-10 13:06:37 -07001648 ##
1649 ## We're not trying to add a dependency on building zlib and openssl here,
1650 ## as it's already done in the libraries. We're assuming that the build
1651 ## trickles down, and that a secure target requires a secure version of
1652 ## a library.
1653 ##
1654 ## That simplifies the codegen a bit, but prevents a fully defined Makefile.
1655 ## I can live with that.
1656 ##
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 ifeq ($(NO_PROTOBUF),true)
Nicolas Noble53830622015-02-12 16:56:38 -08001660
Craig Tiller841c8802015-09-10 13:06:37 -07001661 # 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 -08001662
Craig Tiller841c8802015-09-10 13:06:37 -07001663 $(BINDIR)/$(CONFIG)/${tgt.name}: protobuf_dep_error
Nicolas Noble53830622015-02-12 16:56:38 -08001664
Craig Tiller841c8802015-09-10 13:06:37 -07001665 else
Nicolas Noble53830622015-02-12 16:56:38 -08001666
Craig Tiller841c8802015-09-10 13:06:37 -07001667 $(BINDIR)/$(CONFIG)/${tgt.name}: \
1668 % if not has_no_sources:
1669 $(PROTOBUF_DEP) $(${tgt.name.upper()}_OBJS)\
1670 % endif
1671 % else:
1672 $(BINDIR)/$(CONFIG)/${tgt.name}: \
1673 % if not has_no_sources:
1674 $(${tgt.name.upper()}_OBJS)\
1675 % endif
1676 % endif
1677 % for dep in tgt.deps:
1678 $(LIBDIR)/$(CONFIG)/lib${dep}.a\
1679 % endfor
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001680
Craig Tiller0fe5ee72015-12-22 12:50:36 -08001681 % if tgt.language == "c++" or tgt.boringssl:
Craig Tiller841c8802015-09-10 13:06:37 -07001682 ## C++ targets specificies.
1683 % if tgt.build == 'protoc':
1684 $(E) "[HOSTLD] Linking $@"
1685 $(Q) mkdir -p `dirname $@`
1686 $(Q) $(HOST_LDXX) $(HOST_LDFLAGS) \
1687 % if not has_no_sources:
1688 $(${tgt.name.upper()}_OBJS)\
1689 % endif
1690 % else:
1691 $(E) "[LD] Linking $@"
1692 $(Q) mkdir -p `dirname $@`
1693 $(Q) $(LDXX) $(LDFLAGS) \
1694 % if not has_no_sources:
1695 $(${tgt.name.upper()}_OBJS)\
1696 % endif
1697 % endif
1698 % else:
1699 ## C-only targets specificities.
1700 $(E) "[LD] Linking $@"
1701 $(Q) mkdir -p `dirname $@`
1702 $(Q) $(LD) $(LDFLAGS) \
1703 % if not has_no_sources:
1704 $(${tgt.name.upper()}_OBJS)\
1705 % endif
1706 % endif
1707 % for dep in tgt.deps:
1708 $(LIBDIR)/$(CONFIG)/lib${dep}.a\
1709 % endfor
1710 % if 'zookeeper' in tgt.get('external_deps', []):
1711 -lzookeeper_mt\
1712 % endif
1713 % if tgt.language == "c++":
1714 % if tgt.build == 'protoc':
1715 $(HOST_LDLIBSXX) $(HOST_LDLIBS_PROTOC)\
1716 % else:
1717 $(LDLIBSXX) $(LDLIBS_PROTOBUF)\
1718 % endif
1719 % endif
1720 % if tgt.build == 'protoc':
1721 $(HOST_LDLIBS)\
1722 % else:
1723 $(LDLIBS)\
1724 % endif
1725 % if tgt.build == 'protoc':
1726 $(HOST_LDLIBS_PROTOC)\
1727 % elif tgt.get('secure', 'check') == True or tgt.get('secure', 'check') == 'check':
1728 $(LDLIBS_SECURE)\
1729 % endif
1730 % if tgt.language == 'c++' and tgt.build == 'test':
1731 $(GTEST_LIB)\
1732 % elif tgt.language == 'c++' and tgt.build == 'benchmark':
1733 $(GTEST_LIB)\
1734 % endif
1735 -o $(BINDIR)/$(CONFIG)/${tgt.name}
1736 % if tgt.build == 'protoc' or tgt.language == 'c++':
Nicolas Noble53830622015-02-12 16:56:38 -08001737
Craig Tiller841c8802015-09-10 13:06:37 -07001738 endif
1739 % endif
1740 % if tgt.get('secure', 'check') == True or tgt.get('secure', 'check') == 'check':
nnoble69ac39f2014-12-12 15:43:38 -08001741
Craig Tiller841c8802015-09-10 13:06:37 -07001742 endif
1743 % endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001744
Craig Tiller841c8802015-09-10 13:06:37 -07001745 % for src in tgt.src:
1746 $(OBJDIR)/$(CONFIG)/${os.path.splitext(src)[0]}.o: \
1747 % for dep in tgt.deps:
1748 $(LIBDIR)/$(CONFIG)/lib${dep}.a\
1749 % endfor
Craig Tillerf5371ef2015-01-12 16:40:18 -08001750
Craig Tillerab230452016-01-04 08:18:43 -08001751 % if tgt.language == 'c89':
1752 % for src in tgt.src:
Craig Tillerea21ca22016-01-04 12:34:29 -08001753 $(OBJDIR)/$(CONFIG)/${os.path.splitext(src)[0]}.o : ${src}
1754 $(E) "[C] Compiling $<"
1755 $(Q) mkdir -p `dirname $@`
Nicolas "Pixel" Noble45000342016-01-28 05:04:45 +01001756 $(Q) $(CC) $(CPPFLAGS) $(CFLAGS) -std=c89 -pedantic -MMD -MF $(addsuffix .dep, $(basename $@)) -c -o $@ $<
Craig Tillerab230452016-01-04 08:18:43 -08001757 % endfor
1758 % endif
1759
Craig Tiller841c8802015-09-10 13:06:37 -07001760 % endfor
1761 % if not has_no_sources:
1762 deps_${tgt.name}: $(${tgt.name.upper()}_OBJS:.o=.dep)
1763 % endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001764
Craig Tiller841c8802015-09-10 13:06:37 -07001765 % if not has_no_sources:
1766 % if tgt.get('secure', 'check') == True or tgt.get('secure', 'check') == 'check':
1767 ifneq ($(NO_SECURE),true)
1768 % endif
1769 ifneq ($(NO_DEPS),true)
1770 -include $(${tgt.name.upper()}_OBJS:.o=.dep)
1771 endif
1772 % if tgt.get('secure', 'check') == True or tgt.get('secure', 'check') == 'check':
1773 endif
1774 % endif
1775 % endif
Nicolas "Pixel" Noble472bb682015-11-03 19:09:01 +01001776 % for src in tgt.src:
1777 % if not proto_re.match(src) and any(proto_re.match(src2) for src2 in tgt.src):
1778 $(OBJDIR)/$(CONFIG)/${os.path.splitext(src)[0]}.o: ${' '.join(proto_to_cc(src2) for src2 in tgt.src if proto_re.match(src2))}
1779 % endif
1780 % endfor
Craig Tiller841c8802015-09-10 13:06:37 -07001781 </%def>
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001782
Craig Tiller841c8802015-09-10 13:06:37 -07001783 ifneq ($(OPENSSL_DEP),)
1784 # This is to ensure the embedded OpenSSL is built beforehand, properly
1785 # installing headers to their final destination on the drive. We need this
1786 # otherwise parallel compilation will fail if a source is compiled first.
1787 % for src in sorted(sources_that_need_openssl):
1788 % if src not in sources_that_don_t_need_openssl:
1789 ${src}: $(OPENSSL_DEP)
1790 % endif
1791 % endfor
1792 endif
Nicolas "Pixel" Noble010f1e72015-04-23 02:23:49 +02001793
Craig Tiller841c8802015-09-10 13:06:37 -07001794 .PHONY: all strip tools \
1795 dep_error openssl_dep_error openssl_dep_message git_update stop \
1796 buildtests buildtests_c buildtests_cxx \
1797 test test_c test_cxx \
1798 install install_c install_cxx \
1799 install-headers install-headers_c install-headers_cxx \
1800 install-shared install-shared_c install-shared_cxx \
1801 install-static install-static_c install-static_cxx \
1802 strip strip-shared strip-static \
1803 strip_c strip-shared_c strip-static_c \
1804 strip_cxx strip-shared_cxx strip-static_cxx \
1805 dep_c dep_cxx bins_dep_c bins_dep_cxx \
1806 clean