OSDN Git Service

arm: move check for BX to its own header
[uclinux-h8/uClibc.git] / Rules.mak
index 5108978..9c191f3 100644 (file)
--- a/Rules.mak
+++ b/Rules.mak
@@ -201,7 +201,7 @@ check_as=$(shell \
        if $(CC) -Wa,$(1) -Wa,-Z -c -o /dev/null -xassembler /dev/null > /dev/null 2>&1; \
        then echo "-Wa,$(1)"; fi)
 check_ld=$(shell \
-       if $(LD) $(1) -o /dev/null -b binary /dev/null > /dev/null 2>&1; \
+       if $(CC) $(LDFLAG-fuse-ld) -Wl,$(1) $(CFLAG_-nostdlib) -o /dev/null -Wl,-b,binary /dev/null > /dev/null 2>&1; \
        then echo "$(1)"; fi)
 
 # Use variable indirection here so that we can have variable
@@ -252,6 +252,10 @@ endef
 
 ARFLAGS:=cr
 
+# Note: The check for -nostdlib has to be before all calls to check_ld
+$(eval $(call check-gcc-var,-nostdlib))
+LDFLAG-fuse-ld := $(filter -fuse-ld=%,$(EXTRA_UCLIBC_FLAGS))
+# deliberately not named CFLAG-fuse-ld since unchecked and from user
 
 # Flags in OPTIMIZATION are used only for non-debug builds
 
@@ -277,6 +281,7 @@ GCC_VER := $(subst ., ,$(GCC_VER))
 GCC_MAJOR_VER ?= $(word 1,$(GCC_VER))
 #GCC_MINOR_VER ?= $(word 2,$(GCC_VER))
 
+ifneq ($(TARGET_ARCH),arc)
 ifeq ($(GCC_MAJOR_VER),4)
 # shrinks code, results are from 4.0.2
 # 0.36%
@@ -289,7 +294,7 @@ OPTIMIZATION += $(CFLAG_-fno-tree-dominator-opts)
 $(eval $(call check-gcc-var,-fno-strength-reduce))
 OPTIMIZATION += $(CFLAG_-fno-strength-reduce)
 endif
-
+endif
 
 # CPU_CFLAGS-y contain options which are not warnings,
 # not include or library paths, and not optimizations.
@@ -417,6 +422,7 @@ ifeq ($(TARGET_ARCH),mips)
        CPU_CFLAGS-$(CONFIG_MIPS_ISA_MIPS32)+=-mips32 -mtune=mips32
        CPU_CFLAGS-$(CONFIG_MIPS_ISA_MIPS32R2)+=-march=mips32r2 -mtune=mips32r2
        CPU_CFLAGS-$(CONFIG_MIPS_ISA_MIPS64)+=-mips64 -mtune=mips32
+       CPU_CFLAGS-$(CONFIG_MIPS_ISA_MIPS64R2)+=-mips64r2 -mtune=mips64r2
        ifeq ($(strip $(ARCH_BIG_ENDIAN)),y)
                CPU_LDFLAGS-$(CONFIG_MIPS_N64_ABI)+=-Wl,-melf64btsmip
                CPU_LDFLAGS-$(CONFIG_MIPS_O32_ABI)+=-Wl,-melf32btsmip
@@ -548,6 +554,12 @@ ifeq ($(TARGET_ARCH),c6x)
        CPU_LDFLAGS-y += $(CPU_CFLAGS)
 endif
 
+ifeq ($(TARGET_ARCH),arc)
+       CPU_CFLAGS-y += -mlock -mswape
+       CPU_CFLAGS-$(CONFIG_ARC_CPU_700) += -mA7
+       CPU_LDFLAGS-y += $(CPU_CFLAGS) -marclinux
+endif
+
 $(eval $(call check-gcc-var,$(PIEFLAG_NAME)))
 PIEFLAG := $(CFLAG_$(PIEFLAG_NAME))
 ifeq ($(PIEFLAG),)
@@ -557,11 +569,11 @@ endif
 # well as the LD PIE flag (below) because we can't rely on
 # gcc passing -pie if we used -fPIE. We need to directly use -pie
 # instead of -Wl,-pie as gcc picks up the wrong startfile/endfile
-$(eval $(call cache-output-var,LDPIEFLAG,$(LD) --help 2>/dev/null | grep -q -- -pie && echo "-pie"))
+$(eval $(call cache-output-var,LDPIEFLAG,$(CC) -Wl$(comma)--help 2>/dev/null | grep -q -- -pie && echo "-pie"))
 
 # Check for --as-needed support in linker
 ifndef LD_FLAG_ASNEEDED
-_LD_FLAG_ASNEEDED:=$(shell $(LD) --help 2>/dev/null | grep -- --as-needed)
+_LD_FLAG_ASNEEDED:=$(shell $(CC) -Wl,--help 2>/dev/null | grep -- --as-needed)
 ifneq ($(_LD_FLAG_ASNEEDED),)
 export LD_FLAG_ASNEEDED:=--as-needed
 endif
@@ -585,7 +597,7 @@ link.asneeded = $(if $(findstring yy,$(CC_FLAG_ASNEEDED)$(CC_FLAG_NO_ASNEEDED)),
 
 # Check for AS_NEEDED support in linker script (binutils>=2.16.1 has it)
 ifndef ASNEEDED
-export ASNEEDED:=$(shell $(LD) --help 2>/dev/null | grep -q -- --as-needed && echo "AS_NEEDED ( $(UCLIBC_LDSO) )" || echo "$(UCLIBC_LDSO)")
+export ASNEEDED:=$(shell $(CC) -Wl,--help 2>/dev/null | grep -q -- --as-needed && echo "AS_NEEDED ( $(UCLIBC_LDSO) )" || echo "$(UCLIBC_LDSO)")
 
 # Only used in installed libc.so linker script
 ifeq ($(UCLIBC_HAS_BACKTRACE),y)
@@ -594,7 +606,7 @@ UBACKTRACE_FULL_NAME := $(subst //,/,$(RUNTIME_PREFIX)$(MULTILIB_DIR)/$(UBACKTRA
 else
 UBACKTRACE_FULL_NAME := $(UBACKTRACE_DSO)
 endif
-export UBACKTRACE_ASNEEDED:=$(shell $(LD) --help 2>/dev/null | grep -q -- --as-needed && \
+export UBACKTRACE_ASNEEDED:=$(shell $(CC) -Wl,--help 2>/dev/null | grep -q -- --as-needed && \
        echo "GROUP ( AS_NEEDED ( $(UBACKTRACE_FULL_NAME) ) )" || \
        echo "GROUP ( $(UBACKTRACE_FULL_NAME) )")
 else
@@ -641,8 +653,6 @@ else
 SSP_CFLAGS := $(SSP_DISABLE_FLAGS)
 endif
 
-$(eval $(call check-gcc-var,-nostdlib))
-
 # Collect all CFLAGS components
 CFLAGS := $(XWARNINGS) $(CPU_CFLAGS) $(SSP_CFLAGS) \
        -nostdinc -I$(top_builddir)include \
@@ -663,7 +673,7 @@ endif
 $(eval $(call check-ld-var,--warn-once))
 $(eval $(call check-ld-var,--sort-common))
 $(eval $(call check-ld-var,--discard-all))
-LDFLAGS_NOSTRIP:=$(CPU_LDFLAGS-y) -shared \
+LDFLAGS_NOSTRIP:=$(LDFLAG-fuse-ld) $(CPU_LDFLAGS-y) -shared \
        -Wl,--warn-common $(CFLAG_-Wl--warn-once) -Wl,-z,combreloc
 # binutils-2.16.1 warns about ignored sections, 2.16.91.0.3 and newer are ok
 #$(eval $(call check-ld-var,--gc-sections))