gcc 3 tests activated - new tests for 0.9.17
[tinycc.git] / Makefile
blobdfae33c8e19fc8750b29864740672a87b600e10e
2 # Tiny C Compiler Makefile
4 include config.mak
6 CFLAGS=-O2 -g -Wall
7 LIBS=-ldl
8 CFLAGS_P=$(CFLAGS) -pg -static -DCONFIG_TCC_STATIC
9 LIBS_P=
11 CFLAGS+=-mpreferred-stack-boundary=2
12 ifeq ($(GCC_MAJOR),2)
13 CFLAGS+=-m386 -malign-functions=0
14 else
15 CFLAGS+=-march=i386 -falign-functions=0
16 endif
19 DISAS=objdump -d
20 INSTALL=install
22 # run local version of tcc with local libraries and includes
23 TCC=./tcc -B. -I.
25 all: tcc libtcc1.o bcheck.o tcc-doc.html libtcc.a libtcc_test
27 Makefile: config.mak
29 # auto test
31 test: test.ref test.out
32 @if diff -u test.ref test.out ; then echo "Auto Test OK"; fi
34 tcctest.ref: tcctest.c
35 $(CC) $(CFLAGS) -I. -o $@ $<
37 test.ref: tcctest.ref
38 ./tcctest.ref > $@
40 test.out: tcc tcctest.c
41 $(TCC) tcctest.c > $@
43 run: tcc tcctest.c
44 $(TCC) tcctest.c
46 # iterated test2 (compile tcc then compile tcctest.c !)
47 test2: tcc tcc.c tcctest.c test.ref
48 $(TCC) tcc.c -B. -I. tcctest.c > test.out2
49 @if diff -u test.ref test.out2 ; then echo "Auto Test2 OK"; fi
51 # iterated test3 (compile tcc then compile tcc then compile tcctest.c !)
52 test3: tcc tcc.c tcctest.c test.ref
53 $(TCC) tcc.c -B. -I. tcc.c -B. -I. tcctest.c > test.out3
54 @if diff -u test.ref test.out3 ; then echo "Auto Test3 OK"; fi
56 # binary output test
57 test4: tcc test.ref
58 # dynamic output
59 $(TCC) -o tcctest1 tcctest.c
60 ./tcctest1 > test1.out
61 @if diff -u test.ref test1.out ; then echo "Dynamic Auto Test OK"; fi
62 # static output
63 $(TCC) -static -o tcctest2 tcctest.c
64 ./tcctest2 > test2.out
65 @if diff -u test.ref test2.out ; then echo "Static Auto Test OK"; fi
66 # object + link output
67 $(TCC) -c -o tcctest3.o tcctest.c
68 $(TCC) -o tcctest3 tcctest3.o
69 ./tcctest3 > test3.out
70 @if diff -u test.ref test3.out ; then echo "Object Auto Test OK"; fi
71 # dynamic output + bound check
72 $(TCC) -b -o tcctest4 tcctest.c
73 ./tcctest4 > test4.out
74 @if diff -u test.ref test4.out ; then echo "BCheck Auto Test OK"; fi
76 # memory and bound check auto test
77 BOUNDS_OK = 1 4 8 10
78 BOUNDS_FAIL= 2 5 7 9 11 12 13
80 btest: boundtest.c tcc
81 @for i in $(BOUNDS_OK); do \
82 if $(TCC) -b boundtest.c $$i ; then \
83 /bin/true ; \
84 else\
85 echo Failed positive test $$i ; exit 1 ; \
86 fi ;\
87 done ;\
88 for i in $(BOUNDS_FAIL); do \
89 if $(TCC) -b boundtest.c $$i ; then \
90 echo Failed negative test $$i ; exit 1 ;\
91 else\
92 /bin/true ; \
93 fi\
94 done ;\
95 echo Bound test OK
97 # speed test
98 speed: tcc ex2 ex3
99 time ./ex2 1238 2 3 4 10 13 4
100 time ./tcc -I. ./ex2.c 1238 2 3 4 10 13 4
101 time ./ex3 35
102 time ./tcc -I. ./ex3.c 35
104 ex2: ex2.c
105 $(CC) $(CFLAGS) -o $@ $<
107 ex3: ex3.c
108 $(CC) $(CFLAGS) -o $@ $<
110 # Native Tiny C Compiler
112 tcc_g: tcc.c i386-gen.c tccelf.c tccasm.c i386-asm.c tcctok.h libtcc.h i386-asm.h Makefile
113 $(CC) $(CFLAGS) -o $@ $< $(LIBS)
115 tcc: tcc_g Makefile
116 strip -s -R .comment -R .note -o $@ $<
118 # TinyCC runtime libraries
119 libtcc1.o: libtcc1.c
120 $(CC) -O2 -Wall -c -o $@ $<
122 bcheck.o: bcheck.c
123 $(CC) -O2 -Wall -c -o $@ $<
125 install: tcc_install libinstall
127 tcc_install: tcc libtcc1.o bcheck.o
128 $(INSTALL) -m755 tcc $(bindir)
129 $(INSTALL) tcc.1 $(mandir)/man1
130 mkdir -p $(libdir)/tcc
131 mkdir -p $(libdir)/tcc/include
132 $(INSTALL) -m644 libtcc1.o bcheck.o $(libdir)/tcc
133 $(INSTALL) -m644 stdarg.h stddef.h stdbool.h float.h varargs.h \
134 tcclib.h $(libdir)/tcc/include
136 clean:
137 rm -f *~ *.o tcc tcc1 tcct tcc_g tcctest.ref *.bin *.i ex2 \
138 core gmon.out test.out test.ref a.out tcc_p \
139 *.exe tcc-doc.html libtcc.a libtcc_test \
140 tcctest[1234] test[1234].out
142 distclean: clean
143 rm -f config.h config.mak
145 # win32 TCC
146 tcc_g.exe: tcc.c i386-gen.c bcheck.c Makefile
147 i386-mingw32msvc-gcc $(CFLAGS) -DCONFIG_TCC_STATIC -o $@ $<
149 tcc.exe: tcc_g.exe
150 i386-mingw32msvc-strip -o $@ $<
152 # profiling version
153 tcc_p: tcc.c Makefile
154 $(CC) $(CFLAGS_P) -o $@ $< $(LIBS_P)
156 # libtcc generation and example
157 libinstall: libtcc.a
158 $(INSTALL) -m644 libtcc.a $(libdir)
159 $(INSTALL) -m644 libtcc.h $(includedir)
161 libtcc.o: tcc.c i386-gen.c bcheck.c Makefile
162 $(CC) $(CFLAGS) -DLIBTCC -c -o $@ $<
164 libtcc.a: libtcc.o
165 $(AR) rcs $@ $^
167 libtcc_test: libtcc_test.c libtcc.a
168 $(CC) $(CFLAGS) -I. -o $@ $< -L. -ltcc -ldl
170 libtest: libtcc_test
171 ./libtcc_test
173 # targets for development
175 %.bin: %.c tcc
176 $(TCC) -g -o $@ $<
177 $(DISAS) $@
179 instr: instr.o
180 objdump -d instr.o
182 # tiny assembler testing
184 asmtest.ref: asmtest.S
185 $(CC) -c -o asmtest.ref.o asmtest.S
186 objdump -D asmtest.ref.o > $@
188 # XXX: we compute tcc.c to go faster during development !
189 asmtest.out: asmtest.S tcc
190 # ./tcc tcc.c -c asmtest.S
191 #asmtest.out: asmtest.S tcc
192 ./tcc -c asmtest.S
193 objdump -D asmtest.o > $@
195 asmtest: asmtest.out asmtest.ref
196 @if diff -u --ignore-matching-lines="file format" asmtest.ref asmtest.out ; then echo "ASM Auto Test OK"; fi
198 instr.o: instr.S
199 $(CC) -O2 -Wall -g -c -o $@ $<
201 cache: tcc_g
202 cachegrind ./tcc_g -o /tmp/linpack -lm bench/linpack.c
203 vg_annotate tcc.c > /tmp/linpack.cache.log
205 # documentation
206 tcc-doc.html: tcc-doc.texi
207 texi2html -monolithic -number $<
209 FILES= Makefile Makefile.uClibc configure VERSION \
210 README TODO COPYING \
211 Changelog tcc-doc.texi tcc-doc.html \
212 tcc.1 \
213 tcc.c i386-gen.c tccelf.c tcctok.h tccasm.c i386-asm.c i386-asm.h\
214 bcheck.c libtcc1.c \
215 elf.h stab.h stab.def \
216 stddef.h stdarg.h stdbool.h float.h varargs.h \
217 tcclib.h libtcc.h libtcc_test.c \
218 ex1.c ex2.c ex3.c ex4.c ex5.c \
219 tcctest.c boundtest.c gcctestsuite.sh
221 FILE=tcc-$(VERSION)
223 tar:
224 rm -rf /tmp/$(FILE)
225 mkdir -p /tmp/$(FILE)
226 cp -P $(FILES) /tmp/$(FILE)
227 ( cd /tmp ; tar zcvf ~/$(FILE).tar.gz $(FILE) )
228 rm -rf /tmp/$(FILE)