dnl Process this file with autoconf to produce a configure script.
AC_INIT(src/orb/orbit_types.h)

# (From GTK+)
# Making releases:
#   ORBIT_MICRO_VERSION += 1;
#   ORBIT_INTERFACE_AGE += 1;
#   ORBIT_BINARY_AGE += 1;
# if any functions have been added, set ORBIT_INTERFACE_AGE to 0.
# if backwards compatibility has been broken,
# set ORBIT_BINARY_AGE and ORBIT_INTERFACE_AGE to 0.
#
##########
# Screw the above, just play with the numbers until they match the
# package version number. As soon as libtool lets us specify
# sonames we'll start using that for binary compat, but until then
# caveat user :)

ORBIT_MAJOR_VERSION=0
ORBIT_MINOR_VERSION=3
ORBIT_MICRO_VERSION=0
ORBIT_INTERFACE_AGE=0
ORBIT_BINARY_AGE=0
ORBIT_VERSION=0.3.0
AC_SUBST(ORBIT_MAJOR_VERSION)
AC_SUBST(ORBIT_MINOR_VERSION)
AC_SUBST(ORBIT_MICRO_VERSION)
AC_SUBST(ORBIT_VERSION)

# libtool versioning
#LT_RELEASE=$ORBIT_MAJOR_VERSION.$ORBIT_MINOR_VERSION
#LT_CURRENT=`expr $ORBIT_MICRO_VERSION - $ORBIT_INTERFACE_AGE`
#LT_REVISION=$ORBIT_INTERFACE_AGE
#LT_AGE=`expr $ORBIT_BINARY_AGE - $ORBIT_INTERFACE_AGE`
LT_RELEASE=0.3.0
LT_CURRENT=3
LT_REVISION=0
LT_AGE=3
AC_SUBST(LT_RELEASE)
AC_SUBST(LT_CURRENT)
AC_SUBST(LT_REVISION)
AC_SUBST(LT_AGE)

# Increment this every time a feature is added in the .idl compiler
# that needs help from the main libraries.
ORBIT_SERIAL=3
AC_SUBST(ORBIT_SERIAL)

# For automake.
VERSION=$ORBIT_VERSION
PACKAGE=ORBit

AM_CONFIG_HEADER(config.h)

dnl Initialize automake stuff
AM_INIT_AUTOMAKE($PACKAGE, $VERSION, no-define)

AM_PROG_LIBTOOL
AM_MAINTAINER_MODE

dnl Checks for programs.
AC_PROG_CC
AC_PROG_INSTALL

dnl Handle indent variations (should check for sucky indents (eg solaris) too)
dnl default is "sopwith indent", use "--enable-indent=kr" for legible indent.
AC_ARG_ENABLE(indent, [  --disable-indent        do not indent output code], use_indent=$enableval, use_indent=yes)

if test "$use_indent" != "no"; then
  AC_CHECK_PROG(HAVE_INDENT, indent, yes)
  if test "$HAVE_INDENT" = "yes"; then
    AC_DEFINE(HAVE_INDENT)
    if test "$use_indent" = "kr"; then
      AC_DEFINE(HAVE_INDENT_KR)
    fi
  fi
fi

dnl Checks for libraries.

AM_PATH_GLIB
#AC_CHECK_PROG(HAVE_GLIB_CONFIG, glib-config, yes, no)
#
#if test "$HAVE_GLIB_CONFIG" != "yes"; then
#	echo "You must have glib installed."
#	exit 1
#fi
#GLIB_INCLUDES=`glib-config --cflags`
#GLIB_LIBS=`glib-config --libs`
#AC_SUBST(GLIB_LIBS)
#AC_SUBST(GLIB_INCLUDES)

AC_PROG_YACC
AM_PROG_LEX
AC_PROG_AWK

dnl Checks for header files.
AC_HEADER_STDC
AC_CHECK_HEADERS(fcntl.h unistd.h sys/endian.h endian.h machine/endian.h sys/machine.h sys/isa_defs.h sys/poll.h)
AC_CHECK_HEADERS(stddef.h wchar.h wcstr.h wctype.h machine/types.h)

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

dnl Checks for library functions.
AC_FUNC_VPRINTF
AC_CHECK_FUNCS(poll basename snprintf)
AC_CHECK_FUNC(socket,,[AC_CHECK_LIB(socket,socket)])
AC_CHECK_FUNC(gethostbyname,,[AC_CHECK_LIB(nsl,gethostbyname)])

AC_CHECK_FUNC(inet_aton,,[AC_CHECK_LIB(resolv,inet_aton)])
if test x$ac_cv_func_inet_aton = xno && test x$ac_cv_lib_resolv_inet_aton = xno
then :
else
  AC_DEFINE(HAVE_INET_ATON)
fi

dnl This generates warnings from autoconf...
AC_C_BIGENDIAN

AC_TRY_RUN([
#include <fcntl.h>
#include <sys/uio.h>
#define NIOVECS 50
int main(int argc, char *argv[])
{
	char dumbuf[20] = "\n";
	struct iovec iovecs[NIOVECS];
	int i,fd;

	for(i = 0; i < NIOVECS; i++) {
		iovecs[i].iov_base = dumbuf;
		iovecs[i].iov_len = 1;
	}

	fd=open("/dev/null", O_WRONLY);
	if(fd==-1)
		return(1);

	if(writev(fd, iovecs, NIOVECS) < 0)
		return 1;

	close(fd);
	return 0;
}
], , AC_DEFINE(HAVE_LIMITED_WRITEV),AC_DEFINE(HAVE_LIMITED_WRITEV))
AC_SUBST(HAVE_LIMITED_WRITEV)

AC_CONFIG_SUBDIRS(libIDL)

AC_OUTPUT(Makefile
orbit-config
src/Makefile
src/ORBitutil/Makefile
src/IIOP/Makefile
src/orb/orbit.h
src/orb/Makefile
src/idl-compiler/Makefile
src/services/Makefile
src/services/name/Makefile
test/Makefile
test/test-poa/Makefile)
