aboutsummaryrefslogtreecommitdiff
path: root/lang/sml-nj-devel/Makefile
blob: 48f5bb5c4951f4a8b4bbf7ec29bcc2eebca25c5e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
# New ports collection makefile for: sml/nj
# Date created:        7 July 1998
# Whom:                jkoshy
#
# $FreeBSD$
#

PORTNAME=	smlnj
PORTVERSION=	110.34
CATEGORIES=	lang
MASTER_SITES=	ftp://ftp.research.bell-labs.com/dist/smlnj/working/${PORTVERSION}/ \
		ftp://flint.cs.yale.edu/pub/smlnj/working/${PORTVERSION}/ \
		ftp://sunsite.doc.ic.ac.uk/computing/programming/languages/ml/smlnj/working/${PORTVERSION}/ \
		ftp://ftp.diku.dk/pub/smlnj/working/${PORTVERSION}/
.if (${MACHINE_ARCH} == "i386")
DISTFILES=	boot.x86-unix.tgz
.elif (${MACHINE_ARCH} == "alpha")
DISTFILES=	boot.alpha32-unix.tgz
.endif
DISTFILES+=	config.tgz runtime.tgz cm.tgz ckit.tgz \
		ml-burg.tgz ml-lex.tgz \
		ml-nlffi-lib.tgz ml-nlffigen.tgz \
		ml-yacc.tgz smlnj-lib.tgz
.if defined(WITH_SRC) || defined(WITH_RECOMPILE) || defined(WITH_FLINT)
DISTFILES+=	compiler.tgz system.tgz MLRISC.tgz
.endif
.if defined(WITH_CML) || defined(WITH_EXENE)
DISTFILES+=	cml.tgz
.endif
.if defined(WITH_EXENE)
DISTFILES+=	eXene.tgz
.endif
EXTRACT_ONLY=	config.tgz

MAINTAINER=	jkoshy@freebsd.org

.if (${MACHINE_ARCH} == "i386")
MLARCH=		x86
.elif (${MACHINE_ARCH} == "alpha")
MLARCH=		alpha32
.else
BROKEN=		not ported to ${MLARCH}
.endif

MLTARGETS=	ml-burg ckit ml-nlffi-lib ml-nlffigen
MLEXE=		ml-build ml-makedepend sml ml-yacc ml-lex ml-burg ml-nlffigen
.if defined(WITH_CML) || defined(WITH_EXENE) || defined(WITH_SRC) || defined(WITH_RECOMPILE) || defined(WITH_FLINT)
PLIST=		${WRKDIR}/.PLIST
MLPLISTFILES=	${.CURDIR}/pkg-plist
MLSRCPLIST=	${WRKDIR}/.PLIST.src
.endif

.if defined(WITH_SRC) || defined(WITH_RECOMPILE) || defined(WITH_FLINT)
# the pkg-plist for sources is large, so we'll generate it on the fly (during do-install)
MLPLISTFILES+=	${MLSRCPLIST}
MLTARGETS+=	src-smlnj
.endif
.if defined(WITH_CML) || defined(WITH_EXENE)
MLPLISTFILES+=	${FILESDIR}/plist-cml
MLTARGETS+=	cml cml-lib
.endif
.if defined(WITH_EXENE)
MLPLISTFILES+=	${FILESDIR}/plist-eXene
MLTARGETS+=	eXene
.endif

# Other mirror sites that generally carry only released versions of SML
# 	ftp://rodin.stanford.edu/pub/smlnj/release/
# 	ftp://ftp.cl.cam.ac.uk/MIRRORED/smlnj/release/
# 	ftp://ftp.ntua.gr/pub/lang/smlnj/release/
# Mirror sites that keep files around in gzipped format
# 	ftp://flint.cs.yale.edu/pub/smlnj/working/110.9.1/

DIST_SUBDIR=	sml-nj/${PORTVERSION}
NO_WRKSUBDIR=	yes
USE_GMAKE=	yes

NO_LATEST_LINK=	yes

pre-fetch:
	@${ECHO}
.if !defined(WITH_EXENE)
.if !defined(WITH_CML)
	@${ECHO} 'Use make WITH_CML=yes to build CML (Concurrent ML).'
.endif
	@${ECHO} 'Use make WITH_EXENE=yes to build eXene (X Windows toolkit),'
	@${ECHO} ' this implies WITH_CML.'
.endif
.if !defined(WITH_FLINT)
.if !defined(WITH_RECOMPILE)
.if !defined(WITH_SRC)
	@${ECHO} 'Use make WITH_SRC=yes to have the sources installed.'
.endif
	@${ECHO} 'Use make WITH_RECOMPILE=yes to recompile the compiler,'
	@${ECHO} ' this implies WITH_SRC.'
.endif
	@${ECHO} 'Use make WITH_FLINT=yes to build sml with the FLINT'
	@${ECHO} ' structures accessible (see http://flint.cs.yale.edu),'
	@${ECHO} ' this implies WITH_RECOMPILE.'
.endif
	@${ECHO}

# make symlinks to the dist files

post-extract:
	cd ${WRKDIR} && ${LN} -sf ${_DISTDIR}/*  .

# Configuring is done by uncommenting the appropriate #TARGETS="$TARGETS xxx"
# lines of config/targets

do-configure:
	test -f "${WRKDIR}/config/targets.orig" || \
	${MV} "${WRKDIR}/config/targets" "${WRKDIR}/config/targets.orig"
	${ECHO} -n > ${WRKDIR}/.tmp.sed
.for t in ${MLTARGETS}
	${ECHO} '/^#TARGETS="\$$TARGETS[ 	]+${t}"$$/s/#//' >> ${WRKDIR}/.tmp.sed
.endfor
	${SED} -E -f ${WRKDIR}/.tmp.sed "${WRKDIR}/config/targets.orig" \
	> "${WRKDIR}/config/targets"

# The build target builds and installs the system within the WRKDIR.
# The src/runtime is not cleaned afterwards to avoid recompilation during
# a subsequent make install.
# See src/system/README for information on recompiling the compiler.

.if defined(WITH_FLINT)
MLFLINTPATCH=	optional-patch-flint-access
.endif

do-build:
	cd ${WRKDIR} && unset PWD && \
	FILESDIR="$(FILESDIR)" PATCH="$(PATCH)" PATCH_ARGS="$(PATCH_ARGS)" \
	MLNORUNTIMECLEAN=yes	./config/install.sh
.if defined(WITH_FLINT)
	test -f "${WRKDIR}/.patch.${MLFLINTPATCH}" || \
	( cd ${WRKDIR} && \
	${PATCH} < "${FILESDIR}/${MLFLINTPATCH}" && \
	${TOUCH} "${WRKDIR}/.patch.${MLFLINTPATCH}" )
.endif
.if defined(WITH_RECOMPILE) || defined(WITH_FLINT)
	cd ${WRKDIR}/src/system && ( \
	${ECHO} 'CM.autoload "$$smlnj/cmb.cm";' ; \
	${ECHO} 'CMB.make ();' ) | \
	../../bin/sml && \
	./makeml && \
	./installml &&
.endif

# The install target installs the heaps and libraries to their final
# location in ${PREFIX}/smlnj.
# In case of recompilation, installml installs the sml heap and the
# libraries built during compiler bootstrap to ${PREFIX}/smlnj.

.if defined(WITH_SRC) || defined(WITH_RECOMPILE) || defined(WITH_FLINT)
MLNOINSTALL=	CM
.if defined(WITH_RECOMPILE) || defined(WITH_FLINT)
MLNOINSTALL+=	sml.boot.${MLARCH}-unix sml.bin.${MLARCH}-unix
.endif
MLSRCEXCLUDES=
.for excl in ${MLNOINSTALL}
MLSRCEXCLUDES+=	--exclude "${excl}"
.endfor
.endif

do-install:
	${MKDIR} "${PREFIX}/smlnj"
	cd ${WRKDIR} && unset PWD && \
	FILESDIR="$(FILESDIR)" PATCH="$(PATCH)" PATCH_ARGS="$(PATCH_ARGS)" \
	INSTALLDIR="$(PREFIX)/smlnj"	./config/install.sh
.if defined(WITH_RECOMPILE) || defined(WITH_FLINT)
	cd ${WRKDIR}/src/system && \
	INSTALLROOT="${PREFIX}/smlnj" ./makeml && \
	INSTALLROOT="${PREFIX}/smlnj" ./installml
.endif
.if defined(WITH_SRC) || defined(WITH_RECOMPILE) || defined(WITH_FLINT)
	cd ${WRKDIR}/src/runtime/objs && ${GMAKE} clean
	@${ECHO} -n 'Installing sources into ${PREFIX}/smlnj ...'
	@cd ${WRKDIR} && tar -cf - ${MLSRCEXCLUDES} ckit src | tar -xf - -C "${PREFIX}/smlnj"
	@${ECHO} ' done.'
	cd "${PREFIX}" && ( find -s -d smlnj/src smlnj/ckit \! -type d ; \
	( find -s -d smlnj/src smlnj/ckit -type d | ${AWK} '{ printf "@dirrm "; print }' ) \
	) > ${MLSRCPLIST}
.endif
.if defined(WITH_CML) || defined(WITH_EXENE) || defined(WITH_SRC) || defined(WITH_RECOMPILE) || defined(WITH_FLINT)
	${GREP} -h ^[^@] ${MLPLISTFILES} | sort -u > ${PLIST}
	${GREP} -h ^@dirrm ${MLPLISTFILES} | sort -r -u >> ${PLIST}
.endif

post-install:
	${MKDIR} $(PREFIX)/bin
.for f in $(MLEXE)
	${LN} -s $(PREFIX)/smlnj/bin/$f $(PREFIX)/bin/$f
.endfor

.include <bsd.port.mk>