GNOME Bugzilla – Bug 58786
Support for cross-build
Last modified: 2011-02-18 16:13:45 UTC
The configure file in version 1.2.9 or later version has not supported cross-build yet. The attached patch fixes this. Feel free to modify it if you think it's necessary. -Amy Lin --- glib-1.2.9/acglib.m4.cross Sun Jul 29 01:47:01 2001 +++ glib-1.2.9/acglib.m4 Sun Jul 29 01:47:34 2001 @@ -73,7 +73,8 @@ fprintf(f, "%s%d", i?",":"", *(p++)); fprintf(f, "\n"); exit(0); -}], AC_CV_NAME=`cat conftestval`, AC_CV_NAME=0, AC_CV_NAME=0)])dnl +}], AC_CV_NAME=`cat conftestval`, AC_CV_NAME=0, [ +AC_CV_NAME=`cat confdefval`])])dnl AC_MSG_RESULT($AC_CV_NAME) AC_DEFINE_UNQUOTED(AC_TYPE_NAME, $AC_CV_NAME) undefine([AC_TYPE_NAME])dnl @@ -122,6 +123,19 @@ fi echo "#define GLIB_SYSDEF_$glib_sysdef$glib_default" >>$glib_sysdefso done - AC_MSG_RESULT(failed)]) + AC_MSG_RESULT(failed)], +[ for glib_sysdef_input in $2 ; do + glib_sysdef=`echo $glib_sysdef_input | sed 's/^\([[^:]]*\):.*$/\1/'` + glib_default=`echo $glib_sysdef_input | sed 's/^[[^:]]*:\(.*\)$/\1/'` + if test $glib_sysdef != $glib_default; then + glib_default=" $4$glib_default" + else + glib_default= + fi + echo "#define GLIB_SYSDEF_$glib_sysdef$glib_default" >>$glib_sysdefso + done +] + , +) rm -f confrun.c ]) --- glib-1.2.9/configure.in.cross Sun Jul 29 01:47:13 2001 +++ glib-1.2.9/configure.in Sun Jul 29 01:47:24 2001 @@ -8,6 +8,7 @@ # init autoconf (and check for presence of glist.c) AC_INIT(glist.c) +AC_CANONICAL_SYSTEM # Save this value here, since automake will set cflags later cflags_set=${CFLAGS+set} @@ -79,6 +80,7 @@ AC_CANONICAL_HOST + dnl figure debugging default, prior to $ac_help setup dnl AC_DIVERT_PUSH(AC_DIVERSION_NOTICE)dnl @@ -88,6 +90,21 @@ debug_default=minimum fi AC_DIVERT_POP()dnl +# Handle target_cpu for compatibility. +if test "$host_cpu" != "$target_cpu"; then + host_cpu=$target_cpu +fi +case "$host_cpu" in + alpha*) ARCH=alpha ;; + i?86) ARCH=i386 ;; + ia64) ARCH=ia64 ;; + arm*) ARCH=arm ;; + mips*) ARCH=mips ;; + powerpc) ARCH=ppc ;; + *) ARCH=$host_cpu ;; +esac + + dnl declare --enable-* args and collect ac_help strings AC_ARG_ENABLE(debug, [ --enable-debug=[no/minimum/yes] turn on debugging [default=$debug_default]],,enable_debug=$debug_default) @@ -193,8 +210,10 @@ AC_MSG_RESULT() CFLAGS=$glib_save_CFLAGS AC_MSG_WARN( - [No ANSI prototypes found in library. (-std1 didn't work.)]) - ) + [No ANSI prototypes found in library. (-std1 didn't work.)]), + [CFLAGS=$glib_save_CFLAGS], + ), + [ AC_MSG_RESULT(none needed)], ) LIBS=$glib_save_LIBS @@ -218,12 +237,12 @@ AC_CHECK_FUNCS(atexit on_exit) -AC_CHECK_SIZEOF(char) -AC_CHECK_SIZEOF(short) -AC_CHECK_SIZEOF(long) -AC_CHECK_SIZEOF(int) -AC_CHECK_SIZEOF(void *) -AC_CHECK_SIZEOF(long long) +AC_CHECK_SIZEOF(char,1) +AC_CHECK_SIZEOF(short,2) +AC_CHECK_SIZEOF(long,4) +AC_CHECK_SIZEOF(int,4) +AC_CHECK_SIZEOF(void *,4) +AC_CHECK_SIZEOF(long long, 8) dnl long doubles were not used, and a portability problem dnl AC_C_LONG_DOUBLE @@ -241,7 +260,10 @@ glib_cv_has__inline=yes , glib_cv_has__inline=no - ,) + , + glib_cv_has__inline=yes + , + ), ]) AC_MSG_RESULT($glib_cv_has__inline) case x$glib_cv_has__inline in @@ -256,6 +278,8 @@ glib_cv_has__inline__=yes , glib_cv_has__inline__=no + , + glib_cv_has__inline__=yes ,) ]) AC_MSG_RESULT($glib_cv_has__inline__) @@ -271,6 +295,8 @@ glib_cv_hasinline=yes , glib_cv_hasinline=no + , + glib_cv_hasinline=yes ,) ]) AC_MSG_RESULT($glib_cv_hasinline) @@ -279,7 +305,7 @@ esac dnl for bytesex stuff -AC_C_BIGENDIAN +#AC_C_BIGENDIAN(yes,ac_cv_c_bigendian=no) dnl header file checks AC_CHECK_HEADERS(float.h, AC_DEFINE(HAVE_FLOAT_H)) @@ -408,6 +434,9 @@ AC_DEFINE(REALLOC_0_WORKS) , glib_cv_sane_realloc=no + , + glib_cv_sane_realloc=yes + AC_DEFINE(REALLOC_0_WORKS) ,) ]) AC_MSG_RESULT($glib_cv_sane_realloc) @@ -437,6 +466,8 @@ glib_cv_va_copy=yes , glib_cv_va_copy=no + , + glib_cv_va_copy=yes ,) ]) AC_MSG_RESULT($glib_cv_va_copy) @@ -459,6 +490,8 @@ glib_cv___va_copy=yes , glib_cv___va_copy=no + , + glib_cv___va_copy=yes ,) ]) AC_MSG_RESULT($glib_cv___va_copy) @@ -481,6 +514,8 @@ glib_cv_va_val_copy=yes , glib_cv_va_val_copy=no + , + glib_cv_va_val_copy=yes ,) ]) if test "x$glib_cv_va_copy" = "xyes"; then @@ -577,7 +612,7 @@ }], [glib_cv_rtldglobal_broken=no], [glib_cv_rtldglobal_broken=yes], - []) + [glib_cv_rtldglobal_broken=no]) rm -f plugin.c plugin.o plugin.lo ]) if test "x$glib_cv_rtldglobal_broken" = "xyes"; then @@ -601,6 +636,7 @@ }], glib_cv_uscore=yes, glib_cv_uscore=no, + glib_cv_uscore=yes, ) rm -f plugin.c plugin.o plugin.lo ]) @@ -843,7 +879,9 @@ sizeof (buffer), &pointer); return errno == ENOSYS || error == ENOSYS;}], [ac_cv_func_getpwuid_r=yes], - [ac_cv_func_getpwuid_r=no])]) + [ac_cv_func_getpwuid_r=no], + [ac_cv_func_getpwuid_r=yes], + )]) if test "$ac_cv_func_getpwuid_r" = yes; then AC_MSG_RESULT(yes) AC_DEFINE(HAVE_GETPWUID_R) @@ -880,7 +918,10 @@ return !pthread_mutex_trylock (&mutex); }], [AC_MSG_RESULT(no)], [AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_PTHREAD_MUTEX_TRYLOCK_POSIX)]) + AC_DEFINE(HAVE_PTHREAD_MUTEX_TRYLOCK_POSIX)], + [AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_PTHREAD_MUTEX_TRYLOCK_POSIX)], + ) AC_MSG_CHECKING(whether pthread_cond_timedwait is posix like) # DCE Threads return -1 as failure, posix ETIMEDOUT. AC_TRY_RUN([#include <pthread.h> @@ -896,7 +937,10 @@ != -1;}], [AC_MSG_RESULT(no)], [AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_PTHREAD_COND_TIMEDWAIT_POSIX)]) + AC_DEFINE(HAVE_PTHREAD_COND_TIMEDWAIT_POSIX)], + [AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_PTHREAD_COND_TIMEDWAIT_POSIX)], + ) fi LIBS="$glib_save_LIBS" CFLAGS="$glib_save_CFLAGS" @@ -923,10 +967,12 @@ dnl dnl if mutex_has_default = yes, we also got dnl mutex_default_type, mutex_default_init and mutex_header_file +echo "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0">confdefval GLIB_IF_VAR_EQ(mutex_has_default, yes, GLIB_SIZEOF([#include <$mutex_header_file>], $mutex_default_type, gmutex, + 24, ) GLIB_BYTE_CONTENTS([#include <$mutex_header_file>], $mutex_default_type,
Created attachment 873 [details] [review] cross build support
Doesn't there need to be some mechanism for allowing the person configuring the cross compile to choose the defaults for all the runtime tests? Without this, I dont' really see how there could be any expectation that the resulting cross compile would work properly.
Changing to NEEDINFO until more information about how setting the values for results would be handled. Please reopen if you add more comments to this.
Reopening since the question has come up repeatedly, and we would like to fix this at some point, even if we don't know how to do so now.
Created attachment 5941 [details] [review] patch to autoconf to allow cross compilation of glib
if you have your target accessible, and are willing to recompile autoconf, the following might be worthwhile. the problem (for glib, i assume its the same for gtk), is that some information is gleaned thru the AC_TRY_RUN macro, which compiles and executes c code to, eg, determine the size of the c types. my solution was to modify autoconf so that instead of trying to directly execute the compiled-c-code (called conftest by the macro), it executes a shell script, passing as arguement the executable name. from the autoconf patch -if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext} && (./cross_test.sh conftest; exit) 2>/dev/null i then wrote the cross_test.sh to handle the actual running of the executable. i was on a mercury machine with the filesystem shared between the host and the target, so all i had to do was (an rsh-like command) #! /bin/sh -f runmc -ce 4 $1 you could also (i did before i found the runmc command) use expect to ftp the executable and then telnet to execute it. you could even just have the script prompt you to run the executable by hand - whatever you do, you just need to make sure that the return values and any file modifications (the c code is really simple for the tests) make it back to the host.
The patches in bug 77565 correspond to newer versions of Glib and autoconf, so I'm dup'ing it that way, rather than the reverse. *** This bug has been marked as a duplicate of 77565 ***