1
0
mirror of https://git.FreeBSD.org/ports.git synced 2024-11-24 00:45:52 +00:00
freebsd-ports/lang/smlnj/Makefile
Kurt Jaeger e49a2b510b 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)
2014-07-30 19:42:50 +00:00

389 lines
14 KiB
Makefile

# $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>