| 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 | SOURCES = |
| 17 | TARGETS = $(patsubst %,%-fringe,$(LANGS)) |
| 18 | CLEANFILES = $(TARGETS) |
| 19 | |
| 20 | all:: |
| 21 | clean::; rm -f $(CLEANFILES) |
| 22 | |
| 23 | ###-------------------------------------------------------------------------- |
| 24 | ### Testing. |
| 25 | |
| 26 | CLEANFILES += test.* |
| 27 | test:: all |
| 28 | @win=0 lose=0; \ |
| 29 | for lang in $(LANGS); do \ |
| 30 | echo >&3 "*** $$lang"; \ |
| 31 | printf "Test $$lang..."; \ |
| 32 | time=`command time -o/dev/stdout -f "%U user; %S system; %E" \ |
| 33 | ./test ./$${lang}-fringe 2>&3`; \ |
| 34 | if [ $$? -eq 0 ]; then \ |
| 35 | win=$$(expr $$win + 1); \ |
| 36 | printf " ok ($$time)\n"; \ |
| 37 | else \ |
| 38 | lose=$$(expr $$lose + 1); \ |
| 39 | printf " FAILED\n"; \ |
| 40 | fi; \ |
| 41 | done 3>test.log; \ |
| 42 | if [ $$lose -eq 0 ]; then \ |
| 43 | echo "All $$win test(s) OK"; \ |
| 44 | else \ |
| 45 | echo "FAILED $$lose test(s)!"; \ |
| 46 | exit 1; \ |
| 47 | fi |
| 48 | |
| 49 | ###-------------------------------------------------------------------------- |
| 50 | ### Reporting. |
| 51 | |
| 52 | report:: |
| 53 | wc -l $(SOURCES) | sort -n |
| 54 | |
| 55 | ###-------------------------------------------------------------------------- |
| 56 | ### C. |
| 57 | |
| 58 | CC = gcc |
| 59 | CFLAGS = -O2 -g -pedantic -Wall |
| 60 | CLEANFILES += *.o |
| 61 | .SUFFIXES: .c |
| 62 | .c.o:; $(CC) -c $(CFLAGS) -o $@ $< |
| 63 | |
| 64 | LANGS += c |
| 65 | SOURCES += c-fringe.c |
| 66 | c-fringe: c-fringe.o |
| 67 | $(CC) -o $@ $^ |
| 68 | |
| 69 | ###-------------------------------------------------------------------------- |
| 70 | ### Haskell. |
| 71 | |
| 72 | HC = ghc |
| 73 | HFLAGS = -O2 -XFlexibleInstances |
| 74 | CLEANFILES += *.hi *.hc |
| 75 | .SUFFIXES: .hs |
| 76 | .hs.o:; $(HC) -c $(HFLAGS) -o $@ $< |
| 77 | |
| 78 | LANGS += haskell |
| 79 | SOURCES += haskell-fringe.hs |
| 80 | haskell-fringe: haskell-fringe.o |
| 81 | $(HC) -o $@ $^ |
| 82 | |
| 83 | ###-------------------------------------------------------------------------- |
| 84 | ### Icon. |
| 85 | |
| 86 | ICONT = icont |
| 87 | IFLAGS = -u -fa |
| 88 | |
| 89 | LANGS += icon |
| 90 | SOURCES += icon-fringe.icn |
| 91 | icon-fringe: icon-fringe.icn |
| 92 | $(ICONT) -o $@ $^ |
| 93 | |
| 94 | ###-------------------------------------------------------------------------- |
| 95 | ### Common Lisp. |
| 96 | |
| 97 | CLEANFILES += *.core |
| 98 | |
| 99 | LANGS += cl |
| 100 | SOURCES += cl-fringe.lisp |
| 101 | cl-fringe: cl-fringe.lisp |
| 102 | ## cl-launch -R -o $@ -f `pwd`/$^ -- slow to start |
| 103 | cl-launch -o $@ -f `pwd`/$^ +I -r launch -d $@.core |
| 104 | |
| 105 | ###-------------------------------------------------------------------------- |
| 106 | ### F#. |
| 107 | |
| 108 | FSC = fsc |
| 109 | CLEANFILES += *.exe |
| 110 | .SUFFIXES: .fs .exe |
| 111 | .fs.exe:; fsc -o $@ $< |
| 112 | |
| 113 | LANGS += f\# |
| 114 | SOURCES += f\#-fringe.fs |
| 115 | f\#-fringe: f\#-fringe.exe |
| 116 | chmod +x $< |
| 117 | cp $< $@ |
| 118 | |
| 119 | ###-------------------------------------------------------------------------- |
| 120 | ### Scheme. |
| 121 | |
| 122 | SCMC = csc |
| 123 | SCMFLAGS = -c -O2 |
| 124 | .SUFFIXES: .scm .o |
| 125 | .scm.o:; $(SCMC) $(SCMFLAGS) -o $@ $< |
| 126 | |
| 127 | LANGS += scheme |
| 128 | SOURCES += scheme-fringe.scm |
| 129 | scheme-fringe: scheme-fringe.o |
| 130 | $(SCMC) -o $@ $^ |
| 131 | |
| 132 | ###-------------------------------------------------------------------------- |
| 133 | ### Smalltalk. |
| 134 | |
| 135 | LANGS += smalltalk |
| 136 | TARGETS += smalltalk-fringe.im |
| 137 | SOURCES += smalltalk-fringe.st |
| 138 | smalltalk-fringe.im: smalltalk-fringe.st |
| 139 | echo "ObjectMemory snapshot: '$@.new'" | gst $^ - |
| 140 | mv $@.new $@ |
| 141 | smalltalk-fringe: |
| 142 | { echo '#! /bin/sh'; \ |
| 143 | echo '"exec" "gst" "-I" "$@.im" "-f" "$$0" "$$@"'; \ |
| 144 | echo 'ObjectMemory quit: (Node main: Smalltalk arguments)'; \ |
| 145 | } >$@.new |
| 146 | chmod +x $@.new |
| 147 | mv $@.new $@ |
| 148 | |
| 149 | ###----- That's all, folks -------------------------------------------------- |
| 150 | |
| 151 | all:: $(TARGETS) |