Makefile.am raw
1 ACLOCAL_AMFLAGS = -I autotools-aux/m4
2
3 # AM_CFLAGS will be automatically prepended to CFLAGS by Automake when compiling some foo
4 # which does not have an explicit foo_CFLAGS variable set.
5 AM_CFLAGS = $(SECP_CFLAGS)
6
7 lib_LTLIBRARIES = libsecp256k1.la
8 include_HEADERS = include/secp256k1.h
9 include_HEADERS += include/secp256k1_preallocated.h
10 noinst_HEADERS =
11 noinst_HEADERS += src/scalar.h
12 noinst_HEADERS += src/scalar_4x64.h
13 noinst_HEADERS += src/scalar_8x32.h
14 noinst_HEADERS += src/scalar_low.h
15 noinst_HEADERS += src/scalar_impl.h
16 noinst_HEADERS += src/scalar_4x64_impl.h
17 noinst_HEADERS += src/scalar_8x32_impl.h
18 noinst_HEADERS += src/scalar_low_impl.h
19 noinst_HEADERS += src/group.h
20 noinst_HEADERS += src/group_impl.h
21 noinst_HEADERS += src/ecdsa.h
22 noinst_HEADERS += src/ecdsa_impl.h
23 noinst_HEADERS += src/eckey.h
24 noinst_HEADERS += src/eckey_impl.h
25 noinst_HEADERS += src/ecmult.h
26 noinst_HEADERS += src/ecmult_impl.h
27 noinst_HEADERS += src/ecmult_compute_table.h
28 noinst_HEADERS += src/ecmult_compute_table_impl.h
29 noinst_HEADERS += src/ecmult_const.h
30 noinst_HEADERS += src/ecmult_const_impl.h
31 noinst_HEADERS += src/ecmult_gen.h
32 noinst_HEADERS += src/ecmult_gen_impl.h
33 noinst_HEADERS += src/ecmult_gen_compute_table.h
34 noinst_HEADERS += src/ecmult_gen_compute_table_impl.h
35 noinst_HEADERS += src/field_10x26.h
36 noinst_HEADERS += src/field_10x26_impl.h
37 noinst_HEADERS += src/field_5x52.h
38 noinst_HEADERS += src/field_5x52_impl.h
39 noinst_HEADERS += src/field_5x52_int128_impl.h
40 noinst_HEADERS += src/modinv32.h
41 noinst_HEADERS += src/modinv32_impl.h
42 noinst_HEADERS += src/modinv64.h
43 noinst_HEADERS += src/modinv64_impl.h
44 noinst_HEADERS += src/precomputed_ecmult.h
45 noinst_HEADERS += src/precomputed_ecmult_gen.h
46 noinst_HEADERS += src/assumptions.h
47 noinst_HEADERS += src/checkmem.h
48 noinst_HEADERS += src/tests_common.h
49 noinst_HEADERS += src/testutil.h
50 noinst_HEADERS += src/unit_test.h
51 noinst_HEADERS += src/unit_test.c
52 noinst_HEADERS += src/util.h
53 noinst_HEADERS += src/util_local_visibility.h
54 noinst_HEADERS += src/int128.h
55 noinst_HEADERS += src/int128_impl.h
56 noinst_HEADERS += src/int128_native.h
57 noinst_HEADERS += src/int128_native_impl.h
58 noinst_HEADERS += src/int128_struct.h
59 noinst_HEADERS += src/int128_struct_impl.h
60 noinst_HEADERS += src/scratch.h
61 noinst_HEADERS += src/scratch_impl.h
62 noinst_HEADERS += src/selftest.h
63 noinst_HEADERS += src/testrand.h
64 noinst_HEADERS += src/testrand_impl.h
65 noinst_HEADERS += src/hash.h
66 noinst_HEADERS += src/hash_impl.h
67 noinst_HEADERS += src/field.h
68 noinst_HEADERS += src/field_impl.h
69 noinst_HEADERS += src/bench.h
70 noinst_HEADERS += src/wycheproof/ecdsa_secp256k1_sha256_bitcoin_test.h
71 noinst_HEADERS += src/hsort.h
72 noinst_HEADERS += src/hsort_impl.h
73 noinst_HEADERS += contrib/lax_der_parsing.h
74 noinst_HEADERS += contrib/lax_der_parsing.c
75 noinst_HEADERS += contrib/lax_der_privatekey_parsing.h
76 noinst_HEADERS += contrib/lax_der_privatekey_parsing.c
77 noinst_HEADERS += examples/examples_util.h
78
79 PRECOMPUTED_LIB = libsecp256k1_precomputed.la
80 noinst_LTLIBRARIES = $(PRECOMPUTED_LIB)
81 libsecp256k1_precomputed_la_SOURCES = src/precomputed_ecmult.c src/precomputed_ecmult_gen.c
82 # We need `-I$(top_srcdir)/src` in VPATH builds if libsecp256k1_precomputed_la_SOURCES have been recreated in the build tree.
83 # This helps users and packagers who insist on recreating the precomputed files (e.g., Gentoo).
84 libsecp256k1_precomputed_la_CPPFLAGS = -I$(top_srcdir)/src $(SECP_CONFIG_DEFINES)
85
86 if USE_EXTERNAL_ASM
87 COMMON_LIB = libsecp256k1_common.la
88 else
89 COMMON_LIB =
90 endif
91 noinst_LTLIBRARIES += $(COMMON_LIB)
92
93 pkgconfigdir = $(libdir)/pkgconfig
94 pkgconfig_DATA = libsecp256k1.pc
95
96 if USE_EXTERNAL_ASM
97 if USE_ASM_ARM
98 libsecp256k1_common_la_SOURCES = src/asm/field_10x26_arm.s
99 endif
100 endif
101
102 libsecp256k1_la_SOURCES = src/secp256k1.c
103 libsecp256k1_la_CPPFLAGS = $(SECP_CONFIG_DEFINES)
104 libsecp256k1_la_LIBADD = $(COMMON_LIB) $(PRECOMPUTED_LIB)
105 libsecp256k1_la_LDFLAGS = -no-undefined -version-info $(LIB_VERSION_CURRENT):$(LIB_VERSION_REVISION):$(LIB_VERSION_AGE)
106
107 noinst_PROGRAMS =
108 if USE_BENCHMARK
109 noinst_PROGRAMS += bench bench_internal bench_ecmult
110 bench_SOURCES = src/bench.c
111 bench_LDADD = libsecp256k1.la
112 bench_CPPFLAGS = $(SECP_CONFIG_DEFINES)
113 bench_internal_SOURCES = src/bench_internal.c
114 bench_internal_LDADD = $(COMMON_LIB) $(PRECOMPUTED_LIB)
115 bench_internal_CPPFLAGS = $(SECP_CONFIG_DEFINES)
116 bench_ecmult_SOURCES = src/bench_ecmult.c
117 bench_ecmult_LDADD = $(COMMON_LIB) $(PRECOMPUTED_LIB)
118 bench_ecmult_CPPFLAGS = $(SECP_CONFIG_DEFINES)
119 endif
120
121 TESTS =
122 if USE_TESTS
123 TESTS += noverify_tests
124 noinst_PROGRAMS += noverify_tests
125 noverify_tests_SOURCES = src/tests.c
126 noverify_tests_CPPFLAGS = $(SECP_CONFIG_DEFINES) $(TEST_DEFINES)
127 noverify_tests_LDADD = $(COMMON_LIB) $(PRECOMPUTED_LIB)
128 noverify_tests_LDFLAGS = -static
129 if !ENABLE_COVERAGE
130 TESTS += tests
131 noinst_PROGRAMS += tests
132 tests_SOURCES = $(noverify_tests_SOURCES)
133 tests_CPPFLAGS = $(noverify_tests_CPPFLAGS) -DVERIFY
134 tests_LDADD = $(noverify_tests_LDADD)
135 tests_LDFLAGS = $(noverify_tests_LDFLAGS)
136 endif
137 endif
138
139 if USE_CTIME_TESTS
140 noinst_PROGRAMS += ctime_tests
141 ctime_tests_SOURCES = src/ctime_tests.c
142 ctime_tests_LDADD = libsecp256k1.la
143 ctime_tests_CPPFLAGS = $(SECP_CONFIG_DEFINES)
144 endif
145
146 if USE_EXHAUSTIVE_TESTS
147 noinst_PROGRAMS += exhaustive_tests
148 exhaustive_tests_SOURCES = src/tests_exhaustive.c
149 exhaustive_tests_CPPFLAGS = $(SECP_CONFIG_DEFINES)
150 if !ENABLE_COVERAGE
151 exhaustive_tests_CPPFLAGS += -DVERIFY
152 endif
153 # Note: do not include $(PRECOMPUTED_LIB) in exhaustive_tests (it uses runtime-generated tables).
154 exhaustive_tests_LDADD = $(COMMON_LIB)
155 exhaustive_tests_LDFLAGS = -static
156 TESTS += exhaustive_tests
157 endif
158
159 if USE_EXAMPLES
160 noinst_PROGRAMS += ecdsa_example
161 ecdsa_example_SOURCES = examples/ecdsa.c
162 ecdsa_example_CPPFLAGS = -I$(top_srcdir)/include -DSECP256K1_STATIC
163 ecdsa_example_LDADD = libsecp256k1.la
164 ecdsa_example_LDFLAGS = -static
165 if BUILD_WINDOWS
166 ecdsa_example_LDFLAGS += -lbcrypt
167 endif
168 TESTS += ecdsa_example
169 if ENABLE_MODULE_ECDH
170 noinst_PROGRAMS += ecdh_example
171 ecdh_example_SOURCES = examples/ecdh.c
172 ecdh_example_CPPFLAGS = -I$(top_srcdir)/include -DSECP256K1_STATIC
173 ecdh_example_LDADD = libsecp256k1.la
174 ecdh_example_LDFLAGS = -static
175 if BUILD_WINDOWS
176 ecdh_example_LDFLAGS += -lbcrypt
177 endif
178 TESTS += ecdh_example
179 endif
180 if ENABLE_MODULE_SCHNORRSIG
181 noinst_PROGRAMS += schnorr_example
182 schnorr_example_SOURCES = examples/schnorr.c
183 schnorr_example_CPPFLAGS = -I$(top_srcdir)/include -DSECP256K1_STATIC
184 schnorr_example_LDADD = libsecp256k1.la
185 schnorr_example_LDFLAGS = -static
186 if BUILD_WINDOWS
187 schnorr_example_LDFLAGS += -lbcrypt
188 endif
189 TESTS += schnorr_example
190 endif
191 if ENABLE_MODULE_ELLSWIFT
192 noinst_PROGRAMS += ellswift_example
193 ellswift_example_SOURCES = examples/ellswift.c
194 ellswift_example_CPPFLAGS = -I$(top_srcdir)/include -DSECP256K1_STATIC
195 ellswift_example_LDADD = libsecp256k1.la
196 ellswift_example_LDFLAGS = -static
197 if BUILD_WINDOWS
198 ellswift_example_LDFLAGS += -lbcrypt
199 endif
200 TESTS += ellswift_example
201 endif
202 if ENABLE_MODULE_MUSIG
203 noinst_PROGRAMS += musig_example
204 musig_example_SOURCES = examples/musig.c
205 musig_example_CPPFLAGS = -I$(top_srcdir)/include -DSECP256K1_STATIC
206 musig_example_LDADD = libsecp256k1.la
207 musig_example_LDFLAGS = -static
208 if BUILD_WINDOWS
209 musig_example_LDFLAGS += -lbcrypt
210 endif
211 TESTS += musig_example
212 endif
213 endif
214
215 ### Precomputed tables
216 EXTRA_PROGRAMS = precompute_ecmult precompute_ecmult_gen
217 CLEANFILES = $(EXTRA_PROGRAMS)
218
219 precompute_ecmult_SOURCES = src/precompute_ecmult.c
220 precompute_ecmult_CPPFLAGS = $(SECP_CONFIG_DEFINES) -DVERIFY
221 precompute_ecmult_LDADD = $(COMMON_LIB)
222
223 precompute_ecmult_gen_SOURCES = src/precompute_ecmult_gen.c
224 precompute_ecmult_gen_CPPFLAGS = $(SECP_CONFIG_DEFINES) -DVERIFY
225 precompute_ecmult_gen_LDADD = $(COMMON_LIB)
226
227 # See Automake manual, Section "Errors with distclean".
228 # We don't list any dependencies for the prebuilt files here because
229 # otherwise make's decision whether to rebuild them (even in the first
230 # build by a normal user) depends on mtimes, and thus is very fragile.
231 # This means that rebuilds of the prebuilt files always need to be
232 # forced by deleting them.
233 src/precomputed_ecmult.c:
234 $(MAKE) $(AM_MAKEFLAGS) precompute_ecmult$(EXEEXT)
235 ./precompute_ecmult$(EXEEXT)
236 src/precomputed_ecmult_gen.c:
237 $(MAKE) $(AM_MAKEFLAGS) precompute_ecmult_gen$(EXEEXT)
238 ./precompute_ecmult_gen$(EXEEXT)
239
240 PRECOMP = src/precomputed_ecmult_gen.c src/precomputed_ecmult.c
241 precomp: $(PRECOMP)
242
243 # Ensure the prebuilt files will be build first (only if they don't exist,
244 # e.g., after `make maintainer-clean`).
245 BUILT_SOURCES = $(PRECOMP)
246
247 .PHONY: clean-precomp
248 clean-precomp:
249 rm -f $(PRECOMP)
250 maintainer-clean-local: clean-precomp
251
252 ### Pregenerated test vectors
253 ### (see the comments in the previous section for detailed rationale)
254 TESTVECTORS = src/wycheproof/ecdsa_secp256k1_sha256_bitcoin_test.h
255
256 if ENABLE_MODULE_ECDH
257 TESTVECTORS += src/wycheproof/ecdh_secp256k1_test.h
258 endif
259
260 src/wycheproof/ecdsa_secp256k1_sha256_bitcoin_test.h:
261 mkdir -p $(@D)
262 python3 $(top_srcdir)/tools/tests_wycheproof_generate_ecdsa.py $(top_srcdir)/src/wycheproof/ecdsa_secp256k1_sha256_bitcoin_test.json > $@
263
264 src/wycheproof/ecdh_secp256k1_test.h:
265 mkdir -p $(@D)
266 python3 $(top_srcdir)/tools/tests_wycheproof_generate_ecdh.py $(top_srcdir)/src/wycheproof/ecdh_secp256k1_test.json > $@
267
268 testvectors: $(TESTVECTORS)
269
270 BUILT_SOURCES += $(TESTVECTORS)
271
272 .PHONY: clean-testvectors
273 clean-testvectors:
274 rm -f $(TESTVECTORS)
275 maintainer-clean-local: clean-testvectors
276
277 ### Additional files to distribute
278 EXTRA_DIST = autogen.sh CHANGELOG.md SECURITY.md
279 EXTRA_DIST += doc/release-process.md doc/safegcd_implementation.md
280 EXTRA_DIST += doc/ellswift.md doc/musig.md
281 EXTRA_DIST += examples/EXAMPLES_COPYING
282 EXTRA_DIST += sage/gen_exhaustive_groups.sage
283 EXTRA_DIST += sage/gen_split_lambda_constants.sage
284 EXTRA_DIST += sage/group_prover.sage
285 EXTRA_DIST += sage/prove_group_implementations.sage
286 EXTRA_DIST += sage/secp256k1_params.sage
287 EXTRA_DIST += sage/weierstrass_prover.sage
288 EXTRA_DIST += src/wycheproof/WYCHEPROOF_COPYING
289 EXTRA_DIST += src/wycheproof/ecdsa_secp256k1_sha256_bitcoin_test.json
290 EXTRA_DIST += src/wycheproof/ecdh_secp256k1_test.json
291 EXTRA_DIST += tools/tests_wycheproof_generate_ecdsa.py
292 EXTRA_DIST += tools/tests_wycheproof_generate_ecdh.py
293
294 if ENABLE_MODULE_ECDH
295 include src/modules/ecdh/Makefile.am.include
296 endif
297
298 if ENABLE_MODULE_RECOVERY
299 include src/modules/recovery/Makefile.am.include
300 endif
301
302 if ENABLE_MODULE_EXTRAKEYS
303 include src/modules/extrakeys/Makefile.am.include
304 endif
305
306 if ENABLE_MODULE_SCHNORRSIG
307 include src/modules/schnorrsig/Makefile.am.include
308 endif
309
310 if ENABLE_MODULE_MUSIG
311 include src/modules/musig/Makefile.am.include
312 endif
313
314 if ENABLE_MODULE_ELLSWIFT
315 include src/modules/ellswift/Makefile.am.include
316 endif
317