Initial version.
[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 =
16TARGETS = $(patsubst %,%-fringe,$(LANGS))
17CLEANFILES = $(TARGETS)
18
19all::
20clean::; rm -f $(CLEANFILES)
21
22###--------------------------------------------------------------------------
23### Testing.
24
25CLEANFILES += test.*
26test:: 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
49CC = gcc
50CFLAGS = -O2 -g -pedantic -Wall
51CLEANFILES += *.o
52.SUFFIXES: .c
53.c.o:; $(CC) -c $(CFLAGS) -o $@ $<
54
55LANGS += c
56c-fringe: c-fringe.o
57 $(CC) -o $@ $^
58
59###--------------------------------------------------------------------------
60### Haskell.
61
62HC = ghc
63HFLAGS = -O2 -XFlexibleInstances
64CLEANFILES += *.hi *.hc
65.SUFFIXES: .hs
66.hs.o:; $(HC) -c $(HFLAGS) -o $@ $<
67
68LANGS += haskell
69haskell-fringe: haskell-fringe.o
70 $(HC) -o $@ $^
71
72###--------------------------------------------------------------------------
73### Icon.
74
75ICONT = icont
76IFLAGS = -u -fa
77
78LANGS += icon
79icon-fringe: icon-fringe.icn
80 $(ICONT) -o $@ $^
81
82###--------------------------------------------------------------------------
83### Common Lisp.
84
85LANGS += cl
86cl-fringe: cl-fringe.lisp
87 cl-launch -R -o $@ -f `pwd`/$^
88
89###--------------------------------------------------------------------------
90### F#.
91
92FSC = fsc
93CLEANFILES += *.exe
94.SUFFIXES: .fs .exe
95.fs.exe:; fsc -o $@ $<
96
97LANGS += f\#
98f\#-fringe: f\#-fringe.exe
99 chmod +x $<
100 cp $< $@
101
102###--------------------------------------------------------------------------
103### Scheme.
104
105SCMC = csc
106SCMFLAGS = -c -O2
107.SUFFIXES: .scm .o
108.scm.o:; $(SCMC) $(SCMFLAGS) -o $@ $<
109
110LANGS += scheme
111scheme-fringe: scheme-fringe.o
112 $(SCMC) -o $@ $^
113
114###--------------------------------------------------------------------------
115### Smalltalk.
116
117LANGS += smalltalk
118TARGETS += smalltalk-fringe.im
119smalltalk-fringe.im: smalltalk-fringe.st
120 echo "ObjectMemory snapshot: '$@.new'" | gst $^ -
121 mv $@.new $@
122smalltalk-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
132all:: $(TARGETS)