2 # Tiny C Compiler Makefile
14 CFLAGS_P
=$(CFLAGS
) -pg
-static
-DCONFIG_TCC_STATIC
17 CFLAGS
+=-mpreferred-stack-boundary
=2
19 CFLAGS
+=-m386
-malign-functions
=0
21 CFLAGS
+=-march
=i386
-falign-functions
=0 -fno-strict-aliasing
22 ifneq ($(GCC_MAJOR
),3)
23 CFLAGS
+=-Wno-pointer-sign
-Wno-sign-compare
33 PROGS
+=c67-tcc
$(EXESUF
) arm-tcc-fpa
$(EXESUF
) arm-tcc-fpa-ld
$(EXESUF
) arm-tcc-vfp
$(EXESUF
) arm-tcc-vfp-eabi
$(EXESUF
)
35 PROGS
+=tiny_impdef
$(EXESUF
) tiny_libmaker
$(EXESUF
)
40 PROGS
+=arm-tcc-fpa
$(EXESUF
) arm-tcc-fpa-ld
$(EXESUF
) arm-tcc-vfp
$(EXESUF
) arm-tcc-vfp-eabi
$(EXESUF
)
46 PROGS
+=i386-tcc
$(EXESUF
)
50 PROGS
+=c67-tcc
$(EXESUF
) i386-win32-tcc
$(EXESUF
)
54 ifdef CONFIG_USE_LIBGCC
60 # run local version of tcc with local libraries and includes
64 $(LIBTCC1
) $(BCHECK_O
) tcc-doc.html tcc
.1 libtcc.a \
71 test: test.ref
test.out
72 @if diff
-u
test.ref
test.out
; then echo
"Auto Test OK"; fi
74 tcctest.ref
: tcctest.c
75 $(CC
) $(CFLAGS
) -w
-I.
-o
$@
$<
80 test.out
: tcc tcctest.c
81 $(TCC
) -run tcctest.c
> $@
86 # iterated test2 (compile tcc then compile tcctest.c !)
87 test2
: tcc tcc.c tcctest.c
test.ref
88 $(TCC
) -run tcc.c
-B.
-I.
-run tcctest.c
> test.out2
89 @if diff
-u
test.ref
test.out2
; then echo
"Auto Test2 OK"; fi
91 # iterated test3 (compile tcc then compile tcc then compile tcctest.c !)
92 test3
: tcc tcc.c tcctest.c
test.ref
93 $(TCC
) -run tcc.c
-B.
-I.
-run tcc.c
-B.
-I.
-run tcctest.c
> test.out3
94 @if diff
-u
test.ref
test.out3
; then echo
"Auto Test3 OK"; fi
99 $(TCC
) -o tcctest1 tcctest.c
100 .
/tcctest1
> test1.out
101 @if diff
-u
test.ref test1.out
; then echo
"Dynamic Auto Test OK"; fi
103 $(TCC
) -static
-o tcctest2 tcctest.c
104 .
/tcctest2
> test2.out
105 @if diff
-u
test.ref test2.out
; then echo
"Static Auto Test OK"; fi
106 # object + link output
107 $(TCC
) -c
-o tcctest3.o tcctest.c
108 $(TCC
) -o tcctest3 tcctest3.o
109 .
/tcctest3
> test3.out
110 @if diff
-u
test.ref test3.out
; then echo
"Object Auto Test OK"; fi
111 # dynamic output + bound check
112 $(TCC
) -b
-o tcctest4 tcctest.c
113 .
/tcctest4
> test4.out
114 @if diff
-u
test.ref test4.out
; then echo
"BCheck Auto Test OK"; fi
116 # memory and bound check auto test
118 BOUNDS_FAIL
= 2 5 7 9 11 12 13
120 btest
: boundtest.c tcc
121 @for i in
$(BOUNDS_OK
); do \
122 if
$(TCC
) -b
-run boundtest.c
$$i ; then \
125 echo Failed positive
test $$i ; exit
1 ; \
128 for i in
$(BOUNDS_FAIL
); do \
129 if
$(TCC
) -b
-run boundtest.c
$$i ; then \
130 echo Failed negative
test $$i ; exit
1 ;\
139 time .
/ex2
1238 2 3 4 10 13 4
140 time .
/tcc
-I. .
/ex2.c
1238 2 3 4 10 13 4
142 time .
/tcc
-I. .
/ex3.c
35
145 $(CC
) $(CFLAGS
) -o
$@
$<
148 $(CC
) $(CFLAGS
) -o
$@
$<
150 # Host Tiny C Compiler
152 tcc
$(EXESUF
): tcc.c i386-gen.c tccelf.c tccasm.c i386-asm.c tcctok.h libtcc.h i386-asm.h tccpe.c
153 $(CC
) $(CFLAGS
) -DTCC_TARGET_PE
-o
$@
$< $(LIBS
)
156 tcc
$(EXESUF
): tcc.c i386-gen.c tccelf.c tccasm.c i386-asm.c tcctok.h libtcc.h i386-asm.h
157 $(CC
) $(CFLAGS
) -o
$@
$< $(LIBS
)
160 ARMFLAGS
= $(if
$(wildcard /lib
/ld-linux.so
.3),-DTCC_ARM_EABI
)
161 ARMFLAGS
+= $(if
$(shell grep
-l
"^Features.* \(vfp\|iwmmxt\) " /proc
/cpuinfo
),-DTCC_ARM_VFP
)
163 tcc
$(EXESUF
): tcc.c arm-gen.c tccelf.c tccasm.c tcctok.h libtcc.h
164 $(CC
) $(CFLAGS
) -DTCC_TARGET_ARM
$(ARMFLAGS
) -o
$@
$< $(LIBS
)
168 # Cross Tiny C Compilers
169 i386-tcc
$(EXESUF
): tcc.c i386-gen.c tccelf.c tccasm.c i386-asm.c tcctok.h libtcc.h i386-asm.h
170 $(CC
) $(CFLAGS
) -o
$@
$< $(LIBS
)
172 c67-tcc
$(EXESUF
): tcc.c c67-gen.c tccelf.c tccasm.c tcctok.h libtcc.h tcccoff.c
173 $(CC
) $(CFLAGS
) -DTCC_TARGET_C67
-o
$@
$< $(LIBS
)
175 arm-tcc-fpa
$(EXESUF
): tcc.c arm-gen.c tccelf.c tccasm.c tcctok.h libtcc.h
176 $(CC
) $(CFLAGS
) -DTCC_TARGET_ARM
-o
$@
$< $(LIBS
)
178 arm-tcc-fpa-ld
$(EXESUF
): tcc.c arm-gen.c tccelf.c tccasm.c tcctok.h libtcc.h
179 $(CC
) $(CFLAGS
) -DTCC_TARGET_ARM
-DLDOUBLE_SIZE
=12 -o
$@
$< $(LIBS
)
181 arm-tcc-vfp
$(EXESUF
): tcc.c arm-gen.c tccelf.c tccasm.c tcctok.h libtcc.h
182 $(CC
) $(CFLAGS
) -DTCC_TARGET_ARM
-DTCC_ARM_VFP
-o
$@
$< $(LIBS
)
184 arm-tcc-vfp-eabi
$(EXESUF
): tcc.c arm-gen.c tccelf.c tccasm.c tcctok.h libtcc.h
185 $(CC
) $(CFLAGS
) -DTCC_TARGET_ARM
-DTCC_ARM_EABI
-o
$@
$< $(LIBS
)
187 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
188 $(CC
) $(CFLAGS
) -DTCC_TARGET_PE
-o
$@
$< $(LIBS
)
191 tiny_impdef
$(EXESUF
): win32
/tools
/tiny_impdef.c
192 $(CC
) $(CFLAGS
) -o
$@
$< -lkernel32
193 tiny_libmaker
$(EXESUF
): win32
/tools
/tiny_libmaker.c
194 $(CC
) $(CFLAGS
) -o
$@
$< -lkernel32
196 # TinyCC runtime libraries
198 # for windows, we must use TCC because we generate ELF objects
199 LIBTCC1_OBJS
=$(addprefix win32
/lib
/, crt1.o wincrt1.o dllcrt1.o dllmain.o chkstk.o
) libtcc1.o
200 LIBTCC1_CC
=.
/tcc.exe
-Bwin32
-DTCC_TARGET_PE
202 LIBTCC1_OBJS
=libtcc1.o
206 LIBTCC1_OBJS
+=alloca86.o alloca86-bt.o
210 $(LIBTCC1_CC
) -O2
-Wall
-c
-o
$@
$<
213 $(LIBTCC1_CC
) -c
-o
$@
$<
215 libtcc1.a
: $(LIBTCC1_OBJS
)
219 $(CC
) -O2
-Wall
-c
-o
$@
$<
221 install: tcc_install libinstall
223 tcc_install
: $(PROGS
) tcc
.1 $(LIBTCC1
) $(BCHECK_O
) tcc-doc.html
224 mkdir
-p
"$(DESTDIR)$(bindir)"
225 $(INSTALL
) -s
-m755
$(PROGS
) "$(DESTDIR)$(bindir)"
227 mkdir
-p
"$(DESTDIR)$(mandir)/man1"
228 $(INSTALL
) tcc
.1 "$(DESTDIR)$(mandir)/man1"
230 mkdir
-p
"$(DESTDIR)$(tccdir)"
231 mkdir
-p
"$(DESTDIR)$(tccdir)/include"
233 mkdir
-p
"$(DESTDIR)$(tccdir)/lib"
234 $(INSTALL
) -m644
$(LIBTCC1
) win32
/lib
/*.def
"$(DESTDIR)$(tccdir)/lib"
235 cp
-r win32
/include/.
"$(DESTDIR)$(tccdir)/include"
236 cp
-r win32
/examples
/.
"$(DESTDIR)$(tccdir)/examples"
238 ifndef CONFIG_USE_LIBGCC
239 $(INSTALL
) -m644 libtcc1.a
"$(DESTDIR)$(tccdir)"
241 $(INSTALL
) -m644
$(BCHECK_O
) "$(DESTDIR)$(tccdir)"
242 $(INSTALL
) -m644 stdarg.h stddef.h stdbool.h float.h varargs.h \
243 tcclib.h
"$(DESTDIR)$(tccdir)/include"
245 mkdir
-p
"$(DESTDIR)$(docdir)"
246 $(INSTALL
) -m644 tcc-doc.html
"$(DESTDIR)$(docdir)"
248 $(INSTALL
) -m644 win32
/readme.txt
"$(DESTDIR)$(docdir)"
252 rm -f
*~
*.o
*.a tcc tcct tcc_g tcctest.ref
*.bin
*.i ex2 \
253 core gmon.out
test.out
test.ref a.out tcc_p \
254 *.exe
*.lib tcc.pod libtcc_test \
255 tcctest
[1234] test[1234].out
$(PROGS
) win32
/lib
/*.o
258 rm -f config.h config.mak config.texi
261 tcc_p
: tcc.c Makefile
262 $(CC
) $(CFLAGS_P
) -o
$@
$< $(LIBS_P
)
264 # libtcc generation and example
266 mkdir
-p
"$(DESTDIR)$(libdir)"
267 $(INSTALL
) -m644 libtcc.a
"$(DESTDIR)$(libdir)"
268 mkdir
-p
"$(DESTDIR)$(includedir)"
269 $(INSTALL
) -m644 libtcc.h
"$(DESTDIR)$(includedir)"
271 libtcc.o
: tcc.c i386-gen.c Makefile
273 $(CC
) $(CFLAGS
) -DTCC_TARGET_PE
-DLIBTCC
-c
-o
$@
$<
275 $(CC
) $(CFLAGS
) -DLIBTCC
-c
-o
$@
$<
281 libtcc_test
$(EXESUF
): libtcc_test.c libtcc.a
282 $(CC
) $(CFLAGS
) -o
$@
$< libtcc.a
$(LIBS
)
287 # targets for development
296 # tiny assembler testing
298 asmtest.ref
: asmtest.S
299 $(CC
) -c
-o asmtest.ref.o asmtest.S
300 objdump
-D asmtest.ref.o
> $@
302 # XXX: we compute tcc.c to go faster during development !
303 asmtest.out
: asmtest.S tcc
304 # ./tcc tcc.c -c asmtest.S
305 #asmtest.out: asmtest.S tcc
307 objdump
-D asmtest.o
> $@
309 asmtest
: asmtest.out asmtest.ref
310 @if diff
-u
--ignore-matching-lines
="file format" asmtest.ref asmtest.out
; then echo
"ASM Auto Test OK"; fi
313 $(CC
) -O2
-Wall
-g
-c
-o
$@
$<
316 cachegrind .
/tcc_g
-o
/tmp
/linpack
-lm bench
/linpack.c
317 vg_annotate tcc.c
> /tmp
/linpack.cache.log
319 # documentation and man page
320 tcc-doc.html
: tcc-doc.texi
321 -texi2html
-monolithic
-number
$<
324 -.
/texi2pod.pl
$< tcc.pod
325 -pod2man
--section
=1 --center
=" " --release
=" " tcc.pod
> $@
327 FILE
=tcc-
$(shell cat VERSION
)
329 # tar release (use 'make -k tar' on a checkouted tree)
333 ( cd
/tmp
; tar zcvf ~
/$(FILE
).
tar.gz
$(FILE
) --exclude CVS
)