Skip to content

Commit 1108710

Browse files
authored
Autotools: Sync CS across the configure.ac (#15332)
- AS_* macros used where it makes it easier to read - Redundant double quotes removed (Autoconf and shell script don't need these on these places directly) - Overquoted arguments reduced in AC_RUN_IFELSE
1 parent e5f6387 commit 1108710

File tree

1 file changed

+45
-70
lines changed

1 file changed

+45
-70
lines changed

configure.ac

Lines changed: 45 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -281,16 +281,12 @@ AC_MSG_RESULT([$PHP_SAPI])
281281

282282
dnl Show which binaries were selected.
283283
AC_MSG_CHECKING([for executable SAPI binaries])
284-
if test "$PHP_BINARIES"; then
285-
AC_MSG_RESULT([$PHP_BINARIES])
286-
else
287-
AC_MSG_RESULT([none])
288-
fi
284+
AS_VAR_IF([PHP_BINARIES],,
285+
[AC_MSG_RESULT([none])],
286+
[AC_MSG_RESULT([$PHP_BINARIES])])
289287

290288
dnl Exit early.
291-
if test -z "$PHP_INSTALLED_SAPIS"; then
292-
AC_MSG_ERROR([Nothing to build.])
293-
fi
289+
AS_VAR_IF([PHP_INSTALLED_SAPIS],, [AC_MSG_ERROR([Nothing to build.])])
294290

295291
dnl Add POSIX threads compilation and linker flags when thread safety is enabled
296292
dnl with either the '--enable-zts' configure option or automatically enabled by
@@ -763,10 +759,8 @@ PHP_ARG_ENABLE([gcov],
763759
[no])
764760

765761
if test "$PHP_GCOV" = "yes"; then
766-
767-
if test "$GCC" != "yes"; then
768-
AC_MSG_ERROR([GCC is required for --enable-gcov])
769-
fi
762+
AS_VAR_IF([GCC], [yes],,
763+
[AC_MSG_ERROR([GNU C compatible compiler is required for --enable-gcov])])
770764

771765
dnl Check if ccache is being used.
772766
case `$php_shtool path $CC` in
@@ -877,14 +871,7 @@ PHP_ARG_WITH([layout],
877871
[PHP],
878872
[no])
879873

880-
case $PHP_LAYOUT in
881-
GNU)
882-
oldstyleextdir=no
883-
;;
884-
*)
885-
oldstyleextdir=yes
886-
;;
887-
esac
874+
AS_CASE([$PHP_LAYOUT], [GNU], [oldstyleextdir=no], [oldstyleextdir=yes])
888875

889876
PHP_ARG_WITH([config-file-path],
890877
[path to configuration file],
@@ -893,16 +880,10 @@ PHP_ARG_WITH([config-file-path],
893880
[DEFAULT],
894881
[no])
895882

896-
if test "$PHP_CONFIG_FILE_PATH" = "DEFAULT"; then
897-
case $PHP_LAYOUT in
898-
GNU)
899-
PHP_CONFIG_FILE_PATH=$sysconfdir
900-
;;
901-
*)
902-
PHP_CONFIG_FILE_PATH=$libdir
903-
;;
904-
esac
905-
fi
883+
AS_VAR_IF([PHP_CONFIG_FILE_PATH], [DEFAULT],
884+
[AS_CASE([$PHP_LAYOUT],
885+
[GNU], [PHP_CONFIG_FILE_PATH=$sysconfdir],
886+
[PHP_CONFIG_FILE_PATH=$libdir])])
906887

907888
AC_MSG_CHECKING([where to scan for configuration files])
908889
PHP_ARG_WITH([config-file-scan-dir],,
@@ -911,9 +892,7 @@ PHP_ARG_WITH([config-file-scan-dir],,
911892
[DEFAULT],
912893
[no])
913894

914-
if test "$PHP_CONFIG_FILE_SCAN_DIR" = "DEFAULT"; then
915-
PHP_CONFIG_FILE_SCAN_DIR=
916-
fi
895+
AS_VAR_IF([PHP_CONFIG_FILE_SCAN_DIR], [DEFAULT], [PHP_CONFIG_FILE_SCAN_DIR=])
917896
AC_MSG_RESULT([$PHP_CONFIG_FILE_SCAN_DIR])
918897

919898
PHP_ARG_ENABLE([sigchild],
@@ -936,14 +915,13 @@ PHP_ARG_ENABLE([libgcc],
936915
[no],
937916
[no])
938917

939-
if test "$PHP_LIBGCC" = "yes"; then
918+
AS_VAR_IF([PHP_LIBGCC], [yes], [
940919
PHP_LIBGCC_LIBPATH([gcc])
941-
if test -z "$libgcc_libpath"; then
942-
AC_MSG_ERROR([Cannot locate libgcc. Make sure that gcc is in your path])
943-
fi
920+
AS_VAR_IF([libgcc_libpath],,
921+
[AC_MSG_ERROR([Cannot locate libgcc. Make sure that gcc is in your path])])
944922
PHP_ADD_LIBPATH([$libgcc_libpath])
945923
PHP_ADD_LIBRARY([gcc], [yes])
946-
fi
924+
])
947925

948926
PHP_ARG_ENABLE([short-tags],
949927
[whether to enable short tags by default],
@@ -1028,16 +1006,14 @@ PHP_ARG_ENABLE([fd-setsize],,
10281006
[no],
10291007
[no])
10301008

1031-
if test "$PHP_FD_SETSIZE" != "no"; then
1009+
AS_VAR_IF([PHP_FD_SETSIZE], [no], [AC_MSG_RESULT([using system default])], [
10321010
if test "0$PHP_FD_SETSIZE" -gt 0 2>/dev/null; then
10331011
CPPFLAGS="$CPPFLAGS -DFD_SETSIZE=$PHP_FD_SETSIZE"
10341012
AC_MSG_RESULT([using $PHP_FD_SETSIZE])
10351013
else
10361014
AC_MSG_ERROR([Invalid value passed to --enable-fd-setsize!])
10371015
fi
1038-
else
1039-
AC_MSG_RESULT([using system default])
1040-
fi
1016+
])
10411017

10421018
PHP_ARG_ENABLE([werror],,
10431019
[AS_HELP_STRING([--enable-werror],
@@ -1356,28 +1332,23 @@ datadir=`eval eval echo $datadir`
13561332
dnl Build extension directory path.
13571333
ZEND_MODULE_API_NO=`$EGREP '#define ZEND_MODULE_API_NO ' $srcdir/Zend/zend_modules.h|"${SED}" 's/#define ZEND_MODULE_API_NO //'`
13581334

1359-
if test -z "$EXTENSION_DIR"; then
1335+
AS_VAR_IF([EXTENSION_DIR],, [
13601336
extbasedir=$ZEND_MODULE_API_NO
1361-
if test "$oldstyleextdir" = "yes"; then
1337+
AS_VAR_IF([oldstyleextdir], [yes], [
13621338
AS_VAR_IF([PHP_DEBUG], [1], [part1=debug], [part1=no-debug])
13631339
AS_VAR_IF([PHP_THREAD_SAFETY], [yes], [part2=zts], [part2=non-zts])
13641340
extbasedir=$part1-$part2-$extbasedir
13651341
EXTENSION_DIR=$libdir/extensions/$extbasedir
1366-
else
1342+
], [
13671343
AS_VAR_IF([PHP_THREAD_SAFETY], [yes], [extbasedir=$extbasedir-zts])
13681344
AS_VAR_IF([PHP_DEBUG], [1], [extbasedir=$extbasedir-debug])
13691345
EXTENSION_DIR=$libdir/$extbasedir
1370-
fi
1371-
fi
1346+
])
1347+
])
13721348

1373-
case $PHP_LAYOUT in
1374-
GNU)
1375-
datarootdir=$prefix/share
1376-
;;
1377-
*)
1378-
datarootdir=$prefix/php
1379-
;;
1380-
esac
1349+
AS_CASE([$PHP_LAYOUT],
1350+
[GNU], [datarootdir=$prefix/share],
1351+
[datarootdir=$prefix/php])
13811352

13821353
dnl Expand all directory names for use in macros/constants.
13831354
EXPANDED_PEAR_INSTALLDIR=`eval echo $PEAR_INSTALLDIR`
@@ -1504,23 +1475,23 @@ if test "$PHP_THREAD_SAFETY" = "yes" && test -n "$ac_cv_pthreads_cflags"; then
15041475
fi
15051476

15061477
dnl Enable -Werror late, because it may break configure checks throwing warnings.
1507-
if test "$PHP_WERROR" = "yes"; then
1478+
AS_VAR_IF([PHP_WERROR], [yes], [
15081479
CFLAGS="$CFLAGS -Werror"
15091480
CXXFLAGS="$CXXFLAGS -Werror"
1510-
fi
1481+
])
15111482

15121483
if test "$PHP_MEMORY_SANITIZER" = "yes" &&
15131484
test "$PHP_ADDRESS_SANITIZER" = "yes"; then
15141485
AC_MSG_ERROR([MemorySanitizer and AddressSanitizer are mutually exclusive])
15151486
fi
15161487

15171488
dnl Enable -fsanitize=memory late, because interceptors may break linking detection.
1518-
if test "$PHP_MEMORY_SANITIZER" = "yes"; then
1519-
AX_CHECK_COMPILE_FLAG([-fsanitize=memory -fsanitize-memory-track-origins], [
1489+
AS_VAR_IF([PHP_MEMORY_SANITIZER], [yes],
1490+
[AX_CHECK_COMPILE_FLAG([-fsanitize=memory -fsanitize-memory-track-origins], [
15201491
CFLAGS="$CFLAGS -fsanitize=memory -fsanitize-memory-track-origins"
15211492
CXXFLAGS="$CXXFLAGS -fsanitize=memory -fsanitize-memory-track-origins"
15221493
], [AC_MSG_ERROR([MemorySanitizer is not available])])
1523-
fi
1494+
])
15241495

15251496
AS_VAR_IF([PHP_ADDRESS_SANITIZER], [yes],
15261497
[AS_VAR_IF([PHP_VALGRIND], [no],, [AC_MSG_ERROR(m4_normalize([
@@ -1535,8 +1506,8 @@ AS_VAR_IF([PHP_ADDRESS_SANITIZER], [yes],
15351506
], [AC_MSG_ERROR([AddressSanitizer is not available])])
15361507
])
15371508

1538-
if test "$PHP_UNDEFINED_SANITIZER" = "yes"; then
1539-
AX_CHECK_COMPILE_FLAG([-fsanitize=undefined], [
1509+
AS_VAR_IF([PHP_UNDEFINED_SANITIZER], [yes],
1510+
[AX_CHECK_COMPILE_FLAG([-fsanitize=undefined], [
15401511
CFLAGS="$CFLAGS -fsanitize=undefined -fno-sanitize-recover=undefined"
15411512
CXXFLAGS="$CXXFLAGS -fsanitize=undefined -fno-sanitize-recover=undefined"
15421513
AX_CHECK_COMPILE_FLAG([-fno-sanitize=object-size], [
@@ -1548,23 +1519,27 @@ if test "$PHP_UNDEFINED_SANITIZER" = "yes"; then
15481519
15491520
dnl Clang 17 adds stricter function pointer compatibility checks where pointer args cannot be
15501521
dnl cast to void*. In that case, set -fno-sanitize=function.
1551-
OLD_CFLAGS="$CFLAGS"
1522+
OLD_CFLAGS=$CFLAGS
15521523
CFLAGS="$CFLAGS -fno-sanitize-recover=undefined"
1553-
AC_CACHE_CHECK([whether to add -fno-sanitize=function],[php_cv_ubsan_no_function],[
1554-
AC_RUN_IFELSE([AC_LANG_SOURCE([[
1524+
AC_CACHE_CHECK([whether to add -fno-sanitize=function],
1525+
[php_cv_ubsan_no_function],
1526+
[AC_RUN_IFELSE([AC_LANG_SOURCE([
15551527
void foo(char *string) {}
15561528
int main(void) {
15571529
void (*f)(void *) = (void (*)(void *))foo;
15581530
f("foo");
15591531
}
1560-
]])],[php_cv_ubsan_no_function=no],[php_cv_ubsan_no_function=yes],[php_cv_ubsan_no_function=no])])
1561-
CFLAGS="$OLD_CFLAGS"
1562-
if test "$php_cv_ubsan_no_function" = yes; then
1532+
])],
1533+
[php_cv_ubsan_no_function=no],
1534+
[php_cv_ubsan_no_function=yes],
1535+
[php_cv_ubsan_no_function=no])])
1536+
CFLAGS=$OLD_CFLAGS
1537+
AS_VAR_IF([php_cv_ubsan_no_function], [yes], [
15631538
CFLAGS="$CFLAGS -fno-sanitize=function"
15641539
CXXFLAGS="$CFLAGS -fno-sanitize=function"
1565-
fi
1540+
])
15661541
], [AC_MSG_ERROR([UndefinedBehaviorSanitizer is not available])])
1567-
fi
1542+
])
15681543

15691544
if test "$PHP_MEMORY_SANITIZER" = "yes" ||
15701545
test "$PHP_ADDRESS_SANITIZER" = "yes" ||

0 commit comments

Comments
 (0)