2 # Tiny C Compiler Makefile
6 include $(TOP
)/config.mak
9 CFLAGS_P
=$(CFLAGS
) -pg
-static
-DCONFIG_TCC_STATIC
12 ifneq ($(GCC_MAJOR
),2)
13 CFLAGS
+=-fno-strict-aliasing
14 ifneq ($(GCC_MAJOR
),3)
15 CFLAGS
+=-Wno-pointer-sign
-Wno-sign-compare
-D_FORTIFY_SOURCE
=0
20 CFLAGS
+=-mpreferred-stack-boundary
=2
22 CFLAGS
+=-m386
-malign-functions
=0
24 CFLAGS
+=-march
=i386
-falign-functions
=0
36 NATIVE_TARGET
=-DTCC_TARGET_I386
39 ALLOCA_O
=alloca86.o alloca86-bt.o
42 NATIVE_TARGET
=-DTCC_TARGET_X86_64
45 ALLOCA_O
=alloca86_64.o
50 NATIVE_TARGET
=-DTCC_TARGET_ARM
51 NATIVE_TARGET
+=$(if
$(wildcard /lib
/ld-linux.so
.3),-DTCC_ARM_EABI
)
52 NATIVE_TARGET
+=$(if
$(shell grep
-l
"^Features.* \(vfp\|iwmmxt\) " /proc
/cpuinfo
),-DTCC_ARM_VFP
)
56 NATIVE_TARGET
+=-DTCC_TARGET_PE
60 ifneq ($(wildcard /lib
/ld-uClibc.so
.0),)
61 NATIVE_TARGET
+=-DTCC_UCLIBC
65 ifdef CONFIG_USE_LIBGCC
72 I386_CROSS
= i386-tcc
$(EXESUF
)
73 WIN32_CROSS
= i386-win32-tcc
$(EXESUF
)
74 WIN64_CROSS
= x86_64-win32-tcc
$(EXESUF
)
75 X64_CROSS
= x86_64-tcc
$(EXESUF
)
76 ARM_CROSS
= arm-tcc-fpa
$(EXESUF
) arm-tcc-fpa-ld
$(EXESUF
) \
77 arm-tcc-vfp
$(EXESUF
) arm-tcc-vfp-eabi
$(EXESUF
)
78 C67_CROSS
= c67-tcc
$(EXESUF
)
80 CORE_FILES
= tcc.c libtcc.c tccpp.c tccgen.c tccelf.c tccasm.c \
81 tcc.h config.h libtcc.h tcctok.h
82 I386_FILES
= $(CORE_FILES
) i386-gen.c i386-asm.c i386-asm.h i386-tok.h
83 WIN32_FILES
= $(CORE_FILES
) i386-gen.c i386-asm.c i386-asm.h i386-tok.h tccpe.c
84 WIN64_FILES
= $(CORE_FILES
) x86_64-gen.c x86_64-asm.c x86_64-asm.h x86_64-tok.h tccpe.c
85 X86_64_FILES
= $(CORE_FILES
) x86_64-gen.c x86_64-asm.c x86_64-asm.h x86_64-tok.h
86 ARM_FILES
= $(CORE_FILES
) arm-gen.c
87 C67_FILES
= $(CORE_FILES
) c67-gen.c tcccoff.c
90 PROGS
+=tiny_impdef
$(EXESUF
) tiny_libmaker
$(EXESUF
)
91 NATIVE_FILES
=$(WIN32_FILES
)
92 PROGS_CROSS
=$(WIN64_CROSS
) $(I386_CROSS
) $(X64_CROSS
) $(ARM_CROSS
) $(C67_CROSS
)
95 NATIVE_FILES
=$(I386_FILES
)
96 PROGS_CROSS
=$(X64_CROSS
) $(WIN32_CROSS
) $(WIN64_CROSS
) $(ARM_CROSS
) $(C67_CROSS
)
99 NATIVE_FILES
=$(X86_64_FILES
)
100 PROGS_CROSS
=$(I386_CROSS
) $(WIN32_CROSS
) $(WIN64_CROSS
) $(ARM_CROSS
) $(C67_CROSS
)
103 NATIVE_FILES
=$(ARM_FILES
)
104 PROGS_CROSS
=$(I386_CROSS
) $(X64_CROSS
) $(WIN32_CROSS
) $(WIN64_CROSS
) $(C67_CROSS
)
111 PROGS
+=$(PROGS_CROSS
)
114 all: $(PROGS
) $(LIBTCC1
) $(BCHECK_O
) libtcc.a tcc-doc.html tcc
.1 libtcc_test
$(EXESUF
)
116 # Host Tiny C Compiler
117 tcc
$(EXESUF
): $(NATIVE_FILES
)
118 $(CC
) -o
$@
$< $(NATIVE_TARGET
) $(CFLAGS
) $(LIBS
)
120 # Cross Tiny C Compilers
121 i386-tcc
$(EXESUF
): $(I386_FILES
)
122 $(CC
) -o
$@
$< -DTCC_TARGET_I386
$(CFLAGS
) $(LIBS
)
124 i386-win32-tcc
$(EXESUF
): $(WIN32_FILES
)
125 $(CC
) -o
$@
$< -DTCC_TARGET_PE
$(CFLAGS
) $(LIBS
)
127 x86_64-win32-tcc
$(EXESUF
): $(WIN32_FILES
)
128 $(CC
) -o
$@
$< -DTCC_TARGET_PE
-DTCC_TARGET_X86_64
$(CFLAGS
) $(LIBS
)
130 x86_64-tcc
$(EXESUF
): $(X86_64_FILES
)
131 $(CC
) -o
$@
$< -DTCC_TARGET_X86_64
$(CFLAGS
) $(LIBS
)
133 c67-tcc
$(EXESUF
): $(C67_FILES
)
134 $(CC
) -o
$@
$< -DTCC_TARGET_C67
$(CFLAGS
) $(LIBS
)
136 arm-tcc-fpa
$(EXESUF
): $(ARM_FILES
)
137 $(CC
) -o
$@
$< -DTCC_TARGET_ARM
$(CFLAGS
) $(LIBS
)
139 arm-tcc-fpa-ld
$(EXESUF
): $(ARM_FILES
)
140 $(CC
) -o
$@
$< -DTCC_TARGET_ARM
-DLDOUBLE_SIZE
=12 $(CFLAGS
) $(LIBS
)
142 arm-tcc-vfp
$(EXESUF
): $(ARM_FILES
)
143 $(CC
) -o
$@
$< -DTCC_TARGET_ARM
-DTCC_ARM_VFP
$(CFLAGS
) $(LIBS
)
145 arm-tcc-vfp-eabi
$(EXESUF
): $(ARM_FILES
)
146 $(CC
) -o
$@
$< -DTCC_TARGET_ARM
-DTCC_ARM_EABI
$(CFLAGS
) $(LIBS
)
148 # libtcc generation and test
149 libtcc.o
: $(NATIVE_FILES
)
150 $(CC
) -o
$@
-c libtcc.c
$(NATIVE_TARGET
) $(CFLAGS
)
155 libtcc_test
$(EXESUF
): tests
/libtcc_test.c libtcc.a
156 $(CC
) -o
$@
$^
-I.
$(CFLAGS
) $(LIBS
)
158 libtest
: libtcc_test
$(EXESUF
) $(LIBTCC1
)
159 .
/libtcc_test
$(EXESUF
) lib_path
=.
162 tcc_p
$(EXESUF
): $(NATIVE_FILES
)
163 $(CC
) -o
$@
$< $(NATIVE_TARGET
) $(CFLAGS_P
) $(LIBS_P
)
166 tiny_impdef
$(EXESUF
): win32
/tools
/tiny_impdef.c
167 $(CC
) -o
$@
$< $(CFLAGS
)
168 tiny_libmaker
$(EXESUF
): win32
/tools
/tiny_libmaker.c
169 $(CC
) -o
$@
$< $(CFLAGS
)
171 # TinyCC runtime libraries
172 LIBTCC1_OBJS
=libtcc1.o
$(ALLOCA_O
)
177 # for windows, we must use TCC because we generate ELF objects
178 LIBTCC1_OBJS
+=crt1.o wincrt1.o dllcrt1.o dllmain.o chkstk.o
179 LIBTCC1_CC
=.
/tcc.exe
-Bwin32
-Iinclude
$(NATIVE_TARGET
)
184 $(LIBTCC1_CC
) -o
$@
-c
$< -O2
-Wall
186 $(LIBTCC1_CC
) -o
$@
-c
$<
188 libtcc1.a
: $(LIBTCC1_OBJS
)
192 $(CC
) -o
$@
-c
$< -O2
-Wall
195 TCC_INCLUDES
= stdarg.h stddef.h stdbool.h float.h varargs.h tcclib.h
199 install: $(PROGS
) $(LIBTCC1
) $(BCHECK_O
) libtcc.a tcc
.1 tcc-doc.html
201 $(INSTALL
) -s
-m755
$(PROGS
) "$(bindir)"
202 mkdir
-p
"$(mandir)/man1"
203 $(INSTALL
) tcc
.1 "$(mandir)/man1"
205 mkdir
-p
"$(tccdir)/include"
207 $(INSTALL
) -m644
$(LIBTCC1
) "$(tccdir)"
210 $(INSTALL
) -m644
$(BCHECK_O
) "$(tccdir)"
212 $(INSTALL
) -m644
$(addprefix include/,$(TCC_INCLUDES
)) "$(tccdir)/include"
214 $(INSTALL
) -m644 tcc-doc.html
"$(docdir)"
216 $(INSTALL
) -m644 libtcc.a
"$(libdir)"
217 mkdir
-p
"$(includedir)"
218 $(INSTALL
) -m644 libtcc.h
"$(includedir)"
221 rm -fv
$(foreach P
,$(PROGS
),"$(bindir)/$P")
222 rm -fv
$(foreach P
,$(LIBTCC1
) $(BCHECK_O
),"$(tccdir)/$P")
223 rm -fv
$(foreach P
,$(TCC_INCLUDES
),"$(tccdir)/include/$P")
224 rm -fv
"$(docdir)/tcc-doc.html" "$(mandir)/man1/tcc.1"
225 rm -fv
"$(libdir)/libtcc.a" "$(includedir)/libtcc.h"
228 install: $(PROGS
) $(LIBTCC1
) libtcc.a tcc-doc.html
230 mkdir
-p
"$(tccdir)/lib"
231 mkdir
-p
"$(tccdir)/include"
232 mkdir
-p
"$(tccdir)/examples"
233 mkdir
-p
"$(tccdir)/doc"
234 mkdir
-p
"$(tccdir)/libtcc"
235 $(INSTALL
) -s
-m755
$(PROGS
) "$(tccdir)"
236 $(INSTALL
) -m644
$(LIBTCC1
) win32
/lib
/*.def
"$(tccdir)/lib"
237 cp
-r win32
/include/.
"$(tccdir)/include"
238 cp
-r win32
/examples
/.
"$(tccdir)/examples"
239 $(INSTALL
) -m644
$(addprefix include/,$(TCC_INCLUDES
)) "$(tccdir)/include"
240 $(INSTALL
) -m644 tcc-doc.html win32
/tcc-win32.txt
"$(tccdir)/doc"
241 $(INSTALL
) -m644 libtcc.a libtcc.h
"$(tccdir)/libtcc"
244 # documentation and man page
245 tcc-doc.html
: tcc-doc.texi
246 -texi2html
-monolithic
-number
$<
249 -.
/texi2pod.pl
$< tcc.pod
250 -pod2man
--section
=1 --center
=" " --release
=" " tcc.pod
> $@
252 # tar release (use 'make -k tar' on a checkouted tree)
253 TCC-VERSION
=tcc-
$(shell cat VERSION
)
255 rm -rf
/tmp
/$(TCC-VERSION
)
256 cp
-r .
/tmp
/$(TCC-VERSION
)
257 ( cd
/tmp
; tar zcvf ~
/$(TCC-VERSION
).
tar.gz
$(TCC-VERSION
) --exclude CVS
)
258 rm -rf
/tmp
/$(TCC-VERSION
)
265 @echo Running configure ...
271 rm -vf
$(PROGS
) tcc_p
$(EXESUF
) tcc.pod
*~
*.o
*.a
*.out libtcc_test
$(EXESUF
)
274 rm -vf config.h config.mak config.texi tcc
.1
276 endif # ifeq ($(TOP),.)