]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
configure: find cflags and libs for fts on musl
authorDoan Tran Cong Danh <congdanhqx@gmail.com>
Wed, 6 Nov 2019 11:35:12 +0000 (18:35 +0700)
committerDaniel Molkentin <daniel@molkentin.de>
Sun, 10 Nov 2019 00:47:30 +0000 (01:47 +0100)
Signed-off-by: Doan Tran Cong Danh <congdanhqx@gmail.com>
Makefile
configure

index 31545899dc8f4094cd8685684b69a0976d13119b..f9b42b9676a26e45d6eff3aadce860b1ce737a3c 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -62,7 +62,7 @@ install/util.o: install/util.c install/util.h install/macro.h install/log.h
 install/strv.o: install/strv.c install/strv.h install/util.h install/macro.h install/log.h
 
 install/dracut-install: $(DRACUT_INSTALL_OBJECTS)
-       $(CC) $(LDFLAGS) -o $@ $(DRACUT_INSTALL_OBJECTS) $(LDLIBS) $(KMOD_LIBS)
+       $(CC) $(LDFLAGS) -o $@ $(DRACUT_INSTALL_OBJECTS) $(LDLIBS) $(FTS_LIBS) $(KMOD_LIBS)
 
 logtee: logtee.c
        $(CC) $(LDFLAGS) -o $@ $<
index b55fb6090a90186fcd3f625cf30fd9f59b50b00a..3f724ef220df6a9238eb76ccb3ce00fb19ca7fc3 100755 (executable)
--- a/configure
+++ b/configure
@@ -7,6 +7,7 @@ prefix=/usr
 
 enable_documentation=yes
 
+CC="${CC:-cc}"
 PKG_CONFIG="${PKG_CONFIG:-pkg-config}"
 
 # Little helper function for reading args from the commandline.
@@ -57,6 +58,48 @@ if ! ${PKG_CONFIG} --exists --print-errors " libkmod >= 23 "; then
     exit 1
 fi
 
+cat <<EOF >conftest.c
+#include <fts.h>
+int main() {
+       return 0;
+}
+EOF
+
+${CC} $CFLAGS $LDFLAGS conftest.c >/dev/null 2>&1
+ret=$?
+rm -f conftest.c a.out
+
+# musl doesn't have fts.h included
+if test $ret -ne 0; then
+       echo "dracut needs fts development files." >&2
+       exit 1
+fi
+
+cat <<EOF >conftest.c
+#include <fts.h>
+int main(void) {
+       fts_open(0, 0, 0);
+       return 0;
+}
+EOF
+
+found=no
+for lib in "-lc" "-lfts"; do
+       ${CC} $CFLAGS -Wl,$lib $LDFLAGS conftest.c >/dev/null 2>&1
+       ret=$?
+       if test $ret -eq 0; then
+               FTS_LIBS="$lib"
+               found=yes
+               break;
+       fi
+done
+rm -f conftest.c a.out
+
+if test $found = no; then
+       echo "dracut couldn't find usable fts library" >&2
+       exit 1
+fi
+
 cat > Makefile.inc.$$ <<EOF
 prefix ?= ${prefix}
 libdir ?= ${libdir:-${prefix}/lib}
@@ -68,6 +111,7 @@ enable_documentation ?= ${enable_documentation:-yes}
 bindir ?= ${bindir:-${prefix}/bin}
 KMOD_CFLAGS ?= $(${PKG_CONFIG} --cflags " libkmod >= 23 ")
 KMOD_LIBS ?= $(${PKG_CONFIG} --libs " libkmod >= 23 ")
+FTS_LIBS ?= ${FTS_LIBS}
 EOF
 
 {