OSDN Git Service

Merge remote branch 'origin/master' into nptl
[uclinux-h8/uClibc.git] / Rules.mak
index 611eaa8..18d9d39 100644 (file)
--- a/Rules.mak
+++ b/Rules.mak
@@ -46,6 +46,7 @@ CC         = $(CROSS)gcc
 AR         = $(CROSS)ar
 LD         = $(CROSS)ld
 NM         = $(CROSS)nm
+OBJDUMP    = $(CROSS)objdump
 STRIPTOOL  = $(CROSS)strip
 
 INSTALL    = install
@@ -69,12 +70,15 @@ BUILD_CFLAGS = -Os -Wall
 # mortals.  Unless you hang out with the gods, you should
 # probably leave all this stuff alone.
 
+# strip quotes
+qstrip = $(strip $(subst ",,$(1)))
+#"))
 
 # Pull in the user's uClibc configuration
 ifeq ($(filter $(noconfig_targets),$(MAKECMDGOALS)),)
 -include $(top_builddir).config
 endif
-TARGET_ARCH:=$(strip $(subst ",, $(strip $(TARGET_ARCH))))
+TARGET_ARCH:=$(call qstrip,$(TARGET_ARCH))
 ifeq ($(TARGET_ARCH),)
 ARCH ?= $(shell uname -m | $(SED) -e s/i.86/i386/ \
                                  -e s/sun.*/sparc/ -e s/sparc.*/sparc/ \
@@ -89,11 +93,11 @@ endif
 export ARCH
 
 # Make certain these contain a final "/", but no "//"s.
-TARGET_SUBARCH:=$(shell grep -s '^TARGET_SUBARCH' $(top_builddir)/.config | $(SED) -e 's/^TARGET_SUBARCH=//' -e 's/"//g')
-TARGET_SUBARCH:=$(strip $(subst ",, $(strip $(TARGET_SUBARCH))))
-RUNTIME_PREFIX:=$(strip $(subst //,/, $(subst ,/, $(subst ",, $(strip $(RUNTIME_PREFIX))))))
-DEVEL_PREFIX:=$(strip $(subst //,/, $(subst ,/, $(subst ",, $(strip $(DEVEL_PREFIX))))))
-KERNEL_HEADERS:=$(strip $(subst //,/, $(subst ,/, $(subst ",, $(strip $(KERNEL_HEADERS))))))
+TARGET_SUBARCH:=$(call qstrip,$(shell grep -s '^TARGET_SUBARCH' $(top_builddir)/.config | $(SED) -e 's/^TARGET_SUBARCH=//'))
+TARGET_SUBARCH:=$(call qstrip,$(TARGET_SUBARCH))
+RUNTIME_PREFIX:=$(strip $(subst //,/, $(subst ,/, $(call qstrip,$(RUNTIME_PREFIX)))))
+DEVEL_PREFIX:=$(strip $(subst //,/, $(subst ,/, $(call qstrip,$(DEVEL_PREFIX)))))
+KERNEL_HEADERS:=$(strip $(subst //,/, $(subst ,/, $(call qstrip,$(KERNEL_HEADERS)))))
 export RUNTIME_PREFIX DEVEL_PREFIX KERNEL_HEADERS
 
 
@@ -147,7 +151,7 @@ comma:=,
 space:= #
 
 ifndef CROSS
-CROSS=$(strip $(subst ",, $(CROSS_COMPILER_PREFIX)))
+CROSS=$(call qstrip,$(CROSS_COMPILER_PREFIX))
 endif
 
 # A nifty macro to make testing gcc features easier
@@ -171,6 +175,8 @@ OPTIMIZATION:=
 OPTIMIZATION+=$(call check_gcc,-Os,-O2)
 # Use the gcc 3.4 -funit-at-a-time optimization when available
 OPTIMIZATION+=$(call check_gcc,-funit-at-a-time,)
+# shrinks code by about 0.1%
+OPTIMIZATION+=$(call check_gcc,-fmerge-all-constants)
 
 GCC_MAJOR_VER?=$(shell $(CC) -dumpversion | cut -d . -f 1)
 #GCC_MINOR_VER?=$(shell $(CC) -dumpversion | cut -d . -f 2)
@@ -222,7 +228,7 @@ CPU_CFLAGS-$(UCLIBC_FORMAT_FLAT_SEP_DATA) += -msep-data
 CPU_LDFLAGS-$(ARCH_LITTLE_ENDIAN) += -Wl,-EL
 CPU_LDFLAGS-$(ARCH_BIG_ENDIAN)    += -Wl,-EB
 
-PICFLAG-y := -fPIC
+PICFLAG-y := -fPIC -DPIC
 PICFLAG-$(UCLIBC_FORMAT_FDPIC_ELF) := -mfdpic
 PICFLAG := $(PICFLAG-y)
 PIEFLAG_NAME:=-fPIE
@@ -279,7 +285,7 @@ endif
        # Idx Name          Size      VMA       LMA       File off  Algn
        #   0 .text         xxxxxxxx  00000000  00000000  xxxxxxxx  2**2 <===!
        CPU_CFLAGS-y  += $(call check_gcc,-ffunction-sections -fdata-sections,)
-ifneq ($(call check_ld,--sort-common,),)
+ifneq ($(call check_ld,--sort-common),)
        CPU_LDFLAGS-y += -Wl,--sort-common
 endif
 ifneq ($(call check_ld,--sort-section alignment),)
@@ -339,6 +345,7 @@ ifeq ($(TARGET_ARCH),arm)
 endif
 
 ifeq ($(TARGET_ARCH),mips)
+       OPTIMIZATIONS+=-mno-split-addresses
        CPU_CFLAGS-$(CONFIG_MIPS_ISA_1)+=-mips1
        CPU_CFLAGS-$(CONFIG_MIPS_ISA_2)+=-mips2 -mtune=mips2
        CPU_CFLAGS-$(CONFIG_MIPS_ISA_3)+=-mips3 -mtune=mips3
@@ -360,6 +367,7 @@ ifeq ($(TARGET_ARCH),mips)
 endif
 
 ifeq ($(TARGET_ARCH),nios)
+       OPTIMIZATIONS+=-funaligned-struct-hack
        CPU_LDFLAGS-y+=-Wl,-m32
        CPU_CFLAGS-y+=-Wl,-m32
 endif
@@ -395,6 +403,14 @@ ifeq ($(TARGET_ARCH),h8300)
        CPU_CFLAGS-$(CONFIG_H8S)    += -ms -mint32
 endif
 
+ifeq ($(TARGET_ARCH),i960)
+       OPTIMIZATIONS+=-mh -mint32 #-fsigned-char
+endif
+
+ifeq ($(TARGET_ARCH),e1)
+       OPTIMIZATIONS+=-mgnu-param
+endif
+
 ifeq ($(TARGET_ARCH),cris)
        CPU_LDFLAGS-$(CONFIG_CRIS)+=-Wl,-mcrislinux
        CPU_LDFLAGS-$(CONFIG_CRISV32)+=-Wl,-mcrislinux
@@ -506,7 +522,7 @@ export ASNEEDED:=$(shell $(LD) --help 2>/dev/null | grep -q -- --as-needed && ec
 endif
 
 # Add a bunch of extra pedantic annoyingly strict checks
-XWARNINGS=$(subst ",, $(strip $(WARNINGS))) -Wstrict-prototypes -fno-strict-aliasing
+XWARNINGS=$(call qstrip,$(WARNINGS)) -Wstrict-prototypes -fno-strict-aliasing
 ifeq ($(EXTRA_WARNINGS),y)
 XWARNINGS+=-Wnested-externs -Wshadow -Wmissing-noreturn -Wmissing-format-attribute -Wformat=2
 XWARNINGS+=-Wmissing-prototypes -Wmissing-declarations
@@ -514,10 +530,7 @@ XWARNINGS+=-Wnonnull -Wundef
 # Works only w/ gcc-3.4 and up, can't be checked for gcc-3.x w/ check_gcc()
 #XWARNINGS+=-Wdeclaration-after-statement
 endif
-# Seems to be unused (no ARCH_CFLAGS anywhere), delete?
-# if yes, remove after 0.9.31
-XARCH_CFLAGS=$(subst ",, $(strip $(ARCH_CFLAGS)))
-CPU_CFLAGS=$(subst ",, $(strip $(CPU_CFLAGS-y)))
+CPU_CFLAGS=$(call qstrip,$(CPU_CFLAGS-y))
 
 SSP_DISABLE_FLAGS ?= $(call check_gcc,-fno-stack-protector,)
 ifeq ($(UCLIBC_BUILD_SSP),y)
@@ -536,7 +549,7 @@ CFLAGS := -include $(top_srcdir)include/libc-symbols.h \
        -nostdinc -I$(top_builddir)include -I$(top_srcdir)include -I. \
        -I$(top_srcdir)libc/sysdeps/linux/$(TARGET_ARCH)
 ifneq ($(strip $(UCLIBC_EXTRA_CFLAGS)),"")
-CFLAGS += $(subst ",, $(UCLIBC_EXTRA_CFLAGS))
+CFLAGS += $(call qstrip,$(UCLIBC_EXTRA_CFLAGS))
 endif
 
 # We need this to be checked within libc-symbols.h
@@ -544,8 +557,11 @@ ifneq ($(HAVE_SHARED),y)
 CFLAGS += -DSTATIC
 endif
 
+LDFLAG_WARN_ONCE:=$(if $(call check_ld,--warn-once),-Wl$(comma)--warn-once)
+LDFLAG_SORT_COMMON:=$(if $(call check_ld,--sort-common),-Wl$(comma)--sort-common)
+LDFLAG_DISCARD_ALL:=$(if $(call check_ld,--discard-all),-Wl$(comma)--discard-all)
 LDFLAGS_NOSTRIP:=$(CPU_LDFLAGS-y) -shared \
-       -Wl,--warn-common -Wl,--warn-once -Wl,-z,combreloc
+       -Wl,--warn-common $(LDFLAG_WARN_ONCE) -Wl,-z,combreloc
 # binutils-2.16.1 warns about ignored sections, 2.16.91.0.3 and newer are ok
 #LDFLAGS_NOSTRIP+=$(call check_ld,--gc-sections)
 
@@ -562,7 +578,7 @@ ifeq ($(LDSO_GNU_HASH_SUPPORT),y)
 LDFLAGS_GNUHASH:=$(call check_ld,--hash-style=gnu)
 ifeq ($(LDFLAGS_GNUHASH),)
 ifneq ($(filter-out install_headers headers-y,$(MAKECMDGOALS)),)
-$(error Your binutils don't support --hash-style option, while you want to use it)
+$(error Your binutils do not support --hash-style option, while you want to use it)
 endif
 else
 LDFLAGS_NOSTRIP += -Wl,$(LDFLAGS_GNUHASH)
@@ -571,9 +587,9 @@ endif
 
 LDFLAGS:=$(LDFLAGS_NOSTRIP) -Wl,-z,defs
 ifeq ($(DODEBUG),y)
-CFLAGS += -O0 -g3
+CFLAGS += -O0 -g3 -DDEBUG
 else
-CFLAGS += $(OPTIMIZATION) $(XARCH_CFLAGS)
+CFLAGS += $(OPTIMIZATION)
 endif
 ifeq ($(DOSTRIP),y)
 LDFLAGS += -Wl,-s
@@ -597,7 +613,7 @@ DOMULTI:=n
 endif
 
 ifneq ($(strip $(UCLIBC_EXTRA_LDFLAGS)),"")
-LDFLAGS += $(subst ",, $(UCLIBC_EXTRA_LDFLAGS))
+LDFLAGS += $(call qstrip,$(UCLIBC_EXTRA_LDFLAGS))
 endif
 
 ifeq ($(UCLIBC_HAS_THREADS),y)
@@ -614,6 +630,7 @@ PTDIR := libpthread/$(PTNAME)
 # set up system dependencies include dirs (NOTE: order matters!)
 ifeq ($(UCLIBC_HAS_THREADS_NATIVE),y)
 PTINC:=        -I$(top_srcdir)$(PTDIR)                                         \
+       -I$(top_srcdir)$(PTDIR)/sysdeps/unix/sysv/linux/$(TARGET_ARCH)/$(TARGET_SUBARCH)        \
        -I$(top_srcdir)$(PTDIR)/sysdeps/unix/sysv/linux/$(TARGET_ARCH)  \
        -I$(top_srcdir)$(PTDIR)/sysdeps/$(TARGET_ARCH)                  \
        -I$(top_srcdir)$(PTDIR)/sysdeps/unix/sysv/linux                 \
@@ -653,6 +670,7 @@ else
        PTNAME :=
        PTINC  :=
 endif
+CFLAGS += -I$(top_srcdir)libc/sysdeps/linux/common
 CFLAGS += -I$(KERNEL_HEADERS)
 
 #CFLAGS += -iwithprefix include-fixed -iwithprefix include