Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

nmh compiled for Cygwin

0 views
Skip to first unread message

Earl Hood

unread,
Apr 22, 2002, 6:49:33 PM4/22/02
to

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 write statement for cygwin. Maybe someone
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. The accuracy of such a hack should be
verified by others.

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.

uip/Makefile
Modified to install under cygwin since executables under
Windows end in .exe. Ideally this should be part of
Makefile.in with EXE_SUFFIX set via autoconf.

(configure)
I did,

LIBS=-lgdbm ./configure

If -lgdbm is not specified, dbm_* link errors happen.


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
*/

*** sbr/discard.c.org Mon Apr 22 13:45:00 2002
--- sbr/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
}

*** zotnet/tws/dtime.c.org Mon Apr 22 15:22:45 2002
--- zotnet/tws/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

*** zotnet/tws/dtimep.c-lexed.org Mon Apr 22 11:41:28 2002
--- zotnet/tws/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++;

*** uip/Makefile.org Mon Apr 22 16:58:53 2002
--- uip/Makefile Mon Apr 22 17:00:18 2002
***************
*** 7,12 ****
--- 7,14 ----

SHELL = /bin/sh

+ EXE_SUFFIX = .exe
+
top_srcdir = ..
srcdir = .

***************
*** 250,296 ****
install-cmds:
$(top_srcdir)/mkinstalldirs $(bindir)
for cmd in $(CMDS); do \
! $(INSTALL_PROGRAM) $$cmd $(bindir)/$$cmd; \
done

# install links
install-lcmds:
! rm -f $(bindir)/flists
! rm -f $(bindir)/folders
! rm -f $(bindir)/prev
! rm -f $(bindir)/next
! $(LN) $(bindir)/flist $(bindir)/flists
! $(LN) $(bindir)/folder $(bindir)/folders
! $(LN) $(bindir)/show $(bindir)/prev
! $(LN) $(bindir)/show $(bindir)/next

# install misc support binaries
install-misc:
$(top_srcdir)/mkinstalldirs $(libdir)
for misc in $(MISC); do \
! $(INSTALL_PROGRAM) $$misc $(libdir)/$$misc; \
done

# install commands with special installation needs (thus no $(SCMDS) use here)
install-scmds:
if test x$(SETGID_MAIL) != x; then \
! $(INSTALL_PROGRAM) -g $(MAIL_SPOOL_GRP) -m 2755 inc $(bindir)/$$cmd; \
else \
! $(INSTALL_PROGRAM) inc $(bindir)/$$cmd; \
fi

uninstall:
for cmd in $(CMDS); do \
! rm -f $(bindir)/$$cmd; \
done
for lcmd in $(LCMDS); do \
! rm -f $(bindir)/$$lcmd; \
done
for misc in $(MISC); do \
! rm -f $(libdir)/$$misc; \
done
for cmd in $(SCMDS); do \
! rm -f $(bindir)/$$cmd; \
done

# ========== DEPENDENCIES FOR CLEANUP ==========
--- 252,298 ----
install-cmds:
$(top_srcdir)/mkinstalldirs $(bindir)
for cmd in $(CMDS); do \
! $(INSTALL_PROGRAM) $$cmd$(EXE_SUFFIX) $(bindir)/$$cmd$(EXE_SUFFIX); \
done

# install links
install-lcmds:
! rm -f $(bindir)/flists$(EXE_SUFFIX)
! rm -f $(bindir)/folders$(EXE_SUFFIX)
! rm -f $(bindir)/prev$(EXE_SUFFIX)
! rm -f $(bindir)/next$(EXE_SUFFIX)
! $(LN) $(bindir)/flist$(EXE_SUFFIX) $(bindir)/flists$(EXE_SUFFIX)
! $(LN) $(bindir)/folder$(EXE_SUFFIX) $(bindir)/folders$(EXE_SUFFIX)
! $(LN) $(bindir)/show$(EXE_SUFFIX) $(bindir)/prev$(EXE_SUFFIX)
! $(LN) $(bindir)/show$(EXE_SUFFIX) $(bindir)/next$(EXE_SUFFIX)

# install misc support binaries
install-misc:
$(top_srcdir)/mkinstalldirs $(libdir)
for misc in $(MISC); do \
! $(INSTALL_PROGRAM) $$misc$(EXE_SUFFIX) $(libdir)/$$misc$(EXE_SUFFIX); \
done

# install commands with special installation needs (thus no $(SCMDS) use here)
install-scmds:
if test x$(SETGID_MAIL) != x; then \
! $(INSTALL_PROGRAM) -g $(MAIL_SPOOL_GRP) -m 2755 inc$(EXE_SUFFIX) $(bindir)/inc$(EXE_SUFFIX); \
else \
! $(INSTALL_PROGRAM) inc$(EXE_SUFFIX) $(bindir)/inc$(EXE_SUFFIX); \
fi

uninstall:
for cmd in $(CMDS); do \
! rm -f $(bindir)/$$cmd$(EXE_SUFFIX); \
done
for lcmd in $(LCMDS); do \
! rm -f $(bindir)/$$lcmd$(EXE_SUFFIX); \
done
for misc in $(MISC); do \
! rm -f $(libdir)/$$misc$(EXE_SUFFIX); \
done
for cmd in $(SCMDS); do \
! rm -f $(bindir)/$$cmd$(EXE_SUFFIX); \
done

# ========== DEPENDENCIES FOR CLEANUP ==========
--
Earl Hood
ea...@earlhood.com
<URL:http://www.earlhood.com/>

0 new messages