Unified · Split
| @@ -3,15 +3,15 @@ · 2 unmodified lines | |||
| 3 | # | 3 | # |
| 4 | prefix=/usr/local | 4 | prefix=/usr/local |
| 5 | 5 | ||
| 6 | CFLAGS=-O2 -g -Wall -Wno-parentheses -Wno-missing-braces -I. | 6 | CFLAGS=-O2 -g -Wall |
| 7 | LIBS=-ldl | 7 | LIBS=-ldl |
| 8 | CFLAGS_P=$(CFLAGS) -pg -static -DCONFIG_TCC_STATIC | 8 | CFLAGS_P=$(CFLAGS) -pg -static -DCONFIG_TCC_STATIC |
| 9 | LIBS_P= | 9 | LIBS_P= |
| 10 | 10 | ||
| 11 | CFLAGS+=-m386 -malign-functions=0 | 11 | CFLAGS+=-m386 -malign-functions=0 |
| 12 | DISAS=objdump -D -b binary -m i386 | 12 | DISAS=objdump -d |
| 13 | INSTALL=install | 13 | INSTALL=install |
| 14 | VERSION=0.9.2 | 14 | VERSION=0.9.3 |
| 15 | 15 | ||
| 16 | all: tcc | 16 | all: tcc |
| 17 | 17 | ||
| @@ -20,28 +20,49 @@ all: tcc · 2 unmodified lines | |||
| 20 | test: test.ref test.out | 20 | test: test.ref test.out |
| 21 | @if diff -u test.ref test.out ; then echo "Auto Test OK"; fi | 21 | @if diff -u test.ref test.out ; then echo "Auto Test OK"; fi |
| 22 | 22 | ||
| 23 | prog.ref: prog.c | 23 | tcctest.ref: tcctest.c |
| 24 | gcc3 $(CFLAGS) -o $@ $< | 24 | gcc $(CFLAGS) -I. -o $@ $< |
| 25 | 25 | ||
| 26 | test.ref: prog.ref | 26 | test.ref: tcctest.ref |
| 27 | ./prog.ref > $@ | 27 | ./tcctest.ref > $@ |
| 28 | 28 | ||
| 29 | test.out: tcc prog.c | 29 | test.out: tcc tcctest.c |
| 30 | ./tcc -I. prog.c > $@ | 30 | ./tcc -I. tcctest.c > $@ |
| 31 | 31 | ||
| 32 | run: tcc prog.c | 32 | run: tcc tcctest.c |
| 33 | ./tcc -I. prog.c | 33 | ./tcc -I. tcctest.c |
| 34 | 34 | ||
| 35 | # iterated test2 (compile tcc then compile prog.c !) | 35 | # iterated test2 (compile tcc then compile tcctest.c !) |
| 36 | test2: tcc tcc.c prog.c test.ref | 36 | test2: tcc tcc.c tcctest.c test.ref |
| 37 | ./tcc -I. tcc.c -I. prog.c > test.out2 | 37 | ./tcc -I. tcc.c -I. tcctest.c > test.out2 |
| 38 | @if diff -u test.ref test.out2 ; then echo "Auto Test2 OK"; fi | 38 | @if diff -u test.ref test.out2 ; then echo "Auto Test2 OK"; fi |
| 39 | 39 | ||
| 40 | # iterated test3 (compile tcc then compile tcc then compile prog.c !) | 40 | # iterated test3 (compile tcc then compile tcc then compile tcctest.c !) |
| 41 | test3: tcc tcc.c prog.c test.ref | 41 | test3: tcc tcc.c tcctest.c test.ref |
| 42 | ./tcc -I. tcc.c -I. tcc.c -I. prog.c > test.out3 | 42 | ./tcc -I. tcc.c -I. tcc.c -I. tcctest.c > test.out3 |
| 43 | @if diff -u test.ref test.out3 ; then echo "Auto Test3 OK"; fi | 43 | @if diff -u test.ref test.out3 ; then echo "Auto Test3 OK"; fi |
| 44 | 44 | ||
| 45 | # memory and bound check auto test | ||
| 46 | BOUNDS_OK = 1 4 8 10 | ||
| 47 | BOUNDS_FAIL= 2 5 7 9 11 12 | ||
| 48 | |||
| 49 | btest: boundtest.c tcc | ||
| 50 | @for i in $(BOUNDS_OK); do \ | ||
| 51 | if ./tcc -b boundtest.c $$i ; then \ | ||
| 52 | /bin/true ; \ | ||
| 53 | else\ | ||
| 54 | echo Failed positive test $$i ; exit 1 ; \ | ||
| 55 | fi ;\ | ||
| 56 | done ;\ | ||
| 57 | for i in $(BOUNDS_FAIL); do \ | ||
| 58 | if ./tcc -b boundtest.c $$i ; then \ | ||
| 59 | echo Failed negative test $$i ; exit 1 ;\ | ||
| 60 | else\ | ||
| 61 | /bin/true ; \ | ||
| 62 | fi\ | ||
| 63 | done ;\ | ||
| 64 | echo Bound test OK | ||
| 65 | |||
| 45 | # speed test | 66 | # speed test |
| 46 | speed: tcc ex2 ex3 | 67 | speed: tcc ex2 ex3 |
| 47 | time ./ex2 1238 2 3 4 10 13 4 | 68 | time ./ex2 1238 2 3 4 10 13 4 |
| @@ -57,7 +78,7 @@ ex3: ex3.c · 9 unmodified lines | |||
| 57 | 78 | ||
| 58 | # Tiny C Compiler | 79 | # Tiny C Compiler |
| 59 | 80 | ||
| 60 | tcc_g: tcc.c i386-gen.c Makefile | 81 | tcc_g: tcc.c i386-gen.c bcheck.c Makefile |
| 61 | gcc $(CFLAGS) -o $@ $< $(LIBS) | 82 | gcc $(CFLAGS) -o $@ $< $(LIBS) |
| 62 | 83 | ||
| 63 | tcc: tcc_g | 84 | tcc: tcc_g |
| @@ -66,20 +87,21 @@ tcc: tcc_g · 2 unmodified lines | |||
| 66 | install: tcc | 87 | install: tcc |
| 67 | $(INSTALL) -m755 tcc $(prefix)/bin | 88 | $(INSTALL) -m755 tcc $(prefix)/bin |
| 68 | mkdir -p $(prefix)/lib/tcc | 89 | mkdir -p $(prefix)/lib/tcc |
| 69 | $(INSTALL) -m644 stdarg.h stddef.h float.h tcclib.h $(prefix)/lib/tcc | 90 | $(INSTALL) -m644 stdarg.h stddef.h float.h stdbool.h \ |
| 91 | tcclib.h $(prefix)/lib/tcc | ||
| 70 | 92 | ||
| 71 | clean: | 93 | clean: |
| 72 | rm -f *~ *.o tcc tcc1 tcct tcc_g prog.ref *.bin *.i ex2 \ | 94 | rm -f *~ *.o tcc tcc1 tcct tcc_g tcctest.ref *.bin *.i ex2 \ |
| 73 | core gmon.out test.out test.ref a.out tcc_p | 95 | core gmon.out test.out test.ref a.out tcc_p |
| 74 | 96 | ||
| 75 | # profiling version | 97 | # profiling version |
| 76 | tcc_p: tcc.c Makefile | 98 | tcc_p: tcc.c Makefile |
| 77 | gcc $(CFLAGS_P) -o $@ $< $(LIBS_P) | 99 | gcc $(CFLAGS_P) -o $@ $< $(LIBS_P) |
| 78 | 100 | ||
| 79 | # target for development | 101 | # targets for development |
| 80 | 102 | ||
| 81 | %.bin: %.c tcc | 103 | %.bin: %.c tcc |
| 82 | ./tcc -o $@ -I. $< | 104 | ./tcc -g -o $@ -I. $< |
| 83 | $(DISAS) $@ | 105 | $(DISAS) $@ |
| 84 | 106 | ||
| 85 | instr: instr.o | 107 | instr: instr.o |
| @@ -96,8 +118,8 @@ tar: · 10 unmodified lines | |||
| 96 | ( cd /tmp ; tar zcvf ~/$(FILE).tar.gz \ | 118 | ( cd /tmp ; tar zcvf ~/$(FILE).tar.gz \ |
| 97 | $(FILE)/Makefile $(FILE)/README $(FILE)/TODO $(FILE)/COPYING \ | 119 | $(FILE)/Makefile $(FILE)/README $(FILE)/TODO $(FILE)/COPYING \ |
| 98 | $(FILE)/Changelog $(FILE)/tcc-doc.html \ | 120 | $(FILE)/Changelog $(FILE)/tcc-doc.html \ |
| 99 | $(FILE)/tcc.c $(FILE)/i386-gen.c \ | 121 | $(FILE)/tcc.c $(FILE)/i386-gen.c $(FILE)/bcheck.c \ |
| 100 | $(FILE)/stddef.h $(FILE)/stdarg.h $(FILE)/stdbool.h $(FILE)/float.h \ | 122 | $(FILE)/stddef.h $(FILE)/stdarg.h $(FILE)/stdbool.h $(FILE)/float.h \ |
| 101 | $(FILE)/tcclib.h \ | 123 | $(FILE)/tcclib.h \ |
| 102 | $(FILE)/ex*.c $(FILE)/prog.c ) | 124 | $(FILE)/ex*.c $(FILE)/tcctest.c $(FILE)/boundtest.c ) |
| 103 | rm -rf /tmp/$(FILE) | 125 | rm -rf /tmp/$(FILE) |