scripts/bootstrap.sh
author Peter Kovacs <kpeter@inf.elte.hu>
Tue, 09 Feb 2010 23:29:51 +0100
changeset 823 a7e93de12cbd
parent 747 a42f46828cc1
child 850 e77b621e6e7e
permissions -rwxr-xr-x
Add a warning about huge capacities in Preflow (#319)
alpar@732
     1
#!/bin/bash
alpar@732
     2
#
alpar@732
     3
# This file is a part of LEMON, a generic C++ optimization library.
alpar@732
     4
#
alpar@732
     5
# Copyright (C) 2003-2009
alpar@732
     6
# Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
alpar@732
     7
# (Egervary Research Group on Combinatorial Optimization, EGRES).
alpar@732
     8
#
alpar@732
     9
# Permission to use, modify and distribute this software is granted
alpar@732
    10
# provided that this copyright notice appears in all copies. For
alpar@732
    11
# precise terms see the accompanying LICENSE file.
alpar@732
    12
#
alpar@732
    13
# This software is provided "AS IS" with no warranty of any kind,
alpar@732
    14
# express or implied, and with no claim as to its suitability for any
alpar@732
    15
# purpose.
alpar@732
    16
alpar@732
    17
alpar@732
    18
if [ ! -f ~/.lemon-bootstrap ]; then
alpar@732
    19
    echo 'Create ~/.lemon-bootstrap'.
alpar@732
    20
    cat >~/.lemon-bootstrap <<EOF
alpar@732
    21
#
alpar@732
    22
# Default settings for bootstraping the LEMON source code repository
alpar@732
    23
#
alpar@732
    24
EOF
alpar@732
    25
fi
alpar@732
    26
alpar@732
    27
source ~/.lemon-bootstrap
alpar@732
    28
if [ -f ../../../.lemon-bootstrap ]; then source ../../../.lemon-bootstrap; fi
alpar@732
    29
if [ -f ../../.lemon-bootstrap ]; then source ../../.lemon-bootstrap; fi
alpar@732
    30
if [ -f ../.lemon-bootstrap ]; then source ../.lemon-bootstrap; fi
alpar@732
    31
if [ -f ./.lemon-bootstrap ]; then source ./.lemon-bootstrap; fi
alpar@732
    32
alpar@732
    33
alpar@732
    34
function augment_config() { 
alpar@732
    35
    if [ "x${!1}" == "x" ]; then
alpar@732
    36
        eval $1=$2
alpar@732
    37
        echo Add "'$1'" to '~/.lemon-bootstrap'.
alpar@732
    38
        echo >>~/.lemon-bootstrap
alpar@732
    39
        echo $3 >>~/.lemon-bootstrap
alpar@732
    40
        echo $1=$2 >>~/.lemon-bootstrap
alpar@732
    41
    fi
alpar@732
    42
}
alpar@732
    43
alpar@732
    44
augment_config LEMON_INSTALL_PREFIX /usr/local \
alpar@732
    45
    "# LEMON installation prefix"
alpar@732
    46
alpar@732
    47
augment_config COIN_OR_PREFIX /usr/local/coin-or \
alpar@732
    48
    "# COIN-OR installation root prefix (used for CLP/CBC)"
alpar@732
    49
alpar@747
    50
augment_config SOPLEX_PREFIX /usr/local/soplex \
alpar@747
    51
    "# Soplex build prefix"
alpar@747
    52
alpar@732
    53
alpar@732
    54
function ask() {
alpar@732
    55
echo -n "$1 [$2]? "
alpar@732
    56
read _an
alpar@732
    57
if [ "x$_an" == "x" ]; then
alpar@732
    58
    ret="$2"
alpar@732
    59
else
alpar@732
    60
    ret=$_an
alpar@732
    61
fi
alpar@732
    62
}
alpar@732
    63
alpar@732
    64
function yesorno() {
alpar@732
    65
    ret='rossz'
alpar@732
    66
    while [ "$ret" != "y" -a "$ret" != "n" -a "$ret" != "yes" -a "$ret" != "no" ]; do
alpar@732
    67
        ask "$1" "$2"
alpar@732
    68
    done
alpar@732
    69
    if [ "$ret" != "y" -a "$ret" != "yes" ]; then
alpar@732
    70
        return 1
alpar@732
    71
    else
alpar@732
    72
        return 0
alpar@732
    73
    fi
alpar@732
    74
}
alpar@732
    75
alpar@732
    76
if yesorno "External build" "n"
alpar@732
    77
then
alpar@732
    78
    CONFIGURE_PATH=".."
alpar@732
    79
else
alpar@732
    80
    CONFIGURE_PATH="."
alpar@732
    81
    if yesorno "Autoreconf" "y"
alpar@732
    82
    then
alpar@732
    83
        AUTORE=yes
alpar@732
    84
    else
alpar@732
    85
        AUTORE=no
alpar@732
    86
    fi
alpar@732
    87
fi
alpar@732
    88
alpar@732
    89
if yesorno "Optimize" "n" 
alpar@732
    90
then
alpar@732
    91
    opt_flags=' -O2'
alpar@732
    92
else
alpar@732
    93
    opt_flags=''
alpar@732
    94
fi
alpar@732
    95
alpar@732
    96
if yesorno "Stop on warning" "y" 
alpar@732
    97
then
alpar@732
    98
    werror_flags=' -Werror'
alpar@732
    99
else
alpar@732
   100
    werror_flags=''
alpar@732
   101
fi
alpar@732
   102
alpar@732
   103
cxx_flags="CXXFLAGS=-ggdb$opt_flags$werror_flags"
alpar@732
   104
alpar@794
   105
if yesorno "Check with valgrind" "n" 
alpar@794
   106
then
alpar@794
   107
    valgrind_flags=' --enable-valgrind'
alpar@794
   108
else
alpar@794
   109
    valgrind_flags=''
alpar@794
   110
fi
alpar@794
   111
alpar@747
   112
if [ -f ${COIN_OR_PREFIX}/include/coin/config_coinutils.h ]; then
alpar@747
   113
    if yesorno "Use COIN-OR (CBC/CLP)" "n"
alpar@747
   114
    then
alpar@747
   115
        coin_flag="--with-coin=$COIN_OR_PREFIX"
alpar@747
   116
    else
alpar@747
   117
        coin_flag=""
alpar@747
   118
    fi
alpar@732
   119
else
alpar@747
   120
    coin_flag=""        
alpar@732
   121
fi
alpar@732
   122
alpar@747
   123
if [ -f ${SOPLEX_PREFIX}/src/soplex.h ]; then
alpar@747
   124
    if yesorno "Use Soplex" "n"
alpar@747
   125
    then
alpar@747
   126
        soplex_flag="--with-soplex=$SOPLEX_PREFIX"
alpar@747
   127
    else
alpar@747
   128
        soplex_flag=""
alpar@747
   129
    fi
alpar@747
   130
else
alpar@747
   131
    soplex_flag=""
alpar@747
   132
fi
alpar@732
   133
alpar@732
   134
if [ "x$AUTORE" == "xyes" ]; then
alpar@732
   135
    autoreconf -vif;
alpar@732
   136
fi
alpar@732
   137
${CONFIGURE_PATH}/configure --prefix=$LEMON_INSTALL_PREFIX \
alpar@794
   138
$valgrind_flags \
alpar@732
   139
"$cxx_flags" \
alpar@732
   140
$coin_flag \
alpar@747
   141
$soplex_flag \
alpar@732
   142
$*