diff --git a/configure.in b/configure.in index ca270af93..6fddf13ae 100644 --- a/configure.in +++ b/configure.in @@ -26,14 +26,230 @@ dnl The install stuff has already been taken care of by the automake stuff dnl AC_PROG_INSTALL AC_PROG_MAKE_SET +AC_DEFUN(CURL_CHECK_LOCALTIME_R, +[ + dnl check for a few thread-safe functions + AC_CHECK_FUNCS(localtime_r,[ + AC_MSG_CHECKING(whether localtime_r is declared) + AC_EGREP_CPP(localtime_r,[ +#include ],[ + AC_MSG_RESULT(yes)],[ + AC_MSG_RESULT(no) + AC_MSG_CHECKING(whether localtime_r with -D_REENTRANT is declared) + AC_EGREP_CPP(localtime_r,[ +#define _REENTRANT +#include ],[ + AC_DEFINE(NEED_REENTRANT) + AC_MSG_RESULT(yes)], + AC_MSG_RESULT(no))])]) +]) + +AC_DEFUN(CURL_CHECK_INET_NTOA_R, +[ + dnl determine if function definition for inet_ntoa_r exists. + AC_CHECK_FUNCS(inet_ntoa_r,[ + AC_MSG_CHECKING(whether inet_ntoa_r is declared) + AC_EGREP_CPP(inet_ntoa_r,[ +#include ],[ + AC_DEFINE(HAVE_INET_NTOA_R_DECL) + AC_MSG_RESULT(yes)],[ + AC_MSG_RESULT(no) + AC_MSG_CHECKING(whether inet_ntoa_r with -D_REENTRANT is declared) + AC_EGREP_CPP(inet_ntoa_r,[ +#define _REENTRANT +#include ],[ + AC_DEFINE(HAVE_INET_NTOA_R_DECL) + AC_DEFINE(NEED_REENTRANT) + AC_MSG_RESULT(yes)], + AC_MSG_RESULT(no))])]) + +]) + +AC_DEFUN(CURL_CHECK_GETHOSTBYADDR_R, +[ + dnl check for number of arguments to gethostbyaddr_r. it might take + dnl either 5, 7, or 8 arguments. + AC_CHECK_FUNCS(gethostbyaddr_r,[ + AC_MSG_CHECKING(if gethostbyaddr_r takes 5 arguments) + AC_TRY_COMPILE([ +#include +#include ],[ +char * address; +int length; +int type; +struct hostent h; +struct hostent_data hdata; +int rc; +rc = gethostbyaddr_r(address, length, type, &h, &hdata);],[ + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_GETHOSTBYADDR_R_5) + ac_cv_gethostbyaddr_args=5],[ + AC_MSG_RESULT(no) + AC_MSG_CHECKING(if gethostbyaddr_r with -D_REENTRANT takes 5 arguments) + AC_TRY_COMPILE([ +#define _REENTRANT +#include +#include ],[ +char * address; +int length; +int type; +struct hostent h; +struct hostent_data hdata; +int rc; +rc = gethostbyaddr_r(address, length, type, &h, &hdata);],[ + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_GETHOSTBYADDR_R_5) + AC_DEFINE(NEED_REENTRANT) + ac_cv_gethostbyaddr_args=5],[ + AC_MSG_RESULT(no) + AC_MSG_CHECKING(if gethostbyaddr_r takes 7 arguments) + AC_TRY_COMPILE([ +#include +#include ],[ +char * address; +int length; +int type; +struct hostent h; +char buffer[8192]; +int h_errnop; +struct hostent * hp; + +hp = gethostbyaddr_r(address, length, type, &h, + buffer, 8192, &h_errnop);],[ + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_GETHOSTBYADDR_R_7) + ac_cv_gethostbyaddr_args=7],[ + AC_MSG_RESULT(no) + AC_MSG_CHECKING(if gethostbyaddr_r takes 8 arguments) + AC_TRY_COMPILE([ +#include +#include ],[ +char * address; +int length; +int type; +struct hostent h; +char buffer[8192]; +int h_errnop; +struct hostent * hp; +int rc; + +rc = gethostbyaddr_r(address, length, type, &h, + buffer, 8192, &hp, &h_errnop);],[ + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_GETHOSTBYADDR_R_8) + ac_cv_gethostbyaddr_args=8],[ + AC_MSG_RESULT(no) + have_missing_r_funcs="$have_missing_r_funcs gethostbyaddr_r"])])])])]) + + +]) + +AC_DEFUN(CURL_CHECK_GETHOSTBYNAME_R, +[ + dnl check for number of arguments to gethostbyname_r. it might take + dnl either 3, 5, or 6 arguments. + AC_CHECK_FUNCS(gethostbyname_r,[ + AC_MSG_CHECKING(if gethostbyname_r takes 3 arguments) + AC_TRY_RUN([ +#include +#include +#include + +int +main () { +struct hostent h; +struct hostent_data hdata; +char *name = "localhost"; +int rc; +memset(&h, 0, sizeof(struct hostent)); +memset(&hdata, 0, sizeof(struct hostent_data)); +rc = gethostbyname_r(name, &h, &hdata); +exit (rc != 0 ? 1 : 0); }],[ + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_GETHOSTBYNAME_R_3) + ac_cv_gethostbyname_args=3],[ + AC_MSG_RESULT(no) + AC_MSG_CHECKING(if gethostbyname_r with -D_REENTRANT takes 3 arguments) + AC_TRY_RUN([ +#define _REENTRANT + +#include +#include +#include + +int +main () { +struct hostent h; +struct hostent_data hdata; +char *name = "localhost"; +int rc; +memset(&h, 0, sizeof(struct hostent)); +memset(&hdata, 0, sizeof(struct hostent_data)); +rc = gethostbyname_r(name, &h, &hdata); +exit (rc != 0 ? 1 : 0); }],[ + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_GETHOSTBYNAME_R_3) + AC_DEFINE(NEED_REENTRANT) + ac_cv_gethostbyname_args=3],[ + AC_MSG_RESULT(no) + AC_MSG_CHECKING(if gethostbyname_r takes 5 arguments) + AC_TRY_RUN([ +#include +#include + +int +main () { +struct hostent *hp; +struct hostent h; +char *name = "localhost"; +char buffer[8192]; +int h_errno; +hp = gethostbyname_r(name, &h, buffer, 8192, &h_errno); +exit (hp == NULL ? 1 : 0); }],[ + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_GETHOSTBYNAME_R_5) + ac_cv_gethostbyname_args=5],[ + AC_MSG_RESULT(no) + AC_MSG_CHECKING(if gethostbyname_r takes 6 arguments) + AC_TRY_RUN([ +#include +#include + +int +main () { +struct hostent h; +struct hostent *hp; +char *name = "localhost"; +char buf[8192]; +int rc; +int h_errno; +rc = gethostbyname_r(name, &h, buf, 8192, &hp, &h_errno); +exit (rc != 0 ? 1 : 0); }],[ + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_GETHOSTBYNAME_R_6) + ac_cv_gethostbyname_args=6],[ + AC_MSG_RESULT(no) + have_missing_r_funcs="$have_missing_r_funcs gethostbyname_r"], + [ac_cv_gethostbyname_args=0])], + [ac_cv_gethostbyname_args=0])], + [ac_cv_gethostbyname_args=0])], + [ac_cv_gethostbyname_args=0])]) + +]) + dnl ********************************************************************** dnl Checks for libraries. dnl ********************************************************************** -dnl nsl lib? +dnl gethostbyname in the nsl lib? AC_CHECK_FUNC(gethostbyname, , AC_CHECK_LIB(nsl, gethostbyname)) +if test "$ac_cv_lib_nsl_gethostbyname" != "yes" -a "$ac_cv_func_gethostbyname" != "yes"; then + dnl gethostbyname in the socket lib? + AC_CHECK_FUNC(gethostbyname, , AC_CHECK_LIB(socket, gethostbyname)) +fi + dnl At least one system has been identified to require BOTH nsl and dnl socket libs to link properly. if test "$ac_cv_lib_nsl_gethostbyname" = "$ac_cv_func_gethostbyname"; then @@ -256,200 +472,19 @@ then AC_DEFINE(DISABLED_THREADSAFE, 1, \ Set to explicitly specify we don't want to use thread-safe functions) else - dnl check for number of arguments to gethostbyname_r. it might take - dnl either 3, 5, or 6 arguments. - AC_CHECK_FUNCS(gethostbyname_r,[ - AC_MSG_CHECKING(if gethostbyname_r takes 3 arguments) - AC_TRY_RUN([ -#include -#include -#include -int -main () { -struct hostent h; -struct hostent_data hdata; -char *name = "localhost"; -int rc; -memset(&h, 0, sizeof(struct hostent)); -memset(&hdata, 0, sizeof(struct hostent_data)); -rc = gethostbyname_r(name, &h, &hdata); -exit (rc != 0 ? 1 : 0); }],[ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_GETHOSTBYNAME_R_3) - ac_cv_gethostbyname_args=3],[ - AC_MSG_RESULT(no) - AC_MSG_CHECKING(if gethostbyname_r with -D_REENTRANT takes 3 arguments) - AC_TRY_RUN([ -#define _REENTRANT + dnl dig around for gethostbyname_r() + CURL_CHECK_GETHOSTBYNAME_R() -#include -#include -#include + dnl dig around for gethostbyaddr_r() + CURL_CHECK_GETHOSTBYADDR_R() -int -main () { -struct hostent h; -struct hostent_data hdata; -char *name = "localhost"; -int rc; -memset(&h, 0, sizeof(struct hostent)); -memset(&hdata, 0, sizeof(struct hostent_data)); -rc = gethostbyname_r(name, &h, &hdata); -exit (rc != 0 ? 1 : 0); }],[ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_GETHOSTBYNAME_R_3) - AC_DEFINE(NEED_REENTRANT) - ac_cv_gethostbyname_args=3],[ - AC_MSG_RESULT(no) - AC_MSG_CHECKING(if gethostbyname_r takes 5 arguments) - AC_TRY_RUN([ -#include -#include + dnl poke around for inet_ntoa_r() + CURL_CHECK_INET_NTOA_R() -int -main () { -struct hostent *hp; -struct hostent h; -char *name = "localhost"; -char buffer[8192]; -int h_errno; -hp = gethostbyname_r(name, &h, buffer, 8192, &h_errno); -exit (hp == NULL ? 1 : 0); }],[ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_GETHOSTBYNAME_R_5) - ac_cv_gethostbyname_args=5],[ - AC_MSG_RESULT(no) - AC_MSG_CHECKING(if gethostbyname_r takes 6 arguments) - AC_TRY_RUN([ -#include -#include + dnl is there a localtime_r() + CURL_CHECK_LOCALTIME_R() -int -main () { -struct hostent h; -struct hostent *hp; -char *name = "localhost"; -char buf[8192]; -int rc; -int h_errno; -rc = gethostbyname_r(name, &h, buf, 8192, &hp, &h_errno); -exit (rc != 0 ? 1 : 0); }],[ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_GETHOSTBYNAME_R_6) - ac_cv_gethostbyname_args=6],[ - AC_MSG_RESULT(no) - have_missing_r_funcs="$have_missing_r_funcs gethostbyname_r"], - [ac_cv_gethostbyname_args=0])], - [ac_cv_gethostbyname_args=0])], - [ac_cv_gethostbyname_args=0])], - [ac_cv_gethostbyname_args=0])]) - - dnl check for number of arguments to gethostbyaddr_r. it might take - dnl either 5, 7, or 8 arguments. - AC_CHECK_FUNCS(gethostbyaddr_r,[ - AC_MSG_CHECKING(if gethostbyaddr_r takes 5 arguments) - AC_TRY_COMPILE([ -#include -#include ],[ -char * address; -int length; -int type; -struct hostent h; -struct hostent_data hdata; -int rc; -rc = gethostbyaddr_r(address, length, type, &h, &hdata);],[ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_GETHOSTBYADDR_R_5) - ac_cv_gethostbyaddr_args=5],[ - AC_MSG_RESULT(no) - AC_MSG_CHECKING(if gethostbyaddr_r with -D_REENTRANT takes 5 arguments) - AC_TRY_COMPILE([ -#define _REENTRANT -#include -#include ],[ -char * address; -int length; -int type; -struct hostent h; -struct hostent_data hdata; -int rc; -rc = gethostbyaddr_r(address, length, type, &h, &hdata);],[ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_GETHOSTBYADDR_R_5) - AC_DEFINE(NEED_REENTRANT) - ac_cv_gethostbyaddr_args=5],[ - AC_MSG_RESULT(no) - AC_MSG_CHECKING(if gethostbyaddr_r takes 7 arguments) - AC_TRY_COMPILE([ -#include -#include ],[ -char * address; -int length; -int type; -struct hostent h; -char buffer[8192]; -int h_errnop; -struct hostent * hp; - -hp = gethostbyaddr_r(address, length, type, &h, - buffer, 8192, &h_errnop);],[ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_GETHOSTBYADDR_R_7) - ac_cv_gethostbyaddr_args=7],[ - AC_MSG_RESULT(no) - AC_MSG_CHECKING(if gethostbyaddr_r takes 8 arguments) - AC_TRY_COMPILE([ -#include -#include ],[ -char * address; -int length; -int type; -struct hostent h; -char buffer[8192]; -int h_errnop; -struct hostent * hp; -int rc; - -rc = gethostbyaddr_r(address, length, type, &h, - buffer, 8192, &hp, &h_errnop);],[ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_GETHOSTBYADDR_R_8) - ac_cv_gethostbyaddr_args=8],[ - AC_MSG_RESULT(no) - have_missing_r_funcs="$have_missing_r_funcs gethostbyaddr_r"])])])])]) - - dnl determine if function definition for inet_ntoa_r exists. - AC_CHECK_FUNCS(inet_ntoa_r,[ - AC_MSG_CHECKING(whether inet_ntoa_r is declared) - AC_EGREP_CPP(inet_ntoa_r,[ -#include ],[ - AC_DEFINE(HAVE_INET_NTOA_R_DECL) - AC_MSG_RESULT(yes)],[ - AC_MSG_RESULT(no) - AC_MSG_CHECKING(whether inet_ntoa_r with -D_REENTRANT is declared) - AC_EGREP_CPP(inet_ntoa_r,[ -#define _REENTRANT -#include ],[ - AC_DEFINE(HAVE_INET_NTOA_R_DECL) - AC_DEFINE(NEED_REENTRANT) - AC_MSG_RESULT(yes)], - AC_MSG_RESULT(no))])]) - - dnl check for a few thread-safe functions - AC_CHECK_FUNCS(localtime_r,[ - AC_MSG_CHECKING(whether localtime_r is declared) - AC_EGREP_CPP(localtime_r,[ -#include ],[ - AC_MSG_RESULT(yes)],[ - AC_MSG_RESULT(no) - AC_MSG_CHECKING(whether localtime_r with -D_REENTRANT is declared) - AC_EGREP_CPP(localtime_r,[ -#define _REENTRANT -#include ],[ - AC_DEFINE(NEED_REENTRANT) - AC_MSG_RESULT(yes)], - AC_MSG_RESULT(no))])]) fi dnl **********************************************************************