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