### -*-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 ###-------------------------------------------------------------------------- ### Representation of multiprecision integers. ## The `mpgen' tool for dealing with these things. mpgen = $(srcdir)/mpgen EXTRA_DIST += mpgen AM_V_MPGEN = $(AM_V_MPGEN_$(V)) AM_V_MPGEN_ = $(AM_V_MPGEN_$(AM_DEFAULT_VERBOSITY)) AM_V_MPGEN_0 = @echo " MPGEN $@"; MPGEN = $(AM_V_MPGEN)$(PYTHON) $(mpgen) ## The type information collected by `configure'. CLEANFILES += typeinfo.py EXTRA_DIST += typeinfo.py.in typeinfo.py: $(srcdir)/typeinfo.py.in Makefile $(SUBST) $(srcdir)/typeinfo.py.in >typeinfo.py.new \ type_bits="@type_bits@" \ limits="@limits@" && \ mv typeinfo.py.new typeinfo.py ## The header file containing our representation choices. BUILT_SOURCES += mptypes.h CLEANFILES += mptypes.h nodist_archinclude_HEADERS += mptypes.h mptypes.h: $(mpgen) typeinfo.py $(MPGEN) mptypes >mptypes.h.in && mv mptypes.h.in mptypes.h ## Limits of C types as multiprecision integers. BUILT_SOURCES += mplimits.h mplimits.c CLEANFILES += mplimits.h mplimits.c nodist_archinclude_HEADERS += mplimits.h nodist_libmath_la_SOURCES += mplimits.c mplimits.h: $(mpgen) typeinfo.py $(MPGEN) mplimits_h >mplimits.h.in && mv mplimits.h.in mplimits.h mplimits.c: $(mpgen) typeinfo.py $(MPGEN) mplimits_c >mplimits.c.in && mv mplimits.c.in mplimits.c ###-------------------------------------------------------------------------- ### Main multiprecision integer library. ## 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 libmath_la_SOURCES += mp-arith.c TESTS += mp-arith.$t libmath_la_SOURCES += mp-const.c libmath_la_SOURCES += mp-exp.c mp-exp.h libmath_la_SOURCES += mp-gcd.c TESTS += mp-gcd.$t libmath_la_SOURCES += mp-io.c libmath_la_SOURCES += mp-jacobi.c TESTS += mp-jacobi.$t libmath_la_SOURCES += mp-mem.c libmath_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 libmath_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 ## 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 libmath_la_SOURCES += mpscan.c ## Conversion between multiprecision integers and their textual ## representations. pkginclude_HEADERS += mptext.h libmath_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 libmath_la_SOURCES += mptext-string.c EXTRA_DIST += t/mptext ## Low-level multiprecision arithmetic. pkginclude_HEADERS += mpx.h bitops.h mpw.h libmath_la_SOURCES += mpx.c TESTS += mpx.$t libmath_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. pkginclude_HEADERS += $(precomp)/primetab.h libmath_la_SOURCES += $(precomp)/primetab.c PRECOMPS += $(precomp)/primetab.h $(precomp)/primetab.c PRECOMP_PROGS += genprimes genprimes_LDADD = $(mLib_LIBS) if !CROSS_COMPILING $(precomp)/primetab.h: $(precomp)/primetab.c $(precomp)/primetab.c: $(AM_V_at)$(MKDIR_P) $(precomp) $(AM_V_at)$(MAKE) genprimes$e $(AM_V_GEN)./genprimes -sCATACOMB_PRIMETAB_H \ -h$(precomp)/primetab.h -c$(precomp)/primetab.c \ -n256 -t"unsigned short" -iprimetab endif ## 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: $(precomp)/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. pkginclude_HEADERS += $(precomp)/wheel.h libmath_la_SOURCES += $(precomp)/wheel.c PRECOMPS += $(precomp)/wheel.h $(precomp)/wheel.c PRECOMP_PROGS += genwheel genwheel_LDADD = $(mLib_LIBS) if !CROSS_COMPILING $(precomp)/wheel.h: $(precomp)/wheel.c $(precomp)/wheel.c: $(AM_V_at)$(MKDIR_P) $(precomp) $(AM_V_at)$(MAKE) genwheel$e $(AM_V_GEN)./genwheel -sCATACOMB_WHEEL_H \ -h$(precomp)/wheel.h -c$(precomp)/wheel.c \ -n5 -t"unsigned char" -iwheel endif ###-------------------------------------------------------------------------- ### 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 $(precomp)/gfx-sqrtab.c PRECOMPS += $(precomp)/gfx-sqrtab.c PRECOMP_PROGS += gfx-sqr-mktab if !CROSS_COMPILING $(precomp)/gfx-sqrtab.c: $(AM_V_at)$(MKDIR_P) $(precomp) $(AM_V_at)$(MAKE) gfx-sqr-mktab$e $(AM_V_GEN)./gfx-sqr-mktab >$(precomp)/gfx-sqrtab.c.new && \ mv $(precomp)/gfx-sqrtab.c.new $(precomp)/gfx-sqrtab.c endif TESTS += gfx-sqr.$t 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 nodist_libmath_la_SOURCES += bintab.c CLEANFILES += bintab.c EXTRA_DIST += bintab.in bintab.c: $(mpgen) typeinfo.py bintab.in $(MPGEN) bintab $(srcdir)/bintab.in >bintab.c.new && \ mv bintab.c.new bintab.c ## Table of built-in prime fields. pkginclude_HEADERS += ptab.h nodist_libmath_la_SOURCES += ptab.c CLEANFILES += ptab.c EXTRA_DIST += ptab.in ptab.c: $(mpgen) typeinfo.py ptab.in $(MPGEN) ptab $(srcdir)/ptab.in >ptab.c.new && \ mv ptab.c.new ptab.c ###-------------------------------------------------------------------------- ### 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 ## Table of built-in elliptic-curve groups. pkginclude_HEADERS += ectab.h nodist_libmath_la_SOURCES += ectab.c CLEANFILES += ectab.c EXTRA_DIST += ectab.in ectab.c: $(mpgen) typeinfo.py ectab.in $(MPGEN) ectab $(srcdir)/ectab.in >ectab.c.new && \ mv ectab.c.new ectab.c ###----- That's all, folks --------------------------------------------------