On Tue, 28 Oct 2003, Lars Gullik Bj�nnes wrote:

> Christian Ridderstr�m <[EMAIL PROTECTED]> writes:
> 
> | Could be... it's what came with RedHat 7.3.  Anyway, linking only produces 
> | other errors, so I'll just keep on working using gcc 3.3.2 instead.
> >
> | If it's important to make LyX compile with 2.9.6 in the future, I can 
> | take another look at this.
> 
> yeah... RH 7.3  how old is that now? RH 8 has come and gone, RH 9 is
> still going strong, with RH 10 looming on the horizon...
> 
> I am of course a strange creature, but I see no reason to stick with
> RH 7.3, especially not for C++ developers, or people that expect to
> compile C++ code.

Unless you are ranting, I was mainly thinking about users who would like 
to be able to install lyx 1.4 on RH 7.3...
(it's strange, but later versions of RH need better hardware...)

In my case (on our system) I just do
        'module add gcc/<version>'
to use the desired version of gcc... which reminds me, let me know if 
anyone would like me to try compiling using a specific version. Since I've 
been changing back and forth between different compilers for a while now, 
I ended up writing a script that does the whole cycle for me. (see 
attached file)

/Christian

-- 
Christian Ridderstr�m                           http://www.md.kth.se/~chr
#!/bin/bash

S0=`basename $0`
D0=`dirname $0`

if [[ "x$1" == "x" || "x$1" == "x--help" || "x$1" == "x-h" ]]; then
    cat <<EOF
Syntax: $S0 [options] 

Options:
  -v                    Be more verbose
  -n                    Only print commands, do not actually run
  -f config-file        Name of configuration file to use
  -l log-file           Set name of log-file
  --no-rm               Don't remove previous build directory
  --no-cvs              Don't run cvs update and autogen.sh
  --no-configure        Don't run configure
  --no-make             Don't run make

Example:
 # Read commands from xforms-devel.cfg
 $ $0 -f etc/xforms-devel.cfg

Note that the configuration file is first looked for in the current
directory, and then relative to where the script is located.

EOF
exit 0;
fi

if [[ "x$1" == "x--version" ]]; then printf "$S0 1.0\n"; exit 0; fi

# Use: Verbose 1 "Only printed if Verbose >= 1, arg: %s" "an argument"
# The first numeric argument can be skipped if the condition is onl that
# the verbosity > 0
function Verbose() {
    if [[ ${#1} -eq 1 && $Verbosity -lt $1 ]]; then return; fi;
    if [[ ${#1} -ne 1 && $Verbosity -eq 0 ]]; then return; fi;
    if [[ ${#1} -eq 1 ]]; then shift; fi;
    FMT="$1\n"
    shift;
    printf "$FMT" "$@"
}

function Log() {
    Verbose 0 "# ""$@" | tee --append $LogFile
}

# Use: Error -1 "This argument is wrong: %s" "an argument"
function Error() {
    ERROR_CODE=$1;
    shift;
    printf "%s: Error(%d) " "`basename $0`" $ERROR_CODE
    FMT="$1\n"
    shift
    printf "$FMT" "$@"
    exit $ERROR_CODE
}

# For some reason, 'cd' doesn't work when |tee is used...
function Do() {
    if (($DO)); then msg=""; else msg="## "; fi;
    if (($Verbosity >= 1)); then Log "%s%s" "$msg" "$*"; fi;
    fail=0
    if (($DO)); then
        "$@" | tee --append $LogFile ;
        fail=${PIPESTATUS[0]}
    fi;
    return $fail
}

ConfigFilesRead=0
function ReadConfiguration() {
    Verbose 2 "Looking for configuration file"
    for FIL in "$@" ; do
        Verbose 3 "Checking for %s" "$FIL"
        if [[ -r $FIL ]]; then
            Verbose 1 "Reading %s" "$FIL"
            source $FIL
            let ++ConfigFilesRead
        elif [[ -r $D0/$FIL ]]; then
            Verbose 1 "Reading %s/%s" "$D0" "$FIL"
            source $D0/$FIL
            let ++ConfigFilesRead
        else
            Verbose 2 "Configuration file %s not found" "$FIL"
        fi
    done
    if (( $ConfigFilesRead > 0 )); then
        Verbose 2 "Configuration after reading configuration files:"
        if (( $Verbosity >= 2 )); then ShowConfiguration; fi
    fi
}

#
# Set default values of variables
#
# Standard variables
Verbosity=0                     # Controls the level of verbosity
DO=1                            # Is set false if nothing should be done
LogFile=
#
# Script specific variables
MODULE_LYX=lyx/devel/latest-xforms
MODULE_GCC=gcc/3.3.2
BuildPostfix=""
OPTS_CONFIGURE=(--with-extra-prefix=/pkg/mdhacks/grp/util \
    --with-version-suffix --disable-libtool-lock)
DO_RM=1;                        # Remove previous build directory?
DO_CVS=1;                       # Do CVS update
DO_CONFIGURE=1;                 # Run configure
DO_MAKE=1;                      # Run make

function ShowConfiguration(){
    if (( $Verbosity >= 2 )); then
        Verbose "Variables in the script:"
        Verbose "DO=%s" "$DO"
        Verbose "buildDir=%s" "$buildDir"
        Verbose "BuildPostfix=%s" "$BuildPostfix"
        Verbose ""
    fi;
}

# Initialize modules
. /usr/local/lib/module/default/init/bash
module rm lyx gcc               # Remove any lyx and gcc modules
if (($?)); then Error -1 "While removing modules"; fi;

# Parse arguments
savedArgs="$*"
for ARG in "$@"; do if [[ "$ARG" == "-v" ]]; then let ++Verbosity; fi; done;

until [[ $# -eq 0 ]]; do
    case "$1" in
        -v)     ;;              # Already parsed for
        -n)     DO=0 ;;
        --no-rm)        DO_RM=0 ;;
        --no-cvs)       DO_CVS=0 ;;
        --no-make)      DO_MAKE=0 ;;
        --no-configure) DO_CONFIGURE=0 ;;
        -f)     ReadConfiguration $2; shift ;;
        -l)     LogFile=$2; shift ;;
        -*)     Error -1 "Unknown option: %s" "$1" ;;
        *)      Error -2 "Unkown argument: %s" "$1" ;;
    esac
    shift;
done
Verbose "Output is verbose (verbosity = %d)" "$Verbosity"
if (( $Verbosity >= 2 )); then ShowConfiguration; fi

if (( $ConfigFilesRead == 0 )); then
    Error -2 "No configuration file specified!"
fi;

# Initialize log-file
Verbose 0 "Log file 0 %s\n" "$LogFile"

printf "# --------------------------------\n"\
"# Log file from executing:\n#  %s$ %s %s\n" \
"`pwd`" "$0""$savedArgs" > $LogFile
Log "Date: %s\n" "`date`"

# Verify validity of arguments
# if [[ "x$Adr" == "x" ]]; then Error "No address given!"; fi;

#
# -----------------------
# Actually do stuff...
#

# Add modules
module add $MODULE_LYX $MODULE_GCC  2>&1 1>>$LogFile
if (($?)); then Error -1 "While loading modules"; fi;

buildDir=$LYXDEVEL/$LYXTAG/build-$LYXFRONTEND
if [[ "x$BuildPostfix" != "x" ]]; then buildDir="$buildDir-$BuildPostfix"; fi;

GCC_VERSION="`gcc --version`"
Log "Using %s" "${GCC_VERSION%%Copyright*}"

if (($DO_RM)); then
    Log "Erasing and recreating build directory: %s" "$buildDir"
    Do rm -rf $buildDir && Do mkdir -p $buildDir
    if (($?)); then Error -2 "While erasing/creating build directory"; fi
else
    Log "Skipping erasing build directory"
fi;

if (($DO_RM || $DO_CVS)); then
    Log "Updating source and then running autogen.sh"
    cd $LYXDEVEL/$LYXTAG && Do cvs -q update -d && Do ./autogen.sh
    if (($?)); then Error -3 "While cvs update or autogen.sh"; fi
else
    Log "Skipping 'cvs update' and autogen"
fi;

if (($DO_RM || $DO_CVS || $DO_CONFIGURE)); then
    Log "Running configure"
    if (($DO)); then cd $buildDir; fi
    Do ../configure --prefix=$LYXPREFIX ${OPTS_CONFIGURE[*]}
    if (($?)); then Error -4 "While running configure"; fi
else
    Log "Skipping configure"
fi;

if (($DO_MAKE)); then
    Log "Running make"
    Do make -j 5
    if (($?)); then Error -5 "While running make"; fi
else
    Log "Skipping make"
fi;





MODULE_LYX=lyx/devel/latest-xforms
MODULE_GCC=gcc/3.3.2
BuildPostfix=
OPTS_CONFIGURE=(--with-extra-prefix=/pkg/mdhacks/grp/util \
    --with-version-suffix --disable-libtool-lock \
    --with-frontend=xforms )
LogFile=$HOME/public_html/lyx/build-logs/xforms-devel.log

Reply via email to