Debian Codegraph @

am/libidn.m4

raw
1 # libidn.m4 serial 2
2 dnl Copyright (C) 2013-2026 Free Software Foundation, Inc.
3 dnl
4 dnl This file is part of GNU Inetutils.
5 dnl
6 dnl GNU Inetutils is free software: you can redistribute it and/or modify
7 dnl it under the terms of the GNU General Public License as published by
8 dnl the Free Software Foundation, either version 3 of the License, or (at
9 dnl your option) any later version.
10 dnl
11 dnl GNU Inetutils is distributed in the hope that it will be useful, but
12 dnl WITHOUT ANY WARRANTY; without even the implied warranty of
13 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 dnl General Public License for more details.
15 dnl
16 dnl You should have received a copy of the GNU General Public License
17 dnl along with this program. If not, see `http://www.gnu.org/licenses/'.
18
19 dnl Written by Mats Erik Andersson.
20
21 dnl IU_CHECK_LIBIDN([PREFIX],[HEADERLOC])
22 dnl Search for libidn in standard location and in PREFIX,
23 dnl if the latter is set and is neither "yes", nor "no".
24 dnl
25 dnl First check: $with_idn != no
26
27 AC_DEFUN([IU_CHECK_LIBIDN],
28 [
29 if test x"$with_idn" != xno \
30 && test "$ac_cv_header_locale_h" = yes \
31 && test "$ac_cv_func_setlocale" = yes
32 then
33 if test -n "$1" \
34 && test x"$1" != xno \
35 && test x"$1" != xyes
36 then
37 INCIDN=-I$1/include
38 LIBIDN=-L$1/lib
39 fi
40
41 if test -n "$2" \
42 && test x"$2" != xyes
43 then
44 INCIDN=-I$2
45 fi
46
47 AC_CHECK_LIB([idn2], [idn2_to_ascii_lz], [have_IDN2=yes], , [$LIBIDN])
48
49 AC_CHECK_LIB([idn], [idna_to_ascii_lz], [have_IDN=yes], , [$LIBIDN])
50
51 if test x"$have_IDN2" = xyes
52 then
53 LIBIDN="$LIBIDN -lidn2"
54 else
55 if test x"$have_IDN" = xyes
56 then
57 LIBIDN="$LIBIDN -lidn"
58 else
59 INCIDN= LIBIDN=
60 fi
61 fi
62
63 # Some systems are known to install <idna.h> below
64 # '/usr/include/idn'. The caching performed by
65 # AC_CHECK_HEADERS prevents detection of this using
66 # repeated call of the macro. Functional alternative?
67 save_CPPFLAGS=$CPPFLAGS
68 CPPFLAGS="$CPPFLAGS $INCIDN"
69
70 AC_CHECK_HEADERS([idna.h idn2.h])
71
72 AC_MSG_CHECKING([if GNU libidn is available])
73 if test "$ac_cv_lib_idn2_idn2_to_ascii_lz" = yes \
74 && test "$ac_cv_header_idn2_h" = yes; then
75 AC_DEFINE(HAVE_IDN2, 1, [Define to 1 for use of GNU Libidn2.])
76 AC_MSG_RESULT($ac_cv_lib_idn2_idn2_to_ascii_lz)
77 else
78 if test "$ac_cv_lib_idn_idna_to_ascii_lz" = yes \
79 && test "$ac_cv_header_idna_h" = yes; then
80 AC_DEFINE(HAVE_IDN, 1, [Define to 1 for use of GNU Libidn.])
81 AC_MSG_RESULT($ac_cv_lib_idn_idna_to_ascii_lz)
82 else
83 AC_MSG_RESULT([no])
84 INCIDN= LIBIDN=
85 fi
86 fi
87 CPPFLAGS=$save_CPPFLAGS
88 fi
89 AC_SUBST([LIBIDN])
90 AC_SUBST([INCIDN])
91 ])# IU_CHECK_LIBIDN