#!/usr/bin/sh
#
srcdir=.
prefix=/usr
exec_prefix=/usr
bindir=/usr/bin
sbindir=/usr/bin
libdir=/usr/lib64
datarootdir=${prefix}/share
datadir=/usr/share
includedir=/usr/include/validator
mandir=/usr/share/man

lvc_PREFIX=$prefix
lvc_EXEC_PREFIX=$exec_prefix
lvc_INCLUDEDIR=$includedir
lvc_DEVCFLAGS=""
lvc_CFLAGS="-O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS -DOPENSSL_NO_ENGINE -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1  -mbranch-protection=standard -fasynchronous-unwind-tables -fstack-clash-protection -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer   -Ulinux -Dlinux=linux -Ulinux -Dlinux=linux -DLIBVAL_CONFIGURED=1"
lvc_CPPFLAGS=""
lvc_LDFLAGS="-Wl,-z,relro -Wl,--as-needed  -Wl,-z,pack-relative-relocs -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -specs=/usr/lib/rpm/redhat/redhat-hardened-ld-errors -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1  -Wl,--build-id=sha1 -specs=/usr/lib/rpm/redhat/redhat-package-notes  "
lvc_LIBS="-lssl -lcrypto  -lpthread"
lvc_LIBDIR="-L${libdir}"
LIBVAL_SUFFIX=-threads

lvc_RESOLV_CONF="/etc/dnssec-tools/resolv.conf"
lvc_ROOT_HINTS="/etc/dnssec-tools/root.hints"
lvc_DNSVAL="/etc/dnssec-tools/dnsval.conf"

if test "x$1" = "x"; then
  usage="yes"
else
  while test "x$done" = "x" -a "x$1" != "x" -a "x$usage" != "xyes"; do
  case "$1" in
    -*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
    *) optarg= ;;
  esac

  case $1 in
    --prefix=*)
      prefix=$optarg
      lvc_PREFIX=${prefix}
      lvc_INCLUDEDIR=${prefix}/include
      lvc_LIBDIR=-L${prefix}/lib
      ;;

    --exec-prefix=*)
      exec_prefix=$optarg
      lvc_EXEC_PREFIX=${exec_prefix}
      lvc_LIBDIR=-L${exec_prefix}/lib
      ;;

    --configure-options|--con*)
      echo " '--disable-option-checking' '--prefix=/usr' '--build=aarch64-redhat-linux-gnu' '--host=aarch64-redhat-linux-gnu' '--program-prefix=' '--disable-dependency-tracking' '--exec-prefix=/usr' '--bindir=/usr/bin' '--sbindir=/usr/bin' '--datadir=/usr/share' '--includedir=/usr/include' '--libdir=/usr/lib64' '--libexecdir=/usr/libexec' '--localstatedir=/var' '--sharedstatedir=/var/lib' '--mandir=/usr/share/man' '--infodir=/usr/share/info' '--with-validator-testcases-file=/usr/share/dnssec-tools/validator-testcases' '--with-perl-build-args=INSTALLDIRS=vendor OPTIMIZE='\''-O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Wno-complain-wrong-lang -Werror=format-security -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS -DOPENSSL_NO_ENGINE -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1  -mbranch-protection=standard -fasynchronous-unwind-tables -fstack-clash-protection -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer'\''' '--sysconfdir=/etc' '--with-root-hints=/etc/dnssec-tools/root.hints' '--with-resolv-conf=/etc/dnssec-tools/resolv.conf' '--disable-static' '--with-nsec3' '--with-ipv6' '--with-dlv' '--disable-bind-checks' 'build_alias=aarch64-redhat-linux-gnu' 'host_alias=aarch64-redhat-linux-gnu' 'CC=gcc' 'CFLAGS=-O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS -DOPENSSL_NO_ENGINE -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1  -mbranch-protection=standard -fasynchronous-unwind-tables -fstack-clash-protection -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer  ' 'LDFLAGS=-Wl,-z,relro -Wl,--as-needed  -Wl,-z,pack-relative-relocs -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -specs=/usr/lib/rpm/redhat/redhat-hardened-ld-errors -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1  -Wl,--build-id=sha1 -specs=/usr/lib/rpm/redhat/redhat-package-notes  ' '--cache-file=/dev/null' '--srcdir=.'"
      ;;
    #################################################### compile
    --base-cflags)
      echo ${lvc_CFLAGS} ${lvc_CPPFLAGS} -I${lvc_INCLUDEDIR}
      ;;
    --cflags|--cf*)
      echo ${lvc_CFLAGS} ${lvc_DEVFLAGS} ${lvc_CPPFLAGS} -I. -I${lvc_INCLUDEDIR}
      ;;
    --srcdir)
      echo $lvc_SRCDIR
      ;;
    #################################################### linking
    --libdir|--lib-dir)
      echo $lvc_LIBDIR
      ;;
    --ldflags|--ld*)
      echo $lvc_LDFLAGS
      ;;
    #################################################### client lib
    --libs)
      # use this one == --libval-libs + --external-libs
      echo $lvc_LDFLAGS $lvc_LIBDIR -lsres -lval${LIBVAL_SUFFIX} $lvc_LIBS
      ;;
    --libval-libs)
      echo $lvc_LIBDIR -lsres -lval${LIBVAL_SUFFIX}
      ;;
    --external-libs)
      echo $lvc_LDFLAGS $lvc_LIBS
      ;;
    ####################################################
    --resolver-config|--res*)
        echo $lvc_RESOLV_CONF
        ;;
    --root-hints|--roo*)
        echo $lvc_ROOT_HINTS
        ;;
    --dnsval-config|--dns*)
        echo $lvc_DNSVAL
        ;;
    ####################################################
    --version|--ver*)
      echo 0.3
      ;;
    --help)
      usage="yes"
      ;;
    --prefix|--pre*)
      echo $lvc_PREFIX
      ;;
    --exec-prefix)
      echo $lvc_EXEC_PREFIX
      ;;
    *)
      echo "unknown option $1"
      usage="yes"
      ;;
  esac
  shift
  done
fi

if test "x$usage" = "xyes"; then
  echo ""
  echo "Usage:"
  echo "  libval-config [--cflags] [--agent-libs] [--libs] [--version]"
  echo "                  ... [see below for complete flag list]"
  echo ""
  echo "    --version         displays the libval version number"
  echo ""
  echo "  These options produce the various compilation flags needed when"
  echo "  building external SNMP applications:"
  echo ""
  echo "    --base-cflags     lists additional compilation flags needed"
  echo "    --cflags          lists additional compilation flags needed"
  echo "                      (includes -I. and extra developer warning flags)"
  echo ""
  echo "  These options produce the various link flags needed when"
  echo "  building external SNMP applications:"
  echo ""
  echo "    --libs            lists libraries needed for building applications"
  echo ""
  echo "  These options produce various link flags broken down into parts."
  echo "  (Most of the time the simple options above should be used.)"
  echo ""
  echo "    --libdir              path to libval"
  echo ""
  echo "    --libval-libs         libval (with path)"
  echo ""
  echo "    --ldflags             link flags for external libraries"
  echo "    --external-libs       external libraries needed by libval"
  echo ""
  echo "  Details on how the libval package was compiled:"
  echo ""
  echo "    --configure-options   display original configure arguments"
  echo "    --prefix              display the installation prefix"
  echo ""
  echo "    --resolver-config     display path to resolver configuration"
  echo "    --root-hints          display path to root hints file"
  echo "    --dnsval-config       display path to dnsval configuration"
  exit
fi  
