Here's a patch for moria, to use termios.h and tcgetattr/tcsetattr
rather than ioctl's if USE_TERMIOS is defined.

While here:
- regen distinfo
- reorder Makefile to match Makefile.template
- setup separate build directory in post-configure rather than do-build
- pass CFLAGS=-DPREFIX=... via MAKE_FLAGS and use do-install instead of
  patching unix/Makefile (much nicer to read, imho...)

ok?

Index: Makefile
===================================================================
RCS file: /cvs/ports/games/moria/Makefile,v
retrieving revision 1.16
diff -u -p -r1.16 Makefile
--- Makefile    5 Apr 2013 20:36:27 -0000       1.16
+++ Makefile    12 Dec 2013 15:10:56 -0000
@@ -5,34 +5,43 @@ COMMENT=      The Dungeons of Moria
 V=             5.5.2
 DISTNAME=      um$V
 PKGNAME=       moria-$V
-REVISION=      2
+REVISION=      3
+
 CATEGORIES=    games
-MASTER_SITES=  ftp://ftp.funet.fi/pub/unix/games/moria/source/ \
-               ftp://alge.anart.no/pub/games/RPG/moria/
-EXTRACT_SUFX=  .tar.Z
 
 HOMEPAGE=      http://www-math.bgsu.edu/~grabine/moria.html
 
 PERMIT_PACKAGE_CDROM=  not-for-profit redistribution only
 PERMIT_PACKAGE_FTP=    Yes
-WANTLIB=               c curses termcap
+
+WANTLIB=       c curses termcap
+
+MASTER_SITES=  ftp://ftp.funet.fi/pub/unix/games/moria/source/ \
+               ftp://alge.anart.no/pub/games/RPG/moria/
+EXTRACT_SUFX=  .tar.Z
+
+MAKE_FLAGS=    CC="${CC}" CFLAGS='-DPREFIX=\"${PREFIX}\" ${CFLAGS}'
+
+SEPARATE_BUILD= Yes
 
 NO_TEST=       Yes
 
 WRKDIST=       ${WRKDIR}/umoria
-WRKSRC=                ${WRKDIST}
 
-SEPARATE_BUILD= Yes
-MAKE_ENV=      CC="${CC}" CFLAGS="${CFLAGS}"
+ALL_TARGET=    moria
+
+libfiles=      hours news origcmds.hlp owizcmds.hlp roglcmds.hlp \
+               rwizcmds.hlp version.hlp welcome.hlp
 
-do-build:
-       @cd ${WRKBUILD}; for i in ${WRKSRC}/source/*; do ln -sf $$i; done; \
+post-configure:
+       cd ${WRKBUILD}; for i in ${WRKSRC}/source/*; do ln -sf $$i; done; \
         for i in ${WRKSRC}/unix/*; do ln -sf $$i; done; \
-        ln -sf ${WRKSRC}/files; \
-        ${SETENV} ${MAKE_ENV} ${MAKE_PROGRAM} ${MAKE_FLAGS} PREFIX="${PREFIX}"
+        ln -sf ${WRKSRC}/files
 
 do-install:
-       ${INSTALL_DATA_DIR} ${PREFIX}/share/moria
-       @cd ${WRKBUILD}; ${MAKE_PROGRAM} ${ALL_FAKE_FLAGS} install
+       ${INSTALL_PROGRAM} -g games -m 2711 ${WRKBUILD}/moria ${PREFIX}/bin
+       ${INSTALL_DATA_DIR} -m 711 ${PREFIX}/share/moria
+       cd ${WRKBUILD}/files; ${INSTALL_DATA} ${libfiles} ${PREFIX}/share/moria
+       ${INSTALL_DATA} /dev/null ${PREFIX}/share/moria/scores
 
 .include <bsd.port.mk>
Index: distinfo
===================================================================
RCS file: /cvs/ports/games/moria/distinfo,v
retrieving revision 1.3
diff -u -p -r1.3 distinfo
--- distinfo    5 Apr 2007 15:38:11 -0000       1.3
+++ distinfo    11 Dec 2013 21:21:01 -0000
@@ -1,5 +1,2 @@
-MD5 (um5.5.2.tar.Z) = BKKFKGQwLHAugpkgI9lxhA==
-RMD160 (um5.5.2.tar.Z) = FVbHbxUdfqKdp5BxpXOY9j0LE4s=
-SHA1 (um5.5.2.tar.Z) = acenv04sW+Ej7nqC9a0SrV0PWwg=
 SHA256 (um5.5.2.tar.Z) = //q2VwPHcFihqt2GR8wfRL1DSQZa8LM0cCmG82AHsu0=
 SIZE (um5.5.2.tar.Z) = 910536
Index: patches/patch-source_io_c
===================================================================
RCS file: /cvs/ports/games/moria/patches/patch-source_io_c,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 patch-source_io_c
--- patches/patch-source_io_c   4 Jul 2001 16:57:50 -0000       1.1.1.1
+++ patches/patch-source_io_c   12 Dec 2013 13:56:19 -0000
@@ -1,34 +1,103 @@
 $OpenBSD: patch-source_io_c,v 1.1.1.1 2001/07/04 16:57:50 lebel Exp $
---- source/io.c.orig   Wed Jul  4 12:25:44 2001
-+++ source/io.c        Wed Jul  4 12:25:53 2001
-@@ -60,7 +60,8 @@ long wgetch();
+--- source/io.c.orig   Fri Jul 22 03:47:26 1994
++++ source/io.c        Thu Dec 12 14:55:49 2013
+@@ -60,6 +60,10 @@ long wgetch();
  char *getenv();
  #endif
  
--
-+#include <sys/ioctl_compat.h>
-+#include <curses.h>
++#ifdef __OpenBSD__
++#define USG
++#define USE_TERMIOS
++#endif
+ 
  #include <ctype.h>
  
- #if defined(SYS_V) && defined(lint)
-@@ -245,7 +246,6 @@ int suspend()
+@@ -109,6 +113,14 @@ typedef struct { int stuff; } fpvmach;
+ /* Needs termio.h because curses.h doesn't include it */
+ #include <termio.h>
+ #endif
++#ifdef USE_TERMIOS
++# include <termios.h>
++#else
++# define termios termio
++# define tcgetattr(a, b) ioctl((a), TCGETA, (char *)(b))
++# define tcsetattr(a, b, c) ioctl((a), (b), (char *)(c))
++# define TCSANOW TCSETA
++#endif
+ #else /* ! USG */
+ #include <strings.h>
+ #if defined(atarist) && defined(__GNUC__)
+@@ -201,12 +213,8 @@ void sleep();
+ #if !defined(MAC) && !defined(MSDOS) && !defined(ATARI_ST) && !defined(VMS)
+ #ifndef AMIGA
+ #ifdef USG
+-#ifdef __linux__
+ static struct termios save_termio;
+ #else
+-static struct termio save_termio;
+-#endif
+-#else
+ static struct ltchars save_special_chars;
+ static struct sgttyb save_ttyb;
+ static struct tchars save_tchars;
+@@ -237,32 +245,45 @@ static WINDOW *tempscr;          /* Spare window for VMS 
CTRL(
+    restored.  */
+ int suspend()
+ {
+-#ifdef USG
++#if defined(USG) && !defined(__OpenBSD__)
+   /* for USG systems with BSDisms that have SIGTSTP defined, but don't
+      actually implement it */
+ #else
++#ifdef USE_TERMIOS
++  struct termios tbuf;
++#else
+   struct sgttyb tbuf;
    struct ltchars lcbuf;
    struct tchars cbuf;
    int lbuf;
 -  long time();
++#endif
  
    py.misc.male |= 2;
++#ifdef USE_TERMIOS
++  (void) tcgetattr(0, &tbuf);
++#else
    (void) ioctl(0, TIOCGETP, (char *)&tbuf);
-@@ -316,7 +316,7 @@ void init_curses()
- #if defined(USG) && !defined(PC_CURSES) && !defined(AMIGA)
-   if (initscr() == NULL)
- #else
--  if (initscr() == ERR)
-+  if (initscr() == NULL)
- #endif
-     {
-       (void) printf("Error allocating screen in curses package.\n");
-@@ -334,7 +334,7 @@ void init_curses()
+   (void) ioctl(0, TIOCGETC, (char *)&cbuf);
+   (void) ioctl(0, TIOCGLTC, (char *)&lcbuf);
+ #if !defined(atarist) && !defined(__GNUC__)
+   (void) ioctl(0, TIOCLGET, (char *)&lbuf);
+ #endif
++#endif
++
+   restore_term();
+   (void) kill(0, SIGSTOP);
+   curses_on = TRUE;
++
++#ifdef USE_TERMIOS
++  (void) tcsetattr(0, TCSANOW, &tbuf);
++#else
+   (void) ioctl(0, TIOCSETP, (char *)&tbuf);
+   (void) ioctl(0, TIOCSETC, (char *)&cbuf);
+   (void) ioctl(0, TIOCSLTC, (char *)&lcbuf);
+ #if !defined(atarist) && !defined(__GNUC__)
+   (void) ioctl(0, TIOCLSET, (char *)&lbuf);
+ #endif
++#endif
+   (void) wrefresh(curscr);
+   py.misc.male &= ~2;
+ #endif
+@@ -307,7 +328,7 @@ void init_curses()
+ #else
+ #if !defined(VMS) && !defined(MSDOS) && !defined(ATARI_ST)
+ #ifndef AMIGA
+-  (void) ioctl(0, TCGETA, (char *)&save_termio);
++  (void) tcgetattr(0, &save_termio);
+ #endif
+ #endif
+ #endif
+@@ -334,7 +355,7 @@ void init_curses()
  #ifdef  __386BSD__
    (void) signal (SIGTSTP, (sig_t)suspend);
  #else
@@ -37,12 +106,83 @@ $OpenBSD: patch-source_io_c,v 1.1.1.1 20
  #endif
  #endif
  #endif
-@@ -760,7 +760,7 @@ void shell_out()
- #if defined(USG) || defined(__386BSD__)
-   (void) wait((int *) 0);
+@@ -385,12 +406,8 @@ void moriaterm()
+ #if !defined(MSDOS) && !defined(ATARI_ST) && !defined(VMS)
+ #ifndef AMIGA
+ #ifdef USG
+-#ifdef __linux__
+   struct termios tbuf;
+ #else
+-  struct termio tbuf;
+-#endif
+-#else
+   struct ltchars lbuf;
+   struct tchars buf;
+ #endif
+@@ -420,7 +437,7 @@ void moriaterm()
  #else
--  (void) wait((union wait *) 0);
-+  (void) wait((int *) 0);
+ #if !defined(ATARI_ST) && !defined(VMS)
+ #ifdef USG
+-  (void) ioctl(0, TCGETA, (char *)&tbuf);
++  (void) tcgetattr(0, &tbuf);
+   /* disable all of the normal special control characters */
+   tbuf.c_cc[VINTR] = (char)3; /* control-C */
+   tbuf.c_cc[VQUIT] = (char)-1;
+@@ -438,7 +455,7 @@ void moriaterm()
+   tbuf.c_cc[VMIN] = 1;  /* Input should wait for at least 1 char */
+   tbuf.c_cc[VTIME] = 0; /* no matter how long that takes. */
+ 
+-  (void) ioctl(0, TCSETA, (char *)&tbuf);
++  (void) tcgetattr(0, &tbuf);
+ #else
+   /* disable all of the special characters except the suspend char, interrupt
+      char, and the control flow start/stop characters */
+@@ -552,7 +569,7 @@ void restore_term()
+ #ifdef USG
+ #if !defined(MSDOS) && !defined(ATARI_ST) && !defined(VMS)
+ #ifndef AMIGA
+-  (void) ioctl(0, TCSETA, (char *)&save_termio);
++  (void) tcsetattr(0, TCSANOW, &save_termio);
+ #endif
  #endif
- #endif /* ATARI_ST */
- #endif                 /* MSDOS }*/
+ #else
+@@ -646,12 +663,8 @@ void shell_out()
+ {
+ #ifdef USG
+ #if !defined(MSDOS) && !defined(ATARI_ST) && !defined(AMIGA)
+-#ifdef __linux__
+   struct termios tbuf;
+-#else
+-  struct termio tbuf;
+ #endif
+-#endif
+ #else
+   struct sgttyb tbuf;
+   struct ltchars lcbuf;
+@@ -683,7 +696,7 @@ void shell_out()
+ 
+ #ifdef USG
+ #if !defined(MSDOS) && !defined(ATARI_ST) && !defined(AMIGA)
+-  (void) ioctl(0, TCGETA, (char *)&tbuf);
++  (void) tcgetattr(0, &tbuf);
+ #endif
+ #else
+   (void) ioctl(0, TIOCGETP, (char *)&tbuf);
+@@ -725,7 +738,7 @@ void shell_out()
+       default_signals();
+ #ifdef USG
+ #if !defined(MSDOS) && !defined(ATARI_ST) && !defined(AMIGA)
+-      (void) ioctl(0, TCSETA, (char *)&save_termio);
++      (void) tcsetattr(0, TCSANOW, &save_termio);
+ #endif
+ #else
+       (void) ioctl(0, TIOCSLTC, (char *)&save_special_chars);
+@@ -785,7 +798,7 @@ void shell_out()
+   /* have to disable ^Y for tunneling */
+ #ifdef USG
+ #if !defined(MSDOS) && !defined(ATARI_ST)
+-  (void) ioctl(0, TCSETA, (char *)&tbuf);
++  (void) tcsetattr(0, TCSANOW, &tbuf);
+ #endif
+ #else
+   (void) ioctl(0, TIOCSLTC, (char *)&lcbuf);
Index: patches/patch-unix_Makefile
===================================================================
RCS file: patches/patch-unix_Makefile
diff -N patches/patch-unix_Makefile
--- patches/patch-unix_Makefile 4 Jul 2001 16:57:50 -0000       1.1.1.1
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,65 +0,0 @@
-$OpenBSD: patch-unix_Makefile,v 1.1.1.1 2001/07/04 16:57:50 lebel Exp $
---- unix/Makefile.orig Wed Jul  4 12:31:27 2001
-+++ unix/Makefile      Wed Jul  4 12:31:34 2001
-@@ -3,15 +3,15 @@
- # 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 = ${TRUEPREFIX}/bin
-+LIBDIR = ${TRUEPREFIX}/share/moria
-+OWNER = root
-+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 += -DPREFIX=\"${PREFIX}\"
- 
- # For BSD Systems
- CURSES = -lcurses -ltermcap
-@@ -26,8 +26,6 @@ CURSES = -lcurses -ltermcap
- # Normal systems don't require anything here.
- LFLAGS = 
- 
--CC = cc
--
- SRCS = main.c misc1.c misc2.c misc3.c misc4.c store1.c files.c io.c \
-       create.c desc.c generate.c sets.c dungeon.c creature.c death.c \
-       eat.c help.c magic.c potions.c prayer.c save.c staffs.c wands.c \
-@@ -60,19 +58,19 @@ TAGS : $(SRCS)
- # you must define BINDIR and LIBDIR before installing
- # assumes that BINDIR and LIBDIR exist
- 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)
-+      chmod 755 $(DESTDIR)$(BINDIR)
-+      cp moria $(DESTDIR)$(BINDIR)
-+      chown $(OWNER) $(DESTDIR)$(BINDIR)/moria
-+      chgrp $(GROUP) $(DESTDIR)$(BINDIR)/moria
-+      chmod 711 $(DESTDIR)$(BINDIR)/moria; chmod g+s $(DESTDIR)$(BINDIR)/moria
-+      chmod 755 $(DESTDIR)$(LIBDIR)
-+      (cd files; cp $(LIBFILES) $(DESTDIR)$(LIBDIR))
-+      (cd $(DESTDIR)$(LIBDIR); chmod 444 $(LIBFILES))
-+      (cd $(DESTDIR)$(LIBDIR); touch scores; chmod 664 scores)
-+      (cd $(DESTDIR)$(LIBDIR); chown $(OWNER) $(LIBFILES) scores)
-+      (cd $(DESTDIR)$(LIBDIR); chgrp $(GROUP) $(LIBFILES) scores)
- # If you are short on disk space, or aren't interested in debugging moria.
--#     strip $(BINDIR)/moria
-+      strip $(DESTDIR)$(BINDIR)/moria
- 
- clean:
-       rm -r *.o
Index: pkg/PLIST
===================================================================
RCS file: /cvs/ports/games/moria/pkg/PLIST,v
retrieving revision 1.7
diff -u -p -r1.7 PLIST
--- pkg/PLIST   3 Nov 2005 14:45:09 -0000       1.7
+++ pkg/PLIST   12 Dec 2013 14:35:41 -0000
@@ -1,7 +1,7 @@
 @comment $OpenBSD: PLIST,v 1.7 2005/11/03 14:45:09 niallo Exp $
-@group games
 @mode g+s
-bin/moria
+@group games
+@bin bin/moria
 @mode
 share/moria/
 share/moria/hours

Reply via email to