$NetBSD: patch-aa,v 1.4 2012/05/23 06:05:39 dholland Exp $

- configure for pkgsrc
- honor PREFIX, PKGMANDIR, VARBASE, CFLAGS, LDFLAGS

--- unix/Makefile.orig	1994-07-21 22:37:08.000000000 +0000
+++ unix/Makefile
@@ -3,15 +3,18 @@
 # LIBDIR must be the same directory defined in config.h
 # OWNER is who you want the game to be chown to.
 # GROUP is who you wnat the game to be chgrp to.
-BINDIR = /home/zariski/grabiner/moria
-LIBDIR = /home/zariski/grabiner/moria/files
-OWNER = grabiner
-GROUP = grad
+BINDIR = ${PREFIX}/bin
+LIBDIR = ${PREFIX}/share/games/moria
+MANDIR = ${PREFIX}/${PKGMANDIR}/man6
+SCOREFILE = ${VARBASE}/games/moria.scores
+
+GROUP = games
 
 # For testing and debugging the program, it is best to use this line.
 # CFLAGS = -g
 # For playing the game, you may want to use this line
-CFLAGS = -O
+#CFLAGS = -O
+CPPFLAGS+=-Dunix -DLIBDIR=\"${LIBDIR}\" -DMORIA_TOP=\"${SCOREFILE}\"
 
 # For BSD Systems
 CURSES = -lcurses -ltermcap
@@ -24,7 +27,7 @@ CURSES = -lcurses -ltermcap
 # config.h if you use this.
 #LFLAGS = -lbsd
 # Normal systems don't require anything here.
-LFLAGS = 
+LFLAGS = $(LDFLAGS)
 
 CC = cc
 
@@ -45,6 +48,8 @@ OBJS = main.o misc1.o misc2.o misc3.o mi
 LIBFILES = hours news origcmds.hlp owizcmds.hlp roglcmds.hlp rwizcmds.hlp \
 	version.hlp welcome.hlp
 
+all:	moria
+
 moria : $(OBJS)
 	$(CC) -o moria $(CFLAGS) $(OBJS) $(CURSES) $(LFLAGS)
 
@@ -57,22 +62,16 @@ lintout2 : $(SRCS)
 TAGS : $(SRCS)
 	ctags -x $(SRCS) > TAGS
 
-# you must define BINDIR and LIBDIR before installing
-# assumes that BINDIR and LIBDIR exist
+CHGRP?=	/usr/bin/chgrp
+CHMOD?=	/bin/chmod
+TOUCH?=	/usr/bin/touch
+
 install:
-	chmod 755 $(BINDIR)
-	cp moria $(BINDIR)
-	chmod 4711 $(BINDIR)/moria
-	chmod 711 $(LIBDIR)
-	(cd files; cp $(LIBFILES) $(LIBDIR))
-	(cd $(LIBDIR); chmod 444 $(LIBFILES))
-	(cd $(LIBDIR); touch scores; chmod 644 scores)
-	chown $(OWNER) $(BINDIR)/moria
-	chgrp $(GROUP) $(BINDIR)/moria
-	(cd $(LIBDIR); chown $(OWNER) $(LIBFILES) scores)
-	(cd $(LIBDIR); chgrp $(GROUP) $(LIBFILES) scores)
-# If you are short on disk space, or aren't interested in debugging moria.
-#	strip $(BINDIR)/moria
+	${BSD_INSTALL_PROGRAM} moria ${DESTDIR}${BINDIR}
+	${BSD_INSTALL_MAN} doc/moria.6 ${DESTDIR}${MANDIR}
+	${BSD_INSTALL_DATA_DIR} ${DESTDIR}${LIBDIR}
+	( cd files; ${BSD_INSTALL_DATA} ${LIBFILES} ${DESTDIR}${LIBDIR} )
+	( cd doc ; ${MAKE} install )
 
 clean:
 	rm -r *.o
