1 # Copyright © 2023-2024 Nick Bowler
3 # Monkey patches for gnulib macros.
5 # License WTFPL2: Do What The Fuck You Want To Public License, version 2.
6 # This is free software: you are free to do what the fuck you want to.
7 # There is NO WARRANTY, to the extent permitted by law.
11 # Apply all the patches described below. Should be expanded before AC_INIT.
12 AC_DEFUN([DX_PATCH_GNULIB],
13 [m4_foreach_w([patch], m4_defn([_DX_GL_PATCHES]),
14 [m4_indir([_DX_GL_PATCH(]m4_defn([patch])[)])])])
16 m4_define([_DX_GL_PATCHES])
17 m4_define([_DX_GL_PATCH],
18 [m4_define([_DX_GL_PATCH($1)], [$2])m4_define([_DX_GL_PATCHES],
19 m4_defn([_DX_GL_PATCHES])[ $1])])
21 # Patch if ! ... constructs produced by gnulib conditional dependencies
22 # as these fail in Solaris 10 /bin/sh.
23 _DX_GL_PATCH([gl-cond-deps],
24 [DX_PATCH_MACRO([gl_INIT],
25 [if ! *\(.*gnulib_enabled[^;]*\); then],
26 [if \1; then :; else])])
28 # Patch old versions of threadlib.m4, which have a quoting bug preventing
29 # correct determination of PTHREAD_IN_USE_DETECTION_HARD on Solaris 9 and
30 # earlier. If this is set incorrectly, libcdecl will crash on error.
31 _DX_GL_PATCH([gl-threadlib-solaris-fix],
32 [DX_PATCH_MACRO([gl_PTHREADLIB_BODY],
33 [solaris2\.\[1-9\]], [solaris2.@<:@1-9@:>@])])
35 # Patch old versions of threadlib to default to native Windows threads.
36 # This is the default behaviour in current upstream gnulib, and avoids
37 # pulling in extra libraries by default on MinGW.
38 _DX_GL_PATCH([gl-threadlib-mingw-default],
39 [DX_PATCH_MACRO([gl_THREADLIB_EARLY_BODY],
40 [\[gl_use_winpthreads_default=\]],
41 [[gl_use_winpthreads_default=no]])])
43 # Remove silly warning flag probes that are included unconditionally in newer
44 # gnulib and bloat downstream configure scripts for no real reason.
45 _DX_GL_PATCH([gl-no-warnings],
46 [m4_ifdef([gl_CC_GNULIB_WARNINGS], [AC_DEFUN([gl_CC_GNULIB_WARNINGS])])])
48 # Avoid gnulib stdint.m4 from forcing HAVE_(UNSIGNED_)LONG_LONG_INT as this
49 # breaks anything which actually tries to use AC_TYPE_LONG_LONG_INT to work
50 # with missing long long, and is otherwise pointless.
52 # Gnulib itself doesn't care about these definitions and unconditionally uses
53 # long long. So by itself, this won't fix any failures in Gnulib due to an
54 # actually missing 'long long' but also should not create new problems.
55 _DX_GL_PATCH([stdint-no-fake-longlong],
56 [DX_PATCH_MACRO([gl_STDINT_H],
57 [AC_DEFINE(\[HAVE[_UNSIGNED]*_LONG_LONG_INT\][^)]*.], [dnl])])