summaryrefslogtreecommitdiff
path: root/dev-util/debugedit/files/debugedit-5.0-musl-error.h-fix.patch
blob: 4c7f239111082070d722b84a762e71fe60b41b2e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# musl doesn't provide error.h as a result debugedit is failing to build on
# musl.
#
# With advice from developer Anthony G. Basile <blueness@gentoo.org> I went
# with creating a define that redefines the err function. The major
# improvements over the previous implementation is that this time the patch is
# smaller and more readable compared to previous implementation.
#
# Closes: https://bugs.gentoo.org/714206
--- a/configure.ac
+++ b/configure.ac
@@ -57,6 +57,8 @@ PKG_CHECK_MODULES([LIBDW], [libdw])

 # Checks for header files.
 AC_CHECK_HEADERS([fcntl.h inttypes.h limits.h malloc.h stddef.h stdint.h stdlib.h string.h unistd.h])
+AC_CHECK_HEADERS([error.h],
+		 [AC_DEFINE(HAVE_ERROR_H, 1, [has error.h -- non musl system])])

 # Checks for typedefs, structures, and compiler characteristics.
 AC_CHECK_HEADER_STDBOOL
--- a/tools/debugedit.c
+++ b/tools/debugedit.c
@@ -25,7 +25,12 @@
 #include <byteswap.h>
 #include <endian.h>
 #include <errno.h>
+#ifdef HAVE_ERROR_H
 #include <error.h>
+#else
+#include <err.h>
+#define error(status, errno, ...) err(status, __VA_ARGS__)
+#endif
 #include <limits.h>
 #include <string.h>
 #include <stdlib.h>
--- a/tools/sepdebugcrcfix.c
+++ b/tools/sepdebugcrcfix.c
@@ -29,7 +29,12 @@
 #include <endian.h>
 #include <stdio.h>
 #include <stdlib.h>
+#ifdef HAVE_ERROR_H
 #include <error.h>
+#else
+#include <err.h>
+#define error(status, errno, ...) err(status, __VA_ARGS__)
+#endif
 #include <libelf.h>
 #include <gelf.h>