Debian Codegraph @

Makefile

raw symbols ◀ ▶
Source reconstructed at patch state 0 of 3 — not the installed (fully patched) source.
3 Debian patches touch this file
1 ## Copyright (C) 2009,2011,2013,2017-2022,2024 Matthew Fluet.
2 # Copyright (C) 1999-2007 Henry Cejtin, Matthew Fluet, Suresh
3 # Jagannathan, and Stephen Weeks.
4 # Copyright (C) 1997-2000 NEC Research Institute.
5 #
6 # MLton is released under a HPND-style license.
7 # See the file MLton-LICENSE for details.
8 ##
9
10 ROOT := .
11 include $(ROOT)/Makefile.config
12
13 ######################################################################
14
15 .PHONY: all
16 all:
17 $(MAKE) dirs
18 $(MAKE) runtime
19 $(MAKE) compiler CHECK_FIXPOINT=false # mlton0 -> mlton1
20 $(MAKE) script
21 $(MAKE) basis
22 $(MAKE) libraries
23 $(MAKE) tools CHECK_FIXPOINT=false # mlton1 -> tools1
24 ifeq (2, $(firstword $(sort $(BOOTSTRAP_STYLE) 2)))
25 $(MAKE) compiler-clean
26 $(MAKE) compiler SELF_COMPILE=true CHECK_FIXPOINT=false # tools1 + mlton1 -> mlton2
27 ifeq (3, $(firstword $(sort $(BOOTSTRAP_STYLE) 3)))
28 $(MAKE) tools-clean
29 $(MAKE) tools CHECK_FIXPOINT=true # tools1 + mlton2 -> tools2; tools2 == tools1
30 $(MAKE) compiler-clean
31 $(MAKE) compiler SELF_COMPILE=true CHECK_FIXPOINT=true # tools2 + mlton2 -> mlton3; mlton3 == mlton2
32 endif
33 endif
34 @echo 'Build of MLton succeeded.'
35
36 CLEAN_EXCLS := package
37 $(eval $(MK_COMMON_GOALS))
38
39 .PHONY: clean-git
40 clean-git:
41 $(FIND) . -type d -name .git -prune -exec $(RM) '{}' ';'
42
43 .PHONY: check
44 check:
45 ./bin/regression $(CHECK_ARGS)
46
47 ######################################################################
48
49 .PHONY: basis-no-check
50 basis-no-check:
51 $(RM) "$(LIB)/sml/basis"
52 $(MKDIR) "$(LIB)/sml/basis"
53 ( \
54 cd "$(SRC)/basis-library" && \
55 $(FIND) . -type f '(' -name '*.mlb' -o -name '*.sml' -o -name '*.sig' -o -name '*.fun' ')' | \
56 $(TAR) -c -T - -f - | \
57 ( cd "$(LIB)/sml/basis" && $(TAR) -x -f - ) \
58 )
59
60 .PHONY: basis-check
61 basis-check:
62 @echo 'Type checking basis.'
63 "$(BIN)/$(MLTON)" -disable-ann deadCode -stop tc '$$(SML_LIB)/basis/libs/all.mlb' >/dev/null
64
65 .PHONY: basis
66 basis:
67 $(MAKE) basis-no-check
68 $(MAKE) basis-check
69
70 .PHONY: compiler
71 compiler:
72 $(MAKE) -C "$(SRC)/mlton"
73 ifeq (true, $(CHECK_FIXPOINT))
74 $(DIFF) -b "$(SRC)/mlton/$(MLTON_OUTPUT)$(EXE)" "$(LIB)/$(MLTON_OUTPUT)$(EXE)"
75 endif
76 $(CP) "$(SRC)/mlton/$(MLTON_OUTPUT)$(EXE)" "$(LIB)/"
77
78 .PHONY: compiler-clean
79 compiler-clean:
80 $(MAKE) -C "$(SRC)/mlton" clean
81
82 .PHONY: dirs
83 dirs:
84 $(MKDIR) "$(BIN)" "$(LIB)" "$(INC)"
85 $(MKDIR) "$(LIB)/targets/$(TARGET)/include"
86 $(MKDIR) "$(LIB)/targets/$(TARGET)/sml"
87
88 .PHONY: docs
89 docs:
90 $(MAKE) -C "$(SRC)/doc/guide"
91
92 define LIBRARIES_NO_CHECK_TEMPLATE
93 $(RM) "$(LIB)/sml/$(1)"
94 $(MKDIR) "$(LIB)/sml/$(1)"
95 ( \
96 cd "$(SRC)/lib/$(1)$(2)" && \
97 $(FIND) . '!' -path '*/.cm/*' $(3) -type f '(' -name '*.mlb' -o -name '*.sml' -o -name '*.sig' -o -name '*.fun' ')' | \
98 $(TAR) -c -T - -f - | \
99 ( cd "$(LIB)/sml/$(1)" && $(TAR) -x -f - ) \
100 )
101
102 endef
103
104 .PHONY: libraries-no-check
105 libraries-no-check:
106 $(MAKE) -C "$(SRC)/lib/ckit-lib"
107 $(call LIBRARIES_NO_CHECK_TEMPLATE,ckit-lib,/ckit/src,)
108 $(call LIBRARIES_NO_CHECK_TEMPLATE,cml,,'!' -path '*/tests/*')
109 $(MAKE) -C "$(SRC)/lib/mllpt-lib"
110 $(call LIBRARIES_NO_CHECK_TEMPLATE,mllpt-lib,/ml-lpt/lib,)
111 $(MAKE) -C "$(SRC)/lib/mlnlffi-lib"
112 $(call LIBRARIES_NO_CHECK_TEMPLATE,mlnlffi-lib,,)
113 $(MAKE) -C "$(SRC)/lib/mlrisc-lib"
114 $(call LIBRARIES_NO_CHECK_TEMPLATE,mlrisc-lib,/MLRISC,'!' -path '*/demo/*' '!' -path '*/Tools/*' '!' -path './autoload.sml' '!' -path './make*.sml')
115 $(call LIBRARIES_NO_CHECK_TEMPLATE,mlyacc-lib,,)
116 $(MAKE) -C "$(SRC)/lib/smlnj-lib"
117 $(call LIBRARIES_NO_CHECK_TEMPLATE,smlnj-lib,/smlnj-lib,'!' -path '*/examples/*' '!' -path '*/tests/*' '!' -path '*/Tests/*')
118
119 define LIBRARIES_CHECK_TEMPLATE
120 @echo "Type checking $(1) library."
121 "$(BIN)/$(MLTON)" -disable-ann deadCode -stop tc '$$(SML_LIB)/$(1)/$(1).mlb' >/dev/null
122 endef
123
124 .PHONY: libraries-check
125 libraries-check:
126 $(call LIBRARIES_CHECK_TEMPLATE,ckit-lib)
127 $(call LIBRARIES_CHECK_TEMPLATE,cml)
128 $(call LIBRARIES_CHECK_TEMPLATE,mllpt-lib)
129 $(call LIBRARIES_CHECK_TEMPLATE,mlnlffi-lib)
130 $(call LIBRARIES_CHECK_TEMPLATE,mlrisc-lib)
131 $(call LIBRARIES_CHECK_TEMPLATE,mlyacc-lib)
132 $(call LIBRARIES_CHECK_TEMPLATE,smlnj-lib)
133
134 .PHONY: libraries
135 libraries:
136 $(MAKE) libraries-no-check
137 $(MAKE) libraries-check
138
139 .PHONY: runtime
140 runtime:
141 @echo 'Compiling MLton runtime system for $(TARGET).'
142 $(MAKE) -C "$(SRC)/runtime"
143 $(CP) "$(SRC)/include/"*.h "$(INC)/"
144 $(CP) "$(SRC)/runtime/"*.a "$(LIB)/targets/$(TARGET)/"
145 $(CP) "$(SRC)/runtime/gen/constants" "$(LIB)/targets/$(TARGET)/"
146 $(CP) "$(SRC)/runtime/gen/c-types.sml" "$(LIB)/targets/$(TARGET)/sml/"
147 echo "$(TARGET_OS)" > "$(LIB)/targets/$(TARGET)/os"
148 echo "$(TARGET_ARCH)" > "$(LIB)/targets/$(TARGET)/arch"
149 $(CP) "$(SRC)/runtime/gen/basis-ffi.sml" \
150 basis-library/primitive/basis-ffi.sml
151 $(CP) "$(SRC)/runtime/"*.h "$(INC)/"
152 $(MV) "$(INC)/c-types.h" "$(LIB)/targets/$(TARGET)/include"
153 for d in basis basis/Real basis/Word gc platform util; do \
154 $(MKDIR) "$(INC)/$$d"; \
155 $(CP) "$(SRC)/runtime/$$d/"*.h "$(INC)/$$d"; \
156 done
157 echo "EXE=\"$(EXE)\"" > "$(LIB)/targets/$(TARGET)/vars"
158 echo "CC=\"$(CC)\"" >> "$(LIB)/targets/$(TARGET)/vars"
159 echo "GMP_INC_DIR=\"$(WITH_GMP_INC_DIR)\"" >> "$(LIB)/targets/$(TARGET)/vars"
160 echo "GMP_LIB_DIR=\"$(WITH_GMP_LIB_DIR)\"" >> "$(LIB)/targets/$(TARGET)/vars"
161
162 .PHONY: install-runtime
163 install-runtime:
164 $(MKDIR) "$(TLIB)/targets/$(TARGET)"
165 $(CP) "$(LIB)/targets/$(TARGET)" "$(TLIB)/targets/"
166
167 .PHONY: script
168 script:
169 $(SED) \
170 -e "s;^LIB_REL_BIN=.*;LIB_REL_BIN=\"$(LIB_REL_BIN)\";" \
171 -e 's/mlton-compile/$(MLTON_OUTPUT)/' \
172 -e "s;^ SMLNJ=.*; SMLNJ=\"$(SMLNJ)\";" \
173 < "$(SRC)/bin/mlton-script" > "$(BIN)/$(MLTON)"
174 $(CHMOD) a+x "$(BIN)/$(MLTON)"
175 $(CP) "$(SRC)/bin/static-library" "$(LIB)"
176 ifeq (mingw, $(TARGET_OS))
177 $(CP) "$(SRC)/bin/static-library.bat" "$(LIB)"
178 endif
179
180 ifeq (true, $(CHECK_FIXPOINT))
181 define TOOLS_TEMPLATE_CHECK_FIXPOINT
182 $(DIFF) -b "$(SRC)/$(1)/$(1)$(EXE)" "$(BIN)/$(1)$(EXE)"
183 endef
184 else
185 define TOOLS_TEMPLATE_CHECK_FIXPOINT
186 endef
187 endif
188
189 define TOOLS_TEMPLATE
190 +$(MAKE) -C "$(SRC)/$(1)"
191 $(call TOOLS_TEMPLATE_CHECK_FIXPOINT,$(1))
192 $(CP) "$(SRC)/$(1)/$(1)$(EXE)" "$(BIN)/"
193 endef
194
195 .PHONY: tools
196 tools:
197 $(call TOOLS_TEMPLATE,mllex)
198 $(call TOOLS_TEMPLATE,mlyacc)
199 $(call TOOLS_TEMPLATE,mlprof)
200 $(call TOOLS_TEMPLATE,mlnlffigen)
201
202 .PHONY: tools-clean
203 tools-clean:
204 $(MAKE) -C "$(SRC)/mllex" clean
205 $(MAKE) -C "$(SRC)/mlyacc" clean
206 $(MAKE) -C "$(SRC)/mlprof" clean
207 $(MAKE) -C "$(SRC)/mlnlffigen" clean
208
209 ######################################################################
210
211 # debugged, profiled, traced targets
212
213 .PHONY: debugged
214 debugged:
215 $(MAKE) -C "$(SRC)/mlton" MLTON_NAME="$(MLTON_NAME) (debug)" MLTON_OUTPUT=$(MLTON_OUTPUT).debug \
216 MLTON_COMPILE_ARGS="$(MLTON_COMPILE_ARGS) -debug true -const 'Exn.keepHistory true' -profile-val true -const 'MLton.debug true' -disable-pass 'deepFlatten'"
217 $(CP) "$(SRC)/mlton/$(MLTON_OUTPUT).debug$(EXE)" "$(LIB)/"
218 $(SED) -e 's/$(MLTON_OUTPUT)/$(MLTON_OUTPUT).debug/' \
219 < "$(BIN)/$(MLTON)" \
220 > "$(BIN)/$(MLTON).debug"
221 $(CHMOD) u+x "$(BIN)/$(MLTON).debug"
222
223 define PROFILED_TEMPLATE
224 +$(MAKE) -C "$(SRC)/mlton" MLTON_NAME="$(MLTON_NAME) (profile-$(1))" MLTON_OUTPUT=$(MLTON_OUTPUT).$(1) \
225 MLTON_COMPILE_ARGS="$(MLTON_COMPILE_ARGS) -profile $(1)"
226 $(CP) "$(SRC)/mlton/$(MLTON_OUTPUT).$(1)$(EXE)" "$(LIB)/"
227 $(SED) -e "s/$(MLTON_OUTPUT)/$(MLTON_OUTPUT).$(1)/" \
228 < "$(BIN)/$(MLTON)" \
229 >"$(BIN)/$(MLTON).$(1)"
230 $(CHMOD) u+x "$(BIN)/$(MLTON).$(1)"
231 endef
232
233 .PHONY: profiled-alloc
234 profiled-alloc:
235 $(call PROFILED_TEMPLATE,alloc)
236
237 .PHONY: profiled-count
238 profiled-count:
239 $(call PROFILED_TEMPLATE,count)
240
241 .PHONY: profiled-time
242 profiled-time:
243 $(call PROFILED_TEMPLATE,time)
244
245 .PHONY: profiled
246 profiled:
247 $(MAKE) profiled-alloc
248 $(MAKE) profiled-count
249 $(MAKE) profiled-time
250
251 .PHONY: traced
252 traced:
253 $(MAKE) -C "$(SRC)/mlton" MLTON_NAME="$(MLTON_NAME) (trace)" MLTON_OUTPUT=$(MLTON_OUTPUT).trace \
254 MLTON_COMPILE_ARGS="$(MLTON_COMPILE_ARGS) -const 'Exn.keepHistory true' -profile-val true -const 'MLton.debug true' -disable-pass 'deepFlatten'"
255 $(CP) "$(SRC)/mlton/$(MLTON_OUTPUT).trace$(EXE)" "$(LIB)/"
256 $(SED) -e 's/$(MLTON_OUTPUT)/$(MLTON_OUTPUT).trace/' \
257 < "$(BIN)/$(MLTON)" \
258 > "$(BIN)/$(MLTON).trace"
259 $(CHMOD) u+x "$(BIN)/$(MLTON).trace"
260
261 ######################################################################
262
263 # smlnj targets
264
265 SMLNJ := sml
266
267 .PHONY: bootstrap-smlnj
268 bootstrap-smlnj:
269 $(MAKE) smlnj-mlton
270 $(RM) "$(BIN)/$(MLTON)"
271 $(MAKE) OLD_MLTON="$(BIN)/$(MLTON).smlnj" all
272 $(RM) "$(LIB)/$(MLTON_OUTPUT_SMLNJ_HEAP)"
273 $(RM) "$(BIN)/$(MLTON).smlnj"
274
275 .PHONY: smlnj-mlton
276 smlnj-mlton:
277 $(MAKE) dirs
278 $(MAKE) runtime
279 $(MAKE) -C "$(SRC)/mlton" smlnj-mlton
280 $(CP) "$(SRC)/mlton/$(MLTON_OUTPUT_SMLNJ_HEAP)" "$(LIB)/"
281 $(MAKE) script
282 $(MAKE) basis-no-check
283 $(MAKE) libraries-no-check
284 $(SED) \
285 -e 's;\(doit.* "$$@"\);# \1;' \
286 -e 's;# \(doitSMLNJ "$$@"\);\1;' \
287 < "$(BIN)/$(MLTON)" \
288 > "$(BIN)/$(MLTON).smlnj"
289 $(CHMOD) u+x "$(BIN)/$(MLTON).smlnj"
290 @echo 'Build of MLton (with SML/NJ) succeeded.'
291
292 .PHONY: smlnj-mlton-x2
293 smlnj-mlton-x2:
294 $(MAKE) SMLNJ_CM_SERVERS_NUM=2 smlnj-mlton
295
296 .PHONY: smlnj-mlton-x4
297 smlnj-mlton-x4:
298 $(MAKE) SMLNJ_CM_SERVERS_NUM=4 smlnj-mlton
299
300 .PHONY: smlnj-mlton-x8
301 smlnj-mlton-x8:
302 $(MAKE) SMLNJ_CM_SERVERS_NUM=8 smlnj-mlton
303
304 .PHONY: smlnj-mlton-x16
305 smlnj-mlton-x16:
306 $(MAKE) SMLNJ_CM_SERVERS_NUM=16 smlnj-mlton
307
308 ######################################################################
309
310 # polyml targets
311
312 .PHONY: bootstrap-polyml
313 bootstrap-polyml:
314 $(MAKE) polyml-mlton
315 $(RM) "$(BIN)/$(MLTON)"
316 $(MAKE) OLD_MLTON="$(BIN)/$(MLTON).polyml" all
317 $(RM) "$(LIB)/$(MLTON_OUTPUT)-polyml$(EXE)"
318 $(RM) "$(BIN)/$(MLTON).polyml"
319
320 .PHONY: polyml-mlton
321 polyml-mlton:
322 $(MAKE) dirs
323 $(MAKE) runtime
324 $(MAKE) -C "$(SRC)/mlton" polyml-mlton
325 $(CP) "$(SRC)/mlton/$(MLTON_OUTPUT)-polyml$(EXE)" "$(LIB)/"
326 $(MAKE) script
327 $(MAKE) basis-no-check
328 $(MAKE) libraries-no-check
329 $(SED) \
330 -e 's;\(doit.* "$$@"\);# \1;' \
331 -e 's;# \(doitPolyML "$$@"\);\1;' \
332 < "$(BIN)/$(MLTON)" \
333 > "$(BIN)/$(MLTON).polyml"
334 $(CHMOD) u+x "$(BIN)/$(MLTON).polyml"
335 @echo 'Build of MLton (with Poly/ML) succeeded.'
336
337 ######################################################################
338
339 # mlkit targets
340
341 .PHONY: bootstrap-mlkit
342 bootstrap-mlkit:
343 $(MAKE) mlkit-mlton
344 $(RM) "$(BIN)/$(MLTON)"
345 $(MAKE) OLD_MLTON="$(BIN)/$(MLTON).mlkit" all
346 $(RM) "$(LIB)/$(MLTON_OUTPUT)-mlkit$(EXE)"
347 $(RM) "$(BIN)/$(MLTON).mlkit"
348
349 .PHONY: mlkit-mlton
350 mlkit-mlton:
351 $(MAKE) dirs
352 $(MAKE) runtime
353 $(MAKE) -C "$(SRC)/mlton" mlkit-mlton
354 $(CP) "$(SRC)/mlton/$(MLTON_OUTPUT)-mlkit$(EXE)" "$(LIB)/"
355 $(MAKE) script
356 $(MAKE) basis-no-check
357 $(MAKE) libraries-no-check
358 $(SED) \
359 -e 's;\(doit.* "$$@"\);# \1;' \
360 -e 's;# \(doitMLKit "$$@"\);\1;' \
361 < "$(BIN)/$(MLTON)" \
362 > "$(BIN)/$(MLTON).mlkit"
363 $(CHMOD) u+x "$(BIN)/$(MLTON).mlkit"
364 @echo 'Build of MLton (with MLKit) succeeded.'
365
366 ######################################################################
367
368 # version target
369
370 .PHONY: version
371 version:
372 @echo 'Instantiating version numbers.'
373 $(SED) \
374 -e "s/^MLTON_VERSION := .*/MLTON_VERSION := $(MLTON_VERSION)/" \
375 -e "s/^RELEASE := .*/RELEASE := true/" \
376 < "$(SRC)/Makefile.config" \
377 > z && \
378 $(MV) z "$(SRC)/Makefile.config";
379
380 ######################################################################
381
382 # install and release targets
383
384 prefix := $(PREFIX)
385 exec_prefix := $(prefix)
386 bindir := $(exec_prefix)/bin
387 datarootdir := $(prefix)/share
388 docdir := $(datarootdir)/doc/mlton
389 libdir := $(exec_prefix)/lib
390 mandir := $(datarootdir)/man
391 man1dir := $(mandir)/man1
392
393 TBIN := $(DESTDIR)$(bindir)
394 TLIB := $(DESTDIR)$(libdir)/mlton
395 TMAN := $(DESTDIR)$(man1dir)
396 TDOC := $(DESTDIR)$(docdir)
397 TEXM := $(TDOC)/examples
398
399 TLIB_REL_TBIN := $(shell $(call TGT_REL_SRC,$(TLIB),$(TBIN)))
400
401 GZIP_MAN := true
402 ifeq ($(findstring $(TARGET_OS), openbsd solaris), $(TARGET_OS))
403 GZIP_MAN := false
404 endif
405
406 .PHONY: install
407 install: install-no-strip install-strip
408
409 MAN_PAGES := mlton.1
410 MAN_PAGES := $(MAN_PAGES) \
411 mllex.1 \
412 mlnlffigen.1 \
413 mlprof.1 \
414 mlyacc.1
415
416 .PHONY: install-no-strip
417 install-no-strip:
418 $(MKDIR) "$(TBIN)" "$(TLIB)"
419 $(CP) "$(BIN)/." "$(TBIN)/"
420 $(SED) \
421 -e "s;^LIB_REL_BIN=.*;LIB_REL_BIN=\"$(TLIB_REL_TBIN)\";" \
422 < "$(BIN)/$(MLTON)" > "$(TBIN)/$(MLTON)"
423 $(CHMOD) a+x "$(TBIN)/$(MLTON)"
424 $(CP) "$(LIB)/." "$(TLIB)/"
425 $(MKDIR) "$(TMAN)"
426 cd "$(SRC)/man" && $(CP) $(MAN_PAGES) "$(TMAN)/"
427 ifeq (true, $(GZIP_MAN))
428 cd "$(TMAN)" && $(GZIP) --force --best $(MAN_PAGES);
429 endif
430
431 STRIP_PROGS := "$(TLIB)/$(MLTON_OUTPUT)$(EXE)"
432 STRIP_PROGS := $(STRIP_PROGS) \
433 "$(TBIN)/mllex$(EXE)" \
434 "$(TBIN)/mlnlffigen$(EXE)" \
435 "$(TBIN)/mlprof$(EXE)" \
436 "$(TBIN)/mlyacc$(EXE)"
437
438 .PHONY: install-strip
439 install-strip: install-no-strip
440 for f in $(STRIP_PROGS); do $(STRIP) "$$f"; done
441
442 REGRESSION_EXAMPLES := \
443 callcc.sml command-line.sml hello-world.sml same-fringe.sml \
444 signals.sml size.sml taut.sml thread1.sml thread2.sml \
445 thread-switch.sml timeout.sml
446
447 .PHONY: install-docs
448 install-docs:
449 $(MKDIR) "$(TDOC)" "$(TDOC)/license"
450 ( \
451 cd "$(SRC)" && \
452 $(CP) CHANGELOG.adoc README.adoc "$(TDOC)/" && \
453 $(CP) LICENSE "$(TDOC)/license/MLton-LICENSE" \
454 )
455 ( \
456 cd "$(SRC)/doc" && \
457 $(FIND) examples -type f '!' -name .gitignore \
458 | $(TAR) -c -T - -f - \
459 | ( cd "$(TDOC)/" && $(TAR) -x -f - ) \
460 )
461 ( \
462 cd "$(SRC)/doc" && \
463 $(FIND) license -type f '!' -name .gitignore \
464 | $(TAR) -c -T - -f - \
465 | ( cd "$(TDOC)/" && $(TAR) -x -f - ) \
466 )
467 if [ -d "$(SRC)/doc/guide/localhost" ]; then \
468 $(CP) "$(SRC)/doc/guide/localhost" "$(TDOC)/guide"; \
469 fi
470 ( \
471 cd "$(SRC)/util" && \
472 $(FIND) cm2mlb -type f '!' -name .gitignore \
473 | $(TAR) -c -T - -f - \
474 | ( cd "$(TDOC)/" && $(TAR) -x -f - ) \
475 )
476 ( \
477 cd "$(SRC)/regression" && \
478 $(CP) $(REGRESSION_EXAMPLES) "$(TEXM)/" \
479 )
480
481
482 .PHONY: source-release
483 source-release:
484 $(MAKE) clean
485 $(MAKE) MLTON_VERSION=$(MLTON_VERSION) version
486 $(MAKE) -C doc/guide
487 $(TAR) cvzf ./mlton-$(MLTON_VERSION).src.tgz \
488 --exclude .git/ --exclude .github/ --exclude package/ --exclude mlton-*.tgz \
489 --transform "s@^@mlton-$(MLTON_VERSION)/@S" \
490 *
491
492 MLTON_BINARY_RELEASE := 1
493 MLTON_BINARY_RELEASE_SUFFIX :=
494 MLTON_BINARY_RELEASE_NAME := mlton-$(MLTON_VERSION)-$(MLTON_BINARY_RELEASE).$(TARGET_ARCH)-$(TARGET_OS)$(MLTON_BINARY_RELEASE_SUFFIX)
495 MLTON_BINARY_RELEASE_WITH_DOCS := true
496 .PHONY: binary-release
497 binary-release:
498 $(MAKE) all
499 ifeq (true,$(MLTON_BINARY_RELEASE_WITH_DOCS))
500 $(MAKE) docs
501 endif
502 $(RM) "$(SRC)/$(MLTON_BINARY_RELEASE_NAME)"
503 $(MKDIR) "$(SRC)/$(MLTON_BINARY_RELEASE_NAME)"
504 $(MAKE) DESTDIR="$(SRC)/$(MLTON_BINARY_RELEASE_NAME)" PREFIX="" install
505 ifeq (true,$(MLTON_BINARY_RELEASE_WITH_DOCS))
506 $(MAKE) DESTDIR="$(SRC)/$(MLTON_BINARY_RELEASE_NAME)" PREFIX="" install-docs
507 endif
508 $(CP) "$(SRC)/Makefile.binary" "$(SRC)/$(MLTON_BINARY_RELEASE_NAME)/Makefile"
509 $(CP) "$(SRC)/CHANGELOG.adoc" "$(SRC)/LICENSE" "$(SRC)/README.adoc" "$(SRC)/$(MLTON_BINARY_RELEASE_NAME)/"
510 $(TAR) cvzf $(MLTON_BINARY_RELEASE_NAME).tgz $(MLTON_BINARY_RELEASE_NAME)
511 $(RM) $(MLTON_BINARY_RELEASE_NAME)
512
513 ######################################################################
514
515 # remote-bootstrap and remote-add-cross
516
517 # The `remote-bootstrap` goal automates the process of bootstraping MLton on a
518 # remote machine that doesn't have a suitable pre-compiled `mlton` binary. It
519 # works as follows:
520 # * send the current sources to a remote machine (using ssh)
521 # * build the MLton runtime system on the remote machine
522 # * receive the built runtime system from the remote machine as a new target on
523 # the host machine
524 # * build bootstrap compiler sources on the host machine for the new target
525 # * send the boostrap sources to the remote machine
526 # * build the boostrap compiler on the remote machine using the boostrap
527 # compiler sources
528 # * complete the MLton build on the remote machine with the boostrap compiler to
529 # obtain a boot package
530 # * build MLton on the remote machine from clean sources using the boot package
531 # * receive the built binary release from the remote machine
532 #
533 # The `remote-add-cross` goal automates the process of adding a cross
534 # compiler target. It works as follows:
535 # * send the current sources to a remote machine (using ssh)
536 # * build the MLton runtime system on the remote machine
537 # * receive the built runtime system from the remote machine as a new target on
538 # the host machine
539 #
540 #
541 # For both `remote-bootstrap` and `remote-add-cross`, the following `Makefile`
542 # variables are used:
543 # * REMOTE_MACHINE (required): Specify the remote machine to be used as an
544 # `ssh` destination, either `[user@]hostname` or
545 # `ssh://[user@]hostname[:port]`.
546 # * REMOTE_TMP: Specify (absolute) path on remote machine for building; default
547 # is `/tmp`.
548 # * REMOTE_MAKE: Specify `make` on remote machine.
549 # * REMOTE_MAKEFLAGS: Specify `Makefile` variables to set when invoking `make`
550 # on the remote machine.
551 # For `remote-add-cross`, the following additional `Makefile` variable is used:
552 # * CROSS_TARGET (required): Specify target machine triple for host
553 # cross-compiler; that is the value of `<machine>` in `<machine>-gcc` or
554 # `<triple>` in `clang -target=<triple>` on the host machine, such as
555 # `arm-linux-gnu`.
556 #
557 #
558 # For example, on OpenBSD, GNU Make is named `gmake` (and `make` is BSD Make)
559 # and GMP is provided at `/usr/local` (and not on the default search paths). To
560 # boostrap on an OpenBSD virtual machine (with localhost port 2222 forwarded to
561 # guest VM port 22), one could use:
562 #
563 # $ make REMOTE_MACHINE=ssh://localhost:2222 REMOTE_MAKE=gmake REMOTE_MAKEFLAGS=WITH_GMP_DIR=/usr/local remote-bootstrap
564
565 ifneq (,$(findstring remote-,$(MAKECMDGOALS)))
566
567 ifneq (,$(findstring dirty,$(MLTON_VERSION)))
568 $(warning 'MLTON_VERSION' appears dirty; $(MLTON_VERSION))
569 endif
570
571 ifeq (,$(REMOTE_MACHINE))
572 $(error 'REMOTE_MACHINE' not defined)
573 endif
574
575 SSH := ssh
576
577 ifeq (false,$(shell $(SSH) $(REMOTE_MACHINE) true > /dev/null 2>&1 || echo false))
578 $(error '$(SSH) $(REMOTE_MACHINE) true' failed)
579 endif
580
581 REMOTE_TMP := /tmp
582 REMOTE_ROOT := $(REMOTE_TMP)/mlton-$(MLTON_VERSION)
583
584 REMOTE_BASH := bash
585 REMOTE_TAR := $(TAR)
586
587 REMOTE_CAT := $(CAT)
588 REMOTE_CP := $(CP)
589 REMOTE_MKDIR := $(MKDIR)
590 REMOTE_RM := $(RM)
591
592 REMOTE_MAKE := make
593 REMOTE_MAKEFLAGS :=
594 REMOTE_XMAKEFLAGS := CHECK_MLCMD=
595
596 REMOTE_PLATFORM := $(shell $(CAT) bin/platform | $(SSH) $(REMOTE_MACHINE) "$(REMOTE_BASH) -s")
597 REMOTE_ARCH := $(patsubst HOST_ARCH=%,%,$(filter HOST_ARCH=%,$(REMOTE_PLATFORM)))
598 REMOTE_OS := $(patsubst HOST_OS=%,%,$(filter HOST_OS=%,$(REMOTE_PLATFORM)))
599 REMOTE_TARGET := $(REMOTE_ARCH)-$(REMOTE_OS)
600 CROSS_TARGET := $(REMOTE_ARCH)-$(REMOTE_OS)
601
602 .PHONY: remote-bootstrap
603 remote-bootstrap:
604 $(MAKE) remote--send-src
605 $(MAKE) remote--make-version
606 $(MAKE) remote--make-dirs
607 $(MAKE) remote--make-runtime
608 $(MAKE) remote--recv-runtime
609 $(MAKE) remote--gen-bootstrap-compiler-files
610 $(MAKE) remote--send-bootstrap-compiler-files
611 $(MAKE) remote--make-bootstrap-compiler
612 $(MAKE) remote--make-script
613 $(MAKE) remote--make-basis
614 $(MAKE) remote--make-libraries
615 $(MAKE) remote--recv-boot-files
616 $(MAKE) remote--make-clean
617 $(MAKE) remote--send-boot-files
618 $(MAKE) remote--make-all
619 $(MAKE) remote--make-binary-release
620 $(MAKE) remote--recv-binary-release
621 $(MAKE) remote--rm-root
622
623 .PHONY: remote-add-target
624 remote-add-target:
625 $(MAKE) remote--send-src
626 $(MAKE) remote--make-version
627 $(MAKE) remote--make-dirs
628 $(MAKE) remote--make-runtime
629 $(MAKE) remote--recv-runtime
630 ifneq ($(REMOTE_TARGET),$(CROSS_TARGET))
631 $(MV) "$(LIB)/targets/$(REMOTE_TARGET)" "$(LIB)/targets/$(CROSS_TARGET)"
632 endif
633 $(MAKE) remote--rm-root
634
635
636 .PHONY: remote--send-src
637 remote--send-src:
638 $(SSH) $(REMOTE_MACHINE) "$(REMOTE_RM) $(REMOTE_ROOT) && $(REMOTE_MKDIR) $(REMOTE_ROOT)"
639 $(GIT) archive --format=tar HEAD | $(SSH) $(REMOTE_MACHINE) "cd $(REMOTE_ROOT) && $(REMOTE_TAR) xf -"
640
641 .PHONY: remote--recv-runtime
642 remote--recv-runtime:
643 $(RM) "$(LIB)/targets/$(REMOTE_TARGET)" && $(MKDIR) "$(LIB)/targets/$(REMOTE_TARGET)"
644 $(SSH) $(REMOTE_MACHINE) "cd $(REMOTE_ROOT)/build/lib/mlton/targets/self && $(REMOTE_TAR) cf - ." | (cd "$(LIB)/targets/$(REMOTE_TARGET)" && $(TAR) xf -)
645
646 .PHONY: remote-bootstrap-gen-bootstrap-compiler-files
647 remote--gen-bootstrap-compiler-files:
648 $(MAKE) REMOTE_TARGET=$(REMOTE_TARGET) -C mlton mlton-bootstrap-$(REMOTE_TARGET).tgz
649
650 .PHONY: remote--send-bootstrap-compiler-files
651 remote--send-bootstrap-compiler-files:
652 $(SSH) $(REMOTE_MACHINE) "cd $(REMOTE_ROOT) && $(REMOTE_RM) runtime/bootstrap && $(REMOTE_MKDIR) runtime/bootstrap"
653 $(CAT) mlton/mlton-bootstrap-$(REMOTE_TARGET).tgz | $(SSH) $(REMOTE_MACHINE) "cd $(REMOTE_ROOT)/runtime/bootstrap && $(REMOTE_TAR) xzf -"
654
655 .PHONY: remote--recv-boot-files
656 remote--recv-boot-files:
657 $(SSH) $(REMOTE_MACHINE) "cd $(REMOTE_ROOT) && $(REMOTE_RM) boot && $(REMOTE_CP) build boot"
658 $(SSH) $(REMOTE_MACHINE) "cd $(REMOTE_ROOT) && $(REMOTE_TAR) czf - boot" | $(CAT) - > "$(LIB)/targets/$(REMOTE_TARGET)/boot.tgz"
659
660 .PHONY: remote--send-boot-files
661 remote--send-boot-files:
662 $(SSH) $(REMOTE_MACHINE) "cd $(REMOTE_ROOT) && $(REMOTE_RM) boot"
663 $(CAT) "$(LIB)/targets/$(REMOTE_TARGET)/boot.tgz" | $(SSH) $(REMOTE_MACHINE) "cd $(REMOTE_ROOT) && $(REMOTE_TAR) xzf -"
664
665 .PHONY: remote--recv-binary-release
666 remote--recv-binary-release:
667 $(SSH) $(REMOTE_MACHINE) "cd $(REMOTE_ROOT) && $(REMOTE_CAT) mlton-$(MLTON_VERSION)-$(MLTON_BINARY_RELEASE).$(REMOTE_ARCH)-$(REMOTE_OS)$(MLTON_BINARY_RELEASE_SUFFIX).tgz" | $(CAT) - > mlton-$(MLTON_VERSION)-$(MLTON_BINARY_RELEASE).$(REMOTE_ARCH)-$(REMOTE_OS)$(MLTON_BINARY_RELEASE_SUFFIX).tgz
668
669 .PHONY: remote--rm-root
670 remote--rm-root:
671 $(SSH) $(REMOTE_MACHINE) "$(REMOTE_RM) $(REMOTE_ROOT)"
672
673 define MK_REMOTE_MAKE_TEMPLATE
674 .PHONY: remote--make-$(1)
675 remote--make-$(1):
676 $$(SSH) $$(REMOTE_MACHINE) "cd $$(REMOTE_ROOT) && $$(REMOTE_MAKE) $$(REMOTE_MAKEFLAGS) $$(REMOTE_XMAKEFLAGS) $$($(1)_REMOTE_XMAKEFLAGS) $(1)"
677 endef
678
679 $(eval $(call MK_REMOTE_MAKE_TEMPLATE,show-config))
680 $(eval $(call MK_REMOTE_MAKE_TEMPLATE,clean))
681 version_REMOTE_XMAKEFLAGS := MLTON_VERSION=$(MLTON_VERSION)
682 $(eval $(call MK_REMOTE_MAKE_TEMPLATE,version))
683 $(eval $(call MK_REMOTE_MAKE_TEMPLATE,dirs))
684 runtime_REMOTE_XMAKEFLAGS := RELEASE=false
685 $(eval $(call MK_REMOTE_MAKE_TEMPLATE,runtime))
686 $(eval $(call MK_REMOTE_MAKE_TEMPLATE,bootstrap-compiler))
687 $(eval $(call MK_REMOTE_MAKE_TEMPLATE,script))
688 $(eval $(call MK_REMOTE_MAKE_TEMPLATE,basis))
689 $(eval $(call MK_REMOTE_MAKE_TEMPLATE,libraries))
690 $(eval $(call MK_REMOTE_MAKE_TEMPLATE,check))
691 all_REMOTE_XMAKEFLAGS := OLD_MLTON_DIR=$(REMOTE_ROOT)/boot/bin
692 $(eval $(call MK_REMOTE_MAKE_TEMPLATE,all))
693 binary-release_REMOTE_XMAKEFLAGS := MLTON_BINARY_RELEASE_WITH_DOCS=false
694 $(eval $(call MK_REMOTE_MAKE_TEMPLATE,binary-release))
695
696 endif
697
698 .PHONY: bootstrap-compiler
699 bootstrap-compiler:
700 $(MAKE) -C "$(SRC)/runtime" "bootstrap/$(MLTON_OUTPUT)"
701 $(CP) "$(SRC)/runtime/bootstrap/$(MLTON_OUTPUT)$(EXE)" "$(LIB)/"
702
703 ######################################################################
704
705 # ?????
706
707 BSDSRC := /tmp/mlton-$(MLTON_VERSION)
708 MLTON_FREEBSD_RELEASE := 1
709 .PHONY: freebsd
710 freebsd:
711 $(MAKE) clean clean-git version
712 $(RM) "$(BSDSRC)"
713 $(MKDIR) "$(BSDSRC)"
714 ( cd $(SRC) && $(TAR) -cpf - . ) | ( cd "$(BSDSRC)" && $(TAR) -xpf - )
715 cd /tmp && $(TAR) -cpf - mlton-$(MLTON_VERSION) | \
716 $(GZIP) --force --best >/usr/ports/distfiles/mlton-$(MLTON_VERSION)-$(MLTON_FREEBSD_RELEASE).freebsd.src.tgz
717 # do not change "make" to "$(MAKE)" in the following line
718 cd "$(BSDSRC)/package/freebsd" && MAINTAINER_MODE=yes make build-package