Building HDF4 on Windows

Moved from hdf, doesn't work due to XDR-related bugs in HDF4's build system. This is fixable, but not trivially.

HDF4

First, get the latest source (currently 4.2r4) from http://www.hdfgroup.org/release4/obtain.html and extract it in a convenient place.

HDF4's autoconf infrastructure is a weird mix of too-old and too-new. Open configure.ac, look for “Libtool initialization” (around line 660) and replace the following two lines

LT_INIT(dlopen)
LT_OUTPUT

with these:

AC_LIBTOOL_DLOPEN
AM_PROG_LIBTOOL

Next, there is a spot in configure.ac that checks which OS you're running on and bails if it doesn't recognize it... which is stupid, because it controls code that is only used *only* if you want to use HDF4's own version of NetCDF, which we don't. We can work around this by changing cygwin to mingw32 on line 695. It's wrong, but it doesn't matter, because the result is never used (see below).

Finally, MinGW doesn't have the Sun RPC library, so there are some missing SOURCES, INCLUDES and LDADD lines in several Makefiles:

$ echo 'libxdr_la_SOURCES += byteordr.c' >>mfhdf/xdr/Makefile.am
$ echo 'INCLUDES += -I$(top_srcdir)/mfhdf/xdr' >>mfhdf/libsrc/Makefile.am
$ echo 'INCLUDES += -I$(top_srcdir)/mfhdf/xdr' >>mfhdf/ncdump/Makefile.am
$ echo 'ncdump_LDADD += ../xdr/libxdr.la'>>mfhdf/ncdump/Makefile.am

XXX still doesn't work

Then regenerate everything:

$ aclocal
$ libtoolize --copy --force
$ autoheader
$ automake --add-missing --copy --foreign
$ autoconf

XXX automake warns about F77LINK, check if that requires fixing. harmless since we don't build the Fortran interface

Finally, configure, build and install:

$ LDFLAGS=-L/c/met.no/lib CPPFLAGS="-I/c/met.no/include -DNO_SYS_XDR_INC" ./configure --prefix=/c/met.no --disable-fortran --disable-netcdf
$ make all install

The -DNO_SYS_XDR_INC part fixes more xdr-related breakage.

You must specify --disable-netcdf, otherwise HDF4 will clobber NetCDF's header files!

XXX I'm worried that the xdr stuff may cause more trouble down the line