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.a
$(BCHECK_O
) tcc-doc.html tcc
.1 libtcc.a \
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 # for windows, we must use TCC because we generate ELF objects
173 LIBTCC1_OBJS
=$(addprefix win32
/lib
/, crt1.o wincrt1.o dllcrt1.o dllmain.o chkstk.o
) libtcc1.o
174 LIBTCC1_CC
=.
/tcc.exe
-Bwin32
176 LIBTCC1_OBJS
=libtcc1.o
181 $(LIBTCC1_CC
) -O2
-Wall
-c
-o
$@
$<
184 $(LIBTCC1_CC
) -c
-o
$@
$<
186 libtcc1.a
: $(LIBTCC1_OBJS
)
190 $(CC
) -O2
-Wall
-c
-o
$@
$<
192 install: tcc_install libinstall
194 tcc_install
: $(PROGS
) tcc
.1 libtcc1.a
$(BCHECK_O
) tcc-doc.html tcc
.1
196 $(INSTALL
) -s
-m755
$(PROGS
) "$(bindir)"
198 mkdir
-p
"$(mandir)/man1"
199 $(INSTALL
) tcc
.1 "$(mandir)/man1"
202 mkdir
-p
"$(tccdir)/include"
204 mkdir
-p
"$(tccdir)/lib"
205 $(INSTALL
) -m644 libtcc1.a win32
/lib
/*.def
"$(tccdir)/lib"
206 cp
-r win32
/include/.
"$(tccdir)/include"
207 cp
-r win32
/examples
/.
"$(tccdir)/examples"
209 $(INSTALL
) -m644 libtcc1.a
$(BCHECK_O
) "$(tccdir)"
210 $(INSTALL
) -m644 stdarg.h stddef.h stdbool.h float.h varargs.h \
211 tcclib.h
"$(tccdir)/include"
214 $(INSTALL
) -m644 tcc-doc.html
"$(docdir)"
216 $(INSTALL
) -m644 win32
/readme.txt
"$(docdir)"
220 rm -f
*~
*.o
*.a tcc tcc1 tcct tcc_g tcctest.ref
*.bin
*.i ex2 \
221 core gmon.out
test.out
test.ref a.out tcc_p \
222 *.exe
*.lib tcc.pod libtcc_test \
223 tcctest
[1234] test[1234].out
$(PROGS
) win32
/lib
/*.o
226 rm -f config.h config.mak config.texi
229 tcc_p
: tcc.c Makefile
230 $(CC
) $(CFLAGS_P
) -o
$@
$< $(LIBS_P
)
232 # libtcc generation and example
235 $(INSTALL
) -m644 libtcc.a
"$(libdir)"
236 mkdir
-p
"$(includedir)"
237 $(INSTALL
) -m644 libtcc.h
"$(includedir)"
239 libtcc.o
: tcc.c i386-gen.c Makefile
240 $(CC
) $(CFLAGS
) -DLIBTCC
-c
-o
$@
$<
245 libtcc_test
$(EXESUF
): libtcc_test.c libtcc.a
246 $(CC
) $(CFLAGS
) -o
$@
$< libtcc.a
$(LIBS
)
251 # targets for development
260 # tiny assembler testing
262 asmtest.ref
: asmtest.S
263 $(CC
) -c
-o asmtest.ref.o asmtest.S
264 objdump
-D asmtest.ref.o
> $@
266 # XXX: we compute tcc.c to go faster during development !
267 asmtest.out
: asmtest.S tcc
268 # ./tcc tcc.c -c asmtest.S
269 #asmtest.out: asmtest.S tcc
271 objdump
-D asmtest.o
> $@
273 asmtest
: asmtest.out asmtest.ref
274 @if diff
-u
--ignore-matching-lines
="file format" asmtest.ref asmtest.out
; then echo
"ASM Auto Test OK"; fi
277 $(CC
) -O2
-Wall
-g
-c
-o
$@
$<
280 cachegrind .
/tcc_g
-o
/tmp
/linpack
-lm bench
/linpack.c
281 vg_annotate tcc.c
> /tmp
/linpack.cache.log
283 # documentation and man page
284 tcc-doc.html
: tcc-doc.texi
285 texi2html
-monolithic
-number
$<
288 .
/texi2pod.pl
$< tcc.pod
289 pod2man
--section
=1 --center
=" " --release
=" " tcc.pod
> $@
291 FILE
=tcc-
$(shell cat VERSION
)
293 # tar release (use 'make -k tar' on a checkouted tree)
297 ( cd
/tmp
; tar zcvf ~
/$(FILE
).
tar.gz
$(FILE
) --exclude CVS
)