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

Build multiple php versions #525

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

ebikt
Copy link
Contributor

@ebikt ebikt commented Apr 22, 2024

There can be multiple PHP versions installed at once on Debian Linux distributions. PHP maintainer for debian has repositories for this hosted on deb.sury.org. User needs to copy PHP-CPP source to be able to build phpcpp for multiple
php versions at once. Moreover they need patch soname of output .so, so that multiple versions can be used simultaneously.

This merge requests aims to fix that, by introducing Makefile variables:

  • LIBRARY_NAME (default libphpcpp
  • BUILD_DIR (default build)
  • LDCONFIG (default $(shell which ldconfig 2>/dev/null))

This change is backward compatible, i.e., behaviour of Makefile does not change when user user uses default values, with one exception: resulting .so and .a are now stored in root of $(BUILD_DIR) instead of root of project, so that multiple versions can be built at once, even if user wants them to have same name.

Excerpt from my makefile, that wraps PHP-CPP makefile for building for multiple PHP versions,
main line is the MAKEPHPCPP variable which expects PHP version in $* and expands to
call to PHP-CPP Makefile with properly set build variables.

all: $(addprefix do-all-, $(PHP_VERSIONS))
install: $(addprefix install-all-,$(PHP_VERSIONS))

PHP_CONFIG=php-config$*
DEBDEV=debian/phpcpp-php$*-dev
DEBLIB=debian/libphpcpp-php$*
#Relative to DEBDEV
DEBLIB_REL=../../$(DEBLIB)

MAKEPHPCPP=$(MAKE) -C PHP-CPP BUILD_DIR=build-$* PHP_CONFIG='$(PHP_CONFIG)' LIBRARY_NAME='libphpcpp$*'

call-all-%:
        $(MAKEPHPCPP)

do-all-%: call-all-%
        true

call-install-%:
        $(MAKEPHPCPP) install \
                LDCONFIG="" \
                INSTALL_LIB="../$(DEBDEV)/usr/lib/$(DEB_HOST_GNU_TYPE)/" \
                INSTALL_HEADERS="../$(DEBDEV)/`$(PHP_CONFIG) --include-dir`" \
                CP="cp -af"

do-install-%: call-install-%
        mkdir -p '$(DEBLIB)/usr/lib/$(DEB_HOST_GNU_TYPE)'
        set -e; cd '$(DEBDEV)'; \
        for F in 'usr/lib/$(DEB_HOST_GNU_TYPE)/libphpcpp$*.so.'*; do mv "$$F" '$(DEBLIB_REL)/'"$$F"; done
        mkdir -p '$(DEBDEV)/usr/share/pkgconfig/'
        sh phpcpp.pc.in $* > '$(DEBDEV)/usr/share/pkgconfig/phpcpp-php$*.pc'

ebikt added 4 commits April 22, 2024 09:08
Wnen building for multiple PHP versions at once (e.g. in Debian
Linux distribution), we need configurable build directory, so
that we avoid copying source code.
When installing multiple php versions at once, ldconfig may fail
when executed in parallel. This enables to configure command to
be executed instead of ldconfig.
We need to distinguish phpcpp built for different php versions on same
system, easiest way is to make different library name.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant