# HG changeset patch
# User Mike Hansen <mhansen@gmail.com>
# Date 1302460284 -7200
# Node ID e2b6ff628137d25f0709415aa81d8dae07737520
# Parent  e692f4fae389e38a8a8b42139a56628a17823ef3
#11167: Sage 4.7.alpha3 library doesn't build under Cygwin

diff --git a/c_lib/SConstruct b/c_lib/SConstruct
--- a/c_lib/SConstruct
+++ b/c_lib/SConstruct
@@ -132,7 +132,7 @@
 srcFiles = cFiles + cppFiles
 
 lib = env.SharedLibrary( "csage", [ "src/" + x for x in srcFiles ],
-                         LIBS=['ntl', 'gmp', 'pari', 'python2.6'], 
+                         LIBS=['ntl', 'pari', 'gmp', 'python2.6'], 
                          LIBPATH=['$SAGE_LOCAL/lib','$SAGE_LOCAL/lib/python/config/'],
                          CPPPATH=includes )
 env.Install("$SAGE_LOCAL/lib", lib)
diff --git a/module_list.py b/module_list.py
--- a/module_list.py
+++ b/module_list.py
@@ -226,7 +226,8 @@
               sources=['sage/combinat/dict_addition.pyx']),
 
     Extension('sage.combinat.combinat_cython',
-              sources=['sage/combinat/combinat_cython.pyx']),
+              sources=['sage/combinat/combinat_cython.pyx'],
+              libraries=['gmp']),
 
     ################################
     ## 
@@ -303,7 +304,8 @@
      ################################
 
      Extension('sage.geometry.toric_lattice_element',
-               sources = ['sage/geometry/toric_lattice_element.pyx']),
+               sources = ['sage/geometry/toric_lattice_element.pyx'],
+               libraries=['gmp']),
 
      Extension('sage.geometry.triangulation.base',
                sources = ['sage/geometry/triangulation/functions.cc',
@@ -871,7 +873,7 @@
     Extension('sage.matrix.matrix_integer_dense',
               sources = ['sage/matrix/matrix_integer_dense.pyx'],
               # order matters for cygwin!!
-              libraries = ['iml', 'gmp', 'm', 'pari', BLAS, BLAS2]),
+              libraries = ['iml', 'pari', 'm', 'gmp', BLAS, BLAS2]),
 
     Extension('sage.matrix.matrix_integer_sparse',
               sources = ['sage/matrix/matrix_integer_sparse.pyx'],
@@ -905,7 +907,7 @@
 
     Extension('sage.matrix.matrix_rational_dense',
               sources = ['sage/matrix/matrix_rational_dense.pyx'],
-              libraries = ['gmp', 'pari']),
+              libraries = ['pari', 'gmp']),
     
     Extension('sage.matrix.matrix_rational_sparse',
               sources = ['sage/matrix/matrix_rational_sparse.pyx'],
@@ -1207,7 +1209,7 @@
 
     Extension('sage.rings.integer',
               sources = ['sage/rings/integer.pyx'],
-              libraries=['ntl', 'gmp', 'pari', 'flint'], 
+              libraries=['ntl', 'pari', 'flint', 'gmp'], 
               include_dirs = [SAGE_INC + 'FLINT/'], 
               depends = numpy_depends + flint_depends),
 
@@ -1217,7 +1219,7 @@
 
     Extension('sage.rings.fast_arith',
               sources = ['sage/rings/fast_arith.pyx'],
-              libraries=['gmp','pari','csage']), 
+              libraries=['pari','gmp','csage']), 
 
     Extension('sage.rings.fraction_field_element',
               sources = ['sage/rings/fraction_field_element.pyx']),
@@ -1333,7 +1335,7 @@
 
     Extension('sage.rings.number_field.totallyreal',
               sources = ['sage/rings/number_field/totallyreal.pyx'],
-              libraries = ['gmp', 'pari']),
+              libraries = ['pari', 'gmp']),
     
     Extension('sage.rings.number_field.totallyreal_data',
               sources = ['sage/rings/number_field/totallyreal_data.pyx'],
@@ -1503,9 +1505,7 @@
 
     Extension('sage.rings.polynomial.pbori',
               sources = ['sage/rings/polynomial/pbori.pyx'],
-              libraries=(['polybori','pboriCudd', 'groebner', 'gd'] +
-                           uname_specific('CYGWIN', ['png'], ['png12']) +
-                           ['m4ri']), 
+              libraries=(['polybori','pboriCudd', 'groebner', 'gd', 'png12', 'm4ri']), 
               include_dirs = [SAGE_ROOT+'/local/include/cudd',
                               SAGE_ROOT+'/local/include/polybori',
                               SAGE_ROOT+'/local/include/polybori/groebner',
@@ -1543,7 +1543,8 @@
               libraries = ['flint', 'gmp', 'ratpoints']),
 
     Extension('sage.schemes.generic.toric_divisor_class',
-              sources = ['sage/schemes/generic/toric_divisor_class.pyx']),
+              sources = ['sage/schemes/generic/toric_divisor_class.pyx'],
+              libraries = ['gmp']),
               
     Extension('sage.schemes.hyperelliptic_curves.hypellfrob',
               sources = ['sage/schemes/hyperelliptic_curves/hypellfrob.pyx',
diff --git a/sage/combinat/partitions_c.cc b/sage/combinat/partitions_c.cc
--- a/sage/combinat/partitions_c.cc
+++ b/sage/combinat/partitions_c.cc
@@ -97,6 +97,7 @@
 
 #include <stdio.h>
 #include <cfloat>
+#include <time.h>
 
 #include <cmath>
 #include <cstdlib>
