blob: 978e7e704516e6f7826665cec077dce84d142c5e [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
Craig Tiller841c8802015-09-10 13:06:37 -070010 # Copyright 2015, Google Inc.
11 # 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 Tiller841c8802015-09-10 13:06:37 -070055 # Basic platform detection
56 HOST_SYSTEM = $(shell uname | cut -f 1 -d_)
57 ifeq ($(SYSTEM),)
58 SYSTEM = $(HOST_SYSTEM)
59 endif
60 ifeq ($(SYSTEM),MSYS)
61 SYSTEM = MINGW32
62 endif
63 ifeq ($(SYSTEM),MINGW64)
64 SYSTEM = MINGW32
65 endif
Craig Tiller96b49552015-01-21 16:29:01 -080066
67
Nicolas "Pixel" Noble6dad9b02015-09-23 18:32:26 +020068 MAKEFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST)))
Craig Tiller841c8802015-09-10 13:06:37 -070069 ifndef BUILDDIR
Nicolas "Pixel" Noble42b4c282015-09-17 23:57:08 +020070 BUILDDIR_ABSOLUTE = $(patsubst %/,%,$(dir $(MAKEFILE_PATH)))
71 else
72 BUILDDIR_ABSOLUTE = $(abspath $(BUILDDIR))
Craig Tiller841c8802015-09-10 13:06:37 -070073 endif
Craig Tiller61b910f2015-02-15 10:54:07 -080074
Craig Tiller841c8802015-09-10 13:06:37 -070075 HAS_GCC = $(shell which gcc > /dev/null 2> /dev/null && echo true || echo false)
76 HAS_CC = $(shell which cc > /dev/null 2> /dev/null && echo true || echo false)
77 HAS_CLANG = $(shell which clang > /dev/null 2> /dev/null && echo true || echo false)
Nicolas Noblef8681182015-03-18 14:25:44 -070078
Craig Tiller841c8802015-09-10 13:06:37 -070079 ifeq ($(HAS_CC),true)
80 DEFAULT_CC = cc
81 DEFAULT_CXX = c++
82 else
83 ifeq ($(HAS_GCC),true)
84 DEFAULT_CC = gcc
85 DEFAULT_CXX = g++
86 else
87 ifeq ($(HAS_CLANG),true)
88 DEFAULT_CC = clang
89 DEFAULT_CXX = clang++
90 else
91 DEFAULT_CC = no_c_compiler
92 DEFAULT_CXX = no_c++_compiler
93 endif
94 endif
95 endif
Nicolas Noblef8681182015-03-18 14:25:44 -070096
97
Nicolas "Pixel" Noble42b4c282015-09-17 23:57:08 +020098 BINDIR = $(BUILDDIR_ABSOLUTE)/bins
99 OBJDIR = $(BUILDDIR_ABSOLUTE)/objs
100 LIBDIR = $(BUILDDIR_ABSOLUTE)/libs
101 GENDIR = $(BUILDDIR_ABSOLUTE)/gens
Craig Tiller61b910f2015-02-15 10:54:07 -0800102
Craig Tiller841c8802015-09-10 13:06:37 -0700103 # Configurations
ctiller8cfebb92015-01-06 15:02:12 -0800104
Craig Tiller841c8802015-09-10 13:06:37 -0700105 VALID_CONFIG_opt = 1
106 CC_opt = $(DEFAULT_CC)
107 CXX_opt = $(DEFAULT_CXX)
108 LD_opt = $(DEFAULT_CC)
109 LDXX_opt = $(DEFAULT_CXX)
110 CPPFLAGS_opt = -O2
111 LDFLAGS_opt =
112 DEFINES_opt = NDEBUG
ctiller8cfebb92015-01-06 15:02:12 -0800113
Craig Tiller841c8802015-09-10 13:06:37 -0700114 VALID_CONFIG_basicprof = 1
115 CC_basicprof = $(DEFAULT_CC)
116 CXX_basicprof = $(DEFAULT_CXX)
117 LD_basicprof = $(DEFAULT_CC)
118 LDXX_basicprof = $(DEFAULT_CXX)
119 CPPFLAGS_basicprof = -O2 -DGRPC_BASIC_PROFILER -DGRPC_TIMERS_RDTSC
120 LDFLAGS_basicprof =
121 DEFINES_basicprof = NDEBUG
David Garcia Quintas8954e902015-04-29 09:46:33 -0700122
Craig Tiller841c8802015-09-10 13:06:37 -0700123 VALID_CONFIG_stapprof = 1
124 CC_stapprof = $(DEFAULT_CC)
125 CXX_stapprof = $(DEFAULT_CXX)
126 LD_stapprof = $(DEFAULT_CC)
127 LDXX_stapprof = $(DEFAULT_CXX)
128 CPPFLAGS_stapprof = -O2 -DGRPC_STAP_PROFILER
129 LDFLAGS_stapprof =
130 DEFINES_stapprof = NDEBUG
Vijay Paibc171132015-04-13 10:58:06 -0700131
Craig Tiller841c8802015-09-10 13:06:37 -0700132 VALID_CONFIG_dbg = 1
133 CC_dbg = $(DEFAULT_CC)
134 CXX_dbg = $(DEFAULT_CXX)
135 LD_dbg = $(DEFAULT_CC)
136 LDXX_dbg = $(DEFAULT_CXX)
137 CPPFLAGS_dbg = -O0
138 LDFLAGS_dbg =
139 DEFINES_dbg = _DEBUG DEBUG
ctiller8cfebb92015-01-06 15:02:12 -0800140
Craig Tiller841c8802015-09-10 13:06:37 -0700141 VALID_CONFIG_mutrace = 1
142 CC_mutrace = $(DEFAULT_CC)
143 CXX_mutrace = $(DEFAULT_CXX)
144 LD_mutrace = $(DEFAULT_CC)
145 LDXX_mutrace = $(DEFAULT_CXX)
146 CPPFLAGS_mutrace = -O0
147 LDFLAGS_mutrace = -rdynamic
148 DEFINES_mutrace = _DEBUG DEBUG
Vijay Paidc7110f2015-04-02 13:59:05 -0700149
Craig Tiller841c8802015-09-10 13:06:37 -0700150 VALID_CONFIG_valgrind = 1
151 REQUIRE_CUSTOM_LIBRARIES_valgrind = 1
152 CC_valgrind = $(DEFAULT_CC)
153 CXX_valgrind = $(DEFAULT_CXX)
154 LD_valgrind = $(DEFAULT_CC)
155 LDXX_valgrind = $(DEFAULT_CXX)
156 CPPFLAGS_valgrind = -O0
157 OPENSSL_CFLAGS_valgrind = -DPURIFY
158 LDFLAGS_valgrind =
159 DEFINES_valgrind = _DEBUG DEBUG GRPC_TEST_SLOWDOWN_BUILD_FACTOR=20
Craig Tillerec0b8f32015-01-15 07:30:00 -0800160
Craig Tiller841c8802015-09-10 13:06:37 -0700161 VALID_CONFIG_tsan = 1
162 REQUIRE_CUSTOM_LIBRARIES_tsan = 1
163 CC_tsan = clang
164 CXX_tsan = clang++
165 LD_tsan = clang
166 LDXX_tsan = clang++
Craig Tillerf29a3882015-09-11 12:59:27 -0700167 CPPFLAGS_tsan = -O0 -fsanitize=thread -fno-omit-frame-pointer -Wno-unused-command-line-argument
Craig Tiller841c8802015-09-10 13:06:37 -0700168 LDFLAGS_tsan = -fsanitize=thread
169 DEFINES_tsan = NDEBUG GRPC_TEST_SLOWDOWN_BUILD_FACTOR=10
ctiller8cfebb92015-01-06 15:02:12 -0800170
Craig Tiller841c8802015-09-10 13:06:37 -0700171 VALID_CONFIG_asan = 1
172 REQUIRE_CUSTOM_LIBRARIES_asan = 1
173 CC_asan = clang
174 CXX_asan = clang++
175 LD_asan = clang
176 LDXX_asan = clang++
Craig Tillerf29a3882015-09-11 12:59:27 -0700177 CPPFLAGS_asan = -O0 -fsanitize=address -fno-omit-frame-pointer -Wno-unused-command-line-argument
Craig Tiller841c8802015-09-10 13:06:37 -0700178 LDFLAGS_asan = -fsanitize=address
179 DEFINES_asan = GRPC_TEST_SLOWDOWN_BUILD_FACTOR=3
ctiller8cfebb92015-01-06 15:02:12 -0800180
Craig Tiller841c8802015-09-10 13:06:37 -0700181 VALID_CONFIG_msan = 1
182 REQUIRE_CUSTOM_LIBRARIES_msan = 1
183 CC_msan = clang
184 CXX_msan = clang++-libc++
185 LD_msan = clang
186 LDXX_msan = clang++-libc++
Craig Tillerf29a3882015-09-11 12:59:27 -0700187 CPPFLAGS_msan = -O0 -fsanitize=memory -fsanitize-memory-track-origins -fno-omit-frame-pointer -DGTEST_HAS_TR1_TUPLE=0 -DGTEST_USE_OWN_TR1_TUPLE=1 -Wno-unused-command-line-argument
Craig Tiller841c8802015-09-10 13:06:37 -0700188 OPENSSL_CFLAGS_msan = -DPURIFY
189 LDFLAGS_msan = -fsanitize=memory -DGTEST_HAS_TR1_TUPLE=0 -DGTEST_USE_OWN_TR1_TUPLE=1
190 DEFINES_msan = NDEBUG GRPC_TEST_SLOWDOWN_BUILD_FACTOR=4
ctiller8cfebb92015-01-06 15:02:12 -0800191
Craig Tiller841c8802015-09-10 13:06:37 -0700192 VALID_CONFIG_ubsan = 1
193 REQUIRE_CUSTOM_LIBRARIES_ubsan = 1
194 CC_ubsan = clang
195 CXX_ubsan = clang++
196 LD_ubsan = clang
197 LDXX_ubsan = clang++
Craig Tillerf29a3882015-09-11 12:59:27 -0700198 CPPFLAGS_ubsan = -O1 -fsanitize=undefined -fno-omit-frame-pointer -Wno-unused-command-line-argument
Craig Tiller841c8802015-09-10 13:06:37 -0700199 OPENSSL_CFLAGS_ubsan = -DPURIFY
200 LDFLAGS_ubsan = -fsanitize=undefined
201 DEFINES_ubsan = NDEBUG GRPC_TEST_SLOWDOWN_BUILD_FACTOR=3
Craig Tiller96bd5f62015-02-13 09:04:13 -0800202
Craig Tiller841c8802015-09-10 13:06:37 -0700203 VALID_CONFIG_gcov = 1
204 CC_gcov = gcc
205 CXX_gcov = g++
206 LD_gcov = gcc
207 LDXX_gcov = g++
208 CPPFLAGS_gcov = -O0 -fprofile-arcs -ftest-coverage
209 LDFLAGS_gcov = -fprofile-arcs -ftest-coverage
210 DEFINES_gcov = _DEBUG DEBUG
Craig Tiller699ba212015-01-13 17:02:20 -0800211
Nicolas Noble047b7272015-01-16 13:55:05 -0800212
Craig Tiller841c8802015-09-10 13:06:37 -0700213 # General settings.
214 # You may want to change these depending on your system.
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800215
Craig Tiller841c8802015-09-10 13:06:37 -0700216 prefix ?= /usr/local
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800217
Craig Tiller841c8802015-09-10 13:06:37 -0700218 PROTOC = protoc
219 DTRACE = dtrace
220 CONFIG ?= opt
221 CC = $(CC_$(CONFIG))
222 CXX = $(CXX_$(CONFIG))
223 LD = $(LD_$(CONFIG))
224 LDXX = $(LDXX_$(CONFIG))
225 AR = ar
226 ifeq ($(SYSTEM),Linux)
227 STRIP = strip --strip-unneeded
228 else
229 ifeq ($(SYSTEM),Darwin)
230 STRIP = strip -x
231 else
232 STRIP = strip
233 endif
234 endif
235 INSTALL = install
236 RM = rm -f
237 PKG_CONFIG = pkg-config
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800238
Craig Tiller841c8802015-09-10 13:06:37 -0700239 ifndef VALID_CONFIG_$(CONFIG)
240 $(error Invalid CONFIG value '$(CONFIG)')
241 endif
yangg102e4fe2015-01-06 16:02:50 -0800242
Craig Tiller841c8802015-09-10 13:06:37 -0700243 ifeq ($(SYSTEM),Linux)
244 TMPOUT = /dev/null
245 else
246 TMPOUT = `mktemp /tmp/test-out-XXXXXX`
247 endif
Nicolas Noble047b7272015-01-16 13:55:05 -0800248
Craig Tiller841c8802015-09-10 13:06:37 -0700249 # Detect if we can use C++11
250 CXX11_CHECK_CMD = $(CXX) -std=c++11 -o $(TMPOUT) -c test/build/c++11.cc
251 HAS_CXX11 = $(shell $(CXX11_CHECK_CMD) 2> /dev/null && echo true || echo false)
Craig Tillercf133f42015-02-26 14:05:56 -0800252
Craig Tiller841c8802015-09-10 13:06:37 -0700253 # The HOST compiler settings are used to compile the protoc plugins.
254 # In most cases, you won't have to change anything, but if you are
255 # cross-compiling, you can override these variables from GNU make's
256 # command line: make CC=cross-gcc HOST_CC=gcc
Nicolas Noble047b7272015-01-16 13:55:05 -0800257
Craig Tiller841c8802015-09-10 13:06:37 -0700258 HOST_CC = $(CC)
259 HOST_CXX = $(CXX)
260 HOST_LD = $(LD)
261 HOST_LDXX = $(LDXX)
nnoble72309c62014-12-12 11:42:26 -0800262
Craig Tiller841c8802015-09-10 13:06:37 -0700263 ifdef EXTRA_DEFINES
264 DEFINES += $(EXTRA_DEFINES)
265 endif
Craig Tiller86fa1c52015-02-27 09:57:58 -0800266
Craig Tiller6a6b36c2015-09-10 16:00:22 -0700267 CFLAGS += -std=c89 -pedantic -Wsign-conversion -Wconversion
Craig Tiller841c8802015-09-10 13:06:37 -0700268 ifeq ($(HAS_CXX11),true)
269 CXXFLAGS += -std=c++11
270 else
271 CXXFLAGS += -std=c++0x
272 endif
273 CPPFLAGS += -g -Wall -Wextra -Werror -Wno-long-long -Wno-unused-parameter
274 LDFLAGS += -g
Nicolas Noblef8681182015-03-18 14:25:44 -0700275
Craig Tiller841c8802015-09-10 13:06:37 -0700276 CPPFLAGS += $(CPPFLAGS_$(CONFIG))
277 DEFINES += $(DEFINES_$(CONFIG)) INSTALL_PREFIX=\"$(prefix)\"
278 LDFLAGS += $(LDFLAGS_$(CONFIG))
Nicolas "Pixel" Noble482d7612015-07-16 23:43:30 +0200279
Craig Tiller841c8802015-09-10 13:06:37 -0700280 ifneq ($(SYSTEM),MINGW32)
281 PIC_CPPFLAGS = -fPIC
282 CPPFLAGS += -fPIC
283 LDFLAGS += -fPIC
284 endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800285
Craig Tiller841c8802015-09-10 13:06:37 -0700286 INCLUDES = . include $(GENDIR)
287 LDFLAGS += -Llibs/$(CONFIG)
Nicolas "Pixel" Noble3adab742015-06-02 00:33:06 +0200288
Craig Tiller841c8802015-09-10 13:06:37 -0700289 ifeq ($(SYSTEM),Darwin)
290 ifneq ($(wildcard /usr/local/ssl/include),)
291 INCLUDES += /usr/local/ssl/include
292 endif
293 ifneq ($(wildcard /opt/local/include),)
294 INCLUDES += /opt/local/include
295 endif
296 ifneq ($(wildcard /usr/local/include),)
297 INCLUDES += /usr/local/include
298 endif
299 LIBS = m z
300 ifneq ($(wildcard /usr/local/ssl/lib),)
301 LDFLAGS += -L/usr/local/ssl/lib
302 endif
303 ifneq ($(wildcard /opt/local/lib),)
304 LDFLAGS += -L/opt/local/lib
305 endif
306 ifneq ($(wildcard /usr/local/lib),)
307 LDFLAGS += -L/usr/local/lib
308 endif
309 endif
Nicolas Noblef8681182015-03-18 14:25:44 -0700310
Craig Tiller841c8802015-09-10 13:06:37 -0700311 ifeq ($(SYSTEM),Linux)
312 LIBS = rt m z pthread
313 LDFLAGS += -pthread
314 endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800315
Craig Tiller841c8802015-09-10 13:06:37 -0700316 ifeq ($(SYSTEM),MINGW32)
317 LIBS = m z pthread
318 LDFLAGS += -pthread
319 endif
Nicolas Noblef8681182015-03-18 14:25:44 -0700320
Craig Tiller841c8802015-09-10 13:06:37 -0700321 GTEST_LIB = -Ithird_party/googletest/include -Ithird_party/googletest third_party/googletest/src/gtest-all.cc
322 GTEST_LIB += -lgflags
323 ifeq ($(V),1)
324 E = @:
325 Q =
326 else
327 E = @echo
328 Q = @
329 endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800330
Craig Tiller841c8802015-09-10 13:06:37 -0700331 VERSION = ${settings.version.major}.${settings.version.minor}.${settings.version.micro}.${settings.version.build}
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800332
Craig Tiller841c8802015-09-10 13:06:37 -0700333 CPPFLAGS_NO_ARCH += $(addprefix -I, $(INCLUDES)) $(addprefix -D, $(DEFINES))
334 CPPFLAGS += $(CPPFLAGS_NO_ARCH) $(ARCH_FLAGS)
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800335
Craig Tiller841c8802015-09-10 13:06:37 -0700336 LDFLAGS += $(ARCH_FLAGS)
337 LDLIBS += $(addprefix -l, $(LIBS))
338 LDLIBSXX += $(addprefix -l, $(LIBSXX))
nnoble72309c62014-12-12 11:42:26 -0800339
Craig Tiller841c8802015-09-10 13:06:37 -0700340 HOST_CPPFLAGS = $(CPPFLAGS)
341 HOST_CFLAGS = $(CFLAGS)
342 HOST_CXXFLAGS = $(CXXFLAGS)
343 HOST_LDFLAGS = $(LDFLAGS)
344 HOST_LDLIBS = $(LDLIBS)
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800345
nnoble69ac39f2014-12-12 15:43:38 -0800346
Craig Tiller841c8802015-09-10 13:06:37 -0700347 # These are automatically computed variables.
348 # There shouldn't be any need to change anything from now on.
nnoble69ac39f2014-12-12 15:43:38 -0800349
Craig Tiller841c8802015-09-10 13:06:37 -0700350 -include cache.mk
murgatroid9924e2f4a2015-06-29 11:12:01 -0700351
Craig Tiller841c8802015-09-10 13:06:37 -0700352 CACHE_MK =
murgatroid99aa521572015-07-10 14:49:12 -0700353
Craig Tiller841c8802015-09-10 13:06:37 -0700354 HAS_PKG_CONFIG ?= $(shell command -v $(PKG_CONFIG) >/dev/null 2>&1 && echo true || echo false)
murgatroid99aa521572015-07-10 14:49:12 -0700355
Craig Tiller841c8802015-09-10 13:06:37 -0700356 ifeq ($(HAS_PKG_CONFIG), true)
357 CACHE_MK += HAS_PKG_CONFIG = true,
358 endif
nnoble69ac39f2014-12-12 15:43:38 -0800359
Craig Tiller841c8802015-09-10 13:06:37 -0700360 PC_TEMPLATE = prefix=$(prefix),\
361 exec_prefix=${'\$${prefix}'},\
362 includedir=${'\$${prefix}'}/include,\
363 libdir=${'\$${exec_prefix}'}/lib,\
364 ,\
365 Name: $(PC_NAME),\
366 Description: $(PC_DESCRIPTION),\
367 Version: $(VERSION),\
368 Cflags: -I${'\$${includedir}'} $(PC_CFLAGS),\
369 Requires.private: $(PC_REQUIRES_PRIVATE),\
370 Libs: -L${'\$${libdir}'} $(PC_LIB),\
371 Libs.private: $(PC_LIBS_PRIVATE)
murgatroid998faab232015-06-30 17:24:21 -0700372
Craig Tiller841c8802015-09-10 13:06:37 -0700373 # gpr .pc file
374 PC_NAME = gRPC Portable Runtime
375 PC_DESCRIPTION = gRPC Portable Runtime
376 PC_CFLAGS = -pthread
377 PC_REQUIRES_PRIVATE =
378 PC_LIBS_PRIVATE = -lpthread
379 PC_LIB = -lgpr
380 ifneq ($(SYSTEM),Darwin)
381 PC_LIBS_PRIVATE += -lrt
382 endif
383 GPR_PC_FILE := $(PC_TEMPLATE)
murgatroid998faab232015-06-30 17:24:21 -0700384
Craig Tiller841c8802015-09-10 13:06:37 -0700385 ifeq ($(SYSTEM),MINGW32)
386 SHARED_EXT = dll
387 endif
388 ifeq ($(SYSTEM),Darwin)
389 SHARED_EXT = dylib
390 endif
391 ifeq ($(SHARED_EXT),)
392 SHARED_EXT = so.$(VERSION)
393 endif
nnoble5b7f32a2014-12-22 08:12:44 -0800394
Craig Tiller841c8802015-09-10 13:06:37 -0700395 ifeq ($(wildcard .git),)
396 IS_GIT_FOLDER = false
397 else
398 IS_GIT_FOLDER = true
399 endif
nnoble69ac39f2014-12-12 15:43:38 -0800400
Craig Tiller841c8802015-09-10 13:06:37 -0700401 ifeq ($(SYSTEM),Linux)
402 OPENSSL_REQUIRES_DL = true
403 endif
Nicolas Noblef8681182015-03-18 14:25:44 -0700404
Craig Tiller841c8802015-09-10 13:06:37 -0700405 ifeq ($(SYSTEM),Darwin)
406 OPENSSL_REQUIRES_DL = true
407 endif
Nicolas Noblef8681182015-03-18 14:25:44 -0700408
Craig Tiller841c8802015-09-10 13:06:37 -0700409 ifeq ($(HAS_PKG_CONFIG),true)
410 OPENSSL_ALPN_CHECK_CMD = $(PKG_CONFIG) --atleast-version=1.0.2 openssl
411 OPENSSL_NPN_CHECK_CMD = $(PKG_CONFIG) --atleast-version=1.0.1 openssl
412 ZLIB_CHECK_CMD = $(PKG_CONFIG) --exists zlib
413 PROTOBUF_CHECK_CMD = $(PKG_CONFIG) --atleast-version=3.0.0-alpha-3 protobuf
414 else # HAS_PKG_CONFIG
murgatroid9924e2f4a2015-06-29 11:12:01 -0700415
Craig Tiller841c8802015-09-10 13:06:37 -0700416 ifeq ($(SYSTEM),MINGW32)
417 OPENSSL_LIBS = ssl32 eay32
418 else
419 OPENSSL_LIBS = ssl crypto
420 endif
Nicolas Noblef8681182015-03-18 14:25:44 -0700421
Craig Tiller841c8802015-09-10 13:06:37 -0700422 OPENSSL_ALPN_CHECK_CMD = $(CC) $(CFLAGS) $(CPPFLAGS) -o $(TMPOUT) test/build/openssl-alpn.c $(addprefix -l, $(OPENSSL_LIBS)) $(LDFLAGS)
423 OPENSSL_NPN_CHECK_CMD = $(CC) $(CFLAGS) $(CPPFLAGS) -o $(TMPOUT) test/build/openssl-npn.c $(addprefix -l, $(OPENSSL_LIBS)) $(LDFLAGS)
424 ZLIB_CHECK_CMD = $(CC) $(CFLAGS) $(CPPFLAGS) -o $(TMPOUT) test/build/zlib.c -lz $(LDFLAGS)
425 PROTOBUF_CHECK_CMD = $(CXX) $(CXXFLAGS) $(CPPFLAGS) -o $(TMPOUT) test/build/protobuf.cc -lprotobuf $(LDFLAGS)
Craig Tiller297fafa2015-01-15 15:46:39 -0800426
Craig Tiller841c8802015-09-10 13:06:37 -0700427 ifeq ($(OPENSSL_REQUIRES_DL),true)
428 OPENSSL_ALPN_CHECK_CMD += -ldl
429 OPENSSL_NPN_CHECK_CMD += -ldl
430 endif
Nicolas Noblef8681182015-03-18 14:25:44 -0700431
Craig Tiller841c8802015-09-10 13:06:37 -0700432 endif # HAS_PKG_CONFIG
murgatroid9924e2f4a2015-06-29 11:12:01 -0700433
Craig Tiller841c8802015-09-10 13:06:37 -0700434 PERFTOOLS_CHECK_CMD = $(CC) $(CFLAGS) $(CPPFLAGS) -o $(TMPOUT) test/build/perftools.c -lprofiler $(LDFLAGS)
murgatroid996d9e4012015-07-08 10:22:45 -0700435
Craig Tiller841c8802015-09-10 13:06:37 -0700436 PROTOC_CHECK_CMD = which protoc > /dev/null
437 PROTOC_CHECK_VERSION_CMD = protoc --version | grep -q libprotoc.3
438 DTRACE_CHECK_CMD = which dtrace > /dev/null
439 SYSTEMTAP_HEADERS_CHECK_CMD = $(CC) $(CFLAGS) $(CPPFLAGS) -o $(TMPOUT) test/build/systemtap.c $(LDFLAGS)
440 ZOOKEEPER_CHECK_CMD = $(CC) $(CFLAGS) $(CPPFLAGS) -o $(TMPOUT) test/build/zookeeper.c $(LDFLAGS) -lzookeeper_mt
murgatroid9924e2f4a2015-06-29 11:12:01 -0700441
Craig Tiller841c8802015-09-10 13:06:37 -0700442 ifndef REQUIRE_CUSTOM_LIBRARIES_$(CONFIG)
443 HAS_SYSTEM_PERFTOOLS ?= $(shell $(PERFTOOLS_CHECK_CMD) 2> /dev/null && echo true || echo false)
444 ifeq ($(HAS_SYSTEM_PERFTOOLS),true)
445 DEFINES += GRPC_HAVE_PERFTOOLS
446 LIBS += profiler
447 CACHE_MK += HAS_SYSTEM_PERFTOOLS = true,
448 endif
449 endif
nnoble69ac39f2014-12-12 15:43:38 -0800450
Craig Tiller841c8802015-09-10 13:06:37 -0700451 HAS_SYSTEM_PROTOBUF_VERIFY = $(shell $(PROTOBUF_CHECK_CMD) 2> /dev/null && echo true || echo false)
452 ifndef REQUIRE_CUSTOM_LIBRARIES_$(CONFIG)
453 HAS_SYSTEM_OPENSSL_ALPN ?= $(shell $(OPENSSL_ALPN_CHECK_CMD) 2> /dev/null && echo true || echo false)
454 ifeq ($(HAS_SYSTEM_OPENSSL_ALPN),true)
455 HAS_SYSTEM_OPENSSL_NPN = true
456 CACHE_MK += HAS_SYSTEM_OPENSSL_ALPN = true,
457 else
458 HAS_SYSTEM_OPENSSL_NPN ?= $(shell $(OPENSSL_NPN_CHECK_CMD) 2> /dev/null && echo true || echo false)
459 endif
460 ifeq ($(HAS_SYSTEM_OPENSSL_NPN),true)
461 CACHE_MK += HAS_SYSTEM_OPENSSL_NPN = true,
462 endif
463 HAS_SYSTEM_ZLIB ?= $(shell $(ZLIB_CHECK_CMD) 2> /dev/null && echo true || echo false)
464 ifeq ($(HAS_SYSTEM_ZLIB),true)
465 CACHE_MK += HAS_SYSTEM_ZLIB = true,
466 endif
467 HAS_SYSTEM_PROTOBUF ?= $(HAS_SYSTEM_PROTOBUF_VERIFY)
468 ifeq ($(HAS_SYSTEM_PROTOBUF),true)
469 CACHE_MK += HAS_SYSTEM_PROTOBUF = true,
470 endif
471 else
472 # override system libraries if the config requires a custom compiled library
473 HAS_SYSTEM_OPENSSL_ALPN = false
474 HAS_SYSTEM_OPENSSL_NPN = false
475 HAS_SYSTEM_ZLIB = false
476 HAS_SYSTEM_PROTOBUF = false
477 endif
nnoble69ac39f2014-12-12 15:43:38 -0800478
Craig Tiller841c8802015-09-10 13:06:37 -0700479 HAS_PROTOC ?= $(shell $(PROTOC_CHECK_CMD) 2> /dev/null && echo true || echo false)
480 ifeq ($(HAS_PROTOC),true)
481 CACHE_MK += HAS_PROTOC = true,
482 HAS_VALID_PROTOC ?= $(shell $(PROTOC_CHECK_VERSION_CMD) 2> /dev/null && echo true || echo false)
483 ifeq ($(HAS_VALID_PROTOC),true)
484 CACHE_MK += HAS_VALID_PROTOC = true,
485 endif
486 else
487 HAS_VALID_PROTOC = false
488 endif
Nicolas Noble53830622015-02-12 16:56:38 -0800489
Craig Tiller841c8802015-09-10 13:06:37 -0700490 # Check for Systemtap (https://sourceware.org/systemtap/), first by making sure <sys/sdt.h> is present
491 # in the system and secondly by checking for the "dtrace" binary (on Linux, this is part of the Systemtap
492 # distribution. It's part of the base system on BSD/Solaris machines).
493 ifndef HAS_SYSTEMTAP
494 HAS_SYSTEMTAP_HEADERS = $(shell $(SYSTEMTAP_HEADERS_CHECK_CMD) 2> /dev/null && echo true || echo false)
495 HAS_DTRACE = $(shell $(DTRACE_CHECK_CMD) 2> /dev/null && echo true || echo false)
496 HAS_SYSTEMTAP = false
497 ifeq ($(HAS_SYSTEMTAP_HEADERS),true)
498 ifeq ($(HAS_DTRACE),true)
499 HAS_SYSTEMTAP = true
500 endif
501 endif
502 endif
David Garcia Quintas611b7362015-04-27 15:49:31 -0700503
Craig Tiller841c8802015-09-10 13:06:37 -0700504 ifeq ($(HAS_SYSTEMTAP),true)
505 CACHE_MK += HAS_SYSTEMTAP = true,
506 endif
nnoble69ac39f2014-12-12 15:43:38 -0800507
Craig Tiller841c8802015-09-10 13:06:37 -0700508 HAS_ZOOKEEPER = $(shell $(ZOOKEEPER_CHECK_CMD) 2> /dev/null && echo true || echo false)
Hongwei Wanga8cc4392015-07-16 17:37:47 -0700509
Craig Tiller841c8802015-09-10 13:06:37 -0700510 # Note that for testing purposes, one can do:
511 # make HAS_EMBEDDED_OPENSSL_ALPN=false
512 # to emulate the fact we do not have OpenSSL in the third_party folder.
513 ifeq ($(wildcard third_party/openssl/ssl/ssl.h),)
514 HAS_EMBEDDED_OPENSSL_ALPN = false
515 else
516 HAS_EMBEDDED_OPENSSL_ALPN = true
517 endif
nnoble69ac39f2014-12-12 15:43:38 -0800518
Craig Tiller841c8802015-09-10 13:06:37 -0700519 ifeq ($(wildcard third_party/zlib/zlib.h),)
520 HAS_EMBEDDED_ZLIB = false
521 else
522 HAS_EMBEDDED_ZLIB = true
523 endif
nnoble69ac39f2014-12-12 15:43:38 -0800524
Craig Tiller841c8802015-09-10 13:06:37 -0700525 ifeq ($(wildcard third_party/protobuf/src/google/protobuf/descriptor.pb.h),)
526 HAS_EMBEDDED_PROTOBUF = false
527 ifneq ($(HAS_VALID_PROTOC),true)
528 NO_PROTOC = true
529 endif
530 else
531 HAS_EMBEDDED_PROTOBUF = true
532 endif
Nicolas Noble53830622015-02-12 16:56:38 -0800533
Craig Tiller841c8802015-09-10 13:06:37 -0700534 PC_REQUIRES_GRPC = gpr
535 PC_LIBS_GRPC =
murgatroid998faab232015-06-30 17:24:21 -0700536
Craig Tiller841c8802015-09-10 13:06:37 -0700537 ifeq ($(HAS_SYSTEM_ZLIB),false)
538 ifeq ($(HAS_EMBEDDED_ZLIB),true)
539 ZLIB_DEP = $(LIBDIR)/$(CONFIG)/zlib/libz.a
540 CPPFLAGS += -Ithird_party/zlib
541 LDFLAGS += -L$(LIBDIR)/$(CONFIG)/zlib
542 else
543 DEP_MISSING += zlib
544 endif
545 else
546 ifeq ($(HAS_PKG_CONFIG),true)
547 CPPFLAGS += $(shell $(PKG_CONFIG) --cflags zlib)
548 LDFLAGS += $(shell $(PKG_CONFIG) --libs-only-L zlib)
549 PC_REQUIRES_GRPC += zlib
550 else
551 PC_LIBS_GRPC += -lz
552 endif
553 endif
nnoble69ac39f2014-12-12 15:43:38 -0800554
Craig Tiller841c8802015-09-10 13:06:37 -0700555 OPENSSL_PKG_CONFIG = false
murgatroid99da7a9942015-06-29 14:57:37 -0700556
Craig Tiller841c8802015-09-10 13:06:37 -0700557 PC_REQUIRES_SECURE =
558 PC_LIBS_SECURE =
murgatroid998faab232015-06-30 17:24:21 -0700559
Craig Tiller841c8802015-09-10 13:06:37 -0700560 ifeq ($(HAS_SYSTEM_OPENSSL_ALPN),true)
561 ifeq ($(HAS_PKG_CONFIG),true)
562 OPENSSL_PKG_CONFIG = true
563 PC_REQUIRES_SECURE = openssl
564 CPPFLAGS := $(shell $(PKG_CONFIG) --cflags openssl) $(CPPFLAGS)
565 LDFLAGS_OPENSSL_PKG_CONFIG = $(shell $(PKG_CONFIG) --libs-only-L openssl)
566 ifeq ($(SYSTEM),Linux)
567 ifneq ($(LDFLAGS_OPENSSL_PKG_CONFIG),)
568 LDFLAGS_OPENSSL_PKG_CONFIG += $(shell $(PKG_CONFIG) --libs-only-L openssl | sed s/L/Wl,-rpath,/)
569 endif
570 endif
571 LDFLAGS := $(LDFLAGS_OPENSSL_PKG_CONFIG) $(LDFLAGS)
572 else
573 LIBS_SECURE = $(OPENSSL_LIBS)
574 ifeq ($(OPENSSL_REQUIRES_DL),true)
575 LIBS_SECURE += dl
576 PC_LIBS_SECURE = $(addprefix -l, $(LIBS_SECURE))
577 endif
578 endif
579 else
580 ifeq ($(HAS_EMBEDDED_OPENSSL_ALPN),true)
581 USE_SYSTEM_OPENSSL = false
582 OPENSSL_DEP = $(LIBDIR)/$(CONFIG)/openssl/libssl.a
583 OPENSSL_MERGE_LIBS += $(LIBDIR)/$(CONFIG)/openssl/libssl.a $(LIBDIR)/$(CONFIG)/openssl/libcrypto.a
584 # need to prefix these to ensure overriding system libraries
585 CPPFLAGS := -Ithird_party/openssl/include $(CPPFLAGS)
586 LDFLAGS := -L$(LIBDIR)/$(CONFIG)/openssl $(LDFLAGS)
587 ifeq ($(OPENSSL_REQUIRES_DL),true)
588 LIBS_SECURE = dl
589 endif
590 else
591 ifeq ($(HAS_SYSTEM_OPENSSL_NPN),true)
592 USE_SYSTEM_OPENSSL = true
593 CPPFLAGS += -DTSI_OPENSSL_ALPN_SUPPORT=0
594 LIBS_SECURE = $(OPENSSL_LIBS)
595 ifeq ($(OPENSSL_REQUIRES_DL),true)
596 LIBS_SECURE += dl
597 endif
598 else
599 NO_SECURE = true
600 endif
601 endif
602 endif
nnoble69ac39f2014-12-12 15:43:38 -0800603
Craig Tiller841c8802015-09-10 13:06:37 -0700604 ifeq ($(OPENSSL_PKG_CONFIG),true)
605 LDLIBS_SECURE += $(shell $(PKG_CONFIG) --libs-only-l openssl)
606 else
607 LDLIBS_SECURE += $(addprefix -l, $(LIBS_SECURE))
608 endif
nnoble5b7f32a2014-12-22 08:12:44 -0800609
Craig Tiller841c8802015-09-10 13:06:37 -0700610 # grpc .pc file
611 PC_NAME = gRPC
612 PC_DESCRIPTION = high performance general RPC framework
613 PC_CFLAGS =
614 PC_REQUIRES_PRIVATE = $(PC_REQUIRES_GRPC) $(PC_REQUIRES_SECURE)
615 PC_LIBS_PRIVATE = $(PC_LIBS_GRPC) $(PC_LIBS_SECURE)
616 PC_LIB = -lgrpc
617 GRPC_PC_FILE := $(PC_TEMPLATE)
murgatroid998faab232015-06-30 17:24:21 -0700618
Craig Tiller841c8802015-09-10 13:06:37 -0700619 # gprc_unsecure .pc file
620 PC_NAME = gRPC unsecure
621 PC_DESCRIPTION = high performance general RPC framework without SSL
622 PC_CFLAGS =
623 PC_REQUIRES_PRIVATE = $(PC_REQUIRES_GRPC)
624 PC_LIBS_PRIVATE = $(PC_LIBS_GRPC)
625 PC_LIB = -lgrpc
626 GRPC_UNSECURE_PC_FILE := $(PC_TEMPLATE)
murgatroid998faab232015-06-30 17:24:21 -0700627
Craig Tiller841c8802015-09-10 13:06:37 -0700628 # gprc_zookeeper .pc file
629 PC_NAME = gRPC zookeeper
630 PC_DESCRIPTION = gRPC's zookeeper plugin
631 PC_CFLAGS =
632 PC_REQUIRES_PRIVATE =
633 PC_LIBS_PRIVATE = -lzookeeper_mt
634 GRPC_ZOOKEEPER_PC_FILE := $(PC_TEMPLATE)
Hongwei Wanga8cc4392015-07-16 17:37:47 -0700635
Craig Tiller841c8802015-09-10 13:06:37 -0700636 PROTOBUF_PKG_CONFIG = false
murgatroid99da7a9942015-06-29 14:57:37 -0700637
Craig Tiller841c8802015-09-10 13:06:37 -0700638 PC_REQUIRES_GRPCXX =
639 PC_LIBS_GRPCXX =
murgatroid998faab232015-06-30 17:24:21 -0700640
Craig Tiller841c8802015-09-10 13:06:37 -0700641 CPPFLAGS := -Ithird_party/googletest/include $(CPPFLAGS)
Craig Tiller16f6dac2015-08-24 17:00:04 -0700642
Craig Tiller841c8802015-09-10 13:06:37 -0700643 ifeq ($(HAS_SYSTEM_PROTOBUF),true)
644 ifeq ($(HAS_PKG_CONFIG),true)
645 PROTOBUF_PKG_CONFIG = true
646 PC_REQUIRES_GRPCXX = protobuf
647 CPPFLAGS := $(shell $(PKG_CONFIG) --cflags protobuf) $(CPPFLAGS)
648 LDFLAGS_PROTOBUF_PKG_CONFIG = $(shell $(PKG_CONFIG) --libs-only-L protobuf)
649 ifeq ($(SYSTEM),Linux)
650 ifneq ($(LDFLAGS_PROTOBUF_PKG_CONFIG),)
651 LDFLAGS_PROTOBUF_PKG_CONFIG += $(shell $(PKG_CONFIG) --libs-only-L protobuf | sed s/L/Wl,-rpath,/)
652 endif
653 endif
654 else
655 PC_LIBS_GRPCXX = -lprotobuf
656 endif
657 else
658 ifeq ($(HAS_EMBEDDED_PROTOBUF),true)
659 PROTOBUF_DEP = $(LIBDIR)/$(CONFIG)/protobuf/libprotobuf.a
660 CPPFLAGS := -Ithird_party/protobuf/src $(CPPFLAGS)
661 LDFLAGS := -L$(LIBDIR)/$(CONFIG)/protobuf $(LDFLAGS)
662 PROTOC = $(BINDIR)/$(CONFIG)/protobuf/protoc
663 else
664 NO_PROTOBUF = true
665 endif
666 endif
Nicolas Noble53830622015-02-12 16:56:38 -0800667
Craig Tiller841c8802015-09-10 13:06:37 -0700668 LIBS_PROTOBUF = protobuf
669 LIBS_PROTOC = protoc protobuf
Nicolas Noble53830622015-02-12 16:56:38 -0800670
Craig Tiller841c8802015-09-10 13:06:37 -0700671 HOST_LDLIBS_PROTOC += $(addprefix -l, $(LIBS_PROTOC))
Nicolas Noble53830622015-02-12 16:56:38 -0800672
Craig Tiller841c8802015-09-10 13:06:37 -0700673 ifeq ($(PROTOBUF_PKG_CONFIG),true)
674 LDLIBS_PROTOBUF += $(shell $(PKG_CONFIG) --libs-only-l protobuf)
675 else
676 LDLIBS_PROTOBUF += $(addprefix -l, $(LIBS_PROTOBUF))
677 endif
murgatroid9924e2f4a2015-06-29 11:12:01 -0700678
Craig Tiller841c8802015-09-10 13:06:37 -0700679 # grpc++ .pc file
680 PC_NAME = gRPC++
681 PC_DESCRIPTION = C++ wrapper for gRPC
682 PC_CFLAGS =
683 PC_REQUIRES_PRIVATE = grpc $(PC_REQUIRES_GRPCXX)
684 PC_LIBS_PRIVATE = $(PC_LIBS_GRPCXX)
685 PC_LIB = -lgrpc++
686 GRPCXX_PC_FILE := $(PC_TEMPLATE)
murgatroid998faab232015-06-30 17:24:21 -0700687
Craig Tiller841c8802015-09-10 13:06:37 -0700688 # grpc++_unsecure .pc file
689 PC_NAME = gRPC++ unsecure
690 PC_DESCRIPTION = C++ wrapper for gRPC without SSL
691 PC_CFLAGS =
692 PC_REQUIRES_PRIVATE = grpc_unsecure $(PC_REQUIRES_GRPCXX)
693 PC_LIBS_PRIVATE = $(PC_LIBS_GRPCXX)
694 PC_LIB = -lgrpc++
695 GRPCXX_UNSECURE_PC_FILE := $(PC_TEMPLATE)
murgatroid998faab232015-06-30 17:24:21 -0700696
Craig Tiller841c8802015-09-10 13:06:37 -0700697 ifeq ($(MAKECMDGOALS),clean)
698 NO_DEPS = true
699 endif
nnoble69ac39f2014-12-12 15:43:38 -0800700
Craig Tiller841c8802015-09-10 13:06:37 -0700701 INSTALL_OK = false
702 ifeq ($(HAS_VALID_PROTOC),true)
703 ifeq ($(HAS_SYSTEM_PROTOBUF_VERIFY),true)
704 INSTALL_OK = true
705 endif
706 endif
Nicolas "Pixel" Noble98ab9982015-02-21 04:22:16 +0100707
Craig Tiller841c8802015-09-10 13:06:37 -0700708 .SECONDARY = %.pb.h %.pb.cc
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800709
Craig Tiller841c8802015-09-10 13:06:37 -0700710 PROTOC_PLUGINS =\
711 % for tgt in targets:
712 % if tgt.build == 'protoc':
713 $(BINDIR)/$(CONFIG)/${tgt.name}\
714 % endif
715 % endfor
Craig Tillerf58b9ef2015-01-15 09:09:12 -0800716
Craig Tiller841c8802015-09-10 13:06:37 -0700717 ifeq ($(DEP_MISSING),)
718 all: static shared plugins\
719 % for tgt in targets:
720 % if tgt.build == 'all':
721 $(BINDIR)/$(CONFIG)/${tgt.name}\
722 % endif
723 % endfor
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800724
Craig Tiller841c8802015-09-10 13:06:37 -0700725 dep_error:
726 @echo "You shouldn't see this message - all of your dependencies are correct."
727 else
728 all: dep_error git_update stop
nnoble69ac39f2014-12-12 15:43:38 -0800729
Craig Tiller841c8802015-09-10 13:06:37 -0700730 dep_error:
731 @echo
732 @echo "DEPENDENCY ERROR"
733 @echo
734 @echo "You are missing system dependencies that are essential to build grpc,"
735 @echo "and the third_party directory doesn't have them:"
736 @echo
737 @echo " $(DEP_MISSING)"
738 @echo
739 @echo "Installing the development packages for your system will solve"
740 @echo "this issue. Please consult INSTALL to get more information."
741 @echo
742 @echo "If you need information about why these tests failed, run:"
743 @echo
744 @echo " make run_dep_checks"
745 @echo
746 endif
nnoble69ac39f2014-12-12 15:43:38 -0800747
Craig Tiller841c8802015-09-10 13:06:37 -0700748 git_update:
749 ifeq ($(IS_GIT_FOLDER),true)
750 @echo "Additionally, since you are in a git clone, you can download the"
751 @echo "missing dependencies in third_party by running the following command:"
752 @echo
753 @echo " git submodule update --init"
754 @echo
755 endif
nnoble69ac39f2014-12-12 15:43:38 -0800756
Craig Tiller841c8802015-09-10 13:06:37 -0700757 openssl_dep_error: openssl_dep_message git_update stop
nnoble69ac39f2014-12-12 15:43:38 -0800758
Craig Tiller841c8802015-09-10 13:06:37 -0700759 protobuf_dep_error: protobuf_dep_message git_update stop
Nicolas Noble53830622015-02-12 16:56:38 -0800760
Craig Tiller841c8802015-09-10 13:06:37 -0700761 protoc_dep_error: protoc_dep_message git_update stop
Nicolas Noble53830622015-02-12 16:56:38 -0800762
Craig Tiller841c8802015-09-10 13:06:37 -0700763 openssl_dep_message:
764 @echo
765 @echo "DEPENDENCY ERROR"
766 @echo
767 @echo "The target you are trying to run requires OpenSSL."
768 @echo "Your system doesn't have it, and neither does the third_party directory."
769 @echo
770 @echo "Please consult INSTALL to get more information."
771 @echo
772 @echo "If you need information about why these tests failed, run:"
773 @echo
774 @echo " make run_dep_checks"
775 @echo
nnoble69ac39f2014-12-12 15:43:38 -0800776
Craig Tiller841c8802015-09-10 13:06:37 -0700777 protobuf_dep_message:
778 @echo
779 @echo "DEPENDENCY ERROR"
780 @echo
781 @echo "The target you are trying to run requires protobuf 3.0.0+"
782 @echo "Your system doesn't have it, and neither does the third_party directory."
783 @echo
784 @echo "Please consult INSTALL to get more information."
785 @echo
786 @echo "If you need information about why these tests failed, run:"
787 @echo
788 @echo " make run_dep_checks"
789 @echo
Nicolas Noble53830622015-02-12 16:56:38 -0800790
Craig Tiller841c8802015-09-10 13:06:37 -0700791 protoc_dep_message:
792 @echo
793 @echo "DEPENDENCY ERROR"
794 @echo
795 @echo "The target you are trying to run requires protobuf-compiler 3.0.0+"
796 @echo "Your system doesn't have it, and neither does the third_party directory."
797 @echo
798 @echo "Please consult INSTALL to get more information."
799 @echo
800 @echo "If you need information about why these tests failed, run:"
801 @echo
802 @echo " make run_dep_checks"
803 @echo
Nicolas Noble53830622015-02-12 16:56:38 -0800804
Craig Tiller841c8802015-09-10 13:06:37 -0700805 systemtap_dep_error:
806 @echo
807 @echo "DEPENDENCY ERROR"
808 @echo
809 @echo "Under the '$(CONFIG)' configutation, the target you are trying "
810 @echo "to build requires systemtap 2.7+ (on Linux) or dtrace (on other "
811 @echo "platforms such as Solaris and *BSD). "
812 @echo
813 @echo "Please consult INSTALL to get more information."
814 @echo
David Garcia Quintas8954e902015-04-29 09:46:33 -0700815
Craig Tiller841c8802015-09-10 13:06:37 -0700816 stop:
817 @false
nnoble69ac39f2014-12-12 15:43:38 -0800818
Craig Tiller841c8802015-09-10 13:06:37 -0700819 % for tgt in targets:
820 ${tgt.name}: $(BINDIR)/$(CONFIG)/${tgt.name}
821 % endfor
ctiller09cb6d52014-12-19 17:38:22 -0800822
Craig Tiller841c8802015-09-10 13:06:37 -0700823 run_dep_checks:
824 $(OPENSSL_ALPN_CHECK_CMD) || true
825 $(OPENSSL_NPN_CHECK_CMD) || true
826 $(ZLIB_CHECK_CMD) || true
827 $(PERFTOOLS_CHECK_CMD) || true
828 $(PROTOBUF_CHECK_CMD) || true
829 $(PROTOC_CHECK_VERSION_CMD) || true
830 $(ZOOKEEPER_CHECK_CMD) || true
nnoble69ac39f2014-12-12 15:43:38 -0800831
Craig Tiller841c8802015-09-10 13:06:37 -0700832 $(LIBDIR)/$(CONFIG)/zlib/libz.a:
833 $(E) "[MAKE] Building zlib"
834 $(Q)(cd third_party/zlib ; CC="$(CC)" CFLAGS="$(PIC_CPPFLAGS) -fvisibility=hidden $(CPPFLAGS_$(CONFIG)) $(ZLIB_CFLAGS_EXTRA)" ./configure --static)
835 $(Q)$(MAKE) -C third_party/zlib clean
836 $(Q)$(MAKE) -C third_party/zlib
837 $(Q)mkdir -p $(LIBDIR)/$(CONFIG)/zlib
838 $(Q)cp third_party/zlib/libz.a $(LIBDIR)/$(CONFIG)/zlib
nnoble69ac39f2014-12-12 15:43:38 -0800839
Craig Tiller841c8802015-09-10 13:06:37 -0700840 $(LIBDIR)/$(CONFIG)/openssl/libssl.a:
841 $(E) "[MAKE] Building openssl for $(SYSTEM)"
842 ifeq ($(SYSTEM),Darwin)
843 $(Q)(cd third_party/openssl ; CC="$(CC) $(PIC_CPPFLAGS) -fvisibility=hidden $(CPPFLAGS_$(CONFIG)) $(OPENSSL_CFLAGS_$(CONFIG)) $(OPENSSL_CFLAGS_EXTRA)" ./Configure darwin64-x86_64-cc)
844 else
845 ifeq ($(SYSTEM),MINGW32)
846 @echo "We currently don't have a good way to compile OpenSSL in-place under msys."
847 @echo "Please provide a OpenSSL in your mingw32 system."
848 @echo
849 @echo "Note that you can find a compatible version of the libraries here:"
850 @echo
851 @echo "http://slproweb.com/products/Win32OpenSSL.html"
852 @echo
853 @echo "If you decide to install that one, take the full version. The light"
854 @echo "version only contains compiled DLLs, without the development files."
855 @echo
856 @echo "When installing, chose to copy the OpenSSL dlls to the OpenSSL binaries"
857 @echo "directory. This way we'll link to them directly."
858 @echo
859 @echo "You can then re-start the build the following way:"
860 @echo
861 @echo " CPPFLAGS=-I/c/OpenSSL-Win64/include LDFLAGS=-L/c/OpenSSL-Win64 make"
862 @false
863 else
864 $(Q)(cd third_party/openssl ; CC="$(CC) $(PIC_CPPFLAGS) -fvisibility=hidden $(CPPFLAGS_$(CONFIG)) $(OPENSSL_CFLAGS_$(CONFIG)) $(OPENSSL_CFLAGS_EXTRA)" ./config no-asm $(OPENSSL_CONFIG_$(CONFIG)))
865 endif
866 endif
867 $(Q)$(MAKE) -j 1 -C third_party/openssl clean
868 $(Q)(unset CPPFLAGS; $(MAKE) -j 1 -C third_party/openssl build_crypto build_ssl)
869 $(Q)mkdir -p $(LIBDIR)/$(CONFIG)/openssl
870 $(Q)cp third_party/openssl/libssl.a third_party/openssl/libcrypto.a $(LIBDIR)/$(CONFIG)/openssl
nnoble69ac39f2014-12-12 15:43:38 -0800871
Craig Tiller841c8802015-09-10 13:06:37 -0700872 third_party/protobuf/configure:
873 $(E) "[AUTOGEN] Preparing protobuf"
874 $(Q)(cd third_party/protobuf ; autoreconf -f -i -Wall,no-obsolete)
Nicolas Noble53830622015-02-12 16:56:38 -0800875
Craig Tiller841c8802015-09-10 13:06:37 -0700876 $(LIBDIR)/$(CONFIG)/protobuf/libprotobuf.a: third_party/protobuf/configure
877 $(E) "[MAKE] Building protobuf"
878 $(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)
879 $(Q)$(MAKE) -C third_party/protobuf clean
880 $(Q)$(MAKE) -C third_party/protobuf
881 $(Q)mkdir -p $(LIBDIR)/$(CONFIG)/protobuf
882 $(Q)mkdir -p $(BINDIR)/$(CONFIG)/protobuf
883 $(Q)cp third_party/protobuf/src/.libs/libprotoc.a $(LIBDIR)/$(CONFIG)/protobuf
884 $(Q)cp third_party/protobuf/src/.libs/libprotobuf.a $(LIBDIR)/$(CONFIG)/protobuf
885 $(Q)cp third_party/protobuf/src/protoc $(BINDIR)/$(CONFIG)/protobuf
Nicolas Noble53830622015-02-12 16:56:38 -0800886
Craig Tiller841c8802015-09-10 13:06:37 -0700887 static: static_c static_cxx
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800888
Craig Tiller841c8802015-09-10 13:06:37 -0700889 static_c: pc_c pc_c_unsecure cache.mk pc_gpr pc_c_zookeeper\
890 % for lib in libs:
891 % if lib.build == 'all' and lib.language == 'c' and not lib.get('external_deps', None):
892 $(LIBDIR)/$(CONFIG)/lib${lib.name}.a\
893 % endif
894 % endfor
895 static_zookeeper_libs
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800896
897
Craig Tiller841c8802015-09-10 13:06:37 -0700898 static_cxx: pc_cxx pc_cxx_unsecure pc_gpr cache.mk \
899 % for lib in libs:
900 % if lib.build == 'all' and lib.language == 'c++':
901 $(LIBDIR)/$(CONFIG)/lib${lib.name}.a\
902 % endif
903 % endfor
nnoble29e1d292014-12-01 10:27:40 -0800904
905
Craig Tiller841c8802015-09-10 13:06:37 -0700906 shared: shared_c shared_cxx
nnoble29e1d292014-12-01 10:27:40 -0800907
Craig Tiller841c8802015-09-10 13:06:37 -0700908 shared_c: pc_c pc_c_unsecure pc_gpr cache.mk pc_c_zookeeper\
909 % for lib in libs:
910 % if lib.build == 'all' and lib.language == 'c' and not lib.get('external_deps', None):
911 $(LIBDIR)/$(CONFIG)/lib${lib.name}.$(SHARED_EXT)\
912 % endif
913 % endfor
914 shared_zookeeper_libs
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800915
Craig Tiller841c8802015-09-10 13:06:37 -0700916 shared_cxx: pc_cxx pc_cxx_unsecure cache.mk\
917 % for lib in libs:
918 % if lib.build == 'all' and lib.language == 'c++':
919 $(LIBDIR)/$(CONFIG)/lib${lib.name}.$(SHARED_EXT)\
920 % endif
921 % endfor
nnoble29e1d292014-12-01 10:27:40 -0800922
923
Craig Tiller841c8802015-09-10 13:06:37 -0700924 shared_csharp: shared_c \
925 % for lib in libs:
926 % if lib.build == 'all' and lib.language == 'csharp':
927 $(LIBDIR)/$(CONFIG)/lib${lib.name}.$(SHARED_EXT)\
928 % endif
929 % endfor
Jan Tattermusch2ec0b3e2015-02-18 15:03:12 -0800930
Craig Tiller841c8802015-09-10 13:06:37 -0700931 ifeq ($(HAS_ZOOKEEPER),true)
932 static_zookeeper_libs:\
933 % for lib in libs:
934 % if lib.build == 'all' and lib.language == 'c' and 'zookeeper' in lib.get('external_deps', []):
935 $(LIBDIR)/$(CONFIG)/lib${lib.name}.a\
936 % endif
937 % endfor
Hongwei Wanga8cc4392015-07-16 17:37:47 -0700938
Craig Tiller841c8802015-09-10 13:06:37 -0700939 shared_zookeeper_libs:\
940 % for lib in libs:
941 % if lib.build == 'all' and lib.language == 'c' and 'zookeeper' in lib.get('external_deps', []):
942 $(LIBDIR)/$(CONFIG)/lib${lib.name}.$(SHARED_EXT)\
943 % endif
944 % endfor
Hongwei Wanga8cc4392015-07-16 17:37:47 -0700945
Craig Tiller841c8802015-09-10 13:06:37 -0700946 else
Hongwei Wanga8cc4392015-07-16 17:37:47 -0700947
Craig Tiller841c8802015-09-10 13:06:37 -0700948 static_zookeeper_libs:
Hongwei Wanga8cc4392015-07-16 17:37:47 -0700949
Craig Tiller841c8802015-09-10 13:06:37 -0700950 shared_zookeeper_libs:
Hongwei Wanga8cc4392015-07-16 17:37:47 -0700951
Craig Tiller841c8802015-09-10 13:06:37 -0700952 endif
Hongwei Wanga8cc4392015-07-16 17:37:47 -0700953
Craig Tiller841c8802015-09-10 13:06:37 -0700954 grpc_csharp_ext: shared_csharp
Jan Tattermusch2ec0b3e2015-02-18 15:03:12 -0800955
Craig Tiller841c8802015-09-10 13:06:37 -0700956 plugins: $(PROTOC_PLUGINS)
Nicolas "Pixel" Noble522d7122015-02-19 01:28:02 +0100957
Craig Tiller841c8802015-09-10 13:06:37 -0700958 privatelibs: privatelibs_c privatelibs_cxx
nnoble29e1d292014-12-01 10:27:40 -0800959
Craig Tiller841c8802015-09-10 13:06:37 -0700960 privatelibs_c: \
961 % for lib in libs:
962 % if lib.build == 'private' and lib.language == 'c' and not lib.get('external_deps', None):
963 $(LIBDIR)/$(CONFIG)/lib${lib.name}.a\
964 % endif
965 % endfor
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800966
Craig Tiller841c8802015-09-10 13:06:37 -0700967 pc_gpr: $(LIBDIR)/$(CONFIG)/pkgconfig/gpr.pc
murgatroid998faab232015-06-30 17:24:21 -0700968
Craig Tiller841c8802015-09-10 13:06:37 -0700969 pc_c: $(LIBDIR)/$(CONFIG)/pkgconfig/grpc.pc
murgatroid998faab232015-06-30 17:24:21 -0700970
Craig Tiller841c8802015-09-10 13:06:37 -0700971 pc_c_unsecure: $(LIBDIR)/$(CONFIG)/pkgconfig/grpc_unsecure.pc
murgatroid998faab232015-06-30 17:24:21 -0700972
Craig Tiller841c8802015-09-10 13:06:37 -0700973 ifeq ($(HAS_ZOOKEEPER),true)
974 pc_c_zookeeper: $(LIBDIR)/$(CONFIG)/pkgconfig/grpc_zookeeper.pc
975 else
976 pc_c_zookeeper:
977 endif
Hongwei Wanga3780a82015-07-17 15:27:18 -0700978
Craig Tiller841c8802015-09-10 13:06:37 -0700979 pc_cxx: $(LIBDIR)/$(CONFIG)/pkgconfig/grpc++.pc
murgatroid998faab232015-06-30 17:24:21 -0700980
Craig Tiller841c8802015-09-10 13:06:37 -0700981 pc_cxx_unsecure: $(LIBDIR)/$(CONFIG)/pkgconfig/grpc++_unsecure.pc
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800982
Craig Tiller841c8802015-09-10 13:06:37 -0700983 privatelibs_cxx: \
984 % for lib in libs:
985 % if lib.build == 'private' and lib.language == 'c++' and not lib.get('external_deps', None):
986 $(LIBDIR)/$(CONFIG)/lib${lib.name}.a\
987 % endif
988 % endfor
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800989
990
Craig Tiller841c8802015-09-10 13:06:37 -0700991 ifeq ($(HAS_ZOOKEEPER),true)
992 privatelibs_zookeeper: \
993 % for lib in libs:
994 % if lib.build == 'private' and lib.language == 'c++' and zookeeper in lib.get('external_deps', []):
995 $(LIBDIR)/$(CONFIG)/lib${lib.name}.a\
996 % endif
997 % endfor
Hongwei Wang8e04d412015-07-31 15:12:51 -0700998
Craig Tiller841c8802015-09-10 13:06:37 -0700999 else
1000 privatelibs_zookeeper:
1001 endif
Hongwei Wang8e04d412015-07-31 15:12:51 -07001002
1003
Craig Tiller841c8802015-09-10 13:06:37 -07001004 buildtests: buildtests_c buildtests_cxx buildtests_zookeeper
nnoble29e1d292014-12-01 10:27:40 -08001005
Craig Tiller841c8802015-09-10 13:06:37 -07001006 buildtests_c: privatelibs_c\
1007 % for tgt in targets:
1008 % if tgt.build == 'test' and not tgt.language == 'c++' and not tgt.get('external_deps', None):
1009 $(BINDIR)/$(CONFIG)/${tgt.name}\
1010 % endif
1011 % endfor
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001012
1013
Craig Tiller841c8802015-09-10 13:06:37 -07001014 buildtests_cxx: buildtests_zookeeper privatelibs_cxx\
1015 % for tgt in targets:
1016 % if tgt.build == 'test' and tgt.language == 'c++' and not tgt.get('external_deps', None):
1017 $(BINDIR)/$(CONFIG)/${tgt.name}\
1018 % endif
1019 % endfor
nnoble29e1d292014-12-01 10:27:40 -08001020
1021
Craig Tiller841c8802015-09-10 13:06:37 -07001022 ifeq ($(HAS_ZOOKEEPER),true)
1023 buildtests_zookeeper: privatelibs_zookeeper\
1024 % for tgt in targets:
1025 % if tgt.build == 'test' and tgt.language == 'c++' and 'zookeeper' in tgt.get('external_deps', []):
1026 $(BINDIR)/$(CONFIG)/${tgt.name}\
1027 % endif
1028 % endfor
nnoble29e1d292014-12-01 10:27:40 -08001029
Craig Tiller841c8802015-09-10 13:06:37 -07001030 else
1031 buildtests_zookeeper:
1032 endif
Hongwei Wang8e04d412015-07-31 15:12:51 -07001033
1034
Craig Tiller841c8802015-09-10 13:06:37 -07001035 test: test_c test_cxx test_zookeeper
Hongwei Wang8e04d412015-07-31 15:12:51 -07001036
Craig Tiller841c8802015-09-10 13:06:37 -07001037 flaky_test: flaky_test_c flaky_test_cxx flaky_test_zookeeper
Nicolas "Pixel" Noble4251d562015-05-22 19:43:39 +02001038
Craig Tiller841c8802015-09-10 13:06:37 -07001039 test_c: buildtests_c
1040 % for tgt in targets:
1041 % 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):
1042 $(E) "[RUN] Testing ${tgt.name}"
1043 $(Q) $(BINDIR)/$(CONFIG)/${tgt.name} || ( echo test ${tgt.name} failed ; exit 1 )
1044 % endif
1045 % endfor
Nicolas "Pixel" Noble4251d562015-05-22 19:43:39 +02001046
1047
Craig Tiller841c8802015-09-10 13:06:37 -07001048 flaky_test_c: buildtests_c
1049 % for tgt in targets:
1050 % 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):
1051 $(E) "[RUN] Testing ${tgt.name}"
1052 $(Q) $(BINDIR)/$(CONFIG)/${tgt.name} || ( echo test ${tgt.name} failed ; exit 1 )
1053 % endif
1054 % endfor
nnoble29e1d292014-12-01 10:27:40 -08001055
1056
Craig Tiller841c8802015-09-10 13:06:37 -07001057 test_cxx: test_zookeeper buildtests_cxx
1058 % for tgt in targets:
1059 % 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):
1060 $(E) "[RUN] Testing ${tgt.name}"
1061 $(Q) $(BINDIR)/$(CONFIG)/${tgt.name} || ( echo test ${tgt.name} failed ; exit 1 )
1062 % endif
1063 % endfor
Nicolas "Pixel" Noble4251d562015-05-22 19:43:39 +02001064
1065
Craig Tiller841c8802015-09-10 13:06:37 -07001066 flaky_test_cxx: buildtests_cxx
1067 % for tgt in targets:
1068 % 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):
1069 $(E) "[RUN] Testing ${tgt.name}"
1070 $(Q) $(BINDIR)/$(CONFIG)/${tgt.name} || ( echo test ${tgt.name} failed ; exit 1 )
1071 % endif
1072 % endfor
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001073
1074
Craig Tiller841c8802015-09-10 13:06:37 -07001075 ifeq ($(HAS_ZOOKEEPER),true)
1076 test_zookeeper: buildtests_zookeeper
1077 % for tgt in targets:
1078 % 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', []):
1079 $(E) "[RUN] Testing ${tgt.name}"
1080 $(Q) $(BINDIR)/$(CONFIG)/${tgt.name} || ( echo test ${tgt.name} failed ; exit 1 )
1081 % endif
1082 % endfor
Hongwei Wang8e04d412015-07-31 15:12:51 -07001083
1084
Craig Tiller841c8802015-09-10 13:06:37 -07001085 flaky_test_zookeeper: buildtests_zookeeper
1086 % for tgt in targets:
1087 % 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', []):
1088 $(E) "[RUN] Testing ${tgt.name}"
1089 $(Q) $(BINDIR)/$(CONFIG)/${tgt.name} || ( echo test ${tgt.name} failed ; exit 1 )
1090 % endif
1091 % endfor
Hongwei Wang8e04d412015-07-31 15:12:51 -07001092
Craig Tiller841c8802015-09-10 13:06:37 -07001093 else
1094 test_zookeeper:
1095 flaky_test_zookeeper:
1096 endif
Hongwei Wang8e04d412015-07-31 15:12:51 -07001097
1098
Craig Tiller841c8802015-09-10 13:06:37 -07001099 test_python: static_c
1100 $(E) "[RUN] Testing python code"
1101 $(Q) tools/run_tests/run_tests.py -lpython -c$(CONFIG)
Nicolas "Pixel" Noble051a28f2015-03-17 22:54:54 +01001102
1103
Craig Tiller841c8802015-09-10 13:06:37 -07001104 tools: tools_c tools_cxx
Craig Tiller7552f0f2015-06-19 17:46:20 -07001105
1106
Craig Tiller841c8802015-09-10 13:06:37 -07001107 tools_c: privatelibs_c\
1108 % for tgt in targets:
1109 % if tgt.build == 'tool' and not tgt.language=='c++':
1110 $(BINDIR)/$(CONFIG)/${tgt.name}\
1111 % endif
1112 % endfor
Craig Tiller7552f0f2015-06-19 17:46:20 -07001113
1114
Craig Tiller841c8802015-09-10 13:06:37 -07001115 tools_cxx: privatelibs_cxx\
1116 % for tgt in targets:
1117 % if tgt.build == 'tool' and tgt.language=='c++':
1118 $(BINDIR)/$(CONFIG)/${tgt.name}\
1119 % endif
1120 % endfor
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001121
1122
Craig Tiller841c8802015-09-10 13:06:37 -07001123 buildbenchmarks: privatelibs\
1124 % for tgt in targets:
1125 % if tgt.build == 'benchmark':
1126 $(BINDIR)/$(CONFIG)/${tgt.name}\
1127 % endif
1128 % endfor
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001129
1130
Craig Tiller841c8802015-09-10 13:06:37 -07001131 benchmarks: buildbenchmarks
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001132
Craig Tiller841c8802015-09-10 13:06:37 -07001133 strip: strip-static strip-shared
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001134
Craig Tiller841c8802015-09-10 13:06:37 -07001135 strip-static: strip-static_c strip-static_cxx
nnoble20e2e3f2014-12-16 15:37:57 -08001136
Craig Tiller841c8802015-09-10 13:06:37 -07001137 strip-shared: strip-shared_c strip-shared_cxx
nnoble20e2e3f2014-12-16 15:37:57 -08001138
Nicolas Noble047b7272015-01-16 13:55:05 -08001139
Craig Tiller841c8802015-09-10 13:06:37 -07001140 # TODO(nnoble): the strip target is stripping in-place, instead
1141 # of copying files in a temporary folder.
1142 # This prevents proper debugging after running make install.
Nicolas Noble047b7272015-01-16 13:55:05 -08001143
Craig Tiller841c8802015-09-10 13:06:37 -07001144 strip-static_c: static_c
1145 ifeq ($(CONFIG),opt)
1146 % for lib in libs:
1147 % if lib.language == "c":
1148 % if lib.build == "all":
1149 % if not lib.get('external_deps', None):
1150 $(E) "[STRIP] Stripping lib${lib.name}.a"
1151 $(Q) $(STRIP) $(LIBDIR)/$(CONFIG)/lib${lib.name}.a
1152 % endif
1153 % endif
1154 % endif
1155 % endfor
1156 ifeq ($(HAS_ZOOKEEPER),true)
1157 % for lib in libs:
1158 % if lib.language == "c":
1159 % if lib.build == "all":
1160 % if 'zookeeper' in lib.get('external_deps', []):
1161 $(E) "[STRIP] Stripping lib${lib.name}.a"
1162 $(Q) $(STRIP) $(LIBDIR)/$(CONFIG)/lib${lib.name}.a
1163 % endif
1164 % endif
1165 % endif
1166 % endfor
1167 endif
1168 endif
nnoble85a49262014-12-08 18:14:03 -08001169
Craig Tiller841c8802015-09-10 13:06:37 -07001170 strip-static_cxx: static_cxx
1171 ifeq ($(CONFIG),opt)
1172 % for lib in libs:
1173 % if lib.language == "c++":
1174 % if lib.build == "all":
1175 $(E) "[STRIP] Stripping lib${lib.name}.a"
1176 $(Q) $(STRIP) $(LIBDIR)/$(CONFIG)/lib${lib.name}.a
1177 % endif
1178 % endif
1179 % endfor
1180 endif
Nicolas "Pixel" Noble4ef9b862015-08-14 19:35:24 +02001181
Craig Tiller841c8802015-09-10 13:06:37 -07001182 strip-shared_c: shared_c
1183 ifeq ($(CONFIG),opt)
1184 % for lib in libs:
1185 % if lib.language == "c":
1186 % if lib.build == "all":
1187 % if not lib.get('external_deps', None):
1188 $(E) "[STRIP] Stripping lib${lib.name}.so"
1189 $(Q) $(STRIP) $(LIBDIR)/$(CONFIG)/lib${lib.name}.$(SHARED_EXT)
1190 % endif
1191 % endif
1192 % endif
1193 % endfor
1194 ifeq ($(HAS_ZOOKEEPER),true)
1195 % for lib in libs:
1196 % if lib.language == "c":
1197 % if lib.build == "all":
1198 % if 'zookeeper' in lib.get('external_deps', []):
1199 $(E) "[STRIP] Stripping lib${lib.name}.so"
1200 $(Q) $(STRIP) $(LIBDIR)/$(CONFIG)/lib${lib.name}.$(SHARED_EXT)
1201 % endif
1202 % endif
1203 % endif
1204 % endfor
1205 endif
1206 endif
nnoble85a49262014-12-08 18:14:03 -08001207
Craig Tiller841c8802015-09-10 13:06:37 -07001208 strip-shared_cxx: shared_cxx
1209 ifeq ($(CONFIG),opt)
1210 % for lib in libs:
1211 % if lib.language == "c++":
1212 % if lib.build == "all":
1213 $(E) "[STRIP] Stripping lib${lib.name}.so"
1214 $(Q) $(STRIP) $(LIBDIR)/$(CONFIG)/lib${lib.name}.$(SHARED_EXT)
1215 % endif
1216 % endif
1217 % endfor
1218 endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001219
Craig Tiller841c8802015-09-10 13:06:37 -07001220 strip-shared_csharp: shared_csharp
1221 ifeq ($(CONFIG),opt)
1222 % for lib in libs:
1223 % if lib.language == "csharp":
1224 % if lib.build == "all":
1225 $(E) "[STRIP] Stripping lib${lib.name}.so"
1226 $(Q) $(STRIP) $(LIBDIR)/$(CONFIG)/lib${lib.name}.$(SHARED_EXT)
1227 % endif
1228 % endif
1229 % endfor
1230 endif
Jan Tattermusch2ec0b3e2015-02-18 15:03:12 -08001231
Craig Tiller841c8802015-09-10 13:06:37 -07001232 cache.mk::
1233 $(E) "[MAKE] Generating $@"
1234 $(Q) echo "$(CACHE_MK)" | tr , '\n' >$@
murgatroid99aa521572015-07-10 14:49:12 -07001235
Craig Tiller841c8802015-09-10 13:06:37 -07001236 $(LIBDIR)/$(CONFIG)/pkgconfig/gpr.pc:
1237 $(E) "[MAKE] Generating $@"
1238 $(Q) mkdir -p $(@D)
1239 $(Q) echo "$(GPR_PC_FILE)" | tr , '\n' >$@
murgatroid998faab232015-06-30 17:24:21 -07001240
Craig Tiller841c8802015-09-10 13:06:37 -07001241 $(LIBDIR)/$(CONFIG)/pkgconfig/grpc.pc:
1242 $(E) "[MAKE] Generating $@"
1243 $(Q) mkdir -p $(@D)
1244 $(Q) echo "$(GRPC_PC_FILE)" | tr , '\n' >$@
murgatroid998faab232015-06-30 17:24:21 -07001245
Craig Tiller841c8802015-09-10 13:06:37 -07001246 $(LIBDIR)/$(CONFIG)/pkgconfig/grpc_unsecure.pc:
1247 $(E) "[MAKE] Generating $@"
1248 $(Q) mkdir -p $(@D)
1249 $(Q) echo "$(GRPC_UNSECURE_PC_FILE)" | tr , '\n' >$@
murgatroid998faab232015-06-30 17:24:21 -07001250
Craig Tiller841c8802015-09-10 13:06:37 -07001251 $(LIBDIR)/$(CONFIG)/pkgconfig/grpc_zookeeper.pc:
1252 $(E) "[MAKE] Generating $@"
1253 $(Q) mkdir -p $(@D)
1254 $(Q) echo -e "$(GRPC_ZOOKEEPER_PC_FILE)" >$@
Hongwei Wanga8cc4392015-07-16 17:37:47 -07001255
Craig Tiller841c8802015-09-10 13:06:37 -07001256 $(LIBDIR)/$(CONFIG)/pkgconfig/grpc++.pc:
1257 $(E) "[MAKE] Generating $@"
1258 $(Q) mkdir -p $(@D)
1259 $(Q) echo "$(GRPCXX_PC_FILE)" | tr , '\n' >$@
murgatroid998faab232015-06-30 17:24:21 -07001260
Craig Tiller841c8802015-09-10 13:06:37 -07001261 $(LIBDIR)/$(CONFIG)/pkgconfig/grpc++_unsecure.pc:
1262 $(E) "[MAKE] Generating $@"
1263 $(Q) mkdir -p $(@D)
1264 $(Q) echo "$(GRPCXX_UNSECURE_PC_FILE)" | tr , '\n' >$@
murgatroid998faab232015-06-30 17:24:21 -07001265
Craig Tiller841c8802015-09-10 13:06:37 -07001266 % for p in protos:
1267 ifeq ($(NO_PROTOC),true)
1268 $(GENDIR)/${p}.pb.cc: protoc_dep_error
1269 $(GENDIR)/${p}.grpc.pb.cc: protoc_dep_error
1270 else
1271 $(GENDIR)/${p}.pb.cc: ${p}.proto $(PROTOBUF_DEP) $(PROTOC_PLUGINS)
1272 $(E) "[PROTOC] Generating protobuf CC file from $<"
1273 $(Q) mkdir -p `dirname $@`
1274 $(Q) $(PROTOC) --cpp_out=$(GENDIR) $<
Nicolas "Pixel" Noble0caebbf2015-04-09 23:08:51 +02001275
Craig Tiller841c8802015-09-10 13:06:37 -07001276 $(GENDIR)/${p}.grpc.pb.cc: ${p}.proto $(PROTOBUF_DEP) $(PROTOC_PLUGINS)
1277 $(E) "[GRPC] Generating gRPC's protobuf service CC file from $<"
1278 $(Q) mkdir -p `dirname $@`
1279 $(Q) $(PROTOC) --grpc_out=$(GENDIR) --plugin=protoc-gen-grpc=$(BINDIR)/$(CONFIG)/grpc_cpp_plugin $<
1280 endif
nnoble72309c62014-12-12 11:42:26 -08001281
Craig Tiller841c8802015-09-10 13:06:37 -07001282 % endfor
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001283
Craig Tiller841c8802015-09-10 13:06:37 -07001284 ifeq ($(CONFIG),stapprof)
1285 src/core/profiling/stap_timers.c: $(GENDIR)/src/core/profiling/stap_probes.h
1286 ifeq ($(HAS_SYSTEMTAP),true)
1287 $(GENDIR)/src/core/profiling/stap_probes.h: src/core/profiling/stap_probes.d
1288 $(E) "[DTRACE] Compiling $<"
1289 $(Q) mkdir -p `dirname $@`
1290 $(Q) $(DTRACE) -C -h -s $< -o $@
1291 else
1292 $(GENDIR)/src/core/profiling/stap_probes.h: systemtap_dep_error stop
1293 endif
1294 endif
David Garcia Quintas611b7362015-04-27 15:49:31 -07001295
Craig Tiller841c8802015-09-10 13:06:37 -07001296 $(OBJDIR)/$(CONFIG)/%.o : %.c
1297 $(E) "[C] Compiling $<"
1298 $(Q) mkdir -p `dirname $@`
1299 $(Q) $(CC) $(CFLAGS) $(CPPFLAGS) -MMD -MF $(addsuffix .dep, $(basename $@)) -c -o $@ $<
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001300
Craig Tiller841c8802015-09-10 13:06:37 -07001301 $(OBJDIR)/$(CONFIG)/%.o : $(GENDIR)/%.pb.cc
1302 $(E) "[CXX] Compiling $<"
1303 $(Q) mkdir -p `dirname $@`
1304 $(Q) $(CXX) $(CXXFLAGS) $(CPPFLAGS) -MMD -MF $(addsuffix .dep, $(basename $@)) -c -o $@ $<
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001305
Craig Tiller841c8802015-09-10 13:06:37 -07001306 $(OBJDIR)/$(CONFIG)/src/compiler/%.o : src/compiler/%.cc
1307 $(E) "[HOSTCXX] Compiling $<"
1308 $(Q) mkdir -p `dirname $@`
1309 $(Q) $(HOST_CXX) $(HOST_CXXFLAGS) $(HOST_CPPFLAGS) -MMD -MF $(addsuffix .dep, $(basename $@)) -c -o $@ $<
nnoble72309c62014-12-12 11:42:26 -08001310
Craig Tiller841c8802015-09-10 13:06:37 -07001311 $(OBJDIR)/$(CONFIG)/%.o : %.cc
1312 $(E) "[CXX] Compiling $<"
1313 $(Q) mkdir -p `dirname $@`
1314 $(Q) $(CXX) $(CXXFLAGS) $(CPPFLAGS) -MMD -MF $(addsuffix .dep, $(basename $@)) -c -o $@ $<
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001315
Craig Tiller841c8802015-09-10 13:06:37 -07001316 install: install_c install_cxx install-plugins install-certs verify-install
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001317
Craig Tiller841c8802015-09-10 13:06:37 -07001318 install_c: install-headers_c install-static_c install-shared_c
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001319
Craig Tiller841c8802015-09-10 13:06:37 -07001320 install_cxx: install-headers_cxx install-static_cxx install-shared_cxx
nnoble85a49262014-12-08 18:14:03 -08001321
Craig Tiller841c8802015-09-10 13:06:37 -07001322 install_csharp: install-shared_csharp install_c
Jan Tattermusch2ec0b3e2015-02-18 15:03:12 -08001323
Craig Tiller841c8802015-09-10 13:06:37 -07001324 install_grpc_csharp_ext: install_csharp
Jan Tattermusch2ec0b3e2015-02-18 15:03:12 -08001325
Craig Tiller841c8802015-09-10 13:06:37 -07001326 install-headers: install-headers_c install-headers_cxx
nnoble85a49262014-12-08 18:14:03 -08001327
Craig Tiller841c8802015-09-10 13:06:37 -07001328 install-headers_c:
1329 $(E) "[INSTALL] Installing public C headers"
1330 $(Q) $(foreach h, $(PUBLIC_HEADERS_C), $(INSTALL) -d $(prefix)/$(dir $(h)) && ) exit 0 || exit 1
1331 $(Q) $(foreach h, $(PUBLIC_HEADERS_C), $(INSTALL) $(h) $(prefix)/$(h) && ) exit 0 || exit 1
nnoble85a49262014-12-08 18:14:03 -08001332
Craig Tiller841c8802015-09-10 13:06:37 -07001333 install-headers_cxx:
1334 $(E) "[INSTALL] Installing public C++ headers"
1335 $(Q) $(foreach h, $(PUBLIC_HEADERS_CXX), $(INSTALL) -d $(prefix)/$(dir $(h)) && ) exit 0 || exit 1
1336 $(Q) $(foreach h, $(PUBLIC_HEADERS_CXX), $(INSTALL) $(h) $(prefix)/$(h) && ) exit 0 || exit 1
nnoble85a49262014-12-08 18:14:03 -08001337
Craig Tiller841c8802015-09-10 13:06:37 -07001338 install-static: install-static_c install-static_cxx
nnoble85a49262014-12-08 18:14:03 -08001339
Craig Tiller841c8802015-09-10 13:06:37 -07001340 install-static_c: static_c strip-static_c install-pkg-config_c
1341 % for lib in libs:
1342 % if lib.language == "c":
1343 % if lib.build == "all":
1344 % if not lib.get('external_deps', None):
1345 $(E) "[INSTALL] Installing lib${lib.name}.a"
1346 $(Q) $(INSTALL) -d $(prefix)/lib
1347 $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/lib${lib.name}.a $(prefix)/lib/lib${lib.name}.a
1348 % endif
1349 % endif
1350 % endif
1351 % endfor
1352 ifeq ($(HAS_ZOOKEEPER),true)
1353 % for lib in libs:
1354 % if lib.language == "c":
1355 % if lib.build == "all":
1356 % if 'zookeeper' in lib.get('external_deps', []):
1357 $(E) "[INSTALL] Installing lib${lib.name}.a"
1358 $(Q) $(INSTALL) -d $(prefix)/lib
1359 $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/lib${lib.name}.a $(prefix)/lib/lib${lib.name}.a
1360 % endif
1361 % endif
1362 % endif
1363 % endfor
1364 endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001365
Craig Tiller841c8802015-09-10 13:06:37 -07001366 install-static_cxx: static_cxx strip-static_cxx install-pkg-config_cxx
1367 % for lib in libs:
1368 % if lib.language == "c++":
1369 % if lib.build == "all":
1370 $(E) "[INSTALL] Installing lib${lib.name}.a"
1371 $(Q) $(INSTALL) -d $(prefix)/lib
1372 $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/lib${lib.name}.a $(prefix)/lib/lib${lib.name}.a
1373 % endif
1374 % endif
1375 % endfor
nnoble85a49262014-12-08 18:14:03 -08001376
Craig Tiller841c8802015-09-10 13:06:37 -07001377 <%def name="install_shared(lang_filter)">\
1378 % for lib in libs:
1379 % if lib.language == lang_filter:
1380 % if lib.build == "all":
1381 % if not lib.get('external_deps', None):
1382 ifeq ($(SYSTEM),MINGW32)
1383 $(E) "[INSTALL] Installing ${lib.name}.$(SHARED_EXT)"
1384 $(Q) $(INSTALL) -d $(prefix)/lib
1385 $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/${lib.name}.$(SHARED_EXT) $(prefix)/lib/${lib.name}.$(SHARED_EXT)
1386 $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/lib${lib.name}-imp.a $(prefix)/lib/lib${lib.name}-imp.a
1387 else
1388 $(E) "[INSTALL] Installing lib${lib.name}.$(SHARED_EXT)"
1389 $(Q) $(INSTALL) -d $(prefix)/lib
1390 $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/lib${lib.name}.$(SHARED_EXT) $(prefix)/lib/lib${lib.name}.$(SHARED_EXT)
1391 ifneq ($(SYSTEM),Darwin)
1392 $(Q) ln -sf lib${lib.name}.$(SHARED_EXT) $(prefix)/lib/lib${lib.name}.so.${settings.version.major}
1393 $(Q) ln -sf lib${lib.name}.$(SHARED_EXT) $(prefix)/lib/lib${lib.name}.so
1394 endif
1395 endif
1396 % endif
1397 % endif
1398 % endif
1399 % endfor
1400 ifeq ($(HAS_ZOOKEEPER),true)
1401 % for lib in libs:
1402 % if lib.language == lang_filter:
1403 % if lib.build == "all":
1404 % if 'zookeeper' in lib.get('external_deps', []):
1405 ifeq ($(SYSTEM),MINGW32)
1406 $(E) "[INSTALL] Installing ${lib.name}.$(SHARED_EXT)"
1407 $(Q) $(INSTALL) -d $(prefix)/lib
1408 $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/${lib.name}.$(SHARED_EXT) $(prefix)/lib/${lib.name}.$(SHARED_EXT)
1409 $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/lib${lib.name}-imp.a $(prefix)/lib/lib${lib.name}-imp.a
1410 else
1411 $(E) "[INSTALL] Installing lib${lib.name}.$(SHARED_EXT)"
1412 $(Q) $(INSTALL) -d $(prefix)/lib
1413 $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/lib${lib.name}.$(SHARED_EXT) $(prefix)/lib/lib${lib.name}.$(SHARED_EXT)
1414 ifneq ($(SYSTEM),Darwin)
1415 $(Q) ln -sf lib${lib.name}.$(SHARED_EXT) $(prefix)/lib/lib${lib.name}.so.${settings.version.major}
1416 $(Q) ln -sf lib${lib.name}.$(SHARED_EXT) $(prefix)/lib/lib${lib.name}.so
1417 endif
1418 endif
1419 % endif
1420 % endif
1421 % endif
1422 % endfor
1423 endif
1424 ifneq ($(SYSTEM),MINGW32)
1425 ifneq ($(SYSTEM),Darwin)
1426 $(Q) ldconfig || true
1427 endif
1428 endif
1429 </%def>
nnoble85a49262014-12-08 18:14:03 -08001430
Craig Tiller841c8802015-09-10 13:06:37 -07001431 install-shared_c: shared_c strip-shared_c install-pkg-config_c
1432 ${install_shared("c")}
Nicolas "Pixel" Noble522d7122015-02-19 01:28:02 +01001433
Craig Tiller841c8802015-09-10 13:06:37 -07001434 install-shared_cxx: shared_cxx strip-shared_cxx install-shared_c install-pkg-config_cxx
1435 ${install_shared("c++")}
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001436
Craig Tiller841c8802015-09-10 13:06:37 -07001437 install-shared_csharp: shared_csharp strip-shared_csharp
1438 ${install_shared("csharp")}
Nicolas "Pixel" Noble522d7122015-02-19 01:28:02 +01001439
Craig Tiller841c8802015-09-10 13:06:37 -07001440 install-plugins: $(PROTOC_PLUGINS)
1441 ifeq ($(SYSTEM),MINGW32)
1442 $(Q) false
1443 else
1444 $(E) "[INSTALL] Installing grpc protoc plugins"
1445 % for tgt in targets:
1446 % if tgt.build == 'protoc':
1447 $(Q) $(INSTALL) -d $(prefix)/bin
1448 $(Q) $(INSTALL) $(BINDIR)/$(CONFIG)/${tgt.name} $(prefix)/bin/${tgt.name}
1449 % endif
1450 % endfor
1451 endif
Jan Tattermusch2ec0b3e2015-02-18 15:03:12 -08001452
Craig Tiller841c8802015-09-10 13:06:37 -07001453 install-pkg-config_c: pc_gpr pc_c pc_c_unsecure pc_c_zookeeper
1454 $(E) "[INSTALL] Installing C pkg-config files"
1455 $(Q) $(INSTALL) -d $(prefix)/lib/pkgconfig
1456 $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/pkgconfig/gpr.pc $(prefix)/lib/pkgconfig/gpr.pc
1457 $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/pkgconfig/grpc.pc $(prefix)/lib/pkgconfig/grpc.pc
1458 $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/pkgconfig/grpc_unsecure.pc $(prefix)/lib/pkgconfig/grpc_unsecure.pc
1459 ifeq ($(HAS_ZOOKEEPER),true)
1460 $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/pkgconfig/grpc_zookeeper.pc $(prefix)/lib/pkgconfig/grpc_zookeeper.pc
1461 endif
murgatroid998faab232015-06-30 17:24:21 -07001462
Craig Tiller841c8802015-09-10 13:06:37 -07001463 install-pkg-config_cxx: pc_cxx pc_cxx_unsecure
1464 $(E) "[INSTALL] Installing C++ pkg-config files"
1465 $(Q) $(INSTALL) -d $(prefix)/lib/pkgconfig
1466 $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/pkgconfig/grpc++.pc $(prefix)/lib/pkgconfig/grpc++.pc
1467 $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/pkgconfig/grpc++_unsecure.pc $(prefix)/lib/pkgconfig/grpc++_unsecure.pc
murgatroid998faab232015-06-30 17:24:21 -07001468
Craig Tiller841c8802015-09-10 13:06:37 -07001469 install-certs: etc/roots.pem
1470 $(E) "[INSTALL] Installing root certificates"
1471 $(Q) $(INSTALL) -d $(prefix)/share/grpc
1472 $(Q) $(INSTALL) etc/roots.pem $(prefix)/share/grpc/roots.pem
Nicolas "Pixel" Noble161ea232015-02-22 05:48:53 +01001473
Craig Tiller841c8802015-09-10 13:06:37 -07001474 verify-install:
1475 ifeq ($(INSTALL_OK),true)
1476 @echo "Your system looks ready to go."
1477 @echo
1478 else
1479 @echo "We couldn't find protoc 3.0.0+ installed on your system. While this"
1480 @echo "won't prevent grpc from working, you won't be able to compile"
1481 @echo "and run any meaningful code with it."
1482 @echo
1483 @echo
1484 @echo "Please download and install protobuf 3.0.0+ from:"
1485 @echo
1486 @echo " https://github.com/google/protobuf/releases"
1487 @echo
1488 @echo "Once you've done so, or if you think this message is in error,"
1489 @echo "you can re-run this check by doing:"
1490 @echo
1491 @echo " make verify-install"
1492 endif
Nicolas "Pixel" Noble98ab9982015-02-21 04:22:16 +01001493
Craig Tiller841c8802015-09-10 13:06:37 -07001494 clean:
1495 $(E) "[CLEAN] Cleaning build directories."
1496 $(Q) $(RM) -rf $(OBJDIR) $(LIBDIR) $(BINDIR) $(GENDIR) cache.mk
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001497
1498
Craig Tiller841c8802015-09-10 13:06:37 -07001499 # The various libraries
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001500
Craig Tiller841c8802015-09-10 13:06:37 -07001501 % for lib in libs:
1502 ${makelib(lib)}
1503 % endfor
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001504
1505
Craig Tiller841c8802015-09-10 13:06:37 -07001506 # All of the test targets, and protoc plugins
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001507
Craig Tiller841c8802015-09-10 13:06:37 -07001508 % for tgt in targets:
1509 ${maketarget(tgt)}
1510 % endfor
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001511
Craig Tiller841c8802015-09-10 13:06:37 -07001512 <%def name="makelib(lib)">
1513 LIB${lib.name.upper()}_SRC = \\
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001514
Craig Tiller841c8802015-09-10 13:06:37 -07001515 % for src in lib.src:
1516 ${proto_to_cc(src)} \\
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001517
Craig Tiller841c8802015-09-10 13:06:37 -07001518 % endfor
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001519
Craig Tiller841c8802015-09-10 13:06:37 -07001520 % if "public_headers" in lib:
1521 % if lib.language == "c++":
1522 PUBLIC_HEADERS_CXX += \\
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001523
Craig Tiller841c8802015-09-10 13:06:37 -07001524 % else:
1525 PUBLIC_HEADERS_C += \\
nnoble85a49262014-12-08 18:14:03 -08001526
Craig Tiller841c8802015-09-10 13:06:37 -07001527 % endif
1528 % for hdr in lib.public_headers:
1529 ${hdr} \\
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001530
Craig Tiller841c8802015-09-10 13:06:37 -07001531 % endfor
1532 % endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001533
Craig Tiller841c8802015-09-10 13:06:37 -07001534 LIB${lib.name.upper()}_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(LIB${lib.name.upper()}_SRC))))
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001535
Craig Tiller841c8802015-09-10 13:06:37 -07001536 ## If the library requires OpenSSL, let's add some restrictions.
1537 % if lib.get('secure', 'check') == True or lib.get('secure', 'check') == 'check':
1538 ifeq ($(NO_SECURE),true)
nnoble69ac39f2014-12-12 15:43:38 -08001539
Craig Tiller841c8802015-09-10 13:06:37 -07001540 # You can't build secure libraries if you don't have OpenSSL.
Nicolas Noble047b7272015-01-16 13:55:05 -08001541
Craig Tiller841c8802015-09-10 13:06:37 -07001542 $(LIBDIR)/$(CONFIG)/lib${lib.name}.a: openssl_dep_error
nnoble69ac39f2014-12-12 15:43:38 -08001543
Craig Tiller841c8802015-09-10 13:06:37 -07001544 % if lib.build == "all":
1545 ifeq ($(SYSTEM),MINGW32)
1546 $(LIBDIR)/$(CONFIG)/${lib.name}.$(SHARED_EXT): openssl_dep_error
1547 else
1548 $(LIBDIR)/$(CONFIG)/lib${lib.name}.$(SHARED_EXT): openssl_dep_error
1549 endif
1550 % endif
nnoble5b7f32a2014-12-22 08:12:44 -08001551
Craig Tiller841c8802015-09-10 13:06:37 -07001552 else
nnoble69ac39f2014-12-12 15:43:38 -08001553
Craig Tiller841c8802015-09-10 13:06:37 -07001554 % if lib.language == 'c++':
1555 ifeq ($(NO_PROTOBUF),true)
Nicolas Noble53830622015-02-12 16:56:38 -08001556
Craig Tiller841c8802015-09-10 13:06:37 -07001557 # 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 -08001558
Craig Tiller841c8802015-09-10 13:06:37 -07001559 $(LIBDIR)/$(CONFIG)/lib${lib.name}.a: protobuf_dep_error
Nicolas Noble53830622015-02-12 16:56:38 -08001560
Craig Tiller841c8802015-09-10 13:06:37 -07001561 % if lib.build == "all":
1562 ifeq ($(SYSTEM),MINGW32)
1563 $(LIBDIR)/$(CONFIG)/${lib.name}.$(SHARED_EXT): protobuf_dep_error
1564 else
1565 $(LIBDIR)/$(CONFIG)/lib${lib.name}.$(SHARED_EXT): protobuf_dep_error
1566 endif
1567 % endif
Nicolas Noble53830622015-02-12 16:56:38 -08001568
Craig Tiller841c8802015-09-10 13:06:37 -07001569 else
1570 % endif
Nicolas Noble53830622015-02-12 16:56:38 -08001571
Craig Tiller841c8802015-09-10 13:06:37 -07001572 $(LIBDIR)/$(CONFIG)/lib${lib.name}.a: $(ZLIB_DEP) $(OPENSSL_DEP)\
1573 ## The else here corresponds to the if secure earlier.
1574 % else:
1575 % if lib.language == 'c++':
1576 ifeq ($(NO_PROTOBUF),true)
Nicolas Noble53830622015-02-12 16:56:38 -08001577
Craig Tiller841c8802015-09-10 13:06:37 -07001578 # 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 -08001579
Craig Tiller841c8802015-09-10 13:06:37 -07001580 $(LIBDIR)/$(CONFIG)/lib${lib.name}.a: protobuf_dep_error
Nicolas Noble53830622015-02-12 16:56:38 -08001581
Craig Tiller841c8802015-09-10 13:06:37 -07001582 % if lib.build == "all":
1583 ifeq ($(SYSTEM),MINGW32)
1584 $(LIBDIR)/$(CONFIG)/${lib.name}.$(SHARED_EXT): protobuf_dep_error
1585 else
1586 $(LIBDIR)/$(CONFIG)/lib${lib.name}.$(SHARED_EXT): protobuf_dep_error
1587 endif
1588 % endif
Nicolas Noble53830622015-02-12 16:56:38 -08001589
Craig Tiller841c8802015-09-10 13:06:37 -07001590 else
Nicolas Noble53830622015-02-12 16:56:38 -08001591
Craig Tiller841c8802015-09-10 13:06:37 -07001592 % endif
1593 $(LIBDIR)/$(CONFIG)/lib${lib.name}.a: $(ZLIB_DEP)\
1594 % endif
1595 % if lib.language == 'c++':
1596 $(PROTOBUF_DEP)\
1597 % endif
1598 $(LIB${lib.name.upper()}_OBJS)
1599 $(E) "[AR] Creating $@"
1600 $(Q) mkdir -p `dirname $@`
1601 $(Q) rm -f $(LIBDIR)/$(CONFIG)/lib${lib.name}.a
1602 $(Q) $(AR) rcs $(LIBDIR)/$(CONFIG)/lib${lib.name}.a $(LIB${lib.name.upper()}_OBJS)
1603 % if lib.get('baselib', False):
1604 % if lib.get('secure', 'check') == True:
Nicolas "Pixel" Noble42b4c282015-09-17 23:57:08 +02001605 $(Q) rm -rf $(BUILDDIR_ABSOLUTE)/tmp-merge-${lib.name}
1606 $(Q) mkdir $(BUILDDIR_ABSOLUTE)/tmp-merge-${lib.name}
1607 $(Q) ( cd $(BUILDDIR_ABSOLUTE)/tmp-merge-${lib.name} ; $(AR) x $(LIBDIR)/$(CONFIG)/lib${lib.name}.a )
1608 $(Q) for l in $(OPENSSL_MERGE_LIBS) ; do ( cd $(BUILDDIR_ABSOLUTE)/tmp-merge-${lib.name} ; <%text>ar x $${l}</%text> ) ; done
1609 $(Q) rm -f $(LIBDIR)/$(CONFIG)/lib${lib.name}.a $(BUILDDIR_ABSOLUTE)/tmp-merge-${lib.name}/__.SYMDEF*
1610 $(Q) ar rcs $(LIBDIR)/$(CONFIG)/lib${lib.name}.a $(BUILDDIR_ABSOLUTE)/tmp-merge-${lib.name}/*
1611 $(Q) rm -rf $(BUILDDIR_ABSOLUTE)/tmp-merge-${lib.name}
Craig Tiller841c8802015-09-10 13:06:37 -07001612 % endif
1613 % endif
1614 ifeq ($(SYSTEM),Darwin)
1615 $(Q) ranlib $(LIBDIR)/$(CONFIG)/lib${lib.name}.a
1616 endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001617
Craig Tiller841c8802015-09-10 13:06:37 -07001618 <%
Nicolas "Pixel" Noble010f1e72015-04-23 02:23:49 +02001619
Craig Tiller841c8802015-09-10 13:06:37 -07001620 if lib.language == 'c++':
1621 ld = '$(LDXX)'
1622 else:
1623 ld = '$(LD)'
nnoble5b7f32a2014-12-22 08:12:44 -08001624
Craig Tiller841c8802015-09-10 13:06:37 -07001625 out_base = '$(LIBDIR)/$(CONFIG)/' + lib.name
1626 out_libbase = '$(LIBDIR)/$(CONFIG)/lib' + lib.name
nnoble5b7f32a2014-12-22 08:12:44 -08001627
Craig Tiller841c8802015-09-10 13:06:37 -07001628 common = '$(LIB' + lib.name.upper() + '_OBJS) $(LDLIBS)'
nnoble5b7f32a2014-12-22 08:12:44 -08001629
Craig Tiller841c8802015-09-10 13:06:37 -07001630 libs = ''
1631 lib_deps = ' $(ZLIB_DEP)'
1632 mingw_libs = ''
1633 mingw_lib_deps = ' $(ZLIB_DEP)'
1634 if lib.language == 'c++':
1635 lib_deps += ' $(PROTOBUF_DEP)'
1636 mingw_lib_deps += ' $(PROTOBUF_DEP)'
1637 for dep in lib.get('deps', []):
1638 libs = libs + ' -l' + dep
1639 lib_deps = lib_deps + ' $(LIBDIR)/$(CONFIG)/lib' + dep + '.$(SHARED_EXT)'
1640 mingw_libs = mingw_libs + ' -l' + dep + '-imp'
1641 mingw_lib_deps = mingw_lib_deps + ' $(LIBDIR)/$(CONFIG)/' + dep + '.$(SHARED_EXT)'
nnoble5b7f32a2014-12-22 08:12:44 -08001642
Craig Tiller841c8802015-09-10 13:06:37 -07001643 security = lib.get('secure', 'check')
1644 if security == True:
1645 common = common + ' $(OPENSSL_MERGE_LIBS) $(LDLIBS_SECURE)'
Nicolas "Pixel" Noblea7c162c2015-07-24 20:21:51 +02001646
Craig Tiller841c8802015-09-10 13:06:37 -07001647 if security in [True, 'check']:
1648 for src in lib.src:
1649 if not proto_re.match(src):
1650 sources_that_need_openssl.add(src)
1651 else:
1652 for src in lib.src:
1653 sources_that_don_t_need_openssl.add(src)
Nicolas "Pixel" Noble061690d2015-03-06 22:58:58 +01001654
Craig Tiller841c8802015-09-10 13:06:37 -07001655 if 'zookeeper' in lib.get('external_deps', []):
1656 libs = libs + ' -lzookeeper_mt'
Hongwei Wanga8cc4392015-07-16 17:37:47 -07001657
Craig Tiller841c8802015-09-10 13:06:37 -07001658 if lib.get('secure', 'check') == True or lib.get('secure', 'check') == 'check':
1659 lib_deps = lib_deps + ' $(OPENSSL_DEP)'
1660 mingw_lib_deps = mingw_lib_deps + ' $(OPENSSL_DEP)'
Nicolas "Pixel" Nobledda049c2015-02-21 00:39:32 +01001661
Craig Tiller841c8802015-09-10 13:06:37 -07001662 if lib.language == 'c++':
1663 common = common + ' $(LDLIBSXX) $(LDLIBS_PROTOBUF)'
1664 %>
nnoble5b7f32a2014-12-22 08:12:44 -08001665
Craig Tiller841c8802015-09-10 13:06:37 -07001666 % if lib.build == "all":
1667 ifeq ($(SYSTEM),MINGW32)
1668 ${out_base}.$(SHARED_EXT): $(LIB${lib.name.upper()}_OBJS) ${mingw_lib_deps}
1669 $(E) "[LD] Linking $@"
1670 $(Q) mkdir -p `dirname $@`
1671 $(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}
1672 else
1673 ${out_libbase}.$(SHARED_EXT): $(LIB${lib.name.upper()}_OBJS) ${lib_deps}
1674 $(E) "[LD] Linking $@"
1675 $(Q) mkdir -p `dirname $@`
1676 ifeq ($(SYSTEM),Darwin)
1677 $(Q) ${ld} $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -install_name lib${lib.name}.$(SHARED_EXT) -dynamiclib -o ${out_libbase}.$(SHARED_EXT) ${common}${libs}
1678 else
1679 $(Q) ${ld} $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,-soname,lib${lib.name}.so.${settings.version.major} -o ${out_libbase}.$(SHARED_EXT) ${common}${libs}
1680 $(Q) ln -sf lib${lib.name}.$(SHARED_EXT) ${out_libbase}.so.${settings.version.major}
1681 $(Q) ln -sf lib${lib.name}.$(SHARED_EXT) ${out_libbase}.so
1682 endif
1683 endif
1684 % endif
1685 % if lib.get('secure', 'check') == True or lib.get('secure', 'check') == 'check':
1686 ## If the lib was secure, we have to close the Makefile's if that tested
1687 ## the presence of OpenSSL.
Nicolas Noble53830622015-02-12 16:56:38 -08001688
Craig Tiller841c8802015-09-10 13:06:37 -07001689 endif
1690 % endif
1691 % if lib.language == 'c++':
1692 ## If the lib was C++, we have to close the Makefile's if that tested
1693 ## the presence of protobuf 3.0.0+
nnoble69ac39f2014-12-12 15:43:38 -08001694
Craig Tiller841c8802015-09-10 13:06:37 -07001695 endif
1696 % endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001697
Craig Tiller841c8802015-09-10 13:06:37 -07001698 % if lib.get('secure', 'check') == True or lib.get('secure', 'check') == 'check':
1699 ifneq ($(NO_SECURE),true)
1700 % endif
1701 ifneq ($(NO_DEPS),true)
1702 -include $(LIB${lib.name.upper()}_OBJS:.o=.dep)
1703 endif
1704 % if lib.get('secure', 'check') == True or lib.get('secure', 'check') == 'check':
1705 endif
1706 % endif
1707 % for src in lib.src:
1708 % if not proto_re.match(src) and any(proto_re.match(src2) for src2 in lib.src):
1709 $(OBJDIR)/$(CONFIG)/${os.path.splitext(src)[0]}.o: ${' '.join(proto_to_cc(src2) for src2 in lib.src if proto_re.match(src2))}
1710 % endif
1711 % endfor
1712 </%def>
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001713
Craig Tiller841c8802015-09-10 13:06:37 -07001714 <%def name="maketarget(tgt)"><% has_no_sources = not tgt.src %>
1715 % if not has_no_sources:
1716 ${tgt.name.upper()}_SRC = \\
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001717
Craig Tiller841c8802015-09-10 13:06:37 -07001718 % for src in tgt.src:
1719 ${proto_to_cc(src)} \\
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001720
Craig Tiller841c8802015-09-10 13:06:37 -07001721 % endfor
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001722
Craig Tiller841c8802015-09-10 13:06:37 -07001723 ${tgt.name.upper()}_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(${tgt.name.upper()}_SRC))))
1724 % endif
1725 % if tgt.get('secure', 'check') == True or tgt.get('secure', 'check') == 'check':
1726 ifeq ($(NO_SECURE),true)
nnoble69ac39f2014-12-12 15:43:38 -08001727
Craig Tiller841c8802015-09-10 13:06:37 -07001728 # You can't build secure targets if you don't have OpenSSL.
Nicolas Noble047b7272015-01-16 13:55:05 -08001729
Craig Tiller841c8802015-09-10 13:06:37 -07001730 $(BINDIR)/$(CONFIG)/${tgt.name}: openssl_dep_error
nnoble69ac39f2014-12-12 15:43:38 -08001731
Craig Tiller841c8802015-09-10 13:06:37 -07001732 else
nnoble69ac39f2014-12-12 15:43:38 -08001733
Craig Tiller841c8802015-09-10 13:06:37 -07001734 % endif
1735 ##
1736 ## We're not trying to add a dependency on building zlib and openssl here,
1737 ## as it's already done in the libraries. We're assuming that the build
1738 ## trickles down, and that a secure target requires a secure version of
1739 ## a library.
1740 ##
1741 ## That simplifies the codegen a bit, but prevents a fully defined Makefile.
1742 ## I can live with that.
1743 ##
1744 % if tgt.build == 'protoc' or tgt.language == 'c++':
Nicolas Noble53830622015-02-12 16:56:38 -08001745
Craig Tiller841c8802015-09-10 13:06:37 -07001746 ifeq ($(NO_PROTOBUF),true)
Nicolas Noble53830622015-02-12 16:56:38 -08001747
Craig Tiller841c8802015-09-10 13:06:37 -07001748 # 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 -08001749
Craig Tiller841c8802015-09-10 13:06:37 -07001750 $(BINDIR)/$(CONFIG)/${tgt.name}: protobuf_dep_error
Nicolas Noble53830622015-02-12 16:56:38 -08001751
Craig Tiller841c8802015-09-10 13:06:37 -07001752 else
Nicolas Noble53830622015-02-12 16:56:38 -08001753
Craig Tiller841c8802015-09-10 13:06:37 -07001754 $(BINDIR)/$(CONFIG)/${tgt.name}: \
1755 % if not has_no_sources:
1756 $(PROTOBUF_DEP) $(${tgt.name.upper()}_OBJS)\
1757 % endif
1758 % else:
1759 $(BINDIR)/$(CONFIG)/${tgt.name}: \
1760 % if not has_no_sources:
1761 $(${tgt.name.upper()}_OBJS)\
1762 % endif
1763 % endif
1764 % for dep in tgt.deps:
1765 $(LIBDIR)/$(CONFIG)/lib${dep}.a\
1766 % endfor
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001767
Craig Tiller841c8802015-09-10 13:06:37 -07001768 % if tgt.language == "c++":
1769 ## C++ targets specificies.
1770 % if tgt.build == 'protoc':
1771 $(E) "[HOSTLD] Linking $@"
1772 $(Q) mkdir -p `dirname $@`
1773 $(Q) $(HOST_LDXX) $(HOST_LDFLAGS) \
1774 % if not has_no_sources:
1775 $(${tgt.name.upper()}_OBJS)\
1776 % endif
1777 % else:
1778 $(E) "[LD] Linking $@"
1779 $(Q) mkdir -p `dirname $@`
1780 $(Q) $(LDXX) $(LDFLAGS) \
1781 % if not has_no_sources:
1782 $(${tgt.name.upper()}_OBJS)\
1783 % endif
1784 % endif
1785 % else:
1786 ## C-only targets specificities.
1787 $(E) "[LD] Linking $@"
1788 $(Q) mkdir -p `dirname $@`
1789 $(Q) $(LD) $(LDFLAGS) \
1790 % if not has_no_sources:
1791 $(${tgt.name.upper()}_OBJS)\
1792 % endif
1793 % endif
1794 % for dep in tgt.deps:
1795 $(LIBDIR)/$(CONFIG)/lib${dep}.a\
1796 % endfor
1797 % if 'zookeeper' in tgt.get('external_deps', []):
1798 -lzookeeper_mt\
1799 % endif
1800 % if tgt.language == "c++":
1801 % if tgt.build == 'protoc':
1802 $(HOST_LDLIBSXX) $(HOST_LDLIBS_PROTOC)\
1803 % else:
1804 $(LDLIBSXX) $(LDLIBS_PROTOBUF)\
1805 % endif
1806 % endif
1807 % if tgt.build == 'protoc':
1808 $(HOST_LDLIBS)\
1809 % else:
1810 $(LDLIBS)\
1811 % endif
1812 % if tgt.build == 'protoc':
1813 $(HOST_LDLIBS_PROTOC)\
1814 % elif tgt.get('secure', 'check') == True or tgt.get('secure', 'check') == 'check':
1815 $(LDLIBS_SECURE)\
1816 % endif
1817 % if tgt.language == 'c++' and tgt.build == 'test':
1818 $(GTEST_LIB)\
1819 % elif tgt.language == 'c++' and tgt.build == 'benchmark':
1820 $(GTEST_LIB)\
1821 % endif
1822 -o $(BINDIR)/$(CONFIG)/${tgt.name}
1823 % if tgt.build == 'protoc' or tgt.language == 'c++':
Nicolas Noble53830622015-02-12 16:56:38 -08001824
Craig Tiller841c8802015-09-10 13:06:37 -07001825 endif
1826 % endif
1827 % if tgt.get('secure', 'check') == True or tgt.get('secure', 'check') == 'check':
nnoble69ac39f2014-12-12 15:43:38 -08001828
Craig Tiller841c8802015-09-10 13:06:37 -07001829 endif
1830 % endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001831
Craig Tiller841c8802015-09-10 13:06:37 -07001832 % for src in tgt.src:
1833 $(OBJDIR)/$(CONFIG)/${os.path.splitext(src)[0]}.o: \
1834 % for dep in tgt.deps:
1835 $(LIBDIR)/$(CONFIG)/lib${dep}.a\
1836 % endfor
Craig Tillerf5371ef2015-01-12 16:40:18 -08001837
Craig Tiller841c8802015-09-10 13:06:37 -07001838 % endfor
1839 % if not has_no_sources:
1840 deps_${tgt.name}: $(${tgt.name.upper()}_OBJS:.o=.dep)
1841 % endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001842
Craig Tiller841c8802015-09-10 13:06:37 -07001843 % if not has_no_sources:
1844 % if tgt.get('secure', 'check') == True or tgt.get('secure', 'check') == 'check':
1845 ifneq ($(NO_SECURE),true)
1846 % endif
1847 ifneq ($(NO_DEPS),true)
1848 -include $(${tgt.name.upper()}_OBJS:.o=.dep)
1849 endif
1850 % if tgt.get('secure', 'check') == True or tgt.get('secure', 'check') == 'check':
1851 endif
1852 % endif
1853 % endif
1854 </%def>
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001855
Craig Tiller841c8802015-09-10 13:06:37 -07001856 ifneq ($(OPENSSL_DEP),)
1857 # This is to ensure the embedded OpenSSL is built beforehand, properly
1858 # installing headers to their final destination on the drive. We need this
1859 # otherwise parallel compilation will fail if a source is compiled first.
1860 % for src in sorted(sources_that_need_openssl):
1861 % if src not in sources_that_don_t_need_openssl:
1862 ${src}: $(OPENSSL_DEP)
1863 % endif
1864 % endfor
1865 endif
Nicolas "Pixel" Noble010f1e72015-04-23 02:23:49 +02001866
Craig Tiller841c8802015-09-10 13:06:37 -07001867 .PHONY: all strip tools \
1868 dep_error openssl_dep_error openssl_dep_message git_update stop \
1869 buildtests buildtests_c buildtests_cxx \
1870 test test_c test_cxx \
1871 install install_c install_cxx \
1872 install-headers install-headers_c install-headers_cxx \
1873 install-shared install-shared_c install-shared_cxx \
1874 install-static install-static_c install-static_cxx \
1875 strip strip-shared strip-static \
1876 strip_c strip-shared_c strip-static_c \
1877 strip_cxx strip-shared_cxx strip-static_cxx \
1878 dep_c dep_cxx bins_dep_c bins_dep_cxx \
1879 clean