From 5b1bd33c7dc1b96cc27e4e52e8bdfe63268887e9 Mon Sep 17 00:00:00 2001 From: "Kelvin M. Klann" Date: Sun, 2 Jul 2023 22:19:48 -0300 Subject: build: use full paths on compile/link targets This makes the compile commands clearer when building in parallel (with `make -j`) and ensures that `__FILE__` includes the full build-time path (relative to the root of the repository) whenever it is referenced, such as in failed assert() messages (currently the full path is only shown in errExit() messages). Example: Before: firejail: main.c:100: main: Assertion `1 == 2' failed. Error src/firecfg/main.c:100: main: malloc: Cannot allocate memory After: firejail: ../../src/firejail/main.c:100: main: Assertion `1 == 2' failed. Error ../../src/firecfg/main.c:100: main: malloc: Cannot allocate memory Commands used to search and replace: $ git grep -Ilz '^MOD_DIR =' -- '*Makefile' | xargs -0 -I '{}' \ sh -c "printf '%s\n' \"\$(sed -E \ -e 's|^MOD_DIR = src/(.*)|MOD = \\1\\nMOD_DIR = \$(ROOT)/src/\$(MOD)|' \ -e 's:^(PROG|SO) = [^.]+(\.so)?$:\\1 = \$(MOD_DIR)/\$(MOD)\2:' \ '{}')\" >'{}'" $ git grep -Ilz '^HDRS :=' -- '*.mk' | xargs -0 -I '{}' \ sh -c "printf '%s\n' \"\$(sed -E \ -e 's|wildcard (\*\..)|wildcard \$(MOD_DIR)/\\1|' '{}')\" >'{}'" Note: config.mk.in, src/fnettrace/Makefile and src/include/common.h were edited manually. This is a follow-up to #5871. --- src/etc-cleanup/Makefile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/etc-cleanup') diff --git a/src/etc-cleanup/Makefile b/src/etc-cleanup/Makefile index 296ed41d8..23121c521 100644 --- a/src/etc-cleanup/Makefile +++ b/src/etc-cleanup/Makefile @@ -2,8 +2,9 @@ ROOT = ../.. -include $(ROOT)/config.mk -MOD_DIR = src/etc-cleanup -PROG = etc-cleanup +MOD = etc-cleanup +MOD_DIR = $(ROOT)/src/$(MOD) +PROG = $(MOD_DIR)/$(MOD) TARGET = $(PROG) EXTRA_HDRS = ../include/etc_groups.h -- cgit v1.2.3-54-g00ecf