[MLton-commit] r6982
Wesley Terpstra
wesley at mlton.org
Tue Nov 11 12:41:43 PST 2008
Modify the example building Makefile to:
1. Only build iimport with the 'all' target, defaulting to 'all-win32'
2. Capture the dependency on generated header files to ensure they build first
3. Use pattern rules to build targets with the same recipe
----------------------------------------------------------------------
U mlton/trunk/doc/examples/ffi/Makefile
----------------------------------------------------------------------
Modified: mlton/trunk/doc/examples/ffi/Makefile
===================================================================
--- mlton/trunk/doc/examples/ffi/Makefile 2008-11-10 12:20:42 UTC (rev 6981)
+++ mlton/trunk/doc/examples/ffi/Makefile 2008-11-11 20:41:42 UTC (rev 6982)
@@ -6,31 +6,26 @@
# See the file MLton-LICENSE for details.
##
-PATH := ../../../build/bin:$(shell echo $$PATH)
-
+PATH := ../../../build/bin:$(shell echo $$PATH)
mlton := mlton -default-ann 'allowFFI true'
-.PHONY: all
-all: import import2 export iimport test_quot
+.PHONY: all all-win32
+all-win32: import import2 export test_quot
./import
./import2
./export
- ./iimport
./test_quot
+all: all-win32 iimport
+ ./iimport
-export: export.sml ffi-export.c
- $(mlton) -export-header export.h -stop tc export.sml
- $(mlton) -stop o ffi-export.c
- $(mlton) export.sml ffi-export.o
-
+export: export.sml ffi-export.o
import: import.sml ffi-import.o
- $(mlton) import.sml ffi-import.o
-
import2: import2.sml ffi-import.o
- $(mlton) import2.sml ffi-import.o
+test_quot : test_quot.sml c_quot.o
-ffi-import.o:
- $(mlton) -stop o ffi-import.c
+ffi-import.o: export.h
+ffi-export.o: export.h
+c_quot.o : test_quot.h
iimport: iimport.sml
$(mlton) \
@@ -38,14 +33,12 @@
-target-link-opt solaris -ldl \
iimport.sml
-c_quot.o : c_quot.c test_quot.h
- $(mlton) -stop o c_quot.c
+%.o: %.c
+ $(mlton) -stop o $<
+%.h: %.sml
+ $(mlton) -export-header $@ -stop tc $<
+%:
+ $(mlton) -output $@ $^
-test_quot.h : test_quot.sml
- $(mlton) -export-header test_quot.h -stop tc test_quot.sml
-
-test_quot : test_quot.sml c_quot.o
- $(mlton) test_quot.sml c_quot.o
-
clean:
../../../bin/clean
More information about the MLton-commit
mailing list