Commit | Line | Data |
---|---|---|
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 | |
15 | LANGS = | |
8f12efe5 | 16 | SOURCES = |
2bd37ef1 MW |
17 | TARGETS = $(patsubst %,%-fringe,$(LANGS)) |
18 | CLEANFILES = $(TARGETS) | |
19 | ||
20 | all:: | |
21 | clean::; rm -f $(CLEANFILES) | |
22 | ||
23 | ###-------------------------------------------------------------------------- | |
43aab76c MW |
24 | ### Silent rules stuff. |
25 | ||
26 | ## Default verbosity setting. | |
27 | V = 0 | |
28 | ||
29 | ## Infrastructure. | |
30 | v_echo = $(call v_echo_$V,$1) | |
31 | v_echo_1 = | |
32 | v_echo_0 = @printf " %-6s %s\n" "$1" "$@"; | |
33 | V_HIDE = $(V_HIDE_$V) | |
34 | V_HIDE_0 = @ | |
35 | ||
36 | ###-------------------------------------------------------------------------- | |
2bd37ef1 MW |
37 | ### Testing. |
38 | ||
39 | CLEANFILES += test.* | |
40 | test:: 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 | ||
62 | ###-------------------------------------------------------------------------- | |
8f12efe5 MW |
63 | ### Reporting. |
64 | ||
65 | report:: | |
66 | wc -l $(SOURCES) | sort -n | |
67 | ||
68 | ###-------------------------------------------------------------------------- | |
2bd37ef1 MW |
69 | ### C. |
70 | ||
71 | CC = gcc | |
72 | CFLAGS = -O2 -g -pedantic -Wall | |
73 | CLEANFILES += *.o | |
74 | .SUFFIXES: .c | |
43aab76c | 75 | .c.o:; $(call v_echo,CC)$(CC) -c $(CFLAGS) -o $@ $< |
2bd37ef1 MW |
76 | |
77 | LANGS += c | |
8f12efe5 | 78 | SOURCES += c-fringe.c |
2bd37ef1 | 79 | c-fringe: c-fringe.o |
43aab76c | 80 | $(call v_echo,CCLD)$(CC) -o $@ $^ |
2bd37ef1 MW |
81 | |
82 | ###-------------------------------------------------------------------------- | |
83 | ### Haskell. | |
84 | ||
85 | HC = ghc | |
eee4486f | 86 | HFLAGS = -O2 |
2bd37ef1 MW |
87 | CLEANFILES += *.hi *.hc |
88 | .SUFFIXES: .hs | |
43aab76c | 89 | .hs.o:; $(call v_echo,HC)$(HC) -c $(HFLAGS) -o $@ $< |
2bd37ef1 MW |
90 | |
91 | LANGS += haskell | |
8f12efe5 | 92 | SOURCES += haskell-fringe.hs |
2bd37ef1 | 93 | haskell-fringe: haskell-fringe.o |
43aab76c | 94 | $(call v_echo,HCLD)$(HC) -o $@ $^ |
2bd37ef1 MW |
95 | |
96 | ###-------------------------------------------------------------------------- | |
97 | ### Icon. | |
98 | ||
99 | ICONT = icont | |
e62da1cf | 100 | IFLAGS = -u -s -fa |
2bd37ef1 MW |
101 | |
102 | LANGS += icon | |
8f12efe5 | 103 | SOURCES += icon-fringe.icn |
2bd37ef1 | 104 | icon-fringe: icon-fringe.icn |
e62da1cf | 105 | $(call v_echo,ICONT)$(ICONT) $(IFLAGS) -o $@ $^ |
2bd37ef1 MW |
106 | |
107 | ###-------------------------------------------------------------------------- | |
108 | ### Common Lisp. | |
109 | ||
23416a99 MW |
110 | CLEANFILES += *.core *.fasl |
111 | ||
20ef5352 MW |
112 | SBCL_BUILD = ./sbcl-build |
113 | ||
23416a99 | 114 | .SUFFIXES: .lisp .fasl |
43aab76c | 115 | .lisp.fasl: |
20ef5352 | 116 | $(call v_echo,CL)$(SBCL_BUILD) build $< |
a72b6978 | 117 | |
2bd37ef1 | 118 | LANGS += cl |
8f12efe5 | 119 | SOURCES += cl-fringe.lisp |
23416a99 | 120 | cl-fringe: cl-fringe.fasl |
20ef5352 | 121 | $(call v_echo,CLLD)$(SBCL_BUILD) link $@ $^ |
2bd37ef1 MW |
122 | |
123 | ###-------------------------------------------------------------------------- | |
124 | ### F#. | |
125 | ||
f6006dc5 | 126 | FSC = fsharpc |
e62da1cf | 127 | FSCFLAGS = |
2bd37ef1 MW |
128 | CLEANFILES += *.exe |
129 | .SUFFIXES: .fs .exe | |
e62da1cf | 130 | .fs.exe:; $(call v_echo,FSC)$(FSC) --nologo $(FSCFLAGS) -o $@ $< |
2bd37ef1 MW |
131 | |
132 | LANGS += f\# | |
8f12efe5 | 133 | SOURCES += f\#-fringe.fs |
2bd37ef1 | 134 | f\#-fringe: f\#-fringe.exe |
43aab76c | 135 | $(call v_echo,CP)chmod +x $< && cp $< $@ |
2bd37ef1 MW |
136 | |
137 | ###-------------------------------------------------------------------------- | |
138 | ### Scheme. | |
139 | ||
140 | SCMC = csc | |
226de6c6 | 141 | SCMFLAGS = -c -O2 |
d33d05c3 | 142 | .SUFFIXES: .scm |
43aab76c | 143 | .scm.o:; $(call v_echo,SCMC)$(SCMC) $(SCMFLAGS) -o $@ $< |
2bd37ef1 MW |
144 | |
145 | LANGS += scheme | |
8f12efe5 | 146 | SOURCES += scheme-fringe.scm |
2bd37ef1 | 147 | scheme-fringe: scheme-fringe.o |
43aab76c | 148 | $(call v_echo,SCMLD)$(SCMC) -o $@ $^ |
2bd37ef1 MW |
149 | |
150 | ###-------------------------------------------------------------------------- | |
d888ccd5 MW |
151 | ### Go. |
152 | ||
e13b0c79 | 153 | GOBUILD = go build |
d888ccd5 MW |
154 | LANGS += go |
155 | SOURCES += go-fringe.go | |
e13b0c79 MW |
156 | go-fringe: go-fringe.go |
157 | $(call v_echo,GO)$(GOBUILD) -o $@ $^ | |
d888ccd5 MW |
158 | |
159 | ###-------------------------------------------------------------------------- | |
2bd37ef1 MW |
160 | ### Smalltalk. |
161 | ||
162 | LANGS += smalltalk | |
163 | TARGETS += smalltalk-fringe.im | |
8f12efe5 | 164 | SOURCES += smalltalk-fringe.st |
2bd37ef1 | 165 | smalltalk-fringe.im: smalltalk-fringe.st |
43aab76c MW |
166 | $(call v_echo,GSTIM)echo "ObjectMemory snapshot: '$@.new'" | gst $^ - |
167 | $(V_HIDE)mv $@.new $@ | |
2bd37ef1 | 168 | smalltalk-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 | |
18b71d38 | 175 | ###-------------------------------------------------------------------------- |
67ad47b7 MW |
176 | ### Forth. |
177 | ||
178 | LANGS += forth | |
179 | TARGETS += forth-fringe | |
180 | SOURCES += forth-fringe.fth | |
181 | forth-fringe: forth-fringe.fth | |
182 | $(call v_echo,FORTHI)gforthmi $@ $< | |
183 | ||
184 | ###-------------------------------------------------------------------------- | |
18b71d38 MW |
185 | ### Erlang. |
186 | ||
187 | ERLC = erlc | |
188 | CLEANFILES += *.beam erl_crash.dump | |
189 | .SUFFIXES: .erl .beam | |
190 | .erl.beam:; $(call v_echo,ERLC)$(ERLC) $(ERLCFLAGS) $< | |
191 | ||
3f23c90e MW |
192 | LANGS += erlang |
193 | TARGETS += erlang-fringe.beam | |
194 | SOURCES += erlang-fringe.erl | |
195 | erlang-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 | ||
204 | ALGOL68 = /usr/local/bin/a68g | |
205 | ||
206 | LANGS += algol68 | |
207 | TARGETS += algol68-fringe | |
208 | SOURCES += algol68-fringe.a68 | |
209 | ||
210 | algol68-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 | ||
219 | D2C = d2c | |
220 | CLEANFILES += dylan-*.c *.mak | |
221 | ||
222 | LANGS += dylan | |
223 | TARGETS += dylan-fringe | |
224 | SOURCES += dylan-fringe.dylan dylan-fringe-exports.dylan | |
225 | SOURCES += dylan-fringe.lid | |
226 | ||
227 | dylan-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 | ||
232 | all:: $(TARGETS) |