Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1 | %YAML 1.2 |
| 2 | --- | |
| 3 | # GRPC global makefile |
| 4 | # This currently builds C and C++ code. |
| 5 | # This file has been automatically generated from a template file. |
| 6 | # Please look at the templates directory instead. |
| 7 | # This file can be regenerated from the template by running |
| 8 | # tools/buildgen/generate_projects.sh |
Craig Tiller | 3b93548 | 2015-02-16 12:15:48 -0800 | [diff] [blame] | 9 | |
Craig Tiller | 6169d5f | 2016-03-31 07:46:18 -0700 | [diff] [blame] | 10 | # Copyright 2015, Google Inc. |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 11 | # All rights reserved. |
| 12 | # |
| 13 | # Redistribution and use in source and binary forms, with or without |
| 14 | # modification, are permitted provided that the following conditions are |
| 15 | # met: |
| 16 | # |
| 17 | # * Redistributions of source code must retain the above copyright |
| 18 | # notice, this list of conditions and the following disclaimer. |
| 19 | # * Redistributions in binary form must reproduce the above |
| 20 | # copyright notice, this list of conditions and the following disclaimer |
| 21 | # in the documentation and/or other materials provided with the |
| 22 | # distribution. |
| 23 | # * Neither the name of Google Inc. nor the names of its |
| 24 | # contributors may be used to endorse or promote products derived from |
| 25 | # this software without specific prior written permission. |
| 26 | # |
| 27 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 28 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 29 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 30 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 31 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 32 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 33 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 34 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 35 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 36 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 37 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 38 | <%! |
| 39 | import re |
| 40 | import os |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 41 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 42 | proto_re = re.compile('(.*)\\.proto') |
nnoble | 72309c6 | 2014-12-12 11:42:26 -0800 | [diff] [blame] | 43 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 44 | def proto_to_cc(filename): |
| 45 | m = proto_re.match(filename) |
| 46 | if not m: |
| 47 | return filename |
| 48 | return '$(GENDIR)/' + m.group(1) + '.pb.cc $(GENDIR)/' + m.group(1) + '.grpc.pb.cc' |
Nicolas "Pixel" Noble | 010f1e7 | 2015-04-23 02:23:49 +0200 | [diff] [blame] | 49 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 50 | sources_that_need_openssl = set() |
| 51 | sources_that_don_t_need_openssl = set() |
Craig Tiller | 78222f7 | 2016-05-10 09:55:38 -0700 | [diff] [blame] | 52 | |
| 53 | # warnings we'd like, but that dont exist in all compilers |
| 54 | PREFERRED_WARNINGS=['shadow', 'extra-semi'] |
| 55 | CHECK_WARNINGS=PREFERRED_WARNINGS + ['no-shift-negative-value'] |
| 56 | |
| 57 | def warning_var(fmt, warning): |
| 58 | return fmt % warning.replace('-', '_').upper() |
| 59 | |
| 60 | def neg_warning(warning): |
| 61 | if warning[0:3] == 'no-': |
| 62 | return warning[3:] |
| 63 | else: |
| 64 | return 'no-' + warning |
Craig Tiller | 38b99e9 | 2016-09-15 16:18:09 -0700 | [diff] [blame] | 65 | |
| 66 | lang_to_var = { |
| 67 | 'c': 'CORE', |
| 68 | 'c++': 'CPP', |
| 69 | 'csharp': 'CSHARP' |
| 70 | } |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 71 | %> |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 72 | |
Craig Tiller | 96b4955 | 2015-01-21 16:29:01 -0800 | [diff] [blame] | 73 | |
Craig Tiller | 71a8604 | 2016-01-15 14:59:58 -0800 | [diff] [blame] | 74 | comma := , |
| 75 | |
| 76 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 77 | # Basic platform detection |
| 78 | HOST_SYSTEM = $(shell uname | cut -f 1 -d_) |
Nicolas "Pixel" Noble | c4e57e3 | 2016-01-30 21:05:35 +0100 | [diff] [blame] | 79 | SYSTEM ?= $(HOST_SYSTEM) |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 80 | ifeq ($(SYSTEM),MSYS) |
| 81 | SYSTEM = MINGW32 |
| 82 | endif |
| 83 | ifeq ($(SYSTEM),MINGW64) |
| 84 | SYSTEM = MINGW32 |
| 85 | endif |
Craig Tiller | 96b4955 | 2015-01-21 16:29:01 -0800 | [diff] [blame] | 86 | |
| 87 | |
Nicolas "Pixel" Noble | 6dad9b0 | 2015-09-23 18:32:26 +0200 | [diff] [blame] | 88 | MAKEFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST))) |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 89 | ifndef BUILDDIR |
Nicolas "Pixel" Noble | 42b4c28 | 2015-09-17 23:57:08 +0200 | [diff] [blame] | 90 | BUILDDIR_ABSOLUTE = $(patsubst %/,%,$(dir $(MAKEFILE_PATH))) |
| 91 | else |
| 92 | BUILDDIR_ABSOLUTE = $(abspath $(BUILDDIR)) |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 93 | endif |
Craig Tiller | 61b910f | 2015-02-15 10:54:07 -0800 | [diff] [blame] | 94 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 95 | HAS_GCC = $(shell which gcc > /dev/null 2> /dev/null && echo true || echo false) |
| 96 | HAS_CC = $(shell which cc > /dev/null 2> /dev/null && echo true || echo false) |
| 97 | HAS_CLANG = $(shell which clang > /dev/null 2> /dev/null && echo true || echo false) |
Nicolas Noble | f868118 | 2015-03-18 14:25:44 -0700 | [diff] [blame] | 98 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 99 | ifeq ($(HAS_CC),true) |
| 100 | DEFAULT_CC = cc |
| 101 | DEFAULT_CXX = c++ |
| 102 | else |
| 103 | ifeq ($(HAS_GCC),true) |
| 104 | DEFAULT_CC = gcc |
| 105 | DEFAULT_CXX = g++ |
| 106 | else |
| 107 | ifeq ($(HAS_CLANG),true) |
| 108 | DEFAULT_CC = clang |
| 109 | DEFAULT_CXX = clang++ |
| 110 | else |
| 111 | DEFAULT_CC = no_c_compiler |
| 112 | DEFAULT_CXX = no_c++_compiler |
| 113 | endif |
| 114 | endif |
| 115 | endif |
Nicolas Noble | f868118 | 2015-03-18 14:25:44 -0700 | [diff] [blame] | 116 | |
| 117 | |
Nicolas "Pixel" Noble | 42b4c28 | 2015-09-17 23:57:08 +0200 | [diff] [blame] | 118 | BINDIR = $(BUILDDIR_ABSOLUTE)/bins |
| 119 | OBJDIR = $(BUILDDIR_ABSOLUTE)/objs |
| 120 | LIBDIR = $(BUILDDIR_ABSOLUTE)/libs |
| 121 | GENDIR = $(BUILDDIR_ABSOLUTE)/gens |
Craig Tiller | 61b910f | 2015-02-15 10:54:07 -0800 | [diff] [blame] | 122 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 123 | # Configurations |
ctiller | 8cfebb9 | 2015-01-06 15:02:12 -0800 | [diff] [blame] | 124 | |
Craig Tiller | a0f8517 | 2016-01-20 15:56:06 -0800 | [diff] [blame] | 125 | % for name, args in configs.iteritems(): |
| 126 | VALID_CONFIG_${name} = 1 |
| 127 | % if args.get('compile_the_world', False): |
| 128 | REQUIRE_CUSTOM_LIBRARIES_${name} = 1 |
| 129 | % endif |
Craig Tiller | aff3d50 | 2016-01-20 15:59:31 -0800 | [diff] [blame] | 130 | % for tool, default in [('CC', 'CC'), ('CXX', 'CXX'), ('LD', 'CC'), ('LDXX', 'CXX')]: |
Craig Tiller | a0f8517 | 2016-01-20 15:56:06 -0800 | [diff] [blame] | 131 | ${tool}_${name} = ${args.get(tool, '$(DEFAULT_%s)' % default)} |
| 132 | % endfor |
| 133 | % for arg in ['CFLAGS', 'CXXFLAGS', 'CPPFLAGS', 'LDFLAGS', 'DEFINES']: |
| 134 | % if args.get(arg, None) is not None: |
| 135 | ${arg}_${name} = ${args.get(arg)} |
| 136 | % endif |
| 137 | % endfor |
| 138 | % if args.get('timeout_multiplier', 1) != 1: |
| 139 | DEFINES_${name} += GRPC_TEST_SLOWDOWN_BUILD_FACTOR=${args.timeout_multiplier} |
| 140 | % endif |
ctiller | 8cfebb9 | 2015-01-06 15:02:12 -0800 | [diff] [blame] | 141 | |
Craig Tiller | a0f8517 | 2016-01-20 15:56:06 -0800 | [diff] [blame] | 142 | % endfor |
Craig Tiller | 699ba21 | 2015-01-13 17:02:20 -0800 | [diff] [blame] | 143 | |
Nicolas Noble | 047b727 | 2015-01-16 13:55:05 -0800 | [diff] [blame] | 144 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 145 | # General settings. |
| 146 | # You may want to change these depending on your system. |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 147 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 148 | prefix ?= /usr/local |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 149 | |
Nicolas "Pixel" Noble | 1a8eb85 | 2016-01-26 22:33:19 +0100 | [diff] [blame] | 150 | PROTOC ?= protoc |
| 151 | DTRACE ?= dtrace |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 152 | CONFIG ?= opt |
Nicolas "Pixel" Noble | fba36bc | 2016-01-27 03:24:03 +0100 | [diff] [blame] | 153 | # Doing X ?= Y is the same as: |
| 154 | # ifeq ($(origin X), undefined) |
| 155 | # X = Y |
| 156 | # endif |
| 157 | # but some variables, such as CC, CXX, LD or AR, have defaults. |
| 158 | # So instead of using ?= on them, we need to check their origin. |
| 159 | # See: |
| 160 | # https://www.gnu.org/software/make/manual/html_node/Implicit-Variables.html |
| 161 | # https://www.gnu.org/software/make/manual/html_node/Flavors.html#index-_003f_003d |
| 162 | # https://www.gnu.org/software/make/manual/html_node/Origin-Function.html |
| 163 | ifeq ($(origin CC), default) |
| 164 | CC = $(CC_$(CONFIG)) |
| 165 | endif |
| 166 | ifeq ($(origin CXX), default) |
| 167 | CXX = $(CXX_$(CONFIG)) |
| 168 | endif |
| 169 | ifeq ($(origin LD), default) |
| 170 | LD = $(LD_$(CONFIG)) |
| 171 | endif |
Nicolas "Pixel" Noble | 1a8eb85 | 2016-01-26 22:33:19 +0100 | [diff] [blame] | 172 | LDXX ?= $(LDXX_$(CONFIG)) |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 173 | ifeq ($(SYSTEM),Linux) |
Nicolas "Pixel" Noble | 6e72dae | 2016-02-03 04:23:08 +0100 | [diff] [blame] | 174 | ifeq ($(origin AR), default) |
| 175 | AR = ar rcs |
| 176 | endif |
Nicolas "Pixel" Noble | 1a8eb85 | 2016-01-26 22:33:19 +0100 | [diff] [blame] | 177 | STRIP ?= strip --strip-unneeded |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 178 | else |
| 179 | ifeq ($(SYSTEM),Darwin) |
Nicolas "Pixel" Noble | 6e72dae | 2016-02-03 04:23:08 +0100 | [diff] [blame] | 180 | ifeq ($(origin AR), default) |
Nicolas "Pixel" Noble | e0dbd3f | 2016-02-23 00:21:38 +0100 | [diff] [blame] | 181 | AR = libtool -no_warning_for_no_symbols -o |
Nicolas "Pixel" Noble | 6e72dae | 2016-02-03 04:23:08 +0100 | [diff] [blame] | 182 | endif |
Nicolas "Pixel" Noble | 1a8eb85 | 2016-01-26 22:33:19 +0100 | [diff] [blame] | 183 | STRIP ?= strip -x |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 184 | else |
Mario Emmenlauer | 1643c04 | 2016-12-12 23:12:47 +0100 | [diff] [blame] | 185 | ifeq ($(SYSTEM),MINGW32) |
| 186 | ifeq ($(origin AR), default) |
| 187 | AR = ar rcs |
| 188 | endif |
| 189 | STRIP ?= strip --strip-unneeded |
| 190 | else |
Nicolas "Pixel" Noble | 6e72dae | 2016-02-03 04:23:08 +0100 | [diff] [blame] | 191 | ifeq ($(origin AR), default) |
| 192 | AR = ar rcs |
| 193 | endif |
Nicolas "Pixel" Noble | 1a8eb85 | 2016-01-26 22:33:19 +0100 | [diff] [blame] | 194 | STRIP ?= strip |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 195 | endif |
| 196 | endif |
Mario Emmenlauer | 1643c04 | 2016-12-12 23:12:47 +0100 | [diff] [blame] | 197 | endif |
Nicolas "Pixel" Noble | 1a8eb85 | 2016-01-26 22:33:19 +0100 | [diff] [blame] | 198 | INSTALL ?= install |
| 199 | RM ?= rm -f |
| 200 | PKG_CONFIG ?= pkg-config |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 201 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 202 | ifndef VALID_CONFIG_$(CONFIG) |
| 203 | $(error Invalid CONFIG value '$(CONFIG)') |
| 204 | endif |
yangg | 102e4fe | 2015-01-06 16:02:50 -0800 | [diff] [blame] | 205 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 206 | ifeq ($(SYSTEM),Linux) |
| 207 | TMPOUT = /dev/null |
| 208 | else |
| 209 | TMPOUT = `mktemp /tmp/test-out-XXXXXX` |
| 210 | endif |
Nicolas Noble | 047b727 | 2015-01-16 13:55:05 -0800 | [diff] [blame] | 211 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 212 | # Detect if we can use C++11 |
| 213 | CXX11_CHECK_CMD = $(CXX) -std=c++11 -o $(TMPOUT) -c test/build/c++11.cc |
| 214 | HAS_CXX11 = $(shell $(CXX11_CHECK_CMD) 2> /dev/null && echo true || echo false) |
Craig Tiller | cf133f4 | 2015-02-26 14:05:56 -0800 | [diff] [blame] | 215 | |
Craig Tiller | 78222f7 | 2016-05-10 09:55:38 -0700 | [diff] [blame] | 216 | %for warning in CHECK_WARNINGS: |
| 217 | ${warning_var('CHECK_%s_WORKS_CMD', warning)} = $(CC) -std=c99 -Werror -W${warning} -o $(TMPOUT) -c test/build/${warning}.c |
| 218 | ${warning_var('HAS_WORKING_%s', warning)} = $(shell $(${warning_var('CHECK_%s_WORKS_CMD', warning)}) 2> /dev/null && echo true || echo false) |
| 219 | ifeq ($(${warning_var('HAS_WORKING_%s', warning)}),true) |
| 220 | ${warning_var('W_%s', warning)}=-W${warning} |
| 221 | ${warning_var('NO_W_%s', warning)}=-W${neg_warning(warning)} |
Craig Tiller | 804b855 | 2016-02-23 16:50:24 -0800 | [diff] [blame] | 222 | endif |
Craig Tiller | 78222f7 | 2016-05-10 09:55:38 -0700 | [diff] [blame] | 223 | %endfor |
Craig Tiller | 16872b8 | 2016-01-25 10:55:20 -0800 | [diff] [blame] | 224 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 225 | # The HOST compiler settings are used to compile the protoc plugins. |
| 226 | # In most cases, you won't have to change anything, but if you are |
| 227 | # cross-compiling, you can override these variables from GNU make's |
| 228 | # command line: make CC=cross-gcc HOST_CC=gcc |
Nicolas Noble | 047b727 | 2015-01-16 13:55:05 -0800 | [diff] [blame] | 229 | |
Nicolas "Pixel" Noble | 1a8eb85 | 2016-01-26 22:33:19 +0100 | [diff] [blame] | 230 | HOST_CC ?= $(CC) |
| 231 | HOST_CXX ?= $(CXX) |
| 232 | HOST_LD ?= $(LD) |
| 233 | HOST_LDXX ?= $(LDXX) |
nnoble | 72309c6 | 2014-12-12 11:42:26 -0800 | [diff] [blame] | 234 | |
Craig Tiller | 78222f7 | 2016-05-10 09:55:38 -0700 | [diff] [blame] | 235 | CFLAGS += -std=c99 -Wsign-conversion -Wconversion ${' '.join(warning_var('$(W_%s)', warning) for warning in PREFERRED_WARNINGS)} |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 236 | ifeq ($(HAS_CXX11),true) |
| 237 | CXXFLAGS += -std=c++11 |
| 238 | else |
| 239 | CXXFLAGS += -std=c++0x |
| 240 | endif |
Nicolas "Pixel" Noble | 51b1aee | 2016-01-28 01:14:58 +0100 | [diff] [blame] | 241 | % for arg in ['CFLAGS', 'CXXFLAGS', 'CPPFLAGS', 'LDFLAGS', 'DEFINES']: |
| 242 | % if defaults.get('global', []).get(arg, None) is not None: |
| 243 | ${arg} += ${defaults.get('global').get(arg)} |
| 244 | % endif |
| 245 | % endfor |
Nicolas Noble | f868118 | 2015-03-18 14:25:44 -0700 | [diff] [blame] | 246 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 247 | CPPFLAGS += $(CPPFLAGS_$(CONFIG)) |
Craig Tiller | 0fe5ee7 | 2015-12-22 12:50:36 -0800 | [diff] [blame] | 248 | CFLAGS += $(CFLAGS_$(CONFIG)) |
| 249 | CXXFLAGS += $(CXXFLAGS_$(CONFIG)) |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 250 | DEFINES += $(DEFINES_$(CONFIG)) INSTALL_PREFIX=\"$(prefix)\" |
| 251 | LDFLAGS += $(LDFLAGS_$(CONFIG)) |
Nicolas "Pixel" Noble | 482d761 | 2015-07-16 23:43:30 +0200 | [diff] [blame] | 252 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 253 | ifneq ($(SYSTEM),MINGW32) |
| 254 | PIC_CPPFLAGS = -fPIC |
| 255 | CPPFLAGS += -fPIC |
| 256 | LDFLAGS += -fPIC |
| 257 | endif |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 258 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 259 | INCLUDES = . include $(GENDIR) |
| 260 | LDFLAGS += -Llibs/$(CONFIG) |
Nicolas "Pixel" Noble | 3adab74 | 2015-06-02 00:33:06 +0200 | [diff] [blame] | 261 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 262 | ifeq ($(SYSTEM),Darwin) |
| 263 | ifneq ($(wildcard /usr/local/ssl/include),) |
| 264 | INCLUDES += /usr/local/ssl/include |
| 265 | endif |
| 266 | ifneq ($(wildcard /opt/local/include),) |
| 267 | INCLUDES += /opt/local/include |
| 268 | endif |
| 269 | ifneq ($(wildcard /usr/local/include),) |
| 270 | INCLUDES += /usr/local/include |
| 271 | endif |
| 272 | LIBS = m z |
| 273 | ifneq ($(wildcard /usr/local/ssl/lib),) |
| 274 | LDFLAGS += -L/usr/local/ssl/lib |
| 275 | endif |
| 276 | ifneq ($(wildcard /opt/local/lib),) |
| 277 | LDFLAGS += -L/opt/local/lib |
| 278 | endif |
| 279 | ifneq ($(wildcard /usr/local/lib),) |
| 280 | LDFLAGS += -L/usr/local/lib |
| 281 | endif |
| 282 | endif |
Nicolas Noble | f868118 | 2015-03-18 14:25:44 -0700 | [diff] [blame] | 283 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 284 | ifeq ($(SYSTEM),Linux) |
Craig Tiller | 1b1e238 | 2016-02-03 07:33:56 -0800 | [diff] [blame] | 285 | LIBS = dl rt m pthread |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 286 | LDFLAGS += -pthread |
| 287 | endif |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 288 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 289 | ifeq ($(SYSTEM),MINGW32) |
Nicolas "Pixel" Noble | c4e57e3 | 2016-01-30 21:05:35 +0100 | [diff] [blame] | 290 | LIBS = m pthread ws2_32 |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 291 | LDFLAGS += -pthread |
| 292 | endif |
Nicolas Noble | f868118 | 2015-03-18 14:25:44 -0700 | [diff] [blame] | 293 | |
Vijay Pai | cc7eb8e | 2016-07-19 19:03:55 -0700 | [diff] [blame] | 294 | # |
| 295 | # The steps for cross-compiling are as follows: |
| 296 | # First, clone and make install of grpc using the native compilers for the host. |
| 297 | # Also, install protoc (e.g., from a package like apt-get) |
| 298 | # Then clone a fresh grpc for the actual cross-compiled build |
| 299 | # Set the environment variable GRPC_CROSS_COMPILE to true |
| 300 | # Set CC, CXX, LD, LDXX, AR, and STRIP to the cross-compiling binaries |
| 301 | # Also set PROTOBUF_CONFIG_OPTS to indicate cross-compilation to protobuf (e.g., |
| 302 | # PROTOBUF_CONFIG_OPTS="--host=arm-linux --with-protoc=/usr/local/bin/protoc" ) |
| 303 | # Set HAS_PKG_CONFIG=false |
| 304 | # To build tests, go to third_party/gflags and follow its ccmake instructions |
| 305 | # Make sure that you enable building shared libraries and set your prefix to |
| 306 | # something useful like /usr/local/cross |
| 307 | # You will also need to set GRPC_CROSS_LDOPTS and GRPC_CROSS_AROPTS to hold |
| 308 | # additional required arguments for LD and AR (examples below) |
| 309 | # Then you can do a make from the cross-compiling fresh clone! |
| 310 | # |
| 311 | ifeq ($(GRPC_CROSS_COMPILE),true) |
| 312 | LDFLAGS += $(GRPC_CROSS_LDOPTS) # e.g. -L/usr/local/lib -L/usr/local/cross/lib |
| 313 | AROPTS = $(GRPC_CROSS_AROPTS) # e.g., rc --target=elf32-little |
| 314 | USE_BUILT_PROTOC = false |
| 315 | endif |
| 316 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 317 | GTEST_LIB = -Ithird_party/googletest/include -Ithird_party/googletest third_party/googletest/src/gtest-all.cc |
| 318 | GTEST_LIB += -lgflags |
| 319 | ifeq ($(V),1) |
| 320 | E = @: |
| 321 | Q = |
| 322 | else |
| 323 | E = @echo |
| 324 | Q = @ |
| 325 | endif |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 326 | |
Craig Tiller | 38b99e9 | 2016-09-15 16:18:09 -0700 | [diff] [blame] | 327 | CORE_VERSION = ${settings.core_version} |
| 328 | CPP_VERSION = ${settings.cpp_version} |
| 329 | CSHARP_VERSION = ${settings.csharp_version} |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 330 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 331 | CPPFLAGS_NO_ARCH += $(addprefix -I, $(INCLUDES)) $(addprefix -D, $(DEFINES)) |
| 332 | CPPFLAGS += $(CPPFLAGS_NO_ARCH) $(ARCH_FLAGS) |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 333 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 334 | LDFLAGS += $(ARCH_FLAGS) |
| 335 | LDLIBS += $(addprefix -l, $(LIBS)) |
| 336 | LDLIBSXX += $(addprefix -l, $(LIBSXX)) |
nnoble | 72309c6 | 2014-12-12 11:42:26 -0800 | [diff] [blame] | 337 | |
murgatroid99 | c36f6ea | 2016-10-03 09:24:09 -0700 | [diff] [blame] | 338 | |
| 339 | % for arg in ['CFLAGS', 'CXXFLAGS', 'CPPFLAGS', 'LDFLAGS', 'DEFINES', 'LDLIBS']: |
| 340 | ${arg} += $(EXTRA_${arg}) |
| 341 | % endfor |
| 342 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 343 | HOST_CPPFLAGS = $(CPPFLAGS) |
| 344 | HOST_CFLAGS = $(CFLAGS) |
| 345 | HOST_CXXFLAGS = $(CXXFLAGS) |
| 346 | HOST_LDFLAGS = $(LDFLAGS) |
| 347 | HOST_LDLIBS = $(LDLIBS) |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 348 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 349 | # These are automatically computed variables. |
| 350 | # There shouldn't be any need to change anything from now on. |
nnoble | 69ac39f | 2014-12-12 15:43:38 -0800 | [diff] [blame] | 351 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 352 | -include cache.mk |
murgatroid99 | 24e2f4a | 2015-06-29 11:12:01 -0700 | [diff] [blame] | 353 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 354 | CACHE_MK = |
murgatroid99 | aa52157 | 2015-07-10 14:49:12 -0700 | [diff] [blame] | 355 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 356 | HAS_PKG_CONFIG ?= $(shell command -v $(PKG_CONFIG) >/dev/null 2>&1 && echo true || echo false) |
murgatroid99 | aa52157 | 2015-07-10 14:49:12 -0700 | [diff] [blame] | 357 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 358 | ifeq ($(HAS_PKG_CONFIG), true) |
| 359 | CACHE_MK += HAS_PKG_CONFIG = true, |
| 360 | endif |
nnoble | 69ac39f | 2014-12-12 15:43:38 -0800 | [diff] [blame] | 361 | |
Craig Tiller | 38b99e9 | 2016-09-15 16:18:09 -0700 | [diff] [blame] | 362 | CORE_PC_TEMPLATE = prefix=$(prefix),\ |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 363 | exec_prefix=${'\$${prefix}'},\ |
| 364 | includedir=${'\$${prefix}'}/include,\ |
| 365 | libdir=${'\$${exec_prefix}'}/lib,\ |
| 366 | ,\ |
| 367 | Name: $(PC_NAME),\ |
| 368 | Description: $(PC_DESCRIPTION),\ |
Craig Tiller | 38b99e9 | 2016-09-15 16:18:09 -0700 | [diff] [blame] | 369 | Version: $(CORE_VERSION),\ |
| 370 | Cflags: -I${'\$${includedir}'} $(PC_CFLAGS),\ |
| 371 | Requires.private: $(PC_REQUIRES_PRIVATE),\ |
| 372 | Libs: -L${'\$${libdir}'} $(PC_LIB),\ |
| 373 | Libs.private: $(PC_LIBS_PRIVATE) |
| 374 | |
| 375 | CPP_PC_TEMPLATE = prefix=$(prefix),\ |
| 376 | exec_prefix=${'\$${prefix}'},\ |
| 377 | includedir=${'\$${prefix}'}/include,\ |
| 378 | libdir=${'\$${exec_prefix}'}/lib,\ |
| 379 | ,\ |
| 380 | Name: $(PC_NAME),\ |
| 381 | Description: $(PC_DESCRIPTION),\ |
| 382 | Version: $(CPP_VERSION),\ |
| 383 | Cflags: -I${'\$${includedir}'} $(PC_CFLAGS),\ |
| 384 | Requires.private: $(PC_REQUIRES_PRIVATE),\ |
| 385 | Libs: -L${'\$${libdir}'} $(PC_LIB),\ |
| 386 | Libs.private: $(PC_LIBS_PRIVATE) |
| 387 | |
| 388 | CSHARP_PC_TEMPLATE = prefix=$(prefix),\ |
| 389 | exec_prefix=${'\$${prefix}'},\ |
| 390 | includedir=${'\$${prefix}'}/include,\ |
| 391 | libdir=${'\$${exec_prefix}'}/lib,\ |
| 392 | ,\ |
| 393 | Name: $(PC_NAME),\ |
| 394 | Description: $(PC_DESCRIPTION),\ |
| 395 | Version: $(CSHARP_VERSION),\ |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 396 | Cflags: -I${'\$${includedir}'} $(PC_CFLAGS),\ |
| 397 | Requires.private: $(PC_REQUIRES_PRIVATE),\ |
| 398 | Libs: -L${'\$${libdir}'} $(PC_LIB),\ |
| 399 | Libs.private: $(PC_LIBS_PRIVATE) |
murgatroid99 | 8faab23 | 2015-06-30 17:24:21 -0700 | [diff] [blame] | 400 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 401 | ifeq ($(SYSTEM),MINGW32) |
Mario Emmenlauer | 121d289 | 2016-12-12 23:49:27 +0100 | [diff] [blame] | 402 | EXECUTABLE_SUFFIX = .exe |
Craig Tiller | 38b99e9 | 2016-09-15 16:18:09 -0700 | [diff] [blame] | 403 | SHARED_EXT_CORE = dll |
| 404 | SHARED_EXT_CPP = dll |
| 405 | SHARED_EXT_CSHARP = dll |
Nicolas "Pixel" Noble | c4e57e3 | 2016-01-30 21:05:35 +0100 | [diff] [blame] | 406 | SHARED_PREFIX = |
Craig Tiller | 27f7084 | 2016-09-15 16:21:54 -0700 | [diff] [blame] | 407 | SHARED_VERSION_CORE = -${settings.core_version.major} |
| 408 | SHARED_VERSION_CPP = -${settings.cpp_version.major} |
| 409 | SHARED_VERSION_CSHARP = -${settings.csharp_version.major} |
Nicolas "Pixel" Noble | c4e57e3 | 2016-01-30 21:05:35 +0100 | [diff] [blame] | 410 | else ifeq ($(SYSTEM),Darwin) |
Mario Emmenlauer | 121d289 | 2016-12-12 23:49:27 +0100 | [diff] [blame] | 411 | EXECUTABLE_SUFFIX = |
Craig Tiller | 38b99e9 | 2016-09-15 16:18:09 -0700 | [diff] [blame] | 412 | SHARED_EXT_CORE = dylib |
| 413 | SHARED_EXT_CPP = dylib |
| 414 | SHARED_EXT_CSHARP = dylib |
Nicolas "Pixel" Noble | c4e57e3 | 2016-01-30 21:05:35 +0100 | [diff] [blame] | 415 | SHARED_PREFIX = lib |
Craig Tiller | 27f7084 | 2016-09-15 16:21:54 -0700 | [diff] [blame] | 416 | SHARED_VERSION_CORE = |
| 417 | SHARED_VERSION_CPP = |
| 418 | SHARED_VERSION_CSHARP = |
Nicolas "Pixel" Noble | c4e57e3 | 2016-01-30 21:05:35 +0100 | [diff] [blame] | 419 | else |
Mario Emmenlauer | 121d289 | 2016-12-12 23:49:27 +0100 | [diff] [blame] | 420 | EXECUTABLE_SUFFIX = |
Craig Tiller | 38b99e9 | 2016-09-15 16:18:09 -0700 | [diff] [blame] | 421 | SHARED_EXT_CORE = so.$(CORE_VERSION) |
| 422 | SHARED_EXT_CPP = so.$(CPP_VERSION) |
| 423 | SHARED_EXT_CSHARP = so.$(CSHARP_VERSION) |
Nicolas "Pixel" Noble | c4e57e3 | 2016-01-30 21:05:35 +0100 | [diff] [blame] | 424 | SHARED_PREFIX = lib |
Craig Tiller | 27f7084 | 2016-09-15 16:21:54 -0700 | [diff] [blame] | 425 | SHARED_VERSION_CORE = |
| 426 | SHARED_VERSION_CPP = |
| 427 | SHARED_VERSION_CSHARP = |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 428 | endif |
nnoble | 5b7f32a | 2014-12-22 08:12:44 -0800 | [diff] [blame] | 429 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 430 | ifeq ($(wildcard .git),) |
| 431 | IS_GIT_FOLDER = false |
| 432 | else |
| 433 | IS_GIT_FOLDER = true |
| 434 | endif |
nnoble | 69ac39f | 2014-12-12 15:43:38 -0800 | [diff] [blame] | 435 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 436 | ifeq ($(HAS_PKG_CONFIG),true) |
| 437 | OPENSSL_ALPN_CHECK_CMD = $(PKG_CONFIG) --atleast-version=1.0.2 openssl |
| 438 | OPENSSL_NPN_CHECK_CMD = $(PKG_CONFIG) --atleast-version=1.0.1 openssl |
| 439 | ZLIB_CHECK_CMD = $(PKG_CONFIG) --exists zlib |
Yuchen Zeng | d4df55e | 2016-08-15 16:41:18 -0700 | [diff] [blame] | 440 | PROTOBUF_CHECK_CMD = $(PKG_CONFIG) --atleast-version=3.0.0 protobuf |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 441 | else # HAS_PKG_CONFIG |
murgatroid99 | 24e2f4a | 2015-06-29 11:12:01 -0700 | [diff] [blame] | 442 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 443 | ifeq ($(SYSTEM),MINGW32) |
| 444 | OPENSSL_LIBS = ssl32 eay32 |
| 445 | else |
| 446 | OPENSSL_LIBS = ssl crypto |
| 447 | endif |
Nicolas Noble | f868118 | 2015-03-18 14:25:44 -0700 | [diff] [blame] | 448 | |
Nicolas "Pixel" Noble | 4500034 | 2016-01-28 05:04:45 +0100 | [diff] [blame] | 449 | OPENSSL_ALPN_CHECK_CMD = $(CC) $(CPPFLAGS) $(CFLAGS) -o $(TMPOUT) test/build/openssl-alpn.c $(addprefix -l, $(OPENSSL_LIBS)) $(LDFLAGS) |
| 450 | OPENSSL_NPN_CHECK_CMD = $(CC) $(CPPFLAGS) $(CFLAGS) -o $(TMPOUT) test/build/openssl-npn.c $(addprefix -l, $(OPENSSL_LIBS)) $(LDFLAGS) |
Craig Tiller | b79c1e1 | 2016-02-23 10:00:58 -0800 | [diff] [blame] | 451 | BORINGSSL_COMPILE_CHECK_CMD = $(CC) $(CPPFLAGS) ${defaults.boringssl.CPPFLAGS} $(CFLAGS) ${defaults.boringssl.CFLAGS} -o $(TMPOUT) test/build/boringssl.c $(LDFLAGS) |
Nicolas "Pixel" Noble | 4500034 | 2016-01-28 05:04:45 +0100 | [diff] [blame] | 452 | ZLIB_CHECK_CMD = $(CC) $(CPPFLAGS) $(CFLAGS) -o $(TMPOUT) test/build/zlib.c -lz $(LDFLAGS) |
| 453 | PROTOBUF_CHECK_CMD = $(CXX) $(CPPFLAGS) $(CXXFLAGS) -o $(TMPOUT) test/build/protobuf.cc -lprotobuf $(LDFLAGS) |
Craig Tiller | 297fafa | 2015-01-15 15:46:39 -0800 | [diff] [blame] | 454 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 455 | endif # HAS_PKG_CONFIG |
murgatroid99 | 24e2f4a | 2015-06-29 11:12:01 -0700 | [diff] [blame] | 456 | |
Nicolas "Pixel" Noble | 4500034 | 2016-01-28 05:04:45 +0100 | [diff] [blame] | 457 | PERFTOOLS_CHECK_CMD = $(CC) $(CPPFLAGS) $(CFLAGS) -o $(TMPOUT) test/build/perftools.c -lprofiler $(LDFLAGS) |
murgatroid99 | 6d9e401 | 2015-07-08 10:22:45 -0700 | [diff] [blame] | 458 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 459 | PROTOC_CHECK_CMD = which protoc > /dev/null |
| 460 | PROTOC_CHECK_VERSION_CMD = protoc --version | grep -q libprotoc.3 |
| 461 | DTRACE_CHECK_CMD = which dtrace > /dev/null |
Nicolas "Pixel" Noble | 4500034 | 2016-01-28 05:04:45 +0100 | [diff] [blame] | 462 | SYSTEMTAP_HEADERS_CHECK_CMD = $(CC) $(CPPFLAGS) $(CFLAGS) -o $(TMPOUT) test/build/systemtap.c $(LDFLAGS) |
murgatroid99 | 24e2f4a | 2015-06-29 11:12:01 -0700 | [diff] [blame] | 463 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 464 | ifndef REQUIRE_CUSTOM_LIBRARIES_$(CONFIG) |
| 465 | HAS_SYSTEM_PERFTOOLS ?= $(shell $(PERFTOOLS_CHECK_CMD) 2> /dev/null && echo true || echo false) |
| 466 | ifeq ($(HAS_SYSTEM_PERFTOOLS),true) |
| 467 | DEFINES += GRPC_HAVE_PERFTOOLS |
| 468 | LIBS += profiler |
| 469 | CACHE_MK += HAS_SYSTEM_PERFTOOLS = true, |
| 470 | endif |
| 471 | endif |
nnoble | 69ac39f | 2014-12-12 15:43:38 -0800 | [diff] [blame] | 472 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 473 | HAS_SYSTEM_PROTOBUF_VERIFY = $(shell $(PROTOBUF_CHECK_CMD) 2> /dev/null && echo true || echo false) |
| 474 | ifndef REQUIRE_CUSTOM_LIBRARIES_$(CONFIG) |
| 475 | HAS_SYSTEM_OPENSSL_ALPN ?= $(shell $(OPENSSL_ALPN_CHECK_CMD) 2> /dev/null && echo true || echo false) |
| 476 | ifeq ($(HAS_SYSTEM_OPENSSL_ALPN),true) |
| 477 | HAS_SYSTEM_OPENSSL_NPN = true |
| 478 | CACHE_MK += HAS_SYSTEM_OPENSSL_ALPN = true, |
| 479 | else |
| 480 | HAS_SYSTEM_OPENSSL_NPN ?= $(shell $(OPENSSL_NPN_CHECK_CMD) 2> /dev/null && echo true || echo false) |
| 481 | endif |
| 482 | ifeq ($(HAS_SYSTEM_OPENSSL_NPN),true) |
| 483 | CACHE_MK += HAS_SYSTEM_OPENSSL_NPN = true, |
| 484 | endif |
| 485 | HAS_SYSTEM_ZLIB ?= $(shell $(ZLIB_CHECK_CMD) 2> /dev/null && echo true || echo false) |
| 486 | ifeq ($(HAS_SYSTEM_ZLIB),true) |
| 487 | CACHE_MK += HAS_SYSTEM_ZLIB = true, |
| 488 | endif |
| 489 | HAS_SYSTEM_PROTOBUF ?= $(HAS_SYSTEM_PROTOBUF_VERIFY) |
| 490 | ifeq ($(HAS_SYSTEM_PROTOBUF),true) |
| 491 | CACHE_MK += HAS_SYSTEM_PROTOBUF = true, |
| 492 | endif |
| 493 | else |
| 494 | # override system libraries if the config requires a custom compiled library |
| 495 | HAS_SYSTEM_OPENSSL_ALPN = false |
| 496 | HAS_SYSTEM_OPENSSL_NPN = false |
| 497 | HAS_SYSTEM_ZLIB = false |
| 498 | HAS_SYSTEM_PROTOBUF = false |
| 499 | endif |
nnoble | 69ac39f | 2014-12-12 15:43:38 -0800 | [diff] [blame] | 500 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 501 | HAS_PROTOC ?= $(shell $(PROTOC_CHECK_CMD) 2> /dev/null && echo true || echo false) |
| 502 | ifeq ($(HAS_PROTOC),true) |
| 503 | CACHE_MK += HAS_PROTOC = true, |
| 504 | HAS_VALID_PROTOC ?= $(shell $(PROTOC_CHECK_VERSION_CMD) 2> /dev/null && echo true || echo false) |
| 505 | ifeq ($(HAS_VALID_PROTOC),true) |
| 506 | CACHE_MK += HAS_VALID_PROTOC = true, |
| 507 | endif |
| 508 | else |
| 509 | HAS_VALID_PROTOC = false |
| 510 | endif |
Nicolas Noble | 5383062 | 2015-02-12 16:56:38 -0800 | [diff] [blame] | 511 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 512 | # Check for Systemtap (https://sourceware.org/systemtap/), first by making sure <sys/sdt.h> is present |
| 513 | # in the system and secondly by checking for the "dtrace" binary (on Linux, this is part of the Systemtap |
| 514 | # distribution. It's part of the base system on BSD/Solaris machines). |
| 515 | ifndef HAS_SYSTEMTAP |
| 516 | HAS_SYSTEMTAP_HEADERS = $(shell $(SYSTEMTAP_HEADERS_CHECK_CMD) 2> /dev/null && echo true || echo false) |
| 517 | HAS_DTRACE = $(shell $(DTRACE_CHECK_CMD) 2> /dev/null && echo true || echo false) |
| 518 | HAS_SYSTEMTAP = false |
| 519 | ifeq ($(HAS_SYSTEMTAP_HEADERS),true) |
| 520 | ifeq ($(HAS_DTRACE),true) |
| 521 | HAS_SYSTEMTAP = true |
| 522 | endif |
| 523 | endif |
| 524 | endif |
David Garcia Quintas | 611b736 | 2015-04-27 15:49:31 -0700 | [diff] [blame] | 525 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 526 | ifeq ($(HAS_SYSTEMTAP),true) |
| 527 | CACHE_MK += HAS_SYSTEMTAP = true, |
| 528 | endif |
nnoble | 69ac39f | 2014-12-12 15:43:38 -0800 | [diff] [blame] | 529 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 530 | # Note that for testing purposes, one can do: |
| 531 | # make HAS_EMBEDDED_OPENSSL_ALPN=false |
| 532 | # to emulate the fact we do not have OpenSSL in the third_party folder. |
Craig Tiller | b79c1e1 | 2016-02-23 10:00:58 -0800 | [diff] [blame] | 533 | ifneq ($(wildcard third_party/${openssl_fallback.extraction_dir}/libssl.a),) |
| 534 | HAS_EMBEDDED_OPENSSL_ALPN = third_party/${openssl_fallback.extraction_dir} |
| 535 | else ifeq ($(wildcard third_party/boringssl/include/openssl/ssl.h),) |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 536 | HAS_EMBEDDED_OPENSSL_ALPN = false |
| 537 | else |
Craig Tiller | b79c1e1 | 2016-02-23 10:00:58 -0800 | [diff] [blame] | 538 | CAN_COMPILE_EMBEDDED_OPENSSL ?= $(shell $(BORINGSSL_COMPILE_CHECK_CMD) 2> /dev/null && echo true || echo false) |
| 539 | HAS_EMBEDDED_OPENSSL_ALPN = $(CAN_COMPILE_EMBEDDED_OPENSSL) |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 540 | endif |
nnoble | 69ac39f | 2014-12-12 15:43:38 -0800 | [diff] [blame] | 541 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 542 | ifeq ($(wildcard third_party/zlib/zlib.h),) |
| 543 | HAS_EMBEDDED_ZLIB = false |
| 544 | else |
| 545 | HAS_EMBEDDED_ZLIB = true |
| 546 | endif |
nnoble | 69ac39f | 2014-12-12 15:43:38 -0800 | [diff] [blame] | 547 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 548 | ifeq ($(wildcard third_party/protobuf/src/google/protobuf/descriptor.pb.h),) |
| 549 | HAS_EMBEDDED_PROTOBUF = false |
| 550 | ifneq ($(HAS_VALID_PROTOC),true) |
| 551 | NO_PROTOC = true |
| 552 | endif |
| 553 | else |
| 554 | HAS_EMBEDDED_PROTOBUF = true |
| 555 | endif |
Nicolas Noble | 5383062 | 2015-02-12 16:56:38 -0800 | [diff] [blame] | 556 | |
Nicolas "Pixel" Noble | 0912179 | 2016-01-30 09:01:53 +0100 | [diff] [blame] | 557 | PC_REQUIRES_GRPC = |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 558 | PC_LIBS_GRPC = |
murgatroid99 | 8faab23 | 2015-06-30 17:24:21 -0700 | [diff] [blame] | 559 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 560 | ifeq ($(HAS_SYSTEM_ZLIB),false) |
Craig Tiller | 3dca23a | 2016-01-21 11:44:55 -0800 | [diff] [blame] | 561 | ifeq ($(HAS_EMBEDDED_ZLIB), true) |
| 562 | EMBED_ZLIB ?= true |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 563 | else |
| 564 | DEP_MISSING += zlib |
Craig Tiller | 3dca23a | 2016-01-21 11:44:55 -0800 | [diff] [blame] | 565 | EMBED_ZLIB ?= broken |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 566 | endif |
| 567 | else |
Craig Tiller | 3dca23a | 2016-01-21 11:44:55 -0800 | [diff] [blame] | 568 | EMBED_ZLIB ?= false |
| 569 | endif |
| 570 | |
| 571 | ifeq ($(EMBED_ZLIB),true) |
| 572 | ZLIB_DEP = $(LIBDIR)/$(CONFIG)/libz.a |
| 573 | ZLIB_MERGE_LIBS = $(LIBDIR)/$(CONFIG)/libz.a |
Nicolas "Pixel" Noble | f51a901 | 2016-02-03 07:39:43 +0100 | [diff] [blame] | 574 | ZLIB_MERGE_OBJS = $(LIBZ_OBJS) |
Craig Tiller | 3dca23a | 2016-01-21 11:44:55 -0800 | [diff] [blame] | 575 | CPPFLAGS += -Ithird_party/zlib |
| 576 | LDFLAGS += -L$(LIBDIR)/$(CONFIG)/zlib |
| 577 | else |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 578 | ifeq ($(HAS_PKG_CONFIG),true) |
| 579 | CPPFLAGS += $(shell $(PKG_CONFIG) --cflags zlib) |
| 580 | LDFLAGS += $(shell $(PKG_CONFIG) --libs-only-L zlib) |
Craig Tiller | 0fe5ee7 | 2015-12-22 12:50:36 -0800 | [diff] [blame] | 581 | LIBS += $(patsubst -l%,%,$(shell $(PKG_CONFIG) --libs-only-l zlib)) |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 582 | PC_REQUIRES_GRPC += zlib |
| 583 | else |
| 584 | PC_LIBS_GRPC += -lz |
Craig Tiller | 0fe5ee7 | 2015-12-22 12:50:36 -0800 | [diff] [blame] | 585 | LIBS += z |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 586 | endif |
| 587 | endif |
nnoble | 69ac39f | 2014-12-12 15:43:38 -0800 | [diff] [blame] | 588 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 589 | OPENSSL_PKG_CONFIG = false |
murgatroid99 | da7a994 | 2015-06-29 14:57:37 -0700 | [diff] [blame] | 590 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 591 | PC_REQUIRES_SECURE = |
| 592 | PC_LIBS_SECURE = |
murgatroid99 | 8faab23 | 2015-06-30 17:24:21 -0700 | [diff] [blame] | 593 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 594 | ifeq ($(HAS_SYSTEM_OPENSSL_ALPN),true) |
Craig Tiller | 0fe5ee7 | 2015-12-22 12:50:36 -0800 | [diff] [blame] | 595 | EMBED_OPENSSL ?= false |
| 596 | NO_SECURE ?= false |
| 597 | else # HAS_SYSTEM_OPENSSL_ALPN=false |
Craig Tiller | b79c1e1 | 2016-02-23 10:00:58 -0800 | [diff] [blame] | 598 | ifneq ($(HAS_EMBEDDED_OPENSSL_ALPN),false) |
| 599 | EMBED_OPENSSL ?= $(HAS_EMBEDDED_OPENSSL_ALPN) |
Craig Tiller | 0fe5ee7 | 2015-12-22 12:50:36 -0800 | [diff] [blame] | 600 | NO_SECURE ?= false |
| 601 | else # HAS_EMBEDDED_OPENSSL_ALPN=false |
| 602 | ifeq ($(HAS_SYSTEM_OPENSSL_NPN),true) |
| 603 | EMBED_OPENSSL ?= false |
| 604 | NO_SECURE ?= false |
| 605 | else |
| 606 | NO_SECURE ?= true |
| 607 | endif # HAS_SYSTEM_OPENSSL_NPN=true |
| 608 | endif # HAS_EMBEDDED_OPENSSL_ALPN |
| 609 | endif # HAS_SYSTEM_OPENSSL_ALPN |
| 610 | |
| 611 | OPENSSL_DEP := |
| 612 | OPENSSL_MERGE_LIBS := |
| 613 | ifeq ($(NO_SECURE),false) |
| 614 | ifeq ($(EMBED_OPENSSL),true) |
| 615 | OPENSSL_DEP += $(LIBDIR)/$(CONFIG)/libboringssl.a |
| 616 | OPENSSL_MERGE_LIBS += $(LIBDIR)/$(CONFIG)/libboringssl.a |
Nicolas "Pixel" Noble | f51a901 | 2016-02-03 07:39:43 +0100 | [diff] [blame] | 617 | OPENSSL_MERGE_OBJS += $(LIBBORINGSSL_OBJS) |
Craig Tiller | 0fe5ee7 | 2015-12-22 12:50:36 -0800 | [diff] [blame] | 618 | # need to prefix these to ensure overriding system libraries |
| 619 | CPPFLAGS := -Ithird_party/boringssl/include $(CPPFLAGS) |
Craig Tiller | b79c1e1 | 2016-02-23 10:00:58 -0800 | [diff] [blame] | 620 | else ifneq ($(EMBED_OPENSSL),false) |
| 621 | OPENSSL_DEP += $(EMBED_OPENSSL)/libssl.a $(EMBED_OPENSSL)/libcrypto.a |
| 622 | OPENSSL_MERGE_LIBS += $(EMBED_OPENSSL)/libssl.a $(EMBED_OPENSSL)/libcrypto.a |
| 623 | OPENSSL_MERGE_OBJS += $(wildcard $(EMBED_OPENSSL)/grpc_obj/*.o) |
| 624 | # need to prefix these to ensure overriding system libraries |
| 625 | CPPFLAGS := -I$(EMBED_OPENSSL)/include $(CPPFLAGS) |
Craig Tiller | 0fe5ee7 | 2015-12-22 12:50:36 -0800 | [diff] [blame] | 626 | else # EMBED_OPENSSL=false |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 627 | ifeq ($(HAS_PKG_CONFIG),true) |
| 628 | OPENSSL_PKG_CONFIG = true |
| 629 | PC_REQUIRES_SECURE = openssl |
| 630 | CPPFLAGS := $(shell $(PKG_CONFIG) --cflags openssl) $(CPPFLAGS) |
| 631 | LDFLAGS_OPENSSL_PKG_CONFIG = $(shell $(PKG_CONFIG) --libs-only-L openssl) |
| 632 | ifeq ($(SYSTEM),Linux) |
| 633 | ifneq ($(LDFLAGS_OPENSSL_PKG_CONFIG),) |
| 634 | LDFLAGS_OPENSSL_PKG_CONFIG += $(shell $(PKG_CONFIG) --libs-only-L openssl | sed s/L/Wl,-rpath,/) |
Craig Tiller | 0fe5ee7 | 2015-12-22 12:50:36 -0800 | [diff] [blame] | 635 | endif # LDFLAGS_OPENSSL_PKG_CONFIG='' |
| 636 | endif # System=Linux |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 637 | LDFLAGS := $(LDFLAGS_OPENSSL_PKG_CONFIG) $(LDFLAGS) |
Craig Tiller | 0fe5ee7 | 2015-12-22 12:50:36 -0800 | [diff] [blame] | 638 | else # HAS_PKG_CONFIG=false |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 639 | LIBS_SECURE = $(OPENSSL_LIBS) |
Craig Tiller | 0fe5ee7 | 2015-12-22 12:50:36 -0800 | [diff] [blame] | 640 | endif # HAS_PKG_CONFIG |
| 641 | ifeq ($(HAS_SYSTEM_OPENSSL_NPN),true) |
| 642 | CPPFLAGS += -DTSI_OPENSSL_ALPN_SUPPORT=0 |
| 643 | LIBS_SECURE = $(OPENSSL_LIBS) |
| 644 | endif # HAS_SYSTEM_OPENSSL_NPN |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 645 | PC_LIBS_SECURE = $(addprefix -l, $(LIBS_SECURE)) |
Craig Tiller | 0fe5ee7 | 2015-12-22 12:50:36 -0800 | [diff] [blame] | 646 | endif # EMBED_OPENSSL |
| 647 | endif # NO_SECURE |
nnoble | 69ac39f | 2014-12-12 15:43:38 -0800 | [diff] [blame] | 648 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 649 | ifeq ($(OPENSSL_PKG_CONFIG),true) |
| 650 | LDLIBS_SECURE += $(shell $(PKG_CONFIG) --libs-only-l openssl) |
| 651 | else |
| 652 | LDLIBS_SECURE += $(addprefix -l, $(LIBS_SECURE)) |
| 653 | endif |
nnoble | 5b7f32a | 2014-12-22 08:12:44 -0800 | [diff] [blame] | 654 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 655 | # grpc .pc file |
| 656 | PC_NAME = gRPC |
Craig Tiller | da179ce | 2016-02-09 12:01:53 -0800 | [diff] [blame] | 657 | PC_DESCRIPTION = high performance general RPC framework |
| 658 | PC_CFLAGS = |
| 659 | PC_REQUIRES_PRIVATE = $(PC_REQUIRES_GRPC) $(PC_REQUIRES_SECURE) |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 660 | PC_LIBS_PRIVATE = $(PC_LIBS_GRPC) $(PC_LIBS_SECURE) |
| 661 | PC_LIB = -lgrpc |
Craig Tiller | 38b99e9 | 2016-09-15 16:18:09 -0700 | [diff] [blame] | 662 | GRPC_PC_FILE := $(CORE_PC_TEMPLATE) |
murgatroid99 | 8faab23 | 2015-06-30 17:24:21 -0700 | [diff] [blame] | 663 | |
Craig Tiller | 4a67be4 | 2016-02-09 12:40:32 -0800 | [diff] [blame] | 664 | # grpc_unsecure .pc file |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 665 | PC_NAME = gRPC unsecure |
Craig Tiller | da179ce | 2016-02-09 12:01:53 -0800 | [diff] [blame] | 666 | PC_DESCRIPTION = high performance general RPC framework without SSL |
| 667 | PC_CFLAGS = |
| 668 | PC_REQUIRES_PRIVATE = $(PC_REQUIRES_GRPC) |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 669 | PC_LIBS_PRIVATE = $(PC_LIBS_GRPC) |
| 670 | PC_LIB = -lgrpc |
Craig Tiller | 38b99e9 | 2016-09-15 16:18:09 -0700 | [diff] [blame] | 671 | GRPC_UNSECURE_PC_FILE := $(CORE_PC_TEMPLATE) |
murgatroid99 | 8faab23 | 2015-06-30 17:24:21 -0700 | [diff] [blame] | 672 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 673 | PROTOBUF_PKG_CONFIG = false |
murgatroid99 | da7a994 | 2015-06-29 14:57:37 -0700 | [diff] [blame] | 674 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 675 | PC_REQUIRES_GRPCXX = |
| 676 | PC_LIBS_GRPCXX = |
murgatroid99 | 8faab23 | 2015-06-30 17:24:21 -0700 | [diff] [blame] | 677 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 678 | CPPFLAGS := -Ithird_party/googletest/include $(CPPFLAGS) |
Craig Tiller | 16f6dac | 2015-08-24 17:00:04 -0700 | [diff] [blame] | 679 | |
Vijay Pai | cc7eb8e | 2016-07-19 19:03:55 -0700 | [diff] [blame] | 680 | PROTOC_PLUGINS_ALL =\ |
| 681 | % for tgt in targets: |
| 682 | % if tgt.build == 'protoc': |
| 683 | $(BINDIR)/$(CONFIG)/${tgt.name}\ |
| 684 | % endif |
| 685 | % endfor |
| 686 | |
| 687 | PROTOC_PLUGINS_DIR = $(BINDIR)/$(CONFIG) |
| 688 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 689 | ifeq ($(HAS_SYSTEM_PROTOBUF),true) |
| 690 | ifeq ($(HAS_PKG_CONFIG),true) |
| 691 | PROTOBUF_PKG_CONFIG = true |
| 692 | PC_REQUIRES_GRPCXX = protobuf |
| 693 | CPPFLAGS := $(shell $(PKG_CONFIG) --cflags protobuf) $(CPPFLAGS) |
| 694 | LDFLAGS_PROTOBUF_PKG_CONFIG = $(shell $(PKG_CONFIG) --libs-only-L protobuf) |
| 695 | ifeq ($(SYSTEM),Linux) |
| 696 | ifneq ($(LDFLAGS_PROTOBUF_PKG_CONFIG),) |
| 697 | LDFLAGS_PROTOBUF_PKG_CONFIG += $(shell $(PKG_CONFIG) --libs-only-L protobuf | sed s/L/Wl,-rpath,/) |
| 698 | endif |
| 699 | endif |
| 700 | else |
| 701 | PC_LIBS_GRPCXX = -lprotobuf |
| 702 | endif |
Nicolas "Pixel" Noble | f7fbdd4 | 2016-07-25 20:31:22 +0200 | [diff] [blame] | 703 | PROTOC_PLUGINS = $(PROTOC_PLUGINS_ALL) |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 704 | else |
| 705 | ifeq ($(HAS_EMBEDDED_PROTOBUF),true) |
| 706 | PROTOBUF_DEP = $(LIBDIR)/$(CONFIG)/protobuf/libprotobuf.a |
| 707 | CPPFLAGS := -Ithird_party/protobuf/src $(CPPFLAGS) |
| 708 | LDFLAGS := -L$(LIBDIR)/$(CONFIG)/protobuf $(LDFLAGS) |
Vijay Pai | cc7eb8e | 2016-07-19 19:03:55 -0700 | [diff] [blame] | 709 | ifneq ($(USE_BUILT_PROTOC),false) |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 710 | PROTOC = $(BINDIR)/$(CONFIG)/protobuf/protoc |
Vijay Pai | cc7eb8e | 2016-07-19 19:03:55 -0700 | [diff] [blame] | 711 | PROTOC_PLUGINS = $(PROTOC_PLUGINS_ALL) |
| 712 | else |
| 713 | PROTOC_PLUGINS = |
| 714 | PROTOC_PLUGINS_DIR = $(prefix)/bin |
| 715 | endif |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 716 | else |
| 717 | NO_PROTOBUF = true |
| 718 | endif |
| 719 | endif |
Nicolas Noble | 5383062 | 2015-02-12 16:56:38 -0800 | [diff] [blame] | 720 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 721 | LIBS_PROTOBUF = protobuf |
| 722 | LIBS_PROTOC = protoc protobuf |
Nicolas Noble | 5383062 | 2015-02-12 16:56:38 -0800 | [diff] [blame] | 723 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 724 | HOST_LDLIBS_PROTOC += $(addprefix -l, $(LIBS_PROTOC)) |
Nicolas Noble | 5383062 | 2015-02-12 16:56:38 -0800 | [diff] [blame] | 725 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 726 | ifeq ($(PROTOBUF_PKG_CONFIG),true) |
| 727 | LDLIBS_PROTOBUF += $(shell $(PKG_CONFIG) --libs-only-l protobuf) |
| 728 | else |
| 729 | LDLIBS_PROTOBUF += $(addprefix -l, $(LIBS_PROTOBUF)) |
| 730 | endif |
murgatroid99 | 24e2f4a | 2015-06-29 11:12:01 -0700 | [diff] [blame] | 731 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 732 | # grpc++ .pc file |
| 733 | PC_NAME = gRPC++ |
| 734 | PC_DESCRIPTION = C++ wrapper for gRPC |
| 735 | PC_CFLAGS = |
| 736 | PC_REQUIRES_PRIVATE = grpc $(PC_REQUIRES_GRPCXX) |
| 737 | PC_LIBS_PRIVATE = $(PC_LIBS_GRPCXX) |
| 738 | PC_LIB = -lgrpc++ |
Craig Tiller | 38b99e9 | 2016-09-15 16:18:09 -0700 | [diff] [blame] | 739 | GRPCXX_PC_FILE := $(CPP_PC_TEMPLATE) |
murgatroid99 | 8faab23 | 2015-06-30 17:24:21 -0700 | [diff] [blame] | 740 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 741 | # grpc++_unsecure .pc file |
| 742 | PC_NAME = gRPC++ unsecure |
| 743 | PC_DESCRIPTION = C++ wrapper for gRPC without SSL |
| 744 | PC_CFLAGS = |
| 745 | PC_REQUIRES_PRIVATE = grpc_unsecure $(PC_REQUIRES_GRPCXX) |
| 746 | PC_LIBS_PRIVATE = $(PC_LIBS_GRPCXX) |
| 747 | PC_LIB = -lgrpc++ |
Craig Tiller | 38b99e9 | 2016-09-15 16:18:09 -0700 | [diff] [blame] | 748 | GRPCXX_UNSECURE_PC_FILE := $(CPP_PC_TEMPLATE) |
murgatroid99 | 8faab23 | 2015-06-30 17:24:21 -0700 | [diff] [blame] | 749 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 750 | ifeq ($(MAKECMDGOALS),clean) |
| 751 | NO_DEPS = true |
| 752 | endif |
nnoble | 69ac39f | 2014-12-12 15:43:38 -0800 | [diff] [blame] | 753 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 754 | .SECONDARY = %.pb.h %.pb.cc |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 755 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 756 | ifeq ($(DEP_MISSING),) |
| 757 | all: static shared plugins\ |
| 758 | % for tgt in targets: |
| 759 | % if tgt.build == 'all': |
| 760 | $(BINDIR)/$(CONFIG)/${tgt.name}\ |
| 761 | % endif |
| 762 | % endfor |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 763 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 764 | dep_error: |
| 765 | @echo "You shouldn't see this message - all of your dependencies are correct." |
| 766 | else |
| 767 | all: dep_error git_update stop |
nnoble | 69ac39f | 2014-12-12 15:43:38 -0800 | [diff] [blame] | 768 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 769 | dep_error: |
| 770 | @echo |
| 771 | @echo "DEPENDENCY ERROR" |
| 772 | @echo |
| 773 | @echo "You are missing system dependencies that are essential to build grpc," |
| 774 | @echo "and the third_party directory doesn't have them:" |
| 775 | @echo |
| 776 | @echo " $(DEP_MISSING)" |
| 777 | @echo |
| 778 | @echo "Installing the development packages for your system will solve" |
| 779 | @echo "this issue. Please consult INSTALL to get more information." |
| 780 | @echo |
| 781 | @echo "If you need information about why these tests failed, run:" |
| 782 | @echo |
| 783 | @echo " make run_dep_checks" |
| 784 | @echo |
| 785 | endif |
nnoble | 69ac39f | 2014-12-12 15:43:38 -0800 | [diff] [blame] | 786 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 787 | git_update: |
| 788 | ifeq ($(IS_GIT_FOLDER),true) |
| 789 | @echo "Additionally, since you are in a git clone, you can download the" |
| 790 | @echo "missing dependencies in third_party by running the following command:" |
| 791 | @echo |
| 792 | @echo " git submodule update --init" |
| 793 | @echo |
| 794 | endif |
nnoble | 69ac39f | 2014-12-12 15:43:38 -0800 | [diff] [blame] | 795 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 796 | openssl_dep_error: openssl_dep_message git_update stop |
nnoble | 69ac39f | 2014-12-12 15:43:38 -0800 | [diff] [blame] | 797 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 798 | protobuf_dep_error: protobuf_dep_message git_update stop |
Nicolas Noble | 5383062 | 2015-02-12 16:56:38 -0800 | [diff] [blame] | 799 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 800 | protoc_dep_error: protoc_dep_message git_update stop |
Nicolas Noble | 5383062 | 2015-02-12 16:56:38 -0800 | [diff] [blame] | 801 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 802 | openssl_dep_message: |
| 803 | @echo |
| 804 | @echo "DEPENDENCY ERROR" |
| 805 | @echo |
Craig Tiller | b79c1e1 | 2016-02-23 10:00:58 -0800 | [diff] [blame] | 806 | @echo "The target you are trying to run requires an OpenSSL implementation." |
| 807 | @echo "Your system doesn't have one, and either the third_party directory" |
| 808 | @echo "doesn't have it, or your compiler can't build BoringSSL." |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 809 | @echo |
| 810 | @echo "Please consult INSTALL to get more information." |
| 811 | @echo |
| 812 | @echo "If you need information about why these tests failed, run:" |
| 813 | @echo |
| 814 | @echo " make run_dep_checks" |
| 815 | @echo |
nnoble | 69ac39f | 2014-12-12 15:43:38 -0800 | [diff] [blame] | 816 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 817 | protobuf_dep_message: |
| 818 | @echo |
| 819 | @echo "DEPENDENCY ERROR" |
| 820 | @echo |
| 821 | @echo "The target you are trying to run requires protobuf 3.0.0+" |
| 822 | @echo "Your system doesn't have it, and neither does the third_party directory." |
| 823 | @echo |
| 824 | @echo "Please consult INSTALL to get more information." |
| 825 | @echo |
| 826 | @echo "If you need information about why these tests failed, run:" |
| 827 | @echo |
| 828 | @echo " make run_dep_checks" |
| 829 | @echo |
Nicolas Noble | 5383062 | 2015-02-12 16:56:38 -0800 | [diff] [blame] | 830 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 831 | protoc_dep_message: |
| 832 | @echo |
| 833 | @echo "DEPENDENCY ERROR" |
| 834 | @echo |
| 835 | @echo "The target you are trying to run requires protobuf-compiler 3.0.0+" |
| 836 | @echo "Your system doesn't have it, and neither does the third_party directory." |
| 837 | @echo |
| 838 | @echo "Please consult INSTALL to get more information." |
| 839 | @echo |
| 840 | @echo "If you need information about why these tests failed, run:" |
| 841 | @echo |
| 842 | @echo " make run_dep_checks" |
| 843 | @echo |
Nicolas Noble | 5383062 | 2015-02-12 16:56:38 -0800 | [diff] [blame] | 844 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 845 | systemtap_dep_error: |
| 846 | @echo |
| 847 | @echo "DEPENDENCY ERROR" |
| 848 | @echo |
| 849 | @echo "Under the '$(CONFIG)' configutation, the target you are trying " |
| 850 | @echo "to build requires systemtap 2.7+ (on Linux) or dtrace (on other " |
| 851 | @echo "platforms such as Solaris and *BSD). " |
| 852 | @echo |
| 853 | @echo "Please consult INSTALL to get more information." |
| 854 | @echo |
David Garcia Quintas | 8954e90 | 2015-04-29 09:46:33 -0700 | [diff] [blame] | 855 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 856 | stop: |
| 857 | @false |
nnoble | 69ac39f | 2014-12-12 15:43:38 -0800 | [diff] [blame] | 858 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 859 | % for tgt in targets: |
| 860 | ${tgt.name}: $(BINDIR)/$(CONFIG)/${tgt.name} |
| 861 | % endfor |
ctiller | 09cb6d5 | 2014-12-19 17:38:22 -0800 | [diff] [blame] | 862 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 863 | run_dep_checks: |
| 864 | $(OPENSSL_ALPN_CHECK_CMD) || true |
| 865 | $(OPENSSL_NPN_CHECK_CMD) || true |
| 866 | $(ZLIB_CHECK_CMD) || true |
| 867 | $(PERFTOOLS_CHECK_CMD) || true |
| 868 | $(PROTOBUF_CHECK_CMD) || true |
| 869 | $(PROTOC_CHECK_VERSION_CMD) || true |
nnoble | 69ac39f | 2014-12-12 15:43:38 -0800 | [diff] [blame] | 870 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 871 | third_party/protobuf/configure: |
| 872 | $(E) "[AUTOGEN] Preparing protobuf" |
| 873 | $(Q)(cd third_party/protobuf ; autoreconf -f -i -Wall,no-obsolete) |
Nicolas Noble | 5383062 | 2015-02-12 16:56:38 -0800 | [diff] [blame] | 874 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 875 | $(LIBDIR)/$(CONFIG)/protobuf/libprotobuf.a: third_party/protobuf/configure |
| 876 | $(E) "[MAKE] Building protobuf" |
Vijay Pai | cc7eb8e | 2016-07-19 19:03:55 -0700 | [diff] [blame] | 877 | $(Q)(cd third_party/protobuf ; CC="$(CC)" CXX="$(CXX)" LDFLAGS="$(LDFLAGS_$(CONFIG)) -g $(PROTOBUF_LDFLAGS_EXTRA)" CPPFLAGS="$(PIC_CPPFLAGS) $(CPPFLAGS_$(CONFIG)) -g $(PROTOBUF_CPPFLAGS_EXTRA)" ./configure --disable-shared --enable-static $(PROTOBUF_CONFIG_OPTS)) |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 878 | $(Q)$(MAKE) -C third_party/protobuf clean |
| 879 | $(Q)$(MAKE) -C third_party/protobuf |
| 880 | $(Q)mkdir -p $(LIBDIR)/$(CONFIG)/protobuf |
| 881 | $(Q)mkdir -p $(BINDIR)/$(CONFIG)/protobuf |
| 882 | $(Q)cp third_party/protobuf/src/.libs/libprotoc.a $(LIBDIR)/$(CONFIG)/protobuf |
| 883 | $(Q)cp third_party/protobuf/src/.libs/libprotobuf.a $(LIBDIR)/$(CONFIG)/protobuf |
| 884 | $(Q)cp third_party/protobuf/src/protoc $(BINDIR)/$(CONFIG)/protobuf |
Nicolas Noble | 5383062 | 2015-02-12 16:56:38 -0800 | [diff] [blame] | 885 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 886 | static: static_c static_cxx |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 887 | |
Craig Tiller | eda85c6 | 2016-07-01 12:45:19 -0700 | [diff] [blame] | 888 | static_c: pc_c pc_c_unsecure cache.mk \ |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 889 | % for lib in libs: |
Nicolas "Pixel" Noble | e0dbd3f | 2016-02-23 00:21:38 +0100 | [diff] [blame] | 890 | % if 'Makefile' in lib.get('build_system', ['Makefile']): |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 891 | % if lib.build == 'all' and lib.language == 'c' and not lib.get('external_deps', None): |
| 892 | $(LIBDIR)/$(CONFIG)/lib${lib.name}.a\ |
| 893 | % endif |
Nicolas "Pixel" Noble | e0dbd3f | 2016-02-23 00:21:38 +0100 | [diff] [blame] | 894 | % endif |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 895 | % endfor |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 896 | |
| 897 | |
Nicolas "Pixel" Noble | 0912179 | 2016-01-30 09:01:53 +0100 | [diff] [blame] | 898 | static_cxx: pc_cxx pc_cxx_unsecure cache.mk \ |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 899 | % for lib in libs: |
Nicolas "Pixel" Noble | e0dbd3f | 2016-02-23 00:21:38 +0100 | [diff] [blame] | 900 | % if 'Makefile' in lib.get('build_system', ['Makefile']): |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 901 | % if lib.build == 'all' and lib.language == 'c++': |
| 902 | $(LIBDIR)/$(CONFIG)/lib${lib.name}.a\ |
| 903 | % endif |
Nicolas "Pixel" Noble | e0dbd3f | 2016-02-23 00:21:38 +0100 | [diff] [blame] | 904 | % endif |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 905 | % endfor |
nnoble | 29e1d29 | 2014-12-01 10:27:40 -0800 | [diff] [blame] | 906 | |
| 907 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 908 | shared: shared_c shared_cxx |
nnoble | 29e1d29 | 2014-12-01 10:27:40 -0800 | [diff] [blame] | 909 | |
Craig Tiller | eda85c6 | 2016-07-01 12:45:19 -0700 | [diff] [blame] | 910 | shared_c: pc_c pc_c_unsecure cache.mk\ |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 911 | % for lib in libs: |
Nicolas "Pixel" Noble | e0dbd3f | 2016-02-23 00:21:38 +0100 | [diff] [blame] | 912 | % if 'Makefile' in lib.get('build_system', ['Makefile']): |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 913 | % if lib.build == 'all' and lib.language == 'c' and not lib.get('external_deps', None): |
Craig Tiller | 27f7084 | 2016-09-15 16:21:54 -0700 | [diff] [blame] | 914 | $(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)${lib.name}$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE)\ |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 915 | % endif |
Nicolas "Pixel" Noble | e0dbd3f | 2016-02-23 00:21:38 +0100 | [diff] [blame] | 916 | % endif |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 917 | % endfor |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 918 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 919 | shared_cxx: pc_cxx pc_cxx_unsecure cache.mk\ |
| 920 | % for lib in libs: |
Nicolas "Pixel" Noble | e0dbd3f | 2016-02-23 00:21:38 +0100 | [diff] [blame] | 921 | % if 'Makefile' in lib.get('build_system', ['Makefile']): |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 922 | % if lib.build == 'all' and lib.language == 'c++': |
Craig Tiller | 27f7084 | 2016-09-15 16:21:54 -0700 | [diff] [blame] | 923 | $(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)${lib.name}$(SHARED_VERSION_CPP).$(SHARED_EXT_CPP)\ |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 924 | % endif |
Nicolas "Pixel" Noble | e0dbd3f | 2016-02-23 00:21:38 +0100 | [diff] [blame] | 925 | % endif |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 926 | % endfor |
nnoble | 29e1d29 | 2014-12-01 10:27:40 -0800 | [diff] [blame] | 927 | |
| 928 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 929 | shared_csharp: shared_c \ |
| 930 | % for lib in libs: |
Nicolas "Pixel" Noble | e0dbd3f | 2016-02-23 00:21:38 +0100 | [diff] [blame] | 931 | % if 'Makefile' in lib.get('build_system', ['Makefile']): |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 932 | % if lib.build == 'all' and lib.language == 'csharp': |
Craig Tiller | 27f7084 | 2016-09-15 16:21:54 -0700 | [diff] [blame] | 933 | $(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)${lib.name}$(SHARED_VERSION_CSHARP).$(SHARED_EXT_CSHARP)\ |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 934 | % endif |
Nicolas "Pixel" Noble | e0dbd3f | 2016-02-23 00:21:38 +0100 | [diff] [blame] | 935 | % endif |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 936 | % endfor |
Jan Tattermusch | 2ec0b3e | 2015-02-18 15:03:12 -0800 | [diff] [blame] | 937 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 938 | grpc_csharp_ext: shared_csharp |
Jan Tattermusch | 2ec0b3e | 2015-02-18 15:03:12 -0800 | [diff] [blame] | 939 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 940 | plugins: $(PROTOC_PLUGINS) |
Nicolas "Pixel" Noble | 522d712 | 2015-02-19 01:28:02 +0100 | [diff] [blame] | 941 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 942 | privatelibs: privatelibs_c privatelibs_cxx |
nnoble | 29e1d29 | 2014-12-01 10:27:40 -0800 | [diff] [blame] | 943 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 944 | privatelibs_c: \ |
| 945 | % for lib in libs: |
Nicolas "Pixel" Noble | e0dbd3f | 2016-02-23 00:21:38 +0100 | [diff] [blame] | 946 | % if 'Makefile' in lib.get('build_system', ['Makefile']): |
Craig Tiller | 0fe5ee7 | 2015-12-22 12:50:36 -0800 | [diff] [blame] | 947 | % if lib.build == 'private' and lib.language == 'c' and not lib.get('external_deps', None) and not lib.boringssl: |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 948 | $(LIBDIR)/$(CONFIG)/lib${lib.name}.a\ |
| 949 | % endif |
Nicolas "Pixel" Noble | e0dbd3f | 2016-02-23 00:21:38 +0100 | [diff] [blame] | 950 | % endif |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 951 | % endfor |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 952 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 953 | pc_c: $(LIBDIR)/$(CONFIG)/pkgconfig/grpc.pc |
murgatroid99 | 8faab23 | 2015-06-30 17:24:21 -0700 | [diff] [blame] | 954 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 955 | pc_c_unsecure: $(LIBDIR)/$(CONFIG)/pkgconfig/grpc_unsecure.pc |
murgatroid99 | 8faab23 | 2015-06-30 17:24:21 -0700 | [diff] [blame] | 956 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 957 | pc_cxx: $(LIBDIR)/$(CONFIG)/pkgconfig/grpc++.pc |
murgatroid99 | 8faab23 | 2015-06-30 17:24:21 -0700 | [diff] [blame] | 958 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 959 | pc_cxx_unsecure: $(LIBDIR)/$(CONFIG)/pkgconfig/grpc++_unsecure.pc |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 960 | |
vjpai | 2041092 | 2016-06-15 09:21:42 -0700 | [diff] [blame] | 961 | ifeq ($(EMBED_OPENSSL),true) |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 962 | privatelibs_cxx: \ |
| 963 | % for lib in libs: |
Nicolas "Pixel" Noble | e0dbd3f | 2016-02-23 00:21:38 +0100 | [diff] [blame] | 964 | % if 'Makefile' in lib.get('build_system', ['Makefile']): |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 965 | % if lib.build == 'private' and lib.language == 'c++' and not lib.get('external_deps', None): |
| 966 | $(LIBDIR)/$(CONFIG)/lib${lib.name}.a\ |
| 967 | % endif |
Nicolas "Pixel" Noble | e0dbd3f | 2016-02-23 00:21:38 +0100 | [diff] [blame] | 968 | % endif |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 969 | % endfor |
Craig Tiller | eda85c6 | 2016-07-01 12:45:19 -0700 | [diff] [blame] | 970 | |
vjpai | 2041092 | 2016-06-15 09:21:42 -0700 | [diff] [blame] | 971 | else |
| 972 | privatelibs_cxx: \ |
| 973 | % for lib in libs: |
| 974 | % if 'Makefile' in lib.get('build_system', ['Makefile']): |
| 975 | % if lib.build == 'private' and lib.language == 'c++' and not lib.get('external_deps', None) and not lib.boringssl: |
| 976 | $(LIBDIR)/$(CONFIG)/lib${lib.name}.a\ |
| 977 | % endif |
| 978 | % endif |
| 979 | % endfor |
Craig Tiller | eda85c6 | 2016-07-01 12:45:19 -0700 | [diff] [blame] | 980 | |
vjpai | 2041092 | 2016-06-15 09:21:42 -0700 | [diff] [blame] | 981 | endif |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 982 | |
| 983 | |
Craig Tiller | eda85c6 | 2016-07-01 12:45:19 -0700 | [diff] [blame] | 984 | buildtests: buildtests_c buildtests_cxx |
nnoble | 29e1d29 | 2014-12-01 10:27:40 -0800 | [diff] [blame] | 985 | |
Craig Tiller | 3824b6e | 2015-12-09 11:19:59 -0800 | [diff] [blame] | 986 | buildtests_c: privatelibs_c <%text>\</%text> |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 987 | % for tgt in targets: |
| 988 | % if tgt.build == 'test' and not tgt.language == 'c++' and not tgt.get('external_deps', None): |
Craig Tiller | 3824b6e | 2015-12-09 11:19:59 -0800 | [diff] [blame] | 989 | $(BINDIR)/$(CONFIG)/${tgt.name} <%text>\</%text> |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 990 | % endif |
| 991 | % endfor |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 992 | |
| 993 | |
vjpai | 2041092 | 2016-06-15 09:21:42 -0700 | [diff] [blame] | 994 | ifeq ($(EMBED_OPENSSL),true) |
Craig Tiller | eda85c6 | 2016-07-01 12:45:19 -0700 | [diff] [blame] | 995 | buildtests_cxx: privatelibs_cxx <%text>\</%text> |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 996 | % for tgt in targets: |
| 997 | % if tgt.build == 'test' and tgt.language == 'c++' and not tgt.get('external_deps', None): |
Craig Tiller | 3824b6e | 2015-12-09 11:19:59 -0800 | [diff] [blame] | 998 | $(BINDIR)/$(CONFIG)/${tgt.name} <%text>\</%text> |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 999 | % endif |
| 1000 | % endfor |
Craig Tiller | eda85c6 | 2016-07-01 12:45:19 -0700 | [diff] [blame] | 1001 | |
vjpai | 2041092 | 2016-06-15 09:21:42 -0700 | [diff] [blame] | 1002 | else |
Craig Tiller | eda85c6 | 2016-07-01 12:45:19 -0700 | [diff] [blame] | 1003 | buildtests_cxx: privatelibs_cxx <%text>\</%text> |
vjpai | 2041092 | 2016-06-15 09:21:42 -0700 | [diff] [blame] | 1004 | % for tgt in targets: |
| 1005 | % if tgt.build == 'test' and tgt.language == 'c++' and not tgt.get('external_deps', None) and not tgt.boringssl: |
| 1006 | $(BINDIR)/$(CONFIG)/${tgt.name} <%text>\</%text> |
| 1007 | % endif |
| 1008 | % endfor |
Craig Tiller | eda85c6 | 2016-07-01 12:45:19 -0700 | [diff] [blame] | 1009 | |
vjpai | 2041092 | 2016-06-15 09:21:42 -0700 | [diff] [blame] | 1010 | endif |
nnoble | 29e1d29 | 2014-12-01 10:27:40 -0800 | [diff] [blame] | 1011 | |
| 1012 | |
Craig Tiller | eda85c6 | 2016-07-01 12:45:19 -0700 | [diff] [blame] | 1013 | test: test_c test_cxx |
nnoble | 29e1d29 | 2014-12-01 10:27:40 -0800 | [diff] [blame] | 1014 | |
Craig Tiller | eda85c6 | 2016-07-01 12:45:19 -0700 | [diff] [blame] | 1015 | flaky_test: flaky_test_c flaky_test_cxx |
Nicolas "Pixel" Noble | 4251d56 | 2015-05-22 19:43:39 +0200 | [diff] [blame] | 1016 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1017 | test_c: buildtests_c |
| 1018 | % for tgt in targets: |
| 1019 | % if tgt.build == 'test' and tgt.get('run', True) and not tgt.language == 'c++' and not tgt.get('flaky', False) and not tgt.get('external_deps', None): |
| 1020 | $(E) "[RUN] Testing ${tgt.name}" |
| 1021 | $(Q) $(BINDIR)/$(CONFIG)/${tgt.name} || ( echo test ${tgt.name} failed ; exit 1 ) |
| 1022 | % endif |
| 1023 | % endfor |
Nicolas "Pixel" Noble | 4251d56 | 2015-05-22 19:43:39 +0200 | [diff] [blame] | 1024 | |
| 1025 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1026 | flaky_test_c: buildtests_c |
| 1027 | % for tgt in targets: |
| 1028 | % if tgt.build == 'test' and tgt.get('run', True) and not tgt.language == 'c++' and tgt.get('flaky', False) and not tgt.get('external_deps', None): |
| 1029 | $(E) "[RUN] Testing ${tgt.name}" |
| 1030 | $(Q) $(BINDIR)/$(CONFIG)/${tgt.name} || ( echo test ${tgt.name} failed ; exit 1 ) |
| 1031 | % endif |
| 1032 | % endfor |
nnoble | 29e1d29 | 2014-12-01 10:27:40 -0800 | [diff] [blame] | 1033 | |
| 1034 | |
Craig Tiller | eda85c6 | 2016-07-01 12:45:19 -0700 | [diff] [blame] | 1035 | test_cxx: buildtests_cxx |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1036 | % for tgt in targets: |
| 1037 | % if tgt.build == 'test' and tgt.get('run', True) and tgt.language == 'c++' and not tgt.get('flaky', False) and not tgt.get('external_deps', None): |
| 1038 | $(E) "[RUN] Testing ${tgt.name}" |
| 1039 | $(Q) $(BINDIR)/$(CONFIG)/${tgt.name} || ( echo test ${tgt.name} failed ; exit 1 ) |
| 1040 | % endif |
| 1041 | % endfor |
Nicolas "Pixel" Noble | 4251d56 | 2015-05-22 19:43:39 +0200 | [diff] [blame] | 1042 | |
| 1043 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1044 | flaky_test_cxx: buildtests_cxx |
| 1045 | % for tgt in targets: |
| 1046 | % if tgt.build == 'test' and tgt.get('run', True) and tgt.language == 'c++' and tgt.get('flaky', False) and not tgt.get('external_deps', None): |
| 1047 | $(E) "[RUN] Testing ${tgt.name}" |
| 1048 | $(Q) $(BINDIR)/$(CONFIG)/${tgt.name} || ( echo test ${tgt.name} failed ; exit 1 ) |
| 1049 | % endif |
| 1050 | % endfor |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 1051 | |
| 1052 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1053 | test_python: static_c |
| 1054 | $(E) "[RUN] Testing python code" |
| 1055 | $(Q) tools/run_tests/run_tests.py -lpython -c$(CONFIG) |
Nicolas "Pixel" Noble | 051a28f | 2015-03-17 22:54:54 +0100 | [diff] [blame] | 1056 | |
| 1057 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1058 | tools: tools_c tools_cxx |
Craig Tiller | 7552f0f | 2015-06-19 17:46:20 -0700 | [diff] [blame] | 1059 | |
| 1060 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1061 | tools_c: privatelibs_c\ |
| 1062 | % for tgt in targets: |
| 1063 | % if tgt.build == 'tool' and not tgt.language=='c++': |
| 1064 | $(BINDIR)/$(CONFIG)/${tgt.name}\ |
| 1065 | % endif |
| 1066 | % endfor |
Craig Tiller | 7552f0f | 2015-06-19 17:46:20 -0700 | [diff] [blame] | 1067 | |
| 1068 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1069 | tools_cxx: privatelibs_cxx\ |
| 1070 | % for tgt in targets: |
| 1071 | % if tgt.build == 'tool' and tgt.language=='c++': |
| 1072 | $(BINDIR)/$(CONFIG)/${tgt.name}\ |
| 1073 | % endif |
| 1074 | % endfor |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 1075 | |
| 1076 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1077 | buildbenchmarks: privatelibs\ |
| 1078 | % for tgt in targets: |
| 1079 | % if tgt.build == 'benchmark': |
| 1080 | $(BINDIR)/$(CONFIG)/${tgt.name}\ |
| 1081 | % endif |
| 1082 | % endfor |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 1083 | |
| 1084 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1085 | benchmarks: buildbenchmarks |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 1086 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1087 | strip: strip-static strip-shared |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 1088 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1089 | strip-static: strip-static_c strip-static_cxx |
nnoble | 20e2e3f | 2014-12-16 15:37:57 -0800 | [diff] [blame] | 1090 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1091 | strip-shared: strip-shared_c strip-shared_cxx |
nnoble | 20e2e3f | 2014-12-16 15:37:57 -0800 | [diff] [blame] | 1092 | |
Nicolas Noble | 047b727 | 2015-01-16 13:55:05 -0800 | [diff] [blame] | 1093 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1094 | # TODO(nnoble): the strip target is stripping in-place, instead |
| 1095 | # of copying files in a temporary folder. |
| 1096 | # This prevents proper debugging after running make install. |
Nicolas Noble | 047b727 | 2015-01-16 13:55:05 -0800 | [diff] [blame] | 1097 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1098 | strip-static_c: static_c |
| 1099 | ifeq ($(CONFIG),opt) |
| 1100 | % for lib in libs: |
Nicolas "Pixel" Noble | e0dbd3f | 2016-02-23 00:21:38 +0100 | [diff] [blame] | 1101 | % if 'Makefile' in lib.get('build_system', ['Makefile']): |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1102 | % if lib.language == "c": |
| 1103 | % if lib.build == "all": |
| 1104 | % if not lib.get('external_deps', None): |
| 1105 | $(E) "[STRIP] Stripping lib${lib.name}.a" |
| 1106 | $(Q) $(STRIP) $(LIBDIR)/$(CONFIG)/lib${lib.name}.a |
| 1107 | % endif |
| 1108 | % endif |
| 1109 | % endif |
Nicolas "Pixel" Noble | e0dbd3f | 2016-02-23 00:21:38 +0100 | [diff] [blame] | 1110 | % endif |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1111 | % endfor |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1112 | endif |
nnoble | 85a4926 | 2014-12-08 18:14:03 -0800 | [diff] [blame] | 1113 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1114 | strip-static_cxx: static_cxx |
| 1115 | ifeq ($(CONFIG),opt) |
| 1116 | % for lib in libs: |
Nicolas "Pixel" Noble | e0dbd3f | 2016-02-23 00:21:38 +0100 | [diff] [blame] | 1117 | % if 'Makefile' in lib.get('build_system', ['Makefile']): |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1118 | % if lib.language == "c++": |
| 1119 | % if lib.build == "all": |
| 1120 | $(E) "[STRIP] Stripping lib${lib.name}.a" |
| 1121 | $(Q) $(STRIP) $(LIBDIR)/$(CONFIG)/lib${lib.name}.a |
| 1122 | % endif |
| 1123 | % endif |
Nicolas "Pixel" Noble | e0dbd3f | 2016-02-23 00:21:38 +0100 | [diff] [blame] | 1124 | % endif |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1125 | % endfor |
| 1126 | endif |
Nicolas "Pixel" Noble | 4ef9b86 | 2015-08-14 19:35:24 +0200 | [diff] [blame] | 1127 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1128 | strip-shared_c: shared_c |
| 1129 | ifeq ($(CONFIG),opt) |
| 1130 | % for lib in libs: |
Nicolas "Pixel" Noble | e0dbd3f | 2016-02-23 00:21:38 +0100 | [diff] [blame] | 1131 | % if 'Makefile' in lib.get('build_system', ['Makefile']): |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1132 | % if lib.language == "c": |
| 1133 | % if lib.build == "all": |
| 1134 | % if not lib.get('external_deps', None): |
Craig Tiller | 27f7084 | 2016-09-15 16:21:54 -0700 | [diff] [blame] | 1135 | $(E) "[STRIP] Stripping $(SHARED_PREFIX)${lib.name}$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE)" |
| 1136 | $(Q) $(STRIP) $(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)${lib.name}$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1137 | % endif |
| 1138 | % endif |
| 1139 | % endif |
Nicolas "Pixel" Noble | e0dbd3f | 2016-02-23 00:21:38 +0100 | [diff] [blame] | 1140 | % endif |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1141 | % endfor |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1142 | endif |
nnoble | 85a4926 | 2014-12-08 18:14:03 -0800 | [diff] [blame] | 1143 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1144 | strip-shared_cxx: shared_cxx |
| 1145 | ifeq ($(CONFIG),opt) |
| 1146 | % for lib in libs: |
Nicolas "Pixel" Noble | e0dbd3f | 2016-02-23 00:21:38 +0100 | [diff] [blame] | 1147 | % if 'Makefile' in lib.get('build_system', ['Makefile']): |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1148 | % if lib.language == "c++": |
| 1149 | % if lib.build == "all": |
Craig Tiller | 27f7084 | 2016-09-15 16:21:54 -0700 | [diff] [blame] | 1150 | $(E) "[STRIP] Stripping $(SHARED_PREFIX)${lib.name}$(SHARED_VERSION_CPP).$(SHARED_EXT_CPP)" |
| 1151 | $(Q) $(STRIP) $(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)${lib.name}$(SHARED_VERSION_CPP).$(SHARED_EXT_CPP) |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1152 | % endif |
| 1153 | % endif |
Nicolas "Pixel" Noble | e0dbd3f | 2016-02-23 00:21:38 +0100 | [diff] [blame] | 1154 | % endif |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1155 | % endfor |
| 1156 | endif |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 1157 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1158 | strip-shared_csharp: shared_csharp |
| 1159 | ifeq ($(CONFIG),opt) |
| 1160 | % for lib in libs: |
Nicolas "Pixel" Noble | e0dbd3f | 2016-02-23 00:21:38 +0100 | [diff] [blame] | 1161 | % if 'Makefile' in lib.get('build_system', ['Makefile']): |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1162 | % if lib.language == "csharp": |
| 1163 | % if lib.build == "all": |
Craig Tiller | 27f7084 | 2016-09-15 16:21:54 -0700 | [diff] [blame] | 1164 | $(E) "[STRIP] Stripping $(SHARED_PREFIX)${lib.name}$(SHARED_VERSION_CSHARP).$(SHARED_EXT_CSHARP)" |
| 1165 | $(Q) $(STRIP) $(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)${lib.name}$(SHARED_VERSION_CSHARP).$(SHARED_EXT_CSHARP) |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1166 | % endif |
| 1167 | % endif |
Nicolas "Pixel" Noble | e0dbd3f | 2016-02-23 00:21:38 +0100 | [diff] [blame] | 1168 | % endif |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1169 | % endfor |
| 1170 | endif |
Jan Tattermusch | 2ec0b3e | 2015-02-18 15:03:12 -0800 | [diff] [blame] | 1171 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1172 | cache.mk:: |
| 1173 | $(E) "[MAKE] Generating $@" |
| 1174 | $(Q) echo "$(CACHE_MK)" | tr , '\n' >$@ |
murgatroid99 | aa52157 | 2015-07-10 14:49:12 -0700 | [diff] [blame] | 1175 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1176 | $(LIBDIR)/$(CONFIG)/pkgconfig/grpc.pc: |
| 1177 | $(E) "[MAKE] Generating $@" |
| 1178 | $(Q) mkdir -p $(@D) |
| 1179 | $(Q) echo "$(GRPC_PC_FILE)" | tr , '\n' >$@ |
murgatroid99 | 8faab23 | 2015-06-30 17:24:21 -0700 | [diff] [blame] | 1180 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1181 | $(LIBDIR)/$(CONFIG)/pkgconfig/grpc_unsecure.pc: |
| 1182 | $(E) "[MAKE] Generating $@" |
| 1183 | $(Q) mkdir -p $(@D) |
| 1184 | $(Q) echo "$(GRPC_UNSECURE_PC_FILE)" | tr , '\n' >$@ |
murgatroid99 | 8faab23 | 2015-06-30 17:24:21 -0700 | [diff] [blame] | 1185 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1186 | $(LIBDIR)/$(CONFIG)/pkgconfig/grpc++.pc: |
| 1187 | $(E) "[MAKE] Generating $@" |
| 1188 | $(Q) mkdir -p $(@D) |
| 1189 | $(Q) echo "$(GRPCXX_PC_FILE)" | tr , '\n' >$@ |
murgatroid99 | 8faab23 | 2015-06-30 17:24:21 -0700 | [diff] [blame] | 1190 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1191 | $(LIBDIR)/$(CONFIG)/pkgconfig/grpc++_unsecure.pc: |
| 1192 | $(E) "[MAKE] Generating $@" |
| 1193 | $(Q) mkdir -p $(@D) |
| 1194 | $(Q) echo "$(GRPCXX_UNSECURE_PC_FILE)" | tr , '\n' >$@ |
murgatroid99 | 8faab23 | 2015-06-30 17:24:21 -0700 | [diff] [blame] | 1195 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1196 | % for p in protos: |
| 1197 | ifeq ($(NO_PROTOC),true) |
| 1198 | $(GENDIR)/${p}.pb.cc: protoc_dep_error |
| 1199 | $(GENDIR)/${p}.grpc.pb.cc: protoc_dep_error |
| 1200 | else |
Craig Tiller | 1b4e330 | 2015-12-17 16:35:00 -0800 | [diff] [blame] | 1201 | $(GENDIR)/${p}.pb.cc: ${p}.proto $(PROTOBUF_DEP) $(PROTOC_PLUGINS) ${' '.join('$(GENDIR)/%s.pb.cc' % q for q in proto_deps.get(p, []))} |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1202 | $(E) "[PROTOC] Generating protobuf CC file from $<" |
| 1203 | $(Q) mkdir -p `dirname $@` |
David Garcia Quintas | e68ed6f | 2016-06-17 12:49:14 -0700 | [diff] [blame] | 1204 | $(Q) $(PROTOC) -Ithird_party/protobuf/src -I. --cpp_out=$(GENDIR) $< |
Nicolas "Pixel" Noble | 0caebbf | 2015-04-09 23:08:51 +0200 | [diff] [blame] | 1205 | |
Craig Tiller | 1b4e330 | 2015-12-17 16:35:00 -0800 | [diff] [blame] | 1206 | $(GENDIR)/${p}.grpc.pb.cc: ${p}.proto $(PROTOBUF_DEP) $(PROTOC_PLUGINS) ${' '.join('$(GENDIR)/%s.pb.cc $(GENDIR)/%s.grpc.pb.cc' % (q,q) for q in proto_deps.get(p, []))} |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1207 | $(E) "[GRPC] Generating gRPC's protobuf service CC file from $<" |
| 1208 | $(Q) mkdir -p `dirname $@` |
Mario Emmenlauer | 121d289 | 2016-12-12 23:49:27 +0100 | [diff] [blame] | 1209 | $(Q) $(PROTOC) -Ithird_party/protobuf/src -I. --grpc_out=$(GENDIR) --plugin=protoc-gen-grpc=$(PROTOC_PLUGINS_DIR)/grpc_cpp_plugin$(EXECUTABLE_SUFFIX) $< |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1210 | endif |
nnoble | 72309c6 | 2014-12-12 11:42:26 -0800 | [diff] [blame] | 1211 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1212 | % endfor |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 1213 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1214 | ifeq ($(CONFIG),stapprof) |
| 1215 | src/core/profiling/stap_timers.c: $(GENDIR)/src/core/profiling/stap_probes.h |
| 1216 | ifeq ($(HAS_SYSTEMTAP),true) |
| 1217 | $(GENDIR)/src/core/profiling/stap_probes.h: src/core/profiling/stap_probes.d |
| 1218 | $(E) "[DTRACE] Compiling $<" |
| 1219 | $(Q) mkdir -p `dirname $@` |
| 1220 | $(Q) $(DTRACE) -C -h -s $< -o $@ |
| 1221 | else |
| 1222 | $(GENDIR)/src/core/profiling/stap_probes.h: systemtap_dep_error stop |
| 1223 | endif |
| 1224 | endif |
David Garcia Quintas | 611b736 | 2015-04-27 15:49:31 -0700 | [diff] [blame] | 1225 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1226 | $(OBJDIR)/$(CONFIG)/%.o : %.c |
| 1227 | $(E) "[C] Compiling $<" |
| 1228 | $(Q) mkdir -p `dirname $@` |
Nicolas "Pixel" Noble | 4500034 | 2016-01-28 05:04:45 +0100 | [diff] [blame] | 1229 | $(Q) $(CC) $(CPPFLAGS) $(CFLAGS) -MMD -MF $(addsuffix .dep, $(basename $@)) -c -o $@ $< |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 1230 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1231 | $(OBJDIR)/$(CONFIG)/%.o : $(GENDIR)/%.pb.cc |
| 1232 | $(E) "[CXX] Compiling $<" |
| 1233 | $(Q) mkdir -p `dirname $@` |
Nicolas "Pixel" Noble | 4500034 | 2016-01-28 05:04:45 +0100 | [diff] [blame] | 1234 | $(Q) $(CXX) $(CPPFLAGS) $(CXXFLAGS) -MMD -MF $(addsuffix .dep, $(basename $@)) -c -o $@ $< |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 1235 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1236 | $(OBJDIR)/$(CONFIG)/src/compiler/%.o : src/compiler/%.cc |
| 1237 | $(E) "[HOSTCXX] Compiling $<" |
| 1238 | $(Q) mkdir -p `dirname $@` |
| 1239 | $(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] | 1240 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1241 | $(OBJDIR)/$(CONFIG)/%.o : %.cc |
| 1242 | $(E) "[CXX] Compiling $<" |
| 1243 | $(Q) mkdir -p `dirname $@` |
Nicolas "Pixel" Noble | 4500034 | 2016-01-28 05:04:45 +0100 | [diff] [blame] | 1244 | $(Q) $(CXX) $(CPPFLAGS) $(CXXFLAGS) -MMD -MF $(addsuffix .dep, $(basename $@)) -c -o $@ $< |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 1245 | |
murgatroid99 | a3c5535 | 2016-08-10 13:41:31 -0700 | [diff] [blame] | 1246 | install: install_c install_cxx install-plugins install-certs |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 1247 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1248 | install_c: install-headers_c install-static_c install-shared_c |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 1249 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1250 | install_cxx: install-headers_cxx install-static_cxx install-shared_cxx |
nnoble | 85a4926 | 2014-12-08 18:14:03 -0800 | [diff] [blame] | 1251 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1252 | install_csharp: install-shared_csharp install_c |
Jan Tattermusch | 2ec0b3e | 2015-02-18 15:03:12 -0800 | [diff] [blame] | 1253 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1254 | install_grpc_csharp_ext: install_csharp |
Jan Tattermusch | 2ec0b3e | 2015-02-18 15:03:12 -0800 | [diff] [blame] | 1255 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1256 | install-headers: install-headers_c install-headers_cxx |
nnoble | 85a4926 | 2014-12-08 18:14:03 -0800 | [diff] [blame] | 1257 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1258 | install-headers_c: |
| 1259 | $(E) "[INSTALL] Installing public C headers" |
| 1260 | $(Q) $(foreach h, $(PUBLIC_HEADERS_C), $(INSTALL) -d $(prefix)/$(dir $(h)) && ) exit 0 || exit 1 |
| 1261 | $(Q) $(foreach h, $(PUBLIC_HEADERS_C), $(INSTALL) $(h) $(prefix)/$(h) && ) exit 0 || exit 1 |
nnoble | 85a4926 | 2014-12-08 18:14:03 -0800 | [diff] [blame] | 1262 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1263 | install-headers_cxx: |
| 1264 | $(E) "[INSTALL] Installing public C++ headers" |
| 1265 | $(Q) $(foreach h, $(PUBLIC_HEADERS_CXX), $(INSTALL) -d $(prefix)/$(dir $(h)) && ) exit 0 || exit 1 |
| 1266 | $(Q) $(foreach h, $(PUBLIC_HEADERS_CXX), $(INSTALL) $(h) $(prefix)/$(h) && ) exit 0 || exit 1 |
nnoble | 85a4926 | 2014-12-08 18:14:03 -0800 | [diff] [blame] | 1267 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1268 | install-static: install-static_c install-static_cxx |
nnoble | 85a4926 | 2014-12-08 18:14:03 -0800 | [diff] [blame] | 1269 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1270 | install-static_c: static_c strip-static_c install-pkg-config_c |
| 1271 | % for lib in libs: |
Nicolas "Pixel" Noble | e0dbd3f | 2016-02-23 00:21:38 +0100 | [diff] [blame] | 1272 | % if 'Makefile' in lib.get('build_system', ['Makefile']): |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1273 | % if lib.language == "c": |
| 1274 | % if lib.build == "all": |
| 1275 | % if not lib.get('external_deps', None): |
| 1276 | $(E) "[INSTALL] Installing lib${lib.name}.a" |
| 1277 | $(Q) $(INSTALL) -d $(prefix)/lib |
| 1278 | $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/lib${lib.name}.a $(prefix)/lib/lib${lib.name}.a |
| 1279 | % endif |
| 1280 | % endif |
| 1281 | % endif |
Nicolas "Pixel" Noble | e0dbd3f | 2016-02-23 00:21:38 +0100 | [diff] [blame] | 1282 | % endif |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1283 | % endfor |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 1284 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1285 | install-static_cxx: static_cxx strip-static_cxx install-pkg-config_cxx |
| 1286 | % for lib in libs: |
Nicolas "Pixel" Noble | e0dbd3f | 2016-02-23 00:21:38 +0100 | [diff] [blame] | 1287 | % if 'Makefile' in lib.get('build_system', ['Makefile']): |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1288 | % if lib.language == "c++": |
| 1289 | % if lib.build == "all": |
| 1290 | $(E) "[INSTALL] Installing lib${lib.name}.a" |
| 1291 | $(Q) $(INSTALL) -d $(prefix)/lib |
| 1292 | $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/lib${lib.name}.a $(prefix)/lib/lib${lib.name}.a |
| 1293 | % endif |
| 1294 | % endif |
Nicolas "Pixel" Noble | e0dbd3f | 2016-02-23 00:21:38 +0100 | [diff] [blame] | 1295 | % endif |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1296 | % endfor |
nnoble | 85a4926 | 2014-12-08 18:14:03 -0800 | [diff] [blame] | 1297 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1298 | <%def name="install_shared(lang_filter)">\ |
| 1299 | % for lib in libs: |
Nicolas "Pixel" Noble | e0dbd3f | 2016-02-23 00:21:38 +0100 | [diff] [blame] | 1300 | % if 'Makefile' in lib.get('build_system', ['Makefile']): |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1301 | % if lib.language == lang_filter: |
| 1302 | % if lib.build == "all": |
| 1303 | % if not lib.get('external_deps', None): |
Craig Tiller | 27f7084 | 2016-09-15 16:21:54 -0700 | [diff] [blame] | 1304 | $(E) "[INSTALL] Installing $(SHARED_PREFIX)${lib.name}$(SHARED_VERSION_${lang_to_var[lib.language]}).$(SHARED_EXT_${lang_to_var[lib.language]})" |
Nicolas "Pixel" Noble | c4e57e3 | 2016-01-30 21:05:35 +0100 | [diff] [blame] | 1305 | $(Q) $(INSTALL) -d $(prefix)/lib |
Mario Emmenlauer | 8e883b2 | 2017-01-12 11:45:52 +0100 | [diff] [blame] | 1306 | $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)${lib.name}$(SHARED_VERSION_${lang_to_var[lib.language]}).$(SHARED_EXT_${lang_to_var[lib.language]}) $(prefix)/lib/$(SHARED_PREFIX)${lib.name}$(SHARED_VERSION_${lang_to_var[lib.language]}).$(SHARED_EXT_${lang_to_var[lib.language]}) |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1307 | ifeq ($(SYSTEM),MINGW32) |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1308 | $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/lib${lib.name}-imp.a $(prefix)/lib/lib${lib.name}-imp.a |
Nicolas "Pixel" Noble | c4e57e3 | 2016-01-30 21:05:35 +0100 | [diff] [blame] | 1309 | else ifneq ($(SYSTEM),Darwin) |
Craig Tiller | 27f7084 | 2016-09-15 16:21:54 -0700 | [diff] [blame] | 1310 | $(Q) ln -sf $(SHARED_PREFIX)${lib.name}$(SHARED_VERSION_${lang_to_var[lib.language]}).$(SHARED_EXT_${lang_to_var[lib.language]}) $(prefix)/lib/lib${lib.name}.so.${settings.core_version.major} |
| 1311 | $(Q) ln -sf $(SHARED_PREFIX)${lib.name}$(SHARED_VERSION_${lang_to_var[lib.language]}).$(SHARED_EXT_${lang_to_var[lib.language]}) $(prefix)/lib/lib${lib.name}.so |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1312 | endif |
| 1313 | % endif |
| 1314 | % endif |
| 1315 | % endif |
Nicolas "Pixel" Noble | e0dbd3f | 2016-02-23 00:21:38 +0100 | [diff] [blame] | 1316 | % endif |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1317 | % endfor |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1318 | ifneq ($(SYSTEM),MINGW32) |
| 1319 | ifneq ($(SYSTEM),Darwin) |
| 1320 | $(Q) ldconfig || true |
| 1321 | endif |
| 1322 | endif |
| 1323 | </%def> |
nnoble | 85a4926 | 2014-12-08 18:14:03 -0800 | [diff] [blame] | 1324 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1325 | install-shared_c: shared_c strip-shared_c install-pkg-config_c |
| 1326 | ${install_shared("c")} |
Nicolas "Pixel" Noble | 522d712 | 2015-02-19 01:28:02 +0100 | [diff] [blame] | 1327 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1328 | install-shared_cxx: shared_cxx strip-shared_cxx install-shared_c install-pkg-config_cxx |
| 1329 | ${install_shared("c++")} |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 1330 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1331 | install-shared_csharp: shared_csharp strip-shared_csharp |
| 1332 | ${install_shared("csharp")} |
Nicolas "Pixel" Noble | 522d712 | 2015-02-19 01:28:02 +0100 | [diff] [blame] | 1333 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1334 | install-plugins: $(PROTOC_PLUGINS) |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1335 | $(E) "[INSTALL] Installing grpc protoc plugins" |
| 1336 | % for tgt in targets: |
| 1337 | % if tgt.build == 'protoc': |
| 1338 | $(Q) $(INSTALL) -d $(prefix)/bin |
| 1339 | $(Q) $(INSTALL) $(BINDIR)/$(CONFIG)/${tgt.name} $(prefix)/bin/${tgt.name} |
| 1340 | % endif |
| 1341 | % endfor |
Jan Tattermusch | 2ec0b3e | 2015-02-18 15:03:12 -0800 | [diff] [blame] | 1342 | |
Craig Tiller | eda85c6 | 2016-07-01 12:45:19 -0700 | [diff] [blame] | 1343 | install-pkg-config_c: pc_c pc_c_unsecure |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1344 | $(E) "[INSTALL] Installing C pkg-config files" |
| 1345 | $(Q) $(INSTALL) -d $(prefix)/lib/pkgconfig |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1346 | $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/pkgconfig/grpc.pc $(prefix)/lib/pkgconfig/grpc.pc |
| 1347 | $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/pkgconfig/grpc_unsecure.pc $(prefix)/lib/pkgconfig/grpc_unsecure.pc |
murgatroid99 | 8faab23 | 2015-06-30 17:24:21 -0700 | [diff] [blame] | 1348 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1349 | install-pkg-config_cxx: pc_cxx pc_cxx_unsecure |
| 1350 | $(E) "[INSTALL] Installing C++ pkg-config files" |
| 1351 | $(Q) $(INSTALL) -d $(prefix)/lib/pkgconfig |
| 1352 | $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/pkgconfig/grpc++.pc $(prefix)/lib/pkgconfig/grpc++.pc |
| 1353 | $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/pkgconfig/grpc++_unsecure.pc $(prefix)/lib/pkgconfig/grpc++_unsecure.pc |
murgatroid99 | 8faab23 | 2015-06-30 17:24:21 -0700 | [diff] [blame] | 1354 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1355 | install-certs: etc/roots.pem |
| 1356 | $(E) "[INSTALL] Installing root certificates" |
| 1357 | $(Q) $(INSTALL) -d $(prefix)/share/grpc |
| 1358 | $(Q) $(INSTALL) etc/roots.pem $(prefix)/share/grpc/roots.pem |
Nicolas "Pixel" Noble | 161ea23 | 2015-02-22 05:48:53 +0100 | [diff] [blame] | 1359 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1360 | clean: |
| 1361 | $(E) "[CLEAN] Cleaning build directories." |
| 1362 | $(Q) $(RM) -rf $(OBJDIR) $(LIBDIR) $(BINDIR) $(GENDIR) cache.mk |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 1363 | |
| 1364 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1365 | # The various libraries |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 1366 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1367 | % for lib in libs: |
Nicolas "Pixel" Noble | e0dbd3f | 2016-02-23 00:21:38 +0100 | [diff] [blame] | 1368 | % if 'Makefile' in lib.get('build_system', ['Makefile']): |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1369 | ${makelib(lib)} |
Nicolas "Pixel" Noble | e0dbd3f | 2016-02-23 00:21:38 +0100 | [diff] [blame] | 1370 | % endif |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1371 | % endfor |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 1372 | |
| 1373 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1374 | # All of the test targets, and protoc plugins |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 1375 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1376 | % for tgt in targets: |
| 1377 | ${maketarget(tgt)} |
| 1378 | % endfor |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 1379 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1380 | <%def name="makelib(lib)"> |
| 1381 | LIB${lib.name.upper()}_SRC = \\ |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 1382 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1383 | % for src in lib.src: |
| 1384 | ${proto_to_cc(src)} \\ |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 1385 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1386 | % endfor |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 1387 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1388 | % if "public_headers" in lib: |
| 1389 | % if lib.language == "c++": |
| 1390 | PUBLIC_HEADERS_CXX += \\ |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 1391 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1392 | % else: |
| 1393 | PUBLIC_HEADERS_C += \\ |
nnoble | 85a4926 | 2014-12-08 18:14:03 -0800 | [diff] [blame] | 1394 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1395 | % endif |
| 1396 | % for hdr in lib.public_headers: |
| 1397 | ${hdr} \\ |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 1398 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1399 | % endfor |
| 1400 | % endif |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 1401 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1402 | 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] | 1403 | |
Nicolas "Pixel" Noble | 51b1aee | 2016-01-28 01:14:58 +0100 | [diff] [blame] | 1404 | % if lib.get('defaults', None): |
| 1405 | % for name, value in defaults.get(lib.defaults).iteritems(): |
| 1406 | $(LIB${lib.name.upper()}_OBJS): ${name} += ${value} |
| 1407 | % endfor |
Craig Tiller | 0fe5ee7 | 2015-12-22 12:50:36 -0800 | [diff] [blame] | 1408 | % endif |
| 1409 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1410 | ## If the library requires OpenSSL, let's add some restrictions. |
| 1411 | % if lib.get('secure', 'check') == True or lib.get('secure', 'check') == 'check': |
| 1412 | ifeq ($(NO_SECURE),true) |
nnoble | 69ac39f | 2014-12-12 15:43:38 -0800 | [diff] [blame] | 1413 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1414 | # You can't build secure libraries if you don't have OpenSSL. |
Nicolas Noble | 047b727 | 2015-01-16 13:55:05 -0800 | [diff] [blame] | 1415 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1416 | $(LIBDIR)/$(CONFIG)/lib${lib.name}.a: openssl_dep_error |
nnoble | 69ac39f | 2014-12-12 15:43:38 -0800 | [diff] [blame] | 1417 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1418 | % if lib.build == "all": |
Craig Tiller | 27f7084 | 2016-09-15 16:21:54 -0700 | [diff] [blame] | 1419 | $(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)${lib.name}$(SHARED_VERSION_${lang_to_var[lib.language]}).$(SHARED_EXT_${lang_to_var[lib.language]}): openssl_dep_error |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1420 | % endif |
nnoble | 5b7f32a | 2014-12-22 08:12:44 -0800 | [diff] [blame] | 1421 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1422 | else |
nnoble | 69ac39f | 2014-12-12 15:43:38 -0800 | [diff] [blame] | 1423 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1424 | % if lib.language == 'c++': |
| 1425 | ifeq ($(NO_PROTOBUF),true) |
Nicolas Noble | 5383062 | 2015-02-12 16:56:38 -0800 | [diff] [blame] | 1426 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1427 | # You can't build a C++ library if you don't have protobuf - a bit overreached, but still okay. |
Nicolas Noble | 5383062 | 2015-02-12 16:56:38 -0800 | [diff] [blame] | 1428 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1429 | $(LIBDIR)/$(CONFIG)/lib${lib.name}.a: protobuf_dep_error |
Nicolas Noble | 5383062 | 2015-02-12 16:56:38 -0800 | [diff] [blame] | 1430 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1431 | % if lib.build == "all": |
Craig Tiller | 27f7084 | 2016-09-15 16:21:54 -0700 | [diff] [blame] | 1432 | $(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)${lib.name}$(SHARED_VERSION_${lang_to_var[lib.language]}).$(SHARED_EXT_${lang_to_var[lib.language]}): protobuf_dep_error |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1433 | % endif |
Nicolas Noble | 5383062 | 2015-02-12 16:56:38 -0800 | [diff] [blame] | 1434 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1435 | else |
| 1436 | % endif |
Nicolas Noble | 5383062 | 2015-02-12 16:56:38 -0800 | [diff] [blame] | 1437 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1438 | $(LIBDIR)/$(CONFIG)/lib${lib.name}.a: $(ZLIB_DEP) $(OPENSSL_DEP)\ |
| 1439 | ## The else here corresponds to the if secure earlier. |
| 1440 | % else: |
| 1441 | % if lib.language == 'c++': |
| 1442 | ifeq ($(NO_PROTOBUF),true) |
Nicolas Noble | 5383062 | 2015-02-12 16:56:38 -0800 | [diff] [blame] | 1443 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1444 | # You can't build a C++ library if you don't have protobuf - a bit overreached, but still okay. |
Nicolas Noble | 5383062 | 2015-02-12 16:56:38 -0800 | [diff] [blame] | 1445 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1446 | $(LIBDIR)/$(CONFIG)/lib${lib.name}.a: protobuf_dep_error |
Nicolas Noble | 5383062 | 2015-02-12 16:56:38 -0800 | [diff] [blame] | 1447 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1448 | % if lib.build == "all": |
Craig Tiller | 27f7084 | 2016-09-15 16:21:54 -0700 | [diff] [blame] | 1449 | $(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)${lib.name}$(SHARED_VERSION_${lang_to_var[lib.language]}).$(SHARED_EXT_${lang_to_var[lib.language]}): protobuf_dep_error |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1450 | % endif |
Nicolas Noble | 5383062 | 2015-02-12 16:56:38 -0800 | [diff] [blame] | 1451 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1452 | else |
Nicolas Noble | 5383062 | 2015-02-12 16:56:38 -0800 | [diff] [blame] | 1453 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1454 | % endif |
Nicolas "Pixel" Noble | d649c21 | 2016-01-27 20:27:30 +0100 | [diff] [blame] | 1455 | $(LIBDIR)/$(CONFIG)/lib${lib.name}.a: \ |
| 1456 | % if lib.name != 'z': |
| 1457 | $(ZLIB_DEP) \ |
| 1458 | % endif |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1459 | % endif |
| 1460 | % if lib.language == 'c++': |
| 1461 | $(PROTOBUF_DEP)\ |
| 1462 | % endif |
Nicolas "Pixel" Noble | f51a901 | 2016-02-03 07:39:43 +0100 | [diff] [blame] | 1463 | $(LIB${lib.name.upper()}_OBJS) \ |
| 1464 | % if lib.get('baselib', False): |
Craig Tiller | 1298afd | 2016-02-09 12:29:17 -0800 | [diff] [blame] | 1465 | $(LIBGPR_OBJS) \ |
Nicolas "Pixel" Noble | f51a901 | 2016-02-03 07:39:43 +0100 | [diff] [blame] | 1466 | $(ZLIB_MERGE_OBJS) \ |
| 1467 | % if lib.get('secure', 'check') == True: |
| 1468 | $(OPENSSL_MERGE_OBJS) \ |
| 1469 | % endif |
| 1470 | % endif |
| 1471 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1472 | $(E) "[AR] Creating $@" |
| 1473 | $(Q) mkdir -p `dirname $@` |
| 1474 | $(Q) rm -f $(LIBDIR)/$(CONFIG)/lib${lib.name}.a |
Vijay Pai | cc7eb8e | 2016-07-19 19:03:55 -0700 | [diff] [blame] | 1475 | $(Q) $(AR) $(AROPTS) $(LIBDIR)/$(CONFIG)/lib${lib.name}.a $(LIB${lib.name.upper()}_OBJS) \ |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1476 | % if lib.get('baselib', False): |
Craig Tiller | 1298afd | 2016-02-09 12:29:17 -0800 | [diff] [blame] | 1477 | $(LIBGPR_OBJS) \ |
Nicolas "Pixel" Noble | f51a901 | 2016-02-03 07:39:43 +0100 | [diff] [blame] | 1478 | $(ZLIB_MERGE_OBJS) \ |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1479 | % if lib.get('secure', 'check') == True: |
Nicolas "Pixel" Noble | f51a901 | 2016-02-03 07:39:43 +0100 | [diff] [blame] | 1480 | $(OPENSSL_MERGE_OBJS) \ |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1481 | % endif |
| 1482 | % endif |
Nicolas "Pixel" Noble | f51a901 | 2016-02-03 07:39:43 +0100 | [diff] [blame] | 1483 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1484 | ifeq ($(SYSTEM),Darwin) |
Nicolas "Pixel" Noble | e0dbd3f | 2016-02-23 00:21:38 +0100 | [diff] [blame] | 1485 | $(Q) ranlib -no_warning_for_no_symbols $(LIBDIR)/$(CONFIG)/lib${lib.name}.a |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1486 | endif |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 1487 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1488 | <% |
Nicolas "Pixel" Noble | 010f1e7 | 2015-04-23 02:23:49 +0200 | [diff] [blame] | 1489 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1490 | if lib.language == 'c++': |
| 1491 | ld = '$(LDXX)' |
| 1492 | else: |
| 1493 | ld = '$(LD)' |
nnoble | 5b7f32a | 2014-12-22 08:12:44 -0800 | [diff] [blame] | 1494 | |
Craig Tiller | 40c8fba | 2016-09-15 16:29:09 -0700 | [diff] [blame] | 1495 | out_mingbase = '$(LIBDIR)/$(CONFIG)/' + lib.name + '$(SHARED_VERSION_' + lang_to_var[lib.language] + ')' |
| 1496 | out_libbase = '$(LIBDIR)/$(CONFIG)/lib' + lib.name + '$(SHARED_VERSION_' + lang_to_var[lib.language] + ')' |
nnoble | 5b7f32a | 2014-12-22 08:12:44 -0800 | [diff] [blame] | 1497 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1498 | common = '$(LIB' + lib.name.upper() + '_OBJS) $(LDLIBS)' |
nnoble | 5b7f32a | 2014-12-22 08:12:44 -0800 | [diff] [blame] | 1499 | |
Craig Tiller | d7b1bdf | 2016-11-04 16:20:13 -0700 | [diff] [blame] | 1500 | link_libs = '' |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1501 | lib_deps = ' $(ZLIB_DEP)' |
| 1502 | mingw_libs = '' |
| 1503 | mingw_lib_deps = ' $(ZLIB_DEP)' |
| 1504 | if lib.language == 'c++': |
| 1505 | lib_deps += ' $(PROTOBUF_DEP)' |
| 1506 | mingw_lib_deps += ' $(PROTOBUF_DEP)' |
Jan Tattermusch | 324140c | 2016-01-12 08:54:01 -0800 | [diff] [blame] | 1507 | if lib.get('deps_linkage', None) == 'static': |
| 1508 | for dep in lib.get('deps', []): |
| 1509 | lib_archive = '$(LIBDIR)/$(CONFIG)/lib' + dep + '.a' |
| 1510 | common = common + ' ' + lib_archive |
| 1511 | lib_deps = lib_deps + ' ' + lib_archive |
| 1512 | mingw_lib_deps = mingw_lib_deps + ' ' + lib_archive |
| 1513 | else: |
| 1514 | for dep in lib.get('deps', []): |
Craig Tiller | d7b1bdf | 2016-11-04 16:20:13 -0700 | [diff] [blame] | 1515 | dep_lib = None |
| 1516 | for dl in libs: |
| 1517 | if dl.name == dep: |
| 1518 | dep_lib = dl |
| 1519 | assert dep_lib, 'lib %s not found (in %s)' % (dep, lib.name) |
| 1520 | link_libs = link_libs + ' -l' + dep |
| 1521 | lib_deps = lib_deps + ' $(LIBDIR)/$(CONFIG)/lib' + dep + '.$(SHARED_EXT_' + lang_to_var[dep_lib.language] + ')' |
Jan Tattermusch | 324140c | 2016-01-12 08:54:01 -0800 | [diff] [blame] | 1522 | mingw_libs = mingw_libs + ' -l' + dep + '-imp' |
Mario Emmenlauer | 8e883b2 | 2017-01-12 11:45:52 +0100 | [diff] [blame] | 1523 | mingw_lib_deps = mingw_lib_deps + ' $(LIBDIR)/$(CONFIG)/' + dep + '$(SHARED_VERSION_' + lang_to_var[dep_lib.language] + ').$(SHARED_EXT_' + lang_to_var[dep_lib.language] + ')' |
nnoble | 5b7f32a | 2014-12-22 08:12:44 -0800 | [diff] [blame] | 1524 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1525 | security = lib.get('secure', 'check') |
| 1526 | if security == True: |
| 1527 | common = common + ' $(OPENSSL_MERGE_LIBS) $(LDLIBS_SECURE)' |
Craig Tiller | 0fe5ee7 | 2015-12-22 12:50:36 -0800 | [diff] [blame] | 1528 | common = common + ' $(ZLIB_MERGE_LIBS)' |
Nicolas "Pixel" Noble | a7c162c | 2015-07-24 20:21:51 +0200 | [diff] [blame] | 1529 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1530 | if security in [True, 'check']: |
| 1531 | for src in lib.src: |
| 1532 | if not proto_re.match(src): |
| 1533 | sources_that_need_openssl.add(src) |
| 1534 | else: |
| 1535 | for src in lib.src: |
| 1536 | sources_that_don_t_need_openssl.add(src) |
Nicolas "Pixel" Noble | 061690d | 2015-03-06 22:58:58 +0100 | [diff] [blame] | 1537 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1538 | if lib.get('secure', 'check') == True or lib.get('secure', 'check') == 'check': |
| 1539 | lib_deps = lib_deps + ' $(OPENSSL_DEP)' |
| 1540 | mingw_lib_deps = mingw_lib_deps + ' $(OPENSSL_DEP)' |
Nicolas "Pixel" Noble | dda049c | 2015-02-21 00:39:32 +0100 | [diff] [blame] | 1541 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1542 | if lib.language == 'c++': |
| 1543 | common = common + ' $(LDLIBSXX) $(LDLIBS_PROTOBUF)' |
Craig Tiller | 4bef7ce | 2016-02-02 08:38:43 -0800 | [diff] [blame] | 1544 | |
| 1545 | ldflags = '$(LDFLAGS)' |
| 1546 | if lib.get('LDFLAGS', None): |
| 1547 | ldflags += ' ' + lib['LDFLAGS'] |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1548 | %> |
nnoble | 5b7f32a | 2014-12-22 08:12:44 -0800 | [diff] [blame] | 1549 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1550 | % if lib.build == "all": |
| 1551 | ifeq ($(SYSTEM),MINGW32) |
Craig Tiller | 38b99e9 | 2016-09-15 16:18:09 -0700 | [diff] [blame] | 1552 | ${out_mingbase}.$(SHARED_EXT_${lang_to_var[lib.language]}): $(LIB${lib.name.upper()}_OBJS) ${mingw_lib_deps} |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1553 | $(E) "[LD] Linking $@" |
| 1554 | $(Q) mkdir -p `dirname $@` |
Mario Emmenlauer | 294dc2f | 2016-12-13 00:07:12 +0100 | [diff] [blame] | 1555 | $(Q) ${ld} ${ldflags} -L$(LIBDIR)/$(CONFIG) -shared -Wl,--output-def=${out_mingbase}.def -Wl,--out-implib=${out_libbase}-dll.a -o ${out_mingbase}.$(SHARED_EXT_${lang_to_var[lib.language]}) ${common}${mingw_libs} |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1556 | else |
Craig Tiller | 38b99e9 | 2016-09-15 16:18:09 -0700 | [diff] [blame] | 1557 | ${out_libbase}.$(SHARED_EXT_${lang_to_var[lib.language]}): $(LIB${lib.name.upper()}_OBJS) ${lib_deps} |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1558 | $(E) "[LD] Linking $@" |
| 1559 | $(Q) mkdir -p `dirname $@` |
| 1560 | ifeq ($(SYSTEM),Darwin) |
Mario Emmenlauer | 8e883b2 | 2017-01-12 11:45:52 +0100 | [diff] [blame] | 1561 | $(Q) ${ld} ${ldflags} -L$(LIBDIR)/$(CONFIG) -install_name $(SHARED_PREFIX)${lib.name}$(SHARED_VERSION_${lang_to_var[lib.language]}).$(SHARED_EXT_${lang_to_var[lib.language]}) -dynamiclib -o ${out_libbase}.$(SHARED_EXT_${lang_to_var[lib.language]}) ${common}${link_libs} |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1562 | else |
Craig Tiller | d7b1bdf | 2016-11-04 16:20:13 -0700 | [diff] [blame] | 1563 | $(Q) ${ld} ${ldflags} -L$(LIBDIR)/$(CONFIG) -shared -Wl,-soname,lib${lib.name}.so.${settings.core_version.major} -o ${out_libbase}.$(SHARED_EXT_${lang_to_var[lib.language]}) ${common}${link_libs} |
Mario Emmenlauer | 8e883b2 | 2017-01-12 11:45:52 +0100 | [diff] [blame] | 1564 | $(Q) ln -sf $(SHARED_PREFIX)${lib.name}$(SHARED_VERSION_${lang_to_var[lib.language]}).$(SHARED_EXT_${lang_to_var[lib.language]}) ${out_libbase}.so.${settings.get(lang_to_var[lib.language].lower() + '_version').major} |
| 1565 | $(Q) ln -sf $(SHARED_PREFIX)${lib.name}$(SHARED_VERSION_${lang_to_var[lib.language]}).$(SHARED_EXT_${lang_to_var[lib.language]}) ${out_libbase}.so |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1566 | endif |
| 1567 | endif |
| 1568 | % endif |
| 1569 | % if lib.get('secure', 'check') == True or lib.get('secure', 'check') == 'check': |
| 1570 | ## If the lib was secure, we have to close the Makefile's if that tested |
| 1571 | ## the presence of OpenSSL. |
Nicolas Noble | 5383062 | 2015-02-12 16:56:38 -0800 | [diff] [blame] | 1572 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1573 | endif |
| 1574 | % endif |
| 1575 | % if lib.language == 'c++': |
| 1576 | ## If the lib was C++, we have to close the Makefile's if that tested |
| 1577 | ## the presence of protobuf 3.0.0+ |
nnoble | 69ac39f | 2014-12-12 15:43:38 -0800 | [diff] [blame] | 1578 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1579 | endif |
| 1580 | % endif |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 1581 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1582 | % if lib.get('secure', 'check') == True or lib.get('secure', 'check') == 'check': |
| 1583 | ifneq ($(NO_SECURE),true) |
| 1584 | % endif |
| 1585 | ifneq ($(NO_DEPS),true) |
| 1586 | -include $(LIB${lib.name.upper()}_OBJS:.o=.dep) |
| 1587 | endif |
| 1588 | % if lib.get('secure', 'check') == True or lib.get('secure', 'check') == 'check': |
| 1589 | endif |
| 1590 | % endif |
| 1591 | % for src in lib.src: |
| 1592 | % if not proto_re.match(src) and any(proto_re.match(src2) for src2 in lib.src): |
| 1593 | $(OBJDIR)/$(CONFIG)/${os.path.splitext(src)[0]}.o: ${' '.join(proto_to_cc(src2) for src2 in lib.src if proto_re.match(src2))} |
| 1594 | % endif |
| 1595 | % endfor |
| 1596 | </%def> |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 1597 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1598 | <%def name="maketarget(tgt)"><% has_no_sources = not tgt.src %> |
| 1599 | % if not has_no_sources: |
| 1600 | ${tgt.name.upper()}_SRC = \\ |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 1601 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1602 | % for src in tgt.src: |
| 1603 | ${proto_to_cc(src)} \\ |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 1604 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1605 | % endfor |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 1606 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1607 | ${tgt.name.upper()}_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(${tgt.name.upper()}_SRC)))) |
| 1608 | % endif |
| 1609 | % if tgt.get('secure', 'check') == True or tgt.get('secure', 'check') == 'check': |
| 1610 | ifeq ($(NO_SECURE),true) |
nnoble | 69ac39f | 2014-12-12 15:43:38 -0800 | [diff] [blame] | 1611 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1612 | # You can't build secure targets if you don't have OpenSSL. |
Nicolas Noble | 047b727 | 2015-01-16 13:55:05 -0800 | [diff] [blame] | 1613 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1614 | $(BINDIR)/$(CONFIG)/${tgt.name}: openssl_dep_error |
nnoble | 69ac39f | 2014-12-12 15:43:38 -0800 | [diff] [blame] | 1615 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1616 | else |
nnoble | 69ac39f | 2014-12-12 15:43:38 -0800 | [diff] [blame] | 1617 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1618 | % endif |
Craig Tiller | 0fe5ee7 | 2015-12-22 12:50:36 -0800 | [diff] [blame] | 1619 | |
| 1620 | % if tgt.boringssl: |
| 1621 | # boringssl needs an override to ensure that it does not include |
| 1622 | # system openssl headers regardless of other configuration |
| 1623 | # we do so here with a target specific variable assignment |
Craig Tiller | 78222f7 | 2016-05-10 09:55:38 -0700 | [diff] [blame] | 1624 | $(${tgt.name.upper()}_OBJS): CFLAGS := -Ithird_party/boringssl/include $(CFLAGS) -Wno-sign-conversion -Wno-conversion -Wno-unused-value $(NO_W_EXTRA_SEMI) |
Craig Tiller | 0fe5ee7 | 2015-12-22 12:50:36 -0800 | [diff] [blame] | 1625 | $(${tgt.name.upper()}_OBJS): CXXFLAGS := -Ithird_party/boringssl/include $(CXXFLAGS) |
| 1626 | $(${tgt.name.upper()}_OBJS): CPPFLAGS += -DOPENSSL_NO_ASM -D_GNU_SOURCE |
| 1627 | % else: |
| 1628 | % endif |
| 1629 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1630 | ## |
| 1631 | ## We're not trying to add a dependency on building zlib and openssl here, |
| 1632 | ## as it's already done in the libraries. We're assuming that the build |
| 1633 | ## trickles down, and that a secure target requires a secure version of |
| 1634 | ## a library. |
| 1635 | ## |
| 1636 | ## That simplifies the codegen a bit, but prevents a fully defined Makefile. |
| 1637 | ## I can live with that. |
| 1638 | ## |
| 1639 | % if tgt.build == 'protoc' or tgt.language == 'c++': |
Nicolas Noble | 5383062 | 2015-02-12 16:56:38 -0800 | [diff] [blame] | 1640 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1641 | ifeq ($(NO_PROTOBUF),true) |
Nicolas Noble | 5383062 | 2015-02-12 16:56:38 -0800 | [diff] [blame] | 1642 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1643 | # 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] | 1644 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1645 | $(BINDIR)/$(CONFIG)/${tgt.name}: protobuf_dep_error |
Nicolas Noble | 5383062 | 2015-02-12 16:56:38 -0800 | [diff] [blame] | 1646 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1647 | else |
Nicolas Noble | 5383062 | 2015-02-12 16:56:38 -0800 | [diff] [blame] | 1648 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1649 | $(BINDIR)/$(CONFIG)/${tgt.name}: \ |
| 1650 | % if not has_no_sources: |
| 1651 | $(PROTOBUF_DEP) $(${tgt.name.upper()}_OBJS)\ |
| 1652 | % endif |
| 1653 | % else: |
| 1654 | $(BINDIR)/$(CONFIG)/${tgt.name}: \ |
| 1655 | % if not has_no_sources: |
| 1656 | $(${tgt.name.upper()}_OBJS)\ |
| 1657 | % endif |
| 1658 | % endif |
| 1659 | % for dep in tgt.deps: |
| 1660 | $(LIBDIR)/$(CONFIG)/lib${dep}.a\ |
| 1661 | % endfor |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 1662 | |
Craig Tiller | 32173c5 | 2016-03-17 14:12:45 -0700 | [diff] [blame] | 1663 | % if tgt.language == "c++" or tgt.boringssl or tgt.build == 'fuzzer': |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1664 | ## C++ targets specificies. |
| 1665 | % if tgt.build == 'protoc': |
| 1666 | $(E) "[HOSTLD] Linking $@" |
| 1667 | $(Q) mkdir -p `dirname $@` |
| 1668 | $(Q) $(HOST_LDXX) $(HOST_LDFLAGS) \ |
| 1669 | % if not has_no_sources: |
| 1670 | $(${tgt.name.upper()}_OBJS)\ |
| 1671 | % endif |
| 1672 | % else: |
| 1673 | $(E) "[LD] Linking $@" |
| 1674 | $(Q) mkdir -p `dirname $@` |
| 1675 | $(Q) $(LDXX) $(LDFLAGS) \ |
| 1676 | % if not has_no_sources: |
| 1677 | $(${tgt.name.upper()}_OBJS)\ |
| 1678 | % endif |
| 1679 | % endif |
| 1680 | % else: |
| 1681 | ## C-only targets specificities. |
| 1682 | $(E) "[LD] Linking $@" |
| 1683 | $(Q) mkdir -p `dirname $@` |
| 1684 | $(Q) $(LD) $(LDFLAGS) \ |
| 1685 | % if not has_no_sources: |
| 1686 | $(${tgt.name.upper()}_OBJS)\ |
| 1687 | % endif |
| 1688 | % endif |
| 1689 | % for dep in tgt.deps: |
| 1690 | $(LIBDIR)/$(CONFIG)/lib${dep}.a\ |
| 1691 | % endfor |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1692 | % if tgt.language == "c++": |
| 1693 | % if tgt.build == 'protoc': |
| 1694 | $(HOST_LDLIBSXX) $(HOST_LDLIBS_PROTOC)\ |
| 1695 | % else: |
| 1696 | $(LDLIBSXX) $(LDLIBS_PROTOBUF)\ |
| 1697 | % endif |
| 1698 | % endif |
| 1699 | % if tgt.build == 'protoc': |
| 1700 | $(HOST_LDLIBS)\ |
| 1701 | % else: |
| 1702 | $(LDLIBS)\ |
| 1703 | % endif |
| 1704 | % if tgt.build == 'protoc': |
| 1705 | $(HOST_LDLIBS_PROTOC)\ |
| 1706 | % elif tgt.get('secure', 'check') == True or tgt.get('secure', 'check') == 'check': |
| 1707 | $(LDLIBS_SECURE)\ |
| 1708 | % endif |
| 1709 | % if tgt.language == 'c++' and tgt.build == 'test': |
| 1710 | $(GTEST_LIB)\ |
| 1711 | % elif tgt.language == 'c++' and tgt.build == 'benchmark': |
| 1712 | $(GTEST_LIB)\ |
| 1713 | % endif |
Craig Tiller | 32173c5 | 2016-03-17 14:12:45 -0700 | [diff] [blame] | 1714 | % if tgt.build == 'fuzzer': |
| 1715 | -lFuzzer\ |
| 1716 | % endif |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1717 | -o $(BINDIR)/$(CONFIG)/${tgt.name} |
| 1718 | % if tgt.build == 'protoc' or tgt.language == 'c++': |
Nicolas Noble | 5383062 | 2015-02-12 16:56:38 -0800 | [diff] [blame] | 1719 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1720 | endif |
| 1721 | % endif |
| 1722 | % if tgt.get('secure', 'check') == True or tgt.get('secure', 'check') == 'check': |
nnoble | 69ac39f | 2014-12-12 15:43:38 -0800 | [diff] [blame] | 1723 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1724 | endif |
| 1725 | % endif |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 1726 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1727 | % for src in tgt.src: |
| 1728 | $(OBJDIR)/$(CONFIG)/${os.path.splitext(src)[0]}.o: \ |
| 1729 | % for dep in tgt.deps: |
| 1730 | $(LIBDIR)/$(CONFIG)/lib${dep}.a\ |
| 1731 | % endfor |
Craig Tiller | f5371ef | 2015-01-12 16:40:18 -0800 | [diff] [blame] | 1732 | |
Craig Tiller | ab23045 | 2016-01-04 08:18:43 -0800 | [diff] [blame] | 1733 | % if tgt.language == 'c89': |
| 1734 | % for src in tgt.src: |
Craig Tiller | ea21ca2 | 2016-01-04 12:34:29 -0800 | [diff] [blame] | 1735 | $(OBJDIR)/$(CONFIG)/${os.path.splitext(src)[0]}.o : ${src} |
| 1736 | $(E) "[C] Compiling $<" |
| 1737 | $(Q) mkdir -p `dirname $@` |
Nicolas "Pixel" Noble | 4500034 | 2016-01-28 05:04:45 +0100 | [diff] [blame] | 1738 | $(Q) $(CC) $(CPPFLAGS) $(CFLAGS) -std=c89 -pedantic -MMD -MF $(addsuffix .dep, $(basename $@)) -c -o $@ $< |
Craig Tiller | ab23045 | 2016-01-04 08:18:43 -0800 | [diff] [blame] | 1739 | % endfor |
| 1740 | % endif |
| 1741 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1742 | % endfor |
| 1743 | % if not has_no_sources: |
| 1744 | deps_${tgt.name}: $(${tgt.name.upper()}_OBJS:.o=.dep) |
| 1745 | % endif |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 1746 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1747 | % if not has_no_sources: |
| 1748 | % if tgt.get('secure', 'check') == True or tgt.get('secure', 'check') == 'check': |
| 1749 | ifneq ($(NO_SECURE),true) |
| 1750 | % endif |
| 1751 | ifneq ($(NO_DEPS),true) |
| 1752 | -include $(${tgt.name.upper()}_OBJS:.o=.dep) |
| 1753 | endif |
| 1754 | % if tgt.get('secure', 'check') == True or tgt.get('secure', 'check') == 'check': |
| 1755 | endif |
| 1756 | % endif |
| 1757 | % endif |
Nicolas "Pixel" Noble | 472bb68 | 2015-11-03 19:09:01 +0100 | [diff] [blame] | 1758 | % for src in tgt.src: |
| 1759 | % if not proto_re.match(src) and any(proto_re.match(src2) for src2 in tgt.src): |
| 1760 | $(OBJDIR)/$(CONFIG)/${os.path.splitext(src)[0]}.o: ${' '.join(proto_to_cc(src2) for src2 in tgt.src if proto_re.match(src2))} |
| 1761 | % endif |
| 1762 | % endfor |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1763 | </%def> |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 1764 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1765 | ifneq ($(OPENSSL_DEP),) |
| 1766 | # This is to ensure the embedded OpenSSL is built beforehand, properly |
| 1767 | # installing headers to their final destination on the drive. We need this |
| 1768 | # otherwise parallel compilation will fail if a source is compiled first. |
| 1769 | % for src in sorted(sources_that_need_openssl): |
| 1770 | % if src not in sources_that_don_t_need_openssl: |
| 1771 | ${src}: $(OPENSSL_DEP) |
| 1772 | % endif |
| 1773 | % endfor |
| 1774 | endif |
Nicolas "Pixel" Noble | 010f1e7 | 2015-04-23 02:23:49 +0200 | [diff] [blame] | 1775 | |
Craig Tiller | 841c880 | 2015-09-10 13:06:37 -0700 | [diff] [blame] | 1776 | .PHONY: all strip tools \ |
| 1777 | dep_error openssl_dep_error openssl_dep_message git_update stop \ |
| 1778 | buildtests buildtests_c buildtests_cxx \ |
| 1779 | test test_c test_cxx \ |
| 1780 | install install_c install_cxx \ |
| 1781 | install-headers install-headers_c install-headers_cxx \ |
| 1782 | install-shared install-shared_c install-shared_cxx \ |
| 1783 | install-static install-static_c install-static_cxx \ |
| 1784 | strip strip-shared strip-static \ |
| 1785 | strip_c strip-shared_c strip-static_c \ |
| 1786 | strip_cxx strip-shared_cxx strip-static_cxx \ |
| 1787 | dep_c dep_cxx bins_dep_c bins_dep_cxx \ |
| 1788 | clean |
Craig Tiller | b79c1e1 | 2016-02-23 10:00:58 -0800 | [diff] [blame] | 1789 | |
| 1790 | .PHONY: printvars |
| 1791 | printvars: |
| 1792 | @$(foreach V,$(sort $(.VARIABLES)), \ |
| 1793 | $(if $(filter-out environment% default automatic, \ |
| 1794 | $(origin $V)),$(warning $V=$($V) ($(value $V))))) |