-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathMakefile
163 lines (126 loc) · 3.09 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
OS=$(shell uname -s)
ARCH=$(shell uname -m)
ifeq ($(ARCH), armv6l)
CC = gcc
else
CC = clang
endif
ASAN = 0
###
### CFLAGS
###
CFLAGS = -O1 -MMD -g
CFLAGS += -Wall -Werror
ifneq ($(ARCH), armv6l)
CFLAGS += -Wshadow -Wextra
endif
CFLAGS += -Wno-unused-parameter -Wno-sign-compare -Wno-missing-field-initializers
CFLAGS += -fno-omit-frame-pointer
CFLAGS += -fstack-protector
ifeq ($(ASAN), 1)
ifneq ($(OS), Darwin)
CFLAGS += -fsanitize=address
endif
endif
ifeq ($(OS), OpenBSD)
CFLAGS += -I/usr/local/include
endif
CFLAGS += -Ipublic -Ilib/public -Icore/ -Iapps/bitc-cli/ -Iext/src/public
###
### LDOPTS
###
LDOPTS =
ifneq ($(OS), Darwin)
ifeq ($(ASAN), 1)
LDOPTS += -fsanitize=address
endif
LDOPTS += -rdynamic
endif
ifdef P
CFLAGS += -pg
LDOPTS += -pg
endif
###
### the rest
###
LIBS = -lpthread -lssl -lcrypto -lm -lncurses -lpanel -lform -lcurl
LIBS += -lleveldb -lsnappy -lstdc++
ifeq ($(OS), OpenBSD)
LIBS += -L/usr/local/lib -lexecinfo
LIBS := $(subst -lsnappy,,$(LIBS))
endif
VGRND = valgrind --log-file=/tmp/valgrind.log --leak-check=full --error-exitcode=255
BLDDIR = bld
BTC_BIN = bitc
ALLTARGETS = bitc
ifndef V
QUIET_CC = @echo ' CC ' $<;
QUIET_LINK = @echo ' LINK ' $@;
QUIET_TEST = >/dev/null 2>&1
endif
BTC_FILES = core/btc-message.c
BTC_FILES += core/script.c
BTC_FILES += core/peer.c
BTC_FILES += core/peergroup.c
BTC_FILES += core/addrbook.c
BTC_FILES += core/block-store.c
BTC_FILES += core/base58.c
BTC_FILES += core/bloom.c
BTC_FILES += core/key.c
BTC_FILES += core/txdb.c
BTC_FILES += core/wallet.c
BTC_FILES += core/serialize.c
BTC_FILES += core/crypt.c
BTC_FILES += core/rpc.c
BTC_FILES += core/hash.c
BTC_FILES += lib/hashtable/hashtable.c
BTC_FILES += lib/fx/fx.c
BTC_FILES += lib/util/util.c
BTC_FILES += lib/file/file.c
BTC_FILES += lib/poolworker/poolworker.c
BTC_FILES += lib/config/config.c
BTC_FILES += lib/poll/poll.c
BTC_FILES += lib/netasync/netasync.c
BTC_FILES += lib/ip_info/ip_info.c
BTC_FILES += ext/src/cJSON/cJSON.c
BTC_FILES += ext/src/MurmurHash3/MurmurHash3.c
BTC_FILES += apps/bitc-cli/main.c
BTC_FILES += apps/bitc-cli/ncui.c
BTC_FILES += apps/bitc-cli/bitc_ui.c
BTC_FILES += apps/bitc-cli/test.c
BTC_FILES := $(sort $(BTC_FILES))
BTC_OBJ := $(patsubst %.c,$(BLDDIR)/%.o,$(BTC_FILES))
BTC_DEPS := $(patsubst %.c,$(BLDDIR)/%.d,$(BTC_FILES))
$(BLDDIR)/%.o: %.c
@mkdir -p $(@D)
$(QUIET_CC)$(CC) $(CFLAGS) -c $< -o $@
bitc: $(BTC_OBJ)
$(QUIET_LINK)$(CC) $(LDOPTS) -o $(BTC_BIN) $(BTC_OBJ) $(LIBS)
# do not move the following line:
-include $(BTC_DEPS)
inocuoustest:
$(eval VGRND :=)
test: bitc inocuoustest
./bitc -t 0
vg-test: bitc inocuoustest
$(VGRND) ./bitc -t 0
vg-run:
valgrind --log-file=log --leak-check=full --gen-suppressions=all --suppressions=./valgrind.supp ./bitc
###
### Common
###
all: $(ALLTARGETS)
lldb: apps/test/lldb.c
$(CC) -o ./lldb src/lldb.c -lleveldb
lines:
find . -name '*.[ch]'|xargs cat|wc -l
clean:
rm -f $(ALLTARGETS) *~ gmon*
rm -rf $(BLDDIR)
tags:
rm -f tags
find . -follow \( -name '*.[ch]' \) -a -print | ctags -L -
cscope:
rm -f cscope*
find . -name '*.[ch]' -print | xargs cscope -b -q
.PHONY: clean tags cscope