Old Ubuntu find.
[m6w6/libmemcached] / m4 / uuid.m4
1 # ===========================================================================
2 # http://
3 # ===========================================================================
4 #
5 # SYNOPSIS
6 #
7 # AX_UUID
8 # AX_UUID_GENERATE_TIME_SAFE
9 #
10 # DESCRIPTION
11 #
12 # Check for uuid, and uuid_generate_time_safe support.
13 #
14 # LICENSE
15 #
16 # Copyright (c) 2012 Brian Aker <brian@tangent.org>
17 #
18 # Copying and distribution of this file, with or without modification, are
19 # permitted in any medium without royalty provided the copyright notice
20 # and this notice are preserved. This file is offered as-is, without any
21 # warranty.
22
23 #serial 3
24
25 AC_DEFUN([AX_UUID], [
26 AC_CHECK_HEADER([uuid/uuid.h], [
27 AC_CACHE_CHECK([check to see if -luuid is not needed], [ax_cv_libuuid_is_required], [
28 AC_LANG_PUSH([C])
29 AC_RUN_IFELSE([
30 AC_LANG_PROGRAM([#include <uuid/uuid.h>], [
31 uuid_t out;
32 uuid_generate(out);
33 ])],
34 [ax_cv_libuuid_is_required=no],
35 [ax_cv_libuuid_is_required=maybe],
36 [AC_MSG_WARN([test program execution failed])])
37 AC_LANG_POP
38 ])
39
40 AS_IF([test "$ax_cv_libuuid_is_required" = maybe], [
41 AC_CACHE_CHECK([check to see if -luuid is needed], [ax_cv_libuuid_works], [
42 save_LIBS="$LIBS"
43 LIBS="-luuid $LIBS"
44 AC_LANG_PUSH([C])
45 AC_RUN_IFELSE([
46 AC_LANG_PROGRAM([#include <uuid/uuid.h>], [
47 uuid_t out;
48 uuid_generate(out);
49 ])],
50 [ax_cv_libuuid_works=yes],
51 [ax_cv_libuuid_works=no],
52 [AC_MSG_WARN([test program execution failed])])
53 AC_LANG_POP
54 LIBS="$save_LIBS"
55 ])
56 AS_IF([test "$ax_cv_libuuid_works" = yes], [
57 AC_SUBST([LIBUUID_LDFLAGS],[-luuid])])
58 ])
59
60 AS_IF([test "$ax_cv_libuuid_is_required" = no], [UUID_UUID_H=yes])
61 AS_IF([test "$ax_cv_libuuid_works" = yes], [UUID_UUID_H=yes])
62 ])
63
64 AS_IF([test "$UUID_UUID_H" = yes], [
65 AC_DEFINE([HAVE_UUID_UUID_H], [1], [Have uuid/uuid.h])
66 ],[
67 AC_DEFINE([HAVE_UUID_UUID_H], [0], [Have uuid/uuid.h])
68 ])
69 ])
70
71 AC_DEFUN([AX_UUID_GENERATE_TIME_SAFE], [
72 AC_REQUIRE([AX_UUID])
73 AC_CACHE_CHECK([for uuid_generate_time_safe], [ax_cv_uuid_generate_time_safe], [
74 save_LIBS="$LIBS"
75 LIBS="$LIBUUID_LDFLAGS $LIBS"
76 AC_LANG_PUSH([C])
77 AC_RUN_IFELSE([
78 AC_LANG_PROGRAM([#include <uuid/uuid.h>], [
79 uuid_t out;
80 uuid_generate_time_safe(out);
81 ])],
82 [ax_cv_uuid_generate_time_safe=yes],
83 [ax_cv_uuid_generate_time_safe=no],
84 [AC_MSG_WARN([test program execution failed])])
85 AC_LANG_POP
86 LIBS="$save_LIBS"
87 ])
88
89 AS_IF([test "$ax_cv_uuid_generate_time_safe" = yes],[
90 AC_DEFINE(HAVE_UUID_GENERATE_TIME_SAFE,[1],[Define if uuid_generate_time_safe is present in uuid/uuid.h.])],[
91 AC_DEFINE(HAVE_UUID_GENERATE_TIME_SAFE,[0],[Define if uuid_generate_time_safe is present in uuid/uuid.h.])
92 ])
93 ])