Ticket #11321: lcalc-1.23.p8-p9.diff

File lcalc-1.23.p8-p9.diff, 27.6 KB (added by jdemeyer, 10 years ago)
  • spkg-install

    diff -Naur lcalc-1.23.p8/spkg-install lcalc-1.23.p9/spkg-install
    old new  
    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.
    15 
    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"
    22 
    23 
    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"
    27 
    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.
    33 
    34    if [ -z "$CFLAG64" ] ; then
    35       CFLAG64=-m64
    36    fi
    37 
    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.
     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:
     14
     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"
     21
     22
     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"
     26
     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.
     31
     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
     40
     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
     60if [ "x$SAGE_DEBUG" = xyes ]; then
    6261    echo >&2 "Code will be built with debugging information present. Unset 'SAGE_DEBUG'"
    6362    echo >&2 "or set it to 'no' if you don't want that."
    6463
    65     CFLAGS="$CFLAGS -g "
    66     CXXFLAGS="$CXXFLAGS -g "
    67     FCFLAGS="$FCFLAGS -g "
    68     F77FLAGS="$F77FLAGS -g "
     64    CFLAGS="$CFLAGS -g"
     65    CXXFLAGS="$CXXFLAGS -g"
     66    FCFLAGS="$FCFLAGS -g"
     67    F77FLAGS="$F77FLAGS -g"
    6968else
    7069    echo >&2 "No debugging information will be used during the build of this package."
    7170    echo >&2 "Set 'SAGE_DEBUG' to 'yes' if you want debugging information present (-g added)."
    7271fi
    7372
    7473# 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.
     74# This test of a compiler is not perfect by any means, but is better than
     75# nothing:
    7776
    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.
     77if $CC -flags >/dev/null 2>&1; then
     78    SUN_COMPILER=1
     79    # The Sun compilers are fussy, and adding extra
     80    # warnings will just show too many.
    8281else
    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
     82    # Assume gcc if not the Sun C compiler.
     83    GNU_COMPILER=1
     84    # Add -Wall to show all warnings.
     85    CFLAGS="-Wall $CFLAGS"
     86    CXXFLAGS="-Wall $CXXFLAGS"
     87    FCFLAGS="-Wall $FCFLAGS"
     88    F77FLAGS="-Wall $F77FLAGS"
    9089fi
    9190
    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
     91# Determine if the C++ compiler is the Sun or GNU compiler,
     92# just to check we are not mixing GNU and non-GNU:
     93if $CXX -flags >/dev/null 2>&1; then
     94    SUN_COMPILER=1
    9695else
    97    GNU_COMPILER=1
     96    # Assume gcc/g++ if not the Sun C++ compiler.
     97    GNU_COMPILER=1
    9898fi
    9999
    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."
     100# Determine if the Fortran compiler is the Sun or GNU compiler:
     101if [ -z "$SAGE_FORTRAN" ]; then
     102    echo >&2 "No Fortran compiler has been defined. This is not normally a problem."
    103103else
    104    if $SAGE_FORTRAN -flags > /dev/null 2>&1 ; then
    105       SUN_COMPILER=1
    106    else
    107       GNU_COMPILER=1
    108    fi
     104    if $SAGE_FORTRAN -flags >/dev/null 2>&1; then
     105        SUN_COMPILER=1
     106    else
     107        GNU_COMPILER=1
     108    fi
    109109fi
    110110
    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."
     111# Check if SAGE_FORTRAN_LIB is defined, that the file actually exists.
     112# SAGE_FORTRAN_LIB does not always need to be defined, but if it is defined,
     113# then the file should exist.
     114if [ -n "$SAGE_FORTRAN_LIB" ] && [ ! -r "$SAGE_FORTRAN_LIB" ]; then
     115    echo >&2 "Error: SAGE_FORTRAN_LIB is defined as '$SAGE_FORTRAN_LIB',"
     116    echo >&2 "but that file does not exist (or isn't readable)."
    118117    exit 1
    119118fi
    120119
    121120# Checks that the user is not mixing the Sun and GNU compilers. This problem
    122121# has been seen on code built with the aid of SCons, but in general could
    123122# 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"
     123# This problem is even more likely to occur with the Fortran compiler - I've
     124# done it myself when building Sage!
     125if [ "x$SUN_COMPILER" = "x1" ] && [ "x$GNU_COMPILER" = "x1" ]; then
     126    echo >&2 "Error: You are mixing the Sun and GNU C/C++/Fortran compilers."
    129127    echo >&2 "Such a combination will lead to problems."
    130     echo >&2 "Check CC, CXX & SAGE_FORTRAN carefully."
     128    echo >&2 "Check the environment variables CC, CXX & SAGE_FORTRAN carefully."
    131129    echo >&2 "Exiting ..."
    132130    exit 1
    133131fi
    134132
    135 # These are all used by GNU to specify compilers.
     133echo "The following environment variables will be exported:"
     134
     135# These are all used by GNU to specify compilers:
    136136echo "Using CC=$CC"
    137137echo "Using CXX=$CXX"
    138138echo "Using FC=$FC"
    139139echo "Using F77=$F77"
    140140
    141 # Used by Sage in connection with Fortran
     141# Usually, one would add LD here, too.
     142echo "Using MAKE=$MAKE"
     143
     144# Used by Sage in connection with Fortran:
    142145echo "Using SAGE_FORTRAN=$SAGE_FORTRAN"
    143146echo "Using SAGE_FORTRAN_LIB=$SAGE_FORTRAN_LIB"
    144147
    145 # Flags which may be set.
    146 echo "The following environment variables will be exported"
     148# Flags which may be set:
    147149echo "Using CFLAG64=$CFLAG64"
    148150echo "Using CXXFLAG64=$CXXFLAG64"
    149151echo "Using CFLAGS=$CFLAGS"
     
    153155echo "Using CPPFLAGS=$CPPFLAGS"
    154156echo "Using LDFLAGS=$LDFLAGS"
    155157echo "Using ABI=$ABI"
    156 echo "configure scripts and/or makefiles might override these later"
     158echo "'configure' scripts and/or makefiles might override these later."
    157159echo " "
    158160
    159 # export everything. Probably not necessary in most cases.
     161# Export everything. Probably not necessary in most cases.
    160162export CFLAGS
    161163export CXXFLAGS
    162164export FCFLAGS
     
    164166export CPPFLAGS
    165167export LDFLAGS
    166168export ABI
     169# (Variables like CC, CXX etc. have already been exported by 'sage-env'.)
    167170
    168 # End of pretty general spkg-install file. 
    169 # Now do the specific things needed for this package (lcalc)
     171# End of pretty general spkg-install file.
     172# Now do the specific things needed for this package (lcalc).
    170173
    171174success() {
    172175    if [ $? -ne 0 ]; then
    173         echo >&2 "Error building lcalc '$1'"
     176        echo >&2 "Error building the Lcalc package: '$1'"
    174177        exit 1
    175178    fi
    176179}
     
    179182
    180183cd src
    181184
    182 # Apply Sage specific patches
     185# Apply Sage-specific patches: (See SPKG.txt for details on the patches.)
     186echo >&2 "Patching the upstream source code for Sage..."
    183187for patch in ../patches/*.patch; do
    184188    patch -p1 <"$patch"
    185     success "patch $patch failed"
     189    success "patch $patch failed to apply"
    186190done
    187191
     192# There's currently no 'configure' script for Lcalc; we (also) configure
     193# it by patching the Makefile. This may change in a later release of Lcalc.
    188194
    189 cd src   # Now we are in src/src
     195cd src   # Now we are in src/src.
    190196
    191 # Build everything
     197# Build everything:
     198echo >&2 "Now building lcalc, example programs and the shared library..."
    192199$MAKE
    193200success 'make'
    194201
    195 echo >&2 "Now copying over lcalc binary"
     202echo >&2 "Now copying over lcalc binary..."
    196203cp lcalc "$SAGE_LOCAL"/bin
    197204success 'copying binary'
    198205
    199 echo >&2 "Now copying over lcalc library"
     206echo >&2 "Now copying over lcalc library..."
    200207
    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
     208# Remove next few lines when MacOS X 10.4 (Darwin 8) is no longer supported.
     209# 10.4 does not seem to compile with .so extension in the library files.
    203210if [ "$UNAME" = "Darwin" ]; then
    204211    if [ `sysctl -n kern.osrelease | cut -d . -f 1` -lt 9 ]; then
    205212        cp libLfunction.so "$SAGE_LOCAL"/lib/libLfunction.dylib
    206213        success "copying libLfunction.dylib"
    207214    fi
    208 fi #End of Mac OS X 10.4 specific instructions
     215fi # End of MacOS X 10.4 specific instructions
    209216
    210217
    211218if [ "$UNAME" = "CYGWIN" ]; then
     
    215222fi
    216223success "copying libLfunction.so"
    217224
    218 echo >&2 "Now copying over lcalc library header files"
     225echo >&2 "Now copying over lcalc library header files..."
    219226rm -fr "$SAGE_LOCAL"/include/lcalc
    220227mkdir -p "$SAGE_LOCAL"/include/lcalc
    221228cp ../include/* "$SAGE_LOCAL"/include/lcalc
    222 success 'install'
     229success 'copying header files'
  • lcalc-1.23.

    diff -Naur lcalc-1.23.p8/SPKG.txt lcalc-1.23.p9/SPKG.txt
    old new  
    2323
    2424== Dependencies ==
    2525
    26  * MPIR
     26 * GMP/MPIR
    2727 * MPFR
    2828 * PARI
     29 * GNU patch
    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 which should be removed:
     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 * We (and apparently also upstream) currently don't build Lcalc's tests
     47   (see Makefile), hence there's no spkg-check.
     48   This might change in newer upstream versions.
     49 * TODO / FIXME:
     50   The (upstream) Makefile uses $(CC) to compile C++ (also using $(CCFLAGS)),
     51   which it defines to 'g++', and hardcodes 'g++' when linking the shared
     52   library. (It should use $(CXX) instead, which might *default* to 'g++'.)
     53
     54=== Patches ===
     55
     56 * Makefile.patch:
     57   We change a lot there, since Lcalc doesn't have a 'configure' script,
     58   and hence the Makefile is supposed to be edited to customize Lcalc (build
     59   options, locations of headers and libraries etc.).
     60   Besides that, we
     61   - put CXXFLAGS into Lcalc's "CCFLAGS" used for compiling C++,
     62   - remove some stuff involving LDFLAGS1 and LDFLAGS2, setting just LDFLAGS,
     63   - use $(MAKE) instead of 'make' in the crude build receipts,
     64   - use CXXFLAG64 when linking the shared library.
     65 * Lcommon.h.patch:
     66   Uncomment the definition of lcalc_to_double(const long double& x).
     67   (Necessary for GCC >= 4.6.0, cf. #10892.)
     68   Comment from there:
     69     The reason is the following code horror from src/src/include/Lcommon.h:
     70     [...]
     71     But somebody who is familiar with the codebase should really rewrite lcalc
     72     to not redefine the double() cast, thats just fragile and will sooner or
     73     later again fail inside some system headers.
     74 * pari-2.4.4.patch:
     75   (Patches src/src/Lcommandline.cc and src/src/Lcommandline_elliptic.cc)
     76   Use allocatemem() instead of allocatemoremem() which the new PARI no
     77   longer supports. Also replace lgeti() by (long)cgeti().
     78 * time.h.patch:
     79   (Patches src/include/Lcommandline_numbertheory.h)
     80   Include also <time.h> in Lcommandline_numbertheory.h (at least required
     81   on Cygwin, cf. #9845).
     82   This should get reported upstream.
    4483
    4584== Changelog ==
    4685
    47 === lcalc-1.23.p8 (Jeroen Demeyer, 26 July 2011) ===
     86=== lcalc-1.23.p9 (Jeroen Demeyer, Leif Leonhardy, 6 October 2011) ===
    4887 * Trac #11321: Add a patch for PARI-2.4.4 (use allocatemem() instead of
    4988   allocatemoremem())
    5089 * Remove unused patch Lcommandline_elliptic.cc.cygwin.diff
    5190 * Use `patch` for patching instead of `cp`.
    52  * Restore upstream sources (src/src/Makefile was edited)
     91 * Restore upstream sources (src/src/Makefile was edited) but remove
     92   garbage files mentioned above.
    5393 * Remove date from spkg version string
    5494 * Various clean-up in spkg-install
    5595
  • src/src/Makefile.old

    diff -Naur lcalc-1.23.p8/src/src/Makefile.old lcalc-1.23.p9/src/src/Makefile.old
    old new  
    1 #
    2 # Makefile for the L-function calculator version 0.2
    3 #
    4 
    5 #todo: set up a configuration file that will detect
    6 #the operating system, whether gmp, or pari are installed and
    7 #the location of all the relevant files,
    8 #the c compiler, that will generate options which are specific to the
    9 #compilers, optimization options depending on the chip, etc
    10 
    11 
    12 # Comment out the following line to remove the use of pari's
    13 # elliptic curve routines. Doing so disables the -e option.
    14 # g++ with -DINCLUDE_PARI sends a #define INCLUDE_PARI to the preprocessor.
    15 
    16 #PARI_DEFINE = -DINCLUDE_PARI
    17 #PREPROCESSOR_DEFINE = -DUSE_LONG_DOUBLE
    18 
    19 #OPENMP_FLAG = -fopenmp
    20 
    21 #PREPROCESSOR_DEFINE = -DUSE_MPFR
    22 ifeq ($(PREPROCESSOR_DEFINE),-DUSE_MPFR)
    23   #GMP_FLAGS= -L/usr/local/lib -lmpfrcpp -lgmp -lmpfr
    24   GMP_FLAGS= gmpfrxx.o mpfr_mul_d.o -lmpfr -lgmp -lgmpxx -lm
    25 else
    26   GMP_FLAGS=
    27 endif
    28 
    29 
    30 OS_NAME := $(shell uname)
    31 
    32 CC = g++
    33 #cc = /home/mrubinst/local/bin/gcc
    34 #CC = /home/mrubinst/local/bin/g++
    35 #LD = /home/mrubinst/local/bin/g++
    36 
    37 #CC = /Users/michaelrubinstein/math/L/packages/gcc4.3/usr/local/bin/g++
    38 #EXTRA= -pg
    39 #EXTRA = -ftree-vectorize -ftree-vectorizer-verbose=5 -funroll-loops
    40 
    41 
    42 
    43 #MACHINE_SPECIFIC_FLAGS = -Wno-long-double
    44 MACHINE_SPECIFIC_FLAGS = -ffast-math
    45 
    46 #G4 = FALSE
    47 #ifeq ($(G4),TRUE)
    48 #MACHINE_SPECIFIC_FLAGS = -fast -mcpu=G4 -mtune=G4
    49 #endif
    50 
    51 #G5 = TRUE
    52 ifeq ($(G5),TRUE)
    53    #MACHINE_SPECIFIC_FLAGS = -fast -mcpu=G5 -mtune=G5
    54    #MACHINE_SPECIFIC_FLAGS = -ffast-math -maltivec -mpowerpc -mpowerpc64 -ftree-vectorize -ftree-vectorizer-verbose=5 -funroll-loops
    55 
    56    #MACHINE_SPECIFIC_FLAGS = -ffast-math -mpowerpc -mpowerpc64 -ftree-vectorize -ftree-vectorizer-verbose=5 -funroll-loops
    57    MACHINE_SPECIFIC_FLAGS = -ffast-math -mpowerpc -mpowerpc64 -m64
    58    #MACHINE_SPECIFIC_FLAGS = -mpowerpc -mpowerpc64 -m64
    59 endif
    60 
    61 CCFLAGS =  -Wa,-W -O3 $(OPENMP_FLAG) -Wno-deprecated $(PREPROCESSOR_DEFINE) $(MACHINE_SPECIFIC_FLAGS) $(EXTRA)
    62 #CCFLAGS =  -Wa,-W -O3 $(OPENMP_FLAG)  $(PREPROCESSOR_DEFINE) $(MACHINE_SPECIFIC_FLAGS) $(EXTRA)
    63 #CCFLAGS =  -Wa,-W -O2 -fno-exceptions -Wno-deprecated $(PREPROCESSOR_DEFINE) $(MACHINE_SPECIFIC_FLAGS) $(EXTRA)
    64 
    65 #warning- O2 doesn't help with -DUSE_LONG_DOUBLE on mac, and actually seems to hurt, making runtime longer
    66 #by a factor of 1.5
    67 
    68 
    69 ifeq ($(PARI_DEFINE),-DINCLUDE_PARI)
    70     #location of pari.h.
    71     LOCATION_PARI_H = /usr/local/include/pari #usual location
    72 
    73     #location of libpari.a or of libpari.so
    74     #depending on whether static or dynamic libraries are being used.
    75     #On mac os x it's the former, on linux I think usually the latter.
    76     LOCATION_PARI_LIBRARY = /usr/local/lib #usual location
    77 else
    78     #supplied as a dummy so as to avoid more ifeq's below
    79     LOCATION_PARI_H = .
    80     LOCATION_PARI_LIBRARY = .
    81 endif
    82 
    83 
    84 
    85 #INCLUDEFILES= -I../include -I../../packages/gcc4.3/usr/local/include
    86 INCLUDEFILES= -I../include
    87 
    88 #For Mac os x we omit shared library options
    89 
    90 ifeq ($(OS_NAME),Darwin)
    91     LDFLAGS2 =
    92 else
    93     LDFLAGS1 = -Xlinker -export-dynamic #not sure why pari calls these when linking but on the web I found
    94     #'Libtool provides the `-export-dynamic' link flag (see section Link mode), which does this declaration.
    95     #You need to use this flag if you are linking a shared library that will be dlopened'
    96     #see notes below
    97     #ifeq ($(PARI_DEFINE),-DINCLUDE_PARI)
    98        LDFLAGS2 = $(LDFLAGS1) -Xlinker -rpath -Xlinker $(LOCATION_PARI_LIBRARY)
    99     #else
    100     #    LDFLAGS2 = $(LDFLAGS1)
    101     #endif
    102 endif
    103 
    104 ifeq ($(PARI_DEFINE),-DINCLUDE_PARI)
    105     LDFLAGS = $(LDFLAGS2) -L$(LOCATION_PARI_LIBRARY) -lpari
    106 else
    107     LDFLAGS = $(LDFLAGS2)
    108 endif
    109 
    110 
    111 
    112 #NOTES:
    113 #for caedmon: the shared pari library is in a funny location: /usr/local/pari/pari-2.1.5/lib
    114 #At compile time we need to specify that location with:
    115 #    -L/usr/local/pari/pari-2.1.5/lib -lpari
    116 #At runtime, the computer attempts to load the pari shared library, and if it isn't in a standard
    117 #location, we can do two things.
    118 #1) One page suggested:
    119 #    -Xlinker -rpath -Xlinker /usr/local/pari/pari-2.1.5/lib
    120 #2) The other option, not recommended, is to type at the unix prompt:
    121 #    LD_LIBRARY_PATH=/usr/local/pari/pari-2.1.5/lib:$LD_LIBRARY_PATH
    122 #    export LD_LIBRARY_PATH
    123 #If this is not done correctly, at runntime one gets the error
    124 #    ./lcalc: error while loading shared libraries: libpari.so.1: cannot open shared
    125 #    object file: No such file or directory
    126 #One can list, after compiling, dynamic dependencies with the command: ldd lcalc and it will
    127 #become clear which libraries the computer can find.
    128 
    129 
    130 INSTALL_DIR= /usr/local
    131 
    132 #object files for the libLfunction library
    133 OBJ_L = Lglobals.o Lgamma.o Lriemannsiegel.o Lriemannsiegel_blfi.o Ldokchitser.o
    134 
    135 #object files for the command line program
    136 OBJ2=$(OBJ_L) Lcommandline_globals.o Lcommandline_misc.o Lcommandline_numbertheory.o Lcommandline_values_zeros.o
    137 OBJ3=$(OBJ2) Lcommandline_elliptic.o Lcommandline_twist.o Lcommandline.o cmdline.o
    138 OBJECTS = $(OBJ3)
    139 
    140 all:
    141 #       make print_vars
    142         make libLfunction.a
    143         make lcalc
    144         make examples
    145 #       make find_L
    146 #       make test
    147 
    148 print_vars:
    149         @echo OS_NAME = $(OS_NAME)
    150 
    151 lcalc: $(OBJECTS)
    152         $(CC) $(CCFLAGS) $(INCLUDEFILES) $(OBJECTS) $(LDFLAGS) -o lcalc $(GMP_FLAGS)
    153 
    154 examples:
    155         $(CC) $(CCFLAGS) $(INCLUDEFILES) example_programs/example.cc libLfunction.a -o example_programs/example $(GMP_FLAGS)
    156 
    157 
    158 proc:
    159         $(CC) $(CCFLAGS) $(INCLUDEFILES) example_programs/proc.cc libLfunction.a -o example_programs/proc $(GMP_FLAGS)
    160 
    161 test:
    162         $(CC) $(CCFLAGS) $(INCLUDEFILES) example_programs/test.cc libLfunction.a -o example_programs/test $(GMP_FLAGS)
    163 
    164 find_L:
    165         $(CC) $(CCFLAGS) $(INCLUDEFILES) find_L_functions/find_L_functions.cc libLfunction.a -o find_L_functions/find_L $(GMP_FLAGS)
    166 
    167 .cc.o:
    168         $(CC) $(CCFLAGS) $(INCLUDEFILES) -c $<
    169 .c.o:
    170         $(CC) $(CCFLAGS) $(INCLUDEFILES) -c $<
    171 
    172 
    173 Lglobals.o: ../include/Lglobals.h ../include/Lcommon.h ../include/Lcomplex.h ../include/Lnumeric.h ../include/Lint_complex.h
    174 
    175 #Lmisc.o: ../include/Lmisc.h ../include/Lglobals.h ../include/Lcommon.h ../include/Lcomplex.h ../include/Lnumeric.h ../include/Lint_complex.h
    176 
    177 Lgamma.o: ../include/Lgamma.h ../include/Lglobals.h ../include/Lcommon.h ../include/Lcomplex.h ../include/Lnumeric.h ../include/Lint_complex.h
    178 
    179 Lriemannsiegel.o: ../include/Lriemannsiegel.h ../include/Lglobals.h ../include/Lcommon.h ../include/Lcomplex.h ../include/Lnumeric.h
    180 Lriemannsiegel.o: ../include/Lint_complex.h ../include/Lgamma.h
    181 Lriemannsiegel.o: ../include/Lmisc.h
    182 
    183 Ldokchitser.o: ../include/Ldokchitser.h ../include/Lglobals.h ../include/Lcommon.h ../include/Lcomplex.h ../include/Lnumeric.h ../include/Lint_complex.h
    184 
    185 #all I need here is dependence on the definition of the L-function class
    186 #and the Complex typedef
    187 Lcommandline_globals.o: ../include/Lcommandline_globals.h ../include/L.h
    188 Lcommandline_globals.o: ../include/Lglobals.h ../include/Lcommon.h ../include/Lcomplex.h ../include/Lnumeric.h ../include/Lint_complex.h
    189 #Lcommandline_globals.o: ../include/Lmisc.h ../include/Lgamma.h
    190 #Lcommandline_globals.o: ../include/Lriemannsiegel.h
    191 #Lcommandline_globals.o: ../include/Ldirichlet_series.h ../include/Lprint.h
    192 #Lcommandline_globals.o: ../include/Lnumberzeros.h ../include/Lgram.h
    193 #Lcommandline_globals.o: ../include/Lvalue.h ../include/Lfind_zeros.h
    194 
    195 Lcommandline_misc.o: ../include/Lcommandline_misc.h ../include/L.h
    196 Lcommandline_misc.o: ../include/Lglobals.h ../include/Lcommon.h ../include/Lcomplex.h ../include/Lnumeric.h ../include/Lint_complex.h
    197 Lcommandline_misc.o: ../include/Lmisc.h ../include/Lgamma.h
    198 Lcommandline_misc.o: ../include/Lriemannsiegel.h
    199 Lcommandline_misc.o: ../include/Ldirichlet_series.h ../include/Lprint.h
    200 Lcommandline_misc.o: ../include/Lnumberzeros.h ../include/Lgram.h
    201 Lcommandline_misc.o: ../include/Lvalue.h ../include/Lfind_zeros.h
    202 Lcommandline_misc.o: ../include/Lcommandline_numbertheory.h
    203 Lcommandline_misc.o: ../include/Lcommandline_globals.h
    204 
    205 Lcommandline_numbertheory.o: ../include/Lcommandline_numbertheory.h
    206 Lcommandline_numbertheory.o: ../include/Lglobals.h ../include/Lcommon.h ../include/Lcomplex.h ../include/Lnumeric.h ../include/Lint_complex.h
    207 
    208 Lcommandline_values_zeros.o: ../include/Lcommandline_values_zeros.h
    209 Lcommandline_values_zeros.o: ../include/L.h ../include/Lglobals.h ../include/Lcommon.h ../include/Lcomplex.h ../include/Lnumeric.h
    210 Lcommandline_values_zeros.o: ../include/Lint_complex.h ../include/Lmisc.h
    211 Lcommandline_values_zeros.o: ../include/Lgamma.h ../include/Lriemannsiegel.h
    212 Lcommandline_values_zeros.o: ../include/Ldirichlet_series.h
    213 Lcommandline_values_zeros.o: ../include/Lprint.h ../include/Lnumberzeros.h
    214 Lcommandline_values_zeros.o: ../include/Lgram.h ../include/Lvalue.h
    215 Lcommandline_values_zeros.o: ../include/Lfind_zeros.h
    216 Lcommandline_values_zeros.o: ../include/Lcommandline_numbertheory.h
    217 Lcommandline_values_zeros.o: ../include/Lcommandline_globals.h
    218 
    219 Lcommandline_elliptic.o: ../include/Lcommandline_elliptic.h ../include/L.h
    220 Lcommandline_elliptic.o: ../include/Lglobals.h ../include/Lcommon.h ../include/Lcomplex.h ../include/Lnumeric.h ../include/Lint_complex.h
    221 #Lcommandline_elliptic.o: ../include/Lmisc.h ../include/Lgamma.h
    222 Lcommandline_elliptic.o: ../include/Lriemannsiegel.h
    223 Lcommandline_elliptic.o: ../include/Ldirichlet_series.h ../include/Lprint.h
    224 Lcommandline_elliptic.o: ../include/Lnumberzeros.h ../include/Lgram.h
    225 Lcommandline_elliptic.o: ../include/Lvalue.h ../include/Lfind_zeros.h
    226 Lcommandline_elliptic.o: ../include/Lcommandline_numbertheory.h
    227 Lcommandline_elliptic.o: ../include/Lcommandline_globals.h
    228         $(CC) $(CCFLAGS) $(INCLUDEFILES) -I$(LOCATION_PARI_H) $(PARI_DEFINE) -c Lcommandline_elliptic.cc
    229 
    230 Lcommandline_twist.o: ../include/Lcommandline_twist.h ../include/L.h
    231 Lcommandline_twist.o: ../include/Lglobals.h ../include/Lcommon.h ../include/Lcomplex.h ../include/Lnumeric.h ../include/Lint_complex.h
    232 #Lcommandline_twist.o: ../include/Lmisc.h ../include/Lgamma.h
    233 Lcommandline_twist.o: ../include/Lriemannsiegel.h
    234 Lcommandline_twist.o: ../include/Ldirichlet_series.h ../include/Lprint.h
    235 Lcommandline_twist.o: ../include/Lnumberzeros.h ../include/Lgram.h
    236 Lcommandline_twist.o: ../include/Lvalue.h ../include/Lfind_zeros.h
    237 Lcommandline_twist.o: ../include/Lcommandline_numbertheory.h
    238 Lcommandline_twist.o: ../include/Lcommandline_globals.h
    239 Lcommandline_twist.o: ../include/Lcommandline_elliptic.h
    240         $(CC) $(CCFLAGS) $(INCLUDEFILES) -I$(LOCATION_PARI_H) $(PARI_DEFINE) -c Lcommandline_twist.cc
    241 
    242 cmdline.o: ../include/cmdline.h ../include/getopt.h
    243 #$(CC) $(CCFLAGS) $(INCLUDEFILES) -DHAVE_LONG_LONG -c cmdline.c
    244 
    245 
    246 Lcommandline.o: ../include/Lcommandline.h ../include/L.h
    247 Lcommandline.o: ../include/Lglobals.h ../include/Lcommon.h ../include/Lcomplex.h ../include/Lnumeric.h ../include/Lint_complex.h
    248 Lcommandline.o: ../include/Lmisc.h ../include/Lgamma.h
    249 Lcommandline.o: ../include/Lriemannsiegel.h ../include/Ldirichlet_series.h
    250 Lcommandline.o: ../include/Lprint.h ../include/Lnumberzeros.h
    251 Lcommandline.o: ../include/Lgram.h ../include/Lvalue.h
    252 Lcommandline.o: ../include/Lfind_zeros.h
    253 Lcommandline.o: ../include/Lcommandline_numbertheory.h
    254 Lcommandline.o: ../include/Lcommandline_globals.h
    255 Lcommandline.o: ../include/Lcommandline_misc.h
    256 Lcommandline.o: ../include/Lcommandline_elliptic.h
    257 Lcommandline.o: ../include/Lcommandline_twist.h
    258 Lcommandline.o: ../include/Lcommandline_values_zeros.h
    259         $(CC) $(CCFLAGS) $(INCLUDEFILES) -I$(LOCATION_PARI_H) $(PARI_DEFINE) -c Lcommandline.cc
    260 
    261 
    262 libLfunction.a: $(OBJ_L)
    263         ar ruv libLfunction.a $(OBJ_L)
    264         ranlib libLfunction.a
    265 
    266 clean:
    267         rm -f *.o lcalc libLfunction.a example_programs/example
    268 
    269 install:
    270         cp -f lcalc $(INSTALL_DIR)/bin/.
    271         cp -f libLfunction.a $(INSTALL_DIR)/lib/.
    272         ranlib $(INSTALL_DIR)/lib/libLfunction.a
    273         cp -rf ../include $(INSTALL_DIR)/include/Lfunction
    274 
    275 
    276 SRCS = Lcommandline.cc Lcommandline_elliptic.cc Lcommandline_globals.cc Lcommandline_misc.cc Lcommandline_numbertheory.cc Lcommandline_twist.cc Lcommandline_values_zeros.cc Lgamma.cc Lglobals.cc Lmisc.cc Lriemannsiegel.cc Lriemannsiegel_blfi.cc cmdline.c
    277 depend:
    278         makedepend -f depends -- $(CCFLAGS) -Y../include -- $(SRCS)