File 0001-build-provide-autotools-files.patch of Package flint
From ec03518870f1aff8bf351ba2c83a0e2a8ba3f7b0 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 | 34 +++++++----
Makefile.am | 37 ++++++++++++
autofiles.sh | 43 ++++++++++++++
autogen.sh | 5 +
configure.ac | 129 ++++++++++++++++++++++++++++++++++++++++++
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, 311 insertions(+), 70 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
Index: flint-2.4.5/.gitignore
===================================================================
--- flint-2.4.5.orig/.gitignore
+++ flint-2.4.5/.gitignore
@@ -1,19 +1,29 @@
*~
*.orig
-*.d
-*.o
-*.a
-*.so
*.P
*.ppm
-*/.deps/*
-fmpz/fmpz.c
-build/
-config.h
-fft_tuning.h
-fmpz-conversions.h
-Makefile
doc/latex/flint-manual.*
!doc/latex/flint-manual.tex
doc/latex/input/*
-doc/latex/create_doc
\ No newline at end of file
+doc/latex/create_doc
+
+*.la
+*.lo
+*.o
+.deps/
+.dirstamp
+.libs/
+Makefile
+Makefile.in
+
+/aclocal.m4
+/autom4te.cache/
+/build-aux/
+/confdefs.h
+/configure
+/config.*
+/libtool
+/stamp-h1
+/Mkinclude.am
+
+/flint-config.h
Index: flint-2.4.5/Makefile.am
===================================================================
--- /dev/null
+++ flint-2.4.5/Makefile.am
@@ -0,0 +1,37 @@
+# -*- Makefile -*-
+
+ACLOCAL_AMFLAGS = -I m4
+
+include Mkinclude.am
+
+AM_CPPFLAGS = -DFLINT_CPIMPORT=\"${pkgdatadir}/CPimport.txt\"
+AM_CFLAGS = -ansi -pedantic -Wall ${FLINT_TUNE} ${FLINT_POPCNT}
+AM_CXXFLAGS = ${AM_CFLAGS}
+
+BUILT_SOURCES = flint-config.h
+
+SOURCES = clz_tab.c memory_manager.c version.c profiler.c
+
+pkginclude_HEADERS = config.h flint-config.h ${cwd_headers}
+
+lib_LTLIBRARIES = libflint.la
+libflint_la_SOURCES = ${lib_sources} ${SOURCES}
+libflint_la_LIBADD = -lm ${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
+
+flint-config.h: config.h
+ grep FLINT $< >$@
Index: flint-2.4.5/autofiles.sh
===================================================================
--- /dev/null
+++ flint-2.4.5/autofiles.sh
@@ -0,0 +1,43 @@
+#!/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="ulong_extras long_extras perm fmpz fmpz_vec fmpz_poly \
+ fmpq_poly fmpz_mat mpfr_vec mpfr_mat nmod_vec nmod_poly \
+ nmod_poly_factor arith mpn_extras nmod_mat fmpq 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 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 '$(empty)';
+
+wcdir ()
+{
+ echo "$1 = \\";
+ shift;
+ find "$@" -maxdepth 1 -type f -name "*.c" -printf '\t%p \\\n';
+ echo '$(empty)';
+}
+
+wcdir lib_sources $BUILD_DIRS;
+wcdir exmp_sources examples;
+wcdir test_sources test;
+wcdir prof_sources profile;
Index: flint-2.4.5/autogen.sh
===================================================================
--- /dev/null
+++ flint-2.4.5/autogen.sh
@@ -0,0 +1,5 @@
+#!/bin/sh
+
+./autofiles.sh;
+autoreconf -fi;
+rm -Rf autom4te.cache;
Index: flint-2.4.5/configure.ac
===================================================================
--- /dev/null
+++ flint-2.4.5/configure.ac
@@ -0,0 +1,129 @@
+AC_INIT([flint], [2.3])
+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_ARG_WITH([ntl],
+ [AS_HELP_STRING([--with-ntl], [Use NTL [[no]]])],
+ [with_ntl="$withval"],
+ [with_ntl="no"])
+AM_CONDITIONAL([WITH_NTL], [test "$with_ntl" = yes])
+ntl_LIBS=""
+AS_IF([test "$with_ntl" = yes], [ntl_LIBS="-lntl"])
+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
Index: flint-2.4.5/fft_tuning.h
===================================================================
--- /dev/null
+++ flint-2.4.5/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
Index: flint-2.4.5/fft_tuning32.h
===================================================================
--- /dev/null
+++ flint-2.4.5/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
+
Index: flint-2.4.5/fft_tuning32.in
===================================================================
--- flint-2.4.5.orig/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
-
Index: flint-2.4.5/fft_tuning64.h
===================================================================
--- /dev/null
+++ flint-2.4.5/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
+
Index: flint-2.4.5/fft_tuning64.in
===================================================================
--- flint-2.4.5.orig/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
-
Index: flint-2.4.5/fmpz-conversions-reentrant.h
===================================================================
--- /dev/null
+++ flint-2.4.5/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 */
Index: flint-2.4.5/fmpz-conversions-reentrant.in
===================================================================
--- flint-2.4.5.orig/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 */
Index: flint-2.4.5/fmpz-conversions-single.h
===================================================================
--- /dev/null
+++ flint-2.4.5/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 */
Index: flint-2.4.5/fmpz-conversions-single.in
===================================================================
--- flint-2.4.5.orig/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 */
Index: flint-2.4.5/fmpz-conversions.h
===================================================================
--- /dev/null
+++ flint-2.4.5/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
Index: flint-2.4.5/m4/.gitignore
===================================================================
--- /dev/null
+++ flint-2.4.5/m4/.gitignore
@@ -0,0 +1,2 @@
+/libtool.m4
+/lt*.m4