libreplace: replace inet_ntoa() when it is missing
[jelmer/samba4-debian.git] / source / lib / replace / inet_ntoa.m4
1 AC_CHECK_FUNCS(inet_ntoa,[],[LIBREPLACEOBJ="${LIBREPLACEOBJ} inet_ntoa.o"])
2
3 AC_CACHE_CHECK([for broken inet_ntoa],libreplace_cv_REPLACE_INET_NTOA,[
4 AC_TRY_RUN([
5 #include <stdio.h>
6 #include <unistd.h>
7 #include <sys/types.h>
8 #include <netinet/in.h>
9 #ifdef HAVE_ARPA_INET_H
10 #include <arpa/inet.h>
11 #endif
12 main() { struct in_addr ip; ip.s_addr = 0x12345678;
13 if (strcmp(inet_ntoa(ip),"18.52.86.120") &&
14     strcmp(inet_ntoa(ip),"120.86.52.18")) { exit(0); } 
15 exit(1);}],
16            libreplace_cv_REPLACE_INET_NTOA=yes,libreplace_cv_REPLACE_INET_NTOA=no,libreplace_cv_REPLACE_INET_NTOA=cross)])
17 if test x"$libreplace_cv_REPLACE_INET_NTOA" = x"yes"; then
18     AC_DEFINE(REPLACE_INET_NTOA,1,[Whether inet_ntoa should be replaced])
19 fi