scripts/bootstrap.sh
author Alpar Juttner <alpar@cs.elte.hu>
Wed, 18 Nov 2009 14:22:52 +0100
changeset 791 4e3484a2e90c
parent 732 1f8ad32f088b
child 794 313d58f9e544
permissions -rwxr-xr-x
Merge
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@747
   105
if [ -f ${COIN_OR_PREFIX}/include/coin/config_coinutils.h ]; then
alpar@747
   106
    if yesorno "Use COIN-OR (CBC/CLP)" "n"
alpar@747
   107
    then
alpar@747
   108
        coin_flag="--with-coin=$COIN_OR_PREFIX"
alpar@747
   109
    else
alpar@747
   110
        coin_flag=""
alpar@747
   111
    fi
alpar@732
   112
else
alpar@747
   113
    coin_flag=""        
alpar@732
   114
fi
alpar@732
   115
alpar@747
   116
if [ -f ${SOPLEX_PREFIX}/src/soplex.h ]; then
alpar@747
   117
    if yesorno "Use Soplex" "n"
alpar@747
   118
    then
alpar@747
   119
        soplex_flag="--with-soplex=$SOPLEX_PREFIX"
alpar@747
   120
    else
alpar@747
   121
        soplex_flag=""
alpar@747
   122
    fi
alpar@747
   123
else
alpar@747
   124
    soplex_flag=""
alpar@747
   125
fi
alpar@732
   126
alpar@732
   127
if [ "x$AUTORE" == "xyes" ]; then
alpar@732
   128
    autoreconf -vif;
alpar@732
   129
fi
alpar@732
   130
${CONFIGURE_PATH}/configure --prefix=$LEMON_INSTALL_PREFIX \
alpar@732
   131
"$cxx_flags" \
alpar@732
   132
$coin_flag \
alpar@747
   133
$soplex_flag \
alpar@732
   134
$*