### Makefile for same-fringe implementations. ###-------------------------------------------------------------------------- ### Notes about organization. ### ### Most projects have lots of stuff in just a few languages, so it makes ### sense to put the language configuration in one place. This one's ### different. Its entire purpose is to demonstrate lots of different ### approaches. ### ### So, at the top we declare the main targets; then each language has its ### configuration and build rules. .SUFFIXES: .o LANGS = SOURCES = TARGETS = $(patsubst %,%-fringe,$(LANGS)) CLEANFILES = $(TARGETS) all:: clean::; rm -f $(CLEANFILES) ###-------------------------------------------------------------------------- ### Silent rules stuff. ## Default verbosity setting. V = 0 ## Infrastructure. v_echo = $(call v_echo_$V,$1) v_echo_1 = v_echo_0 = @printf " %-6s %s\n" "$1" "$@"; V_HIDE = $(V_HIDE_$V) V_HIDE_0 = @ ###-------------------------------------------------------------------------- ### Testing. CLEANFILES += test.* test:: all @win=0 lose=0; \ for lang in $(LANGS); do \ echo >&3 "*** $$lang"; \ printf "Test $$lang..."; \ time=`command time -o/dev/stdout -f "%U user; %S system; %E" \ ./test ./$${lang}-fringe 2>&3`; \ if [ $$? -eq 0 ]; then \ win=$$(expr $$win + 1); \ printf " ok ($$time)\n"; \ else \ lose=$$(expr $$lose + 1); \ printf " FAILED\n"; \ fi; \ done 3>test.log; \ if [ $$lose -eq 0 ]; then \ echo "All $$win test(s) OK"; \ else \ echo "FAILED $$lose test(s)!"; \ exit 1; \ fi ###-------------------------------------------------------------------------- ### Reporting. report:: wc -l $(SOURCES) | sort -n ###-------------------------------------------------------------------------- ### C. CC = gcc CFLAGS = -O2 -g -pedantic -Wall CLEANFILES += *.o .SUFFIXES: .c .c.o:; $(call v_echo,CC)$(CC) -c $(CFLAGS) -o $@ $< LANGS += c SOURCES += c-fringe.c c-fringe: c-fringe.o $(call v_echo,CCLD)$(CC) -o $@ $^ ###-------------------------------------------------------------------------- ### Haskell. HC = ghc HFLAGS = -O2 CLEANFILES += *.hi *.hc .SUFFIXES: .hs .hs.o:; $(call v_echo,HC)$(HC) -c $(HFLAGS) -o $@ $< LANGS += haskell SOURCES += haskell-fringe.hs haskell-fringe: haskell-fringe.o $(call v_echo,HCLD)$(HC) -o $@ $^ ###-------------------------------------------------------------------------- ### Icon. ICONT = icont IFLAGS = -u -s -fa LANGS += icon SOURCES += icon-fringe.icn icon-fringe: icon-fringe.icn $(call v_echo,ICONT)$(ICONT) $(IFLAGS) -o $@ $^ ###-------------------------------------------------------------------------- ### Common Lisp. CLEANFILES += *.core *.fasl .SUFFIXES: .lisp .fasl .lisp.fasl: $(call v_echo,CL)sbcl --noinform --eval \ '(quit :unix-status (if (compile-file "$<" :verbose nil :print nil) 0 1))' LANGS += cl SOURCES += cl-fringe.lisp cl-fringe: cl-fringe.fasl $(call v_echo,CP)cp $< $@.new && chmod +x $@.new && mv $@.new $@ ## $(call v_echo,CL)cl-launch -o $@ -f `pwd`/$^ +I -r launch -d $@.core ###-------------------------------------------------------------------------- ### F#. FSC = fsharpc FSCFLAGS = CLEANFILES += *.exe .SUFFIXES: .fs .exe .fs.exe:; $(call v_echo,FSC)$(FSC) --nologo $(FSCFLAGS) -o $@ $< LANGS += f\# SOURCES += f\#-fringe.fs f\#-fringe: f\#-fringe.exe $(call v_echo,CP)chmod +x $< && cp $< $@ ###-------------------------------------------------------------------------- ### Scheme. SCMC = csc SCMFLAGS = -c -O2 .SUFFIXES: .scm .scm.o:; $(call v_echo,SCMC)$(SCMC) $(SCMFLAGS) -o $@ $< LANGS += scheme SOURCES += scheme-fringe.scm scheme-fringe: scheme-fringe.o $(call v_echo,SCMLD)$(SCMC) -o $@ $^ ###-------------------------------------------------------------------------- ### Go. GOBUILD = go build LANGS += go SOURCES += go-fringe.go go-fringe: go-fringe.go $(call v_echo,GO)$(GOBUILD) -o $@ $^ ###-------------------------------------------------------------------------- ### Smalltalk. LANGS += smalltalk TARGETS += smalltalk-fringe.im SOURCES += smalltalk-fringe.st smalltalk-fringe.im: smalltalk-fringe.st $(call v_echo,GSTIM)echo "ObjectMemory snapshot: '$@.new'" | gst $^ - $(V_HIDE)mv $@.new $@ smalltalk-fringe: $(call v_echo,GENSH){ echo '#! /bin/sh'; \ echo '"exec" "gst" "-I" "$@.im" "-f" "$$0" "$$@"'; \ echo 'ObjectMemory quit: (Node main: Smalltalk arguments)'; \ } >$@.new $(V_HIDE)chmod +x $@.new && mv $@.new $@ ###-------------------------------------------------------------------------- ### Forth. LANGS += forth TARGETS += forth-fringe SOURCES += forth-fringe.fth forth-fringe: forth-fringe.fth $(call v_echo,FORTHI)gforthmi $@ $< ###-------------------------------------------------------------------------- ### Erlang. ERLC = erlc CLEANFILES += *.beam erl_crash.dump .SUFFIXES: .erl .beam .erl.beam:; $(call v_echo,ERLC)$(ERLC) $(ERLCFLAGS) $< LANGS += erlang TARGETS += erlang-fringe.beam SOURCES += erlang-fringe.erl erlang-fringe: $(call v_echo,GENSH){ echo '#! /bin/sh'; \ echo 'exec erl -pa . -noshell -run erlang-fringe main -extra "$$@"'; \ } >$@.new $(V_HIDE)chmod +x $@.new && mv $@.new $@ ###-------------------------------------------------------------------------- ### Algol 68. ALGOL68 = /usr/local/bin/a68g LANGS += algol68 TARGETS += algol68-fringe SOURCES += algol68-fringe.a68 algol68-fringe: algol68-fringe.a68 $(call v_echo,GENSH){ echo '#! $(ALGOL68) --script'; \ cat $<; \ } >$@.new $(V_HIDE)chmod +x $@.new && mv $@.new $@ ###-------------------------------------------------------------------------- ### Dylan. D2C = d2c CLEANFILES += dylan-*.c *.mak LANGS += dylan TARGETS += dylan-fringe SOURCES += dylan-fringe.dylan dylan-fringe-exports.dylan SOURCES += dylan-fringe.lid dylan-fringe: dylan-fringe.lid dylan-fringe.dylan dylan-fringe-exports.dylan $(call v_echo,D2C)d2c -g $< ###----- That's all, folks -------------------------------------------------- all:: $(TARGETS)