#!/bin/bash # Tested on Ubuntu 12.04 64-bit # Willem.Marais@ssec.wisc.edu - 10/08/2013 # HOWTO USE: # ========== # The script needs three arguments. The first argument to the script is the # location of the directory where all the tar packages are. This will most # probably be the directory of this script. The second argument is the location # of the directory where in this script can compile the programs. The last # argument is the output directory where all the binaries will be copied to. # # For example, if the compile_binaries directory is under the home directory, the # following can be executed: # # PACK_DIR=$HOME/compile_binaries # COMPILE_DIR=$HOME/scratch # OUTPUT_DIR=$HOME/output # mkdir -p $COMPILE_DIR $OUTPUT_DIR # /bin/bash $PACK_DIR/compile_binaries.bash $PACK_DIR $COMPILE_DIR $OUTPUT_DIR # # The output binaries will be located in $OUTPUT_DIR. if [ $# -ne 3 ]; then echo "(ERROR) Usage:" echo " "$(basename $0)" " exit 1 fi pack_dir=$1 compile_dir=$2 out_bin_dir=$3 # Check if the installation package exits if [ ! -e $pack_dir ]; then echo "(ERROR) The compile install package directory does not exists." exit 1 fi cd $pack_dir if [ ! -e hdf5-1.6.10.tar.bz2 ] || [ ! -e hdf-4.2.5.tar.bz2 ] || [ ! -e szip-2.1.tar.gz ] || [ ! -e zlib-1.2.5.tar.bz2 ]; then echo "(ERROR) Not all the packages are present in the $pack_dir directory." exit 1 fi if [ ! -e jpegsrc.v6b.tar.gz ] || [ ! -e h4h5tools-2.1.1.tar.gz ] || [ ! -e h4h5tools-2.1.1.patch.static ]; then echo "(ERROR) Not all the packages are present in the $pack_dir directory." exit 1 fi if [ ! -e mersi_crefl_1.4.2d.tar.bz2 ] || [ ! -e update_fy3_l1b_calb.tar.bz2 ]; then echo "(ERROR) Not all the packages are present in the $pack_dir directory." exit 1 fi cd - # Make sure that previous temporary installation diretories are removed to prevent possible installation problems rm -rf $compile_dir/h5h4tools $compile_dir/mersi_crefl $compile_dir/fy3_l1b_calb $compile_dir/local-install # Unpacking and compiling HDF libaries (version 4 and 5) and tools # ================================================================ echo "========= HDF LIBRARIES =========" # B: Unpack HDFs mkdir $compile_dir/h5h4tools cd $compile_dir/h5h4tools tar xjf $pack_dir/hdf5-1.6.10.tar.bz2 tar xjf $pack_dir/hdf-4.2.5.tar.bz2 tar xzf $pack_dir/szip-2.1.tar.gz tar xjf $pack_dir/zlib-1.2.5.tar.bz2 tar xzf $pack_dir/jpegsrc.v6b.tar.gz tar xzf $pack_dir/h4h5tools-2.1.1.tar.gz # E: Unpack HDFs # B: Copy patch cp $pack_dir/h4h5tools-2.1.1.patch.static $compile_dir/h5h4tools # E: Copy patch # B: Unpack szip cd szip-2.1 ./configure --prefix=$compile_dir/local-install make -j3 make install cd .. # E: Unpack szip # B: Unpack jpeg mkdir -p $compile_dir/local-install/bin $compile_dir/local-install/man/man1 cd jpeg-6b CFLAGS="-D_GNU_SOURCE -fPIC" ./configure --prefix=$compile_dir/local-install make -j3 make install make install-lib cd .. # E: Unpack jpeg # B: Unpack hdf5 cd hdf5-1.6.10 CFLAGS="-O0 -D_GNU_SOURCE" LDFLAGS="-L/lib64 -L/usr/lib64" ./configure --disable-fortran --with-szlib --enable-static-exec --prefix=$compile_dir/local-install make -j3 make install cd .. # E: Unpack hdf5 # B: Unpack hdf4 cd hdf-4.2.5 CFLAGS="-O0 -D_GNU_SOURCE" LDFLAGS="-L/lib64 -L/usr/lib64 -L$compile_dir/local-install/lib" CPPFLAGS="-I$compile_dir/local-install/include" ./configure --disable-fortran --with-szlib=no --prefix=$compile_dir/local-install make -j3 make install cd ../ # E: Unpack hdf4 # B: Unpack zlib mkdir $compile_dir/local-install cd zlib-1.2.5 CFLAGS="-D_GNU_SOURCE" LDFLAGS="-L/lib64 -L/usr/lib64" ./configure --prefix=$compile_dir/local-install make -j3 make install cd .. # E: Unpack zlib # B: Unpack h4h5tools cd h4h5tools-2.1.1 patch -p1 -i ../h4h5tools-2.1.1.patch.static CC="gcc" CXX="g++" LIBS="-ldf -lmfhdf -lz -ljpeg -lm -ltirpc" CFLAGS="-O0 -D_GNU_SOURCE" LDFLAGS="-L/lib -L/usr/lib -L$compile_dir/local-install/lib" CPPFLAGS="-I$compile_dir/local-install/include" ./configure --enable-static-exec --prefix=$compile_dir/local-install make -j3 make install cd .. # E: Unpack h4h5tools echo "========= MERSI CREFL =========" # B: Unpack,compile MERSI CREFL mkdir $compile_dir/mersi_crefl cd $compile_dir/mersi_crefl tar xjf $pack_dir/mersi_crefl_1.4.2d.tar.bz2 cd mersi_crefl_1.4.2d LDFLAGS="-L/lib -L/usr/lib" CFLAGS="-D_GNU_SOURCE" HDFHOME=$compile_dir/local-install make # E: Unpack,compile MERSI CREFL echo "========= UPDATE_FY3_L1B_CALB =========" # B: Unpack update_fy3_l1b_calb mkdir $compile_dir/fy3_l1b_calb cd $compile_dir/fy3_l1b_calb tar xjf $pack_dir/update_fy3_l1b_calb.tar.bz2 cd update_fy3_l1b_calb # E: Unpack update_fy3_l1b_calb # B: Compile update_fy3_l1b_calb CFLAGS="-D_GNU_SOURCE" LDFLAGS="-L/lib -L/usr/lib" HDF5HOME=$compile_dir/local-install make # E: Compile update_fy3_l1b_calb # Copy installed binaries to MIPS bin directory # ============================================= # B: Copy binaires to MIPS bin cp $compile_dir/local-install/bin/h5toh4 $out_bin_dir cp $compile_dir/mersi_crefl/mersi_crefl_1.4.2d/mersi_crefl.1.4.2 $out_bin_dir cp $compile_dir/mersi_crefl/mersi_crefl_1.4.2d/tbase.hdf $out_bin_dir cp $compile_dir/fy3_l1b_calb/update_fy3_l1b_calb/update_fy3_l1b_calb $out_bin_dir # E: Copy binaires to MIPS bin