-# $FreeBSD$
+PREFIX ?= /usr
+DESTDIR ?=
+MEMO_PREFIX ?=
+MEMO_SUB_PREFIX ?= /usr
-SCRIPTS=adduser.sh rmuser.sh
-MAN= adduser.8 rmuser.8
+all: adduser rmuser
-.include <bsd.prog.mk>
+adduser: adduser.sh
+ sed -e 's|@MEMO_PREFIX@|$(MEMO_PREFIX)|g' \
+ -e 's|@MEMO_SUB_PREFIX@|$(MEMO_SUB_PREFIX)|g' \
+ $< > $@
+
+rmuser: rmuser.sh
+ sed -e 's|@MEMO_PREFIX@|$(MEMO_PREFIX)|g' \
+ -e 's|@MEMO_SUB_PREFIX@|$(MEMO_SUB_PREFIX)|g' \
+ $< > $@
+
+clean:
+ rm -f adduser rmuser
+
+install: install-adduser install-rmuser
+
+install-adduser: adduser adduser.8 adduser.conf.5
+ install -d $(DESTDIR)/$(PREFIX)/sbin \
+ $(DESTDIR)/$(PREFIX)/share/man/man5 \
+ $(DESTDIR)/$(PREFIX)/share/man/man8
+ install -m755 adduser $(DESTDIR)/$(PREFIX)/sbin/adduser
+ install -m644 adduser.8 $(DESTDIR)/$(PREFIX)/share/man/man8/adduser.8
+ install -m644 adduser.conf.5 $(DESTDIR)/$(PREFIX)/share/man/man5/adduser.conf.5
+
+install-rmuser: rmuser rmuser.8
+ install -d $(DESTDIR)/$(PREFIX)/sbin \
+ $(DESTDIR)/$(PREFIX)/share/man/man8
+ install -m755 rmuser $(DESTDIR)/$(PREFIX)/sbin/rmuser
+ install -m644 rmuser.8 $(DESTDIR)/$(PREFIX)/share/man/man8/rmuser.8
+
+.PHONY: all install install-adduser install-rmuser clean