1 # --------------------------------------------------------------------------
3 # Tiny C Compiler Makefile
11 ifeq ($(findstring $(MAKECMDGOALS
),clean distclean),)
12 include $(TOP
)/config.mak
15 ifeq (-$(GCC_MAJOR
)-$(findstring $(GCC_MINOR
),56789)-,-4--)
16 CFLAGS
+= -D_FORTIFY_SOURCE
=0
29 ifneq ($(CONFIG_static
),yes
)
30 LIBTCC
= libtcc
$(DLLSUF
)
31 LIBTCCDEF
= libtcc.def
33 ifneq ($(CONFIG_debug
),yes
)
36 NATIVE_TARGET
= $(ARCH
)-win
$(if
$(findstring arm
,$(ARCH
)),ce
,32)
40 ifneq ($(CONFIG_ldl
),no
)
43 ifneq ($(CONFIG_pthread
),no
)
46 # make libtcc as static or dynamic library?
47 ifeq ($(CONFIG_static
),no
)
48 LIBTCC
=libtcc
$(DLLSUF
)
49 export LD_LIBRARY_PATH
:= $(CURDIR
)/$(TOP
)
50 ifneq ($(CONFIG_rpath
),no
)
52 LINK_LIBTCC
+= -Wl
,-rpath
,"$(libdir)"
54 # macOS doesn't support env-vars libdir out of the box - which we need for
55 # `make test' when libtcc.dylib is used (configure --disable-static), so
56 # we bake a relative path into the binary. $libdir is used after install.
57 LINK_LIBTCC
+= -Wl
,-rpath
,"@executable_path/$(TOP)" -Wl
,-rpath
,"$(libdir)"
58 # -current/compatibility_version must not contain letters.
59 MACOS_DYLIB_VERSION
:= $(firstword $(subst rc
, ,$(VERSION
)))
60 DYLIBVER
+= -current_version
$(MACOS_DYLIB_VERSION
)
61 DYLIBVER
+= -compatibility_version
$(MACOS_DYLIB_VERSION
)
65 NATIVE_TARGET
= $(ARCH
)
67 NATIVE_TARGET
= $(ARCH
)-osx
68 ifneq ($(CC_NAME
),tcc
)
69 LDFLAGS
+= -flat_namespace
-undefined warning
71 export MACOSX_DEPLOYMENT_TARGET
:= 10.6
75 # run local version of tcc with local libraries and includes
76 TCCFLAGS-unx
= -B
$(TOP
) -I
$(TOPSRC
)/include -I
$(TOPSRC
) -I
$(TOP
)
77 TCCFLAGS-win
= -B
$(TOPSRC
)/win32
-I
$(TOPSRC
)/include -I
$(TOPSRC
) -I
$(TOP
) -L
$(TOP
)
78 TCCFLAGS
= $(TCCFLAGS
$(CFG
))
79 TCC_LOCAL
= $(TOP
)/tcc
$(EXESUF
)
80 TCC
= $(TCC_LOCAL
) $(TCCFLAGS
)
82 CFLAGS_P
= $(CFLAGS
) -pg
-static
-DCONFIG_TCC_STATIC
-DTCC_PROFILE
84 LDFLAGS_P
= $(LDFLAGS
)
87 NATIVE_DEFINES_
$(CONFIG_i386
) += -DTCC_TARGET_I386
88 NATIVE_DEFINES_
$(CONFIG_x86_64
) += -DTCC_TARGET_X86_64
89 NATIVE_DEFINES_
$(CONFIG_WIN32
) += -DTCC_TARGET_PE
90 NATIVE_DEFINES_
$(CONFIG_OSX
) += -DTCC_TARGET_MACHO
91 NATIVE_DEFINES_
$(CONFIG_uClibc
) += -DTCC_UCLIBC
92 NATIVE_DEFINES_
$(CONFIG_musl
) += -DTCC_MUSL
93 NATIVE_DEFINES_
$(CONFIG_libgcc
) += -DCONFIG_USE_LIBGCC
94 NATIVE_DEFINES_
$(CONFIG_selinux
) += -DHAVE_SELINUX
95 NATIVE_DEFINES_
$(CONFIG_arm
) += -DTCC_TARGET_ARM
96 NATIVE_DEFINES_
$(CONFIG_arm_eabihf
) += -DTCC_ARM_EABI
-DTCC_ARM_HARDFLOAT
97 NATIVE_DEFINES_
$(CONFIG_arm_eabi
) += -DTCC_ARM_EABI
98 NATIVE_DEFINES_
$(CONFIG_arm_vfp
) += -DTCC_ARM_VFP
99 NATIVE_DEFINES_
$(CONFIG_arm64
) += -DTCC_TARGET_ARM64
100 NATIVE_DEFINES_
$(CONFIG_riscv64
) += -DTCC_TARGET_RISCV64
101 NATIVE_DEFINES_
$(CONFIG_BSD
) += -DTARGETOS_
$(TARGETOS
)
102 NATIVE_DEFINES_
$(CONFIG_Android
) += -DTARGETOS_ANDROID
103 NATIVE_DEFINES_
$(CONFIG_pie
) += -DCONFIG_TCC_PIE
104 NATIVE_DEFINES_
$(CONFIG_pic
) += -DCONFIG_TCC_PIC
105 NATIVE_DEFINES_no_
$(CONFIG_new_macho
) += -DCONFIG_NEW_MACHO
=0
106 NATIVE_DEFINES_
$(CONFIG_codesign
) += -DCONFIG_CODESIGN
107 NATIVE_DEFINES_
$(CONFIG_new-dtags
) += -DCONFIG_NEW_DTAGS
108 NATIVE_DEFINES_no_
$(CONFIG_bcheck
) += -DCONFIG_TCC_BCHECK
=0
109 NATIVE_DEFINES_no_
$(CONFIG_backtrace
) += -DCONFIG_TCC_BACKTRACE
=0
110 NATIVE_DEFINES
+= $(NATIVE_DEFINES_yes
) $(NATIVE_DEFINES_no_no
)
112 DEF-i386
= -DTCC_TARGET_I386
113 DEF-i386-win32
= -DTCC_TARGET_I386
-DTCC_TARGET_PE
114 DEF-i386-OpenBSD
= $(DEF-i386
) -DTARGETOS_OpenBSD
115 DEF-x86_64
= -DTCC_TARGET_X86_64
116 DEF-x86_64-win32
= -DTCC_TARGET_X86_64
-DTCC_TARGET_PE
117 DEF-x86_64-osx
= -DTCC_TARGET_X86_64
-DTCC_TARGET_MACHO
118 DEF-arm-fpa
= -DTCC_TARGET_ARM
119 DEF-arm-fpa-ld
= -DTCC_TARGET_ARM
-DLDOUBLE_SIZE
=12
120 DEF-arm-vfp
= -DTCC_TARGET_ARM
-DTCC_ARM_VFP
121 DEF-arm-eabi
= -DTCC_TARGET_ARM
-DTCC_ARM_VFP
-DTCC_ARM_EABI
122 DEF-arm-eabihf
= $(DEF-arm-eabi
) -DTCC_ARM_HARDFLOAT
123 DEF-arm
= $(DEF-arm-eabihf
)
124 DEF-arm-NetBSD
= $(DEF-arm-eabihf
) -DTARGETOS_NetBSD
125 DEF-arm-wince
= $(DEF-arm-eabihf
) -DTCC_TARGET_PE
126 DEF-arm64
= -DTCC_TARGET_ARM64
127 DEF-arm64-osx
= $(DEF-arm64
) -DTCC_TARGET_MACHO
128 DEF-arm64-FreeBSD
= $(DEF-arm64
) -DTARGETOS_FreeBSD
129 DEF-arm64-NetBSD
= $(DEF-arm64
) -DTARGETOS_NetBSD
130 DEF-arm64-OpenBSD
= $(DEF-arm64
) -DTARGETOS_OpenBSD
131 DEF-riscv64
= -DTCC_TARGET_RISCV64
132 DEF-c67
= -DTCC_TARGET_C67
-w
# disable warnigs
133 DEF-x86_64-FreeBSD
= $(DEF-x86_64
) -DTARGETOS_FreeBSD
134 DEF-x86_64-NetBSD
= $(DEF-x86_64
) -DTARGETOS_NetBSD
135 DEF-x86_64-OpenBSD
= $(DEF-x86_64
) -DTARGETOS_OpenBSD
137 DEF-
$(NATIVE_TARGET
) = $(NATIVE_DEFINES
)
139 ifeq ($(INCLUDED
),no
)
140 # --------------------------------------------------------------------------
141 # running top Makefile
144 TCCLIBS
= $(LIBTCCDEF
) $(LIBTCC
) $(LIBTCC1
)
145 TCCDOCS
= tcc
.1 tcc-doc.html tcc-doc.
info
147 all: $(PROGS
) $(TCCLIBS
) $(TCCDOCS
)
149 # cross compiler targets to build
150 TCC_X
= i386 x86_64 i386-win32 x86_64-win32 x86_64-osx arm arm64 arm-wince c67
151 TCC_X
+= riscv64 arm64-osx
152 # TCC_X += arm-fpa arm-fpa-ld arm-vfp arm-eabi
154 # cross libtcc1.a targets to build
155 LIBTCC1_X
= i386 x86_64 i386-win32 x86_64-win32 x86_64-osx arm arm64 arm-wince
156 LIBTCC1_X
+= riscv64 arm64-osx
158 PROGS_CROSS
= $(foreach X
,$(TCC_X
),$X-tcc
$(EXESUF
))
159 LIBTCC1_CROSS
= $(foreach X
,$(LIBTCC1_X
),$X-libtcc
1.a
)
161 # build cross compilers & libs
162 cross
: $(LIBTCC1_CROSS
) $(PROGS_CROSS
)
164 # build specific cross compiler & lib
165 cross-
%: %-tcc
$(EXESUF
) %-libtcc1.a
;
167 install: ; @
$(MAKE
) --no-print-directory
install$(CFG
)
168 install-strip
: ; @
$(MAKE
) --no-print-directory
install$(CFG
) CONFIG_strip
=yes
169 uninstall: ; @
$(MAKE
) --no-print-directory
uninstall$(CFG
)
175 # --------------------------------------------
177 T
= $(or
$(CROSS_TARGET
),$(NATIVE_TARGET
),unknown
)
178 X
= $(if
$(CROSS_TARGET
),$(CROSS_TARGET
)-)
180 DEFINES
+= $(DEF-
$T) $(DEF-all
)
181 DEFINES
+= $(if
$(ROOT-
$T),-DCONFIG_SYSROOT
="\"$(ROOT-$T)\"")
182 DEFINES
+= $(if
$(CRT-
$T),-DCONFIG_TCC_CRTPREFIX
="\"$(CRT-$T)\"")
183 DEFINES
+= $(if
$(LIB-
$T),-DCONFIG_TCC_LIBPATHS
="\"$(LIB-$T)\"")
184 DEFINES
+= $(if
$(INC-
$T),-DCONFIG_TCC_SYSINCLUDEPATHS
="\"$(INC-$T)\"")
185 DEFINES
+= $(if
$(ELF-
$T),-DCONFIG_TCC_ELFINTERP
="\"$(ELF-$T)\"")
186 DEFINES
+= $(DEF-
$(or
$(findstring win
,$T),unx
))
189 DEF-all
+= -DCONFIG_TCC_CROSSPREFIX
="\"$X\""
190 ifneq ($(CONFIG_WIN32
),yes
)
191 DEF-win
+= -DCONFIG_TCCDIR
="\"$(tccdir)/win32\""
195 # include custom configuration (see make help)
196 -include config-extra.mak
198 ifneq ($(T
),$(NATIVE_TARGET
))
199 # assume support files for cross-targets in "/usr/<triplet>" by default
200 TRIPLET-i386 ?
= i686-linux-gnu
201 TRIPLET-x86_64 ?
= x86_64-linux-gnu
202 TRIPLET-arm ?
= arm-linux-gnueabi
203 TRIPLET-arm64 ?
= aarch64-linux-gnu
204 TRIPLET-riscv64 ?
= riscv64-linux-gnu
205 MARCH-i386 ?
= i386-linux-gnu
206 MARCH-
$T ?
= $(TRIPLET-
$T)
207 TR
= $(if
$(TRIPLET-
$T),$T,ignored
)
208 CRT-
$(TR
) ?
= /usr
/$(TRIPLET-
$T)/lib
209 LIB-
$(TR
) ?
= {B
}:/usr
/$(TRIPLET-
$T)/lib
:/usr
/lib
/$(MARCH-
$T)
210 INC-
$(TR
) ?
= {B
}/include:/usr
/$(TRIPLET-
$T)/include:/usr
/include
213 CORE_FILES
= tcc.c tcctools.c libtcc.c tccpp.c tccgen.c tccdbg.c tccelf.c tccasm.c tccrun.c
214 CORE_FILES
+= tcc.h config.h libtcc.h tcctok.h
215 i386_FILES
= $(CORE_FILES
) i386-gen.c i386-link.c i386-asm.c i386-asm.h i386-tok.h
216 i386-win32_FILES
= $(i386_FILES
) tccpe.c
217 x86_64_FILES
= $(CORE_FILES
) x86_64-gen.c x86_64-link.c i386-asm.c x86_64-asm.h
218 x86_64-win32_FILES
= $(x86_64_FILES
) tccpe.c
219 x86_64-osx_FILES
= $(x86_64_FILES
) tccmacho.c
220 arm_FILES
= $(CORE_FILES
) arm-gen.c arm-link.c arm-asm.c arm-tok.h
221 arm-wince_FILES
= $(arm_FILES
) tccpe.c
222 arm-eabihf_FILES
= $(arm_FILES
)
223 arm-fpa_FILES
= $(arm_FILES
)
224 arm-fpa-ld_FILES
= $(arm_FILES
)
225 arm-vfp_FILES
= $(arm_FILES
)
226 arm-eabi_FILES
= $(arm_FILES
)
227 arm-eabihf_FILES
= $(arm_FILES
)
228 arm64_FILES
= $(CORE_FILES
) arm64-gen.c arm64-link.c arm64-asm.c
229 arm64-osx_FILES
= $(arm64_FILES
) tccmacho.c
230 c67_FILES
= $(CORE_FILES
) c67-gen.c c67-link.c tcccoff.c
231 riscv64_FILES
= $(CORE_FILES
) riscv64-gen.c riscv64-link.c riscv64-asm.c
233 TCCDEFS_H
$(subst yes
,,$(CONFIG_predefs
)) = tccdefs_.h
236 LIBTCC_SRC
= $(filter-out tcc.c tcctools.c
,$(filter %.c
,$($T_FILES)))
238 ifeq ($(ONE_SOURCE
),yes
)
239 LIBTCC_OBJ
= $(X
)libtcc.o
240 LIBTCC_INC
= $($T_FILES)
241 TCC_FILES
= $(X
)tcc.o
242 tcc.o
: DEFINES
+= -DONE_SOURCE
=0
243 $(X
)tcc.o
$(X
)libtcc.o
: $(TCCDEFS_H
)
245 LIBTCC_OBJ
= $(patsubst %.c
,$(X
)%.o
,$(LIBTCC_SRC
))
246 LIBTCC_INC
= $(filter %.h
%-gen.c
%-link.c
,$($T_FILES))
247 TCC_FILES
= $(X
)tcc.o
$(LIBTCC_OBJ
)
248 $(TCC_FILES
) : DEFINES
+= -DONE_SOURCE
=0
249 $(X
)tccpp.o
: $(TCCDEFS_H
)
252 GITHASH
:=$(shell git rev-parse
--abbrev-ref HEAD
2>/dev
/null || echo no
)
253 ifneq ($(GITHASH
),no
)
254 GITHASH
:=$(shell git log
-1 --date
=short
--pretty
='format:%cd $(GITHASH)@%h')
255 GITMODF
:=$(shell git diff
--quiet || echo
'*')
256 DEF_GITHASH
:= -DTCC_GITHASH
="\"$(GITHASH)$(GITMODF)\""
259 ifeq ($(CONFIG_debug
),yes
)
264 # convert "include/tccdefs.h" to "tccdefs_.h"
265 %_.h
: include/%.h conftest.c
266 $S$(CC
) -DC2STR
$(filter %.c
,$^
) -o c2str.exe
&& .
/c2str.exe
$< $@
268 # target specific object rule
269 $(X
)%.o
: %.c
$(LIBTCC_INC
)
270 $S$(CC
) -o
$@
-c
$< $(DEFINES
) $(CFLAGS
)
272 # additional dependencies
273 $(X
)tcc.o
: tcctools.c
274 $(X
)tcc.o
: DEFINES
+= $(DEF_GITHASH
)
276 # Host Tiny C Compiler
277 tcc
$(EXESUF
): tcc.o
$(LIBTCC
)
278 $S$(CC
) -o
$@
$^
$(LIBS
) $(LDFLAGS
) $(LINK_LIBTCC
)
280 # Cross Tiny C Compilers
281 # (the TCCDEFS_H dependency is only necessary for parallel makes,
282 # ala 'make -j x86_64-tcc i386-tcc tcc', which would create multiple
283 # c2str.exe and tccdefs_.h files in parallel, leading to access errors.
284 # This forces it to be made only once. Make normally tracks multiple paths
285 # to the same goals and only remakes it once, but that doesn't work over
286 # sub-makes like in this target)
287 %-tcc
$(EXESUF
): $(TCCDEFS_H
) FORCE
288 @
$(MAKE
) --no-print-directory
$@ CROSS_TARGET
=$* ONE_SOURCE
=$(or
$(ONE_SOURCE
),yes
)
290 $(CROSS_TARGET
)-tcc
$(EXESUF
): $(TCC_FILES
)
291 $S$(CC
) -o
$@
$^
$(LIBS
) $(LDFLAGS
)
294 tcc_p
$(EXESUF
): $($T_FILES)
295 $S$(CC
) -o
$@
$< $(DEFINES
) $(CFLAGS_P
) $(LIBS_P
) $(LDFLAGS_P
)
297 # static libtcc library
298 libtcc.a
: $(LIBTCC_OBJ
)
301 # dynamic libtcc library
302 libtcc.so
: $(LIBTCC_OBJ
)
303 $S$(CC
) -shared
-Wl
,-soname
,$@
-o
$@
$^
$(LIBS
) $(LDFLAGS
)
305 libtcc.so
: CFLAGS
+=-fPIC
306 libtcc.so
: LDFLAGS
+=-fPIC
308 # OSX dynamic libtcc library
309 libtcc.dylib
: $(LIBTCC_OBJ
)
310 $S$(CC
) -dynamiclib
$(DYLIBVER
) -install_name @rpath
/$@
-o
$@
$^
$(LDFLAGS
)
312 # OSX libtcc.dylib (without rpath/ prefix)
313 libtcc.osx
: $(LIBTCC_OBJ
)
314 $S$(CC
) -shared
-install_name libtcc.dylib
-o libtcc.dylib
$^
$(LDFLAGS
)
316 # windows dynamic libtcc library
317 libtcc.dll
: $(LIBTCC_OBJ
)
318 $S$(CC
) -shared
-o
$@
$^
$(LDFLAGS
)
319 libtcc.dll
: DEFINES
+= -DLIBTCC_AS_DLL
321 # import file for windows libtcc.dll
322 libtcc.def
: libtcc.dll tcc
$(EXESUF
)
323 $S$(XTCC
) -impdef
$< -o
$@
324 XTCC ?
= .
/tcc
$(EXESUF
)
326 # TinyCC runtime libraries
327 libtcc1.a
: tcc
$(EXESUF
) FORCE
331 %-libtcc1.a
: %-tcc
$(EXESUF
) FORCE
332 @
$(MAKE
) -C lib CROSS_TARGET
=$*
334 .PRECIOUS
: %-libtcc1.a
337 # WHICH = which $1 2>/dev/null
338 # some versions of gnu-make do not recognize 'command' as a shell builtin
339 WHICH
= sh
-c
'command -v $1'
341 run-if
= $(if
$(shell $(call WHICH
,$1)),$S $1 $2)
342 S
= $(if
$(findstring yes
,$(SILENT
)),@
$(info * $@
))
344 # --------------------------------------------------------------------------
345 # documentation and man page
346 tcc-doc.html
: tcc-doc.texi
347 $(call run-if
,makeinfo,--no-split
--html
--number-sections
-o
$@
$<)
349 tcc-doc.
info: tcc-doc.texi
350 $(call run-if
,makeinfo,$< || true
)
353 $(call run-if
,pod2man
,--section
=1 --center
="Tiny C Compiler" \
354 --release
="$(VERSION)" $< >$@
)
356 $(call run-if
,perl
,$(TOPSRC
)/texi2pod.pl
$< $@
)
360 # --------------------------------------------------------------------------
363 INSTALL
= install -m644
364 INSTALLBIN
= install -m755
$(STRIP_
$(CONFIG_strip
))
367 LIBTCC1_W
= $(filter %-win32-libtcc1.a
%-wince-libtcc1.a
,$(LIBTCC1_CROSS
))
368 LIBTCC1_U
= $(filter-out $(LIBTCC1_W
),$(wildcard *-libtcc1.a
))
369 IB
= $(if
$1,$(IM
) mkdir
-p
$2 && $(INSTALLBIN
) $1 $2)
370 IBw
= $(call IB
,$(wildcard $1),$2)
371 IF
= $(if
$1,$(IM
) mkdir
-p
$2 && $(INSTALL
) $1 $2)
372 IFw
= $(call IF
,$(wildcard $1),$2)
373 IR
= $(IM
) mkdir
-p
$2 && cp
-r
$1/.
$2
374 IM
= @echo
"-> $2 : $1" ;
375 BINCHECK
= $(if
$(wildcard $(PROGS
) *-tcc
$(EXESUF
)),,@echo
"Makefile: nothing found to install" && exit
1)
377 B_O
= bcheck.o bt-exe.o bt-log.o bt-dll.o
379 # install progs & libs
382 $(call IBw
,$(PROGS
) *-tcc
,"$(bindir)")
383 $(call IFw
,$(LIBTCC1
) $(B_O
) $(LIBTCC1_U
),"$(tccdir)")
384 $(call IF
,$(TOPSRC
)/include/*.h
$(TOPSRC
)/tcclib.h
,"$(tccdir)/include")
385 $(call
$(if
$(findstring .so
,$(LIBTCC
)),IBw
,IFw
),$(LIBTCC
),"$(libdir)")
386 $(call IF
,$(TOPSRC
)/libtcc.h
,"$(includedir)")
387 $(call IFw
,tcc
.1,"$(mandir)/man1")
388 $(call IFw
,tcc-doc.
info,"$(infodir)")
389 $(call IFw
,tcc-doc.html
,"$(docdir)")
390 ifneq "$(wildcard $(LIBTCC1_W))" ""
391 $(call IFw
,$(TOPSRC
)/win32
/lib
/*.def
$(LIBTCC1_W
),"$(tccdir)/win32/lib")
392 $(call IR
,$(TOPSRC
)/win32
/include,"$(tccdir)/win32/include")
393 $(call IF
,$(TOPSRC
)/include/*.h
$(TOPSRC
)/tcclib.h
,"$(tccdir)/win32/include")
398 @
rm -fv
$(addprefix "$(bindir)/",$(PROGS
) $(PROGS_CROSS
))
399 @
rm -fv
$(addprefix "$(libdir)/", libtcc
*.a libtcc
*.so libtcc.dylib
,$P)
400 @
rm -fv
$(addprefix "$(includedir)/", libtcc.h
)
401 @
rm -fv
"$(mandir)/man1/tcc.1" "$(infodir)/tcc-doc.info"
402 @
rm -fv
"$(docdir)/tcc-doc.html"
405 # install progs & libs on windows
408 $(call IBw
,$(PROGS
) *-tcc.exe libtcc.dll
,"$(bindir)")
409 $(call IF
,$(TOPSRC
)/win32
/lib
/*.def
,"$(tccdir)/lib")
410 $(call IFw
,libtcc1.a
$(B_O
) $(LIBTCC1_W
),"$(tccdir)/lib")
411 $(call IF
,$(TOPSRC
)/include/*.h
$(TOPSRC
)/tcclib.h
,"$(tccdir)/include")
412 $(call IR
,$(TOPSRC
)/win32
/include,"$(tccdir)/include")
413 $(call IR
,$(TOPSRC
)/win32
/examples
,"$(tccdir)/examples")
414 $(call IF
,$(TOPSRC
)/tests
/libtcc_test.c
,"$(tccdir)/examples")
415 $(call IFw
,$(TOPSRC
)/libtcc.h libtcc.def
,"$(libdir)")
416 $(call IFw
,$(TOPSRC
)/win32
/tcc-win32.txt tcc-doc.html
,"$(docdir)")
417 ifneq "$(wildcard $(LIBTCC1_U))" ""
418 $(call IFw
,$(LIBTCC1_U
),"$(tccdir)/lib")
419 $(call IF
,$(TOPSRC
)/include/*.h
$(TOPSRC
)/tcclib.h
,"$(tccdir)/lib/include")
422 # uninstall on windows
424 @
rm -fv
$(addprefix "$(bindir)/", libtcc
*.dll
$(PROGS
) *-tcc.exe
)
425 @
rm -fr
$(foreach P
,doc examples
include lib libtcc
,"$(tccdir)/$P/*")
426 @
rm -frv
$(addprefix "$(tccdir)/", doc examples
include lib libtcc
)
428 # the msys-git shell works to configure && make except it does not have install
429 ifeq ($(OS
),Windows_NT
)
430 ifeq ($(shell $(call WHICH
,install) || echo no
),no
)
436 # --------------------------------------------------------------------------
439 TAGFILES
= *.
[ch
] include/*.h lib
/*.
[chS
]
440 tags : ; ctags
$(TAGFILES
)
441 # cannot have both tags and TAGS on windows
442 ETAGS
: ; etags
$(TAGFILES
)
444 # create release tarball from *current* git branch (including tcc-doc.html
445 # and converting two files to CRLF)
446 TCC-VERSION
= tcc-
$(VERSION
)
447 TCC-VERSION
= tinycc-mob-
$(shell git rev-parse
--short
=7 HEAD
)
449 mkdir
-p
$(TCC-VERSION
)
450 ( cd
$(TCC-VERSION
) && git
--git-dir ..
/.git checkout
-f
)
451 cp tcc-doc.html
$(TCC-VERSION
)
452 for f in tcc-win32.txt build-tcc.bat
; do \
453 cat win32
/$$f | sed
's,\(.*\),\1\r,g' > $(TCC-VERSION
)/win32
/$$f ; \
455 tar cjf
$(TCC-VERSION
).
tar.bz2
$(TCC-VERSION
)
456 rm -rf
$(TCC-VERSION
)
460 $(if
$(wildcard $@
),,@echo
"Please run ./configure." && exit
1)
465 # run test(s) from tests2 subdir (see make help)
467 @
$(MAKE
) -C tests
/tests2
$@
468 # run test(s) from testspp subdir (see make help)
470 @
$(MAKE
) -C tests
/pp
$@
471 # run tests with code coverage
472 tcov-tes
% : tcc_c
$(EXESUF
)
474 @
$(MAKE
) --no-print-directory TCC_LOCAL
=$(CURDIR
)/$< tes
$*
475 tcc_c
$(EXESUF
): $($T_FILES)
476 $S$(TCC
) tcc.c
-o
$@
-ftest-coverage
$(DEFINES
) $(LIBS
)
479 @
rm -f tcc
$(EXESUF
) tcc_c
$(EXESUF
) tcc_p
$(EXESUF
) *-tcc
$(EXESUF
)
480 @
rm -f
tags ETAGS
*.o
*.a
*.so
* *.out
*.log lib
*.def
*.exe
*.dll
481 @
rm -f a.out
*.dylib
*_.h
*.pod
*.tcov
482 @
$(MAKE
) -s
-C lib
$@
483 @
$(MAKE
) -s
-C tests
$@
486 @
rm -vf config.h config.mak config.texi
489 .PHONY
: all clean test tar tags ETAGS doc
distclean install uninstall FORCE
493 @echo
" build native compiler (from separate objects)"
495 @echo
" build cross compilers (from one source)"
496 @echo
"make ONE_SOURCE=no/yes SILENT=no/yes"
497 @echo
" force building from separate/one object(s), less/more silently"
498 @echo
"make cross-TARGET"
499 @echo
" build one specific cross compiler for 'TARGET'. Currently supported:"
500 @echo
" $(wordlist 1,8,$(TCC_X))"
501 @echo
" $(wordlist 9,99,$(TCC_X))"
503 @echo
" run all tests"
504 @echo
"make tests2.all / make tests2.37 / make tests2.37+"
505 @echo
" run all/single test(s) from tests2, optionally update .expect"
506 @echo
"make testspp.all / make testspp.17"
507 @echo
" run all/single test(s) from tests/pp"
508 @echo
"make tcov-test / tcov-tests2... / tcov-testspp..."
509 @echo
" run tests as above with code coverage. After test(s) see tcc_c$(EXESUF).tcov"
510 @echo
"Other supported make targets:"
511 @echo
" install install-strip doc clean tags ETAGS tar distclean help"
512 @echo
"Custom configuration:"
513 @echo
" The makefile includes a file 'config-extra.mak' if it is present."
514 @echo
" This file may contain some custom configuration. For example:"
515 @echo
" NATIVE_DEFINES += -D..."
516 @echo
" Or for example to configure the search paths for a cross-compiler"
517 @echo
" assuming the support files in /usr/i686-linux-gnu:"
518 @echo
" ROOT-i386 = /usr/i686-linux-gnu"
519 @echo
" CRT-i386 = {R}/lib"
520 @echo
" LIB-i386 = {B}:{R}/lib"
521 @echo
" INC-i386 = {B}/include:{R}/include (*)"
522 @echo
" DEF-i386 += -D__linux__"
523 @echo
" Or also, for the cross platform files in /usr/<triplet>"
524 @echo
" TRIPLET-i386 = i686-linux-gnu"
525 @echo
" (*) tcc replaces {B} by 'tccdir' and {R} by 'CONFIG_SYSROOT'"
527 # --------------------------------------------------------------------------
528 endif # ($(INCLUDED),no)