Busybox: Upgrade to 1.21.1 (stable). lsof active.
[tomato.git] / release / src / router / php / scripts / phpize.in
blob43cd8d30ffed7c582f388dfbf83ee12e33594ec4
1 #!/bin/sh
3 # Variable declaration
4 prefix='@prefix@'
5 datarootdir='@datarootdir@'
6 exec_prefix="`eval echo @exec_prefix@`"
7 phpdir="`eval echo @libdir@`/build"
8 includedir="`eval echo @includedir@`/php"
9 builddir="`pwd`"
10 SED="@SED@"
12 FILES_BUILD="mkdep.awk scan_makefile_in.awk shtool libtool.m4"
13 FILES="acinclude.m4 Makefile.global config.sub config.guess ltmain.sh run-tests*.php"
14 CLEAN_FILES="$FILES *.o *.lo *.la .deps .libs/ build/ include/ modules/ install-sh \
15 mkinstalldirs missing config.nice config.sub config.guess configure configure.in \
16 aclocal.m4 config.h config.h.in conftest* ltmain.sh libtool config.cache autom4te.cache/ \
17 config.log config.status Makefile Makefile.fragments Makefile.objects confdefs.h \
18 run-tests*.php tests/*.diff tests/*.exp tests/*.log tests/*.out tests/*.php"
20 # function declaration
21 phpize_usage()
23 echo "Usage: $0 [--clean|--help|--version|-v]"
26 phpize_no_configm4()
28 if test $@ -eq 1; then
29 clean=" --clean"
32 echo "Cannot find config.m4. "
33 echo "Make sure that you run '$0$clean' in the top level source directory of the module"
34 echo
37 phpize_clean()
39 echo "Cleaning.."
40 for i in $CLEAN_FILES; do
41 if test -f "$i"; then
42 rm -f $i
43 elif test -d "$i"; then
44 rm -rf $i
46 done
49 phpize_check_configm4()
51 if test ! -r config.m4; then
52 phpize_no_configm4 $@
53 exit 1
58 phpize_get_api_numbers()
60 # extracting API NOs:
61 PHP_API_VERSION=`grep '#define PHP_API_VERSION' $includedir/main/php.h|$SED 's/#define PHP_API_VERSION//'`
62 ZEND_MODULE_API_NO=`grep '#define ZEND_MODULE_API_NO' $includedir/Zend/zend_modules.h|$SED 's/#define ZEND_MODULE_API_NO//'`
63 ZEND_EXTENSION_API_NO=`grep '#define ZEND_EXTENSION_API_NO' $includedir/Zend/zend_extensions.h|$SED 's/#define ZEND_EXTENSION_API_NO//'`
66 phpize_print_api_numbers()
68 phpize_get_api_numbers
69 echo "Configuring for:"
70 echo "PHP Api Version: "$PHP_API_VERSION
71 echo "Zend Module Api No: "$ZEND_MODULE_API_NO
72 echo "Zend Extension Api No: "$ZEND_EXTENSION_API_NO
75 phpize_check_build_files()
77 if test ! -d "$phpdir"; then
78 cat <<EOF
79 Cannot find build files at '$phpdir'. Please check your PHP installation.
81 EOF
82 exit 1
85 case "$phpdir" in
86 *\ * | *\ *)
87 cat <<EOF
88 Invalid source path '$phpdir'. Whitespace is not allowed in source path.
90 EOF
91 exit 1;;
92 esac
94 case "$builddir" in
95 *\ * | *\ *)
96 cat <<EOF
97 Invalid build path '$builddir'. Whitespace is not allowed in build path.
99 EOF
100 exit 1;;
101 esac
104 phpize_check_shtool()
106 test -x "$builddir/build/shtool" || chmod +x "$builddir/build/shtool"
108 if test ! -x "$builddir/build/shtool"; then
109 cat <<EOF
110 shtool at '$builddir/build/shtool' does not exist or is not executable.
111 Make sure that the file exists and is executable and then rerun this script.
114 exit 1
115 else
116 php_shtool=$builddir/build/shtool
120 phpize_check_autotools()
122 test -z "$PHP_AUTOCONF" && PHP_AUTOCONF=autoconf
123 test -z "$PHP_AUTOHEADER" && PHP_AUTOHEADER=autoheader
125 if test ! -x "$PHP_AUTOCONF" && test ! -x "`$php_shtool path $PHP_AUTOCONF`"; then
126 cat <<EOF
127 Cannot find autoconf. Please check your autoconf installation and the
128 \$PHP_AUTOCONF environment variable. Then, rerun this script.
131 exit 1
133 if test ! -x "$PHP_AUTOHEADER" && test ! -x "`$php_shtool path $PHP_AUTOHEADER`"; then
134 cat <<EOF
135 Cannot find autoheader. Please check your autoconf installation and the
136 \$PHP_AUTOHEADER environment variable. Then, rerun this script.
139 exit 1
143 phpize_copy_files()
145 test -d build || mkdir build
147 (cd "$phpdir" && cp $FILES_BUILD "$builddir"/build)
148 (cd "$phpdir" && cp $FILES "$builddir")
149 (cd "$builddir" && cat acinclude.m4 ./build/libtool.m4 > aclocal.m4)
152 phpize_replace_prefix()
154 $SED \
155 -e "s#@prefix@#$prefix#" \
156 < "$phpdir/phpize.m4" > configure.in
159 phpize_autotools()
161 $PHP_AUTOCONF || exit 1
162 $PHP_AUTOHEADER || exit 1
165 # Main script
167 case "$1" in
168 # Cleanup
169 --clean)
170 phpize_check_configm4 1
171 phpize_clean
172 exit 0
175 # Usage
176 --help)
177 phpize_usage
178 exit 0
181 # Version
182 --version|-v)
183 phpize_print_api_numbers
184 exit 0
187 # Default
189 phpize_check_configm4 0
191 phpize_check_build_files
193 phpize_print_api_numbers
195 phpize_copy_files
197 phpize_replace_prefix
199 touch install-sh mkinstalldirs missing
201 phpize_check_shtool
203 phpize_check_autotools
205 phpize_autotools
207 esac
209 exit 0