blob: bc8f1bb1d071b7db97b864ae18bf0bded5a5acb0 [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.
Craig Tiller3b935482015-02-16 12:15:48 -08005
Craig Tillerd7f33352015-02-20 15:18:45 -08006# Copyright 2015, Google Inc.
Craig Tiller3b935482015-02-16 12:15:48 -08007# All rights reserved.
8#
9# Redistribution and use in source and binary forms, with or without
10# modification, are permitted provided that the following conditions are
11# met:
12#
13# * Redistributions of source code must retain the above copyright
14# notice, this list of conditions and the following disclaimer.
15# * Redistributions in binary form must reproduce the above
16# copyright notice, this list of conditions and the following disclaimer
17# in the documentation and/or other materials provided with the
18# distribution.
19# * Neither the name of Google Inc. nor the names of its
20# contributors may be used to endorse or promote products derived from
21# this software without specific prior written permission.
22#
23# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
27# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
29# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
30# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -080034<%!
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -080035 import re
Craig Tillerf5371ef2015-01-12 16:40:18 -080036 import os
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -080037
nnoblec87b1c52015-01-05 17:15:18 -080038 proto_re = re.compile('(.*)\\.proto')
nnoble72309c62014-12-12 11:42:26 -080039
nnoble72309c62014-12-12 11:42:26 -080040 def proto_to_cc(filename):
41 m = proto_re.match(filename)
42 if not m:
43 return filename
Nicolas "Pixel" Noble0caebbf2015-04-09 23:08:51 +020044 return '$(GENDIR)/' + m.group(1) + '.pb.cc $(GENDIR)/' + m.group(1) + '.grpc.pb.cc'
Nicolas "Pixel" Noble010f1e72015-04-23 02:23:49 +020045
46 sources_that_need_openssl = set()
47 sources_that_don_t_need_openssl = set()
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -080048%>
49
Craig Tiller96b49552015-01-21 16:29:01 -080050
51# Basic platform detection
52HOST_SYSTEM = $(shell uname | cut -f 1 -d_)
53ifeq ($(SYSTEM),)
54SYSTEM = $(HOST_SYSTEM)
55endif
Nicolas Noblef8681182015-03-18 14:25:44 -070056ifeq ($(SYSTEM),MSYS)
57SYSTEM = MINGW32
58endif
Nicolas "Pixel" Noble5fc1adf2015-05-10 22:20:31 +020059ifeq ($(SYSTEM),MINGW64)
60SYSTEM = MINGW32
61endif
Craig Tiller96b49552015-01-21 16:29:01 -080062
63
Craig Tiller61b910f2015-02-15 10:54:07 -080064ifndef BUILDDIR
65BUILDDIR = .
66endif
67
Nicolas Noblef8681182015-03-18 14:25:44 -070068HAS_GCC = $(shell which gcc > /dev/null 2> /dev/null && echo true || echo false)
69HAS_CC = $(shell which cc > /dev/null 2> /dev/null && echo true || echo false)
70HAS_CLANG = $(shell which clang > /dev/null 2> /dev/null && echo true || echo false)
71
72ifeq ($(HAS_CC),true)
73DEFAULT_CC = cc
74DEFAULT_CXX = c++
75else
76ifeq ($(HAS_GCC),true)
77DEFAULT_CC = gcc
78DEFAULT_CXX = g++
79else
80ifeq ($(HAS_CLANG),true)
81DEFAULT_CC = clang
82DEFAULT_CXX = clang++
83else
84DEFAULT_CC = no_c_compiler
85DEFAULT_CXX = no_c++_compiler
86endif
87endif
88endif
89
90
Craig Tiller61b910f2015-02-15 10:54:07 -080091BINDIR = $(BUILDDIR)/bins
92OBJDIR = $(BUILDDIR)/objs
93LIBDIR = $(BUILDDIR)/libs
94GENDIR = $(BUILDDIR)/gens
95
ctiller8cfebb92015-01-06 15:02:12 -080096# Configurations
97
98VALID_CONFIG_opt = 1
Nicolas Noblef8681182015-03-18 14:25:44 -070099CC_opt = $(DEFAULT_CC)
100CXX_opt = $(DEFAULT_CXX)
101LD_opt = $(DEFAULT_CC)
102LDXX_opt = $(DEFAULT_CXX)
ctiller8cfebb92015-01-06 15:02:12 -0800103CPPFLAGS_opt = -O2
104LDFLAGS_opt =
105DEFINES_opt = NDEBUG
106
David Garcia Quintas8954e902015-04-29 09:46:33 -0700107VALID_CONFIG_basicprof = 1
108CC_basicprof = $(DEFAULT_CC)
109CXX_basicprof = $(DEFAULT_CXX)
110LD_basicprof = $(DEFAULT_CC)
111LDXX_basicprof = $(DEFAULT_CXX)
Craig Tiller113d1692015-05-01 15:26:15 -0700112CPPFLAGS_basicprof = -O2 -DGRPC_BASIC_PROFILER -DGRPC_TIMERS_RDTSC
David Garcia Quintas8954e902015-04-29 09:46:33 -0700113LDFLAGS_basicprof =
114DEFINES_basicprof = NDEBUG
115
116VALID_CONFIG_stapprof = 1
117CC_stapprof = $(DEFAULT_CC)
118CXX_stapprof = $(DEFAULT_CXX)
119LD_stapprof = $(DEFAULT_CC)
120LDXX_stapprof = $(DEFAULT_CXX)
121CPPFLAGS_stapprof = -O2 -DGRPC_STAP_PROFILER
122LDFLAGS_stapprof =
123DEFINES_stapprof = NDEBUG
Vijay Paibc171132015-04-13 10:58:06 -0700124
ctiller8cfebb92015-01-06 15:02:12 -0800125VALID_CONFIG_dbg = 1
Nicolas Noblef8681182015-03-18 14:25:44 -0700126CC_dbg = $(DEFAULT_CC)
127CXX_dbg = $(DEFAULT_CXX)
128LD_dbg = $(DEFAULT_CC)
129LDXX_dbg = $(DEFAULT_CXX)
ctiller8cfebb92015-01-06 15:02:12 -0800130CPPFLAGS_dbg = -O0
131LDFLAGS_dbg =
132DEFINES_dbg = _DEBUG DEBUG
133
Vijay Paidc7110f2015-04-02 13:59:05 -0700134VALID_CONFIG_mutrace = 1
135CC_mutrace = $(DEFAULT_CC)
136CXX_mutrace = $(DEFAULT_CXX)
137LD_mutrace = $(DEFAULT_CC)
138LDXX_mutrace = $(DEFAULT_CXX)
139CPPFLAGS_mutrace = -O0
140LDFLAGS_mutrace = -rdynamic
141DEFINES_mutrace = _DEBUG DEBUG
142
Craig Tillerec0b8f32015-01-15 07:30:00 -0800143VALID_CONFIG_valgrind = 1
Craig Tillerc4da6b72015-01-15 08:01:14 -0800144REQUIRE_CUSTOM_LIBRARIES_valgrind = 1
Nicolas Noblef8681182015-03-18 14:25:44 -0700145CC_valgrind = $(DEFAULT_CC)
146CXX_valgrind = $(DEFAULT_CXX)
147LD_valgrind = $(DEFAULT_CC)
148LDXX_valgrind = $(DEFAULT_CXX)
Craig Tillerec0b8f32015-01-15 07:30:00 -0800149CPPFLAGS_valgrind = -O0
150OPENSSL_CFLAGS_valgrind = -DPURIFY
151LDFLAGS_valgrind =
Craig Tillerf6901be2015-02-27 09:12:58 -0800152DEFINES_valgrind = _DEBUG DEBUG GRPC_TEST_SLOWDOWN_BUILD_FACTOR=20
Craig Tillerec0b8f32015-01-15 07:30:00 -0800153
ctiller8cfebb92015-01-06 15:02:12 -0800154VALID_CONFIG_tsan = 1
Craig Tillerc4da6b72015-01-15 08:01:14 -0800155REQUIRE_CUSTOM_LIBRARIES_tsan = 1
ctiller8cfebb92015-01-06 15:02:12 -0800156CC_tsan = clang
157CXX_tsan = clang++
158LD_tsan = clang
159LDXX_tsan = clang++
160CPPFLAGS_tsan = -O1 -fsanitize=thread -fno-omit-frame-pointer
161LDFLAGS_tsan = -fsanitize=thread
Craig Tillerf6901be2015-02-27 09:12:58 -0800162DEFINES_tsan = NDEBUG GRPC_TEST_SLOWDOWN_BUILD_FACTOR=10
ctiller8cfebb92015-01-06 15:02:12 -0800163
164VALID_CONFIG_asan = 1
Craig Tillerc4da6b72015-01-15 08:01:14 -0800165REQUIRE_CUSTOM_LIBRARIES_asan = 1
ctiller8cfebb92015-01-06 15:02:12 -0800166CC_asan = clang
167CXX_asan = clang++
168LD_asan = clang
169LDXX_asan = clang++
Craig Tiller6902ad22015-04-16 08:01:49 -0700170CPPFLAGS_asan = -O0 -fsanitize=address -fno-omit-frame-pointer
ctiller8cfebb92015-01-06 15:02:12 -0800171LDFLAGS_asan = -fsanitize=address
Craig Tiller6902ad22015-04-16 08:01:49 -0700172DEFINES_asan = GRPC_TEST_SLOWDOWN_BUILD_FACTOR=5
ctiller8cfebb92015-01-06 15:02:12 -0800173
174VALID_CONFIG_msan = 1
Craig Tillerc4da6b72015-01-15 08:01:14 -0800175REQUIRE_CUSTOM_LIBRARIES_msan = 1
ctiller8cfebb92015-01-06 15:02:12 -0800176CC_msan = clang
Nicolas "Pixel" Nobled66cba22015-02-14 02:59:12 +0100177CXX_msan = clang++-libc++
ctiller8cfebb92015-01-06 15:02:12 -0800178LD_msan = clang
Nicolas "Pixel" Nobled66cba22015-02-14 02:59:12 +0100179LDXX_msan = clang++-libc++
Craig Tiller6902ad22015-04-16 08:01:49 -0700180CPPFLAGS_msan = -O0 -fsanitize=memory -fsanitize-memory-track-origins -fno-omit-frame-pointer -DGTEST_HAS_TR1_TUPLE=0 -DGTEST_USE_OWN_TR1_TUPLE=1
Craig Tillerec0b8f32015-01-15 07:30:00 -0800181OPENSSL_CFLAGS_msan = -DPURIFY
Nicolas "Pixel" Nobled66cba22015-02-14 02:59:12 +0100182LDFLAGS_msan = -fsanitize=memory -DGTEST_HAS_TR1_TUPLE=0 -DGTEST_USE_OWN_TR1_TUPLE=1
Craig Tillerf6901be2015-02-27 09:12:58 -0800183DEFINES_msan = NDEBUG GRPC_TEST_SLOWDOWN_BUILD_FACTOR=20
ctiller8cfebb92015-01-06 15:02:12 -0800184
Craig Tiller96bd5f62015-02-13 09:04:13 -0800185VALID_CONFIG_ubsan = 1
186REQUIRE_CUSTOM_LIBRARIES_ubsan = 1
187CC_ubsan = clang
188CXX_ubsan = clang++
189LD_ubsan = clang
190LDXX_ubsan = clang++
191CPPFLAGS_ubsan = -O1 -fsanitize=undefined -fno-omit-frame-pointer
192OPENSSL_CFLAGS_ubsan = -DPURIFY
Craig Tiller96bd5f62015-02-13 09:04:13 -0800193LDFLAGS_ubsan = -fsanitize=undefined
Craig Tillerf6901be2015-02-27 09:12:58 -0800194DEFINES_ubsan = NDEBUG GRPC_TEST_SLOWDOWN_BUILD_FACTOR=10
Craig Tiller96bd5f62015-02-13 09:04:13 -0800195
Craig Tiller699ba212015-01-13 17:02:20 -0800196VALID_CONFIG_gcov = 1
197CC_gcov = gcc
198CXX_gcov = g++
199LD_gcov = gcc
200LDXX_gcov = g++
201CPPFLAGS_gcov = -O0 -fprofile-arcs -ftest-coverage
202LDFLAGS_gcov = -fprofile-arcs -ftest-coverage
Craig Tiller2e4a7dc2015-04-30 09:22:31 -0700203DEFINES_gcov = _DEBUG DEBUG
Craig Tiller699ba212015-01-13 17:02:20 -0800204
Nicolas Noble047b7272015-01-16 13:55:05 -0800205
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800206# General settings.
207# You may want to change these depending on your system.
208
209prefix ?= /usr/local
210
211PROTOC = protoc
David Garcia Quintas611b7362015-04-27 15:49:31 -0700212DTRACE = dtrace
yangg102e4fe2015-01-06 16:02:50 -0800213CONFIG ?= opt
ctiller8cfebb92015-01-06 15:02:12 -0800214CC = $(CC_$(CONFIG))
215CXX = $(CXX_$(CONFIG))
216LD = $(LD_$(CONFIG))
217LDXX = $(LDXX_$(CONFIG))
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800218AR = ar
Nicolas "Pixel" Nobled7631a42015-02-27 07:52:39 +0100219ifeq ($(SYSTEM),Linux)
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800220STRIP = strip --strip-unneeded
Nicolas "Pixel" Nobled7631a42015-02-27 07:52:39 +0100221else
222ifeq ($(SYSTEM),Darwin)
223STRIP = strip -x
224else
225STRIP = strip
226endif
227endif
Nicolas "Pixel" Noble932d5d32015-02-21 02:15:34 +0100228INSTALL = install
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800229RM = rm -f
230
yangg102e4fe2015-01-06 16:02:50 -0800231ifndef VALID_CONFIG_$(CONFIG)
232$(error Invalid CONFIG value '$(CONFIG)')
233endif
234
Nicolas "Pixel" Noblee758ed12015-03-11 22:51:39 +0100235ifeq ($(SYSTEM),Linux)
236TMPOUT = /dev/null
237else
238TMPOUT = `mktemp /tmp/test-out-XXXXXX`
239endif
Nicolas Noble047b7272015-01-16 13:55:05 -0800240
Craig Tillercf133f42015-02-26 14:05:56 -0800241# Detect if we can use C++11
Nicolas "Pixel" Noblee758ed12015-03-11 22:51:39 +0100242CXX11_CHECK_CMD = $(CXX) -std=c++11 -o $(TMPOUT) -c test/build/c++11.cc
Craig Tillercf133f42015-02-26 14:05:56 -0800243HAS_CXX11 = $(shell $(CXX11_CHECK_CMD) 2> /dev/null && echo true || echo false)
244
Nicolas Noble047b7272015-01-16 13:55:05 -0800245# The HOST compiler settings are used to compile the protoc plugins.
246# In most cases, you won't have to change anything, but if you are
247# cross-compiling, you can override these variables from GNU make's
248# command line: make CC=cross-gcc HOST_CC=gcc
249
nnoble72309c62014-12-12 11:42:26 -0800250HOST_CC = $(CC)
251HOST_CXX = $(CXX)
252HOST_LD = $(LD)
253HOST_LDXX = $(LDXX)
254
ctillercab52e72015-01-06 13:10:23 -0800255CPPFLAGS += $(CPPFLAGS_$(CONFIG))
Nicolas "Pixel" Noble72743822015-02-20 20:59:29 +0100256DEFINES += $(DEFINES_$(CONFIG)) INSTALL_PREFIX=\"$(prefix)\"
ctiller8cfebb92015-01-06 15:02:12 -0800257LDFLAGS += $(LDFLAGS_$(CONFIG))
ctillercab52e72015-01-06 13:10:23 -0800258
Craig Tiller86fa1c52015-02-27 09:57:58 -0800259ifdef EXTRA_DEFINES
Craig Tillerf5065c52015-02-27 16:17:39 -0800260DEFINES += $(EXTRA_DEFINES)
Craig Tiller86fa1c52015-02-27 09:57:58 -0800261endif
262
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800263CFLAGS += -std=c89 -pedantic
Craig Tillercf133f42015-02-26 14:05:56 -0800264ifeq ($(HAS_CXX11),true)
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800265CXXFLAGS += -std=c++11
Craig Tillercf133f42015-02-26 14:05:56 -0800266else
267CXXFLAGS += -std=c++0x
Craig Tillercf133f42015-02-26 14:05:56 -0800268endif
Nicolas Noblef8681182015-03-18 14:25:44 -0700269CPPFLAGS += -g -Wall -Wextra -Werror -Wno-long-long -Wno-unused-parameter
270LDFLAGS += -g
271
272ifneq ($(SYSTEM),MINGW32)
273PIC_CPPFLAGS = -fPIC
274CPPFLAGS += -fPIC
275LDFLAGS += -fPIC
276endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800277
Craig Tillerda224d62015-02-15 11:01:58 -0800278INCLUDES = . include $(GENDIR)
Craig Tiller96b49552015-01-21 16:29:01 -0800279ifeq ($(SYSTEM),Darwin)
Nicolas "Pixel" Noblee758ed12015-03-11 22:51:39 +0100280ifneq ($(wildcard /usr/local/ssl/include),)
281INCLUDES += /usr/local/ssl/include
282endif
283ifneq ($(wildcard /opt/local/include),)
284INCLUDES += /opt/local/include
285endif
286ifneq ($(wildcard /usr/local/include),)
287INCLUDES += /usr/local/include
288endif
Craig Tiller96b49552015-01-21 16:29:01 -0800289LIBS = m z
Nicolas "Pixel" Noblee758ed12015-03-11 22:51:39 +0100290ifneq ($(wildcard /usr/local/ssl/lib),)
291LDFLAGS += -L/usr/local/ssl/lib
292endif
293ifneq ($(wildcard /opt/local/lib),)
294LDFLAGS += -L/opt/local/lib
295endif
296ifneq ($(wildcard /usr/local/lib),)
297LDFLAGS += -L/usr/local/lib
298endif
Nicolas Noblef8681182015-03-18 14:25:44 -0700299endif
300
301ifeq ($(SYSTEM),Linux)
ctillerc008ae52015-01-07 15:33:00 -0800302LIBS = rt m z pthread
Craig Tiller96b49552015-01-21 16:29:01 -0800303LDFLAGS += -pthread
304endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800305
Nicolas Noblef8681182015-03-18 14:25:44 -0700306ifeq ($(SYSTEM),MINGW32)
307LIBS = m z pthread
308LDFLAGS += -pthread
309endif
310
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800311ifneq ($(wildcard /usr/src/gtest/src/gtest-all.cc),)
312GTEST_LIB = /usr/src/gtest/src/gtest-all.cc -I/usr/src/gtest
313else
314GTEST_LIB = -lgtest
315endif
chenwa8fd44a2014-12-10 15:13:55 -0800316GTEST_LIB += -lgflags
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800317ifeq ($(V),1)
318E = @:
319Q =
320else
321E = @echo
322Q = @
323endif
324
325VERSION = ${settings.version.major}.${settings.version.minor}.${settings.version.micro}.${settings.version.build}
326
327CPPFLAGS_NO_ARCH += $(addprefix -I, $(INCLUDES)) $(addprefix -D, $(DEFINES))
328CPPFLAGS += $(CPPFLAGS_NO_ARCH) $(ARCH_FLAGS)
329
330LDFLAGS += $(ARCH_FLAGS)
331LDLIBS += $(addprefix -l, $(LIBS))
332LDLIBSXX += $(addprefix -l, $(LIBSXX))
nnoble72309c62014-12-12 11:42:26 -0800333
334HOST_CPPFLAGS = $(CPPFLAGS)
335HOST_CFLAGS = $(CFLAGS)
336HOST_CXXFLAGS = $(CXXFLAGS)
337HOST_LDFLAGS = $(LDFLAGS)
338HOST_LDLIBS = $(LDLIBS)
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800339
nnoble69ac39f2014-12-12 15:43:38 -0800340
341# These are automatically computed variables.
342# There shouldn't be any need to change anything from now on.
343
nnoble5b7f32a2014-12-22 08:12:44 -0800344ifeq ($(SYSTEM),MINGW32)
345SHARED_EXT = dll
346endif
347ifeq ($(SYSTEM),Darwin)
348SHARED_EXT = dylib
349endif
350ifeq ($(SHARED_EXT),)
351SHARED_EXT = so.$(VERSION)
352endif
353
nnoble69ac39f2014-12-12 15:43:38 -0800354ifeq ($(wildcard .git),)
355IS_GIT_FOLDER = false
356else
357IS_GIT_FOLDER = true
358endif
359
Nicolas Noblef8681182015-03-18 14:25:44 -0700360ifeq ($(SYSTEM),Linux)
361OPENSSL_REQUIRES_DL = true
362endif
363
364ifeq ($(SYSTEM),Darwin)
365OPENSSL_REQUIRES_DL = true
366endif
367
368ifeq ($(SYSTEM),MINGW32)
369OPENSSL_LIBS = ssl32 eay32
370else
371OPENSSL_LIBS = ssl crypto
372endif
373
374OPENSSL_ALPN_CHECK_CMD = $(CC) $(CFLAGS) $(CPPFLAGS) -o $(TMPOUT) test/build/openssl-alpn.c $(addprefix -l, $(OPENSSL_LIBS)) $(LDFLAGS)
Nicolas "Pixel" Noblee758ed12015-03-11 22:51:39 +0100375ZLIB_CHECK_CMD = $(CC) $(CFLAGS) $(CPPFLAGS) -o $(TMPOUT) test/build/zlib.c -lz $(LDFLAGS)
376PERFTOOLS_CHECK_CMD = $(CC) $(CFLAGS) $(CPPFLAGS) -o $(TMPOUT) test/build/perftools.c -lprofiler $(LDFLAGS)
377PROTOBUF_CHECK_CMD = $(CXX) $(CXXFLAGS) $(CPPFLAGS) -o $(TMPOUT) test/build/protobuf.cc -lprotobuf $(LDFLAGS)
David Garcia Quintasf5fcafd2015-04-24 16:12:54 -0700378PROTOC_CHECK_CMD = which protoc > /dev/null
379PROTOC_CHECK_VERSION_CMD = protoc --version | grep -q libprotoc.3
David Garcia Quintas611b7362015-04-27 15:49:31 -0700380DTRACE_CHECK_CMD = which dtrace > /dev/null
381SYSTEMTAP_HEADERS_CHECK_CMD = $(CC) $(CFLAGS) $(CPPFLAGS) -o $(TMPOUT) test/build/systemtap.c $(LDFLAGS)
Craig Tiller297fafa2015-01-15 15:46:39 -0800382
Nicolas Noblef8681182015-03-18 14:25:44 -0700383ifeq ($(OPENSSL_REQUIRES_DL),true)
384OPENSSL_ALPN_CHECK_CMD += -ldl
385endif
386
Craig Tiller50524cc2015-01-29 23:00:00 -0800387ifndef REQUIRE_CUSTOM_LIBRARIES_$(CONFIG)
Craig Tiller297fafa2015-01-15 15:46:39 -0800388HAS_SYSTEM_PERFTOOLS = $(shell $(PERFTOOLS_CHECK_CMD) 2> /dev/null && echo true || echo false)
389ifeq ($(HAS_SYSTEM_PERFTOOLS),true)
390DEFINES += GRPC_HAVE_PERFTOOLS
391LIBS += profiler
392endif
Craig Tiller50524cc2015-01-29 23:00:00 -0800393endif
nnoble69ac39f2014-12-12 15:43:38 -0800394
Nicolas "Pixel" Noble98ab9982015-02-21 04:22:16 +0100395HAS_SYSTEM_PROTOBUF_VERIFY = $(shell $(PROTOBUF_CHECK_CMD) 2> /dev/null && echo true || echo false)
Craig Tillerc4da6b72015-01-15 08:01:14 -0800396ifndef REQUIRE_CUSTOM_LIBRARIES_$(CONFIG)
nnoble60825402014-12-15 14:43:51 -0800397HAS_SYSTEM_OPENSSL_ALPN = $(shell $(OPENSSL_ALPN_CHECK_CMD) 2> /dev/null && echo true || echo false)
398HAS_SYSTEM_ZLIB = $(shell $(ZLIB_CHECK_CMD) 2> /dev/null && echo true || echo false)
Nicolas "Pixel" Noble98ab9982015-02-21 04:22:16 +0100399HAS_SYSTEM_PROTOBUF = $(HAS_SYSTEM_PROTOBUF_VERIFY)
Craig Tillerc4da6b72015-01-15 08:01:14 -0800400else
401# override system libraries if the config requires a custom compiled library
402HAS_SYSTEM_OPENSSL_ALPN = false
403HAS_SYSTEM_ZLIB = false
Nicolas Noble53830622015-02-12 16:56:38 -0800404HAS_SYSTEM_PROTOBUF = false
Craig Tillerc4da6b72015-01-15 08:01:14 -0800405endif
nnoble69ac39f2014-12-12 15:43:38 -0800406
David Garcia Quintasf5fcafd2015-04-24 16:12:54 -0700407HAS_PROTOC = $(shell $(PROTOC_CHECK_CMD) 2> /dev/null && echo true || echo false)
Nicolas "Pixel" Noble98ab9982015-02-21 04:22:16 +0100408ifeq ($(HAS_PROTOC),true)
David Garcia Quintasf5fcafd2015-04-24 16:12:54 -0700409HAS_VALID_PROTOC = $(shell $(PROTOC_CHECK_VERSION_CMD) 2> /dev/null && echo true || echo false)
Nicolas "Pixel" Noble98ab9982015-02-21 04:22:16 +0100410else
411HAS_VALID_PROTOC = false
412endif
Nicolas Noble53830622015-02-12 16:56:38 -0800413
David Garcia Quintas611b7362015-04-27 15:49:31 -0700414# Check for Systemtap (https://sourceware.org/systemtap/), first by making sure <sys/sdt.h> is present
415# in the system and secondly by checking for the "dtrace" binary (on Linux, this is part of the Systemtap
416# distribution. It's part of the base system on BSD/Solaris machines).
417HAS_SYSTEMTAP_HEADERS = $(shell $(SYSTEMTAP_HEADERS_CHECK_CMD) 2> /dev/null && echo true || echo false)
418HAS_DTRACE = $(shell $(DTRACE_CHECK_CMD) 2> /dev/null && echo true || echo false)
419HAS_SYSTEMTAP = false
420ifeq ($(HAS_SYSTEMTAP_HEADERS),true)
421ifeq ($(HAS_DTRACE),true)
422HAS_SYSTEMTAP = true
David Garcia Quintas611b7362015-04-27 15:49:31 -0700423endif
424endif
425
nnoble69ac39f2014-12-12 15:43:38 -0800426ifeq ($(wildcard third_party/openssl/ssl/ssl.h),)
427HAS_EMBEDDED_OPENSSL_ALPN = false
428else
429HAS_EMBEDDED_OPENSSL_ALPN = true
430endif
431
432ifeq ($(wildcard third_party/zlib/zlib.h),)
433HAS_EMBEDDED_ZLIB = false
434else
435HAS_EMBEDDED_ZLIB = true
436endif
437
Nicolas Noble53830622015-02-12 16:56:38 -0800438ifeq ($(wildcard third_party/protobuf/src/google/protobuf/descriptor.pb.h),)
439HAS_EMBEDDED_PROTOBUF = false
440ifneq ($(HAS_VALID_PROTOC),true)
441NO_PROTOC = true
442endif
443else
444HAS_EMBEDDED_PROTOBUF = true
445endif
446
nnoble69ac39f2014-12-12 15:43:38 -0800447ifeq ($(HAS_SYSTEM_ZLIB),false)
448ifeq ($(HAS_EMBEDDED_ZLIB),true)
Craig Tiller61b910f2015-02-15 10:54:07 -0800449ZLIB_DEP = $(LIBDIR)/$(CONFIG)/zlib/libz.a
nnoble69ac39f2014-12-12 15:43:38 -0800450CPPFLAGS += -Ithird_party/zlib
Craig Tillerda224d62015-02-15 11:01:58 -0800451LDFLAGS += -L$(LIBDIR)/$(CONFIG)/zlib
nnoble69ac39f2014-12-12 15:43:38 -0800452else
453DEP_MISSING += zlib
454endif
455endif
456
457ifeq ($(HAS_SYSTEM_OPENSSL_ALPN),false)
458ifeq ($(HAS_EMBEDDED_OPENSSL_ALPN),true)
Craig Tiller61b910f2015-02-15 10:54:07 -0800459OPENSSL_DEP = $(LIBDIR)/$(CONFIG)/openssl/libssl.a
460OPENSSL_MERGE_LIBS += $(LIBDIR)/$(CONFIG)/openssl/libssl.a $(LIBDIR)/$(CONFIG)/openssl/libcrypto.a
Craig Tillerec043032015-02-20 17:24:41 -0800461# need to prefix these to ensure overriding system libraries
462CPPFLAGS := -Ithird_party/openssl/include $(CPPFLAGS)
463LDFLAGS := -L$(LIBDIR)/$(CONFIG)/openssl $(LDFLAGS)
Nicolas Noblef8681182015-03-18 14:25:44 -0700464ifeq ($(OPENSSL_REQUIRES_DL),true)
nnoble5b7f32a2014-12-22 08:12:44 -0800465LIBS_SECURE = dl
Nicolas Noblef8681182015-03-18 14:25:44 -0700466endif
nnoble69ac39f2014-12-12 15:43:38 -0800467else
468NO_SECURE = true
469endif
nnoble5b7f32a2014-12-22 08:12:44 -0800470else
Nicolas Noblef8681182015-03-18 14:25:44 -0700471LIBS_SECURE = $(OPENSSL_LIBS)
472ifeq ($(OPENSSL_REQUIRES_DL),true)
473LIBS_SECURE += dl
474endif
nnoble69ac39f2014-12-12 15:43:38 -0800475endif
476
nnoble5b7f32a2014-12-22 08:12:44 -0800477LDLIBS_SECURE += $(addprefix -l, $(LIBS_SECURE))
478
Nicolas Noble53830622015-02-12 16:56:38 -0800479ifeq ($(HAS_SYSTEM_PROTOBUF),false)
480ifeq ($(HAS_EMBEDDED_PROTOBUF),true)
Craig Tiller61b910f2015-02-15 10:54:07 -0800481PROTOBUF_DEP = $(LIBDIR)/$(CONFIG)/protobuf/libprotobuf.a
Craig Tiller9ec95fa2015-02-20 20:36:21 -0800482CPPFLAGS := -Ithird_party/protobuf/src $(CPPFLAGS)
483LDFLAGS := -L$(LIBDIR)/$(CONFIG)/protobuf $(LDFLAGS)
Craig Tiller61b910f2015-02-15 10:54:07 -0800484PROTOC = $(BINDIR)/$(CONFIG)/protobuf/protoc
Nicolas Noble53830622015-02-12 16:56:38 -0800485else
486NO_PROTOBUF = true
487endif
488else
489endif
490
491LIBS_PROTOBUF = protobuf
492LIBS_PROTOC = protoc protobuf
493
494LDLIBS_PROTOBUF += $(addprefix -l, $(LIBS_PROTOBUF))
495HOST_LDLIBS_PROTOC += $(addprefix -l, $(LIBS_PROTOC))
496
Craig Tiller12c82092015-01-15 08:45:56 -0800497ifeq ($(MAKECMDGOALS),clean)
nnoble69ac39f2014-12-12 15:43:38 -0800498NO_DEPS = true
499endif
500
Nicolas "Pixel" Noble98ab9982015-02-21 04:22:16 +0100501INSTALL_OK = false
502ifeq ($(HAS_VALID_PROTOC),true)
503ifeq ($(HAS_SYSTEM_PROTOBUF_VERIFY),true)
504INSTALL_OK = true
505endif
506endif
507
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800508.SECONDARY = %.pb.h %.pb.cc
509
Nicolas "Pixel" Noble522d7122015-02-19 01:28:02 +0100510PROTOC_PLUGINS =\
Craig Tillerf58b9ef2015-01-15 09:09:12 -0800511% for tgt in targets:
512% if tgt.build == 'protoc':
Craig Tiller61b910f2015-02-15 10:54:07 -0800513 $(BINDIR)/$(CONFIG)/${tgt.name}\
Craig Tillerf58b9ef2015-01-15 09:09:12 -0800514% endif
515% endfor
516
nnoble69ac39f2014-12-12 15:43:38 -0800517ifeq ($(DEP_MISSING),)
Nicolas "Pixel" Noble522d7122015-02-19 01:28:02 +0100518all: static shared plugins\
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800519% for tgt in targets:
520% if tgt.build == 'all':
Craig Tiller61b910f2015-02-15 10:54:07 -0800521 $(BINDIR)/$(CONFIG)/${tgt.name}\
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800522% endif
523% endfor
524
nnoble69ac39f2014-12-12 15:43:38 -0800525dep_error:
526 @echo "You shouldn't see this message - all of your dependencies are correct."
527else
528all: dep_error git_update stop
529
530dep_error:
531 @echo
532 @echo "DEPENDENCY ERROR"
533 @echo
534 @echo "You are missing system dependencies that are essential to build grpc,"
535 @echo "and the third_party directory doesn't have them:"
536 @echo
537 @echo " $(DEP_MISSING)"
538 @echo
539 @echo "Installing the development packages for your system will solve"
540 @echo "this issue. Please consult INSTALL to get more information."
541 @echo
542 @echo "If you need information about why these tests failed, run:"
543 @echo
544 @echo " make run_dep_checks"
545 @echo
546endif
547
548git_update:
549ifeq ($(IS_GIT_FOLDER),true)
550 @echo "Additionally, since you are in a git clone, you can download the"
551 @echo "missing dependencies in third_party by running the following command:"
552 @echo
ctiller64f29102014-12-15 10:40:59 -0800553 @echo " git submodule update --init"
nnoble69ac39f2014-12-12 15:43:38 -0800554 @echo
555endif
556
557openssl_dep_error: openssl_dep_message git_update stop
558
Nicolas Noble53830622015-02-12 16:56:38 -0800559protobuf_dep_error: protobuf_dep_message git_update stop
560
561protoc_dep_error: protoc_dep_message git_update stop
562
nnoble69ac39f2014-12-12 15:43:38 -0800563openssl_dep_message:
564 @echo
565 @echo "DEPENDENCY ERROR"
566 @echo
567 @echo "The target you are trying to run requires OpenSSL with ALPN support."
568 @echo "Your system doesn't have it, and neither does the third_party directory."
569 @echo
570 @echo "Please consult INSTALL to get more information."
571 @echo
572 @echo "If you need information about why these tests failed, run:"
573 @echo
574 @echo " make run_dep_checks"
575 @echo
576
Nicolas Noble53830622015-02-12 16:56:38 -0800577protobuf_dep_message:
578 @echo
579 @echo "DEPENDENCY ERROR"
580 @echo
581 @echo "The target you are trying to run requires protobuf 3.0.0+"
582 @echo "Your system doesn't have it, and neither does the third_party directory."
583 @echo
584 @echo "Please consult INSTALL to get more information."
585 @echo
586 @echo "If you need information about why these tests failed, run:"
587 @echo
588 @echo " make run_dep_checks"
589 @echo
590
591protoc_dep_message:
592 @echo
593 @echo "DEPENDENCY ERROR"
594 @echo
595 @echo "The target you are trying to run requires protobuf-compiler 3.0.0+"
596 @echo "Your system doesn't have it, and neither does the third_party directory."
597 @echo
598 @echo "Please consult INSTALL to get more information."
599 @echo
600 @echo "If you need information about why these tests failed, run:"
601 @echo
602 @echo " make run_dep_checks"
603 @echo
604
David Garcia Quintas8954e902015-04-29 09:46:33 -0700605systemtap_dep_error:
606 @echo
607 @echo "DEPENDENCY ERROR"
608 @echo
609 @echo "Under the '$(CONFIG)' configutation, the target you are trying "
610 @echo "to build requires systemtap 2.7+ (on Linux) or dtrace (on other "
611 @echo "platforms such as Solaris and *BSD). "
612 @echo
613 @echo "Please consult INSTALL to get more information."
614 @echo
615
nnoble69ac39f2014-12-12 15:43:38 -0800616stop:
617 @false
618
ctiller09cb6d52014-12-19 17:38:22 -0800619% for tgt in targets:
Craig Tiller61b910f2015-02-15 10:54:07 -0800620${tgt.name}: $(BINDIR)/$(CONFIG)/${tgt.name}
ctiller09cb6d52014-12-19 17:38:22 -0800621% endfor
622
nnoble69ac39f2014-12-12 15:43:38 -0800623run_dep_checks:
nnoble69ac39f2014-12-12 15:43:38 -0800624 $(OPENSSL_ALPN_CHECK_CMD) || true
625 $(ZLIB_CHECK_CMD) || true
Nicolas Noble53830622015-02-12 16:56:38 -0800626 $(PERFTOOLS_CHECK_CMD) || true
627 $(PROTOBUF_CHECK_CMD) || true
David Garcia Quintasf5fcafd2015-04-24 16:12:54 -0700628 $(PROTOC_CHECK_VERSION_CMD) || true
nnoble69ac39f2014-12-12 15:43:38 -0800629
Craig Tiller61b910f2015-02-15 10:54:07 -0800630$(LIBDIR)/$(CONFIG)/zlib/libz.a:
Nicolas "Pixel" Noble17f2b592015-01-16 07:09:10 +0100631 $(E) "[MAKE] Building zlib"
Nicolas Noblef8681182015-03-18 14:25:44 -0700632 $(Q)(cd third_party/zlib ; CC="$(CC)" CFLAGS="$(PIC_CPPFLAGS) -fvisibility=hidden $(CPPFLAGS_$(CONFIG))" ./configure --static)
Nicolas "Pixel" Noble17f2b592015-01-16 07:09:10 +0100633 $(Q)$(MAKE) -C third_party/zlib clean
634 $(Q)$(MAKE) -C third_party/zlib
Craig Tiller61b910f2015-02-15 10:54:07 -0800635 $(Q)mkdir -p $(LIBDIR)/$(CONFIG)/zlib
636 $(Q)cp third_party/zlib/libz.a $(LIBDIR)/$(CONFIG)/zlib
nnoble69ac39f2014-12-12 15:43:38 -0800637
Craig Tiller61b910f2015-02-15 10:54:07 -0800638$(LIBDIR)/$(CONFIG)/openssl/libssl.a:
Craig Tillerb4ee3b52015-01-21 16:22:50 -0800639 $(E) "[MAKE] Building openssl for $(SYSTEM)"
640ifeq ($(SYSTEM),Darwin)
Nicolas Noblef8681182015-03-18 14:25:44 -0700641 $(Q)(cd third_party/openssl ; CC="$(CC) $(PIC_CPPFLAGS) -fvisibility=hidden $(CPPFLAGS_$(CONFIG)) $(OPENSSL_CFLAGS_$(CONFIG))" ./Configure darwin64-x86_64-cc)
Craig Tillerb4ee3b52015-01-21 16:22:50 -0800642else
Nicolas Noblef8681182015-03-18 14:25:44 -0700643ifeq ($(SYSTEM),MINGW32)
644 @echo "We currently don't have a good way to compile OpenSSL in-place under msys."
645 @echo "Please provide an ALPN-capable OpenSSL in your mingw32 system."
646 @echo
647 @echo "Note that you can find a compatible version of the libraries here:"
648 @echo
649 @echo "http://slproweb.com/products/Win32OpenSSL.html"
650 @echo
651 @echo "If you decide to install that one, take the full version. The light"
652 @echo "version only contains compiled DLLs, without the development files."
653 @echo
654 @echo "When installing, chose to copy the OpenSSL dlls to the OpenSSL binaries"
655 @echo "directory. This way we'll link to them directly."
656 @echo
657 @echo "You can then re-start the build the following way:"
658 @echo
659 @echo " CPPFLAGS=-I/c/OpenSSL-Win64/include LDFLAGS=-L/c/OpenSSL-Win64 make"
660 @false
661else
662 $(Q)(cd third_party/openssl ; CC="$(CC) $(PIC_CPPFLAGS) -fvisibility=hidden $(CPPFLAGS_$(CONFIG)) $(OPENSSL_CFLAGS_$(CONFIG))" ./config no-asm $(OPENSSL_CONFIG_$(CONFIG)))
663endif
Craig Tillerb4ee3b52015-01-21 16:22:50 -0800664endif
Nicolas "Pixel" Noble17f2b592015-01-16 07:09:10 +0100665 $(Q)$(MAKE) -C third_party/openssl clean
666 $(Q)$(MAKE) -C third_party/openssl build_crypto build_ssl
Craig Tiller61b910f2015-02-15 10:54:07 -0800667 $(Q)mkdir -p $(LIBDIR)/$(CONFIG)/openssl
668 $(Q)cp third_party/openssl/libssl.a third_party/openssl/libcrypto.a $(LIBDIR)/$(CONFIG)/openssl
nnoble69ac39f2014-12-12 15:43:38 -0800669
Nicolas Noble53830622015-02-12 16:56:38 -0800670third_party/protobuf/configure:
671 $(E) "[AUTOGEN] Preparing protobuf"
672 $(Q)(cd third_party/protobuf ; autoreconf -f -i -Wall,no-obsolete)
673
Craig Tiller61b910f2015-02-15 10:54:07 -0800674$(LIBDIR)/$(CONFIG)/protobuf/libprotobuf.a: third_party/protobuf/configure
Nicolas Noble53830622015-02-12 16:56:38 -0800675 $(E) "[MAKE] Building protobuf"
Nicolas "Pixel" Noblee0953b72015-05-21 05:05:17 +0200676 $(Q)(cd third_party/protobuf ; CC="$(CC)" CXX="$(CXX)" LDFLAGS="$(LDFLAGS_$(CONFIG)) -g" CPPFLAGS="$(PIC_CPPFLAGS) $(CPPFLAGS_$(CONFIG)) -g" ./configure --disable-shared --enable-static)
Nicolas Noble53830622015-02-12 16:56:38 -0800677 $(Q)$(MAKE) -C third_party/protobuf clean
678 $(Q)$(MAKE) -C third_party/protobuf
Craig Tiller61b910f2015-02-15 10:54:07 -0800679 $(Q)mkdir -p $(LIBDIR)/$(CONFIG)/protobuf
680 $(Q)mkdir -p $(BINDIR)/$(CONFIG)/protobuf
681 $(Q)cp third_party/protobuf/src/.libs/libprotoc.a $(LIBDIR)/$(CONFIG)/protobuf
682 $(Q)cp third_party/protobuf/src/.libs/libprotobuf.a $(LIBDIR)/$(CONFIG)/protobuf
683 $(Q)cp third_party/protobuf/src/protoc $(BINDIR)/$(CONFIG)/protobuf
Nicolas Noble53830622015-02-12 16:56:38 -0800684
nnoble29e1d292014-12-01 10:27:40 -0800685static: static_c static_cxx
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800686
Craig Tiller12c82092015-01-15 08:45:56 -0800687static_c: \
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800688% for lib in libs:
Craig Tiller59140fc2015-01-18 10:12:17 -0800689% if lib.build == 'all' and lib.language == 'c':
Craig Tiller61b910f2015-02-15 10:54:07 -0800690 $(LIBDIR)/$(CONFIG)/lib${lib.name}.a\
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800691% endif
692% endfor
693
694
Craig Tiller12c82092015-01-15 08:45:56 -0800695static_cxx: \
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800696% for lib in libs:
Craig Tiller59140fc2015-01-18 10:12:17 -0800697% if lib.build == 'all' and lib.language == 'c++':
Craig Tiller61b910f2015-02-15 10:54:07 -0800698 $(LIBDIR)/$(CONFIG)/lib${lib.name}.a\
nnoble29e1d292014-12-01 10:27:40 -0800699% endif
700% endfor
701
702
703shared: shared_c shared_cxx
704
Craig Tiller12c82092015-01-15 08:45:56 -0800705shared_c: \
nnoble29e1d292014-12-01 10:27:40 -0800706% for lib in libs:
Craig Tiller59140fc2015-01-18 10:12:17 -0800707% if lib.build == 'all' and lib.language == 'c':
Craig Tiller61b910f2015-02-15 10:54:07 -0800708 $(LIBDIR)/$(CONFIG)/lib${lib.name}.$(SHARED_EXT)\
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800709% endif
710% endfor
711
712
Craig Tiller12c82092015-01-15 08:45:56 -0800713shared_cxx: \
nnoble29e1d292014-12-01 10:27:40 -0800714% for lib in libs:
Craig Tiller59140fc2015-01-18 10:12:17 -0800715% if lib.build == 'all' and lib.language == 'c++':
Craig Tiller61b910f2015-02-15 10:54:07 -0800716 $(LIBDIR)/$(CONFIG)/lib${lib.name}.$(SHARED_EXT)\
nnoble29e1d292014-12-01 10:27:40 -0800717% endif
718% endfor
719
720
Jan Tattermusch2ec0b3e2015-02-18 15:03:12 -0800721shared_csharp: shared_c \
722% for lib in libs:
723% if lib.build == 'all' and lib.language == 'csharp':
724 $(LIBDIR)/$(CONFIG)/lib${lib.name}.$(SHARED_EXT)\
725% endif
726% endfor
727
728grpc_csharp_ext: shared_csharp
729
Nicolas "Pixel" Noble522d7122015-02-19 01:28:02 +0100730plugins: $(PROTOC_PLUGINS)
731
nnoble29e1d292014-12-01 10:27:40 -0800732privatelibs: privatelibs_c privatelibs_cxx
733
Craig Tiller12c82092015-01-15 08:45:56 -0800734privatelibs_c: \
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800735% for lib in libs:
Craig Tiller59140fc2015-01-18 10:12:17 -0800736% if lib.build == 'private' and lib.language == 'c':
Craig Tiller61b910f2015-02-15 10:54:07 -0800737 $(LIBDIR)/$(CONFIG)/lib${lib.name}.a\
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800738% endif
739% endfor
740
741
Craig Tiller12c82092015-01-15 08:45:56 -0800742privatelibs_cxx: \
nnoble29e1d292014-12-01 10:27:40 -0800743% for lib in libs:
Craig Tiller59140fc2015-01-18 10:12:17 -0800744% if lib.build == 'private' and lib.language == 'c++':
Craig Tiller61b910f2015-02-15 10:54:07 -0800745 $(LIBDIR)/$(CONFIG)/lib${lib.name}.a\
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800746% endif
747% endfor
748
749
nnoble29e1d292014-12-01 10:27:40 -0800750buildtests: buildtests_c buildtests_cxx
751
Craig Tiller12c82092015-01-15 08:45:56 -0800752buildtests_c: privatelibs_c\
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800753% for tgt in targets:
Craig Tiller59140fc2015-01-18 10:12:17 -0800754% if tgt.build == 'test' and not tgt.language == 'c++':
Craig Tiller61b910f2015-02-15 10:54:07 -0800755 $(BINDIR)/$(CONFIG)/${tgt.name}\
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800756% endif
757% endfor
758
759
Craig Tiller12c82092015-01-15 08:45:56 -0800760buildtests_cxx: privatelibs_cxx\
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800761% for tgt in targets:
Craig Tiller59140fc2015-01-18 10:12:17 -0800762% if tgt.build == 'test' and tgt.language == 'c++':
Craig Tiller61b910f2015-02-15 10:54:07 -0800763 $(BINDIR)/$(CONFIG)/${tgt.name}\
nnoble29e1d292014-12-01 10:27:40 -0800764% endif
765% endfor
766
767
nnoble85a49262014-12-08 18:14:03 -0800768test: test_c test_cxx
nnoble29e1d292014-12-01 10:27:40 -0800769
Nicolas "Pixel" Noble4251d562015-05-22 19:43:39 +0200770flaky_test: flaky_test_c flaky_test_cxx
771
nnoble85a49262014-12-08 18:14:03 -0800772test_c: buildtests_c
nnoble29e1d292014-12-01 10:27:40 -0800773% for tgt in targets:
Nicolas "Pixel" Noble4251d562015-05-22 19:43:39 +0200774% if tgt.build == 'test' and tgt.get('run', True) and not tgt.language == 'c++' and not tgt.get('flaky', False):
775 $(E) "[RUN] Testing ${tgt.name}"
776 $(Q) $(BINDIR)/$(CONFIG)/${tgt.name} || ( echo test ${tgt.name} failed ; exit 1 )
777% endif
778% endfor
779
780
781flaky_test_c: buildtests_c
782% for tgt in targets:
783% 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 -0800784 $(E) "[RUN] Testing ${tgt.name}"
Craig Tillerda224d62015-02-15 11:01:58 -0800785 $(Q) $(BINDIR)/$(CONFIG)/${tgt.name} || ( echo test ${tgt.name} failed ; exit 1 )
nnoble29e1d292014-12-01 10:27:40 -0800786% endif
787% endfor
788
789
nnoble85a49262014-12-08 18:14:03 -0800790test_cxx: buildtests_cxx
nnoble29e1d292014-12-01 10:27:40 -0800791% for tgt in targets:
Nicolas "Pixel" Noble4251d562015-05-22 19:43:39 +0200792% if tgt.build == 'test' and tgt.get('run', True) and tgt.language == 'c++' and not tgt.get('flaky', False):
793 $(E) "[RUN] Testing ${tgt.name}"
794 $(Q) $(BINDIR)/$(CONFIG)/${tgt.name} || ( echo test ${tgt.name} failed ; exit 1 )
795% endif
796% endfor
797
798
799flaky_test_cxx: buildtests_cxx
800% for tgt in targets:
801% 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 -0800802 $(E) "[RUN] Testing ${tgt.name}"
Craig Tillerda224d62015-02-15 11:01:58 -0800803 $(Q) $(BINDIR)/$(CONFIG)/${tgt.name} || ( echo test ${tgt.name} failed ; exit 1 )
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800804% endif
805% endfor
806
807
Nicolas "Pixel" Noble051a28f2015-03-17 22:54:54 +0100808test_python: static_c
809 $(E) "[RUN] Testing python code"
810 $(Q) tools/run_tests/run_tests.py -lpython -c$(CONFIG)
811
812
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800813tools: privatelibs\
814% for tgt in targets:
815% if tgt.build == 'tool':
Craig Tiller61b910f2015-02-15 10:54:07 -0800816 $(BINDIR)/$(CONFIG)/${tgt.name}\
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800817% endif
818% endfor
819
820
821buildbenchmarks: privatelibs\
822% for tgt in targets:
823% if tgt.build == 'benchmark':
Craig Tiller61b910f2015-02-15 10:54:07 -0800824 $(BINDIR)/$(CONFIG)/${tgt.name}\
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800825% endif
826% endfor
827
828
829benchmarks: buildbenchmarks
830
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800831strip: strip-static strip-shared
832
nnoble20e2e3f2014-12-16 15:37:57 -0800833strip-static: strip-static_c strip-static_cxx
834
835strip-shared: strip-shared_c strip-shared_cxx
836
Nicolas Noble047b7272015-01-16 13:55:05 -0800837
838# TODO(nnoble): the strip target is stripping in-place, instead
839# of copying files in a temporary folder.
840# This prevents proper debugging after running make install.
841
nnoble85a49262014-12-08 18:14:03 -0800842strip-static_c: static_c
Nicolas "Pixel" Noble3a2551c2015-01-29 21:33:32 +0100843ifeq ($(CONFIG),opt)
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800844% for lib in libs:
Craig Tiller59140fc2015-01-18 10:12:17 -0800845% if lib.language == "c":
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800846% if lib.build == "all":
847 $(E) "[STRIP] Stripping lib${lib.name}.a"
Craig Tiller61b910f2015-02-15 10:54:07 -0800848 $(Q) $(STRIP) $(LIBDIR)/$(CONFIG)/lib${lib.name}.a
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800849% endif
nnoble85a49262014-12-08 18:14:03 -0800850% endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800851% endfor
Nicolas "Pixel" Noble3a2551c2015-01-29 21:33:32 +0100852endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800853
nnoble85a49262014-12-08 18:14:03 -0800854strip-static_cxx: static_cxx
Nicolas "Pixel" Noble3a2551c2015-01-29 21:33:32 +0100855ifeq ($(CONFIG),opt)
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800856% for lib in libs:
Craig Tiller59140fc2015-01-18 10:12:17 -0800857% if lib.language == "c++":
nnoble85a49262014-12-08 18:14:03 -0800858% if lib.build == "all":
859 $(E) "[STRIP] Stripping lib${lib.name}.a"
Craig Tiller61b910f2015-02-15 10:54:07 -0800860 $(Q) $(STRIP) $(LIBDIR)/$(CONFIG)/lib${lib.name}.a
nnoble85a49262014-12-08 18:14:03 -0800861% endif
862% endif
863% endfor
Nicolas "Pixel" Noble3a2551c2015-01-29 21:33:32 +0100864endif
nnoble85a49262014-12-08 18:14:03 -0800865
866strip-shared_c: shared_c
Nicolas "Pixel" Noble3a2551c2015-01-29 21:33:32 +0100867ifeq ($(CONFIG),opt)
nnoble85a49262014-12-08 18:14:03 -0800868% for lib in libs:
Craig Tiller59140fc2015-01-18 10:12:17 -0800869% if lib.language == "c":
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800870% if lib.build == "all":
871 $(E) "[STRIP] Stripping lib${lib.name}.so"
Craig Tiller61b910f2015-02-15 10:54:07 -0800872 $(Q) $(STRIP) $(LIBDIR)/$(CONFIG)/lib${lib.name}.$(SHARED_EXT)
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800873% endif
nnoble85a49262014-12-08 18:14:03 -0800874% endif
875% endfor
Nicolas "Pixel" Noble3a2551c2015-01-29 21:33:32 +0100876endif
nnoble85a49262014-12-08 18:14:03 -0800877
878strip-shared_cxx: shared_cxx
Nicolas "Pixel" Noble3a2551c2015-01-29 21:33:32 +0100879ifeq ($(CONFIG),opt)
nnoble85a49262014-12-08 18:14:03 -0800880% for lib in libs:
Craig Tiller59140fc2015-01-18 10:12:17 -0800881% if lib.language == "c++":
nnoble85a49262014-12-08 18:14:03 -0800882% if lib.build == "all":
883 $(E) "[STRIP] Stripping lib${lib.name}.so"
Craig Tiller61b910f2015-02-15 10:54:07 -0800884 $(Q) $(STRIP) $(LIBDIR)/$(CONFIG)/lib${lib.name}.$(SHARED_EXT)
nnoble85a49262014-12-08 18:14:03 -0800885% endif
886% endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800887% endfor
Nicolas "Pixel" Noble3a2551c2015-01-29 21:33:32 +0100888endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800889
Jan Tattermusch2ec0b3e2015-02-18 15:03:12 -0800890strip-shared_csharp: shared_csharp
891ifeq ($(CONFIG),opt)
892% for lib in libs:
893% if lib.language == "csharp":
894% if lib.build == "all":
895 $(E) "[STRIP] Stripping lib${lib.name}.so"
896 $(Q) $(STRIP) $(LIBDIR)/$(CONFIG)/lib${lib.name}.$(SHARED_EXT)
897% endif
898% endif
899% endfor
900endif
901
nnoble72309c62014-12-12 11:42:26 -0800902% for p in protos:
Nicolas Noble53830622015-02-12 16:56:38 -0800903ifeq ($(NO_PROTOC),true)
Craig Tiller61b910f2015-02-15 10:54:07 -0800904$(GENDIR)/${p}.pb.cc: protoc_dep_error
Nicolas "Pixel" Noble0caebbf2015-04-09 23:08:51 +0200905$(GENDIR)/${p}.grpc.pb.cc: protoc_dep_error
Nicolas Noble53830622015-02-12 16:56:38 -0800906else
Craig Tiller61b910f2015-02-15 10:54:07 -0800907$(GENDIR)/${p}.pb.cc: ${p}.proto $(PROTOBUF_DEP) $(PROTOC_PLUGINS)
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800908 $(E) "[PROTOC] Generating protobuf CC file from $<"
909 $(Q) mkdir -p `dirname $@`
Nicolas "Pixel" Noble0caebbf2015-04-09 23:08:51 +0200910 $(Q) $(PROTOC) --cpp_out=$(GENDIR) $<
911
912$(GENDIR)/${p}.grpc.pb.cc: ${p}.proto $(PROTOBUF_DEP) $(PROTOC_PLUGINS)
913 $(E) "[GRPC] Generating gRPC's protobuf service CC file from $<"
914 $(Q) mkdir -p `dirname $@`
915 $(Q) $(PROTOC) --grpc_out=$(GENDIR) --plugin=protoc-gen-grpc=$(BINDIR)/$(CONFIG)/grpc_cpp_plugin $<
Nicolas Noble53830622015-02-12 16:56:38 -0800916endif
nnoble72309c62014-12-12 11:42:26 -0800917
918% endfor
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800919
David Garcia Quintasbbc0b772015-04-29 14:10:05 -0700920ifeq ($(CONFIG),stapprof)
921src/core/profiling/stap_timers.c: $(GENDIR)/src/core/profiling/stap_probes.h
David Garcia Quintas611b7362015-04-27 15:49:31 -0700922ifeq ($(HAS_SYSTEMTAP),true)
923$(GENDIR)/src/core/profiling/stap_probes.h: src/core/profiling/stap_probes.d
924 $(E) "[DTRACE] Compiling $<"
925 $(Q) mkdir -p `dirname $@`
926 $(Q) $(DTRACE) -C -h -s $< -o $@
David Garcia Quintas8954e902015-04-29 09:46:33 -0700927else
928$(GENDIR)/src/core/profiling/stap_probes.h: systemtap_dep_error stop
929endif
David Garcia Quintas611b7362015-04-27 15:49:31 -0700930endif
931
Craig Tiller61b910f2015-02-15 10:54:07 -0800932$(OBJDIR)/$(CONFIG)/%.o : %.c
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800933 $(E) "[C] Compiling $<"
934 $(Q) mkdir -p `dirname $@`
Craig Tiller12c82092015-01-15 08:45:56 -0800935 $(Q) $(CC) $(CFLAGS) $(CPPFLAGS) -MMD -MF $(addsuffix .dep, $(basename $@)) -c -o $@ $<
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800936
Craig Tiller61b910f2015-02-15 10:54:07 -0800937$(OBJDIR)/$(CONFIG)/%.o : $(GENDIR)/%.pb.cc
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800938 $(E) "[CXX] Compiling $<"
939 $(Q) mkdir -p `dirname $@`
Craig Tiller12c82092015-01-15 08:45:56 -0800940 $(Q) $(CXX) $(CXXFLAGS) $(CPPFLAGS) -MMD -MF $(addsuffix .dep, $(basename $@)) -c -o $@ $<
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800941
Craig Tiller61b910f2015-02-15 10:54:07 -0800942$(OBJDIR)/$(CONFIG)/src/compiler/%.o : src/compiler/%.cc
nnoble72309c62014-12-12 11:42:26 -0800943 $(E) "[HOSTCXX] Compiling $<"
944 $(Q) mkdir -p `dirname $@`
Craig Tiller12c82092015-01-15 08:45:56 -0800945 $(Q) $(HOST_CXX) $(HOST_CXXFLAGS) $(HOST_CPPFLAGS) -MMD -MF $(addsuffix .dep, $(basename $@)) -c -o $@ $<
nnoble72309c62014-12-12 11:42:26 -0800946
Craig Tiller61b910f2015-02-15 10:54:07 -0800947$(OBJDIR)/$(CONFIG)/%.o : %.cc
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800948 $(E) "[CXX] Compiling $<"
949 $(Q) mkdir -p `dirname $@`
Craig Tiller12c82092015-01-15 08:45:56 -0800950 $(Q) $(CXX) $(CXXFLAGS) $(CPPFLAGS) -MMD -MF $(addsuffix .dep, $(basename $@)) -c -o $@ $<
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800951
Nicolas "Pixel" Noble161ea232015-02-22 05:48:53 +0100952install: install_c install_cxx install-plugins install-certs verify-install
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800953
nnoble85a49262014-12-08 18:14:03 -0800954install_c: install-headers_c install-static_c install-shared_c
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800955
nnoble85a49262014-12-08 18:14:03 -0800956install_cxx: install-headers_cxx install-static_cxx install-shared_cxx
957
Jan Tattermusch2ec0b3e2015-02-18 15:03:12 -0800958install_csharp: install-shared_csharp install_c
959
960install_grpc_csharp_ext: install_csharp
961
nnoble85a49262014-12-08 18:14:03 -0800962install-headers: install-headers_c install-headers_cxx
963
964install-headers_c:
965 $(E) "[INSTALL] Installing public C headers"
Nicolas "Pixel" Noble932d5d32015-02-21 02:15:34 +0100966 $(Q) $(foreach h, $(PUBLIC_HEADERS_C), $(INSTALL) -d $(prefix)/$(dir $(h)) && ) exit 0 || exit 1
nnoble85a49262014-12-08 18:14:03 -0800967 $(Q) $(foreach h, $(PUBLIC_HEADERS_C), $(INSTALL) $(h) $(prefix)/$(h) && ) exit 0 || exit 1
968
969install-headers_cxx:
970 $(E) "[INSTALL] Installing public C++ headers"
Nicolas "Pixel" Noble932d5d32015-02-21 02:15:34 +0100971 $(Q) $(foreach h, $(PUBLIC_HEADERS_CXX), $(INSTALL) -d $(prefix)/$(dir $(h)) && ) exit 0 || exit 1
nnoble85a49262014-12-08 18:14:03 -0800972 $(Q) $(foreach h, $(PUBLIC_HEADERS_CXX), $(INSTALL) $(h) $(prefix)/$(h) && ) exit 0 || exit 1
973
974install-static: install-static_c install-static_cxx
975
976install-static_c: static_c strip-static_c
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800977% for lib in libs:
Craig Tiller59140fc2015-01-18 10:12:17 -0800978% if lib.language == "c":
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800979% if lib.build == "all":
980 $(E) "[INSTALL] Installing lib${lib.name}.a"
Nicolas "Pixel" Noble932d5d32015-02-21 02:15:34 +0100981 $(Q) $(INSTALL) -d $(prefix)/lib
Craig Tiller61b910f2015-02-15 10:54:07 -0800982 $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/lib${lib.name}.a $(prefix)/lib/lib${lib.name}.a
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800983% endif
nnoble85a49262014-12-08 18:14:03 -0800984% endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800985% endfor
986
nnoble85a49262014-12-08 18:14:03 -0800987install-static_cxx: static_cxx strip-static_cxx
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800988% for lib in libs:
Craig Tiller59140fc2015-01-18 10:12:17 -0800989% if lib.language == "c++":
nnoble85a49262014-12-08 18:14:03 -0800990% if lib.build == "all":
991 $(E) "[INSTALL] Installing lib${lib.name}.a"
Nicolas "Pixel" Noble932d5d32015-02-21 02:15:34 +0100992 $(Q) $(INSTALL) -d $(prefix)/lib
Craig Tiller61b910f2015-02-15 10:54:07 -0800993 $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/lib${lib.name}.a $(prefix)/lib/lib${lib.name}.a
nnoble85a49262014-12-08 18:14:03 -0800994% endif
995% endif
996% endfor
997
Nicolas "Pixel" Noble522d7122015-02-19 01:28:02 +0100998<%def name="install_shared(lang_filter)">\
nnoble85a49262014-12-08 18:14:03 -0800999% for lib in libs:
Nicolas "Pixel" Noble522d7122015-02-19 01:28:02 +01001000% if lib.language == lang_filter:
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001001% if lib.build == "all":
nnoble5b7f32a2014-12-22 08:12:44 -08001002ifeq ($(SYSTEM),MINGW32)
1003 $(E) "[INSTALL] Installing ${lib.name}.$(SHARED_EXT)"
Nicolas "Pixel" Noble932d5d32015-02-21 02:15:34 +01001004 $(Q) $(INSTALL) -d $(prefix)/lib
Craig Tiller61b910f2015-02-15 10:54:07 -08001005 $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/${lib.name}.$(SHARED_EXT) $(prefix)/lib/${lib.name}.$(SHARED_EXT)
1006 $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/lib${lib.name}-imp.a $(prefix)/lib/lib${lib.name}-imp.a
nnoble5b7f32a2014-12-22 08:12:44 -08001007else
1008 $(E) "[INSTALL] Installing lib${lib.name}.$(SHARED_EXT)"
Nicolas "Pixel" Noble932d5d32015-02-21 02:15:34 +01001009 $(Q) $(INSTALL) -d $(prefix)/lib
Craig Tiller61b910f2015-02-15 10:54:07 -08001010 $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/lib${lib.name}.$(SHARED_EXT) $(prefix)/lib/lib${lib.name}.$(SHARED_EXT)
Masood Malekghassemid1be74f2015-04-07 16:23:09 -07001011ifneq ($(SYSTEM),Darwin)
Tim Emiola820e3d62015-04-10 09:11:50 -07001012 $(Q) ln -sf lib${lib.name}.$(SHARED_EXT) $(prefix)/lib/lib${lib.name}.so.${settings.version.major}
nnoble5b7f32a2014-12-22 08:12:44 -08001013 $(Q) ln -sf lib${lib.name}.$(SHARED_EXT) $(prefix)/lib/lib${lib.name}.so
1014endif
1015endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001016% endif
nnoble85a49262014-12-08 18:14:03 -08001017% endif
1018% endfor
nnoble5b7f32a2014-12-22 08:12:44 -08001019ifneq ($(SYSTEM),MINGW32)
1020ifneq ($(SYSTEM),Darwin)
Nicolas "Pixel" Noblecc2b42a2015-02-20 00:42:21 +01001021 $(Q) ldconfig || true
nnoble5b7f32a2014-12-22 08:12:44 -08001022endif
1023endif
Nicolas "Pixel" Noble522d7122015-02-19 01:28:02 +01001024</%def>
nnoble85a49262014-12-08 18:14:03 -08001025
Nicolas "Pixel" Noble522d7122015-02-19 01:28:02 +01001026install-shared_c: shared_c strip-shared_c
1027${install_shared("c")}
1028
1029install-shared_cxx: shared_cxx strip-shared_cxx install-shared_c
1030${install_shared("c++")}
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001031
Jan Tattermusch2ec0b3e2015-02-18 15:03:12 -08001032install-shared_csharp: shared_csharp strip-shared_csharp
Nicolas "Pixel" Noble522d7122015-02-19 01:28:02 +01001033${install_shared("csharp")}
1034
Nicolas "Pixel" Noble522d7122015-02-19 01:28:02 +01001035install-plugins: $(PROTOC_PLUGINS)
1036ifeq ($(SYSTEM),MINGW32)
1037 $(Q) false
1038else
1039 $(E) "[INSTALL] Installing grpc protoc plugins"
1040% for tgt in targets:
1041% if tgt.build == 'protoc':
Nicolas "Pixel" Noble932d5d32015-02-21 02:15:34 +01001042 $(Q) $(INSTALL) -d $(prefix)/bin
Nicolas "Pixel" Noble522d7122015-02-19 01:28:02 +01001043 $(Q) $(INSTALL) $(BINDIR)/$(CONFIG)/${tgt.name} $(prefix)/bin/${tgt.name}
1044% endif
1045% endfor
1046endif
Jan Tattermusch2ec0b3e2015-02-18 15:03:12 -08001047
Nicolas "Pixel" Noble161ea232015-02-22 05:48:53 +01001048install-certs: etc/roots.pem
1049 $(E) "[INSTALL] Installing root certificates"
1050 $(Q) $(INSTALL) -d $(prefix)/share/grpc
1051 $(Q) $(INSTALL) etc/roots.pem $(prefix)/share/grpc/roots.pem
1052
Nicolas "Pixel" Noble98ab9982015-02-21 04:22:16 +01001053verify-install:
Nicolas "Pixel" Noble2c23a722015-02-24 20:17:45 +01001054ifeq ($(INSTALL_OK),true)
Nicolas "Pixel" Noble98ab9982015-02-21 04:22:16 +01001055 @echo "Your system looks ready to go."
1056 @echo
1057else
murgatroid99b6181362015-03-02 14:32:25 -08001058 @echo "We couldn't find protoc 3.0.0+ installed on your system. While this"
Nicolas "Pixel" Noble98ab9982015-02-21 04:22:16 +01001059 @echo "won't prevent grpc from working, you won't be able to compile"
1060 @echo "and run any meaningful code with it."
1061 @echo
1062 @echo
1063 @echo "Please download and install protobuf 3.0.0+ from:"
1064 @echo
1065 @echo " https://github.com/google/protobuf/releases"
1066 @echo
murgatroid99b6181362015-03-02 14:32:25 -08001067 @echo "Once you've done so, or if you think this message is in error,"
1068 @echo "you can re-run this check by doing:"
Nicolas "Pixel" Noble98ab9982015-02-21 04:22:16 +01001069 @echo
1070 @echo " make verify-install"
1071endif
1072
Craig Tiller3759e6f2015-01-15 08:13:11 -08001073clean:
Nicolas "Pixel" Noble522d7122015-02-19 01:28:02 +01001074 $(E) "[CLEAN] Cleaning build directories."
Craig Tillerda224d62015-02-15 11:01:58 -08001075 $(Q) $(RM) -rf $(OBJDIR) $(LIBDIR) $(BINDIR) $(GENDIR)
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001076
1077
1078# The various libraries
1079
1080% for lib in libs:
1081${makelib(lib)}
1082% endfor
1083
1084
nnoble69ac39f2014-12-12 15:43:38 -08001085# All of the test targets, and protoc plugins
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001086
1087% for tgt in targets:
1088${maketarget(tgt)}
1089% endfor
1090
1091<%def name="makelib(lib)">
1092LIB${lib.name.upper()}_SRC = \\
1093
1094% for src in lib.src:
nnoble72309c62014-12-12 11:42:26 -08001095 ${proto_to_cc(src)} \\
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001096
1097% endfor
1098
1099% if "public_headers" in lib:
Craig Tiller59140fc2015-01-18 10:12:17 -08001100% if lib.language == "c++":
nnoble85a49262014-12-08 18:14:03 -08001101PUBLIC_HEADERS_CXX += \\
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001102
nnoble85a49262014-12-08 18:14:03 -08001103% else:
1104PUBLIC_HEADERS_C += \\
1105
1106% endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001107% for hdr in lib.public_headers:
1108 ${hdr} \\
1109
1110% endfor
1111% endif
1112
Craig Tiller61b910f2015-02-15 10:54:07 -08001113LIB${lib.name.upper()}_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(LIB${lib.name.upper()}_SRC))))
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001114
Nicolas Noble047b7272015-01-16 13:55:05 -08001115## If the library requires OpenSSL with ALPN, let's add some restrictions.
Nicolas "Pixel" Noble061690d2015-03-06 22:58:58 +01001116% if lib.get('secure', 'check') == 'yes' or lib.get('secure', 'check') == 'check':
nnoble69ac39f2014-12-12 15:43:38 -08001117ifeq ($(NO_SECURE),true)
1118
Nicolas Noble047b7272015-01-16 13:55:05 -08001119# You can't build secure libraries if you don't have OpenSSL with ALPN.
1120
Craig Tiller61b910f2015-02-15 10:54:07 -08001121$(LIBDIR)/$(CONFIG)/lib${lib.name}.a: openssl_dep_error
nnoble69ac39f2014-12-12 15:43:38 -08001122
nnoble5b7f32a2014-12-22 08:12:44 -08001123% if lib.build == "all":
1124ifeq ($(SYSTEM),MINGW32)
Craig Tiller61b910f2015-02-15 10:54:07 -08001125$(LIBDIR)/$(CONFIG)/${lib.name}.$(SHARED_EXT): openssl_dep_error
nnoble5b7f32a2014-12-22 08:12:44 -08001126else
Craig Tiller61b910f2015-02-15 10:54:07 -08001127$(LIBDIR)/$(CONFIG)/lib${lib.name}.$(SHARED_EXT): openssl_dep_error
nnoble5b7f32a2014-12-22 08:12:44 -08001128endif
1129% endif
1130
nnoble69ac39f2014-12-12 15:43:38 -08001131else
1132
Nicolas Noble53830622015-02-12 16:56:38 -08001133% if lib.language == 'c++':
1134ifeq ($(NO_PROTOBUF),true)
1135
1136# You can't build a C++ library if you don't have protobuf - a bit overreached, but still okay.
1137
Craig Tiller61b910f2015-02-15 10:54:07 -08001138$(LIBDIR)/$(CONFIG)/lib${lib.name}.a: protobuf_dep_error
Nicolas Noble53830622015-02-12 16:56:38 -08001139
1140% if lib.build == "all":
1141ifeq ($(SYSTEM),MINGW32)
Craig Tiller61b910f2015-02-15 10:54:07 -08001142$(LIBDIR)/$(CONFIG)/${lib.name}.$(SHARED_EXT): protobuf_dep_error
Nicolas Noble53830622015-02-12 16:56:38 -08001143else
Craig Tiller61b910f2015-02-15 10:54:07 -08001144$(LIBDIR)/$(CONFIG)/lib${lib.name}.$(SHARED_EXT): protobuf_dep_error
Nicolas Noble53830622015-02-12 16:56:38 -08001145endif
1146% endif
1147
1148else
1149% endif
1150
Craig Tiller61b910f2015-02-15 10:54:07 -08001151$(LIBDIR)/$(CONFIG)/lib${lib.name}.a: $(ZLIB_DEP) $(OPENSSL_DEP)\
Nicolas Noble047b7272015-01-16 13:55:05 -08001152## The else here corresponds to the if secure earlier.
nnoble20e2e3f2014-12-16 15:37:57 -08001153% else:
Nicolas Noble53830622015-02-12 16:56:38 -08001154% if lib.language == 'c++':
1155ifeq ($(NO_PROTOBUF),true)
1156
1157# You can't build a C++ library if you don't have protobuf - a bit overreached, but still okay.
1158
Craig Tiller61b910f2015-02-15 10:54:07 -08001159$(LIBDIR)/$(CONFIG)/lib${lib.name}.a: protobuf_dep_error
Nicolas Noble53830622015-02-12 16:56:38 -08001160
1161% if lib.build == "all":
1162ifeq ($(SYSTEM),MINGW32)
Craig Tiller61b910f2015-02-15 10:54:07 -08001163$(LIBDIR)/$(CONFIG)/${lib.name}.$(SHARED_EXT): protobuf_dep_error
Nicolas Noble53830622015-02-12 16:56:38 -08001164else
Craig Tiller61b910f2015-02-15 10:54:07 -08001165$(LIBDIR)/$(CONFIG)/lib${lib.name}.$(SHARED_EXT): protobuf_dep_error
Nicolas Noble53830622015-02-12 16:56:38 -08001166endif
nnoble20e2e3f2014-12-16 15:37:57 -08001167% endif
Nicolas Noble53830622015-02-12 16:56:38 -08001168
1169else
1170
1171% endif
Craig Tiller61b910f2015-02-15 10:54:07 -08001172$(LIBDIR)/$(CONFIG)/lib${lib.name}.a: $(ZLIB_DEP)\
Nicolas Noble53830622015-02-12 16:56:38 -08001173% endif
1174% if lib.language == 'c++':
1175 $(PROTOBUF_DEP)\
1176% endif
1177 $(LIB${lib.name.upper()}_OBJS)
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001178 $(E) "[AR] Creating $@"
nnoble85a49262014-12-08 18:14:03 -08001179 $(Q) mkdir -p `dirname $@`
Craig Tiller61b910f2015-02-15 10:54:07 -08001180 $(Q) rm -f $(LIBDIR)/$(CONFIG)/lib${lib.name}.a
1181 $(Q) $(AR) rcs $(LIBDIR)/$(CONFIG)/lib${lib.name}.a $(LIB${lib.name.upper()}_OBJS)
nnoble20e2e3f2014-12-16 15:37:57 -08001182% if lib.get('baselib', False):
Nicolas "Pixel" Noble061690d2015-03-06 22:58:58 +01001183% if lib.get('secure', 'check') == 'yes':
Craig Tiller7ab4fee2015-02-24 08:15:53 -08001184 $(Q) rm -rf tmp-merge-${lib.name}
1185 $(Q) mkdir tmp-merge-${lib.name}
1186 $(Q) ( cd tmp-merge-${lib.name} ; $(AR) x ../$(LIBDIR)/$(CONFIG)/lib${lib.name}.a )
1187 $(Q) for l in $(OPENSSL_MERGE_LIBS) ; do ( cd tmp-merge-${lib.name} ; <%text>ar x ../$${l}</%text> ) ; done
1188 $(Q) rm -f $(LIBDIR)/$(CONFIG)/lib${lib.name}.a tmp-merge-${lib.name}/__.SYMDEF*
1189 $(Q) ar rcs $(LIBDIR)/$(CONFIG)/lib${lib.name}.a tmp-merge-${lib.name}/*
1190 $(Q) rm -rf tmp-merge-${lib.name}
nnoble20e2e3f2014-12-16 15:37:57 -08001191% endif
1192% endif
Craig Tillerb4ee3b52015-01-21 16:22:50 -08001193ifeq ($(SYSTEM),Darwin)
murgatroid99b6181362015-03-02 14:32:25 -08001194 $(Q) ranlib $(LIBDIR)/$(CONFIG)/lib${lib.name}.a
Craig Tillerb4ee3b52015-01-21 16:22:50 -08001195endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001196
nnoble5b7f32a2014-12-22 08:12:44 -08001197<%
Nicolas "Pixel" Noble010f1e72015-04-23 02:23:49 +02001198
Craig Tiller59140fc2015-01-18 10:12:17 -08001199 if lib.language == 'c++':
nnoble5b7f32a2014-12-22 08:12:44 -08001200 ld = '$(LDXX)'
1201 else:
1202 ld = '$(LD)'
1203
Craig Tillerda224d62015-02-15 11:01:58 -08001204 out_base = '$(LIBDIR)/$(CONFIG)/' + lib.name
1205 out_libbase = '$(LIBDIR)/$(CONFIG)/lib' + lib.name
nnoble5b7f32a2014-12-22 08:12:44 -08001206
1207 common = '$(LIB' + lib.name.upper() + '_OBJS) $(LDLIBS)'
1208
1209 libs = ''
Nicolas "Pixel" Noble85bf09b2015-01-15 18:22:40 +01001210 lib_deps = ' $(ZLIB_DEP)'
nnoble5b7f32a2014-12-22 08:12:44 -08001211 mingw_libs = ''
Nicolas "Pixel" Noble85bf09b2015-01-15 18:22:40 +01001212 mingw_lib_deps = ' $(ZLIB_DEP)'
Michael Berlinbf2e7f02015-05-01 16:17:01 -07001213 if lib.language == 'c++':
1214 lib_deps += ' $(PROTOBUF_DEP)'
1215 mingw_lib_deps += ' $(PROTOBUF_DEP)'
nnoble5b7f32a2014-12-22 08:12:44 -08001216 for dep in lib.get('deps', []):
1217 libs = libs + ' -l' + dep
Craig Tiller61b910f2015-02-15 10:54:07 -08001218 lib_deps = lib_deps + ' $(LIBDIR)/$(CONFIG)/lib' + dep + '.$(SHARED_EXT)'
nnoble5b7f32a2014-12-22 08:12:44 -08001219 mingw_libs = mingw_libs + ' -l' + dep + '-imp'
Michael Berlin53513922015-05-01 16:14:15 -07001220 mingw_lib_deps = mingw_lib_deps + ' $(LIBDIR)/$(CONFIG)/' + dep + '.$(SHARED_EXT)'
nnoble5b7f32a2014-12-22 08:12:44 -08001221
Nicolas "Pixel" Noble061690d2015-03-06 22:58:58 +01001222 if lib.get('secure', 'check') == 'yes':
nnoble5b7f32a2014-12-22 08:12:44 -08001223 common = common + ' $(LDLIBS_SECURE) $(OPENSSL_MERGE_LIBS)'
Nicolas "Pixel" Noble010f1e72015-04-23 02:23:49 +02001224 for src in lib.src:
1225 sources_that_need_openssl.add(src)
1226 else:
1227 for src in lib.src:
1228 sources_that_don_t_need_openssl.add(src)
Nicolas "Pixel" Noble061690d2015-03-06 22:58:58 +01001229
1230 if lib.get('secure', 'check') == 'yes' or lib.get('secure', 'check') == 'check':
nnoble5b7f32a2014-12-22 08:12:44 -08001231 lib_deps = lib_deps + ' $(OPENSSL_DEP)'
1232 mingw_lib_deps = mingw_lib_deps + ' $(OPENSSL_DEP)'
Nicolas "Pixel" Nobledda049c2015-02-21 00:39:32 +01001233
1234 if lib.language == 'c++':
1235 common = common + ' $(LDLIBSXX) $(LDLIBS_PROTOBUF)'
nnoble5b7f32a2014-12-22 08:12:44 -08001236%>
1237
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001238% if lib.build == "all":
nnoble5b7f32a2014-12-22 08:12:44 -08001239ifeq ($(SYSTEM),MINGW32)
1240${out_base}.$(SHARED_EXT): $(LIB${lib.name.upper()}_OBJS) ${mingw_lib_deps}
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001241 $(E) "[LD] Linking $@"
nnoble85a49262014-12-08 18:14:03 -08001242 $(Q) mkdir -p `dirname $@`
Craig Tillerda224d62015-02-15 11:01:58 -08001243 $(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 -08001244else
1245${out_libbase}.$(SHARED_EXT): $(LIB${lib.name.upper()}_OBJS) ${lib_deps}
1246 $(E) "[LD] Linking $@"
1247 $(Q) mkdir -p `dirname $@`
1248ifeq ($(SYSTEM),Darwin)
Masood Malekghassemid1be74f2015-04-07 16:23:09 -07001249 $(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 -08001250else
Craig Tillerda224d62015-02-15 11:01:58 -08001251 $(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 +01001252 $(Q) ln -sf lib${lib.name}.$(SHARED_EXT) ${out_libbase}.so.${settings.version.major}
nnoble5b7f32a2014-12-22 08:12:44 -08001253 $(Q) ln -sf lib${lib.name}.$(SHARED_EXT) ${out_libbase}.so
1254endif
1255endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001256% endif
Nicolas "Pixel" Noble061690d2015-03-06 22:58:58 +01001257% if lib.get('secure', 'check') == 'yes' or lib.get('secure', 'check') == 'check':
Nicolas Noble047b7272015-01-16 13:55:05 -08001258## If the lib was secure, we have to close the Makefile's if that tested
1259## the presence of an ALPN-capable OpenSSL.
Nicolas Noble53830622015-02-12 16:56:38 -08001260
1261endif
1262% endif
1263% if lib.language == 'c++':
1264## If the lib was C++, we have to close the Makefile's if that tested
1265## the presence of protobuf 3.0.0+
nnoble69ac39f2014-12-12 15:43:38 -08001266
1267endif
1268% endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001269
Nicolas "Pixel" Noble061690d2015-03-06 22:58:58 +01001270% if lib.get('secure', 'check') == 'yes' or lib.get('secure', 'check') == 'check':
nnoble69ac39f2014-12-12 15:43:38 -08001271ifneq ($(NO_SECURE),true)
1272% endif
1273ifneq ($(NO_DEPS),true)
Craig Tiller8f126a62015-01-15 08:50:19 -08001274-include $(LIB${lib.name.upper()}_OBJS:.o=.dep)
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001275endif
Nicolas "Pixel" Noble061690d2015-03-06 22:58:58 +01001276% if lib.get('secure', 'check') == 'yes' or lib.get('secure', 'check') == 'check':
nnoble69ac39f2014-12-12 15:43:38 -08001277endif
1278% endif
Craig Tiller27715ca2015-01-12 16:55:59 -08001279% for src in lib.src:
Craig Tillerd896fa52015-04-24 14:30:09 -07001280% if not proto_re.match(src) and any(proto_re.match(src2) for src2 in lib.src):
Craig Tiller04f81562015-04-24 14:34:30 -07001281$(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 -08001282% endif
Craig Tiller27715ca2015-01-12 16:55:59 -08001283% endfor
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001284</%def>
1285
Nicolas "Pixel" Nobleadaa1002015-04-29 08:56:01 +02001286<%def name="maketarget(tgt)"><% has_no_sources = not tgt.src %>
1287% if not has_no_sources:
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001288${tgt.name.upper()}_SRC = \\
1289
1290% for src in tgt.src:
nnoble72309c62014-12-12 11:42:26 -08001291 ${proto_to_cc(src)} \\
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001292
1293% endfor
1294
Craig Tiller61b910f2015-02-15 10:54:07 -08001295${tgt.name.upper()}_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(${tgt.name.upper()}_SRC))))
Nicolas "Pixel" Nobleadaa1002015-04-29 08:56:01 +02001296% endif
Nicolas "Pixel" Noble061690d2015-03-06 22:58:58 +01001297% if tgt.get('secure', 'check') == 'yes' or tgt.get('secure', 'check') == 'check':
nnoble69ac39f2014-12-12 15:43:38 -08001298ifeq ($(NO_SECURE),true)
1299
Nicolas Noble047b7272015-01-16 13:55:05 -08001300# You can't build secure targets if you don't have OpenSSL with ALPN.
1301
Craig Tiller61b910f2015-02-15 10:54:07 -08001302$(BINDIR)/$(CONFIG)/${tgt.name}: openssl_dep_error
nnoble69ac39f2014-12-12 15:43:38 -08001303
1304else
1305
1306% endif
Nicolas Noble047b7272015-01-16 13:55:05 -08001307##
1308## We're not trying to add a dependency on building zlib and openssl here,
1309## as it's already done in the libraries. We're assuming that the build
1310## trickles down, and that a secure target requires a secure version of
1311## a library.
1312##
1313## That simplifies the codegen a bit, but prevents a fully defined Makefile.
1314## I can live with that.
1315##
Nicolas "Pixel" Noble18953e32015-02-27 02:41:11 +01001316% if tgt.build == 'protoc' or tgt.language == 'c++':
Nicolas Noble53830622015-02-12 16:56:38 -08001317
1318ifeq ($(NO_PROTOBUF),true)
1319
Nicolas "Pixel" Noble18953e32015-02-27 02:41:11 +01001320# 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 -08001321
Craig Tiller61b910f2015-02-15 10:54:07 -08001322$(BINDIR)/$(CONFIG)/${tgt.name}: protobuf_dep_error
Nicolas Noble53830622015-02-12 16:56:38 -08001323
1324else
1325
Nicolas "Pixel" Nobleadaa1002015-04-29 08:56:01 +02001326$(BINDIR)/$(CONFIG)/${tgt.name}: \
1327% if not has_no_sources:
1328$(PROTOBUF_DEP) $(${tgt.name.upper()}_OBJS)\
1329% endif
Nicolas Noble53830622015-02-12 16:56:38 -08001330% else:
Nicolas "Pixel" Nobleadaa1002015-04-29 08:56:01 +02001331$(BINDIR)/$(CONFIG)/${tgt.name}: \
1332% if not has_no_sources:
1333$(${tgt.name.upper()}_OBJS)\
1334% endif
Nicolas Noble53830622015-02-12 16:56:38 -08001335% endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001336% for dep in tgt.deps:
Craig Tiller61b910f2015-02-15 10:54:07 -08001337 $(LIBDIR)/$(CONFIG)/lib${dep}.a\
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001338% endfor
1339
Craig Tiller59140fc2015-01-18 10:12:17 -08001340% if tgt.language == "c++":
Nicolas Noble047b7272015-01-16 13:55:05 -08001341## C++ targets specificies.
nnoble72309c62014-12-12 11:42:26 -08001342% if tgt.build == 'protoc':
1343 $(E) "[HOSTLD] Linking $@"
1344 $(Q) mkdir -p `dirname $@`
Nicolas "Pixel" Nobleadaa1002015-04-29 08:56:01 +02001345 $(Q) $(HOST_LDXX) $(HOST_LDFLAGS) \
1346% if not has_no_sources:
1347$(${tgt.name.upper()}_OBJS)\
1348% endif
nnoble72309c62014-12-12 11:42:26 -08001349% else:
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001350 $(E) "[LD] Linking $@"
nnoble85a49262014-12-08 18:14:03 -08001351 $(Q) mkdir -p `dirname $@`
Nicolas "Pixel" Nobleadaa1002015-04-29 08:56:01 +02001352 $(Q) $(LDXX) $(LDFLAGS) \
1353% if not has_no_sources:
1354$(${tgt.name.upper()}_OBJS)\
1355% endif
nnoble72309c62014-12-12 11:42:26 -08001356% endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001357% else:
Nicolas Noble047b7272015-01-16 13:55:05 -08001358## C-only targets specificities.
nnoble72309c62014-12-12 11:42:26 -08001359 $(E) "[LD] Linking $@"
1360 $(Q) mkdir -p `dirname $@`
Nicolas "Pixel" Nobleadaa1002015-04-29 08:56:01 +02001361 $(Q) $(LD) $(LDFLAGS) \
1362% if not has_no_sources:
1363$(${tgt.name.upper()}_OBJS)\
1364% endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001365% endif
1366% for dep in tgt.deps:
Craig Tiller61b910f2015-02-15 10:54:07 -08001367 $(LIBDIR)/$(CONFIG)/lib${dep}.a\
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001368% endfor
Craig Tiller59140fc2015-01-18 10:12:17 -08001369% if tgt.language == "c++":
nnoble72309c62014-12-12 11:42:26 -08001370% if tgt.build == 'protoc':
Nicolas Noble53830622015-02-12 16:56:38 -08001371 $(HOST_LDLIBSXX) $(HOST_LDLIBS_PROTOC)\
nnoble72309c62014-12-12 11:42:26 -08001372% else:
Nicolas Noble53830622015-02-12 16:56:38 -08001373 $(LDLIBSXX) $(LDLIBS_PROTOBUF)\
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001374% endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001375% endif
nnoblec78b3402014-12-11 16:06:57 -08001376% if tgt.build == 'protoc':
nnoble72309c62014-12-12 11:42:26 -08001377 $(HOST_LDLIBS)\
1378% else:
1379 $(LDLIBS)\
1380% endif
1381% if tgt.build == 'protoc':
1382 $(HOST_LDLIBS_PROTOC)\
Nicolas "Pixel" Noble061690d2015-03-06 22:58:58 +01001383% elif tgt.get('secure', 'check') == 'yes' or tgt.get('secure', 'check') == 'check':
nnoble72309c62014-12-12 11:42:26 -08001384 $(LDLIBS_SECURE)\
nnoblec78b3402014-12-11 16:06:57 -08001385% endif
Yang Gaob0b518e2015-04-13 14:53:25 -07001386% if tgt.language == 'c++' and tgt.build == 'test':
1387 $(GTEST_LIB)\
David Garcia Quintasaa52d0a2015-05-14 19:04:23 -07001388% elif tgt.language == 'c++' and tgt.build == 'benchmark':
1389 $(GTEST_LIB)\
Yang Gaob0b518e2015-04-13 14:53:25 -07001390% endif
Craig Tiller61b910f2015-02-15 10:54:07 -08001391 -o $(BINDIR)/$(CONFIG)/${tgt.name}
Nicolas "Pixel" Noble18953e32015-02-27 02:41:11 +01001392% if tgt.build == 'protoc' or tgt.language == 'c++':
Nicolas Noble53830622015-02-12 16:56:38 -08001393
1394endif
1395% endif
Nicolas "Pixel" Noble061690d2015-03-06 22:58:58 +01001396% if tgt.get('secure', 'check') == 'yes' or tgt.get('secure', 'check') == 'check':
nnoble69ac39f2014-12-12 15:43:38 -08001397
1398endif
1399% endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001400
Craig Tillerf5371ef2015-01-12 16:40:18 -08001401% for src in tgt.src:
Craig Tiller61b910f2015-02-15 10:54:07 -08001402$(OBJDIR)/$(CONFIG)/${os.path.splitext(src)[0]}.o: \
Craig Tillerf5371ef2015-01-12 16:40:18 -08001403% for dep in tgt.deps:
Craig Tiller61b910f2015-02-15 10:54:07 -08001404 $(LIBDIR)/$(CONFIG)/lib${dep}.a\
Craig Tillerf5371ef2015-01-12 16:40:18 -08001405% endfor
1406
1407% endfor
Nicolas "Pixel" Nobleadaa1002015-04-29 08:56:01 +02001408% if not has_no_sources:
Craig Tiller8f126a62015-01-15 08:50:19 -08001409deps_${tgt.name}: $(${tgt.name.upper()}_OBJS:.o=.dep)
Nicolas "Pixel" Nobleadaa1002015-04-29 08:56:01 +02001410% endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001411
Nicolas "Pixel" Nobleadaa1002015-04-29 08:56:01 +02001412% if not has_no_sources:
Nicolas "Pixel" Noble061690d2015-03-06 22:58:58 +01001413% if tgt.get('secure', 'check') == 'yes' or tgt.get('secure', 'check') == 'check':
nnoble69ac39f2014-12-12 15:43:38 -08001414ifneq ($(NO_SECURE),true)
1415% endif
1416ifneq ($(NO_DEPS),true)
Craig Tiller8f126a62015-01-15 08:50:19 -08001417-include $(${tgt.name.upper()}_OBJS:.o=.dep)
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001418endif
Nicolas "Pixel" Noble061690d2015-03-06 22:58:58 +01001419% if tgt.get('secure', 'check') == 'yes' or tgt.get('secure', 'check') == 'check':
nnoble69ac39f2014-12-12 15:43:38 -08001420endif
1421% endif
Nicolas "Pixel" Nobleadaa1002015-04-29 08:56:01 +02001422% endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001423</%def>
1424
Nicolas "Pixel" Noble010f1e72015-04-23 02:23:49 +02001425ifneq ($(OPENSSL_DEP),)
1426# This is to ensure the embedded OpenSSL is built beforehand, properly
1427# installing headers to their final destination on the drive. We need this
1428# otherwise parallel compilation will fail if a source is compiled first.
1429% for src in sorted(sources_that_need_openssl):
1430% if src not in sources_that_don_t_need_openssl:
1431${src}: $(OPENSSL_DEP)
1432% endif
1433% endfor
1434endif
1435
nnoble85a49262014-12-08 18:14:03 -08001436.PHONY: all strip tools \
nnoble69ac39f2014-12-12 15:43:38 -08001437dep_error openssl_dep_error openssl_dep_message git_update stop \
nnoble85a49262014-12-08 18:14:03 -08001438buildtests buildtests_c buildtests_cxx \
1439test test_c test_cxx \
1440install install_c install_cxx \
1441install-headers install-headers_c install-headers_cxx \
1442install-shared install-shared_c install-shared_cxx \
1443install-static install-static_c install-static_cxx \
1444strip strip-shared strip-static \
1445strip_c strip-shared_c strip-static_c \
1446strip_cxx strip-shared_cxx strip-static_cxx \
Craig Tillerf0afe502015-01-15 09:04:49 -08001447dep_c dep_cxx bins_dep_c bins_dep_cxx \
Craig Tiller12c82092015-01-15 08:45:56 -08001448clean