Jump to content

Archived

This topic is now archived and is closed to further replies.

MaaSTaaR

problem with config.m4 file

Recommended Posts

Hello ...

sorry for my bad English .

My os is Ubuntu Linux and i have Bison 2.3 , Flex 2.5.31 , GCC 4.0.3 .

i don't have any problem with compile php , but my problem exactly is i get this problem from config.m4 file :

maastaar@MaaSTaaR:~/php-4.4.4/ext/hello$ ./config.m4
./config.m4: line 1: syntax error near unexpected token `hello,'
./config.m4: line 1: `PHP_ARG_ENABLE(hello, whether to enable Hello World support,'


config.m4 :
PHP_ARG_ENABLE(hello, whether to enable Hello World support,
[ --enable-hello  Enable Hello World support])

if test "$PHP_HELLO" = "yes"; then
  AC_DEFINE(HAVE_HELLO, 1, [Whether you have Hello World])
  PHP_NEW_EXTENSION(hello, hello.c, $ext_shared)
fi


hello.c :
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#include "php.h"
#include "php_hello.h"

static function_entry hello_functions[] = {
    PHP_FE(hello_world, NULL)
    {NULL, NULL, NULL}
};

zend_module_entry hello_module_entry = {
#if ZEND_MODULE_API_NO >= 20010901
    STANDARD_MODULE_HEADER,
#endif
    PHP_HELLO_WORLD_EXTNAME,
    hello_functions,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
#if ZEND_MODULE_API_NO >= 20010901
    PHP_HELLO_WORLD_VERSION,
#endif
    STANDARD_MODULE_PROPERTIES
};

#ifdef COMPILE_DL_HELLO
ZEND_GET_MODULE(hello)
#endif

PHP_FUNCTION(hello_world)
{
    char *str;

    str = estrdup("Hello World");
    RETURN_STRING(str, 0);
}


php_hello.h :
#ifndef PHP_HELLO_H
#define PHP_HELLO_H 1

#define PHP_HELLO_WORLD_VERSION "1.0"
#define PHP_HELLO_WORLD_EXTNAME "hello"

PHP_FUNCTION(hello_world);

extern zend_module_entry hello_module_entry;
#define phpext_hello_ptr &hello_module_entry

#endif


what is the problem , and how i can solve it ?

Share this post


Link to post
Share on other sites
Hi,

You should not be running "./config.m4" directly.  Instead, you should edit config.m4, and then run "./buildconf"

These are the instructions you should follow (from extskel):

"To use your new extension, you will have to execute the following steps:

1.  $ cd ..
2.  $ vi ext/hello/config.m4
3.  $ ./buildconf
4.  $ ./configure --[with|enable]-hello
5.  $ make
6.  $ ./php -f ext/hello/hello.php
7.  $ vi ext/hello/hello.c
8.  $ make

Repeat steps 3-6 until you are satisfied with ext/hello/config.m4 and
step 6 confirms that your module is compiled into PHP. Then, start writing
code and repeat the last two steps as often as necessary."

Good luck, and have fun :)

Share this post


Link to post
Share on other sites
Hello ...

great it's work fine now thanks :) , i have another question please .

in the article (http://www.zend.com/php/internals/extension-writing1.php) the writer said "After running each of these commands, you should have a hello.so file in ext/hello/modules/" , The problem is i don't have hello.so i have hello.o only , so how i can generating the hello.so to use it as php extension ?

Share this post


Link to post
Share on other sites
I don't have any ".so" file for my extension either.  I think it is ok.  The extension still works properly.

I have these files only (my extension is named c_array):

c_array.c  c_array.o    config.m4  CREDITS      php_c_array.h
c_array.lo  c_array.php  config.w32  EXPERIMENTAL  tests

I am using php-5.1.6 source.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.