cross-tools: fts has different types for cmp routine

fts has different types for its compare rotuine. Other systems, not
4.4BSD based, have a non-const version. Before we tested against
__GLIBC__, but now we test against __linux__ because that's Linux's API
and musl doesn't define __GLIBC__.

In addition, link against libftl on this platform since musl doesn't
include ftl routines in libc, but rather in libftl.

Co-authored-by:		Val Packett <val@packett.cool>
Sponsored by:		Netflix
Pull Request:		https://github.com/freebsd/freebsd-src/pull/1066
Reviewed by:		val_packett.cool
Differential Revision:	https://reviews.freebsd.org/D45349
This commit is contained in:
Warner Losh 2024-05-26 11:38:30 -06:00
parent 9c975a0d90
commit 364c014d9b
4 changed files with 7 additions and 3 deletions

View file

@ -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

View file

@ -1355,7 +1355,7 @@ int main(int argc, char *argv[])
#include <fts.h>
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)

View file

@ -50,6 +50,10 @@ CFLAGS+= -I${SRCTOP}/tools/build/cross-build/include/linux
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

View file

@ -745,7 +745,7 @@ usage(void)
}
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)