fixed local extern handling - fixed '!' with symbols
[tinycc.git] / Makefile
blob98c45d1ca73d107a446581b97c96edb69fda5ad4
2 # Tiny C Compiler Makefile
4 prefix=/usr/local
6 CFLAGS=-O2 -g -Wall
7 LIBS=-ldl
8 CFLAGS_P=$(CFLAGS) -pg -static -DCONFIG_TCC_STATIC
9 LIBS_P=
11 CFLAGS+=-m386 -malign-functions=0
12 CFLAGS+=-DCONFIG_TCC_PREFIX=\"$(prefix)\"
13 DISAS=objdump -d
14 INSTALL=install
15 VERSION=0.9.10
17 # run local version of tcc with local libraries and includes
18 TCC=./tcc -B. -I.
20 all: tcc libtcc1.o bcheck.o tcc-doc.html
22 # auto test
24 test: test.ref test.out
25 @if diff -u test.ref test.out ; then echo "Auto Test OK"; fi
27 tcctest.ref: tcctest.c
28 gcc $(CFLAGS) -I. -o $@ $<
30 test.ref: tcctest.ref
31 ./tcctest.ref > $@
33 test.out: tcc tcctest.c
34 $(TCC) tcctest.c > $@
36 run: tcc tcctest.c
37 $(TCC) tcctest.c
39 # iterated test2 (compile tcc then compile tcctest.c !)
40 test2: tcc tcc.c tcctest.c test.ref
41 $(TCC) tcc.c -B. -I. tcctest.c > test.out2
42 @if diff -u test.ref test.out2 ; then echo "Auto Test2 OK"; fi
44 # iterated test3 (compile tcc then compile tcc then compile tcctest.c !)
45 test3: tcc tcc.c tcctest.c test.ref
46 $(TCC) tcc.c -B. -I. tcc.c -B. -I. tcctest.c > test.out3
47 @if diff -u test.ref test.out3 ; then echo "Auto Test3 OK"; fi
49 # binary output test
50 test4: tcc test.ref
51 # dynamic output
52 $(TCC) -o tcctest1 tcctest.c
53 ./tcctest1 > test1.out
54 @if diff -u test.ref test1.out ; then echo "Dynamic Auto Test OK"; fi
55 # static output
56 $(TCC) -static -o tcctest2 tcctest.c
57 ./tcctest2 > test2.out
58 @if diff -u test.ref test2.out ; then echo "Static Auto Test OK"; fi
59 # object + link output
60 $(TCC) -c -o tcctest3.o tcctest.c
61 $(TCC) -o tcctest3 tcctest3.o
62 ./tcctest3 > test3.out
63 @if diff -u test.ref test3.out ; then echo "Object Auto Test OK"; fi
64 # dynamic output + bound check
65 $(TCC) -b -o tcctest4 tcctest.c
66 ./tcctest4 > test4.out
67 @if diff -u test.ref test4.out ; then echo "BCheck Auto Test OK"; fi
69 # memory and bound check auto test
70 BOUNDS_OK = 1 4 8 10
71 BOUNDS_FAIL= 2 5 7 9 11 12 13
73 btest: boundtest.c tcc
74 @for i in $(BOUNDS_OK); do \
75 if $(TCC) -b boundtest.c $$i ; then \
76 /bin/true ; \
77 else\
78 echo Failed positive test $$i ; exit 1 ; \
79 fi ;\
80 done ;\
81 for i in $(BOUNDS_FAIL); do \
82 if $(TCC) -b boundtest.c $$i ; then \
83 echo Failed negative test $$i ; exit 1 ;\
84 else\
85 /bin/true ; \
86 fi\
87 done ;\
88 echo Bound test OK
90 # speed test
91 speed: tcc ex2 ex3
92 time ./ex2 1238 2 3 4 10 13 4
93 time ./tcc -I. ./ex2.c 1238 2 3 4 10 13 4
94 time ./ex3 35
95 time ./tcc -I. ./ex3.c 35
97 ex2: ex2.c
98 gcc $(CFLAGS) -o $@ $<
100 ex3: ex3.c
101 gcc $(CFLAGS) -o $@ $<
103 # Native Tiny C Compiler
105 tcc_g: tcc.c i386-gen.c tccelf.c tcctok.h libtcc.h Makefile
106 gcc $(CFLAGS) -o $@ $< $(LIBS)
108 tcc: tcc_g
109 strip -s -R .comment -R .note -o $@ $<
111 # TinyCC runtime libraries
112 libtcc1.o: libtcc1.c
113 gcc -O2 -Wall -c -o $@ $<
115 bcheck.o: bcheck.c
116 gcc -O2 -Wall -c -o $@ $<
118 install: tcc libtcc1.o bcheck.o
119 $(INSTALL) -m755 tcc $(prefix)/bin
120 $(INSTALL) tcc.1 $(prefix)/share/man/man1
121 mkdir -p $(prefix)/lib/tcc
122 mkdir -p $(prefix)/lib/tcc/include
123 $(INSTALL) -m644 libtcc1.o bcheck.o $(prefix)/lib/tcc
124 $(INSTALL) -m644 stdarg.h stddef.h float.h stdbool.h \
125 tcclib.h $(prefix)/lib/tcc/include
127 clean:
128 rm -f *~ *.o tcc tcc1 tcct tcc_g tcctest.ref *.bin *.i ex2 \
129 core gmon.out test.out test.ref a.out tcc_p \
130 *.exe iltcc iltcc_g tcc-doc.html \
131 tcctest[1234] test[1234].out
133 # IL TCC
135 iltcc_g: tcc.c il-gen.c bcheck.c Makefile
136 gcc $(CFLAGS) -DTCC_TARGET_IL -o $@ $< $(LIBS)
138 iltcc: iltcc_g
139 strip -s -R .comment -R .note -o $@ $<
141 # win32 TCC
142 tcc_g.exe: tcc.c i386-gen.c bcheck.c Makefile
143 i386-mingw32msvc-gcc $(CFLAGS) -DCONFIG_TCC_STATIC -o $@ $<
145 tcc.exe: tcc_g.exe
146 i386-mingw32msvc-strip -o $@ $<
148 # profiling version
149 tcc_p: tcc.c Makefile
150 gcc $(CFLAGS_P) -o $@ $< $(LIBS_P)
152 # libtcc generation and example
153 libinstall: libtcc.a
154 $(INSTALL) -m644 libtcc.a $(prefix)/lib
155 $(INSTALL) -m644 libtcc.h $(prefix)/include
157 libtcc.o: tcc.c i386-gen.c bcheck.c Makefile
158 gcc $(CFLAGS) -DLIBTCC -c -o $@ $<
160 libtcc.a: libtcc.o
161 ar rcs $@ $^
163 libtcc_test: libtcc_test.c libtcc.a
164 gcc $(CFLAGS) -I. -o $@ $< -L. -ltcc -ldl
166 # targets for development
168 %.bin: %.c tcc
169 $(TCC) -g -o $@ $<
170 $(DISAS) $@
172 instr: instr.o
173 objdump -d instr.o
175 instr.o: instr.S
176 gcc -O2 -Wall -g -c -o $@ $<
178 # documentation
179 tcc-doc.html: tcc-doc.texi
180 texi2html -monolithic -number $<
182 FILE=tcc-$(VERSION)
184 tar:
185 rm -rf /tmp/$(FILE)
186 cp -r ../tcc /tmp/$(FILE)
187 ( cd /tmp ; tar zcvf ~/$(FILE).tar.gz \
188 $(FILE)/Makefile $(FILE)/Makefile.uClibc \
189 $(FILE)/README $(FILE)/TODO $(FILE)/COPYING \
190 $(FILE)/Changelog $(FILE)/tcc-doc.texi $(FILE)/tcc-doc.html \
191 $(FILE)/tcc.1 \
192 $(FILE)/tcc.c $(FILE)/i386-gen.c $(FILE)/tccelf.c $(FILE)/tcctok.h \
193 $(FILE)/bcheck.c $(FILE)/libtcc1.c \
194 $(FILE)/il-opcodes.h $(FILE)/il-gen.c \
195 $(FILE)/elf.h $(FILE)/stab.h $(FILE)/stab.def \
196 $(FILE)/stddef.h $(FILE)/stdarg.h $(FILE)/stdbool.h $(FILE)/float.h \
197 $(FILE)/tcclib.h $(FILE)/libtcc.h $(FILE)/libtcc_test.c \
198 $(FILE)/ex*.c $(FILE)/tcctest.c $(FILE)/boundtest.c )
199 rm -rf /tmp/$(FILE)