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.

151 lines
3.0 KiB

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