initial TMS320C67xx support (TK)
[tinycc.git] / Makefile
blob85578278bd871b43cc75f8ffaeaa7381e2097500
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
18 DISAS=objdump -d
19 INSTALL=install
21 # run local version of tcc with local libraries and includes
22 TCC=./tcc -B. -I.
24 all: tcc libtcc1.a bcheck.o tcc-doc.html tcc.1 libtcc.a libtcc_test
26 Makefile: config.mak
28 # auto test
30 test: test.ref test.out
31 @if diff -u test.ref test.out ; then echo "Auto Test OK"; fi
33 tcctest.ref: tcctest.c
34 $(CC) $(CFLAGS) -I. -o $@ $<
36 test.ref: tcctest.ref
37 ./tcctest.ref > $@
39 test.out: tcc tcctest.c
40 $(TCC) -run tcctest.c > $@
42 run: tcc tcctest.c
43 $(TCC) -run tcctest.c
45 # iterated test2 (compile tcc then compile tcctest.c !)
46 test2: tcc tcc.c tcctest.c test.ref
47 $(TCC) -run tcc.c -B. -I. -run tcctest.c > test.out2
48 @if diff -u test.ref test.out2 ; then echo "Auto Test2 OK"; fi
50 # iterated test3 (compile tcc then compile tcc then compile tcctest.c !)
51 test3: tcc tcc.c tcctest.c test.ref
52 $(TCC) -run tcc.c -B. -I. -run tcc.c -B. -I. -run tcctest.c > test.out3
53 @if diff -u test.ref test.out3 ; then echo "Auto Test3 OK"; fi
55 # binary output test
56 test4: tcc test.ref
57 # dynamic output
58 $(TCC) -o tcctest1 tcctest.c
59 ./tcctest1 > test1.out
60 @if diff -u test.ref test1.out ; then echo "Dynamic Auto Test OK"; fi
61 # static output
62 $(TCC) -static -o tcctest2 tcctest.c
63 ./tcctest2 > test2.out
64 @if diff -u test.ref test2.out ; then echo "Static Auto Test OK"; fi
65 # object + link output
66 $(TCC) -c -o tcctest3.o tcctest.c
67 $(TCC) -o tcctest3 tcctest3.o
68 ./tcctest3 > test3.out
69 @if diff -u test.ref test3.out ; then echo "Object Auto Test OK"; fi
70 # dynamic output + bound check
71 $(TCC) -b -o tcctest4 tcctest.c
72 ./tcctest4 > test4.out
73 @if diff -u test.ref test4.out ; then echo "BCheck Auto Test OK"; fi
75 # memory and bound check auto test
76 BOUNDS_OK = 1 4 8 10
77 BOUNDS_FAIL= 2 5 7 9 11 12 13
79 btest: boundtest.c tcc
80 @for i in $(BOUNDS_OK); do \
81 if $(TCC) -b -run boundtest.c $$i ; then \
82 /bin/true ; \
83 else\
84 echo Failed positive test $$i ; exit 1 ; \
85 fi ;\
86 done ;\
87 for i in $(BOUNDS_FAIL); do \
88 if $(TCC) -b -run boundtest.c $$i ; then \
89 echo Failed negative test $$i ; exit 1 ;\
90 else\
91 /bin/true ; \
92 fi\
93 done ;\
94 echo Bound test OK
96 # speed test
97 speed: tcc ex2 ex3
98 time ./ex2 1238 2 3 4 10 13 4
99 time ./tcc -I. ./ex2.c 1238 2 3 4 10 13 4
100 time ./ex3 35
101 time ./tcc -I. ./ex3.c 35
103 ex2: ex2.c
104 $(CC) $(CFLAGS) -o $@ $<
106 ex3: ex3.c
107 $(CC) $(CFLAGS) -o $@ $<
109 # Native Tiny C Compiler
111 tcc_g: tcc.c i386-gen.c tccelf.c tccasm.c i386-asm.c tcctok.h libtcc.h i386-asm.h Makefile
112 $(CC) $(CFLAGS) -o $@ $< $(LIBS)
114 tcc: tcc_g Makefile
115 strip -s -R .comment -R .note -o $@ $<
117 c67-tcc: tcc.c c67-gen.c tccelf.c tccasm.c tcctok.h libtcc.h Makefile
118 $(CC) $(CFLAGS) -DTCC_TARGET_C67 -o $@ $< $(LIBS)
120 arm-tcc: tcc.c arm-gen.c tccelf.c tccasm.c tcctok.h libtcc.h Makefile
121 $(CC) $(CFLAGS) -DTCC_TARGET_ARM -o $@ $< $(LIBS)
123 # TinyCC runtime libraries
124 libtcc1.o: libtcc1.c
125 $(CC) -O2 -Wall -c -o $@ $<
127 libtcc1.a: libtcc1.o
128 $(AR) rcs $@ $^
130 bcheck.o: bcheck.c
131 $(CC) -O2 -Wall -c -o $@ $<
133 install: tcc_install libinstall
135 tcc_install: tcc tcc.1 libtcc1.a bcheck.o
136 mkdir -p $(bindir)
137 $(INSTALL) -m755 tcc $(bindir)
138 mkdir -p $(mandir)/man1
139 $(INSTALL) tcc.1 $(mandir)/man1
140 mkdir -p $(libdir)/tcc
141 mkdir -p $(libdir)/tcc/include
142 $(INSTALL) -m644 libtcc1.a bcheck.o $(libdir)/tcc
143 $(INSTALL) -m644 stdarg.h stddef.h stdbool.h float.h varargs.h \
144 tcclib.h $(libdir)/tcc/include
146 clean:
147 rm -f *~ *.o tcc tcc1 tcct tcc_g tcctest.ref *.bin *.i ex2 \
148 core gmon.out test.out test.ref a.out tcc_p \
149 *.exe tcc-doc.html tcc.pod tcc.1 libtcc.a libtcc_test \
150 tcctest[1234] test[1234].out
152 distclean: clean
153 rm -f config.h config.mak config.texi
155 # win32 TCC
156 tcc_g.exe: tcc.c i386-gen.c bcheck.c Makefile
157 i386-mingw32msvc-gcc $(CFLAGS) -DCONFIG_TCC_STATIC -o $@ $<
159 tcc.exe: tcc_g.exe
160 i386-mingw32msvc-strip -o $@ $<
162 # profiling version
163 tcc_p: tcc.c Makefile
164 $(CC) $(CFLAGS_P) -o $@ $< $(LIBS_P)
166 # libtcc generation and example
167 libinstall: libtcc.a
168 mkdir -p $(libdir)
169 $(INSTALL) -m644 libtcc.a $(libdir)
170 mkdir -p $(includedir)
171 $(INSTALL) -m644 libtcc.h $(includedir)
173 libtcc.o: tcc.c i386-gen.c bcheck.c Makefile
174 $(CC) $(CFLAGS) -DLIBTCC -c -o $@ $<
176 libtcc.a: libtcc.o
177 $(AR) rcs $@ $^
179 libtcc_test: libtcc_test.c libtcc.a
180 $(CC) $(CFLAGS) -I. -o $@ $< -L. -ltcc -ldl
182 libtest: libtcc_test
183 ./libtcc_test
185 # targets for development
187 %.bin: %.c tcc
188 $(TCC) -g -o $@ $<
189 $(DISAS) $@
191 instr: instr.o
192 objdump -d instr.o
194 # tiny assembler testing
196 asmtest.ref: asmtest.S
197 $(CC) -c -o asmtest.ref.o asmtest.S
198 objdump -D asmtest.ref.o > $@
200 # XXX: we compute tcc.c to go faster during development !
201 asmtest.out: asmtest.S tcc
202 # ./tcc tcc.c -c asmtest.S
203 #asmtest.out: asmtest.S tcc
204 ./tcc -c asmtest.S
205 objdump -D asmtest.o > $@
207 asmtest: asmtest.out asmtest.ref
208 @if diff -u --ignore-matching-lines="file format" asmtest.ref asmtest.out ; then echo "ASM Auto Test OK"; fi
210 instr.o: instr.S
211 $(CC) -O2 -Wall -g -c -o $@ $<
213 cache: tcc_g
214 cachegrind ./tcc_g -o /tmp/linpack -lm bench/linpack.c
215 vg_annotate tcc.c > /tmp/linpack.cache.log
217 # documentation and man page
218 tcc-doc.html: tcc-doc.texi
219 texi2html -monolithic -number $<
221 tcc.1: tcc-doc.texi
222 ./texi2pod.pl $< tcc.pod
223 pod2man --section=1 --center=" " --release=" " tcc.pod > $@
225 FILES= Makefile Makefile.uClibc configure VERSION \
226 README TODO COPYING \
227 Changelog tcc-doc.texi tcc-doc.html \
228 tcc.1 \
229 tcc.c i386-gen.c tccelf.c tcctok.h tccasm.c i386-asm.c i386-asm.h\
230 bcheck.c libtcc1.c \
231 elf.h stab.h stab.def \
232 stddef.h stdarg.h stdbool.h float.h varargs.h \
233 tcclib.h libtcc.h libtcc_test.c \
234 ex1.c ex2.c ex3.c ex4.c ex5.c \
235 tcctest.c boundtest.c gcctestsuite.sh texi2pod.pl
237 FILE=tcc-$(VERSION)
239 tar:
240 rm -rf /tmp/$(FILE)
241 mkdir -p /tmp/$(FILE)
242 cp -P $(FILES) /tmp/$(FILE)
243 ( cd /tmp ; tar zcvf ~/$(FILE).tar.gz $(FILE) )
244 rm -rf /tmp/$(FILE)