lnstools

Linux namespace tools
git clone https://ccx.te2000.cz/git/lnstools
Log | Files | Refs | README

commit 1a15532cb8e3fd3f7a0977851df41887c8aacf82
parent d43d0f46a13c4d581ce4682dd480f5184dad3d66
Author: Jan Pobrislo <ccx@te2000.cz>
Date:   Wed, 19 Nov 2025 22:02:40 +0000

Separate directory for configuration information

Diffstat:
M.gitignore | 1+
MMakefile | 17++++++++++++++---
Mconfigure | 8++++----
Msimplelink.mk | 28+++++++++++++++-------------
4 files changed, 34 insertions(+), 20 deletions(-)

diff --git a/.gitignore b/.gitignore @@ -1,2 +1,3 @@ *.sw[op] build +conf diff --git a/Makefile b/Makefile @@ -1,12 +1,23 @@ -default: static_executables +default: static_executables script_executables .PHONY: default -executables:=lns-lockdown lns-envuidgid lns-applyuidgid lns-pidns +script_executables:=build/lns-mount-chroot build/lns-mounts-to-env +script_executables: ${script_executables} +.PHONY: script_executables + +c_executables:=lns-lockdown lns-envuidgid lns-applyuidgid lns-pidns include simplelink.mk -build/cc build/ld.shared build/ld.static: +conf/cc conf/ld.shared conf/ld.static conf/script_gen: @printf '%s\n' "Please run configure script first!"; exit 1 +build/%: src/%.in conf/script_gen scripts/abspaths2.awk + conf/script_gen awk -f ./scripts/abspaths2.awk 'src/$*.in' >'$@.new' + mv -v '$@.new' '$@' + clean: rm -r build + +distclean: + rm -rf conf build .PHONY: clean diff --git a/configure b/configure @@ -47,8 +47,8 @@ generate() { replace_if_different "$out" || exit $? } -mkdir -p build || exit $? +mkdir -p conf || exit $? -generate build/cc awk -f ./scripts/gen-cc -generate build/ld.shared awk -f ./scripts/gen-ld -generate build/ld.static env LDFLAGS="$LDFLAGS -static" awk -f ./scripts/gen-ld +generate conf/cc awk -f ./scripts/gen-cc +generate conf/ld.shared awk -f ./scripts/gen-ld +generate conf/ld.static env LDFLAGS="$LDFLAGS -static" awk -f ./scripts/gen-ld diff --git a/simplelink.mk b/simplelink.mk @@ -1,30 +1,32 @@ -SRC_DIR ?= src -BUILD_DIR ?= build -SCRIPTS_DIR ?= scripts +TOP_DIR ?= . +SRC_DIR ?= ${TOP_DIR}/src +BUILD_DIR ?= ${TOP_DIR}/build +SCRIPTS_DIR ?= ${TOP_DIR}/scripts +CONF_DIR ?= ${TOP_DIR}/conf -shared_executables: $(patsubst %,$(BUILD_DIR)/bin-shared/%,$(executables)) -static_executables: $(patsubst %,$(BUILD_DIR)/bin-static/%,$(executables)) +shared_executables: $(patsubst %,$(BUILD_DIR)/bin-shared/%,$(c_executables)) +static_executables: $(patsubst %,$(BUILD_DIR)/bin-static/%,$(c_executables)) .PHONY: shared_executables static_executables define simplelink = include $$(BUILD_DIR)/$(1)_main.c.deps.mk -$$(BUILD_DIR)/bin-shared/$(1): $$(LINKDEP_$(subst -,__,$(1))_main__c) $$(BUILD_DIR)/ld.shared $$(BUILD_DIR)/$(1)_main.c.deps.mk $$(BUILD_DIR)/bin-shared/.exists - $$(BUILD_DIR)/ld.shared -o '$$@' $$(LINKDEP_$(subst -,__,$(1))_main__c) +$$(BUILD_DIR)/bin-shared/$(1): $$(LINKDEP_$(subst -,__,$(1))_main__c) $$(CONF_DIR)/ld.shared $$(BUILD_DIR)/$(1)_main.c.deps.mk $$(BUILD_DIR)/bin-shared/.exists + $$(CONF_DIR)/ld.shared -o '$$@' $$(LINKDEP_$(subst -,__,$(1))_main__c) include $$(BUILD_DIR)/$(1)_main.c.deps.mk -$$(BUILD_DIR)/bin-static/$(1): $$(LINKDEP_$(subst -,__,$(1))_main__c) $$(BUILD_DIR)/ld.static $$(BUILD_DIR)/$(1)_main.c.deps.mk $$(BUILD_DIR)/bin-static/.exists - $$(BUILD_DIR)/ld.static -o '$$@' $$(LINKDEP_$(subst -,__,$(1))_main__c) +$$(BUILD_DIR)/bin-static/$(1): $$(LINKDEP_$(subst -,__,$(1))_main__c) $$(CONF_DIR)/ld.static $$(BUILD_DIR)/$(1)_main.c.deps.mk $$(BUILD_DIR)/bin-static/.exists + $$(CONF_DIR)/ld.static -o '$$@' $$(LINKDEP_$(subst -,__,$(1))_main__c) endef $(foreach var,$(executables),$(eval $(call simplelink,$(var)))) ## pattern rules: # preprocess C sources -$(BUILD_DIR)/%.c.i: $(SRC_DIR)/%.c $(BUILD_DIR)/cc $(BUILD_DIR)/.exists - $(BUILD_DIR)/cc -E -C -o '$@' '$(SRC_DIR)/$*.c' +$(BUILD_DIR)/%.c.i: $(SRC_DIR)/%.c $(CONF_DIR)/cc $(BUILD_DIR)/.exists + $(CONF_DIR)/cc -E -C -o '$@' '$(SRC_DIR)/$*.c' # compile preprocessed C sources -$(BUILD_DIR)/%.o: $(BUILD_DIR)/%.c.i $(BUILD_DIR)/cc - $(BUILD_DIR)/cc -fpreprocessed -c -o '$@' '$(BUILD_DIR)/$*.c.i' +$(BUILD_DIR)/%.o: $(BUILD_DIR)/%.c.i $(CONF_DIR)/cc + $(CONF_DIR)/cc -fpreprocessed -c -o '$@' '$(BUILD_DIR)/$*.c.i' # extract dependencies from preprocessed sources $(BUILD_DIR)/%.c.deps.mk: $(BUILD_DIR)/%.c.i $(SCRIPTS_DIR)/codedeps.awk