2 # Tiny C Compiler Makefile
8 CFLAGS
+=-Wno-pointer-sign
16 ifneq ($(ARCH
),x86-64
)
20 CFLAGS_P
=$(CFLAGS
) -pg
-static
-DCONFIG_TCC_STATIC
23 ifneq ($(GCC_MAJOR
),2)
24 CFLAGS
+=-fno-strict-aliasing
28 CFLAGS
+=-mpreferred-stack-boundary
=2
30 CFLAGS
+=-m386
-malign-functions
=0
32 CFLAGS
+=-march
=i386
-falign-functions
=0
33 ifneq ($(GCC_MAJOR
),3)
34 CFLAGS
+=-Wno-pointer-sign
-Wno-sign-compare
45 PROGS
+=c67-tcc
$(EXESUF
) arm-tcc-fpa
$(EXESUF
) arm-tcc-fpa-ld
$(EXESUF
) arm-tcc-vfp
$(EXESUF
) arm-tcc-vfp-eabi
$(EXESUF
)
47 PROGS
+=tiny_impdef
$(EXESUF
) tiny_libmaker
$(EXESUF
)
52 PROGS
+=arm-tcc-fpa
$(EXESUF
) arm-tcc-fpa-ld
$(EXESUF
) arm-tcc-vfp
$(EXESUF
) arm-tcc-vfp-eabi
$(EXESUF
)
58 PROGS
+=i386-tcc
$(EXESUF
)
62 PROGS
+=c67-tcc
$(EXESUF
) i386-win32-tcc
$(EXESUF
)
69 ifdef CONFIG_USE_LIBGCC
75 # run local version of tcc with local libraries and includes
79 $(LIBTCC1
) $(BCHECK_O
) tcc-doc.html tcc
.1 libtcc.a \
86 test: test.ref
test.out
87 @if diff
-u
test.ref
test.out
; then echo
"Auto Test OK"; fi
89 tcctest.ref
: tcctest.c
90 $(CC
) $(CFLAGS
) -w
-I.
-o
$@
$<
95 test.out
: tcc tcctest.c
96 $(TCC
) -run tcctest.c
> $@
101 # iterated test2 (compile tcc then compile tcctest.c !)
102 test2
: tcc tcc.c tcctest.c
test.ref
103 $(TCC
) -run tcc.c
-B.
-I.
-run tcctest.c
> test.out2
104 @if diff
-u
test.ref
test.out2
; then echo
"Auto Test2 OK"; fi
106 # iterated test3 (compile tcc then compile tcc then compile tcctest.c !)
107 test3
: tcc tcc.c tcctest.c
test.ref
108 $(TCC
) -run tcc.c
-B.
-I.
-run tcc.c
-B.
-I.
-run tcctest.c
> test.out3
109 @if diff
-u
test.ref
test.out3
; then echo
"Auto Test3 OK"; fi
114 $(TCC
) -o tcctest1 tcctest.c
115 .
/tcctest1
> test1.out
116 @if diff
-u
test.ref test1.out
; then echo
"Dynamic Auto Test OK"; fi
118 $(TCC
) -static
-o tcctest2 tcctest.c
119 .
/tcctest2
> test2.out
120 @if diff
-u
test.ref test2.out
; then echo
"Static Auto Test OK"; fi
121 # object + link output
122 $(TCC
) -c
-o tcctest3.o tcctest.c
123 $(TCC
) -o tcctest3 tcctest3.o
124 .
/tcctest3
> test3.out
125 @if diff
-u
test.ref test3.out
; then echo
"Object Auto Test OK"; fi
126 # dynamic output + bound check
127 $(TCC
) -b
-o tcctest4 tcctest.c
128 .
/tcctest4
> test4.out
129 @if diff
-u
test.ref test4.out
; then echo
"BCheck Auto Test OK"; fi
131 # memory and bound check auto test
133 BOUNDS_FAIL
= 2 5 7 9 11 12 13
135 btest
: boundtest.c tcc
136 @for i in
$(BOUNDS_OK
); do \
137 if
$(TCC
) -b
-run boundtest.c
$$i ; then \
140 echo Failed positive
test $$i ; exit
1 ; \
143 for i in
$(BOUNDS_FAIL
); do \
144 if
$(TCC
) -b
-run boundtest.c
$$i ; then \
145 echo Failed negative
test $$i ; exit
1 ;\
154 time .
/ex2
1238 2 3 4 10 13 4
155 time .
/tcc
-I. .
/ex2.c
1238 2 3 4 10 13 4
157 time .
/tcc
-I. .
/ex3.c
35
160 $(CC
) $(CFLAGS
) -o
$@
$<
163 $(CC
) $(CFLAGS
) -o
$@
$<
165 # Host Tiny C Compiler
167 tcc
$(EXESUF
): tcc.c i386-gen.c tccelf.c tccasm.c i386-asm.c tcctok.h libtcc.h i386-asm.h tccpe.c
168 $(CC
) $(CFLAGS
) -DTCC_TARGET_PE
-o
$@
$< $(LIBS
)
171 tcc
$(EXESUF
): tcc.c i386-gen.c tccelf.c tccasm.c i386-asm.c tcctok.h libtcc.h i386-asm.h
172 $(CC
) $(CFLAGS
) -o
$@
$< $(LIBS
)
175 ARMFLAGS
= $(if
$(wildcard /lib
/ld-linux.so
.3),-DTCC_ARM_EABI
)
176 ARMFLAGS
+= $(if
$(shell grep
-l
"^Features.* \(vfp\|iwmmxt\) " /proc
/cpuinfo
),-DTCC_ARM_VFP
)
178 tcc
$(EXESUF
): tcc.c arm-gen.c tccelf.c tccasm.c tcctok.h libtcc.h
179 $(CC
) $(CFLAGS
) -DTCC_TARGET_ARM
$(ARMFLAGS
) -o
$@
$< $(LIBS
)
181 ifeq ($(ARCH
),x86-64
)
182 tcc
$(EXESUF
): tcc.c tccelf.c tccasm.c tcctok.h libtcc.h x86_64-gen.c
183 $(CC
) $(CFLAGS
) -DTCC_TARGET_X86_64
-o
$@
$< $(LIBS
)
187 # Cross Tiny C Compilers
188 i386-tcc
$(EXESUF
): tcc.c i386-gen.c tccelf.c tccasm.c i386-asm.c tcctok.h libtcc.h i386-asm.h
189 $(CC
) $(CFLAGS
) -o
$@
$< $(LIBS
)
191 c67-tcc
$(EXESUF
): tcc.c c67-gen.c tccelf.c tccasm.c tcctok.h libtcc.h tcccoff.c
192 $(CC
) $(CFLAGS
) -DTCC_TARGET_C67
-o
$@
$< $(LIBS
)
194 arm-tcc-fpa
$(EXESUF
): tcc.c arm-gen.c tccelf.c tccasm.c tcctok.h libtcc.h
195 $(CC
) $(CFLAGS
) -DTCC_TARGET_ARM
-o
$@
$< $(LIBS
)
197 arm-tcc-fpa-ld
$(EXESUF
): tcc.c arm-gen.c tccelf.c tccasm.c tcctok.h libtcc.h
198 $(CC
) $(CFLAGS
) -DTCC_TARGET_ARM
-DLDOUBLE_SIZE
=12 -o
$@
$< $(LIBS
)
200 arm-tcc-vfp
$(EXESUF
): tcc.c arm-gen.c tccelf.c tccasm.c tcctok.h libtcc.h
201 $(CC
) $(CFLAGS
) -DTCC_TARGET_ARM
-DTCC_ARM_VFP
-o
$@
$< $(LIBS
)
203 arm-tcc-vfp-eabi
$(EXESUF
): tcc.c arm-gen.c tccelf.c tccasm.c tcctok.h libtcc.h
204 $(CC
) $(CFLAGS
) -DTCC_TARGET_ARM
-DTCC_ARM_EABI
-o
$@
$< $(LIBS
)
206 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
207 $(CC
) $(CFLAGS
) -DTCC_TARGET_PE
-o
$@
$< $(LIBS
)
210 tiny_impdef
$(EXESUF
): win32
/tools
/tiny_impdef.c
211 $(CC
) $(CFLAGS
) -o
$@
$< -lkernel32
212 tiny_libmaker
$(EXESUF
): win32
/tools
/tiny_libmaker.c
213 $(CC
) $(CFLAGS
) -o
$@
$< -lkernel32
215 # TinyCC runtime libraries
217 # for windows, we must use TCC because we generate ELF objects
218 LIBTCC1_OBJS
=$(addprefix win32
/lib
/, crt1.o wincrt1.o dllcrt1.o dllmain.o chkstk.o
) libtcc1.o
219 LIBTCC1_CC
=.
/tcc.exe
-Bwin32
-DTCC_TARGET_PE
221 LIBTCC1_OBJS
=libtcc1.o
225 LIBTCC1_OBJS
+=alloca86.o alloca86-bt.o
229 $(LIBTCC1_CC
) -O2
-Wall
-c
-o
$@
$<
232 $(LIBTCC1_CC
) -c
-o
$@
$<
234 libtcc1.a
: $(LIBTCC1_OBJS
)
238 $(CC
) -O2
-Wall
-c
-o
$@
$<
240 install: tcc_install libinstall
242 tcc_install
: $(PROGS
) tcc
.1 $(LIBTCC1
) $(BCHECK_O
) tcc-doc.html
243 mkdir
-p
"$(DESTDIR)$(bindir)"
244 $(INSTALL
) -s
-m755
$(PROGS
) "$(DESTDIR)$(bindir)"
246 mkdir
-p
"$(DESTDIR)$(mandir)/man1"
247 $(INSTALL
) tcc
.1 "$(DESTDIR)$(mandir)/man1"
249 mkdir
-p
"$(DESTDIR)$(tccdir)"
250 mkdir
-p
"$(DESTDIR)$(tccdir)/include"
252 mkdir
-p
"$(DESTDIR)$(tccdir)/lib"
253 $(INSTALL
) -m644
$(LIBTCC1
) win32
/lib
/*.def
"$(DESTDIR)$(tccdir)/lib"
254 cp
-r win32
/include/.
"$(DESTDIR)$(tccdir)/include"
255 cp
-r win32
/examples
/.
"$(DESTDIR)$(tccdir)/examples"
257 ifndef CONFIG_USE_LIBGCC
258 $(INSTALL
) -m644 libtcc1.a
"$(DESTDIR)$(tccdir)"
260 ifneq ($(ARCH
),x86-64
)
261 $(INSTALL
) -m644
$(BCHECK_O
) "$(DESTDIR)$(tccdir)"
263 $(INSTALL
) -m644 stdarg.h stddef.h stdbool.h float.h varargs.h \
264 tcclib.h
"$(DESTDIR)$(tccdir)/include"
266 mkdir
-p
"$(DESTDIR)$(docdir)"
267 $(INSTALL
) -m644 tcc-doc.html
"$(DESTDIR)$(docdir)"
269 $(INSTALL
) -m644 win32
/readme.txt
"$(DESTDIR)$(docdir)"
273 rm -f
*~
*.o
*.a tcc tcct tcc_g tcctest.ref
*.bin
*.i ex2 \
274 core gmon.out
test.out
test.ref a.out tcc_p \
275 *.exe
*.lib tcc.pod libtcc_test \
276 tcctest
[1234] test[1234].out
$(PROGS
) win32
/lib
/*.o
279 rm -f config.h config.mak config.texi
282 tcc_p
: tcc.c Makefile
283 $(CC
) $(CFLAGS_P
) -o
$@
$< $(LIBS_P
)
285 # libtcc generation and example
287 mkdir
-p
"$(DESTDIR)$(libdir)"
288 $(INSTALL
) -m644 libtcc.a
"$(DESTDIR)$(libdir)"
289 mkdir
-p
"$(DESTDIR)$(includedir)"
290 $(INSTALL
) -m644 libtcc.h
"$(DESTDIR)$(includedir)"
292 libtcc.o
: tcc.c i386-gen.c Makefile
294 $(CC
) $(CFLAGS
) -DTCC_TARGET_PE
-DLIBTCC
-c
-o
$@
$<
296 ifeq ($(ARCH
),x86-64
)
297 $(CC
) $(CFLAGS
) -DTCC_TARGET_X86_64
-DLIBTCC
-c
-o
$@
$<
299 $(CC
) $(CFLAGS
) -DLIBTCC
-c
-o
$@
$<
306 libtcc_test
$(EXESUF
): libtcc_test.c libtcc.a
307 $(CC
) $(CFLAGS
) -o
$@
$< libtcc.a
$(LIBS
)
312 # targets for development
321 # tiny assembler testing
323 asmtest.ref
: asmtest.S
324 $(CC
) -c
-o asmtest.ref.o asmtest.S
325 objdump
-D asmtest.ref.o
> $@
327 # XXX: we compute tcc.c to go faster during development !
328 asmtest.out
: asmtest.S tcc
329 # ./tcc tcc.c -c asmtest.S
330 #asmtest.out: asmtest.S tcc
332 objdump
-D asmtest.o
> $@
334 asmtest
: asmtest.out asmtest.ref
335 @if diff
-u
--ignore-matching-lines
="file format" asmtest.ref asmtest.out
; then echo
"ASM Auto Test OK"; fi
338 $(CC
) -O2
-Wall
-g
-c
-o
$@
$<
341 cachegrind .
/tcc_g
-o
/tmp
/linpack
-lm bench
/linpack.c
342 vg_annotate tcc.c
> /tmp
/linpack.cache.log
344 # documentation and man page
345 tcc-doc.html
: tcc-doc.texi
346 -texi2html
-monolithic
-number
$<
349 -.
/texi2pod.pl
$< tcc.pod
350 -pod2man
--section
=1 --center
=" " --release
=" " tcc.pod
> $@
352 FILE
=tcc-
$(shell cat VERSION
)
354 # tar release (use 'make -k tar' on a checkouted tree)
358 ( cd
/tmp
; tar zcvf ~
/$(FILE
).
tar.gz
$(FILE
) --exclude CVS
)