summaryrefslogtreecommitdiff
path: root/Rules.mak
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2002-01-01 22:16:45 +0000
committerEric Andersen <andersen@codepoet.org>2002-01-01 22:16:45 +0000
commit06d634eab66c7ebce0fe02d87b2c0b48ac4fa72b (patch)
treeb2b74e4d34b78b42775b329bfa0c07403638570e /Rules.mak
parent4643b181bdf1d9121f9d6d4214e991e7b9f52d30 (diff)
Support arch specific optimizations (examples shown for x86 and ARM).
Autodetect target architecture by asking the compiler. -Erik
Diffstat (limited to 'Rules.mak')
-rw-r--r--Rules.mak21
1 files changed, 19 insertions, 2 deletions
diff --git a/Rules.mak b/Rules.mak
index 534a97843..6dbc96fcf 100644
--- a/Rules.mak
+++ b/Rules.mak
@@ -38,11 +38,28 @@ BUILDTIME = ${shell TZ=UTC date --utc "+%Y.%m.%d-%H:%M%z"}
GCCINCDIR = ${shell $(CC) -print-search-dirs | sed -ne "s/install: \(.*\)/\1include/gp"}
NATIVE_ARCH = ${shell uname -m | sed -e 's/i.86/i386/' -e 's/sparc.*/sparc/' \
-e 's/arm.*/arm/g' -e 's/m68k.*/m68k/' -e 's/ppc/powerpc/g'}
+TARGET_ARCH=${shell $(CC) -dumpmachine | sed -e s'/-linux//' -e 's/i.86/i386/' -e 's/sparc.*/sparc/' \
+ -e 's/arm.*/arm/g' -e 's/m68k.*/m68k/' -e 's/ppc/powerpc/g'}
-# use '-Os' optimization if available, else use -O2, allow Config to override
+# Some nice architecture specific optimizations
ifndef OPTIMIZATION
+# use '-Os' optimization if available, else use -O2, allow Config to override
OPTIMIZATION = ${shell if $(CC) -Os -S -o /dev/null -xc /dev/null >/dev/null 2>&1; \
then echo "-Os"; else echo "-O2" ; fi}
+ifeq ($(strip $(TARGET_ARCH)),arm)
+ OPTIMIZATION+=-fstrict-aliasing
+endif
+ifeq ($(strip $(TARGET_ARCH)),i386)
+ OPTIMIZATION+=-march=i386
+ OPTIMIZATION += ${shell if $(CC) -mpreferred-stack-boundary=2 -S -o /dev/null -xc \
+ /dev/null >/dev/null 2>&1; then echo "-mpreferred-stack-boundary=2"; fi}
+ OPTIMIZATION += ${shell if $(CC) -malign-functions=0 -malign-jumps=0 -malign-loops=0 \
+ -S -o /dev/null -xc /dev/null >/dev/null 2>&1; then echo \
+ "-malign-functions=0 -malign-jumps=0 -malign-loops=0"; fi}
+ CPUFLAGS+=-pipe
+else
+ CPUFLAGS+=-pipe
+endif
endif
ARFLAGS=r
@@ -75,7 +92,7 @@ ifeq ($(strip $(HAVE_SHARED)),true)
ifeq ($(strip $(BUILD_UCLIBC_LDSO)),true)
LDSO=$(TOPDIR)lib/$(UCLIBC_LDSO)
DYNAMIC_LINKER=$(SHARED_LIB_LOADER_PATH)/$(UCLIBC_LDSO)
- BUILD_DYNAMIC_LINKER=$(shell cd $(TOPDIR)lib; pwd)/$(UCLIBC_LDSO)
+ BUILD_DYNAMIC_LINKER=${shell cd $(TOPDIR)lib && pwd}/$(UCLIBC_LDSO)
else
LDSO=$(SYSTEM_LDSO)
DYNAMIC_LINKER=/lib/$(notdir $(SYSTEM_LDSO))