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