View Issue Details

IDProjectCategoryView StatusLast Update
0000599LDMud 3.3Compilation, Installationpublic2009-01-16 17:32
Reporterpeng Assigned To 
PrioritynormalSeverityfeatureReproducibilityN/A
Status newResolutionopen 
Product Version3.3.718 
Summary0000599: patch to allow cross-compiling
DescriptionWith this patch its possible to cross-compile the driver like in the appended shell-script.
Tagsldmud-extensions
Attached Files
cross_compiling.diff (10,643 bytes)   
Index: Makefile.in
===================================================================
--- Makefile.in	(revision 2485)
+++ Makefile.in	(working copy)
@@ -6,6 +6,7 @@
 mkinstalldirs=$(SHELL) @top_srcdir@/mkinstalldirs
 #
 CC=@CC@
+CC_FOR_BUILD=@CC_FOR_BUILD@
 #
 YACC = @YACC@
 YACCTAB = @YACCTAB@
@@ -152,8 +153,8 @@
 	lint *.c
 
 clean:
-	$(RM) $(YACCTAB)h $(YACCTAB)c make_func.c *.o mkfunc@EXEEXT@
-	$(RM) dftables@EXEEXT@ pcre/chartables.c
+	$(RM) $(YACCTAB)h $(YACCTAB)c make_func.c *.o mkfunc@EXEEXT_FOR_BUILD@
+	$(RM) dftables@EXEEXT_FOR_BUILD@ pcre/chartables.c
 	$(RM) stdstrings.c stdstrings.h
 	$(RM) efun_defs.c instrs.h lang.y lang.h lang.c y.output tags TAGS
 	$(RM) ldmud@EXEEXT@ core mudlib/core mudlib/debug.log lpmud.log
@@ -180,31 +181,36 @@
 	@MOVE_YACC_TAB@ make_func.c
 	@CLEAN_YACC_TAB@
 
-#mkfunc.o : mkfunc.c make_func.c driver.h config.h machine.h port.h
-#	  $(CC) $(CFLAGS) -c mkfunc.c
+hash_b.o : hash.h
+	$(CC_FOR_BUILD) $(CFLAGS) -c hash.c -o hash_b.o
 
-mkfunc@EXEEXT@: mkfunc.o hash.o exec.h
-	$(CC) @OPTIMIZE_LINKING@ $(LDFLAGS) mkfunc.o hash.o -o mkfunc@EXEEXT@
+mkfunc.o : make_func.c ../mudlib/sys/driver_hook.h hash.h exec.h \
+    my-alloca.h driver.h bytecode.h typedefs.h port.h config.h hosts/unix.h \
+    hosts/be/be.h machine.h
+	$(CC_FOR_BUILD) $(CFLAGS) -c mkfunc.c
+ 
+mkfunc@EXEEXT_FOR_BUILD@: mkfunc.o hash_b.o exec.h
+	$(CC_FOR_BUILD) @OPTIMIZE_LINKING@ $(LDFLAGS) mkfunc.o hash_b.o -o mkfunc@EXEEXT_FOR_BUILD@

 dftables.o : pcre/dftables.c pcre/maketables.c pcre/config.h
-	$(CC) $(CFLAGS) -c pcre/dftables.c -o dftables.o
+	$(CC_FOR_BUILD) $(CFLAGS) -c pcre/dftables.c -o dftables.o
 
-dftables@EXEEXT@ : dftables.o
-	$(CC) @OPTIMIZE_LINKING@ $(LDFLAGS) dftables.o -o dftables@EXEEXT@
+dftables@EXEEXT_FOR_BUILD@ : dftables.o
+	$(CC_FOR_BUILD) @OPTIMIZE_LINKING@ $(LDFLAGS) dftables.o -o dftables@EXEEXT_FOR_BUILD@
 
-lang.y: mkfunc@EXEEXT@ prolang.y config.h
+lang.y: mkfunc@EXEEXT_FOR_BUILD@ prolang.y config.h
 	$(RM) lang.y
-	./mkfunc@EXEEXT@ lang
+	./mkfunc@EXEEXT_FOR_BUILD@ lang
 
-efun_defs.c instrs.h: func_spec mkfunc@EXEEXT@ config.h machine.h
+efun_defs.c instrs.h: func_spec mkfunc@EXEEXT_FOR_BUILD@ config.h machine.h
 	$(RM) instrs.h
 	$(RM) efun_defs.c
-	./mkfunc@EXEEXT@ instrs
+	./mkfunc@EXEEXT_FOR_BUILD@ instrs
 
-stdstrings.c stdstrings.h: string_spec mkfunc@EXEEXT@ config.h machine.h
+stdstrings.c stdstrings.h: string_spec mkfunc@EXEEXT_FOR_BUILD@ config.h machine.h
 	$(RM) stdstrings.c
 	$(RM) stdstrings.h
-	./mkfunc@EXEEXT@ strings
+	./mkfunc@EXEEXT_FOR_BUILD@ strings
 
 lang.c lang.h: lang.y
 	$(YACC) -d -v lang.y
@@ -212,8 +218,8 @@
 	@CLEAN_YACC_TAB@
 	$(MV) $(YACCTAB)h lang.h
 
-pcre/chartables.c : dftables@EXEEXT@
-	./dftables@EXEEXT@ pcre/chartables.c
+pcre/chartables.c : dftables@EXEEXT_FOR_BUILD@
+	./dftables@EXEEXT_FOR_BUILD@ pcre/chartables.c
 
 random.o : random.c config.h driver.h
 	$(CC) $(CFLAGS) $(SFMT_FLAGS) -c random.c -o random.o
@@ -391,10 +397,6 @@
     simulate.h gcollect.h mempools.h driver.h typedefs.h sent.h bytecode.h \
     port.h config.h hosts/unix.h hosts/be/be.h machine.h
 
-mkfunc.o : make_func.c ../mudlib/sys/driver_hook.h hash.h exec.h \
-    my-alloca.h driver.h bytecode.h typedefs.h port.h config.h hosts/unix.h \
-    hosts/be/be.h machine.h
-
 mregex.o : ../mudlib/sys/regexp.h ../mudlib/sys/driver_hook.h \
     ../mudlib/sys/debug_info.h xalloc.h svalue.h strfuns.h simulate.h \
     regexp.h pkg-pcre.h mstrings.h main.h interpret.h hash.h gcollect.h \
Index: autoconf/configure.in
===================================================================
--- autoconf/configure.in	(revision 2485)
+++ autoconf/configure.in	(working copy)
@@ -87,6 +87,39 @@
     not_available="[$not_available], $1"
 fi])
 
+dnl Get a default for CC_FOR_BUILD to put into Makefile.
+AC_DEFUN([AC_CC_FOR_BUILD],
+[# Put a plausible default for CC_FOR_BUILD in Makefile.
+if test -z "$CC_FOR_BUILD"; then
+  if test "x$cross_compiling" = "xno"; then
+    CC_FOR_BUILD='$(CC)'
+  else
+    CC_FOR_BUILD=gcc
+  fi
+fi])
+
+dnl Also set EXEEXT_FOR_BUILD.
+AC_DEFUN([AC_CC_EXEEXT_FOR_BUILD],
+[if test "x$cross_compiling" = "xno"; then
+  EXEEXT_FOR_BUILD='$(EXEEXT)'
+else
+  AC_CACHE_CHECK([for build system executable suffix], ac_cv_build_exeext,
+    [rm -f conftest*
+     echo 'int main () { return 0; }' > conftest.c
+     ac_cv_build_exeext=
+     ${CC_FOR_BUILD} -o conftest conftest.c 1>&5 2>&5
+     for file in conftest.*; do
+       case $file in
+       *.c | *.o | *.obj | *.ilk | *.pdb) ;;
+       *) ac_cv_build_exeext=`echo $file | sed -e s/conftest//` ;;
+       esac
+     done
+     rm -f conftest*
+     test x"${ac_cv_build_exeext}" = x && ac_cv_build_exeext=no])
+  EXEEXT_FOR_BUILD=""
+  test x"${ac_cv_build_exeext}" != xno && EXEEXT_FOR_BUILD=${ac_cv_build_exeext}
+fi])
+
 dnl
 dnl let's start
 AC_INIT(prolang.y)
@@ -505,6 +540,8 @@
 dnl select a C-Compiler
 dnl
 AC_PROG_CC
+AC_CC_FOR_BUILD
+AC_CC_EXEEXT_FOR_BUILD
 
 # The newer versions of gcc/egcs running on SunOS fall into catatonia when
 # asked to compile this test with any optimisation. To be able to run
@@ -697,7 +734,8 @@
 }
     ],
     lp_cv_need_lib_resolv=no,
-    lp_cv_need_lib_resolv=yes
+    lp_cv_need_lib_resolv=yes,
+    lp_cv_need_lib_resolv=no
 ))
 if test "$lp_cv_need_lib_resolv" = "yes"; then
     AC_CHECK_LIB(resolv,main, LIBS="$LIBS -lresolv")
@@ -815,7 +853,8 @@
 }
             ],
             lp_cv_need_lib_inet6=no,
-            lp_cv_need_lib_inet6=yes
+            lp_cv_need_lib_inet6=yes,
+            lp_cv_need_lib_inet6=no
         ))
         if test "$lp_cv_need_lib_inet6" = "yes"; then
             AC_CHECK_LIB(inet6,main, LIBS="$LIBS -linet6")
@@ -885,6 +925,8 @@
     }
                 ],
                 lp_cv_need_lib_ssl=no,
-                lp_cv_need_lib_ssl=yes
+                lp_cv_need_lib_ssl=yes,
+                lp_cv_need_lib_ssl=no
             ))
             if test "$lp_cv_need_lib_ssl" = "yes"; then
@@ -910,6 +951,8 @@
 }
                     ],
                     lp_cv_need_lib_crypto=no,
-                    lp_cv_need_lib_crypto=yes
+                    lp_cv_need_lib_crypto=yes,
+                    lp_cv_need_lib_crypto=no
                 ))
                 if test "$lp_cv_need_lib_crypto" = "yes"; then
@@ -958,6 +1000,8 @@
     }
                 ],
                 lp_cv_need_lib_gnutls=no,
-                lp_cv_need_lib_gnutls=yes
+                lp_cv_need_lib_gnutls=yes,
+                lp_cv_need_lib_gnutls=no
             ))
             if test "$lp_cv_need_lib_gnutls" = "yes"; then
@@ -983,7 +1025,8 @@
     }
                 ],
                 lp_cv_has_gnutls_version=8,
-                lp_cv_has_gnutls_version=7
+                lp_cv_has_gnutls_version=7,
+                lp_cv_has_gnutls_version=8
             ))
             LIBS="$savelibs"
             AC_DEFINE_UNQUOTED(HAS_GNUTLS_VERSION, $lp_cv_has_gnutls_version, [version of GNUTLS library])
@@ -1049,7 +1092,8 @@
 }
         ],
         lp_cv_need_lib_pthread=no,
-        lp_cv_need_lib_pthread=yes
+        lp_cv_need_lib_pthread=yes,
+        lp_cv_need_lib_pthread=no
     ))
     if test "$lp_cv_need_lib_pthread" = "yes"; then
         lp_cv_has_lib_pthread=no
@@ -1076,6 +1120,7 @@
     return 0;
 }
         ],lp_cv_has_pthread_atfork=yes,
+        lp_cv_has_pthread_atfork=no,
         lp_cv_has_pthread_atfork=no
         )
     )
@@ -1120,6 +1165,7 @@
 }
             ],
             lp_cv_has_pcre=yes,
+            lp_cv_has_pcre=no,
             lp_cv_has_pcre=no
         ))
     CFLAGS="$saveflags"
@@ -1234,7 +1280,8 @@
 }
         ],
         lp_cv_need_lib_iconv=no,
-        lp_cv_need_lib_iconv=yes
+        lp_cv_need_lib_iconv=yes,
+        lp_cv_need_lib_iconv=no
     ))
     if test "$lp_cv_need_lib_iconv" = "yes"; then
         # Search the libraries
@@ -1387,7 +1434,8 @@
 }
           ],
           lp_cv_need_lib_z=no,
-          lp_cv_need_lib_z=yes
+          lp_cv_need_lib_z=yes,
+          lp_cv_need_lib_z=no
       ))
       if test "$lp_cv_need_lib_z" = "yes"; then
           AC_CHECK_LIB(z,main, PKGLIBS="$PKGLIBS -lz")
@@ -1408,7 +1456,8 @@
 }
           ],
           lp_cv_need_lib_nsl=no,
-          lp_cv_need_lib_nsl=yes
+          lp_cv_need_lib_nsl=yes,
+          lp_cv_need_lib_nsl=no
       ))
       if test "$lp_cv_need_lib_nsl" = "yes"; then
           AC_CHECK_LIB(nsl,main, PKGLIBS="$PKGLIBS -lnsl")
@@ -1523,6 +1572,7 @@
 }
           ],
           lp_cv_need_lib_ssl=no,
+          lp_cv_need_lib_ssl=yes,
           lp_cv_need_lib_ssl=yes
       ))
       if test "$lp_cv_need_lib_ssl" = "yes"; then
@@ -1543,7 +1593,8 @@
 }
               ],
               lp_cv_need_lib_crypto=no,
-              lp_cv_need_lib_crypto=yes
+              lp_cv_need_lib_crypto=yes,
+              lp_cv_need_lib_crypto=no
           ))
           if test "$lp_cv_need_lib_crypto" = "yes"; then
               AC_CHECK_LIB(crypto,main, PKGLIBS="$PKGLIBS -lcrypto")
@@ -1775,7 +1826,9 @@
 }
 ],
 lp_cv_sys_rename_handles_directories=yes,
-lp_cv_sys_rename_handles_directories=no))
+lp_cv_sys_rename_handles_directories=no,
+lp_cv_sys_rename_handles_directories=yes,
+))
 if test $lp_cv_sys_rename_handles_directories = yes; then
   AC_DEFINE(RENAME_HANDLES_DIRECTORIES, 1, [Can rename handle directories?])
 fi
@@ -1941,7 +1994,9 @@
     exit(0);
 }
 ], lp_cv_prop_strtol_broken=no,
-lp_cv_prop_strtol_broken=yes))
+lp_cv_prop_strtol_broken=yes,
+lp_cv_prop_strtol_broken=no
+))
 if test $lp_cv_prop_strtol_broken = yes; then
   AC_DEFINE(STRTOL_BROKEN, 1, [the atari strtol() used to consider characters '9' < c < 'A' to be numeric])
 fi
@@ -2619,7 +2674,9 @@
     POINTER p;
 { return 1; }
 #endif
-],SBRK_OK=1)
+],SBRK_OK=1,
+  SBRK_OK=0,
+  SBRK_OK=1)
 if test -n "${SBRK_OK}"; then
   if test -z "${TESTFLAG}"; then
     AC_DEFINE(SBRK_OK, 1, [can we define our own malloc() safely?])
@@ -2659,7 +2716,12 @@
 #include "${srcdir}/util/overhead.c"
 EOF
 ${CC-cc} -o conftest conftest.c
-lp_cv_sys_malloc_overhead=`./conftest --terse`
+if test "x$cross_compiling" = "xyes"; then
+  lp_cv_sys_malloc_overhead=0
+  AC_MSG_RESULT("cross compiling, please set it by hand")
+else
+  lp_cv_sys_malloc_overhead=`./conftest --terse`
+fi
 rm -f conftest*
 )
 AC_DEFINE_UNQUOTED(EXTERN_MALLOC_OVERHEAD,$lp_cv_sys_malloc_overhead,                                                                                                                                              
@@ -2707,6 +2769,8 @@
 AC_SUBST(YACCTAB)
 AC_SUBST(CONFIG_SHELL)
 AC_SUBST(EXEEXT)
+AC_SUBST(CC_FOR_BUILD)
+AC_SUBST(EXEEXT_FOR_BUILD)
 
 dnl
 dnl additional replacements:
cross_compiling.diff (10,643 bytes)   

Activities

Issue History

Date Modified Username Field Change
2009-01-16 17:31 peng New Issue
2009-01-16 17:31 peng File Added: cross_compiling.diff
2009-01-16 17:32 peng File Added: build_win_and_linux.sh
2010-02-14 03:32 zesstra Tag Attached: ldmud-extensions