m4: merge TangentOrg/ddm4
[awesomized/libmemcached] / m4 / ax_printf_strerror.m4
1 # ===========================================================================
2 # https://github.com/BrianAker/ddm4/
3 # ===========================================================================
4 #
5 # SYNOPSIS
6 #
7 # AX_PRINTF_STRERROR()
8 #
9 # DESCRIPTION
10 #
11 # Check to see if printf() has %m implemented (i.e. can handle strerror
12 # internally)
13 #
14 # LICENSE
15 #
16 # Copyright (C) 2013 Brian Aker All rights reserved.
17 #
18 # Redistribution and use in source and binary forms, with or without
19 # modification, are permitted provided that the following conditions are
20 # met:
21 #
22 # * Redistributions of source code must retain the above copyright
23 # notice, this list of conditions and the following disclaimer.
24 #
25 # * Redistributions in binary form must reproduce the above
26 # copyright notice, this list of conditions and the following disclaimer
27 # in the documentation and/or other materials provided with the
28 # distribution.
29 #
30 # * The names of its contributors may not be used to endorse or
31 # promote products derived from this software without specific prior
32 # written permission.
33 #
34 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
35 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
36 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
37 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
38 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
39 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
40 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
41 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
42 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
43 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
44 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
45
46 #serial 2
47
48 AC_DEFUN([AX_PRINTF_STRERROR],
49 [AC_PREREQ([2.63])dnl
50 AC_CACHE_CHECK([printf() has strerror option],
51 [ax_cv_have_printf_strerror],
52 [AC_LANG_PUSH([C++])
53 AC_RUN_IFELSE([AC_LANG_PROGRAM([[#include <cstdio>
54 #include <cstddef>
55 #include <cstdlib>
56 #include <cstring>
57 #include <cerrno>
58 ]],
59 [[char buffer[1024]; errno=0; snprintf(buffer, sizeof(buffer), "%m"); if (strcmp("Success", buffer) !=0 ) return EXIT_FAILURE;]])],
60 [ax_cv_have_printf_strerror=yes],
61 [ax_cv_have_printf_strerror=no],
62 [ax_cv_have_printf_strerror=no])
63 AC_LANG_POP])
64 AC_MSG_RESULT(["$ax_cv_have_printf_strerror"])
65 AS_IF([test "x$ax_cv_have_printf_strerror" = xyes],
66 [AC_DEFINE([HAVE_PRINTF_STRERROR],[1],[define if printf supports directly print errno])])
67 ])