php-src/ext/ext_skel
2000-06-09 03:38:37 +00:00

121 lines
2.6 KiB
Bash
Executable File

#!/bin/sh
extname="$1"
EXTNAME=`echo $1|tr a-z A-Z`
givup() {
echo $*
exit 1
}
if test "$extname" = ""; then
givup "usage: $0 extension-name"
fi
if test -d "$extname" ; then
givup "Directory $extname already exists."
fi
test -f ext_skel || givup "ext_skel must be in the current directory"
if echo '\c' | grep -s c >/dev/null 2>&1
then
ECHO_N="echo -n"
ECHO_C=""
else
ECHO_N="echo"
ECHO_C='\c'
fi
echo "Creating directory"
mkdir $extname || givup "Cannot create directory $extname"
cd $extname
chmod 755 .
$ECHO_N "Creating basic files:$ECHO_C"
$ECHO_N " config.m4$ECHO_C"
cat >config.m4 <<eof
dnl \$Id\$
dnl config.m4 for extension $extname
dnl don't forget to call PHP_EXTENSION($extname)
dnl Comments in this file start with the string 'dnl'.
dnl Remove where necessary. This file will not work
dnl without editing.
dnl If your extension references something external, use with:
dnl PHP_ARG_WITH($extname, for $extname support,
dnl Make sure that the comment is aligned:
dnl [ --with-$extname Include $extname support])
dnl Otherwise use enable:
dnl PHP_ARG_ENABLE($extname, whether to enable $extname support,
dnl Make sure that the comment is aligned:
dnl [ --enable-$extname Enable $extname support])
if test "\$PHP_$EXTNAME" != "no"; then
dnl If you will not be testing anything external, like existence of
dnl headers, libraries or functions in them, just uncomment the
dnl following line and you are ready to go.
dnl AC_DEFINE(HAVE_$EXTNAME, 1, [ ])
dnl Write more examples of tests here...
PHP_EXTENSION($extname, \$ext_shared)
fi
eof
$ECHO_N " Makefile.in$ECHO_C"
cat >Makefile.in <<eof
# \$Id\$
LTLIBRARY_NAME = lib$extname.la
LTLIBRARY_SOURCES = $extname.c
LTLIBRARY_SHARED_NAME = $extname.la
include \$(top_srcdir)/build/dynlib.mk
eof
$ECHO_N " .cvsignore$ECHO_C"
cat >.cvsignore <<eof
.deps
Makefile
*.o
*.lo
*.la
.libs
libs.mk
eof
$ECHO_N " $extname.c$ECHO_C"
cat ../skeleton/skeleton.c | sed -e "s/_extname_/$extname/g" | sed -e "s/_EXTNAME_/$EXTNAME/g" > $extname.c
$ECHO_N " php_$extname.h$ECHO_C"
cat ../skeleton/php_skeleton.h | sed -e "s/_extname_/$extname/g" | sed -e "s/_EXTNAME_/$EXTNAME/g" > php_$extname.h
$ECHO_N " $extname.php$ECHO_C"
cat ../skeleton/skeleton.php | sed -e "s/_extname_/$extname/g" | sed -e "s/_EXTNAME_/$EXTNAME/g" > $extname.php
chmod 644 *
echo " [done]."
cat <<eof
To use your new extension, you will have to execute the following steps:
$ cd ..
$ vi ext/$extname/config.m4
$ ./buildconf
$ ./configure --[with|enable]-$extname
$ make
$ vi ext/$extname/$extname.c
Repeat the last two steps as often as necessary.
eof