summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.EXT_SKEL43
-rw-r--r--README.SELF-CONTAINED-EXTENSIONS4
-rwxr-xr-xext/ext_skel.php110
3 files changed, 91 insertions, 66 deletions
diff --git a/README.EXT_SKEL b/README.EXT_SKEL
deleted file mode 100644
index ea450c045a..0000000000
--- a/README.EXT_SKEL
+++ /dev/null
@@ -1,43 +0,0 @@
-WHAT IT IS
-
- It's a tool for automatically creating the basic framework for a PHP extension.
-
-HOW TO USE IT
-
- Very simple. First, change to the ext/ directory of the PHP sources. Then
- run the following
-
- php ext_skel.php --ext extension_name
-
- and everything you need will be placed in directory ext/extension_name.
-
- If you don't need to test the existence of any external header files,
- libraries or functions in them, the extension is ready to be compiled in
- PHP. To compile the extension, run the following:
-
- ./buildconf; ./configure --enable-extension_name; make
-
- The definition of PHP_extension_NAME_VERSION will be present in the
- php_extension_name.h and injected into the zend_extension_entry definition. This
- is required by the PECL website for the version string conformity checks
- against package.xml
-
-SOURCE AND HEADER FILE NAME
-
- The ext_skel.php script generates 'extension_name.c' and 'php_extension_name.h'
- as the main source and header files. Keep these names.
-
- extension functions (User functions) must be named
-
- extension_name_function()
-
- When you need to expose extension functions to other extensions, expose functions
- strictly needed by others. Exposed internal function must be named
-
- php_extension_name_function()
-
- See also CODING_STANDARDS.
-
-OTHER OPTIONS
-
- Run php ext_skel.php --help to see the available options.
diff --git a/README.SELF-CONTAINED-EXTENSIONS b/README.SELF-CONTAINED-EXTENSIONS
index e28ec4d6db..1aaec6d6c4 100644
--- a/README.SELF-CONTAINED-EXTENSIONS
+++ b/README.SELF-CONTAINED-EXTENSIONS
@@ -104,8 +104,8 @@ CREATING SOURCE FILES
ext_skel can be of great help when creating the common code for all modules
in PHP for you and also writing basic function definitions and C code for
- handling arguments passed to your functions. See README.EXT_SKEL for further
- information.
+ handling arguments passed to your functions. See `./ext/ext_skel.php --help`
+ for further information.
As for the rest, you are currently alone here. There are a lot of existing
modules, use a simple module as a starting point and add your own code.
diff --git a/ext/ext_skel.php b/ext/ext_skel.php
index ff41ee8ccf..4623910ecf 100755
--- a/ext/ext_skel.php
+++ b/ext/ext_skel.php
@@ -31,23 +31,91 @@ function error($message) {
/* {{{ print_help
*/
function print_help() {
- printf('php ext_skel.php --ext <name> [--experimental] [--author <name>]%s', PHP_EOL);
- printf(' [--dir <path>] [--std] [--onlyunix]%s', PHP_EOL);
- printf(' [--onlywindows] [--help]%1$s%1$s', PHP_EOL);
- printf(' --ext <name> The name of the extension defined as <name>%s', PHP_EOL);
- printf(' --experimental Passed if this extension is experimental, this creates%s', PHP_EOL);
- printf(' the EXPERIMENTAL file in the root of the extension%s', PHP_EOL);
- printf(' --author <name> Your name, this is used if --std is passed and%s', PHP_EOL);
- printf(' for the CREDITS file%s', PHP_EOL);
- printf(' --dir <path> Path to the directory for where extension should be%s', PHP_EOL);
- printf(' created. Defaults to the directory of where this script%s', PHP_EOL);
- printf(' lives%s', PHP_EOL);
- printf(' --std If passed, the standard header used%s', PHP_EOL);
- printf(' in extensions that is included in the core, will be used%s', PHP_EOL);
- printf(' --onlyunix Only generate configure scripts for Unix%s', PHP_EOL);
- printf(' --onlywindows Only generate configure scripts for Windows%s', PHP_EOL);
- printf(' --help This help%s', PHP_EOL);
+ if (PHP_OS_FAMILY != 'Windows') {
+ $file_prefix = './';
+ $make_prefix = '';
+ } else {
+ $file_prefix = '';
+ $make_prefix = 'n';
+ }
+ echo <<<HELP
+WHAT IT IS
+
+ It's a tool for automatically creating the basic framework for a PHP extension.
+
+HOW TO USE IT
+
+ Very simple. First, change to the ext/ directory of the PHP sources. Then run
+ the following
+
+ php ext_skel.php --ext extension_name
+
+ and everything you need will be placed in directory ext/extension_name.
+
+ If you don't need to test the existence of any external header files,
+ libraries or functions in them, the extension is ready to be compiled in PHP.
+ To compile the extension run the following:
+
+ cd extension_name
+ phpize
+ {$file_prefix}configure
+ {$make_prefix}make
+
+ Don't forget to run tests once the compilation is done:
+
+ {$make_prefix}make test
+
+ Alternatively, to compile extension in the PHP:
+
+ cd /path/to/php-src
+ {$file_prefix}buildconf
+ {$file_prefix}configure --enable-extension_name
+ {$make_prefix}make
+ {$make_prefix}make test TESTS=ext/extension_name/tests
+
+ The definition of PHP_extension_NAME_VERSION will be present in the
+ php_extension_name.h and injected into the zend_extension_entry definition.
+ This is required by the PECL website for the version string conformity checks
+ against package.xml
+
+SOURCE AND HEADER FILE NAME
+
+ The ext_skel.php script generates 'extension_name.c' and 'php_extension_name.h'
+ as the main source and header files. Keep these names.
+
+ extension functions (User functions) must be named
+
+ extension_name_function()
+
+ When you need to expose extension functions to other extensions, expose
+ functions strictly needed by others. Exposed internal function must be named
+
+ php_extension_name_function()
+
+ See also CODING_STANDARDS.
+
+OPTIONS
+
+ php ext_skel.php --ext <name> [--experimental] [--author <name>]
+ [--dir <path>] [--std] [--onlyunix]
+ [--onlywindows] [--help]
+
+ --ext <name> The name of the extension defined as <name>
+ --experimental Passed if this extension is experimental, this creates
+ the EXPERIMENTAL file in the root of the extension
+ --author <name> Your name, this is used if --std is passed and for the
+ CREDITS file
+ --dir <path> Path to the directory for where extension should be
+ created. Defaults to the directory of where this script
+ lives
+ --std If passed, the standard header used in extensions that
+ is included in the core, will be used
+ --onlyunix Only generate configure scripts for Unix
+ --onlywindows Only generate configure scripts for Windows
+ --help This help
+
+HELP;
exit;
}
/* }}} */
@@ -76,14 +144,14 @@ function print_success() {
$make_prefix = 'n';
}
- printf('%1$sSuccess. The extension is now ready to be compiled into PHP. To do so, use the%s', PHP_EOL);
+ printf('%1$sSuccess. The extension is now ready to be compiled. To do so, use the%s', PHP_EOL);
printf('following steps:%1$s%1$s', PHP_EOL);
- printf('cd /path/to/php-src%s', PHP_EOL);
- printf('%sbuildconf%s', $file_prefix, PHP_EOL);
- printf('%sconfigure --enable-%s%s', $file_prefix, $options['ext'], PHP_EOL);
+ printf('cd /path/to/php-src/%s%s', $options['ext'], PHP_EOL);
+ printf('phpize%s', PHP_EOL);
+ printf('%sconfigure%s', $file_prefix, PHP_EOL);
printf('%smake%2$s%2$s', $make_prefix, PHP_EOL);
printf('Don\'t forget to run tests once the compilation is done:%s', PHP_EOL);
- printf('%smake test TESTS=ext/%s/tests%3$s%3$s', $make_prefix, $options['ext'], PHP_EOL);
+ printf('%smake test%2$s%2$s', $make_prefix, PHP_EOL);
printf('Thank you for using PHP!%s', PHP_EOL);
}
/* }}} */