#!/bin/sh extname="$1" EXTNAME=`echo $1|tr a-z A-Z` if [ ! -z $2 -a -r $2 ]; then functions=$2 echo=$2 fi givup() { echo $* exit 1 } if test "$extname" = ""; then givup "usage: $0 extension-name [/full/path/to/function-list]" 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" test -d skeleton || givup "subdirectory skeleton does not exist or is not 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" if [ ! -z $functions ]; then echo $functions cat $functions | awk -v extname=$extname -f ./skeleton/create_stubs fi cd $extname chmod 755 . $ECHO_N "Creating basic files:$ECHO_C" $ECHO_N " config.m4$ECHO_C" cat >config.m4 <Makefile.in <.cvsignore < $extname.c $ECHO_N " php_$extname.h$ECHO_C" cat ../skeleton/php_skeleton.h | sed \ -e "s/extname/$extname/g" \ -e "s/EXTNAME/$EXTNAME/g" \ -e '/__function_declarations_here__/r function_declarations' \ -e '/__function_declarations_here__/D' \ > php_$extname.h $ECHO_N " $extname.php$ECHO_C" cat ../skeleton/skeleton.php | sed \ -e "s/extname/$extname/g" \ > $extname.php if [ ! -z $functions ]; then rm function_entries rm function_declarations rm function_stubs if [ -f function_warning ]; then rm function_warning warning=" NOTE! Because some arguments to functions were resources, the code generated cannot yet be compiled without editing. Please consider this to be step 4.5 in the instructions above. " fi fi chmod 644 * echo " [done]." cat <