summaryrefslogtreecommitdiff
path: root/m4/ax_include_strcasecmp.m4
blob: 224f0391f7cf6d05f9871351172d30d34aa04cbf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# ===========================================================================
#  https://www.gnu.org/software/autoconf-archive/ax_include_strcasecmp.html
# ===========================================================================
#
# SYNOPSIS
#
#   AX_INCLUDE_STRCASECMP
#
# DESCRIPTION
#
#   This macro tries to find a header for strcasecmp() in strings.h, then
#   string.h, and AC_DEFINEs AX_STRCASECMP_HEADER to the value it found. Use
#   it in your source like so:
#
#     #ifdef AX_STRCASECMP_HEADER
#     #include AX_STRCASECMP_HEADER
#     #endif
#
# LICENSE
#
#   Copyright (c) 2012 Leo Davis <ldavis@speechfxinc.com>
#
#   Copying and distribution of this file, with or without modification, are
#   permitted in any medium without royalty provided the copyright notice
#   and this notice are preserved. This file is offered as-is, without any
#   warranty.

#serial 3

AC_DEFUN([AX_INCLUDE_STRCASECMP],
[
AC_CACHE_CHECK([for strcasecmp header file], [ax_cv_include_strcasecmp_found], [
        ax_cv_include_strcasecmp_found=no
        AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <strings.h>]],
                [[strcasecmp("foo", "bar");]])],
                [ax_cv_include_strcasecmp_found='<strings.h>'],
                [ax_cv_include_strcasecmp_found=no])

        if test x"$ax_cv_include_strcasecmp_found" = "xno"
        then
        AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <string.h>]],
                [[strcasecmp("foo", "bar");]])],
                [ax_cv_include_strcasecmp_found='<string.h>'],
                [ax_cv_include_strcasecmp_found=no])
        fi
])
        if test x"$ax_cv_include_strcasecmp_found" != "xno"
        then
            AC_DEFINE_UNQUOTED([AX_STRCASECMP_HEADER], [$ax_cv_include_strcasecmp_found],
                                                       [Defined to <strings.h> or <string.h> if strcasecmp is found])

        fi
]) dnl AX_INCLUDE_STRCASECMP