@@ -1,103 +0,0 @@
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
5−
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.
8−
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.
16−---
17− configure.ac | 2 +-
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(-)
22−
23−diff --git a/configure.ac b/configure.ac
24−index 018b3f6..19ea0ed 100644
25−--- a/configure.ac
26−+++ b/configure.ac
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])
32− LT_INIT
33−-AC_PROG_CC
34− AC_PROG_CC_C99
35− AC_PROG_INSTALL
36− AC_SYS_LARGEFILE
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
41−@@ -7,6 +7,10 @@
42− #ifndef COMPAT_H
43− #define COMPAT_H
44−
45−+#ifndef __linux__
46−+#define O_PATH 0
47−+#endif
48−+
49− #if defined(__APPLE__)
50− #include <libkern/OSByteOrder.h>
51−
52−@@ -17,14 +21,8 @@
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>
61−-
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)
68−@@ -89,7 +87,6 @@
69− #else
70− #include <sys/types.h>
71− #include <sys/stat.h>
72−-#include <sys/sysmacros.h>
73− #endif
74−
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
80−@@ -5,6 +5,7 @@
81− * Copyright (C) 2019 David Oberhollenzer <goliath@infraroot.at>
82− */
83− #include "common.h"
84−+#include "util/compat.h"
85−
86− #include <string.h>
87− #include <stdlib.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
92−@@ -7,7 +7,7 @@
93− #include "common.h"
94−
95− #include <string.h>
96−-#include <alloca.h>
97−+#include <stdlib.h>
98− #include <stdio.h>
99− #include <errno.h>
100−
101−--
102−2.23.0
103−