[MLton-commit] r7417

Wesley Terpstra wesley at mlton.org
Mon Feb 15 08:40:30 PST 2010


Multiple target rules do not work the way the original Makefile author thinks.

foo.h bar.h: deps
	rule

This means run 'rule' twice. Once for foo.h and once for bar.h.
In a serial build this doesn't matter because make will notice bar.h is 
up-to-date after building foo.h. In a parallel build, however, it will run
the 'rule' twice concurrently, leading to problems since the rule probably
affects both files.


----------------------------------------------------------------------

U   mlton/trunk/runtime/Makefile

----------------------------------------------------------------------

Modified: mlton/trunk/runtime/Makefile
===================================================================
--- mlton/trunk/runtime/Makefile	2010-02-15 14:57:21 UTC (rev 7416)
+++ mlton/trunk/runtime/Makefile	2010-02-15 16:40:30 UTC (rev 7417)
@@ -285,12 +285,15 @@
 
 all: $(ALL)
 
-$(GDTOACFILES):
+gdtoa/arithchk.c:	gdtoa.tgz gdtoa-patch gdtoa-patch.internal gdtoa-patch.mlton
 	gzip -dc gdtoa.tgz | tar xf -
 	patch -s -p0 <gdtoa-patch
 	patch -s -p0 <gdtoa-patch.internal
 	patch -s -p0 <gdtoa-patch.mlton
 
+$(GDTOACFILES): gdtoa/arithchk.c
+	@touch $@
+
 gdtoa/arithchk.out: gdtoa/arithchk.c
 	cd gdtoa && $(CC) $(OPTCFLAGS) $(OPTWARNCFLAGS) -w -O1 -o arithchk.out arithchk.c
 
@@ -309,22 +312,24 @@
 	rm -f basis.c
 	cat $(BASISCFILES) >> basis.c
 
-gen/c-types.h gen/c-types.sml gen/ml-types.h: gen/gen-types.c util.h util.o
+gen/c-types.h gen/c-types.sml gen/ml-types.h: gen/gen-types
+	@touch $@
+gen/gen-types:	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
-	rm -f gen/gen-types$(EXE)
 
-c-types.h ml-types.h: gen/c-types.h gen/ml-types.h
-	rm -f c-types.h ml-types.h
-	cp gen/c-types.h c-types.h
-	cp gen/ml-types.h ml-types.h
+c-types.h: gen/c-types.h
+	cp $< $@
+ml-types.h:	gen/ml-types.h
+	cp $< $@
 
-gen/basis-ffi.h gen/basis-ffi.sml: gen/gen-basis-ffi.sml gen/basis-ffi.def
+gen/basis-ffi.h gen/basis-ffi.sml: gen/gen-basis-ffi
+	@touch $@
+gen/gen-basis-ffi:	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
-	rm -f gen/gen-basis-ffi
 
 basis-ffi.h: gen/basis-ffi.h
 	rm -f basis-ffi.h
@@ -336,7 +341,7 @@
 	cd gen && ./gen-sizes
 	rm -f gen/gen-sizes$(EXE)
 
-bytecode/opcodes: bytecode/print-opcodes.c bytecode/opcode.h
+bytecode/opcodes: bytecode/print-opcodes.c bytecode/opcode.h $(BASISHFILES)
 	$(CC) $(OPTCFLAGS) $(WARNCFLAGS) -o bytecode/print-opcodes bytecode/print-opcodes.c
 	rm -f bytecode/opcodes
 	cd bytecode && ./print-opcodes > opcodes
@@ -439,8 +444,8 @@
 clean:
 	../bin/clean
 
-.PHONY: gdtoa-patch
-gdtoa-patch:
+.PHONY: rebuild-gdtoa-patch
+rebuild-gdtoa-patch:
 	cd gdtoa && $(MAKE) clean && rm -f *~ *.orig
 	mv gdtoa gdtoa-new
 	gzip -dc gdtoa.tgz | tar xf -




More information about the MLton-commit mailing list