From be61b1a69e41353fa7cf468513c2cf564d56cae8 Mon Sep 17 00:00:00 2001 From: "John \"Elwin\" Edwards" Date: Wed, 7 May 2014 14:08:38 -0700 Subject: [PATCH] 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. --- README.txt | 13 ++++++++++++- arogue5/configure.ac | 2 +- arogue5/mdport.c | 30 ++++++++++++++++++++---------- rogue4/configure.ac | 4 +--- rogue4/mdport.c | 37 ++++++++++++------------------------- 5 files changed, 46 insertions(+), 40 deletions(-) diff --git a/README.txt b/README.txt index ddc4de8..a76b346 100644 --- a/README.txt +++ b/README.txt @@ -7,7 +7,7 @@ with the dgamelaunch online play system. Some bugs have also been fixed, and 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 @@ To install on Windows: 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. diff --git a/arogue5/configure.ac b/arogue5/configure.ac index 21d03ee..8de73db 100644 --- a/arogue5/configure.ac +++ b/arogue5/configure.ac @@ -13,7 +13,7 @@ AC_PROG_CC 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 diff --git a/arogue5/mdport.c b/arogue5/mdport.c index 5bad93f..4af7270 100644 --- a/arogue5/mdport.c +++ b/arogue5/mdport.c @@ -42,9 +42,15 @@ #undef MOUSE_MOVED #elif defined(__DJGPP__) #include -#else +#endif + +#ifdef HAVE_PWD_H #include +#endif +#ifdef HAVE_SYS_UTSNAME_H #include +#endif +#ifdef HAVE_UNISTD_H #include #endif @@ -57,12 +63,10 @@ #include -#if defined(__INTERIX) || defined(__MSYS__) +#if defined(HAVE_TERM_H) #include #elif defined(HAVE_NCURSES_TERM_H) #include -#else -#include #endif #include @@ -93,14 +97,20 @@ md_init() } int -md_hasclreol() +md_hasclreol(void) { -#ifndef attron - return(!CE); -#elif !defined(__PDCURSES__) - return(clr_eol != NULL); -#else +#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((CE != NULL) && (*CE != 0)); #endif } diff --git a/rogue4/configure.ac b/rogue4/configure.ac index b4b2818..a5d9bcd 100644 --- a/rogue4/configure.ac +++ b/rogue4/configure.ac @@ -14,9 +14,7 @@ AC_PROG_CC 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 diff --git a/rogue4/mdport.c b/rogue4/mdport.c index 3a010db..4db7989 100644 --- a/rogue4/mdport.c +++ b/rogue4/mdport.c @@ -29,6 +29,10 @@ SUCH DAMAGE. */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #if defined(_WIN32) #include #include @@ -40,10 +44,15 @@ #undef MOUSE_MOVED #elif defined(__DJGPP__) #include -#else +#endif + +#ifdef HAVE_PWD_H #include -#include +#endif +#ifdef HAVE_UNISTD_H #include +#endif +#ifdef HAVE_UTMPX_H #include #endif @@ -60,7 +69,7 @@ char *strdup(const char *s); #endif #include -#if !defined(DJGPP) +#ifdef HAVE_TERM_H #include #endif @@ -657,28 +666,6 @@ md_memused() #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() {