aboutsummaryrefslogtreecommitdiff
path: root/mk
diff options
context:
space:
mode:
authoreldritch horrors <pennae@lix.systems>2024-03-04 06:12:19 +0100
committereldritch horrors <pennae@lix.systems>2024-03-04 07:11:25 +0100
commita089d8f5f6f96ea3f35790c36b6456e71f477879 (patch)
treeba290e853e076393ec9eaf1b075d294093c04cb0 /mk
parentc208e918e55c423203692343b56d893dc7435095 (diff)
Merge pull request #9465 from obsidiansystems/build-dir
Use `buildprefix` in a few more places (cherry picked from commit b6a3fde6b7a416929553e6be36fc991680ddf9ef) Change-Id: I2790663fa9f8242ac2db6582b7e421d2fdf42942
Diffstat (limited to 'mk')
-rw-r--r--mk/build-dir.mk10
-rw-r--r--mk/install-dirs.mk11
-rw-r--r--mk/lib.mk25
-rw-r--r--mk/templates.mk8
4 files changed, 28 insertions, 26 deletions
diff --git a/mk/build-dir.mk b/mk/build-dir.mk
new file mode 100644
index 000000000..02f4cae60
--- /dev/null
+++ b/mk/build-dir.mk
@@ -0,0 +1,10 @@
+# Initialise support for build directories.
+builddir ?=
+
+ifdef builddir
+ buildprefix = $(builddir)/
+ buildprefixrel = $(builddir)
+else
+ buildprefix =
+ buildprefixrel = .
+endif
diff --git a/mk/install-dirs.mk b/mk/install-dirs.mk
new file mode 100644
index 000000000..732b0d6fc
--- /dev/null
+++ b/mk/install-dirs.mk
@@ -0,0 +1,11 @@
+# Default installation paths.
+prefix ?= /usr/local
+libdir ?= $(prefix)/lib
+bindir ?= $(prefix)/bin
+libexecdir ?= $(prefix)/libexec
+datadir ?= $(prefix)/share
+localstatedir ?= $(prefix)/var
+sysconfdir ?= $(prefix)/etc
+mandir ?= $(prefix)/share/man
+
+DESTDIR ?=
diff --git a/mk/lib.mk b/mk/lib.mk
index e86a7f1a4..366f0e373 100644
--- a/mk/lib.mk
+++ b/mk/lib.mk
@@ -43,27 +43,6 @@ define newline
endef
-# Default installation paths.
-prefix ?= /usr/local
-libdir ?= $(prefix)/lib
-bindir ?= $(prefix)/bin
-libexecdir ?= $(prefix)/libexec
-datadir ?= $(prefix)/share
-localstatedir ?= $(prefix)/var
-sysconfdir ?= $(prefix)/etc
-mandir ?= $(prefix)/share/man
-
-
-# Initialise support for build directories.
-builddir ?=
-
-ifdef builddir
- buildprefix = $(builddir)/
-else
- buildprefix =
-endif
-
-
# Pass -fPIC if we're building dynamic libraries.
BUILD_SHARED_LIBS ?= 1
@@ -94,6 +73,8 @@ ifeq ($(BUILD_DEBUG), 1)
endif
+include mk/build-dir.mk
+include mk/install-dirs.mk
include mk/functions.mk
include mk/tracing.mk
include mk/clean.mk
@@ -112,7 +93,7 @@ define include-sub-makefile
include $(1)
endef
-$(foreach mf, $(makefiles), $(eval $(call include-sub-makefile, $(mf))))
+$(foreach mf, $(makefiles), $(eval $(call include-sub-makefile,$(mf))))
# Instantiate stuff.
diff --git a/mk/templates.mk b/mk/templates.mk
index c7ac7afbf..866bdc17f 100644
--- a/mk/templates.mk
+++ b/mk/templates.mk
@@ -10,10 +10,10 @@ endef
ifneq ($(MAKECMDGOALS), clean)
-%.h: %.h.in
- $(trace-gen) rm -f $@ && ./config.status --quiet --header=$@
+$(buildprefix)%.h: %.h.in
+ $(trace-gen) rm -f $@ && cd $(buildprefixrel) && ./config.status --quiet --header=$(@:$(buildprefix)%=%)
-%: %.in
- $(trace-gen) rm -f $@ && ./config.status --quiet --file=$@
+$(buildprefix)%: %.in
+ $(trace-gen) rm -f $@ && cd $(buildprefixrel) && ./config.status --quiet --file=$(@:$(buildprefix)%=%)
endif