Makefile: Print timing information in test output.
[fringe] / Makefile
CommitLineData
2bd37ef1
MW
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
15LANGS =
16TARGETS = $(patsubst %,%-fringe,$(LANGS))
17CLEANFILES = $(TARGETS)
18
19all::
20clean::; rm -f $(CLEANFILES)
21
22###--------------------------------------------------------------------------
23### Testing.
24
25CLEANFILES += test.*
26test:: all
b3cbee25
MW
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; \
2bd37ef1
MW
46 fi
47
48###--------------------------------------------------------------------------
49### C.
50
51CC = gcc
52CFLAGS = -O2 -g -pedantic -Wall
53CLEANFILES += *.o
54.SUFFIXES: .c
55.c.o:; $(CC) -c $(CFLAGS) -o $@ $<
56
57LANGS += c
58c-fringe: c-fringe.o
59 $(CC) -o $@ $^
60
61###--------------------------------------------------------------------------
62### Haskell.
63
64HC = ghc
65HFLAGS = -O2 -XFlexibleInstances
66CLEANFILES += *.hi *.hc
67.SUFFIXES: .hs
68.hs.o:; $(HC) -c $(HFLAGS) -o $@ $<
69
70LANGS += haskell
71haskell-fringe: haskell-fringe.o
72 $(HC) -o $@ $^
73
74###--------------------------------------------------------------------------
75### Icon.
76
77ICONT = icont
78IFLAGS = -u -fa
79
80LANGS += icon
81icon-fringe: icon-fringe.icn
82 $(ICONT) -o $@ $^
83
84###--------------------------------------------------------------------------
85### Common Lisp.
86
87LANGS += cl
88cl-fringe: cl-fringe.lisp
89 cl-launch -R -o $@ -f `pwd`/$^
90
91###--------------------------------------------------------------------------
92### F#.
93
94FSC = fsc
95CLEANFILES += *.exe
96.SUFFIXES: .fs .exe
97.fs.exe:; fsc -o $@ $<
98
99LANGS += f\#
100f\#-fringe: f\#-fringe.exe
101 chmod +x $<
102 cp $< $@
103
104###--------------------------------------------------------------------------
105### Scheme.
106
107SCMC = csc
108SCMFLAGS = -c -O2
109.SUFFIXES: .scm .o
110.scm.o:; $(SCMC) $(SCMFLAGS) -o $@ $<
111
112LANGS += scheme
113scheme-fringe: scheme-fringe.o
114 $(SCMC) -o $@ $^
115
116###--------------------------------------------------------------------------
117### Smalltalk.
118
119LANGS += smalltalk
120TARGETS += smalltalk-fringe.im
121smalltalk-fringe.im: smalltalk-fringe.st
122 echo "ObjectMemory snapshot: '$@.new'" | gst $^ -
123 mv $@.new $@
124smalltalk-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
134all:: $(TARGETS)