diff --git a/contrib/mandoc/config.h b/contrib/mandoc/config.h --- a/contrib/mandoc/config.h +++ b/contrib/mandoc/config.h @@ -13,7 +13,7 @@ #define HAVE_ENDIAN 0 #define HAVE_ERR 1 #define HAVE_FTS 1 -#if defined(__GLIBC__) || defined(__APPLE__) +#if defined(__linux__) || defined(__APPLE__) #define HAVE_FTS_COMPARE_CONST 0 #else #define HAVE_FTS_COMPARE_CONST 1 diff --git a/lib/libpmc/pmu-events/jevents.c b/lib/libpmc/pmu-events/jevents.c --- a/lib/libpmc/pmu-events/jevents.c +++ b/lib/libpmc/pmu-events/jevents.c @@ -1355,7 +1355,7 @@ #include static int -#if defined(__GLIBC__) || defined(__APPLE__) +#if defined(__linux__) || defined(__APPLE__) fts_compare(const FTSENT **a, const FTSENT **b) #else fts_compare(const FTSENT * const *a, const FTSENT * const *b) diff --git a/tools/build/mk/Makefile.boot b/tools/build/mk/Makefile.boot --- a/tools/build/mk/Makefile.boot +++ b/tools/build/mk/Makefile.boot @@ -50,6 +50,10 @@ CFLAGS+= -D_GNU_SOURCE=1 # Needed for sem_init, etc. on Linux (used by usr.bin/sort) LDADD+= -pthread +.if exists(/usr/lib/libfts.so) || exists(/usr/lib/libfts.a) || exists(/lib/libfts.so) || exists(/lib/libfts.a) +# Needed for fts_open, etc. on musl (used by usr.bin/grep) +LDADD+= -lfts +.endif .elif ${.MAKE.OS} == "Darwin" CFLAGS+= -D_DARWIN_C_SOURCE=1 diff --git a/usr.sbin/kldxref/kldxref.c b/usr.sbin/kldxref/kldxref.c --- a/usr.sbin/kldxref/kldxref.c +++ b/usr.sbin/kldxref/kldxref.c @@ -745,7 +745,7 @@ } static int -#if defined(__GLIBC__) || defined(__APPLE__) +#if defined(__linux__) || defined(__APPLE__) compare(const FTSENT **a, const FTSENT **b) #else compare(const FTSENT *const *a, const FTSENT *const *b)