blob: 6530ea5eb236ac6ebd6a81231c2b4a0a95b99b45 [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)
Craig Tiller60287b62015-08-05 07:23:48 -0700285ifneq ($(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
294LIBS = m z
295ifneq ($(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)
Craig Tiller60287b62015-08-05 07:23:48 -0700307LIBS = 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)
Craig Tiller60287b62015-08-05 07:23:48 -0700312LIBS = m z pthread
Nicolas Noblef8681182015-03-18 14:25:44 -0700313LDFLAGS += -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
350
351CACHE_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
murgatroid9924e2f4a2015-06-29 11:12:01 -0700358
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)
439
Craig Tiller50524cc2015-01-29 23:00:00 -0800440ifndef REQUIRE_CUSTOM_LIBRARIES_$(CONFIG)
murgatroid99aa521572015-07-10 14:49:12 -0700441HAS_SYSTEM_PERFTOOLS ?= $(shell $(PERFTOOLS_CHECK_CMD) 2> /dev/null && echo true || echo false)
Craig Tiller297fafa2015-01-15 15:46:39 -0800442ifeq ($(HAS_SYSTEM_PERFTOOLS),true)
443DEFINES += GRPC_HAVE_PERFTOOLS
444LIBS += profiler
Nicolas "Pixel" Noble367e30f2015-07-15 22:36:31 +0200445CACHE_MK += HAS_SYSTEM_PERFTOOLS = true,
Craig Tiller297fafa2015-01-15 15:46:39 -0800446endif
Craig Tiller50524cc2015-01-29 23:00:00 -0800447endif
nnoble69ac39f2014-12-12 15:43:38 -0800448
Nicolas "Pixel" Noble98ab9982015-02-21 04:22:16 +0100449HAS_SYSTEM_PROTOBUF_VERIFY = $(shell $(PROTOBUF_CHECK_CMD) 2> /dev/null && echo true || echo false)
Craig Tillerc4da6b72015-01-15 08:01:14 -0800450ifndef REQUIRE_CUSTOM_LIBRARIES_$(CONFIG)
murgatroid99aa521572015-07-10 14:49:12 -0700451HAS_SYSTEM_OPENSSL_ALPN ?= $(shell $(OPENSSL_ALPN_CHECK_CMD) 2> /dev/null && echo true || echo false)
Nicolas "Pixel" Noble4cc8c8a2015-06-23 02:37:49 +0200452ifeq ($(HAS_SYSTEM_OPENSSL_ALPN),true)
453HAS_SYSTEM_OPENSSL_NPN = true
Nicolas "Pixel" Noble367e30f2015-07-15 22:36:31 +0200454CACHE_MK += HAS_SYSTEM_OPENSSL_ALPN = true,
Nicolas "Pixel" Noble4cc8c8a2015-06-23 02:37:49 +0200455else
murgatroid99aa521572015-07-10 14:49:12 -0700456HAS_SYSTEM_OPENSSL_NPN ?= $(shell $(OPENSSL_NPN_CHECK_CMD) 2> /dev/null && echo true || echo false)
Nicolas "Pixel" Noble4cc8c8a2015-06-23 02:37:49 +0200457endif
murgatroid99aa521572015-07-10 14:49:12 -0700458ifeq ($(HAS_SYSTEM_OPENSSL_NPN),true)
Nicolas "Pixel" Noble367e30f2015-07-15 22:36:31 +0200459CACHE_MK += HAS_SYSTEM_OPENSSL_NPN = true,
murgatroid99aa521572015-07-10 14:49:12 -0700460endif
461HAS_SYSTEM_ZLIB ?= $(shell $(ZLIB_CHECK_CMD) 2> /dev/null && echo true || echo false)
462ifeq ($(HAS_SYSTEM_ZLIB),true)
Nicolas "Pixel" Noble367e30f2015-07-15 22:36:31 +0200463CACHE_MK += HAS_SYSTEM_ZLIB = true,
murgatroid99aa521572015-07-10 14:49:12 -0700464endif
465HAS_SYSTEM_PROTOBUF ?= $(HAS_SYSTEM_PROTOBUF_VERIFY)
466ifeq ($(HAS_SYSTEM_PROTOBUF),true)
Nicolas "Pixel" Noble367e30f2015-07-15 22:36:31 +0200467CACHE_MK += HAS_SYSTEM_PROTOBUF = true,
murgatroid99aa521572015-07-10 14:49:12 -0700468endif
Craig Tillerc4da6b72015-01-15 08:01:14 -0800469else
470# override system libraries if the config requires a custom compiled library
471HAS_SYSTEM_OPENSSL_ALPN = false
Nicolas "Pixel" Noble4cc8c8a2015-06-23 02:37:49 +0200472HAS_SYSTEM_OPENSSL_NPN = false
Craig Tillerc4da6b72015-01-15 08:01:14 -0800473HAS_SYSTEM_ZLIB = false
Nicolas Noble53830622015-02-12 16:56:38 -0800474HAS_SYSTEM_PROTOBUF = false
Craig Tillerc4da6b72015-01-15 08:01:14 -0800475endif
nnoble69ac39f2014-12-12 15:43:38 -0800476
murgatroid99aa521572015-07-10 14:49:12 -0700477HAS_PROTOC ?= $(shell $(PROTOC_CHECK_CMD) 2> /dev/null && echo true || echo false)
Nicolas "Pixel" Noble98ab9982015-02-21 04:22:16 +0100478ifeq ($(HAS_PROTOC),true)
Nicolas "Pixel" Noble367e30f2015-07-15 22:36:31 +0200479CACHE_MK += HAS_PROTOC = true,
murgatroid99aa521572015-07-10 14:49:12 -0700480HAS_VALID_PROTOC ?= $(shell $(PROTOC_CHECK_VERSION_CMD) 2> /dev/null && echo true || echo false)
481ifeq ($(HAS_VALID_PROTOC),true)
Nicolas "Pixel" Noble367e30f2015-07-15 22:36:31 +0200482CACHE_MK += HAS_VALID_PROTOC = true,
murgatroid99aa521572015-07-10 14:49:12 -0700483endif
Nicolas "Pixel" Noble98ab9982015-02-21 04:22:16 +0100484else
485HAS_VALID_PROTOC = false
486endif
Nicolas Noble53830622015-02-12 16:56:38 -0800487
David Garcia Quintas611b7362015-04-27 15:49:31 -0700488# Check for Systemtap (https://sourceware.org/systemtap/), first by making sure <sys/sdt.h> is present
489# in the system and secondly by checking for the "dtrace" binary (on Linux, this is part of the Systemtap
490# distribution. It's part of the base system on BSD/Solaris machines).
murgatroid99aa521572015-07-10 14:49:12 -0700491ifndef HAS_SYSTEMTAP
David Garcia Quintas611b7362015-04-27 15:49:31 -0700492HAS_SYSTEMTAP_HEADERS = $(shell $(SYSTEMTAP_HEADERS_CHECK_CMD) 2> /dev/null && echo true || echo false)
493HAS_DTRACE = $(shell $(DTRACE_CHECK_CMD) 2> /dev/null && echo true || echo false)
494HAS_SYSTEMTAP = false
495ifeq ($(HAS_SYSTEMTAP_HEADERS),true)
496ifeq ($(HAS_DTRACE),true)
497HAS_SYSTEMTAP = true
David Garcia Quintas611b7362015-04-27 15:49:31 -0700498endif
499endif
murgatroid99aa521572015-07-10 14:49:12 -0700500endif
David Garcia Quintas611b7362015-04-27 15:49:31 -0700501
murgatroid994a015a62015-07-10 14:54:57 -0700502ifeq ($(HAS_SYSTEMTAP),true)
Nicolas "Pixel" Noble367e30f2015-07-15 22:36:31 +0200503CACHE_MK += HAS_SYSTEMTAP = true,
murgatroid994a015a62015-07-10 14:54:57 -0700504endif
505
Nicolas "Pixel" Noble4cc8c8a2015-06-23 02:37:49 +0200506# Note that for testing purposes, one can do:
507# make HAS_EMBEDDED_OPENSSL_ALPN=false
508# to emulate the fact we do not have OpenSSL in the third_party folder.
nnoble69ac39f2014-12-12 15:43:38 -0800509ifeq ($(wildcard third_party/openssl/ssl/ssl.h),)
510HAS_EMBEDDED_OPENSSL_ALPN = false
511else
512HAS_EMBEDDED_OPENSSL_ALPN = true
513endif
514
515ifeq ($(wildcard third_party/zlib/zlib.h),)
516HAS_EMBEDDED_ZLIB = false
517else
518HAS_EMBEDDED_ZLIB = true
519endif
520
Nicolas Noble53830622015-02-12 16:56:38 -0800521ifeq ($(wildcard third_party/protobuf/src/google/protobuf/descriptor.pb.h),)
522HAS_EMBEDDED_PROTOBUF = false
523ifneq ($(HAS_VALID_PROTOC),true)
524NO_PROTOC = true
525endif
526else
527HAS_EMBEDDED_PROTOBUF = true
528endif
529
murgatroid998faab232015-06-30 17:24:21 -0700530PC_REQUIRES_GRPC = gpr
531PC_LIBS_GRPC =
532
nnoble69ac39f2014-12-12 15:43:38 -0800533ifeq ($(HAS_SYSTEM_ZLIB),false)
534ifeq ($(HAS_EMBEDDED_ZLIB),true)
Craig Tiller61b910f2015-02-15 10:54:07 -0800535ZLIB_DEP = $(LIBDIR)/$(CONFIG)/zlib/libz.a
nnoble69ac39f2014-12-12 15:43:38 -0800536CPPFLAGS += -Ithird_party/zlib
Craig Tillerda224d62015-02-15 11:01:58 -0800537LDFLAGS += -L$(LIBDIR)/$(CONFIG)/zlib
nnoble69ac39f2014-12-12 15:43:38 -0800538else
539DEP_MISSING += zlib
540endif
murgatroid9924e2f4a2015-06-29 11:12:01 -0700541else
542ifeq ($(HAS_PKG_CONFIG),true)
murgatroid9966d6edb2015-07-06 11:37:51 -0700543CPPFLAGS += $(shell $(PKG_CONFIG) --cflags zlib)
544LDFLAGS += $(shell $(PKG_CONFIG) --libs-only-L zlib)
murgatroid998faab232015-06-30 17:24:21 -0700545PC_REQUIRES_GRPC += zlib
546else
547PC_LIBS_GRPC += -lz
murgatroid9924e2f4a2015-06-29 11:12:01 -0700548endif
nnoble69ac39f2014-12-12 15:43:38 -0800549endif
550
murgatroid99da7a9942015-06-29 14:57:37 -0700551OPENSSL_PKG_CONFIG = false
552
murgatroid998faab232015-06-30 17:24:21 -0700553PC_REQUIRES_SECURE =
554PC_LIBS_SECURE =
555
murgatroid99da7a9942015-06-29 14:57:37 -0700556ifeq ($(HAS_SYSTEM_OPENSSL_ALPN),true)
557ifeq ($(HAS_PKG_CONFIG),true)
558OPENSSL_PKG_CONFIG = true
murgatroid998faab232015-06-30 17:24:21 -0700559PC_REQUIRES_SECURE = openssl
murgatroid9966d6edb2015-07-06 11:37:51 -0700560CPPFLAGS := $(shell $(PKG_CONFIG) --cflags openssl) $(CPPFLAGS)
561LDFLAGS_OPENSSL_PKG_CONFIG = $(shell $(PKG_CONFIG) --libs-only-L openssl)
murgatroid99da7a9942015-06-29 14:57:37 -0700562ifeq ($(SYSTEM),Linux)
563ifneq ($(LDFLAGS_OPENSSL_PKG_CONFIG),)
murgatroid9966d6edb2015-07-06 11:37:51 -0700564LDFLAGS_OPENSSL_PKG_CONFIG += $(shell $(PKG_CONFIG) --libs-only-L openssl | sed s/L/Wl,-rpath,/)
murgatroid99da7a9942015-06-29 14:57:37 -0700565endif
566endif
567LDFLAGS := $(LDFLAGS_OPENSSL_PKG_CONFIG) $(LDFLAGS)
568else
569LIBS_SECURE = $(OPENSSL_LIBS)
570ifeq ($(OPENSSL_REQUIRES_DL),true)
571LIBS_SECURE += dl
murgatroid998faab232015-06-30 17:24:21 -0700572PC_LIBS_SECURE = $(addprefix -l, $(LIBS_SECURE))
murgatroid99da7a9942015-06-29 14:57:37 -0700573endif
574endif
575else
nnoble69ac39f2014-12-12 15:43:38 -0800576ifeq ($(HAS_EMBEDDED_OPENSSL_ALPN),true)
Nicolas "Pixel" Noble4cc8c8a2015-06-23 02:37:49 +0200577USE_SYSTEM_OPENSSL = false
Craig Tiller61b910f2015-02-15 10:54:07 -0800578OPENSSL_DEP = $(LIBDIR)/$(CONFIG)/openssl/libssl.a
579OPENSSL_MERGE_LIBS += $(LIBDIR)/$(CONFIG)/openssl/libssl.a $(LIBDIR)/$(CONFIG)/openssl/libcrypto.a
Craig Tillerec043032015-02-20 17:24:41 -0800580# need to prefix these to ensure overriding system libraries
581CPPFLAGS := -Ithird_party/openssl/include $(CPPFLAGS)
582LDFLAGS := -L$(LIBDIR)/$(CONFIG)/openssl $(LDFLAGS)
Nicolas Noblef8681182015-03-18 14:25:44 -0700583ifeq ($(OPENSSL_REQUIRES_DL),true)
nnoble5b7f32a2014-12-22 08:12:44 -0800584LIBS_SECURE = dl
Nicolas Noblef8681182015-03-18 14:25:44 -0700585endif
nnoble69ac39f2014-12-12 15:43:38 -0800586else
Nicolas "Pixel" Noble4cc8c8a2015-06-23 02:37:49 +0200587ifeq ($(HAS_SYSTEM_OPENSSL_NPN),true)
588USE_SYSTEM_OPENSSL = true
589CPPFLAGS += -DTSI_OPENSSL_ALPN_SUPPORT=0
590LIBS_SECURE = $(OPENSSL_LIBS)
591ifeq ($(OPENSSL_REQUIRES_DL),true)
592LIBS_SECURE += dl
nnoble69ac39f2014-12-12 15:43:38 -0800593endif
nnoble5b7f32a2014-12-22 08:12:44 -0800594else
nnoble69ac39f2014-12-12 15:43:38 -0800595NO_SECURE = true
596endif
murgatroid9924e2f4a2015-06-29 11:12:01 -0700597endif
Nicolas "Pixel" Noblebe2d3a32015-06-30 19:48:47 +0200598endif
nnoble69ac39f2014-12-12 15:43:38 -0800599
murgatroid99da7a9942015-06-29 14:57:37 -0700600ifeq ($(OPENSSL_PKG_CONFIG),true)
murgatroid9966d6edb2015-07-06 11:37:51 -0700601LDLIBS_SECURE += $(shell $(PKG_CONFIG) --libs-only-l openssl)
murgatroid9924e2f4a2015-06-29 11:12:01 -0700602else
nnoble5b7f32a2014-12-22 08:12:44 -0800603LDLIBS_SECURE += $(addprefix -l, $(LIBS_SECURE))
murgatroid9924e2f4a2015-06-29 11:12:01 -0700604endif
nnoble5b7f32a2014-12-22 08:12:44 -0800605
murgatroid998faab232015-06-30 17:24:21 -0700606# grpc .pc file
607PC_NAME = gRPC
608PC_DESCRIPTION = high performance general RPC framework
609PC_CFLAGS =
610PC_REQUIRES_PRIVATE = $(PC_REQUIRES_GRPC) $(PC_REQUIRES_SECURE)
611PC_LIBS_PRIVATE = $(PC_LIBS_GRPC) $(PC_LIBS_SECURE)
murgatroid994fed2122015-07-06 11:26:30 -0700612PC_LIB = -lgrpc
murgatroid998faab232015-06-30 17:24:21 -0700613GRPC_PC_FILE := $(PC_TEMPLATE)
614
615# gprc_unsecure .pc file
616PC_NAME = gRPC unsecure
617PC_DESCRIPTION = high performance general RPC framework without SSL
618PC_CFLAGS =
619PC_REQUIRES_PRIVATE = $(PC_REQUIRES_GRPC)
620PC_LIBS_PRIVATE = $(PC_LIBS_GRPC)
murgatroid994fed2122015-07-06 11:26:30 -0700621PC_LIB = -lgrpc
murgatroid998faab232015-06-30 17:24:21 -0700622GRPC_UNSECURE_PC_FILE := $(PC_TEMPLATE)
623
murgatroid99da7a9942015-06-29 14:57:37 -0700624PROTOBUF_PKG_CONFIG = false
625
murgatroid998faab232015-06-30 17:24:21 -0700626PC_REQUIRES_GRPCXX =
627PC_LIBS_GRPCXX =
628
murgatroid99da7a9942015-06-29 14:57:37 -0700629ifeq ($(HAS_SYSTEM_PROTOBUF),true)
630ifeq ($(HAS_PKG_CONFIG),true)
631PROTOBUF_PKG_CONFIG = true
murgatroid998faab232015-06-30 17:24:21 -0700632PC_REQUIRES_GRPCXX = protobuf
murgatroid9966d6edb2015-07-06 11:37:51 -0700633CPPFLAGS := $(shell $(PKG_CONFIG) --cflags protobuf) $(CPPFLAGS)
634LDFLAGS_PROTOBUF_PKG_CONFIG = $(shell $(PKG_CONFIG) --libs-only-L protobuf)
murgatroid99da7a9942015-06-29 14:57:37 -0700635ifeq ($(SYSTEM),Linux)
636ifneq ($(LDFLAGS_PROTOBUF_PKG_CONFIG),)
murgatroid9966d6edb2015-07-06 11:37:51 -0700637LDFLAGS_PROTOBUF_PKG_CONFIG += $(shell $(PKG_CONFIG) --libs-only-L protobuf | sed s/L/Wl,-rpath,/)
murgatroid99da7a9942015-06-29 14:57:37 -0700638endif
639endif
murgatroid998faab232015-06-30 17:24:21 -0700640else
641PC_LIBS_GRPCXX = -lprotobuf
murgatroid99da7a9942015-06-29 14:57:37 -0700642endif
643else
Nicolas Noble53830622015-02-12 16:56:38 -0800644ifeq ($(HAS_EMBEDDED_PROTOBUF),true)
Craig Tiller61b910f2015-02-15 10:54:07 -0800645PROTOBUF_DEP = $(LIBDIR)/$(CONFIG)/protobuf/libprotobuf.a
Craig Tiller9ec95fa2015-02-20 20:36:21 -0800646CPPFLAGS := -Ithird_party/protobuf/src $(CPPFLAGS)
647LDFLAGS := -L$(LIBDIR)/$(CONFIG)/protobuf $(LDFLAGS)
Craig Tiller61b910f2015-02-15 10:54:07 -0800648PROTOC = $(BINDIR)/$(CONFIG)/protobuf/protoc
Nicolas Noble53830622015-02-12 16:56:38 -0800649else
650NO_PROTOBUF = true
651endif
Nicolas Noble53830622015-02-12 16:56:38 -0800652endif
653
654LIBS_PROTOBUF = protobuf
655LIBS_PROTOC = protoc protobuf
656
Nicolas Noble53830622015-02-12 16:56:38 -0800657HOST_LDLIBS_PROTOC += $(addprefix -l, $(LIBS_PROTOC))
658
murgatroid99da7a9942015-06-29 14:57:37 -0700659ifeq ($(PROTOBUF_PKG_CONFIG),true)
murgatroid9966d6edb2015-07-06 11:37:51 -0700660LDLIBS_PROTOBUF += $(shell $(PKG_CONFIG) --libs-only-l protobuf)
murgatroid9924e2f4a2015-06-29 11:12:01 -0700661else
662LDLIBS_PROTOBUF += $(addprefix -l, $(LIBS_PROTOBUF))
663endif
664
murgatroid998faab232015-06-30 17:24:21 -0700665# grpc++ .pc file
666PC_NAME = gRPC++
667PC_DESCRIPTION = C++ wrapper for gRPC
668PC_CFLAGS =
669PC_REQUIRES_PRIVATE = grpc $(PC_REQUIRES_GRPCXX)
670PC_LIBS_PRIVATE = $(PC_LIBS_GRPCXX)
murgatroid994fed2122015-07-06 11:26:30 -0700671PC_LIB = -lgrpc++
murgatroid998faab232015-06-30 17:24:21 -0700672GRPCXX_PC_FILE := $(PC_TEMPLATE)
673
674# grpc++_unsecure .pc file
675PC_NAME = gRPC++ unsecure
676PC_DESCRIPTION = C++ wrapper for gRPC without SSL
677PC_CFLAGS =
678PC_REQUIRES_PRIVATE = grpc_unsecure $(PC_REQUIRES_GRPCXX)
679PC_LIBS_PRIVATE = $(PC_LIBS_GRPCXX)
murgatroid994fed2122015-07-06 11:26:30 -0700680PC_LIB = -lgrpc++
murgatroid998faab232015-06-30 17:24:21 -0700681GRPCXX_UNSECURE_PC_FILE := $(PC_TEMPLATE)
682
Craig Tiller12c82092015-01-15 08:45:56 -0800683ifeq ($(MAKECMDGOALS),clean)
nnoble69ac39f2014-12-12 15:43:38 -0800684NO_DEPS = true
685endif
686
Nicolas "Pixel" Noble98ab9982015-02-21 04:22:16 +0100687INSTALL_OK = false
688ifeq ($(HAS_VALID_PROTOC),true)
689ifeq ($(HAS_SYSTEM_PROTOBUF_VERIFY),true)
690INSTALL_OK = true
691endif
692endif
693
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800694.SECONDARY = %.pb.h %.pb.cc
695
Nicolas "Pixel" Noble522d7122015-02-19 01:28:02 +0100696PROTOC_PLUGINS =\
Craig Tillerf58b9ef2015-01-15 09:09:12 -0800697% for tgt in targets:
698% if tgt.build == 'protoc':
Craig Tiller61b910f2015-02-15 10:54:07 -0800699 $(BINDIR)/$(CONFIG)/${tgt.name}\
Craig Tillerf58b9ef2015-01-15 09:09:12 -0800700% endif
701% endfor
702
nnoble69ac39f2014-12-12 15:43:38 -0800703ifeq ($(DEP_MISSING),)
Nicolas "Pixel" Noble522d7122015-02-19 01:28:02 +0100704all: static shared plugins\
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800705% for tgt in targets:
706% if tgt.build == 'all':
Craig Tiller61b910f2015-02-15 10:54:07 -0800707 $(BINDIR)/$(CONFIG)/${tgt.name}\
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800708% endif
709% endfor
710
nnoble69ac39f2014-12-12 15:43:38 -0800711dep_error:
712 @echo "You shouldn't see this message - all of your dependencies are correct."
713else
714all: dep_error git_update stop
715
716dep_error:
717 @echo
718 @echo "DEPENDENCY ERROR"
719 @echo
720 @echo "You are missing system dependencies that are essential to build grpc,"
721 @echo "and the third_party directory doesn't have them:"
722 @echo
723 @echo " $(DEP_MISSING)"
724 @echo
725 @echo "Installing the development packages for your system will solve"
726 @echo "this issue. Please consult INSTALL to get more information."
727 @echo
728 @echo "If you need information about why these tests failed, run:"
729 @echo
730 @echo " make run_dep_checks"
731 @echo
732endif
733
734git_update:
735ifeq ($(IS_GIT_FOLDER),true)
736 @echo "Additionally, since you are in a git clone, you can download the"
737 @echo "missing dependencies in third_party by running the following command:"
738 @echo
ctiller64f29102014-12-15 10:40:59 -0800739 @echo " git submodule update --init"
nnoble69ac39f2014-12-12 15:43:38 -0800740 @echo
741endif
742
743openssl_dep_error: openssl_dep_message git_update stop
744
Nicolas Noble53830622015-02-12 16:56:38 -0800745protobuf_dep_error: protobuf_dep_message git_update stop
746
747protoc_dep_error: protoc_dep_message git_update stop
748
nnoble69ac39f2014-12-12 15:43:38 -0800749openssl_dep_message:
750 @echo
751 @echo "DEPENDENCY ERROR"
752 @echo
Nicolas "Pixel" Noble4cc8c8a2015-06-23 02:37:49 +0200753 @echo "The target you are trying to run requires OpenSSL."
nnoble69ac39f2014-12-12 15:43:38 -0800754 @echo "Your system doesn't have it, and neither does the third_party directory."
755 @echo
756 @echo "Please consult INSTALL to get more information."
757 @echo
758 @echo "If you need information about why these tests failed, run:"
759 @echo
760 @echo " make run_dep_checks"
761 @echo
762
Nicolas Noble53830622015-02-12 16:56:38 -0800763protobuf_dep_message:
764 @echo
765 @echo "DEPENDENCY ERROR"
766 @echo
767 @echo "The target you are trying to run requires protobuf 3.0.0+"
768 @echo "Your system doesn't have it, and neither does the third_party directory."
769 @echo
770 @echo "Please consult INSTALL to get more information."
771 @echo
772 @echo "If you need information about why these tests failed, run:"
773 @echo
774 @echo " make run_dep_checks"
775 @echo
776
777protoc_dep_message:
778 @echo
779 @echo "DEPENDENCY ERROR"
780 @echo
781 @echo "The target you are trying to run requires protobuf-compiler 3.0.0+"
782 @echo "Your system doesn't have it, and neither does the third_party directory."
783 @echo
784 @echo "Please consult INSTALL to get more information."
785 @echo
786 @echo "If you need information about why these tests failed, run:"
787 @echo
788 @echo " make run_dep_checks"
789 @echo
790
David Garcia Quintas8954e902015-04-29 09:46:33 -0700791systemtap_dep_error:
792 @echo
793 @echo "DEPENDENCY ERROR"
794 @echo
795 @echo "Under the '$(CONFIG)' configutation, the target you are trying "
796 @echo "to build requires systemtap 2.7+ (on Linux) or dtrace (on other "
797 @echo "platforms such as Solaris and *BSD). "
798 @echo
799 @echo "Please consult INSTALL to get more information."
800 @echo
801
nnoble69ac39f2014-12-12 15:43:38 -0800802stop:
803 @false
804
ctiller09cb6d52014-12-19 17:38:22 -0800805% for tgt in targets:
Craig Tiller61b910f2015-02-15 10:54:07 -0800806${tgt.name}: $(BINDIR)/$(CONFIG)/${tgt.name}
ctiller09cb6d52014-12-19 17:38:22 -0800807% endfor
808
nnoble69ac39f2014-12-12 15:43:38 -0800809run_dep_checks:
nnoble69ac39f2014-12-12 15:43:38 -0800810 $(OPENSSL_ALPN_CHECK_CMD) || true
Nicolas "Pixel" Noble4cc8c8a2015-06-23 02:37:49 +0200811 $(OPENSSL_NPN_CHECK_CMD) || true
nnoble69ac39f2014-12-12 15:43:38 -0800812 $(ZLIB_CHECK_CMD) || true
Nicolas Noble53830622015-02-12 16:56:38 -0800813 $(PERFTOOLS_CHECK_CMD) || true
814 $(PROTOBUF_CHECK_CMD) || true
David Garcia Quintasf5fcafd2015-04-24 16:12:54 -0700815 $(PROTOC_CHECK_VERSION_CMD) || true
nnoble69ac39f2014-12-12 15:43:38 -0800816
Craig Tiller61b910f2015-02-15 10:54:07 -0800817$(LIBDIR)/$(CONFIG)/zlib/libz.a:
Nicolas "Pixel" Noble17f2b592015-01-16 07:09:10 +0100818 $(E) "[MAKE] Building zlib"
Nicolas "Pixel" Noble482d7612015-07-16 23:43:30 +0200819 $(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 +0100820 $(Q)$(MAKE) -C third_party/zlib clean
821 $(Q)$(MAKE) -C third_party/zlib
Craig Tiller61b910f2015-02-15 10:54:07 -0800822 $(Q)mkdir -p $(LIBDIR)/$(CONFIG)/zlib
823 $(Q)cp third_party/zlib/libz.a $(LIBDIR)/$(CONFIG)/zlib
nnoble69ac39f2014-12-12 15:43:38 -0800824
Craig Tiller61b910f2015-02-15 10:54:07 -0800825$(LIBDIR)/$(CONFIG)/openssl/libssl.a:
Craig Tillerb4ee3b52015-01-21 16:22:50 -0800826 $(E) "[MAKE] Building openssl for $(SYSTEM)"
827ifeq ($(SYSTEM),Darwin)
Nicolas "Pixel" Noble482d7612015-07-16 23:43:30 +0200828 $(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 -0800829else
Nicolas Noblef8681182015-03-18 14:25:44 -0700830ifeq ($(SYSTEM),MINGW32)
831 @echo "We currently don't have a good way to compile OpenSSL in-place under msys."
Nicolas "Pixel" Noble4cc8c8a2015-06-23 02:37:49 +0200832 @echo "Please provide a OpenSSL in your mingw32 system."
Nicolas Noblef8681182015-03-18 14:25:44 -0700833 @echo
834 @echo "Note that you can find a compatible version of the libraries here:"
835 @echo
836 @echo "http://slproweb.com/products/Win32OpenSSL.html"
837 @echo
838 @echo "If you decide to install that one, take the full version. The light"
839 @echo "version only contains compiled DLLs, without the development files."
840 @echo
841 @echo "When installing, chose to copy the OpenSSL dlls to the OpenSSL binaries"
842 @echo "directory. This way we'll link to them directly."
843 @echo
844 @echo "You can then re-start the build the following way:"
845 @echo
846 @echo " CPPFLAGS=-I/c/OpenSSL-Win64/include LDFLAGS=-L/c/OpenSSL-Win64 make"
847 @false
848else
Nicolas "Pixel" Noble482d7612015-07-16 23:43:30 +0200849 $(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 -0700850endif
Craig Tillerb4ee3b52015-01-21 16:22:50 -0800851endif
Nicolas "Pixel" Noble17f2b592015-01-16 07:09:10 +0100852 $(Q)$(MAKE) -C third_party/openssl clean
Jan Tattermuschc9c83cf2015-06-17 13:42:34 -0700853 $(Q)(unset CPPFLAGS; $(MAKE) -C third_party/openssl build_crypto build_ssl)
Craig Tiller61b910f2015-02-15 10:54:07 -0800854 $(Q)mkdir -p $(LIBDIR)/$(CONFIG)/openssl
855 $(Q)cp third_party/openssl/libssl.a third_party/openssl/libcrypto.a $(LIBDIR)/$(CONFIG)/openssl
nnoble69ac39f2014-12-12 15:43:38 -0800856
Nicolas Noble53830622015-02-12 16:56:38 -0800857third_party/protobuf/configure:
858 $(E) "[AUTOGEN] Preparing protobuf"
859 $(Q)(cd third_party/protobuf ; autoreconf -f -i -Wall,no-obsolete)
860
Craig Tiller61b910f2015-02-15 10:54:07 -0800861$(LIBDIR)/$(CONFIG)/protobuf/libprotobuf.a: third_party/protobuf/configure
Nicolas Noble53830622015-02-12 16:56:38 -0800862 $(E) "[MAKE] Building protobuf"
Nicolas "Pixel" Noble482d7612015-07-16 23:43:30 +0200863 $(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 -0800864 $(Q)$(MAKE) -C third_party/protobuf clean
865 $(Q)$(MAKE) -C third_party/protobuf
Craig Tiller61b910f2015-02-15 10:54:07 -0800866 $(Q)mkdir -p $(LIBDIR)/$(CONFIG)/protobuf
867 $(Q)mkdir -p $(BINDIR)/$(CONFIG)/protobuf
868 $(Q)cp third_party/protobuf/src/.libs/libprotoc.a $(LIBDIR)/$(CONFIG)/protobuf
869 $(Q)cp third_party/protobuf/src/.libs/libprotobuf.a $(LIBDIR)/$(CONFIG)/protobuf
870 $(Q)cp third_party/protobuf/src/protoc $(BINDIR)/$(CONFIG)/protobuf
Nicolas Noble53830622015-02-12 16:56:38 -0800871
nnoble29e1d292014-12-01 10:27:40 -0800872static: static_c static_cxx
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800873
murgatroid99aa521572015-07-10 14:49:12 -0700874static_c: pc_c pc_c_unsecure cache.mk \
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800875% for lib in libs:
Craig Tiller59140fc2015-01-18 10:12:17 -0800876% if lib.build == 'all' and lib.language == 'c':
Craig Tiller61b910f2015-02-15 10:54:07 -0800877 $(LIBDIR)/$(CONFIG)/lib${lib.name}.a\
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800878% endif
879% endfor
880
881
murgatroid99aa521572015-07-10 14:49:12 -0700882static_cxx: pc_cxx pc_cxx_unsecure pc_gpr cache.mk \
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800883% for lib in libs:
Craig Tiller59140fc2015-01-18 10:12:17 -0800884% if lib.build == 'all' and lib.language == 'c++':
Craig Tiller61b910f2015-02-15 10:54:07 -0800885 $(LIBDIR)/$(CONFIG)/lib${lib.name}.a\
nnoble29e1d292014-12-01 10:27:40 -0800886% endif
887% endfor
888
889
890shared: shared_c shared_cxx
891
murgatroid99aa521572015-07-10 14:49:12 -0700892shared_c: pc_c pc_c_unsecure pc_gpr cache.mk\
nnoble29e1d292014-12-01 10:27:40 -0800893% for lib in libs:
Craig Tiller59140fc2015-01-18 10:12:17 -0800894% if lib.build == 'all' and lib.language == 'c':
Craig Tiller61b910f2015-02-15 10:54:07 -0800895 $(LIBDIR)/$(CONFIG)/lib${lib.name}.$(SHARED_EXT)\
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800896% endif
897% endfor
898
899
murgatroid99aa521572015-07-10 14:49:12 -0700900shared_cxx: pc_cxx pc_cxx_unsecure cache.mk\
nnoble29e1d292014-12-01 10:27:40 -0800901% for lib in libs:
Craig Tiller59140fc2015-01-18 10:12:17 -0800902% if lib.build == 'all' and lib.language == 'c++':
Craig Tiller61b910f2015-02-15 10:54:07 -0800903 $(LIBDIR)/$(CONFIG)/lib${lib.name}.$(SHARED_EXT)\
nnoble29e1d292014-12-01 10:27:40 -0800904% endif
905% endfor
906
907
Jan Tattermusch2ec0b3e2015-02-18 15:03:12 -0800908shared_csharp: shared_c \
909% for lib in libs:
910% if lib.build == 'all' and lib.language == 'csharp':
911 $(LIBDIR)/$(CONFIG)/lib${lib.name}.$(SHARED_EXT)\
912% endif
913% endfor
914
915grpc_csharp_ext: shared_csharp
916
Nicolas "Pixel" Noble522d7122015-02-19 01:28:02 +0100917plugins: $(PROTOC_PLUGINS)
918
nnoble29e1d292014-12-01 10:27:40 -0800919privatelibs: privatelibs_c privatelibs_cxx
920
Craig Tiller12c82092015-01-15 08:45:56 -0800921privatelibs_c: \
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800922% for lib in libs:
Craig Tiller59140fc2015-01-18 10:12:17 -0800923% if lib.build == 'private' and lib.language == 'c':
Craig Tiller61b910f2015-02-15 10:54:07 -0800924 $(LIBDIR)/$(CONFIG)/lib${lib.name}.a\
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800925% endif
926% endfor
927
murgatroid998faab232015-06-30 17:24:21 -0700928pc_gpr: $(LIBDIR)/$(CONFIG)/pkgconfig/gpr.pc
929
930pc_c: $(LIBDIR)/$(CONFIG)/pkgconfig/grpc.pc
931
932pc_c_unsecure: $(LIBDIR)/$(CONFIG)/pkgconfig/grpc_unsecure.pc
933
934pc_cxx: $(LIBDIR)/$(CONFIG)/pkgconfig/grpc++.pc
935
936pc_cxx_unsecure: $(LIBDIR)/$(CONFIG)/pkgconfig/grpc++_unsecure.pc
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800937
Craig Tiller12c82092015-01-15 08:45:56 -0800938privatelibs_cxx: \
nnoble29e1d292014-12-01 10:27:40 -0800939% for lib in libs:
Craig Tiller59140fc2015-01-18 10:12:17 -0800940% if lib.build == 'private' and lib.language == 'c++':
Craig Tiller61b910f2015-02-15 10:54:07 -0800941 $(LIBDIR)/$(CONFIG)/lib${lib.name}.a\
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800942% endif
943% endfor
944
945
nnoble29e1d292014-12-01 10:27:40 -0800946buildtests: buildtests_c buildtests_cxx
947
Craig Tiller12c82092015-01-15 08:45:56 -0800948buildtests_c: privatelibs_c\
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800949% for tgt in targets:
Craig Tiller59140fc2015-01-18 10:12:17 -0800950% if tgt.build == 'test' and not tgt.language == 'c++':
Craig Tiller61b910f2015-02-15 10:54:07 -0800951 $(BINDIR)/$(CONFIG)/${tgt.name}\
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800952% endif
953% endfor
954
955
Craig Tiller12c82092015-01-15 08:45:56 -0800956buildtests_cxx: privatelibs_cxx\
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800957% for tgt in targets:
Craig Tiller59140fc2015-01-18 10:12:17 -0800958% if tgt.build == 'test' and tgt.language == 'c++':
Craig Tiller61b910f2015-02-15 10:54:07 -0800959 $(BINDIR)/$(CONFIG)/${tgt.name}\
nnoble29e1d292014-12-01 10:27:40 -0800960% endif
961% endfor
962
963
nnoble85a49262014-12-08 18:14:03 -0800964test: test_c test_cxx
nnoble29e1d292014-12-01 10:27:40 -0800965
Nicolas "Pixel" Noble4251d562015-05-22 19:43:39 +0200966flaky_test: flaky_test_c flaky_test_cxx
967
nnoble85a49262014-12-08 18:14:03 -0800968test_c: buildtests_c
nnoble29e1d292014-12-01 10:27:40 -0800969% for tgt in targets:
Nicolas "Pixel" Noble4251d562015-05-22 19:43:39 +0200970% if tgt.build == 'test' and tgt.get('run', True) and not tgt.language == 'c++' and not tgt.get('flaky', False):
971 $(E) "[RUN] Testing ${tgt.name}"
972 $(Q) $(BINDIR)/$(CONFIG)/${tgt.name} || ( echo test ${tgt.name} failed ; exit 1 )
973% endif
974% endfor
975
976
977flaky_test_c: buildtests_c
978% for tgt in targets:
979% if tgt.build == 'test' and tgt.get('run', True) and not tgt.language == 'c++' and tgt.get('flaky', False):
nnoble29e1d292014-12-01 10:27:40 -0800980 $(E) "[RUN] Testing ${tgt.name}"
Craig Tillerda224d62015-02-15 11:01:58 -0800981 $(Q) $(BINDIR)/$(CONFIG)/${tgt.name} || ( echo test ${tgt.name} failed ; exit 1 )
nnoble29e1d292014-12-01 10:27:40 -0800982% endif
983% endfor
984
985
nnoble85a49262014-12-08 18:14:03 -0800986test_cxx: buildtests_cxx
nnoble29e1d292014-12-01 10:27:40 -0800987% for tgt in targets:
Nicolas "Pixel" Noble4251d562015-05-22 19:43:39 +0200988% if tgt.build == 'test' and tgt.get('run', True) and tgt.language == 'c++' and not tgt.get('flaky', False):
989 $(E) "[RUN] Testing ${tgt.name}"
990 $(Q) $(BINDIR)/$(CONFIG)/${tgt.name} || ( echo test ${tgt.name} failed ; exit 1 )
991% endif
992% endfor
993
994
995flaky_test_cxx: buildtests_cxx
996% for tgt in targets:
997% if tgt.build == 'test' and tgt.get('run', True) and tgt.language == 'c++' and tgt.get('flaky', False):
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800998 $(E) "[RUN] Testing ${tgt.name}"
Craig Tillerda224d62015-02-15 11:01:58 -0800999 $(Q) $(BINDIR)/$(CONFIG)/${tgt.name} || ( echo test ${tgt.name} failed ; exit 1 )
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001000% endif
1001% endfor
1002
1003
Nicolas "Pixel" Noble051a28f2015-03-17 22:54:54 +01001004test_python: static_c
1005 $(E) "[RUN] Testing python code"
1006 $(Q) tools/run_tests/run_tests.py -lpython -c$(CONFIG)
1007
1008
Craig Tiller7552f0f2015-06-19 17:46:20 -07001009tools: tools_c tools_cxx
1010
1011
1012tools_c: privatelibs_c\
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001013% for tgt in targets:
Craig Tiller7552f0f2015-06-19 17:46:20 -07001014% if tgt.build == 'tool' and not tgt.language=='c++':
1015 $(BINDIR)/$(CONFIG)/${tgt.name}\
1016% endif
1017% endfor
1018
1019
1020tools_cxx: privatelibs_cxx\
1021% for tgt in targets:
1022% if tgt.build == 'tool' and tgt.language=='c++':
Craig Tiller61b910f2015-02-15 10:54:07 -08001023 $(BINDIR)/$(CONFIG)/${tgt.name}\
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001024% endif
1025% endfor
1026
1027
1028buildbenchmarks: privatelibs\
1029% for tgt in targets:
1030% if tgt.build == 'benchmark':
Craig Tiller61b910f2015-02-15 10:54:07 -08001031 $(BINDIR)/$(CONFIG)/${tgt.name}\
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001032% endif
1033% endfor
1034
1035
1036benchmarks: buildbenchmarks
1037
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001038strip: strip-static strip-shared
1039
nnoble20e2e3f2014-12-16 15:37:57 -08001040strip-static: strip-static_c strip-static_cxx
1041
1042strip-shared: strip-shared_c strip-shared_cxx
1043
Nicolas Noble047b7272015-01-16 13:55:05 -08001044
1045# TODO(nnoble): the strip target is stripping in-place, instead
1046# of copying files in a temporary folder.
1047# This prevents proper debugging after running make install.
1048
nnoble85a49262014-12-08 18:14:03 -08001049strip-static_c: static_c
Nicolas "Pixel" Noble3a2551c2015-01-29 21:33:32 +01001050ifeq ($(CONFIG),opt)
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001051% for lib in libs:
Craig Tiller59140fc2015-01-18 10:12:17 -08001052% if lib.language == "c":
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001053% if lib.build == "all":
1054 $(E) "[STRIP] Stripping lib${lib.name}.a"
Craig Tiller61b910f2015-02-15 10:54:07 -08001055 $(Q) $(STRIP) $(LIBDIR)/$(CONFIG)/lib${lib.name}.a
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001056% endif
nnoble85a49262014-12-08 18:14:03 -08001057% endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001058% endfor
Nicolas "Pixel" Noble3a2551c2015-01-29 21:33:32 +01001059endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001060
nnoble85a49262014-12-08 18:14:03 -08001061strip-static_cxx: static_cxx
Nicolas "Pixel" Noble3a2551c2015-01-29 21:33:32 +01001062ifeq ($(CONFIG),opt)
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001063% for lib in libs:
Craig Tiller59140fc2015-01-18 10:12:17 -08001064% if lib.language == "c++":
nnoble85a49262014-12-08 18:14:03 -08001065% if lib.build == "all":
1066 $(E) "[STRIP] Stripping lib${lib.name}.a"
Craig Tiller61b910f2015-02-15 10:54:07 -08001067 $(Q) $(STRIP) $(LIBDIR)/$(CONFIG)/lib${lib.name}.a
nnoble85a49262014-12-08 18:14:03 -08001068% endif
1069% endif
1070% endfor
Nicolas "Pixel" Noble3a2551c2015-01-29 21:33:32 +01001071endif
nnoble85a49262014-12-08 18:14:03 -08001072
1073strip-shared_c: shared_c
Nicolas "Pixel" Noble3a2551c2015-01-29 21:33:32 +01001074ifeq ($(CONFIG),opt)
nnoble85a49262014-12-08 18:14:03 -08001075% for lib in libs:
Craig Tiller59140fc2015-01-18 10:12:17 -08001076% if lib.language == "c":
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001077% if lib.build == "all":
1078 $(E) "[STRIP] Stripping lib${lib.name}.so"
Craig Tiller61b910f2015-02-15 10:54:07 -08001079 $(Q) $(STRIP) $(LIBDIR)/$(CONFIG)/lib${lib.name}.$(SHARED_EXT)
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001080% endif
nnoble85a49262014-12-08 18:14:03 -08001081% endif
1082% endfor
Nicolas "Pixel" Noble3a2551c2015-01-29 21:33:32 +01001083endif
nnoble85a49262014-12-08 18:14:03 -08001084
1085strip-shared_cxx: shared_cxx
Nicolas "Pixel" Noble3a2551c2015-01-29 21:33:32 +01001086ifeq ($(CONFIG),opt)
nnoble85a49262014-12-08 18:14:03 -08001087% for lib in libs:
Craig Tiller59140fc2015-01-18 10:12:17 -08001088% if lib.language == "c++":
nnoble85a49262014-12-08 18:14:03 -08001089% if lib.build == "all":
1090 $(E) "[STRIP] Stripping lib${lib.name}.so"
Craig Tiller61b910f2015-02-15 10:54:07 -08001091 $(Q) $(STRIP) $(LIBDIR)/$(CONFIG)/lib${lib.name}.$(SHARED_EXT)
nnoble85a49262014-12-08 18:14:03 -08001092% endif
1093% endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001094% endfor
Nicolas "Pixel" Noble3a2551c2015-01-29 21:33:32 +01001095endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001096
Jan Tattermusch2ec0b3e2015-02-18 15:03:12 -08001097strip-shared_csharp: shared_csharp
1098ifeq ($(CONFIG),opt)
1099% for lib in libs:
1100% if lib.language == "csharp":
1101% if lib.build == "all":
1102 $(E) "[STRIP] Stripping lib${lib.name}.so"
1103 $(Q) $(STRIP) $(LIBDIR)/$(CONFIG)/lib${lib.name}.$(SHARED_EXT)
1104% endif
1105% endif
1106% endfor
1107endif
1108
murgatroid99aa521572015-07-10 14:49:12 -07001109cache.mk::
1110 $(E) "[MAKE] Generating $@"
Nicolas "Pixel" Noble367e30f2015-07-15 22:36:31 +02001111 $(Q) echo "$(CACHE_MK)" | tr , '\n' >$@
murgatroid99aa521572015-07-10 14:49:12 -07001112
murgatroid998faab232015-06-30 17:24:21 -07001113$(LIBDIR)/$(CONFIG)/pkgconfig/gpr.pc:
1114 $(E) "[MAKE] Generating $@"
1115 $(Q) mkdir -p $(@D)
Nicolas "Pixel" Noble367e30f2015-07-15 22:36:31 +02001116 $(Q) echo "$(GPR_PC_FILE)" | tr , '\n' >$@
murgatroid998faab232015-06-30 17:24:21 -07001117
1118$(LIBDIR)/$(CONFIG)/pkgconfig/grpc.pc:
1119 $(E) "[MAKE] Generating $@"
1120 $(Q) mkdir -p $(@D)
Nicolas "Pixel" Noble367e30f2015-07-15 22:36:31 +02001121 $(Q) echo "$(GRPC_PC_FILE)" | tr , '\n' >$@
murgatroid998faab232015-06-30 17:24:21 -07001122
1123$(LIBDIR)/$(CONFIG)/pkgconfig/grpc_unsecure.pc:
1124 $(E) "[MAKE] Generating $@"
1125 $(Q) mkdir -p $(@D)
Nicolas "Pixel" Noble367e30f2015-07-15 22:36:31 +02001126 $(Q) echo "$(GRPC_UNSECURE_PC_FILE)" | tr , '\n' >$@
murgatroid998faab232015-06-30 17:24:21 -07001127
1128$(LIBDIR)/$(CONFIG)/pkgconfig/grpc++.pc:
1129 $(E) "[MAKE] Generating $@"
1130 $(Q) mkdir -p $(@D)
Nicolas "Pixel" Noble367e30f2015-07-15 22:36:31 +02001131 $(Q) echo "$(GRPCXX_PC_FILE)" | tr , '\n' >$@
murgatroid998faab232015-06-30 17:24:21 -07001132
1133$(LIBDIR)/$(CONFIG)/pkgconfig/grpc++_unsecure.pc:
1134 $(E) "[MAKE] Generating $@"
1135 $(Q) mkdir -p $(@D)
Nicolas "Pixel" Noble367e30f2015-07-15 22:36:31 +02001136 $(Q) echo "$(GRPCXX_UNSECURE_PC_FILE)" | tr , '\n' >$@
murgatroid998faab232015-06-30 17:24:21 -07001137
nnoble72309c62014-12-12 11:42:26 -08001138% for p in protos:
Nicolas Noble53830622015-02-12 16:56:38 -08001139ifeq ($(NO_PROTOC),true)
Craig Tiller61b910f2015-02-15 10:54:07 -08001140$(GENDIR)/${p}.pb.cc: protoc_dep_error
Nicolas "Pixel" Noble0caebbf2015-04-09 23:08:51 +02001141$(GENDIR)/${p}.grpc.pb.cc: protoc_dep_error
Nicolas Noble53830622015-02-12 16:56:38 -08001142else
Craig Tiller61b910f2015-02-15 10:54:07 -08001143$(GENDIR)/${p}.pb.cc: ${p}.proto $(PROTOBUF_DEP) $(PROTOC_PLUGINS)
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001144 $(E) "[PROTOC] Generating protobuf CC file from $<"
1145 $(Q) mkdir -p `dirname $@`
Nicolas "Pixel" Noble0caebbf2015-04-09 23:08:51 +02001146 $(Q) $(PROTOC) --cpp_out=$(GENDIR) $<
1147
1148$(GENDIR)/${p}.grpc.pb.cc: ${p}.proto $(PROTOBUF_DEP) $(PROTOC_PLUGINS)
1149 $(E) "[GRPC] Generating gRPC's protobuf service CC file from $<"
1150 $(Q) mkdir -p `dirname $@`
1151 $(Q) $(PROTOC) --grpc_out=$(GENDIR) --plugin=protoc-gen-grpc=$(BINDIR)/$(CONFIG)/grpc_cpp_plugin $<
Nicolas Noble53830622015-02-12 16:56:38 -08001152endif
nnoble72309c62014-12-12 11:42:26 -08001153
1154% endfor
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001155
David Garcia Quintasbbc0b772015-04-29 14:10:05 -07001156ifeq ($(CONFIG),stapprof)
1157src/core/profiling/stap_timers.c: $(GENDIR)/src/core/profiling/stap_probes.h
David Garcia Quintas611b7362015-04-27 15:49:31 -07001158ifeq ($(HAS_SYSTEMTAP),true)
1159$(GENDIR)/src/core/profiling/stap_probes.h: src/core/profiling/stap_probes.d
1160 $(E) "[DTRACE] Compiling $<"
1161 $(Q) mkdir -p `dirname $@`
1162 $(Q) $(DTRACE) -C -h -s $< -o $@
David Garcia Quintas8954e902015-04-29 09:46:33 -07001163else
1164$(GENDIR)/src/core/profiling/stap_probes.h: systemtap_dep_error stop
1165endif
David Garcia Quintas611b7362015-04-27 15:49:31 -07001166endif
1167
Craig Tiller61b910f2015-02-15 10:54:07 -08001168$(OBJDIR)/$(CONFIG)/%.o : %.c
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001169 $(E) "[C] Compiling $<"
1170 $(Q) mkdir -p `dirname $@`
Craig Tiller12c82092015-01-15 08:45:56 -08001171 $(Q) $(CC) $(CFLAGS) $(CPPFLAGS) -MMD -MF $(addsuffix .dep, $(basename $@)) -c -o $@ $<
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001172
Craig Tiller61b910f2015-02-15 10:54:07 -08001173$(OBJDIR)/$(CONFIG)/%.o : $(GENDIR)/%.pb.cc
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001174 $(E) "[CXX] Compiling $<"
1175 $(Q) mkdir -p `dirname $@`
Craig Tiller12c82092015-01-15 08:45:56 -08001176 $(Q) $(CXX) $(CXXFLAGS) $(CPPFLAGS) -MMD -MF $(addsuffix .dep, $(basename $@)) -c -o $@ $<
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001177
Craig Tiller61b910f2015-02-15 10:54:07 -08001178$(OBJDIR)/$(CONFIG)/src/compiler/%.o : src/compiler/%.cc
nnoble72309c62014-12-12 11:42:26 -08001179 $(E) "[HOSTCXX] Compiling $<"
1180 $(Q) mkdir -p `dirname $@`
Craig Tiller12c82092015-01-15 08:45:56 -08001181 $(Q) $(HOST_CXX) $(HOST_CXXFLAGS) $(HOST_CPPFLAGS) -MMD -MF $(addsuffix .dep, $(basename $@)) -c -o $@ $<
nnoble72309c62014-12-12 11:42:26 -08001182
Craig Tiller61b910f2015-02-15 10:54:07 -08001183$(OBJDIR)/$(CONFIG)/%.o : %.cc
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001184 $(E) "[CXX] Compiling $<"
1185 $(Q) mkdir -p `dirname $@`
Craig Tiller12c82092015-01-15 08:45:56 -08001186 $(Q) $(CXX) $(CXXFLAGS) $(CPPFLAGS) -MMD -MF $(addsuffix .dep, $(basename $@)) -c -o $@ $<
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001187
Nicolas "Pixel" Noble161ea232015-02-22 05:48:53 +01001188install: install_c install_cxx install-plugins install-certs verify-install
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001189
nnoble85a49262014-12-08 18:14:03 -08001190install_c: install-headers_c install-static_c install-shared_c
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001191
nnoble85a49262014-12-08 18:14:03 -08001192install_cxx: install-headers_cxx install-static_cxx install-shared_cxx
1193
Jan Tattermusch2ec0b3e2015-02-18 15:03:12 -08001194install_csharp: install-shared_csharp install_c
1195
1196install_grpc_csharp_ext: install_csharp
1197
nnoble85a49262014-12-08 18:14:03 -08001198install-headers: install-headers_c install-headers_cxx
1199
1200install-headers_c:
1201 $(E) "[INSTALL] Installing public C headers"
Nicolas "Pixel" Noble932d5d32015-02-21 02:15:34 +01001202 $(Q) $(foreach h, $(PUBLIC_HEADERS_C), $(INSTALL) -d $(prefix)/$(dir $(h)) && ) exit 0 || exit 1
nnoble85a49262014-12-08 18:14:03 -08001203 $(Q) $(foreach h, $(PUBLIC_HEADERS_C), $(INSTALL) $(h) $(prefix)/$(h) && ) exit 0 || exit 1
1204
1205install-headers_cxx:
1206 $(E) "[INSTALL] Installing public C++ headers"
Nicolas "Pixel" Noble932d5d32015-02-21 02:15:34 +01001207 $(Q) $(foreach h, $(PUBLIC_HEADERS_CXX), $(INSTALL) -d $(prefix)/$(dir $(h)) && ) exit 0 || exit 1
nnoble85a49262014-12-08 18:14:03 -08001208 $(Q) $(foreach h, $(PUBLIC_HEADERS_CXX), $(INSTALL) $(h) $(prefix)/$(h) && ) exit 0 || exit 1
1209
1210install-static: install-static_c install-static_cxx
1211
murgatroid998faab232015-06-30 17:24:21 -07001212install-static_c: static_c strip-static_c install-pkg-config_c
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001213% for lib in libs:
Craig Tiller59140fc2015-01-18 10:12:17 -08001214% if lib.language == "c":
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001215% if lib.build == "all":
1216 $(E) "[INSTALL] Installing lib${lib.name}.a"
Nicolas "Pixel" Noble932d5d32015-02-21 02:15:34 +01001217 $(Q) $(INSTALL) -d $(prefix)/lib
Craig Tiller61b910f2015-02-15 10:54:07 -08001218 $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/lib${lib.name}.a $(prefix)/lib/lib${lib.name}.a
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001219% endif
nnoble85a49262014-12-08 18:14:03 -08001220% endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001221% endfor
1222
murgatroid998faab232015-06-30 17:24:21 -07001223install-static_cxx: static_cxx strip-static_cxx install-pkg-config_cxx
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001224% for lib in libs:
Craig Tiller59140fc2015-01-18 10:12:17 -08001225% if lib.language == "c++":
nnoble85a49262014-12-08 18:14:03 -08001226% if lib.build == "all":
1227 $(E) "[INSTALL] Installing lib${lib.name}.a"
Nicolas "Pixel" Noble932d5d32015-02-21 02:15:34 +01001228 $(Q) $(INSTALL) -d $(prefix)/lib
Craig Tiller61b910f2015-02-15 10:54:07 -08001229 $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/lib${lib.name}.a $(prefix)/lib/lib${lib.name}.a
nnoble85a49262014-12-08 18:14:03 -08001230% endif
1231% endif
1232% endfor
1233
Nicolas "Pixel" Noble522d7122015-02-19 01:28:02 +01001234<%def name="install_shared(lang_filter)">\
nnoble85a49262014-12-08 18:14:03 -08001235% for lib in libs:
Nicolas "Pixel" Noble522d7122015-02-19 01:28:02 +01001236% if lib.language == lang_filter:
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001237% if lib.build == "all":
nnoble5b7f32a2014-12-22 08:12:44 -08001238ifeq ($(SYSTEM),MINGW32)
1239 $(E) "[INSTALL] Installing ${lib.name}.$(SHARED_EXT)"
Nicolas "Pixel" Noble932d5d32015-02-21 02:15:34 +01001240 $(Q) $(INSTALL) -d $(prefix)/lib
Craig Tiller61b910f2015-02-15 10:54:07 -08001241 $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/${lib.name}.$(SHARED_EXT) $(prefix)/lib/${lib.name}.$(SHARED_EXT)
1242 $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/lib${lib.name}-imp.a $(prefix)/lib/lib${lib.name}-imp.a
nnoble5b7f32a2014-12-22 08:12:44 -08001243else
1244 $(E) "[INSTALL] Installing lib${lib.name}.$(SHARED_EXT)"
Nicolas "Pixel" Noble932d5d32015-02-21 02:15:34 +01001245 $(Q) $(INSTALL) -d $(prefix)/lib
Craig Tiller61b910f2015-02-15 10:54:07 -08001246 $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/lib${lib.name}.$(SHARED_EXT) $(prefix)/lib/lib${lib.name}.$(SHARED_EXT)
Masood Malekghassemid1be74f2015-04-07 16:23:09 -07001247ifneq ($(SYSTEM),Darwin)
Tim Emiola820e3d62015-04-10 09:11:50 -07001248 $(Q) ln -sf lib${lib.name}.$(SHARED_EXT) $(prefix)/lib/lib${lib.name}.so.${settings.version.major}
nnoble5b7f32a2014-12-22 08:12:44 -08001249 $(Q) ln -sf lib${lib.name}.$(SHARED_EXT) $(prefix)/lib/lib${lib.name}.so
1250endif
1251endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001252% endif
nnoble85a49262014-12-08 18:14:03 -08001253% endif
1254% endfor
nnoble5b7f32a2014-12-22 08:12:44 -08001255ifneq ($(SYSTEM),MINGW32)
1256ifneq ($(SYSTEM),Darwin)
Nicolas "Pixel" Noblecc2b42a2015-02-20 00:42:21 +01001257 $(Q) ldconfig || true
nnoble5b7f32a2014-12-22 08:12:44 -08001258endif
1259endif
Nicolas "Pixel" Noble522d7122015-02-19 01:28:02 +01001260</%def>
nnoble85a49262014-12-08 18:14:03 -08001261
murgatroid998faab232015-06-30 17:24:21 -07001262install-shared_c: shared_c strip-shared_c install-pkg-config_c
Nicolas "Pixel" Noble522d7122015-02-19 01:28:02 +01001263${install_shared("c")}
1264
murgatroid998faab232015-06-30 17:24:21 -07001265install-shared_cxx: shared_cxx strip-shared_cxx install-shared_c install-pkg-config_cxx
Nicolas "Pixel" Noble522d7122015-02-19 01:28:02 +01001266${install_shared("c++")}
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001267
Jan Tattermusch2ec0b3e2015-02-18 15:03:12 -08001268install-shared_csharp: shared_csharp strip-shared_csharp
Nicolas "Pixel" Noble522d7122015-02-19 01:28:02 +01001269${install_shared("csharp")}
1270
Nicolas "Pixel" Noble522d7122015-02-19 01:28:02 +01001271install-plugins: $(PROTOC_PLUGINS)
1272ifeq ($(SYSTEM),MINGW32)
1273 $(Q) false
1274else
1275 $(E) "[INSTALL] Installing grpc protoc plugins"
1276% for tgt in targets:
1277% if tgt.build == 'protoc':
Nicolas "Pixel" Noble932d5d32015-02-21 02:15:34 +01001278 $(Q) $(INSTALL) -d $(prefix)/bin
Nicolas "Pixel" Noble522d7122015-02-19 01:28:02 +01001279 $(Q) $(INSTALL) $(BINDIR)/$(CONFIG)/${tgt.name} $(prefix)/bin/${tgt.name}
1280% endif
1281% endfor
1282endif
Jan Tattermusch2ec0b3e2015-02-18 15:03:12 -08001283
murgatroid998faab232015-06-30 17:24:21 -07001284install-pkg-config_c: pc_gpr pc_c pc_c_unsecure
1285 $(E) "[INSTALL] Installing C pkg-config files"
1286 $(Q) $(INSTALL) -d $(prefix)/lib/pkgconfig
1287 $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/pkgconfig/gpr.pc $(prefix)/lib/pkgconfig/gpr.pc
1288 $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/pkgconfig/grpc.pc $(prefix)/lib/pkgconfig/grpc.pc
1289 $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/pkgconfig/grpc_unsecure.pc $(prefix)/lib/pkgconfig/grpc_unsecure.pc
1290
1291install-pkg-config_cxx: pc_cxx pc_cxx_unsecure
1292 $(E) "[INSTALL] Installing C++ pkg-config files"
1293 $(Q) $(INSTALL) -d $(prefix)/lib/pkgconfig
1294 $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/pkgconfig/grpc++.pc $(prefix)/lib/pkgconfig/grpc++.pc
1295 $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/pkgconfig/grpc++_unsecure.pc $(prefix)/lib/pkgconfig/grpc++_unsecure.pc
1296
Nicolas "Pixel" Noble161ea232015-02-22 05:48:53 +01001297install-certs: etc/roots.pem
1298 $(E) "[INSTALL] Installing root certificates"
1299 $(Q) $(INSTALL) -d $(prefix)/share/grpc
1300 $(Q) $(INSTALL) etc/roots.pem $(prefix)/share/grpc/roots.pem
1301
Nicolas "Pixel" Noble98ab9982015-02-21 04:22:16 +01001302verify-install:
Nicolas "Pixel" Noble2c23a722015-02-24 20:17:45 +01001303ifeq ($(INSTALL_OK),true)
Nicolas "Pixel" Noble98ab9982015-02-21 04:22:16 +01001304 @echo "Your system looks ready to go."
1305 @echo
1306else
murgatroid99b6181362015-03-02 14:32:25 -08001307 @echo "We couldn't find protoc 3.0.0+ installed on your system. While this"
Nicolas "Pixel" Noble98ab9982015-02-21 04:22:16 +01001308 @echo "won't prevent grpc from working, you won't be able to compile"
1309 @echo "and run any meaningful code with it."
1310 @echo
1311 @echo
1312 @echo "Please download and install protobuf 3.0.0+ from:"
1313 @echo
1314 @echo " https://github.com/google/protobuf/releases"
1315 @echo
murgatroid99b6181362015-03-02 14:32:25 -08001316 @echo "Once you've done so, or if you think this message is in error,"
1317 @echo "you can re-run this check by doing:"
Nicolas "Pixel" Noble98ab9982015-02-21 04:22:16 +01001318 @echo
1319 @echo " make verify-install"
1320endif
1321
Craig Tiller3759e6f2015-01-15 08:13:11 -08001322clean:
Nicolas "Pixel" Noble522d7122015-02-19 01:28:02 +01001323 $(E) "[CLEAN] Cleaning build directories."
murgatroid99aa521572015-07-10 14:49:12 -07001324 $(Q) $(RM) -rf $(OBJDIR) $(LIBDIR) $(BINDIR) $(GENDIR) cache.mk
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001325
1326
1327# The various libraries
1328
1329% for lib in libs:
1330${makelib(lib)}
1331% endfor
1332
1333
nnoble69ac39f2014-12-12 15:43:38 -08001334# All of the test targets, and protoc plugins
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001335
1336% for tgt in targets:
1337${maketarget(tgt)}
1338% endfor
1339
1340<%def name="makelib(lib)">
1341LIB${lib.name.upper()}_SRC = \\
1342
1343% for src in lib.src:
nnoble72309c62014-12-12 11:42:26 -08001344 ${proto_to_cc(src)} \\
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001345
1346% endfor
1347
1348% if "public_headers" in lib:
Craig Tiller59140fc2015-01-18 10:12:17 -08001349% if lib.language == "c++":
nnoble85a49262014-12-08 18:14:03 -08001350PUBLIC_HEADERS_CXX += \\
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001351
nnoble85a49262014-12-08 18:14:03 -08001352% else:
1353PUBLIC_HEADERS_C += \\
1354
1355% endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001356% for hdr in lib.public_headers:
1357 ${hdr} \\
1358
1359% endfor
1360% endif
1361
Craig Tiller61b910f2015-02-15 10:54:07 -08001362LIB${lib.name.upper()}_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(LIB${lib.name.upper()}_SRC))))
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001363
Nicolas "Pixel" Noble4cc8c8a2015-06-23 02:37:49 +02001364## If the library requires OpenSSL, let's add some restrictions.
Nicolas "Pixel" Noble061690d2015-03-06 22:58:58 +01001365% if lib.get('secure', 'check') == 'yes' or lib.get('secure', 'check') == 'check':
nnoble69ac39f2014-12-12 15:43:38 -08001366ifeq ($(NO_SECURE),true)
1367
Nicolas "Pixel" Noble4cc8c8a2015-06-23 02:37:49 +02001368# You can't build secure libraries if you don't have OpenSSL.
Nicolas Noble047b7272015-01-16 13:55:05 -08001369
Craig Tiller61b910f2015-02-15 10:54:07 -08001370$(LIBDIR)/$(CONFIG)/lib${lib.name}.a: openssl_dep_error
nnoble69ac39f2014-12-12 15:43:38 -08001371
nnoble5b7f32a2014-12-22 08:12:44 -08001372% if lib.build == "all":
1373ifeq ($(SYSTEM),MINGW32)
Craig Tiller61b910f2015-02-15 10:54:07 -08001374$(LIBDIR)/$(CONFIG)/${lib.name}.$(SHARED_EXT): openssl_dep_error
nnoble5b7f32a2014-12-22 08:12:44 -08001375else
Craig Tiller61b910f2015-02-15 10:54:07 -08001376$(LIBDIR)/$(CONFIG)/lib${lib.name}.$(SHARED_EXT): openssl_dep_error
nnoble5b7f32a2014-12-22 08:12:44 -08001377endif
1378% endif
1379
nnoble69ac39f2014-12-12 15:43:38 -08001380else
1381
Nicolas Noble53830622015-02-12 16:56:38 -08001382% if lib.language == 'c++':
1383ifeq ($(NO_PROTOBUF),true)
1384
1385# You can't build a C++ library if you don't have protobuf - a bit overreached, but still okay.
1386
Craig Tiller61b910f2015-02-15 10:54:07 -08001387$(LIBDIR)/$(CONFIG)/lib${lib.name}.a: protobuf_dep_error
Nicolas Noble53830622015-02-12 16:56:38 -08001388
1389% if lib.build == "all":
1390ifeq ($(SYSTEM),MINGW32)
Craig Tiller61b910f2015-02-15 10:54:07 -08001391$(LIBDIR)/$(CONFIG)/${lib.name}.$(SHARED_EXT): protobuf_dep_error
Nicolas Noble53830622015-02-12 16:56:38 -08001392else
Craig Tiller61b910f2015-02-15 10:54:07 -08001393$(LIBDIR)/$(CONFIG)/lib${lib.name}.$(SHARED_EXT): protobuf_dep_error
Nicolas Noble53830622015-02-12 16:56:38 -08001394endif
1395% endif
1396
1397else
1398% endif
1399
Craig Tiller61b910f2015-02-15 10:54:07 -08001400$(LIBDIR)/$(CONFIG)/lib${lib.name}.a: $(ZLIB_DEP) $(OPENSSL_DEP)\
Nicolas Noble047b7272015-01-16 13:55:05 -08001401## The else here corresponds to the if secure earlier.
nnoble20e2e3f2014-12-16 15:37:57 -08001402% else:
Nicolas Noble53830622015-02-12 16:56:38 -08001403% if lib.language == 'c++':
1404ifeq ($(NO_PROTOBUF),true)
1405
1406# You can't build a C++ library if you don't have protobuf - a bit overreached, but still okay.
1407
Craig Tiller61b910f2015-02-15 10:54:07 -08001408$(LIBDIR)/$(CONFIG)/lib${lib.name}.a: protobuf_dep_error
Nicolas Noble53830622015-02-12 16:56:38 -08001409
1410% if lib.build == "all":
1411ifeq ($(SYSTEM),MINGW32)
Craig Tiller61b910f2015-02-15 10:54:07 -08001412$(LIBDIR)/$(CONFIG)/${lib.name}.$(SHARED_EXT): protobuf_dep_error
Nicolas Noble53830622015-02-12 16:56:38 -08001413else
Craig Tiller61b910f2015-02-15 10:54:07 -08001414$(LIBDIR)/$(CONFIG)/lib${lib.name}.$(SHARED_EXT): protobuf_dep_error
Nicolas Noble53830622015-02-12 16:56:38 -08001415endif
nnoble20e2e3f2014-12-16 15:37:57 -08001416% endif
Nicolas Noble53830622015-02-12 16:56:38 -08001417
1418else
1419
1420% endif
Craig Tiller61b910f2015-02-15 10:54:07 -08001421$(LIBDIR)/$(CONFIG)/lib${lib.name}.a: $(ZLIB_DEP)\
Nicolas Noble53830622015-02-12 16:56:38 -08001422% endif
1423% if lib.language == 'c++':
1424 $(PROTOBUF_DEP)\
1425% endif
1426 $(LIB${lib.name.upper()}_OBJS)
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001427 $(E) "[AR] Creating $@"
nnoble85a49262014-12-08 18:14:03 -08001428 $(Q) mkdir -p `dirname $@`
Craig Tiller61b910f2015-02-15 10:54:07 -08001429 $(Q) rm -f $(LIBDIR)/$(CONFIG)/lib${lib.name}.a
1430 $(Q) $(AR) rcs $(LIBDIR)/$(CONFIG)/lib${lib.name}.a $(LIB${lib.name.upper()}_OBJS)
nnoble20e2e3f2014-12-16 15:37:57 -08001431% if lib.get('baselib', False):
Nicolas "Pixel" Noble061690d2015-03-06 22:58:58 +01001432% if lib.get('secure', 'check') == 'yes':
Craig Tiller7ab4fee2015-02-24 08:15:53 -08001433 $(Q) rm -rf tmp-merge-${lib.name}
1434 $(Q) mkdir tmp-merge-${lib.name}
1435 $(Q) ( cd tmp-merge-${lib.name} ; $(AR) x ../$(LIBDIR)/$(CONFIG)/lib${lib.name}.a )
1436 $(Q) for l in $(OPENSSL_MERGE_LIBS) ; do ( cd tmp-merge-${lib.name} ; <%text>ar x ../$${l}</%text> ) ; done
1437 $(Q) rm -f $(LIBDIR)/$(CONFIG)/lib${lib.name}.a tmp-merge-${lib.name}/__.SYMDEF*
1438 $(Q) ar rcs $(LIBDIR)/$(CONFIG)/lib${lib.name}.a tmp-merge-${lib.name}/*
1439 $(Q) rm -rf tmp-merge-${lib.name}
nnoble20e2e3f2014-12-16 15:37:57 -08001440% endif
1441% endif
Craig Tillerb4ee3b52015-01-21 16:22:50 -08001442ifeq ($(SYSTEM),Darwin)
murgatroid99b6181362015-03-02 14:32:25 -08001443 $(Q) ranlib $(LIBDIR)/$(CONFIG)/lib${lib.name}.a
Craig Tillerb4ee3b52015-01-21 16:22:50 -08001444endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001445
nnoble5b7f32a2014-12-22 08:12:44 -08001446<%
Nicolas "Pixel" Noble010f1e72015-04-23 02:23:49 +02001447
Craig Tiller59140fc2015-01-18 10:12:17 -08001448 if lib.language == 'c++':
nnoble5b7f32a2014-12-22 08:12:44 -08001449 ld = '$(LDXX)'
1450 else:
1451 ld = '$(LD)'
1452
Craig Tillerda224d62015-02-15 11:01:58 -08001453 out_base = '$(LIBDIR)/$(CONFIG)/' + lib.name
1454 out_libbase = '$(LIBDIR)/$(CONFIG)/lib' + lib.name
nnoble5b7f32a2014-12-22 08:12:44 -08001455
1456 common = '$(LIB' + lib.name.upper() + '_OBJS) $(LDLIBS)'
1457
1458 libs = ''
Nicolas "Pixel" Noble85bf09b2015-01-15 18:22:40 +01001459 lib_deps = ' $(ZLIB_DEP)'
nnoble5b7f32a2014-12-22 08:12:44 -08001460 mingw_libs = ''
Nicolas "Pixel" Noble85bf09b2015-01-15 18:22:40 +01001461 mingw_lib_deps = ' $(ZLIB_DEP)'
Michael Berlinbf2e7f02015-05-01 16:17:01 -07001462 if lib.language == 'c++':
1463 lib_deps += ' $(PROTOBUF_DEP)'
1464 mingw_lib_deps += ' $(PROTOBUF_DEP)'
nnoble5b7f32a2014-12-22 08:12:44 -08001465 for dep in lib.get('deps', []):
1466 libs = libs + ' -l' + dep
Craig Tiller61b910f2015-02-15 10:54:07 -08001467 lib_deps = lib_deps + ' $(LIBDIR)/$(CONFIG)/lib' + dep + '.$(SHARED_EXT)'
nnoble5b7f32a2014-12-22 08:12:44 -08001468 mingw_libs = mingw_libs + ' -l' + dep + '-imp'
Michael Berlin53513922015-05-01 16:14:15 -07001469 mingw_lib_deps = mingw_lib_deps + ' $(LIBDIR)/$(CONFIG)/' + dep + '.$(SHARED_EXT)'
nnoble5b7f32a2014-12-22 08:12:44 -08001470
Nicolas "Pixel" Noblea7c162c2015-07-24 20:21:51 +02001471 security = lib.get('secure', 'check')
1472 if security == 'yes':
Nicolas "Pixel" Noble945b4132015-06-02 20:13:40 +02001473 common = common + ' $(OPENSSL_MERGE_LIBS) $(LDLIBS_SECURE)'
Nicolas "Pixel" Noblea7c162c2015-07-24 20:21:51 +02001474
1475 if security in ['yes', 'check']:
Nicolas "Pixel" Noble010f1e72015-04-23 02:23:49 +02001476 for src in lib.src:
Nicolas "Pixel" Noblea7c162c2015-07-24 20:21:51 +02001477 if not proto_re.match(src):
1478 sources_that_need_openssl.add(src)
Nicolas "Pixel" Noble010f1e72015-04-23 02:23:49 +02001479 else:
1480 for src in lib.src:
1481 sources_that_don_t_need_openssl.add(src)
Nicolas "Pixel" Noble061690d2015-03-06 22:58:58 +01001482
1483 if lib.get('secure', 'check') == 'yes' or lib.get('secure', 'check') == 'check':
nnoble5b7f32a2014-12-22 08:12:44 -08001484 lib_deps = lib_deps + ' $(OPENSSL_DEP)'
1485 mingw_lib_deps = mingw_lib_deps + ' $(OPENSSL_DEP)'
Nicolas "Pixel" Nobledda049c2015-02-21 00:39:32 +01001486
1487 if lib.language == 'c++':
1488 common = common + ' $(LDLIBSXX) $(LDLIBS_PROTOBUF)'
nnoble5b7f32a2014-12-22 08:12:44 -08001489%>
1490
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001491% if lib.build == "all":
nnoble5b7f32a2014-12-22 08:12:44 -08001492ifeq ($(SYSTEM),MINGW32)
1493${out_base}.$(SHARED_EXT): $(LIB${lib.name.upper()}_OBJS) ${mingw_lib_deps}
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001494 $(E) "[LD] Linking $@"
nnoble85a49262014-12-08 18:14:03 -08001495 $(Q) mkdir -p `dirname $@`
Craig Tillerda224d62015-02-15 11:01:58 -08001496 $(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 -08001497else
1498${out_libbase}.$(SHARED_EXT): $(LIB${lib.name.upper()}_OBJS) ${lib_deps}
1499 $(E) "[LD] Linking $@"
1500 $(Q) mkdir -p `dirname $@`
1501ifeq ($(SYSTEM),Darwin)
Masood Malekghassemid1be74f2015-04-07 16:23:09 -07001502 $(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 -08001503else
Craig Tillerda224d62015-02-15 11:01:58 -08001504 $(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 +01001505 $(Q) ln -sf lib${lib.name}.$(SHARED_EXT) ${out_libbase}.so.${settings.version.major}
nnoble5b7f32a2014-12-22 08:12:44 -08001506 $(Q) ln -sf lib${lib.name}.$(SHARED_EXT) ${out_libbase}.so
1507endif
1508endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001509% endif
Nicolas "Pixel" Noble061690d2015-03-06 22:58:58 +01001510% if lib.get('secure', 'check') == 'yes' or lib.get('secure', 'check') == 'check':
Nicolas Noble047b7272015-01-16 13:55:05 -08001511## If the lib was secure, we have to close the Makefile's if that tested
Nicolas "Pixel" Noble4cc8c8a2015-06-23 02:37:49 +02001512## the presence of OpenSSL.
Nicolas Noble53830622015-02-12 16:56:38 -08001513
1514endif
1515% endif
1516% if lib.language == 'c++':
1517## If the lib was C++, we have to close the Makefile's if that tested
1518## the presence of protobuf 3.0.0+
nnoble69ac39f2014-12-12 15:43:38 -08001519
1520endif
1521% endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001522
Nicolas "Pixel" Noble061690d2015-03-06 22:58:58 +01001523% if lib.get('secure', 'check') == 'yes' or lib.get('secure', 'check') == 'check':
nnoble69ac39f2014-12-12 15:43:38 -08001524ifneq ($(NO_SECURE),true)
1525% endif
1526ifneq ($(NO_DEPS),true)
Craig Tiller8f126a62015-01-15 08:50:19 -08001527-include $(LIB${lib.name.upper()}_OBJS:.o=.dep)
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001528endif
Nicolas "Pixel" Noble061690d2015-03-06 22:58:58 +01001529% if lib.get('secure', 'check') == 'yes' or lib.get('secure', 'check') == 'check':
nnoble69ac39f2014-12-12 15:43:38 -08001530endif
1531% endif
Craig Tiller27715ca2015-01-12 16:55:59 -08001532% for src in lib.src:
Craig Tillerd896fa52015-04-24 14:30:09 -07001533% if not proto_re.match(src) and any(proto_re.match(src2) for src2 in lib.src):
Craig Tiller04f81562015-04-24 14:34:30 -07001534$(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 -08001535% endif
Craig Tiller27715ca2015-01-12 16:55:59 -08001536% endfor
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001537</%def>
1538
Nicolas "Pixel" Nobleadaa1002015-04-29 08:56:01 +02001539<%def name="maketarget(tgt)"><% has_no_sources = not tgt.src %>
1540% if not has_no_sources:
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001541${tgt.name.upper()}_SRC = \\
1542
1543% for src in tgt.src:
nnoble72309c62014-12-12 11:42:26 -08001544 ${proto_to_cc(src)} \\
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001545
1546% endfor
1547
Craig Tiller61b910f2015-02-15 10:54:07 -08001548${tgt.name.upper()}_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(${tgt.name.upper()}_SRC))))
Nicolas "Pixel" Nobleadaa1002015-04-29 08:56:01 +02001549% endif
Nicolas "Pixel" Noble061690d2015-03-06 22:58:58 +01001550% if tgt.get('secure', 'check') == 'yes' or tgt.get('secure', 'check') == 'check':
nnoble69ac39f2014-12-12 15:43:38 -08001551ifeq ($(NO_SECURE),true)
1552
Nicolas "Pixel" Noble4cc8c8a2015-06-23 02:37:49 +02001553# You can't build secure targets if you don't have OpenSSL.
Nicolas Noble047b7272015-01-16 13:55:05 -08001554
Craig Tiller61b910f2015-02-15 10:54:07 -08001555$(BINDIR)/$(CONFIG)/${tgt.name}: openssl_dep_error
nnoble69ac39f2014-12-12 15:43:38 -08001556
1557else
1558
1559% endif
Nicolas Noble047b7272015-01-16 13:55:05 -08001560##
1561## We're not trying to add a dependency on building zlib and openssl here,
1562## as it's already done in the libraries. We're assuming that the build
1563## trickles down, and that a secure target requires a secure version of
1564## a library.
1565##
1566## That simplifies the codegen a bit, but prevents a fully defined Makefile.
1567## I can live with that.
1568##
Nicolas "Pixel" Noble18953e32015-02-27 02:41:11 +01001569% if tgt.build == 'protoc' or tgt.language == 'c++':
Nicolas Noble53830622015-02-12 16:56:38 -08001570
1571ifeq ($(NO_PROTOBUF),true)
1572
Nicolas "Pixel" Noble18953e32015-02-27 02:41:11 +01001573# 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 -08001574
Craig Tiller61b910f2015-02-15 10:54:07 -08001575$(BINDIR)/$(CONFIG)/${tgt.name}: protobuf_dep_error
Nicolas Noble53830622015-02-12 16:56:38 -08001576
1577else
1578
Nicolas "Pixel" Nobleadaa1002015-04-29 08:56:01 +02001579$(BINDIR)/$(CONFIG)/${tgt.name}: \
1580% if not has_no_sources:
1581$(PROTOBUF_DEP) $(${tgt.name.upper()}_OBJS)\
1582% endif
Nicolas Noble53830622015-02-12 16:56:38 -08001583% else:
Nicolas "Pixel" Nobleadaa1002015-04-29 08:56:01 +02001584$(BINDIR)/$(CONFIG)/${tgt.name}: \
1585% if not has_no_sources:
1586$(${tgt.name.upper()}_OBJS)\
1587% endif
Nicolas Noble53830622015-02-12 16:56:38 -08001588% endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001589% for dep in tgt.deps:
Craig Tiller61b910f2015-02-15 10:54:07 -08001590 $(LIBDIR)/$(CONFIG)/lib${dep}.a\
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001591% endfor
1592
Craig Tiller59140fc2015-01-18 10:12:17 -08001593% if tgt.language == "c++":
Nicolas Noble047b7272015-01-16 13:55:05 -08001594## C++ targets specificies.
nnoble72309c62014-12-12 11:42:26 -08001595% if tgt.build == 'protoc':
1596 $(E) "[HOSTLD] Linking $@"
1597 $(Q) mkdir -p `dirname $@`
Nicolas "Pixel" Nobleadaa1002015-04-29 08:56:01 +02001598 $(Q) $(HOST_LDXX) $(HOST_LDFLAGS) \
1599% if not has_no_sources:
1600$(${tgt.name.upper()}_OBJS)\
1601% endif
nnoble72309c62014-12-12 11:42:26 -08001602% else:
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001603 $(E) "[LD] Linking $@"
nnoble85a49262014-12-08 18:14:03 -08001604 $(Q) mkdir -p `dirname $@`
Nicolas "Pixel" Nobleadaa1002015-04-29 08:56:01 +02001605 $(Q) $(LDXX) $(LDFLAGS) \
1606% if not has_no_sources:
1607$(${tgt.name.upper()}_OBJS)\
1608% endif
nnoble72309c62014-12-12 11:42:26 -08001609% endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001610% else:
Nicolas Noble047b7272015-01-16 13:55:05 -08001611## C-only targets specificities.
nnoble72309c62014-12-12 11:42:26 -08001612 $(E) "[LD] Linking $@"
1613 $(Q) mkdir -p `dirname $@`
Nicolas "Pixel" Nobleadaa1002015-04-29 08:56:01 +02001614 $(Q) $(LD) $(LDFLAGS) \
1615% if not has_no_sources:
1616$(${tgt.name.upper()}_OBJS)\
1617% endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001618% endif
1619% for dep in tgt.deps:
Craig Tiller61b910f2015-02-15 10:54:07 -08001620 $(LIBDIR)/$(CONFIG)/lib${dep}.a\
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001621% endfor
Craig Tiller59140fc2015-01-18 10:12:17 -08001622% if tgt.language == "c++":
nnoble72309c62014-12-12 11:42:26 -08001623% if tgt.build == 'protoc':
Nicolas Noble53830622015-02-12 16:56:38 -08001624 $(HOST_LDLIBSXX) $(HOST_LDLIBS_PROTOC)\
nnoble72309c62014-12-12 11:42:26 -08001625% else:
Nicolas Noble53830622015-02-12 16:56:38 -08001626 $(LDLIBSXX) $(LDLIBS_PROTOBUF)\
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001627% endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001628% endif
nnoblec78b3402014-12-11 16:06:57 -08001629% if tgt.build == 'protoc':
nnoble72309c62014-12-12 11:42:26 -08001630 $(HOST_LDLIBS)\
1631% else:
1632 $(LDLIBS)\
1633% endif
1634% if tgt.build == 'protoc':
1635 $(HOST_LDLIBS_PROTOC)\
Nicolas "Pixel" Noble061690d2015-03-06 22:58:58 +01001636% elif tgt.get('secure', 'check') == 'yes' or tgt.get('secure', 'check') == 'check':
nnoble72309c62014-12-12 11:42:26 -08001637 $(LDLIBS_SECURE)\
nnoblec78b3402014-12-11 16:06:57 -08001638% endif
Yang Gaob0b518e2015-04-13 14:53:25 -07001639% if tgt.language == 'c++' and tgt.build == 'test':
1640 $(GTEST_LIB)\
David Garcia Quintasaa52d0a2015-05-14 19:04:23 -07001641% elif tgt.language == 'c++' and tgt.build == 'benchmark':
1642 $(GTEST_LIB)\
Yang Gaob0b518e2015-04-13 14:53:25 -07001643% endif
Craig Tiller61b910f2015-02-15 10:54:07 -08001644 -o $(BINDIR)/$(CONFIG)/${tgt.name}
Nicolas "Pixel" Noble18953e32015-02-27 02:41:11 +01001645% if tgt.build == 'protoc' or tgt.language == 'c++':
Nicolas Noble53830622015-02-12 16:56:38 -08001646
1647endif
1648% endif
Nicolas "Pixel" Noble061690d2015-03-06 22:58:58 +01001649% if tgt.get('secure', 'check') == 'yes' or tgt.get('secure', 'check') == 'check':
nnoble69ac39f2014-12-12 15:43:38 -08001650
1651endif
1652% endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001653
Craig Tillerf5371ef2015-01-12 16:40:18 -08001654% for src in tgt.src:
Craig Tiller61b910f2015-02-15 10:54:07 -08001655$(OBJDIR)/$(CONFIG)/${os.path.splitext(src)[0]}.o: \
Craig Tillerf5371ef2015-01-12 16:40:18 -08001656% for dep in tgt.deps:
Craig Tiller61b910f2015-02-15 10:54:07 -08001657 $(LIBDIR)/$(CONFIG)/lib${dep}.a\
Craig Tillerf5371ef2015-01-12 16:40:18 -08001658% endfor
1659
1660% endfor
Nicolas "Pixel" Nobleadaa1002015-04-29 08:56:01 +02001661% if not has_no_sources:
Craig Tiller8f126a62015-01-15 08:50:19 -08001662deps_${tgt.name}: $(${tgt.name.upper()}_OBJS:.o=.dep)
Nicolas "Pixel" Nobleadaa1002015-04-29 08:56:01 +02001663% endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001664
Nicolas "Pixel" Nobleadaa1002015-04-29 08:56:01 +02001665% if not has_no_sources:
Nicolas "Pixel" Noble061690d2015-03-06 22:58:58 +01001666% if tgt.get('secure', 'check') == 'yes' or tgt.get('secure', 'check') == 'check':
nnoble69ac39f2014-12-12 15:43:38 -08001667ifneq ($(NO_SECURE),true)
1668% endif
1669ifneq ($(NO_DEPS),true)
Craig Tiller8f126a62015-01-15 08:50:19 -08001670-include $(${tgt.name.upper()}_OBJS:.o=.dep)
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001671endif
Nicolas "Pixel" Noble061690d2015-03-06 22:58:58 +01001672% if tgt.get('secure', 'check') == 'yes' or tgt.get('secure', 'check') == 'check':
nnoble69ac39f2014-12-12 15:43:38 -08001673endif
1674% endif
Nicolas "Pixel" Nobleadaa1002015-04-29 08:56:01 +02001675% endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001676</%def>
1677
Nicolas "Pixel" Noble010f1e72015-04-23 02:23:49 +02001678ifneq ($(OPENSSL_DEP),)
1679# This is to ensure the embedded OpenSSL is built beforehand, properly
1680# installing headers to their final destination on the drive. We need this
1681# otherwise parallel compilation will fail if a source is compiled first.
1682% for src in sorted(sources_that_need_openssl):
1683% if src not in sources_that_don_t_need_openssl:
1684${src}: $(OPENSSL_DEP)
1685% endif
1686% endfor
1687endif
1688
nnoble85a49262014-12-08 18:14:03 -08001689.PHONY: all strip tools \
nnoble69ac39f2014-12-12 15:43:38 -08001690dep_error openssl_dep_error openssl_dep_message git_update stop \
nnoble85a49262014-12-08 18:14:03 -08001691buildtests buildtests_c buildtests_cxx \
1692test test_c test_cxx \
1693install install_c install_cxx \
1694install-headers install-headers_c install-headers_cxx \
1695install-shared install-shared_c install-shared_cxx \
1696install-static install-static_c install-static_cxx \
1697strip strip-shared strip-static \
1698strip_c strip-shared_c strip-static_c \
1699strip_cxx strip-shared_cxx strip-static_cxx \
Craig Tillerf0afe502015-01-15 09:04:49 -08001700dep_c dep_cxx bins_dep_c bins_dep_cxx \
Craig Tiller12c82092015-01-15 08:45:56 -08001701clean