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
## 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
## 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
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
## 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
## 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.
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 --------------------------------------------------