function parameters must be converted to pointer of functions
[tinycc/miki.git] / Makefile
blob23d8291b58f8289ec1d78d90f176b5604cffa25f
2 # Tiny C Compiler Makefile
4 prefix=/usr/local
5 manpath=$(prefix)/man
7 CFLAGS=-O2 -g -Wall
8 LIBS=-ldl
9 CFLAGS_P=$(CFLAGS) -pg -static -DCONFIG_TCC_STATIC
10 LIBS_P=
12 CFLAGS+=-m386 -malign-functions=0 -mpreferred-stack-boundary=2
13 CFLAGS+=-DCONFIG_TCC_PREFIX=\"$(prefix)\"
14 DISAS=objdump -d
15 INSTALL=install
16 VERSION=0.9.16
18 # run local version of tcc with local libraries and includes
19 TCC=./tcc -B. -I.
21 all: tcc libtcc1.o bcheck.o tcc-doc.html
23 # auto test
25 test: test.ref test.out
26 @if diff -u test.ref test.out ; then echo "Auto Test OK"; fi
28 tcctest.ref: tcctest.c
29 gcc $(CFLAGS) -I. -o $@ $<
31 test.ref: tcctest.ref
32 ./tcctest.ref > $@
34 test.out: tcc tcctest.c
35 $(TCC) tcctest.c > $@
37 run: tcc tcctest.c
38 $(TCC) tcctest.c
40 # iterated test2 (compile tcc then compile tcctest.c !)
41 test2: tcc tcc.c tcctest.c test.ref
42 $(TCC) tcc.c -B. -I. tcctest.c > test.out2
43 @if diff -u test.ref test.out2 ; then echo "Auto Test2 OK"; fi
45 # iterated test3 (compile tcc then compile tcc then compile tcctest.c !)
46 test3: tcc tcc.c tcctest.c test.ref
47 $(TCC) tcc.c -B. -I. tcc.c -B. -I. tcctest.c > test.out3
48 @if diff -u test.ref test.out3 ; then echo "Auto Test3 OK"; fi
50 # binary output test
51 test4: tcc test.ref
52 # dynamic output
53 $(TCC) -o tcctest1 tcctest.c
54 ./tcctest1 > test1.out
55 @if diff -u test.ref test1.out ; then echo "Dynamic Auto Test OK"; fi
56 # static output
57 $(TCC) -static -o tcctest2 tcctest.c
58 ./tcctest2 > test2.out
59 @if diff -u test.ref test2.out ; then echo "Static Auto Test OK"; fi
60 # object + link output
61 $(TCC) -c -o tcctest3.o tcctest.c
62 $(TCC) -o tcctest3 tcctest3.o
63 ./tcctest3 > test3.out
64 @if diff -u test.ref test3.out ; then echo "Object Auto Test OK"; fi
65 # dynamic output + bound check
66 $(TCC) -b -o tcctest4 tcctest.c
67 ./tcctest4 > test4.out
68 @if diff -u test.ref test4.out ; then echo "BCheck Auto Test OK"; fi
70 # memory and bound check auto test
71 BOUNDS_OK = 1 4 8 10
72 BOUNDS_FAIL= 2 5 7 9 11 12 13
74 btest: boundtest.c tcc
75 @for i in $(BOUNDS_OK); do \
76 if $(TCC) -b boundtest.c $$i ; then \
77 /bin/true ; \
78 else\
79 echo Failed positive test $$i ; exit 1 ; \
80 fi ;\
81 done ;\
82 for i in $(BOUNDS_FAIL); do \
83 if $(TCC) -b boundtest.c $$i ; then \
84 echo Failed negative test $$i ; exit 1 ;\
85 else\
86 /bin/true ; \
87 fi\
88 done ;\
89 echo Bound test OK
91 # speed test
92 speed: tcc ex2 ex3
93 time ./ex2 1238 2 3 4 10 13 4
94 time ./tcc -I. ./ex2.c 1238 2 3 4 10 13 4
95 time ./ex3 35
96 time ./tcc -I. ./ex3.c 35
98 ex2: ex2.c
99 gcc $(CFLAGS) -o $@ $<
101 ex3: ex3.c
102 gcc $(CFLAGS) -o $@ $<
104 # Native Tiny C Compiler
106 tcc_g: tcc.c i386-gen.c tccelf.c tccasm.c i386-asm.c tcctok.h libtcc.h i386-asm.h Makefile
107 gcc $(CFLAGS) -o $@ $< $(LIBS)
109 tcc: tcc_g
110 strip -s -R .comment -R .note -o $@ $<
112 # TinyCC runtime libraries
113 libtcc1.o: libtcc1.c
114 gcc -O2 -Wall -c -o $@ $<
116 bcheck.o: bcheck.c
117 gcc -O2 -Wall -c -o $@ $<
119 install: tcc libtcc1.o bcheck.o
120 $(INSTALL) -m755 tcc $(prefix)/bin
121 $(INSTALL) tcc.1 $(manpath)/man1
122 mkdir -p $(prefix)/lib/tcc
123 mkdir -p $(prefix)/lib/tcc/include
124 $(INSTALL) -m644 libtcc1.o bcheck.o $(prefix)/lib/tcc
125 $(INSTALL) -m644 stdarg.h stddef.h stdbool.h float.h varargs.h \
126 tcclib.h $(prefix)/lib/tcc/include
128 clean:
129 rm -f *~ *.o tcc tcc1 tcct tcc_g tcctest.ref *.bin *.i ex2 \
130 core gmon.out test.out test.ref a.out tcc_p \
131 *.exe tcc-doc.html \
132 tcctest[1234] test[1234].out
134 # win32 TCC
135 tcc_g.exe: tcc.c i386-gen.c bcheck.c Makefile
136 i386-mingw32msvc-gcc $(CFLAGS) -DCONFIG_TCC_STATIC -o $@ $<
138 tcc.exe: tcc_g.exe
139 i386-mingw32msvc-strip -o $@ $<
141 # profiling version
142 tcc_p: tcc.c Makefile
143 gcc $(CFLAGS_P) -o $@ $< $(LIBS_P)
145 # libtcc generation and example
146 libinstall: libtcc.a
147 $(INSTALL) -m644 libtcc.a $(prefix)/lib
148 $(INSTALL) -m644 libtcc.h $(prefix)/include
150 libtcc.o: tcc.c i386-gen.c bcheck.c Makefile
151 gcc $(CFLAGS) -DLIBTCC -c -o $@ $<
153 libtcc.a: libtcc.o
154 ar rcs $@ $^
156 libtcc_test: libtcc_test.c libtcc.a
157 gcc $(CFLAGS) -I. -o $@ $< -L. -ltcc -ldl
159 libtest: libtcc_test
160 ./libtcc_test
162 # targets for development
164 %.bin: %.c tcc
165 $(TCC) -g -o $@ $<
166 $(DISAS) $@
168 instr: instr.o
169 objdump -d instr.o
171 # tiny assembler testing
173 asmtest.ref: asmtest.S
174 gcc -c -o asmtest.ref.o asmtest.S
175 objdump -D asmtest.ref.o > $@
177 # XXX: we compute tcc.c to go faster during development !
178 asmtest.out: asmtest.S tcc
179 # ./tcc tcc.c -c asmtest.S
180 #asmtest.out: asmtest.S tcc
181 ./tcc -c asmtest.S
182 objdump -D asmtest.o > $@
184 asmtest: asmtest.out asmtest.ref
185 @if diff -u --ignore-matching-lines="file format" asmtest.ref asmtest.out ; then echo "ASM Auto Test OK"; fi
187 instr.o: instr.S
188 gcc -O2 -Wall -g -c -o $@ $<
190 cache: tcc_g
191 cachegrind ./tcc_g -o /tmp/linpack -lm bench/linpack.c
192 vg_annotate tcc.c > /tmp/linpack.cache.log
194 # documentation
195 tcc-doc.html: tcc-doc.texi
196 texi2html -monolithic -number $<
198 FILES= Makefile Makefile.uClibc \
199 README TODO COPYING \
200 Changelog tcc-doc.texi tcc-doc.html \
201 tcc.1 \
202 tcc.c i386-gen.c tccelf.c tcctok.h tccasm.c i386-asm.c i386-asm.h\
203 bcheck.c libtcc1.c \
204 elf.h stab.h stab.def \
205 stddef.h stdarg.h stdbool.h float.h varargs.h \
206 tcclib.h libtcc.h libtcc_test.c \
207 ex1.c ex2.c ex3.c ex4.c ex5.c \
208 tcctest.c boundtest.c gcctestsuite.sh
210 FILE=tcc-$(VERSION)
212 tar:
213 rm -rf /tmp/$(FILE)
214 mkdir -p /tmp/$(FILE)
215 cp -P $(FILES) /tmp/$(FILE)
216 ( cd /tmp ; tar zcvf ~/$(FILE).tar.gz $(FILE) )
217 rm -rf /tmp/$(FILE)