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.

189 lines
4.0 KiB

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