~midori/midori/trunk

251 by Christian Dywan
Add 'configure' like waf wrapper
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
3390 by Christian Dywan
Make 'configure' script look for python2
41
	    PYTHON=`which python2 2>/dev/null`
42
	fi
43
	if [ -z "$PYTHON" ] ; then
251 by Christian Dywan
Add 'configure' like waf wrapper
44
	    PYTHON=`which python 2>/dev/null`
45
	fi
46
	printf "Checking for Python\t\t\t:  "
47
	if [ ! -x "$PYTHON" ] ; then
48
	  printf $RED"not found!"$NORMAL"\n"
49
	  echo "Please make sure that the Python interpreter is available in your PATH"
50
	  echo "or invoke configure using the PYTHON flag, e.g."
51
	  echo "$ PYTHON=/usr/local/bin/python configure"
52
	  exit $EXIT_FAILURE
53
	fi
54
	printf $GREEN"$PYTHON"$NORMAL"\n"
55
}
56
57
# Checks for WAF. Honours $WAF if set. Stores path to 'waf' in $WAF.
58
# Requires that $PYTHON is set.
59
#
60
checkWAF()
61
{
62
	printf "Checking for WAF\t\t\t:  "
63
	#installed miniwaf in sourcedir
64
	if [ -z "$WAF" ] ; then
65
	    if [ -f "${WORKINGDIR}/waf" ] ; then
66
		WAF="${WORKINGDIR}/waf"
67
		if [ ! -x "$WAF" ] ; then
68
		    chmod +x $WAF
69
		fi
70
	    fi
71
	fi
72
	if [ -z "$WAF" ] ; then
73
	    if [ -f "${WORKINGDIR}/waf-light" ] ; then
74
		${WORKINGDIR}/waf-light --make-waf
75
	        WAF="${WORKINGDIR}/waf"
76
	    fi
77
	fi
78
	#global installed waf with waf->waf.py link
79
	if [ -z "$WAF" ] ; then
80
	    WAF=`which waf 2>/dev/null`
81
	fi
82
	# neither waf nor miniwaf could be found
83
	if [ ! -x "$WAF" ] ; then
84
	    printf $RED"not found"$NORMAL"\n"
85
	    echo "Go to http://code.google.com/p/waf/"
86
	    echo "and download a waf version"
87
	    exit $EXIT_FAILURE
88
	else
89
	  printf $GREEN"$WAF"$NORMAL"\n"
90
	fi
3390 by Christian Dywan
Make 'configure' script look for python2
91
	WAF="$PYTHON $WAF"
251 by Christian Dywan
Add 'configure' like waf wrapper
92
}
93
94
# Generates a Makefile. Requires that $WAF is set.
95
#
96
generateMakefile()
97
{
98
	cat > Makefile << EOF
99
#!/usr/bin/make -f
100
# Waf Makefile wrapper
101
WAF_HOME=$CUR_DIR
102
103
all:
104
	@$WAF build
105
106
all-debug:
107
	@$WAF -v build
108
109
all-progress:
110
	@$WAF -p build
111
112
install:
113
	@if test -n "\$(DESTDIR)"; then \\
114
	    $WAF install --destdir="\$(DESTDIR)"; \\
115
	else \\
116
	    $WAF install; \\
117
	fi;
118
261 by Anders F Björklund
Make wrapped makefile's 'install' target phony
119
.PHONY: install
120
251 by Christian Dywan
Add 'configure' like waf wrapper
121
uninstall:
122
	@if test -n "\$(DESTDIR)"; then \\
123
	    $WAF uninstall --destdir="\$(DESTDIR)"; \\
124
	else \\
125
	    $WAF uninstall; \\
126
	fi;
127
128
clean:
129
	@$WAF clean
130
131
distclean:
132
	@$WAF distclean
4744 by Paweł Forysiuk
Accomodate docs for build dir renaming
133
	@-rm -rf _build
251 by Christian Dywan
Add 'configure' like waf wrapper
134
	@-rm -f Makefile
135
136
check:
137
	@$WAF check
138
139
dist:
140
	@$WAF dist
141
142
EOF
143
}
144
145
checkPython
146
checkWAF
147
148
echo "calling waf configure with parameters"
149
$WAF configure $* || exit $EXIT_ERROR
150
151
if [ -f "Makefile" ] ; then
152
    echo ""
153
else
154
    generateMakefile
155
fi
156
157
exit $EXIT_SUCCESS