aboutsummaryrefslogtreecommitdiff
path: root/mk
diff options
context:
space:
mode:
authorJohn Ericson <John.Ericson@Obsidian.Systems>2023-01-29 12:31:34 -0500
committerJohn Ericson <John.Ericson@Obsidian.Systems>2023-01-29 13:52:57 -0500
commit6772e9ed0ac7853cefdeb6b354c81cba531829f2 (patch)
treec03a8eb395bbf79c9ef74e813883f387932e2c18 /mk
parentccaadc957593522e9b46336eb5afa45ff876f13f (diff)
Allow programs to have custom names
Logic modeled after that for libraries.
Diffstat (limited to 'mk')
-rw-r--r--mk/programs.mk8
1 files changed, 6 insertions, 2 deletions
diff --git a/mk/programs.mk b/mk/programs.mk
index 0fc1990f7..204409332 100644
--- a/mk/programs.mk
+++ b/mk/programs.mk
@@ -3,6 +3,9 @@ programs-list :=
# Build a program with symbolic name $(1). The program is defined by
# various variables prefixed by ‘$(1)_’:
#
+# - $(1)_NAME: the name of the program (e.g. ‘foo’); defaults to
+# $(1).
+#
# - $(1)_DIR: the directory where the (non-installed) program will be
# placed.
#
@@ -23,11 +26,12 @@ programs-list :=
# - $(1)_INSTALL_DIR: the directory where the program will be
# installed; defaults to $(bindir).
define build-program
+ $(1)_NAME ?= $(1)
_d := $(buildprefix)$$($(1)_DIR)
_srcs := $$(sort $$(foreach src, $$($(1)_SOURCES), $$(src)))
$(1)_OBJS := $$(addprefix $(buildprefix), $$(addsuffix .o, $$(basename $$(_srcs))))
_libs := $$(foreach lib, $$($(1)_LIBS), $$($$(lib)_PATH))
- $(1)_PATH := $$(_d)/$(1)
+ $(1)_PATH := $$(_d)/$$($(1)_NAME)
$$(eval $$(call create-dir, $$(_d)))
@@ -38,7 +42,7 @@ define build-program
ifdef $(1)_INSTALL_DIR
- $(1)_INSTALL_PATH := $$($(1)_INSTALL_DIR)/$(1)
+ $(1)_INSTALL_PATH := $$($(1)_INSTALL_DIR)/$$($(1)_NAME)
$$(eval $$(call create-dir, $$($(1)_INSTALL_DIR)))