dnl Process this file with autoconf to produce a configure script.
AC_INIT(bonnie++.cpp)
AC_CONFIG_HEADER(conf.h)
AC_SUBST(version)
version="1.03"

AC_SUBST(stripping)
AC_ARG_ENABLE(stripping,
      [  --disable-stripping  disables stripping of installed binaries],
      STRIPPING=$strippingval, STRIPPING=no)
if [[ ! "$STRIPPING" = "no" ]]; then
  stripping=""
else
  stripping="-s"
fi
echo $DEB_BUILD_OPTIONS | grep -q nostrip
if [[ "$?" = "0" ]]; then
  stripping=""
fi

AC_SUBST(debug)
AC_ARG_ENABLE(debug,
      [  --with-debug  enables debug code generation for binaries],
      debug=-g, debug="")
echo $DEB_BUILD_OPTIONS | grep -q debug
if [[ "$?" = "0" ]]; then
  debug=-g
fi

dnl Checks for programs.
AC_LANG_CPLUSPLUS
AC_PROG_CXX
AC_PROG_CXXCPP
AC_PROG_INSTALL

dnl Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
AC_TYPE_SIZE_T

AC_SUBST(semun)
AC_TRY_COMPILE(#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/sem.h>
    , union semun sem , semun="yes")
if [[ -n "$semun" ]]; then
   semun="#define SEMUN_IN_SEM_H"
fi
AC_SUBST(sa_sigaction)
AC_TRY_COMPILE([#include <signal.h>]
             , [struct sigaction sa; sa.sa_sigaction = 0]
             , sa_sigaction=y)
if [[ "$sa_sigaction" = "y" ]]; then
  sa_sigaction="#define USE_SA_SIGACTION"
fi
AC_SUBST(bool)
AC_TRY_COMPILE([], [bool var;] , , bool="typedef bool char;")
AC_SUBST(true_false)
AC_TRY_COMPILE(, [char c = true; char d = false;
] , true_false="0", true_false="1")
AC_SUBST(snprintf)
AC_TRY_LINK([#include <stdio.h>], char buf[[10]]; snprintf(buf, sizeof(buf), "abc");,,snprintf="no");
if [[ -n "$snprintf" ]]; then
   snprintf="#define NO_SNPRINTF"
fi

AC_SUBST(exes)
AC_SUBST(man8)
exes="bonnie++"
man8="bonnie++.8"
AC_CHECK_HEADERS(vector.h vector, exes="$exes zcav" man8="$man8 zcav.8", echo "STL not installed so no ZCAV!")
AC_CHECK_HEADERS(algo.h algo)

AC_SUBST(aix_mem_size)
if [[ -f /etc/objrepos ]]; then
  aix_mem_size="#define AIX_MEM_SIZE 1"
fi

AC_OUTPUT(Makefile bonnie.h port.h bonnie++.spec bon_csv2html bon_csv2txt sun/pkginfo)
