Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 1 | # GRPC global makefile |
| 2 | # This currently builds C and C++ code. |
| 3 | <%! |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 4 | import re |
Craig Tiller | f5371ef | 2015-01-12 16:40:18 -0800 | [diff] [blame] | 5 | import os |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 6 | |
nnoble | c87b1c5 | 2015-01-05 17:15:18 -0800 | [diff] [blame] | 7 | proto_re = re.compile('(.*)\\.proto') |
nnoble | 72309c6 | 2014-12-12 11:42:26 -0800 | [diff] [blame] | 8 | |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 9 | def excluded(filename, exclude_res): |
| 10 | for r in exclude_res: |
| 11 | if r.match(filename): |
| 12 | return True |
| 13 | return False |
nnoble | 72309c6 | 2014-12-12 11:42:26 -0800 | [diff] [blame] | 14 | |
| 15 | def proto_to_cc(filename): |
| 16 | m = proto_re.match(filename) |
| 17 | if not m: |
| 18 | return filename |
| 19 | return 'gens/' + m.group(1) + '.pb.cc' |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 20 | %> |
| 21 | |
Craig Tiller | 96b4955 | 2015-01-21 16:29:01 -0800 | [diff] [blame] | 22 | |
| 23 | # Basic platform detection |
| 24 | HOST_SYSTEM = $(shell uname | cut -f 1 -d_) |
| 25 | ifeq ($(SYSTEM),) |
| 26 | SYSTEM = $(HOST_SYSTEM) |
| 27 | endif |
| 28 | |
| 29 | |
ctiller | 8cfebb9 | 2015-01-06 15:02:12 -0800 | [diff] [blame] | 30 | # Configurations |
| 31 | |
| 32 | VALID_CONFIG_opt = 1 |
| 33 | CC_opt = gcc |
| 34 | CXX_opt = g++ |
| 35 | LD_opt = gcc |
| 36 | LDXX_opt = g++ |
| 37 | CPPFLAGS_opt = -O2 |
| 38 | LDFLAGS_opt = |
| 39 | DEFINES_opt = NDEBUG |
| 40 | |
| 41 | VALID_CONFIG_dbg = 1 |
| 42 | CC_dbg = gcc |
| 43 | CXX_dbg = g++ |
| 44 | LD_dbg = gcc |
| 45 | LDXX_dbg = g++ |
| 46 | CPPFLAGS_dbg = -O0 |
| 47 | LDFLAGS_dbg = |
| 48 | DEFINES_dbg = _DEBUG DEBUG |
| 49 | |
Craig Tiller | ec0b8f3 | 2015-01-15 07:30:00 -0800 | [diff] [blame] | 50 | VALID_CONFIG_valgrind = 1 |
Craig Tiller | c4da6b7 | 2015-01-15 08:01:14 -0800 | [diff] [blame] | 51 | REQUIRE_CUSTOM_LIBRARIES_valgrind = 1 |
Craig Tiller | ec0b8f3 | 2015-01-15 07:30:00 -0800 | [diff] [blame] | 52 | CC_valgrind = gcc |
| 53 | CXX_valgrind = g++ |
| 54 | LD_valgrind = gcc |
| 55 | LDXX_valgrind = g++ |
| 56 | CPPFLAGS_valgrind = -O0 |
| 57 | OPENSSL_CFLAGS_valgrind = -DPURIFY |
| 58 | LDFLAGS_valgrind = |
| 59 | DEFINES_valgrind = _DEBUG DEBUG |
| 60 | |
ctiller | 8cfebb9 | 2015-01-06 15:02:12 -0800 | [diff] [blame] | 61 | VALID_CONFIG_tsan = 1 |
Craig Tiller | c4da6b7 | 2015-01-15 08:01:14 -0800 | [diff] [blame] | 62 | REQUIRE_CUSTOM_LIBRARIES_tsan = 1 |
ctiller | 8cfebb9 | 2015-01-06 15:02:12 -0800 | [diff] [blame] | 63 | CC_tsan = clang |
| 64 | CXX_tsan = clang++ |
| 65 | LD_tsan = clang |
| 66 | LDXX_tsan = clang++ |
| 67 | CPPFLAGS_tsan = -O1 -fsanitize=thread -fno-omit-frame-pointer |
Craig Tiller | ec0b8f3 | 2015-01-15 07:30:00 -0800 | [diff] [blame] | 68 | OPENSSL_CONFIG_tsan = no-asm |
ctiller | 8cfebb9 | 2015-01-06 15:02:12 -0800 | [diff] [blame] | 69 | LDFLAGS_tsan = -fsanitize=thread |
| 70 | DEFINES_tsan = NDEBUG |
| 71 | |
| 72 | VALID_CONFIG_asan = 1 |
Craig Tiller | c4da6b7 | 2015-01-15 08:01:14 -0800 | [diff] [blame] | 73 | REQUIRE_CUSTOM_LIBRARIES_asan = 1 |
ctiller | 8cfebb9 | 2015-01-06 15:02:12 -0800 | [diff] [blame] | 74 | CC_asan = clang |
| 75 | CXX_asan = clang++ |
| 76 | LD_asan = clang |
| 77 | LDXX_asan = clang++ |
| 78 | CPPFLAGS_asan = -O1 -fsanitize=address -fno-omit-frame-pointer |
Craig Tiller | ec0b8f3 | 2015-01-15 07:30:00 -0800 | [diff] [blame] | 79 | OPENSSL_CONFIG_asan = no-asm |
ctiller | 8cfebb9 | 2015-01-06 15:02:12 -0800 | [diff] [blame] | 80 | LDFLAGS_asan = -fsanitize=address |
| 81 | DEFINES_asan = NDEBUG |
| 82 | |
| 83 | VALID_CONFIG_msan = 1 |
Craig Tiller | c4da6b7 | 2015-01-15 08:01:14 -0800 | [diff] [blame] | 84 | REQUIRE_CUSTOM_LIBRARIES_msan = 1 |
ctiller | 8cfebb9 | 2015-01-06 15:02:12 -0800 | [diff] [blame] | 85 | CC_msan = clang |
| 86 | CXX_msan = clang++ |
| 87 | LD_msan = clang |
| 88 | LDXX_msan = clang++ |
| 89 | CPPFLAGS_msan = -O1 -fsanitize=memory -fno-omit-frame-pointer |
Craig Tiller | ec0b8f3 | 2015-01-15 07:30:00 -0800 | [diff] [blame] | 90 | OPENSSL_CFLAGS_msan = -DPURIFY |
| 91 | OPENSSL_CONFIG_msan = no-asm |
ctiller | 8cfebb9 | 2015-01-06 15:02:12 -0800 | [diff] [blame] | 92 | LDFLAGS_msan = -fsanitize=memory |
| 93 | DEFINES_msan = NDEBUG |
| 94 | |
Craig Tiller | 699ba21 | 2015-01-13 17:02:20 -0800 | [diff] [blame] | 95 | VALID_CONFIG_gcov = 1 |
| 96 | CC_gcov = gcc |
| 97 | CXX_gcov = g++ |
| 98 | LD_gcov = gcc |
| 99 | LDXX_gcov = g++ |
| 100 | CPPFLAGS_gcov = -O0 -fprofile-arcs -ftest-coverage |
| 101 | LDFLAGS_gcov = -fprofile-arcs -ftest-coverage |
| 102 | DEFINES_gcov = NDEBUG |
| 103 | |
Nicolas Noble | 047b727 | 2015-01-16 13:55:05 -0800 | [diff] [blame] | 104 | |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 105 | # General settings. |
| 106 | # You may want to change these depending on your system. |
| 107 | |
| 108 | prefix ?= /usr/local |
| 109 | |
| 110 | PROTOC = protoc |
yangg | 102e4fe | 2015-01-06 16:02:50 -0800 | [diff] [blame] | 111 | CONFIG ?= opt |
ctiller | 8cfebb9 | 2015-01-06 15:02:12 -0800 | [diff] [blame] | 112 | CC = $(CC_$(CONFIG)) |
| 113 | CXX = $(CXX_$(CONFIG)) |
| 114 | LD = $(LD_$(CONFIG)) |
| 115 | LDXX = $(LDXX_$(CONFIG)) |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 116 | AR = ar |
| 117 | STRIP = strip --strip-unneeded |
| 118 | INSTALL = install -D |
| 119 | RM = rm -f |
| 120 | |
yangg | 102e4fe | 2015-01-06 16:02:50 -0800 | [diff] [blame] | 121 | ifndef VALID_CONFIG_$(CONFIG) |
| 122 | $(error Invalid CONFIG value '$(CONFIG)') |
| 123 | endif |
| 124 | |
Nicolas Noble | 047b727 | 2015-01-16 13:55:05 -0800 | [diff] [blame] | 125 | |
| 126 | # The HOST compiler settings are used to compile the protoc plugins. |
| 127 | # In most cases, you won't have to change anything, but if you are |
| 128 | # cross-compiling, you can override these variables from GNU make's |
| 129 | # command line: make CC=cross-gcc HOST_CC=gcc |
| 130 | |
nnoble | 72309c6 | 2014-12-12 11:42:26 -0800 | [diff] [blame] | 131 | HOST_CC = $(CC) |
| 132 | HOST_CXX = $(CXX) |
| 133 | HOST_LD = $(LD) |
| 134 | HOST_LDXX = $(LDXX) |
| 135 | |
ctiller | cab52e7 | 2015-01-06 13:10:23 -0800 | [diff] [blame] | 136 | CPPFLAGS += $(CPPFLAGS_$(CONFIG)) |
| 137 | DEFINES += $(DEFINES_$(CONFIG)) |
ctiller | 8cfebb9 | 2015-01-06 15:02:12 -0800 | [diff] [blame] | 138 | LDFLAGS += $(LDFLAGS_$(CONFIG)) |
ctiller | cab52e7 | 2015-01-06 13:10:23 -0800 | [diff] [blame] | 139 | |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 140 | CFLAGS += -std=c89 -pedantic |
| 141 | CXXFLAGS += -std=c++11 |
Nicolas "Pixel" Noble | 213ed91 | 2015-01-30 02:11:35 +0100 | [diff] [blame] | 142 | CPPFLAGS += -g -fPIC -Wall -Wextra -Werror -Wno-long-long -Wno-unused-parameter |
Craig Tiller | 96b4955 | 2015-01-21 16:29:01 -0800 | [diff] [blame] | 143 | LDFLAGS += -g -fPIC |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 144 | |
| 145 | INCLUDES = . include gens |
Craig Tiller | 96b4955 | 2015-01-21 16:29:01 -0800 | [diff] [blame] | 146 | ifeq ($(SYSTEM),Darwin) |
| 147 | LIBS = m z |
| 148 | else |
ctiller | c008ae5 | 2015-01-07 15:33:00 -0800 | [diff] [blame] | 149 | LIBS = rt m z pthread |
Craig Tiller | 96b4955 | 2015-01-21 16:29:01 -0800 | [diff] [blame] | 150 | LDFLAGS += -pthread |
| 151 | endif |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 152 | LIBSXX = protobuf |
nnoble | c78b340 | 2014-12-11 16:06:57 -0800 | [diff] [blame] | 153 | LIBS_PROTOC = protoc protobuf |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 154 | |
| 155 | ifneq ($(wildcard /usr/src/gtest/src/gtest-all.cc),) |
| 156 | GTEST_LIB = /usr/src/gtest/src/gtest-all.cc -I/usr/src/gtest |
| 157 | else |
| 158 | GTEST_LIB = -lgtest |
| 159 | endif |
chenw | a8fd44a | 2014-12-10 15:13:55 -0800 | [diff] [blame] | 160 | GTEST_LIB += -lgflags |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 161 | ifeq ($(V),1) |
| 162 | E = @: |
| 163 | Q = |
| 164 | else |
| 165 | E = @echo |
| 166 | Q = @ |
| 167 | endif |
| 168 | |
| 169 | VERSION = ${settings.version.major}.${settings.version.minor}.${settings.version.micro}.${settings.version.build} |
| 170 | |
| 171 | CPPFLAGS_NO_ARCH += $(addprefix -I, $(INCLUDES)) $(addprefix -D, $(DEFINES)) |
| 172 | CPPFLAGS += $(CPPFLAGS_NO_ARCH) $(ARCH_FLAGS) |
| 173 | |
| 174 | LDFLAGS += $(ARCH_FLAGS) |
| 175 | LDLIBS += $(addprefix -l, $(LIBS)) |
| 176 | LDLIBSXX += $(addprefix -l, $(LIBSXX)) |
nnoble | 72309c6 | 2014-12-12 11:42:26 -0800 | [diff] [blame] | 177 | HOST_LDLIBS_PROTOC += $(addprefix -l, $(LIBS_PROTOC)) |
| 178 | |
| 179 | HOST_CPPFLAGS = $(CPPFLAGS) |
| 180 | HOST_CFLAGS = $(CFLAGS) |
| 181 | HOST_CXXFLAGS = $(CXXFLAGS) |
| 182 | HOST_LDFLAGS = $(LDFLAGS) |
| 183 | HOST_LDLIBS = $(LDLIBS) |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 184 | |
nnoble | 69ac39f | 2014-12-12 15:43:38 -0800 | [diff] [blame] | 185 | |
| 186 | # These are automatically computed variables. |
| 187 | # There shouldn't be any need to change anything from now on. |
| 188 | |
nnoble | 5b7f32a | 2014-12-22 08:12:44 -0800 | [diff] [blame] | 189 | ifeq ($(SYSTEM),MINGW32) |
| 190 | SHARED_EXT = dll |
| 191 | endif |
| 192 | ifeq ($(SYSTEM),Darwin) |
| 193 | SHARED_EXT = dylib |
| 194 | endif |
| 195 | ifeq ($(SHARED_EXT),) |
| 196 | SHARED_EXT = so.$(VERSION) |
| 197 | endif |
| 198 | |
nnoble | 69ac39f | 2014-12-12 15:43:38 -0800 | [diff] [blame] | 199 | ifeq ($(wildcard .git),) |
| 200 | IS_GIT_FOLDER = false |
| 201 | else |
| 202 | IS_GIT_FOLDER = true |
| 203 | endif |
| 204 | |
nnoble | 7e012cf | 2014-12-22 17:53:44 -0800 | [diff] [blame] | 205 | OPENSSL_ALPN_CHECK_CMD = $(CC) $(CFLAGS) $(CPPFLAGS) -o /dev/null test/build/openssl-alpn.c -lssl -lcrypto -ldl $(LDFLAGS) |
| 206 | ZLIB_CHECK_CMD = $(CC) $(CFLAGS) $(CPPFLAGS) -o /dev/null test/build/zlib.c -lz $(LDFLAGS) |
Craig Tiller | 297fafa | 2015-01-15 15:46:39 -0800 | [diff] [blame] | 207 | PERFTOOLS_CHECK_CMD = $(CC) $(CFLAGS) $(CPPFLAGS) -o /dev/null test/build/perftools.c -lprofiler $(LDFLAGS) |
| 208 | |
Craig Tiller | 50524cc | 2015-01-29 23:00:00 -0800 | [diff] [blame] | 209 | ifndef REQUIRE_CUSTOM_LIBRARIES_$(CONFIG) |
Craig Tiller | 297fafa | 2015-01-15 15:46:39 -0800 | [diff] [blame] | 210 | HAS_SYSTEM_PERFTOOLS = $(shell $(PERFTOOLS_CHECK_CMD) 2> /dev/null && echo true || echo false) |
| 211 | ifeq ($(HAS_SYSTEM_PERFTOOLS),true) |
| 212 | DEFINES += GRPC_HAVE_PERFTOOLS |
| 213 | LIBS += profiler |
| 214 | endif |
Craig Tiller | 50524cc | 2015-01-29 23:00:00 -0800 | [diff] [blame] | 215 | endif |
nnoble | 69ac39f | 2014-12-12 15:43:38 -0800 | [diff] [blame] | 216 | |
Craig Tiller | c4da6b7 | 2015-01-15 08:01:14 -0800 | [diff] [blame] | 217 | ifndef REQUIRE_CUSTOM_LIBRARIES_$(CONFIG) |
nnoble | 6082540 | 2014-12-15 14:43:51 -0800 | [diff] [blame] | 218 | HAS_SYSTEM_OPENSSL_ALPN = $(shell $(OPENSSL_ALPN_CHECK_CMD) 2> /dev/null && echo true || echo false) |
| 219 | HAS_SYSTEM_ZLIB = $(shell $(ZLIB_CHECK_CMD) 2> /dev/null && echo true || echo false) |
Craig Tiller | c4da6b7 | 2015-01-15 08:01:14 -0800 | [diff] [blame] | 220 | else |
| 221 | # override system libraries if the config requires a custom compiled library |
| 222 | HAS_SYSTEM_OPENSSL_ALPN = false |
| 223 | HAS_SYSTEM_ZLIB = false |
| 224 | endif |
nnoble | 69ac39f | 2014-12-12 15:43:38 -0800 | [diff] [blame] | 225 | |
nnoble | 69ac39f | 2014-12-12 15:43:38 -0800 | [diff] [blame] | 226 | ifeq ($(wildcard third_party/openssl/ssl/ssl.h),) |
| 227 | HAS_EMBEDDED_OPENSSL_ALPN = false |
| 228 | else |
| 229 | HAS_EMBEDDED_OPENSSL_ALPN = true |
| 230 | endif |
| 231 | |
| 232 | ifeq ($(wildcard third_party/zlib/zlib.h),) |
| 233 | HAS_EMBEDDED_ZLIB = false |
| 234 | else |
| 235 | HAS_EMBEDDED_ZLIB = true |
| 236 | endif |
| 237 | |
nnoble | 69ac39f | 2014-12-12 15:43:38 -0800 | [diff] [blame] | 238 | ifeq ($(HAS_SYSTEM_ZLIB),false) |
| 239 | ifeq ($(HAS_EMBEDDED_ZLIB),true) |
Craig Tiller | 3ccae02 | 2015-01-15 07:47:29 -0800 | [diff] [blame] | 240 | ZLIB_DEP = libs/$(CONFIG)/zlib/libz.a |
nnoble | 69ac39f | 2014-12-12 15:43:38 -0800 | [diff] [blame] | 241 | CPPFLAGS += -Ithird_party/zlib |
| 242 | LDFLAGS += -Lthird_party/zlib |
| 243 | else |
| 244 | DEP_MISSING += zlib |
| 245 | endif |
| 246 | endif |
| 247 | |
| 248 | ifeq ($(HAS_SYSTEM_OPENSSL_ALPN),false) |
| 249 | ifeq ($(HAS_EMBEDDED_OPENSSL_ALPN),true) |
Craig Tiller | ec0b8f3 | 2015-01-15 07:30:00 -0800 | [diff] [blame] | 250 | OPENSSL_DEP = libs/$(CONFIG)/openssl/libssl.a |
| 251 | OPENSSL_MERGE_LIBS += libs/$(CONFIG)/openssl/libssl.a libs/$(CONFIG)/openssl/libcrypto.a |
nnoble | 69ac39f | 2014-12-12 15:43:38 -0800 | [diff] [blame] | 252 | CPPFLAGS += -Ithird_party/openssl/include |
Craig Tiller | ec0b8f3 | 2015-01-15 07:30:00 -0800 | [diff] [blame] | 253 | LDFLAGS += -Llibs/$(CONFIG)/openssl |
nnoble | 5b7f32a | 2014-12-22 08:12:44 -0800 | [diff] [blame] | 254 | LIBS_SECURE = dl |
nnoble | 69ac39f | 2014-12-12 15:43:38 -0800 | [diff] [blame] | 255 | else |
| 256 | NO_SECURE = true |
| 257 | endif |
nnoble | 5b7f32a | 2014-12-22 08:12:44 -0800 | [diff] [blame] | 258 | else |
| 259 | LIBS_SECURE = ssl crypto dl |
nnoble | 69ac39f | 2014-12-12 15:43:38 -0800 | [diff] [blame] | 260 | endif |
| 261 | |
nnoble | 5b7f32a | 2014-12-22 08:12:44 -0800 | [diff] [blame] | 262 | LDLIBS_SECURE += $(addprefix -l, $(LIBS_SECURE)) |
| 263 | |
Craig Tiller | 12c8209 | 2015-01-15 08:45:56 -0800 | [diff] [blame] | 264 | ifeq ($(MAKECMDGOALS),clean) |
nnoble | 69ac39f | 2014-12-12 15:43:38 -0800 | [diff] [blame] | 265 | NO_DEPS = true |
| 266 | endif |
| 267 | |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 268 | .SECONDARY = %.pb.h %.pb.cc |
| 269 | |
Craig Tiller | f58b9ef | 2015-01-15 09:09:12 -0800 | [diff] [blame] | 270 | PROTOC_PLUGINS=\ |
| 271 | % for tgt in targets: |
| 272 | % if tgt.build == 'protoc': |
| 273 | bins/$(CONFIG)/${tgt.name}\ |
| 274 | % endif |
| 275 | % endfor |
| 276 | |
nnoble | 69ac39f | 2014-12-12 15:43:38 -0800 | [diff] [blame] | 277 | ifeq ($(DEP_MISSING),) |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 278 | all: static shared\ |
| 279 | % for tgt in targets: |
| 280 | % if tgt.build == 'all': |
ctiller | cab52e7 | 2015-01-06 13:10:23 -0800 | [diff] [blame] | 281 | bins/$(CONFIG)/${tgt.name}\ |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 282 | % endif |
| 283 | % endfor |
| 284 | |
nnoble | 69ac39f | 2014-12-12 15:43:38 -0800 | [diff] [blame] | 285 | dep_error: |
| 286 | @echo "You shouldn't see this message - all of your dependencies are correct." |
| 287 | else |
| 288 | all: dep_error git_update stop |
| 289 | |
| 290 | dep_error: |
| 291 | @echo |
| 292 | @echo "DEPENDENCY ERROR" |
| 293 | @echo |
| 294 | @echo "You are missing system dependencies that are essential to build grpc," |
| 295 | @echo "and the third_party directory doesn't have them:" |
| 296 | @echo |
| 297 | @echo " $(DEP_MISSING)" |
| 298 | @echo |
| 299 | @echo "Installing the development packages for your system will solve" |
| 300 | @echo "this issue. Please consult INSTALL to get more information." |
| 301 | @echo |
| 302 | @echo "If you need information about why these tests failed, run:" |
| 303 | @echo |
| 304 | @echo " make run_dep_checks" |
| 305 | @echo |
| 306 | endif |
| 307 | |
| 308 | git_update: |
| 309 | ifeq ($(IS_GIT_FOLDER),true) |
| 310 | @echo "Additionally, since you are in a git clone, you can download the" |
| 311 | @echo "missing dependencies in third_party by running the following command:" |
| 312 | @echo |
ctiller | 64f2910 | 2014-12-15 10:40:59 -0800 | [diff] [blame] | 313 | @echo " git submodule update --init" |
nnoble | 69ac39f | 2014-12-12 15:43:38 -0800 | [diff] [blame] | 314 | @echo |
| 315 | endif |
| 316 | |
| 317 | openssl_dep_error: openssl_dep_message git_update stop |
| 318 | |
| 319 | openssl_dep_message: |
| 320 | @echo |
| 321 | @echo "DEPENDENCY ERROR" |
| 322 | @echo |
| 323 | @echo "The target you are trying to run requires OpenSSL with ALPN support." |
| 324 | @echo "Your system doesn't have it, and neither does the third_party directory." |
| 325 | @echo |
| 326 | @echo "Please consult INSTALL to get more information." |
| 327 | @echo |
| 328 | @echo "If you need information about why these tests failed, run:" |
| 329 | @echo |
| 330 | @echo " make run_dep_checks" |
| 331 | @echo |
| 332 | |
| 333 | stop: |
| 334 | @false |
| 335 | |
ctiller | 09cb6d5 | 2014-12-19 17:38:22 -0800 | [diff] [blame] | 336 | % for tgt in targets: |
ctiller | cab52e7 | 2015-01-06 13:10:23 -0800 | [diff] [blame] | 337 | ${tgt.name}: bins/$(CONFIG)/${tgt.name} |
ctiller | 09cb6d5 | 2014-12-19 17:38:22 -0800 | [diff] [blame] | 338 | % endfor |
| 339 | |
nnoble | 69ac39f | 2014-12-12 15:43:38 -0800 | [diff] [blame] | 340 | run_dep_checks: |
nnoble | 69ac39f | 2014-12-12 15:43:38 -0800 | [diff] [blame] | 341 | $(OPENSSL_ALPN_CHECK_CMD) || true |
| 342 | $(ZLIB_CHECK_CMD) || true |
| 343 | |
Craig Tiller | 3ccae02 | 2015-01-15 07:47:29 -0800 | [diff] [blame] | 344 | libs/$(CONFIG)/zlib/libz.a: |
Nicolas "Pixel" Noble | 17f2b59 | 2015-01-16 07:09:10 +0100 | [diff] [blame] | 345 | $(E) "[MAKE] Building zlib" |
| 346 | $(Q)(cd third_party/zlib ; CC="$(CC)" CFLAGS="-fPIC -fvisibility=hidden $(CPPFLAGS_$(CONFIG))" ./configure --static) |
| 347 | $(Q)$(MAKE) -C third_party/zlib clean |
| 348 | $(Q)$(MAKE) -C third_party/zlib |
| 349 | $(Q)mkdir -p libs/$(CONFIG)/zlib |
| 350 | $(Q)cp third_party/zlib/libz.a libs/$(CONFIG)/zlib |
nnoble | 69ac39f | 2014-12-12 15:43:38 -0800 | [diff] [blame] | 351 | |
Craig Tiller | ec0b8f3 | 2015-01-15 07:30:00 -0800 | [diff] [blame] | 352 | libs/$(CONFIG)/openssl/libssl.a: |
Craig Tiller | b4ee3b5 | 2015-01-21 16:22:50 -0800 | [diff] [blame] | 353 | $(E) "[MAKE] Building openssl for $(SYSTEM)" |
| 354 | ifeq ($(SYSTEM),Darwin) |
| 355 | $(Q)(cd third_party/openssl ; CC="$(CC) -fPIC -fvisibility=hidden $(CPPFLAGS_$(CONFIG)) $(OPENSSL_CFLAGS_$(CONFIG))" ./Configure darwin64-x86_64-cc $(OPENSSL_CONFIG_$(CONFIG))) |
| 356 | else |
Nicolas "Pixel" Noble | 17f2b59 | 2015-01-16 07:09:10 +0100 | [diff] [blame] | 357 | $(Q)(cd third_party/openssl ; CC="$(CC) -fPIC -fvisibility=hidden $(CPPFLAGS_$(CONFIG)) $(OPENSSL_CFLAGS_$(CONFIG))" ./config $(OPENSSL_CONFIG_$(CONFIG))) |
Craig Tiller | b4ee3b5 | 2015-01-21 16:22:50 -0800 | [diff] [blame] | 358 | endif |
Nicolas "Pixel" Noble | 17f2b59 | 2015-01-16 07:09:10 +0100 | [diff] [blame] | 359 | $(Q)$(MAKE) -C third_party/openssl clean |
| 360 | $(Q)$(MAKE) -C third_party/openssl build_crypto build_ssl |
| 361 | $(Q)mkdir -p libs/$(CONFIG)/openssl |
| 362 | $(Q)cp third_party/openssl/libssl.a third_party/openssl/libcrypto.a libs/$(CONFIG)/openssl |
nnoble | 69ac39f | 2014-12-12 15:43:38 -0800 | [diff] [blame] | 363 | |
nnoble | 29e1d29 | 2014-12-01 10:27:40 -0800 | [diff] [blame] | 364 | static: static_c static_cxx |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 365 | |
Craig Tiller | 12c8209 | 2015-01-15 08:45:56 -0800 | [diff] [blame] | 366 | static_c: \ |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 367 | % for lib in libs: |
Craig Tiller | 59140fc | 2015-01-18 10:12:17 -0800 | [diff] [blame] | 368 | % if lib.build == 'all' and lib.language == 'c': |
ctiller | cab52e7 | 2015-01-06 13:10:23 -0800 | [diff] [blame] | 369 | libs/$(CONFIG)/lib${lib.name}.a\ |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 370 | % endif |
| 371 | % endfor |
| 372 | |
| 373 | |
Craig Tiller | 12c8209 | 2015-01-15 08:45:56 -0800 | [diff] [blame] | 374 | static_cxx: \ |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 375 | % for lib in libs: |
Craig Tiller | 59140fc | 2015-01-18 10:12:17 -0800 | [diff] [blame] | 376 | % if lib.build == 'all' and lib.language == 'c++': |
ctiller | cab52e7 | 2015-01-06 13:10:23 -0800 | [diff] [blame] | 377 | libs/$(CONFIG)/lib${lib.name}.a\ |
nnoble | 29e1d29 | 2014-12-01 10:27:40 -0800 | [diff] [blame] | 378 | % endif |
| 379 | % endfor |
| 380 | |
| 381 | |
| 382 | shared: shared_c shared_cxx |
| 383 | |
Craig Tiller | 12c8209 | 2015-01-15 08:45:56 -0800 | [diff] [blame] | 384 | shared_c: \ |
nnoble | 29e1d29 | 2014-12-01 10:27:40 -0800 | [diff] [blame] | 385 | % for lib in libs: |
Craig Tiller | 59140fc | 2015-01-18 10:12:17 -0800 | [diff] [blame] | 386 | % if lib.build == 'all' and lib.language == 'c': |
ctiller | cab52e7 | 2015-01-06 13:10:23 -0800 | [diff] [blame] | 387 | libs/$(CONFIG)/lib${lib.name}.$(SHARED_EXT)\ |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 388 | % endif |
| 389 | % endfor |
| 390 | |
| 391 | |
Craig Tiller | 12c8209 | 2015-01-15 08:45:56 -0800 | [diff] [blame] | 392 | shared_cxx: \ |
nnoble | 29e1d29 | 2014-12-01 10:27:40 -0800 | [diff] [blame] | 393 | % for lib in libs: |
Craig Tiller | 59140fc | 2015-01-18 10:12:17 -0800 | [diff] [blame] | 394 | % if lib.build == 'all' and lib.language == 'c++': |
ctiller | cab52e7 | 2015-01-06 13:10:23 -0800 | [diff] [blame] | 395 | libs/$(CONFIG)/lib${lib.name}.$(SHARED_EXT)\ |
nnoble | 29e1d29 | 2014-12-01 10:27:40 -0800 | [diff] [blame] | 396 | % endif |
| 397 | % endfor |
| 398 | |
| 399 | |
| 400 | privatelibs: privatelibs_c privatelibs_cxx |
| 401 | |
Craig Tiller | 12c8209 | 2015-01-15 08:45:56 -0800 | [diff] [blame] | 402 | privatelibs_c: \ |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 403 | % for lib in libs: |
Craig Tiller | 59140fc | 2015-01-18 10:12:17 -0800 | [diff] [blame] | 404 | % if lib.build == 'private' and lib.language == 'c': |
ctiller | cab52e7 | 2015-01-06 13:10:23 -0800 | [diff] [blame] | 405 | libs/$(CONFIG)/lib${lib.name}.a\ |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 406 | % endif |
| 407 | % endfor |
| 408 | |
| 409 | |
Craig Tiller | 12c8209 | 2015-01-15 08:45:56 -0800 | [diff] [blame] | 410 | privatelibs_cxx: \ |
nnoble | 29e1d29 | 2014-12-01 10:27:40 -0800 | [diff] [blame] | 411 | % for lib in libs: |
Craig Tiller | 59140fc | 2015-01-18 10:12:17 -0800 | [diff] [blame] | 412 | % if lib.build == 'private' and lib.language == 'c++': |
ctiller | cab52e7 | 2015-01-06 13:10:23 -0800 | [diff] [blame] | 413 | libs/$(CONFIG)/lib${lib.name}.a\ |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 414 | % endif |
| 415 | % endfor |
| 416 | |
| 417 | |
nnoble | 29e1d29 | 2014-12-01 10:27:40 -0800 | [diff] [blame] | 418 | buildtests: buildtests_c buildtests_cxx |
| 419 | |
Craig Tiller | 12c8209 | 2015-01-15 08:45:56 -0800 | [diff] [blame] | 420 | buildtests_c: privatelibs_c\ |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 421 | % for tgt in targets: |
Craig Tiller | 59140fc | 2015-01-18 10:12:17 -0800 | [diff] [blame] | 422 | % if tgt.build == 'test' and not tgt.language == 'c++': |
ctiller | cab52e7 | 2015-01-06 13:10:23 -0800 | [diff] [blame] | 423 | bins/$(CONFIG)/${tgt.name}\ |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 424 | % endif |
| 425 | % endfor |
| 426 | |
| 427 | |
Craig Tiller | 12c8209 | 2015-01-15 08:45:56 -0800 | [diff] [blame] | 428 | buildtests_cxx: privatelibs_cxx\ |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 429 | % for tgt in targets: |
Craig Tiller | 59140fc | 2015-01-18 10:12:17 -0800 | [diff] [blame] | 430 | % if tgt.build == 'test' and tgt.language == 'c++': |
Craig Tiller | f5371ef | 2015-01-12 16:40:18 -0800 | [diff] [blame] | 431 | bins/$(CONFIG)/${tgt.name}\ |
nnoble | 29e1d29 | 2014-12-01 10:27:40 -0800 | [diff] [blame] | 432 | % endif |
| 433 | % endfor |
| 434 | |
| 435 | |
nnoble | 85a4926 | 2014-12-08 18:14:03 -0800 | [diff] [blame] | 436 | test: test_c test_cxx |
nnoble | 29e1d29 | 2014-12-01 10:27:40 -0800 | [diff] [blame] | 437 | |
nnoble | 85a4926 | 2014-12-08 18:14:03 -0800 | [diff] [blame] | 438 | test_c: buildtests_c |
nnoble | 29e1d29 | 2014-12-01 10:27:40 -0800 | [diff] [blame] | 439 | % for tgt in targets: |
Craig Tiller | 59140fc | 2015-01-18 10:12:17 -0800 | [diff] [blame] | 440 | % if tgt.build == 'test' and tgt.get('run', True) and not tgt.language == 'c++': |
nnoble | 29e1d29 | 2014-12-01 10:27:40 -0800 | [diff] [blame] | 441 | $(E) "[RUN] Testing ${tgt.name}" |
ctiller | cab52e7 | 2015-01-06 13:10:23 -0800 | [diff] [blame] | 442 | $(Q) ./bins/$(CONFIG)/${tgt.name} || ( echo test ${tgt.name} failed ; exit 1 ) |
nnoble | 29e1d29 | 2014-12-01 10:27:40 -0800 | [diff] [blame] | 443 | % endif |
| 444 | % endfor |
| 445 | |
| 446 | |
nnoble | 85a4926 | 2014-12-08 18:14:03 -0800 | [diff] [blame] | 447 | test_cxx: buildtests_cxx |
nnoble | 29e1d29 | 2014-12-01 10:27:40 -0800 | [diff] [blame] | 448 | % for tgt in targets: |
Craig Tiller | 59140fc | 2015-01-18 10:12:17 -0800 | [diff] [blame] | 449 | % if tgt.build == 'test' and tgt.get('run', True) and tgt.language == 'c++': |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 450 | $(E) "[RUN] Testing ${tgt.name}" |
ctiller | cab52e7 | 2015-01-06 13:10:23 -0800 | [diff] [blame] | 451 | $(Q) ./bins/$(CONFIG)/${tgt.name} || ( echo test ${tgt.name} failed ; exit 1 ) |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 452 | % endif |
| 453 | % endfor |
| 454 | |
| 455 | |
| 456 | tools: privatelibs\ |
| 457 | % for tgt in targets: |
| 458 | % if tgt.build == 'tool': |
ctiller | cab52e7 | 2015-01-06 13:10:23 -0800 | [diff] [blame] | 459 | bins/$(CONFIG)/${tgt.name}\ |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 460 | % endif |
| 461 | % endfor |
| 462 | |
| 463 | |
| 464 | buildbenchmarks: privatelibs\ |
| 465 | % for tgt in targets: |
| 466 | % if tgt.build == 'benchmark': |
ctiller | cab52e7 | 2015-01-06 13:10:23 -0800 | [diff] [blame] | 467 | bins/$(CONFIG)/${tgt.name}\ |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 468 | % endif |
| 469 | % endfor |
| 470 | |
| 471 | |
| 472 | benchmarks: buildbenchmarks |
| 473 | |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 474 | strip: strip-static strip-shared |
| 475 | |
nnoble | 20e2e3f | 2014-12-16 15:37:57 -0800 | [diff] [blame] | 476 | strip-static: strip-static_c strip-static_cxx |
| 477 | |
| 478 | strip-shared: strip-shared_c strip-shared_cxx |
| 479 | |
Nicolas Noble | 047b727 | 2015-01-16 13:55:05 -0800 | [diff] [blame] | 480 | |
| 481 | # TODO(nnoble): the strip target is stripping in-place, instead |
| 482 | # of copying files in a temporary folder. |
| 483 | # This prevents proper debugging after running make install. |
| 484 | |
nnoble | 85a4926 | 2014-12-08 18:14:03 -0800 | [diff] [blame] | 485 | strip-static_c: static_c |
Nicolas "Pixel" Noble | 3a2551c | 2015-01-29 21:33:32 +0100 | [diff] [blame] | 486 | ifeq ($(CONFIG),opt) |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 487 | % for lib in libs: |
Craig Tiller | 59140fc | 2015-01-18 10:12:17 -0800 | [diff] [blame] | 488 | % if lib.language == "c": |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 489 | % if lib.build == "all": |
| 490 | $(E) "[STRIP] Stripping lib${lib.name}.a" |
ctiller | cab52e7 | 2015-01-06 13:10:23 -0800 | [diff] [blame] | 491 | $(Q) $(STRIP) libs/$(CONFIG)/lib${lib.name}.a |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 492 | % endif |
nnoble | 85a4926 | 2014-12-08 18:14:03 -0800 | [diff] [blame] | 493 | % endif |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 494 | % endfor |
Nicolas "Pixel" Noble | 3a2551c | 2015-01-29 21:33:32 +0100 | [diff] [blame] | 495 | endif |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 496 | |
nnoble | 85a4926 | 2014-12-08 18:14:03 -0800 | [diff] [blame] | 497 | strip-static_cxx: static_cxx |
Nicolas "Pixel" Noble | 3a2551c | 2015-01-29 21:33:32 +0100 | [diff] [blame] | 498 | ifeq ($(CONFIG),opt) |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 499 | % for lib in libs: |
Craig Tiller | 59140fc | 2015-01-18 10:12:17 -0800 | [diff] [blame] | 500 | % if lib.language == "c++": |
nnoble | 85a4926 | 2014-12-08 18:14:03 -0800 | [diff] [blame] | 501 | % if lib.build == "all": |
| 502 | $(E) "[STRIP] Stripping lib${lib.name}.a" |
ctiller | cab52e7 | 2015-01-06 13:10:23 -0800 | [diff] [blame] | 503 | $(Q) $(STRIP) libs/$(CONFIG)/lib${lib.name}.a |
nnoble | 85a4926 | 2014-12-08 18:14:03 -0800 | [diff] [blame] | 504 | % endif |
| 505 | % endif |
| 506 | % endfor |
Nicolas "Pixel" Noble | 3a2551c | 2015-01-29 21:33:32 +0100 | [diff] [blame] | 507 | endif |
nnoble | 85a4926 | 2014-12-08 18:14:03 -0800 | [diff] [blame] | 508 | |
| 509 | strip-shared_c: shared_c |
Nicolas "Pixel" Noble | 3a2551c | 2015-01-29 21:33:32 +0100 | [diff] [blame] | 510 | ifeq ($(CONFIG),opt) |
nnoble | 85a4926 | 2014-12-08 18:14:03 -0800 | [diff] [blame] | 511 | % for lib in libs: |
Craig Tiller | 59140fc | 2015-01-18 10:12:17 -0800 | [diff] [blame] | 512 | % if lib.language == "c": |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 513 | % if lib.build == "all": |
| 514 | $(E) "[STRIP] Stripping lib${lib.name}.so" |
ctiller | cab52e7 | 2015-01-06 13:10:23 -0800 | [diff] [blame] | 515 | $(Q) $(STRIP) libs/$(CONFIG)/lib${lib.name}.$(SHARED_EXT) |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 516 | % endif |
nnoble | 85a4926 | 2014-12-08 18:14:03 -0800 | [diff] [blame] | 517 | % endif |
| 518 | % endfor |
Nicolas "Pixel" Noble | 3a2551c | 2015-01-29 21:33:32 +0100 | [diff] [blame] | 519 | endif |
nnoble | 85a4926 | 2014-12-08 18:14:03 -0800 | [diff] [blame] | 520 | |
| 521 | strip-shared_cxx: shared_cxx |
Nicolas "Pixel" Noble | 3a2551c | 2015-01-29 21:33:32 +0100 | [diff] [blame] | 522 | ifeq ($(CONFIG),opt) |
nnoble | 85a4926 | 2014-12-08 18:14:03 -0800 | [diff] [blame] | 523 | % for lib in libs: |
Craig Tiller | 59140fc | 2015-01-18 10:12:17 -0800 | [diff] [blame] | 524 | % if lib.language == "c++": |
nnoble | 85a4926 | 2014-12-08 18:14:03 -0800 | [diff] [blame] | 525 | % if lib.build == "all": |
| 526 | $(E) "[STRIP] Stripping lib${lib.name}.so" |
ctiller | cab52e7 | 2015-01-06 13:10:23 -0800 | [diff] [blame] | 527 | $(Q) $(STRIP) libs/$(CONFIG)/lib${lib.name}.$(SHARED_EXT) |
nnoble | 85a4926 | 2014-12-08 18:14:03 -0800 | [diff] [blame] | 528 | % endif |
| 529 | % endif |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 530 | % endfor |
Nicolas "Pixel" Noble | 3a2551c | 2015-01-29 21:33:32 +0100 | [diff] [blame] | 531 | endif |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 532 | |
nnoble | 72309c6 | 2014-12-12 11:42:26 -0800 | [diff] [blame] | 533 | % for p in protos: |
Craig Tiller | f58b9ef | 2015-01-15 09:09:12 -0800 | [diff] [blame] | 534 | gens/${p}.pb.cc: ${p}.proto $(PROTOC_PLUGINS) |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 535 | $(E) "[PROTOC] Generating protobuf CC file from $<" |
| 536 | $(Q) mkdir -p `dirname $@` |
ctiller | cab52e7 | 2015-01-06 13:10:23 -0800 | [diff] [blame] | 537 | $(Q) $(PROTOC) --cpp_out=gens --grpc_out=gens --plugin=protoc-gen-grpc=bins/$(CONFIG)/cpp_plugin $< |
nnoble | 72309c6 | 2014-12-12 11:42:26 -0800 | [diff] [blame] | 538 | |
| 539 | % endfor |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 540 | |
ctiller | cab52e7 | 2015-01-06 13:10:23 -0800 | [diff] [blame] | 541 | objs/$(CONFIG)/%.o : %.c |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 542 | $(E) "[C] Compiling $<" |
| 543 | $(Q) mkdir -p `dirname $@` |
Craig Tiller | 12c8209 | 2015-01-15 08:45:56 -0800 | [diff] [blame] | 544 | $(Q) $(CC) $(CFLAGS) $(CPPFLAGS) -MMD -MF $(addsuffix .dep, $(basename $@)) -c -o $@ $< |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 545 | |
ctiller | cab52e7 | 2015-01-06 13:10:23 -0800 | [diff] [blame] | 546 | objs/$(CONFIG)/%.o : gens/%.pb.cc |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 547 | $(E) "[CXX] Compiling $<" |
| 548 | $(Q) mkdir -p `dirname $@` |
Craig Tiller | 12c8209 | 2015-01-15 08:45:56 -0800 | [diff] [blame] | 549 | $(Q) $(CXX) $(CXXFLAGS) $(CPPFLAGS) -MMD -MF $(addsuffix .dep, $(basename $@)) -c -o $@ $< |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 550 | |
ctiller | cab52e7 | 2015-01-06 13:10:23 -0800 | [diff] [blame] | 551 | objs/$(CONFIG)/src/compiler/%.o : src/compiler/%.cc |
nnoble | 72309c6 | 2014-12-12 11:42:26 -0800 | [diff] [blame] | 552 | $(E) "[HOSTCXX] Compiling $<" |
| 553 | $(Q) mkdir -p `dirname $@` |
Craig Tiller | 12c8209 | 2015-01-15 08:45:56 -0800 | [diff] [blame] | 554 | $(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] | 555 | |
ctiller | cab52e7 | 2015-01-06 13:10:23 -0800 | [diff] [blame] | 556 | objs/$(CONFIG)/%.o : %.cc |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 557 | $(E) "[CXX] Compiling $<" |
| 558 | $(Q) mkdir -p `dirname $@` |
Craig Tiller | 12c8209 | 2015-01-15 08:45:56 -0800 | [diff] [blame] | 559 | $(Q) $(CXX) $(CXXFLAGS) $(CPPFLAGS) -MMD -MF $(addsuffix .dep, $(basename $@)) -c -o $@ $< |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 560 | |
| 561 | |
nnoble | 85a4926 | 2014-12-08 18:14:03 -0800 | [diff] [blame] | 562 | install: install_c install_cxx |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 563 | |
nnoble | 85a4926 | 2014-12-08 18:14:03 -0800 | [diff] [blame] | 564 | install_c: install-headers_c install-static_c install-shared_c |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 565 | |
nnoble | 85a4926 | 2014-12-08 18:14:03 -0800 | [diff] [blame] | 566 | install_cxx: install-headers_cxx install-static_cxx install-shared_cxx |
| 567 | |
| 568 | install-headers: install-headers_c install-headers_cxx |
| 569 | |
| 570 | install-headers_c: |
| 571 | $(E) "[INSTALL] Installing public C headers" |
| 572 | $(Q) $(foreach h, $(PUBLIC_HEADERS_C), $(INSTALL) $(h) $(prefix)/$(h) && ) exit 0 || exit 1 |
| 573 | |
| 574 | install-headers_cxx: |
| 575 | $(E) "[INSTALL] Installing public C++ headers" |
| 576 | $(Q) $(foreach h, $(PUBLIC_HEADERS_CXX), $(INSTALL) $(h) $(prefix)/$(h) && ) exit 0 || exit 1 |
| 577 | |
| 578 | install-static: install-static_c install-static_cxx |
| 579 | |
| 580 | install-static_c: static_c strip-static_c |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 581 | % for lib in libs: |
Craig Tiller | 59140fc | 2015-01-18 10:12:17 -0800 | [diff] [blame] | 582 | % if lib.language == "c": |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 583 | % if lib.build == "all": |
| 584 | $(E) "[INSTALL] Installing lib${lib.name}.a" |
ctiller | cab52e7 | 2015-01-06 13:10:23 -0800 | [diff] [blame] | 585 | $(Q) $(INSTALL) libs/$(CONFIG)/lib${lib.name}.a $(prefix)/lib/lib${lib.name}.a |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 586 | % endif |
nnoble | 85a4926 | 2014-12-08 18:14:03 -0800 | [diff] [blame] | 587 | % endif |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 588 | % endfor |
| 589 | |
nnoble | 85a4926 | 2014-12-08 18:14:03 -0800 | [diff] [blame] | 590 | install-static_cxx: static_cxx strip-static_cxx |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 591 | % for lib in libs: |
Craig Tiller | 59140fc | 2015-01-18 10:12:17 -0800 | [diff] [blame] | 592 | % if lib.language == "c++": |
nnoble | 85a4926 | 2014-12-08 18:14:03 -0800 | [diff] [blame] | 593 | % if lib.build == "all": |
| 594 | $(E) "[INSTALL] Installing lib${lib.name}.a" |
ctiller | cab52e7 | 2015-01-06 13:10:23 -0800 | [diff] [blame] | 595 | $(Q) $(INSTALL) libs/$(CONFIG)/lib${lib.name}.a $(prefix)/lib/lib${lib.name}.a |
nnoble | 85a4926 | 2014-12-08 18:14:03 -0800 | [diff] [blame] | 596 | % endif |
| 597 | % endif |
| 598 | % endfor |
| 599 | |
| 600 | install-shared_c: shared_c strip-shared_c |
| 601 | % for lib in libs: |
Craig Tiller | 59140fc | 2015-01-18 10:12:17 -0800 | [diff] [blame] | 602 | % if lib.language == "c": |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 603 | % if lib.build == "all": |
nnoble | 5b7f32a | 2014-12-22 08:12:44 -0800 | [diff] [blame] | 604 | ifeq ($(SYSTEM),MINGW32) |
| 605 | $(E) "[INSTALL] Installing ${lib.name}.$(SHARED_EXT)" |
ctiller | cab52e7 | 2015-01-06 13:10:23 -0800 | [diff] [blame] | 606 | $(Q) $(INSTALL) libs/$(CONFIG)/${lib.name}.$(SHARED_EXT) $(prefix)/lib/${lib.name}.$(SHARED_EXT) |
| 607 | $(Q) $(INSTALL) libs/$(CONFIG)/lib${lib.name}-imp.a $(prefix)/lib/lib${lib.name}-imp.a |
nnoble | 5b7f32a | 2014-12-22 08:12:44 -0800 | [diff] [blame] | 608 | else |
| 609 | $(E) "[INSTALL] Installing lib${lib.name}.$(SHARED_EXT)" |
ctiller | cab52e7 | 2015-01-06 13:10:23 -0800 | [diff] [blame] | 610 | $(Q) $(INSTALL) libs/$(CONFIG)/lib${lib.name}.$(SHARED_EXT) $(prefix)/lib/lib${lib.name}.$(SHARED_EXT) |
nnoble | 5b7f32a | 2014-12-22 08:12:44 -0800 | [diff] [blame] | 611 | ifneq ($(SYSTEM),Darwin) |
| 612 | $(Q) ln -sf lib${lib.name}.$(SHARED_EXT) $(prefix)/lib/lib${lib.name}.so |
| 613 | endif |
| 614 | endif |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 615 | % endif |
nnoble | 85a4926 | 2014-12-08 18:14:03 -0800 | [diff] [blame] | 616 | % endif |
| 617 | % endfor |
nnoble | 5b7f32a | 2014-12-22 08:12:44 -0800 | [diff] [blame] | 618 | ifneq ($(SYSTEM),MINGW32) |
| 619 | ifneq ($(SYSTEM),Darwin) |
| 620 | $(Q) ldconfig |
| 621 | endif |
| 622 | endif |
nnoble | 85a4926 | 2014-12-08 18:14:03 -0800 | [diff] [blame] | 623 | |
| 624 | install-shared_cxx: shared_cxx strip-shared_cxx |
| 625 | % for lib in libs: |
Craig Tiller | 59140fc | 2015-01-18 10:12:17 -0800 | [diff] [blame] | 626 | % if lib.language == "c++": |
nnoble | 85a4926 | 2014-12-08 18:14:03 -0800 | [diff] [blame] | 627 | % if lib.build == "all": |
nnoble | 5b7f32a | 2014-12-22 08:12:44 -0800 | [diff] [blame] | 628 | ifeq ($(SYSTEM),MINGW32) |
| 629 | $(E) "[INSTALL] Installing ${lib.name}.$(SHARED_EXT)" |
ctiller | cab52e7 | 2015-01-06 13:10:23 -0800 | [diff] [blame] | 630 | $(Q) $(INSTALL) libs/$(CONFIG)/${lib.name}.$(SHARED_EXT) $(prefix)/lib/${lib.name}.$(SHARED_EXT) |
| 631 | $(Q) $(INSTALL) libs/$(CONFIG)/lib${lib.name}-imp.a $(prefix)/lib/lib${lib.name}-imp.a |
nnoble | 5b7f32a | 2014-12-22 08:12:44 -0800 | [diff] [blame] | 632 | else |
| 633 | $(E) "[INSTALL] Installing lib${lib.name}.$(SHARED_EXT)" |
ctiller | cab52e7 | 2015-01-06 13:10:23 -0800 | [diff] [blame] | 634 | $(Q) $(INSTALL) libs/$(CONFIG)/lib${lib.name}.$(SHARED_EXT) $(prefix)/lib/lib${lib.name}.$(SHARED_EXT) |
nnoble | 5b7f32a | 2014-12-22 08:12:44 -0800 | [diff] [blame] | 635 | ifneq ($(SYSTEM),Darwin) |
| 636 | $(Q) ln -sf lib${lib.name}.$(SHARED_EXT) $(prefix)/lib/lib${lib.name}.so |
| 637 | endif |
| 638 | endif |
nnoble | 85a4926 | 2014-12-08 18:14:03 -0800 | [diff] [blame] | 639 | % endif |
| 640 | % endif |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 641 | % endfor |
nnoble | 5b7f32a | 2014-12-22 08:12:44 -0800 | [diff] [blame] | 642 | ifneq ($(SYSTEM),MINGW32) |
| 643 | ifneq ($(SYSTEM),Darwin) |
| 644 | $(Q) ldconfig |
| 645 | endif |
| 646 | endif |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 647 | |
Craig Tiller | 3759e6f | 2015-01-15 08:13:11 -0800 | [diff] [blame] | 648 | clean: |
Craig Tiller | 12c8209 | 2015-01-15 08:45:56 -0800 | [diff] [blame] | 649 | $(Q) $(RM) -rf objs libs bins gens |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 650 | |
| 651 | |
| 652 | # The various libraries |
| 653 | |
| 654 | % for lib in libs: |
| 655 | ${makelib(lib)} |
| 656 | % endfor |
| 657 | |
| 658 | |
nnoble | 69ac39f | 2014-12-12 15:43:38 -0800 | [diff] [blame] | 659 | # All of the test targets, and protoc plugins |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 660 | |
| 661 | % for tgt in targets: |
| 662 | ${maketarget(tgt)} |
| 663 | % endfor |
| 664 | |
| 665 | <%def name="makelib(lib)"> |
| 666 | LIB${lib.name.upper()}_SRC = \\ |
| 667 | |
| 668 | % for src in lib.src: |
nnoble | 72309c6 | 2014-12-12 11:42:26 -0800 | [diff] [blame] | 669 | ${proto_to_cc(src)} \\ |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 670 | |
| 671 | % endfor |
| 672 | |
| 673 | % if "public_headers" in lib: |
Craig Tiller | 59140fc | 2015-01-18 10:12:17 -0800 | [diff] [blame] | 674 | % if lib.language == "c++": |
nnoble | 85a4926 | 2014-12-08 18:14:03 -0800 | [diff] [blame] | 675 | PUBLIC_HEADERS_CXX += \\ |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 676 | |
nnoble | 85a4926 | 2014-12-08 18:14:03 -0800 | [diff] [blame] | 677 | % else: |
| 678 | PUBLIC_HEADERS_C += \\ |
| 679 | |
| 680 | % endif |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 681 | % for hdr in lib.public_headers: |
| 682 | ${hdr} \\ |
| 683 | |
| 684 | % endfor |
| 685 | % endif |
| 686 | |
ctiller | cab52e7 | 2015-01-06 13:10:23 -0800 | [diff] [blame] | 687 | LIB${lib.name.upper()}_OBJS = $(addprefix objs/$(CONFIG)/, $(addsuffix .o, $(basename $(LIB${lib.name.upper()}_SRC)))) |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 688 | |
Nicolas Noble | 047b727 | 2015-01-16 13:55:05 -0800 | [diff] [blame] | 689 | ## If the library requires OpenSSL with ALPN, let's add some restrictions. |
nnoble | 69ac39f | 2014-12-12 15:43:38 -0800 | [diff] [blame] | 690 | % if lib.get('secure', True): |
nnoble | 69ac39f | 2014-12-12 15:43:38 -0800 | [diff] [blame] | 691 | ifeq ($(NO_SECURE),true) |
| 692 | |
Nicolas Noble | 047b727 | 2015-01-16 13:55:05 -0800 | [diff] [blame] | 693 | # You can't build secure libraries if you don't have OpenSSL with ALPN. |
| 694 | |
ctiller | cab52e7 | 2015-01-06 13:10:23 -0800 | [diff] [blame] | 695 | libs/$(CONFIG)/lib${lib.name}.a: openssl_dep_error |
nnoble | 69ac39f | 2014-12-12 15:43:38 -0800 | [diff] [blame] | 696 | |
nnoble | 5b7f32a | 2014-12-22 08:12:44 -0800 | [diff] [blame] | 697 | % if lib.build == "all": |
| 698 | ifeq ($(SYSTEM),MINGW32) |
ctiller | cab52e7 | 2015-01-06 13:10:23 -0800 | [diff] [blame] | 699 | libs/$(CONFIG)/${lib.name}.$(SHARED_EXT): openssl_dep_error |
nnoble | 5b7f32a | 2014-12-22 08:12:44 -0800 | [diff] [blame] | 700 | else |
ctiller | cab52e7 | 2015-01-06 13:10:23 -0800 | [diff] [blame] | 701 | libs/$(CONFIG)/lib${lib.name}.$(SHARED_EXT): openssl_dep_error |
nnoble | 5b7f32a | 2014-12-22 08:12:44 -0800 | [diff] [blame] | 702 | endif |
| 703 | % endif |
| 704 | |
nnoble | 69ac39f | 2014-12-12 15:43:38 -0800 | [diff] [blame] | 705 | else |
| 706 | |
Nicolas "Pixel" Noble | 17f2b59 | 2015-01-16 07:09:10 +0100 | [diff] [blame] | 707 | ifneq ($(OPENSSL_DEP),) |
| 708 | % for src in lib.src: |
| 709 | ${src}: $(OPENSSL_DEP) |
| 710 | % endfor |
| 711 | endif |
| 712 | |
Nicolas "Pixel" Noble | 85bf09b | 2015-01-15 18:22:40 +0100 | [diff] [blame] | 713 | libs/$(CONFIG)/lib${lib.name}.a: $(ZLIB_DEP) $(OPENSSL_DEP) $(LIB${lib.name.upper()}_OBJS) |
Nicolas Noble | 047b727 | 2015-01-16 13:55:05 -0800 | [diff] [blame] | 714 | ## The else here corresponds to the if secure earlier. |
nnoble | 20e2e3f | 2014-12-16 15:37:57 -0800 | [diff] [blame] | 715 | % else: |
Nicolas "Pixel" Noble | 85bf09b | 2015-01-15 18:22:40 +0100 | [diff] [blame] | 716 | libs/$(CONFIG)/lib${lib.name}.a: $(ZLIB_DEP) $(LIB${lib.name.upper()}_OBJS) |
nnoble | 20e2e3f | 2014-12-16 15:37:57 -0800 | [diff] [blame] | 717 | % endif |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 718 | $(E) "[AR] Creating $@" |
nnoble | 85a4926 | 2014-12-08 18:14:03 -0800 | [diff] [blame] | 719 | $(Q) mkdir -p `dirname $@` |
Craig Tiller | b4ee3b5 | 2015-01-21 16:22:50 -0800 | [diff] [blame] | 720 | $(Q) rm -f libs/$(CONFIG)/lib${lib.name}.a |
ctiller | cab52e7 | 2015-01-06 13:10:23 -0800 | [diff] [blame] | 721 | $(Q) $(AR) rcs libs/$(CONFIG)/lib${lib.name}.a $(LIB${lib.name.upper()}_OBJS) |
nnoble | 20e2e3f | 2014-12-16 15:37:57 -0800 | [diff] [blame] | 722 | % if lib.get('baselib', False): |
| 723 | % if lib.get('secure', True): |
Craig Tiller | f5371ef | 2015-01-12 16:40:18 -0800 | [diff] [blame] | 724 | $(Q) rm -rf tmp-merge |
nnoble | 20e2e3f | 2014-12-16 15:37:57 -0800 | [diff] [blame] | 725 | $(Q) mkdir tmp-merge |
ctiller | cab52e7 | 2015-01-06 13:10:23 -0800 | [diff] [blame] | 726 | $(Q) ( cd tmp-merge ; $(AR) x ../libs/$(CONFIG)/lib${lib.name}.a ) |
nnoble | 20e2e3f | 2014-12-16 15:37:57 -0800 | [diff] [blame] | 727 | $(Q) for l in $(OPENSSL_MERGE_LIBS) ; do ( cd tmp-merge ; <%text>ar x ../$${l}</%text> ) ; done |
ctiller | cab52e7 | 2015-01-06 13:10:23 -0800 | [diff] [blame] | 728 | $(Q) rm -f libs/$(CONFIG)/lib${lib.name}.a tmp-merge/__.SYMDEF* |
| 729 | $(Q) ar rcs libs/$(CONFIG)/lib${lib.name}.a tmp-merge/* |
nnoble | 20e2e3f | 2014-12-16 15:37:57 -0800 | [diff] [blame] | 730 | $(Q) rm -rf tmp-merge |
| 731 | % endif |
| 732 | % endif |
Craig Tiller | b4ee3b5 | 2015-01-21 16:22:50 -0800 | [diff] [blame] | 733 | ifeq ($(SYSTEM),Darwin) |
| 734 | $(Q) ranlib libs/$(CONFIG)/lib${lib.name}.a |
| 735 | endif |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 736 | |
nnoble | 5b7f32a | 2014-12-22 08:12:44 -0800 | [diff] [blame] | 737 | <% |
Craig Tiller | 59140fc | 2015-01-18 10:12:17 -0800 | [diff] [blame] | 738 | if lib.language == 'c++': |
nnoble | 5b7f32a | 2014-12-22 08:12:44 -0800 | [diff] [blame] | 739 | ld = '$(LDXX)' |
| 740 | else: |
| 741 | ld = '$(LD)' |
| 742 | |
ctiller | cab52e7 | 2015-01-06 13:10:23 -0800 | [diff] [blame] | 743 | out_base = 'libs/$(CONFIG)/' + lib.name |
| 744 | out_libbase = 'libs/$(CONFIG)/lib' + lib.name |
nnoble | 5b7f32a | 2014-12-22 08:12:44 -0800 | [diff] [blame] | 745 | |
| 746 | common = '$(LIB' + lib.name.upper() + '_OBJS) $(LDLIBS)' |
| 747 | |
| 748 | libs = '' |
Nicolas "Pixel" Noble | 85bf09b | 2015-01-15 18:22:40 +0100 | [diff] [blame] | 749 | lib_deps = ' $(ZLIB_DEP)' |
nnoble | 5b7f32a | 2014-12-22 08:12:44 -0800 | [diff] [blame] | 750 | mingw_libs = '' |
Nicolas "Pixel" Noble | 85bf09b | 2015-01-15 18:22:40 +0100 | [diff] [blame] | 751 | mingw_lib_deps = ' $(ZLIB_DEP)' |
nnoble | 5b7f32a | 2014-12-22 08:12:44 -0800 | [diff] [blame] | 752 | for dep in lib.get('deps', []): |
| 753 | libs = libs + ' -l' + dep |
Craig Tiller | a614caa | 2015-01-15 09:33:21 -0800 | [diff] [blame] | 754 | lib_deps = lib_deps + ' libs/$(CONFIG)/lib' + dep + '.$(SHARED_EXT)' |
nnoble | 5b7f32a | 2014-12-22 08:12:44 -0800 | [diff] [blame] | 755 | mingw_libs = mingw_libs + ' -l' + dep + '-imp' |
ctiller | cab52e7 | 2015-01-06 13:10:23 -0800 | [diff] [blame] | 756 | mingw_lib_deps = mingw_lib_deps + 'libs/$(CONFIG)/' + dep + '.$(SHARED_EXT)' |
nnoble | 5b7f32a | 2014-12-22 08:12:44 -0800 | [diff] [blame] | 757 | |
| 758 | if lib.get('secure', True): |
| 759 | common = common + ' $(LDLIBS_SECURE) $(OPENSSL_MERGE_LIBS)' |
| 760 | lib_deps = lib_deps + ' $(OPENSSL_DEP)' |
| 761 | mingw_lib_deps = mingw_lib_deps + ' $(OPENSSL_DEP)' |
nnoble | 5b7f32a | 2014-12-22 08:12:44 -0800 | [diff] [blame] | 762 | %> |
| 763 | |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 764 | % if lib.build == "all": |
nnoble | 5b7f32a | 2014-12-22 08:12:44 -0800 | [diff] [blame] | 765 | ifeq ($(SYSTEM),MINGW32) |
| 766 | ${out_base}.$(SHARED_EXT): $(LIB${lib.name.upper()}_OBJS) ${mingw_lib_deps} |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 767 | $(E) "[LD] Linking $@" |
nnoble | 85a4926 | 2014-12-08 18:14:03 -0800 | [diff] [blame] | 768 | $(Q) mkdir -p `dirname $@` |
ctiller | cab52e7 | 2015-01-06 13:10:23 -0800 | [diff] [blame] | 769 | $(Q) ${ld} $(LDFLAGS) -Llibs/$(CONFIG) -shared -Wl,--output-def=${out_base}.def -Wl,--out-implib=${out_libbase}-imp.a -o ${out_base}.$(SHARED_EXT) ${common}${mingw_libs} |
nnoble | 5b7f32a | 2014-12-22 08:12:44 -0800 | [diff] [blame] | 770 | else |
| 771 | ${out_libbase}.$(SHARED_EXT): $(LIB${lib.name.upper()}_OBJS) ${lib_deps} |
| 772 | $(E) "[LD] Linking $@" |
| 773 | $(Q) mkdir -p `dirname $@` |
| 774 | ifeq ($(SYSTEM),Darwin) |
ctiller | cab52e7 | 2015-01-06 13:10:23 -0800 | [diff] [blame] | 775 | $(Q) ${ld} $(LDFLAGS) -Llibs/$(CONFIG) -dynamiclib -o ${out_libbase}.$(SHARED_EXT) ${common}${libs} |
nnoble | 5b7f32a | 2014-12-22 08:12:44 -0800 | [diff] [blame] | 776 | else |
ctiller | cab52e7 | 2015-01-06 13:10:23 -0800 | [diff] [blame] | 777 | $(Q) ${ld} $(LDFLAGS) -Llibs/$(CONFIG) -shared -Wl,-soname,lib${lib.name}.so.${settings.version.major} -o ${out_libbase}.$(SHARED_EXT) ${common}${libs} |
Nicolas "Pixel" Noble | d8f8b6b | 2015-01-29 21:29:43 +0100 | [diff] [blame] | 778 | $(Q) ln -sf lib${lib.name}.$(SHARED_EXT) ${out_libbase}.so.${settings.version.major} |
nnoble | 5b7f32a | 2014-12-22 08:12:44 -0800 | [diff] [blame] | 779 | $(Q) ln -sf lib${lib.name}.$(SHARED_EXT) ${out_libbase}.so |
| 780 | endif |
| 781 | endif |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 782 | % endif |
| 783 | |
Nicolas Noble | 047b727 | 2015-01-16 13:55:05 -0800 | [diff] [blame] | 784 | ## If the lib was secure, we have to close the Makefile's if that tested |
| 785 | ## the presence of an ALPN-capable OpenSSL. |
nnoble | 69ac39f | 2014-12-12 15:43:38 -0800 | [diff] [blame] | 786 | % if lib.get('secure', True): |
| 787 | |
| 788 | endif |
| 789 | % endif |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 790 | |
nnoble | 69ac39f | 2014-12-12 15:43:38 -0800 | [diff] [blame] | 791 | % if lib.get('secure', True): |
| 792 | ifneq ($(NO_SECURE),true) |
| 793 | % endif |
| 794 | ifneq ($(NO_DEPS),true) |
Craig Tiller | 8f126a6 | 2015-01-15 08:50:19 -0800 | [diff] [blame] | 795 | -include $(LIB${lib.name.upper()}_OBJS:.o=.dep) |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 796 | endif |
nnoble | 69ac39f | 2014-12-12 15:43:38 -0800 | [diff] [blame] | 797 | % if lib.get('secure', True): |
| 798 | endif |
| 799 | % endif |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 800 | |
Craig Tiller | 27715ca | 2015-01-12 16:55:59 -0800 | [diff] [blame] | 801 | % for src in lib.src: |
| 802 | % if not proto_re.match(src): |
| 803 | objs/$(CONFIG)/${os.path.splitext(src)[0]}.o: \ |
| 804 | % for src2 in lib.src: |
| 805 | % if proto_re.match(src2): |
| 806 | ${proto_to_cc(src2)}\ |
| 807 | % endif |
| 808 | % endfor |
| 809 | % endif |
| 810 | |
| 811 | % endfor |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 812 | </%def> |
| 813 | |
| 814 | <%def name="maketarget(tgt)"> |
| 815 | ${tgt.name.upper()}_SRC = \\ |
| 816 | |
| 817 | % for src in tgt.src: |
nnoble | 72309c6 | 2014-12-12 11:42:26 -0800 | [diff] [blame] | 818 | ${proto_to_cc(src)} \\ |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 819 | |
| 820 | % endfor |
| 821 | |
ctiller | cab52e7 | 2015-01-06 13:10:23 -0800 | [diff] [blame] | 822 | ${tgt.name.upper()}_OBJS = $(addprefix objs/$(CONFIG)/, $(addsuffix .o, $(basename $(${tgt.name.upper()}_SRC)))) |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 823 | |
nnoble | 69ac39f | 2014-12-12 15:43:38 -0800 | [diff] [blame] | 824 | % if tgt.get('secure', True): |
| 825 | ifeq ($(NO_SECURE),true) |
| 826 | |
Nicolas Noble | 047b727 | 2015-01-16 13:55:05 -0800 | [diff] [blame] | 827 | # You can't build secure targets if you don't have OpenSSL with ALPN. |
| 828 | |
ctiller | cab52e7 | 2015-01-06 13:10:23 -0800 | [diff] [blame] | 829 | bins/$(CONFIG)/${tgt.name}: openssl_dep_error |
nnoble | 69ac39f | 2014-12-12 15:43:38 -0800 | [diff] [blame] | 830 | |
| 831 | else |
| 832 | |
| 833 | % endif |
Nicolas Noble | 047b727 | 2015-01-16 13:55:05 -0800 | [diff] [blame] | 834 | ## |
| 835 | ## We're not trying to add a dependency on building zlib and openssl here, |
| 836 | ## as it's already done in the libraries. We're assuming that the build |
| 837 | ## trickles down, and that a secure target requires a secure version of |
| 838 | ## a library. |
| 839 | ## |
| 840 | ## That simplifies the codegen a bit, but prevents a fully defined Makefile. |
| 841 | ## I can live with that. |
| 842 | ## |
ctiller | cab52e7 | 2015-01-06 13:10:23 -0800 | [diff] [blame] | 843 | bins/$(CONFIG)/${tgt.name}: $(${tgt.name.upper()}_OBJS)\ |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 844 | % for dep in tgt.deps: |
ctiller | cab52e7 | 2015-01-06 13:10:23 -0800 | [diff] [blame] | 845 | libs/$(CONFIG)/lib${dep}.a\ |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 846 | % endfor |
| 847 | |
Craig Tiller | 59140fc | 2015-01-18 10:12:17 -0800 | [diff] [blame] | 848 | % if tgt.language == "c++": |
Nicolas Noble | 047b727 | 2015-01-16 13:55:05 -0800 | [diff] [blame] | 849 | ## C++ targets specificies. |
nnoble | 72309c6 | 2014-12-12 11:42:26 -0800 | [diff] [blame] | 850 | % if tgt.build == 'protoc': |
| 851 | $(E) "[HOSTLD] Linking $@" |
| 852 | $(Q) mkdir -p `dirname $@` |
| 853 | $(Q) $(HOST_LDXX) $(HOST_LDFLAGS) $(${tgt.name.upper()}_OBJS)\ |
| 854 | % else: |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 855 | $(E) "[LD] Linking $@" |
nnoble | 85a4926 | 2014-12-08 18:14:03 -0800 | [diff] [blame] | 856 | $(Q) mkdir -p `dirname $@` |
nnoble | c78b340 | 2014-12-11 16:06:57 -0800 | [diff] [blame] | 857 | $(Q) $(LDXX) $(LDFLAGS) $(${tgt.name.upper()}_OBJS)\ |
nnoble | 72309c6 | 2014-12-12 11:42:26 -0800 | [diff] [blame] | 858 | % endif |
nnoble | c78b340 | 2014-12-11 16:06:57 -0800 | [diff] [blame] | 859 | % if tgt.build == 'test': |
| 860 | $(GTEST_LIB)\ |
| 861 | % endif |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 862 | % else: |
Nicolas Noble | 047b727 | 2015-01-16 13:55:05 -0800 | [diff] [blame] | 863 | ## C-only targets specificities. |
nnoble | 72309c6 | 2014-12-12 11:42:26 -0800 | [diff] [blame] | 864 | $(E) "[LD] Linking $@" |
| 865 | $(Q) mkdir -p `dirname $@` |
nnoble | 5b7f32a | 2014-12-22 08:12:44 -0800 | [diff] [blame] | 866 | $(Q) $(LD) $(LDFLAGS) $(${tgt.name.upper()}_OBJS)\ |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 867 | % endif |
| 868 | % for dep in tgt.deps: |
ctiller | cab52e7 | 2015-01-06 13:10:23 -0800 | [diff] [blame] | 869 | libs/$(CONFIG)/lib${dep}.a\ |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 870 | % endfor |
Craig Tiller | 59140fc | 2015-01-18 10:12:17 -0800 | [diff] [blame] | 871 | % if tgt.language == "c++": |
nnoble | 72309c6 | 2014-12-12 11:42:26 -0800 | [diff] [blame] | 872 | % if tgt.build == 'protoc': |
| 873 | $(HOST_LDLIBSXX)\ |
| 874 | % else: |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 875 | $(LDLIBSXX)\ |
| 876 | % endif |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 877 | % endif |
nnoble | c78b340 | 2014-12-11 16:06:57 -0800 | [diff] [blame] | 878 | % if tgt.build == 'protoc': |
nnoble | 72309c6 | 2014-12-12 11:42:26 -0800 | [diff] [blame] | 879 | $(HOST_LDLIBS)\ |
| 880 | % else: |
| 881 | $(LDLIBS)\ |
| 882 | % endif |
| 883 | % if tgt.build == 'protoc': |
| 884 | $(HOST_LDLIBS_PROTOC)\ |
| 885 | % elif tgt.get('secure', True): |
| 886 | $(LDLIBS_SECURE)\ |
nnoble | c78b340 | 2014-12-11 16:06:57 -0800 | [diff] [blame] | 887 | % endif |
ctiller | cab52e7 | 2015-01-06 13:10:23 -0800 | [diff] [blame] | 888 | -o bins/$(CONFIG)/${tgt.name} |
nnoble | 69ac39f | 2014-12-12 15:43:38 -0800 | [diff] [blame] | 889 | % if tgt.get('secure', True): |
| 890 | |
| 891 | endif |
| 892 | % endif |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 893 | |
Craig Tiller | f5371ef | 2015-01-12 16:40:18 -0800 | [diff] [blame] | 894 | % for src in tgt.src: |
| 895 | objs/$(CONFIG)/${os.path.splitext(src)[0]}.o: \ |
| 896 | % for dep in tgt.deps: |
| 897 | libs/$(CONFIG)/lib${dep}.a\ |
| 898 | % endfor |
| 899 | |
| 900 | % endfor |
| 901 | |
Craig Tiller | 8f126a6 | 2015-01-15 08:50:19 -0800 | [diff] [blame] | 902 | deps_${tgt.name}: $(${tgt.name.upper()}_OBJS:.o=.dep) |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 903 | |
nnoble | 69ac39f | 2014-12-12 15:43:38 -0800 | [diff] [blame] | 904 | % if tgt.get('secure', True): |
| 905 | ifneq ($(NO_SECURE),true) |
| 906 | % endif |
| 907 | ifneq ($(NO_DEPS),true) |
Craig Tiller | 8f126a6 | 2015-01-15 08:50:19 -0800 | [diff] [blame] | 908 | -include $(${tgt.name.upper()}_OBJS:.o=.dep) |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 909 | endif |
nnoble | 69ac39f | 2014-12-12 15:43:38 -0800 | [diff] [blame] | 910 | % if tgt.get('secure', True): |
| 911 | endif |
| 912 | % endif |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 913 | </%def> |
| 914 | |
nnoble | 85a4926 | 2014-12-08 18:14:03 -0800 | [diff] [blame] | 915 | .PHONY: all strip tools \ |
nnoble | 69ac39f | 2014-12-12 15:43:38 -0800 | [diff] [blame] | 916 | dep_error openssl_dep_error openssl_dep_message git_update stop \ |
nnoble | 85a4926 | 2014-12-08 18:14:03 -0800 | [diff] [blame] | 917 | buildtests buildtests_c buildtests_cxx \ |
| 918 | test test_c test_cxx \ |
| 919 | install install_c install_cxx \ |
| 920 | install-headers install-headers_c install-headers_cxx \ |
| 921 | install-shared install-shared_c install-shared_cxx \ |
| 922 | install-static install-static_c install-static_cxx \ |
| 923 | strip strip-shared strip-static \ |
| 924 | strip_c strip-shared_c strip-static_c \ |
| 925 | strip_cxx strip-shared_cxx strip-static_cxx \ |
Craig Tiller | f0afe50 | 2015-01-15 09:04:49 -0800 | [diff] [blame] | 926 | dep_c dep_cxx bins_dep_c bins_dep_cxx \ |
Craig Tiller | 12c8209 | 2015-01-15 08:45:56 -0800 | [diff] [blame] | 927 | clean |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 928 | |