File 0001-build-provide-autotools-files.patch of Package flint
From bd27c18fc4f70be8407e72d398978dca1d9ad61e Mon Sep 17 00:00:00 2001
From: Jan Engelhardt <jengelh@inai.de>
Date: Sat, 8 Dec 2012 22:32:11 +0100
Subject: [PATCH] build: provide autotools files
---
.gitignore | 32 +++++----
Makefile.am | 42 ++++++++++++
autofiles.sh | 51 +++++++++++++++
autogen.sh | 5 ++
configure.ac | 147 ++++++++++++++++++++++++++++++++++++++++++
fft_tuning.h | 9 +++
fft_tuning32.h | 19 ++++++
fft_tuning32.in | 19 ------
fft_tuning64.h | 19 ++++++
fft_tuning64.in | 19 ------
fmpz-conversions-reentrant.h | 10 +++
fmpz-conversions-reentrant.in | 10 ---
fmpz-conversions-single.h | 10 +++
fmpz-conversions-single.in | 10 ---
fmpz-conversions.h | 6 ++
m4/.gitignore | 2 +
16 files changed, 341 insertions(+), 69 deletions(-)
create mode 100644 Makefile.am
create mode 100755 autofiles.sh
create mode 100755 autogen.sh
create mode 100644 configure.ac
create mode 100644 fft_tuning.h
create mode 100644 fft_tuning32.h
delete mode 100644 fft_tuning32.in
create mode 100644 fft_tuning64.h
delete mode 100644 fft_tuning64.in
create mode 100644 fmpz-conversions-reentrant.h
delete mode 100644 fmpz-conversions-reentrant.in
create mode 100644 fmpz-conversions-single.h
delete mode 100644 fmpz-conversions-single.in
create mode 100644 fmpz-conversions.h
create mode 100644 m4/.gitignore
diff --git a/Makefile.am b/Makefile.am
new file mode 100644
index 0000000..99e517c
--- /dev/null
+++ b/Makefile.am
@@ -0,0 +1,42 @@
+# -*- Makefile -*-
+
+ACLOCAL_AMFLAGS = -I m4
+
+include Mkinclude.am
+
+AM_CPPFLAGS = -DFLINT_CPIMPORT=\"${pkgdatadir}/CPimport.txt\" -DFLINT_DLL=__attribute__\(\(visibility\(\"default\"\)\)\)
+AM_CFLAGS = -ansi -pedantic -Wall -fvisibility=hidden ${FLINT_TUNE} ${FLINT_POPCNT}
+AM_CXXFLAGS = ${AM_CFLAGS} -std=gnu++11
+
+BUILT_SOURCES = flint-config.h build/CPimport.h
+
+SOURCES = printf.c fprintf.c sprintf.c scanf.c fscanf.c sscanf.c clz_tab.c memory_manager.c version.c profiler.c thread_support.c exception.c
+
+pkginclude_HEADERS = ${cwd_headers}
+
+lib_LTLIBRARIES = libflint.la
+noinst_LTLIBRARIES = ${libflint_im}
+libflint_la_SOURCES = ${lib_sources} ${SOURCES}
+libflint_la_LIBADD = ${libflint_im} -lm -lpthread ${mpfr_LIBS} ${mpir_LIBS}
+
+if ENABLE_REENTRANT
+libflint_la_SOURCES += fmpz/link/fmpz_reentrant.c
+else
+libflint_la_SOURCES += fmpz/link/fmpz_single.c
+endif
+
+if WITH_NTL
+libflint_la_SOURCES += interfaces/NTL-interface.cpp
+libflint_la_LIBADD += ${ntl_LIBS}
+endif
+
+if WITH_BLAS
+libflint_la_LIBADD += ${blas_LIBS}
+endif
+
+build/CPimport.h: ${srcdir}/qadic/CPimport.txt
+ @${MKDIR_P} build
+ ${AM_V_GEN}sed "s/ /,/g;s/.*/&,/g" $< >$@
+
+flint-config.h: config.h
+ grep FLINT <$< >$@
diff --git a/autofiles.sh b/autofiles.sh
new file mode 100755
index 0000000..42a0b55
--- /dev/null
+++ b/autofiles.sh
@@ -0,0 +1,51 @@
+#!/bin/sh
+#
+# Expand wildcards, gobble up all sources and refresh Mkinclude.am.
+# If a Makefile already exists at the time of running autofiles.sh,
+# autoreconf/configure need not be called again.
+#
+BUILD_DIRS="aprcl ulong_extras long_extras perm fmpz fmpz_vec fmpz_poly \
+ fmpq_poly fmpz_mat fmpz_lll mpfr_vec mpfr_mat mpf_vec mpf_mat nmod_vec nmod_poly \
+ nmod_poly_factor arith mpn_extras nmod_mat fmpq fmpq_vec fmpq_mat padic \
+ fmpz_poly_q fmpz_poly_mat nmod_poly_mat fmpz_mod_poly \
+ fmpz_mod_poly_factor fmpz_factor fmpz_poly_factor fft qsieve \
+ double_extras d_vec d_mat padic_poly padic_mat qadic \
+ fq fq_vec fq_mat fq_poly fq_poly_factor\
+ fq_nmod fq_nmod_vec fq_nmod_mat fq_nmod_poly fq_nmod_poly_factor \
+ fq_zech fq_zech_vec fq_zech_mat fq_zech_poly fq_zech_poly_factor"
+
+exec >Mkinclude.am;
+echo "# -*- Makefile -*- ";
+
+echo "bd_headers = \\";
+for i in $BUILD_DIRS; do
+ echo " $i.h \\";
+done;
+echo ' $(emptyonpurpose)';
+
+echo "cwd_headers = \\";
+for i in *.h; do
+ echo " $i \\";
+done;
+echo ' $(emptyonpurpose)';
+
+wcdir ()
+{
+ echo "$1 = \\";
+ shift;
+ find "$@" -maxdepth 1 -type f -name "*.c" -printf '\t%p \\\n' | sort;
+ echo '$(empty)';
+}
+
+libflint_im=""
+for i in $BUILD_DIRS; do
+ # there are quite a lot of .lo files (2414), and building with
+ # intermediate libs reduces the link time of the whole project from
+ # 1m53s to 32s (2600K), less with make -j (e.g. 12s on -j8)
+ wcdir "libflint_${i}_la_SOURCES" "$i"
+ libflint_im="$libflint_im libflint_${i}.la"
+done
+echo "libflint_im = $libflint_im"
+wcdir exmp_sources examples
+wcdir test_sources test
+wcdir prof_sources profile
diff --git a/autogen.sh b/autogen.sh
new file mode 100755
index 0000000..82cf41a
--- /dev/null
+++ b/autogen.sh
@@ -0,0 +1,5 @@
+#!/bin/sh
+
+./autofiles.sh;
+autoreconf -fi;
+rm -Rf autom4te.cache;
diff --git a/configure.ac b/configure.ac
new file mode 100644
index 0000000..ee3307c
--- /dev/null
+++ b/configure.ac
@@ -0,0 +1,147 @@
+AC_INIT([flint], [3.0])
+AC_CONFIG_AUX_DIR([build-aux])
+AC_CONFIG_HEADERS([config.h])
+AC_CONFIG_MACRO_DIR([m4])
+AC_CANONICAL_HOST
+AM_INIT_AUTOMAKE([-Wall foreign subdir-objects tar-pax no-dist-gzip dist-xz])
+AC_PROG_CC
+AM_PROG_CC_C_O
+AC_PROG_CXX
+m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
+AC_PROG_LIBTOOL
+
+
+dnl
+dnl Various tuning parameters
+dnl
+AC_MSG_CHECKING([for some "tuning" parameters])
+case "$host" in
+ x86_64-*-linux*) FLINT_TUNE="-funroll-loops";;
+ powerpc-*-darwin*|ppc-*-darwin*) FLINT_TUNE="-funroll-loops";;
+ powerpc64-*|ppc64-*) FLINT_TUNE="-m64 -mcpu=970 -mtune=970 -mpowerpc64 -falign-loops=16 -falign-labels=16 -falign-jumps=16";;
+ #
+ # -funroll-loops crashes the build on itanium under GCC-4.2.1,
+ # as reported by Kate Minola.
+ #
+ ia64-*) FLINT_TUNE="";;
+ *) FLINT_TUNE="-funroll-loops";;
+esac
+AC_MSG_RESULT([$FLINT_TUNE])
+AC_SUBST([FLINT_TUNE])
+
+AH_TEMPLATE([FLINT_REENTRANT], [Set to 1 if reentrant flint is desired])
+AC_ARG_ENABLE([reentrant],
+ [AS_HELP_STRING([--enable-reentrant], [Enable reentrant code])],
+ [
+ AC_DEFINE([FLINT_REENTRANT], [1])
+ AM_CONDITIONAL([ENABLE_REENTRANT], [true])
+ ],
+ [
+ AC_DEFINE([FLINT_REENTRANT], [0])
+ AM_CONDITIONAL([ENABLE_REENTRANT], [false])
+ ])
+
+
+dnl
+dnl popcount builtin and compiler flags
+dnl
+FLINT_POPCNT=""
+AH_TEMPLATE([POPCNT_INTRINSICS], [Define to 1 if __builtin_popcountl is available])
+AC_MSG_CHECKING([__builtin_popcountl])
+AC_COMPILE_IFELSE(
+ [AC_LANG_SOURCE([
+ int main(int argc, char **argv)
+ {
+ return __builtin_popcountl(argc) == 100;
+ }
+ ])],
+ [
+ AC_MSG_RESULT([yes])
+ AC_DEFINE([POPCNT_INTRINSICS], [1])
+ FLINT_POPCNT=1
+ ],
+ [
+ AC_MSG_RESULT([no])
+ ])
+AS_IF([test "$FLINT_POPCNT" = "1"],
+ [
+ AC_MSG_CHECKING([$CC -mpopcnt])
+ saved_CFLAGS="$CFLAGS"; CFLAGS="$CFLAGS -mpopcnt";
+ AC_COMPILE_IFELSE([AC_LANG_SOURCE([])],
+ [AC_MSG_RESULT([yes]); FLINT_POPCNT="-mpopcnt";],
+ [AC_MSG_RESULT([no]); FLINT_POPCNT=""])
+ CFLAGS="$saved_CFLAGS";
+ ],
+ [FLINT_POPCNT=""])
+AC_SUBST([FLINT_POPCNT])
+
+
+dnl
+dnl NTL interface
+dnl
+AC_MSG_CHECKING([whether to enable NTL])
+AC_ARG_WITH([ntl],
+ [AS_HELP_STRING([--with-ntl], [Use NTL [[no]]])],
+ [with_ntl="$withval"],
+ [with_ntl="no"])
+AS_IF([test "x$with_ntl" = "xno"],
+ [
+ AM_CONDITIONAL([WITH_NTL], [false])
+ AC_MSG_RESULT([no])
+ ],
+ [
+ AC_MSG_RESULT([yes])
+ saved_LIBS="$LIBS"; LIBS="$LIBS -lntl";
+ AC_LANG_PUSH([C++])
+ AC_LINK_IFELSE([
+ AC_LANG_SOURCE([
+ #include <NTL/lip.h>
+ int main(void) { _ntl_gsetlength; }
+ ])],
+ [ntl_LIBS="-lntl"],
+ [AC_MSG_ERROR([NTL not found.])]
+ )
+ LIBS="$saved_LIBS";
+ AC_LANG_POP([C++])
+ AM_CONDITIONAL([WITH_NTL], [true])
+ ])
+AC_SUBST([ntl_LIBS])
+
+
+dnl
+dnl OpenBLAS (currently unused)
+dnl
+AH_TEMPLATE([HAVE_BLAS], [Define to 1 when OpenBLAS is available])
+AC_MSG_CHECKING([whether to enable OpenBLAS])
+AC_ARG_WITH([openblas],
+ [AS_HELP_STRING([--with-openblas], [Use OpenBLAS [[no]]])],
+ [with_blas="$withval"],
+ [with_blas="no"])
+AS_IF([test "x$with_blas" = "xno"],
+ [
+ AM_CONDITIONAL([WITH_BLAS], [false])
+ AC_MSG_RESULT([no])
+ ],
+ [
+ AC_MSG_RESULT([yes])
+ saved_LIBS="$LIBS"; LIBS="";
+ AC_SEARCH_LIBS([openblas_set_num_threads], [openblas], [],
+ [AC_MSG_ERROR([OpenBLAS not found.])])
+ AC_DEFINE([HAVE_BLAS], [1])
+ blas_LIBS="-lopenblas";
+ LIBS="$saved_LIBS";
+ AM_CONDITIONAL([WITH_BLAS], [true])
+ ])
+AC_SUBST([blas_LIBS])
+
+
+dnl
+dnl MPFR and MPIR (mandatory)
+dnl
+AC_SEARCH_LIBS([mpfr_init2], [mpfr], [mpfr_LIBS="$LIBS"; LIBS=""])
+AC_SUBST([mpfr_LIBS])
+AC_SEARCH_LIBS([__gmpn_get_d], [mpir], [mpir_LIBS="$LIBS"; LIBS=""])
+AC_SUBST([mpir_LIBS])
+
+AC_CONFIG_FILES([Makefile])
+AC_OUTPUT
diff --git a/fft_tuning.h b/fft_tuning.h
new file mode 100644
index 0000000..988226e
--- /dev/null
+++ b/fft_tuning.h
@@ -0,0 +1,9 @@
+/*
+ * Checking for "64-bit" must not depend on uname at all.
+ * Only the compiler is qualified to determine this.
+ */
+#if defined(_LP64) || defined(__LP64__) || defined(__arch64__)
+# include "fft_tuning64.h"
+#else
+# include "fft_tuning32.h"
+#endif
diff --git a/fft_tuning32.h b/fft_tuning32.h
new file mode 100644
index 0000000..27ff431
--- /dev/null
+++ b/fft_tuning32.h
@@ -0,0 +1,19 @@
+/* fft_tuning.h -- autogenerated by tune-fft */
+
+#ifndef FFT_TUNING_H
+#define FFT_TUNING_H
+
+#include "gmp.h"
+
+#define FFT_TAB \
+ { { 3, 3 }, { 3, 2 }, { 2, 1 }, { 2, 1 }, { 0, 0 } }
+
+#define MULMOD_TAB \
+ { 4, 3, 3, 3, 3, 2, 2, 2, 3, 2, 2, 2, 2, 1, 1 }
+
+#define FFT_N_NUM 15
+
+#define FFT_MULMOD_2EXPP1_CUTOFF 256
+
+#endif
+
diff --git a/fft_tuning32.in b/fft_tuning32.in
deleted file mode 100644
index 27ff431..0000000
--- a/fft_tuning32.in
+++ /dev/null
@@ -1,19 +0,0 @@
-/* fft_tuning.h -- autogenerated by tune-fft */
-
-#ifndef FFT_TUNING_H
-#define FFT_TUNING_H
-
-#include "gmp.h"
-
-#define FFT_TAB \
- { { 3, 3 }, { 3, 2 }, { 2, 1 }, { 2, 1 }, { 0, 0 } }
-
-#define MULMOD_TAB \
- { 4, 3, 3, 3, 3, 2, 2, 2, 3, 2, 2, 2, 2, 1, 1 }
-
-#define FFT_N_NUM 15
-
-#define FFT_MULMOD_2EXPP1_CUTOFF 256
-
-#endif
-
diff --git a/fft_tuning64.h b/fft_tuning64.h
new file mode 100644
index 0000000..f7f94da
--- /dev/null
+++ b/fft_tuning64.h
@@ -0,0 +1,19 @@
+/* fft_tuning.h -- autogenerated by tune-fft */
+
+#ifndef FFT_TUNING_H
+#define FFT_TUNING_H
+
+#include "gmp.h"
+
+#define FFT_TAB \
+ { { 4, 4 }, { 4, 3 }, { 3, 2 }, { 2, 1 }, { 2, 1 } }
+
+#define MULMOD_TAB \
+ { 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 1, 1 }
+
+#define FFT_N_NUM 19
+
+#define FFT_MULMOD_2EXPP1_CUTOFF 128
+
+#endif
+
diff --git a/fft_tuning64.in b/fft_tuning64.in
deleted file mode 100644
index f7f94da..0000000
--- a/fft_tuning64.in
+++ /dev/null
@@ -1,19 +0,0 @@
-/* fft_tuning.h -- autogenerated by tune-fft */
-
-#ifndef FFT_TUNING_H
-#define FFT_TUNING_H
-
-#include "gmp.h"
-
-#define FFT_TAB \
- { { 4, 4 }, { 4, 3 }, { 3, 2 }, { 2, 1 }, { 2, 1 } }
-
-#define MULMOD_TAB \
- { 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 1, 1 }
-
-#define FFT_N_NUM 19
-
-#define FFT_MULMOD_2EXPP1_CUTOFF 128
-
-#endif
-
diff --git a/fmpz-conversions-reentrant.h b/fmpz-conversions-reentrant.h
new file mode 100644
index 0000000..a0d9cbd
--- /dev/null
+++ b/fmpz-conversions-reentrant.h
@@ -0,0 +1,10 @@
+#ifndef FMPZ_CONVERSIONS_H
+#define FMPZ_CONVERSIONS_H
+
+/* turn a pointer to an __mpz_struct into a fmpz_t */
+#define PTR_TO_COEFF(x) (((ulong) (x) >> 2) | (WORD(1) << (FLINT_BITS - 2)))
+
+/* turns an fmpz into a pointer to an mpz */
+#define COEFF_TO_PTR(x) ((__mpz_struct *) ((x) << 2))
+
+#endif /* FMPZ_CONVERSIONS_H */
diff --git a/fmpz-conversions-reentrant.in b/fmpz-conversions-reentrant.in
deleted file mode 100644
index a0d9cbd..0000000
--- a/fmpz-conversions-reentrant.in
+++ /dev/null
@@ -1,10 +0,0 @@
-#ifndef FMPZ_CONVERSIONS_H
-#define FMPZ_CONVERSIONS_H
-
-/* turn a pointer to an __mpz_struct into a fmpz_t */
-#define PTR_TO_COEFF(x) (((ulong) (x) >> 2) | (WORD(1) << (FLINT_BITS - 2)))
-
-/* turns an fmpz into a pointer to an mpz */
-#define COEFF_TO_PTR(x) ((__mpz_struct *) ((x) << 2))
-
-#endif /* FMPZ_CONVERSIONS_H */
diff --git a/fmpz-conversions-single.h b/fmpz-conversions-single.h
new file mode 100644
index 0000000..a0d9cbd
--- /dev/null
+++ b/fmpz-conversions-single.h
@@ -0,0 +1,10 @@
+#ifndef FMPZ_CONVERSIONS_H
+#define FMPZ_CONVERSIONS_H
+
+/* turn a pointer to an __mpz_struct into a fmpz_t */
+#define PTR_TO_COEFF(x) (((ulong) (x) >> 2) | (WORD(1) << (FLINT_BITS - 2)))
+
+/* turns an fmpz into a pointer to an mpz */
+#define COEFF_TO_PTR(x) ((__mpz_struct *) ((x) << 2))
+
+#endif /* FMPZ_CONVERSIONS_H */
diff --git a/fmpz-conversions-single.in b/fmpz-conversions-single.in
deleted file mode 100644
index a0d9cbd..0000000
--- a/fmpz-conversions-single.in
+++ /dev/null
@@ -1,10 +0,0 @@
-#ifndef FMPZ_CONVERSIONS_H
-#define FMPZ_CONVERSIONS_H
-
-/* turn a pointer to an __mpz_struct into a fmpz_t */
-#define PTR_TO_COEFF(x) (((ulong) (x) >> 2) | (WORD(1) << (FLINT_BITS - 2)))
-
-/* turns an fmpz into a pointer to an mpz */
-#define COEFF_TO_PTR(x) ((__mpz_struct *) ((x) << 2))
-
-#endif /* FMPZ_CONVERSIONS_H */
diff --git a/fmpz-conversions.h b/fmpz-conversions.h
new file mode 100644
index 0000000..a0289ec
--- /dev/null
+++ b/fmpz-conversions.h
@@ -0,0 +1,6 @@
+#include "flint-config.h"
+#ifdef FLINT_REENTRANT
+# include "fmpz-conversions-reentrant.h"
+#else
+# include "fmpz-conversions-single.h"
+#endif
diff --git a/m4/.gitignore b/m4/.gitignore
new file mode 100644
index 0000000..64d9bbc
--- /dev/null
+++ b/m4/.gitignore
@@ -0,0 +1,2 @@
+/libtool.m4
+/lt*.m4
--
2.7.0