[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: I need a hint to integrate a php-extension build into an existing au

From: Russ Allbery
Subject: Re: I need a hint to integrate a php-extension build into an existing automake
Date: Thu, 01 Oct 2009 12:54:45 -0700
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux)

Andreas Otto <address@hidden> writes:

>   I want to add a "php" extension into an allready existing project creating
>   various extensions to other languages as well

Yeah, this is always weird.  I keep meaning to write up what I'm currently
doing in my projects for review.

> 1. while running the toplevel "automake" (or autoreconf)  I would like to run
>     the tool "phpize" in the phpmsgque subdirectory to create the php build
>    environment. I have the "" (not used in the php build) to
>    add instructions to link the both build environments.
> 2. while run toplevel "configure" I would like to run the "configure"
>       script in the "phpmsgque" subdirectory as well

I played with doing things this way, and in my experience it's not a good
idea.  It turns out to work better if you run configure in the php
subdirectory during the build instead of when running configure at the top
level.  The reason for this is that you want to detect phpize during your
top-level configure and then run it on the build host, not distribute its
results as part of your distribution, since it hard-codes paths.  Also,
the amount of hacking you have to do in configure to run phpize before
recursing into the subdirectory is just insane and not really

Here's what I do.  In

dnl Whether to build the PHP bindings.
    [AC_HELP_STRING([--enable-php], [Build remctl PECL extension for PHP])],
    [AS_IF([test x"$enableval" = xyes],
         AC_ARG_VAR([PHPIZE], [Path to phpize])
         AC_PATH_PROG([PHPIZE], [phpize])
         AS_IF([test x"$PHPIZE" = x],
             [AC_MSG_ERROR([cannot build PECL extension without phpize])])])])
AM_CONDITIONAL([BUILD_PHP], [test x"$build_php" = xyes])
AS_IF([test x"$build_php" = xyes],
    [AC_CONFIG_FILES([php/config.m4 php/php_remctl.h])])

Then, in at the top level:

PHP_FILES = php/README php/php_remctl.c php/test-wrapper php/tests/001.phpt \
        php/tests/002.phpt php/tests/003.phpt

# phpize --clean is stupid and requires that config.m4 exist, but it was
# already deleted by the regular distclean target.  Hack around that.
        set -e; if [ x"$(builddir)" != x"$(srcdir)" ] ; then \
            rm -rf php ; \
        else \
            if [ -n "$(PHPIZE)" ] ; then \
                cd php && touch config.m4 && $(PHPIZE) --clean && cd .. ; \
            fi ; \
            rm -f php/ php/config.m4 ; \

# The following section sets up the PECL extension for PHP.

PHP_WARNINGS = -Wno-strict-prototypes -Wno-write-strings \
        -Wno-missing-prototypes -Wno-unused-parameter

php/modules/ php/config.m4 php/php_remctl.h \
        set -e; if [ x"$(builddir)" != x"$(srcdir)" ] ; then \
            mkdir php/tests 2>/dev/null || true ; \
            for f in $(PHP_FILES) ; do \
                cp "$(srcdir)/$$f" "$(builddir)/$$f" ; \
            done \
        cd php && $(PHPIZE) --clean && $(PHPIZE)
        cd php && ./configure CPPFLAGS="$(CPPFLAGS)" \
        cd php && $(MAKE) CFLAGS="$(CFLAGS) $(PHP_WARNINGS)"

# PHP's build system uses INSTALL_ROOT where everyone else uses DESTDIR.
install-data-local-php: php/modules/
        cd php && $(MAKE) install INSTALL_ROOT=$(DESTDIR)

# Build and install the PHP bindings if desired.
BINDINGS += php/modules/
BINDINGS_INSTALL += install-data-local-php

all-local: $(BINDINGS)
install-data-local: $(BINDINGS_INSTALL)

Russ Allbery (address@hidden)             <>

reply via email to

[Prev in Thread] Current Thread [Next in Thread]