$NetBSD: patch-ab,v 1.3 2006/06/17 19:00:08 rillig Exp $

--- sys/unix/Makefile.top.orig	2001-06-24 18:57:24.000000000 +0200
+++ sys/unix/Makefile.top	2006-06-17 20:32:55.000000000 +0200
@@ -14,19 +14,17 @@
 # MAKE = make
 
 # make NetHack
-#PREFIX	 = /usr
-PREFIX = $(shell pwd)/compiled
-GAME     = nethack
+GAME     = falcons-eye
 # GAME     = nethack.prg
-GAMEUID  = games
-GAMEGRP  = bin
+GAMEUID  = root
+GAMEGRP  = games
 
 # Permissions - some places use setgid instead of setuid, for instance
 # See also the option "SECURE" in include/config.h
-GAMEPERM = 04755
-FILEPERM = 0644
+GAMEPERM = 02755
+FILEPERM = 0664
 EXEPERM  = 0755
-DIRPERM  = 0755
+DIRPERM  = 0775
 
 # GAMEDIR also appears in config.h as "HACKDIR".
 # VARDIR may also appear in unixconf.h as "VAR_PLAYGROUND" else GAMEDIR
@@ -36,9 +34,9 @@ DIRPERM  = 0755
 # therefore there should not be anything in GAMEDIR that you want to keep
 # (if there is, you'll have to do the installation by hand or modify the
 # instructions)
-GAMEDIR  = $(PREFIX)/games/lib/$(GAME)dir
+GAMEDIR  = $(PREFIX)/share/$(GAME)-dir
 VARDIR  = $(GAMEDIR)
-SHELLDIR = $(PREFIX)/games
+SHELLDIR = $(PREFIX)/bin
 
 # per discussion in Install.X11 and Install.Qt
 VARDATND = 
@@ -65,10 +63,8 @@ VARDAT = $(VARDATD) $(VARDATND)
 # other permission-related reasons.  If that happens, you may want to set the
 # command to "true", which is a no-op. Note that disabling chown or chgrp
 # will only work if setuid (or setgid) behavior is not desired or required.
-# CHOWN = chown
-# CHGRP = chgrp
-CHOWN = true
-CHGRP = true
+CHOWN = chown
+CHGRP = chgrp
 
 # ----------------------------------------------
 # Extra configuration for NetHack - Falcon's Eye
@@ -119,9 +115,12 @@ JTPMANUALFILES = *.jpg *.html *.css
 $(GAME):
 	( cd src ; $(MAKE) )
 
-all:	$(GAME) Guidebook $(VARDAT) dungeon spec_levs check-dlb
+all:	$(GAME) datastuff
 	@echo "Done."
 
+datastuff: Guidebook $(VARDAT) dungeon spec_levs check-dlb recover
+	@echo "Data Sets Built."
+
 Guidebook:
 	( cd doc ; $(MAKE) Guidebook )
 
@@ -131,6 +130,9 @@ manpages:
 data:
 	( cd dat ; $(MAKE) data )
 
+recover:
+	( cd util ; $(MAKE) recover )
+
 rumors:
 	( cd dat ; $(MAKE) rumors )
 
@@ -188,6 +190,11 @@ dlb:
 	( cd util ; $(MAKE) dlb )
 	( cd dat ; ../util/dlb cf nhdat $(DATDLB) )
 
+binfiles: $(GAME)
+	cp src/$(GAME) $(SHELLDIR)/$(GAME)$(GTYPE)
+	-( cd $(GAMEDIR) ; $(CHOWN) $(GAMEUID) $(SHELLDIR)/$(GAME)$(GTYPE) ; \
+		$(CHGRP) $(GAMEGRP) $(SHELLDIR)/$(GAME)$(GTYPE) )
+	chmod $(GAMEPERM) $(SHELLDIR)/$(GAME)$(GTYPE)
 
 dofiles:
 	target=`sed -n					\
@@ -203,6 +210,7 @@ dofiles:
 	-rm -f $(SHELLDIR)/$(GAME)
 	sed -e 's;/usr/games/lib/nethackdir;$(GAMEDIR);' \
 		-e 's;HACKDIR/nethack;HACKDIR/$(GAME);' \
+		-e 's;XXXPREFIXXXX;$(PREFIX);' \
 		< sys/unix/nethack.sh \
 		> $(SHELLDIR)/$(GAME)
 # set up their permissions
@@ -239,7 +247,8 @@ dofiles-jtp:
 	chmod $(DIRPERM) $(JTPMAINDIR) $(JTPDATADIR) $(JTPGRAPHICSDIR) $(JTPSOUNDDIR) $(JTPMANUALDIR)
 # copy over the Falcon's Eye files
 	( cd  win/jtp/gamedata; cp $(JTPMAINFILES) $(JTPMAINDIR) ; \
-	cd config; cp $(JTPDATAFILES) $(JTPDATADIR) ; \
+	${BSD_INSTALL_DATA_DIR} $(PREFIX)/share/examples/falcons-eye ; \
+	cd config; ${BSD_INSTALL_DATA} $(JTPDATAFILES) $(PREFIX)/share/examples/falcons-eye ; \
 	cd ../graphics; cp $(JTPGRAPHICSFILES) $(JTPGRAPHICSDIR) ; \
 	cd ../sound; cp $(JTPSOUNDFILES) $(JTPSOUNDDIR) ; \
 	cd ../manual; cp $(JTPMANUALFILES) $(JTPMANUALDIR) )
@@ -247,9 +256,6 @@ dofiles-jtp:
 	-( cd $(JTPMAINDIR) ; $(CHOWN) $(GAMEUID) $(JTPMAINFILES) ; \
 	$(CHGRP) $(GAMEGRP) $(JTPMAINFILES) ; \
 	chmod $(FILEPERM) $(JTPMAINFILES) ; \
-	cd $(JTPDATADIR) ; $(CHOWN) $(GAMEUID) $(JTPDATAFILES) ; \
-	$(CHGRP) $(GAMEGRP) $(JTPDATAFILES) ; \
-	chmod $(FILEPERM) $(JTPDATAFILES) ; \
 	cd $(JTPGRAPHICSDIR) ; $(CHOWN) $(GAMEUID) $(JTPGRAPHICSFILES) ; \
 	$(CHGRP) $(GAMEGRP) $(JTPGRAPHICSFILES) ; \
 	chmod $(FILEPERM) $(JTPGRAPHICSFILES) ; \
@@ -280,19 +286,27 @@ install: $(GAME) $(VARDAT) dungeon spec_
 # set up the directories
 # not all mkdirs have -p; those that don't will create a -p directory
 	-mkdir -p $(SHELLDIR)
-	-rm -rf $(GAMEDIR) $(VARDIR)
 	-mkdir -p $(GAMEDIR) $(VARDIR) $(VARDIR)/save
 	-rmdir ./-p
 	-$(CHOWN) $(GAMEUID) $(GAMEDIR) $(VARDIR) $(VARDIR)/save
 	$(CHGRP) $(GAMEGRP) $(GAMEDIR) $(VARDIR) $(VARDIR)/save
-	chmod $(DIRPERM) $(GAMEDIR) $(VARDIR) $(VARDIR)/save
+	chmod $(DIRPERM) $(GAMEDIR) $(VARDIR)
+	chmod 770 $(VARDIR)/save
 # set up the game files
 	( $(MAKE) dofiles )
 # set up some additional files
-	touch $(VARDIR)/perm $(VARDIR)/record $(VARDIR)/logfile
-	-( cd $(VARDIR) ; $(CHOWN) $(GAMEUID) perm record logfile ; \
-			$(CHGRP) $(GAMEGRP) perm record logfile ; \
-			chmod $(FILEPERM) perm record logfile )
+	touch $(VARDIR)/perm
+	-( cd $(VARDIR) ; $(CHOWN) $(GAMEUID) perm ; \
+			$(CHGRP) $(GAMEGRP) perm ; \
+			chmod $(FILEPERM) perm )
+	-mkdir -p $(PREFIX)/share/doc/$(GAME)
+	cp doc/Guidebook.txt $(PREFIX)/share/doc/$(GAME)
+	chown $(GAMEUID):$(GAMEGRP) $(PREFIX)/share/doc/$(GAME)/Guidebook.txt
+	chmod $(FILEPERM) $(PREFIX)/share/doc/$(GAME)/Guidebook.txt
+	cp util/recover $(PREFIX)/bin/recover-$(GAME)
+	: chown 0:0 $(PREFIX)/bin/recover-$(GAME)
+	chmod 755 $(PREFIX)/bin/recover-$(GAME)
+
 # and a reminder
 	@echo You may also want to reinstall the man pages via the doc Makefile.
 
