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
$(EXESUF
)
35 PROGS
+=tiny_impdef
$(EXESUF
) tiny_libmaker
$(EXESUF
)
40 PROGS
+=arm-tcc
$(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
) -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 tcc
$(EXESUF
): tcc.c arm-gen.c tccelf.c tccasm.c tcctok.h libtcc.h
155 $(CC
) $(CFLAGS
) -DTCC_TARGET_ARM
-o
$@
$< $(LIBS
)
159 # Cross Tiny C Compilers
160 i386-tcc
$(EXESUF
): tcc.c i386-gen.c tccelf.c tccasm.c i386-asm.c tcctok.h libtcc.h i386-asm.h
161 $(CC
) $(CFLAGS
) -o
$@
$< $(LIBS
)
163 c67-tcc
$(EXESUF
): tcc.c c67-gen.c tccelf.c tccasm.c tcctok.h libtcc.h tcccoff.c
164 $(CC
) $(CFLAGS
) -DTCC_TARGET_C67
-o
$@
$< $(LIBS
)
166 arm-tcc
$(EXESUF
): tcc.c arm-gen.c tccelf.c tccasm.c tcctok.h libtcc.h
167 $(CC
) $(CFLAGS
) -DTCC_TARGET_ARM
-DTCC_ARM_EABI
-o
$@
$< $(LIBS
)
169 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
170 $(CC
) $(CFLAGS
) -DTCC_TARGET_PE
-o
$@
$< $(LIBS
)
173 tiny_impdef
$(EXESUF
): win32
/tools
/tiny_impdef.c
174 $(CC
) $(CFLAGS
) -o
$@
$< -lkernel32
175 tiny_libmaker
$(EXESUF
): win32
/tools
/tiny_libmaker.c
176 $(CC
) $(CFLAGS
) -o
$@
$< -lkernel32
178 # TinyCC runtime libraries
180 # for windows, we must use TCC because we generate ELF objects
181 LIBTCC1_OBJS
=$(addprefix win32
/lib
/, crt1.o wincrt1.o dllcrt1.o dllmain.o chkstk.o
) libtcc1.o
182 LIBTCC1_CC
=.
/tcc.exe
-Bwin32
-DTCC_TARGET_PE
184 LIBTCC1_OBJS
=libtcc1.o
188 LIBTCC1_OBJS
+=alloca86.o alloca86-bt.o
192 $(LIBTCC1_CC
) -O2
-Wall
-c
-o
$@
$<
195 $(LIBTCC1_CC
) -c
-o
$@
$<
197 libtcc1.a
: $(LIBTCC1_OBJS
)
201 $(CC
) -O2
-Wall
-c
-o
$@
$<
203 install: tcc_install libinstall
205 tcc_install
: $(PROGS
) tcc
.1 libtcc1.a
$(BCHECK_O
) tcc-doc.html
207 $(INSTALL
) -s
-m755
$(PROGS
) "$(bindir)"
209 mkdir
-p
"$(mandir)/man1"
210 $(INSTALL
) tcc
.1 "$(mandir)/man1"
213 mkdir
-p
"$(tccdir)/include"
215 mkdir
-p
"$(tccdir)/lib"
216 $(INSTALL
) -m644 libtcc1.a win32
/lib
/*.def
"$(tccdir)/lib"
217 cp
-r win32
/include/.
"$(tccdir)/include"
218 cp
-r win32
/examples
/.
"$(tccdir)/examples"
220 $(INSTALL
) -m644 libtcc1.a
$(BCHECK_O
) "$(tccdir)"
221 $(INSTALL
) -m644 stdarg.h stddef.h stdbool.h float.h varargs.h \
222 tcclib.h
"$(tccdir)/include"
225 $(INSTALL
) -m644 tcc-doc.html
"$(docdir)"
227 $(INSTALL
) -m644 win32
/readme.txt
"$(docdir)"
231 rm -f
*~
*.o
*.a tcc tcct tcc_g tcctest.ref
*.bin
*.i ex2 \
232 core gmon.out
test.out
test.ref a.out tcc_p \
233 *.exe
*.lib tcc.pod libtcc_test \
234 tcctest
[1234] test[1234].out
$(PROGS
) win32
/lib
/*.o
237 rm -f config.h config.mak config.texi
240 tcc_p
: tcc.c Makefile
241 $(CC
) $(CFLAGS_P
) -o
$@
$< $(LIBS_P
)
243 # libtcc generation and example
246 $(INSTALL
) -m644 libtcc.a
"$(libdir)"
247 mkdir
-p
"$(includedir)"
248 $(INSTALL
) -m644 libtcc.h
"$(includedir)"
250 libtcc.o
: tcc.c i386-gen.c Makefile
252 $(CC
) $(CFLAGS
) -DTCC_TARGET_PE
-DLIBTCC
-c
-o
$@
$<
254 $(CC
) $(CFLAGS
) -DLIBTCC
-c
-o
$@
$<
260 libtcc_test
$(EXESUF
): libtcc_test.c libtcc.a
261 $(CC
) $(CFLAGS
) -o
$@
$< libtcc.a
$(LIBS
)
266 # targets for development
275 # tiny assembler testing
277 asmtest.ref
: asmtest.S
278 $(CC
) -c
-o asmtest.ref.o asmtest.S
279 objdump
-D asmtest.ref.o
> $@
281 # XXX: we compute tcc.c to go faster during development !
282 asmtest.out
: asmtest.S tcc
283 # ./tcc tcc.c -c asmtest.S
284 #asmtest.out: asmtest.S tcc
286 objdump
-D asmtest.o
> $@
288 asmtest
: asmtest.out asmtest.ref
289 @if diff
-u
--ignore-matching-lines
="file format" asmtest.ref asmtest.out
; then echo
"ASM Auto Test OK"; fi
292 $(CC
) -O2
-Wall
-g
-c
-o
$@
$<
295 cachegrind .
/tcc_g
-o
/tmp
/linpack
-lm bench
/linpack.c
296 vg_annotate tcc.c
> /tmp
/linpack.cache.log
298 # documentation and man page
299 tcc-doc.html
: tcc-doc.texi
300 -texi2html
-monolithic
-number
$<
303 -.
/texi2pod.pl
$< tcc.pod
304 -pod2man
--section
=1 --center
=" " --release
=" " tcc.pod
> $@
306 FILE
=tcc-
$(shell cat VERSION
)
308 # tar release (use 'make -k tar' on a checkouted tree)
312 ( cd
/tmp
; tar zcvf ~
/$(FILE
).
tar.gz
$(FILE
) --exclude CVS
)