Jump to content


Photo

problem with config.m4 file


  • Please log in to reply
3 replies to this topic

#1 MaaSTaaR

MaaSTaaR
  • Members
  • PipPip
  • Member
  • 26 posts
  • LocationKuwait

Posted 07 September 2006 - 12:43 AM

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 ?

Sorry for my bad English, it's not my mother language and I am still learning it :)

#2 btherl

btherl
  • Staff Alumni
  • Advanced Member
  • 3,893 posts
  • LocationAustralia

Posted 07 September 2006 - 02:49 AM

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 :)

#3 MaaSTaaR

MaaSTaaR
  • Members
  • PipPip
  • Member
  • 26 posts
  • LocationKuwait

Posted 07 September 2006 - 09:39 AM

Hello ...

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

in the article (http://www.zend.com/...on-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 ?
Sorry for my bad English, it's not my mother language and I am still learning it :)

#4 btherl

btherl
  • Staff Alumni
  • Advanced Member
  • 3,893 posts
  • LocationAustralia

Posted 10 September 2006 - 05:18 AM

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.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users