diff options
author | 2022-05-06 21:00:19 -0300 | |
---|---|---|
committer | 2022-06-12 16:08:47 -0300 | |
commit | da6d855dc29e0db10ecf1065f9860a2874b6bf07 (patch) | |
tree | 1ccebf31579401effbd97467ccce86b84805eeba /src/fbuilder | |
parent | common.mk.in: fix comment about file usage intent (diff) | |
download | firejail-da6d855dc29e0db10ecf1065f9860a2874b6bf07.tar.gz firejail-da6d855dc29e0db10ecf1065f9860a2874b6bf07.tar.zst firejail-da6d855dc29e0db10ecf1065f9860a2874b6bf07.zip |
makefiles: define root dir and include relative to it
A non-absolute path on an include command is always treated as being
relative to the directory in which "make" was started in, rather than
being relative to the makefile that contains the command. For example,
given the following project structure and file contents:
* Makefile: include src/foo.mk
* src/foo.mk: include bar.mk
* src/bar.mk:
Running "make" on the root project directory (that is, where "Makefile"
is) yields the following:
src/foo.mk:1: bar.mk: No such file or directory
As "bar.mk" in "include bar.mk" is relative to the current (process)
directory (that is, "./bar.mk") and not to where foo.mk is located in
("./src/bar.mk").
So on every makefile that contains an include command, define the root
project directory in the ROOT variable and always include relative to
it, to later enable any included mkfiles to include other mkfiles
without having to worry about the correct path.
Commands used to search and replace:
$ git grep -Flz 'include ../common.mk' -- src |
xargs -0 -I '{}' sh -c \
"printf '%s\n' \"\`sed 's|include ../common.mk|ROOT = ../..\ninclude \$(ROOT)/src/common.mk|' '{}'\`\" >'{}'"
Environment: GNU make 4.3-3.1 on Artix Linux
Diffstat (limited to 'src/fbuilder')
-rw-r--r-- | src/fbuilder/Makefile.in | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/fbuilder/Makefile.in b/src/fbuilder/Makefile.in index 6eaee284b..060f97493 100644 --- a/src/fbuilder/Makefile.in +++ b/src/fbuilder/Makefile.in | |||
@@ -1,7 +1,8 @@ | |||
1 | .PHONY: all | 1 | .PHONY: all |
2 | all: fbuilder | 2 | all: fbuilder |
3 | 3 | ||
4 | include ../common.mk | 4 | ROOT = ../.. |
5 | include $(ROOT)/src/common.mk | ||
5 | 6 | ||
6 | %.o : %.c $(H_FILE_LIST) ../include/common.h ../include/syscall.h | 7 | %.o : %.c $(H_FILE_LIST) ../include/common.h ../include/syscall.h |
7 | $(CC) $(CFLAGS) $(EXTRA_CFLAGS) $(INCLUDE) -c $< -o $@ | 8 | $(CC) $(CFLAGS) $(EXTRA_CFLAGS) $(INCLUDE) -c $< -o $@ |