blob: 0eb4e1251279d4389141c506dc16258556bb871f [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 \
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
39CFLAGS_Debug := \
40 -O0 \
41 -g3
42
43CFLAGS_Release := \
44 -Os
45
46CFLAGS_C := \
47 -std=c99
48
49CFLAGS_CC := \
50 -std=c++11
51
52include file_lists.mk third_party.mk examples.mk tests.mk
53
54###
55# libweave.so
56
57out/$(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
63weave_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
69out/$(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
73all : out/$(BUILD_MODE)/libweave.so out/$(BUILD_MODE)/libweave_exports_testrunner out/$(BUILD_MODE)/libweave_testrunner all-examples
74
75clean :
76 rm -rf out
77
78cleanall : clean clean-gtest clean-libevent
79
80.PHONY : clean cleanall all
81