Debian Codegraph @

Makefile

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