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
17 CFLAGS
+=-mpreferred-stack-boundary
=2
19 CFLAGS
+=-m386
-malign-functions
=0
21 CFLAGS
+=-march
=i386
-falign-functions
=0
22 ifneq ($(GCC_MAJOR
),3)
23 CFLAGS
+=-Wno-pointer-sign
-Wno-sign-compare
-D_FORTIFY_SOURCE
=0
29 CFLAGS
+=-Wno-pointer-sign
40 NATIVE_TARGET
=-DTCC_TARGET_PE
44 NATIVE_TARGET
=-DTCC_TARGET_I386
49 NATIVE_TARGET
=-DTCC_TARGET_ARM
50 NATIVE_TARGET
+=$(if
$(wildcard /lib
/ld-linux.so
.3),-DTCC_ARM_EABI
)
51 NATIVE_TARGET
+=$(if
$(shell grep
-l
"^Features.* \(vfp\|iwmmxt\) " /proc
/cpuinfo
),-DTCC_ARM_VFP
)
54 NATIVE_TARGET
=-DTCC_TARGET_X86_64
61 ifneq ($(wildcard /lib
/ld-uClibc.so
.0),)
62 NATIVE_TARGET
+=-DTCC_UCLIBC
66 ifdef CONFIG_USE_LIBGCC
74 I386_CROSS
= i386-tcc
$(EXESUF
)
75 WIN32_CROSS
= i386-win32-tcc
$(EXESUF
)
76 WIN64_CROSS
= x86_64-win32-tcc
$(EXESUF
)
77 X64_CROSS
= x86_64-tcc
$(EXESUF
)
78 ARM_CROSS
= arm-tcc-fpa
$(EXESUF
) arm-tcc-fpa-ld
$(EXESUF
) \
79 arm-tcc-vfp
$(EXESUF
) arm-tcc-vfp-eabi
$(EXESUF
)
80 C67_CROSS
= c67-tcc
$(EXESUF
)
82 CORE_FILES
= tcc.c libtcc.c tccpp.c tccgen.c tccelf.c tccasm.c \
83 tcc.h config.h libtcc.h tcctok.h
84 I386_FILES
= $(CORE_FILES
) i386-gen.c i386-asm.c i386-asm.h
85 WIN32_FILES
= $(CORE_FILES
) i386-gen.c i386-asm.c i386-asm.h tccpe.c
86 WIN64_FILES
= $(CORE_FILES
) x86_64-gen.c tccpe.c
87 X86_64_FILES
= $(CORE_FILES
) x86_64-gen.c
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-tcc-fpa
$(EXESUF
): $(ARM_FILES
)
139 $(CC
) -o
$@
$< -DTCC_TARGET_ARM
$(CFLAGS
) $(LIBS
)
141 arm-tcc-fpa-ld
$(EXESUF
): $(ARM_FILES
)
142 $(CC
) -o
$@
$< -DTCC_TARGET_ARM
-DLDOUBLE_SIZE
=12 $(CFLAGS
) $(LIBS
)
144 arm-tcc-vfp
$(EXESUF
): $(ARM_FILES
)
145 $(CC
) -o
$@
$< -DTCC_TARGET_ARM
-DTCC_ARM_VFP
$(CFLAGS
) $(LIBS
)
147 arm-tcc-vfp-eabi
$(EXESUF
): $(ARM_FILES
)
148 $(CC
) -o
$@
$< -DTCC_TARGET_ARM
-DTCC_ARM_EABI
$(CFLAGS
) $(LIBS
)
150 # libtcc generation and test
151 libtcc.o
: $(NATIVE_FILES
)
152 $(CC
) -o
$@
-c libtcc.c
$(NATIVE_TARGET
) $(CFLAGS
)
157 libtcc_test
$(EXESUF
): tests
/libtcc_test.c libtcc.a
158 $(CC
) -o
$@
$^
-I.
$(CFLAGS
) $(LIBS
)
160 libtest
: libtcc_test
$(EXESUF
) $(LIBTCC1
)
161 .
/libtcc_test
$(EXESUF
) lib_path
=.
164 tcc_p
$(EXESUF
): $(NATIVE_FILES
)
165 $(CC
) -o
$@
$< $(NATIVE_TARGET
) $(CFLAGS_P
) $(LIBS_P
)
168 tiny_impdef
$(EXESUF
): win32
/tools
/tiny_impdef.c
169 $(CC
) -o
$@
$< $(CFLAGS
)
170 tiny_libmaker
$(EXESUF
): win32
/tools
/tiny_libmaker.c
171 $(CC
) -o
$@
$< $(CFLAGS
)
173 # TinyCC runtime libraries
174 LIBTCC1_OBJS
=libtcc1.o
178 # for windows, we must use TCC because we generate ELF objects
179 LIBTCC1_OBJS
+=crt1.o wincrt1.o dllcrt1.o dllmain.o chkstk.o
180 LIBTCC1_CC
=.
/tcc.exe
-Bwin32
-Iinclude
$(NATIVE_TARGET
)
184 LIBTCC1_OBJS
+=alloca86.o alloca86-bt.o
186 ifeq ($(ARCH
),x86-64
)
187 LIBTCC1_OBJS
+=alloca86_64.o
192 $(LIBTCC1_CC
) -o
$@
-c
$< -O2
-Wall
195 $(LIBTCC1_CC
) -o
$@
-c
$<
197 libtcc1.a
: $(LIBTCC1_OBJS
)
201 $(CC
) -o
$@
-c
$< -O2
-Wall
204 TCC_INCLUDES
= stdarg.h stddef.h stdbool.h float.h varargs.h tcclib.h
208 install: $(PROGS
) $(LIBTCC1
) $(BCHECK_O
) libtcc.a tcc
.1 tcc-doc.html
210 $(INSTALL
) -s
-m755
$(PROGS
) "$(bindir)"
211 mkdir
-p
"$(mandir)/man1"
212 $(INSTALL
) tcc
.1 "$(mandir)/man1"
214 mkdir
-p
"$(tccdir)/include"
216 $(INSTALL
) -m644
$(LIBTCC1
) "$(tccdir)"
219 $(INSTALL
) -m644
$(BCHECK_O
) "$(tccdir)"
221 $(INSTALL
) -m644
$(addprefix include/,$(TCC_INCLUDES
)) "$(tccdir)/include"
223 $(INSTALL
) -m644 tcc-doc.html
"$(docdir)"
225 $(INSTALL
) -m644 libtcc.a
"$(libdir)"
226 mkdir
-p
"$(includedir)"
227 $(INSTALL
) -m644 libtcc.h
"$(includedir)"
230 rm -fv
$(foreach P
,$(PROGS
),"$(bindir)/$P")
231 rm -fv
$(foreach P
,$(LIBTCC1
) $(BCHECK_O
),"$(tccdir)/$P")
232 rm -fv
$(foreach P
,$(TCC_INCLUDES
),"$(tccdir)/include/$P")
233 rm -fv
"$(docdir)/tcc-doc.html" "$(mandir)/man1/tcc.1"
234 rm -fv
"$(libdir)/libtcc.a" "$(includedir)/libtcc.h"
237 install: $(PROGS
) $(LIBTCC1
) libtcc.a tcc-doc.html
239 mkdir
-p
"$(tccdir)/lib"
240 mkdir
-p
"$(tccdir)/include"
241 mkdir
-p
"$(tccdir)/examples"
242 mkdir
-p
"$(tccdir)/doc"
243 mkdir
-p
"$(tccdir)/libtcc"
244 $(INSTALL
) -s
-m755
$(PROGS
) "$(tccdir)"
245 $(INSTALL
) -m644
$(LIBTCC1
) win32
/lib
/*.def
"$(tccdir)/lib"
246 cp
-r win32
/include/.
"$(tccdir)/include"
247 cp
-r win32
/examples
/.
"$(tccdir)/examples"
248 $(INSTALL
) -m644
$(addprefix include/,$(TCC_INCLUDES
)) "$(tccdir)/include"
249 $(INSTALL
) -m644 tcc-doc.html win32
/tcc-win32.txt
"$(tccdir)/doc"
250 $(INSTALL
) -m644 libtcc.a libtcc.h
"$(tccdir)/libtcc"
253 # documentation and man page
254 tcc-doc.html
: tcc-doc.texi
255 -texi2html
-monolithic
-number
$<
258 -.
/texi2pod.pl
$< tcc.pod
259 -pod2man
--section
=1 --center
=" " --release
=" " tcc.pod
> $@
261 # tar release (use 'make -k tar' on a checkouted tree)
262 TCC-VERSION
=tcc-
$(shell cat VERSION
)
264 rm -rf
/tmp
/$(TCC-VERSION
)
265 cp
-r .
/tmp
/$(TCC-VERSION
)
266 ( cd
/tmp
; tar zcvf ~
/$(TCC-VERSION
).
tar.gz
$(TCC-VERSION
) --exclude CVS
)
267 rm -rf
/tmp
/$(TCC-VERSION
)
274 @echo Running configure ...
280 rm -vf
$(PROGS
) tcc_p
$(EXESUF
) tcc.pod
*~
*.o
*.a
*.out libtcc_test
$(EXESUF
)
283 rm -vf config.h config.mak config.texi tcc
.1
285 endif # ifeq ($(TOP),.)