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