blob: 32c2f18b07bdbc2e87bc0839f7b94022893634df [file] [log] [blame]
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001# GRPC global makefile
2# This currently builds C and C++ code.
3<%!
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08004 import re
Craig Tillerf5371ef2015-01-12 16:40:18 -08005 import os
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08006
nnoblec87b1c52015-01-05 17:15:18 -08007 proto_re = re.compile('(.*)\\.proto')
nnoble72309c62014-12-12 11:42:26 -08008
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08009 def excluded(filename, exclude_res):
10 for r in exclude_res:
11 if r.match(filename):
12 return True
13 return False
nnoble72309c62014-12-12 11:42:26 -080014
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 Nobleb7ebd3b2014-11-26 16:33:03 -080020%>
21
ctiller8cfebb92015-01-06 15:02:12 -080022# Configurations
23
24VALID_CONFIG_opt = 1
25CC_opt = gcc
26CXX_opt = g++
27LD_opt = gcc
28LDXX_opt = g++
29CPPFLAGS_opt = -O2
30LDFLAGS_opt =
31DEFINES_opt = NDEBUG
32
33VALID_CONFIG_dbg = 1
34CC_dbg = gcc
35CXX_dbg = g++
36LD_dbg = gcc
37LDXX_dbg = g++
38CPPFLAGS_dbg = -O0
39LDFLAGS_dbg =
40DEFINES_dbg = _DEBUG DEBUG
41
42VALID_CONFIG_tsan = 1
43CC_tsan = clang
44CXX_tsan = clang++
45LD_tsan = clang
46LDXX_tsan = clang++
47CPPFLAGS_tsan = -O1 -fsanitize=thread -fno-omit-frame-pointer
48LDFLAGS_tsan = -fsanitize=thread
49DEFINES_tsan = NDEBUG
50
51VALID_CONFIG_asan = 1
52CC_asan = clang
53CXX_asan = clang++
54LD_asan = clang
55LDXX_asan = clang++
56CPPFLAGS_asan = -O1 -fsanitize=address -fno-omit-frame-pointer
57LDFLAGS_asan = -fsanitize=address
58DEFINES_asan = NDEBUG
59
60VALID_CONFIG_msan = 1
61CC_msan = clang
62CXX_msan = clang++
63LD_msan = clang
64LDXX_msan = clang++
65CPPFLAGS_msan = -O1 -fsanitize=memory -fno-omit-frame-pointer
66LDFLAGS_msan = -fsanitize=memory
67DEFINES_msan = NDEBUG
68
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -080069# General settings.
70# You may want to change these depending on your system.
71
72prefix ?= /usr/local
73
74PROTOC = protoc
yangg102e4fe2015-01-06 16:02:50 -080075CONFIG ?= opt
ctiller8cfebb92015-01-06 15:02:12 -080076CC = $(CC_$(CONFIG))
77CXX = $(CXX_$(CONFIG))
78LD = $(LD_$(CONFIG))
79LDXX = $(LDXX_$(CONFIG))
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -080080AR = ar
81STRIP = strip --strip-unneeded
82INSTALL = install -D
83RM = rm -f
84
yangg102e4fe2015-01-06 16:02:50 -080085ifndef VALID_CONFIG_$(CONFIG)
86$(error Invalid CONFIG value '$(CONFIG)')
87endif
88
nnoble72309c62014-12-12 11:42:26 -080089HOST_CC = $(CC)
90HOST_CXX = $(CXX)
91HOST_LD = $(LD)
92HOST_LDXX = $(LDXX)
93
ctillercab52e72015-01-06 13:10:23 -080094CPPFLAGS += $(CPPFLAGS_$(CONFIG))
95DEFINES += $(DEFINES_$(CONFIG))
ctiller8cfebb92015-01-06 15:02:12 -080096LDFLAGS += $(LDFLAGS_$(CONFIG))
ctillercab52e72015-01-06 13:10:23 -080097
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -080098CFLAGS += -std=c89 -pedantic
99CXXFLAGS += -std=c++11
100CPPFLAGS += -g -fPIC -Wall -Werror -Wno-long-long
101LDFLAGS += -g -pthread -fPIC
102
103INCLUDES = . include gens
ctillerc008ae52015-01-07 15:33:00 -0800104LIBS = rt m z pthread
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800105LIBSXX = protobuf
nnoblec78b3402014-12-11 16:06:57 -0800106LIBS_PROTOC = protoc protobuf
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800107
108ifneq ($(wildcard /usr/src/gtest/src/gtest-all.cc),)
109GTEST_LIB = /usr/src/gtest/src/gtest-all.cc -I/usr/src/gtest
110else
111GTEST_LIB = -lgtest
112endif
chenwa8fd44a2014-12-10 15:13:55 -0800113GTEST_LIB += -lgflags
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800114ifeq ($(V),1)
115E = @:
116Q =
117else
118E = @echo
119Q = @
120endif
121
122VERSION = ${settings.version.major}.${settings.version.minor}.${settings.version.micro}.${settings.version.build}
123
124CPPFLAGS_NO_ARCH += $(addprefix -I, $(INCLUDES)) $(addprefix -D, $(DEFINES))
125CPPFLAGS += $(CPPFLAGS_NO_ARCH) $(ARCH_FLAGS)
126
127LDFLAGS += $(ARCH_FLAGS)
128LDLIBS += $(addprefix -l, $(LIBS))
129LDLIBSXX += $(addprefix -l, $(LIBSXX))
nnoble72309c62014-12-12 11:42:26 -0800130HOST_LDLIBS_PROTOC += $(addprefix -l, $(LIBS_PROTOC))
131
132HOST_CPPFLAGS = $(CPPFLAGS)
133HOST_CFLAGS = $(CFLAGS)
134HOST_CXXFLAGS = $(CXXFLAGS)
135HOST_LDFLAGS = $(LDFLAGS)
136HOST_LDLIBS = $(LDLIBS)
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800137
nnoble69ac39f2014-12-12 15:43:38 -0800138
139# These are automatically computed variables.
140# There shouldn't be any need to change anything from now on.
141
142HOST_SYSTEM = $(shell uname | cut -f 1 -d_)
143ifeq ($(SYSTEM),)
144SYSTEM = $(HOST_SYSTEM)
145endif
146
nnoble5b7f32a2014-12-22 08:12:44 -0800147ifeq ($(SYSTEM),MINGW32)
148SHARED_EXT = dll
149endif
150ifeq ($(SYSTEM),Darwin)
151SHARED_EXT = dylib
152endif
153ifeq ($(SHARED_EXT),)
154SHARED_EXT = so.$(VERSION)
155endif
156
nnoble69ac39f2014-12-12 15:43:38 -0800157ifeq ($(wildcard .git),)
158IS_GIT_FOLDER = false
159else
160IS_GIT_FOLDER = true
161endif
162
nnoble7e012cf2014-12-22 17:53:44 -0800163OPENSSL_ALPN_CHECK_CMD = $(CC) $(CFLAGS) $(CPPFLAGS) -o /dev/null test/build/openssl-alpn.c -lssl -lcrypto -ldl $(LDFLAGS)
164ZLIB_CHECK_CMD = $(CC) $(CFLAGS) $(CPPFLAGS) -o /dev/null test/build/zlib.c -lz $(LDFLAGS)
nnoble69ac39f2014-12-12 15:43:38 -0800165
nnoble60825402014-12-15 14:43:51 -0800166HAS_SYSTEM_OPENSSL_ALPN = $(shell $(OPENSSL_ALPN_CHECK_CMD) 2> /dev/null && echo true || echo false)
167HAS_SYSTEM_ZLIB = $(shell $(ZLIB_CHECK_CMD) 2> /dev/null && echo true || echo false)
nnoble69ac39f2014-12-12 15:43:38 -0800168
nnoble69ac39f2014-12-12 15:43:38 -0800169ifeq ($(wildcard third_party/openssl/ssl/ssl.h),)
170HAS_EMBEDDED_OPENSSL_ALPN = false
171else
172HAS_EMBEDDED_OPENSSL_ALPN = true
173endif
174
175ifeq ($(wildcard third_party/zlib/zlib.h),)
176HAS_EMBEDDED_ZLIB = false
177else
178HAS_EMBEDDED_ZLIB = true
179endif
180
nnoble69ac39f2014-12-12 15:43:38 -0800181ifeq ($(HAS_SYSTEM_ZLIB),false)
182ifeq ($(HAS_EMBEDDED_ZLIB),true)
183ZLIB_DEP = third_party/zlib/libz.a
184CPPFLAGS += -Ithird_party/zlib
185LDFLAGS += -Lthird_party/zlib
186else
187DEP_MISSING += zlib
188endif
189endif
190
191ifeq ($(HAS_SYSTEM_OPENSSL_ALPN),false)
192ifeq ($(HAS_EMBEDDED_OPENSSL_ALPN),true)
193OPENSSL_DEP = third_party/openssl/libssl.a
nnoble20e2e3f2014-12-16 15:37:57 -0800194OPENSSL_MERGE_LIBS += third_party/openssl/libssl.a third_party/openssl/libcrypto.a
nnoble69ac39f2014-12-12 15:43:38 -0800195CPPFLAGS += -Ithird_party/openssl/include
196LDFLAGS += -Lthird_party/openssl
nnoble5b7f32a2014-12-22 08:12:44 -0800197LIBS_SECURE = dl
nnoble69ac39f2014-12-12 15:43:38 -0800198else
199NO_SECURE = true
200endif
nnoble5b7f32a2014-12-22 08:12:44 -0800201else
202LIBS_SECURE = ssl crypto dl
nnoble69ac39f2014-12-12 15:43:38 -0800203endif
204
nnoble5b7f32a2014-12-22 08:12:44 -0800205LDLIBS_SECURE += $(addprefix -l, $(LIBS_SECURE))
206
nnoble69ac39f2014-12-12 15:43:38 -0800207ifneq ($(DEP_MISSING),)
208NO_DEPS = true
209endif
210
211ifneq ($(MAKECMDGOALS),clean)
212NO_DEPS = true
213endif
214
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800215.SECONDARY = %.pb.h %.pb.cc
216
nnoble69ac39f2014-12-12 15:43:38 -0800217ifeq ($(DEP_MISSING),)
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800218all: static shared\
219% for tgt in targets:
220% if tgt.build == 'all':
ctillercab52e72015-01-06 13:10:23 -0800221 bins/$(CONFIG)/${tgt.name}\
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800222% endif
223% endfor
224
nnoble69ac39f2014-12-12 15:43:38 -0800225dep_error:
226 @echo "You shouldn't see this message - all of your dependencies are correct."
227else
228all: dep_error git_update stop
229
230dep_error:
231 @echo
232 @echo "DEPENDENCY ERROR"
233 @echo
234 @echo "You are missing system dependencies that are essential to build grpc,"
235 @echo "and the third_party directory doesn't have them:"
236 @echo
237 @echo " $(DEP_MISSING)"
238 @echo
239 @echo "Installing the development packages for your system will solve"
240 @echo "this issue. Please consult INSTALL to get more information."
241 @echo
242 @echo "If you need information about why these tests failed, run:"
243 @echo
244 @echo " make run_dep_checks"
245 @echo
246endif
247
248git_update:
249ifeq ($(IS_GIT_FOLDER),true)
250 @echo "Additionally, since you are in a git clone, you can download the"
251 @echo "missing dependencies in third_party by running the following command:"
252 @echo
ctiller64f29102014-12-15 10:40:59 -0800253 @echo " git submodule update --init"
nnoble69ac39f2014-12-12 15:43:38 -0800254 @echo
255endif
256
257openssl_dep_error: openssl_dep_message git_update stop
258
259openssl_dep_message:
260 @echo
261 @echo "DEPENDENCY ERROR"
262 @echo
263 @echo "The target you are trying to run requires OpenSSL with ALPN support."
264 @echo "Your system doesn't have it, and neither does the third_party directory."
265 @echo
266 @echo "Please consult INSTALL to get more information."
267 @echo
268 @echo "If you need information about why these tests failed, run:"
269 @echo
270 @echo " make run_dep_checks"
271 @echo
272
273stop:
274 @false
275
ctiller09cb6d52014-12-19 17:38:22 -0800276% for tgt in targets:
ctillercab52e72015-01-06 13:10:23 -0800277${tgt.name}: bins/$(CONFIG)/${tgt.name}
ctiller09cb6d52014-12-19 17:38:22 -0800278% endfor
279
nnoble69ac39f2014-12-12 15:43:38 -0800280run_dep_checks:
nnoble69ac39f2014-12-12 15:43:38 -0800281 $(OPENSSL_ALPN_CHECK_CMD) || true
282 $(ZLIB_CHECK_CMD) || true
283
284third_party/zlib/libz.a:
285 (cd third_party/zlib ; CFLAGS="-fPIC -fvisibility=hidden" ./configure --static)
286 $(MAKE) -C third_party/zlib
287
288third_party/openssl/libssl.a:
289 (cd third_party/openssl ; CC="$(CC) -fPIC -fvisibility=hidden" ./config)
290 $(MAKE) -C third_party/openssl build_crypto build_ssl
291
nnoble29e1d292014-12-01 10:27:40 -0800292static: static_c static_cxx
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800293
nnoble85a49262014-12-08 18:14:03 -0800294static_c: dep_c\
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800295% for lib in libs:
nnoble29e1d292014-12-01 10:27:40 -0800296% if lib.build == 'all' and not lib.get('c++', False):
ctillercab52e72015-01-06 13:10:23 -0800297 libs/$(CONFIG)/lib${lib.name}.a\
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800298% endif
299% endfor
300
301
nnoble85a49262014-12-08 18:14:03 -0800302static_cxx: dep_cxx\
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800303% for lib in libs:
nnoble29e1d292014-12-01 10:27:40 -0800304% if lib.build == 'all' and lib.get('c++', False):
ctillercab52e72015-01-06 13:10:23 -0800305 libs/$(CONFIG)/lib${lib.name}.a\
nnoble29e1d292014-12-01 10:27:40 -0800306% endif
307% endfor
308
309
310shared: shared_c shared_cxx
311
nnoble85a49262014-12-08 18:14:03 -0800312shared_c: dep_c\
nnoble29e1d292014-12-01 10:27:40 -0800313% for lib in libs:
314% if lib.build == 'all' and not lib.get('c++', False):
ctillercab52e72015-01-06 13:10:23 -0800315 libs/$(CONFIG)/lib${lib.name}.$(SHARED_EXT)\
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800316% endif
317% endfor
318
319
nnoble85a49262014-12-08 18:14:03 -0800320shared_cxx: dep_cxx\
nnoble29e1d292014-12-01 10:27:40 -0800321% for lib in libs:
322% if lib.build == 'all' and lib.get('c++', False):
ctillercab52e72015-01-06 13:10:23 -0800323 libs/$(CONFIG)/lib${lib.name}.$(SHARED_EXT)\
nnoble29e1d292014-12-01 10:27:40 -0800324% endif
325% endfor
326
327
328privatelibs: privatelibs_c privatelibs_cxx
329
nnoble85a49262014-12-08 18:14:03 -0800330privatelibs_c: dep_c\
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800331% for lib in libs:
332% if lib.build == 'private':
ctillercab52e72015-01-06 13:10:23 -0800333 libs/$(CONFIG)/lib${lib.name}.a\
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800334% endif
335% endfor
336
337
nnoble85a49262014-12-08 18:14:03 -0800338privatelibs_cxx: dep_cxx\
nnoble29e1d292014-12-01 10:27:40 -0800339% for lib in libs:
340% if lib.build == 'private':
ctillercab52e72015-01-06 13:10:23 -0800341 libs/$(CONFIG)/lib${lib.name}.a\
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800342% endif
343% endfor
344
345
nnoble29e1d292014-12-01 10:27:40 -0800346buildtests: buildtests_c buildtests_cxx
347
nnoblebba76922014-12-15 13:27:38 -0800348buildtests_c: bins_dep_c privatelibs_c\
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800349% for tgt in targets:
350% if tgt.build == 'test' and not tgt.get('c++', False):
ctillercab52e72015-01-06 13:10:23 -0800351 bins/$(CONFIG)/${tgt.name}\
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800352% endif
353% endfor
354
355
nnoblebba76922014-12-15 13:27:38 -0800356buildtests_cxx: bins_dep_cxx privatelibs_cxx\
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800357% for tgt in targets:
nnoble29e1d292014-12-01 10:27:40 -0800358% if tgt.build == 'test' and tgt.get('c++', False):
Craig Tillerf5371ef2015-01-12 16:40:18 -0800359 bins/$(CONFIG)/${tgt.name}\
nnoble29e1d292014-12-01 10:27:40 -0800360% endif
361% endfor
362
363
nnoble85a49262014-12-08 18:14:03 -0800364test: test_c test_cxx
nnoble29e1d292014-12-01 10:27:40 -0800365
nnoble85a49262014-12-08 18:14:03 -0800366test_c: buildtests_c
nnoble29e1d292014-12-01 10:27:40 -0800367% for tgt in targets:
368% if tgt.build == 'test' and tgt.get('run', True) and not tgt.get('c++', False):
369 $(E) "[RUN] Testing ${tgt.name}"
ctillercab52e72015-01-06 13:10:23 -0800370 $(Q) ./bins/$(CONFIG)/${tgt.name} || ( echo test ${tgt.name} failed ; exit 1 )
nnoble29e1d292014-12-01 10:27:40 -0800371% endif
372% endfor
373
374
nnoble85a49262014-12-08 18:14:03 -0800375test_cxx: buildtests_cxx
nnoble29e1d292014-12-01 10:27:40 -0800376% for tgt in targets:
377% if tgt.build == 'test' and tgt.get('run', True) and tgt.get('c++', False):
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800378 $(E) "[RUN] Testing ${tgt.name}"
ctillercab52e72015-01-06 13:10:23 -0800379 $(Q) ./bins/$(CONFIG)/${tgt.name} || ( echo test ${tgt.name} failed ; exit 1 )
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800380% endif
381% endfor
382
383
384tools: privatelibs\
385% for tgt in targets:
386% if tgt.build == 'tool':
ctillercab52e72015-01-06 13:10:23 -0800387 bins/$(CONFIG)/${tgt.name}\
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800388% endif
389% endfor
390
391
nnobleebebb7e2014-12-10 16:31:01 -0800392protoc_plugins:\
393% for tgt in targets:
394% if tgt.build == 'protoc':
ctillercab52e72015-01-06 13:10:23 -0800395 bins/$(CONFIG)/${tgt.name}\
nnobleebebb7e2014-12-10 16:31:01 -0800396% endif
397% endfor
398
399
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800400buildbenchmarks: privatelibs\
401% for tgt in targets:
402% if tgt.build == 'benchmark':
ctillercab52e72015-01-06 13:10:23 -0800403 bins/$(CONFIG)/${tgt.name}\
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800404% endif
405% endfor
406
407
408benchmarks: buildbenchmarks
409
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800410strip: strip-static strip-shared
411
nnoble20e2e3f2014-12-16 15:37:57 -0800412strip-static: strip-static_c strip-static_cxx
413
414strip-shared: strip-shared_c strip-shared_cxx
415
nnoble85a49262014-12-08 18:14:03 -0800416strip-static_c: static_c
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800417% for lib in libs:
nnoble85a49262014-12-08 18:14:03 -0800418% if not lib.get("c++", False):
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800419% if lib.build == "all":
420 $(E) "[STRIP] Stripping lib${lib.name}.a"
ctillercab52e72015-01-06 13:10:23 -0800421 $(Q) $(STRIP) libs/$(CONFIG)/lib${lib.name}.a
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800422% endif
nnoble85a49262014-12-08 18:14:03 -0800423% endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800424% endfor
425
nnoble85a49262014-12-08 18:14:03 -0800426strip-static_cxx: static_cxx
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800427% for lib in libs:
nnoble85a49262014-12-08 18:14:03 -0800428% if lib.get("c++", False):
429% if lib.build == "all":
430 $(E) "[STRIP] Stripping lib${lib.name}.a"
ctillercab52e72015-01-06 13:10:23 -0800431 $(Q) $(STRIP) libs/$(CONFIG)/lib${lib.name}.a
nnoble85a49262014-12-08 18:14:03 -0800432% endif
433% endif
434% endfor
435
436strip-shared_c: shared_c
437% for lib in libs:
438% if not lib.get("c++", False):
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800439% if lib.build == "all":
440 $(E) "[STRIP] Stripping lib${lib.name}.so"
ctillercab52e72015-01-06 13:10:23 -0800441 $(Q) $(STRIP) libs/$(CONFIG)/lib${lib.name}.$(SHARED_EXT)
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800442% endif
nnoble85a49262014-12-08 18:14:03 -0800443% endif
444% endfor
445
446strip-shared_cxx: shared_cxx
447% for lib in libs:
448% if lib.get("c++", False):
449% if lib.build == "all":
450 $(E) "[STRIP] Stripping lib${lib.name}.so"
ctillercab52e72015-01-06 13:10:23 -0800451 $(Q) $(STRIP) libs/$(CONFIG)/lib${lib.name}.$(SHARED_EXT)
nnoble85a49262014-12-08 18:14:03 -0800452% endif
453% endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800454% endfor
455
nnoble72309c62014-12-12 11:42:26 -0800456% for p in protos:
ctillercab52e72015-01-06 13:10:23 -0800457deps/$(CONFIG)/gens/${p}.pb.dep:
nnoble72309c62014-12-12 11:42:26 -0800458 $(Q) mkdir -p `dirname $@`
459 $(Q) touch $@
460
461gens/${p}.pb.cc: ${p}.proto protoc_plugins
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800462 $(E) "[PROTOC] Generating protobuf CC file from $<"
463 $(Q) mkdir -p `dirname $@`
ctillercab52e72015-01-06 13:10:23 -0800464 $(Q) $(PROTOC) --cpp_out=gens --grpc_out=gens --plugin=protoc-gen-grpc=bins/$(CONFIG)/cpp_plugin $<
nnoble72309c62014-12-12 11:42:26 -0800465
466% endfor
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800467
ctillercab52e72015-01-06 13:10:23 -0800468deps/$(CONFIG)/%.dep : %.c
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800469 $(E) "[DEP] Generating dependencies for $<"
470 $(Q) mkdir -p `dirname $@`
471 $(Q) $(CC) $(CFLAGS) $(CPPFLAGS_NO_ARCH) -MG -M $< > $@
472
ctillercab52e72015-01-06 13:10:23 -0800473deps/$(CONFIG)/%.dep : %.cc
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800474 $(E) "[DEP] Generating dependencies for $<"
475 $(Q) mkdir -p `dirname $@`
476 $(Q) $(CXX) $(CXXFLAGS) $(CPPFLAGS_NO_ARCH) -MG -M $< > $@
477
ctillercab52e72015-01-06 13:10:23 -0800478objs/$(CONFIG)/%.o : %.c
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800479 $(E) "[C] Compiling $<"
480 $(Q) mkdir -p `dirname $@`
481 $(Q) $(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $<
482
ctillercab52e72015-01-06 13:10:23 -0800483objs/$(CONFIG)/%.o : gens/%.pb.cc
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800484 $(E) "[CXX] Compiling $<"
485 $(Q) mkdir -p `dirname $@`
486 $(Q) $(CXX) $(CXXFLAGS) $(CPPFLAGS) -c -o $@ $<
487
ctillercab52e72015-01-06 13:10:23 -0800488objs/$(CONFIG)/src/compiler/%.o : src/compiler/%.cc
nnoble72309c62014-12-12 11:42:26 -0800489 $(E) "[HOSTCXX] Compiling $<"
490 $(Q) mkdir -p `dirname $@`
491 $(Q) $(HOST_CXX) $(HOST_CXXFLAGS) $(HOST_CPPFLAGS) -c -o $@ $<
492
ctillercab52e72015-01-06 13:10:23 -0800493objs/$(CONFIG)/%.o : %.cc
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800494 $(E) "[CXX] Compiling $<"
495 $(Q) mkdir -p `dirname $@`
496 $(Q) $(CXX) $(CXXFLAGS) $(CPPFLAGS) -c -o $@ $<
497
nnoble0c475f02014-12-05 15:37:39 -0800498dep: dep_c dep_cxx
499
500dep_c:\
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800501% for lib in libs:
nnoble0c475f02014-12-05 15:37:39 -0800502% if not lib.get('c++', False):
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800503 deps_lib${lib.name}\
nnoble0c475f02014-12-05 15:37:39 -0800504% endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800505% endfor
nnoble69ac39f2014-12-12 15:43:38 -0800506
507
508bins_dep_c:\
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800509% for tgt in targets:
nnoble0c475f02014-12-05 15:37:39 -0800510% if not tgt.get('c++', False):
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800511 deps_${tgt.name}\
nnoble0c475f02014-12-05 15:37:39 -0800512% endif
513% endfor
514
515
516dep_cxx:\
517% for lib in libs:
518% if lib.get('c++', False):
519 deps_lib${lib.name}\
520% endif
521% endfor
nnoble69ac39f2014-12-12 15:43:38 -0800522
523
524bins_dep_cxx:\
nnoble0c475f02014-12-05 15:37:39 -0800525% for tgt in targets:
526% if tgt.get('c++', False):
527 deps_${tgt.name}\
528% endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800529% endfor
530
531
nnoble85a49262014-12-08 18:14:03 -0800532install: install_c install_cxx
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800533
nnoble85a49262014-12-08 18:14:03 -0800534install_c: install-headers_c install-static_c install-shared_c
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800535
nnoble85a49262014-12-08 18:14:03 -0800536install_cxx: install-headers_cxx install-static_cxx install-shared_cxx
537
538install-headers: install-headers_c install-headers_cxx
539
540install-headers_c:
541 $(E) "[INSTALL] Installing public C headers"
542 $(Q) $(foreach h, $(PUBLIC_HEADERS_C), $(INSTALL) $(h) $(prefix)/$(h) && ) exit 0 || exit 1
543
544install-headers_cxx:
545 $(E) "[INSTALL] Installing public C++ headers"
546 $(Q) $(foreach h, $(PUBLIC_HEADERS_CXX), $(INSTALL) $(h) $(prefix)/$(h) && ) exit 0 || exit 1
547
548install-static: install-static_c install-static_cxx
549
550install-static_c: static_c strip-static_c
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800551% for lib in libs:
nnoble85a49262014-12-08 18:14:03 -0800552% if not lib.get("c++", False):
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800553% if lib.build == "all":
554 $(E) "[INSTALL] Installing lib${lib.name}.a"
ctillercab52e72015-01-06 13:10:23 -0800555 $(Q) $(INSTALL) libs/$(CONFIG)/lib${lib.name}.a $(prefix)/lib/lib${lib.name}.a
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800556% endif
nnoble85a49262014-12-08 18:14:03 -0800557% endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800558% endfor
559
nnoble85a49262014-12-08 18:14:03 -0800560install-static_cxx: static_cxx strip-static_cxx
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800561% for lib in libs:
nnoble85a49262014-12-08 18:14:03 -0800562% if lib.get("c++", False):
563% if lib.build == "all":
564 $(E) "[INSTALL] Installing lib${lib.name}.a"
ctillercab52e72015-01-06 13:10:23 -0800565 $(Q) $(INSTALL) libs/$(CONFIG)/lib${lib.name}.a $(prefix)/lib/lib${lib.name}.a
nnoble85a49262014-12-08 18:14:03 -0800566% endif
567% endif
568% endfor
569
570install-shared_c: shared_c strip-shared_c
571% for lib in libs:
572% if not lib.get("c++", False):
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800573% if lib.build == "all":
nnoble5b7f32a2014-12-22 08:12:44 -0800574ifeq ($(SYSTEM),MINGW32)
575 $(E) "[INSTALL] Installing ${lib.name}.$(SHARED_EXT)"
ctillercab52e72015-01-06 13:10:23 -0800576 $(Q) $(INSTALL) libs/$(CONFIG)/${lib.name}.$(SHARED_EXT) $(prefix)/lib/${lib.name}.$(SHARED_EXT)
577 $(Q) $(INSTALL) libs/$(CONFIG)/lib${lib.name}-imp.a $(prefix)/lib/lib${lib.name}-imp.a
nnoble5b7f32a2014-12-22 08:12:44 -0800578else
579 $(E) "[INSTALL] Installing lib${lib.name}.$(SHARED_EXT)"
ctillercab52e72015-01-06 13:10:23 -0800580 $(Q) $(INSTALL) libs/$(CONFIG)/lib${lib.name}.$(SHARED_EXT) $(prefix)/lib/lib${lib.name}.$(SHARED_EXT)
nnoble5b7f32a2014-12-22 08:12:44 -0800581ifneq ($(SYSTEM),Darwin)
582 $(Q) ln -sf lib${lib.name}.$(SHARED_EXT) $(prefix)/lib/lib${lib.name}.so
583endif
584endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800585% endif
nnoble85a49262014-12-08 18:14:03 -0800586% endif
587% endfor
nnoble5b7f32a2014-12-22 08:12:44 -0800588ifneq ($(SYSTEM),MINGW32)
589ifneq ($(SYSTEM),Darwin)
590 $(Q) ldconfig
591endif
592endif
nnoble85a49262014-12-08 18:14:03 -0800593
594install-shared_cxx: shared_cxx strip-shared_cxx
595% for lib in libs:
596% if lib.get("c++", False):
597% if lib.build == "all":
nnoble5b7f32a2014-12-22 08:12:44 -0800598ifeq ($(SYSTEM),MINGW32)
599 $(E) "[INSTALL] Installing ${lib.name}.$(SHARED_EXT)"
ctillercab52e72015-01-06 13:10:23 -0800600 $(Q) $(INSTALL) libs/$(CONFIG)/${lib.name}.$(SHARED_EXT) $(prefix)/lib/${lib.name}.$(SHARED_EXT)
601 $(Q) $(INSTALL) libs/$(CONFIG)/lib${lib.name}-imp.a $(prefix)/lib/lib${lib.name}-imp.a
nnoble5b7f32a2014-12-22 08:12:44 -0800602else
603 $(E) "[INSTALL] Installing lib${lib.name}.$(SHARED_EXT)"
ctillercab52e72015-01-06 13:10:23 -0800604 $(Q) $(INSTALL) libs/$(CONFIG)/lib${lib.name}.$(SHARED_EXT) $(prefix)/lib/lib${lib.name}.$(SHARED_EXT)
nnoble5b7f32a2014-12-22 08:12:44 -0800605ifneq ($(SYSTEM),Darwin)
606 $(Q) ln -sf lib${lib.name}.$(SHARED_EXT) $(prefix)/lib/lib${lib.name}.so
607endif
608endif
nnoble85a49262014-12-08 18:14:03 -0800609% endif
610% endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800611% endfor
nnoble5b7f32a2014-12-22 08:12:44 -0800612ifneq ($(SYSTEM),MINGW32)
613ifneq ($(SYSTEM),Darwin)
614 $(Q) ldconfig
615endif
616endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800617
618clean:\
619% for lib in libs:
620 clean_lib${lib.name}\
621% endfor
622% for tgt in targets:
623 clean_${tgt.name}\
624% endfor
625
626 $(Q) $(RM) -r deps objs libs bins gens
627
628
629# The various libraries
630
631% for lib in libs:
632${makelib(lib)}
633% endfor
634
635
nnoble69ac39f2014-12-12 15:43:38 -0800636# All of the test targets, and protoc plugins
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800637
638% for tgt in targets:
639${maketarget(tgt)}
640% endfor
641
642<%def name="makelib(lib)">
643LIB${lib.name.upper()}_SRC = \\
644
645% for src in lib.src:
nnoble72309c62014-12-12 11:42:26 -0800646 ${proto_to_cc(src)} \\
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800647
648% endfor
649
650% if "public_headers" in lib:
nnoble85a49262014-12-08 18:14:03 -0800651% if lib.get("c++", False):
652PUBLIC_HEADERS_CXX += \\
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800653
nnoble85a49262014-12-08 18:14:03 -0800654% else:
655PUBLIC_HEADERS_C += \\
656
657% endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800658% for hdr in lib.public_headers:
659 ${hdr} \\
660
661% endfor
662% endif
663
ctillercab52e72015-01-06 13:10:23 -0800664LIB${lib.name.upper()}_OBJS = $(addprefix objs/$(CONFIG)/, $(addsuffix .o, $(basename $(LIB${lib.name.upper()}_SRC))))
665LIB${lib.name.upper()}_DEPS = $(addprefix deps/$(CONFIG)/, $(addsuffix .dep, $(basename $(LIB${lib.name.upper()}_SRC))))
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800666
nnoble69ac39f2014-12-12 15:43:38 -0800667% if lib.get('secure', True):
nnoble69ac39f2014-12-12 15:43:38 -0800668ifeq ($(NO_SECURE),true)
669
ctillercab52e72015-01-06 13:10:23 -0800670libs/$(CONFIG)/lib${lib.name}.a: openssl_dep_error
nnoble69ac39f2014-12-12 15:43:38 -0800671
nnoble5b7f32a2014-12-22 08:12:44 -0800672% if lib.build == "all":
673ifeq ($(SYSTEM),MINGW32)
ctillercab52e72015-01-06 13:10:23 -0800674libs/$(CONFIG)/${lib.name}.$(SHARED_EXT): openssl_dep_error
nnoble5b7f32a2014-12-22 08:12:44 -0800675else
ctillercab52e72015-01-06 13:10:23 -0800676libs/$(CONFIG)/lib${lib.name}.$(SHARED_EXT): openssl_dep_error
nnoble5b7f32a2014-12-22 08:12:44 -0800677endif
678% endif
679
nnoble69ac39f2014-12-12 15:43:38 -0800680else
681
ctillercab52e72015-01-06 13:10:23 -0800682libs/$(CONFIG)/lib${lib.name}.a: $(OPENSSL_DEP) $(LIB${lib.name.upper()}_OBJS)
nnoble20e2e3f2014-12-16 15:37:57 -0800683% else:
ctillercab52e72015-01-06 13:10:23 -0800684libs/$(CONFIG)/lib${lib.name}.a: $(LIB${lib.name.upper()}_OBJS)
nnoble20e2e3f2014-12-16 15:37:57 -0800685% endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800686 $(E) "[AR] Creating $@"
nnoble85a49262014-12-08 18:14:03 -0800687 $(Q) mkdir -p `dirname $@`
ctillercab52e72015-01-06 13:10:23 -0800688 $(Q) $(AR) rcs libs/$(CONFIG)/lib${lib.name}.a $(LIB${lib.name.upper()}_OBJS)
nnoble20e2e3f2014-12-16 15:37:57 -0800689% if lib.get('baselib', False):
690% if lib.get('secure', True):
Craig Tillerf5371ef2015-01-12 16:40:18 -0800691 $(Q) rm -rf tmp-merge
nnoble20e2e3f2014-12-16 15:37:57 -0800692 $(Q) mkdir tmp-merge
ctillercab52e72015-01-06 13:10:23 -0800693 $(Q) ( cd tmp-merge ; $(AR) x ../libs/$(CONFIG)/lib${lib.name}.a )
nnoble20e2e3f2014-12-16 15:37:57 -0800694 $(Q) for l in $(OPENSSL_MERGE_LIBS) ; do ( cd tmp-merge ; <%text>ar x ../$${l}</%text> ) ; done
ctillercab52e72015-01-06 13:10:23 -0800695 $(Q) rm -f libs/$(CONFIG)/lib${lib.name}.a tmp-merge/__.SYMDEF*
696 $(Q) ar rcs libs/$(CONFIG)/lib${lib.name}.a tmp-merge/*
nnoble20e2e3f2014-12-16 15:37:57 -0800697 $(Q) rm -rf tmp-merge
698% endif
699% endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800700
nnoble5b7f32a2014-12-22 08:12:44 -0800701<%
702 if lib.get('c++', False):
703 ld = '$(LDXX)'
704 else:
705 ld = '$(LD)'
706
ctillercab52e72015-01-06 13:10:23 -0800707 out_base = 'libs/$(CONFIG)/' + lib.name
708 out_libbase = 'libs/$(CONFIG)/lib' + lib.name
nnoble5b7f32a2014-12-22 08:12:44 -0800709
710 common = '$(LIB' + lib.name.upper() + '_OBJS) $(LDLIBS)'
711
712 libs = ''
713 lib_deps = ''
714 mingw_libs = ''
715 mingw_lib_deps = ''
716 for dep in lib.get('deps', []):
717 libs = libs + ' -l' + dep
ctillercab52e72015-01-06 13:10:23 -0800718 lib_deps = lib_deps + 'libs/$(CONFIG)/lib' + dep + '.$(SHARED_EXT)'
nnoble5b7f32a2014-12-22 08:12:44 -0800719 mingw_libs = mingw_libs + ' -l' + dep + '-imp'
ctillercab52e72015-01-06 13:10:23 -0800720 mingw_lib_deps = mingw_lib_deps + 'libs/$(CONFIG)/' + dep + '.$(SHARED_EXT)'
nnoble5b7f32a2014-12-22 08:12:44 -0800721
722 if lib.get('secure', True):
723 common = common + ' $(LDLIBS_SECURE) $(OPENSSL_MERGE_LIBS)'
724 lib_deps = lib_deps + ' $(OPENSSL_DEP)'
725 mingw_lib_deps = mingw_lib_deps + ' $(OPENSSL_DEP)'
726
727%>
728
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800729% if lib.build == "all":
nnoble5b7f32a2014-12-22 08:12:44 -0800730ifeq ($(SYSTEM),MINGW32)
731${out_base}.$(SHARED_EXT): $(LIB${lib.name.upper()}_OBJS) ${mingw_lib_deps}
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800732 $(E) "[LD] Linking $@"
nnoble85a49262014-12-08 18:14:03 -0800733 $(Q) mkdir -p `dirname $@`
ctillercab52e72015-01-06 13:10:23 -0800734 $(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}
nnoble5b7f32a2014-12-22 08:12:44 -0800735else
736${out_libbase}.$(SHARED_EXT): $(LIB${lib.name.upper()}_OBJS) ${lib_deps}
737 $(E) "[LD] Linking $@"
738 $(Q) mkdir -p `dirname $@`
739ifeq ($(SYSTEM),Darwin)
ctillercab52e72015-01-06 13:10:23 -0800740 $(Q) ${ld} $(LDFLAGS) -Llibs/$(CONFIG) -dynamiclib -o ${out_libbase}.$(SHARED_EXT) ${common}${libs}
nnoble5b7f32a2014-12-22 08:12:44 -0800741else
ctillercab52e72015-01-06 13:10:23 -0800742 $(Q) ${ld} $(LDFLAGS) -Llibs/$(CONFIG) -shared -Wl,-soname,lib${lib.name}.so.${settings.version.major} -o ${out_libbase}.$(SHARED_EXT) ${common}${libs}
nnoble5b7f32a2014-12-22 08:12:44 -0800743 $(Q) ln -sf lib${lib.name}.$(SHARED_EXT) ${out_libbase}.so
744endif
745endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800746% endif
747
nnoble69ac39f2014-12-12 15:43:38 -0800748% if lib.get('secure', True):
749
750endif
751% endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800752
753deps_lib${lib.name}: $(LIB${lib.name.upper()}_DEPS)
754
nnoble69ac39f2014-12-12 15:43:38 -0800755% if lib.get('secure', True):
756ifneq ($(NO_SECURE),true)
757% endif
758ifneq ($(NO_DEPS),true)
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800759-include $(LIB${lib.name.upper()}_DEPS)
760endif
nnoble69ac39f2014-12-12 15:43:38 -0800761% if lib.get('secure', True):
762endif
763% endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800764
765clean_lib${lib.name}:
766 $(E) "[CLEAN] Cleaning lib${lib.name} files"
767 $(Q) $(RM) $(LIB${lib.name.upper()}_OBJS)
768 $(Q) $(RM) $(LIB${lib.name.upper()}_DEPS)
ctillercab52e72015-01-06 13:10:23 -0800769 $(Q) $(RM) libs/$(CONFIG)/lib${lib.name}.a
770 $(Q) $(RM) libs/$(CONFIG)/lib${lib.name}.$(SHARED_EXT)
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800771</%def>
772
773<%def name="maketarget(tgt)">
774${tgt.name.upper()}_SRC = \\
775
776% for src in tgt.src:
nnoble72309c62014-12-12 11:42:26 -0800777 ${proto_to_cc(src)} \\
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800778
779% endfor
780
ctillercab52e72015-01-06 13:10:23 -0800781${tgt.name.upper()}_OBJS = $(addprefix objs/$(CONFIG)/, $(addsuffix .o, $(basename $(${tgt.name.upper()}_SRC))))
782${tgt.name.upper()}_DEPS = $(addprefix deps/$(CONFIG)/, $(addsuffix .dep, $(basename $(${tgt.name.upper()}_SRC))))
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800783
nnoble69ac39f2014-12-12 15:43:38 -0800784% if tgt.get('secure', True):
785ifeq ($(NO_SECURE),true)
786
ctillercab52e72015-01-06 13:10:23 -0800787bins/$(CONFIG)/${tgt.name}: openssl_dep_error
nnoble69ac39f2014-12-12 15:43:38 -0800788
789else
790
791% endif
ctillercab52e72015-01-06 13:10:23 -0800792bins/$(CONFIG)/${tgt.name}: $(${tgt.name.upper()}_OBJS)\
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800793% for dep in tgt.deps:
ctillercab52e72015-01-06 13:10:23 -0800794 libs/$(CONFIG)/lib${dep}.a\
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800795% endfor
796
nnoble72309c62014-12-12 11:42:26 -0800797% if tgt.get("c++", False):
798% if tgt.build == 'protoc':
799 $(E) "[HOSTLD] Linking $@"
800 $(Q) mkdir -p `dirname $@`
801 $(Q) $(HOST_LDXX) $(HOST_LDFLAGS) $(${tgt.name.upper()}_OBJS)\
802% else:
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800803 $(E) "[LD] Linking $@"
nnoble85a49262014-12-08 18:14:03 -0800804 $(Q) mkdir -p `dirname $@`
nnoblec78b3402014-12-11 16:06:57 -0800805 $(Q) $(LDXX) $(LDFLAGS) $(${tgt.name.upper()}_OBJS)\
nnoble72309c62014-12-12 11:42:26 -0800806% endif
nnoblec78b3402014-12-11 16:06:57 -0800807% if tgt.build == 'test':
808 $(GTEST_LIB)\
809% endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800810% else:
nnoble72309c62014-12-12 11:42:26 -0800811 $(E) "[LD] Linking $@"
812 $(Q) mkdir -p `dirname $@`
nnoble5b7f32a2014-12-22 08:12:44 -0800813 $(Q) $(LD) $(LDFLAGS) $(${tgt.name.upper()}_OBJS)\
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800814% endif
815% for dep in tgt.deps:
ctillercab52e72015-01-06 13:10:23 -0800816 libs/$(CONFIG)/lib${dep}.a\
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800817% endfor
818% if tgt.get("c++", False):
nnoble72309c62014-12-12 11:42:26 -0800819% if tgt.build == 'protoc':
820 $(HOST_LDLIBSXX)\
821% else:
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800822 $(LDLIBSXX)\
823% endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800824% endif
nnoblec78b3402014-12-11 16:06:57 -0800825% if tgt.build == 'protoc':
nnoble72309c62014-12-12 11:42:26 -0800826 $(HOST_LDLIBS)\
827% else:
828 $(LDLIBS)\
829% endif
830% if tgt.build == 'protoc':
831 $(HOST_LDLIBS_PROTOC)\
832% elif tgt.get('secure', True):
833 $(LDLIBS_SECURE)\
nnoblec78b3402014-12-11 16:06:57 -0800834% endif
ctillercab52e72015-01-06 13:10:23 -0800835 -o bins/$(CONFIG)/${tgt.name}
nnoble69ac39f2014-12-12 15:43:38 -0800836% if tgt.get('secure', True):
837
838endif
839% endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800840
Craig Tillerf5371ef2015-01-12 16:40:18 -0800841% for src in tgt.src:
842objs/$(CONFIG)/${os.path.splitext(src)[0]}.o: \
843% for dep in tgt.deps:
844 libs/$(CONFIG)/lib${dep}.a\
845% endfor
846
847% endfor
848
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800849deps_${tgt.name}: $(${tgt.name.upper()}_DEPS)
850
nnoble69ac39f2014-12-12 15:43:38 -0800851% if tgt.get('secure', True):
852ifneq ($(NO_SECURE),true)
853% endif
854ifneq ($(NO_DEPS),true)
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800855-include $(${tgt.name.upper()}_DEPS)
856endif
nnoble69ac39f2014-12-12 15:43:38 -0800857% if tgt.get('secure', True):
858endif
859% endif
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800860
861clean_${tgt.name}:
862 $(E) "[CLEAN] Cleaning ${tgt.name} files"
863 $(Q) $(RM) $(${tgt.name.upper()}_OBJS)
864 $(Q) $(RM) $(${tgt.name.upper()}_DEPS)
ctillercab52e72015-01-06 13:10:23 -0800865 $(Q) $(RM) bins/$(CONFIG)/${tgt.name}
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800866</%def>
867
nnoble85a49262014-12-08 18:14:03 -0800868.PHONY: all strip tools \
nnoble69ac39f2014-12-12 15:43:38 -0800869dep_error openssl_dep_error openssl_dep_message git_update stop \
nnoble85a49262014-12-08 18:14:03 -0800870buildtests buildtests_c buildtests_cxx \
871test test_c test_cxx \
872install install_c install_cxx \
873install-headers install-headers_c install-headers_cxx \
874install-shared install-shared_c install-shared_cxx \
875install-static install-static_c install-static_cxx \
876strip strip-shared strip-static \
877strip_c strip-shared_c strip-static_c \
878strip_cxx strip-shared_cxx strip-static_cxx \
nnoblebba76922014-12-15 13:27:38 -0800879clean \
880dep_c dep_cxx bins_dep_c bins_dep_cxx\
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800881% for lib in libs:
882 deps_lib${lib.name} clean_lib${lib.name}\
883% endfor
884% for tgt in targets:
885 deps_${tgt.name} clean_${tgt.name}\
886% endfor
887