[c5c522c] | 1 | # $Id: dspam_functions.m4,v 1.0 2009/06/10 22:00:31 sbajic Exp $ |
---|
| 2 | # m4/dspam_functions.m4 |
---|
| 3 | # Stevan Bajic <stevan@bajic.ch> |
---|
| 4 | # |
---|
| 5 | # Various m4 macros |
---|
| 6 | # |
---|
| 7 | # |
---|
| 8 | |
---|
| 9 | dnl DS_INCLUDES_ARPA_INET |
---|
| 10 | dnl ------------------------------------------------- |
---|
| 11 | dnl Set up variable with list of headers that must be |
---|
| 12 | dnl included when arpa/inet.h is to be included. |
---|
| 13 | |
---|
| 14 | AC_DEFUN([DS_INCLUDES_ARPA_INET], |
---|
| 15 | [ |
---|
| 16 | ds_includes_arpa_inet="\ |
---|
| 17 | /* includes start */ |
---|
| 18 | #ifdef HAVE_SYS_TYPES_H |
---|
| 19 | # include <sys/types.h> |
---|
| 20 | #endif |
---|
| 21 | #ifdef HAVE_SYS_SOCKET_H |
---|
| 22 | # include <sys/socket.h> |
---|
| 23 | #endif |
---|
| 24 | #ifdef HAVE_NETINET_IN_H |
---|
| 25 | # include <netinet/in.h> |
---|
| 26 | #endif |
---|
| 27 | #ifdef HAVE_ARPA_INET_H |
---|
| 28 | # include <arpa/inet.h> |
---|
| 29 | #endif |
---|
| 30 | /* includes end */" |
---|
| 31 | AC_CHECK_HEADERS( |
---|
| 32 | sys/types.h sys/socket.h netinet/in.h arpa/inet.h, |
---|
| 33 | [], [], [$ds_includes_arpa_inet]) |
---|
| 34 | ]) |
---|
| 35 | |
---|
| 36 | |
---|
| 37 | dnl DS_CHECK_FUNC_INET_NTOA_R |
---|
| 38 | dnl ------------------------------------------------- |
---|
| 39 | dnl Verify if inet_ntoa_r is available, prototyped, |
---|
| 40 | dnl can be compiled and the count of arguments used. |
---|
| 41 | |
---|
| 42 | AC_DEFUN([DS_CHECK_FUNC_INET_NTOA_R], |
---|
| 43 | [ |
---|
| 44 | AC_REQUIRE([DS_INCLUDES_ARPA_INET])dnl |
---|
| 45 | # |
---|
| 46 | test_prototyped_inet_ntoa_r="unknown" |
---|
| 47 | test_compiles_inet_ntoa_r="unknown" |
---|
| 48 | test_number_of_arguments_inet_ntoa_r="unknown" |
---|
| 49 | # |
---|
| 50 | AC_CHECK_FUNCS(inet_ntoa_r) |
---|
| 51 | # |
---|
| 52 | if test "$ac_cv_func_inet_ntoa_r" = "yes"; then |
---|
| 53 | AC_MSG_CHECKING([if inet_ntoa_r is prototyped]) |
---|
| 54 | AC_EGREP_CPP([inet_ntoa_r],[ |
---|
| 55 | $ds_includes_arpa_inet |
---|
| 56 | ],[ |
---|
| 57 | AC_MSG_RESULT([yes]) |
---|
| 58 | test_prototyped_inet_ntoa_r="yes" |
---|
| 59 | ],[ |
---|
| 60 | AC_MSG_RESULT([no]) |
---|
| 61 | test_prototyped_inet_ntoa_r="no" |
---|
| 62 | ]) |
---|
| 63 | fi |
---|
| 64 | # |
---|
| 65 | if test "$test_prototyped_inet_ntoa_r" = "yes"; then |
---|
| 66 | if test "$test_number_of_arguments_inet_ntoa_r" = "unknown"; then |
---|
| 67 | AC_MSG_CHECKING([if inet_ntoa_r takes 2 args.]) |
---|
| 68 | AC_COMPILE_IFELSE([ |
---|
| 69 | AC_LANG_PROGRAM([[ |
---|
| 70 | $ds_includes_arpa_inet |
---|
| 71 | ]],[[ |
---|
| 72 | struct in_addr addr; |
---|
| 73 | if(0 != inet_ntoa_r(addr, 0)) |
---|
| 74 | return 1; |
---|
| 75 | ]]) |
---|
| 76 | ],[ |
---|
| 77 | AC_MSG_RESULT([yes]) |
---|
| 78 | test_compiles_inet_ntoa_r="yes" |
---|
| 79 | test_number_of_arguments_inet_ntoa_r="2" |
---|
| 80 | ],[ |
---|
| 81 | AC_MSG_RESULT([no]) |
---|
| 82 | test_compiles_inet_ntoa_r="no" |
---|
| 83 | ]) |
---|
| 84 | fi |
---|
| 85 | if test "$test_number_of_arguments_inet_ntoa_r" = "unknown"; then |
---|
| 86 | AC_MSG_CHECKING([if inet_ntoa_r takes 3 args.]) |
---|
| 87 | AC_COMPILE_IFELSE([ |
---|
| 88 | AC_LANG_PROGRAM([[ |
---|
| 89 | $ds_includes_arpa_inet |
---|
| 90 | ]],[[ |
---|
| 91 | struct in_addr addr; |
---|
| 92 | if(0 != inet_ntoa_r(addr, 0, 0)) |
---|
| 93 | return 1; |
---|
| 94 | ]]) |
---|
| 95 | ],[ |
---|
| 96 | AC_MSG_RESULT([yes]) |
---|
| 97 | test_compiles_inet_ntoa_r="yes" |
---|
| 98 | test_number_of_arguments_inet_ntoa_r="3" |
---|
| 99 | ],[ |
---|
| 100 | AC_MSG_RESULT([no]) |
---|
| 101 | test_compiles_inet_ntoa_r="no" |
---|
| 102 | ]) |
---|
| 103 | fi |
---|
| 104 | AC_MSG_CHECKING([if inet_ntoa_r is compilable]) |
---|
| 105 | if test "$test_compiles_inet_ntoa_r" = "yes"; then |
---|
| 106 | AC_MSG_RESULT([yes]) |
---|
| 107 | else |
---|
| 108 | AC_MSG_RESULT([no]) |
---|
| 109 | fi |
---|
| 110 | fi |
---|
| 111 | # |
---|
| 112 | AC_MSG_CHECKING([if inet_ntoa_r might be used]) |
---|
| 113 | if test "$test_prototyped_inet_ntoa_r" = "yes" && |
---|
| 114 | test "$test_compiles_inet_ntoa_r" = "yes"; then |
---|
| 115 | AC_MSG_RESULT([yes]) |
---|
| 116 | AC_DEFINE_UNQUOTED(HAVE_INET_NTOA_R, 1, |
---|
| 117 | [Define to 1 if you have the inet_ntoa_r function.]) |
---|
| 118 | dnl AC_DEFINE_UNQUOTED(INET_NTOA_R_ARGS, $test_number_of_arguments_inet_ntoa_r, |
---|
| 119 | dnl [Specifies the number of arguments to inet_ntoa_r]) |
---|
| 120 | # |
---|
| 121 | if test "$test_number_of_arguments_inet_ntoa_r" -eq "2"; then |
---|
| 122 | AC_DEFINE(HAVE_INET_NTOA_R_2, 1, [inet_ntoa_r() takes 2 args]) |
---|
| 123 | elif test "$test_number_of_arguments_inet_ntoa_r" -eq "3"; then |
---|
| 124 | AC_DEFINE(HAVE_INET_NTOA_R_3, 1, [inet_ntoa_r() takes 3 args]) |
---|
| 125 | fi |
---|
| 126 | # |
---|
| 127 | ac_cv_func_inet_ntoa_r="yes" |
---|
| 128 | else |
---|
| 129 | AC_MSG_RESULT([no]) |
---|
| 130 | ac_cv_func_inet_ntoa_r="no" |
---|
| 131 | fi |
---|
| 132 | ]) |
---|