Makefile: Print timing information in test output.
[fringe] / Makefile
1 ### Makefile for same-fringe implementations.
2
3 ###--------------------------------------------------------------------------
4 ### Notes about organization.
5 ###
6 ### Most projects have lots of stuff in just a few languages, so it makes
7 ### sense to put the language configuration in one place. This one's
8 ### different. Its entire purpose is to demonstrate lots of different
9 ### approaches.
10 ###
11 ### So, at the top we declare the main targets; then each language has its
12 ### configuration and build rules.
13
14 .SUFFIXES: .o
15 LANGS =
16 TARGETS = $(patsubst %,%-fringe,$(LANGS))
17 CLEANFILES = $(TARGETS)
18
19 all::
20 clean::; rm -f $(CLEANFILES)
21
22 ###--------------------------------------------------------------------------
23 ### Testing.
24
25 CLEANFILES += test.*
26 test:: all
27 @win=0 lose=0; \
28 for lang in $(LANGS); do \
29 echo >&3 "*** $$lang"; \
30 printf "Test $$lang..."; \
31 time=`command time -o/dev/stdout -f "%U user; %S system; %E" \
32 ./test ./$${lang}-fringe 2>&3`; \
33 if [ $$? -eq 0 ]; then \
34 win=$$(expr $$win + 1); \
35 printf " ok ($$time)\n"; \
36 else \
37 lose=$$(expr $$lose + 1); \
38 printf " FAILED\n"; \
39 fi; \
40 done 3>test.log; \
41 if [ $$lose -eq 0 ]; then \
42 echo "All $$win test(s) OK"; \
43 else \
44 echo "FAILED $$lose test(s)!"; \
45 exit 1; \
46 fi
47
48 ###--------------------------------------------------------------------------
49 ### C.
50
51 CC = gcc
52 CFLAGS = -O2 -g -pedantic -Wall
53 CLEANFILES += *.o
54 .SUFFIXES: .c
55 .c.o:; $(CC) -c $(CFLAGS) -o $@ $<
56
57 LANGS += c
58 c-fringe: c-fringe.o
59 $(CC) -o $@ $^
60
61 ###--------------------------------------------------------------------------
62 ### Haskell.
63
64 HC = ghc
65 HFLAGS = -O2 -XFlexibleInstances
66 CLEANFILES += *.hi *.hc
67 .SUFFIXES: .hs
68 .hs.o:; $(HC) -c $(HFLAGS) -o $@ $<
69
70 LANGS += haskell
71 haskell-fringe: haskell-fringe.o
72 $(HC) -o $@ $^
73
74 ###--------------------------------------------------------------------------
75 ### Icon.
76
77 ICONT = icont
78 IFLAGS = -u -fa
79
80 LANGS += icon
81 icon-fringe: icon-fringe.icn
82 $(ICONT) -o $@ $^
83
84 ###--------------------------------------------------------------------------
85 ### Common Lisp.
86
87 LANGS += cl
88 cl-fringe: cl-fringe.lisp
89 cl-launch -R -o $@ -f `pwd`/$^
90
91 ###--------------------------------------------------------------------------
92 ### F#.
93
94 FSC = fsc
95 CLEANFILES += *.exe
96 .SUFFIXES: .fs .exe
97 .fs.exe:; fsc -o $@ $<
98
99 LANGS += f\#
100 f\#-fringe: f\#-fringe.exe
101 chmod +x $<
102 cp $< $@
103
104 ###--------------------------------------------------------------------------
105 ### Scheme.
106
107 SCMC = csc
108 SCMFLAGS = -c -O2
109 .SUFFIXES: .scm .o
110 .scm.o:; $(SCMC) $(SCMFLAGS) -o $@ $<
111
112 LANGS += scheme
113 scheme-fringe: scheme-fringe.o
114 $(SCMC) -o $@ $^
115
116 ###--------------------------------------------------------------------------
117 ### Smalltalk.
118
119 LANGS += smalltalk
120 TARGETS += smalltalk-fringe.im
121 smalltalk-fringe.im: smalltalk-fringe.st
122 echo "ObjectMemory snapshot: '$@.new'" | gst $^ -
123 mv $@.new $@
124 smalltalk-fringe:
125 { echo '#! /bin/sh'; \
126 echo '"exec" "gst" "-I" "$@.im" "-f" "$$0" "$$@"'; \
127 echo 'ObjectMemory quit: (Node main: Smalltalk arguments)'; \
128 } >$@.new
129 chmod +x $@.new
130 mv $@.new $@
131
132 ###----- That's all, folks --------------------------------------------------
133
134 all:: $(TARGETS)