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 WINCE_CROSS
= arm-win32-tcc
$(EXESUF
)
76 X64_CROSS
= x86_64-tcc
$(EXESUF
)
77 ARM_CROSS
= arm-tcc-fpa
$(EXESUF
) arm-tcc-fpa-ld
$(EXESUF
) \
78 arm-tcc-vfp
$(EXESUF
) arm-tcc-vfp-eabi
$(EXESUF
)
79 C67_CROSS
= c67-tcc
$(EXESUF
)
81 CORE_FILES
= tcc.c libtcc.c tccpp.c tccgen.c tccelf.c tccasm.c \
82 tcc.h config.h libtcc.h tcctok.h
83 I386_FILES
= $(CORE_FILES
) i386-gen.c i386-asm.c i386-asm.h i386-tok.h
84 WIN32_FILES
= $(CORE_FILES
) i386-gen.c i386-asm.c i386-asm.h i386-tok.h tccpe.c
85 WIN64_FILES
= $(CORE_FILES
) x86_64-gen.c x86_64-asm.c x86_64-asm.h x86_64-tok.h tccpe.c
86 WINCE_FILES
= $(CORE_FILES
) arm-gen.c tccpe.c
87 X86_64_FILES
= $(CORE_FILES
) x86_64-gen.c x86_64-asm.c x86_64-asm.h x86_64-tok.h
88 ARM_FILES
= $(CORE_FILES
) arm-gen.c
89 C67_FILES
= $(CORE_FILES
) c67-gen.c tcccoff.c
92 PROGS
+=tiny_impdef
$(EXESUF
) tiny_libmaker
$(EXESUF
)
93 NATIVE_FILES
=$(WIN32_FILES
)
94 PROGS_CROSS
=$(WIN64_CROSS
) $(I386_CROSS
) $(X64_CROSS
) $(ARM_CROSS
) $(C67_CROSS
)
97 NATIVE_FILES
=$(I386_FILES
)
98 PROGS_CROSS
=$(X64_CROSS
) $(WIN32_CROSS
) $(WIN64_CROSS
) $(ARM_CROSS
) $(C67_CROSS
)
100 ifeq ($(ARCH
),x86-64
)
101 NATIVE_FILES
=$(X86_64_FILES
)
102 PROGS_CROSS
=$(I386_CROSS
) $(WIN32_CROSS
) $(WIN64_CROSS
) $(ARM_CROSS
) $(C67_CROSS
)
105 NATIVE_FILES
=$(ARM_FILES
)
106 PROGS_CROSS
=$(I386_CROSS
) $(X64_CROSS
) $(WIN32_CROSS
) $(WIN64_CROSS
) $(C67_CROSS
)
113 PROGS
+=$(PROGS_CROSS
)
116 all: $(PROGS
) $(LIBTCC1
) $(BCHECK_O
) libtcc.a tcc-doc.html tcc
.1 libtcc_test
$(EXESUF
)
118 # Host Tiny C Compiler
119 tcc
$(EXESUF
): $(NATIVE_FILES
)
120 $(CC
) -o
$@
$< $(NATIVE_TARGET
) $(CFLAGS
) $(LIBS
)
122 # Cross Tiny C Compilers
123 i386-tcc
$(EXESUF
): $(I386_FILES
)
124 $(CC
) -o
$@
$< -DTCC_TARGET_I386
$(CFLAGS
) $(LIBS
)
126 i386-win32-tcc
$(EXESUF
): $(WIN32_FILES
)
127 $(CC
) -o
$@
$< -DTCC_TARGET_PE
$(CFLAGS
) $(LIBS
)
129 x86_64-win32-tcc
$(EXESUF
): $(WIN32_FILES
)
130 $(CC
) -o
$@
$< -DTCC_TARGET_PE
-DTCC_TARGET_X86_64
$(CFLAGS
) $(LIBS
)
132 x86_64-tcc
$(EXESUF
): $(X86_64_FILES
)
133 $(CC
) -o
$@
$< -DTCC_TARGET_X86_64
$(CFLAGS
) $(LIBS
)
135 c67-tcc
$(EXESUF
): $(C67_FILES
)
136 $(CC
) -o
$@
$< -DTCC_TARGET_C67
$(CFLAGS
) $(LIBS
)
138 arm-win32-tcc
$(EXESUF
): $(WIN32_FILES
)
139 $(CC
) -o
$@
$< -DTCC_TARGET_PE
-DTCC_TARGET_ARM
$(CFLAGS
) $(LIBS
)
141 arm-tcc-fpa
$(EXESUF
): $(ARM_FILES
)
142 $(CC
) -o
$@
$< -DTCC_TARGET_ARM
$(CFLAGS
) $(LIBS
)
144 arm-tcc-fpa-ld
$(EXESUF
): $(ARM_FILES
)
145 $(CC
) -o
$@
$< -DTCC_TARGET_ARM
-DLDOUBLE_SIZE
=12 $(CFLAGS
) $(LIBS
)
147 arm-tcc-vfp
$(EXESUF
): $(ARM_FILES
)
148 $(CC
) -o
$@
$< -DTCC_TARGET_ARM
-DTCC_ARM_VFP
$(CFLAGS
) $(LIBS
)
150 arm-tcc-vfp-eabi
$(EXESUF
): $(ARM_FILES
)
151 $(CC
) -o
$@
$< -DTCC_TARGET_ARM
-DTCC_ARM_EABI
$(CFLAGS
) $(LIBS
)
153 # libtcc generation and test
154 libtcc.o
: $(NATIVE_FILES
)
155 $(CC
) -o
$@
-c libtcc.c
$(NATIVE_TARGET
) $(CFLAGS
)
160 libtcc_test
$(EXESUF
): tests
/libtcc_test.c libtcc.a
161 $(CC
) -o
$@
$^
-I.
$(CFLAGS
) $(LIBS
)
163 libtest
: libtcc_test
$(EXESUF
) $(LIBTCC1
)
164 .
/libtcc_test
$(EXESUF
) lib_path
=.
167 tcc_p
$(EXESUF
): $(NATIVE_FILES
)
168 $(CC
) -o
$@
$< $(NATIVE_TARGET
) $(CFLAGS_P
) $(LIBS_P
)
171 tiny_impdef
$(EXESUF
): win32
/tools
/tiny_impdef.c
172 $(CC
) -o
$@
$< $(CFLAGS
)
173 tiny_libmaker
$(EXESUF
): win32
/tools
/tiny_libmaker.c
174 $(CC
) -o
$@
$< $(CFLAGS
)
176 # TinyCC runtime libraries
177 LIBTCC1_OBJS
=libtcc1.o
$(ALLOCA_O
)
182 # for windows, we must use TCC because we generate ELF objects
183 LIBTCC1_OBJS
+=crt1.o wincrt1.o dllcrt1.o dllmain.o chkstk.o
184 LIBTCC1_CC
=.
/tcc.exe
-Bwin32
-Iinclude
$(NATIVE_TARGET
)
189 $(LIBTCC1_CC
) -o
$@
-c
$< -O2
-Wall
191 $(LIBTCC1_CC
) -o
$@
-c
$<
193 libtcc1.a
: $(LIBTCC1_OBJS
)
197 $(CC
) -o
$@
-c
$< -O2
-Wall
200 TCC_INCLUDES
= stdarg.h stddef.h stdbool.h float.h varargs.h tcclib.h
204 install: $(PROGS
) $(LIBTCC1
) $(BCHECK_O
) libtcc.a tcc
.1 tcc-doc.html
206 $(INSTALL
) -s
-m755
$(PROGS
) "$(bindir)"
207 mkdir
-p
"$(mandir)/man1"
208 $(INSTALL
) tcc
.1 "$(mandir)/man1"
210 mkdir
-p
"$(tccdir)/include"
212 $(INSTALL
) -m644
$(LIBTCC1
) "$(tccdir)"
215 $(INSTALL
) -m644
$(BCHECK_O
) "$(tccdir)"
217 $(INSTALL
) -m644
$(addprefix include/,$(TCC_INCLUDES
)) "$(tccdir)/include"
219 $(INSTALL
) -m644 tcc-doc.html
"$(docdir)"
221 $(INSTALL
) -m644 libtcc.a
"$(libdir)"
222 mkdir
-p
"$(includedir)"
223 $(INSTALL
) -m644 libtcc.h
"$(includedir)"
226 rm -fv
$(foreach P
,$(PROGS
),"$(bindir)/$P")
227 rm -fv
$(foreach P
,$(LIBTCC1
) $(BCHECK_O
),"$(tccdir)/$P")
228 rm -fv
$(foreach P
,$(TCC_INCLUDES
),"$(tccdir)/include/$P")
229 rm -fv
"$(docdir)/tcc-doc.html" "$(mandir)/man1/tcc.1"
230 rm -fv
"$(libdir)/libtcc.a" "$(includedir)/libtcc.h"
233 install: $(PROGS
) $(LIBTCC1
) libtcc.a tcc-doc.html
235 mkdir
-p
"$(tccdir)/lib"
236 mkdir
-p
"$(tccdir)/include"
237 mkdir
-p
"$(tccdir)/examples"
238 mkdir
-p
"$(tccdir)/doc"
239 mkdir
-p
"$(tccdir)/libtcc"
240 $(INSTALL
) -s
-m755
$(PROGS
) "$(tccdir)"
241 $(INSTALL
) -m644
$(LIBTCC1
) win32
/lib
/*.def
"$(tccdir)/lib"
242 cp
-r win32
/include/.
"$(tccdir)/include"
243 cp
-r win32
/examples
/.
"$(tccdir)/examples"
244 $(INSTALL
) -m644
$(addprefix include/,$(TCC_INCLUDES
)) "$(tccdir)/include"
245 $(INSTALL
) -m644 tcc-doc.html win32
/tcc-win32.txt
"$(tccdir)/doc"
246 $(INSTALL
) -m644 libtcc.a libtcc.h
"$(tccdir)/libtcc"
249 # documentation and man page
250 tcc-doc.html
: tcc-doc.texi
251 -texi2html
-monolithic
-number
$<
254 -.
/texi2pod.pl
$< tcc.pod
255 -pod2man
--section
=1 --center
=" " --release
=" " tcc.pod
> $@
257 # tar release (use 'make -k tar' on a checkouted tree)
258 TCC-VERSION
=tcc-
$(shell cat VERSION
)
260 rm -rf
/tmp
/$(TCC-VERSION
)
261 cp
-r .
/tmp
/$(TCC-VERSION
)
262 ( cd
/tmp
; tar zcvf ~
/$(TCC-VERSION
).
tar.gz
$(TCC-VERSION
) --exclude CVS
)
263 rm -rf
/tmp
/$(TCC-VERSION
)
270 @echo Running configure ...
276 rm -vf
$(PROGS
) tcc_p
$(EXESUF
) tcc.pod
*~
*.o
*.a
*.out libtcc_test
$(EXESUF
)
279 rm -vf config.h config.mak config.texi tcc
.1
281 endif # ifeq ($(TOP),.)