-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
54 lines (40 loc) · 1.48 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
PREFIX ?= /usr/local
BINDIR ?= ${PREFIX}/bin
DATADIR ?= ${PREFIX}/share
MANDIR ?= ${DATADIR}/man
SHELL = /bin/sh
INSTALL ?= install
PROGRAM_NAME = bitbutler
install: doc persist
$(INSTALL) -D -t "${DESTDIR}${DATADIR}/${PROGRAM_NAME}" src/*.sh
$(INSTALL) -D man/bitbutler.1 $(DESTDIR)$(MANDIR)/man1/${PROGRAM_NAME}.1
mkdir -p "${DESTDIR}${BINDIR}"
printf '#!/usr/bin/env bash\nBB_VENDOR_PATH="${DESTDIR}${DATADIR}/${PROGRAM_NAME}" exec ${DESTDIR}${DATADIR}/${PROGRAM_NAME}/bitbutler.sh "$$@"' > "${DESTDIR}${BINDIR}/${PROGRAM_NAME}"
chmod u+rwx,g+x,o+x "${DESTDIR}${BINDIR}/${PROGRAM_NAME}"
persist: dirs
$(eval PERSIST_FILE := $(DESTDIR)$(DATADIR)/$(PROGRAM_NAME)/make.settings)
$(file > $(PERSIST_FILE),PREFIX=$(PREFIX))
$(file >> $(PERSIST_FILE),BINDIR=$(BINDIR))
$(file >> $(PERSIST_FILE),DATADIR=$(DATADIR))
$(file >> $(PERSIST_FILE),MANDIR=$(MANDIR))
$(file >> $(PERSIST_FILE),DESTDIR=$(DESTDIR))
# before persist is called for the first time, this needs to be run
# note: it cannot be in the persist step, as it would run the `eval` before the step is run
dirs:
mkdir -pv "$(DESTDIR)$(DATADIR)/$(PROGRAM_NAME)"
doc:
$(MAKE) -C man
test:
bats tests
coverage:
kcov --include-path=. coverage bats tests/
shellcheck:
find 'src/' -type f -name '*.sh' | xargs shellcheck --external-sources
stylecheck:
shfmt -i 2 -ci -d src
stylefix:
shfmt -i 2 -ci -w src
clean:
$(RM) -r ./coverage
$(MAKE) -C man clean
.PHONY: install test coverage clean doc shellcheck stylecheck persist dirs