From d74c91a8a89476b54563524d6baba94cc1094a6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20R=C3=BChsen?= Date: Wed, 1 Jul 2026 00:03:08 +0200 Subject: [PATCH 1/4] Replace if/then/else with AS_IF --- configure.ac | 572 ++++++++++++++++++++++++++------------------------- 1 file changed, 292 insertions(+), 280 deletions(-) diff --git a/configure.ac b/configure.ac index 123b695..733f580 100644 --- a/configure.ac +++ b/configure.ac @@ -65,9 +65,9 @@ m4_ifdef([GTK_DOC_USE_LIBTOOL], [], [ AM_CONDITIONAL([GTK_DOC_USE_LIBTOOL], false) ]) -if test x"$have_gtk_doc" = xyes -a x"$enable_gtk_doc" = xyes; then +AS_IF([test "$have_gtk_doc" = yes && test "$enable_gtk_doc" = yes], [ AC_SUBST([LIBPSL_DOCS], [docs/libpsl]) -fi +]) # # enable creation of man pages @@ -75,15 +75,15 @@ fi AC_ARG_ENABLE([man], [AS_HELP_STRING([--enable-man], [generate man pages [default=auto]])], [ - if test "$enable_man" = yes; then + AS_IF([test "$enable_man" = yes], [ AC_PATH_PROG([XSLTPROC], [xsltproc]) AS_IF([test -z "$XSLTPROC"], [ AC_MSG_ERROR([xsltproc is required for --enable-man]) enable_man="no (xsltproc not found)" ]) - fi - ], [ enable_man=no ]) -AM_CONDITIONAL(ENABLE_MAN, test x$enable_man = xyes) + ]) + ], [enable_man=no]) +AM_CONDITIONAL([ENABLE_MAN], [test "$enable_man" = "yes"]) # src/psl-make-dafsa needs python 2.7+ AS_IF([! test -f src/suffixes_dafsa.h -a -f tests/psl.dafsa -a -f tests/psl_ascii.dafsa], @@ -95,43 +95,44 @@ PKG_PROG_PKG_CONFIG AC_ARG_ENABLE([fuzzing], [AS_HELP_STRING([--enable-fuzzing], [Turn on fuzzing build (for developers)])], - [enable_fuzzing=yes; - AC_SUBST([LIB_FUZZING_ENGINE]) - AC_DEFINE([FUZZING], 1, [Define to 1 if this is a fuzzing build]) + [ + enable_fuzzing=yes + AC_SUBST([LIB_FUZZING_ENGINE]) + AC_DEFINE([FUZZING], 1, [Define to 1 if this is a fuzzing build]) ], [enable_fuzzing=no; LIB_FUZZING_ENGINE=""]) AM_CONDITIONAL([FUZZING], [test "$enable_fuzzing" = "yes"]) AC_ARG_ENABLE([cfi], [AS_HELP_STRING([--enable-cfi], [Turn on clang's Control Flow Integrity (CFI)])], [ - if test "$enable_cfi" = yes; then - CFLAGS=$CFLAGS" -B/usr/bin/gold -fsanitize=cfi -flto -fvisibility=default -fno-sanitize-trap=all" + AS_IF([test "$enable_cfi" = yes], [ + CFLAGS="$CFLAGS -B/usr/bin/gold -fsanitize=cfi -flto -fvisibility=default -fno-sanitize-trap=all" AC_LINK_IFELSE([ AC_LANG_PROGRAM([], []) ], [], [ AC_MSG_ERROR([clang 3.7+ and the 'gold' linker are required for --enable-cfi]) ]) - fi - ], [ enable_cfi=no ]) + ]) + ], [enable_cfi=no]) AC_ARG_ENABLE([ubsan], [AS_HELP_STRING([--enable-ubsan], [Turn on Undefined Behavior Sanitizer (UBSan)])], [ - if test "$enable_ubsan" = yes; then + AS_IF([test "$enable_ubsan" = yes], [ # Set basic UBSAN compiler flags. Add your own to CFLAGS. - CFLAGS=$CFLAGS" -fsanitize=undefined -fno-sanitize-recover=undefined" - fi - ], [ enable_ubsan=no ]) + CFLAGS="$CFLAGS -fsanitize=undefined -fno-sanitize-recover=undefined" + ]) + ], [enable_ubsan=no]) AC_ARG_ENABLE([asan], [AS_HELP_STRING([--enable-asan], [Turn on Address Sanitizer (ASan)])], [ - if test "$enable_asan" = yes; then + AS_IF([test "$enable_asan" = yes], [ # Set basic ASAN compiler flags. Add your own to CFLAGS. - CFLAGS=$CFLAGS" -fsanitize=address -fno-omit-frame-pointer" + CFLAGS="$CFLAGS -fsanitize=address -fno-omit-frame-pointer" AX_CHECK_COMPILE_FLAG([-fsanitize-address-use-after-scope], [CFLAGS="$CFLAGS -fsanitize-address-use-after-scope"]) - fi - ], [ enable_asan=no ]) + ]) + ], [enable_asan=no]) # Define these substitutions here to keep all version information in one place. # For information on how to properly maintain the library version information, @@ -158,23 +159,18 @@ AC_ARG_ENABLE(runtime, libidn: IDNA2003 library (also needs libunistring) --disable-runtime Do not link runtime IDNA functionality ], [ - if test "$enableval" = "libidn2" -o "$enableval" = "yes"; then - enable_runtime=libidn2 - AC_DEFINE([WITH_LIBIDN2], [1], [generate PSL data using libidn2]) - elif test "$enableval" = "libicu"; then - enable_runtime=libicu - AC_DEFINE([WITH_LIBICU], [1], [generate PSL data using libicu]) - elif test "$enableval" = "libicucore"; then - enable_runtime=libicucore - AC_DEFINE([WITH_LIBICUCORE], [1], [generate PSL data using libicucore]) - elif test "$enableval" = "libidn"; then - enable_runtime=libidn - AC_DEFINE([WITH_LIBIDN], [1], [generate PSL data using libidn]) - elif test "$enableval" = "no"; then - enable_runtime=no - else - AC_MSG_ERROR([Unknown value $enableval for --enable-runtime]) - fi + AS_IF( + [test "$enableval" = "libidn2" -o "$enableval" = "yes"], + [enable_runtime=libidn2; AC_DEFINE([WITH_LIBIDN2], [1], [generate PSL data using libidn2])], + [test "$enableval" = "libicu"], + [enable_runtime=libicu; AC_DEFINE([WITH_LIBICU], [1], [generate PSL data using libicu])], + [test "$enableval" = "libicucore"], + [enable_runtime=libicucore; AC_DEFINE([WITH_LIBICUCORE], [1], [generate PSL data using libicucore])], + [test "$enableval" = "libidn"], + [enable_runtime=libidn; AC_DEFINE([WITH_LIBIDN], [1], [generate PSL data using libidn])], + [test "$enableval" = "no"], + [enable_runtime=no], + [AC_MSG_ERROR([Unknown value $enableval for --enable-runtime])] ) ], [ # this is the default if neither --enable-runtime nor --disable-runtime were specified enable_runtime=auto @@ -186,24 +182,22 @@ AC_ARG_ENABLE(builtin, --enable-builtin Generate built-in PSL data --disable-builtin Do not generate built-in PSL data ], [ - if test "$enableval" = "yes"; then - enable_builtin=yes - elif test "$enableval" = "libidn" -o "$enableval" = "libidn2" -o "$enableval" = "libicu"; then - AC_MSG_WARN([--enable-builtin=$enableval is deprecated, use --enable-builtin (enabled by default)]) - enable_builtin=yes - elif test "$enableval" = "no"; then - enable_builtin=no - else - AC_MSG_ERROR(Unknown value $enableval) - fi + AS_IF( + [test "$enableval" = "yes"], + [enable_builtin=yes], + [test "$enableval" = "libidn" -o "$enableval" = "libidn2" -o "$enableval" = "libicu"], + [AC_MSG_WARN([--enable-builtin=$enableval is deprecated, use --enable-builtin (enabled by default)]); enable_builtin=yes], + [test "$enableval" = "no"], + [enable_builtin=no], + [AC_MSG_ERROR(Unknown value $enableval)] ) ], [ # this is the default if neither --enable-builtin nor --disable-builtin were specified enable_builtin=yes ]) -if test "$enable_builtin" = "yes"; then +AS_IF([test "$enable_builtin" = "yes"], [ AC_DEFINE([ENABLE_BUILTIN], [1], [Generate built-in PSL data]) -fi +]) dnl Global project-specific compiler and linker flags. dnl @@ -221,7 +215,7 @@ AC_SUBST([AM_LDFLAGS]) dnl If we are building only static libraries, we need to define PSL_STATIC dnl when building psl executable; this is required on Windows since libpsl dnl uses __declspec(dllimport) by default. -AS_IF([test "x${enable_shared}" = "xno"], +AS_IF([test "${enable_shared}" = "no"], [AS_VAR_APPEND([AM_CPPFLAGS], [" -DPSL_STATIC"])]) dnl We use pkg-config/pkgconf to find dependencies. We want to ensure that we @@ -245,277 +239,285 @@ AC_SUBST([runtime_CFLAGS]) AC_SUBST([runtime_LIBS]) dnl Check for libicucore -if test "$enable_runtime" = "libicucore" || { test "$host_vendor" = "apple" -a "$enable_runtime" = "auto"; }; then - HAVE_LIBICUCORE=no +AS_IF( + [test "$enable_runtime" = "libicucore" || { test "$host_vendor" = "apple" -a "$enable_runtime" = "auto"; }], + [ + HAVE_LIBICUCORE=no - # Check if we can link against libicucore - AC_CHECK_LIB(icucore, uidna_openUTS46, [ - AC_CHECK_HEADER(unicode/uidna.h, [ - HAVE_LIBICUCORE=yes + # Check if we can link against libicucore + AC_CHECK_LIB(icucore, uidna_openUTS46, [ + AC_CHECK_HEADER(unicode/uidna.h, [ + HAVE_LIBICUCORE=yes + ]) ]) - ]) - if test "x$HAVE_LIBICUCORE" = "xyes"; then - runtime_LIBS="-licucore" + AS_IF([test "$HAVE_LIBICUCORE" = "yes"], [ + runtime_LIBS="-licucore" - if test "$enable_runtime" = "auto"; then - enable_runtime=libicucore - AC_DEFINE([WITH_LIBICUCORE], [1], [generate PSL data using libicucore]) - fi - else - if test "$enable_runtime" = "libicucore"; then + AS_IF([test "$enable_runtime" = "auto"], [ + enable_runtime=libicucore + AC_DEFINE([WITH_LIBICUCORE], [1], [generate PSL data using libicucore]) + ]) + ], + [test "$enable_runtime" = "libicucore"], [ AC_MSG_ERROR([You requested libicucore but it is not available or usable.]) - fi - fi -fi + ]) + ]) -dnl Check for libidn2 -if test "$enable_runtime" = "libidn2" -o "$enable_runtime" = "auto"; then - HAVE_LIBIDN2=no - # Save CFLAGS and LIBS so we can restore them later - __save_CFLAGS=$CFLAGS - __save_LIBS=$LIBS +dnl Check for libidn2 +AS_IF( + [test "$enable_runtime" = "libidn2" -o "$enable_runtime" = "auto"], + [ + HAVE_LIBIDN2=no - m4_define([LIBIDN2_LINK_TEST], [AC_LANG_PROGRAM( - [extern char idn2_lookup_u8 (void);], - [idn2_lookup_u8();] - )]) + # Save CFLAGS and LIBS so we can restore them later + __save_CFLAGS=$CFLAGS + __save_LIBS=$LIBS - PKG_CHECK_MODULES([LIBIDN2], [libidn2], [HAVE_LIBIDN2=maybe], [HAVE_LIBIDN2=no]) + m4_define([LIBIDN2_LINK_TEST], [AC_LANG_PROGRAM( + [extern char idn2_lookup_u8 (void);], + [idn2_lookup_u8();] + )]) - # Check if we can link against libidn2 - AS_IF([test "x$HAVE_LIBIDN2" = xmaybe], [ - CFLAGS="$LIBIDN2_CFLAGS $CFLAGS" - LIBS="$LIBIDN2_LIBS $LIBS" - AC_LINK_IFELSE([ - LIBIDN2_LINK_TEST - ], [ - HAVE_LIBIDN2=yes - ], [ - AC_MSG_NOTICE([located libidn2 but cannot link... trying static linking]) - LIBIDN2_CFLAGS= - LIBIDN2_LIBS= - CFLAGS=$__save_CFLAGS - LIBS=$__save_LIBS - ]) - ]) + PKG_CHECK_MODULES([LIBIDN2], [libidn2], [HAVE_LIBIDN2=maybe], [HAVE_LIBIDN2=no]) - # If we cannot link against found libidn2, try static linking - AS_IF([test "x$HAVE_LIBIDN2" = xmaybe], [ - PKG_CHECK_MODULES_STATIC([LIBIDN2], [libidn2], [ + # Check if we can link against libidn2 + AS_IF([test "$HAVE_LIBIDN2" = maybe], [ CFLAGS="$LIBIDN2_CFLAGS $CFLAGS" LIBS="$LIBIDN2_LIBS $LIBS" AC_LINK_IFELSE([ LIBIDN2_LINK_TEST ], [ HAVE_LIBIDN2=yes - AC_MSG_NOTICE([using static libidn2]) ], [ - HAVE_LIBIDN2=no - AC_MSG_NOTICE([libidn2 is installed but unusable]) + AC_MSG_NOTICE([located libidn2 but cannot link... trying static linking]) LIBIDN2_CFLAGS= LIBIDN2_LIBS= CFLAGS=$__save_CFLAGS LIBS=$__save_LIBS ]) - ], [ - HAVE_LIBIDN2=no ]) - ]) - CFLAGS=$__save_CFLAGS - LIBS=$__save_LIBS - - if test "x$HAVE_LIBIDN2" = "xyes"; then - runtime_CFLAGS=$LIBIDN2_CFLAGS - runtime_LIBS=$LIBIDN2_LIBS + # If we cannot link against found libidn2, try static linking + AS_IF([test "$HAVE_LIBIDN2" = maybe], [ + PKG_CHECK_MODULES_STATIC([LIBIDN2], [libidn2], [ + CFLAGS="$LIBIDN2_CFLAGS $CFLAGS" + LIBS="$LIBIDN2_LIBS $LIBS" + AC_LINK_IFELSE([ + LIBIDN2_LINK_TEST + ], [ + HAVE_LIBIDN2=yes + AC_MSG_NOTICE([using static libidn2]) + ], [ + HAVE_LIBIDN2=no + AC_MSG_NOTICE([libidn2 is installed but unusable]) + LIBIDN2_CFLAGS= + LIBIDN2_LIBS= + CFLAGS=$__save_CFLAGS + LIBS=$__save_LIBS + ]) + ], [ + HAVE_LIBIDN2=no + ]) + ]) - if test "$enable_runtime" = "auto"; then - enable_runtime=libidn2 - AC_DEFINE([WITH_LIBIDN2], [1], [generate PSL data using libidn2]) - fi - else - if test "$enable_runtime" = "libidn2"; then - AC_MSG_ERROR([You requested libidn2 but it is not installed or usable.]) - fi - fi -fi + CFLAGS=$__save_CFLAGS + LIBS=$__save_LIBS -dnl Check for libicu -if test "$enable_runtime" = "libicu" -o "$enable_runtime" = "auto"; then - HAVE_LIBICU=no - # Whether we found libicu using pkg-config - HAVE_LIBICU_PC=no + AS_IF([test "$HAVE_LIBIDN2" = "yes"], [ + runtime_CFLAGS=$LIBIDN2_CFLAGS + runtime_LIBS=$LIBIDN2_LIBS - # Save CFLAGS and LIBS so we can restore them later - __save_CFLAGS=$CFLAGS - __save_LIBS=$LIBS + AS_IF([test "$enable_runtime" = "auto"], [ + enable_runtime=libidn2 + AC_DEFINE([WITH_LIBIDN2], [1], [generate PSL data using libidn2]) + ]) + ], + [test "$enable_runtime" = "libidn2"], [ + AC_MSG_ERROR([You requested libidn2 but it is not installed or usable.]) + ]) + ]) - m4_define([ICU_LINK_TEST], [AC_LANG_PROGRAM( - [[#include ]], - [[u_strToUTF8(NULL, 0, NULL, NULL, 0, NULL);]] - )]) - # using pkg-config won't work on older systems like Ubuntu 12.04 LTS Server Edition 64bit - # using AC_SEARCH_LIBS also don't work since functions have the library version appended - PKG_CHECK_MODULES([LIBICU], [icu-uc], [ - HAVE_LIBICU_PC=yes - HAVE_LIBICU=maybe - ], [ +dnl Check for libicu +AS_IF( + [test "$enable_runtime" = "libicu" -o "$enable_runtime" = "auto"], + [ HAVE_LIBICU=no - ]) - - # Check if we can link against libicu - AS_IF([test "x$HAVE_LIBICU" = xmaybe], [ - CFLAGS="$LIBICU_CFLAGS $CFLAGS" - LIBS="$LIBICU_LIBS $LIBS" - AC_LINK_IFELSE([ - ICU_LINK_TEST - ], [ - HAVE_LIBICU=yes + # Whether we found libicu using pkg-config + HAVE_LIBICU_PC=no + + # Save CFLAGS and LIBS so we can restore them later + __save_CFLAGS=$CFLAGS + __save_LIBS=$LIBS + + m4_define([ICU_LINK_TEST], [AC_LANG_PROGRAM( + [[#include ]], + [[u_strToUTF8(NULL, 0, NULL, NULL, 0, NULL);]] + )]) + + # using pkg-config won't work on older systems like Ubuntu 12.04 LTS Server Edition 64bit + # using AC_SEARCH_LIBS also don't work since functions have the library version appended + PKG_CHECK_MODULES([LIBICU], [icu-uc], [ + HAVE_LIBICU_PC=yes + HAVE_LIBICU=maybe ], [ - AC_MSG_NOTICE([located libicu but cannot link... trying static linking]) - LIBICU_CFLAGS= - LIBICU_LIBS= - CFLAGS=$__save_CFLAGS - LIBS=$__save_LIBS + HAVE_LIBICU=no ]) - ]) - # If we cannot link against found libicu, try static linking - AS_IF([test "x$HAVE_LIBICU" = xmaybe], [ - PKG_CHECK_MODULES_STATIC([LIBICU], [icu-uc], [ + # Check if we can link against libicu + AS_IF([test "$HAVE_LIBICU" = maybe], [ CFLAGS="$LIBICU_CFLAGS $CFLAGS" LIBS="$LIBICU_LIBS $LIBS" AC_LINK_IFELSE([ ICU_LINK_TEST ], [ HAVE_LIBICU=yes - AC_MSG_NOTICE([using static libicu]) ], [ - HAVE_LIBICU_PC=no - HAVE_LIBICU=no - AC_MSG_NOTICE([libicu is installed but unusable]) + AC_MSG_NOTICE([located libicu but cannot link... trying static linking]) LIBICU_CFLAGS= LIBICU_LIBS= CFLAGS=$__save_CFLAGS LIBS=$__save_LIBS ]) - ], [ - HAVE_LIBICU=no ]) - ]) - # Try -licuuc - AS_IF([test "x$HAVE_LIBICU" = xno], [ - AC_MSG_CHECKING([for ICU unicode library]) - LIBS="-licuuc $LIBS" - AC_LINK_IFELSE([ - ICU_LINK_TEST - ], [ - HAVE_LIBICU=yes - LIBICU_LIBS='-licuuc' - ], [ - HAVE_LIBICU=no - LIBS=$__save_LIBS + # If we cannot link against found libicu, try static linking + AS_IF([test "$HAVE_LIBICU" = maybe], [ + PKG_CHECK_MODULES_STATIC([LIBICU], [icu-uc], [ + CFLAGS="$LIBICU_CFLAGS $CFLAGS" + LIBS="$LIBICU_LIBS $LIBS" + AC_LINK_IFELSE([ + ICU_LINK_TEST + ], [ + HAVE_LIBICU=yes + AC_MSG_NOTICE([using static libicu]) + ], [ + HAVE_LIBICU_PC=no + HAVE_LIBICU=no + AC_MSG_NOTICE([libicu is installed but unusable]) + LIBICU_CFLAGS= + LIBICU_LIBS= + CFLAGS=$__save_CFLAGS + LIBS=$__save_LIBS + ]) + ], [ + HAVE_LIBICU=no + ]) ]) - AC_MSG_RESULT([$HAVE_LIBICU]) - ]) - CFLAGS=$__save_CFLAGS - LIBS=$__save_LIBS + # Try -licuuc + AS_IF([test "$HAVE_LIBICU" = no], [ + AC_MSG_CHECKING([for ICU unicode library]) + LIBS="-licuuc $LIBS" + AC_LINK_IFELSE([ + ICU_LINK_TEST + ], [ + HAVE_LIBICU=yes + LIBICU_LIBS='-licuuc' + ], [ + HAVE_LIBICU=no + LIBS=$__save_LIBS + ]) + AC_MSG_RESULT([$HAVE_LIBICU]) + ]) + + CFLAGS=$__save_CFLAGS + LIBS=$__save_LIBS - if test "x$HAVE_LIBICU" = "xyes"; then - runtime_CFLAGS=$LIBICU_CFLAGS - runtime_LIBS=$LIBICU_LIBS + AS_IF([test "$HAVE_LIBICU" = "yes"], [ + runtime_CFLAGS=$LIBICU_CFLAGS + runtime_LIBS=$LIBICU_LIBS - if test "$enable_runtime" = "auto"; then - enable_runtime=libicu - AC_DEFINE([WITH_LIBICU], [1], [generate PSL data using libicu]) - fi - else - if test "$enable_runtime" = "libicu"; then + AS_IF([test "$enable_runtime" = "auto"], [ + enable_runtime=libicu + AC_DEFINE([WITH_LIBICU], [1], [generate PSL data using libicu]) + ]) + ], + [test "$enable_runtime" = "libicu"], [ AC_MSG_ERROR([You requested libicu but it is not installed or usable.]) - fi - fi -fi + ]) + ]) -dnl Checl for libidn -if test "$enable_runtime" = "libidn"; then - HAVE_LIBIDN=no - # Save CFLAGS and LIBS so we can restore them later - __save_CFLAGS=$CFLAGS - __save_LIBS=$LIBS +dnl Check for libidn +AS_IF( + [test "$enable_runtime" = "libidn"], + [ + HAVE_LIBIDN=no - m4_define([LIBIDN_LINK_TEST], [AC_LANG_PROGRAM( - [extern char idna_to_ascii_8z (void);], - [idna_to_ascii_8z();] - )]) + # Save CFLAGS and LIBS so we can restore them later + __save_CFLAGS=$CFLAGS + __save_LIBS=$LIBS - PKG_CHECK_MODULES([LIBIDN], [libidn], [HAVE_LIBIDN=maybe], [HAVE_LIBIDN=no]) + m4_define([LIBIDN_LINK_TEST], [AC_LANG_PROGRAM( + [extern char idna_to_ascii_8z (void);], + [idna_to_ascii_8z();] + )]) - # Check if we can link against libidn - AS_IF([test "x$HAVE_LIBIDN" = xmaybe], [ - CFLAGS="$LIBIDN_CFLAGS $CFLAGS" - LIBS="$LIBIDN_LIBS $LIBS" - AC_LINK_IFELSE([ - LIBIDN_LINK_TEST - ], [ - HAVE_LIBIDN=yes - ], [ - AC_MSG_NOTICE([located libidn but cannot link... trying static linking]) - LIBIDN_CFLAGS= - LIBIDN_LIBS= - CFLAGS=$__save_CFLAGS - LIBS=$__save_LIBS - ]) - ]) + PKG_CHECK_MODULES([LIBIDN], [libidn], [HAVE_LIBIDN=maybe], [HAVE_LIBIDN=no]) - # If we cannot link against found libidn, try static linking - AS_IF([test "x$HAVE_LIBIDN" = xmaybe], [ - PKG_CHECK_MODULES_STATIC([LIBIDN], [libidn], [ + # Check if we can link against libidn + AS_IF([test "$HAVE_LIBIDN" = maybe], [ CFLAGS="$LIBIDN_CFLAGS $CFLAGS" LIBS="$LIBIDN_LIBS $LIBS" AC_LINK_IFELSE([ LIBIDN_LINK_TEST ], [ HAVE_LIBIDN=yes - AC_MSG_NOTICE([using static libidn]) ], [ - HAVE_LIBIDN=no - AC_MSG_NOTICE([libidn is installed but unusable]) + AC_MSG_NOTICE([located libidn but cannot link... trying static linking]) LIBIDN_CFLAGS= LIBIDN_LIBS= CFLAGS=$__save_CFLAGS LIBS=$__save_LIBS ]) - ], [ - HAVE_LIBIDN=no ]) - ]) - CFLAGS=$__save_CFLAGS - LIBS=$__save_LIBS + # If we cannot link against found libidn, try static linking + AS_IF([test "$HAVE_LIBIDN" = maybe], [ + PKG_CHECK_MODULES_STATIC([LIBIDN], [libidn], [ + CFLAGS="$LIBIDN_CFLAGS $CFLAGS" + LIBS="$LIBIDN_LIBS $LIBS" + AC_LINK_IFELSE([ + LIBIDN_LINK_TEST + ], [ + HAVE_LIBIDN=yes + AC_MSG_NOTICE([using static libidn]) + ], [ + HAVE_LIBIDN=no + AC_MSG_NOTICE([libidn is installed but unusable]) + LIBIDN_CFLAGS= + LIBIDN_LIBS= + CFLAGS=$__save_CFLAGS + LIBS=$__save_LIBS + ]) + ], [ + HAVE_LIBIDN=no + ]) + ]) + + CFLAGS=$__save_CFLAGS + LIBS=$__save_LIBS - if test "x$HAVE_LIBIDN" = "xyes"; then - runtime_CFLAGS=$LIBIDN_CFLAGS - runtime_LIBS=$LIBIDN_LIBS - else - if test "$enable_runtime" = "libidn"; then + AS_IF([test "$HAVE_LIBIDN" = "yes"], [ + runtime_CFLAGS=$LIBIDN_CFLAGS + runtime_LIBS=$LIBIDN_LIBS + ], + [test "$enable_runtime" = "libidn"], [ AC_MSG_ERROR([You requested libidn but it is not installed or usable.]) - fi - fi -fi + ]) + ]) + # last fallback is noruntime/nobuiltin -if test "$enable_runtime" = "auto"; then - enable_runtime=no -fi +AS_IF([test "$enable_runtime" = "auto"], [enable_runtime=no]) dnl If we use libidn or libidn2, we also need libiconv and libunistring. libicucore also needs iconv -if test "x$enable_runtime" = "xlibidn2" -o "x$enable_runtime" = "xlibidn" -o "x$enable_runtime" = "xlibicucore"; then +AS_IF( + [test "$enable_runtime" = "libidn2" -o "$enable_runtime" = "libidn" -o "$enable_runtime" = "libicucore"], + [ __save_LIBS=$LIBS LIBS=$LIBICONV @@ -527,23 +529,24 @@ if test "x$enable_runtime" = "xlibidn2" -o "x$enable_runtime" = "xlibidn" -o "x$ LIBS=$__save_LIBS runtime_LIBS="$runtime_LIBS $LTLIBICONV" - if test "x$enable_runtime" != "xlibicucore"; then - LIBS=$LIBUNISTRING - AC_LINK_IFELSE([ - AC_LANG_PROGRAM([char u8_tolower (void);], [u8_tolower ();]) - ], [:], [ - AC_MSG_ERROR([You requested libidn2|libidn but libunistring is not installed.]) + AS_IF([test "$enable_runtime" != "libicucore"], [ + LIBS=$LIBUNISTRING + AC_LINK_IFELSE([ + AC_LANG_PROGRAM([char u8_tolower (void);], [u8_tolower ();]) + ], [:], [ + AC_MSG_ERROR([You requested libidn2|libidn but libunistring is not installed.]) + ]) + LIBS=$__save_LIBS + runtime_LIBS="$runtime_LIBS $LTLIBUNISTRING" ]) - LIBS=$__save_LIBS - runtime_LIBS="$runtime_LIBS $LTLIBUNISTRING" - fi -fi + ]) -AM_CONDITIONAL([WITH_LIBICU], test "x$enable_runtime" = "xlibicu") -AM_CONDITIONAL([WITH_LIBICUCORE], test "x$enable_runtime" = "xlibicucore") -AM_CONDITIONAL([WITH_LIBIDN2], test "x$enable_runtime" = "xlibidn2") -AM_CONDITIONAL([WITH_LIBIDN], test "x$enable_runtime" = "xlibidn") -AM_CONDITIONAL([ENABLE_BUILTIN], test "x$enable_builtin" = "xyes") + +AM_CONDITIONAL([WITH_LIBICU], test "$enable_runtime" = "libicu") +AM_CONDITIONAL([WITH_LIBICUCORE], test "$enable_runtime" = "libicucore") +AM_CONDITIONAL([WITH_LIBIDN2], test "$enable_runtime" = "libidn2") +AM_CONDITIONAL([WITH_LIBIDN], test "$enable_runtime" = "libidn") +AM_CONDITIONAL([ENABLE_BUILTIN], test "$enable_builtin" = "yes") dnl libpsl.pc libpsl_pc_Cflags= @@ -553,22 +556,31 @@ libpsl_pc_Libs_private= libpsl_pc_Requires= libpsl_pc_Requires_private= -if test "$enable_runtime" = libidn2; then - libpsl_pc_Libs_private="$LTLIBUNISTRING $LTLIBICONV $LIBS" - libpsl_pc_Requires_private=libidn2 -elif test "$enable_runtime" = libidn; then - libpsl_pc_Libs_private="$LTLIBUNISTRING $LTLIBICONV $LIBS" - libpsl_pc_Requires_private=libidn -elif test "$enable_runtime" = libicu; then - if test "x$HAVE_LIBICU_PC" = xyes; then - libpsl_pc_Libs_private="$LIBS" - libpsl_pc_Requires_private=icu-uc - else - libpsl_pc_Libs_private="$LIBICU_LIBS $LIBS" - fi -elif test "$enable_runtime" = libicucore; then - libpsl_pc_Libs_private="-licucore $LTLIBICONV $LIBS" -fi +AS_IF( + [test "$enable_runtime" = libidn2], + [ + libpsl_pc_Libs_private="$LTLIBUNISTRING $LTLIBICONV $LIBS" + libpsl_pc_Requires_private=libidn2 + ], + [test "$enable_runtime" = libidn], + [ + libpsl_pc_Libs_private="$LTLIBUNISTRING $LTLIBICONV $LIBS" + libpsl_pc_Requires_private=libidn + ], + [test "$enable_runtime" = libicu], + [ + AS_IF([test "$HAVE_LIBICU_PC" = yes], [ + libpsl_pc_Libs_private="$LIBS" + libpsl_pc_Requires_private=icu-uc + ], [ + libpsl_pc_Libs_private="$LIBICU_LIBS $LIBS" + ]) + ], + [test "$enable_runtime" = libicucore], + [ + libpsl_pc_Libs_private="-licucore $LTLIBICONV $LIBS" + ]) + dnl On Windows we use pkgconf-specific Cflags.private to pass -DPSL_STATIC AS_CASE([${host}], @@ -593,18 +605,18 @@ AC_ARG_ENABLE(valgrind-tests, [ac_enable_valgrind=$enableval], [ac_enable_valgrind=no]) -if test "${ac_enable_valgrind}" = "yes" ; then +AS_IF([test "${ac_enable_valgrind}" = "yes"], [ AC_CHECK_PROG(HAVE_VALGRIND, valgrind, yes, no) - if test "$HAVE_VALGRIND" = "yes" ; then + AS_IF([test "$HAVE_VALGRIND" = "yes"], [ VALGRIND_ENVIRONMENT="valgrind --error-exitcode=1 --leak-check=yes --show-reachable=yes --track-origins=yes" AC_SUBST(VALGRIND_ENVIRONMENT) TESTS_INFO="Test suite will be run under Valgrind" - else + ], [ TESTS_INFO="Valgrind not found" - fi -else + ]) +], [ TESTS_INFO="Valgrind testing not enabled" -fi +]) # Check for distribution-wide PSL file AC_ARG_WITH(psl-distfile, From d02f18c88d501ee18073935223b6350f735c03b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20R=C3=BChsen?= Date: Tue, 30 Jun 2026 23:38:51 +0200 Subject: [PATCH 2/4] Replace # with dnl in configure.ac --- configure.ac | 115 +++++++++++++++++++++++++-------------------------- 1 file changed, 57 insertions(+), 58 deletions(-) diff --git a/configure.ac b/configure.ac index 733f580..cafcde5 100644 --- a/configure.ac +++ b/configure.ac @@ -4,13 +4,12 @@ AC_PREREQ([2.59]) AC_CONFIG_AUX_DIR([build-aux]) AM_INIT_AUTOMAKE([1.10 no-define foreign dist-lzip]) -# Generate two configuration headers; one for building the library itself with -# an autogenerated template, and a second one that will be installed alongside -# the library. +dnl Generate two configuration headers; one for building the library itself with +dnl an autogenerated template, and a second one that will be installed alongside +dnl the library. AC_CONFIG_HEADERS([config.h]) AC_PROG_CC m4_ifdef([AM_PROG_AR], [AM_PROG_AR]) -#LT_INIT([disable-static]) LT_INIT([win32-dll]) AC_CONFIG_MACRO_DIR([m4]) m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) @@ -36,31 +35,31 @@ AM_ICONV dnl Unicode support gl_LIBUNISTRING -# -# Generate version defines for include file -# +dnl +dnl Generate version defines for include file +dnl AC_SUBST([LIBPSL_VERSION_MAJOR], [`echo $VERSION|cut -d'.' -f1`]) AC_SUBST([LIBPSL_VERSION_MINOR], [`echo $VERSION|cut -d'.' -f2`]) AC_SUBST([LIBPSL_VERSION_PATCH], [`echo $VERSION|cut -d'.' -f3`]) AC_SUBST([LIBPSL_VERSION_NUMBER], [`printf '0x%02x%02x%02x' $LIBPSL_VERSION_MAJOR $LIBPSL_VERSION_MINOR $LIBPSL_VERSION_PATCH`]) AC_CONFIG_FILES([include/libpsl.h]) -# -# Gettext -# +dnl +dnl Gettext +dnl AM_GNU_GETTEXT([external],[need-ngettext]) AM_GNU_GETTEXT_VERSION([0.19.3]) AM_GNU_GETTEXT_REQUIRE_VERSION([0.19.3]) -# -# check for gtk-doc -# +dnl +dnl check for gtk-doc +dnl m4_ifdef([GTK_DOC_CHECK], [ GTK_DOC_CHECK([1.15],[--flavour no-tmpl]) ],[ AM_CONDITIONAL([ENABLE_GTK_DOC], false) ]) -# needed for some older versions of gtk-doc +dnl needed for some older versions of gtk-doc m4_ifdef([GTK_DOC_USE_LIBTOOL], [], [ AM_CONDITIONAL([GTK_DOC_USE_LIBTOOL], false) ]) @@ -69,9 +68,9 @@ AS_IF([test "$have_gtk_doc" = yes && test "$enable_gtk_doc" = yes], [ AC_SUBST([LIBPSL_DOCS], [docs/libpsl]) ]) -# -# enable creation of man pages -# +dnl +dnl enable creation of man pages +dnl AC_ARG_ENABLE([man], [AS_HELP_STRING([--enable-man], [generate man pages [default=auto]])], [ @@ -85,7 +84,7 @@ AC_ARG_ENABLE([man], ], [enable_man=no]) AM_CONDITIONAL([ENABLE_MAN], [test "$enable_man" = "yes"]) -# src/psl-make-dafsa needs python 2.7+ +dnl src/psl-make-dafsa needs python 2.7+ AS_IF([! test -f src/suffixes_dafsa.h -a -f tests/psl.dafsa -a -f tests/psl_ascii.dafsa], [ AM_PATH_PYTHON([2.7],, [AC_MSG_ERROR([python 2.7+ is required to convert the PSL data])]) @@ -119,7 +118,7 @@ AC_ARG_ENABLE([ubsan], [AS_HELP_STRING([--enable-ubsan], [Turn on Undefined Behavior Sanitizer (UBSan)])], [ AS_IF([test "$enable_ubsan" = yes], [ - # Set basic UBSAN compiler flags. Add your own to CFLAGS. + dnl Set basic UBSAN compiler flags. Add your own to CFLAGS. CFLAGS="$CFLAGS -fsanitize=undefined -fno-sanitize-recover=undefined" ]) ], [enable_ubsan=no]) @@ -128,27 +127,27 @@ AC_ARG_ENABLE([asan], [AS_HELP_STRING([--enable-asan], [Turn on Address Sanitizer (ASan)])], [ AS_IF([test "$enable_asan" = yes], [ - # Set basic ASAN compiler flags. Add your own to CFLAGS. + dnl Set basic ASAN compiler flags. Add your own to CFLAGS. CFLAGS="$CFLAGS -fsanitize=address -fno-omit-frame-pointer" AX_CHECK_COMPILE_FLAG([-fsanitize-address-use-after-scope], [CFLAGS="$CFLAGS -fsanitize-address-use-after-scope"]) ]) ], [enable_asan=no]) -# Define these substitutions here to keep all version information in one place. -# For information on how to properly maintain the library version information, -# refer to the libtool manual, section "Updating library version information": -# https://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html -# -# 1. Start with version information of ‘0:0:0’ for each libtool library. -# 2. Update the version information only immediately before a public release of your software. More frequent updates are unnecessary, and only guarantee that the current interface number gets larger faster. -# 3. If the library source code has changed at all since the last update, then increment revision (‘c:r:a’ becomes ‘c:r+1:a’). -# 4. If any interfaces have been added, removed, or changed since the last update, increment current, and set revision to 0. -# 5. If any interfaces have been added since the last public release, then increment age. -# 6. If any existing interfaces have been removed or changed since the last public release, then set age to 0. +dnl Define these substitutions here to keep all version information in one place. +dnl For information on how to properly maintain the library version information, +dnl refer to the libtool manual, section "Updating library version information": +dnl https://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html +dnl +dnl 1. Start with version information of '0:0:0' for each libtool library. +dnl 2. Update the version information only immediately before a public release of your software. More frequent updates are unnecessary, and only guarantee that the current interface number gets larger faster. +dnl 3. If the library source code has changed at all since the last update, then increment revision ('c:r:a' becomes 'c:r+1:a'). +dnl 4. If any interfaces have been added, removed, or changed since the last update, increment current, and set revision to 0. +dnl 5. If any interfaces have been added since the last public release, then increment age. +dnl 6. If any existing interfaces have been removed or changed since the last public release, then set age to 0. AC_SUBST([LIBPSL_SO_VERSION], m4_normalize(m4_include([libtool_version_info.txt]))) AC_SUBST([LIBPSL_VERSION], $VERSION) -# Check for enable/disable runtime PSL data +dnl Check for enable/disable runtime PSL data AC_ARG_ENABLE(runtime, [ --enable-runtime[[=IDNA library]] @@ -172,11 +171,11 @@ AC_ARG_ENABLE(runtime, [enable_runtime=no], [AC_MSG_ERROR([Unknown value $enableval for --enable-runtime])] ) ], [ - # this is the default if neither --enable-runtime nor --disable-runtime were specified + dnl this is the default if neither --enable-runtime nor --disable-runtime were specified enable_runtime=auto ]) -# Check for enable/disable builtin PSL data +dnl Check for enable/disable builtin PSL data AC_ARG_ENABLE(builtin, [ --enable-builtin Generate built-in PSL data @@ -191,7 +190,7 @@ AC_ARG_ENABLE(builtin, [enable_builtin=no], [AC_MSG_ERROR(Unknown value $enableval)] ) ], [ - # this is the default if neither --enable-builtin nor --disable-builtin were specified + dnl this is the default if neither --enable-builtin nor --disable-builtin were specified enable_builtin=yes ]) @@ -244,7 +243,7 @@ AS_IF( [ HAVE_LIBICUCORE=no - # Check if we can link against libicucore + dnl Check if we can link against libicucore AC_CHECK_LIB(icucore, uidna_openUTS46, [ AC_CHECK_HEADER(unicode/uidna.h, [ HAVE_LIBICUCORE=yes @@ -271,7 +270,7 @@ AS_IF( [ HAVE_LIBIDN2=no - # Save CFLAGS and LIBS so we can restore them later + dnl Save CFLAGS and LIBS so we can restore them later __save_CFLAGS=$CFLAGS __save_LIBS=$LIBS @@ -282,7 +281,7 @@ AS_IF( PKG_CHECK_MODULES([LIBIDN2], [libidn2], [HAVE_LIBIDN2=maybe], [HAVE_LIBIDN2=no]) - # Check if we can link against libidn2 + dnl Check if we can link against libidn2 AS_IF([test "$HAVE_LIBIDN2" = maybe], [ CFLAGS="$LIBIDN2_CFLAGS $CFLAGS" LIBS="$LIBIDN2_LIBS $LIBS" @@ -299,7 +298,7 @@ AS_IF( ]) ]) - # If we cannot link against found libidn2, try static linking + dnl If we cannot link against found libidn2, try static linking AS_IF([test "$HAVE_LIBIDN2" = maybe], [ PKG_CHECK_MODULES_STATIC([LIBIDN2], [libidn2], [ CFLAGS="$LIBIDN2_CFLAGS $CFLAGS" @@ -345,10 +344,10 @@ AS_IF( [test "$enable_runtime" = "libicu" -o "$enable_runtime" = "auto"], [ HAVE_LIBICU=no - # Whether we found libicu using pkg-config + dnl Whether we found libicu using pkg-config HAVE_LIBICU_PC=no - # Save CFLAGS and LIBS so we can restore them later + dnl Save CFLAGS and LIBS so we can restore them later __save_CFLAGS=$CFLAGS __save_LIBS=$LIBS @@ -357,8 +356,8 @@ AS_IF( [[u_strToUTF8(NULL, 0, NULL, NULL, 0, NULL);]] )]) - # using pkg-config won't work on older systems like Ubuntu 12.04 LTS Server Edition 64bit - # using AC_SEARCH_LIBS also don't work since functions have the library version appended + dnl using pkg-config won't work on older systems like Ubuntu 12.04 LTS Server Edition 64bit + dnl using AC_SEARCH_LIBS also don't work since functions have the library version appended PKG_CHECK_MODULES([LIBICU], [icu-uc], [ HAVE_LIBICU_PC=yes HAVE_LIBICU=maybe @@ -366,7 +365,7 @@ AS_IF( HAVE_LIBICU=no ]) - # Check if we can link against libicu + dnl Check if we can link against libicu AS_IF([test "$HAVE_LIBICU" = maybe], [ CFLAGS="$LIBICU_CFLAGS $CFLAGS" LIBS="$LIBICU_LIBS $LIBS" @@ -383,7 +382,7 @@ AS_IF( ]) ]) - # If we cannot link against found libicu, try static linking + dnl If we cannot link against found libicu, try static linking AS_IF([test "$HAVE_LIBICU" = maybe], [ PKG_CHECK_MODULES_STATIC([LIBICU], [icu-uc], [ CFLAGS="$LIBICU_CFLAGS $CFLAGS" @@ -407,7 +406,7 @@ AS_IF( ]) ]) - # Try -licuuc + dnl Try -licuuc AS_IF([test "$HAVE_LIBICU" = no], [ AC_MSG_CHECKING([for ICU unicode library]) LIBS="-licuuc $LIBS" @@ -447,7 +446,7 @@ AS_IF( [ HAVE_LIBIDN=no - # Save CFLAGS and LIBS so we can restore them later + dnl Save CFLAGS and LIBS so we can restore them later __save_CFLAGS=$CFLAGS __save_LIBS=$LIBS @@ -458,7 +457,7 @@ AS_IF( PKG_CHECK_MODULES([LIBIDN], [libidn], [HAVE_LIBIDN=maybe], [HAVE_LIBIDN=no]) - # Check if we can link against libidn + dnl Check if we can link against libidn AS_IF([test "$HAVE_LIBIDN" = maybe], [ CFLAGS="$LIBIDN_CFLAGS $CFLAGS" LIBS="$LIBIDN_LIBS $LIBS" @@ -475,7 +474,7 @@ AS_IF( ]) ]) - # If we cannot link against found libidn, try static linking + dnl If we cannot link against found libidn, try static linking AS_IF([test "$HAVE_LIBIDN" = maybe], [ PKG_CHECK_MODULES_STATIC([LIBIDN], [libidn], [ CFLAGS="$LIBIDN_CFLAGS $CFLAGS" @@ -511,7 +510,7 @@ AS_IF( ]) -# last fallback is noruntime/nobuiltin +dnl last fallback is noruntime/nobuiltin AS_IF([test "$enable_runtime" = "auto"], [enable_runtime=no]) dnl If we use libidn or libidn2, we also need libiconv and libunistring. libicucore also needs iconv @@ -595,10 +594,10 @@ AC_SUBST([libpsl_pc_Libs_private]) AC_SUBST([libpsl_pc_Requires]) AC_SUBST([libpsl_pc_Requires_private]) -# Check for clock_gettime() used for performance measurement +dnl Check for clock_gettime() used for performance measurement AC_SEARCH_LIBS(clock_gettime, rt) -# Check for valgrind +dnl Check for valgrind ac_enable_valgrind=no AC_ARG_ENABLE(valgrind-tests, AS_HELP_STRING([--enable-valgrind-tests], [enable using Valgrind for tests]), @@ -618,19 +617,19 @@ AS_IF([test "${ac_enable_valgrind}" = "yes"], [ TESTS_INFO="Valgrind testing not enabled" ]) -# Check for distribution-wide PSL file +dnl Check for distribution-wide PSL file AC_ARG_WITH(psl-distfile, AS_HELP_STRING([--with-psl-distfile=[PATH]], [path to distribution-wide PSL file]), PSL_DISTFILE=$withval AC_SUBST(PSL_DISTFILE)) -# Check for custom PSL file +dnl Check for custom PSL file AC_ARG_WITH(psl-file, AS_HELP_STRING([--with-psl-file=[PATH]], [path to PSL file]), PSL_FILE=$withval, PSL_FILE="\$(top_srcdir)/list/public_suffix_list.dat") AC_SUBST(PSL_FILE) -# Check for custom PSL test file +dnl Check for custom PSL test file AC_ARG_WITH(psl-testfile, AS_HELP_STRING([--with-psl-testfile=[PATH]], [path to PSL test file]), PSL_TESTFILE=$withval, @@ -640,11 +639,11 @@ AC_SUBST(PSL_TESTFILE) AC_CHECK_FUNCS([clock_gettime fmemopen nl_langinfo]) AC_CHECK_DECLS([localtime_r]) -# check for dirent.h +dnl check for dirent.h AC_HEADER_DIRENT -# Override the template file name of the generated .pc file, so that there -# is no need to rename the template file when the API version changes. +dnl Override the template file name of the generated .pc file, so that there +dnl is no need to rename the template file when the API version changes. AC_CONFIG_FILES([Makefile include/Makefile src/Makefile From cc444465290002903169c983d2ea1cd32be2b12c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20R=C3=BChsen?= Date: Wed, 1 Jul 2026 10:51:47 +0200 Subject: [PATCH 3/4] Formatting and using shell operators --- configure.ac | 202 ++++++++++++++++++++++++--------------------------- 1 file changed, 93 insertions(+), 109 deletions(-) diff --git a/configure.ac b/configure.ac index cafcde5..0dad3a3 100644 --- a/configure.ac +++ b/configure.ac @@ -1,5 +1,5 @@ m4_define([libpsl_version], m4_normalize(m4_include(version.txt))) -AC_INIT([libpsl], libpsl_version, [tim.ruehsen@gmx.de], [libpsl], [https://github.com/rockdaboot/libpsl]) +AC_INIT([libpsl], [libpsl_version], [tim.ruehsen@gmx.de], [libpsl], [https://github.com/rockdaboot/libpsl]) AC_PREREQ([2.59]) AC_CONFIG_AUX_DIR([build-aux]) AM_INIT_AUTOMAKE([1.10 no-define foreign dist-lzip]) @@ -38,10 +38,10 @@ gl_LIBUNISTRING dnl dnl Generate version defines for include file dnl -AC_SUBST([LIBPSL_VERSION_MAJOR], [`echo $VERSION|cut -d'.' -f1`]) -AC_SUBST([LIBPSL_VERSION_MINOR], [`echo $VERSION|cut -d'.' -f2`]) -AC_SUBST([LIBPSL_VERSION_PATCH], [`echo $VERSION|cut -d'.' -f3`]) -AC_SUBST([LIBPSL_VERSION_NUMBER], [`printf '0x%02x%02x%02x' $LIBPSL_VERSION_MAJOR $LIBPSL_VERSION_MINOR $LIBPSL_VERSION_PATCH`]) +AC_SUBST([LIBPSL_VERSION_MAJOR], [$(echo $VERSION | cut -d'.' -f1)]) +AC_SUBST([LIBPSL_VERSION_MINOR], [$(echo $VERSION | cut -d'.' -f2)]) +AC_SUBST([LIBPSL_VERSION_PATCH], [$(echo $VERSION | cut -d'.' -f3)]) +AC_SUBST([LIBPSL_VERSION_NUMBER], [$(printf '0x%02x%02x%02x' $LIBPSL_VERSION_MAJOR $LIBPSL_VERSION_MINOR $LIBPSL_VERSION_PATCH)]) AC_CONFIG_FILES([include/libpsl.h]) dnl @@ -72,8 +72,7 @@ dnl dnl enable creation of man pages dnl AC_ARG_ENABLE([man], - [AS_HELP_STRING([--enable-man], [generate man pages [default=auto]])], - [ + [AS_HELP_STRING([--enable-man], [generate man pages [default=auto]])], [ AS_IF([test "$enable_man" = yes], [ AC_PATH_PROG([XSLTPROC], [xsltproc]) AS_IF([test -z "$XSLTPROC"], [ @@ -85,16 +84,14 @@ AC_ARG_ENABLE([man], AM_CONDITIONAL([ENABLE_MAN], [test "$enable_man" = "yes"]) dnl src/psl-make-dafsa needs python 2.7+ -AS_IF([! test -f src/suffixes_dafsa.h -a -f tests/psl.dafsa -a -f tests/psl_ascii.dafsa], - [ - AM_PATH_PYTHON([2.7],, [AC_MSG_ERROR([python 2.7+ is required to convert the PSL data])]) - ]) +AS_IF([test ! -f src/suffixes_dafsa.h || test ! -f tests/psl.dafsa || test ! -f tests/psl_ascii.dafsa], [ + AM_PATH_PYTHON([2.7],, [AC_MSG_ERROR([python 2.7+ is required to convert the PSL data])]) +]) PKG_PROG_PKG_CONFIG AC_ARG_ENABLE([fuzzing], - [AS_HELP_STRING([--enable-fuzzing], [Turn on fuzzing build (for developers)])], - [ + [AS_HELP_STRING([--enable-fuzzing], [Turn on fuzzing build (for developers)])], [ enable_fuzzing=yes AC_SUBST([LIB_FUZZING_ENGINE]) AC_DEFINE([FUZZING], 1, [Define to 1 if this is a fuzzing build]) @@ -102,8 +99,7 @@ AC_ARG_ENABLE([fuzzing], AM_CONDITIONAL([FUZZING], [test "$enable_fuzzing" = "yes"]) AC_ARG_ENABLE([cfi], - [AS_HELP_STRING([--enable-cfi], [Turn on clang's Control Flow Integrity (CFI)])], - [ + [AS_HELP_STRING([--enable-cfi], [Turn on clang's Control Flow Integrity (CFI)])], [ AS_IF([test "$enable_cfi" = yes], [ CFLAGS="$CFLAGS -B/usr/bin/gold -fsanitize=cfi -flto -fvisibility=default -fno-sanitize-trap=all" AC_LINK_IFELSE([ @@ -115,8 +111,7 @@ AC_ARG_ENABLE([cfi], ], [enable_cfi=no]) AC_ARG_ENABLE([ubsan], - [AS_HELP_STRING([--enable-ubsan], [Turn on Undefined Behavior Sanitizer (UBSan)])], - [ + [AS_HELP_STRING([--enable-ubsan], [Turn on Undefined Behavior Sanitizer (UBSan)])], [ AS_IF([test "$enable_ubsan" = yes], [ dnl Set basic UBSAN compiler flags. Add your own to CFLAGS. CFLAGS="$CFLAGS -fsanitize=undefined -fno-sanitize-recover=undefined" @@ -124,8 +119,7 @@ AC_ARG_ENABLE([ubsan], ], [enable_ubsan=no]) AC_ARG_ENABLE([asan], - [AS_HELP_STRING([--enable-asan], [Turn on Address Sanitizer (ASan)])], - [ + [AS_HELP_STRING([--enable-asan], [Turn on Address Sanitizer (ASan)])], [ AS_IF([test "$enable_asan" = yes], [ dnl Set basic ASAN compiler flags. Add your own to CFLAGS. CFLAGS="$CFLAGS -fsanitize=address -fno-omit-frame-pointer" @@ -145,11 +139,10 @@ dnl 4. If any interfaces have been added, removed, or changed since the last upd dnl 5. If any interfaces have been added since the last public release, then increment age. dnl 6. If any existing interfaces have been removed or changed since the last public release, then set age to 0. AC_SUBST([LIBPSL_SO_VERSION], m4_normalize(m4_include([libtool_version_info.txt]))) -AC_SUBST([LIBPSL_VERSION], $VERSION) +AC_SUBST([LIBPSL_VERSION], [$VERSION]) dnl Check for enable/disable runtime PSL data -AC_ARG_ENABLE(runtime, - [ +AC_ARG_ENABLE([runtime], [ --enable-runtime[[=IDNA library]] Specify the IDNA library used for libpsl run-time conversions: libidn2 [[default]]: IDNA2008 library (also needs libunistring) @@ -157,42 +150,41 @@ AC_ARG_ENABLE(runtime, libicucore: IDNA2008 UTS#46 library shipped with Apple OSes libidn: IDNA2003 library (also needs libunistring) --disable-runtime Do not link runtime IDNA functionality - ], [ - AS_IF( - [test "$enableval" = "libidn2" -o "$enableval" = "yes"], - [enable_runtime=libidn2; AC_DEFINE([WITH_LIBIDN2], [1], [generate PSL data using libidn2])], - [test "$enableval" = "libicu"], - [enable_runtime=libicu; AC_DEFINE([WITH_LIBICU], [1], [generate PSL data using libicu])], - [test "$enableval" = "libicucore"], - [enable_runtime=libicucore; AC_DEFINE([WITH_LIBICUCORE], [1], [generate PSL data using libicucore])], - [test "$enableval" = "libidn"], - [enable_runtime=libidn; AC_DEFINE([WITH_LIBIDN], [1], [generate PSL data using libidn])], - [test "$enableval" = "no"], - [enable_runtime=no], - [AC_MSG_ERROR([Unknown value $enableval for --enable-runtime])] ) - ], [ - dnl this is the default if neither --enable-runtime nor --disable-runtime were specified - enable_runtime=auto - ]) +], [ + AS_IF( + [test "$enableval" = "libidn2" || test "$enableval" = "yes"], + [enable_runtime=libidn2; AC_DEFINE([WITH_LIBIDN2], [1], [generate PSL data using libidn2])], + [test "$enableval" = "libicu"], + [enable_runtime=libicu; AC_DEFINE([WITH_LIBICU], [1], [generate PSL data using libicu])], + [test "$enableval" = "libicucore"], + [enable_runtime=libicucore; AC_DEFINE([WITH_LIBICUCORE], [1], [generate PSL data using libicucore])], + [test "$enableval" = "libidn"], + [enable_runtime=libidn; AC_DEFINE([WITH_LIBIDN], [1], [generate PSL data using libidn])], + [test "$enableval" = "no"], + [enable_runtime=no], + [AC_MSG_ERROR([Unknown value $enableval for --enable-runtime])] ) +], [ + dnl this is the default if neither --enable-runtime nor --disable-runtime were specified + enable_runtime=auto +]) dnl Check for enable/disable builtin PSL data -AC_ARG_ENABLE(builtin, - [ +AC_ARG_ENABLE([builtin], [ --enable-builtin Generate built-in PSL data --disable-builtin Do not generate built-in PSL data - ], [ - AS_IF( - [test "$enableval" = "yes"], - [enable_builtin=yes], - [test "$enableval" = "libidn" -o "$enableval" = "libidn2" -o "$enableval" = "libicu"], - [AC_MSG_WARN([--enable-builtin=$enableval is deprecated, use --enable-builtin (enabled by default)]); enable_builtin=yes], - [test "$enableval" = "no"], - [enable_builtin=no], - [AC_MSG_ERROR(Unknown value $enableval)] ) - ], [ - dnl this is the default if neither --enable-builtin nor --disable-builtin were specified - enable_builtin=yes - ]) +], [ + AS_IF( + [test "$enableval" = "yes"], + [enable_builtin=yes], + [test "$enableval" = "libidn" || test "$enableval" = "libidn2" || test "$enableval" = "libicu"], + [AC_MSG_WARN([--enable-builtin=$enableval is deprecated, use --enable-builtin (enabled by default)]); enable_builtin=yes], + [test "$enableval" = "no"], + [enable_builtin=no], + [AC_MSG_ERROR([Unknown value $enableval])] ) +], [ + dnl this is the default if neither --enable-builtin nor --disable-builtin were specified + enable_builtin=yes +]) AS_IF([test "$enable_builtin" = "yes"], [ AC_DEFINE([ENABLE_BUILTIN], [1], [Generate built-in PSL data]) @@ -239,8 +231,7 @@ AC_SUBST([runtime_LIBS]) dnl Check for libicucore AS_IF( - [test "$enable_runtime" = "libicucore" || { test "$host_vendor" = "apple" -a "$enable_runtime" = "auto"; }], - [ + [test "$enable_runtime" = "libicucore" || { test "$host_vendor" = "apple" && test "$enable_runtime" = "auto"; }], [ HAVE_LIBICUCORE=no dnl Check if we can link against libicucore @@ -257,17 +248,17 @@ AS_IF( enable_runtime=libicucore AC_DEFINE([WITH_LIBICUCORE], [1], [generate PSL data using libicucore]) ]) - ], - [test "$enable_runtime" = "libicucore"], [ - AC_MSG_ERROR([You requested libicucore but it is not available or usable.]) + ], [ + AS_IF([test "$enable_runtime" = "libicucore"], [ + AC_MSG_ERROR([You requested libicucore but it is not available or usable.]) + ]) ]) ]) dnl Check for libidn2 AS_IF( - [test "$enable_runtime" = "libidn2" -o "$enable_runtime" = "auto"], - [ + [test "$enable_runtime" = "libidn2" || test "$enable_runtime" = "auto"], [ HAVE_LIBIDN2=no dnl Save CFLAGS and LIBS so we can restore them later @@ -341,8 +332,7 @@ AS_IF( dnl Check for libicu AS_IF( - [test "$enable_runtime" = "libicu" -o "$enable_runtime" = "auto"], - [ + [test "$enable_runtime" = "libicu" || test "$enable_runtime" = "auto"], [ HAVE_LIBICU=no dnl Whether we found libicu using pkg-config HAVE_LIBICU_PC=no @@ -442,8 +432,7 @@ AS_IF( dnl Check for libidn AS_IF( - [test "$enable_runtime" = "libidn"], - [ + [test "$enable_runtime" = "libidn"], [ HAVE_LIBIDN=no dnl Save CFLAGS and LIBS so we can restore them later @@ -515,18 +504,17 @@ AS_IF([test "$enable_runtime" = "auto"], [enable_runtime=no]) dnl If we use libidn or libidn2, we also need libiconv and libunistring. libicucore also needs iconv AS_IF( - [test "$enable_runtime" = "libidn2" -o "$enable_runtime" = "libidn" -o "$enable_runtime" = "libicucore"], - [ - __save_LIBS=$LIBS - - LIBS=$LIBICONV - AC_LINK_IFELSE([ - AC_LANG_PROGRAM([#include ], [iconv_open ("", "");]) - ], [:], [ - AC_MSG_ERROR([You requested libidn2|libidn|libicucore but libiconv is not installed.]) - ]) - LIBS=$__save_LIBS - runtime_LIBS="$runtime_LIBS $LTLIBICONV" + [test "$enable_runtime" = "libidn2" || test "$enable_runtime" = "libidn" || test "$enable_runtime" = "libicucore"], [ + __save_LIBS=$LIBS + + LIBS=$LIBICONV + AC_LINK_IFELSE([ + AC_LANG_PROGRAM([#include ], [iconv_open ("", "");]) + ], [:], [ + AC_MSG_ERROR([You requested libidn2|libidn|libicucore but libiconv is not installed.]) + ]) + LIBS=$__save_LIBS + runtime_LIBS="$runtime_LIBS $LTLIBICONV" AS_IF([test "$enable_runtime" != "libicucore"], [ LIBS=$LIBUNISTRING @@ -541,11 +529,11 @@ AS_IF( ]) -AM_CONDITIONAL([WITH_LIBICU], test "$enable_runtime" = "libicu") -AM_CONDITIONAL([WITH_LIBICUCORE], test "$enable_runtime" = "libicucore") -AM_CONDITIONAL([WITH_LIBIDN2], test "$enable_runtime" = "libidn2") -AM_CONDITIONAL([WITH_LIBIDN], test "$enable_runtime" = "libidn") -AM_CONDITIONAL([ENABLE_BUILTIN], test "$enable_builtin" = "yes") +AM_CONDITIONAL([WITH_LIBICU], [test "$enable_runtime" = "libicu"]) +AM_CONDITIONAL([WITH_LIBICUCORE], [test "$enable_runtime" = "libicucore"]) +AM_CONDITIONAL([WITH_LIBIDN2], [test "$enable_runtime" = "libidn2"]) +AM_CONDITIONAL([WITH_LIBIDN], [test "$enable_runtime" = "libidn"]) +AM_CONDITIONAL([ENABLE_BUILTIN], [test "$enable_builtin" = "yes"]) dnl libpsl.pc libpsl_pc_Cflags= @@ -556,27 +544,20 @@ libpsl_pc_Requires= libpsl_pc_Requires_private= AS_IF( - [test "$enable_runtime" = libidn2], - [ + [test "$enable_runtime" = libidn2], [ libpsl_pc_Libs_private="$LTLIBUNISTRING $LTLIBICONV $LIBS" libpsl_pc_Requires_private=libidn2 - ], - [test "$enable_runtime" = libidn], - [ + ], [test "$enable_runtime" = libidn], [ libpsl_pc_Libs_private="$LTLIBUNISTRING $LTLIBICONV $LIBS" libpsl_pc_Requires_private=libidn - ], - [test "$enable_runtime" = libicu], - [ + ], [test "$enable_runtime" = libicu], [ AS_IF([test "$HAVE_LIBICU_PC" = yes], [ libpsl_pc_Libs_private="$LIBS" libpsl_pc_Requires_private=icu-uc ], [ libpsl_pc_Libs_private="$LIBICU_LIBS $LIBS" ]) - ], - [test "$enable_runtime" = libicucore], - [ + ], [test "$enable_runtime" = libicucore], [ libpsl_pc_Libs_private="-licucore $LTLIBICONV $LIBS" ]) @@ -585,7 +566,8 @@ dnl On Windows we use pkgconf-specific Cflags.private to pass -DPSL_STATIC AS_CASE([${host}], [*-mingw32 | *-mingw64 | *-windows], [ libpsl_pc_Cflags_private='Cflags.private: -DPSL_STATIC' - libpsl_pc_Requires='pkgconf']) + libpsl_pc_Requires='pkgconf' + ]) AC_SUBST([libpsl_pc_Cflags]) AC_SUBST([libpsl_pc_Cflags_private]) @@ -595,20 +577,20 @@ AC_SUBST([libpsl_pc_Requires]) AC_SUBST([libpsl_pc_Requires_private]) dnl Check for clock_gettime() used for performance measurement -AC_SEARCH_LIBS(clock_gettime, rt) +AC_SEARCH_LIBS([clock_gettime], [rt]) dnl Check for valgrind ac_enable_valgrind=no -AC_ARG_ENABLE(valgrind-tests, +AC_ARG_ENABLE([valgrind-tests], AS_HELP_STRING([--enable-valgrind-tests], [enable using Valgrind for tests]), [ac_enable_valgrind=$enableval], [ac_enable_valgrind=no]) AS_IF([test "${ac_enable_valgrind}" = "yes"], [ - AC_CHECK_PROG(HAVE_VALGRIND, valgrind, yes, no) + AC_CHECK_PROG([HAVE_VALGRIND], [valgrind], [yes], [no]) AS_IF([test "$HAVE_VALGRIND" = "yes"], [ VALGRIND_ENVIRONMENT="valgrind --error-exitcode=1 --leak-check=yes --show-reachable=yes --track-origins=yes" - AC_SUBST(VALGRIND_ENVIRONMENT) + AC_SUBST([VALGRIND_ENVIRONMENT]) TESTS_INFO="Test suite will be run under Valgrind" ], [ TESTS_INFO="Valgrind not found" @@ -618,29 +600,31 @@ AS_IF([test "${ac_enable_valgrind}" = "yes"], [ ]) dnl Check for distribution-wide PSL file -AC_ARG_WITH(psl-distfile, +AC_ARG_WITH([psl-distfile], AS_HELP_STRING([--with-psl-distfile=[PATH]], [path to distribution-wide PSL file]), - PSL_DISTFILE=$withval AC_SUBST(PSL_DISTFILE)) + [PSL_DISTFILE=$withval], + [PSL_DISTFILE=]) +AC_SUBST([PSL_DISTFILE]) dnl Check for custom PSL file -AC_ARG_WITH(psl-file, +AC_ARG_WITH([psl-file], AS_HELP_STRING([--with-psl-file=[PATH]], [path to PSL file]), - PSL_FILE=$withval, - PSL_FILE="\$(top_srcdir)/list/public_suffix_list.dat") -AC_SUBST(PSL_FILE) + [PSL_FILE=$withval], + [PSL_FILE="\$(top_srcdir)/list/public_suffix_list.dat"]) +AC_SUBST([PSL_FILE]) dnl Check for custom PSL test file -AC_ARG_WITH(psl-testfile, +AC_ARG_WITH([psl-testfile], AS_HELP_STRING([--with-psl-testfile=[PATH]], [path to PSL test file]), - PSL_TESTFILE=$withval, - PSL_TESTFILE="\$(top_srcdir)/list/tests/tests.txt") -AC_SUBST(PSL_TESTFILE) + [PSL_TESTFILE=$withval], + [PSL_TESTFILE="\$(top_srcdir)/list/tests/tests.txt"]) +AC_SUBST([PSL_TESTFILE]) AC_CHECK_FUNCS([clock_gettime fmemopen nl_langinfo]) AC_CHECK_DECLS([localtime_r]) dnl check for dirent.h -AC_HEADER_DIRENT +AC_CHECK_HEADERS([dirent.h]) dnl Override the template file name of the generated .pc file, so that there dnl is no need to rename the template file when the API version changes. From b0994e86c1e95d52d0e0018e291dc55903e3abe2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20R=C3=BChsen?= Date: Wed, 1 Jul 2026 11:37:08 +0200 Subject: [PATCH 4/4] Don't taint $CFLAGS when using sanitizer options --- configure.ac | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/configure.ac b/configure.ac index 0dad3a3..aba6076 100644 --- a/configure.ac +++ b/configure.ac @@ -101,7 +101,7 @@ AM_CONDITIONAL([FUZZING], [test "$enable_fuzzing" = "yes"]) AC_ARG_ENABLE([cfi], [AS_HELP_STRING([--enable-cfi], [Turn on clang's Control Flow Integrity (CFI)])], [ AS_IF([test "$enable_cfi" = yes], [ - CFLAGS="$CFLAGS -B/usr/bin/gold -fsanitize=cfi -flto -fvisibility=default -fno-sanitize-trap=all" + SANITIZER_CFLAGS="$SANITIZER_CFLAGS -B/usr/bin/gold -fsanitize=cfi -flto -fvisibility=default -fno-sanitize-trap=all" AC_LINK_IFELSE([ AC_LANG_PROGRAM([], []) ], [], [ @@ -114,7 +114,7 @@ AC_ARG_ENABLE([ubsan], [AS_HELP_STRING([--enable-ubsan], [Turn on Undefined Behavior Sanitizer (UBSan)])], [ AS_IF([test "$enable_ubsan" = yes], [ dnl Set basic UBSAN compiler flags. Add your own to CFLAGS. - CFLAGS="$CFLAGS -fsanitize=undefined -fno-sanitize-recover=undefined" + SANITIZER_CFLAGS="$SANITIZER_CFLAGS -fsanitize=undefined -fno-sanitize-recover=undefined" ]) ], [enable_ubsan=no]) @@ -122,8 +122,8 @@ AC_ARG_ENABLE([asan], [AS_HELP_STRING([--enable-asan], [Turn on Address Sanitizer (ASan)])], [ AS_IF([test "$enable_asan" = yes], [ dnl Set basic ASAN compiler flags. Add your own to CFLAGS. - CFLAGS="$CFLAGS -fsanitize=address -fno-omit-frame-pointer" - AX_CHECK_COMPILE_FLAG([-fsanitize-address-use-after-scope], [CFLAGS="$CFLAGS -fsanitize-address-use-after-scope"]) + SANITIZER_CFLAGS="$SANITIZER_CFLAGS -fsanitize=address -fno-omit-frame-pointer" + AX_CHECK_COMPILE_FLAG([-fsanitize-address-use-after-scope], [SANITIZER_CFLAGS="$SANITIZER_CFLAGS -fsanitize-address-use-after-scope"]) ]) ], [enable_asan=no]) @@ -196,7 +196,7 @@ dnl We should not use plain *FLAGS since they belong to the user. dnl We can temporary modify them for configuration checks, but then we need to dnl restore them to their original values. AM_CPPFLAGS="-I\$(top_builddir)/include -I\$(top_srcdir)/include" -AM_CFLAGS= +AM_CFLAGS="$AM_CFLAGS $SANITIZER_CFLAGS" AM_LDFLAGS= AC_SUBST([AM_CPPFLAGS]) @@ -223,7 +223,7 @@ dnl required to link against static library. dnl Compiler flags required to use $enable_runtime (when != "no") runtime_CFLAGS= -dnl Libraries required to use $enable_runitme (when != "no") +dnl Libraries required to use $enable_runtime (when != "no") runtime_LIBS= AC_SUBST([runtime_CFLAGS])