diff options
author | Bernhard Reutner-Fischer <rep.dot.nop@gmail.com> | 2006-01-27 15:45:56 +0000 |
---|---|---|
committer | Bernhard Reutner-Fischer <rep.dot.nop@gmail.com> | 2006-01-27 15:45:56 +0000 |
commit | 08a1b5095d710c5d905056a9daa14a1acad5590b (patch) | |
tree | 2b3632bc1361c718d8f80b7c95240730b7f52d71 | |
parent | 79af7d5debe2f40ca1128975167243d4bb00fb51 (diff) | |
download | busybox-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-- | Makefile | 3 | ||||
-rw-r--r-- | Rules.mak | 32 |
2 files changed, 27 insertions, 8 deletions
@@ -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) $(^) \ |
@@ -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 | ||
119 | check_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 | ||
126 | check_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 |
119 | ifeq ($(subst s,,$(MAKEFLAGS)),$(MAKEFLAGS)) | 133 | ifeq ($(subst s,,$(MAKEFLAGS)),$(MAKEFLAGS)) |
120 | export MAKE_IS_SILENT=n | 134 | export MAKE_IS_SILENT=n |
@@ -145,10 +159,15 @@ OPTIMIZATION+=$(call check_gcc,-funit-at-a-time,) | |||
145 | PROG_CFLAGS+=$(call check_gcc,-fwhole-program,) | 159 | PROG_CFLAGS+=$(call check_gcc,-fwhole-program,) |
146 | endif # CONFIG_BUILD_AT_ONCE | 160 | endif # CONFIG_BUILD_AT_ONCE |
147 | 161 | ||
162 | LIB_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 |
149 | ifeq ($(strip $(TARGET_ARCH)),arm) | 169 | ifeq ($(strip $(TARGET_ARCH)),arm) |
150 | OPTIMIZATION+=-fstrict-aliasing | 170 | OPTIMIZATION+=-fstrict-aliasing |
151 | OPTIMIZATION+=$(call check_gcc,-msingle-pic-base,) | ||
152 | endif | 171 | endif |
153 | ifeq ($(strip $(TARGET_ARCH)),i386) | 172 | ifeq ($(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,) |
170 | endif # gcc-4.1 and beyond | 189 | endif # gcc-4.1 and beyond |
171 | endif | 190 | endif |
172 | OPTIMIZATIONS:=$(OPTIMIZATION) -fomit-frame-pointer | 191 | OPTIMIZATIONS:=$(OPTIMIZATION) $(call check_gcc,-fomit-frame-pointer,) |
173 | 192 | ||
174 | # | 193 | # |
175 | #-------------------------------------------------------- | 194 | #-------------------------------------------------------- |
@@ -195,21 +214,22 @@ else | |||
195 | endif | 214 | endif |
196 | ifeq ($(strip $(CONFIG_DEBUG)),y) | 215 | ifeq ($(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 |
200 | else | 219 | else |
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 |
204 | endif | 224 | endif |
205 | ifeq ($(strip $(CONFIG_STATIC)),y) | 225 | ifeq ($(strip $(CONFIG_STATIC)),y) |
206 | LDFLAGS += --static | 226 | LDFLAGS += $(call check_ld,--static,) |
207 | #else | 227 | #else |
208 | # LIBRARIES += -ldl | 228 | # LIBRARIES += -ldl |
209 | endif | 229 | endif |
210 | 230 | ||
211 | ifeq ($(strip $(CONFIG_BUILD_LIBBUSYBOX)),y) | 231 | ifeq ($(strip $(CONFIG_BUILD_LIBBUSYBOX)),y) |
212 | CFLAGS_PIC:= -fPIC #-DPIC | 232 | CFLAGS_PIC:= $(call check_gcc,-fPIC,) |
213 | endif | 233 | endif |
214 | 234 | ||
215 | ifeq ($(strip $(CONFIG_SELINUX)),y) | 235 | ifeq ($(strip $(CONFIG_SELINUX)),y) |