aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAaronMatthewBrown <devnull@localhost>2009-12-10 14:20:48 +0000
committerAaronMatthewBrown <devnull@localhost>2009-12-10 14:20:48 +0000
commita067fb27c2843d27f767b691763a5ee5dc200d4d (patch)
tree0f452a9824d98a289780ac1f7e638e396ff0e5e6
parent79e6f229122e78add835073a12cd6f990b664cba (diff)
downloadiperf3-a067fb27c2843d27f767b691763a5ee5dc200d4d.tar.gz
Modify auto* scripts to handle the different uuid libraries/headers.
-rw-r--r--configure.ac31
-rw-r--r--src/Makefile.am4
-rw-r--r--src/config.h.in12
-rw-r--r--src/uuid.c17
4 files changed, 56 insertions, 8 deletions
diff --git a/configure.ac b/configure.ac
index ba1e9ce..625ee73 100644
--- a/configure.ac
+++ b/configure.ac
@@ -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
diff --git a/src/Makefile.am b/src/Makefile.am
index d2a10fe..ad6204c 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -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 =
diff --git a/src/config.h.in b/src/config.h.in
index 9e9fa68..e764d3d 100644
--- a/src/config.h.in
+++ b/src/config.h.in
@@ -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
diff --git a/src/uuid.c b/src/uuid.c
index e75b542..6f62eae 100644
--- a/src/uuid.c
+++ b/src/uuid.c
@@ -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);
}