~midori/midori/trunk

« back to all changes in this revision

Viewing changes to configure

  • Committer: Christian Dywan
  • Date: 2008-08-10 12:38:47 UTC
  • Revision ID: git-v1:1b0fc074e333af772ef829e2cd2f1f2335b4cf91
Add 'configure' like waf wrapper

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#! /bin/sh
 
2
 
 
3
# waf configure wrapper
 
4
 
 
5
# Fancy colors used to beautify the output a bit.
 
6
#
 
7
if [ "$NOCOLOR" ] ; then
 
8
    NORMAL=""
 
9
    BOLD=""
 
10
    RED=""
 
11
    YELLOW=""
 
12
    GREEN=""
 
13
else
 
14
    NORMAL="\033[0m"
 
15
    BOLD="\033[1m"
 
16
    RED="\033[91m"
 
17
    YELLOW="\033[01;93m"
 
18
    GREEN="\033[92m"
 
19
fi
 
20
 
 
21
EXIT_SUCCESS=0
 
22
EXIT_FAILURE=1
 
23
EXIT_ERROR=2
 
24
EXIT_BUG=10
 
25
 
 
26
CUR_DIR=$PWD
 
27
 
 
28
#possible relative path
 
29
WORKINGDIR=`dirname $0`
 
30
cd $WORKINGDIR
 
31
#abs path
 
32
WORKINGDIR=`pwd`
 
33
cd $CUR_DIR
 
34
 
 
35
# Checks for Python interpreter. Honours $PYTHON if set. Stores path to
 
36
# interpreter in $PYTHON.
 
37
#
 
38
checkPython()
 
39
{
 
40
        if [ -z "$PYTHON" ] ; then
 
41
            PYTHON=`which python 2>/dev/null`
 
42
        fi
 
43
        printf "Checking for Python\t\t\t:  "
 
44
        if [ ! -x "$PYTHON" ] ; then
 
45
          printf $RED"not found!"$NORMAL"\n"
 
46
          echo "Please make sure that the Python interpreter is available in your PATH"
 
47
          echo "or invoke configure using the PYTHON flag, e.g."
 
48
          echo "$ PYTHON=/usr/local/bin/python configure"
 
49
          exit $EXIT_FAILURE
 
50
        fi
 
51
        printf $GREEN"$PYTHON"$NORMAL"\n"
 
52
}
 
53
 
 
54
# Checks for WAF. Honours $WAF if set. Stores path to 'waf' in $WAF.
 
55
# Requires that $PYTHON is set.
 
56
#
 
57
checkWAF()
 
58
{
 
59
        printf "Checking for WAF\t\t\t:  "
 
60
        #installed miniwaf in sourcedir
 
61
        if [ -z "$WAF" ] ; then
 
62
            if [ -f "${WORKINGDIR}/waf" ] ; then
 
63
                WAF="${WORKINGDIR}/waf"
 
64
                if [ ! -x "$WAF" ] ; then
 
65
                    chmod +x $WAF
 
66
                fi
 
67
            fi
 
68
        fi
 
69
        if [ -z "$WAF" ] ; then
 
70
            if [ -f "${WORKINGDIR}/waf-light" ] ; then
 
71
                ${WORKINGDIR}/waf-light --make-waf
 
72
                WAF="${WORKINGDIR}/waf"
 
73
            fi
 
74
        fi
 
75
        #global installed waf with waf->waf.py link
 
76
        if [ -z "$WAF" ] ; then
 
77
            WAF=`which waf 2>/dev/null`
 
78
        fi
 
79
        # neither waf nor miniwaf could be found
 
80
        if [ ! -x "$WAF" ] ; then
 
81
            printf $RED"not found"$NORMAL"\n"
 
82
            echo "Go to http://code.google.com/p/waf/"
 
83
            echo "and download a waf version"
 
84
            exit $EXIT_FAILURE
 
85
        else
 
86
          printf $GREEN"$WAF"$NORMAL"\n"
 
87
        fi
 
88
}
 
89
 
 
90
# Generates a Makefile. Requires that $WAF is set.
 
91
#
 
92
generateMakefile()
 
93
{
 
94
        cat > Makefile << EOF
 
95
#!/usr/bin/make -f
 
96
# Waf Makefile wrapper
 
97
WAF_HOME=$CUR_DIR
 
98
 
 
99
all:
 
100
        @$WAF build
 
101
 
 
102
all-debug:
 
103
        @$WAF -v build
 
104
 
 
105
all-progress:
 
106
        @$WAF -p build
 
107
 
 
108
install:
 
109
        @if test -n "\$(DESTDIR)"; then \\
 
110
            $WAF install --destdir="\$(DESTDIR)"; \\
 
111
        else \\
 
112
            $WAF install; \\
 
113
        fi;
 
114
 
 
115
uninstall:
 
116
        @if test -n "\$(DESTDIR)"; then \\
 
117
            $WAF uninstall --destdir="\$(DESTDIR)"; \\
 
118
        else \\
 
119
            $WAF uninstall; \\
 
120
        fi;
 
121
 
 
122
clean:
 
123
        @$WAF clean
 
124
 
 
125
distclean:
 
126
        @$WAF distclean
 
127
        @-rm -rf _build_
 
128
        @-rm -f Makefile
 
129
 
 
130
check:
 
131
        @$WAF check
 
132
 
 
133
dist:
 
134
        @$WAF dist
 
135
 
 
136
EOF
 
137
}
 
138
 
 
139
checkPython
 
140
checkWAF
 
141
 
 
142
echo "calling waf configure with parameters"
 
143
$WAF configure $* || exit $EXIT_ERROR
 
144
 
 
145
if [ -f "Makefile" ] ; then
 
146
    echo ""
 
147
else
 
148
    generateMakefile
 
149
fi
 
150
 
 
151
exit $EXIT_SUCCESS