blob: 91f26a37d56ca8d67cfa30342ab7f1121f33a6ee [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
Craig Tiller841c8802015-09-10 13:06:37 -0700133 PROTOC = protoc
134 DTRACE = dtrace
135 CONFIG ?= opt
136 CC = $(CC_$(CONFIG))
137 CXX = $(CXX_$(CONFIG))
138 LD = $(LD_$(CONFIG))
139 LDXX = $(LDXX_$(CONFIG))
140 AR = ar
141 ifeq ($(SYSTEM),Linux)
142 STRIP = strip --strip-unneeded
143 else
144 ifeq ($(SYSTEM),Darwin)
145 STRIP = strip -x
146 else
147 STRIP = strip
148 endif
149 endif
150 INSTALL = install
151 RM = rm -f
152 PKG_CONFIG = pkg-config
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800153
Craig Tiller841c8802015-09-10 13:06:37 -0700154 ifndef VALID_CONFIG_$(CONFIG)
155 $(error Invalid CONFIG value '$(CONFIG)')
156 endif
yangg102e4fe2015-01-06 16:02:50 -0800157
Craig Tiller841c8802015-09-10 13:06:37 -0700158 ifeq ($(SYSTEM),Linux)
159 TMPOUT = /dev/null
160 else
161 TMPOUT = `mktemp /tmp/test-out-XXXXXX`
162 endif
Nicolas Noble047b7272015-01-16 13:55:05 -0800163
Craig Tiller841c8802015-09-10 13:06:37 -0700164 # Detect if we can use C++11
165 CXX11_CHECK_CMD = $(CXX) -std=c++11 -o $(TMPOUT) -c test/build/c++11.cc
166 HAS_CXX11 = $(shell $(CXX11_CHECK_CMD) 2> /dev/null && echo true || echo false)
Craig Tillercf133f42015-02-26 14:05:56 -0800167
Craig Tiller82f3f0d2016-01-25 11:27:42 -0800168 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 -0800169 HAS_NO_SHIFT_NEGATIVE_VALUE = $(shell $(CHECK_NO_SHIFT_NEGATIVE_VALUE_CMD) 2> /dev/null && echo true || echo false)
170 ifeq ($(HAS_NO_SHIFT_NEGATIVE_VALUE),true)
171 W_NO_SHIFT_NEGATIVE_VALUE=-Wno-shift-negative-value
172 endif
173
Craig Tiller841c8802015-09-10 13:06:37 -0700174 # The HOST compiler settings are used to compile the protoc plugins.
175 # In most cases, you won't have to change anything, but if you are
176 # cross-compiling, you can override these variables from GNU make's
177 # command line: make CC=cross-gcc HOST_CC=gcc
Nicolas Noble047b7272015-01-16 13:55:05 -0800178
Craig Tiller841c8802015-09-10 13:06:37 -0700179 HOST_CC = $(CC)
180 HOST_CXX = $(CXX)
181 HOST_LD = $(LD)
182 HOST_LDXX = $(LDXX)
nnoble72309c62014-12-12 11:42:26 -0800183
Craig Tiller841c8802015-09-10 13:06:37 -0700184 ifdef EXTRA_DEFINES
185 DEFINES += $(EXTRA_DEFINES)
186 endif
Craig Tiller86fa1c52015-02-27 09:57:58 -0800187
Craig Tiller0fe5ee72015-12-22 12:50:36 -0800188 CFLAGS += -std=c99 -Wsign-conversion -Wconversion -Wshadow
Craig Tiller841c8802015-09-10 13:06:37 -0700189 ifeq ($(HAS_CXX11),true)
190 CXXFLAGS += -std=c++11
191 else
192 CXXFLAGS += -std=c++0x
193 endif
Craig Tiller0fe5ee72015-12-22 12:50:36 -0800194 CFLAGS += -g -Wall -Wextra -Werror -Wno-long-long -Wno-unused-parameter
195 CXXFLAGS += -g -Wall -Wextra -Werror -Wno-long-long -Wno-unused-parameter
Craig Tiller841c8802015-09-10 13:06:37 -0700196 LDFLAGS += -g
Nicolas Noblef8681182015-03-18 14:25:44 -0700197
Craig Tiller841c8802015-09-10 13:06:37 -0700198 CPPFLAGS += $(CPPFLAGS_$(CONFIG))
Craig Tiller0fe5ee72015-12-22 12:50:36 -0800199 CFLAGS += $(CFLAGS_$(CONFIG))
200 CXXFLAGS += $(CXXFLAGS_$(CONFIG))
Craig Tiller841c8802015-09-10 13:06:37 -0700201 DEFINES += $(DEFINES_$(CONFIG)) INSTALL_PREFIX=\"$(prefix)\"
202 LDFLAGS += $(LDFLAGS_$(CONFIG))
Nicolas "Pixel" Noble482d7612015-07-16 23:43:30 +0200203
Craig Tiller841c8802015-09-10 13:06:37 -0700204 ifneq ($(SYSTEM),MINGW32)
205 PIC_CPPFLAGS = -fPIC
206 CPPFLAGS += -fPIC
207 LDFLAGS += -fPIC
208 endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800209
Craig Tiller841c8802015-09-10 13:06:37 -0700210 INCLUDES = . include $(GENDIR)
211 LDFLAGS += -Llibs/$(CONFIG)
Nicolas "Pixel" Noble3adab742015-06-02 00:33:06 +0200212
Craig Tiller841c8802015-09-10 13:06:37 -0700213 ifeq ($(SYSTEM),Darwin)
214 ifneq ($(wildcard /usr/local/ssl/include),)
215 INCLUDES += /usr/local/ssl/include
216 endif
217 ifneq ($(wildcard /opt/local/include),)
218 INCLUDES += /opt/local/include
219 endif
220 ifneq ($(wildcard /usr/local/include),)
221 INCLUDES += /usr/local/include
222 endif
223 LIBS = m z
224 ifneq ($(wildcard /usr/local/ssl/lib),)
225 LDFLAGS += -L/usr/local/ssl/lib
226 endif
227 ifneq ($(wildcard /opt/local/lib),)
228 LDFLAGS += -L/opt/local/lib
229 endif
230 ifneq ($(wildcard /usr/local/lib),)
231 LDFLAGS += -L/usr/local/lib
232 endif
233 endif
Nicolas Noblef8681182015-03-18 14:25:44 -0700234
Craig Tiller841c8802015-09-10 13:06:37 -0700235 ifeq ($(SYSTEM),Linux)
Craig Tiller0fe5ee72015-12-22 12:50:36 -0800236 LIBS = rt m pthread
Craig Tiller841c8802015-09-10 13:06:37 -0700237 LDFLAGS += -pthread
238 endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800239
Craig Tiller841c8802015-09-10 13:06:37 -0700240 ifeq ($(SYSTEM),MINGW32)
Craig Tiller0fe5ee72015-12-22 12:50:36 -0800241 LIBS = m pthread
Craig Tiller841c8802015-09-10 13:06:37 -0700242 LDFLAGS += -pthread
243 endif
Nicolas Noblef8681182015-03-18 14:25:44 -0700244
Craig Tiller841c8802015-09-10 13:06:37 -0700245 GTEST_LIB = -Ithird_party/googletest/include -Ithird_party/googletest third_party/googletest/src/gtest-all.cc
246 GTEST_LIB += -lgflags
247 ifeq ($(V),1)
248 E = @:
249 Q =
250 else
251 E = @echo
252 Q = @
253 endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800254
Craig Tiller841c8802015-09-10 13:06:37 -0700255 VERSION = ${settings.version.major}.${settings.version.minor}.${settings.version.micro}.${settings.version.build}
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800256
Craig Tiller841c8802015-09-10 13:06:37 -0700257 CPPFLAGS_NO_ARCH += $(addprefix -I, $(INCLUDES)) $(addprefix -D, $(DEFINES))
258 CPPFLAGS += $(CPPFLAGS_NO_ARCH) $(ARCH_FLAGS)
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800259
Craig Tiller841c8802015-09-10 13:06:37 -0700260 LDFLAGS += $(ARCH_FLAGS)
261 LDLIBS += $(addprefix -l, $(LIBS))
262 LDLIBSXX += $(addprefix -l, $(LIBSXX))
nnoble72309c62014-12-12 11:42:26 -0800263
Craig Tiller841c8802015-09-10 13:06:37 -0700264 HOST_CPPFLAGS = $(CPPFLAGS)
265 HOST_CFLAGS = $(CFLAGS)
266 HOST_CXXFLAGS = $(CXXFLAGS)
267 HOST_LDFLAGS = $(LDFLAGS)
268 HOST_LDLIBS = $(LDLIBS)
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800269
Craig Tiller841c8802015-09-10 13:06:37 -0700270 # These are automatically computed variables.
271 # There shouldn't be any need to change anything from now on.
nnoble69ac39f2014-12-12 15:43:38 -0800272
Craig Tiller841c8802015-09-10 13:06:37 -0700273 -include cache.mk
murgatroid9924e2f4a2015-06-29 11:12:01 -0700274
Craig Tiller841c8802015-09-10 13:06:37 -0700275 CACHE_MK =
murgatroid99aa521572015-07-10 14:49:12 -0700276
Craig Tiller841c8802015-09-10 13:06:37 -0700277 HAS_PKG_CONFIG ?= $(shell command -v $(PKG_CONFIG) >/dev/null 2>&1 && echo true || echo false)
murgatroid99aa521572015-07-10 14:49:12 -0700278
Craig Tiller841c8802015-09-10 13:06:37 -0700279 ifeq ($(HAS_PKG_CONFIG), true)
280 CACHE_MK += HAS_PKG_CONFIG = true,
281 endif
nnoble69ac39f2014-12-12 15:43:38 -0800282
Craig Tiller841c8802015-09-10 13:06:37 -0700283 PC_TEMPLATE = prefix=$(prefix),\
284 exec_prefix=${'\$${prefix}'},\
285 includedir=${'\$${prefix}'}/include,\
286 libdir=${'\$${exec_prefix}'}/lib,\
287 ,\
288 Name: $(PC_NAME),\
289 Description: $(PC_DESCRIPTION),\
290 Version: $(VERSION),\
291 Cflags: -I${'\$${includedir}'} $(PC_CFLAGS),\
292 Requires.private: $(PC_REQUIRES_PRIVATE),\
293 Libs: -L${'\$${libdir}'} $(PC_LIB),\
294 Libs.private: $(PC_LIBS_PRIVATE)
murgatroid998faab232015-06-30 17:24:21 -0700295
Craig Tiller841c8802015-09-10 13:06:37 -0700296 # gpr .pc file
297 PC_NAME = gRPC Portable Runtime
298 PC_DESCRIPTION = gRPC Portable Runtime
299 PC_CFLAGS = -pthread
300 PC_REQUIRES_PRIVATE =
301 PC_LIBS_PRIVATE = -lpthread
302 PC_LIB = -lgpr
303 ifneq ($(SYSTEM),Darwin)
304 PC_LIBS_PRIVATE += -lrt
305 endif
306 GPR_PC_FILE := $(PC_TEMPLATE)
murgatroid998faab232015-06-30 17:24:21 -0700307
Craig Tiller841c8802015-09-10 13:06:37 -0700308 ifeq ($(SYSTEM),MINGW32)
309 SHARED_EXT = dll
310 endif
311 ifeq ($(SYSTEM),Darwin)
312 SHARED_EXT = dylib
313 endif
314 ifeq ($(SHARED_EXT),)
315 SHARED_EXT = so.$(VERSION)
316 endif
nnoble5b7f32a2014-12-22 08:12:44 -0800317
Craig Tiller841c8802015-09-10 13:06:37 -0700318 ifeq ($(wildcard .git),)
319 IS_GIT_FOLDER = false
320 else
321 IS_GIT_FOLDER = true
322 endif
nnoble69ac39f2014-12-12 15:43:38 -0800323
Craig Tiller841c8802015-09-10 13:06:37 -0700324 ifeq ($(SYSTEM),Linux)
325 OPENSSL_REQUIRES_DL = true
326 endif
Nicolas Noblef8681182015-03-18 14:25:44 -0700327
Craig Tiller841c8802015-09-10 13:06:37 -0700328 ifeq ($(SYSTEM),Darwin)
329 OPENSSL_REQUIRES_DL = true
330 endif
Nicolas Noblef8681182015-03-18 14:25:44 -0700331
Craig Tiller841c8802015-09-10 13:06:37 -0700332 ifeq ($(HAS_PKG_CONFIG),true)
333 OPENSSL_ALPN_CHECK_CMD = $(PKG_CONFIG) --atleast-version=1.0.2 openssl
334 OPENSSL_NPN_CHECK_CMD = $(PKG_CONFIG) --atleast-version=1.0.1 openssl
335 ZLIB_CHECK_CMD = $(PKG_CONFIG) --exists zlib
336 PROTOBUF_CHECK_CMD = $(PKG_CONFIG) --atleast-version=3.0.0-alpha-3 protobuf
337 else # HAS_PKG_CONFIG
murgatroid9924e2f4a2015-06-29 11:12:01 -0700338
Craig Tiller841c8802015-09-10 13:06:37 -0700339 ifeq ($(SYSTEM),MINGW32)
340 OPENSSL_LIBS = ssl32 eay32
341 else
342 OPENSSL_LIBS = ssl crypto
343 endif
Nicolas Noblef8681182015-03-18 14:25:44 -0700344
Craig Tiller841c8802015-09-10 13:06:37 -0700345 OPENSSL_ALPN_CHECK_CMD = $(CC) $(CFLAGS) $(CPPFLAGS) -o $(TMPOUT) test/build/openssl-alpn.c $(addprefix -l, $(OPENSSL_LIBS)) $(LDFLAGS)
346 OPENSSL_NPN_CHECK_CMD = $(CC) $(CFLAGS) $(CPPFLAGS) -o $(TMPOUT) test/build/openssl-npn.c $(addprefix -l, $(OPENSSL_LIBS)) $(LDFLAGS)
347 ZLIB_CHECK_CMD = $(CC) $(CFLAGS) $(CPPFLAGS) -o $(TMPOUT) test/build/zlib.c -lz $(LDFLAGS)
348 PROTOBUF_CHECK_CMD = $(CXX) $(CXXFLAGS) $(CPPFLAGS) -o $(TMPOUT) test/build/protobuf.cc -lprotobuf $(LDFLAGS)
Craig Tiller297fafa2015-01-15 15:46:39 -0800349
Craig Tiller841c8802015-09-10 13:06:37 -0700350 ifeq ($(OPENSSL_REQUIRES_DL),true)
351 OPENSSL_ALPN_CHECK_CMD += -ldl
352 OPENSSL_NPN_CHECK_CMD += -ldl
353 endif
Nicolas Noblef8681182015-03-18 14:25:44 -0700354
Craig Tiller841c8802015-09-10 13:06:37 -0700355 endif # HAS_PKG_CONFIG
murgatroid9924e2f4a2015-06-29 11:12:01 -0700356
Craig Tiller841c8802015-09-10 13:06:37 -0700357 PERFTOOLS_CHECK_CMD = $(CC) $(CFLAGS) $(CPPFLAGS) -o $(TMPOUT) test/build/perftools.c -lprofiler $(LDFLAGS)
murgatroid996d9e4012015-07-08 10:22:45 -0700358
Craig Tiller841c8802015-09-10 13:06:37 -0700359 PROTOC_CHECK_CMD = which protoc > /dev/null
360 PROTOC_CHECK_VERSION_CMD = protoc --version | grep -q libprotoc.3
361 DTRACE_CHECK_CMD = which dtrace > /dev/null
362 SYSTEMTAP_HEADERS_CHECK_CMD = $(CC) $(CFLAGS) $(CPPFLAGS) -o $(TMPOUT) test/build/systemtap.c $(LDFLAGS)
363 ZOOKEEPER_CHECK_CMD = $(CC) $(CFLAGS) $(CPPFLAGS) -o $(TMPOUT) test/build/zookeeper.c $(LDFLAGS) -lzookeeper_mt
murgatroid9924e2f4a2015-06-29 11:12:01 -0700364
Craig Tiller841c8802015-09-10 13:06:37 -0700365 ifndef REQUIRE_CUSTOM_LIBRARIES_$(CONFIG)
366 HAS_SYSTEM_PERFTOOLS ?= $(shell $(PERFTOOLS_CHECK_CMD) 2> /dev/null && echo true || echo false)
367 ifeq ($(HAS_SYSTEM_PERFTOOLS),true)
368 DEFINES += GRPC_HAVE_PERFTOOLS
369 LIBS += profiler
370 CACHE_MK += HAS_SYSTEM_PERFTOOLS = true,
371 endif
372 endif
nnoble69ac39f2014-12-12 15:43:38 -0800373
Craig Tiller841c8802015-09-10 13:06:37 -0700374 HAS_SYSTEM_PROTOBUF_VERIFY = $(shell $(PROTOBUF_CHECK_CMD) 2> /dev/null && echo true || echo false)
375 ifndef REQUIRE_CUSTOM_LIBRARIES_$(CONFIG)
376 HAS_SYSTEM_OPENSSL_ALPN ?= $(shell $(OPENSSL_ALPN_CHECK_CMD) 2> /dev/null && echo true || echo false)
377 ifeq ($(HAS_SYSTEM_OPENSSL_ALPN),true)
378 HAS_SYSTEM_OPENSSL_NPN = true
379 CACHE_MK += HAS_SYSTEM_OPENSSL_ALPN = true,
380 else
381 HAS_SYSTEM_OPENSSL_NPN ?= $(shell $(OPENSSL_NPN_CHECK_CMD) 2> /dev/null && echo true || echo false)
382 endif
383 ifeq ($(HAS_SYSTEM_OPENSSL_NPN),true)
384 CACHE_MK += HAS_SYSTEM_OPENSSL_NPN = true,
385 endif
386 HAS_SYSTEM_ZLIB ?= $(shell $(ZLIB_CHECK_CMD) 2> /dev/null && echo true || echo false)
387 ifeq ($(HAS_SYSTEM_ZLIB),true)
388 CACHE_MK += HAS_SYSTEM_ZLIB = true,
389 endif
390 HAS_SYSTEM_PROTOBUF ?= $(HAS_SYSTEM_PROTOBUF_VERIFY)
391 ifeq ($(HAS_SYSTEM_PROTOBUF),true)
392 CACHE_MK += HAS_SYSTEM_PROTOBUF = true,
393 endif
394 else
395 # override system libraries if the config requires a custom compiled library
396 HAS_SYSTEM_OPENSSL_ALPN = false
397 HAS_SYSTEM_OPENSSL_NPN = false
398 HAS_SYSTEM_ZLIB = false
399 HAS_SYSTEM_PROTOBUF = false
400 endif
nnoble69ac39f2014-12-12 15:43:38 -0800401
Craig Tiller841c8802015-09-10 13:06:37 -0700402 HAS_PROTOC ?= $(shell $(PROTOC_CHECK_CMD) 2> /dev/null && echo true || echo false)
403 ifeq ($(HAS_PROTOC),true)
404 CACHE_MK += HAS_PROTOC = true,
405 HAS_VALID_PROTOC ?= $(shell $(PROTOC_CHECK_VERSION_CMD) 2> /dev/null && echo true || echo false)
406 ifeq ($(HAS_VALID_PROTOC),true)
407 CACHE_MK += HAS_VALID_PROTOC = true,
408 endif
409 else
410 HAS_VALID_PROTOC = false
411 endif
Nicolas Noble53830622015-02-12 16:56:38 -0800412
Craig Tiller841c8802015-09-10 13:06:37 -0700413 # Check for Systemtap (https://sourceware.org/systemtap/), first by making sure <sys/sdt.h> is present
414 # in the system and secondly by checking for the "dtrace" binary (on Linux, this is part of the Systemtap
415 # distribution. It's part of the base system on BSD/Solaris machines).
416 ifndef HAS_SYSTEMTAP
417 HAS_SYSTEMTAP_HEADERS = $(shell $(SYSTEMTAP_HEADERS_CHECK_CMD) 2> /dev/null && echo true || echo false)
418 HAS_DTRACE = $(shell $(DTRACE_CHECK_CMD) 2> /dev/null && echo true || echo false)
419 HAS_SYSTEMTAP = false
420 ifeq ($(HAS_SYSTEMTAP_HEADERS),true)
421 ifeq ($(HAS_DTRACE),true)
422 HAS_SYSTEMTAP = true
423 endif
424 endif
425 endif
David Garcia Quintas611b7362015-04-27 15:49:31 -0700426
Craig Tiller841c8802015-09-10 13:06:37 -0700427 ifeq ($(HAS_SYSTEMTAP),true)
428 CACHE_MK += HAS_SYSTEMTAP = true,
429 endif
nnoble69ac39f2014-12-12 15:43:38 -0800430
Craig Tiller841c8802015-09-10 13:06:37 -0700431 HAS_ZOOKEEPER = $(shell $(ZOOKEEPER_CHECK_CMD) 2> /dev/null && echo true || echo false)
Hongwei Wanga8cc4392015-07-16 17:37:47 -0700432
Craig Tiller841c8802015-09-10 13:06:37 -0700433 # Note that for testing purposes, one can do:
434 # make HAS_EMBEDDED_OPENSSL_ALPN=false
435 # to emulate the fact we do not have OpenSSL in the third_party folder.
Craig Tiller0fe5ee72015-12-22 12:50:36 -0800436 ifeq ($(wildcard third_party/boringssl/include/openssl/ssl.h),)
Craig Tiller841c8802015-09-10 13:06:37 -0700437 HAS_EMBEDDED_OPENSSL_ALPN = false
438 else
439 HAS_EMBEDDED_OPENSSL_ALPN = true
440 endif
nnoble69ac39f2014-12-12 15:43:38 -0800441
Craig Tiller841c8802015-09-10 13:06:37 -0700442 ifeq ($(wildcard third_party/zlib/zlib.h),)
443 HAS_EMBEDDED_ZLIB = false
444 else
445 HAS_EMBEDDED_ZLIB = true
446 endif
nnoble69ac39f2014-12-12 15:43:38 -0800447
Craig Tiller841c8802015-09-10 13:06:37 -0700448 ifeq ($(wildcard third_party/protobuf/src/google/protobuf/descriptor.pb.h),)
449 HAS_EMBEDDED_PROTOBUF = false
450 ifneq ($(HAS_VALID_PROTOC),true)
451 NO_PROTOC = true
452 endif
453 else
454 HAS_EMBEDDED_PROTOBUF = true
455 endif
Nicolas Noble53830622015-02-12 16:56:38 -0800456
Craig Tiller841c8802015-09-10 13:06:37 -0700457 PC_REQUIRES_GRPC = gpr
458 PC_LIBS_GRPC =
murgatroid998faab232015-06-30 17:24:21 -0700459
Craig Tiller841c8802015-09-10 13:06:37 -0700460 ifeq ($(HAS_SYSTEM_ZLIB),false)
Craig Tiller3dca23a2016-01-21 11:44:55 -0800461 ifeq ($(HAS_EMBEDDED_ZLIB), true)
462 EMBED_ZLIB ?= true
Craig Tiller841c8802015-09-10 13:06:37 -0700463 else
464 DEP_MISSING += zlib
Craig Tiller3dca23a2016-01-21 11:44:55 -0800465 EMBED_ZLIB ?= broken
Craig Tiller841c8802015-09-10 13:06:37 -0700466 endif
467 else
Craig Tiller3dca23a2016-01-21 11:44:55 -0800468 EMBED_ZLIB ?= false
469 endif
470
471 ifeq ($(EMBED_ZLIB),true)
472 ZLIB_DEP = $(LIBDIR)/$(CONFIG)/libz.a
473 ZLIB_MERGE_LIBS = $(LIBDIR)/$(CONFIG)/libz.a
474 CPPFLAGS += -Ithird_party/zlib
475 LDFLAGS += -L$(LIBDIR)/$(CONFIG)/zlib
476 else
Craig Tiller841c8802015-09-10 13:06:37 -0700477 ifeq ($(HAS_PKG_CONFIG),true)
478 CPPFLAGS += $(shell $(PKG_CONFIG) --cflags zlib)
479 LDFLAGS += $(shell $(PKG_CONFIG) --libs-only-L zlib)
Craig Tiller0fe5ee72015-12-22 12:50:36 -0800480 LIBS += $(patsubst -l%,%,$(shell $(PKG_CONFIG) --libs-only-l zlib))
Craig Tiller841c8802015-09-10 13:06:37 -0700481 PC_REQUIRES_GRPC += zlib
482 else
483 PC_LIBS_GRPC += -lz
Craig Tiller0fe5ee72015-12-22 12:50:36 -0800484 LIBS += z
Craig Tiller841c8802015-09-10 13:06:37 -0700485 endif
486 endif
nnoble69ac39f2014-12-12 15:43:38 -0800487
Craig Tiller841c8802015-09-10 13:06:37 -0700488 OPENSSL_PKG_CONFIG = false
murgatroid99da7a9942015-06-29 14:57:37 -0700489
Craig Tiller841c8802015-09-10 13:06:37 -0700490 PC_REQUIRES_SECURE =
491 PC_LIBS_SECURE =
murgatroid998faab232015-06-30 17:24:21 -0700492
Craig Tiller841c8802015-09-10 13:06:37 -0700493 ifeq ($(HAS_SYSTEM_OPENSSL_ALPN),true)
Craig Tiller0fe5ee72015-12-22 12:50:36 -0800494 EMBED_OPENSSL ?= false
495 NO_SECURE ?= false
496 else # HAS_SYSTEM_OPENSSL_ALPN=false
497 ifeq ($(HAS_EMBEDDED_OPENSSL_ALPN),true)
498 EMBED_OPENSSL ?= true
499 NO_SECURE ?= false
500 else # HAS_EMBEDDED_OPENSSL_ALPN=false
501 ifeq ($(HAS_SYSTEM_OPENSSL_NPN),true)
502 EMBED_OPENSSL ?= false
503 NO_SECURE ?= false
504 else
505 NO_SECURE ?= true
506 endif # HAS_SYSTEM_OPENSSL_NPN=true
507 endif # HAS_EMBEDDED_OPENSSL_ALPN
508 endif # HAS_SYSTEM_OPENSSL_ALPN
509
510 OPENSSL_DEP :=
511 OPENSSL_MERGE_LIBS :=
512 ifeq ($(NO_SECURE),false)
513 ifeq ($(EMBED_OPENSSL),true)
514 OPENSSL_DEP += $(LIBDIR)/$(CONFIG)/libboringssl.a
515 OPENSSL_MERGE_LIBS += $(LIBDIR)/$(CONFIG)/libboringssl.a
516 # need to prefix these to ensure overriding system libraries
517 CPPFLAGS := -Ithird_party/boringssl/include $(CPPFLAGS)
518 ifeq ($(OPENSSL_REQUIRES_DL),true)
519 LIBS_SECURE = dl
520 endif # OPENSSL_REQUIRES_DL
521 else # EMBED_OPENSSL=false
Craig Tiller841c8802015-09-10 13:06:37 -0700522 ifeq ($(HAS_PKG_CONFIG),true)
523 OPENSSL_PKG_CONFIG = true
524 PC_REQUIRES_SECURE = openssl
525 CPPFLAGS := $(shell $(PKG_CONFIG) --cflags openssl) $(CPPFLAGS)
526 LDFLAGS_OPENSSL_PKG_CONFIG = $(shell $(PKG_CONFIG) --libs-only-L openssl)
527 ifeq ($(SYSTEM),Linux)
528 ifneq ($(LDFLAGS_OPENSSL_PKG_CONFIG),)
529 LDFLAGS_OPENSSL_PKG_CONFIG += $(shell $(PKG_CONFIG) --libs-only-L openssl | sed s/L/Wl,-rpath,/)
Craig Tiller0fe5ee72015-12-22 12:50:36 -0800530 endif # LDFLAGS_OPENSSL_PKG_CONFIG=''
531 endif # System=Linux
Craig Tiller841c8802015-09-10 13:06:37 -0700532 LDFLAGS := $(LDFLAGS_OPENSSL_PKG_CONFIG) $(LDFLAGS)
Craig Tiller0fe5ee72015-12-22 12:50:36 -0800533 else # HAS_PKG_CONFIG=false
Craig Tiller841c8802015-09-10 13:06:37 -0700534 LIBS_SECURE = $(OPENSSL_LIBS)
Craig Tiller0fe5ee72015-12-22 12:50:36 -0800535 endif # HAS_PKG_CONFIG
536 ifeq ($(HAS_SYSTEM_OPENSSL_NPN),true)
537 CPPFLAGS += -DTSI_OPENSSL_ALPN_SUPPORT=0
538 LIBS_SECURE = $(OPENSSL_LIBS)
539 endif # HAS_SYSTEM_OPENSSL_NPN
Craig Tiller841c8802015-09-10 13:06:37 -0700540 ifeq ($(OPENSSL_REQUIRES_DL),true)
541 LIBS_SECURE += dl
542 PC_LIBS_SECURE = $(addprefix -l, $(LIBS_SECURE))
Craig Tiller0fe5ee72015-12-22 12:50:36 -0800543 endif # OPENSSL_REQUIRES_DL=true
544 endif # EMBED_OPENSSL
545 endif # NO_SECURE
nnoble69ac39f2014-12-12 15:43:38 -0800546
Craig Tiller841c8802015-09-10 13:06:37 -0700547 ifeq ($(OPENSSL_PKG_CONFIG),true)
548 LDLIBS_SECURE += $(shell $(PKG_CONFIG) --libs-only-l openssl)
549 else
550 LDLIBS_SECURE += $(addprefix -l, $(LIBS_SECURE))
551 endif
nnoble5b7f32a2014-12-22 08:12:44 -0800552
Craig Tiller841c8802015-09-10 13:06:37 -0700553 # grpc .pc file
554 PC_NAME = gRPC
555 PC_DESCRIPTION = high performance general RPC framework
556 PC_CFLAGS =
557 PC_REQUIRES_PRIVATE = $(PC_REQUIRES_GRPC) $(PC_REQUIRES_SECURE)
558 PC_LIBS_PRIVATE = $(PC_LIBS_GRPC) $(PC_LIBS_SECURE)
559 PC_LIB = -lgrpc
560 GRPC_PC_FILE := $(PC_TEMPLATE)
murgatroid998faab232015-06-30 17:24:21 -0700561
Craig Tiller841c8802015-09-10 13:06:37 -0700562 # gprc_unsecure .pc file
563 PC_NAME = gRPC unsecure
564 PC_DESCRIPTION = high performance general RPC framework without SSL
565 PC_CFLAGS =
566 PC_REQUIRES_PRIVATE = $(PC_REQUIRES_GRPC)
567 PC_LIBS_PRIVATE = $(PC_LIBS_GRPC)
568 PC_LIB = -lgrpc
569 GRPC_UNSECURE_PC_FILE := $(PC_TEMPLATE)
murgatroid998faab232015-06-30 17:24:21 -0700570
Craig Tiller841c8802015-09-10 13:06:37 -0700571 # gprc_zookeeper .pc file
572 PC_NAME = gRPC zookeeper
573 PC_DESCRIPTION = gRPC's zookeeper plugin
574 PC_CFLAGS =
575 PC_REQUIRES_PRIVATE =
576 PC_LIBS_PRIVATE = -lzookeeper_mt
577 GRPC_ZOOKEEPER_PC_FILE := $(PC_TEMPLATE)
Hongwei Wanga8cc4392015-07-16 17:37:47 -0700578
Craig Tiller841c8802015-09-10 13:06:37 -0700579 PROTOBUF_PKG_CONFIG = false
murgatroid99da7a9942015-06-29 14:57:37 -0700580
Craig Tiller841c8802015-09-10 13:06:37 -0700581 PC_REQUIRES_GRPCXX =
582 PC_LIBS_GRPCXX =
murgatroid998faab232015-06-30 17:24:21 -0700583
Craig Tiller841c8802015-09-10 13:06:37 -0700584 CPPFLAGS := -Ithird_party/googletest/include $(CPPFLAGS)
Craig Tiller16f6dac2015-08-24 17:00:04 -0700585
Craig Tiller841c8802015-09-10 13:06:37 -0700586 ifeq ($(HAS_SYSTEM_PROTOBUF),true)
587 ifeq ($(HAS_PKG_CONFIG),true)
588 PROTOBUF_PKG_CONFIG = true
589 PC_REQUIRES_GRPCXX = protobuf
590 CPPFLAGS := $(shell $(PKG_CONFIG) --cflags protobuf) $(CPPFLAGS)
591 LDFLAGS_PROTOBUF_PKG_CONFIG = $(shell $(PKG_CONFIG) --libs-only-L protobuf)
592 ifeq ($(SYSTEM),Linux)
593 ifneq ($(LDFLAGS_PROTOBUF_PKG_CONFIG),)
594 LDFLAGS_PROTOBUF_PKG_CONFIG += $(shell $(PKG_CONFIG) --libs-only-L protobuf | sed s/L/Wl,-rpath,/)
595 endif
596 endif
597 else
598 PC_LIBS_GRPCXX = -lprotobuf
599 endif
600 else
601 ifeq ($(HAS_EMBEDDED_PROTOBUF),true)
602 PROTOBUF_DEP = $(LIBDIR)/$(CONFIG)/protobuf/libprotobuf.a
603 CPPFLAGS := -Ithird_party/protobuf/src $(CPPFLAGS)
604 LDFLAGS := -L$(LIBDIR)/$(CONFIG)/protobuf $(LDFLAGS)
605 PROTOC = $(BINDIR)/$(CONFIG)/protobuf/protoc
606 else
607 NO_PROTOBUF = true
608 endif
609 endif
Nicolas Noble53830622015-02-12 16:56:38 -0800610
Craig Tiller841c8802015-09-10 13:06:37 -0700611 LIBS_PROTOBUF = protobuf
612 LIBS_PROTOC = protoc protobuf
Nicolas Noble53830622015-02-12 16:56:38 -0800613
Craig Tiller841c8802015-09-10 13:06:37 -0700614 HOST_LDLIBS_PROTOC += $(addprefix -l, $(LIBS_PROTOC))
Nicolas Noble53830622015-02-12 16:56:38 -0800615
Craig Tiller841c8802015-09-10 13:06:37 -0700616 ifeq ($(PROTOBUF_PKG_CONFIG),true)
617 LDLIBS_PROTOBUF += $(shell $(PKG_CONFIG) --libs-only-l protobuf)
618 else
619 LDLIBS_PROTOBUF += $(addprefix -l, $(LIBS_PROTOBUF))
620 endif
murgatroid9924e2f4a2015-06-29 11:12:01 -0700621
Craig Tiller841c8802015-09-10 13:06:37 -0700622 # grpc++ .pc file
623 PC_NAME = gRPC++
624 PC_DESCRIPTION = C++ wrapper for gRPC
625 PC_CFLAGS =
626 PC_REQUIRES_PRIVATE = grpc $(PC_REQUIRES_GRPCXX)
627 PC_LIBS_PRIVATE = $(PC_LIBS_GRPCXX)
628 PC_LIB = -lgrpc++
629 GRPCXX_PC_FILE := $(PC_TEMPLATE)
murgatroid998faab232015-06-30 17:24:21 -0700630
Craig Tiller841c8802015-09-10 13:06:37 -0700631 # grpc++_unsecure .pc file
632 PC_NAME = gRPC++ unsecure
633 PC_DESCRIPTION = C++ wrapper for gRPC without SSL
634 PC_CFLAGS =
635 PC_REQUIRES_PRIVATE = grpc_unsecure $(PC_REQUIRES_GRPCXX)
636 PC_LIBS_PRIVATE = $(PC_LIBS_GRPCXX)
637 PC_LIB = -lgrpc++
638 GRPCXX_UNSECURE_PC_FILE := $(PC_TEMPLATE)
murgatroid998faab232015-06-30 17:24:21 -0700639
Craig Tiller841c8802015-09-10 13:06:37 -0700640 ifeq ($(MAKECMDGOALS),clean)
641 NO_DEPS = true
642 endif
nnoble69ac39f2014-12-12 15:43:38 -0800643
Craig Tiller841c8802015-09-10 13:06:37 -0700644 INSTALL_OK = false
645 ifeq ($(HAS_VALID_PROTOC),true)
646 ifeq ($(HAS_SYSTEM_PROTOBUF_VERIFY),true)
647 INSTALL_OK = true
648 endif
649 endif
Nicolas "Pixel" Noble98ab9982015-02-21 04:22:16 +0100650
Craig Tiller841c8802015-09-10 13:06:37 -0700651 .SECONDARY = %.pb.h %.pb.cc
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800652
Craig Tiller841c8802015-09-10 13:06:37 -0700653 PROTOC_PLUGINS =\
654 % for tgt in targets:
655 % if tgt.build == 'protoc':
656 $(BINDIR)/$(CONFIG)/${tgt.name}\
657 % endif
658 % endfor
Craig Tillerf58b9ef2015-01-15 09:09:12 -0800659
Craig Tiller841c8802015-09-10 13:06:37 -0700660 ifeq ($(DEP_MISSING),)
661 all: static shared plugins\
662 % for tgt in targets:
663 % if tgt.build == 'all':
664 $(BINDIR)/$(CONFIG)/${tgt.name}\
665 % endif
666 % endfor
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800667
Craig Tiller841c8802015-09-10 13:06:37 -0700668 dep_error:
669 @echo "You shouldn't see this message - all of your dependencies are correct."
670 else
671 all: dep_error git_update stop
nnoble69ac39f2014-12-12 15:43:38 -0800672
Craig Tiller841c8802015-09-10 13:06:37 -0700673 dep_error:
674 @echo
675 @echo "DEPENDENCY ERROR"
676 @echo
677 @echo "You are missing system dependencies that are essential to build grpc,"
678 @echo "and the third_party directory doesn't have them:"
679 @echo
680 @echo " $(DEP_MISSING)"
681 @echo
682 @echo "Installing the development packages for your system will solve"
683 @echo "this issue. Please consult INSTALL to get more information."
684 @echo
685 @echo "If you need information about why these tests failed, run:"
686 @echo
687 @echo " make run_dep_checks"
688 @echo
689 endif
nnoble69ac39f2014-12-12 15:43:38 -0800690
Craig Tiller841c8802015-09-10 13:06:37 -0700691 git_update:
692 ifeq ($(IS_GIT_FOLDER),true)
693 @echo "Additionally, since you are in a git clone, you can download the"
694 @echo "missing dependencies in third_party by running the following command:"
695 @echo
696 @echo " git submodule update --init"
697 @echo
698 endif
nnoble69ac39f2014-12-12 15:43:38 -0800699
Craig Tiller841c8802015-09-10 13:06:37 -0700700 openssl_dep_error: openssl_dep_message git_update stop
nnoble69ac39f2014-12-12 15:43:38 -0800701
Craig Tiller841c8802015-09-10 13:06:37 -0700702 protobuf_dep_error: protobuf_dep_message git_update stop
Nicolas Noble53830622015-02-12 16:56:38 -0800703
Craig Tiller841c8802015-09-10 13:06:37 -0700704 protoc_dep_error: protoc_dep_message git_update stop
Nicolas Noble53830622015-02-12 16:56:38 -0800705
Craig Tiller841c8802015-09-10 13:06:37 -0700706 openssl_dep_message:
707 @echo
708 @echo "DEPENDENCY ERROR"
709 @echo
710 @echo "The target you are trying to run requires OpenSSL."
711 @echo "Your system doesn't have it, and neither does the third_party directory."
712 @echo
713 @echo "Please consult INSTALL to get more information."
714 @echo
715 @echo "If you need information about why these tests failed, run:"
716 @echo
717 @echo " make run_dep_checks"
718 @echo
nnoble69ac39f2014-12-12 15:43:38 -0800719
Craig Tiller841c8802015-09-10 13:06:37 -0700720 protobuf_dep_message:
721 @echo
722 @echo "DEPENDENCY ERROR"
723 @echo
724 @echo "The target you are trying to run requires protobuf 3.0.0+"
725 @echo "Your system doesn't have it, and neither does the third_party directory."
726 @echo
727 @echo "Please consult INSTALL to get more information."
728 @echo
729 @echo "If you need information about why these tests failed, run:"
730 @echo
731 @echo " make run_dep_checks"
732 @echo
Nicolas Noble53830622015-02-12 16:56:38 -0800733
Craig Tiller841c8802015-09-10 13:06:37 -0700734 protoc_dep_message:
735 @echo
736 @echo "DEPENDENCY ERROR"
737 @echo
738 @echo "The target you are trying to run requires protobuf-compiler 3.0.0+"
739 @echo "Your system doesn't have it, and neither does the third_party directory."
740 @echo
741 @echo "Please consult INSTALL to get more information."
742 @echo
743 @echo "If you need information about why these tests failed, run:"
744 @echo
745 @echo " make run_dep_checks"
746 @echo
Nicolas Noble53830622015-02-12 16:56:38 -0800747
Craig Tiller841c8802015-09-10 13:06:37 -0700748 systemtap_dep_error:
749 @echo
750 @echo "DEPENDENCY ERROR"
751 @echo
752 @echo "Under the '$(CONFIG)' configutation, the target you are trying "
753 @echo "to build requires systemtap 2.7+ (on Linux) or dtrace (on other "
754 @echo "platforms such as Solaris and *BSD). "
755 @echo
756 @echo "Please consult INSTALL to get more information."
757 @echo
David Garcia Quintas8954e902015-04-29 09:46:33 -0700758
Craig Tiller841c8802015-09-10 13:06:37 -0700759 stop:
760 @false
nnoble69ac39f2014-12-12 15:43:38 -0800761
Craig Tiller841c8802015-09-10 13:06:37 -0700762 % for tgt in targets:
763 ${tgt.name}: $(BINDIR)/$(CONFIG)/${tgt.name}
764 % endfor
ctiller09cb6d52014-12-19 17:38:22 -0800765
Craig Tiller841c8802015-09-10 13:06:37 -0700766 run_dep_checks:
767 $(OPENSSL_ALPN_CHECK_CMD) || true
768 $(OPENSSL_NPN_CHECK_CMD) || true
769 $(ZLIB_CHECK_CMD) || true
770 $(PERFTOOLS_CHECK_CMD) || true
771 $(PROTOBUF_CHECK_CMD) || true
772 $(PROTOC_CHECK_VERSION_CMD) || true
773 $(ZOOKEEPER_CHECK_CMD) || true
nnoble69ac39f2014-12-12 15:43:38 -0800774
Craig Tiller841c8802015-09-10 13:06:37 -0700775 third_party/protobuf/configure:
776 $(E) "[AUTOGEN] Preparing protobuf"
777 $(Q)(cd third_party/protobuf ; autoreconf -f -i -Wall,no-obsolete)
Nicolas Noble53830622015-02-12 16:56:38 -0800778
Craig Tiller841c8802015-09-10 13:06:37 -0700779 $(LIBDIR)/$(CONFIG)/protobuf/libprotobuf.a: third_party/protobuf/configure
780 $(E) "[MAKE] Building protobuf"
781 $(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)
782 $(Q)$(MAKE) -C third_party/protobuf clean
783 $(Q)$(MAKE) -C third_party/protobuf
784 $(Q)mkdir -p $(LIBDIR)/$(CONFIG)/protobuf
785 $(Q)mkdir -p $(BINDIR)/$(CONFIG)/protobuf
786 $(Q)cp third_party/protobuf/src/.libs/libprotoc.a $(LIBDIR)/$(CONFIG)/protobuf
787 $(Q)cp third_party/protobuf/src/.libs/libprotobuf.a $(LIBDIR)/$(CONFIG)/protobuf
788 $(Q)cp third_party/protobuf/src/protoc $(BINDIR)/$(CONFIG)/protobuf
Nicolas Noble53830622015-02-12 16:56:38 -0800789
Craig Tiller841c8802015-09-10 13:06:37 -0700790 static: static_c static_cxx
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800791
Craig Tiller841c8802015-09-10 13:06:37 -0700792 static_c: pc_c pc_c_unsecure cache.mk pc_gpr pc_c_zookeeper\
793 % for lib in libs:
794 % if lib.build == 'all' and lib.language == 'c' and not lib.get('external_deps', None):
795 $(LIBDIR)/$(CONFIG)/lib${lib.name}.a\
796 % endif
797 % endfor
798 static_zookeeper_libs
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800799
800
Craig Tiller841c8802015-09-10 13:06:37 -0700801 static_cxx: pc_cxx pc_cxx_unsecure pc_gpr cache.mk \
802 % for lib in libs:
803 % if lib.build == 'all' and lib.language == 'c++':
804 $(LIBDIR)/$(CONFIG)/lib${lib.name}.a\
805 % endif
806 % endfor
nnoble29e1d292014-12-01 10:27:40 -0800807
808
Craig Tiller841c8802015-09-10 13:06:37 -0700809 shared: shared_c shared_cxx
nnoble29e1d292014-12-01 10:27:40 -0800810
Craig Tiller841c8802015-09-10 13:06:37 -0700811 shared_c: pc_c pc_c_unsecure pc_gpr cache.mk pc_c_zookeeper\
812 % for lib in libs:
813 % if lib.build == 'all' and lib.language == 'c' and not lib.get('external_deps', None):
814 $(LIBDIR)/$(CONFIG)/lib${lib.name}.$(SHARED_EXT)\
815 % endif
816 % endfor
817 shared_zookeeper_libs
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800818
Craig Tiller841c8802015-09-10 13:06:37 -0700819 shared_cxx: pc_cxx pc_cxx_unsecure cache.mk\
820 % for lib in libs:
821 % if lib.build == 'all' and lib.language == 'c++':
822 $(LIBDIR)/$(CONFIG)/lib${lib.name}.$(SHARED_EXT)\
823 % endif
824 % endfor
nnoble29e1d292014-12-01 10:27:40 -0800825
826
Craig Tiller841c8802015-09-10 13:06:37 -0700827 shared_csharp: shared_c \
828 % for lib in libs:
829 % if lib.build == 'all' and lib.language == 'csharp':
830 $(LIBDIR)/$(CONFIG)/lib${lib.name}.$(SHARED_EXT)\
831 % endif
832 % endfor
Jan Tattermusch2ec0b3e2015-02-18 15:03:12 -0800833
Craig Tiller841c8802015-09-10 13:06:37 -0700834 ifeq ($(HAS_ZOOKEEPER),true)
835 static_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}.a\
839 % endif
840 % endfor
Hongwei Wanga8cc4392015-07-16 17:37:47 -0700841
Craig Tiller841c8802015-09-10 13:06:37 -0700842 shared_zookeeper_libs:\
843 % for lib in libs:
844 % if lib.build == 'all' and lib.language == 'c' and 'zookeeper' in lib.get('external_deps', []):
845 $(LIBDIR)/$(CONFIG)/lib${lib.name}.$(SHARED_EXT)\
846 % endif
847 % endfor
Hongwei Wanga8cc4392015-07-16 17:37:47 -0700848
Craig Tiller841c8802015-09-10 13:06:37 -0700849 else
Hongwei Wanga8cc4392015-07-16 17:37:47 -0700850
Craig Tiller841c8802015-09-10 13:06:37 -0700851 static_zookeeper_libs:
Hongwei Wanga8cc4392015-07-16 17:37:47 -0700852
Craig Tiller841c8802015-09-10 13:06:37 -0700853 shared_zookeeper_libs:
Hongwei Wanga8cc4392015-07-16 17:37:47 -0700854
Craig Tiller841c8802015-09-10 13:06:37 -0700855 endif
Hongwei Wanga8cc4392015-07-16 17:37:47 -0700856
Craig Tiller841c8802015-09-10 13:06:37 -0700857 grpc_csharp_ext: shared_csharp
Jan Tattermusch2ec0b3e2015-02-18 15:03:12 -0800858
Craig Tiller841c8802015-09-10 13:06:37 -0700859 plugins: $(PROTOC_PLUGINS)
Nicolas "Pixel" Noble522d7122015-02-19 01:28:02 +0100860
Craig Tiller841c8802015-09-10 13:06:37 -0700861 privatelibs: privatelibs_c privatelibs_cxx
nnoble29e1d292014-12-01 10:27:40 -0800862
Craig Tiller841c8802015-09-10 13:06:37 -0700863 privatelibs_c: \
864 % for lib in libs:
Craig Tiller0fe5ee72015-12-22 12:50:36 -0800865 % if lib.build == 'private' and lib.language == 'c' and not lib.get('external_deps', None) and not lib.boringssl:
Craig Tiller841c8802015-09-10 13:06:37 -0700866 $(LIBDIR)/$(CONFIG)/lib${lib.name}.a\
867 % endif
868 % endfor
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800869
Craig Tiller841c8802015-09-10 13:06:37 -0700870 pc_gpr: $(LIBDIR)/$(CONFIG)/pkgconfig/gpr.pc
murgatroid998faab232015-06-30 17:24:21 -0700871
Craig Tiller841c8802015-09-10 13:06:37 -0700872 pc_c: $(LIBDIR)/$(CONFIG)/pkgconfig/grpc.pc
murgatroid998faab232015-06-30 17:24:21 -0700873
Craig Tiller841c8802015-09-10 13:06:37 -0700874 pc_c_unsecure: $(LIBDIR)/$(CONFIG)/pkgconfig/grpc_unsecure.pc
murgatroid998faab232015-06-30 17:24:21 -0700875
Craig Tiller841c8802015-09-10 13:06:37 -0700876 ifeq ($(HAS_ZOOKEEPER),true)
877 pc_c_zookeeper: $(LIBDIR)/$(CONFIG)/pkgconfig/grpc_zookeeper.pc
878 else
879 pc_c_zookeeper:
880 endif
Hongwei Wanga3780a82015-07-17 15:27:18 -0700881
Craig Tiller841c8802015-09-10 13:06:37 -0700882 pc_cxx: $(LIBDIR)/$(CONFIG)/pkgconfig/grpc++.pc
murgatroid998faab232015-06-30 17:24:21 -0700883
Craig Tiller841c8802015-09-10 13:06:37 -0700884 pc_cxx_unsecure: $(LIBDIR)/$(CONFIG)/pkgconfig/grpc++_unsecure.pc
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800885
Craig Tiller841c8802015-09-10 13:06:37 -0700886 privatelibs_cxx: \
887 % for lib in libs:
888 % if lib.build == 'private' and lib.language == 'c++' and not lib.get('external_deps', None):
889 $(LIBDIR)/$(CONFIG)/lib${lib.name}.a\
890 % endif
891 % endfor
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800892
893
Craig Tiller841c8802015-09-10 13:06:37 -0700894 ifeq ($(HAS_ZOOKEEPER),true)
895 privatelibs_zookeeper: \
896 % for lib in libs:
897 % if lib.build == 'private' and lib.language == 'c++' and zookeeper in lib.get('external_deps', []):
898 $(LIBDIR)/$(CONFIG)/lib${lib.name}.a\
899 % endif
900 % endfor
Hongwei Wang8e04d412015-07-31 15:12:51 -0700901
Craig Tiller841c8802015-09-10 13:06:37 -0700902 else
903 privatelibs_zookeeper:
904 endif
Hongwei Wang8e04d412015-07-31 15:12:51 -0700905
906
Craig Tiller841c8802015-09-10 13:06:37 -0700907 buildtests: buildtests_c buildtests_cxx buildtests_zookeeper
nnoble29e1d292014-12-01 10:27:40 -0800908
Craig Tiller3824b6e2015-12-09 11:19:59 -0800909 buildtests_c: privatelibs_c <%text>\</%text>
Craig Tiller841c8802015-09-10 13:06:37 -0700910 % for tgt in targets:
911 % if tgt.build == 'test' and not tgt.language == 'c++' and not tgt.get('external_deps', None):
Craig Tiller3824b6e2015-12-09 11:19:59 -0800912 $(BINDIR)/$(CONFIG)/${tgt.name} <%text>\</%text>
Craig Tiller841c8802015-09-10 13:06:37 -0700913 % endif
914 % endfor
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800915
916
Craig Tiller3824b6e2015-12-09 11:19:59 -0800917 buildtests_cxx: buildtests_zookeeper privatelibs_cxx <%text>\</%text>
Craig Tiller841c8802015-09-10 13:06:37 -0700918 % for tgt in targets:
919 % if tgt.build == 'test' and tgt.language == 'c++' and not tgt.get('external_deps', None):
Craig Tiller3824b6e2015-12-09 11:19:59 -0800920 $(BINDIR)/$(CONFIG)/${tgt.name} <%text>\</%text>
Craig Tiller841c8802015-09-10 13:06:37 -0700921 % endif
922 % endfor
nnoble29e1d292014-12-01 10:27:40 -0800923
924
Craig Tiller841c8802015-09-10 13:06:37 -0700925 ifeq ($(HAS_ZOOKEEPER),true)
Craig Tiller3824b6e2015-12-09 11:19:59 -0800926 buildtests_zookeeper: privatelibs_zookeeper <%text>\</%text>
Craig Tiller841c8802015-09-10 13:06:37 -0700927 % for tgt in targets:
928 % if tgt.build == 'test' and tgt.language == 'c++' and 'zookeeper' in tgt.get('external_deps', []):
Craig Tiller3824b6e2015-12-09 11:19:59 -0800929 $(BINDIR)/$(CONFIG)/${tgt.name} <%text>\</%text>
Craig Tiller841c8802015-09-10 13:06:37 -0700930 % endif
931 % endfor
nnoble29e1d292014-12-01 10:27:40 -0800932
Craig Tiller841c8802015-09-10 13:06:37 -0700933 else
934 buildtests_zookeeper:
935 endif
Hongwei Wang8e04d412015-07-31 15:12:51 -0700936
937
Craig Tiller841c8802015-09-10 13:06:37 -0700938 test: test_c test_cxx test_zookeeper
Hongwei Wang8e04d412015-07-31 15:12:51 -0700939
Craig Tiller841c8802015-09-10 13:06:37 -0700940 flaky_test: flaky_test_c flaky_test_cxx flaky_test_zookeeper
Nicolas "Pixel" Noble4251d562015-05-22 19:43:39 +0200941
Craig Tiller841c8802015-09-10 13:06:37 -0700942 test_c: buildtests_c
943 % for tgt in targets:
944 % 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):
945 $(E) "[RUN] Testing ${tgt.name}"
946 $(Q) $(BINDIR)/$(CONFIG)/${tgt.name} || ( echo test ${tgt.name} failed ; exit 1 )
947 % endif
948 % endfor
Nicolas "Pixel" Noble4251d562015-05-22 19:43:39 +0200949
950
Craig Tiller841c8802015-09-10 13:06:37 -0700951 flaky_test_c: buildtests_c
952 % for tgt in targets:
953 % 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):
954 $(E) "[RUN] Testing ${tgt.name}"
955 $(Q) $(BINDIR)/$(CONFIG)/${tgt.name} || ( echo test ${tgt.name} failed ; exit 1 )
956 % endif
957 % endfor
nnoble29e1d292014-12-01 10:27:40 -0800958
959
Craig Tiller841c8802015-09-10 13:06:37 -0700960 test_cxx: test_zookeeper buildtests_cxx
961 % for tgt in targets:
962 % 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):
963 $(E) "[RUN] Testing ${tgt.name}"
964 $(Q) $(BINDIR)/$(CONFIG)/${tgt.name} || ( echo test ${tgt.name} failed ; exit 1 )
965 % endif
966 % endfor
Nicolas "Pixel" Noble4251d562015-05-22 19:43:39 +0200967
968
Craig Tiller841c8802015-09-10 13:06:37 -0700969 flaky_test_cxx: buildtests_cxx
970 % for tgt in targets:
971 % 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):
972 $(E) "[RUN] Testing ${tgt.name}"
973 $(Q) $(BINDIR)/$(CONFIG)/${tgt.name} || ( echo test ${tgt.name} failed ; exit 1 )
974 % endif
975 % endfor
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800976
977
Craig Tiller841c8802015-09-10 13:06:37 -0700978 ifeq ($(HAS_ZOOKEEPER),true)
979 test_zookeeper: buildtests_zookeeper
980 % for tgt in targets:
981 % 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', []):
982 $(E) "[RUN] Testing ${tgt.name}"
983 $(Q) $(BINDIR)/$(CONFIG)/${tgt.name} || ( echo test ${tgt.name} failed ; exit 1 )
984 % endif
985 % endfor
Hongwei Wang8e04d412015-07-31 15:12:51 -0700986
987
Craig Tiller841c8802015-09-10 13:06:37 -0700988 flaky_test_zookeeper: buildtests_zookeeper
989 % for tgt in targets:
990 % 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', []):
991 $(E) "[RUN] Testing ${tgt.name}"
992 $(Q) $(BINDIR)/$(CONFIG)/${tgt.name} || ( echo test ${tgt.name} failed ; exit 1 )
993 % endif
994 % endfor
Hongwei Wang8e04d412015-07-31 15:12:51 -0700995
Craig Tiller841c8802015-09-10 13:06:37 -0700996 else
997 test_zookeeper:
998 flaky_test_zookeeper:
999 endif
Hongwei Wang8e04d412015-07-31 15:12:51 -07001000
1001
Craig Tiller841c8802015-09-10 13:06:37 -07001002 test_python: static_c
1003 $(E) "[RUN] Testing python code"
1004 $(Q) tools/run_tests/run_tests.py -lpython -c$(CONFIG)
Nicolas "Pixel" Noble051a28f2015-03-17 22:54:54 +01001005
1006
Craig Tiller841c8802015-09-10 13:06:37 -07001007 tools: tools_c tools_cxx
Craig Tiller7552f0f2015-06-19 17:46:20 -07001008
1009
Craig Tiller841c8802015-09-10 13:06:37 -07001010 tools_c: privatelibs_c\
1011 % for tgt in targets:
1012 % if tgt.build == 'tool' and not tgt.language=='c++':
1013 $(BINDIR)/$(CONFIG)/${tgt.name}\
1014 % endif
1015 % endfor
Craig Tiller7552f0f2015-06-19 17:46:20 -07001016
1017
Craig Tiller841c8802015-09-10 13:06:37 -07001018 tools_cxx: privatelibs_cxx\
1019 % for tgt in targets:
1020 % if tgt.build == 'tool' and tgt.language=='c++':
1021 $(BINDIR)/$(CONFIG)/${tgt.name}\
1022 % endif
1023 % endfor
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001024
1025
Craig Tiller841c8802015-09-10 13:06:37 -07001026 buildbenchmarks: privatelibs\
1027 % for tgt in targets:
1028 % if tgt.build == 'benchmark':
1029 $(BINDIR)/$(CONFIG)/${tgt.name}\
1030 % endif
1031 % endfor
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001032
1033
Craig Tiller841c8802015-09-10 13:06:37 -07001034 benchmarks: buildbenchmarks
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001035
Craig Tiller841c8802015-09-10 13:06:37 -07001036 strip: strip-static strip-shared
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001037
Craig Tiller841c8802015-09-10 13:06:37 -07001038 strip-static: strip-static_c strip-static_cxx
nnoble20e2e3f2014-12-16 15:37:57 -08001039
Craig Tiller841c8802015-09-10 13:06:37 -07001040 strip-shared: strip-shared_c strip-shared_cxx
nnoble20e2e3f2014-12-16 15:37:57 -08001041
Nicolas Noble047b7272015-01-16 13:55:05 -08001042
Craig Tiller841c8802015-09-10 13:06:37 -07001043 # TODO(nnoble): the strip target is stripping in-place, instead
1044 # of copying files in a temporary folder.
1045 # This prevents proper debugging after running make install.
Nicolas Noble047b7272015-01-16 13:55:05 -08001046
Craig Tiller841c8802015-09-10 13:06:37 -07001047 strip-static_c: static_c
1048 ifeq ($(CONFIG),opt)
1049 % for lib in libs:
1050 % if lib.language == "c":
1051 % if lib.build == "all":
1052 % if not lib.get('external_deps', None):
1053 $(E) "[STRIP] Stripping lib${lib.name}.a"
1054 $(Q) $(STRIP) $(LIBDIR)/$(CONFIG)/lib${lib.name}.a
1055 % endif
1056 % endif
1057 % endif
1058 % endfor
1059 ifeq ($(HAS_ZOOKEEPER),true)
1060 % for lib in libs:
1061 % if lib.language == "c":
1062 % if lib.build == "all":
1063 % if 'zookeeper' in lib.get('external_deps', []):
1064 $(E) "[STRIP] Stripping lib${lib.name}.a"
1065 $(Q) $(STRIP) $(LIBDIR)/$(CONFIG)/lib${lib.name}.a
1066 % endif
1067 % endif
1068 % endif
1069 % endfor
1070 endif
1071 endif
nnoble85a49262014-12-08 18:14:03 -08001072
Craig Tiller841c8802015-09-10 13:06:37 -07001073 strip-static_cxx: static_cxx
1074 ifeq ($(CONFIG),opt)
1075 % for lib in libs:
1076 % if lib.language == "c++":
1077 % if lib.build == "all":
1078 $(E) "[STRIP] Stripping lib${lib.name}.a"
1079 $(Q) $(STRIP) $(LIBDIR)/$(CONFIG)/lib${lib.name}.a
1080 % endif
1081 % endif
1082 % endfor
1083 endif
Nicolas "Pixel" Noble4ef9b862015-08-14 19:35:24 +02001084
Craig Tiller841c8802015-09-10 13:06:37 -07001085 strip-shared_c: shared_c
1086 ifeq ($(CONFIG),opt)
1087 % for lib in libs:
1088 % if lib.language == "c":
1089 % if lib.build == "all":
1090 % if not lib.get('external_deps', None):
1091 $(E) "[STRIP] Stripping lib${lib.name}.so"
1092 $(Q) $(STRIP) $(LIBDIR)/$(CONFIG)/lib${lib.name}.$(SHARED_EXT)
1093 % endif
1094 % endif
1095 % endif
1096 % endfor
1097 ifeq ($(HAS_ZOOKEEPER),true)
1098 % for lib in libs:
1099 % if lib.language == "c":
1100 % if lib.build == "all":
1101 % if 'zookeeper' in lib.get('external_deps', []):
1102 $(E) "[STRIP] Stripping lib${lib.name}.so"
1103 $(Q) $(STRIP) $(LIBDIR)/$(CONFIG)/lib${lib.name}.$(SHARED_EXT)
1104 % endif
1105 % endif
1106 % endif
1107 % endfor
1108 endif
1109 endif
nnoble85a49262014-12-08 18:14:03 -08001110
Craig Tiller841c8802015-09-10 13:06:37 -07001111 strip-shared_cxx: shared_cxx
1112 ifeq ($(CONFIG),opt)
1113 % for lib in libs:
1114 % if lib.language == "c++":
1115 % if lib.build == "all":
1116 $(E) "[STRIP] Stripping lib${lib.name}.so"
1117 $(Q) $(STRIP) $(LIBDIR)/$(CONFIG)/lib${lib.name}.$(SHARED_EXT)
1118 % endif
1119 % endif
1120 % endfor
1121 endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001122
Craig Tiller841c8802015-09-10 13:06:37 -07001123 strip-shared_csharp: shared_csharp
1124 ifeq ($(CONFIG),opt)
1125 % for lib in libs:
1126 % if lib.language == "csharp":
1127 % if lib.build == "all":
1128 $(E) "[STRIP] Stripping lib${lib.name}.so"
1129 $(Q) $(STRIP) $(LIBDIR)/$(CONFIG)/lib${lib.name}.$(SHARED_EXT)
1130 % endif
1131 % endif
1132 % endfor
1133 endif
Jan Tattermusch2ec0b3e2015-02-18 15:03:12 -08001134
Craig Tiller841c8802015-09-10 13:06:37 -07001135 cache.mk::
1136 $(E) "[MAKE] Generating $@"
1137 $(Q) echo "$(CACHE_MK)" | tr , '\n' >$@
murgatroid99aa521572015-07-10 14:49:12 -07001138
Craig Tiller841c8802015-09-10 13:06:37 -07001139 $(LIBDIR)/$(CONFIG)/pkgconfig/gpr.pc:
1140 $(E) "[MAKE] Generating $@"
1141 $(Q) mkdir -p $(@D)
1142 $(Q) echo "$(GPR_PC_FILE)" | tr , '\n' >$@
murgatroid998faab232015-06-30 17:24:21 -07001143
Craig Tiller841c8802015-09-10 13:06:37 -07001144 $(LIBDIR)/$(CONFIG)/pkgconfig/grpc.pc:
1145 $(E) "[MAKE] Generating $@"
1146 $(Q) mkdir -p $(@D)
1147 $(Q) echo "$(GRPC_PC_FILE)" | tr , '\n' >$@
murgatroid998faab232015-06-30 17:24:21 -07001148
Craig Tiller841c8802015-09-10 13:06:37 -07001149 $(LIBDIR)/$(CONFIG)/pkgconfig/grpc_unsecure.pc:
1150 $(E) "[MAKE] Generating $@"
1151 $(Q) mkdir -p $(@D)
1152 $(Q) echo "$(GRPC_UNSECURE_PC_FILE)" | tr , '\n' >$@
murgatroid998faab232015-06-30 17:24:21 -07001153
Craig Tiller841c8802015-09-10 13:06:37 -07001154 $(LIBDIR)/$(CONFIG)/pkgconfig/grpc_zookeeper.pc:
1155 $(E) "[MAKE] Generating $@"
1156 $(Q) mkdir -p $(@D)
1157 $(Q) echo -e "$(GRPC_ZOOKEEPER_PC_FILE)" >$@
Hongwei Wanga8cc4392015-07-16 17:37:47 -07001158
Craig Tiller841c8802015-09-10 13:06:37 -07001159 $(LIBDIR)/$(CONFIG)/pkgconfig/grpc++.pc:
1160 $(E) "[MAKE] Generating $@"
1161 $(Q) mkdir -p $(@D)
1162 $(Q) echo "$(GRPCXX_PC_FILE)" | tr , '\n' >$@
murgatroid998faab232015-06-30 17:24:21 -07001163
Craig Tiller841c8802015-09-10 13:06:37 -07001164 $(LIBDIR)/$(CONFIG)/pkgconfig/grpc++_unsecure.pc:
1165 $(E) "[MAKE] Generating $@"
1166 $(Q) mkdir -p $(@D)
1167 $(Q) echo "$(GRPCXX_UNSECURE_PC_FILE)" | tr , '\n' >$@
murgatroid998faab232015-06-30 17:24:21 -07001168
Craig Tiller841c8802015-09-10 13:06:37 -07001169 % for p in protos:
1170 ifeq ($(NO_PROTOC),true)
1171 $(GENDIR)/${p}.pb.cc: protoc_dep_error
1172 $(GENDIR)/${p}.grpc.pb.cc: protoc_dep_error
1173 else
Craig Tiller1b4e3302015-12-17 16:35:00 -08001174 $(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 -07001175 $(E) "[PROTOC] Generating protobuf CC file from $<"
1176 $(Q) mkdir -p `dirname $@`
1177 $(Q) $(PROTOC) --cpp_out=$(GENDIR) $<
Nicolas "Pixel" Noble0caebbf2015-04-09 23:08:51 +02001178
Craig Tiller1b4e3302015-12-17 16:35:00 -08001179 $(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 -07001180 $(E) "[GRPC] Generating gRPC's protobuf service CC file from $<"
1181 $(Q) mkdir -p `dirname $@`
1182 $(Q) $(PROTOC) --grpc_out=$(GENDIR) --plugin=protoc-gen-grpc=$(BINDIR)/$(CONFIG)/grpc_cpp_plugin $<
1183 endif
nnoble72309c62014-12-12 11:42:26 -08001184
Craig Tiller841c8802015-09-10 13:06:37 -07001185 % endfor
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001186
Craig Tiller841c8802015-09-10 13:06:37 -07001187 ifeq ($(CONFIG),stapprof)
1188 src/core/profiling/stap_timers.c: $(GENDIR)/src/core/profiling/stap_probes.h
1189 ifeq ($(HAS_SYSTEMTAP),true)
1190 $(GENDIR)/src/core/profiling/stap_probes.h: src/core/profiling/stap_probes.d
1191 $(E) "[DTRACE] Compiling $<"
1192 $(Q) mkdir -p `dirname $@`
1193 $(Q) $(DTRACE) -C -h -s $< -o $@
1194 else
1195 $(GENDIR)/src/core/profiling/stap_probes.h: systemtap_dep_error stop
1196 endif
1197 endif
David Garcia Quintas611b7362015-04-27 15:49:31 -07001198
Craig Tiller841c8802015-09-10 13:06:37 -07001199 $(OBJDIR)/$(CONFIG)/%.o : %.c
1200 $(E) "[C] Compiling $<"
1201 $(Q) mkdir -p `dirname $@`
1202 $(Q) $(CC) $(CFLAGS) $(CPPFLAGS) -MMD -MF $(addsuffix .dep, $(basename $@)) -c -o $@ $<
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001203
Craig Tiller841c8802015-09-10 13:06:37 -07001204 $(OBJDIR)/$(CONFIG)/%.o : $(GENDIR)/%.pb.cc
1205 $(E) "[CXX] Compiling $<"
1206 $(Q) mkdir -p `dirname $@`
1207 $(Q) $(CXX) $(CXXFLAGS) $(CPPFLAGS) -MMD -MF $(addsuffix .dep, $(basename $@)) -c -o $@ $<
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001208
Craig Tiller841c8802015-09-10 13:06:37 -07001209 $(OBJDIR)/$(CONFIG)/src/compiler/%.o : src/compiler/%.cc
1210 $(E) "[HOSTCXX] Compiling $<"
1211 $(Q) mkdir -p `dirname $@`
1212 $(Q) $(HOST_CXX) $(HOST_CXXFLAGS) $(HOST_CPPFLAGS) -MMD -MF $(addsuffix .dep, $(basename $@)) -c -o $@ $<
nnoble72309c62014-12-12 11:42:26 -08001213
Craig Tiller841c8802015-09-10 13:06:37 -07001214 $(OBJDIR)/$(CONFIG)/%.o : %.cc
1215 $(E) "[CXX] Compiling $<"
1216 $(Q) mkdir -p `dirname $@`
1217 $(Q) $(CXX) $(CXXFLAGS) $(CPPFLAGS) -MMD -MF $(addsuffix .dep, $(basename $@)) -c -o $@ $<
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001218
Craig Tiller841c8802015-09-10 13:06:37 -07001219 install: install_c install_cxx install-plugins install-certs verify-install
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001220
Craig Tiller841c8802015-09-10 13:06:37 -07001221 install_c: install-headers_c install-static_c install-shared_c
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001222
Craig Tiller841c8802015-09-10 13:06:37 -07001223 install_cxx: install-headers_cxx install-static_cxx install-shared_cxx
nnoble85a49262014-12-08 18:14:03 -08001224
Craig Tiller841c8802015-09-10 13:06:37 -07001225 install_csharp: install-shared_csharp install_c
Jan Tattermusch2ec0b3e2015-02-18 15:03:12 -08001226
Craig Tiller841c8802015-09-10 13:06:37 -07001227 install_grpc_csharp_ext: install_csharp
Jan Tattermusch2ec0b3e2015-02-18 15:03:12 -08001228
Craig Tiller841c8802015-09-10 13:06:37 -07001229 install-headers: install-headers_c install-headers_cxx
nnoble85a49262014-12-08 18:14:03 -08001230
Craig Tiller841c8802015-09-10 13:06:37 -07001231 install-headers_c:
1232 $(E) "[INSTALL] Installing public C headers"
1233 $(Q) $(foreach h, $(PUBLIC_HEADERS_C), $(INSTALL) -d $(prefix)/$(dir $(h)) && ) exit 0 || exit 1
1234 $(Q) $(foreach h, $(PUBLIC_HEADERS_C), $(INSTALL) $(h) $(prefix)/$(h) && ) exit 0 || exit 1
nnoble85a49262014-12-08 18:14:03 -08001235
Craig Tiller841c8802015-09-10 13:06:37 -07001236 install-headers_cxx:
1237 $(E) "[INSTALL] Installing public C++ headers"
1238 $(Q) $(foreach h, $(PUBLIC_HEADERS_CXX), $(INSTALL) -d $(prefix)/$(dir $(h)) && ) exit 0 || exit 1
1239 $(Q) $(foreach h, $(PUBLIC_HEADERS_CXX), $(INSTALL) $(h) $(prefix)/$(h) && ) exit 0 || exit 1
nnoble85a49262014-12-08 18:14:03 -08001240
Craig Tiller841c8802015-09-10 13:06:37 -07001241 install-static: install-static_c install-static_cxx
nnoble85a49262014-12-08 18:14:03 -08001242
Craig Tiller841c8802015-09-10 13:06:37 -07001243 install-static_c: static_c strip-static_c install-pkg-config_c
1244 % for lib in libs:
1245 % if lib.language == "c":
1246 % if lib.build == "all":
1247 % if not lib.get('external_deps', None):
1248 $(E) "[INSTALL] Installing lib${lib.name}.a"
1249 $(Q) $(INSTALL) -d $(prefix)/lib
1250 $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/lib${lib.name}.a $(prefix)/lib/lib${lib.name}.a
1251 % endif
1252 % endif
1253 % endif
1254 % endfor
1255 ifeq ($(HAS_ZOOKEEPER),true)
1256 % for lib in libs:
1257 % if lib.language == "c":
1258 % if lib.build == "all":
1259 % if 'zookeeper' in lib.get('external_deps', []):
1260 $(E) "[INSTALL] Installing lib${lib.name}.a"
1261 $(Q) $(INSTALL) -d $(prefix)/lib
1262 $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/lib${lib.name}.a $(prefix)/lib/lib${lib.name}.a
1263 % endif
1264 % endif
1265 % endif
1266 % endfor
1267 endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001268
Craig Tiller841c8802015-09-10 13:06:37 -07001269 install-static_cxx: static_cxx strip-static_cxx install-pkg-config_cxx
1270 % for lib in libs:
1271 % if lib.language == "c++":
1272 % if lib.build == "all":
1273 $(E) "[INSTALL] Installing lib${lib.name}.a"
1274 $(Q) $(INSTALL) -d $(prefix)/lib
1275 $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/lib${lib.name}.a $(prefix)/lib/lib${lib.name}.a
1276 % endif
1277 % endif
1278 % endfor
nnoble85a49262014-12-08 18:14:03 -08001279
Craig Tiller841c8802015-09-10 13:06:37 -07001280 <%def name="install_shared(lang_filter)">\
1281 % for lib in libs:
1282 % if lib.language == lang_filter:
1283 % if lib.build == "all":
1284 % if not lib.get('external_deps', None):
1285 ifeq ($(SYSTEM),MINGW32)
1286 $(E) "[INSTALL] Installing ${lib.name}.$(SHARED_EXT)"
1287 $(Q) $(INSTALL) -d $(prefix)/lib
1288 $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/${lib.name}.$(SHARED_EXT) $(prefix)/lib/${lib.name}.$(SHARED_EXT)
1289 $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/lib${lib.name}-imp.a $(prefix)/lib/lib${lib.name}-imp.a
1290 else
1291 $(E) "[INSTALL] Installing lib${lib.name}.$(SHARED_EXT)"
1292 $(Q) $(INSTALL) -d $(prefix)/lib
1293 $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/lib${lib.name}.$(SHARED_EXT) $(prefix)/lib/lib${lib.name}.$(SHARED_EXT)
1294 ifneq ($(SYSTEM),Darwin)
1295 $(Q) ln -sf lib${lib.name}.$(SHARED_EXT) $(prefix)/lib/lib${lib.name}.so.${settings.version.major}
1296 $(Q) ln -sf lib${lib.name}.$(SHARED_EXT) $(prefix)/lib/lib${lib.name}.so
1297 endif
1298 endif
1299 % endif
1300 % endif
1301 % endif
1302 % endfor
1303 ifeq ($(HAS_ZOOKEEPER),true)
1304 % for lib in libs:
1305 % if lib.language == lang_filter:
1306 % if lib.build == "all":
1307 % if 'zookeeper' in lib.get('external_deps', []):
1308 ifeq ($(SYSTEM),MINGW32)
1309 $(E) "[INSTALL] Installing ${lib.name}.$(SHARED_EXT)"
1310 $(Q) $(INSTALL) -d $(prefix)/lib
1311 $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/${lib.name}.$(SHARED_EXT) $(prefix)/lib/${lib.name}.$(SHARED_EXT)
1312 $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/lib${lib.name}-imp.a $(prefix)/lib/lib${lib.name}-imp.a
1313 else
1314 $(E) "[INSTALL] Installing lib${lib.name}.$(SHARED_EXT)"
1315 $(Q) $(INSTALL) -d $(prefix)/lib
1316 $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/lib${lib.name}.$(SHARED_EXT) $(prefix)/lib/lib${lib.name}.$(SHARED_EXT)
1317 ifneq ($(SYSTEM),Darwin)
1318 $(Q) ln -sf lib${lib.name}.$(SHARED_EXT) $(prefix)/lib/lib${lib.name}.so.${settings.version.major}
1319 $(Q) ln -sf lib${lib.name}.$(SHARED_EXT) $(prefix)/lib/lib${lib.name}.so
1320 endif
1321 endif
1322 % endif
1323 % endif
1324 % endif
1325 % endfor
1326 endif
1327 ifneq ($(SYSTEM),MINGW32)
1328 ifneq ($(SYSTEM),Darwin)
1329 $(Q) ldconfig || true
1330 endif
1331 endif
1332 </%def>
nnoble85a49262014-12-08 18:14:03 -08001333
Craig Tiller841c8802015-09-10 13:06:37 -07001334 install-shared_c: shared_c strip-shared_c install-pkg-config_c
1335 ${install_shared("c")}
Nicolas "Pixel" Noble522d7122015-02-19 01:28:02 +01001336
Craig Tiller841c8802015-09-10 13:06:37 -07001337 install-shared_cxx: shared_cxx strip-shared_cxx install-shared_c install-pkg-config_cxx
1338 ${install_shared("c++")}
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001339
Craig Tiller841c8802015-09-10 13:06:37 -07001340 install-shared_csharp: shared_csharp strip-shared_csharp
1341 ${install_shared("csharp")}
Nicolas "Pixel" Noble522d7122015-02-19 01:28:02 +01001342
Craig Tiller841c8802015-09-10 13:06:37 -07001343 install-plugins: $(PROTOC_PLUGINS)
1344 ifeq ($(SYSTEM),MINGW32)
1345 $(Q) false
1346 else
1347 $(E) "[INSTALL] Installing grpc protoc plugins"
1348 % for tgt in targets:
1349 % if tgt.build == 'protoc':
1350 $(Q) $(INSTALL) -d $(prefix)/bin
1351 $(Q) $(INSTALL) $(BINDIR)/$(CONFIG)/${tgt.name} $(prefix)/bin/${tgt.name}
1352 % endif
1353 % endfor
1354 endif
Jan Tattermusch2ec0b3e2015-02-18 15:03:12 -08001355
Craig Tiller841c8802015-09-10 13:06:37 -07001356 install-pkg-config_c: pc_gpr pc_c pc_c_unsecure pc_c_zookeeper
1357 $(E) "[INSTALL] Installing C pkg-config files"
1358 $(Q) $(INSTALL) -d $(prefix)/lib/pkgconfig
1359 $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/pkgconfig/gpr.pc $(prefix)/lib/pkgconfig/gpr.pc
1360 $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/pkgconfig/grpc.pc $(prefix)/lib/pkgconfig/grpc.pc
1361 $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/pkgconfig/grpc_unsecure.pc $(prefix)/lib/pkgconfig/grpc_unsecure.pc
1362 ifeq ($(HAS_ZOOKEEPER),true)
1363 $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/pkgconfig/grpc_zookeeper.pc $(prefix)/lib/pkgconfig/grpc_zookeeper.pc
1364 endif
murgatroid998faab232015-06-30 17:24:21 -07001365
Craig Tiller841c8802015-09-10 13:06:37 -07001366 install-pkg-config_cxx: pc_cxx pc_cxx_unsecure
1367 $(E) "[INSTALL] Installing C++ pkg-config files"
1368 $(Q) $(INSTALL) -d $(prefix)/lib/pkgconfig
1369 $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/pkgconfig/grpc++.pc $(prefix)/lib/pkgconfig/grpc++.pc
1370 $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/pkgconfig/grpc++_unsecure.pc $(prefix)/lib/pkgconfig/grpc++_unsecure.pc
murgatroid998faab232015-06-30 17:24:21 -07001371
Craig Tiller841c8802015-09-10 13:06:37 -07001372 install-certs: etc/roots.pem
1373 $(E) "[INSTALL] Installing root certificates"
1374 $(Q) $(INSTALL) -d $(prefix)/share/grpc
1375 $(Q) $(INSTALL) etc/roots.pem $(prefix)/share/grpc/roots.pem
Nicolas "Pixel" Noble161ea232015-02-22 05:48:53 +01001376
Craig Tiller841c8802015-09-10 13:06:37 -07001377 verify-install:
1378 ifeq ($(INSTALL_OK),true)
1379 @echo "Your system looks ready to go."
1380 @echo
1381 else
1382 @echo "We couldn't find protoc 3.0.0+ installed on your system. While this"
1383 @echo "won't prevent grpc from working, you won't be able to compile"
1384 @echo "and run any meaningful code with it."
1385 @echo
1386 @echo
1387 @echo "Please download and install protobuf 3.0.0+ from:"
1388 @echo
1389 @echo " https://github.com/google/protobuf/releases"
1390 @echo
1391 @echo "Once you've done so, or if you think this message is in error,"
1392 @echo "you can re-run this check by doing:"
1393 @echo
1394 @echo " make verify-install"
1395 endif
Nicolas "Pixel" Noble98ab9982015-02-21 04:22:16 +01001396
Craig Tiller841c8802015-09-10 13:06:37 -07001397 clean:
1398 $(E) "[CLEAN] Cleaning build directories."
1399 $(Q) $(RM) -rf $(OBJDIR) $(LIBDIR) $(BINDIR) $(GENDIR) cache.mk
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001400
1401
Craig Tiller841c8802015-09-10 13:06:37 -07001402 # The various libraries
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001403
Craig Tiller841c8802015-09-10 13:06:37 -07001404 % for lib in libs:
1405 ${makelib(lib)}
1406 % endfor
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001407
1408
Craig Tiller841c8802015-09-10 13:06:37 -07001409 # All of the test targets, and protoc plugins
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001410
Craig Tiller841c8802015-09-10 13:06:37 -07001411 % for tgt in targets:
1412 ${maketarget(tgt)}
1413 % endfor
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001414
Craig Tiller841c8802015-09-10 13:06:37 -07001415 <%def name="makelib(lib)">
1416 LIB${lib.name.upper()}_SRC = \\
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001417
Craig Tiller841c8802015-09-10 13:06:37 -07001418 % for src in lib.src:
1419 ${proto_to_cc(src)} \\
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001420
Craig Tiller841c8802015-09-10 13:06:37 -07001421 % endfor
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001422
Craig Tiller841c8802015-09-10 13:06:37 -07001423 % if "public_headers" in lib:
1424 % if lib.language == "c++":
1425 PUBLIC_HEADERS_CXX += \\
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001426
Craig Tiller841c8802015-09-10 13:06:37 -07001427 % else:
1428 PUBLIC_HEADERS_C += \\
nnoble85a49262014-12-08 18:14:03 -08001429
Craig Tiller841c8802015-09-10 13:06:37 -07001430 % endif
1431 % for hdr in lib.public_headers:
1432 ${hdr} \\
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001433
Craig Tiller841c8802015-09-10 13:06:37 -07001434 % endfor
1435 % endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001436
Craig Tiller841c8802015-09-10 13:06:37 -07001437 LIB${lib.name.upper()}_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(LIB${lib.name.upper()}_SRC))))
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001438
Craig Tiller0fe5ee72015-12-22 12:50:36 -08001439 % if lib.boringssl:
1440 # boringssl needs an override to ensure that it does not include
1441 # system openssl headers regardless of other configuration
1442 # we do so here with a target specific variable assignment
1443 $(LIB${lib.name.upper()}_OBJS): CFLAGS := -Ithird_party/boringssl/include $(CFLAGS) -Wno-sign-conversion -Wno-conversion -Wno-unused-value -fvisibility=hidden
1444 $(LIB${lib.name.upper()}_OBJS): CXXFLAGS := -Ithird_party/boringssl/include $(CXXFLAGS) -fvisibility=hidden
1445 $(LIB${lib.name.upper()}_OBJS): CPPFLAGS += -DOPENSSL_NO_ASM -D_GNU_SOURCE
Craig Tiller3dca23a2016-01-21 11:44:55 -08001446 % elif lib.zlib:
Craig Tiller16872b82016-01-25 10:55:20 -08001447 $(LIB${lib.name.upper()}_OBJS): CFLAGS := $(CFLAGS) -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-implicit-function-declaration $(W_NO_SHIFT_NEGATIVE_VALUE) -fvisibility=hidden
Craig Tiller0fe5ee72015-12-22 12:50:36 -08001448 % else:
1449 % endif
1450
Craig Tiller841c8802015-09-10 13:06:37 -07001451 ## If the library requires OpenSSL, let's add some restrictions.
1452 % if lib.get('secure', 'check') == True or lib.get('secure', 'check') == 'check':
1453 ifeq ($(NO_SECURE),true)
nnoble69ac39f2014-12-12 15:43:38 -08001454
Craig Tiller841c8802015-09-10 13:06:37 -07001455 # You can't build secure libraries if you don't have OpenSSL.
Nicolas Noble047b7272015-01-16 13:55:05 -08001456
Craig Tiller841c8802015-09-10 13:06:37 -07001457 $(LIBDIR)/$(CONFIG)/lib${lib.name}.a: openssl_dep_error
nnoble69ac39f2014-12-12 15:43:38 -08001458
Craig Tiller841c8802015-09-10 13:06:37 -07001459 % if lib.build == "all":
1460 ifeq ($(SYSTEM),MINGW32)
1461 $(LIBDIR)/$(CONFIG)/${lib.name}.$(SHARED_EXT): openssl_dep_error
1462 else
1463 $(LIBDIR)/$(CONFIG)/lib${lib.name}.$(SHARED_EXT): openssl_dep_error
1464 endif
1465 % endif
nnoble5b7f32a2014-12-22 08:12:44 -08001466
Craig Tiller841c8802015-09-10 13:06:37 -07001467 else
nnoble69ac39f2014-12-12 15:43:38 -08001468
Craig Tiller841c8802015-09-10 13:06:37 -07001469 % if lib.language == 'c++':
1470 ifeq ($(NO_PROTOBUF),true)
Nicolas Noble53830622015-02-12 16:56:38 -08001471
Craig Tiller841c8802015-09-10 13:06:37 -07001472 # 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 -08001473
Craig Tiller841c8802015-09-10 13:06:37 -07001474 $(LIBDIR)/$(CONFIG)/lib${lib.name}.a: protobuf_dep_error
Nicolas Noble53830622015-02-12 16:56:38 -08001475
Craig Tiller841c8802015-09-10 13:06:37 -07001476 % if lib.build == "all":
1477 ifeq ($(SYSTEM),MINGW32)
1478 $(LIBDIR)/$(CONFIG)/${lib.name}.$(SHARED_EXT): protobuf_dep_error
1479 else
1480 $(LIBDIR)/$(CONFIG)/lib${lib.name}.$(SHARED_EXT): protobuf_dep_error
1481 endif
1482 % endif
Nicolas Noble53830622015-02-12 16:56:38 -08001483
Craig Tiller841c8802015-09-10 13:06:37 -07001484 else
1485 % endif
Nicolas Noble53830622015-02-12 16:56:38 -08001486
Craig Tiller841c8802015-09-10 13:06:37 -07001487 $(LIBDIR)/$(CONFIG)/lib${lib.name}.a: $(ZLIB_DEP) $(OPENSSL_DEP)\
1488 ## The else here corresponds to the if secure earlier.
1489 % else:
1490 % if lib.language == 'c++':
1491 ifeq ($(NO_PROTOBUF),true)
Nicolas Noble53830622015-02-12 16:56:38 -08001492
Craig Tiller841c8802015-09-10 13:06:37 -07001493 # 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 -08001494
Craig Tiller841c8802015-09-10 13:06:37 -07001495 $(LIBDIR)/$(CONFIG)/lib${lib.name}.a: protobuf_dep_error
Nicolas Noble53830622015-02-12 16:56:38 -08001496
Craig Tiller841c8802015-09-10 13:06:37 -07001497 % if lib.build == "all":
1498 ifeq ($(SYSTEM),MINGW32)
1499 $(LIBDIR)/$(CONFIG)/${lib.name}.$(SHARED_EXT): protobuf_dep_error
1500 else
1501 $(LIBDIR)/$(CONFIG)/lib${lib.name}.$(SHARED_EXT): protobuf_dep_error
1502 endif
1503 % endif
Nicolas Noble53830622015-02-12 16:56:38 -08001504
Craig Tiller841c8802015-09-10 13:06:37 -07001505 else
Nicolas Noble53830622015-02-12 16:56:38 -08001506
Craig Tiller841c8802015-09-10 13:06:37 -07001507 % endif
Craig Tiller0fe5ee72015-12-22 12:50:36 -08001508 $(LIBDIR)/$(CONFIG)/lib${lib.name}.a: $(ZLIB_DEP) $(OPENSSL_DEP) \
Craig Tiller841c8802015-09-10 13:06:37 -07001509 % endif
1510 % if lib.language == 'c++':
1511 $(PROTOBUF_DEP)\
1512 % endif
1513 $(LIB${lib.name.upper()}_OBJS)
1514 $(E) "[AR] Creating $@"
1515 $(Q) mkdir -p `dirname $@`
1516 $(Q) rm -f $(LIBDIR)/$(CONFIG)/lib${lib.name}.a
1517 $(Q) $(AR) rcs $(LIBDIR)/$(CONFIG)/lib${lib.name}.a $(LIB${lib.name.upper()}_OBJS)
1518 % if lib.get('baselib', False):
Craig Tiller0fe5ee72015-12-22 12:50:36 -08001519 $(Q) rm -rf $(BUILDDIR_ABSOLUTE)/tmp-merge-${lib.name}
1520 $(Q) ( mkdir -p $(BUILDDIR_ABSOLUTE)/tmp-merge-${lib.name}/grpc ; <%text>\</%text>
1521 cd $(BUILDDIR_ABSOLUTE)/tmp-merge-${lib.name}/grpc ; <%text>\</%text>
1522 $(AR) x $(LIBDIR)/$(CONFIG)/lib${lib.name}.a )
1523 $(Q) for l in $(ZLIB_MERGE_LIBS) ; do ( <%text>\</%text>
1524 mkdir -p $(BUILDDIR_ABSOLUTE)/tmp-merge-${lib.name}/zlib ; <%text>\</%text>
1525 cd $(BUILDDIR_ABSOLUTE)/tmp-merge-${lib.name}/zlib ; <%text>\</%text>
1526 <%text>$(AR) x $${l}</%text> ) ; done
1527 $(Q) for l in $(ZLIB_MERGE_LIBS) ; do ( <%text>\</%text>
1528 mkdir -p $(BUILDDIR_ABSOLUTE)/tmp-merge-${lib.name}/zlib ; <%text>\</%text>
1529 cd $(BUILDDIR_ABSOLUTE)/tmp-merge-${lib.name}/zlib ; <%text>\</%text>
1530 <%text>$(AR) x $${l}</%text> ) ; done
Craig Tiller841c8802015-09-10 13:06:37 -07001531 % if lib.get('secure', 'check') == True:
Craig Tiller0fe5ee72015-12-22 12:50:36 -08001532 $(Q) for l in $(OPENSSL_MERGE_LIBS) ; do ( <%text>\</%text>
1533 mkdir -p $(BUILDDIR_ABSOLUTE)/tmp-merge-${lib.name}/ssl ; <%text>\</%text>
1534 cd $(BUILDDIR_ABSOLUTE)/tmp-merge-${lib.name}/ssl ; <%text>\</%text>
1535 <%text>$(AR) x $${l}</%text> ) ; done
1536 $(Q) for l in $(OPENSSL_MERGE_LIBS) ; do ( <%text>\</%text>
1537 mkdir -p $(BUILDDIR_ABSOLUTE)/tmp-merge-${lib.name}/ssl ; <%text>\</%text>
1538 cd $(BUILDDIR_ABSOLUTE)/tmp-merge-${lib.name}/ssl ; <%text>\</%text>
1539 <%text>$(AR) x $${l}</%text> ) ; done
Craig Tiller841c8802015-09-10 13:06:37 -07001540 % endif
Craig Tiller0fe5ee72015-12-22 12:50:36 -08001541 $(Q) rm -f $(LIBDIR)/$(CONFIG)/lib${lib.name}.a $(BUILDDIR_ABSOLUTE)/tmp-merge-${lib.name}/*/__.SYMDEF*
1542 $(Q) ar rcs $(LIBDIR)/$(CONFIG)/lib${lib.name}.a $(BUILDDIR_ABSOLUTE)/tmp-merge-${lib.name}/*/*
1543 $(Q) rm -rf $(BUILDDIR_ABSOLUTE)/tmp-merge-${lib.name}
Craig Tiller841c8802015-09-10 13:06:37 -07001544 % endif
1545 ifeq ($(SYSTEM),Darwin)
1546 $(Q) ranlib $(LIBDIR)/$(CONFIG)/lib${lib.name}.a
1547 endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001548
Craig Tiller841c8802015-09-10 13:06:37 -07001549 <%
Nicolas "Pixel" Noble010f1e72015-04-23 02:23:49 +02001550
Craig Tiller841c8802015-09-10 13:06:37 -07001551 if lib.language == 'c++':
1552 ld = '$(LDXX)'
1553 else:
1554 ld = '$(LD)'
nnoble5b7f32a2014-12-22 08:12:44 -08001555
Craig Tiller841c8802015-09-10 13:06:37 -07001556 out_base = '$(LIBDIR)/$(CONFIG)/' + lib.name
1557 out_libbase = '$(LIBDIR)/$(CONFIG)/lib' + lib.name
nnoble5b7f32a2014-12-22 08:12:44 -08001558
Craig Tiller841c8802015-09-10 13:06:37 -07001559 common = '$(LIB' + lib.name.upper() + '_OBJS) $(LDLIBS)'
nnoble5b7f32a2014-12-22 08:12:44 -08001560
Craig Tiller841c8802015-09-10 13:06:37 -07001561 libs = ''
1562 lib_deps = ' $(ZLIB_DEP)'
1563 mingw_libs = ''
1564 mingw_lib_deps = ' $(ZLIB_DEP)'
1565 if lib.language == 'c++':
1566 lib_deps += ' $(PROTOBUF_DEP)'
1567 mingw_lib_deps += ' $(PROTOBUF_DEP)'
Jan Tattermusch324140c2016-01-12 08:54:01 -08001568 if lib.get('deps_linkage', None) == 'static':
1569 for dep in lib.get('deps', []):
1570 lib_archive = '$(LIBDIR)/$(CONFIG)/lib' + dep + '.a'
1571 common = common + ' ' + lib_archive
1572 lib_deps = lib_deps + ' ' + lib_archive
1573 mingw_lib_deps = mingw_lib_deps + ' ' + lib_archive
1574 else:
1575 for dep in lib.get('deps', []):
1576 libs = libs + ' -l' + dep
1577 lib_deps = lib_deps + ' $(LIBDIR)/$(CONFIG)/lib' + dep + '.$(SHARED_EXT)'
1578 mingw_libs = mingw_libs + ' -l' + dep + '-imp'
1579 mingw_lib_deps = mingw_lib_deps + ' $(LIBDIR)/$(CONFIG)/' + dep + '.$(SHARED_EXT)'
nnoble5b7f32a2014-12-22 08:12:44 -08001580
Craig Tiller841c8802015-09-10 13:06:37 -07001581 security = lib.get('secure', 'check')
1582 if security == True:
1583 common = common + ' $(OPENSSL_MERGE_LIBS) $(LDLIBS_SECURE)'
Craig Tiller0fe5ee72015-12-22 12:50:36 -08001584 common = common + ' $(ZLIB_MERGE_LIBS)'
Nicolas "Pixel" Noblea7c162c2015-07-24 20:21:51 +02001585
Craig Tiller841c8802015-09-10 13:06:37 -07001586 if security in [True, 'check']:
1587 for src in lib.src:
1588 if not proto_re.match(src):
1589 sources_that_need_openssl.add(src)
1590 else:
1591 for src in lib.src:
1592 sources_that_don_t_need_openssl.add(src)
Nicolas "Pixel" Noble061690d2015-03-06 22:58:58 +01001593
Craig Tiller841c8802015-09-10 13:06:37 -07001594 if 'zookeeper' in lib.get('external_deps', []):
1595 libs = libs + ' -lzookeeper_mt'
Hongwei Wanga8cc4392015-07-16 17:37:47 -07001596
Craig Tiller841c8802015-09-10 13:06:37 -07001597 if lib.get('secure', 'check') == True or lib.get('secure', 'check') == 'check':
1598 lib_deps = lib_deps + ' $(OPENSSL_DEP)'
1599 mingw_lib_deps = mingw_lib_deps + ' $(OPENSSL_DEP)'
Nicolas "Pixel" Nobledda049c2015-02-21 00:39:32 +01001600
Craig Tiller841c8802015-09-10 13:06:37 -07001601 if lib.language == 'c++':
1602 common = common + ' $(LDLIBSXX) $(LDLIBS_PROTOBUF)'
1603 %>
nnoble5b7f32a2014-12-22 08:12:44 -08001604
Craig Tiller841c8802015-09-10 13:06:37 -07001605 % if lib.build == "all":
1606 ifeq ($(SYSTEM),MINGW32)
1607 ${out_base}.$(SHARED_EXT): $(LIB${lib.name.upper()}_OBJS) ${mingw_lib_deps}
1608 $(E) "[LD] Linking $@"
1609 $(Q) mkdir -p `dirname $@`
1610 $(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}
1611 else
1612 ${out_libbase}.$(SHARED_EXT): $(LIB${lib.name.upper()}_OBJS) ${lib_deps}
1613 $(E) "[LD] Linking $@"
1614 $(Q) mkdir -p `dirname $@`
1615 ifeq ($(SYSTEM),Darwin)
1616 $(Q) ${ld} $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -install_name lib${lib.name}.$(SHARED_EXT) -dynamiclib -o ${out_libbase}.$(SHARED_EXT) ${common}${libs}
1617 else
1618 $(Q) ${ld} $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,-soname,lib${lib.name}.so.${settings.version.major} -o ${out_libbase}.$(SHARED_EXT) ${common}${libs}
1619 $(Q) ln -sf lib${lib.name}.$(SHARED_EXT) ${out_libbase}.so.${settings.version.major}
1620 $(Q) ln -sf lib${lib.name}.$(SHARED_EXT) ${out_libbase}.so
1621 endif
1622 endif
1623 % endif
1624 % if lib.get('secure', 'check') == True or lib.get('secure', 'check') == 'check':
1625 ## If the lib was secure, we have to close the Makefile's if that tested
1626 ## the presence of OpenSSL.
Nicolas Noble53830622015-02-12 16:56:38 -08001627
Craig Tiller841c8802015-09-10 13:06:37 -07001628 endif
1629 % endif
1630 % if lib.language == 'c++':
1631 ## If the lib was C++, we have to close the Makefile's if that tested
1632 ## the presence of protobuf 3.0.0+
nnoble69ac39f2014-12-12 15:43:38 -08001633
Craig Tiller841c8802015-09-10 13:06:37 -07001634 endif
1635 % endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001636
Craig Tiller841c8802015-09-10 13:06:37 -07001637 % if lib.get('secure', 'check') == True or lib.get('secure', 'check') == 'check':
1638 ifneq ($(NO_SECURE),true)
1639 % endif
1640 ifneq ($(NO_DEPS),true)
1641 -include $(LIB${lib.name.upper()}_OBJS:.o=.dep)
1642 endif
1643 % if lib.get('secure', 'check') == True or lib.get('secure', 'check') == 'check':
1644 endif
1645 % endif
1646 % for src in lib.src:
1647 % if not proto_re.match(src) and any(proto_re.match(src2) for src2 in lib.src):
1648 $(OBJDIR)/$(CONFIG)/${os.path.splitext(src)[0]}.o: ${' '.join(proto_to_cc(src2) for src2 in lib.src if proto_re.match(src2))}
1649 % endif
1650 % endfor
1651 </%def>
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001652
Craig Tiller841c8802015-09-10 13:06:37 -07001653 <%def name="maketarget(tgt)"><% has_no_sources = not tgt.src %>
1654 % if not has_no_sources:
1655 ${tgt.name.upper()}_SRC = \\
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001656
Craig Tiller841c8802015-09-10 13:06:37 -07001657 % for src in tgt.src:
1658 ${proto_to_cc(src)} \\
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001659
Craig Tiller841c8802015-09-10 13:06:37 -07001660 % endfor
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001661
Craig Tiller841c8802015-09-10 13:06:37 -07001662 ${tgt.name.upper()}_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(${tgt.name.upper()}_SRC))))
1663 % endif
1664 % if tgt.get('secure', 'check') == True or tgt.get('secure', 'check') == 'check':
1665 ifeq ($(NO_SECURE),true)
nnoble69ac39f2014-12-12 15:43:38 -08001666
Craig Tiller841c8802015-09-10 13:06:37 -07001667 # You can't build secure targets if you don't have OpenSSL.
Nicolas Noble047b7272015-01-16 13:55:05 -08001668
Craig Tiller841c8802015-09-10 13:06:37 -07001669 $(BINDIR)/$(CONFIG)/${tgt.name}: openssl_dep_error
nnoble69ac39f2014-12-12 15:43:38 -08001670
Craig Tiller841c8802015-09-10 13:06:37 -07001671 else
nnoble69ac39f2014-12-12 15:43:38 -08001672
Craig Tiller841c8802015-09-10 13:06:37 -07001673 % endif
Craig Tiller0fe5ee72015-12-22 12:50:36 -08001674
1675 % if tgt.boringssl:
1676 # boringssl needs an override to ensure that it does not include
1677 # system openssl headers regardless of other configuration
1678 # we do so here with a target specific variable assignment
1679 $(${tgt.name.upper()}_OBJS): CFLAGS := -Ithird_party/boringssl/include $(CFLAGS) -Wno-sign-conversion -Wno-conversion -Wno-unused-value
1680 $(${tgt.name.upper()}_OBJS): CXXFLAGS := -Ithird_party/boringssl/include $(CXXFLAGS)
1681 $(${tgt.name.upper()}_OBJS): CPPFLAGS += -DOPENSSL_NO_ASM -D_GNU_SOURCE
1682 % else:
1683 % endif
1684
Craig Tiller841c8802015-09-10 13:06:37 -07001685 ##
1686 ## We're not trying to add a dependency on building zlib and openssl here,
1687 ## as it's already done in the libraries. We're assuming that the build
1688 ## trickles down, and that a secure target requires a secure version of
1689 ## a library.
1690 ##
1691 ## That simplifies the codegen a bit, but prevents a fully defined Makefile.
1692 ## I can live with that.
1693 ##
1694 % if tgt.build == 'protoc' or tgt.language == 'c++':
Nicolas Noble53830622015-02-12 16:56:38 -08001695
Craig Tiller841c8802015-09-10 13:06:37 -07001696 ifeq ($(NO_PROTOBUF),true)
Nicolas Noble53830622015-02-12 16:56:38 -08001697
Craig Tiller841c8802015-09-10 13:06:37 -07001698 # 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 -08001699
Craig Tiller841c8802015-09-10 13:06:37 -07001700 $(BINDIR)/$(CONFIG)/${tgt.name}: protobuf_dep_error
Nicolas Noble53830622015-02-12 16:56:38 -08001701
Craig Tiller841c8802015-09-10 13:06:37 -07001702 else
Nicolas Noble53830622015-02-12 16:56:38 -08001703
Craig Tiller841c8802015-09-10 13:06:37 -07001704 $(BINDIR)/$(CONFIG)/${tgt.name}: \
1705 % if not has_no_sources:
1706 $(PROTOBUF_DEP) $(${tgt.name.upper()}_OBJS)\
1707 % endif
1708 % else:
1709 $(BINDIR)/$(CONFIG)/${tgt.name}: \
1710 % if not has_no_sources:
1711 $(${tgt.name.upper()}_OBJS)\
1712 % endif
1713 % endif
1714 % for dep in tgt.deps:
1715 $(LIBDIR)/$(CONFIG)/lib${dep}.a\
1716 % endfor
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001717
Craig Tiller0fe5ee72015-12-22 12:50:36 -08001718 % if tgt.language == "c++" or tgt.boringssl:
Craig Tiller841c8802015-09-10 13:06:37 -07001719 ## C++ targets specificies.
1720 % if tgt.build == 'protoc':
1721 $(E) "[HOSTLD] Linking $@"
1722 $(Q) mkdir -p `dirname $@`
1723 $(Q) $(HOST_LDXX) $(HOST_LDFLAGS) \
1724 % if not has_no_sources:
1725 $(${tgt.name.upper()}_OBJS)\
1726 % endif
1727 % else:
1728 $(E) "[LD] Linking $@"
1729 $(Q) mkdir -p `dirname $@`
1730 $(Q) $(LDXX) $(LDFLAGS) \
1731 % if not has_no_sources:
1732 $(${tgt.name.upper()}_OBJS)\
1733 % endif
1734 % endif
1735 % else:
1736 ## C-only targets specificities.
1737 $(E) "[LD] Linking $@"
1738 $(Q) mkdir -p `dirname $@`
1739 $(Q) $(LD) $(LDFLAGS) \
1740 % if not has_no_sources:
1741 $(${tgt.name.upper()}_OBJS)\
1742 % endif
1743 % endif
1744 % for dep in tgt.deps:
1745 $(LIBDIR)/$(CONFIG)/lib${dep}.a\
1746 % endfor
1747 % if 'zookeeper' in tgt.get('external_deps', []):
1748 -lzookeeper_mt\
1749 % endif
1750 % if tgt.language == "c++":
1751 % if tgt.build == 'protoc':
1752 $(HOST_LDLIBSXX) $(HOST_LDLIBS_PROTOC)\
1753 % else:
1754 $(LDLIBSXX) $(LDLIBS_PROTOBUF)\
1755 % endif
1756 % endif
1757 % if tgt.build == 'protoc':
1758 $(HOST_LDLIBS)\
1759 % else:
1760 $(LDLIBS)\
1761 % endif
1762 % if tgt.build == 'protoc':
1763 $(HOST_LDLIBS_PROTOC)\
1764 % elif tgt.get('secure', 'check') == True or tgt.get('secure', 'check') == 'check':
1765 $(LDLIBS_SECURE)\
1766 % endif
1767 % if tgt.language == 'c++' and tgt.build == 'test':
1768 $(GTEST_LIB)\
1769 % elif tgt.language == 'c++' and tgt.build == 'benchmark':
1770 $(GTEST_LIB)\
1771 % endif
1772 -o $(BINDIR)/$(CONFIG)/${tgt.name}
1773 % if tgt.build == 'protoc' or tgt.language == 'c++':
Nicolas Noble53830622015-02-12 16:56:38 -08001774
Craig Tiller841c8802015-09-10 13:06:37 -07001775 endif
1776 % endif
1777 % if tgt.get('secure', 'check') == True or tgt.get('secure', 'check') == 'check':
nnoble69ac39f2014-12-12 15:43:38 -08001778
Craig Tiller841c8802015-09-10 13:06:37 -07001779 endif
1780 % endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001781
Craig Tiller841c8802015-09-10 13:06:37 -07001782 % for src in tgt.src:
1783 $(OBJDIR)/$(CONFIG)/${os.path.splitext(src)[0]}.o: \
1784 % for dep in tgt.deps:
1785 $(LIBDIR)/$(CONFIG)/lib${dep}.a\
1786 % endfor
Craig Tillerf5371ef2015-01-12 16:40:18 -08001787
Craig Tillerab230452016-01-04 08:18:43 -08001788 % if tgt.language == 'c89':
1789 % for src in tgt.src:
Craig Tillerea21ca22016-01-04 12:34:29 -08001790 $(OBJDIR)/$(CONFIG)/${os.path.splitext(src)[0]}.o : ${src}
1791 $(E) "[C] Compiling $<"
1792 $(Q) mkdir -p `dirname $@`
1793 $(Q) $(CC) $(CFLAGS) $(CPPFLAGS) -std=c89 -pedantic -MMD -MF $(addsuffix .dep, $(basename $@)) -c -o $@ $<
Craig Tillerab230452016-01-04 08:18:43 -08001794 % endfor
1795 % endif
1796
Craig Tiller841c8802015-09-10 13:06:37 -07001797 % endfor
1798 % if not has_no_sources:
1799 deps_${tgt.name}: $(${tgt.name.upper()}_OBJS:.o=.dep)
1800 % endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001801
Craig Tiller841c8802015-09-10 13:06:37 -07001802 % if not has_no_sources:
1803 % if tgt.get('secure', 'check') == True or tgt.get('secure', 'check') == 'check':
1804 ifneq ($(NO_SECURE),true)
1805 % endif
1806 ifneq ($(NO_DEPS),true)
1807 -include $(${tgt.name.upper()}_OBJS:.o=.dep)
1808 endif
1809 % if tgt.get('secure', 'check') == True or tgt.get('secure', 'check') == 'check':
1810 endif
1811 % endif
1812 % endif
Nicolas "Pixel" Noble472bb682015-11-03 19:09:01 +01001813 % for src in tgt.src:
1814 % if not proto_re.match(src) and any(proto_re.match(src2) for src2 in tgt.src):
1815 $(OBJDIR)/$(CONFIG)/${os.path.splitext(src)[0]}.o: ${' '.join(proto_to_cc(src2) for src2 in tgt.src if proto_re.match(src2))}
1816 % endif
1817 % endfor
Craig Tiller841c8802015-09-10 13:06:37 -07001818 </%def>
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001819
Craig Tiller841c8802015-09-10 13:06:37 -07001820 ifneq ($(OPENSSL_DEP),)
1821 # This is to ensure the embedded OpenSSL is built beforehand, properly
1822 # installing headers to their final destination on the drive. We need this
1823 # otherwise parallel compilation will fail if a source is compiled first.
1824 % for src in sorted(sources_that_need_openssl):
1825 % if src not in sources_that_don_t_need_openssl:
1826 ${src}: $(OPENSSL_DEP)
1827 % endif
1828 % endfor
1829 endif
Nicolas "Pixel" Noble010f1e72015-04-23 02:23:49 +02001830
Craig Tiller841c8802015-09-10 13:06:37 -07001831 .PHONY: all strip tools \
1832 dep_error openssl_dep_error openssl_dep_message git_update stop \
1833 buildtests buildtests_c buildtests_cxx \
1834 test test_c test_cxx \
1835 install install_c install_cxx \
1836 install-headers install-headers_c install-headers_cxx \
1837 install-shared install-shared_c install-shared_cxx \
1838 install-static install-static_c install-static_cxx \
1839 strip strip-shared strip-static \
1840 strip_c strip-shared_c strip-static_c \
1841 strip_cxx strip-shared_cxx strip-static_cxx \
1842 dep_c dep_cxx bins_dep_c bins_dep_cxx \
1843 clean