build: if no perl, fix to use the pre-built hugehelp, if present

- 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 0035ff45c5 #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 137aecfbf1 #13514
  Follow-up to 541321507e #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 25119fbaaa #18104

Closes #18118
This commit is contained in:
Viktor Szakats 2025-07-31 16:38:34 +02:00
parent 18e00c8ed0
commit 54da6f5a32
No known key found for this signature in database
GPG key ID: B5ABD165E2AEF201
6 changed files with 63 additions and 54 deletions

View 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()

View 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