blob: 1b898efbdda287d3c707a60dbb08e4837fff666c [file] [log] [blame]
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001# GRPC global makefile
2# This currently builds C and C++ code.
Nicolas "Pixel" Nobled49893d2015-04-21 04:57:45 +02003# This file has been automatically generated from a template file.
4# Please look at the templates directory instead.
murgatroid99c241d2c2015-06-22 11:19:57 -07005# This file can be regenerated from the template by running
6# tools/buildgen/generate_projects.sh
Craig Tiller3b935482015-02-16 12:15:48 -08007
Craig Tillerd7f33352015-02-20 15:18:45 -08008# Copyright 2015, Google Inc.
Craig Tiller3b935482015-02-16 12:15:48 -08009# All rights reserved.
10#
11# Redistribution and use in source and binary forms, with or without
12# modification, are permitted provided that the following conditions are
13# met:
14#
15# * Redistributions of source code must retain the above copyright
16# notice, this list of conditions and the following disclaimer.
17# * Redistributions in binary form must reproduce the above
18# copyright notice, this list of conditions and the following disclaimer
19# in the documentation and/or other materials provided with the
20# distribution.
21# * Neither the name of Google Inc. nor the names of its
22# contributors may be used to endorse or promote products derived from
23# this software without specific prior written permission.
24#
25# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
28# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
29# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
30# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
31# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
35# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -080036<%!
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -080037 import re
Craig Tillerf5371ef2015-01-12 16:40:18 -080038 import os
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -080039
nnoblec87b1c52015-01-05 17:15:18 -080040 proto_re = re.compile('(.*)\\.proto')
nnoble72309c62014-12-12 11:42:26 -080041
nnoble72309c62014-12-12 11:42:26 -080042 def proto_to_cc(filename):
43 m = proto_re.match(filename)
44 if not m:
45 return filename
Nicolas "Pixel" Noble0caebbf2015-04-09 23:08:51 +020046 return '$(GENDIR)/' + m.group(1) + '.pb.cc $(GENDIR)/' + m.group(1) + '.grpc.pb.cc'
Nicolas "Pixel" Noble010f1e72015-04-23 02:23:49 +020047
48 sources_that_need_openssl = set()
49 sources_that_don_t_need_openssl = set()
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -080050%>
51
Craig Tiller96b49552015-01-21 16:29:01 -080052
53# Basic platform detection
54HOST_SYSTEM = $(shell uname | cut -f 1 -d_)
55ifeq ($(SYSTEM),)
56SYSTEM = $(HOST_SYSTEM)
57endif
Nicolas Noblef8681182015-03-18 14:25:44 -070058ifeq ($(SYSTEM),MSYS)
59SYSTEM = MINGW32
60endif
Nicolas "Pixel" Noble5fc1adf2015-05-10 22:20:31 +020061ifeq ($(SYSTEM),MINGW64)
62SYSTEM = MINGW32
63endif
Craig Tiller96b49552015-01-21 16:29:01 -080064
65
Craig Tiller61b910f2015-02-15 10:54:07 -080066ifndef BUILDDIR
67BUILDDIR = .
68endif
69
Nicolas Noblef8681182015-03-18 14:25:44 -070070HAS_GCC = $(shell which gcc > /dev/null 2> /dev/null && echo true || echo false)
71HAS_CC = $(shell which cc > /dev/null 2> /dev/null && echo true || echo false)
72HAS_CLANG = $(shell which clang > /dev/null 2> /dev/null && echo true || echo false)
73
74ifeq ($(HAS_CC),true)
75DEFAULT_CC = cc
76DEFAULT_CXX = c++
77else
78ifeq ($(HAS_GCC),true)
79DEFAULT_CC = gcc
80DEFAULT_CXX = g++
81else
82ifeq ($(HAS_CLANG),true)
83DEFAULT_CC = clang
84DEFAULT_CXX = clang++
85else
86DEFAULT_CC = no_c_compiler
87DEFAULT_CXX = no_c++_compiler
88endif
89endif
90endif
91
92
Craig Tiller61b910f2015-02-15 10:54:07 -080093BINDIR = $(BUILDDIR)/bins
94OBJDIR = $(BUILDDIR)/objs
95LIBDIR = $(BUILDDIR)/libs
96GENDIR = $(BUILDDIR)/gens
97
ctiller8cfebb92015-01-06 15:02:12 -080098# Configurations
99
100VALID_CONFIG_opt = 1
Nicolas Noblef8681182015-03-18 14:25:44 -0700101CC_opt = $(DEFAULT_CC)
102CXX_opt = $(DEFAULT_CXX)
103LD_opt = $(DEFAULT_CC)
104LDXX_opt = $(DEFAULT_CXX)
ctiller8cfebb92015-01-06 15:02:12 -0800105CPPFLAGS_opt = -O2
106LDFLAGS_opt =
107DEFINES_opt = NDEBUG
108
David Garcia Quintas8954e902015-04-29 09:46:33 -0700109VALID_CONFIG_basicprof = 1
110CC_basicprof = $(DEFAULT_CC)
111CXX_basicprof = $(DEFAULT_CXX)
112LD_basicprof = $(DEFAULT_CC)
113LDXX_basicprof = $(DEFAULT_CXX)
Craig Tiller113d1692015-05-01 15:26:15 -0700114CPPFLAGS_basicprof = -O2 -DGRPC_BASIC_PROFILER -DGRPC_TIMERS_RDTSC
David Garcia Quintas8954e902015-04-29 09:46:33 -0700115LDFLAGS_basicprof =
116DEFINES_basicprof = NDEBUG
117
118VALID_CONFIG_stapprof = 1
119CC_stapprof = $(DEFAULT_CC)
120CXX_stapprof = $(DEFAULT_CXX)
121LD_stapprof = $(DEFAULT_CC)
122LDXX_stapprof = $(DEFAULT_CXX)
123CPPFLAGS_stapprof = -O2 -DGRPC_STAP_PROFILER
124LDFLAGS_stapprof =
125DEFINES_stapprof = NDEBUG
Vijay Paibc171132015-04-13 10:58:06 -0700126
ctiller8cfebb92015-01-06 15:02:12 -0800127VALID_CONFIG_dbg = 1
Nicolas Noblef8681182015-03-18 14:25:44 -0700128CC_dbg = $(DEFAULT_CC)
129CXX_dbg = $(DEFAULT_CXX)
130LD_dbg = $(DEFAULT_CC)
131LDXX_dbg = $(DEFAULT_CXX)
ctiller8cfebb92015-01-06 15:02:12 -0800132CPPFLAGS_dbg = -O0
133LDFLAGS_dbg =
134DEFINES_dbg = _DEBUG DEBUG
135
Vijay Paidc7110f2015-04-02 13:59:05 -0700136VALID_CONFIG_mutrace = 1
137CC_mutrace = $(DEFAULT_CC)
138CXX_mutrace = $(DEFAULT_CXX)
139LD_mutrace = $(DEFAULT_CC)
140LDXX_mutrace = $(DEFAULT_CXX)
141CPPFLAGS_mutrace = -O0
142LDFLAGS_mutrace = -rdynamic
143DEFINES_mutrace = _DEBUG DEBUG
144
Craig Tillerec0b8f32015-01-15 07:30:00 -0800145VALID_CONFIG_valgrind = 1
Craig Tillerc4da6b72015-01-15 08:01:14 -0800146REQUIRE_CUSTOM_LIBRARIES_valgrind = 1
Nicolas Noblef8681182015-03-18 14:25:44 -0700147CC_valgrind = $(DEFAULT_CC)
148CXX_valgrind = $(DEFAULT_CXX)
149LD_valgrind = $(DEFAULT_CC)
150LDXX_valgrind = $(DEFAULT_CXX)
Craig Tillerec0b8f32015-01-15 07:30:00 -0800151CPPFLAGS_valgrind = -O0
152OPENSSL_CFLAGS_valgrind = -DPURIFY
153LDFLAGS_valgrind =
Craig Tillerf6901be2015-02-27 09:12:58 -0800154DEFINES_valgrind = _DEBUG DEBUG GRPC_TEST_SLOWDOWN_BUILD_FACTOR=20
Craig Tillerec0b8f32015-01-15 07:30:00 -0800155
ctiller8cfebb92015-01-06 15:02:12 -0800156VALID_CONFIG_tsan = 1
Craig Tillerc4da6b72015-01-15 08:01:14 -0800157REQUIRE_CUSTOM_LIBRARIES_tsan = 1
ctiller8cfebb92015-01-06 15:02:12 -0800158CC_tsan = clang
159CXX_tsan = clang++
160LD_tsan = clang
161LDXX_tsan = clang++
Nicolas "Pixel" Noble482d7612015-07-16 23:43:30 +0200162CPPFLAGS_tsan = -O0 -fsanitize=thread -fno-omit-frame-pointer -Wno-error=unused-command-line-argument
ctiller8cfebb92015-01-06 15:02:12 -0800163LDFLAGS_tsan = -fsanitize=thread
Craig Tillerf6901be2015-02-27 09:12:58 -0800164DEFINES_tsan = NDEBUG GRPC_TEST_SLOWDOWN_BUILD_FACTOR=10
ctiller8cfebb92015-01-06 15:02:12 -0800165
166VALID_CONFIG_asan = 1
Craig Tillerc4da6b72015-01-15 08:01:14 -0800167REQUIRE_CUSTOM_LIBRARIES_asan = 1
ctiller8cfebb92015-01-06 15:02:12 -0800168CC_asan = clang
169CXX_asan = clang++
170LD_asan = clang
171LDXX_asan = clang++
Nicolas "Pixel" Noble482d7612015-07-16 23:43:30 +0200172CPPFLAGS_asan = -O0 -fsanitize=address -fno-omit-frame-pointer -Wno-error=unused-command-line-argument
ctiller8cfebb92015-01-06 15:02:12 -0800173LDFLAGS_asan = -fsanitize=address
Craig Tillerd6cc19e2015-07-01 10:05:00 -0700174DEFINES_asan = GRPC_TEST_SLOWDOWN_BUILD_FACTOR=3
ctiller8cfebb92015-01-06 15:02:12 -0800175
176VALID_CONFIG_msan = 1
Craig Tillerc4da6b72015-01-15 08:01:14 -0800177REQUIRE_CUSTOM_LIBRARIES_msan = 1
ctiller8cfebb92015-01-06 15:02:12 -0800178CC_msan = clang
Nicolas "Pixel" Nobled66cba22015-02-14 02:59:12 +0100179CXX_msan = clang++-libc++
ctiller8cfebb92015-01-06 15:02:12 -0800180LD_msan = clang
Nicolas "Pixel" Nobled66cba22015-02-14 02:59:12 +0100181LDXX_msan = clang++-libc++
Nicolas "Pixel" Noble482d7612015-07-16 23:43:30 +0200182CPPFLAGS_msan = -O0 -fsanitize=memory -fsanitize-memory-track-origins -fno-omit-frame-pointer -DGTEST_HAS_TR1_TUPLE=0 -DGTEST_USE_OWN_TR1_TUPLE=1 -Wno-error=unused-command-line-argument
Craig Tillerec0b8f32015-01-15 07:30:00 -0800183OPENSSL_CFLAGS_msan = -DPURIFY
Nicolas "Pixel" Nobled66cba22015-02-14 02:59:12 +0100184LDFLAGS_msan = -fsanitize=memory -DGTEST_HAS_TR1_TUPLE=0 -DGTEST_USE_OWN_TR1_TUPLE=1
Craig Tillerd6cc19e2015-07-01 10:05:00 -0700185DEFINES_msan = NDEBUG GRPC_TEST_SLOWDOWN_BUILD_FACTOR=4
ctiller8cfebb92015-01-06 15:02:12 -0800186
Craig Tiller96bd5f62015-02-13 09:04:13 -0800187VALID_CONFIG_ubsan = 1
188REQUIRE_CUSTOM_LIBRARIES_ubsan = 1
189CC_ubsan = clang
190CXX_ubsan = clang++
191LD_ubsan = clang
192LDXX_ubsan = clang++
Nicolas "Pixel" Noble482d7612015-07-16 23:43:30 +0200193CPPFLAGS_ubsan = -O1 -fsanitize=undefined -fno-omit-frame-pointer -Wno-error=unused-command-line-argument
Craig Tiller96bd5f62015-02-13 09:04:13 -0800194OPENSSL_CFLAGS_ubsan = -DPURIFY
Craig Tiller96bd5f62015-02-13 09:04:13 -0800195LDFLAGS_ubsan = -fsanitize=undefined
Craig Tillerd6cc19e2015-07-01 10:05:00 -0700196DEFINES_ubsan = NDEBUG GRPC_TEST_SLOWDOWN_BUILD_FACTOR=3
Craig Tiller96bd5f62015-02-13 09:04:13 -0800197
Craig Tiller699ba212015-01-13 17:02:20 -0800198VALID_CONFIG_gcov = 1
199CC_gcov = gcc
200CXX_gcov = g++
201LD_gcov = gcc
202LDXX_gcov = g++
203CPPFLAGS_gcov = -O0 -fprofile-arcs -ftest-coverage
204LDFLAGS_gcov = -fprofile-arcs -ftest-coverage
Craig Tiller2e4a7dc2015-04-30 09:22:31 -0700205DEFINES_gcov = _DEBUG DEBUG
Craig Tiller699ba212015-01-13 17:02:20 -0800206
Nicolas Noble047b7272015-01-16 13:55:05 -0800207
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800208# General settings.
209# You may want to change these depending on your system.
210
211prefix ?= /usr/local
212
213PROTOC = protoc
David Garcia Quintas611b7362015-04-27 15:49:31 -0700214DTRACE = dtrace
yangg102e4fe2015-01-06 16:02:50 -0800215CONFIG ?= opt
ctiller8cfebb92015-01-06 15:02:12 -0800216CC = $(CC_$(CONFIG))
217CXX = $(CXX_$(CONFIG))
218LD = $(LD_$(CONFIG))
219LDXX = $(LDXX_$(CONFIG))
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800220AR = ar
Nicolas "Pixel" Nobled7631a42015-02-27 07:52:39 +0100221ifeq ($(SYSTEM),Linux)
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800222STRIP = strip --strip-unneeded
Nicolas "Pixel" Nobled7631a42015-02-27 07:52:39 +0100223else
224ifeq ($(SYSTEM),Darwin)
225STRIP = strip -x
226else
227STRIP = strip
228endif
229endif
Nicolas "Pixel" Noble932d5d32015-02-21 02:15:34 +0100230INSTALL = install
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800231RM = rm -f
murgatroid9966d6edb2015-07-06 11:37:51 -0700232PKG_CONFIG = pkg-config
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800233
yangg102e4fe2015-01-06 16:02:50 -0800234ifndef VALID_CONFIG_$(CONFIG)
235$(error Invalid CONFIG value '$(CONFIG)')
236endif
237
Nicolas "Pixel" Noblee758ed12015-03-11 22:51:39 +0100238ifeq ($(SYSTEM),Linux)
239TMPOUT = /dev/null
240else
241TMPOUT = `mktemp /tmp/test-out-XXXXXX`
242endif
Nicolas Noble047b7272015-01-16 13:55:05 -0800243
Craig Tillercf133f42015-02-26 14:05:56 -0800244# Detect if we can use C++11
Nicolas "Pixel" Noblee758ed12015-03-11 22:51:39 +0100245CXX11_CHECK_CMD = $(CXX) -std=c++11 -o $(TMPOUT) -c test/build/c++11.cc
Craig Tillercf133f42015-02-26 14:05:56 -0800246HAS_CXX11 = $(shell $(CXX11_CHECK_CMD) 2> /dev/null && echo true || echo false)
247
Nicolas Noble047b7272015-01-16 13:55:05 -0800248# The HOST compiler settings are used to compile the protoc plugins.
249# In most cases, you won't have to change anything, but if you are
250# cross-compiling, you can override these variables from GNU make's
251# command line: make CC=cross-gcc HOST_CC=gcc
252
nnoble72309c62014-12-12 11:42:26 -0800253HOST_CC = $(CC)
254HOST_CXX = $(CXX)
255HOST_LD = $(LD)
256HOST_LDXX = $(LDXX)
257
Craig Tiller86fa1c52015-02-27 09:57:58 -0800258ifdef EXTRA_DEFINES
Craig Tillerf5065c52015-02-27 16:17:39 -0800259DEFINES += $(EXTRA_DEFINES)
Craig Tiller86fa1c52015-02-27 09:57:58 -0800260endif
261
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800262CFLAGS += -std=c89 -pedantic
Craig Tillercf133f42015-02-26 14:05:56 -0800263ifeq ($(HAS_CXX11),true)
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800264CXXFLAGS += -std=c++11
Craig Tillercf133f42015-02-26 14:05:56 -0800265else
266CXXFLAGS += -std=c++0x
Craig Tillercf133f42015-02-26 14:05:56 -0800267endif
Nicolas Noblef8681182015-03-18 14:25:44 -0700268CPPFLAGS += -g -Wall -Wextra -Werror -Wno-long-long -Wno-unused-parameter
269LDFLAGS += -g
270
Nicolas "Pixel" Noble482d7612015-07-16 23:43:30 +0200271CPPFLAGS += $(CPPFLAGS_$(CONFIG))
272DEFINES += $(DEFINES_$(CONFIG)) INSTALL_PREFIX=\"$(prefix)\"
273LDFLAGS += $(LDFLAGS_$(CONFIG))
274
Nicolas Noblef8681182015-03-18 14:25:44 -0700275ifneq ($(SYSTEM),MINGW32)
276PIC_CPPFLAGS = -fPIC
277CPPFLAGS += -fPIC
278LDFLAGS += -fPIC
279endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800280
Craig Tillerda224d62015-02-15 11:01:58 -0800281INCLUDES = . include $(GENDIR)
Nicolas "Pixel" Noble3adab742015-06-02 00:33:06 +0200282LDFLAGS += -Llibs/$(CONFIG)
283
Craig Tiller96b49552015-01-21 16:29:01 -0800284ifeq ($(SYSTEM),Darwin)
Nicolas "Pixel" Noblee758ed12015-03-11 22:51:39 +0100285ifneq ($(wildcard /usr/local/ssl/include),)
286INCLUDES += /usr/local/ssl/include
287endif
288ifneq ($(wildcard /opt/local/include),)
289INCLUDES += /opt/local/include
290endif
291ifneq ($(wildcard /usr/local/include),)
292INCLUDES += /usr/local/include
293endif
Craig Tiller96b49552015-01-21 16:29:01 -0800294LIBS = m z
Nicolas "Pixel" Noblee758ed12015-03-11 22:51:39 +0100295ifneq ($(wildcard /usr/local/ssl/lib),)
296LDFLAGS += -L/usr/local/ssl/lib
297endif
298ifneq ($(wildcard /opt/local/lib),)
299LDFLAGS += -L/opt/local/lib
300endif
301ifneq ($(wildcard /usr/local/lib),)
302LDFLAGS += -L/usr/local/lib
303endif
Nicolas Noblef8681182015-03-18 14:25:44 -0700304endif
305
306ifeq ($(SYSTEM),Linux)
ctillerc008ae52015-01-07 15:33:00 -0800307LIBS = rt m z pthread
Craig Tiller96b49552015-01-21 16:29:01 -0800308LDFLAGS += -pthread
309endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800310
Nicolas Noblef8681182015-03-18 14:25:44 -0700311ifeq ($(SYSTEM),MINGW32)
312LIBS = m z pthread
313LDFLAGS += -pthread
314endif
315
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800316ifneq ($(wildcard /usr/src/gtest/src/gtest-all.cc),)
317GTEST_LIB = /usr/src/gtest/src/gtest-all.cc -I/usr/src/gtest
318else
319GTEST_LIB = -lgtest
320endif
chenwa8fd44a2014-12-10 15:13:55 -0800321GTEST_LIB += -lgflags
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800322ifeq ($(V),1)
323E = @:
324Q =
325else
326E = @echo
327Q = @
328endif
329
330VERSION = ${settings.version.major}.${settings.version.minor}.${settings.version.micro}.${settings.version.build}
331
332CPPFLAGS_NO_ARCH += $(addprefix -I, $(INCLUDES)) $(addprefix -D, $(DEFINES))
333CPPFLAGS += $(CPPFLAGS_NO_ARCH) $(ARCH_FLAGS)
334
335LDFLAGS += $(ARCH_FLAGS)
336LDLIBS += $(addprefix -l, $(LIBS))
337LDLIBSXX += $(addprefix -l, $(LIBSXX))
nnoble72309c62014-12-12 11:42:26 -0800338
339HOST_CPPFLAGS = $(CPPFLAGS)
340HOST_CFLAGS = $(CFLAGS)
341HOST_CXXFLAGS = $(CXXFLAGS)
342HOST_LDFLAGS = $(LDFLAGS)
343HOST_LDLIBS = $(LDLIBS)
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800344
nnoble69ac39f2014-12-12 15:43:38 -0800345
346# These are automatically computed variables.
347# There shouldn't be any need to change anything from now on.
348
murgatroid99aa521572015-07-10 14:49:12 -0700349-include cache.mk
murgatroid9924e2f4a2015-06-29 11:12:01 -0700350
murgatroid99aa521572015-07-10 14:49:12 -0700351CACHE_MK =
352
353HAS_PKG_CONFIG ?= $(shell command -v $(PKG_CONFIG) >/dev/null 2>&1 && echo true || echo false)
354
355ifeq ($(HAS_PKG_CONFIG), true)
Nicolas "Pixel" Noble367e30f2015-07-15 22:36:31 +0200356CACHE_MK += HAS_PKG_CONFIG = true,
murgatroid99aa521572015-07-10 14:49:12 -0700357endif
nnoble69ac39f2014-12-12 15:43:38 -0800358
Nicolas "Pixel" Noble367e30f2015-07-15 22:36:31 +0200359PC_TEMPLATE = prefix=$(prefix),\
360exec_prefix=${'\$${prefix}'},\
361includedir=${'\$${prefix}'}/include,\
362libdir=${'\$${exec_prefix}'}/lib,\
363,\
364Name: $(PC_NAME),\
365Description: $(PC_DESCRIPTION),\
366Version: $(VERSION),\
367Cflags: -I${'\$${includedir}'} $(PC_CFLAGS),\
368Requires.private: $(PC_REQUIRES_PRIVATE),\
369Libs: -L${'\$${libdir}'} $(PC_LIB),\
murgatroid998faab232015-06-30 17:24:21 -0700370Libs.private: $(PC_LIBS_PRIVATE)
371
372# gpr .pc file
murgatroid99dbc0caf2015-07-01 12:59:49 -0700373PC_NAME = gRPC Portable Runtime
374PC_DESCRIPTION = gRPC Portable Runtime
murgatroid99c34a3a62015-07-01 10:35:33 -0700375PC_CFLAGS = -pthread
murgatroid998faab232015-06-30 17:24:21 -0700376PC_REQUIRES_PRIVATE =
murgatroid99c34a3a62015-07-01 10:35:33 -0700377PC_LIBS_PRIVATE = -lpthread
murgatroid994fed2122015-07-06 11:26:30 -0700378PC_LIB = -lgpr
murgatroid99d8f1ef72015-07-06 11:34:07 -0700379ifneq ($(SYSTEM),Darwin)
murgatroid99c34a3a62015-07-01 10:35:33 -0700380PC_LIBS_PRIVATE += -lrt
murgatroid998faab232015-06-30 17:24:21 -0700381endif
382GPR_PC_FILE := $(PC_TEMPLATE)
383
nnoble5b7f32a2014-12-22 08:12:44 -0800384ifeq ($(SYSTEM),MINGW32)
385SHARED_EXT = dll
386endif
387ifeq ($(SYSTEM),Darwin)
388SHARED_EXT = dylib
389endif
390ifeq ($(SHARED_EXT),)
391SHARED_EXT = so.$(VERSION)
392endif
393
nnoble69ac39f2014-12-12 15:43:38 -0800394ifeq ($(wildcard .git),)
395IS_GIT_FOLDER = false
396else
397IS_GIT_FOLDER = true
398endif
399
Nicolas Noblef8681182015-03-18 14:25:44 -0700400ifeq ($(SYSTEM),Linux)
401OPENSSL_REQUIRES_DL = true
402endif
403
404ifeq ($(SYSTEM),Darwin)
405OPENSSL_REQUIRES_DL = true
406endif
407
murgatroid9924e2f4a2015-06-29 11:12:01 -0700408ifeq ($(HAS_PKG_CONFIG),true)
murgatroid9966d6edb2015-07-06 11:37:51 -0700409OPENSSL_ALPN_CHECK_CMD = $(PKG_CONFIG) --atleast-version=1.0.2 openssl
murgatroid9971020da2015-07-08 13:04:05 -0700410OPENSSL_NPN_CHECK_CMD = $(PKG_CONFIG) --atleast-version=1.0.1 openssl
murgatroid9966d6edb2015-07-06 11:37:51 -0700411ZLIB_CHECK_CMD = $(PKG_CONFIG) --exists zlib
murgatroid9966d6edb2015-07-06 11:37:51 -0700412PROTOBUF_CHECK_CMD = $(PKG_CONFIG) --atleast-version=3.0.0-alpha-3 protobuf
murgatroid9924e2f4a2015-06-29 11:12:01 -0700413else # HAS_PKG_CONFIG
414
Nicolas Noblef8681182015-03-18 14:25:44 -0700415ifeq ($(SYSTEM),MINGW32)
416OPENSSL_LIBS = ssl32 eay32
417else
418OPENSSL_LIBS = ssl crypto
419endif
420
421OPENSSL_ALPN_CHECK_CMD = $(CC) $(CFLAGS) $(CPPFLAGS) -o $(TMPOUT) test/build/openssl-alpn.c $(addprefix -l, $(OPENSSL_LIBS)) $(LDFLAGS)
Nicolas "Pixel" Noble4cc8c8a2015-06-23 02:37:49 +0200422OPENSSL_NPN_CHECK_CMD = $(CC) $(CFLAGS) $(CPPFLAGS) -o $(TMPOUT) test/build/openssl-npn.c $(addprefix -l, $(OPENSSL_LIBS)) $(LDFLAGS)
Nicolas "Pixel" Noblee758ed12015-03-11 22:51:39 +0100423ZLIB_CHECK_CMD = $(CC) $(CFLAGS) $(CPPFLAGS) -o $(TMPOUT) test/build/zlib.c -lz $(LDFLAGS)
Nicolas "Pixel" Noblee758ed12015-03-11 22:51:39 +0100424PROTOBUF_CHECK_CMD = $(CXX) $(CXXFLAGS) $(CPPFLAGS) -o $(TMPOUT) test/build/protobuf.cc -lprotobuf $(LDFLAGS)
Craig Tiller297fafa2015-01-15 15:46:39 -0800425
Nicolas Noblef8681182015-03-18 14:25:44 -0700426ifeq ($(OPENSSL_REQUIRES_DL),true)
427OPENSSL_ALPN_CHECK_CMD += -ldl
Nicolas "Pixel" Noble4cc8c8a2015-06-23 02:37:49 +0200428OPENSSL_NPN_CHECK_CMD += -ldl
Nicolas Noblef8681182015-03-18 14:25:44 -0700429endif
430
murgatroid9924e2f4a2015-06-29 11:12:01 -0700431endif # HAS_PKG_CONFIG
432
murgatroid996d9e4012015-07-08 10:22:45 -0700433PERFTOOLS_CHECK_CMD = $(CC) $(CFLAGS) $(CPPFLAGS) -o $(TMPOUT) test/build/perftools.c -lprofiler $(LDFLAGS)
434
murgatroid9924e2f4a2015-06-29 11:12:01 -0700435PROTOC_CHECK_CMD = which protoc > /dev/null
436PROTOC_CHECK_VERSION_CMD = protoc --version | grep -q libprotoc.3
437DTRACE_CHECK_CMD = which dtrace > /dev/null
438SYSTEMTAP_HEADERS_CHECK_CMD = $(CC) $(CFLAGS) $(CPPFLAGS) -o $(TMPOUT) test/build/systemtap.c $(LDFLAGS)
Hongwei Wanga8cc4392015-07-16 17:37:47 -0700439ZOOKEEPER_CHECK_CMD = $(CC) $(CFLAGS) $(CPPFLAGS) -o $(TMPOUT) test/build/zookeeper.c $(LDFLAGS) -lzookeeper_mt
murgatroid9924e2f4a2015-06-29 11:12:01 -0700440
Craig Tiller50524cc2015-01-29 23:00:00 -0800441ifndef REQUIRE_CUSTOM_LIBRARIES_$(CONFIG)
murgatroid99aa521572015-07-10 14:49:12 -0700442HAS_SYSTEM_PERFTOOLS ?= $(shell $(PERFTOOLS_CHECK_CMD) 2> /dev/null && echo true || echo false)
Craig Tiller297fafa2015-01-15 15:46:39 -0800443ifeq ($(HAS_SYSTEM_PERFTOOLS),true)
444DEFINES += GRPC_HAVE_PERFTOOLS
445LIBS += profiler
Nicolas "Pixel" Noble367e30f2015-07-15 22:36:31 +0200446CACHE_MK += HAS_SYSTEM_PERFTOOLS = true,
Craig Tiller297fafa2015-01-15 15:46:39 -0800447endif
Craig Tiller50524cc2015-01-29 23:00:00 -0800448endif
nnoble69ac39f2014-12-12 15:43:38 -0800449
Nicolas "Pixel" Noble98ab9982015-02-21 04:22:16 +0100450HAS_SYSTEM_PROTOBUF_VERIFY = $(shell $(PROTOBUF_CHECK_CMD) 2> /dev/null && echo true || echo false)
Craig Tillerc4da6b72015-01-15 08:01:14 -0800451ifndef REQUIRE_CUSTOM_LIBRARIES_$(CONFIG)
murgatroid99aa521572015-07-10 14:49:12 -0700452HAS_SYSTEM_OPENSSL_ALPN ?= $(shell $(OPENSSL_ALPN_CHECK_CMD) 2> /dev/null && echo true || echo false)
Nicolas "Pixel" Noble4cc8c8a2015-06-23 02:37:49 +0200453ifeq ($(HAS_SYSTEM_OPENSSL_ALPN),true)
454HAS_SYSTEM_OPENSSL_NPN = true
Nicolas "Pixel" Noble367e30f2015-07-15 22:36:31 +0200455CACHE_MK += HAS_SYSTEM_OPENSSL_ALPN = true,
Nicolas "Pixel" Noble4cc8c8a2015-06-23 02:37:49 +0200456else
murgatroid99aa521572015-07-10 14:49:12 -0700457HAS_SYSTEM_OPENSSL_NPN ?= $(shell $(OPENSSL_NPN_CHECK_CMD) 2> /dev/null && echo true || echo false)
Nicolas "Pixel" Noble4cc8c8a2015-06-23 02:37:49 +0200458endif
murgatroid99aa521572015-07-10 14:49:12 -0700459ifeq ($(HAS_SYSTEM_OPENSSL_NPN),true)
Nicolas "Pixel" Noble367e30f2015-07-15 22:36:31 +0200460CACHE_MK += HAS_SYSTEM_OPENSSL_NPN = true,
murgatroid99aa521572015-07-10 14:49:12 -0700461endif
462HAS_SYSTEM_ZLIB ?= $(shell $(ZLIB_CHECK_CMD) 2> /dev/null && echo true || echo false)
463ifeq ($(HAS_SYSTEM_ZLIB),true)
Nicolas "Pixel" Noble367e30f2015-07-15 22:36:31 +0200464CACHE_MK += HAS_SYSTEM_ZLIB = true,
murgatroid99aa521572015-07-10 14:49:12 -0700465endif
466HAS_SYSTEM_PROTOBUF ?= $(HAS_SYSTEM_PROTOBUF_VERIFY)
467ifeq ($(HAS_SYSTEM_PROTOBUF),true)
Nicolas "Pixel" Noble367e30f2015-07-15 22:36:31 +0200468CACHE_MK += HAS_SYSTEM_PROTOBUF = true,
murgatroid99aa521572015-07-10 14:49:12 -0700469endif
Craig Tillerc4da6b72015-01-15 08:01:14 -0800470else
471# override system libraries if the config requires a custom compiled library
472HAS_SYSTEM_OPENSSL_ALPN = false
Nicolas "Pixel" Noble4cc8c8a2015-06-23 02:37:49 +0200473HAS_SYSTEM_OPENSSL_NPN = false
Craig Tillerc4da6b72015-01-15 08:01:14 -0800474HAS_SYSTEM_ZLIB = false
Nicolas Noble53830622015-02-12 16:56:38 -0800475HAS_SYSTEM_PROTOBUF = false
Craig Tillerc4da6b72015-01-15 08:01:14 -0800476endif
nnoble69ac39f2014-12-12 15:43:38 -0800477
murgatroid99aa521572015-07-10 14:49:12 -0700478HAS_PROTOC ?= $(shell $(PROTOC_CHECK_CMD) 2> /dev/null && echo true || echo false)
Nicolas "Pixel" Noble98ab9982015-02-21 04:22:16 +0100479ifeq ($(HAS_PROTOC),true)
Nicolas "Pixel" Noble367e30f2015-07-15 22:36:31 +0200480CACHE_MK += HAS_PROTOC = true,
murgatroid99aa521572015-07-10 14:49:12 -0700481HAS_VALID_PROTOC ?= $(shell $(PROTOC_CHECK_VERSION_CMD) 2> /dev/null && echo true || echo false)
482ifeq ($(HAS_VALID_PROTOC),true)
Nicolas "Pixel" Noble367e30f2015-07-15 22:36:31 +0200483CACHE_MK += HAS_VALID_PROTOC = true,
murgatroid99aa521572015-07-10 14:49:12 -0700484endif
Nicolas "Pixel" Noble98ab9982015-02-21 04:22:16 +0100485else
486HAS_VALID_PROTOC = false
487endif
Nicolas Noble53830622015-02-12 16:56:38 -0800488
David Garcia Quintas611b7362015-04-27 15:49:31 -0700489# Check for Systemtap (https://sourceware.org/systemtap/), first by making sure <sys/sdt.h> is present
490# in the system and secondly by checking for the "dtrace" binary (on Linux, this is part of the Systemtap
491# distribution. It's part of the base system on BSD/Solaris machines).
murgatroid99aa521572015-07-10 14:49:12 -0700492ifndef HAS_SYSTEMTAP
David Garcia Quintas611b7362015-04-27 15:49:31 -0700493HAS_SYSTEMTAP_HEADERS = $(shell $(SYSTEMTAP_HEADERS_CHECK_CMD) 2> /dev/null && echo true || echo false)
494HAS_DTRACE = $(shell $(DTRACE_CHECK_CMD) 2> /dev/null && echo true || echo false)
495HAS_SYSTEMTAP = false
496ifeq ($(HAS_SYSTEMTAP_HEADERS),true)
497ifeq ($(HAS_DTRACE),true)
498HAS_SYSTEMTAP = true
David Garcia Quintas611b7362015-04-27 15:49:31 -0700499endif
500endif
murgatroid99aa521572015-07-10 14:49:12 -0700501endif
David Garcia Quintas611b7362015-04-27 15:49:31 -0700502
murgatroid994a015a62015-07-10 14:54:57 -0700503ifeq ($(HAS_SYSTEMTAP),true)
Nicolas "Pixel" Noble367e30f2015-07-15 22:36:31 +0200504CACHE_MK += HAS_SYSTEMTAP = true,
murgatroid994a015a62015-07-10 14:54:57 -0700505endif
nnoble69ac39f2014-12-12 15:43:38 -0800506
Hongwei Wanga8cc4392015-07-16 17:37:47 -0700507HAS_ZOOKEEPER = $(shell $(ZOOKEEPER_CHECK_CMD) 2> /dev/null && echo true || echo false)
508
Nicolas "Pixel" Noble4cc8c8a2015-06-23 02:37:49 +0200509# Note that for testing purposes, one can do:
510# make HAS_EMBEDDED_OPENSSL_ALPN=false
511# to emulate the fact we do not have OpenSSL in the third_party folder.
nnoble69ac39f2014-12-12 15:43:38 -0800512ifeq ($(wildcard third_party/openssl/ssl/ssl.h),)
513HAS_EMBEDDED_OPENSSL_ALPN = false
514else
515HAS_EMBEDDED_OPENSSL_ALPN = true
516endif
517
518ifeq ($(wildcard third_party/zlib/zlib.h),)
519HAS_EMBEDDED_ZLIB = false
520else
521HAS_EMBEDDED_ZLIB = true
522endif
523
Nicolas Noble53830622015-02-12 16:56:38 -0800524ifeq ($(wildcard third_party/protobuf/src/google/protobuf/descriptor.pb.h),)
525HAS_EMBEDDED_PROTOBUF = false
526ifneq ($(HAS_VALID_PROTOC),true)
527NO_PROTOC = true
528endif
529else
530HAS_EMBEDDED_PROTOBUF = true
531endif
532
murgatroid998faab232015-06-30 17:24:21 -0700533PC_REQUIRES_GRPC = gpr
534PC_LIBS_GRPC =
535
nnoble69ac39f2014-12-12 15:43:38 -0800536ifeq ($(HAS_SYSTEM_ZLIB),false)
537ifeq ($(HAS_EMBEDDED_ZLIB),true)
Craig Tiller61b910f2015-02-15 10:54:07 -0800538ZLIB_DEP = $(LIBDIR)/$(CONFIG)/zlib/libz.a
nnoble69ac39f2014-12-12 15:43:38 -0800539CPPFLAGS += -Ithird_party/zlib
Craig Tillerda224d62015-02-15 11:01:58 -0800540LDFLAGS += -L$(LIBDIR)/$(CONFIG)/zlib
nnoble69ac39f2014-12-12 15:43:38 -0800541else
542DEP_MISSING += zlib
543endif
murgatroid9924e2f4a2015-06-29 11:12:01 -0700544else
545ifeq ($(HAS_PKG_CONFIG),true)
murgatroid9966d6edb2015-07-06 11:37:51 -0700546CPPFLAGS += $(shell $(PKG_CONFIG) --cflags zlib)
547LDFLAGS += $(shell $(PKG_CONFIG) --libs-only-L zlib)
murgatroid998faab232015-06-30 17:24:21 -0700548PC_REQUIRES_GRPC += zlib
549else
550PC_LIBS_GRPC += -lz
murgatroid9924e2f4a2015-06-29 11:12:01 -0700551endif
nnoble69ac39f2014-12-12 15:43:38 -0800552endif
553
murgatroid99da7a9942015-06-29 14:57:37 -0700554OPENSSL_PKG_CONFIG = false
555
murgatroid998faab232015-06-30 17:24:21 -0700556PC_REQUIRES_SECURE =
557PC_LIBS_SECURE =
558
murgatroid99da7a9942015-06-29 14:57:37 -0700559ifeq ($(HAS_SYSTEM_OPENSSL_ALPN),true)
560ifeq ($(HAS_PKG_CONFIG),true)
561OPENSSL_PKG_CONFIG = true
murgatroid998faab232015-06-30 17:24:21 -0700562PC_REQUIRES_SECURE = openssl
murgatroid9966d6edb2015-07-06 11:37:51 -0700563CPPFLAGS := $(shell $(PKG_CONFIG) --cflags openssl) $(CPPFLAGS)
564LDFLAGS_OPENSSL_PKG_CONFIG = $(shell $(PKG_CONFIG) --libs-only-L openssl)
murgatroid99da7a9942015-06-29 14:57:37 -0700565ifeq ($(SYSTEM),Linux)
566ifneq ($(LDFLAGS_OPENSSL_PKG_CONFIG),)
murgatroid9966d6edb2015-07-06 11:37:51 -0700567LDFLAGS_OPENSSL_PKG_CONFIG += $(shell $(PKG_CONFIG) --libs-only-L openssl | sed s/L/Wl,-rpath,/)
murgatroid99da7a9942015-06-29 14:57:37 -0700568endif
569endif
570LDFLAGS := $(LDFLAGS_OPENSSL_PKG_CONFIG) $(LDFLAGS)
571else
572LIBS_SECURE = $(OPENSSL_LIBS)
573ifeq ($(OPENSSL_REQUIRES_DL),true)
574LIBS_SECURE += dl
murgatroid998faab232015-06-30 17:24:21 -0700575PC_LIBS_SECURE = $(addprefix -l, $(LIBS_SECURE))
murgatroid99da7a9942015-06-29 14:57:37 -0700576endif
577endif
578else
nnoble69ac39f2014-12-12 15:43:38 -0800579ifeq ($(HAS_EMBEDDED_OPENSSL_ALPN),true)
Nicolas "Pixel" Noble4cc8c8a2015-06-23 02:37:49 +0200580USE_SYSTEM_OPENSSL = false
Craig Tiller61b910f2015-02-15 10:54:07 -0800581OPENSSL_DEP = $(LIBDIR)/$(CONFIG)/openssl/libssl.a
582OPENSSL_MERGE_LIBS += $(LIBDIR)/$(CONFIG)/openssl/libssl.a $(LIBDIR)/$(CONFIG)/openssl/libcrypto.a
Craig Tillerec043032015-02-20 17:24:41 -0800583# need to prefix these to ensure overriding system libraries
584CPPFLAGS := -Ithird_party/openssl/include $(CPPFLAGS)
585LDFLAGS := -L$(LIBDIR)/$(CONFIG)/openssl $(LDFLAGS)
Nicolas Noblef8681182015-03-18 14:25:44 -0700586ifeq ($(OPENSSL_REQUIRES_DL),true)
nnoble5b7f32a2014-12-22 08:12:44 -0800587LIBS_SECURE = dl
Nicolas Noblef8681182015-03-18 14:25:44 -0700588endif
nnoble69ac39f2014-12-12 15:43:38 -0800589else
Nicolas "Pixel" Noble4cc8c8a2015-06-23 02:37:49 +0200590ifeq ($(HAS_SYSTEM_OPENSSL_NPN),true)
591USE_SYSTEM_OPENSSL = true
592CPPFLAGS += -DTSI_OPENSSL_ALPN_SUPPORT=0
593LIBS_SECURE = $(OPENSSL_LIBS)
594ifeq ($(OPENSSL_REQUIRES_DL),true)
595LIBS_SECURE += dl
nnoble69ac39f2014-12-12 15:43:38 -0800596endif
nnoble5b7f32a2014-12-22 08:12:44 -0800597else
nnoble69ac39f2014-12-12 15:43:38 -0800598NO_SECURE = true
599endif
murgatroid9924e2f4a2015-06-29 11:12:01 -0700600endif
Nicolas "Pixel" Noblebe2d3a32015-06-30 19:48:47 +0200601endif
nnoble69ac39f2014-12-12 15:43:38 -0800602
murgatroid99da7a9942015-06-29 14:57:37 -0700603ifeq ($(OPENSSL_PKG_CONFIG),true)
murgatroid9966d6edb2015-07-06 11:37:51 -0700604LDLIBS_SECURE += $(shell $(PKG_CONFIG) --libs-only-l openssl)
murgatroid9924e2f4a2015-06-29 11:12:01 -0700605else
nnoble5b7f32a2014-12-22 08:12:44 -0800606LDLIBS_SECURE += $(addprefix -l, $(LIBS_SECURE))
murgatroid9924e2f4a2015-06-29 11:12:01 -0700607endif
nnoble5b7f32a2014-12-22 08:12:44 -0800608
murgatroid998faab232015-06-30 17:24:21 -0700609# grpc .pc file
610PC_NAME = gRPC
611PC_DESCRIPTION = high performance general RPC framework
612PC_CFLAGS =
613PC_REQUIRES_PRIVATE = $(PC_REQUIRES_GRPC) $(PC_REQUIRES_SECURE)
614PC_LIBS_PRIVATE = $(PC_LIBS_GRPC) $(PC_LIBS_SECURE)
murgatroid994fed2122015-07-06 11:26:30 -0700615PC_LIB = -lgrpc
murgatroid998faab232015-06-30 17:24:21 -0700616GRPC_PC_FILE := $(PC_TEMPLATE)
617
618# gprc_unsecure .pc file
619PC_NAME = gRPC unsecure
620PC_DESCRIPTION = high performance general RPC framework without SSL
621PC_CFLAGS =
622PC_REQUIRES_PRIVATE = $(PC_REQUIRES_GRPC)
623PC_LIBS_PRIVATE = $(PC_LIBS_GRPC)
murgatroid994fed2122015-07-06 11:26:30 -0700624PC_LIB = -lgrpc
murgatroid998faab232015-06-30 17:24:21 -0700625GRPC_UNSECURE_PC_FILE := $(PC_TEMPLATE)
626
Hongwei Wanga8cc4392015-07-16 17:37:47 -0700627# gprc_zookeeper .pc file
628PC_NAME = gRPC zookeeper
629PC_DESCRIPTION = gRPC's zookeeper plugin
630PC_CFLAGS =
631PC_REQUIRES_PRIVATE =
632PC_LIBS_PRIVATE = -lzookeeper_mt
633GRPC_ZOOKEEPER_PC_FILE := $(PC_TEMPLATE)
634
murgatroid99da7a9942015-06-29 14:57:37 -0700635PROTOBUF_PKG_CONFIG = false
636
murgatroid998faab232015-06-30 17:24:21 -0700637PC_REQUIRES_GRPCXX =
638PC_LIBS_GRPCXX =
639
murgatroid99da7a9942015-06-29 14:57:37 -0700640ifeq ($(HAS_SYSTEM_PROTOBUF),true)
641ifeq ($(HAS_PKG_CONFIG),true)
642PROTOBUF_PKG_CONFIG = true
murgatroid998faab232015-06-30 17:24:21 -0700643PC_REQUIRES_GRPCXX = protobuf
murgatroid9966d6edb2015-07-06 11:37:51 -0700644CPPFLAGS := $(shell $(PKG_CONFIG) --cflags protobuf) $(CPPFLAGS)
645LDFLAGS_PROTOBUF_PKG_CONFIG = $(shell $(PKG_CONFIG) --libs-only-L protobuf)
murgatroid99da7a9942015-06-29 14:57:37 -0700646ifeq ($(SYSTEM),Linux)
647ifneq ($(LDFLAGS_PROTOBUF_PKG_CONFIG),)
murgatroid9966d6edb2015-07-06 11:37:51 -0700648LDFLAGS_PROTOBUF_PKG_CONFIG += $(shell $(PKG_CONFIG) --libs-only-L protobuf | sed s/L/Wl,-rpath,/)
murgatroid99da7a9942015-06-29 14:57:37 -0700649endif
650endif
murgatroid998faab232015-06-30 17:24:21 -0700651else
652PC_LIBS_GRPCXX = -lprotobuf
murgatroid99da7a9942015-06-29 14:57:37 -0700653endif
654else
Nicolas Noble53830622015-02-12 16:56:38 -0800655ifeq ($(HAS_EMBEDDED_PROTOBUF),true)
Craig Tiller61b910f2015-02-15 10:54:07 -0800656PROTOBUF_DEP = $(LIBDIR)/$(CONFIG)/protobuf/libprotobuf.a
Craig Tiller9ec95fa2015-02-20 20:36:21 -0800657CPPFLAGS := -Ithird_party/protobuf/src $(CPPFLAGS)
658LDFLAGS := -L$(LIBDIR)/$(CONFIG)/protobuf $(LDFLAGS)
Craig Tiller61b910f2015-02-15 10:54:07 -0800659PROTOC = $(BINDIR)/$(CONFIG)/protobuf/protoc
Nicolas Noble53830622015-02-12 16:56:38 -0800660else
661NO_PROTOBUF = true
662endif
Nicolas Noble53830622015-02-12 16:56:38 -0800663endif
664
665LIBS_PROTOBUF = protobuf
666LIBS_PROTOC = protoc protobuf
667
Nicolas Noble53830622015-02-12 16:56:38 -0800668HOST_LDLIBS_PROTOC += $(addprefix -l, $(LIBS_PROTOC))
669
murgatroid99da7a9942015-06-29 14:57:37 -0700670ifeq ($(PROTOBUF_PKG_CONFIG),true)
murgatroid9966d6edb2015-07-06 11:37:51 -0700671LDLIBS_PROTOBUF += $(shell $(PKG_CONFIG) --libs-only-l protobuf)
murgatroid9924e2f4a2015-06-29 11:12:01 -0700672else
673LDLIBS_PROTOBUF += $(addprefix -l, $(LIBS_PROTOBUF))
674endif
675
murgatroid998faab232015-06-30 17:24:21 -0700676# grpc++ .pc file
677PC_NAME = gRPC++
678PC_DESCRIPTION = C++ wrapper for gRPC
679PC_CFLAGS =
680PC_REQUIRES_PRIVATE = grpc $(PC_REQUIRES_GRPCXX)
681PC_LIBS_PRIVATE = $(PC_LIBS_GRPCXX)
murgatroid994fed2122015-07-06 11:26:30 -0700682PC_LIB = -lgrpc++
murgatroid998faab232015-06-30 17:24:21 -0700683GRPCXX_PC_FILE := $(PC_TEMPLATE)
684
685# grpc++_unsecure .pc file
686PC_NAME = gRPC++ unsecure
687PC_DESCRIPTION = C++ wrapper for gRPC without SSL
688PC_CFLAGS =
689PC_REQUIRES_PRIVATE = grpc_unsecure $(PC_REQUIRES_GRPCXX)
690PC_LIBS_PRIVATE = $(PC_LIBS_GRPCXX)
murgatroid994fed2122015-07-06 11:26:30 -0700691PC_LIB = -lgrpc++
murgatroid998faab232015-06-30 17:24:21 -0700692GRPCXX_UNSECURE_PC_FILE := $(PC_TEMPLATE)
693
Craig Tiller12c82092015-01-15 08:45:56 -0800694ifeq ($(MAKECMDGOALS),clean)
nnoble69ac39f2014-12-12 15:43:38 -0800695NO_DEPS = true
696endif
697
Nicolas "Pixel" Noble98ab9982015-02-21 04:22:16 +0100698INSTALL_OK = false
699ifeq ($(HAS_VALID_PROTOC),true)
700ifeq ($(HAS_SYSTEM_PROTOBUF_VERIFY),true)
701INSTALL_OK = true
702endif
703endif
704
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800705.SECONDARY = %.pb.h %.pb.cc
706
Nicolas "Pixel" Noble522d7122015-02-19 01:28:02 +0100707PROTOC_PLUGINS =\
Craig Tillerf58b9ef2015-01-15 09:09:12 -0800708% for tgt in targets:
709% if tgt.build == 'protoc':
Craig Tiller61b910f2015-02-15 10:54:07 -0800710 $(BINDIR)/$(CONFIG)/${tgt.name}\
Craig Tillerf58b9ef2015-01-15 09:09:12 -0800711% endif
712% endfor
713
nnoble69ac39f2014-12-12 15:43:38 -0800714ifeq ($(DEP_MISSING),)
Nicolas "Pixel" Noble522d7122015-02-19 01:28:02 +0100715all: static shared plugins\
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800716% for tgt in targets:
717% if tgt.build == 'all':
Craig Tiller61b910f2015-02-15 10:54:07 -0800718 $(BINDIR)/$(CONFIG)/${tgt.name}\
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800719% endif
720% endfor
721
nnoble69ac39f2014-12-12 15:43:38 -0800722dep_error:
723 @echo "You shouldn't see this message - all of your dependencies are correct."
724else
725all: dep_error git_update stop
726
727dep_error:
728 @echo
729 @echo "DEPENDENCY ERROR"
730 @echo
731 @echo "You are missing system dependencies that are essential to build grpc,"
732 @echo "and the third_party directory doesn't have them:"
733 @echo
734 @echo " $(DEP_MISSING)"
735 @echo
736 @echo "Installing the development packages for your system will solve"
737 @echo "this issue. Please consult INSTALL to get more information."
738 @echo
739 @echo "If you need information about why these tests failed, run:"
740 @echo
741 @echo " make run_dep_checks"
742 @echo
743endif
744
745git_update:
746ifeq ($(IS_GIT_FOLDER),true)
747 @echo "Additionally, since you are in a git clone, you can download the"
748 @echo "missing dependencies in third_party by running the following command:"
749 @echo
ctiller64f29102014-12-15 10:40:59 -0800750 @echo " git submodule update --init"
nnoble69ac39f2014-12-12 15:43:38 -0800751 @echo
752endif
753
754openssl_dep_error: openssl_dep_message git_update stop
755
Nicolas Noble53830622015-02-12 16:56:38 -0800756protobuf_dep_error: protobuf_dep_message git_update stop
757
758protoc_dep_error: protoc_dep_message git_update stop
759
nnoble69ac39f2014-12-12 15:43:38 -0800760openssl_dep_message:
761 @echo
762 @echo "DEPENDENCY ERROR"
763 @echo
Nicolas "Pixel" Noble4cc8c8a2015-06-23 02:37:49 +0200764 @echo "The target you are trying to run requires OpenSSL."
nnoble69ac39f2014-12-12 15:43:38 -0800765 @echo "Your system doesn't have it, and neither does the third_party directory."
766 @echo
767 @echo "Please consult INSTALL to get more information."
768 @echo
769 @echo "If you need information about why these tests failed, run:"
770 @echo
771 @echo " make run_dep_checks"
772 @echo
773
Nicolas Noble53830622015-02-12 16:56:38 -0800774protobuf_dep_message:
775 @echo
776 @echo "DEPENDENCY ERROR"
777 @echo
778 @echo "The target you are trying to run requires protobuf 3.0.0+"
779 @echo "Your system doesn't have it, and neither does the third_party directory."
780 @echo
781 @echo "Please consult INSTALL to get more information."
782 @echo
783 @echo "If you need information about why these tests failed, run:"
784 @echo
785 @echo " make run_dep_checks"
786 @echo
787
788protoc_dep_message:
789 @echo
790 @echo "DEPENDENCY ERROR"
791 @echo
792 @echo "The target you are trying to run requires protobuf-compiler 3.0.0+"
793 @echo "Your system doesn't have it, and neither does the third_party directory."
794 @echo
795 @echo "Please consult INSTALL to get more information."
796 @echo
797 @echo "If you need information about why these tests failed, run:"
798 @echo
799 @echo " make run_dep_checks"
800 @echo
801
David Garcia Quintas8954e902015-04-29 09:46:33 -0700802systemtap_dep_error:
803 @echo
804 @echo "DEPENDENCY ERROR"
805 @echo
806 @echo "Under the '$(CONFIG)' configutation, the target you are trying "
807 @echo "to build requires systemtap 2.7+ (on Linux) or dtrace (on other "
808 @echo "platforms such as Solaris and *BSD). "
809 @echo
810 @echo "Please consult INSTALL to get more information."
811 @echo
812
nnoble69ac39f2014-12-12 15:43:38 -0800813stop:
814 @false
815
ctiller09cb6d52014-12-19 17:38:22 -0800816% for tgt in targets:
Craig Tiller61b910f2015-02-15 10:54:07 -0800817${tgt.name}: $(BINDIR)/$(CONFIG)/${tgt.name}
ctiller09cb6d52014-12-19 17:38:22 -0800818% endfor
819
nnoble69ac39f2014-12-12 15:43:38 -0800820run_dep_checks:
nnoble69ac39f2014-12-12 15:43:38 -0800821 $(OPENSSL_ALPN_CHECK_CMD) || true
Nicolas "Pixel" Noble4cc8c8a2015-06-23 02:37:49 +0200822 $(OPENSSL_NPN_CHECK_CMD) || true
nnoble69ac39f2014-12-12 15:43:38 -0800823 $(ZLIB_CHECK_CMD) || true
Nicolas Noble53830622015-02-12 16:56:38 -0800824 $(PERFTOOLS_CHECK_CMD) || true
825 $(PROTOBUF_CHECK_CMD) || true
David Garcia Quintasf5fcafd2015-04-24 16:12:54 -0700826 $(PROTOC_CHECK_VERSION_CMD) || true
Hongwei Wanga8cc4392015-07-16 17:37:47 -0700827 $(ZOOKEEPER_CHECK_CMD) || true
nnoble69ac39f2014-12-12 15:43:38 -0800828
Craig Tiller61b910f2015-02-15 10:54:07 -0800829$(LIBDIR)/$(CONFIG)/zlib/libz.a:
Nicolas "Pixel" Noble17f2b592015-01-16 07:09:10 +0100830 $(E) "[MAKE] Building zlib"
Nicolas "Pixel" Noble482d7612015-07-16 23:43:30 +0200831 $(Q)(cd third_party/zlib ; CC="$(CC)" CFLAGS="$(PIC_CPPFLAGS) -fvisibility=hidden $(CPPFLAGS_$(CONFIG)) $(ZLIB_CFLAGS_EXTRA)" ./configure --static)
Nicolas "Pixel" Noble17f2b592015-01-16 07:09:10 +0100832 $(Q)$(MAKE) -C third_party/zlib clean
833 $(Q)$(MAKE) -C third_party/zlib
Craig Tiller61b910f2015-02-15 10:54:07 -0800834 $(Q)mkdir -p $(LIBDIR)/$(CONFIG)/zlib
835 $(Q)cp third_party/zlib/libz.a $(LIBDIR)/$(CONFIG)/zlib
nnoble69ac39f2014-12-12 15:43:38 -0800836
Craig Tiller61b910f2015-02-15 10:54:07 -0800837$(LIBDIR)/$(CONFIG)/openssl/libssl.a:
Craig Tillerb4ee3b52015-01-21 16:22:50 -0800838 $(E) "[MAKE] Building openssl for $(SYSTEM)"
839ifeq ($(SYSTEM),Darwin)
Nicolas "Pixel" Noble482d7612015-07-16 23:43:30 +0200840 $(Q)(cd third_party/openssl ; CC="$(CC) $(PIC_CPPFLAGS) -fvisibility=hidden $(CPPFLAGS_$(CONFIG)) $(OPENSSL_CFLAGS_$(CONFIG)) $(OPENSSL_CFLAGS_EXTRA)" ./Configure darwin64-x86_64-cc)
Craig Tillerb4ee3b52015-01-21 16:22:50 -0800841else
Nicolas Noblef8681182015-03-18 14:25:44 -0700842ifeq ($(SYSTEM),MINGW32)
843 @echo "We currently don't have a good way to compile OpenSSL in-place under msys."
Nicolas "Pixel" Noble4cc8c8a2015-06-23 02:37:49 +0200844 @echo "Please provide a OpenSSL in your mingw32 system."
Nicolas Noblef8681182015-03-18 14:25:44 -0700845 @echo
846 @echo "Note that you can find a compatible version of the libraries here:"
847 @echo
848 @echo "http://slproweb.com/products/Win32OpenSSL.html"
849 @echo
850 @echo "If you decide to install that one, take the full version. The light"
851 @echo "version only contains compiled DLLs, without the development files."
852 @echo
853 @echo "When installing, chose to copy the OpenSSL dlls to the OpenSSL binaries"
854 @echo "directory. This way we'll link to them directly."
855 @echo
856 @echo "You can then re-start the build the following way:"
857 @echo
858 @echo " CPPFLAGS=-I/c/OpenSSL-Win64/include LDFLAGS=-L/c/OpenSSL-Win64 make"
859 @false
860else
Nicolas "Pixel" Noble482d7612015-07-16 23:43:30 +0200861 $(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)))
Nicolas Noblef8681182015-03-18 14:25:44 -0700862endif
Craig Tillerb4ee3b52015-01-21 16:22:50 -0800863endif
Nicolas "Pixel" Noble17f2b592015-01-16 07:09:10 +0100864 $(Q)$(MAKE) -C third_party/openssl clean
Jan Tattermuschc9c83cf2015-06-17 13:42:34 -0700865 $(Q)(unset CPPFLAGS; $(MAKE) -C third_party/openssl build_crypto build_ssl)
Craig Tiller61b910f2015-02-15 10:54:07 -0800866 $(Q)mkdir -p $(LIBDIR)/$(CONFIG)/openssl
867 $(Q)cp third_party/openssl/libssl.a third_party/openssl/libcrypto.a $(LIBDIR)/$(CONFIG)/openssl
nnoble69ac39f2014-12-12 15:43:38 -0800868
Nicolas Noble53830622015-02-12 16:56:38 -0800869third_party/protobuf/configure:
870 $(E) "[AUTOGEN] Preparing protobuf"
871 $(Q)(cd third_party/protobuf ; autoreconf -f -i -Wall,no-obsolete)
872
Craig Tiller61b910f2015-02-15 10:54:07 -0800873$(LIBDIR)/$(CONFIG)/protobuf/libprotobuf.a: third_party/protobuf/configure
Nicolas Noble53830622015-02-12 16:56:38 -0800874 $(E) "[MAKE] Building protobuf"
Nicolas "Pixel" Noble482d7612015-07-16 23:43:30 +0200875 $(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)
Nicolas Noble53830622015-02-12 16:56:38 -0800876 $(Q)$(MAKE) -C third_party/protobuf clean
877 $(Q)$(MAKE) -C third_party/protobuf
Craig Tiller61b910f2015-02-15 10:54:07 -0800878 $(Q)mkdir -p $(LIBDIR)/$(CONFIG)/protobuf
879 $(Q)mkdir -p $(BINDIR)/$(CONFIG)/protobuf
880 $(Q)cp third_party/protobuf/src/.libs/libprotoc.a $(LIBDIR)/$(CONFIG)/protobuf
881 $(Q)cp third_party/protobuf/src/.libs/libprotobuf.a $(LIBDIR)/$(CONFIG)/protobuf
882 $(Q)cp third_party/protobuf/src/protoc $(BINDIR)/$(CONFIG)/protobuf
Nicolas Noble53830622015-02-12 16:56:38 -0800883
nnoble29e1d292014-12-01 10:27:40 -0800884static: static_c static_cxx
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800885
Hongwei Wangb307ae22015-07-17 17:38:34 -0700886static_c: pc_c pc_c_unsecure cache.mk pc_gpr pc_c_zookeeper\
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800887% for lib in libs:
Hongwei Wanga8cc4392015-07-16 17:37:47 -0700888% if lib.build == 'all' and lib.language == 'c' and not lib.get('external_deps', None):
Craig Tiller61b910f2015-02-15 10:54:07 -0800889 $(LIBDIR)/$(CONFIG)/lib${lib.name}.a\
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800890% endif
891% endfor
Hongwei Wanga8cc4392015-07-16 17:37:47 -0700892 static_zookeeper_libs
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800893
894
murgatroid99aa521572015-07-10 14:49:12 -0700895static_cxx: pc_cxx pc_cxx_unsecure pc_gpr cache.mk \
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800896% for lib in libs:
Craig Tiller59140fc2015-01-18 10:12:17 -0800897% if lib.build == 'all' and lib.language == 'c++':
Craig Tiller61b910f2015-02-15 10:54:07 -0800898 $(LIBDIR)/$(CONFIG)/lib${lib.name}.a\
nnoble29e1d292014-12-01 10:27:40 -0800899% endif
900% endfor
901
902
903shared: shared_c shared_cxx
904
Hongwei Wangb307ae22015-07-17 17:38:34 -0700905shared_c: pc_c pc_c_unsecure pc_gpr cache.mk pc_c_zookeeper\
nnoble29e1d292014-12-01 10:27:40 -0800906% for lib in libs:
Hongwei Wanga8cc4392015-07-16 17:37:47 -0700907% if lib.build == 'all' and lib.language == 'c' and not lib.get('external_deps', None):
Craig Tiller61b910f2015-02-15 10:54:07 -0800908 $(LIBDIR)/$(CONFIG)/lib${lib.name}.$(SHARED_EXT)\
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800909% endif
910% endfor
Hongwei Wanga8cc4392015-07-16 17:37:47 -0700911 shared_zookeeper_libs
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800912
murgatroid99aa521572015-07-10 14:49:12 -0700913shared_cxx: pc_cxx pc_cxx_unsecure cache.mk\
nnoble29e1d292014-12-01 10:27:40 -0800914% for lib in libs:
Craig Tiller59140fc2015-01-18 10:12:17 -0800915% if lib.build == 'all' and lib.language == 'c++':
Craig Tiller61b910f2015-02-15 10:54:07 -0800916 $(LIBDIR)/$(CONFIG)/lib${lib.name}.$(SHARED_EXT)\
nnoble29e1d292014-12-01 10:27:40 -0800917% endif
918% endfor
919
920
Jan Tattermusch2ec0b3e2015-02-18 15:03:12 -0800921shared_csharp: shared_c \
922% for lib in libs:
923% if lib.build == 'all' and lib.language == 'csharp':
924 $(LIBDIR)/$(CONFIG)/lib${lib.name}.$(SHARED_EXT)\
925% endif
926% endfor
927
Hongwei Wanga8cc4392015-07-16 17:37:47 -0700928ifeq ($(HAS_ZOOKEEPER),true)
929static_zookeeper_libs:\
930% for lib in libs:
931% if lib.build == 'all' and lib.language == 'c' and 'zookeeper' in lib.get('external_deps', []):
932 $(LIBDIR)/$(CONFIG)/lib${lib.name}.a\
933% endif
934% endfor
935
936shared_zookeeper_libs:\
937% for lib in libs:
938% if lib.build == 'all' and lib.language == 'c' and 'zookeeper' in lib.get('external_deps', []):
939 $(LIBDIR)/$(CONFIG)/lib${lib.name}.$(SHARED_EXT)\
940% endif
941% endfor
942
943else
944
945static_zookeeper_libs:
946
947shared_zookeeper_libs:
948
949endif
950
Jan Tattermusch2ec0b3e2015-02-18 15:03:12 -0800951grpc_csharp_ext: shared_csharp
952
Nicolas "Pixel" Noble522d7122015-02-19 01:28:02 +0100953plugins: $(PROTOC_PLUGINS)
954
nnoble29e1d292014-12-01 10:27:40 -0800955privatelibs: privatelibs_c privatelibs_cxx
956
Craig Tiller12c82092015-01-15 08:45:56 -0800957privatelibs_c: \
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800958% for lib in libs:
Hongwei Wang8e04d412015-07-31 15:12:51 -0700959% if lib.build == 'private' and lib.language == 'c' and not lib.get('external_deps', None):
Craig Tiller61b910f2015-02-15 10:54:07 -0800960 $(LIBDIR)/$(CONFIG)/lib${lib.name}.a\
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800961% endif
962% endfor
963
murgatroid998faab232015-06-30 17:24:21 -0700964pc_gpr: $(LIBDIR)/$(CONFIG)/pkgconfig/gpr.pc
965
966pc_c: $(LIBDIR)/$(CONFIG)/pkgconfig/grpc.pc
967
968pc_c_unsecure: $(LIBDIR)/$(CONFIG)/pkgconfig/grpc_unsecure.pc
969
Hongwei Wanga3780a82015-07-17 15:27:18 -0700970ifeq ($(HAS_ZOOKEEPER),true)
971pc_c_zookeeper: $(LIBDIR)/$(CONFIG)/pkgconfig/grpc_zookeeper.pc
972else
973pc_c_zookeeper:
974endif
975
murgatroid998faab232015-06-30 17:24:21 -0700976pc_cxx: $(LIBDIR)/$(CONFIG)/pkgconfig/grpc++.pc
977
978pc_cxx_unsecure: $(LIBDIR)/$(CONFIG)/pkgconfig/grpc++_unsecure.pc
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800979
Craig Tiller12c82092015-01-15 08:45:56 -0800980privatelibs_cxx: \
nnoble29e1d292014-12-01 10:27:40 -0800981% for lib in libs:
Hongwei Wang8e04d412015-07-31 15:12:51 -0700982% if lib.build == 'private' and lib.language == 'c++' and not lib.get('external_deps', None):
Craig Tiller61b910f2015-02-15 10:54:07 -0800983 $(LIBDIR)/$(CONFIG)/lib${lib.name}.a\
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800984% endif
985% endfor
986
987
Hongwei Wang8e04d412015-07-31 15:12:51 -0700988ifeq ($(HAS_ZOOKEEPER),true)
989privatelibs_zookeeper: \
990% for lib in libs:
991% if lib.build == 'private' and lib.language == 'c++' and zookeeper in lib.get('external_deps', []):
992 $(LIBDIR)/$(CONFIG)/lib${lib.name}.a\
993% endif
994% endfor
995
996else
997privatelibs_zookeeper:
998endif
999
1000
1001buildtests: buildtests_c buildtests_cxx buildtests_zookeeper
nnoble29e1d292014-12-01 10:27:40 -08001002
Craig Tiller12c82092015-01-15 08:45:56 -08001003buildtests_c: privatelibs_c\
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001004% for tgt in targets:
Hongwei Wang8e04d412015-07-31 15:12:51 -07001005% if tgt.build == 'test' and not tgt.language == 'c++' and not tgt.get('external_deps', None):
Craig Tiller61b910f2015-02-15 10:54:07 -08001006 $(BINDIR)/$(CONFIG)/${tgt.name}\
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001007% endif
1008% endfor
1009
1010
Hongwei Wang5c9bbfb2015-08-04 14:11:42 -07001011buildtests_cxx: buildtests_zookeeper privatelibs_cxx\
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001012% for tgt in targets:
Hongwei Wang8e04d412015-07-31 15:12:51 -07001013% if tgt.build == 'test' and tgt.language == 'c++' and not tgt.get('external_deps', None):
Craig Tiller61b910f2015-02-15 10:54:07 -08001014 $(BINDIR)/$(CONFIG)/${tgt.name}\
nnoble29e1d292014-12-01 10:27:40 -08001015% endif
1016% endfor
1017
1018
Hongwei Wang8e04d412015-07-31 15:12:51 -07001019ifeq ($(HAS_ZOOKEEPER),true)
1020buildtests_zookeeper: privatelibs_zookeeper\
1021% for tgt in targets:
1022% if tgt.build == 'test' and tgt.language == 'c++' and 'zookeeper' in tgt.get('external_deps', []):
1023 $(BINDIR)/$(CONFIG)/${tgt.name}\
1024% endif
1025% endfor
nnoble29e1d292014-12-01 10:27:40 -08001026
Hongwei Wang8e04d412015-07-31 15:12:51 -07001027else
1028buildtests_zookeeper:
1029endif
1030
1031
1032test: test_c test_cxx test_zookeeper
1033
1034flaky_test: flaky_test_c flaky_test_cxx flaky_test_zookeeper
Nicolas "Pixel" Noble4251d562015-05-22 19:43:39 +02001035
nnoble85a49262014-12-08 18:14:03 -08001036test_c: buildtests_c
nnoble29e1d292014-12-01 10:27:40 -08001037% for tgt in targets:
Hongwei Wang8e04d412015-07-31 15:12:51 -07001038% 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):
Nicolas "Pixel" Noble4251d562015-05-22 19:43:39 +02001039 $(E) "[RUN] Testing ${tgt.name}"
1040 $(Q) $(BINDIR)/$(CONFIG)/${tgt.name} || ( echo test ${tgt.name} failed ; exit 1 )
1041% endif
1042% endfor
1043
1044
1045flaky_test_c: buildtests_c
1046% for tgt in targets:
Hongwei Wang8e04d412015-07-31 15:12:51 -07001047% 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):
nnoble29e1d292014-12-01 10:27:40 -08001048 $(E) "[RUN] Testing ${tgt.name}"
Craig Tillerda224d62015-02-15 11:01:58 -08001049 $(Q) $(BINDIR)/$(CONFIG)/${tgt.name} || ( echo test ${tgt.name} failed ; exit 1 )
nnoble29e1d292014-12-01 10:27:40 -08001050% endif
1051% endfor
1052
1053
Hongwei Wang5c9bbfb2015-08-04 14:11:42 -07001054test_cxx: test_zookeeper buildtests_cxx
nnoble29e1d292014-12-01 10:27:40 -08001055% for tgt in targets:
Hongwei Wang8e04d412015-07-31 15:12:51 -07001056% 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):
Nicolas "Pixel" Noble4251d562015-05-22 19:43:39 +02001057 $(E) "[RUN] Testing ${tgt.name}"
1058 $(Q) $(BINDIR)/$(CONFIG)/${tgt.name} || ( echo test ${tgt.name} failed ; exit 1 )
1059% endif
1060% endfor
1061
1062
1063flaky_test_cxx: buildtests_cxx
1064% for tgt in targets:
Hongwei Wang8e04d412015-07-31 15:12:51 -07001065% 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):
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001066 $(E) "[RUN] Testing ${tgt.name}"
Craig Tillerda224d62015-02-15 11:01:58 -08001067 $(Q) $(BINDIR)/$(CONFIG)/${tgt.name} || ( echo test ${tgt.name} failed ; exit 1 )
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001068% endif
1069% endfor
1070
1071
Hongwei Wang8e04d412015-07-31 15:12:51 -07001072ifeq ($(HAS_ZOOKEEPER),true)
1073test_zookeeper: buildtests_zookeeper
1074% for tgt in targets:
1075% 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', []):
1076 $(E) "[RUN] Testing ${tgt.name}"
1077 $(Q) $(BINDIR)/$(CONFIG)/${tgt.name} || ( echo test ${tgt.name} failed ; exit 1 )
1078% endif
1079% endfor
1080
1081
1082flaky_test_zookeeper: buildtests_zookeeper
1083% for tgt in targets:
1084% 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', []):
1085 $(E) "[RUN] Testing ${tgt.name}"
1086 $(Q) $(BINDIR)/$(CONFIG)/${tgt.name} || ( echo test ${tgt.name} failed ; exit 1 )
1087% endif
1088% endfor
1089
1090else
1091test_zookeeper:
1092flaky_test_zookeeper:
1093endif
1094
1095
Nicolas "Pixel" Noble051a28f2015-03-17 22:54:54 +01001096test_python: static_c
1097 $(E) "[RUN] Testing python code"
1098 $(Q) tools/run_tests/run_tests.py -lpython -c$(CONFIG)
1099
1100
Craig Tiller7552f0f2015-06-19 17:46:20 -07001101tools: tools_c tools_cxx
1102
1103
1104tools_c: privatelibs_c\
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001105% for tgt in targets:
Craig Tiller7552f0f2015-06-19 17:46:20 -07001106% if tgt.build == 'tool' and not tgt.language=='c++':
1107 $(BINDIR)/$(CONFIG)/${tgt.name}\
1108% endif
1109% endfor
1110
1111
1112tools_cxx: privatelibs_cxx\
1113% for tgt in targets:
1114% if tgt.build == 'tool' and tgt.language=='c++':
Craig Tiller61b910f2015-02-15 10:54:07 -08001115 $(BINDIR)/$(CONFIG)/${tgt.name}\
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001116% endif
1117% endfor
1118
1119
1120buildbenchmarks: privatelibs\
1121% for tgt in targets:
1122% if tgt.build == 'benchmark':
Craig Tiller61b910f2015-02-15 10:54:07 -08001123 $(BINDIR)/$(CONFIG)/${tgt.name}\
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001124% endif
1125% endfor
1126
1127
1128benchmarks: buildbenchmarks
1129
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001130strip: strip-static strip-shared
1131
nnoble20e2e3f2014-12-16 15:37:57 -08001132strip-static: strip-static_c strip-static_cxx
1133
1134strip-shared: strip-shared_c strip-shared_cxx
1135
Nicolas Noble047b7272015-01-16 13:55:05 -08001136
1137# TODO(nnoble): the strip target is stripping in-place, instead
1138# of copying files in a temporary folder.
1139# This prevents proper debugging after running make install.
1140
nnoble85a49262014-12-08 18:14:03 -08001141strip-static_c: static_c
Nicolas "Pixel" Noble3a2551c2015-01-29 21:33:32 +01001142ifeq ($(CONFIG),opt)
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001143% for lib in libs:
Craig Tiller59140fc2015-01-18 10:12:17 -08001144% if lib.language == "c":
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001145% if lib.build == "all":
Hongwei Wanga8cc4392015-07-16 17:37:47 -07001146% if not lib.get('external_deps', None):
nnoble85a49262014-12-08 18:14:03 -08001147 $(E) "[STRIP] Stripping lib${lib.name}.a"
Craig Tiller61b910f2015-02-15 10:54:07 -08001148 $(Q) $(STRIP) $(LIBDIR)/$(CONFIG)/lib${lib.name}.a
nnoble85a49262014-12-08 18:14:03 -08001149% endif
1150% endif
Hongwei Wanga8cc4392015-07-16 17:37:47 -07001151% endif
nnoble85a49262014-12-08 18:14:03 -08001152% endfor
Hongwei Wanga8cc4392015-07-16 17:37:47 -07001153ifeq ($(HAS_ZOOKEEPER),true)
1154% for lib in libs:
Nicolas "Pixel" Noble4ef9b862015-08-14 19:35:24 +02001155% if lib.language == "c":
Hongwei Wanga8cc4392015-07-16 17:37:47 -07001156% if lib.build == "all":
1157% if 'zookeeper' in lib.get('external_deps', []):
Nicolas "Pixel" Noble4ef9b862015-08-14 19:35:24 +02001158 $(E) "[STRIP] Stripping lib${lib.name}.a"
1159 $(Q) $(STRIP) $(LIBDIR)/$(CONFIG)/lib${lib.name}.a
Hongwei Wanga8cc4392015-07-16 17:37:47 -07001160% endif
1161% endif
1162% endif
1163% endfor
1164endif
Nicolas "Pixel" Noble3a2551c2015-01-29 21:33:32 +01001165endif
nnoble85a49262014-12-08 18:14:03 -08001166
Nicolas "Pixel" Noble4ef9b862015-08-14 19:35:24 +02001167strip-static_cxx: static_cxx
1168ifeq ($(CONFIG),opt)
1169% for lib in libs:
1170% if lib.language == "c++":
1171% if lib.build == "all":
1172 $(E) "[STRIP] Stripping lib${lib.name}.a"
1173 $(Q) $(STRIP) $(LIBDIR)/$(CONFIG)/lib${lib.name}.a
1174% endif
1175% endif
1176% endfor
1177endif
1178
nnoble85a49262014-12-08 18:14:03 -08001179strip-shared_c: shared_c
Nicolas "Pixel" Noble3a2551c2015-01-29 21:33:32 +01001180ifeq ($(CONFIG),opt)
nnoble85a49262014-12-08 18:14:03 -08001181% for lib in libs:
Craig Tiller59140fc2015-01-18 10:12:17 -08001182% if lib.language == "c":
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001183% if lib.build == "all":
Hongwei Wanga8cc4392015-07-16 17:37:47 -07001184% if not lib.get('external_deps', None):
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001185 $(E) "[STRIP] Stripping lib${lib.name}.so"
Craig Tiller61b910f2015-02-15 10:54:07 -08001186 $(Q) $(STRIP) $(LIBDIR)/$(CONFIG)/lib${lib.name}.$(SHARED_EXT)
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001187% endif
nnoble85a49262014-12-08 18:14:03 -08001188% endif
Hongwei Wanga8cc4392015-07-16 17:37:47 -07001189% endif
nnoble85a49262014-12-08 18:14:03 -08001190% endfor
Hongwei Wanga8cc4392015-07-16 17:37:47 -07001191ifeq ($(HAS_ZOOKEEPER),true)
1192% for lib in libs:
1193% if lib.language == "c":
1194% if lib.build == "all":
1195% if 'zookeeper' in lib.get('external_deps', []):
1196 $(E) "[STRIP] Stripping lib${lib.name}.so"
1197 $(Q) $(STRIP) $(LIBDIR)/$(CONFIG)/lib${lib.name}.$(SHARED_EXT)
1198% endif
1199% endif
1200% endif
1201% endfor
1202endif
Nicolas "Pixel" Noble3a2551c2015-01-29 21:33:32 +01001203endif
nnoble85a49262014-12-08 18:14:03 -08001204
1205strip-shared_cxx: shared_cxx
Nicolas "Pixel" Noble3a2551c2015-01-29 21:33:32 +01001206ifeq ($(CONFIG),opt)
nnoble85a49262014-12-08 18:14:03 -08001207% for lib in libs:
Craig Tiller59140fc2015-01-18 10:12:17 -08001208% if lib.language == "c++":
nnoble85a49262014-12-08 18:14:03 -08001209% if lib.build == "all":
1210 $(E) "[STRIP] Stripping lib${lib.name}.so"
Craig Tiller61b910f2015-02-15 10:54:07 -08001211 $(Q) $(STRIP) $(LIBDIR)/$(CONFIG)/lib${lib.name}.$(SHARED_EXT)
nnoble85a49262014-12-08 18:14:03 -08001212% endif
1213% endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001214% endfor
Nicolas "Pixel" Noble3a2551c2015-01-29 21:33:32 +01001215endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001216
Jan Tattermusch2ec0b3e2015-02-18 15:03:12 -08001217strip-shared_csharp: shared_csharp
1218ifeq ($(CONFIG),opt)
1219% for lib in libs:
1220% if lib.language == "csharp":
1221% if lib.build == "all":
1222 $(E) "[STRIP] Stripping lib${lib.name}.so"
1223 $(Q) $(STRIP) $(LIBDIR)/$(CONFIG)/lib${lib.name}.$(SHARED_EXT)
1224% endif
1225% endif
1226% endfor
1227endif
1228
murgatroid99aa521572015-07-10 14:49:12 -07001229cache.mk::
1230 $(E) "[MAKE] Generating $@"
Nicolas "Pixel" Noble367e30f2015-07-15 22:36:31 +02001231 $(Q) echo "$(CACHE_MK)" | tr , '\n' >$@
murgatroid99aa521572015-07-10 14:49:12 -07001232
murgatroid998faab232015-06-30 17:24:21 -07001233$(LIBDIR)/$(CONFIG)/pkgconfig/gpr.pc:
1234 $(E) "[MAKE] Generating $@"
1235 $(Q) mkdir -p $(@D)
Nicolas "Pixel" Noble367e30f2015-07-15 22:36:31 +02001236 $(Q) echo "$(GPR_PC_FILE)" | tr , '\n' >$@
murgatroid998faab232015-06-30 17:24:21 -07001237
1238$(LIBDIR)/$(CONFIG)/pkgconfig/grpc.pc:
1239 $(E) "[MAKE] Generating $@"
1240 $(Q) mkdir -p $(@D)
Nicolas "Pixel" Noble367e30f2015-07-15 22:36:31 +02001241 $(Q) echo "$(GRPC_PC_FILE)" | tr , '\n' >$@
murgatroid998faab232015-06-30 17:24:21 -07001242
1243$(LIBDIR)/$(CONFIG)/pkgconfig/grpc_unsecure.pc:
1244 $(E) "[MAKE] Generating $@"
1245 $(Q) mkdir -p $(@D)
Nicolas "Pixel" Noble367e30f2015-07-15 22:36:31 +02001246 $(Q) echo "$(GRPC_UNSECURE_PC_FILE)" | tr , '\n' >$@
murgatroid998faab232015-06-30 17:24:21 -07001247
Hongwei Wanga8cc4392015-07-16 17:37:47 -07001248$(LIBDIR)/$(CONFIG)/pkgconfig/grpc_zookeeper.pc:
1249 $(E) "[MAKE] Generating $@"
1250 $(Q) mkdir -p $(@D)
1251 $(Q) echo -e "$(GRPC_ZOOKEEPER_PC_FILE)" >$@
1252
murgatroid998faab232015-06-30 17:24:21 -07001253$(LIBDIR)/$(CONFIG)/pkgconfig/grpc++.pc:
1254 $(E) "[MAKE] Generating $@"
1255 $(Q) mkdir -p $(@D)
Nicolas "Pixel" Noble367e30f2015-07-15 22:36:31 +02001256 $(Q) echo "$(GRPCXX_PC_FILE)" | tr , '\n' >$@
murgatroid998faab232015-06-30 17:24:21 -07001257
1258$(LIBDIR)/$(CONFIG)/pkgconfig/grpc++_unsecure.pc:
1259 $(E) "[MAKE] Generating $@"
1260 $(Q) mkdir -p $(@D)
Nicolas "Pixel" Noble367e30f2015-07-15 22:36:31 +02001261 $(Q) echo "$(GRPCXX_UNSECURE_PC_FILE)" | tr , '\n' >$@
murgatroid998faab232015-06-30 17:24:21 -07001262
nnoble72309c62014-12-12 11:42:26 -08001263% for p in protos:
Nicolas Noble53830622015-02-12 16:56:38 -08001264ifeq ($(NO_PROTOC),true)
Craig Tiller61b910f2015-02-15 10:54:07 -08001265$(GENDIR)/${p}.pb.cc: protoc_dep_error
Nicolas "Pixel" Noble0caebbf2015-04-09 23:08:51 +02001266$(GENDIR)/${p}.grpc.pb.cc: protoc_dep_error
Nicolas Noble53830622015-02-12 16:56:38 -08001267else
Craig Tiller61b910f2015-02-15 10:54:07 -08001268$(GENDIR)/${p}.pb.cc: ${p}.proto $(PROTOBUF_DEP) $(PROTOC_PLUGINS)
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001269 $(E) "[PROTOC] Generating protobuf CC file from $<"
1270 $(Q) mkdir -p `dirname $@`
Nicolas "Pixel" Noble0caebbf2015-04-09 23:08:51 +02001271 $(Q) $(PROTOC) --cpp_out=$(GENDIR) $<
1272
1273$(GENDIR)/${p}.grpc.pb.cc: ${p}.proto $(PROTOBUF_DEP) $(PROTOC_PLUGINS)
1274 $(E) "[GRPC] Generating gRPC's protobuf service CC file from $<"
1275 $(Q) mkdir -p `dirname $@`
1276 $(Q) $(PROTOC) --grpc_out=$(GENDIR) --plugin=protoc-gen-grpc=$(BINDIR)/$(CONFIG)/grpc_cpp_plugin $<
Nicolas Noble53830622015-02-12 16:56:38 -08001277endif
nnoble72309c62014-12-12 11:42:26 -08001278
1279% endfor
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001280
David Garcia Quintasbbc0b772015-04-29 14:10:05 -07001281ifeq ($(CONFIG),stapprof)
1282src/core/profiling/stap_timers.c: $(GENDIR)/src/core/profiling/stap_probes.h
David Garcia Quintas611b7362015-04-27 15:49:31 -07001283ifeq ($(HAS_SYSTEMTAP),true)
1284$(GENDIR)/src/core/profiling/stap_probes.h: src/core/profiling/stap_probes.d
1285 $(E) "[DTRACE] Compiling $<"
1286 $(Q) mkdir -p `dirname $@`
1287 $(Q) $(DTRACE) -C -h -s $< -o $@
David Garcia Quintas8954e902015-04-29 09:46:33 -07001288else
1289$(GENDIR)/src/core/profiling/stap_probes.h: systemtap_dep_error stop
1290endif
David Garcia Quintas611b7362015-04-27 15:49:31 -07001291endif
1292
Craig Tiller61b910f2015-02-15 10:54:07 -08001293$(OBJDIR)/$(CONFIG)/%.o : %.c
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001294 $(E) "[C] Compiling $<"
1295 $(Q) mkdir -p `dirname $@`
Craig Tiller12c82092015-01-15 08:45:56 -08001296 $(Q) $(CC) $(CFLAGS) $(CPPFLAGS) -MMD -MF $(addsuffix .dep, $(basename $@)) -c -o $@ $<
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001297
Craig Tiller61b910f2015-02-15 10:54:07 -08001298$(OBJDIR)/$(CONFIG)/%.o : $(GENDIR)/%.pb.cc
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001299 $(E) "[CXX] Compiling $<"
1300 $(Q) mkdir -p `dirname $@`
Craig Tiller12c82092015-01-15 08:45:56 -08001301 $(Q) $(CXX) $(CXXFLAGS) $(CPPFLAGS) -MMD -MF $(addsuffix .dep, $(basename $@)) -c -o $@ $<
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001302
Craig Tiller61b910f2015-02-15 10:54:07 -08001303$(OBJDIR)/$(CONFIG)/src/compiler/%.o : src/compiler/%.cc
nnoble72309c62014-12-12 11:42:26 -08001304 $(E) "[HOSTCXX] Compiling $<"
1305 $(Q) mkdir -p `dirname $@`
Craig Tiller12c82092015-01-15 08:45:56 -08001306 $(Q) $(HOST_CXX) $(HOST_CXXFLAGS) $(HOST_CPPFLAGS) -MMD -MF $(addsuffix .dep, $(basename $@)) -c -o $@ $<
nnoble72309c62014-12-12 11:42:26 -08001307
Craig Tiller61b910f2015-02-15 10:54:07 -08001308$(OBJDIR)/$(CONFIG)/%.o : %.cc
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001309 $(E) "[CXX] Compiling $<"
1310 $(Q) mkdir -p `dirname $@`
Craig Tiller12c82092015-01-15 08:45:56 -08001311 $(Q) $(CXX) $(CXXFLAGS) $(CPPFLAGS) -MMD -MF $(addsuffix .dep, $(basename $@)) -c -o $@ $<
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001312
Nicolas "Pixel" Noble161ea232015-02-22 05:48:53 +01001313install: install_c install_cxx install-plugins install-certs verify-install
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001314
nnoble85a49262014-12-08 18:14:03 -08001315install_c: install-headers_c install-static_c install-shared_c
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001316
nnoble85a49262014-12-08 18:14:03 -08001317install_cxx: install-headers_cxx install-static_cxx install-shared_cxx
1318
Jan Tattermusch2ec0b3e2015-02-18 15:03:12 -08001319install_csharp: install-shared_csharp install_c
1320
1321install_grpc_csharp_ext: install_csharp
1322
nnoble85a49262014-12-08 18:14:03 -08001323install-headers: install-headers_c install-headers_cxx
1324
1325install-headers_c:
1326 $(E) "[INSTALL] Installing public C headers"
Nicolas "Pixel" Noble932d5d32015-02-21 02:15:34 +01001327 $(Q) $(foreach h, $(PUBLIC_HEADERS_C), $(INSTALL) -d $(prefix)/$(dir $(h)) && ) exit 0 || exit 1
nnoble85a49262014-12-08 18:14:03 -08001328 $(Q) $(foreach h, $(PUBLIC_HEADERS_C), $(INSTALL) $(h) $(prefix)/$(h) && ) exit 0 || exit 1
1329
1330install-headers_cxx:
1331 $(E) "[INSTALL] Installing public C++ headers"
Nicolas "Pixel" Noble932d5d32015-02-21 02:15:34 +01001332 $(Q) $(foreach h, $(PUBLIC_HEADERS_CXX), $(INSTALL) -d $(prefix)/$(dir $(h)) && ) exit 0 || exit 1
nnoble85a49262014-12-08 18:14:03 -08001333 $(Q) $(foreach h, $(PUBLIC_HEADERS_CXX), $(INSTALL) $(h) $(prefix)/$(h) && ) exit 0 || exit 1
1334
1335install-static: install-static_c install-static_cxx
1336
murgatroid998faab232015-06-30 17:24:21 -07001337install-static_c: static_c strip-static_c install-pkg-config_c
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001338% for lib in libs:
Craig Tiller59140fc2015-01-18 10:12:17 -08001339% if lib.language == "c":
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001340% if lib.build == "all":
Hongwei Wanga8cc4392015-07-16 17:37:47 -07001341% if not lib.get('external_deps', None):
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001342 $(E) "[INSTALL] Installing lib${lib.name}.a"
Nicolas "Pixel" Noble932d5d32015-02-21 02:15:34 +01001343 $(Q) $(INSTALL) -d $(prefix)/lib
Craig Tiller61b910f2015-02-15 10:54:07 -08001344 $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/lib${lib.name}.a $(prefix)/lib/lib${lib.name}.a
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001345% endif
nnoble85a49262014-12-08 18:14:03 -08001346% endif
Hongwei Wanga8cc4392015-07-16 17:37:47 -07001347% endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001348% endfor
Hongwei Wanga8cc4392015-07-16 17:37:47 -07001349ifeq ($(HAS_ZOOKEEPER),true)
1350% for lib in libs:
1351% if lib.language == "c":
1352% if lib.build == "all":
1353% if 'zookeeper' in lib.get('external_deps', []):
1354 $(E) "[INSTALL] Installing lib${lib.name}.a"
1355 $(Q) $(INSTALL) -d $(prefix)/lib
1356 $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/lib${lib.name}.a $(prefix)/lib/lib${lib.name}.a
1357% endif
1358% endif
1359% endif
1360% endfor
1361endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001362
murgatroid998faab232015-06-30 17:24:21 -07001363install-static_cxx: static_cxx strip-static_cxx install-pkg-config_cxx
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001364% for lib in libs:
Craig Tiller59140fc2015-01-18 10:12:17 -08001365% if lib.language == "c++":
nnoble85a49262014-12-08 18:14:03 -08001366% if lib.build == "all":
1367 $(E) "[INSTALL] Installing lib${lib.name}.a"
Nicolas "Pixel" Noble932d5d32015-02-21 02:15:34 +01001368 $(Q) $(INSTALL) -d $(prefix)/lib
Craig Tiller61b910f2015-02-15 10:54:07 -08001369 $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/lib${lib.name}.a $(prefix)/lib/lib${lib.name}.a
nnoble85a49262014-12-08 18:14:03 -08001370% endif
1371% endif
1372% endfor
1373
Nicolas "Pixel" Noble522d7122015-02-19 01:28:02 +01001374<%def name="install_shared(lang_filter)">\
nnoble85a49262014-12-08 18:14:03 -08001375% for lib in libs:
Nicolas "Pixel" Noble522d7122015-02-19 01:28:02 +01001376% if lib.language == lang_filter:
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001377% if lib.build == "all":
Hongwei Wanga8cc4392015-07-16 17:37:47 -07001378% if not lib.get('external_deps', None):
nnoble5b7f32a2014-12-22 08:12:44 -08001379ifeq ($(SYSTEM),MINGW32)
1380 $(E) "[INSTALL] Installing ${lib.name}.$(SHARED_EXT)"
Nicolas "Pixel" Noble932d5d32015-02-21 02:15:34 +01001381 $(Q) $(INSTALL) -d $(prefix)/lib
Craig Tiller61b910f2015-02-15 10:54:07 -08001382 $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/${lib.name}.$(SHARED_EXT) $(prefix)/lib/${lib.name}.$(SHARED_EXT)
1383 $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/lib${lib.name}-imp.a $(prefix)/lib/lib${lib.name}-imp.a
nnoble5b7f32a2014-12-22 08:12:44 -08001384else
1385 $(E) "[INSTALL] Installing lib${lib.name}.$(SHARED_EXT)"
Nicolas "Pixel" Noble932d5d32015-02-21 02:15:34 +01001386 $(Q) $(INSTALL) -d $(prefix)/lib
Craig Tiller61b910f2015-02-15 10:54:07 -08001387 $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/lib${lib.name}.$(SHARED_EXT) $(prefix)/lib/lib${lib.name}.$(SHARED_EXT)
Masood Malekghassemid1be74f2015-04-07 16:23:09 -07001388ifneq ($(SYSTEM),Darwin)
Tim Emiola820e3d62015-04-10 09:11:50 -07001389 $(Q) ln -sf lib${lib.name}.$(SHARED_EXT) $(prefix)/lib/lib${lib.name}.so.${settings.version.major}
nnoble5b7f32a2014-12-22 08:12:44 -08001390 $(Q) ln -sf lib${lib.name}.$(SHARED_EXT) $(prefix)/lib/lib${lib.name}.so
1391endif
1392endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001393% endif
nnoble85a49262014-12-08 18:14:03 -08001394% endif
Hongwei Wanga8cc4392015-07-16 17:37:47 -07001395% endif
nnoble85a49262014-12-08 18:14:03 -08001396% endfor
Hongwei Wanga8cc4392015-07-16 17:37:47 -07001397ifeq ($(HAS_ZOOKEEPER),true)
1398% for lib in libs:
1399% if lib.language == lang_filter:
1400% if lib.build == "all":
1401% if 'zookeeper' in lib.get('external_deps', []):
1402ifeq ($(SYSTEM),MINGW32)
1403 $(E) "[INSTALL] Installing ${lib.name}.$(SHARED_EXT)"
1404 $(Q) $(INSTALL) -d $(prefix)/lib
1405 $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/${lib.name}.$(SHARED_EXT) $(prefix)/lib/${lib.name}.$(SHARED_EXT)
1406 $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/lib${lib.name}-imp.a $(prefix)/lib/lib${lib.name}-imp.a
1407else
1408 $(E) "[INSTALL] Installing lib${lib.name}.$(SHARED_EXT)"
1409 $(Q) $(INSTALL) -d $(prefix)/lib
1410 $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/lib${lib.name}.$(SHARED_EXT) $(prefix)/lib/lib${lib.name}.$(SHARED_EXT)
1411ifneq ($(SYSTEM),Darwin)
1412 $(Q) ln -sf lib${lib.name}.$(SHARED_EXT) $(prefix)/lib/lib${lib.name}.so.${settings.version.major}
1413 $(Q) ln -sf lib${lib.name}.$(SHARED_EXT) $(prefix)/lib/lib${lib.name}.so
1414endif
1415endif
1416% endif
1417% endif
1418% endif
1419% endfor
1420endif
nnoble5b7f32a2014-12-22 08:12:44 -08001421ifneq ($(SYSTEM),MINGW32)
1422ifneq ($(SYSTEM),Darwin)
Nicolas "Pixel" Noblecc2b42a2015-02-20 00:42:21 +01001423 $(Q) ldconfig || true
nnoble5b7f32a2014-12-22 08:12:44 -08001424endif
1425endif
Nicolas "Pixel" Noble522d7122015-02-19 01:28:02 +01001426</%def>
nnoble85a49262014-12-08 18:14:03 -08001427
murgatroid998faab232015-06-30 17:24:21 -07001428install-shared_c: shared_c strip-shared_c install-pkg-config_c
Nicolas "Pixel" Noble522d7122015-02-19 01:28:02 +01001429${install_shared("c")}
1430
murgatroid998faab232015-06-30 17:24:21 -07001431install-shared_cxx: shared_cxx strip-shared_cxx install-shared_c install-pkg-config_cxx
Nicolas "Pixel" Noble522d7122015-02-19 01:28:02 +01001432${install_shared("c++")}
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001433
Jan Tattermusch2ec0b3e2015-02-18 15:03:12 -08001434install-shared_csharp: shared_csharp strip-shared_csharp
Nicolas "Pixel" Noble522d7122015-02-19 01:28:02 +01001435${install_shared("csharp")}
1436
Nicolas "Pixel" Noble522d7122015-02-19 01:28:02 +01001437install-plugins: $(PROTOC_PLUGINS)
1438ifeq ($(SYSTEM),MINGW32)
1439 $(Q) false
1440else
1441 $(E) "[INSTALL] Installing grpc protoc plugins"
1442% for tgt in targets:
1443% if tgt.build == 'protoc':
Nicolas "Pixel" Noble932d5d32015-02-21 02:15:34 +01001444 $(Q) $(INSTALL) -d $(prefix)/bin
Nicolas "Pixel" Noble522d7122015-02-19 01:28:02 +01001445 $(Q) $(INSTALL) $(BINDIR)/$(CONFIG)/${tgt.name} $(prefix)/bin/${tgt.name}
1446% endif
1447% endfor
1448endif
Jan Tattermusch2ec0b3e2015-02-18 15:03:12 -08001449
Hongwei Wanga3780a82015-07-17 15:27:18 -07001450install-pkg-config_c: pc_gpr pc_c pc_c_unsecure pc_c_zookeeper
murgatroid998faab232015-06-30 17:24:21 -07001451 $(E) "[INSTALL] Installing C pkg-config files"
1452 $(Q) $(INSTALL) -d $(prefix)/lib/pkgconfig
1453 $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/pkgconfig/gpr.pc $(prefix)/lib/pkgconfig/gpr.pc
1454 $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/pkgconfig/grpc.pc $(prefix)/lib/pkgconfig/grpc.pc
1455 $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/pkgconfig/grpc_unsecure.pc $(prefix)/lib/pkgconfig/grpc_unsecure.pc
Hongwei Wanga3780a82015-07-17 15:27:18 -07001456ifeq ($(HAS_ZOOKEEPER),true)
Hongwei Wanga8cc4392015-07-16 17:37:47 -07001457 $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/pkgconfig/grpc_zookeeper.pc $(prefix)/lib/pkgconfig/grpc_zookeeper.pc
Hongwei Wanga3780a82015-07-17 15:27:18 -07001458endif
murgatroid998faab232015-06-30 17:24:21 -07001459
1460install-pkg-config_cxx: pc_cxx pc_cxx_unsecure
1461 $(E) "[INSTALL] Installing C++ pkg-config files"
1462 $(Q) $(INSTALL) -d $(prefix)/lib/pkgconfig
1463 $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/pkgconfig/grpc++.pc $(prefix)/lib/pkgconfig/grpc++.pc
1464 $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/pkgconfig/grpc++_unsecure.pc $(prefix)/lib/pkgconfig/grpc++_unsecure.pc
1465
Nicolas "Pixel" Noble161ea232015-02-22 05:48:53 +01001466install-certs: etc/roots.pem
1467 $(E) "[INSTALL] Installing root certificates"
1468 $(Q) $(INSTALL) -d $(prefix)/share/grpc
1469 $(Q) $(INSTALL) etc/roots.pem $(prefix)/share/grpc/roots.pem
1470
Nicolas "Pixel" Noble98ab9982015-02-21 04:22:16 +01001471verify-install:
Nicolas "Pixel" Noble2c23a722015-02-24 20:17:45 +01001472ifeq ($(INSTALL_OK),true)
Nicolas "Pixel" Noble98ab9982015-02-21 04:22:16 +01001473 @echo "Your system looks ready to go."
1474 @echo
1475else
murgatroid99b6181362015-03-02 14:32:25 -08001476 @echo "We couldn't find protoc 3.0.0+ installed on your system. While this"
Nicolas "Pixel" Noble98ab9982015-02-21 04:22:16 +01001477 @echo "won't prevent grpc from working, you won't be able to compile"
1478 @echo "and run any meaningful code with it."
1479 @echo
1480 @echo
1481 @echo "Please download and install protobuf 3.0.0+ from:"
1482 @echo
1483 @echo " https://github.com/google/protobuf/releases"
1484 @echo
murgatroid99b6181362015-03-02 14:32:25 -08001485 @echo "Once you've done so, or if you think this message is in error,"
1486 @echo "you can re-run this check by doing:"
Nicolas "Pixel" Noble98ab9982015-02-21 04:22:16 +01001487 @echo
1488 @echo " make verify-install"
1489endif
1490
Craig Tiller3759e6f2015-01-15 08:13:11 -08001491clean:
Nicolas "Pixel" Noble522d7122015-02-19 01:28:02 +01001492 $(E) "[CLEAN] Cleaning build directories."
murgatroid99aa521572015-07-10 14:49:12 -07001493 $(Q) $(RM) -rf $(OBJDIR) $(LIBDIR) $(BINDIR) $(GENDIR) cache.mk
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001494
1495
1496# The various libraries
1497
1498% for lib in libs:
1499${makelib(lib)}
1500% endfor
1501
1502
nnoble69ac39f2014-12-12 15:43:38 -08001503# All of the test targets, and protoc plugins
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001504
1505% for tgt in targets:
1506${maketarget(tgt)}
1507% endfor
1508
1509<%def name="makelib(lib)">
1510LIB${lib.name.upper()}_SRC = \\
1511
1512% for src in lib.src:
nnoble72309c62014-12-12 11:42:26 -08001513 ${proto_to_cc(src)} \\
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001514
1515% endfor
1516
1517% if "public_headers" in lib:
Craig Tiller59140fc2015-01-18 10:12:17 -08001518% if lib.language == "c++":
nnoble85a49262014-12-08 18:14:03 -08001519PUBLIC_HEADERS_CXX += \\
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001520
nnoble85a49262014-12-08 18:14:03 -08001521% else:
1522PUBLIC_HEADERS_C += \\
1523
1524% endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001525% for hdr in lib.public_headers:
1526 ${hdr} \\
1527
1528% endfor
1529% endif
1530
Craig Tiller61b910f2015-02-15 10:54:07 -08001531LIB${lib.name.upper()}_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(LIB${lib.name.upper()}_SRC))))
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001532
Nicolas "Pixel" Noble4cc8c8a2015-06-23 02:37:49 +02001533## If the library requires OpenSSL, let's add some restrictions.
Nicolas "Pixel" Noble061690d2015-03-06 22:58:58 +01001534% if lib.get('secure', 'check') == 'yes' or lib.get('secure', 'check') == 'check':
nnoble69ac39f2014-12-12 15:43:38 -08001535ifeq ($(NO_SECURE),true)
1536
Nicolas "Pixel" Noble4cc8c8a2015-06-23 02:37:49 +02001537# You can't build secure libraries if you don't have OpenSSL.
Nicolas Noble047b7272015-01-16 13:55:05 -08001538
Craig Tiller61b910f2015-02-15 10:54:07 -08001539$(LIBDIR)/$(CONFIG)/lib${lib.name}.a: openssl_dep_error
nnoble69ac39f2014-12-12 15:43:38 -08001540
nnoble5b7f32a2014-12-22 08:12:44 -08001541% if lib.build == "all":
1542ifeq ($(SYSTEM),MINGW32)
Craig Tiller61b910f2015-02-15 10:54:07 -08001543$(LIBDIR)/$(CONFIG)/${lib.name}.$(SHARED_EXT): openssl_dep_error
nnoble5b7f32a2014-12-22 08:12:44 -08001544else
Craig Tiller61b910f2015-02-15 10:54:07 -08001545$(LIBDIR)/$(CONFIG)/lib${lib.name}.$(SHARED_EXT): openssl_dep_error
nnoble5b7f32a2014-12-22 08:12:44 -08001546endif
1547% endif
1548
nnoble69ac39f2014-12-12 15:43:38 -08001549else
1550
Nicolas Noble53830622015-02-12 16:56:38 -08001551% if lib.language == 'c++':
1552ifeq ($(NO_PROTOBUF),true)
1553
1554# You can't build a C++ library if you don't have protobuf - a bit overreached, but still okay.
1555
Craig Tiller61b910f2015-02-15 10:54:07 -08001556$(LIBDIR)/$(CONFIG)/lib${lib.name}.a: protobuf_dep_error
Nicolas Noble53830622015-02-12 16:56:38 -08001557
1558% if lib.build == "all":
1559ifeq ($(SYSTEM),MINGW32)
Craig Tiller61b910f2015-02-15 10:54:07 -08001560$(LIBDIR)/$(CONFIG)/${lib.name}.$(SHARED_EXT): protobuf_dep_error
Nicolas Noble53830622015-02-12 16:56:38 -08001561else
Craig Tiller61b910f2015-02-15 10:54:07 -08001562$(LIBDIR)/$(CONFIG)/lib${lib.name}.$(SHARED_EXT): protobuf_dep_error
Nicolas Noble53830622015-02-12 16:56:38 -08001563endif
1564% endif
1565
1566else
1567% endif
1568
Craig Tiller61b910f2015-02-15 10:54:07 -08001569$(LIBDIR)/$(CONFIG)/lib${lib.name}.a: $(ZLIB_DEP) $(OPENSSL_DEP)\
Nicolas Noble047b7272015-01-16 13:55:05 -08001570## The else here corresponds to the if secure earlier.
nnoble20e2e3f2014-12-16 15:37:57 -08001571% else:
Nicolas Noble53830622015-02-12 16:56:38 -08001572% if lib.language == 'c++':
1573ifeq ($(NO_PROTOBUF),true)
1574
1575# You can't build a C++ library if you don't have protobuf - a bit overreached, but still okay.
1576
Craig Tiller61b910f2015-02-15 10:54:07 -08001577$(LIBDIR)/$(CONFIG)/lib${lib.name}.a: protobuf_dep_error
Nicolas Noble53830622015-02-12 16:56:38 -08001578
1579% if lib.build == "all":
1580ifeq ($(SYSTEM),MINGW32)
Craig Tiller61b910f2015-02-15 10:54:07 -08001581$(LIBDIR)/$(CONFIG)/${lib.name}.$(SHARED_EXT): protobuf_dep_error
Nicolas Noble53830622015-02-12 16:56:38 -08001582else
Craig Tiller61b910f2015-02-15 10:54:07 -08001583$(LIBDIR)/$(CONFIG)/lib${lib.name}.$(SHARED_EXT): protobuf_dep_error
Nicolas Noble53830622015-02-12 16:56:38 -08001584endif
nnoble20e2e3f2014-12-16 15:37:57 -08001585% endif
Nicolas Noble53830622015-02-12 16:56:38 -08001586
1587else
1588
1589% endif
Craig Tiller61b910f2015-02-15 10:54:07 -08001590$(LIBDIR)/$(CONFIG)/lib${lib.name}.a: $(ZLIB_DEP)\
Nicolas Noble53830622015-02-12 16:56:38 -08001591% endif
1592% if lib.language == 'c++':
1593 $(PROTOBUF_DEP)\
1594% endif
1595 $(LIB${lib.name.upper()}_OBJS)
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001596 $(E) "[AR] Creating $@"
nnoble85a49262014-12-08 18:14:03 -08001597 $(Q) mkdir -p `dirname $@`
Craig Tiller61b910f2015-02-15 10:54:07 -08001598 $(Q) rm -f $(LIBDIR)/$(CONFIG)/lib${lib.name}.a
1599 $(Q) $(AR) rcs $(LIBDIR)/$(CONFIG)/lib${lib.name}.a $(LIB${lib.name.upper()}_OBJS)
nnoble20e2e3f2014-12-16 15:37:57 -08001600% if lib.get('baselib', False):
Nicolas "Pixel" Noble061690d2015-03-06 22:58:58 +01001601% if lib.get('secure', 'check') == 'yes':
Craig Tiller7ab4fee2015-02-24 08:15:53 -08001602 $(Q) rm -rf tmp-merge-${lib.name}
1603 $(Q) mkdir tmp-merge-${lib.name}
1604 $(Q) ( cd tmp-merge-${lib.name} ; $(AR) x ../$(LIBDIR)/$(CONFIG)/lib${lib.name}.a )
1605 $(Q) for l in $(OPENSSL_MERGE_LIBS) ; do ( cd tmp-merge-${lib.name} ; <%text>ar x ../$${l}</%text> ) ; done
1606 $(Q) rm -f $(LIBDIR)/$(CONFIG)/lib${lib.name}.a tmp-merge-${lib.name}/__.SYMDEF*
1607 $(Q) ar rcs $(LIBDIR)/$(CONFIG)/lib${lib.name}.a tmp-merge-${lib.name}/*
1608 $(Q) rm -rf tmp-merge-${lib.name}
nnoble20e2e3f2014-12-16 15:37:57 -08001609% endif
1610% endif
Craig Tillerb4ee3b52015-01-21 16:22:50 -08001611ifeq ($(SYSTEM),Darwin)
murgatroid99b6181362015-03-02 14:32:25 -08001612 $(Q) ranlib $(LIBDIR)/$(CONFIG)/lib${lib.name}.a
Craig Tillerb4ee3b52015-01-21 16:22:50 -08001613endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001614
nnoble5b7f32a2014-12-22 08:12:44 -08001615<%
Nicolas "Pixel" Noble010f1e72015-04-23 02:23:49 +02001616
Craig Tiller59140fc2015-01-18 10:12:17 -08001617 if lib.language == 'c++':
nnoble5b7f32a2014-12-22 08:12:44 -08001618 ld = '$(LDXX)'
1619 else:
1620 ld = '$(LD)'
1621
Craig Tillerda224d62015-02-15 11:01:58 -08001622 out_base = '$(LIBDIR)/$(CONFIG)/' + lib.name
1623 out_libbase = '$(LIBDIR)/$(CONFIG)/lib' + lib.name
nnoble5b7f32a2014-12-22 08:12:44 -08001624
1625 common = '$(LIB' + lib.name.upper() + '_OBJS) $(LDLIBS)'
1626
1627 libs = ''
Nicolas "Pixel" Noble85bf09b2015-01-15 18:22:40 +01001628 lib_deps = ' $(ZLIB_DEP)'
nnoble5b7f32a2014-12-22 08:12:44 -08001629 mingw_libs = ''
Nicolas "Pixel" Noble85bf09b2015-01-15 18:22:40 +01001630 mingw_lib_deps = ' $(ZLIB_DEP)'
Michael Berlinbf2e7f02015-05-01 16:17:01 -07001631 if lib.language == 'c++':
1632 lib_deps += ' $(PROTOBUF_DEP)'
1633 mingw_lib_deps += ' $(PROTOBUF_DEP)'
nnoble5b7f32a2014-12-22 08:12:44 -08001634 for dep in lib.get('deps', []):
1635 libs = libs + ' -l' + dep
Craig Tiller61b910f2015-02-15 10:54:07 -08001636 lib_deps = lib_deps + ' $(LIBDIR)/$(CONFIG)/lib' + dep + '.$(SHARED_EXT)'
nnoble5b7f32a2014-12-22 08:12:44 -08001637 mingw_libs = mingw_libs + ' -l' + dep + '-imp'
Michael Berlin53513922015-05-01 16:14:15 -07001638 mingw_lib_deps = mingw_lib_deps + ' $(LIBDIR)/$(CONFIG)/' + dep + '.$(SHARED_EXT)'
nnoble5b7f32a2014-12-22 08:12:44 -08001639
Nicolas "Pixel" Noblea7c162c2015-07-24 20:21:51 +02001640 security = lib.get('secure', 'check')
1641 if security == 'yes':
Nicolas "Pixel" Noble945b4132015-06-02 20:13:40 +02001642 common = common + ' $(OPENSSL_MERGE_LIBS) $(LDLIBS_SECURE)'
Nicolas "Pixel" Noblea7c162c2015-07-24 20:21:51 +02001643
1644 if security in ['yes', 'check']:
Nicolas "Pixel" Noble010f1e72015-04-23 02:23:49 +02001645 for src in lib.src:
Nicolas "Pixel" Noblea7c162c2015-07-24 20:21:51 +02001646 if not proto_re.match(src):
1647 sources_that_need_openssl.add(src)
Nicolas "Pixel" Noble010f1e72015-04-23 02:23:49 +02001648 else:
1649 for src in lib.src:
1650 sources_that_don_t_need_openssl.add(src)
Nicolas "Pixel" Noble061690d2015-03-06 22:58:58 +01001651
Hongwei Wanga8cc4392015-07-16 17:37:47 -07001652 if 'zookeeper' in lib.get('external_deps', []):
1653 libs = libs + ' -lzookeeper_mt'
1654
Nicolas "Pixel" Noble061690d2015-03-06 22:58:58 +01001655 if lib.get('secure', 'check') == 'yes' or lib.get('secure', 'check') == 'check':
nnoble5b7f32a2014-12-22 08:12:44 -08001656 lib_deps = lib_deps + ' $(OPENSSL_DEP)'
1657 mingw_lib_deps = mingw_lib_deps + ' $(OPENSSL_DEP)'
Nicolas "Pixel" Nobledda049c2015-02-21 00:39:32 +01001658
1659 if lib.language == 'c++':
1660 common = common + ' $(LDLIBSXX) $(LDLIBS_PROTOBUF)'
nnoble5b7f32a2014-12-22 08:12:44 -08001661%>
1662
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001663% if lib.build == "all":
nnoble5b7f32a2014-12-22 08:12:44 -08001664ifeq ($(SYSTEM),MINGW32)
1665${out_base}.$(SHARED_EXT): $(LIB${lib.name.upper()}_OBJS) ${mingw_lib_deps}
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001666 $(E) "[LD] Linking $@"
nnoble85a49262014-12-08 18:14:03 -08001667 $(Q) mkdir -p `dirname $@`
Craig Tillerda224d62015-02-15 11:01:58 -08001668 $(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}
nnoble5b7f32a2014-12-22 08:12:44 -08001669else
1670${out_libbase}.$(SHARED_EXT): $(LIB${lib.name.upper()}_OBJS) ${lib_deps}
1671 $(E) "[LD] Linking $@"
1672 $(Q) mkdir -p `dirname $@`
1673ifeq ($(SYSTEM),Darwin)
Masood Malekghassemid1be74f2015-04-07 16:23:09 -07001674 $(Q) ${ld} $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -install_name lib${lib.name}.$(SHARED_EXT) -dynamiclib -o ${out_libbase}.$(SHARED_EXT) ${common}${libs}
nnoble5b7f32a2014-12-22 08:12:44 -08001675else
Craig Tillerda224d62015-02-15 11:01:58 -08001676 $(Q) ${ld} $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,-soname,lib${lib.name}.so.${settings.version.major} -o ${out_libbase}.$(SHARED_EXT) ${common}${libs}
Nicolas "Pixel" Nobled8f8b6b2015-01-29 21:29:43 +01001677 $(Q) ln -sf lib${lib.name}.$(SHARED_EXT) ${out_libbase}.so.${settings.version.major}
nnoble5b7f32a2014-12-22 08:12:44 -08001678 $(Q) ln -sf lib${lib.name}.$(SHARED_EXT) ${out_libbase}.so
1679endif
1680endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001681% endif
Nicolas "Pixel" Noble061690d2015-03-06 22:58:58 +01001682% if lib.get('secure', 'check') == 'yes' or lib.get('secure', 'check') == 'check':
Nicolas Noble047b7272015-01-16 13:55:05 -08001683## If the lib was secure, we have to close the Makefile's if that tested
Nicolas "Pixel" Noble4cc8c8a2015-06-23 02:37:49 +02001684## the presence of OpenSSL.
Nicolas Noble53830622015-02-12 16:56:38 -08001685
1686endif
1687% endif
1688% if lib.language == 'c++':
1689## If the lib was C++, we have to close the Makefile's if that tested
1690## the presence of protobuf 3.0.0+
nnoble69ac39f2014-12-12 15:43:38 -08001691
1692endif
1693% endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001694
Nicolas "Pixel" Noble061690d2015-03-06 22:58:58 +01001695% if lib.get('secure', 'check') == 'yes' or lib.get('secure', 'check') == 'check':
nnoble69ac39f2014-12-12 15:43:38 -08001696ifneq ($(NO_SECURE),true)
1697% endif
1698ifneq ($(NO_DEPS),true)
Craig Tiller8f126a62015-01-15 08:50:19 -08001699-include $(LIB${lib.name.upper()}_OBJS:.o=.dep)
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001700endif
Nicolas "Pixel" Noble061690d2015-03-06 22:58:58 +01001701% if lib.get('secure', 'check') == 'yes' or lib.get('secure', 'check') == 'check':
nnoble69ac39f2014-12-12 15:43:38 -08001702endif
1703% endif
Craig Tiller27715ca2015-01-12 16:55:59 -08001704% for src in lib.src:
Craig Tillerd896fa52015-04-24 14:30:09 -07001705% if not proto_re.match(src) and any(proto_re.match(src2) for src2 in lib.src):
Craig Tiller04f81562015-04-24 14:34:30 -07001706$(OBJDIR)/$(CONFIG)/${os.path.splitext(src)[0]}.o: ${' '.join(proto_to_cc(src2) for src2 in lib.src if proto_re.match(src2))}
Craig Tiller27715ca2015-01-12 16:55:59 -08001707% endif
Craig Tiller27715ca2015-01-12 16:55:59 -08001708% endfor
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001709</%def>
1710
Nicolas "Pixel" Nobleadaa1002015-04-29 08:56:01 +02001711<%def name="maketarget(tgt)"><% has_no_sources = not tgt.src %>
1712% if not has_no_sources:
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001713${tgt.name.upper()}_SRC = \\
1714
1715% for src in tgt.src:
nnoble72309c62014-12-12 11:42:26 -08001716 ${proto_to_cc(src)} \\
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001717
1718% endfor
1719
Craig Tiller61b910f2015-02-15 10:54:07 -08001720${tgt.name.upper()}_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(${tgt.name.upper()}_SRC))))
Nicolas "Pixel" Nobleadaa1002015-04-29 08:56:01 +02001721% endif
Nicolas "Pixel" Noble061690d2015-03-06 22:58:58 +01001722% if tgt.get('secure', 'check') == 'yes' or tgt.get('secure', 'check') == 'check':
nnoble69ac39f2014-12-12 15:43:38 -08001723ifeq ($(NO_SECURE),true)
1724
Nicolas "Pixel" Noble4cc8c8a2015-06-23 02:37:49 +02001725# You can't build secure targets if you don't have OpenSSL.
Nicolas Noble047b7272015-01-16 13:55:05 -08001726
Craig Tiller61b910f2015-02-15 10:54:07 -08001727$(BINDIR)/$(CONFIG)/${tgt.name}: openssl_dep_error
nnoble69ac39f2014-12-12 15:43:38 -08001728
1729else
1730
1731% endif
Nicolas Noble047b7272015-01-16 13:55:05 -08001732##
1733## We're not trying to add a dependency on building zlib and openssl here,
1734## as it's already done in the libraries. We're assuming that the build
1735## trickles down, and that a secure target requires a secure version of
1736## a library.
1737##
1738## That simplifies the codegen a bit, but prevents a fully defined Makefile.
1739## I can live with that.
1740##
Nicolas "Pixel" Noble18953e32015-02-27 02:41:11 +01001741% if tgt.build == 'protoc' or tgt.language == 'c++':
Nicolas Noble53830622015-02-12 16:56:38 -08001742
1743ifeq ($(NO_PROTOBUF),true)
1744
Nicolas "Pixel" Noble18953e32015-02-27 02:41:11 +01001745# 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 -08001746
Craig Tiller61b910f2015-02-15 10:54:07 -08001747$(BINDIR)/$(CONFIG)/${tgt.name}: protobuf_dep_error
Nicolas Noble53830622015-02-12 16:56:38 -08001748
1749else
1750
Nicolas "Pixel" Nobleadaa1002015-04-29 08:56:01 +02001751$(BINDIR)/$(CONFIG)/${tgt.name}: \
1752% if not has_no_sources:
1753$(PROTOBUF_DEP) $(${tgt.name.upper()}_OBJS)\
1754% endif
Nicolas Noble53830622015-02-12 16:56:38 -08001755% else:
Nicolas "Pixel" Nobleadaa1002015-04-29 08:56:01 +02001756$(BINDIR)/$(CONFIG)/${tgt.name}: \
1757% if not has_no_sources:
1758$(${tgt.name.upper()}_OBJS)\
1759% endif
Nicolas Noble53830622015-02-12 16:56:38 -08001760% endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001761% for dep in tgt.deps:
Craig Tiller61b910f2015-02-15 10:54:07 -08001762 $(LIBDIR)/$(CONFIG)/lib${dep}.a\
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001763% endfor
1764
Craig Tiller59140fc2015-01-18 10:12:17 -08001765% if tgt.language == "c++":
Nicolas Noble047b7272015-01-16 13:55:05 -08001766## C++ targets specificies.
nnoble72309c62014-12-12 11:42:26 -08001767% if tgt.build == 'protoc':
1768 $(E) "[HOSTLD] Linking $@"
1769 $(Q) mkdir -p `dirname $@`
Nicolas "Pixel" Nobleadaa1002015-04-29 08:56:01 +02001770 $(Q) $(HOST_LDXX) $(HOST_LDFLAGS) \
1771% if not has_no_sources:
1772$(${tgt.name.upper()}_OBJS)\
1773% endif
nnoble72309c62014-12-12 11:42:26 -08001774% else:
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001775 $(E) "[LD] Linking $@"
nnoble85a49262014-12-08 18:14:03 -08001776 $(Q) mkdir -p `dirname $@`
Nicolas "Pixel" Nobleadaa1002015-04-29 08:56:01 +02001777 $(Q) $(LDXX) $(LDFLAGS) \
1778% if not has_no_sources:
1779$(${tgt.name.upper()}_OBJS)\
1780% endif
nnoble72309c62014-12-12 11:42:26 -08001781% endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001782% else:
Nicolas Noble047b7272015-01-16 13:55:05 -08001783## C-only targets specificities.
nnoble72309c62014-12-12 11:42:26 -08001784 $(E) "[LD] Linking $@"
1785 $(Q) mkdir -p `dirname $@`
Nicolas "Pixel" Nobleadaa1002015-04-29 08:56:01 +02001786 $(Q) $(LD) $(LDFLAGS) \
1787% if not has_no_sources:
1788$(${tgt.name.upper()}_OBJS)\
1789% endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001790% endif
1791% for dep in tgt.deps:
Craig Tiller61b910f2015-02-15 10:54:07 -08001792 $(LIBDIR)/$(CONFIG)/lib${dep}.a\
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001793% endfor
Hongwei Wang8e04d412015-07-31 15:12:51 -07001794% if 'zookeeper' in tgt.get('external_deps', []):
1795 -lzookeeper_mt\
1796% endif
Craig Tiller59140fc2015-01-18 10:12:17 -08001797% if tgt.language == "c++":
nnoble72309c62014-12-12 11:42:26 -08001798% if tgt.build == 'protoc':
Nicolas Noble53830622015-02-12 16:56:38 -08001799 $(HOST_LDLIBSXX) $(HOST_LDLIBS_PROTOC)\
nnoble72309c62014-12-12 11:42:26 -08001800% else:
Nicolas Noble53830622015-02-12 16:56:38 -08001801 $(LDLIBSXX) $(LDLIBS_PROTOBUF)\
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001802% endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001803% endif
nnoblec78b3402014-12-11 16:06:57 -08001804% if tgt.build == 'protoc':
nnoble72309c62014-12-12 11:42:26 -08001805 $(HOST_LDLIBS)\
1806% else:
1807 $(LDLIBS)\
1808% endif
1809% if tgt.build == 'protoc':
1810 $(HOST_LDLIBS_PROTOC)\
Nicolas "Pixel" Noble061690d2015-03-06 22:58:58 +01001811% elif tgt.get('secure', 'check') == 'yes' or tgt.get('secure', 'check') == 'check':
nnoble72309c62014-12-12 11:42:26 -08001812 $(LDLIBS_SECURE)\
nnoblec78b3402014-12-11 16:06:57 -08001813% endif
Yang Gaob0b518e2015-04-13 14:53:25 -07001814% if tgt.language == 'c++' and tgt.build == 'test':
1815 $(GTEST_LIB)\
David Garcia Quintasaa52d0a2015-05-14 19:04:23 -07001816% elif tgt.language == 'c++' and tgt.build == 'benchmark':
1817 $(GTEST_LIB)\
Yang Gaob0b518e2015-04-13 14:53:25 -07001818% endif
Craig Tiller61b910f2015-02-15 10:54:07 -08001819 -o $(BINDIR)/$(CONFIG)/${tgt.name}
Nicolas "Pixel" Noble18953e32015-02-27 02:41:11 +01001820% if tgt.build == 'protoc' or tgt.language == 'c++':
Nicolas Noble53830622015-02-12 16:56:38 -08001821
1822endif
1823% endif
Nicolas "Pixel" Noble061690d2015-03-06 22:58:58 +01001824% if tgt.get('secure', 'check') == 'yes' or tgt.get('secure', 'check') == 'check':
nnoble69ac39f2014-12-12 15:43:38 -08001825
1826endif
1827% endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001828
Craig Tillerf5371ef2015-01-12 16:40:18 -08001829% for src in tgt.src:
Craig Tiller61b910f2015-02-15 10:54:07 -08001830$(OBJDIR)/$(CONFIG)/${os.path.splitext(src)[0]}.o: \
Craig Tillerf5371ef2015-01-12 16:40:18 -08001831% for dep in tgt.deps:
Craig Tiller61b910f2015-02-15 10:54:07 -08001832 $(LIBDIR)/$(CONFIG)/lib${dep}.a\
Craig Tillerf5371ef2015-01-12 16:40:18 -08001833% endfor
1834
1835% endfor
Nicolas "Pixel" Nobleadaa1002015-04-29 08:56:01 +02001836% if not has_no_sources:
Craig Tiller8f126a62015-01-15 08:50:19 -08001837deps_${tgt.name}: $(${tgt.name.upper()}_OBJS:.o=.dep)
Nicolas "Pixel" Nobleadaa1002015-04-29 08:56:01 +02001838% endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001839
Nicolas "Pixel" Nobleadaa1002015-04-29 08:56:01 +02001840% if not has_no_sources:
Nicolas "Pixel" Noble061690d2015-03-06 22:58:58 +01001841% if tgt.get('secure', 'check') == 'yes' or tgt.get('secure', 'check') == 'check':
nnoble69ac39f2014-12-12 15:43:38 -08001842ifneq ($(NO_SECURE),true)
1843% endif
1844ifneq ($(NO_DEPS),true)
Craig Tiller8f126a62015-01-15 08:50:19 -08001845-include $(${tgt.name.upper()}_OBJS:.o=.dep)
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001846endif
Nicolas "Pixel" Noble061690d2015-03-06 22:58:58 +01001847% if tgt.get('secure', 'check') == 'yes' or tgt.get('secure', 'check') == 'check':
nnoble69ac39f2014-12-12 15:43:38 -08001848endif
1849% endif
Nicolas "Pixel" Nobleadaa1002015-04-29 08:56:01 +02001850% endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001851</%def>
1852
Nicolas "Pixel" Noble010f1e72015-04-23 02:23:49 +02001853ifneq ($(OPENSSL_DEP),)
1854# This is to ensure the embedded OpenSSL is built beforehand, properly
1855# installing headers to their final destination on the drive. We need this
1856# otherwise parallel compilation will fail if a source is compiled first.
1857% for src in sorted(sources_that_need_openssl):
1858% if src not in sources_that_don_t_need_openssl:
1859${src}: $(OPENSSL_DEP)
1860% endif
1861% endfor
1862endif
1863
nnoble85a49262014-12-08 18:14:03 -08001864.PHONY: all strip tools \
nnoble69ac39f2014-12-12 15:43:38 -08001865dep_error openssl_dep_error openssl_dep_message git_update stop \
nnoble85a49262014-12-08 18:14:03 -08001866buildtests buildtests_c buildtests_cxx \
1867test test_c test_cxx \
1868install install_c install_cxx \
1869install-headers install-headers_c install-headers_cxx \
1870install-shared install-shared_c install-shared_cxx \
1871install-static install-static_c install-static_cxx \
1872strip strip-shared strip-static \
1873strip_c strip-shared_c strip-static_c \
1874strip_cxx strip-shared_cxx strip-static_cxx \
Craig Tillerf0afe502015-01-15 09:04:49 -08001875dep_c dep_cxx bins_dep_c bins_dep_cxx \
Craig Tiller12c82092015-01-15 08:45:56 -08001876clean