aboutsummaryrefslogtreecommitdiff
path: root/lang/smlnj
diff options
context:
space:
mode:
authorKurt Jaeger <pi@FreeBSD.org>2014-07-30 19:42:50 +0000
committerKurt Jaeger <pi@FreeBSD.org>2014-07-30 19:42:50 +0000
commite49a2b510bb92aad6ed9c13ba726e27d72c58550 (patch)
treec10fde69e14ac19ce1d4153f198c2cbaeec7234d /lang/smlnj
parent460a00fdfda6713fb5c5067f7d20943448c8ffe8 (diff)
lang/smlnj: 110.71 -> 110.76
- unbreak and support staging - support amd64 - no longer depends on gmake - moves lang/sml-nj-devel to lang/smlnj - supersedes lang/sml-nj PR: 191899 Reviewed by: Robert Cina <transitive@gmail.com>, Timothy Beyer <beyert@cs.ucr.edu> Approved by: Johannes <joemann@beefree.free.de> (maintainer)
Notes
Notes: svn path=/head/; revision=363509
Diffstat (limited to 'lang/smlnj')
-rw-r--r--lang/smlnj/Makefile388
-rw-r--r--lang/smlnj/distinfo40
-rw-r--r--lang/smlnj/files/do-patch-base_runtime_objs_makefile43
-rw-r--r--lang/smlnj/files/do-patch-base_runtime_objs_mk.x86-freebsd37
-rw-r--r--lang/smlnj/files/extra-patch-base_runtime_c-libs_smlnj-math_ctlrndmode.c22
-rw-r--r--lang/smlnj/files/extra-patch-base_runtime_include_freebsd-8-i386-__types.h137
-rw-r--r--lang/smlnj/files/extra-patch-base_runtime_include_freebsd-8-i386-endian.h139
-rw-r--r--lang/smlnj/files/extra-patch-base_runtime_include_freebsd-8-i386-ieeefp.h262
-rw-r--r--lang/smlnj/files/extra-patch-base_runtime_include_freebsd-8-i386-signal.h137
-rw-r--r--lang/smlnj/files/extra-patch-base_runtime_include_freebsd-9-i386-__types.h131
-rw-r--r--lang/smlnj/files/extra-patch-base_runtime_include_freebsd-9-i386-endian.h148
-rw-r--r--lang/smlnj/files/extra-patch-base_runtime_include_ml-unixdep.h18
-rw-r--r--lang/smlnj/files/patch-config___arch-n-opsys11
-rw-r--r--lang/smlnj/files/patch-config___heap2exec33
-rw-r--r--lang/smlnj/files/patch-config_install.sh180
-rw-r--r--lang/smlnj/files/pkg-install.in589
-rw-r--r--lang/smlnj/pkg-descr12
-rw-r--r--lang/smlnj/pkg-plist337
18 files changed, 2664 insertions, 0 deletions
diff --git a/lang/smlnj/Makefile b/lang/smlnj/Makefile
new file mode 100644
index 000000000000..914103d2cbe6
--- /dev/null
+++ b/lang/smlnj/Makefile
@@ -0,0 +1,388 @@
+# $FreeBSD$
+
+PORTNAME= smlnj
+PORTVERSION= 110.76
+CATEGORIES= lang
+MASTER_SITES= http://smlnj.cs.uchicago.edu/dist/working/${PORTVERSION}/ \
+ ftp://mirror.free.de/http/smlnj.cs.uchicago.edu/dist/working/${PORTVERSION}/
+DISTFILES= config.tgz runtime.tgz
+DIST_SUBDIR= smlnj/${PORTVERSION}
+EXTRACT_ONLY= config.tgz
+
+MAINTAINER= joemann@beefree.free.de
+COMMENT= Compiler and tools for Standard ML (SML '97)
+
+NO_WRKSUBDIR= yes
+
+SUB_FILES= pkg-install
+SUB_LIST= EXEBINDIR=${MLBINRELATIVE} EXENAMES="${MLEXE}"
+PKGDEINSTALL= ${PKGINSTALL}
+
+# Calm portlint
+CALM=
+
+OPTIONS_RADIO= RG1
+OPTIONS_RADIO_RG1= EVERYTHING RECOMPILE POSITION64
+OPTIONS_EXCLUDE_amd64= RECOMPILE POSITION64
+EVERYTHING_DESC= install${CALM} everything from the SML/NJ distribution
+RECOMPILE_DESC= recompile the SML compiler - implies EVERYTHING
+POSITION64_DESC= use 64bit file${CALM} positions - implies RECOMPILE
+
+.include <bsd.port.pre.mk>
+
+# Recompiling the compiler currently fails on amd64
+.if ${ARCH} == "i386"
+ML_RECOMPILE_OPTIONS= RECOMPILE POSITION64
+.endif
+
+.if (${ARCH} == "amd64") && (${OSVERSION} >= 1000029)
+ONLY_FOR_ARCHS= i386 amd64
+.elif (${ARCH} == "amd64") && (${OSVERSION} >= 800000)
+ONLY_FOR_ARCHS= i386 amd64
+# Compilation of the i386 runtime source on older amd64 systems requires
+# i386 system headers from the respective FreeBSD Version, taken from
+# stable/N/sys/i386/include, r196045 (N=8) and r225736 (N=9).
+EXTRA_DEFS+= -DINCLUDE_FREEBSD_I386_SIGNAL=\\\"freebsd-8-i386-signal.h\\\"
+EXTRA_DEFS+= -DINCLUDE_FREEBSD_I386_IEEEFP=\\\"freebsd-8-i386-ieeefp.h\\\"
+.if (${OSVERSION} < 900000)
+EXTRA_DEFS+= -DINCLUDE_FREEBSD_I386__TYPES=\\\"freebsd-8-i386-_types.h\\\"
+EXTRA_DEFS+= -DINCLUDE_FREEBSD_I386_ENDIAN=\\\"freebsd-8-i386-endian.h\\\"
+.else
+EXTRA_DEFS+= -DINCLUDE_FREEBSD_I386__TYPES=\\\"freebsd-9-i386-_types.h\\\"
+EXTRA_DEFS+= -DINCLUDE_FREEBSD_I386_ENDIAN=\\\"freebsd-9-i386-endian.h\\\"
+.endif
+.else
+ONLY_FOR_ARCHS= i386
+.endif
+
+.if (${ARCH} == "amd64")
+CFLAGS+= -m32
+AS?= as
+AS+= --32
+.endif
+.if (${ARCH} == "i386" || ${ARCH} == "amd64")
+MLARCH= x86
+DISTFILES+= boot.x86-unix.tgz
+.endif
+DISTFILES+= MLRISC.tgz ckit.tgz cml.tgz heap2asm.tgz ml-burg.tgz \
+ ml-lpt.tgz ml-lex.tgz ml-yacc.tgz nlffi.tgz \
+ smlnj-lib.tgz trace-debug-profile.tgz
+
+PLIST_SUB= MLARCH=${MLARCH}
+
+.if ${PORT_OPTIONS:MPOSITION64} || defined(ML_POSITION64)
+ML_POSITION64?= ${PORT_OPTIONS:MPOSITION64}
+ML_RECOMPILE?= ${ML_POSITION64}
+ML_EVERYTHING?= ${ML_POSITION64}
+CMB_COMMAND= '(\#set o CMB.symval) "USE_64_BIT_POSITIONS" (SOME 1);'
+.else
+CMB_COMMAND=
+.endif
+
+.if ${PORT_OPTIONS:MRECOMPILE} || defined(ML_RECOMPILE)
+ML_RECOMPILE?= ${PORT_OPTIONS:MRECOMPILE}
+ML_EVERYTHING?= ${ML_RECOMPILE}
+.endif
+
+.if ${PORT_OPTIONS:MEVERYTHING} || defined(ML_EVERYTHING)
+ML_EVERYTHING?= ${PORT_OPTIONS:MEVERYTHING}
+DISTFILES+= cm.tgz compiler.tgz eXene.tgz \
+ pgraph.tgz smlnj-c.tgz system.tgz
+PLIST_SUB+= EVERYTHING=""
+.else
+PLIST_SUB+= EVERYTHING="@comment "
+.endif
+
+MLROOTRELATIVE= smlnj
+MLROOT= ${PREFIX}/${MLROOTRELATIVE}
+MLBINRELATIVE= ${MLROOTRELATIVE}/bin
+MLBIN= ${MLROOT}/bin
+MLLIB= ${MLROOT}/lib
+MLSTDSRCDIRS= cml heap2asm ml-burg ml-lex ml-lpt ml-yacc nlffi smlnj-lib
+MLSRCDIRS= base ${MLSTDSRCDIRS} \
+ ckit eXene pgraph smlnj-c
+MLSRCS=
+.for srcdir in ${MLSRCDIRS}
+MLSRCS+= ${MLROOT}/${srcdir}
+.endfor
+MLTARGETS= heap2asm
+MLEXE= heap2exec ml-antlr ml-build ml-burg ml-lex ml-makedepend \
+ ml-nlffigen ml-ulex ml-yacc sml
+.if defined(ML_EVERYTHING)
+MLTARGETS+= eXene mlrisc-tools nowhere pgraph-util src-smlnj
+MLEXE+= nowhere
+PLIST= ${WRKDIR}/.PLIST
+MLRUNTIMEPLIST= ${WRKDIR}/.PLIST-runtime
+MLSRCPLIST= ${WRKDIR}/.PLIST-src
+MLPLISTFILES= ${.CURDIR}/pkg-plist ${MLRUNTIMEPLIST} ${MLSRCPLIST}
+.endif
+
+pre-fetch:
+ @${ECHO}
+.if ! defined(ML_EVERYTHING)
+ @${ECHO} 'Use make ML_EVERYTHING=yes to also build/install'
+ @${ECHO} ' eXene (X Windows toolkit),'
+ @${ECHO} ' nowhere (preprocessor for conditional patterns),'
+ @${ECHO} ' various libraries, and all the sources.'
+.endif
+.if !empty(ML_RECOMPILE_OPTIONS:MRECOMPILE) && !defined(ML_RECOMPILE)
+ @${ECHO} 'Use make ML_RECOMPILE=yes to recompile the compiler.'
+ @${ECHO} ' This implies ML_EVERYTHING.'
+.endif
+.if !empty(ML_RECOMPILE_OPTIONS:MPOSITION64) && !defined(ML_POSITION64)
+ @${ECHO} 'Use make ML_POSITION64=yes to use 64bit file positions.'
+ @${ECHO} ' This implies ML_RECOMPILE.'
+.endif
+ @${ECHO}
+
+# make symlinks to the dist files
+
+post-extract:
+ cd ${WRKDIR} && ${LN} -sf ${_DISTDIR}/* .
+
+# Configuring is done by uncommenting the appropriate #request
+# lines of config/targets. Dependency details are handled by
+# base/system/smlnj/installer using config/dependencies and
+# config/actions.
+
+do-configure:
+.if defined(MLTARGETS)
+ ${ECHO_CMD} -n > "${WRKDIR}/.tmp.sed"
+.for t in ${MLTARGETS}
+ ${ECHO_CMD} '/^#request[ ]+${t}$$/s/^#//' >> "${WRKDIR}/.tmp.sed"
+.endfor
+ ${SED} -i .default -E -f "${WRKDIR}/.tmp.sed" "${WRKDIR}/config/targets"
+.endif
+# Recompilation requires ml-lex and ml-yacc. All requested targets
+# will be built later using the recompiled core system after
+# removing targets.customized. See "do-build" below.
+.if defined(ML_RECOMPILE)
+ ( ${ECHO_CMD} "request ml-yacc" && \
+ ${ECHO_CMD} "request ml-lex" && \
+ ${ECHO_CMD} "request ml-lex-mllex-tool" && \
+ ${ECHO_CMD} "request src-smlnj" ) \
+ > "${WRKDIR}/config/targets.customized"
+.endif
+
+# The build target patches, builds, and installs the system within WRKDIR.
+# base/runtime is not cleaned afterwards to avoid its recompilation during
+# a subsequent make install.
+# See base/system/README for information on recompiling the compiler.
+
+.if defined(ML_RECOMPILE)
+RECOMPILEDIR= base/system
+.else
+RECOMPILEDIR=
+.endif
+
+.if (${ARCH} == "amd64") && (${OSVERSION} >= 800000) && (${OSVERSION} < 1000029)
+MLRUNTIMEPATCHES_CMD= cd ${FILESDIR} && \
+ ( ${LS} do-patch-base_runtime_* extra-patch-base_runtime_* 2>&- || \
+ ${TRUE} )
+.else
+MLRUNTIMEPATCHES_CMD= cd ${FILESDIR} && \
+ ( ${LS} do-patch-base_runtime_* 2>&- || \
+ ${TRUE} )
+.endif
+MLSTANDARDPATCHES_CMD= cd ${FILESDIR} && \
+ ( for srcdir in ${MLSTDSRCDIRS} ; \
+ do ${LS} do-patch-$${srcdir}_* 2>&- ; \
+ done ) || ${TRUE}
+MLSTANDARDPATCHDIRS_CMD= cd ${FILESDIR} && \
+ ( for srcdir in ${MLSTDSRCDIRS} ; \
+ do if ${LS} do-patch-$${srcdir}_* 1>&- 2>&- ; \
+ then ${ECHO_CMD} -n $${srcdir} " " ; break ; fi ; \
+ done ) || ${TRUE}
+.if defined(ML_EVERYTHING)
+MLSOURCEPATCHES_CMD= cd ${FILESDIR} && \
+ ( ${LS} do-patch-* 2>&- || \
+ ${TRUE} )
+.else
+MLSOURCEPATCHES_CMD= ${TRUE}
+.endif
+
+do-build:
+ cd ${WRKDIR} && unset PWD && \
+ FILESDIR="${FILESDIR}" PATCH="${PATCH}" PATCH_ARGS="${PATCH_ARGS}" \
+ MLNORUNTIMECLEAN=yes \
+ MLRUNTIMEPATCHES=`${MLRUNTIMEPATCHES_CMD}` \
+ MLSTANDARDPATCHES=`${MLSTANDARDPATCHES_CMD}` \
+ MLSTANDARDPATCHDIRS=`${MLSTANDARDPATCHDIRS_CMD}` \
+ MLSOURCEPATCHES=`${MLSOURCEPATCHES_CMD}` \
+ CFLAGS='${CFLAGS}' AS='${AS}' EXTRA_DEFS='${EXTRA_DEFS}' \
+ ./config/install.sh
+.if defined(ML_RECOMPILE)
+ -${RM} ${WRKDIR}/config/targets.customized
+ @${ECHO} '(* Recompiling the core system: *)'
+ cd ${WRKDIR}/${RECOMPILEDIR} && ( \
+ ${ECHO_CMD} 'CM.autoload "$$smlnj/cmb.cm";' ; \
+ ${ECHO_CMD} ${CMB_COMMAND} ; \
+ ${ECHO_CMD} 'CMB.make ();' ) | \
+ ../../bin/sml
+ @${ECHO} '(* Building the recompiled heap: *)'
+ cd ${WRKDIR}/${RECOMPILEDIR} && \
+ ./makeml
+ @${ECHO} '(* Removing old libs and heaps: *)'
+ cd ${WRKDIR}/${RECOMPILEDIR} && \
+ ${RM} -rf ../../lib && ${MKDIR} ../../lib && \
+ ${FIND} ../../bin/.heap -name '*.${MLARCH}-bsd' \
+ \! -name 'sml.${MLARCH}-bsd' -delete -print
+ @${ECHO} '(* Installing the recompiled libs and heap: *)'
+ cd ${WRKDIR}/${RECOMPILEDIR} && \
+ ./installml
+ @${ECHO} '(* Building requested targets: *)'
+ cd ${WRKDIR} && unset PWD && \
+ FILESDIR="${FILESDIR}" PATCH="${PATCH}" PATCH_ARGS="${PATCH_ARGS}" \
+ MLNORUNTIMECLEAN=yes RECOMPILEDIR="${RECOMPILEDIR}" \
+ CFLAGS='${CFLAGS}' AS='${AS}' EXTRA_DEFS='${EXTRA_DEFS}' \
+ ./config/install.sh
+.endif
+
+# Nowadays PLIST has to be computed before installation. We do it in
+# "pre-install" because source extraction happens during "build".
+
+.if defined(ML_EVERYTHING)
+MLNOINSTALL= .cm
+.if defined(ML_RECOMPILE)
+MLNOINSTALL+= sml.bin.${MLARCH}-unix sml.boot.${MLARCH}-unix \
+ sml.lib sml.${MLARCH}-bsd
+.endif
+MLSRCEXCLUDEREGEX= -e '^(@dirrm\ )?${MLROOTRELATIVE}/base/runtime'
+.for excl in ${MLNOINSTALL}
+MLSRCEXCLUDEREGEX+= -e '/${excl}$$' -e '/${excl}/'
+.endfor
+MLPATCHPATHREGEX= -E -e 's%(^|[^_])_([^_]|$$)%\1/\2%g' \
+ -e 's%(^|[^_])__([^_]|$$)%\1_\2%g' \
+ -e 's%(^|[^_])___([^_]|$$)%\1/_\2%g'
+.endif
+
+pre-install:
+.if defined(ML_EVERYTHING)
+ @${ECHO} -n '(* Computing package list ...'
+ @${TAR} -tzf ${WRKDIR}/runtime.tgz | \
+ ${SED} -E -e 's%^(.*[^/])$$%${MLROOTRELATIVE}/base/\1%' \
+ -e 's%^(.*)/$$%@dirrm\ ${MLROOTRELATIVE}/base/\1%' \
+ > ${MLRUNTIMEPLIST}
+ @${MLRUNTIMEPATCHES_CMD} | \
+ ${SED} ${MLPATCHPATHREGEX} | \
+ ${SED} -E -e 's%^(do|extra)-patch-(base/.*)%${MLROOTRELATIVE}/\2%' \
+ > ${MLRUNTIMEPLIST}.patched
+ -@${GREP} -F -v -f ${MLRUNTIMEPLIST} ${MLRUNTIMEPLIST}.patched \
+ > ${MLRUNTIMEPLIST}.patchednew
+ @${CAT} ${MLRUNTIMEPLIST}.patchednew >> ${MLRUNTIMEPLIST}
+ @${MLRUNTIMEPATCHES_CMD} | \
+ ${SED} ${MLPATCHPATHREGEX} | \
+ ${SED} -E -e 's%^(do|extra)-patch-(base/.*)%${MLROOTRELATIVE}/\2.orig%' \
+ >> ${MLRUNTIMEPLIST}
+ @cd "${WRKDIR}" && ( \
+ ( ${FIND} -s -d ${MLSRCDIRS} \! -type d | \
+ ${AWK} '{ print "${MLROOTRELATIVE}/" $$0 }' ) ; \
+ ( ${FIND} -s -d ${MLSRCDIRS} -type d -empty | \
+ ${AWK} '{ print "@exec mkdir${CALM} -p %D/${MLROOTRELATIVE}/" $$0 }' ) ; \
+ ( ${FIND} -s -d ${MLSRCDIRS} -type d | \
+ ${AWK} '{ print "@dirrm ${MLROOTRELATIVE}/" $$0 }' ) ) | \
+ ${EGREP} -v ${MLSRCEXCLUDEREGEX} > ${MLSRCPLIST}
+ @${SED} -e 's/^%%EVERYTHING%%//' ${MLPLISTFILES} | \
+ ${GREP} -h -v "^@dirrm" | ${SORT} -u > ${PLIST}
+ @${GREP} -h "^@exec mkdir${CALM}" ${MLPLISTFILES} | ${SORT} -u >> ${PLIST}
+ @${SED} -e 's/^%%EVERYTHING%%//' ${MLPLISTFILES} | \
+ ${GREP} -h "^@dirrm" | ${SORT} -r -u >> ${PLIST}
+ @${ECHO} ' done. *)'
+.endif
+# ${PKGINSTALL} contains multiexec-wrapper, which is used to select
+# between executables of the same name that have been installed by
+# different packages (like smlnj and smlnj-devel). The source of
+# multiexec-wrapper is extracted from ${PKGINSTALL}, and inserted
+# into ${PKGINSTALL} in compressed and encoded form. So it is still
+# available when being installed from a binary package, even if
+# ${PKGINSTALL} is no file at that time (but only input to a shell).
+ @${SED} -e '/^#%%PKG-INSTALL-START%%$$/,/^#%%PKG-INSTALL-END%%$$/d' \
+ ${PKGINSTALL} > ${PKGINSTALL}.script
+ @${GZIP_CMD} ${PKGINSTALL}.script
+ @b64encode ${PKGINSTALL}.script.gz script.gz > ${PKGINSTALL}.script.gz.b64
+ @${SED} -n -e '1,/~EOF~.$$/p' ${PKGINSTALL} > ${PKGINSTALL}.pre
+ @${SED} -n -e '/^~EOF~$$/,$$p' ${PKGINSTALL} > ${PKGINSTALL}.post
+ @${CAT} ${PKGINSTALL}.pre ${PKGINSTALL}.script.gz.b64 ${PKGINSTALL}.post > ${PKGINSTALL}.full
+ @${DIFF} -q ${PKGINSTALL} ${PKGINSTALL}.full >/dev/null || ${CP} ${PKGINSTALL}.full ${PKGINSTALL}
+
+# The install target installs the heaps and libraries to their final
+# location in ${MLBIN} and ${MLLIB}.
+# In case of recompilation, installml installs the sml heap and the
+# libraries built during compiler bootstrap to ${MLBIN} and ${MLLIB}.
+# When staging CM_PATHCONFIG has to point to the final
+# ${MLLIB}/pathconfig (in ${PREFIX}) while building the compiler.
+
+.if defined(ML_EVERYTHING)
+MLSRCEXCLUDES=
+.for excl in ${MLNOINSTALL}
+MLSRCEXCLUDES+= --exclude "${excl}"
+.endfor
+.endif
+
+do-install:
+ ${MKDIR} "${STAGEDIR}${MLROOT}"
+.if ! defined(ML_RECOMPILE)
+ cd ${WRKDIR} && unset PWD && \
+ FILESDIR="${FILESDIR}" PATCH="${PATCH}" PATCH_ARGS="${PATCH_ARGS}" \
+ STAGEDIR="${STAGEDIR}" MLLIB="${MLLIB}" \
+ INSTALLDIR="${STAGEDIR}${MLROOT}" \
+ CFLAGS='${CFLAGS}' AS='${AS}' EXTRA_DEFS='${EXTRA_DEFS}' \
+ ./config/install.sh
+.else
+ @${ECHO} '(* Rebuilding the recompiled libs: *)'
+ cd ${WRKDIR}/${RECOMPILEDIR} && ( \
+ ${ECHO_CMD} 'CM.autoload "$$smlnj/cmb.cm";' ; \
+ ${ECHO_CMD} ${CMB_COMMAND} ; \
+ ${ECHO_CMD} 'CMB.make ();' ) | \
+ ../../bin/sml
+ @${ECHO} '(* Rebuilding the recompiled heap: *)'
+ cd ${WRKDIR}/${RECOMPILEDIR} && \
+ ./makeml
+ @${ECHO} '(* Installing into ${MLROOT}: *)'
+ cd ${WRKDIR} && unset PWD && \
+ FILESDIR="${FILESDIR}" PATCH="${PATCH}" PATCH_ARGS="${PATCH_ARGS}" \
+ STAGEDIR="${STAGEDIR}" MLLIB="${MLLIB}" \
+ INSTALLDIR="${STAGEDIR}${MLROOT}" RECOMPILEDIR="${RECOMPILEDIR}" \
+ CFLAGS='${CFLAGS}' AS='${AS}' EXTRA_DEFS='${EXTRA_DEFS}' \
+ ./config/install.sh
+.endif
+ MLARCHOPSYS=`${STAGEDIR}${MLBIN}/.arch-n-opsys` && \
+ ( eval $${MLARCHOPSYS} ; \
+ ${STRIP_CMD} "${STAGEDIR}${MLBIN}/.run/run.$${ARCH}-$${OPSYS}" )
+.if defined(ML_EVERYTHING)
+ @${ECHO} '(* Cleaning base/runtime: *)'
+ cd ${WRKDIR}/base/runtime/objs && ${MAKE_CMD} clean
+ @${ECHO} -n '(* Installing sources into ${STAGEDIR}${MLROOT} ...'
+ @cd ${WRKDIR} && ${TAR} -cf - ${MLSRCEXCLUDES} ${MLSRCDIRS} | \
+ ${TAR} -xf - -C "${STAGEDIR}${MLROOT}"
+ @${ECHO} ' done. *)'
+.endif
+
+post-install:
+# Only execute ${PKGINSTALL} when installing to ${PREFIX},
+# but not when staging.
+.ifmake install${CALM}
+ PKG_PREFIX=${PREFIX} MULTIEXEC_WRAPPER_VERBOSE=yes \
+ ${SH} ${PKGINSTALL} ${PKGNAME} POST-INSTALL
+.endif
+
+post-stage:
+ ${STRIP_CMD} ${STAGEDIR}${PREFIX}/smlnj/bin/.run/run.x86-freebsd.so
+
+.ifndef MULTIEXEC_WRAPPER_VERBOSE
+deinstall:
+ export MULTIEXEC_WRAPPER_VERBOSE=yes && \
+ cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} deinstall
+.endif
+
+# This target may be used by dependent ports to set SMLNJ_VERSION
+# either to the currently installed smlnj package's version
+# or else to this port's version. SMLNJ_VERSION is an environment
+# variable used by multiexec-wrapper to select the executable
+# from that smlnj-* package matching SMLNJ_VERSION.
+smlnj-version:
+ @{ ${PKG_INFO} -e smlnj && \
+ ${EXPR} `${PKG_INFO} -E smlnj` : '.*-\(.*\)' 2>/dev/null ; } || \
+ ${ECHO_CMD} ${PKGVERSION}
+
+.include <bsd.port.post.mk>
diff --git a/lang/smlnj/distinfo b/lang/smlnj/distinfo
new file mode 100644
index 000000000000..fb7c97e0a07c
--- /dev/null
+++ b/lang/smlnj/distinfo
@@ -0,0 +1,40 @@
+SIZE (smlnj/110.76/MLRISC.tgz) = 1434516
+SHA256 (smlnj/110.76/MLRISC.tgz) = 9d944dea4e80a8ef2cc01e7e16ae72cb280f2e4dc0d6648c9bc27156ccfcc102
+SIZE (smlnj/110.76/boot.x86-unix.tgz) = 5890950
+SHA256 (smlnj/110.76/boot.x86-unix.tgz) = dd16569fb6991d673e66dae57f5e9b372d5a4e305f92a9756002e4bb296c9b61
+SIZE (smlnj/110.76/ckit.tgz) = 194486
+SHA256 (smlnj/110.76/ckit.tgz) = c4534e6e7f910ebee3146cc8ed214a1d5a2ea90afbd79c2290cefdc784ee0dbb
+SIZE (smlnj/110.76/cm.tgz) = 200425
+SHA256 (smlnj/110.76/cm.tgz) = 539e8199764a803f486dbf5c0ecb3fa3b2277a6b52ccbbf350bbdcc231bec193
+SIZE (smlnj/110.76/cml.tgz) = 106005
+SHA256 (smlnj/110.76/cml.tgz) = cbd357a3b3377d049911a247be880dcde7f52f705f7cdfe800b67631858681e1
+SHA256 (smlnj/110.76/compiler.tgz) = 322755b8a3f105eec4ce4a3197aaf83bcd542e4c2b2f43c724d0ae8f393bf681
+SIZE (smlnj/110.76/compiler.tgz) = 817182
+SHA256 (smlnj/110.76/config.tgz) = 41cec8bd28c43f49bea24cc7d80d091d8a0e0c7473ee67e4a0b06019567ca557
+SIZE (smlnj/110.76/config.tgz) = 511139
+SHA256 (smlnj/110.76/eXene.tgz) = 35befa7d37207c7fc2eab81e29e3a5afb4f2c5893f7336394906425d5f4ee607
+SIZE (smlnj/110.76/eXene.tgz) = 703059
+SIZE (smlnj/110.76/heap2asm.tgz) = 1314
+SHA256 (smlnj/110.76/heap2asm.tgz) = 8c1f52bc7459de1d0d8e07807abb8e8916fa5ef1cf08c0ceb3f06437f977215d
+SIZE (smlnj/110.76/ml-burg.tgz) = 36341
+SHA256 (smlnj/110.76/ml-burg.tgz) = d59dad9188778c96b3e59f9d754a4fbdef4b67de2ded67deb0d26c40915a594e
+SIZE (smlnj/110.76/ml-lex.tgz) = 33150
+SHA256 (smlnj/110.76/ml-lex.tgz) = 9d00143cff4e8cc87421270d34b29864c27d353d6b429cce3d3428f6c7280a6b
+SIZE (smlnj/110.76/ml-lpt.tgz) = 256293
+SHA256 (smlnj/110.76/ml-lpt.tgz) = 9970b22506a605012055700cc28497c2850d29fbb7bcc5b069fbef785220fc8d
+SHA256 (smlnj/110.76/ml-yacc.tgz) = 9151f7fef0abcb312daf731621b682b2c7e9f87a151832e99c30b5e56f03f1cf
+SIZE (smlnj/110.76/ml-yacc.tgz) = 99943
+SHA256 (smlnj/110.76/nlffi.tgz) = 07bdc123b2c93f01bc0a5bbdf33aac0b34407bd70cd8d3e1d06ad55e92deb521
+SIZE (smlnj/110.76/nlffi.tgz) = 74484
+SIZE (smlnj/110.76/pgraph.tgz) = 5440
+SHA256 (smlnj/110.76/pgraph.tgz) = df44036b170f68a79a62134812adecd54c3f0da2188f0190996fc57faa10969c
+SIZE (smlnj/110.76/runtime.tgz) = 324373
+SHA256 (smlnj/110.76/runtime.tgz) = f6086cd4e30ea3a89c528ee08c793eca77f7701589e0436acf347faf7e940a7f
+SHA256 (smlnj/110.76/smlnj-c.tgz) = 0cdf1c3563f3080dffc184e8e64f5e58f7f21f1426d43cb8960cf090e2232a6f
+SIZE (smlnj/110.76/smlnj-c.tgz) = 10534
+SIZE (smlnj/110.76/smlnj-lib.tgz) = 402937
+SHA256 (smlnj/110.76/smlnj-lib.tgz) = 81e994a07d7c8979b28c4911272de3c37eec648e58c03a9dc1ecb9bbbadca1d7
+SIZE (smlnj/110.76/system.tgz) = 227685
+SHA256 (smlnj/110.76/system.tgz) = 8f6a143db22a9d025e2820899c9cccbf0e66c679a9aa68c3dcd1bec68003da37
+SHA256 (smlnj/110.76/trace-debug-profile.tgz) = 3769e1d251d04c95b4c1b759f3bf21644bcb3135404d0346e8ff34553ae704df
+SIZE (smlnj/110.76/trace-debug-profile.tgz) = 3899
diff --git a/lang/smlnj/files/do-patch-base_runtime_objs_makefile b/lang/smlnj/files/do-patch-base_runtime_objs_makefile
new file mode 100644
index 000000000000..36e43c459178
--- /dev/null
+++ b/lang/smlnj/files/do-patch-base_runtime_objs_makefile
@@ -0,0 +1,43 @@
+--- base/runtime/objs/makefile.orig 2012-04-18 02:28:08.000000000 +0200
++++ base/runtime/objs/makefile 2014-06-30 20:25:38.000000000 +0200
+@@ -5,10 +5,10 @@
+
+ SHELL = /bin/sh
+ MAKE = make
+-CC = cc
+-CPP = /lib/cpp
++CC ?= cc
++CPP ?= /lib/cpp
+ LD_LIBS =
+-AS = as
++AS ?= as
+ AR = ar
+ ARFLAGS = rcv
+ RANLIB = ranlib
+@@ -38,7 +38,7 @@
+ CLIB_DIR = $(ROOT_DIR)/c-libs
+ CONFIG_DIR = $(ROOT_DIR)/config
+
+-CFLAGS = -O
++CFLAGS ?= -O
+
+ INCLUDES = -I$(OBJS_DIR) -I$(INC_DIR)
+ GC_INCLUDES = $(INCLUDES) -I$(GC_DIR)
+@@ -329,7 +329,7 @@
+ #
+ MK_ARGS = VERSION="$(VERSION)" \
+ MAKE="$(MAKE)" \
+- CC="$(CC)" CFLAGS="$(CFLAGS)" DEFS="$(DEFS)" \
++ CC="$(CC)" CFLAGS="$(CFLAGS)" DEFS='$(DEFS)' \
+ AR="$(AR)" ARFLAGS="$(ARFLAGS)" \
+ RANLIB="$(RANLIB)" \
+ INCLUDES="$(GC_INCLUDES) -I../bytecode"
+@@ -420,7 +420,7 @@
+ #
+ LIB_MK_ARGS = VERSION="$(VERSION)" \
+ MAKE="$(MAKE)" \
+- CC="$(CC)" CFLAGS="$(CFLAGS)" DEFS="$(DEFS)" \
++ CC="$(CC)" CFLAGS="$(CFLAGS)" DEFS='$(DEFS)' \
+ AR="$(AR)" ARFLAGS="$(ARFLAGS)" \
+ RANLIB="$(RANLIB)" \
+ INCLUDES="$(LIB_INCLUDES)"
diff --git a/lang/smlnj/files/do-patch-base_runtime_objs_mk.x86-freebsd b/lang/smlnj/files/do-patch-base_runtime_objs_mk.x86-freebsd
new file mode 100644
index 000000000000..9a3b982f6db8
--- /dev/null
+++ b/lang/smlnj/files/do-patch-base_runtime_objs_mk.x86-freebsd
@@ -0,0 +1,37 @@
+--- base/runtime/objs/mk.x86-freebsd.orig 2006-04-20 17:28:53.000000000 +0200
++++ base/runtime/objs/mk.x86-freebsd 2014-07-04 13:12:45.000000000 +0200
+@@ -5,19 +5,19 @@
+
+ SHELL = /bin/sh
+
+-MAKE = gmake
++MAKE = make
+
+ ARFLAGS = Trcv
+-CC = gcc -ansi
+-CFLAGS = -O2
+-CPP = gcc -x assembler-with-cpp -E -P
++CC ?= gcc -ansi
++CFLAGS ?= -O2
++CPP = ${CC} -x assembler-with-cpp -E -P
+ #CPP = /usr/bin/cpp -P
+
+ XOBJS =
+ XLIBS = ../c-libs/dl/libunix-dynload.a
+ LD_LIBS =
+ BASE_DEFS =
+-DEFS = $(BASE_DEFS) -DHOST_X86 -DTARGET_X86 -DOPSYS_UNIX -DOPSYS_FREEBSD -DDLOPEN
++DEFS = $(BASE_DEFS) -DHOST_X86 -DTARGET_X86 -DOPSYS_UNIX -DOPSYS_FREEBSD -DDLOPEN $(EXTRA_DEFS)
+ TARGET = X86
+ VERSION = v-x86-freebsd
+ RUNTIME = run.x86-freebsd
+@@ -25,6 +25,6 @@
+ RUNTIME_A = run.x86-freebsd.a
+
+ all:
+- ($(MAKE) RUNTIME="$(RUNTIME)" VERSION="$(VERSION)" MAKE="$(MAKE)" CC="$(CC)" CFLAGS="$(CFLAGS)" CPP="$(CPP)" TARGET=$(TARGET) DEFS="$(DEFS)" XOBJS="$(XOBJS)" XLIBS="$(XLIBS)" LD_LIBS="$(LD_LIBS)" $(RUNTIME))
+- ($(MAKE) RUNTIME="$(RUNTIME_SO)" VERSION="$(VERSION)" MAKE="$(MAKE)" CC="$(CC)" CFLAGS="$(CFLAGS)" CPP="$(CPP)" TARGET=$(TARGET) DEFS="$(DEFS)" XOBJS="$(XOBJS)" XLIBS="$(XLIBS)" LD_LIBS="$(LD_LIBS)" LDFLAGS="-shared" $(RUNTIME_SO))
+- ($(MAKE) RUNTIME_A="$(RUNTIME_A)" VERSION="$(VERSION)" MAKE="$(MAKE)" CC="$(CC)" CFLAGS="$(CFLAGS)" CPP="$(CPP)" TARGET=$(TARGET) DEFS="$(DEFS)" XOBJS="$(XOBJS)" XLIBS="$(XLIBS)" LD_LIBS="$(LD_LIBS)" LDFLAGS="" $(RUNTIME_A))
++ ($(MAKE) RUNTIME="$(RUNTIME)" VERSION="$(VERSION)" MAKE="$(MAKE)" AS="$(AS)" CC="$(CC)" CFLAGS="$(CFLAGS)" CPP="$(CPP)" TARGET=$(TARGET) DEFS="$(DEFS)" XOBJS="$(XOBJS)" XLIBS="$(XLIBS)" LD_LIBS="$(LD_LIBS)" $(RUNTIME))
++ ($(MAKE) RUNTIME="$(RUNTIME_SO)" VERSION="$(VERSION)" MAKE="$(MAKE)" AS="$(AS)" CC="$(CC)" CFLAGS="$(CFLAGS)" CPP="$(CPP)" TARGET=$(TARGET) DEFS="$(DEFS)" XOBJS="$(XOBJS)" XLIBS="$(XLIBS)" LD_LIBS="$(LD_LIBS)" LDFLAGS="-shared" $(RUNTIME_SO))
++ ($(MAKE) RUNTIME_A="$(RUNTIME_A)" VERSION="$(VERSION)" MAKE="$(MAKE)" AS="$(AS)" CC="$(CC)" CFLAGS="$(CFLAGS)" CPP="$(CPP)" TARGET=$(TARGET) DEFS="$(DEFS)" XOBJS="$(XOBJS)" XLIBS="$(XLIBS)" LD_LIBS="$(LD_LIBS)" LDFLAGS="" $(RUNTIME_A))
diff --git a/lang/smlnj/files/extra-patch-base_runtime_c-libs_smlnj-math_ctlrndmode.c b/lang/smlnj/files/extra-patch-base_runtime_c-libs_smlnj-math_ctlrndmode.c
new file mode 100644
index 000000000000..057f573fcaa9
--- /dev/null
+++ b/lang/smlnj/files/extra-patch-base_runtime_c-libs_smlnj-math_ctlrndmode.c
@@ -0,0 +1,22 @@
+--- base/runtime/c-libs/smlnj-math/ctlrndmode.c.orig 2000-06-01 20:34:03.000000000 +0200
++++ base/runtime/c-libs/smlnj-math/ctlrndmode.c 2013-06-18 15:08:01.715990633 +0200
+@@ -3,6 +3,19 @@
+ * COPYRIGHT (c) 1996 AT&T Research.
+ */
+
++ #if defined(OPSYS_FREEBSD)
++ # if defined(INCLUDE_FREEBSD_I386__TYPES)
++ # include <sys/cdefs.h>
++ # include INCLUDE_FREEBSD_I386__TYPES
++ # endif
++ # if defined(INCLUDE_FREEBSD_I386_ENDIAN)
++ # include INCLUDE_FREEBSD_I386_ENDIAN
++ # endif
++ # if defined(INCLUDE_FREEBSD_I386_IEEEFP)
++ # include INCLUDE_FREEBSD_I386_IEEEFP
++ # endif
++ #endif
++
+ #include "ml-base.h"
+ #include "fp-dep.h"
+ #include "ml-objects.h"
diff --git a/lang/smlnj/files/extra-patch-base_runtime_include_freebsd-8-i386-__types.h b/lang/smlnj/files/extra-patch-base_runtime_include_freebsd-8-i386-__types.h
new file mode 100644
index 000000000000..cedda3e5f374
--- /dev/null
+++ b/lang/smlnj/files/extra-patch-base_runtime_include_freebsd-8-i386-__types.h
@@ -0,0 +1,137 @@
+--- base/runtime/include/freebsd-8-i386-_types.h.orig 1970-01-01 01:00:00.000000000 +0100
++++ base/runtime/include/freebsd-8-i386-_types.h 2013-06-19 16:14:57.000000000 +0200
+@@ -0,0 +1,134 @@
++/*-
++ * Copyright (c) 2002 Mike Barcroft <mike@FreeBSD.org>
++ * Copyright (c) 1990, 1993
++ * The Regents of the University of California. All rights reserved.
++ *
++ * Redistribution and use in source and binary forms, with or without
++ * modification, are permitted provided that the following conditions
++ * are met:
++ * 1. Redistributions of source code must retain the above copyright
++ * notice, this list of conditions and the following disclaimer.
++ * 2. Redistributions in binary form must reproduce the above copyright
++ * notice, this list of conditions and the following disclaimer in the
++ * documentation and/or other materials provided with the distribution.
++ * 3. All advertising materials mentioning features or use of this software
++ * must display the following acknowledgement:
++ * This product includes software developed by the University of
++ * California, Berkeley and its contributors.
++ * 4. Neither the name of the University nor the names of its contributors
++ * may be used to endorse or promote products derived from this software
++ * without specific prior written permission.
++ *
++ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
++ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
++ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
++ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
++ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
++ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
++ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
++ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
++ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
++ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
++ * SUCH DAMAGE.
++ *
++ * From: @(#)ansi.h 8.2 (Berkeley) 1/4/94
++ * From: @(#)types.h 8.3 (Berkeley) 1/5/94
++ * $FreeBSD: stable/8/sys/i386/include/_types.h 176827 2008-03-05 11:21:14Z bde $
++ */
++
++#ifndef _MACHINE__TYPES_H_
++#define _MACHINE__TYPES_H_
++
++#ifndef _SYS_CDEFS_H_
++#error this file needs sys/cdefs.h as a prerequisite
++#endif
++
++#define __NO_STRICT_ALIGNMENT
++
++/*
++ * Basic types upon which most other types are built.
++ */
++typedef __signed char __int8_t;
++typedef unsigned char __uint8_t;
++typedef short __int16_t;
++typedef unsigned short __uint16_t;
++typedef int __int32_t;
++typedef unsigned int __uint32_t;
++
++#if defined(lint)
++/* LONGLONG */
++typedef long long __int64_t;
++/* LONGLONG */
++typedef unsigned long long __uint64_t;
++#elif defined(__GNUCLIKE_ATTRIBUTE_MODE_DI)
++typedef int __attribute__((__mode__(__DI__))) __int64_t;
++typedef unsigned int __attribute__((__mode__(__DI__))) __uint64_t;
++#else
++/* LONGLONG */
++typedef long long __int64_t;
++/* LONGLONG */
++typedef unsigned long long __uint64_t;
++#endif
++
++/*
++ * Standard type definitions.
++ */
++typedef unsigned long __clock_t; /* clock()... */
++typedef unsigned int __cpumask_t;
++typedef __int32_t __critical_t;
++typedef long double __double_t;
++typedef long double __float_t;
++typedef __int32_t __intfptr_t;
++typedef __int64_t __intmax_t;
++typedef __int32_t __intptr_t;
++typedef __int32_t __int_fast8_t;
++typedef __int32_t __int_fast16_t;
++typedef __int32_t __int_fast32_t;
++typedef __int64_t __int_fast64_t;
++typedef __int8_t __int_least8_t;
++typedef __int16_t __int_least16_t;
++typedef __int32_t __int_least32_t;
++typedef __int64_t __int_least64_t;
++typedef __int32_t __ptrdiff_t; /* ptr1 - ptr2 */
++typedef __int32_t __register_t;
++typedef __int32_t __segsz_t; /* segment size (in pages) */
++typedef __uint32_t __size_t; /* sizeof() */
++typedef __int32_t __ssize_t; /* byte count or error */
++typedef __int32_t __time_t; /* time()... */
++typedef __uint32_t __uintfptr_t;
++typedef __uint64_t __uintmax_t;
++typedef __uint32_t __uintptr_t;
++typedef __uint32_t __uint_fast8_t;
++typedef __uint32_t __uint_fast16_t;
++typedef __uint32_t __uint_fast32_t;
++typedef __uint64_t __uint_fast64_t;
++typedef __uint8_t __uint_least8_t;
++typedef __uint16_t __uint_least16_t;
++typedef __uint32_t __uint_least32_t;
++typedef __uint64_t __uint_least64_t;
++typedef __uint32_t __u_register_t;
++typedef __uint32_t __vm_offset_t;
++typedef __int64_t __vm_ooffset_t;
++#ifdef PAE
++typedef __uint64_t __vm_paddr_t;
++#else
++typedef __uint32_t __vm_paddr_t;
++#endif
++typedef __uint64_t __vm_pindex_t;
++typedef __uint32_t __vm_size_t;
++
++/*
++ * Unusual type definitions.
++ */
++#ifdef __GNUCLIKE_BUILTIN_VARARGS
++typedef __builtin_va_list __va_list; /* internally known to gcc */
++#else
++typedef char * __va_list;
++#endif /* __GNUCLIKE_BUILTIN_VARARGS */
++#if defined(__GNUC_VA_LIST_COMPATIBILITY) && !defined(__GNUC_VA_LIST) \
++ && !defined(__NO_GNUC_VA_LIST)
++#define __GNUC_VA_LIST
++typedef __va_list __gnuc_va_list; /* compatibility w/GNU headers*/
++#endif
++
++#endif /* !_MACHINE__TYPES_H_ */
diff --git a/lang/smlnj/files/extra-patch-base_runtime_include_freebsd-8-i386-endian.h b/lang/smlnj/files/extra-patch-base_runtime_include_freebsd-8-i386-endian.h
new file mode 100644
index 000000000000..c00265a5a803
--- /dev/null
+++ b/lang/smlnj/files/extra-patch-base_runtime_include_freebsd-8-i386-endian.h
@@ -0,0 +1,139 @@
+--- base/runtime/include/freebsd-8-i386-endian.h.orig 1970-01-01 01:00:00.000000000 +0100
++++ base/runtime/include/freebsd-8-i386-endian.h 2013-06-19 16:14:56.000000000 +0200
+@@ -0,0 +1,136 @@
++/*-
++ * Copyright (c) 1987, 1991 Regents of the University of California.
++ * All rights reserved.
++ *
++ * Redistribution and use in source and binary forms, with or without
++ * modification, are permitted provided that the following conditions
++ * are met:
++ * 1. Redistributions of source code must retain the above copyright
++ * notice, this list of conditions and the following disclaimer.
++ * 2. Redistributions in binary form must reproduce the above copyright
++ * notice, this list of conditions and the following disclaimer in the
++ * documentation and/or other materials provided with the distribution.
++ * 4. Neither the name of the University nor the names of its contributors
++ * may be used to endorse or promote products derived from this software
++ * without specific prior written permission.
++ *
++ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
++ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
++ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
++ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
++ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
++ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
++ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
++ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
++ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
++ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
++ * SUCH DAMAGE.
++ *
++ * @(#)endian.h 7.8 (Berkeley) 4/3/91
++ * $FreeBSD: stable/8/sys/i386/include/endian.h 190854 2009-04-08 19:10:20Z ed $
++ */
++
++#ifndef _MACHINE_ENDIAN_H_
++#define _MACHINE_ENDIAN_H_
++
++#include <sys/cdefs.h>
++#include <sys/_types.h>
++
++#ifdef __cplusplus
++extern "C" {
++#endif
++
++/*
++ * Define the order of 32-bit words in 64-bit words.
++ */
++#define _QUAD_HIGHWORD 1
++#define _QUAD_LOWWORD 0
++
++/*
++ * Definitions for byte order, according to byte significance from low
++ * address to high.
++ */
++#define _LITTLE_ENDIAN 1234 /* LSB first: i386, vax */
++#define _BIG_ENDIAN 4321 /* MSB first: 68000, ibm, net */
++#define _PDP_ENDIAN 3412 /* LSB first in word, MSW first in long */
++
++#define _BYTE_ORDER _LITTLE_ENDIAN
++
++/*
++ * Deprecated variants that don't have enough underscores to be useful in more
++ * strict namespaces.
++ */
++#if __BSD_VISIBLE
++#define LITTLE_ENDIAN _LITTLE_ENDIAN
++#define BIG_ENDIAN _BIG_ENDIAN
++#define PDP_ENDIAN _PDP_ENDIAN
++#define BYTE_ORDER _BYTE_ORDER
++#endif
++
++#if defined(__GNUCLIKE_ASM) && defined(__GNUCLIKE_BUILTIN_CONSTANT_P)
++
++#define __byte_swap_int_var(x) \
++__extension__ ({ register __uint32_t __X = (x); \
++ __asm ("bswap %0" : "+r" (__X)); \
++ __X; })
++
++#ifdef __OPTIMIZE__
++
++#define __byte_swap_int_const(x) \
++ ((((x) & 0xff000000) >> 24) | \
++ (((x) & 0x00ff0000) >> 8) | \
++ (((x) & 0x0000ff00) << 8) | \
++ (((x) & 0x000000ff) << 24))
++#define __byte_swap_int(x) (__builtin_constant_p(x) ? \
++ __byte_swap_int_const(x) : __byte_swap_int_var(x))
++
++#else /* __OPTIMIZE__ */
++
++#define __byte_swap_int(x) __byte_swap_int_var(x)
++
++#endif /* __OPTIMIZE__ */
++
++static __inline __uint64_t
++__bswap64(__uint64_t _x)
++{
++
++ return ((_x >> 56) | ((_x >> 40) & 0xff00) | ((_x >> 24) & 0xff0000) |
++ ((_x >> 8) & 0xff000000) | ((_x << 8) & ((__uint64_t)0xff << 32)) |
++ ((_x << 24) & ((__uint64_t)0xff << 40)) |
++ ((_x << 40) & ((__uint64_t)0xff << 48)) | ((_x << 56)));
++}
++
++static __inline __uint32_t
++__bswap32(__uint32_t _x)
++{
++
++ return (__byte_swap_int(_x));
++}
++
++static __inline __uint16_t
++__bswap16(__uint16_t _x)
++{
++ return (_x << 8 | _x >> 8);
++}
++
++#define __htonl(x) __bswap32(x)
++#define __htons(x) __bswap16(x)
++#define __ntohl(x) __bswap32(x)
++#define __ntohs(x) __bswap16(x)
++
++#else /* !(__GNUCLIKE_ASM && __GNUCLIKE_BUILTIN_CONSTANT_P) */
++
++/*
++ * No optimizations are available for this compiler. Fall back to
++ * non-optimized functions by defining the constant usually used to prevent
++ * redefinition.
++ */
++#define _BYTEORDER_FUNC_DEFINED
++
++#endif /* __GNUCLIKE_ASM && __GNUCLIKE_BUILTIN_CONSTANT_P */
++
++#ifdef __cplusplus
++}
++#endif
++
++#endif /* !_MACHINE_ENDIAN_H_ */
diff --git a/lang/smlnj/files/extra-patch-base_runtime_include_freebsd-8-i386-ieeefp.h b/lang/smlnj/files/extra-patch-base_runtime_include_freebsd-8-i386-ieeefp.h
new file mode 100644
index 000000000000..9722f88fd4f3
--- /dev/null
+++ b/lang/smlnj/files/extra-patch-base_runtime_include_freebsd-8-i386-ieeefp.h
@@ -0,0 +1,262 @@
+--- base/runtime/include/freebsd-8-i386-ieeefp.h.orig 1970-01-01 01:00:00.000000000 +0100
++++ base/runtime/include/freebsd-8-i386-ieeefp.h 2013-06-19 16:14:57.000000000 +0200
+@@ -0,0 +1,259 @@
++/*-
++ * Copyright (c) 2003 Peter Wemm.
++ * Copyright (c) 1990 Andrew Moore, Talke Studio
++ * All rights reserved.
++ *
++ * Redistribution and use in source and binary forms, with or without
++ * modification, are permitted provided that the following conditions
++ * are met:
++ * 1. Redistributions of source code must retain the above copyright
++ * notice, this list of conditions and the following disclaimer.
++ * 2. Redistributions in binary form must reproduce the above copyright
++ * notice, this list of conditions and the following disclaimer in the
++ * documentation and/or other materials provided with the distribution.
++ * 3. All advertising materials mentioning features or use of this software
++ * must display the following acknowledgement:
++ * This product includes software developed by the University of
++ * California, Berkeley and its contributors.
++ * 4. Neither the name of the University nor the names of its contributors
++ * may be used to endorse or promote products derived from this software
++ * without specific prior written permission.
++ *
++ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
++ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
++ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
++ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
++ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
++ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
++ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
++ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
++ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
++ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
++ * SUCH DAMAGE.
++ *
++ * from: @(#) ieeefp.h 1.0 (Berkeley) 9/23/93
++ * $FreeBSD: stable/8/sys/i386/include/ieeefp.h 175234 2008-01-11 18:59:35Z bde $
++ */
++
++#ifndef _MACHINE_IEEEFP_H_
++#define _MACHINE_IEEEFP_H_
++
++/*
++ * IEEE floating point type, constant and function definitions.
++ * XXX: FP*FLD and FP*OFF are undocumented pollution.
++ */
++
++#ifndef _SYS_CDEFS_H_
++#error this file needs sys/cdefs.h as a prerequisite
++#endif
++
++/*
++ * Rounding modes.
++ */
++typedef enum {
++ FP_RN=0, /* round to nearest */
++ FP_RM, /* round down towards minus infinity */
++ FP_RP, /* round up towards plus infinity */
++ FP_RZ /* truncate */
++} fp_rnd_t;
++
++/*
++ * Precision (i.e., rounding precision) modes.
++ */
++typedef enum {
++ FP_PS=0, /* 24 bit (single-precision) */
++ FP_PRS, /* reserved */
++ FP_PD, /* 53 bit (double-precision) */
++ FP_PE /* 64 bit (extended-precision) */
++} fp_prec_t;
++
++#define fp_except_t int
++
++/*
++ * Exception bit masks.
++ */
++#define FP_X_INV 0x01 /* invalid operation */
++#define FP_X_DNML 0x02 /* denormal */
++#define FP_X_DZ 0x04 /* zero divide */
++#define FP_X_OFL 0x08 /* overflow */
++#define FP_X_UFL 0x10 /* underflow */
++#define FP_X_IMP 0x20 /* (im)precision */
++#define FP_X_STK 0x40 /* stack fault */
++
++/*
++ * FPU control word bit-field masks.
++ */
++#define FP_MSKS_FLD 0x3f /* exception masks field */
++#define FP_PRC_FLD 0x300 /* precision control field */
++#define FP_RND_FLD 0xc00 /* rounding control field */
++
++/*
++ * FPU status word bit-field masks.
++ */
++#define FP_STKY_FLD 0x3f /* sticky flags field */
++
++/*
++ * FPU control word bit-field offsets (shift counts).
++ */
++#define FP_MSKS_OFF 0 /* exception masks offset */
++#define FP_PRC_OFF 8 /* precision control offset */
++#define FP_RND_OFF 10 /* rounding control offset */
++
++/*
++ * FPU status word bit-field offsets (shift counts).
++ */
++#define FP_STKY_OFF 0 /* sticky flags offset */
++
++#ifdef __GNUCLIKE_ASM
++
++#define __fldcw(addr) __asm __volatile("fldcw %0" : : "m" (*(addr)))
++#define __fldenv(addr) __asm __volatile("fldenv %0" : : "m" (*(addr)))
++#define __fnclex() __asm __volatile("fnclex")
++#define __fnstcw(addr) __asm __volatile("fnstcw %0" : "=m" (*(addr)))
++#define __fnstenv(addr) __asm __volatile("fnstenv %0" : "=m" (*(addr)))
++#define __fnstsw(addr) __asm __volatile("fnstsw %0" : "=m" (*(addr)))
++
++/*
++ * Load the control word. Be careful not to trap if there is a currently
++ * unmasked exception (ones that will become freshly unmasked are not a
++ * problem). This case must be handled by a save/restore of the
++ * environment or even of the full x87 state. Accessing the environment
++ * is very inefficient, so only do it when necessary.
++ */
++static __inline void
++__fnldcw(unsigned short _cw, unsigned short _newcw)
++{
++ struct {
++ unsigned _cw;
++ unsigned _other[6];
++ } _env;
++ unsigned short _sw;
++
++ if ((_cw & FP_MSKS_FLD) != FP_MSKS_FLD) {
++ __fnstsw(&_sw);
++ if (((_sw & ~_cw) & FP_STKY_FLD) != 0) {
++ __fnstenv(&_env);
++ _env._cw = _newcw;
++ __fldenv(&_env);
++ return;
++ }
++ }
++ __fldcw(&_newcw);
++}
++
++static __inline fp_rnd_t
++fpgetround(void)
++{
++ unsigned short _cw;
++
++ __fnstcw(&_cw);
++ return ((fp_rnd_t)((_cw & FP_RND_FLD) >> FP_RND_OFF));
++}
++
++static __inline fp_rnd_t
++fpsetround(fp_rnd_t _m)
++{
++ fp_rnd_t _p;
++ unsigned short _cw, _newcw;
++
++ __fnstcw(&_cw);
++ _p = (fp_rnd_t)((_cw & FP_RND_FLD) >> FP_RND_OFF);
++ _newcw = _cw & ~FP_RND_FLD;
++ _newcw |= (_m << FP_RND_OFF) & FP_RND_FLD;
++ __fnldcw(_cw, _newcw);
++ return (_p);
++}
++
++static __inline fp_prec_t
++fpgetprec(void)
++{
++ unsigned short _cw;
++
++ __fnstcw(&_cw);
++ return ((fp_prec_t)((_cw & FP_PRC_FLD) >> FP_PRC_OFF));
++}
++
++static __inline fp_prec_t
++fpsetprec(fp_prec_t _m)
++{
++ fp_prec_t _p;
++ unsigned short _cw, _newcw;
++
++ __fnstcw(&_cw);
++ _p = (fp_prec_t)((_cw & FP_PRC_FLD) >> FP_PRC_OFF);
++ _newcw = _cw & ~FP_PRC_FLD;
++ _newcw |= (_m << FP_PRC_OFF) & FP_PRC_FLD;
++ __fnldcw(_cw, _newcw);
++ return (_p);
++}
++
++/*
++ * Get or set the exception mask.
++ * Note that the x87 mask bits are inverted by the API -- a mask bit of 1
++ * means disable for x87 and SSE, but for fp*mask() it means enable.
++ */
++
++static __inline fp_except_t
++fpgetmask(void)
++{
++ unsigned short _cw;
++
++ __fnstcw(&_cw);
++ return ((~_cw & FP_MSKS_FLD) >> FP_MSKS_OFF);
++}
++
++static __inline fp_except_t
++fpsetmask(fp_except_t _m)
++{
++ fp_except_t _p;
++ unsigned short _cw, _newcw;
++
++ __fnstcw(&_cw);
++ _p = (~_cw & FP_MSKS_FLD) >> FP_MSKS_OFF;
++ _newcw = _cw & ~FP_MSKS_FLD;
++ _newcw |= (~_m << FP_MSKS_OFF) & FP_MSKS_FLD;
++ __fnldcw(_cw, _newcw);
++ return (_p);
++}
++
++static __inline fp_except_t
++fpgetsticky(void)
++{
++ unsigned _ex;
++ unsigned short _sw;
++
++ __fnstsw(&_sw);
++ _ex = (_sw & FP_STKY_FLD) >> FP_STKY_OFF;
++ return ((fp_except_t)_ex);
++}
++
++static __inline fp_except_t
++fpresetsticky(fp_except_t _m)
++{
++ struct {
++ unsigned _cw;
++ unsigned _sw;
++ unsigned _other[5];
++ } _env;
++ fp_except_t _p;
++
++ _m &= FP_STKY_FLD >> FP_STKY_OFF;
++ _p = fpgetsticky();
++ if ((_p & ~_m) == _p)
++ return (_p);
++ if ((_p & ~_m) == 0) {
++ __fnclex();
++ return (_p);
++ }
++ __fnstenv(&_env);
++ _env._sw &= ~_m;
++ __fldenv(&_env);
++ return (_p);
++}
++
++#endif /* __GNUCLIKE_ASM */
++
++/* Suppress prototypes in the MI header. */
++#define _IEEEFP_INLINED_ 1
++
++#endif /* !_MACHINE_IEEEFP_H_ */
diff --git a/lang/smlnj/files/extra-patch-base_runtime_include_freebsd-8-i386-signal.h b/lang/smlnj/files/extra-patch-base_runtime_include_freebsd-8-i386-signal.h
new file mode 100644
index 000000000000..31570e340095
--- /dev/null
+++ b/lang/smlnj/files/extra-patch-base_runtime_include_freebsd-8-i386-signal.h
@@ -0,0 +1,137 @@
+--- base/runtime/include/freebsd-8-i386-signal.h.orig 1970-01-01 01:00:00.000000000 +0100
++++ base/runtime/include/freebsd-8-i386-signal.h 2013-06-19 16:14:56.000000000 +0200
+@@ -0,0 +1,134 @@
++/*-
++ * Copyright (c) 1986, 1989, 1991, 1993
++ * The Regents of the University of California. All rights reserved.
++ *
++ * Redistribution and use in source and binary forms, with or without
++ * modification, are permitted provided that the following conditions
++ * are met:
++ * 1. Redistributions of source code must retain the above copyright
++ * notice, this list of conditions and the following disclaimer.
++ * 2. Redistributions in binary form must reproduce the above copyright
++ * notice, this list of conditions and the following disclaimer in the
++ * documentation and/or other materials provided with the distribution.
++ * 4. Neither the name of the University nor the names of its contributors
++ * may be used to endorse or promote products derived from this software
++ * without specific prior written permission.
++ *
++ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
++ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
++ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
++ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
++ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
++ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
++ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
++ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
++ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
++ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
++ * SUCH DAMAGE.
++ *
++ * @(#)signal.h 8.1 (Berkeley) 6/11/93
++ * $FreeBSD: stable/8/sys/i386/include/signal.h 190623 2009-04-01 13:44:28Z kib $
++ */
++
++#ifndef _MACHINE_SIGNAL_H_
++#define _MACHINE_SIGNAL_H_
++
++#include <sys/cdefs.h>
++#include <sys/_sigset.h>
++
++/*
++ * Machine-dependent signal definitions
++ */
++
++typedef int sig_atomic_t;
++
++#if __BSD_VISIBLE
++#include <machine/trap.h> /* codes for SIGILL, SIGFPE */
++
++/*
++ * Only the kernel should need these old type definitions.
++ */
++#if defined(_KERNEL) && defined(COMPAT_43)
++/*
++ * Information pushed on stack when a signal is delivered.
++ * This is used by the kernel to restore state following
++ * execution of the signal handler. It is also made available
++ * to the handler to allow it to restore state properly if
++ * a non-standard exit is performed.
++ */
++struct osigcontext {
++ int sc_onstack; /* sigstack state to restore */
++ osigset_t sc_mask; /* signal mask to restore */
++ int sc_esp; /* machine state follows: */
++ int sc_ebp;
++ int sc_isp;
++ int sc_eip;
++ int sc_efl;
++ int sc_es;
++ int sc_ds;
++ int sc_cs;
++ int sc_ss;
++ int sc_edi;
++ int sc_esi;
++ int sc_ebx;
++ int sc_edx;
++ int sc_ecx;
++ int sc_eax;
++ int sc_gs;
++ int sc_fs;
++ int sc_trapno;
++ int sc_err;
++};
++#endif
++
++/*
++ * The sequence of the fields/registers in struct sigcontext should match
++ * those in mcontext_t.
++ */
++struct sigcontext {
++ struct __sigset sc_mask; /* signal mask to restore */
++ int sc_onstack; /* sigstack state to restore */
++ int sc_gs; /* machine state (struct trapframe) */
++ int sc_fs;
++ int sc_es;
++ int sc_ds;
++ int sc_edi;
++ int sc_esi;
++ int sc_ebp;
++ int sc_isp;
++ int sc_ebx;
++ int sc_edx;
++ int sc_ecx;
++ int sc_eax;
++ int sc_trapno;
++ int sc_err;
++ int sc_eip;
++ int sc_cs;
++ int sc_efl;
++ int sc_esp;
++ int sc_ss;
++ int sc_len; /* sizeof(mcontext_t) */
++ /*
++ * XXX - See <machine/ucontext.h> and <machine/npx.h> for
++ * the following fields.
++ */
++ int sc_fpformat;
++ int sc_ownedfp;
++ int sc_spare1[1];
++ int sc_fpstate[128] __aligned(16);
++
++ int sc_fsbase;
++ int sc_gsbase;
++
++ int sc_spare2[6];
++};
++
++#define sc_sp sc_esp
++#define sc_fp sc_ebp
++#define sc_pc sc_eip
++#define sc_ps sc_efl
++#define sc_eflags sc_efl
++
++#endif /* __BSD_VISIBLE */
++
++#endif /* !_MACHINE_SIGNAL_H_ */
diff --git a/lang/smlnj/files/extra-patch-base_runtime_include_freebsd-9-i386-__types.h b/lang/smlnj/files/extra-patch-base_runtime_include_freebsd-9-i386-__types.h
new file mode 100644
index 000000000000..4a6ca38435dc
--- /dev/null
+++ b/lang/smlnj/files/extra-patch-base_runtime_include_freebsd-9-i386-__types.h
@@ -0,0 +1,131 @@
+--- base/runtime/include/freebsd-9-i386-_types.h.orig 1970-01-01 01:00:00.000000000 +0100
++++ base/runtime/include/freebsd-9-i386-_types.h 2013-06-19 16:07:03.000000000 +0200
+@@ -0,0 +1,128 @@
++/*-
++ * Copyright (c) 2002 Mike Barcroft <mike@FreeBSD.org>
++ * Copyright (c) 1990, 1993
++ * The Regents of the University of California. All rights reserved.
++ *
++ * Redistribution and use in source and binary forms, with or without
++ * modification, are permitted provided that the following conditions
++ * are met:
++ * 1. Redistributions of source code must retain the above copyright
++ * notice, this list of conditions and the following disclaimer.
++ * 2. Redistributions in binary form must reproduce the above copyright
++ * notice, this list of conditions and the following disclaimer in the
++ * documentation and/or other materials provided with the distribution.
++ * 3. All advertising materials mentioning features or use of this software
++ * must display the following acknowledgement:
++ * This product includes software developed by the University of
++ * California, Berkeley and its contributors.
++ * 4. Neither the name of the University nor the names of its contributors
++ * may be used to endorse or promote products derived from this software
++ * without specific prior written permission.
++ *
++ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
++ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
++ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
++ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
++ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
++ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
++ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
++ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
++ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
++ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
++ * SUCH DAMAGE.
++ *
++ * From: @(#)ansi.h 8.2 (Berkeley) 1/4/94
++ * From: @(#)types.h 8.3 (Berkeley) 1/5/94
++ * $FreeBSD: stable/9/sys/i386/include/_types.h 222813 2011-06-07 08:46:13Z attilio $
++ */
++
++#ifndef _MACHINE__TYPES_H_
++#define _MACHINE__TYPES_H_
++
++#ifndef _SYS_CDEFS_H_
++#error this file needs sys/cdefs.h as a prerequisite
++#endif
++
++#define __NO_STRICT_ALIGNMENT
++
++/*
++ * Basic types upon which most other types are built.
++ */
++typedef __signed char __int8_t;
++typedef unsigned char __uint8_t;
++typedef short __int16_t;
++typedef unsigned short __uint16_t;
++typedef int __int32_t;
++typedef unsigned int __uint32_t;
++#ifndef lint
++__extension__
++#endif
++/* LONGLONG */
++typedef long long __int64_t;
++#ifndef lint
++__extension__
++#endif
++/* LONGLONG */
++typedef unsigned long long __uint64_t;
++
++/*
++ * Standard type definitions.
++ */
++typedef unsigned long __clock_t; /* clock()... */
++typedef __int32_t __critical_t;
++typedef long double __double_t;
++typedef long double __float_t;
++typedef __int32_t __intfptr_t;
++typedef __int64_t __intmax_t;
++typedef __int32_t __intptr_t;
++typedef __int32_t __int_fast8_t;
++typedef __int32_t __int_fast16_t;
++typedef __int32_t __int_fast32_t;
++typedef __int64_t __int_fast64_t;
++typedef __int8_t __int_least8_t;
++typedef __int16_t __int_least16_t;
++typedef __int32_t __int_least32_t;
++typedef __int64_t __int_least64_t;
++typedef __int32_t __ptrdiff_t; /* ptr1 - ptr2 */
++typedef __int32_t __register_t;
++typedef __int32_t __segsz_t; /* segment size (in pages) */
++typedef __uint32_t __size_t; /* sizeof() */
++typedef __int32_t __ssize_t; /* byte count or error */
++typedef __int32_t __time_t; /* time()... */
++typedef __uint32_t __uintfptr_t;
++typedef __uint64_t __uintmax_t;
++typedef __uint32_t __uintptr_t;
++typedef __uint32_t __uint_fast8_t;
++typedef __uint32_t __uint_fast16_t;
++typedef __uint32_t __uint_fast32_t;
++typedef __uint64_t __uint_fast64_t;
++typedef __uint8_t __uint_least8_t;
++typedef __uint16_t __uint_least16_t;
++typedef __uint32_t __uint_least32_t;
++typedef __uint64_t __uint_least64_t;
++typedef __uint32_t __u_register_t;
++typedef __uint32_t __vm_offset_t;
++typedef __int64_t __vm_ooffset_t;
++#ifdef PAE
++typedef __uint64_t __vm_paddr_t;
++#else
++typedef __uint32_t __vm_paddr_t;
++#endif
++typedef __uint64_t __vm_pindex_t;
++typedef __uint32_t __vm_size_t;
++
++/*
++ * Unusual type definitions.
++ */
++#ifdef __GNUCLIKE_BUILTIN_VARARGS
++typedef __builtin_va_list __va_list; /* internally known to gcc */
++#else
++typedef char * __va_list;
++#endif /* __GNUCLIKE_BUILTIN_VARARGS */
++#if defined(__GNUC_VA_LIST_COMPATIBILITY) && !defined(__GNUC_VA_LIST) \
++ && !defined(__NO_GNUC_VA_LIST)
++#define __GNUC_VA_LIST
++typedef __va_list __gnuc_va_list; /* compatibility w/GNU headers*/
++#endif
++
++#endif /* !_MACHINE__TYPES_H_ */
diff --git a/lang/smlnj/files/extra-patch-base_runtime_include_freebsd-9-i386-endian.h b/lang/smlnj/files/extra-patch-base_runtime_include_freebsd-9-i386-endian.h
new file mode 100644
index 000000000000..0b5e54e4a73d
--- /dev/null
+++ b/lang/smlnj/files/extra-patch-base_runtime_include_freebsd-9-i386-endian.h
@@ -0,0 +1,148 @@
+--- base/runtime/include/freebsd-9-i386-endian.h.orig 1970-01-01 01:00:00.000000000 +0100
++++ base/runtime/include/freebsd-9-i386-endian.h 2013-06-19 16:13:50.000000000 +0200
+@@ -0,0 +1,145 @@
++/*-
++ * Copyright (c) 1987, 1991 Regents of the University of California.
++ * All rights reserved.
++ *
++ * Redistribution and use in source and binary forms, with or without
++ * modification, are permitted provided that the following conditions
++ * are met:
++ * 1. Redistributions of source code must retain the above copyright
++ * notice, this list of conditions and the following disclaimer.
++ * 2. Redistributions in binary form must reproduce the above copyright
++ * notice, this list of conditions and the following disclaimer in the
++ * documentation and/or other materials provided with the distribution.
++ * 4. Neither the name of the University nor the names of its contributors
++ * may be used to endorse or promote products derived from this software
++ * without specific prior written permission.
++ *
++ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
++ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
++ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
++ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
++ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
++ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
++ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
++ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
++ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
++ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
++ * SUCH DAMAGE.
++ *
++ * @(#)endian.h 7.8 (Berkeley) 4/3/91
++ * $FreeBSD: stable/9/sys/i386/include/endian.h 219819 2011-03-21 09:40:01Z jeff $
++ */
++
++#ifndef _MACHINE_ENDIAN_H_
++#define _MACHINE_ENDIAN_H_
++
++#include <sys/cdefs.h>
++#include <sys/_types.h>
++
++#ifdef __cplusplus
++extern "C" {
++#endif
++
++/*
++ * Define the order of 32-bit words in 64-bit words.
++ */
++#define _QUAD_HIGHWORD 1
++#define _QUAD_LOWWORD 0
++
++/*
++ * Definitions for byte order, according to byte significance from low
++ * address to high.
++ */
++#define _LITTLE_ENDIAN 1234 /* LSB first: i386, vax */
++#define _BIG_ENDIAN 4321 /* MSB first: 68000, ibm, net */
++#define _PDP_ENDIAN 3412 /* LSB first in word, MSW first in long */
++
++#define _BYTE_ORDER _LITTLE_ENDIAN
++
++/*
++ * Deprecated variants that don't have enough underscores to be useful in more
++ * strict namespaces.
++ */
++#if __BSD_VISIBLE
++#define LITTLE_ENDIAN _LITTLE_ENDIAN
++#define BIG_ENDIAN _BIG_ENDIAN
++#define PDP_ENDIAN _PDP_ENDIAN
++#define BYTE_ORDER _BYTE_ORDER
++#endif
++
++#if defined(__GNUCLIKE_ASM) && defined(__GNUCLIKE_BUILTIN_CONSTANT_P)
++
++#define __bswap64_const(_x) \
++ (((_x) >> 56) | \
++ (((_x) >> 40) & (0xffULL << 8)) | \
++ (((_x) >> 24) & (0xffULL << 16)) | \
++ (((_x) >> 8) & (0xffULL << 24)) | \
++ (((_x) << 8) & (0xffULL << 32)) | \
++ (((_x) << 24) & (0xffULL << 40)) | \
++ (((_x) << 40) & (0xffULL << 48)) | \
++ ((_x) << 56))
++
++#define __bswap32_const(_x) \
++ (((_x) >> 24) | \
++ (((_x) & (0xff << 16)) >> 8) | \
++ (((_x) & (0xff << 8)) << 8) | \
++ ((_x) << 24))
++
++#define __bswap16_const(_x) (__uint16_t)((_x) << 8 | (_x) >> 8)
++
++static __inline __uint64_t
++__bswap64_var(__uint64_t __x)
++{
++
++ return __bswap64_const(__x);
++}
++
++
++static __inline __uint32_t
++__bswap32_var(__uint32_t _x)
++{
++
++ __asm ("bswap %0" : "+r" (_x));
++ return (_x);
++}
++
++static __inline __uint16_t
++__bswap16_var(__uint16_t _x)
++{
++
++ return (__bswap16_const(_x));
++}
++
++#define __bswap64(_x) \
++ (__builtin_constant_p(_x) ? \
++ __bswap64_const((__uint64_t)(_x)) : __bswap64_var(_x))
++
++#define __bswap32(_x) \
++ (__builtin_constant_p(_x) ? \
++ __bswap32_const((__uint32_t)(_x)) : __bswap32_var(_x))
++
++#define __bswap16(_x) \
++ (__builtin_constant_p(_x) ? \
++ __bswap16_const((__uint16_t)(_x)) : __bswap16_var(_x))
++
++#define __htonl(x) __bswap32(x)
++#define __htons(x) __bswap16(x)
++#define __ntohl(x) __bswap32(x)
++#define __ntohs(x) __bswap16(x)
++
++#else /* !(__GNUCLIKE_ASM && __GNUCLIKE_BUILTIN_CONSTANT_P) */
++
++/*
++ * No optimizations are available for this compiler. Fall back to
++ * non-optimized functions by defining the constant usually used to prevent
++ * redefinition.
++ */
++#define _BYTEORDER_FUNC_DEFINED
++
++#endif /* __GNUCLIKE_ASM && __GNUCLIKE_BUILTIN_CONSTANT_P */
++
++#ifdef __cplusplus
++}
++#endif
++
++#endif /* !_MACHINE_ENDIAN_H_ */
diff --git a/lang/smlnj/files/extra-patch-base_runtime_include_ml-unixdep.h b/lang/smlnj/files/extra-patch-base_runtime_include_ml-unixdep.h
new file mode 100644
index 000000000000..2acc3ac3341a
--- /dev/null
+++ b/lang/smlnj/files/extra-patch-base_runtime_include_ml-unixdep.h
@@ -0,0 +1,18 @@
+--- base/runtime/include/ml-unixdep.h.orig 2012-08-02 20:03:33.000000000 +0200
++++ base/runtime/include/ml-unixdep.h 2013-06-18 13:16:20.292993889 +0200
+@@ -371,6 +371,15 @@
+ # define __EXTENSIONS__
+ #endif
+
++#if defined(OPSYS_FREEBSD)
++# if defined(INCLUDE_FREEBSD_I386__TYPES)
++# include <sys/cdefs.h>
++# include INCLUDE_FREEBSD_I386__TYPES
++# endif
++# if defined(INCLUDE_FREEBSD_I386_SIGNAL)
++# include INCLUDE_FREEBSD_I386_SIGNAL
++# endif
++#endif
+ #include INCLUDE_TYPES_H
+ #include <unistd.h>
+ #include <string.h>
diff --git a/lang/smlnj/files/patch-config___arch-n-opsys b/lang/smlnj/files/patch-config___arch-n-opsys
new file mode 100644
index 000000000000..c4472c5fde4c
--- /dev/null
+++ b/lang/smlnj/files/patch-config___arch-n-opsys
@@ -0,0 +1,11 @@
+--- config/_arch-n-opsys.orig 2012-07-28 05:32:38.000000000 +0200
++++ config/_arch-n-opsys 2013-06-12 21:46:19.925992679 +0200
+@@ -83,6 +83,8 @@
+ HEAP_OPSYS=bsd
+ case `uname -m` in
+ *86) ARCH=x86;;
++ # Fall back to x86 compatibility mode.
++ amd64) ARCH=x86;;
+ *) exit 1;;
+ esac
+ ;;
diff --git a/lang/smlnj/files/patch-config___heap2exec b/lang/smlnj/files/patch-config___heap2exec
new file mode 100644
index 000000000000..c534993bec30
--- /dev/null
+++ b/lang/smlnj/files/patch-config___heap2exec
@@ -0,0 +1,33 @@
+--- config/_heap2exec 2006-04-20 17:28:53.000000000 +0200
++++ config/_heap2exec 2013-06-14 22:18:55.050990989 +0200
+@@ -83,6 +83,7 @@
+ A_PROG=
+ A_FLAGS=
+ A_LIBS=
++AS_FLAGS=
+
+ case ${OPSYS} in
+ darwin)
+@@ -96,6 +97,13 @@
+ A_PROG=${CC}
+ A_FLAGS=-Wl,--export-dynamic
+ A_LIBS=-lm
++ case `uname -m` in
++ amd64)
++ SO_FLAGS="${SO_FLAGS} -m32"
++ A_FLAGS="${A_FLAGS} -m32"
++ AS_FLAGS="${AS_FLAGS} -m32"
++ ;;
++ esac
+ ;;
+ linux)
+ SO_PROG=${CC}
+@@ -116,7 +124,7 @@
+ RESULT=0
+ if ${H2A} "$heapfile" "$execfile".s ; then
+ if [ -f "$execfile".s ] ; then
+- if ${CC} -c -o "$execfile".o "$execfile".s ; then
++ if ${CC} -c ${AS_FLAGS} -o "$execfile".o "$execfile".s ; then
+ rm "$execfile".s
+ else
+ rm "$execfile".s
diff --git a/lang/smlnj/files/patch-config_install.sh b/lang/smlnj/files/patch-config_install.sh
new file mode 100644
index 000000000000..dbfcd76daa67
--- /dev/null
+++ b/lang/smlnj/files/patch-config_install.sh
@@ -0,0 +1,180 @@
+--- config/install.sh.orig 2012-03-02 23:57:26.000000000 +0100
++++ config/install.sh 2014-07-14 20:12:56.000000000 +0200
+@@ -18,6 +18,8 @@
+ nolib=false
+ fi
+
++[ -n "$RECOMPILEDIR" ] && echo "RECOMPILEDIR=$RECOMPILEDIR"
++
+ if [ x${INSTALL_QUIETLY} = xtrue ] ; then
+ export CM_VERBOSE
+ CM_VERBOSE=false
+@@ -38,6 +40,28 @@
+ exit 1
+ }
+
++#
++# do_patch patch-file
++# apply a patch file
++do_patch() {
++ patchfile=$FILESDIR/$1
++
++ if [ ! -r $patchfile ]; then
++ echo "$this: !!! patch file $patchfile not found."
++ exit 1;
++ fi
++
++ if [ ! -f $CONFIGDIR/.patch_$1 ]; then
++ $PATCH $PATCH_ARGS < $patchfile || {\
++ echo "$this: !!! patch file $patchfile failed to patch."
++ exit 1;
++ }
++ echo > $CONFIGDIR/.patch_$1
++ else
++ echo "$this: patch $patchfile already installed."
++ fi
++}
++
+ this=$0
+
+
+@@ -97,7 +121,28 @@
+ # Especially important is CM_PATHCONFIG.
+ #
+ export CM_PATHCONFIG
+-CM_PATHCONFIG=$LIBDIR/pathconfig
++if [ -n "$STAGEDIR" -a -n "$MLLIB" ]
++then
++ # The final CM_PATHCONFIG file should not yet exist during
++ # staging, but still it has to be set in the environment when
++ # creating the (final) compiler heap. This way it becomes the
++ # the default pathconfig for the (final) heap.
++ # Therefore we will use the secondary pathconfig environment
++ # variable CM_LOCAL_PATHCONFIG to point to the (existing;)
++ # pathconfig in ROOT. This enables $smlnj/installer.cm
++ # to operate within STAGEDIR (using the final heap) below.
++ CM_PATHCONFIG=$MLLIB/pathconfig
++ if [ -r $CM_PATHCONFIG ]
++ then
++ vsay "$this: !!! Staging conflicts with an existing installation!"
++ complain "$this: !!! Make $CM_PATHCONFIG unreadable and try again!"
++ fi
++ CM_PATHCONFIG_STAGE=$STAGEDIR$CM_PATHCONFIG
++ CM_LOCAL_PATHCONFIG=$CM_PATHCONFIG_STAGE
++else
++ CM_PATHCONFIG=$LIBDIR/pathconfig
++ CM_PATHCONFIG_STAGE=$CM_PATHCONFIG
++fi
+ #
+ # the release version that we are installing
+ #
+@@ -327,7 +372,12 @@
+ # the name of the bin files directory
+ #
+ BOOT_ARCHIVE=boot.$ARCH-unix
+-BOOT_FILES=sml.$BOOT_ARCHIVE
++if [ -z "$RECOMPILEDIR" ]
++then
++ BOOT_FILES=sml.$BOOT_ARCHIVE
++else
++ BOOT_FILES=$RECOMPILEDIR/sml.$BOOT_ARCHIVE
++fi
+
+ #
+ # build the run-time system
+@@ -336,9 +386,15 @@
+ vsay $this: Run-time system already exists.
+ else
+ "$CONFIGDIR"/unpack "$ROOT" runtime
++ [ -n "$MLRUNTIMEPATCHES" ] && \
++ for p in $MLRUNTIMEPATCHES
++ do
++ do_patch $p
++ done
+ cd "$BASEDIR"/runtime/objs
+ echo $this: Compiling the run-time system.
+- $MAKE -f mk.$ARCH-$OPSYS $EXTRA_DEFS
++ echo "$MAKE -f mk.$ARCH-$OPSYS $EXTRA_DEFS AS=\""$AS\"" CFLAGS=\"$CFLAGS\""
++ $MAKE -f mk.$ARCH-$OPSYS $EXTRA_DEFS AS="$AS" CFLAGS="$CFLAGS"
+ if [ -x run.$ARCH-$OPSYS ]; then
+ mv run.$ARCH-$OPSYS "$RUNDIR"
+ if [ -f runx.$ARCH-$OPSYS ]; then
+@@ -350,7 +406,7 @@
+ if [ -f run.$ARCH-$OPSYS.a ]; then
+ mv run.$ARCH-$OPSYS.a "$RUNDIR"
+ fi
+- $MAKE MAKE=$MAKE clean
++ [ "$MLNORUNTIMECLEAN" ] || $MAKE MAKE=$MAKE clean
+ else
+ complain "$this: !!! Run-time system build failed for some reason."
+ fi
+@@ -376,7 +432,7 @@
+ complain "$this !!! Unable to re-create heap image (sml.$HEAP_SUFFIX)."
+ fi
+ else
+- "$CONFIGDIR"/unpack "$ROOT" "$BOOT_ARCHIVE"
++ [ -n "$RECOMPILEDIR" ] || "$CONFIGDIR"/unpack "$ROOT" "$BOOT_ARCHIVE"
+
+ fish "$ROOT"/"$BOOT_FILES"/smlnj/basis
+
+@@ -411,7 +467,7 @@
+ cd "$ROOT"/"$BOOT_FILES"
+ for anchor in * ; do
+ if [ -d $anchor ] ; then
+- echo $anchor $anchor >>$CM_PATHCONFIG
++ echo $anchor $anchor >>$CM_PATHCONFIG_STAGE
+ move $anchor "$LIBDIR"/$anchor
+ fi
+ done
+@@ -434,6 +490,18 @@
+
+ cd "$ROOT"
+
++# apply source patches for standard targets
++[ -n "$MLSTANDARDPATCHDIRS" ] && \
++for d in $MLSTANDARDPATCHDIRS
++do
++ "$CONFIGDIR"/unpack "$ROOT" "$d"
++done
++[ -n "$MLSTANDARDPATCHES" ] && \
++for p in $MLSTANDARDPATCHES
++do
++ do_patch $p
++done
++
+ #
+ # Now do all the rest using the precompiled installer:
+ #
+@@ -442,6 +510,12 @@
+ export ROOT INSTALLDIR CONFIGDIR BINDIR
+ CM_TOLERATE_TOOL_FAILURES=true
+ export CM_TOLERATE_TOOL_FAILURES
++ # smlnj/installer/nix-install.sml (re)sets CM_LOCAL_PATHCONFIG
++ # to /dev/null in the buildcmd that it uses to invoke the builds.
++ # So the build process needs a working CM_PATHCONFIG. This is NOT
++ # propagated to the resulting heaps because the heaps generated
++ # in this stage don't contain the compiler.
++ [ -z "$STAGEDIR" ] || CM_PATHCONFIG=$CM_LOCAL_PATHCONFIG
+ if "$BINDIR"/sml -m \$smlnj/installer.cm
+ then
+ vsay $this: Installation complete.
+@@ -450,4 +524,19 @@
+ fi
+ fi
+
++# Finish staging by removing the $STAGEDIR prefix from the driver scripts.
++if [ -n "$STAGEDIR" ]
++then
++ find $BINDIR -type f -perm -1 | \
++ xargs fgrep -l "$STAGEDIR" | \
++ xargs sed -i "" -e 's%'"$STAGEDIR"'%%g'
++fi
++
++# apply all source patches
++[ -n "$MLSOURCEPATCHES" ] && \
++for p in $MLSOURCEPATCHES
++do
++ do_patch $p
++done
++
+ exit 0
diff --git a/lang/smlnj/files/pkg-install.in b/lang/smlnj/files/pkg-install.in
new file mode 100644
index 000000000000..abed0aab5e53
--- /dev/null
+++ b/lang/smlnj/files/pkg-install.in
@@ -0,0 +1,589 @@
+#!/bin/sh
+# This file was automatically created - don't modify it!
+#%%SOURCEINFO-START%%
+# source version: $Id: $
+# installed by port/package: %%SOURCEINFO-PACKAGE%%
+# installed from file: %%SOURCEINFO-FILE%%
+#%%SOURCEINFO-END%%
+if [ -n "$MULTIEXEC_WRAPPER_VERBOSE" ]
+then
+ QUIET=0
+else
+ QUIET=1
+fi
+#%%PKG-INSTALL-START%%
+# ===== IMPORTANT =====
+# If you modify any byte of this script outside of the
+# %%SOURCEINFO-*%% and #%%PKG-INSTALL-*%% sections, then
+# don't forget to bump the MINOR version variable below!
+#
+case "$2" in
+ # no-op cases if called as port/package de/installation script
+ PRE-INSTALL|POST-DEINSTALL)
+ exit 0
+ ;;
+esac
+#%%PKG-INSTALL-END%%
+
+ME=multiexec-wrapper
+CALLED_NAME="`basename $0`"
+PREFIX=%%PREFIX%%
+CONFIG="$PREFIX/etc/$ME.conf"
+
+lookup_executable() {
+ local calledname pkgname name executable rest \
+ portname version envvarname envvarversion result
+ # use global variable for the result to avoid subshell
+ lookup_executable_result=
+ [ -r "$CONFIG" ] || return 1
+ calledname="$1"
+ result=
+ while read pkgname name executable rest
+ do
+ if [ "$name" = "$calledname" -a -n "$executable" ]
+ then
+ result="$executable"
+ portname=`expr "$pkgname" : "\(.*\)-"`
+ envvarname="`echo -n "$portname" | \
+ tr "[:lower:]" "[:upper:]" | \
+ tr -cs "[:alnum:]" "_"`"
+ # <PORTNAME> variable selects package if name matches
+ eval envvarvalue='$'"$envvarname"
+ if [ -n "$envvarvalue" ]
+ then
+ break
+ fi
+ # <PORTNAME>_VERSION variable selects package version
+ version=`expr "$pkgname" : ".*-\([^-_,]*\)"`
+ eval envvarversion='$'"$envvarname"_VERSION
+ if [ "$envvarversion" = "$version" ]
+ then
+ break
+ fi
+ fi
+ done < "$CONFIG"
+ lookup_executable_result="$result"
+}
+
+warn () {
+ echo "${ME}: $1" 1>&2
+}
+
+die () {
+ warn "$1"
+ exit 1
+}
+
+# Normal usage: if called through a symlink,
+# lookup and exec a registered executable.
+
+if [ -L "$0" -a "$CALLED_NAME" != "$ME" ]
+then
+ lookup_executable "$CALLED_NAME"
+ executable="$lookup_executable_result"
+ if [ -x "$executable" ]
+ then
+ exec "$executable" "$@"
+ elif [ -z "$executable" ]
+ then
+ die "no executable registered for '$CALLED_NAME'."
+ elif [ ! -e "$executable" ]
+ then
+ die "$executable does not exist."
+ else
+ die "$executable is not executable."
+ fi
+fi
+
+EPOCH=1
+CONFIG_FORMAT=1
+MAJOR=1
+MINOR=1
+VERSION=$EPOCH.$CONFIG_FORMAT.$MAJOR.$MINOR
+
+usage() {
+ echo "usage: $ME <cmd> <arg> ..."
+ echo " with one of the following <cmd>s:"
+#%%PKG-INSTALL-START%%
+ echo " install-self-to <prefix> <pkgname>"
+ echo " deinstall-self-from <prefix>"
+#%%PKG-INSTALL-END%%
+ echo " deinstall-pkg <pkgname>"
+ echo " register <pkgname> <name> <executable>"
+ echo " unregister <pkgname> <name> <executable>"
+ echo " version"
+ echo " which <name>"
+ echo " list-all-packages"
+ echo " list-packages-for-name <name>"
+ exit 1
+}
+
+say () {
+ [ $QUIET -gt 0 ] || echo "${ME}: $1"
+}
+
+version() {
+ echo "$VERSION"
+ exit 0
+}
+
+which() {
+ local name executable
+ name="$1"
+ lookup_executable "$name"
+ executable="$lookup_executable_result"
+ [ -z "$executable" ] && return 1
+ echo "$executable"
+}
+
+#%%PKG-INSTALL-START%%
+install_self_to() {
+ local pkgname myself target oldversion tmpfile tmpfile_gz
+ PREFIX="$1"
+ pkgname="$2"
+ if [ "$0" = "/bin/sh" ]
+ then # We're stdin of a shell (installation from binary package).
+ # Recover original script from its b64encoded compressed source.
+ tmpfile=`mktemp "/tmp/$ME.XXXXXX"`
+ tmpfile_gz=`mktemp "/tmp/$ME.gz.XXXXXX"`
+ trap "rm -f $tmpfile $tmpfile_gz" EXIT
+ b64decode -p > $tmpfile_gz << '~EOF~'
+~EOF~
+ gunzip -cf $tmpfile_gz > $tmpfile || die "decompression of script source for $ME failed."
+ myself=$tmpfile
+ else
+ myself=`realpath "$0"`
+ fi
+ target="$PREFIX/bin/$ME"
+ MYSELF_INSTALLED="$target"
+ if [ -e "$target" ]
+ then
+ if [ ! -x "$target" ]
+ then
+ die "$target already exists but is not executable."
+ else
+ oldversion=`$target version 2>/dev/null`
+ if [ $? -ne 0 ]
+ then
+ die "bogus $target already exists."
+ elif [ "$oldversion" = "$VERSION" ]
+ then
+ oldmd5=`sed -e '/^#%%PKG-INSTALL-START%%$/,/^#%%PKG-INSTALL-END%%$/d' \
+ -e '/^#%%SOURCEINFO-START%%$/,/^#%%SOURCEINFO-END%%$/d' \
+ -e 's?\%\%PREFIX\%\%?'"$PREFIX"'?g' "$target" | \
+ md5 -q`
+ newmd5=`sed -e '/^#%%PKG-INSTALL-START%%$/,/^#%%PKG-INSTALL-END%%$/d' \
+ -e '/^#%%SOURCEINFO-START%%$/,/^#%%SOURCEINFO-END%%$/d' \
+ -e 's?\%\%PREFIX\%\%?'"$PREFIX"'?g' "$myself" | \
+ md5 -q`
+ if [ "$newmd5" = "$oldmd5" ]
+ then
+ say "$myself (version $VERSION) already installed as $target."
+ return
+ else
+ die "$myself and $target have same version ($VERSION) but differ."
+ fi
+ elif [ `pkg_version -t "$oldversion" "$VERSION"` != "<" ]
+ then
+ say "$myself (version $VERSION) is not newer than $target (version $oldversion)."
+ fi
+ fi
+ fi
+ if sed -e '/^#%%PKG-INSTALL-START%%$/,/^#%%PKG-INSTALL-END%%$/d' \
+ -e 's?%%SOURCEINFO-PACKAGE%%?'"$pkgname"'?g' \
+ -e 's?%%SOURCEINFO-FILE%%?'"$myself"'?g' \
+ -e 's?\%\%PREFIX\%\%?'"$PREFIX"'?g' "$myself" > "$target" && \
+ chmod +x "$target"
+ then
+ say "$myself (version $VERSION) installed as $target."
+ return
+ else
+ die "failed to install $ME (version $VERSION) as $target."
+ fi
+}
+
+deinstall_self_from() {
+ local config_empty=1
+ PREFIX="$1"
+ MYSELF_INSTALLED="$PREFIX/bin/$ME"
+ CONFIG="$PREFIX/etc/$ME.conf"
+ if [ ! -e "$CONFIG" ]
+ then
+ say "$CONFIG does not exist."
+ elif grep -v -q "^/SELF/" "$CONFIG"
+ then
+ say "$CONFIG is not empty."
+ config_empty=0
+ elif rm -f "$CONFIG"
+ then
+ say "$CONFIG removed."
+ else
+ warn "failed to remove $CONFIG."
+ fi
+ if [ "$config_empty" -eq 1 ]
+ then
+ if [ ! -e "$MYSELF_INSTALLED" ]
+ then
+ warn "$MYSELF_INSTALLED does not exist."
+ elif rm -f "$MYSELF_INSTALLED"
+ then
+ say "$MYSELF_INSTALLED removed."
+ else
+ warn "failed to remove $MYSELF_INSTALLED."
+ fi
+ fi
+}
+
+#%%PKG-INSTALL-END%%
+
+config_init() {
+ local format oldformat pkgname name executable rest
+ format="$EPOCH.$CONFIG_FORMAT"
+ if [ -r "$CONFIG" -a -s "$CONFIG" ]
+ then
+ oldformat=`cat "$CONFIG" | \
+ while read pkgname name executable rest
+ do
+ if [ "$pkgname" = "/SELF/" -a "$name" = "/FORMAT/" ]
+ then
+ echo "$executable"
+ break
+ fi
+ done`
+ if [ -z "$oldformat" ]
+ then
+ say "old $CONFIG has no format information - backing up ..."
+ if mv "$CONFIG" "$CONFIG.bak"
+ then
+ say "... done"
+ else
+ die "failed to backup old $CONFIG."
+ fi
+ elif [ "$oldformat" = "$format" ]
+ then
+ say "matching format statement found in $CONFIG."
+ else
+ # XXX compare versions and try to upgrade if appropriate
+ die "differing format statement found in $CONFIG ($executable instead of $format)."
+ fi
+ elif echo "/SELF/ /FORMAT/ $format" > "$CONFIG"
+ then
+ say "$CONFIG initialized."
+ else
+ die "failed to initialize $CONFIG"
+ fi
+}
+
+lookup_matches() {
+ local pkgname name executable rest p n e r
+ pkgname="$1"
+ name="$2"
+ executable="$3"
+ [ -r "$CONFIG" ] || return 1
+ cat "$CONFIG" | \
+ while read p n e r
+ do
+ [ "$pkgname" = "" -o "$p" = "$pkgname" ] && \
+ [ "$name" = "" -o "$n" = "$name" ] && \
+ [ "$executable" = "" -o "$e" = "$executable" ] && \
+ echo "$p $n $e"
+ done
+ return 0
+}
+
+config_add() {
+ local pkgname name executable matches
+ pkgname="$1"
+ name="$2"
+ executable="$3"
+ if [ ! -e "$CONFIG" ]
+ then
+ config_init
+ fi
+ if [ ! -r "$CONFIG" ]
+ then
+ die "$CONFIG not readable."
+ else
+ matches=`lookup_matches "$pkgname" "$name" "$executable"`
+ if [ -n "$matches" ]
+ then
+ say "already registered in $CONFIG: $pkgname $name $executable"
+ return
+ elif [ ! -w "$CONFIG" ]
+ then
+ die "$CONFIG is not writeable"
+ fi
+ fi
+ if echo "$pkgname $name $executable" >> "$CONFIG"
+ then
+ say "now added to config: $pkgname $name $executable"
+ else
+ die "write failed while trying to add to $CONFIG: $pkgname $name $executable"
+ fi
+}
+
+config_delete() {
+ local pkgname name executable matches
+ pkgname="$1"
+ name="$2"
+ executable="$3"
+ if [ ! -e "$CONFIG" ]
+ then
+ die "failed to delete from config: $CONFIG does not exist."
+ elif [ ! -r "$CONFIG" ]
+ then
+ die "$CONFIG not readable."
+ else
+ matches=`lookup_matches "$pkgname" "$name" "$executable"`
+ if [ -z "$matches" ]
+ then
+ say "no entry found in config for: $pkgname $name $executable."
+ elif [ ! -w "$CONFIG" ]
+ then
+ die "$CONFIG is not writeable."
+ elif [ ! -w `dirname "$CONFIG"` ]
+ then
+ die "config directory `dirname $CONFIG` is not writeable."
+ elif awk '$1 != "'"$pkgname"'" || \
+ $2 != "'"$name"'" || \
+ $3 != "'"$executable"'"' \
+ "$CONFIG" > "$CONFIG.new"
+ then
+ if diff -q "$CONFIG" "$CONFIG.new" >/dev/null
+ then
+ say "failed to delete from config (match problem): $pkgname $name $executable."
+ rm "$CONFIG.new"
+ elif mv -f "$CONFIG.new" "$CONFIG"
+ then
+ say "deleted from config: $pkgname $name $executable."
+ else
+ die "failed to update $CONFIG."
+ fi
+ else
+ die "failed to create new config $CONFIG.new."
+ fi
+ fi
+}
+
+register() {
+ local pkgname name executable savedwd
+ pkgname="$1"
+ name="$2"
+ executable="$3"
+ savedwd=$PWD
+ if [ ! -e "$executable" ]
+ then
+ die "won't register ${name}: $executable does not exist"
+ elif [ ! -x "$executable" ]
+ then
+ die "won't register ${name}: $executable is not executable"
+ elif cd "$PREFIX/bin"
+ then
+ if [ -e "$name" ]
+ then
+ if [ -L "$name" ]
+ then
+ target=`readlink $name`
+ if [ "$target" = "$ME" ]
+ then
+ say "symlink $name -> $ME already exists."
+ else
+ die "symlink $name already exists, but does not point to $ME (instead to $target)."
+ fi
+ else
+ die "$name already exists, but is not a symlink."
+ fi
+ else
+ if ln -s "$ME" "$name"
+ then
+ say "symlink $name -> $ME created."
+ else
+ die "failed to create symlink $name -> $ME."
+ fi
+ fi
+ config_add "$pkgname" "$name" "$executable"
+ else
+ die "can't cd to $PREFIX/bin."
+ fi
+ cd "$savedwd"
+}
+
+unregister() {
+ local pkgname name executable savedwd matches count
+ pkgname="$1"
+ name="$2"
+ executable="$3"
+ savedwd=$PWD
+ if [ ! -e "$executable" ]
+ then
+ say "while unregistering ${name}: $executable does not exist"
+ elif [ ! -x "$executable" ]
+ then
+ say "while unregistering ${name}: $executable is not executable"
+ fi
+ if cd "$PREFIX/bin"
+ then
+ if [ ! -e "$name" ]
+ then
+ say "symlink $name does not exist."
+ elif [ ! -L "$name" ]
+ then
+ say "$name exists, but is not a symlink."
+ else
+ target=`readlink $name`
+ if [ "$target" != "$ME" ]
+ then
+ say "symlink $name exists, but does not point to $ME (instead to $target)."
+ else
+ matches=`lookup_matches "" "$name"`
+ count=`printf "%s" "$matches" | wc -l`
+ if [ "$count" -eq 0 -o \
+ \( "$count" -eq 1 -a \
+ `expr "$matches" : "${pkgname}-"` -gt 0 \) ]
+ then
+ if rm -f "$name"
+ then
+ say "symlink $name removed."
+ else
+ die "failed to remove symlink $name -> $ME."
+ fi
+ else
+ say "not removing symlink $name because of further config entries."
+ fi
+ fi
+ fi
+ config_delete "$pkgname" "$name" "$executable"
+ else
+ die "can't cd to $PREFIX/bin."
+ fi
+ cd "$savedwd"
+}
+
+deinstall_pkg() {
+ local pkgname matches count p n e r
+ pkgname="$1"
+ matches=`lookup_matches "$pkgname"`
+ if [ $? -ne 0 ]
+ then
+ die "reading $CONFIG failed."
+ elif [ -z "$matches" ]
+ then
+ say "no entries for package $package in $CONFIG."
+ else
+ count=`printf "%s" "$matches" | wc -l`
+ say "trying to unregister $count entries for package $pkgname."
+ cat "$CONFIG" | \
+ while read p n e r
+ do
+ if [ "$p" = "$pkgname" ]
+ then
+ if [ -z "$n" ]
+ then
+ warn "in $CONFIG: incomplete config entry (no name) found for package $pkgname."
+ elif [ -z "$e" ]
+ then
+ warn "in $CONFIG: incomplete config entry (no executable) found for package $pkgname, name $name."
+ else
+ unregister "$pkgname" "$n" "$e"
+ fi
+ fi
+ done
+ fi
+}
+
+
+#%%PKG-INSTALL-START%%
+case "$2" in
+ POST-INSTALL)
+ PKGNAME="$1"
+ install_self_to "$PKG_PREFIX" "$PKGNAME"
+ "$MYSELF_INSTALLED" config-init || die "config-init of $CONFIG failed."
+ for exename in %%EXENAMES%%
+ do
+ exepath="$PKG_PREFIX/%%EXEBINDIR%%/$exename"
+ if [ -x "$exepath" ]
+ then
+ "$MYSELF_INSTALLED" register "$PKGNAME" "$exename" "$exepath" \
+ || die "failure during registration - aborting."
+ else
+ die "not an executable: $exepath."
+ fi
+ done
+ ;;
+ DEINSTALL)
+ PKGNAME="$1"
+ PREFIX="$PKG_PREFIX"
+ CONFIG="$PREFIX/etc/$ME.conf"
+ MYSELF_INSTALLED="$PREFIX/bin/$ME"
+ doitmyself=0
+ if [ ! -e "$MYSELF_INSTALLED" ]
+ then
+ say "$ME was not (or is no longer) installed as $MYSELF_INSTALLED."
+ doitmyself=1
+ elif [ ! -x "$MYSELF_INSTALLED" ]
+ then
+ say "$MYSELF_INSTALLED is not executable."
+ doitmyself=1
+ fi
+ if [ "$doitmyself" -eq 0 ]
+ then
+ "$MYSELF_INSTALLED" deinstall-pkg "$PKGNAME"
+ else
+ deinstall_pkg "$PKGNAME"
+ fi
+ deinstall_self_from "$PKG_PREFIX"
+ ;;
+esac
+#%%PKG-INSTALL-END%%
+
+list_all_packages() {
+ grep -v "^/" "$CONFIG" | \
+ awk '{ print $1 }' | \
+ uniq
+}
+
+list_packages_for_name() {
+ local name="$1"
+ lookup_matches "" "$name" "" | \
+ awk '{ print $1 }'
+}
+
+# main
+
+case "$1" in
+""|-h|--help)
+ usage
+ ;;
+#%%PKG-INSTALL-START%%
+install-self-to)
+ install_self_to "$2" "$3"
+ ;;
+deinstall-self-from)
+ deinstall_self_from "$2"
+ ;;
+#%%PKG-INSTALL-END%%
+version)
+ version
+ ;;
+which)
+ which "$2"
+ ;;
+config-init)
+ config_init
+ ;;
+register)
+ register "$2" "$3" "$4"
+ ;;
+unregister)
+ unregister "$2" "$3" "$4"
+ ;;
+deinstall-pkg)
+ deinstall_pkg "$2"
+ ;;
+list-all-packages)
+ list_all_packages "$2"
+ ;;
+list-packages-for-name)
+ list_packages_for_name "$2"
+ ;;
+esac
diff --git a/lang/smlnj/pkg-descr b/lang/smlnj/pkg-descr
new file mode 100644
index 000000000000..5e0ba89151d5
--- /dev/null
+++ b/lang/smlnj/pkg-descr
@@ -0,0 +1,12 @@
+Standard ML (SML) is a safe, modular, strict, functional,
+polymorphic programming language with compile-time type checking
+and type inference, garbage collection, exception handling,
+immutable data types and updatable references, abstract data types,
+and parametric modules. It has efficient implementations and a
+formal definition with a proof of soundness.
+
+Standard ML of New Jersey (abbreviated SML/NJ) is a compiler for
+the Standard ML '97 programming language with associated libraries,
+tools, and documentation.
+
+WWW: http://www.smlnj.org/
diff --git a/lang/smlnj/pkg-plist b/lang/smlnj/pkg-plist
new file mode 100644
index 000000000000..7ada4e057532
--- /dev/null
+++ b/lang/smlnj/pkg-plist
@@ -0,0 +1,337 @@
+smlnj/bin/.arch-n-opsys
+smlnj/bin/.heap/heap2asm.%%MLARCH%%-bsd
+smlnj/bin/.heap/ml-antlr.%%MLARCH%%-bsd
+smlnj/bin/.heap/ml-burg.%%MLARCH%%-bsd
+smlnj/bin/.heap/ml-lex.%%MLARCH%%-bsd
+smlnj/bin/.heap/ml-nlffigen.%%MLARCH%%-bsd
+smlnj/bin/.heap/ml-ulex.%%MLARCH%%-bsd
+smlnj/bin/.heap/ml-yacc.%%MLARCH%%-bsd
+%%EVERYTHING%%smlnj/bin/.heap/nowhere.%%MLARCH%%-bsd
+smlnj/bin/.heap/sml.%%MLARCH%%-bsd
+smlnj/bin/.link-sml
+smlnj/bin/.run/run.%%MLARCH%%-freebsd
+smlnj/bin/.run/run.%%MLARCH%%-freebsd.a
+smlnj/bin/.run/run.%%MLARCH%%-freebsd.so
+smlnj/bin/.run-sml
+smlnj/bin/heap2asm
+smlnj/bin/heap2exec
+smlnj/bin/ml-antlr
+smlnj/bin/ml-build
+smlnj/bin/ml-burg
+smlnj/bin/ml-lex
+smlnj/bin/ml-makedepend
+smlnj/bin/ml-nlffigen
+smlnj/bin/ml-ulex
+smlnj/bin/ml-yacc
+%%EVERYTHING%%smlnj/bin/nowhere
+smlnj/bin/sml
+smlnj/lib/SMLNJ-BASIS/.cm/%%MLARCH%%-unix/basis.cm
+smlnj/lib/SMLNJ-LIB/Controls/.cm/%%MLARCH%%-unix/controls-lib.cm
+smlnj/lib/SMLNJ-LIB/HTML/.cm/%%MLARCH%%-unix/html-lib.cm
+smlnj/lib/SMLNJ-LIB/PP/.cm/%%MLARCH%%-unix/pp-lib.cm
+smlnj/lib/SMLNJ-LIB/Util/.cm/%%MLARCH%%-unix/smlnj-lib.cm
+smlnj/lib/SMLNJ-ML-YACC-LIB/.cm/%%MLARCH%%-unix/ml-yacc-lib.cm
+smlnj/lib/SMLNJ-MLRISC/.cm/%%MLARCH%%-unix/ALPHA.cm
+smlnj/lib/SMLNJ-MLRISC/.cm/%%MLARCH%%-unix/AMD64-Peephole.cm
+smlnj/lib/SMLNJ-MLRISC/.cm/%%MLARCH%%-unix/AMD64.cm
+smlnj/lib/SMLNJ-MLRISC/.cm/%%MLARCH%%-unix/CCall-Vararg.cm
+smlnj/lib/SMLNJ-MLRISC/.cm/%%MLARCH%%-unix/CCall-sparc.cm
+smlnj/lib/SMLNJ-MLRISC/.cm/%%MLARCH%%-unix/CCall-x86-64.cm
+smlnj/lib/SMLNJ-MLRISC/.cm/%%MLARCH%%-unix/CCall-x86.cm
+smlnj/lib/SMLNJ-MLRISC/.cm/%%MLARCH%%-unix/CCall.cm
+smlnj/lib/SMLNJ-MLRISC/.cm/%%MLARCH%%-unix/Control.cm
+smlnj/lib/SMLNJ-MLRISC/.cm/%%MLARCH%%-unix/Graphs.cm
+smlnj/lib/SMLNJ-MLRISC/.cm/%%MLARCH%%-unix/HPPA.cm
+smlnj/lib/SMLNJ-MLRISC/.cm/%%MLARCH%%-unix/IA32-Peephole.cm
+smlnj/lib/SMLNJ-MLRISC/.cm/%%MLARCH%%-unix/IA32.cm
+smlnj/lib/SMLNJ-MLRISC/.cm/%%MLARCH%%-unix/Lib.cm
+smlnj/lib/SMLNJ-MLRISC/.cm/%%MLARCH%%-unix/MLRISC.cm
+smlnj/lib/SMLNJ-MLRISC/.cm/%%MLARCH%%-unix/MLTREE.cm
+smlnj/lib/SMLNJ-MLRISC/.cm/%%MLARCH%%-unix/PPC.cm
+smlnj/lib/SMLNJ-MLRISC/.cm/%%MLARCH%%-unix/Peephole.cm
+smlnj/lib/SMLNJ-MLRISC/.cm/%%MLARCH%%-unix/RA.cm
+smlnj/lib/SMLNJ-MLRISC/.cm/%%MLARCH%%-unix/SPARC.cm
+smlnj/lib/SMLNJ-MLRISC/.cm/%%MLARCH%%-unix/StagedAlloc.cm
+smlnj/lib/SMLNJ-MLRISC/.cm/%%MLARCH%%-unix/Visual.cm
+smlnj/lib/burg-ext.cm/.cm/%%MLARCH%%-unix/burg-ext.cm
+smlnj/lib/c/.cm/%%MLARCH%%-unix/c.cm
+smlnj/lib/c/internals/.cm/%%MLARCH%%-unix/c-int.cm
+smlnj/lib/c/memory/.cm/%%MLARCH%%-unix/memory.cm
+smlnj/lib/ckit-lib.cm/.cm/%%MLARCH%%-unix/ckit-lib.cm
+smlnj/lib/cml/.cm/%%MLARCH%%-unix/basis.cm
+smlnj/lib/cml/.cm/%%MLARCH%%-unix/cml-internal.cm
+smlnj/lib/cml/.cm/%%MLARCH%%-unix/cml-lib.cm
+smlnj/lib/cml/.cm/%%MLARCH%%-unix/cml.cm
+smlnj/lib/cml/.cm/%%MLARCH%%-unix/core-cml.cm
+smlnj/lib/cml/.cm/%%MLARCH%%-unix/inet-lib.cm
+smlnj/lib/cml/.cm/%%MLARCH%%-unix/smlnj-lib.cm
+smlnj/lib/cml/.cm/%%MLARCH%%-unix/trace-cml.cm
+smlnj/lib/cml/.cm/%%MLARCH%%-unix/unix-lib.cm
+smlnj/lib/cml-lib/.cm/%%MLARCH%%-unix/smlnj-lib.cm
+smlnj/lib/cml-lib/.cm/%%MLARCH%%-unix/trace-cml.cm
+smlnj/lib/dir-tool.cm/.cm/%%MLARCH%%-unix/dir-tool.cm
+%%EVERYTHING%%smlnj/lib/eXene.cm/.cm/%%MLARCH%%-unix/eXene.cm
+smlnj/lib/grm-ext.cm/.cm/%%MLARCH%%-unix/grm-ext.cm
+smlnj/lib/hash-cons-lib.cm/.cm/%%MLARCH%%-unix/hash-cons-lib.cm
+smlnj/lib/html4-lib.cm/.cm/%%MLARCH%%-unix/html4-lib.cm
+smlnj/lib/inet-lib.cm/.cm/%%MLARCH%%-unix/inet-lib.cm
+smlnj/lib/json-lib.cm/.cm/%%MLARCH%%-unix/json-lib.cm
+smlnj/lib/lex-ext.cm/.cm/%%MLARCH%%-unix/lex-ext.cm
+smlnj/lib/make-tool.cm/.cm/%%MLARCH%%-unix/make-tool.cm
+smlnj/lib/ml-antlr-tool.cm/.cm/%%MLARCH%%-unix/ml-antlr-tool.cm
+smlnj/lib/ml-lpt-lib.cm/.cm/%%MLARCH%%-unix/ml-lpt-lib.cm
+smlnj/lib/ml-ulex-tool.cm/.cm/%%MLARCH%%-unix/ml-ulex-tool.cm
+smlnj/lib/mlburg-tool.cm/.cm/%%MLARCH%%-unix/mlburg-tool.cm
+smlnj/lib/mllex-tool.cm/.cm/%%MLARCH%%-unix/mllex-tool.cm
+%%EVERYTHING%%smlnj/lib/mlrisc-tools/.cm/%%MLARCH%%-unix/match-compiler.cm
+%%EVERYTHING%%smlnj/lib/mlrisc-tools/.cm/%%MLARCH%%-unix/parser.cm
+%%EVERYTHING%%smlnj/lib/mlrisc-tools/.cm/%%MLARCH%%-unix/pp.cm
+%%EVERYTHING%%smlnj/lib/mlrisc-tools/.cm/%%MLARCH%%-unix/prec-parser.cm
+%%EVERYTHING%%smlnj/lib/mlrisc-tools/.cm/%%MLARCH%%-unix/sml-ast.cm
+%%EVERYTHING%%smlnj/lib/mlrisc-tools/.cm/%%MLARCH%%-unix/source-map.cm
+smlnj/lib/mlyacc-tool.cm/.cm/%%MLARCH%%-unix/mlyacc-tool.cm
+smlnj/lib/noweb-tool.cm/.cm/%%MLARCH%%-unix/noweb-tool.cm
+smlnj/lib/nw-ext.cm/.cm/%%MLARCH%%-unix/nw-ext.cm
+smlnj/lib/pathconfig
+%%EVERYTHING%%smlnj/lib/pgraph-util.cm/.cm/%%MLARCH%%-unix/pgraph-util.cm
+smlnj/lib/pgraph.cm/.cm/%%MLARCH%%-unix/pgraph.cm
+smlnj/lib/pickle-lib.cm/.cm/%%MLARCH%%-unix/pickle-lib.cm
+smlnj/lib/reactive-lib.cm/.cm/%%MLARCH%%-unix/reactive-lib.cm
+smlnj/lib/regexp-lib.cm/.cm/%%MLARCH%%-unix/regexp-lib.cm
+smlnj/lib/sexp-lib.cm/.cm/%%MLARCH%%-unix/sexp-lib.cm
+smlnj/lib/shell-tool.cm/.cm/%%MLARCH%%-unix/shell-tool.cm
+smlnj/lib/smlnj-tdp/.cm/%%MLARCH%%-unix/back-trace.cm
+smlnj/lib/smlnj-tdp/.cm/%%MLARCH%%-unix/coverage.cm
+smlnj/lib/smlnj-tdp/.cm/%%MLARCH%%-unix/plugins.cm
+smlnj/lib/smlnj/.cm/%%MLARCH%%-unix/cm.cm
+smlnj/lib/smlnj/.cm/%%MLARCH%%-unix/cmb.cm
+smlnj/lib/smlnj/.cm/%%MLARCH%%-unix/compiler.cm
+smlnj/lib/smlnj/.cm/%%MLARCH%%-unix/installer.cm
+smlnj/lib/smlnj/.cm/%%MLARCH%%-unix/library-install.cm
+smlnj/lib/smlnj/MLRISC/.cm/%%MLARCH%%-unix/ALPHA.cm
+smlnj/lib/smlnj/MLRISC/.cm/%%MLARCH%%-unix/AMD64.cm
+smlnj/lib/smlnj/MLRISC/.cm/%%MLARCH%%-unix/Control.cm
+smlnj/lib/smlnj/MLRISC/.cm/%%MLARCH%%-unix/Graphs.cm
+smlnj/lib/smlnj/MLRISC/.cm/%%MLARCH%%-unix/HPPA.cm
+smlnj/lib/smlnj/MLRISC/.cm/%%MLARCH%%-unix/IA32.cm
+smlnj/lib/smlnj/MLRISC/.cm/%%MLARCH%%-unix/Lib.cm
+smlnj/lib/smlnj/MLRISC/.cm/%%MLARCH%%-unix/MLRISC.cm
+smlnj/lib/smlnj/MLRISC/.cm/%%MLARCH%%-unix/MLTREE.cm
+smlnj/lib/smlnj/MLRISC/.cm/%%MLARCH%%-unix/PPC.cm
+smlnj/lib/smlnj/MLRISC/.cm/%%MLARCH%%-unix/SPARC.cm
+smlnj/lib/smlnj/MLRISC/.cm/%%MLARCH%%-unix/Visual.cm
+smlnj/lib/smlnj/basis/.cm/%%MLARCH%%-unix/basis.cm
+smlnj/lib/smlnj/cm/.cm/%%MLARCH%%-unix/cm.cm
+smlnj/lib/smlnj/cm/.cm/%%MLARCH%%-unix/tools.cm
+smlnj/lib/smlnj/cmb/.cm/%%MLARCH%%-unix/alpha32-unix.cm
+smlnj/lib/smlnj/cmb/.cm/%%MLARCH%%-unix/amd64-unix.cm
+smlnj/lib/smlnj/cmb/.cm/%%MLARCH%%-unix/current.cm
+smlnj/lib/smlnj/cmb/.cm/%%MLARCH%%-unix/hppa-unix.cm
+smlnj/lib/smlnj/cmb/.cm/%%MLARCH%%-unix/ppc-macos.cm
+smlnj/lib/smlnj/cmb/.cm/%%MLARCH%%-unix/ppc-unix.cm
+smlnj/lib/smlnj/cmb/.cm/%%MLARCH%%-unix/sparc-unix.cm
+smlnj/lib/smlnj/cmb/.cm/%%MLARCH%%-unix/x86-unix.cm
+smlnj/lib/smlnj/cmb/.cm/%%MLARCH%%-unix/x86-win32.cm
+smlnj/lib/smlnj/compiler/.cm/%%MLARCH%%-unix/all.cm
+smlnj/lib/smlnj/compiler/.cm/%%MLARCH%%-unix/alpha32.cm
+smlnj/lib/smlnj/compiler/.cm/%%MLARCH%%-unix/amd64.cm
+smlnj/lib/smlnj/compiler/.cm/%%MLARCH%%-unix/compiler.cm
+smlnj/lib/smlnj/compiler/.cm/%%MLARCH%%-unix/current.cm
+smlnj/lib/smlnj/compiler/.cm/%%MLARCH%%-unix/hppa.cm
+smlnj/lib/smlnj/compiler/.cm/%%MLARCH%%-unix/minimal-only.cm
+smlnj/lib/smlnj/compiler/.cm/%%MLARCH%%-unix/minimal.cm
+smlnj/lib/smlnj/compiler/.cm/%%MLARCH%%-unix/ppc.cm
+smlnj/lib/smlnj/compiler/.cm/%%MLARCH%%-unix/sparc.cm
+smlnj/lib/smlnj/compiler/.cm/%%MLARCH%%-unix/x86.cm
+smlnj/lib/smlnj/init/.cm/%%MLARCH%%-unix/init.cmi
+smlnj/lib/smlnj/installer/.cm/%%MLARCH%%-unix/util.cm
+smlnj/lib/smlnj/internal/.cm/%%MLARCH%%-unix/cm-lib.cm
+smlnj/lib/smlnj/internal/.cm/%%MLARCH%%-unix/cm-sig-lib.cm
+smlnj/lib/smlnj/internal/.cm/%%MLARCH%%-unix/cm0.cm
+smlnj/lib/smlnj/internal/.cm/%%MLARCH%%-unix/intsys.cm
+smlnj/lib/smlnj/internal/.cm/%%MLARCH%%-unix/smlnj-version.cm
+smlnj/lib/smlnj/internal/.cm/%%MLARCH%%-unix/srcpath-lib.cm
+smlnj/lib/smlnj/ml-yacc/.cm/%%MLARCH%%-unix/ml-yacc-lib.cm
+smlnj/lib/smlnj/smlnj-lib/.cm/%%MLARCH%%-unix/controls-lib.cm
+smlnj/lib/smlnj/smlnj-lib/.cm/%%MLARCH%%-unix/html-lib.cm
+smlnj/lib/smlnj/smlnj-lib/.cm/%%MLARCH%%-unix/pp-lib.cm
+smlnj/lib/smlnj/smlnj-lib/.cm/%%MLARCH%%-unix/smlnj-lib.cm
+smlnj/lib/smlnj/viscomp/.cm/%%MLARCH%%-unix/alpha32.cm
+smlnj/lib/smlnj/viscomp/.cm/%%MLARCH%%-unix/amd64.cm
+smlnj/lib/smlnj/viscomp/.cm/%%MLARCH%%-unix/basics.cm
+smlnj/lib/smlnj/viscomp/.cm/%%MLARCH%%-unix/core.cm
+smlnj/lib/smlnj/viscomp/.cm/%%MLARCH%%-unix/debugprof.cm
+smlnj/lib/smlnj/viscomp/.cm/%%MLARCH%%-unix/elabdata.cm
+smlnj/lib/smlnj/viscomp/.cm/%%MLARCH%%-unix/elaborate.cm
+smlnj/lib/smlnj/viscomp/.cm/%%MLARCH%%-unix/execute.cm
+smlnj/lib/smlnj/viscomp/.cm/%%MLARCH%%-unix/hppa.cm
+smlnj/lib/smlnj/viscomp/.cm/%%MLARCH%%-unix/parser.cm
+smlnj/lib/smlnj/viscomp/.cm/%%MLARCH%%-unix/ppc.cm
+smlnj/lib/smlnj/viscomp/.cm/%%MLARCH%%-unix/sparc.cm
+smlnj/lib/smlnj/viscomp/.cm/%%MLARCH%%-unix/x86.cm
+smlnj/lib/unix-lib.cm/.cm/%%MLARCH%%-unix/unix-lib.cm
+@dirrm smlnj/bin/.heap
+@dirrm smlnj/bin/.run
+@dirrm smlnj/bin
+@dirrm smlnj/lib/SMLNJ-BASIS/.cm/%%MLARCH%%-unix
+@dirrm smlnj/lib/SMLNJ-BASIS/.cm
+@dirrm smlnj/lib/SMLNJ-BASIS
+@dirrm smlnj/lib/SMLNJ-LIB/Controls/.cm/%%MLARCH%%-unix
+@dirrm smlnj/lib/SMLNJ-LIB/Controls/.cm
+@dirrm smlnj/lib/SMLNJ-LIB/Controls
+@dirrm smlnj/lib/SMLNJ-LIB/HTML/.cm/%%MLARCH%%-unix
+@dirrm smlnj/lib/SMLNJ-LIB/HTML/.cm
+@dirrm smlnj/lib/SMLNJ-LIB/HTML
+@dirrm smlnj/lib/SMLNJ-LIB/PP/.cm/%%MLARCH%%-unix
+@dirrm smlnj/lib/SMLNJ-LIB/PP/.cm
+@dirrm smlnj/lib/SMLNJ-LIB/PP
+@dirrm smlnj/lib/SMLNJ-LIB/Util/.cm/%%MLARCH%%-unix
+@dirrm smlnj/lib/SMLNJ-LIB/Util/.cm
+@dirrm smlnj/lib/SMLNJ-LIB/Util
+@dirrm smlnj/lib/SMLNJ-LIB
+@dirrm smlnj/lib/SMLNJ-ML-YACC-LIB/.cm/%%MLARCH%%-unix
+@dirrm smlnj/lib/SMLNJ-ML-YACC-LIB/.cm
+@dirrm smlnj/lib/SMLNJ-ML-YACC-LIB
+@dirrm smlnj/lib/SMLNJ-MLRISC/.cm/%%MLARCH%%-unix
+@dirrm smlnj/lib/SMLNJ-MLRISC/.cm
+@dirrm smlnj/lib/SMLNJ-MLRISC
+@dirrm smlnj/lib/burg-ext.cm/.cm/%%MLARCH%%-unix
+@dirrm smlnj/lib/burg-ext.cm/.cm
+@dirrm smlnj/lib/burg-ext.cm
+@dirrm smlnj/lib/c/memory/.cm/%%MLARCH%%-unix
+@dirrm smlnj/lib/c/memory/.cm
+@dirrm smlnj/lib/c/memory
+@dirrm smlnj/lib/c/internals/.cm/%%MLARCH%%-unix
+@dirrm smlnj/lib/c/internals/.cm
+@dirrm smlnj/lib/c/internals
+@dirrm smlnj/lib/c/.cm/%%MLARCH%%-unix
+@dirrm smlnj/lib/c/.cm
+@dirrm smlnj/lib/c
+@dirrm smlnj/lib/ckit-lib.cm/.cm/%%MLARCH%%-unix
+@dirrm smlnj/lib/ckit-lib.cm/.cm
+@dirrm smlnj/lib/ckit-lib.cm
+@dirrm smlnj/lib/cml/.cm/%%MLARCH%%-unix
+@dirrm smlnj/lib/cml/.cm
+@dirrm smlnj/lib/cml
+@dirrm smlnj/lib/cml-lib/.cm/%%MLARCH%%-unix
+@dirrm smlnj/lib/cml-lib/.cm
+@dirrm smlnj/lib/cml-lib
+@dirrm smlnj/lib/dir-tool.cm/.cm/%%MLARCH%%-unix
+@dirrm smlnj/lib/dir-tool.cm/.cm
+@dirrm smlnj/lib/dir-tool.cm
+%%EVERYTHING%%@dirrm smlnj/lib/eXene.cm/.cm/%%MLARCH%%-unix
+%%EVERYTHING%%@dirrm smlnj/lib/eXene.cm/.cm
+%%EVERYTHING%%@dirrm smlnj/lib/eXene.cm
+@dirrm smlnj/lib/grm-ext.cm/.cm/%%MLARCH%%-unix
+@dirrm smlnj/lib/grm-ext.cm/.cm
+@dirrm smlnj/lib/grm-ext.cm
+@dirrm smlnj/lib/hash-cons-lib.cm/.cm/%%MLARCH%%-unix
+@dirrm smlnj/lib/hash-cons-lib.cm/.cm
+@dirrm smlnj/lib/hash-cons-lib.cm
+@dirrm smlnj/lib/html4-lib.cm/.cm/%%MLARCH%%-unix
+@dirrm smlnj/lib/html4-lib.cm/.cm
+@dirrm smlnj/lib/html4-lib.cm
+@dirrm smlnj/lib/inet-lib.cm/.cm/%%MLARCH%%-unix
+@dirrm smlnj/lib/inet-lib.cm/.cm
+@dirrm smlnj/lib/inet-lib.cm
+@dirrm smlnj/lib/json-lib.cm/.cm/%%MLARCH%%-unix
+@dirrm smlnj/lib/json-lib.cm/.cm
+@dirrm smlnj/lib/json-lib.cm
+@dirrm smlnj/lib/lex-ext.cm/.cm/%%MLARCH%%-unix
+@dirrm smlnj/lib/lex-ext.cm/.cm
+@dirrm smlnj/lib/lex-ext.cm
+@dirrm smlnj/lib/make-tool.cm/.cm/%%MLARCH%%-unix
+@dirrm smlnj/lib/make-tool.cm/.cm
+@dirrm smlnj/lib/make-tool.cm
+@dirrm smlnj/lib/ml-antlr-tool.cm/.cm/%%MLARCH%%-unix
+@dirrm smlnj/lib/ml-antlr-tool.cm/.cm
+@dirrm smlnj/lib/ml-antlr-tool.cm
+@dirrm smlnj/lib/ml-lpt-lib.cm/.cm/%%MLARCH%%-unix
+@dirrm smlnj/lib/ml-lpt-lib.cm/.cm
+@dirrm smlnj/lib/ml-lpt-lib.cm
+@dirrm smlnj/lib/ml-ulex-tool.cm/.cm/%%MLARCH%%-unix
+@dirrm smlnj/lib/ml-ulex-tool.cm/.cm
+@dirrm smlnj/lib/ml-ulex-tool.cm
+@dirrm smlnj/lib/mlburg-tool.cm/.cm/%%MLARCH%%-unix
+@dirrm smlnj/lib/mlburg-tool.cm/.cm
+@dirrm smlnj/lib/mlburg-tool.cm
+@dirrm smlnj/lib/mllex-tool.cm/.cm/%%MLARCH%%-unix
+@dirrm smlnj/lib/mllex-tool.cm/.cm
+@dirrm smlnj/lib/mllex-tool.cm
+%%EVERYTHING%%@dirrm smlnj/lib/mlrisc-tools/.cm/%%MLARCH%%-unix
+%%EVERYTHING%%@dirrm smlnj/lib/mlrisc-tools/.cm
+%%EVERYTHING%%@dirrm smlnj/lib/mlrisc-tools
+@dirrm smlnj/lib/mlyacc-tool.cm/.cm/%%MLARCH%%-unix
+@dirrm smlnj/lib/mlyacc-tool.cm/.cm
+@dirrm smlnj/lib/mlyacc-tool.cm
+@dirrm smlnj/lib/noweb-tool.cm/.cm/%%MLARCH%%-unix
+@dirrm smlnj/lib/noweb-tool.cm/.cm
+@dirrm smlnj/lib/noweb-tool.cm
+@dirrm smlnj/lib/nw-ext.cm/.cm/%%MLARCH%%-unix
+@dirrm smlnj/lib/nw-ext.cm/.cm
+@dirrm smlnj/lib/nw-ext.cm
+%%EVERYTHING%%@dirrm smlnj/lib/pgraph-util.cm/.cm/%%MLARCH%%-unix
+%%EVERYTHING%%@dirrm smlnj/lib/pgraph-util.cm/.cm
+%%EVERYTHING%%@dirrm smlnj/lib/pgraph-util.cm
+@dirrm smlnj/lib/pgraph.cm/.cm/%%MLARCH%%-unix
+@dirrm smlnj/lib/pgraph.cm/.cm
+@dirrm smlnj/lib/pgraph.cm
+@dirrm smlnj/lib/pickle-lib.cm/.cm/%%MLARCH%%-unix
+@dirrm smlnj/lib/pickle-lib.cm/.cm
+@dirrm smlnj/lib/pickle-lib.cm
+@dirrm smlnj/lib/reactive-lib.cm/.cm/%%MLARCH%%-unix
+@dirrm smlnj/lib/reactive-lib.cm/.cm
+@dirrm smlnj/lib/reactive-lib.cm
+@dirrm smlnj/lib/regexp-lib.cm/.cm/%%MLARCH%%-unix
+@dirrm smlnj/lib/regexp-lib.cm/.cm
+@dirrm smlnj/lib/regexp-lib.cm
+@dirrm smlnj/lib/sexp-lib.cm/.cm/%%MLARCH%%-unix
+@dirrm smlnj/lib/sexp-lib.cm/.cm
+@dirrm smlnj/lib/sexp-lib.cm
+@dirrm smlnj/lib/shell-tool.cm/.cm/%%MLARCH%%-unix
+@dirrm smlnj/lib/shell-tool.cm/.cm
+@dirrm smlnj/lib/shell-tool.cm
+@dirrm smlnj/lib/smlnj/.cm/%%MLARCH%%-unix
+@dirrm smlnj/lib/smlnj/.cm
+@dirrm smlnj/lib/smlnj/basis/.cm/%%MLARCH%%-unix
+@dirrm smlnj/lib/smlnj/basis/.cm
+@dirrm smlnj/lib/smlnj/basis
+@dirrm smlnj/lib/smlnj/MLRISC/.cm/%%MLARCH%%-unix
+@dirrm smlnj/lib/smlnj/MLRISC/.cm
+@dirrm smlnj/lib/smlnj/MLRISC
+@dirrm smlnj/lib/smlnj/cm/.cm/%%MLARCH%%-unix
+@dirrm smlnj/lib/smlnj/cm/.cm
+@dirrm smlnj/lib/smlnj/cm
+@dirrm smlnj/lib/smlnj/cmb/.cm/%%MLARCH%%-unix
+@dirrm smlnj/lib/smlnj/cmb/.cm
+@dirrm smlnj/lib/smlnj/cmb
+@dirrm smlnj/lib/smlnj/compiler/.cm/%%MLARCH%%-unix
+@dirrm smlnj/lib/smlnj/compiler/.cm
+@dirrm smlnj/lib/smlnj/compiler
+@dirrm smlnj/lib/smlnj/init/.cm/%%MLARCH%%-unix
+@dirrm smlnj/lib/smlnj/init/.cm
+@dirrm smlnj/lib/smlnj/init
+@dirrm smlnj/lib/smlnj/internal/.cm/%%MLARCH%%-unix
+@dirrm smlnj/lib/smlnj/internal/.cm
+@dirrm smlnj/lib/smlnj/internal
+@dirrm smlnj/lib/smlnj/installer/.cm/%%MLARCH%%-unix
+@dirrm smlnj/lib/smlnj/installer/.cm
+@dirrm smlnj/lib/smlnj/installer
+@dirrm smlnj/lib/smlnj/ml-yacc/.cm/%%MLARCH%%-unix
+@dirrm smlnj/lib/smlnj/ml-yacc/.cm
+@dirrm smlnj/lib/smlnj/ml-yacc
+@dirrm smlnj/lib/smlnj/smlnj-lib/.cm/%%MLARCH%%-unix
+@dirrm smlnj/lib/smlnj/smlnj-lib/.cm
+@dirrm smlnj/lib/smlnj/smlnj-lib
+@dirrm smlnj/lib/smlnj/viscomp/.cm/%%MLARCH%%-unix
+@dirrm smlnj/lib/smlnj/viscomp/.cm
+@dirrm smlnj/lib/smlnj/viscomp
+@dirrm smlnj/lib/smlnj
+@dirrm smlnj/lib/smlnj-tdp/.cm/%%MLARCH%%-unix
+@dirrm smlnj/lib/smlnj-tdp/.cm
+@dirrm smlnj/lib/smlnj-tdp
+@dirrm smlnj/lib/unix-lib.cm/.cm/%%MLARCH%%-unix
+@dirrm smlnj/lib/unix-lib.cm/.cm
+@dirrm smlnj/lib/unix-lib.cm
+@dirrm smlnj/lib
+@dirrm smlnj