Rearrange the file tree.
[u/mdw/catacomb] / math / Makefile.am
diff --git a/math/Makefile.am b/math/Makefile.am
new file mode 100644 (file)
index 0000000..5bb546c
--- /dev/null
@@ -0,0 +1,392 @@
+### -*-makefile-*-
+###
+### Build script for mathematical infrastructure
+###
+### (c) 2013 Straylight/Edgeware
+###
+
+###----- Licensing notice ---------------------------------------------------
+###
+### This file is part of Catacomb.
+###
+### Catacomb is free software; you can redistribute it and/or modify
+### it under the terms of the GNU Library General Public License as
+### published by the Free Software Foundation; either version 2 of the
+### License, or (at your option) any later version.
+###
+### Catacomb is distributed in the hope that it will be useful,
+### but WITHOUT ANY WARRANTY; without even the implied warranty of
+### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+### GNU Library General Public License for more details.
+###
+### You should have received a copy of the GNU Library General Public
+### License along with Catacomb; if not, write to the Free
+### Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+### MA 02111-1307, USA.
+
+include $(top_srcdir)/vars.am
+
+noinst_LTLIBRARIES      = libmath.la
+libmath_la_SOURCES      =
+nodist_libmath_la_SOURCES =
+libmath_la_LIBADD       =
+
+TEST_LIBS               = libmath.la
+
+###--------------------------------------------------------------------------
+### Main multiprecision integer library.
+
+## This library is unfortunately intertwined with some of the code generation
+## programs, so we must be rather careful.  The important bits of the maths
+## library needed by these programs is separated out into `libmpbase'.  There
+## is work going on to fix this unpleasant situation by generating the
+## relevant files from Python scripts rather than C programs, using
+## information gathered by `configure'.
+noinst_LTLIBRARIES     += libmpbase.la
+libmath_la_LIBADD      += libmpbase.la
+libmpbase_la_LIBADD     = $(mLib_LIBS)
+libmpbase_la_SOURCES    =
+$(libmpbase_la_OBJECTS): mptypes.h
+
+## Additional buffer I/O functions for mathematical objects.
+pkginclude_HEADERS     += buf.h
+libmath_la_SOURCES     += buf.c
+
+## Infrastructure for fast exponentiation.
+pkginclude_HEADERS     += exp.h
+libmath_la_SOURCES     += exp.c
+
+## Main user-visible multiprecision arithmetic.
+pkginclude_HEADERS     += mp.h
+libmpbase_la_SOURCES   += mp-arith.c
+TESTS                  += mp-arith.$t
+libmpbase_la_SOURCES   += mp-const.c
+libmath_la_SOURCES     += mp-exp.c mp-exp.h
+libmath_la_SOURCES     += mp-gcd.c
+TESTS                  += mp-gcd.$t
+libmpbase_la_SOURCES   += mp-io.c
+libmath_la_SOURCES     += mp-jacobi.c
+TESTS                  += mp-jacobi.$t
+libmpbase_la_SOURCES   += mp-mem.c
+libmpbase_la_SOURCES   += mp-misc.c
+libmath_la_SOURCES     += mp-modexp.c
+TESTS                  += mp-modexp.$t
+libmath_la_SOURCES     += mp-modsqrt.c
+TESTS                  += mp-modsqrt.$t
+libmath_la_SOURCES     += mp-sqrt.c
+TESTS                  += mp-sqrt.$t
+libmath_la_SOURCES     += mp-test.c
+EXTRA_DIST             += t/mp
+
+## Computing Fibonacci numbers.
+pkginclude_HEADERS     += mp-fibonacci.h
+libmath_la_SOURCES     += mp-fibonacci.c
+TESTS                  += mp-fibonacci.$t
+
+## Special memory allocation for multiprecision integers.
+pkginclude_HEADERS     += mparena.h
+libmpbase_la_SOURCES   += mparena.c
+
+## Barrett reduction, an efficient method for modular reduction.
+pkginclude_HEADERS     += mpbarrett.h
+libmath_la_SOURCES     += mpbarrett.c
+TESTS                  += mpbarrett.$t
+libmath_la_SOURCES     += mpbarrett-exp.c mpbarrett-mexp.c mpbarrett-exp.h
+TESTS                  += mpbarrett-exp.$t mpbarrett-mexp.$t
+TESTS                  += mpbarrett.$t
+EXTRA_DIST             += t/mpbarrett
+
+## Solving congruences using the Chinese Remainder Theorem.
+pkginclude_HEADERS     += mpcrt.h
+libmath_la_SOURCES     += mpcrt.c
+TESTS                  += mpcrt.$t
+EXTRA_DIST             += t/mpcrt
+
+## Conversions between machine-native and multiprecision integers.
+pkginclude_HEADERS     += mpint.h
+libmath_la_SOURCES     += mpint.c
+TESTS                  += mpint.$t
+EXTRA_DIST             += t/mpint
+
+## Table of upper and lower limits of various types of machine integers, as
+## multiprecision integers.
+nodist_archinclude_HEADERS += mplimits.h
+nodist_libmath_la_SOURCES += mplimits.c
+CLEANFILES             += mplimits.h mplimits.c
+noinst_PROGRAMS                += genlimits
+genlimits_LDADD                 = libmpbase.la
+mplimits.c: genlimits$e
+       $(AM_V_GEN)./genlimits c >mplimits.c.new && \
+               mv mplimits.c.new mplimits.c
+mplimits.h: genlimits$e
+       $(AM_V_GEN)./genlimits h >mplimits.h.new && \
+               mv mplimits.h.new mplimits.h
+$(genlimits_OBJECTS): mptypes.h
+mplimits.lo: mplimits.h
+
+## Montgomery reduction, a clever method for modular arithmetic.
+pkginclude_HEADERS     += mpmont.h
+libmath_la_SOURCES     += mpmont.c
+TESTS                  += mpmont.$t
+libmath_la_SOURCES     += mpmont-exp.c mpmont-mexp.c mpmont-exp.h
+TESTS                  += mpmont-exp.$t mpmont-mexp.$t
+EXTRA_DIST             += t/mpmont
+
+## Efficient multiplication of many small numbers.
+pkginclude_HEADERS     += mpmul.h
+libmath_la_SOURCES     += mpmul.c
+TESTS                  += mpmul.$t
+
+## Generating random numbers.
+pkginclude_HEADERS     += mprand.h
+libmath_la_SOURCES     += mprand.c
+
+## Efficient reduction modulo numbers with conveninent binary
+## representations.
+pkginclude_HEADERS     += mpreduce.h
+libmath_la_SOURCES     += mpreduce.c mpreduce-exp.h
+TESTS                  += mpreduce.$t
+EXTRA_DIST             += t/mpreduce
+
+## Iteratiion over the bianry representation of multiprecision integers.
+pkginclude_HEADERS     += mpscan.h
+libmpbase_la_SOURCES   += mpscan.c
+
+## Conversion between multiprecision integers and their textual
+## representations.
+pkginclude_HEADERS     += mptext.h
+libmpbase_la_SOURCES   += mptext.c
+TESTS                  += mptext.$t
+libmath_la_SOURCES     += mptext-dstr.c
+libmath_la_SOURCES     += mptext-file.c
+libmath_la_SOURCES     += mptext-len.c
+libmpbase_la_SOURCES   += mptext-string.c
+EXTRA_DIST             += t/mptext
+
+## Basic types used in the representation of multiprecision integers.
+nodist_archinclude_HEADERS += mptypes.h
+BUILT_SOURCES          += mptypes.h
+CLEANFILES             += mptypes.h
+noinst_PROGRAMS                += mptypes
+mptypes.h: mptypes$e
+       $(AM_V_GEN)./mptypes >mptypes.h.new && mv mptypes.h.new mptypes.h
+
+## Low-level multiprecision arithmetic.
+pkginclude_HEADERS     += mpx.h bitops.h mpw.h
+libmpbase_la_SOURCES   += mpx.c
+TESTS                  += mpx.$t
+libmpbase_la_SOURCES   += karatsuba.h mpx-kmul.c mpx-ksqr.c
+TESTS                  += mpx-kmul.$t mpx-ksqr.$t
+noinst_PROGRAMS                += bittest
+TESTS                  += bittest
+EXTRA_DIST             += t/mpx
+
+## A quick-and-dirty parser, used for parsing descriptions of groups, fields,
+## etc.
+pkginclude_HEADERS     += qdparse.h
+libmath_la_SOURCES     += qdparse.c
+
+## Pollard's `rho' algorithm for determining discrete logarithms.
+pkginclude_HEADERS     += rho.h
+libmath_la_SOURCES     += rho.c
+TESTS                  += rho.$t
+
+###--------------------------------------------------------------------------
+### Prime number checking, searching, and related jobs.
+
+## Generating Lim--Lee groups, i.e., unit groups of finite fields without
+## small subgroups (except for the obvious ones).
+pkginclude_HEADERS     += limlee.h
+libmath_la_SOURCES     += limlee.c
+
+## A table of small prime numbers.
+nodist_pkginclude_HEADERS += primetab.h
+nodist_libmath_la_SOURCES += primetab.c
+CLEANFILES             += primetab.h primetab.c
+BUILT_SOURCES          += primetab.h primetab.c
+noinst_PROGRAMS                += genprimes
+genprimes_LDADD                 = $(mLib_LIBS)
+primetab.h: primetab.c
+primetab.c: genprimes$e
+       $(AM_V_GEN)./genprimes -hprimetab.h -cprimetab.c \
+               -sCATACOMB_PRIMETAB_H \
+               -n256 -t"unsigned short" -iprimetab
+
+## Filtering candidate prime numbers by checking for small factors
+## efficiently.
+pkginclude_HEADERS     += pfilt.h
+libmath_la_SOURCES     += pfilt.c
+
+## Generating prime numbers (and other kinds of numbers which need searching
+## for).
+pkginclude_HEADERS     += pgen.h
+libmath_la_SOURCES     += pgen.c
+libmath_la_SOURCES     += pgen-gcd.c
+libmath_la_SOURCES     += pgen-simul.c
+libmath_la_SOURCES     += pgen-stdev.c
+TESTS                  += pgen.$t
+EXTRA_DIST             += t/pgen
+
+## Finding primitive elements in finite fields.
+pkginclude_HEADERS     += prim.h
+libmath_la_SOURCES     += prim.c
+
+## Iterating over all prime numbers from a given starting point.
+pkginclude_HEADERS     += primeiter.h
+libmath_la_SOURCES     += primeiter.c
+TESTS                  += primeiter.$t
+primeiter.lo: wheel.h
+
+## The Miller--Rabin primality test.
+pkginclude_HEADERS     += rabin.h
+libmath_la_SOURCES     += rabin.c
+
+## Finding `strong' primes, using Gordon's algorithm.  Once upon a time,
+## products of these kinds of numbers were harder to factor.
+pkginclude_HEADERS     += strongprime.h
+libmath_la_SOURCES     += strongprime.c
+
+## A `wheel', used by the prime iteration machinery.
+nodist_pkginclude_HEADERS += wheel.h
+nodist_libmath_la_SOURCES += wheel.c
+CLEANFILES             += wheel.h wheel.c
+noinst_PROGRAMS                += genwheel
+genwheel_LDADD          = $(mLib_LIBS)
+wheel.h: wheel.c
+wheel.c: genwheel$e
+       $(AM_V_GEN)./genwheel -hwheel.h -cwheel.c \
+               -sCATACOMB_WHEEL_H \
+               -n5 -t"unsigned char" -iwheel
+
+###--------------------------------------------------------------------------
+### Binary polynomial arithmetic.
+
+## User-visible binary polynomial arithmetic.
+pkginclude_HEADERS     += gf.h
+libmath_la_SOURCES     += gf-arith.c
+TESTS                  += gf-arith.$t
+libmath_la_SOURCES     += gf-exp.c gf-exp.h
+libmath_la_SOURCES     += gf-gcd.c
+TESTS                  += gf-gcd.$t
+EXTRA_DIST             += t/gf
+
+## Low-level binary polynomial arithmetic.
+pkginclude_HEADERS     += gfx.h
+libmath_la_SOURCES     += gfx.c
+TESTS                  += gfx.$t
+libmath_la_SOURCES     += gfx-kmul.c
+TESTS                  += gfx-kmul.$t
+libmath_la_SOURCES     += gfx-sqr.c
+gfx-sqr.lo: gfx-sqr-tab.h
+TESTS                  += gfx-sqr.$t
+CLEANFILES             += gfx-sqr-tab.h
+noinst_PROGRAMS                += gfx-sqr-mktab
+gfx-sqr-tab.h: gfx-sqr-mktab$e
+       $(AM_V_GEN)./gfx-sqr-mktab >gfx-sqr-tab.h.in && \
+               mv gfx-sqr-tab.h.in gfx-sqr-tab.h
+EXTRA_DIST             += t/gfx
+
+## Conversions between normal and polynomial basis representations for binary
+## fields.
+pkginclude_HEADERS     += gfn.h
+libmath_la_SOURCES     += gfn.c
+TESTS                  += gfn.$t
+EXTRA_DIST             += t/gfn
+
+## Efficient reduction modulo sparse polynomials.
+pkginclude_HEADERS     += gfreduce.h
+libmath_la_SOURCES     += gfreduce.c gfreduce-exp.h
+TESTS                  += gfreduce.$t
+EXTRA_DIST             += t/gfreduce
+
+###--------------------------------------------------------------------------
+### Abstractions for various kinds of algebraic objects.
+
+## Abstract cyclic groups.
+pkginclude_HEADERS     += group.h group-guts.h
+libmath_la_SOURCES     += group-dstr.c
+libmath_la_SOURCES     += group-exp.c group-exp.h
+libmath_la_SOURCES     += group-file.c
+libmath_la_SOURCES     += group-parse.c
+libmath_la_SOURCES     += group-stdops.c
+libmath_la_SOURCES     += group-string.c
+libmath_la_SOURCES     += g-bin.c
+libmath_la_SOURCES     += g-prime.c
+libmath_la_SOURCES     += g-ec.c
+EXTRA_DIST             += group-test.c
+TESTS                  += group-test.$t
+EXTRA_DIST             += t/group
+
+## Abstract finite fields.
+pkginclude_HEADERS     += field.h field-guts.h
+libmath_la_SOURCES     += field.c
+libmath_la_SOURCES     += field-exp.c field-exp.h
+libmath_la_SOURCES     += field-parse.c
+libmath_la_SOURCES     += f-binpoly.c
+libmath_la_SOURCES     += f-niceprime.c
+libmath_la_SOURCES     += f-prime.c
+
+## Table of built-in binary fields.
+pkginclude_HEADERS     += bintab.h
+libmath_la_SOURCES     += bintab.c
+CLEANFILES             += bintab.c
+EXTRA_DIST             += bintab.in bin-gentab.awk
+bintab.c: bintab.in bin-gentab.awk mpdump$e
+       $(AM_V_GEN)awk -f $(srcdir)/bin-gentab.awk \
+               <$(srcdir)/bintab.in >bintab.c.new && \
+       mv bintab.c.new bintab.c
+
+## Table of built-in prime fields.
+pkginclude_HEADERS     += ptab.h
+libmath_la_SOURCES     += ptab.c
+CLEANFILES             += ptab.c
+EXTRA_DIST             += ptab.in p-gentab.awk
+ptab.c: ptab.in p-gentab.awk mpdump$e
+       $(AM_V_GEN)awk -f $(srcdir)/p-gentab.awk \
+               <$(srcdir)/ptab.in >ptab.c.new && \
+       mv ptab.c.new ptab.c
+
+## A utility for building multiprecision integer constants.
+noinst_PROGRAMS                += mpdump
+mpdump_LDADD            = libmpbase.la
+$(mpdump_OBJECTS): mptypes.h
+
+###--------------------------------------------------------------------------
+### Elliptic curve arithmetic.
+
+## Basic elliptic curve arithmetic.
+pkginclude_HEADERS     += ec.h ec-guts.h
+libmath_la_SOURCES     += ec.c
+libmath_la_SOURCES     += ec-exp.c ec-exp.h
+libmath_la_SOURCES     += ec-info.c
+TESTS                  += ec-info.$t
+libmath_la_SOURCES     += ec-bin.c
+TESTS                  += ec-bin.$t
+libmath_la_SOURCES     += ec-prime.c
+TESTS                  += ec-prime.$t
+EXTRA_DIST             += t/ec
+
+## The standard `raw' encoding (`EC2OSP') of elliptic curve points.
+pkginclude_HEADERS     += ec-raw.h
+libmath_la_SOURCES     += ec-raw.c
+
+## Assistance for elliptic-curve keys.
+pkginclude_HEADERS     += ec-keys.h
+libmath_la_SOURCES     += ec-fetch.c
+
+## Test infrastructure for elliptic curves.
+pkginclude_HEADERS     += ec-test.h
+libmath_la_SOURCES     += ec-test.c
+TESTS                  += ec-test.$t
+
+## A table of built-in elliptic curves.
+pkginclude_HEADERS     += ectab.h
+libmath_la_SOURCES     += ectab.c
+CLEANFILES             += ectab.c
+EXTRA_DIST             += ectab.in ec-gentab.awk
+ectab.c: ectab.in ec-gentab.awk mpdump$e
+       $(AM_V_GEN)awk -f $(srcdir)/ec-gentab.awk \
+               <$(srcdir)/ectab.in >ectab.c.new && \
+       mv ectab.c.new ectab.c
+
+###----- That's all, folks --------------------------------------------------