Well, after some hacking, I got nmh 1.0.4 to compile under cygwin. Here are the problem highlights:
sbr/discard.c: fpurge() does not exist under cygwin and the _FSTDIO appears to get set by the compiler. I added a #ifdef __CYGWIN__ check to deal with this. I examined the /usr/include header files to see how the FILE struct is done and made a stab at putting the correct statement for cygwin. Maybe someone with more knowledge can verify if the cygwin patch is proper. I do find it ugly that the internal FILE struct must be used. zotnet/tws/{dtime,dtimep.c}: The extern timezone declaration does not work under cygwin. Hence, I did a hack to work around this. I'm not sure how robust my hack is since I could not find anything convenient under cygwin to give a good timezone value. The ftimeb() call appears to give invalid data, so I rolled a hack by computing the timezone minute offset by comparing gmt time with local time. Note, I edited the pre-lexed dtimep.c to get things to compile. Ideally, timezone computation should be abstracted into a utility function to make dtime.c and dtimep.c cleaner. config.in I added lines for timezone hack above. Something better should probably be done. (configure) I did, LIBS=-lgdbm ./configure If -lgdbm is not specified, dbm_* link errors happen. (installation): Windows has all executables ending with .exe. Hence, make install fails. I did a hack on uip/Makefile to get things to work. It appears it should be easy to handle with autoconf to define the value of EXE_SUFFIX to .exe if building under cygwin. I do not know autoconf, so hopefully someone else can help. Following are context diffs of files I changed. For those who maintain nmh, I hope these patches, or something like them, can be incorporated in the main nmh source since it appears there is some demand for nmh on cygwin. *** config.h.in.org Mon Apr 22 15:19:25 2002 --- config.h.in Mon Apr 22 14:29:23 2002 *************** *** 12,17 **** --- 12,21 ---- * wish to change the features that are compiled into nmh. */ + #ifdef __CYGWIN__ + #define TZ_HACK 1 + #endif + /* * Turn on locale (setlocale) support */ *** discard.c.org Mon Apr 22 13:45:00 2002 --- discard.c Mon Apr 22 13:47:54 2002 *************** *** 51,64 **** # endif #endif ! #ifdef _FSTDIO ! fpurge (io); #else ! # ifdef LINUX_STDIO ! io->_IO_write_ptr = io->_IO_write_base; # else if ((io->_ptr = io->_base)) io->_cnt = 0; # endif #endif } --- 51,68 ---- # endif #endif ! #ifdef __CYGWIN__ ! io->_p = io->_bf._base; #else ! # ifdef _FSTDIO ! fpurge (io); # else + # ifdef LINUX_STDIO + io->_IO_write_ptr = io->_IO_write_base; + # else if ((io->_ptr = io->_base)) io->_cnt = 0; + # endif # endif #endif } *** dtime.c.org Mon Apr 22 15:22:45 2002 --- dtime.c Mon Apr 22 13:15:19 2002 *************** *** 26,32 **** --- 26,34 ---- #if !defined(HAVE_TM_GMTOFF) && defined(HAVE_TZSET) extern int daylight; + # if !defined(TZ_HACK) extern long timezone; + # endif extern char *tzname[]; #endif *************** *** 138,143 **** --- 140,151 ---- static struct tws tw; struct tm *tm; + #ifdef TZ_HACK + struct tm tm_local; + struct tm tm_gmt; + time_t clock_local; + time_t clock_gmt; + #endif #if !defined(HAVE_TM_GMTOFF) && !defined(HAVE_TZSET) struct timeb tb; #endif *************** *** 165,181 **** if (tm->tm_isdst) tw.tw_flags |= TW_DST; ! #ifdef HAVE_TM_GMTOFF tw.tw_zone = tm->tm_gmtoff / 60; if (tm->tm_isdst) /* if DST is in effect */ tw.tw_zone -= 60; /* reset to normal offset */ ! #else ! # ifdef HAVE_TZSET tzset(); tw.tw_zone = -(timezone / 60); ! # else ftime (&tb); tw.tw_zone = -tb.timezone; # endif #endif --- 173,200 ---- if (tm->tm_isdst) tw.tw_flags |= TW_DST; ! #ifdef TZ_HACK ! gmtime_r(clock, &tm_gmt); ! localtime_r(clock, &tm_local); ! clock_gmt = mktime(&tm_gmt); ! clock_local = mktime(&tm_local); ! tw.tw_zone = (int)(difftime(clock_gmt, clock_local)/60); ! if (tm_local.tm_isdst) /* if DST is in effect */ ! tw.tw_zone -= 60; /* reset to normal offset */ ! ! #else ! # ifdef HAVE_TM_GMTOFF tw.tw_zone = tm->tm_gmtoff / 60; if (tm->tm_isdst) /* if DST is in effect */ tw.tw_zone -= 60; /* reset to normal offset */ ! # else ! # ifdef HAVE_TZSET tzset(); tw.tw_zone = -(timezone / 60); ! # else ftime (&tb); tw.tw_zone = -tb.timezone; + # endif # endif #endif *** dtimep.c-lexed.org Mon Apr 22 11:41:28 2002 --- dtimep.c-lexed Mon Apr 22 12:59:14 2002 *************** *** 12,18 **** # include <sys/timeb.h> #endif ! #if !defined(HAVE_TM_GMTOFF) && defined(HAVE_TZSET) extern int daylight; extern long timezone; extern char *tzname[]; --- 12,18 ---- # include <sys/timeb.h> #endif ! #if !defined(TZ_HACK) && !defined(HAVE_TM_GMTOFF) && defined(HAVE_TZSET) extern int daylight; extern long timezone; extern char *tzname[]; *************** *** 140,153 **** register int gotdate = 0; time_t tclock; ! #ifdef HAVE_TM_GMTOFF struct tm *tm; time_t clock; ! #else ! # ifndef HAVE_TZSET struct timeb tb; ! # endif /* not HAVE_TZSET */ ! #endif /* HAVE_TM_GMTOFF */ start_cond = 0; --- 140,161 ---- register int gotdate = 0; time_t tclock; ! #ifdef TZ_HACK ! struct tm tm_local; ! struct tm tm_gmt; ! time_t clock_local; ! time_t clock_gmt; ! ! #else ! # ifdef HAVE_TM_GMTOFF struct tm *tm; time_t clock; ! # else ! # ifndef HAVE_TZSET struct timeb tb; ! # endif /* not HAVE_TZSET */ ! # endif /* HAVE_TM_GMTOFF */ ! #endif /* TM_HACK */ start_cond = 0; *************** *** 155,175 **** memset( (char *) &tw, 0, sizeof(tw)); /* Set default time zone. */ ! #ifdef HAVE_TM_GMTOFF time (&clock); tm = localtime(&clock); tw.tw_zone = tm->tm_gmtoff / 60; if (tm->tm_isdst) /* if DST is in effect */ tw.tw_zone -= 60; /* reset to normal offset */ ! #else ! # ifdef HAVE_TZSET tzset(); tw.tw_zone = -(timezone / 60); ! # else ftime(&tb); tw.tw_zone = -tb.timezone; ! # endif /* HAVE_TZSET */ ! #endif /* HAVE_TM_GMTOFF */ while (isspace(*str)) str++; --- 163,195 ---- memset( (char *) &tw, 0, sizeof(tw)); /* Set default time zone. */ ! #ifdef TZ_HACK ! time (&tclock); ! gmtime_r(&tclock, &tm_gmt); ! localtime_r(&tclock, &tm_local); ! clock_gmt = mktime(&tm_gmt); ! clock_local = mktime(&tm_local); ! tw.tw_zone = (int)(difftime(clock_gmt, clock_local)/60); ! if (tm_local.tm_isdst) /* if DST is in effect */ ! tw.tw_zone -= 60; /* reset to normal offset */ ! ! #else ! # ifdef HAVE_TM_GMTOFF time (&clock); tm = localtime(&clock); tw.tw_zone = tm->tm_gmtoff / 60; if (tm->tm_isdst) /* if DST is in effect */ tw.tw_zone -= 60; /* reset to normal offset */ ! # else ! # ifdef HAVE_TZSET tzset(); tw.tw_zone = -(timezone / 60); ! # else ftime(&tb); tw.tw_zone = -tb.timezone; ! # endif /* HAVE_TZSET */ ! # endif /* HAVE_TM_GMTOFF */ ! #endif /* TZ_HACK */ while (isspace(*str)) str++;