2 # Tiny C Compiler Makefile - tests
6 include $(TOP
)/Makefile
7 VPATH
= $(top_srcdir
)/tests
17 # test4 -- problem with -static
18 # asmtest -- minor differences with gcc
19 # btest -- works on i386 (including win32)
20 # test3 -- win32 does not know how to printf long doubles
22 # bounds-checking is supported only on i386
24 TESTS
:= $(filter-out btest
,$(TESTS
))
27 TESTS
:= $(filter-out test3
,$(TESTS
))
29 ifeq ($(TARGETOS
),Darwin
)
30 TESTS
:= $(filter-out hello-exe test3 btest
,$(TESTS
))
34 export LD_LIBRARY_PATH
:=$(CURDIR
)/..
37 ifeq ($(TARGETOS
),Darwin
)
38 CFLAGS
+=-Wl
,-flat_namespace
,-undefined
,warning
39 export MACOSX_DEPLOYMENT_TARGET
:=10.2
40 NATIVE_DEFINES
+=-D_ANSI_SOURCE
43 # run local version of tcc with local libraries and includes
46 TCCFLAGS
= -B
$(top_srcdir
)/win32
-I
$(top_srcdir
)/include -L
$(TOP
)
49 TCC
= $(TOP
)/tcc
$(TCCFLAGS
)
50 RUN_TCC
= $(NATIVE_DEFINES
) -DONE_SOURCE
-run
$(TOP
)/tcc.c
$(TCCFLAGS
)
56 LIBTCC1
:=$(TOP
)/$(LIBTCC1
)
61 hello-exe
: ..
/examples
/ex1.c
62 @echo
------------ $@
------------
63 $(TCC
) $< -o hello
$(EXESUF
) ||
($(TOP
)/tcc
-vv
; exit
1) && .
/hello
$(EXESUF
)
65 hello-run
: ..
/examples
/ex1.c
66 @echo
------------ $@
------------
69 libtest
: libtcc_test
$(EXESUF
) $(LIBTCC1
)
70 @echo
------------ $@
------------
71 .
/libtcc_test
$(EXESUF
) lib_path
=..
73 libtcc_test
$(EXESUF
): libtcc_test.c
$(top_builddir
)/$(LIBTCC
)
74 $(CC
) -o
$@
$^
$(CPPFLAGS
) $(CFLAGS
) $(NATIVE_DEFINES
) $(LIBS
) $(LINK_LIBTCC
) $(LDFLAGS
)
77 @echo
------------ $@
------------
80 # test.ref - generate using gcc
81 # copy only tcclib.h so GCC's stddef and stdarg will be used
83 cp ..
/include/tcclib.h .
84 gcc
-o tcctest.gcc
$< -I.
$(CPPFLAGS
) -w
$(CFLAGS
) $(NATIVE_DEFINES
) -std
=gnu99
-O0
-fno-omit-frame-pointer
$(LDFLAGS
)
89 @echo
------------ $@
------------
90 $(TCC
) -run tcctest.c
> test.out1
91 @if diff
-u
test.ref
test.out1
; then echo
"Auto Test OK"; fi
93 # iterated test2 (compile tcc then compile tcctest.c !)
95 @echo
------------ $@
------------
96 $(TCC
) $(RUN_TCC
) $(RUN_TCC
) -run tcctest.c
> test.out2
97 @if diff
-u
test.ref
test.out2
; then echo
"Auto Test2 OK"; fi
99 # iterated test3 (compile tcc then compile tcc then compile tcctest.c !)
101 @echo
------------ $@
------------
102 $(TCC
) $(RUN_TCC
) $(RUN_TCC
) $(RUN_TCC
) -run tcctest.c
> test.out3
103 @if diff
-u
test.ref
test.out3
; then echo
"Auto Test3 OK"; fi
107 @echo
------------ $@
------------
108 # object + link output
109 $(TCC
) -c
-o tcctest3.o tcctest.c
110 $(TCC
) -o tcctest3 tcctest3.o
111 .
/tcctest3
> test3.out
112 @if diff
-u
test.ref test3.out
; then echo
"Object Auto Test OK"; fi
114 $(TCC
) -o tcctest1 tcctest.c
115 .
/tcctest1
> test1.out
116 @if diff
-u
test.ref test1.out
; then echo
"Dynamic Auto Test OK"; fi
117 # dynamic output + bound check
118 $(TCC
) -b
-o tcctest4 tcctest.c
119 .
/tcctest4
> test4.out
120 @if diff
-u
test.ref test4.out
; then echo
"BCheck Auto Test OK"; fi
122 $(TCC
) -static
-o tcctest2 tcctest.c
123 .
/tcctest2
> test2.out
124 @if diff
-u
test.ref test2.out
; then echo
"Static Auto Test OK"; fi
126 # memory and bound check auto test
127 BOUNDS_OK
= 1 4 8 10 14
128 BOUNDS_FAIL
= 2 5 7 9 11 12 13 15
131 @echo
------------ $@
------------
132 @for i in
$(BOUNDS_OK
); do \
133 echo
; echo
--- boundtest
$$i ---; \
134 if
$(TCC
) -b
-run boundtest.c
$$i ; then \
135 echo succeded
as expected
; \
137 echo Failed positive
test $$i ; exit
1 ; \
140 for i in
$(BOUNDS_FAIL
); do \
141 echo
; echo
--- boundtest
$$i ---; \
142 if
$(TCC
) -b
-run boundtest.c
$$i ; then \
143 echo Failed negative
test $$i ; exit
1 ;\
145 echo failed
as expected
; \
148 echo
; echo Bound
test OK
152 @echo
------------ $@
------------
153 time .
/ex2
1238 2 3 4 10 13 4
154 time
$(TCC
) -run
$(top_srcdir
)/examples
/ex2.c
1238 2 3 4 10 13 4
156 time
$(TCC
) -run
$(top_srcdir
)/examples
/ex3.c
35
159 $(TCC
) -c tcctest.c
-o weaktest.tcc.o
$(CPPFLAGS
) $(CFLAGS
)
160 $(CC
) -c tcctest.c
-o weaktest.gcc.o
-I.
$(CPPFLAGS
) -w
$(CFLAGS
)
161 objdump
-t weaktest.tcc.o | grep
' w ' | sed
-e
's/.* \([a-zA-Z0-9_]*\)$$/\1/' | LC_ALL
=C
sort > weaktest.tcc.o.txt
162 objdump
-t weaktest.gcc.o | grep
' w ' | sed
-e
's/.* \([a-zA-Z0-9_]*\)$$/\1/' | LC_ALL
=C
sort > weaktest.gcc.o.txt
163 diff weaktest.gcc.o.txt weaktest.tcc.o.txt
&& echo
"Weak Auto Test OK"
165 ex
%: $(top_srcdir
)/examples
/ex
%.c
166 $(CC
) -o
$@
$< $(CPPFLAGS
) $(CFLAGS
) $(LDFLAGS
)
168 # tiny assembler testing
169 asmtest.ref
: asmtest.S
170 $(CC
) -Wa
,-W
-o asmtest.ref.o
-c asmtest.S
171 objdump
-D asmtest.ref.o
> asmtest.ref
174 @echo
------------ $@
------------
176 objdump
-D asmtest.o
> asmtest.out
177 @if diff
-u
--ignore-matching-lines
="file format" asmtest.ref asmtest.out
; then echo
"ASM Auto Test OK"; fi
179 # targets for development
188 $(CC
) -o
$@
-c
$< -O2
-Wall
-g
191 cachegrind .
/tcc_g
-o
/tmp
/linpack
-lm bench
/linpack.c
192 vg_annotate tcc.c
> /tmp
/linpack.cache.log
197 rm -vf
*~
*.o
*.a
*.bin
*.i
*.ref
*.out
*.out?
*.out?b
*.gcc
*.exe \
198 hello libtcc_test tcctest
[1234] ex? tcc_g tcclib.h