Index: EcnlProtoTool/trunk/tcc-0.9.27/lib/Makefile
===================================================================
--- EcnlProtoTool/trunk/tcc-0.9.26/lib/Makefile	(revision 279)
+++ EcnlProtoTool/trunk/tcc-0.9.27/lib/Makefile	(revision 331)
@@ -5,98 +5,69 @@
 TOP = ..
 include $(TOP)/Makefile
-VPATH = $(top_srcdir)/lib $(top_srcdir)/win32/lib
+VPATH = $(TOPSRC)/lib $(TOPSRC)/win32/lib
+T = $(or $(CROSS_TARGET),$(NATIVE_TARGET),unknown)
+X = $(if $(CROSS_TARGET),$(CROSS_TARGET)-)
+BIN = $(TOP)/$(X)libtcc1.a
 
-ifndef TARGET
- ifdef CONFIG_WIN64
-  TARGET = x86_64-win32
- else
- ifdef CONFIG_WIN32
-  TARGET = i386-win32
- else
- ifeq ($(ARCH),i386)
-  TARGET = i386
-  ifneq ($(TARGETOS),Darwin)
-   XCC = $(CC)
-  endif
- else
- ifeq ($(ARCH),x86-64)
-  TARGET = x86_64
-  ifneq ($(TARGETOS),Darwin)
-   XCC = $(CC)
-  endif
- endif
- endif
- endif
- endif
- BCHECK_O = bcheck.o
+XTCC ?= $(TOP)/$(X)tcc$(EXESUF)
+XCC = $(XTCC)
+XAR = $(XTCC) -ar
+XFLAGS-unx = -B$(TOPSRC)
+XFLAGS-win = -B$(TOPSRC)/win32 -I$(TOPSRC)/include
+XFLAGS = $(XFLAGS$(XCFG))
+XCFG = $(or $(findstring -win,$T),-unx)
+
+# in order to use gcc, tyoe: make <target>-libtcc1-usegcc=yes
+arm-libtcc1-usegcc ?= no
+
+ifeq "$($(T)-libtcc1-usegcc)" "yes"
+ XCC = $(CC)
+ XAR = $(AR)
+ XFLAGS = $(CFLAGS) -fPIC
 endif
 
-DIR = $(TARGET)
+# only for native compiler
+$(X)BCHECK_O = bcheck.o
 
-native : ../libtcc1.a
-cross : $(DIR)/libtcc1.a
-
-native : TCC = $(TOP)/tcc$(EXESUF)
-cross : TCC = $(TOP)/$(TARGET)-tcc$(EXESUF)
-
-I386_O = libtcc1.o alloca86.o alloca86-bt.o $(BCHECK_O)
-X86_64_O = libtcc1.o alloca86_64.o
-WIN32_O = $(I386_O) crt1.o wincrt1.o dllcrt1.o dllmain.o chkstk.o
-WIN64_O = $(X86_64_O) crt1.o wincrt1.o dllcrt1.o dllmain.o chkstk.o
-
-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)
-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)
-else
-ifeq "$(TARGET)" "i386"
- OBJ = $(addprefix $(DIR)/,$(I386_O))
- TGT = -DTCC_TARGET_I386
- XCC ?= $(TCC) -B$(TOP)
-else
-ifeq "$(TARGET)" "x86_64"
- OBJ = $(addprefix $(DIR)/,$(X86_64_O))
- TGT = -DTCC_TARGET_X86_64
- XCC ?= $(TCC) -B$(TOP)
-else
- $(error libtcc1.a not supported on target '$(TARGET)')
-endif
-endif
-endif
-endif
-
-XFLAGS = $(CPPFLAGS) $(CFLAGS) $(TGT)
-
-ifeq ($(TARGETOS),Darwin)
- XAR = $(DIR)/tiny_libmaker$(EXESUF)
- XFLAGS += -D_ANSI_SOURCE
+ifeq ($(CONFIG_musl)$(CONFIG_uClibc),yes)
  BCHECK_O =
 endif
 
-ifdef XAR
-AR = $(XAR)
+ifdef CONFIG_OSX
+ XFLAGS += -D_ANSI_SOURCE
 endif
 
-$(DIR)/libtcc1.a ../libtcc1.a : $(OBJ) $(XAR)
-	$(AR) rcs $@ $(OBJ)
-$(DIR)/%.o : %.c
+I386_O = libtcc1.o alloca86.o alloca86-bt.o
+X86_64_O = libtcc1.o alloca86_64.o alloca86_64-bt.o
+ARM_O = libtcc1.o armeabi.o alloca-arm.o armflush.o
+ARM64_O = lib-arm64.o
+WIN_O = crt1.o crt1w.o wincrt1.o wincrt1w.o dllcrt1.o dllmain.o
+
+OBJ-i386 = $(I386_O) $(BCHECK_O)
+OBJ-x86_64 = $(X86_64_O) va_list.o $(BCHECK_O)
+OBJ-x86_64-osx = $(X86_64_O) va_list.o
+OBJ-i386-win32 = $(I386_O) chkstk.o bcheck.o $(WIN_O)
+OBJ-x86_64-win32 = $(X86_64_O) chkstk.o bcheck.o $(WIN_O)
+OBJ-arm64 = $(ARM64_O)
+OBJ-arm = $(ARM_O)
+OBJ-arm-fpa = $(ARM_O)
+OBJ-arm-fpa-ld = $(ARM_O)
+OBJ-arm-vfp = $(ARM_O)
+OBJ-arm-eabi = $(ARM_O)
+OBJ-arm-eabihf = $(ARM_O)
+OBJ-arm-wince = $(ARM_O) $(WIN_O)
+
+$(BIN) : $(patsubst %.o,$(X)%.o,$(OBJ-$T))
+	$(XAR) rcs $@ $^
+
+$(X)%.o : %.c
 	$(XCC) -c $< -o $@ $(XFLAGS)
-$(DIR)/%.o : %.S
+
+$(X)%.o : %.S
 	$(XCC) -c $< -o $@ $(XFLAGS)
-$(DIR)/%$(EXESUF) : $(TOP)/win32/tools/%.c
-	$(CC) -o $@ $< $(XFLAGS) $(LDFLAGS)
 
-$(OBJ) $(XAR) : $(DIR)/exists
-$(DIR)/exists :
-	mkdir -p $(DIR)
-	@echo $@ > $@
+$(X)crt1w.o : crt1.c
+$(X)wincrt1w.o : wincrt1.c
 
 clean :
-	rm -rfv i386-win32 x86_64-win32 i386 x86_64
+	rm -f *.a *.o $(BIN)
