Add an implementation of the fts_*() functions
The fts_*() functions are optional in uClibc, and not compiled in our
default configuration. The best option would be to migrate this
elfutils code to the nftw family of functions, but it requires quite
So we have several options here:
*) Enable fts_*() functions in our default uClibc configuration. Not
nice since only one package needs them (the help text of uClibc
for fts_*() functions explicitly mention that they have been added
to be able to build elfutils).
*) Use gnulib, but it is quite heavy to setup, requires modifications
to configure.ac, and other things.
*) Copy the fts function from uClibc into elfutils source code. This
is the solution used below. uClibc is LGPL, and elfutils is
LGPL/GPL, so there should not be any licensing issue.
Of course, the fts_*() functions are only built if they are not
already provided by the C library.
Based on the former patch by Thomas Petazzoni.
[Vincent: tweak patch for 0.166]
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Signed-off-by: Vicente Olivert Riera <Vincent.Riera@imgtec.com>
diff -Nrup a/configure.ac b/configure.ac
--- a/configure.ac 2016-06-17 14:47:03.561704498 +0100
+++ b/configure.ac 2016-06-17 14:52:35.038200412 +0100
@@ -259,6 +259,10 @@ AC_ARG_ENABLE([progs],
AM_CONDITIONAL(ENABLE_PROGS, test "$enable_progs" = yes)
+AC_CHECK_HEADER([fts.h],
+ AC_DEFINE([HAVE_FTS_H], [], [Define if <fts.h> is available in C library]))
+AM_CONDITIONAL(HAVE_FTS, test "$ac_cv_header_fts_h" = yes)
diff -Nrup a/libdwfl/fts.c b/libdwfl/fts.c
--- a/libdwfl/fts.c 1970-01-01 01:00:00.000000000 +0100
+++ b/libdwfl/fts.c 2016-06-17 14:57:26.649912084 +0100
+ * Copyright (c) 1990, 1993, 1994
+ * The Regents of the University of California. All rights reserved.
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software