diff git a/.hgtags b/.hgtags
a

b


2  2  6c0000b82e9a27c7b6baeae6c68ee790e6b5a341 mpir1.2.p3 
3  3  8910de51d3da6d9906c39cf8189486f176ed408c mpir2.1.3.p1 
4  4  5cc6cee3d3d156416e5c4053f1479331baa3d5dd mpir2.1.3.p2 
5   c7bccdf78798ca44893d002b5dc5ffd0d1995406 mpir2.1.3.p3 
6   c7bccdf78798ca44893d002b5dc5ffd0d1995406 mpir2.1.3.p3 
7  5  1ef781ef316a238a9fc4f28b19d0f2426a5196c0 mpir2.1.3.p3 
8  6  8e43565fafb7d3211b4d91de7312744cfc34bf09 mpir2.1.3.p4 
9  7  57a991f5baeeaa9c19d1367ebac8dd071e554b78 mpir2.1.3.p5 
10  8  4f3644c720091f9a584e2c0cfab163f472d1c14e mpir2.1.3.p6 
11  9  3b33192c35c487a7c77c2d623096f1dc1d48695f mpir2.1.3.p7 
12  10  ea29d1f05281a05c2664c8362dcc65e6f0bbb52a mpir2.1.3.p9 
 11  99dba51e64053e990d9ade3be4e9b5aee69cb0ac mpir2.1.3.p8 
 12  d76b39da03c3d84bf84bbf26533a6cc511a09e13 mpir2.4.0.p1 
diff git a/SPKG.txt b/SPKG.txt
a

b


27  27  each upgrade.) 
28  28  * Make sure the patches still apply; also, putting "Wl,z,noexecstack" 
29  29  into LDFLAGS might not be necessary for later versions. 
30   * There is a race condition in `make install`, supposed to be fixed in 
31   MPIR 2.1.4. Currently we work around this by installing with j1. 
32  30  * Perhaps make sure we still delete the correct files on 32bit MacOS X 
33  31  on Intel hardware (x86) to not break PIC there. 
34  32  * Remove some files / directories not needed for Sage from upstream: 
… 
… 

42  40  
43  41  == Changelog == 
44  42  
 43  === mpir2.4.0.p1 (Leif Leonhardy, March 21st, 2012) === 
 44  * Upstream upgrade to MPIR 2.4.0 (#11616). 
 45  The 2.4.0.p0 spkg isn't in this history, as it was based 
 46  on the 2.1.3.p4 spkg, i.e., is "on another branch", 
 47  and never got merged into Sage. 
 48  * Remove forcing a sequential `make install` again, since 
 49  the potential race condition was fixed in MPIR 2.1.4. 
 50  * Fix `.hgtags`, which contained duplicate entries, and 
 51  was missing others. 
 52  
45  53  === mpir2.1.3.p9 (Simon King, 11 December 2011) === 
46  54  * #12131: Use libdir, so that the package works on openSUSE 
47  55  
diff git a/patches/gmph.in b/patches/gmph.in
a

b


47  47  #define GMP_NAIL_MASK (~ GMP_NUMB_MASK) 
48  48  
49  49  
50   /* The following (everything under ifndef __GNU_MP__) must be identical in 
51   mpir.h and mp.h to allow both to be included in an application or during 
52   the library build. */ 
53  50  #ifndef __GNU_MP__ 
54  51  #define __GNU_MP__ 4 
55  52  
… 
… 

67  64  #define __GMP_LIBGMP_DLL @LIBGMP_DLL@ 
68  65  #endif 
69  66  
 67  /* #if defined(__GMP_WITHIN_CONFIGURE) && defined(_WIN64) */ 
 68  #ifdef __WIN64 
 69  #define _LONG_LONG_LIMB 1 
 70  #endif 
70  71  
71  72  /* __STDC__  some ANSI compilers define this only to 0, hence the use of 
72  73  "defined" and not "__STDC__0". In particular Sun workshop C 5.0 
… 
… 

203  204  #endif 
204  205  #endif 
205  206  
206   #if defined( _MSC_VER ) && defined( _WIN64 ) 
 207  #ifdef _WIN64 
207  208  typedef unsigned long long int mp_bitcnt_t; 
 209  #define __GMP_BITCNT_MAX (~(unsigned long long) 0) 
208  210  #else 
209  211  typedef unsigned long int mp_bitcnt_t; 
 212  #define __GMP_BITCNT_MAX (~(unsigned long) 0) 
210  213  #endif 
211  214  
212  215  /* For reference, note that the name __mpz_struct gets into C++ mangled 
… 
… 

228  231  
229  232  typedef mp_limb_t * mp_ptr; 
230  233  typedef __gmp_const mp_limb_t * mp_srcptr; 
231   #if defined (_CRAY) && ! defined (_CRAYMPP) 
232   /* plain `int' is much faster (48 bits) */ 
233   #define __GMP_MP_SIZE_T_INT 1 
234   typedef int mp_size_t; 
235   typedef int mp_exp_t; 
236   #elif defined( _WIN64) 
 234  #if defined( _WIN64) 
237  235  #define __GMP_MP_SIZE_T_INT 0 
238  236  typedef long long int mp_size_t; 
239  237  typedef long int mp_exp_t; 
… 
… 

294  292  typedef __mpq_struct *mpq_ptr; 
295  293  
296  294  
297   /* This is not wanted in mp.h, so put it outside the __GNU_MP__ common 
298   section. */ 
299  295  #if __GMP_LIBGMP_DLL 
300  296  #if __GMP_WITHIN_GMPXX 
301  297  /* compiling to go into a DLL libmpirxx */ 
… 
… 

334  330   defined (__STDIO_H) /* Borland */ \ 
335  331   defined (__STDIO_H__) /* IRIX */ \ 
336  332   defined (_STDIO_INCLUDED) /* HPUX */ \ 
337    defined (__dj_include_stdio_h_) /* DJGPP */ \ 
338  333   defined (_FILE_DEFINED) /* Microsoft */ \ 
339  334   defined (__STDIO__) /* Apple MPW MrC */ \ 
340  335   defined (_MSL_STDIO_H) /* Metrowerks */ \ 
… 
… 

529  524  #define __GMP_UNLIKELY(cond) (cond) 
530  525  #endif 
531  526  
532   #ifdef _CRAY 
533   #define __GMP_CRAY_Pragma(str) _Pragma (str) 
534   #else 
535   #define __GMP_CRAY_Pragma(str) 
536   #endif 
537   
538   
539  527  /* Allow direct user access to numerator and denominator of a mpq_t object. */ 
540  528  #define mpq_numref(Q) (&((Q)>_mp_num)) 
541  529  #define mpq_denref(Q) (&((Q)>_mp_den)) 
… 
… 

732  720  __GMP_DECLSPEC void mpz_cdiv_q __GMP_PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr)); 
733  721  
734  722  #define mpz_cdiv_q_2exp __gmpz_cdiv_q_2exp 
735   __GMP_DECLSPEC void mpz_cdiv_q_2exp __GMP_PROTO ((mpz_ptr, mpz_srcptr, unsigned long)); 
 723  __GMP_DECLSPEC void mpz_cdiv_q_2exp __GMP_PROTO ((mpz_ptr, mpz_srcptr, mp_bitcnt_t)); 
736  724  
737  725  #define mpz_cdiv_q_ui __gmpz_cdiv_q_ui 
738  726  __GMP_DECLSPEC unsigned long int mpz_cdiv_q_ui __GMP_PROTO ((mpz_ptr, mpz_srcptr, unsigned long int)); 
… 
… 

1069  1057  __GMP_DECLSPEC void mpz_realloc2 __GMP_PROTO ((mpz_ptr, mp_bitcnt_t)); 
1070  1058  
1071  1059  #define mpz_remove __gmpz_remove 
1072   __GMP_DECLSPEC unsigned long int mpz_remove __GMP_PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr)); 
 1060  __GMP_DECLSPEC mp_bitcnt_t mpz_remove __GMP_PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr)); 
1073  1061  
1074  1062  #define mpz_root __gmpz_root 
1075  1063  __GMP_DECLSPEC int mpz_root __GMP_PROTO ((mpz_ptr, mpz_srcptr, unsigned long int)); 
… 
… 

1197  1185  __GMP_DECLSPEC void mpz_xor __GMP_PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr)); 
1198  1186  
1199  1187  
 1188  /****** Integer (i.e. Z) routines for intmaax_t/uintmax_t types ******/ 
 1189  
 1190  #if defined( _STDINT_H )  defined ( _STDINT_H_ )  defined ( _STDINT ) 
 1191  
 1192  #define __GMP_BITS_PER_UINTMAX (8*sizeof(uintmax_t)) 
 1193  
 1194  #define mpz_get_ux __gmpz_get_ux 
 1195  __GMP_DECLSPEC uintmax_t mpz_get_ux __GMP_PROTO ((mpz_srcptr)); 
 1196  
 1197  #define mpz_get_sx __gmpz_get_sx 
 1198  __GMP_DECLSPEC intmax_t mpz_get_sx __GMP_PROTO ((mpz_srcptr)); 
 1199  
 1200  #define mpz_set_ux __gmpz_set_ux 
 1201  __GMP_DECLSPEC void mpz_set_ux __GMP_PROTO ((mpz_ptr, uintmax_t)); 
 1202  
 1203  #define mpz_set_sx __gmpz_set_sx 
 1204  __GMP_DECLSPEC void mpz_set_sx __GMP_PROTO ((mpz_ptr, intmax_t)); 
 1205  
 1206  #define mpz_init_set_ux __gmpz_init_set_ux 
 1207  __GMP_DECLSPEC void mpz_init_set_ux __GMP_PROTO ((mpz_ptr, uintmax_t)); 
 1208  
 1209  #define mpz_init_set_sx __gmpz_init_set_sx 
 1210  __GMP_DECLSPEC void mpz_init_set_sx __GMP_PROTO ((mpz_ptr, intmax_t)); 
 1211  
 1212  #endif 
 1213  
 1214  
1200  1215  /**************** Rational (i.e. Q) routines. ****************/ 
1201  1216  
1202  1217  #define mpq_abs __gmpq_abs 
… 
… 

1354  1369  __GMP_DECLSPEC void mpf_dump __GMP_PROTO ((mpf_srcptr)); 
1355  1370  
1356  1371  #define mpf_eq __gmpf_eq 
1357   __GMP_DECLSPEC int mpf_eq __GMP_PROTO ((mpf_srcptr, mpf_srcptr, unsigned long int)) __GMP_ATTRIBUTE_PURE; 
 1372  __GMP_DECLSPEC int mpf_eq __GMP_PROTO ((mpf_srcptr, mpf_srcptr, mp_bitcnt_t)) __GMP_ATTRIBUTE_PURE; 
1358  1373  
1359  1374  #define mpf_fits_sint_p __gmpf_fits_sint_p 
1360  1375  __GMP_DECLSPEC int mpf_fits_sint_p __GMP_PROTO ((mpf_srcptr)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; 
… 
… 

1557  1572  __GMP_DECLSPEC int mpn_cmp __GMP_PROTO ((mp_srcptr, mp_srcptr, mp_size_t)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; 
1558  1573  #endif 
1559  1574  
 1575  #define mpn_redc_1 __MPN(redc_1) 
 1576  __GMP_DECLSPEC void mpn_redc_1 __GMP_PROTO ((mp_ptr, mp_ptr, mp_srcptr, mp_size_t, mp_limb_t);) 
 1577  
1560  1578  #define mpn_divexact_by3(dst,src,size) \ 
1561  1579  mpn_divexact_by3c (dst, src, size, __GMP_CAST (mp_limb_t, 0)) 
1562  1580  
… 
… 

1877  1895  "__GMP_ULONG_MAX < GMP_NUMB_MASK". */ 
1878  1896  #if GMP_NAIL_BITS == 0  defined (_LONG_LONG_LIMB) 
1879  1897  /* limb==long and no nails, or limb==longlong, one limb is enough */ 
1880   return (__gmp_n != 0 ? __gmp_l : 0); 
 1898  return (unsigned long)(__gmp_n != 0 ? __gmp_l : 0); 
1881  1899  #else 
1882  1900  /* limb==long and nails, need two limbs when available */ 
1883  1901  __gmp_n = __GMP_ABS (__gmp_n); 
… 
… 

1942  1960  mp_bitcnt_t __gmp_result; 
1943  1961  
1944  1962  __gmp_usize = __gmp_u>_mp_size; 
1945   __gmp_result = (__gmp_usize < 0 ? __GMP_ULONG_MAX : 0); 
 1963  __gmp_result = (__gmp_usize < 0 ? __GMP_BITCNT_MAX : 0); 
1946  1964  if (__GMP_LIKELY (__gmp_usize > 0)) 
1947  1965  __gmp_result = mpn_popcount (__gmp_u>_mp_d, __gmp_usize); 
1948  1966  return __gmp_result; 
… 
… 

2211  2229  /* ASSERT ((start) >= 0); */ \ 
2212  2230  /* ASSERT ((start) <= (size)); */ \ 
2213  2231  /* ASSERT (MPN_SAME_OR_SEPARATE_P (dst, src, size)); */ \ 
2214   __GMP_CRAY_Pragma ("_CRI ivdep"); \ 
2215  2232  for (__gmp_j = (start); __gmp_j < (size); __gmp_j++) \ 
2216  2233  (dst)[__gmp_j] = (src)[__gmp_j]; \ 
2217  2234  } while (0) 
… 
… 

2378  2395  /* Major version number is the value of __GNU_MP__ too, above and in mp.h. */ 
2379  2396  #define __GNU_MP_VERSION 5 
2380  2397  #define __GNU_MP_VERSION_MINOR 0 
2381   #define __GNU_MP_VERSION_PATCHLEVEL 1 
2382   #define GMP_VERSION "5.0.1" 
 2398  #define __GNU_MP_VERSION_PATCHLEVEL 2 
 2399  #define GMP_VERSION "5.0.2" 
2383  2400  
2384  2401  #define __MPIR_VERSION 2 
2385   #define __MPIR_VERSION_MINOR 1 
2386   #define __MPIR_VERSION_PATCHLEVEL 3 
 2402  #define __MPIR_VERSION_MINOR 4 
 2403  #define __MPIR_VERSION_PATCHLEVEL 0 
2387  2404  #if defined( _MSC_VER ) 
2388   #define _MSC_MPIR_VERSION "2.1.3" 
 2405  #define _MSC_MPIR_VERSION "2.4.0" 
2389  2406  #endif 
2390  2407  
2391  2408  /* These are for programs like MPFR to use the same CC and CFLAGS as MPIR */ 
diff git a/spkginstall b/spkginstall
a

b


75  75  exit 1 
76  76  fi 
77  77  header_file=$1 
 78  # We'll probably have to change the following patterns (conditionally) when we 
 79  # upgrade to MPIR >=2.5.0(?), since MPIR's gmp.h was changed to define __GMP_CC 
 80  # to (literally) __MPIR_CC, and likewise __GMP_CFLAGS to __MPIR_CFLAGS. 
 81  # I.e., in later releases __MPIR_CC and __MPIR_CFLAGS will contain the real strings 
 82  # we need (unless they again change this; I've already complained about that). 
78  83  gmp_cc_pat='/^[ ]*#[ ]*define[ ]\+__GMP_CC[ ]\+/s/.*"\([^"]*\)"/\1/p' 
79  84  gmp_cflags_pat='/^[ ]*#[ ]*define[ ]\+__GMP_CFLAGS[ ]\+/s/.*"\([^"]*\)"/\1/p' 
80  85  if ! [ f "$header_file" ]; then 
… 
… 

128  133  # The Yasm build uses PYTHON from the environment to find python, so unset 
129  134  # it since the setting from 'spkg/standard/newest_version' confuses it: 
130  135  unset PYTHON 
 136  # This can be removed once #10492 has been merged, which turns the "package 
 137  # version" environment variables into solely `make` variables, such that the 
 138  # (shell) environment does no longer get polluted. 
131  139  
132  140  user_cflags=$CFLAGS # Save them. 'sageenv' sets CC, but not CFLAGS. 
133  141  required_cflags="" # Additional mandatory settings required by Sage, accumulated below. 
134  142  default_cflags="" # Spkg defaults that can and might get overridden. 
 143  
 144  # Newer autotools may put libs into .../lib64 (on 64bit systems): 
135  145  SAGE_CONF_OPTS=libdir="$SAGE_LOCAL/lib" 
 146  # (Further options to `configure` are added below.) 
136  147  
137  148  
138  149  if [ z "$CFLAG32" ]; then 
… 
… 

201  212  # on both 64bit and 32bit, though this is likely to change. 
202  213  case "`uname m`" in 
203  214  i[3456]86) 
204   echo "** Building with FAT Binary Support (32bit) **" 
 215  echo "** Building with \"fat binary\" support for 32bit CPUs **" 
205  216  SAGE_CONF_OPTS="$SAGE_CONF_OPTS enablefat" 
206  217  ;; 
207  218  x86_64amd64) 
208   echo "** Building with FAT Binary Support (64bit) **" 
 219  echo "** Building with \"fat binary\" support for 64bit CPUs **" 
209  220  SAGE_CONF_OPTS="$SAGE_CONF_OPTS enablefat" 
210  221  ;; 
211  222  *) # e.g. ia64 (Itanium) or PPC (ppc, ppc64) 
… 
… 

251  262  ;; 
252  263  *) # e.g. AIX or HPUX 
253  264  echo "Warning: Your platform ($UNAME) isn't yet explicitly supported" \ 
254   "in this spkg." 
 265  "by this MPIR spkg, i.e., by Sage's part of it." 
255  266  esac 
256  267  
257  268  export ABI CFLAGS CXXFLAGS # Partially redundant, but safe(r). 
… 
… 

382  393  echo " prefix=\"$SAGE_LOCAL\" $SAGE_CONF_OPTS" 
383  394  echo "You can set MPIR_EXTRA_OPTS to pass additional parameters." 
384  395  else 
385   echo "Using additional 'configure' options as specified with" \ 
 396  echo "Using additional 'configure' options as specified through" \ 
386  397  "MPIR_EXTRA_OPTS:" 
387  398  echo " $MPIR_EXTRA_OPTS" 
388  399  echo "Configuring MPIR with the following options:" 
… 
… 

431  442  # Now install MPIR: 
432  443  ############################################################################### 
433  444  
434   # Serial make since parallel is broken (#12139). 
435   $MAKE j1 install 
 445  # The potential race condition in `make install` was fixed in MPIR 2.1.4. 
 446  $MAKE install 
436  447  if [ $? ne 0 ]; then 
437  448  echo >&2 "Error installing MPIR." 
438  449  if [ "$UNAME" != "CYGWIN" ]; then # On Cygwin an error is not fatal. 
… 
… 

443  454  echo "Remember to rebuild the Sage library ('./sage b') such that it" 
444  455  echo "will use the new MPIR." 
445  456  echo "You may also have to (or want to) rebuild other Sage packages" 
446   echo "that use MPIR. Provided that this MPIR spkg is in 'spkg/standard/'," 
 457  echo "that use MPIR. Provided that this MPIR spkg is in 'spkg/standard/'," 
447  458  echo "you can rebuild all packages depending on MPIR by typing:" 
448  459  echo " cd $SAGE_ROOT" 
449  460  echo " env SAGE_UPGRADING=yes make" 