In Progress
Note: There are 2 versions of HDF 4.x and 5.x, they are different and incompatible.
The patches in these instructions get the library built, the executables have not been tested. The libraries have been tested by way of the GDAL tests. I prefer describing the patches over patch files because it's easier to apply from the description when there are changes in future versions of the source. Except when the patch is messy.
version: 4.2r3
source: HDF Group
HDF4 has a lot of cruft for detecting endianess and bit size. The following patches so far work on v4.2r3 and 4.2r4, unless said otherwise.
Delete "-DSWAP" and "-DBIG_LONGS" whereever you find them – we need to set these dynamically in the config headers.
There is a long test right after the comment:
/* Generally Big-Endian machines */
Replace that test with:
#if !defined(__LITTLE_ENDIAN__)
Find the section that starts with:
#if defined (__APPLE__)
and ends with:
#endif /* __APPLE__ */
In that section, replace the line:
#ifdef __i386
with:
#ifdef __LITTLE_ENDIAN__
and replace the line:
typedef int hdf_pint_t;
with:
typedef long hdf_pint_t;
Then, well past that section, replace the line:
#if defined __x86_64__ && !(defined SUN)
with:
#if defined __x86_64__ && !(defined SUN) && !(defined __APPLE__)
In a small section defining nclong, replace the line:
#elif defined __alpha || (_MIPS_SZLONG == 64) || defined IA64 || (defined __sun__ && defined _LP64) || defined AIX5L64
with:
#elif defined __LP64__
Do the same as for netcdf.h.in.
Replace the line:
#if defined __alpha || (_MIPS_SZLONG == 64) || defined __ia64 || (defined __sun && defined _LP64) || defined AIX5L64 || defined __x86_64__
with:
#ifdef __LP64__
Here's a patch. Unzip it into the mfhdf/libsrc folder, cd to same folder in a Terminal, and run:
patch xdrposix.c < xdrposix.c.patch
In the HDF4 source:
export MACOSX_DEPLOYMENT_TARGET=10.5 ./configure --disable-fortran --disable-dependency-tracking --disable-netcdf \\ --with-jpeg=/Library/Frameworks/UnixImageIO.framework/unix \\ CFLAGS="-Os -arch i386 -arch ppc -arch x86_64 -arch ppc64"
– change the H4_SIZEOF_INTP line to:
#undef BIG_LONGS #ifdef __LP64__ #define H4_SIZEOF_INTP 8 #define BIG_LONGS 1 #else #define H4_SIZEOF_INTP 4 #endif
– change the H4_WORDS_BIGENDIAN line to:
#undef SWAP #ifdef __BIG_ENDIAN__ #define H4_WORDS_BIGENDIAN 1 #else #undef H4_WORDS_BIGENDIAN #define SWAP 1 #endif
make sudo make install
Quite a bit simpler than for Leopard.
Delete "-DSWAP" whereever you find it – we need to set these dynamically in the config headers.
There is a long test right after the comment:
/* Generally Big-Endian machines */
Replace that test with:
#if !defined(__LITTLE_ENDIAN__)
Here's a patch. Unzip it into the mfhdf/libsrc folder, cd to same folder in a Terminal, and run:
patch xdrposix.c < xdrposix.c.patch
In the HDF4 source:
export MACOSX_DEPLOYMENT_TARGET=10.4 ./configure --disable-fortran --disable-dependency-tracking --disable-netcdf \\ --with-jpeg=/Library/Frameworks/UnixImageIO.framework/unix \\ CFLAGS="-Os -arch i386 -arch ppc -isysroot /Developer/SDKs/MacOSX10.4u.sdk"
– change the H4_WORDS_BIGENDIAN line to:
#undef SWAP #ifdef __BIG_ENDIAN__ #define H4_WORDS_BIGENDIAN 1 #else #undef H4_WORDS_BIGENDIAN #define SWAP 1 #endif
make sudo make install
In the HDF4 source:
export MACOSX_DEPLOYMENT_TARGET=10.4 ./configure --disable-fortran --disable-dependency-tracking --disable-netcdf \\ --with-jpeg=/Library/Frameworks/UnixImageIO.framework/unix CFLAGS=-Os make sudo make install
version: 1.8.2
source: HDF Group
HDF5 got rid of most of the cruft of HDF4, but it still does some unusual endian and bit depth checking that must be worked around. The annoying part is that during compilation it compiles and runs a program to generate a source file with the machine-specific junk in it. This doesn't work for a multiarchitecture build. And it's not possible to completely do 4 different architecture builds and lipo them together because Rosetta can't run PPC 64bit programs, and PPC Macs can't run Intel programs at all (if you're building on a PPC Mac).
Grab this H5Tinit.c, unzip it, and drop it into the HDF5 src/ folder. Then apply a patch to disable the step that normally generates this file:
Find the line:
H5Tinit.c: H5detect$(EXEEXT)
and comment it and the indented lines following it.
Also, replace the line:
MOSTLYCLEANFILES = H5Tinit.c
with:
MOSTLYCLEANFILES =
In the HDF5 source:
export MACOSX_DEPLOYMENT_TARGET=10.5 ./configure --disable-dependency-tracking --enable-threadsafe \\ CFLAGS="-Os -arch ppc -arch i386 -arch ppc64 -arch x86_64"
– change the FP_TO_ULLONG_RIGHT_MAXIMUM line to:
#ifdef __BIG_ENDIAN__ #define FP_TO_ULLONG_RIGHT_MAXIMUM 1 #endif
– change the LDOUBLE_TO_LLONG_ACCURATE line to:
#ifdef __LITTLE_ENDIAN__ #define LDOUBLE_TO_LLONG_ACCURATE 1 #endif
– change the LLONG_TO_LDOUBLE_CORRECT line to:
#ifdef __LITTLE_ENDIAN__ #define LLONG_TO_LDOUBLE_CORRECT 1 #endif
– change the PRINTF_LL_WIDTH line to:
#ifdef __LP64__ #define PRINTF_LL_WIDTH "l" #else #define PRINTF_LL_WIDTH "ll" #endif
– change the SIZEOF_LONG line to:
#ifdef __LP64__ #define SIZEOF_LONG 8 #else #define SIZEOF_LONG 4 #endif
– change the SIZEOF_SIZE_T line to:
#ifdef __LP64__ #define SIZEOF_SIZE_T 8 #else #define SIZEOF_SIZE_T 4 #endif
– change the SIZEOF_SSIZE_T line to:
#ifdef __LP64__ #define SIZEOF_SSIZE_T 8 #else #define SIZEOF_SSIZE_T 4 #endif
– change the WORDS_BIGENDIAN line to:
#ifdef __BIG_ENDIAN__ #define WORDS_BIGENDIAN 1 #else #undef WORDS_BIGENDIAN #endif
– change the H5_FP_TO_ULLONG_RIGHT_MAXIMUM line to:
#ifdef __BIG_ENDIAN__ #define H5_FP_TO_ULLONG_RIGHT_MAXIMUM 1 #endif
– change the H5_LDOUBLE_TO_LLONG_ACCURATE line to:
#ifdef __LITTLE_ENDIAN__ #define H5_LDOUBLE_TO_LLONG_ACCURATE 1 #endif
– change the H5_LLONG_TO_LDOUBLE_CORRECT line to:
#ifdef __LITTLE_ENDIAN__ #define H5_LLONG_TO_LDOUBLE_CORRECT 1 #endif
– change the H5_PRINTF_LL_WIDTH line to:
#ifdef __LP64__ #define H5_PRINTF_LL_WIDTH "l" #else #define H5_PRINTF_LL_WIDTH "ll" #endif
– change the H5_SIZEOF_LONG line to:
#ifdef __LP64__ #define H5_SIZEOF_LONG 8 #else #define H5_SIZEOF_LONG 4 #endif
– change the H5_SIZEOF_SIZE_T line to:
#ifdef __LP64__ #define H5_SIZEOF_SIZE_T 8 #else #define H5_SIZEOF_SIZE_T 4 #endif
– change the H5_SIZEOF_SSIZE_T line to:
#ifdef __LP64__ #define H5_SIZEOF_SSIZE_T 8 #else #define H5_SIZEOF_SSIZE_T 4 #endif
– change the H5_WORDS_BIGENDIAN line to:
#ifdef __BIG_ENDIAN__ #define H5_WORDS_BIGENDIAN 1 #else #undef H5_WORDS_BIGENDIAN #endif
make sudo make install
Grab the same H5Tinit.c, unzip it, and drop it into the HDF5 src/ folder. Then apply a patch to disable the step that normally generates this file:
Find the line:
H5Tinit.c: H5detect$(EXEEXT)
and comment it and the indented lines following it.
Also, replace the line:
MOSTLYCLEANFILES = H5Tinit.c
with:
MOSTLYCLEANFILES =
In the HDF5 source:
export MACOSX_DEPLOYMENT_TARGET=10.4 ./configure --disable-dependency-tracking --enable-threadsafe \\ CFLAGS="-Os -arch ppc -arch i386 -isysroot /Developer/SDKs/MacOSX10.4u.sdk"
– change the FP_TO_ULLONG_RIGHT_MAXIMUM line to:
#ifdef __BIG_ENDIAN__ #define FP_TO_ULLONG_RIGHT_MAXIMUM 1 #endif
– change the LDOUBLE_TO_LLONG_ACCURATE line to:
#ifdef __LITTLE_ENDIAN__ #define LDOUBLE_TO_LLONG_ACCURATE 1 #endif
– change the LLONG_TO_LDOUBLE_CORRECT line to:
#ifdef __LITTLE_ENDIAN__ #define LLONG_TO_LDOUBLE_CORRECT 1 #endif
– change the WORDS_BIGENDIAN line to:
#ifdef __BIG_ENDIAN__ #define WORDS_BIGENDIAN 1 #else #undef WORDS_BIGENDIAN #endif
– change the H5_FP_TO_ULLONG_RIGHT_MAXIMUM line to:
#ifdef __BIG_ENDIAN__ #define H5_FP_TO_ULLONG_RIGHT_MAXIMUM 1 #endif
– change the H5_LDOUBLE_TO_LLONG_ACCURATE line to:
#ifdef __LITTLE_ENDIAN__ #define H5_LDOUBLE_TO_LLONG_ACCURATE 1 #endif
– change the H5_LLONG_TO_LDOUBLE_CORRECT line to:
#ifdef __LITTLE_ENDIAN__ #define H5_LLONG_TO_LDOUBLE_CORRECT 1 #endif
– change the H5_WORDS_BIGENDIAN line to:
#ifdef __BIG_ENDIAN__ #define H5_WORDS_BIGENDIAN 1 #else #undef H5_WORDS_BIGENDIAN #endif
make sudo make install
No patches needed – it's all PPC 32bit.
In the HDF5 source:
./configure --disable-dependency-tracking --enable-threadsafe CFLAGS=-Os make sudo make install