blob: ba06a03837947c6a12fd3ec95850441d87e77c1e [file] [log] [blame]
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001# GRPC global makefile
2# This currently builds C and C++ code.
Craig Tiller3b935482015-02-16 12:15:48 -08003
4# Copyright 2014, Google Inc.
5# All rights reserved.
6#
7# Redistribution and use in source and binary forms, with or without
8# modification, are permitted provided that the following conditions are
9# met:
10#
11# * Redistributions of source code must retain the above copyright
12# notice, this list of conditions and the following disclaimer.
13# * Redistributions in binary form must reproduce the above
14# copyright notice, this list of conditions and the following disclaimer
15# in the documentation and/or other materials provided with the
16# distribution.
17# * Neither the name of Google Inc. nor the names of its
18# contributors may be used to endorse or promote products derived from
19# this software without specific prior written permission.
20#
21# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -080032<%!
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -080033 import re
Craig Tillerf5371ef2015-01-12 16:40:18 -080034 import os
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -080035
nnoblec87b1c52015-01-05 17:15:18 -080036 proto_re = re.compile('(.*)\\.proto')
nnoble72309c62014-12-12 11:42:26 -080037
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -080038 def excluded(filename, exclude_res):
39 for r in exclude_res:
40 if r.match(filename):
41 return True
42 return False
nnoble72309c62014-12-12 11:42:26 -080043
44 def proto_to_cc(filename):
45 m = proto_re.match(filename)
46 if not m:
47 return filename
Craig Tillerda224d62015-02-15 11:01:58 -080048 return '$(GENDIR)/' + m.group(1) + '.pb.cc'
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -080049%>
50
Craig Tiller96b49552015-01-21 16:29:01 -080051
52# Basic platform detection
53HOST_SYSTEM = $(shell uname | cut -f 1 -d_)
54ifeq ($(SYSTEM),)
55SYSTEM = $(HOST_SYSTEM)
56endif
57
58
Craig Tiller61b910f2015-02-15 10:54:07 -080059ifndef BUILDDIR
60BUILDDIR = .
61endif
62
63BINDIR = $(BUILDDIR)/bins
64OBJDIR = $(BUILDDIR)/objs
65LIBDIR = $(BUILDDIR)/libs
66GENDIR = $(BUILDDIR)/gens
67
ctiller8cfebb92015-01-06 15:02:12 -080068# Configurations
69
70VALID_CONFIG_opt = 1
71CC_opt = gcc
72CXX_opt = g++
73LD_opt = gcc
74LDXX_opt = g++
75CPPFLAGS_opt = -O2
76LDFLAGS_opt =
77DEFINES_opt = NDEBUG
78
79VALID_CONFIG_dbg = 1
80CC_dbg = gcc
81CXX_dbg = g++
82LD_dbg = gcc
83LDXX_dbg = g++
84CPPFLAGS_dbg = -O0
85LDFLAGS_dbg =
86DEFINES_dbg = _DEBUG DEBUG
87
Craig Tillerec0b8f32015-01-15 07:30:00 -080088VALID_CONFIG_valgrind = 1
Craig Tillerc4da6b72015-01-15 08:01:14 -080089REQUIRE_CUSTOM_LIBRARIES_valgrind = 1
Craig Tillerec0b8f32015-01-15 07:30:00 -080090CC_valgrind = gcc
91CXX_valgrind = g++
92LD_valgrind = gcc
93LDXX_valgrind = g++
94CPPFLAGS_valgrind = -O0
95OPENSSL_CFLAGS_valgrind = -DPURIFY
96LDFLAGS_valgrind =
97DEFINES_valgrind = _DEBUG DEBUG
98
ctiller8cfebb92015-01-06 15:02:12 -080099VALID_CONFIG_tsan = 1
Craig Tillerc4da6b72015-01-15 08:01:14 -0800100REQUIRE_CUSTOM_LIBRARIES_tsan = 1
ctiller8cfebb92015-01-06 15:02:12 -0800101CC_tsan = clang
102CXX_tsan = clang++
103LD_tsan = clang
104LDXX_tsan = clang++
105CPPFLAGS_tsan = -O1 -fsanitize=thread -fno-omit-frame-pointer
106LDFLAGS_tsan = -fsanitize=thread
107DEFINES_tsan = NDEBUG
108
109VALID_CONFIG_asan = 1
Craig Tillerc4da6b72015-01-15 08:01:14 -0800110REQUIRE_CUSTOM_LIBRARIES_asan = 1
ctiller8cfebb92015-01-06 15:02:12 -0800111CC_asan = clang
112CXX_asan = clang++
113LD_asan = clang
114LDXX_asan = clang++
115CPPFLAGS_asan = -O1 -fsanitize=address -fno-omit-frame-pointer
116LDFLAGS_asan = -fsanitize=address
117DEFINES_asan = NDEBUG
118
119VALID_CONFIG_msan = 1
Craig Tillerc4da6b72015-01-15 08:01:14 -0800120REQUIRE_CUSTOM_LIBRARIES_msan = 1
ctiller8cfebb92015-01-06 15:02:12 -0800121CC_msan = clang
Nicolas "Pixel" Nobled66cba22015-02-14 02:59:12 +0100122CXX_msan = clang++-libc++
ctiller8cfebb92015-01-06 15:02:12 -0800123LD_msan = clang
Nicolas "Pixel" Nobled66cba22015-02-14 02:59:12 +0100124LDXX_msan = clang++-libc++
Craig Tilleracd62292015-02-16 11:12:28 -0800125CPPFLAGS_msan = -O1 -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 -0800126OPENSSL_CFLAGS_msan = -DPURIFY
Nicolas "Pixel" Nobled66cba22015-02-14 02:59:12 +0100127LDFLAGS_msan = -fsanitize=memory -DGTEST_HAS_TR1_TUPLE=0 -DGTEST_USE_OWN_TR1_TUPLE=1
ctiller8cfebb92015-01-06 15:02:12 -0800128DEFINES_msan = NDEBUG
129
Craig Tiller96bd5f62015-02-13 09:04:13 -0800130VALID_CONFIG_ubsan = 1
131REQUIRE_CUSTOM_LIBRARIES_ubsan = 1
132CC_ubsan = clang
133CXX_ubsan = clang++
134LD_ubsan = clang
135LDXX_ubsan = clang++
136CPPFLAGS_ubsan = -O1 -fsanitize=undefined -fno-omit-frame-pointer
137OPENSSL_CFLAGS_ubsan = -DPURIFY
Craig Tiller96bd5f62015-02-13 09:04:13 -0800138LDFLAGS_ubsan = -fsanitize=undefined
139DEFINES_ubsan = NDEBUG
140
Craig Tiller699ba212015-01-13 17:02:20 -0800141VALID_CONFIG_gcov = 1
142CC_gcov = gcc
143CXX_gcov = g++
144LD_gcov = gcc
145LDXX_gcov = g++
146CPPFLAGS_gcov = -O0 -fprofile-arcs -ftest-coverage
147LDFLAGS_gcov = -fprofile-arcs -ftest-coverage
148DEFINES_gcov = NDEBUG
149
Nicolas Noble047b7272015-01-16 13:55:05 -0800150
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800151# General settings.
152# You may want to change these depending on your system.
153
154prefix ?= /usr/local
155
156PROTOC = protoc
yangg102e4fe2015-01-06 16:02:50 -0800157CONFIG ?= opt
ctiller8cfebb92015-01-06 15:02:12 -0800158CC = $(CC_$(CONFIG))
159CXX = $(CXX_$(CONFIG))
160LD = $(LD_$(CONFIG))
161LDXX = $(LDXX_$(CONFIG))
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800162AR = ar
163STRIP = strip --strip-unneeded
Nicolas "Pixel" Noble932d5d32015-02-21 02:15:34 +0100164INSTALL = install
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800165RM = rm -f
166
yangg102e4fe2015-01-06 16:02:50 -0800167ifndef VALID_CONFIG_$(CONFIG)
168$(error Invalid CONFIG value '$(CONFIG)')
169endif
170
Nicolas Noble047b7272015-01-16 13:55:05 -0800171
172# The HOST compiler settings are used to compile the protoc plugins.
173# In most cases, you won't have to change anything, but if you are
174# cross-compiling, you can override these variables from GNU make's
175# command line: make CC=cross-gcc HOST_CC=gcc
176
nnoble72309c62014-12-12 11:42:26 -0800177HOST_CC = $(CC)
178HOST_CXX = $(CXX)
179HOST_LD = $(LD)
180HOST_LDXX = $(LDXX)
181
ctillercab52e72015-01-06 13:10:23 -0800182CPPFLAGS += $(CPPFLAGS_$(CONFIG))
Nicolas "Pixel" Noble72743822015-02-20 20:59:29 +0100183DEFINES += $(DEFINES_$(CONFIG)) INSTALL_PREFIX=\"$(prefix)\"
ctiller8cfebb92015-01-06 15:02:12 -0800184LDFLAGS += $(LDFLAGS_$(CONFIG))
ctillercab52e72015-01-06 13:10:23 -0800185
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800186CFLAGS += -std=c89 -pedantic
187CXXFLAGS += -std=c++11
Nicolas "Pixel" Noble213ed912015-01-30 02:11:35 +0100188CPPFLAGS += -g -fPIC -Wall -Wextra -Werror -Wno-long-long -Wno-unused-parameter
Craig Tiller96b49552015-01-21 16:29:01 -0800189LDFLAGS += -g -fPIC
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800190
Craig Tillerda224d62015-02-15 11:01:58 -0800191INCLUDES = . include $(GENDIR)
Craig Tiller96b49552015-01-21 16:29:01 -0800192ifeq ($(SYSTEM),Darwin)
vjpai7cc2c302015-02-18 12:33:37 -0800193INCLUDES += /usr/local/ssl/include /opt/local/include
Craig Tiller96b49552015-01-21 16:29:01 -0800194LIBS = m z
vjpai7cc2c302015-02-18 12:33:37 -0800195LDFLAGS += -L/usr/local/ssl/lib -L/opt/local/lib
Craig Tiller96b49552015-01-21 16:29:01 -0800196else
ctillerc008ae52015-01-07 15:33:00 -0800197LIBS = rt m z pthread
Craig Tiller96b49552015-01-21 16:29:01 -0800198LDFLAGS += -pthread
199endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800200
201ifneq ($(wildcard /usr/src/gtest/src/gtest-all.cc),)
202GTEST_LIB = /usr/src/gtest/src/gtest-all.cc -I/usr/src/gtest
203else
204GTEST_LIB = -lgtest
205endif
chenwa8fd44a2014-12-10 15:13:55 -0800206GTEST_LIB += -lgflags
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800207ifeq ($(V),1)
208E = @:
209Q =
210else
211E = @echo
212Q = @
213endif
214
215VERSION = ${settings.version.major}.${settings.version.minor}.${settings.version.micro}.${settings.version.build}
216
217CPPFLAGS_NO_ARCH += $(addprefix -I, $(INCLUDES)) $(addprefix -D, $(DEFINES))
218CPPFLAGS += $(CPPFLAGS_NO_ARCH) $(ARCH_FLAGS)
219
220LDFLAGS += $(ARCH_FLAGS)
221LDLIBS += $(addprefix -l, $(LIBS))
222LDLIBSXX += $(addprefix -l, $(LIBSXX))
nnoble72309c62014-12-12 11:42:26 -0800223
224HOST_CPPFLAGS = $(CPPFLAGS)
225HOST_CFLAGS = $(CFLAGS)
226HOST_CXXFLAGS = $(CXXFLAGS)
227HOST_LDFLAGS = $(LDFLAGS)
228HOST_LDLIBS = $(LDLIBS)
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800229
nnoble69ac39f2014-12-12 15:43:38 -0800230
231# These are automatically computed variables.
232# There shouldn't be any need to change anything from now on.
233
nnoble5b7f32a2014-12-22 08:12:44 -0800234ifeq ($(SYSTEM),MINGW32)
235SHARED_EXT = dll
236endif
237ifeq ($(SYSTEM),Darwin)
238SHARED_EXT = dylib
239endif
240ifeq ($(SHARED_EXT),)
241SHARED_EXT = so.$(VERSION)
242endif
243
nnoble69ac39f2014-12-12 15:43:38 -0800244ifeq ($(wildcard .git),)
245IS_GIT_FOLDER = false
246else
247IS_GIT_FOLDER = true
248endif
249
nnoble7e012cf2014-12-22 17:53:44 -0800250OPENSSL_ALPN_CHECK_CMD = $(CC) $(CFLAGS) $(CPPFLAGS) -o /dev/null test/build/openssl-alpn.c -lssl -lcrypto -ldl $(LDFLAGS)
251ZLIB_CHECK_CMD = $(CC) $(CFLAGS) $(CPPFLAGS) -o /dev/null test/build/zlib.c -lz $(LDFLAGS)
Craig Tiller297fafa2015-01-15 15:46:39 -0800252PERFTOOLS_CHECK_CMD = $(CC) $(CFLAGS) $(CPPFLAGS) -o /dev/null test/build/perftools.c -lprofiler $(LDFLAGS)
Nicolas Noble53830622015-02-12 16:56:38 -0800253PROTOBUF_CHECK_CMD = $(CXX) $(CXXFLAGS) $(CPPFLAGS) -o /dev/null test/build/protobuf.cc -lprotobuf $(LDFLAGS)
254PROTOC_CHECK_CMD = protoc --version | grep -q libprotoc.3
Craig Tiller297fafa2015-01-15 15:46:39 -0800255
Craig Tiller50524cc2015-01-29 23:00:00 -0800256ifndef REQUIRE_CUSTOM_LIBRARIES_$(CONFIG)
Craig Tiller297fafa2015-01-15 15:46:39 -0800257HAS_SYSTEM_PERFTOOLS = $(shell $(PERFTOOLS_CHECK_CMD) 2> /dev/null && echo true || echo false)
258ifeq ($(HAS_SYSTEM_PERFTOOLS),true)
259DEFINES += GRPC_HAVE_PERFTOOLS
260LIBS += profiler
261endif
Craig Tiller50524cc2015-01-29 23:00:00 -0800262endif
nnoble69ac39f2014-12-12 15:43:38 -0800263
Craig Tillerc4da6b72015-01-15 08:01:14 -0800264ifndef REQUIRE_CUSTOM_LIBRARIES_$(CONFIG)
nnoble60825402014-12-15 14:43:51 -0800265HAS_SYSTEM_OPENSSL_ALPN = $(shell $(OPENSSL_ALPN_CHECK_CMD) 2> /dev/null && echo true || echo false)
266HAS_SYSTEM_ZLIB = $(shell $(ZLIB_CHECK_CMD) 2> /dev/null && echo true || echo false)
Nicolas Noble53830622015-02-12 16:56:38 -0800267HAS_SYSTEM_PROTOBUF = $(shell $(PROTOBUF_CHECK_CMD) 2> /dev/null && echo true || echo false)
Craig Tillerc4da6b72015-01-15 08:01:14 -0800268else
269# override system libraries if the config requires a custom compiled library
270HAS_SYSTEM_OPENSSL_ALPN = false
271HAS_SYSTEM_ZLIB = false
Nicolas Noble53830622015-02-12 16:56:38 -0800272HAS_SYSTEM_PROTOBUF = false
Craig Tillerc4da6b72015-01-15 08:01:14 -0800273endif
nnoble69ac39f2014-12-12 15:43:38 -0800274
Nicolas Noble53830622015-02-12 16:56:38 -0800275HAS_VALID_PROTOC = $(shell $(PROTOC_CHECK_CMD) 2> /dev/null && echo true || echo false)
276
nnoble69ac39f2014-12-12 15:43:38 -0800277ifeq ($(wildcard third_party/openssl/ssl/ssl.h),)
278HAS_EMBEDDED_OPENSSL_ALPN = false
279else
280HAS_EMBEDDED_OPENSSL_ALPN = true
281endif
282
283ifeq ($(wildcard third_party/zlib/zlib.h),)
284HAS_EMBEDDED_ZLIB = false
285else
286HAS_EMBEDDED_ZLIB = true
287endif
288
Nicolas Noble53830622015-02-12 16:56:38 -0800289ifeq ($(wildcard third_party/protobuf/src/google/protobuf/descriptor.pb.h),)
290HAS_EMBEDDED_PROTOBUF = false
291ifneq ($(HAS_VALID_PROTOC),true)
292NO_PROTOC = true
293endif
294else
295HAS_EMBEDDED_PROTOBUF = true
296endif
297
nnoble69ac39f2014-12-12 15:43:38 -0800298ifeq ($(HAS_SYSTEM_ZLIB),false)
299ifeq ($(HAS_EMBEDDED_ZLIB),true)
Craig Tiller61b910f2015-02-15 10:54:07 -0800300ZLIB_DEP = $(LIBDIR)/$(CONFIG)/zlib/libz.a
nnoble69ac39f2014-12-12 15:43:38 -0800301CPPFLAGS += -Ithird_party/zlib
Craig Tillerda224d62015-02-15 11:01:58 -0800302LDFLAGS += -L$(LIBDIR)/$(CONFIG)/zlib
nnoble69ac39f2014-12-12 15:43:38 -0800303else
304DEP_MISSING += zlib
305endif
306endif
307
308ifeq ($(HAS_SYSTEM_OPENSSL_ALPN),false)
309ifeq ($(HAS_EMBEDDED_OPENSSL_ALPN),true)
Craig Tiller61b910f2015-02-15 10:54:07 -0800310OPENSSL_DEP = $(LIBDIR)/$(CONFIG)/openssl/libssl.a
311OPENSSL_MERGE_LIBS += $(LIBDIR)/$(CONFIG)/openssl/libssl.a $(LIBDIR)/$(CONFIG)/openssl/libcrypto.a
nnoble69ac39f2014-12-12 15:43:38 -0800312CPPFLAGS += -Ithird_party/openssl/include
Craig Tillerda224d62015-02-15 11:01:58 -0800313LDFLAGS += -L$(LIBDIR)/$(CONFIG)/openssl
nnoble5b7f32a2014-12-22 08:12:44 -0800314LIBS_SECURE = dl
nnoble69ac39f2014-12-12 15:43:38 -0800315else
316NO_SECURE = true
317endif
nnoble5b7f32a2014-12-22 08:12:44 -0800318else
319LIBS_SECURE = ssl crypto dl
nnoble69ac39f2014-12-12 15:43:38 -0800320endif
321
nnoble5b7f32a2014-12-22 08:12:44 -0800322LDLIBS_SECURE += $(addprefix -l, $(LIBS_SECURE))
323
Nicolas Noble53830622015-02-12 16:56:38 -0800324ifeq ($(HAS_SYSTEM_PROTOBUF),false)
325ifeq ($(HAS_EMBEDDED_PROTOBUF),true)
Craig Tiller61b910f2015-02-15 10:54:07 -0800326PROTOBUF_DEP = $(LIBDIR)/$(CONFIG)/protobuf/libprotobuf.a
Nicolas Noble53830622015-02-12 16:56:38 -0800327CPPFLAGS += -Ithird_party/protobuf/src
Craig Tillerda224d62015-02-15 11:01:58 -0800328LDFLAGS += -L$(LIBDIR)/$(CONFIG)/protobuf
Craig Tiller61b910f2015-02-15 10:54:07 -0800329PROTOC = $(BINDIR)/$(CONFIG)/protobuf/protoc
Nicolas Noble53830622015-02-12 16:56:38 -0800330else
331NO_PROTOBUF = true
332endif
333else
334endif
335
336LIBS_PROTOBUF = protobuf
337LIBS_PROTOC = protoc protobuf
338
339LDLIBS_PROTOBUF += $(addprefix -l, $(LIBS_PROTOBUF))
340HOST_LDLIBS_PROTOC += $(addprefix -l, $(LIBS_PROTOC))
341
Craig Tiller12c82092015-01-15 08:45:56 -0800342ifeq ($(MAKECMDGOALS),clean)
nnoble69ac39f2014-12-12 15:43:38 -0800343NO_DEPS = true
344endif
345
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800346.SECONDARY = %.pb.h %.pb.cc
347
Nicolas "Pixel" Noble522d7122015-02-19 01:28:02 +0100348PROTOC_PLUGINS =\
Craig Tillerf58b9ef2015-01-15 09:09:12 -0800349% for tgt in targets:
350% if tgt.build == 'protoc':
Craig Tiller61b910f2015-02-15 10:54:07 -0800351 $(BINDIR)/$(CONFIG)/${tgt.name}\
Craig Tillerf58b9ef2015-01-15 09:09:12 -0800352% endif
353% endfor
354
nnoble69ac39f2014-12-12 15:43:38 -0800355ifeq ($(DEP_MISSING),)
Nicolas "Pixel" Noble522d7122015-02-19 01:28:02 +0100356all: static shared plugins\
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800357% for tgt in targets:
358% if tgt.build == 'all':
Craig Tiller61b910f2015-02-15 10:54:07 -0800359 $(BINDIR)/$(CONFIG)/${tgt.name}\
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800360% endif
361% endfor
362
nnoble69ac39f2014-12-12 15:43:38 -0800363dep_error:
364 @echo "You shouldn't see this message - all of your dependencies are correct."
365else
366all: dep_error git_update stop
367
368dep_error:
369 @echo
370 @echo "DEPENDENCY ERROR"
371 @echo
372 @echo "You are missing system dependencies that are essential to build grpc,"
373 @echo "and the third_party directory doesn't have them:"
374 @echo
375 @echo " $(DEP_MISSING)"
376 @echo
377 @echo "Installing the development packages for your system will solve"
378 @echo "this issue. Please consult INSTALL to get more information."
379 @echo
380 @echo "If you need information about why these tests failed, run:"
381 @echo
382 @echo " make run_dep_checks"
383 @echo
384endif
385
386git_update:
387ifeq ($(IS_GIT_FOLDER),true)
388 @echo "Additionally, since you are in a git clone, you can download the"
389 @echo "missing dependencies in third_party by running the following command:"
390 @echo
ctiller64f29102014-12-15 10:40:59 -0800391 @echo " git submodule update --init"
nnoble69ac39f2014-12-12 15:43:38 -0800392 @echo
393endif
394
395openssl_dep_error: openssl_dep_message git_update stop
396
Nicolas Noble53830622015-02-12 16:56:38 -0800397protobuf_dep_error: protobuf_dep_message git_update stop
398
399protoc_dep_error: protoc_dep_message git_update stop
400
nnoble69ac39f2014-12-12 15:43:38 -0800401openssl_dep_message:
402 @echo
403 @echo "DEPENDENCY ERROR"
404 @echo
405 @echo "The target you are trying to run requires OpenSSL with ALPN support."
406 @echo "Your system doesn't have it, and neither does the third_party directory."
407 @echo
408 @echo "Please consult INSTALL to get more information."
409 @echo
410 @echo "If you need information about why these tests failed, run:"
411 @echo
412 @echo " make run_dep_checks"
413 @echo
414
Nicolas Noble53830622015-02-12 16:56:38 -0800415protobuf_dep_message:
416 @echo
417 @echo "DEPENDENCY ERROR"
418 @echo
419 @echo "The target you are trying to run requires protobuf 3.0.0+"
420 @echo "Your system doesn't have it, and neither does the third_party directory."
421 @echo
422 @echo "Please consult INSTALL to get more information."
423 @echo
424 @echo "If you need information about why these tests failed, run:"
425 @echo
426 @echo " make run_dep_checks"
427 @echo
428
429protoc_dep_message:
430 @echo
431 @echo "DEPENDENCY ERROR"
432 @echo
433 @echo "The target you are trying to run requires protobuf-compiler 3.0.0+"
434 @echo "Your system doesn't have it, and neither does the third_party directory."
435 @echo
436 @echo "Please consult INSTALL to get more information."
437 @echo
438 @echo "If you need information about why these tests failed, run:"
439 @echo
440 @echo " make run_dep_checks"
441 @echo
442
nnoble69ac39f2014-12-12 15:43:38 -0800443stop:
444 @false
445
ctiller09cb6d52014-12-19 17:38:22 -0800446% for tgt in targets:
Craig Tiller61b910f2015-02-15 10:54:07 -0800447${tgt.name}: $(BINDIR)/$(CONFIG)/${tgt.name}
ctiller09cb6d52014-12-19 17:38:22 -0800448% endfor
449
nnoble69ac39f2014-12-12 15:43:38 -0800450run_dep_checks:
nnoble69ac39f2014-12-12 15:43:38 -0800451 $(OPENSSL_ALPN_CHECK_CMD) || true
452 $(ZLIB_CHECK_CMD) || true
Nicolas Noble53830622015-02-12 16:56:38 -0800453 $(PERFTOOLS_CHECK_CMD) || true
454 $(PROTOBUF_CHECK_CMD) || true
455 $(PROTOC_CHECK_CMD) || true
nnoble69ac39f2014-12-12 15:43:38 -0800456
Craig Tiller61b910f2015-02-15 10:54:07 -0800457$(LIBDIR)/$(CONFIG)/zlib/libz.a:
Nicolas "Pixel" Noble17f2b592015-01-16 07:09:10 +0100458 $(E) "[MAKE] Building zlib"
459 $(Q)(cd third_party/zlib ; CC="$(CC)" CFLAGS="-fPIC -fvisibility=hidden $(CPPFLAGS_$(CONFIG))" ./configure --static)
460 $(Q)$(MAKE) -C third_party/zlib clean
461 $(Q)$(MAKE) -C third_party/zlib
Craig Tiller61b910f2015-02-15 10:54:07 -0800462 $(Q)mkdir -p $(LIBDIR)/$(CONFIG)/zlib
463 $(Q)cp third_party/zlib/libz.a $(LIBDIR)/$(CONFIG)/zlib
nnoble69ac39f2014-12-12 15:43:38 -0800464
Craig Tiller61b910f2015-02-15 10:54:07 -0800465$(LIBDIR)/$(CONFIG)/openssl/libssl.a:
Craig Tillerb4ee3b52015-01-21 16:22:50 -0800466 $(E) "[MAKE] Building openssl for $(SYSTEM)"
467ifeq ($(SYSTEM),Darwin)
Nicolas "Pixel" Noblee567fa92015-02-20 07:10:21 +0100468 $(Q)(cd third_party/openssl ; CC="$(CC) -fPIC -fvisibility=hidden $(CPPFLAGS_$(CONFIG)) $(OPENSSL_CFLAGS_$(CONFIG))" ./Configure darwin64-x86_64-cc)
Craig Tillerb4ee3b52015-01-21 16:22:50 -0800469else
Nicolas "Pixel" Noblee567fa92015-02-20 07:10:21 +0100470 $(Q)(cd third_party/openssl ; CC="$(CC) -fPIC -fvisibility=hidden $(CPPFLAGS_$(CONFIG)) $(OPENSSL_CFLAGS_$(CONFIG))" ./config no-asm $(OPENSSL_CONFIG_$(CONFIG)))
Craig Tillerb4ee3b52015-01-21 16:22:50 -0800471endif
Nicolas "Pixel" Noble17f2b592015-01-16 07:09:10 +0100472 $(Q)$(MAKE) -C third_party/openssl clean
473 $(Q)$(MAKE) -C third_party/openssl build_crypto build_ssl
Craig Tiller61b910f2015-02-15 10:54:07 -0800474 $(Q)mkdir -p $(LIBDIR)/$(CONFIG)/openssl
475 $(Q)cp third_party/openssl/libssl.a third_party/openssl/libcrypto.a $(LIBDIR)/$(CONFIG)/openssl
nnoble69ac39f2014-12-12 15:43:38 -0800476
Nicolas Noble53830622015-02-12 16:56:38 -0800477third_party/protobuf/configure:
478 $(E) "[AUTOGEN] Preparing protobuf"
479 $(Q)(cd third_party/protobuf ; autoreconf -f -i -Wall,no-obsolete)
480
Craig Tiller61b910f2015-02-15 10:54:07 -0800481$(LIBDIR)/$(CONFIG)/protobuf/libprotobuf.a: third_party/protobuf/configure
Nicolas Noble53830622015-02-12 16:56:38 -0800482 $(E) "[MAKE] Building protobuf"
483 $(Q)(cd third_party/protobuf ; CC="$(CC)" CXX="$(CXX)" LDFLAGS="$(LDFLAGS_$(CONFIG)) -g" CXXFLAGS="-DLANG_CXX11 -std=c++11" CPPFLAGS="$(CPPFLAGS_$(CONFIG)) -g" ./configure --disable-shared --enable-static)
484 $(Q)$(MAKE) -C third_party/protobuf clean
485 $(Q)$(MAKE) -C third_party/protobuf
Craig Tiller61b910f2015-02-15 10:54:07 -0800486 $(Q)mkdir -p $(LIBDIR)/$(CONFIG)/protobuf
487 $(Q)mkdir -p $(BINDIR)/$(CONFIG)/protobuf
488 $(Q)cp third_party/protobuf/src/.libs/libprotoc.a $(LIBDIR)/$(CONFIG)/protobuf
489 $(Q)cp third_party/protobuf/src/.libs/libprotobuf.a $(LIBDIR)/$(CONFIG)/protobuf
490 $(Q)cp third_party/protobuf/src/protoc $(BINDIR)/$(CONFIG)/protobuf
Nicolas Noble53830622015-02-12 16:56:38 -0800491
nnoble29e1d292014-12-01 10:27:40 -0800492static: static_c static_cxx
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800493
Craig Tiller12c82092015-01-15 08:45:56 -0800494static_c: \
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800495% for lib in libs:
Craig Tiller59140fc2015-01-18 10:12:17 -0800496% if lib.build == 'all' and lib.language == 'c':
Craig Tiller61b910f2015-02-15 10:54:07 -0800497 $(LIBDIR)/$(CONFIG)/lib${lib.name}.a\
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800498% endif
499% endfor
500
501
Craig Tiller12c82092015-01-15 08:45:56 -0800502static_cxx: \
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800503% for lib in libs:
Craig Tiller59140fc2015-01-18 10:12:17 -0800504% if lib.build == 'all' and lib.language == 'c++':
Craig Tiller61b910f2015-02-15 10:54:07 -0800505 $(LIBDIR)/$(CONFIG)/lib${lib.name}.a\
nnoble29e1d292014-12-01 10:27:40 -0800506% endif
507% endfor
508
509
510shared: shared_c shared_cxx
511
Craig Tiller12c82092015-01-15 08:45:56 -0800512shared_c: \
nnoble29e1d292014-12-01 10:27:40 -0800513% for lib in libs:
Craig Tiller59140fc2015-01-18 10:12:17 -0800514% if lib.build == 'all' and lib.language == 'c':
Craig Tiller61b910f2015-02-15 10:54:07 -0800515 $(LIBDIR)/$(CONFIG)/lib${lib.name}.$(SHARED_EXT)\
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800516% endif
517% endfor
518
519
Craig Tiller12c82092015-01-15 08:45:56 -0800520shared_cxx: \
nnoble29e1d292014-12-01 10:27:40 -0800521% for lib in libs:
Craig Tiller59140fc2015-01-18 10:12:17 -0800522% if lib.build == 'all' and lib.language == 'c++':
Craig Tiller61b910f2015-02-15 10:54:07 -0800523 $(LIBDIR)/$(CONFIG)/lib${lib.name}.$(SHARED_EXT)\
nnoble29e1d292014-12-01 10:27:40 -0800524% endif
525% endfor
526
527
Jan Tattermusch2ec0b3e2015-02-18 15:03:12 -0800528shared_csharp: shared_c \
529% for lib in libs:
530% if lib.build == 'all' and lib.language == 'csharp':
531 $(LIBDIR)/$(CONFIG)/lib${lib.name}.$(SHARED_EXT)\
532% endif
533% endfor
534
535grpc_csharp_ext: shared_csharp
536
Nicolas "Pixel" Noble522d7122015-02-19 01:28:02 +0100537plugins: $(PROTOC_PLUGINS)
538
nnoble29e1d292014-12-01 10:27:40 -0800539privatelibs: privatelibs_c privatelibs_cxx
540
Craig Tiller12c82092015-01-15 08:45:56 -0800541privatelibs_c: \
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800542% for lib in libs:
Craig Tiller59140fc2015-01-18 10:12:17 -0800543% if lib.build == 'private' and lib.language == 'c':
Craig Tiller61b910f2015-02-15 10:54:07 -0800544 $(LIBDIR)/$(CONFIG)/lib${lib.name}.a\
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800545% endif
546% endfor
547
548
Craig Tiller12c82092015-01-15 08:45:56 -0800549privatelibs_cxx: \
nnoble29e1d292014-12-01 10:27:40 -0800550% for lib in libs:
Craig Tiller59140fc2015-01-18 10:12:17 -0800551% if lib.build == 'private' and lib.language == 'c++':
Craig Tiller61b910f2015-02-15 10:54:07 -0800552 $(LIBDIR)/$(CONFIG)/lib${lib.name}.a\
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800553% endif
554% endfor
555
556
nnoble29e1d292014-12-01 10:27:40 -0800557buildtests: buildtests_c buildtests_cxx
558
Craig Tiller12c82092015-01-15 08:45:56 -0800559buildtests_c: privatelibs_c\
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800560% for tgt in targets:
Craig Tiller59140fc2015-01-18 10:12:17 -0800561% if tgt.build == 'test' and not tgt.language == 'c++':
Craig Tiller61b910f2015-02-15 10:54:07 -0800562 $(BINDIR)/$(CONFIG)/${tgt.name}\
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800563% endif
564% endfor
565
566
Craig Tiller12c82092015-01-15 08:45:56 -0800567buildtests_cxx: privatelibs_cxx\
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800568% for tgt in targets:
Craig Tiller59140fc2015-01-18 10:12:17 -0800569% if tgt.build == 'test' and tgt.language == 'c++':
Craig Tiller61b910f2015-02-15 10:54:07 -0800570 $(BINDIR)/$(CONFIG)/${tgt.name}\
nnoble29e1d292014-12-01 10:27:40 -0800571% endif
572% endfor
573
574
nnoble85a49262014-12-08 18:14:03 -0800575test: test_c test_cxx
nnoble29e1d292014-12-01 10:27:40 -0800576
nnoble85a49262014-12-08 18:14:03 -0800577test_c: buildtests_c
nnoble29e1d292014-12-01 10:27:40 -0800578% for tgt in targets:
Craig Tiller59140fc2015-01-18 10:12:17 -0800579% if tgt.build == 'test' and tgt.get('run', True) and not tgt.language == 'c++':
nnoble29e1d292014-12-01 10:27:40 -0800580 $(E) "[RUN] Testing ${tgt.name}"
Craig Tillerda224d62015-02-15 11:01:58 -0800581 $(Q) $(BINDIR)/$(CONFIG)/${tgt.name} || ( echo test ${tgt.name} failed ; exit 1 )
nnoble29e1d292014-12-01 10:27:40 -0800582% endif
583% endfor
584
585
nnoble85a49262014-12-08 18:14:03 -0800586test_cxx: buildtests_cxx
nnoble29e1d292014-12-01 10:27:40 -0800587% for tgt in targets:
Craig Tiller59140fc2015-01-18 10:12:17 -0800588% if tgt.build == 'test' and tgt.get('run', True) and tgt.language == 'c++':
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800589 $(E) "[RUN] Testing ${tgt.name}"
Craig Tillerda224d62015-02-15 11:01:58 -0800590 $(Q) $(BINDIR)/$(CONFIG)/${tgt.name} || ( echo test ${tgt.name} failed ; exit 1 )
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800591% endif
592% endfor
593
594
595tools: privatelibs\
596% for tgt in targets:
597% if tgt.build == 'tool':
Craig Tiller61b910f2015-02-15 10:54:07 -0800598 $(BINDIR)/$(CONFIG)/${tgt.name}\
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800599% endif
600% endfor
601
602
603buildbenchmarks: privatelibs\
604% for tgt in targets:
605% if tgt.build == 'benchmark':
Craig Tiller61b910f2015-02-15 10:54:07 -0800606 $(BINDIR)/$(CONFIG)/${tgt.name}\
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800607% endif
608% endfor
609
610
611benchmarks: buildbenchmarks
612
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800613strip: strip-static strip-shared
614
nnoble20e2e3f2014-12-16 15:37:57 -0800615strip-static: strip-static_c strip-static_cxx
616
617strip-shared: strip-shared_c strip-shared_cxx
618
Nicolas Noble047b7272015-01-16 13:55:05 -0800619
620# TODO(nnoble): the strip target is stripping in-place, instead
621# of copying files in a temporary folder.
622# This prevents proper debugging after running make install.
623
nnoble85a49262014-12-08 18:14:03 -0800624strip-static_c: static_c
Nicolas "Pixel" Noble3a2551c2015-01-29 21:33:32 +0100625ifeq ($(CONFIG),opt)
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800626% for lib in libs:
Craig Tiller59140fc2015-01-18 10:12:17 -0800627% if lib.language == "c":
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800628% if lib.build == "all":
629 $(E) "[STRIP] Stripping lib${lib.name}.a"
Craig Tiller61b910f2015-02-15 10:54:07 -0800630 $(Q) $(STRIP) $(LIBDIR)/$(CONFIG)/lib${lib.name}.a
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800631% endif
nnoble85a49262014-12-08 18:14:03 -0800632% endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800633% endfor
Nicolas "Pixel" Noble3a2551c2015-01-29 21:33:32 +0100634endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800635
nnoble85a49262014-12-08 18:14:03 -0800636strip-static_cxx: static_cxx
Nicolas "Pixel" Noble3a2551c2015-01-29 21:33:32 +0100637ifeq ($(CONFIG),opt)
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800638% for lib in libs:
Craig Tiller59140fc2015-01-18 10:12:17 -0800639% if lib.language == "c++":
nnoble85a49262014-12-08 18:14:03 -0800640% if lib.build == "all":
641 $(E) "[STRIP] Stripping lib${lib.name}.a"
Craig Tiller61b910f2015-02-15 10:54:07 -0800642 $(Q) $(STRIP) $(LIBDIR)/$(CONFIG)/lib${lib.name}.a
nnoble85a49262014-12-08 18:14:03 -0800643% endif
644% endif
645% endfor
Nicolas "Pixel" Noble3a2551c2015-01-29 21:33:32 +0100646endif
nnoble85a49262014-12-08 18:14:03 -0800647
648strip-shared_c: shared_c
Nicolas "Pixel" Noble3a2551c2015-01-29 21:33:32 +0100649ifeq ($(CONFIG),opt)
nnoble85a49262014-12-08 18:14:03 -0800650% for lib in libs:
Craig Tiller59140fc2015-01-18 10:12:17 -0800651% if lib.language == "c":
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800652% if lib.build == "all":
653 $(E) "[STRIP] Stripping lib${lib.name}.so"
Craig Tiller61b910f2015-02-15 10:54:07 -0800654 $(Q) $(STRIP) $(LIBDIR)/$(CONFIG)/lib${lib.name}.$(SHARED_EXT)
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800655% endif
nnoble85a49262014-12-08 18:14:03 -0800656% endif
657% endfor
Nicolas "Pixel" Noble3a2551c2015-01-29 21:33:32 +0100658endif
nnoble85a49262014-12-08 18:14:03 -0800659
660strip-shared_cxx: shared_cxx
Nicolas "Pixel" Noble3a2551c2015-01-29 21:33:32 +0100661ifeq ($(CONFIG),opt)
nnoble85a49262014-12-08 18:14:03 -0800662% for lib in libs:
Craig Tiller59140fc2015-01-18 10:12:17 -0800663% if lib.language == "c++":
nnoble85a49262014-12-08 18:14:03 -0800664% if lib.build == "all":
665 $(E) "[STRIP] Stripping lib${lib.name}.so"
Craig Tiller61b910f2015-02-15 10:54:07 -0800666 $(Q) $(STRIP) $(LIBDIR)/$(CONFIG)/lib${lib.name}.$(SHARED_EXT)
nnoble85a49262014-12-08 18:14:03 -0800667% endif
668% endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800669% endfor
Nicolas "Pixel" Noble3a2551c2015-01-29 21:33:32 +0100670endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800671
Jan Tattermusch2ec0b3e2015-02-18 15:03:12 -0800672strip-shared_csharp: shared_csharp
673ifeq ($(CONFIG),opt)
674% for lib in libs:
675% if lib.language == "csharp":
676% if lib.build == "all":
677 $(E) "[STRIP] Stripping lib${lib.name}.so"
678 $(Q) $(STRIP) $(LIBDIR)/$(CONFIG)/lib${lib.name}.$(SHARED_EXT)
679% endif
680% endif
681% endfor
682endif
683
nnoble72309c62014-12-12 11:42:26 -0800684% for p in protos:
Nicolas Noble53830622015-02-12 16:56:38 -0800685ifeq ($(NO_PROTOC),true)
Craig Tiller61b910f2015-02-15 10:54:07 -0800686$(GENDIR)/${p}.pb.cc: protoc_dep_error
Nicolas Noble53830622015-02-12 16:56:38 -0800687else
Craig Tiller61b910f2015-02-15 10:54:07 -0800688$(GENDIR)/${p}.pb.cc: ${p}.proto $(PROTOBUF_DEP) $(PROTOC_PLUGINS)
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800689 $(E) "[PROTOC] Generating protobuf CC file from $<"
690 $(Q) mkdir -p `dirname $@`
Vijay Pai850290f2015-02-19 09:59:44 -0800691 $(Q) $(PROTOC) --cpp_out=$(GENDIR) --grpc_out=$(GENDIR) --plugin=protoc-gen-grpc=$(BINDIR)/$(CONFIG)/grpc_cpp_plugin $<
Nicolas Noble53830622015-02-12 16:56:38 -0800692endif
nnoble72309c62014-12-12 11:42:26 -0800693
694% endfor
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800695
Craig Tiller61b910f2015-02-15 10:54:07 -0800696$(OBJDIR)/$(CONFIG)/%.o : %.c
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800697 $(E) "[C] Compiling $<"
698 $(Q) mkdir -p `dirname $@`
Craig Tiller12c82092015-01-15 08:45:56 -0800699 $(Q) $(CC) $(CFLAGS) $(CPPFLAGS) -MMD -MF $(addsuffix .dep, $(basename $@)) -c -o $@ $<
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800700
Craig Tiller61b910f2015-02-15 10:54:07 -0800701$(OBJDIR)/$(CONFIG)/%.o : $(GENDIR)/%.pb.cc
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800702 $(E) "[CXX] Compiling $<"
703 $(Q) mkdir -p `dirname $@`
Craig Tiller12c82092015-01-15 08:45:56 -0800704 $(Q) $(CXX) $(CXXFLAGS) $(CPPFLAGS) -MMD -MF $(addsuffix .dep, $(basename $@)) -c -o $@ $<
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800705
Craig Tiller61b910f2015-02-15 10:54:07 -0800706$(OBJDIR)/$(CONFIG)/src/compiler/%.o : src/compiler/%.cc
nnoble72309c62014-12-12 11:42:26 -0800707 $(E) "[HOSTCXX] Compiling $<"
708 $(Q) mkdir -p `dirname $@`
Craig Tiller12c82092015-01-15 08:45:56 -0800709 $(Q) $(HOST_CXX) $(HOST_CXXFLAGS) $(HOST_CPPFLAGS) -MMD -MF $(addsuffix .dep, $(basename $@)) -c -o $@ $<
nnoble72309c62014-12-12 11:42:26 -0800710
Craig Tiller61b910f2015-02-15 10:54:07 -0800711$(OBJDIR)/$(CONFIG)/%.o : %.cc
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800712 $(E) "[CXX] Compiling $<"
713 $(Q) mkdir -p `dirname $@`
Craig Tiller12c82092015-01-15 08:45:56 -0800714 $(Q) $(CXX) $(CXXFLAGS) $(CPPFLAGS) -MMD -MF $(addsuffix .dep, $(basename $@)) -c -o $@ $<
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800715
716
Nicolas "Pixel" Noble522d7122015-02-19 01:28:02 +0100717install: install_c install_cxx install-protobuf install-plugins
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800718
nnoble85a49262014-12-08 18:14:03 -0800719install_c: install-headers_c install-static_c install-shared_c
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800720
nnoble85a49262014-12-08 18:14:03 -0800721install_cxx: install-headers_cxx install-static_cxx install-shared_cxx
722
Jan Tattermusch2ec0b3e2015-02-18 15:03:12 -0800723install_csharp: install-shared_csharp install_c
724
725install_grpc_csharp_ext: install_csharp
726
nnoble85a49262014-12-08 18:14:03 -0800727install-headers: install-headers_c install-headers_cxx
728
729install-headers_c:
730 $(E) "[INSTALL] Installing public C headers"
Nicolas "Pixel" Noble932d5d32015-02-21 02:15:34 +0100731 $(Q) $(foreach h, $(PUBLIC_HEADERS_C), $(INSTALL) -d $(prefix)/$(dir $(h)) && ) exit 0 || exit 1
nnoble85a49262014-12-08 18:14:03 -0800732 $(Q) $(foreach h, $(PUBLIC_HEADERS_C), $(INSTALL) $(h) $(prefix)/$(h) && ) exit 0 || exit 1
733
734install-headers_cxx:
735 $(E) "[INSTALL] Installing public C++ headers"
Nicolas "Pixel" Noble932d5d32015-02-21 02:15:34 +0100736 $(Q) $(foreach h, $(PUBLIC_HEADERS_CXX), $(INSTALL) -d $(prefix)/$(dir $(h)) && ) exit 0 || exit 1
nnoble85a49262014-12-08 18:14:03 -0800737 $(Q) $(foreach h, $(PUBLIC_HEADERS_CXX), $(INSTALL) $(h) $(prefix)/$(h) && ) exit 0 || exit 1
738
739install-static: install-static_c install-static_cxx
740
741install-static_c: static_c strip-static_c
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800742% for lib in libs:
Craig Tiller59140fc2015-01-18 10:12:17 -0800743% if lib.language == "c":
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800744% if lib.build == "all":
745 $(E) "[INSTALL] Installing lib${lib.name}.a"
Nicolas "Pixel" Noble932d5d32015-02-21 02:15:34 +0100746 $(Q) $(INSTALL) -d $(prefix)/lib
Craig Tiller61b910f2015-02-15 10:54:07 -0800747 $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/lib${lib.name}.a $(prefix)/lib/lib${lib.name}.a
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800748% endif
nnoble85a49262014-12-08 18:14:03 -0800749% endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800750% endfor
751
nnoble85a49262014-12-08 18:14:03 -0800752install-static_cxx: static_cxx strip-static_cxx
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800753% for lib in libs:
Craig Tiller59140fc2015-01-18 10:12:17 -0800754% if lib.language == "c++":
nnoble85a49262014-12-08 18:14:03 -0800755% if lib.build == "all":
756 $(E) "[INSTALL] Installing lib${lib.name}.a"
Nicolas "Pixel" Noble932d5d32015-02-21 02:15:34 +0100757 $(Q) $(INSTALL) -d $(prefix)/lib
Craig Tiller61b910f2015-02-15 10:54:07 -0800758 $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/lib${lib.name}.a $(prefix)/lib/lib${lib.name}.a
nnoble85a49262014-12-08 18:14:03 -0800759% endif
760% endif
761% endfor
762
Nicolas "Pixel" Noble522d7122015-02-19 01:28:02 +0100763<%def name="install_shared(lang_filter)">\
nnoble85a49262014-12-08 18:14:03 -0800764% for lib in libs:
Nicolas "Pixel" Noble522d7122015-02-19 01:28:02 +0100765% if lib.language == lang_filter:
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800766% if lib.build == "all":
nnoble5b7f32a2014-12-22 08:12:44 -0800767ifeq ($(SYSTEM),MINGW32)
768 $(E) "[INSTALL] Installing ${lib.name}.$(SHARED_EXT)"
Nicolas "Pixel" Noble932d5d32015-02-21 02:15:34 +0100769 $(Q) $(INSTALL) -d $(prefix)/lib
Craig Tiller61b910f2015-02-15 10:54:07 -0800770 $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/${lib.name}.$(SHARED_EXT) $(prefix)/lib/${lib.name}.$(SHARED_EXT)
771 $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/lib${lib.name}-imp.a $(prefix)/lib/lib${lib.name}-imp.a
nnoble5b7f32a2014-12-22 08:12:44 -0800772else
773 $(E) "[INSTALL] Installing lib${lib.name}.$(SHARED_EXT)"
Nicolas "Pixel" Noble932d5d32015-02-21 02:15:34 +0100774 $(Q) $(INSTALL) -d $(prefix)/lib
Craig Tiller61b910f2015-02-15 10:54:07 -0800775 $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/lib${lib.name}.$(SHARED_EXT) $(prefix)/lib/lib${lib.name}.$(SHARED_EXT)
nnoble5b7f32a2014-12-22 08:12:44 -0800776ifneq ($(SYSTEM),Darwin)
777 $(Q) ln -sf lib${lib.name}.$(SHARED_EXT) $(prefix)/lib/lib${lib.name}.so
778endif
779endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800780% endif
nnoble85a49262014-12-08 18:14:03 -0800781% endif
782% endfor
nnoble5b7f32a2014-12-22 08:12:44 -0800783ifneq ($(SYSTEM),MINGW32)
784ifneq ($(SYSTEM),Darwin)
Nicolas "Pixel" Noblecc2b42a2015-02-20 00:42:21 +0100785 $(Q) ldconfig || true
nnoble5b7f32a2014-12-22 08:12:44 -0800786endif
787endif
Nicolas "Pixel" Noble522d7122015-02-19 01:28:02 +0100788</%def>
nnoble85a49262014-12-08 18:14:03 -0800789
Nicolas "Pixel" Noble522d7122015-02-19 01:28:02 +0100790install-shared_c: shared_c strip-shared_c
791${install_shared("c")}
792
793install-shared_cxx: shared_cxx strip-shared_cxx install-shared_c
794${install_shared("c++")}
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800795
Jan Tattermusch2ec0b3e2015-02-18 15:03:12 -0800796install-shared_csharp: shared_csharp strip-shared_csharp
Nicolas "Pixel" Noble522d7122015-02-19 01:28:02 +0100797${install_shared("csharp")}
798
799install-protobuf: $(PROTOBUF_DEP)
800ifneq ($(PROTOBUF_DEP),)
801 $(E) "[INSTALL] Installing embedded protobufs"
802 $(Q) $(MAKE) -C third_party/protobuf install prefix=$(prefix)
Jan Tattermusch2ec0b3e2015-02-18 15:03:12 -0800803ifneq ($(SYSTEM),MINGW32)
804ifneq ($(SYSTEM),Darwin)
Nicolas "Pixel" Noblecc2b42a2015-02-20 00:42:21 +0100805 $(Q) ldconfig || true
Jan Tattermusch2ec0b3e2015-02-18 15:03:12 -0800806endif
807endif
Nicolas "Pixel" Noble522d7122015-02-19 01:28:02 +0100808endif
809
810install-plugins: $(PROTOC_PLUGINS)
811ifeq ($(SYSTEM),MINGW32)
812 $(Q) false
813else
814 $(E) "[INSTALL] Installing grpc protoc plugins"
815% for tgt in targets:
816% if tgt.build == 'protoc':
Nicolas "Pixel" Noble932d5d32015-02-21 02:15:34 +0100817 $(Q) $(INSTALL) -d $(prefix)/bin
Nicolas "Pixel" Noble522d7122015-02-19 01:28:02 +0100818 $(Q) $(INSTALL) $(BINDIR)/$(CONFIG)/${tgt.name} $(prefix)/bin/${tgt.name}
819% endif
820% endfor
821endif
Jan Tattermusch2ec0b3e2015-02-18 15:03:12 -0800822
Craig Tiller3759e6f2015-01-15 08:13:11 -0800823clean:
Nicolas "Pixel" Noble522d7122015-02-19 01:28:02 +0100824 $(E) "[CLEAN] Cleaning build directories."
Craig Tillerda224d62015-02-15 11:01:58 -0800825 $(Q) $(RM) -rf $(OBJDIR) $(LIBDIR) $(BINDIR) $(GENDIR)
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800826
827
828# The various libraries
829
830% for lib in libs:
831${makelib(lib)}
832% endfor
833
834
nnoble69ac39f2014-12-12 15:43:38 -0800835# All of the test targets, and protoc plugins
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800836
837% for tgt in targets:
838${maketarget(tgt)}
839% endfor
840
841<%def name="makelib(lib)">
842LIB${lib.name.upper()}_SRC = \\
843
844% for src in lib.src:
nnoble72309c62014-12-12 11:42:26 -0800845 ${proto_to_cc(src)} \\
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800846
847% endfor
848
849% if "public_headers" in lib:
Craig Tiller59140fc2015-01-18 10:12:17 -0800850% if lib.language == "c++":
nnoble85a49262014-12-08 18:14:03 -0800851PUBLIC_HEADERS_CXX += \\
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800852
nnoble85a49262014-12-08 18:14:03 -0800853% else:
854PUBLIC_HEADERS_C += \\
855
856% endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800857% for hdr in lib.public_headers:
858 ${hdr} \\
859
860% endfor
861% endif
862
Craig Tiller61b910f2015-02-15 10:54:07 -0800863LIB${lib.name.upper()}_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(LIB${lib.name.upper()}_SRC))))
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800864
Nicolas Noble047b7272015-01-16 13:55:05 -0800865## If the library requires OpenSSL with ALPN, let's add some restrictions.
nnoble69ac39f2014-12-12 15:43:38 -0800866% if lib.get('secure', True):
nnoble69ac39f2014-12-12 15:43:38 -0800867ifeq ($(NO_SECURE),true)
868
Nicolas Noble047b7272015-01-16 13:55:05 -0800869# You can't build secure libraries if you don't have OpenSSL with ALPN.
870
Craig Tiller61b910f2015-02-15 10:54:07 -0800871$(LIBDIR)/$(CONFIG)/lib${lib.name}.a: openssl_dep_error
nnoble69ac39f2014-12-12 15:43:38 -0800872
nnoble5b7f32a2014-12-22 08:12:44 -0800873% if lib.build == "all":
874ifeq ($(SYSTEM),MINGW32)
Craig Tiller61b910f2015-02-15 10:54:07 -0800875$(LIBDIR)/$(CONFIG)/${lib.name}.$(SHARED_EXT): openssl_dep_error
nnoble5b7f32a2014-12-22 08:12:44 -0800876else
Craig Tiller61b910f2015-02-15 10:54:07 -0800877$(LIBDIR)/$(CONFIG)/lib${lib.name}.$(SHARED_EXT): openssl_dep_error
nnoble5b7f32a2014-12-22 08:12:44 -0800878endif
879% endif
880
nnoble69ac39f2014-12-12 15:43:38 -0800881else
882
Nicolas Noble53830622015-02-12 16:56:38 -0800883% if lib.language == 'c++':
884ifeq ($(NO_PROTOBUF),true)
885
886# You can't build a C++ library if you don't have protobuf - a bit overreached, but still okay.
887
Craig Tiller61b910f2015-02-15 10:54:07 -0800888$(LIBDIR)/$(CONFIG)/lib${lib.name}.a: protobuf_dep_error
Nicolas Noble53830622015-02-12 16:56:38 -0800889
890% if lib.build == "all":
891ifeq ($(SYSTEM),MINGW32)
Craig Tiller61b910f2015-02-15 10:54:07 -0800892$(LIBDIR)/$(CONFIG)/${lib.name}.$(SHARED_EXT): protobuf_dep_error
Nicolas Noble53830622015-02-12 16:56:38 -0800893else
Craig Tiller61b910f2015-02-15 10:54:07 -0800894$(LIBDIR)/$(CONFIG)/lib${lib.name}.$(SHARED_EXT): protobuf_dep_error
Nicolas Noble53830622015-02-12 16:56:38 -0800895endif
896% endif
897
898else
899% endif
900
Nicolas "Pixel" Noble17f2b592015-01-16 07:09:10 +0100901ifneq ($(OPENSSL_DEP),)
Nicolas Noble53830622015-02-12 16:56:38 -0800902# This is to ensure the embedded OpenSSL is built beforehand, properly
903# installing headers to their final destination on the drive. We need this
904# otherwise parallel compilation will fail if a source is compiled first.
Nicolas "Pixel" Noble17f2b592015-01-16 07:09:10 +0100905% for src in lib.src:
906${src}: $(OPENSSL_DEP)
907% endfor
908endif
909
Craig Tiller61b910f2015-02-15 10:54:07 -0800910$(LIBDIR)/$(CONFIG)/lib${lib.name}.a: $(ZLIB_DEP) $(OPENSSL_DEP)\
Nicolas Noble047b7272015-01-16 13:55:05 -0800911## The else here corresponds to the if secure earlier.
nnoble20e2e3f2014-12-16 15:37:57 -0800912% else:
Nicolas Noble53830622015-02-12 16:56:38 -0800913% if lib.language == 'c++':
914ifeq ($(NO_PROTOBUF),true)
915
916# You can't build a C++ library if you don't have protobuf - a bit overreached, but still okay.
917
Craig Tiller61b910f2015-02-15 10:54:07 -0800918$(LIBDIR)/$(CONFIG)/lib${lib.name}.a: protobuf_dep_error
Nicolas Noble53830622015-02-12 16:56:38 -0800919
920% if lib.build == "all":
921ifeq ($(SYSTEM),MINGW32)
Craig Tiller61b910f2015-02-15 10:54:07 -0800922$(LIBDIR)/$(CONFIG)/${lib.name}.$(SHARED_EXT): protobuf_dep_error
Nicolas Noble53830622015-02-12 16:56:38 -0800923else
Craig Tiller61b910f2015-02-15 10:54:07 -0800924$(LIBDIR)/$(CONFIG)/lib${lib.name}.$(SHARED_EXT): protobuf_dep_error
Nicolas Noble53830622015-02-12 16:56:38 -0800925endif
nnoble20e2e3f2014-12-16 15:37:57 -0800926% endif
Nicolas Noble53830622015-02-12 16:56:38 -0800927
928else
929
930% endif
Craig Tiller61b910f2015-02-15 10:54:07 -0800931$(LIBDIR)/$(CONFIG)/lib${lib.name}.a: $(ZLIB_DEP)\
Nicolas Noble53830622015-02-12 16:56:38 -0800932% endif
933% if lib.language == 'c++':
934 $(PROTOBUF_DEP)\
935% endif
936 $(LIB${lib.name.upper()}_OBJS)
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800937 $(E) "[AR] Creating $@"
nnoble85a49262014-12-08 18:14:03 -0800938 $(Q) mkdir -p `dirname $@`
Craig Tiller61b910f2015-02-15 10:54:07 -0800939 $(Q) rm -f $(LIBDIR)/$(CONFIG)/lib${lib.name}.a
940 $(Q) $(AR) rcs $(LIBDIR)/$(CONFIG)/lib${lib.name}.a $(LIB${lib.name.upper()}_OBJS)
nnoble20e2e3f2014-12-16 15:37:57 -0800941% if lib.get('baselib', False):
942% if lib.get('secure', True):
Craig Tillerf5371ef2015-01-12 16:40:18 -0800943 $(Q) rm -rf tmp-merge
nnoble20e2e3f2014-12-16 15:37:57 -0800944 $(Q) mkdir tmp-merge
Craig Tillerda224d62015-02-15 11:01:58 -0800945 $(Q) ( cd tmp-merge ; $(AR) x ../$(LIBDIR)/$(CONFIG)/lib${lib.name}.a )
nnoble20e2e3f2014-12-16 15:37:57 -0800946 $(Q) for l in $(OPENSSL_MERGE_LIBS) ; do ( cd tmp-merge ; <%text>ar x ../$${l}</%text> ) ; done
Craig Tiller61b910f2015-02-15 10:54:07 -0800947 $(Q) rm -f $(LIBDIR)/$(CONFIG)/lib${lib.name}.a tmp-merge/__.SYMDEF*
948 $(Q) ar rcs $(LIBDIR)/$(CONFIG)/lib${lib.name}.a tmp-merge/*
nnoble20e2e3f2014-12-16 15:37:57 -0800949 $(Q) rm -rf tmp-merge
950% endif
951% endif
Craig Tillerb4ee3b52015-01-21 16:22:50 -0800952ifeq ($(SYSTEM),Darwin)
Craig Tiller61b910f2015-02-15 10:54:07 -0800953 $(Q) ranlib $(LIBDIR)/$(CONFIG)/lib${lib.name}.a
Craig Tillerb4ee3b52015-01-21 16:22:50 -0800954endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800955
nnoble5b7f32a2014-12-22 08:12:44 -0800956<%
Craig Tiller59140fc2015-01-18 10:12:17 -0800957 if lib.language == 'c++':
nnoble5b7f32a2014-12-22 08:12:44 -0800958 ld = '$(LDXX)'
959 else:
960 ld = '$(LD)'
961
Craig Tillerda224d62015-02-15 11:01:58 -0800962 out_base = '$(LIBDIR)/$(CONFIG)/' + lib.name
963 out_libbase = '$(LIBDIR)/$(CONFIG)/lib' + lib.name
nnoble5b7f32a2014-12-22 08:12:44 -0800964
965 common = '$(LIB' + lib.name.upper() + '_OBJS) $(LDLIBS)'
966
967 libs = ''
Nicolas "Pixel" Noble85bf09b2015-01-15 18:22:40 +0100968 lib_deps = ' $(ZLIB_DEP)'
nnoble5b7f32a2014-12-22 08:12:44 -0800969 mingw_libs = ''
Nicolas "Pixel" Noble85bf09b2015-01-15 18:22:40 +0100970 mingw_lib_deps = ' $(ZLIB_DEP)'
nnoble5b7f32a2014-12-22 08:12:44 -0800971 for dep in lib.get('deps', []):
972 libs = libs + ' -l' + dep
Craig Tiller61b910f2015-02-15 10:54:07 -0800973 lib_deps = lib_deps + ' $(LIBDIR)/$(CONFIG)/lib' + dep + '.$(SHARED_EXT)'
nnoble5b7f32a2014-12-22 08:12:44 -0800974 mingw_libs = mingw_libs + ' -l' + dep + '-imp'
Craig Tillerda224d62015-02-15 11:01:58 -0800975 mingw_lib_deps = mingw_lib_deps + '$(LIBDIR)/$(CONFIG)/' + dep + '.$(SHARED_EXT)'
nnoble5b7f32a2014-12-22 08:12:44 -0800976
977 if lib.get('secure', True):
978 common = common + ' $(LDLIBS_SECURE) $(OPENSSL_MERGE_LIBS)'
979 lib_deps = lib_deps + ' $(OPENSSL_DEP)'
980 mingw_lib_deps = mingw_lib_deps + ' $(OPENSSL_DEP)'
Nicolas "Pixel" Nobledda049c2015-02-21 00:39:32 +0100981
982 if lib.language == 'c++':
983 common = common + ' $(LDLIBSXX) $(LDLIBS_PROTOBUF)'
nnoble5b7f32a2014-12-22 08:12:44 -0800984%>
985
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800986% if lib.build == "all":
nnoble5b7f32a2014-12-22 08:12:44 -0800987ifeq ($(SYSTEM),MINGW32)
988${out_base}.$(SHARED_EXT): $(LIB${lib.name.upper()}_OBJS) ${mingw_lib_deps}
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800989 $(E) "[LD] Linking $@"
nnoble85a49262014-12-08 18:14:03 -0800990 $(Q) mkdir -p `dirname $@`
Craig Tillerda224d62015-02-15 11:01:58 -0800991 $(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 -0800992else
993${out_libbase}.$(SHARED_EXT): $(LIB${lib.name.upper()}_OBJS) ${lib_deps}
994 $(E) "[LD] Linking $@"
995 $(Q) mkdir -p `dirname $@`
996ifeq ($(SYSTEM),Darwin)
Craig Tillerda224d62015-02-15 11:01:58 -0800997 $(Q) ${ld} $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -dynamiclib -o ${out_libbase}.$(SHARED_EXT) ${common}${libs}
nnoble5b7f32a2014-12-22 08:12:44 -0800998else
Craig Tillerda224d62015-02-15 11:01:58 -0800999 $(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 +01001000 $(Q) ln -sf lib${lib.name}.$(SHARED_EXT) ${out_libbase}.so.${settings.version.major}
nnoble5b7f32a2014-12-22 08:12:44 -08001001 $(Q) ln -sf lib${lib.name}.$(SHARED_EXT) ${out_libbase}.so
1002endif
1003endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001004% endif
Nicolas Noble53830622015-02-12 16:56:38 -08001005% if lib.get('secure', True):
Nicolas Noble047b7272015-01-16 13:55:05 -08001006## If the lib was secure, we have to close the Makefile's if that tested
1007## the presence of an ALPN-capable OpenSSL.
Nicolas Noble53830622015-02-12 16:56:38 -08001008
1009endif
1010% endif
1011% if lib.language == 'c++':
1012## If the lib was C++, we have to close the Makefile's if that tested
1013## the presence of protobuf 3.0.0+
nnoble69ac39f2014-12-12 15:43:38 -08001014
1015endif
1016% endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001017
nnoble69ac39f2014-12-12 15:43:38 -08001018% if lib.get('secure', True):
1019ifneq ($(NO_SECURE),true)
1020% endif
1021ifneq ($(NO_DEPS),true)
Craig Tiller8f126a62015-01-15 08:50:19 -08001022-include $(LIB${lib.name.upper()}_OBJS:.o=.dep)
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001023endif
nnoble69ac39f2014-12-12 15:43:38 -08001024% if lib.get('secure', True):
1025endif
1026% endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001027
Craig Tiller27715ca2015-01-12 16:55:59 -08001028% for src in lib.src:
1029% if not proto_re.match(src):
Craig Tiller61b910f2015-02-15 10:54:07 -08001030$(OBJDIR)/$(CONFIG)/${os.path.splitext(src)[0]}.o: \
Craig Tiller27715ca2015-01-12 16:55:59 -08001031% for src2 in lib.src:
1032% if proto_re.match(src2):
1033 ${proto_to_cc(src2)}\
1034% endif
1035% endfor
1036% endif
1037
1038% endfor
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001039</%def>
1040
1041<%def name="maketarget(tgt)">
1042${tgt.name.upper()}_SRC = \\
1043
1044% for src in tgt.src:
nnoble72309c62014-12-12 11:42:26 -08001045 ${proto_to_cc(src)} \\
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001046
1047% endfor
1048
Craig Tiller61b910f2015-02-15 10:54:07 -08001049${tgt.name.upper()}_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(${tgt.name.upper()}_SRC))))
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001050
nnoble69ac39f2014-12-12 15:43:38 -08001051% if tgt.get('secure', True):
1052ifeq ($(NO_SECURE),true)
1053
Nicolas Noble047b7272015-01-16 13:55:05 -08001054# You can't build secure targets if you don't have OpenSSL with ALPN.
1055
Craig Tiller61b910f2015-02-15 10:54:07 -08001056$(BINDIR)/$(CONFIG)/${tgt.name}: openssl_dep_error
nnoble69ac39f2014-12-12 15:43:38 -08001057
1058else
1059
1060% endif
Nicolas Noble047b7272015-01-16 13:55:05 -08001061##
1062## We're not trying to add a dependency on building zlib and openssl here,
1063## as it's already done in the libraries. We're assuming that the build
1064## trickles down, and that a secure target requires a secure version of
1065## a library.
1066##
1067## That simplifies the codegen a bit, but prevents a fully defined Makefile.
1068## I can live with that.
1069##
Nicolas Noble53830622015-02-12 16:56:38 -08001070% if tgt.build == 'protoc':
1071
1072ifeq ($(NO_PROTOBUF),true)
1073
1074# You can't build the protoc plugins if you don't have protobuf 3.0.0+.
1075
Craig Tiller61b910f2015-02-15 10:54:07 -08001076$(BINDIR)/$(CONFIG)/${tgt.name}: protobuf_dep_error
Nicolas Noble53830622015-02-12 16:56:38 -08001077
1078else
1079
Craig Tiller61b910f2015-02-15 10:54:07 -08001080$(BINDIR)/$(CONFIG)/${tgt.name}: $(PROTOBUF_DEP) $(${tgt.name.upper()}_OBJS)\
Nicolas Noble53830622015-02-12 16:56:38 -08001081% else:
Craig Tiller61b910f2015-02-15 10:54:07 -08001082$(BINDIR)/$(CONFIG)/${tgt.name}: $(${tgt.name.upper()}_OBJS)\
Nicolas Noble53830622015-02-12 16:56:38 -08001083% endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001084% for dep in tgt.deps:
Craig Tiller61b910f2015-02-15 10:54:07 -08001085 $(LIBDIR)/$(CONFIG)/lib${dep}.a\
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001086% endfor
1087
Craig Tiller59140fc2015-01-18 10:12:17 -08001088% if tgt.language == "c++":
Nicolas Noble047b7272015-01-16 13:55:05 -08001089## C++ targets specificies.
nnoble72309c62014-12-12 11:42:26 -08001090% if tgt.build == 'protoc':
1091 $(E) "[HOSTLD] Linking $@"
1092 $(Q) mkdir -p `dirname $@`
1093 $(Q) $(HOST_LDXX) $(HOST_LDFLAGS) $(${tgt.name.upper()}_OBJS)\
1094% else:
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001095 $(E) "[LD] Linking $@"
nnoble85a49262014-12-08 18:14:03 -08001096 $(Q) mkdir -p `dirname $@`
nnoblec78b3402014-12-11 16:06:57 -08001097 $(Q) $(LDXX) $(LDFLAGS) $(${tgt.name.upper()}_OBJS)\
nnoble72309c62014-12-12 11:42:26 -08001098% endif
nnoblec78b3402014-12-11 16:06:57 -08001099% if tgt.build == 'test':
1100 $(GTEST_LIB)\
1101% endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001102% else:
Nicolas Noble047b7272015-01-16 13:55:05 -08001103## C-only targets specificities.
nnoble72309c62014-12-12 11:42:26 -08001104 $(E) "[LD] Linking $@"
1105 $(Q) mkdir -p `dirname $@`
nnoble5b7f32a2014-12-22 08:12:44 -08001106 $(Q) $(LD) $(LDFLAGS) $(${tgt.name.upper()}_OBJS)\
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001107% endif
1108% for dep in tgt.deps:
Craig Tiller61b910f2015-02-15 10:54:07 -08001109 $(LIBDIR)/$(CONFIG)/lib${dep}.a\
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001110% endfor
Craig Tiller59140fc2015-01-18 10:12:17 -08001111% if tgt.language == "c++":
nnoble72309c62014-12-12 11:42:26 -08001112% if tgt.build == 'protoc':
Nicolas Noble53830622015-02-12 16:56:38 -08001113 $(HOST_LDLIBSXX) $(HOST_LDLIBS_PROTOC)\
nnoble72309c62014-12-12 11:42:26 -08001114% else:
Nicolas Noble53830622015-02-12 16:56:38 -08001115 $(LDLIBSXX) $(LDLIBS_PROTOBUF)\
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001116% endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001117% endif
nnoblec78b3402014-12-11 16:06:57 -08001118% if tgt.build == 'protoc':
nnoble72309c62014-12-12 11:42:26 -08001119 $(HOST_LDLIBS)\
1120% else:
1121 $(LDLIBS)\
1122% endif
1123% if tgt.build == 'protoc':
1124 $(HOST_LDLIBS_PROTOC)\
1125% elif tgt.get('secure', True):
1126 $(LDLIBS_SECURE)\
nnoblec78b3402014-12-11 16:06:57 -08001127% endif
Craig Tiller61b910f2015-02-15 10:54:07 -08001128 -o $(BINDIR)/$(CONFIG)/${tgt.name}
Nicolas Noble53830622015-02-12 16:56:38 -08001129% if tgt.build == 'protoc':
1130
1131endif
1132% endif
nnoble69ac39f2014-12-12 15:43:38 -08001133% if tgt.get('secure', True):
1134
1135endif
1136% endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001137
Craig Tillerf5371ef2015-01-12 16:40:18 -08001138% for src in tgt.src:
Craig Tiller61b910f2015-02-15 10:54:07 -08001139$(OBJDIR)/$(CONFIG)/${os.path.splitext(src)[0]}.o: \
Craig Tillerf5371ef2015-01-12 16:40:18 -08001140% for dep in tgt.deps:
Craig Tiller61b910f2015-02-15 10:54:07 -08001141 $(LIBDIR)/$(CONFIG)/lib${dep}.a\
Craig Tillerf5371ef2015-01-12 16:40:18 -08001142% endfor
1143
1144% endfor
1145
Craig Tiller8f126a62015-01-15 08:50:19 -08001146deps_${tgt.name}: $(${tgt.name.upper()}_OBJS:.o=.dep)
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001147
nnoble69ac39f2014-12-12 15:43:38 -08001148% if tgt.get('secure', True):
1149ifneq ($(NO_SECURE),true)
1150% endif
1151ifneq ($(NO_DEPS),true)
Craig Tiller8f126a62015-01-15 08:50:19 -08001152-include $(${tgt.name.upper()}_OBJS:.o=.dep)
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001153endif
nnoble69ac39f2014-12-12 15:43:38 -08001154% if tgt.get('secure', True):
1155endif
1156% endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001157</%def>
1158
nnoble85a49262014-12-08 18:14:03 -08001159.PHONY: all strip tools \
nnoble69ac39f2014-12-12 15:43:38 -08001160dep_error openssl_dep_error openssl_dep_message git_update stop \
nnoble85a49262014-12-08 18:14:03 -08001161buildtests buildtests_c buildtests_cxx \
1162test test_c test_cxx \
1163install install_c install_cxx \
1164install-headers install-headers_c install-headers_cxx \
1165install-shared install-shared_c install-shared_cxx \
1166install-static install-static_c install-static_cxx \
1167strip strip-shared strip-static \
1168strip_c strip-shared_c strip-static_c \
1169strip_cxx strip-shared_cxx strip-static_cxx \
Craig Tillerf0afe502015-01-15 09:04:49 -08001170dep_c dep_cxx bins_dep_c bins_dep_cxx \
Craig Tiller12c82092015-01-15 08:45:56 -08001171clean
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001172