Skip to content

Commit

Permalink
- restructured phpize
Browse files Browse the repository at this point in the history
 - added -v and --version to print out API numbers
 - discussed with Jani and Andi
  • Loading branch information
Jan Lehnardt committed Dec 19, 2003
1 parent 5f16e61 commit 1e1e343
Showing 1 changed file with 130 additions and 54 deletions.
184 changes: 130 additions & 54 deletions scripts/phpize.in
@@ -1,5 +1,6 @@
#! /bin/sh #!/bin/sh


# Variable declaration
prefix='@prefix@' prefix='@prefix@'
phpdir="$prefix/lib/php/build" phpdir="$prefix/lib/php/build"
includedir="$prefix/include/php" includedir="$prefix/include/php"
Expand All @@ -12,69 +13,144 @@ CLEAN_FILES="$FILES *.lo *.la *.o .deps .libs/ build/ include/ modules/ install-
aclocal.m4 config.h config.h.in conftest* ltmain.sh libtool config.cache \ aclocal.m4 config.h config.h.in conftest* ltmain.sh libtool config.cache \
config.log config.status Makefile Makefile.fragments Makefile.objects confdefs.h" config.log config.status Makefile Makefile.fragments Makefile.objects confdefs.h"


# function declaration
phpize_usage()
{
echo "Usage: $0 [--clean|--help|--version|-v]"
}

phpize_no_configm4()
{
if test $@ -eq 1; then
clean=" --clean"
fi

echo "Cannot find config.m4. "
echo "Make sure that you run '$0$clean' in the top level source directory of the module"
echo
}

phpize_clean()
{
echo "Cleaning.."
for i in $CLEAN_FILES; do
test -e $i && rm -rf $i
done
}

phpize_check_configm4()
{
if test ! -r config.m4; then
phpize_no_configm4 $@
exit 1
fi

}

phpize_get_api_numbers()
{
# extracting API NOs:
PHP_API_VERSION=`egrep '#define PHP_API_VERSION' $includedir/main/php.h|sed 's/#define PHP_API_VERSION//'`
ZEND_MODULE_API_NO=`egrep '#define ZEND_MODULE_API_NO' $includedir/Zend/zend_modules.h|sed 's/#define ZEND_MODULE_API_NO//'`
ZEND_EXTENSION_API_NO=`egrep '#define ZEND_EXTENSION_API_NO' $includedir/Zend/zend_extensions.h|sed 's/#define ZEND_EXTENSION_API_NO//'`
}

phpize_print_api_numbers()
{
phpize_get_api_numbers
echo "Configuring for:"
echo "PHP Api Version: "$PHP_API_VERSION
echo "Zend Module Api No: "$ZEND_MODULE_API_NO
echo "Zend Extension Api No: "$ZEND_EXTENSION_API_NO
}

phpize_no_shtool()
{
echo <<EOF
shtool at '$builddir/build/shtool' not executable.
Make sure that the file exists and is executable and then rerun this script.
EOF
}

phpize_check_shtool()
{
test -x $builddir/build/shtool || chmod +x $builddir/build/shtool

if test ! -x $builddir/build/shtool; then
phpize_no_shtool
exit 1
fi
}


phpize_copy_files()
{
test -d build || mkdir build

(cd $phpdir && cp $FILES_BUILD "$builddir"/build)
(cd $phpdir && cp $FILES "$builddir")
}

phpize_replace_prefix()
{
sed \
-e "s#@prefix@#$prefix#" \
< $phpdir/phpize.m4 > configure.in
}

phpize_autotools()
{
aclocal || exit 1
autoconf || exit 1
autoheader || exit 1
}

phpize_libtoolize()
{
libtoolize=`$builddir/build/shtool path glibtoolize libtoolize`
$libtoolize -f -c || exit 1
}

# Main script

case "$1" in case "$1" in
# Cleanup # Cleanup
--clean) --clean)
if test -r config.m4; then phpize_check_configm4 1
echo "Cleaning.." phpize_clean
for i in $CLEAN_FILES; do exit 0
test -e $i && rm -rf $i
done
exit 0
else
echo "Cannot find config.m4. "
echo "Make sure that you run '$0 --clean' in the top level source directory of the module"
echo
exit 1
fi
;; ;;

# Usage # Usage
--help) --help)
echo "Usage: $0 [--clean|--help]" phpize_usage
exit 1 exit 0
;; ;;

# Version
--version|-v)
phpize_get_api_numbers
phpize_print_api_numbers
exit 0
;;

# Default
*) *)
if test ! -r config.m4; then phpize_check_configm4 0
echo "Cannot find config.m4. "
echo "Make sure that you run '$0' in the top level source directory of the module"
echo
exit 1
fi
;;
esac


test -d build || mkdir build phpize_copy_files


(cd $phpdir && cp $FILES_BUILD "$builddir"/build) phpize_replace_prefix
(cd $phpdir && cp $FILES "$builddir")


sed \ touch install-sh mkinstalldirs missing
-e "s#@prefix@#$prefix#" \
< $phpdir/phpize.m4 > configure.in


touch install-sh mkinstalldirs missing phpize_autotools


aclocal || exit 1 phpize_check_shtool
autoconf || exit 1
autoheader || exit 1 phpize_libtoolize
test -x $builddir/build/shtool || chmod +x $builddir/build/shtool ;;
if test ! -x $builddir/build/shtool; then esac
echo "shtool at '$builddir/build/shtool' not executable. "
echo "Make sure that the file exists and is executable and then rerun this script. " exit 0
echo
exit 1
fi
libtoolize=`$builddir/build/shtool path glibtoolize libtoolize`
$libtoolize -f -c || exit 1

# dumping API NOs:
PHP_API_VERSION=`egrep '#define PHP_API_VERSION' $includedir/main/php.h|sed 's/#define PHP_API_VERSION//'`
ZEND_MODULE_API_NO=`egrep '#define ZEND_MODULE_API_NO' $includedir/Zend/zend_modules.h|sed 's/#define ZEND_MODULE_API_NO//'`
ZEND_EXTENSION_API_NO=`egrep '#define ZEND_EXTENSION_API_NO' $includedir/Zend/zend_extensions.h|sed 's/#define ZEND_EXTENSION_API_NO//'`

echo "Configuring for:"
echo " PHP Api Version: "$PHP_API_VERSION
echo " Zend Module Api No: "$ZEND_MODULE_API_NO
echo " Zend Extension Api No: "$ZEND_EXTENSION_API_NO

exit 0

0 comments on commit 1e1e343

Please sign in to comment.