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 CFLAGS
+=-Wno-pointer-sign
-Wno-sign-compare
31 PROGS
+=c67-tcc
$(EXESUF
) arm-tcc
$(EXESUF
)
33 PROGS
+=tiny_impdef
$(EXESUF
)
38 PROGS
+=arm-tcc
$(EXESUF
)
44 PROGS
+=i386-tcc
$(EXESUF
)
48 PROGS
+=c67-tcc
$(EXESUF
) i386-win32-tcc
$(EXESUF
)
52 # run local version of tcc with local libraries and includes
56 libtcc1.a
$(BCHECK_O
) tcc-doc.html tcc
.1 libtcc.a \
63 test: test.ref
test.out
64 @if diff
-u
test.ref
test.out
; then echo
"Auto Test OK"; fi
66 tcctest.ref
: tcctest.c
67 $(CC
) $(CFLAGS
) -I.
-o
$@
$<
72 test.out
: tcc tcctest.c
73 $(TCC
) -run tcctest.c
> $@
78 # iterated test2 (compile tcc then compile tcctest.c !)
79 test2
: tcc tcc.c tcctest.c
test.ref
80 $(TCC
) -run tcc.c
-B.
-I.
-run tcctest.c
> test.out2
81 @if diff
-u
test.ref
test.out2
; then echo
"Auto Test2 OK"; fi
83 # iterated test3 (compile tcc then compile tcc then compile tcctest.c !)
84 test3
: tcc tcc.c tcctest.c
test.ref
85 $(TCC
) -run tcc.c
-B.
-I.
-run tcc.c
-B.
-I.
-run tcctest.c
> test.out3
86 @if diff
-u
test.ref
test.out3
; then echo
"Auto Test3 OK"; fi
91 $(TCC
) -o tcctest1 tcctest.c
92 .
/tcctest1
> test1.out
93 @if diff
-u
test.ref test1.out
; then echo
"Dynamic Auto Test OK"; fi
95 $(TCC
) -static
-o tcctest2 tcctest.c
96 .
/tcctest2
> test2.out
97 @if diff
-u
test.ref test2.out
; then echo
"Static Auto Test OK"; fi
98 # object + link output
99 $(TCC
) -c
-o tcctest3.o tcctest.c
100 $(TCC
) -o tcctest3 tcctest3.o
101 .
/tcctest3
> test3.out
102 @if diff
-u
test.ref test3.out
; then echo
"Object Auto Test OK"; fi
103 # dynamic output + bound check
104 $(TCC
) -b
-o tcctest4 tcctest.c
105 .
/tcctest4
> test4.out
106 @if diff
-u
test.ref test4.out
; then echo
"BCheck Auto Test OK"; fi
108 # memory and bound check auto test
110 BOUNDS_FAIL
= 2 5 7 9 11 12 13
112 btest
: boundtest.c tcc
113 @for i in
$(BOUNDS_OK
); do \
114 if
$(TCC
) -b
-run boundtest.c
$$i ; then \
117 echo Failed positive
test $$i ; exit
1 ; \
120 for i in
$(BOUNDS_FAIL
); do \
121 if
$(TCC
) -b
-run boundtest.c
$$i ; then \
122 echo Failed negative
test $$i ; exit
1 ;\
131 time .
/ex2
1238 2 3 4 10 13 4
132 time .
/tcc
-I. .
/ex2.c
1238 2 3 4 10 13 4
134 time .
/tcc
-I. .
/ex3.c
35
137 $(CC
) $(CFLAGS
) -o
$@
$<
140 $(CC
) $(CFLAGS
) -o
$@
$<
142 # Host Tiny C Compiler
144 tcc
$(EXESUF
): tcc.c i386-gen.c tccelf.c tccasm.c i386-asm.c tcctok.h libtcc.h i386-asm.h tccpe.c
145 $(CC
) $(CFLAGS
) -DTCC_TARGET_PE
-o
$@
$< $(LIBS
)
148 tcc
$(EXESUF
): tcc.c i386-gen.c tccelf.c tccasm.c i386-asm.c tcctok.h libtcc.h i386-asm.h
149 $(CC
) $(CFLAGS
) -o
$@
$< $(LIBS
)
152 tcc
$(EXESUF
): tcc.c arm-gen.c tccelf.c tccasm.c tcctok.h libtcc.h
153 $(CC
) $(CFLAGS
) -DTCC_TARGET_ARM
-o
$@
$< $(LIBS
)
157 # Cross Tiny C Compilers
158 i386-tcc
$(EXESUF
): tcc.c i386-gen.c tccelf.c tccasm.c i386-asm.c tcctok.h libtcc.h i386-asm.h
159 $(CC
) $(CFLAGS
) -o
$@
$< $(LIBS
)
161 c67-tcc
$(EXESUF
): tcc.c c67-gen.c tccelf.c tccasm.c tcctok.h libtcc.h tcccoff.c
162 $(CC
) $(CFLAGS
) -DTCC_TARGET_C67
-o
$@
$< $(LIBS
)
164 arm-tcc
$(EXESUF
): tcc.c arm-gen.c tccelf.c tccasm.c tcctok.h libtcc.h
165 $(CC
) $(CFLAGS
) -DTCC_TARGET_ARM
-DTCC_ARM_EABI
-o
$@
$< $(LIBS
)
167 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
168 $(CC
) $(CFLAGS
) -DTCC_TARGET_PE
-o
$@
$< $(LIBS
)
171 tiny_impdef
$(EXESUF
): tiny_impdef.c
172 $(CC
) $(CFLAGS
) -o
$@
$< -lkernel32
174 # TinyCC runtime libraries
176 # for windows, we must use TCC because we generate ELF objects
177 LIBTCC1_OBJS
=$(addprefix win32
/lib
/, crt1.o wincrt1.o dllcrt1.o dllmain.o chkstk.o
) libtcc1.o
178 LIBTCC1_CC
=.
/tcc.exe
-Bwin32
180 LIBTCC1_OBJS
=libtcc1.o
184 LIBTCC1_OBJS
+=alloca86.o alloca86-bt.o
188 $(LIBTCC1_CC
) -O2
-Wall
-c
-o
$@
$<
191 $(LIBTCC1_CC
) -c
-o
$@
$<
193 libtcc1.a
: $(LIBTCC1_OBJS
)
197 $(CC
) -O2
-Wall
-c
-o
$@
$<
199 install: tcc_install libinstall
201 tcc_install
: $(PROGS
) tcc
.1 libtcc1.a
$(BCHECK_O
) tcc-doc.html
203 $(INSTALL
) -s
-m755
$(PROGS
) "$(bindir)"
205 mkdir
-p
"$(mandir)/man1"
206 $(INSTALL
) tcc
.1 "$(mandir)/man1"
209 mkdir
-p
"$(tccdir)/include"
211 mkdir
-p
"$(tccdir)/lib"
212 $(INSTALL
) -m644 libtcc1.a win32
/lib
/*.def
"$(tccdir)/lib"
213 cp
-r win32
/include/.
"$(tccdir)/include"
214 cp
-r win32
/examples
/.
"$(tccdir)/examples"
216 $(INSTALL
) -m644 libtcc1.a
$(BCHECK_O
) "$(tccdir)"
217 $(INSTALL
) -m644 stdarg.h stddef.h stdbool.h float.h varargs.h \
218 tcclib.h
"$(tccdir)/include"
221 $(INSTALL
) -m644 tcc-doc.html
"$(docdir)"
223 $(INSTALL
) -m644 win32
/readme.txt
"$(docdir)"
227 rm -f
*~
*.o
*.a tcc tcct tcc_g tcctest.ref
*.bin
*.i ex2 \
228 core gmon.out
test.out
test.ref a.out tcc_p \
229 *.exe
*.lib tcc.pod libtcc_test \
230 tcctest
[1234] test[1234].out
$(PROGS
) win32
/lib
/*.o
233 rm -f config.h config.mak config.texi
236 tcc_p
: tcc.c Makefile
237 $(CC
) $(CFLAGS_P
) -o
$@
$< $(LIBS_P
)
239 # libtcc generation and example
242 $(INSTALL
) -m644 libtcc.a
"$(libdir)"
243 mkdir
-p
"$(includedir)"
244 $(INSTALL
) -m644 libtcc.h
"$(includedir)"
246 libtcc.o
: tcc.c i386-gen.c Makefile
248 $(CC
) $(CFLAGS
) -DTCC_TARGET_PE
-DLIBTCC
-c
-o
$@
$<
250 $(CC
) $(CFLAGS
) -DLIBTCC
-c
-o
$@
$<
256 libtcc_test
$(EXESUF
): libtcc_test.c libtcc.a
257 $(CC
) $(CFLAGS
) -o
$@
$< libtcc.a
$(LIBS
)
262 # targets for development
271 # tiny assembler testing
273 asmtest.ref
: asmtest.S
274 $(CC
) -c
-o asmtest.ref.o asmtest.S
275 objdump
-D asmtest.ref.o
> $@
277 # XXX: we compute tcc.c to go faster during development !
278 asmtest.out
: asmtest.S tcc
279 # ./tcc tcc.c -c asmtest.S
280 #asmtest.out: asmtest.S tcc
282 objdump
-D asmtest.o
> $@
284 asmtest
: asmtest.out asmtest.ref
285 @if diff
-u
--ignore-matching-lines
="file format" asmtest.ref asmtest.out
; then echo
"ASM Auto Test OK"; fi
288 $(CC
) -O2
-Wall
-g
-c
-o
$@
$<
291 cachegrind .
/tcc_g
-o
/tmp
/linpack
-lm bench
/linpack.c
292 vg_annotate tcc.c
> /tmp
/linpack.cache.log
294 # documentation and man page
295 tcc-doc.html
: tcc-doc.texi
296 -texi2html
-monolithic
-number
$<
299 -.
/texi2pod.pl
$< tcc.pod
300 -pod2man
--section
=1 --center
=" " --release
=" " tcc.pod
> $@
302 FILE
=tcc-
$(shell cat VERSION
)
304 # tar release (use 'make -k tar' on a checkouted tree)
308 ( cd
/tmp
; tar zcvf ~
/$(FILE
).
tar.gz
$(FILE
) --exclude CVS
)