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 -fno-strict-aliasing
27 PROGS
+=c67-tcc
$(EXESUF
) arm-tcc
$(EXESUF
)
29 PROGS
+=tiny_impdef
$(EXESUF
)
34 PROGS
+=arm-tcc
$(EXESUF
)
40 PROGS
+=i386-tcc
$(EXESUF
)
44 PROGS
+=c67-tcc
$(EXESUF
) i386-win32-tcc
$(EXESUF
)
48 # run local version of tcc with local libraries and includes
52 libtcc1
$(LIBSUF
) $(BCHECK_O
) tcc-doc.html tcc
.1 libtcc
$(LIBSUF
) \
59 test: test.ref
test.out
60 @if diff
-u
test.ref
test.out
; then echo
"Auto Test OK"; fi
62 tcctest.ref
: tcctest.c
63 $(CC
) $(CFLAGS
) -I.
-o
$@
$<
68 test.out
: tcc tcctest.c
69 $(TCC
) -run tcctest.c
> $@
74 # iterated test2 (compile tcc then compile tcctest.c !)
75 test2
: tcc tcc.c tcctest.c
test.ref
76 $(TCC
) -run tcc.c
-B.
-I.
-run tcctest.c
> test.out2
77 @if diff
-u
test.ref
test.out2
; then echo
"Auto Test2 OK"; fi
79 # iterated test3 (compile tcc then compile tcc then compile tcctest.c !)
80 test3
: tcc tcc.c tcctest.c
test.ref
81 $(TCC
) -run tcc.c
-B.
-I.
-run tcc.c
-B.
-I.
-run tcctest.c
> test.out3
82 @if diff
-u
test.ref
test.out3
; then echo
"Auto Test3 OK"; fi
87 $(TCC
) -o tcctest1 tcctest.c
88 .
/tcctest1
> test1.out
89 @if diff
-u
test.ref test1.out
; then echo
"Dynamic Auto Test OK"; fi
91 $(TCC
) -static
-o tcctest2 tcctest.c
92 .
/tcctest2
> test2.out
93 @if diff
-u
test.ref test2.out
; then echo
"Static Auto Test OK"; fi
94 # object + link output
95 $(TCC
) -c
-o tcctest3.o tcctest.c
96 $(TCC
) -o tcctest3 tcctest3.o
97 .
/tcctest3
> test3.out
98 @if diff
-u
test.ref test3.out
; then echo
"Object Auto Test OK"; fi
99 # dynamic output + bound check
100 $(TCC
) -b
-o tcctest4 tcctest.c
101 .
/tcctest4
> test4.out
102 @if diff
-u
test.ref test4.out
; then echo
"BCheck Auto Test OK"; fi
104 # memory and bound check auto test
106 BOUNDS_FAIL
= 2 5 7 9 11 12 13
108 btest
: boundtest.c tcc
109 @for i in
$(BOUNDS_OK
); do \
110 if
$(TCC
) -b
-run boundtest.c
$$i ; then \
113 echo Failed positive
test $$i ; exit
1 ; \
116 for i in
$(BOUNDS_FAIL
); do \
117 if
$(TCC
) -b
-run boundtest.c
$$i ; then \
118 echo Failed negative
test $$i ; exit
1 ;\
127 time .
/ex2
1238 2 3 4 10 13 4
128 time .
/tcc
-I. .
/ex2.c
1238 2 3 4 10 13 4
130 time .
/tcc
-I. .
/ex3.c
35
133 $(CC
) $(CFLAGS
) -o
$@
$<
136 $(CC
) $(CFLAGS
) -o
$@
$<
138 # Host Tiny C Compiler
140 tcc
$(EXESUF
): tcc.c i386-gen.c tccelf.c tccasm.c i386-asm.c tcctok.h libtcc.h i386-asm.h tccpe.c
141 $(CC
) $(CFLAGS
) -DTCC_TARGET_PE
-o
$@
$< $(LIBS
)
144 tcc
$(EXESUF
): tcc.c i386-gen.c tccelf.c tccasm.c i386-asm.c tcctok.h libtcc.h i386-asm.h
145 $(CC
) $(CFLAGS
) -o
$@
$< $(LIBS
)
148 tcc
$(EXESUF
): tcc.c arm-gen.c tccelf.c tccasm.c tcctok.h libtcc.h
149 $(CC
) $(CFLAGS
) -DTCC_TARGET_ARM
-o
$@
$< $(LIBS
)
153 # Cross Tiny C Compilers
154 i386-tcc
$(EXESUF
): tcc.c i386-gen.c tccelf.c tccasm.c i386-asm.c tcctok.h libtcc.h i386-asm.h
155 $(CC
) $(CFLAGS
) -o
$@
$< $(LIBS
)
157 c67-tcc
$(EXESUF
): tcc.c c67-gen.c tccelf.c tccasm.c tcctok.h libtcc.h tcccoff.c
158 $(CC
) $(CFLAGS
) -DTCC_TARGET_C67
-o
$@
$< $(LIBS
)
160 arm-tcc
$(EXESUF
): tcc.c arm-gen.c tccelf.c tccasm.c tcctok.h libtcc.h
161 $(CC
) $(CFLAGS
) -DTCC_TARGET_ARM
-o
$@
$< $(LIBS
)
163 i386-win32-tcc
$(EXESUF
): tcc.c i386-gen.c tccelf.c tccasm.c i386-asm.c tcctok.h libtcc.h i386-asm.h tccpe.c
164 $(CC
) $(CFLAGS
) -DTCC_TARGET_PE
-o
$@
$< $(LIBS
)
167 tiny_impdef
$(EXESUF
): tiny_impdef.c
168 $(CC
) $(CFLAGS
) -o
$@
$< -lkernel32
170 # TinyCC runtime libraries
172 LIBTCC1_OBJS
=$(addprefix win32
/lib
/, crt1.o wincrt1.o dllcrt1.o dllmain.o chkstk.o
) libtcc1.o
174 LIBTCC1_OBJS
=libtcc1.o
178 $(CC
) -O2
-Wall
-c
-o
$@
$<
183 libtcc1
$(LIBSUF
): $(LIBTCC1_OBJS
)
187 $(CC
) -O2
-Wall
-c
-o
$@
$<
189 install: tcc_install libinstall
191 tcc_install
: $(PROGS
) tcc
.1 libtcc1
$(LIBSUF
) $(BCHECK_O
) tcc-doc.html tcc
.1
193 $(INSTALL
) -s
-m755
$(PROGS
) "$(bindir)"
195 mkdir
-p
"$(mandir)/man1"
196 $(INSTALL
) tcc
.1 "$(mandir)/man1"
199 mkdir
-p
"$(tccdir)/include"
200 mkdir
-p
"$(tccdir)/lib"
202 $(INSTALL
) -m644 libtcc1
$(LIBSUF
) win32
/lib
/*.def
"$(tccdir)/lib"
203 cp
-r win32
/include "$(tccdir)/include"
204 cp
-r win32
/examples
"$(tccdir)/examples"
206 $(INSTALL
) -m644 libtcc1
$(LIBSUF
) $(BCHECK_O
) "$(tccdir)/lib"
207 $(INSTALL
) -m644 stdarg.h stddef.h stdbool.h float.h varargs.h \
208 tcclib.h
"$(tccdir)/include"
211 $(INSTALL
) -m644 tcc-doc.html
"$(docdir)"
213 $(INSTALL
) -m644 win32
/readme.txt
"$(docdir)"
217 rm -f
*~
*.o tcc tcc1 tcct tcc_g tcctest.ref
*.bin
*.i ex2 \
218 core gmon.out
test.out
test.ref a.out tcc_p \
219 *.exe tcc-doc.html tcc.pod tcc
.1 libtcc
$(LIBSUF
) libtcc_test \
220 tcctest
[1234] test[1234].out
$(PROGS
) win32
/lib
/*.o
223 rm -f config.h config.mak config.texi
226 tcc_p
: tcc.c Makefile
227 $(CC
) $(CFLAGS_P
) -o
$@
$< $(LIBS_P
)
229 # libtcc generation and example
230 libinstall
: libtcc
$(LIBSUF
)
232 $(INSTALL
) -m644 libtcc
$(LIBSUF
) "$(libdir)"
233 mkdir
-p
"$(includedir)"
234 $(INSTALL
) -m644 libtcc.h
"$(includedir)"
236 libtcc.o
: tcc.c i386-gen.c Makefile
237 $(CC
) $(CFLAGS
) -DLIBTCC
-c
-o
$@
$<
239 libtcc
$(LIBSUF
): libtcc.o
242 libtcc_test
$(EXESUF
): libtcc_test.c libtcc
$(LIBSUF
)
243 $(CC
) $(CFLAGS
) -o
$@
$< libtcc
$(LIBSUF
) $(LIBS
)
248 # targets for development
257 # tiny assembler testing
259 asmtest.ref
: asmtest.S
260 $(CC
) -c
-o asmtest.ref.o asmtest.S
261 objdump
-D asmtest.ref.o
> $@
263 # XXX: we compute tcc.c to go faster during development !
264 asmtest.out
: asmtest.S tcc
265 # ./tcc tcc.c -c asmtest.S
266 #asmtest.out: asmtest.S tcc
268 objdump
-D asmtest.o
> $@
270 asmtest
: asmtest.out asmtest.ref
271 @if diff
-u
--ignore-matching-lines
="file format" asmtest.ref asmtest.out
; then echo
"ASM Auto Test OK"; fi
274 $(CC
) -O2
-Wall
-g
-c
-o
$@
$<
277 cachegrind .
/tcc_g
-o
/tmp
/linpack
-lm bench
/linpack.c
278 vg_annotate tcc.c
> /tmp
/linpack.cache.log
280 # documentation and man page
281 tcc-doc.html
: tcc-doc.texi
282 texi2html
-monolithic
-number
$<
285 .
/texi2pod.pl
$< tcc.pod
286 pod2man
--section
=1 --center
=" " --release
=" " tcc.pod
> $@
288 FILES
= Makefile Makefile.uClibc configure VERSION \
289 README TODO COPYING \
290 Changelog tcc-doc.texi tcc-doc.html \
292 tcc.c tccelf.c tcctok.h tccasm.c i386-asm.c i386-asm.h \
294 i386-gen.c c67-gen.c arm-gen.c \
296 elf.h stab.h stab.def \
297 stddef.h stdarg.h stdbool.h float.h varargs.h \
298 tcclib.h libtcc.h libtcc_test.c \
299 ex1.c ex2.c ex3.c ex4.c ex5.c \
300 tcctest.c boundtest.c gcctestsuite.sh texi2pod.pl
306 mkdir
-p
/tmp
/$(FILE
)
307 cp
-P
$(FILES
) /tmp
/$(FILE
)
308 ( cd
/tmp
; tar zcvf ~
/$(FILE
).
tar.gz
$(FILE
) )