blob: 70f7ee77b2559585c575d252d75728ec5fa00101 [file] [log] [blame]
Jacob Marble7e724372016-01-07 16:16:47 -08001# 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.
6BUILD_MODE ?= Debug
7
8DEFS_Debug := \
9 -D_DEBUG
10
11DEFS_Release := \
12 -DNDEBUG
13
14INCLUDES := \
15 -I. \
16 -Iinclude \
17 -Ithird_party/chromium \
18 -Ithird_party/include \
19 -Ithird_party/libuweave \
20 -Ithird_party/modp_b64/modp_b64
21
22CFLAGS := \
23 -fno-exceptions \
24 -fPIC \
25 -fvisibility=hidden \
26 -Wall \
27 -Werror \
28 -Wextra \
Vitaly Buka50a147a2016-01-22 12:33:59 -080029 -Wformat=2 \
Jacob Marble7e724372016-01-07 16:16:47 -080030 -Wl,--exclude-libs,ALL \
Jacob Marble7e724372016-01-07 16:16:47 -080031 -Wno-missing-field-initializers \
Jacob Marble7e724372016-01-07 16:16:47 -080032 -Wno-unused-parameter \
Jacob Marble7e724372016-01-07 16:16:47 -080033
34CFLAGS_Debug := \
Jacob Marbleddb87592016-02-02 12:35:23 -080035 -O0 \
Jacob Marble7e724372016-01-07 16:16:47 -080036 -g3
37
38CFLAGS_Release := \
39 -Os
40
41CFLAGS_C := \
42 -std=c99
43
44CFLAGS_CC := \
45 -std=c++11
46
Jacob Marblef1ac1d42016-01-12 16:34:39 -080047comma := ,
48ifeq (1, $(CLANG))
49 CC = $(shell which clang-3.6)
50 CXX = $(shell which clang++-3.6)
51 CFLAGS := $(filter-out -Wl$(comma)--exclude-libs$(comma)ALL,$(CFLAGS))
52 CFLAGS += \
53 -fno-omit-frame-pointer \
Jacob Marblef1ac1d42016-01-12 16:34:39 -080054 -Wno-inconsistent-missing-override
55 ifeq (Debug, $(BUILD_MODE))
56 CFLAGS += \
57 -fsanitize=address
58 LDFLAGS += \
59 -fsanitize=address
60 endif
61endif
62
Vitaly Bukae0b0c6d2016-01-14 18:22:43 -080063# Headers dependencies.
64CFLAGS += -MMD
65OBJFILES = $(shell find out/$(BUILD_MODE)/ -type f -name '*.o')
66-include $(OBJFILES:.o=.d)
67
Vitaly Bukae03c0942016-01-22 20:16:21 -080068DEFS_TEST := \
69 $(DEFS_$(BUILD_MODE)) \
70 -DHAS_GTEST=1
71
Jacob Marble7e724372016-01-07 16:16:47 -080072###
73# libweave.so
74
75out/$(BUILD_MODE)/libweave.so : out/$(BUILD_MODE)/libweave_common.a
76 $(CXX) -shared -Wl,-soname=libweave.so -o $@ -Wl,--whole-archive $^ -Wl,--no-whole-archive -lcrypto -lexpat -lpthread -lrt
77
Jacob Marblee785ec92016-01-13 13:49:44 -080078include file_lists.mk third_party/third_party.mk examples/examples.mk tests.mk
79
Jacob Marble7e724372016-01-07 16:16:47 -080080###
81# src/
82
83weave_obj_files := $(WEAVE_SRC_FILES:%.cc=out/$(BUILD_MODE)/%.o)
84
Vitaly Bukae03c0942016-01-22 20:16:21 -080085$(weave_obj_files) : out/$(BUILD_MODE)/%.o : %.cc
Jacob Marble7e724372016-01-07 16:16:47 -080086 mkdir -p $(dir $@)
87 $(CXX) $(DEFS_$(BUILD_MODE)) $(INCLUDES) $(CFLAGS) $(CFLAGS_$(BUILD_MODE)) $(CFLAGS_CC) -c -o $@ $<
88
89out/$(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)
90 rm -f $@
91 $(AR) crsT $@ $^
92
Vitaly Bukae03c0942016-01-22 20:16:21 -080093all : out/$(BUILD_MODE)/libweave.so all-examples out/$(BUILD_MODE)/libweave_exports_testrunner out/$(BUILD_MODE)/libweave_testrunner
Jacob Marble7e724372016-01-07 16:16:47 -080094
95clean :
96 rm -rf out
97
Jacob Marble33135582016-01-28 10:29:23 -080098cleanall : clean clean-gtest clean-libevhtp
Jacob Marble7e724372016-01-07 16:16:47 -080099
100.PHONY : clean cleanall all
Jacob Marblec3d77142016-02-01 12:30:57 -0800101.DEFAULT_GOAL := all
Jacob Marble7e724372016-01-07 16:16:47 -0800102