Reusable targets for projects that keep executable commands in
localbin/ and install them into $(HOME)/.local/bin.
Ideal for:
- shellscripts
- command/container wrapper scripts
- simple unpackaged compiled projects
See the Install section for adding this repository as a submodule.
Only GNU Make is officially supported.
Run from the parent repository:
git submodule add --force -b dev \
ssh://git@codeberg.org/dza/make-localbin-install.git \
deps/make/localbin-install
[ -e Makefile ] || cat >Makefile <<'MK_EOF'
LOCALBIN_Q ?= @
install: localbin-install
uninstall: localbin-uninstall
#update: localbin-update
#check: localbin-check
# Last to avoid default target
-include deps/make/localbin-install/Makefile
MK_EOF
mkdir -p localbin && git config --local localbin.installMode linkThis initializes the submodule, creates a default Makefile and sets installMode to linking by default. git submodule add --force avoids error, if it already exists.
Setting localbin.installMode is required.
git config --local localbin.installMode linkcopy files into ~/.local/bin.
git config --local localbin.installMode copylink files into ~/.local/bin.
git config --local localbin.installMode linkSet localbin.renameSh to true to install localbin/foo.sh as foo.
The default is to preserve the filename.
Make variables may be set through the environment or command line:
LOCALBIN_Q: set to@to silence commands.LOCALBIN_PREFIX: install directory; defaults to$(HOME)/.local/bin.LOCALBIN_SRC: source binaries; defaults tolocalbin/.LOCALBIN_MAP: map file name or onesource:host-namemapping; defaults tolocalbin.map.DESTDIR: prefix prepended toLOCALBIN_PREFIX; defaults to empty.localbin.renameSh: optional git config; strip.shfrom installed names.
When LOCALBIN_MAP contains :, it is one inline source:host-name mapping.
Otherwise it names a map file inside LOCALBIN_SRC. The default is
localbin/localbin.map.
A map file contains one source:host-name mapping per line; for example:
foo.sh:foo
bar.bash:barBlank lines and # comments are ignored.
This links or copies localbin/foo.sh to ~/.local/bin/foo and
localbin/bar.bash to ~/.local/bin/bar.
If the map file does not exist, every regular non-.map
file in LOCALBIN_SRC is installed as before. Files ending in .map are
reserved as mapping metadata and are never installed.
For example:
make install LOCALBIN_SRC=/binaries # /binaries/{src_bin} -> ...{installed}
make install LOCALBIN_MAP=go.sh:go # localbin/go.sh -> ~/.local/bin/go
make install LOCALBIN_PREFIX=$HOME/bin # ~/bin/{installed}
make install DESTDIR=/tmp/foo/ # /tmp/foo/home/user/.local/bin/{installed}
make install DESTDIR=/tmp/foo/ LOCALBIN_PREFIX=/bin # /tmp/foo/bin/{installed}
make LOCALBIN_Q=@ install # quiet install