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
40 NATIVE_DEFINES
=-DTCC_TARGET_I386
43 NATIVE_DEFINES
=-DTCC_TARGET_X86_64
44 NATIVE_DEFINES
+=$(if
$(wildcard /lib64
/ld-linux-x86-64.so
.2),-DTCC_TARGET_X86_64_CENTOS
)
49 NATIVE_DEFINES
=-DTCC_TARGET_ARM
50 NATIVE_DEFINES
+=-DWITHOUT_LIBTCC
51 NATIVE_DEFINES
+=$(if
$(wildcard /lib
/ld-linux.so
.3),-DTCC_ARM_EABI
)
52 NATIVE_DEFINES
+=$(if
$(shell grep
-l
"^Features.* \(vfp\|iwmmxt\) " /proc
/cpuinfo
),-DTCC_ARM_VFP
)
56 NATIVE_DEFINES
+=-DTCC_TARGET_PE
59 ifneq ($(wildcard /lib
/ld-uClibc.so
.0),)
60 NATIVE_DEFINES
+=-DTCC_UCLIBC
64 # make libtcc as static or dynamic library?
67 LINK_LIBTCC
=-Wl
,-rpath
,"$(libdir)"
79 I386_CROSS
= i386-tcc
$(EXESUF
)
80 WIN32_CROSS
= i386-win32-tcc
$(EXESUF
)
81 WIN64_CROSS
= x86_64-win32-tcc
$(EXESUF
)
82 WINCE_CROSS
= arm-win32-tcc
$(EXESUF
)
83 X64_CROSS
= x86_64-tcc
$(EXESUF
)
84 ARM_FPA_CROSS
= arm-fpa-tcc
$(EXESUF
)
85 ARM_FPA_LD_CROSS
= arm-fpa-ld-tcc
$(EXESUF
)
86 ARM_VFP_CROSS
= arm-vfp-tcc
$(EXESUF
)
87 ARM_EABI_CROSS
= arm-eabi-tcc
$(EXESUF
)
88 ARM_CROSS
= $(ARM_FPA_CROSS
) $(ARM_FPA_LD_CROSS
) $(ARM_VFP_CROSS
) $(ARM_EABI_CROSS
)
89 C67_CROSS
= c67-tcc
$(EXESUF
)
91 CORE_FILES
= tcc.c libtcc.c tccpp.c tccgen.c tccelf.c tccasm.c tccrun.c
92 CORE_FILES
+= tcc.h config.h libtcc.h tcctok.h
93 I386_FILES
= $(CORE_FILES
) i386-gen.c i386-asm.c i386-asm.h i386-tok.h
94 WIN32_FILES
= $(CORE_FILES
) i386-gen.c i386-asm.c i386-asm.h i386-tok.h tccpe.c
95 WIN64_FILES
= $(CORE_FILES
) x86_64-gen.c i386-asm.c x86_64-asm.h tccpe.c
96 WINCE_FILES
= $(CORE_FILES
) arm-gen.c tccpe.c
97 X86_64_FILES
= $(CORE_FILES
) x86_64-gen.c i386-asm.c x86_64-asm.h
98 ARM_FILES
= $(CORE_FILES
) arm-gen.c
99 C67_FILES
= $(CORE_FILES
) c67-gen.c tcccoff.c
102 PROGS
+=tiny_impdef
$(EXESUF
) tiny_libmaker
$(EXESUF
)
103 NATIVE_FILES
=$(WIN64_FILES
)
104 PROGS_CROSS
=$(WIN32_CROSS
) $(I386_CROSS
) $(X64_CROSS
) $(ARM_CROSS
) $(C67_CROSS
)
105 LIBTCC1_CROSS
=lib
/i386-win32
/libtcc1.a
109 PROGS
+=tiny_impdef
$(EXESUF
) tiny_libmaker
$(EXESUF
)
110 NATIVE_FILES
=$(WIN32_FILES
)
111 PROGS_CROSS
=$(WIN64_CROSS
) $(I386_CROSS
) $(X64_CROSS
) $(ARM_CROSS
) $(C67_CROSS
)
112 LIBTCC1_CROSS
=lib
/x86_64-win32
/libtcc1.a
116 NATIVE_FILES
=$(I386_FILES
)
117 PROGS_CROSS
=$(X64_CROSS
) $(WIN32_CROSS
) $(WIN64_CROSS
) $(ARM_CROSS
) $(C67_CROSS
)
118 LIBTCC1_CROSS
=lib
/i386-win32
/libtcc1.a lib
/x86_64-win32
/libtcc1.a
122 ifeq ($(ARCH
),x86-64
)
123 NATIVE_FILES
=$(X86_64_FILES
)
124 PROGS_CROSS
=$(I386_CROSS
) $(WIN32_CROSS
) $(WIN64_CROSS
) $(ARM_CROSS
) $(C67_CROSS
)
125 LIBTCC1_CROSS
=lib
/i386-win32
/libtcc1.a lib
/x86_64-win32
/libtcc1.a lib
/i386
/libtcc1.a
129 NATIVE_FILES
=$(ARM_FILES
)
130 PROGS_CROSS
=$(I386_CROSS
) $(X64_CROSS
) $(WIN32_CROSS
) $(WIN64_CROSS
) $(C67_CROSS
)
141 ifdef CONFIG_USE_LIBGCC
145 TCCLIBS
= $(LIBTCC1
) $(LIBTCC
) $(BCHECK_O
)
146 TCCDOCS
= tcc
.1 tcc-doc.html tcc-doc.
info
149 PROGS
+=$(PROGS_CROSS
)
150 TCCLIBS
+=$(LIBTCC1_CROSS
)
153 all: $(PROGS
) $(TCCLIBS
) $(TCCDOCS
)
155 # Host Tiny C Compiler
156 tcc
$(EXESUF
): tcc.o
$(LIBTCC
)
157 $(CC
) -o
$@
$^
$(LIBS
) $(LDFLAGS
) $(LINK_LIBTCC
)
159 # Cross Tiny C Compilers
161 $(CC
) -o
$@ tcc.c
$(DEFINES
) $(CFLAGS
) $(LIBS
) $(LDFLAGS
)
163 $(I386_CROSS
): DEFINES
= -DTCC_TARGET_I386
-DCONFIG_TCCDIR
="\"$(tccdir)/i386\""
164 $(X64_CROSS
): DEFINES
= -DTCC_TARGET_X86_64
165 $(WIN32_CROSS
): DEFINES
= -DTCC_TARGET_I386
-DTCC_TARGET_PE
-DCONFIG_TCCDIR
="\"$(tccdir)/win32\"" -DCONFIG_TCC_CROSSLIB
="\"lib/32\""
166 $(WIN64_CROSS
): DEFINES
= -DTCC_TARGET_X86_64
-DTCC_TARGET_PE
-DCONFIG_TCCDIR
="\"$(tccdir)/win32\"" -DCONFIG_TCC_CROSSLIB
="\"lib/64\""
167 $(WINCE_CROSS
): DEFINES
= -DTCC_TARGET_PE
168 $(C67_CROSS
): DEFINES
= -DTCC_TARGET_C67
169 $(ARM_FPA_CROSS
): DEFINES
= -DTCC_TARGET_ARM
170 $(ARM_FPA_LD_CROSS
)$(EXESUF
): DEFINES
= -DTCC_TARGET_ARM
-DLDOUBLE_SIZE
=12
171 $(ARM_VFP_CROSS
): DEFINES
= -DTCC_TARGET_ARM
-DTCC_ARM_VFP
172 $(ARM_EABI_CROSS
): DEFINES
= -DTCC_TARGET_ARM
-DTCC_ARM_EABI
174 $(I386_CROSS
): $(I386_FILES
)
175 $(X64_CROSS
): $(X86_64_FILES
)
176 $(WIN32_CROSS
): $(WIN32_FILES
)
177 $(WIN64_CROSS
): $(WIN64_FILES
)
178 $(WINCE_CROSS
): $(WINCE_FILES
)
179 $(C67_CROSS
): $(C67_FILES
)
180 $(ARM_FPA_CROSS
) $(ARM_FPA_LD_CROSS
) $(ARM_VFP_CROSS
) $(ARM_EABI_CROSS
): $(ARM_FILES
)
182 # libtcc generation and test
184 LIBTCC_OBJ
= $(filter-out tcc.o
,$(patsubst %.c
,%.o
,$(filter %.c
,$(NATIVE_FILES
))))
185 LIBTCC_INC
= $(filter %.h
,$(CORE_FILES
)) $(filter-out $(CORE_FILES
),$(NATIVE_FILES
))
186 $(LIBTCC_OBJ
) tcc.o
: NATIVE_DEFINES
+= -DNOTALLINONE
188 LIBTCC_OBJ
= libtcc.o
189 LIBTCC_INC
= $(NATIVE_FILES
)
190 tcc.o
: NATIVE_DEFINES
+= -DNOTALLINONE
193 $(LIBTCC_OBJ
) tcc.o
: %.o
: %.c
$(LIBTCC_INC
)
194 $(CC
) -o
$@
-c
$< $(NATIVE_DEFINES
) $(CFLAGS
)
196 libtcc.a
: $(LIBTCC_OBJ
)
199 libtcc.so
.1.0: $(LIBTCC_OBJ
)
200 $(CC
) -shared
-Wl
,-soname
,$@
-o
$@
$^
202 libtcc.so
.1.0: CFLAGS
+=-fPIC
205 tcc_p
$(EXESUF
): $(NATIVE_FILES
)
206 $(CC
) -o
$@
$< $(NATIVE_DEFINES
) $(CFLAGS_P
) $(LIBS_P
)
209 tiny_impdef
$(EXESUF
): win32
/tools
/tiny_impdef.c
210 $(CC
) -o
$@
$< $(CFLAGS
)
211 tiny_libmaker
$(EXESUF
): win32
/tools
/tiny_libmaker.c
212 $(CC
) -o
$@
$< $(CFLAGS
)
214 # TinyCC runtime libraries
216 @
$(MAKE
) -C lib native
217 lib
/%/libtcc1.a
: FORCE
$(PROGS_CROSS
)
218 @
$(MAKE
) -C lib cross TARGET
=$*
219 bcheck.o
: lib
/bcheck.c
220 gcc
-c
$< -o
$@
-O2
-Wall
224 TCC_INCLUDES
= stdarg.h stddef.h stdbool.h float.h varargs.h tcclib.h
228 install: $(PROGS
) $(TCCLIBS
) $(TCCDOCS
)
231 $(INSTALL
) -m755
$(PROGS
) "$(bindir)"
233 $(INSTALL
) -s
-m755
$(PROGS
) "$(bindir)"
235 mkdir
-p
"$(mandir)/man1"
236 -$(INSTALL
) tcc
.1 "$(mandir)/man1"
237 mkdir
-p
"$(infodir)"
238 -$(INSTALL
) tcc-doc.
info "$(infodir)"
240 mkdir
-p
"$(tccdir)/include"
242 $(INSTALL
) -m644
$(LIBTCC1
) "$(tccdir)"
245 $(INSTALL
) -m644
$(BCHECK_O
) "$(tccdir)"
247 $(INSTALL
) -m644
$(addprefix include/,$(TCC_INCLUDES
)) "$(tccdir)/include"
249 $(INSTALL
) -m755
$(LIBTCC
) "$(libdir)"
251 ln
-sf
"$(ln_libdir)/libtcc.so.1.0" "$(libdir)/libtcc.so.1"
252 ln
-sf
"$(ln_libdir)/libtcc.so.1.0" "$(libdir)/libtcc.so"
254 mkdir
-p
"$(includedir)"
255 $(INSTALL
) -m644 libtcc.h
"$(includedir)"
257 -$(INSTALL
) -m644 tcc-doc.html
"$(docdir)"
259 mkdir
-p
"$(tccdir)/win32/lib/32"
260 mkdir
-p
"$(tccdir)/win32/lib/64"
261 ifeq ($(ARCH
),x86-64
)
262 mkdir
-p
"$(tccdir)/i386"
263 $(INSTALL
) -m644 lib
/i386
/libtcc1.a
"$(tccdir)/i386"
264 cp
-r
"$(tccdir)/include" "$(tccdir)/i386"
266 $(INSTALL
) -m644 win32
/lib
/*.def
"$(tccdir)/win32/lib"
267 $(INSTALL
) -m644 lib
/i386-win32
/libtcc1.a
"$(tccdir)/win32/lib/32"
268 $(INSTALL
) -m644 lib
/x86_64-win32
/libtcc1.a
"$(tccdir)/win32/lib/64"
269 cp
-r win32
/include/.
"$(tccdir)/win32/include"
270 cp
-r
include/.
"$(tccdir)/win32/include"
274 rm -fv
$(foreach P
,$(PROGS
),"$(bindir)/$P")
275 rm -fv
$(foreach P
,$(LIBTCC1
) $(BCHECK_O
),"$(tccdir)/$P")
276 rm -fv
$(foreach P
,$(TCC_INCLUDES
),"$(tccdir)/include/$P")
277 rm -fv
"$(docdir)/tcc-doc.html" "$(mandir)/man1/tcc.1" "$(infodir)/tcc-doc.info"
278 rm -fv
"$(libdir)/$(LIBTCC)" "$(includedir)/libtcc.h"
279 rm -fv
"$(libdir)/libtcc.so*"
280 rm -rf
"$(tccdir)/win32"
281 -rmdir
$(tccdir
)/include
282 ifeq ($(ARCH
),x86-64
)
283 rm -rf
"$(tccdir)/i386"
287 install: $(PROGS
) $(TCCLIBS
) $(TCCDOCS
)
289 mkdir
-p
"$(tccdir)/lib"
290 mkdir
-p
"$(tccdir)/include"
291 mkdir
-p
"$(tccdir)/examples"
292 mkdir
-p
"$(tccdir)/doc"
293 mkdir
-p
"$(tccdir)/libtcc"
294 $(INSTALL
) -s
-m755
$(PROGS
) "$(tccdir)"
295 $(INSTALL
) -m644
$(LIBTCC1
) win32
/lib
/*.def
"$(tccdir)/lib"
296 cp
-r win32
/include/.
"$(tccdir)/include"
297 cp
-r win32
/examples
/.
"$(tccdir)/examples"
298 $(INSTALL
) -m644
$(addprefix include/,$(TCC_INCLUDES
)) "$(tccdir)/include"
299 $(INSTALL
) -m644 tcc-doc.html win32
/tcc-win32.txt
"$(tccdir)/doc"
300 $(INSTALL
) -m644
$(LIBTCC
) libtcc.h
"$(tccdir)/libtcc"
302 mkdir
-p
"$(tccdir)/lib/32"
303 mkdir
-p
"$(tccdir)/lib/64"
304 -$(INSTALL
) -m644 lib
/i386-win32
/libtcc1.a
"$(tccdir)/lib/32"
305 -$(INSTALL
) -m644 lib
/x86_64-win32
/libtcc1.a
"$(tccdir)/lib/64"
309 rm -rfv
"$(tccdir)/*"
312 # documentation and man page
313 tcc-doc.html
: tcc-doc.texi
314 -texi2html
-monolithic
-number
$<
317 -.
/texi2pod.pl
$< tcc.pod
318 -pod2man
--section
=1 --center
=" " --release
=" " tcc.pod
> $@
320 tcc-doc.
info: tcc-doc.texi
321 -makeinfo tcc-doc.texi
323 .PHONY
: all clean tar distclean install uninstall FORCE
325 # tar release (use 'make -k tar' on a checkouted tree)
326 TCC-VERSION
=tcc-
$(shell cat VERSION
)
328 rm -rf
/tmp
/$(TCC-VERSION
)
329 cp
-r .
/tmp
/$(TCC-VERSION
)
330 ( cd
/tmp
; tar zcvf ~
/$(TCC-VERSION
).
tar.gz
$(TCC-VERSION
) --exclude CVS
)
331 rm -rf
/tmp
/$(TCC-VERSION
)
338 rm -vf
$(PROGS
) tcc_p
$(EXESUF
) tcc.pod
*~
*.o
*.a
*.so
* *.out
*.exe libtcc_test
$(EXESUF
)
343 rm -vf config.h config.mak config.texi tcc
.1 tcc-doc.
info tcc-doc.html
346 @echo
"Please run ./configure."
349 endif # ifeq ($(TOP),.)