scripts/bootstrap.sh
changeset 770 432c54cec63c
parent 732 1f8ad32f088b
child 794 313d58f9e544
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/scripts/bootstrap.sh	Thu Nov 05 08:39:49 2009 +0100
     1.3 @@ -0,0 +1,134 @@
     1.4 +#!/bin/bash
     1.5 +#
     1.6 +# This file is a part of LEMON, a generic C++ optimization library.
     1.7 +#
     1.8 +# Copyright (C) 2003-2009
     1.9 +# Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
    1.10 +# (Egervary Research Group on Combinatorial Optimization, EGRES).
    1.11 +#
    1.12 +# Permission to use, modify and distribute this software is granted
    1.13 +# provided that this copyright notice appears in all copies. For
    1.14 +# precise terms see the accompanying LICENSE file.
    1.15 +#
    1.16 +# This software is provided "AS IS" with no warranty of any kind,
    1.17 +# express or implied, and with no claim as to its suitability for any
    1.18 +# purpose.
    1.19 +
    1.20 +
    1.21 +if [ ! -f ~/.lemon-bootstrap ]; then
    1.22 +    echo 'Create ~/.lemon-bootstrap'.
    1.23 +    cat >~/.lemon-bootstrap <<EOF
    1.24 +#
    1.25 +# Default settings for bootstraping the LEMON source code repository
    1.26 +#
    1.27 +EOF
    1.28 +fi
    1.29 +
    1.30 +source ~/.lemon-bootstrap
    1.31 +if [ -f ../../../.lemon-bootstrap ]; then source ../../../.lemon-bootstrap; fi
    1.32 +if [ -f ../../.lemon-bootstrap ]; then source ../../.lemon-bootstrap; fi
    1.33 +if [ -f ../.lemon-bootstrap ]; then source ../.lemon-bootstrap; fi
    1.34 +if [ -f ./.lemon-bootstrap ]; then source ./.lemon-bootstrap; fi
    1.35 +
    1.36 +
    1.37 +function augment_config() { 
    1.38 +    if [ "x${!1}" == "x" ]; then
    1.39 +        eval $1=$2
    1.40 +        echo Add "'$1'" to '~/.lemon-bootstrap'.
    1.41 +        echo >>~/.lemon-bootstrap
    1.42 +        echo $3 >>~/.lemon-bootstrap
    1.43 +        echo $1=$2 >>~/.lemon-bootstrap
    1.44 +    fi
    1.45 +}
    1.46 +
    1.47 +augment_config LEMON_INSTALL_PREFIX /usr/local \
    1.48 +    "# LEMON installation prefix"
    1.49 +
    1.50 +augment_config COIN_OR_PREFIX /usr/local/coin-or \
    1.51 +    "# COIN-OR installation root prefix (used for CLP/CBC)"
    1.52 +
    1.53 +augment_config SOPLEX_PREFIX /usr/local/soplex \
    1.54 +    "# Soplex build prefix"
    1.55 +
    1.56 +
    1.57 +function ask() {
    1.58 +echo -n "$1 [$2]? "
    1.59 +read _an
    1.60 +if [ "x$_an" == "x" ]; then
    1.61 +    ret="$2"
    1.62 +else
    1.63 +    ret=$_an
    1.64 +fi
    1.65 +}
    1.66 +
    1.67 +function yesorno() {
    1.68 +    ret='rossz'
    1.69 +    while [ "$ret" != "y" -a "$ret" != "n" -a "$ret" != "yes" -a "$ret" != "no" ]; do
    1.70 +        ask "$1" "$2"
    1.71 +    done
    1.72 +    if [ "$ret" != "y" -a "$ret" != "yes" ]; then
    1.73 +        return 1
    1.74 +    else
    1.75 +        return 0
    1.76 +    fi
    1.77 +}
    1.78 +
    1.79 +if yesorno "External build" "n"
    1.80 +then
    1.81 +    CONFIGURE_PATH=".."
    1.82 +else
    1.83 +    CONFIGURE_PATH="."
    1.84 +    if yesorno "Autoreconf" "y"
    1.85 +    then
    1.86 +        AUTORE=yes
    1.87 +    else
    1.88 +        AUTORE=no
    1.89 +    fi
    1.90 +fi
    1.91 +
    1.92 +if yesorno "Optimize" "n" 
    1.93 +then
    1.94 +    opt_flags=' -O2'
    1.95 +else
    1.96 +    opt_flags=''
    1.97 +fi
    1.98 +
    1.99 +if yesorno "Stop on warning" "y" 
   1.100 +then
   1.101 +    werror_flags=' -Werror'
   1.102 +else
   1.103 +    werror_flags=''
   1.104 +fi
   1.105 +
   1.106 +cxx_flags="CXXFLAGS=-ggdb$opt_flags$werror_flags"
   1.107 +
   1.108 +if [ -f ${COIN_OR_PREFIX}/include/coin/config_coinutils.h ]; then
   1.109 +    if yesorno "Use COIN-OR (CBC/CLP)" "n"
   1.110 +    then
   1.111 +        coin_flag="--with-coin=$COIN_OR_PREFIX"
   1.112 +    else
   1.113 +        coin_flag=""
   1.114 +    fi
   1.115 +else
   1.116 +    coin_flag=""        
   1.117 +fi
   1.118 +
   1.119 +if [ -f ${SOPLEX_PREFIX}/src/soplex.h ]; then
   1.120 +    if yesorno "Use Soplex" "n"
   1.121 +    then
   1.122 +        soplex_flag="--with-soplex=$SOPLEX_PREFIX"
   1.123 +    else
   1.124 +        soplex_flag=""
   1.125 +    fi
   1.126 +else
   1.127 +    soplex_flag=""
   1.128 +fi
   1.129 +
   1.130 +if [ "x$AUTORE" == "xyes" ]; then
   1.131 +    autoreconf -vif;
   1.132 +fi
   1.133 +${CONFIGURE_PATH}/configure --prefix=$LEMON_INSTALL_PREFIX \
   1.134 +"$cxx_flags" \
   1.135 +$coin_flag \
   1.136 +$soplex_flag \
   1.137 +$*