Modify auto* scripts to handle the different uuid libraries/headers.

This commit is contained in:
AaronMatthewBrown 2009-12-10 14:20:48 +00:00
parent 79e6f22912
commit a067fb27c2
4 changed files with 56 additions and 8 deletions

View File

@ -20,6 +20,7 @@ AC_PROG_RANLIB
AC_PROG_LN_S
AC_PROG_LIBTOOL
# Sets a conditional makefile variable so that certain Makefile tasks will be
# performed only on linux (currently, add -luuid to LD_FLAGS)
AM_CONDITIONAL(LINUX, [case $host_os in linux*) true;; *) false;; esac])
@ -28,8 +29,34 @@ AM_CONDITIONAL(LINUX, [case $host_os in linux*) true;; *) false;; esac])
AC_HEADER_STDC
# Check for uuid.h and a valid libuuid
AC_CHECK_HEADER(uuid/uuid.h, ,AC_MSG_ERROR([uuid/uuid.h is not available]))
AC_CHECK_LIB(uuid, uuid_generate, ,AC_MSG_ERROR([libuuid is not available]))
AC_CHECK_FUNC(uuid_create)
if test "${ac_cv_func_uuid_create}" = yes ; then
AC_DEFINE(HAVE_UUID_CREATE, [], "specifies if the uuid_create function defined")
use_uuid_library="no"
else
AC_CHECK_FUNC(uuid_generate)
if test "${ac_cv_func_uuid_generate}" = yes ; then
AC_DEFINE(HAVE_UUID_GENERATE, [], "specifies if the uuid_generate function defined")
use_uuid_library="no"
else
AC_CHECK_LIB(uuid, uuid_generate, ,
AC_MSG_ERROR([libuuid is not available]))
AC_DEFINE(HAVE_UUID_GENERATE, [], "specifies if the uuid_generate function defined")
use_uuid_library="yes"
fi
fi
AM_CONDITIONAL(USE_UUID_LIBRARY, test "${use_uuid_library}" = yes)
AC_CHECK_HEADER(uuid.h)
if test "${ac_cv_header_uuid_h}" = yes ; then
AC_DEFINE(HAVE_UUID_H, [], "specifies if the uuid.h header exists")
else
AC_CHECK_HEADER(uuid/uuid.h)
if test "${ac_cv_header_uuid_uuid_h}" = yes ; then
AC_DEFINE(HAVE_UUID_UUID_H, [], "specifies if the uuid/uuid.h header exists")
fi
fi
# Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST

View File

@ -37,7 +37,7 @@ iperf3_CFLAGS = -g -Wall
iperf3_LDADD = libiperf.a
# Linux installs require the uuid library explicitly linked in
if LINUX
if USE_UUID_LIBRARY
iperf3_LDFLAGS = -luuid
else
iperf3_LDFLAGS =
@ -73,7 +73,7 @@ iperf3_profile_CFLAGS = -pg -Wall
iperf3_profile_LDADD = libiperf.a
# Linux installs require the uuid library explicitly linked in
if LINUX
if USE_UUID_LIBRARY
iperf3_profile_LDFLAGS = -luuid
else
iperf3_profile_LDFLAGS =

View File

@ -33,6 +33,18 @@
/* Define to 1 if you have the <unistd.h> header file. */
#undef HAVE_UNISTD_H
/* "specifies if the uuid_create function defined" */
#undef HAVE_UUID_CREATE
/* "specifies if the uuid_generate function defined" */
#undef HAVE_UUID_GENERATE
/* "specifies if the uuid.h header exists" */
#undef HAVE_UUID_H
/* "specifies if the uuid/uuid.h header exists" */
#undef HAVE_UUID_UUID_H
/* Name of package */
#undef PACKAGE

View File

@ -1,12 +1,19 @@
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include<string.h>
#if defined(__FreeBSD__)
#if defined(HAVE_UUID_H)
#warning DOING SOMETHING
#include <uuid.h>
#else
#elif defined(HAVE_UUID_UUID_H)
#include <uuid/uuid.h>
#else
#error No uuid header file specified
#endif
/* XXX: this code is not portable: not all versions of linux install libuuidgen
by default
* if not installed, may need to do something like this:
@ -21,13 +28,15 @@ get_uuid(char *temp)
char *s;
uuid_t uu;
#if defined(__FreeBSD__)
#if defined(HAVE_UUID_CREATE)
uuid_create(&uu, NULL);
uuid_to_string(&uu, &s, 0);
#else
#elif defined(HAVE_UUID_GENERATE)
s = (char *) malloc(37);
uuid_generate(uu);
uuid_unparse(uu, s);
#else
#error No uuid function specified
#endif
memcpy(temp, s, 37);
}