[PATCH] allow cross-compiling samba-2.2.7

Dan Kegel dank at kegel.com
Fri Dec 6 15:27:00 GMT 2002


I needed to cross-compile Samba for ppc linux from x86 linux.
Fortunately, samba-2.2.7 is very nearly cross-compile-friendly.
The main problem when cross-compiling autoconf'd projects is AC_TRY_RUN
in configure.in, which just doesn't work.  Sure enough, to get
Samba to build in a cross-compilation environment, all I had
to do was get rid of one use of AC_TRY_RUN in configure.in,
run autoconf2.50 (to generate a configure script that sets
SIZEOF_INT without using AC_TRY_RUN), and run configure like this:

CC=/opt/cegl-1.4/hardhat/devkit/ppc/405/bin/powerpc-linux-gcc CFLAGS="-mcpu=403" 
../samba-2.2.7/source/configure --build=pentium-unknown-linux --host=ppc-unknown-linux

Here's a patch that removes the one use of AC_TRY_RUN in configure.in
that was causing trouble.  (And oddly, this makes the definition of
HAVE_GETTIMEOFDAY_TZ better match how this macro is used in the sources,
I think.)  Please apply if you agree it's benign.  Thanks!

--- samba-2.2.7/source/configure.in.orig	Thu Dec  5 12:09:07 2002
+++ samba-2.2.7/source/configure.in	Thu Dec  5 12:18:52 2002
@@ -1167,10 +1167,10 @@
  fi

  AC_CACHE_CHECK([if gettimeofday takes tz argument],samba_cv_HAVE_GETTIMEOFDAY_TZ,[
-AC_TRY_RUN([
+AC_TRY_COMPILE([
  #include <sys/time.h>
-#include <unistd.h>
-main() { struct timeval tv; exit(gettimeofday(&tv, NULL));}],
+#include <unistd.h>],
+[struct timeval tv; exit(gettimeofday(&tv, NULL));],
 
samba_cv_HAVE_GETTIMEOFDAY_TZ=yes,samba_cv_HAVE_GETTIMEOFDAY_TZ=no,samba_cv_HAVE_GETTIMEOFDAY_TZ=cross)])
  if test x"$samba_cv_HAVE_GETTIMEOFDAY_TZ" = x"yes"; then
      AC_DEFINE(HAVE_GETTIMEOFDAY_TZ)
-------------- next part --------------
--- samba-2.2.7/source/configure.in.orig	Thu Dec  5 12:09:07 2002
+++ samba-2.2.7/source/configure.in	Thu Dec  5 12:18:52 2002
@@ -1167,10 +1167,10 @@
 fi
 
 AC_CACHE_CHECK([if gettimeofday takes tz argument],samba_cv_HAVE_GETTIMEOFDAY_TZ,[
-AC_TRY_RUN([
+AC_TRY_COMPILE([
 #include <sys/time.h>
-#include <unistd.h>
-main() { struct timeval tv; exit(gettimeofday(&tv, NULL));}],
+#include <unistd.h>],
+[struct timeval tv; exit(gettimeofday(&tv, NULL));],
            samba_cv_HAVE_GETTIMEOFDAY_TZ=yes,samba_cv_HAVE_GETTIMEOFDAY_TZ=no,samba_cv_HAVE_GETTIMEOFDAY_TZ=cross)])
 if test x"$samba_cv_HAVE_GETTIMEOFDAY_TZ" = x"yes"; then
     AC_DEFINE(HAVE_GETTIMEOFDAY_TZ)



More information about the samba-technical mailing list