algol68-fringe: New language.
[fringe] / Makefile
index aac2437..2c43ae8 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -13,6 +13,7 @@
 
 .SUFFIXES: .o
 LANGS                   =
+SOURCES                         =
 TARGETS                         = $(patsubst %,%-fringe,$(LANGS))
 CLEANFILES              = $(TARGETS)
 
@@ -20,112 +21,203 @@ 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...";                      \
-         if ./test ./$${lang}-fringe 2>&3; then        \
-           win=$$(expr $$win + 1);                     \
-           printf " ok\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;                                       \
+       @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:; $(CC) -c $(CFLAGS) -o $@ $<
+.c.o:; $(call v_echo,CC)$(CC) -c $(CFLAGS) -o $@ $<
 
 LANGS                  += c
+SOURCES                        += c-fringe.c
 c-fringe: c-fringe.o
-       $(CC) -o $@ $^
+       $(call v_echo,CCLD)$(CC) -o $@ $^
 
 ###--------------------------------------------------------------------------
 ### Haskell.
 
 HC                      = ghc
-HFLAGS                  = -O2 -XFlexibleInstances
+HFLAGS                  = -O2
 CLEANFILES             += *.hi *.hc
 .SUFFIXES: .hs
-.hs.o:; $(HC) -c $(HFLAGS) -o $@ $<
+.hs.o:; $(call v_echo,HC)$(HC) -c $(HFLAGS) -o $@ $<
 
 LANGS                  += haskell
+SOURCES                        += haskell-fringe.hs
 haskell-fringe: haskell-fringe.o
-       $(HC) -o $@ $^
+       $(call v_echo,HCLD)$(HC) -o $@ $^
 
 ###--------------------------------------------------------------------------
 ### Icon.
 
 ICONT                   = icont
-IFLAGS                  = -u -fa
+IFLAGS                  = -u -s -fa
 
 LANGS                  += icon
+SOURCES                        += icon-fringe.icn
 icon-fringe: icon-fringe.icn
-       $(ICONT) -o $@ $^
+       $(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
-cl-fringe: cl-fringe.lisp
-       cl-launch -R -o $@ -f `pwd`/$^
+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                     = fsc
+FSCFLAGS                =
 CLEANFILES             += *.exe
 .SUFFIXES: .fs .exe
-.fs.exe:; fsc -o $@ $<
+.fs.exe:; $(call v_echo,FSC)$(FSC) --nologo $(FSCFLAGS) -o $@ $<
 
 LANGS                  += f\#
+SOURCES                        += f\#-fringe.fs
 f\#-fringe: f\#-fringe.exe
-       chmod +x $<
-       cp $< $@
+       $(call v_echo,CP)chmod +x $< && cp $< $@
 
 ###--------------------------------------------------------------------------
 ### Scheme.
 
 SCMC                    = csc
 SCMFLAGS                = -c -O2 
-.SUFFIXES: .scm .o
-.scm.o:; $(SCMC) $(SCMFLAGS) -o $@ $<
+.SUFFIXES: .scm
+.scm.o:; $(call v_echo,SCMC)$(SCMC) $(SCMFLAGS) -o $@ $<
 
 LANGS                  += scheme
+SOURCES                        += scheme-fringe.scm
 scheme-fringe: scheme-fringe.o
-       $(SCMC) -o $@ $^
+       $(call v_echo,SCMLD)$(SCMC) -o $@ $^
+
+###--------------------------------------------------------------------------
+### Go.
+
+GOOBJ                   = 8
+GOC                     = $(GOOBJ)g
+GOLINK                  = $(GOOBJ)l
+CLEANFILES             += *.$(GOOBJ)
+.SUFFIXES: .$(GOOBJ) .go
+.go.$(GOOBJ):; $(call v_echo,GOC)$(GOC) $(GOFLAGS) $<
+
+LANGS                  += go
+SOURCES                        += go-fringe.go
+go-fringe: go-fringe.$(GOOBJ)
+       $(call v_echo,GOLD)$(GOLINK) -o $@ $^
 
 ###--------------------------------------------------------------------------
 ### Smalltalk.
 
 LANGS                  += smalltalk
 TARGETS                        += smalltalk-fringe.im
+SOURCES                        += smalltalk-fringe.st
 smalltalk-fringe.im: smalltalk-fringe.st
-       echo "ObjectMemory snapshot: '$@.new'" | gst $^ -
-       mv $@.new $@
+       $(call v_echo,GSTIM)echo "ObjectMemory snapshot: '$@.new'" | gst $^ -
+       $(V_HIDE)mv $@.new $@
 smalltalk-fringe:
-       { echo '#! /bin/sh';                                            \
+       $(call v_echo,GENSH){ echo '#! /bin/sh';                        \
          echo '"exec" "gst" "-I" "$@.im" "-f" "$$0" "$$@"';            \
          echo 'ObjectMemory quit: (Node main: Smalltalk arguments)';   \
        } >$@.new
-       chmod +x $@.new
-       mv $@.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 $@
 
 ###----- That's all, folks --------------------------------------------------