diff -Naur mlton-r6658.orig/bin/upgrade-basis mlton-r6658/bin/upgrade-basis --- mlton-r6658.orig/bin/upgrade-basis 2008-06-16 16:08:02.000000000 +0200 +++ mlton-r6658/bin/upgrade-basis 2008-06-16 16:40:47.000000000 +0200 @@ -11,14 +11,15 @@ name=`basename "$0"` usage () { - die "usage: $name " + die "usage: $name " } case "$#" in -3) +4) PATH="$1" ARCH="$2" OS="$3" + TARGET="$4" ;; *) usage @@ -28,7 +29,7 @@ tmp="$$.sml" echo "val () = print \"I work\"" >"$tmp" -if ! mlton "$tmp" 1>&2; then +if ! mlton -target $TARGET "$tmp" 1>&2; then die "Error: cannot upgrade basis because the compiler doesn't work" fi @@ -36,7 +37,7 @@ feature="$1" sml="$2" echo "$feature" >"$tmp" - if ! mlton -stop tc "$tmp" >/dev/null 2>&1; then + if ! mlton -target $TARGET -stop tc "$tmp" >/dev/null 2>&1; then echo "$sml" fi } diff -Naur mlton-r6658.orig/Makefile mlton-r6658/Makefile --- mlton-r6658.orig/Makefile 2008-06-16 16:08:03.000000000 +0200 +++ mlton-r6658/Makefile 2008-06-16 16:40:47.000000000 +0200 @@ -9,6 +9,7 @@ export TARGET := self export TARGET_ARCH := $(shell bin/host-arch) export TARGET_OS := $(shell bin/host-os) +export TARGET_MACHINE := localhost ROOT := $(shell pwd) BUILD := $(ROOT)/build SRC := $(ROOT) @@ -34,7 +35,20 @@ PATH := $(BIN):$(SRC)/bin:$(shell echo $$PATH) CP := /bin/cp -fpR GZIP := gzip --force --best +ifeq ($(TARGET), self) RANLIB := ranlib +else +RANLIB := $(TARGET)-ranlib +endif +ifeq ($(TARGET_MACHINE), localhost) +TARGET_EXEC_BEGIN := $(EXTRA_TARGET_EXEC_INIT) +TARGET_EXEC_STDOUT := +TARGET_EXEC_FILE := +else +TARGET_EXEC_BEGIN := cat +TARGET_EXEC_STDOUT := | ssh -x $(TARGET_MACHINE) "mkdir /tmp/mlton-\$$\$$ ; cd /tmp/mlton-\$$\$$ ; cat - > binary.exe ; chmod +x binary.exe ; ($(EXTRA_TARGET_EXEC_INIT) ./binary.exe) ; cd / ; /bin/rm -rf /tmp/mlton-\$$\$$" +TARGET_EXEC_FILE := | ssh -x $(TARGET_MACHINE) "mkdir /tmp/mlton-\$$\$$ ; cd /tmp/mlton-\$$\$$ ; cat - > binary.exe ; chmod +x binary.exe ; ($(EXTRA_TARGET_EXEC_INIT) ./binary.exe) ; /bin/rm -f binary.exe ; tar cf - . ; cd / ; /bin/rm -rf /tmp/mlton-\$$\$$" | tar xf - +endif # If we're compiling with another version of MLton, then we want to do # another round of compilation so that we get a MLton built without @@ -108,9 +122,9 @@ .PHONY: constants constants: @echo 'Creating constants file.' - "$(BIN)/mlton" -build-constants true >tmp.c - "$(BIN)/mlton" -output tmp tmp.c - ./tmp >"$(LIB)/$(TARGET)/constants" + "$(BIN)/mlton" -target $(TARGET) -build-constants true >tmp.c + "$(BIN)/mlton" -target $(TARGET) -output tmp tmp.c + $(TARGET_EXEC_BEGIN) ./tmp $(TARGET_EXEC_STDOUT) >"$(LIB)/$(TARGET)/constants" rm -f tmp tmp.c DEBSRC := mlton-$(VERSION).orig diff -Naur mlton-r6658.orig/mlton/Makefile mlton-r6658/mlton/Makefile --- mlton-r6658.orig/mlton/Makefile 2008-06-16 16:04:17.000000000 +0200 +++ mlton-r6658/mlton/Makefile 2008-06-16 16:40:47.000000000 +0200 @@ -9,8 +9,8 @@ SRC := $(shell cd .. && pwd) BUILD := $(SRC)/build BIN := $(BUILD)/bin -HOST_ARCH := $(shell "$(SRC)/bin/host-arch") -HOST_OS := $(shell "$(SRC)/bin/host-os") +TARGET_ARCH := $(shell "$(SRC)/bin/host-arch") +TARGET_OS := $(shell "$(SRC)/bin/host-os") LIB := $(BUILD)/lib MLTON := mlton TARGET := self @@ -27,12 +27,12 @@ FLAGS += -default-ann 'warnUnused true' # FLAGS += -type-check true -show-types true else -ifeq (cygwin, $(HOST_OS)) +ifeq (cygwin, $(TARGET_OS)) # The stubs don't work on Cygwin, since they define spawn in terms of # fork, and fork doesn't work on Cygwin. So, make without the stubs. FILE := mlton.cm else -ifeq (mingw, $(HOST_OS)) +ifeq (mingw, $(TARGET_OS)) # Ditto for MinGW. FILE := mlton.cm else @@ -87,7 +87,7 @@ #! Pass $(PATH) to upgrade-basis because it is run via #!/usr/bin/env # bash, which resets the path. $(UP): - "$(SRC)/bin/upgrade-basis" '$(PATH)' "$(HOST_ARCH)" "$(HOST_OS)" >$(UP) + "$(SRC)/bin/upgrade-basis" '$(PATH)' "$(TARGET_ARCH)" "$(TARGET_OS)" "$(TARGET)" >$(UP) mlton.sml: $(SOURCES) rm -f mlton.sml && mlton -stop sml mlton.cm && chmod -w mlton.sml diff -Naur mlton-r6658.orig/runtime/Makefile mlton-r6658/runtime/Makefile --- mlton-r6658.orig/runtime/Makefile 2008-06-16 16:03:08.000000000 +0200 +++ mlton-r6658/runtime/Makefile 2008-06-16 16:42:12.000000000 +0200 @@ -9,6 +9,17 @@ PATH := ../bin:$(shell echo $$PATH) TARGET := self +TARGET_MACHINE := localhost + +ifeq ($(TARGET_MACHINE), localhost) +TARGET_EXEC_BEGIN := $(EXTRA_TARGET_EXEC_INIT) +TARGET_EXEC_STDOUT := +TARGET_EXEC_FILE := +else +TARGET_EXEC_BEGIN := cat +TARGET_EXEC_STDOUT := | ssh -x $(TARGET_MACHINE) "mkdir /tmp/mlton-\$$\$$ ; cd /tmp/mlton-\$$\$$ ; cat - > binary.exe ; chmod +x binary.exe ; ($(EXTRA_TARGET_EXEC_INIT) ./binary.exe) ; cd / ; /bin/rm -rf /tmp/mlton-\$$\$$" +TARGET_EXEC_FILE := | ssh -x $(TARGET_MACHINE) "mkdir /tmp/mlton-\$$\$$ ; cd /tmp/mlton-\$$\$$ ; cat - > binary.exe ; chmod +x binary.exe ; ($(EXTRA_TARGET_EXEC_INIT) ./binary.exe) ; /bin/rm -f binary.exe ; tar cf - . ; cd / ; /bin/rm -rf /tmp/mlton-\$$\$$" | tar xf - +endif ifeq ($(TARGET), self) CC := gcc -std=gnu99 @@ -256,7 +267,7 @@ cd gdtoa && $(CC) $(OPTCFLAGS) $(OPTWARNCFLAGS) -w -O1 -o arithchk.out arithchk.c gdtoa/arith.h: gdtoa/arithchk.out - cd gdtoa && ./arithchk.out >arith.h + cd gdtoa && $(TARGET_EXEC_BEGIN) ./arithchk.out $(TARGET_EXEC_STDOUT) >arith.h libmlton.a: $(OBJS) $(AR) libmlton.a $(OBJS) @@ -274,7 +285,7 @@ gen/c-types.h gen/c-types.sml gen/ml-types.h: gen/gen-types.c util.h util.o $(CC) $(OPTCFLAGS) $(WARNCFLAGS) -o gen/gen-types gen/gen-types.c util.o rm -f gen/c-types.h gen/c-types.sml gen/ml-types.h - cd gen && ./gen-types + cd gen && $(TARGET_EXEC_BEGIN) ./gen-types $(TARGET_EXEC_FILE) rm -f gen/gen-types$(EXE) c-types.h ml-types.h: gen/c-types.h gen/ml-types.h @@ -285,7 +296,7 @@ gen/basis-ffi.h gen/basis-ffi.sml: gen/gen-basis-ffi.sml gen/basis-ffi.def mlton -output gen/gen-basis-ffi gen/gen-basis-ffi.sml rm -f gen/basis-ffi.h gen/basis-ffi.sml - cd gen && ./gen-basis-ffi + cd gen && $(TARGET_EXEC_BEGIN) ./gen-basis-ffi $(TARGET_EXEC_FILE) rm -f gen/gen-basis-ffi basis-ffi.h: gen/basis-ffi.h @@ -295,13 +306,13 @@ gen/sizes: gen/gen-sizes.c libmlton.a $(CC) $(OPTCFLAGS) $(WARNCFLAGS) -o gen/gen-sizes -I. -L. -lmlton gen/gen-sizes.c util.o rm -f gen/sizes - cd gen && ./gen-sizes + cd gen && $(TARGET_EXEC_BEGIN) ./gen-sizes $(TARGET_EXEC_FILE) rm -f gen/gen-sizes$(EXE) bytecode/opcodes: bytecode/print-opcodes.c bytecode/opcode.h $(CC) $(OPTCFLAGS) $(WARNCFLAGS) -o bytecode/print-opcodes bytecode/print-opcodes.c rm -f bytecode/opcodes - cd bytecode && ./print-opcodes > opcodes + cd bytecode && $(TARGET_EXEC_BEGIN) ./print-opcodes $(TARGET_EXEC_STDOUT) > opcodes rm -f bytecode/print-opcodes$(EXE)