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 leif, 10 years ago)

SPKG patch. The only change with slight functional effect is the rearrangement of flags (CFLAGS et al.). Apply to Jeroen's p8 of July 26th.

  • 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  
    2323
    2424== Dependencies ==
    2525
    26  * MPIR
     26 * GMP/MPIR
    2727 * MPFR
    2828 * PARI
     29 * GNU patch (shipped with Sage)
    2930
    3031== Special Update/Build Instructions ==
    3132
    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.
    4480
    4581== Changelog ==
    4682
  • spkg-install

    diff -r 00247ae8f727 -r ab9c0dd596b8 spkg-install
    a b  
    11#!/usr/bin/env bash
    22
    3 if [ -z "$SAGE_LOCAL" ] ; then
    4   echo >&2 "SAGE_LOCAL undefined ... exiting";
    5   echo >&2 "Maybe run 'sage -sh'?"
    6   exit 1
     3if [ -z "$SAGE_LOCAL" ]; then
     4    echo >&2 "Error: SAGE_LOCAL undefined ... exiting"
     5    echo >&2 "Maybe run 'sage -sh'?"
     6    exit 1
    77fi
    88
    99# Add a sensible default optimisation flag. Change if necessary.
    1010OPTIMIZATION_FLAGS="-O3"
    1111
    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:
    1514
    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"
     15CFLAGS="$OPTIMIZATION_FLAGS $CFLAGS"
     16CXXFLAGS="$OPTIMIZATION_FLAGS $CXXFLAGS"
     17FCFLAGS="$OPTIMIZATION_FLAGS $FCFLAGS"
     18F77FLAGS="$OPTIMIZATION_FLAGS $F77FLAGS"
     19CPPFLAGS="-I$SAGE_LOCAL/include $CPPFLAGS"
     20LDFLAGS="-L$SAGE_LOCAL/lib $LDFLAGS"
    2221
    2322
    24 # Compile for 64-bit if SAGE64 is set to 'yes' 
    25 if [ "x$SAGE64" = xyes ]  ; then
    26    echo >&2 "Building a 64-bit version of lcalc"
     23# Compile for 64-bit if SAGE64 is set to 'yes':
     24if [ "x$SAGE64" = xyes ]; then
     25    echo >&2 "Building a 64-bit version of lcalc"
    2726
    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.
    3331
    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
    3740
    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)
    5554fi
    5655
    5756# If SAGE_DEBUG is set to 'yes', add debugging information.  Since both
    5857# the Sun and GNU compilers accept -g to give debugging information,
    5958# there is no need to do anything specific to one compiler or the other.
    6059
    61 if [ "x$SAGE_DEBUG" = xyes ] ; then
    62     echo >&2 "Code will be built with debugging information present. Unset 'SAGE_DEBUG'"
     60if [ "x$SAGE_DEBUG" = xyes ]; then
     61    echo >&2 "Code will be built with debugging information present." \
     62             "Unset 'SAGE_DEBUG'"
    6363    echo >&2 "or set it to 'no' if you don't want that."
    6464
    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"
    6969else
    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)."
    7274fi
    7375
    7476# 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:
    7779
    78 if $CC -flags > /dev/null 2>&1 ; then
    79    SUN_COMPILER=1
    80    # The Sun compilers are fussy, and adding extra
    81    # warnings will just show too many.
     80if $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.
    8284else
    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=1
     85    # 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"
    9092fi
    9193
    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 ; then
    95    SUN_COMPILER=1
     94# Determine if the C++ compiler is the Sun or GNU compiler,
     95# just to check we are not mixing GNU and non-GNU:
     96if $CXX -flags >/dev/null 2>&1; then
     97    SUN_COMPILER=1
    9698else
    97    GNU_COMPILER=1
     99    # Assume gcc/g++ if not the Sun C++ compiler.
     100    GNU_COMPILER=1
    98101fi
    99102
    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:
     104if [ -z "$SAGE_FORTRAN" ]; then
     105    echo >&2 "No Fortran compiler has been defined." \
     106             "This is not normally a problem."
    103107else
    104    if $SAGE_FORTRAN -flags > /dev/null 2>&1 ; then
    105       SUN_COMPILER=1
    106    else
    107       GNU_COMPILER=1
    108    fi
     108    if $SAGE_FORTRAN -flags >/dev/null 2>&1; then
     109        SUN_COMPILER=1
     110    else
     111        GNU_COMPILER=1
     112    fi
    109113fi
    110114
    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.
     118if [ -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)."
    118121    exit 1
    119122fi
    120123
    121124# Checks that the user is not mixing the Sun and GNU compilers. This problem
    122125# has been seen on code built with the aid of SCons, but in general could
    123126# 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!
     129if [ "x$SUN_COMPILER" = "x1" ] && [ "x$GNU_COMPILER" = "x1" ]; then
     130    echo >&2 "Error: You are mixing the Sun and GNU C/C++/Fortran compilers."
    129131    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."
    131134    echo >&2 "Exiting ..."
    132135    exit 1
    133136fi
    134137
    135 # These are all used by GNU to specify compilers.
     138echo "The following environment variables will be exported:"
     139
     140# These are all used by GNU to specify compilers:
    136141echo "Using CC=$CC"
    137142echo "Using CXX=$CXX"
    138143echo "Using FC=$FC"
    139144echo "Using F77=$F77"
    140145
    141 # Used by Sage in connection with Fortran
     146# Usually, one would add LD here, too.
     147echo "Using MAKE=$MAKE"
     148
     149# Used by Sage in connection with Fortran:
    142150echo "Using SAGE_FORTRAN=$SAGE_FORTRAN"
    143151echo "Using SAGE_FORTRAN_LIB=$SAGE_FORTRAN_LIB"
    144152
    145 # Flags which may be set.
    146 echo "The following environment variables will be exported"
     153# Flags which may be set:
    147154echo "Using CFLAG64=$CFLAG64"
    148155echo "Using CXXFLAG64=$CXXFLAG64"
    149156echo "Using CFLAGS=$CFLAGS"
     
    153160echo "Using CPPFLAGS=$CPPFLAGS"
    154161echo "Using LDFLAGS=$LDFLAGS"
    155162echo "Using ABI=$ABI"
    156 echo "configure scripts and/or makefiles might override these later"
     163echo "'configure' scripts and/or makefiles might override these later."
    157164echo " "
    158165
    159 # export everything. Probably not necessary in most cases.
     166# Export everything. Probably not necessary in most cases.
    160167export CFLAGS
    161168export CXXFLAGS
    162169export FCFLAGS
     
    164171export CPPFLAGS
    165172export LDFLAGS
    166173export ABI
     174# (Variables like CC, CXX etc. have already been exported by 'sage-env'.)
    167175
    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).
    170178
    171179success() {
    172180    if [ $? -ne 0 ]; then
    173         echo >&2 "Error building lcalc '$1'"
     181        echo >&2 "Error building the Lcalc package: '$1'"
    174182        exit 1
    175183    fi
    176184}
     
    179187
    180188cd src
    181189
    182 # Apply Sage specific patches
     190# Apply Sage-specific patches: (See SPKG.txt for details on the patches.)
     191echo >&2 "Patching the upstream source code for Sage..."
    183192for patch in ../patches/*.patch; do
    184193    patch -p1 <"$patch"
    185     success "patch $patch failed"
     194    success "patch $patch failed to apply"
    186195done
    187196
     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.
    188199
    189 cd src   # Now we are in src/src
     200cd src   # Now we are in src/src.
    190201
    191 # Build everything
     202# Build everything:
     203echo >&2 "Now building lcalc, example programs and the shared library..."
    192204$MAKE
    193205success 'make'
    194206
    195 echo >&2 "Now copying over lcalc binary"
     207echo >&2 "Now copying over lcalc binary..."
    196208cp lcalc "$SAGE_LOCAL"/bin
    197209success 'copying binary'
    198210
    199 echo >&2 "Now copying over lcalc library"
     211echo >&2 "Now copying over lcalc library..."
    200212
    201 #Remove next few lines  when OSX 10.4 is no longer supported
    202 #10.4 does not seem to compile with .so extension in the library files
     213# 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.
    203215if [ "$UNAME" = "Darwin" ]; then
    204216    if [ `sysctl -n kern.osrelease | cut -d . -f 1` -lt 9 ]; then
    205217        cp libLfunction.so "$SAGE_LOCAL"/lib/libLfunction.dylib
    206218        success "copying libLfunction.dylib"
    207219    fi
    208 fi #End of Mac OS X 10.4 specific instructions
     220fi # End of MacOS X 10.4 specific instructions
    209221
    210222
    211223if [ "$UNAME" = "CYGWIN" ]; then
     
    215227fi
    216228success "copying libLfunction.so"
    217229
    218 echo >&2 "Now copying over lcalc library header files"
     230echo >&2 "Now copying over lcalc library header files..."
    219231rm -fr "$SAGE_LOCAL"/include/lcalc
    220232mkdir -p "$SAGE_LOCAL"/include/lcalc
    221233cp ../include/* "$SAGE_LOCAL"/include/lcalc
    222 success 'install'
     234success 'copying header files'