Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
pbiggar opened this issue Jun 3, 2015 · 5 comments
Open

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

pbiggar opened this issue Jun 3, 2015 · 5 comments

Comments

@pbiggar
Copy link
Owner

pbiggar commented Jun 3, 2015

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 thesin on 2012-06-19 15:03:16

@pbiggar
Copy link
Owner Author

pbiggar commented Jun 3, 2015

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 issue reported on code.google.com by thesin on 2012-06-19 16:33:09

@pbiggar
Copy link
Owner Author

pbiggar commented Jun 3, 2015

Sounds good, can you provide a pull request to https://github.com/pbiggar/phc?

Original issue reported on code.google.com by paul.biggar on 2012-06-19 16:48:11

@pbiggar
Copy link
Owner Author

pbiggar commented Jun 3, 2015

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 issue reported on code.google.com by thesin on 2012-06-19 16:59:10

@pbiggar
Copy link
Owner Author

pbiggar commented Jun 3, 2015

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 issue reported on code.google.com by thesin on 2012-06-19 19:57:32

@pbiggar
Copy link
Owner Author

pbiggar commented Jun 3, 2015

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

Original issue reported on code.google.com by thesin on 2012-06-19 21:08:56

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant