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.

208 lines
4.4 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. case "$phpdir" in
  72. *\ * | *\ *)
  73. cat <<EOF
  74. Invalid source path '$phpdir'. Whitespace is not allowed in source path.
  75. EOF
  76. exit 1;;
  77. esac
  78. case "$builddir" in
  79. *\ * | *\ *)
  80. cat <<EOF
  81. Invalid build path '$builddir'. Whitespace is not allowed in build path.
  82. EOF
  83. exit 1;;
  84. esac
  85. }
  86. phpize_check_shtool()
  87. {
  88. test -x "$builddir/build/shtool" || chmod +x "$builddir/build/shtool"
  89. if test ! -x "$builddir/build/shtool"; then
  90. cat <<EOF
  91. shtool at '$builddir/build/shtool' does not exist or is not executable.
  92. Make sure that the file exists and is executable and then rerun this script.
  93. EOF
  94. exit 1
  95. else
  96. php_shtool=$builddir/build/shtool
  97. fi
  98. }
  99. phpize_check_autotools()
  100. {
  101. test -z "$PHP_AUTOCONF" && PHP_AUTOCONF=autoconf
  102. test -z "$PHP_AUTOHEADER" && PHP_AUTOHEADER=autoheader
  103. if ! test -x "$PHP_AUTOCONF" && ! test -x "`$php_shtool path $PHP_AUTOCONF`"; then
  104. cat <<EOF
  105. Cannot find autoconf. Please check your autoconf installation and the
  106. \$PHP_AUTOCONF environment variable. Then, rerun this script.
  107. EOF
  108. exit 1
  109. fi
  110. if ! test -x "$PHP_AUTOHEADER" && ! test -x "`$php_shtool path $PHP_AUTOHEADER`"; then
  111. cat <<EOF
  112. Cannot find autoheader. Please check your autoconf installation and the
  113. \$PHP_AUTOHEADER environment variable. Then, rerun this script.
  114. EOF
  115. exit 1
  116. fi
  117. }
  118. phpize_copy_files()
  119. {
  120. test -d build || mkdir build
  121. (cd "$phpdir" && cp $FILES_BUILD "$builddir"/build)
  122. (cd "$phpdir" && cp $FILES "$builddir")
  123. (cd "$builddir" && cat acinclude.m4 ./build/libtool.m4 > aclocal.m4)
  124. }
  125. phpize_replace_prefix()
  126. {
  127. $SED \
  128. -e "s#@prefix@#$prefix#" \
  129. < "$phpdir/phpize.m4" > configure.in
  130. }
  131. phpize_autotools()
  132. {
  133. $PHP_AUTOCONF || exit 1
  134. $PHP_AUTOHEADER || exit 1
  135. }
  136. # Main script
  137. case "$1" in
  138. # Cleanup
  139. --clean)
  140. phpize_check_configm4 1
  141. phpize_clean
  142. exit 0
  143. ;;
  144. # Usage
  145. --help)
  146. phpize_usage
  147. exit 0
  148. ;;
  149. # Version
  150. --version|-v)
  151. phpize_print_api_numbers
  152. exit 0
  153. ;;
  154. # Default
  155. *)
  156. phpize_check_configm4 0
  157. phpize_check_build_files
  158. phpize_print_api_numbers
  159. phpize_copy_files
  160. phpize_replace_prefix
  161. touch install-sh mkinstalldirs missing
  162. phpize_check_shtool
  163. phpize_check_autotools
  164. phpize_autotools
  165. ;;
  166. esac
  167. exit 0