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