-# $Id$
+PREFIX ?= /usr
+DESTDIR ?=
+MEMO_PREFIX ?=
+MEMO_SUB_PREFIX ?= /usr
-SCRIPTS= adduser.perl #rmuser.perl addgroup.tcl rmgroup.sh
-MAN8= adduser.8 #rmuser.8 addgroup.8 rmgroup.8
+all: adduser rmuser
-beforeinstall:
-.for script in ${SCRIPTS}
- ${INSTALL} -c -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
- ${.CURDIR}/${script} ${DESTDIR}${BINDIR}/${script:R}
-.endfor
+adduser: adduser.sh
+ sed -e 's|@MEMO_PREFIX@|$(MEMO_PREFIX)|g' \
+ -e 's|@MEMO_SUB_PREFIX@|$(MEMO_SUB_PREFIX)|g' \
+ $< > $@
-.include <bsd.prog.mk>
+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