Any problem with japhar-config.in written as this?  (it works, just
want to make sure everyone is okay with this as it is more akin to
guile-config and includes more information (which I need)).  Of course if 
I'm the only person using japhar-config, there should be no problems!

Brian


#!/bin/sh

prefix="@prefix@"
exec_prefix="@exec_prefix@"

japhar_jni_libs="@JAPHAR_JNI_LIBS@"
japhar_cflags="@JAPHAR_CFLAGS@"

LIBS="@LIBS@"
pkgincludedir="@pkgincludedir@"
pkglibdir="@pkglibdir@"
includedir="@includedir@"
mandir="@mandir@"
infodir="@infodir@"
libdir="@libdir@"
localstatedir="@localstatedir@"
sysconfdir="@sysconfdir@"
datadir="@datadir@"
libexecdir="@libexecdir@"
sbindir="@sbindir@"
bindir="@bindir@"
#${prefix}
#exec_prefix_set=no
srcdir="@srcdir@"
top_srcdir="@top_srcdir@"

# need LIBS in two cases, hence this is here
for i in $japhar_jni_libs ; do
  add_to_lib=1
  for j in ${LIBS}; do
    if test $i = $j || test $i = "-L${libdir}"; then
      add_to_lib=0
    fi
  done
  if test $add_to_lib -eq 1; then
    LIBS="${LIBS} $i"
  fi
done

usage="\
Usage: \n\
  japhar-config --version         - show installed script and Guile version \n\
  japhar-config --help            - show usage info (this message)          \n\
  japhar-config --help SUBCOMMAND - show help for SUBCOMMAND                \n\
  japhar-config link              - print libraries to link with            \n\
  japhar-config compile           - print C compiler flags to compile with  \n\
  japhar-config info [VAR]        - print Guile build directories           "


# [--prefix[=DIR]] [--exec-prefix[=DIR]] [--version] [--jni-libs] [--cflags]

if test $# -eq 0; then
      echo -e "${usage}" 1>&2
      exit 1
fi

if test $# -gt 0; then
  case $1 in
    --version)
      echo @VERSION@
      ;;
    --cflags)
      if test ${prefix}/include != /usr/include ; then
        includes=-I${prefix}/include
        for i in $japhar_cflags ; do
          if test $i = -I${prefix}/include ; then
            includes=""
          fi
        done
      fi
      echo @JAPHAR_CFLAGS@
      ;;
    --jni-libs)
      libdirs=-L${exec_prefix}/lib
      for i in $japhar_jni_libs ; do
        if test $i = -L${exec_prefix}/lib ; then
          libdirs=""
        fi
      done
      echo $libdirs $japhar_jni_libs
      ;;
    --help)
      if test $# -eq 1; then
        echo -e "${usage}" 1>&2
      elif test $# -eq 2; then
        case $2 in 
          link)
            echo "Usage: $0 link"
            echo "  Print linker flags for building the \`japhar' executable."
            echo "  Print the linker command-line flags necessary to link against"
            echo "  the Japhar JNI library, and any other libraries it requires."
            ;;
          compile)
            echo "Usage: $0 compile"
            echo "  Print C compiler flags for compiling code that uses Japhar JNI."
            echo "  This includes any \`-I' flags needed to find Japhar's header 
files."
            ;;
          info)
            echo "Usage: $0 info [VAR]"
            echo "  Display the value of the Makefile variable VAR used when Japhar"
            echo "  was built.  If VAR is omitted, display all Makefile variables."
            echo "  Use this command to find out where Japhar was installed,"
            echo "  where it installed its class library, etc."
            ;;
        esac
      else
        echo -e "${usage}" 1>&2
      fi
      exit 1
      ;;
    link)
      echo "-L${libdir} ${LIBS}"
      ;;
    compile)
      unique_cflags="-I${includedir}"
      for i in $japhar_cflags; do
        if test $i != $includedir; then
          unique_cflags="${unique_cflags} $i"
        fi
      done
      echo ${unique_cflags}
      ;;
    info)
      if test $# -eq 1; then
        echo "LIBS = ${LIBS}"
#        echo "pkgincludedir = ${pkgincludedir}"
#        echo "pkglibdir = ${pkglibdir}"
        echo "includedir = ${includedir}"
        echo "mandir = ${mandir}"
        echo "infodir = ${infodir}"
        echo "libdir = ${libdir}"
        echo "localstatedir = ${localstatedir}"
        echo "sysconfdir = ${sysconfdir}"
        echo "datadir = ${datadir}"
        echo "libexecdir = ${libexecdir}"
        echo "sbindir = ${sbindir}"
        echo "bindir = ${bindir}"
        echo "prefix = ${prefix}"
        echo "exec_prefix = ${exec_prefix}"
#        echo "srcdir = ${srcdir}"
#        echo "top_srcdir = ${top_srcdir}"
      elif test $# -eq 2; then
        case $2 in
          LIBS)
            echo ${LIBS}
            ;;
          pkgincludedir)
            echo ${pkgincludedir}
            ;;
          pkglibdir)
            echo ${pkglibdir}
            ;;
          pkgdatadir)
            echo ${pkgdatadir}
            ;;
          includedir)
            echo ${includdir}
            ;;
          mandir)
            echo ${mandir}
            ;;
          infodir)
            echo ${infodir}
            ;;
          libdir)
            echo ${libdir}
            ;;
          localstatedir)
            echo ${localstatedir}
            ;;
          sharedstatedir)
            echo ${sharedstatedir}
            ;;
          sysconfdir)
            echo ${sysconfdir}
            ;;
          datadir)
            echo ${datadir}
            ;;
          libexecdir)
            echo ${libexecdir}
            ;;
          sbindir)
            echo ${sbindir}
            ;;
          bindir)
            echo ${bindir}
            ;;
          exec_prefix)
            echo ${exec_prefix}
            ;;
          prefix)
            echo ${prefix}
            ;;
#          top_srcdir)
#            echo ${top_srcdir}
#            ;;
#          srcdir)
#            echo ${srcdir}
#            ;;
          *)
            echo -e "${usage}" 1>&2
            ;;
        esac          
      fi
      ;;
    *)
      echo -e "${usage}" 1>&2
      exit 1
      ;;
  esac
fi

Reply via email to