cl-fringe.lisp: Abstract out the startup stuff.
[fringe] / Makefile
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 =
16 SOURCES =
17 TARGETS = $(patsubst %,%-fringe,$(LANGS))
18 CLEANFILES = $(TARGETS)
19
20 all::
21 clean::; rm -f $(CLEANFILES)
22
23 ###--------------------------------------------------------------------------
24 ### Testing.
25
26 CLEANFILES += test.*
27 test:: all
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; \
47 fi
48
49 ###--------------------------------------------------------------------------
50 ### Reporting.
51
52 report::
53 wc -l $(SOURCES) | sort -n
54
55 ###--------------------------------------------------------------------------
56 ### C.
57
58 CC = gcc
59 CFLAGS = -O2 -g -pedantic -Wall
60 CLEANFILES += *.o
61 .SUFFIXES: .c
62 .c.o:; $(CC) -c $(CFLAGS) -o $@ $<
63
64 LANGS += c
65 SOURCES += c-fringe.c
66 c-fringe: c-fringe.o
67 $(CC) -o $@ $^
68
69 ###--------------------------------------------------------------------------
70 ### Haskell.
71
72 HC = ghc
73 HFLAGS = -O2
74 CLEANFILES += *.hi *.hc
75 .SUFFIXES: .hs
76 .hs.o:; $(HC) -c $(HFLAGS) -o $@ $<
77
78 LANGS += haskell
79 SOURCES += haskell-fringe.hs
80 haskell-fringe: haskell-fringe.o
81 $(HC) -o $@ $^
82
83 ###--------------------------------------------------------------------------
84 ### Icon.
85
86 ICONT = icont
87 IFLAGS = -u -fa
88
89 LANGS += icon
90 SOURCES += icon-fringe.icn
91 icon-fringe: icon-fringe.icn
92 $(ICONT) -o $@ $^
93
94 ###--------------------------------------------------------------------------
95 ### Common Lisp.
96
97 CLEANFILES += *.core *.fasl
98
99 .SUFFIXES: .lisp .fasl
100 .lisp.fasl:; sbcl --eval '(quit :unix-status (if (compile-file "$<") 0 1))'
101
102 LANGS += cl
103 SOURCES += cl-fringe.lisp
104 cl-fringe: cl-fringe.fasl
105 cp $< $@.new && chmod +x $@.new && mv $@.new $@
106 ## cl-launch -o $@ -f `pwd`/$^ +I -r launch -d $@.core
107
108 ###--------------------------------------------------------------------------
109 ### F#.
110
111 FSC = fsc
112 CLEANFILES += *.exe
113 .SUFFIXES: .fs .exe
114 .fs.exe:; fsc -o $@ $<
115
116 LANGS += f\#
117 SOURCES += f\#-fringe.fs
118 f\#-fringe: f\#-fringe.exe
119 chmod +x $<
120 cp $< $@
121
122 ###--------------------------------------------------------------------------
123 ### Scheme.
124
125 SCMC = csc
126 SCMFLAGS = -c -O2
127 .SUFFIXES: .scm
128 .scm.o:; $(SCMC) $(SCMFLAGS) -o $@ $<
129
130 LANGS += scheme
131 SOURCES += scheme-fringe.scm
132 scheme-fringe: scheme-fringe.o
133 $(SCMC) -o $@ $^
134
135 ###--------------------------------------------------------------------------
136 ### Go.
137
138 GOOBJ = 8
139 GOC = $(GOOBJ)g
140 GOLINK = $(GOOBJ)l
141 CLEANFILES += *.$(GOOBJ)
142 .SUFFIXES: .$(GOOBJ) .go
143 .go.$(GOOBJ):; $(GOC) $(GOFLAGS) $<
144
145 LANGS += go
146 SOURCES += go-fringe.go
147 go-fringe: go-fringe.$(GOOBJ)
148 $(GOLINK) -o $@ $^
149
150 ###--------------------------------------------------------------------------
151 ### Smalltalk.
152
153 LANGS += smalltalk
154 TARGETS += smalltalk-fringe.im
155 SOURCES += smalltalk-fringe.st
156 smalltalk-fringe.im: smalltalk-fringe.st
157 echo "ObjectMemory snapshot: '$@.new'" | gst $^ -
158 mv $@.new $@
159 smalltalk-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
169 all:: $(TARGETS)