summaryrefslogtreecommitdiff
path: root/expat/buildconf.sh
diff options
context:
space:
mode:
authorSebastian Pipping <sebastian@pipping.org>2021-05-23 03:30:41 +0200
committerSebastian Pipping <sebastian@pipping.org>2021-05-23 15:43:56 +0200
commit779d147681f4ff3bf399f5c4f2d77a8f0d266db4 (patch)
tree101a908468f80d933ee3740f094f36b70682b5e8 /expat/buildconf.sh
parentfa12e73d0526546de349661d2076a74fd9e9f93d (diff)
downloadlibexpat-git-779d147681f4ff3bf399f5c4f2d77a8f0d266db4.tar.gz
Keep macro SIZEOF_VOID_P out of expat_config.h(.in) for multilib support
Diffstat (limited to 'expat/buildconf.sh')
-rwxr-xr-xexpat/buildconf.sh31
1 files changed, 27 insertions, 4 deletions
diff --git a/expat/buildconf.sh b/expat/buildconf.sh
index 174b6c07..5edbc565 100755
--- a/expat/buildconf.sh
+++ b/expat/buildconf.sh
@@ -1,4 +1,4 @@
-#! /bin/sh
+#! /usr/bin/env bash
# __ __ _
# ___\ \/ /_ __ __ _| |_
# / _ \\ /| '_ \ / _` | __|
@@ -6,8 +6,8 @@
# \___/_/\_\ .__/ \__,_|\__|
# |_| XML parser
#
-# Copyright (c) 2017 Sebastian Pipping <sebastian@pipping.org>
-# Copyright (c) 2018 Marco Maggi <marco.maggi-ipsu@poste.it>
+# Copyright (c) 2017-2021 Sebastian Pipping <sebastian@pipping.org>
+# Copyright (c) 2018 Marco Maggi <marco.maggi-ipsu@poste.it>
# Licensed under the MIT license:
#
# Permission is hereby granted, free of charge, to any person obtaining
@@ -29,4 +29,27 @@
# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
# USE OR OTHER DEALINGS IN THE SOFTWARE.
-exec autoreconf --warnings=all --install --verbose "$@"
+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="$(fgrep -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