erofs-utils: fuse: disable backtrace if unsupported

Let's enable backtrace conditionally since it's a GNU extension.

Link: https://lore.kernel.org/r/20201217090625.22738-1-hsiangkao@aol.com
Fixes: 5e35b75ad499 ("erofs-utils: introduce fuse implementation")
Reviewed-by: Li Guifu <bluce.lee@aliyun.com>
Signed-off-by: Gao Xiang <hsiangkao@aol.com>
diff --git a/configure.ac b/configure.ac
index d5fdfb8..28926c3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -96,6 +96,7 @@
 # Checks for header files.
 AC_CHECK_HEADERS(m4_flatten([
 	dirent.h
+	execinfo.h
 	fcntl.h
 	getopt.h
 	inttypes.h
@@ -147,7 +148,7 @@
    #include <unistd.h>])
 
 # Checks for library functions.
-AC_CHECK_FUNCS([fallocate gettimeofday memset realpath strdup strerror strrchr strtoull])
+AC_CHECK_FUNCS([backtrace fallocate gettimeofday memset realpath strdup strerror strrchr strtoull])
 
 # Configure libuuid
 AS_IF([test "x$with_uuid" != "xno"], [
diff --git a/fuse/main.c b/fuse/main.c
index 1e24efe..c162912 100644
--- a/fuse/main.c
+++ b/fuse/main.c
@@ -6,7 +6,6 @@
  */
 #include <stdlib.h>
 #include <string.h>
-#include <execinfo.h>
 #include <signal.h>
 #include <libgen.h>
 #include <fuse.h>
@@ -168,6 +167,9 @@
 	return 1;
 }
 
+#if defined(HAVE_EXECINFO_H) && defined(HAVE_BACKTRACE)
+#include <execinfo.h>
+
 static void signal_handle_sigsegv(int signal)
 {
 	void *array[10];
@@ -187,7 +189,7 @@
 	erofs_dump("========================================\n");
 	abort();
 }
-
+#endif
 
 int main(int argc, char *argv[])
 {
@@ -197,11 +199,13 @@
 	erofs_init_configure();
 	fprintf(stderr, "%s %s\n", basename(argv[0]), cfg.c_version);
 
+#if defined(HAVE_EXECINFO_H) && defined(HAVE_BACKTRACE)
 	if (signal(SIGSEGV, signal_handle_sigsegv) == SIG_ERR) {
 		fprintf(stderr, "failed to initialize signals\n");
 		ret = -errno;
 		goto err;
 	}
+#endif
 
 	/* parse options */
 	ret = fuse_opt_parse(&args, &fusecfg, option_spec, optional_opt_func);