Makefile.am: Some reformatting.
[catacomb] / math / Makefile.am
CommitLineData
0f00dc4c
MW
1### -*-makefile-*-
2###
3### Build script for mathematical infrastructure
4###
5### (c) 2013 Straylight/Edgeware
6###
7
8###----- Licensing notice ---------------------------------------------------
9###
10### This file is part of Catacomb.
11###
12### Catacomb is free software; you can redistribute it and/or modify
13### it under the terms of the GNU Library General Public License as
14### published by the Free Software Foundation; either version 2 of the
15### License, or (at your option) any later version.
16###
17### Catacomb is distributed in the hope that it will be useful,
18### but WITHOUT ANY WARRANTY; without even the implied warranty of
19### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20### GNU Library General Public License for more details.
21###
22### You should have received a copy of the GNU Library General Public
23### License along with Catacomb; if not, write to the Free
24### Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
25### MA 02111-1307, USA.
26
27include $(top_srcdir)/vars.am
28
29noinst_LTLIBRARIES = libmath.la
30libmath_la_SOURCES =
31nodist_libmath_la_SOURCES =
32libmath_la_LIBADD =
33
34TEST_LIBS = libmath.la
35
36###--------------------------------------------------------------------------
1c3d4cf5
MW
37### Representation of multiprecision integers.
38
39## The `mpgen' tool for dealing with these things.
40mpgen = $(srcdir)/mpgen
41EXTRA_DIST += mpgen
42AM_V_MPGEN = $(AM_V_MPGEN_$(V))
43AM_V_MPGEN_ = $(AM_V_MPGEN_$(AM_DEFAULT_VERBOSITY))
44AM_V_MPGEN_0 = @echo " MPGEN $@";
45MPGEN = $(AM_V_MPGEN)$(PYTHON) $(mpgen)
46
47## The type information collected by `configure'.
48CLEANFILES += typeinfo.py
49EXTRA_DIST += typeinfo.py.in
50typeinfo.py: $(srcdir)/typeinfo.py.in Makefile
51 $(SUBST) $(srcdir)/typeinfo.py.in >typeinfo.py.new \
52 type_bits="@type_bits@" \
53 limits="@limits@" && \
54 mv typeinfo.py.new typeinfo.py
55
56## The header file containing our representation choices.
57BUILT_SOURCES += mptypes.h
58CLEANFILES += mptypes.h
59nodist_archinclude_HEADERS += mptypes.h
60mptypes.h: $(mpgen) typeinfo.py
61 $(MPGEN) mptypes >mptypes.h.in && mv mptypes.h.in mptypes.h
62
63## Limits of C types as multiprecision integers.
64BUILT_SOURCES += mplimits.h mplimits.c
65CLEANFILES += mplimits.h mplimits.c
66nodist_archinclude_HEADERS += mplimits.h
67nodist_libmath_la_SOURCES += mplimits.c
68mplimits.h: $(mpgen) typeinfo.py
69 $(MPGEN) mplimits_h >mplimits.h.in && mv mplimits.h.in mplimits.h
70mplimits.c: $(mpgen) typeinfo.py
71 $(MPGEN) mplimits_c >mplimits.c.in && mv mplimits.c.in mplimits.c
0f00dc4c 72
1c3d4cf5
MW
73###--------------------------------------------------------------------------
74### Main multiprecision integer library.
0f00dc4c
MW
75
76## Additional buffer I/O functions for mathematical objects.
77pkginclude_HEADERS += buf.h
78libmath_la_SOURCES += buf.c
79
80## Infrastructure for fast exponentiation.
81pkginclude_HEADERS += exp.h
82libmath_la_SOURCES += exp.c
83
84## Main user-visible multiprecision arithmetic.
85pkginclude_HEADERS += mp.h
1c3d4cf5 86libmath_la_SOURCES += mp-arith.c
ba57d652 87TESTS += mp-arith.t$(EXEEXT)
1c3d4cf5 88libmath_la_SOURCES += mp-const.c
0f00dc4c
MW
89libmath_la_SOURCES += mp-exp.c mp-exp.h
90libmath_la_SOURCES += mp-gcd.c
ba57d652 91TESTS += mp-gcd.t$(EXEEXT)
1c3d4cf5 92libmath_la_SOURCES += mp-io.c
0f00dc4c 93libmath_la_SOURCES += mp-jacobi.c
ba57d652 94TESTS += mp-jacobi.t$(EXEEXT)
1c3d4cf5
MW
95libmath_la_SOURCES += mp-mem.c
96libmath_la_SOURCES += mp-misc.c
0f00dc4c 97libmath_la_SOURCES += mp-modexp.c
ba57d652 98TESTS += mp-modexp.t$(EXEEXT)
0f00dc4c 99libmath_la_SOURCES += mp-modsqrt.c
ba57d652 100TESTS += mp-modsqrt.t$(EXEEXT)
0f00dc4c 101libmath_la_SOURCES += mp-sqrt.c
ba57d652 102TESTS += mp-sqrt.t$(EXEEXT)
0f00dc4c
MW
103libmath_la_SOURCES += mp-test.c
104EXTRA_DIST += t/mp
105
106## Computing Fibonacci numbers.
107pkginclude_HEADERS += mp-fibonacci.h
108libmath_la_SOURCES += mp-fibonacci.c
ba57d652 109TESTS += mp-fibonacci.t$(EXEEXT)
0f00dc4c
MW
110
111## Special memory allocation for multiprecision integers.
112pkginclude_HEADERS += mparena.h
1c3d4cf5 113libmath_la_SOURCES += mparena.c
0f00dc4c
MW
114
115## Barrett reduction, an efficient method for modular reduction.
116pkginclude_HEADERS += mpbarrett.h
117libmath_la_SOURCES += mpbarrett.c
ba57d652 118TESTS += mpbarrett.t$(EXEEXT)
0f00dc4c 119libmath_la_SOURCES += mpbarrett-exp.c mpbarrett-mexp.c mpbarrett-exp.h
ba57d652
MW
120TESTS += mpbarrett-exp.t$(EXEEXT) mpbarrett-mexp.t$(EXEEXT)
121TESTS += mpbarrett.t$(EXEEXT)
0f00dc4c
MW
122EXTRA_DIST += t/mpbarrett
123
124## Solving congruences using the Chinese Remainder Theorem.
125pkginclude_HEADERS += mpcrt.h
126libmath_la_SOURCES += mpcrt.c
ba57d652 127TESTS += mpcrt.t$(EXEEXT)
0f00dc4c
MW
128EXTRA_DIST += t/mpcrt
129
130## Conversions between machine-native and multiprecision integers.
131pkginclude_HEADERS += mpint.h
132libmath_la_SOURCES += mpint.c
ba57d652 133TESTS += mpint.t$(EXEEXT)
0f00dc4c
MW
134EXTRA_DIST += t/mpint
135
0f00dc4c
MW
136## Montgomery reduction, a clever method for modular arithmetic.
137pkginclude_HEADERS += mpmont.h
138libmath_la_SOURCES += mpmont.c
ba57d652 139TESTS += mpmont.t$(EXEEXT)
0f00dc4c 140libmath_la_SOURCES += mpmont-exp.c mpmont-mexp.c mpmont-exp.h
ba57d652 141TESTS += mpmont-exp.t$(EXEEXT) mpmont-mexp.t$(EXEEXT)
0f00dc4c
MW
142EXTRA_DIST += t/mpmont
143
144## Efficient multiplication of many small numbers.
145pkginclude_HEADERS += mpmul.h
146libmath_la_SOURCES += mpmul.c
ba57d652 147TESTS += mpmul.t$(EXEEXT)
0f00dc4c
MW
148
149## Generating random numbers.
150pkginclude_HEADERS += mprand.h
151libmath_la_SOURCES += mprand.c
152
153## Efficient reduction modulo numbers with conveninent binary
154## representations.
155pkginclude_HEADERS += mpreduce.h
156libmath_la_SOURCES += mpreduce.c mpreduce-exp.h
ba57d652 157TESTS += mpreduce.t$(EXEEXT)
0f00dc4c
MW
158EXTRA_DIST += t/mpreduce
159
160## Iteratiion over the bianry representation of multiprecision integers.
161pkginclude_HEADERS += mpscan.h
1c3d4cf5 162libmath_la_SOURCES += mpscan.c
0f00dc4c
MW
163
164## Conversion between multiprecision integers and their textual
165## representations.
166pkginclude_HEADERS += mptext.h
1c3d4cf5 167libmath_la_SOURCES += mptext.c
ba57d652 168TESTS += mptext.t$(EXEEXT)
0f00dc4c
MW
169libmath_la_SOURCES += mptext-dstr.c
170libmath_la_SOURCES += mptext-file.c
171libmath_la_SOURCES += mptext-len.c
1c3d4cf5 172libmath_la_SOURCES += mptext-string.c
0f00dc4c
MW
173EXTRA_DIST += t/mptext
174
0f00dc4c
MW
175## Low-level multiprecision arithmetic.
176pkginclude_HEADERS += mpx.h bitops.h mpw.h
1c3d4cf5 177libmath_la_SOURCES += mpx.c
ba57d652 178TESTS += mpx.t$(EXEEXT)
1c3d4cf5 179libmath_la_SOURCES += karatsuba.h mpx-kmul.c mpx-ksqr.c
ba57d652 180TESTS += mpx-kmul.t$(EXEEXT) mpx-ksqr.t$(EXEEXT)
0f00dc4c
MW
181noinst_PROGRAMS += bittest
182TESTS += bittest
183EXTRA_DIST += t/mpx
444083ae
MW
184if CPUFAM_X86
185libmath_la_SOURCES += mpx-mul4-x86-sse2.S
186endif
3119b3ae
MW
187if CPUFAM_AMD64
188libmath_la_SOURCES += mpx-mul4-amd64-sse2.S
189endif
0f00dc4c
MW
190
191## A quick-and-dirty parser, used for parsing descriptions of groups, fields,
192## etc.
193pkginclude_HEADERS += qdparse.h
194libmath_la_SOURCES += qdparse.c
195
196## Pollard's `rho' algorithm for determining discrete logarithms.
197pkginclude_HEADERS += rho.h
198libmath_la_SOURCES += rho.c
ba57d652 199TESTS += rho.t$(EXEEXT)
0f00dc4c
MW
200
201###--------------------------------------------------------------------------
202### Prime number checking, searching, and related jobs.
203
204## Generating Lim--Lee groups, i.e., unit groups of finite fields without
205## small subgroups (except for the obvious ones).
206pkginclude_HEADERS += limlee.h
207libmath_la_SOURCES += limlee.c
208
209## A table of small prime numbers.
c9cfa678
MW
210pkginclude_HEADERS += $(precomp)/math/primetab.h
211nodist_libmath_la_SOURCES += ../precomp/math/primetab.c
212PRECOMPS += $(precomp)/math/primetab.h \
213 $(precomp)/math/primetab.c
e5b61a8d 214PRECOMP_PROGS += genprimes
0f00dc4c 215genprimes_LDADD = $(mLib_LIBS)
e5b61a8d 216if !CROSS_COMPILING
c9cfa678
MW
217$(precomp)/math/primetab.h: $(precomp)/math/primetab.c
218$(precomp)/math/primetab.c:
219 $(AM_V_at)$(MKDIR_P) $(precomp)/math
ba57d652 220 $(AM_V_at)$(MAKE) genprimes$(EXEEXT)
e5b61a8d 221 $(AM_V_GEN)./genprimes -sCATACOMB_PRIMETAB_H \
c9cfa678 222 -h$(precomp)/math/primetab.h -c$(precomp)/math/primetab.c \
0f00dc4c 223 -n256 -t"unsigned short" -iprimetab
e5b61a8d 224endif
0f00dc4c
MW
225
226## Filtering candidate prime numbers by checking for small factors
227## efficiently.
228pkginclude_HEADERS += pfilt.h
229libmath_la_SOURCES += pfilt.c
230
231## Generating prime numbers (and other kinds of numbers which need searching
232## for).
233pkginclude_HEADERS += pgen.h
234libmath_la_SOURCES += pgen.c
235libmath_la_SOURCES += pgen-gcd.c
236libmath_la_SOURCES += pgen-simul.c
237libmath_la_SOURCES += pgen-stdev.c
ba57d652 238TESTS += pgen.t$(EXEEXT)
0f00dc4c
MW
239EXTRA_DIST += t/pgen
240
241## Finding primitive elements in finite fields.
242pkginclude_HEADERS += prim.h
243libmath_la_SOURCES += prim.c
244
245## Iterating over all prime numbers from a given starting point.
246pkginclude_HEADERS += primeiter.h
247libmath_la_SOURCES += primeiter.c
ba57d652 248TESTS += primeiter.t$(EXEEXT)
c9cfa678 249primeiter.lo: $(precomp)/math/wheel.h
0f00dc4c
MW
250
251## The Miller--Rabin primality test.
252pkginclude_HEADERS += rabin.h
253libmath_la_SOURCES += rabin.c
254
255## Finding `strong' primes, using Gordon's algorithm. Once upon a time,
256## products of these kinds of numbers were harder to factor.
257pkginclude_HEADERS += strongprime.h
258libmath_la_SOURCES += strongprime.c
259
260## A `wheel', used by the prime iteration machinery.
c9cfa678
MW
261pkginclude_HEADERS += $(precomp)/math/wheel.h
262nodist_libmath_la_SOURCES += ../precomp/math/wheel.c
263PRECOMPS += $(precomp)/math/wheel.h $(precomp)/math/wheel.c
e5b61a8d 264PRECOMP_PROGS += genwheel
0f00dc4c 265genwheel_LDADD = $(mLib_LIBS)
e5b61a8d 266if !CROSS_COMPILING
c9cfa678
MW
267$(precomp)/math/wheel.h: $(precomp)/math/wheel.c
268$(precomp)/math/wheel.c:
269 $(AM_V_at)$(MKDIR_P) $(precomp)/math
ba57d652 270 $(AM_V_at)$(MAKE) genwheel$(EXEEXT)
e5b61a8d 271 $(AM_V_GEN)./genwheel -sCATACOMB_WHEEL_H \
c9cfa678 272 -h$(precomp)/math/wheel.h -c$(precomp)/math/wheel.c \
0f00dc4c 273 -n5 -t"unsigned char" -iwheel
e5b61a8d 274endif
0f00dc4c
MW
275
276###--------------------------------------------------------------------------
277### Binary polynomial arithmetic.
278
279## User-visible binary polynomial arithmetic.
280pkginclude_HEADERS += gf.h
281libmath_la_SOURCES += gf-arith.c
ba57d652 282TESTS += gf-arith.t$(EXEEXT)
0f00dc4c
MW
283libmath_la_SOURCES += gf-exp.c gf-exp.h
284libmath_la_SOURCES += gf-gcd.c
ba57d652 285TESTS += gf-gcd.t$(EXEEXT)
0f00dc4c
MW
286EXTRA_DIST += t/gf
287
288## Low-level binary polynomial arithmetic.
289pkginclude_HEADERS += gfx.h
290libmath_la_SOURCES += gfx.c
ba57d652 291TESTS += gfx.t$(EXEEXT)
0f00dc4c 292libmath_la_SOURCES += gfx-kmul.c
ba57d652 293TESTS += gfx-kmul.t$(EXEEXT)
c9cfa678
MW
294libmath_la_SOURCES += gfx-sqr.c
295nodist_libmath_la_SOURCES += ../precomp/math/gfx-sqrtab.c
296PRECOMPS += $(precomp)/math/gfx-sqrtab.c
e5b61a8d
MW
297PRECOMP_PROGS += gfx-sqr-mktab
298if !CROSS_COMPILING
c9cfa678
MW
299$(precomp)/math/gfx-sqrtab.c:
300 $(AM_V_at)$(MKDIR_P) $(precomp)/math
ba57d652 301 $(AM_V_at)$(MAKE) gfx-sqr-mktab$(EXEEXT)
c9cfa678
MW
302 $(AM_V_GEN)./gfx-sqr-mktab >$(precomp)/math/gfx-sqrtab.c.new && \
303 mv $(precomp)/math/gfx-sqrtab.c.new \
304 $(precomp)/math/gfx-sqrtab.c
e5b61a8d 305endif
ba57d652 306TESTS += gfx-sqr.t$(EXEEXT)
0f00dc4c
MW
307EXTRA_DIST += t/gfx
308
309## Conversions between normal and polynomial basis representations for binary
310## fields.
311pkginclude_HEADERS += gfn.h
312libmath_la_SOURCES += gfn.c
ba57d652 313TESTS += gfn.t$(EXEEXT)
0f00dc4c
MW
314EXTRA_DIST += t/gfn
315
316## Efficient reduction modulo sparse polynomials.
317pkginclude_HEADERS += gfreduce.h
318libmath_la_SOURCES += gfreduce.c gfreduce-exp.h
ba57d652 319TESTS += gfreduce.t$(EXEEXT)
0f00dc4c
MW
320EXTRA_DIST += t/gfreduce
321
322###--------------------------------------------------------------------------
323### Abstractions for various kinds of algebraic objects.
324
325## Abstract cyclic groups.
326pkginclude_HEADERS += group.h group-guts.h
327libmath_la_SOURCES += group-dstr.c
328libmath_la_SOURCES += group-exp.c group-exp.h
329libmath_la_SOURCES += group-file.c
330libmath_la_SOURCES += group-parse.c
331libmath_la_SOURCES += group-stdops.c
332libmath_la_SOURCES += group-string.c
333libmath_la_SOURCES += g-bin.c
334libmath_la_SOURCES += g-prime.c
335libmath_la_SOURCES += g-ec.c
336EXTRA_DIST += group-test.c
ba57d652 337TESTS += group-test.t$(EXEEXT)
0f00dc4c
MW
338EXTRA_DIST += t/group
339
340## Abstract finite fields.
341pkginclude_HEADERS += field.h field-guts.h
342libmath_la_SOURCES += field.c
343libmath_la_SOURCES += field-exp.c field-exp.h
344libmath_la_SOURCES += field-parse.c
345libmath_la_SOURCES += f-binpoly.c
346libmath_la_SOURCES += f-niceprime.c
347libmath_la_SOURCES += f-prime.c
348
349## Table of built-in binary fields.
350pkginclude_HEADERS += bintab.h
1c3d4cf5 351nodist_libmath_la_SOURCES += bintab.c
0f00dc4c 352CLEANFILES += bintab.c
1c3d4cf5
MW
353EXTRA_DIST += bintab.in
354bintab.c: $(mpgen) typeinfo.py bintab.in
355 $(MPGEN) bintab $(srcdir)/bintab.in >bintab.c.new && \
356 mv bintab.c.new bintab.c
0f00dc4c
MW
357
358## Table of built-in prime fields.
359pkginclude_HEADERS += ptab.h
1c3d4cf5 360nodist_libmath_la_SOURCES += ptab.c
0f00dc4c 361CLEANFILES += ptab.c
1c3d4cf5
MW
362EXTRA_DIST += ptab.in
363ptab.c: $(mpgen) typeinfo.py ptab.in
364 $(MPGEN) ptab $(srcdir)/ptab.in >ptab.c.new && \
365 mv ptab.c.new ptab.c
0f00dc4c
MW
366
367###--------------------------------------------------------------------------
368### Elliptic curve arithmetic.
369
370## Basic elliptic curve arithmetic.
371pkginclude_HEADERS += ec.h ec-guts.h
372libmath_la_SOURCES += ec.c
373libmath_la_SOURCES += ec-exp.c ec-exp.h
374libmath_la_SOURCES += ec-info.c
ba57d652 375TESTS += ec-info.t$(EXEEXT)
0f00dc4c 376libmath_la_SOURCES += ec-bin.c
ba57d652 377TESTS += ec-bin.t$(EXEEXT)
0f00dc4c 378libmath_la_SOURCES += ec-prime.c
ba57d652 379TESTS += ec-prime.t$(EXEEXT)
0f00dc4c
MW
380EXTRA_DIST += t/ec
381
382## The standard `raw' encoding (`EC2OSP') of elliptic curve points.
383pkginclude_HEADERS += ec-raw.h
384libmath_la_SOURCES += ec-raw.c
385
386## Assistance for elliptic-curve keys.
387pkginclude_HEADERS += ec-keys.h
388libmath_la_SOURCES += ec-fetch.c
389
390## Test infrastructure for elliptic curves.
391pkginclude_HEADERS += ec-test.h
392libmath_la_SOURCES += ec-test.c
ba57d652 393TESTS += ec-test.t$(EXEEXT)
0f00dc4c 394
1c3d4cf5 395## Table of built-in elliptic-curve groups.
0f00dc4c 396pkginclude_HEADERS += ectab.h
1c3d4cf5 397nodist_libmath_la_SOURCES += ectab.c
0f00dc4c 398CLEANFILES += ectab.c
1c3d4cf5
MW
399EXTRA_DIST += ectab.in
400ectab.c: $(mpgen) typeinfo.py ectab.in
401 $(MPGEN) ectab $(srcdir)/ectab.in >ectab.c.new && \
402 mv ectab.c.new ectab.c
0f00dc4c
MW
403
404###----- That's all, folks --------------------------------------------------