X-Git-Url: https://git.distorted.org.uk/u/mdw/catacomb/blobdiff_plain/0f00dc4c8eb47e67bc0f148c2dd109f73a451e0a..3e248c3b5b309bc03eb5f70762d3f5671d51f996:/math/Makefile.am diff --git a/math/Makefile.am b/math/Makefile.am index 5bb546c..7cabf89 100644 --- a/math/Makefile.am +++ b/math/Makefile.am @@ -34,19 +34,44 @@ libmath_la_LIBADD = TEST_LIBS = libmath.la ###-------------------------------------------------------------------------- -### Main multiprecision integer library. +### 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 -## 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 +###-------------------------------------------------------------------------- +### Main multiprecision integer library. ## Additional buffer I/O functions for mathematical objects. pkginclude_HEADERS += buf.h @@ -58,17 +83,17 @@ libmath_la_SOURCES += exp.c ## Main user-visible multiprecision arithmetic. pkginclude_HEADERS += mp.h -libmpbase_la_SOURCES += mp-arith.c +libmath_la_SOURCES += mp-arith.c TESTS += mp-arith.$t -libmpbase_la_SOURCES += mp-const.c +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 -libmpbase_la_SOURCES += mp-io.c +libmath_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-mem.c +libmath_la_SOURCES += mp-misc.c libmath_la_SOURCES += mp-modexp.c TESTS += mp-modexp.$t libmath_la_SOURCES += mp-modsqrt.c @@ -85,7 +110,7 @@ TESTS += mp-fibonacci.$t ## Special memory allocation for multiprecision integers. pkginclude_HEADERS += mparena.h -libmpbase_la_SOURCES += mparena.c +libmath_la_SOURCES += mparena.c ## Barrett reduction, an efficient method for modular reduction. pkginclude_HEADERS += mpbarrett.h @@ -108,22 +133,6 @@ 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 @@ -150,32 +159,24 @@ EXTRA_DIST += t/mpreduce ## Iteratiion over the bianry representation of multiprecision integers. pkginclude_HEADERS += mpscan.h -libmpbase_la_SOURCES += mpscan.c +libmath_la_SOURCES += mpscan.c ## Conversion between multiprecision integers and their textual ## representations. pkginclude_HEADERS += mptext.h -libmpbase_la_SOURCES += mptext.c +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 -libmpbase_la_SOURCES += mptext-string.c +libmath_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 +libmath_la_SOURCES += mpx.c TESTS += mpx.$t -libmpbase_la_SOURCES += karatsuba.h mpx-kmul.c mpx-ksqr.c +libmath_la_SOURCES += karatsuba.h mpx-kmul.c mpx-ksqr.c TESTS += mpx-kmul.$t mpx-ksqr.$t noinst_PROGRAMS += bittest TESTS += bittest @@ -200,17 +201,20 @@ 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 +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) -primetab.h: primetab.c -primetab.c: genprimes$e - $(AM_V_GEN)./genprimes -hprimetab.h -cprimetab.c \ - -sCATACOMB_PRIMETAB_H \ +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. @@ -235,7 +239,7 @@ libmath_la_SOURCES += prim.c pkginclude_HEADERS += primeiter.h libmath_la_SOURCES += primeiter.c TESTS += primeiter.$t -primeiter.lo: wheel.h +primeiter.lo: $(precomp)/wheel.h ## The Miller--Rabin primality test. pkginclude_HEADERS += rabin.h @@ -247,16 +251,20 @@ 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 +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) -wheel.h: wheel.c -wheel.c: genwheel$e - $(AM_V_GEN)./genwheel -hwheel.h -cwheel.c \ - -sCATACOMB_WHEEL_H \ +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. @@ -276,14 +284,17 @@ 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 +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 -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 @@ -328,28 +339,21 @@ libmath_la_SOURCES += f-prime.c ## Table of built-in binary fields. pkginclude_HEADERS += bintab.h -libmath_la_SOURCES += bintab.c +nodist_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 +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 -libmath_la_SOURCES += ptab.c +nodist_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 +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. @@ -379,14 +383,13 @@ pkginclude_HEADERS += ec-test.h libmath_la_SOURCES += ec-test.c TESTS += ec-test.$t -## A table of built-in elliptic curves. +## Table of built-in elliptic-curve groups. pkginclude_HEADERS += ectab.h -libmath_la_SOURCES += ectab.c +nodist_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 +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 --------------------------------------------------