]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
build: if no perl, fix to use the pre-built hugehelp, if present
authorViktor Szakats <commit@vsz.me>
Thu, 31 Jul 2025 14:38:34 +0000 (16:38 +0200)
committerViktor Szakats <commit@vsz.me>
Fri, 1 Aug 2025 21:54:12 +0000 (23:54 +0200)
- cmake: Before this patch a missing perl disabled the curl manual.
  After this patch, it automatically picks up a pre-built hugehelp,
  if present (= when building from a release tarball).
  Follow-up to 0035ff45c59437db1a8ffe960b40905c8582b149 #16081

- autotools: Rework behavior when perl is missing. Before this patch
  it caused a hard error when docs/manual/ca-embed were enabled.
  Of these, docs were enabled by default. After this patch, doc
  generation is automatically skipped, with a warning. Manual generation
  falls back to using a pre-built hugehelp, or a stub if that's missing.
  CA-embed is automatically skipped, with a warning.
  Slight difference from cmake: When built with no perl and no pre-built
  hugehelp, the manual is enabled, but the content is empty; with cmake
  it's disabled proper.
  Follow-up to 137aecfbf1e933e7228a4f62cc977eabffb2afbf #13514
  Follow-up to 541321507e386744c3ea1200cc83cc98338e27d7 #12857

Also:
- GHA/distcheck: verify if the pre-built hugehelp makes it into curl.
- GHA/distcheck: streamline disabling perl with autotools.
- GHA/distcheck: `--disable-docs` no longer required to build without perl.
  Passing it also implicitly disables the curl manual, which is
  undesired in these tests.
- cmake: drop redundant `HAVE_MANUAL_TOOLS` interim variable.
- cmake: move two `set()` lines close to their counterparts.

Follow-up to 25119fbaaa76a182d4b08d64853d0a8db9181219 #18104

Closes #18118

.github/workflows/distcheck.yml
CMakeLists.txt
acinclude.m4
configure.ac
src/CMakeLists.txt
src/Makefile.am

index 03032023f6d4dc562433c5114b4cae67d740e965..42633ef040128a94ab6c8bef55ecf77de9dbf696 100644 (file)
@@ -113,7 +113,7 @@ jobs:
           make test-ci
           make install
           curl-install/bin/curl --disable --version
-          curl-install/bin/curl --manual | wc -l
+          curl-install/bin/curl --manual | wc -l | grep -v '^ *0$'
           popd
           scripts/checksrc-all.pl
 
@@ -127,9 +127,6 @@ jobs:
         with:
           name: 'release-tgz'
 
-      - name: 'disable preinstalled perl'
-        run: sudo mv "$(command -v perl)" "$(command -v perl)"-disabled
-
       - name: 'build & install'
         run: |
           echo "::stop-commands::$(uuidgen)"
@@ -137,11 +134,11 @@ jobs:
           pushd curl-99.98.97
           mkdir build
           pushd build
-          ../configure --prefix="$PWD"/curl-install --enable-werror --without-ssl --without-libpsl --disable-docs
+          ../configure --prefix="$PWD"/curl-install --enable-werror --without-ssl --without-libpsl ac_cv_path_PERL=
           make
           make install
           curl-install/bin/curl --disable --version
-          curl-install/bin/curl --manual | wc -l
+          curl-install/bin/curl --manual | wc -l | grep -v '^ *0$'
           popd
 
   verify-in-tree-autotools:
@@ -154,19 +151,16 @@ jobs:
         with:
           name: 'release-tgz'
 
-      - name: 'disable preinstalled perl'
-        run: sudo mv "$(command -v perl)" "$(command -v perl)"-disabled
-
       - name: 'build & install'
         run: |
           echo "::stop-commands::$(uuidgen)"
           tar xvf curl-99.98.97.tar.gz
           pushd curl-99.98.97
-          ./configure --prefix="$PWD"/curl-install --enable-werror --without-ssl --without-libpsl --disable-docs
+          ./configure --prefix="$PWD"/curl-install --enable-werror --without-ssl --without-libpsl ac_cv_path_PERL=
           make
           make install
           curl-install/bin/curl --disable --version
-          curl-install/bin/curl --manual | wc -l
+          curl-install/bin/curl --manual | wc -l | grep -v '^ *0$'
 
   verify-out-of-tree-cmake:
     name: 'CM out-of-tree !perl'
@@ -188,7 +182,7 @@ jobs:
           cmake --install build
           export LD_LIBRARY_PATH="$PWD/curl-install/lib:$LD_LIBRARY_PATH"
           curl-install/bin/curl --disable --version
-          curl-install/bin/curl --manual | wc -l
+          curl-install/bin/curl --manual | wc -l | grep -v '^ *0$'
 
   verify-in-tree-cmake:
     name: 'CM in-tree !perl'
@@ -210,7 +204,7 @@ jobs:
           cmake --install .
           export LD_LIBRARY_PATH="$PWD/curl-install/lib:$LD_LIBRARY_PATH"
           curl-install/bin/curl --disable --version
-          curl-install/bin/curl --manual | wc -l
+          curl-install/bin/curl --manual | wc -l | grep -v '^ *0$'
 
   missing-files:
     name: 'missing files'
index 7a63b04d821a61b1918d079c8aedd15e7c3f339d..7e3cfff3ce6809f6a71188b809ff2e8323ce8f10 100644 (file)
@@ -532,13 +532,8 @@ option(BUILD_LIBCURL_DOCS "Build libcurl man pages" ON)
 option(BUILD_MISC_DOCS "Build misc man pages (e.g. curl-config and mk-ca-bundle)" ON)
 option(ENABLE_CURL_MANUAL "Build the man page for curl and enable its -M/--manual option" ON)
 
-if(ENABLE_CURL_MANUAL OR BUILD_LIBCURL_DOCS)
-  if(PERL_FOUND)
-    set(HAVE_MANUAL_TOOLS ON)
-  endif()
-  if(NOT HAVE_MANUAL_TOOLS)
-    message(WARNING "Perl not found. Will not build manuals.")
-  endif()
+if((ENABLE_CURL_MANUAL OR BUILD_LIBCURL_DOCS) AND NOT PERL_FOUND)
+  message(WARNING "Perl not found. Will not build manuals.")
 endif()
 
 # If we are on AIX, do the _ALL_SOURCE magic
@@ -2034,7 +2029,7 @@ else()
   set(CURL_BUILD_TESTING OFF)
 endif()
 
-if(HAVE_MANUAL_TOOLS)
+if(PERL_FOUND)
   set(CURL_MANPAGE "${PROJECT_BINARY_DIR}/docs/cmdline-opts/curl.1")
   set(CURL_ASCIIPAGE "${PROJECT_BINARY_DIR}/docs/cmdline-opts/curl.txt")
   add_subdirectory(docs)
index e10e4a01e0407a8cb8be584cfff73bc2e3f3cc50..105874fbe0bb1e62e6e95838261c0cebf01cba5b 100644 (file)
@@ -1284,9 +1284,14 @@ AS_HELP_STRING([--without-ca-embed], [Don't embed a default CA bundle in the cur
 
   CURL_CA_EMBED=''
   if test "x$want_ca_embed" != "xno" -a "x$want_ca_embed" != "xunset" -a -f "$want_ca_embed"; then
-    CURL_CA_EMBED="$want_ca_embed"
-    AC_SUBST(CURL_CA_EMBED)
-    AC_MSG_RESULT([$want_ca_embed])
+    if test -n "$PERL"; then
+      CURL_CA_EMBED="$want_ca_embed"
+      AC_SUBST(CURL_CA_EMBED)
+      AC_MSG_RESULT([$want_ca_embed])
+    else
+      AC_MSG_RESULT([no])
+      AC_MSG_WARN([perl was not found. Will not do CA embed.])
+    fi
   else
     AC_MSG_RESULT([no])
   fi
index 7cce097794a1924c81ce86dac98926559b3f47a8..a76761d7974327e9fc431e33f837db7d95506081 100644 (file)
@@ -280,6 +280,10 @@ AS_HELP_STRING([--with-rustls=PATH],[where to look for Rustls, PATH points to th
   fi
 ])
 
+AC_PATH_PROG(PERL, perl,, $PATH:/usr/local/bin/perl:/usr/bin/:/usr/local/bin)
+AC_SUBST(PERL)
+AM_CONDITIONAL(PERL, test -n "$PERL")
+
 TEST_NGHTTPX=nghttpx
 AC_ARG_WITH(test-nghttpx,dnl
 AS_HELP_STRING([--with-test-nghttpx=PATH],[where to find nghttpx for testing]),
@@ -1056,7 +1060,10 @@ AS_HELP_STRING([--disable-docs],[Disable documentation]),
     AC_MSG_RESULT(yes)
     BUILD_DOCS=1
 )
-
+if test -z "$PERL" -a "x$BUILD_DOCS" != "x0"; then
+  AC_MSG_WARN([perl was not found. Will not build documentation.])
+  BUILD_DOCS=0
+fi
 
 dnl ************************************************************
 dnl disable C code generation support
@@ -4218,16 +4225,6 @@ fi
 
 CURL_CHECK_NONBLOCKING_SOCKET
 
-AC_PATH_PROG(PERL, perl,,
-  $PATH:/usr/local/bin/perl:/usr/bin/:/usr/local/bin)
-AC_SUBST(PERL)
-
-if test "x$BUILD_DOCS" != "x0" -o "x$USE_MANUAL" != "x0" -o "x$CURL_CA_EMBED" != "x"; then
-  if test -z "$PERL"; then
-    AC_MSG_ERROR([perl was not found, needed for docs, manual and CA embed])
-  fi
-fi
-
 dnl set variable for use in automakefile(s)
 AM_CONDITIONAL(BUILD_DOCS, test x"$BUILD_DOCS" = x1)
 
index 51b2b76b870f1ac5b07cc11df922589e4c3be713..68d068727ff2744fc8d634b4dbcffcb1ab962995 100644 (file)
@@ -28,31 +28,34 @@ set(_curl_cfiles_gen "")
 set(_curl_hfiles_gen "")
 set(_curl_definitions "")
 
-if(ENABLE_CURL_MANUAL AND HAVE_MANUAL_TOOLS)
-  list(APPEND _curl_definitions "USE_MANUAL")
-  add_custom_command(OUTPUT "tool_hugehelp.c"
-    COMMAND ${CMAKE_COMMAND} -E echo "#include \"tool_setup.h\"" > "tool_hugehelp.c"
-    COMMAND ${CMAKE_COMMAND} -E echo "/* !checksrc! disable COPYRIGHT all */" >> "tool_hugehelp.c"
-    COMMAND ${CMAKE_COMMAND} -E echo "/* !checksrc! disable INCLUDEDUP all */" >> "tool_hugehelp.c"
-    COMMAND ${CMAKE_COMMAND} -E echo "/* !checksrc! disable LONGLINE all */" >> "tool_hugehelp.c"
-    COMMAND ${CMAKE_COMMAND} -E echo "#ifndef HAVE_LIBZ" >> "tool_hugehelp.c"
-    COMMAND "${PERL_EXECUTABLE}" "${CMAKE_CURRENT_SOURCE_DIR}/mkhelp.pl"    < "${CURL_ASCIIPAGE}" >> "tool_hugehelp.c"
-    COMMAND ${CMAKE_COMMAND} -E echo "#else" >> "tool_hugehelp.c"
-    COMMAND "${PERL_EXECUTABLE}" "${CMAKE_CURRENT_SOURCE_DIR}/mkhelp.pl" -c < "${CURL_ASCIIPAGE}" >> "tool_hugehelp.c"
-    COMMAND ${CMAKE_COMMAND} -E echo "#endif /* HAVE_LIBZ */" >> "tool_hugehelp.c"
-    DEPENDS
-      generate-curl.1
-      "${CMAKE_CURRENT_SOURCE_DIR}/mkhelp.pl"
-      "${CMAKE_CURRENT_SOURCE_DIR}/tool_hugehelp.h"
-      "${CURL_ASCIIPAGE}"
-    VERBATIM)
+if(ENABLE_CURL_MANUAL AND (PERL_FOUND OR EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/tool_hugehelp.c"))
+  if(PERL_FOUND)
+    add_custom_command(OUTPUT "tool_hugehelp.c"
+      COMMAND ${CMAKE_COMMAND} -E echo "#include \"tool_setup.h\"" > "tool_hugehelp.c"
+      COMMAND ${CMAKE_COMMAND} -E echo "/* !checksrc! disable COPYRIGHT all */" >> "tool_hugehelp.c"
+      COMMAND ${CMAKE_COMMAND} -E echo "/* !checksrc! disable INCLUDEDUP all */" >> "tool_hugehelp.c"
+      COMMAND ${CMAKE_COMMAND} -E echo "/* !checksrc! disable LONGLINE all */" >> "tool_hugehelp.c"
+      COMMAND ${CMAKE_COMMAND} -E echo "#ifndef HAVE_LIBZ" >> "tool_hugehelp.c"
+      COMMAND "${PERL_EXECUTABLE}" "${CMAKE_CURRENT_SOURCE_DIR}/mkhelp.pl"    < "${CURL_ASCIIPAGE}" >> "tool_hugehelp.c"
+      COMMAND ${CMAKE_COMMAND} -E echo "#else" >> "tool_hugehelp.c"
+      COMMAND "${PERL_EXECUTABLE}" "${CMAKE_CURRENT_SOURCE_DIR}/mkhelp.pl" -c < "${CURL_ASCIIPAGE}" >> "tool_hugehelp.c"
+      COMMAND ${CMAKE_COMMAND} -E echo "#endif /* HAVE_LIBZ */" >> "tool_hugehelp.c"
+      DEPENDS
+        generate-curl.1
+        "${CMAKE_CURRENT_SOURCE_DIR}/mkhelp.pl"
+        "${CMAKE_CURRENT_SOURCE_DIR}/tool_hugehelp.h"
+        "${CURL_ASCIIPAGE}"
+      VERBATIM)
+  else()
+    message(STATUS "Perl not found. Using the pre-built tool_hugehelp.c found in the source tree.")
+  endif()
   list(APPEND _curl_cfiles_gen "tool_hugehelp.c")
   list(APPEND _curl_hfiles_gen "tool_hugehelp.h")
+  list(APPEND _curl_definitions "USE_MANUAL")
 endif()
 
 if(CURL_CA_EMBED_SET)
   if(PERL_FOUND)
-    list(APPEND _curl_definitions "CURL_CA_EMBED")
     add_custom_command(OUTPUT "tool_ca_embed.c"
       COMMAND "${PERL_EXECUTABLE}" "${CMAKE_CURRENT_SOURCE_DIR}/mk-file-embed.pl" --var curl_ca_embed
         < "${CURL_CA_EMBED}" > "tool_ca_embed.c"
@@ -61,6 +64,7 @@ if(CURL_CA_EMBED_SET)
         "${CURL_CA_EMBED}"
       VERBATIM)
     list(APPEND _curl_cfiles_gen "tool_ca_embed.c")
+    list(APPEND _curl_definitions "CURL_CA_EMBED")
   else()
     message(WARNING "Perl not found. Will not embed the CA bundle.")
   endif()
index 78e2f812435b23d47b5085f31530ac8e6b698d7f..14202cf9450d0c0e823f206af47779d50f6f04fd 100644 (file)
@@ -141,6 +141,7 @@ curl_CPPFLAGS += -DUSE_MANUAL
 $(ASCIIPAGE):
        cd $(top_builddir)/docs && $(MAKE)
 
+if PERL
 if HAVE_LIBZ
 # This generates the tool_hugehelp.c file in both uncompressed and
 # compressed formats.
@@ -163,6 +164,19 @@ $(HUGE): $(ASCIIPAGE) $(MKHELP)
        echo '#include "tool_setup.h"' >> $(HUGE);                 \
        $(PERL) $(MKHELP) < $(ASCIIPAGE) >> $(HUGE) )
 endif
+else # PERL
+$(HUGE):
+       $(HUGECMD)(                                                \
+       if test ! -f "$(srcdir)/$(HUGE)"; then                     \
+         echo '/* !checksrc! disable COPYRIGHT all */' > $(HUGE); \
+         echo '#include "tool_hugehelp.h"' >> $(HUGE);            \
+         echo 'void hugehelp(void) {}' >> $(HUGE);                \
+         echo 'void showhelp(const char *trigger, const char *arg, const char *endarg)' >> $(HUGE); \
+         echo '{' >> $(HUGE);                                     \
+         echo '  (void)trigger; (void)arg; (void)endarg;' >> $(HUGE); \
+         echo '}' >> $(HUGE);                                     \
+       fi)
+endif
 
 else # USE_MANUAL
 # built-in manual has been disabled, make a blank file