5bb546c2282b110524abfccc705bcd8471aac43b
[u/mdw/catacomb] / math / Makefile.am
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
27 include $(top_srcdir)/vars.am
28
29 noinst_LTLIBRARIES = libmath.la
30 libmath_la_SOURCES =
31 nodist_libmath_la_SOURCES =
32 libmath_la_LIBADD =
33
34 TEST_LIBS = libmath.la
35
36 ###--------------------------------------------------------------------------
37 ### Main multiprecision integer library.
38
39 ## This library is unfortunately intertwined with some of the code generation
40 ## programs, so we must be rather careful. The important bits of the maths
41 ## library needed by these programs is separated out into `libmpbase'. There
42 ## is work going on to fix this unpleasant situation by generating the
43 ## relevant files from Python scripts rather than C programs, using
44 ## information gathered by `configure'.
45 noinst_LTLIBRARIES += libmpbase.la
46 libmath_la_LIBADD += libmpbase.la
47 libmpbase_la_LIBADD = $(mLib_LIBS)
48 libmpbase_la_SOURCES =
49 $(libmpbase_la_OBJECTS): mptypes.h
50
51 ## Additional buffer I/O functions for mathematical objects.
52 pkginclude_HEADERS += buf.h
53 libmath_la_SOURCES += buf.c
54
55 ## Infrastructure for fast exponentiation.
56 pkginclude_HEADERS += exp.h
57 libmath_la_SOURCES += exp.c
58
59 ## Main user-visible multiprecision arithmetic.
60 pkginclude_HEADERS += mp.h
61 libmpbase_la_SOURCES += mp-arith.c
62 TESTS += mp-arith.$t
63 libmpbase_la_SOURCES += mp-const.c
64 libmath_la_SOURCES += mp-exp.c mp-exp.h
65 libmath_la_SOURCES += mp-gcd.c
66 TESTS += mp-gcd.$t
67 libmpbase_la_SOURCES += mp-io.c
68 libmath_la_SOURCES += mp-jacobi.c
69 TESTS += mp-jacobi.$t
70 libmpbase_la_SOURCES += mp-mem.c
71 libmpbase_la_SOURCES += mp-misc.c
72 libmath_la_SOURCES += mp-modexp.c
73 TESTS += mp-modexp.$t
74 libmath_la_SOURCES += mp-modsqrt.c
75 TESTS += mp-modsqrt.$t
76 libmath_la_SOURCES += mp-sqrt.c
77 TESTS += mp-sqrt.$t
78 libmath_la_SOURCES += mp-test.c
79 EXTRA_DIST += t/mp
80
81 ## Computing Fibonacci numbers.
82 pkginclude_HEADERS += mp-fibonacci.h
83 libmath_la_SOURCES += mp-fibonacci.c
84 TESTS += mp-fibonacci.$t
85
86 ## Special memory allocation for multiprecision integers.
87 pkginclude_HEADERS += mparena.h
88 libmpbase_la_SOURCES += mparena.c
89
90 ## Barrett reduction, an efficient method for modular reduction.
91 pkginclude_HEADERS += mpbarrett.h
92 libmath_la_SOURCES += mpbarrett.c
93 TESTS += mpbarrett.$t
94 libmath_la_SOURCES += mpbarrett-exp.c mpbarrett-mexp.c mpbarrett-exp.h
95 TESTS += mpbarrett-exp.$t mpbarrett-mexp.$t
96 TESTS += mpbarrett.$t
97 EXTRA_DIST += t/mpbarrett
98
99 ## Solving congruences using the Chinese Remainder Theorem.
100 pkginclude_HEADERS += mpcrt.h
101 libmath_la_SOURCES += mpcrt.c
102 TESTS += mpcrt.$t
103 EXTRA_DIST += t/mpcrt
104
105 ## Conversions between machine-native and multiprecision integers.
106 pkginclude_HEADERS += mpint.h
107 libmath_la_SOURCES += mpint.c
108 TESTS += mpint.$t
109 EXTRA_DIST += t/mpint
110
111 ## Table of upper and lower limits of various types of machine integers, as
112 ## multiprecision integers.
113 nodist_archinclude_HEADERS += mplimits.h
114 nodist_libmath_la_SOURCES += mplimits.c
115 CLEANFILES += mplimits.h mplimits.c
116 noinst_PROGRAMS += genlimits
117 genlimits_LDADD = libmpbase.la
118 mplimits.c: genlimits$e
119 $(AM_V_GEN)./genlimits c >mplimits.c.new && \
120 mv mplimits.c.new mplimits.c
121 mplimits.h: genlimits$e
122 $(AM_V_GEN)./genlimits h >mplimits.h.new && \
123 mv mplimits.h.new mplimits.h
124 $(genlimits_OBJECTS): mptypes.h
125 mplimits.lo: mplimits.h
126
127 ## Montgomery reduction, a clever method for modular arithmetic.
128 pkginclude_HEADERS += mpmont.h
129 libmath_la_SOURCES += mpmont.c
130 TESTS += mpmont.$t
131 libmath_la_SOURCES += mpmont-exp.c mpmont-mexp.c mpmont-exp.h
132 TESTS += mpmont-exp.$t mpmont-mexp.$t
133 EXTRA_DIST += t/mpmont
134
135 ## Efficient multiplication of many small numbers.
136 pkginclude_HEADERS += mpmul.h
137 libmath_la_SOURCES += mpmul.c
138 TESTS += mpmul.$t
139
140 ## Generating random numbers.
141 pkginclude_HEADERS += mprand.h
142 libmath_la_SOURCES += mprand.c
143
144 ## Efficient reduction modulo numbers with conveninent binary
145 ## representations.
146 pkginclude_HEADERS += mpreduce.h
147 libmath_la_SOURCES += mpreduce.c mpreduce-exp.h
148 TESTS += mpreduce.$t
149 EXTRA_DIST += t/mpreduce
150
151 ## Iteratiion over the bianry representation of multiprecision integers.
152 pkginclude_HEADERS += mpscan.h
153 libmpbase_la_SOURCES += mpscan.c
154
155 ## Conversion between multiprecision integers and their textual
156 ## representations.
157 pkginclude_HEADERS += mptext.h
158 libmpbase_la_SOURCES += mptext.c
159 TESTS += mptext.$t
160 libmath_la_SOURCES += mptext-dstr.c
161 libmath_la_SOURCES += mptext-file.c
162 libmath_la_SOURCES += mptext-len.c
163 libmpbase_la_SOURCES += mptext-string.c
164 EXTRA_DIST += t/mptext
165
166 ## Basic types used in the representation of multiprecision integers.
167 nodist_archinclude_HEADERS += mptypes.h
168 BUILT_SOURCES += mptypes.h
169 CLEANFILES += mptypes.h
170 noinst_PROGRAMS += mptypes
171 mptypes.h: mptypes$e
172 $(AM_V_GEN)./mptypes >mptypes.h.new && mv mptypes.h.new mptypes.h
173
174 ## Low-level multiprecision arithmetic.
175 pkginclude_HEADERS += mpx.h bitops.h mpw.h
176 libmpbase_la_SOURCES += mpx.c
177 TESTS += mpx.$t
178 libmpbase_la_SOURCES += karatsuba.h mpx-kmul.c mpx-ksqr.c
179 TESTS += mpx-kmul.$t mpx-ksqr.$t
180 noinst_PROGRAMS += bittest
181 TESTS += bittest
182 EXTRA_DIST += t/mpx
183
184 ## A quick-and-dirty parser, used for parsing descriptions of groups, fields,
185 ## etc.
186 pkginclude_HEADERS += qdparse.h
187 libmath_la_SOURCES += qdparse.c
188
189 ## Pollard's `rho' algorithm for determining discrete logarithms.
190 pkginclude_HEADERS += rho.h
191 libmath_la_SOURCES += rho.c
192 TESTS += rho.$t
193
194 ###--------------------------------------------------------------------------
195 ### Prime number checking, searching, and related jobs.
196
197 ## Generating Lim--Lee groups, i.e., unit groups of finite fields without
198 ## small subgroups (except for the obvious ones).
199 pkginclude_HEADERS += limlee.h
200 libmath_la_SOURCES += limlee.c
201
202 ## A table of small prime numbers.
203 nodist_pkginclude_HEADERS += primetab.h
204 nodist_libmath_la_SOURCES += primetab.c
205 CLEANFILES += primetab.h primetab.c
206 BUILT_SOURCES += primetab.h primetab.c
207 noinst_PROGRAMS += genprimes
208 genprimes_LDADD = $(mLib_LIBS)
209 primetab.h: primetab.c
210 primetab.c: genprimes$e
211 $(AM_V_GEN)./genprimes -hprimetab.h -cprimetab.c \
212 -sCATACOMB_PRIMETAB_H \
213 -n256 -t"unsigned short" -iprimetab
214
215 ## Filtering candidate prime numbers by checking for small factors
216 ## efficiently.
217 pkginclude_HEADERS += pfilt.h
218 libmath_la_SOURCES += pfilt.c
219
220 ## Generating prime numbers (and other kinds of numbers which need searching
221 ## for).
222 pkginclude_HEADERS += pgen.h
223 libmath_la_SOURCES += pgen.c
224 libmath_la_SOURCES += pgen-gcd.c
225 libmath_la_SOURCES += pgen-simul.c
226 libmath_la_SOURCES += pgen-stdev.c
227 TESTS += pgen.$t
228 EXTRA_DIST += t/pgen
229
230 ## Finding primitive elements in finite fields.
231 pkginclude_HEADERS += prim.h
232 libmath_la_SOURCES += prim.c
233
234 ## Iterating over all prime numbers from a given starting point.
235 pkginclude_HEADERS += primeiter.h
236 libmath_la_SOURCES += primeiter.c
237 TESTS += primeiter.$t
238 primeiter.lo: wheel.h
239
240 ## The Miller--Rabin primality test.
241 pkginclude_HEADERS += rabin.h
242 libmath_la_SOURCES += rabin.c
243
244 ## Finding `strong' primes, using Gordon's algorithm. Once upon a time,
245 ## products of these kinds of numbers were harder to factor.
246 pkginclude_HEADERS += strongprime.h
247 libmath_la_SOURCES += strongprime.c
248
249 ## A `wheel', used by the prime iteration machinery.
250 nodist_pkginclude_HEADERS += wheel.h
251 nodist_libmath_la_SOURCES += wheel.c
252 CLEANFILES += wheel.h wheel.c
253 noinst_PROGRAMS += genwheel
254 genwheel_LDADD = $(mLib_LIBS)
255 wheel.h: wheel.c
256 wheel.c: genwheel$e
257 $(AM_V_GEN)./genwheel -hwheel.h -cwheel.c \
258 -sCATACOMB_WHEEL_H \
259 -n5 -t"unsigned char" -iwheel
260
261 ###--------------------------------------------------------------------------
262 ### Binary polynomial arithmetic.
263
264 ## User-visible binary polynomial arithmetic.
265 pkginclude_HEADERS += gf.h
266 libmath_la_SOURCES += gf-arith.c
267 TESTS += gf-arith.$t
268 libmath_la_SOURCES += gf-exp.c gf-exp.h
269 libmath_la_SOURCES += gf-gcd.c
270 TESTS += gf-gcd.$t
271 EXTRA_DIST += t/gf
272
273 ## Low-level binary polynomial arithmetic.
274 pkginclude_HEADERS += gfx.h
275 libmath_la_SOURCES += gfx.c
276 TESTS += gfx.$t
277 libmath_la_SOURCES += gfx-kmul.c
278 TESTS += gfx-kmul.$t
279 libmath_la_SOURCES += gfx-sqr.c
280 gfx-sqr.lo: gfx-sqr-tab.h
281 TESTS += gfx-sqr.$t
282 CLEANFILES += gfx-sqr-tab.h
283 noinst_PROGRAMS += gfx-sqr-mktab
284 gfx-sqr-tab.h: gfx-sqr-mktab$e
285 $(AM_V_GEN)./gfx-sqr-mktab >gfx-sqr-tab.h.in && \
286 mv gfx-sqr-tab.h.in gfx-sqr-tab.h
287 EXTRA_DIST += t/gfx
288
289 ## Conversions between normal and polynomial basis representations for binary
290 ## fields.
291 pkginclude_HEADERS += gfn.h
292 libmath_la_SOURCES += gfn.c
293 TESTS += gfn.$t
294 EXTRA_DIST += t/gfn
295
296 ## Efficient reduction modulo sparse polynomials.
297 pkginclude_HEADERS += gfreduce.h
298 libmath_la_SOURCES += gfreduce.c gfreduce-exp.h
299 TESTS += gfreduce.$t
300 EXTRA_DIST += t/gfreduce
301
302 ###--------------------------------------------------------------------------
303 ### Abstractions for various kinds of algebraic objects.
304
305 ## Abstract cyclic groups.
306 pkginclude_HEADERS += group.h group-guts.h
307 libmath_la_SOURCES += group-dstr.c
308 libmath_la_SOURCES += group-exp.c group-exp.h
309 libmath_la_SOURCES += group-file.c
310 libmath_la_SOURCES += group-parse.c
311 libmath_la_SOURCES += group-stdops.c
312 libmath_la_SOURCES += group-string.c
313 libmath_la_SOURCES += g-bin.c
314 libmath_la_SOURCES += g-prime.c
315 libmath_la_SOURCES += g-ec.c
316 EXTRA_DIST += group-test.c
317 TESTS += group-test.$t
318 EXTRA_DIST += t/group
319
320 ## Abstract finite fields.
321 pkginclude_HEADERS += field.h field-guts.h
322 libmath_la_SOURCES += field.c
323 libmath_la_SOURCES += field-exp.c field-exp.h
324 libmath_la_SOURCES += field-parse.c
325 libmath_la_SOURCES += f-binpoly.c
326 libmath_la_SOURCES += f-niceprime.c
327 libmath_la_SOURCES += f-prime.c
328
329 ## Table of built-in binary fields.
330 pkginclude_HEADERS += bintab.h
331 libmath_la_SOURCES += bintab.c
332 CLEANFILES += bintab.c
333 EXTRA_DIST += bintab.in bin-gentab.awk
334 bintab.c: bintab.in bin-gentab.awk mpdump$e
335 $(AM_V_GEN)awk -f $(srcdir)/bin-gentab.awk \
336 <$(srcdir)/bintab.in >bintab.c.new && \
337 mv bintab.c.new bintab.c
338
339 ## Table of built-in prime fields.
340 pkginclude_HEADERS += ptab.h
341 libmath_la_SOURCES += ptab.c
342 CLEANFILES += ptab.c
343 EXTRA_DIST += ptab.in p-gentab.awk
344 ptab.c: ptab.in p-gentab.awk mpdump$e
345 $(AM_V_GEN)awk -f $(srcdir)/p-gentab.awk \
346 <$(srcdir)/ptab.in >ptab.c.new && \
347 mv ptab.c.new ptab.c
348
349 ## A utility for building multiprecision integer constants.
350 noinst_PROGRAMS += mpdump
351 mpdump_LDADD = libmpbase.la
352 $(mpdump_OBJECTS): mptypes.h
353
354 ###--------------------------------------------------------------------------
355 ### Elliptic curve arithmetic.
356
357 ## Basic elliptic curve arithmetic.
358 pkginclude_HEADERS += ec.h ec-guts.h
359 libmath_la_SOURCES += ec.c
360 libmath_la_SOURCES += ec-exp.c ec-exp.h
361 libmath_la_SOURCES += ec-info.c
362 TESTS += ec-info.$t
363 libmath_la_SOURCES += ec-bin.c
364 TESTS += ec-bin.$t
365 libmath_la_SOURCES += ec-prime.c
366 TESTS += ec-prime.$t
367 EXTRA_DIST += t/ec
368
369 ## The standard `raw' encoding (`EC2OSP') of elliptic curve points.
370 pkginclude_HEADERS += ec-raw.h
371 libmath_la_SOURCES += ec-raw.c
372
373 ## Assistance for elliptic-curve keys.
374 pkginclude_HEADERS += ec-keys.h
375 libmath_la_SOURCES += ec-fetch.c
376
377 ## Test infrastructure for elliptic curves.
378 pkginclude_HEADERS += ec-test.h
379 libmath_la_SOURCES += ec-test.c
380 TESTS += ec-test.$t
381
382 ## A table of built-in elliptic curves.
383 pkginclude_HEADERS += ectab.h
384 libmath_la_SOURCES += ectab.c
385 CLEANFILES += ectab.c
386 EXTRA_DIST += ectab.in ec-gentab.awk
387 ectab.c: ectab.in ec-gentab.awk mpdump$e
388 $(AM_V_GEN)awk -f $(srcdir)/ec-gentab.awk \
389 <$(srcdir)/ectab.in >ectab.c.new && \
390 mv ectab.c.new ectab.c
391
392 ###----- That's all, folks --------------------------------------------------