Skip to content

Commit 287a883

Browse files
committed
allow to customize BZip2 location during installation
1 parent 8cdad18 commit 287a883

File tree

3 files changed

+45
-30
lines changed

3 files changed

+45
-30
lines changed

.github/workflows/config.yml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,6 @@ jobs:
77
version: ["7.4", "8.0", "8.1", "8.2"]
88
runs-on: ubuntu-latest
99
steps:
10-
- name: Install package libbz2-dev
11-
run: |
12-
sudo apt-get update
13-
sudo apt-get install -y libbz2-dev --no-install-recommends
1410
- name: Checkout php-bsdiff
1511
uses: actions/checkout@v2
1612
- name: Setup PHP
@@ -20,7 +16,7 @@ jobs:
2016
- name: phpize
2117
run: phpize
2218
- name: configure
23-
run: ./configure
19+
run: ./configure --with-libdir=x86_64-linux-gnu
2420
- name: make
2521
run: make
2622
- name: test

README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,15 @@ For more information, visit his website at <http://www.daemonology.net/bsdiff/>.
1111
## Requirements
1212

1313
* PHP 7.4+
14+
* BZip2 1.0+
1415

1516
## Installation
1617

1718
```bash
1819
phpize
1920
./configure
2021
make
21-
make test # optional
22+
make test
2223
make install
2324
```
2425

@@ -28,6 +29,12 @@ Once done, add the following line to your `php.ini` file:
2829
extension=bsdiff.so
2930
```
3031

32+
In case BZip2 can't be found automatically, use option `--with-bz2` to specify the installation directory of BZip2. e.g.,
33+
34+
```bash
35+
./configure --with-bz2=/usr/local/opt/bzip2 # When BZip2 is stalled via Homebrew on MacOS.
36+
```
37+
3138
## Functions
3239

3340
There are two PHP functions added by the extension:

config.m4

Lines changed: 36 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ PHP_ARG_ENABLE([bsdiff],
1818
[Enable bsdiff support])],
1919
[no])
2020

21+
PHP_ARG_WITH([bz2],
22+
[to specify installation directory of BZip2],
23+
[AS_HELP_STRING([[--with-bz2=DIR]],
24+
[Specify installation directory of BZip2])])
25+
2126
if test "$PHP_BSDIFF" != "no"; then
2227
dnl Write more examples of tests here...
2328

@@ -62,30 +67,37 @@ if test "$PHP_BSDIFF" != "no"; then
6267
dnl LIBNAME=BSDIFF # you may want to change this
6368
dnl LIBSYMBOL=BSDIFF # you most likely want to change this
6469

65-
dnl If you need to check for a particular library function (e.g. a conditional
66-
dnl or version-dependent feature) and you are using pkg-config:
67-
dnl PHP_CHECK_LIBRARY($LIBNAME, $LIBSYMBOL,
68-
dnl [
69-
dnl AC_DEFINE(HAVE_BSDIFF_FEATURE, 1, [ ])
70-
dnl ],[
71-
dnl AC_MSG_ERROR([FEATURE not supported by your bsdiff library.])
72-
dnl ], [
73-
dnl $LIBFOO_LIBS
74-
dnl ])
75-
76-
dnl If you need to check for a particular library function (e.g. a conditional
77-
dnl or version-dependent feature) and you are not using pkg-config:
78-
dnl PHP_CHECK_LIBRARY($LIBNAME, $LIBSYMBOL,
79-
dnl [
80-
dnl PHP_ADD_LIBRARY_WITH_PATH($LIBNAME, $BSDIFF_DIR/$PHP_LIBDIR, BSDIFF_SHARED_LIBADD)
81-
dnl AC_DEFINE(HAVE_BSDIFF_FEATURE, 1, [ ])
82-
dnl ],[
83-
dnl AC_MSG_ERROR([FEATURE not supported by your bsdiff library.])
84-
dnl ],[
85-
dnl -L$BSDIFF_DIR/$PHP_LIBDIR -lm
86-
dnl ])
87-
dnl
88-
dnl PHP_SUBST(BSDIFF_SHARED_LIBADD)
70+
if test "$PHP_BZ2" != "no"; then
71+
if test -r $PHP_BZ2/include/bzlib.h; then
72+
BZIP_DIR=$PHP_BZ2
73+
else
74+
AC_MSG_CHECKING(for BZip2 in default path)
75+
for i in /usr/local /usr; do
76+
if test -r $i/include/bzlib.h; then
77+
BZIP_DIR=$i
78+
AC_MSG_RESULT(found in $i)
79+
break
80+
fi
81+
done
82+
fi
83+
84+
if test -z "$BZIP_DIR"; then
85+
AC_MSG_RESULT(not found)
86+
AC_MSG_ERROR(Please reinstall the BZip2 distribution)
87+
fi
88+
89+
PHP_CHECK_LIBRARY(bz2, BZ2_bzWriteOpen,
90+
[
91+
PHP_ADD_INCLUDE($BZIP_DIR/include)
92+
PHP_ADD_LIBRARY_WITH_PATH(bz2, $BZIP_DIR/$PHP_LIBDIR, BSDIFF_SHARED_LIBADD)
93+
AC_DEFINE(HAVE_BZ2,1,[ ])
94+
], [
95+
AC_MSG_ERROR(php-bsdiff requires libbz2 >= 1.0.0)
96+
], [
97+
-L$BZIP_DIR/$PHP_LIBDIR
98+
])
99+
PHP_SUBST(BSDIFF_SHARED_LIBADD)
100+
fi
89101

90102
dnl In case of no dependencies
91103
AC_DEFINE(HAVE_BSDIFF, 1, [ Have bsdiff support ])

0 commit comments

Comments
 (0)