From 0a624782dfc8fee6f0600066b135d3b20e4274f4 Mon Sep 17 00:00:00 2001 From: grischka Date: Sat, 1 Oct 2016 21:06:33 +0200 Subject: [PATCH] build: revert Makefiles to 0.9.26 state (mostly) Except - that libtcc1.a is now installed in subdirs i386/ etc. - the support for arm and arm64 - some of the "Darwin" fixes - tests are mosly unchanged Also - removed the "legacy links for cross compilers" (was total mess) - removed "out-of-tree" build support (was broken anyway) --- Makefile | 348 ++++++++++++++++-------------------------- configure | 321 +++++++++++++++++--------------------- lib/Makefile | 100 +++++------- libtcc.c | 6 +- tcc.h | 11 +- tccelf.c | 19 +-- tests/Makefile | 109 ++++++------- tests/pp/Makefile | 9 +- tests/tests2/Makefile | 24 +-- win32/build-tcc.bat | 19 +-- 10 files changed, 383 insertions(+), 583 deletions(-) diff --git a/Makefile b/Makefile index 2d6590cb..75d73aa0 100644 --- a/Makefile +++ b/Makefile @@ -4,49 +4,52 @@ TOP ?= . include $(TOP)/config.mak -VPATH = $(top_srcdir) +VPATH = $(TOP) -CPPFLAGS += -I$(TOP) # for config.h - -ifneq (-$(findstring gcc,$(CC))-,-gcc-) -ifeq (-$(findstring clang,$(CC))-,-clang-) -# make clang accept gnuisms in libtcc1.c -CFLAGS+=-fheinous-gnu-extensions -endif +ifeq (-$(findstring gcc,$(CC))-,-gcc-) + ifeq (-$(GCC_MAJOR)-$(findstring $(GCC_MINOR),56789)-,-4--) + CFLAGS += -D_FORTIFY_SOURCE=0 + endif +else + ifeq (-$(findstring clang,$(CC))-,-clang-) + # make clang accept gnuisms in libtcc1.c + CFLAGS+=-fheinous-gnu-extensions + endif endif -CPPFLAGS_P=$(CPPFLAGS) -DCONFIG_TCC_STATIC -CFLAGS_P=$(CFLAGS) -pg -static +CFLAGS_P = $(CFLAGS) -pg -static -DCONFIG_TCC_STATIC LIBS_P= -LDFLAGS_P=$(LDFLAGS) +LDFLAGS_P = $(LDFLAGS) -ifdef CONFIG_WIN64 -CONFIG_WIN32=yes -endif +LIBTCC = libtcc.a +LIBTCC1 = libtcc1.a +LINK_LIBTCC = +LIBS = -ifndef CONFIG_WIN32 -LIBS=-lm -ifndef CONFIG_NOLDL -LIBS+=-ldl -endif -endif - -# make libtcc as static or dynamic library? -ifdef DISABLE_STATIC -ifndef CONFIG_WIN32 -LIBTCC=libtcc.so.1.0 +ifdef CONFIG_WIN32 + ifeq ($(ARCH),x86-64) + CONFIG_WIN64=yes + endif + STRIP_BINARIES = yes + LIBTCC = libtcc.dll else -LIBTCC=libtcc.dll -LIBTCC_DLL=yes -LIBTCC_EXTRA=libtcc.def libtcc.a + LIBS=-lm + ifndef CONFIG_NOLDL + LIBS+=-ldl + endif + # make libtcc as static or dynamic library? + ifdef DISABLE_STATIC + LIBTCC=libtcc.so + ifndef DISABLE_RPATH + LINK_LIBTCC += -Wl,-rpath,"$(libdir)" + export LD_LIBRARY_PATH := $(CURDIR)/$(TOP) + endif + endif endif -LINK_LIBTCC=-Wl,-rpath,"$(libdir)" -ifdef DISABLE_RPATH -LINK_LIBTCC= -endif -else -LIBTCC=libtcc.a -LINK_LIBTCC= + +ifeq ($(TARGETOS),Darwin) + CFLAGS += -Wl,-flat_namespace,-undefined,warning + export MACOSX_DEPLOYMENT_TARGET:=10.2 endif CONFIG_$(ARCH) = yes @@ -64,53 +67,20 @@ NATIVE_DEFINES += $(NATIVE_DEFINES_yes) ifeq ($(TOP),.) PROGS=tcc$(EXESUF) -I386_CROSS = i386-linux-gnu-tcc$(EXESUF) -WIN32_CROSS = i386-win-mingw32-tcc$(EXESUF) -WIN64_CROSS = x86_64-win-mingw32-tcc$(EXESUF) -WINCE_CROSS = arm-win-mingw32ce-tcc$(EXESUF) -X64_CROSS = x86_64-linux-gnu-tcc$(EXESUF) -ARM_FPA_CROSS = arm-linux-fpa-tcc$(EXESUF) -ARM_FPA_LD_CROSS = arm-linux-fpa-ld-tcc$(EXESUF) -ARM_VFP_CROSS = arm-linux-gnu-tcc$(EXESUF) -ARM_EABI_CROSS = arm-linux-gnueabi-tcc$(EXESUF) -ARM_EABIHF_CROSS = arm-linux-gnueabihf-tcc$(EXESUF) +I386_CROSS = i386-tcc$(EXESUF) +WIN32_CROSS = i386-win32-tcc$(EXESUF) +WIN64_CROSS = x86_64-win32-tcc$(EXESUF) +WINCE_CROSS = arm-wince-tcc$(EXESUF) +X64_CROSS = x86_64-tcc$(EXESUF) +ARM_FPA_CROSS = arm-fpa-tcc$(EXESUF) +ARM_FPA_LD_CROSS = arm-fpa-ld-tcc$(EXESUF) +ARM_VFP_CROSS = arm-vfp-tcc$(EXESUF) +ARM_EABI_CROSS = arm-eabi-tcc$(EXESUF) +ARM_EABIHF_CROSS = arm-eabihf-tcc$(EXESUF) ARM_CROSS = $(ARM_FPA_CROSS) $(ARM_FPA_LD_CROSS) $(ARM_VFP_CROSS) $(ARM_EABI_CROSS) ARM64_CROSS = arm64-tcc$(EXESUF) C67_CROSS = c67-tcc$(EXESUF) -# Legacy symlinks for cross compilers -$(I386_CROSS)_LINK = i386-tcc$(EXESUF) -$(WIN32_CROSS)_LINK = i386-win-tcc$(EXESUF) -$(WIN64_CROSS)_LINK = x86_64-win-tcc$(EXESUF) -$(WINCE_CROSS)_LINK = arm-win-tcc$(EXESUF) -$(X64_CROSS)_LINK = x86_64-tcc$(EXESUF) -$(ARM_FPA_CROSS)_LINK = arm-fpa-tcc$(EXESUF) -$(ARM_FPA_LD_CROSS)_LINK = arm-fpa-ld-tcc$(EXESUF) -$(ARM_VFP_CROSS)_LINK = arm-vfp-tcc$(EXESUF) -$(ARM_EABI_CROSS)_LINK = arm-eabi-tcc$(EXESUF) - -ifeq ($(TARGETOS),Windows) -ifeq ($(ARCH),i386) -PROGS:=$($(WIN32_CROSS)_LINK) -$($(WIN32_CROSS)_LINK)_TCC = yes -endif -ifeq ($(ARCH),x86-64) -PROGS:=$($(WIN64_CROSS)_LINK) -$($(WIN64_CROSS)_LINK)_TCC = yes -endif -endif - -ifeq ($(TARGETOS),Linux) -ifeq ($(ARCH),i386) -PROGS:=$($(I386_CROSS)_LINK) -$($(I386_CROSS)_LINK)_TCC = yes -endif -ifeq ($(ARCH),x86-64) -PROGS:=$($(X64_CROSS)_LINK) -$($(X64_CROSS)_LINK)_TCC = yes -endif -endif - CORE_FILES = tcc.c libtcc.c tccpp.c tccgen.c tccelf.c tccasm.c tccrun.c CORE_FILES += tcc.h config.h libtcc.h tcctok.h I386_FILES = $(CORE_FILES) i386-gen.c i386-asm.c i386-asm.h i386-tok.h @@ -126,102 +96,84 @@ ifdef CONFIG_WIN64 PROGS+=tiny_impdef$(EXESUF) NATIVE_FILES=$(WIN64_FILES) PROGS_CROSS=$(WIN32_CROSS) $(I386_CROSS) $(X64_CROSS) $(ARM_CROSS) $(ARM64_CROSS) $(C67_CROSS) $(WINCE_CROSS) -LIBTCC1_CROSS=lib/i386-win/libtcc1.a -LIBTCC1=libtcc1.a +LIBTCC1_CROSS=lib/i386-win32/libtcc1.a + else ifdef CONFIG_WIN32 PROGS+=tiny_impdef$(EXESUF) NATIVE_FILES=$(WIN32_FILES) PROGS_CROSS=$(WIN64_CROSS) $(I386_CROSS) $(X64_CROSS) $(ARM_CROSS) $(ARM64_CROSS) $(C67_CROSS) $(WINCE_CROSS) -LIBTCC1_CROSS=lib/x86_64-win/libtcc1.a -LIBTCC1=libtcc1.a +LIBTCC1_CROSS=lib/x86_64-win32/libtcc1.a + else ifeq ($(ARCH),i386) NATIVE_FILES=$(I386_FILES) -PROGS_CROSS=$($(X64_CROSS)_LINK) $($(WIN32_CROSS)_LINK) $($(WIN64_CROSS)_LINK) $(ARM_CROSS) $(ARM64_CROSS) $(C67_CROSS) $(WINCE_CROSS) -LIBTCC1_CROSS=lib/i386-win/libtcc1.a lib/x86_64-win/libtcc1.a lib/i386/libtcc1.a lib/x86_64/libtcc1.a \ - lib/arm64/libtcc1.a -LIBTCC1=libtcc1.a +PROGS_CROSS=$(X64_CROSS) $(WIN32_CROSS) $(WIN64_CROSS) $(ARM_CROSS) $(ARM64_CROSS) $(C67_CROSS) $(WINCE_CROSS) +LIBTCC1_CROSS=lib/i386-win32/libtcc1.a lib/x86_64-win32/libtcc1.a + else ifeq ($(ARCH),x86-64) -ifeq ($(TARGETOS),Darwin) NATIVE_FILES=$(X86_64_FILES) -PROGS_CROSS=$($(I386_CROSS)_LINK) $($(WIN32_CROSS)_LINK) $($(WIN64_CROSS)_LINK) $(ARM_CROSS) $(C67_CROSS) $(WINCE_CROSS) -LIBTCC1_CROSS=lib/i386-win/libtcc1.a lib/x86_64-win/libtcc1.a lib/i386/libtcc1.a lib/x86_64/libtcc1.a -LIBTCC1=libtcc1.a -else -NATIVE_FILES=$(X86_64_FILES) -PROGS_CROSS=$($(I386_CROSS)_LINK) $($(WIN32_CROSS)_LINK) $($(WIN64_CROSS)_LINK) $(ARM_CROSS) $(ARM64_CROSS) $(C67_CROSS) $(WINCE_CROSS) -LIBTCC1_CROSS=lib/i386-win/libtcc1.a lib/x86_64-win/libtcc1.a lib/i386/libtcc1.a lib/x86_64/libtcc1.a \ - lib/arm64/libtcc1.a -LIBTCC1=libtcc1.a -endif +PROGS_CROSS=$(I386_CROSS) $(WIN32_CROSS) $(WIN64_CROSS) $(ARM_CROSS) $(ARM64_CROSS) $(C67_CROSS) $(WINCE_CROSS) +LIBTCC1_CROSS=lib/i386-win32/libtcc1.a lib/x86_64-win32/libtcc1.a + else ifeq ($(ARCH),arm) NATIVE_FILES=$(ARM_FILES) PROGS_CROSS=$(I386_CROSS) $(X64_CROSS) $(WIN32_CROSS) $(WIN64_CROSS) $(ARM64_CROSS) $(C67_CROSS) $(WINCE_CROSS) -LIBTCC1=libtcc1.a -LIBTCC1_CROSS=lib/i386-win/libtcc1.a lib/x86_64-win/libtcc1.a lib/i386/libtcc1.a + else ifeq ($(ARCH),arm64) NATIVE_FILES=$(ARM64_FILES) PROGS_CROSS=$(I386_CROSS) $(X64_CROSS) $(WIN32_CROSS) $(WIN64_CROSS) $(ARM_CROSS) $(C67_CROSS) $(WINCE_CROSS) -LIBTCC1=libtcc1.a -LIBTCC1_CROSS=lib/i386-win/libtcc1.a lib/x86_64-win/libtcc1.a lib/i386/libtcc1.a endif -PROGS_CROSS_LINK=$(foreach PROG_CROSS,$(PROGS_CROSS),$($(PROG_CROSS)_LINK)) -PROGS+=tiny_libmaker$(EXESUF) +ifeq ($(TARGETOS),Darwin) + PROGS += tiny_libmaker$(EXESUF) +endif -TCCLIBS = $(LIBTCC1) $(LIBTCC) $(LIBTCC_EXTRA) +TCCLIBS = $(LIBTCC1) $(LIBTCC) TCCDOCS = tcc.1 tcc-doc.html tcc-doc.info ifdef CONFIG_CROSS -PROGS+=$(PROGS_CROSS) -TCCLIBS+=$(LIBTCC1_CROSS) + PROGS += $(PROGS_CROSS) + TCCLIBS += $(LIBTCC1_CROSS) endif all: $(PROGS) $(TCCLIBS) $(TCCDOCS) -ifdef ONE_SOURCE -NATIVE_TCC_REQUISITES=tcc.o -else -NATIVE_TCC_REQUISITES=tcc.o $(LIBTCC) -endif - # Host Tiny C Compiler -tcc$(EXESUF): $(NATIVE_TCC_REQUISITES) - $(CC) -o $@ $^ $(LIBS) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) $(LINK_LIBTCC) +tcc$(EXESUF): tcc.c $(LIBTCC) + $(CC) -o $@ $^ $(LIBS) $(CFLAGS) $(LDFLAGS) $(LINK_LIBTCC) # Cross Tiny C Compilers %-tcc$(EXESUF): tcc.c - $(CC) -o $@ $< -DONE_SOURCE $(if $($@_TCC),$(NATIVE_DEFINES),$(DEFINES)) $(CPPFLAGS) $(CFLAGS) $(LIBS) $(LDFLAGS) - $(if $($@_LINK),ln -sf $@ $($@_LINK)) - $(if $($@_TCC),ln -sf $@ tcc$(EXESUF)) + $(CC) -o $@ $< -DONE_SOURCE $(DEFINES) $(CFLAGS) $(LIBS) $(LDFLAGS) # profiling version tcc_p$(EXESUF): $(NATIVE_FILES) $(CC) -o $@ $< -DONE_SOURCE $(NATIVE_DEFINES) $(CPPFLAGS_P) $(CFLAGS_P) $(LIBS_P) $(LDFLAGS_P) -$(I386_CROSS) $($(I386_CROSS)_LINK): DEFINES = -DTCC_TARGET_I386 -$(X64_CROSS) $($(X64_CROSS)_LINK): DEFINES = -DTCC_TARGET_X86_64 -$(WIN32_CROSS) $($(WIN32_CROSS)_LINK): DEFINES = -DTCC_TARGET_I386 -DTCC_TARGET_PE \ +$(I386_CROSS): DEFINES = -DTCC_TARGET_I386 \ + -DCONFIG_TCCDIR="\"$(tccdir)/i386\"" +$(X64_CROSS) : DEFINES = -DTCC_TARGET_X86_64 + -DCONFIG_TCCDIR="\"$(tccdir)/x86_64\"" +$(WIN32_CROSS) : DEFINES = -DTCC_TARGET_I386 -DTCC_TARGET_PE \ -DCONFIG_TCCDIR="\"$(tccdir)/win32\"" \ -DCONFIG_TCC_LIBPATHS="\"{B}/lib/32;{B}/lib\"" -$(WIN64_CROSS) $($(WIN64_CROSS)_LINK): DEFINES = -DTCC_TARGET_X86_64 -DTCC_TARGET_PE \ +$(WIN64_CROSS) : DEFINES = -DTCC_TARGET_X86_64 -DTCC_TARGET_PE \ -DCONFIG_TCCDIR="\"$(tccdir)/win32\"" \ -DCONFIG_TCC_LIBPATHS="\"{B}/lib/64;{B}/lib\"" $(WINCE_CROSS): DEFINES = -DTCC_TARGET_PE -$(C67_CROSS): DEFINES = -DTCC_TARGET_C67 +$(C67_CROSS): DEFINES = -DTCC_TARGET_C67 -w # disable warnigs $(ARM_FPA_CROSS): DEFINES = -DTCC_TARGET_ARM $(ARM_FPA_LD_CROSS)$(EXESUF): DEFINES = -DTCC_TARGET_ARM -DLDOUBLE_SIZE=12 $(ARM_VFP_CROSS): DEFINES = -DTCC_TARGET_ARM -DTCC_ARM_VFP $(ARM_EABI_CROSS): DEFINES = -DTCC_TARGET_ARM -DTCC_ARM_EABI -DTCC_ARM_VFP $(ARM64_CROSS): DEFINES = -DTCC_TARGET_ARM64 -$(I386_CROSS) $($(I386_CROSS)_LINK): $(I386_FILES) -$(X64_CROSS) $($(X64_CROSS)_LINK): $(X86_64_FILES) -$(WIN32_CROSS) $($(WIN32_CROSS)_LINK): $(WIN32_FILES) -$(WIN64_CROSS) $($(WIN64_CROSS)_LINK): $(WIN64_FILES) -$(WINCE_CROSS) $($(WINCE_CROSS)_LINK): $(WINCE_FILES) -$(C67_CROSS) $($(C67_CROSS)_LINK): $(C67_FILES) +$(I386_CROSS) : $(I386_FILES) +$(X64_CROSS) : $(X86_64_FILES) +$(WIN32_CROSS) : $(WIN32_FILES) +$(WIN64_CROSS) : $(WIN64_FILES) +$(WINCE_CROSS) : $(WINCE_FILES) +$(C67_CROSS) : $(C67_FILES) $(ARM_FPA_CROSS) $(ARM_FPA_LD_CROSS) $(ARM_VFP_CROSS) $(ARM_EABI_CROSS): $(ARM_FILES) -$($(ARM_FPA_CROSS)_LINK) $($(ARM_FPA_LD_CROSS)_LINK) $($(ARM_VFP_CROSS)_LINK) $($(ARM_EABI_CROSS)_LINK): $(ARM_FILES) $(ARM64_CROSS): $(ARM64_FILES) # libtcc generation and test @@ -236,34 +188,33 @@ tcc.o : NATIVE_DEFINES += -DONE_SOURCE endif $(LIBTCC_OBJ) tcc.o : %.o : %.c $(LIBTCC_INC) - $(CC) -o $@ -c $< $(NATIVE_DEFINES) $(CPPFLAGS) $(CFLAGS) + $(CC) -o $@ -c $< $(NATIVE_DEFINES) $(CFLAGS) -ifndef LIBTCC_DLL libtcc.a: $(LIBTCC_OBJ) $(AR) rcs $@ $^ -endif -libtcc.so.1.0: $(LIBTCC_OBJ) +libtcc.so: $(LIBTCC_OBJ) $(CC) -shared -Wl,-soname,$@ -o $@ $^ $(LDFLAGS) -libtcc.so.1.0: CFLAGS+=-fPIC +libtcc.so: CFLAGS+=-fPIC -ifdef LIBTCC_DLL -libtcc.dll libtcc.def libtcc.a: $(LIBTCC_OBJ) - $(CC) -shared $^ -o $@ $(LDFLAGS) -Wl,--output-def,libtcc.def,--out-implib,libtcc.a +# windows : libtcc.dll +libtcc.dll : $(LIBTCC_OBJ) tiny_impdef$(EXESUF) + $(CC) -shared $(LIBTCC_OBJ) -o $@ $(LDFLAGS) + ./tiny_impdef $@ + +libtcc.dll : NATIVE_DEFINES += -DLIBTCC_AS_DLL + +# windows : utilities +tiny_%$(EXESUF): $(SRCTOP)/win32/tools/tiny_%.c + $(CC) -o $@ $< $(CFLAGS) $(LDFLAGS) $(NATIVE_DEFINES) + +ifneq ($(LIBTCC1),) +# TinyCC runtime libraries +$(LIBTCC1) : FORCE $(PROGS) + $(MAKE) -C lib native endif -# windows utilities -tiny_impdef$(EXESUF): win32/tools/tiny_impdef.c - $(CC) -o $@ $< $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -tiny_libmaker$(EXESUF): win32/tools/tiny_libmaker.c - $(CC) -o $@ $< $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) - -# TinyCC runtime libraries -libtcc1.a : FORCE $(PROGS) - $(MAKE) -C lib native - if test ! -d $(ARCH); then mkdir $(ARCH); fi - if test ! -L $(ARCH)/$@; then ln -sf ../$@ $(ARCH)/$@; fi lib/%/libtcc1.a : FORCE $(PROGS_CROSS) $(MAKE) -C lib cross TARGET=$* @@ -272,27 +223,20 @@ FORCE: # install TCC_INCLUDES = stdarg.h stddef.h stdbool.h float.h varargs.h INSTALL=install -ifdef STRIP_BINARIES -INSTALLBIN=$(INSTALL) -s -else -INSTALLBIN=$(INSTALL) -endif -ifdef CONFIG_WIN32 -CONFIG_WIN=yes -endif -ifdef CONFIG_WIN64 -CONFIG_WIN=yes +ifdef STRIP_BINARIES + INSTALLBIN=$(INSTALL) -s +else + INSTALLBIN=$(INSTALL) endif install-strip: install strip $(foreach PROG,$(PROGS),"$(bindir)"/$(PROG)) -ifndef CONFIG_WIN +ifndef CONFIG_WIN32 install: $(PROGS) $(TCCLIBS) $(TCCDOCS) mkdir -p "$(bindir)" $(INSTALLBIN) -m755 $(PROGS) "$(bindir)" - cp -P tcc$(EXESUF) "$(bindir)" mkdir -p "$(mandir)/man1" -$(INSTALL) -m644 tcc.1 "$(mandir)/man1" mkdir -p "$(infodir)" @@ -300,46 +244,32 @@ install: $(PROGS) $(TCCLIBS) $(TCCDOCS) mkdir -p "$(tccdir)" mkdir -p "$(tccdir)/include" ifneq ($(LIBTCC1),) - mkdir -p "$(tccdir)/$(ARCH)" - $(INSTALL) -m644 $(LIBTCC1) "$(tccdir)/$(ARCH)" + $(INSTALL) -m644 $(LIBTCC1) "$(tccdir)" endif - $(INSTALL) -m644 $(addprefix $(top_srcdir)/include/,$(TCC_INCLUDES)) $(top_srcdir)/tcclib.h "$(tccdir)/include" + $(INSTALL) -m644 $(addprefix include/,$(TCC_INCLUDES)) tcclib.h "$(tccdir)/include" mkdir -p "$(libdir)" $(INSTALL) -m644 $(LIBTCC) "$(libdir)" -ifdef DISABLE_STATIC - ln -sf "$(ln_libdir)/libtcc.so.1.0" "$(libdir)/libtcc.so.1" - ln -sf "$(ln_libdir)/libtcc.so.1.0" "$(libdir)/libtcc.so" -endif mkdir -p "$(includedir)" - $(INSTALL) -m644 $(top_srcdir)/libtcc.h "$(includedir)" + $(INSTALL) -m644 libtcc.h "$(includedir)" mkdir -p "$(docdir)" -$(INSTALL) -m644 tcc-doc.html "$(docdir)" ifdef CONFIG_CROSS mkdir -p "$(tccdir)/win32/lib/32" mkdir -p "$(tccdir)/win32/lib/64" - mkdir -p "$(tccdir)/i386" - mkdir -p "$(tccdir)/x86-64" -ifneq ($(HOST_OS),Darwin) - mkdir -p "$(tccdir)/arm64" - $(INSTALL) -m644 lib/arm64/libtcc1.a "$(tccdir)/arm64" -endif - $(INSTALL) -m644 lib/i386/libtcc1.a "$(tccdir)/i386" - $(INSTALL) -m644 lib/x86_64/libtcc1.a "$(tccdir)/x86-64" - $(INSTALL) -m644 $(top_srcdir)/win32/lib/*.def "$(tccdir)/win32/lib" - $(INSTALL) -m644 lib/i386-win/libtcc1.a "$(tccdir)/win32/lib/32" - $(INSTALL) -m644 lib/x86_64-win/libtcc1.a "$(tccdir)/win32/lib/64" - cp -r $(top_srcdir)/win32/include/. "$(tccdir)/win32/include" + $(INSTALL) -m644 win32/lib/*.def "$(tccdir)/win32/lib" + -$(INSTALL) -m644 lib/i386-win32/libtcc1.a "$(tccdir)/win32/lib/32" + -$(INSTALL) -m644 lib/x86_64-win32/libtcc1.a "$(tccdir)/win32/lib/64" + cp -r win32/include/. "$(tccdir)/win32/include" cp -r "$(tccdir)/include" "$(tccdir)/win32" endif uninstall: rm -fv $(foreach P,$(PROGS),"$(bindir)/$P") - rm -fv "$(bindir)/tcc$(EXESUF)" rm -fv $(foreach P,$(LIBTCC1),"$(tccdir)/$P") rm -fv $(foreach P,$(TCC_INCLUDES),"$(tccdir)/include/$P") rm -fv "$(mandir)/man1/tcc.1" "$(infodir)/tcc-doc.info" rm -fv "$(libdir)/$(LIBTCC)" "$(includedir)/libtcc.h" - rm -fv "$(libdir)/libtcc.so*" + rm -fv $(libdir)/libtcc.so* rm -rv "$(tccdir)" rm -rv "$(docdir)" else @@ -351,24 +281,23 @@ install: $(PROGS) $(TCCLIBS) $(TCCDOCS) mkdir -p "$(tccdir)/examples" mkdir -p "$(tccdir)/doc" mkdir -p "$(tccdir)/libtcc" - $(INSTALLBIN) -m755 $(PROGS) "$(tccdir)" - $(INSTALLBIN) -m755 tcc.exe "$(tccdir)" - $(INSTALL) -m644 $(LIBTCC1) $(top_srcdir)/win32/lib/*.def "$(tccdir)/lib" - cp -r $(top_srcdir)/win32/include/. "$(tccdir)/include" - cp -r $(top_srcdir)/win32/examples/. "$(tccdir)/examples" - $(INSTALL) -m644 $(addprefix $(top_srcdir)/include/,$(TCC_INCLUDES)) $(top_srcdir)/tcclib.h "$(tccdir)/include" - $(INSTALL) -m644 tcc-doc.html $(top_srcdir)/win32/tcc-win32.txt "$(tccdir)/doc" - $(INSTALL) -m644 $(top_srcdir)/libtcc.h $(LIBTCC_EXTRA) "$(tccdir)/libtcc" - $(INSTALL) -m644 $(LIBTCC) "$(tccdir)" + $(INSTALLBIN) -m755 $(PROGS) $(LIBTCC) "$(tccdir)" + $(INSTALL) -m644 libtcc1.a win32/lib/*.def "$(tccdir)/lib" + cp -r win32/include/. "$(tccdir)/include" + cp -r win32/examples/. "$(tccdir)/examples" + cp tests/libtcc_test.c "$(tccdir)/examples" + $(INSTALL) -m644 $(addprefix include/,$(TCC_INCLUDES)) tcclib.h "$(tccdir)/include" + $(INSTALL) -m644 tcc-doc.html win32/tcc-win32.txt "$(tccdir)/doc" + $(INSTALL) -m644 libtcc.h libtcc.def "$(tccdir)/libtcc" ifdef CONFIG_CROSS mkdir -p "$(tccdir)/lib/32" mkdir -p "$(tccdir)/lib/64" - -$(INSTALL) -m644 lib/i386-win/libtcc1.a "$(tccdir)/lib/32" - -$(INSTALL) -m644 lib/x86_64-win/libtcc1.a "$(tccdir)/lib/64" + -$(INSTALL) -m644 lib/i386-win32/libtcc1.a "$(tccdir)/lib/32" + -$(INSTALL) -m644 lib/x86_64-win32/libtcc1.a "$(tccdir)/lib/64" endif uninstall: - rm -rfv "$(tccdir)/*" + rm -rfv "$(tccdir)/"* endif # documentation and man page @@ -376,30 +305,21 @@ tcc-doc.html: tcc-doc.texi -makeinfo --no-split --html --number-sections -o $@ $< tcc.1: tcc-doc.texi - -$(top_srcdir)/texi2pod.pl $< tcc.pod - -pod2man --section=1 --center="Tiny C Compiler" --release=`cat $(top_srcdir)/VERSION` tcc.pod > $@ + -texi2pod.pl $< tcc.pod + -pod2man --section=1 --center="Tiny C Compiler" --release="$(VERSION)" tcc.pod > $@ tcc-doc.info: tcc-doc.texi -makeinfo $< # in tests subdir -export LIBTCC1 - -%est: - $(MAKE) -C tests $@ 'PROGS_CROSS=$(PROGS_CROSS)' +test: + $(MAKE) -C tests clean: rm -vf $(PROGS) tcc_p$(EXESUF) tcc.pod *~ *.o *.a *.so* *.out *.log \ - *.exe a.out tags TAGS libtcc_test$(EXESUF) tcc$(EXESUF) - -rm -r $(ARCH) arm64 -ifeq ($(HOST_OS),Linux) - -rm -r ./C: -endif - -rm *-tcc$(EXESUF) + lib*.def *.exe *.dll a.out tags TAGS libtcc_test$(EXESUF) tcc$(EXESUF) $(MAKE) -C tests $@ -ifneq ($(LIBTCC1),) $(MAKE) -C lib $@ -endif distclean: clean rm -vf config.h config.mak config.texi tcc.1 tcc-doc.info tcc-doc.html @@ -408,15 +328,13 @@ config.mak: @echo "Please run ./configure." @exit 1 -tags: - ctags $(top_srcdir)/*.[ch] $(top_srcdir)/include/*.h $(top_srcdir)/lib/*.[chS] - -TAGS: - etags $(top_srcdir)/*.[ch] $(top_srcdir)/include/*.h $(top_srcdir)/lib/*.[chS] +TAGFILES = *.[ch] include/*.h lib/*.[chS] +tags : ; ctags $(TAGFILES) +TAGS : ; etags $(TAGFILES) # create release tarball from *current* git branch (including tcc-doc.html # and converting two files to CRLF) -TCC-VERSION := tcc-$(shell cat $(top_srcdir)/VERSION) +TCC-VERSION = $(VERSION) tar: tcc-doc.html mkdir $(TCC-VERSION) ( cd $(TCC-VERSION) && git --git-dir ../.git checkout -f ) @@ -428,6 +346,6 @@ tar: tcc-doc.html rm -rf $(TCC-VERSION) git reset -.PHONY: all clean tar tags TAGS distclean install uninstall FORCE +.PHONY: all clean test tar tags TAGS distclean install uninstall FORCE endif # ifeq ($(TOP),.) diff --git a/configure b/configure index 5e467b6d..89e32fe8 100755 --- a/configure +++ b/configure @@ -19,7 +19,6 @@ TMPH=$TMPN.h # default parameters build_cross="no" use_libgcc="no" -enable_assert="no" prefix="" execprefix="" bindir="" @@ -31,7 +30,6 @@ infodir="" sysroot="" cross_prefix="" cc="gcc" -host_cc="gcc" ar="ar" strip="strip" cygwin="no" @@ -48,16 +46,10 @@ tcc_lddir= confvars= cpu= -host_os=`uname` -case $host_os in - MINGW32*) host_os=Windows; ;; - *) ;; -esac - # OS specific targetos=`uname` case $targetos in - MINGW32*) mingw32=yes; host_os=Windows; ;; + MINGW32*) mingw32=yes;; DragonFly) noldl=yes;; OpenBSD) noldl=yes;; FreeBSD) noldl=yes;; @@ -76,55 +68,57 @@ if test -z "$source_path" -o "$source_path" = "." ; then source_path_used="no" fi -classify_cpu () -{ - cpu="$1" +cpu=`uname -m` +if test $mingw32=yes; then + if test "$PROCESSOR_ARCHITEW6432" = "AMD64" \ + -o "$PROCESSOR_ARCHITECTURE" = "AMD64"; then + cpu="x86_64" + fi +fi - case "$cpu" in - x86|i386|i486|i586|i686|i86pc|BePC|i686-AT386) - cpu="x86" - ;; - x86_64|amd64) - cpu="x86-64" - ;; - arm*) - case "$cpu" in - arm|armv4l) - cpuver=4 - ;; - armv5tel|armv5tejl) - cpuver=5 - ;; - armv6j|armv6l) - cpuver=6 - ;; - armv7a|armv7l) - cpuver=7 - ;; - esac - cpu="armv4l" - ;; - aarch64) - cpu="aarch64" - ;; - alpha) - cpu="alpha" - ;; - "Power Macintosh"|ppc|ppc64) - cpu="powerpc" - ;; - mips) - cpu="mips" - ;; - s390) - cpu="s390" - ;; - *) - echo "Unsupported CPU: $cpu" - exit 1 - ;; - esac -} +case "$cpu" in +x86|i386|i486|i586|i686|i86pc|BePC|i686-AT386) + cpu="x86" + ;; + x86_64|amd64) + cpu="x86-64" + ;; + arm*) + case "$cpu" in + arm|armv4l) + cpuver=4 + ;; + armv5tel|armv5tejl) + cpuver=5 + ;; + armv6j|armv6l) + cpuver=6 + ;; + armv7a|armv7l) + cpuver=7 + ;; + esac + cpu="armv4l" + ;; + aarch64) + cpu="aarch64" + ;; + alpha) + cpu="alpha" + ;; + "Power Macintosh"|ppc|ppc64) + cpu="powerpc" + ;; + mips) + cpu="mips" + ;; + s390) + cpu="s390" + ;; + *) + cpu="unknown" + ;; +esac for opt do eval opt=\"$opt\" @@ -155,6 +149,16 @@ for opt do ;; --cross-prefix=*) cross_prefix=`echo $opt | cut -d '=' -f 2` ;; + --cc=*) cc=`echo $opt | cut -d '=' -f 2` + ;; + --ar=*) ar=`echo $opt | cut -d '=' -f 2` + ;; + --extra-cflags=*) CFLAGS="${opt#--extra-cflags=}" + ;; + --extra-ldflags=*) LDFLAGS="${opt#--extra-ldflags=}" + ;; + --extra-libs=*) extralibs="${opt#--extra-libs=}" + ;; --sysincludepaths=*) tcc_sysincludepaths=`echo $opt | cut -d '=' -f 2` ;; --libpaths=*) tcc_libpaths=`echo $opt | cut -d '=' -f 2` @@ -163,32 +167,16 @@ for opt do ;; --elfinterp=*) tcc_elfinterp=`echo $opt | cut -d '=' -f 2` ;; - --ar=*) ar=`echo $opt | cut -d '=' -f 2` - ;; - --cc=*) cc=`echo $opt | cut -d '=' -f 2` - ;; - --extra-cflags=*) CFLAGS="${opt#--extra-cflags=}" - ;; - --extra-ldflags=*) LDFLAGS="${opt#--extra-ldflags=}" - ;; - --extra-libs=*) extralibs=${opt#--extra-libs=} - ;; --cpu=*) cpu=`echo $opt | cut -d '=' -f 2` ;; --enable-gprof) gprof="yes" ;; - --enable-mingw32) mingw32="yes" ; cross_prefix="i686-pc-mingw32-" ; cpu=x86; targetos=Windows; + --enable-mingw32) mingw32="yes" ; cross_prefix="i686-pc-mingw32-" ; cpu=x86 ;; - --enable-cygwin) mingw32="yes" ; cygwin="yes" ; cross_prefix="mingw32-" ; cpu=x86; targetos=Windows; - ;; - --enable-tcc32-mingw) mingw32="yes" ; cross_prefix="i386-win-" ; cpu=x86; cc=tcc; targetos=Windows; - ;; - --enable-tcc64-mingw) mingw32="yes" ; cross_prefix="x86_64-win-" ; cpu=x86_64; cc=tcc; targetos=Windows; + --enable-cygwin) mingw32="yes" ; cygwin="yes" ; cross_prefix="mingw32-" ; cpu=x86 ;; --enable-cross) build_cross="yes" ;; - --enable-assert) enable_assert="yes" - ;; --disable-static) disable_static="yes" ;; --disable-rpath) disable_rpath="yes" @@ -206,29 +194,23 @@ for opt do esac done -if test -z "$cpu" ; then - if test -n "$ARCH" ; then - cpu="$ARCH" - else - cpu=`uname -m` - fi -fi -classify_cpu "$cpu" - # Checking for CFLAGS if test -z "$CFLAGS"; then - CFLAGS="-Wall -g -O0" + CFLAGS="-Wall -g -O2" + if test "$mingw32" = "yes" -a "$cpu" = "x86-64"; then + CFLAGS="-m64 $CFLAGS" + fi fi if test "$mingw32" = "yes" ; then if test x"$tccdir" = x""; then - tccdir="tcc" + tccdir="tcc" fi if test -z "$prefix" ; then - prefix="C:/Program Files/${tccdir}" + prefix="C:/Program Files/${tccdir}" fi if test -z "$sharedir" ; then - sharedir="${prefix}" + sharedir="${prefix}" fi execprefix="$prefix" bindir="${prefix}" @@ -241,46 +223,37 @@ if test "$mingw32" = "yes" ; then EXESUF=".exe" else if test -z "$prefix" ; then - prefix="/usr/local" + prefix="/usr/local" fi if test -z "$sharedir" ; then - sharedir="${prefix}/share" + sharedir="${prefix}/share" fi if test x"$execprefix" = x""; then - execprefix="${prefix}" - fi - if test x"$tccdir" = x""; then - tccdir="tcc" + execprefix="${prefix}" fi if test x"$libdir" = x""; then - libdir="${execprefix}/lib" - if test -n "${tccdir}"; then - tccdir="${libdir}/${tccdir}" - else - tccdir="${libdir}" - fi - if test "$cpu" = "x86-64"; then - libdir="${execprefix}/lib64" - fi - else - tccdir="${libdir}/${tccdir}" + libdir="${execprefix}/lib" fi if test x"$bindir" = x""; then - bindir="${execprefix}/bin" + bindir="${execprefix}/bin" + fi + if test x"$tccdir" = x""; then + tccdir="tcc" fi if test x"$docdir" = x""; then - docdir="${sharedir}/doc" + docdir="${sharedir}/doc/${tccdir}" fi if test x"$mandir" = x""; then - mandir="${sharedir}/man" + mandir="${sharedir}/man" fi if test x"$infodir" = x""; then - infodir="${sharedir}/info" + infodir="${sharedir}/info" fi + tccdir="${libdir}/${tccdir}" fi # mingw32 if test x"$includedir" = x""; then -includedir="${prefix}/include" + includedir="${prefix}/include" fi if test x"$show_help" = "xyes" ; then @@ -292,7 +265,7 @@ Standard options: --help print this message --prefix=PREFIX install in PREFIX [$prefix] --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX - [same as prefix] + [same as prefix] --bindir=DIR user executables in DIR [EPREFIX/bin] --libdir=DIR object code libraries in DIR [EPREFIX/lib] --tccdir=DIR installation directory [EPREFIX/lib/tcc] @@ -310,17 +283,13 @@ Advanced options (experts only): --ar=AR create archives using AR [$ar] --extra-cflags= specify compiler flags [$CFLAGS] --extra-ldflags= specify linker options [] - --cpu=CPU CPU [$cpu] --strip-binaries strip symbol tables from resulting binaries --disable-static make libtcc.so instead of libtcc.a --disable-rpath disable use of -rpath with the above --with-libgcc use libgcc_s.so.1 instead of libtcc1.a in dynamic link - --enable-tcc64-mingw build windows version on linux with x86_64-win-tcc - --enable-tcc32-mingw build windows version on linux with i386-win-tcc --enable-mingw32 build windows version on linux with mingw32 --enable-cygwin build windows version on windows with cygwin --enable-cross build cross compilers - --enable-assert enable debug assertions --with-selinux use mmap for exec mem [needs writable /tmp] --sysincludepaths=... specify system include paths, colon separated --libpaths=... specify system library paths, colon separated @@ -331,10 +300,8 @@ EOF exit 1 fi -if test "$cc" != "tcc"; then - ar="${cross_prefix}${ar}" -fi cc="${cross_prefix}${cc}" +ar="${cross_prefix}${ar}" strip="${cross_prefix}${strip}" CONFTEST=./conftest$EXESUF @@ -349,21 +316,21 @@ if test -z "$cross_prefix" ; then if test "$mingw32" = "no" ; then triplet="$($CONFTEST triplet)" if test -f "/usr/lib/$triplet/crti.o" ; then - tcc_lddir="lib" - multiarch_triplet="$triplet" - elif test "$cpu" != "x86" -a -f "/usr/lib64/crti.o" ; then - tcc_lddir="lib64" + tcc_lddir="lib/$triplet" + multiarch_triplet="$triplet" + elif test -f "/usr/lib64/crti.o" ; then + tcc_lddir="lib64" fi if test "$cpu" = "armv4l" ; then - if test "${triplet%eabihf}" != "$triplet" ; then - confvars="$confvars arm_eabihf" - elif test "${triplet%eabi}" != "$triplet" ; then - confvars="$confvars arm_eabi" - fi - if grep -s -q "^Features.* \(vfp\|iwmmxt\) " /proc/cpuinfo ; then - confvars="$confvars arm_vfp" - fi + if test "${triplet%eabihf}" != "$triplet" ; then + confvars="$confvars arm_eabihf" + elif test "${triplet%eabi}" != "$triplet" ; then + confvars="$confvars arm_eabi" + fi + if grep -s -q "^Features.* \(vfp\|iwmmxt\) " /proc/cpuinfo ; then + confvars="$confvars arm_vfp" + fi fi # multiarch_triplet=${libc_dir#*/} @@ -374,11 +341,12 @@ if test -z "$cross_prefix" ; then # fi if test -f "/lib/ld-uClibc.so.0" ; then - confvars="$confvars uClibc" + confvars="$confvars uClibc" fi -# gr: maybe for after the release: -# tcc_elfinterp="$(ldd $CONFTEST | grep 'ld.*.so' | sed 's,\s*\(\S\+\).*,\1,')" - # echo "elfinterp $tcc_elfinterp" + +# if test -z "$tcc_elfinterp" ; then +# tcc_elfinterp="$(ldd $CONFTEST | grep '/ld-.*.so' | sed 's,\s*\(\S\+\).*,\1,')" +# fi fi fi @@ -390,22 +358,23 @@ else fi # a final configuration tuning +$cc -v --help > cc_help.txt 2>&1 W_OPTIONS="declaration-after-statement" for i in $W_OPTIONS; do - O_PRESENT="$($cc -v --help 2>&1 | grep -- -W$i)" + O_PRESENT="$(grep -- -W$i cc_help.txt)" if test -n "$O_PRESENT"; then CFLAGS="$CFLAGS -W$i"; fi done W_OPTIONS="deprecated-declarations strict-aliasing pointer-sign sign-compare unused-result uninitialized" for i in $W_OPTIONS; do - O_PRESENT="$($cc -v --help 2>&1 | grep -- -W$i)" + O_PRESENT="$(grep -- -W$i cc_help.txt)" if test -n "$O_PRESENT"; then CFLAGS="$CFLAGS -Wno-$i"; fi done F_OPTIONS="strict-aliasing" for i in $F_OPTIONS; do - O_PRESENT="$($cc -v --help 2>&1 | grep -- -f$i)" + O_PRESENT="$(grep -- -f$i cc_help.txt)" if test -n "$O_PRESENT"; then CFLAGS="$CFLAGS -fno-$i"; fi done -if test -z "$tcc_lddir" -a "$cpu" = "x86-64"; then tcc_lddir="lib64"; fi +rm -f cc_help.txt echo "Binary directory $bindir" echo "TinyCC directory $tccdir" @@ -415,18 +384,14 @@ echo "Manual directory $mandir" echo "Info directory $infodir" echo "Doc directory $docdir" echo "Target root prefix $sysroot" -echo "Source path $source_path" -echo "C compiler $cc" -echo "ar $ar" -echo "cross compilers $build_cross" -if test "$build_cross" = "no"; then -echo "Target CPU $cpu" -fi -echo "Host OS $host_os" -echo "Target OS $targetos" -echo "Big Endian $bigendian" -echo "gprof enabled $gprof" -echo "use libgcc $use_libgcc" +echo "Source path $source_path" +echo "C compiler $cc" +echo "Target OS $targetos" +echo "CPU $cpu" +echo "Big Endian $bigendian" +echo "gprof enabled $gprof" +echo "cross compilers $build_cross" +echo "use libgcc $use_libgcc" echo "Creating config.mak and config.h" @@ -444,21 +409,13 @@ docdir=\$(DESTDIR)$docdir CC=$cc GCC_MAJOR=$gcc_major GCC_MINOR=$gcc_minor -HOST_CC=$host_cc AR=$ar STRIP=$strip -s -R .comment -R .note CFLAGS=$CFLAGS LDFLAGS=$LDFLAGS LIBSUF=$LIBSUF EXESUF=$EXESUF -HOST_OS=$host_os EOF -if test "$mingw32" = "yes" -a "$host_os" != "Windows" ; then -cat >>config.mak < $TMPH print_inc CONFIG_SYSROOT "$sysroot" print_inc CONFIG_TCCDIR "$tccdir" -if test "$build_cross" = "no"; then -print_inc CONFIG_LDDIR "$tcc_lddir" -fi print_mak CONFIG_TCC_SYSINCLUDEPATHS "$tcc_sysincludepaths" print_mak CONFIG_TCC_LIBPATHS "$tcc_libpaths" print_mak CONFIG_TCC_CRTPREFIX "$tcc_crtprefix" print_mak CONFIG_TCC_ELFINTERP "$tcc_elfinterp" +print_mak CONFIG_LDDIR "$tcc_lddir" print_mak CONFIG_MULTIARCHDIR "$multiarch_triplet" echo "#define GCC_MAJOR $gcc_major" >> $TMPH @@ -520,13 +475,7 @@ if test "$noldl" = "yes" ; then echo "CONFIG_NOLDL=yes" >> config.mak fi if test "$mingw32" = "yes" ; then - if test "$cpu" = "x86-64"; then - echo "CONFIG_WIN64=yes" >> config.mak - echo "#define CONFIG_WIN64 1" >> $TMPH - else - echo "CONFIG_WIN32=yes" >> config.mak - echo "#define CONFIG_WIN32 1" >> $TMPH - fi + echo "CONFIG_WIN32=yes" >> config.mak fi if test "$cygwin" = "yes" ; then echo "#ifndef _WIN32" >> $TMPH @@ -562,25 +511,20 @@ if test "$have_selinux" = "yes" ; then echo "#define HAVE_SELINUX" >> $TMPH echo "HAVE_SELINUX=yes" >> config.mak fi -if test "$enable_assert" = "yes" ; then - echo "#define CONFIG_TCC_ASSERT" >> $TMPH -fi version=`head $source_path/VERSION` -echo "VERSION=$version" >>config.mak +echo "VERSION = $version" >> config.mak echo "#define TCC_VERSION \"$version\"" >> $TMPH echo "@set VERSION $version" > config.texi -echo "SRC_PATH=$source_path" >>config.mak if test "$source_path_used" = "yes" ; then case $source_path in - /*) echo "top_srcdir=$source_path";; - *) echo "top_srcdir=\$(TOP)/$source_path";; + /*) echo "SRCTOP=$source_path";; + *) echo "SRCTOP=\$(TOP)/$source_path";; esac >>config.mak else - echo 'top_srcdir=$(TOP)' >>config.mak + echo 'SRCTOP=$(TOP)' >>config.mak fi -echo 'top_builddir=$(TOP)' >>config.mak diff $TMPH config.h >/dev/null 2>&1 if test $? -ne 0 ; then @@ -596,17 +540,24 @@ rm -f $TMPN* $CONFTEST fn_makelink() { - SRCDIR=$(realpath $1) - DIR=$(dirname $2) - FILE=$(basename $2) - if test ! -d "$DIR"; then - mkdir -p "$DIR" - fi - ln -s $SRCDIR/$DIR/$FILE $DIR/ + tgt=$1/$2 + case $2 in + */*) dn=${2%/*} + test -d $dn || mkdir -p $dn + case $1 in + /*) ;; + *) while test $dn ; do + tgt=../$tgt; dn=${dn#${dn%%/*}}; dn=${dn#/} + done + ;; + esac + ;; + esac + ln -sfn $tgt $2 } if test "$source_path_used" = "yes" ; then - FILES="Makefile lib/Makefile tests/Makefile tests/tests2/* tests/pp/* tests/exsymtab/*" + FILES="Makefile lib/Makefile tests/Makefile tests/tests2/Makefile tests/pp/Makefile" for f in $FILES ; do fn_makelink $source_path $f done diff --git a/lib/Makefile b/lib/Makefile index 3b904d42..94dcbe34 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -4,37 +4,31 @@ TOP = .. include $(TOP)/Makefile -VPATH = $(top_srcdir)/lib $(top_srcdir)/win32/lib +VPATH = $(TOP)/lib $(TOP)/win32/lib -ifndef TARGET # native library +ifndef TARGET + # we're building the native libtcc1.a ifdef CONFIG_WIN64 - TARGET = x86_64-win - else - ifdef CONFIG_WIN32 - TARGET = i386-win - else - ifeq ($(ARCH),i386) + TARGET = x86_64-win32 + # using tcc + else ifdef CONFIG_WIN32 + TARGET = i386-win32 + # using tcc + else ifeq ($(ARCH),i386) TARGET = i386 - else - ifeq ($(ARCH),x86-64) + XCC = $(CC) # using gcc + else ifeq ($(ARCH),x86-64) TARGET = x86_64 - else - ifeq ($(ARCH),arm) + XCC = $(CC) # using gcc + else ifeq ($(ARCH),arm) TARGET = arm - XCC = $(CC) - else - ifeq ($(ARCH),arm64) + XCC = $(CC) # using gcc + else ifeq ($(ARCH),arm64) TARGET = arm64 - else - endif - endif - endif - endif - endif endif + BCHECK_O = bcheck.o endif -BCHECK_O = bcheck.o DIR = $(TARGET) native : ../libtcc1.a @@ -54,53 +48,39 @@ ARM64_O = lib-arm64.o # into shared libraries PICFLAGS = -fPIC -# don't compile with -fstack-protector-strong, TCC doesn't handle it -# correctly -CFLAGS := $(filter-out -fstack-protector-strong,$(CFLAGS)) - -ifeq "$(TARGET)" "i386-win" +ifeq "$(TARGET)" "i386-win32" OBJ = $(addprefix $(DIR)/,$(WIN32_O)) TGT = -DTCC_TARGET_I386 -DTCC_TARGET_PE - XCC ?= $(TCC) -B$(top_srcdir)/win32 -I$(top_srcdir)/include - XAR ?= $(DIR)/tiny_libmaker$(EXESUF) - PICFLAGS = -else -ifeq "$(TARGET)" "x86_64-win" + XCC = $(TCC) -B$(TOP)/win32 -I$(TOP)/include + XAR = $(DIR)/tiny_libmaker$(EXESUF) + XFLAGS = $(TGT) +else ifeq "$(TARGET)" "x86_64-win32" OBJ = $(addprefix $(DIR)/,$(WIN64_O)) TGT = -DTCC_TARGET_X86_64 -DTCC_TARGET_PE - XCC ?= $(TCC) -B$(top_srcdir)/win32 -I$(top_srcdir)/include - XAR ?= $(DIR)/tiny_libmaker$(EXESUF) - PICFLAGS = -else -ifeq "$(TARGET)" "i386" + XCC = $(TCC) -B$(TOP)/win32 -I$(TOP)/include + XAR = $(DIR)/tiny_libmaker$(EXESUF) + XFLAGS = $(TGT) +else ifeq "$(TARGET)" "i386" OBJ = $(addprefix $(DIR)/,$(I386_O)) TGT = -DTCC_TARGET_I386 - XCC ?= $(TCC) -B$(top_srcdir) -else -ifeq "$(TARGET)" "x86_64" + XCC ?= $(TCC) -B$(TOP) +else ifeq "$(TARGET)" "x86_64" OBJ = $(addprefix $(DIR)/,$(X86_64_O)) TGT = -DTCC_TARGET_X86_64 - XCC ?= $(TCC) -B$(top_srcdir) -else -ifeq "$(TARGET)" "arm" + XCC ?= $(TCC) -B$(TOP) +else ifeq "$(TARGET)" "arm" OBJ = $(addprefix $(DIR)/,$(ARM_O)) TGT = -DTCC_TARGET_ARM - XCC ?= $(TCC) -B$(top_srcdir) -else -ifeq "$(TARGET)" "arm64" + XCC ?= $(TCC) -B$(TOP) +else ifeq "$(TARGET)" "arm64" OBJ = $(addprefix $(DIR)/,$(ARM64_O)) TGT = -DTCC_TARGET_ARM64 XCC ?= $(TCC) -B$(top_srcdir) else $(error libtcc1.a not supported on target '$(TARGET)') endif -endif -endif -endif -endif -endif -XFLAGS = $(filter-out -b,$(CPPFLAGS) $(CFLAGS) $(PICFLAGS) $(TGT)) +XFLAGS ?= $(CFLAGS) $(PICFLAGS) $(TGT) ifeq ($(TARGETOS),Darwin) XAR = $(DIR)/tiny_libmaker$(EXESUF) @@ -108,21 +88,25 @@ ifeq ($(TARGETOS),Darwin) BCHECK_O = endif -XAR ?= $(AR) +ifdef XAR +AR = $(XAR) +endif $(DIR)/libtcc1.a ../libtcc1.a : $(OBJ) $(XAR) - $(XAR) rcs $@ $(OBJ) + $(AR) rcs $@ $(OBJ) $(DIR)/%.o : %.c $(XCC) -c $< -o $@ $(XFLAGS) $(DIR)/%.o : %.S $(XCC) -c $< -o $@ $(XFLAGS) -$(DIR)/%$(EXESUF) : $(TOP)/win32/tools/%.c - $(CC) -o $@ $< $(XFLAGS) $(LDFLAGS) +# windows : utilities +$(DIR)/tiny_%$(EXESUF) : $(TOP)/win32/tools/tiny_%.c + $(CC) -o $@ $< $(CFLAGS) $(LDFLAGS) $(TGT) $(OBJ) $(XAR) : $(DIR)/exists -$(DIR)/exists : + +%/exists : mkdir -p $(DIR) @echo $@ > $@ clean : - rm -rfv i386-win x86_64-win i386 x86_64 arm64 + rm -rfv i386-win32 x86_64-win32 i386 x86_64 arm arm64 diff --git a/libtcc.c b/libtcc.c index 29dc9646..a9a39ac3 100644 --- a/libtcc.c +++ b/libtcc.c @@ -135,7 +135,7 @@ BOOL WINAPI DllMain (HINSTANCE hDll, DWORD dwReason, LPVOID lpReserved) /********************************************************/ /* copy a string and truncate it. */ -ST_FUNC char *pstrcpy(char *buf, int buf_size, const char *s) +PUB_FUNC char *pstrcpy(char *buf, int buf_size, const char *s) { char *q, *q_end; int c; @@ -155,7 +155,7 @@ ST_FUNC char *pstrcpy(char *buf, int buf_size, const char *s) } /* strcat and truncate. */ -ST_FUNC char *pstrcat(char *buf, int buf_size, const char *s) +PUB_FUNC char *pstrcat(char *buf, int buf_size, const char *s) { int len; len = strlen(buf); @@ -164,7 +164,7 @@ ST_FUNC char *pstrcat(char *buf, int buf_size, const char *s) return buf; } -ST_FUNC char *pstrncpy(char *out, const char *in, size_t num) +PUB_FUNC char *pstrncpy(char *out, const char *in, size_t num) { memcpy(out, in, num); out[num] = '\0'; diff --git a/tcc.h b/tcc.h index a5380b57..d0e08880 100644 --- a/tcc.h +++ b/tcc.h @@ -281,6 +281,11 @@ # define DEFAULT_ELFINTERP(s) default_elfinterp(s) #endif +/* target specific subdir for libtcc1.a */ +#ifndef TCC_ARCH_DIR +# define TCC_ARCH_DIR "" +#endif + /* library to use with CONFIG_USE_LIBGCC instead of libtcc1.a */ #define TCC_LIBGCC USE_MUADIR(CONFIG_SYSROOT "/" CONFIG_LDDIR) "/libgcc_s.so.1" @@ -1068,9 +1073,9 @@ ST_DATA int tcc_ext; ST_DATA struct TCCState *tcc_state; /* public functions currently used by the tcc main function */ -ST_FUNC char *pstrcpy(char *buf, int buf_size, const char *s); -ST_FUNC char *pstrcat(char *buf, int buf_size, const char *s); -ST_FUNC char *pstrncpy(char *out, const char *in, size_t num); +PUB_FUNC char *pstrcpy(char *buf, int buf_size, const char *s); +PUB_FUNC char *pstrcat(char *buf, int buf_size, const char *s); +PUB_FUNC char *pstrncpy(char *out, const char *in, size_t num); PUB_FUNC char *tcc_basename(const char *name); PUB_FUNC char *tcc_fileextension (const char *name); diff --git a/tccelf.c b/tccelf.c index 33ee0768..0aa70144 100644 --- a/tccelf.c +++ b/tccelf.c @@ -1555,24 +1555,7 @@ static void add_init_array_defines(TCCState *s1, const char *section_name) static int tcc_add_support(TCCState *s1, const char *filename) { char buf[1024]; - snprintf(buf, sizeof(buf), "%s/%s/%s", s1->tcc_lib_path, - /* an cpu specific path inside tcc_lib_path, mainly for keeping libtcc1.a */ - #ifdef TCC_TARGET_I386 - "i386" - #endif - #ifdef TCC_TARGET_X86_64 - "x86-64" - #endif - #ifdef TCC_TARGET_ARM - "arm" - #endif - #ifdef TCC_TARGET_ARM64 - "arm64" - #endif - #ifdef TCC_TARGET_C67 - "C67" - #endif - ,filename); + snprintf(buf, sizeof(buf), "%s/"TCC_ARCH_DIR"%s", s1->tcc_lib_path, filename); return tcc_add_file(s1, buf); } diff --git a/tests/Makefile b/tests/Makefile index 0e601bd4..b9f4bf6a 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -4,12 +4,8 @@ TOP = .. include $(TOP)/Makefile -SRCDIR = $(top_srcdir)/tests -VPATH = $(SRCDIR) $(top_srcdir) - -# clear CFLAGS and LDFLAGS -CFLAGS := -LDFLAGS := +VPATH = $(TOP)/tests $(TOP) +CFLAGS = -I$(TOP) # what tests to run TESTS = \ @@ -19,14 +15,11 @@ TESTS = \ test3 \ abitest \ vla_test-run \ - tests2-dir pp-dir + tests2-dir \ + pp-dir BTESTS = test1b test3b btest -ifdef CONFIG_CROSS - TESTS += hello-cross -endif - # test4 -- problem with -static # asmtest -- minor differences with gcc # btest -- works on i386 (including win32) @@ -48,62 +41,40 @@ ifeq ($(CONFIG_arm_eabi),yes) TESTS := $(filter-out test3,$(TESTS)) endif -ifdef DISABLE_STATIC - export LD_LIBRARY_PATH:=$(CURDIR)/.. -endif - -ifeq ($(TARGETOS),Darwin) - CFLAGS+=-Wl,-flat_namespace,-undefined,warning - export MACOSX_DEPLOYMENT_TARGET:=10.2 - NATIVE_DEFINES+=-D_ANSI_SOURCE -endif - # run local version of tcc with local libraries and includes -TCCFLAGS = -B$(TOP) -I$(TOP) -I$(top_srcdir) -I$(top_srcdir)/include -L$(TOP) +TCCFLAGS = -B$(TOP) -I$(TOP) ifdef CONFIG_WIN32 - TCCFLAGS = -B$(top_srcdir)/win32 -I$(top_srcdir) -I$(top_srcdir)/include -L$(TOP) + TCCFLAGS = -B$(TOP)/win32 -I$(TOP)/include -I$(TOP) -L$(TOP) + PATH := $(CURDIR)/$(TOP):$(PATH) # for libtcc_test to find libtcc.dll endif -XTCCFLAGS = -B$(TOP) -B$(top_srcdir)/win32 -I$(TOP) -I$(top_srcdir) -I$(top_srcdir)/include TCC = $(TOP)/tcc $(TCCFLAGS) -RUN_TCC = $(NATIVE_DEFINES) -DONE_SOURCE -run $(top_srcdir)/tcc.c $(TCCFLAGS) +RUN_TCC = $(NATIVE_DEFINES) -DONE_SOURCE -run $(TOP)/tcc.c $(TCCFLAGS) + +ifeq ($(TARGETOS),Darwin) + CFLAGS += -Wl,-flat_namespace,-undefined,warning + TCCFLAGS += -D_ANSI_SOURCE + export MACOSX_DEPLOYMENT_TARGET:=10.2 +endif DISAS = objdump -d -# libtcc test -ifdef LIBTCC1 - ifdef CONFIG_WIN32 - LIBTCC1:=$(TOP)/win32/libtcc/libtcc.a - else - LIBTCC1:=$(TOP)/$(LIBTCC1) - endif -endif - -all test : $(TESTS) +all test : clean-s $(TESTS) hello-exe: ../examples/ex1.c @echo ------------ $@ ------------ $(TCC) $< -o hello$(EXESUF) || ($(TOP)/tcc -vv; exit 1) && ./hello$(EXESUF) -hello-cross: ../examples/ex1.c - @echo ------------ $@ ------------ - for XTCC in $(PROGS_CROSS) ; \ - do echo -n "Test of $$XTCC... "; \ - out=$$($(TOP)/$$XTCC $(XTCCFLAGS) -c $< 2>&1); \ - test $$? -ne 0 && { echo "Failed\n$$out\n" ; $(TOP)/$$XTCC -vv; exit 1; } ; \ - echo "Success"; \ - done - hello-run: ../examples/ex1.c @echo ------------ $@ ------------ $(TCC) -run $< -libtest: libtcc_test$(EXESUF) $(LIBTCC1) +libtest: libtcc_test$(EXESUF) @echo ------------ $@ ------------ ./libtcc_test$(EXESUF) $(TCCFLAGS) -libtcc_test$(EXESUF): libtcc_test.c $(top_builddir)/$(LIBTCC) - $(CC) -o $@ $^ $(CPPFLAGS) $(CFLAGS) $(NATIVE_DEFINES) $(LIBS) $(LINK_LIBTCC) $(LDFLAGS) -I$(top_srcdir) +libtcc_test$(EXESUF): libtcc_test.c $(LIBTCC) + $(CC) -o $@ $^ $(CFLAGS) $(LIBS) %-dir: @echo ------------ $@ ------------ @@ -111,8 +82,8 @@ libtcc_test$(EXESUF): libtcc_test.c $(top_builddir)/$(LIBTCC) # test.ref - generate using cc test.ref: tcctest.c - $(CC) -o tcctest.cc $< -I$(top_srcdir) $(CPPFLAGS) -w $(CFLAGS) $(NATIVE_DEFINES) -std=gnu99 -O0 -fno-omit-frame-pointer $(LDFLAGS) - ./tcctest.cc > $@ + $(CC) -o tcctest.gcc $< $(NATIVE_DEFINES) $(CFLAGS) -w -O0 -std=gnu99 -fno-omit-frame-pointer + ./tcctest.gcc > $@ # auto test test1 test1b: tcctest.c test.ref @@ -183,19 +154,19 @@ btest: boundtest.c speedtest: ex2 ex3 @echo ------------ $@ ------------ time ./ex2 1238 2 3 4 10 13 4 - time $(TCC) -run $(top_srcdir)/examples/ex2.c 1238 2 3 4 10 13 4 + time $(TCC) -run $(TOP)/examples/ex2.c 1238 2 3 4 10 13 4 time ./ex3 35 - time $(TCC) -run $(top_srcdir)/examples/ex3.c 35 + time $(TCC) -run $(TOP)/examples/ex3.c 35 weaktest: tcctest.c test.ref - $(TCC) -c $< -o weaktest.tcc.o $(CPPFLAGS) $(CFLAGS) - $(CC) -c $< -o weaktest.cc.o -I. $(CPPFLAGS) -w $(CFLAGS) + $(TCC) -c $< -o weaktest.tcc.o + $(CC) -c $< -o weaktest.gcc.o -I. $(CFLAGS) objdump -t weaktest.tcc.o | grep ' w ' | sed -e 's/.* \([a-zA-Z0-9_]*\)$$/\1/' | LC_ALL=C sort > weaktest.tcc.o.txt - objdump -t weaktest.cc.o | grep ' w ' | sed -e 's/.* \([a-zA-Z0-9_]*\)$$/\1/' | LC_ALL=C sort > weaktest.cc.o.txt - diff weaktest.cc.o.txt weaktest.tcc.o.txt && echo "Weak Auto Test OK" + objdump -t weaktest.gcc.o | grep ' w ' | sed -e 's/.* \([a-zA-Z0-9_]*\)$$/\1/' | LC_ALL=C sort > weaktest.gcc.o.txt + diff weaktest.gcc.o.txt weaktest.tcc.o.txt && echo "Weak Auto Test OK" -ex%: $(top_srcdir)/examples/ex%.c - $(CC) -o $@ $< $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) +ex%: $(TOP)/examples/ex%.c + $(CC) -o $@ $< $(CFLAGS) # tiny assembler testing asmtest.ref: asmtest.S @@ -210,24 +181,27 @@ asmtest: asmtest.ref # Check that code generated by libtcc is binary compatible with # that generated by CC -abitest-cc$(EXESUF): abitest.c $(top_builddir)/$(LIBTCC) - $(CC) -o $@ $^ $(CPPFLAGS) $(CFLAGS) $(NATIVE_DEFINES) $(LIBS) $(LINK_LIBTCC) $(LDFLAGS) -I$(top_srcdir) +abitest-cc$(EXESUF): abitest.c $(LIBTCC) + $(CC) -o $@ $^ $(CFLAGS) $(LIBS) -w abitest-tcc$(EXESUF): abitest.c libtcc.c - $(TCC) -o $@ $^ $(CPPFLAGS) $(CFLAGS) $(NATIVE_DEFINES) -DONE_SOURCE $(LIBS) $(LDFLAGS) -I$(top_srcdir) + $(TCC) -o $@ $^ $(NATIVE_DEFINES) -DONE_SOURCE $(LIBS) ABITESTS := abitest-cc$(EXESUF) ifneq ($(CONFIG_arm_eabi),yes) # not ARM soft-float - ABITESTS += abitest-tcc$(EXESUF) + ABITESTS += abitest-tcc$(EXESUF) endif abitest: $(ABITESTS) @echo ------------ $@ ------------ ./abitest-cc$(EXESUF) $(TCCFLAGS) - if [ "$(CONFIG_arm_eabi)" != "yes" ]; then ./abitest-tcc$(EXESUF) $(TCCFLAGS); fi +ifneq ($(CONFIG_arm_eabi),yes) # not ARM soft-float + ./abitest-tcc$(EXESUF) $(TCCFLAGS) +endif vla_test$(EXESUF): vla_test.c - $(TCC) -o $@ $^ $(CPPFLAGS) $(CFLAGS) + $(TCC) -o $@ $^ + vla_test-run: vla_test$(EXESUF) @echo ------------ $@ ------------ ./vla_test$(EXESUF) @@ -249,8 +223,11 @@ cache: tcc_g # clean clean: + rm -f *~ *.o *.a *.bin *.i *.ref *.out *.out? *.out?b *.cc *.gcc \ +*-cc *-gcc *-tcc *.exe hello libtcc_test vla_test tcctest[1234] ex? tcc_g $(MAKE) -C tests2 $@ $(MAKE) -C pp $@ - rm -vf *~ *.o *.a *.bin *.i *.ref *.out *.out? *.out?b *.cc \ - *-cc *-tcc *.exe \ - hello libtcc_test vla_test tcctest[1234] ex? tcc_g + +# silent clean, used before running tests +clean-s: + @$(MAKE) -s --no-print-directory clean diff --git a/tests/pp/Makefile b/tests/pp/Makefile index cd0b83f1..d687acab 100644 --- a/tests/pp/Makefile +++ b/tests/pp/Makefile @@ -3,9 +3,8 @@ # TCC = ../../tcc - -TESTS = $(patsubst %.c,%.test,$(wildcard *.c)) -TESTS += $(patsubst %.S,%.test,$(wildcard *.S)) +files = $(patsubst %.$1,%.test,$(wildcard *.$1)) +TESTS = $(call files,c) $(call files,S) all test : $(sort $(TESTS)) @@ -25,10 +24,10 @@ DIFF_OPTS = -Nu -b -B -I "^\#" # automatically generate .expect files with gcc: %.expect: %.c - gcc -E -P $*.c >$*.expect 2>&1 + gcc -E -P $< >$*.expect 2>&1 %.expect: %.S - gcc -E -P $*.S >$*.expect 2>&1 + gcc -E -P $< >$*.expect 2>&1 # tell make not to delete .PRECIOUS: %.expect diff --git a/tests/tests2/Makefile b/tests/tests2/Makefile index 65bf2dce..587f1e7b 100644 --- a/tests/tests2/Makefile +++ b/tests/tests2/Makefile @@ -1,22 +1,11 @@ TOP = ../.. include $(TOP)/Makefile -# clear CFLAGS and LDFLAGS -CFLAGS := -LDFLAGS := - +# run local version of tcc with local libraries and includes +TCCFLAGS = -B$(TOP) -I$(TOP) ifdef CONFIG_WIN32 - TCCFLAGS = -B$(top_srcdir)/win32 -I$(top_srcdir)/include -L$(TOP) -else - TCCFLAGS = -B$(TOP) -I$(top_srcdir)/include -lm + TCCFLAGS = -B$(TOP)/win32 -I$(TOP)/include -I$(TOP) -L$(TOP) endif - -ifeq ($(TARGETOS),Darwin) - CFLAGS += -Wl,-flat_namespace,-undefined,warning - TCCFLAGS += -D_ANSI_SOURCE - export MACOSX_DEPLOYMENT_TARGET:=10.2 -endif - TCC = $(TOP)/tcc $(TCCFLAGS) TESTS = $(patsubst %.c,%.test,$(sort $(wildcard *.c))) @@ -48,8 +37,7 @@ ARGS = 46_grep.test : ARGS = '[^* ]*[:a:d: ]+\:\*-/: $$' 46_grep.c # Some tests might need different flags -FLAGS = -76_dollars_in_identifiers.test : FLAGS = -fdollars-in-identifiers +76_dollars_in_identifiers.test : TCCFLAGS += -fdollars-in-identifiers # Filter some always-warning FILTER = @@ -62,7 +50,7 @@ all test: $(filter-out $(SKIP),$(TESTS)) %.test: %.c %.expect @echo Test: $*... # test -run - @$(TCC) $(FLAGS) -run $< $(ARGS) $(FILTER) >$*.output 2>&1 || true + @$(TCC) -run $< $(ARGS) $(FILTER) >$*.output 2>&1 || true @diff -Nbu $*.expect $*.output && rm -f $*.output # test exe (disabled for speed) # @($(TCC) $(FLAGS) $< -o $*.exe && ./$*.exe $(ARGS)) $(FiLTER) >$*.output2 2>&1 ; \ @@ -76,4 +64,4 @@ all test: $(filter-out $(SKIP),$(TESTS)) .PRECIOUS: %.expect clean: - rm -vf fred.txt *.output a.exe + rm -f fred.txt *.output a.exe diff --git a/win32/build-tcc.bat b/win32/build-tcc.bat index e5caf3b6..cdb42725 100644 --- a/win32/build-tcc.bat +++ b/win32/build-tcc.bat @@ -1,4 +1,3 @@ -@echo off @rem ---------------------------------------------------- @rem batch file to build tcc using mingw gcc @rem ---------------------------------------------------- @@ -10,26 +9,25 @@ echo>..\config.h #define TCC_VERSION "%VERSION%" @if _%1_==_x64_ shift /1 && goto x86_64 @set target=-DTCC_TARGET_PE -DTCC_TARGET_I386 -@set CC=gcc -Os -s -fno-strict-aliasing -Wno-incompatible-pointer-types +@set CC=gcc -Os -s -fno-strict-aliasing @if _%1_==_debug_ set CC=gcc -g -ggdb @set P=32 @goto tools :x86_64 @set target=-DTCC_TARGET_PE -DTCC_TARGET_X86_64 -@set CC=x86_64-w64-mingw32-gcc -Os -s -fno-strict-aliasing -Wno-incompatible-pointer-types +@set CC=x86_64-w64-mingw32-gcc -Os -s -fno-strict-aliasing @if _%1_==_debug_ set CC=x86_64-w64-mingw32-gcc -g -ggdb @set P=64 @goto tools :tools -echo will use %CC% %target% %CC% %target% tools/tiny_impdef.c -o tiny_impdef.exe %CC% %target% tools/tiny_libmaker.c -o tiny_libmaker.exe :libtcc if not exist libtcc mkdir libtcc -copy ..\libtcc.h libtcc\libtcc.h > nul +copy ..\libtcc.h libtcc\libtcc.h %CC% %target% -shared -DLIBTCC_AS_DLL -DONE_SOURCE ../libtcc.c -o libtcc.dll -Wl,-out-implib,libtcc/libtcc.a tiny_impdef libtcc.dll -o libtcc/libtcc.def @@ -37,7 +35,7 @@ tiny_impdef libtcc.dll -o libtcc/libtcc.def %CC% %target% ../tcc.c -o tcc.exe -ltcc -Llibtcc :copy_std_includes -copy ..\include\*.h include > nul +copy ..\include\*.h include :libtcc1.a .\tcc %target% -c ../lib/libtcc1.c @@ -61,13 +59,10 @@ tiny_libmaker lib/libtcc1.a libtcc1.o alloca86_64.o crt1.o wincrt1.o dllcrt1.o d :the_end del *.o +copy ..\tests\libtcc_test.c examples :makedoc -for /f "delims=" %%i in ('where makeinfo') do set minfo=perl "%%~i" -if "%minfo%"=="" goto :skip_makedoc -echo>..\config.texi @set VERSION %VERSION% if not exist doc md doc -%minfo% --html --no-split -o doc\tcc-doc.html ../tcc-doc.texi copy tcc-win32.txt doc -copy ..\tests\libtcc_test.c examples -:skip_makedoc +echo>..\config.texi @set VERSION %VERSION% +makeinfo --html --no-split -o doc\tcc-doc.html ../tcc-doc.texi