Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 1 | # GRPC global makefile |
| 2 | # This currently builds C and C++ code. |
Nicolas "Pixel" Noble | d49893d | 2015-04-21 04:57:45 +0200 | [diff] [blame] | 3 | # This file has been automatically generated from a template file. |
| 4 | # Please look at the templates directory instead. |
Craig Tiller | 3b93548 | 2015-02-16 12:15:48 -0800 | [diff] [blame] | 5 | |
Craig Tiller | d7f3335 | 2015-02-20 15:18:45 -0800 | [diff] [blame] | 6 | # Copyright 2015, Google Inc. |
Craig Tiller | 3b93548 | 2015-02-16 12:15:48 -0800 | [diff] [blame] | 7 | # 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 Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 34 | <%! |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 35 | import re |
Craig Tiller | f5371ef | 2015-01-12 16:40:18 -0800 | [diff] [blame] | 36 | import os |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 37 | |
nnoble | c87b1c5 | 2015-01-05 17:15:18 -0800 | [diff] [blame] | 38 | proto_re = re.compile('(.*)\\.proto') |
nnoble | 72309c6 | 2014-12-12 11:42:26 -0800 | [diff] [blame] | 39 | |
nnoble | 72309c6 | 2014-12-12 11:42:26 -0800 | [diff] [blame] | 40 | def proto_to_cc(filename): |
| 41 | m = proto_re.match(filename) |
| 42 | if not m: |
| 43 | return filename |
Nicolas "Pixel" Noble | 0caebbf | 2015-04-09 23:08:51 +0200 | [diff] [blame] | 44 | return '$(GENDIR)/' + m.group(1) + '.pb.cc $(GENDIR)/' + m.group(1) + '.grpc.pb.cc' |
Nicolas "Pixel" Noble | 010f1e7 | 2015-04-23 02:23:49 +0200 | [diff] [blame] | 45 | |
| 46 | sources_that_need_openssl = set() |
| 47 | sources_that_don_t_need_openssl = set() |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 48 | %> |
| 49 | |
Craig Tiller | 96b4955 | 2015-01-21 16:29:01 -0800 | [diff] [blame] | 50 | |
| 51 | # Basic platform detection |
| 52 | HOST_SYSTEM = $(shell uname | cut -f 1 -d_) |
| 53 | ifeq ($(SYSTEM),) |
| 54 | SYSTEM = $(HOST_SYSTEM) |
| 55 | endif |
Nicolas Noble | f868118 | 2015-03-18 14:25:44 -0700 | [diff] [blame] | 56 | ifeq ($(SYSTEM),MSYS) |
| 57 | SYSTEM = MINGW32 |
| 58 | endif |
Craig Tiller | 96b4955 | 2015-01-21 16:29:01 -0800 | [diff] [blame] | 59 | |
| 60 | |
Craig Tiller | 61b910f | 2015-02-15 10:54:07 -0800 | [diff] [blame] | 61 | ifndef BUILDDIR |
| 62 | BUILDDIR = . |
| 63 | endif |
| 64 | |
Nicolas Noble | f868118 | 2015-03-18 14:25:44 -0700 | [diff] [blame] | 65 | HAS_GCC = $(shell which gcc > /dev/null 2> /dev/null && echo true || echo false) |
| 66 | HAS_CC = $(shell which cc > /dev/null 2> /dev/null && echo true || echo false) |
| 67 | HAS_CLANG = $(shell which clang > /dev/null 2> /dev/null && echo true || echo false) |
| 68 | |
| 69 | ifeq ($(HAS_CC),true) |
| 70 | DEFAULT_CC = cc |
| 71 | DEFAULT_CXX = c++ |
| 72 | else |
| 73 | ifeq ($(HAS_GCC),true) |
| 74 | DEFAULT_CC = gcc |
| 75 | DEFAULT_CXX = g++ |
| 76 | else |
| 77 | ifeq ($(HAS_CLANG),true) |
| 78 | DEFAULT_CC = clang |
| 79 | DEFAULT_CXX = clang++ |
| 80 | else |
| 81 | DEFAULT_CC = no_c_compiler |
| 82 | DEFAULT_CXX = no_c++_compiler |
| 83 | endif |
| 84 | endif |
| 85 | endif |
| 86 | |
| 87 | |
Craig Tiller | 61b910f | 2015-02-15 10:54:07 -0800 | [diff] [blame] | 88 | BINDIR = $(BUILDDIR)/bins |
| 89 | OBJDIR = $(BUILDDIR)/objs |
| 90 | LIBDIR = $(BUILDDIR)/libs |
| 91 | GENDIR = $(BUILDDIR)/gens |
| 92 | |
ctiller | 8cfebb9 | 2015-01-06 15:02:12 -0800 | [diff] [blame] | 93 | # Configurations |
| 94 | |
| 95 | VALID_CONFIG_opt = 1 |
Nicolas Noble | f868118 | 2015-03-18 14:25:44 -0700 | [diff] [blame] | 96 | CC_opt = $(DEFAULT_CC) |
| 97 | CXX_opt = $(DEFAULT_CXX) |
| 98 | LD_opt = $(DEFAULT_CC) |
| 99 | LDXX_opt = $(DEFAULT_CXX) |
ctiller | 8cfebb9 | 2015-01-06 15:02:12 -0800 | [diff] [blame] | 100 | CPPFLAGS_opt = -O2 |
| 101 | LDFLAGS_opt = |
| 102 | DEFINES_opt = NDEBUG |
| 103 | |
Vijay Pai | bc17113 | 2015-04-13 10:58:06 -0700 | [diff] [blame] | 104 | VALID_CONFIG_latprof = 1 |
| 105 | CC_latprof = $(DEFAULT_CC) |
| 106 | CXX_latprof = $(DEFAULT_CXX) |
| 107 | LD_latprof = $(DEFAULT_CC) |
| 108 | LDXX_latprof = $(DEFAULT_CXX) |
| 109 | CPPFLAGS_latprof = -O2 -DGRPC_LATENCY_PROFILER |
| 110 | LDFLAGS_latprof = |
| 111 | DEFINES_latprof = NDEBUG |
| 112 | |
ctiller | 8cfebb9 | 2015-01-06 15:02:12 -0800 | [diff] [blame] | 113 | VALID_CONFIG_dbg = 1 |
Nicolas Noble | f868118 | 2015-03-18 14:25:44 -0700 | [diff] [blame] | 114 | CC_dbg = $(DEFAULT_CC) |
| 115 | CXX_dbg = $(DEFAULT_CXX) |
| 116 | LD_dbg = $(DEFAULT_CC) |
| 117 | LDXX_dbg = $(DEFAULT_CXX) |
ctiller | 8cfebb9 | 2015-01-06 15:02:12 -0800 | [diff] [blame] | 118 | CPPFLAGS_dbg = -O0 |
| 119 | LDFLAGS_dbg = |
| 120 | DEFINES_dbg = _DEBUG DEBUG |
| 121 | |
Vijay Pai | dc7110f | 2015-04-02 13:59:05 -0700 | [diff] [blame] | 122 | VALID_CONFIG_mutrace = 1 |
| 123 | CC_mutrace = $(DEFAULT_CC) |
| 124 | CXX_mutrace = $(DEFAULT_CXX) |
| 125 | LD_mutrace = $(DEFAULT_CC) |
| 126 | LDXX_mutrace = $(DEFAULT_CXX) |
| 127 | CPPFLAGS_mutrace = -O0 |
| 128 | LDFLAGS_mutrace = -rdynamic |
| 129 | DEFINES_mutrace = _DEBUG DEBUG |
| 130 | |
Craig Tiller | ec0b8f3 | 2015-01-15 07:30:00 -0800 | [diff] [blame] | 131 | VALID_CONFIG_valgrind = 1 |
Craig Tiller | c4da6b7 | 2015-01-15 08:01:14 -0800 | [diff] [blame] | 132 | REQUIRE_CUSTOM_LIBRARIES_valgrind = 1 |
Nicolas Noble | f868118 | 2015-03-18 14:25:44 -0700 | [diff] [blame] | 133 | CC_valgrind = $(DEFAULT_CC) |
| 134 | CXX_valgrind = $(DEFAULT_CXX) |
| 135 | LD_valgrind = $(DEFAULT_CC) |
| 136 | LDXX_valgrind = $(DEFAULT_CXX) |
Craig Tiller | ec0b8f3 | 2015-01-15 07:30:00 -0800 | [diff] [blame] | 137 | CPPFLAGS_valgrind = -O0 |
| 138 | OPENSSL_CFLAGS_valgrind = -DPURIFY |
| 139 | LDFLAGS_valgrind = |
Craig Tiller | f6901be | 2015-02-27 09:12:58 -0800 | [diff] [blame] | 140 | DEFINES_valgrind = _DEBUG DEBUG GRPC_TEST_SLOWDOWN_BUILD_FACTOR=20 |
Craig Tiller | ec0b8f3 | 2015-01-15 07:30:00 -0800 | [diff] [blame] | 141 | |
ctiller | 8cfebb9 | 2015-01-06 15:02:12 -0800 | [diff] [blame] | 142 | VALID_CONFIG_tsan = 1 |
Craig Tiller | c4da6b7 | 2015-01-15 08:01:14 -0800 | [diff] [blame] | 143 | REQUIRE_CUSTOM_LIBRARIES_tsan = 1 |
ctiller | 8cfebb9 | 2015-01-06 15:02:12 -0800 | [diff] [blame] | 144 | CC_tsan = clang |
| 145 | CXX_tsan = clang++ |
| 146 | LD_tsan = clang |
| 147 | LDXX_tsan = clang++ |
| 148 | CPPFLAGS_tsan = -O1 -fsanitize=thread -fno-omit-frame-pointer |
| 149 | LDFLAGS_tsan = -fsanitize=thread |
Craig Tiller | f6901be | 2015-02-27 09:12:58 -0800 | [diff] [blame] | 150 | DEFINES_tsan = NDEBUG GRPC_TEST_SLOWDOWN_BUILD_FACTOR=10 |
ctiller | 8cfebb9 | 2015-01-06 15:02:12 -0800 | [diff] [blame] | 151 | |
| 152 | VALID_CONFIG_asan = 1 |
Craig Tiller | c4da6b7 | 2015-01-15 08:01:14 -0800 | [diff] [blame] | 153 | REQUIRE_CUSTOM_LIBRARIES_asan = 1 |
ctiller | 8cfebb9 | 2015-01-06 15:02:12 -0800 | [diff] [blame] | 154 | CC_asan = clang |
| 155 | CXX_asan = clang++ |
| 156 | LD_asan = clang |
| 157 | LDXX_asan = clang++ |
Craig Tiller | 6902ad2 | 2015-04-16 08:01:49 -0700 | [diff] [blame] | 158 | CPPFLAGS_asan = -O0 -fsanitize=address -fno-omit-frame-pointer |
ctiller | 8cfebb9 | 2015-01-06 15:02:12 -0800 | [diff] [blame] | 159 | LDFLAGS_asan = -fsanitize=address |
Craig Tiller | 6902ad2 | 2015-04-16 08:01:49 -0700 | [diff] [blame] | 160 | DEFINES_asan = GRPC_TEST_SLOWDOWN_BUILD_FACTOR=5 |
ctiller | 8cfebb9 | 2015-01-06 15:02:12 -0800 | [diff] [blame] | 161 | |
| 162 | VALID_CONFIG_msan = 1 |
Craig Tiller | c4da6b7 | 2015-01-15 08:01:14 -0800 | [diff] [blame] | 163 | REQUIRE_CUSTOM_LIBRARIES_msan = 1 |
ctiller | 8cfebb9 | 2015-01-06 15:02:12 -0800 | [diff] [blame] | 164 | CC_msan = clang |
Nicolas "Pixel" Noble | d66cba2 | 2015-02-14 02:59:12 +0100 | [diff] [blame] | 165 | CXX_msan = clang++-libc++ |
ctiller | 8cfebb9 | 2015-01-06 15:02:12 -0800 | [diff] [blame] | 166 | LD_msan = clang |
Nicolas "Pixel" Noble | d66cba2 | 2015-02-14 02:59:12 +0100 | [diff] [blame] | 167 | LDXX_msan = clang++-libc++ |
Craig Tiller | 6902ad2 | 2015-04-16 08:01:49 -0700 | [diff] [blame] | 168 | CPPFLAGS_msan = -O0 -fsanitize=memory -fsanitize-memory-track-origins -fno-omit-frame-pointer -DGTEST_HAS_TR1_TUPLE=0 -DGTEST_USE_OWN_TR1_TUPLE=1 |
Craig Tiller | ec0b8f3 | 2015-01-15 07:30:00 -0800 | [diff] [blame] | 169 | OPENSSL_CFLAGS_msan = -DPURIFY |
Nicolas "Pixel" Noble | d66cba2 | 2015-02-14 02:59:12 +0100 | [diff] [blame] | 170 | LDFLAGS_msan = -fsanitize=memory -DGTEST_HAS_TR1_TUPLE=0 -DGTEST_USE_OWN_TR1_TUPLE=1 |
Craig Tiller | f6901be | 2015-02-27 09:12:58 -0800 | [diff] [blame] | 171 | DEFINES_msan = NDEBUG GRPC_TEST_SLOWDOWN_BUILD_FACTOR=20 |
ctiller | 8cfebb9 | 2015-01-06 15:02:12 -0800 | [diff] [blame] | 172 | |
Craig Tiller | 96bd5f6 | 2015-02-13 09:04:13 -0800 | [diff] [blame] | 173 | VALID_CONFIG_ubsan = 1 |
| 174 | REQUIRE_CUSTOM_LIBRARIES_ubsan = 1 |
| 175 | CC_ubsan = clang |
| 176 | CXX_ubsan = clang++ |
| 177 | LD_ubsan = clang |
| 178 | LDXX_ubsan = clang++ |
| 179 | CPPFLAGS_ubsan = -O1 -fsanitize=undefined -fno-omit-frame-pointer |
| 180 | OPENSSL_CFLAGS_ubsan = -DPURIFY |
Craig Tiller | 96bd5f6 | 2015-02-13 09:04:13 -0800 | [diff] [blame] | 181 | LDFLAGS_ubsan = -fsanitize=undefined |
Craig Tiller | f6901be | 2015-02-27 09:12:58 -0800 | [diff] [blame] | 182 | DEFINES_ubsan = NDEBUG GRPC_TEST_SLOWDOWN_BUILD_FACTOR=10 |
Craig Tiller | 96bd5f6 | 2015-02-13 09:04:13 -0800 | [diff] [blame] | 183 | |
Craig Tiller | 699ba21 | 2015-01-13 17:02:20 -0800 | [diff] [blame] | 184 | VALID_CONFIG_gcov = 1 |
| 185 | CC_gcov = gcc |
| 186 | CXX_gcov = g++ |
| 187 | LD_gcov = gcc |
| 188 | LDXX_gcov = g++ |
| 189 | CPPFLAGS_gcov = -O0 -fprofile-arcs -ftest-coverage |
| 190 | LDFLAGS_gcov = -fprofile-arcs -ftest-coverage |
| 191 | DEFINES_gcov = NDEBUG |
| 192 | |
Nicolas Noble | 047b727 | 2015-01-16 13:55:05 -0800 | [diff] [blame] | 193 | |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 194 | # General settings. |
| 195 | # You may want to change these depending on your system. |
| 196 | |
| 197 | prefix ?= /usr/local |
| 198 | |
| 199 | PROTOC = protoc |
yangg | 102e4fe | 2015-01-06 16:02:50 -0800 | [diff] [blame] | 200 | CONFIG ?= opt |
ctiller | 8cfebb9 | 2015-01-06 15:02:12 -0800 | [diff] [blame] | 201 | CC = $(CC_$(CONFIG)) |
| 202 | CXX = $(CXX_$(CONFIG)) |
| 203 | LD = $(LD_$(CONFIG)) |
| 204 | LDXX = $(LDXX_$(CONFIG)) |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 205 | AR = ar |
Nicolas "Pixel" Noble | d7631a4 | 2015-02-27 07:52:39 +0100 | [diff] [blame] | 206 | ifeq ($(SYSTEM),Linux) |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 207 | STRIP = strip --strip-unneeded |
Nicolas "Pixel" Noble | d7631a4 | 2015-02-27 07:52:39 +0100 | [diff] [blame] | 208 | else |
| 209 | ifeq ($(SYSTEM),Darwin) |
| 210 | STRIP = strip -x |
| 211 | else |
| 212 | STRIP = strip |
| 213 | endif |
| 214 | endif |
Nicolas "Pixel" Noble | 932d5d3 | 2015-02-21 02:15:34 +0100 | [diff] [blame] | 215 | INSTALL = install |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 216 | RM = rm -f |
| 217 | |
yangg | 102e4fe | 2015-01-06 16:02:50 -0800 | [diff] [blame] | 218 | ifndef VALID_CONFIG_$(CONFIG) |
| 219 | $(error Invalid CONFIG value '$(CONFIG)') |
| 220 | endif |
| 221 | |
Nicolas "Pixel" Noble | e758ed1 | 2015-03-11 22:51:39 +0100 | [diff] [blame] | 222 | ifeq ($(SYSTEM),Linux) |
| 223 | TMPOUT = /dev/null |
| 224 | else |
| 225 | TMPOUT = `mktemp /tmp/test-out-XXXXXX` |
| 226 | endif |
Nicolas Noble | 047b727 | 2015-01-16 13:55:05 -0800 | [diff] [blame] | 227 | |
Craig Tiller | cf133f4 | 2015-02-26 14:05:56 -0800 | [diff] [blame] | 228 | # Detect if we can use C++11 |
Nicolas "Pixel" Noble | e758ed1 | 2015-03-11 22:51:39 +0100 | [diff] [blame] | 229 | CXX11_CHECK_CMD = $(CXX) -std=c++11 -o $(TMPOUT) -c test/build/c++11.cc |
Craig Tiller | cf133f4 | 2015-02-26 14:05:56 -0800 | [diff] [blame] | 230 | HAS_CXX11 = $(shell $(CXX11_CHECK_CMD) 2> /dev/null && echo true || echo false) |
| 231 | |
Nicolas Noble | 047b727 | 2015-01-16 13:55:05 -0800 | [diff] [blame] | 232 | # The HOST compiler settings are used to compile the protoc plugins. |
| 233 | # In most cases, you won't have to change anything, but if you are |
| 234 | # cross-compiling, you can override these variables from GNU make's |
| 235 | # command line: make CC=cross-gcc HOST_CC=gcc |
| 236 | |
nnoble | 72309c6 | 2014-12-12 11:42:26 -0800 | [diff] [blame] | 237 | HOST_CC = $(CC) |
| 238 | HOST_CXX = $(CXX) |
| 239 | HOST_LD = $(LD) |
| 240 | HOST_LDXX = $(LDXX) |
| 241 | |
ctiller | cab52e7 | 2015-01-06 13:10:23 -0800 | [diff] [blame] | 242 | CPPFLAGS += $(CPPFLAGS_$(CONFIG)) |
Nicolas "Pixel" Noble | 7274382 | 2015-02-20 20:59:29 +0100 | [diff] [blame] | 243 | DEFINES += $(DEFINES_$(CONFIG)) INSTALL_PREFIX=\"$(prefix)\" |
ctiller | 8cfebb9 | 2015-01-06 15:02:12 -0800 | [diff] [blame] | 244 | LDFLAGS += $(LDFLAGS_$(CONFIG)) |
ctiller | cab52e7 | 2015-01-06 13:10:23 -0800 | [diff] [blame] | 245 | |
Craig Tiller | 86fa1c5 | 2015-02-27 09:57:58 -0800 | [diff] [blame] | 246 | ifdef EXTRA_DEFINES |
Craig Tiller | f5065c5 | 2015-02-27 16:17:39 -0800 | [diff] [blame] | 247 | DEFINES += $(EXTRA_DEFINES) |
Craig Tiller | 86fa1c5 | 2015-02-27 09:57:58 -0800 | [diff] [blame] | 248 | endif |
| 249 | |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 250 | CFLAGS += -std=c89 -pedantic |
Craig Tiller | cf133f4 | 2015-02-26 14:05:56 -0800 | [diff] [blame] | 251 | ifeq ($(HAS_CXX11),true) |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 252 | CXXFLAGS += -std=c++11 |
Craig Tiller | cf133f4 | 2015-02-26 14:05:56 -0800 | [diff] [blame] | 253 | else |
| 254 | CXXFLAGS += -std=c++0x |
Craig Tiller | cf133f4 | 2015-02-26 14:05:56 -0800 | [diff] [blame] | 255 | endif |
Nicolas Noble | f868118 | 2015-03-18 14:25:44 -0700 | [diff] [blame] | 256 | CPPFLAGS += -g -Wall -Wextra -Werror -Wno-long-long -Wno-unused-parameter |
| 257 | LDFLAGS += -g |
| 258 | |
| 259 | ifneq ($(SYSTEM),MINGW32) |
| 260 | PIC_CPPFLAGS = -fPIC |
| 261 | CPPFLAGS += -fPIC |
| 262 | LDFLAGS += -fPIC |
| 263 | endif |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 264 | |
Craig Tiller | da224d6 | 2015-02-15 11:01:58 -0800 | [diff] [blame] | 265 | INCLUDES = . include $(GENDIR) |
Craig Tiller | 96b4955 | 2015-01-21 16:29:01 -0800 | [diff] [blame] | 266 | ifeq ($(SYSTEM),Darwin) |
Nicolas "Pixel" Noble | e758ed1 | 2015-03-11 22:51:39 +0100 | [diff] [blame] | 267 | ifneq ($(wildcard /usr/local/ssl/include),) |
| 268 | INCLUDES += /usr/local/ssl/include |
| 269 | endif |
| 270 | ifneq ($(wildcard /opt/local/include),) |
| 271 | INCLUDES += /opt/local/include |
| 272 | endif |
| 273 | ifneq ($(wildcard /usr/local/include),) |
| 274 | INCLUDES += /usr/local/include |
| 275 | endif |
Craig Tiller | 96b4955 | 2015-01-21 16:29:01 -0800 | [diff] [blame] | 276 | LIBS = m z |
Nicolas "Pixel" Noble | e758ed1 | 2015-03-11 22:51:39 +0100 | [diff] [blame] | 277 | ifneq ($(wildcard /usr/local/ssl/lib),) |
| 278 | LDFLAGS += -L/usr/local/ssl/lib |
| 279 | endif |
| 280 | ifneq ($(wildcard /opt/local/lib),) |
| 281 | LDFLAGS += -L/opt/local/lib |
| 282 | endif |
| 283 | ifneq ($(wildcard /usr/local/lib),) |
| 284 | LDFLAGS += -L/usr/local/lib |
| 285 | endif |
Nicolas Noble | f868118 | 2015-03-18 14:25:44 -0700 | [diff] [blame] | 286 | endif |
| 287 | |
| 288 | ifeq ($(SYSTEM),Linux) |
ctiller | c008ae5 | 2015-01-07 15:33:00 -0800 | [diff] [blame] | 289 | LIBS = rt m z pthread |
Craig Tiller | 96b4955 | 2015-01-21 16:29:01 -0800 | [diff] [blame] | 290 | LDFLAGS += -pthread |
| 291 | endif |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 292 | |
Nicolas Noble | f868118 | 2015-03-18 14:25:44 -0700 | [diff] [blame] | 293 | ifeq ($(SYSTEM),MINGW32) |
| 294 | LIBS = m z pthread |
| 295 | LDFLAGS += -pthread |
| 296 | endif |
| 297 | |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 298 | ifneq ($(wildcard /usr/src/gtest/src/gtest-all.cc),) |
| 299 | GTEST_LIB = /usr/src/gtest/src/gtest-all.cc -I/usr/src/gtest |
| 300 | else |
| 301 | GTEST_LIB = -lgtest |
| 302 | endif |
chenw | a8fd44a | 2014-12-10 15:13:55 -0800 | [diff] [blame] | 303 | GTEST_LIB += -lgflags |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 304 | ifeq ($(V),1) |
| 305 | E = @: |
| 306 | Q = |
| 307 | else |
| 308 | E = @echo |
| 309 | Q = @ |
| 310 | endif |
| 311 | |
| 312 | VERSION = ${settings.version.major}.${settings.version.minor}.${settings.version.micro}.${settings.version.build} |
| 313 | |
| 314 | CPPFLAGS_NO_ARCH += $(addprefix -I, $(INCLUDES)) $(addprefix -D, $(DEFINES)) |
| 315 | CPPFLAGS += $(CPPFLAGS_NO_ARCH) $(ARCH_FLAGS) |
| 316 | |
| 317 | LDFLAGS += $(ARCH_FLAGS) |
| 318 | LDLIBS += $(addprefix -l, $(LIBS)) |
| 319 | LDLIBSXX += $(addprefix -l, $(LIBSXX)) |
nnoble | 72309c6 | 2014-12-12 11:42:26 -0800 | [diff] [blame] | 320 | |
| 321 | HOST_CPPFLAGS = $(CPPFLAGS) |
| 322 | HOST_CFLAGS = $(CFLAGS) |
| 323 | HOST_CXXFLAGS = $(CXXFLAGS) |
| 324 | HOST_LDFLAGS = $(LDFLAGS) |
| 325 | HOST_LDLIBS = $(LDLIBS) |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 326 | |
nnoble | 69ac39f | 2014-12-12 15:43:38 -0800 | [diff] [blame] | 327 | |
| 328 | # These are automatically computed variables. |
| 329 | # There shouldn't be any need to change anything from now on. |
| 330 | |
nnoble | 5b7f32a | 2014-12-22 08:12:44 -0800 | [diff] [blame] | 331 | ifeq ($(SYSTEM),MINGW32) |
| 332 | SHARED_EXT = dll |
| 333 | endif |
| 334 | ifeq ($(SYSTEM),Darwin) |
| 335 | SHARED_EXT = dylib |
| 336 | endif |
| 337 | ifeq ($(SHARED_EXT),) |
| 338 | SHARED_EXT = so.$(VERSION) |
| 339 | endif |
| 340 | |
nnoble | 69ac39f | 2014-12-12 15:43:38 -0800 | [diff] [blame] | 341 | ifeq ($(wildcard .git),) |
| 342 | IS_GIT_FOLDER = false |
| 343 | else |
| 344 | IS_GIT_FOLDER = true |
| 345 | endif |
| 346 | |
Nicolas Noble | f868118 | 2015-03-18 14:25:44 -0700 | [diff] [blame] | 347 | ifeq ($(SYSTEM),Linux) |
| 348 | OPENSSL_REQUIRES_DL = true |
| 349 | endif |
| 350 | |
| 351 | ifeq ($(SYSTEM),Darwin) |
| 352 | OPENSSL_REQUIRES_DL = true |
| 353 | endif |
| 354 | |
| 355 | ifeq ($(SYSTEM),MINGW32) |
| 356 | OPENSSL_LIBS = ssl32 eay32 |
| 357 | else |
| 358 | OPENSSL_LIBS = ssl crypto |
| 359 | endif |
| 360 | |
| 361 | OPENSSL_ALPN_CHECK_CMD = $(CC) $(CFLAGS) $(CPPFLAGS) -o $(TMPOUT) test/build/openssl-alpn.c $(addprefix -l, $(OPENSSL_LIBS)) $(LDFLAGS) |
Nicolas "Pixel" Noble | e758ed1 | 2015-03-11 22:51:39 +0100 | [diff] [blame] | 362 | ZLIB_CHECK_CMD = $(CC) $(CFLAGS) $(CPPFLAGS) -o $(TMPOUT) test/build/zlib.c -lz $(LDFLAGS) |
| 363 | PERFTOOLS_CHECK_CMD = $(CC) $(CFLAGS) $(CPPFLAGS) -o $(TMPOUT) test/build/perftools.c -lprofiler $(LDFLAGS) |
| 364 | PROTOBUF_CHECK_CMD = $(CXX) $(CXXFLAGS) $(CPPFLAGS) -o $(TMPOUT) test/build/protobuf.cc -lprotobuf $(LDFLAGS) |
Nicolas Noble | f868118 | 2015-03-18 14:25:44 -0700 | [diff] [blame] | 365 | PROTOC_CMD = which protoc > /dev/null |
Nicolas Noble | 5383062 | 2015-02-12 16:56:38 -0800 | [diff] [blame] | 366 | PROTOC_CHECK_CMD = protoc --version | grep -q libprotoc.3 |
Craig Tiller | 297fafa | 2015-01-15 15:46:39 -0800 | [diff] [blame] | 367 | |
Nicolas Noble | f868118 | 2015-03-18 14:25:44 -0700 | [diff] [blame] | 368 | ifeq ($(OPENSSL_REQUIRES_DL),true) |
| 369 | OPENSSL_ALPN_CHECK_CMD += -ldl |
| 370 | endif |
| 371 | |
Craig Tiller | 50524cc | 2015-01-29 23:00:00 -0800 | [diff] [blame] | 372 | ifndef REQUIRE_CUSTOM_LIBRARIES_$(CONFIG) |
Craig Tiller | 297fafa | 2015-01-15 15:46:39 -0800 | [diff] [blame] | 373 | HAS_SYSTEM_PERFTOOLS = $(shell $(PERFTOOLS_CHECK_CMD) 2> /dev/null && echo true || echo false) |
| 374 | ifeq ($(HAS_SYSTEM_PERFTOOLS),true) |
| 375 | DEFINES += GRPC_HAVE_PERFTOOLS |
| 376 | LIBS += profiler |
| 377 | endif |
Craig Tiller | 50524cc | 2015-01-29 23:00:00 -0800 | [diff] [blame] | 378 | endif |
nnoble | 69ac39f | 2014-12-12 15:43:38 -0800 | [diff] [blame] | 379 | |
Nicolas "Pixel" Noble | 98ab998 | 2015-02-21 04:22:16 +0100 | [diff] [blame] | 380 | HAS_SYSTEM_PROTOBUF_VERIFY = $(shell $(PROTOBUF_CHECK_CMD) 2> /dev/null && echo true || echo false) |
Craig Tiller | c4da6b7 | 2015-01-15 08:01:14 -0800 | [diff] [blame] | 381 | ifndef REQUIRE_CUSTOM_LIBRARIES_$(CONFIG) |
nnoble | 6082540 | 2014-12-15 14:43:51 -0800 | [diff] [blame] | 382 | HAS_SYSTEM_OPENSSL_ALPN = $(shell $(OPENSSL_ALPN_CHECK_CMD) 2> /dev/null && echo true || echo false) |
| 383 | HAS_SYSTEM_ZLIB = $(shell $(ZLIB_CHECK_CMD) 2> /dev/null && echo true || echo false) |
Nicolas "Pixel" Noble | 98ab998 | 2015-02-21 04:22:16 +0100 | [diff] [blame] | 384 | HAS_SYSTEM_PROTOBUF = $(HAS_SYSTEM_PROTOBUF_VERIFY) |
Craig Tiller | c4da6b7 | 2015-01-15 08:01:14 -0800 | [diff] [blame] | 385 | else |
| 386 | # override system libraries if the config requires a custom compiled library |
| 387 | HAS_SYSTEM_OPENSSL_ALPN = false |
| 388 | HAS_SYSTEM_ZLIB = false |
Nicolas Noble | 5383062 | 2015-02-12 16:56:38 -0800 | [diff] [blame] | 389 | HAS_SYSTEM_PROTOBUF = false |
Craig Tiller | c4da6b7 | 2015-01-15 08:01:14 -0800 | [diff] [blame] | 390 | endif |
nnoble | 69ac39f | 2014-12-12 15:43:38 -0800 | [diff] [blame] | 391 | |
Nicolas Noble | f868118 | 2015-03-18 14:25:44 -0700 | [diff] [blame] | 392 | HAS_PROTOC = $(shell $(PROTOC_CMD) 2> /dev/null && echo true || echo false) |
Nicolas "Pixel" Noble | 98ab998 | 2015-02-21 04:22:16 +0100 | [diff] [blame] | 393 | ifeq ($(HAS_PROTOC),true) |
Nicolas Noble | 5383062 | 2015-02-12 16:56:38 -0800 | [diff] [blame] | 394 | HAS_VALID_PROTOC = $(shell $(PROTOC_CHECK_CMD) 2> /dev/null && echo true || echo false) |
Nicolas "Pixel" Noble | 98ab998 | 2015-02-21 04:22:16 +0100 | [diff] [blame] | 395 | else |
| 396 | HAS_VALID_PROTOC = false |
| 397 | endif |
Nicolas Noble | 5383062 | 2015-02-12 16:56:38 -0800 | [diff] [blame] | 398 | |
nnoble | 69ac39f | 2014-12-12 15:43:38 -0800 | [diff] [blame] | 399 | ifeq ($(wildcard third_party/openssl/ssl/ssl.h),) |
| 400 | HAS_EMBEDDED_OPENSSL_ALPN = false |
| 401 | else |
| 402 | HAS_EMBEDDED_OPENSSL_ALPN = true |
| 403 | endif |
| 404 | |
| 405 | ifeq ($(wildcard third_party/zlib/zlib.h),) |
| 406 | HAS_EMBEDDED_ZLIB = false |
| 407 | else |
| 408 | HAS_EMBEDDED_ZLIB = true |
| 409 | endif |
| 410 | |
Nicolas Noble | 5383062 | 2015-02-12 16:56:38 -0800 | [diff] [blame] | 411 | ifeq ($(wildcard third_party/protobuf/src/google/protobuf/descriptor.pb.h),) |
| 412 | HAS_EMBEDDED_PROTOBUF = false |
| 413 | ifneq ($(HAS_VALID_PROTOC),true) |
| 414 | NO_PROTOC = true |
| 415 | endif |
| 416 | else |
| 417 | HAS_EMBEDDED_PROTOBUF = true |
| 418 | endif |
| 419 | |
nnoble | 69ac39f | 2014-12-12 15:43:38 -0800 | [diff] [blame] | 420 | ifeq ($(HAS_SYSTEM_ZLIB),false) |
| 421 | ifeq ($(HAS_EMBEDDED_ZLIB),true) |
Craig Tiller | 61b910f | 2015-02-15 10:54:07 -0800 | [diff] [blame] | 422 | ZLIB_DEP = $(LIBDIR)/$(CONFIG)/zlib/libz.a |
nnoble | 69ac39f | 2014-12-12 15:43:38 -0800 | [diff] [blame] | 423 | CPPFLAGS += -Ithird_party/zlib |
Craig Tiller | da224d6 | 2015-02-15 11:01:58 -0800 | [diff] [blame] | 424 | LDFLAGS += -L$(LIBDIR)/$(CONFIG)/zlib |
nnoble | 69ac39f | 2014-12-12 15:43:38 -0800 | [diff] [blame] | 425 | else |
| 426 | DEP_MISSING += zlib |
| 427 | endif |
| 428 | endif |
| 429 | |
| 430 | ifeq ($(HAS_SYSTEM_OPENSSL_ALPN),false) |
| 431 | ifeq ($(HAS_EMBEDDED_OPENSSL_ALPN),true) |
Craig Tiller | 61b910f | 2015-02-15 10:54:07 -0800 | [diff] [blame] | 432 | OPENSSL_DEP = $(LIBDIR)/$(CONFIG)/openssl/libssl.a |
| 433 | OPENSSL_MERGE_LIBS += $(LIBDIR)/$(CONFIG)/openssl/libssl.a $(LIBDIR)/$(CONFIG)/openssl/libcrypto.a |
Craig Tiller | ec04303 | 2015-02-20 17:24:41 -0800 | [diff] [blame] | 434 | # need to prefix these to ensure overriding system libraries |
| 435 | CPPFLAGS := -Ithird_party/openssl/include $(CPPFLAGS) |
| 436 | LDFLAGS := -L$(LIBDIR)/$(CONFIG)/openssl $(LDFLAGS) |
Nicolas Noble | f868118 | 2015-03-18 14:25:44 -0700 | [diff] [blame] | 437 | ifeq ($(OPENSSL_REQUIRES_DL),true) |
nnoble | 5b7f32a | 2014-12-22 08:12:44 -0800 | [diff] [blame] | 438 | LIBS_SECURE = dl |
Nicolas Noble | f868118 | 2015-03-18 14:25:44 -0700 | [diff] [blame] | 439 | endif |
nnoble | 69ac39f | 2014-12-12 15:43:38 -0800 | [diff] [blame] | 440 | else |
| 441 | NO_SECURE = true |
| 442 | endif |
nnoble | 5b7f32a | 2014-12-22 08:12:44 -0800 | [diff] [blame] | 443 | else |
Nicolas Noble | f868118 | 2015-03-18 14:25:44 -0700 | [diff] [blame] | 444 | LIBS_SECURE = $(OPENSSL_LIBS) |
| 445 | ifeq ($(OPENSSL_REQUIRES_DL),true) |
| 446 | LIBS_SECURE += dl |
| 447 | endif |
nnoble | 69ac39f | 2014-12-12 15:43:38 -0800 | [diff] [blame] | 448 | endif |
| 449 | |
nnoble | 5b7f32a | 2014-12-22 08:12:44 -0800 | [diff] [blame] | 450 | LDLIBS_SECURE += $(addprefix -l, $(LIBS_SECURE)) |
| 451 | |
Nicolas Noble | 5383062 | 2015-02-12 16:56:38 -0800 | [diff] [blame] | 452 | ifeq ($(HAS_SYSTEM_PROTOBUF),false) |
| 453 | ifeq ($(HAS_EMBEDDED_PROTOBUF),true) |
Craig Tiller | 61b910f | 2015-02-15 10:54:07 -0800 | [diff] [blame] | 454 | PROTOBUF_DEP = $(LIBDIR)/$(CONFIG)/protobuf/libprotobuf.a |
Craig Tiller | 9ec95fa | 2015-02-20 20:36:21 -0800 | [diff] [blame] | 455 | CPPFLAGS := -Ithird_party/protobuf/src $(CPPFLAGS) |
| 456 | LDFLAGS := -L$(LIBDIR)/$(CONFIG)/protobuf $(LDFLAGS) |
Craig Tiller | 61b910f | 2015-02-15 10:54:07 -0800 | [diff] [blame] | 457 | PROTOC = $(BINDIR)/$(CONFIG)/protobuf/protoc |
Nicolas Noble | 5383062 | 2015-02-12 16:56:38 -0800 | [diff] [blame] | 458 | else |
| 459 | NO_PROTOBUF = true |
| 460 | endif |
| 461 | else |
| 462 | endif |
| 463 | |
| 464 | LIBS_PROTOBUF = protobuf |
| 465 | LIBS_PROTOC = protoc protobuf |
| 466 | |
| 467 | LDLIBS_PROTOBUF += $(addprefix -l, $(LIBS_PROTOBUF)) |
| 468 | HOST_LDLIBS_PROTOC += $(addprefix -l, $(LIBS_PROTOC)) |
| 469 | |
Craig Tiller | 12c8209 | 2015-01-15 08:45:56 -0800 | [diff] [blame] | 470 | ifeq ($(MAKECMDGOALS),clean) |
nnoble | 69ac39f | 2014-12-12 15:43:38 -0800 | [diff] [blame] | 471 | NO_DEPS = true |
| 472 | endif |
| 473 | |
Nicolas "Pixel" Noble | 98ab998 | 2015-02-21 04:22:16 +0100 | [diff] [blame] | 474 | INSTALL_OK = false |
| 475 | ifeq ($(HAS_VALID_PROTOC),true) |
| 476 | ifeq ($(HAS_SYSTEM_PROTOBUF_VERIFY),true) |
| 477 | INSTALL_OK = true |
| 478 | endif |
| 479 | endif |
| 480 | |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 481 | .SECONDARY = %.pb.h %.pb.cc |
| 482 | |
Nicolas "Pixel" Noble | 522d712 | 2015-02-19 01:28:02 +0100 | [diff] [blame] | 483 | PROTOC_PLUGINS =\ |
Craig Tiller | f58b9ef | 2015-01-15 09:09:12 -0800 | [diff] [blame] | 484 | % for tgt in targets: |
| 485 | % if tgt.build == 'protoc': |
Craig Tiller | 61b910f | 2015-02-15 10:54:07 -0800 | [diff] [blame] | 486 | $(BINDIR)/$(CONFIG)/${tgt.name}\ |
Craig Tiller | f58b9ef | 2015-01-15 09:09:12 -0800 | [diff] [blame] | 487 | % endif |
| 488 | % endfor |
| 489 | |
nnoble | 69ac39f | 2014-12-12 15:43:38 -0800 | [diff] [blame] | 490 | ifeq ($(DEP_MISSING),) |
Nicolas "Pixel" Noble | 522d712 | 2015-02-19 01:28:02 +0100 | [diff] [blame] | 491 | all: static shared plugins\ |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 492 | % for tgt in targets: |
| 493 | % if tgt.build == 'all': |
Craig Tiller | 61b910f | 2015-02-15 10:54:07 -0800 | [diff] [blame] | 494 | $(BINDIR)/$(CONFIG)/${tgt.name}\ |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 495 | % endif |
| 496 | % endfor |
| 497 | |
nnoble | 69ac39f | 2014-12-12 15:43:38 -0800 | [diff] [blame] | 498 | dep_error: |
| 499 | @echo "You shouldn't see this message - all of your dependencies are correct." |
| 500 | else |
| 501 | all: dep_error git_update stop |
| 502 | |
| 503 | dep_error: |
| 504 | @echo |
| 505 | @echo "DEPENDENCY ERROR" |
| 506 | @echo |
| 507 | @echo "You are missing system dependencies that are essential to build grpc," |
| 508 | @echo "and the third_party directory doesn't have them:" |
| 509 | @echo |
| 510 | @echo " $(DEP_MISSING)" |
| 511 | @echo |
| 512 | @echo "Installing the development packages for your system will solve" |
| 513 | @echo "this issue. Please consult INSTALL to get more information." |
| 514 | @echo |
| 515 | @echo "If you need information about why these tests failed, run:" |
| 516 | @echo |
| 517 | @echo " make run_dep_checks" |
| 518 | @echo |
| 519 | endif |
| 520 | |
| 521 | git_update: |
| 522 | ifeq ($(IS_GIT_FOLDER),true) |
| 523 | @echo "Additionally, since you are in a git clone, you can download the" |
| 524 | @echo "missing dependencies in third_party by running the following command:" |
| 525 | @echo |
ctiller | 64f2910 | 2014-12-15 10:40:59 -0800 | [diff] [blame] | 526 | @echo " git submodule update --init" |
nnoble | 69ac39f | 2014-12-12 15:43:38 -0800 | [diff] [blame] | 527 | @echo |
| 528 | endif |
| 529 | |
| 530 | openssl_dep_error: openssl_dep_message git_update stop |
| 531 | |
Nicolas Noble | 5383062 | 2015-02-12 16:56:38 -0800 | [diff] [blame] | 532 | protobuf_dep_error: protobuf_dep_message git_update stop |
| 533 | |
| 534 | protoc_dep_error: protoc_dep_message git_update stop |
| 535 | |
nnoble | 69ac39f | 2014-12-12 15:43:38 -0800 | [diff] [blame] | 536 | openssl_dep_message: |
| 537 | @echo |
| 538 | @echo "DEPENDENCY ERROR" |
| 539 | @echo |
| 540 | @echo "The target you are trying to run requires OpenSSL with ALPN support." |
| 541 | @echo "Your system doesn't have it, and neither does the third_party directory." |
| 542 | @echo |
| 543 | @echo "Please consult INSTALL to get more information." |
| 544 | @echo |
| 545 | @echo "If you need information about why these tests failed, run:" |
| 546 | @echo |
| 547 | @echo " make run_dep_checks" |
| 548 | @echo |
| 549 | |
Nicolas Noble | 5383062 | 2015-02-12 16:56:38 -0800 | [diff] [blame] | 550 | protobuf_dep_message: |
| 551 | @echo |
| 552 | @echo "DEPENDENCY ERROR" |
| 553 | @echo |
| 554 | @echo "The target you are trying to run requires protobuf 3.0.0+" |
| 555 | @echo "Your system doesn't have it, and neither does the third_party directory." |
| 556 | @echo |
| 557 | @echo "Please consult INSTALL to get more information." |
| 558 | @echo |
| 559 | @echo "If you need information about why these tests failed, run:" |
| 560 | @echo |
| 561 | @echo " make run_dep_checks" |
| 562 | @echo |
| 563 | |
| 564 | protoc_dep_message: |
| 565 | @echo |
| 566 | @echo "DEPENDENCY ERROR" |
| 567 | @echo |
| 568 | @echo "The target you are trying to run requires protobuf-compiler 3.0.0+" |
| 569 | @echo "Your system doesn't have it, and neither does the third_party directory." |
| 570 | @echo |
| 571 | @echo "Please consult INSTALL to get more information." |
| 572 | @echo |
| 573 | @echo "If you need information about why these tests failed, run:" |
| 574 | @echo |
| 575 | @echo " make run_dep_checks" |
| 576 | @echo |
| 577 | |
nnoble | 69ac39f | 2014-12-12 15:43:38 -0800 | [diff] [blame] | 578 | stop: |
| 579 | @false |
| 580 | |
ctiller | 09cb6d5 | 2014-12-19 17:38:22 -0800 | [diff] [blame] | 581 | % for tgt in targets: |
Craig Tiller | 61b910f | 2015-02-15 10:54:07 -0800 | [diff] [blame] | 582 | ${tgt.name}: $(BINDIR)/$(CONFIG)/${tgt.name} |
ctiller | 09cb6d5 | 2014-12-19 17:38:22 -0800 | [diff] [blame] | 583 | % endfor |
| 584 | |
nnoble | 69ac39f | 2014-12-12 15:43:38 -0800 | [diff] [blame] | 585 | run_dep_checks: |
nnoble | 69ac39f | 2014-12-12 15:43:38 -0800 | [diff] [blame] | 586 | $(OPENSSL_ALPN_CHECK_CMD) || true |
| 587 | $(ZLIB_CHECK_CMD) || true |
Nicolas Noble | 5383062 | 2015-02-12 16:56:38 -0800 | [diff] [blame] | 588 | $(PERFTOOLS_CHECK_CMD) || true |
| 589 | $(PROTOBUF_CHECK_CMD) || true |
| 590 | $(PROTOC_CHECK_CMD) || true |
nnoble | 69ac39f | 2014-12-12 15:43:38 -0800 | [diff] [blame] | 591 | |
Craig Tiller | 61b910f | 2015-02-15 10:54:07 -0800 | [diff] [blame] | 592 | $(LIBDIR)/$(CONFIG)/zlib/libz.a: |
Nicolas "Pixel" Noble | 17f2b59 | 2015-01-16 07:09:10 +0100 | [diff] [blame] | 593 | $(E) "[MAKE] Building zlib" |
Nicolas Noble | f868118 | 2015-03-18 14:25:44 -0700 | [diff] [blame] | 594 | $(Q)(cd third_party/zlib ; CC="$(CC)" CFLAGS="$(PIC_CPPFLAGS) -fvisibility=hidden $(CPPFLAGS_$(CONFIG))" ./configure --static) |
Nicolas "Pixel" Noble | 17f2b59 | 2015-01-16 07:09:10 +0100 | [diff] [blame] | 595 | $(Q)$(MAKE) -C third_party/zlib clean |
| 596 | $(Q)$(MAKE) -C third_party/zlib |
Craig Tiller | 61b910f | 2015-02-15 10:54:07 -0800 | [diff] [blame] | 597 | $(Q)mkdir -p $(LIBDIR)/$(CONFIG)/zlib |
| 598 | $(Q)cp third_party/zlib/libz.a $(LIBDIR)/$(CONFIG)/zlib |
nnoble | 69ac39f | 2014-12-12 15:43:38 -0800 | [diff] [blame] | 599 | |
Craig Tiller | 61b910f | 2015-02-15 10:54:07 -0800 | [diff] [blame] | 600 | $(LIBDIR)/$(CONFIG)/openssl/libssl.a: |
Craig Tiller | b4ee3b5 | 2015-01-21 16:22:50 -0800 | [diff] [blame] | 601 | $(E) "[MAKE] Building openssl for $(SYSTEM)" |
| 602 | ifeq ($(SYSTEM),Darwin) |
Nicolas Noble | f868118 | 2015-03-18 14:25:44 -0700 | [diff] [blame] | 603 | $(Q)(cd third_party/openssl ; CC="$(CC) $(PIC_CPPFLAGS) -fvisibility=hidden $(CPPFLAGS_$(CONFIG)) $(OPENSSL_CFLAGS_$(CONFIG))" ./Configure darwin64-x86_64-cc) |
Craig Tiller | b4ee3b5 | 2015-01-21 16:22:50 -0800 | [diff] [blame] | 604 | else |
Nicolas Noble | f868118 | 2015-03-18 14:25:44 -0700 | [diff] [blame] | 605 | ifeq ($(SYSTEM),MINGW32) |
| 606 | @echo "We currently don't have a good way to compile OpenSSL in-place under msys." |
| 607 | @echo "Please provide an ALPN-capable OpenSSL in your mingw32 system." |
| 608 | @echo |
| 609 | @echo "Note that you can find a compatible version of the libraries here:" |
| 610 | @echo |
| 611 | @echo "http://slproweb.com/products/Win32OpenSSL.html" |
| 612 | @echo |
| 613 | @echo "If you decide to install that one, take the full version. The light" |
| 614 | @echo "version only contains compiled DLLs, without the development files." |
| 615 | @echo |
| 616 | @echo "When installing, chose to copy the OpenSSL dlls to the OpenSSL binaries" |
| 617 | @echo "directory. This way we'll link to them directly." |
| 618 | @echo |
| 619 | @echo "You can then re-start the build the following way:" |
| 620 | @echo |
| 621 | @echo " CPPFLAGS=-I/c/OpenSSL-Win64/include LDFLAGS=-L/c/OpenSSL-Win64 make" |
| 622 | @false |
| 623 | else |
| 624 | $(Q)(cd third_party/openssl ; CC="$(CC) $(PIC_CPPFLAGS) -fvisibility=hidden $(CPPFLAGS_$(CONFIG)) $(OPENSSL_CFLAGS_$(CONFIG))" ./config no-asm $(OPENSSL_CONFIG_$(CONFIG))) |
| 625 | endif |
Craig Tiller | b4ee3b5 | 2015-01-21 16:22:50 -0800 | [diff] [blame] | 626 | endif |
Nicolas "Pixel" Noble | 17f2b59 | 2015-01-16 07:09:10 +0100 | [diff] [blame] | 627 | $(Q)$(MAKE) -C third_party/openssl clean |
| 628 | $(Q)$(MAKE) -C third_party/openssl build_crypto build_ssl |
Craig Tiller | 61b910f | 2015-02-15 10:54:07 -0800 | [diff] [blame] | 629 | $(Q)mkdir -p $(LIBDIR)/$(CONFIG)/openssl |
| 630 | $(Q)cp third_party/openssl/libssl.a third_party/openssl/libcrypto.a $(LIBDIR)/$(CONFIG)/openssl |
nnoble | 69ac39f | 2014-12-12 15:43:38 -0800 | [diff] [blame] | 631 | |
Nicolas Noble | 5383062 | 2015-02-12 16:56:38 -0800 | [diff] [blame] | 632 | third_party/protobuf/configure: |
| 633 | $(E) "[AUTOGEN] Preparing protobuf" |
| 634 | $(Q)(cd third_party/protobuf ; autoreconf -f -i -Wall,no-obsolete) |
| 635 | |
Craig Tiller | 61b910f | 2015-02-15 10:54:07 -0800 | [diff] [blame] | 636 | $(LIBDIR)/$(CONFIG)/protobuf/libprotobuf.a: third_party/protobuf/configure |
Nicolas Noble | 5383062 | 2015-02-12 16:56:38 -0800 | [diff] [blame] | 637 | $(E) "[MAKE] Building protobuf" |
Craig Tiller | cf133f4 | 2015-02-26 14:05:56 -0800 | [diff] [blame] | 638 | ifeq ($(HAVE_CXX11),true) |
Nicolas Noble | f868118 | 2015-03-18 14:25:44 -0700 | [diff] [blame] | 639 | $(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 Tiller | cf133f4 | 2015-02-26 14:05:56 -0800 | [diff] [blame] | 640 | else |
Nicolas Noble | f868118 | 2015-03-18 14:25:44 -0700 | [diff] [blame] | 641 | $(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 Tiller | cf133f4 | 2015-02-26 14:05:56 -0800 | [diff] [blame] | 642 | endif |
Nicolas Noble | 5383062 | 2015-02-12 16:56:38 -0800 | [diff] [blame] | 643 | $(Q)$(MAKE) -C third_party/protobuf clean |
| 644 | $(Q)$(MAKE) -C third_party/protobuf |
Craig Tiller | 61b910f | 2015-02-15 10:54:07 -0800 | [diff] [blame] | 645 | $(Q)mkdir -p $(LIBDIR)/$(CONFIG)/protobuf |
| 646 | $(Q)mkdir -p $(BINDIR)/$(CONFIG)/protobuf |
| 647 | $(Q)cp third_party/protobuf/src/.libs/libprotoc.a $(LIBDIR)/$(CONFIG)/protobuf |
| 648 | $(Q)cp third_party/protobuf/src/.libs/libprotobuf.a $(LIBDIR)/$(CONFIG)/protobuf |
| 649 | $(Q)cp third_party/protobuf/src/protoc $(BINDIR)/$(CONFIG)/protobuf |
Nicolas Noble | 5383062 | 2015-02-12 16:56:38 -0800 | [diff] [blame] | 650 | |
nnoble | 29e1d29 | 2014-12-01 10:27:40 -0800 | [diff] [blame] | 651 | static: static_c static_cxx |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 652 | |
Craig Tiller | 12c8209 | 2015-01-15 08:45:56 -0800 | [diff] [blame] | 653 | static_c: \ |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 654 | % for lib in libs: |
Craig Tiller | 59140fc | 2015-01-18 10:12:17 -0800 | [diff] [blame] | 655 | % if lib.build == 'all' and lib.language == 'c': |
Craig Tiller | 61b910f | 2015-02-15 10:54:07 -0800 | [diff] [blame] | 656 | $(LIBDIR)/$(CONFIG)/lib${lib.name}.a\ |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 657 | % endif |
| 658 | % endfor |
| 659 | |
| 660 | |
Craig Tiller | 12c8209 | 2015-01-15 08:45:56 -0800 | [diff] [blame] | 661 | static_cxx: \ |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 662 | % for lib in libs: |
Craig Tiller | 59140fc | 2015-01-18 10:12:17 -0800 | [diff] [blame] | 663 | % if lib.build == 'all' and lib.language == 'c++': |
Craig Tiller | 61b910f | 2015-02-15 10:54:07 -0800 | [diff] [blame] | 664 | $(LIBDIR)/$(CONFIG)/lib${lib.name}.a\ |
nnoble | 29e1d29 | 2014-12-01 10:27:40 -0800 | [diff] [blame] | 665 | % endif |
| 666 | % endfor |
| 667 | |
| 668 | |
| 669 | shared: shared_c shared_cxx |
| 670 | |
Craig Tiller | 12c8209 | 2015-01-15 08:45:56 -0800 | [diff] [blame] | 671 | shared_c: \ |
nnoble | 29e1d29 | 2014-12-01 10:27:40 -0800 | [diff] [blame] | 672 | % for lib in libs: |
Craig Tiller | 59140fc | 2015-01-18 10:12:17 -0800 | [diff] [blame] | 673 | % if lib.build == 'all' and lib.language == 'c': |
Craig Tiller | 61b910f | 2015-02-15 10:54:07 -0800 | [diff] [blame] | 674 | $(LIBDIR)/$(CONFIG)/lib${lib.name}.$(SHARED_EXT)\ |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 675 | % endif |
| 676 | % endfor |
| 677 | |
| 678 | |
Craig Tiller | 12c8209 | 2015-01-15 08:45:56 -0800 | [diff] [blame] | 679 | shared_cxx: \ |
nnoble | 29e1d29 | 2014-12-01 10:27:40 -0800 | [diff] [blame] | 680 | % for lib in libs: |
Craig Tiller | 59140fc | 2015-01-18 10:12:17 -0800 | [diff] [blame] | 681 | % if lib.build == 'all' and lib.language == 'c++': |
Craig Tiller | 61b910f | 2015-02-15 10:54:07 -0800 | [diff] [blame] | 682 | $(LIBDIR)/$(CONFIG)/lib${lib.name}.$(SHARED_EXT)\ |
nnoble | 29e1d29 | 2014-12-01 10:27:40 -0800 | [diff] [blame] | 683 | % endif |
| 684 | % endfor |
| 685 | |
| 686 | |
Jan Tattermusch | 2ec0b3e | 2015-02-18 15:03:12 -0800 | [diff] [blame] | 687 | shared_csharp: shared_c \ |
| 688 | % for lib in libs: |
| 689 | % if lib.build == 'all' and lib.language == 'csharp': |
| 690 | $(LIBDIR)/$(CONFIG)/lib${lib.name}.$(SHARED_EXT)\ |
| 691 | % endif |
| 692 | % endfor |
| 693 | |
| 694 | grpc_csharp_ext: shared_csharp |
| 695 | |
Nicolas "Pixel" Noble | 522d712 | 2015-02-19 01:28:02 +0100 | [diff] [blame] | 696 | plugins: $(PROTOC_PLUGINS) |
| 697 | |
nnoble | 29e1d29 | 2014-12-01 10:27:40 -0800 | [diff] [blame] | 698 | privatelibs: privatelibs_c privatelibs_cxx |
| 699 | |
Craig Tiller | 12c8209 | 2015-01-15 08:45:56 -0800 | [diff] [blame] | 700 | privatelibs_c: \ |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 701 | % for lib in libs: |
Craig Tiller | 59140fc | 2015-01-18 10:12:17 -0800 | [diff] [blame] | 702 | % if lib.build == 'private' and lib.language == 'c': |
Craig Tiller | 61b910f | 2015-02-15 10:54:07 -0800 | [diff] [blame] | 703 | $(LIBDIR)/$(CONFIG)/lib${lib.name}.a\ |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 704 | % endif |
| 705 | % endfor |
| 706 | |
| 707 | |
Craig Tiller | 12c8209 | 2015-01-15 08:45:56 -0800 | [diff] [blame] | 708 | privatelibs_cxx: \ |
nnoble | 29e1d29 | 2014-12-01 10:27:40 -0800 | [diff] [blame] | 709 | % for lib in libs: |
Craig Tiller | 59140fc | 2015-01-18 10:12:17 -0800 | [diff] [blame] | 710 | % if lib.build == 'private' and lib.language == 'c++': |
Craig Tiller | 61b910f | 2015-02-15 10:54:07 -0800 | [diff] [blame] | 711 | $(LIBDIR)/$(CONFIG)/lib${lib.name}.a\ |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 712 | % endif |
| 713 | % endfor |
| 714 | |
| 715 | |
nnoble | 29e1d29 | 2014-12-01 10:27:40 -0800 | [diff] [blame] | 716 | buildtests: buildtests_c buildtests_cxx |
| 717 | |
Craig Tiller | 12c8209 | 2015-01-15 08:45:56 -0800 | [diff] [blame] | 718 | buildtests_c: privatelibs_c\ |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 719 | % for tgt in targets: |
Craig Tiller | 59140fc | 2015-01-18 10:12:17 -0800 | [diff] [blame] | 720 | % if tgt.build == 'test' and not tgt.language == 'c++': |
Craig Tiller | 61b910f | 2015-02-15 10:54:07 -0800 | [diff] [blame] | 721 | $(BINDIR)/$(CONFIG)/${tgt.name}\ |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 722 | % endif |
| 723 | % endfor |
| 724 | |
| 725 | |
Craig Tiller | 12c8209 | 2015-01-15 08:45:56 -0800 | [diff] [blame] | 726 | buildtests_cxx: privatelibs_cxx\ |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 727 | % for tgt in targets: |
Craig Tiller | 59140fc | 2015-01-18 10:12:17 -0800 | [diff] [blame] | 728 | % if tgt.build == 'test' and tgt.language == 'c++': |
Craig Tiller | 61b910f | 2015-02-15 10:54:07 -0800 | [diff] [blame] | 729 | $(BINDIR)/$(CONFIG)/${tgt.name}\ |
nnoble | 29e1d29 | 2014-12-01 10:27:40 -0800 | [diff] [blame] | 730 | % endif |
| 731 | % endfor |
| 732 | |
| 733 | |
nnoble | 85a4926 | 2014-12-08 18:14:03 -0800 | [diff] [blame] | 734 | test: test_c test_cxx |
nnoble | 29e1d29 | 2014-12-01 10:27:40 -0800 | [diff] [blame] | 735 | |
nnoble | 85a4926 | 2014-12-08 18:14:03 -0800 | [diff] [blame] | 736 | test_c: buildtests_c |
nnoble | 29e1d29 | 2014-12-01 10:27:40 -0800 | [diff] [blame] | 737 | % for tgt in targets: |
Craig Tiller | 59140fc | 2015-01-18 10:12:17 -0800 | [diff] [blame] | 738 | % if tgt.build == 'test' and tgt.get('run', True) and not tgt.language == 'c++': |
nnoble | 29e1d29 | 2014-12-01 10:27:40 -0800 | [diff] [blame] | 739 | $(E) "[RUN] Testing ${tgt.name}" |
Craig Tiller | da224d6 | 2015-02-15 11:01:58 -0800 | [diff] [blame] | 740 | $(Q) $(BINDIR)/$(CONFIG)/${tgt.name} || ( echo test ${tgt.name} failed ; exit 1 ) |
nnoble | 29e1d29 | 2014-12-01 10:27:40 -0800 | [diff] [blame] | 741 | % endif |
| 742 | % endfor |
| 743 | |
| 744 | |
nnoble | 85a4926 | 2014-12-08 18:14:03 -0800 | [diff] [blame] | 745 | test_cxx: buildtests_cxx |
nnoble | 29e1d29 | 2014-12-01 10:27:40 -0800 | [diff] [blame] | 746 | % for tgt in targets: |
Craig Tiller | 59140fc | 2015-01-18 10:12:17 -0800 | [diff] [blame] | 747 | % if tgt.build == 'test' and tgt.get('run', True) and tgt.language == 'c++': |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 748 | $(E) "[RUN] Testing ${tgt.name}" |
Craig Tiller | da224d6 | 2015-02-15 11:01:58 -0800 | [diff] [blame] | 749 | $(Q) $(BINDIR)/$(CONFIG)/${tgt.name} || ( echo test ${tgt.name} failed ; exit 1 ) |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 750 | % endif |
| 751 | % endfor |
| 752 | |
| 753 | |
Nicolas "Pixel" Noble | 051a28f | 2015-03-17 22:54:54 +0100 | [diff] [blame] | 754 | test_python: static_c |
| 755 | $(E) "[RUN] Testing python code" |
| 756 | $(Q) tools/run_tests/run_tests.py -lpython -c$(CONFIG) |
| 757 | |
| 758 | |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 759 | tools: privatelibs\ |
| 760 | % for tgt in targets: |
| 761 | % if tgt.build == 'tool': |
Craig Tiller | 61b910f | 2015-02-15 10:54:07 -0800 | [diff] [blame] | 762 | $(BINDIR)/$(CONFIG)/${tgt.name}\ |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 763 | % endif |
| 764 | % endfor |
| 765 | |
| 766 | |
| 767 | buildbenchmarks: privatelibs\ |
| 768 | % for tgt in targets: |
| 769 | % if tgt.build == 'benchmark': |
Craig Tiller | 61b910f | 2015-02-15 10:54:07 -0800 | [diff] [blame] | 770 | $(BINDIR)/$(CONFIG)/${tgt.name}\ |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 771 | % endif |
| 772 | % endfor |
| 773 | |
| 774 | |
| 775 | benchmarks: buildbenchmarks |
| 776 | |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 777 | strip: strip-static strip-shared |
| 778 | |
nnoble | 20e2e3f | 2014-12-16 15:37:57 -0800 | [diff] [blame] | 779 | strip-static: strip-static_c strip-static_cxx |
| 780 | |
| 781 | strip-shared: strip-shared_c strip-shared_cxx |
| 782 | |
Nicolas Noble | 047b727 | 2015-01-16 13:55:05 -0800 | [diff] [blame] | 783 | |
| 784 | # TODO(nnoble): the strip target is stripping in-place, instead |
| 785 | # of copying files in a temporary folder. |
| 786 | # This prevents proper debugging after running make install. |
| 787 | |
nnoble | 85a4926 | 2014-12-08 18:14:03 -0800 | [diff] [blame] | 788 | strip-static_c: static_c |
Nicolas "Pixel" Noble | 3a2551c | 2015-01-29 21:33:32 +0100 | [diff] [blame] | 789 | ifeq ($(CONFIG),opt) |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 790 | % for lib in libs: |
Craig Tiller | 59140fc | 2015-01-18 10:12:17 -0800 | [diff] [blame] | 791 | % if lib.language == "c": |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 792 | % if lib.build == "all": |
| 793 | $(E) "[STRIP] Stripping lib${lib.name}.a" |
Craig Tiller | 61b910f | 2015-02-15 10:54:07 -0800 | [diff] [blame] | 794 | $(Q) $(STRIP) $(LIBDIR)/$(CONFIG)/lib${lib.name}.a |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 795 | % endif |
nnoble | 85a4926 | 2014-12-08 18:14:03 -0800 | [diff] [blame] | 796 | % endif |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 797 | % endfor |
Nicolas "Pixel" Noble | 3a2551c | 2015-01-29 21:33:32 +0100 | [diff] [blame] | 798 | endif |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 799 | |
nnoble | 85a4926 | 2014-12-08 18:14:03 -0800 | [diff] [blame] | 800 | strip-static_cxx: static_cxx |
Nicolas "Pixel" Noble | 3a2551c | 2015-01-29 21:33:32 +0100 | [diff] [blame] | 801 | ifeq ($(CONFIG),opt) |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 802 | % for lib in libs: |
Craig Tiller | 59140fc | 2015-01-18 10:12:17 -0800 | [diff] [blame] | 803 | % if lib.language == "c++": |
nnoble | 85a4926 | 2014-12-08 18:14:03 -0800 | [diff] [blame] | 804 | % if lib.build == "all": |
| 805 | $(E) "[STRIP] Stripping lib${lib.name}.a" |
Craig Tiller | 61b910f | 2015-02-15 10:54:07 -0800 | [diff] [blame] | 806 | $(Q) $(STRIP) $(LIBDIR)/$(CONFIG)/lib${lib.name}.a |
nnoble | 85a4926 | 2014-12-08 18:14:03 -0800 | [diff] [blame] | 807 | % endif |
| 808 | % endif |
| 809 | % endfor |
Nicolas "Pixel" Noble | 3a2551c | 2015-01-29 21:33:32 +0100 | [diff] [blame] | 810 | endif |
nnoble | 85a4926 | 2014-12-08 18:14:03 -0800 | [diff] [blame] | 811 | |
| 812 | strip-shared_c: shared_c |
Nicolas "Pixel" Noble | 3a2551c | 2015-01-29 21:33:32 +0100 | [diff] [blame] | 813 | ifeq ($(CONFIG),opt) |
nnoble | 85a4926 | 2014-12-08 18:14:03 -0800 | [diff] [blame] | 814 | % for lib in libs: |
Craig Tiller | 59140fc | 2015-01-18 10:12:17 -0800 | [diff] [blame] | 815 | % if lib.language == "c": |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 816 | % if lib.build == "all": |
| 817 | $(E) "[STRIP] Stripping lib${lib.name}.so" |
Craig Tiller | 61b910f | 2015-02-15 10:54:07 -0800 | [diff] [blame] | 818 | $(Q) $(STRIP) $(LIBDIR)/$(CONFIG)/lib${lib.name}.$(SHARED_EXT) |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 819 | % endif |
nnoble | 85a4926 | 2014-12-08 18:14:03 -0800 | [diff] [blame] | 820 | % endif |
| 821 | % endfor |
Nicolas "Pixel" Noble | 3a2551c | 2015-01-29 21:33:32 +0100 | [diff] [blame] | 822 | endif |
nnoble | 85a4926 | 2014-12-08 18:14:03 -0800 | [diff] [blame] | 823 | |
| 824 | strip-shared_cxx: shared_cxx |
Nicolas "Pixel" Noble | 3a2551c | 2015-01-29 21:33:32 +0100 | [diff] [blame] | 825 | ifeq ($(CONFIG),opt) |
nnoble | 85a4926 | 2014-12-08 18:14:03 -0800 | [diff] [blame] | 826 | % for lib in libs: |
Craig Tiller | 59140fc | 2015-01-18 10:12:17 -0800 | [diff] [blame] | 827 | % if lib.language == "c++": |
nnoble | 85a4926 | 2014-12-08 18:14:03 -0800 | [diff] [blame] | 828 | % if lib.build == "all": |
| 829 | $(E) "[STRIP] Stripping lib${lib.name}.so" |
Craig Tiller | 61b910f | 2015-02-15 10:54:07 -0800 | [diff] [blame] | 830 | $(Q) $(STRIP) $(LIBDIR)/$(CONFIG)/lib${lib.name}.$(SHARED_EXT) |
nnoble | 85a4926 | 2014-12-08 18:14:03 -0800 | [diff] [blame] | 831 | % endif |
| 832 | % endif |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 833 | % endfor |
Nicolas "Pixel" Noble | 3a2551c | 2015-01-29 21:33:32 +0100 | [diff] [blame] | 834 | endif |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 835 | |
Jan Tattermusch | 2ec0b3e | 2015-02-18 15:03:12 -0800 | [diff] [blame] | 836 | strip-shared_csharp: shared_csharp |
| 837 | ifeq ($(CONFIG),opt) |
| 838 | % for lib in libs: |
| 839 | % if lib.language == "csharp": |
| 840 | % if lib.build == "all": |
| 841 | $(E) "[STRIP] Stripping lib${lib.name}.so" |
| 842 | $(Q) $(STRIP) $(LIBDIR)/$(CONFIG)/lib${lib.name}.$(SHARED_EXT) |
| 843 | % endif |
| 844 | % endif |
| 845 | % endfor |
| 846 | endif |
| 847 | |
nnoble | 72309c6 | 2014-12-12 11:42:26 -0800 | [diff] [blame] | 848 | % for p in protos: |
Nicolas Noble | 5383062 | 2015-02-12 16:56:38 -0800 | [diff] [blame] | 849 | ifeq ($(NO_PROTOC),true) |
Craig Tiller | 61b910f | 2015-02-15 10:54:07 -0800 | [diff] [blame] | 850 | $(GENDIR)/${p}.pb.cc: protoc_dep_error |
Nicolas "Pixel" Noble | 0caebbf | 2015-04-09 23:08:51 +0200 | [diff] [blame] | 851 | $(GENDIR)/${p}.grpc.pb.cc: protoc_dep_error |
Nicolas Noble | 5383062 | 2015-02-12 16:56:38 -0800 | [diff] [blame] | 852 | else |
Craig Tiller | 61b910f | 2015-02-15 10:54:07 -0800 | [diff] [blame] | 853 | $(GENDIR)/${p}.pb.cc: ${p}.proto $(PROTOBUF_DEP) $(PROTOC_PLUGINS) |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 854 | $(E) "[PROTOC] Generating protobuf CC file from $<" |
| 855 | $(Q) mkdir -p `dirname $@` |
Nicolas "Pixel" Noble | 0caebbf | 2015-04-09 23:08:51 +0200 | [diff] [blame] | 856 | $(Q) $(PROTOC) --cpp_out=$(GENDIR) $< |
| 857 | |
| 858 | $(GENDIR)/${p}.grpc.pb.cc: ${p}.proto $(PROTOBUF_DEP) $(PROTOC_PLUGINS) |
| 859 | $(E) "[GRPC] Generating gRPC's protobuf service CC file from $<" |
| 860 | $(Q) mkdir -p `dirname $@` |
| 861 | $(Q) $(PROTOC) --grpc_out=$(GENDIR) --plugin=protoc-gen-grpc=$(BINDIR)/$(CONFIG)/grpc_cpp_plugin $< |
Nicolas Noble | 5383062 | 2015-02-12 16:56:38 -0800 | [diff] [blame] | 862 | endif |
nnoble | 72309c6 | 2014-12-12 11:42:26 -0800 | [diff] [blame] | 863 | |
| 864 | % endfor |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 865 | |
Craig Tiller | 61b910f | 2015-02-15 10:54:07 -0800 | [diff] [blame] | 866 | $(OBJDIR)/$(CONFIG)/%.o : %.c |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 867 | $(E) "[C] Compiling $<" |
| 868 | $(Q) mkdir -p `dirname $@` |
Craig Tiller | 12c8209 | 2015-01-15 08:45:56 -0800 | [diff] [blame] | 869 | $(Q) $(CC) $(CFLAGS) $(CPPFLAGS) -MMD -MF $(addsuffix .dep, $(basename $@)) -c -o $@ $< |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 870 | |
Craig Tiller | 61b910f | 2015-02-15 10:54:07 -0800 | [diff] [blame] | 871 | $(OBJDIR)/$(CONFIG)/%.o : $(GENDIR)/%.pb.cc |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 872 | $(E) "[CXX] Compiling $<" |
| 873 | $(Q) mkdir -p `dirname $@` |
Craig Tiller | 12c8209 | 2015-01-15 08:45:56 -0800 | [diff] [blame] | 874 | $(Q) $(CXX) $(CXXFLAGS) $(CPPFLAGS) -MMD -MF $(addsuffix .dep, $(basename $@)) -c -o $@ $< |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 875 | |
Craig Tiller | 61b910f | 2015-02-15 10:54:07 -0800 | [diff] [blame] | 876 | $(OBJDIR)/$(CONFIG)/src/compiler/%.o : src/compiler/%.cc |
nnoble | 72309c6 | 2014-12-12 11:42:26 -0800 | [diff] [blame] | 877 | $(E) "[HOSTCXX] Compiling $<" |
| 878 | $(Q) mkdir -p `dirname $@` |
Craig Tiller | 12c8209 | 2015-01-15 08:45:56 -0800 | [diff] [blame] | 879 | $(Q) $(HOST_CXX) $(HOST_CXXFLAGS) $(HOST_CPPFLAGS) -MMD -MF $(addsuffix .dep, $(basename $@)) -c -o $@ $< |
nnoble | 72309c6 | 2014-12-12 11:42:26 -0800 | [diff] [blame] | 880 | |
Craig Tiller | 61b910f | 2015-02-15 10:54:07 -0800 | [diff] [blame] | 881 | $(OBJDIR)/$(CONFIG)/%.o : %.cc |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 882 | $(E) "[CXX] Compiling $<" |
| 883 | $(Q) mkdir -p `dirname $@` |
Craig Tiller | 12c8209 | 2015-01-15 08:45:56 -0800 | [diff] [blame] | 884 | $(Q) $(CXX) $(CXXFLAGS) $(CPPFLAGS) -MMD -MF $(addsuffix .dep, $(basename $@)) -c -o $@ $< |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 885 | |
| 886 | |
Nicolas "Pixel" Noble | 161ea23 | 2015-02-22 05:48:53 +0100 | [diff] [blame] | 887 | install: install_c install_cxx install-plugins install-certs verify-install |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 888 | |
nnoble | 85a4926 | 2014-12-08 18:14:03 -0800 | [diff] [blame] | 889 | install_c: install-headers_c install-static_c install-shared_c |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 890 | |
nnoble | 85a4926 | 2014-12-08 18:14:03 -0800 | [diff] [blame] | 891 | install_cxx: install-headers_cxx install-static_cxx install-shared_cxx |
| 892 | |
Jan Tattermusch | 2ec0b3e | 2015-02-18 15:03:12 -0800 | [diff] [blame] | 893 | install_csharp: install-shared_csharp install_c |
| 894 | |
| 895 | install_grpc_csharp_ext: install_csharp |
| 896 | |
nnoble | 85a4926 | 2014-12-08 18:14:03 -0800 | [diff] [blame] | 897 | install-headers: install-headers_c install-headers_cxx |
| 898 | |
| 899 | install-headers_c: |
| 900 | $(E) "[INSTALL] Installing public C headers" |
Nicolas "Pixel" Noble | 932d5d3 | 2015-02-21 02:15:34 +0100 | [diff] [blame] | 901 | $(Q) $(foreach h, $(PUBLIC_HEADERS_C), $(INSTALL) -d $(prefix)/$(dir $(h)) && ) exit 0 || exit 1 |
nnoble | 85a4926 | 2014-12-08 18:14:03 -0800 | [diff] [blame] | 902 | $(Q) $(foreach h, $(PUBLIC_HEADERS_C), $(INSTALL) $(h) $(prefix)/$(h) && ) exit 0 || exit 1 |
| 903 | |
| 904 | install-headers_cxx: |
| 905 | $(E) "[INSTALL] Installing public C++ headers" |
Nicolas "Pixel" Noble | 932d5d3 | 2015-02-21 02:15:34 +0100 | [diff] [blame] | 906 | $(Q) $(foreach h, $(PUBLIC_HEADERS_CXX), $(INSTALL) -d $(prefix)/$(dir $(h)) && ) exit 0 || exit 1 |
nnoble | 85a4926 | 2014-12-08 18:14:03 -0800 | [diff] [blame] | 907 | $(Q) $(foreach h, $(PUBLIC_HEADERS_CXX), $(INSTALL) $(h) $(prefix)/$(h) && ) exit 0 || exit 1 |
| 908 | |
| 909 | install-static: install-static_c install-static_cxx |
| 910 | |
| 911 | install-static_c: static_c strip-static_c |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 912 | % for lib in libs: |
Craig Tiller | 59140fc | 2015-01-18 10:12:17 -0800 | [diff] [blame] | 913 | % if lib.language == "c": |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 914 | % if lib.build == "all": |
| 915 | $(E) "[INSTALL] Installing lib${lib.name}.a" |
Nicolas "Pixel" Noble | 932d5d3 | 2015-02-21 02:15:34 +0100 | [diff] [blame] | 916 | $(Q) $(INSTALL) -d $(prefix)/lib |
Craig Tiller | 61b910f | 2015-02-15 10:54:07 -0800 | [diff] [blame] | 917 | $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/lib${lib.name}.a $(prefix)/lib/lib${lib.name}.a |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 918 | % endif |
nnoble | 85a4926 | 2014-12-08 18:14:03 -0800 | [diff] [blame] | 919 | % endif |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 920 | % endfor |
| 921 | |
nnoble | 85a4926 | 2014-12-08 18:14:03 -0800 | [diff] [blame] | 922 | install-static_cxx: static_cxx strip-static_cxx |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 923 | % for lib in libs: |
Craig Tiller | 59140fc | 2015-01-18 10:12:17 -0800 | [diff] [blame] | 924 | % if lib.language == "c++": |
nnoble | 85a4926 | 2014-12-08 18:14:03 -0800 | [diff] [blame] | 925 | % if lib.build == "all": |
| 926 | $(E) "[INSTALL] Installing lib${lib.name}.a" |
Nicolas "Pixel" Noble | 932d5d3 | 2015-02-21 02:15:34 +0100 | [diff] [blame] | 927 | $(Q) $(INSTALL) -d $(prefix)/lib |
Craig Tiller | 61b910f | 2015-02-15 10:54:07 -0800 | [diff] [blame] | 928 | $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/lib${lib.name}.a $(prefix)/lib/lib${lib.name}.a |
nnoble | 85a4926 | 2014-12-08 18:14:03 -0800 | [diff] [blame] | 929 | % endif |
| 930 | % endif |
| 931 | % endfor |
| 932 | |
Nicolas "Pixel" Noble | 522d712 | 2015-02-19 01:28:02 +0100 | [diff] [blame] | 933 | <%def name="install_shared(lang_filter)">\ |
nnoble | 85a4926 | 2014-12-08 18:14:03 -0800 | [diff] [blame] | 934 | % for lib in libs: |
Nicolas "Pixel" Noble | 522d712 | 2015-02-19 01:28:02 +0100 | [diff] [blame] | 935 | % if lib.language == lang_filter: |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 936 | % if lib.build == "all": |
nnoble | 5b7f32a | 2014-12-22 08:12:44 -0800 | [diff] [blame] | 937 | ifeq ($(SYSTEM),MINGW32) |
| 938 | $(E) "[INSTALL] Installing ${lib.name}.$(SHARED_EXT)" |
Nicolas "Pixel" Noble | 932d5d3 | 2015-02-21 02:15:34 +0100 | [diff] [blame] | 939 | $(Q) $(INSTALL) -d $(prefix)/lib |
Craig Tiller | 61b910f | 2015-02-15 10:54:07 -0800 | [diff] [blame] | 940 | $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/${lib.name}.$(SHARED_EXT) $(prefix)/lib/${lib.name}.$(SHARED_EXT) |
| 941 | $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/lib${lib.name}-imp.a $(prefix)/lib/lib${lib.name}-imp.a |
nnoble | 5b7f32a | 2014-12-22 08:12:44 -0800 | [diff] [blame] | 942 | else |
| 943 | $(E) "[INSTALL] Installing lib${lib.name}.$(SHARED_EXT)" |
Nicolas "Pixel" Noble | 932d5d3 | 2015-02-21 02:15:34 +0100 | [diff] [blame] | 944 | $(Q) $(INSTALL) -d $(prefix)/lib |
Craig Tiller | 61b910f | 2015-02-15 10:54:07 -0800 | [diff] [blame] | 945 | $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/lib${lib.name}.$(SHARED_EXT) $(prefix)/lib/lib${lib.name}.$(SHARED_EXT) |
Masood Malekghassemi | d1be74f | 2015-04-07 16:23:09 -0700 | [diff] [blame] | 946 | ifneq ($(SYSTEM),Darwin) |
Tim Emiola | 820e3d6 | 2015-04-10 09:11:50 -0700 | [diff] [blame] | 947 | $(Q) ln -sf lib${lib.name}.$(SHARED_EXT) $(prefix)/lib/lib${lib.name}.so.${settings.version.major} |
nnoble | 5b7f32a | 2014-12-22 08:12:44 -0800 | [diff] [blame] | 948 | $(Q) ln -sf lib${lib.name}.$(SHARED_EXT) $(prefix)/lib/lib${lib.name}.so |
| 949 | endif |
| 950 | endif |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 951 | % endif |
nnoble | 85a4926 | 2014-12-08 18:14:03 -0800 | [diff] [blame] | 952 | % endif |
| 953 | % endfor |
nnoble | 5b7f32a | 2014-12-22 08:12:44 -0800 | [diff] [blame] | 954 | ifneq ($(SYSTEM),MINGW32) |
| 955 | ifneq ($(SYSTEM),Darwin) |
Nicolas "Pixel" Noble | cc2b42a | 2015-02-20 00:42:21 +0100 | [diff] [blame] | 956 | $(Q) ldconfig || true |
nnoble | 5b7f32a | 2014-12-22 08:12:44 -0800 | [diff] [blame] | 957 | endif |
| 958 | endif |
Nicolas "Pixel" Noble | 522d712 | 2015-02-19 01:28:02 +0100 | [diff] [blame] | 959 | </%def> |
nnoble | 85a4926 | 2014-12-08 18:14:03 -0800 | [diff] [blame] | 960 | |
Nicolas "Pixel" Noble | 522d712 | 2015-02-19 01:28:02 +0100 | [diff] [blame] | 961 | install-shared_c: shared_c strip-shared_c |
| 962 | ${install_shared("c")} |
| 963 | |
| 964 | install-shared_cxx: shared_cxx strip-shared_cxx install-shared_c |
| 965 | ${install_shared("c++")} |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 966 | |
Jan Tattermusch | 2ec0b3e | 2015-02-18 15:03:12 -0800 | [diff] [blame] | 967 | install-shared_csharp: shared_csharp strip-shared_csharp |
Nicolas "Pixel" Noble | 522d712 | 2015-02-19 01:28:02 +0100 | [diff] [blame] | 968 | ${install_shared("csharp")} |
| 969 | |
Nicolas "Pixel" Noble | 522d712 | 2015-02-19 01:28:02 +0100 | [diff] [blame] | 970 | install-plugins: $(PROTOC_PLUGINS) |
| 971 | ifeq ($(SYSTEM),MINGW32) |
| 972 | $(Q) false |
| 973 | else |
| 974 | $(E) "[INSTALL] Installing grpc protoc plugins" |
| 975 | % for tgt in targets: |
| 976 | % if tgt.build == 'protoc': |
Nicolas "Pixel" Noble | 932d5d3 | 2015-02-21 02:15:34 +0100 | [diff] [blame] | 977 | $(Q) $(INSTALL) -d $(prefix)/bin |
Nicolas "Pixel" Noble | 522d712 | 2015-02-19 01:28:02 +0100 | [diff] [blame] | 978 | $(Q) $(INSTALL) $(BINDIR)/$(CONFIG)/${tgt.name} $(prefix)/bin/${tgt.name} |
| 979 | % endif |
| 980 | % endfor |
| 981 | endif |
Jan Tattermusch | 2ec0b3e | 2015-02-18 15:03:12 -0800 | [diff] [blame] | 982 | |
Nicolas "Pixel" Noble | 161ea23 | 2015-02-22 05:48:53 +0100 | [diff] [blame] | 983 | install-certs: etc/roots.pem |
| 984 | $(E) "[INSTALL] Installing root certificates" |
| 985 | $(Q) $(INSTALL) -d $(prefix)/share/grpc |
| 986 | $(Q) $(INSTALL) etc/roots.pem $(prefix)/share/grpc/roots.pem |
| 987 | |
Nicolas "Pixel" Noble | 98ab998 | 2015-02-21 04:22:16 +0100 | [diff] [blame] | 988 | verify-install: |
Nicolas "Pixel" Noble | 2c23a72 | 2015-02-24 20:17:45 +0100 | [diff] [blame] | 989 | ifeq ($(INSTALL_OK),true) |
Nicolas "Pixel" Noble | 98ab998 | 2015-02-21 04:22:16 +0100 | [diff] [blame] | 990 | @echo "Your system looks ready to go." |
| 991 | @echo |
| 992 | else |
murgatroid99 | b618136 | 2015-03-02 14:32:25 -0800 | [diff] [blame] | 993 | @echo "We couldn't find protoc 3.0.0+ installed on your system. While this" |
Nicolas "Pixel" Noble | 98ab998 | 2015-02-21 04:22:16 +0100 | [diff] [blame] | 994 | @echo "won't prevent grpc from working, you won't be able to compile" |
| 995 | @echo "and run any meaningful code with it." |
| 996 | @echo |
| 997 | @echo |
| 998 | @echo "Please download and install protobuf 3.0.0+ from:" |
| 999 | @echo |
| 1000 | @echo " https://github.com/google/protobuf/releases" |
| 1001 | @echo |
murgatroid99 | b618136 | 2015-03-02 14:32:25 -0800 | [diff] [blame] | 1002 | @echo "Once you've done so, or if you think this message is in error," |
| 1003 | @echo "you can re-run this check by doing:" |
Nicolas "Pixel" Noble | 98ab998 | 2015-02-21 04:22:16 +0100 | [diff] [blame] | 1004 | @echo |
| 1005 | @echo " make verify-install" |
| 1006 | endif |
| 1007 | |
Craig Tiller | 3759e6f | 2015-01-15 08:13:11 -0800 | [diff] [blame] | 1008 | clean: |
Nicolas "Pixel" Noble | 522d712 | 2015-02-19 01:28:02 +0100 | [diff] [blame] | 1009 | $(E) "[CLEAN] Cleaning build directories." |
Craig Tiller | da224d6 | 2015-02-15 11:01:58 -0800 | [diff] [blame] | 1010 | $(Q) $(RM) -rf $(OBJDIR) $(LIBDIR) $(BINDIR) $(GENDIR) |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 1011 | |
| 1012 | |
| 1013 | # The various libraries |
| 1014 | |
| 1015 | % for lib in libs: |
| 1016 | ${makelib(lib)} |
| 1017 | % endfor |
| 1018 | |
| 1019 | |
nnoble | 69ac39f | 2014-12-12 15:43:38 -0800 | [diff] [blame] | 1020 | # All of the test targets, and protoc plugins |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 1021 | |
| 1022 | % for tgt in targets: |
| 1023 | ${maketarget(tgt)} |
| 1024 | % endfor |
| 1025 | |
| 1026 | <%def name="makelib(lib)"> |
| 1027 | LIB${lib.name.upper()}_SRC = \\ |
| 1028 | |
| 1029 | % for src in lib.src: |
nnoble | 72309c6 | 2014-12-12 11:42:26 -0800 | [diff] [blame] | 1030 | ${proto_to_cc(src)} \\ |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 1031 | |
| 1032 | % endfor |
| 1033 | |
| 1034 | % if "public_headers" in lib: |
Craig Tiller | 59140fc | 2015-01-18 10:12:17 -0800 | [diff] [blame] | 1035 | % if lib.language == "c++": |
nnoble | 85a4926 | 2014-12-08 18:14:03 -0800 | [diff] [blame] | 1036 | PUBLIC_HEADERS_CXX += \\ |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 1037 | |
nnoble | 85a4926 | 2014-12-08 18:14:03 -0800 | [diff] [blame] | 1038 | % else: |
| 1039 | PUBLIC_HEADERS_C += \\ |
| 1040 | |
| 1041 | % endif |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 1042 | % for hdr in lib.public_headers: |
| 1043 | ${hdr} \\ |
| 1044 | |
| 1045 | % endfor |
| 1046 | % endif |
| 1047 | |
Craig Tiller | 61b910f | 2015-02-15 10:54:07 -0800 | [diff] [blame] | 1048 | LIB${lib.name.upper()}_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(LIB${lib.name.upper()}_SRC)))) |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 1049 | |
Nicolas Noble | 047b727 | 2015-01-16 13:55:05 -0800 | [diff] [blame] | 1050 | ## If the library requires OpenSSL with ALPN, let's add some restrictions. |
Nicolas "Pixel" Noble | 061690d | 2015-03-06 22:58:58 +0100 | [diff] [blame] | 1051 | % if lib.get('secure', 'check') == 'yes' or lib.get('secure', 'check') == 'check': |
nnoble | 69ac39f | 2014-12-12 15:43:38 -0800 | [diff] [blame] | 1052 | ifeq ($(NO_SECURE),true) |
| 1053 | |
Nicolas Noble | 047b727 | 2015-01-16 13:55:05 -0800 | [diff] [blame] | 1054 | # You can't build secure libraries if you don't have OpenSSL with ALPN. |
| 1055 | |
Craig Tiller | 61b910f | 2015-02-15 10:54:07 -0800 | [diff] [blame] | 1056 | $(LIBDIR)/$(CONFIG)/lib${lib.name}.a: openssl_dep_error |
nnoble | 69ac39f | 2014-12-12 15:43:38 -0800 | [diff] [blame] | 1057 | |
nnoble | 5b7f32a | 2014-12-22 08:12:44 -0800 | [diff] [blame] | 1058 | % if lib.build == "all": |
| 1059 | ifeq ($(SYSTEM),MINGW32) |
Craig Tiller | 61b910f | 2015-02-15 10:54:07 -0800 | [diff] [blame] | 1060 | $(LIBDIR)/$(CONFIG)/${lib.name}.$(SHARED_EXT): openssl_dep_error |
nnoble | 5b7f32a | 2014-12-22 08:12:44 -0800 | [diff] [blame] | 1061 | else |
Craig Tiller | 61b910f | 2015-02-15 10:54:07 -0800 | [diff] [blame] | 1062 | $(LIBDIR)/$(CONFIG)/lib${lib.name}.$(SHARED_EXT): openssl_dep_error |
nnoble | 5b7f32a | 2014-12-22 08:12:44 -0800 | [diff] [blame] | 1063 | endif |
| 1064 | % endif |
| 1065 | |
nnoble | 69ac39f | 2014-12-12 15:43:38 -0800 | [diff] [blame] | 1066 | else |
| 1067 | |
Nicolas Noble | 5383062 | 2015-02-12 16:56:38 -0800 | [diff] [blame] | 1068 | % if lib.language == 'c++': |
| 1069 | ifeq ($(NO_PROTOBUF),true) |
| 1070 | |
| 1071 | # You can't build a C++ library if you don't have protobuf - a bit overreached, but still okay. |
| 1072 | |
Craig Tiller | 61b910f | 2015-02-15 10:54:07 -0800 | [diff] [blame] | 1073 | $(LIBDIR)/$(CONFIG)/lib${lib.name}.a: protobuf_dep_error |
Nicolas Noble | 5383062 | 2015-02-12 16:56:38 -0800 | [diff] [blame] | 1074 | |
| 1075 | % if lib.build == "all": |
| 1076 | ifeq ($(SYSTEM),MINGW32) |
Craig Tiller | 61b910f | 2015-02-15 10:54:07 -0800 | [diff] [blame] | 1077 | $(LIBDIR)/$(CONFIG)/${lib.name}.$(SHARED_EXT): protobuf_dep_error |
Nicolas Noble | 5383062 | 2015-02-12 16:56:38 -0800 | [diff] [blame] | 1078 | else |
Craig Tiller | 61b910f | 2015-02-15 10:54:07 -0800 | [diff] [blame] | 1079 | $(LIBDIR)/$(CONFIG)/lib${lib.name}.$(SHARED_EXT): protobuf_dep_error |
Nicolas Noble | 5383062 | 2015-02-12 16:56:38 -0800 | [diff] [blame] | 1080 | endif |
| 1081 | % endif |
| 1082 | |
| 1083 | else |
| 1084 | % endif |
| 1085 | |
Craig Tiller | 61b910f | 2015-02-15 10:54:07 -0800 | [diff] [blame] | 1086 | $(LIBDIR)/$(CONFIG)/lib${lib.name}.a: $(ZLIB_DEP) $(OPENSSL_DEP)\ |
Nicolas Noble | 047b727 | 2015-01-16 13:55:05 -0800 | [diff] [blame] | 1087 | ## The else here corresponds to the if secure earlier. |
nnoble | 20e2e3f | 2014-12-16 15:37:57 -0800 | [diff] [blame] | 1088 | % else: |
Nicolas Noble | 5383062 | 2015-02-12 16:56:38 -0800 | [diff] [blame] | 1089 | % if lib.language == 'c++': |
| 1090 | ifeq ($(NO_PROTOBUF),true) |
| 1091 | |
| 1092 | # You can't build a C++ library if you don't have protobuf - a bit overreached, but still okay. |
| 1093 | |
Craig Tiller | 61b910f | 2015-02-15 10:54:07 -0800 | [diff] [blame] | 1094 | $(LIBDIR)/$(CONFIG)/lib${lib.name}.a: protobuf_dep_error |
Nicolas Noble | 5383062 | 2015-02-12 16:56:38 -0800 | [diff] [blame] | 1095 | |
| 1096 | % if lib.build == "all": |
| 1097 | ifeq ($(SYSTEM),MINGW32) |
Craig Tiller | 61b910f | 2015-02-15 10:54:07 -0800 | [diff] [blame] | 1098 | $(LIBDIR)/$(CONFIG)/${lib.name}.$(SHARED_EXT): protobuf_dep_error |
Nicolas Noble | 5383062 | 2015-02-12 16:56:38 -0800 | [diff] [blame] | 1099 | else |
Craig Tiller | 61b910f | 2015-02-15 10:54:07 -0800 | [diff] [blame] | 1100 | $(LIBDIR)/$(CONFIG)/lib${lib.name}.$(SHARED_EXT): protobuf_dep_error |
Nicolas Noble | 5383062 | 2015-02-12 16:56:38 -0800 | [diff] [blame] | 1101 | endif |
nnoble | 20e2e3f | 2014-12-16 15:37:57 -0800 | [diff] [blame] | 1102 | % endif |
Nicolas Noble | 5383062 | 2015-02-12 16:56:38 -0800 | [diff] [blame] | 1103 | |
| 1104 | else |
| 1105 | |
| 1106 | % endif |
Craig Tiller | 61b910f | 2015-02-15 10:54:07 -0800 | [diff] [blame] | 1107 | $(LIBDIR)/$(CONFIG)/lib${lib.name}.a: $(ZLIB_DEP)\ |
Nicolas Noble | 5383062 | 2015-02-12 16:56:38 -0800 | [diff] [blame] | 1108 | % endif |
| 1109 | % if lib.language == 'c++': |
| 1110 | $(PROTOBUF_DEP)\ |
| 1111 | % endif |
| 1112 | $(LIB${lib.name.upper()}_OBJS) |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 1113 | $(E) "[AR] Creating $@" |
nnoble | 85a4926 | 2014-12-08 18:14:03 -0800 | [diff] [blame] | 1114 | $(Q) mkdir -p `dirname $@` |
Craig Tiller | 61b910f | 2015-02-15 10:54:07 -0800 | [diff] [blame] | 1115 | $(Q) rm -f $(LIBDIR)/$(CONFIG)/lib${lib.name}.a |
| 1116 | $(Q) $(AR) rcs $(LIBDIR)/$(CONFIG)/lib${lib.name}.a $(LIB${lib.name.upper()}_OBJS) |
nnoble | 20e2e3f | 2014-12-16 15:37:57 -0800 | [diff] [blame] | 1117 | % if lib.get('baselib', False): |
Nicolas "Pixel" Noble | 061690d | 2015-03-06 22:58:58 +0100 | [diff] [blame] | 1118 | % if lib.get('secure', 'check') == 'yes': |
Craig Tiller | 7ab4fee | 2015-02-24 08:15:53 -0800 | [diff] [blame] | 1119 | $(Q) rm -rf tmp-merge-${lib.name} |
| 1120 | $(Q) mkdir tmp-merge-${lib.name} |
| 1121 | $(Q) ( cd tmp-merge-${lib.name} ; $(AR) x ../$(LIBDIR)/$(CONFIG)/lib${lib.name}.a ) |
| 1122 | $(Q) for l in $(OPENSSL_MERGE_LIBS) ; do ( cd tmp-merge-${lib.name} ; <%text>ar x ../$${l}</%text> ) ; done |
| 1123 | $(Q) rm -f $(LIBDIR)/$(CONFIG)/lib${lib.name}.a tmp-merge-${lib.name}/__.SYMDEF* |
| 1124 | $(Q) ar rcs $(LIBDIR)/$(CONFIG)/lib${lib.name}.a tmp-merge-${lib.name}/* |
| 1125 | $(Q) rm -rf tmp-merge-${lib.name} |
nnoble | 20e2e3f | 2014-12-16 15:37:57 -0800 | [diff] [blame] | 1126 | % endif |
| 1127 | % endif |
Craig Tiller | b4ee3b5 | 2015-01-21 16:22:50 -0800 | [diff] [blame] | 1128 | ifeq ($(SYSTEM),Darwin) |
murgatroid99 | b618136 | 2015-03-02 14:32:25 -0800 | [diff] [blame] | 1129 | $(Q) ranlib $(LIBDIR)/$(CONFIG)/lib${lib.name}.a |
Craig Tiller | b4ee3b5 | 2015-01-21 16:22:50 -0800 | [diff] [blame] | 1130 | endif |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 1131 | |
nnoble | 5b7f32a | 2014-12-22 08:12:44 -0800 | [diff] [blame] | 1132 | <% |
Nicolas "Pixel" Noble | 010f1e7 | 2015-04-23 02:23:49 +0200 | [diff] [blame] | 1133 | |
Craig Tiller | 59140fc | 2015-01-18 10:12:17 -0800 | [diff] [blame] | 1134 | if lib.language == 'c++': |
nnoble | 5b7f32a | 2014-12-22 08:12:44 -0800 | [diff] [blame] | 1135 | ld = '$(LDXX)' |
| 1136 | else: |
| 1137 | ld = '$(LD)' |
| 1138 | |
Craig Tiller | da224d6 | 2015-02-15 11:01:58 -0800 | [diff] [blame] | 1139 | out_base = '$(LIBDIR)/$(CONFIG)/' + lib.name |
| 1140 | out_libbase = '$(LIBDIR)/$(CONFIG)/lib' + lib.name |
nnoble | 5b7f32a | 2014-12-22 08:12:44 -0800 | [diff] [blame] | 1141 | |
| 1142 | common = '$(LIB' + lib.name.upper() + '_OBJS) $(LDLIBS)' |
| 1143 | |
| 1144 | libs = '' |
Nicolas "Pixel" Noble | 85bf09b | 2015-01-15 18:22:40 +0100 | [diff] [blame] | 1145 | lib_deps = ' $(ZLIB_DEP)' |
nnoble | 5b7f32a | 2014-12-22 08:12:44 -0800 | [diff] [blame] | 1146 | mingw_libs = '' |
Nicolas "Pixel" Noble | 85bf09b | 2015-01-15 18:22:40 +0100 | [diff] [blame] | 1147 | mingw_lib_deps = ' $(ZLIB_DEP)' |
nnoble | 5b7f32a | 2014-12-22 08:12:44 -0800 | [diff] [blame] | 1148 | for dep in lib.get('deps', []): |
| 1149 | libs = libs + ' -l' + dep |
Craig Tiller | 61b910f | 2015-02-15 10:54:07 -0800 | [diff] [blame] | 1150 | lib_deps = lib_deps + ' $(LIBDIR)/$(CONFIG)/lib' + dep + '.$(SHARED_EXT)' |
nnoble | 5b7f32a | 2014-12-22 08:12:44 -0800 | [diff] [blame] | 1151 | mingw_libs = mingw_libs + ' -l' + dep + '-imp' |
Craig Tiller | da224d6 | 2015-02-15 11:01:58 -0800 | [diff] [blame] | 1152 | mingw_lib_deps = mingw_lib_deps + '$(LIBDIR)/$(CONFIG)/' + dep + '.$(SHARED_EXT)' |
nnoble | 5b7f32a | 2014-12-22 08:12:44 -0800 | [diff] [blame] | 1153 | |
Nicolas "Pixel" Noble | 061690d | 2015-03-06 22:58:58 +0100 | [diff] [blame] | 1154 | if lib.get('secure', 'check') == 'yes': |
nnoble | 5b7f32a | 2014-12-22 08:12:44 -0800 | [diff] [blame] | 1155 | common = common + ' $(LDLIBS_SECURE) $(OPENSSL_MERGE_LIBS)' |
Nicolas "Pixel" Noble | 010f1e7 | 2015-04-23 02:23:49 +0200 | [diff] [blame] | 1156 | for src in lib.src: |
| 1157 | sources_that_need_openssl.add(src) |
| 1158 | else: |
| 1159 | for src in lib.src: |
| 1160 | sources_that_don_t_need_openssl.add(src) |
Nicolas "Pixel" Noble | 061690d | 2015-03-06 22:58:58 +0100 | [diff] [blame] | 1161 | |
| 1162 | if lib.get('secure', 'check') == 'yes' or lib.get('secure', 'check') == 'check': |
nnoble | 5b7f32a | 2014-12-22 08:12:44 -0800 | [diff] [blame] | 1163 | lib_deps = lib_deps + ' $(OPENSSL_DEP)' |
| 1164 | mingw_lib_deps = mingw_lib_deps + ' $(OPENSSL_DEP)' |
Nicolas "Pixel" Noble | dda049c | 2015-02-21 00:39:32 +0100 | [diff] [blame] | 1165 | |
| 1166 | if lib.language == 'c++': |
| 1167 | common = common + ' $(LDLIBSXX) $(LDLIBS_PROTOBUF)' |
nnoble | 5b7f32a | 2014-12-22 08:12:44 -0800 | [diff] [blame] | 1168 | %> |
| 1169 | |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 1170 | % if lib.build == "all": |
nnoble | 5b7f32a | 2014-12-22 08:12:44 -0800 | [diff] [blame] | 1171 | ifeq ($(SYSTEM),MINGW32) |
| 1172 | ${out_base}.$(SHARED_EXT): $(LIB${lib.name.upper()}_OBJS) ${mingw_lib_deps} |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 1173 | $(E) "[LD] Linking $@" |
nnoble | 85a4926 | 2014-12-08 18:14:03 -0800 | [diff] [blame] | 1174 | $(Q) mkdir -p `dirname $@` |
Craig Tiller | da224d6 | 2015-02-15 11:01:58 -0800 | [diff] [blame] | 1175 | $(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} |
nnoble | 5b7f32a | 2014-12-22 08:12:44 -0800 | [diff] [blame] | 1176 | else |
| 1177 | ${out_libbase}.$(SHARED_EXT): $(LIB${lib.name.upper()}_OBJS) ${lib_deps} |
| 1178 | $(E) "[LD] Linking $@" |
| 1179 | $(Q) mkdir -p `dirname $@` |
| 1180 | ifeq ($(SYSTEM),Darwin) |
Masood Malekghassemi | d1be74f | 2015-04-07 16:23:09 -0700 | [diff] [blame] | 1181 | $(Q) ${ld} $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -install_name lib${lib.name}.$(SHARED_EXT) -dynamiclib -o ${out_libbase}.$(SHARED_EXT) ${common}${libs} |
nnoble | 5b7f32a | 2014-12-22 08:12:44 -0800 | [diff] [blame] | 1182 | else |
Craig Tiller | da224d6 | 2015-02-15 11:01:58 -0800 | [diff] [blame] | 1183 | $(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" Noble | d8f8b6b | 2015-01-29 21:29:43 +0100 | [diff] [blame] | 1184 | $(Q) ln -sf lib${lib.name}.$(SHARED_EXT) ${out_libbase}.so.${settings.version.major} |
nnoble | 5b7f32a | 2014-12-22 08:12:44 -0800 | [diff] [blame] | 1185 | $(Q) ln -sf lib${lib.name}.$(SHARED_EXT) ${out_libbase}.so |
| 1186 | endif |
| 1187 | endif |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 1188 | % endif |
Nicolas "Pixel" Noble | 061690d | 2015-03-06 22:58:58 +0100 | [diff] [blame] | 1189 | % if lib.get('secure', 'check') == 'yes' or lib.get('secure', 'check') == 'check': |
Nicolas Noble | 047b727 | 2015-01-16 13:55:05 -0800 | [diff] [blame] | 1190 | ## If the lib was secure, we have to close the Makefile's if that tested |
| 1191 | ## the presence of an ALPN-capable OpenSSL. |
Nicolas Noble | 5383062 | 2015-02-12 16:56:38 -0800 | [diff] [blame] | 1192 | |
| 1193 | endif |
| 1194 | % endif |
| 1195 | % if lib.language == 'c++': |
| 1196 | ## If the lib was C++, we have to close the Makefile's if that tested |
| 1197 | ## the presence of protobuf 3.0.0+ |
nnoble | 69ac39f | 2014-12-12 15:43:38 -0800 | [diff] [blame] | 1198 | |
| 1199 | endif |
| 1200 | % endif |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 1201 | |
Nicolas "Pixel" Noble | 061690d | 2015-03-06 22:58:58 +0100 | [diff] [blame] | 1202 | % if lib.get('secure', 'check') == 'yes' or lib.get('secure', 'check') == 'check': |
nnoble | 69ac39f | 2014-12-12 15:43:38 -0800 | [diff] [blame] | 1203 | ifneq ($(NO_SECURE),true) |
| 1204 | % endif |
| 1205 | ifneq ($(NO_DEPS),true) |
Craig Tiller | 8f126a6 | 2015-01-15 08:50:19 -0800 | [diff] [blame] | 1206 | -include $(LIB${lib.name.upper()}_OBJS:.o=.dep) |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 1207 | endif |
Nicolas "Pixel" Noble | 061690d | 2015-03-06 22:58:58 +0100 | [diff] [blame] | 1208 | % if lib.get('secure', 'check') == 'yes' or lib.get('secure', 'check') == 'check': |
nnoble | 69ac39f | 2014-12-12 15:43:38 -0800 | [diff] [blame] | 1209 | endif |
| 1210 | % endif |
Craig Tiller | 27715ca | 2015-01-12 16:55:59 -0800 | [diff] [blame] | 1211 | % for src in lib.src: |
Craig Tiller | d896fa5 | 2015-04-24 14:30:09 -0700 | [diff] [blame] | 1212 | % if not proto_re.match(src) and any(proto_re.match(src2) for src2 in lib.src): |
Craig Tiller | 04f8156 | 2015-04-24 14:34:30 -0700 | [diff] [blame^] | 1213 | $(OBJDIR)/$(CONFIG)/${os.path.splitext(src)[0]}.o: ${' '.join(proto_to_cc(src2) for src2 in lib.src if proto_re.match(src2))} |
Craig Tiller | 27715ca | 2015-01-12 16:55:59 -0800 | [diff] [blame] | 1214 | % endif |
Craig Tiller | 27715ca | 2015-01-12 16:55:59 -0800 | [diff] [blame] | 1215 | % endfor |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 1216 | </%def> |
| 1217 | |
| 1218 | <%def name="maketarget(tgt)"> |
| 1219 | ${tgt.name.upper()}_SRC = \\ |
| 1220 | |
| 1221 | % for src in tgt.src: |
nnoble | 72309c6 | 2014-12-12 11:42:26 -0800 | [diff] [blame] | 1222 | ${proto_to_cc(src)} \\ |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 1223 | |
| 1224 | % endfor |
| 1225 | |
Craig Tiller | 61b910f | 2015-02-15 10:54:07 -0800 | [diff] [blame] | 1226 | ${tgt.name.upper()}_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(${tgt.name.upper()}_SRC)))) |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 1227 | |
Nicolas "Pixel" Noble | 061690d | 2015-03-06 22:58:58 +0100 | [diff] [blame] | 1228 | % if tgt.get('secure', 'check') == 'yes' or tgt.get('secure', 'check') == 'check': |
nnoble | 69ac39f | 2014-12-12 15:43:38 -0800 | [diff] [blame] | 1229 | ifeq ($(NO_SECURE),true) |
| 1230 | |
Nicolas Noble | 047b727 | 2015-01-16 13:55:05 -0800 | [diff] [blame] | 1231 | # You can't build secure targets if you don't have OpenSSL with ALPN. |
| 1232 | |
Craig Tiller | 61b910f | 2015-02-15 10:54:07 -0800 | [diff] [blame] | 1233 | $(BINDIR)/$(CONFIG)/${tgt.name}: openssl_dep_error |
nnoble | 69ac39f | 2014-12-12 15:43:38 -0800 | [diff] [blame] | 1234 | |
| 1235 | else |
| 1236 | |
| 1237 | % endif |
Nicolas Noble | 047b727 | 2015-01-16 13:55:05 -0800 | [diff] [blame] | 1238 | ## |
| 1239 | ## We're not trying to add a dependency on building zlib and openssl here, |
| 1240 | ## as it's already done in the libraries. We're assuming that the build |
| 1241 | ## trickles down, and that a secure target requires a secure version of |
| 1242 | ## a library. |
| 1243 | ## |
| 1244 | ## That simplifies the codegen a bit, but prevents a fully defined Makefile. |
| 1245 | ## I can live with that. |
| 1246 | ## |
Nicolas "Pixel" Noble | 18953e3 | 2015-02-27 02:41:11 +0100 | [diff] [blame] | 1247 | % if tgt.build == 'protoc' or tgt.language == 'c++': |
Nicolas Noble | 5383062 | 2015-02-12 16:56:38 -0800 | [diff] [blame] | 1248 | |
| 1249 | ifeq ($(NO_PROTOBUF),true) |
| 1250 | |
Nicolas "Pixel" Noble | 18953e3 | 2015-02-27 02:41:11 +0100 | [diff] [blame] | 1251 | # You can't build the protoc plugins or protobuf-enabled targets if you don't have protobuf 3.0.0+. |
Nicolas Noble | 5383062 | 2015-02-12 16:56:38 -0800 | [diff] [blame] | 1252 | |
Craig Tiller | 61b910f | 2015-02-15 10:54:07 -0800 | [diff] [blame] | 1253 | $(BINDIR)/$(CONFIG)/${tgt.name}: protobuf_dep_error |
Nicolas Noble | 5383062 | 2015-02-12 16:56:38 -0800 | [diff] [blame] | 1254 | |
| 1255 | else |
| 1256 | |
Craig Tiller | 61b910f | 2015-02-15 10:54:07 -0800 | [diff] [blame] | 1257 | $(BINDIR)/$(CONFIG)/${tgt.name}: $(PROTOBUF_DEP) $(${tgt.name.upper()}_OBJS)\ |
Nicolas Noble | 5383062 | 2015-02-12 16:56:38 -0800 | [diff] [blame] | 1258 | % else: |
Craig Tiller | 61b910f | 2015-02-15 10:54:07 -0800 | [diff] [blame] | 1259 | $(BINDIR)/$(CONFIG)/${tgt.name}: $(${tgt.name.upper()}_OBJS)\ |
Nicolas Noble | 5383062 | 2015-02-12 16:56:38 -0800 | [diff] [blame] | 1260 | % endif |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 1261 | % for dep in tgt.deps: |
Craig Tiller | 61b910f | 2015-02-15 10:54:07 -0800 | [diff] [blame] | 1262 | $(LIBDIR)/$(CONFIG)/lib${dep}.a\ |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 1263 | % endfor |
| 1264 | |
Craig Tiller | 59140fc | 2015-01-18 10:12:17 -0800 | [diff] [blame] | 1265 | % if tgt.language == "c++": |
Nicolas Noble | 047b727 | 2015-01-16 13:55:05 -0800 | [diff] [blame] | 1266 | ## C++ targets specificies. |
nnoble | 72309c6 | 2014-12-12 11:42:26 -0800 | [diff] [blame] | 1267 | % if tgt.build == 'protoc': |
| 1268 | $(E) "[HOSTLD] Linking $@" |
| 1269 | $(Q) mkdir -p `dirname $@` |
| 1270 | $(Q) $(HOST_LDXX) $(HOST_LDFLAGS) $(${tgt.name.upper()}_OBJS)\ |
| 1271 | % else: |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 1272 | $(E) "[LD] Linking $@" |
nnoble | 85a4926 | 2014-12-08 18:14:03 -0800 | [diff] [blame] | 1273 | $(Q) mkdir -p `dirname $@` |
nnoble | c78b340 | 2014-12-11 16:06:57 -0800 | [diff] [blame] | 1274 | $(Q) $(LDXX) $(LDFLAGS) $(${tgt.name.upper()}_OBJS)\ |
nnoble | 72309c6 | 2014-12-12 11:42:26 -0800 | [diff] [blame] | 1275 | % endif |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 1276 | % else: |
Nicolas Noble | 047b727 | 2015-01-16 13:55:05 -0800 | [diff] [blame] | 1277 | ## C-only targets specificities. |
nnoble | 72309c6 | 2014-12-12 11:42:26 -0800 | [diff] [blame] | 1278 | $(E) "[LD] Linking $@" |
| 1279 | $(Q) mkdir -p `dirname $@` |
nnoble | 5b7f32a | 2014-12-22 08:12:44 -0800 | [diff] [blame] | 1280 | $(Q) $(LD) $(LDFLAGS) $(${tgt.name.upper()}_OBJS)\ |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 1281 | % endif |
| 1282 | % for dep in tgt.deps: |
Craig Tiller | 61b910f | 2015-02-15 10:54:07 -0800 | [diff] [blame] | 1283 | $(LIBDIR)/$(CONFIG)/lib${dep}.a\ |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 1284 | % endfor |
Craig Tiller | 59140fc | 2015-01-18 10:12:17 -0800 | [diff] [blame] | 1285 | % if tgt.language == "c++": |
nnoble | 72309c6 | 2014-12-12 11:42:26 -0800 | [diff] [blame] | 1286 | % if tgt.build == 'protoc': |
Nicolas Noble | 5383062 | 2015-02-12 16:56:38 -0800 | [diff] [blame] | 1287 | $(HOST_LDLIBSXX) $(HOST_LDLIBS_PROTOC)\ |
nnoble | 72309c6 | 2014-12-12 11:42:26 -0800 | [diff] [blame] | 1288 | % else: |
Nicolas Noble | 5383062 | 2015-02-12 16:56:38 -0800 | [diff] [blame] | 1289 | $(LDLIBSXX) $(LDLIBS_PROTOBUF)\ |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 1290 | % endif |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 1291 | % endif |
nnoble | c78b340 | 2014-12-11 16:06:57 -0800 | [diff] [blame] | 1292 | % if tgt.build == 'protoc': |
nnoble | 72309c6 | 2014-12-12 11:42:26 -0800 | [diff] [blame] | 1293 | $(HOST_LDLIBS)\ |
| 1294 | % else: |
| 1295 | $(LDLIBS)\ |
| 1296 | % endif |
| 1297 | % if tgt.build == 'protoc': |
| 1298 | $(HOST_LDLIBS_PROTOC)\ |
Nicolas "Pixel" Noble | 061690d | 2015-03-06 22:58:58 +0100 | [diff] [blame] | 1299 | % elif tgt.get('secure', 'check') == 'yes' or tgt.get('secure', 'check') == 'check': |
nnoble | 72309c6 | 2014-12-12 11:42:26 -0800 | [diff] [blame] | 1300 | $(LDLIBS_SECURE)\ |
nnoble | c78b340 | 2014-12-11 16:06:57 -0800 | [diff] [blame] | 1301 | % endif |
Yang Gao | b0b518e | 2015-04-13 14:53:25 -0700 | [diff] [blame] | 1302 | % if tgt.language == 'c++' and tgt.build == 'test': |
| 1303 | $(GTEST_LIB)\ |
| 1304 | % endif |
Craig Tiller | 61b910f | 2015-02-15 10:54:07 -0800 | [diff] [blame] | 1305 | -o $(BINDIR)/$(CONFIG)/${tgt.name} |
Nicolas "Pixel" Noble | 18953e3 | 2015-02-27 02:41:11 +0100 | [diff] [blame] | 1306 | % if tgt.build == 'protoc' or tgt.language == 'c++': |
Nicolas Noble | 5383062 | 2015-02-12 16:56:38 -0800 | [diff] [blame] | 1307 | |
| 1308 | endif |
| 1309 | % endif |
Nicolas "Pixel" Noble | 061690d | 2015-03-06 22:58:58 +0100 | [diff] [blame] | 1310 | % if tgt.get('secure', 'check') == 'yes' or tgt.get('secure', 'check') == 'check': |
nnoble | 69ac39f | 2014-12-12 15:43:38 -0800 | [diff] [blame] | 1311 | |
| 1312 | endif |
| 1313 | % endif |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 1314 | |
Craig Tiller | f5371ef | 2015-01-12 16:40:18 -0800 | [diff] [blame] | 1315 | % for src in tgt.src: |
Craig Tiller | 61b910f | 2015-02-15 10:54:07 -0800 | [diff] [blame] | 1316 | $(OBJDIR)/$(CONFIG)/${os.path.splitext(src)[0]}.o: \ |
Craig Tiller | f5371ef | 2015-01-12 16:40:18 -0800 | [diff] [blame] | 1317 | % for dep in tgt.deps: |
Craig Tiller | 61b910f | 2015-02-15 10:54:07 -0800 | [diff] [blame] | 1318 | $(LIBDIR)/$(CONFIG)/lib${dep}.a\ |
Craig Tiller | f5371ef | 2015-01-12 16:40:18 -0800 | [diff] [blame] | 1319 | % endfor |
| 1320 | |
| 1321 | % endfor |
| 1322 | |
Craig Tiller | 8f126a6 | 2015-01-15 08:50:19 -0800 | [diff] [blame] | 1323 | deps_${tgt.name}: $(${tgt.name.upper()}_OBJS:.o=.dep) |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 1324 | |
Nicolas "Pixel" Noble | 061690d | 2015-03-06 22:58:58 +0100 | [diff] [blame] | 1325 | % if tgt.get('secure', 'check') == 'yes' or tgt.get('secure', 'check') == 'check': |
nnoble | 69ac39f | 2014-12-12 15:43:38 -0800 | [diff] [blame] | 1326 | ifneq ($(NO_SECURE),true) |
| 1327 | % endif |
| 1328 | ifneq ($(NO_DEPS),true) |
Craig Tiller | 8f126a6 | 2015-01-15 08:50:19 -0800 | [diff] [blame] | 1329 | -include $(${tgt.name.upper()}_OBJS:.o=.dep) |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 1330 | endif |
Nicolas "Pixel" Noble | 061690d | 2015-03-06 22:58:58 +0100 | [diff] [blame] | 1331 | % if tgt.get('secure', 'check') == 'yes' or tgt.get('secure', 'check') == 'check': |
nnoble | 69ac39f | 2014-12-12 15:43:38 -0800 | [diff] [blame] | 1332 | endif |
| 1333 | % endif |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 1334 | </%def> |
| 1335 | |
Nicolas "Pixel" Noble | 010f1e7 | 2015-04-23 02:23:49 +0200 | [diff] [blame] | 1336 | ifneq ($(OPENSSL_DEP),) |
| 1337 | # This is to ensure the embedded OpenSSL is built beforehand, properly |
| 1338 | # installing headers to their final destination on the drive. We need this |
| 1339 | # otherwise parallel compilation will fail if a source is compiled first. |
| 1340 | % for src in sorted(sources_that_need_openssl): |
| 1341 | % if src not in sources_that_don_t_need_openssl: |
| 1342 | ${src}: $(OPENSSL_DEP) |
| 1343 | % endif |
| 1344 | % endfor |
| 1345 | endif |
| 1346 | |
nnoble | 85a4926 | 2014-12-08 18:14:03 -0800 | [diff] [blame] | 1347 | .PHONY: all strip tools \ |
nnoble | 69ac39f | 2014-12-12 15:43:38 -0800 | [diff] [blame] | 1348 | dep_error openssl_dep_error openssl_dep_message git_update stop \ |
nnoble | 85a4926 | 2014-12-08 18:14:03 -0800 | [diff] [blame] | 1349 | buildtests buildtests_c buildtests_cxx \ |
| 1350 | test test_c test_cxx \ |
| 1351 | install install_c install_cxx \ |
| 1352 | install-headers install-headers_c install-headers_cxx \ |
| 1353 | install-shared install-shared_c install-shared_cxx \ |
| 1354 | install-static install-static_c install-static_cxx \ |
| 1355 | strip strip-shared strip-static \ |
| 1356 | strip_c strip-shared_c strip-static_c \ |
| 1357 | strip_cxx strip-shared_cxx strip-static_cxx \ |
Craig Tiller | f0afe50 | 2015-01-15 09:04:49 -0800 | [diff] [blame] | 1358 | dep_c dep_cxx bins_dep_c bins_dep_cxx \ |
Craig Tiller | 12c8209 | 2015-01-15 08:45:56 -0800 | [diff] [blame] | 1359 | clean |