chiark / gitweb /
go-fringe.go: Language change: `closed' function on channels has gone.
[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
43aab76c
MW
23###--------------------------------------------------------------------------
24### Silent rules stuff.
25
26## Default verbosity setting.
27V = 0
28
29## Infrastructure.
30v_echo = $(call v_echo_$V,$1)
31v_echo_1 =
32v_echo_0 = @printf " %-6s %s\n" "$1" "$@";
33V_HIDE = $(V_HIDE_$V)
34V_HIDE_0 = @
35
2bd37ef1
MW
36###--------------------------------------------------------------------------
37### Testing.
38
39CLEANFILES += test.*
40test:: all
b3cbee25
MW
41 @win=0 lose=0; \
42 for lang in $(LANGS); do \
43 echo >&3 "*** $$lang"; \
44 printf "Test $$lang..."; \
45 time=`command time -o/dev/stdout -f "%U user; %S system; %E" \
46 ./test ./$${lang}-fringe 2>&3`; \
47 if [ $$? -eq 0 ]; then \
48 win=$$(expr $$win + 1); \
49 printf " ok ($$time)\n"; \
50 else \
51 lose=$$(expr $$lose + 1); \
52 printf " FAILED\n"; \
53 fi; \
54 done 3>test.log; \
55 if [ $$lose -eq 0 ]; then \
56 echo "All $$win test(s) OK"; \
57 else \
58 echo "FAILED $$lose test(s)!"; \
59 exit 1; \
2bd37ef1
MW
60 fi
61
8f12efe5
MW
62###--------------------------------------------------------------------------
63### Reporting.
64
65report::
66 wc -l $(SOURCES) | sort -n
67
2bd37ef1
MW
68###--------------------------------------------------------------------------
69### C.
70
71CC = gcc
72CFLAGS = -O2 -g -pedantic -Wall
73CLEANFILES += *.o
74.SUFFIXES: .c
43aab76c 75.c.o:; $(call v_echo,CC)$(CC) -c $(CFLAGS) -o $@ $<
2bd37ef1
MW
76
77LANGS += c
8f12efe5 78SOURCES += c-fringe.c
2bd37ef1 79c-fringe: c-fringe.o
43aab76c 80 $(call v_echo,CCLD)$(CC) -o $@ $^
2bd37ef1
MW
81
82###--------------------------------------------------------------------------
83### Haskell.
84
85HC = ghc
eee4486f 86HFLAGS = -O2
2bd37ef1
MW
87CLEANFILES += *.hi *.hc
88.SUFFIXES: .hs
43aab76c 89.hs.o:; $(call v_echo,HC)$(HC) -c $(HFLAGS) -o $@ $<
2bd37ef1
MW
90
91LANGS += haskell
8f12efe5 92SOURCES += haskell-fringe.hs
2bd37ef1 93haskell-fringe: haskell-fringe.o
43aab76c 94 $(call v_echo,HCLD)$(HC) -o $@ $^
2bd37ef1
MW
95
96###--------------------------------------------------------------------------
97### Icon.
98
99ICONT = icont
e62da1cf 100IFLAGS = -u -s -fa
2bd37ef1
MW
101
102LANGS += icon
8f12efe5 103SOURCES += icon-fringe.icn
2bd37ef1 104icon-fringe: icon-fringe.icn
e62da1cf 105 $(call v_echo,ICONT)$(ICONT) $(IFLAGS) -o $@ $^
2bd37ef1
MW
106
107###--------------------------------------------------------------------------
108### Common Lisp.
109
23416a99
MW
110CLEANFILES += *.core *.fasl
111
112.SUFFIXES: .lisp .fasl
43aab76c 113.lisp.fasl:
e62da1cf
MW
114 $(call v_echo,CL)sbcl --noinform --eval \
115 '(quit :unix-status (if (compile-file "$<" :verbose nil :print nil) 0 1))'
a72b6978 116
2bd37ef1 117LANGS += cl
8f12efe5 118SOURCES += cl-fringe.lisp
23416a99 119cl-fringe: cl-fringe.fasl
43aab76c
MW
120 $(call v_echo,CP)cp $< $@.new && chmod +x $@.new && mv $@.new $@
121## $(call v_echo,CL)cl-launch -o $@ -f `pwd`/$^ +I -r launch -d $@.core
2bd37ef1
MW
122
123###--------------------------------------------------------------------------
124### F#.
125
f6006dc5 126FSC = fsharpc
e62da1cf 127FSCFLAGS =
2bd37ef1
MW
128CLEANFILES += *.exe
129.SUFFIXES: .fs .exe
e62da1cf 130.fs.exe:; $(call v_echo,FSC)$(FSC) --nologo $(FSCFLAGS) -o $@ $<
2bd37ef1
MW
131
132LANGS += f\#
8f12efe5 133SOURCES += f\#-fringe.fs
2bd37ef1 134f\#-fringe: f\#-fringe.exe
43aab76c 135 $(call v_echo,CP)chmod +x $< && cp $< $@
2bd37ef1
MW
136
137###--------------------------------------------------------------------------
138### Scheme.
139
140SCMC = csc
226de6c6 141SCMFLAGS = -c -O2
d33d05c3 142.SUFFIXES: .scm
43aab76c 143.scm.o:; $(call v_echo,SCMC)$(SCMC) $(SCMFLAGS) -o $@ $<
2bd37ef1
MW
144
145LANGS += scheme
8f12efe5 146SOURCES += scheme-fringe.scm
2bd37ef1 147scheme-fringe: scheme-fringe.o
43aab76c 148 $(call v_echo,SCMLD)$(SCMC) -o $@ $^
2bd37ef1 149
d888ccd5
MW
150###--------------------------------------------------------------------------
151### Go.
152
e13b0c79 153GOBUILD = go build
d888ccd5
MW
154LANGS += go
155SOURCES += go-fringe.go
e13b0c79
MW
156go-fringe: go-fringe.go
157 $(call v_echo,GO)$(GOBUILD) -o $@ $^
d888ccd5 158
2bd37ef1
MW
159###--------------------------------------------------------------------------
160### Smalltalk.
161
162LANGS += smalltalk
163TARGETS += smalltalk-fringe.im
8f12efe5 164SOURCES += smalltalk-fringe.st
2bd37ef1 165smalltalk-fringe.im: smalltalk-fringe.st
43aab76c
MW
166 $(call v_echo,GSTIM)echo "ObjectMemory snapshot: '$@.new'" | gst $^ -
167 $(V_HIDE)mv $@.new $@
2bd37ef1 168smalltalk-fringe:
43aab76c 169 $(call v_echo,GENSH){ echo '#! /bin/sh'; \
2bd37ef1
MW
170 echo '"exec" "gst" "-I" "$@.im" "-f" "$$0" "$$@"'; \
171 echo 'ObjectMemory quit: (Node main: Smalltalk arguments)'; \
172 } >$@.new
43aab76c 173 $(V_HIDE)chmod +x $@.new && mv $@.new $@
2bd37ef1 174
67ad47b7
MW
175###--------------------------------------------------------------------------
176### Forth.
177
178LANGS += forth
179TARGETS += forth-fringe
180SOURCES += forth-fringe.fth
181forth-fringe: forth-fringe.fth
182 $(call v_echo,FORTHI)gforthmi $@ $<
183
18b71d38
MW
184###--------------------------------------------------------------------------
185### Erlang.
186
187ERLC = erlc
188CLEANFILES += *.beam erl_crash.dump
189.SUFFIXES: .erl .beam
190.erl.beam:; $(call v_echo,ERLC)$(ERLC) $(ERLCFLAGS) $<
191
3f23c90e
MW
192LANGS += erlang
193TARGETS += erlang-fringe.beam
194SOURCES += erlang-fringe.erl
195erlang-fringe:
18b71d38 196 $(call v_echo,GENSH){ echo '#! /bin/sh'; \
3f23c90e 197 echo 'exec erl -pa . -noshell -run erlang-fringe main -extra "$$@"'; \
18b71d38
MW
198 } >$@.new
199 $(V_HIDE)chmod +x $@.new && mv $@.new $@
200
ca488b91
MW
201###--------------------------------------------------------------------------
202### Algol 68.
203
204ALGOL68 = /usr/local/bin/a68g
205
206LANGS += algol68
207TARGETS += algol68-fringe
208SOURCES += algol68-fringe.a68
209
210algol68-fringe: algol68-fringe.a68
211 $(call v_echo,GENSH){ echo '#! $(ALGOL68) --script'; \
212 cat $<; \
213 } >$@.new
214 $(V_HIDE)chmod +x $@.new && mv $@.new $@
215
5c4e9900
MW
216###--------------------------------------------------------------------------
217### Dylan.
218
219D2C = d2c
220CLEANFILES += dylan-*.c *.mak
221
222LANGS += dylan
223TARGETS += dylan-fringe
224SOURCES += dylan-fringe.dylan dylan-fringe-exports.dylan
225SOURCES += dylan-fringe.lid
226
227dylan-fringe: dylan-fringe.lid dylan-fringe.dylan dylan-fringe-exports.dylan
228 $(call v_echo,D2C)d2c -g $<
229
2bd37ef1
MW
230###----- That's all, folks --------------------------------------------------
231
232all:: $(TARGETS)