changeset 122:65f3da34578a

rogue4, arogue5: improve portability. Most changes merely prevent including header files that don't exist. All games now build and run on MinGW, though bugs remain.
author John "Elwin" Edwards
date Wed, 07 May 2014 14:08:38 -0700
parents e6c8652473fe
children 8dd4b06a9155
files README.txt arogue5/configure.ac arogue5/mdport.c rogue4/configure.ac rogue4/mdport.c
diffstat 5 files changed, 46 insertions(+), 40 deletions(-) [+]
line wrap: on
line diff
--- a/README.txt	Sat May 03 10:31:30 2014 -0700
+++ b/README.txt	Wed May 07 14:08:38 2014 -0700
@@ -7,7 +7,7 @@
 the build process slightly improved.  The essential flavor of a codebase half
 as old as stored-program computing machinery remains unchanged.
 
-To install on Unix:
+To install on Unix (including OS X):
 
 If you checked out the source from Mercurial, run 'autoreconf' first.
 
@@ -26,6 +26,17 @@
 Use the included Visual Studio solution files.  Warning: they have not been 
 tested recently.
 
+You can also build on Windows using MinGW.  Make sure pdcurses is installed.
+You will have to go into the '/lib' folder and copy 'libpdcurses.a' to
+'libcurses.a', and 'libpdcurses.dll.a' to 'libcurses.dll.a'; this should get
+fixed soon.
+
+It is recommended to run 'configure' with the '--disable-logfile' option, and
+'make' with the 'LDFLAGS=-static' option.
+
+The games should all build with MinGW, but there are still bugs with arrow keys
+and saving/restoring.
+
 See the individual games' subdirectories for further documentation.  Some of 
 the manpages may be outdated, but the guides to playing should be accurate.
 
--- a/arogue5/configure.ac	Sat May 03 10:31:30 2014 -0700
+++ b/arogue5/configure.ac	Wed May 07 14:08:38 2014 -0700
@@ -13,7 +13,7 @@
 MP_WITH_CURSES
 # Checks for header files.
 AC_HEADER_STDC
-AC_CHECK_HEADERS([pwd.h errno.h fcntl.h limits.h nlist.h stdlib.h string.h sys/ioctl.h termios.h unistd.h utmp.h term.h ncurses/term.h process.h])
+AC_CHECK_HEADERS([pwd.h errno.h fcntl.h limits.h nlist.h stdlib.h string.h sys/ioctl.h sys/utsname.h termios.h unistd.h utmp.h term.h ncurses/term.h process.h])
 
 # Checks for typedefs, structures, and compiler characteristics.
 AC_TYPE_SIZE_T
--- a/arogue5/mdport.c	Sat May 03 10:31:30 2014 -0700
+++ b/arogue5/mdport.c	Wed May 07 14:08:38 2014 -0700
@@ -42,9 +42,15 @@
 #undef MOUSE_MOVED
 #elif defined(__DJGPP__)
 #include <process.h>
-#else
+#endif
+
+#ifdef HAVE_PWD_H
 #include <pwd.h>
+#endif
+#ifdef HAVE_SYS_UTSNAME_H
 #include <sys/utsname.h>
+#endif
+#ifdef HAVE_UNISTD_H
 #include <unistd.h>
 #endif
 
@@ -57,12 +63,10 @@
 
 #include <curses.h>
 
-#if defined(__INTERIX) || defined(__MSYS__)
+#if defined(HAVE_TERM_H)
 #include <term.h>
 #elif defined(HAVE_NCURSES_TERM_H)
 #include <ncurses/term.h>
-#else
-#include <term.h>
 #endif
 
 #include <stdio.h>
@@ -93,14 +97,20 @@
 }
 
 int
-md_hasclreol()
+md_hasclreol(void)
 {
-#ifndef	attron
-    return(!CE);
-#elif !defined(__PDCURSES__)
-    return(clr_eol != NULL);
+#if defined(clr_eol)
+#ifdef NCURSES_VERSION
+    if (cur_term == NULL)
+	return(0);
+    if (cur_term->type.Strings == NULL)
+	return(0);
+#endif
+    return((clr_eol != NULL) && (*clr_eol != 0));
+#elif defined(__PDCURSES__)
+    return(TRUE);
 #else
-    return(TRUE);
+    return((CE != NULL) && (*CE != 0));
 #endif
 }
 
--- a/rogue4/configure.ac	Sat May 03 10:31:30 2014 -0700
+++ b/rogue4/configure.ac	Wed May 07 14:08:38 2014 -0700
@@ -14,9 +14,7 @@
 MP_WITH_CURSES
 # Checks for header files.
 AC_HEADER_STDC
-AC_CHECK_HEADERS([arpa/inet.h sys/utsname.h pwd.h fcntl.h limits.h nlist.h stdlib.h string.h sys/ioctl.h termios.h unistd.h utmp.h term.h ncurses/term.h process.h])
-# WARN: the sources often don't include the headers when needed.  That is one
-# reason why adding "-Wall" to CFLAGS produces 1246 lines of messages.
+AC_CHECK_HEADERS([arpa/inet.h sys/utsname.h pwd.h fcntl.h limits.h nlist.h stdlib.h string.h sys/ioctl.h termios.h unistd.h utmpx.h term.h ncurses/term.h process.h])
 
 # Checks for typedefs, structures, and compiler characteristics.
 AC_TYPE_UID_T
--- a/rogue4/mdport.c	Sat May 03 10:31:30 2014 -0700
+++ b/rogue4/mdport.c	Wed May 07 14:08:38 2014 -0700
@@ -29,6 +29,10 @@
     SUCH DAMAGE.
 */
 
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
 #if defined(_WIN32)
 #include <Windows.h>
 #include <Lmcons.h>
@@ -40,10 +44,15 @@
 #undef MOUSE_MOVED
 #elif defined(__DJGPP__)
 #include <process.h>
-#else
+#endif
+
+#ifdef HAVE_PWD_H
 #include <pwd.h>
-#include <sys/utsname.h>
+#endif
+#ifdef HAVE_UNISTD_H
 #include <unistd.h>
+#endif
+#ifdef HAVE_UTMPX_H
 #include <utmpx.h>
 #endif
 
@@ -60,7 +69,7 @@
 #endif
 
 #include <curses.h>
-#if !defined(DJGPP)
+#ifdef HAVE_TERM_H
 #include <term.h>
 #endif
 
@@ -657,28 +666,6 @@
 #endif
 }
 
-char *
-md_gethostname()
-{
-    static char nodename[80];
-    char *n = NULL;
-#if !defined(_WIN32) && !defined(__DJGPP__)
-    struct utsname ourname;
-
-    if (uname(&ourname) == 0)
-        n = ourname.nodename;
-#endif
-    if ((n == NULL) || (*n == '\0'))
-        if ( (n = getenv("COMPUTERNAME")) == NULL)
-            if ( (n = getenv("HOSTNAME")) == NULL)
-                n = "localhost";
-
-    strncpy(nodename, n, 80);
-    nodename[79] = 0;
-
-    return(nodename);
-}
-
 int
 md_erasechar()
 {