AR = $(CROSS)ar
LD = $(CROSS)ld
NM = $(CROSS)nm
+OBJDUMP = $(CROSS)objdump
STRIPTOOL = $(CROSS)strip
INSTALL = install
# 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/ \
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
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
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)
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
# 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),)
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
endif
ifeq ($(TARGET_ARCH),nios)
+ OPTIMIZATIONS+=-funaligned-struct-hack
CPU_LDFLAGS-y+=-Wl,-m32
CPU_CFLAGS-y+=-Wl,-m32
endif
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
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
# 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)
-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
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)
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)
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
endif
ifneq ($(strip $(UCLIBC_EXTRA_LDFLAGS)),"")
-LDFLAGS += $(subst ",, $(UCLIBC_EXTRA_LDFLAGS))
+LDFLAGS += $(call qstrip,$(UCLIBC_EXTRA_LDFLAGS))
endif
ifeq ($(UCLIBC_HAS_THREADS),y)
# 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 \
PTNAME :=
PTINC :=
endif
+CFLAGS += -I$(top_srcdir)libc/sysdeps/linux/common
CFLAGS += -I$(KERNEL_HEADERS)
#CFLAGS += -iwithprefix include-fixed -iwithprefix include