[Mono-list] PATCH: build mono 0.16 on Darwin/MacOSX

Benjamin Reed ranger@befunk.com
10 Oct 2002 14:16:37 -0400


--=-QipnxArUW7jcQ1BVjYdW
Content-Type: text/plain
Content-Transfer-Encoding: 7bit

Attached is a patch to allow the mono 0.16 tarball to build on Darwin
(tested only on Jaguar right now, and only mint, no mono).  I don't know
how much of it will work and/or freak out yet.  It seems that mint runs
now, but it likes to segfault and/or lock up when I try to build the mcs
0.16 tree.  I'm not kung-fu enough to dig into what's going on, so if
there are any OSX lurkers on the list that want to pick this up where I
left off, feel free.  =)

The patch does the following:

1. It adds some settings in configure to use libdl and force cpp to act
unix-y rather than apple-y.  I'm not sure if the NEED_LINK_UNLINK define
needs to be there, but I erred on the side of caution.

2. It adds to configure a check for a working socklen_t even if the
typedef isn't defined in headers, as it isn't on Darwin (blech).

3. It adds powerpc-*-darwin* to the list of powerpc targets.

4. It adds config.h to any headers that use socklen_t so that they can
find the definition made earlier -- 5 or 6 of them I think, mostly in
mono/metadata/.

5. It adds config.h to interp.h so it can find SIZEOF_VOID_P (which was
being defined in config.h on platforms that don't have it in system
headers, like Darwin, but wasn't ever being included)

6. It adds a check in Makefile.am for the scripts/ dir to make it so
that running "mcs" on non-x86 unixes will call mint instead of mono.

Thanks!  Looking forward to playing with mono once it builds on my
system...  =)

--=-QipnxArUW7jcQ1BVjYdW
Content-Disposition: attachment; filename=mono-0.16-darwin.patch
Content-Transfer-Encoding: quoted-printable
Content-Type: text/x-patch; name=mono-0.16-darwin.patch; charset=ISO-8859-15

diff -uNbr mono-0.16/config.h.in mono-0.16-new/config.h.in
--- mono-0.16/config.h.in	Tue Oct  1 17:55:31 2002
+++ mono-0.16-new/config.h.in	Thu Oct 10 13:53:15 2002
@@ -112,3 +112,6 @@
=20
 /* Version number of package */
 #undef VERSION
+
+/* Define the real type of socklen_t */
+#undef socklen_t
diff -uNbr mono-0.16/configure mono-0.16-new/configure
--- mono-0.16/configure	Tue Oct  1 18:13:15 2002
+++ mono-0.16-new/configure	Thu Oct 10 13:50:01 2002
@@ -1780,6 +1780,14 @@
 		CPPFLAGS=3D"$CPPFLAGS -DGC_WIN32_THREADS"
 		libdl=3D
 		;;
+	*-*-*darwin*)
+		platform_win32=3Dno
+		CPPFLAGS=3D"$CPPFLAGS -no-cpp-precomp"
+		cat >>confdefs.h <<\_ACEOF
+#define NEED_LINK_UNLINK 1
+_ACEOF
+		libdl=3D"-ldl"
+		;;
 	*-*-*bsd*)
 		platform_win32=3Dno
 		CPPFLAGS=3D"$CPPFLAGS -D_THREAD_SAFE"
@@ -8756,6 +8764,118 @@
 echo "$as_me: WARNING: No 64 bit file size support available" >&2;}
 	fi
=20
+                                echo "$as_me:$LINENO: checking for socklen=
_t" >&5
+echo $ECHO_N "checking for socklen_t... $ECHO_C" >&6
+        if test "${ac_cv_socklen_t+set}" =3D set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+
+                cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+#include "confdefs.h"
+
+#include <sys/types.h>
+#include <sys/socket.h>
+
+#ifdef F77_DUMMY_MAIN
+#  ifdef __cplusplus
+     extern "C"
+#  endif
+   int F77_DUMMY_MAIN() { return 1; }
+#endif
+int
+main ()
+{
+
+socklen_t a=3D0;
+getsockname(0,(struct sockaddr*)0, &a);
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=3D$?
+  echo "$as_me:$LINENO: \$? =3D $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try=3D'test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=3D$?
+  echo "$as_me:$LINENO: \$? =3D $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_socklen_t=3Dsocklen_t
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+#include "confdefs.h"
+
+#include <sys/types.h>
+#include <sys/socket.h>
+
+#ifdef F77_DUMMY_MAIN
+#  ifdef __cplusplus
+     extern "C"
+#  endif
+   int F77_DUMMY_MAIN() { return 1; }
+#endif
+int
+main ()
+{
+
+int a=3D0;
+getsockname(0,(struct sockaddr*)0, &a);
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=3D$?
+  echo "$as_me:$LINENO: \$? =3D $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try=3D'test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=3D$?
+  echo "$as_me:$LINENO: \$? =3D $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_socklen_t=3Dint
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+ac_cv_socklen_t=3Dsize_t
+
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+
+fi
+
+
+        echo "$as_me:$LINENO: result: $ac_cv_socklen_t" >&5
+echo "${ECHO_T}$ac_cv_socklen_t" >&6
+        if test "$ac_cv_socklen_t" !=3D "socklen_t"; then
+
+cat >>confdefs.h <<_ACEOF
+#define socklen_t $ac_cv_socklen_t
+_ACEOF
+
+        fi
+
+cat >>confdefs.h <<_ACEOF
+#define ksize_t socklen_t
+_ACEOF
+
+
 				echo "$as_me:$LINENO: checking for socket in -lsocket" >&5
 echo $ECHO_N "checking for socket in -lsocket... $ECHO_C" >&6
 if test "${ac_cv_lib_socket_socket+set}" =3D set; then
@@ -9901,7 +10021,7 @@
 sparc*-*-*) TARGET=3DSPARC; arch_target=3Dsparc; ACCESS_UNALIGNED=3D"no";;
 #alpha*-*-linux* | alpha*-*-osf*) TARGET=3DALPHA; ACCESS_UNALIGNED=3D"no";=
;
 #m68k-*-linux*) TARGET=3DM68K;;
-macppc-*-openbsd* | powerpc-*-linux* | powerpc-*-openbsd* | powerpc-*-sysv=
*) TARGET=3DPOWERPC; arch_target=3Dppc;;
+powerpc-*-darwin* | macppc-*-openbsd* | powerpc-*-linux* | powerpc-*-openb=
sd* | powerpc-*-sysv*) TARGET=3DPOWERPC; arch_target=3Dppc;;
 arm-*-linux-* | armv4l-*-linux-*) TARGET=3DARM; arch_target=3Darm; ACCESS_=
UNALIGNED=3D"no";;
 esac
=20
diff -uNbr mono-0.16/configure.in mono-0.16-new/configure.in
--- mono-0.16/configure.in	Tue Oct  1 17:32:16 2002
+++ mono-0.16-new/configure.in	Thu Oct 10 13:45:22 2002
@@ -15,6 +15,12 @@
 		CPPFLAGS=3D"$CPPFLAGS -DGC_WIN32_THREADS"
 		libdl=3D
 		;;
+	*-*-*darwin*)
+		platform_win32=3Dno
+		CPPFLAGS=3D"$CPPFLAGS -no-cpp-precomp"
+		AC_DEFINE(NEED_LINK_UNLINK)
+		libdl=3D"-ldl"
+		;;
 	*-*-*bsd*)
 		platform_win32=3Dno
 		CPPFLAGS=3D"$CPPFLAGS -D_THREAD_SAFE"
@@ -203,6 +209,40 @@
 	fi
 =09
 	dnl *****************************
+	dnl *** Checks for socklen_t  ***
+	dnl *****************************
+	AC_MSG_CHECKING(for socklen_t)
+	AC_CACHE_VAL(ac_cv_socklen_t, [
+		AC_TRY_COMPILE([
+#include <sys/types.h>
+#include <sys/socket.h>
+			],[
+socklen_t a=3D0;
+getsockname(0,(struct sockaddr*)0, &a);
+			],
+			ac_cv_socklen_t=3Dsocklen_t,
+			AC_TRY_COMPILE([
+#include <sys/types.h>
+#include <sys/socket.h>
+				],[
+int a=3D0;
+getsockname(0,(struct sockaddr*)0, &a);
+				],
+				ac_cv_socklen_t=3Dint,
+				ac_cv_socklen_t=3Dsize_t
+			)
+		)
+		AC_LANG_RESTORE
+	])
+
+	AC_MSG_RESULT($ac_cv_socklen_t)
+	if test "$ac_cv_socklen_t" !=3D "socklen_t"; then
+		AC_DEFINE_UNQUOTED(socklen_t, $ac_cv_socklen_t,
+			[Define the real type of socklen_t])
+	fi
+	AC_DEFINE_UNQUOTED(ksize_t, socklen_t, [Compatibility define])
+
+	dnl *****************************
 	dnl *** Checks for libsocket  ***
 	dnl *****************************
 	AC_CHECK_LIB(socket, socket, LIBS=3D"$LIBS -lsocket")
@@ -469,7 +509,7 @@
 sparc*-*-*) TARGET=3DSPARC; arch_target=3Dsparc; ACCESS_UNALIGNED=3D"no";;
 #alpha*-*-linux* | alpha*-*-osf*) TARGET=3DALPHA; ACCESS_UNALIGNED=3D"no";=
;
 #m68k-*-linux*) TARGET=3DM68K;;
-macppc-*-openbsd* | powerpc-*-linux* | powerpc-*-openbsd* | powerpc-*-sysv=
*) TARGET=3DPOWERPC; arch_target=3Dppc;;
+powerpc-*-darwin* | macppc-*-openbsd* | powerpc-*-linux* | powerpc-*-openb=
sd* | powerpc-*-sysv*) TARGET=3DPOWERPC; arch_target=3Dppc;;
 arm-*-linux-* | armv4l-*-linux-*) TARGET=3DARM; arch_target=3Darm; ACCESS_=
UNALIGNED=3D"no";;
 esac
=20
diff -uNbr mono-0.16/mono/interpreter/interp.h mono-0.16-new/mono/interpret=
er/interp.h
--- mono-0.16/mono/interpreter/interp.h	Fri Aug  2 07:02:35 2002
+++ mono-0.16-new/mono/interpreter/interp.h	Thu Oct 10 13:35:35 2002
@@ -1,4 +1,4 @@
-
+#include <config.h>
 #include <glib.h>
 #include <mono/metadata/loader.h>
 #include <mono/metadata/object.h>
diff -uNbr mono-0.16/mono/io-layer/Makefile.am mono-0.16-new/mono/io-layer/=
Makefile.am
--- mono-0.16/mono/io-layer/Makefile.am	Thu Aug  1 08:15:41 2002
+++ mono-0.16-new/mono/io-layer/Makefile.am	Thu Oct 10 13:35:35 2002
@@ -5,7 +5,8 @@
 	$(GMODULE_CFLAGS)	\
 	-D_WAPI_BUILDING=3D1	\
 	-DMONO_BINDIR=3D\""$(bindir)"\"	\
-	-I$(top_srcdir)=09
+	-I$(top_srcdir)		\
+	-I$(prefix)/include
=20
 libwapiincludedir =3D $(includedir)/mono/io-layer
=20
diff -uNbr mono-0.16/mono/io-layer/Makefile.in mono-0.16-new/mono/io-layer/=
Makefile.in
--- mono-0.16/mono/io-layer/Makefile.in	Tue Oct  1 18:31:17 2002
+++ mono-0.16-new/mono/io-layer/Makefile.in	Thu Oct 10 13:35:35 2002
@@ -103,7 +103,8 @@
 	$(GMODULE_CFLAGS)	\
 	-D_WAPI_BUILDING=3D1	\
 	-DMONO_BINDIR=3D\""$(bindir)"\"	\
-	-I$(top_srcdir)=09
+	-I$(top_srcdir)	\
+	-I$(prefix)/include
=20
=20
 libwapiincludedir =3D $(includedir)/mono/io-layer
diff -uNbr mono-0.16/mono/metadata/decimal.c mono-0.16-new/mono/metadata/de=
cimal.c
--- mono-0.16/mono/metadata/decimal.c	Fri May 31 06:14:30 2002
+++ mono-0.16-new/mono/metadata/decimal.c	Thu Oct 10 13:57:11 2002
@@ -13,6 +13,7 @@
  * CSharp value type System.Decimal
  */
=20
+#include <config.h>
 #include <stdio.h>
 #include <memory.h>
 #include <stdlib.h>
diff -uNbr mono-0.16/mono/metadata/exception.c mono-0.16-new/mono/metadata/=
exception.c
--- mono-0.16/mono/metadata/exception.c	Wed Aug 14 12:08:11 2002
+++ mono-0.16-new/mono/metadata/exception.c	Thu Oct 10 13:58:15 2002
@@ -10,6 +10,7 @@
  * (C) 2001, 2002 Ximian, Inc.
  */
=20
+#include <config.h>
 #include <mono/metadata/exception.h>
 #include <mono/metadata/class.h>
 #include <mono/metadata/appdomain.h>
diff -uNbr mono-0.16/mono/metadata/monosn.c mono-0.16-new/mono/metadata/mon=
osn.c
--- mono-0.16/mono/metadata/monosn.c	Tue Sep 24 05:31:42 2002
+++ mono-0.16-new/mono/metadata/monosn.c	Thu Oct 10 13:59:45 2002
@@ -7,6 +7,7 @@
  * (C) 2002 Ximian, Inc.
  *
  */
+#include <config.h>
 #include <mono/metadata/class.h>
 #include <mono/metadata/debug-helpers.h>
 #include <mono/metadata/tokentype.h>
diff -uNbr mono-0.16/mono/metadata/profiler.c mono-0.16-new/mono/metadata/p=
rofiler.c
--- mono-0.16/mono/metadata/profiler.c	Sat Aug 24 13:29:06 2002
+++ mono-0.16-new/mono/metadata/profiler.c	Thu Oct 10 13:59:20 2002
@@ -1,4 +1,5 @@
=20
+#include <config.h>
 #include "mono/metadata/profiler-private.h"
 #include "mono/metadata/debug-helpers.h"
 #include <string.h>
diff -uNbr mono-0.16/mono/metadata/verify.c mono-0.16-new/mono/metadata/ver=
ify.c
--- mono-0.16/mono/metadata/verify.c	Mon Sep 16 13:07:44 2002
+++ mono-0.16-new/mono/metadata/verify.c	Thu Oct 10 13:56:36 2002
@@ -1,4 +1,4 @@
-
+#include <config.h>
 #include <mono/metadata/object.h>
 #include <mono/metadata/verify.h>
 #include <mono/metadata/opcodes.h>
diff -uNbr mono-0.16/mono/monograph/monograph.c mono-0.16-new/mono/monograp=
h/monograph.c
--- mono-0.16/mono/monograph/monograph.c	Fri Jul 19 08:25:53 2002
+++ mono-0.16-new/mono/monograph/monograph.c	Thu Oct 10 14:01:27 2002
@@ -1,3 +1,4 @@
+#include <config.h>
 #include <glib.h>
 #include <string.h>
 #include "mono/metadata/class.h"
diff -uNbr mono-0.16/scripts/Makefile.am mono-0.16-new/scripts/Makefile.am
--- mono-0.16/scripts/Makefile.am	Fri Feb 15 05:12:19 2002
+++ mono-0.16-new/scripts/Makefile.am	Thu Oct 10 13:35:35 2002
@@ -4,6 +4,12 @@
=20
 CLEANFILES =3D mcs
=20
+if X86
+MONO_INTERP =3D mono
+else
+MONO_INTERP =3D mint
+endif
+
 mcs: mcs.in
-	sed -e 's^\@bindir\@^$(bindir)^g' < $(srcdir)/mcs.in > mcs.tmp \
+	sed -e 's^\@bindir\@^$(bindir)^g' -e 's^\@mono_interp\@^$(MONO_INTERP)^g'=
 < $(srcdir)/mcs.in > mcs.tmp \
 	&& mv mcs.tmp mcs=20
diff -uNbr mono-0.16/scripts/Makefile.in mono-0.16-new/scripts/Makefile.in
--- mono-0.16/scripts/Makefile.in	Tue Oct  1 18:31:28 2002
+++ mono-0.16-new/scripts/Makefile.in	Thu Oct 10 13:35:35 2002
@@ -106,6 +106,9 @@
 CONFIG_CLEAN_FILES =3D=20
 SCRIPTS =3D  $(bin_SCRIPTS)
=20
+@X86_TRUE@MONO_INTERP =3D mono
+@X86_FALSE@MONO_INTERP =3D mint
+
 DIST_COMMON =3D  Makefile.am Makefile.in
=20
=20
diff -uNbr mono-0.16/scripts/mcs.in mono-0.16-new/scripts/mcs.in
--- mono-0.16/scripts/mcs.in	Tue May  7 13:37:37 2002
+++ mono-0.16-new/scripts/mcs.in	Thu Oct 10 13:35:35 2002
@@ -1,2 +1,2 @@
 #!/bin/sh
-@bindir@/mono @bindir@/mcs.exe "$@"
+@bindir@/@mono_interp@ @bindir@/mcs.exe "$@"

--=-QipnxArUW7jcQ1BVjYdW--