cl-fringe.lisp: Abstract out the startup stuff.
[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
eee4486f 73HFLAGS = -O2
2bd37ef1
MW
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
23416a99
MW
97CLEANFILES += *.core *.fasl
98
99.SUFFIXES: .lisp .fasl
100.lisp.fasl:; sbcl --eval '(quit :unix-status (if (compile-file "$<") 0 1))'
a72b6978 101
2bd37ef1 102LANGS += cl
8f12efe5 103SOURCES += cl-fringe.lisp
23416a99
MW
104cl-fringe: cl-fringe.fasl
105 cp $< $@.new && chmod +x $@.new && mv $@.new $@
106## cl-launch -o $@ -f `pwd`/$^ +I -r launch -d $@.core
2bd37ef1
MW
107
108###--------------------------------------------------------------------------
109### F#.
110
111FSC = fsc
112CLEANFILES += *.exe
113.SUFFIXES: .fs .exe
114.fs.exe:; fsc -o $@ $<
115
116LANGS += f\#
8f12efe5 117SOURCES += f\#-fringe.fs
2bd37ef1
MW
118f\#-fringe: f\#-fringe.exe
119 chmod +x $<
120 cp $< $@
121
122###--------------------------------------------------------------------------
123### Scheme.
124
125SCMC = csc
126SCMFLAGS = -c -O2
d33d05c3 127.SUFFIXES: .scm
2bd37ef1
MW
128.scm.o:; $(SCMC) $(SCMFLAGS) -o $@ $<
129
130LANGS += scheme
8f12efe5 131SOURCES += scheme-fringe.scm
2bd37ef1
MW
132scheme-fringe: scheme-fringe.o
133 $(SCMC) -o $@ $^
134
135###--------------------------------------------------------------------------
d888ccd5
MW
136### Go.
137
138GOOBJ = 8
139GOC = $(GOOBJ)g
140GOLINK = $(GOOBJ)l
141CLEANFILES += *.$(GOOBJ)
142.SUFFIXES: .$(GOOBJ) .go
143.go.$(GOOBJ):; $(GOC) $(GOFLAGS) $<
144
145LANGS += go
146SOURCES += go-fringe.go
147go-fringe: go-fringe.$(GOOBJ)
148 $(GOLINK) -o $@ $^
149
150###--------------------------------------------------------------------------
2bd37ef1
MW
151### Smalltalk.
152
153LANGS += smalltalk
154TARGETS += smalltalk-fringe.im
8f12efe5 155SOURCES += smalltalk-fringe.st
2bd37ef1
MW
156smalltalk-fringe.im: smalltalk-fringe.st
157 echo "ObjectMemory snapshot: '$@.new'" | gst $^ -
158 mv $@.new $@
159smalltalk-fringe:
160 { echo '#! /bin/sh'; \
161 echo '"exec" "gst" "-I" "$@.im" "-f" "$$0" "$$@"'; \
162 echo 'ObjectMemory quit: (Node main: Smalltalk arguments)'; \
163 } >$@.new
164 chmod +x $@.new
165 mv $@.new $@
166
167###----- That's all, folks --------------------------------------------------
168
169all:: $(TARGETS)