ARudik / phc

Automatically exported from code.google.com/p/phc
0 stars 0 forks source link

php5 includes should use php-config --includes #146

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. none required
2.
3.

What is the expected output? What do you see instead?
currently ./configure only searched specific directories, include/php/... it 
would be better to use php-config --includes to get the proper directories, 
since in fink and debian these headers are in include/php5/...

What version of the product are you using? On what operating system?
0.3.0.1, OSX 10.7.4 (Darwin 11.4.0)

Please provide any additional information below.
currently ./configure only searched specific directories, include/php/... it 
would be better to use php-config --includes to get the proper directories, 
since in fink and debian these headers are in include/php5/...

Original issue reported on code.google.com by the...@gmail.com on 19 Jun 2012 at 3:03

GoogleCodeExporter commented 9 years ago
just found that this affects src/codegen/Compile_C.cpp as well, and I see now 
that this is true for libdir where libphp5.dylib is kept in fink this is 
PHPDIR/lib/php5/libphp5.dylib, I was just adding -LPHPDIR/lib/php5 to LDFLAGS 
but now I need to patch src/codegen/Compile_C.cpp so it adds the right lib dir.

Original comment by the...@gmail.com on 19 Jun 2012 at 4:33

GoogleCodeExporter commented 9 years ago
Sounds good, can you provide a pull request to https://github.com/pbiggar/phc?

Original comment by paul.biggar on 19 Jun 2012 at 4:48

GoogleCodeExporter commented 9 years ago
I haven't done a proper patch for this, I believe this will take some work and 
maybe some compile time or config.h defines to pass to src/codegen/Compile_C.cpp

I'm currently just running

perl -pi -e 's,include/php,include/php5,g' m4/php-embed.m4
perl -pi -e 's,include/php,include/php5,g' src/codegen/Compile_C.cpp
perl -pi -e 's,/lib,/lib/php5,g' src/codegen/Compile_C.cpp

and setting LDFLAGS=-L/sw/lib/php5

/sw = PHP_INSTALL_DIR, but can change in fink

I'm not that good with auto tools, but I'll see if I can figure out how to add 
a check to php-embed.m4 for php-config and prefer it if it exists, then I'll 
need to setup since defines in config.h to parse and pass those include dirs to 
src/codegen/Compile_C.cpp as well as perhaps make a --php-embed-libdir= option 
for configure doing the same since php-config doesn't keep the embed lib dir 
any place.

Original comment by the...@gmail.com on 19 Jun 2012 at 4:59

GoogleCodeExporter commented 9 years ago
I'm thinking something like this to start, still need to work out the DEFINES 
that will be required and how I'll parse php-config --includes, still need to 
make a loop check for the PHP_LIB_PATH though, maybe check PHP_INSTALL_PATH/lib 
then PHP_INSTALL_PATH/lib/php then PHP_INSTALL_PATH/lib/php5 ?  This is just a 
start, I'll keep working on it, like I said though I'm not an auto tools expert 
by any extension ;)

dnl Find php-config script
PHP_ARG_WITH(php-config,,
[  --with-php-config=PATH  Path to php-config [php-config]], php-config, no)

dnl For BC
PHP_CONFIG=$PHP_PHP_CONFIG
PHP_INSTALL_PATH=`$PHP_CONFIG --prefix 2>/dev/null`
PHP_INCLUDES=`$PHP_CONFIG --includes 2>/dev/null`
PHP_EXECUTABLE=`$PHP_CONFIG --php-binary 2>/dev/null`

if test -z "$prefix"; then
  AC_MSG_ERROR([Cannot find php-config. Please use --with-php-config=PATH])
fi

    dnl To check if the PHP embed SAPI has been installed, we temporarily add the
    dnl PHP installation path to LDFLAGS and CFLAGS, and restore it later (since 
    dnl we do not need that path to build phc itself).
    AS_VAR_SET(found_embed_sapi, yes)
    OLD_LDFLAGS=$LDFLAGS
    OLD_CFLAGS=$CFLAGS
    LDFLAGS="-L${PHP_INSTALL_PATH}/lib $LDFLAGS"    
    CFLAGS="${PHP_INCLUDES} $CFLAGS"
    AC_CHECK_LIB(
        [php5], 
        [zend_eval_string], 
        [
            AS_VAR_SET(found_embed_sapi, yes)
            AC_DEFINE(HAVE_EMBED, 1)
            AC_SUBST([libphp_headers], ["${PHP_INCLUDES}"])
            LIBS="-lphp5 -L${PHP_INSTALL_PATH}/lib -R${PHP_INSTALL_PATH}/lib $LIBS"
        ], 
        [
            AS_VAR_SET(found_embed_sapi, no)
        ], 
        []
        )
    AC_CHECK_HEADER(
        [sapi/embed/php_embed.h], 
        [], 
        [AS_VAR_SET(found_embed_sapi, no)],
        []
        )
    CFLAGS=$OLD_CFLAGS
    LDFLAGS=$OLD_LDFLAGS
])

Original comment by the...@gmail.com on 19 Jun 2012 at 7:57

GoogleCodeExporter commented 9 years ago
I got something whipped up, not going to say it's 100%, but it works here, send 
a git push request.

Original comment by the...@gmail.com on 19 Jun 2012 at 9:08