Skip to content

Commit

Permalink
Allow programs to have custom names
Browse files Browse the repository at this point in the history
Logic modeled after that for libraries.
  • Loading branch information
Ericson2314 committed Jan 29, 2023
1 parent ccaadc9 commit 6772e9e
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions mk/programs.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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.
#
Expand All @@ -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)))

Expand All @@ -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)))

Expand Down

0 comments on commit 6772e9e

Please sign in to comment.