--- bin/mlton	2007-08-30 07:10:03.000000000 +0800
+++ bin/mlton	2023-07-21 01:57:07.000000000 +0800
@@ -5,9 +5,9 @@
 set -e
 
 dir=`dirname "$0"`
-lib='/usr/local/lib/mlton'
+lib='@MLTON@'
 eval `"$lib/platform"`
-gcc='gcc'
+gcc='@CC@'
 case "$HOST_OS" in
 mingw)
 	exe='.exe'

--- bin/mlton	2023-07-21 22:12:12.000000000 +0800
+++ bin/mlton	2023-07-21 22:20:42.000000000 +0800
@@ -83,11 +83,8 @@
 # The darwin linker complains (loudly) about non-existent library
 # search paths.
 darwinLinkOpts=''
-if [ -d '/usr/local/lib' ]; then
-        darwinLinkOpts="$darwinLinkOpts -L/usr/local/lib"
-fi
-if [ -d '/opt/local/lib' ]; then
-        darwinLinkOpts="$darwinLinkOpts -L/opt/local/lib"
+if [ -d '@PREFIX@/lib' ]; then
+        darwinLinkOpts="$darwinLinkOpts -L@PREFIX@/lib"
 fi
 if [ -d '/sw/lib' ]; then
         darwinLinkOpts="$darwinLinkOpts -L/sw/lib"
@@ -107,8 +104,7 @@
                 '-mieee -mbwx -mtune=ev6 -mfp-rounding-mode=d'   \
         -target-cc-opt amd64 '-m64'                              \
         -target-cc-opt darwin                                    \
-                '-I/usr/local/include
-                 -I/opt/local/include
+                '-I@PREFIX@/include
                  -I/sw/include'                                  \
         -target-cc-opt freebsd '-I/usr/local/include'            \
         -target-cc-opt netbsd '-I/usr/pkg/include'               \

--- lib/mlton/include/platform/darwin.h	2010-06-08 23:00:43.000000000 +0800
+++ lib/mlton/include/platform/darwin.h	2023-07-21 22:27:28.000000000 +0800
@@ -1,3 +1,7 @@
+#ifndef __STDC_FORMAT_MACROS
+#define __STDC_FORMAT_MACROS
+#endif
+
 #include <fenv.h>
 #include <inttypes.h>
 #include <stdint.h>
@@ -27,6 +31,11 @@
 #include <sys/wait.h>
 #include <syslog.h>
 #include <termios.h>
+
+#ifndef _XOPEN_SOURCE
+#define _XOPEN_SOURCE /* In order for <ucontext.h> to work. */
+#endif
+
 #include <sys/ucontext.h>
 #include <utime.h>
 
