2 # Tiny C Compiler Makefile
9 CFLAGS_P
=$(CFLAGS
) -pg
-static
-DCONFIG_TCC_STATIC
12 CFLAGS
+=-m386
-malign-functions
=0 -mpreferred-stack-boundary
=2
13 CFLAGS
+=-DCONFIG_TCC_PREFIX
=\"$(prefix)\"
18 # run local version of tcc with local libraries and includes
21 all: tcc libtcc1.o bcheck.o tcc-doc.html
25 test: test.ref
test.out
26 @if diff
-u
test.ref
test.out
; then echo
"Auto Test OK"; fi
28 tcctest.ref
: tcctest.c
29 gcc
$(CFLAGS
) -I.
-o
$@
$<
34 test.out
: tcc tcctest.c
40 # iterated test2 (compile tcc then compile tcctest.c !)
41 test2
: tcc tcc.c tcctest.c
test.ref
42 $(TCC
) tcc.c
-B.
-I. tcctest.c
> test.out2
43 @if diff
-u
test.ref
test.out2
; then echo
"Auto Test2 OK"; fi
45 # iterated test3 (compile tcc then compile tcc then compile tcctest.c !)
46 test3
: tcc tcc.c tcctest.c
test.ref
47 $(TCC
) tcc.c
-B.
-I. tcc.c
-B.
-I. tcctest.c
> test.out3
48 @if diff
-u
test.ref
test.out3
; then echo
"Auto Test3 OK"; fi
53 $(TCC
) -o tcctest1 tcctest.c
54 .
/tcctest1
> test1.out
55 @if diff
-u
test.ref test1.out
; then echo
"Dynamic Auto Test OK"; fi
57 $(TCC
) -static
-o tcctest2 tcctest.c
58 .
/tcctest2
> test2.out
59 @if diff
-u
test.ref test2.out
; then echo
"Static Auto Test OK"; fi
60 # object + link output
61 $(TCC
) -c
-o tcctest3.o tcctest.c
62 $(TCC
) -o tcctest3 tcctest3.o
63 .
/tcctest3
> test3.out
64 @if diff
-u
test.ref test3.out
; then echo
"Object Auto Test OK"; fi
65 # dynamic output + bound check
66 $(TCC
) -b
-o tcctest4 tcctest.c
67 .
/tcctest4
> test4.out
68 @if diff
-u
test.ref test4.out
; then echo
"BCheck Auto Test OK"; fi
70 # memory and bound check auto test
72 BOUNDS_FAIL
= 2 5 7 9 11 12 13
74 btest
: boundtest.c tcc
75 @for i in
$(BOUNDS_OK
); do \
76 if
$(TCC
) -b boundtest.c
$$i ; then \
79 echo Failed positive
test $$i ; exit
1 ; \
82 for i in
$(BOUNDS_FAIL
); do \
83 if
$(TCC
) -b boundtest.c
$$i ; then \
84 echo Failed negative
test $$i ; exit
1 ;\
93 time .
/ex2
1238 2 3 4 10 13 4
94 time .
/tcc
-I. .
/ex2.c
1238 2 3 4 10 13 4
96 time .
/tcc
-I. .
/ex3.c
35
99 gcc
$(CFLAGS
) -o
$@
$<
102 gcc
$(CFLAGS
) -o
$@
$<
104 # Native Tiny C Compiler
106 tcc_g
: tcc.c i386-gen.c tccelf.c tcctok.h libtcc.h Makefile
107 gcc
$(CFLAGS
) -o
$@
$< $(LIBS
)
110 strip -s
-R .comment
-R .note
-o
$@
$<
112 # TinyCC runtime libraries
114 gcc
-O2
-Wall
-c
-o
$@
$<
117 gcc
-O2
-Wall
-c
-o
$@
$<
119 install: tcc libtcc1.o bcheck.o
120 $(INSTALL
) -m755 tcc
$(prefix)/bin
121 $(INSTALL
) tcc
.1 $(manpath
)/man1
122 mkdir
-p
$(prefix)/lib
/tcc
123 mkdir
-p
$(prefix)/lib
/tcc
/include
124 $(INSTALL
) -m644 libtcc1.o bcheck.o
$(prefix)/lib
/tcc
125 $(INSTALL
) -m644 stdarg.h stddef.h stdbool.h float.h varargs.h \
126 tcclib.h
$(prefix)/lib
/tcc
/include
129 rm -f
*~
*.o tcc tcc1 tcct tcc_g tcctest.ref
*.bin
*.i ex2 \
130 core gmon.out
test.out
test.ref a.out tcc_p \
131 *.exe iltcc iltcc_g tcc-doc.html \
132 tcctest
[1234] test[1234].out
136 iltcc_g
: tcc.c il-gen.c bcheck.c Makefile
137 gcc
$(CFLAGS
) -DTCC_TARGET_IL
-o
$@
$< $(LIBS
)
140 strip -s
-R .comment
-R .note
-o
$@
$<
143 tcc_g.exe
: tcc.c i386-gen.c bcheck.c Makefile
144 i386-mingw32msvc-gcc
$(CFLAGS
) -DCONFIG_TCC_STATIC
-o
$@
$<
147 i386-mingw32msvc-strip
-o
$@
$<
150 tcc_p
: tcc.c Makefile
151 gcc
$(CFLAGS_P
) -o
$@
$< $(LIBS_P
)
153 # libtcc generation and example
155 $(INSTALL
) -m644 libtcc.a
$(prefix)/lib
156 $(INSTALL
) -m644 libtcc.h
$(prefix)/include
158 libtcc.o
: tcc.c i386-gen.c bcheck.c Makefile
159 gcc
$(CFLAGS
) -DLIBTCC
-c
-o
$@
$<
164 libtcc_test
: libtcc_test.c libtcc.a
165 gcc
$(CFLAGS
) -I.
-o
$@
$< -L.
-ltcc
-ldl
170 # targets for development
180 gcc
-O2
-Wall
-g
-c
-o
$@
$<
183 cachegrind .
/tcc_g
-o
/tmp
/linpack
-lm bench
/linpack.c
184 vg_annotate tcc.c
> /tmp
/linpack.cache.log
187 tcc-doc.html
: tcc-doc.texi
188 texi2html
-monolithic
-number
$<
190 FILES
= Makefile Makefile.uClibc \
191 README TODO COPYING \
192 Changelog tcc-doc.texi tcc-doc.html \
194 tcc.c i386-gen.c tccelf.c tcctok.h \
196 il-opcodes.h il-gen.c \
197 elf.h stab.h stab.def \
198 stddef.h stdarg.h stdbool.h float.h varargs.h \
199 tcclib.h libtcc.h libtcc_test.c \
200 ex1.c ex2.c ex3.c ex4.c ex5.c \
201 tcctest.c boundtest.c gcctestsuite.sh
207 mkdir
-p
/tmp
/$(FILE
)
208 cp
-P
$(FILES
) /tmp
/$(FILE
)
209 ( cd
/tmp
; tar zcvf ~
/$(FILE
).
tar.gz
$(FILE
) )