You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

190 lines
4.1 KiB

20 years ago
21 years ago
  1. #!/bin/sh
  2. # Variable declaration
  3. prefix='@prefix@'
  4. exec_prefix="`eval echo @exec_prefix@`"
  5. phpdir="`eval echo @libdir@`/build"
  6. includedir="`eval echo @includedir@`/php"
  7. builddir="`pwd`"
  8. SED="@SED@"
  9. FILES_BUILD="mkdep.awk scan_makefile_in.awk shtool libtool.m4"
  10. FILES="acinclude.m4 Makefile.global config.sub config.guess ltmain.sh run-tests*.php"
  11. CLEAN_FILES="$FILES *.o *.lo *.la .deps .libs/ build/ include/ modules/ install-sh \
  12. mkinstalldirs missing config.nice config.sub config.guess configure configure.in \
  13. aclocal.m4 config.h config.h.in conftest* ltmain.sh libtool config.cache autom4te.cache/ \
  14. config.log config.status Makefile Makefile.fragments Makefile.objects confdefs.h \
  15. run-tests*.php tests/*.diff tests/*.exp tests/*.log tests/*.out tests/*.php"
  16. # function declaration
  17. phpize_usage()
  18. {
  19. echo "Usage: $0 [--clean|--help|--version|-v]"
  20. }
  21. phpize_no_configm4()
  22. {
  23. if test $@ -eq 1; then
  24. clean=" --clean"
  25. fi
  26. echo "Cannot find config.m4. "
  27. echo "Make sure that you run '$0$clean' in the top level source directory of the module"
  28. echo
  29. }
  30. phpize_clean()
  31. {
  32. echo "Cleaning.."
  33. for i in $CLEAN_FILES; do
  34. if test -f "$i"; then
  35. rm -f $i
  36. elif test -d "$i"; then
  37. rm -rf $i
  38. fi
  39. done
  40. }
  41. phpize_check_configm4()
  42. {
  43. if test ! -r config.m4; then
  44. phpize_no_configm4 $@
  45. exit 1
  46. fi
  47. }
  48. phpize_get_api_numbers()
  49. {
  50. # extracting API NOs:
  51. PHP_API_VERSION=`grep '#define PHP_API_VERSION' $includedir/main/php.h|$SED 's/#define PHP_API_VERSION//'`
  52. ZEND_MODULE_API_NO=`grep '#define ZEND_MODULE_API_NO' $includedir/Zend/zend_modules.h|$SED 's/#define ZEND_MODULE_API_NO//'`
  53. ZEND_EXTENSION_API_NO=`grep '#define ZEND_EXTENSION_API_NO' $includedir/Zend/zend_extensions.h|$SED 's/#define ZEND_EXTENSION_API_NO//'`
  54. }
  55. phpize_print_api_numbers()
  56. {
  57. phpize_get_api_numbers
  58. echo "Configuring for:"
  59. echo "PHP Api Version: "$PHP_API_VERSION
  60. echo "Zend Module Api No: "$ZEND_MODULE_API_NO
  61. echo "Zend Extension Api No: "$ZEND_EXTENSION_API_NO
  62. }
  63. phpize_check_build_files()
  64. {
  65. if test ! -d "$phpdir"; then
  66. cat <<EOF
  67. Cannot find build files at '$phpdir'. Please check your PHP installation.
  68. EOF
  69. exit 1
  70. fi
  71. }
  72. phpize_check_shtool()
  73. {
  74. test -x "$builddir/build/shtool" || chmod +x "$builddir/build/shtool"
  75. if test ! -x "$builddir/build/shtool"; then
  76. cat <<EOF
  77. shtool at '$builddir/build/shtool' does not exist or is not executable.
  78. Make sure that the file exists and is executable and then rerun this script.
  79. EOF
  80. exit 1
  81. else
  82. php_shtool=$builddir/build/shtool
  83. fi
  84. }
  85. phpize_check_autotools()
  86. {
  87. test -z "$PHP_AUTOCONF" && PHP_AUTOCONF=autoconf
  88. test -z "$PHP_AUTOHEADER" && PHP_AUTOHEADER=autoheader
  89. if test ! -x "`$php_shtool path $PHP_AUTOCONF`"; then
  90. cat <<EOF
  91. Cannot find autoconf. Please check your autoconf installation and the \$PHP_AUTOCONF
  92. environment variable is set correctly and then rerun this script.
  93. EOF
  94. exit 1
  95. fi
  96. if test ! -x "`$php_shtool path $PHP_AUTOHEADER`"; then
  97. cat <<EOF
  98. Cannot find autoheader. Please check your autoconf installation and the \$PHP_AUTOHEADER
  99. environment variable is set correctly and then rerun this script.
  100. EOF
  101. exit 1
  102. fi
  103. }
  104. phpize_copy_files()
  105. {
  106. test -d build || mkdir build
  107. (cd "$phpdir" && cp $FILES_BUILD "$builddir"/build)
  108. (cd "$phpdir" && cp $FILES "$builddir")
  109. (cd "$builddir" && cat acinclude.m4 ./build/libtool.m4 > aclocal.m4)
  110. }
  111. phpize_replace_prefix()
  112. {
  113. $SED \
  114. -e "s#@prefix@#$prefix#" \
  115. < "$phpdir/phpize.m4" > configure.in
  116. }
  117. phpize_autotools()
  118. {
  119. $PHP_AUTOCONF || exit 1
  120. $PHP_AUTOHEADER || exit 1
  121. }
  122. # Main script
  123. case "$1" in
  124. # Cleanup
  125. --clean)
  126. phpize_check_configm4 1
  127. phpize_clean
  128. exit 0
  129. ;;
  130. # Usage
  131. --help)
  132. phpize_usage
  133. exit 0
  134. ;;
  135. # Version
  136. --version|-v)
  137. phpize_print_api_numbers
  138. exit 0
  139. ;;
  140. # Default
  141. *)
  142. phpize_check_configm4 0
  143. phpize_check_build_files
  144. phpize_print_api_numbers
  145. phpize_copy_files
  146. phpize_replace_prefix
  147. touch install-sh mkinstalldirs missing
  148. phpize_check_shtool
  149. phpize_check_autotools
  150. phpize_autotools
  151. ;;
  152. esac
  153. exit 0