Ticket #12173: flint-2.3.p0.diff.14241

File flint-2.3.p0.diff.14241, 29.4 KB (added by jpflori, 9 years ago)

Spkg diff, for review only. Based on #14241.

Line 
1diff --git a/SPKG.txt b/SPKG.txt
2--- a/SPKG.txt
3+++ b/SPKG.txt
4@@ -2,41 +2,49 @@
5 
6 == Description ==
7 
8-FLINT is a C library for doing number theory, written by William Hart and David Harvey.
9+FLINT is a C library for doing number theory, maintained by William Hart.
10 
11 Website: www.flintlib.org
12 
13 == License ==
14 
15-GPL V2+
16+FLINT is licensed GPL v2+.
17 
18 == SPKG Maintainers ==
19 
20- * Burcin Erocal
21- * Mike Hansen
22- * William Stein
23+ * Fredrik Johansson
24+ * Jean-Pierre Flori
25 
26 == Upstream Contact ==
27 
28- * Bill Hart
29- * Development list for FLINT <flint-devel@lists.sourceforge.net> (moderated)
30+ * flint-devel Gougle Group (http://groups.google.co.uk/group/flint-devel)
31+ * William Hart
32 
33 == Dependencies ==
34 
35- * gmp
36+ * MPIR
37+ * MPFR
38  * NTL
39 
40-== Special Update/Build Instructions ==
41+== Patches ==
42 
43- * We patch the makefile slightly to add 64 bit OSX build support and also change
44-   LIBS such that the NTL interface is linked into the flint library.
45-   This is not an officially supported option because flint is pure C
46-   and the NTL interface requires C++.
47- * Remove the '.svn' directories from upstream ('src/') if present.
48- * Remove the 'src/zn_poly/demo/bernoulli/.DS_Store' file
49+ * dylib.patch: patch configure so that the shared library is called
50+   libflint.dylib on Darwin.
51 
52 == Changelog ==
53 
54+=== flint-2.3.p0 (Jean-Pierre Flori, 26 March 2013) ===
55+  * Trac #12173: add dylib.patch to make sure the shared library is called
56+    libflint.dylib on Darwin
57+
58+=== flint-2.3 (Mike Hansen, Fredrik Johansson, Jean-Pierre Flori, May 2012-March 2013) ===
59+  * Trac #12173: Update FLINT to version 2.3.
60+  * Removed obsolete patches.
61+  * Cleanup spkg-install and spkg-check scripts.
62+  * Removed Cygwin hack for libntl.a made useless by #9050.
63+  * Removed now useless patch --binary flag on Cygwin.
64+  * Only build shared library on Cygwin.
65+
66 === flint-1.5.2.p3 (Timo Kluck, 7 March 2013) ===
67   * #14241: Fix double // path separators in longlong.patch
68 
69@@ -86,20 +94,20 @@
70  * #9277 Add -m64 flag when building the Flint test suite
71    if SAGE64 is set to "yes". Otherwise it builds 32-bit
72    objects and so the test files are not built, but instead
73-   generating the usual "WRONG ELF CLASS" error.
74- * Remove a couple of lines which call spkg-check from
75-   spkg-install if SAGE_CHECK is set to "yes". Otherwise,
76-   spkg-check gets called twice, which is a waste of time.
77+   generating the usual "WRONG ELF CLASS" error.
78+ * Remove a couple of lines which call spkg-check from
79+   spkg-install if SAGE_CHECK is set to "yes". Otherwise,
80+   spkg-check gets called twice, which is a waste of time.
81    I'm afraid to say it was probably me that put those couple
82-   of lines in a year or two ago, before I realised how
83-   spkg-check was supposed to be called.
84+   of lines in a year or two ago, before I realised how
85+   spkg-check was supposed to be called.
86 
87 === flint-1.5.0.p4 (Jaap Spies, Feb 23th, 2010) ===
88  * #8112 Pass CFLAG64 to FLINT_TUNE if set for a 64 bit build.
89 
90 === flint-1.5.0.p3 (David Kirkby, January  2nd, 2010) ===
91- * #7815 Changed makes and spkg-install so that the flag -m64 got
92-   added with a 64-bit build.
93+ * #7815 Changed makes and spkg-install so that the flag -m64 got
94+   added with a 64-bit build.
95 
96 === flint-1.5.0.p1 (William Stein, September 25th, 2009) ===
97  * Included a cygwin fix that involves naming the library .dll instead of .so.
98@@ -109,12 +117,12 @@
99 
100 === flint-1.3.0p3 (Ondrej Certik, September 20th, 2009) ===
101  *  Move libntl.a out of the way temporarily on CYGWIN (this makes the package
102-    built, because it will link to the .so lib instead)
103+    built, because it will link to the .so lib instead)
104 
105 === flint-1.3.0p2 (David Kirkby, June 30th, 2009) ===
106  *  Change '-a' to '-p' option spkg-install so flint installs
107     on Solaris too. The usual GNUism. Only one byte is changed!
108-
109+
110 === flint-1.3.0 (Nick Alexander, June 9th, 2009) ===
111  * Update to latest upstream FLINT, 1.3.0.
112 
113@@ -165,7 +173,7 @@
114 
115 === flint-1.0.20 (Michael Abshoff, December 23rd, 2008) ===
116  * Upgrade to latest upstream (#4861)
117- * clean up SPKG.txt
118+ * clean up SPKG.txt
119 
120 === flint-1.0.13.p0 (Michael Abshoff, August 18th, 2008) ===
121  * Add 64 bit OSX support
122@@ -185,7 +193,7 @@
123  * Only check major and minor gcc release number, not tiny (fixes #3528)
124 
125 === flint-1.010 (William Stein and Craig Citro, June 30, 2008) ===
126- * upgrade to version 1.0.10
127+ * upgrade to version 1.0.10
128 
129 === flint-1.06.p3 (Michael Abshoff, April 1st, 2008) ===
130  * import shared library versioning for flint (Tim Abbott, #3259)
131diff --git a/patches/ZmodF_mul.c.patch b/patches/ZmodF_mul.c.patch
132deleted file mode 100644
133--- a/patches/ZmodF_mul.c.patch
134+++ /dev/null
135@@ -1,10 +0,0 @@
136---- src/ZmodF_mul.c    2009-09-23 18:03:27.000000000 +0800
137-+++ patches/ZmodF_mul.c        2011-04-25 22:32:40.000000000 +0800
138-@@ -30,7 +30,6 @@
139- ******************************************************************************/
140-
141- #include <math.h>
142--#include "ZmodF.h"
143- #include "ZmodF_poly.h"
144- #include "ZmodF_mul.h"
145- #include "mpn_extras.h"
146diff --git a/patches/ZmodF_poly.c.patch b/patches/ZmodF_poly.c.patch
147deleted file mode 100644
148--- a/patches/ZmodF_poly.c.patch
149+++ /dev/null
150@@ -1,11 +0,0 @@
151---- src/ZmodF_poly.c   2009-09-23 18:03:27.000000000 +0800
152-+++ patches/ZmodF_poly.c       2011-04-25 22:37:17.000000000 +0800
153-@@ -29,8 +29,6 @@
154-
155- *****************************************************************************/
156-
157--#include "flint.h"
158--#include "memory-manager.h"
159- #include "ZmodF_poly.h"
160- #include "ZmodF_mul.h"
161- #include "fmpz_poly.h"
162diff --git a/patches/dylib.patch b/patches/dylib.patch
163new file mode 100644
164--- /dev/null
165+++ b/patches/dylib.patch
166@@ -0,0 +1,17 @@
167+diff -druN src.orig/configure src/configure
168+--- src.orig/configure 2012-11-09 21:42:47.000000000 +0100
169++++ src/configure      2013-03-06 18:21:03.644037750 +0100
170+@@ -225,12 +225,7 @@
171+ if [ -z "$FLINT_LIB" ]; then
172+    case $OS in
173+       Darwin)
174+-         case $MACHINE in
175+-            *64)
176+-               FLINT_LIB="libflint.dylib64";;
177+-            *)
178+-               FLINT_LIB="libflint.dylib";;
179+-         esac;;
180++         FLINT_LIB="libflint.dylib";;
181+       CYGWIN | MINGW*)
182+          FLINT_LIB="libflint.dll";;
183+       *)
184diff --git a/patches/longlong.patch b/patches/longlong.patch
185deleted file mode 100644
186--- a/patches/longlong.patch
187+++ /dev/null
188@@ -1,50 +0,0 @@
189-diff -ur flint-1.5.2.orig/longlong.h flint-1.5.2/longlong.h
190---- flint-1.5.2.orig/longlong.h        2009-09-23 12:03:27.000000000 +0200
191-+++ flint-1.5.2/longlong.h     2010-11-25 07:00:41.000000000 +0100
192-@@ -411,46 +411,6 @@
193-   __asm__ ("adds\t%1, %4, %5\n\tadc\t%0, %2, %3"                      \
194-          : "=r" (sh), "=&r" (sl)                                      \
195-          : "r" (ah), "rI" (bh), "%r" (al), "rI" (bl) __CLOBBER_CC)
196--#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
197--  do {                                                                        \
198--    if (__builtin_constant_p (al))                                    \
199--      {                                                                       \
200--      if (__builtin_constant_p (ah))                                  \
201--        __asm__ ("rsbs\t%1, %5, %4\n\trsc\t%0, %3, %2"                \
202--                 : "=r" (sh), "=&r" (sl)                              \
203--                 : "rI" (ah), "r" (bh), "rI" (al), "r" (bl) __CLOBBER_CC); \
204--      else                                                            \
205--        __asm__ ("rsbs\t%1, %5, %4\n\tsbc\t%0, %2, %3"                \
206--                 : "=r" (sh), "=&r" (sl)                              \
207--                 : "r" (ah), "rI" (bh), "rI" (al), "r" (bl) __CLOBBER_CC); \
208--      }                                                                       \
209--    else if (__builtin_constant_p (ah))                                       \
210--      {                                                                       \
211--      if (__builtin_constant_p (bl))                                  \
212--        __asm__ ("subs\t%1, %4, %5\n\trsc\t%0, %3, %2"                \
213--                 : "=r" (sh), "=&r" (sl)                              \
214--                 : "rI" (ah), "r" (bh), "r" (al), "rI" (bl) __CLOBBER_CC); \
215--      else                                                            \
216--        __asm__ ("rsbs\t%1, %5, %4\n\trsc\t%0, %3, %2"                \
217--                 : "=r" (sh), "=&r" (sl)                              \
218--                 : "rI" (ah), "r" (bh), "rI" (al), "r" (bl) __CLOBBER_CC); \
219--      }                                                                       \
220--    else if (__builtin_constant_p (bl))                                       \
221--      {                                                                       \
222--      if (__builtin_constant_p (bh))                                  \
223--        __asm__ ("subs\t%1, %4, %5\n\tsbc\t%0, %2, %3"                \
224--                 : "=r" (sh), "=&r" (sl)                              \
225--                 : "r" (ah), "rI" (bh), "r" (al), "rI" (bl) __CLOBBER_CC); \
226--      else                                                            \
227--        __asm__ ("subs\t%1, %4, %5\n\trsc\t%0, %3, %2"                \
228--                 : "=r" (sh), "=&r" (sl)                              \
229--                 : "rI" (ah), "r" (bh), "r" (al), "rI" (bl) __CLOBBER_CC); \
230--      }                                                                       \
231--    else /* only bh might be a constant */                            \
232--      __asm__ ("subs\t%1, %4, %5\n\tsbc\t%0, %2, %3"                  \
233--             : "=r" (sh), "=&r" (sl)                                  \
234--             : "r" (ah), "rI" (bh), "r" (al), "rI" (bl) __CLOBBER_CC);\
235--    } while (0)
236- #if 1 || defined (__arm_m__)  /* `M' series has widening multiply support */
237- #define umul_ppmm(xh, xl, a, b) \
238-   __asm__ ("umull %0,%1,%2,%3" : "=&r" (xl), "=&r" (xh) : "r" (a), "r" (b))
239diff --git a/patches/makefile.patch b/patches/makefile.patch
240deleted file mode 100644
241--- a/patches/makefile.patch
242+++ /dev/null
243@@ -1,250 +0,0 @@
244---- src/makefile       2009-09-23 12:03:27.000000000 +0200
245-+++ patches/makefile   2010-01-02 07:00:32.000000000 +0100
246-@@ -1,3 +1,5 @@
247-+# sage depends on the NTL interface, so we include it in the flint library
248-+
249- LIBDIR=$(PREFIX)/lib
250- INCLUDEDIR=$(PREFIX)/include
251- DOCDIR=$(PREFIX)/doc
252-@@ -22,7 +24,8 @@
253-
254- CPP = $(FLINT_CPP)
255-
256--LIBS = -L$(FLINT_GMP_LIB_DIR) $(FLINT_LINK_OPTIONS) -lgmp -lpthread -lm
257-+# add NTL options so that NTL interface links properly
258-+LIBS = -L$(FLINT_GMP_LIB_DIR) -L$(FLINT_NTL_LIB_DIR) $(FLINT_LINK_OPTIONS) -lgmp -lpthread -lntl -lm
259-
260- LIBS2 = -L$(FLINT_GMP_LIB_DIR) -L$(FLINT_NTL_LIB_DIR) $(FLINT_LINK_OPTIONS) -lgmp -lpthread -lntl -lm
261-
262-@@ -66,7 +69,8 @@
263-       theta.h \
264-       zmod_mat.h \
265-       F_mpz.h \
266--      QS/tinyQS.h
267-+      QS/tinyQS.h \
268-+      NTL-interface.h
269-
270- ####### library object files
271-
272-@@ -109,13 +113,14 @@
273-       poly.o \
274-       sieve.o \
275-       linear_algebra.o \
276--      block_lanczos.o
277-+      block_lanczos.o \
278-+      NTL-interface.o
279-
280- QS: mpQS
281-
282- tune: ZmodF_mul-tune mpz_poly-tune
283-
284--test: F_mpz-test mpn_extras-test fmpz_poly-test fmpz-test ZmodF-test ZmodF_poly-test mpz_poly-test ZmodF_mul-test long_extras-test zmod_poly-test zmod_mat-test
285-+test: F_mpz-test mpn_extras-test fmpz_poly-test fmpz-test ZmodF-test ZmodF_poly-test mpz_poly-test ZmodF_mul-test long_extras-test zmod_poly-test zmod_mat-test NTL-interface-test
286-
287- check: test
288-       ./F_mpz-test
289-@@ -139,16 +144,20 @@
290- library: $(FLINT_LIB)
291-
292- libflint.dylib: $(FLINTOBJ)
293--      $(CC) -single_module -fPIC -dynamiclib -o libflint.dylib $(FLINTOBJ) $(LIBS)
294-+      $(CPP) -single_module -fPIC -dynamiclib -o libflint.dylib $(FLINTOBJ) $(LIBS)
295-
296- libflint.dylib64: $(FLINTOBJ)
297--      $(CC) -m64 -single_module -fPIC -dynamiclib -o libflint.dylib $(FLINTOBJ) $(LIBS)
298-+      $(CPP) -m64 -single_module -fPIC -dynamiclib -o libflint.dylib $(FLINTOBJ) $(LIBS)
299-
300- libflint.dll: $(FLINTOBJ)
301--      $(CC) -fPIC -shared -o libflint.dll $(FLINTOBJ) $(LIBS)
302-+      $(CPP) -fPIC -shared -o libflint.dll $(FLINTOBJ) $(LIBS)
303-+
304-+# Since this code uses the C++ compiler as a linker to produce
305-+# a library, the -m64 (or equivalent) option must be provided, as it
306-+# it is in the line above where the target is libflint.dylib64
307-
308- libflint.so: $(FLINTOBJ)
309--      $(CC) -fPIC -shared -o libflint.so $(FLINTOBJ) $(LIBS)
310-+      $(CPP) $(CXXFLAG64) -fPIC -shared -o libflint.so $(FLINTOBJ) $(LIBS)
311-
312- ##### zn_poly object files
313-
314-@@ -345,55 +354,56 @@
315- ####### test program targets
316-
317- mpn_extras-test: mpn_extras-test.o test-support.o $(FLINTOBJ) $(HEADERS)
318--      $(CC) $(CFLAGS) mpn_extras-test.o test-support.o -o mpn_extras-test $(FLINTOBJ) $(LIBS)
319-+      $(CPP) $(CFLAGS) mpn_extras-test.o test-support.o -o mpn_extras-test $(FLINTOBJ) $(LIBS)
320-
321- fmpz_poly-test: fmpz_poly-test.o test-support.o $(FLINTOBJ) $(HEADERS)
322--      $(CC) $(CFLAGS) fmpz_poly-test.o test-support.o -o fmpz_poly-test $(FLINTOBJ) $(LIBS)
323-+      $(CPP) $(CFLAGS) fmpz_poly-test.o test-support.o -o fmpz_poly-test $(FLINTOBJ) $(LIBS)
324-
325- fmpz-test: fmpz-test.o test-support.o $(FLINTOBJ) $(HEADERS)
326--      $(CC) $(CFLAGS) fmpz-test.o test-support.o -o fmpz-test $(FLINTOBJ) $(LIBS)
327-+      $(CPP) $(CFLAGS) fmpz-test.o test-support.o -o fmpz-test $(FLINTOBJ) $(LIBS)
328-
329- F_mpz-test: F_mpz-test.o test-support.o $(FLINTOBJ) $(HEADERS)
330--      $(CC) $(CFLAGS) F_mpz-test.o test-support.o -o F_mpz-test $(FLINTOBJ) $(LIBS)
331-+      $(CPP) $(CFLAGS) F_mpz-test.o test-support.o -o F_mpz-test $(FLINTOBJ) $(LIBS)
332-
333- ZmodF-test: ZmodF-test.o test-support.o $(FLINTOBJ) $(HEADERS)
334--      $(CC) $(CFLAGS) ZmodF-test.o test-support.o -o ZmodF-test $(FLINTOBJ) $(LIBS)
335-+      $(CPP) $(CFLAGS) ZmodF-test.o test-support.o -o ZmodF-test $(FLINTOBJ) $(LIBS)
336-
337- ZmodF_poly-test: ZmodF_poly-test.o test-support.o $(FLINTOBJ) $(HEADERS)
338--      $(CC) $(CFLAGS) ZmodF_poly-test.o test-support.o -o ZmodF_poly-test $(FLINTOBJ) $(LIBS)
339-+      $(CPP) $(CFLAGS) ZmodF_poly-test.o test-support.o -o ZmodF_poly-test $(FLINTOBJ) $(LIBS)
340-
341- mpz_poly-test: mpz_poly-test.o test-support.o $(FLINTOBJ) $(HEADERS)
342--      $(CC) $(CFLAGS) mpz_poly-test.o test-support.o -o mpz_poly-test $(FLINTOBJ) $(LIBS)
343-+      $(CPP) $(CFLAGS) mpz_poly-test.o test-support.o -o mpz_poly-test $(FLINTOBJ) $(LIBS)
344-
345- F_mpz_mat-test: F_mpz_mat-test.o test-support.o $(FLINTOBJ) $(HEADERS)
346--      $(CC) $(CFLAGS) F_mpz_mat-test.o test-support.o -o F_mpz_mat-test $(FLINTOBJ) $(LIBS)
347-+      $(CPP) $(CFLAGS) F_mpz_mat-test.o test-support.o -o F_mpz_mat-test $(FLINTOBJ) $(LIBS)
348-
349- F_mpz_LLL_fast_d-test: F_mpz_LLL_fast_d-test.o test-support.o $(FLINTOBJ) $(HEADERS)
350--      $(CC) $(CFLAGS) F_mpz_LLL_fast_d-test.o test-support.o -o F_mpz_LLL_fast_d-test $(FLINTOBJ) $(LIBS)
351-+      $(CPP) $(CFLAGS) F_mpz_LLL_fast_d-test.o test-support.o -o F_mpz_LLL_fast_d-test $(FLINTOBJ) $(LIBS)
352-       
353- ZmodF_mul-test: ZmodF_mul-test.o test-support.o $(FLINTOBJ) $(HEADERS)
354--      $(CC) $(CFLAGS) ZmodF_mul-test.o test-support.o -o ZmodF_mul-test $(FLINTOBJ) $(LIBS)
355-+      $(CPP) $(CFLAGS) ZmodF_mul-test.o test-support.o -o ZmodF_mul-test $(FLINTOBJ) $(LIBS)
356-
357- long_extras-test: long_extras-test.o test-support.o $(FLINTOBJ)
358--      $(CC) $(CFLAGS) long_extras-test.o test-support.o -o long_extras-test $(FLINTOBJ) $(LIBS)
359-+      $(CPP) $(CFLAGS) long_extras-test.o test-support.o -o long_extras-test $(FLINTOBJ) $(LIBS)
360-
361- packed_vec-test: packed_vec-test.o test-support.o $(FLINTOBJ) $(HEADERS)
362--      $(CC) $(CFLAGS) packed_vec-test.o test-support.o -o packed_vec-test $(FLINTOBJ) $(LIBS)
363-+      $(CPP) $(CFLAGS) packed_vec-test.o test-support.o -o packed_vec-test $(FLINTOBJ) $(LIBS)
364-
365- zmod_poly-test: zmod_poly-test.o test-support.o $(FLINTOBJ) $(HEADERS)
366--      $(CC) $(CFLAGS) zmod_poly-test.o test-support.o -o zmod_poly-test $(FLINTOBJ) $(LIBS)
367-+      $(CPP) $(CFLAGS) zmod_poly-test.o test-support.o -o zmod_poly-test $(FLINTOBJ) $(LIBS)
368-
369- zmod_mat-test: zmod_mat-test.o test-support.o $(FLINTOBJ) $(HEADERS)
370--      $(CC) $(CFLAGS) zmod_mat-test.o test-support.o -o zmod_mat-test $(FLINTOBJ) $(LIBS)
371-+      $(CPP) $(CFLAGS) zmod_mat-test.o test-support.o -o zmod_mat-test $(FLINTOBJ) $(LIBS)
372-
373- F_zmod_mat-test: F_zmod_mat-test.o test-support.o $(FLINTOBJ) $(HEADERS)
374--      $(CC) $(CFLAGS) F_zmod_mat-test.o test-support.o -o F_zmod_mat-test $(FLINTOBJ) $(LIBS)
375-+      $(CPP) $(CFLAGS) F_zmod_mat-test.o test-support.o -o F_zmod_mat-test $(FLINTOBJ) $(LIBS)
376-
377- F_mpz_poly-test: F_mpz_poly-test.o test-support.o $(FLINTOBJ) $(HEADERS)
378--      $(CC) $(CFLAGS) F_mpz_poly-test.o test-support.o -o F_mpz_poly-test $(FLINTOBJ) $(LIBS)
379-+      $(CPP) $(CFLAGS) F_mpz_poly-test.o test-support.o -o F_mpz_poly-test $(FLINTOBJ) $(LIBS)
380-
381-+# NTL interface is linked in the library
382- NTL-interface-test: NTL-interface.o NTL-interface-test.o test-support.o $(FLINTOBJ) $(HEADERS)
383--      $(CPP) $(CFLAGS) NTL-interface-test.o NTL-interface.o test-support.o $(FLINTOBJ) -o NTL-interface-test $(LIBS2)
384-+      $(CPP) $(CFLAGS) NTL-interface-test.o test-support.o $(FLINTOBJ) -o NTL-interface-test $(LIBS2)
385-
386- ####### tuning program object files
387-
388-@@ -489,70 +499,70 @@
389- PROFOBJ = $(FLINTOBJ) profiler.o profiler-main.o
390-
391- fmpz_poly-profile: fmpz_poly-profile.o fmpz_poly-profile-tables.o test-support.o $(PROFOBJ)
392--      $(CC) $(CFLAGS) -o fmpz_poly-profile fmpz_poly-profile.o fmpz_poly-profile-tables.o test-support.o $(PROFOBJ) $(LIBS)
393-+      $(CPP) $(CFLAGS) -o fmpz_poly-profile fmpz_poly-profile.o fmpz_poly-profile-tables.o test-support.o $(PROFOBJ) $(LIBS)
394-
395- F_mpz_poly-profile: F_mpz_poly-profile.o F_mpz_poly-profile-tables.o test-support.o $(PROFOBJ)
396--      $(CC) $(CFLAGS) -o F_mpz_poly-profile F_mpz_poly-profile.o F_mpz_poly-profile-tables.o test-support.o $(PROFOBJ) $(LIBS)
397-+      $(CPP) $(CFLAGS) -o F_mpz_poly-profile F_mpz_poly-profile.o F_mpz_poly-profile-tables.o test-support.o $(PROFOBJ) $(LIBS)
398-
399- mpz_poly-profile: mpz_poly-profile.o mpz_poly-profile-tables.o test-support.o $(PROFOBJ)
400--      $(CC) $(CFLAGS) -o mpz_poly-profile mpz_poly-profile.o mpz_poly-profile-tables.o test-support.o $(PROFOBJ) $(LIBS)
401-+      $(CPP) $(CFLAGS) -o mpz_poly-profile mpz_poly-profile.o mpz_poly-profile-tables.o test-support.o $(PROFOBJ) $(LIBS)
402-
403- ZmodF_mul-profile: ZmodF_mul-profile.o ZmodF_mul-profile-tables.o $(PROFOBJ)
404--      $(CC) $(CFLAGS) -o ZmodF_mul-profile ZmodF_mul-profile.o ZmodF_mul-profile-tables.o $(PROFOBJ) $(LIBS)
405-+      $(CPP) $(CFLAGS) -o ZmodF_mul-profile ZmodF_mul-profile.o ZmodF_mul-profile-tables.o $(PROFOBJ) $(LIBS)
406-
407- ZmodF_poly-profile: ZmodF_poly-profile.o ZmodF_poly-profile-tables.o $(PROFOBJ)
408--      $(CC) $(CFLAGS) -o ZmodF_poly-profile ZmodF_poly-profile.o ZmodF_poly-profile-tables.o $(PROFOBJ) $(LIBS)
409-+      $(CPP) $(CFLAGS) -o ZmodF_poly-profile ZmodF_poly-profile.o ZmodF_poly-profile-tables.o $(PROFOBJ) $(LIBS)
410-
411-
412- kara-profile: kara-profile.c profiler.o test-support.o $(FLINTOBJ)
413--      $(CC) $(CFLAGS) -o kara-profile kara-profile.c profiler.o test-support.o $(FLINTOBJ) $(LIBS)
414-+      $(CPP) $(CFLAGS) -o kara-profile kara-profile.c profiler.o test-support.o $(FLINTOBJ) $(LIBS)
415-
416- NTL-profile: NTL-profile.c test-support.o NTL-profile-tables.o $(PROFOBJ)
417-       $(CPP) $(CFLAGS) -o NTL-profile NTL-profile.c NTL-profile-tables.o test-support.o $(PROFOBJ) $(LIB) -lntl
418-
419- zmod_poly-profile: zmod_poly-profile.o zmod_poly-profile-tables.o $(PROFOBJ)
420--      $(CC) $(CFLAGS) -o zmod_poly-profile zmod_poly.o zmod_poly-profile.o zmod_poly-profile-tables.o $(PROFOBJ) $(LIBS)
421-+      $(CPP) $(CFLAGS) -o zmod_poly-profile zmod_poly.o zmod_poly-profile.o zmod_poly-profile-tables.o $(PROFOBJ) $(LIBS)
422-
423- bernoulli-profile: bernoulli-profile.o bernoulli-profile-tables.o $(PROFOBJ)
424--      $(CC) $(CFLAGS) -o bernoulli-profile zmod_poly.o bernoulli-profile.o bernoulli-profile-tables.o $(PROFOBJ) $(LIBS)
425-+      $(CPP) $(CFLAGS) -o bernoulli-profile zmod_poly.o bernoulli-profile.o bernoulli-profile-tables.o $(PROFOBJ) $(LIBS)
426-
427- ####### example programs
428-
429- delta_qexp.o: delta_qexp.c $(HEADERS)
430--      $(CC) $(CFLAGS) -c delta_qexp.c -o delta_qexp.o
431-+      $(CPP) $(CFLAGS) -c delta_qexp.c -o delta_qexp.o
432-
433- delta_qexp: delta_qexp.o $(FLINTOBJ)
434--      $(CC) $(CFLAGS) -o delta_qexp delta_qexp.o $(FLINTOBJ) $(LIBS)
435-+      $(CPP) $(CFLAGS) -o delta_qexp delta_qexp.o $(FLINTOBJ) $(LIBS)
436-
437- expmod: expmod.c $(FLINTOBJ)
438--      $(CC) $(CFLAGS) -o expmod expmod.c $(FLINTOBJ) $(LIBS)
439-+      $(CPP) $(CFLAGS) -o expmod expmod.c $(FLINTOBJ) $(LIBS)
440-
441- BPTJCubes: BPTJCubes.c $(FLINTOBJ)
442--      $(CC) $(CFLAGS) -o BPTJCubes BPTJCubes.c $(FLINTOBJ) $(LIBS)
443-+      $(CPP) $(CFLAGS) -o BPTJCubes BPTJCubes.c $(FLINTOBJ) $(LIBS)
444-
445- bernoulli.o: bernoulli.c $(HEADERS)
446--      $(CC) $(CFLAGS) -c bernoulli.c -o bernoulli.o
447-+      $(CPP) $(CFLAGS) -c bernoulli.c -o bernoulli.o
448-
449- bernoulli: bernoulli.o $(FLINTOBJ)
450--      $(CC) $(CFLAGS) -o bernoulli bernoulli.o $(FLINTOBJ) $(LIBS)
451-+      $(CPP) $(CFLAGS) -o bernoulli bernoulli.o $(FLINTOBJ) $(LIBS)
452-
453- bernoulli_fmpz.o: bernoulli_fmpz.c $(HEADERS)
454--      $(CC) $(CFLAGS) -c bernoulli_fmpz.c -o bernoulli_fmpz.o
455-+      $(CPP) $(CFLAGS) -c bernoulli_fmpz.c -o bernoulli_fmpz.o
456-
457- bernoulli_fmpz: bernoulli_fmpz.o $(FLINTOBJ)
458--      $(CC) $(CFLAGS) -o bernoulli_fmpz bernoulli_fmpz.o $(FLINTOBJ) $(LIBS)
459-+      $(CPP) $(CFLAGS) -o bernoulli_fmpz bernoulli_fmpz.o $(FLINTOBJ) $(LIBS)
460-
461- bernoulli_zmod.o: bernoulli_zmod.c $(HEADERS)
462--      $(CC) $(CFLAGS) -c bernoulli_zmod.c -o bernoulli_zmod.o
463-+      $(CPP) $(CFLAGS) -c bernoulli_zmod.c -o bernoulli_zmod.o
464-
465- bernoulli_zmod: bernoulli_zmod.o $(FLINTOBJ)
466--      $(CC) $(CFLAGS) -o bernoulli_zmod bernoulli_zmod.o $(FLINTOBJ) $(LIBS)
467-+      $(CPP) $(CFLAGS) -o bernoulli_zmod bernoulli_zmod.o $(FLINTOBJ) $(LIBS)
468-
469- thetaproduct.o: thetaproduct.c $(HEADERS)
470--      $(CC) $(CFLAGS2) $(WITH_ZNPOLY) -c thetaproduct.c -o thetaproduct.o
471-+      $(CPP) $(CFLAGS2) $(WITH_ZNPOLY) -c thetaproduct.c -o thetaproduct.o
472-
473- thetaproduct: thetaproduct.o $(FLINTOBJ)
474--      $(CC) $(CFLAGS2) -o thetaproduct thetaproduct.o $(FLINTOBJ) $(LIBS)
475-+      $(CPP) $(CFLAGS2) -o thetaproduct thetaproduct.o $(FLINTOBJ) $(LIBS)
476-
477- ####### Quadratic sieve
478-
479-@@ -590,12 +600,12 @@
480-       $(CC) $(CFLAGS) -c QS/mp_factor_base.c -o mp_factor_base.o
481-
482- mpQS: QS/mpQS.c QS/mpQS.h QS/tinyQS.h mp_factor_base.o mp_poly.o mp_sieve.o mp_linear_algebra.o mp_lprels.o $(FLINTOBJ)
483--      $(CC) $(CFLAGS) -o mpQS QS/mpQS.c mp_factor_base.o mp_poly.o mp_sieve.o mp_linear_algebra.o mp_lprels.o $(FLINTOBJ) $(LIBS)
484-+      $(CPP) $(CFLAGS) -o mpQS QS/mpQS.c mp_factor_base.o mp_poly.o mp_sieve.o mp_linear_algebra.o mp_lprels.o $(FLINTOBJ) $(LIBS)
485-
486- ####### Integer multiplication timing
487-
488- ZMULOBJ = zn_mod.o misc.o mul_ks.o pack.o mul.o mulmid.o mulmid_ks.o ks_support.o mpn_mulmid.o nuss.o pmf.o pmfvec_fft.o tuning.o mul_fft.o mul_fft_dft.o array.o invert.o zmod_mat.o zmod_poly.o memory-manager.o fmpz.o ZmodF_mul-tuning.o mpz_poly.o mpz_poly-tuning.o fmpz_poly.o ZmodF_poly.o mpz_extras.o profiler.o ZmodF_mul.o ZmodF.o mpn_extras.o F_mpz_mul-timing.o long_extras.o factor_base.o poly.o sieve.o linear_algebra.o block_lanczos.o
489-
490- F_mpz_mul-timing: $(FLINTOBJ)
491--      $(CC) $(CFLAGS) F_mpz_mul-timing.c profiler.o -o Zmul $(FLINTOBJ) $(LIBS)
492-+      $(CPP) $(CFLAGS) F_mpz_mul-timing.c profiler.o -o Zmul $(FLINTOBJ) $(LIBS)
493-
494diff --git a/patches/mpn_extras.h.patch b/patches/mpn_extras.h.patch
495deleted file mode 100644
496--- a/patches/mpn_extras.h.patch
497+++ /dev/null
498@@ -1,10 +0,0 @@
499---- src/mpn_extras.h   2009-09-23 03:03:27.000000000 -0700
500-+++ patches/mpn_extras.h       2011-12-20 15:47:18.495311148 -0800
501-@@ -22,7 +22,6 @@
502- #ifndef MPN_EXTRAS_H
503- #define MPN_EXTRAS_H
504-
505--#include "flint.h"
506- #include "ZmodF_poly.h"
507-
508- #include "longlong_wrapper.h"
509diff --git a/spkg-check b/spkg-check
510--- a/spkg-check
511+++ b/spkg-check
512@@ -1,62 +1,21 @@
513 #!/usr/bin/env bash
514 
515-echo "*************************************************"
516-echo "Running test suite. This should take 6-20 minutes"
517-echo "   Please report all failures to sage-devel      "
518-echo "*************************************************"
519+###############################################################################
520+#
521+# FLINT Sage check script
522+#
523+###############################################################################
524 
525-if [ "`uname`" = "Linux" -a "`uname -m`" = "x86_64" ]; then
526-   FLINT_TUNE="-mtune=opteron -march=opteron -fPIC -funroll-loops "
527-elif [ "`uname`" = "Darwin" -a "`uname -m`" = "Power Macintosh" ]; then
528-   FLINT_TUNE=" -fPIC -funroll-loops "
529-elif [ "`uname -m`" = "ia64" ]; then
530-   # -funroll-loops crashes the build on itanium under GCC-4.2.1, as reported by
531-   # Kate Minola.
532-   FLINT_TUNE=" -fPIC "
533-else
534-   FLINT_TUNE=" -fPIC -funroll-loops  "
535+if [ "$SAGE_LOCAL" = "" ]; then
536+   echo >&2 "Error: SAGE_LOCAL undefined - exiting..."
537+   echo >&2 "Maybe run 'sage -sh'?"
538+   exit 1
539 fi
540 
541-export FLINT_TUNE
542+cd src
543+$MAKE check
544 
545-if [ "x$SAGE64" = xyes ]; then
546-   echo "Building a 64-bit version of the Flint test suite"
547-   FLINT_TUNE=" -fPIC -m64 -funroll-loops"
548-fi
549-
550-FLINT_GMP_INCLUDE_DIR="$SAGE_LOCAL"/include/
551-FLINT_GMP_LIB_DIR="$SAGE_LOCAL"/lib/
552-
553-FLINT_NTL_INCLUDE_DIR="$SAGE_LOCAL"/include
554-FLINT_NTL_LIB_DIR="$SAGE_LOCAL"/lib/
555-
556-# What is QD??
557-FLINT_QD_LIB_DIR="$SAGE_LOCAL"/include
558-FLINT_QD_INCLUDE_DIR="$SAGE_LOCAL"/include
559-
560-export FLINT_GMP_INCLUDE_DIR
561-export FLINT_GMP_LIB_DIR
562-export FLINT_QD_INCLUDE_DIR
563-export FLINT_QD_LIB_DIR
564-export FLINT_NTL_INCLUDE_DIR
565-export FLINT_NTL_LIB_DIR
566-
567-###
568-FLINT_LINK_OPTIONS=""
569-export FLINT_LINK_OPTIONS
570-
571-cd src
572-
573-make test
574 if [ $? -ne 0 ]; then
575-    echo "Error building the test suite for FLINT"
576+    echo >&2 "Error: FLINT failed to pass its test suite."
577     exit 1
578 fi
579-
580-for i in {mpn_extras-test,ZmodF-test,ZmodF_mul-test,ZmodF_poly-test,fmpz-test,fmpz_poly-test,mpz_poly-test,long_extras-test,zmod_poly-test,zmod_mat-test,NTL-interface-test}; do
581-       ./$i
582-       if [ $? -ne 0 ]; then
583-           echo "FLINT test failed: $i"
584-           exit 1
585-       fi
586-done
587diff --git a/spkg-install b/spkg-install
588--- a/spkg-install
589+++ b/spkg-install
590@@ -1,147 +1,67 @@
591 #!/usr/bin/env bash
592 
593+###############################################################################
594+#
595+# FLINT Sage install script
596+#
597+###############################################################################
598+
599 if [ "$SAGE_LOCAL" = "" ]; then
600-   echo "SAGE_LOCAL undefined ... exiting";
601-   echo "Maybe run 'sage -sh'?"
602+   echo >&2 "Error: SAGE_LOCAL undefined - exiting..."
603+   echo >&2 "Maybe run 'sage -sh'?"
604    exit 1
605 fi
606 
607-if [ $UNAME = "CYGWIN" ]; then
608-   # we'll move the libntl.a temporarily out of the way and move it back at the
609-   # end of this spkg-install script
610-   mv $SAGE_LOCAL/lib/libntl.a $SAGE_LOCAL/lib/xxx_libntl.a
611-fi
612-
613-if [ "`uname`" = "Linux" -a "`uname -m`" = "x86_64" ]; then
614-   # This line causes *MAJOR* Illegal Instruction problems on
615-   # 64-bit Pentium 4's.  Do *not* do that!!  Only enable the
616-   # opteron stuff with a surefire way of detecting that a
617-   # machine is really an opteron.
618-   #FLINT_TUNE="-mtune=opteron -march=opteron -fPIC -funroll-loops "
619-
620-   FLINT_TUNE="-fPIC -funroll-loops "
621-elif [ "`uname`" = "Darwin" -a "`uname -m`" = "Power Macintosh" ]; then
622-   FLINT_TUNE=" -fPIC -funroll-loops "
623-elif [ "`uname -m`" = "ia64" ]; then 
624-   # -funroll-loops crashes the build on itanium under GCC-4.2.1, as reported by
625-   # Kate Minola.
626-   echo "Turning off loop unrolling on Linux/Itanium"
627-   FLINT_TUNE=" -fPIC "
628-elif [ "`uname`" = "SunOS" -a "`uname -p`" = "sparc" ]; then
629-   # -funroll-loops crashes the build on an US IIIi under GCC-4.3.2, as reported by
630-   # Michael Abshoff
631-   echo "Turning off loop unrolling on Solaris/Sparc"
632-   FLINT_TUNE=" -fPIC "
633-else
634-   FLINT_TUNE=" -fPIC -funroll-loops  "
635+if [ "$SAGE64" = "yes" ]; then
636+    echo "Building a 64-bit version of FLINT."
637+    ABI="64"; export ABI
638 fi
639 
640-if [ -z "$CFLAG64" ] ; then
641-    CFLAG64=-m64
642-fi
643-
644-if [ -z "$CXXFLAG64" ] ; then
645-    CXXFLAG64=-m64
646+if [ "$SAGE_DEBUG" = "yes" ]; then
647+    echo "Building a debug version of FLINT."
648+    CFLAGS="-O0 -g $CFLAGS"; export CFLAGS
649+    FLINT_TUNE=" $FLINT_TUNE"; export FLINT_TUNE
650 fi
651 
652-
653-if [ "x$SAGE64" = xyes ]; then
654-   FLINT_TUNE="$FLINT_TUNE $CFLAG64"
655-   export CXXFLAG64
656+if [ "$UNAME" = "CYGWIN" ]; then
657+    echo "Only building a shared version of FLINT on Cygwin."
658+    FLINT_CONFIGURE="--disable-static $FLINT_CONFIGURE"
659 fi
660 
661-export FLINT_TUNE
662+cd src
663 
664-FLINT_GMP_INCLUDE_DIR="$SAGE_LOCAL"/include/
665-FLINT_GMP_LIB_DIR="$SAGE_LOCAL"/lib/
666-
667-FLINT_NTL_INCLUDE_DIR="$SAGE_LOCAL"/include
668-FLINT_NTL_LIB_DIR="$SAGE_LOCAL"/lib/
669-
670-# What is QD?? possibly quad double?
671-FLINT_QD_LIB_DIR="$SAGE_LOCAL"/include
672-FLINT_QD_INCLUDE_DIR="$SAGE_LOCAL"/include
673-
674-export FLINT_GMP_INCLUDE_DIR
675-export FLINT_GMP_LIB_DIR
676-export FLINT_QD_INCLUDE_DIR
677-export FLINT_QD_LIB_DIR
678-export FLINT_NTL_INCLUDE_DIR
679-export FLINT_NTL_LIB_DIR
680-
681-###
682-FLINT_LINK_OPTIONS=""
683-export FLINT_LINK_OPTIONS
684-
685-# Apply all patches
686-if [ $UNAME = "CYGWIN" ]; then
687-    PATCH_FLAG=--binary
688-fi
689-cd src
690-echo "Patching Flint"
691-for p in ../patches/*.patch; do 
692-    patch $PATCH_FLAG -p1 <"$p"
693+echo "Patching FLINT."
694+for patch in ../patches/*.patch; do
695+    [ -f "$patch" ] || continue
696+    patch -p1 <"$patch"
697     if [ $? -ne 0 ]; then
698-        echo "Applying patch $p failed"
699+        echo >&2 "Error applying '$patch'"
700         exit 1
701     fi
702-done
703+done
704 
705-# UNIX
706-if [ $UNAME != "Darwin" ]; then
707-    $MAKE libflint.so
708-    if [ $? -ne 0 ]; then
709-        if [ $UNAME = "CYGWIN" ]; then
710-           # let's move libntl.a back
711-           mv $SAGE_LOCAL/lib/xxx_libntl.a $SAGE_LOCAL/lib/libntl.a
712-        fi
713-        echo "Error building flint shared library."
714-        exit 1
715-    fi
716-    if [ $UNAME = "CYGWIN" ]; then
717-       # let's move libntl.a back
718-       mv $SAGE_LOCAL/lib/xxx_libntl.a $SAGE_LOCAL/lib/libntl.a
719-       # make both kinds of dynamic libraries available for Windows
720-       cp -p libflint.so libflint.dll
721-    fi
722-    echo "Deleting old FLINT"
723-    rm -f $SAGE_LOCAL/lib/libflint*
724-    echo "Installing new library file"
725-    $CP -p libflint* "$SAGE_LOCAL/lib/"
726-fi
727+echo "Configuring FLINT."
728+./configure --prefix="$SAGE_LOCAL" --with-mpir="$SAGE_LOCAL" \
729+    --with-mpfr="$SAGE_LOCAL" --with-ntl="$SAGE_LOCAL" $FLINT_CONFIGURE
730+if [ $? -ne 0 ]; then
731+    echo >&2 "Error: Failed to configure FLINT."
732+    exit 1
733+fi
734 
735-# OS X
736-if [ $UNAME = "Darwin" ]; then
737-    if [ "$SAGE64" = "yes" ]; then
738-       $MAKE libflint.dylib64
739-    else
740-       $MAKE libflint.dylib
741-    fi
742-    if [ ! -f libflint.dylib ]; then
743-        echo "Failed to build FLINT dylib."
744-        exit 1
745-    fi
746-    echo "Deleting old FLINT"
747-    rm -f $SAGE_LOCAL/lib/libflint*
748-    echo "Installing new library file"
749-    $CP libflint.dylib "$SAGE_LOCAL/lib/"
750-fi
751+echo "Building FLINT shared library."
752+$MAKE
753+if [ $? -ne 0 ]; then
754+    echo >&2 "Error: Failed to build FLINT shared library."
755+    exit 1
756+fi
757 
758+echo "Deleting old FLINT files."
759+rm -f $SAGE_LOCAL/lib/libflint*
760+rm -rf $SAGE_LOCAL/include/flint
761 
762-# Copy the header files
763-
764-rm -rf "$SAGE_LOCAL"/include/FLINT
765-
766-for i in {FLINT/,FLINT/zn_poly/src/}; do
767-       mkdir -p "$SAGE_LOCAL"/include/$i
768-       if [ $? -ne 0 ]; then
769-           echo "Error building FLINT"
770-           exit 1
771-       fi
772-
773-       $CP ${i/FLINT\//}*.h "$SAGE_LOCAL"/include/$i
774-       if [ $? -ne 0 ]; then
775-           echo "Error building FLINT"
776-           exit 1
777-       fi
778-done
779+echo "Installing new FLINT files."
780+$MAKE install
781+if [ $? -ne 0 ]; then
782+    echo >&2 "Error: Failed to install FLINT."
783+    exit 1
784+fi