From 0f840e973f9473797e23a6f3d700fa635aec3c63 Mon Sep 17 00:00:00 2001 From: Peter Kokot Date: Thu, 5 Sep 2024 20:47:23 +0200 Subject: [PATCH] Autotools: Refactor rt library check (#520) This appends the -lrt only as needed to the LIBS (if apcu is built as static) or to the APCU_SHARED_LIBADD variable (when APCu is built as shared). Modern *nix systems have shared memory operations located in default libraries and explicit linking with -lrt is redundant. --- config.m4 | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/config.m4 b/config.m4 index 47edf36..5682ca2 100644 --- a/config.m4 +++ b/config.m4 @@ -216,7 +216,12 @@ if test "$PHP_APCU" != "no"; then apc_iterator.c \ apc_persist.c" - PHP_CHECK_LIBRARY(rt, shm_open, [PHP_ADD_LIBRARY(rt,,APCU_SHARED_LIBADD)]) + LIBS_SAVED=$LIBS; LIBS= + AC_SEARCH_LIBS([shm_open], [rt]) + LIBS=$LIBS_SAVED + AS_CASE([$ac_cv_search_shm_open], ["none required"|no], [], + [PHP_EVAL_LIBLINE([$ac_cv_search_shm_open], [APCU_SHARED_LIBADD])]) + PHP_NEW_EXTENSION([apcu], [$apc_sources], [$ext_shared],, [$APCU_CFLAGS]) PHP_SUBST(APCU_SHARED_LIBADD) PHP_SUBST(PHP_LDFLAGS)