optimized token strings - optimized token hashing
[tinycc/miki.git] / Makefile
blob0b377d052bb1b303084616bbd34fe5b26d839ce7
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
13 CFLAGS+=-DCONFIG_TCC_PREFIX=\"$(prefix)\"
14 DISAS=objdump -d
15 INSTALL=install
16 VERSION=0.9.13
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 tcctok.h libtcc.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 float.h stdbool.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 iltcc iltcc_g tcc-doc.html \
132 tcctest[1234] test[1234].out
134 # IL TCC
136 iltcc_g: tcc.c il-gen.c bcheck.c Makefile
137 gcc $(CFLAGS) -DTCC_TARGET_IL -o $@ $< $(LIBS)
139 iltcc: iltcc_g
140 strip -s -R .comment -R .note -o $@ $<
142 # win32 TCC
143 tcc_g.exe: tcc.c i386-gen.c bcheck.c Makefile
144 i386-mingw32msvc-gcc $(CFLAGS) -DCONFIG_TCC_STATIC -o $@ $<
146 tcc.exe: tcc_g.exe
147 i386-mingw32msvc-strip -o $@ $<
149 # profiling version
150 tcc_p: tcc.c Makefile
151 gcc $(CFLAGS_P) -o $@ $< $(LIBS_P)
153 # libtcc generation and example
154 libinstall: libtcc.a
155 $(INSTALL) -m644 libtcc.a $(prefix)/lib
156 $(INSTALL) -m644 libtcc.h $(prefix)/include
158 libtcc.o: tcc.c i386-gen.c bcheck.c Makefile
159 gcc $(CFLAGS) -DLIBTCC -c -o $@ $<
161 libtcc.a: libtcc.o
162 ar rcs $@ $^
164 libtcc_test: libtcc_test.c libtcc.a
165 gcc $(CFLAGS) -I. -o $@ $< -L. -ltcc -ldl
167 # targets for development
169 %.bin: %.c tcc
170 $(TCC) -g -o $@ $<
171 $(DISAS) $@
173 instr: instr.o
174 objdump -d instr.o
176 instr.o: instr.S
177 gcc -O2 -Wall -g -c -o $@ $<
179 # documentation
180 tcc-doc.html: tcc-doc.texi
181 texi2html -monolithic -number $<
183 FILES= Makefile Makefile.uClibc \
184 README TODO COPYING \
185 Changelog tcc-doc.texi tcc-doc.html \
186 tcc.1 \
187 tcc.c i386-gen.c tccelf.c tcctok.h \
188 bcheck.c libtcc1.c \
189 il-opcodes.h il-gen.c \
190 elf.h stab.h stab.def \
191 stddef.h stdarg.h stdbool.h float.h \
192 tcclib.h libtcc.h libtcc_test.c \
193 ex1.c ex2.c ex3.c ex4.c ex5.c \
194 tcctest.c boundtest.c
196 FILE=tcc-$(VERSION)
198 tar:
199 rm -rf /tmp/$(FILE)
200 mkdir -p /tmp/$(FILE)
201 cp -P $(FILES) /tmp/$(FILE)
202 ( cd /tmp ; tar zcvf ~/$(FILE).tar.gz $(FILE) )
203 rm -rf /tmp/$(FILE)