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