Makefile 1.29 KB
SUBCOMMANDS = random \
	      rand_printable \
	      amngrdbinit \
	      amngrdbdestroy \
	      amngradd \
	      amngrcreate \
	      amngrcrypt \
	      amngrdelete \
	      amngrgen \
	      amngrgetoldpass \
	      amngrgetolduser \
	      amngrgetpass \
	      amngrgetuser \
	      amngrid \
	      amngrlist \
	      amngrrename \
	      amngrsearch

PREFIX ?= /usr
DESTDIR ?=

export PREFIX DESTDIR

PROGRAM = accountmanager.sh

DIST_FILES = doc/Makefile \
	     doc/accountmanager.1 \
	     $(PROGRAM) \
	     Makefile \
	     README.md \
	     LICENSE \
	     VERSION \
	     AUTHORS

all: doc

README_new.md: doc/accountmanager.1
	groff -D utf8 -mandoc -Thtml "$<" |\
		pandoc -f html -t markdown_strict >"$@"

.PHONY: clean install doc dist

dist: ARCHIVE_NAME = $(basename $(PROGRAM))-`cat VERSION`
dist: clean $(DIST_FILES)
	tar cvf - --xform="s/^/$(ARCHIVE_NAME)\//" $(DIST_FILES) | \
		bzip2 -9 -c >$(ARCHIVE_NAME).tar.bz2

doc:
	+make -C doc

install_doc: doc
	+make -C doc install

install_$(PROGRAM):
	@+install -D "$(PROGRAM)" "$(DESTDIR)/$(PREFIX)/bin/$(PROGRAM)"

install_%: install_$(PROGRAM)
	@+ln -s "$(realpath ${DESTDIR}/${PREFIX}/bin/$(PROGRAM))" \
		"${DESTDIR}/$(PREFIX)/bin/$(subst install_,,$@)"

install: $(patsubst %,install_%,$(SUBCOMMANDS)) install_doc

clean:
	+make -C doc clean