configure does not work when cross compiling because of the AC_TRY_RUN macro without cross-compilation parameters. Most of these can be resolved by relatively safe guesses, changing them to AC_TRY_LINK, or runtime detection. Attached is a patch that allows Openssh 3.4p1 to cross-compile. --- openssh-3.4p1/configure.ac Tue Jun 25 15:35:16 2002 +++ openssh-3.4p1.ayr/configure.ac Fri Jun 28 14:21:34 2002 @@ -463,20 +463,6 @@ ] ) -AC_MSG_CHECKING([whether struct dirent allocates space for d_name]) -AC_TRY_RUN( - [ -#include <sys/types.h> -#include <dirent.h> -int main(void){struct dirent d;return(sizeof(d.d_name)<=sizeof(char));} - ], - [AC_MSG_RESULT(yes)], - [ - AC_MSG_RESULT(no) - AC_DEFINE(BROKEN_ONE_BYTE_DIRENT_D_NAME) - ] -) - # Check whether user wants S/Key support SKEY_MSG="no" AC_ARG_WITH(skey, @@ -505,6 +491,10 @@ [ AC_MSG_RESULT(no) AC_MSG_ERROR([** Incomplete or missing s/key libraries.]) + ] + [ + AC_MSG_RESULT(no) + AC_MSG_ERROR([** Incomplete or missing s/key libraries.]) ]) fi ] @@ -597,6 +587,7 @@ AC_MSG_RESULT(yes) AC_DEFINE(HAVE_MMAP_ANON_SHARED) ], + [ AC_MSG_RESULT(no) ], [ AC_MSG_RESULT(no) ] ) fi @@ -626,6 +617,7 @@ } ], [ ac_cv_have_broken_dirname="no" ], + [ ac_cv_have_broken_dirname="yes" ], [ ac_cv_have_broken_dirname="yes" ] ) LIBS="$save_LIBS" @@ -670,6 +662,10 @@ AC_MSG_RESULT(no) AC_DEFINE(BROKEN_SNPRINTF) AC_MSG_WARN([****** Your snprintf() function is broken, complain to your vendor]) + ], + [ + AC_MSG_RESULT(assuming no) + AC_DEFINE(BROKEN_SNPRINTF) ] ) fi @@ -784,6 +780,10 @@ [ AC_MSG_RESULT(no) AC_MSG_ERROR(Your OpenSSL headers do not match your library) + ], + [ + AC_MSG_RESULT(yes) + AC_MSG_WARN(Not sure, hoping so) ] ) @@ -813,6 +813,13 @@ # Default to use of the rand helper if OpenSSL doesn't # seed itself USE_RAND_HELPER=yes + ], + [ + AC_MSG_RESULT(no) + # Default to use of the rand helper if OpenSSL doesn't + # seed itself + USE_RAND_HELPER=yes + AC_MSG_WARN(Not sure, assuming no) ] ) @@ -1417,7 +1424,8 @@ #else main() { exit(0); } #endif - ], [ true ], [ AC_DEFINE(BROKEN_SNPRINTF) ] + ], [ true ], [ AC_DEFINE(BROKEN_SNPRINTF) ], + [ AC_DEFINE(BROKEN_SNPRINTF) ] ) fi AC_SUBST(NO_SFTP) @@ -1523,13 +1531,16 @@ 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_TRY_COMPILE( [ #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; @@ -1547,13 +1558,16 @@ AC_CACHE_CHECK([for msg_control field in struct msghdr], ac_cv_have_control_in_msghdr, [ - AC_TRY_RUN( + AC_TRY_COMPILE( [ #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; @@ -1860,20 +1874,17 @@ if test -z "$no_dev_ptmx" ; then if test "x$disable_ptmx_check" != "xyes" ; then - AC_CHECK_FILE("/dev/ptmx", - [ - AC_DEFINE_UNQUOTED(HAVE_DEV_PTMX) - have_dev_ptmx=1 - ] - ) + if test -f "/dev/ptc" ; then + AC_DEFINE_UNQUOTED(HAVE_DEV_PTMX) + have_dev_ptmx=1 + fi fi fi -AC_CHECK_FILE("/dev/ptc", - [ - AC_DEFINE_UNQUOTED(HAVE_DEV_PTS_AND_PTC) - have_dev_ptc=1 - ] -) + +if test -f "/dev/ptc" ; then + AC_DEFINE_UNQUOTED(HAVE_DEV_PTS_AND_PTC) + have_dev_ptc=1 +fi # Options from here on. Some of these are preset by platform above AC_ARG_WITH(mantype, --- openssh-3.4p1/sftp-glob.c Tue Feb 12 19:10:33 2002 +++ openssh-3.4p1.ayr/sftp-glob.c Fri Jun 28 14:02:44 2002 @@ -78,12 +78,9 @@ * Solaris defines dirent->d_name as a one byte array and expects * you to hack around it. */ -#ifdef BROKEN_ONE_BYTE_DIRENT_D_NAME - strlcpy(ret->d_name, od->dir[od->offset++]->filename, MAXPATHLEN); -#else strlcpy(ret->d_name, od->dir[od->offset++]->filename, - sizeof(ret->d_name)); -#endif + (sizeof(ret->d_name) <= sizeof(char))? + MAXPATHLEN: sizeof(ret->d_name)); #ifdef __GNU_LIBRARY__ /* * Idiot glibc uses extensions to struct dirent for readdir with
Created attachment 123 [details] configure.ac diff
Created attachment 124 [details] sftp-glob.c diff
Created attachment 655 [details] Patch to configure.ac (3.7p1) This new patch is for 3.7p1. It only modifies configure.ac; no C source. Can someone *please* apply?
Comment on attachment 655 [details] Patch to configure.ac (3.7p1) >+if test "$cross_compiling"; then I don't think that's portable, should probably be: if test ! -z "$cross_compiling";then >+ echo cross compiling: Disabling /etc/default/login test I think that should be AC_MSG_WARN(). I updated the patch to -current, will attach shortly.
Created attachment 656 [details] Update to -current Update to current. AC_TRY_COMPILE is marked obsolete so if we're making changes we should use the modern equivalent AC_COMPILE_IFELSE. Ditto for AC_TRY_RUN -> AC_RUN_IFELSE, especially since the manual says AC_TRY_RUN doesn't have "action-if-cross-compiling" blocks. Please test it (I don't cross-compile, so I haven't tested those bits).
Patch 656 works, except that the zlib detection stuff needs some modification as well. I'll submit a new patch.
Created attachment 657 [details] Updated patch for -current, which handles the zlib test This patch works for me. I'm configuring with: ./configure --with-ssl-dir=/usr/local/cross-solaris --host=sparc-sun-solaris2.8 --disable-etc-default-login I've only tested the ssh client binary though; not sshd.
Comment on attachment 657 [details] Updated patch for -current, which handles the zlib test This looks mostly OK, but I'd rather avoid messing with the /etc/default/login tests. Is reasonable to just expect people cross compiling to add --without-etc-default-login? Any other suggestions/opinions?
>Is reasonable to just expect people cross compiling to add >--without-etc-default-login? Yes, I think this is reasonable.
I try to compile openssh-3.8.1p1 on a i386 linux system for s390-unknown-linux, but configure is still complaining about cross-compiling: "checking if setresuid seems to work... configure: error: cannot run test program while cross compiling" I tried to change configure.ac the way you did (although I'm not really sure what I am doing here :-) and also the test for setresgid. Fixed it, but now I am stuck at "checking if openpty correctly handles controlling tty... configure: error: cannot run test program while cross compiling" How can I solve this?
Micheal: You probably just need to run "autoreconf" to rebuild configure after apply the patch(s). Autoconf v2.59 is what we currently use, other versions might work too.
Daren: I ran autoconf after modifying configure.ac, of course. But I only applied the latest patch from here (...which handles the zlib test) ...
Created attachment 710 [details] Add cross-compile support to the setres[ug]id test Ah, OK. That check is only run if the setresuid is found, so I guess the other folks doing cross-compiling are building for platforms that don't have it. Please try this patch in addition to #657.
Comment on attachment 657 [details] Updated patch for -current, which handles the zlib test BTW, patch looks OK to me. Should probably commit this (and the setresuid one if it tests OK).
Comment on attachment 710 [details] Add cross-compile support to the setres[ug]id test this looks ok
Comment on attachment 710 [details] Add cross-compile support to the setres[ug]id test >- AC_TRY_RUN([ >+ AC_TRY_IFELSE([ Correction: make that "AC_RUN_IFELSE".
Patches #657 and #710 applied. Thanks to all.
Change all RESOLVED bug to CLOSED with the exception of the ones fixed post-4.4.