api change
[tinycc.git] / Makefile
blobd5456a31a70c0a7146d3fa8a92910e3529e8db2a
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.7
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 13
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 # Native 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 \
96 *.exe iltcc iltcc_g
98 # IL TCC
100 iltcc_g: tcc.c il-gen.c bcheck.c Makefile
101 gcc $(CFLAGS) -DTCC_TARGET_IL -o $@ $< $(LIBS)
103 iltcc: iltcc_g
104 strip -s -R .comment -R .note -o $@ $<
106 # win32 TCC
107 tcc_g.exe: tcc.c i386-gen.c bcheck.c Makefile
108 i386-mingw32msvc-gcc $(CFLAGS) -DCONFIG_TCC_STATIC -o $@ $<
110 tcc.exe: tcc_g.exe
111 i386-mingw32msvc-strip -o $@ $<
113 # profiling version
114 tcc_p: tcc.c Makefile
115 gcc $(CFLAGS_P) -o $@ $< $(LIBS_P)
117 # libtcc generation and example
118 libinstall: libtcc.a
119 $(INSTALL) -m644 libtcc.a $(prefix)/lib
120 $(INSTALL) -m644 libtcc.h $(prefix)/include
122 libtcc.o: tcc.c i386-gen.c bcheck.c Makefile
123 gcc $(CFLAGS) -DLIBTCC -c -o $@ $<
125 libtcc.a: libtcc.o
126 ar rcs $@ $^
128 libtcc_test: libtcc_test.c libtcc.a
129 gcc $(CFLAGS) -I. -o $@ $< -L. -ltcc -ldl
131 # targets for development
133 %.bin: %.c tcc
134 ./tcc -g -o $@ -I. $<
135 $(DISAS) $@
137 instr: instr.o
138 objdump -d instr.o
140 instr.o: instr.S
141 gcc -O2 -Wall -g -c -o $@ $<
143 FILE=tcc-$(VERSION)
145 tar:
146 rm -rf /tmp/$(FILE)
147 cp -r ../tcc /tmp/$(FILE)
148 ( cd /tmp ; tar zcvf ~/$(FILE).tar.gz \
149 $(FILE)/Makefile $(FILE)/Makefile.uClibc \
150 $(FILE)/README $(FILE)/TODO $(FILE)/COPYING \
151 $(FILE)/Changelog $(FILE)/tcc-doc.html \
152 $(FILE)/tcc.c $(FILE)/i386-gen.c $(FILE)/bcheck.c \
153 $(FILE)/il-opcodes.h $(FILE)/il-gen.c \
154 $(FILE)/elf.h $(FILE)/stab.h $(FILE)/stab.def \
155 $(FILE)/stddef.h $(FILE)/stdarg.h $(FILE)/stdbool.h $(FILE)/float.h \
156 $(FILE)/tcclib.h $(FILE)/libtcc.h $(FILE)/libtcc_test.c \
157 $(FILE)/ex*.c $(FILE)/tcctest.c $(FILE)/boundtest.c )
158 rm -rf /tmp/$(FILE)