Debian Codegraph @

Makefile

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