2 # Tiny C Compiler Makefile
9 TARGET
=-DTCC_TARGET_X86_64
10 CFLAGS
+=-Wno-pointer-sign
18 ifneq ($(ARCH
),x86-64
)
22 CFLAGS_P
=$(CFLAGS
) -pg
-static
-DCONFIG_TCC_STATIC
25 ifneq ($(GCC_MAJOR
),2)
26 CFLAGS
+=-fno-strict-aliasing
30 CFLAGS
+=-mpreferred-stack-boundary
=2
32 CFLAGS
+=-m386
-malign-functions
=0
34 CFLAGS
+=-march
=i386
-falign-functions
=0
35 ifneq ($(GCC_MAJOR
),3)
36 CFLAGS
+=-Wno-pointer-sign
-Wno-sign-compare
47 PROGS
+=c67-tcc
$(EXESUF
) arm-tcc-fpa
$(EXESUF
) arm-tcc-fpa-ld
$(EXESUF
) arm-tcc-vfp
$(EXESUF
) arm-tcc-vfp-eabi
$(EXESUF
)
49 PROGS
+=tiny_impdef
$(EXESUF
) tiny_libmaker
$(EXESUF
)
54 PROGS
+=arm-tcc-fpa
$(EXESUF
) arm-tcc-fpa-ld
$(EXESUF
) arm-tcc-vfp
$(EXESUF
) arm-tcc-vfp-eabi
$(EXESUF
)
60 PROGS
+=i386-tcc
$(EXESUF
)
64 PROGS
+=c67-tcc
$(EXESUF
) i386-win32-tcc
$(EXESUF
)
71 ifdef CONFIG_USE_LIBGCC
77 # run local version of tcc with local libraries and includes
81 $(LIBTCC1
) $(BCHECK_O
) tcc-doc.html tcc
.1 libtcc.a \
88 test: test.ref
test.out
89 @if diff
-u
test.ref
test.out
; then echo
"Auto Test OK"; fi
91 tcctest.ref
: tcctest.c
92 $(CC
) $(CFLAGS
) -w
-I.
-o
$@
$<
97 test.out
: tcc tcctest.c
98 $(TCC
) -run tcctest.c
> $@
101 $(TCC
) -run tcctest.c
103 # iterated test2 (compile tcc then compile tcctest.c !)
104 test2
: tcc tcc.c tcctest.c
test.ref
105 $(TCC
) -run
$(TARGET
) tcc.c
-B.
-I.
-run tcctest.c
> test.out2
106 @if diff
-u
test.ref
test.out2
; then echo
"Auto Test2 OK"; fi
108 # iterated test3 (compile tcc then compile tcc then compile tcctest.c !)
109 test3
: tcc tcc.c tcctest.c
test.ref
110 $(TCC
) -run
$(TARGET
) tcc.c
-B.
-I.
-run
$(TARGET
) tcc.c
-B.
-I.
-run tcctest.c
> test.out3
111 @if diff
-u
test.ref
test.out3
; then echo
"Auto Test3 OK"; fi
116 $(TCC
) -o tcctest1 tcctest.c
117 .
/tcctest1
> test1.out
118 @if diff
-u
test.ref test1.out
; then echo
"Dynamic Auto Test OK"; fi
120 $(TCC
) -static
-o tcctest2 tcctest.c
121 .
/tcctest2
> test2.out
122 @if diff
-u
test.ref test2.out
; then echo
"Static Auto Test OK"; fi
123 # object + link output
124 $(TCC
) -c
-o tcctest3.o tcctest.c
125 $(TCC
) -o tcctest3 tcctest3.o
126 .
/tcctest3
> test3.out
127 @if diff
-u
test.ref test3.out
; then echo
"Object Auto Test OK"; fi
128 # dynamic output + bound check
129 $(TCC
) -b
-o tcctest4 tcctest.c
130 .
/tcctest4
> test4.out
131 @if diff
-u
test.ref test4.out
; then echo
"BCheck Auto Test OK"; fi
133 # memory and bound check auto test
135 BOUNDS_FAIL
= 2 5 7 9 11 12 13
137 btest
: boundtest.c tcc
138 @for i in
$(BOUNDS_OK
); do \
139 if
$(TCC
) -b
-run boundtest.c
$$i ; then \
142 echo Failed positive
test $$i ; exit
1 ; \
145 for i in
$(BOUNDS_FAIL
); do \
146 if
$(TCC
) -b
-run boundtest.c
$$i ; then \
147 echo Failed negative
test $$i ; exit
1 ;\
156 time .
/ex2
1238 2 3 4 10 13 4
157 time .
/tcc
-I. .
/ex2.c
1238 2 3 4 10 13 4
159 time .
/tcc
-I. .
/ex3.c
35
162 $(CC
) $(CFLAGS
) -o
$@
$<
165 $(CC
) $(CFLAGS
) -o
$@
$<
167 # Host Tiny C Compiler
169 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 tcc
$(EXESUF
): tcc.c i386-gen.c tccelf.c tccasm.c i386-asm.c tcctok.h libtcc.h i386-asm.h
174 $(CC
) $(CFLAGS
) -o
$@
$< $(LIBS
)
177 ARMFLAGS
= $(if
$(wildcard /lib
/ld-linux.so
.3),-DTCC_ARM_EABI
)
178 ARMFLAGS
+= $(if
$(shell grep
-l
"^Features.* \(vfp\|iwmmxt\) " /proc
/cpuinfo
),-DTCC_ARM_VFP
)
180 tcc
$(EXESUF
): tcc.c arm-gen.c tccelf.c tccasm.c tcctok.h libtcc.h
181 $(CC
) $(CFLAGS
) -DTCC_TARGET_ARM
$(ARMFLAGS
) -o
$@
$< $(LIBS
)
183 ifeq ($(ARCH
),x86-64
)
184 tcc
$(EXESUF
): tcc.c tccelf.c tccasm.c tcctok.h libtcc.h x86_64-gen.c
185 $(CC
) $(CFLAGS
) -DTCC_TARGET_X86_64
-o
$@
$< $(LIBS
)
189 # Cross Tiny C Compilers
190 i386-tcc
$(EXESUF
): tcc.c i386-gen.c tccelf.c tccasm.c i386-asm.c tcctok.h libtcc.h i386-asm.h
191 $(CC
) $(CFLAGS
) -o
$@
$< $(LIBS
)
193 c67-tcc
$(EXESUF
): tcc.c c67-gen.c tccelf.c tccasm.c tcctok.h libtcc.h tcccoff.c
194 $(CC
) $(CFLAGS
) -DTCC_TARGET_C67
-o
$@
$< $(LIBS
)
196 arm-tcc-fpa
$(EXESUF
): tcc.c arm-gen.c tccelf.c tccasm.c tcctok.h libtcc.h
197 $(CC
) $(CFLAGS
) -DTCC_TARGET_ARM
-o
$@
$< $(LIBS
)
199 arm-tcc-fpa-ld
$(EXESUF
): tcc.c arm-gen.c tccelf.c tccasm.c tcctok.h libtcc.h
200 $(CC
) $(CFLAGS
) -DTCC_TARGET_ARM
-DLDOUBLE_SIZE
=12 -o
$@
$< $(LIBS
)
202 arm-tcc-vfp
$(EXESUF
): tcc.c arm-gen.c tccelf.c tccasm.c tcctok.h libtcc.h
203 $(CC
) $(CFLAGS
) -DTCC_TARGET_ARM
-DTCC_ARM_VFP
-o
$@
$< $(LIBS
)
205 arm-tcc-vfp-eabi
$(EXESUF
): tcc.c arm-gen.c tccelf.c tccasm.c tcctok.h libtcc.h
206 $(CC
) $(CFLAGS
) -DTCC_TARGET_ARM
-DTCC_ARM_EABI
-o
$@
$< $(LIBS
)
208 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
209 $(CC
) $(CFLAGS
) -DTCC_TARGET_PE
-o
$@
$< $(LIBS
)
212 tiny_impdef
$(EXESUF
): win32
/tools
/tiny_impdef.c
213 $(CC
) $(CFLAGS
) -o
$@
$< -lkernel32
214 tiny_libmaker
$(EXESUF
): win32
/tools
/tiny_libmaker.c
215 $(CC
) $(CFLAGS
) -o
$@
$< -lkernel32
217 # TinyCC runtime libraries
219 # for windows, we must use TCC because we generate ELF objects
220 LIBTCC1_OBJS
=$(addprefix win32
/lib
/, crt1.o wincrt1.o dllcrt1.o dllmain.o chkstk.o
) libtcc1.o
221 LIBTCC1_CC
=.
/tcc.exe
-Bwin32
-DTCC_TARGET_PE
223 LIBTCC1_OBJS
=libtcc1.o
227 LIBTCC1_OBJS
+=alloca86.o alloca86-bt.o
231 $(LIBTCC1_CC
) -O2
-Wall
-c
-o
$@
$<
234 $(LIBTCC1_CC
) -c
-o
$@
$<
236 libtcc1.a
: $(LIBTCC1_OBJS
)
240 $(CC
) -O2
-Wall
-c
-o
$@
$<
242 install: tcc_install libinstall
244 tcc_install
: $(PROGS
) tcc
.1 $(LIBTCC1
) $(BCHECK_O
) tcc-doc.html
245 mkdir
-p
"$(DESTDIR)$(bindir)"
246 $(INSTALL
) -s
-m755
$(PROGS
) "$(DESTDIR)$(bindir)"
248 mkdir
-p
"$(DESTDIR)$(mandir)/man1"
249 $(INSTALL
) tcc
.1 "$(DESTDIR)$(mandir)/man1"
251 mkdir
-p
"$(DESTDIR)$(tccdir)"
252 mkdir
-p
"$(DESTDIR)$(tccdir)/include"
254 mkdir
-p
"$(DESTDIR)$(tccdir)/lib"
255 $(INSTALL
) -m644
$(LIBTCC1
) win32
/lib
/*.def
"$(DESTDIR)$(tccdir)/lib"
256 cp
-r win32
/include/.
"$(DESTDIR)$(tccdir)/include"
257 cp
-r win32
/examples
/.
"$(DESTDIR)$(tccdir)/examples"
259 ifndef CONFIG_USE_LIBGCC
260 $(INSTALL
) -m644 libtcc1.a
"$(DESTDIR)$(tccdir)"
262 ifneq ($(ARCH
),x86-64
)
263 $(INSTALL
) -m644
$(BCHECK_O
) "$(DESTDIR)$(tccdir)"
265 $(INSTALL
) -m644 stdarg.h stddef.h stdbool.h float.h varargs.h \
266 tcclib.h
"$(DESTDIR)$(tccdir)/include"
268 mkdir
-p
"$(DESTDIR)$(docdir)"
269 $(INSTALL
) -m644 tcc-doc.html
"$(DESTDIR)$(docdir)"
271 $(INSTALL
) -m644 win32
/readme.txt
"$(DESTDIR)$(docdir)"
275 rm -f
*~
*.o
*.a tcc tcct tcc_g tcctest.ref
*.bin
*.i ex2 \
276 core gmon.out
test.out
test.ref a.out tcc_p \
277 *.exe
*.lib tcc.pod libtcc_test \
278 tcctest
[1234] test[1234].out
$(PROGS
) win32
/lib
/*.o
281 rm -f config.h config.mak config.texi
284 tcc_p
: tcc.c Makefile
285 $(CC
) $(CFLAGS_P
) -o
$@
$< $(LIBS_P
)
287 # libtcc generation and example
289 mkdir
-p
"$(DESTDIR)$(libdir)"
290 $(INSTALL
) -m644 libtcc.a
"$(DESTDIR)$(libdir)"
291 mkdir
-p
"$(DESTDIR)$(includedir)"
292 $(INSTALL
) -m644 libtcc.h
"$(DESTDIR)$(includedir)"
294 libtcc.o
: tcc.c i386-gen.c Makefile
296 $(CC
) $(CFLAGS
) -DTCC_TARGET_PE
-DLIBTCC
-c
-o
$@
$<
298 $(CC
) $(CFLAGS
) $(TARGET
) -DLIBTCC
-c
-o
$@
$<
304 libtcc_test
$(EXESUF
): libtcc_test.c libtcc.a
305 $(CC
) $(CFLAGS
) -o
$@
$< libtcc.a
$(LIBS
)
310 # targets for development
319 # tiny assembler testing
321 asmtest.ref
: asmtest.S
322 $(CC
) -c
-o asmtest.ref.o asmtest.S
323 objdump
-D asmtest.ref.o
> $@
325 # XXX: we compute tcc.c to go faster during development !
326 asmtest.out
: asmtest.S tcc
327 # ./tcc tcc.c -c asmtest.S
328 #asmtest.out: asmtest.S tcc
330 objdump
-D asmtest.o
> $@
332 asmtest
: asmtest.out asmtest.ref
333 @if diff
-u
--ignore-matching-lines
="file format" asmtest.ref asmtest.out
; then echo
"ASM Auto Test OK"; fi
336 $(CC
) -O2
-Wall
-g
-c
-o
$@
$<
339 cachegrind .
/tcc_g
-o
/tmp
/linpack
-lm bench
/linpack.c
340 vg_annotate tcc.c
> /tmp
/linpack.cache.log
342 # documentation and man page
343 tcc-doc.html
: tcc-doc.texi
344 -texi2html
-monolithic
-number
$<
347 -.
/texi2pod.pl
$< tcc.pod
348 -pod2man
--section
=1 --center
=" " --release
=" " tcc.pod
> $@
350 FILE
=tcc-
$(shell cat VERSION
)
352 # tar release (use 'make -k tar' on a checkouted tree)
356 ( cd
/tmp
; tar zcvf ~
/$(FILE
).
tar.gz
$(FILE
) --exclude CVS
)