aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBernhard Reutner-Fischer <rep.dot.nop@gmail.com>2006-01-27 15:45:56 +0000
committerBernhard Reutner-Fischer <rep.dot.nop@gmail.com>2006-01-27 15:45:56 +0000
commit08a1b5095d710c5d905056a9daa14a1acad5590b (patch)
tree2b3632bc1361c718d8f80b7c95240730b7f52d71
parent79af7d5debe2f40ca1128975167243d4bb00fb51 (diff)
downloadbusybox-w32-08a1b5095d710c5d905056a9daa14a1acad5590b.tar.gz
busybox-w32-08a1b5095d710c5d905056a9daa14a1acad5590b.tar.bz2
busybox-w32-08a1b5095d710c5d905056a9daa14a1acad5590b.zip
- add a macro to check for ld and as flags
Very unreliable as e.g the ld check will see the flags supported by each emulation, not just the active one. good enough for now.. Fix would be to crate one or more dummy .c files and accually try if a flag works.
-rw-r--r--Makefile3
-rw-r--r--Rules.mak32
2 files changed, 27 insertions, 8 deletions
diff --git a/Makefile b/Makefile
index ce45583bc..9841659fe 100644
--- a/Makefile
+++ b/Makefile
@@ -277,8 +277,7 @@ endif
277 $(CC) $(CFLAGS) $(EXTRA_CFLAGS) $(LDFLAGS) -shared \ 277 $(CC) $(CFLAGS) $(EXTRA_CFLAGS) $(LDFLAGS) -shared \
278 $(CFLAGS_PIC) \ 278 $(CFLAGS_PIC) \
279 -Wl,-soname=$(LD_LIBBUSYBOX).$(MAJOR_VERSION) \ 279 -Wl,-soname=$(LD_LIBBUSYBOX).$(MAJOR_VERSION) \
280 -Wl,--enable-new-dtags -Wl,--reduce-memory-overheads \ 280 -Wl,-z,combreloc $(LIB_LDFLAGS) \
281 -Wl,-z,combreloc -Wl,-shared -Wl,--as-needed -Wl,--warn-shared-textrel \
282 -o $(@) \ 281 -o $(@) \
283 -Wl,--start-group -Wl,--whole-archive \ 282 -Wl,--start-group -Wl,--whole-archive \
284 $(LIBRARY_DEFINE) $(^) \ 283 $(LIBRARY_DEFINE) $(^) \
diff --git a/Rules.mak b/Rules.mak
index 8652b00f4..335cb3664 100644
--- a/Rules.mak
+++ b/Rules.mak
@@ -115,6 +115,20 @@ check_gcc=$(shell \
115 then echo "$(1)"; else echo "$(2)"; fi \ 115 then echo "$(1)"; else echo "$(2)"; fi \
116 fi) 116 fi)
117 117
118# A not very robust macro to check for available ld flags
119check_ld=$(shell \
120 echo "checking='$(1)'" >> foo.txt ; \
121 if [ "x$(1)" != "x" ]; then \
122 $(LD) --help | grep -q \\$(1) && echo "-Wl,$(1)$(2)" ; \
123 fi)
124
125# A not very robust macro to check for available as flags
126check_as=$(shell \
127 if [ "x$(1)" != "x" ]; then \
128 $(AS) --help | grep -q "\\$(1)" && echo "-Wa,$(1)$(2)" ; \
129 fi)
130
131
118# Setup some shortcuts so that silent mode is silent like it should be 132# Setup some shortcuts so that silent mode is silent like it should be
119ifeq ($(subst s,,$(MAKEFLAGS)),$(MAKEFLAGS)) 133ifeq ($(subst s,,$(MAKEFLAGS)),$(MAKEFLAGS))
120export MAKE_IS_SILENT=n 134export MAKE_IS_SILENT=n
@@ -145,10 +159,15 @@ OPTIMIZATION+=$(call check_gcc,-funit-at-a-time,)
145PROG_CFLAGS+=$(call check_gcc,-fwhole-program,) 159PROG_CFLAGS+=$(call check_gcc,-fwhole-program,)
146endif # CONFIG_BUILD_AT_ONCE 160endif # CONFIG_BUILD_AT_ONCE
147 161
162LIB_LDFLAGS:=$(call check_ld,--enable-new-dtags,)
163#LIB_LDFLAGS+=$(call check_ld,--reduce-memory-overheads,)
164#LIB_LDFLAGS+=$(call check_ld,--as-needed,)
165#LIB_LDFLAGS+=$(call check_ld,--warn-shared-textrel,)
166
167
148# Some nice architecture specific optimizations 168# Some nice architecture specific optimizations
149ifeq ($(strip $(TARGET_ARCH)),arm) 169ifeq ($(strip $(TARGET_ARCH)),arm)
150 OPTIMIZATION+=-fstrict-aliasing 170 OPTIMIZATION+=-fstrict-aliasing
151 OPTIMIZATION+=$(call check_gcc,-msingle-pic-base,)
152endif 171endif
153ifeq ($(strip $(TARGET_ARCH)),i386) 172ifeq ($(strip $(TARGET_ARCH)),i386)
154 OPTIMIZATION+=$(call check_gcc,-march=i386,) 173 OPTIMIZATION+=$(call check_gcc,-march=i386,)
@@ -169,7 +188,7 @@ ifeq ($(strip $(shell [ $(CC_MAJOR) -ge 4 -a $(CC_MINOR) -ge 1 ] ; echo $$?)),0)
169 OPTIMIZATION+=$(call check_gcc,-fno-branch-count-reg,) 188 OPTIMIZATION+=$(call check_gcc,-fno-branch-count-reg,)
170endif # gcc-4.1 and beyond 189endif # gcc-4.1 and beyond
171endif 190endif
172OPTIMIZATIONS:=$(OPTIMIZATION) -fomit-frame-pointer 191OPTIMIZATIONS:=$(OPTIMIZATION) $(call check_gcc,-fomit-frame-pointer,)
173 192
174# 193#
175#-------------------------------------------------------- 194#--------------------------------------------------------
@@ -195,21 +214,22 @@ else
195endif 214endif
196ifeq ($(strip $(CONFIG_DEBUG)),y) 215ifeq ($(strip $(CONFIG_DEBUG)),y)
197 CFLAGS +=$(WARNINGS) -g -D_GNU_SOURCE 216 CFLAGS +=$(WARNINGS) -g -D_GNU_SOURCE
198 LDFLAGS +=-Wl,-warn-common 217 LDFLAGS += $(call check_ld,-warn-common,)
199 STRIPCMD:=/bin/true -Not_stripping_since_we_are_debugging 218 STRIPCMD:=/bin/true -Not_stripping_since_we_are_debugging
200else 219else
201 CFLAGS+=$(WARNINGS) $(OPTIMIZATIONS) -D_GNU_SOURCE -DNDEBUG 220 CFLAGS+=$(WARNINGS) $(OPTIMIZATIONS) -D_GNU_SOURCE -DNDEBUG
202 LDFLAGS += -Wl,-warn-common -Wl,--sort-common 221 LDFLAGS += $(call check_ld,-warn-common,)
222 LDFLAGS += $(call check_ld,--sort-common,)
203 STRIPCMD:=$(STRIP) -s --remove-section=.note --remove-section=.comment 223 STRIPCMD:=$(STRIP) -s --remove-section=.note --remove-section=.comment
204endif 224endif
205ifeq ($(strip $(CONFIG_STATIC)),y) 225ifeq ($(strip $(CONFIG_STATIC)),y)
206 LDFLAGS += --static 226 LDFLAGS += $(call check_ld,--static,)
207#else 227#else
208# LIBRARIES += -ldl 228# LIBRARIES += -ldl
209endif 229endif
210 230
211ifeq ($(strip $(CONFIG_BUILD_LIBBUSYBOX)),y) 231ifeq ($(strip $(CONFIG_BUILD_LIBBUSYBOX)),y)
212 CFLAGS_PIC:= -fPIC #-DPIC 232 CFLAGS_PIC:= $(call check_gcc,-fPIC,)
213endif 233endif
214 234
215ifeq ($(strip $(CONFIG_SELINUX)),y) 235ifeq ($(strip $(CONFIG_SELINUX)),y)