aboutsummaryrefslogtreecommitdiffstats
path: root/config.mk.in
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 /config.mk.in
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 'config.mk.in')
-rw-r--r--config.mk.in7
1 files changed, 5 insertions, 2 deletions
diff --git a/config.mk.in b/config.mk.in
index 63d7fb981..1521a2633 100644
--- a/config.mk.in
+++ b/config.mk.in
@@ -81,6 +81,7 @@ LDFLAGS=@LDFLAGS@
81 81
82# Project variables 82# Project variables
83EXTRA_CFLAGS =@EXTRA_CFLAGS@ 83EXTRA_CFLAGS =@EXTRA_CFLAGS@
84DEPS_CFLAGS =@DEPS_CFLAGS@
84COMMON_CFLAGS = \ 85COMMON_CFLAGS = \
85 -ggdb -O2 -DVERSION='"$(VERSION)"' \ 86 -ggdb -O2 -DVERSION='"$(VERSION)"' \
86 -Wall -Wextra $(HAVE_FATAL_WARNINGS) \ 87 -Wall -Wextra $(HAVE_FATAL_WARNINGS) \
@@ -88,16 +89,18 @@ COMMON_CFLAGS = \
88 -fstack-protector-all -D_FORTIFY_SOURCE=2 \ 89 -fstack-protector-all -D_FORTIFY_SOURCE=2 \
89 -DPREFIX='"$(prefix)"' -DSYSCONFDIR='"$(sysconfdir)/firejail"' \ 90 -DPREFIX='"$(prefix)"' -DSYSCONFDIR='"$(sysconfdir)/firejail"' \
90 -DLIBDIR='"$(libdir)"' -DBINDIR='"$(bindir)"' \ 91 -DLIBDIR='"$(libdir)"' -DBINDIR='"$(bindir)"' \
91 -DVARDIR='"/var/lib/firejail"' \ 92 -DVARDIR='"/var/lib/firejail"'
92 93
93PROG_CFLAGS = \ 94PROG_CFLAGS = \
94 $(COMMON_CFLAGS) \ 95 $(COMMON_CFLAGS) \
95 $(HAVE_GCOV) $(MANFLAGS) \ 96 $(HAVE_GCOV) $(MANFLAGS) \
96 $(EXTRA_CFLAGS) \ 97 $(EXTRA_CFLAGS) \
98 $(DEPS_CFLAGS) \
97 -fPIE 99 -fPIE
98 100
99SO_CFLAGS = \ 101SO_CFLAGS = \
100 $(COMMON_CFLAGS) \ 102 $(COMMON_CFLAGS) \
103 $(DEPS_CFLAGS) \
101 -fPIC 104 -fPIC
102 105
103EXTRA_LDFLAGS =@EXTRA_LDFLAGS@ 106EXTRA_LDFLAGS =@EXTRA_LDFLAGS@
@@ -105,4 +108,4 @@ PROG_LDFLAGS = -Wl,-z,relro -Wl,-z,now -fPIE -pie $(EXTRA_LDFLAGS)
105SO_LDFLAGS = -Wl,-z,relro -Wl,-z,now -fPIC 108SO_LDFLAGS = -Wl,-z,relro -Wl,-z,now -fPIC
106LIBS =@LIBS@ 109LIBS =@LIBS@
107 110
108CLEANFILES = *.o *.gcov *.gcda *.gcno *.plist 111CLEANFILES = *.d *.o *.gcov *.gcda *.gcno *.plist