From 6d6c20ba0b37d2ebf2487cdc973ae0489c33616f Mon Sep 17 00:00:00 2001
From: Chris Roberts <cpr420@gmail.com>
Date: Tue, 1 Feb 2022 17:38:34 -0700
Subject: don't use syscalls.c or the linker script on Haiku


diff --git a/configure.ac b/configure.ac
index a0e343c..416d327 100644
--- a/configure.ac
+++ b/configure.ac
@@ -23,6 +23,7 @@ AC_PREFIX_DEFAULT(/usr)
 AM_INIT_AUTOMAKE([-Wall foreign 1.11 dist-xz subdir-objects])
 AM_SILENT_RULES([yes])
 
+AC_CANONICAL_HOST
 AC_PROG_CC
 AM_PROG_CC_C_O
 AC_USE_SYSTEM_EXTENSIONS
@@ -53,6 +54,11 @@ fi
 LT_REVISION=$(printf "%d%d%02d" "$1" "$2" "$3")
 AC_SUBST(LT_REVISION)
 
+AS_CASE([$host_os],
+	[linux], [os_linux=yes],
+)
+AM_CONDITIONAL([OS_LINUX], [test "x$os_linux" = "xyes"])
+
 AC_CONFIG_COMMANDS([include/attr],
 	[dnl
 	rm -rf include/attr
diff --git a/libattr/Makemodule.am b/libattr/Makemodule.am
index 4b3720c..c9422f4 100644
--- a/libattr/Makemodule.am
+++ b/libattr/Makemodule.am
@@ -8,19 +8,32 @@ LT_CURRENT = 2
 LT_AGE = 1
 LTVERSION = $(LT_CURRENT):$(LT_REVISION):$(LT_AGE)
 
-libattr_la_DEPENDENCIES = exports libattr/libattr.lds
+libattr_la_DEPENDENCIES = \
+	exports
+if OS_LINUX
+libattr_la_DEPENDENCIES += \
+	libattr/libattr.lds
+endif
 libattr_la_SOURCES = \
 	libattr/attr_copy_action.c \
 	libattr/attr_copy_check.c \
 	libattr/attr_copy_fd.c \
 	libattr/attr_copy_file.c \
 	libattr/libattr.c \
-	libattr/syscalls.c \
 	libattr/libattr.h
+if OS_LINUX
+libattr_la_SOURCES += \
+	libattr/syscalls.c
+endif
 libattr_la_CFLAGS = -include libattr/libattr.h
 libattr_la_LDFLAGS = \
 	-Wl,--version-script,$(top_srcdir)/exports \
-	-Wl,$(top_srcdir)/libattr/libattr.lds \
 	-version-info $(LTVERSION)
+if OS_LINUX
+libattr_la_LDFLAGS += \
+	-Wl,$(top_srcdir)/libattr/libattr.lds
+endif
 
+if OS_LINUX
 EXTRA_DIST += libattr/libattr.lds
+endif
-- 
2.30.2


From 73213834b93d4ad347aee84aac92ef47ca31ac91 Mon Sep 17 00:00:00 2001
From: Chris Roberts <cpr420@gmail.com>
Date: Tue, 1 Feb 2022 17:47:41 -0700
Subject: check for libgen.h to use basename()


diff --git a/configure.ac b/configure.ac
index 416d327..16ed1ac 100644
--- a/configure.ac
+++ b/configure.ac
@@ -36,6 +36,8 @@ AC_SYS_LARGEFILE
 AM_PROG_AR
 LT_INIT
 
+AC_CHECK_HEADER(posix/libgen.h)
+
 AM_GNU_GETTEXT_VERSION([0.18.2])
 AM_GNU_GETTEXT([external])
 
diff --git a/include/config.h.in b/include/config.h.in
index 1f888f5..244be56 100644
--- a/include/config.h.in
+++ b/include/config.h.in
@@ -49,6 +49,9 @@
 /* Define to 1 if you have the <memory.h> header file. */
 #undef HAVE_MEMORY_H
 
+/* Define to 1 if you have the <posix/libgen.h> header file. */
+#undef HAVE_POSIX_LIBGEN_H
+
 /* Define to 1 if you have the <stdint.h> header file. */
 #undef HAVE_STDINT_H
 
diff --git a/tools/attr.c b/tools/attr.c
index 312aef1..4501d42 100644
--- a/tools/attr.c
+++ b/tools/attr.c
@@ -31,6 +31,10 @@
 
 #include <attr/attributes.h>
 
+#ifdef HAVE_POSIX_LIBGEN_H
+#include <posix/libgen.h>
+#endif
+
 #include "misc.h"
 
 #define	SETOP		1		/* do a SET operation */
diff --git a/tools/getfattr.c b/tools/getfattr.c
index abdd0d4..53cc9c6 100644
--- a/tools/getfattr.c
+++ b/tools/getfattr.c
@@ -32,6 +32,10 @@
 #include <libgen.h>
 #include <sys/xattr.h>
 
+#ifdef HAVE_POSIX_LIBGEN_H
+#include <posix/libgen.h>
+#endif
+
 #include "walk_tree.h"
 #include "misc.h"
 
diff --git a/tools/setfattr.c b/tools/setfattr.c
index b2e1df0..072ef7c 100644
--- a/tools/setfattr.c
+++ b/tools/setfattr.c
@@ -32,6 +32,10 @@
 #include <sys/xattr.h>
 #include <errno.h>
 
+#ifdef HAVE_POSIX_LIBGEN_H
+#include <posix/libgen.h>
+#endif
+
 #include "misc.h"
 
 #define CMD_LINE_OPTIONS "n:x:v:h"
-- 
2.30.2

