2 # Tiny C Compiler Makefile
8 CFLAGS_P
=$(CFLAGS
) -pg
-static
-DCONFIG_TCC_STATIC
11 CFLAGS
+=-mpreferred-stack-boundary
=2
13 CFLAGS
+=-m386
-malign-functions
=0
15 CFLAGS
+=-march
=i386
-falign-functions
=0
22 # run local version of tcc with local libraries and includes
25 all: tcc libtcc1.o bcheck.o tcc-doc.html libtcc.a libtcc_test
31 test: test.ref
test.out
32 @if diff
-u
test.ref
test.out
; then echo
"Auto Test OK"; fi
34 tcctest.ref
: tcctest.c
35 $(CC
) $(CFLAGS
) -I.
-o
$@
$<
40 test.out
: tcc tcctest.c
46 # iterated test2 (compile tcc then compile tcctest.c !)
47 test2
: tcc tcc.c tcctest.c
test.ref
48 $(TCC
) tcc.c
-B.
-I. tcctest.c
> test.out2
49 @if diff
-u
test.ref
test.out2
; then echo
"Auto Test2 OK"; fi
51 # iterated test3 (compile tcc then compile tcc then compile tcctest.c !)
52 test3
: tcc tcc.c tcctest.c
test.ref
53 $(TCC
) tcc.c
-B.
-I. tcc.c
-B.
-I. tcctest.c
> test.out3
54 @if diff
-u
test.ref
test.out3
; then echo
"Auto Test3 OK"; fi
59 $(TCC
) -o tcctest1 tcctest.c
60 .
/tcctest1
> test1.out
61 @if diff
-u
test.ref test1.out
; then echo
"Dynamic Auto Test OK"; fi
63 $(TCC
) -static
-o tcctest2 tcctest.c
64 .
/tcctest2
> test2.out
65 @if diff
-u
test.ref test2.out
; then echo
"Static Auto Test OK"; fi
66 # object + link output
67 $(TCC
) -c
-o tcctest3.o tcctest.c
68 $(TCC
) -o tcctest3 tcctest3.o
69 .
/tcctest3
> test3.out
70 @if diff
-u
test.ref test3.out
; then echo
"Object Auto Test OK"; fi
71 # dynamic output + bound check
72 $(TCC
) -b
-o tcctest4 tcctest.c
73 .
/tcctest4
> test4.out
74 @if diff
-u
test.ref test4.out
; then echo
"BCheck Auto Test OK"; fi
76 # memory and bound check auto test
78 BOUNDS_FAIL
= 2 5 7 9 11 12 13
80 btest
: boundtest.c tcc
81 @for i in
$(BOUNDS_OK
); do \
82 if
$(TCC
) -b boundtest.c
$$i ; then \
85 echo Failed positive
test $$i ; exit
1 ; \
88 for i in
$(BOUNDS_FAIL
); do \
89 if
$(TCC
) -b boundtest.c
$$i ; then \
90 echo Failed negative
test $$i ; exit
1 ;\
99 time .
/ex2
1238 2 3 4 10 13 4
100 time .
/tcc
-I. .
/ex2.c
1238 2 3 4 10 13 4
102 time .
/tcc
-I. .
/ex3.c
35
105 $(CC
) $(CFLAGS
) -o
$@
$<
108 $(CC
) $(CFLAGS
) -o
$@
$<
110 # Native Tiny C Compiler
112 tcc_g
: tcc.c i386-gen.c tccelf.c tccasm.c i386-asm.c tcctok.h libtcc.h i386-asm.h Makefile
113 $(CC
) $(CFLAGS
) -o
$@
$< $(LIBS
)
116 strip -s
-R .comment
-R .note
-o
$@
$<
118 # TinyCC runtime libraries
120 $(CC
) -O2
-Wall
-c
-o
$@
$<
123 $(CC
) -O2
-Wall
-c
-o
$@
$<
125 install: tcc_install libinstall
127 tcc_install
: tcc libtcc1.o bcheck.o
128 $(INSTALL
) -m755 tcc
$(bindir)
129 $(INSTALL
) tcc
.1 $(mandir)/man1
130 mkdir
-p
$(libdir)/tcc
131 mkdir
-p
$(libdir)/tcc
/include
132 $(INSTALL
) -m644 libtcc1.o bcheck.o
$(libdir)/tcc
133 $(INSTALL
) -m644 stdarg.h stddef.h stdbool.h float.h varargs.h \
134 tcclib.h
$(libdir)/tcc
/include
137 rm -f
*~
*.o tcc tcc1 tcct tcc_g tcctest.ref
*.bin
*.i ex2 \
138 core gmon.out
test.out
test.ref a.out tcc_p \
139 *.exe tcc-doc.html libtcc.a libtcc_test \
140 tcctest
[1234] test[1234].out
143 rm -f config.h config.mak
146 tcc_g.exe
: tcc.c i386-gen.c bcheck.c Makefile
147 i386-mingw32msvc-gcc
$(CFLAGS
) -DCONFIG_TCC_STATIC
-o
$@
$<
150 i386-mingw32msvc-strip
-o
$@
$<
153 tcc_p
: tcc.c Makefile
154 $(CC
) $(CFLAGS_P
) -o
$@
$< $(LIBS_P
)
156 # libtcc generation and example
158 $(INSTALL
) -m644 libtcc.a
$(libdir)
159 $(INSTALL
) -m644 libtcc.h
$(includedir)
161 libtcc.o
: tcc.c i386-gen.c bcheck.c Makefile
162 $(CC
) $(CFLAGS
) -DLIBTCC
-c
-o
$@
$<
167 libtcc_test
: libtcc_test.c libtcc.a
168 $(CC
) $(CFLAGS
) -I.
-o
$@
$< -L.
-ltcc
-ldl
173 # targets for development
182 # tiny assembler testing
184 asmtest.ref
: asmtest.S
185 $(CC
) -c
-o asmtest.ref.o asmtest.S
186 objdump
-D asmtest.ref.o
> $@
188 # XXX: we compute tcc.c to go faster during development !
189 asmtest.out
: asmtest.S tcc
190 # ./tcc tcc.c -c asmtest.S
191 #asmtest.out: asmtest.S tcc
193 objdump
-D asmtest.o
> $@
195 asmtest
: asmtest.out asmtest.ref
196 @if diff
-u
--ignore-matching-lines
="file format" asmtest.ref asmtest.out
; then echo
"ASM Auto Test OK"; fi
199 $(CC
) -O2
-Wall
-g
-c
-o
$@
$<
202 cachegrind .
/tcc_g
-o
/tmp
/linpack
-lm bench
/linpack.c
203 vg_annotate tcc.c
> /tmp
/linpack.cache.log
206 tcc-doc.html
: tcc-doc.texi
207 texi2html
-monolithic
-number
$<
209 FILES
= Makefile Makefile.uClibc configure VERSION \
210 README TODO COPYING \
211 Changelog tcc-doc.texi tcc-doc.html \
213 tcc.c i386-gen.c tccelf.c tcctok.h tccasm.c i386-asm.c i386-asm.h\
215 elf.h stab.h stab.def \
216 stddef.h stdarg.h stdbool.h float.h varargs.h \
217 tcclib.h libtcc.h libtcc_test.c \
218 ex1.c ex2.c ex3.c ex4.c ex5.c \
219 tcctest.c boundtest.c gcctestsuite.sh
225 mkdir
-p
/tmp
/$(FILE
)
226 cp
-P
$(FILES
) /tmp
/$(FILE
)
227 ( cd
/tmp
; tar zcvf ~
/$(FILE
).
tar.gz
$(FILE
) )