Bug 559854 - Compile target xpidl only if libIDL is configured when cross compiling. [r=ted]
authorJacek Caban <jacek@codeweavers.com>
Wed, 02 Jun 2010 10:08:00 -0400
changeset 43116 0388c837c9867762bcc10a1fb88428050d158479
parent 43115 ceeb7737c4bb57ac4aacb1cc17b8d8c8856de011
child 43117 0c87f407797d0bc7353049a52f5c705fc1d4ae67
push id13625
push userCallek@gmail.com
push dateSat, 05 Jun 2010 02:02:21 +0000
treeherdermozilla-central@63b89b311461 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersted
bugs559854
milestone1.9.3a5pre
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 559854 - Compile target xpidl only if libIDL is configured when cross compiling. [r=ted]
build/autoconf/libIDL.m4
configure.in
xpcom/typelib/xpidl/Makefile.in
--- a/build/autoconf/libIDL.m4
+++ b/build/autoconf/libIDL.m4
@@ -13,56 +13,52 @@ AC_ARG_WITH(libIDL-prefix,[  --with-libI
 AC_ARG_WITH(libIDL-exec-prefix,[  --with-libIDL-exec-prefix=PFX
                           Exec prefix where libIDL is installed (optional)],
             libIDL_config_exec_prefix="$withval", libIDL_config_exec_prefix="")
 AC_ARG_ENABLE(libIDLtest, [  --disable-libIDLtest    Do not try to compile and run a test libIDL program],
 		    , enable_libIDLtest=yes)
 
   if test x$libIDL_config_exec_prefix != x ; then
      libIDL_config_args="$libIDL_config_args --exec-prefix=$libIDL_config_exec_prefix"
-     if test x${LIBIDL_CONFIG+set} != xset ; then
-        LIBIDL_CONFIG=$libIDL_config_exec_prefix/bin/libIDL-config
+     if test x${HOST_LIBIDL_CONFIG+set} != xset ; then
+        HOST_LIBIDL_CONFIG=$libIDL_config_exec_prefix/bin/libIDL-config
      fi
   fi
   if test x$libIDL_config_prefix != x ; then
      libIDL_config_args="$libIDL_config_args --prefix=$libIDL_config_prefix"
-     if test x${LIBIDL_CONFIG+set} != xset ; then
-        LIBIDL_CONFIG=$libIDL_config_prefix/bin/libIDL-config
+     if test x${HOST_LIBIDL_CONFIG+set} != xset ; then
+        HOST_LIBIDL_CONFIG=$libIDL_config_prefix/bin/libIDL-config
      fi
   fi
 
   AM_PATH_GLIB(1.2.0)
 
   dnl Force a version check to keep upgraded versions from being overridden by the cached value.
   unset ac_cv_path_LIBIDL_CONFIG
 
-  AC_PATH_PROG(LIBIDL_CONFIG, libIDL-config, no)
+  AC_PATH_PROG(HOST_LIBIDL_CONFIG, libIDL-config, no)
   min_libIDL_version=ifelse([$1], ,0.6.0,$1)
   AC_MSG_CHECKING(for libIDL - version >= $min_libIDL_version)
   no_libIDL=""
-  if test "$LIBIDL_CONFIG" = "no" ; then
+  if test "$HOST_LIBIDL_CONFIG" = "no" ; then
     no_libIDL=yes
   else
-    LIBIDL_CFLAGS=`$LIBIDL_CONFIG $libIDL_config_args --cflags`
-    LIBIDL_LIBS=`$LIBIDL_CONFIG $libIDL_config_args --libs`
-    # hack to allow us to keep using libIDL 0.6.3-0.6.7. Anyone may remove
-    # this after we start requiring libIDL 0.6.8 or anything higher
-    LIBIDL_CFLAGS="$GLIB_CFLAGS $LIBIDL_CFLAGS"
-    LIBIDL_LIBS="$GLIB_LIBS $LIBIDL_LIBS"
-    libIDL_config_major_version=`$LIBIDL_CONFIG $libIDL_config_args --version | \
+    HOST_LIBIDL_CFLAGS=`$HOST_LIBIDL_CONFIG $libIDL_config_args --cflags`
+    HOST_LIBIDL_LIBS=`$HOST_LIBIDL_CONFIG $libIDL_config_args --libs`
+    libIDL_config_major_version=`$HOST_LIBIDL_CONFIG $libIDL_config_args --version | \
            sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
-    libIDL_config_minor_version=`$LIBIDL_CONFIG $libIDL_config_args --version | \
+    libIDL_config_minor_version=`$HOST_LIBIDL_CONFIG $libIDL_config_args --version | \
            sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
-    libIDL_config_micro_version=`$LIBIDL_CONFIG $libIDL_config_args --version | \
+    libIDL_config_micro_version=`$HOST_LIBIDL_CONFIG $libIDL_config_args --version | \
            sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
     if test "x$enable_libIDLtest" = "xyes" ; then
       ac_save_CFLAGS="$CFLAGS"
       ac_save_LIBS="$LIBS"
-      CFLAGS="$CFLAGS $LIBIDL_CFLAGS"
-      LIBS="$LIBIDL_LIBS $LIBS"
+      CFLAGS="$CFLAGS $HOST_LIBIDL_CFLAGS"
+      LIBS="$HOST_LIBIDL_LIBS $LIBS"
 dnl
 dnl Now check if the installed LIBIDL is sufficiently new.
 dnl
       rm -f conf.libIDLtest
       AC_TRY_RUN([
 #include <stdio.h>
 #include <stdlib.h>
 #include <libIDL/IDL.h>
@@ -149,28 +145,28 @@ main ()
        LIBS="$ac_save_LIBS"
      fi
   fi
   if test "x$no_libIDL" = x ; then
      AC_MSG_RESULT(yes)
      ifelse([$2], , :, [$2])     
   else
      AC_MSG_RESULT(no)
-     if test "$LIBIDL_CONFIG" = "no" ; then
+     if test "$HOST_LIBIDL_CONFIG" = "no" ; then
        echo "*** The libIDL-config script installed by libIDL could not be found"
        echo "*** If libIDL was installed in PREFIX, make sure PREFIX/bin is in"
        echo "*** your path, or set the LIBIDL_CONFIG environment variable to the"
        echo "*** full path to libIDL-config."
      else
        if test -f conf.libIDLtest ; then
         :
        else
           echo "*** Could not run libIDL test program, checking why..."
-          CFLAGS="$CFLAGS $LIBIDL_CFLAGS"
-          LIBS="$LIBS $LIBIDL_LIBS"
+          CFLAGS="$CFLAGS $HOST_LIBIDL_CFLAGS"
+          LIBS="$LIBS $HOST_LIBIDL_LIBS"
           AC_TRY_LINK([
 #include <stdio.h>
 #include <stdlib.h>
 #include <libIDL/IDL.h>
 ],      [ return IDL_get_libver_string ? 1 : 0; ],
         [ echo "*** The test program compiled, but did not run. This usually means"
           echo "*** that the run-time linker is not finding libIDL or finding the wrong"
           echo "*** version of LIBIDL. If it is not finding libIDL, you'll need to set your"
@@ -183,16 +179,16 @@ main ()
         [ echo "*** The test program failed to compile or link. See the file config.log for the"
           echo "*** exact error that occurred. This usually means libIDL was incorrectly installed"
           echo "*** or that you have moved libIDL since it was installed. In the latter case, you"
           echo "*** may want to edit the libIDL-config script: $LIBIDL_CONFIG" ])
           CFLAGS="$ac_save_CFLAGS"
           LIBS="$ac_save_LIBS"
        fi
      fi
-     LIBIDL_CFLAGS=""
-     LIBIDL_LIBS=""
+     HOST_LIBIDL_CFLAGS=""
+     HOST_LIBIDL_LIBS=""
      ifelse([$3], , :, [$3])
   fi
-  AC_SUBST(LIBIDL_CFLAGS)
-  AC_SUBST(LIBIDL_LIBS)
+  AC_SUBST(HOST_LIBIDL_CFLAGS)
+  AC_SUBST(HOST_LIBIDL_LIBS)
   rm -f conf.libIDLtest
 ])
--- a/configure.in
+++ b/configure.in
@@ -2288,19 +2288,16 @@ ia64*-hpux*)
     OBJ_SUFFIX=obj
     RANLIB='echo not_ranlib'
     STRIP='echo not_strip'
     TARGET_NSPR_MDCPUCFG='\"md/_wince.cfg\"'
     UNZIP=unzip
     XARGS=xargs
     XPCOM_FROZEN_LDOPTS='$(LIBXUL_DIST)/lib/xpcom.lib $(LIBXUL_DIST)/lib/mozalloc.lib'
     ZIP=zip
-    LIBIDL_CFLAGS="-I$MOZ_TOOLS_DIR/include ${GLIB_CFLAGS}"
-    LIBIDL_LIBS="$MOZ_TOOLS_DIR/lib/libidl-0.6_s.lib $MOZ_TOOLS_DIR/lib/glib-1.2_s.lib"
-    STATIC_LIBIDL=1
     MOZ_TREE_FREETYPE=1
 
     AC_DEFINE(HAVE_SNPRINTF)
     AC_DEFINE(_WINDOWS)
     AC_DEFINE(WIN32)
     AC_DEFINE(XP_WIN)
     AC_DEFINE(XP_WIN32)
     AC_DEFINE(HW_THREADS)
@@ -2469,94 +2466,17 @@ ia64*-hpux*)
     if test "$?" != "0" || test -z "$MOZ_TOOLS_DIR"; then
         AC_MSG_ERROR([cd \$MOZ_TOOLS failed. MOZ_TOOLS ==? $MOZ_TOOLS])
     fi
     MOZ_TOOLS_BIN_DIR="$(cd "$MOZ_TOOLS_DIR/bin" && pwd)"
     if test `echo ${PATH}: | grep -ic "$MOZ_TOOLS_BINDIR:"` = 0; then
         AC_MSG_ERROR([\$MOZ_TOOLS\\bin must be in your path.])
     fi
     MOZ_TOOLS_DIR=`$CYGPATH_W $MOZ_TOOLS_DIR | $CYGPATH_S`
-
-    if test -n "$GLIB_PREFIX"; then
-        _GLIB_PREFIX_DIR=`cd $GLIB_PREFIX && pwd -W`
-        if test "$?" = "0"; then
-            if test `echo ${PATH}: | grep -ic "$_GLIB_PREFIX_DIR/bin:"` = 0; then
-                AC_MSG_ERROR([GLIB_PREFIX must be in your \$PATH.])
-            fi
-            _GLIB_PREFIX_DIR=`$CYGPATH_W $_GLIB_PREFIX_DIR | $CYGPATH_S`
-        else
-            AC_MSG_ERROR([GLIB_PREFIX is set but "${GLIB_PREFIX}" is not a directory.])
-        fi
-    else
-        _GLIB_PREFIX_DIR=$MOZ_TOOLS_DIR
-    fi
-    if test ! -f "${_GLIB_PREFIX_DIR}/include/glib.h"; then
-        AC_MSG_ERROR([Cannot find $_GLIB_PREFIX_DIR/include/glib.h .])
-    fi
-    GLIB_CFLAGS="-I${_GLIB_PREFIX_DIR}/include"
-    if test -f "${_GLIB_PREFIX_DIR}/lib/glib-1.2_s.lib"; then
-        GLIB_LIBS="${_GLIB_PREFIX_DIR}/lib/glib-1.2_s.lib"
-    elif test -f "${_GLIB_PREFIX_DIR}/lib/glib-1.2.lib"; then
-        GLIB_LIBS="${_GLIB_PREFIX_DIR}/lib/glib-1.2.lib"
-    else
-        AC_MSG_ERROR([Cannot find $_GLIB_PREFIX_DIR/lib/glib-1.2.lib or $_GLIB_PREFIX_DIR/lib/glib-1.2_s.lib])
-    fi
-
-    if test -n "$LIBIDL_PREFIX"; then
-        _LIBIDL_PREFIX_DIR=`cd $LIBIDL_PREFIX && pwd -W`
-        if test "$?" = "0"; then
-            if test `echo ${PATH}: | grep -ic "$_LIBIDL_PREFIX_DIR/bin:"` = 0; then
-                AC_MSG_ERROR([LIBIDL_PREFIX must be in your \$PATH.])
-            fi
-            _LIBIDL_PREFIX_DIR=`$CYGPATH_W $_LIBIDL_PREFIX_DIR | $CYGPATH_S`
-        else
-            AC_MSG_ERROR([LIBIDL_PREFIX is set but "${LIBIDL_PREFIX}" is not a directory.])
-        fi
-    else
-        _LIBIDL_PREFIX_DIR=$MOZ_TOOLS_DIR
-    fi        
-    if test ! -f "${_LIBIDL_PREFIX_DIR}/include/libIDL/IDL.h"; then
-        AC_MSG_ERROR([Cannot find $_LIBIDL_PREFIX_DIR/include/libIDL/IDL.h .])
-    fi
-    LIBIDL_CFLAGS="-I${_LIBIDL_PREFIX_DIR}/include ${GLIB_CFLAGS}"
-    if test -f "${_LIBIDL_PREFIX_DIR}/lib/libidl-0.6_s.lib"; then
-        LIBIDL_LIBS="${_LIBIDL_PREFIX_DIR}/lib/libidl-0.6_s.lib"
-        STATIC_LIBIDL=1
-    elif test -f "${_LIBIDL_PREFIX_DIR}/lib/libidl-0.6.lib"; then
-        LIBIDL_LIBS="${_LIBIDL_PREFIX_DIR}/lib/libidl-0.6.lib"
-    else
-        AC_MSG_ERROR([Cannot find $_LIBIDL_PREFIX_DIR/lib/libidl-0.6.lib or $_LIBIDL_PREFIX_DIR/lib/libidl-0.6_s.lib])
-    fi
-    LIBIDL_LIBS="${LIBIDL_LIBS} ${GLIB_LIBS}"
-    ;;
-
-    *) # else cross-compiling
-        if test -n "$GLIB_PREFIX"; then
-            GLIB_CFLAGS="-I${GLIB_PREFIX}/include"
-            if test -f "${GLIB_PREFIX}/lib/glib-1.2_s.lib"; then
-                GLIB_LIBS="${GLIB_PREFIX}/lib/glib-1.2_s.lib"
-            elif test -f "${GLIB_PREFIX}/lib/glib-1.2.lib"; then
-                GLIB_LIBS="${GLIB_PREFIX}/lib/glib-1.2.lib"
-            else
-                AC_MSG_ERROR([Cannot find $GLIB_PREFIX/lib/glib-1.2.lib or $GLIB_PREFIX/lib/glib-1.2_s.lib])
-            fi
-        fi
-        if test -n "$LIBIDL_PREFIX"; then
-            LIBIDL_CFLAGS="-I${LIBIDL_PREFIX}/include ${GLIB_CFLAGS}"
-            if test -f "${LIBIDL_PREFIX}/lib/libIDL-0.6_s.lib"; then
-                LIBIDL_LIBS="${LIBIDL_PREFIX}/lib/libIDL-0.6_s.lib"
-                STATIC_LIBIDL=1
-            elif test -f "${LIBIDL_PREFIX}/lib/libIDL-0.6.lib"; then
-                LIBIDL_LIBS="${LIBIDL_PREFIX}/lib/libIDL-0.6.lib"
-            else
-                AC_MSG_ERROR([Cannot find $LIBIDL_PREFIX/lib/libIDL-0.6.lib or $LIBIDL_PREFIX/lib/libIDL-0.6_s.lib])
-            fi
-        fi
-        LIBIDL_LIBS="${LIBIDL_LIBS} ${GLIB_LIBS}"
-        ;;
+    ;;
     esac 
 
 
     case "$host_os" in
     cygwin*|msvc*|mks*)
         AC_MSG_WARN([Using a cygwin build environment is unsupported. Configure cannot check for the presence of necessary headers. Please upgrade to MozillaBuild; see http://developer.mozilla.org/en/docs/Windows_Build_Prerequisites])
         ;;
 
@@ -7982,97 +7902,157 @@ dnl ====================================
 dnl =
 dnl = Standalone module options
 dnl = 
 dnl ========================================================
 MOZ_ARG_HEADER(Standalone module options (Not for building Mozilla))
 
 dnl Check for GLib and libIDL.
 dnl ========================================================
-case "$target_os" in
-msvc*|mks*|cygwin*|mingw*|wince*|winmo*)
-    SKIP_IDL_CHECK="yes"
-    ;;
-*)
-    SKIP_IDL_CHECK="no"
-    ;;
-esac
+SKIP_IDL_CHECK="no"
 
 if test -z "$COMPILE_ENVIRONMENT"; then
     SKIP_IDL_CHECK="yes"
 fi
 
 dnl = Allow users to disable libIDL checking for standalone modules
 MOZ_ARG_WITHOUT_BOOL(libIDL,
 [  --without-libIDL        Skip check for libIDL (standalone modules only)],
 	SKIP_IDL_CHECK="yes")
 
+if test -z "$CROSS_COMPILE"; then
+    if test -z "$HOST_LIBIDL_CONFIG"; then
+        HOST_LIBIDL_CONFIG="$LIBIDL_CONFIG"
+    fi
+    if test -z "$HOST_LIBIDL_PREFIX"; then
+        HOST_LIBIDL_PREFIX="$LIBIDL_PREFIX"
+    fi
+fi
+
 if test "$SKIP_IDL_CHECK" = "no"
 then
     _LIBIDL_FOUND=
-    if test "$MACOS_SDK_DIR"; then 
-      dnl xpidl, and therefore libIDL, is only needed on the build host.
-      dnl Don't build it against the SDK, as that causes problems.
-      _MACSAVE_CFLAGS="$CFLAGS"
-      _MACSAVE_LIBS="$LIBS"
-      _MACSAVE_LDFLAGS="$LDFLAGS"
-      _MACSAVE_NEXT_ROOT="$NEXT_ROOT"
-      changequote(,)
-      CFLAGS=`echo $CFLAGS|sed -E -e "s%((-I|-isystem )${MACOS_SDK_DIR}/usr/(include|lib/gcc)[^ ]*)|-F${MACOS_SDK_DIR}(/System)?/Library/Frameworks[^ ]*|-nostdinc[^ ]*|-isysroot ${MACOS_SDK_DIR}%%g"`
-      LIBS=`echo $LIBS|sed -e "s?-L${MACOS_SDK_DIR}/usr/lib[^ ]*??g"`
-      LDFLAGS=`echo $LDFLAGS|sed -e "s?-Wl,-syslibroot,${MACOS_SDK_DIR}??g"`
-      changequote([,])
-      unset NEXT_ROOT
-    fi
-
-    if test "$MOZ_ENABLE_GTK2"; then
-        PKG_CHECK_MODULES(LIBIDL, libIDL-2.0 >= 0.8.0 glib-2.0 gobject-2.0, _LIBIDL_FOUND=1,_LIBIDL_FOUND=)
-    fi
+    case "$host" in
+    *-mingw*|*-cygwin*|*-msvc*|*-mks*)
+        if test -n "$GLIB_PREFIX"; then
+            _GLIB_PREFIX_DIR=`cd $GLIB_PREFIX && pwd -W`
+            if test "$?" = "0"; then
+                if test `echo ${PATH}: | grep -ic "$_GLIB_PREFIX_DIR/bin:"` = 0; then
+                    AC_MSG_ERROR([GLIB_PREFIX must be in your \$PATH.])
+                fi
+                _GLIB_PREFIX_DIR=`$CYGPATH_W $_GLIB_PREFIX_DIR | $CYGPATH_S`
+            else
+                 AC_MSG_ERROR([GLIB_PREFIX is set but "${GLIB_PREFIX}" is not a directory.])
+            fi
+        else
+            _GLIB_PREFIX_DIR=$MOZ_TOOLS_DIR
+        fi
+        if test ! -f "${_GLIB_PREFIX_DIR}/include/glib.h"; then
+            AC_MSG_ERROR([Cannot find $_GLIB_PREFIX_DIR/include/glib.h .])
+        fi
+        GLIB_CFLAGS="-I${_GLIB_PREFIX_DIR}/include"
+        if test -f "${_GLIB_PREFIX_DIR}/lib/glib-1.2_s.lib"; then
+            GLIB_LIBS="${_GLIB_PREFIX_DIR}/lib/glib-1.2_s.lib"
+        elif test -f "${_GLIB_PREFIX_DIR}/lib/glib-1.2.lib"; then
+            GLIB_LIBS="${_GLIB_PREFIX_DIR}/lib/glib-1.2.lib"
+        else
+            AC_MSG_ERROR([Cannot find $_GLIB_PREFIX_DIR/lib/glib-1.2.lib or $_GLIB_PREFIX_DIR/lib/glib-1.2_s.lib])
+        fi
+
+        if test -n "$HOST_LIBIDL_PREFIX"; then
+            _LIBIDL_PREFIX_DIR=`cd $HOST_LIBIDL_PREFIX && pwd -W`
+            if test "$?" = "0"; then
+                if test `echo ${PATH}: | grep -ic "$_LIBIDL_PREFIX_DIR/bin:"` = 0; then
+                    AC_MSG_ERROR([LIBIDL_PREFIX must be in your \$PATH.])
+                fi
+                _LIBIDL_PREFIX_DIR=`$CYGPATH_W $_LIBIDL_PREFIX_DIR | $CYGPATH_S`
+            else
+                AC_MSG_ERROR([LIBIDL_PREFIX is set but "${LIBIDL_PREFIX}" is not a directory.])
+            fi
+        else
+            _LIBIDL_PREFIX_DIR=$MOZ_TOOLS_DIR
+        fi        
+        if test ! -f "${_LIBIDL_PREFIX_DIR}/include/libIDL/IDL.h"; then
+            AC_MSG_ERROR([Cannot find $_LIBIDL_PREFIX_DIR/include/libIDL/IDL.h .])
+        fi
+        HOST_LIBIDL_CFLAGS="-I${_LIBIDL_PREFIX_DIR}/include ${GLIB_CFLAGS}"
+        if test -f "${_LIBIDL_PREFIX_DIR}/lib/libidl-0.6_s.lib"; then
+            HOST_LIBIDL_LIBS="${_LIBIDL_PREFIX_DIR}/lib/libidl-0.6_s.lib"
+            STATIC_LIBIDL=1
+        elif test -f "${_LIBIDL_PREFIX_DIR}/lib/libidl-0.6.lib"; then
+            HOST_LIBIDL_LIBS="${_LIBIDL_PREFIX_DIR}/lib/libidl-0.6.lib"
+        else
+            AC_MSG_ERROR([Cannot find $_LIBIDL_PREFIX_DIR/lib/libidl-0.6.lib or $_LIBIDL_PREFIX_DIR/lib/libidl-0.6_s.lib])
+        fi
+        HOST_LIBIDL_LIBS="${HOST_LIBIDL_LIBS} ${GLIB_LIBS}"
+        _LIBIDL_FOUND=1
+        ;;
+    esac
+
+    if test -z "$_LIBIDL_FOUND"; then
+        if test "$MACOS_SDK_DIR"; then 
+            dnl xpidl, and therefore libIDL, is only needed on the build host.
+            dnl Don't build it against the SDK, as that causes problems.
+            _MACSAVE_CFLAGS="$CFLAGS"
+            _MACSAVE_LIBS="$LIBS"
+            _MACSAVE_LDFLAGS="$LDFLAGS"
+            _MACSAVE_NEXT_ROOT="$NEXT_ROOT"
+          changequote(,)
+          CFLAGS=`echo $CFLAGS|sed -E -e "s%((-I|-isystem )${MACOS_SDK_DIR}/usr/(include|lib/gcc)[^ ]*)|-F${MACOS_SDK_DIR}(/System)?/Library/Frameworks[^ ]*|-nostdinc[^ ]*|-isysroot ${MACOS_SDK_DIR}%%g"`
+          LIBS=`echo $LIBS|sed -e "s?-L${MACOS_SDK_DIR}/usr/lib[^ ]*??g"`
+          LDFLAGS=`echo $LDFLAGS|sed -e "s?-Wl,-syslibroot,${MACOS_SDK_DIR}??g"`
+          changequote([,])
+          unset NEXT_ROOT
+        fi
+
+        PKG_CHECK_MODULES(HOST_LIBIDL, libIDL-2.0 >= 0.8.0 glib-2.0 gobject-2.0, _LIBIDL_FOUND=1,_LIBIDL_FOUND=)
+    fi
+
     dnl if no gtk/libIDL1 or gtk2/libIDL2 combination was found, fall back
     dnl to either libIDL1 or libIDL2.
     if test -z "$_LIBIDL_FOUND"; then
         AM_PATH_LIBIDL($LIBIDL_VERSION,_LIBIDL_FOUND=1)
         if test -z "$_LIBIDL_FOUND"; then
-            PKG_CHECK_MODULES(LIBIDL, libIDL-2.0 >= 0.8.0,_LIBIDL_FOUND=1)
+            PKG_CHECK_MODULES(HOST_LIBIDL, libIDL-2.0 >= 0.8.0,_LIBIDL_FOUND=1)
         fi
     fi
     dnl
     dnl If we don't have a libIDL config program & not cross-compiling, 
     dnl     look for orbit-config instead.
     dnl
     if test -z "$_LIBIDL_FOUND" && test -z "$CROSS_COMPILE"; then
         MOZ_PATH_PROGS(ORBIT_CONFIG, $ORBIT_CONFIG orbit-config)
         if test -n "$ORBIT_CONFIG"; then
             AC_MSG_CHECKING([for ORBit libIDL usability])
         	_ORBIT_CFLAGS=`${ORBIT_CONFIG} client --cflags`
     	    _ORBIT_LIBS=`${ORBIT_CONFIG} client --libs`
             _ORBIT_INC_PATH=`${PERL} -e '{ for $f (@ARGV) { print "$f " if ($f =~ m/^-I/); } }' -- ${_ORBIT_CFLAGS}`
             _ORBIT_LIB_PATH=`${PERL} -e '{ for $f (@ARGV) { print "$f " if ($f =~ m/^-L/); } }' -- ${_ORBIT_LIBS}`
-            LIBIDL_CFLAGS="$_ORBIT_INC_PATH"
-            LIBIDL_LIBS="$_ORBIT_LIB_PATH -lIDL -lglib"
-            LIBIDL_CONFIG=
+            HOST_LIBIDL_CFLAGS="$_ORBIT_INC_PATH"
+            HOST_LIBIDL_LIBS="$_ORBIT_LIB_PATH -lIDL -lglib"
+            HOST_LIBIDL_CONFIG=
             _SAVE_CFLAGS="$CFLAGS"
             _SAVE_LIBS="$LIBS"
-            CFLAGS="$LIBIDL_CFLAGS $CFLAGS"
-            LIBS="$LIBIDL_LIBS $LIBS"
+            CFLAGS="$HOST_LIBIDL_CFLAGS $CFLAGS"
+            LIBS="$HOST_LIBIDL_LIBS $LIBS"
             AC_TRY_RUN([
 #include <stdlib.h>
 #include <libIDL/IDL.h>
 int main() {
   char *s;
   s=strdup(IDL_get_libver_string());
   if(s==NULL) {
     exit(1);
   }
   exit(0);
 }
             ], [_LIBIDL_FOUND=1
                 result="yes"],
-               [LIBIDL_CFLAGS=
-                LIBIDL_LIBS=
+               [HOST_LIBIDL_CFLAGS=
+                HOST_LIBIDL_LIBS=
                 result="no"],
                [_LIBIDL_FOUND=1
                 result="maybe"] )
             AC_MSG_RESULT($result)
             CFLAGS="$_SAVE_CFLAGS"
             LIBS="$_SAVE_LIBS"
         fi
     fi
@@ -8086,26 +8066,52 @@ int main() {
       LDFLAGS="$_MACSAVE_LDFLAGS"
       if test -n "$_MACSAVE_NEXT_ROOT" ; then
         export NEXT_ROOT="$_MACSAVE_NEXT_ROOT"
       fi
     fi
 fi
 
 if test -n "$CROSS_COMPILE"; then
-     if test -z "$HOST_LIBIDL_CONFIG"; then
-        HOST_LIBIDL_CONFIG="$LIBIDL_CONFIG"
-    fi
-    if test -n "$HOST_LIBIDL_CONFIG" && test "$HOST_LIBIDL_CONFIG" != "no"; then
-        HOST_LIBIDL_CFLAGS=`${HOST_LIBIDL_CONFIG} --cflags`
-        HOST_LIBIDL_LIBS=`${HOST_LIBIDL_CONFIG} --libs`
-    else
-        HOST_LIBIDL_CFLAGS="$LIBIDL_CFLAGS"
-        HOST_LIBIDL_LIBS="$LIBIDL_LIBS"
-    fi
+    case "$target" in
+    *-mingw*|*-cygwin*|*-msvc*|*-mks*)
+        if test -n "$GLIB_PREFIX"; then
+            GLIB_CFLAGS="-I${GLIB_PREFIX}/include"
+            if test -f "${GLIB_PREFIX}/lib/glib-1.2_s.lib"; then
+                GLIB_LIBS="${GLIB_PREFIX}/lib/glib-1.2_s.lib"
+            elif test -f "${GLIB_PREFIX}/lib/glib-1.2.lib"; then
+                GLIB_LIBS="${GLIB_PREFIX}/lib/glib-1.2.lib"
+            else
+                AC_MSG_ERROR([Cannot find $GLIB_PREFIX/lib/glib-1.2.lib or $GLIB_PREFIX/lib/glib-1.2_s.lib])
+            fi
+        fi
+
+        if test -n "$LIBIDL_PREFIX"; then
+            LIBIDL_CFLAGS="-I${LIBIDL_PREFIX}/include ${GLIB_CFLAGS}"
+            if test -f "${LIBIDL_PREFIX}/lib/libIDL-0.6_s.lib"; then
+                LIBIDL_LIBS="${LIBIDL_PREFIX}/lib/libIDL-0.6_s.lib"
+                STATIC_LIBIDL=1
+            elif test -f "${LIBIDL_PREFIX}/lib/libIDL-0.6.lib"; then
+                LIBIDL_LIBS="${LIBIDL_PREFIX}/lib/libIDL-0.6.lib"
+            else
+                AC_MSG_ERROR([Cannot find $LIBIDL_PREFIX/lib/libIDL-0.6.lib or $LIBIDL_PREFIX/lib/libIDL-0.6_s.lib])
+            fi
+        fi
+        LIBIDL_LIBS="${LIBIDL_LIBS} ${GLIB_LIBS}"
+        ;;
+    *)
+        if test -n "LIBIDL_CONFIG" && test "LIBIDL_CONFIG" != "no"; then
+            LIBIDL_CFLAGS=`${LIBIDL_CONFIG} --cflags`
+            LIBIDL_LIBS=`${LIBIDL_CONFIG} --libs`
+        fi
+        ;;
+    esac
+else
+    LIBIDL_CFLAGS="$HOST_LIBIDL_CFLAGS"
+    LIBIDL_LIBS="$HOST_LIBIDL_LIBS"
 fi
 
 if test -z "$SKIP_PATH_CHECKS"; then
 if test -z "${GLIB_CFLAGS}" || test -z "${GLIB_LIBS}" ; then
     if test "$MOZ_ENABLE_GTK2" || test "$USE_ELF_DYNSTR_GC" ; then
         PKG_CHECK_MODULES(GLIB, glib-2.0 >= 1.3.7 gobject-2.0)
     else
         AM_PATH_GLIB(${GLIB_VERSION})
--- a/xpcom/typelib/xpidl/Makefile.in
+++ b/xpcom/typelib/xpidl/Makefile.in
@@ -39,87 +39,68 @@ DEPTH		= ../../..
 topsrcdir	= @top_srcdir@
 srcdir		= @srcdir@
 VPATH		= @srcdir@
 
 include $(DEPTH)/config/autoconf.mk
 
 MODULE		= xpcom
 
-# there's no reason to build a target xpidl, why do we do this at all?
-##ifneq (,$(filter-out WINCE SYMBIAN,$(OS_ARCH)))
-### Sadly, the code here is too smart for the WinCE/Symbian compiler's brain
-ifndef CROSS_COMPILE
-PROGRAM		= xpidl$(BIN_SUFFIX)
-SDK_BINARY  = $(PROGRAM)
-endif
-
 INTERNAL_TOOLS	= 1
 
 # glib and libIDL link against the non-debug msvcrt
 MOZ_NO_DEBUG_RTL=1
 
-CSRCS		= \
+XPIDL_CSRCS	= \
 		xpidl.c \
 		xpidl_idl.c \
 		xpidl_util.c \
 		xpidl_header.c \
 		xpidl_typelib.c \
 		xpidl_doc.c \
 		xpidl_java.c \
 		$(NULL)
 
 ifdef CROSS_COMPILE
+
 HOST_PROGRAM	= host_xpidl$(HOST_BIN_SUFFIX)
-HOST_CSRCS	= $(CSRCS)
+HOST_CSRCS	= $(XPIDL_CSRCS)
+
 ifdef WINCE
 HOST_LDFLAGS += -ladvapi32.lib
 endif
+
+ifdef LIBIDL_LIBS
+BUILD_TARGET = 1
+endif
+
+else # CROSS_COMPILE
+
+BUILD_TARGET = 1
+
+endif # CROSS_COMPILE
+
+ifdef BUILD_TARGET
+PROGRAM		= xpidl$(BIN_SUFFIX)
+CSRCS 		= $(XPIDL_CSRCS)
+SDK_BINARY  	= $(PROGRAM)
+CFLAGS         += LIBIDL_CFLAGS
+LIBS           += LIBIDL_LIBS
 endif
 
 USE_STATIC_LIBS = 1
 
 ifeq ($(OS_ARCH),Darwin)
 # The only reason to not always strip the SDK out is that the libraries
 # in / on ppc currently aren't fat, preventing the target xpidl from linking
 # on a ppc->x86 build.  The SDK, presumably 10.4u, must be included in that
 # case in order to successfully link.  Because the target xpidl isn't
 # currently built in a cross compile, though, this point is moot for the
 # time being.
-
-ifndef CROSS_COMPILE
-# When doing a native build, don't build xpidl against the SDK.  libIDL
-# was most likely configured for the system headers, and bringing in the
-# SDK's headers instead will cause problems.
 _STRIP_SDK = 1
-else
-
-# Cross-compiling
-
-# Don't build xpidl for the target.  This is not intended to be a permanent
-# solution.  It's necessary because it is presently difficult to build
-# xpidl's prerequisites (libIDL and glib) as fat and suitable for a cross.
-# This will be fixed.  -mm
-PROGRAM=
-
-# Since only host_xpidl will be built for now, always strip out the SDK
-# (as above).
-_STRIP_SDK=1
-
-# When fat xpidl prerequisites are available, the PROGRAM= and _STRIP_SDK=1
-# above are expected to disappear, and be replaced with the following
-# conditonal.
-
-# ifeq (86_powerpc,$(findstring 86,$(host_cpu))_$(TARGET_CPU))
-# # When cross-compiling from x86 to ppc, an old (10.2-ish) SDK might be in
-# # use, and libIDL will have been configured for new (10.4-ish) headers.
-# _STRIP_SDK = 1
-# endif
-
-endif # CROSS_COMPILE
 
 ifneq (,$(_STRIP_SDK)$(MACOS_SDK_DIR))
 # libIDL is configured for the system's headers, with no SDK involved.
 # There may be header conflicts if the SDK used for the Mozilla build
 # is used here.  There are very few specific cases where the SDK needs to
 # remain set to build xpidl.
 NEXT_ROOT=
 OS_CFLAGS := $(shell echo $(OS_CFLAGS)|sed -E -e "s%((-I|-isystem )$(MACOS_SDK_DIR)/usr/(include|lib/gcc)[^ ]*)|-F$(MACOS_SDK_DIR)(/System)?/Library/Frameworks[^ ]*|-nostdinc[^ ]*|-isysroot $(MACOS_SDK_DIR)%%g")