Skip to content

Commit 0c07b0d

Browse files
adsrpetk
authored andcommitted
Make --enable-embed libs respect --libdir
And make locatable by via `php-config`. Prior to this, `libphp.*` would always install to `$prefix/lib`. After this, they will install to `$libdir`. In practice, this will make it so that programs embedding libphp can use `php-config` to determine appropriate compile flags without guessing. In `configure.ac`, it seems `$libdir` is mutated in some instances. Ideally the mutated version would be stored in `$phplibdir` or something. Instead of tracking down all uses of that variable, I introduced another variable `$orig_libdir` that holds the original value passed to the configure script. This is a no-op for users unless they are compiling with `--libdir` set to something other than `$prefix/lib`, the default. Closes GH-12389
1 parent df017cd commit 0c07b0d

File tree

5 files changed

+36
-4
lines changed

5 files changed

+36
-4
lines changed

‎UPGRADING.INTERNALS

+1
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ PHP 8.4 INTERNALS UPGRADE NOTES
120120
AC_CHECK_MEMBERS).
121121
- M4 macro PHP_CHECK_GCC_ARG has been removed since PHP 8.0 (use
122122
AX_CHECK_COMPILE_FLAG).
123+
- Added php-config --lib-dir and --lib-embed options for PHP embed SAPI.
123124

124125
c. Windows build system changes
125126
- The configure options --with-oci8-11g, --with-oci8-12c, --with-oci8-19 have

‎configure.ac

+9-2
Original file line numberDiff line numberDiff line change
@@ -287,8 +287,11 @@ dnl SAPI configuration.
287287
dnl ----------------------------------------------------------------------------
288288

289289
dnl Paths to the targets are relative to the build directory.
290-
SAPI_SHARED=libs/libphp.[]$SHLIB_DL_SUFFIX_NAME
291-
SAPI_STATIC=libs/libphp.a
290+
SAPI_LIBNAME=libphp
291+
SAPI_LIBNAME_SHARED=$SAPI_LIBNAME.[]$SHLIB_DL_SUFFIX_NAME
292+
SAPI_LIBNAME_STATIC=$SAPI_LIBNAME.a
293+
SAPI_SHARED=libs/$SAPI_LIBNAME_SHARED
294+
SAPI_STATIC=libs/$SAPI_LIBNAME_STATIC
292295
SAPI_LIBTOOL=libphp.la
293296

294297
PHP_CONFIGURE_PART(Configuring SAPI modules)
@@ -1369,6 +1372,7 @@ test "$exec_prefix" = "NONE" && exec_prefix='${prefix}'
13691372
test "$program_prefix" = "NONE" && program_prefix=
13701373
test "$program_suffix" = "NONE" && program_suffix=
13711374

1375+
orig_libdir=$libdir
13721376
case $libdir in
13731377
'${exec_prefix}/lib')
13741378
libdir=$libdir/php
@@ -1504,6 +1508,7 @@ PHP_SUBST(exec_prefix)
15041508
PHP_SUBST_OLD(program_prefix)
15051509
PHP_SUBST_OLD(program_suffix)
15061510
PHP_SUBST(includedir)
1511+
PHP_SUBST_OLD(orig_libdir)
15071512
PHP_SUBST(libdir)
15081513
PHP_SUBST(mandir)
15091514
PHP_SUBST(phptempdir)
@@ -1546,6 +1551,8 @@ PHP_SUBST(SHELL)
15461551
PHP_SUBST(PHP_FRAMEWORKS)
15471552
PHP_SUBST(PHP_FRAMEWORKPATH)
15481553
PHP_SUBST(INSTALL_HEADERS)
1554+
PHP_SUBST_OLD(SAPI_LIBNAME_SHARED)
1555+
PHP_SUBST_OLD(SAPI_LIBNAME_STATIC)
15491556

15501557
old_CC=$CC
15511558

‎sapi/embed/config.m4

+3-2
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ if test "$PHP_EMBED" != "no"; then
1212
yes|shared)
1313
LIBPHP_CFLAGS="-shared"
1414
PHP_EMBED_TYPE=shared
15-
INSTALL_IT="\$(mkinstalldirs) \$(INSTALL_ROOT)\$(prefix)/lib; \$(INSTALL) -m 0755 $SAPI_SHARED \$(INSTALL_ROOT)\$(prefix)/lib"
15+
INSTALL_IT="\$(mkinstalldirs) \$(INSTALL_ROOT)\$(orig_libdir); \$(INSTALL) -m 0755 $SAPI_SHARED \$(INSTALL_ROOT)\$(orig_libdir)"
1616
;;
1717
static)
1818
LIBPHP_CFLAGS="-static"
1919
PHP_EMBED_TYPE=static
20-
INSTALL_IT="\$(mkinstalldirs) \$(INSTALL_ROOT)\$(prefix)/lib; \$(INSTALL) -m 0644 $SAPI_STATIC \$(INSTALL_ROOT)\$(prefix)/lib"
20+
INSTALL_IT="\$(mkinstalldirs) \$(INSTALL_ROOT)\$(orig_libdir); \$(INSTALL) -m 0644 $SAPI_STATIC \$(INSTALL_ROOT)\$(orig_libdir)"
2121
;;
2222
*)
2323
PHP_EMBED_TYPE=no
@@ -29,6 +29,7 @@ if test "$PHP_EMBED" != "no"; then
2929
PHP_INSTALL_HEADERS([sapi/embed], [php_embed.h])
3030
fi
3131
AC_MSG_RESULT([$PHP_EMBED_TYPE])
32+
PHP_SUBST_OLD(PHP_EMBED_TYPE)
3233
else
3334
AC_MSG_RESULT(no)
3435
fi

‎scripts/man1/php-config.1.in

+8
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,14 @@ Directory where extensions are searched by default
3939
Directory prefix where header files are installed by default
4040
.TP
4141
.PD 0
42+
.B \-\-lib-dir
43+
Directory where libraries are installed by default
44+
.TP
45+
.PD 0
46+
.B \-\-lib-embed
47+
PHP embed library name
48+
.TP
49+
.PD 0
4250
.B \-\-php-binary
4351
Full path to php CLI or CGI binary
4452
.TP

‎scripts/php-config.in

+15
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ exec_prefix="@exec_prefix@"
77
version="@PHP_VERSION@"
88
vernum="@PHP_VERSION_ID@"
99
include_dir="@includedir@/php"
10+
lib_dir="@orig_libdir@"
1011
includes="-I$include_dir -I$include_dir/main -I$include_dir/TSRM -I$include_dir/Zend -I$include_dir/ext -I$include_dir/ext/date/lib"
1112
ldflags="@PHP_LDFLAGS@"
1213
libs="@EXTRA_LIBS@"
@@ -21,6 +22,7 @@ configure_options="@CONFIGURE_OPTIONS@"
2122
php_sapis="@PHP_INSTALLED_SAPIS@"
2223
ini_dir="@EXPANDED_PHP_CONFIG_FILE_SCAN_DIR@"
2324
ini_path="@EXPANDED_PHP_CONFIG_FILE_PATH@"
25+
php_embed_type="@PHP_EMBED_TYPE@"
2426

2527
# Set php_cli_binary and php_cgi_binary if available
2628
for sapi in $php_sapis; do
@@ -41,6 +43,13 @@ else
4143
php_binary="$php_cgi_binary"
4244
fi
4345

46+
# Set embed SAPI library path
47+
if test "$php_embed_type" = "shared"; then
48+
php_embed_lib=@SAPI_LIBNAME_SHARED@
49+
elif test "$php_embed_type" = "static"; then
50+
php_embed_lib=@SAPI_LIBNAME_STATIC@
51+
fi
52+
4453
# Remove quotes
4554
configure_options=`echo $configure_options | $SED -e "s#'##g"`
4655

@@ -57,6 +66,10 @@ case "$1" in
5766
echo $extension_dir;;
5867
--include-dir)
5968
echo $include_dir;;
69+
--lib-dir)
70+
echo $lib_dir;;
71+
--lib-embed)
72+
echo $php_embed_lib;;
6073
--php-binary)
6174
echo $php_binary;;
6275
--php-sapis)
@@ -83,6 +96,8 @@ Options:
8396
--libs [$libs]
8497
--extension-dir [$extension_dir]
8598
--include-dir [$include_dir]
99+
--lib-dir [$lib_dir]
100+
--lib-embed [$php_embed_lib]
86101
--man-dir [$man_dir]
87102
--php-binary [$php_binary]
88103
--php-sapis [$php_sapis]

0 commit comments

Comments
 (0)