configure.ac: Improve C99 compatibility Future compilers will not support implicit declarations and implicit ints by default. This means that configure probes which rely on them will fail unconditionally, without actually testing anything. The changes mostly mirror what has been implemented in the openssh repository, but had to be adapted somewhat because of drift between the two versions of configure.ac. Sam James has submitted similar fixes upstream: diff --git a/configure.ac b/configure.ac index 6496679..d927b62 100644 --- a/configure.ac +++ b/configure.ac @@ -500,10 +500,10 @@ int main(void) { exit(0); } AC_DEFINE(HAVE_BUNDLE, 1, [Define if your system uses bundles instead of ELF shared objects]) AC_MSG_CHECKING(if we have working getaddrinfo) AC_TRY_RUN([#include -main() { if (NSVersionOfRunTimeLibrary("System") >= (60 << 16)) - exit(0); +int main(void) { if (NSVersionOfRunTimeLibrary("System") >= (60 << 16)) + return 0; else - exit(1); + return 1; }], [AC_MSG_RESULT(working)], [AC_MSG_RESULT(buggy) AC_DEFINE(BROKEN_GETADDRINFO, 1, [getaddrinfo is broken (if present)])], @@ -917,8 +917,8 @@ AC_SUBST(LDFLAGS_SHARED) AC_MSG_CHECKING(compiler and flags for sanity) AC_RUN_IFELSE( [AC_LANG_SOURCE([ -#include -int main(){exit(0);} +#include +int main(void){exit(0);} ])], [ AC_MSG_RESULT(yes) ], [ @@ -951,9 +951,9 @@ int main(int argc, char **argv) { strncpy(buf,"/etc", 32); s = dirname(buf); if (!s || strncmp(s, "/", 32) != 0) { - exit(1); + return 1; } else { - exit(0); + return 0; } } ]])], @@ -1102,7 +1102,7 @@ AC_RUN_IFELSE( [AC_LANG_SOURCE([[ #include #include -int main(void){struct dirent d;exit(sizeof(d.d_name)<=sizeof(char));} +int main(void){struct dirent d;return sizeof(d.d_name)<=sizeof(char);} ]])], [AC_MSG_RESULT(yes)], [ @@ -1327,8 +1327,10 @@ AC_CHECK_FUNCS(setresuid, [ AC_MSG_CHECKING(if setresuid seems to work) AC_RUN_IFELSE( [AC_LANG_SOURCE([[ +#define _GNU_SOURCE #include #include +#include int main(){errno=0; setresuid(0,0,0); if (errno==ENOSYS) exit(1); else exit(0);} ]])], [AC_MSG_RESULT(yes)], @@ -1344,8 +1346,10 @@ AC_CHECK_FUNCS(setresgid, [ AC_MSG_CHECKING(if setresgid seems to work) AC_RUN_IFELSE( [AC_LANG_SOURCE([[ +#define _GNU_SOURCE #include #include +#include int main(){errno=0; setresgid(0,0,0); if (errno==ENOSYS) exit(1); else exit(0);} ]])], [AC_MSG_RESULT(yes)], @@ -1384,7 +1388,7 @@ if test "x$ac_cv_func_snprintf" = "xyes" ; then AC_RUN_IFELSE( [AC_LANG_SOURCE([[ #include -int main(void){char b[5];snprintf(b,5,"123456789");exit(b[4]!='\0');} +int main(void){char b[5];snprintf(b,5,"123456789");return b[4]!='\0';} ]])], [AC_MSG_RESULT(yes)], [ @@ -1418,7 +1422,7 @@ int x_snprintf(char *str,size_t count,const char *fmt,...) int main(void) { char x[1]; - exit(x_snprintf(x, 1, "%s %d", "hello", 12345) == 11 ? 0 : 1); + return x_snprintf(x, 1, "%s %d", "hello", 12345) == 11 ? 0 : 1; } ]])], [AC_MSG_RESULT(yes)], [ @@ -1467,7 +1471,8 @@ AC_MSG_CHECKING([for (overly) strict mkstemp]) AC_RUN_IFELSE( [AC_LANG_SOURCE([[ #include -main() { char template[]="conftest.mkstemp-test"; +#include +int main(void) { char template[]="conftest.mkstemp-test"; if (mkstemp(template) == -1) exit(1); unlink(template); exit(0); @@ -1492,10 +1497,14 @@ if test ! -z "$check_for_openpty_ctty_bug"; then AC_MSG_CHECKING(if openpty correctly handles controlling tty) AC_RUN_IFELSE( [AC_LANG_SOURCE([[ +#include #include #include #include #include +#ifdef HAVE_PTY_H +#include +#endif int main() @@ -1543,6 +1552,7 @@ if test "x$ac_cv_func_getaddrinfo" = "xyes" && \ AC_RUN_IFELSE( [AC_LANG_SOURCE([[ #include +#include #include #include #include @@ -1748,6 +1758,7 @@ AC_TRY_LINK_FUNC(RAND_add, AC_DEFINE(HAVE_OPENSSL, 1, AC_MSG_CHECKING([OpenSSL header version]) AC_RUN_IFELSE( [AC_LANG_SOURCE([[ +#include #include #include #include @@ -1794,12 +1805,12 @@ int main(void) { fd = fopen(DATA,"w"); if(fd == NULL) - exit(1); + return 1; if ((rc = fprintf(fd ,"%x (%s)\n", SSLeay(), SSLeay_version(SSLEAY_VERSION))) <0) - exit(1); + return 1; - exit(0); + return 0; } ]])], [ @@ -1829,7 +1840,7 @@ AC_RUN_IFELSE( [AC_LANG_SOURCE([[ #include #include -int main(void) { exit(SSLeay() == OPENSSL_VERSION_NUMBER ? 0 : 1); } +int main(void) { return SSLeay() == OPENSSL_VERSION_NUMBER ? 0 : 1; } ]])], [ AC_MSG_RESULT(yes) @@ -2598,7 +2609,7 @@ dnl test snprintf (broken on SCO w/gcc) #include #include #ifdef HAVE_SNPRINTF -main() +int main(void) { char buf[50]; char expected_out[50]; @@ -2611,11 +2622,11 @@ main() strcpy(expected_out, "9223372036854775807"); snprintf(buf, mazsize, "%lld", num); if(strcmp(buf, expected_out) != 0) - exit(1); - exit(0); + return 1; + return 0; } #else -main() { exit(0); } +int main(void) { return 0; } #endif ]])], [ true ], [ AC_DEFINE(BROKEN_SNPRINTF) ], AC_MSG_WARN([cross compiling: Assuming working snprintf()]) @@ -2746,11 +2757,11 @@ AC_CACHE_CHECK([for msg_accrights field in struct msghdr], int main() { #ifdef msg_accrights #error "msg_accrights is a macro" -exit(1); +return 1; #endif struct msghdr m; m.msg_accrights = 0; -exit(0); +return 0; } ])], [ ac_cv_have_accrights_in_msghdr="yes" ], @@ -2773,11 +2784,11 @@ AC_CACHE_CHECK([for msg_control field in struct msghdr], int main() { #ifdef msg_control #error "msg_control is a macro" -exit(1); +return 1; #endif struct msghdr m; m.msg_control = 0; -exit(0); +return 0; } ])], [ ac_cv_have_control_in_msghdr="yes" ], @@ -2791,7 +2802,7 @@ if test "x$ac_cv_have_control_in_msghdr" = "xyes" ; then fi AC_CACHE_CHECK([if libc defines __progname], ac_cv_libc_defines___progname, [ - AC_TRY_LINK([], + AC_TRY_LINK([#include ], [ extern char *__progname; printf("%s", __progname); ], [ ac_cv_libc_defines___progname="yes" ], [ ac_cv_libc_defines___progname="no" ] @@ -2871,7 +2882,7 @@ if test "x$ac_cv_have_getopt_optreset" = "xyes" ; then fi AC_CACHE_CHECK([if libc defines sys_errlist], ac_cv_libc_defines_sys_errlist, [ - AC_TRY_LINK([], + AC_TRY_LINK([#include ], [ extern const char *const sys_errlist[]; printf("%s", sys_errlist[0]);], [ ac_cv_libc_defines_sys_errlist="yes" ], [ ac_cv_libc_defines_sys_errlist="no" ] @@ -2884,7 +2895,7 @@ fi AC_CACHE_CHECK([if libc defines sys_nerr], ac_cv_libc_defines_sys_nerr, [ - AC_TRY_LINK([], + AC_TRY_LINK([#include ], [ extern int sys_nerr; printf("%i", sys_nerr);], [ ac_cv_libc_defines_sys_nerr="yes" ], [ ac_cv_libc_defines_sys_nerr="no" ]