aboutsummaryrefslogtreecommitdiffstats
path: root/configure
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
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')
-rwxr-xr-xconfigure47
1 files changed, 46 insertions, 1 deletions
diff --git a/configure b/configure
index 767d1da00..adcd6162b 100755
--- a/configure
+++ b/configure
@@ -682,6 +682,7 @@ PKG_CONFIG_PATH
682PKG_CONFIG 682PKG_CONFIG
683HAVE_APPARMOR 683HAVE_APPARMOR
684HAVE_IDS 684HAVE_IDS
685DEPS_CFLAGS
685OBJEXT 686OBJEXT
686EXEEXT 687EXEEXT
687ac_ct_CC 688ac_ct_CC
@@ -3270,8 +3271,51 @@ ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $
3270ac_compiler_gnu=$ac_cv_c_compiler_gnu 3271ac_compiler_gnu=$ac_cv_c_compiler_gnu
3271 3272
3272 3273
3273HAVE_SPECTRE="no" 3274DEPS_CFLAGS=""
3275
3276
3277{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts -MMD -MP" >&5
3278printf %s "checking whether C compiler accepts -MMD -MP... " >&6; }
3279if test ${ax_cv_check_cflags___MMD__MP+y}
3280then :
3281 printf %s "(cached) " >&6
3282else $as_nop
3283
3284 ax_check_save_flags=$CFLAGS
3285 CFLAGS="$CFLAGS -MMD -MP"
3286 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
3287/* end confdefs.h. */
3288
3289int
3290main (void)
3291{
3292
3293 ;
3294 return 0;
3295}
3296_ACEOF
3297if ac_fn_c_try_compile "$LINENO"
3298then :
3299 ax_cv_check_cflags___MMD__MP=yes
3300else $as_nop
3301 ax_cv_check_cflags___MMD__MP=no
3302fi
3303rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
3304 CFLAGS=$ax_check_save_flags
3305fi
3306{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ax_cv_check_cflags___MMD__MP" >&5
3307printf "%s\n" "$ax_cv_check_cflags___MMD__MP" >&6; }
3308if test "x$ax_cv_check_cflags___MMD__MP" = xyes
3309then :
3310
3311 DEPS_CFLAGS="$DEPS_CFLAGS -MMD -MP"
3312
3313else $as_nop
3314 :
3315fi
3274 3316
3317
3318HAVE_SPECTRE="no"
3275{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts -mindirect-branch=thunk" >&5 3319{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts -mindirect-branch=thunk" >&5
3276printf %s "checking whether C compiler accepts -mindirect-branch=thunk... " >&6; } 3320printf %s "checking whether C compiler accepts -mindirect-branch=thunk... " >&6; }
3277if test ${ax_cv_check_cflags___mindirect_branch_thunk+y} 3321if test ${ax_cv_check_cflags___mindirect_branch_thunk+y}
@@ -5311,6 +5355,7 @@ Compile options:
5311 CPPFLAGS: $CPPFLAGS 5355 CPPFLAGS: $CPPFLAGS
5312 LDFLAGS: $LDFLAGS 5356 LDFLAGS: $LDFLAGS
5313 EXTRA_CFLAGS: $EXTRA_CFLAGS 5357 EXTRA_CFLAGS: $EXTRA_CFLAGS
5358 DEPS_CFLAGS: $DEPS_CFLAGS
5314 EXTRA_LDFLAGS: $EXTRA_LDFLAGS 5359 EXTRA_LDFLAGS: $EXTRA_LDFLAGS
5315 LIBS: $LIBS 5360 LIBS: $LIBS
5316 fatal warnings: $HAVE_FATAL_WARNINGS 5361 fatal warnings: $HAVE_FATAL_WARNINGS