blob: 66703f812b120f5426e6e28a40e25f826086bf1f [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"
Craig Tillercf133f42015-02-26 14:05:56 -0800676ifeq ($(HAVE_CXX11),true)
Nicolas Noblef8681182015-03-18 14:25:44 -0700677 $(Q)(cd third_party/protobuf ; CC="$(CC)" CXX="$(CXX)" LDFLAGS="$(LDFLAGS_$(CONFIG)) -g" CXXFLAGS="-DLANG_CXX11 -std=c++11" CPPFLAGS="$(PIC_CPPFLAGS) $(CPPFLAGS_$(CONFIG)) -g" ./configure --disable-shared --enable-static)
Craig Tillercf133f42015-02-26 14:05:56 -0800678else
Nicolas Noblef8681182015-03-18 14:25:44 -0700679 $(Q)(cd third_party/protobuf ; CC="$(CC)" CXX="$(CXX)" LDFLAGS="$(LDFLAGS_$(CONFIG)) -g" CXXFLAGS="-std=c++0x" CPPFLAGS="$(PIC_CPPFLAGS) $(CPPFLAGS_$(CONFIG)) -g" ./configure --disable-shared --enable-static)
Craig Tillercf133f42015-02-26 14:05:56 -0800680endif
Nicolas Noble53830622015-02-12 16:56:38 -0800681 $(Q)$(MAKE) -C third_party/protobuf clean
682 $(Q)$(MAKE) -C third_party/protobuf
Craig Tiller61b910f2015-02-15 10:54:07 -0800683 $(Q)mkdir -p $(LIBDIR)/$(CONFIG)/protobuf
684 $(Q)mkdir -p $(BINDIR)/$(CONFIG)/protobuf
685 $(Q)cp third_party/protobuf/src/.libs/libprotoc.a $(LIBDIR)/$(CONFIG)/protobuf
686 $(Q)cp third_party/protobuf/src/.libs/libprotobuf.a $(LIBDIR)/$(CONFIG)/protobuf
687 $(Q)cp third_party/protobuf/src/protoc $(BINDIR)/$(CONFIG)/protobuf
Nicolas Noble53830622015-02-12 16:56:38 -0800688
nnoble29e1d292014-12-01 10:27:40 -0800689static: static_c static_cxx
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800690
Craig Tiller12c82092015-01-15 08:45:56 -0800691static_c: \
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800692% for lib in libs:
Craig Tiller59140fc2015-01-18 10:12:17 -0800693% if lib.build == 'all' and lib.language == 'c':
Craig Tiller61b910f2015-02-15 10:54:07 -0800694 $(LIBDIR)/$(CONFIG)/lib${lib.name}.a\
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800695% endif
696% endfor
697
698
Craig Tiller12c82092015-01-15 08:45:56 -0800699static_cxx: \
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800700% for lib in libs:
Craig Tiller59140fc2015-01-18 10:12:17 -0800701% if lib.build == 'all' and lib.language == 'c++':
Craig Tiller61b910f2015-02-15 10:54:07 -0800702 $(LIBDIR)/$(CONFIG)/lib${lib.name}.a\
nnoble29e1d292014-12-01 10:27:40 -0800703% endif
704% endfor
705
706
707shared: shared_c shared_cxx
708
Craig Tiller12c82092015-01-15 08:45:56 -0800709shared_c: \
nnoble29e1d292014-12-01 10:27:40 -0800710% for lib in libs:
Craig Tiller59140fc2015-01-18 10:12:17 -0800711% if lib.build == 'all' and lib.language == 'c':
Craig Tiller61b910f2015-02-15 10:54:07 -0800712 $(LIBDIR)/$(CONFIG)/lib${lib.name}.$(SHARED_EXT)\
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800713% endif
714% endfor
715
716
Craig Tiller12c82092015-01-15 08:45:56 -0800717shared_cxx: \
nnoble29e1d292014-12-01 10:27:40 -0800718% for lib in libs:
Craig Tiller59140fc2015-01-18 10:12:17 -0800719% if lib.build == 'all' and lib.language == 'c++':
Craig Tiller61b910f2015-02-15 10:54:07 -0800720 $(LIBDIR)/$(CONFIG)/lib${lib.name}.$(SHARED_EXT)\
nnoble29e1d292014-12-01 10:27:40 -0800721% endif
722% endfor
723
724
Jan Tattermusch2ec0b3e2015-02-18 15:03:12 -0800725shared_csharp: shared_c \
726% for lib in libs:
727% if lib.build == 'all' and lib.language == 'csharp':
728 $(LIBDIR)/$(CONFIG)/lib${lib.name}.$(SHARED_EXT)\
729% endif
730% endfor
731
732grpc_csharp_ext: shared_csharp
733
Nicolas "Pixel" Noble522d7122015-02-19 01:28:02 +0100734plugins: $(PROTOC_PLUGINS)
735
nnoble29e1d292014-12-01 10:27:40 -0800736privatelibs: privatelibs_c privatelibs_cxx
737
Craig Tiller12c82092015-01-15 08:45:56 -0800738privatelibs_c: \
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800739% for lib in libs:
Craig Tiller59140fc2015-01-18 10:12:17 -0800740% if lib.build == 'private' and lib.language == 'c':
Craig Tiller61b910f2015-02-15 10:54:07 -0800741 $(LIBDIR)/$(CONFIG)/lib${lib.name}.a\
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800742% endif
743% endfor
744
745
Craig Tiller12c82092015-01-15 08:45:56 -0800746privatelibs_cxx: \
nnoble29e1d292014-12-01 10:27:40 -0800747% for lib in libs:
Craig Tiller59140fc2015-01-18 10:12:17 -0800748% if lib.build == 'private' and lib.language == 'c++':
Craig Tiller61b910f2015-02-15 10:54:07 -0800749 $(LIBDIR)/$(CONFIG)/lib${lib.name}.a\
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800750% endif
751% endfor
752
753
nnoble29e1d292014-12-01 10:27:40 -0800754buildtests: buildtests_c buildtests_cxx
755
Craig Tiller12c82092015-01-15 08:45:56 -0800756buildtests_c: privatelibs_c\
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800757% for tgt in targets:
Craig Tiller59140fc2015-01-18 10:12:17 -0800758% if tgt.build == 'test' and not tgt.language == 'c++':
Craig Tiller61b910f2015-02-15 10:54:07 -0800759 $(BINDIR)/$(CONFIG)/${tgt.name}\
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800760% endif
761% endfor
762
763
Craig Tiller12c82092015-01-15 08:45:56 -0800764buildtests_cxx: privatelibs_cxx\
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800765% for tgt in targets:
Craig Tiller59140fc2015-01-18 10:12:17 -0800766% if tgt.build == 'test' and tgt.language == 'c++':
Craig Tiller61b910f2015-02-15 10:54:07 -0800767 $(BINDIR)/$(CONFIG)/${tgt.name}\
nnoble29e1d292014-12-01 10:27:40 -0800768% endif
769% endfor
770
771
nnoble85a49262014-12-08 18:14:03 -0800772test: test_c test_cxx
nnoble29e1d292014-12-01 10:27:40 -0800773
nnoble85a49262014-12-08 18:14:03 -0800774test_c: buildtests_c
nnoble29e1d292014-12-01 10:27:40 -0800775% for tgt in targets:
Craig Tiller59140fc2015-01-18 10:12:17 -0800776% if tgt.build == 'test' and tgt.get('run', True) and not tgt.language == 'c++':
nnoble29e1d292014-12-01 10:27:40 -0800777 $(E) "[RUN] Testing ${tgt.name}"
Craig Tillerda224d62015-02-15 11:01:58 -0800778 $(Q) $(BINDIR)/$(CONFIG)/${tgt.name} || ( echo test ${tgt.name} failed ; exit 1 )
nnoble29e1d292014-12-01 10:27:40 -0800779% endif
780% endfor
781
782
nnoble85a49262014-12-08 18:14:03 -0800783test_cxx: buildtests_cxx
nnoble29e1d292014-12-01 10:27:40 -0800784% for tgt in targets:
Craig Tiller59140fc2015-01-18 10:12:17 -0800785% if tgt.build == 'test' and tgt.get('run', True) and tgt.language == 'c++':
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800786 $(E) "[RUN] Testing ${tgt.name}"
Craig Tillerda224d62015-02-15 11:01:58 -0800787 $(Q) $(BINDIR)/$(CONFIG)/${tgt.name} || ( echo test ${tgt.name} failed ; exit 1 )
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800788% endif
789% endfor
790
791
Nicolas "Pixel" Noble051a28f2015-03-17 22:54:54 +0100792test_python: static_c
793 $(E) "[RUN] Testing python code"
794 $(Q) tools/run_tests/run_tests.py -lpython -c$(CONFIG)
795
796
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800797tools: privatelibs\
798% for tgt in targets:
799% if tgt.build == 'tool':
Craig Tiller61b910f2015-02-15 10:54:07 -0800800 $(BINDIR)/$(CONFIG)/${tgt.name}\
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800801% endif
802% endfor
803
804
805buildbenchmarks: privatelibs\
806% for tgt in targets:
807% if tgt.build == 'benchmark':
Craig Tiller61b910f2015-02-15 10:54:07 -0800808 $(BINDIR)/$(CONFIG)/${tgt.name}\
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800809% endif
810% endfor
811
812
813benchmarks: buildbenchmarks
814
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800815strip: strip-static strip-shared
816
nnoble20e2e3f2014-12-16 15:37:57 -0800817strip-static: strip-static_c strip-static_cxx
818
819strip-shared: strip-shared_c strip-shared_cxx
820
Nicolas Noble047b7272015-01-16 13:55:05 -0800821
822# TODO(nnoble): the strip target is stripping in-place, instead
823# of copying files in a temporary folder.
824# This prevents proper debugging after running make install.
825
nnoble85a49262014-12-08 18:14:03 -0800826strip-static_c: static_c
Nicolas "Pixel" Noble3a2551c2015-01-29 21:33:32 +0100827ifeq ($(CONFIG),opt)
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800828% for lib in libs:
Craig Tiller59140fc2015-01-18 10:12:17 -0800829% if lib.language == "c":
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800830% if lib.build == "all":
831 $(E) "[STRIP] Stripping lib${lib.name}.a"
Craig Tiller61b910f2015-02-15 10:54:07 -0800832 $(Q) $(STRIP) $(LIBDIR)/$(CONFIG)/lib${lib.name}.a
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800833% endif
nnoble85a49262014-12-08 18:14:03 -0800834% endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800835% endfor
Nicolas "Pixel" Noble3a2551c2015-01-29 21:33:32 +0100836endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800837
nnoble85a49262014-12-08 18:14:03 -0800838strip-static_cxx: static_cxx
Nicolas "Pixel" Noble3a2551c2015-01-29 21:33:32 +0100839ifeq ($(CONFIG),opt)
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800840% for lib in libs:
Craig Tiller59140fc2015-01-18 10:12:17 -0800841% if lib.language == "c++":
nnoble85a49262014-12-08 18:14:03 -0800842% if lib.build == "all":
843 $(E) "[STRIP] Stripping lib${lib.name}.a"
Craig Tiller61b910f2015-02-15 10:54:07 -0800844 $(Q) $(STRIP) $(LIBDIR)/$(CONFIG)/lib${lib.name}.a
nnoble85a49262014-12-08 18:14:03 -0800845% endif
846% endif
847% endfor
Nicolas "Pixel" Noble3a2551c2015-01-29 21:33:32 +0100848endif
nnoble85a49262014-12-08 18:14:03 -0800849
850strip-shared_c: shared_c
Nicolas "Pixel" Noble3a2551c2015-01-29 21:33:32 +0100851ifeq ($(CONFIG),opt)
nnoble85a49262014-12-08 18:14:03 -0800852% for lib in libs:
Craig Tiller59140fc2015-01-18 10:12:17 -0800853% if lib.language == "c":
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800854% if lib.build == "all":
855 $(E) "[STRIP] Stripping lib${lib.name}.so"
Craig Tiller61b910f2015-02-15 10:54:07 -0800856 $(Q) $(STRIP) $(LIBDIR)/$(CONFIG)/lib${lib.name}.$(SHARED_EXT)
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800857% endif
nnoble85a49262014-12-08 18:14:03 -0800858% endif
859% endfor
Nicolas "Pixel" Noble3a2551c2015-01-29 21:33:32 +0100860endif
nnoble85a49262014-12-08 18:14:03 -0800861
862strip-shared_cxx: shared_cxx
Nicolas "Pixel" Noble3a2551c2015-01-29 21:33:32 +0100863ifeq ($(CONFIG),opt)
nnoble85a49262014-12-08 18:14:03 -0800864% for lib in libs:
Craig Tiller59140fc2015-01-18 10:12:17 -0800865% if lib.language == "c++":
nnoble85a49262014-12-08 18:14:03 -0800866% if lib.build == "all":
867 $(E) "[STRIP] Stripping lib${lib.name}.so"
Craig Tiller61b910f2015-02-15 10:54:07 -0800868 $(Q) $(STRIP) $(LIBDIR)/$(CONFIG)/lib${lib.name}.$(SHARED_EXT)
nnoble85a49262014-12-08 18:14:03 -0800869% endif
870% endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800871% endfor
Nicolas "Pixel" Noble3a2551c2015-01-29 21:33:32 +0100872endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800873
Jan Tattermusch2ec0b3e2015-02-18 15:03:12 -0800874strip-shared_csharp: shared_csharp
875ifeq ($(CONFIG),opt)
876% for lib in libs:
877% if lib.language == "csharp":
878% if lib.build == "all":
879 $(E) "[STRIP] Stripping lib${lib.name}.so"
880 $(Q) $(STRIP) $(LIBDIR)/$(CONFIG)/lib${lib.name}.$(SHARED_EXT)
881% endif
882% endif
883% endfor
884endif
885
nnoble72309c62014-12-12 11:42:26 -0800886% for p in protos:
Nicolas Noble53830622015-02-12 16:56:38 -0800887ifeq ($(NO_PROTOC),true)
Craig Tiller61b910f2015-02-15 10:54:07 -0800888$(GENDIR)/${p}.pb.cc: protoc_dep_error
Nicolas "Pixel" Noble0caebbf2015-04-09 23:08:51 +0200889$(GENDIR)/${p}.grpc.pb.cc: protoc_dep_error
Nicolas Noble53830622015-02-12 16:56:38 -0800890else
Craig Tiller61b910f2015-02-15 10:54:07 -0800891$(GENDIR)/${p}.pb.cc: ${p}.proto $(PROTOBUF_DEP) $(PROTOC_PLUGINS)
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800892 $(E) "[PROTOC] Generating protobuf CC file from $<"
893 $(Q) mkdir -p `dirname $@`
Nicolas "Pixel" Noble0caebbf2015-04-09 23:08:51 +0200894 $(Q) $(PROTOC) --cpp_out=$(GENDIR) $<
895
896$(GENDIR)/${p}.grpc.pb.cc: ${p}.proto $(PROTOBUF_DEP) $(PROTOC_PLUGINS)
897 $(E) "[GRPC] Generating gRPC's protobuf service CC file from $<"
898 $(Q) mkdir -p `dirname $@`
899 $(Q) $(PROTOC) --grpc_out=$(GENDIR) --plugin=protoc-gen-grpc=$(BINDIR)/$(CONFIG)/grpc_cpp_plugin $<
Nicolas Noble53830622015-02-12 16:56:38 -0800900endif
nnoble72309c62014-12-12 11:42:26 -0800901
902% endfor
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800903
David Garcia Quintasbbc0b772015-04-29 14:10:05 -0700904ifeq ($(CONFIG),stapprof)
905src/core/profiling/stap_timers.c: $(GENDIR)/src/core/profiling/stap_probes.h
David Garcia Quintas611b7362015-04-27 15:49:31 -0700906ifeq ($(HAS_SYSTEMTAP),true)
907$(GENDIR)/src/core/profiling/stap_probes.h: src/core/profiling/stap_probes.d
908 $(E) "[DTRACE] Compiling $<"
909 $(Q) mkdir -p `dirname $@`
910 $(Q) $(DTRACE) -C -h -s $< -o $@
David Garcia Quintas8954e902015-04-29 09:46:33 -0700911else
912$(GENDIR)/src/core/profiling/stap_probes.h: systemtap_dep_error stop
913endif
David Garcia Quintas611b7362015-04-27 15:49:31 -0700914endif
915
Craig Tiller61b910f2015-02-15 10:54:07 -0800916$(OBJDIR)/$(CONFIG)/%.o : %.c
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800917 $(E) "[C] Compiling $<"
918 $(Q) mkdir -p `dirname $@`
Craig Tiller12c82092015-01-15 08:45:56 -0800919 $(Q) $(CC) $(CFLAGS) $(CPPFLAGS) -MMD -MF $(addsuffix .dep, $(basename $@)) -c -o $@ $<
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800920
Craig Tiller61b910f2015-02-15 10:54:07 -0800921$(OBJDIR)/$(CONFIG)/%.o : $(GENDIR)/%.pb.cc
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800922 $(E) "[CXX] Compiling $<"
923 $(Q) mkdir -p `dirname $@`
Craig Tiller12c82092015-01-15 08:45:56 -0800924 $(Q) $(CXX) $(CXXFLAGS) $(CPPFLAGS) -MMD -MF $(addsuffix .dep, $(basename $@)) -c -o $@ $<
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800925
Craig Tiller61b910f2015-02-15 10:54:07 -0800926$(OBJDIR)/$(CONFIG)/src/compiler/%.o : src/compiler/%.cc
nnoble72309c62014-12-12 11:42:26 -0800927 $(E) "[HOSTCXX] Compiling $<"
928 $(Q) mkdir -p `dirname $@`
Craig Tiller12c82092015-01-15 08:45:56 -0800929 $(Q) $(HOST_CXX) $(HOST_CXXFLAGS) $(HOST_CPPFLAGS) -MMD -MF $(addsuffix .dep, $(basename $@)) -c -o $@ $<
nnoble72309c62014-12-12 11:42:26 -0800930
Craig Tiller61b910f2015-02-15 10:54:07 -0800931$(OBJDIR)/$(CONFIG)/%.o : %.cc
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800932 $(E) "[CXX] Compiling $<"
933 $(Q) mkdir -p `dirname $@`
Craig Tiller12c82092015-01-15 08:45:56 -0800934 $(Q) $(CXX) $(CXXFLAGS) $(CPPFLAGS) -MMD -MF $(addsuffix .dep, $(basename $@)) -c -o $@ $<
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800935
Nicolas "Pixel" Noble161ea232015-02-22 05:48:53 +0100936install: install_c install_cxx install-plugins install-certs verify-install
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800937
nnoble85a49262014-12-08 18:14:03 -0800938install_c: install-headers_c install-static_c install-shared_c
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800939
nnoble85a49262014-12-08 18:14:03 -0800940install_cxx: install-headers_cxx install-static_cxx install-shared_cxx
941
Jan Tattermusch2ec0b3e2015-02-18 15:03:12 -0800942install_csharp: install-shared_csharp install_c
943
944install_grpc_csharp_ext: install_csharp
945
nnoble85a49262014-12-08 18:14:03 -0800946install-headers: install-headers_c install-headers_cxx
947
948install-headers_c:
949 $(E) "[INSTALL] Installing public C headers"
Nicolas "Pixel" Noble932d5d32015-02-21 02:15:34 +0100950 $(Q) $(foreach h, $(PUBLIC_HEADERS_C), $(INSTALL) -d $(prefix)/$(dir $(h)) && ) exit 0 || exit 1
nnoble85a49262014-12-08 18:14:03 -0800951 $(Q) $(foreach h, $(PUBLIC_HEADERS_C), $(INSTALL) $(h) $(prefix)/$(h) && ) exit 0 || exit 1
952
953install-headers_cxx:
954 $(E) "[INSTALL] Installing public C++ headers"
Nicolas "Pixel" Noble932d5d32015-02-21 02:15:34 +0100955 $(Q) $(foreach h, $(PUBLIC_HEADERS_CXX), $(INSTALL) -d $(prefix)/$(dir $(h)) && ) exit 0 || exit 1
nnoble85a49262014-12-08 18:14:03 -0800956 $(Q) $(foreach h, $(PUBLIC_HEADERS_CXX), $(INSTALL) $(h) $(prefix)/$(h) && ) exit 0 || exit 1
957
958install-static: install-static_c install-static_cxx
959
960install-static_c: static_c strip-static_c
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800961% for lib in libs:
Craig Tiller59140fc2015-01-18 10:12:17 -0800962% if lib.language == "c":
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800963% if lib.build == "all":
964 $(E) "[INSTALL] Installing lib${lib.name}.a"
Nicolas "Pixel" Noble932d5d32015-02-21 02:15:34 +0100965 $(Q) $(INSTALL) -d $(prefix)/lib
Craig Tiller61b910f2015-02-15 10:54:07 -0800966 $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/lib${lib.name}.a $(prefix)/lib/lib${lib.name}.a
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800967% endif
nnoble85a49262014-12-08 18:14:03 -0800968% endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800969% endfor
970
nnoble85a49262014-12-08 18:14:03 -0800971install-static_cxx: static_cxx strip-static_cxx
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800972% for lib in libs:
Craig Tiller59140fc2015-01-18 10:12:17 -0800973% if lib.language == "c++":
nnoble85a49262014-12-08 18:14:03 -0800974% if lib.build == "all":
975 $(E) "[INSTALL] Installing lib${lib.name}.a"
Nicolas "Pixel" Noble932d5d32015-02-21 02:15:34 +0100976 $(Q) $(INSTALL) -d $(prefix)/lib
Craig Tiller61b910f2015-02-15 10:54:07 -0800977 $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/lib${lib.name}.a $(prefix)/lib/lib${lib.name}.a
nnoble85a49262014-12-08 18:14:03 -0800978% endif
979% endif
980% endfor
981
Nicolas "Pixel" Noble522d7122015-02-19 01:28:02 +0100982<%def name="install_shared(lang_filter)">\
nnoble85a49262014-12-08 18:14:03 -0800983% for lib in libs:
Nicolas "Pixel" Noble522d7122015-02-19 01:28:02 +0100984% if lib.language == lang_filter:
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800985% if lib.build == "all":
nnoble5b7f32a2014-12-22 08:12:44 -0800986ifeq ($(SYSTEM),MINGW32)
987 $(E) "[INSTALL] Installing ${lib.name}.$(SHARED_EXT)"
Nicolas "Pixel" Noble932d5d32015-02-21 02:15:34 +0100988 $(Q) $(INSTALL) -d $(prefix)/lib
Craig Tiller61b910f2015-02-15 10:54:07 -0800989 $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/${lib.name}.$(SHARED_EXT) $(prefix)/lib/${lib.name}.$(SHARED_EXT)
990 $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/lib${lib.name}-imp.a $(prefix)/lib/lib${lib.name}-imp.a
nnoble5b7f32a2014-12-22 08:12:44 -0800991else
992 $(E) "[INSTALL] Installing lib${lib.name}.$(SHARED_EXT)"
Nicolas "Pixel" Noble932d5d32015-02-21 02:15:34 +0100993 $(Q) $(INSTALL) -d $(prefix)/lib
Craig Tiller61b910f2015-02-15 10:54:07 -0800994 $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/lib${lib.name}.$(SHARED_EXT) $(prefix)/lib/lib${lib.name}.$(SHARED_EXT)
Masood Malekghassemid1be74f2015-04-07 16:23:09 -0700995ifneq ($(SYSTEM),Darwin)
Tim Emiola820e3d62015-04-10 09:11:50 -0700996 $(Q) ln -sf lib${lib.name}.$(SHARED_EXT) $(prefix)/lib/lib${lib.name}.so.${settings.version.major}
nnoble5b7f32a2014-12-22 08:12:44 -0800997 $(Q) ln -sf lib${lib.name}.$(SHARED_EXT) $(prefix)/lib/lib${lib.name}.so
998endif
999endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001000% endif
nnoble85a49262014-12-08 18:14:03 -08001001% endif
1002% endfor
nnoble5b7f32a2014-12-22 08:12:44 -08001003ifneq ($(SYSTEM),MINGW32)
1004ifneq ($(SYSTEM),Darwin)
Nicolas "Pixel" Noblecc2b42a2015-02-20 00:42:21 +01001005 $(Q) ldconfig || true
nnoble5b7f32a2014-12-22 08:12:44 -08001006endif
1007endif
Nicolas "Pixel" Noble522d7122015-02-19 01:28:02 +01001008</%def>
nnoble85a49262014-12-08 18:14:03 -08001009
Nicolas "Pixel" Noble522d7122015-02-19 01:28:02 +01001010install-shared_c: shared_c strip-shared_c
1011${install_shared("c")}
1012
1013install-shared_cxx: shared_cxx strip-shared_cxx install-shared_c
1014${install_shared("c++")}
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001015
Jan Tattermusch2ec0b3e2015-02-18 15:03:12 -08001016install-shared_csharp: shared_csharp strip-shared_csharp
Nicolas "Pixel" Noble522d7122015-02-19 01:28:02 +01001017${install_shared("csharp")}
1018
Nicolas "Pixel" Noble522d7122015-02-19 01:28:02 +01001019install-plugins: $(PROTOC_PLUGINS)
1020ifeq ($(SYSTEM),MINGW32)
1021 $(Q) false
1022else
1023 $(E) "[INSTALL] Installing grpc protoc plugins"
1024% for tgt in targets:
1025% if tgt.build == 'protoc':
Nicolas "Pixel" Noble932d5d32015-02-21 02:15:34 +01001026 $(Q) $(INSTALL) -d $(prefix)/bin
Nicolas "Pixel" Noble522d7122015-02-19 01:28:02 +01001027 $(Q) $(INSTALL) $(BINDIR)/$(CONFIG)/${tgt.name} $(prefix)/bin/${tgt.name}
1028% endif
1029% endfor
1030endif
Jan Tattermusch2ec0b3e2015-02-18 15:03:12 -08001031
Nicolas "Pixel" Noble161ea232015-02-22 05:48:53 +01001032install-certs: etc/roots.pem
1033 $(E) "[INSTALL] Installing root certificates"
1034 $(Q) $(INSTALL) -d $(prefix)/share/grpc
1035 $(Q) $(INSTALL) etc/roots.pem $(prefix)/share/grpc/roots.pem
1036
Nicolas "Pixel" Noble98ab9982015-02-21 04:22:16 +01001037verify-install:
Nicolas "Pixel" Noble2c23a722015-02-24 20:17:45 +01001038ifeq ($(INSTALL_OK),true)
Nicolas "Pixel" Noble98ab9982015-02-21 04:22:16 +01001039 @echo "Your system looks ready to go."
1040 @echo
1041else
murgatroid99b6181362015-03-02 14:32:25 -08001042 @echo "We couldn't find protoc 3.0.0+ installed on your system. While this"
Nicolas "Pixel" Noble98ab9982015-02-21 04:22:16 +01001043 @echo "won't prevent grpc from working, you won't be able to compile"
1044 @echo "and run any meaningful code with it."
1045 @echo
1046 @echo
1047 @echo "Please download and install protobuf 3.0.0+ from:"
1048 @echo
1049 @echo " https://github.com/google/protobuf/releases"
1050 @echo
murgatroid99b6181362015-03-02 14:32:25 -08001051 @echo "Once you've done so, or if you think this message is in error,"
1052 @echo "you can re-run this check by doing:"
Nicolas "Pixel" Noble98ab9982015-02-21 04:22:16 +01001053 @echo
1054 @echo " make verify-install"
1055endif
1056
Craig Tiller3759e6f2015-01-15 08:13:11 -08001057clean:
Nicolas "Pixel" Noble522d7122015-02-19 01:28:02 +01001058 $(E) "[CLEAN] Cleaning build directories."
Craig Tillerda224d62015-02-15 11:01:58 -08001059 $(Q) $(RM) -rf $(OBJDIR) $(LIBDIR) $(BINDIR) $(GENDIR)
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001060
1061
1062# The various libraries
1063
1064% for lib in libs:
1065${makelib(lib)}
1066% endfor
1067
1068
nnoble69ac39f2014-12-12 15:43:38 -08001069# All of the test targets, and protoc plugins
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001070
1071% for tgt in targets:
1072${maketarget(tgt)}
1073% endfor
1074
1075<%def name="makelib(lib)">
1076LIB${lib.name.upper()}_SRC = \\
1077
1078% for src in lib.src:
nnoble72309c62014-12-12 11:42:26 -08001079 ${proto_to_cc(src)} \\
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001080
1081% endfor
1082
1083% if "public_headers" in lib:
Craig Tiller59140fc2015-01-18 10:12:17 -08001084% if lib.language == "c++":
nnoble85a49262014-12-08 18:14:03 -08001085PUBLIC_HEADERS_CXX += \\
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001086
nnoble85a49262014-12-08 18:14:03 -08001087% else:
1088PUBLIC_HEADERS_C += \\
1089
1090% endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001091% for hdr in lib.public_headers:
1092 ${hdr} \\
1093
1094% endfor
1095% endif
1096
Craig Tiller61b910f2015-02-15 10:54:07 -08001097LIB${lib.name.upper()}_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(LIB${lib.name.upper()}_SRC))))
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001098
Nicolas Noble047b7272015-01-16 13:55:05 -08001099## If the library requires OpenSSL with ALPN, let's add some restrictions.
Nicolas "Pixel" Noble061690d2015-03-06 22:58:58 +01001100% if lib.get('secure', 'check') == 'yes' or lib.get('secure', 'check') == 'check':
nnoble69ac39f2014-12-12 15:43:38 -08001101ifeq ($(NO_SECURE),true)
1102
Nicolas Noble047b7272015-01-16 13:55:05 -08001103# You can't build secure libraries if you don't have OpenSSL with ALPN.
1104
Craig Tiller61b910f2015-02-15 10:54:07 -08001105$(LIBDIR)/$(CONFIG)/lib${lib.name}.a: openssl_dep_error
nnoble69ac39f2014-12-12 15:43:38 -08001106
nnoble5b7f32a2014-12-22 08:12:44 -08001107% if lib.build == "all":
1108ifeq ($(SYSTEM),MINGW32)
Craig Tiller61b910f2015-02-15 10:54:07 -08001109$(LIBDIR)/$(CONFIG)/${lib.name}.$(SHARED_EXT): openssl_dep_error
nnoble5b7f32a2014-12-22 08:12:44 -08001110else
Craig Tiller61b910f2015-02-15 10:54:07 -08001111$(LIBDIR)/$(CONFIG)/lib${lib.name}.$(SHARED_EXT): openssl_dep_error
nnoble5b7f32a2014-12-22 08:12:44 -08001112endif
1113% endif
1114
nnoble69ac39f2014-12-12 15:43:38 -08001115else
1116
Nicolas Noble53830622015-02-12 16:56:38 -08001117% if lib.language == 'c++':
1118ifeq ($(NO_PROTOBUF),true)
1119
1120# You can't build a C++ library if you don't have protobuf - a bit overreached, but still okay.
1121
Craig Tiller61b910f2015-02-15 10:54:07 -08001122$(LIBDIR)/$(CONFIG)/lib${lib.name}.a: protobuf_dep_error
Nicolas Noble53830622015-02-12 16:56:38 -08001123
1124% if lib.build == "all":
1125ifeq ($(SYSTEM),MINGW32)
Craig Tiller61b910f2015-02-15 10:54:07 -08001126$(LIBDIR)/$(CONFIG)/${lib.name}.$(SHARED_EXT): protobuf_dep_error
Nicolas Noble53830622015-02-12 16:56:38 -08001127else
Craig Tiller61b910f2015-02-15 10:54:07 -08001128$(LIBDIR)/$(CONFIG)/lib${lib.name}.$(SHARED_EXT): protobuf_dep_error
Nicolas Noble53830622015-02-12 16:56:38 -08001129endif
1130% endif
1131
1132else
1133% endif
1134
Craig Tiller61b910f2015-02-15 10:54:07 -08001135$(LIBDIR)/$(CONFIG)/lib${lib.name}.a: $(ZLIB_DEP) $(OPENSSL_DEP)\
Nicolas Noble047b7272015-01-16 13:55:05 -08001136## The else here corresponds to the if secure earlier.
nnoble20e2e3f2014-12-16 15:37:57 -08001137% else:
Nicolas Noble53830622015-02-12 16:56:38 -08001138% if lib.language == 'c++':
1139ifeq ($(NO_PROTOBUF),true)
1140
1141# You can't build a C++ library if you don't have protobuf - a bit overreached, but still okay.
1142
Craig Tiller61b910f2015-02-15 10:54:07 -08001143$(LIBDIR)/$(CONFIG)/lib${lib.name}.a: protobuf_dep_error
Nicolas Noble53830622015-02-12 16:56:38 -08001144
1145% if lib.build == "all":
1146ifeq ($(SYSTEM),MINGW32)
Craig Tiller61b910f2015-02-15 10:54:07 -08001147$(LIBDIR)/$(CONFIG)/${lib.name}.$(SHARED_EXT): protobuf_dep_error
Nicolas Noble53830622015-02-12 16:56:38 -08001148else
Craig Tiller61b910f2015-02-15 10:54:07 -08001149$(LIBDIR)/$(CONFIG)/lib${lib.name}.$(SHARED_EXT): protobuf_dep_error
Nicolas Noble53830622015-02-12 16:56:38 -08001150endif
nnoble20e2e3f2014-12-16 15:37:57 -08001151% endif
Nicolas Noble53830622015-02-12 16:56:38 -08001152
1153else
1154
1155% endif
Craig Tiller61b910f2015-02-15 10:54:07 -08001156$(LIBDIR)/$(CONFIG)/lib${lib.name}.a: $(ZLIB_DEP)\
Nicolas Noble53830622015-02-12 16:56:38 -08001157% endif
1158% if lib.language == 'c++':
1159 $(PROTOBUF_DEP)\
1160% endif
1161 $(LIB${lib.name.upper()}_OBJS)
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001162 $(E) "[AR] Creating $@"
nnoble85a49262014-12-08 18:14:03 -08001163 $(Q) mkdir -p `dirname $@`
Craig Tiller61b910f2015-02-15 10:54:07 -08001164 $(Q) rm -f $(LIBDIR)/$(CONFIG)/lib${lib.name}.a
1165 $(Q) $(AR) rcs $(LIBDIR)/$(CONFIG)/lib${lib.name}.a $(LIB${lib.name.upper()}_OBJS)
nnoble20e2e3f2014-12-16 15:37:57 -08001166% if lib.get('baselib', False):
Nicolas "Pixel" Noble061690d2015-03-06 22:58:58 +01001167% if lib.get('secure', 'check') == 'yes':
Craig Tiller7ab4fee2015-02-24 08:15:53 -08001168 $(Q) rm -rf tmp-merge-${lib.name}
1169 $(Q) mkdir tmp-merge-${lib.name}
1170 $(Q) ( cd tmp-merge-${lib.name} ; $(AR) x ../$(LIBDIR)/$(CONFIG)/lib${lib.name}.a )
1171 $(Q) for l in $(OPENSSL_MERGE_LIBS) ; do ( cd tmp-merge-${lib.name} ; <%text>ar x ../$${l}</%text> ) ; done
1172 $(Q) rm -f $(LIBDIR)/$(CONFIG)/lib${lib.name}.a tmp-merge-${lib.name}/__.SYMDEF*
1173 $(Q) ar rcs $(LIBDIR)/$(CONFIG)/lib${lib.name}.a tmp-merge-${lib.name}/*
1174 $(Q) rm -rf tmp-merge-${lib.name}
nnoble20e2e3f2014-12-16 15:37:57 -08001175% endif
1176% endif
Craig Tillerb4ee3b52015-01-21 16:22:50 -08001177ifeq ($(SYSTEM),Darwin)
murgatroid99b6181362015-03-02 14:32:25 -08001178 $(Q) ranlib $(LIBDIR)/$(CONFIG)/lib${lib.name}.a
Craig Tillerb4ee3b52015-01-21 16:22:50 -08001179endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001180
nnoble5b7f32a2014-12-22 08:12:44 -08001181<%
Nicolas "Pixel" Noble010f1e72015-04-23 02:23:49 +02001182
Craig Tiller59140fc2015-01-18 10:12:17 -08001183 if lib.language == 'c++':
nnoble5b7f32a2014-12-22 08:12:44 -08001184 ld = '$(LDXX)'
1185 else:
1186 ld = '$(LD)'
1187
Craig Tillerda224d62015-02-15 11:01:58 -08001188 out_base = '$(LIBDIR)/$(CONFIG)/' + lib.name
1189 out_libbase = '$(LIBDIR)/$(CONFIG)/lib' + lib.name
nnoble5b7f32a2014-12-22 08:12:44 -08001190
1191 common = '$(LIB' + lib.name.upper() + '_OBJS) $(LDLIBS)'
1192
1193 libs = ''
Nicolas "Pixel" Noble85bf09b2015-01-15 18:22:40 +01001194 lib_deps = ' $(ZLIB_DEP)'
nnoble5b7f32a2014-12-22 08:12:44 -08001195 mingw_libs = ''
Nicolas "Pixel" Noble85bf09b2015-01-15 18:22:40 +01001196 mingw_lib_deps = ' $(ZLIB_DEP)'
Michael Berlinbf2e7f02015-05-01 16:17:01 -07001197 if lib.language == 'c++':
1198 lib_deps += ' $(PROTOBUF_DEP)'
1199 mingw_lib_deps += ' $(PROTOBUF_DEP)'
nnoble5b7f32a2014-12-22 08:12:44 -08001200 for dep in lib.get('deps', []):
1201 libs = libs + ' -l' + dep
Craig Tiller61b910f2015-02-15 10:54:07 -08001202 lib_deps = lib_deps + ' $(LIBDIR)/$(CONFIG)/lib' + dep + '.$(SHARED_EXT)'
nnoble5b7f32a2014-12-22 08:12:44 -08001203 mingw_libs = mingw_libs + ' -l' + dep + '-imp'
Michael Berlin53513922015-05-01 16:14:15 -07001204 mingw_lib_deps = mingw_lib_deps + ' $(LIBDIR)/$(CONFIG)/' + dep + '.$(SHARED_EXT)'
nnoble5b7f32a2014-12-22 08:12:44 -08001205
Nicolas "Pixel" Noble061690d2015-03-06 22:58:58 +01001206 if lib.get('secure', 'check') == 'yes':
nnoble5b7f32a2014-12-22 08:12:44 -08001207 common = common + ' $(LDLIBS_SECURE) $(OPENSSL_MERGE_LIBS)'
Nicolas "Pixel" Noble010f1e72015-04-23 02:23:49 +02001208 for src in lib.src:
1209 sources_that_need_openssl.add(src)
1210 else:
1211 for src in lib.src:
1212 sources_that_don_t_need_openssl.add(src)
Nicolas "Pixel" Noble061690d2015-03-06 22:58:58 +01001213
1214 if lib.get('secure', 'check') == 'yes' or lib.get('secure', 'check') == 'check':
nnoble5b7f32a2014-12-22 08:12:44 -08001215 lib_deps = lib_deps + ' $(OPENSSL_DEP)'
1216 mingw_lib_deps = mingw_lib_deps + ' $(OPENSSL_DEP)'
Nicolas "Pixel" Nobledda049c2015-02-21 00:39:32 +01001217
1218 if lib.language == 'c++':
1219 common = common + ' $(LDLIBSXX) $(LDLIBS_PROTOBUF)'
nnoble5b7f32a2014-12-22 08:12:44 -08001220%>
1221
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001222% if lib.build == "all":
nnoble5b7f32a2014-12-22 08:12:44 -08001223ifeq ($(SYSTEM),MINGW32)
1224${out_base}.$(SHARED_EXT): $(LIB${lib.name.upper()}_OBJS) ${mingw_lib_deps}
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001225 $(E) "[LD] Linking $@"
nnoble85a49262014-12-08 18:14:03 -08001226 $(Q) mkdir -p `dirname $@`
Craig Tillerda224d62015-02-15 11:01:58 -08001227 $(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 -08001228else
1229${out_libbase}.$(SHARED_EXT): $(LIB${lib.name.upper()}_OBJS) ${lib_deps}
1230 $(E) "[LD] Linking $@"
1231 $(Q) mkdir -p `dirname $@`
1232ifeq ($(SYSTEM),Darwin)
Masood Malekghassemid1be74f2015-04-07 16:23:09 -07001233 $(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 -08001234else
Craig Tillerda224d62015-02-15 11:01:58 -08001235 $(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 +01001236 $(Q) ln -sf lib${lib.name}.$(SHARED_EXT) ${out_libbase}.so.${settings.version.major}
nnoble5b7f32a2014-12-22 08:12:44 -08001237 $(Q) ln -sf lib${lib.name}.$(SHARED_EXT) ${out_libbase}.so
1238endif
1239endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001240% endif
Nicolas "Pixel" Noble061690d2015-03-06 22:58:58 +01001241% if lib.get('secure', 'check') == 'yes' or lib.get('secure', 'check') == 'check':
Nicolas Noble047b7272015-01-16 13:55:05 -08001242## If the lib was secure, we have to close the Makefile's if that tested
1243## the presence of an ALPN-capable OpenSSL.
Nicolas Noble53830622015-02-12 16:56:38 -08001244
1245endif
1246% endif
1247% if lib.language == 'c++':
1248## If the lib was C++, we have to close the Makefile's if that tested
1249## the presence of protobuf 3.0.0+
nnoble69ac39f2014-12-12 15:43:38 -08001250
1251endif
1252% endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001253
Nicolas "Pixel" Noble061690d2015-03-06 22:58:58 +01001254% if lib.get('secure', 'check') == 'yes' or lib.get('secure', 'check') == 'check':
nnoble69ac39f2014-12-12 15:43:38 -08001255ifneq ($(NO_SECURE),true)
1256% endif
1257ifneq ($(NO_DEPS),true)
Craig Tiller8f126a62015-01-15 08:50:19 -08001258-include $(LIB${lib.name.upper()}_OBJS:.o=.dep)
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001259endif
Nicolas "Pixel" Noble061690d2015-03-06 22:58:58 +01001260% if lib.get('secure', 'check') == 'yes' or lib.get('secure', 'check') == 'check':
nnoble69ac39f2014-12-12 15:43:38 -08001261endif
1262% endif
Craig Tiller27715ca2015-01-12 16:55:59 -08001263% for src in lib.src:
Craig Tillerd896fa52015-04-24 14:30:09 -07001264% if not proto_re.match(src) and any(proto_re.match(src2) for src2 in lib.src):
Craig Tiller04f81562015-04-24 14:34:30 -07001265$(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 -08001266% endif
Craig Tiller27715ca2015-01-12 16:55:59 -08001267% endfor
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001268</%def>
1269
Nicolas "Pixel" Nobleadaa1002015-04-29 08:56:01 +02001270<%def name="maketarget(tgt)"><% has_no_sources = not tgt.src %>
1271% if not has_no_sources:
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001272${tgt.name.upper()}_SRC = \\
1273
1274% for src in tgt.src:
nnoble72309c62014-12-12 11:42:26 -08001275 ${proto_to_cc(src)} \\
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001276
1277% endfor
1278
Craig Tiller61b910f2015-02-15 10:54:07 -08001279${tgt.name.upper()}_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(${tgt.name.upper()}_SRC))))
Nicolas "Pixel" Nobleadaa1002015-04-29 08:56:01 +02001280% endif
Nicolas "Pixel" Noble061690d2015-03-06 22:58:58 +01001281% if tgt.get('secure', 'check') == 'yes' or tgt.get('secure', 'check') == 'check':
nnoble69ac39f2014-12-12 15:43:38 -08001282ifeq ($(NO_SECURE),true)
1283
Nicolas Noble047b7272015-01-16 13:55:05 -08001284# You can't build secure targets if you don't have OpenSSL with ALPN.
1285
Craig Tiller61b910f2015-02-15 10:54:07 -08001286$(BINDIR)/$(CONFIG)/${tgt.name}: openssl_dep_error
nnoble69ac39f2014-12-12 15:43:38 -08001287
1288else
1289
1290% endif
Nicolas Noble047b7272015-01-16 13:55:05 -08001291##
1292## We're not trying to add a dependency on building zlib and openssl here,
1293## as it's already done in the libraries. We're assuming that the build
1294## trickles down, and that a secure target requires a secure version of
1295## a library.
1296##
1297## That simplifies the codegen a bit, but prevents a fully defined Makefile.
1298## I can live with that.
1299##
Nicolas "Pixel" Noble18953e32015-02-27 02:41:11 +01001300% if tgt.build == 'protoc' or tgt.language == 'c++':
Nicolas Noble53830622015-02-12 16:56:38 -08001301
1302ifeq ($(NO_PROTOBUF),true)
1303
Nicolas "Pixel" Noble18953e32015-02-27 02:41:11 +01001304# 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 -08001305
Craig Tiller61b910f2015-02-15 10:54:07 -08001306$(BINDIR)/$(CONFIG)/${tgt.name}: protobuf_dep_error
Nicolas Noble53830622015-02-12 16:56:38 -08001307
1308else
1309
Nicolas "Pixel" Nobleadaa1002015-04-29 08:56:01 +02001310$(BINDIR)/$(CONFIG)/${tgt.name}: \
1311% if not has_no_sources:
1312$(PROTOBUF_DEP) $(${tgt.name.upper()}_OBJS)\
1313% endif
Nicolas Noble53830622015-02-12 16:56:38 -08001314% else:
Nicolas "Pixel" Nobleadaa1002015-04-29 08:56:01 +02001315$(BINDIR)/$(CONFIG)/${tgt.name}: \
1316% if not has_no_sources:
1317$(${tgt.name.upper()}_OBJS)\
1318% endif
Nicolas Noble53830622015-02-12 16:56:38 -08001319% endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001320% for dep in tgt.deps:
Craig Tiller61b910f2015-02-15 10:54:07 -08001321 $(LIBDIR)/$(CONFIG)/lib${dep}.a\
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001322% endfor
1323
Craig Tiller59140fc2015-01-18 10:12:17 -08001324% if tgt.language == "c++":
Nicolas Noble047b7272015-01-16 13:55:05 -08001325## C++ targets specificies.
nnoble72309c62014-12-12 11:42:26 -08001326% if tgt.build == 'protoc':
1327 $(E) "[HOSTLD] Linking $@"
1328 $(Q) mkdir -p `dirname $@`
Nicolas "Pixel" Nobleadaa1002015-04-29 08:56:01 +02001329 $(Q) $(HOST_LDXX) $(HOST_LDFLAGS) \
1330% if not has_no_sources:
1331$(${tgt.name.upper()}_OBJS)\
1332% endif
nnoble72309c62014-12-12 11:42:26 -08001333% else:
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001334 $(E) "[LD] Linking $@"
nnoble85a49262014-12-08 18:14:03 -08001335 $(Q) mkdir -p `dirname $@`
Nicolas "Pixel" Nobleadaa1002015-04-29 08:56:01 +02001336 $(Q) $(LDXX) $(LDFLAGS) \
1337% if not has_no_sources:
1338$(${tgt.name.upper()}_OBJS)\
1339% endif
nnoble72309c62014-12-12 11:42:26 -08001340% endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001341% else:
Nicolas Noble047b7272015-01-16 13:55:05 -08001342## C-only targets specificities.
nnoble72309c62014-12-12 11:42:26 -08001343 $(E) "[LD] Linking $@"
1344 $(Q) mkdir -p `dirname $@`
Nicolas "Pixel" Nobleadaa1002015-04-29 08:56:01 +02001345 $(Q) $(LD) $(LDFLAGS) \
1346% if not has_no_sources:
1347$(${tgt.name.upper()}_OBJS)\
1348% endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001349% endif
1350% for dep in tgt.deps:
Craig Tiller61b910f2015-02-15 10:54:07 -08001351 $(LIBDIR)/$(CONFIG)/lib${dep}.a\
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001352% endfor
Craig Tiller59140fc2015-01-18 10:12:17 -08001353% if tgt.language == "c++":
nnoble72309c62014-12-12 11:42:26 -08001354% if tgt.build == 'protoc':
Nicolas Noble53830622015-02-12 16:56:38 -08001355 $(HOST_LDLIBSXX) $(HOST_LDLIBS_PROTOC)\
nnoble72309c62014-12-12 11:42:26 -08001356% else:
Nicolas Noble53830622015-02-12 16:56:38 -08001357 $(LDLIBSXX) $(LDLIBS_PROTOBUF)\
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001358% endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001359% endif
nnoblec78b3402014-12-11 16:06:57 -08001360% if tgt.build == 'protoc':
nnoble72309c62014-12-12 11:42:26 -08001361 $(HOST_LDLIBS)\
1362% else:
1363 $(LDLIBS)\
1364% endif
1365% if tgt.build == 'protoc':
1366 $(HOST_LDLIBS_PROTOC)\
Nicolas "Pixel" Noble061690d2015-03-06 22:58:58 +01001367% elif tgt.get('secure', 'check') == 'yes' or tgt.get('secure', 'check') == 'check':
nnoble72309c62014-12-12 11:42:26 -08001368 $(LDLIBS_SECURE)\
nnoblec78b3402014-12-11 16:06:57 -08001369% endif
Yang Gaob0b518e2015-04-13 14:53:25 -07001370% if tgt.language == 'c++' and tgt.build == 'test':
1371 $(GTEST_LIB)\
David Garcia Quintasaa52d0a2015-05-14 19:04:23 -07001372% elif tgt.language == 'c++' and tgt.build == 'benchmark':
1373 $(GTEST_LIB)\
Yang Gaob0b518e2015-04-13 14:53:25 -07001374% endif
Craig Tiller61b910f2015-02-15 10:54:07 -08001375 -o $(BINDIR)/$(CONFIG)/${tgt.name}
Nicolas "Pixel" Noble18953e32015-02-27 02:41:11 +01001376% if tgt.build == 'protoc' or tgt.language == 'c++':
Nicolas Noble53830622015-02-12 16:56:38 -08001377
1378endif
1379% endif
Nicolas "Pixel" Noble061690d2015-03-06 22:58:58 +01001380% if tgt.get('secure', 'check') == 'yes' or tgt.get('secure', 'check') == 'check':
nnoble69ac39f2014-12-12 15:43:38 -08001381
1382endif
1383% endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001384
Craig Tillerf5371ef2015-01-12 16:40:18 -08001385% for src in tgt.src:
Craig Tiller61b910f2015-02-15 10:54:07 -08001386$(OBJDIR)/$(CONFIG)/${os.path.splitext(src)[0]}.o: \
Craig Tillerf5371ef2015-01-12 16:40:18 -08001387% for dep in tgt.deps:
Craig Tiller61b910f2015-02-15 10:54:07 -08001388 $(LIBDIR)/$(CONFIG)/lib${dep}.a\
Craig Tillerf5371ef2015-01-12 16:40:18 -08001389% endfor
1390
1391% endfor
Nicolas "Pixel" Nobleadaa1002015-04-29 08:56:01 +02001392% if not has_no_sources:
Craig Tiller8f126a62015-01-15 08:50:19 -08001393deps_${tgt.name}: $(${tgt.name.upper()}_OBJS:.o=.dep)
Nicolas "Pixel" Nobleadaa1002015-04-29 08:56:01 +02001394% endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001395
Nicolas "Pixel" Nobleadaa1002015-04-29 08:56:01 +02001396% if not has_no_sources:
Nicolas "Pixel" Noble061690d2015-03-06 22:58:58 +01001397% if tgt.get('secure', 'check') == 'yes' or tgt.get('secure', 'check') == 'check':
nnoble69ac39f2014-12-12 15:43:38 -08001398ifneq ($(NO_SECURE),true)
1399% endif
1400ifneq ($(NO_DEPS),true)
Craig Tiller8f126a62015-01-15 08:50:19 -08001401-include $(${tgt.name.upper()}_OBJS:.o=.dep)
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001402endif
Nicolas "Pixel" Noble061690d2015-03-06 22:58:58 +01001403% if tgt.get('secure', 'check') == 'yes' or tgt.get('secure', 'check') == 'check':
nnoble69ac39f2014-12-12 15:43:38 -08001404endif
1405% endif
Nicolas "Pixel" Nobleadaa1002015-04-29 08:56:01 +02001406% endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001407</%def>
1408
Nicolas "Pixel" Noble010f1e72015-04-23 02:23:49 +02001409ifneq ($(OPENSSL_DEP),)
1410# This is to ensure the embedded OpenSSL is built beforehand, properly
1411# installing headers to their final destination on the drive. We need this
1412# otherwise parallel compilation will fail if a source is compiled first.
1413% for src in sorted(sources_that_need_openssl):
1414% if src not in sources_that_don_t_need_openssl:
1415${src}: $(OPENSSL_DEP)
1416% endif
1417% endfor
1418endif
1419
nnoble85a49262014-12-08 18:14:03 -08001420.PHONY: all strip tools \
nnoble69ac39f2014-12-12 15:43:38 -08001421dep_error openssl_dep_error openssl_dep_message git_update stop \
nnoble85a49262014-12-08 18:14:03 -08001422buildtests buildtests_c buildtests_cxx \
1423test test_c test_cxx \
1424install install_c install_cxx \
1425install-headers install-headers_c install-headers_cxx \
1426install-shared install-shared_c install-shared_cxx \
1427install-static install-static_c install-static_cxx \
1428strip strip-shared strip-static \
1429strip_c strip-shared_c strip-static_c \
1430strip_cxx strip-shared_cxx strip-static_cxx \
Craig Tillerf0afe502015-01-15 09:04:49 -08001431dep_c dep_cxx bins_dep_c bins_dep_cxx \
Craig Tiller12c82092015-01-15 08:45:56 -08001432clean