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