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