Modify auto* scripts to handle the different uuid libraries/headers.
This commit is contained in:
parent
79e6f22912
commit
a067fb27c2
31
configure.ac
31
configure.ac
@ -20,6 +20,7 @@ AC_PROG_RANLIB
|
|||||||
AC_PROG_LN_S
|
AC_PROG_LN_S
|
||||||
AC_PROG_LIBTOOL
|
AC_PROG_LIBTOOL
|
||||||
|
|
||||||
|
|
||||||
# Sets a conditional makefile variable so that certain Makefile tasks will be
|
# Sets a conditional makefile variable so that certain Makefile tasks will be
|
||||||
# performed only on linux (currently, add -luuid to LD_FLAGS)
|
# performed only on linux (currently, add -luuid to LD_FLAGS)
|
||||||
AM_CONDITIONAL(LINUX, [case $host_os in linux*) true;; *) false;; esac])
|
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
|
AC_HEADER_STDC
|
||||||
|
|
||||||
# Check for uuid.h and a valid libuuid
|
# 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_FUNC(uuid_create)
|
||||||
AC_CHECK_LIB(uuid, uuid_generate, ,AC_MSG_ERROR([libuuid is not available]))
|
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.
|
# Checks for typedefs, structures, and compiler characteristics.
|
||||||
AC_C_CONST
|
AC_C_CONST
|
||||||
|
@ -37,7 +37,7 @@ iperf3_CFLAGS = -g -Wall
|
|||||||
iperf3_LDADD = libiperf.a
|
iperf3_LDADD = libiperf.a
|
||||||
|
|
||||||
# Linux installs require the uuid library explicitly linked in
|
# Linux installs require the uuid library explicitly linked in
|
||||||
if LINUX
|
if USE_UUID_LIBRARY
|
||||||
iperf3_LDFLAGS = -luuid
|
iperf3_LDFLAGS = -luuid
|
||||||
else
|
else
|
||||||
iperf3_LDFLAGS =
|
iperf3_LDFLAGS =
|
||||||
@ -73,7 +73,7 @@ iperf3_profile_CFLAGS = -pg -Wall
|
|||||||
iperf3_profile_LDADD = libiperf.a
|
iperf3_profile_LDADD = libiperf.a
|
||||||
|
|
||||||
# Linux installs require the uuid library explicitly linked in
|
# Linux installs require the uuid library explicitly linked in
|
||||||
if LINUX
|
if USE_UUID_LIBRARY
|
||||||
iperf3_profile_LDFLAGS = -luuid
|
iperf3_profile_LDFLAGS = -luuid
|
||||||
else
|
else
|
||||||
iperf3_profile_LDFLAGS =
|
iperf3_profile_LDFLAGS =
|
||||||
|
@ -33,6 +33,18 @@
|
|||||||
/* Define to 1 if you have the <unistd.h> header file. */
|
/* Define to 1 if you have the <unistd.h> header file. */
|
||||||
#undef HAVE_UNISTD_H
|
#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 */
|
/* Name of package */
|
||||||
#undef PACKAGE
|
#undef PACKAGE
|
||||||
|
|
||||||
|
17
src/uuid.c
17
src/uuid.c
@ -1,12 +1,19 @@
|
|||||||
|
#include "config.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include<string.h>
|
#include<string.h>
|
||||||
#if defined(__FreeBSD__)
|
|
||||||
|
#if defined(HAVE_UUID_H)
|
||||||
|
#warning DOING SOMETHING
|
||||||
#include <uuid.h>
|
#include <uuid.h>
|
||||||
#else
|
#elif defined(HAVE_UUID_UUID_H)
|
||||||
#include <uuid/uuid.h>
|
#include <uuid/uuid.h>
|
||||||
|
#else
|
||||||
|
#error No uuid header file specified
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/* XXX: this code is not portable: not all versions of linux install libuuidgen
|
/* XXX: this code is not portable: not all versions of linux install libuuidgen
|
||||||
by default
|
by default
|
||||||
* if not installed, may need to do something like this:
|
* if not installed, may need to do something like this:
|
||||||
@ -21,13 +28,15 @@ get_uuid(char *temp)
|
|||||||
char *s;
|
char *s;
|
||||||
uuid_t uu;
|
uuid_t uu;
|
||||||
|
|
||||||
#if defined(__FreeBSD__)
|
#if defined(HAVE_UUID_CREATE)
|
||||||
uuid_create(&uu, NULL);
|
uuid_create(&uu, NULL);
|
||||||
uuid_to_string(&uu, &s, 0);
|
uuid_to_string(&uu, &s, 0);
|
||||||
#else
|
#elif defined(HAVE_UUID_GENERATE)
|
||||||
s = (char *) malloc(37);
|
s = (char *) malloc(37);
|
||||||
uuid_generate(uu);
|
uuid_generate(uu);
|
||||||
uuid_unparse(uu, s);
|
uuid_unparse(uu, s);
|
||||||
|
#else
|
||||||
|
#error No uuid function specified
|
||||||
#endif
|
#endif
|
||||||
memcpy(temp, s, 37);
|
memcpy(temp, s, 37);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user