dnl Process this file with autoconf to produce a configure script.
AC_INIT(src/DarkIce.cpp)
AM_INIT_AUTOMAKE(darkice, 0.5)

AM_CONFIG_HEADER(config.h)

AC_PROG_CXX
AC_PROG_INSTALL

dnl AC_STDC_HEADERS
AC_HAVE_HEADERS(errno.h fcntl.h stdio.h stdlib.h string.h unistd.h limits.h)
AC_HAVE_HEADERS(getopt.h signal.h time.h sys/time.h sys/types.h sys/soundcard.h)
AC_HAVE_HEADERS(netdb.h netinet/in.h sys/ioctl.h sys/socket.h sys/stat.h)
AC_HAVE_HEADERS(sched.h)
AC_HEADER_SYS_WAIT()

AC_TYPE_PID_T()
AC_TYPE_SIZE_T()

AC_SUBST(LAME_INCFLAGS)
AC_SUBST(LAME_LDFLAGS)
AC_SUBST(LINK_STATIC)
AC_SUBST(VERSION)

dnl checkin for lame library
AC_MSG_CHECKING(lame library)
AC_ARG_WITH(lame-prefix,
[  --with-lame-prefix=DIR  alternate location for lame [/usr]
                          files looked for: LAME-PREFIX/lib/libmp3lame.a
                                            LAME-PREFIX/include/lame/lame.h],
  CONFIG_LAME_PREFIX="${withval}", CONFIG_LAME_PREFIX="/usr")
  if test "x${CONFIG_LAME_PREFIX}" != "x" ; then
    # look for lame lib. This overrides any standard location
    LA_SEARCH_LIB(LAME_LIB_LOC, LAME_INC_LOC, libmp3lame.a, lame/lame.h, ${CONFIG_LAME_PREFIX})
    if test "x${LAME_LIB_LOC}" != "x" ; then
      AC_DEFINE(HAVE_LAME_LIB, 1, build with lame library calls)
      if test "x${LAME_INC_LOC}" != "x/usr/include" ; then
          LAME_INCFLAGS="-I${LAME_INC_LOC}"
          LAME_LDFLAGS="-Wl,--rpath -Wl,${LAME_LIB_LOC} -lmp3lame"
      else
          LAME_LDFLAGS="-lmp3lame"
      fi
      AC_MSG_RESULT( "lame found at ${LAME_LIB_LOC}")
    else
      AC_MSG_ERROR( "lame library not found")
    fi
  fi

AC_ARG_ENABLE( static,
[  --enable-static         link everything into the executable statically [no]],
  CONFIG_LINK_STATIC="${enableval}", CONFIG_LINK_STATIC="")
  if test "${CONFIG_LINK_STATIC}" == "yes" ; then
    LINK_STATIC="--static"
    AC_MSG_RESULT( "creating statically linked executable")
  else
    LINK_STATIC=""
    AC_MSG_RESULT( "creating dinamically linked executable")
  fi


AC_OUTPUT(Makefile src/Makefile man/Makefile)

