~ubuntu-branches/ubuntu/hardy/php5/hardy-updates

« back to all changes in this revision

Viewing changes to scripts/phpize.in

  • Committer: Bazaar Package Importer
  • Author(s): Adam Conrad
  • Date: 2005-10-09 03:14:32 UTC
  • Revision ID: james.westby@ubuntu.com-20051009031432-kspik3lobxstafv9
Tags: upstream-5.0.5
ImportĀ upstreamĀ versionĀ 5.0.5

Show diffs side-by-side

added added

removed removed

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