dnl ##
dnl ##  OSSP uuid - Universally Unique Identifier
dnl ##  Copyright (c) 2004 Ralf S. Engelschall <rse@engelschall.com>
dnl ##  Copyright (c) 2004 The OSSP Project <http://www.ossp.org/>
dnl ##
dnl ##  This file is part of OSSP uuid, a library for the generation
dnl ##  of UUIDs which can found at http://www.ossp.org/pkg/lib/uuid/
dnl ##
dnl ##  Permission to use, copy, modify, and distribute this software for
dnl ##  any purpose with or without fee is hereby granted, provided that
dnl ##  the above copyright notice and this permission notice appear in all
dnl ##  copies.
dnl ##
dnl ##  THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
dnl ##  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
dnl ##  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
dnl ##  IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
dnl ##  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
dnl ##  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
dnl ##  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
dnl ##  USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
dnl ##  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
dnl ##  OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
dnl ##  OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
dnl ##  SUCH DAMAGE.
dnl ##
dnl ##  uuid.ac: UUID specific Autoconf checks
dnl ##

dnl #   Check for anything OSSP uuid wants to know
dnl #   configure.in:
dnl #     UUID_CHECK_ALL

AC_DEFUN(UUID_CHECK_ALL,[
    dnl #   make sure libnsl and libsocket are linked in if they exist
    AC_CHECK_LIB(nsl, gethostname)
    if test ".`echo $LIBS | grep nsl`" = .; then
        AC_CHECK_LIB(nsl, gethostbyname)
    fi
    AC_CHECK_LIB(socket, accept)

    dnl #   check for system headers
    AC_CHECK_HEADERS(sys/types.h sys/param.h sys/time.h sys/socket.h sys/sockio.h sys/ioctl.h)
    AC_CHECK_HEADERS(netdb.h ifaddrs.h net/if.h net/if_dl.h net/if_arp.h netinet/in.h arpa/inet.h,,,
[[
#if HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#if HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
#if HAVE_SYS_IOCTL_H
#include <sys/ioctl.h>
#endif
]])

    dnl #   check for functions
    AC_CHECK_FUNCS(getifaddrs nanosleep)

    dnl #   check size of built-in types
    AC_CHECK_TYPES([long long, long double])
    AC_CHECK_SIZEOF(char, 1)
    AC_CHECK_SIZEOF(unsigned char, 1)
    AC_CHECK_SIZEOF(short, 2)
    AC_CHECK_SIZEOF(unsigned short, 2)
    AC_CHECK_SIZEOF(int, 4)
    AC_CHECK_SIZEOF(unsigned int, 4)
    AC_CHECK_SIZEOF(long, 4)
    AC_CHECK_SIZEOF(unsigned long, 4)
    AC_CHECK_SIZEOF(long long, 8)
    AC_CHECK_SIZEOF(unsigned long long, 8)

    dnl #   options
    AC_ARG_WITH(dce,
        AC_HELP_STRING([--with-dce], [build DCE 1.1 backward compatibility API]),
        [ac_cv_with_dce=$withval], [ac_cv_with_dce=no])
    if test ".$ac_cv_with_dce" = ".yes"; then
        AC_DEFINE(WITH_DCE, 1, [whether to build DCE 1.1 backward compatibility API])
        WITH_DCE='yes'
        DCE_NAME='$(DCE_NAME)'
    else
        WITH_DCE='no'
        DCE_NAME=''
    fi
    AC_SUBST(WITH_DCE)
    AC_SUBST(DCE_NAME)
])

