Jacob Marble | 7e72437 | 2016-01-07 16:16:47 -0800 | [diff] [blame^] | 1 | # Copyright 2015 The Weave Authors. All rights reserved. |
| 2 | # Use of this source code is governed by a BSD-style license that can be |
| 3 | # found in the LICENSE file. |
| 4 | |
| 5 | # Run make with BUILD_MODE=Release for release. |
| 6 | BUILD_MODE ?= Debug |
| 7 | |
| 8 | DEFS_Debug := \ |
| 9 | -D_DEBUG |
| 10 | |
| 11 | DEFS_Release := \ |
| 12 | -DNDEBUG |
| 13 | |
| 14 | INCLUDES := \ |
| 15 | -I. \ |
| 16 | -Iinclude \ |
| 17 | -Ithird_party/chromium \ |
| 18 | -Ithird_party/include \ |
| 19 | -Ithird_party/libuweave \ |
| 20 | -Ithird_party/modp_b64/modp_b64 |
| 21 | |
| 22 | CFLAGS := \ |
| 23 | -fno-exceptions \ |
| 24 | -fPIC \ |
| 25 | -fvisibility=hidden \ |
| 26 | -Wall \ |
| 27 | -Werror \ |
| 28 | -Wextra \ |
| 29 | -Wl,--exclude-libs,ALL \ |
| 30 | -Wno-char-subscripts \ |
| 31 | -Wno-format-nonliteral \ |
| 32 | -Wno-missing-field-initializers \ |
| 33 | -Wno-unused-local-typedefs \ |
| 34 | -Wno-unused-parameter \ |
| 35 | -Wpacked \ |
| 36 | -Wpointer-arith \ |
| 37 | -Wwrite-strings |
| 38 | |
| 39 | CFLAGS_Debug := \ |
| 40 | -O0 \ |
| 41 | -g3 |
| 42 | |
| 43 | CFLAGS_Release := \ |
| 44 | -Os |
| 45 | |
| 46 | CFLAGS_C := \ |
| 47 | -std=c99 |
| 48 | |
| 49 | CFLAGS_CC := \ |
| 50 | -std=c++11 |
| 51 | |
| 52 | include file_lists.mk third_party.mk examples.mk tests.mk |
| 53 | |
| 54 | ### |
| 55 | # libweave.so |
| 56 | |
| 57 | out/$(BUILD_MODE)/libweave.so : out/$(BUILD_MODE)/libweave_common.a |
| 58 | $(CXX) -shared -Wl,-soname=libweave.so -o $@ -Wl,--whole-archive $^ -Wl,--no-whole-archive -lcrypto -lexpat -lpthread -lrt |
| 59 | |
| 60 | ### |
| 61 | # src/ |
| 62 | |
| 63 | weave_obj_files := $(WEAVE_SRC_FILES:%.cc=out/$(BUILD_MODE)/%.o) |
| 64 | |
| 65 | $(weave_obj_files) : out/$(BUILD_MODE)/%.o : %.cc |
| 66 | mkdir -p $(dir $@) |
| 67 | $(CXX) $(DEFS_$(BUILD_MODE)) $(INCLUDES) $(CFLAGS) $(CFLAGS_$(BUILD_MODE)) $(CFLAGS_CC) -c -o $@ $< |
| 68 | |
| 69 | out/$(BUILD_MODE)/libweave_common.a : $(weave_obj_files) $(third_party_chromium_base_obj_files) $(third_party_chromium_crypto_obj_files) $(third_party_modp_b64_obj_files) $(third_party_libuweave_obj_files) |
| 70 | rm -f $@ |
| 71 | $(AR) crsT $@ $^ |
| 72 | |
| 73 | all : out/$(BUILD_MODE)/libweave.so out/$(BUILD_MODE)/libweave_exports_testrunner out/$(BUILD_MODE)/libweave_testrunner all-examples |
| 74 | |
| 75 | clean : |
| 76 | rm -rf out |
| 77 | |
| 78 | cleanall : clean clean-gtest clean-libevent |
| 79 | |
| 80 | .PHONY : clean cleanall all |
| 81 | |