It generates a `compile_commands.json` suitable for clangd.
This is almost mandatory to have a command like this one for NixOs
users as tool like bear are not able to intercept correctly the
clang calls due to the usage of a wrapper.
Ticket: #7669
CLEANFILES = stamp-h[0-9]*
+DISTCLEANFILES = compile_commands.json
+
install-data-am:
@echo "Run 'make install-conf' if you want to install initial configuration files. Or 'make install-full' to install configuration and rules";
install-headers:
cd src && $(MAKE) $@
+
+compile-commands:
+if HAVE_CLANG
+ $(MAKE) -C src clean
+ TMP_DIR=$$(mktemp -d --suffix=.suricata-compile-commands) && \
+ $(MAKE) EXTRA_CFLAGS="-MJ $$TMP_DIR/\$$*.json" && \
+ echo '[' > $(top_builddir)/compile_commands.json && \
+ cat $$TMP_DIR/*.json >> $(top_builddir)/compile_commands.json && \
+ echo ']' >> $(top_builddir)/compile_commands.json && \
+ rm -rf $$TMP_DIR
+else
+ @echo "clang compile_commands.json generation not supported with current compiler"
+endif
;;
esac
+ AM_CONDITIONAL([HAVE_CLANG], [test "x$compiler" == "xclang"])
+
# Checks for programs.
AC_PROG_AWK
AC_PROG_CC