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