]> git.draconx.ca Git - dxcommon.git/blobdiff - m4/base.m4
DX_C_ALIGNAS: Work around bash-5 parsing bug.
[dxcommon.git] / m4 / base.m4
index 86d6b842c0d6098fd29323945c7545ad2bacd4e5..4dc0d146520ddc86b1ddf8c2f354b8da39eb007a 100644 (file)
@@ -1,10 +1,10 @@
-dnl Copyright © 2012, 2014 Nick Bowler
-dnl
-dnl Base directory handling for dxcommon.
-dnl
-dnl License WTFPL2: Do What The Fuck You Want To Public License, version 2.
-dnl This is free software: you are free to do what the fuck you want to.
-dnl There is NO WARRANTY, to the extent permitted by law.
+# Copyright © 2012, 2014, 2021, 2023-2024 Nick Bowler
+#
+# Basic macros for dxcommon.
+#
+# License WTFPL2: Do What The Fuck You Want To Public License, version 2.
+# This is free software: you are free to do what the fuck you want to.
+# There is NO WARRANTY, to the extent permitted by law.
 
 AC_PREREQ([2.64])
 
@@ -60,9 +60,32 @@ AC_DEFUN_ONCE([DX_INIT], [m4_do(
   [_DX_SET_BASEDIR([$1])],
   [AC_SUBST([DX_BASEDIR])],
   [AC_CONFIG_COMMANDS_PRE(
-    [[DX_BASEDIR]="AS_ESCAPE(m4_dquote(m4_defn([_DX_BASEDIR])))"])])])
+    [[DX_BASEDIR]="\${top_srcdir}/AS_ESCAPE(
+      m4_dquote(m4_defn([_DX_BASEDIR])))"])])])
 
 dnl DX_BASEDIR
 dnl
 dnl This macro expands to the dxcommon base directory, as a quoted string.
 AC_DEFUN([DX_BASEDIR], [m4_ignore(DX_INIT())m4_defn([_DX_BASEDIR])])
+
+# DX_RUN_LOG(command)
+#
+# Run a command, logging all of the command, its output, and overall
+# exit status to config.log.  The expansion of this macro is a single
+# complex shell command suitable for use in shell conditionals.
+AC_DEFUN([DX_RUN_LOG],
+[{ _dx_shopt=$-
+( set -x
+$1
+) >&AS_MESSAGE_LOG_FD 2>&1
+_dx_status=$?
+test x"$-" = x"$_dx_shopt" || set +x # work around DJGPP subshell bug
+AS_ECHO(["\$? = $_dx_status"]) >&AS_MESSAGE_LOG_FD
+test $_dx_status = 0; } 2>/dev/null])
+
+# DX_PATCH_MACRO([macro-name], [regexp], [replacement])
+#
+# Patches the definition of macro-name by replacing substrings that match
+# the given regexp (a la m4_bpatsubst).
+AC_DEFUN([DX_PATCH_MACRO], [m4_ifdef([$1],
+  [m4_define([$1], m4_bpatsubst(m4_dquote(m4_defn([$1])), [$2], [$3]))])])