File: configure

package info (click to toggle)
wmmaiload 2.2.1-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k, lenny
  • size: 436 kB
  • ctags: 480
  • sloc: ansic: 4,043; makefile: 204; sh: 76
file content (96 lines) | stat: -rwxr-xr-x 2,774 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#!/bin/sh
#
# Script that enable features for wmmailad and creates its configuration file.


CONFIG="Config.make"
DEFAULT_PREFIX="/usr/local"
DEFINES=`awk '/HAVE_/{print $3}' "$CONFIG".in`
FEATURES=`echo "$DEFINES" | sed -e 's/-DHAVE_//g'`
PREFIX=""
ENABLE=""
VERSION=`cat VERSION`


do_help() {
        echo "configure - configure script for wmmaiload, Thomas Nemeth, 2005"
        echo "Usage: ./configure [-h] [-p PATH] [-e FEATURE] ..."
        echo " -h, --help           : this (very) short help :)"
        echo " -p, --prefix=PATH    : path where to install the program"
        echo " -e, --enable=FEATURE : enable feature FEATURE for compiling wmmaiload"
        echo
        echo "FEATURE is one of :"
        for FEATURE in $FEATURES ; do
                echo " - $FEATURE"
        done
        echo "You can use as much --enable option as you want."
        exit 1
}


do_set_feature() {
        OPTIONS=`echo "$1" | tr "[a-z]" "[A-Z]"`
        set -- `IFS=','; echo $OPTIONS`
        for OPTION in $*; do
                REQUEST=""
                for FEATURE in $FEATURES; do
                        if [ "$OPTION" = "$FEATURE" ]; then
                                REQUEST="$FEATURE"
                                break
                        fi
                done
                if [ "$REQUEST" = "" ]; then
                        echo "Feature '$1' does not exist." > /dev/stderr
                        exit 2
                fi
                ENABLE="$ENABLE $REQUEST"
        done
}


do_parse_args() {
        while [ "$1" != "" ]; do
                case $1 in
                        -h)         do_help;;
                        --help)     do_help;;
                        -p)         PREFIX=$2; shift;;
                        --prefix=*) PREFIX=`echo $1 | cut -d'=' -f2`;;
                        -e)         do_set_feature $2; shift;;
                        --enable=*) do_set_feature `echo $1 | cut -d'=' -f2`;;
                        *)          echo "Unknown option [$1]."; exit 2;;
                esac
                shift
        done
}


do_add_option_cmd() {
        SEDCMD="${SEDCMD};/HAVE_$1/s/^.//"
}


do_check_config() {
        if [ "$PREFIX" = "" ]; then
                PREFIX="$DEFAULT_PREFIX"
        fi
        if [ "$ENABLE" = "" ]; then
                echo "There's no need to call this script if you don't enable at least 1 option."
                echo "Configuring for all options..."
                ENABLE="$FEATURES"
        fi
}


do_configure() {
        do_check_config
        SEDCMD="s,#VERSION#,$VERSION,;s,#PREFIX#,$PREFIX,"
        for OPTION in $ENABLE ; do
                do_add_option_cmd $OPTION
        done
        sed -e "$SEDCMD" $CONFIG.in > $CONFIG
}


do_parse_args $@
do_configure