Skip to content

Instantly share code, notes, and snippets.

@postmodern
Last active March 4, 2024 14:42
Show Gist options
  • Save postmodern/3224049 to your computer and use it in GitHub Desktop.
Save postmodern/3224049 to your computer and use it in GitHub Desktop.
A generic Makefile for building/signing/install bash scripts
NAME=project
VERSION=0.0.1
FILES=$(shell git ls-files)
BIN_FILES=$(shell find bin/ -type f)
SBIN_FILES=$(shell find sbin/ -type f)
LIB_FILES=$(shell find lib/ -type f)
MAN_FILES=$(shell find man/ -type f)
DOC_FILES=$(shell find doc/ -type f)
DOC_FILES+=$(shell find . -type f -name *.{md,tt,txt})
PKG=$(NAME)-$(VERSION).tar.bz2
SIG=$(PKG).asc
PREFIX=/usr/local
SHARE_DIR=$(PREFIX)/share
DOC_DIR=$(SHARE_DIR)/doc/$(NAME)-$(VERSION)
$(PKG): $(FILES)
tar -cjvf $(PKG) $(FILES)
pkg: $(PKG)
$(SIG): $(PKG)
gpg --sign --detach-sign --armor $(PKG)
sign: $(SIG)
all: pkg sign
clean:
rm -f $(PKG) $(SIG)
install:
for file in $(BIN_FILES); do cp $$file $(PREFIX)/$$file; done
for file in $(SBIN_FILES); do cp $$file $(PREFIX)/$$file; done
for file in $(LIB_FILES); do cp $$file $(PREFIX)/$$file; done
for file in $(MAN_FILES); do cp $$file $(SHARE_DIR)/$$file; done
mkdir -p $(DOC_DIR)
cp $(DOC_FILES) $(DOC_DIR)
uninstall:
for file in $(BIN_FILES); do rm $(PREFIX)/$$file; done
for file in $(SBIN_FILES); do rm $(PREFIX)/$$file; done
for file in $(LIB_FILES); do rm $(PREFIX)/$$file; done
for file in $(MAN_FILES); do rm $(SHARE_DIR)/$$file; done
rm -rf $(DOC_DIR)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment