-
Notifications
You must be signed in to change notification settings - Fork 977
/
Copy pathMakefile.am
169 lines (132 loc) · 6.23 KB
/
Makefile.am
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
163
164
165
166
167
168
169
## Process this file with automake to produce Makefile.in
AUTOMAKE_OPTIONS = serial-tests
bin_PROGRAMS = stellar-core
include $(top_srcdir)/common.mk
include $(srcdir)/src.mk
noinst_HEADERS = $(SRC_H_FILES)
if BUILD_TESTS
stellar_core_SOURCES = main/StellarCoreVersion.cpp main/XDRFilesSha256.cpp $(SRC_CXX_FILES) $(SRC_TEST_CXX_FILES)
else # !BUILD_TESTS
stellar_core_SOURCES = main/StellarCoreVersion.cpp main/XDRFilesSha256.cpp $(SRC_CXX_FILES)
endif # !BUILD_TESTS
if ENABLE_PROTOCOL_UPGRADE_VIA_SOROBAN_ENV_HOST_PREV
CARGO_FEATURES = --features soroban-env-host-prev
else
CARGO_FEATURES =
endif
if USE_TRACY
CARGO_FEATURES += --features tracy
endif
if ENABLE_NEXT_PROTOCOL_VERSION_UNSAFE_FOR_PRODUCTION
CARGO_FEATURES += --features core-vnext
main/XDRFilesSha256.cpp: $(SRC_X_FILES) Makefile $(top_srcdir)/hash-xdrs.sh
$(top_srcdir)/hash-xdrs.sh protocol-next >$@
else
main/XDRFilesSha256.cpp: $(SRC_X_FILES) Makefile $(top_srcdir)/hash-xdrs.sh
$(top_srcdir)/hash-xdrs.sh protocol-curr >$@
endif
stellar_core_LDADD = $(soci_LIBS) $(libmedida_LIBS) \
$(top_builddir)/lib/lib3rdparty.a $(sqlite3_LIBS) \
$(libpq_LIBS) $(xdrpp_LIBS) $(libsodium_LIBS) $(libunwind_LIBS)
TESTDATA_DIR = testdata
TEST_FILES = $(TESTDATA_DIR)/stellar-core_example.cfg $(TESTDATA_DIR)/stellar-core_standalone.cfg \
$(TESTDATA_DIR)/stellar-core_testnet.cfg $(TESTDATA_DIR)/stellar-core_testnet_legacy.cfg \
$(TESTDATA_DIR)/stellar-history.testnet.6714239.json $(TESTDATA_DIR)/stellar-history.livenet.15686975.json \
$(TESTDATA_DIR)/stellar-core_testnet_validator.cfg $(TESTDATA_DIR)/stellar-core_example_validators.cfg \
$(TESTDATA_DIR)/stellar-history.testnet.6714239.networkPassphrase.json
BUILT_SOURCES = $(SRC_X_FILES:.x=.h) main/StellarCoreVersion.cpp main/XDRFilesSha256.cpp $(TEST_FILES)
$(SRC_X_FILES:.x=.h): $(XDRC)
SUFFIXES = .x .h .rs
.x.h:
$(XDRC) -hh -pedantic -o $@ $<
BISON=bison
FLEX=flex
util/xdrquery/XDRQueryScanner.cpp: util/xdrquery/XDRQueryScanner.ll
$(FLEX) --outfile=$@ $<
util/xdrquery/XDRQueryParser.cpp: util/xdrquery/XDRQueryParser.yy
$(BISON) --defines=util/xdrquery/XDRQueryParser.h --output=$@ $<
util/xdrquery/XDRQueryParser.h: util/xdrquery/XDRQueryParser.cpp
touch $@
BUILT_SOURCES += util/xdrquery/XDRQueryScanner.cpp util/xdrquery/XDRQueryParser.h util/xdrquery/XDRQueryParser.cpp
stellar_core_SOURCES += util/xdrquery/XDRQueryScanner.cpp util/xdrquery/XDRQueryParser.h util/xdrquery/XDRQueryParser.cpp
# Old automakes have buggy dependency tracking for conditional generated
# sources. We work around this here by making rust/RustBridge.{cpp,h} generated
# in all cases, and just empty in the non-rust case. Also because of the way old
# automake relies on horrible path-munging code in config.status to extract the
# names of depfiles from the Makefile itself, we can't use any variables in the
# SOURCES addition we're doing here, have to list unadorned paths.
BUILT_SOURCES += rust/RustBridge.h rust/RustBridge.cpp
stellar_core_SOURCES += rust/RustBridge.h rust/RustBridge.cpp
RUST_BUILD_DIR=$(top_builddir)/src/rust
RUST_BIN_DIR=$(RUST_BUILD_DIR)/bin
RUST_TARGET_DIR=$(top_builddir)/target
RUST_CXXBRIDGE=$(RUST_BIN_DIR)/cxxbridge
RUST_PROFILE=release
RUST_HOST_DEPFILES=rust/Cargo.toml $(top_srcdir)/Cargo.toml $(top_srcdir)/Cargo.lock rust/src/host-dep-tree-curr.txt rust/src/host-dep-tree-prev.txt
LIBRUST_STELLAR_CORE=$(RUST_TARGET_DIR)/$(RUST_PROFILE)/librust_stellar_core.a
stellar_core_LDADD += $(LIBRUST_STELLAR_CORE) -ldl
$(RUST_CXXBRIDGE):
mkdir -p $(RUST_BIN_DIR)
CARGO_HTTP_MULTIPLEXING=false $(CARGO) install --locked --root $(RUST_BUILD_DIR) cxxbridge-cmd --version 1.0.68
rust/RustBridge.h: rust/src/lib.rs $(SRC_RUST_FILES) Makefile $(RUST_CXXBRIDGE)
$(RUST_CXXBRIDGE) $< --header --output $@.tmp
if cmp -s $@.tmp $@; then rm -v $@.tmp; else mv -v $@.tmp $@; fi
rust/RustBridge.cpp: rust/src/lib.rs $(SRC_RUST_FILES) Makefile $(RUST_CXXBRIDGE)
$(RUST_CXXBRIDGE) $< --output $@.tmp
if cmp -s $@.tmp $@; then rm -v $@.tmp; else mv -v $@.tmp $@; fi
$(LIBRUST_STELLAR_CORE): $(RUST_HOST_DEPFILES) $(SRC_RUST_FILES) Makefile
CARGO_NET_GIT_FETCH_WITH_CLI=true cargo build --locked --$(RUST_PROFILE) --target-dir $(abspath $(RUST_TARGET_DIR)) $(CARGO_FEATURES)
ranlib $@
$(srcdir)/src.mk: $(top_srcdir)/make-mks
cd $(top_srcdir) && ./make-mks
$(TESTDATA_DIR)/%.cfg : $(top_srcdir)/docs/%.cfg
mkdir -p $(@D) && cp $< $@
$(TESTDATA_DIR)/%.json : $(top_srcdir)/src/history/serialize-tests/%.json
mkdir -p $(@D) && cp $< $@
.PHONY: always
always:
@:
# Always rebuild because .git/HEAD is a symbolic ref one can't depend on
main/StellarCoreVersion.cpp: always
@vers=$$(cd "$(srcdir)" \
&& git describe --always --dirty --tags 2>/dev/null \
|| echo "$(PACKAGE) $(VERSION)"); \
sed -e "s@%%VERSION%%@$$vers@" \
< "$(srcdir)/main/StellarCoreVersion.cpp.in" > $@~
@if cmp -s $@~ $@; then rm -f $@~; else \
mv -f $@~ $@ && printf "echo '%s' > $@\n" "$$(cat $@)"; fi
if USE_POSTGRES
TESTS=test/selftest-pg
else # !USE_POSTGRES
TESTS=test/selftest-nopg
endif # !USE_POSTGRES
TESTS += test/check-nondet
format: always
if USE_CLANG_FORMAT
cd $(srcdir) && $(CLANG_FORMAT) -style=file -i $(SRC_CXX_FILES) $(SRC_H_FILES) $(SRC_TEST_CXX_FILES) $(SRC_TEST_H_FILES)
endif # USE_CLANG_FORMAT
cd $(srcdir) && $(CARGO) fmt --all
if USE_AFL_FUZZ
FUZZER_MODE ?= overlay
fuzz-testcases: stellar-core
mkdir -p fuzz-testcases
for i in `seq 1 10000`; do \
./stellar-core gen-fuzz --mode=${FUZZER_MODE} fuzz-testcases/fuzz$$i.xdr ; \
done
mkdir -p min-testcases
afl-cmin -i fuzz-testcases -o min-testcases -m 500 -t 250 ./stellar-core fuzz --ll ERROR --mode=${FUZZER_MODE} @@
rm -Rf fuzz-testcases
# when running in parallel,
# run the same command than below replacing `-M main` with `-S worker_N`
# and `--process-id 0` with `--process-id N`
fuzz: fuzz-testcases stellar-core
mkdir -p fuzz-findings
afl-fuzz -m 500 -M main -t 250 -i min-testcases -o fuzz-findings \
./stellar-core fuzz --ll ERROR --process-id 0 --mode=${FUZZER_MODE} @@
fuzz-clean: always
rm -Rf fuzz-testcases fuzz-findings
distclean-local: fuzz-clean
endif # USE_AFL_FUZZ
CLEANFILES = $(BUILT_SOURCES) *~ */*~ stellar*.log
MAINTAINERCLEANFILES = $(srcdir)/Makefile.in $(srcdir)/*~ $(srcdir)/*/*~
EXTRA_DIST = $(SRC_X_FILES) test/selftest-nopg test/selftest-pg