2 # Tiny C Compiler Makefile - tests
8 # these should work too
9 # TESTS += test1 test2 speed
11 # these don't work as they should
12 # TESTS += test4 btest asmtest
16 include $(TOP
)/Makefile
18 # run local version of tcc with local libraries and includes
20 RUN_TCC
= $(TARGET
) -run ..
/tcc.c
-B..
25 # make sure that tcc exists
31 libtest
: libtcc_test
$(EXESUF
)
32 @echo
------------ $@
------------
33 .
/libtcc_test lib_path
=..
35 libtcc_test
$(EXESUF
): libtcc_test.c ..
/libtcc.a
36 $(CC
) -o
$@
$^
-I..
$(CFLAGS
) $(LIBS
)
38 # test.ref - generate using gcc
40 $(CC
) -o tcctest.gcc
$< -w
-I..
-I..
/include $(CFLAGS
)
45 @echo
------------ $@
------------
46 $(TCC
) -run tcctest.c
> test.out1
47 @if diff
-u
test.ref
test.out1
; then echo
"Auto Test OK"; fi
49 # iterated test2 (compile tcc then compile tcctest.c !)
51 @echo
------------ $@
------------
52 $(TCC
) $(RUN_TCC
) $(RUN_TCC
) -run tcctest.c
> test.out2
53 @if diff
-u
test.ref
test.out2
; then echo
"Auto Test2 OK"; fi
55 # iterated test3 (compile tcc then compile tcc then compile tcctest.c !)
57 @echo
------------ $@
------------
58 $(TCC
) $(RUN_TCC
) $(RUN_TCC
) $(RUN_TCC
) -run tcctest.c
> test.out3
59 @if diff
-u
test.ref
test.out3
; then echo
"Auto Test3 OK"; fi
63 @echo
------------ $@
------------
65 $(TCC
) -o tcctest1 tcctest.c
66 .
/tcctest1
> test1.out
67 @if diff
-u
test.ref test1.out
; then echo
"Dynamic Auto Test OK"; fi
68 # object + link output
69 $(TCC
) -c
-o tcctest3.o tcctest.c
70 $(TCC
) -o tcctest3 tcctest3.o
71 .
/tcctest3
> test3.out
72 @if diff
-u
test.ref test3.out
; then echo
"Object Auto Test OK"; fi
74 $(TCC
) -static
-o tcctest2 tcctest.c
75 .
/tcctest2
> test2.out
76 @if diff
-u
test.ref test2.out
; then echo
"Static Auto Test OK"; fi
77 # dynamic output + bound check
78 $(TCC
) -b
-o tcctest4 tcctest.c
79 .
/tcctest4
> test4.out
80 @if diff
-u
test.ref test4.out
; then echo
"BCheck Auto Test OK"; fi
82 # memory and bound check auto test
84 BOUNDS_FAIL
= 2 5 7 9 11 12 13
87 @echo
------------ $@
------------
88 @for i in
$(BOUNDS_OK
); do \
89 if
$(TCC
) -b
-run boundtest.c
$$i ; then \
92 echo Failed positive
test $$i ; exit
1 ; \
95 for i in
$(BOUNDS_FAIL
); do \
96 if
$(TCC
) -b
-run boundtest.c
$$i ; then \
97 echo Failed negative
test $$i ; exit
1 ;\
106 @echo
------------ $@
------------
107 time .
/ex2
1238 2 3 4 10 13 4
108 time
$(TCC
) -run ..
/examples
/ex2.c
1238 2 3 4 10 13 4
110 time
$(TCC
) -run ..
/examples
/ex3.c
35
112 ex
%: ..
/examples
/ex
%.c
113 $(CC
) -o
$@
$< $(CFLAGS
)
115 # tiny assembler testing
116 asmtest.ref
: asmtest.S
117 $(CC
) -o asmtest.ref.o
-c asmtest.S
118 objdump
-D asmtest.ref.o
> $@
121 @echo
------------ $@
------------
123 objdump
-D asmtest.o
> $@
124 @if diff
-u
--ignore-matching-lines
="file format" asmtest.ref asmtest.out
; then echo
"ASM Auto Test OK"; fi
126 # targets for development
135 $(CC
) -o
$@
-c
$< -O2
-Wall
-g
138 cachegrind .
/tcc_g
-o
/tmp
/linpack
-lm bench
/linpack.c
139 vg_annotate tcc.c
> /tmp
/linpack.cache.log
143 rm -vf
*~
*.o
*.a
*.bin
*.i
*.ref
*.out
*.out?
*.gcc \
144 tcctest
[1234] ex? libtcc_test tcc_g