-
Notifications
You must be signed in to change notification settings - Fork 1
/
configure
executable file
·174 lines (163 loc) · 5.84 KB
/
configure
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
#! /bin/bash
OS=`uname -s | tr '[:upper:]' '[:lower:]'`
ARCH=`uname -p`
TARGET=debug
TOOLCHAIN=gcc
HOST=""
EXTERNAL_ZLIB="no"
EXTERNAL_ZLIB_CPPFLAGS=""
EXTERNAL_ZLIB_LDFLAGS=""
EXTERNAL_LIBXML="no"
EXTERNAL_LIBXML_CPPFLAGS=""
EXTERNAL_LIBXML_LDFLAGS=""
while test $# -ge 1
do
case "$1" in
-h* | --help)
echo 'usage:'
echo ' configure [--with-python="PATH TO PYTHON EXECUTABLE"]'
echo ' [--platform="OS-TARGET-TOOLCHAIN", e.g. --platform="linux-debug-gcc-i386"]'
echo ' [--os="OS", e.g. --os="linux"]'
echo ' [--target="TARGET", e.g. --target="release"]'
echo ' [--toolchain="TOOLCHAIN", e.g. --toolchain="clang"]'
echo ' [--arch="ARCH", e.g. --arch="i386"]'
exit 0 ;;
--with-python=*) PYTHON_PATH=`echo $1 | sed 's/.*=//'`; shift ;;
--platform=*) PLATFORM=`echo $1 | sed 's/.*=//'`; shift ;;
--target=*) TARGET=`echo $1 | sed 's/.*=//'`; shift ;;
--toolchain=*) TOOLCHAIN=`echo $1 | sed 's/.*=//'`; shift ;;
--os=*) OS=`echo $1 | sed 's/.*=//'`; shift ;;
--arch=*) ARCH=`echo $1 | sed 's/.*=//'`; shift ;;
--with-zlib=*) EXTERNAL_ZLIB=`echo $1 | sed 's/.*=//'`; shift ;;
--with-zlib-cppflags=*) EXTERNAL_ZLIB_CPPFLAGS=`echo $1 | sed 's/.*=//'`; shift ;;
--with-zlib-ldflags=*) EXTERNAL_ZLIB_LDFLAGS=`echo $1 | sed 's/.*=//'`; shift ;;
--with-libxml=*) EXTERNAL_LIBXML=`echo $1 | sed 's/.*=//'`; shift ;;
--with-libxml-cppflags=*) EXTERNAL_LIBXML_CPPFLAGS=`echo $1 | sed 's/.*=//'`; shift ;;
--with-libxml-ldflags=*) EXTERNAL_LIBXML_LDFLAGS=`echo $1 | sed 's/.*=//'`; shift ;;
*) echo "unknown option: $1"; echo "$0 --help for help"; exit 1 ;;
esac
done
BUILDDIR="build"
PLIBCONFIG=""
PLIBFILES="include/plib/plib.h=>%PACKAGE%/config/%PLATFORM%/plib/include/plib/"
ZLIBCONFIG=""
ZLIBFILES="zconf.h=>config/%PLATFORM%/%PACKAGE%/"
LIBXMLCONFIG="--without-c14n \
--without-catalog \
--without-docbook \
--without-fexceptions \
--without-ftp \
--without-history \
--without-html \
--without-http \
--without-iconv \
--without-iso8859x \
--without-legacy \
--without-output \
--without-pattern \
--without-push \
--without-python \
--with-reader \
--without-regexps \
--without-sax1 \
--without-schemas \
--without-schematron \
--without-threads \
--without-tree \
--without-valid \
--with-writer \
--without-xinclude \
--without-xpath \
--without-xptr \
--without-modules \
--without-zlib"
LIBXMLFILES="config.h=>config/%PLATFORM%/%PACKAGE%/ include/libxml/xmlversion.h=>config/%PLATFORM%/%PACKAGE%/libxml"
execConfigure() {
RET=0
SRCDIR=$1
PACKAGE=$2
OPTIONS=$3
FILES=$4
OPT_HOST=$5
echo "Configuring $SRCDIR/$PACKAGE"
mkdir -p "$BUILDDIR/copy"
rm -rf "$BUILDDIR/copy/$PACKAGE"
rm -rf "$BUILDDIR/$PLATFORM/$PACKAGE"
cp -r "$SRCDIR/$PACKAGE" "$BUILDDIR/copy/$PACKAGE"
if [ -d "$BUILDDIR/copy/$PACKAGE" ]; then
pushd "$BUILDDIR/copy/$PACKAGE" > /dev/null
if [ -x "./configure" ]; then
./configure $OPT_HOST $OPTIONS
if [ $? -ne 0 ]; then
popd -n > /dev/null
echo "*** error running \"./configure $OPT_HOST $OPTIONS\" in \"$BUILDDIR/$PACKAGE\""
echo "*** please fix this first!"
exit 1
fi
else
echo "configure not found in directory \"$BUILDDIR/$PACKAGE\""
fi
popd > /dev/null
PAIR=$FILES
for PAIR in $FILES; do
FILE=(${PAIR/=>/ })
SRCFILE="$BUILDDIR/copy/$PACKAGE/${FILE[0]}"
if [ ! -f "$SRCFILE" ]; then
echo "*** file \"$SRCFILE\" in has not been generated by configure."
exit 1
fi
TARGETDIR="$BUILDDIR/${FILE[1]}"
TARGETDIR=${TARGETDIR/\%PLATFORM\%/$PLATFORM}
TARGETDIR=${TARGETDIR/\%PACKAGE\%/$PACKAGE}
mkdir -p "$TARGETDIR"
cp "$SRCFILE" "$TARGETDIR"
TARGETFILE="$TARGETDIR/`basename ${FILE[0]}`"
if [ ! -f "$TARGETFILE" ]; then
echo "*** file "$SRCFILE" could not be copied to "$TARGETFILE" (either directory could not be created or copy failed)"
exit 1
fi
done
else
echo "could not create temporary copy of \"$SRCDIR/$PACKAGE\" in \"$BUILDDIR/copy/$PACKAGE\""
fi
rm -rf "$BUILDDIR/copy/$PACKAGE"
}
if [ x$PLATFORM = x ]; then
PLATFORM="$OS-$TARGET-$TOOLCHAIN-$ARCH"
fi
#if [ x$CC = x ]; then
# CC=${PLATFORM##*-}
#fi
#export CC
if [ x$PYTHON_PATH = x ]; then
PYTHON_PATH=python
fi
if [[ $PLATFORM =~ ^[^-]+-[^-]+-[^-]+-[^-]+$ ]]; then
PYTHON_VERSION="`$PYTHON_PATH -V 2>&1`"
if [[ $PYTHON_VERSION =~ ^"Python 2.6."[1-9][0-9]*$|^"Python 2."[7-9][0-9]*(\.[0-9]*(\+)?)?$|^"Python "[3][0-9]*(\.[0-9]*(\.[0-9]*)(\+)?)?$ ]]; then
FLAGS=`$PYTHON_PATH generate.py --include Makefile.platform.xml --config-dir $BUILDDIR --with-zlib=$EXTERNAL_ZLIB --with-zlib-cppflags="$EXTERNAL_ZLIB_CPPFLAGS" --with-zlib-ldflags="$EXTERNAL_ZLIB_LDFLAGS" --with-libxml=$EXTERNAL_LIBXML --with-libxml-cppflags="$EXTERNAL_LIBXML_CPPFLAGS" --with-libxml-ldflags="$EXTERNAL_LIBXML_LDFLAGS" --print-env $PLATFORM`
eval $FLAGS
CONFIG_OPT=""
if [ x"" != x$HOST ]; then
CONFIG_OPT="--host=$HOST"
fi
execConfigure "." "plib" "$PLIBCONFIG" "$PLIBFILES" "$CONFIG_OPT"
if [ x"no" == x$EXTERNAL_ZLIB ]; then
execConfigure "third_party" "zlib-1.2.5" "$ZLIBCONFIG" "$ZLIBFILES" ""
fi
if [ x"no" == x$EXTERNAL_LIBXML ]; then
execConfigure "third_party" "libxml2-2.7.7" "$LIBXMLCONFIG" "$LIBXMLFILES" "$CONFIG_OPT"
fi
$PYTHON_PATH generate.py --include Makefile.xml --config-dir $BUILDDIR --with-zlib=$EXTERNAL_ZLIB --with-zlib-cppflags="$EXTERNAL_ZLIB_CPPFLAGS" --with-zlib-ldflags="$EXTERNAL_ZLIB_LDFLAGS" --with-libxml=$EXTERNAL_LIBXML --with-libxml-cppflags="$EXTERNAL_LIBXML_CPPFLAGS" --with-libxml-ldflags="$EXTERNAL_LIBXML_LDFLAGS" $PLATFORM
if [ $? -ne 0 ]; then
echo "*** error generating Makefile!"
exit 1
fi
else
echo "Need python version >2.6.1. You have \"$PYTHON_VERSION\"."
fi
else
echo "Can not guess PLATFORM quadruple. It is set to \"$PLATFORM\" but it should be something like \"linux-debug-gcc-i386\"."
fi
echo "Configured platform $PLATFORM."
echo "Executables will be generated in \"build/$PLATFORM\"."