1dnl Id: configure.in,v 1.1 2003/06/04 00:25:25 marka Exp
2dnl Process this file with autoconf to produce a configure script.
3dnl
4dnl Copyright (c) 2000 Japan Network Information Center.  All rights reserved.
5dnl
6dnl By using this file, you agree to the terms and conditions set forth bellow.
7dnl
8dnl 			LICENSE TERMS AND CONDITIONS
9dnl
10dnl The following License Terms and Conditions apply, unless a different
11dnl license is obtained from Japan Network Information Center ("JPNIC"),
12dnl a Japanese association, Kokusai-Kougyou-Kanda Bldg 6F, 2-3-4 Uchi-Kanda,
13dnl Chiyoda-ku, Tokyo 101-0047, Japan.
14dnl
15dnl 1. Use, Modification and Redistribution (including distribution of any
16dnl    modified or derived work) in source and/or binary forms is permitted
17dnl    under this License Terms and Conditions.
18dnl
19dnl 2. Redistribution of source code must retain the copyright notices as they
20dnl    appear in each source code file, this License Terms and Conditions.
21dnl
22dnl 3. Redistribution in binary form must reproduce the Copyright Notice,
23dnl    this License Terms and Conditions, in the documentation and/or other
24dnl    materials provided with the distribution.  For the purposes of binary
25dnl    distribution the "Copyright Notice" refers to the following language:
26dnl    "Copyright (c) 2000-2002 Japan Network Information Center.  All rights reserved."
27dnl
28dnl 4. The name of JPNIC may not be used to endorse or promote products
29dnl    derived from this Software without specific prior written approval of
30dnl    JPNIC.
31dnl
32dnl 5. Disclaimer/Limitation of Liability: THIS SOFTWARE IS PROVIDED BY JPNIC
33dnl    "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
34dnl    LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
35dnl    PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL JPNIC BE LIABLE
36dnl    FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
37dnl    CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
38dnl    SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
39dnl    BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
40dnl    WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
41dnl    OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
42dnl    ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
43
44AC_INIT(include/idn/converter.h)
45
46AC_CANONICAL_HOST
47
48debug=no
49AC_ARG_ENABLE(debug,
50[  --enable-debug          enable debug codes [default=no]],
51	debug=$enableval)
52case "$debug" in
53yes)
54    CFLAGS="$CFLAGS -DDEBUG"
55    ;;
56esac
57
58mdnkit_compat=no
59COMPAT_TRUE="#"
60COMPAT_FALSE=
61AC_ARG_ENABLE(mdnkit-compat,
62[  --enable-mdnkit-compat  enable mDNkit compatibility mode [default=no]],
63	mdnkit_compat=$enableval)
64case "$mdnkit_compat" in
65yes)
66    COMPAT_TRUE=
67    COMPAT_FALSE="#"
68    AC_DEFINE(ENABLE_MDNKIT_COMPAT, 1,
69	[Define if --enable-mdnkit-compat is specified])
70    ;;
71no)
72    ;;
73*)
74    AC_MSG_ERROR([You must specify yes or no to --enable-runidn option.])
75    ;;
76esac
77AC_SUBST(COMPAT_TRUE)
78AC_SUBST(COMPAT_FALSE)
79
80extraace=no
81AC_ARG_ENABLE(extra-ace,
82[  --enable-extra-ace      enable additional ACE converters. [default=no]],
83	extraace=$enableval)
84case "$extraace" in
85no)
86    ;;
87yes)
88    AC_DEFINE(IDN_EXTRA_ACE, 1,
89	[Define if you want additional ACE converters compiled in.])
90    ;;
91*)
92    AC_MSG_ERROR([You must specify yes or no to --enable-extra-ace option.])
93    ;;
94esac
95
96UTF8_NAME=no
97AC_ARG_WITH(utf8,
98[  --with-utf8=NAME        codeset name for UTF-8 encoding [UTF-8]],
99	UTF8_NAME=$withval)
100case "$UTF8_NAME" in
101no)
102    UTF8_NAME=UTF-8
103    ;;
104yes)
105    AC_MSG_ERROR([You must specify NAME to --with-utf8 option.])
106    ;;
107*)
108    AC_DEFINE_UNQUOTED(IDN_UTF8_ENCODING_NAME, "$UTF8_NAME",
109	[Define if your iconv() does not accept "UTF-8" as the codeset name for utf-8.])
110    ;;
111esac
112AC_SUBST(UTF8_NAME)
113
114liteonly=no
115LITEONLY_TRUE="#"
116LITEONLY_FALSE=
117AC_ARG_ENABLE(liteonly,
118[  --enable-liteonly       compile and install lite library only [default=no]],
119	liteonly=$enableval)
120case "$liteonly" in
121no)
122    ;;
123yes)
124    if test "$install_runidn" = yes ; then
125	AC_MSG_ERROR([you can't set value \"yes\" to --enable-runidn and --enable-liteonly simultaneously, because runidn requires iconv support of generic libidnkit.])
126    fi
127    LITEONLY_TRUE=
128    LITEONLY_FALSE="#"
129    ;;
130*)
131    AC_MSG_ERROR([You must specify yes or no to --enable-liteonly option.])
132    ;;
133esac
134AC_SUBST(LITEONLY_TRUE)
135AC_SUBST(LITEONLY_FALSE)
136
137install_runidn=no
138RUNIDN_TRUE="#"
139RUNIDN_FALSE=
140AC_ARG_ENABLE(runidn,
141[  --enable-runidn         compile and install runidn [default=no]],
142	install_runidn=$enableval)
143case "$install_runidn" in
144no)
145    ;;
146yes)
147    if test "$liteonly" = yes ; then
148	AC_MSG_ERROR([you can't set value \"yes\" to --enable-runidn and --enable-liteonly simultaneously, because runidn requires iconv support of generic libidnkit.])
149    fi
150    RUNIDN_TRUE=
151    RUNIDN_FALSE="#"
152    ;;
153*)
154    AC_MSG_ERROR([You must specify yes or no to --enable-runidn option.])
155    ;;
156esac
157AC_SUBST(RUNIDN_TRUE)
158AC_SUBST(RUNIDN_FALSE)
159
160ICONVINC=
161ICONVLIB=
162
163libiconv=unspec
164AC_ARG_WITH(libiconv,
165[  --with-libiconv=IPREFIX  GNU libiconv are installed in IPREFIX [PREFIX]],
166	libiconv=$withval)
167case "$libiconv" in
168unspec)
169    ;;
170no)
171    ICONVINC=
172    ICONVLIB=
173    ;;
174yes)
175    if test "$liteonly" = yes ; then
176	AC_MSG_ERROR([you can't set iconv options at all when you set value \"yes\" to --enable-liteonly, because lite library does not have iconv support.])
177    fi
178    if test X$prefix = XNONE ; then
179	libiconv=$ac_default_prefix
180    else
181	libiconv=$prefix
182    fi
183    ICONVINC="-I$libiconv/include"
184    ICONVLIB="-L$libiconv/lib -R$libiconv/lib -liconv"
185    ;;
186*)
187    if test "$liteonly" = yes ; then
188	AC_MSG_ERROR([you can't set iconv options at all when you set value \"yes\" to --enable-liteonly, because lite library does not have iconv support.])
189    fi
190    ICONVINC="-I$libiconv/include"
191    ICONVLIB="-L$libiconv/lib -R$libiconv/lib -liconv"
192    ;;
193esac
194
195iconv_include=unspec
196AC_ARG_WITH(iconv-include,
197[  --with-iconv-include=DIR  iconv include files are in DIR []],
198	iconv_include=$withval)
199case "$iconv_include" in
200unspec)
201    ;;
202no)
203    ICONVINC=
204    ;;
205yes)
206    if test "$liteonly" = yes ; then
207	AC_MSG_ERROR([you can't set iconv options at all when you set value \"yes\" to --enable-liteonly, because lite library does not have iconv support.])
208    fi
209    AC_MSG_WARN([You must supply DIR to --with-iconv-include option.
210  Ignored.])
211    ICONVINC=
212    ;;
213*)
214    if test "$liteonly" = yes ; then
215	AC_MSG_ERROR([you can't set iconv options at all when you set value \"yes\" to --enable-liteonly, because lite library does not have iconv support.])
216    fi
217    ICONVINC="-I$iconv_include"
218    ;;
219esac
220
221if test "X$ICONVINC" != X ; then
222    iconv_include="`echo X$ICONVINC | sed -e 's/^X-I//'`"
223    if test ! -f "$iconv_include/iconv.h" ; then
224	AC_MSG_ERROR([iconv.h doesn't exist in $iconv_include])
225    fi
226fi
227
228AC_SUBST(ICONVINC)
229
230iconv=unspec
231AC_ARG_WITH(iconv,
232[  --with-iconv=LIB        special library for iconv []],
233	iconv=$withval)
234case "$iconv" in
235unspec)
236    ;;
237no)
238    ICONVLIB=
239    ;;
240yes)
241    if test "$liteonly" = yes ; then
242	AC_MSG_ERROR([you can't set iconv options at all when you set value \"yes\" to --enable-liteonly, because lite library does not have iconv support.])
243    fi
244    AC_MSG_WARN([You must supply LIB to --with-iconv option.
245  -liconv is assumed.])
246    ICONVLIB=-liconv
247    ;;
248*)
249    if test "$liteonly" = yes ; then
250	AC_MSG_ERROR([you can't set iconv options at all when you set value \"yes\" to --enable-liteonly, because lite library does not have iconv support.])
251    fi
252    ICONVLIB=$iconv
253    ;;
254esac
255AC_SUBST(ICONVLIB)
256
257AC_ARG_WITH(iconv-sofile,
258[  --with-iconv-sofile=PATH  shared library file for libiconv []],
259	iconv_file=$withval, iconv_file=guess)
260ICONVSOFILE=
261case "$iconv_file" in
262no)
263    ICONVSOFILE=none
264    ;;
265yes)
266    if test "$liteonly" = yes ; then
267	AC_MSG_ERROR([you can't set iconv options at all when you set value \"yes\" to --enable-liteonly, because lite library does not have iconv support.])
268    fi
269    AC_MSG_ERROR([You must supply PATH to --with-iconv-sofile option.])
270    ;;
271guess)
272    if test "$liteonly" != yes ; then
273	if test "$ICONVLIB" = ""; then
274	    ICONVSOFILE=none
275	else
276	    AC_MSG_CHECKING(pathname of iconv shared library)
277	    ic_libdir=
278	    ic_libname=
279	    case "$host" in
280	    *-hpux*)
281		SO=sl
282		;;
283	    *)
284		SO=so
285		;;
286	    esac
287	    for arg in $ICONVLIB; do
288		case "$arg" in
289		-L*) ic_libdir="$ic_libdir `echo $arg | sed s/-L//`" ;;
290		-l*) ic_libname=`echo $arg | sed s/-l//` ;;
291		/*.$SO*) ICONVSOFILE=$arg ;;
292		esac
293	    done
294	    if test "$ICONVSOFILE" = ""; then
295		if test "$ic_libname" = ""; then
296		    AC_MSG_RESULT(unknown)
297		    AC_MSG_WARN([use --with-iconv-sofile for specifying iconv shared library file])
298		    ICONVSOFILE=none
299		else
300		    if test "$ic_libdir" = ""; then
301			# Standard (and semi-standard) library directories
302			ic_libdir="/lib /usr/lib /usr/local/lib"
303		    fi
304		    for dir in $ic_libdir; do
305			ICONVSOFILE=`ls -r $dir/lib$ic_libname.$SO* 2>/dev/null | head -1`
306			if test "$ICONVSOFILE" != ""; then
307			    break
308			fi
309		    done
310		    if test "$ICONVSOFILE" != ""; then
311			AC_MSG_RESULT($ICONVSOFILE)
312		    else
313			AC_MSG_RESULT(unknown)
314			AC_MSG_WARN([use --with-iconv-sofile for specifying iconv shared library file])
315			ICONVSOFILE=none
316		    fi
317		fi
318	    fi
319	fi
320    else
321	ICONVSOFILE=none
322    fi
323    ;;
324*)
325    if test "$liteonly" = yes ; then
326	AC_MSG_ERROR([you can't set iconv options at all when you set value \"yes\" to --enable-liteonly, because lite library does not have iconv support.])
327    fi
328    ICONVSOFILE=$iconv_file
329    ;;
330esac
331AC_SUBST(ICONVSOFILE)
332
333dnl Figure out preload stuff.
334PRELOAD_VAR="LD_PRELOAD"
335PRELOAD_SEP=":"
336PRELOAD_LAST=""
337case "$host" in
338*-solaris*)
339    PRELOAD_SEP=" "
340    ;;
341*-linux*)
342    PRELOAD_SEP=" "
343    ;;
344*-osf*)
345    PRELOAD_VAR="_RLD_LIST"
346    PRELOAD_LAST=":DEFAULT"
347    ;;
348*-netbsd*)
349    if test -x /usr/bin/file -a -x /usr/bin/grep ; then
350        case "`/usr/bin/file /usr/bin/grep`" in
351	*ELF*)
352	    PRELOAD_SEP=" "
353	    ;;
354	esac
355    fi
356    ;;
357esac
358
359AC_SUBST(PRELOAD_VAR)
360AC_SUBST(PRELOAD_SEP)
361AC_SUBST(PRELOAD_LAST)
362
363dnl Checks for standard tools.
364AC_PROG_CC
365AC_PROG_INSTALL
366AM_PROG_LIBTOOL
367
368AC_PATH_PROGS(PERL, perl, perl)
369
370dnl Checks for header files.
371AC_CHECK_HEADERS(unistd.h locale.h langinfo.h pwd.h)
372if test "$install_runidn" = yes ; then
373    AC_CHECK_HEADERS(dlfcn.h)
374fi
375
376saved_CPPFLAGS=$CPPFLAGS
377CPPFLAGS="$CPPFLAGS $ICONVINC"
378if test "$liteonly" != yes ; then
379    AC_CHECK_HEADER(iconv.h, , [AC_MSG_ERROR([iconv.h doesn't exist])])
380fi
381CPPFLAGS=$saved_CPPFLAGS
382
383dnl Checks for data types.
384AC_TYPE_UID_T
385dnl for dnsproxy.
386AC_CHECK_TYPE(BOOL, int)
387
388dnl Checks for libraries.
389if test "$install_runidn" = yes ; then
390    AC_CHECK_LIB(socket, socket)
391    AC_CHECK_LIB(nsl, inet_addr)
392    AC_CHECK_LIB(dl, dlopen, [
393	LIBS="-ldl $LIBS"
394	LIBDL="-ldl"
395	AC_DEFINE(HAVE_LIBDL, 1, [Define if you have the dl library (-ldl).])
396	AC_SUBST(LIBDL)
397    ])
398fi
399
400dnl Checks for library functions.
401AC_CHECK_FUNCS(vsnprintf setvbuf setlocale nl_langinfo memmove bcopy setenv \
402    unsetenv)
403if test "$install_runidn" = yes ; then
404    AC_CHECK_FUNCS(gethostbyname gethostbyname2 gethostbyaddr)
405    AC_CHECK_FUNCS(gethostbyname_r gethostbyname2_r gethostbyaddr_r, find_gethost_r=yes)
406    AC_CHECK_FUNCS(getipnodebyname getipnodebyaddr freehostent)
407    AC_CHECK_FUNCS(getaddrinfo freeaddrinfo getnameinfo)
408    AC_CHECK_FUNCS(dlopen dlsym)
409fi
410
411if test "$install_runidn" = yes ; then
412dnl Checks the flavor of gethostbyaddr* functions.
413    AC_CACHE_CHECK(flavor of gethostbyaddr, ac_cv_flavor_gethostbyaddr,
414    [ac_cv_flavor_gethostbyaddr=unknown
415    AC_TRY_RUN(
416    [
417    #include <stddef.h>
418    #include <sys/types.h>
419    #include <sys/socket.h>
420    #include <netdb.h>
421    struct hostent *gethostbyaddr(const void *addr, socklen_t len, int type) {
422	return NULL;
423    }
424    int main() {
425	(void)gethostbyaddr(NULL, 0, 0);
426	return 0;
427    }
428    ], ac_cv_flavor_gethostbyaddr=glibc2_2,,
429       ac_cv_flavor_gethostbyaddr=unknown)
430    AC_TRY_RUN(
431    [
432    #include <stddef.h>
433    #include <sys/types.h>
434    #include <sys/socket.h>
435    #include <netdb.h>
436    struct hostent *gethostbyaddr(const char *addr, size_t len, int type) {
437	return NULL;
438    }
439    int main() {
440	(void)gethostbyaddr(NULL, 0, 0);
441	return 0;
442    }
443    ], ac_cv_flavor_gethostbyaddr=glibc,,
444       ac_cv_flavor_gethostbyaddr=unknown)
445    AC_TRY_RUN(
446    [
447    #include <stddef.h>
448    #include <sys/types.h>
449    #include <sys/socket.h>
450    #include <netdb.h>
451    struct hostent *gethostbyaddr(const char *addr, int len, int type) {
452	return NULL;
453    }
454    int main() {
455	(void)gethostbyaddr(NULL, 0, 0);
456	return 0;
457    }
458    ], ac_cv_flavor_gethostbyaddr=traditional,,
459       ac_cv_flavor_gethostbyaddr=unknown)
460    if test "$ac_cv_func_gethostbyaddr" = no ; then
461	ac_cv_flavor_gethostbyaddr=none
462    fi])
463
464    case "$ac_cv_flavor_gethostbyaddr" in
465    glibc2_2)
466	ac_cv_type_ghba_addr_t='const void *'
467	ac_cv_type_ghba_addrlen_t='socklen_t'
468	;;
469    glibc)
470	ac_cv_type_ghba_addr_t='const char *'
471	ac_cv_type_ghba_addrlen_t='size_t'
472	;;
473    traditional | none)
474	ac_cv_type_ghba_addr_t='const char *'
475	ac_cv_type_ghba_addrlen_t='int'
476	;;
477    *)
478	AC_MSG_ERROR([can't build runidn, since parameter type list of gethostbyaddr() is unknown to configure.])
479	;;
480    esac
481    AC_DEFINE_UNQUOTED(GHBA_ADDR_T, $ac_cv_type_ghba_addr_t,
482	[Define as the type of the 1st argument of gethostbyaddr.])
483    AC_DEFINE_UNQUOTED(GHBA_ADDRLEN_T, $ac_cv_type_ghba_addrlen_t,
484	[Define as the type of the 2nd argument of gethostbyaddr.])
485
486dnl Checks the flavor of getnameinfo functions.
487    AC_CACHE_CHECK(flavor of getnameinfo, ac_cv_flavor_getnameinfo,
488    [ac_cv_flavor_getnameinfo=unknown
489    AC_TRY_RUN(
490    [
491    #include <stddef.h>
492    #include <sys/types.h>
493    #include <sys/socket.h>
494    #include <netdb.h>
495    int getnameinfo(const struct sockaddr *sa, socklen_t salen, char *host,
496                    socklen_t hostlen, char *serv, socklen_t servlen,
497                    unsigned int flags) {
498	return NULL;
499    }
500    int main() {
501	(void)getnameinfo(NULL, 0, NULL, 0, NULL, 0, 0);
502	return 0;
503    }
504    ], ac_cv_flavor_getnameinfo=glibc2_2_2,,
505       ac_cv_flavor_getnameinfo=unknown)
506    AC_TRY_RUN(
507    [
508    #include <stddef.h>
509    #include <sys/types.h>
510    #include <sys/socket.h>
511    #include <netdb.h>
512    int getnameinfo(const struct sockaddr *sa, socklen_t salen, char *host,
513                    socklen_t hostlen, char *serv, socklen_t servlen,
514                    int flags) {
515	return NULL;
516    }
517    int main() {
518	(void)getnameinfo(NULL, 0, NULL, 0, NULL, 0, 0);
519	return 0;
520    }
521    ], ac_cv_flavor_getnameinfo=rfc2553bis_03,,
522       ac_cv_flavor_getnameinfo=unknown)
523    AC_TRY_RUN(
524    [
525    #include <stddef.h>
526    #include <sys/types.h>
527    #include <sys/socket.h>
528    #include <netdb.h>
529    int getnameinfo(const struct sockaddr *sa, socklen_t salen, char *host,
530                    size_t hostlen, char *serv, size_t servlen, int flags) {
531	return NULL;
532    }
533    int main() {
534	(void)getnameinfo(NULL, 0, NULL, 0, NULL, 0, 0);
535	return 0;
536    }
537    ], ac_cv_flavor_getnameinfo=rfc2553,,
538       ac_cv_flavor_getnameinfo=unknown)
539    AC_TRY_RUN(
540    [
541    #include <stddef.h>
542    #include <sys/types.h>
543    #include <sys/socket.h>
544    #include <netdb.h>
545    int getnameinfo(const struct sockaddr *sa, size_t salen, char *host,
546                    size_t hostlen, char *serv, size_t servlen, int flags) {
547	return NULL;
548    }
549    int main() {
550	(void)getnameinfo(NULL, 0, NULL, 0, NULL, 0, 0);
551	return 0;
552    }
553    ], ac_cv_flavor_getnameinfo=rfc2133,,
554       ac_cv_flavor_getnameinfo=unknown)
555    if test "$ac_cv_func_getnameinfo" = no ; then
556	ac_cv_flavor_getnameinfo=none
557    fi])
558
559    case "$ac_cv_flavor_getnameinfo" in
560    glibc2_2_2)
561	ac_cv_type_gni_salen_t='socklen_t'
562	ac_cv_type_gni_hostlen_t='socklen_t'
563	ac_cv_type_gni_servlen_t='socklen_t'
564	ac_cv_type_gni_flags_t='unsigned int'
565	;;
566    rfc2553bis_03)
567	ac_cv_type_gni_salen_t='socklen_t'
568	ac_cv_type_gni_hostlen_t='socklen_t'
569	ac_cv_type_gni_servlen_t='socklen_t'
570	ac_cv_type_gni_flags_t='int'
571	;;
572    rfc2553)
573	ac_cv_type_gni_salen_t='socklen_t'
574	ac_cv_type_gni_hostlen_t='size_t'
575	ac_cv_type_gni_servlen_t='size_t'
576	ac_cv_type_gni_flags_t='int'
577	;;
578    rfc2133 | none)
579	ac_cv_type_gni_salen_t='size_t'
580	ac_cv_type_gni_hostlen_t='size_t'
581	ac_cv_type_gni_servlen_t='size_t'
582	ac_cv_type_gni_flags_t='int'
583	;;
584    *)
585	AC_MSG_ERROR([can't build runidn, since parameter type list of getnameinfo() is unknown to configure.])
586    esac
587    AC_DEFINE_UNQUOTED(GNI_SALEN_T, $ac_cv_type_gni_salen_t,
588	[Define as the type of the 2nd argument of getnameinfo.])
589    AC_DEFINE_UNQUOTED(GNI_HOSTLEN_T, $ac_cv_type_gni_hostlen_t,
590	[Define as the type of the 4th argument of getnameinfo.])
591    AC_DEFINE_UNQUOTED(GNI_SERVLEN_T, $ac_cv_type_gni_servlen_t,
592	[Define as the type of the 6th argument of getnameinfo.])
593    AC_DEFINE_UNQUOTED(GNI_FLAGS_T, $ac_cv_type_gni_flags_t,
594	[Define as the type of the 7th argument of getnameinfo.])
595fi
596
597dnl resume here.
598dnl Checks the flavor of gethost*_r functions.
599if test "$find_gethost_r" = yes; then
600    AC_CACHE_CHECK(flavor of gethostbyname_r, ac_cv_flavor_gethost_r,
601    [AC_TRY_RUN(
602changequote(<<, >>)dnl
603<<
604#include <stddef.h>
605#include <sys/types.h>
606#include <sys/socket.h>
607#include <netdb.h>
608#include <stdio.h>
609int main()
610{
611    int err = 0;
612    struct hostent hebuf, *hp;
613    char buf[10];
614    /* Try resolving a invalid name using glibc flavor. */
615    (void)gethostbyname_r("@#!", &hebuf, buf, sizeof(buf), &hp, &err);
616    if (err != 0)
617	return 0;	/* glibc flavor */
618    else
619	return 1;	/* Sun flavor */
620}
621>>,
622changequote([, ])dnl
623	ac_cv_flavor_gethost_r=glibc,
624	ac_cv_flavor_gethost_r=sun,
625	ac_cv_flavor_gethost_r=sun)])
626    if test "$ac_cv_flavor_gethost_r" = "glibc"; then
627	AC_DEFINE(GETHOST_R_GLIBC_FLAVOR, 1,
628	    [Define if the prototype of gethost*_r is glibc flavor.])
629    fi
630fi
631
632dnl Find system shared object paths.
633AC_FIND_SYSTEM_SHOBJ(libc)
634if test "$install_runidn" = yes ; then
635    AC_FIND_SYSTEM_SHOBJ(libnsl)
636fi
637
638dnl Checks for iconv library.
639if test "$liteonly" != yes ; then
640    AC_MSG_CHECKING(for iconv)
641    saved_CPPFLAGS=$CPPFLAGS
642    saved_LIBS=$LIBS
643    CPPFLAGS="$CPPFLAGS $ICONVINC"
644    LIBS="$LIBS $ICONVLIB"
645    AC_TRY_LINK([
646    #include <iconv.h>
647    ], [
648	iconv_t i;
649	i = iconv_open("ISO-8859-1", "UTF-8");
650    ], [iconv_try_link=yes], [iconv_try_link=no])
651    LIBS=$saved_LIBS
652    CPPFLAGS=$saved_CPPFLAGS
653    AC_MSG_RESULT($iconv_try_link)
654    if test "$iconv_try_link" = no ; then
655	AC_MSG_ERROR(iconv function not available)
656    fi
657fi
658
659dnl Check for codeset name for UTF-8.
660if test "$liteonly" != yes ; then
661    AC_MSG_CHECKING([for codeset name $UTF8_NAME])
662    saved_CPPFLAGS=$CPPFLAGS
663    saved_LIBS=$LIBS
664    CPPFLAGS="$CPPFLAGS $ICONVINC"
665    LIBS="$LIBS $ICONVLIB"
666    AC_TRY_RUN([
667    #include <stddef.h>
668    #include <stdlib.h>
669    #include <iconv.h>
670    #define UTF8_NAME "$UTF8_NAME"
671    #define ICONV_FAIL ((iconv_t)(-1))
672    /* Check if the codeset name UTF8_NAME is valid by performing iconv_open(). */
673    int main() {
674	int i;
675	/* list of codeset names likely to exist */
676	static char *codeset[] = {
677	    "ASCII", "ISO-8859-1", "ISO8859-1", "iso8859_1", "8859-1",
678	    "Shift_JIS", "SJIS", "sjis", NULL,
679	};
680
681	/* First try null conversion. */
682	if (iconv_open(UTF8_NAME, UTF8_NAME) != ICONV_FAIL) return 0;
683
684	/* Unfortunately, above check fails on certain systems, such as Solaris. */
685	for (i = 0; codeset[i] != NULL; i++) {
686	    if (iconv_open(UTF8_NAME, codeset[i]) != ICONV_FAIL) return 0;
687	}
688	return 1;
689    }
690    ], utf8_name_valid=yes, utf8_name_valid=no, utf8_name_valid=unknown)
691    LIBS=$saved_LIBS
692    CPPFLAGS=$saved_CPPFLAGS
693    AC_MSG_RESULT($utf8_name_valid)
694fi
695
696dnl Output.
697AC_CONFIG_HEADER(include/config.h)
698AC_OUTPUT(
699	Makefile
700	include/Makefile
701	include/idn/Makefile
702	include/mdn/Makefile
703	lib/Makefile
704	man/Makefile
705	tools/Makefile
706	tools/idnconv/Makefile
707	tools/runidn/Makefile
708	tools/runidn/runidn
709	map/Makefile
710	lib/tests/Makefile
711)
712