separated i386 code generator
[tinycc.git] / Makefile
blob435a08036e418b85f4547c4e972609d47e1bc2cf
2 # Tiny C Compiler Makefile
4 prefix=/usr/local
6 CFLAGS=-O2 -g -Wall -Wno-parentheses -Wno-missing-braces -I.
7 LIBS=-ldl
8 #CFLAGS=-O2 -g -Wall -Wno-parentheses -I. -pg -static -DPROFILE
9 #LIBS=
11 CFLAGS+=-m386 -malign-functions=0
12 DISAS=objdump -D -b binary -m i386
13 INSTALL=install
14 VERSION=0.9.1
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 prog.ref: prog.c
24 gcc $(CFLAGS) -o $@ $<
26 test.ref: prog.ref
27 ./prog.ref > $@
29 test.out: tcc prog.c
30 ./tcc -I. prog.c > $@
32 run: tcc prog.c
33 ./tcc -I. prog.c
35 # iterated test2 (compile tcc then compile prog.c !)
36 test2: tcc tcc.c prog.c
37 ./tcc -I. tcc.c -I. prog.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 prog.c !)
41 test3: tcc tcc.c prog.c
42 ./tcc -I. tcc.c -I. tcc.c -I. prog.c > test.out3
43 @if diff -u test.ref test.out3 ; then echo "Auto Test3 OK"; fi
45 # speed test
46 speed: tcc ex2 ex3
47 time ./ex2 1238 2 3 4 10 13 4
48 time ./tcc -I. ./ex2.c 1238 2 3 4 10 13 4
49 time ./ex3 35
50 time ./tcc -I. ./ex3.c 35
52 ex2: ex2.c
53 gcc $(CFLAGS) -o $@ $<
55 ex3: ex3.c
56 gcc $(CFLAGS) -o $@ $<
58 # Tiny C Compiler
60 tcc_g: tcc.c Makefile
61 gcc $(CFLAGS) -o $@ $< $(LIBS)
63 tcc: tcc_g
64 strip -s -R .comment -R .note -o $@ $<
66 install: tcc
67 $(INSTALL) -m755 tcc $(prefix)/bin
68 mkdir -p $(prefix)/lib/tcc
69 $(INSTALL) -m644 stdarg.h stddef.h tcclib.h $(prefix)/lib/tcc
71 clean:
72 rm -f *~ *.o tcc tcc1 tcct tcc_g prog.ref *.bin *.i ex2 \
73 core gmon.out test.out test.ref a.out
75 # target for development
77 %.bin: %.c tcc
78 ./tcc -o $@ -I. $<
79 $(DISAS) $@
81 instr.o: instr.S
82 gcc -O2 -Wall -g -c -o $@ $<
84 FILE=tcc-$(VERSION)
86 tar:
87 rm -rf /tmp/$(FILE)
88 cp -r ../tcc /tmp/$(FILE)
89 ( cd /tmp ; tar zcvf ~/$(FILE).tar.gz \
90 $(FILE)/Makefile $(FILE)/README $(FILE)/TODO $(FILE)/COPYING \
91 $(FILE)/tcc.c $(FILE)/stddef.h $(FILE)/stdarg.h $(FILE)/tcclib.h \
92 $(FILE)/ex*.c $(FILE)/prog.c )
93 rm -rf /tmp/$(FILE)