From 54400c2e0c86acce56e13acc260cc8bf7ee28719 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dag-Erling=20Sm=C3=B8rgrav?= Date: Fri, 3 May 2024 01:20:31 +0200 Subject: [PATCH] autotools: Simplify handling of `SIZEOF_VOID_P`. --- expat/buildconf.sh | 23 +------------------ .../autotools/expat-config-version.cmake.in | 6 ++--- expat/configure.ac | 16 +++++-------- 3 files changed, 10 insertions(+), 35 deletions(-) diff --git a/expat/buildconf.sh b/expat/buildconf.sh index 5e2b3269..1b4dc699 100755 --- a/expat/buildconf.sh +++ b/expat/buildconf.sh @@ -31,25 +31,4 @@ set -e -# File expat_config.h.in (as generated by autoheader by autoreconf) contains -# macro SIZEOF_VOID_P which is (1) not really needed by Expat as of today and -# (2) a problem to "multilib" systems with one shared installed -# /usr/include/expat_config.h for two Expats with different "void *" sizes -# installed in e.g. /usr/lib32 and /usr/lib64. Hence we patch macro -# SIZEOF_VOID_P out of template expat_config.h.in so that configure will -# not put SIZEOF_VOID_P in the eventual expat_config.h. -patch_expat_config_h_in() { - local filename="$1" - local sizeof_void_p_line_number="$(grep -F -n SIZEOF_VOID_P "${filename}" | awk -F: '{print $1}')" - [[ ${sizeof_void_p_line_number} =~ ^[0-9]+$ ]] # cheap assert - local first_line_to_delete=$(( sizeof_void_p_line_number - 1 )) - local last_line_to_delete=$(( sizeof_void_p_line_number + 1 )) - # Note: Avoiding "sed -i" only for macOS portability. - local tempfile="$(mktemp)" - sed "${first_line_to_delete},${last_line_to_delete}d" "${filename}" > "${tempfile}" - mv "${tempfile}" "${filename}" -} - -autoreconf --warnings=all --install --verbose "$@" - -patch_expat_config_h_in expat_config.h.in +exec autoreconf --warnings=all --install --verbose "$@" diff --git a/expat/cmake/autotools/expat-config-version.cmake.in b/expat/cmake/autotools/expat-config-version.cmake.in index f880e638..17ab1924 100644 --- a/expat/cmake/autotools/expat-config-version.cmake.in +++ b/expat/cmake/autotools/expat-config-version.cmake.in @@ -53,13 +53,13 @@ endif() # if the installed or the using project don't have CMAKE_SIZEOF_VOID_P set, ignore it: -if("${CMAKE_SIZEOF_VOID_P}" STREQUAL "" OR "@ac_cv_sizeof_void_p@" STREQUAL "") +if("${CMAKE_SIZEOF_VOID_P}" STREQUAL "" OR "@SIZEOF_VOID_P@" STREQUAL "") return() endif() # check that the installed version has the same 32/64bit-ness as the one which is currently searching: -if(NOT CMAKE_SIZEOF_VOID_P STREQUAL "@ac_cv_sizeof_void_p@") - math(EXPR installedBits "@ac_cv_sizeof_void_p@ * 8") +if(NOT CMAKE_SIZEOF_VOID_P STREQUAL "@SIZEOF_VOID_P@") + math(EXPR installedBits "@SIZEOF_VOID_P@ * 8") set(PACKAGE_VERSION "${PACKAGE_VERSION} (${installedBits}bit)") set(PACKAGE_VERSION_UNSUITABLE TRUE) endif() diff --git a/expat/configure.ac b/expat/configure.ac index 9d28d79a..1d0954b7 100644 --- a/expat/configure.ac +++ b/expat/configure.ac @@ -403,7 +403,6 @@ LIBDIR_BASENAME="$(basename "${libdir}")" SO_MAJOR="$(expr "${LIBCURRENT}" - "${LIBAGE}")" SO_MINOR="${LIBAGE}" SO_PATCH="${LIBREVISION}" -AC_CHECK_SIZEOF([void *]) # sets ac_cv_sizeof_void_p AC_SUBST([EXPAT_ATTR_INFO]) AC_SUBST([EXPAT_DTD]) AC_SUBST([EXPAT_LARGE_SIZE]) @@ -416,16 +415,13 @@ AC_SUBST([LIBDIR_BASENAME]) AC_SUBST([SO_MAJOR]) AC_SUBST([SO_MINOR]) AC_SUBST([SO_PATCH]) -AC_SUBST([ac_cv_sizeof_void_p]) -dnl Protect against generating an expat_config.h that would break multilib -AS_IF([grep -F -q SIZEOF_VOID_P "${srcdir}"/expat_config.h.in], - [AC_MSG_ERROR( - [Plain autoreconf/autoheader does not cut it, - please use ./buildconf.sh or imitate its effect - through other means, so that file expat_config.h.in - no longer defines macro SIZEOF_VOID_P, as that would - break multilib support. Thank you.])]) +dnl The canonical way of doing this is AC_CHECK_SIZEOF(void *), but +dnl that adds SIZEOF_VOID_P to expat_config.h.in, making it difficult +dnl to have 32-bit and 64-bit versions of libexpat installed on the +dnl same system with a single, shared copy of the header. +AC_COMPUTE_INT(SIZEOF_VOID_P, [sizeof(void *)]) +AC_SUBST([SIZEOF_VOID_P]) dnl write the Automake flags we set AC_SUBST([AM_CPPFLAGS])