aboutsummaryrefslogtreecommitdiffstats
path: root/configure.ac
diff options
context:
space:
mode:
authorLibravatar Kelvin M. Klann <kmk3.code@protonmail.com>2023-07-05 23:56:06 -0300
committerLibravatar Kelvin M. Klann <kmk3.code@protonmail.com>2024-01-22 18:05:47 -0300
commite665769f5225062565b3a75677ce43eb37b988c5 (patch)
treeba46eebf03f497bfa9669c85d10e41fcef946895 /configure.ac
parentbuild: move EXTRA vars directly into targets (diff)
downloadfirejail-e665769f5225062565b3a75677ce43eb37b988c5.tar.gz
firejail-e665769f5225062565b3a75677ce43eb37b988c5.tar.zst
firejail-e665769f5225062565b3a75677ce43eb37b988c5.zip
build: automatically generate header dependencies
Instead of manually specifying which source files depend on which headers, use compiler flags to automatically generate depfiles (.d), which declare the correct header (make) dependencies for each source file (.c). Use `-MMD` (which ignores system headers) to generate the dependencies and `-MP` to prevent make from complaining when a header file is removed while it is listed as a dependency in a depfile. If depfiles exist, just include them. If not, make each object file (.o) unconditionally depend on all header files in its source directory and in src/include, to ensure that rebuilds are done when needed. The latter case applies to the first build after `make clean` (which would build everything anyway) and when the compiler does not support generating depfiles. Note that both gcc and clang have supported these options for a long time. Misc: This depends on the changes from commit 5b1bd33c7 ("build: use full paths on compile/link targets", 2023-07-02) / PR #6158 to avoid issues with make dependency tracking.
Diffstat (limited to 'configure.ac')
-rw-r--r--configure.ac7
1 files changed, 7 insertions, 0 deletions
diff --git a/configure.ac b/configure.ac
index d3b05d839..7a2c379fe 100644
--- a/configure.ac
+++ b/configure.ac
@@ -20,6 +20,12 @@ AC_CONFIG_MACRO_DIR([m4])
20 20
21AC_PROG_CC 21AC_PROG_CC
22 22
23DEPS_CFLAGS=""
24AC_SUBST([DEPS_CFLAGS])
25AX_CHECK_COMPILE_FLAG([-MMD -MP], [
26 DEPS_CFLAGS="$DEPS_CFLAGS -MMD -MP"
27])
28
23HAVE_SPECTRE="no" 29HAVE_SPECTRE="no"
24AX_CHECK_COMPILE_FLAG([-mindirect-branch=thunk], [ 30AX_CHECK_COMPILE_FLAG([-mindirect-branch=thunk], [
25 HAVE_SPECTRE="yes" 31 HAVE_SPECTRE="yes"
@@ -279,6 +285,7 @@ Compile options:
279 CPPFLAGS: $CPPFLAGS 285 CPPFLAGS: $CPPFLAGS
280 LDFLAGS: $LDFLAGS 286 LDFLAGS: $LDFLAGS
281 EXTRA_CFLAGS: $EXTRA_CFLAGS 287 EXTRA_CFLAGS: $EXTRA_CFLAGS
288 DEPS_CFLAGS: $DEPS_CFLAGS
282 EXTRA_LDFLAGS: $EXTRA_LDFLAGS 289 EXTRA_LDFLAGS: $EXTRA_LDFLAGS
283 LIBS: $LIBS 290 LIBS: $LIBS
284 fatal warnings: $HAVE_FATAL_WARNINGS 291 fatal warnings: $HAVE_FATAL_WARNINGS