scripts/bootstrap.sh
author Balazs Dezso <deba@inf.elte.hu>
Sun, 04 Oct 2009 00:28:42 +0200
changeset 793 e4554cd6b2bf
child 794 a42f46828cc1
permissions -rwxr-xr-x
Faster add row operation (#203)

One virtual function call instead of more
alpar@779
     1
#!/bin/bash
alpar@779
     2
#
alpar@779
     3
# This file is a part of LEMON, a generic C++ optimization library.
alpar@779
     4
#
alpar@779
     5
# Copyright (C) 2003-2009
alpar@779
     6
# Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
alpar@779
     7
# (Egervary Research Group on Combinatorial Optimization, EGRES).
alpar@779
     8
#
alpar@779
     9
# Permission to use, modify and distribute this software is granted
alpar@779
    10
# provided that this copyright notice appears in all copies. For
alpar@779
    11
# precise terms see the accompanying LICENSE file.
alpar@779
    12
#
alpar@779
    13
# This software is provided "AS IS" with no warranty of any kind,
alpar@779
    14
# express or implied, and with no claim as to its suitability for any
alpar@779
    15
# purpose.
alpar@779
    16
alpar@779
    17
alpar@779
    18
if [ ! -f ~/.lemon-bootstrap ]; then
alpar@779
    19
    echo 'Create ~/.lemon-bootstrap'.
alpar@779
    20
    cat >~/.lemon-bootstrap <<EOF
alpar@779
    21
#
alpar@779
    22
# Default settings for bootstraping the LEMON source code repository
alpar@779
    23
#
alpar@779
    24
EOF
alpar@779
    25
fi
alpar@779
    26
alpar@779
    27
source ~/.lemon-bootstrap
alpar@779
    28
if [ -f ../../../.lemon-bootstrap ]; then source ../../../.lemon-bootstrap; fi
alpar@779
    29
if [ -f ../../.lemon-bootstrap ]; then source ../../.lemon-bootstrap; fi
alpar@779
    30
if [ -f ../.lemon-bootstrap ]; then source ../.lemon-bootstrap; fi
alpar@779
    31
if [ -f ./.lemon-bootstrap ]; then source ./.lemon-bootstrap; fi
alpar@779
    32
alpar@779
    33
alpar@779
    34
function augment_config() { 
alpar@779
    35
    if [ "x${!1}" == "x" ]; then
alpar@779
    36
        eval $1=$2
alpar@779
    37
        echo Add "'$1'" to '~/.lemon-bootstrap'.
alpar@779
    38
        echo >>~/.lemon-bootstrap
alpar@779
    39
        echo $3 >>~/.lemon-bootstrap
alpar@779
    40
        echo $1=$2 >>~/.lemon-bootstrap
alpar@779
    41
    fi
alpar@779
    42
}
alpar@779
    43
alpar@779
    44
augment_config LEMON_INSTALL_PREFIX /usr/local \
alpar@779
    45
    "# LEMON installation prefix"
alpar@779
    46
alpar@779
    47
augment_config COIN_OR_PREFIX /usr/local/coin-or \
alpar@779
    48
    "# COIN-OR installation root prefix (used for CLP/CBC)"
alpar@779
    49
alpar@779
    50
alpar@779
    51
function ask() {
alpar@779
    52
echo -n "$1 [$2]? "
alpar@779
    53
read _an
alpar@779
    54
if [ "x$_an" == "x" ]; then
alpar@779
    55
    ret="$2"
alpar@779
    56
else
alpar@779
    57
    ret=$_an
alpar@779
    58
fi
alpar@779
    59
}
alpar@779
    60
alpar@779
    61
function yesorno() {
alpar@779
    62
    ret='rossz'
alpar@779
    63
    while [ "$ret" != "y" -a "$ret" != "n" -a "$ret" != "yes" -a "$ret" != "no" ]; do
alpar@779
    64
        ask "$1" "$2"
alpar@779
    65
    done
alpar@779
    66
    if [ "$ret" != "y" -a "$ret" != "yes" ]; then
alpar@779
    67
        return 1
alpar@779
    68
    else
alpar@779
    69
        return 0
alpar@779
    70
    fi
alpar@779
    71
}
alpar@779
    72
alpar@779
    73
if yesorno "External build" "n"
alpar@779
    74
then
alpar@779
    75
    CONFIGURE_PATH=".."
alpar@779
    76
else
alpar@779
    77
    CONFIGURE_PATH="."
alpar@779
    78
    if yesorno "Autoreconf" "y"
alpar@779
    79
    then
alpar@779
    80
        AUTORE=yes
alpar@779
    81
    else
alpar@779
    82
        AUTORE=no
alpar@779
    83
    fi
alpar@779
    84
fi
alpar@779
    85
alpar@779
    86
if yesorno "Optimize" "n" 
alpar@779
    87
then
alpar@779
    88
    opt_flags=' -O2'
alpar@779
    89
else
alpar@779
    90
    opt_flags=''
alpar@779
    91
fi
alpar@779
    92
alpar@779
    93
if yesorno "Stop on warning" "y" 
alpar@779
    94
then
alpar@779
    95
    werror_flags=' -Werror'
alpar@779
    96
else
alpar@779
    97
    werror_flags=''
alpar@779
    98
fi
alpar@779
    99
alpar@779
   100
cxx_flags="CXXFLAGS=-ggdb$opt_flags$werror_flags"
alpar@779
   101
alpar@779
   102
if yesorno "Use COIN" "n"
alpar@779
   103
then
alpar@779
   104
    coin_flag="--with-coin=$COIN_OR_PREFIX"
alpar@779
   105
else
alpar@779
   106
    coin_flag=""
alpar@779
   107
fi
alpar@779
   108
alpar@779
   109
alpar@779
   110
if [ "x$AUTORE" == "xyes" ]; then
alpar@779
   111
    autoreconf -vif;
alpar@779
   112
fi
alpar@779
   113
${CONFIGURE_PATH}/configure --prefix=$LEMON_INSTALL_PREFIX \
alpar@779
   114
"$cxx_flags" \
alpar@779
   115
$coin_flag \
alpar@779
   116
$*