diff -ruN /opt/local/var/macports/sources/rsync.macports.org/release/ports/lang/ocaml/Portfile lang/ocaml/Portfile
--- /opt/local/var/macports/sources/rsync.macports.org/release/ports/lang/ocaml/Portfile	2009-01-28 02:23:55.000000000 +0100
+++ lang/ocaml/Portfile	2009-04-13 15:40:52.000000000 +0200
@@ -1,81 +1,88 @@
-# $Id: Portfile 46051 2009-01-28 01:23:55Z mcalhoun@macports.org $
+# $Id: Portfile 41305 2008-10-30 08:01:18Z pguyot@kallisys.net $
 
-PortSystem		1.0
+PortSystem      1.0
 
-name 			ocaml
-version			3.11.0
-set major_vers	[join [lrange [split ${version} .] 0 1] .]
-platforms		darwin
-maintainers		pguyot@kallisys.net openmaintainer
-categories		lang ml
-description		Objective Caml is an implementation of the ML language
-homepage		http://www.ocaml.org/
-master_sites	http://caml.inria.fr/pub/distrib/ocaml-${major_vers}/
+name            ocaml
+version         3.11.0
+revision        1
+set major_vers  [join [lrange [split ${version} .] 0 1] .]
+platforms       darwin
+maintainers     pguyot@kallisys.net openmaintainer
+categories      lang ml
+description     Objective Caml is an implementation of the ML language
+homepage        http://www.ocaml.org/
+master_sites    http://caml.inria.fr/pub/distrib/ocaml-${major_vers}/
 checksums       ocaml-${version}.tar.bz2 \
-					md5 6ed1c3ed660a15408362242fa8fa4668 \
-					sha1 fed19b82828789b8c509049590f0b82f8e5e6eb3 \
-					rmd160 06f367eacfa3f4d413138fc2386bf3b1ee822cf6 \
-				ocaml-3.11-refman.html.tar.gz \
-					md5 bfb4ed960974159f4224014a979baf6d \
-					sha1 97159cf3d4ea64d0ca03f04997fdfc00982d22b0 \
-					rmd160 8d77630ee0c3dcdae1ef142a59eb876271f1c335
+                    md5     6ed1c3ed660a15408362242fa8fa4668 \
+                    sha1    fed19b82828789b8c509049590f0b82f8e5e6eb3 \
+                    rmd160  06f367eacfa3f4d413138fc2386bf3b1ee822cf6 \
+                ocaml-3.11-refman.html.tar.gz \
+                    md5     bfb4ed960974159f4224014a979baf6d \
+                    sha1    97159cf3d4ea64d0ca03f04997fdfc00982d22b0 \
+                    rmd160  8d77630ee0c3dcdae1ef142a59eb876271f1c335
 
 long_description \
-			Objective Caml is an implementation of the ML language, based on \
-			the Caml Light dialect extended with a complete class-based object \
-			system	and a powerful module system in the style of Standard ML.
+            Objective Caml is an implementation of the ML language, based on \
+            the Caml Light dialect extended with a complete class-based object \
+            system    and a powerful module system in the style of Standard ML.
 
-use_bzip2			yes
-use_parallel_build	no
+use_bzip2            yes
+use_parallel_build    no
 universal_variant   no
 
-set doc_distname	${name}-${major_vers}-refman
-set docdir			${prefix}/share/doc/${name}-${version}
+set doc_distname    ${name}-${major_vers}-refman
+set docdir            ${prefix}/share/doc/${name}-${version}
+
+patchfiles          ocaml-threads-fork.diff
+
+platform darwin 9 {
+    macosx_deployment_target    10.4
+}
 
 # Configure.
-configure.pre_args	-prefix ${prefix}
-configure.args		-no-tk -cc ${configure.cc} -aspp \"${configure.cc} -c\"
+configure.pre_args    -prefix ${prefix}
+configure.args        -no-tk
 
 # Building.
-build.target		world.opt
+build.target        world.opt
 build.cmd           "unset LD_PREBIND LD_PREBIND_ALLOW_OVERLAP && ${build.cmd}"
 
 # Install.
-destroot.target		install
-destroot.destdir	BINDIR=${destroot}${prefix}/bin \
-					LIBDIR=${destroot}${prefix}/lib/ocaml \
-					MANDIR=${destroot}${prefix}/share/man
+destroot.target        install
+destroot.destdir    BINDIR=${destroot}${prefix}/bin \
+                    LIBDIR=${destroot}${prefix}/lib/ocaml \
+                    MANDIR=${destroot}${prefix}/share/man
 
 post-destroot {
-	# Change "ld.conf" to remove ${destroot} in paths.
-	reinplace "s:${destroot}::g" ${destroot}${prefix}/lib/ocaml/ld.conf
+    # Change "ld.conf" to remove ${destroot} in paths.
+    reinplace "s:${destroot}::g" ${destroot}${prefix}/lib/ocaml/ld.conf
 }
 
 # Variants.
 variant labltk {
-	depends_lib		lib:tcl8.4:tcl lib:tk8.4:tk
-	configure.args-delete 	-no-tk
+    depends_lib        lib:tcl8.4:tcl lib:tk8.4:tk
+    configure.args-delete     -no-tk
 }
 
 variant doc description {Install extra documentation} {
-	extract.only        ${distfiles}
-	distfiles-append    ${doc_distname}.html.tar.gz
+    extract.only        ${distfiles}
+    distfiles-append    ${doc_distname}.html.tar.gz
 
-	post-extract {
-		system "tar xzvf ${distpath}/${doc_distname}.html.tar.gz -C ${workpath}"
-	}
-
-	post-destroot {
-		xinstall -d ${destroot}${docdir}
-		xinstall -m 0644 -W ${worksrcpath} Changes LICENSE README ${destroot}${docdir}
-		xinstall -d ${destroot}${docdir}/html/libref
-		eval xinstall -m 0644 [glob ${workpath}/htmlman/libref/*] \
-			${destroot}${docdir}/html/libref
-		eval xinstall -m 0644 [glob ${workpath}/htmlman/*.*] \
-			${destroot}${docdir}/html
-	}
+    post-extract {
+        system "tar xzvf ${distpath}/${doc_distname}.html.tar.gz -C ${workpath}"
+    }
+
+    post-destroot {
+        xinstall -d ${destroot}${docdir}
+        xinstall -m 0644 -W ${worksrcpath} Changes LICENSE README ${destroot}${docdir}
+        xinstall -d ${destroot}${docdir}/html/libref
+        eval xinstall -m 0644 [glob ${workpath}/htmlman/libref/*] \
+            ${destroot}${docdir}/html/libref
+        eval xinstall -m 0644 [glob ${workpath}/htmlman/*.*] \
+            ${destroot}${docdir}/html
+    }
 }
 
-livecheck.check	regex
-livecheck.url	http://caml.inria.fr/news.en.rss
-livecheck.regex	"<title>Objective Caml (.*) released"
+livecheck.check    regex
+livecheck.url    http://caml.inria.fr/news.en.rss
+livecheck.regex    "<title>Objective Caml (.*) released"
diff -ruN /opt/local/var/macports/sources/rsync.macports.org/release/ports/lang/ocaml/files/ocaml-threads-fork.diff lang/ocaml/files/ocaml-threads-fork.diff
--- /opt/local/var/macports/sources/rsync.macports.org/release/ports/lang/ocaml/files/ocaml-threads-fork.diff	1970-01-01 01:00:00.000000000 +0100
+++ lang/ocaml/files/ocaml-threads-fork.diff	2009-04-13 15:40:52.000000000 +0200
@@ -0,0 +1,111 @@
+--- otherlibs/systhreads/posix.c.orig	2008-09-27 11:46:55.000000000 +0100
++++ otherlibs/systhreads/posix.c	2009-03-02 21:30:34.000000000 +0000
+@@ -11,7 +11,7 @@
+ /*                                                                     */
+ /***********************************************************************/
+ 
+-/* $Id: posix.c,v 1.58 2008/09/27 10:46:55 xleroy Exp $ */
++/* $Id: posix.c,v 1.58.2.1 2008-12-14 18:16:38 xleroy Exp $ */
+ 
+ /* Thread interface for POSIX 1003.1c threads */
+ 
+@@ -111,6 +111,9 @@
+ /* Condition signaled when caml_runtime_busy becomes 0 */
+ static pthread_cond_t caml_runtime_is_free = PTHREAD_COND_INITIALIZER;
+ 
++/* Whether the ``tick'' thread is already running */
++static int caml_tick_thread_running = 0;
++
+ /* The key used for storing the thread descriptor in the specific data
+    of the corresponding Posix thread. */
+ static pthread_key_t thread_descriptor_key;
+@@ -332,8 +335,6 @@
+ static void caml_thread_reinitialize(void)
+ {
+   caml_thread_t thr, next;
+-  pthread_t tick_pthread;
+-  pthread_attr_t attr;
+   struct channel * chan;
+ 
+   /* Remove all other threads (now nonexistent)
+@@ -353,24 +354,21 @@
+   pthread_cond_init(&caml_runtime_is_free, NULL);
+   caml_runtime_waiters = 0;     /* no other thread is waiting for the RTS */
+   caml_runtime_busy = 1;        /* normally useless */
++  /* Tick thread is not currently running in child process, will be
++     re-created at next Thread.create */
++  caml_tick_thread_running = 0;
+   /* Reinitialize all IO mutexes */
+   for (chan = caml_all_opened_channels;
+        chan != NULL;
+        chan = chan->next) {
+     if (chan->mutex != NULL) pthread_mutex_init(chan->mutex, NULL);
+   }
+-  /* Fork a new tick thread */
+-  pthread_attr_init(&attr);
+-  pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
+-  pthread_create(&tick_pthread, &attr, caml_thread_tick, NULL);
+ }
+ 
+ /* Initialize the thread machinery */
+ 
+ value caml_thread_initialize(value unit)   /* ML */
+ {
+-  pthread_t tick_pthread;
+-  pthread_attr_t attr;
+   value mu = Val_unit;
+   value descr;
+ 
+@@ -415,12 +413,6 @@
+     caml_channel_mutex_lock = caml_io_mutex_lock;
+     caml_channel_mutex_unlock = caml_io_mutex_unlock;
+     caml_channel_mutex_unlock_exn = caml_io_mutex_unlock_exn;
+-    /* Fork the tick thread */
+-    pthread_attr_init(&attr);
+-    pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
+-    caml_pthread_check(
+-        pthread_create(&tick_pthread, &attr, caml_thread_tick, NULL),
+-        "Thread.init");
+     /* Set up fork() to reinitialize the thread machinery in the child
+        (PR#4577) */
+     pthread_atfork(NULL, NULL, caml_thread_reinitialize);
+@@ -488,6 +480,7 @@
+ {
+   pthread_attr_t attr;
+   caml_thread_t th;
++  pthread_t tick_pthread;
+   value mu = Val_unit;
+   value descr;
+   int err;
+@@ -526,12 +519,12 @@
+     th->prev = curr_thread;
+     curr_thread->next->prev = th;
+     curr_thread->next = th;
+-    /* Fork the new thread */
++    /* Create the new thread */
+     pthread_attr_init(&attr);
+     pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
+     err = pthread_create(&th->pthread, &attr, caml_thread_start, (void *) th);
+     if (err != 0) {
+-      /* Fork failed, remove thread info block from list of threads */
++      /* Creation failed, remove thread info block from list of threads */
+       th->next->prev = curr_thread;
+       curr_thread->next = th->next;
+ #ifndef NATIVE_CODE
+@@ -541,6 +534,16 @@
+       caml_pthread_check(err, "Thread.create");
+     }
+   End_roots();
++  /* Create the tick thread if not already done.  
++     Because of PR#4666, we start the tick thread late, only when we create
++     the first additional thread in the current process*/
++  if (! caml_tick_thread_running) {
++    caml_tick_thread_running = 1;
++    pthread_attr_init(&attr);
++    pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
++    err = pthread_create(&tick_pthread, &attr, caml_thread_tick, NULL);
++    caml_pthread_check(err, "Thread.create");
++  }
+   return descr;
+ }
+ 

