0001-configure.ac-find-libpsl-with-pkg-config.patch 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. From 9b3f67e267d1fa8d7867655d133bdbf8830a0ab3 Mon Sep 17 00:00:00 2001
  2. From: Fabrice Fontaine <fontaine.fabrice@gmail.com>
  3. Date: Thu, 15 Feb 2024 20:59:25 +0100
  4. Subject: [PATCH] configure.ac: find libpsl with pkg-config
  5. Find libpsl with pkg-config to avoid static build failures.
  6. Ref: http://autobuild.buildroot.org/results/1fb15e1a99472c403d0d3b1a688902f32e78d002
  7. Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
  8. Closes #12947
  9. Upstream: https://github.com/curl/curl/commit/9b3f67e267d1fa8d7867655d133bdbf8830a0ab3
  10. ---
  11. configure.ac | 79 ++++++++++++++++++++++++++++++++++++++++++++--------
  12. docs/TODO | 7 -----
  13. 2 files changed, 67 insertions(+), 19 deletions(-)
  14. diff --git a/configure.ac b/configure.ac
  15. index cd0e2d07d8d164..09d5364f4de575 100644
  16. --- a/configure.ac
  17. +++ b/configure.ac
  18. @@ -2075,19 +2075,74 @@ dnl **********************************************************************
  19. dnl Check for libpsl
  20. dnl **********************************************************************
  21. -AC_ARG_WITH(libpsl,
  22. - AS_HELP_STRING([--without-libpsl],
  23. - [disable support for libpsl]),
  24. - with_libpsl=$withval,
  25. - with_libpsl=yes)
  26. -curl_psl_msg="no (libpsl disabled)"
  27. -if test $with_libpsl != "no"; then
  28. - AC_SEARCH_LIBS(psl_builtin, psl,
  29. - [curl_psl_msg="enabled";
  30. - AC_DEFINE([USE_LIBPSL], [1], [PSL support enabled])
  31. - ],
  32. - [AC_MSG_ERROR([libpsl was not found]) ]
  33. +dnl Default to compiler & linker defaults for LIBPSL files & libraries.
  34. +OPT_LIBPSL=off
  35. +AC_ARG_WITH(libpsl,dnl
  36. +AS_HELP_STRING([--with-libpsl=PATH],[Where to look for libpsl, PATH points to the LIBPSL installation; when possible, set the PKG_CONFIG_PATH environment variable instead of using this option])
  37. +AS_HELP_STRING([--without-libpsl], [disable LIBPSL]),
  38. + OPT_LIBPSL=$withval)
  39. +
  40. +if test X"$OPT_LIBPSL" != Xno; then
  41. + dnl backup the pre-libpsl variables
  42. + CLEANLDFLAGS="$LDFLAGS"
  43. + CLEANCPPFLAGS="$CPPFLAGS"
  44. + CLEANLIBS="$LIBS"
  45. +
  46. + case "$OPT_LIBPSL" in
  47. + yes)
  48. + dnl --with-libpsl (without path) used
  49. + CURL_CHECK_PKGCONFIG(libpsl)
  50. +
  51. + if test "$PKGCONFIG" != "no" ; then
  52. + LIB_PSL=`$PKGCONFIG --libs-only-l libpsl`
  53. + LD_PSL=`$PKGCONFIG --libs-only-L libpsl`
  54. + CPP_PSL=`$PKGCONFIG --cflags-only-I libpsl`
  55. + else
  56. + dnl no libpsl pkg-config found
  57. + LIB_PSL="-lpsl"
  58. + fi
  59. +
  60. + ;;
  61. + off)
  62. + dnl no --with-libpsl option given, just check default places
  63. + LIB_PSL="-lpsl"
  64. + ;;
  65. + *)
  66. + dnl use the given --with-libpsl spot
  67. + LIB_PSL="-lpsl"
  68. + PREFIX_PSL=$OPT_LIBPSL
  69. + ;;
  70. + esac
  71. +
  72. + dnl if given with a prefix, we set -L and -I based on that
  73. + if test -n "$PREFIX_PSL"; then
  74. + LD_PSL=-L${PREFIX_PSL}/lib$libsuff
  75. + CPP_PSL=-I${PREFIX_PSL}/include
  76. + fi
  77. +
  78. + LDFLAGS="$LDFLAGS $LD_PSL"
  79. + CPPFLAGS="$CPPFLAGS $CPP_PSL"
  80. + LIBS="$LIB_PSL $LIBS"
  81. +
  82. + AC_CHECK_LIB(psl, psl_builtin,
  83. + [
  84. + AC_CHECK_HEADERS(libpsl.h,
  85. + curl_psl_msg="enabled"
  86. + LIBPSL_ENABLED=1
  87. + AC_DEFINE(USE_LIBPSL, 1, [if libpsl is in use])
  88. + AC_SUBST(USE_LIBPSL, [1])
  89. + )
  90. + ],
  91. + dnl not found, revert back to clean variables
  92. + LDFLAGS=$CLEANLDFLAGS
  93. + CPPFLAGS=$CLEANCPPFLAGS
  94. + LIBS=$CLEANLIBS
  95. )
  96. +
  97. + if test X"$OPT_LIBPSL" != Xoff &&
  98. + test "$LIBPSL_ENABLED" != "1"; then
  99. + AC_MSG_ERROR([libpsl libs and/or directories were not found where specified!])
  100. + fi
  101. fi
  102. AM_CONDITIONAL([USE_LIBPSL], [test "$curl_psl_msg" = "enabled"])