Makefile: Tweak various compiler options for quieter builds.
[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###--------------------------------------------------------------------------
43aab76c
MW
24### Silent rules stuff.
25
26## Default verbosity setting.
27V = 0
28
29## Infrastructure.
30v_echo = $(call v_echo_$V,$1)
31v_echo_1 =
32v_echo_0 = @printf " %-6s %s\n" "$1" "$@";
33V_HIDE = $(V_HIDE_$V)
34V_HIDE_0 = @
35
36###--------------------------------------------------------------------------
2bd37ef1
MW
37### Testing.
38
39CLEANFILES += test.*
40test:: all
b3cbee25
MW
41 @win=0 lose=0; \
42 for lang in $(LANGS); do \
43 echo >&3 "*** $$lang"; \
44 printf "Test $$lang..."; \
45 time=`command time -o/dev/stdout -f "%U user; %S system; %E" \
46 ./test ./$${lang}-fringe 2>&3`; \
47 if [ $$? -eq 0 ]; then \
48 win=$$(expr $$win + 1); \
49 printf " ok ($$time)\n"; \
50 else \
51 lose=$$(expr $$lose + 1); \
52 printf " FAILED\n"; \
53 fi; \
54 done 3>test.log; \
55 if [ $$lose -eq 0 ]; then \
56 echo "All $$win test(s) OK"; \
57 else \
58 echo "FAILED $$lose test(s)!"; \
59 exit 1; \
2bd37ef1
MW
60 fi
61
62###--------------------------------------------------------------------------
8f12efe5
MW
63### Reporting.
64
65report::
66 wc -l $(SOURCES) | sort -n
67
68###--------------------------------------------------------------------------
2bd37ef1
MW
69### C.
70
71CC = gcc
72CFLAGS = -O2 -g -pedantic -Wall
73CLEANFILES += *.o
74.SUFFIXES: .c
43aab76c 75.c.o:; $(call v_echo,CC)$(CC) -c $(CFLAGS) -o $@ $<
2bd37ef1
MW
76
77LANGS += c
8f12efe5 78SOURCES += c-fringe.c
2bd37ef1 79c-fringe: c-fringe.o
43aab76c 80 $(call v_echo,CCLD)$(CC) -o $@ $^
2bd37ef1
MW
81
82###--------------------------------------------------------------------------
83### Haskell.
84
85HC = ghc
eee4486f 86HFLAGS = -O2
2bd37ef1
MW
87CLEANFILES += *.hi *.hc
88.SUFFIXES: .hs
43aab76c 89.hs.o:; $(call v_echo,HC)$(HC) -c $(HFLAGS) -o $@ $<
2bd37ef1
MW
90
91LANGS += haskell
8f12efe5 92SOURCES += haskell-fringe.hs
2bd37ef1 93haskell-fringe: haskell-fringe.o
43aab76c 94 $(call v_echo,HCLD)$(HC) -o $@ $^
2bd37ef1
MW
95
96###--------------------------------------------------------------------------
97### Icon.
98
99ICONT = icont
e62da1cf 100IFLAGS = -u -s -fa
2bd37ef1
MW
101
102LANGS += icon
8f12efe5 103SOURCES += icon-fringe.icn
2bd37ef1 104icon-fringe: icon-fringe.icn
e62da1cf 105 $(call v_echo,ICONT)$(ICONT) $(IFLAGS) -o $@ $^
2bd37ef1
MW
106
107###--------------------------------------------------------------------------
108### Common Lisp.
109
23416a99
MW
110CLEANFILES += *.core *.fasl
111
112.SUFFIXES: .lisp .fasl
43aab76c 113.lisp.fasl:
e62da1cf
MW
114 $(call v_echo,CL)sbcl --noinform --eval \
115 '(quit :unix-status (if (compile-file "$<" :verbose nil :print nil) 0 1))'
a72b6978 116
2bd37ef1 117LANGS += cl
8f12efe5 118SOURCES += cl-fringe.lisp
23416a99 119cl-fringe: cl-fringe.fasl
43aab76c
MW
120 $(call v_echo,CP)cp $< $@.new && chmod +x $@.new && mv $@.new $@
121## $(call v_echo,CL)cl-launch -o $@ -f `pwd`/$^ +I -r launch -d $@.core
2bd37ef1
MW
122
123###--------------------------------------------------------------------------
124### F#.
125
126FSC = fsc
e62da1cf 127FSCFLAGS =
2bd37ef1
MW
128CLEANFILES += *.exe
129.SUFFIXES: .fs .exe
e62da1cf 130.fs.exe:; $(call v_echo,FSC)$(FSC) --nologo $(FSCFLAGS) -o $@ $<
2bd37ef1
MW
131
132LANGS += f\#
8f12efe5 133SOURCES += f\#-fringe.fs
2bd37ef1 134f\#-fringe: f\#-fringe.exe
43aab76c 135 $(call v_echo,CP)chmod +x $< && cp $< $@
2bd37ef1
MW
136
137###--------------------------------------------------------------------------
138### Scheme.
139
140SCMC = csc
141SCMFLAGS = -c -O2
d33d05c3 142.SUFFIXES: .scm
43aab76c 143.scm.o:; $(call v_echo,SCMC)$(SCMC) $(SCMFLAGS) -o $@ $<
2bd37ef1
MW
144
145LANGS += scheme
8f12efe5 146SOURCES += scheme-fringe.scm
2bd37ef1 147scheme-fringe: scheme-fringe.o
43aab76c 148 $(call v_echo,SCMLD)$(SCMC) -o $@ $^
2bd37ef1
MW
149
150###--------------------------------------------------------------------------
d888ccd5
MW
151### Go.
152
153GOOBJ = 8
154GOC = $(GOOBJ)g
155GOLINK = $(GOOBJ)l
156CLEANFILES += *.$(GOOBJ)
157.SUFFIXES: .$(GOOBJ) .go
43aab76c 158.go.$(GOOBJ):; $(call v_echo,GOC)$(GOC) $(GOFLAGS) $<
d888ccd5
MW
159
160LANGS += go
161SOURCES += go-fringe.go
162go-fringe: go-fringe.$(GOOBJ)
43aab76c 163 $(call v_echo,GOLD)$(GOLINK) -o $@ $^
d888ccd5
MW
164
165###--------------------------------------------------------------------------
2bd37ef1
MW
166### Smalltalk.
167
168LANGS += smalltalk
169TARGETS += smalltalk-fringe.im
8f12efe5 170SOURCES += smalltalk-fringe.st
2bd37ef1 171smalltalk-fringe.im: smalltalk-fringe.st
43aab76c
MW
172 $(call v_echo,GSTIM)echo "ObjectMemory snapshot: '$@.new'" | gst $^ -
173 $(V_HIDE)mv $@.new $@
2bd37ef1 174smalltalk-fringe:
43aab76c 175 $(call v_echo,GENSH){ echo '#! /bin/sh'; \
2bd37ef1
MW
176 echo '"exec" "gst" "-I" "$@.im" "-f" "$$0" "$$@"'; \
177 echo 'ObjectMemory quit: (Node main: Smalltalk arguments)'; \
178 } >$@.new
43aab76c 179 $(V_HIDE)chmod +x $@.new && mv $@.new $@
2bd37ef1
MW
180
181###----- That's all, folks --------------------------------------------------
182
183all:: $(TARGETS)