--- src/util/xmlconfig.c.orig	2022-09-30 20:20:44.000000000 -0700
+++ src/util/xmlconfig.c	2022-09-30 20:26:58.000000000 -0700
@@ -65,6 +65,15 @@
 #define PATH_MAX 4096
 #endif
 
+#ifdef __APPLE__
+#include <AvailabilityMacros.h>
+#endif
+
+#define HAVE_NEW_SCANDIR
+#if (defined(MAC_OS_X_VERSION_MAX_ALLOWED) && MAC_OS_X_VERSION_MAX_ALLOWED < 1080)
+#undef HAVE_NEW_SCANDIR
+#endif
+
 static bool
 be_verbose(void)
 {
@@ -1000,7 +1009,11 @@
 }
 
 static int
+#ifdef HAVE_NEW_SCANDIR
 scandir_filter(const struct dirent *ent)
+#else
+scandir_filter(struct dirent *ent)
+#endif
 {
 #ifndef DT_REG /* systems without d_type in dirent results */
    struct stat st;
