blob: a3d37804492c05efd5617746e2e556fb37198484 [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_)
60 ifeq ($(SYSTEM),)
61 SYSTEM = $(HOST_SYSTEM)
62 endif
63 ifeq ($(SYSTEM),MSYS)
64 SYSTEM = MINGW32
65 endif
66 ifeq ($(SYSTEM),MINGW64)
67 SYSTEM = MINGW32
68 endif
Craig Tiller96b49552015-01-21 16:29:01 -080069
70
Nicolas "Pixel" Noble6dad9b02015-09-23 18:32:26 +020071 MAKEFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST)))
Craig Tiller841c8802015-09-10 13:06:37 -070072 ifndef BUILDDIR
Nicolas "Pixel" Noble42b4c282015-09-17 23:57:08 +020073 BUILDDIR_ABSOLUTE = $(patsubst %/,%,$(dir $(MAKEFILE_PATH)))
74 else
75 BUILDDIR_ABSOLUTE = $(abspath $(BUILDDIR))
Craig Tiller841c8802015-09-10 13:06:37 -070076 endif
Craig Tiller61b910f2015-02-15 10:54:07 -080077
Craig Tiller841c8802015-09-10 13:06:37 -070078 HAS_GCC = $(shell which gcc > /dev/null 2> /dev/null && echo true || echo false)
79 HAS_CC = $(shell which cc > /dev/null 2> /dev/null && echo true || echo false)
80 HAS_CLANG = $(shell which clang > /dev/null 2> /dev/null && echo true || echo false)
Nicolas Noblef8681182015-03-18 14:25:44 -070081
Craig Tiller841c8802015-09-10 13:06:37 -070082 ifeq ($(HAS_CC),true)
83 DEFAULT_CC = cc
84 DEFAULT_CXX = c++
85 else
86 ifeq ($(HAS_GCC),true)
87 DEFAULT_CC = gcc
88 DEFAULT_CXX = g++
89 else
90 ifeq ($(HAS_CLANG),true)
91 DEFAULT_CC = clang
92 DEFAULT_CXX = clang++
93 else
94 DEFAULT_CC = no_c_compiler
95 DEFAULT_CXX = no_c++_compiler
96 endif
97 endif
98 endif
Nicolas Noblef8681182015-03-18 14:25:44 -070099
100
Nicolas "Pixel" Noble42b4c282015-09-17 23:57:08 +0200101 BINDIR = $(BUILDDIR_ABSOLUTE)/bins
102 OBJDIR = $(BUILDDIR_ABSOLUTE)/objs
103 LIBDIR = $(BUILDDIR_ABSOLUTE)/libs
104 GENDIR = $(BUILDDIR_ABSOLUTE)/gens
Craig Tiller61b910f2015-02-15 10:54:07 -0800105
Craig Tiller841c8802015-09-10 13:06:37 -0700106 # Configurations
ctiller8cfebb92015-01-06 15:02:12 -0800107
Craig Tillera0f85172016-01-20 15:56:06 -0800108 % for name, args in configs.iteritems():
109 VALID_CONFIG_${name} = 1
110 % if args.get('compile_the_world', False):
111 REQUIRE_CUSTOM_LIBRARIES_${name} = 1
112 % endif
Craig Tilleraff3d502016-01-20 15:59:31 -0800113 % for tool, default in [('CC', 'CC'), ('CXX', 'CXX'), ('LD', 'CC'), ('LDXX', 'CXX')]:
Craig Tillera0f85172016-01-20 15:56:06 -0800114 ${tool}_${name} = ${args.get(tool, '$(DEFAULT_%s)' % default)}
115 % endfor
116 % for arg in ['CFLAGS', 'CXXFLAGS', 'CPPFLAGS', 'LDFLAGS', 'DEFINES']:
117 % if args.get(arg, None) is not None:
118 ${arg}_${name} = ${args.get(arg)}
119 % endif
120 % endfor
121 % if args.get('timeout_multiplier', 1) != 1:
122 DEFINES_${name} += GRPC_TEST_SLOWDOWN_BUILD_FACTOR=${args.timeout_multiplier}
123 % endif
ctiller8cfebb92015-01-06 15:02:12 -0800124
Craig Tillera0f85172016-01-20 15:56:06 -0800125 % endfor
Craig Tiller699ba212015-01-13 17:02:20 -0800126
Nicolas Noble047b7272015-01-16 13:55:05 -0800127
Craig Tiller841c8802015-09-10 13:06:37 -0700128 # General settings.
129 # You may want to change these depending on your system.
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800130
Craig Tiller841c8802015-09-10 13:06:37 -0700131 prefix ?= /usr/local
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800132
Nicolas "Pixel" Noble1a8eb852016-01-26 22:33:19 +0100133 PROTOC ?= protoc
134 DTRACE ?= dtrace
Craig Tiller841c8802015-09-10 13:06:37 -0700135 CONFIG ?= opt
Nicolas "Pixel" Noblefba36bc2016-01-27 03:24:03 +0100136 # Doing X ?= Y is the same as:
137 # ifeq ($(origin X), undefined)
138 # X = Y
139 # endif
140 # but some variables, such as CC, CXX, LD or AR, have defaults.
141 # So instead of using ?= on them, we need to check their origin.
142 # See:
143 # https://www.gnu.org/software/make/manual/html_node/Implicit-Variables.html
144 # https://www.gnu.org/software/make/manual/html_node/Flavors.html#index-_003f_003d
145 # https://www.gnu.org/software/make/manual/html_node/Origin-Function.html
146 ifeq ($(origin CC), default)
147 CC = $(CC_$(CONFIG))
148 endif
149 ifeq ($(origin CXX), default)
150 CXX = $(CXX_$(CONFIG))
151 endif
152 ifeq ($(origin LD), default)
153 LD = $(LD_$(CONFIG))
154 endif
Nicolas "Pixel" Noble1a8eb852016-01-26 22:33:19 +0100155 LDXX ?= $(LDXX_$(CONFIG))
Nicolas "Pixel" Noblefba36bc2016-01-27 03:24:03 +0100156 ifeq ($(origin AR), default)
157 AR = ar
158 endif
Craig Tiller841c8802015-09-10 13:06:37 -0700159 ifeq ($(SYSTEM),Linux)
Nicolas "Pixel" Noble1a8eb852016-01-26 22:33:19 +0100160 STRIP ?= strip --strip-unneeded
Craig Tiller841c8802015-09-10 13:06:37 -0700161 else
162 ifeq ($(SYSTEM),Darwin)
Nicolas "Pixel" Noble1a8eb852016-01-26 22:33:19 +0100163 STRIP ?= strip -x
Craig Tiller841c8802015-09-10 13:06:37 -0700164 else
Nicolas "Pixel" Noble1a8eb852016-01-26 22:33:19 +0100165 STRIP ?= strip
Craig Tiller841c8802015-09-10 13:06:37 -0700166 endif
167 endif
Nicolas "Pixel" Noble1a8eb852016-01-26 22:33:19 +0100168 INSTALL ?= install
169 RM ?= rm -f
170 PKG_CONFIG ?= pkg-config
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800171
Craig Tiller841c8802015-09-10 13:06:37 -0700172 ifndef VALID_CONFIG_$(CONFIG)
173 $(error Invalid CONFIG value '$(CONFIG)')
174 endif
yangg102e4fe2015-01-06 16:02:50 -0800175
Craig Tiller841c8802015-09-10 13:06:37 -0700176 ifeq ($(SYSTEM),Linux)
177 TMPOUT = /dev/null
178 else
179 TMPOUT = `mktemp /tmp/test-out-XXXXXX`
180 endif
Nicolas Noble047b7272015-01-16 13:55:05 -0800181
Craig Tiller841c8802015-09-10 13:06:37 -0700182 # Detect if we can use C++11
183 CXX11_CHECK_CMD = $(CXX) -std=c++11 -o $(TMPOUT) -c test/build/c++11.cc
184 HAS_CXX11 = $(shell $(CXX11_CHECK_CMD) 2> /dev/null && echo true || echo false)
Craig Tillercf133f42015-02-26 14:05:56 -0800185
Craig Tiller82f3f0d2016-01-25 11:27:42 -0800186 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 -0800187 HAS_NO_SHIFT_NEGATIVE_VALUE = $(shell $(CHECK_NO_SHIFT_NEGATIVE_VALUE_CMD) 2> /dev/null && echo true || echo false)
188 ifeq ($(HAS_NO_SHIFT_NEGATIVE_VALUE),true)
189 W_NO_SHIFT_NEGATIVE_VALUE=-Wno-shift-negative-value
190 endif
191
Craig Tiller841c8802015-09-10 13:06:37 -0700192 # The HOST compiler settings are used to compile the protoc plugins.
193 # In most cases, you won't have to change anything, but if you are
194 # cross-compiling, you can override these variables from GNU make's
195 # command line: make CC=cross-gcc HOST_CC=gcc
Nicolas Noble047b7272015-01-16 13:55:05 -0800196
Nicolas "Pixel" Noble1a8eb852016-01-26 22:33:19 +0100197 HOST_CC ?= $(CC)
198 HOST_CXX ?= $(CXX)
199 HOST_LD ?= $(LD)
200 HOST_LDXX ?= $(LDXX)
nnoble72309c62014-12-12 11:42:26 -0800201
Craig Tiller841c8802015-09-10 13:06:37 -0700202 ifdef EXTRA_DEFINES
203 DEFINES += $(EXTRA_DEFINES)
204 endif
Craig Tiller86fa1c52015-02-27 09:57:58 -0800205
Craig Tiller0fe5ee72015-12-22 12:50:36 -0800206 CFLAGS += -std=c99 -Wsign-conversion -Wconversion -Wshadow
Craig Tiller841c8802015-09-10 13:06:37 -0700207 ifeq ($(HAS_CXX11),true)
208 CXXFLAGS += -std=c++11
209 else
210 CXXFLAGS += -std=c++0x
211 endif
Nicolas "Pixel" Noble51b1aee2016-01-28 01:14:58 +0100212 % for arg in ['CFLAGS', 'CXXFLAGS', 'CPPFLAGS', 'LDFLAGS', 'DEFINES']:
213 % if defaults.get('global', []).get(arg, None) is not None:
214 ${arg} += ${defaults.get('global').get(arg)}
215 % endif
216 % endfor
Nicolas Noblef8681182015-03-18 14:25:44 -0700217
Craig Tiller841c8802015-09-10 13:06:37 -0700218 CPPFLAGS += $(CPPFLAGS_$(CONFIG))
Craig Tiller0fe5ee72015-12-22 12:50:36 -0800219 CFLAGS += $(CFLAGS_$(CONFIG))
220 CXXFLAGS += $(CXXFLAGS_$(CONFIG))
Craig Tiller841c8802015-09-10 13:06:37 -0700221 DEFINES += $(DEFINES_$(CONFIG)) INSTALL_PREFIX=\"$(prefix)\"
222 LDFLAGS += $(LDFLAGS_$(CONFIG))
Nicolas "Pixel" Noble482d7612015-07-16 23:43:30 +0200223
Craig Tiller841c8802015-09-10 13:06:37 -0700224 ifneq ($(SYSTEM),MINGW32)
225 PIC_CPPFLAGS = -fPIC
226 CPPFLAGS += -fPIC
227 LDFLAGS += -fPIC
228 endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800229
Craig Tiller841c8802015-09-10 13:06:37 -0700230 INCLUDES = . include $(GENDIR)
231 LDFLAGS += -Llibs/$(CONFIG)
Nicolas "Pixel" Noble3adab742015-06-02 00:33:06 +0200232
Craig Tiller841c8802015-09-10 13:06:37 -0700233 ifeq ($(SYSTEM),Darwin)
234 ifneq ($(wildcard /usr/local/ssl/include),)
235 INCLUDES += /usr/local/ssl/include
236 endif
237 ifneq ($(wildcard /opt/local/include),)
238 INCLUDES += /opt/local/include
239 endif
240 ifneq ($(wildcard /usr/local/include),)
241 INCLUDES += /usr/local/include
242 endif
243 LIBS = m z
244 ifneq ($(wildcard /usr/local/ssl/lib),)
245 LDFLAGS += -L/usr/local/ssl/lib
246 endif
247 ifneq ($(wildcard /opt/local/lib),)
248 LDFLAGS += -L/opt/local/lib
249 endif
250 ifneq ($(wildcard /usr/local/lib),)
251 LDFLAGS += -L/usr/local/lib
252 endif
253 endif
Nicolas Noblef8681182015-03-18 14:25:44 -0700254
Craig Tiller841c8802015-09-10 13:06:37 -0700255 ifeq ($(SYSTEM),Linux)
Craig Tiller0fe5ee72015-12-22 12:50:36 -0800256 LIBS = rt m pthread
Craig Tiller841c8802015-09-10 13:06:37 -0700257 LDFLAGS += -pthread
258 endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800259
Craig Tiller841c8802015-09-10 13:06:37 -0700260 ifeq ($(SYSTEM),MINGW32)
Craig Tiller0fe5ee72015-12-22 12:50:36 -0800261 LIBS = m pthread
Craig Tiller841c8802015-09-10 13:06:37 -0700262 LDFLAGS += -pthread
263 endif
Nicolas Noblef8681182015-03-18 14:25:44 -0700264
Craig Tiller841c8802015-09-10 13:06:37 -0700265 GTEST_LIB = -Ithird_party/googletest/include -Ithird_party/googletest third_party/googletest/src/gtest-all.cc
266 GTEST_LIB += -lgflags
267 ifeq ($(V),1)
268 E = @:
269 Q =
270 else
271 E = @echo
272 Q = @
273 endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800274
Craig Tiller841c8802015-09-10 13:06:37 -0700275 VERSION = ${settings.version.major}.${settings.version.minor}.${settings.version.micro}.${settings.version.build}
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800276
Craig Tiller841c8802015-09-10 13:06:37 -0700277 CPPFLAGS_NO_ARCH += $(addprefix -I, $(INCLUDES)) $(addprefix -D, $(DEFINES))
278 CPPFLAGS += $(CPPFLAGS_NO_ARCH) $(ARCH_FLAGS)
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800279
Craig Tiller841c8802015-09-10 13:06:37 -0700280 LDFLAGS += $(ARCH_FLAGS)
281 LDLIBS += $(addprefix -l, $(LIBS))
282 LDLIBSXX += $(addprefix -l, $(LIBSXX))
nnoble72309c62014-12-12 11:42:26 -0800283
Craig Tiller841c8802015-09-10 13:06:37 -0700284 HOST_CPPFLAGS = $(CPPFLAGS)
285 HOST_CFLAGS = $(CFLAGS)
286 HOST_CXXFLAGS = $(CXXFLAGS)
287 HOST_LDFLAGS = $(LDFLAGS)
288 HOST_LDLIBS = $(LDLIBS)
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800289
Craig Tiller841c8802015-09-10 13:06:37 -0700290 # These are automatically computed variables.
291 # There shouldn't be any need to change anything from now on.
nnoble69ac39f2014-12-12 15:43:38 -0800292
Craig Tiller841c8802015-09-10 13:06:37 -0700293 -include cache.mk
murgatroid9924e2f4a2015-06-29 11:12:01 -0700294
Craig Tiller841c8802015-09-10 13:06:37 -0700295 CACHE_MK =
murgatroid99aa521572015-07-10 14:49:12 -0700296
Craig Tiller841c8802015-09-10 13:06:37 -0700297 HAS_PKG_CONFIG ?= $(shell command -v $(PKG_CONFIG) >/dev/null 2>&1 && echo true || echo false)
murgatroid99aa521572015-07-10 14:49:12 -0700298
Craig Tiller841c8802015-09-10 13:06:37 -0700299 ifeq ($(HAS_PKG_CONFIG), true)
300 CACHE_MK += HAS_PKG_CONFIG = true,
301 endif
nnoble69ac39f2014-12-12 15:43:38 -0800302
Craig Tiller841c8802015-09-10 13:06:37 -0700303 PC_TEMPLATE = prefix=$(prefix),\
304 exec_prefix=${'\$${prefix}'},\
305 includedir=${'\$${prefix}'}/include,\
306 libdir=${'\$${exec_prefix}'}/lib,\
307 ,\
308 Name: $(PC_NAME),\
309 Description: $(PC_DESCRIPTION),\
310 Version: $(VERSION),\
311 Cflags: -I${'\$${includedir}'} $(PC_CFLAGS),\
312 Requires.private: $(PC_REQUIRES_PRIVATE),\
313 Libs: -L${'\$${libdir}'} $(PC_LIB),\
314 Libs.private: $(PC_LIBS_PRIVATE)
murgatroid998faab232015-06-30 17:24:21 -0700315
Craig Tiller841c8802015-09-10 13:06:37 -0700316 # gpr .pc file
317 PC_NAME = gRPC Portable Runtime
318 PC_DESCRIPTION = gRPC Portable Runtime
319 PC_CFLAGS = -pthread
320 PC_REQUIRES_PRIVATE =
321 PC_LIBS_PRIVATE = -lpthread
322 PC_LIB = -lgpr
323 ifneq ($(SYSTEM),Darwin)
324 PC_LIBS_PRIVATE += -lrt
325 endif
326 GPR_PC_FILE := $(PC_TEMPLATE)
murgatroid998faab232015-06-30 17:24:21 -0700327
Craig Tiller841c8802015-09-10 13:06:37 -0700328 ifeq ($(SYSTEM),MINGW32)
329 SHARED_EXT = dll
330 endif
331 ifeq ($(SYSTEM),Darwin)
332 SHARED_EXT = dylib
333 endif
334 ifeq ($(SHARED_EXT),)
335 SHARED_EXT = so.$(VERSION)
336 endif
nnoble5b7f32a2014-12-22 08:12:44 -0800337
Craig Tiller841c8802015-09-10 13:06:37 -0700338 ifeq ($(wildcard .git),)
339 IS_GIT_FOLDER = false
340 else
341 IS_GIT_FOLDER = true
342 endif
nnoble69ac39f2014-12-12 15:43:38 -0800343
Craig Tiller841c8802015-09-10 13:06:37 -0700344 ifeq ($(HAS_PKG_CONFIG),true)
345 OPENSSL_ALPN_CHECK_CMD = $(PKG_CONFIG) --atleast-version=1.0.2 openssl
346 OPENSSL_NPN_CHECK_CMD = $(PKG_CONFIG) --atleast-version=1.0.1 openssl
347 ZLIB_CHECK_CMD = $(PKG_CONFIG) --exists zlib
348 PROTOBUF_CHECK_CMD = $(PKG_CONFIG) --atleast-version=3.0.0-alpha-3 protobuf
349 else # HAS_PKG_CONFIG
murgatroid9924e2f4a2015-06-29 11:12:01 -0700350
Craig Tiller841c8802015-09-10 13:06:37 -0700351 ifeq ($(SYSTEM),MINGW32)
352 OPENSSL_LIBS = ssl32 eay32
353 else
354 OPENSSL_LIBS = ssl crypto
355 endif
Nicolas Noblef8681182015-03-18 14:25:44 -0700356
Nicolas "Pixel" Noble45000342016-01-28 05:04:45 +0100357 OPENSSL_ALPN_CHECK_CMD = $(CC) $(CPPFLAGS) $(CFLAGS) -o $(TMPOUT) test/build/openssl-alpn.c $(addprefix -l, $(OPENSSL_LIBS)) $(LDFLAGS)
358 OPENSSL_NPN_CHECK_CMD = $(CC) $(CPPFLAGS) $(CFLAGS) -o $(TMPOUT) test/build/openssl-npn.c $(addprefix -l, $(OPENSSL_LIBS)) $(LDFLAGS)
359 ZLIB_CHECK_CMD = $(CC) $(CPPFLAGS) $(CFLAGS) -o $(TMPOUT) test/build/zlib.c -lz $(LDFLAGS)
360 PROTOBUF_CHECK_CMD = $(CXX) $(CPPFLAGS) $(CXXFLAGS) -o $(TMPOUT) test/build/protobuf.cc -lprotobuf $(LDFLAGS)
Craig Tiller297fafa2015-01-15 15:46:39 -0800361
Craig Tiller841c8802015-09-10 13:06:37 -0700362 endif # HAS_PKG_CONFIG
murgatroid9924e2f4a2015-06-29 11:12:01 -0700363
Nicolas "Pixel" Noble45000342016-01-28 05:04:45 +0100364 PERFTOOLS_CHECK_CMD = $(CC) $(CPPFLAGS) $(CFLAGS) -o $(TMPOUT) test/build/perftools.c -lprofiler $(LDFLAGS)
murgatroid996d9e4012015-07-08 10:22:45 -0700365
Craig Tiller841c8802015-09-10 13:06:37 -0700366 PROTOC_CHECK_CMD = which protoc > /dev/null
367 PROTOC_CHECK_VERSION_CMD = protoc --version | grep -q libprotoc.3
368 DTRACE_CHECK_CMD = which dtrace > /dev/null
Nicolas "Pixel" Noble45000342016-01-28 05:04:45 +0100369 SYSTEMTAP_HEADERS_CHECK_CMD = $(CC) $(CPPFLAGS) $(CFLAGS) -o $(TMPOUT) test/build/systemtap.c $(LDFLAGS)
370 ZOOKEEPER_CHECK_CMD = $(CC) $(CPPFLAGS) $(CFLAGS) -o $(TMPOUT) test/build/zookeeper.c $(LDFLAGS) -lzookeeper_mt
murgatroid9924e2f4a2015-06-29 11:12:01 -0700371
Craig Tiller841c8802015-09-10 13:06:37 -0700372 ifndef REQUIRE_CUSTOM_LIBRARIES_$(CONFIG)
373 HAS_SYSTEM_PERFTOOLS ?= $(shell $(PERFTOOLS_CHECK_CMD) 2> /dev/null && echo true || echo false)
374 ifeq ($(HAS_SYSTEM_PERFTOOLS),true)
375 DEFINES += GRPC_HAVE_PERFTOOLS
376 LIBS += profiler
377 CACHE_MK += HAS_SYSTEM_PERFTOOLS = true,
378 endif
379 endif
nnoble69ac39f2014-12-12 15:43:38 -0800380
Craig Tiller841c8802015-09-10 13:06:37 -0700381 HAS_SYSTEM_PROTOBUF_VERIFY = $(shell $(PROTOBUF_CHECK_CMD) 2> /dev/null && echo true || echo false)
382 ifndef REQUIRE_CUSTOM_LIBRARIES_$(CONFIG)
383 HAS_SYSTEM_OPENSSL_ALPN ?= $(shell $(OPENSSL_ALPN_CHECK_CMD) 2> /dev/null && echo true || echo false)
384 ifeq ($(HAS_SYSTEM_OPENSSL_ALPN),true)
385 HAS_SYSTEM_OPENSSL_NPN = true
386 CACHE_MK += HAS_SYSTEM_OPENSSL_ALPN = true,
387 else
388 HAS_SYSTEM_OPENSSL_NPN ?= $(shell $(OPENSSL_NPN_CHECK_CMD) 2> /dev/null && echo true || echo false)
389 endif
390 ifeq ($(HAS_SYSTEM_OPENSSL_NPN),true)
391 CACHE_MK += HAS_SYSTEM_OPENSSL_NPN = true,
392 endif
393 HAS_SYSTEM_ZLIB ?= $(shell $(ZLIB_CHECK_CMD) 2> /dev/null && echo true || echo false)
394 ifeq ($(HAS_SYSTEM_ZLIB),true)
395 CACHE_MK += HAS_SYSTEM_ZLIB = true,
396 endif
397 HAS_SYSTEM_PROTOBUF ?= $(HAS_SYSTEM_PROTOBUF_VERIFY)
398 ifeq ($(HAS_SYSTEM_PROTOBUF),true)
399 CACHE_MK += HAS_SYSTEM_PROTOBUF = true,
400 endif
401 else
402 # override system libraries if the config requires a custom compiled library
403 HAS_SYSTEM_OPENSSL_ALPN = false
404 HAS_SYSTEM_OPENSSL_NPN = false
405 HAS_SYSTEM_ZLIB = false
406 HAS_SYSTEM_PROTOBUF = false
407 endif
nnoble69ac39f2014-12-12 15:43:38 -0800408
Craig Tiller841c8802015-09-10 13:06:37 -0700409 HAS_PROTOC ?= $(shell $(PROTOC_CHECK_CMD) 2> /dev/null && echo true || echo false)
410 ifeq ($(HAS_PROTOC),true)
411 CACHE_MK += HAS_PROTOC = true,
412 HAS_VALID_PROTOC ?= $(shell $(PROTOC_CHECK_VERSION_CMD) 2> /dev/null && echo true || echo false)
413 ifeq ($(HAS_VALID_PROTOC),true)
414 CACHE_MK += HAS_VALID_PROTOC = true,
415 endif
416 else
417 HAS_VALID_PROTOC = false
418 endif
Nicolas Noble53830622015-02-12 16:56:38 -0800419
Craig Tiller841c8802015-09-10 13:06:37 -0700420 # Check for Systemtap (https://sourceware.org/systemtap/), first by making sure <sys/sdt.h> is present
421 # in the system and secondly by checking for the "dtrace" binary (on Linux, this is part of the Systemtap
422 # distribution. It's part of the base system on BSD/Solaris machines).
423 ifndef HAS_SYSTEMTAP
424 HAS_SYSTEMTAP_HEADERS = $(shell $(SYSTEMTAP_HEADERS_CHECK_CMD) 2> /dev/null && echo true || echo false)
425 HAS_DTRACE = $(shell $(DTRACE_CHECK_CMD) 2> /dev/null && echo true || echo false)
426 HAS_SYSTEMTAP = false
427 ifeq ($(HAS_SYSTEMTAP_HEADERS),true)
428 ifeq ($(HAS_DTRACE),true)
429 HAS_SYSTEMTAP = true
430 endif
431 endif
432 endif
David Garcia Quintas611b7362015-04-27 15:49:31 -0700433
Craig Tiller841c8802015-09-10 13:06:37 -0700434 ifeq ($(HAS_SYSTEMTAP),true)
435 CACHE_MK += HAS_SYSTEMTAP = true,
436 endif
nnoble69ac39f2014-12-12 15:43:38 -0800437
Craig Tiller841c8802015-09-10 13:06:37 -0700438 HAS_ZOOKEEPER = $(shell $(ZOOKEEPER_CHECK_CMD) 2> /dev/null && echo true || echo false)
Hongwei Wanga8cc4392015-07-16 17:37:47 -0700439
Craig Tiller841c8802015-09-10 13:06:37 -0700440 # Note that for testing purposes, one can do:
441 # make HAS_EMBEDDED_OPENSSL_ALPN=false
442 # to emulate the fact we do not have OpenSSL in the third_party folder.
Craig Tiller0fe5ee72015-12-22 12:50:36 -0800443 ifeq ($(wildcard third_party/boringssl/include/openssl/ssl.h),)
Craig Tiller841c8802015-09-10 13:06:37 -0700444 HAS_EMBEDDED_OPENSSL_ALPN = false
445 else
446 HAS_EMBEDDED_OPENSSL_ALPN = true
447 endif
nnoble69ac39f2014-12-12 15:43:38 -0800448
Craig Tiller841c8802015-09-10 13:06:37 -0700449 ifeq ($(wildcard third_party/zlib/zlib.h),)
450 HAS_EMBEDDED_ZLIB = false
451 else
452 HAS_EMBEDDED_ZLIB = true
453 endif
nnoble69ac39f2014-12-12 15:43:38 -0800454
Craig Tiller841c8802015-09-10 13:06:37 -0700455 ifeq ($(wildcard third_party/protobuf/src/google/protobuf/descriptor.pb.h),)
456 HAS_EMBEDDED_PROTOBUF = false
457 ifneq ($(HAS_VALID_PROTOC),true)
458 NO_PROTOC = true
459 endif
460 else
461 HAS_EMBEDDED_PROTOBUF = true
462 endif
Nicolas Noble53830622015-02-12 16:56:38 -0800463
Craig Tiller841c8802015-09-10 13:06:37 -0700464 PC_REQUIRES_GRPC = gpr
465 PC_LIBS_GRPC =
murgatroid998faab232015-06-30 17:24:21 -0700466
Craig Tiller841c8802015-09-10 13:06:37 -0700467 ifeq ($(HAS_SYSTEM_ZLIB),false)
Craig Tiller3dca23a2016-01-21 11:44:55 -0800468 ifeq ($(HAS_EMBEDDED_ZLIB), true)
469 EMBED_ZLIB ?= true
Craig Tiller841c8802015-09-10 13:06:37 -0700470 else
471 DEP_MISSING += zlib
Craig Tiller3dca23a2016-01-21 11:44:55 -0800472 EMBED_ZLIB ?= broken
Craig Tiller841c8802015-09-10 13:06:37 -0700473 endif
474 else
Craig Tiller3dca23a2016-01-21 11:44:55 -0800475 EMBED_ZLIB ?= false
476 endif
477
478 ifeq ($(EMBED_ZLIB),true)
479 ZLIB_DEP = $(LIBDIR)/$(CONFIG)/libz.a
480 ZLIB_MERGE_LIBS = $(LIBDIR)/$(CONFIG)/libz.a
481 CPPFLAGS += -Ithird_party/zlib
482 LDFLAGS += -L$(LIBDIR)/$(CONFIG)/zlib
483 else
Craig Tiller841c8802015-09-10 13:06:37 -0700484 ifeq ($(HAS_PKG_CONFIG),true)
485 CPPFLAGS += $(shell $(PKG_CONFIG) --cflags zlib)
486 LDFLAGS += $(shell $(PKG_CONFIG) --libs-only-L zlib)
Craig Tiller0fe5ee72015-12-22 12:50:36 -0800487 LIBS += $(patsubst -l%,%,$(shell $(PKG_CONFIG) --libs-only-l zlib))
Craig Tiller841c8802015-09-10 13:06:37 -0700488 PC_REQUIRES_GRPC += zlib
489 else
490 PC_LIBS_GRPC += -lz
Craig Tiller0fe5ee72015-12-22 12:50:36 -0800491 LIBS += z
Craig Tiller841c8802015-09-10 13:06:37 -0700492 endif
493 endif
nnoble69ac39f2014-12-12 15:43:38 -0800494
Craig Tiller841c8802015-09-10 13:06:37 -0700495 OPENSSL_PKG_CONFIG = false
murgatroid99da7a9942015-06-29 14:57:37 -0700496
Craig Tiller841c8802015-09-10 13:06:37 -0700497 PC_REQUIRES_SECURE =
498 PC_LIBS_SECURE =
murgatroid998faab232015-06-30 17:24:21 -0700499
Craig Tiller841c8802015-09-10 13:06:37 -0700500 ifeq ($(HAS_SYSTEM_OPENSSL_ALPN),true)
Craig Tiller0fe5ee72015-12-22 12:50:36 -0800501 EMBED_OPENSSL ?= false
502 NO_SECURE ?= false
503 else # HAS_SYSTEM_OPENSSL_ALPN=false
504 ifeq ($(HAS_EMBEDDED_OPENSSL_ALPN),true)
505 EMBED_OPENSSL ?= true
506 NO_SECURE ?= false
507 else # HAS_EMBEDDED_OPENSSL_ALPN=false
508 ifeq ($(HAS_SYSTEM_OPENSSL_NPN),true)
509 EMBED_OPENSSL ?= false
510 NO_SECURE ?= false
511 else
512 NO_SECURE ?= true
513 endif # HAS_SYSTEM_OPENSSL_NPN=true
514 endif # HAS_EMBEDDED_OPENSSL_ALPN
515 endif # HAS_SYSTEM_OPENSSL_ALPN
516
517 OPENSSL_DEP :=
518 OPENSSL_MERGE_LIBS :=
519 ifeq ($(NO_SECURE),false)
520 ifeq ($(EMBED_OPENSSL),true)
521 OPENSSL_DEP += $(LIBDIR)/$(CONFIG)/libboringssl.a
522 OPENSSL_MERGE_LIBS += $(LIBDIR)/$(CONFIG)/libboringssl.a
523 # need to prefix these to ensure overriding system libraries
524 CPPFLAGS := -Ithird_party/boringssl/include $(CPPFLAGS)
Craig Tiller0fe5ee72015-12-22 12:50:36 -0800525 else # EMBED_OPENSSL=false
Craig Tiller841c8802015-09-10 13:06:37 -0700526 ifeq ($(HAS_PKG_CONFIG),true)
527 OPENSSL_PKG_CONFIG = true
528 PC_REQUIRES_SECURE = openssl
529 CPPFLAGS := $(shell $(PKG_CONFIG) --cflags openssl) $(CPPFLAGS)
530 LDFLAGS_OPENSSL_PKG_CONFIG = $(shell $(PKG_CONFIG) --libs-only-L openssl)
531 ifeq ($(SYSTEM),Linux)
532 ifneq ($(LDFLAGS_OPENSSL_PKG_CONFIG),)
533 LDFLAGS_OPENSSL_PKG_CONFIG += $(shell $(PKG_CONFIG) --libs-only-L openssl | sed s/L/Wl,-rpath,/)
Craig Tiller0fe5ee72015-12-22 12:50:36 -0800534 endif # LDFLAGS_OPENSSL_PKG_CONFIG=''
535 endif # System=Linux
Craig Tiller841c8802015-09-10 13:06:37 -0700536 LDFLAGS := $(LDFLAGS_OPENSSL_PKG_CONFIG) $(LDFLAGS)
Craig Tiller0fe5ee72015-12-22 12:50:36 -0800537 else # HAS_PKG_CONFIG=false
Craig Tiller841c8802015-09-10 13:06:37 -0700538 LIBS_SECURE = $(OPENSSL_LIBS)
Craig Tiller0fe5ee72015-12-22 12:50:36 -0800539 endif # HAS_PKG_CONFIG
540 ifeq ($(HAS_SYSTEM_OPENSSL_NPN),true)
541 CPPFLAGS += -DTSI_OPENSSL_ALPN_SUPPORT=0
542 LIBS_SECURE = $(OPENSSL_LIBS)
543 endif # HAS_SYSTEM_OPENSSL_NPN
Craig Tiller841c8802015-09-10 13:06:37 -0700544 PC_LIBS_SECURE = $(addprefix -l, $(LIBS_SECURE))
Craig Tiller0fe5ee72015-12-22 12:50:36 -0800545 endif # EMBED_OPENSSL
546 endif # NO_SECURE
nnoble69ac39f2014-12-12 15:43:38 -0800547
Craig Tiller841c8802015-09-10 13:06:37 -0700548 ifeq ($(OPENSSL_PKG_CONFIG),true)
549 LDLIBS_SECURE += $(shell $(PKG_CONFIG) --libs-only-l openssl)
550 else
551 LDLIBS_SECURE += $(addprefix -l, $(LIBS_SECURE))
552 endif
nnoble5b7f32a2014-12-22 08:12:44 -0800553
Craig Tiller841c8802015-09-10 13:06:37 -0700554 # grpc .pc file
555 PC_NAME = gRPC
556 PC_DESCRIPTION = high performance general RPC framework
557 PC_CFLAGS =
558 PC_REQUIRES_PRIVATE = $(PC_REQUIRES_GRPC) $(PC_REQUIRES_SECURE)
559 PC_LIBS_PRIVATE = $(PC_LIBS_GRPC) $(PC_LIBS_SECURE)
560 PC_LIB = -lgrpc
561 GRPC_PC_FILE := $(PC_TEMPLATE)
murgatroid998faab232015-06-30 17:24:21 -0700562
Craig Tiller841c8802015-09-10 13:06:37 -0700563 # gprc_unsecure .pc file
564 PC_NAME = gRPC unsecure
565 PC_DESCRIPTION = high performance general RPC framework without SSL
566 PC_CFLAGS =
567 PC_REQUIRES_PRIVATE = $(PC_REQUIRES_GRPC)
568 PC_LIBS_PRIVATE = $(PC_LIBS_GRPC)
569 PC_LIB = -lgrpc
570 GRPC_UNSECURE_PC_FILE := $(PC_TEMPLATE)
murgatroid998faab232015-06-30 17:24:21 -0700571
Craig Tiller841c8802015-09-10 13:06:37 -0700572 # gprc_zookeeper .pc file
573 PC_NAME = gRPC zookeeper
574 PC_DESCRIPTION = gRPC's zookeeper plugin
575 PC_CFLAGS =
576 PC_REQUIRES_PRIVATE =
577 PC_LIBS_PRIVATE = -lzookeeper_mt
578 GRPC_ZOOKEEPER_PC_FILE := $(PC_TEMPLATE)
Hongwei Wanga8cc4392015-07-16 17:37:47 -0700579
Craig Tiller841c8802015-09-10 13:06:37 -0700580 PROTOBUF_PKG_CONFIG = false
murgatroid99da7a9942015-06-29 14:57:37 -0700581
Craig Tiller841c8802015-09-10 13:06:37 -0700582 PC_REQUIRES_GRPCXX =
583 PC_LIBS_GRPCXX =
murgatroid998faab232015-06-30 17:24:21 -0700584
Craig Tiller841c8802015-09-10 13:06:37 -0700585 CPPFLAGS := -Ithird_party/googletest/include $(CPPFLAGS)
Craig Tiller16f6dac2015-08-24 17:00:04 -0700586
Craig Tiller841c8802015-09-10 13:06:37 -0700587 ifeq ($(HAS_SYSTEM_PROTOBUF),true)
588 ifeq ($(HAS_PKG_CONFIG),true)
589 PROTOBUF_PKG_CONFIG = true
590 PC_REQUIRES_GRPCXX = protobuf
591 CPPFLAGS := $(shell $(PKG_CONFIG) --cflags protobuf) $(CPPFLAGS)
592 LDFLAGS_PROTOBUF_PKG_CONFIG = $(shell $(PKG_CONFIG) --libs-only-L protobuf)
593 ifeq ($(SYSTEM),Linux)
594 ifneq ($(LDFLAGS_PROTOBUF_PKG_CONFIG),)
595 LDFLAGS_PROTOBUF_PKG_CONFIG += $(shell $(PKG_CONFIG) --libs-only-L protobuf | sed s/L/Wl,-rpath,/)
596 endif
597 endif
598 else
599 PC_LIBS_GRPCXX = -lprotobuf
600 endif
601 else
602 ifeq ($(HAS_EMBEDDED_PROTOBUF),true)
603 PROTOBUF_DEP = $(LIBDIR)/$(CONFIG)/protobuf/libprotobuf.a
604 CPPFLAGS := -Ithird_party/protobuf/src $(CPPFLAGS)
605 LDFLAGS := -L$(LIBDIR)/$(CONFIG)/protobuf $(LDFLAGS)
606 PROTOC = $(BINDIR)/$(CONFIG)/protobuf/protoc
607 else
608 NO_PROTOBUF = true
609 endif
610 endif
Nicolas Noble53830622015-02-12 16:56:38 -0800611
Craig Tiller841c8802015-09-10 13:06:37 -0700612 LIBS_PROTOBUF = protobuf
613 LIBS_PROTOC = protoc protobuf
Nicolas Noble53830622015-02-12 16:56:38 -0800614
Craig Tiller841c8802015-09-10 13:06:37 -0700615 HOST_LDLIBS_PROTOC += $(addprefix -l, $(LIBS_PROTOC))
Nicolas Noble53830622015-02-12 16:56:38 -0800616
Craig Tiller841c8802015-09-10 13:06:37 -0700617 ifeq ($(PROTOBUF_PKG_CONFIG),true)
618 LDLIBS_PROTOBUF += $(shell $(PKG_CONFIG) --libs-only-l protobuf)
619 else
620 LDLIBS_PROTOBUF += $(addprefix -l, $(LIBS_PROTOBUF))
621 endif
murgatroid9924e2f4a2015-06-29 11:12:01 -0700622
Craig Tiller841c8802015-09-10 13:06:37 -0700623 # grpc++ .pc file
624 PC_NAME = gRPC++
625 PC_DESCRIPTION = C++ wrapper for gRPC
626 PC_CFLAGS =
627 PC_REQUIRES_PRIVATE = grpc $(PC_REQUIRES_GRPCXX)
628 PC_LIBS_PRIVATE = $(PC_LIBS_GRPCXX)
629 PC_LIB = -lgrpc++
630 GRPCXX_PC_FILE := $(PC_TEMPLATE)
murgatroid998faab232015-06-30 17:24:21 -0700631
Craig Tiller841c8802015-09-10 13:06:37 -0700632 # grpc++_unsecure .pc file
633 PC_NAME = gRPC++ unsecure
634 PC_DESCRIPTION = C++ wrapper for gRPC without SSL
635 PC_CFLAGS =
636 PC_REQUIRES_PRIVATE = grpc_unsecure $(PC_REQUIRES_GRPCXX)
637 PC_LIBS_PRIVATE = $(PC_LIBS_GRPCXX)
638 PC_LIB = -lgrpc++
639 GRPCXX_UNSECURE_PC_FILE := $(PC_TEMPLATE)
murgatroid998faab232015-06-30 17:24:21 -0700640
Craig Tiller841c8802015-09-10 13:06:37 -0700641 ifeq ($(MAKECMDGOALS),clean)
642 NO_DEPS = true
643 endif
nnoble69ac39f2014-12-12 15:43:38 -0800644
Craig Tiller841c8802015-09-10 13:06:37 -0700645 INSTALL_OK = false
646 ifeq ($(HAS_VALID_PROTOC),true)
647 ifeq ($(HAS_SYSTEM_PROTOBUF_VERIFY),true)
648 INSTALL_OK = true
649 endif
650 endif
Nicolas "Pixel" Noble98ab9982015-02-21 04:22:16 +0100651
Craig Tiller841c8802015-09-10 13:06:37 -0700652 .SECONDARY = %.pb.h %.pb.cc
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800653
Craig Tiller841c8802015-09-10 13:06:37 -0700654 PROTOC_PLUGINS =\
655 % for tgt in targets:
656 % if tgt.build == 'protoc':
657 $(BINDIR)/$(CONFIG)/${tgt.name}\
658 % endif
659 % endfor
Craig Tillerf58b9ef2015-01-15 09:09:12 -0800660
Craig Tiller841c8802015-09-10 13:06:37 -0700661 ifeq ($(DEP_MISSING),)
662 all: static shared plugins\
663 % for tgt in targets:
664 % if tgt.build == 'all':
665 $(BINDIR)/$(CONFIG)/${tgt.name}\
666 % endif
667 % endfor
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800668
Craig Tiller841c8802015-09-10 13:06:37 -0700669 dep_error:
670 @echo "You shouldn't see this message - all of your dependencies are correct."
671 else
672 all: dep_error git_update stop
nnoble69ac39f2014-12-12 15:43:38 -0800673
Craig Tiller841c8802015-09-10 13:06:37 -0700674 dep_error:
675 @echo
676 @echo "DEPENDENCY ERROR"
677 @echo
678 @echo "You are missing system dependencies that are essential to build grpc,"
679 @echo "and the third_party directory doesn't have them:"
680 @echo
681 @echo " $(DEP_MISSING)"
682 @echo
683 @echo "Installing the development packages for your system will solve"
684 @echo "this issue. Please consult INSTALL to get more information."
685 @echo
686 @echo "If you need information about why these tests failed, run:"
687 @echo
688 @echo " make run_dep_checks"
689 @echo
690 endif
nnoble69ac39f2014-12-12 15:43:38 -0800691
Craig Tiller841c8802015-09-10 13:06:37 -0700692 git_update:
693 ifeq ($(IS_GIT_FOLDER),true)
694 @echo "Additionally, since you are in a git clone, you can download the"
695 @echo "missing dependencies in third_party by running the following command:"
696 @echo
697 @echo " git submodule update --init"
698 @echo
699 endif
nnoble69ac39f2014-12-12 15:43:38 -0800700
Craig Tiller841c8802015-09-10 13:06:37 -0700701 openssl_dep_error: openssl_dep_message git_update stop
nnoble69ac39f2014-12-12 15:43:38 -0800702
Craig Tiller841c8802015-09-10 13:06:37 -0700703 protobuf_dep_error: protobuf_dep_message git_update stop
Nicolas Noble53830622015-02-12 16:56:38 -0800704
Craig Tiller841c8802015-09-10 13:06:37 -0700705 protoc_dep_error: protoc_dep_message git_update stop
Nicolas Noble53830622015-02-12 16:56:38 -0800706
Craig Tiller841c8802015-09-10 13:06:37 -0700707 openssl_dep_message:
708 @echo
709 @echo "DEPENDENCY ERROR"
710 @echo
711 @echo "The target you are trying to run requires OpenSSL."
712 @echo "Your system doesn't have it, and neither does the third_party directory."
713 @echo
714 @echo "Please consult INSTALL to get more information."
715 @echo
716 @echo "If you need information about why these tests failed, run:"
717 @echo
718 @echo " make run_dep_checks"
719 @echo
nnoble69ac39f2014-12-12 15:43:38 -0800720
Craig Tiller841c8802015-09-10 13:06:37 -0700721 protobuf_dep_message:
722 @echo
723 @echo "DEPENDENCY ERROR"
724 @echo
725 @echo "The target you are trying to run requires protobuf 3.0.0+"
726 @echo "Your system doesn't have it, and neither does the third_party directory."
727 @echo
728 @echo "Please consult INSTALL to get more information."
729 @echo
730 @echo "If you need information about why these tests failed, run:"
731 @echo
732 @echo " make run_dep_checks"
733 @echo
Nicolas Noble53830622015-02-12 16:56:38 -0800734
Craig Tiller841c8802015-09-10 13:06:37 -0700735 protoc_dep_message:
736 @echo
737 @echo "DEPENDENCY ERROR"
738 @echo
739 @echo "The target you are trying to run requires protobuf-compiler 3.0.0+"
740 @echo "Your system doesn't have it, and neither does the third_party directory."
741 @echo
742 @echo "Please consult INSTALL to get more information."
743 @echo
744 @echo "If you need information about why these tests failed, run:"
745 @echo
746 @echo " make run_dep_checks"
747 @echo
Nicolas Noble53830622015-02-12 16:56:38 -0800748
Craig Tiller841c8802015-09-10 13:06:37 -0700749 systemtap_dep_error:
750 @echo
751 @echo "DEPENDENCY ERROR"
752 @echo
753 @echo "Under the '$(CONFIG)' configutation, the target you are trying "
754 @echo "to build requires systemtap 2.7+ (on Linux) or dtrace (on other "
755 @echo "platforms such as Solaris and *BSD). "
756 @echo
757 @echo "Please consult INSTALL to get more information."
758 @echo
David Garcia Quintas8954e902015-04-29 09:46:33 -0700759
Craig Tiller841c8802015-09-10 13:06:37 -0700760 stop:
761 @false
nnoble69ac39f2014-12-12 15:43:38 -0800762
Craig Tiller841c8802015-09-10 13:06:37 -0700763 % for tgt in targets:
764 ${tgt.name}: $(BINDIR)/$(CONFIG)/${tgt.name}
765 % endfor
ctiller09cb6d52014-12-19 17:38:22 -0800766
Craig Tiller841c8802015-09-10 13:06:37 -0700767 run_dep_checks:
768 $(OPENSSL_ALPN_CHECK_CMD) || true
769 $(OPENSSL_NPN_CHECK_CMD) || true
770 $(ZLIB_CHECK_CMD) || true
771 $(PERFTOOLS_CHECK_CMD) || true
772 $(PROTOBUF_CHECK_CMD) || true
773 $(PROTOC_CHECK_VERSION_CMD) || true
774 $(ZOOKEEPER_CHECK_CMD) || true
nnoble69ac39f2014-12-12 15:43:38 -0800775
Craig Tiller841c8802015-09-10 13:06:37 -0700776 third_party/protobuf/configure:
777 $(E) "[AUTOGEN] Preparing protobuf"
778 $(Q)(cd third_party/protobuf ; autoreconf -f -i -Wall,no-obsolete)
Nicolas Noble53830622015-02-12 16:56:38 -0800779
Craig Tiller841c8802015-09-10 13:06:37 -0700780 $(LIBDIR)/$(CONFIG)/protobuf/libprotobuf.a: third_party/protobuf/configure
781 $(E) "[MAKE] Building protobuf"
782 $(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)
783 $(Q)$(MAKE) -C third_party/protobuf clean
784 $(Q)$(MAKE) -C third_party/protobuf
785 $(Q)mkdir -p $(LIBDIR)/$(CONFIG)/protobuf
786 $(Q)mkdir -p $(BINDIR)/$(CONFIG)/protobuf
787 $(Q)cp third_party/protobuf/src/.libs/libprotoc.a $(LIBDIR)/$(CONFIG)/protobuf
788 $(Q)cp third_party/protobuf/src/.libs/libprotobuf.a $(LIBDIR)/$(CONFIG)/protobuf
789 $(Q)cp third_party/protobuf/src/protoc $(BINDIR)/$(CONFIG)/protobuf
Nicolas Noble53830622015-02-12 16:56:38 -0800790
Craig Tiller841c8802015-09-10 13:06:37 -0700791 static: static_c static_cxx
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800792
Craig Tiller841c8802015-09-10 13:06:37 -0700793 static_c: pc_c pc_c_unsecure cache.mk pc_gpr pc_c_zookeeper\
794 % for lib in libs:
795 % if lib.build == 'all' and lib.language == 'c' and not lib.get('external_deps', None):
796 $(LIBDIR)/$(CONFIG)/lib${lib.name}.a\
797 % endif
798 % endfor
799 static_zookeeper_libs
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800800
801
Craig Tiller841c8802015-09-10 13:06:37 -0700802 static_cxx: pc_cxx pc_cxx_unsecure pc_gpr cache.mk \
803 % for lib in libs:
804 % if lib.build == 'all' and lib.language == 'c++':
805 $(LIBDIR)/$(CONFIG)/lib${lib.name}.a\
806 % endif
807 % endfor
nnoble29e1d292014-12-01 10:27:40 -0800808
809
Craig Tiller841c8802015-09-10 13:06:37 -0700810 shared: shared_c shared_cxx
nnoble29e1d292014-12-01 10:27:40 -0800811
Craig Tiller841c8802015-09-10 13:06:37 -0700812 shared_c: pc_c pc_c_unsecure pc_gpr cache.mk pc_c_zookeeper\
813 % for lib in libs:
814 % if lib.build == 'all' and lib.language == 'c' and not lib.get('external_deps', None):
815 $(LIBDIR)/$(CONFIG)/lib${lib.name}.$(SHARED_EXT)\
816 % endif
817 % endfor
818 shared_zookeeper_libs
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800819
Craig Tiller841c8802015-09-10 13:06:37 -0700820 shared_cxx: pc_cxx pc_cxx_unsecure cache.mk\
821 % for lib in libs:
822 % if lib.build == 'all' and lib.language == 'c++':
823 $(LIBDIR)/$(CONFIG)/lib${lib.name}.$(SHARED_EXT)\
824 % endif
825 % endfor
nnoble29e1d292014-12-01 10:27:40 -0800826
827
Craig Tiller841c8802015-09-10 13:06:37 -0700828 shared_csharp: shared_c \
829 % for lib in libs:
830 % if lib.build == 'all' and lib.language == 'csharp':
831 $(LIBDIR)/$(CONFIG)/lib${lib.name}.$(SHARED_EXT)\
832 % endif
833 % endfor
Jan Tattermusch2ec0b3e2015-02-18 15:03:12 -0800834
Craig Tiller841c8802015-09-10 13:06:37 -0700835 ifeq ($(HAS_ZOOKEEPER),true)
836 static_zookeeper_libs:\
837 % for lib in libs:
838 % if lib.build == 'all' and lib.language == 'c' and 'zookeeper' in lib.get('external_deps', []):
839 $(LIBDIR)/$(CONFIG)/lib${lib.name}.a\
840 % endif
841 % endfor
Hongwei Wanga8cc4392015-07-16 17:37:47 -0700842
Craig Tiller841c8802015-09-10 13:06:37 -0700843 shared_zookeeper_libs:\
844 % for lib in libs:
845 % if lib.build == 'all' and lib.language == 'c' and 'zookeeper' in lib.get('external_deps', []):
846 $(LIBDIR)/$(CONFIG)/lib${lib.name}.$(SHARED_EXT)\
847 % endif
848 % endfor
Hongwei Wanga8cc4392015-07-16 17:37:47 -0700849
Craig Tiller841c8802015-09-10 13:06:37 -0700850 else
Hongwei Wanga8cc4392015-07-16 17:37:47 -0700851
Craig Tiller841c8802015-09-10 13:06:37 -0700852 static_zookeeper_libs:
Hongwei Wanga8cc4392015-07-16 17:37:47 -0700853
Craig Tiller841c8802015-09-10 13:06:37 -0700854 shared_zookeeper_libs:
Hongwei Wanga8cc4392015-07-16 17:37:47 -0700855
Craig Tiller841c8802015-09-10 13:06:37 -0700856 endif
Hongwei Wanga8cc4392015-07-16 17:37:47 -0700857
Craig Tiller841c8802015-09-10 13:06:37 -0700858 grpc_csharp_ext: shared_csharp
Jan Tattermusch2ec0b3e2015-02-18 15:03:12 -0800859
Craig Tiller841c8802015-09-10 13:06:37 -0700860 plugins: $(PROTOC_PLUGINS)
Nicolas "Pixel" Noble522d7122015-02-19 01:28:02 +0100861
Craig Tiller841c8802015-09-10 13:06:37 -0700862 privatelibs: privatelibs_c privatelibs_cxx
nnoble29e1d292014-12-01 10:27:40 -0800863
Craig Tiller841c8802015-09-10 13:06:37 -0700864 privatelibs_c: \
865 % for lib in libs:
Craig Tiller0fe5ee72015-12-22 12:50:36 -0800866 % 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 -0700867 $(LIBDIR)/$(CONFIG)/lib${lib.name}.a\
868 % endif
869 % endfor
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800870
Craig Tiller841c8802015-09-10 13:06:37 -0700871 pc_gpr: $(LIBDIR)/$(CONFIG)/pkgconfig/gpr.pc
murgatroid998faab232015-06-30 17:24:21 -0700872
Craig Tiller841c8802015-09-10 13:06:37 -0700873 pc_c: $(LIBDIR)/$(CONFIG)/pkgconfig/grpc.pc
murgatroid998faab232015-06-30 17:24:21 -0700874
Craig Tiller841c8802015-09-10 13:06:37 -0700875 pc_c_unsecure: $(LIBDIR)/$(CONFIG)/pkgconfig/grpc_unsecure.pc
murgatroid998faab232015-06-30 17:24:21 -0700876
Craig Tiller841c8802015-09-10 13:06:37 -0700877 ifeq ($(HAS_ZOOKEEPER),true)
878 pc_c_zookeeper: $(LIBDIR)/$(CONFIG)/pkgconfig/grpc_zookeeper.pc
879 else
880 pc_c_zookeeper:
881 endif
Hongwei Wanga3780a82015-07-17 15:27:18 -0700882
Craig Tiller841c8802015-09-10 13:06:37 -0700883 pc_cxx: $(LIBDIR)/$(CONFIG)/pkgconfig/grpc++.pc
murgatroid998faab232015-06-30 17:24:21 -0700884
Craig Tiller841c8802015-09-10 13:06:37 -0700885 pc_cxx_unsecure: $(LIBDIR)/$(CONFIG)/pkgconfig/grpc++_unsecure.pc
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800886
Craig Tiller841c8802015-09-10 13:06:37 -0700887 privatelibs_cxx: \
888 % for lib in libs:
889 % if lib.build == 'private' and lib.language == 'c++' and not lib.get('external_deps', None):
890 $(LIBDIR)/$(CONFIG)/lib${lib.name}.a\
891 % endif
892 % endfor
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800893
894
Craig Tiller841c8802015-09-10 13:06:37 -0700895 ifeq ($(HAS_ZOOKEEPER),true)
896 privatelibs_zookeeper: \
897 % for lib in libs:
898 % if lib.build == 'private' and lib.language == 'c++' and zookeeper in lib.get('external_deps', []):
899 $(LIBDIR)/$(CONFIG)/lib${lib.name}.a\
900 % endif
901 % endfor
Hongwei Wang8e04d412015-07-31 15:12:51 -0700902
Craig Tiller841c8802015-09-10 13:06:37 -0700903 else
904 privatelibs_zookeeper:
905 endif
Hongwei Wang8e04d412015-07-31 15:12:51 -0700906
907
Craig Tiller841c8802015-09-10 13:06:37 -0700908 buildtests: buildtests_c buildtests_cxx buildtests_zookeeper
nnoble29e1d292014-12-01 10:27:40 -0800909
Craig Tiller3824b6e2015-12-09 11:19:59 -0800910 buildtests_c: privatelibs_c <%text>\</%text>
Craig Tiller841c8802015-09-10 13:06:37 -0700911 % for tgt in targets:
912 % if tgt.build == 'test' and not tgt.language == 'c++' and not tgt.get('external_deps', None):
Craig Tiller3824b6e2015-12-09 11:19:59 -0800913 $(BINDIR)/$(CONFIG)/${tgt.name} <%text>\</%text>
Craig Tiller841c8802015-09-10 13:06:37 -0700914 % endif
915 % endfor
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800916
917
Craig Tiller3824b6e2015-12-09 11:19:59 -0800918 buildtests_cxx: buildtests_zookeeper privatelibs_cxx <%text>\</%text>
Craig Tiller841c8802015-09-10 13:06:37 -0700919 % for tgt in targets:
920 % if tgt.build == 'test' and tgt.language == 'c++' and not tgt.get('external_deps', None):
Craig Tiller3824b6e2015-12-09 11:19:59 -0800921 $(BINDIR)/$(CONFIG)/${tgt.name} <%text>\</%text>
Craig Tiller841c8802015-09-10 13:06:37 -0700922 % endif
923 % endfor
nnoble29e1d292014-12-01 10:27:40 -0800924
925
Craig Tiller841c8802015-09-10 13:06:37 -0700926 ifeq ($(HAS_ZOOKEEPER),true)
Craig Tiller3824b6e2015-12-09 11:19:59 -0800927 buildtests_zookeeper: privatelibs_zookeeper <%text>\</%text>
Craig Tiller841c8802015-09-10 13:06:37 -0700928 % for tgt in targets:
929 % if tgt.build == 'test' and tgt.language == 'c++' and 'zookeeper' in tgt.get('external_deps', []):
Craig Tiller3824b6e2015-12-09 11:19:59 -0800930 $(BINDIR)/$(CONFIG)/${tgt.name} <%text>\</%text>
Craig Tiller841c8802015-09-10 13:06:37 -0700931 % endif
932 % endfor
nnoble29e1d292014-12-01 10:27:40 -0800933
Craig Tiller841c8802015-09-10 13:06:37 -0700934 else
935 buildtests_zookeeper:
936 endif
Hongwei Wang8e04d412015-07-31 15:12:51 -0700937
938
Craig Tiller841c8802015-09-10 13:06:37 -0700939 test: test_c test_cxx test_zookeeper
Hongwei Wang8e04d412015-07-31 15:12:51 -0700940
Craig Tiller841c8802015-09-10 13:06:37 -0700941 flaky_test: flaky_test_c flaky_test_cxx flaky_test_zookeeper
Nicolas "Pixel" Noble4251d562015-05-22 19:43:39 +0200942
Craig Tiller841c8802015-09-10 13:06:37 -0700943 test_c: buildtests_c
944 % for tgt in targets:
945 % 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):
946 $(E) "[RUN] Testing ${tgt.name}"
947 $(Q) $(BINDIR)/$(CONFIG)/${tgt.name} || ( echo test ${tgt.name} failed ; exit 1 )
948 % endif
949 % endfor
Nicolas "Pixel" Noble4251d562015-05-22 19:43:39 +0200950
951
Craig Tiller841c8802015-09-10 13:06:37 -0700952 flaky_test_c: buildtests_c
953 % for tgt in targets:
954 % 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):
955 $(E) "[RUN] Testing ${tgt.name}"
956 $(Q) $(BINDIR)/$(CONFIG)/${tgt.name} || ( echo test ${tgt.name} failed ; exit 1 )
957 % endif
958 % endfor
nnoble29e1d292014-12-01 10:27:40 -0800959
960
Craig Tiller841c8802015-09-10 13:06:37 -0700961 test_cxx: test_zookeeper buildtests_cxx
962 % for tgt in targets:
963 % 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):
964 $(E) "[RUN] Testing ${tgt.name}"
965 $(Q) $(BINDIR)/$(CONFIG)/${tgt.name} || ( echo test ${tgt.name} failed ; exit 1 )
966 % endif
967 % endfor
Nicolas "Pixel" Noble4251d562015-05-22 19:43:39 +0200968
969
Craig Tiller841c8802015-09-10 13:06:37 -0700970 flaky_test_cxx: buildtests_cxx
971 % for tgt in targets:
972 % 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):
973 $(E) "[RUN] Testing ${tgt.name}"
974 $(Q) $(BINDIR)/$(CONFIG)/${tgt.name} || ( echo test ${tgt.name} failed ; exit 1 )
975 % endif
976 % endfor
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800977
978
Craig Tiller841c8802015-09-10 13:06:37 -0700979 ifeq ($(HAS_ZOOKEEPER),true)
980 test_zookeeper: buildtests_zookeeper
981 % for tgt in targets:
982 % 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', []):
983 $(E) "[RUN] Testing ${tgt.name}"
984 $(Q) $(BINDIR)/$(CONFIG)/${tgt.name} || ( echo test ${tgt.name} failed ; exit 1 )
985 % endif
986 % endfor
Hongwei Wang8e04d412015-07-31 15:12:51 -0700987
988
Craig Tiller841c8802015-09-10 13:06:37 -0700989 flaky_test_zookeeper: buildtests_zookeeper
990 % for tgt in targets:
991 % 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', []):
992 $(E) "[RUN] Testing ${tgt.name}"
993 $(Q) $(BINDIR)/$(CONFIG)/${tgt.name} || ( echo test ${tgt.name} failed ; exit 1 )
994 % endif
995 % endfor
Hongwei Wang8e04d412015-07-31 15:12:51 -0700996
Craig Tiller841c8802015-09-10 13:06:37 -0700997 else
998 test_zookeeper:
999 flaky_test_zookeeper:
1000 endif
Hongwei Wang8e04d412015-07-31 15:12:51 -07001001
1002
Craig Tiller841c8802015-09-10 13:06:37 -07001003 test_python: static_c
1004 $(E) "[RUN] Testing python code"
1005 $(Q) tools/run_tests/run_tests.py -lpython -c$(CONFIG)
Nicolas "Pixel" Noble051a28f2015-03-17 22:54:54 +01001006
1007
Craig Tiller841c8802015-09-10 13:06:37 -07001008 tools: tools_c tools_cxx
Craig Tiller7552f0f2015-06-19 17:46:20 -07001009
1010
Craig Tiller841c8802015-09-10 13:06:37 -07001011 tools_c: privatelibs_c\
1012 % for tgt in targets:
1013 % if tgt.build == 'tool' and not tgt.language=='c++':
1014 $(BINDIR)/$(CONFIG)/${tgt.name}\
1015 % endif
1016 % endfor
Craig Tiller7552f0f2015-06-19 17:46:20 -07001017
1018
Craig Tiller841c8802015-09-10 13:06:37 -07001019 tools_cxx: privatelibs_cxx\
1020 % for tgt in targets:
1021 % if tgt.build == 'tool' and tgt.language=='c++':
1022 $(BINDIR)/$(CONFIG)/${tgt.name}\
1023 % endif
1024 % endfor
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001025
1026
Craig Tiller841c8802015-09-10 13:06:37 -07001027 buildbenchmarks: privatelibs\
1028 % for tgt in targets:
1029 % if tgt.build == 'benchmark':
1030 $(BINDIR)/$(CONFIG)/${tgt.name}\
1031 % endif
1032 % endfor
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001033
1034
Craig Tiller841c8802015-09-10 13:06:37 -07001035 benchmarks: buildbenchmarks
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001036
Craig Tiller841c8802015-09-10 13:06:37 -07001037 strip: strip-static strip-shared
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001038
Craig Tiller841c8802015-09-10 13:06:37 -07001039 strip-static: strip-static_c strip-static_cxx
nnoble20e2e3f2014-12-16 15:37:57 -08001040
Craig Tiller841c8802015-09-10 13:06:37 -07001041 strip-shared: strip-shared_c strip-shared_cxx
nnoble20e2e3f2014-12-16 15:37:57 -08001042
Nicolas Noble047b7272015-01-16 13:55:05 -08001043
Craig Tiller841c8802015-09-10 13:06:37 -07001044 # TODO(nnoble): the strip target is stripping in-place, instead
1045 # of copying files in a temporary folder.
1046 # This prevents proper debugging after running make install.
Nicolas Noble047b7272015-01-16 13:55:05 -08001047
Craig Tiller841c8802015-09-10 13:06:37 -07001048 strip-static_c: static_c
1049 ifeq ($(CONFIG),opt)
1050 % for lib in libs:
1051 % if lib.language == "c":
1052 % if lib.build == "all":
1053 % if not lib.get('external_deps', None):
1054 $(E) "[STRIP] Stripping lib${lib.name}.a"
1055 $(Q) $(STRIP) $(LIBDIR)/$(CONFIG)/lib${lib.name}.a
1056 % endif
1057 % endif
1058 % endif
1059 % endfor
1060 ifeq ($(HAS_ZOOKEEPER),true)
1061 % for lib in libs:
1062 % if lib.language == "c":
1063 % if lib.build == "all":
1064 % if 'zookeeper' in lib.get('external_deps', []):
1065 $(E) "[STRIP] Stripping lib${lib.name}.a"
1066 $(Q) $(STRIP) $(LIBDIR)/$(CONFIG)/lib${lib.name}.a
1067 % endif
1068 % endif
1069 % endif
1070 % endfor
1071 endif
1072 endif
nnoble85a49262014-12-08 18:14:03 -08001073
Craig Tiller841c8802015-09-10 13:06:37 -07001074 strip-static_cxx: static_cxx
1075 ifeq ($(CONFIG),opt)
1076 % for lib in libs:
1077 % if lib.language == "c++":
1078 % if lib.build == "all":
1079 $(E) "[STRIP] Stripping lib${lib.name}.a"
1080 $(Q) $(STRIP) $(LIBDIR)/$(CONFIG)/lib${lib.name}.a
1081 % endif
1082 % endif
1083 % endfor
1084 endif
Nicolas "Pixel" Noble4ef9b862015-08-14 19:35:24 +02001085
Craig Tiller841c8802015-09-10 13:06:37 -07001086 strip-shared_c: shared_c
1087 ifeq ($(CONFIG),opt)
1088 % for lib in libs:
1089 % if lib.language == "c":
1090 % if lib.build == "all":
1091 % if not lib.get('external_deps', None):
1092 $(E) "[STRIP] Stripping lib${lib.name}.so"
1093 $(Q) $(STRIP) $(LIBDIR)/$(CONFIG)/lib${lib.name}.$(SHARED_EXT)
1094 % endif
1095 % endif
1096 % endif
1097 % endfor
1098 ifeq ($(HAS_ZOOKEEPER),true)
1099 % for lib in libs:
1100 % if lib.language == "c":
1101 % if lib.build == "all":
1102 % if 'zookeeper' in lib.get('external_deps', []):
1103 $(E) "[STRIP] Stripping lib${lib.name}.so"
1104 $(Q) $(STRIP) $(LIBDIR)/$(CONFIG)/lib${lib.name}.$(SHARED_EXT)
1105 % endif
1106 % endif
1107 % endif
1108 % endfor
1109 endif
1110 endif
nnoble85a49262014-12-08 18:14:03 -08001111
Craig Tiller841c8802015-09-10 13:06:37 -07001112 strip-shared_cxx: shared_cxx
1113 ifeq ($(CONFIG),opt)
1114 % for lib in libs:
1115 % if lib.language == "c++":
1116 % if lib.build == "all":
1117 $(E) "[STRIP] Stripping lib${lib.name}.so"
1118 $(Q) $(STRIP) $(LIBDIR)/$(CONFIG)/lib${lib.name}.$(SHARED_EXT)
1119 % endif
1120 % endif
1121 % endfor
1122 endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001123
Craig Tiller841c8802015-09-10 13:06:37 -07001124 strip-shared_csharp: shared_csharp
1125 ifeq ($(CONFIG),opt)
1126 % for lib in libs:
1127 % if lib.language == "csharp":
1128 % if lib.build == "all":
1129 $(E) "[STRIP] Stripping lib${lib.name}.so"
1130 $(Q) $(STRIP) $(LIBDIR)/$(CONFIG)/lib${lib.name}.$(SHARED_EXT)
1131 % endif
1132 % endif
1133 % endfor
1134 endif
Jan Tattermusch2ec0b3e2015-02-18 15:03:12 -08001135
Craig Tiller841c8802015-09-10 13:06:37 -07001136 cache.mk::
1137 $(E) "[MAKE] Generating $@"
1138 $(Q) echo "$(CACHE_MK)" | tr , '\n' >$@
murgatroid99aa521572015-07-10 14:49:12 -07001139
Craig Tiller841c8802015-09-10 13:06:37 -07001140 $(LIBDIR)/$(CONFIG)/pkgconfig/gpr.pc:
1141 $(E) "[MAKE] Generating $@"
1142 $(Q) mkdir -p $(@D)
1143 $(Q) echo "$(GPR_PC_FILE)" | tr , '\n' >$@
murgatroid998faab232015-06-30 17:24:21 -07001144
Craig Tiller841c8802015-09-10 13:06:37 -07001145 $(LIBDIR)/$(CONFIG)/pkgconfig/grpc.pc:
1146 $(E) "[MAKE] Generating $@"
1147 $(Q) mkdir -p $(@D)
1148 $(Q) echo "$(GRPC_PC_FILE)" | tr , '\n' >$@
murgatroid998faab232015-06-30 17:24:21 -07001149
Craig Tiller841c8802015-09-10 13:06:37 -07001150 $(LIBDIR)/$(CONFIG)/pkgconfig/grpc_unsecure.pc:
1151 $(E) "[MAKE] Generating $@"
1152 $(Q) mkdir -p $(@D)
1153 $(Q) echo "$(GRPC_UNSECURE_PC_FILE)" | tr , '\n' >$@
murgatroid998faab232015-06-30 17:24:21 -07001154
Craig Tiller841c8802015-09-10 13:06:37 -07001155 $(LIBDIR)/$(CONFIG)/pkgconfig/grpc_zookeeper.pc:
1156 $(E) "[MAKE] Generating $@"
1157 $(Q) mkdir -p $(@D)
1158 $(Q) echo -e "$(GRPC_ZOOKEEPER_PC_FILE)" >$@
Hongwei Wanga8cc4392015-07-16 17:37:47 -07001159
Craig Tiller841c8802015-09-10 13:06:37 -07001160 $(LIBDIR)/$(CONFIG)/pkgconfig/grpc++.pc:
1161 $(E) "[MAKE] Generating $@"
1162 $(Q) mkdir -p $(@D)
1163 $(Q) echo "$(GRPCXX_PC_FILE)" | tr , '\n' >$@
murgatroid998faab232015-06-30 17:24:21 -07001164
Craig Tiller841c8802015-09-10 13:06:37 -07001165 $(LIBDIR)/$(CONFIG)/pkgconfig/grpc++_unsecure.pc:
1166 $(E) "[MAKE] Generating $@"
1167 $(Q) mkdir -p $(@D)
1168 $(Q) echo "$(GRPCXX_UNSECURE_PC_FILE)" | tr , '\n' >$@
murgatroid998faab232015-06-30 17:24:21 -07001169
Craig Tiller841c8802015-09-10 13:06:37 -07001170 % for p in protos:
1171 ifeq ($(NO_PROTOC),true)
1172 $(GENDIR)/${p}.pb.cc: protoc_dep_error
1173 $(GENDIR)/${p}.grpc.pb.cc: protoc_dep_error
1174 else
Craig Tiller1b4e3302015-12-17 16:35:00 -08001175 $(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 -07001176 $(E) "[PROTOC] Generating protobuf CC file from $<"
1177 $(Q) mkdir -p `dirname $@`
1178 $(Q) $(PROTOC) --cpp_out=$(GENDIR) $<
Nicolas "Pixel" Noble0caebbf2015-04-09 23:08:51 +02001179
Craig Tiller1b4e3302015-12-17 16:35:00 -08001180 $(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 -07001181 $(E) "[GRPC] Generating gRPC's protobuf service CC file from $<"
1182 $(Q) mkdir -p `dirname $@`
1183 $(Q) $(PROTOC) --grpc_out=$(GENDIR) --plugin=protoc-gen-grpc=$(BINDIR)/$(CONFIG)/grpc_cpp_plugin $<
1184 endif
nnoble72309c62014-12-12 11:42:26 -08001185
Craig Tiller841c8802015-09-10 13:06:37 -07001186 % endfor
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001187
Craig Tiller841c8802015-09-10 13:06:37 -07001188 ifeq ($(CONFIG),stapprof)
1189 src/core/profiling/stap_timers.c: $(GENDIR)/src/core/profiling/stap_probes.h
1190 ifeq ($(HAS_SYSTEMTAP),true)
1191 $(GENDIR)/src/core/profiling/stap_probes.h: src/core/profiling/stap_probes.d
1192 $(E) "[DTRACE] Compiling $<"
1193 $(Q) mkdir -p `dirname $@`
1194 $(Q) $(DTRACE) -C -h -s $< -o $@
1195 else
1196 $(GENDIR)/src/core/profiling/stap_probes.h: systemtap_dep_error stop
1197 endif
1198 endif
David Garcia Quintas611b7362015-04-27 15:49:31 -07001199
Craig Tiller841c8802015-09-10 13:06:37 -07001200 $(OBJDIR)/$(CONFIG)/%.o : %.c
1201 $(E) "[C] Compiling $<"
1202 $(Q) mkdir -p `dirname $@`
Nicolas "Pixel" Noble45000342016-01-28 05:04:45 +01001203 $(Q) $(CC) $(CPPFLAGS) $(CFLAGS) -MMD -MF $(addsuffix .dep, $(basename $@)) -c -o $@ $<
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001204
Craig Tiller841c8802015-09-10 13:06:37 -07001205 $(OBJDIR)/$(CONFIG)/%.o : $(GENDIR)/%.pb.cc
1206 $(E) "[CXX] Compiling $<"
1207 $(Q) mkdir -p `dirname $@`
Nicolas "Pixel" Noble45000342016-01-28 05:04:45 +01001208 $(Q) $(CXX) $(CPPFLAGS) $(CXXFLAGS) -MMD -MF $(addsuffix .dep, $(basename $@)) -c -o $@ $<
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001209
Craig Tiller841c8802015-09-10 13:06:37 -07001210 $(OBJDIR)/$(CONFIG)/src/compiler/%.o : src/compiler/%.cc
1211 $(E) "[HOSTCXX] Compiling $<"
1212 $(Q) mkdir -p `dirname $@`
1213 $(Q) $(HOST_CXX) $(HOST_CXXFLAGS) $(HOST_CPPFLAGS) -MMD -MF $(addsuffix .dep, $(basename $@)) -c -o $@ $<
nnoble72309c62014-12-12 11:42:26 -08001214
Craig Tiller841c8802015-09-10 13:06:37 -07001215 $(OBJDIR)/$(CONFIG)/%.o : %.cc
1216 $(E) "[CXX] Compiling $<"
1217 $(Q) mkdir -p `dirname $@`
Nicolas "Pixel" Noble45000342016-01-28 05:04:45 +01001218 $(Q) $(CXX) $(CPPFLAGS) $(CXXFLAGS) -MMD -MF $(addsuffix .dep, $(basename $@)) -c -o $@ $<
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001219
Craig Tiller841c8802015-09-10 13:06:37 -07001220 install: install_c install_cxx install-plugins install-certs verify-install
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001221
Craig Tiller841c8802015-09-10 13:06:37 -07001222 install_c: install-headers_c install-static_c install-shared_c
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001223
Craig Tiller841c8802015-09-10 13:06:37 -07001224 install_cxx: install-headers_cxx install-static_cxx install-shared_cxx
nnoble85a49262014-12-08 18:14:03 -08001225
Craig Tiller841c8802015-09-10 13:06:37 -07001226 install_csharp: install-shared_csharp install_c
Jan Tattermusch2ec0b3e2015-02-18 15:03:12 -08001227
Craig Tiller841c8802015-09-10 13:06:37 -07001228 install_grpc_csharp_ext: install_csharp
Jan Tattermusch2ec0b3e2015-02-18 15:03:12 -08001229
Craig Tiller841c8802015-09-10 13:06:37 -07001230 install-headers: install-headers_c install-headers_cxx
nnoble85a49262014-12-08 18:14:03 -08001231
Craig Tiller841c8802015-09-10 13:06:37 -07001232 install-headers_c:
1233 $(E) "[INSTALL] Installing public C headers"
1234 $(Q) $(foreach h, $(PUBLIC_HEADERS_C), $(INSTALL) -d $(prefix)/$(dir $(h)) && ) exit 0 || exit 1
1235 $(Q) $(foreach h, $(PUBLIC_HEADERS_C), $(INSTALL) $(h) $(prefix)/$(h) && ) exit 0 || exit 1
nnoble85a49262014-12-08 18:14:03 -08001236
Craig Tiller841c8802015-09-10 13:06:37 -07001237 install-headers_cxx:
1238 $(E) "[INSTALL] Installing public C++ headers"
1239 $(Q) $(foreach h, $(PUBLIC_HEADERS_CXX), $(INSTALL) -d $(prefix)/$(dir $(h)) && ) exit 0 || exit 1
1240 $(Q) $(foreach h, $(PUBLIC_HEADERS_CXX), $(INSTALL) $(h) $(prefix)/$(h) && ) exit 0 || exit 1
nnoble85a49262014-12-08 18:14:03 -08001241
Craig Tiller841c8802015-09-10 13:06:37 -07001242 install-static: install-static_c install-static_cxx
nnoble85a49262014-12-08 18:14:03 -08001243
Craig Tiller841c8802015-09-10 13:06:37 -07001244 install-static_c: static_c strip-static_c install-pkg-config_c
1245 % for lib in libs:
1246 % if lib.language == "c":
1247 % if lib.build == "all":
1248 % if not lib.get('external_deps', None):
1249 $(E) "[INSTALL] Installing lib${lib.name}.a"
1250 $(Q) $(INSTALL) -d $(prefix)/lib
1251 $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/lib${lib.name}.a $(prefix)/lib/lib${lib.name}.a
1252 % endif
1253 % endif
1254 % endif
1255 % endfor
1256 ifeq ($(HAS_ZOOKEEPER),true)
1257 % for lib in libs:
1258 % if lib.language == "c":
1259 % if lib.build == "all":
1260 % if 'zookeeper' in lib.get('external_deps', []):
1261 $(E) "[INSTALL] Installing lib${lib.name}.a"
1262 $(Q) $(INSTALL) -d $(prefix)/lib
1263 $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/lib${lib.name}.a $(prefix)/lib/lib${lib.name}.a
1264 % endif
1265 % endif
1266 % endif
1267 % endfor
1268 endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001269
Craig Tiller841c8802015-09-10 13:06:37 -07001270 install-static_cxx: static_cxx strip-static_cxx install-pkg-config_cxx
1271 % for lib in libs:
1272 % if lib.language == "c++":
1273 % if lib.build == "all":
1274 $(E) "[INSTALL] Installing lib${lib.name}.a"
1275 $(Q) $(INSTALL) -d $(prefix)/lib
1276 $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/lib${lib.name}.a $(prefix)/lib/lib${lib.name}.a
1277 % endif
1278 % endif
1279 % endfor
nnoble85a49262014-12-08 18:14:03 -08001280
Craig Tiller841c8802015-09-10 13:06:37 -07001281 <%def name="install_shared(lang_filter)">\
1282 % for lib in libs:
1283 % if lib.language == lang_filter:
1284 % if lib.build == "all":
1285 % if not lib.get('external_deps', None):
1286 ifeq ($(SYSTEM),MINGW32)
1287 $(E) "[INSTALL] Installing ${lib.name}.$(SHARED_EXT)"
1288 $(Q) $(INSTALL) -d $(prefix)/lib
1289 $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/${lib.name}.$(SHARED_EXT) $(prefix)/lib/${lib.name}.$(SHARED_EXT)
1290 $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/lib${lib.name}-imp.a $(prefix)/lib/lib${lib.name}-imp.a
1291 else
1292 $(E) "[INSTALL] Installing lib${lib.name}.$(SHARED_EXT)"
1293 $(Q) $(INSTALL) -d $(prefix)/lib
1294 $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/lib${lib.name}.$(SHARED_EXT) $(prefix)/lib/lib${lib.name}.$(SHARED_EXT)
1295 ifneq ($(SYSTEM),Darwin)
1296 $(Q) ln -sf lib${lib.name}.$(SHARED_EXT) $(prefix)/lib/lib${lib.name}.so.${settings.version.major}
1297 $(Q) ln -sf lib${lib.name}.$(SHARED_EXT) $(prefix)/lib/lib${lib.name}.so
1298 endif
1299 endif
1300 % endif
1301 % endif
1302 % endif
1303 % endfor
1304 ifeq ($(HAS_ZOOKEEPER),true)
1305 % for lib in libs:
1306 % if lib.language == lang_filter:
1307 % if lib.build == "all":
1308 % if 'zookeeper' in lib.get('external_deps', []):
1309 ifeq ($(SYSTEM),MINGW32)
1310 $(E) "[INSTALL] Installing ${lib.name}.$(SHARED_EXT)"
1311 $(Q) $(INSTALL) -d $(prefix)/lib
1312 $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/${lib.name}.$(SHARED_EXT) $(prefix)/lib/${lib.name}.$(SHARED_EXT)
1313 $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/lib${lib.name}-imp.a $(prefix)/lib/lib${lib.name}-imp.a
1314 else
1315 $(E) "[INSTALL] Installing lib${lib.name}.$(SHARED_EXT)"
1316 $(Q) $(INSTALL) -d $(prefix)/lib
1317 $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/lib${lib.name}.$(SHARED_EXT) $(prefix)/lib/lib${lib.name}.$(SHARED_EXT)
1318 ifneq ($(SYSTEM),Darwin)
1319 $(Q) ln -sf lib${lib.name}.$(SHARED_EXT) $(prefix)/lib/lib${lib.name}.so.${settings.version.major}
1320 $(Q) ln -sf lib${lib.name}.$(SHARED_EXT) $(prefix)/lib/lib${lib.name}.so
1321 endif
1322 endif
1323 % endif
1324 % endif
1325 % endif
1326 % endfor
1327 endif
1328 ifneq ($(SYSTEM),MINGW32)
1329 ifneq ($(SYSTEM),Darwin)
1330 $(Q) ldconfig || true
1331 endif
1332 endif
1333 </%def>
nnoble85a49262014-12-08 18:14:03 -08001334
Craig Tiller841c8802015-09-10 13:06:37 -07001335 install-shared_c: shared_c strip-shared_c install-pkg-config_c
1336 ${install_shared("c")}
Nicolas "Pixel" Noble522d7122015-02-19 01:28:02 +01001337
Craig Tiller841c8802015-09-10 13:06:37 -07001338 install-shared_cxx: shared_cxx strip-shared_cxx install-shared_c install-pkg-config_cxx
1339 ${install_shared("c++")}
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001340
Craig Tiller841c8802015-09-10 13:06:37 -07001341 install-shared_csharp: shared_csharp strip-shared_csharp
1342 ${install_shared("csharp")}
Nicolas "Pixel" Noble522d7122015-02-19 01:28:02 +01001343
Craig Tiller841c8802015-09-10 13:06:37 -07001344 install-plugins: $(PROTOC_PLUGINS)
1345 ifeq ($(SYSTEM),MINGW32)
1346 $(Q) false
1347 else
1348 $(E) "[INSTALL] Installing grpc protoc plugins"
1349 % for tgt in targets:
1350 % if tgt.build == 'protoc':
1351 $(Q) $(INSTALL) -d $(prefix)/bin
1352 $(Q) $(INSTALL) $(BINDIR)/$(CONFIG)/${tgt.name} $(prefix)/bin/${tgt.name}
1353 % endif
1354 % endfor
1355 endif
Jan Tattermusch2ec0b3e2015-02-18 15:03:12 -08001356
Craig Tiller841c8802015-09-10 13:06:37 -07001357 install-pkg-config_c: pc_gpr pc_c pc_c_unsecure pc_c_zookeeper
1358 $(E) "[INSTALL] Installing C pkg-config files"
1359 $(Q) $(INSTALL) -d $(prefix)/lib/pkgconfig
1360 $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/pkgconfig/gpr.pc $(prefix)/lib/pkgconfig/gpr.pc
1361 $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/pkgconfig/grpc.pc $(prefix)/lib/pkgconfig/grpc.pc
1362 $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/pkgconfig/grpc_unsecure.pc $(prefix)/lib/pkgconfig/grpc_unsecure.pc
1363 ifeq ($(HAS_ZOOKEEPER),true)
1364 $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/pkgconfig/grpc_zookeeper.pc $(prefix)/lib/pkgconfig/grpc_zookeeper.pc
1365 endif
murgatroid998faab232015-06-30 17:24:21 -07001366
Craig Tiller841c8802015-09-10 13:06:37 -07001367 install-pkg-config_cxx: pc_cxx pc_cxx_unsecure
1368 $(E) "[INSTALL] Installing C++ pkg-config files"
1369 $(Q) $(INSTALL) -d $(prefix)/lib/pkgconfig
1370 $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/pkgconfig/grpc++.pc $(prefix)/lib/pkgconfig/grpc++.pc
1371 $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/pkgconfig/grpc++_unsecure.pc $(prefix)/lib/pkgconfig/grpc++_unsecure.pc
murgatroid998faab232015-06-30 17:24:21 -07001372
Craig Tiller841c8802015-09-10 13:06:37 -07001373 install-certs: etc/roots.pem
1374 $(E) "[INSTALL] Installing root certificates"
1375 $(Q) $(INSTALL) -d $(prefix)/share/grpc
1376 $(Q) $(INSTALL) etc/roots.pem $(prefix)/share/grpc/roots.pem
Nicolas "Pixel" Noble161ea232015-02-22 05:48:53 +01001377
Craig Tiller841c8802015-09-10 13:06:37 -07001378 verify-install:
1379 ifeq ($(INSTALL_OK),true)
1380 @echo "Your system looks ready to go."
1381 @echo
1382 else
1383 @echo "We couldn't find protoc 3.0.0+ installed on your system. While this"
1384 @echo "won't prevent grpc from working, you won't be able to compile"
1385 @echo "and run any meaningful code with it."
1386 @echo
1387 @echo
1388 @echo "Please download and install protobuf 3.0.0+ from:"
1389 @echo
1390 @echo " https://github.com/google/protobuf/releases"
1391 @echo
1392 @echo "Once you've done so, or if you think this message is in error,"
1393 @echo "you can re-run this check by doing:"
1394 @echo
1395 @echo " make verify-install"
1396 endif
Nicolas "Pixel" Noble98ab9982015-02-21 04:22:16 +01001397
Craig Tiller841c8802015-09-10 13:06:37 -07001398 clean:
1399 $(E) "[CLEAN] Cleaning build directories."
1400 $(Q) $(RM) -rf $(OBJDIR) $(LIBDIR) $(BINDIR) $(GENDIR) cache.mk
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001401
1402
Craig Tiller841c8802015-09-10 13:06:37 -07001403 # The various libraries
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001404
Craig Tiller841c8802015-09-10 13:06:37 -07001405 % for lib in libs:
1406 ${makelib(lib)}
1407 % endfor
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001408
1409
Craig Tiller841c8802015-09-10 13:06:37 -07001410 # All of the test targets, and protoc plugins
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001411
Craig Tiller841c8802015-09-10 13:06:37 -07001412 % for tgt in targets:
1413 ${maketarget(tgt)}
1414 % endfor
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001415
Craig Tiller841c8802015-09-10 13:06:37 -07001416 <%def name="makelib(lib)">
1417 LIB${lib.name.upper()}_SRC = \\
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001418
Craig Tiller841c8802015-09-10 13:06:37 -07001419 % for src in lib.src:
1420 ${proto_to_cc(src)} \\
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001421
Craig Tiller841c8802015-09-10 13:06:37 -07001422 % endfor
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001423
Craig Tiller841c8802015-09-10 13:06:37 -07001424 % if "public_headers" in lib:
1425 % if lib.language == "c++":
1426 PUBLIC_HEADERS_CXX += \\
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001427
Craig Tiller841c8802015-09-10 13:06:37 -07001428 % else:
1429 PUBLIC_HEADERS_C += \\
nnoble85a49262014-12-08 18:14:03 -08001430
Craig Tiller841c8802015-09-10 13:06:37 -07001431 % endif
1432 % for hdr in lib.public_headers:
1433 ${hdr} \\
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001434
Craig Tiller841c8802015-09-10 13:06:37 -07001435 % endfor
1436 % endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001437
Craig Tiller841c8802015-09-10 13:06:37 -07001438 LIB${lib.name.upper()}_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(LIB${lib.name.upper()}_SRC))))
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001439
Nicolas "Pixel" Noble51b1aee2016-01-28 01:14:58 +01001440 % if lib.get('defaults', None):
1441 % for name, value in defaults.get(lib.defaults).iteritems():
1442 $(LIB${lib.name.upper()}_OBJS): ${name} += ${value}
1443 % endfor
Craig Tiller0fe5ee72015-12-22 12:50:36 -08001444 % endif
1445
Craig Tiller841c8802015-09-10 13:06:37 -07001446 ## If the library requires OpenSSL, let's add some restrictions.
1447 % if lib.get('secure', 'check') == True or lib.get('secure', 'check') == 'check':
1448 ifeq ($(NO_SECURE),true)
nnoble69ac39f2014-12-12 15:43:38 -08001449
Craig Tiller841c8802015-09-10 13:06:37 -07001450 # You can't build secure libraries if you don't have OpenSSL.
Nicolas Noble047b7272015-01-16 13:55:05 -08001451
Craig Tiller841c8802015-09-10 13:06:37 -07001452 $(LIBDIR)/$(CONFIG)/lib${lib.name}.a: openssl_dep_error
nnoble69ac39f2014-12-12 15:43:38 -08001453
Craig Tiller841c8802015-09-10 13:06:37 -07001454 % if lib.build == "all":
1455 ifeq ($(SYSTEM),MINGW32)
1456 $(LIBDIR)/$(CONFIG)/${lib.name}.$(SHARED_EXT): openssl_dep_error
1457 else
1458 $(LIBDIR)/$(CONFIG)/lib${lib.name}.$(SHARED_EXT): openssl_dep_error
1459 endif
1460 % endif
nnoble5b7f32a2014-12-22 08:12:44 -08001461
Craig Tiller841c8802015-09-10 13:06:37 -07001462 else
nnoble69ac39f2014-12-12 15:43:38 -08001463
Craig Tiller841c8802015-09-10 13:06:37 -07001464 % if lib.language == 'c++':
1465 ifeq ($(NO_PROTOBUF),true)
Nicolas Noble53830622015-02-12 16:56:38 -08001466
Craig Tiller841c8802015-09-10 13:06:37 -07001467 # 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 -08001468
Craig Tiller841c8802015-09-10 13:06:37 -07001469 $(LIBDIR)/$(CONFIG)/lib${lib.name}.a: protobuf_dep_error
Nicolas Noble53830622015-02-12 16:56:38 -08001470
Craig Tiller841c8802015-09-10 13:06:37 -07001471 % if lib.build == "all":
1472 ifeq ($(SYSTEM),MINGW32)
1473 $(LIBDIR)/$(CONFIG)/${lib.name}.$(SHARED_EXT): protobuf_dep_error
1474 else
1475 $(LIBDIR)/$(CONFIG)/lib${lib.name}.$(SHARED_EXT): protobuf_dep_error
1476 endif
1477 % endif
Nicolas Noble53830622015-02-12 16:56:38 -08001478
Craig Tiller841c8802015-09-10 13:06:37 -07001479 else
1480 % endif
Nicolas Noble53830622015-02-12 16:56:38 -08001481
Craig Tiller841c8802015-09-10 13:06:37 -07001482 $(LIBDIR)/$(CONFIG)/lib${lib.name}.a: $(ZLIB_DEP) $(OPENSSL_DEP)\
1483 ## The else here corresponds to the if secure earlier.
1484 % else:
1485 % if lib.language == 'c++':
1486 ifeq ($(NO_PROTOBUF),true)
Nicolas Noble53830622015-02-12 16:56:38 -08001487
Craig Tiller841c8802015-09-10 13:06:37 -07001488 # 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 -08001489
Craig Tiller841c8802015-09-10 13:06:37 -07001490 $(LIBDIR)/$(CONFIG)/lib${lib.name}.a: protobuf_dep_error
Nicolas Noble53830622015-02-12 16:56:38 -08001491
Craig Tiller841c8802015-09-10 13:06:37 -07001492 % if lib.build == "all":
1493 ifeq ($(SYSTEM),MINGW32)
1494 $(LIBDIR)/$(CONFIG)/${lib.name}.$(SHARED_EXT): protobuf_dep_error
1495 else
1496 $(LIBDIR)/$(CONFIG)/lib${lib.name}.$(SHARED_EXT): protobuf_dep_error
1497 endif
1498 % endif
Nicolas Noble53830622015-02-12 16:56:38 -08001499
Craig Tiller841c8802015-09-10 13:06:37 -07001500 else
Nicolas Noble53830622015-02-12 16:56:38 -08001501
Craig Tiller841c8802015-09-10 13:06:37 -07001502 % endif
Nicolas "Pixel" Nobled649c212016-01-27 20:27:30 +01001503 $(LIBDIR)/$(CONFIG)/lib${lib.name}.a: \
1504 % if lib.name != 'z':
1505 $(ZLIB_DEP) \
1506 % endif
Craig Tiller841c8802015-09-10 13:06:37 -07001507 % endif
1508 % if lib.language == 'c++':
1509 $(PROTOBUF_DEP)\
1510 % endif
1511 $(LIB${lib.name.upper()}_OBJS)
1512 $(E) "[AR] Creating $@"
1513 $(Q) mkdir -p `dirname $@`
1514 $(Q) rm -f $(LIBDIR)/$(CONFIG)/lib${lib.name}.a
1515 $(Q) $(AR) rcs $(LIBDIR)/$(CONFIG)/lib${lib.name}.a $(LIB${lib.name.upper()}_OBJS)
1516 % if lib.get('baselib', False):
Craig Tiller0fe5ee72015-12-22 12:50:36 -08001517 $(Q) rm -rf $(BUILDDIR_ABSOLUTE)/tmp-merge-${lib.name}
1518 $(Q) ( mkdir -p $(BUILDDIR_ABSOLUTE)/tmp-merge-${lib.name}/grpc ; <%text>\</%text>
1519 cd $(BUILDDIR_ABSOLUTE)/tmp-merge-${lib.name}/grpc ; <%text>\</%text>
1520 $(AR) x $(LIBDIR)/$(CONFIG)/lib${lib.name}.a )
1521 $(Q) for l in $(ZLIB_MERGE_LIBS) ; do ( <%text>\</%text>
1522 mkdir -p $(BUILDDIR_ABSOLUTE)/tmp-merge-${lib.name}/zlib ; <%text>\</%text>
1523 cd $(BUILDDIR_ABSOLUTE)/tmp-merge-${lib.name}/zlib ; <%text>\</%text>
1524 <%text>$(AR) x $${l}</%text> ) ; done
1525 $(Q) for l in $(ZLIB_MERGE_LIBS) ; do ( <%text>\</%text>
1526 mkdir -p $(BUILDDIR_ABSOLUTE)/tmp-merge-${lib.name}/zlib ; <%text>\</%text>
1527 cd $(BUILDDIR_ABSOLUTE)/tmp-merge-${lib.name}/zlib ; <%text>\</%text>
1528 <%text>$(AR) x $${l}</%text> ) ; done
Craig Tiller841c8802015-09-10 13:06:37 -07001529 % if lib.get('secure', 'check') == True:
Craig Tiller0fe5ee72015-12-22 12:50:36 -08001530 $(Q) for l in $(OPENSSL_MERGE_LIBS) ; do ( <%text>\</%text>
1531 mkdir -p $(BUILDDIR_ABSOLUTE)/tmp-merge-${lib.name}/ssl ; <%text>\</%text>
1532 cd $(BUILDDIR_ABSOLUTE)/tmp-merge-${lib.name}/ssl ; <%text>\</%text>
1533 <%text>$(AR) x $${l}</%text> ) ; done
1534 $(Q) for l in $(OPENSSL_MERGE_LIBS) ; do ( <%text>\</%text>
1535 mkdir -p $(BUILDDIR_ABSOLUTE)/tmp-merge-${lib.name}/ssl ; <%text>\</%text>
1536 cd $(BUILDDIR_ABSOLUTE)/tmp-merge-${lib.name}/ssl ; <%text>\</%text>
1537 <%text>$(AR) x $${l}</%text> ) ; done
Craig Tiller841c8802015-09-10 13:06:37 -07001538 % endif
Craig Tiller0fe5ee72015-12-22 12:50:36 -08001539 $(Q) rm -f $(LIBDIR)/$(CONFIG)/lib${lib.name}.a $(BUILDDIR_ABSOLUTE)/tmp-merge-${lib.name}/*/__.SYMDEF*
1540 $(Q) ar rcs $(LIBDIR)/$(CONFIG)/lib${lib.name}.a $(BUILDDIR_ABSOLUTE)/tmp-merge-${lib.name}/*/*
1541 $(Q) rm -rf $(BUILDDIR_ABSOLUTE)/tmp-merge-${lib.name}
Craig Tiller841c8802015-09-10 13:06:37 -07001542 % endif
1543 ifeq ($(SYSTEM),Darwin)
1544 $(Q) ranlib $(LIBDIR)/$(CONFIG)/lib${lib.name}.a
1545 endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001546
Craig Tiller841c8802015-09-10 13:06:37 -07001547 <%
Nicolas "Pixel" Noble010f1e72015-04-23 02:23:49 +02001548
Craig Tiller841c8802015-09-10 13:06:37 -07001549 if lib.language == 'c++':
1550 ld = '$(LDXX)'
1551 else:
1552 ld = '$(LD)'
nnoble5b7f32a2014-12-22 08:12:44 -08001553
Craig Tiller841c8802015-09-10 13:06:37 -07001554 out_base = '$(LIBDIR)/$(CONFIG)/' + lib.name
1555 out_libbase = '$(LIBDIR)/$(CONFIG)/lib' + lib.name
nnoble5b7f32a2014-12-22 08:12:44 -08001556
Craig Tiller841c8802015-09-10 13:06:37 -07001557 common = '$(LIB' + lib.name.upper() + '_OBJS) $(LDLIBS)'
nnoble5b7f32a2014-12-22 08:12:44 -08001558
Craig Tiller841c8802015-09-10 13:06:37 -07001559 libs = ''
1560 lib_deps = ' $(ZLIB_DEP)'
1561 mingw_libs = ''
1562 mingw_lib_deps = ' $(ZLIB_DEP)'
1563 if lib.language == 'c++':
1564 lib_deps += ' $(PROTOBUF_DEP)'
1565 mingw_lib_deps += ' $(PROTOBUF_DEP)'
Jan Tattermusch324140c2016-01-12 08:54:01 -08001566 if lib.get('deps_linkage', None) == 'static':
1567 for dep in lib.get('deps', []):
1568 lib_archive = '$(LIBDIR)/$(CONFIG)/lib' + dep + '.a'
1569 common = common + ' ' + lib_archive
1570 lib_deps = lib_deps + ' ' + lib_archive
1571 mingw_lib_deps = mingw_lib_deps + ' ' + lib_archive
1572 else:
1573 for dep in lib.get('deps', []):
1574 libs = libs + ' -l' + dep
1575 lib_deps = lib_deps + ' $(LIBDIR)/$(CONFIG)/lib' + dep + '.$(SHARED_EXT)'
1576 mingw_libs = mingw_libs + ' -l' + dep + '-imp'
1577 mingw_lib_deps = mingw_lib_deps + ' $(LIBDIR)/$(CONFIG)/' + dep + '.$(SHARED_EXT)'
nnoble5b7f32a2014-12-22 08:12:44 -08001578
Craig Tiller841c8802015-09-10 13:06:37 -07001579 security = lib.get('secure', 'check')
1580 if security == True:
1581 common = common + ' $(OPENSSL_MERGE_LIBS) $(LDLIBS_SECURE)'
Craig Tiller0fe5ee72015-12-22 12:50:36 -08001582 common = common + ' $(ZLIB_MERGE_LIBS)'
Nicolas "Pixel" Noblea7c162c2015-07-24 20:21:51 +02001583
Craig Tiller841c8802015-09-10 13:06:37 -07001584 if security in [True, 'check']:
1585 for src in lib.src:
1586 if not proto_re.match(src):
1587 sources_that_need_openssl.add(src)
1588 else:
1589 for src in lib.src:
1590 sources_that_don_t_need_openssl.add(src)
Nicolas "Pixel" Noble061690d2015-03-06 22:58:58 +01001591
Craig Tiller841c8802015-09-10 13:06:37 -07001592 if 'zookeeper' in lib.get('external_deps', []):
1593 libs = libs + ' -lzookeeper_mt'
Hongwei Wanga8cc4392015-07-16 17:37:47 -07001594
Craig Tiller841c8802015-09-10 13:06:37 -07001595 if lib.get('secure', 'check') == True or lib.get('secure', 'check') == 'check':
1596 lib_deps = lib_deps + ' $(OPENSSL_DEP)'
1597 mingw_lib_deps = mingw_lib_deps + ' $(OPENSSL_DEP)'
Nicolas "Pixel" Nobledda049c2015-02-21 00:39:32 +01001598
Craig Tiller841c8802015-09-10 13:06:37 -07001599 if lib.language == 'c++':
1600 common = common + ' $(LDLIBSXX) $(LDLIBS_PROTOBUF)'
Craig Tiller4bef7ce2016-02-02 08:38:43 -08001601
1602 ldflags = '$(LDFLAGS)'
1603 if lib.get('LDFLAGS', None):
1604 ldflags += ' ' + lib['LDFLAGS']
Craig Tiller841c8802015-09-10 13:06:37 -07001605 %>
nnoble5b7f32a2014-12-22 08:12:44 -08001606
Craig Tiller841c8802015-09-10 13:06:37 -07001607 % if lib.build == "all":
1608 ifeq ($(SYSTEM),MINGW32)
1609 ${out_base}.$(SHARED_EXT): $(LIB${lib.name.upper()}_OBJS) ${mingw_lib_deps}
1610 $(E) "[LD] Linking $@"
1611 $(Q) mkdir -p `dirname $@`
Craig Tiller4bef7ce2016-02-02 08:38:43 -08001612 $(Q) ${ld} ${ldflags} -L$(LIBDIR)/$(CONFIG) -shared -Wl,--output-def=${out_base}.def -Wl,--out-implib=${out_libbase}-imp.a -o ${out_base}.$(SHARED_EXT) ${common}${mingw_libs}
Craig Tiller841c8802015-09-10 13:06:37 -07001613 else
1614 ${out_libbase}.$(SHARED_EXT): $(LIB${lib.name.upper()}_OBJS) ${lib_deps}
1615 $(E) "[LD] Linking $@"
1616 $(Q) mkdir -p `dirname $@`
1617 ifeq ($(SYSTEM),Darwin)
Craig Tiller4bef7ce2016-02-02 08:38:43 -08001618 $(Q) ${ld} ${ldflags} -L$(LIBDIR)/$(CONFIG) -install_name lib${lib.name}.$(SHARED_EXT) -dynamiclib -o ${out_libbase}.$(SHARED_EXT) ${common}${libs}
Craig Tiller841c8802015-09-10 13:06:37 -07001619 else
Craig Tiller4bef7ce2016-02-02 08:38:43 -08001620 $(Q) ${ld} ${ldflags} -L$(LIBDIR)/$(CONFIG) -shared -Wl,-soname,lib${lib.name}.so.${settings.version.major} -o ${out_libbase}.$(SHARED_EXT) ${common}${libs}
Craig Tiller841c8802015-09-10 13:06:37 -07001621 $(Q) ln -sf lib${lib.name}.$(SHARED_EXT) ${out_libbase}.so.${settings.version.major}
1622 $(Q) ln -sf lib${lib.name}.$(SHARED_EXT) ${out_libbase}.so
1623 endif
1624 endif
1625 % endif
1626 % if lib.get('secure', 'check') == True or lib.get('secure', 'check') == 'check':
1627 ## If the lib was secure, we have to close the Makefile's if that tested
1628 ## the presence of OpenSSL.
Nicolas Noble53830622015-02-12 16:56:38 -08001629
Craig Tiller841c8802015-09-10 13:06:37 -07001630 endif
1631 % endif
1632 % if lib.language == 'c++':
1633 ## If the lib was C++, we have to close the Makefile's if that tested
1634 ## the presence of protobuf 3.0.0+
nnoble69ac39f2014-12-12 15:43:38 -08001635
Craig Tiller841c8802015-09-10 13:06:37 -07001636 endif
1637 % endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001638
Craig Tiller841c8802015-09-10 13:06:37 -07001639 % if lib.get('secure', 'check') == True or lib.get('secure', 'check') == 'check':
1640 ifneq ($(NO_SECURE),true)
1641 % endif
1642 ifneq ($(NO_DEPS),true)
1643 -include $(LIB${lib.name.upper()}_OBJS:.o=.dep)
1644 endif
1645 % if lib.get('secure', 'check') == True or lib.get('secure', 'check') == 'check':
1646 endif
1647 % endif
1648 % for src in lib.src:
1649 % if not proto_re.match(src) and any(proto_re.match(src2) for src2 in lib.src):
1650 $(OBJDIR)/$(CONFIG)/${os.path.splitext(src)[0]}.o: ${' '.join(proto_to_cc(src2) for src2 in lib.src if proto_re.match(src2))}
1651 % endif
1652 % endfor
1653 </%def>
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001654
Craig Tiller841c8802015-09-10 13:06:37 -07001655 <%def name="maketarget(tgt)"><% has_no_sources = not tgt.src %>
1656 % if not has_no_sources:
1657 ${tgt.name.upper()}_SRC = \\
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001658
Craig Tiller841c8802015-09-10 13:06:37 -07001659 % for src in tgt.src:
1660 ${proto_to_cc(src)} \\
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001661
Craig Tiller841c8802015-09-10 13:06:37 -07001662 % endfor
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001663
Craig Tiller841c8802015-09-10 13:06:37 -07001664 ${tgt.name.upper()}_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(${tgt.name.upper()}_SRC))))
1665 % endif
1666 % if tgt.get('secure', 'check') == True or tgt.get('secure', 'check') == 'check':
1667 ifeq ($(NO_SECURE),true)
nnoble69ac39f2014-12-12 15:43:38 -08001668
Craig Tiller841c8802015-09-10 13:06:37 -07001669 # You can't build secure targets if you don't have OpenSSL.
Nicolas Noble047b7272015-01-16 13:55:05 -08001670
Craig Tiller841c8802015-09-10 13:06:37 -07001671 $(BINDIR)/$(CONFIG)/${tgt.name}: openssl_dep_error
nnoble69ac39f2014-12-12 15:43:38 -08001672
Craig Tiller841c8802015-09-10 13:06:37 -07001673 else
nnoble69ac39f2014-12-12 15:43:38 -08001674
Craig Tiller841c8802015-09-10 13:06:37 -07001675 % endif
Craig Tiller0fe5ee72015-12-22 12:50:36 -08001676
1677 % if tgt.boringssl:
1678 # boringssl needs an override to ensure that it does not include
1679 # system openssl headers regardless of other configuration
1680 # we do so here with a target specific variable assignment
1681 $(${tgt.name.upper()}_OBJS): CFLAGS := -Ithird_party/boringssl/include $(CFLAGS) -Wno-sign-conversion -Wno-conversion -Wno-unused-value
1682 $(${tgt.name.upper()}_OBJS): CXXFLAGS := -Ithird_party/boringssl/include $(CXXFLAGS)
1683 $(${tgt.name.upper()}_OBJS): CPPFLAGS += -DOPENSSL_NO_ASM -D_GNU_SOURCE
1684 % else:
1685 % endif
1686
Craig Tiller841c8802015-09-10 13:06:37 -07001687 ##
1688 ## We're not trying to add a dependency on building zlib and openssl here,
1689 ## as it's already done in the libraries. We're assuming that the build
1690 ## trickles down, and that a secure target requires a secure version of
1691 ## a library.
1692 ##
1693 ## That simplifies the codegen a bit, but prevents a fully defined Makefile.
1694 ## I can live with that.
1695 ##
1696 % if tgt.build == 'protoc' or tgt.language == 'c++':
Nicolas Noble53830622015-02-12 16:56:38 -08001697
Craig Tiller841c8802015-09-10 13:06:37 -07001698 ifeq ($(NO_PROTOBUF),true)
Nicolas Noble53830622015-02-12 16:56:38 -08001699
Craig Tiller841c8802015-09-10 13:06:37 -07001700 # 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 -08001701
Craig Tiller841c8802015-09-10 13:06:37 -07001702 $(BINDIR)/$(CONFIG)/${tgt.name}: protobuf_dep_error
Nicolas Noble53830622015-02-12 16:56:38 -08001703
Craig Tiller841c8802015-09-10 13:06:37 -07001704 else
Nicolas Noble53830622015-02-12 16:56:38 -08001705
Craig Tiller841c8802015-09-10 13:06:37 -07001706 $(BINDIR)/$(CONFIG)/${tgt.name}: \
1707 % if not has_no_sources:
1708 $(PROTOBUF_DEP) $(${tgt.name.upper()}_OBJS)\
1709 % endif
1710 % else:
1711 $(BINDIR)/$(CONFIG)/${tgt.name}: \
1712 % if not has_no_sources:
1713 $(${tgt.name.upper()}_OBJS)\
1714 % endif
1715 % endif
1716 % for dep in tgt.deps:
1717 $(LIBDIR)/$(CONFIG)/lib${dep}.a\
1718 % endfor
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001719
Craig Tiller0fe5ee72015-12-22 12:50:36 -08001720 % if tgt.language == "c++" or tgt.boringssl:
Craig Tiller841c8802015-09-10 13:06:37 -07001721 ## C++ targets specificies.
1722 % if tgt.build == 'protoc':
1723 $(E) "[HOSTLD] Linking $@"
1724 $(Q) mkdir -p `dirname $@`
1725 $(Q) $(HOST_LDXX) $(HOST_LDFLAGS) \
1726 % if not has_no_sources:
1727 $(${tgt.name.upper()}_OBJS)\
1728 % endif
1729 % else:
1730 $(E) "[LD] Linking $@"
1731 $(Q) mkdir -p `dirname $@`
1732 $(Q) $(LDXX) $(LDFLAGS) \
1733 % if not has_no_sources:
1734 $(${tgt.name.upper()}_OBJS)\
1735 % endif
1736 % endif
1737 % else:
1738 ## C-only targets specificities.
1739 $(E) "[LD] Linking $@"
1740 $(Q) mkdir -p `dirname $@`
1741 $(Q) $(LD) $(LDFLAGS) \
1742 % if not has_no_sources:
1743 $(${tgt.name.upper()}_OBJS)\
1744 % endif
1745 % endif
1746 % for dep in tgt.deps:
1747 $(LIBDIR)/$(CONFIG)/lib${dep}.a\
1748 % endfor
1749 % if 'zookeeper' in tgt.get('external_deps', []):
1750 -lzookeeper_mt\
1751 % endif
1752 % if tgt.language == "c++":
1753 % if tgt.build == 'protoc':
1754 $(HOST_LDLIBSXX) $(HOST_LDLIBS_PROTOC)\
1755 % else:
1756 $(LDLIBSXX) $(LDLIBS_PROTOBUF)\
1757 % endif
1758 % endif
1759 % if tgt.build == 'protoc':
1760 $(HOST_LDLIBS)\
1761 % else:
1762 $(LDLIBS)\
1763 % endif
1764 % if tgt.build == 'protoc':
1765 $(HOST_LDLIBS_PROTOC)\
1766 % elif tgt.get('secure', 'check') == True or tgt.get('secure', 'check') == 'check':
1767 $(LDLIBS_SECURE)\
1768 % endif
1769 % if tgt.language == 'c++' and tgt.build == 'test':
1770 $(GTEST_LIB)\
1771 % elif tgt.language == 'c++' and tgt.build == 'benchmark':
1772 $(GTEST_LIB)\
1773 % endif
1774 -o $(BINDIR)/$(CONFIG)/${tgt.name}
1775 % if tgt.build == 'protoc' or tgt.language == 'c++':
Nicolas Noble53830622015-02-12 16:56:38 -08001776
Craig Tiller841c8802015-09-10 13:06:37 -07001777 endif
1778 % endif
1779 % if tgt.get('secure', 'check') == True or tgt.get('secure', 'check') == 'check':
nnoble69ac39f2014-12-12 15:43:38 -08001780
Craig Tiller841c8802015-09-10 13:06:37 -07001781 endif
1782 % endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001783
Craig Tiller841c8802015-09-10 13:06:37 -07001784 % for src in tgt.src:
1785 $(OBJDIR)/$(CONFIG)/${os.path.splitext(src)[0]}.o: \
1786 % for dep in tgt.deps:
1787 $(LIBDIR)/$(CONFIG)/lib${dep}.a\
1788 % endfor
Craig Tillerf5371ef2015-01-12 16:40:18 -08001789
Craig Tillerab230452016-01-04 08:18:43 -08001790 % if tgt.language == 'c89':
1791 % for src in tgt.src:
Craig Tillerea21ca22016-01-04 12:34:29 -08001792 $(OBJDIR)/$(CONFIG)/${os.path.splitext(src)[0]}.o : ${src}
1793 $(E) "[C] Compiling $<"
1794 $(Q) mkdir -p `dirname $@`
Nicolas "Pixel" Noble45000342016-01-28 05:04:45 +01001795 $(Q) $(CC) $(CPPFLAGS) $(CFLAGS) -std=c89 -pedantic -MMD -MF $(addsuffix .dep, $(basename $@)) -c -o $@ $<
Craig Tillerab230452016-01-04 08:18:43 -08001796 % endfor
1797 % endif
1798
Craig Tiller841c8802015-09-10 13:06:37 -07001799 % endfor
1800 % if not has_no_sources:
1801 deps_${tgt.name}: $(${tgt.name.upper()}_OBJS:.o=.dep)
1802 % endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001803
Craig Tiller841c8802015-09-10 13:06:37 -07001804 % if not has_no_sources:
1805 % if tgt.get('secure', 'check') == True or tgt.get('secure', 'check') == 'check':
1806 ifneq ($(NO_SECURE),true)
1807 % endif
1808 ifneq ($(NO_DEPS),true)
1809 -include $(${tgt.name.upper()}_OBJS:.o=.dep)
1810 endif
1811 % if tgt.get('secure', 'check') == True or tgt.get('secure', 'check') == 'check':
1812 endif
1813 % endif
1814 % endif
Nicolas "Pixel" Noble472bb682015-11-03 19:09:01 +01001815 % for src in tgt.src:
1816 % if not proto_re.match(src) and any(proto_re.match(src2) for src2 in tgt.src):
1817 $(OBJDIR)/$(CONFIG)/${os.path.splitext(src)[0]}.o: ${' '.join(proto_to_cc(src2) for src2 in tgt.src if proto_re.match(src2))}
1818 % endif
1819 % endfor
Craig Tiller841c8802015-09-10 13:06:37 -07001820 </%def>
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001821
Craig Tiller841c8802015-09-10 13:06:37 -07001822 ifneq ($(OPENSSL_DEP),)
1823 # This is to ensure the embedded OpenSSL is built beforehand, properly
1824 # installing headers to their final destination on the drive. We need this
1825 # otherwise parallel compilation will fail if a source is compiled first.
1826 % for src in sorted(sources_that_need_openssl):
1827 % if src not in sources_that_don_t_need_openssl:
1828 ${src}: $(OPENSSL_DEP)
1829 % endif
1830 % endfor
1831 endif
Nicolas "Pixel" Noble010f1e72015-04-23 02:23:49 +02001832
Craig Tiller841c8802015-09-10 13:06:37 -07001833 .PHONY: all strip tools \
1834 dep_error openssl_dep_error openssl_dep_message git_update stop \
1835 buildtests buildtests_c buildtests_cxx \
1836 test test_c test_cxx \
1837 install install_c install_cxx \
1838 install-headers install-headers_c install-headers_cxx \
1839 install-shared install-shared_c install-shared_cxx \
1840 install-static install-static_c install-static_cxx \
1841 strip strip-shared strip-static \
1842 strip_c strip-shared_c strip-static_c \
1843 strip_cxx strip-shared_cxx strip-static_cxx \
1844 dep_c dep_cxx bins_dep_c bins_dep_cxx \
1845 clean