scripts/bootstrap.sh
author Akos Ladanyi <ladanyi@tmit.bme.hu>
Wed, 25 Aug 2010 21:34:58 +0200
changeset 897 e20fecd1945f
parent 794 313d58f9e544
permissions -rwxr-xr-x
Add check target for CMake (#388)
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@850
    47
augment_config GLPK_PREFIX /usr/local/ \
alpar@850
    48
    "# GLPK installation root prefix"
alpar@850
    49
alpar@732
    50
augment_config COIN_OR_PREFIX /usr/local/coin-or \
alpar@732
    51
    "# COIN-OR installation root prefix (used for CLP/CBC)"
alpar@732
    52
alpar@747
    53
augment_config SOPLEX_PREFIX /usr/local/soplex \
alpar@747
    54
    "# Soplex build prefix"
alpar@747
    55
alpar@732
    56
alpar@732
    57
function ask() {
alpar@732
    58
echo -n "$1 [$2]? "
alpar@732
    59
read _an
alpar@732
    60
if [ "x$_an" == "x" ]; then
alpar@732
    61
    ret="$2"
alpar@732
    62
else
alpar@732
    63
    ret=$_an
alpar@732
    64
fi
alpar@732
    65
}
alpar@732
    66
alpar@732
    67
function yesorno() {
alpar@732
    68
    ret='rossz'
alpar@732
    69
    while [ "$ret" != "y" -a "$ret" != "n" -a "$ret" != "yes" -a "$ret" != "no" ]; do
alpar@732
    70
        ask "$1" "$2"
alpar@732
    71
    done
alpar@732
    72
    if [ "$ret" != "y" -a "$ret" != "yes" ]; then
alpar@732
    73
        return 1
alpar@732
    74
    else
alpar@732
    75
        return 0
alpar@732
    76
    fi
alpar@732
    77
}
alpar@732
    78
alpar@732
    79
if yesorno "External build" "n"
alpar@732
    80
then
alpar@732
    81
    CONFIGURE_PATH=".."
alpar@732
    82
else
alpar@732
    83
    CONFIGURE_PATH="."
alpar@732
    84
    if yesorno "Autoreconf" "y"
alpar@732
    85
    then
alpar@732
    86
        AUTORE=yes
alpar@732
    87
    else
alpar@732
    88
        AUTORE=no
alpar@732
    89
    fi
alpar@732
    90
fi
alpar@732
    91
alpar@732
    92
if yesorno "Optimize" "n" 
alpar@732
    93
then
alpar@732
    94
    opt_flags=' -O2'
alpar@732
    95
else
alpar@732
    96
    opt_flags=''
alpar@732
    97
fi
alpar@732
    98
alpar@732
    99
if yesorno "Stop on warning" "y" 
alpar@732
   100
then
alpar@732
   101
    werror_flags=' -Werror'
alpar@732
   102
else
alpar@732
   103
    werror_flags=''
alpar@732
   104
fi
alpar@732
   105
alpar@732
   106
cxx_flags="CXXFLAGS=-ggdb$opt_flags$werror_flags"
alpar@732
   107
alpar@794
   108
if yesorno "Check with valgrind" "n" 
alpar@794
   109
then
alpar@794
   110
    valgrind_flags=' --enable-valgrind'
alpar@794
   111
else
alpar@794
   112
    valgrind_flags=''
alpar@794
   113
fi
alpar@794
   114
alpar@850
   115
if [ -f ${GLPK_PREFIX}/include/glpk.h ]; then
alpar@850
   116
    if yesorno "Use GLPK" "y"
alpar@850
   117
    then
alpar@850
   118
        glpk_flag="--with-glpk=$GLPK_PREFIX"
alpar@850
   119
    else
alpar@850
   120
        glpk_flag="--without-glpk"
alpar@850
   121
    fi
alpar@850
   122
else
alpar@850
   123
    glpk_flag="--without-glpk"        
alpar@850
   124
fi
alpar@850
   125
alpar@747
   126
if [ -f ${COIN_OR_PREFIX}/include/coin/config_coinutils.h ]; then
alpar@747
   127
    if yesorno "Use COIN-OR (CBC/CLP)" "n"
alpar@747
   128
    then
alpar@747
   129
        coin_flag="--with-coin=$COIN_OR_PREFIX"
alpar@747
   130
    else
alpar@850
   131
        coin_flag="--without-coin"
alpar@747
   132
    fi
alpar@732
   133
else
alpar@850
   134
    coin_flag="--without-coin"        
alpar@732
   135
fi
alpar@732
   136
alpar@747
   137
if [ -f ${SOPLEX_PREFIX}/src/soplex.h ]; then
alpar@747
   138
    if yesorno "Use Soplex" "n"
alpar@747
   139
    then
alpar@747
   140
        soplex_flag="--with-soplex=$SOPLEX_PREFIX"
alpar@747
   141
    else
alpar@850
   142
        soplex_flag="--without-soplex"
alpar@747
   143
    fi
alpar@747
   144
else
alpar@850
   145
    soplex_flag="--without-soplex"
alpar@747
   146
fi
alpar@732
   147
alpar@732
   148
if [ "x$AUTORE" == "xyes" ]; then
alpar@732
   149
    autoreconf -vif;
alpar@732
   150
fi
alpar@732
   151
${CONFIGURE_PATH}/configure --prefix=$LEMON_INSTALL_PREFIX \
alpar@794
   152
$valgrind_flags \
alpar@732
   153
"$cxx_flags" \
alpar@850
   154
$glpk_flag \
alpar@732
   155
$coin_flag \
alpar@747
   156
$soplex_flag \
alpar@732
   157
$*