Makefile: Gather statistics and report them.
[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 =
8f12efe5 16SOURCES =
2bd37ef1
MW
17TARGETS = $(patsubst %,%-fringe,$(LANGS))
18CLEANFILES = $(TARGETS)
19
20all::
21clean::; rm -f $(CLEANFILES)
22
23###--------------------------------------------------------------------------
24### Testing.
25
26CLEANFILES += test.*
27test:: all
b3cbee25
MW
28 @win=0 lose=0; \
29 for lang in $(LANGS); do \
30 echo >&3 "*** $$lang"; \
31 printf "Test $$lang..."; \
32 time=`command time -o/dev/stdout -f "%U user; %S system; %E" \
33 ./test ./$${lang}-fringe 2>&3`; \
34 if [ $$? -eq 0 ]; then \
35 win=$$(expr $$win + 1); \
36 printf " ok ($$time)\n"; \
37 else \
38 lose=$$(expr $$lose + 1); \
39 printf " FAILED\n"; \
40 fi; \
41 done 3>test.log; \
42 if [ $$lose -eq 0 ]; then \
43 echo "All $$win test(s) OK"; \
44 else \
45 echo "FAILED $$lose test(s)!"; \
46 exit 1; \
2bd37ef1
MW
47 fi
48
49###--------------------------------------------------------------------------
8f12efe5
MW
50### Reporting.
51
52report::
53 wc -l $(SOURCES) | sort -n
54
55###--------------------------------------------------------------------------
2bd37ef1
MW
56### C.
57
58CC = gcc
59CFLAGS = -O2 -g -pedantic -Wall
60CLEANFILES += *.o
61.SUFFIXES: .c
62.c.o:; $(CC) -c $(CFLAGS) -o $@ $<
63
64LANGS += c
8f12efe5 65SOURCES += c-fringe.c
2bd37ef1
MW
66c-fringe: c-fringe.o
67 $(CC) -o $@ $^
68
69###--------------------------------------------------------------------------
70### Haskell.
71
72HC = ghc
73HFLAGS = -O2 -XFlexibleInstances
74CLEANFILES += *.hi *.hc
75.SUFFIXES: .hs
76.hs.o:; $(HC) -c $(HFLAGS) -o $@ $<
77
78LANGS += haskell
8f12efe5 79SOURCES += haskell-fringe.hs
2bd37ef1
MW
80haskell-fringe: haskell-fringe.o
81 $(HC) -o $@ $^
82
83###--------------------------------------------------------------------------
84### Icon.
85
86ICONT = icont
87IFLAGS = -u -fa
88
89LANGS += icon
8f12efe5 90SOURCES += icon-fringe.icn
2bd37ef1
MW
91icon-fringe: icon-fringe.icn
92 $(ICONT) -o $@ $^
93
94###--------------------------------------------------------------------------
95### Common Lisp.
96
a72b6978
MW
97CLEANFILES += *.core
98
2bd37ef1 99LANGS += cl
8f12efe5 100SOURCES += cl-fringe.lisp
2bd37ef1 101cl-fringe: cl-fringe.lisp
a72b6978
MW
102## cl-launch -R -o $@ -f `pwd`/$^ -- slow to start
103 cl-launch -o $@ -f `pwd`/$^ +I -r launch -d $@.core
2bd37ef1
MW
104
105###--------------------------------------------------------------------------
106### F#.
107
108FSC = fsc
109CLEANFILES += *.exe
110.SUFFIXES: .fs .exe
111.fs.exe:; fsc -o $@ $<
112
113LANGS += f\#
8f12efe5 114SOURCES += f\#-fringe.fs
2bd37ef1
MW
115f\#-fringe: f\#-fringe.exe
116 chmod +x $<
117 cp $< $@
118
119###--------------------------------------------------------------------------
120### Scheme.
121
122SCMC = csc
123SCMFLAGS = -c -O2
124.SUFFIXES: .scm .o
125.scm.o:; $(SCMC) $(SCMFLAGS) -o $@ $<
126
127LANGS += scheme
8f12efe5 128SOURCES += scheme-fringe.scm
2bd37ef1
MW
129scheme-fringe: scheme-fringe.o
130 $(SCMC) -o $@ $^
131
132###--------------------------------------------------------------------------
133### Smalltalk.
134
135LANGS += smalltalk
136TARGETS += smalltalk-fringe.im
8f12efe5 137SOURCES += smalltalk-fringe.st
2bd37ef1
MW
138smalltalk-fringe.im: smalltalk-fringe.st
139 echo "ObjectMemory snapshot: '$@.new'" | gst $^ -
140 mv $@.new $@
141smalltalk-fringe:
142 { echo '#! /bin/sh'; \
143 echo '"exec" "gst" "-I" "$@.im" "-f" "$$0" "$$@"'; \
144 echo 'ObjectMemory quit: (Node main: Smalltalk arguments)'; \
145 } >$@.new
146 chmod +x $@.new
147 mv $@.new $@
148
149###----- That's all, folks --------------------------------------------------
150
151all:: $(TARGETS)