tcc.h: Extend search path for include, lib and crt.
[tinycc.git] / Makefile
blob15ece52a80952b7ea1eb2afb588552541d2252d6
1 # --------------------------------------------------------------------------
3 # Tiny C Compiler Makefile
6 ifndef TOP
7 TOP = .
8 INCLUDED = no
9 endif
11 # Uncomment the next two commands to allow debug this Makefile
12 # When enabled, GNU make will no longer execute commands directly.
13 # All build commands will be executed using the shell. This needs more time
14 #OLD_SHELL := $(SHELL)
15 #SHELL = $(info Building $* $(if $<, (from $<))$(if $?, ($? newer)))$(OLD_SHELL)
17 ifeq ($(findstring $(MAKECMDGOALS),clean distclean),)
18 include $(TOP)/config.mak
19 endif
21 ifeq (-$(GCC_MAJOR)-$(findstring $(GCC_MINOR),56789)-,-4--)
22 CFLAGS += -D_FORTIFY_SOURCE=0
23 endif
25 LIBTCC = libtcc.a
26 LIBTCC1 = libtcc1.a
27 LINK_LIBTCC =
28 LIBS =
29 CFLAGS += -I$(TOP)
30 CFLAGS += $(CPPFLAGS)
31 VPATH = $(TOPSRC)
33 ifdef CONFIG_WIN32
34 CFG = -win
35 ifneq ($(CONFIG_static),yes)
36 LIBTCC = libtcc$(DLLSUF)
37 LIBTCCDEF = libtcc.def
38 endif
39 NATIVE_TARGET = $(ARCH)-win$(if $(findstring arm,$(ARCH)),ce,32)
40 else
41 CFG = -unx
42 LIBS=-lm -lpthread
43 ifneq ($(CONFIG_ldl),no)
44 LIBS+=-ldl
45 endif
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)
51 ifndef CONFIG_OSX
52 LINK_LIBTCC += -Wl,-rpath,"$(libdir)"
53 else
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 DYLIBVER += -current_version $(VERSION)
59 DYLIBVER += -compatibility_version $(VERSION)
60 endif
61 endif
62 endif
63 NATIVE_TARGET = $(ARCH)
64 ifdef CONFIG_OSX
65 NATIVE_TARGET = $(ARCH)-osx
66 ifneq ($(CC_NAME),tcc)
67 LDFLAGS += -flat_namespace -undefined warning
68 endif
69 export MACOSX_DEPLOYMENT_TARGET := 10.6
70 endif
71 endif
73 # run local version of tcc with local libraries and includes
74 TCCFLAGS-unx = -B$(TOP) -I$(TOPSRC)/include -I$(TOPSRC) -I$(TOP)
75 TCCFLAGS-win = -B$(TOPSRC)/win32 -I$(TOPSRC)/include -I$(TOPSRC) -I$(TOP) -L$(TOP)
76 TCCFLAGS = $(TCCFLAGS$(CFG))
77 TCC = $(TOP)/tcc$(EXESUF) $(TCCFLAGS)
79 CFLAGS_P = $(CFLAGS) -pg -static -DCONFIG_TCC_STATIC -DTCC_PROFILE
80 LIBS_P = $(LIBS)
81 LDFLAGS_P = $(LDFLAGS)
83 CONFIG_$(ARCH) = yes
84 NATIVE_DEFINES_$(CONFIG_i386) += -DTCC_TARGET_I386
85 NATIVE_DEFINES_$(CONFIG_x86_64) += -DTCC_TARGET_X86_64
86 NATIVE_DEFINES_$(CONFIG_WIN32) += -DTCC_TARGET_PE
87 NATIVE_DEFINES_$(CONFIG_OSX) += -DTCC_TARGET_MACHO
88 NATIVE_DEFINES_$(CONFIG_uClibc) += -DTCC_UCLIBC
89 NATIVE_DEFINES_$(CONFIG_musl) += -DTCC_MUSL
90 NATIVE_DEFINES_$(CONFIG_libgcc) += -DCONFIG_USE_LIBGCC
91 NATIVE_DEFINES_$(CONFIG_selinux) += -DHAVE_SELINUX
92 NATIVE_DEFINES_$(CONFIG_arm) += -DTCC_TARGET_ARM
93 NATIVE_DEFINES_$(CONFIG_arm_eabihf) += -DTCC_ARM_EABI -DTCC_ARM_HARDFLOAT
94 NATIVE_DEFINES_$(CONFIG_arm_eabi) += -DTCC_ARM_EABI
95 NATIVE_DEFINES_$(CONFIG_arm_vfp) += -DTCC_ARM_VFP
96 NATIVE_DEFINES_$(CONFIG_arm64) += -DTCC_TARGET_ARM64
97 NATIVE_DEFINES_$(CONFIG_riscv64) += -DTCC_TARGET_RISCV64
98 NATIVE_DEFINES_$(CONFIG_BSD) += -DTARGETOS_$(TARGETOS)
99 NATIVE_DEFINES_$(CONFIG_pie) += -DCONFIG_TCC_PIE
100 NATIVE_DEFINES_no_$(CONFIG_bcheck) += -DCONFIG_TCC_BCHECK=0
101 NATIVE_DEFINES_no_$(CONFIG_backtrace) += -DCONFIG_TCC_BACKTRACE=0
102 NATIVE_DEFINES += $(NATIVE_DEFINES_yes) $(NATIVE_DEFINES_no_no)
104 DEF-i386 = -DTCC_TARGET_I386
105 DEF-i386-win32 = -DTCC_TARGET_I386 -DTCC_TARGET_PE
106 DEF-i386-OpenBSD = $(DEF-i386) -DTARGETOS_OpenBSD
107 DEF-x86_64 = -DTCC_TARGET_X86_64
108 DEF-x86_64-win32 = -DTCC_TARGET_X86_64 -DTCC_TARGET_PE
109 DEF-x86_64-osx = -DTCC_TARGET_X86_64 -DTCC_TARGET_MACHO
110 DEF-arm-fpa = -DTCC_TARGET_ARM
111 DEF-arm-fpa-ld = -DTCC_TARGET_ARM -DLDOUBLE_SIZE=12
112 DEF-arm-vfp = -DTCC_TARGET_ARM -DTCC_ARM_VFP
113 DEF-arm-eabi = -DTCC_TARGET_ARM -DTCC_ARM_VFP -DTCC_ARM_EABI
114 DEF-arm-eabihf = $(DEF-arm-eabi) -DTCC_ARM_HARDFLOAT
115 DEF-arm = $(DEF-arm-eabihf)
116 DEF-arm-NetBSD = $(DEF-arm-eabihf) -DTARGETOS_NetBSD
117 DEF-arm-wince = $(DEF-arm-eabihf) -DTCC_TARGET_PE
118 DEF-arm64 = -DTCC_TARGET_ARM64
119 DEF-arm64-osx = $(DEF-arm64) -DTCC_TARGET_MACHO
120 DEF-arm64-FreeBSD = $(DEF-arm64) -DTARGETOS_FreeBSD
121 DEF-arm64-NetBSD = $(DEF-arm64) -DTARGETOS_NetBSD
122 DEF-arm64-OpenBSD = $(DEF-arm64) -DTARGETOS_OpenBSD
123 DEF-riscv64 = -DTCC_TARGET_RISCV64
124 DEF-c67 = -DTCC_TARGET_C67 -w # disable warnigs
125 DEF-x86_64-FreeBSD = $(DEF-x86_64) -DTARGETOS_FreeBSD
126 DEF-x86_64-NetBSD = $(DEF-x86_64) -DTARGETOS_NetBSD
127 DEF-x86_64-OpenBSD = $(DEF-x86_64) -DTARGETOS_OpenBSD
129 DEF-$(NATIVE_TARGET) = $(NATIVE_DEFINES)
131 ifeq ($(INCLUDED),no)
132 # --------------------------------------------------------------------------
133 # running top Makefile
135 PROGS = tcc$(EXESUF)
136 TCCLIBS = $(LIBTCCDEF) $(LIBTCC) $(LIBTCC1)
137 TCCDOCS = tcc.1 tcc-doc.html tcc-doc.info
139 all: $(PROGS) $(TCCLIBS) $(TCCDOCS)
141 # cross compiler targets to build
142 TCC_X = i386 x86_64 i386-win32 x86_64-win32 x86_64-osx arm arm64 arm-wince c67
143 TCC_X += riscv64 arm64-osx
144 # TCC_X += arm-fpa arm-fpa-ld arm-vfp arm-eabi
146 # cross libtcc1.a targets to build
147 LIBTCC1_X = i386 x86_64 i386-win32 x86_64-win32 x86_64-osx arm arm64 arm-wince
148 LIBTCC1_X += riscv64 arm64-osx
150 PROGS_CROSS = $(foreach X,$(TCC_X),$X-tcc$(EXESUF))
151 LIBTCC1_CROSS = $(foreach X,$(LIBTCC1_X),$X-libtcc1.a)
153 # build cross compilers & libs
154 cross: $(LIBTCC1_CROSS) $(PROGS_CROSS)
156 # build specific cross compiler & lib
157 cross-%: %-tcc$(EXESUF) %-libtcc1.a ;
159 install: ; @$(MAKE) --no-print-directory install$(CFG)
160 install-strip: ; @$(MAKE) --no-print-directory install$(CFG) CONFIG_strip=yes
161 uninstall: ; @$(MAKE) --no-print-directory uninstall$(CFG)
163 ifdef CONFIG_cross
164 all : cross
165 endif
167 # --------------------------------------------
169 T = $(or $(CROSS_TARGET),$(NATIVE_TARGET),unknown)
170 X = $(if $(CROSS_TARGET),$(CROSS_TARGET)-)
172 DEFINES += $(DEF-$T) $(DEF-all)
173 DEFINES += $(if $(ROOT-$T),-DCONFIG_SYSROOT="\"$(ROOT-$T)\"")
174 DEFINES += $(if $(CRT-$T),-DCONFIG_TCC_CRTPREFIX="\"$(CRT-$T)\"")
175 DEFINES += $(if $(LIB-$T),-DCONFIG_TCC_LIBPATHS="\"$(LIB-$T)\"")
176 DEFINES += $(if $(INC-$T),-DCONFIG_TCC_SYSINCLUDEPATHS="\"$(INC-$T)\"")
177 DEFINES += $(DEF-$(or $(findstring win,$T),unx))
179 ifneq ($(X),)
180 ifeq ($(CONFIG_WIN32),yes)
181 DEF-win += -DTCC_LIBTCC1="\"$(X)libtcc1.a\""
182 DEF-unx += -DTCC_LIBTCC1="\"lib/$(X)libtcc1.a\""
183 else
184 DEF-all += -DTCC_LIBTCC1="\"$(X)libtcc1.a\""
185 DEF-win += -DCONFIG_TCCDIR="\"$(tccdir)/win32\""
186 endif
187 endif
189 # include custom configuration (see make help)
190 -include config-extra.mak
192 CORE_FILES = tcc.c tcctools.c libtcc.c tccpp.c tccgen.c tccelf.c tccasm.c tccrun.c
193 CORE_FILES += tcc.h config.h libtcc.h tcctok.h
194 i386_FILES = $(CORE_FILES) i386-gen.c i386-link.c i386-asm.c i386-asm.h i386-tok.h
195 i386-win32_FILES = $(i386_FILES) tccpe.c
196 x86_64_FILES = $(CORE_FILES) x86_64-gen.c x86_64-link.c i386-asm.c x86_64-asm.h
197 x86_64-win32_FILES = $(x86_64_FILES) tccpe.c
198 x86_64-osx_FILES = $(x86_64_FILES) tccmacho.c
199 arm_FILES = $(CORE_FILES) arm-gen.c arm-link.c arm-asm.c arm-tok.h
200 arm-wince_FILES = $(arm_FILES) tccpe.c
201 arm-eabihf_FILES = $(arm_FILES)
202 arm-fpa_FILES = $(arm_FILES)
203 arm-fpa-ld_FILES = $(arm_FILES)
204 arm-vfp_FILES = $(arm_FILES)
205 arm-eabi_FILES = $(arm_FILES)
206 arm-eabihf_FILES = $(arm_FILES)
207 arm64_FILES = $(CORE_FILES) arm64-gen.c arm64-link.c arm64-asm.c
208 arm64-osx_FILES = $(arm64_FILES) tccmacho.c
209 c67_FILES = $(CORE_FILES) c67-gen.c c67-link.c tcccoff.c
210 riscv64_FILES = $(CORE_FILES) riscv64-gen.c riscv64-link.c riscv64-asm.c
212 TCCDEFS_H$(subst yes,,$(CONFIG_predefs)) = tccdefs_.h
214 # libtcc sources
215 LIBTCC_SRC = $(filter-out tcc.c tcctools.c,$(filter %.c,$($T_FILES)))
217 ifeq ($(ONE_SOURCE),yes)
218 LIBTCC_OBJ = $(X)libtcc.o
219 LIBTCC_INC = $($T_FILES)
220 TCC_FILES = $(X)tcc.o
221 tcc.o : DEFINES += -DONE_SOURCE=0
222 $(X)tcc.o $(X)libtcc.o : $(TCCDEFS_H)
223 else
224 LIBTCC_OBJ = $(patsubst %.c,$(X)%.o,$(LIBTCC_SRC))
225 LIBTCC_INC = $(filter %.h %-gen.c %-link.c,$($T_FILES))
226 TCC_FILES = $(X)tcc.o $(LIBTCC_OBJ)
227 $(TCC_FILES) : DEFINES += -DONE_SOURCE=0
228 $(X)tccpp.o : $(TCCDEFS_H)
229 endif
231 GITHASH := $(shell git rev-parse >/dev/null 2>&1 && git rev-parse --short HEAD || echo no)
232 ifneq ($(GITHASH),no)
233 DEF_GITHASH := -DTCC_GITHASH="\"$(shell git rev-parse --abbrev-ref HEAD):$(GITHASH)$(shell git diff --quiet || echo '-mod')\""
234 endif
236 ifeq ($(CONFIG_debug),yes)
237 CFLAGS += -g
238 LDFLAGS += -g
239 else
240 ifndef CONFIG_OSX
241 LDFLAGS += -s
242 endif
243 endif
245 # convert "include/tccdefs.h" to "tccdefs_.h"
246 %_.h : include/%.h conftest.c
247 $S$(CC) -DC2STR $(filter %.c,$^) -o c2str$(EXESUF) && ./c2str$(EXESUF) $< $@
249 # target specific object rule
250 $(X)%.o : %.c $(LIBTCC_INC)
251 $S$(CC) -o $@ -c $< $(DEFINES) $(CFLAGS)
253 # additional dependencies
254 $(X)tcc.o : tcctools.c
255 $(X)tcc.o : DEFINES += $(DEF_GITHASH)
257 # Host Tiny C Compiler
258 tcc$(EXESUF): tcc.o $(LIBTCC)
259 $S$(CC) -o $@ $^ $(LIBS) $(LDFLAGS) $(LINK_LIBTCC)
261 # Cross Tiny C Compilers
262 # (the TCCDEFS_H dependency is only necessary for parallel makes,
263 # ala 'make -j x86_64-tcc i386-tcc tcc', which would create multiple
264 # c2str and tccdefs_.h files in parallel, leading to access errors.
265 # This forces it to be made only once. Make normally tracks multiple paths
266 # to the same goals and only remakes it once, but that doesn't work over
267 # sub-makes like in this target)
268 %-tcc$(EXESUF): $(TCCDEFS_H) FORCE
269 @$(MAKE) --no-print-directory $@ CROSS_TARGET=$* ONE_SOURCE=$(or $(ONE_SOURCE),yes)
271 $(CROSS_TARGET)-tcc$(EXESUF): $(TCC_FILES)
272 $S$(CC) -o $@ $^ $(LIBS) $(LDFLAGS)
274 # profiling version
275 tcc_p$(EXESUF): $($T_FILES)
276 $S$(CC) -o $@ $< $(DEFINES) $(CFLAGS_P) $(LIBS_P) $(LDFLAGS_P)
278 # static libtcc library
279 libtcc.a: $(LIBTCC_OBJ)
280 $S$(AR) rcs $@ $^
282 # dynamic libtcc library
283 libtcc.so: $(LIBTCC_OBJ)
284 $S$(CC) -shared -Wl,-soname,$@ -o $@ $^ $(LDFLAGS)
286 libtcc.so: CFLAGS+=-fPIC
287 libtcc.so: LDFLAGS+=-fPIC
289 # OSX dynamic libtcc library
290 libtcc.dylib: $(LIBTCC_OBJ)
291 $S$(CC) -dynamiclib $(DYLIBVER) -install_name @rpath/$@ -o $@ $^ $(LDFLAGS)
293 # OSX libtcc.dylib (without rpath/ prefix)
294 libtcc.osx: $(LIBTCC_OBJ)
295 $S$(CC) -shared -install_name libtcc.dylib -o libtcc.dylib $^ $(LDFLAGS)
297 # windows dynamic libtcc library
298 libtcc.dll : $(LIBTCC_OBJ)
299 $S$(CC) -shared -o $@ $^ $(LDFLAGS)
300 libtcc.dll : DEFINES += -DLIBTCC_AS_DLL
302 # import file for windows libtcc.dll
303 libtcc.def : libtcc.dll tcc$(EXESUF)
304 $S$(XTCC) -impdef $< -o $@
305 XTCC ?= ./tcc$(EXESUF)
307 # TinyCC runtime libraries
308 libtcc1.a : tcc$(EXESUF) FORCE
309 @$(MAKE) -C lib
311 # Cross libtcc1.a
312 %-libtcc1.a : %-tcc$(EXESUF) FORCE
313 @$(MAKE) -C lib CROSS_TARGET=$*
315 .PRECIOUS: %-libtcc1.a
316 FORCE:
318 run-if = $(if $(shell which $1),$S $1 $2)
319 S = $(if $(findstring yes,$(SILENT)),@$(info * $@))
321 # --------------------------------------------------------------------------
322 # documentation and man page
323 tcc-doc.html: tcc-doc.texi
324 $(call run-if,makeinfo,--no-split --html --number-sections -o $@ $<)
326 tcc-doc.info: tcc-doc.texi
327 $(call run-if,makeinfo,$< || true)
329 tcc.1 : tcc-doc.pod
330 $(call run-if,pod2man,--section=1 --center="Tiny C Compiler" \
331 --release="$(VERSION)" $< >$@ && rm -f $<)
332 %.pod : %.texi
333 $(call run-if,perl,$(TOPSRC)/texi2pod.pl $< $@)
335 # --------------------------------------------------------------------------
336 # install
338 INSTALL = install -m644
339 INSTALLBIN = install -m755 $(STRIP_$(CONFIG_strip))
340 STRIP_yes = -s
342 LIBTCC1_W = $(filter %-win32-libtcc1.a %-wince-libtcc1.a,$(LIBTCC1_CROSS))
343 LIBTCC1_U = $(filter-out $(LIBTCC1_W),$(LIBTCC1_CROSS))
344 IB = $(if $1,$(IM) mkdir -p $2 && $(INSTALLBIN) $1 $2)
345 IBw = $(call IB,$(wildcard $1),$2)
346 IF = $(if $1,$(IM) mkdir -p $2 && $(INSTALL) $1 $2)
347 IFw = $(call IF,$(wildcard $1),$2)
348 IR = $(IM) mkdir -p $2 && cp -r $1/. $2
349 IM = $(info -> $2 : $1)@
351 B_O = bcheck.o bt-exe.o bt-log.o bt-dll.o
353 # install progs & libs
354 install-unx:
355 $(call IBw,$(PROGS) $(PROGS_CROSS),"$(bindir)")
356 $(call IFw,$(LIBTCC1) $(B_O) $(LIBTCC1_U),"$(tccdir)")
357 $(call IF,$(TOPSRC)/include/*.h $(TOPSRC)/tcclib.h,"$(tccdir)/include")
358 $(call $(if $(findstring .so,$(LIBTCC)),IBw,IFw),$(LIBTCC),"$(libdir)")
359 $(call IF,$(TOPSRC)/libtcc.h,"$(includedir)")
360 $(call IFw,tcc.1,"$(mandir)/man1")
361 $(call IFw,tcc-doc.info,"$(infodir)")
362 $(call IFw,tcc-doc.html,"$(docdir)")
363 ifneq "$(wildcard $(LIBTCC1_W))" ""
364 $(call IFw,$(TOPSRC)/win32/lib/*.def $(LIBTCC1_W),"$(tccdir)/win32/lib")
365 $(call IR,$(TOPSRC)/win32/include,"$(tccdir)/win32/include")
366 $(call IF,$(TOPSRC)/include/*.h $(TOPSRC)/tcclib.h,"$(tccdir)/win32/include")
367 endif
369 # uninstall
370 uninstall-unx:
371 @rm -fv $(foreach P,$(PROGS) $(PROGS_CROSS),"$(bindir)/$P")
372 @rm -fv "$(libdir)/libtcc.a" "$(libdir)/libtcc.so" "$(libdir)/libtcc.dylib" "$(includedir)/libtcc.h"
373 @rm -fv "$(mandir)/man1/tcc.1" "$(infodir)/tcc-doc.info"
374 @rm -fv "$(docdir)/tcc-doc.html"
375 @rm -frv "$(tccdir)"
377 # install progs & libs on windows
378 install-win:
379 $(call IBw,$(PROGS) $(PROGS_CROSS) $(subst libtcc.a,,$(LIBTCC)),"$(bindir)")
380 $(call IF,$(TOPSRC)/win32/lib/*.def,"$(tccdir)/lib")
381 $(call IFw,libtcc1.a $(B_O) $(LIBTCC1_W),"$(tccdir)/lib")
382 $(call IF,$(TOPSRC)/include/*.h $(TOPSRC)/tcclib.h,"$(tccdir)/include")
383 $(call IR,$(TOPSRC)/win32/include,"$(tccdir)/include")
384 $(call IR,$(TOPSRC)/win32/examples,"$(tccdir)/examples")
385 $(call IF,$(TOPSRC)/tests/libtcc_test.c,"$(tccdir)/examples")
386 $(call IFw,$(TOPSRC)/libtcc.h $(subst .dll,.def,$(LIBTCC)),"$(libdir)")
387 $(call IFw,$(TOPSRC)/win32/tcc-win32.txt tcc-doc.html,"$(docdir)")
388 ifneq "$(wildcard $(LIBTCC1_U))" ""
389 $(call IFw,$(LIBTCC1_U),"$(tccdir)/lib")
390 $(call IF,$(TOPSRC)/include/*.h $(TOPSRC)/tcclib.h,"$(tccdir)/lib/include")
391 endif
393 # the msys-git shell works to configure && make except it does not have install
394 ifeq ($(CONFIG_WIN32)-$(shell which install || echo no),yes-no)
395 install-win : INSTALL = cp
396 install-win : INSTALLBIN = cp
397 endif
399 # uninstall on windows
400 uninstall-win:
401 @rm -fv $(foreach P,libtcc.dll $(PROGS) *-tcc.exe,"$(bindir)"/$P)
402 @rm -fr $(foreach P,doc examples include lib libtcc,"$(tccdir)/$P"/*)
403 @rm -frv $(foreach P,doc examples include lib libtcc,"$(tccdir)/$P")
405 # --------------------------------------------------------------------------
406 # other stuff
408 TAGFILES = *.[ch] include/*.h lib/*.[chS]
409 tags : ; ctags $(TAGFILES)
410 # cannot have both tags and TAGS on windows
411 ETAGS : ; etags $(TAGFILES)
413 # documentation
414 doc: tcc-doc.html tcc-doc.info tcc.1
417 # create release tarball from *current* git branch (including tcc-doc.html
418 # and converting two files to CRLF)
419 TCC-VERSION = tcc-$(VERSION)
420 TCC-VERSION = tinycc-mob-$(shell git rev-parse --short=7 HEAD)
421 tar: tcc-doc.html
422 mkdir -p $(TCC-VERSION)
423 ( cd $(TCC-VERSION) && git --git-dir ../.git checkout -f )
424 cp tcc-doc.html $(TCC-VERSION)
425 for f in tcc-win32.txt build-tcc.bat ; do \
426 cat win32/$$f | sed 's,\(.*\),\1\r,g' > $(TCC-VERSION)/win32/$$f ; \
427 done
428 tar cjf $(TCC-VERSION).tar.bz2 $(TCC-VERSION)
429 rm -rf $(TCC-VERSION)
430 git reset
432 config.mak:
433 $(if $(wildcard $@),,@echo "Please run ./configure." && exit 1)
435 # run all tests
436 test:
437 @$(MAKE) -C tests
438 # run test(s) from tests2 subdir (see make help)
439 tests2.%:
440 @$(MAKE) -C tests/tests2 $@
442 testspp.%:
443 @$(MAKE) -C tests/pp $@
445 clean:
446 @rm -f tcc$(EXESUF) tcc_p$(EXESUF) *-tcc$(EXESUF) tcc.pod tags ETAGS
447 @rm -f *.o *.a *.so* *.out *.log lib*.def *.exe *.dll a.out *.dylib *_.h
448 @$(MAKE) -s -C lib $@
449 @$(MAKE) -s -C tests $@
451 distclean: clean
452 @rm -fv config.h config.mak config.texi tcc.1 tcc-doc.info tcc-doc.html
454 .PHONY: all clean test tar tags ETAGS distclean install uninstall FORCE
456 help:
457 @echo "make"
458 @echo " build native compiler (from separate objects)"
459 @echo ""
460 @echo "make cross"
461 @echo " build cross compilers (from one source)"
462 @echo ""
463 @echo "make ONE_SOURCE=no/yes SILENT=no/yes"
464 @echo " force building from separate/one object(s), less/more silently"
465 @echo ""
466 @echo "make cross-TARGET"
467 @echo " build one specific cross compiler for 'TARGET'. Currently supported:"
468 @echo " $(wordlist 1,6,$(TCC_X))"
469 @echo " $(wordlist 7,99,$(TCC_X))"
470 @echo ""
471 @echo "make test"
472 @echo " run all tests"
473 @echo ""
474 @echo "make tests2.all / make tests2.37 / make tests2.37+"
475 @echo " run all/single test(s) from tests2, optionally update .expect"
476 @echo ""
477 @echo "make testspp.all / make testspp.17"
478 @echo " run all/single test(s) from tests/pp"
479 @echo ""
480 @echo "Other supported make targets:"
481 @echo " install install-strip doc clean tags ETAGS tar distclean help"
482 @echo ""
483 @echo "Custom configuration:"
484 @echo " The makefile includes a file 'config-extra.mak' if it is present."
485 @echo " This file may contain some custom configuration. For example:"
486 @echo " NATIVE_DEFINES += -D..."
487 @echo " Or for example to configure the search paths for a cross-compiler"
488 @echo " that expects the linux files in <tccdir>/i386-linux:"
489 @echo " ROOT-i386 = {B}/i386-linux"
490 @echo " CRT-i386 = {B}/i386-linux/usr/lib"
491 @echo " LIB-i386 = {B}/i386-linux/lib:{B}/i386-linux/usr/lib"
492 @echo " INC-i386 = {B}/lib/include:{B}/i386-linux/usr/include"
493 @echo " DEF-i386 += -D__linux__"
495 # --------------------------------------------------------------------------
496 endif # ($(INCLUDED),no)