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 -Wformat=2 \ 30 -Wl,--exclude-libs,ALL \ 31 -Wno-char-subscripts \ 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 comma := , 53 ifeq (1, $(CLANG)) 54 CC = $(shell which clang-3.6) 55 CXX = $(shell which clang++-3.6) 56 CFLAGS := $(filter-out -Wl$(comma)--exclude-libs$(comma)ALL,$(CFLAGS)) 57 CFLAGS += \ 58 -fno-omit-frame-pointer \ 59 -Wno-deprecated-register \ 60 -Wno-inconsistent-missing-override 61 ifeq (Debug, $(BUILD_MODE)) 62 CFLAGS += \ 63 -fsanitize=address 64 LDFLAGS += \ 65 -fsanitize=address 66 endif 67 endif 68 69 # Headers dependencies. 70 CFLAGS += -MMD 71 OBJFILES = $(shell find out/$(BUILD_MODE)/ -type f -name '*.o') 72 -include $(OBJFILES:.o=.d) 73 74 DEFS_TEST := \ 75 $(DEFS_$(BUILD_MODE)) \ 76 -DHAS_GTEST=1 77 78 ### 79 # libweave.so 80 81 out/$(BUILD_MODE)/libweave.so : out/$(BUILD_MODE)/libweave_common.a 82 $(CXX) -shared -Wl,-soname=libweave.so -o $@ -Wl,--whole-archive $^ -Wl,--no-whole-archive -lcrypto -lexpat -lpthread -lrt 83 84 include file_lists.mk third_party/third_party.mk examples/examples.mk tests.mk 85 86 ### 87 # src/ 88 89 weave_obj_files := $(WEAVE_SRC_FILES:%.cc=out/$(BUILD_MODE)/%.o) 90 91 $(weave_obj_files) : out/$(BUILD_MODE)/%.o : %.cc 92 mkdir -p $(dir $@) 93 $(CXX) $(DEFS_$(BUILD_MODE)) $(INCLUDES) $(CFLAGS) $(CFLAGS_$(BUILD_MODE)) $(CFLAGS_CC) -c -o $@ $< 94 95 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) 96 rm -f $@ 97 $(AR) crsT $@ $^ 98 99 all : out/$(BUILD_MODE)/libweave.so all-examples out/$(BUILD_MODE)/libweave_exports_testrunner out/$(BUILD_MODE)/libweave_testrunner 100 101 clean : 102 rm -rf out 103 104 cleanall : clean clean-gtest clean-libevhtp 105 106 .PHONY : clean cleanall all 107 .DEFAULT_GOAL := all 108 109