blob: a4fcf667825213e46cc7a2919a6b1aa7c903cd23 [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 Tiller841c8802015-09-10 13:06:37 -0700186 # The HOST compiler settings are used to compile the protoc plugins.
187 # In most cases, you won't have to change anything, but if you are
188 # cross-compiling, you can override these variables from GNU make's
189 # command line: make CC=cross-gcc HOST_CC=gcc
Nicolas Noble047b7272015-01-16 13:55:05 -0800190
Nicolas "Pixel" Noble1a8eb852016-01-26 22:33:19 +0100191 HOST_CC ?= $(CC)
192 HOST_CXX ?= $(CXX)
193 HOST_LD ?= $(LD)
194 HOST_LDXX ?= $(LDXX)
nnoble72309c62014-12-12 11:42:26 -0800195
Craig Tiller841c8802015-09-10 13:06:37 -0700196 ifdef EXTRA_DEFINES
197 DEFINES += $(EXTRA_DEFINES)
198 endif
Craig Tiller86fa1c52015-02-27 09:57:58 -0800199
Craig Tiller0fe5ee72015-12-22 12:50:36 -0800200 CFLAGS += -std=c99 -Wsign-conversion -Wconversion -Wshadow
Craig Tiller841c8802015-09-10 13:06:37 -0700201 ifeq ($(HAS_CXX11),true)
202 CXXFLAGS += -std=c++11
203 else
204 CXXFLAGS += -std=c++0x
205 endif
Craig Tiller0fe5ee72015-12-22 12:50:36 -0800206 CFLAGS += -g -Wall -Wextra -Werror -Wno-long-long -Wno-unused-parameter
207 CXXFLAGS += -g -Wall -Wextra -Werror -Wno-long-long -Wno-unused-parameter
Craig Tiller841c8802015-09-10 13:06:37 -0700208 LDFLAGS += -g
Nicolas Noblef8681182015-03-18 14:25:44 -0700209
Craig Tiller841c8802015-09-10 13:06:37 -0700210 CPPFLAGS += $(CPPFLAGS_$(CONFIG))
Craig Tiller0fe5ee72015-12-22 12:50:36 -0800211 CFLAGS += $(CFLAGS_$(CONFIG))
212 CXXFLAGS += $(CXXFLAGS_$(CONFIG))
Craig Tiller841c8802015-09-10 13:06:37 -0700213 DEFINES += $(DEFINES_$(CONFIG)) INSTALL_PREFIX=\"$(prefix)\"
214 LDFLAGS += $(LDFLAGS_$(CONFIG))
Nicolas "Pixel" Noble482d7612015-07-16 23:43:30 +0200215
Craig Tiller841c8802015-09-10 13:06:37 -0700216 ifneq ($(SYSTEM),MINGW32)
217 PIC_CPPFLAGS = -fPIC
218 CPPFLAGS += -fPIC
219 LDFLAGS += -fPIC
220 endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800221
Craig Tiller841c8802015-09-10 13:06:37 -0700222 INCLUDES = . include $(GENDIR)
223 LDFLAGS += -Llibs/$(CONFIG)
Nicolas "Pixel" Noble3adab742015-06-02 00:33:06 +0200224
Craig Tiller841c8802015-09-10 13:06:37 -0700225 ifeq ($(SYSTEM),Darwin)
226 ifneq ($(wildcard /usr/local/ssl/include),)
227 INCLUDES += /usr/local/ssl/include
228 endif
229 ifneq ($(wildcard /opt/local/include),)
230 INCLUDES += /opt/local/include
231 endif
232 ifneq ($(wildcard /usr/local/include),)
233 INCLUDES += /usr/local/include
234 endif
235 LIBS = m z
236 ifneq ($(wildcard /usr/local/ssl/lib),)
237 LDFLAGS += -L/usr/local/ssl/lib
238 endif
239 ifneq ($(wildcard /opt/local/lib),)
240 LDFLAGS += -L/opt/local/lib
241 endif
242 ifneq ($(wildcard /usr/local/lib),)
243 LDFLAGS += -L/usr/local/lib
244 endif
245 endif
Nicolas Noblef8681182015-03-18 14:25:44 -0700246
Craig Tiller841c8802015-09-10 13:06:37 -0700247 ifeq ($(SYSTEM),Linux)
Craig Tiller0fe5ee72015-12-22 12:50:36 -0800248 LIBS = rt m pthread
Craig Tiller841c8802015-09-10 13:06:37 -0700249 LDFLAGS += -pthread
250 endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800251
Craig Tiller841c8802015-09-10 13:06:37 -0700252 ifeq ($(SYSTEM),MINGW32)
Craig Tiller0fe5ee72015-12-22 12:50:36 -0800253 LIBS = m pthread
Craig Tiller841c8802015-09-10 13:06:37 -0700254 LDFLAGS += -pthread
255 endif
Nicolas Noblef8681182015-03-18 14:25:44 -0700256
Craig Tiller841c8802015-09-10 13:06:37 -0700257 GTEST_LIB = -Ithird_party/googletest/include -Ithird_party/googletest third_party/googletest/src/gtest-all.cc
258 GTEST_LIB += -lgflags
259 ifeq ($(V),1)
260 E = @:
261 Q =
262 else
263 E = @echo
264 Q = @
265 endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800266
Craig Tiller841c8802015-09-10 13:06:37 -0700267 VERSION = ${settings.version.major}.${settings.version.minor}.${settings.version.micro}.${settings.version.build}
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800268
Craig Tiller841c8802015-09-10 13:06:37 -0700269 CPPFLAGS_NO_ARCH += $(addprefix -I, $(INCLUDES)) $(addprefix -D, $(DEFINES))
270 CPPFLAGS += $(CPPFLAGS_NO_ARCH) $(ARCH_FLAGS)
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800271
Craig Tiller841c8802015-09-10 13:06:37 -0700272 LDFLAGS += $(ARCH_FLAGS)
273 LDLIBS += $(addprefix -l, $(LIBS))
274 LDLIBSXX += $(addprefix -l, $(LIBSXX))
nnoble72309c62014-12-12 11:42:26 -0800275
Craig Tiller841c8802015-09-10 13:06:37 -0700276 HOST_CPPFLAGS = $(CPPFLAGS)
277 HOST_CFLAGS = $(CFLAGS)
278 HOST_CXXFLAGS = $(CXXFLAGS)
279 HOST_LDFLAGS = $(LDFLAGS)
280 HOST_LDLIBS = $(LDLIBS)
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800281
Craig Tiller841c8802015-09-10 13:06:37 -0700282 # These are automatically computed variables.
283 # There shouldn't be any need to change anything from now on.
nnoble69ac39f2014-12-12 15:43:38 -0800284
Craig Tiller841c8802015-09-10 13:06:37 -0700285 -include cache.mk
murgatroid9924e2f4a2015-06-29 11:12:01 -0700286
Craig Tiller841c8802015-09-10 13:06:37 -0700287 CACHE_MK =
murgatroid99aa521572015-07-10 14:49:12 -0700288
Craig Tiller841c8802015-09-10 13:06:37 -0700289 HAS_PKG_CONFIG ?= $(shell command -v $(PKG_CONFIG) >/dev/null 2>&1 && echo true || echo false)
murgatroid99aa521572015-07-10 14:49:12 -0700290
Craig Tiller841c8802015-09-10 13:06:37 -0700291 ifeq ($(HAS_PKG_CONFIG), true)
292 CACHE_MK += HAS_PKG_CONFIG = true,
293 endif
nnoble69ac39f2014-12-12 15:43:38 -0800294
Craig Tiller841c8802015-09-10 13:06:37 -0700295 PC_TEMPLATE = prefix=$(prefix),\
296 exec_prefix=${'\$${prefix}'},\
297 includedir=${'\$${prefix}'}/include,\
298 libdir=${'\$${exec_prefix}'}/lib,\
299 ,\
300 Name: $(PC_NAME),\
301 Description: $(PC_DESCRIPTION),\
302 Version: $(VERSION),\
303 Cflags: -I${'\$${includedir}'} $(PC_CFLAGS),\
304 Requires.private: $(PC_REQUIRES_PRIVATE),\
305 Libs: -L${'\$${libdir}'} $(PC_LIB),\
306 Libs.private: $(PC_LIBS_PRIVATE)
murgatroid998faab232015-06-30 17:24:21 -0700307
Craig Tiller841c8802015-09-10 13:06:37 -0700308 # gpr .pc file
309 PC_NAME = gRPC Portable Runtime
310 PC_DESCRIPTION = gRPC Portable Runtime
311 PC_CFLAGS = -pthread
312 PC_REQUIRES_PRIVATE =
313 PC_LIBS_PRIVATE = -lpthread
314 PC_LIB = -lgpr
315 ifneq ($(SYSTEM),Darwin)
316 PC_LIBS_PRIVATE += -lrt
317 endif
318 GPR_PC_FILE := $(PC_TEMPLATE)
murgatroid998faab232015-06-30 17:24:21 -0700319
Craig Tiller841c8802015-09-10 13:06:37 -0700320 ifeq ($(SYSTEM),MINGW32)
321 SHARED_EXT = dll
322 endif
323 ifeq ($(SYSTEM),Darwin)
324 SHARED_EXT = dylib
325 endif
326 ifeq ($(SHARED_EXT),)
327 SHARED_EXT = so.$(VERSION)
328 endif
nnoble5b7f32a2014-12-22 08:12:44 -0800329
Craig Tiller841c8802015-09-10 13:06:37 -0700330 ifeq ($(wildcard .git),)
331 IS_GIT_FOLDER = false
332 else
333 IS_GIT_FOLDER = true
334 endif
nnoble69ac39f2014-12-12 15:43:38 -0800335
Craig Tiller841c8802015-09-10 13:06:37 -0700336 ifeq ($(HAS_PKG_CONFIG),true)
337 OPENSSL_ALPN_CHECK_CMD = $(PKG_CONFIG) --atleast-version=1.0.2 openssl
338 OPENSSL_NPN_CHECK_CMD = $(PKG_CONFIG) --atleast-version=1.0.1 openssl
339 ZLIB_CHECK_CMD = $(PKG_CONFIG) --exists zlib
340 PROTOBUF_CHECK_CMD = $(PKG_CONFIG) --atleast-version=3.0.0-alpha-3 protobuf
341 else # HAS_PKG_CONFIG
murgatroid9924e2f4a2015-06-29 11:12:01 -0700342
Craig Tiller841c8802015-09-10 13:06:37 -0700343 ifeq ($(SYSTEM),MINGW32)
344 OPENSSL_LIBS = ssl32 eay32
345 else
346 OPENSSL_LIBS = ssl crypto
347 endif
Nicolas Noblef8681182015-03-18 14:25:44 -0700348
Craig Tiller841c8802015-09-10 13:06:37 -0700349 OPENSSL_ALPN_CHECK_CMD = $(CC) $(CFLAGS) $(CPPFLAGS) -o $(TMPOUT) test/build/openssl-alpn.c $(addprefix -l, $(OPENSSL_LIBS)) $(LDFLAGS)
350 OPENSSL_NPN_CHECK_CMD = $(CC) $(CFLAGS) $(CPPFLAGS) -o $(TMPOUT) test/build/openssl-npn.c $(addprefix -l, $(OPENSSL_LIBS)) $(LDFLAGS)
351 ZLIB_CHECK_CMD = $(CC) $(CFLAGS) $(CPPFLAGS) -o $(TMPOUT) test/build/zlib.c -lz $(LDFLAGS)
352 PROTOBUF_CHECK_CMD = $(CXX) $(CXXFLAGS) $(CPPFLAGS) -o $(TMPOUT) test/build/protobuf.cc -lprotobuf $(LDFLAGS)
Craig Tiller297fafa2015-01-15 15:46:39 -0800353
Craig Tiller841c8802015-09-10 13:06:37 -0700354 endif # HAS_PKG_CONFIG
murgatroid9924e2f4a2015-06-29 11:12:01 -0700355
Craig Tiller841c8802015-09-10 13:06:37 -0700356 PERFTOOLS_CHECK_CMD = $(CC) $(CFLAGS) $(CPPFLAGS) -o $(TMPOUT) test/build/perftools.c -lprofiler $(LDFLAGS)
murgatroid996d9e4012015-07-08 10:22:45 -0700357
Craig Tiller841c8802015-09-10 13:06:37 -0700358 PROTOC_CHECK_CMD = which protoc > /dev/null
359 PROTOC_CHECK_VERSION_CMD = protoc --version | grep -q libprotoc.3
360 DTRACE_CHECK_CMD = which dtrace > /dev/null
361 SYSTEMTAP_HEADERS_CHECK_CMD = $(CC) $(CFLAGS) $(CPPFLAGS) -o $(TMPOUT) test/build/systemtap.c $(LDFLAGS)
362 ZOOKEEPER_CHECK_CMD = $(CC) $(CFLAGS) $(CPPFLAGS) -o $(TMPOUT) test/build/zookeeper.c $(LDFLAGS) -lzookeeper_mt
murgatroid9924e2f4a2015-06-29 11:12:01 -0700363
Craig Tiller841c8802015-09-10 13:06:37 -0700364 ifndef REQUIRE_CUSTOM_LIBRARIES_$(CONFIG)
365 HAS_SYSTEM_PERFTOOLS ?= $(shell $(PERFTOOLS_CHECK_CMD) 2> /dev/null && echo true || echo false)
366 ifeq ($(HAS_SYSTEM_PERFTOOLS),true)
367 DEFINES += GRPC_HAVE_PERFTOOLS
368 LIBS += profiler
369 CACHE_MK += HAS_SYSTEM_PERFTOOLS = true,
370 endif
371 endif
nnoble69ac39f2014-12-12 15:43:38 -0800372
Craig Tiller841c8802015-09-10 13:06:37 -0700373 HAS_SYSTEM_PROTOBUF_VERIFY = $(shell $(PROTOBUF_CHECK_CMD) 2> /dev/null && echo true || echo false)
374 ifndef REQUIRE_CUSTOM_LIBRARIES_$(CONFIG)
375 HAS_SYSTEM_OPENSSL_ALPN ?= $(shell $(OPENSSL_ALPN_CHECK_CMD) 2> /dev/null && echo true || echo false)
376 ifeq ($(HAS_SYSTEM_OPENSSL_ALPN),true)
377 HAS_SYSTEM_OPENSSL_NPN = true
378 CACHE_MK += HAS_SYSTEM_OPENSSL_ALPN = true,
379 else
380 HAS_SYSTEM_OPENSSL_NPN ?= $(shell $(OPENSSL_NPN_CHECK_CMD) 2> /dev/null && echo true || echo false)
381 endif
382 ifeq ($(HAS_SYSTEM_OPENSSL_NPN),true)
383 CACHE_MK += HAS_SYSTEM_OPENSSL_NPN = true,
384 endif
385 HAS_SYSTEM_ZLIB ?= $(shell $(ZLIB_CHECK_CMD) 2> /dev/null && echo true || echo false)
386 ifeq ($(HAS_SYSTEM_ZLIB),true)
387 CACHE_MK += HAS_SYSTEM_ZLIB = true,
388 endif
389 HAS_SYSTEM_PROTOBUF ?= $(HAS_SYSTEM_PROTOBUF_VERIFY)
390 ifeq ($(HAS_SYSTEM_PROTOBUF),true)
391 CACHE_MK += HAS_SYSTEM_PROTOBUF = true,
392 endif
393 else
394 # override system libraries if the config requires a custom compiled library
395 HAS_SYSTEM_OPENSSL_ALPN = false
396 HAS_SYSTEM_OPENSSL_NPN = false
397 HAS_SYSTEM_ZLIB = false
398 HAS_SYSTEM_PROTOBUF = false
399 endif
nnoble69ac39f2014-12-12 15:43:38 -0800400
Craig Tiller841c8802015-09-10 13:06:37 -0700401 HAS_PROTOC ?= $(shell $(PROTOC_CHECK_CMD) 2> /dev/null && echo true || echo false)
402 ifeq ($(HAS_PROTOC),true)
403 CACHE_MK += HAS_PROTOC = true,
404 HAS_VALID_PROTOC ?= $(shell $(PROTOC_CHECK_VERSION_CMD) 2> /dev/null && echo true || echo false)
405 ifeq ($(HAS_VALID_PROTOC),true)
406 CACHE_MK += HAS_VALID_PROTOC = true,
407 endif
408 else
409 HAS_VALID_PROTOC = false
410 endif
Nicolas Noble53830622015-02-12 16:56:38 -0800411
Craig Tiller841c8802015-09-10 13:06:37 -0700412 # Check for Systemtap (https://sourceware.org/systemtap/), first by making sure <sys/sdt.h> is present
413 # in the system and secondly by checking for the "dtrace" binary (on Linux, this is part of the Systemtap
414 # distribution. It's part of the base system on BSD/Solaris machines).
415 ifndef HAS_SYSTEMTAP
416 HAS_SYSTEMTAP_HEADERS = $(shell $(SYSTEMTAP_HEADERS_CHECK_CMD) 2> /dev/null && echo true || echo false)
417 HAS_DTRACE = $(shell $(DTRACE_CHECK_CMD) 2> /dev/null && echo true || echo false)
418 HAS_SYSTEMTAP = false
419 ifeq ($(HAS_SYSTEMTAP_HEADERS),true)
420 ifeq ($(HAS_DTRACE),true)
421 HAS_SYSTEMTAP = true
422 endif
423 endif
424 endif
David Garcia Quintas611b7362015-04-27 15:49:31 -0700425
Craig Tiller841c8802015-09-10 13:06:37 -0700426 ifeq ($(HAS_SYSTEMTAP),true)
427 CACHE_MK += HAS_SYSTEMTAP = true,
428 endif
nnoble69ac39f2014-12-12 15:43:38 -0800429
Craig Tiller841c8802015-09-10 13:06:37 -0700430 HAS_ZOOKEEPER = $(shell $(ZOOKEEPER_CHECK_CMD) 2> /dev/null && echo true || echo false)
Hongwei Wanga8cc4392015-07-16 17:37:47 -0700431
Craig Tiller841c8802015-09-10 13:06:37 -0700432 # Note that for testing purposes, one can do:
433 # make HAS_EMBEDDED_OPENSSL_ALPN=false
434 # to emulate the fact we do not have OpenSSL in the third_party folder.
Craig Tiller0fe5ee72015-12-22 12:50:36 -0800435 ifeq ($(wildcard third_party/boringssl/include/openssl/ssl.h),)
Craig Tiller841c8802015-09-10 13:06:37 -0700436 HAS_EMBEDDED_OPENSSL_ALPN = false
437 else
438 HAS_EMBEDDED_OPENSSL_ALPN = true
439 endif
nnoble69ac39f2014-12-12 15:43:38 -0800440
Craig Tiller841c8802015-09-10 13:06:37 -0700441 ifeq ($(wildcard third_party/zlib/zlib.h),)
442 HAS_EMBEDDED_ZLIB = false
443 else
444 HAS_EMBEDDED_ZLIB = true
445 endif
nnoble69ac39f2014-12-12 15:43:38 -0800446
Craig Tiller841c8802015-09-10 13:06:37 -0700447 ifeq ($(wildcard third_party/protobuf/src/google/protobuf/descriptor.pb.h),)
448 HAS_EMBEDDED_PROTOBUF = false
449 ifneq ($(HAS_VALID_PROTOC),true)
450 NO_PROTOC = true
451 endif
452 else
453 HAS_EMBEDDED_PROTOBUF = true
454 endif
Nicolas Noble53830622015-02-12 16:56:38 -0800455
Craig Tiller841c8802015-09-10 13:06:37 -0700456 PC_REQUIRES_GRPC = gpr
457 PC_LIBS_GRPC =
murgatroid998faab232015-06-30 17:24:21 -0700458
Craig Tiller841c8802015-09-10 13:06:37 -0700459 ifeq ($(HAS_SYSTEM_ZLIB),false)
Craig Tiller3dca23a2016-01-21 11:44:55 -0800460 ifeq ($(HAS_EMBEDDED_ZLIB), true)
461 EMBED_ZLIB ?= true
Craig Tiller841c8802015-09-10 13:06:37 -0700462 else
463 DEP_MISSING += zlib
Craig Tiller3dca23a2016-01-21 11:44:55 -0800464 EMBED_ZLIB ?= broken
Craig Tiller841c8802015-09-10 13:06:37 -0700465 endif
466 else
Craig Tiller3dca23a2016-01-21 11:44:55 -0800467 EMBED_ZLIB ?= false
468 endif
469
470 ifeq ($(EMBED_ZLIB),true)
471 ZLIB_DEP = $(LIBDIR)/$(CONFIG)/libz.a
472 ZLIB_MERGE_LIBS = $(LIBDIR)/$(CONFIG)/libz.a
473 CPPFLAGS += -Ithird_party/zlib
474 LDFLAGS += -L$(LIBDIR)/$(CONFIG)/zlib
475 else
Craig Tiller841c8802015-09-10 13:06:37 -0700476 ifeq ($(HAS_PKG_CONFIG),true)
477 CPPFLAGS += $(shell $(PKG_CONFIG) --cflags zlib)
478 LDFLAGS += $(shell $(PKG_CONFIG) --libs-only-L zlib)
Craig Tiller0fe5ee72015-12-22 12:50:36 -0800479 LIBS += $(patsubst -l%,%,$(shell $(PKG_CONFIG) --libs-only-l zlib))
Craig Tiller841c8802015-09-10 13:06:37 -0700480 PC_REQUIRES_GRPC += zlib
481 else
482 PC_LIBS_GRPC += -lz
Craig Tiller0fe5ee72015-12-22 12:50:36 -0800483 LIBS += z
Craig Tiller841c8802015-09-10 13:06:37 -0700484 endif
485 endif
nnoble69ac39f2014-12-12 15:43:38 -0800486
Craig Tiller841c8802015-09-10 13:06:37 -0700487 OPENSSL_PKG_CONFIG = false
murgatroid99da7a9942015-06-29 14:57:37 -0700488
Craig Tiller841c8802015-09-10 13:06:37 -0700489 PC_REQUIRES_SECURE =
490 PC_LIBS_SECURE =
murgatroid998faab232015-06-30 17:24:21 -0700491
Craig Tiller841c8802015-09-10 13:06:37 -0700492 ifeq ($(HAS_SYSTEM_OPENSSL_ALPN),true)
Craig Tiller0fe5ee72015-12-22 12:50:36 -0800493 EMBED_OPENSSL ?= false
494 NO_SECURE ?= false
495 else # HAS_SYSTEM_OPENSSL_ALPN=false
496 ifeq ($(HAS_EMBEDDED_OPENSSL_ALPN),true)
497 EMBED_OPENSSL ?= true
498 NO_SECURE ?= false
499 else # HAS_EMBEDDED_OPENSSL_ALPN=false
500 ifeq ($(HAS_SYSTEM_OPENSSL_NPN),true)
501 EMBED_OPENSSL ?= false
502 NO_SECURE ?= false
503 else
504 NO_SECURE ?= true
505 endif # HAS_SYSTEM_OPENSSL_NPN=true
506 endif # HAS_EMBEDDED_OPENSSL_ALPN
507 endif # HAS_SYSTEM_OPENSSL_ALPN
508
509 OPENSSL_DEP :=
510 OPENSSL_MERGE_LIBS :=
511 ifeq ($(NO_SECURE),false)
512 ifeq ($(EMBED_OPENSSL),true)
513 OPENSSL_DEP += $(LIBDIR)/$(CONFIG)/libboringssl.a
514 OPENSSL_MERGE_LIBS += $(LIBDIR)/$(CONFIG)/libboringssl.a
515 # need to prefix these to ensure overriding system libraries
516 CPPFLAGS := -Ithird_party/boringssl/include $(CPPFLAGS)
Craig Tiller0fe5ee72015-12-22 12:50:36 -0800517 else # EMBED_OPENSSL=false
Craig Tiller841c8802015-09-10 13:06:37 -0700518 ifeq ($(HAS_PKG_CONFIG),true)
519 OPENSSL_PKG_CONFIG = true
520 PC_REQUIRES_SECURE = openssl
521 CPPFLAGS := $(shell $(PKG_CONFIG) --cflags openssl) $(CPPFLAGS)
522 LDFLAGS_OPENSSL_PKG_CONFIG = $(shell $(PKG_CONFIG) --libs-only-L openssl)
523 ifeq ($(SYSTEM),Linux)
524 ifneq ($(LDFLAGS_OPENSSL_PKG_CONFIG),)
525 LDFLAGS_OPENSSL_PKG_CONFIG += $(shell $(PKG_CONFIG) --libs-only-L openssl | sed s/L/Wl,-rpath,/)
Craig Tiller0fe5ee72015-12-22 12:50:36 -0800526 endif # LDFLAGS_OPENSSL_PKG_CONFIG=''
527 endif # System=Linux
Craig Tiller841c8802015-09-10 13:06:37 -0700528 LDFLAGS := $(LDFLAGS_OPENSSL_PKG_CONFIG) $(LDFLAGS)
Craig Tiller0fe5ee72015-12-22 12:50:36 -0800529 else # HAS_PKG_CONFIG=false
Craig Tiller841c8802015-09-10 13:06:37 -0700530 LIBS_SECURE = $(OPENSSL_LIBS)
Craig Tiller0fe5ee72015-12-22 12:50:36 -0800531 endif # HAS_PKG_CONFIG
532 ifeq ($(HAS_SYSTEM_OPENSSL_NPN),true)
533 CPPFLAGS += -DTSI_OPENSSL_ALPN_SUPPORT=0
534 LIBS_SECURE = $(OPENSSL_LIBS)
535 endif # HAS_SYSTEM_OPENSSL_NPN
Craig Tiller841c8802015-09-10 13:06:37 -0700536 PC_LIBS_SECURE = $(addprefix -l, $(LIBS_SECURE))
Craig Tiller0fe5ee72015-12-22 12:50:36 -0800537 endif # EMBED_OPENSSL
538 endif # NO_SECURE
nnoble69ac39f2014-12-12 15:43:38 -0800539
Craig Tiller841c8802015-09-10 13:06:37 -0700540 ifeq ($(OPENSSL_PKG_CONFIG),true)
541 LDLIBS_SECURE += $(shell $(PKG_CONFIG) --libs-only-l openssl)
542 else
543 LDLIBS_SECURE += $(addprefix -l, $(LIBS_SECURE))
544 endif
nnoble5b7f32a2014-12-22 08:12:44 -0800545
Craig Tiller841c8802015-09-10 13:06:37 -0700546 # grpc .pc file
547 PC_NAME = gRPC
548 PC_DESCRIPTION = high performance general RPC framework
549 PC_CFLAGS =
550 PC_REQUIRES_PRIVATE = $(PC_REQUIRES_GRPC) $(PC_REQUIRES_SECURE)
551 PC_LIBS_PRIVATE = $(PC_LIBS_GRPC) $(PC_LIBS_SECURE)
552 PC_LIB = -lgrpc
553 GRPC_PC_FILE := $(PC_TEMPLATE)
murgatroid998faab232015-06-30 17:24:21 -0700554
Craig Tiller841c8802015-09-10 13:06:37 -0700555 # gprc_unsecure .pc file
556 PC_NAME = gRPC unsecure
557 PC_DESCRIPTION = high performance general RPC framework without SSL
558 PC_CFLAGS =
559 PC_REQUIRES_PRIVATE = $(PC_REQUIRES_GRPC)
560 PC_LIBS_PRIVATE = $(PC_LIBS_GRPC)
561 PC_LIB = -lgrpc
562 GRPC_UNSECURE_PC_FILE := $(PC_TEMPLATE)
murgatroid998faab232015-06-30 17:24:21 -0700563
Craig Tiller841c8802015-09-10 13:06:37 -0700564 # gprc_zookeeper .pc file
565 PC_NAME = gRPC zookeeper
566 PC_DESCRIPTION = gRPC's zookeeper plugin
567 PC_CFLAGS =
568 PC_REQUIRES_PRIVATE =
569 PC_LIBS_PRIVATE = -lzookeeper_mt
570 GRPC_ZOOKEEPER_PC_FILE := $(PC_TEMPLATE)
Hongwei Wanga8cc4392015-07-16 17:37:47 -0700571
Craig Tiller841c8802015-09-10 13:06:37 -0700572 PROTOBUF_PKG_CONFIG = false
murgatroid99da7a9942015-06-29 14:57:37 -0700573
Craig Tiller841c8802015-09-10 13:06:37 -0700574 PC_REQUIRES_GRPCXX =
575 PC_LIBS_GRPCXX =
murgatroid998faab232015-06-30 17:24:21 -0700576
Craig Tiller841c8802015-09-10 13:06:37 -0700577 CPPFLAGS := -Ithird_party/googletest/include $(CPPFLAGS)
Craig Tiller16f6dac2015-08-24 17:00:04 -0700578
Craig Tiller841c8802015-09-10 13:06:37 -0700579 ifeq ($(HAS_SYSTEM_PROTOBUF),true)
580 ifeq ($(HAS_PKG_CONFIG),true)
581 PROTOBUF_PKG_CONFIG = true
582 PC_REQUIRES_GRPCXX = protobuf
583 CPPFLAGS := $(shell $(PKG_CONFIG) --cflags protobuf) $(CPPFLAGS)
584 LDFLAGS_PROTOBUF_PKG_CONFIG = $(shell $(PKG_CONFIG) --libs-only-L protobuf)
585 ifeq ($(SYSTEM),Linux)
586 ifneq ($(LDFLAGS_PROTOBUF_PKG_CONFIG),)
587 LDFLAGS_PROTOBUF_PKG_CONFIG += $(shell $(PKG_CONFIG) --libs-only-L protobuf | sed s/L/Wl,-rpath,/)
588 endif
589 endif
590 else
591 PC_LIBS_GRPCXX = -lprotobuf
592 endif
593 else
594 ifeq ($(HAS_EMBEDDED_PROTOBUF),true)
595 PROTOBUF_DEP = $(LIBDIR)/$(CONFIG)/protobuf/libprotobuf.a
596 CPPFLAGS := -Ithird_party/protobuf/src $(CPPFLAGS)
597 LDFLAGS := -L$(LIBDIR)/$(CONFIG)/protobuf $(LDFLAGS)
598 PROTOC = $(BINDIR)/$(CONFIG)/protobuf/protoc
599 else
600 NO_PROTOBUF = true
601 endif
602 endif
Nicolas Noble53830622015-02-12 16:56:38 -0800603
Craig Tiller841c8802015-09-10 13:06:37 -0700604 LIBS_PROTOBUF = protobuf
605 LIBS_PROTOC = protoc protobuf
Nicolas Noble53830622015-02-12 16:56:38 -0800606
Craig Tiller841c8802015-09-10 13:06:37 -0700607 HOST_LDLIBS_PROTOC += $(addprefix -l, $(LIBS_PROTOC))
Nicolas Noble53830622015-02-12 16:56:38 -0800608
Craig Tiller841c8802015-09-10 13:06:37 -0700609 ifeq ($(PROTOBUF_PKG_CONFIG),true)
610 LDLIBS_PROTOBUF += $(shell $(PKG_CONFIG) --libs-only-l protobuf)
611 else
612 LDLIBS_PROTOBUF += $(addprefix -l, $(LIBS_PROTOBUF))
613 endif
murgatroid9924e2f4a2015-06-29 11:12:01 -0700614
Craig Tiller841c8802015-09-10 13:06:37 -0700615 # grpc++ .pc file
616 PC_NAME = gRPC++
617 PC_DESCRIPTION = C++ wrapper for gRPC
618 PC_CFLAGS =
619 PC_REQUIRES_PRIVATE = grpc $(PC_REQUIRES_GRPCXX)
620 PC_LIBS_PRIVATE = $(PC_LIBS_GRPCXX)
621 PC_LIB = -lgrpc++
622 GRPCXX_PC_FILE := $(PC_TEMPLATE)
murgatroid998faab232015-06-30 17:24:21 -0700623
Craig Tiller841c8802015-09-10 13:06:37 -0700624 # grpc++_unsecure .pc file
625 PC_NAME = gRPC++ unsecure
626 PC_DESCRIPTION = C++ wrapper for gRPC without SSL
627 PC_CFLAGS =
628 PC_REQUIRES_PRIVATE = grpc_unsecure $(PC_REQUIRES_GRPCXX)
629 PC_LIBS_PRIVATE = $(PC_LIBS_GRPCXX)
630 PC_LIB = -lgrpc++
631 GRPCXX_UNSECURE_PC_FILE := $(PC_TEMPLATE)
murgatroid998faab232015-06-30 17:24:21 -0700632
Craig Tiller841c8802015-09-10 13:06:37 -0700633 ifeq ($(MAKECMDGOALS),clean)
634 NO_DEPS = true
635 endif
nnoble69ac39f2014-12-12 15:43:38 -0800636
Craig Tiller841c8802015-09-10 13:06:37 -0700637 INSTALL_OK = false
638 ifeq ($(HAS_VALID_PROTOC),true)
639 ifeq ($(HAS_SYSTEM_PROTOBUF_VERIFY),true)
640 INSTALL_OK = true
641 endif
642 endif
Nicolas "Pixel" Noble98ab9982015-02-21 04:22:16 +0100643
Craig Tiller841c8802015-09-10 13:06:37 -0700644 .SECONDARY = %.pb.h %.pb.cc
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800645
Craig Tiller841c8802015-09-10 13:06:37 -0700646 PROTOC_PLUGINS =\
647 % for tgt in targets:
648 % if tgt.build == 'protoc':
649 $(BINDIR)/$(CONFIG)/${tgt.name}\
650 % endif
651 % endfor
Craig Tillerf58b9ef2015-01-15 09:09:12 -0800652
Craig Tiller841c8802015-09-10 13:06:37 -0700653 ifeq ($(DEP_MISSING),)
654 all: static shared plugins\
655 % for tgt in targets:
656 % if tgt.build == 'all':
657 $(BINDIR)/$(CONFIG)/${tgt.name}\
658 % endif
659 % endfor
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800660
Craig Tiller841c8802015-09-10 13:06:37 -0700661 dep_error:
662 @echo "You shouldn't see this message - all of your dependencies are correct."
663 else
664 all: dep_error git_update stop
nnoble69ac39f2014-12-12 15:43:38 -0800665
Craig Tiller841c8802015-09-10 13:06:37 -0700666 dep_error:
667 @echo
668 @echo "DEPENDENCY ERROR"
669 @echo
670 @echo "You are missing system dependencies that are essential to build grpc,"
671 @echo "and the third_party directory doesn't have them:"
672 @echo
673 @echo " $(DEP_MISSING)"
674 @echo
675 @echo "Installing the development packages for your system will solve"
676 @echo "this issue. Please consult INSTALL to get more information."
677 @echo
678 @echo "If you need information about why these tests failed, run:"
679 @echo
680 @echo " make run_dep_checks"
681 @echo
682 endif
nnoble69ac39f2014-12-12 15:43:38 -0800683
Craig Tiller841c8802015-09-10 13:06:37 -0700684 git_update:
685 ifeq ($(IS_GIT_FOLDER),true)
686 @echo "Additionally, since you are in a git clone, you can download the"
687 @echo "missing dependencies in third_party by running the following command:"
688 @echo
689 @echo " git submodule update --init"
690 @echo
691 endif
nnoble69ac39f2014-12-12 15:43:38 -0800692
Craig Tiller841c8802015-09-10 13:06:37 -0700693 openssl_dep_error: openssl_dep_message git_update stop
nnoble69ac39f2014-12-12 15:43:38 -0800694
Craig Tiller841c8802015-09-10 13:06:37 -0700695 protobuf_dep_error: protobuf_dep_message git_update stop
Nicolas Noble53830622015-02-12 16:56:38 -0800696
Craig Tiller841c8802015-09-10 13:06:37 -0700697 protoc_dep_error: protoc_dep_message git_update stop
Nicolas Noble53830622015-02-12 16:56:38 -0800698
Craig Tiller841c8802015-09-10 13:06:37 -0700699 openssl_dep_message:
700 @echo
701 @echo "DEPENDENCY ERROR"
702 @echo
703 @echo "The target you are trying to run requires OpenSSL."
704 @echo "Your system doesn't have it, and neither does the third_party directory."
705 @echo
706 @echo "Please consult INSTALL to get more information."
707 @echo
708 @echo "If you need information about why these tests failed, run:"
709 @echo
710 @echo " make run_dep_checks"
711 @echo
nnoble69ac39f2014-12-12 15:43:38 -0800712
Craig Tiller841c8802015-09-10 13:06:37 -0700713 protobuf_dep_message:
714 @echo
715 @echo "DEPENDENCY ERROR"
716 @echo
717 @echo "The target you are trying to run requires protobuf 3.0.0+"
718 @echo "Your system doesn't have it, and neither does the third_party directory."
719 @echo
720 @echo "Please consult INSTALL to get more information."
721 @echo
722 @echo "If you need information about why these tests failed, run:"
723 @echo
724 @echo " make run_dep_checks"
725 @echo
Nicolas Noble53830622015-02-12 16:56:38 -0800726
Craig Tiller841c8802015-09-10 13:06:37 -0700727 protoc_dep_message:
728 @echo
729 @echo "DEPENDENCY ERROR"
730 @echo
731 @echo "The target you are trying to run requires protobuf-compiler 3.0.0+"
732 @echo "Your system doesn't have it, and neither does the third_party directory."
733 @echo
734 @echo "Please consult INSTALL to get more information."
735 @echo
736 @echo "If you need information about why these tests failed, run:"
737 @echo
738 @echo " make run_dep_checks"
739 @echo
Nicolas Noble53830622015-02-12 16:56:38 -0800740
Craig Tiller841c8802015-09-10 13:06:37 -0700741 systemtap_dep_error:
742 @echo
743 @echo "DEPENDENCY ERROR"
744 @echo
745 @echo "Under the '$(CONFIG)' configutation, the target you are trying "
746 @echo "to build requires systemtap 2.7+ (on Linux) or dtrace (on other "
747 @echo "platforms such as Solaris and *BSD). "
748 @echo
749 @echo "Please consult INSTALL to get more information."
750 @echo
David Garcia Quintas8954e902015-04-29 09:46:33 -0700751
Craig Tiller841c8802015-09-10 13:06:37 -0700752 stop:
753 @false
nnoble69ac39f2014-12-12 15:43:38 -0800754
Craig Tiller841c8802015-09-10 13:06:37 -0700755 % for tgt in targets:
756 ${tgt.name}: $(BINDIR)/$(CONFIG)/${tgt.name}
757 % endfor
ctiller09cb6d52014-12-19 17:38:22 -0800758
Craig Tiller841c8802015-09-10 13:06:37 -0700759 run_dep_checks:
760 $(OPENSSL_ALPN_CHECK_CMD) || true
761 $(OPENSSL_NPN_CHECK_CMD) || true
762 $(ZLIB_CHECK_CMD) || true
763 $(PERFTOOLS_CHECK_CMD) || true
764 $(PROTOBUF_CHECK_CMD) || true
765 $(PROTOC_CHECK_VERSION_CMD) || true
766 $(ZOOKEEPER_CHECK_CMD) || true
nnoble69ac39f2014-12-12 15:43:38 -0800767
Craig Tiller841c8802015-09-10 13:06:37 -0700768 third_party/protobuf/configure:
769 $(E) "[AUTOGEN] Preparing protobuf"
770 $(Q)(cd third_party/protobuf ; autoreconf -f -i -Wall,no-obsolete)
Nicolas Noble53830622015-02-12 16:56:38 -0800771
Craig Tiller841c8802015-09-10 13:06:37 -0700772 $(LIBDIR)/$(CONFIG)/protobuf/libprotobuf.a: third_party/protobuf/configure
773 $(E) "[MAKE] Building protobuf"
774 $(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)
775 $(Q)$(MAKE) -C third_party/protobuf clean
776 $(Q)$(MAKE) -C third_party/protobuf
777 $(Q)mkdir -p $(LIBDIR)/$(CONFIG)/protobuf
778 $(Q)mkdir -p $(BINDIR)/$(CONFIG)/protobuf
779 $(Q)cp third_party/protobuf/src/.libs/libprotoc.a $(LIBDIR)/$(CONFIG)/protobuf
780 $(Q)cp third_party/protobuf/src/.libs/libprotobuf.a $(LIBDIR)/$(CONFIG)/protobuf
781 $(Q)cp third_party/protobuf/src/protoc $(BINDIR)/$(CONFIG)/protobuf
Nicolas Noble53830622015-02-12 16:56:38 -0800782
Craig Tiller841c8802015-09-10 13:06:37 -0700783 static: static_c static_cxx
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800784
Craig Tiller841c8802015-09-10 13:06:37 -0700785 static_c: pc_c pc_c_unsecure cache.mk pc_gpr pc_c_zookeeper\
786 % for lib in libs:
787 % if lib.build == 'all' and lib.language == 'c' and not lib.get('external_deps', None):
788 $(LIBDIR)/$(CONFIG)/lib${lib.name}.a\
789 % endif
790 % endfor
791 static_zookeeper_libs
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800792
793
Craig Tiller841c8802015-09-10 13:06:37 -0700794 static_cxx: pc_cxx pc_cxx_unsecure pc_gpr cache.mk \
795 % for lib in libs:
796 % if lib.build == 'all' and lib.language == 'c++':
797 $(LIBDIR)/$(CONFIG)/lib${lib.name}.a\
798 % endif
799 % endfor
nnoble29e1d292014-12-01 10:27:40 -0800800
801
Craig Tiller841c8802015-09-10 13:06:37 -0700802 shared: shared_c shared_cxx
nnoble29e1d292014-12-01 10:27:40 -0800803
Craig Tiller841c8802015-09-10 13:06:37 -0700804 shared_c: pc_c pc_c_unsecure pc_gpr cache.mk pc_c_zookeeper\
805 % for lib in libs:
806 % if lib.build == 'all' and lib.language == 'c' and not lib.get('external_deps', None):
807 $(LIBDIR)/$(CONFIG)/lib${lib.name}.$(SHARED_EXT)\
808 % endif
809 % endfor
810 shared_zookeeper_libs
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800811
Craig Tiller841c8802015-09-10 13:06:37 -0700812 shared_cxx: pc_cxx pc_cxx_unsecure cache.mk\
813 % for lib in libs:
814 % if lib.build == 'all' and lib.language == 'c++':
815 $(LIBDIR)/$(CONFIG)/lib${lib.name}.$(SHARED_EXT)\
816 % endif
817 % endfor
nnoble29e1d292014-12-01 10:27:40 -0800818
819
Craig Tiller841c8802015-09-10 13:06:37 -0700820 shared_csharp: shared_c \
821 % for lib in libs:
822 % if lib.build == 'all' and lib.language == 'csharp':
823 $(LIBDIR)/$(CONFIG)/lib${lib.name}.$(SHARED_EXT)\
824 % endif
825 % endfor
Jan Tattermusch2ec0b3e2015-02-18 15:03:12 -0800826
Craig Tiller841c8802015-09-10 13:06:37 -0700827 ifeq ($(HAS_ZOOKEEPER),true)
828 static_zookeeper_libs:\
829 % for lib in libs:
830 % if lib.build == 'all' and lib.language == 'c' and 'zookeeper' in lib.get('external_deps', []):
831 $(LIBDIR)/$(CONFIG)/lib${lib.name}.a\
832 % endif
833 % endfor
Hongwei Wanga8cc4392015-07-16 17:37:47 -0700834
Craig Tiller841c8802015-09-10 13:06:37 -0700835 shared_zookeeper_libs:\
836 % for lib in libs:
837 % if lib.build == 'all' and lib.language == 'c' and 'zookeeper' in lib.get('external_deps', []):
838 $(LIBDIR)/$(CONFIG)/lib${lib.name}.$(SHARED_EXT)\
839 % endif
840 % endfor
Hongwei Wanga8cc4392015-07-16 17:37:47 -0700841
Craig Tiller841c8802015-09-10 13:06:37 -0700842 else
Hongwei Wanga8cc4392015-07-16 17:37:47 -0700843
Craig Tiller841c8802015-09-10 13:06:37 -0700844 static_zookeeper_libs:
Hongwei Wanga8cc4392015-07-16 17:37:47 -0700845
Craig Tiller841c8802015-09-10 13:06:37 -0700846 shared_zookeeper_libs:
Hongwei Wanga8cc4392015-07-16 17:37:47 -0700847
Craig Tiller841c8802015-09-10 13:06:37 -0700848 endif
Hongwei Wanga8cc4392015-07-16 17:37:47 -0700849
Craig Tiller841c8802015-09-10 13:06:37 -0700850 grpc_csharp_ext: shared_csharp
Jan Tattermusch2ec0b3e2015-02-18 15:03:12 -0800851
Craig Tiller841c8802015-09-10 13:06:37 -0700852 plugins: $(PROTOC_PLUGINS)
Nicolas "Pixel" Noble522d7122015-02-19 01:28:02 +0100853
Craig Tiller841c8802015-09-10 13:06:37 -0700854 privatelibs: privatelibs_c privatelibs_cxx
nnoble29e1d292014-12-01 10:27:40 -0800855
Craig Tiller841c8802015-09-10 13:06:37 -0700856 privatelibs_c: \
857 % for lib in libs:
Craig Tiller0fe5ee72015-12-22 12:50:36 -0800858 % 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 -0700859 $(LIBDIR)/$(CONFIG)/lib${lib.name}.a\
860 % endif
861 % endfor
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800862
Craig Tiller841c8802015-09-10 13:06:37 -0700863 pc_gpr: $(LIBDIR)/$(CONFIG)/pkgconfig/gpr.pc
murgatroid998faab232015-06-30 17:24:21 -0700864
Craig Tiller841c8802015-09-10 13:06:37 -0700865 pc_c: $(LIBDIR)/$(CONFIG)/pkgconfig/grpc.pc
murgatroid998faab232015-06-30 17:24:21 -0700866
Craig Tiller841c8802015-09-10 13:06:37 -0700867 pc_c_unsecure: $(LIBDIR)/$(CONFIG)/pkgconfig/grpc_unsecure.pc
murgatroid998faab232015-06-30 17:24:21 -0700868
Craig Tiller841c8802015-09-10 13:06:37 -0700869 ifeq ($(HAS_ZOOKEEPER),true)
870 pc_c_zookeeper: $(LIBDIR)/$(CONFIG)/pkgconfig/grpc_zookeeper.pc
871 else
872 pc_c_zookeeper:
873 endif
Hongwei Wanga3780a82015-07-17 15:27:18 -0700874
Craig Tiller841c8802015-09-10 13:06:37 -0700875 pc_cxx: $(LIBDIR)/$(CONFIG)/pkgconfig/grpc++.pc
murgatroid998faab232015-06-30 17:24:21 -0700876
Craig Tiller841c8802015-09-10 13:06:37 -0700877 pc_cxx_unsecure: $(LIBDIR)/$(CONFIG)/pkgconfig/grpc++_unsecure.pc
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800878
Craig Tiller841c8802015-09-10 13:06:37 -0700879 privatelibs_cxx: \
880 % for lib in libs:
881 % if lib.build == 'private' and lib.language == 'c++' and not lib.get('external_deps', None):
882 $(LIBDIR)/$(CONFIG)/lib${lib.name}.a\
883 % endif
884 % endfor
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800885
886
Craig Tiller841c8802015-09-10 13:06:37 -0700887 ifeq ($(HAS_ZOOKEEPER),true)
888 privatelibs_zookeeper: \
889 % for lib in libs:
890 % if lib.build == 'private' and lib.language == 'c++' and zookeeper in lib.get('external_deps', []):
891 $(LIBDIR)/$(CONFIG)/lib${lib.name}.a\
892 % endif
893 % endfor
Hongwei Wang8e04d412015-07-31 15:12:51 -0700894
Craig Tiller841c8802015-09-10 13:06:37 -0700895 else
896 privatelibs_zookeeper:
897 endif
Hongwei Wang8e04d412015-07-31 15:12:51 -0700898
899
Craig Tiller841c8802015-09-10 13:06:37 -0700900 buildtests: buildtests_c buildtests_cxx buildtests_zookeeper
nnoble29e1d292014-12-01 10:27:40 -0800901
Craig Tiller3824b6e2015-12-09 11:19:59 -0800902 buildtests_c: privatelibs_c <%text>\</%text>
Craig Tiller841c8802015-09-10 13:06:37 -0700903 % for tgt in targets:
904 % if tgt.build == 'test' and not tgt.language == 'c++' and not tgt.get('external_deps', None):
Craig Tiller3824b6e2015-12-09 11:19:59 -0800905 $(BINDIR)/$(CONFIG)/${tgt.name} <%text>\</%text>
Craig Tiller841c8802015-09-10 13:06:37 -0700906 % endif
907 % endfor
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800908
909
Craig Tiller3824b6e2015-12-09 11:19:59 -0800910 buildtests_cxx: buildtests_zookeeper privatelibs_cxx <%text>\</%text>
Craig Tiller841c8802015-09-10 13:06:37 -0700911 % for tgt in targets:
912 % if tgt.build == 'test' and 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
nnoble29e1d292014-12-01 10:27:40 -0800916
917
Craig Tiller841c8802015-09-10 13:06:37 -0700918 ifeq ($(HAS_ZOOKEEPER),true)
Craig Tiller3824b6e2015-12-09 11:19:59 -0800919 buildtests_zookeeper: privatelibs_zookeeper <%text>\</%text>
Craig Tiller841c8802015-09-10 13:06:37 -0700920 % for tgt in targets:
921 % if tgt.build == 'test' and tgt.language == 'c++' and 'zookeeper' in tgt.get('external_deps', []):
Craig Tiller3824b6e2015-12-09 11:19:59 -0800922 $(BINDIR)/$(CONFIG)/${tgt.name} <%text>\</%text>
Craig Tiller841c8802015-09-10 13:06:37 -0700923 % endif
924 % endfor
nnoble29e1d292014-12-01 10:27:40 -0800925
Craig Tiller841c8802015-09-10 13:06:37 -0700926 else
927 buildtests_zookeeper:
928 endif
Hongwei Wang8e04d412015-07-31 15:12:51 -0700929
930
Craig Tiller841c8802015-09-10 13:06:37 -0700931 test: test_c test_cxx test_zookeeper
Hongwei Wang8e04d412015-07-31 15:12:51 -0700932
Craig Tiller841c8802015-09-10 13:06:37 -0700933 flaky_test: flaky_test_c flaky_test_cxx flaky_test_zookeeper
Nicolas "Pixel" Noble4251d562015-05-22 19:43:39 +0200934
Craig Tiller841c8802015-09-10 13:06:37 -0700935 test_c: buildtests_c
936 % for tgt in targets:
937 % if tgt.build == 'test' and tgt.get('run', True) and not tgt.language == 'c++' and not tgt.get('flaky', False) and not tgt.get('external_deps', None):
938 $(E) "[RUN] Testing ${tgt.name}"
939 $(Q) $(BINDIR)/$(CONFIG)/${tgt.name} || ( echo test ${tgt.name} failed ; exit 1 )
940 % endif
941 % endfor
Nicolas "Pixel" Noble4251d562015-05-22 19:43:39 +0200942
943
Craig Tiller841c8802015-09-10 13:06:37 -0700944 flaky_test_c: buildtests_c
945 % for tgt in targets:
946 % if tgt.build == 'test' and tgt.get('run', True) and not tgt.language == 'c++' and tgt.get('flaky', False) and not tgt.get('external_deps', None):
947 $(E) "[RUN] Testing ${tgt.name}"
948 $(Q) $(BINDIR)/$(CONFIG)/${tgt.name} || ( echo test ${tgt.name} failed ; exit 1 )
949 % endif
950 % endfor
nnoble29e1d292014-12-01 10:27:40 -0800951
952
Craig Tiller841c8802015-09-10 13:06:37 -0700953 test_cxx: test_zookeeper buildtests_cxx
954 % for tgt in targets:
955 % if tgt.build == 'test' and tgt.get('run', True) and tgt.language == 'c++' and not tgt.get('flaky', False) and not tgt.get('external_deps', None):
956 $(E) "[RUN] Testing ${tgt.name}"
957 $(Q) $(BINDIR)/$(CONFIG)/${tgt.name} || ( echo test ${tgt.name} failed ; exit 1 )
958 % endif
959 % endfor
Nicolas "Pixel" Noble4251d562015-05-22 19:43:39 +0200960
961
Craig Tiller841c8802015-09-10 13:06:37 -0700962 flaky_test_cxx: buildtests_cxx
963 % for tgt in targets:
964 % if tgt.build == 'test' and tgt.get('run', True) and tgt.language == 'c++' and tgt.get('flaky', False) and not tgt.get('external_deps', None):
965 $(E) "[RUN] Testing ${tgt.name}"
966 $(Q) $(BINDIR)/$(CONFIG)/${tgt.name} || ( echo test ${tgt.name} failed ; exit 1 )
967 % endif
968 % endfor
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800969
970
Craig Tiller841c8802015-09-10 13:06:37 -0700971 ifeq ($(HAS_ZOOKEEPER),true)
972 test_zookeeper: buildtests_zookeeper
973 % for tgt in targets:
974 % 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', []):
975 $(E) "[RUN] Testing ${tgt.name}"
976 $(Q) $(BINDIR)/$(CONFIG)/${tgt.name} || ( echo test ${tgt.name} failed ; exit 1 )
977 % endif
978 % endfor
Hongwei Wang8e04d412015-07-31 15:12:51 -0700979
980
Craig Tiller841c8802015-09-10 13:06:37 -0700981 flaky_test_zookeeper: buildtests_zookeeper
982 % for tgt in targets:
983 % 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', []):
984 $(E) "[RUN] Testing ${tgt.name}"
985 $(Q) $(BINDIR)/$(CONFIG)/${tgt.name} || ( echo test ${tgt.name} failed ; exit 1 )
986 % endif
987 % endfor
Hongwei Wang8e04d412015-07-31 15:12:51 -0700988
Craig Tiller841c8802015-09-10 13:06:37 -0700989 else
990 test_zookeeper:
991 flaky_test_zookeeper:
992 endif
Hongwei Wang8e04d412015-07-31 15:12:51 -0700993
994
Craig Tiller841c8802015-09-10 13:06:37 -0700995 test_python: static_c
996 $(E) "[RUN] Testing python code"
997 $(Q) tools/run_tests/run_tests.py -lpython -c$(CONFIG)
Nicolas "Pixel" Noble051a28f2015-03-17 22:54:54 +0100998
999
Craig Tiller841c8802015-09-10 13:06:37 -07001000 tools: tools_c tools_cxx
Craig Tiller7552f0f2015-06-19 17:46:20 -07001001
1002
Craig Tiller841c8802015-09-10 13:06:37 -07001003 tools_c: privatelibs_c\
1004 % for tgt in targets:
1005 % if tgt.build == 'tool' and not tgt.language=='c++':
1006 $(BINDIR)/$(CONFIG)/${tgt.name}\
1007 % endif
1008 % endfor
Craig Tiller7552f0f2015-06-19 17:46:20 -07001009
1010
Craig Tiller841c8802015-09-10 13:06:37 -07001011 tools_cxx: privatelibs_cxx\
1012 % for tgt in targets:
1013 % if tgt.build == 'tool' and tgt.language=='c++':
1014 $(BINDIR)/$(CONFIG)/${tgt.name}\
1015 % endif
1016 % endfor
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001017
1018
Craig Tiller841c8802015-09-10 13:06:37 -07001019 buildbenchmarks: privatelibs\
1020 % for tgt in targets:
1021 % if tgt.build == 'benchmark':
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 benchmarks: buildbenchmarks
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001028
Craig Tiller841c8802015-09-10 13:06:37 -07001029 strip: strip-static strip-shared
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001030
Craig Tiller841c8802015-09-10 13:06:37 -07001031 strip-static: strip-static_c strip-static_cxx
nnoble20e2e3f2014-12-16 15:37:57 -08001032
Craig Tiller841c8802015-09-10 13:06:37 -07001033 strip-shared: strip-shared_c strip-shared_cxx
nnoble20e2e3f2014-12-16 15:37:57 -08001034
Nicolas Noble047b7272015-01-16 13:55:05 -08001035
Craig Tiller841c8802015-09-10 13:06:37 -07001036 # TODO(nnoble): the strip target is stripping in-place, instead
1037 # of copying files in a temporary folder.
1038 # This prevents proper debugging after running make install.
Nicolas Noble047b7272015-01-16 13:55:05 -08001039
Craig Tiller841c8802015-09-10 13:06:37 -07001040 strip-static_c: static_c
1041 ifeq ($(CONFIG),opt)
1042 % for lib in libs:
1043 % if lib.language == "c":
1044 % if lib.build == "all":
1045 % if not lib.get('external_deps', None):
1046 $(E) "[STRIP] Stripping lib${lib.name}.a"
1047 $(Q) $(STRIP) $(LIBDIR)/$(CONFIG)/lib${lib.name}.a
1048 % endif
1049 % endif
1050 % endif
1051 % endfor
1052 ifeq ($(HAS_ZOOKEEPER),true)
1053 % for lib in libs:
1054 % if lib.language == "c":
1055 % if lib.build == "all":
1056 % if 'zookeeper' in lib.get('external_deps', []):
1057 $(E) "[STRIP] Stripping lib${lib.name}.a"
1058 $(Q) $(STRIP) $(LIBDIR)/$(CONFIG)/lib${lib.name}.a
1059 % endif
1060 % endif
1061 % endif
1062 % endfor
1063 endif
1064 endif
nnoble85a49262014-12-08 18:14:03 -08001065
Craig Tiller841c8802015-09-10 13:06:37 -07001066 strip-static_cxx: static_cxx
1067 ifeq ($(CONFIG),opt)
1068 % for lib in libs:
1069 % if lib.language == "c++":
1070 % if lib.build == "all":
1071 $(E) "[STRIP] Stripping lib${lib.name}.a"
1072 $(Q) $(STRIP) $(LIBDIR)/$(CONFIG)/lib${lib.name}.a
1073 % endif
1074 % endif
1075 % endfor
1076 endif
Nicolas "Pixel" Noble4ef9b862015-08-14 19:35:24 +02001077
Craig Tiller841c8802015-09-10 13:06:37 -07001078 strip-shared_c: shared_c
1079 ifeq ($(CONFIG),opt)
1080 % for lib in libs:
1081 % if lib.language == "c":
1082 % if lib.build == "all":
1083 % if not lib.get('external_deps', None):
1084 $(E) "[STRIP] Stripping lib${lib.name}.so"
1085 $(Q) $(STRIP) $(LIBDIR)/$(CONFIG)/lib${lib.name}.$(SHARED_EXT)
1086 % endif
1087 % endif
1088 % endif
1089 % endfor
1090 ifeq ($(HAS_ZOOKEEPER),true)
1091 % for lib in libs:
1092 % if lib.language == "c":
1093 % if lib.build == "all":
1094 % if 'zookeeper' in lib.get('external_deps', []):
1095 $(E) "[STRIP] Stripping lib${lib.name}.so"
1096 $(Q) $(STRIP) $(LIBDIR)/$(CONFIG)/lib${lib.name}.$(SHARED_EXT)
1097 % endif
1098 % endif
1099 % endif
1100 % endfor
1101 endif
1102 endif
nnoble85a49262014-12-08 18:14:03 -08001103
Craig Tiller841c8802015-09-10 13:06:37 -07001104 strip-shared_cxx: shared_cxx
1105 ifeq ($(CONFIG),opt)
1106 % for lib in libs:
1107 % if lib.language == "c++":
1108 % if lib.build == "all":
1109 $(E) "[STRIP] Stripping lib${lib.name}.so"
1110 $(Q) $(STRIP) $(LIBDIR)/$(CONFIG)/lib${lib.name}.$(SHARED_EXT)
1111 % endif
1112 % endif
1113 % endfor
1114 endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001115
Craig Tiller841c8802015-09-10 13:06:37 -07001116 strip-shared_csharp: shared_csharp
1117 ifeq ($(CONFIG),opt)
1118 % for lib in libs:
1119 % if lib.language == "csharp":
1120 % if lib.build == "all":
1121 $(E) "[STRIP] Stripping lib${lib.name}.so"
1122 $(Q) $(STRIP) $(LIBDIR)/$(CONFIG)/lib${lib.name}.$(SHARED_EXT)
1123 % endif
1124 % endif
1125 % endfor
1126 endif
Jan Tattermusch2ec0b3e2015-02-18 15:03:12 -08001127
Craig Tiller841c8802015-09-10 13:06:37 -07001128 cache.mk::
1129 $(E) "[MAKE] Generating $@"
1130 $(Q) echo "$(CACHE_MK)" | tr , '\n' >$@
murgatroid99aa521572015-07-10 14:49:12 -07001131
Craig Tiller841c8802015-09-10 13:06:37 -07001132 $(LIBDIR)/$(CONFIG)/pkgconfig/gpr.pc:
1133 $(E) "[MAKE] Generating $@"
1134 $(Q) mkdir -p $(@D)
1135 $(Q) echo "$(GPR_PC_FILE)" | tr , '\n' >$@
murgatroid998faab232015-06-30 17:24:21 -07001136
Craig Tiller841c8802015-09-10 13:06:37 -07001137 $(LIBDIR)/$(CONFIG)/pkgconfig/grpc.pc:
1138 $(E) "[MAKE] Generating $@"
1139 $(Q) mkdir -p $(@D)
1140 $(Q) echo "$(GRPC_PC_FILE)" | tr , '\n' >$@
murgatroid998faab232015-06-30 17:24:21 -07001141
Craig Tiller841c8802015-09-10 13:06:37 -07001142 $(LIBDIR)/$(CONFIG)/pkgconfig/grpc_unsecure.pc:
1143 $(E) "[MAKE] Generating $@"
1144 $(Q) mkdir -p $(@D)
1145 $(Q) echo "$(GRPC_UNSECURE_PC_FILE)" | tr , '\n' >$@
murgatroid998faab232015-06-30 17:24:21 -07001146
Craig Tiller841c8802015-09-10 13:06:37 -07001147 $(LIBDIR)/$(CONFIG)/pkgconfig/grpc_zookeeper.pc:
1148 $(E) "[MAKE] Generating $@"
1149 $(Q) mkdir -p $(@D)
1150 $(Q) echo -e "$(GRPC_ZOOKEEPER_PC_FILE)" >$@
Hongwei Wanga8cc4392015-07-16 17:37:47 -07001151
Craig Tiller841c8802015-09-10 13:06:37 -07001152 $(LIBDIR)/$(CONFIG)/pkgconfig/grpc++.pc:
1153 $(E) "[MAKE] Generating $@"
1154 $(Q) mkdir -p $(@D)
1155 $(Q) echo "$(GRPCXX_PC_FILE)" | tr , '\n' >$@
murgatroid998faab232015-06-30 17:24:21 -07001156
Craig Tiller841c8802015-09-10 13:06:37 -07001157 $(LIBDIR)/$(CONFIG)/pkgconfig/grpc++_unsecure.pc:
1158 $(E) "[MAKE] Generating $@"
1159 $(Q) mkdir -p $(@D)
1160 $(Q) echo "$(GRPCXX_UNSECURE_PC_FILE)" | tr , '\n' >$@
murgatroid998faab232015-06-30 17:24:21 -07001161
Craig Tiller841c8802015-09-10 13:06:37 -07001162 % for p in protos:
1163 ifeq ($(NO_PROTOC),true)
1164 $(GENDIR)/${p}.pb.cc: protoc_dep_error
1165 $(GENDIR)/${p}.grpc.pb.cc: protoc_dep_error
1166 else
Craig Tiller1b4e3302015-12-17 16:35:00 -08001167 $(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 -07001168 $(E) "[PROTOC] Generating protobuf CC file from $<"
1169 $(Q) mkdir -p `dirname $@`
1170 $(Q) $(PROTOC) --cpp_out=$(GENDIR) $<
Nicolas "Pixel" Noble0caebbf2015-04-09 23:08:51 +02001171
Craig Tiller1b4e3302015-12-17 16:35:00 -08001172 $(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 -07001173 $(E) "[GRPC] Generating gRPC's protobuf service CC file from $<"
1174 $(Q) mkdir -p `dirname $@`
1175 $(Q) $(PROTOC) --grpc_out=$(GENDIR) --plugin=protoc-gen-grpc=$(BINDIR)/$(CONFIG)/grpc_cpp_plugin $<
1176 endif
nnoble72309c62014-12-12 11:42:26 -08001177
Craig Tiller841c8802015-09-10 13:06:37 -07001178 % endfor
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001179
Craig Tiller841c8802015-09-10 13:06:37 -07001180 ifeq ($(CONFIG),stapprof)
1181 src/core/profiling/stap_timers.c: $(GENDIR)/src/core/profiling/stap_probes.h
1182 ifeq ($(HAS_SYSTEMTAP),true)
1183 $(GENDIR)/src/core/profiling/stap_probes.h: src/core/profiling/stap_probes.d
1184 $(E) "[DTRACE] Compiling $<"
1185 $(Q) mkdir -p `dirname $@`
1186 $(Q) $(DTRACE) -C -h -s $< -o $@
1187 else
1188 $(GENDIR)/src/core/profiling/stap_probes.h: systemtap_dep_error stop
1189 endif
1190 endif
David Garcia Quintas611b7362015-04-27 15:49:31 -07001191
Craig Tiller841c8802015-09-10 13:06:37 -07001192 $(OBJDIR)/$(CONFIG)/%.o : %.c
1193 $(E) "[C] Compiling $<"
1194 $(Q) mkdir -p `dirname $@`
1195 $(Q) $(CC) $(CFLAGS) $(CPPFLAGS) -MMD -MF $(addsuffix .dep, $(basename $@)) -c -o $@ $<
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001196
Craig Tiller841c8802015-09-10 13:06:37 -07001197 $(OBJDIR)/$(CONFIG)/%.o : $(GENDIR)/%.pb.cc
1198 $(E) "[CXX] Compiling $<"
1199 $(Q) mkdir -p `dirname $@`
1200 $(Q) $(CXX) $(CXXFLAGS) $(CPPFLAGS) -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)/src/compiler/%.o : src/compiler/%.cc
1203 $(E) "[HOSTCXX] Compiling $<"
1204 $(Q) mkdir -p `dirname $@`
1205 $(Q) $(HOST_CXX) $(HOST_CXXFLAGS) $(HOST_CPPFLAGS) -MMD -MF $(addsuffix .dep, $(basename $@)) -c -o $@ $<
nnoble72309c62014-12-12 11:42:26 -08001206
Craig Tiller841c8802015-09-10 13:06:37 -07001207 $(OBJDIR)/$(CONFIG)/%.o : %.cc
1208 $(E) "[CXX] Compiling $<"
1209 $(Q) mkdir -p `dirname $@`
1210 $(Q) $(CXX) $(CXXFLAGS) $(CPPFLAGS) -MMD -MF $(addsuffix .dep, $(basename $@)) -c -o $@ $<
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001211
Craig Tiller841c8802015-09-10 13:06:37 -07001212 install: install_c install_cxx install-plugins install-certs verify-install
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001213
Craig Tiller841c8802015-09-10 13:06:37 -07001214 install_c: install-headers_c install-static_c install-shared_c
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001215
Craig Tiller841c8802015-09-10 13:06:37 -07001216 install_cxx: install-headers_cxx install-static_cxx install-shared_cxx
nnoble85a49262014-12-08 18:14:03 -08001217
Craig Tiller841c8802015-09-10 13:06:37 -07001218 install_csharp: install-shared_csharp install_c
Jan Tattermusch2ec0b3e2015-02-18 15:03:12 -08001219
Craig Tiller841c8802015-09-10 13:06:37 -07001220 install_grpc_csharp_ext: install_csharp
Jan Tattermusch2ec0b3e2015-02-18 15:03:12 -08001221
Craig Tiller841c8802015-09-10 13:06:37 -07001222 install-headers: install-headers_c install-headers_cxx
nnoble85a49262014-12-08 18:14:03 -08001223
Craig Tiller841c8802015-09-10 13:06:37 -07001224 install-headers_c:
1225 $(E) "[INSTALL] Installing public C headers"
1226 $(Q) $(foreach h, $(PUBLIC_HEADERS_C), $(INSTALL) -d $(prefix)/$(dir $(h)) && ) exit 0 || exit 1
1227 $(Q) $(foreach h, $(PUBLIC_HEADERS_C), $(INSTALL) $(h) $(prefix)/$(h) && ) exit 0 || exit 1
nnoble85a49262014-12-08 18:14:03 -08001228
Craig Tiller841c8802015-09-10 13:06:37 -07001229 install-headers_cxx:
1230 $(E) "[INSTALL] Installing public C++ headers"
1231 $(Q) $(foreach h, $(PUBLIC_HEADERS_CXX), $(INSTALL) -d $(prefix)/$(dir $(h)) && ) exit 0 || exit 1
1232 $(Q) $(foreach h, $(PUBLIC_HEADERS_CXX), $(INSTALL) $(h) $(prefix)/$(h) && ) exit 0 || exit 1
nnoble85a49262014-12-08 18:14:03 -08001233
Craig Tiller841c8802015-09-10 13:06:37 -07001234 install-static: install-static_c install-static_cxx
nnoble85a49262014-12-08 18:14:03 -08001235
Craig Tiller841c8802015-09-10 13:06:37 -07001236 install-static_c: static_c strip-static_c install-pkg-config_c
1237 % for lib in libs:
1238 % if lib.language == "c":
1239 % if lib.build == "all":
1240 % if not lib.get('external_deps', None):
1241 $(E) "[INSTALL] Installing lib${lib.name}.a"
1242 $(Q) $(INSTALL) -d $(prefix)/lib
1243 $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/lib${lib.name}.a $(prefix)/lib/lib${lib.name}.a
1244 % endif
1245 % endif
1246 % endif
1247 % endfor
1248 ifeq ($(HAS_ZOOKEEPER),true)
1249 % for lib in libs:
1250 % if lib.language == "c":
1251 % if lib.build == "all":
1252 % if 'zookeeper' in lib.get('external_deps', []):
1253 $(E) "[INSTALL] Installing lib${lib.name}.a"
1254 $(Q) $(INSTALL) -d $(prefix)/lib
1255 $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/lib${lib.name}.a $(prefix)/lib/lib${lib.name}.a
1256 % endif
1257 % endif
1258 % endif
1259 % endfor
1260 endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001261
Craig Tiller841c8802015-09-10 13:06:37 -07001262 install-static_cxx: static_cxx strip-static_cxx install-pkg-config_cxx
1263 % for lib in libs:
1264 % if lib.language == "c++":
1265 % if lib.build == "all":
1266 $(E) "[INSTALL] Installing lib${lib.name}.a"
1267 $(Q) $(INSTALL) -d $(prefix)/lib
1268 $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/lib${lib.name}.a $(prefix)/lib/lib${lib.name}.a
1269 % endif
1270 % endif
1271 % endfor
nnoble85a49262014-12-08 18:14:03 -08001272
Craig Tiller841c8802015-09-10 13:06:37 -07001273 <%def name="install_shared(lang_filter)">\
1274 % for lib in libs:
1275 % if lib.language == lang_filter:
1276 % if lib.build == "all":
1277 % if not lib.get('external_deps', None):
1278 ifeq ($(SYSTEM),MINGW32)
1279 $(E) "[INSTALL] Installing ${lib.name}.$(SHARED_EXT)"
1280 $(Q) $(INSTALL) -d $(prefix)/lib
1281 $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/${lib.name}.$(SHARED_EXT) $(prefix)/lib/${lib.name}.$(SHARED_EXT)
1282 $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/lib${lib.name}-imp.a $(prefix)/lib/lib${lib.name}-imp.a
1283 else
1284 $(E) "[INSTALL] Installing lib${lib.name}.$(SHARED_EXT)"
1285 $(Q) $(INSTALL) -d $(prefix)/lib
1286 $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/lib${lib.name}.$(SHARED_EXT) $(prefix)/lib/lib${lib.name}.$(SHARED_EXT)
1287 ifneq ($(SYSTEM),Darwin)
1288 $(Q) ln -sf lib${lib.name}.$(SHARED_EXT) $(prefix)/lib/lib${lib.name}.so.${settings.version.major}
1289 $(Q) ln -sf lib${lib.name}.$(SHARED_EXT) $(prefix)/lib/lib${lib.name}.so
1290 endif
1291 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', []):
1301 ifeq ($(SYSTEM),MINGW32)
1302 $(E) "[INSTALL] Installing ${lib.name}.$(SHARED_EXT)"
1303 $(Q) $(INSTALL) -d $(prefix)/lib
1304 $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/${lib.name}.$(SHARED_EXT) $(prefix)/lib/${lib.name}.$(SHARED_EXT)
1305 $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/lib${lib.name}-imp.a $(prefix)/lib/lib${lib.name}-imp.a
1306 else
1307 $(E) "[INSTALL] Installing lib${lib.name}.$(SHARED_EXT)"
1308 $(Q) $(INSTALL) -d $(prefix)/lib
1309 $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/lib${lib.name}.$(SHARED_EXT) $(prefix)/lib/lib${lib.name}.$(SHARED_EXT)
1310 ifneq ($(SYSTEM),Darwin)
1311 $(Q) ln -sf lib${lib.name}.$(SHARED_EXT) $(prefix)/lib/lib${lib.name}.so.${settings.version.major}
1312 $(Q) ln -sf lib${lib.name}.$(SHARED_EXT) $(prefix)/lib/lib${lib.name}.so
1313 endif
1314 endif
1315 % endif
1316 % endif
1317 % endif
1318 % endfor
1319 endif
1320 ifneq ($(SYSTEM),MINGW32)
1321 ifneq ($(SYSTEM),Darwin)
1322 $(Q) ldconfig || true
1323 endif
1324 endif
1325 </%def>
nnoble85a49262014-12-08 18:14:03 -08001326
Craig Tiller841c8802015-09-10 13:06:37 -07001327 install-shared_c: shared_c strip-shared_c install-pkg-config_c
1328 ${install_shared("c")}
Nicolas "Pixel" Noble522d7122015-02-19 01:28:02 +01001329
Craig Tiller841c8802015-09-10 13:06:37 -07001330 install-shared_cxx: shared_cxx strip-shared_cxx install-shared_c install-pkg-config_cxx
1331 ${install_shared("c++")}
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001332
Craig Tiller841c8802015-09-10 13:06:37 -07001333 install-shared_csharp: shared_csharp strip-shared_csharp
1334 ${install_shared("csharp")}
Nicolas "Pixel" Noble522d7122015-02-19 01:28:02 +01001335
Craig Tiller841c8802015-09-10 13:06:37 -07001336 install-plugins: $(PROTOC_PLUGINS)
1337 ifeq ($(SYSTEM),MINGW32)
1338 $(Q) false
1339 else
1340 $(E) "[INSTALL] Installing grpc protoc plugins"
1341 % for tgt in targets:
1342 % if tgt.build == 'protoc':
1343 $(Q) $(INSTALL) -d $(prefix)/bin
1344 $(Q) $(INSTALL) $(BINDIR)/$(CONFIG)/${tgt.name} $(prefix)/bin/${tgt.name}
1345 % endif
1346 % endfor
1347 endif
Jan Tattermusch2ec0b3e2015-02-18 15:03:12 -08001348
Craig Tiller841c8802015-09-10 13:06:37 -07001349 install-pkg-config_c: pc_gpr pc_c pc_c_unsecure pc_c_zookeeper
1350 $(E) "[INSTALL] Installing C pkg-config files"
1351 $(Q) $(INSTALL) -d $(prefix)/lib/pkgconfig
1352 $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/pkgconfig/gpr.pc $(prefix)/lib/pkgconfig/gpr.pc
1353 $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/pkgconfig/grpc.pc $(prefix)/lib/pkgconfig/grpc.pc
1354 $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/pkgconfig/grpc_unsecure.pc $(prefix)/lib/pkgconfig/grpc_unsecure.pc
1355 ifeq ($(HAS_ZOOKEEPER),true)
1356 $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/pkgconfig/grpc_zookeeper.pc $(prefix)/lib/pkgconfig/grpc_zookeeper.pc
1357 endif
murgatroid998faab232015-06-30 17:24:21 -07001358
Craig Tiller841c8802015-09-10 13:06:37 -07001359 install-pkg-config_cxx: pc_cxx pc_cxx_unsecure
1360 $(E) "[INSTALL] Installing C++ pkg-config files"
1361 $(Q) $(INSTALL) -d $(prefix)/lib/pkgconfig
1362 $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/pkgconfig/grpc++.pc $(prefix)/lib/pkgconfig/grpc++.pc
1363 $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/pkgconfig/grpc++_unsecure.pc $(prefix)/lib/pkgconfig/grpc++_unsecure.pc
murgatroid998faab232015-06-30 17:24:21 -07001364
Craig Tiller841c8802015-09-10 13:06:37 -07001365 install-certs: etc/roots.pem
1366 $(E) "[INSTALL] Installing root certificates"
1367 $(Q) $(INSTALL) -d $(prefix)/share/grpc
1368 $(Q) $(INSTALL) etc/roots.pem $(prefix)/share/grpc/roots.pem
Nicolas "Pixel" Noble161ea232015-02-22 05:48:53 +01001369
Craig Tiller841c8802015-09-10 13:06:37 -07001370 verify-install:
1371 ifeq ($(INSTALL_OK),true)
1372 @echo "Your system looks ready to go."
1373 @echo
1374 else
1375 @echo "We couldn't find protoc 3.0.0+ installed on your system. While this"
1376 @echo "won't prevent grpc from working, you won't be able to compile"
1377 @echo "and run any meaningful code with it."
1378 @echo
1379 @echo
1380 @echo "Please download and install protobuf 3.0.0+ from:"
1381 @echo
1382 @echo " https://github.com/google/protobuf/releases"
1383 @echo
1384 @echo "Once you've done so, or if you think this message is in error,"
1385 @echo "you can re-run this check by doing:"
1386 @echo
1387 @echo " make verify-install"
1388 endif
Nicolas "Pixel" Noble98ab9982015-02-21 04:22:16 +01001389
Craig Tiller841c8802015-09-10 13:06:37 -07001390 clean:
1391 $(E) "[CLEAN] Cleaning build directories."
1392 $(Q) $(RM) -rf $(OBJDIR) $(LIBDIR) $(BINDIR) $(GENDIR) cache.mk
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001393
1394
Craig Tiller841c8802015-09-10 13:06:37 -07001395 # The various libraries
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001396
Craig Tiller841c8802015-09-10 13:06:37 -07001397 % for lib in libs:
1398 ${makelib(lib)}
1399 % endfor
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001400
1401
Craig Tiller841c8802015-09-10 13:06:37 -07001402 # All of the test targets, and protoc plugins
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001403
Craig Tiller841c8802015-09-10 13:06:37 -07001404 % for tgt in targets:
1405 ${maketarget(tgt)}
1406 % endfor
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001407
Craig Tiller841c8802015-09-10 13:06:37 -07001408 <%def name="makelib(lib)">
1409 LIB${lib.name.upper()}_SRC = \\
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001410
Craig Tiller841c8802015-09-10 13:06:37 -07001411 % for src in lib.src:
1412 ${proto_to_cc(src)} \\
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001413
Craig Tiller841c8802015-09-10 13:06:37 -07001414 % endfor
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001415
Craig Tiller841c8802015-09-10 13:06:37 -07001416 % if "public_headers" in lib:
1417 % if lib.language == "c++":
1418 PUBLIC_HEADERS_CXX += \\
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001419
Craig Tiller841c8802015-09-10 13:06:37 -07001420 % else:
1421 PUBLIC_HEADERS_C += \\
nnoble85a49262014-12-08 18:14:03 -08001422
Craig Tiller841c8802015-09-10 13:06:37 -07001423 % endif
1424 % for hdr in lib.public_headers:
1425 ${hdr} \\
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001426
Craig Tiller841c8802015-09-10 13:06:37 -07001427 % endfor
1428 % endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001429
Craig Tiller841c8802015-09-10 13:06:37 -07001430 LIB${lib.name.upper()}_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(LIB${lib.name.upper()}_SRC))))
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001431
Craig Tiller0fe5ee72015-12-22 12:50:36 -08001432 % if lib.boringssl:
1433 # boringssl needs an override to ensure that it does not include
1434 # system openssl headers regardless of other configuration
1435 # we do so here with a target specific variable assignment
1436 $(LIB${lib.name.upper()}_OBJS): CFLAGS := -Ithird_party/boringssl/include $(CFLAGS) -Wno-sign-conversion -Wno-conversion -Wno-unused-value -fvisibility=hidden
1437 $(LIB${lib.name.upper()}_OBJS): CXXFLAGS := -Ithird_party/boringssl/include $(CXXFLAGS) -fvisibility=hidden
1438 $(LIB${lib.name.upper()}_OBJS): CPPFLAGS += -DOPENSSL_NO_ASM -D_GNU_SOURCE
Craig Tiller3dca23a2016-01-21 11:44:55 -08001439 % elif lib.zlib:
1440 $(LIB${lib.name.upper()}_OBJS): CFLAGS := $(CFLAGS) -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-implicit-function-declaration -fvisibility=hidden
Craig Tiller0fe5ee72015-12-22 12:50:36 -08001441 % else:
1442 % endif
1443
Craig Tiller841c8802015-09-10 13:06:37 -07001444 ## If the library requires OpenSSL, let's add some restrictions.
1445 % if lib.get('secure', 'check') == True or lib.get('secure', 'check') == 'check':
1446 ifeq ($(NO_SECURE),true)
nnoble69ac39f2014-12-12 15:43:38 -08001447
Craig Tiller841c8802015-09-10 13:06:37 -07001448 # You can't build secure libraries if you don't have OpenSSL.
Nicolas Noble047b7272015-01-16 13:55:05 -08001449
Craig Tiller841c8802015-09-10 13:06:37 -07001450 $(LIBDIR)/$(CONFIG)/lib${lib.name}.a: openssl_dep_error
nnoble69ac39f2014-12-12 15:43:38 -08001451
Craig Tiller841c8802015-09-10 13:06:37 -07001452 % if lib.build == "all":
1453 ifeq ($(SYSTEM),MINGW32)
1454 $(LIBDIR)/$(CONFIG)/${lib.name}.$(SHARED_EXT): openssl_dep_error
1455 else
1456 $(LIBDIR)/$(CONFIG)/lib${lib.name}.$(SHARED_EXT): openssl_dep_error
1457 endif
1458 % endif
nnoble5b7f32a2014-12-22 08:12:44 -08001459
Craig Tiller841c8802015-09-10 13:06:37 -07001460 else
nnoble69ac39f2014-12-12 15:43:38 -08001461
Craig Tiller841c8802015-09-10 13:06:37 -07001462 % if lib.language == 'c++':
1463 ifeq ($(NO_PROTOBUF),true)
Nicolas Noble53830622015-02-12 16:56:38 -08001464
Craig Tiller841c8802015-09-10 13:06:37 -07001465 # 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 -08001466
Craig Tiller841c8802015-09-10 13:06:37 -07001467 $(LIBDIR)/$(CONFIG)/lib${lib.name}.a: protobuf_dep_error
Nicolas Noble53830622015-02-12 16:56:38 -08001468
Craig Tiller841c8802015-09-10 13:06:37 -07001469 % if lib.build == "all":
1470 ifeq ($(SYSTEM),MINGW32)
1471 $(LIBDIR)/$(CONFIG)/${lib.name}.$(SHARED_EXT): protobuf_dep_error
1472 else
1473 $(LIBDIR)/$(CONFIG)/lib${lib.name}.$(SHARED_EXT): protobuf_dep_error
1474 endif
1475 % endif
Nicolas Noble53830622015-02-12 16:56:38 -08001476
Craig Tiller841c8802015-09-10 13:06:37 -07001477 else
1478 % endif
Nicolas Noble53830622015-02-12 16:56:38 -08001479
Craig Tiller841c8802015-09-10 13:06:37 -07001480 $(LIBDIR)/$(CONFIG)/lib${lib.name}.a: $(ZLIB_DEP) $(OPENSSL_DEP)\
1481 ## The else here corresponds to the if secure earlier.
1482 % else:
1483 % if lib.language == 'c++':
1484 ifeq ($(NO_PROTOBUF),true)
Nicolas Noble53830622015-02-12 16:56:38 -08001485
Craig Tiller841c8802015-09-10 13:06:37 -07001486 # 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 -08001487
Craig Tiller841c8802015-09-10 13:06:37 -07001488 $(LIBDIR)/$(CONFIG)/lib${lib.name}.a: protobuf_dep_error
Nicolas Noble53830622015-02-12 16:56:38 -08001489
Craig Tiller841c8802015-09-10 13:06:37 -07001490 % if lib.build == "all":
1491 ifeq ($(SYSTEM),MINGW32)
1492 $(LIBDIR)/$(CONFIG)/${lib.name}.$(SHARED_EXT): protobuf_dep_error
1493 else
1494 $(LIBDIR)/$(CONFIG)/lib${lib.name}.$(SHARED_EXT): protobuf_dep_error
1495 endif
1496 % endif
Nicolas Noble53830622015-02-12 16:56:38 -08001497
Craig Tiller841c8802015-09-10 13:06:37 -07001498 else
Nicolas Noble53830622015-02-12 16:56:38 -08001499
Craig Tiller841c8802015-09-10 13:06:37 -07001500 % endif
Craig Tiller0fe5ee72015-12-22 12:50:36 -08001501 $(LIBDIR)/$(CONFIG)/lib${lib.name}.a: $(ZLIB_DEP) $(OPENSSL_DEP) \
Craig Tiller841c8802015-09-10 13:06:37 -07001502 % endif
1503 % if lib.language == 'c++':
1504 $(PROTOBUF_DEP)\
1505 % endif
1506 $(LIB${lib.name.upper()}_OBJS)
1507 $(E) "[AR] Creating $@"
1508 $(Q) mkdir -p `dirname $@`
1509 $(Q) rm -f $(LIBDIR)/$(CONFIG)/lib${lib.name}.a
1510 $(Q) $(AR) rcs $(LIBDIR)/$(CONFIG)/lib${lib.name}.a $(LIB${lib.name.upper()}_OBJS)
1511 % if lib.get('baselib', False):
Craig Tiller0fe5ee72015-12-22 12:50:36 -08001512 $(Q) rm -rf $(BUILDDIR_ABSOLUTE)/tmp-merge-${lib.name}
1513 $(Q) ( mkdir -p $(BUILDDIR_ABSOLUTE)/tmp-merge-${lib.name}/grpc ; <%text>\</%text>
1514 cd $(BUILDDIR_ABSOLUTE)/tmp-merge-${lib.name}/grpc ; <%text>\</%text>
1515 $(AR) x $(LIBDIR)/$(CONFIG)/lib${lib.name}.a )
1516 $(Q) for l in $(ZLIB_MERGE_LIBS) ; do ( <%text>\</%text>
1517 mkdir -p $(BUILDDIR_ABSOLUTE)/tmp-merge-${lib.name}/zlib ; <%text>\</%text>
1518 cd $(BUILDDIR_ABSOLUTE)/tmp-merge-${lib.name}/zlib ; <%text>\</%text>
1519 <%text>$(AR) x $${l}</%text> ) ; done
1520 $(Q) for l in $(ZLIB_MERGE_LIBS) ; do ( <%text>\</%text>
1521 mkdir -p $(BUILDDIR_ABSOLUTE)/tmp-merge-${lib.name}/zlib ; <%text>\</%text>
1522 cd $(BUILDDIR_ABSOLUTE)/tmp-merge-${lib.name}/zlib ; <%text>\</%text>
1523 <%text>$(AR) x $${l}</%text> ) ; done
Craig Tiller841c8802015-09-10 13:06:37 -07001524 % if lib.get('secure', 'check') == True:
Craig Tiller0fe5ee72015-12-22 12:50:36 -08001525 $(Q) for l in $(OPENSSL_MERGE_LIBS) ; do ( <%text>\</%text>
1526 mkdir -p $(BUILDDIR_ABSOLUTE)/tmp-merge-${lib.name}/ssl ; <%text>\</%text>
1527 cd $(BUILDDIR_ABSOLUTE)/tmp-merge-${lib.name}/ssl ; <%text>\</%text>
1528 <%text>$(AR) x $${l}</%text> ) ; done
1529 $(Q) for l in $(OPENSSL_MERGE_LIBS) ; do ( <%text>\</%text>
1530 mkdir -p $(BUILDDIR_ABSOLUTE)/tmp-merge-${lib.name}/ssl ; <%text>\</%text>
1531 cd $(BUILDDIR_ABSOLUTE)/tmp-merge-${lib.name}/ssl ; <%text>\</%text>
1532 <%text>$(AR) x $${l}</%text> ) ; done
Craig Tiller841c8802015-09-10 13:06:37 -07001533 % endif
Craig Tiller0fe5ee72015-12-22 12:50:36 -08001534 $(Q) rm -f $(LIBDIR)/$(CONFIG)/lib${lib.name}.a $(BUILDDIR_ABSOLUTE)/tmp-merge-${lib.name}/*/__.SYMDEF*
1535 $(Q) ar rcs $(LIBDIR)/$(CONFIG)/lib${lib.name}.a $(BUILDDIR_ABSOLUTE)/tmp-merge-${lib.name}/*/*
1536 $(Q) rm -rf $(BUILDDIR_ABSOLUTE)/tmp-merge-${lib.name}
Craig Tiller841c8802015-09-10 13:06:37 -07001537 % endif
1538 ifeq ($(SYSTEM),Darwin)
1539 $(Q) ranlib $(LIBDIR)/$(CONFIG)/lib${lib.name}.a
1540 endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001541
Craig Tiller841c8802015-09-10 13:06:37 -07001542 <%
Nicolas "Pixel" Noble010f1e72015-04-23 02:23:49 +02001543
Craig Tiller841c8802015-09-10 13:06:37 -07001544 if lib.language == 'c++':
1545 ld = '$(LDXX)'
1546 else:
1547 ld = '$(LD)'
nnoble5b7f32a2014-12-22 08:12:44 -08001548
Craig Tiller841c8802015-09-10 13:06:37 -07001549 out_base = '$(LIBDIR)/$(CONFIG)/' + lib.name
1550 out_libbase = '$(LIBDIR)/$(CONFIG)/lib' + lib.name
nnoble5b7f32a2014-12-22 08:12:44 -08001551
Craig Tiller841c8802015-09-10 13:06:37 -07001552 common = '$(LIB' + lib.name.upper() + '_OBJS) $(LDLIBS)'
nnoble5b7f32a2014-12-22 08:12:44 -08001553
Craig Tiller841c8802015-09-10 13:06:37 -07001554 libs = ''
1555 lib_deps = ' $(ZLIB_DEP)'
1556 mingw_libs = ''
1557 mingw_lib_deps = ' $(ZLIB_DEP)'
1558 if lib.language == 'c++':
1559 lib_deps += ' $(PROTOBUF_DEP)'
1560 mingw_lib_deps += ' $(PROTOBUF_DEP)'
Jan Tattermusch324140c2016-01-12 08:54:01 -08001561 if lib.get('deps_linkage', None) == 'static':
1562 for dep in lib.get('deps', []):
1563 lib_archive = '$(LIBDIR)/$(CONFIG)/lib' + dep + '.a'
1564 common = common + ' ' + lib_archive
1565 lib_deps = lib_deps + ' ' + lib_archive
1566 mingw_lib_deps = mingw_lib_deps + ' ' + lib_archive
1567 else:
1568 for dep in lib.get('deps', []):
1569 libs = libs + ' -l' + dep
1570 lib_deps = lib_deps + ' $(LIBDIR)/$(CONFIG)/lib' + dep + '.$(SHARED_EXT)'
1571 mingw_libs = mingw_libs + ' -l' + dep + '-imp'
1572 mingw_lib_deps = mingw_lib_deps + ' $(LIBDIR)/$(CONFIG)/' + dep + '.$(SHARED_EXT)'
nnoble5b7f32a2014-12-22 08:12:44 -08001573
Craig Tiller841c8802015-09-10 13:06:37 -07001574 security = lib.get('secure', 'check')
1575 if security == True:
1576 common = common + ' $(OPENSSL_MERGE_LIBS) $(LDLIBS_SECURE)'
Craig Tiller0fe5ee72015-12-22 12:50:36 -08001577 common = common + ' $(ZLIB_MERGE_LIBS)'
Nicolas "Pixel" Noblea7c162c2015-07-24 20:21:51 +02001578
Craig Tiller841c8802015-09-10 13:06:37 -07001579 if security in [True, 'check']:
1580 for src in lib.src:
1581 if not proto_re.match(src):
1582 sources_that_need_openssl.add(src)
1583 else:
1584 for src in lib.src:
1585 sources_that_don_t_need_openssl.add(src)
Nicolas "Pixel" Noble061690d2015-03-06 22:58:58 +01001586
Craig Tiller841c8802015-09-10 13:06:37 -07001587 if 'zookeeper' in lib.get('external_deps', []):
1588 libs = libs + ' -lzookeeper_mt'
Hongwei Wanga8cc4392015-07-16 17:37:47 -07001589
Craig Tiller841c8802015-09-10 13:06:37 -07001590 if lib.get('secure', 'check') == True or lib.get('secure', 'check') == 'check':
1591 lib_deps = lib_deps + ' $(OPENSSL_DEP)'
1592 mingw_lib_deps = mingw_lib_deps + ' $(OPENSSL_DEP)'
Nicolas "Pixel" Nobledda049c2015-02-21 00:39:32 +01001593
Craig Tiller841c8802015-09-10 13:06:37 -07001594 if lib.language == 'c++':
1595 common = common + ' $(LDLIBSXX) $(LDLIBS_PROTOBUF)'
1596 %>
nnoble5b7f32a2014-12-22 08:12:44 -08001597
Craig Tiller841c8802015-09-10 13:06:37 -07001598 % if lib.build == "all":
1599 ifeq ($(SYSTEM),MINGW32)
1600 ${out_base}.$(SHARED_EXT): $(LIB${lib.name.upper()}_OBJS) ${mingw_lib_deps}
1601 $(E) "[LD] Linking $@"
1602 $(Q) mkdir -p `dirname $@`
1603 $(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}
1604 else
1605 ${out_libbase}.$(SHARED_EXT): $(LIB${lib.name.upper()}_OBJS) ${lib_deps}
1606 $(E) "[LD] Linking $@"
1607 $(Q) mkdir -p `dirname $@`
1608 ifeq ($(SYSTEM),Darwin)
1609 $(Q) ${ld} $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -install_name lib${lib.name}.$(SHARED_EXT) -dynamiclib -o ${out_libbase}.$(SHARED_EXT) ${common}${libs}
1610 else
1611 $(Q) ${ld} $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,-soname,lib${lib.name}.so.${settings.version.major} -o ${out_libbase}.$(SHARED_EXT) ${common}${libs}
1612 $(Q) ln -sf lib${lib.name}.$(SHARED_EXT) ${out_libbase}.so.${settings.version.major}
1613 $(Q) ln -sf lib${lib.name}.$(SHARED_EXT) ${out_libbase}.so
1614 endif
1615 endif
1616 % endif
1617 % if lib.get('secure', 'check') == True or lib.get('secure', 'check') == 'check':
1618 ## If the lib was secure, we have to close the Makefile's if that tested
1619 ## the presence of OpenSSL.
Nicolas Noble53830622015-02-12 16:56:38 -08001620
Craig Tiller841c8802015-09-10 13:06:37 -07001621 endif
1622 % endif
1623 % if lib.language == 'c++':
1624 ## If the lib was C++, we have to close the Makefile's if that tested
1625 ## the presence of protobuf 3.0.0+
nnoble69ac39f2014-12-12 15:43:38 -08001626
Craig Tiller841c8802015-09-10 13:06:37 -07001627 endif
1628 % endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001629
Craig Tiller841c8802015-09-10 13:06:37 -07001630 % if lib.get('secure', 'check') == True or lib.get('secure', 'check') == 'check':
1631 ifneq ($(NO_SECURE),true)
1632 % endif
1633 ifneq ($(NO_DEPS),true)
1634 -include $(LIB${lib.name.upper()}_OBJS:.o=.dep)
1635 endif
1636 % if lib.get('secure', 'check') == True or lib.get('secure', 'check') == 'check':
1637 endif
1638 % endif
1639 % for src in lib.src:
1640 % if not proto_re.match(src) and any(proto_re.match(src2) for src2 in lib.src):
1641 $(OBJDIR)/$(CONFIG)/${os.path.splitext(src)[0]}.o: ${' '.join(proto_to_cc(src2) for src2 in lib.src if proto_re.match(src2))}
1642 % endif
1643 % endfor
1644 </%def>
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001645
Craig Tiller841c8802015-09-10 13:06:37 -07001646 <%def name="maketarget(tgt)"><% has_no_sources = not tgt.src %>
1647 % if not has_no_sources:
1648 ${tgt.name.upper()}_SRC = \\
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001649
Craig Tiller841c8802015-09-10 13:06:37 -07001650 % for src in tgt.src:
1651 ${proto_to_cc(src)} \\
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001652
Craig Tiller841c8802015-09-10 13:06:37 -07001653 % endfor
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001654
Craig Tiller841c8802015-09-10 13:06:37 -07001655 ${tgt.name.upper()}_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(${tgt.name.upper()}_SRC))))
1656 % endif
1657 % if tgt.get('secure', 'check') == True or tgt.get('secure', 'check') == 'check':
1658 ifeq ($(NO_SECURE),true)
nnoble69ac39f2014-12-12 15:43:38 -08001659
Craig Tiller841c8802015-09-10 13:06:37 -07001660 # You can't build secure targets if you don't have OpenSSL.
Nicolas Noble047b7272015-01-16 13:55:05 -08001661
Craig Tiller841c8802015-09-10 13:06:37 -07001662 $(BINDIR)/$(CONFIG)/${tgt.name}: openssl_dep_error
nnoble69ac39f2014-12-12 15:43:38 -08001663
Craig Tiller841c8802015-09-10 13:06:37 -07001664 else
nnoble69ac39f2014-12-12 15:43:38 -08001665
Craig Tiller841c8802015-09-10 13:06:37 -07001666 % endif
Craig Tiller0fe5ee72015-12-22 12:50:36 -08001667
1668 % if tgt.boringssl:
1669 # boringssl needs an override to ensure that it does not include
1670 # system openssl headers regardless of other configuration
1671 # we do so here with a target specific variable assignment
1672 $(${tgt.name.upper()}_OBJS): CFLAGS := -Ithird_party/boringssl/include $(CFLAGS) -Wno-sign-conversion -Wno-conversion -Wno-unused-value
1673 $(${tgt.name.upper()}_OBJS): CXXFLAGS := -Ithird_party/boringssl/include $(CXXFLAGS)
1674 $(${tgt.name.upper()}_OBJS): CPPFLAGS += -DOPENSSL_NO_ASM -D_GNU_SOURCE
1675 % else:
1676 % endif
1677
Craig Tiller841c8802015-09-10 13:06:37 -07001678 ##
1679 ## We're not trying to add a dependency on building zlib and openssl here,
1680 ## as it's already done in the libraries. We're assuming that the build
1681 ## trickles down, and that a secure target requires a secure version of
1682 ## a library.
1683 ##
1684 ## That simplifies the codegen a bit, but prevents a fully defined Makefile.
1685 ## I can live with that.
1686 ##
1687 % if tgt.build == 'protoc' or tgt.language == 'c++':
Nicolas Noble53830622015-02-12 16:56:38 -08001688
Craig Tiller841c8802015-09-10 13:06:37 -07001689 ifeq ($(NO_PROTOBUF),true)
Nicolas Noble53830622015-02-12 16:56:38 -08001690
Craig Tiller841c8802015-09-10 13:06:37 -07001691 # 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 -08001692
Craig Tiller841c8802015-09-10 13:06:37 -07001693 $(BINDIR)/$(CONFIG)/${tgt.name}: protobuf_dep_error
Nicolas Noble53830622015-02-12 16:56:38 -08001694
Craig Tiller841c8802015-09-10 13:06:37 -07001695 else
Nicolas Noble53830622015-02-12 16:56:38 -08001696
Craig Tiller841c8802015-09-10 13:06:37 -07001697 $(BINDIR)/$(CONFIG)/${tgt.name}: \
1698 % if not has_no_sources:
1699 $(PROTOBUF_DEP) $(${tgt.name.upper()}_OBJS)\
1700 % endif
1701 % else:
1702 $(BINDIR)/$(CONFIG)/${tgt.name}: \
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
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001710
Craig Tiller0fe5ee72015-12-22 12:50:36 -08001711 % if tgt.language == "c++" or tgt.boringssl:
Craig Tiller841c8802015-09-10 13:06:37 -07001712 ## C++ targets specificies.
1713 % if tgt.build == 'protoc':
1714 $(E) "[HOSTLD] Linking $@"
1715 $(Q) mkdir -p `dirname $@`
1716 $(Q) $(HOST_LDXX) $(HOST_LDFLAGS) \
1717 % if not has_no_sources:
1718 $(${tgt.name.upper()}_OBJS)\
1719 % endif
1720 % else:
1721 $(E) "[LD] Linking $@"
1722 $(Q) mkdir -p `dirname $@`
1723 $(Q) $(LDXX) $(LDFLAGS) \
1724 % if not has_no_sources:
1725 $(${tgt.name.upper()}_OBJS)\
1726 % endif
1727 % endif
1728 % else:
1729 ## C-only targets specificities.
1730 $(E) "[LD] Linking $@"
1731 $(Q) mkdir -p `dirname $@`
1732 $(Q) $(LD) $(LDFLAGS) \
1733 % if not has_no_sources:
1734 $(${tgt.name.upper()}_OBJS)\
1735 % endif
1736 % endif
1737 % for dep in tgt.deps:
1738 $(LIBDIR)/$(CONFIG)/lib${dep}.a\
1739 % endfor
1740 % if 'zookeeper' in tgt.get('external_deps', []):
1741 -lzookeeper_mt\
1742 % endif
1743 % if tgt.language == "c++":
1744 % if tgt.build == 'protoc':
1745 $(HOST_LDLIBSXX) $(HOST_LDLIBS_PROTOC)\
1746 % else:
1747 $(LDLIBSXX) $(LDLIBS_PROTOBUF)\
1748 % endif
1749 % endif
1750 % if tgt.build == 'protoc':
1751 $(HOST_LDLIBS)\
1752 % else:
1753 $(LDLIBS)\
1754 % endif
1755 % if tgt.build == 'protoc':
1756 $(HOST_LDLIBS_PROTOC)\
1757 % elif tgt.get('secure', 'check') == True or tgt.get('secure', 'check') == 'check':
1758 $(LDLIBS_SECURE)\
1759 % endif
1760 % if tgt.language == 'c++' and tgt.build == 'test':
1761 $(GTEST_LIB)\
1762 % elif tgt.language == 'c++' and tgt.build == 'benchmark':
1763 $(GTEST_LIB)\
1764 % endif
1765 -o $(BINDIR)/$(CONFIG)/${tgt.name}
1766 % if tgt.build == 'protoc' or tgt.language == 'c++':
Nicolas Noble53830622015-02-12 16:56:38 -08001767
Craig Tiller841c8802015-09-10 13:06:37 -07001768 endif
1769 % endif
1770 % if tgt.get('secure', 'check') == True or tgt.get('secure', 'check') == 'check':
nnoble69ac39f2014-12-12 15:43:38 -08001771
Craig Tiller841c8802015-09-10 13:06:37 -07001772 endif
1773 % endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001774
Craig Tiller841c8802015-09-10 13:06:37 -07001775 % for src in tgt.src:
1776 $(OBJDIR)/$(CONFIG)/${os.path.splitext(src)[0]}.o: \
1777 % for dep in tgt.deps:
1778 $(LIBDIR)/$(CONFIG)/lib${dep}.a\
1779 % endfor
Craig Tillerf5371ef2015-01-12 16:40:18 -08001780
Craig Tillerab230452016-01-04 08:18:43 -08001781 % if tgt.language == 'c89':
1782 % for src in tgt.src:
Craig Tillerea21ca22016-01-04 12:34:29 -08001783 $(OBJDIR)/$(CONFIG)/${os.path.splitext(src)[0]}.o : ${src}
1784 $(E) "[C] Compiling $<"
1785 $(Q) mkdir -p `dirname $@`
1786 $(Q) $(CC) $(CFLAGS) $(CPPFLAGS) -std=c89 -pedantic -MMD -MF $(addsuffix .dep, $(basename $@)) -c -o $@ $<
Craig Tillerab230452016-01-04 08:18:43 -08001787 % endfor
1788 % endif
1789
Craig Tiller841c8802015-09-10 13:06:37 -07001790 % endfor
1791 % if not has_no_sources:
1792 deps_${tgt.name}: $(${tgt.name.upper()}_OBJS:.o=.dep)
1793 % endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001794
Craig Tiller841c8802015-09-10 13:06:37 -07001795 % if not has_no_sources:
1796 % if tgt.get('secure', 'check') == True or tgt.get('secure', 'check') == 'check':
1797 ifneq ($(NO_SECURE),true)
1798 % endif
1799 ifneq ($(NO_DEPS),true)
1800 -include $(${tgt.name.upper()}_OBJS:.o=.dep)
1801 endif
1802 % if tgt.get('secure', 'check') == True or tgt.get('secure', 'check') == 'check':
1803 endif
1804 % endif
1805 % endif
Nicolas "Pixel" Noble472bb682015-11-03 19:09:01 +01001806 % for src in tgt.src:
1807 % if not proto_re.match(src) and any(proto_re.match(src2) for src2 in tgt.src):
1808 $(OBJDIR)/$(CONFIG)/${os.path.splitext(src)[0]}.o: ${' '.join(proto_to_cc(src2) for src2 in tgt.src if proto_re.match(src2))}
1809 % endif
1810 % endfor
Craig Tiller841c8802015-09-10 13:06:37 -07001811 </%def>
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001812
Craig Tiller841c8802015-09-10 13:06:37 -07001813 ifneq ($(OPENSSL_DEP),)
1814 # This is to ensure the embedded OpenSSL is built beforehand, properly
1815 # installing headers to their final destination on the drive. We need this
1816 # otherwise parallel compilation will fail if a source is compiled first.
1817 % for src in sorted(sources_that_need_openssl):
1818 % if src not in sources_that_don_t_need_openssl:
1819 ${src}: $(OPENSSL_DEP)
1820 % endif
1821 % endfor
1822 endif
Nicolas "Pixel" Noble010f1e72015-04-23 02:23:49 +02001823
Craig Tiller841c8802015-09-10 13:06:37 -07001824 .PHONY: all strip tools \
1825 dep_error openssl_dep_error openssl_dep_message git_update stop \
1826 buildtests buildtests_c buildtests_cxx \
1827 test test_c test_cxx \
1828 install install_c install_cxx \
1829 install-headers install-headers_c install-headers_cxx \
1830 install-shared install-shared_c install-shared_cxx \
1831 install-static install-static_c install-static_cxx \
1832 strip strip-shared strip-static \
1833 strip_c strip-shared_c strip-static_c \
1834 strip_cxx strip-shared_cxx strip-static_cxx \
1835 dep_c dep_cxx bins_dep_c bins_dep_cxx \
1836 clean