Ticket #11321: trac_11321-reviewer_part1-document_patches_and_further_clean-up.spkg.patch
File trac_11321-reviewer_part1-document_patches_and_further_clean-up.spkg.patch, 15.2 KB (added by , 11 years ago) |
---|
-
SPKG.txt
# HG changeset patch # User Leif Leonhardy <not.really@online.de> # Date 1311976216 -7200 # Node ID ab9c0dd596b875f79ea2e30bf2bf4b6f36f8119d # Parent 00247ae8f72767ad97b4e5fe42960998143f29a4 #11321 Reviewer patch to 1.23.p8: Document patches etc.; change order of flags, further cosmetic clean-up. diff -r 00247ae8f727 -r ab9c0dd596b8 SPKG.txt
a b 23 23 24 24 == Dependencies == 25 25 26 * MPIR26 * GMP/MPIR 27 27 * MPFR 28 28 * PARI 29 * GNU patch (shipped with Sage) 29 30 30 31 == Special Update/Build Instructions == 31 32 32 There is some garbage in the upstream sources: 33 src/include/.Lexplicit_formula.h.swp 34 src/include/.Lvalue.h.swp 35 src/include/._.DS_Store 36 src/include/.DS_Store 37 src/include/Lexplicit_formula.h.swap.crap 38 src/include/Lvalue.h.bak 39 src/src/.Makefile.old.swp 40 src/src/._.DS_Store 41 src/src/.DS_Store 42 src/src/.Lcommandline.ggo.swp 43 src/src/libLfunction.a 33 * There is some garbage in the upstream sources: 34 src/include/.Lexplicit_formula.h.swp 35 src/include/.Lvalue.h.swp 36 src/include/._.DS_Store 37 src/include/.DS_Store 38 src/include/Lexplicit_formula.h.swap.crap 39 src/include/Lvalue.h.bak 40 src/src/Makefile.old 41 src/src/.Makefile.old.swp 42 src/src/._.DS_Store 43 src/src/.DS_Store 44 src/src/.Lcommandline.ggo.swp 45 src/src/libLfunction.a 46 * Make sure the patches still apply cleanly. 47 * TODO / FIXME: 48 The (upstream) Makefile uses $(CC) to compile C++ (also using $(CCFLAGS)), 49 which it defines to 'g++', and hardcodes 'g++' when linking the shared 50 library. (It should use $(CXX) instead, which might *default* to 'g++'.) 51 52 === Patches === 53 54 * Lcommon.h.patch: 55 Uncomment the definition of lcalc_to_double(const long double& x). 56 (Necessary for GCC >= 4.6.0, cf. #10892.) 57 Comment from there: 58 The reason is the following code horror from src/src/include/Lcommon.h: 59 [...] 60 But somebody who is familiar with the codebase should really rewrite lcalc 61 to not redefine the double() cast, thats just fragile and will sooner or 62 later again fail inside some system headers. 63 * Makefile.patch: 64 We change a lot there, since Lcalc doesn't have a 'configure' script, 65 and hence the Makefile is supposed to be edited to customize Lcalc (build 66 options, locations of headers and libraries etc.). 67 Besides that, we 68 - put CXXFLAGS into Lcalc's "CCFLAGS" used for compiling C++, 69 - remove some stuff involving LDFLAGS1 and LDFLAGS2, setting just LDFLAGS, 70 - use $(MAKE) instead of 'make' in the crude build receipts, 71 - use CXXFLAG64 when linking the shared library. 72 * pari-2.4.4.patch: 73 Use allocatemem() instead of allocatemoremem() which the new PARI no 74 longer supports. (The former isn't supported by older versions of PARI 75 though; cf. #11321.) 76 * time.h.patch: 77 Include also <time.h> in Lcommandline_numbertheory.h (at least required 78 on Cygwin, cf. #9845). 79 This should get reported upstream. 44 80 45 81 == Changelog == 46 82 -
spkg-install
diff -r 00247ae8f727 -r ab9c0dd596b8 spkg-install
a b 1 1 #!/usr/bin/env bash 2 2 3 if [ -z "$SAGE_LOCAL" ] 4 echo >&2 "SAGE_LOCAL undefined ... exiting";5 echo >&2 "Maybe run 'sage -sh'?"6 exit 13 if [ -z "$SAGE_LOCAL" ]; then 4 echo >&2 "Error: SAGE_LOCAL undefined ... exiting" 5 echo >&2 "Maybe run 'sage -sh'?" 6 exit 1 7 7 fi 8 8 9 9 # Add a sensible default optimisation flag. Change if necessary. 10 10 OPTIMIZATION_FLAGS="-O3" 11 11 12 # Most packages do not need all these set 13 # But it is better to do them all each time, rather than ommit 14 # a flag by mistake. 12 # Most packages do not need all these set, but it is better to do them all 13 # each time, rather than omit a flag by mistake: 15 14 16 CFLAGS="$ CFLAGS $OPTIMIZATION_FLAGS"17 CXXFLAGS="$ CXXFLAGS $OPTIMIZATION_FLAGS"18 FCFLAGS="$ FCFLAGS $OPTIMIZATION_FLAGS"19 F77FLAGS="$ F77FLAGS $OPTIMIZATION_FLAGS"20 CPPFLAGS=" $CPPFLAGS -I$SAGE_LOCAL/include"21 LDFLAGS=" $LDFLAGS -L$SAGE_LOCAL/lib"15 CFLAGS="$OPTIMIZATION_FLAGS $CFLAGS" 16 CXXFLAGS="$OPTIMIZATION_FLAGS $CXXFLAGS" 17 FCFLAGS="$OPTIMIZATION_FLAGS $FCFLAGS" 18 F77FLAGS="$OPTIMIZATION_FLAGS $F77FLAGS" 19 CPPFLAGS="-I$SAGE_LOCAL/include $CPPFLAGS" 20 LDFLAGS="-L$SAGE_LOCAL/lib $LDFLAGS" 22 21 23 22 24 # Compile for 64-bit if SAGE64 is set to 'yes' 25 if [ "x$SAGE64" = xyes ] 26 echo >&2 "Building a 64-bit version of lcalc"23 # Compile for 64-bit if SAGE64 is set to 'yes': 24 if [ "x$SAGE64" = xyes ]; then 25 echo >&2 "Building a 64-bit version of lcalc" 27 26 28 # Both Sun and GNU compilers use -m64 to build 64-bit code, 29 # but compilers from IBM (on AIX), and HP (on HP-UX) 30 # do not. So allow the environment 31 # variables CFLAG64 and CXXFLAG64 to set the flag to whatever 32 # option the C and C++ compilers want for 64-bit code. If not default to -m64. 27 # Both Sun and GNU compilers use -m64 to build 64-bit code, but compilers 28 # from IBM (on AIX), and HP (on HP-UX) do not. So allow the environment 29 # variables CFLAG64 and CXXFLAG64 to set the flag to whatever option the 30 # C and C++ compilers want for 64-bit code. If not set, default to -m64. 33 31 34 if [ -z "$CFLAG64" ] ; then 35 CFLAG64=-m64 36 fi 32 if [ -z "$CFLAG64" ]; then 33 CFLAG64=-m64 34 fi 35 if [ -z "$CXXFLAG64" ]; then 36 CXXFLAG64="$CFLAG64" # default to that of the C compiler 37 fi 38 export CFLAG64 39 export CXXFLAG64 37 40 38 if [ -z "$CXXFLAG64" ] ; then 39 CXXFLAG64=-m64 40 fi 41 export CFLAG64 42 export CXXFLAG64 43 44 CFLAGS="$CFLAGS $CFLAG64 " 45 CXXFLAGS="$CXXFLAGS $CXXFLAG64 " 46 FCFLAGS="$FCFLAGS $CXXFLAG64 " 47 F77FLAGS="$F77FLAGS $CXXFLAG64 " 48 # Some packages may need LDFLAGS and/or ABI set here. 49 # LDFLAGS="$LDFLAGS -m64 " 50 # ABI=64 51 # Normally one would just add this to CXXFLAGS, but since the Makefile 52 # does not import CXXFLAGS properly, and it would take a major change to 53 # sort out the Makefile properly, the variable can just be added here, 54 # and ${CXXFLAG64} added at the right point in the Makefile for 64-bit builds. 41 CFLAGS="$CFLAGS $CFLAG64" 42 CXXFLAGS="$CXXFLAGS $CXXFLAG64" 43 FCFLAGS="$FCFLAGS $CXXFLAG64" # XXX Does this make sense? 44 F77FLAGS="$F77FLAGS $CXXFLAG64" 45 # Some packages may need LDFLAGS and/or ABI set here. 46 # LDFLAGS="$LDFLAGS $CFLAG64" # XXX Perhaps should use some LDFLAG64. 47 # ABI=64 48 # Normally one would just add this to CXXFLAGS, but since the Makefile 49 # does not import CXXFLAGS properly, and it would take a major change to 50 # sort out the Makefile properly, the variable can just be added here, 51 # and ${CXXFLAG64} added at the right point in the Makefile for 64-bit 52 # builds. 53 # (The last sentence apparently refers to CXXFLAG64 only. -leif) 55 54 fi 56 55 57 56 # If SAGE_DEBUG is set to 'yes', add debugging information. Since both 58 57 # the Sun and GNU compilers accept -g to give debugging information, 59 58 # there is no need to do anything specific to one compiler or the other. 60 59 61 if [ "x$SAGE_DEBUG" = xyes ] ; then 62 echo >&2 "Code will be built with debugging information present. Unset 'SAGE_DEBUG'" 60 if [ "x$SAGE_DEBUG" = xyes ]; then 61 echo >&2 "Code will be built with debugging information present." \ 62 "Unset 'SAGE_DEBUG'" 63 63 echo >&2 "or set it to 'no' if you don't want that." 64 64 65 CFLAGS="$CFLAGS -g 66 CXXFLAGS="$CXXFLAGS -g 67 FCFLAGS="$FCFLAGS -g 68 F77FLAGS="$F77FLAGS -g 65 CFLAGS="$CFLAGS -g" 66 CXXFLAGS="$CXXFLAGS -g" 67 FCFLAGS="$FCFLAGS -g" 68 F77FLAGS="$F77FLAGS -g" 69 69 else 70 echo >&2 "No debugging information will be used during the build of this package." 71 echo >&2 "Set 'SAGE_DEBUG' to 'yes' if you want debugging information present (-g added)." 70 echo >&2 "No debugging information will be used during the build of" \ 71 "this package." 72 echo >&2 "Set 'SAGE_DEBUG' to 'yes' if you want debugging information" \ 73 "present (-g added)." 72 74 fi 73 75 74 76 # Add appropriate flag(s) to show all warnings. 75 # This test of a compiler is not perfect by any means, but 76 # is better than nothing.77 # This test of a compiler is not perfect by any means, but is better than 78 # nothing: 77 79 78 if $CC -flags > /dev/null 2>&1; then79 SUN_COMPILER=180 # The Sun compilers are fussy, and adding extra81 # warnings will just show too many.80 if $CC -flags >/dev/null 2>&1; then 81 SUN_COMPILER=1 82 # The Sun compilers are fussy, and adding extra 83 # warnings will just show too many. 82 84 else 83 # Assume gcc if not the Sun C compiler.84 # Add -Wall to show all warnings.85 CFLAGS="$CFLAGS -Wall "86 CXXFLAGS="$CXXFLAGS -Wall"87 FCFLAGS="$FCFLAGS -Wall"88 F77FLAGS="$F77FLAGS -Wall"89 GNU_COMPILER=185 # Assume gcc if not the Sun C compiler. 86 GNU_COMPILER=1 87 # Add -Wall to show all warnings. 88 CFLAGS="-Wall $CFLAGS" 89 CXXFLAGS="-Wall $CXXFLAGS" 90 FCFLAGS="-Wall $FCFLAGS" 91 F77FLAGS="-Wall $F77FLAGS" 90 92 fi 91 93 92 # Determine if the C++ compiler is the Sun or GNU compiler 93 # Just to check we are not mising GNU and non-GNU.94 if $CXX -flags > /dev/null 2>&1; then95 SUN_COMPILER=194 # Determine if the C++ compiler is the Sun or GNU compiler, 95 # just to check we are not mixing GNU and non-GNU: 96 if $CXX -flags >/dev/null 2>&1; then 97 SUN_COMPILER=1 96 98 else 97 GNU_COMPILER=1 99 # Assume gcc/g++ if not the Sun C++ compiler. 100 GNU_COMPILER=1 98 101 fi 99 102 100 # Determine if the Fortran compiler is the Sun or GNU compiler 101 if [ -z "$SAGE_FORTRAN" ] ; then 102 echo >&2 "No Fortran compiler has been defined. This is not normally a problem." 103 # Determine if the Fortran compiler is the Sun or GNU compiler: 104 if [ -z "$SAGE_FORTRAN" ]; then 105 echo >&2 "No Fortran compiler has been defined." \ 106 "This is not normally a problem." 103 107 else 104 if $SAGE_FORTRAN -flags > /dev/null 2>&1 ;then105 SUN_COMPILER=1106 else107 GNU_COMPILER=1108 fi108 if $SAGE_FORTRAN -flags >/dev/null 2>&1; then 109 SUN_COMPILER=1 110 else 111 GNU_COMPILER=1 112 fi 109 113 fi 110 114 111 112 # Check if SAGE_FORTRAN_LIB is defined, that the file actually exists. 113 # SAGE_FORTRAN_LIB does not always need to be defined, but if it is defined, then 114 # the file should exist. 115 if [ -n "$SAGE_FORTRAN_LIB" ] && [ ! -r "$SAGE_FORTRAN_LIB" ]; then 116 echo >&2 "SAGE_FORTRAN_LIB is defined as $SAGE_FORTRAN_LIB," 117 echo >&2 "but that file does not exist." 115 # Check if SAGE_FORTRAN_LIB is defined, that the file actually exists. 116 # SAGE_FORTRAN_LIB does not always need to be defined, but if it is defined, 117 # then the file should exist. 118 if [ -n "$SAGE_FORTRAN_LIB" ] && [ ! -r "$SAGE_FORTRAN_LIB" ]; then 119 echo >&2 "Error: SAGE_FORTRAN_LIB is defined as '$SAGE_FORTRAN_LIB'," 120 echo >&2 "but that file does not exist (or isn't readable)." 118 121 exit 1 119 122 fi 120 123 121 124 # Checks that the user is not mixing the Sun and GNU compilers. This problem 122 125 # has been seen on code built with the aid of SCons, but in general could 123 126 # happen with any code if the user has specified a C compiler but not a C++ one. 124 # This problem is even more likely to occur with the Fortran compiler - I've done 125 # it myself when building Sage! 126 127 if [ "x$SUN_COMPILER" = "x1" ] && [ "x$GNU_COMPILER" = "x1" ] ; then 128 echo >&2 "You are mixing the Sun and GNU C/C++/Fortran compilers" 127 # This problem is even more likely to occur with the Fortran compiler - I've 128 # done it myself when building Sage! 129 if [ "x$SUN_COMPILER" = "x1" ] && [ "x$GNU_COMPILER" = "x1" ]; then 130 echo >&2 "Error: You are mixing the Sun and GNU C/C++/Fortran compilers." 129 131 echo >&2 "Such a combination will lead to problems." 130 echo >&2 "Check CC, CXX & SAGE_FORTRAN carefully." 132 echo >&2 "Check the environment variables CC, CXX & SAGE_FORTRAN" \ 133 "carefully." 131 134 echo >&2 "Exiting ..." 132 135 exit 1 133 136 fi 134 137 135 # These are all used by GNU to specify compilers. 138 echo "The following environment variables will be exported:" 139 140 # These are all used by GNU to specify compilers: 136 141 echo "Using CC=$CC" 137 142 echo "Using CXX=$CXX" 138 143 echo "Using FC=$FC" 139 144 echo "Using F77=$F77" 140 145 141 # Used by Sage in connection with Fortran 146 # Usually, one would add LD here, too. 147 echo "Using MAKE=$MAKE" 148 149 # Used by Sage in connection with Fortran: 142 150 echo "Using SAGE_FORTRAN=$SAGE_FORTRAN" 143 151 echo "Using SAGE_FORTRAN_LIB=$SAGE_FORTRAN_LIB" 144 152 145 # Flags which may be set. 146 echo "The following environment variables will be exported" 153 # Flags which may be set: 147 154 echo "Using CFLAG64=$CFLAG64" 148 155 echo "Using CXXFLAG64=$CXXFLAG64" 149 156 echo "Using CFLAGS=$CFLAGS" … … 153 160 echo "Using CPPFLAGS=$CPPFLAGS" 154 161 echo "Using LDFLAGS=$LDFLAGS" 155 162 echo "Using ABI=$ABI" 156 echo " configure scripts and/or makefiles might override these later"163 echo "'configure' scripts and/or makefiles might override these later." 157 164 echo " " 158 165 159 # export everything. Probably not necessary in most cases.166 # Export everything. Probably not necessary in most cases. 160 167 export CFLAGS 161 168 export CXXFLAGS 162 169 export FCFLAGS … … 164 171 export CPPFLAGS 165 172 export LDFLAGS 166 173 export ABI 174 # (Variables like CC, CXX etc. have already been exported by 'sage-env'.) 167 175 168 # End of pretty general spkg-install file. 169 # Now do the specific things needed for this package (lcalc) 176 # End of pretty general spkg-install file. 177 # Now do the specific things needed for this package (lcalc). 170 178 171 179 success() { 172 180 if [ $? -ne 0 ]; then 173 echo >&2 "Error building lcalc'$1'"181 echo >&2 "Error building the Lcalc package: '$1'" 174 182 exit 1 175 183 fi 176 184 } … … 179 187 180 188 cd src 181 189 182 # Apply Sage specific patches 190 # Apply Sage-specific patches: (See SPKG.txt for details on the patches.) 191 echo >&2 "Patching the upstream source code for Sage..." 183 192 for patch in ../patches/*.patch; do 184 193 patch -p1 <"$patch" 185 success "patch $patch failed "194 success "patch $patch failed to apply" 186 195 done 187 196 197 # There's currently no 'configure' script for Lcalc; we (also) configure 198 # it by patching the Makefile. This may change in a later release of Lcalc. 188 199 189 cd src # Now we are in src/src 200 cd src # Now we are in src/src. 190 201 191 # Build everything 202 # Build everything: 203 echo >&2 "Now building lcalc, example programs and the shared library..." 192 204 $MAKE 193 205 success 'make' 194 206 195 echo >&2 "Now copying over lcalc binary "207 echo >&2 "Now copying over lcalc binary..." 196 208 cp lcalc "$SAGE_LOCAL"/bin 197 209 success 'copying binary' 198 210 199 echo >&2 "Now copying over lcalc library "211 echo >&2 "Now copying over lcalc library..." 200 212 201 # Remove next few lines when OSX 10.4 is no longer supported202 # 10.4 does not seem to compile with .so extension in the library files213 # Remove next few lines when MacOS X 10.4 (Darwin 8) is no longer supported. 214 # 10.4 does not seem to compile with .so extension in the library files. 203 215 if [ "$UNAME" = "Darwin" ]; then 204 216 if [ `sysctl -n kern.osrelease | cut -d . -f 1` -lt 9 ]; then 205 217 cp libLfunction.so "$SAGE_LOCAL"/lib/libLfunction.dylib 206 218 success "copying libLfunction.dylib" 207 219 fi 208 fi # End of MacOS X 10.4 specific instructions220 fi # End of MacOS X 10.4 specific instructions 209 221 210 222 211 223 if [ "$UNAME" = "CYGWIN" ]; then … … 215 227 fi 216 228 success "copying libLfunction.so" 217 229 218 echo >&2 "Now copying over lcalc library header files "230 echo >&2 "Now copying over lcalc library header files..." 219 231 rm -fr "$SAGE_LOCAL"/include/lcalc 220 232 mkdir -p "$SAGE_LOCAL"/include/lcalc 221 233 cp ../include/* "$SAGE_LOCAL"/include/lcalc 222 success ' install'234 success 'copying header files'