HDF4 support for GDAL on Arch Linux

I have been trouble reading HDF files with OTB on Arch Linux for a while. I finally took the time to investigate this problem and come to a solution.

At the beginning I was misled by the fact that I was able to open a HDF5 file with Monteverdi on Arch. But I finally understood that the GDAL pre-compiled package for Arch was only missing HDF4 support.
It is due to the fact that HDF4 depends on libjpeg version 6, and is incompatible with the standard current version of libjpeg on Arch.
So the solution is to install libjpeg6 and HDF4 from the AUR and then regenerate the gdal package, who, during the configuration phase will automatically add HDF4 support.
Here are the detailed steps I took:

  1. Install libjpeg6 from AUR:
    1. mkdir ~/local/packages
    2. cd ~/local/packages
    3. wget http://aur.archlinux.org/packages/libjpeg6/libjpeg6.tar.gz
    4. tar xzf libjpeg6.tar.gz
    5. cd libjpeg6
    6. makepkg -i #will prompt for root psswd for installation
  2. Install HDF4 from AUR:
    1. cd ~/local/packages
    2. wget http://aur.archlinux.org/packages/hdf4-nonetcdf/hdf4-nonetcdf.tar.gz
    3. tar xzf hdf4-nonetcdf.tar.gz
    4. cd hdf4-nonetcdf
    5. makepkg -i #will prompt for root psswd for installation
  3. Setup an Arch Build System build tree
    1. sudo pacman -S abs
    2. sudo abs
    3. mkdir ~/local/abs
  4. Compile gdal
    1. cp -r /var/abs/community/gdal ~/local/abs
    2. makepkg -s #generated the package without installing it
    3. sudo pacman -U gdal-1.8.0-2-x8664.pkg.tar.gz

If you are new to using AUR and makepkg, please note that the AUR package installation need the sudo package to be installed first (the packages are build as a non root user and sudo is called by makepkg).
Step 3 above is only needed if you have never set up the Arch Build System on your system.