dnl****************************************************************************/
dnl* NCSA HDF                                                                 *
dnl* National Comptational Science Alliance                                   *
dnl* University of Illinois at Urbana-Champaign                               *
dnl* 605 E. Springfield, Champaign IL 61820                                   *
dnl*                                                                          *
dnl* For conditions of distribution and use, see the accompanying             *
dnl* hdf-java/COPYING file.                                                   *
dnl*                                                                          *
dnl****************************************************************************/

dnl Process this file with autoconf to produce a configure script.

AC_INIT(native/hdflib/hdfImp.c)
AC_CONFIG_AUX_DIR(./config)

dnl ----------------------------------------------------------------------
dnl Some platforms have broken tr, basename, and/or xargs programs. Check
dnl that it actually does what it's supposed to do. Catch this early
dnl since configure relies upon tr heavily and there's no use continuing
dnl if it's broken.
dnl
AC_MSG_CHECKING([if tr works])
TR_TEST="`echo Test | tr 'a-z,' 'A-Z '`"
if test $TR_TEST != "TEST"; then
  AC_MSG_ERROR([tr program doesn't work])
else
  AC_MSG_RESULT([yes])
fi

AC_PROG_AWK
dnl ----------------------------------------------------------------------
dnl Some platforms have broken 'expr' programs. Check
dnl that it actually does what it's supposed to do. Catch this early
dnl since configure relies upon 'expr' to process its arguments, and
dnl there isn't much use continuging if it's broken.
dnl
AC_MSG_CHECKING([if expr works])
yyy_ok="yes"
yyy_option="$*"
for yyy_option
do
  yyy_opt=`expr "x$yyy_option" : 'x.*=.*'`
  if test "$yyy_opt" != "0"; then
    zzz_opt=`echo x$yyy_option | awk '{print [index($0,"=")]}'`
    if test "$yyy_opt" != "$zzz_opt"; then
  dnl  AC_MSG_WARN([$yyy_option: option is empty?])
  dnl  yyy_ok="maybe"
  dnl  else
      yyy_optarg=`expr "x$yyy_option" : 'x[[^=]]*=\(.*\)'`
      if test -z "$yyy_optarg"; then
      AC_MSG_RESULT([option $yyy_option too long, configure will fail])
      yyy_ok="no"
      fi
    fi
  fi
done
if test "$yyy_ok" != "yes"; then
  echo $yyy_ok
  AC_MSG_ERROR([expr program doesn't work])
else
  AC_MSG_RESULT([yes])
fi

dnl Checks for programs.
AC_PROG_CC

AC_PROG_MAKE_SET
AC_PROG_INSTALL

AC_HEADER_STDC                    
AC_CHECK_LIB(m,ceil)

if test "`uname`" = "SunOS" -o "`uname -sr`" = "HP-UX B.11.00"; then
  dnl ...for Solaris and hdf4
  AC_CHECK_LIB(nsl, xdr_int)
fi


AC_PREFIX_DEFAULT("")
AC_PATH_PROG(RM,rm,\"\",,)
AC_PATH_PROG(FIND,find,\"\",,)

dnl
dnl  Some platform specific settings for different Java implementations
dnl
AC_CANONICAL_SYSTEM
TARGET=$target
echo "FYI the target here is: "$target
case $target in
alpha-dec-osf*.*) TARGETLIB="alpha"
LD=$CC; LDOPT="-pthread -shared"; SLEXT="so";
LLEXT="a";
JSLEXT="so";
COPT="-pthread -shared"; COPTNOSHARED=;
;;
*aix*) TARGETLIB="aix"
LD=$CC; LDOPT=-G; SLEXT="so";
LLEXT="a";
JSLEXT="so";
COPT=-G; COPTNOSHARED=;
;;
*-*-solaris2*) TARGETLIB="solaris"
LD=$CC; LDOPT=-G; SLEXT="so";
LLEXT="a";  
JSLEXT="so";
COPT=-G; COPTNOSHARED=; 
;;
mips*-sgi-irix6*) 
TARGETLIB="irix"
LD=ld; 
LLEXT="a";  
JSLEXT="so";
;;
x86_64-pc-linux*) LD=$CC; LDOPT=-shared; SLEXT="so";
TARGETLIB="linux"
SLEXT="so";
LLEXT="a";  dnl the extension for the HDF and other libraries to link to
JSLEXT="so";
COPT="-shared -Dx86_64 -fPIC" ; 
;;
ia64-pc-linux*) LD=$CC; LDOPT=-shared; SLEXT="so";
TARGETLIB="linux"
SLEXT="so";
LLEXT="a";  dnl the extension for the HDF and other libraries to link to
JSLEXT="so";
COPT="-shared -Dia64 -fPIC" ; 
;;
*-pc-linux*) LD=$CC; LDOPT=-shared; SLEXT="so";
TARGETLIB="linux"
SLEXT="so";
LLEXT="a";  dnl the extension for the HDF and other libraries to link to
JSLEXT="so";
COPT="-shared -DUNIX386" ; 
;;
*-freebsd*) LD=$CC; LDOPT=-shared;
TARGETLIB="freebsd"
SLEXT="so";
LLEXT="a";  dnl the extension for the HDF and other libraries to link to
JSLEXT="so";
COPT="-shared" ;
;;
*powerpc-apple*) 
LD=$CC; LDOPT=-bundle; 
JSLEXT="jnilib";
LLEXT="a";
SLEXT="dylib";
;;
*) LD=$CC; LDOPT=-G; SLEXT="so";
LLEXT="a";
TARGETLIB="$target"
esac

dnl ----------------
dnl  Check for the external compression libraries required by the 
dnl  HDF libraries.
dnl
dnl  Note:  we need to find static libraries, so we can't rely on
dnl  autoconf for these detections.
dnl

AC_MSG_CHECKING([gzip compression])
HAVE_ZLIB="no"
withval="";
AC_SUBST(ZLIB) ZLIB=""
AC_ARG_WITH(libz,[  --with-libz=LIB     Path to the gzip library (required if not in default path)],,)

case "$withval" in
  yes)
      ZLIB=""
  HAVE_ZLIB="no"
    ;;
  no)
      ZLIB=""
  HAVE_ZLIB="suppressed"
    ;;
  *)
    if test -n "$withval" ; then
        z_lib="`echo $withval |cut -f2 -d, -s`"
  ZLIB=$z_lib"/libz."$LLEXT
  HAVE_ZLIB="yes"
    else
      ZLIB=""
  HAVE_ZLIB="no"
    fi
;;
esac
if test -n "$ZLIB"; then
  LIBS="$LIBS $ZLIB"
  HAVE_ZLIB="yes"
fi
AC_MSG_RESULT([$HAVE_ZLIB])
if test $HAVE_ZLIB = "yes"; then
      AC_MSG_RESULT([zlib found: $ZLIB]);
fi

AC_MSG_CHECKING([jpeg compression])
HAVE_JPEG="no"
withval="";
AC_SUBST(JPEGLIB) JPEGLIB=""
AC_ARG_WITH(libjpeg,[  --with-libjpeg=LIB     Path to the jpeg library (required if not in default path)],,)

case "$withval" in
  yes)
  HAVE_JPEG="no"
    ;;
  no)
      JPEGLIB=""
  HAVE_JPEG="suppressed"
    ;;
  *)
    if test -n "$withval" ; then
        jpeg_lib="`echo $withval |cut -f2 -d, -s`"
  JPEGLIB=$jpeg_lib"/libjpeg."$LLEXT
      dnl AC_MSG_RESULT([jpeg found: $JPEGLIB]);
  HAVE_JPEG="yes"
    else
  HAVE_JPEG="no"
    fi
;;
esac
if test -n "$JPEGLIB"; then
  LIBS="$LIBS $JPEGLIB"
  HAVE_JPEG="yes"
fi
AC_MSG_RESULT([$HAVE_JPEG])
if test $HAVE_JPEG = "yes"; then
      AC_MSG_RESULT([jpeg found: $JPEGLIB]);
fi

AC_MSG_CHECKING([szip compression])
HAVE_SZIP="no"
withval="";
AC_SUBST(SZLIB) SZLIB=""
AC_ARG_WITH(libsz,[  --with-libsz=LIB     Path to the szip library (required if not in default path)],,)

case "$withval" in
  yes)
      SZLIB=""
  HAVE_SZIP="no"
    ;;
  no)
      SZLIB=""
  HAVE_SZIP="suppressed"
    ;;
  *)
  if test -n "$withval" ; then
      sz_lib="`echo $withval |cut -f2 -d, -s`"
    SZLIB=$sz_lib"/libsz."$LLEXT
    dnl AC_MSG_RESULT([szlib found: $SZLIB]);
    HAVE_SZIP="yes"
  else
        SZLIB=""
    HAVE_SZIP="no"
  fi
  ;;
esac
if test -n "$SZLIB"; then
  LIBS="$LIBS $SZLIB"
  HAVE_SZIP="yes"
fi
AC_MSG_RESULT([$HAVE_SZIP])
if test $HAVE_SZIP = "yes"; then
      AC_MSG_RESULT([szlib found: $SZLIB]);
fi

dnl
dnl  Look for HDF4 library, if selected.
dnl  Must find static libraries.
dnl
AC_MSG_CHECKING([HDF4 library])
HAVE_HDF4="no"
withval="";
AC_SUBST(HDF4LIB) HDF4LIB=""
AC_ARG_WITH(hdf4,[  --with-hdf4=LIB     Path to the hdf library (required if not in default path)],,)

case "$withval" in
  yes)
    dnl AC_MSG_ERROR(HDF4 library needed for compilation.)
      HDF4LIB=""
  HAVE_HDF4="no"
    ;;
  no)
      HDF4LIB=""
  HAVE_HDF4="suppressed"
    ;;
  *)
  if test -n "$withval" ; then
      hdf4_inc="`echo $withval |cut -f1 -d,`"
      if test -n "$hdf4_inc"; then
        HDF4INC="$hdf4_inc"
      fi
      hdf4_lib="`echo $withval |cut -f2 -d, -s`"
      if test -n "$hdf4_lib"; then
    HDF4LIB=$hdf4_lib
      fi
      HAVE_HDF4="yes"
  else
        HDF4LIB=""
      HAVE_HDF4="no"
  fi
  ;;
esac
if test -n "$HDF4LIB"; then
  LIBS="$HDF4LIB/libdf.$LLEXT $HDF4LIB/libmfhdf.$LLEXT $LIBS"
  HAVE_HDF4="yes"
fi
AC_MSG_RESULT([$HAVE_HDF4])
if test $HAVE_HDF4 = "yes"; then
      AC_MSG_RESULT([HDF4 found: $HDF4LIB]);
fi

dnl
dnl  Check that the libraries that HDF4 needs have been found
dnl
dnl  Must stop here if something is missing.
dnl
if test "$HAVE_HDF4" = "yes"; then
  AC_MSG_CHECKING([dependencies for HDF4 library])
  needjpg=`grep 'define H4_HAVE_LIBJPEG 1' $HDF4INC/h4config.h`
  needgzip=`grep 'define H4_HAVE_LIBZ 1' $HDF4INC/h4config.h`
  needszip=`grep 'define H4_HAVE_LIBSZ 1' $HDF4INC/h4config.h`
  if test -n "$needjpg"; then
    if test "$HAVE_JPEG" != "yes"; then
        AC_MSG_ERROR([ HDF4 library needs JPEG, JPEG not defined.])
    fi
  fi

  if test -n "$needgzip"; then
    if test "$HAVE_ZLIB" != "yes"; then
        AC_MSG_ERROR([ HDF4 library needs GZIP, GZIP not defined.])
    fi
  fi

  if test -n "$needszip"; then
    if test "$HAVE_SZIP" != "yes"; then
        AC_MSG_ERROR([ HDF4 library needs SZIP, SZIP not defined.])
    fi
  fi
  AC_MSG_RESULT([OK])
fi


ac_cv_lib_HDF4=$HDF4LIB
ac_cv_lib_HDF4INC=$HDF4INC


AC_MSG_CHECKING([HDF5 library])
HAVE_HDF5="no"
withval="";
AC_SUBST(HDF5LIB) HDF5LIB=""
AC_ARG_WITH(hdf5,[  --with-hdf5=LIB     Path to the hdf5 library (required if not in default path)],,)

case "$withval" in
  yes)
      HDF5LIB=""
  HAVE_HDF5="no"
    ;;
  no)
      HDF5LIB=""
  HAVE_HDF5="suppressed"
    ;;
  *)
  if test -n "$withval" ; then
      hdf5_lib="`echo $withval |cut -f2 -d, -s`"
    HDF5LIB=$hdf5_lib"/libhdf.$LLEXT"
      hdf5_inc="`echo $withval |cut -f1 -d,`"
      if test -n "$hdf5_inc"; then
        HDF5INC="$hdf5_inc"
      fi
      hdf5_lib="`echo $withval |cut -f2 -d, -s`"
      if test -n "$hdf5_lib"; then
    HDF5LIB=$hdf5_lib
      fi
      HAVE_HDF5="yes"
  else
        HDF5LIB=""
      HAVE_HDF5="no"
  fi
  ;;
esac
if test -n "$HDF5LIB"; then
  LIBS="$HDF5LIB/libhdf5.$LLEXT $LIBS"
  HAVE_HDF5="yes"
fi
AC_MSG_RESULT([$HAVE_HDF5])
if test $HAVE_HDF5 = "yes"; then
      AC_MSG_RESULT([HDF5 found: $HDF5LIB]);
fi

dnl
dnl  Check that the libraries that HDF4 needs have been found
dnl
dnl  Must stop here if something is missing.
dnl
if test -n "$HDF5LIB"; then
  AC_MSG_CHECKING([dependencies for HDF5 library])
  DFL=`grep 'filters (external)' $HDF5LIB"/libhdf5.settings" | grep deflate`
  SZP=`grep 'filters (external)' $HDF5LIB"/libhdf5.settings" | grep szip`
  if test -n "$DFL";
  then
    if test "$HAVE_ZLIB" != "yes"; then
        AC_MSG_ERROR([ HDF5 library needs GZIP, GZIP not defined.])
    fi
  fi
  if test -n "$SZP";
  then
    if test "$HAVE_SZIP" != "yes"; then
        AC_MSG_ERROR([ HDF5 library needs SZIP, SZIP not defined.])
    fi
  fi
  AC_MSG_RESULT([OK])
fi
ac_cv_lib_HDF5=$HDF5LIB
ac_cv_lib_HDF5INC=$HDF5INC


dnl check for libh4toh5  == if with-h4toh5 is not set, then can
dnl only build hdf and hdf5 separately.
dnl
dnl  This code need to be updated to check all the dependencies,
dnl  as for H4 and H5 libs above.

AC_MSG_CHECKING([HDF4to5 library])
USEH45="no"
withval="";
AC_SUBST(LIBH45) LIBH45=""
AC_ARG_WITH(h4toh5,[  --with-h4toh5=INC,LIB     Path to the HDF 4 to 5 library (optional feature, if selected then path required is not in default path)],,)
case "$withval" in
  yes)
  USEH45="no"
    ;;
  no)
  H45LIB=""
  H45INC=""
  USEH45="suppressed"
    ;;
  *)
    if test -n "$withval"; then
        hdf45_inc="`echo $withval |cut -f1 -d,`"
        if test -n "$hdf45_inc"; then
          HDF45INC="$hdf45_inc"
          saved_CPPFLAGS="$CPPFLAGS"
          CPPFLAGS="$CPPFLAGS -I$hdf45_inc"
        fi
    
        AC_CHECK_HEADERS(h4toh5.h,,
                         CPPFLAGS="$saved_CPPFLAGS"
                         AC_MSG_ERROR(cannot find HDF45 header files!))
    
        hdf45_lib="`echo $withval | cut -f2 -d, -s`"
    
        if test -n "$hdf45_lib"; then
          HDF45LIB="$hdf45_lib"
          saved_LDFLAGS="$LDFLAGS"
          LDFLAGS="$LDFLAGS -L$hdf45_lib"
          AC_CHECK_LIB(h4toh5, H4toh5open,, LDFLAGS="$saved_LDFLAGS"
                     AC_MSG_ERROR(cannot find HDF45 library.))
        else
       AC_MSG_ERROR(cannot find HDF45 library path.)
        fi
  USEH45="yes"
    fi
    ;;
esac

AC_MSG_RESULT([$USEH45])
if test -n "$H45LIB"; then
  AC_MSG_RESULT([h4toh5 library found at: $HDF45LIB])
fi
H45LIB=$HDF45LIB
H45INC=$HDF45INC

ac_cv_lib_HDF45=$HDF45LIB
ac_cv_lib_HDF45INC=$HDF45INC

dnl  find java stuff:  use -with-jdk

withval="";
AC_SUBST(jdkclasses) jdkclasses=""
AC_ARG_WITH(jdkclasses,[  --with-classpath=LIB],,)

jdkclasses=$withval

withval="";
AC_SUBST(JAVALIB) JAVALIB=""
AC_ARG_WITH(jdk,[  --with-jdk=INC,LIB     Path to the JDK (required if not in default path)],,)
case "$withval" in
  yes)
    AC_MSG_ERROR(JDK needed for compilation.)
    ;;
  no)
    AC_MSG_ERROR(JDK needed for compilation.)
    ;;
  *)
    jdk_inc="`echo $withval |cut -f1 -d,`"
    if test -n "$jdk_inc"; then
      JAVAINC="$jdk_inc"
      saved_CPPFLAGS="$CPPFLAGS"
      CPPFLAGS="$CPPFLAGS $COPT -I$jdk_inc -I$jdk_inc/$TARGETLIB"
    fi

    AC_CHECK_HEADERS(jni.h,,
                     CPPFLAGS="$saved_CPPFLAGS"
                     AC_MSG_ERROR(cannot find JDK header files!))

    jdk_lib="`echo $withval | cut -f2 -d, -s`"

    if test -n "$jdk_lib"; then
      JAVALIB="$jdk_lib"
    else
   AC_MSG_ERROR(cannot find jdk library path.)
    fi
    ;;
esac

if test -n "$jdkclasses"; then

if test -f $jdkclasses/classes.jar ; then
  JAVACLASSES=$jdkclasses/classes.jar
  JAVACLASSPATH_FOUND=1
else
   AC_MSG_ERROR(cannot find jdk classes in JDK lib path.)
fi
else

if test -f $JAVALIB/classes.zip ; then
  JAVACLASSES=$JAVALIB/classes.zip
  JAVACLASSPATH_FOUND=1
elif test -f $JAVALIB/core.jar ; then
  JAVACLASSES=$JAVALIB/rt.jar
  JAVACLASSPATH_FOUND=1
elif test -f $JAVALIB/rt.jar ; then
  JAVACLASSES=$JAVALIB/rt.jar
  JAVACLASSPATH_FOUND=1
elif test -d $JAVALIB/classes ; then
  JAVACLASSES=$JAVALIB/classes
  JAVACLASSPATH_FOUND=1
else
  JL=`dirname $JAVALIB`
  if test -f $JL/jre/lib/rt.jar; then
    JAVACLASSES=$JL/jre/lib/rt.jar
    JAVACLASSPATH_FOUND=1
    JAVALIB=$JL/jre/lib
    AC_SUBST(JAVALIB) JAVALIB=""
  else
     AC_MSG_ERROR(cannot find jdk classes in JDK lib path.)
  fi
fi
fi
HERE=`pwd`
CLASSPATH="$JAVACLASSES"":""$HERE"

withval="";
AC_SUBST(javabin) javax=""
AC_ARG_WITH(javax,[  --with-javax=LIB],,)
javax=$withval

if test -n "$javax" ; then
JAVAX=$javax
fi

withval="";
AC_SUBST(javabin) javabin=""
AC_ARG_WITH(javabin,[  --with-javabin=LIB],,)
javabin=$withval

if test -n "$javabin" ; then
JAVABIN=$javabin
else
JAVABIN=`dirname $JAVAINC`
JAVABIN="$JAVABIN/bin"
fi

AC_PATH_PROG(JAVA,java,,$JAVABIN,)
AC_PATH_PROG(JAVAC,javac,,$JAVABIN,)
AC_PATH_PROG(JAVADOC,javadoc,,$JAVABIN,)
AC_PATH_PROG(JAR,jar,,$JAVABIN,)

dnl  optional find the jhdf wrappers 

withval="";
AC_ARG_WITH(jhdf4,[  --with-jhdf4=LIB     Path to the jhdf4,jar (optional override, used only by H4 to H5) ],,)
case "$withval" in
  yes)
    AC_MSG_ERROR(jhdf4 path needed for compilation.)
    ;;
  no)
    dnl use default path
    ;;
  *)
    jhdf_jar="`echo $withval |cut -f1 -d,`"
    if test -n "$jhdf_jar"; then
  CLASSPATH="$CLASSPATH"":""$jhdf_jar""/jhdf.jar"
    fi
    ;;
esac

withval="";
AC_ARG_WITH(jhdf5,[  --with-jhdf5=LIB     Path to the jhdf45.jar (optional override, used only by the H4 to H5 library) ],,)
case "$withval" in
  yes)
    AC_MSG_ERROR( jhdf5 path needed for compilation.)
    ;;
  no)
    #AC_MSG_ERROR( jhdf5 needed for compilation.)
  # use default path
    ;;
  *)
    jhdf5_jar="`echo $withval |cut -f1 -d,`"
    if test -n "$jhdf5_jar"; then
  CLASSPATH="$CLASSPATH"":""$jhdf5_jar""/jhdf5.jar"
    #else
     # AC_MSG_ERROR(jhdf5.jar needed for compilation.)
  # use default path...
    fi
    ;;
esac

ac_cv_lib_JAVAINC=$JAVAINC


if test "$prefix" != "NONE" ; then
  JH45INST="$prefix"
else
  JH45INST=""
fi

JH45INST_FOUND=1
if test -z "$JH45INST" ; then
AC_CACHE_CHECK("JH45 install directory",ac_cv_lib_JH45INST,JH45INST_FOUND=0)
fi
if test $JH45INST_FOUND -eq 1; then
  if test -z "$JH45INST" ; then
    JH45INST=$ac_cv_lib_JH45INST;
  fi
  if test \( ! -d "$JH45INST" \); then
    JH45INST_FOUND=0
  fi
  if test \( ! -w "$JH45INST" \); then
    AC_MSG_ERROR( [ $JH45INST : not writable ])
    JH45INST_FOUND=0
  fi
fi
until test $JH45INST_FOUND -eq 1; do
  echo "Please type the directory in which to install the JH45"
  read JH45INST
  JH45INST_FOUND=1
  if test \( ! -d "$JH45INST" \); then
    JH45INST_FOUND=0
  fi
  if test \( ! -w "$JH45INST" \); then
    AC_MSG_ERROR( [ $JH45INST : not writable ])
    JH45INST_FOUND=0
  fi
done

ac_cv_lib_JH45INST=$JH45INST
JHVINST=$JH45INST
JH5INST=$JH45INST

case $target in
alpha-dec-osf*.*)
LD=$CC; LDOPT="-pthread -shared"; SLEXT="so";
LLEXT="a";
JSLEXT="so";
COPT="-pthread -shared"; COPTNOSHARED=;
JAVAINC2=$JAVAINC/alpha ; JAVATARG=alpha;
;;
*aix*)
LD=$CC; LDOPT=-G; SLEXT="so";
LLEXT="a";
JSLEXT="so";
COPT=-G; COPTNOSHARED=;
JAVAINC2=$JAVAINC/aix ; JAVATARG=aix;
;;
*-*-solaris2*) 
LD=$CC; LDOPT=-G; SLEXT="so";
LLEXT="a";  
JSLEXT="so";
COPT=-G; COPTNOSHARED=; 
JAVAINC2=$JAVAINC/solaris ; JAVATARG=solaris;
;;
mips*-sgi-irix6*) 
LD=ld; 
LLEXT="a";  # the extension for the HDF and other libraries to link to
JSLEXT="so";  
OS=`uname -r`;
SYS=`uname -s`
if test "$SYS" = "IRIX"; then
LDOPT2="-check_registry /usr/lib/so_locations"; SLEXT="so";
if test "$GCC" = "yes" ; then
LDOPT="-shared";
COPT="-shared" ; COPTNOSHARED=""; 
else
LDOPT="-n32 -shared";
COPT="-n32 -shared" ; COPTNOSHARED="-n32"; 
fi
elif test "$SYS" = "IRIX64"; then
LDOPT2="-check_registry /usr/lib/so_locations"; SLEXT="so";
if test "$GCC" = "yes" ; then
LDOPT="-shared";
COPT="-shared" ; COPTNOSHARED=""; 
else
LDOPT="-n32 -shared";
COPT="-n32 -shared" ; COPTNOSHARED="-n32"; 
fi
else 
echo "No such system: "$SYS
fi
JSLEXT="so";
JAVAINC2=$JAVAINC/irix; JAVATARG=irix-$OS;
;;
x86_64-pc-linux*) LD=$CC; LDOPT=-shared;
SLEXT="so";
LLEXT="a";  # the extension for the HDF and other libraries to link to
JSLEXT="so";
COPT="-shared -Dx86_64 -fPIC" ;
JAVAINC2=$JAVAINC/linux;
JAVATARG=linux;
;;
ia64-pc-linux*) LD=$CC; LDOPT=-shared;
SLEXT="so";
LLEXT="a";  # the extension for the HDF and other libraries to link to
JSLEXT="so";
COPT="-shared -Dia64 -fPIC" ;
JAVAINC2=$JAVAINC/linux;
JAVATARG=linux;
;;
*-pc-linux*) LD=$CC; LDOPT=-shared; 
SLEXT="so";
LLEXT="a";  # the extension for the HDF and other libraries to link to
JSLEXT="so";
COPT="-shared -DUNIX386" ; 
JAVAINC2=$JAVAINC/linux; 
JAVATARG=linux;
;;
*-freebsd*) LD=$CC; LDOPT=-shared;
SLEXT="so";
LLEXT="a";  # the extension for the HDF and other libraries to link to
JSLEXT="so";
COPT="-shared" ;
JAVAINC2=$JAVAINC/freebsd; 
JAVATARG=freebsd;
;;
*powerpc-apple*) 
LD=$CC; LDOPT=-bundle; 
JSLEXT="jnilib";
LLEXT="a";
SLEXT="dylib";
JAVAINC2=$JAVAINC/macosx; 
JAVATARG=macosx;
;;
*) LD=$CC; LDOPT=-G; SLEXT="so";
JSLEXT="so";
LLEXT="a";
COPT=-shared; COPTNOSHSARED=; JAVAINC2=$JAVAINC/$target; JAVATARG=$TARGET ;;
esac

AC_SUBST(LD)
AC_SUBST(LDOPT)
AC_SUBST(LDOPT2)
AC_SUBST(LLEXT)
AC_SUBST(SLEXT)
AC_SUBST(JSLEXT)
AC_SUBST(COPT)
AC_SUBST(COPTNOSHARE)
AC_SUBST(RM)
AC_SUBST(AWK)
AC_SUBST(FIND)
AC_SUBST(JAVA)
AC_SUBST(JAVABIN)
AC_SUBST(JAVAX)
AC_SUBST(JAVAC)
AC_SUBST(JAVADOC)
AC_SUBST(JAVAINC)
AC_SUBST(JAVAINC2)
AC_SUBST(HDF5LIB)
AC_SUBST(HDF5INC)
AC_SUBST(HDF4LIB)
AC_SUBST(HDF4INC)
AC_SUBST(H45LIB)
AC_SUBST(H45INC)
AC_SUBST(TARGET)
AC_SUBST(JAVATARG)
AC_SUBST(JAR)
AC_SUBST(CLASSPATH)
AC_SUBST(JH45INST)
AC_SUBST(JHVINST)
AC_SUBST(JH5INST)
AC_SUBST(ZLIB)
AC_SUBST(SZLIB)

AC_SUBST_FILE(VERSION)
VERSION=./VERSION
VERSSTRING=`/bin/cat ./VERSION | sed -e 's/VERSION=HDF-JAVA-//' `
AC_SUBST(VERSSTRING)


##
## Select one of the following, depending on what is being distributed.
##

OUTPUT_FILES="Makefile native/Makefile native/hdflib/Makefile native/hdf5lib/Makefile ncsa/Makefile ncsa/hdf/Makefile ncsa/hdf/hdflib/Makefile ncsa/hdf/hdf5lib/Makefile ncsa/hdf/hdf5lib/exceptions/Makefile ncsa/hdf/hdf5lib/callbacks/Makefile ncsa/hdf/hdf5lib/structs/Makefile ncsa/hdf/object/Makefile ncsa/hdf/object/fits/Makefile ncsa/hdf/object/h4/Makefile ncsa/hdf/object/h5/Makefile ncsa/hdf/object/nc2/Makefile ncsa/hdf/view/Makefile bin/hdfview.sh"
if test "$USEH45" = "yes"; then
##  want H4toH5 configured
if test -d "./test"; then
##
##  Everything
##
# OUTPUT_FILES="$OUTPUT_FILES test/Makefile test/object/misc/testh4file.sh test/object/misc/testh5file.sh test/object/misc/Makefile test/object/misc/runtests.sh test/hdf5lib/junit.sh test/hdf5lib/Makefile test/uitest/junit.sh test/uitest/Makefile examples/Makefile examples/intro/Makefile examples/datasets/Makefile examples/datatypes/Makefile examples/groups/Makefile"
OUTPUT_FILES="$OUTPUT_FILES test/Makefile test/object/misc/testh4file.sh test/object/misc/testh5file.sh test/object/misc/Makefile test/object/misc/runtests.sh test/hdf5lib/junit.sh test/hdf5lib/Makefile examples/Makefile examples/intro/Makefile examples/datasets/Makefile examples/datatypes/Makefile examples/groups/Makefile"
else
##
##  H4, H5, H45, but NO tests
##
OUTPUT_FILES="Makefile native/Makefile native/hdflib/Makefile native/hdf5lib/Makefile ncsa/Makefile ncsa/hdf/Makefile ncsa/hdf/hdflib/Makefile ncsa/hdf/hdf5lib/Makefile ncsa/hdf/hdf5lib/exceptions/Makefile ncsa/hdf/hdf5lib/callbacks/Makefile ncsa/hdf/hdf5lib/structs/Makefile ncsa/hdf/object/Makefile ncsa/hdf/object/fits/Makefile ncsa/hdf/object/h4/Makefile ncsa/hdf/object/h5/Makefile ncsa/hdf/object/nc2/Makefile ncsa/hdf/view/Makefile"
fi
else
if test -d "./test"; then
##  Don't use H4toH5 (but do include some tests)
#OUTPUT_FILES="$OUTPUT_FILES test/Makefile test/object/misc/Makefile test/object/misc/testh4file.sh test/object/misc/testh5file.sh test/object/misc/runtests.sh test/object/misc/TestH5Object.sh test/object/misc/TestH5Table.sh test/object/misc/TestH5MemoryLeak.sh test/object/Makefile test/object/unittests.sh test/hdf5lib/junit.sh test/hdf5lib/Makefile test/uitest/junit.sh test/uitest/Makefile examples/Makefile examples/intro/Makefile examples/datasets/Makefile examples/datatypes/Makefile examples/groups/Makefile examples/runExample.sh"
OUTPUT_FILES="$OUTPUT_FILES test/Makefile test/object/misc/Makefile test/object/misc/testh4file.sh test/object/misc/testh5file.sh test/object/misc/runtests.sh test/object/misc/TestH5Object.sh test/object/misc/TestH5Table.sh test/object/misc/TestH5MemoryLeak.sh test/object/Makefile test/object/unittests.sh test/hdf5lib/junit.sh test/hdf5lib/Makefile examples/Makefile examples/intro/Makefile examples/datasets/Makefile examples/datatypes/Makefile examples/groups/Makefile examples/runExample.sh"
else
##  Don't use H4toH5 (no tests)
OUTPUT_FILES="$OUTPUT_FILES"
fi
fi

AC_OUTPUT($OUTPUT_FILES)

if test -d "./test"; then
chmod +x test/object/misc/TestH5Object.sh
chmod +x test/object/misc/TestH5Table.sh
chmod +x test/object/misc/TestH5MemoryLeak.sh
chmod +x test/object/unittests.sh
chmod +x test/hdf5lib/junit.sh
fi


