Skip to content

Latest commit

 

History

9 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Introduction

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.

Install

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 link

This initializes the submodule, creates a default Makefile and sets installMode to linking by default. git submodule add --force avoids error, if it already exists.

Modes

Setting localbin.installMode is required.

git config --local localbin.installMode link

copy files into ~/.local/bin.

git config --local localbin.installMode copy

link files into ~/.local/bin.

git config --local localbin.installMode link

Set localbin.renameSh to true to install localbin/foo.sh as foo. The default is to preserve the filename.

Overrides

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 to localbin/.
  • LOCALBIN_MAP: map file name or one source:host-name mapping; defaults to localbin.map.
  • DESTDIR: prefix prepended to LOCALBIN_PREFIX; defaults to empty.
  • localbin.renameSh: optional git config; strip .sh from 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:bar

Blank 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

Releases

Packages

Contributors

Languages