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.

157 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"
  8. FILES="acinclude.m4 Makefile.global"
  9. CLEAN_FILES="$FILES *.lo *.la *.o .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 \
  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. }
  77. phpize_replace_prefix()
  78. {
  79. sed \
  80. -e "s#@prefix@#$prefix#" \
  81. < $phpdir/phpize.m4 > configure.in
  82. }
  83. phpize_autotools()
  84. {
  85. aclocal || exit 1
  86. autoconf || exit 1
  87. autoheader || exit 1
  88. }
  89. phpize_libtoolize()
  90. {
  91. libtoolize=`$builddir/build/shtool path glibtoolize libtoolize`
  92. $libtoolize -f -c || exit 1
  93. }
  94. # Main script
  95. case "$1" in
  96. # Cleanup
  97. --clean)
  98. phpize_check_configm4 1
  99. phpize_clean
  100. exit 0
  101. ;;
  102. # Usage
  103. --help)
  104. phpize_usage
  105. exit 0
  106. ;;
  107. # Version
  108. --version|-v)
  109. phpize_print_api_numbers
  110. exit 0
  111. ;;
  112. # Default
  113. *)
  114. phpize_check_configm4 0
  115. phpize_print_api_numbers
  116. phpize_copy_files
  117. phpize_replace_prefix
  118. touch install-sh mkinstalldirs missing
  119. phpize_autotools
  120. phpize_check_shtool
  121. phpize_libtoolize
  122. ;;
  123. esac
  124. exit 0