added ansi proto
[tinycc.git] / Makefile
blob8313d26b8d43e7886db58ee4a3fa055dce5464a8
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 DISAS=objdump -d
13 INSTALL=install
14 VERSION=0.9.3
16 all: tcc
18 # auto test
20 test: test.ref test.out
21 @if diff -u test.ref test.out ; then echo "Auto Test OK"; fi
23 tcctest.ref: tcctest.c
24 gcc $(CFLAGS) -I. -o $@ $<
26 test.ref: tcctest.ref
27 ./tcctest.ref > $@
29 test.out: tcc tcctest.c
30 ./tcc -I. tcctest.c > $@
32 run: tcc tcctest.c
33 ./tcc -I. tcctest.c
35 # iterated test2 (compile tcc then compile tcctest.c !)
36 test2: tcc tcc.c tcctest.c test.ref
37 ./tcc -I. tcc.c -I. tcctest.c > test.out2
38 @if diff -u test.ref test.out2 ; then echo "Auto Test2 OK"; fi
40 # iterated test3 (compile tcc then compile tcc then compile tcctest.c !)
41 test3: tcc tcc.c tcctest.c test.ref
42 ./tcc -I. tcc.c -I. tcc.c -I. tcctest.c > test.out3
43 @if diff -u test.ref test.out3 ; then echo "Auto Test3 OK"; fi
45 # memory and bound check auto test
46 BOUNDS_OK = 1 4 8 10
47 BOUNDS_FAIL= 2 5 7 9 11 12
49 btest: boundtest.c tcc
50 @for i in $(BOUNDS_OK); do \
51 if ./tcc -b boundtest.c $$i ; then \
52 /bin/true ; \
53 else\
54 echo Failed positive test $$i ; exit 1 ; \
55 fi ;\
56 done ;\
57 for i in $(BOUNDS_FAIL); do \
58 if ./tcc -b boundtest.c $$i ; then \
59 echo Failed negative test $$i ; exit 1 ;\
60 else\
61 /bin/true ; \
62 fi\
63 done ;\
64 echo Bound test OK
66 # speed test
67 speed: tcc ex2 ex3
68 time ./ex2 1238 2 3 4 10 13 4
69 time ./tcc -I. ./ex2.c 1238 2 3 4 10 13 4
70 time ./ex3 35
71 time ./tcc -I. ./ex3.c 35
73 ex2: ex2.c
74 gcc $(CFLAGS) -o $@ $<
76 ex3: ex3.c
77 gcc $(CFLAGS) -o $@ $<
79 # Tiny C Compiler
81 tcc_g: tcc.c i386-gen.c bcheck.c Makefile
82 gcc $(CFLAGS) -o $@ $< $(LIBS)
84 tcc: tcc_g
85 strip -s -R .comment -R .note -o $@ $<
87 install: tcc
88 $(INSTALL) -m755 tcc $(prefix)/bin
89 mkdir -p $(prefix)/lib/tcc
90 $(INSTALL) -m644 stdarg.h stddef.h float.h stdbool.h \
91 tcclib.h $(prefix)/lib/tcc
93 clean:
94 rm -f *~ *.o tcc tcc1 tcct tcc_g tcctest.ref *.bin *.i ex2 \
95 core gmon.out test.out test.ref a.out tcc_p
97 # profiling version
98 tcc_p: tcc.c Makefile
99 gcc $(CFLAGS_P) -o $@ $< $(LIBS_P)
101 # targets for development
103 %.bin: %.c tcc
104 ./tcc -g -o $@ -I. $<
105 $(DISAS) $@
107 instr: instr.o
108 objdump -d instr.o
110 instr.o: instr.S
111 gcc -O2 -Wall -g -c -o $@ $<
113 FILE=tcc-$(VERSION)
115 tar:
116 rm -rf /tmp/$(FILE)
117 cp -r ../tcc /tmp/$(FILE)
118 ( cd /tmp ; tar zcvf ~/$(FILE).tar.gz \
119 $(FILE)/Makefile $(FILE)/README $(FILE)/TODO $(FILE)/COPYING \
120 $(FILE)/Changelog $(FILE)/tcc-doc.html \
121 $(FILE)/tcc.c $(FILE)/i386-gen.c $(FILE)/bcheck.c \
122 $(FILE)/stddef.h $(FILE)/stdarg.h $(FILE)/stdbool.h $(FILE)/float.h \
123 $(FILE)/tcclib.h \
124 $(FILE)/ex*.c $(FILE)/tcctest.c $(FILE)/boundtest.c )
125 rm -rf /tmp/$(FILE)