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
= $(NATIVE_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 cp
-u ..
/include/tcclib.h .
41 $(CC
) -o tcctest.gcc
$< -I.
-w
$(CFLAGS
)
46 @echo
------------ $@
------------
47 $(TCC
) -run tcctest.c
> test.out1
48 @if diff
-u
test.ref
test.out1
; then echo
"Auto Test OK"; fi
50 # iterated test2 (compile tcc then compile tcctest.c !)
52 @echo
------------ $@
------------
53 $(TCC
) $(RUN_TCC
) $(RUN_TCC
) -run tcctest.c
> test.out2
54 @if diff
-u
test.ref
test.out2
; then echo
"Auto Test2 OK"; fi
56 # iterated test3 (compile tcc then compile tcc then compile tcctest.c !)
58 @echo
------------ $@
------------
59 $(TCC
) $(RUN_TCC
) $(RUN_TCC
) $(RUN_TCC
) -run tcctest.c
> test.out3
60 @if diff
-u
test.ref
test.out3
; then echo
"Auto Test3 OK"; fi
64 @echo
------------ $@
------------
66 $(TCC
) -o tcctest1 tcctest.c
67 .
/tcctest1
> test1.out
68 @if diff
-u
test.ref test1.out
; then echo
"Dynamic Auto Test OK"; fi
69 # object + link output
70 $(TCC
) -c
-o tcctest3.o tcctest.c
71 $(TCC
) -o tcctest3 tcctest3.o
72 .
/tcctest3
> test3.out
73 @if diff
-u
test.ref test3.out
; then echo
"Object Auto Test OK"; fi
75 $(TCC
) -static
-o tcctest2 tcctest.c
76 .
/tcctest2
> test2.out
77 @if diff
-u
test.ref test2.out
; then echo
"Static Auto Test OK"; fi
78 # dynamic output + bound check
79 $(TCC
) -b
-o tcctest4 tcctest.c
80 .
/tcctest4
> test4.out
81 @if diff
-u
test.ref test4.out
; then echo
"BCheck Auto Test OK"; fi
83 # memory and bound check auto test
85 BOUNDS_FAIL
= 2 5 7 9 11 12 13
88 @echo
------------ $@
------------
89 @for i in
$(BOUNDS_OK
); do \
90 if
$(TCC
) -b
-run boundtest.c
$$i ; then \
93 echo Failed positive
test $$i ; exit
1 ; \
96 for i in
$(BOUNDS_FAIL
); do \
97 if
$(TCC
) -b
-run boundtest.c
$$i ; then \
98 echo Failed negative
test $$i ; exit
1 ;\
107 @echo
------------ $@
------------
108 time .
/ex2
1238 2 3 4 10 13 4
109 time
$(TCC
) -run ..
/examples
/ex2.c
1238 2 3 4 10 13 4
111 time
$(TCC
) -run ..
/examples
/ex3.c
35
113 ex
%: ..
/examples
/ex
%.c
114 $(CC
) -o
$@
$< $(CFLAGS
)
116 # tiny assembler testing
117 asmtest.ref
: asmtest.S
118 $(CC
) -o asmtest.ref.o
-c asmtest.S
119 objdump
-D asmtest.ref.o
> $@
122 @echo
------------ $@
------------
124 objdump
-D asmtest.o
> $@
125 @if diff
-u
--ignore-matching-lines
="file format" asmtest.ref asmtest.out
; then echo
"ASM Auto Test OK"; fi
127 # targets for development
136 $(CC
) -o
$@
-c
$< -O2
-Wall
-g
139 cachegrind .
/tcc_g
-o
/tmp
/linpack
-lm bench
/linpack.c
140 vg_annotate tcc.c
> /tmp
/linpack.cache.log
144 rm -vf
*~
*.o
*.a
*.bin
*.i
*.ref
*.out
*.out?
*.gcc \
145 tcctest
[1234] ex? libtcc_test
$(EXESUF
) tcc_g tcclib.h