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