Kyng Chaos
“The beast is actively interested only in now, and, as it is always now and always shall be, there is an eternity of time for the accomplishment of objects.”
- the wisdom of Tarzan

HDF Build

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.

HDF4

version: 4.2.5
source: HDF Group

parallel: OK

Leopard

patches

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.

configure

Delete "-DSWAP" and "-DBIG_LONGS" whereever you find them – we need to set these dynamically in the config headers.

hdf/src/hconv.h

There is a long test right after the comment:

Replace that test with:

#if !defined(__LITTLE_ENDIAN__)

Even on intel-only Snow, this is needed because the test otherwise misses i386.

hdf/src/hdfi.h

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__)

mfhdf/libsrc/netcdf.h.in

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__

mfhdf/libsrc/config/netcdf-apple.h

Do the same as for netcdf.h.in.

mfhdf/ncgen/ncgen.l

Replace the line:

#if defined __alpha || (_MIPS_SZLONG == 64) || defined __ia64 ||
(defined __sun && defined _LP64) || defined AIX5L64 || defined __x86_64__

with:

#ifdef __LP64__  

mfhdf/libsrc/xdrposix.c

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 

configure

In the HDF4 source:

export MACOSX_DEPLOYMENT_TARGET=10.6
./configure --disable-fortran --disable-dependency-tracking --disable-netcdf \
CFLAGS="-Os -arch i386 -arch x86_64"

hdf/src/h4config.h

– 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

make & install

make
sudo make install

Leopard

patches

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.

configure

Delete "-DSWAP" and "-DBIG_LONGS" whereever you find them – we need to set these dynamically in the config headers.

hdf/src/hconv.h

There is a long test right after the comment:

Replace that test with:

#if !defined(__LITTLE_ENDIAN__)

hdf/src/hdfi.h

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__)

mfhdf/libsrc/netcdf.h.in

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__

mfhdf/libsrc/config/netcdf-apple.h

Do the same as for netcdf.h.in.

mfhdf/ncgen/ncgen.l

Replace the line:

#if defined __alpha || (_MIPS_SZLONG == 64) || defined __ia64 ||
(defined __sun && defined _LP64) || defined AIX5L64 || defined __x86_64__

with:

#ifdef __LP64__  

mfhdf/libsrc/xdrposix.c

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 

configure

In the HDF4 source:

export MACOSX_DEPLOYMENT_TARGET=10.5
./configure --disable-fortran --disable-dependency-tracking --disable-netcdf \
CFLAGS="-Os -arch i386 -arch ppc -arch x86_64 -arch ppc64"

hdf/src/h4config.h

– 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 & install

make
sudo make install

Tiger

patches

Quite a bit simpler than for Leopard.

configure

Delete "-DSWAP" whereever you find it – we need to set these dynamically in the config headers.

hdf/src/hconv.h

There is a long test right after the comment:

Replace that test with:

#if !defined(__LITTLE_ENDIAN__)

mfhdf/libsrc/xdrposix.c

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 

configure

In the HDF4 source:

export MACOSX_DEPLOYMENT_TARGET=10.4
./configure --disable-fortran --disable-dependency-tracking --disable-netcdf \
CFLAGS="-Os -arch i386 -arch ppc -isysroot /Developer/SDKs/MacOSX10.4u.sdk"

hdf/src/h4config.h

– 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 & install

make
sudo make install

Panther

In the HDF4 source:

export MACOSX_DEPLOYMENT_TARGET=10.4
./configure --disable-fortran --disable-dependency-tracking --disable-netcdf \
make
sudo make install

HDF5

version: 1.8.5
source: HDF Group

parallel: OK

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).

Snow Leopard

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:

src/makefile.in

Find the line:

H5Tinit.c: H5detect$(EXEEXT)

and comment it and the indented lines following it.

Also, replace the line:

MOSTLYCLEANFILES = H5Tinit.c H5lib_settings.c

with:

MOSTLYCLEANFILES = H5lib_settings.c

src/H5public.h

Change the line:

#if H5_SIZEOF_LONG_LONG >= 8

to:

#if H5_SIZEOF_LONG >= 8
typedef unsigned long 	hsize_t;
typedef signed long	hssize_t;
#       define H5_SIZEOF_HSIZE_T H5_SIZEOF_LONG
#       define H5_SIZEOF_HSSIZE_T H5_SIZEOF_LONG
#elif H5_SIZEOF_LONG_LONG >= 8

configure

In the HDF5 source:

export MACOSX_DEPLOYMENT_TARGET=10.6
./configure --disable-dependency-tracking --enable-threadsafe \
CFLAGS="-Os -arch i386 -arch x86_64"

src/H5config.h

add at the end:

#undef LDOUBLE_TO_LLONG_ACCURATE
#undef LLONG_TO_LDOUBLE_CORRECT
#undef PRINTF_LL_WIDTH
#undef SIZEOF_LONG
#undef SIZEOF_SIZE_T
#undef SIZEOF_SSIZE_T
#ifdef __LITTLE_ENDIAN__
#define LDOUBLE_TO_LLONG_ACCURATE 1
#define LLONG_TO_LDOUBLE_CORRECT 1
#endif
#ifdef __LP64__
#define PRINTF_LL_WIDTH "l"
#define SIZEOF_LONG 8
#define SIZEOF_SIZE_T 8
#define SIZEOF_SSIZE_T 8
#else
#define PRINTF_LL_WIDTH "ll"
#define SIZEOF_LONG 4
#define SIZEOF_SIZE_T 4
#define SIZEOF_SSIZE_T 4
#endif

src/H5pubconf.h

add at the end:

#undef H5_PRINTF_LL_WIDTH
#undef H5_SIZEOF_LONG
#undef H5_SIZEOF_SIZE_T
#undef H5_SIZEOF_SSIZE_T

#ifdef __LP64__
#define H5_PRINTF_LL_WIDTH "l"
#define H5_SIZEOF_LONG 8
#define H5_SIZEOF_SIZE_T 8
#define H5_SIZEOF_SSIZE_T 8
#else
#define H5_PRINTF_LL_WIDTH "ll"
#define H5_SIZEOF_LONG 4
#define H5_SIZEOF_SIZE_T 4
#define H5_SIZEOF_SSIZE_T 4
#endif

make & install

make
sudo make install

Leopard

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:

src/makefile.in

Find the line:

H5Tinit.c: H5detect$(EXEEXT)

and comment it and the indented lines following it.

Also, replace the line:

MOSTLYCLEANFILES = H5Tinit.c H5lib_settings.c

with:

MOSTLYCLEANFILES = H5lib_settings.c

configure

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"

src/H5config.h

add at the end:

#undef LDOUBLE_TO_LLONG_ACCURATE
#undef LLONG_TO_LDOUBLE_CORRECT
#undef PRINTF_LL_WIDTH
#undef SIZEOF_LONG
#undef SIZEOF_SIZE_T
#undef SIZEOF_SSIZE_T
#ifdef __LITTLE_ENDIAN__
#define LDOUBLE_TO_LLONG_ACCURATE 1
#define LLONG_TO_LDOUBLE_CORRECT 1
#endif
#ifdef __LP64__
#define PRINTF_LL_WIDTH "l"
#define SIZEOF_LONG 8
#define SIZEOF_SIZE_T 8
#define SIZEOF_SSIZE_T 8
#else
#define PRINTF_LL_WIDTH "ll"
#define SIZEOF_LONG 4
#define SIZEOF_SIZE_T 4
#define SIZEOF_SSIZE_T 4
#endif

src/H5pubconf.h

add at end:

#undef H5_LDOUBLE_TO_LLONG_ACCURATE
#undef H5_LLONG_TO_LDOUBLE_CORRECT
#undef H5_PRINTF_LL_WIDTH
#undef H5_SIZEOF_LONG
#undef H5_SIZEOF_SIZE_T
#undef H5_SIZEOF_SSIZE_T
#ifdef __LITTLE_ENDIAN__
#define H5_LDOUBLE_TO_LLONG_ACCURATE 1
#define H5_LLONG_TO_LDOUBLE_CORRECT 1
#endif
#ifdef __LP64__
#define H5_PRINTF_LL_WIDTH "l"
#define H5_SIZEOF_LONG 8
#define H5_SIZEOF_SIZE_T 8
#define H5_SIZEOF_SSIZE_T 8
#else
#define H5_PRINTF_LL_WIDTH "ll"
#define H5_SIZEOF_LONG 4
#define H5_SIZEOF_SIZE_T 4
#define H5_SIZEOF_SSIZE_T 4
#endif

make & install

make
sudo make install

Tiger

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:

src/makefile.in

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 = 

configure

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"

src/H5config.h

add at end:

#ifdef __LITTLE_ENDIAN__
#define LDOUBLE_TO_LLONG_ACCURATE 1
#define LLONG_TO_LDOUBLE_CORRECT 1
#endif

src/H5pubconf.h

add at end:

#ifdef __LITTLE_ENDIAN__
#define H5_LDOUBLE_TO_LLONG_ACCURATE 1
#define H5_LLONG_TO_LDOUBLE_CORRECT 1
#endif

make & install

make
sudo make install

Panther

No patches needed – it's all PPC 32bit.

In the HDF5 source:

./configure --disable-dependency-tracking --enable-threadsafe CFLAGS=-Os
make
sudo make install
macosx/build/hdf.txt · Last modified: 2010/07/26 19:16 by kyngchaos
[unknown link type]Back to top
Copyright © 2004-2011 William Kyngesburye Driven by DokuWiki Recent changes RSS feed