- (dtucker) [configure.ac] Bug #321: Add cross-compile support to configure.
Parts by chua at ayrnetworks.com, astrand at lysator.liu.se and me. ok djm@
diff --git a/ChangeLog b/ChangeLog
index 268e0f9..750751f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -11,6 +11,8 @@
SSH2_MSG_USERAUTH_BANNER messages. Note that this will not happen with
SSH2 kbdint authentication, which need to be dealt with separately. ok djm@
- (dtucker) [session.c] Bug #927: make .hushlogin silent again. ok djm@
+ - (dtucker) [configure.ac] Bug #321: Add cross-compile support to configure.
+ Parts by chua at ayrnetworks.com, astrand at lysator.liu.se and me. ok djm@
20040830
- (dtucker) [session.c openbsd-compat/bsd-cygwin_util.{c,h}] Bug #915: only
@@ -1730,4 +1732,4 @@
- (djm) Trim deprecated options from INSTALL. Mention UsePAM
- (djm) Fix quote handling in sftp; Patch from admorten AT umich.edu
-$Id: ChangeLog,v 1.3545 2004/09/11 13:09:53 dtucker Exp $
+$Id: ChangeLog,v 1.3546 2004/09/11 13:26:37 dtucker Exp $
diff --git a/configure.ac b/configure.ac
index 85d46f3..9b80c6a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,4 +1,4 @@
-# $Id: configure.ac,v 1.228 2004/08/29 11:18:09 dtucker Exp $
+# $Id: configure.ac,v 1.229 2004/09/11 13:26:37 dtucker Exp $
#
# Copyright (c) 1999-2004 Damien Miller
#
@@ -506,7 +506,7 @@
)
AC_MSG_CHECKING(compiler and flags for sanity)
-AC_TRY_RUN([
+AC_RUN_IFELSE([
#include <stdio.h>
int main(){exit(0);}
],
@@ -514,7 +514,8 @@
[
AC_MSG_RESULT(no)
AC_MSG_ERROR([*** compiler cannot create working executables, check config.log ***])
- ]
+ ],
+ [ AC_MSG_WARN([cross compiling: not checking compiler sanity]) ]
)
# Checks for header files.
@@ -647,7 +648,7 @@
)
AC_MSG_CHECKING(for zlib 1.1.4 or greater)
-AC_TRY_RUN([
+AC_RUN_IFELSE([
#include <zlib.h>
int main()
{
@@ -672,7 +673,8 @@
else
AC_MSG_WARN([zlib version may have security problems])
fi
- ]
+ ],
+ [ AC_MSG_WARN([cross compiling: not checking zlib version]) ]
)
dnl UnixWare 2.x
@@ -726,7 +728,7 @@
)
AC_MSG_CHECKING([whether struct dirent allocates space for d_name])
-AC_TRY_RUN(
+AC_RUN_IFELSE(
[
#include <sys/types.h>
#include <dirent.h>
@@ -736,6 +738,10 @@
[
AC_MSG_RESULT(no)
AC_DEFINE(BROKEN_ONE_BYTE_DIRENT_D_NAME)
+ ],
+ [
+ AC_MSG_WARN([cross compiling: assuming BROKEN_ONE_BYTE_DIRENT_D_NAME])
+ AC_DEFINE(BROKEN_ONE_BYTE_DIRENT_D_NAME)
]
)
@@ -895,28 +901,30 @@
AC_CHECK_FUNCS(setresuid, [
dnl Some platorms have setresuid that isn't implemented, test for this
AC_MSG_CHECKING(if setresuid seems to work)
- AC_TRY_RUN([
+ AC_RUN_IFELSE([
#include <stdlib.h>
#include <errno.h>
int main(){errno=0; setresuid(0,0,0); if (errno==ENOSYS) exit(1); else exit(0);}
],
[AC_MSG_RESULT(yes)],
[AC_DEFINE(BROKEN_SETRESUID)
- AC_MSG_RESULT(not implemented)]
+ AC_MSG_RESULT(not implemented)],
+ [AC_MSG_WARN([cross compiling: not checking setresuid])]
)
])
AC_CHECK_FUNCS(setresgid, [
dnl Some platorms have setresgid that isn't implemented, test for this
AC_MSG_CHECKING(if setresgid seems to work)
- AC_TRY_RUN([
+ AC_RUN_IFELSE([
#include <stdlib.h>
#include <errno.h>
int main(){errno=0; setresgid(0,0,0); if (errno==ENOSYS) exit(1); else exit(0);}
],
[AC_MSG_RESULT(yes)],
[AC_DEFINE(BROKEN_SETRESGID)
- AC_MSG_RESULT(not implemented)]
+ AC_MSG_RESULT(not implemented)],
+ [AC_MSG_WARN([cross compiling: not checking setresuid])]
)
])
@@ -942,7 +950,7 @@
# Check for broken snprintf
if test "x$ac_cv_func_snprintf" = "xyes" ; then
AC_MSG_CHECKING([whether snprintf correctly terminates long strings])
- AC_TRY_RUN(
+ AC_RUN_IFELSE(
[
#include <stdio.h>
int main(void){char b[5];snprintf(b,5,"123456789");exit(b[4]!='\0');}
@@ -952,7 +960,8 @@
AC_MSG_RESULT(no)
AC_DEFINE(BROKEN_SNPRINTF)
AC_MSG_WARN([****** Your snprintf() function is broken, complain to your vendor])
- ]
+ ],
+ [ AC_MSG_WARN([cross compiling: Assuming working snprintf()]) ]
)
fi
@@ -1213,7 +1222,7 @@
# Determine OpenSSL header version
AC_MSG_CHECKING([OpenSSL header version])
-AC_TRY_RUN(
+AC_RUN_IFELSE(
[
#include <stdio.h>
#include <string.h>
@@ -1240,12 +1249,15 @@
[
AC_MSG_RESULT(not found)
AC_MSG_ERROR(OpenSSL version header not found.)
+ ],
+ [
+ AC_MSG_WARN([cross compiling: not checking])
]
)
# Determine OpenSSL library version
AC_MSG_CHECKING([OpenSSL library version])
-AC_TRY_RUN(
+AC_RUN_IFELSE(
[
#include <stdio.h>
#include <string.h>
@@ -1273,12 +1285,15 @@
[
AC_MSG_RESULT(not found)
AC_MSG_ERROR(OpenSSL library not found.)
+ ],
+ [
+ AC_MSG_WARN([cross compiling: not checking])
]
)
# Sanity check OpenSSL headers
AC_MSG_CHECKING([whether OpenSSL's headers match the library])
-AC_TRY_RUN(
+AC_RUN_IFELSE(
[
#include <string.h>
#include <openssl/opensslv.h>
@@ -1292,6 +1307,9 @@
AC_MSG_ERROR([Your OpenSSL headers do not match your library.
Check config.log for details.
Also see contrib/findssl.sh for help identifying header/library mismatches.])
+ ],
+ [
+ AC_MSG_WARN([cross compiling: not checking])
]
)
@@ -1312,7 +1330,7 @@
# Check wheter OpenSSL seeds itself
AC_MSG_CHECKING([whether OpenSSL's PRNG is internally seeded])
-AC_TRY_RUN(
+AC_RUN_IFELSE(
[
#include <string.h>
#include <openssl/rand.h>
@@ -1327,6 +1345,12 @@
# Default to use of the rand helper if OpenSSL doesn't
# seed itself
USE_RAND_HELPER=yes
+ ],
+ [
+ AC_MSG_WARN([cross compiling: assuming yes])
+ # This is safe, since all recent OpenSSL versions will
+ # complain at runtime if not seeded correctly.
+ OPENSSL_SEEDS_ITSELF=yes
]
)
@@ -1893,7 +1917,7 @@
exit 1;
else
dnl test snprintf (broken on SCO w/gcc)
- AC_TRY_RUN(
+ AC_RUN_IFELSE(
[
#include <stdio.h>
#include <string.h>
@@ -1917,7 +1941,8 @@
#else
main() { exit(0); }
#endif
- ], [ true ], [ AC_DEFINE(BROKEN_SNPRINTF) ]
+ ], [ true ], [ AC_DEFINE(BROKEN_SNPRINTF) ],
+ AC_MSG_WARN([cross compiling: Assuming working snprintf()])
)
fi
@@ -2022,13 +2047,14 @@
dnl make sure we're using the real structure members and not defines
AC_CACHE_CHECK([for msg_accrights field in struct msghdr],
ac_cv_have_accrights_in_msghdr, [
- AC_TRY_RUN(
+ AC_COMPILE_IFELSE(
[
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/uio.h>
int main() {
#ifdef msg_accrights
+#error "msg_accrights is a macro"
exit(1);
#endif
struct msghdr m;
@@ -2046,13 +2072,14 @@
AC_CACHE_CHECK([for msg_control field in struct msghdr],
ac_cv_have_control_in_msghdr, [
- AC_TRY_RUN(
+ AC_COMPILE_IFELSE(
[
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/uio.h>
int main() {
#ifdef msg_control
+#error "msg_control is a macro"
exit(1);
#endif
struct msghdr m;
@@ -2386,6 +2413,10 @@
AC_DEFINE_UNQUOTED(MAIL_DIRECTORY, "$maildir")
fi
+if test ! -z "$cross_compiling"; then
+ AC_MSG_WARN([cross compiling: Disabling /dev/ptmx test])
+ disable_ptmx_check=yes
+fi
if test -z "$no_dev_ptmx" ; then
if test "x$disable_ptmx_check" != "xyes" ; then
AC_CHECK_FILE("/dev/ptmx",
@@ -2396,12 +2427,17 @@
)
fi
fi
-AC_CHECK_FILE("/dev/ptc",
- [
- AC_DEFINE_UNQUOTED(HAVE_DEV_PTS_AND_PTC)
- have_dev_ptc=1
- ]
-)
+
+if test -z "$cross_compiling"; then
+ AC_CHECK_FILE("/dev/ptc",
+ [
+ AC_DEFINE_UNQUOTED(HAVE_DEV_PTS_AND_PTC)
+ have_dev_ptc=1
+ ]
+ )
+else
+ AC_MSG_WARN([cross compiling: Disabling /dev/ptc test])
+fi
# Options from here on. Some of these are preset by platform above
AC_ARG_WITH(mantype,
@@ -2498,13 +2534,16 @@
# check for /etc/default/login and use it if present.
AC_ARG_ENABLE(etc-default-login,
[ --disable-etc-default-login Disable using PATH from /etc/default/login [no]],,
-[
-AC_CHECK_FILE("/etc/default/login", [ external_path_file=/etc/default/login ])
+ [ AC_CHECK_FILE("/etc/default/login",
+ [ external_path_file=/etc/default/login ])
-if test "x$external_path_file" = "x/etc/default/login"; then
- AC_DEFINE(HAVE_ETC_DEFAULT_LOGIN)
-fi
-])
+ if test ! -z "$cross_compiling"; then
+ AC_MSG_WARN([cross compiling: Disabling /etc/default/login test])
+ elif test "x$external_path_file" = "x/etc/default/login"; then
+ AC_DEFINE(HAVE_ETC_DEFAULT_LOGIN)
+ fi
+ ]
+)
dnl BSD systems use /etc/login.conf so --with-default-path= has no effect
if test $ac_cv_func_login_getcapbool = "yes" -a \