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