2 # Tiny C Compiler Makefile
11 CFLAGS_P
=$(CFLAGS
) -pg
-static
-DCONFIG_TCC_STATIC
14 CFLAGS
+=-mpreferred-stack-boundary
=2
16 CFLAGS
+=-m386
-malign-functions
=0
18 CFLAGS
+=-march
=i386
-falign-functions
=0
23 PROGS
=tcc
$(EXESUF
) c67-tcc
$(EXESUF
) arm-tcc
$(EXESUF
)
24 # run local version of tcc with local libraries and includes
28 libtcc1
$(LIBSUF
) $(BCHECK_O
) tcc-doc.html tcc
.1 libtcc
$(LIBSUF
) \
35 test: test.ref
test.out
36 @if diff
-u
test.ref
test.out
; then echo
"Auto Test OK"; fi
38 tcctest.ref
: tcctest.c
39 $(CC
) $(CFLAGS
) -I.
-o
$@
$<
44 test.out
: tcc tcctest.c
45 $(TCC
) -run tcctest.c
> $@
50 # iterated test2 (compile tcc then compile tcctest.c !)
51 test2
: tcc tcc.c tcctest.c
test.ref
52 $(TCC
) -run tcc.c
-B.
-I.
-run tcctest.c
> test.out2
53 @if diff
-u
test.ref
test.out2
; then echo
"Auto Test2 OK"; fi
55 # iterated test3 (compile tcc then compile tcc then compile tcctest.c !)
56 test3
: tcc tcc.c tcctest.c
test.ref
57 $(TCC
) -run tcc.c
-B.
-I.
-run tcc.c
-B.
-I.
-run tcctest.c
> test.out3
58 @if diff
-u
test.ref
test.out3
; then echo
"Auto Test3 OK"; fi
63 $(TCC
) -o tcctest1 tcctest.c
64 .
/tcctest1
> test1.out
65 @if diff
-u
test.ref test1.out
; then echo
"Dynamic Auto Test OK"; fi
67 $(TCC
) -static
-o tcctest2 tcctest.c
68 .
/tcctest2
> test2.out
69 @if diff
-u
test.ref test2.out
; then echo
"Static Auto Test OK"; fi
70 # object + link output
71 $(TCC
) -c
-o tcctest3.o tcctest.c
72 $(TCC
) -o tcctest3 tcctest3.o
73 .
/tcctest3
> test3.out
74 @if diff
-u
test.ref test3.out
; then echo
"Object Auto Test OK"; fi
75 # dynamic output + bound check
76 $(TCC
) -b
-o tcctest4 tcctest.c
77 .
/tcctest4
> test4.out
78 @if diff
-u
test.ref test4.out
; then echo
"BCheck Auto Test OK"; fi
80 # memory and bound check auto test
82 BOUNDS_FAIL
= 2 5 7 9 11 12 13
84 btest
: boundtest.c tcc
85 @for i in
$(BOUNDS_OK
); do \
86 if
$(TCC
) -b
-run boundtest.c
$$i ; then \
89 echo Failed positive
test $$i ; exit
1 ; \
92 for i in
$(BOUNDS_FAIL
); do \
93 if
$(TCC
) -b
-run boundtest.c
$$i ; then \
94 echo Failed negative
test $$i ; exit
1 ;\
103 time .
/ex2
1238 2 3 4 10 13 4
104 time .
/tcc
-I. .
/ex2.c
1238 2 3 4 10 13 4
106 time .
/tcc
-I. .
/ex3.c
35
109 $(CC
) $(CFLAGS
) -o
$@
$<
112 $(CC
) $(CFLAGS
) -o
$@
$<
114 # Native Tiny C Compiler
116 tcc_g
$(EXESUF
): tcc.c i386-gen.c tccelf.c tccasm.c i386-asm.c tcctok.h libtcc.h i386-asm.h Makefile
117 $(CC
) $(CFLAGS
) -o
$@
$< $(LIBS
)
119 tcc
$(EXESUF
): tcc_g
$(EXESUF
) Makefile
122 c67-tcc
$(EXESUF
): tcc.c c67-gen.c tccelf.c tccasm.c tcctok.h libtcc.h tcccoff.c Makefile
123 $(CC
) $(CFLAGS
) -DTCC_TARGET_C67
-o
$@
$< $(LIBS
)
125 arm-tcc
$(EXESUF
): tcc.c arm-gen.c tccelf.c tccasm.c tcctok.h libtcc.h Makefile
126 $(CC
) $(CFLAGS
) -DTCC_TARGET_ARM
-o
$@
$< $(LIBS
)
128 # TinyCC runtime libraries
130 $(CC
) -O2
-Wall
-c
-o
$@
$<
132 libtcc1
$(LIBSUF
): libtcc1.o
136 $(CC
) -O2
-Wall
-c
-o
$@
$<
138 install: tcc_install libinstall
140 tcc_install
: $(PROGS
) tcc
.1 libtcc1
$(LIBSUF
) $(BCHECK_O
) tcc-doc.html tcc
.1
142 $(INSTALL
) -s
-m755
$(PROGS
) "$(bindir)"
144 mkdir
-p
"$(mandir)/man1"
145 $(INSTALL
) tcc
.1 "$(mandir)/man1"
147 mkdir
-p
"$(libdir)/tcc"
148 mkdir
-p
"$(libdir)/tcc/include"
149 $(INSTALL
) -m644 libtcc1
$(LIBSUF
) $(BCHECK_O
) "$(libdir)/tcc"
150 $(INSTALL
) -m644 stdarg.h stddef.h stdbool.h float.h varargs.h \
151 tcclib.h
"$(libdir)/tcc/include"
153 $(INSTALL
) -m644 tcc-doc.html
"$(docdir)"
156 rm -f
*~
*.o tcc tcc1 tcct tcc_g tcctest.ref
*.bin
*.i ex2 \
157 core gmon.out
test.out
test.ref a.out tcc_p \
158 *.exe tcc-doc.html tcc.pod tcc
.1 libtcc
$(LIBSUF
) libtcc_test \
159 tcctest
[1234] test[1234].out c67-tcc arm-tcc
162 rm -f config.h config.mak config.texi
165 tcc_p
: tcc.c Makefile
166 $(CC
) $(CFLAGS_P
) -o
$@
$< $(LIBS_P
)
168 # libtcc generation and example
169 libinstall
: libtcc
$(LIBSUF
)
171 $(INSTALL
) -m644 libtcc
$(LIBSUF
) "$(libdir)"
172 mkdir
-p
"$(includedir)"
173 $(INSTALL
) -m644 libtcc.h
"$(includedir)"
175 libtcc.o
: tcc.c i386-gen.c Makefile
176 $(CC
) $(CFLAGS
) -DLIBTCC
-c
-o
$@
$<
178 libtcc
$(LIBSUF
): libtcc.o
181 libtcc_test
$(EXESUF
): libtcc_test.c libtcc
$(LIBSUF
)
182 $(CC
) $(CFLAGS
) -o
$@
$< libtcc
$(LIBSUF
) $(LIBS
)
187 # targets for development
196 # tiny assembler testing
198 asmtest.ref
: asmtest.S
199 $(CC
) -c
-o asmtest.ref.o asmtest.S
200 objdump
-D asmtest.ref.o
> $@
202 # XXX: we compute tcc.c to go faster during development !
203 asmtest.out
: asmtest.S tcc
204 # ./tcc tcc.c -c asmtest.S
205 #asmtest.out: asmtest.S tcc
207 objdump
-D asmtest.o
> $@
209 asmtest
: asmtest.out asmtest.ref
210 @if diff
-u
--ignore-matching-lines
="file format" asmtest.ref asmtest.out
; then echo
"ASM Auto Test OK"; fi
213 $(CC
) -O2
-Wall
-g
-c
-o
$@
$<
216 cachegrind .
/tcc_g
-o
/tmp
/linpack
-lm bench
/linpack.c
217 vg_annotate tcc.c
> /tmp
/linpack.cache.log
219 # documentation and man page
220 tcc-doc.html
: tcc-doc.texi
221 texi2html
-monolithic
-number
$<
224 .
/texi2pod.pl
$< tcc.pod
225 pod2man
--section
=1 --center
=" " --release
=" " tcc.pod
> $@
227 FILES
= Makefile Makefile.uClibc configure VERSION \
228 README TODO COPYING \
229 Changelog tcc-doc.texi tcc-doc.html \
231 tcc.c tccelf.c tcctok.h tccasm.c i386-asm.c i386-asm.h \
233 i386-gen.c c67-gen.c arm-gen.c \
235 elf.h stab.h stab.def \
236 stddef.h stdarg.h stdbool.h float.h varargs.h \
237 tcclib.h libtcc.h libtcc_test.c \
238 ex1.c ex2.c ex3.c ex4.c ex5.c \
239 tcctest.c boundtest.c gcctestsuite.sh texi2pod.pl
245 mkdir
-p
/tmp
/$(FILE
)
246 cp
-P
$(FILES
) /tmp
/$(FILE
)
247 ( cd
/tmp
; tar zcvf ~
/$(FILE
).
tar.gz
$(FILE
) )