2 # Tiny C Compiler Makefile
6 include $(TOP
)/config.mak
8 CFLAGS_P
=$(CFLAGS
) -pg
-static
-DCONFIG_TCC_STATIC
11 ifneq ($(GCC_MAJOR
),2)
12 CFLAGS
+=-fno-strict-aliasing
13 ifneq ($(GCC_MAJOR
),3)
14 CFLAGS
+=-Wno-pointer-sign
-Wno-sign-compare
-D_FORTIFY_SOURCE
=0
19 CFLAGS
+=-mpreferred-stack-boundary
=2
21 CFLAGS
+=-m386
-malign-functions
=0
23 CFLAGS
+=-march
=i386
-falign-functions
=0
39 NATIVE_DEFINES
=-DTCC_TARGET_I386
42 NATIVE_DEFINES
=-DTCC_TARGET_X86_64
43 NATIVE_DEFINES
+=$(if
$(wildcard /lib64
/ld-linux-x86-64.so
.2),-DTCC_TARGET_X86_64_CENTOS
)
48 NATIVE_DEFINES
=-DTCC_TARGET_ARM
49 NATIVE_DEFINES
+=-DWITHOUT_LIBTCC
50 NATIVE_DEFINES
+=$(if
$(wildcard /lib
/ld-linux.so
.3),-DTCC_ARM_EABI
)
51 NATIVE_DEFINES
+=$(if
$(shell grep
-l
"^Features.* \(vfp\|iwmmxt\) " /proc
/cpuinfo
),-DTCC_ARM_VFP
)
55 NATIVE_DEFINES
+=-DTCC_TARGET_PE
58 ifneq ($(wildcard /lib
/ld-uClibc.so
.0),)
59 NATIVE_DEFINES
+=-DTCC_UCLIBC
63 # make libtcc as static or dynamic library?
66 LINK_LIBTCC
=-Wl
,-rpath
,"$(libdir)"
78 I386_CROSS
= i386-tcc
$(EXESUF
)
79 WIN32_CROSS
= i386-win32-tcc
$(EXESUF
)
80 WIN64_CROSS
= x86_64-win32-tcc
$(EXESUF
)
81 WINCE_CROSS
= arm-win32-tcc
$(EXESUF
)
82 X64_CROSS
= x86_64-tcc
$(EXESUF
)
83 ARM_FPA_CROSS
= arm-fpa-tcc
$(EXESUF
)
84 ARM_FPA_LD_CROSS
= arm-fpa-ld-tcc
$(EXESUF
)
85 ARM_VFP_CROSS
= arm-vfp-tcc
$(EXESUF
)
86 ARM_EABI_CROSS
= arm-eabi-tcc
$(EXESUF
)
87 ARM_CROSS
= $(ARM_FPA_CROSS
) $(ARM_FPA_LD_CROSS
) $(ARM_VFP_CROSS
) $(ARM_EABI_CROSS
)
88 C67_CROSS
= c67-tcc
$(EXESUF
)
90 CORE_FILES
= tcc.c libtcc.c tccpp.c tccgen.c tccelf.c tccasm.c tccrun.c
91 CORE_FILES
+= tcc.h config.h libtcc.h tcctok.h
92 I386_FILES
= $(CORE_FILES
) i386-gen.c i386-asm.c i386-asm.h i386-tok.h
93 WIN32_FILES
= $(CORE_FILES
) i386-gen.c i386-asm.c i386-asm.h i386-tok.h tccpe.c
94 WIN64_FILES
= $(CORE_FILES
) x86_64-gen.c i386-asm.c x86_64-asm.h tccpe.c
95 WINCE_FILES
= $(CORE_FILES
) arm-gen.c tccpe.c
96 X86_64_FILES
= $(CORE_FILES
) x86_64-gen.c i386-asm.c x86_64-asm.h
97 ARM_FILES
= $(CORE_FILES
) arm-gen.c
98 C67_FILES
= $(CORE_FILES
) c67-gen.c tcccoff.c
101 PROGS
+=tiny_impdef
$(EXESUF
) tiny_libmaker
$(EXESUF
)
102 NATIVE_FILES
=$(WIN64_FILES
)
103 PROGS_CROSS
=$(WIN32_CROSS
) $(I386_CROSS
) $(X64_CROSS
) $(ARM_CROSS
) $(C67_CROSS
)
104 LIBTCC1_CROSS
=lib
/i386-win32
/libtcc1.a
108 PROGS
+=tiny_impdef
$(EXESUF
) tiny_libmaker
$(EXESUF
)
109 NATIVE_FILES
=$(WIN32_FILES
)
110 PROGS_CROSS
=$(WIN64_CROSS
) $(I386_CROSS
) $(X64_CROSS
) $(ARM_CROSS
) $(C67_CROSS
)
111 LIBTCC1_CROSS
=lib
/x86_64-win32
/libtcc1.a
115 NATIVE_FILES
=$(I386_FILES
)
116 PROGS_CROSS
=$(X64_CROSS
) $(WIN32_CROSS
) $(WIN64_CROSS
) $(ARM_CROSS
) $(C67_CROSS
)
117 LIBTCC1_CROSS
=lib
/i386-win32
/libtcc1.a lib
/x86_64-win32
/libtcc1.a
121 ifeq ($(ARCH
),x86-64
)
122 NATIVE_FILES
=$(X86_64_FILES
)
123 PROGS_CROSS
=$(I386_CROSS
) $(WIN32_CROSS
) $(WIN64_CROSS
) $(ARM_CROSS
) $(C67_CROSS
)
124 LIBTCC1_CROSS
=lib
/i386-win32
/libtcc1.a lib
/x86_64-win32
/libtcc1.a lib
/i386
/libtcc1.a
128 NATIVE_FILES
=$(ARM_FILES
)
129 PROGS_CROSS
=$(I386_CROSS
) $(X64_CROSS
) $(WIN32_CROSS
) $(WIN64_CROSS
) $(C67_CROSS
)
140 ifdef CONFIG_USE_LIBGCC
144 TCCLIBS
= $(LIBTCC1
) $(LIBTCC
) $(BCHECK_O
)
145 TCCDOCS
= tcc
.1 tcc-doc.html tcc-doc.
info
148 PROGS
+=$(PROGS_CROSS
)
149 TCCLIBS
+=$(LIBTCC1_CROSS
)
152 all: $(PROGS
) $(TCCLIBS
) $(TCCDOCS
)
154 # Host Tiny C Compiler
155 tcc
$(EXESUF
): tcc.o
$(LIBTCC
)
156 $(CC
) -o
$@
$^
$(LIBS
) $(LDFLAGS
) $(LINK_LIBTCC
)
158 # Cross Tiny C Compilers
160 $(CC
) -o
$@ tcc.c
-DONE_SOURCE
$(DEFINES
) $(CFLAGS
) $(LIBS
) $(LDFLAGS
)
162 $(I386_CROSS
): DEFINES
= -DTCC_TARGET_I386 \
163 -DCONFIG_TCCDIR
="\"$(tccdir)/i386\""
164 $(X64_CROSS
): DEFINES
= -DTCC_TARGET_X86_64
165 $(WIN32_CROSS
): DEFINES
= -DTCC_TARGET_I386
-DTCC_TARGET_PE \
166 -DCONFIG_TCCDIR
="\"$(tccdir)/win32\"" \
167 -DCONFIG_TCC_LIBPATH
="\"\b/lib/32;\b/lib\""
168 $(WIN64_CROSS
): DEFINES
= -DTCC_TARGET_X86_64
-DTCC_TARGET_PE \
169 -DCONFIG_TCCDIR
="\"$(tccdir)/win32\"" \
170 -DCONFIG_TCC_LIBPATH
="\"\b/lib/64;\b/lib\""
171 $(WINCE_CROSS
): DEFINES
= -DTCC_TARGET_PE
172 $(C67_CROSS
): DEFINES
= -DTCC_TARGET_C67
173 $(ARM_FPA_CROSS
): DEFINES
= -DTCC_TARGET_ARM
174 $(ARM_FPA_LD_CROSS
)$(EXESUF
): DEFINES
= -DTCC_TARGET_ARM
-DLDOUBLE_SIZE
=12
175 $(ARM_VFP_CROSS
): DEFINES
= -DTCC_TARGET_ARM
-DTCC_ARM_VFP
176 $(ARM_EABI_CROSS
): DEFINES
= -DTCC_TARGET_ARM
-DTCC_ARM_EABI
178 $(I386_CROSS
): $(I386_FILES
)
179 $(X64_CROSS
): $(X86_64_FILES
)
180 $(WIN32_CROSS
): $(WIN32_FILES
)
181 $(WIN64_CROSS
): $(WIN64_FILES
)
182 $(WINCE_CROSS
): $(WINCE_FILES
)
183 $(C67_CROSS
): $(C67_FILES
)
184 $(ARM_FPA_CROSS
) $(ARM_FPA_LD_CROSS
) $(ARM_VFP_CROSS
) $(ARM_EABI_CROSS
): $(ARM_FILES
)
186 # libtcc generation and test
188 LIBTCC_OBJ
= $(filter-out tcc.o
,$(patsubst %.c
,%.o
,$(filter %.c
,$(NATIVE_FILES
))))
189 LIBTCC_INC
= $(filter %.h
,$(CORE_FILES
)) $(filter-out $(CORE_FILES
),$(NATIVE_FILES
))
191 LIBTCC_OBJ
= libtcc.o
192 LIBTCC_INC
= $(NATIVE_FILES
)
193 $(LIBTCC_OBJ
) tcc.o
: NATIVE_DEFINES
+= -DONE_SOURCE
196 $(LIBTCC_OBJ
) tcc.o
: %.o
: %.c
$(LIBTCC_INC
)
197 $(CC
) -o
$@
-c
$< $(NATIVE_DEFINES
) $(CFLAGS
)
199 libtcc.a
: $(LIBTCC_OBJ
)
202 libtcc.so
.1.0: $(LIBTCC_OBJ
)
203 $(CC
) -shared
-Wl
,-soname
,$@
-o
$@
$^
205 libtcc.so
.1.0: CFLAGS
+=-fPIC
208 tcc_p
$(EXESUF
): $(NATIVE_FILES
)
209 $(CC
) -o
$@
$< $(NATIVE_DEFINES
) $(CFLAGS_P
) $(LIBS_P
)
212 tiny_impdef
$(EXESUF
): win32
/tools
/tiny_impdef.c
213 $(CC
) -o
$@
$< $(CFLAGS
)
214 tiny_libmaker
$(EXESUF
): win32
/tools
/tiny_libmaker.c
215 $(CC
) -o
$@
$< $(CFLAGS
)
217 # TinyCC runtime libraries
219 @
$(MAKE
) -C lib native
220 lib
/%/libtcc1.a
: FORCE
$(PROGS_CROSS
)
221 @
$(MAKE
) -C lib cross TARGET
=$*
222 bcheck.o
: lib
/bcheck.c
223 gcc
-c
$< -o
$@
$(CFLAGS
)
227 TCC_INCLUDES
= stdarg.h stddef.h stdbool.h float.h varargs.h tcclib.h
230 INSTALLBIN
=$(INSTALL
) -s
232 INSTALLBIN
=$(INSTALL
)
236 install: $(PROGS
) $(TCCLIBS
) $(TCCDOCS
)
239 $(INSTALL
) -m755
$(PROGS
) "$(bindir)"
241 $(INSTALLBIN
) -m755
$(PROGS
) "$(bindir)"
243 mkdir
-p
"$(mandir)/man1"
244 -$(INSTALL
) tcc
.1 "$(mandir)/man1"
245 mkdir
-p
"$(infodir)"
246 -$(INSTALL
) tcc-doc.
info "$(infodir)"
248 mkdir
-p
"$(tccdir)/include"
250 $(INSTALL
) -m644
$(LIBTCC1
) "$(tccdir)"
253 $(INSTALL
) -m644
$(BCHECK_O
) "$(tccdir)"
255 $(INSTALL
) -m644
$(addprefix include/,$(TCC_INCLUDES
)) "$(tccdir)/include"
257 $(INSTALL
) -m755
$(LIBTCC
) "$(libdir)"
259 ln
-sf
"$(ln_libdir)/libtcc.so.1.0" "$(libdir)/libtcc.so.1"
260 ln
-sf
"$(ln_libdir)/libtcc.so.1.0" "$(libdir)/libtcc.so"
262 mkdir
-p
"$(includedir)"
263 $(INSTALL
) -m644 libtcc.h
"$(includedir)"
265 -$(INSTALL
) -m644 tcc-doc.html
"$(docdir)"
267 mkdir
-p
"$(tccdir)/win32/lib/32"
268 mkdir
-p
"$(tccdir)/win32/lib/64"
269 ifeq ($(ARCH
),x86-64
)
270 mkdir
-p
"$(tccdir)/i386"
271 $(INSTALL
) -m644 lib
/i386
/libtcc1.a
"$(tccdir)/i386"
272 cp
-r
"$(tccdir)/include" "$(tccdir)/i386"
274 $(INSTALL
) -m644 win32
/lib
/*.def
"$(tccdir)/win32/lib"
275 $(INSTALL
) -m644 lib
/i386-win32
/libtcc1.a
"$(tccdir)/win32/lib/32"
276 $(INSTALL
) -m644 lib
/x86_64-win32
/libtcc1.a
"$(tccdir)/win32/lib/64"
277 cp
-r win32
/include/.
"$(tccdir)/win32/include"
278 cp
-r
include/.
"$(tccdir)/win32/include"
282 rm -fv
$(foreach P
,$(PROGS
),"$(bindir)/$P")
283 rm -fv
$(foreach P
,$(LIBTCC1
) $(BCHECK_O
),"$(tccdir)/$P")
284 rm -fv
$(foreach P
,$(TCC_INCLUDES
),"$(tccdir)/include/$P")
285 rm -fv
"$(docdir)/tcc-doc.html" "$(mandir)/man1/tcc.1" "$(infodir)/tcc-doc.info"
286 rm -fv
"$(libdir)/$(LIBTCC)" "$(includedir)/libtcc.h"
287 rm -fv
"$(libdir)/libtcc.so*"
288 rm -rf
"$(tccdir)/win32"
289 -rmdir
$(tccdir
)/include
290 ifeq ($(ARCH
),x86-64
)
291 rm -rf
"$(tccdir)/i386"
295 install: $(PROGS
) $(TCCLIBS
) $(TCCDOCS
)
297 mkdir
-p
"$(tccdir)/lib"
298 mkdir
-p
"$(tccdir)/include"
299 mkdir
-p
"$(tccdir)/examples"
300 mkdir
-p
"$(tccdir)/doc"
301 mkdir
-p
"$(tccdir)/libtcc"
302 $(INSTALLBIN
) -m755
$(PROGS
) "$(tccdir)"
303 $(INSTALL
) -m644
$(LIBTCC1
) win32
/lib
/*.def
"$(tccdir)/lib"
304 cp
-r win32
/include/.
"$(tccdir)/include"
305 cp
-r win32
/examples
/.
"$(tccdir)/examples"
306 $(INSTALL
) -m644
$(addprefix include/,$(TCC_INCLUDES
)) "$(tccdir)/include"
307 $(INSTALL
) -m644 tcc-doc.html win32
/tcc-win32.txt
"$(tccdir)/doc"
308 $(INSTALL
) -m644
$(LIBTCC
) libtcc.h
"$(tccdir)/libtcc"
310 mkdir
-p
"$(tccdir)/lib/32"
311 mkdir
-p
"$(tccdir)/lib/64"
312 -$(INSTALL
) -m644 lib
/i386-win32
/libtcc1.a
"$(tccdir)/lib/32"
313 -$(INSTALL
) -m644 lib
/x86_64-win32
/libtcc1.a
"$(tccdir)/lib/64"
317 rm -rfv
"$(tccdir)/*"
320 # documentation and man page
321 tcc-doc.html
: tcc-doc.texi
322 -texi2html
-monolithic
-number
$<
325 -.
/texi2pod.pl
$< tcc.pod
326 -pod2man
--section
=1 --center
=" " --release
=" " tcc.pod
> $@
328 tcc-doc.
info: tcc-doc.texi
329 -makeinfo tcc-doc.texi
331 .PHONY
: all clean tar distclean install uninstall FORCE
333 # tar release (use 'make -k tar' on a checkouted tree)
334 TCC-VERSION
=tcc-
$(shell cat VERSION
)
336 rm -rf
/tmp
/$(TCC-VERSION
)
337 cp
-r .
/tmp
/$(TCC-VERSION
)
338 ( cd
/tmp
; tar zcvf ~
/$(TCC-VERSION
).
tar.gz
$(TCC-VERSION
) --exclude CVS
)
339 rm -rf
/tmp
/$(TCC-VERSION
)
348 rm -vf
$(PROGS
) tcc_p
$(EXESUF
) tcc.pod
*~
*.o
*.a
*.so
* *.out
*.exe libtcc_test
$(EXESUF
)
355 rm -vf config.h config.mak config.texi tcc
.1 tcc-doc.
info tcc-doc.html
358 @echo
"Please run ./configure."
361 endif # ifeq ($(TOP),.)