···
1
-
From ea1bc0fcfd33191002c5d1f7072c1c02bb7ec4af Mon Sep 17 00:00:00 2001
2
-
From: Alyssa Ross <hi@alyssa.is>
3
-
Date: Thu, 14 Nov 2019 15:45:46 +0000
4
-
Subject: [PATCH] Fix build on BSD systems
6
-
I tested FreeBSD, DragonflyBSD, NetBSD and OpenBSD and the endian
7
-
macros weren't necessary (and in fact caused errors) on all of them.
9
-
Because OpenBSD ships with an ancient GCC that doesn't support the
10
-
checked addition/multiplication builtins, the build there would fail
11
-
unless built with CC=cc or CC=clang. I changed configure.ac to prefer
12
-
cc over gcc, so that the distribution's compiler preference is
13
-
respected. (The default is [gcc cc]). I had to move AC_PROG_CC above
14
-
LT_INIT because otherwise LT_INIT would run AC_PROG_CC first, and we
15
-
wouldn't have a chance to use non-default parameters.
18
-
include/util/compat.h | 13 +++++--------
19
-
lib/common/dirstack.c | 1 +
20
-
lib/common/mkdir_p.c | 2 +-
21
-
4 files changed, 8 insertions(+), 10 deletions(-)
23
-
diff --git a/configure.ac b/configure.ac
24
-
index 018b3f6..19ea0ed 100644
27
-
@@ -3,8 +3,8 @@ AC_INIT([squashfs-tools-ng], [0.7], [goliath@infraroot.at], squashfs-tools-ng)
28
-
AC_CONFIG_MACRO_DIR([m4])
29
-
AM_INIT_AUTOMAKE([foreign dist-xz subdir-objects])
30
-
AM_SILENT_RULES([yes])
31
-
+AC_PROG_CC([cc gcc clang])
37
-
diff --git a/include/util/compat.h b/include/util/compat.h
38
-
index 74d0b6f..f53fd0e 100644
39
-
--- a/include/util/compat.h
40
-
+++ b/include/util/compat.h
49
-
#if defined(__APPLE__)
50
-
#include <libkern/OSByteOrder.h>
53
-
#define le32toh(x) OSSwapLittleToHostInt32(x)
54
-
#define le16toh(x) OSSwapLittleToHostInt16(x)
55
-
#define le64toh(x) OSSwapLittleToHostInt64(x)
56
-
-#elif defined(__OpenBSD__)
57
-
+#elif defined(__DragonFly__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
58
-
#include <sys/endian.h>
59
-
-#elif defined(__NetBSD__) || defined(__FreeBSD__) || defined(__DragonFly__)
60
-
-#include <sys/endian.h>
62
-
-#define le16toh(x) letoh16(x)
63
-
-#define le32toh(x) letoh32(x)
64
-
-#define le64toh(x) letoh64(x)
65
-
#elif defined(_WIN32) || defined(__WINDOWS__)
66
-
#define htole16(x) (x)
67
-
#define htole32(x) (x)
70
-
#include <sys/types.h>
71
-
#include <sys/stat.h>
72
-
-#include <sys/sysmacros.h>
75
-
#endif /* COMPAT_H */
76
-
diff --git a/lib/common/dirstack.c b/lib/common/dirstack.c
77
-
index 8f73898..f8d1278 100644
78
-
--- a/lib/common/dirstack.c
79
-
+++ b/lib/common/dirstack.c
81
-
* Copyright (C) 2019 David Oberhollenzer <goliath@infraroot.at>
84
-
+#include "util/compat.h"
88
-
diff --git a/lib/common/mkdir_p.c b/lib/common/mkdir_p.c
89
-
index cb433b3..95187ba 100644
90
-
--- a/lib/common/mkdir_p.c
91
-
+++ b/lib/common/mkdir_p.c
96
-
-#include <alloca.h>
97
-
+#include <stdlib.h>