kfreebsd: link against libfreebsd-glue

cpuset_getaffinity() is available on kfreebsd but not in libc but in
libfreebsd-glue. This code adds the library if kfreebsd is detected so
cpuset_getaffinity() can be used.
Without it tuklib_cpucores will detect `cpuset' because the compile test
succeeds and later it fails at link phase.

Patch-Name: kfreebsd-link-against-libfreebsd-glue.patch
Signed-off-by: Sebastian Andrzej Siewior <sebastian@breakpoint.cc>
diff --git a/configure.ac b/configure.ac
index d17629e..9697fbd 100644
--- a/configure.ac
+++ b/configure.ac
@@ -39,6 +39,13 @@
 esac
 AM_CONDITIONAL([COND_W32], [test "$is_w32" = yes])
 
+# We need -lfreebsd-glue on kfreebsd
+case $host_os in
+	kfreebsd*-gnu* ) is_kfreebsd=yes ;;
+	*)               is_kfreebsd=no ;;
+esac
+AM_CONDITIONAL([COND_NEED_FREEBSD_GLUE], [test "$is_kfreebsd" = yes])
+
 # We need to use $EXEEXT with $(LN_S) when creating symlinks to
 # executables. Cygwin is an exception to this, since it is recommended
 # that symlinks don't have the .exe suffix. To make this work, we
diff --git a/src/liblzma/Makefile.am b/src/liblzma/Makefile.am
index 24d9c26..13624d0 100644
--- a/src/liblzma/Makefile.am
+++ b/src/liblzma/Makefile.am
@@ -32,6 +32,10 @@
 	-Wl,--version-script=$(top_srcdir)/src/liblzma/liblzma.map
 endif
 
+if COND_NEED_FREEBSD_GLUE
+liblzma_la_LDFLAGS += -lfreebsd-glue
+endif
+
 liblzma_la_SOURCES += ../common/tuklib_physmem.c
 
 if COND_THREADS