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.

184 lines
3.9 KiB

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