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 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
84 WIN32_FILES
= $(CORE_FILES
) i386-gen.c i386-asm.c i386-asm.h tccpe.c
85 X86_64_FILES
= $(CORE_FILES
) x86_64-gen.c
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
=$(I386_CROSS
) $(X64_CROSS
) $(ARM_CROSS
) $(C67_CROSS
)
95 NATIVE_FILES
=$(I386_FILES
)
96 PROGS_CROSS
=$(X64_CROSS
) $(WIN32_CROSS
) $(ARM_CROSS
) $(C67_CROSS
)
99 NATIVE_FILES
=$(X86_64_FILES
)
100 PROGS_CROSS
=$(I386_CROSS
) $(WIN32_CROSS
) $(ARM_CROSS
) $(C67_CROSS
)
103 NATIVE_FILES
=$(ARM_FILES
)
104 PROGS_CROSS
=$(I386_CROSS
) $(X64_CROSS
) $(WIN32_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-tcc
$(EXESUF
): $(X86_64_FILES
)
128 $(CC
) -o
$@
$< -DTCC_TARGET_X86_64
$(CFLAGS
) $(LIBS
)
130 c67-tcc
$(EXESUF
): $(C67_FILES
)
131 $(CC
) -o
$@
$< -DTCC_TARGET_C67
$(CFLAGS
) $(LIBS
)
133 arm-tcc-fpa
$(EXESUF
): $(ARM_FILES
)
134 $(CC
) -o
$@
$< -DTCC_TARGET_ARM
$(CFLAGS
) $(LIBS
)
136 arm-tcc-fpa-ld
$(EXESUF
): $(ARM_FILES
)
137 $(CC
) -o
$@
$< -DTCC_TARGET_ARM
-DLDOUBLE_SIZE
=12 $(CFLAGS
) $(LIBS
)
139 arm-tcc-vfp
$(EXESUF
): $(ARM_FILES
)
140 $(CC
) -o
$@
$< -DTCC_TARGET_ARM
-DTCC_ARM_VFP
$(CFLAGS
) $(LIBS
)
142 arm-tcc-vfp-eabi
$(EXESUF
): $(ARM_FILES
)
143 $(CC
) -o
$@
$< -DTCC_TARGET_ARM
-DTCC_ARM_EABI
$(CFLAGS
) $(LIBS
)
145 # libtcc generation and test
146 libtcc.o
: $(NATIVE_FILES
)
147 $(CC
) -o
$@
-c libtcc.c
$(NATIVE_TARGET
) $(CFLAGS
)
152 libtcc_test
$(EXESUF
): tests
/libtcc_test.c libtcc.a
153 $(CC
) -o
$@
$^
-I.
$(CFLAGS
) $(LIBS
)
155 libtest
: libtcc_test
$(EXESUF
) $(LIBTCC1
)
156 .
/libtcc_test
$(EXESUF
) lib_path
=.
159 tcc_p
$(EXESUF
): $(NATIVE_FILES
)
160 $(CC
) -o
$@
$< $(NATIVE_TARGET
) $(CFLAGS_P
) $(LIBS_P
)
163 tiny_impdef
$(EXESUF
): win32
/tools
/tiny_impdef.c
164 $(CC
) -o
$@
$< $(CFLAGS
)
165 tiny_libmaker
$(EXESUF
): win32
/tools
/tiny_libmaker.c
166 $(CC
) -o
$@
$< $(CFLAGS
)
168 # TinyCC runtime libraries
169 LIBTCC1_OBJS
=libtcc1.o
173 # for windows, we must use TCC because we generate ELF objects
174 LIBTCC1_OBJS
+=crt1.o wincrt1.o dllcrt1.o dllmain.o chkstk.o
175 LIBTCC1_CC
=.
/tcc.exe
-Bwin32
-DTCC_TARGET_PE
179 LIBTCC1_OBJS
+=alloca86.o alloca86-bt.o
181 ifeq ($(ARCH
),x86-64
)
182 LIBTCC1_OBJS
+=alloca86_64.o
187 $(LIBTCC1_CC
) -o
$@
-c
$< -O2
-Wall
190 $(LIBTCC1_CC
) -o
$@
-c
$<
192 libtcc1.a
: $(LIBTCC1_OBJS
)
196 $(CC
) -o
$@
-c
$< -O2
-Wall
199 TCC_INCLUDES
= stdarg.h stddef.h stdbool.h float.h varargs.h tcclib.h
203 install: $(PROGS
) $(LIBTCC1
) $(BCHECK_O
) libtcc.a tcc
.1 tcc-doc.html
205 $(INSTALL
) -s
-m755
$(PROGS
) "$(bindir)"
206 mkdir
-p
"$(mandir)/man1"
207 $(INSTALL
) tcc
.1 "$(mandir)/man1"
209 mkdir
-p
"$(tccdir)/include"
211 $(INSTALL
) -m644
$(LIBTCC1
) "$(tccdir)"
214 $(INSTALL
) -m644
$(BCHECK_O
) "$(tccdir)"
216 $(INSTALL
) -m644
$(addprefix include/,$(TCC_INCLUDES
)) "$(tccdir)/include"
218 $(INSTALL
) -m644 tcc-doc.html
"$(docdir)"
220 $(INSTALL
) -m644 libtcc.a
"$(libdir)"
221 mkdir
-p
"$(includedir)"
222 $(INSTALL
) -m644 libtcc.h
"$(includedir)"
225 rm -fv
$(foreach P
,$(PROGS
),"$(bindir)/$P")
226 rm -fv
$(foreach P
,$(LIBTCC1
) $(BCHECK_O
),"$(tccdir)/$P")
227 rm -fv
$(foreach P
,$(TCC_INCLUDES
),"$(tccdir)/include/$P")
228 rm -fv
"$(docdir)/tcc-doc.html" "$(mandir)/man1/tcc.1"
229 rm -fv
"$(libdir)/libtcc.a" "$(includedir)/libtcc.h"
232 install: $(PROGS
) $(LIBTCC1
) libtcc.a tcc-doc.html
234 mkdir
-p
"$(tccdir)/lib"
235 mkdir
-p
"$(tccdir)/include"
236 mkdir
-p
"$(tccdir)/examples"
237 mkdir
-p
"$(tccdir)/doc"
238 mkdir
-p
"$(tccdir)/libtcc"
239 $(INSTALL
) -s
-m755
$(PROGS
) "$(tccdir)"
240 $(INSTALL
) -m644
$(LIBTCC1
) win32
/lib
/*.def
"$(tccdir)/lib"
241 cp
-r win32
/include/.
"$(tccdir)/include"
242 cp
-r win32
/examples
/.
"$(tccdir)/examples"
243 # $(INSTALL) -m644 $(addprefix include/,$(TCC_INCLUDES)) "$(tccdir)/include"
244 $(INSTALL
) -m644 tcc-doc.html win32
/tcc-win32.txt
"$(tccdir)/doc"
245 $(INSTALL
) -m644 libtcc.a libtcc.h
"$(tccdir)/libtcc"
248 # documentation and man page
249 tcc-doc.html
: tcc-doc.texi
250 -texi2html
-monolithic
-number
$<
253 -.
/texi2pod.pl
$< tcc.pod
254 -pod2man
--section
=1 --center
=" " --release
=" " tcc.pod
> $@
256 # tar release (use 'make -k tar' on a checkouted tree)
257 TCC-VERSION
=tcc-
$(shell cat VERSION
)
259 rm -rf
/tmp
/$(TCC-VERSION
)
260 cp
-r .
/tmp
/$(TCC-VERSION
)
261 ( cd
/tmp
; tar zcvf ~
/$(TCC-VERSION
).
tar.gz
$(TCC-VERSION
) --exclude CVS
)
262 rm -rf
/tmp
/$(TCC-VERSION
)
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 tcc-doc.html
276 endif # ifeq ($(TOP),.)