]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
build: use `configurehelp.pm.in` with autotools and cmake
authorViktor Szakats <commit@vsz.me>
Fri, 6 Sep 2024 23:49:40 +0000 (01:49 +0200)
committerViktor Szakats <commit@vsz.me>
Sat, 21 Sep 2024 10:21:14 +0000 (12:21 +0200)
Before this patch, each build tool generated `tests/configurehelp.pm`
manually.

Ref: https://github.com/curl/curl/pull/14802#issuecomment-2332734326
Closes #14819

acinclude.m4
configure.ac
tests/CMakeLists.txt
tests/Makefile.am
tests/configurehelp.pm.in [new file with mode: 0644]

index c1408b10e3cf7e7c68eb018b885ab99a602420cc..67ea2d865ad33c3b0a99cefc11ae24f27b45694a 100644 (file)
@@ -1518,44 +1518,20 @@ AC_DEFUN([CURL_CHECK_PKGCONFIG], [
 ])
 
 
-dnl CURL_GENERATE_CONFIGUREHELP_PM
+dnl CURL_PREPARE_CONFIGUREHELP_PM
 dnl -------------------------------------------------
-dnl Generate test harness configurehelp.pm module, defining and
+dnl Prepare test harness configurehelp.pm module, defining and
 dnl initializing some perl variables with values which are known
 dnl when the configure script runs. For portability reasons, test
 dnl harness needs information on how to run the C preprocessor.
 
-AC_DEFUN([CURL_GENERATE_CONFIGUREHELP_PM], [
+AC_DEFUN([CURL_PREPARE_CONFIGUREHELP_PM], [
   AC_REQUIRE([AC_PROG_CPP])dnl
   tmp_cpp=`eval echo "$ac_cpp" 2>/dev/null`
   if test -z "$tmp_cpp"; then
     tmp_cpp='cpp'
   fi
-  cat >./tests/configurehelp.pm <<_EOF
-[@%:@] This is a generated file.  Do not edit.
-
-package configurehelp;
-
-use strict;
-use warnings;
-use Exporter;
-
-use vars qw(
-    @ISA
-    @EXPORT_OK
-    \$Cpreprocessor
-    );
-
-@ISA = qw(Exporter);
-
-@EXPORT_OK = qw(
-    \$Cpreprocessor
-    );
-
-\$Cpreprocessor = '$tmp_cpp';
-
-1;
-_EOF
+  AC_SUBST(CURL_CPP, $tmp_cpp)
 ])
 
 
index 6ec1699fd55a9ab2218d11243bd932c2dd7b12d6..784c0ce9fc91e1fadd9b88b9fa708f733d9ec3e5 100644 (file)
@@ -5274,6 +5274,8 @@ if test "x$want_curldebug_assumed" = "xyes" &&
   ac_configure_args="$ac_configure_args --enable-curldebug"
 fi
 
+CURL_PREPARE_CONFIGUREHELP_PM
+
 AC_CONFIG_FILES([\
   Makefile \
   docs/Makefile \
@@ -5289,6 +5291,7 @@ AC_CONFIG_FILES([\
   lib/libcurl.vers \
   tests/Makefile \
   tests/config \
+  tests/configurehelp.pm \
   tests/certs/Makefile \
   tests/certs/scripts/Makefile \
   tests/data/Makefile \
@@ -5305,8 +5308,6 @@ AC_CONFIG_FILES([\
 ])
 AC_OUTPUT
 
-CURL_GENERATE_CONFIGUREHELP_PM
-
 SUPPORT_PROTOCOLS_LOWER=`echo "$SUPPORT_PROTOCOLS" | tr A-Z a-z`
 
 AC_MSG_NOTICE([Configured to build curl/libcurl:
index 879f4db109c7a175dd0d318a6ebfbbd0efffb8d6..3a9e8e76ac271956299dc9dbf0e09ef9b8e2737d 100644 (file)
@@ -55,42 +55,24 @@ endfunction()
 
 # Create configurehelp.pm, used by tests needing to run the C preprocessor.
 if(MSVC OR CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID MATCHES "Clang")
-  set(_cpp_cmd "\"${CMAKE_C_COMPILER}\" -E")
+  set(CURL_CPP "\"${CMAKE_C_COMPILER}\" -E")
   if(APPLE AND CMAKE_OSX_SYSROOT)
-    set(_cpp_cmd "${_cpp_cmd} -isysroot ${CMAKE_OSX_SYSROOT}")
+    set(CURL_CPP "${CURL_CPP} -isysroot ${CMAKE_OSX_SYSROOT}")
   endif()
   # Add header directories, like autotools builds do.
   get_property(_include_dirs TARGET ${LIB_SELECTED} PROPERTY INCLUDE_DIRECTORIES)
   foreach(_include_dir IN LISTS _include_dirs)
-    set(_cpp_cmd "${_cpp_cmd} -I${_include_dir}")
+    set(CURL_CPP "${CURL_CPP} -I${_include_dir}")
   endforeach()
 else()
-  set(_cpp_cmd "cpp")
+  set(CURL_CPP "cpp")
 endif()
-file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/configurehelp.pm" "# This is a generated file.  Do not edit.
-
-package configurehelp;
-
-use strict;
-use warnings;
-use Exporter;
-
-use vars qw(
-    @ISA
-    @EXPORT_OK
-    \$Cpreprocessor
-    );
-
-@ISA = qw(Exporter);
-
-@EXPORT_OK = qw(
-    \$Cpreprocessor
-    );
-
-\$Cpreprocessor = '${_cpp_cmd}';
-
-1;
-")
+# Generate version script for the linker, for versioned symbols.
+# Consumed variable:
+#   CURL_CPP
+configure_file(
+  "${CMAKE_CURRENT_SOURCE_DIR}/configurehelp.pm.in"
+  "${CMAKE_CURRENT_BINARY_DIR}/configurehelp.pm" @ONLY)
 
 add_runtests(test-quiet     "-a -s")
 add_runtests(test-am        "-a -am")
index b4a406a97b48d84202276c06c7dafd9678a571cf..d3d5e804d41e6c705fd92f34ac50fa942c2c59fc 100644 (file)
@@ -95,8 +95,6 @@ EXTRA_DIST =        \
  $(TESTSCRIPTS)     \
  $(CURLPAGES)
 
-DISTCLEANFILES = configurehelp.pm
-
 # we have two variables here to make sure DIST_SUBDIRS won't get 'unit'
 # added twice as then targets such as 'distclean' misbehave and try to
 # do things twice in that subdir at times (and thus fails).
diff --git a/tests/configurehelp.pm.in b/tests/configurehelp.pm.in
new file mode 100644 (file)
index 0000000..626df2c
--- /dev/null
@@ -0,0 +1,45 @@
+#***************************************************************************
+#                                  _   _ ____  _
+#  Project                     ___| | | |  _ \| |
+#                             / __| | | | |_) | |
+#                            | (__| |_| |  _ <| |___
+#                             \___|\___/|_| \_\_____|
+#
+# Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
+#
+# This software is licensed as described in the file COPYING, which
+# you should have received as part of this distribution. The terms
+# are also available at https://curl.se/docs/copyright.html.
+#
+# You may opt to use, copy, modify, merge, publish, distribute and/or sell
+# copies of the Software, and permit persons to whom the Software is
+# furnished to do so, under the terms of the COPYING file.
+#
+# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+# KIND, either express or implied.
+#
+# SPDX-License-Identifier: curl
+#
+###########################################################################
+
+package configurehelp;
+
+use strict;
+use warnings;
+use Exporter;
+
+use vars qw(
+    @ISA
+    @EXPORT_OK
+    $Cpreprocessor
+    );
+
+@ISA = qw(Exporter);
+
+@EXPORT_OK = qw(
+    $Cpreprocessor
+    );
+
+$Cpreprocessor = '@CURL_CPP@';
+
+1;