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 # run local version of tcc with local libraries and includes
58 libtcc1.a
$(BCHECK_O
) tcc-doc.html tcc
.1 libtcc.a \
65 test: test.ref
test.out
66 @if diff
-u
test.ref
test.out
; then echo
"Auto Test OK"; fi
68 tcctest.ref
: tcctest.c
69 $(CC
) $(CFLAGS
) -w
-I.
-o
$@
$<
74 test.out
: tcc tcctest.c
75 $(TCC
) -run tcctest.c
> $@
80 # iterated test2 (compile tcc then compile tcctest.c !)
81 test2
: tcc tcc.c tcctest.c
test.ref
82 $(TCC
) -run tcc.c
-B.
-I.
-run tcctest.c
> test.out2
83 @if diff
-u
test.ref
test.out2
; then echo
"Auto Test2 OK"; fi
85 # iterated test3 (compile tcc then compile tcc then compile tcctest.c !)
86 test3
: tcc tcc.c tcctest.c
test.ref
87 $(TCC
) -run tcc.c
-B.
-I.
-run tcc.c
-B.
-I.
-run tcctest.c
> test.out3
88 @if diff
-u
test.ref
test.out3
; then echo
"Auto Test3 OK"; fi
93 $(TCC
) -o tcctest1 tcctest.c
94 .
/tcctest1
> test1.out
95 @if diff
-u
test.ref test1.out
; then echo
"Dynamic Auto Test OK"; fi
97 $(TCC
) -static
-o tcctest2 tcctest.c
98 .
/tcctest2
> test2.out
99 @if diff
-u
test.ref test2.out
; then echo
"Static Auto Test OK"; fi
100 # object + link output
101 $(TCC
) -c
-o tcctest3.o tcctest.c
102 $(TCC
) -o tcctest3 tcctest3.o
103 .
/tcctest3
> test3.out
104 @if diff
-u
test.ref test3.out
; then echo
"Object Auto Test OK"; fi
105 # dynamic output + bound check
106 $(TCC
) -b
-o tcctest4 tcctest.c
107 .
/tcctest4
> test4.out
108 @if diff
-u
test.ref test4.out
; then echo
"BCheck Auto Test OK"; fi
110 # memory and bound check auto test
112 BOUNDS_FAIL
= 2 5 7 9 11 12 13
114 btest
: boundtest.c tcc
115 @for i in
$(BOUNDS_OK
); do \
116 if
$(TCC
) -b
-run boundtest.c
$$i ; then \
119 echo Failed positive
test $$i ; exit
1 ; \
122 for i in
$(BOUNDS_FAIL
); do \
123 if
$(TCC
) -b
-run boundtest.c
$$i ; then \
124 echo Failed negative
test $$i ; exit
1 ;\
133 time .
/ex2
1238 2 3 4 10 13 4
134 time .
/tcc
-I. .
/ex2.c
1238 2 3 4 10 13 4
136 time .
/tcc
-I. .
/ex3.c
35
139 $(CC
) $(CFLAGS
) -o
$@
$<
142 $(CC
) $(CFLAGS
) -o
$@
$<
144 # Host Tiny C Compiler
146 tcc
$(EXESUF
): tcc.c i386-gen.c tccelf.c tccasm.c i386-asm.c tcctok.h libtcc.h i386-asm.h tccpe.c
147 $(CC
) $(CFLAGS
) -DTCC_TARGET_PE
-o
$@
$< $(LIBS
)
150 tcc
$(EXESUF
): tcc.c i386-gen.c tccelf.c tccasm.c i386-asm.c tcctok.h libtcc.h i386-asm.h
151 $(CC
) $(CFLAGS
) -o
$@
$< $(LIBS
)
154 ARMFLAGS
= $(if
$(wildcard /lib
/ld-linux.so
.3),-DTCC_ARM_EABI
)
155 ARMFLAGS
+= $(if
$(shell grep
-l
"^Features.* \(vfp\|iwmmxt\) " /proc
/cpuinfo
),-DTCC_ARM_VFP
)
157 tcc
$(EXESUF
): tcc.c arm-gen.c tccelf.c tccasm.c tcctok.h libtcc.h
158 $(CC
) $(CFLAGS
) -DTCC_TARGET_ARM
$(ARMFLAGS
) -o
$@
$< $(LIBS
)
162 # Cross Tiny C Compilers
163 i386-tcc
$(EXESUF
): tcc.c i386-gen.c tccelf.c tccasm.c i386-asm.c tcctok.h libtcc.h i386-asm.h
164 $(CC
) $(CFLAGS
) -o
$@
$< $(LIBS
)
166 c67-tcc
$(EXESUF
): tcc.c c67-gen.c tccelf.c tccasm.c tcctok.h libtcc.h tcccoff.c
167 $(CC
) $(CFLAGS
) -DTCC_TARGET_C67
-o
$@
$< $(LIBS
)
169 arm-tcc-fpa
$(EXESUF
): tcc.c arm-gen.c tccelf.c tccasm.c tcctok.h libtcc.h
170 $(CC
) $(CFLAGS
) -DTCC_TARGET_ARM
-o
$@
$< $(LIBS
)
172 arm-tcc-fpa-ld
$(EXESUF
): tcc.c arm-gen.c tccelf.c tccasm.c tcctok.h libtcc.h
173 $(CC
) $(CFLAGS
) -DTCC_TARGET_ARM
-DLDOUBLE_SIZE
=12 -o
$@
$< $(LIBS
)
175 arm-tcc-vfp
$(EXESUF
): tcc.c arm-gen.c tccelf.c tccasm.c tcctok.h libtcc.h
176 $(CC
) $(CFLAGS
) -DTCC_TARGET_ARM
-DTCC_ARM_VFP
-o
$@
$< $(LIBS
)
178 arm-tcc-vfp-eabi
$(EXESUF
): tcc.c arm-gen.c tccelf.c tccasm.c tcctok.h libtcc.h
179 $(CC
) $(CFLAGS
) -DTCC_TARGET_ARM
-DTCC_ARM_EABI
-o
$@
$< $(LIBS
)
181 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
182 $(CC
) $(CFLAGS
) -DTCC_TARGET_PE
-o
$@
$< $(LIBS
)
185 tiny_impdef
$(EXESUF
): win32
/tools
/tiny_impdef.c
186 $(CC
) $(CFLAGS
) -o
$@
$< -lkernel32
187 tiny_libmaker
$(EXESUF
): win32
/tools
/tiny_libmaker.c
188 $(CC
) $(CFLAGS
) -o
$@
$< -lkernel32
190 # TinyCC runtime libraries
192 # for windows, we must use TCC because we generate ELF objects
193 LIBTCC1_OBJS
=$(addprefix win32
/lib
/, crt1.o wincrt1.o dllcrt1.o dllmain.o chkstk.o
) libtcc1.o
194 LIBTCC1_CC
=.
/tcc.exe
-Bwin32
-DTCC_TARGET_PE
196 LIBTCC1_OBJS
=libtcc1.o
200 LIBTCC1_OBJS
+=alloca86.o alloca86-bt.o
204 $(LIBTCC1_CC
) -O2
-Wall
-c
-o
$@
$<
207 $(LIBTCC1_CC
) -c
-o
$@
$<
209 libtcc1.a
: $(LIBTCC1_OBJS
)
213 $(CC
) -O2
-Wall
-c
-o
$@
$<
215 install: tcc_install libinstall
217 tcc_install
: $(PROGS
) tcc
.1 libtcc1.a
$(BCHECK_O
) tcc-doc.html
218 mkdir
-p
"$(DESTDIR)$(bindir)"
219 $(INSTALL
) -s
-m755
$(PROGS
) "$(DESTDIR)$(bindir)"
221 mkdir
-p
"$(DESTDIR)$(mandir)/man1"
222 $(INSTALL
) tcc
.1 "$(DESTDIR)$(mandir)/man1"
224 mkdir
-p
"$(DESTDIR)$(tccdir)"
225 mkdir
-p
"$(DESTDIR)$(tccdir)/include"
227 mkdir
-p
"$(DESTDIR)$(tccdir)/lib"
228 $(INSTALL
) -m644 libtcc1.a win32
/lib
/*.def
"$(DESTDIR)$(tccdir)/lib"
229 cp
-r win32
/include/.
"$(DESTDIR)$(tccdir)/include"
230 cp
-r win32
/examples
/.
"$(DESTDIR)$(tccdir)/examples"
232 $(INSTALL
) -m644 libtcc1.a
$(BCHECK_O
) "$(DESTDIR)$(tccdir)"
233 $(INSTALL
) -m644 stdarg.h stddef.h stdbool.h float.h varargs.h \
234 tcclib.h
"$(DESTDIR)$(tccdir)/include"
236 mkdir
-p
"$(DESTDIR)$(docdir)"
237 $(INSTALL
) -m644 tcc-doc.html
"$(DESTDIR)$(docdir)"
239 $(INSTALL
) -m644 win32
/readme.txt
"$(DESTDIR)$(docdir)"
243 rm -f
*~
*.o
*.a tcc tcct tcc_g tcctest.ref
*.bin
*.i ex2 \
244 core gmon.out
test.out
test.ref a.out tcc_p \
245 *.exe
*.lib tcc.pod libtcc_test \
246 tcctest
[1234] test[1234].out
$(PROGS
) win32
/lib
/*.o
249 rm -f config.h config.mak config.texi
252 tcc_p
: tcc.c Makefile
253 $(CC
) $(CFLAGS_P
) -o
$@
$< $(LIBS_P
)
255 # libtcc generation and example
257 mkdir
-p
"$(DESTDIR)$(libdir)"
258 $(INSTALL
) -m644 libtcc.a
"$(DESTDIR)$(libdir)"
259 mkdir
-p
"$(DESTDIR)$(includedir)"
260 $(INSTALL
) -m644 libtcc.h
"$(DESTDIR)$(includedir)"
262 libtcc.o
: tcc.c i386-gen.c Makefile
264 $(CC
) $(CFLAGS
) -DTCC_TARGET_PE
-DLIBTCC
-c
-o
$@
$<
266 $(CC
) $(CFLAGS
) -DLIBTCC
-c
-o
$@
$<
272 libtcc_test
$(EXESUF
): libtcc_test.c libtcc.a
273 $(CC
) $(CFLAGS
) -o
$@
$< libtcc.a
$(LIBS
)
278 # targets for development
287 # tiny assembler testing
289 asmtest.ref
: asmtest.S
290 $(CC
) -c
-o asmtest.ref.o asmtest.S
291 objdump
-D asmtest.ref.o
> $@
293 # XXX: we compute tcc.c to go faster during development !
294 asmtest.out
: asmtest.S tcc
295 # ./tcc tcc.c -c asmtest.S
296 #asmtest.out: asmtest.S tcc
298 objdump
-D asmtest.o
> $@
300 asmtest
: asmtest.out asmtest.ref
301 @if diff
-u
--ignore-matching-lines
="file format" asmtest.ref asmtest.out
; then echo
"ASM Auto Test OK"; fi
304 $(CC
) -O2
-Wall
-g
-c
-o
$@
$<
307 cachegrind .
/tcc_g
-o
/tmp
/linpack
-lm bench
/linpack.c
308 vg_annotate tcc.c
> /tmp
/linpack.cache.log
310 # documentation and man page
311 tcc-doc.html
: tcc-doc.texi
312 -texi2html
-monolithic
-number
$<
315 -.
/texi2pod.pl
$< tcc.pod
316 -pod2man
--section
=1 --center
=" " --release
=" " tcc.pod
> $@
318 FILE
=tcc-
$(shell cat VERSION
)
320 # tar release (use 'make -k tar' on a checkouted tree)
324 ( cd
/tmp
; tar zcvf ~
/$(FILE
).
tar.gz
$(FILE
) --exclude CVS
)