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