aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBernhard Reutner-Fischer <rep.dot.nop@gmail.com>2006-05-26 13:22:57 +0000
committerBernhard Reutner-Fischer <rep.dot.nop@gmail.com>2006-05-26 13:22:57 +0000
commite28d1d6fdc27aa16c2c3a5bbf06cba36798bff5a (patch)
treea28c70ce8e2dc7cf38c003a1d88c69ebaed3126d
parent6d0dbeb55017985fa5d476b99427f7bf525e9a14 (diff)
downloadbusybox-w32-e28d1d6fdc27aa16c2c3a5bbf06cba36798bff5a.tar.gz
busybox-w32-e28d1d6fdc27aa16c2c3a5bbf06cba36798bff5a.tar.bz2
busybox-w32-e28d1d6fdc27aa16c2c3a5bbf06cba36798bff5a.zip
- add target hosttools (see make help)
- rename check_gcc to check_cc and pass the CC to use as arg#1; peruse check_cc for HOSTCFLAGS - add and use check_strip - add checks for {,no-}whole-archive and {start,end}-group LD flags
-rw-r--r--Makefile34
-rw-r--r--Rules.mak171
2 files changed, 141 insertions, 64 deletions
diff --git a/Makefile b/Makefile
index 77c25742b..5b7b5c61f 100644
--- a/Makefile
+++ b/Makefile
@@ -8,7 +8,7 @@
8#-------------------------------------------------------------- 8#--------------------------------------------------------------
9# You shouldn't need to mess with anything beyond this point... 9# You shouldn't need to mess with anything beyond this point...
10#-------------------------------------------------------------- 10#--------------------------------------------------------------
11noconfig_targets := menuconfig config oldconfig randconfig \ 11noconfig_targets := menuconfig config oldconfig randconfig hosttools \
12 defconfig allyesconfig allnoconfig allbareconfig \ 12 defconfig allyesconfig allnoconfig allbareconfig \
13 clean distclean help \ 13 clean distclean help \
14 release tags 14 release tags
@@ -126,6 +126,10 @@ help:
126 @echo ' defconfig - set .config to largest generic configuration' 126 @echo ' defconfig - set .config to largest generic configuration'
127 @echo ' menuconfig - interactive curses-based configurator' 127 @echo ' menuconfig - interactive curses-based configurator'
128 @echo ' oldconfig - resolve any unresolved symbols in .config' 128 @echo ' oldconfig - resolve any unresolved symbols in .config'
129 @echo ' hosttools - build sed for the host.'
130 @echo ' You can use these commands if the commands on the host'
131 @echo ' is unusable. Afterwards use it like:'
132 @echo ' make SED="$(top_builddir)/sed"'
129 @echo 133 @echo
130 @echo 'Installation:' 134 @echo 'Installation:'
131 @echo ' install - install busybox into $(PREFIX)' 135 @echo ' install - install busybox into $(PREFIX)'
@@ -210,6 +214,18 @@ allbareconfig: scripts/config/conf
210 @echo "CONFIG_FEATURE_BUFFERS_GO_ON_STACK=y" >> .config 214 @echo "CONFIG_FEATURE_BUFFERS_GO_ON_STACK=y" >> .config
211 @yes n | ./scripts/config/conf -o $(CONFIG_CONFIG_IN) > /dev/null 215 @yes n | ./scripts/config/conf -o $(CONFIG_CONFIG_IN) > /dev/null
212 216
217hosttools:
218 $(Q)cp .config .config.bak || noold=yea
219 $(Q)$(MAKE) CC="$(HOSTCC)" CFLAGS="$(HOSTCFLAGS) $(INCS)" allnoconfig
220 $(Q)mv .config .config.in
221 $(Q)(grep -v CONFIG_SED .config.in ; \
222 echo "CONFIG_SED=y" ; ) > .config
223 $(Q)$(MAKE) CC="$(HOSTCC)" CFLAGS="$(HOSTCFLAGS) $(INCS)" oldconfig include/bb_config.h
224 $(Q)$(MAKE) CC="$(HOSTCC)" CFLAGS="$(HOSTCFLAGS) $(INCS)" busybox
225 $(Q)[ -f .config.bak ] && mv .config.bak .config || rm .config
226 mv busybox sed
227 @echo "Now do: $(MAKE) SED=$(top_builddir)/sed <target>"
228
213else # ifneq ($(strip $(HAVE_DOT_CONFIG)),y) 229else # ifneq ($(strip $(HAVE_DOT_CONFIG)),y)
214 230
215all: busybox busybox.links doc 231all: busybox busybox.links doc
@@ -287,9 +303,9 @@ endif
287 -Wl,-soname=$(LD_LIBBUSYBOX).$(MAJOR_VERSION) \ 303 -Wl,-soname=$(LD_LIBBUSYBOX).$(MAJOR_VERSION) \
288 -Wl,-z,combreloc $(LIB_LDFLAGS) \ 304 -Wl,-z,combreloc $(LIB_LDFLAGS) \
289 -o $(@) \ 305 -o $(@) \
290 -Wl,--start-group -Wl,--whole-archive \ 306 $(LD_START_GROUP) $(LD_WHOLE_ARCHIVE) \
291 $(LIBRARY_DEFINE) $(^) \ 307 $(LIBRARY_DEFINE) $(^) \
292 -Wl,--no-whole-archive -Wl,--end-group 308 $(LD_NO_WHOLE_ARCHIVE) $(LD_END_GROUP)
293 @rm -f $(DO_INSTALL_LIBS) 309 @rm -f $(DO_INSTALL_LIBS)
294 @for i in $(DO_INSTALL_LIBS); do ln -s $(@) $$i ; done 310 @for i in $(DO_INSTALL_LIBS); do ln -s $(@) $$i ; done
295 $(do_strip) 311 $(do_strip)
@@ -298,11 +314,11 @@ endif # ifeq ($(strip $(CONFIG_BUILD_LIBBUSYBOX)),y)
298 314
299busybox_unstripped: .depend $(LIBBUSYBOX_SONAME) $(BUSYBOX_SRC) $(APPLET_SRC) $(libraries-y) 315busybox_unstripped: .depend $(LIBBUSYBOX_SONAME) $(BUSYBOX_SRC) $(APPLET_SRC) $(libraries-y)
300 $(do_link) $(PROG_CFLAGS) $(PROG_LDFLAGS) $(CFLAGS_COMBINE) \ 316 $(do_link) $(PROG_CFLAGS) $(PROG_LDFLAGS) $(CFLAGS_COMBINE) \
301 -o $@ -Wl,--start-group \ 317 -o $@ $(LD_START_GROUP) \
302 $(APPLETS_DEFINE) $(APPLET_SRC) \ 318 $(APPLETS_DEFINE) $(APPLET_SRC) \
303 $(BUSYBOX_DEFINE) $(BUSYBOX_SRC) $(libraries-y) \ 319 $(BUSYBOX_DEFINE) $(BUSYBOX_SRC) $(libraries-y) \
304 $(LDBUSYBOX) $(LIBRARIES) \ 320 $(LDBUSYBOX) $(LIBRARIES) \
305 -Wl,--end-group 321 $(LD_END_GROUP)
306 322
307busybox: busybox_unstripped 323busybox: busybox_unstripped
308 $(Q)cp busybox_unstripped busybox 324 $(Q)cp busybox_unstripped busybox
@@ -349,8 +365,8 @@ ifneq ($(strip $(KBUILD_VERBOSE)),)
349# ARFLAGS+=v 365# ARFLAGS+=v
350endif 366endif
351check test: busybox 367check test: busybox
352 bindir=$(top_builddir) srcdir=$(top_srcdir)/testsuite \ 368 bindir=$(top_builddir) srcdir=$(top_srcdir)/testsuite SED="$(SED)" \
353 $(top_srcdir)/testsuite/runtest $(CHECK_VERBOSE) 369 $(SHELL) $(top_srcdir)/testsuite/runtest $(CHECK_VERBOSE)
354 370
355.PHONY: checkhelp 371.PHONY: checkhelp
356checkhelp: 372checkhelp:
@@ -422,7 +438,7 @@ $(USAGE_BIN): $(top_srcdir)/scripts/usage.c
422DEP_INCLUDES += include/usage_compressed.h 438DEP_INCLUDES += include/usage_compressed.h
423 439
424include/usage_compressed.h: .config $(USAGE_BIN) 440include/usage_compressed.h: .config $(USAGE_BIN)
425 $(Q)$(SHELL) $(top_srcdir)/scripts/usage_compressed "$(top_builddir)/scripts" > $@ 441 $(Q)SED="$(SED)" $(SHELL) $(top_srcdir)/scripts/usage_compressed "$(top_builddir)/scripts" > $@
426endif # CONFIG_FEATURE_COMPRESS_USAGE 442endif # CONFIG_FEATURE_COMPRESS_USAGE
427 443
428# workaround alleged bug in make-3.80, make-3.81 444# workaround alleged bug in make-3.80, make-3.81
@@ -486,4 +502,4 @@ tags:
486endif # ifeq ($(skip-makefile),) 502endif # ifeq ($(skip-makefile),)
487 503
488.PHONY: dummy subdirs release distclean clean config oldconfig \ 504.PHONY: dummy subdirs release distclean clean config oldconfig \
489 menuconfig tags check test depend dep buildtree 505 menuconfig tags check test depend dep buildtree hosttools
diff --git a/Rules.mak b/Rules.mak
index ebd09edb3..cce41dcb9 100644
--- a/Rules.mak
+++ b/Rules.mak
@@ -31,7 +31,8 @@ BUILDTIME := $(shell TZ=UTC date -u "+%Y.%m.%d-%H:%M%z")
31# to something more interesting... Target architecture is determined 31# to something more interesting... Target architecture is determined
32# by asking the CC compiler what arch it compiles things for, so unless 32# by asking the CC compiler what arch it compiles things for, so unless
33# your compiler is broken, you should not need to specify TARGET_ARCH 33# your compiler is broken, you should not need to specify TARGET_ARCH
34CROSS =$(subst ",, $(strip $(CROSS_COMPILER_PREFIX))) 34CROSS =$(strip $(subst ",, $(strip $(CROSS_COMPILER_PREFIX))))
35# be gentle to vi coloring.. "))
35CC = $(CROSS)gcc 36CC = $(CROSS)gcc
36AR = $(CROSS)ar 37AR = $(CROSS)ar
37AS = $(CROSS)as 38AS = $(CROSS)as
@@ -41,16 +42,13 @@ STRIP = $(CROSS)strip
41ELF2FLT = $(CROSS)elf2flt 42ELF2FLT = $(CROSS)elf2flt
42CPP = $(CC) -E 43CPP = $(CC) -E
43SED ?= sed 44SED ?= sed
45BZIP2 ?= bzip2
44 46
45 47
46# What OS are you compiling busybox for? This allows you to include 48# What OS are you compiling busybox for? This allows you to include
47# OS specific things, syscall overrides, etc. 49# OS specific things, syscall overrides, etc.
48TARGET_OS=linux 50TARGET_OS=linux
49 51
50# Select the compiler needed to build binaries for your development system
51HOSTCC = gcc
52HOSTCFLAGS= -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer
53
54# Ensure consistent sort order, 'gcc -print-search-dirs' behavior, etc. 52# Ensure consistent sort order, 'gcc -print-search-dirs' behavior, etc.
55LC_ALL:= C 53LC_ALL:= C
56 54
@@ -71,7 +69,7 @@ CFLAGS_EXTRA=$(subst ",, $(strip $(EXTRA_CFLAGS_OPTIONS)))
71#LDFLAGS+=-nostdlib 69#LDFLAGS+=-nostdlib
72#LIBRARIES:=$(LIBCDIR)/lib/libc.a -lgcc 70#LIBRARIES:=$(LIBCDIR)/lib/libc.a -lgcc
73#CROSS_CFLAGS+=-nostdinc -I$(LIBCDIR)/include -I$(GCCINCDIR) -funsigned-char 71#CROSS_CFLAGS+=-nostdinc -I$(LIBCDIR)/include -I$(GCCINCDIR) -funsigned-char
74#GCCINCDIR:=$(shell gcc -print-search-dirs | sed -ne "s/install: \(.*\)/\1include/gp") 72#GCCINCDIR:=$(shell gcc -print-search-dirs | $(SED) -ne "s/install: \(.*\)/\1include/gp")
75 73
76# This must bind late because srcdir is reset for every source subdirectory. 74# This must bind late because srcdir is reset for every source subdirectory.
77INCS:=-I$(top_builddir)/include -I$(top_srcdir)/include 75INCS:=-I$(top_builddir)/include -I$(top_srcdir)/include
@@ -79,11 +77,6 @@ CFLAGS=$(INCS) -I$(srcdir) -D_GNU_SOURCE
79CFLAGS+=$(CHECKED_CFLAGS) 77CFLAGS+=$(CHECKED_CFLAGS)
80ARFLAGS=cru 78ARFLAGS=cru
81 79
82# Warnings
83
84CFLAGS += -Wall -Wstrict-prototypes -Wshadow
85LDFLAGS += $(call check_ld,--warn-common,)
86
87# gcc centric. Perhaps fiddle with findstring gcc,$(CC) for the rest 80# gcc centric. Perhaps fiddle with findstring gcc,$(CC) for the rest
88# get the CC MAJOR/MINOR version 81# get the CC MAJOR/MINOR version
89CC_MAJOR:=$(shell printf "%02d" $(shell echo __GNUC__ | $(CC) -E -xc - | tail -n 1)) 82CC_MAJOR:=$(shell printf "%02d" $(shell echo __GNUC__ | $(CC) -E -xc - | tail -n 1))
@@ -92,7 +85,7 @@ CC_MINOR:=$(shell printf "%02d" $(shell echo __GNUC_MINOR__ | $(CC) -E -xc - | t
92#-------------------------------------------------------- 85#--------------------------------------------------------
93export VERSION BUILDTIME HOSTCC HOSTCFLAGS CROSS CC AR AS LD NM STRIP CPP 86export VERSION BUILDTIME HOSTCC HOSTCFLAGS CROSS CC AR AS LD NM STRIP CPP
94ifeq ($(strip $(TARGET_ARCH)),) 87ifeq ($(strip $(TARGET_ARCH)),)
95TARGET_ARCH:=$(shell $(CC) -dumpmachine | sed -e s'/-.*//' \ 88TARGET_ARCH:=$(shell $(CC) -dumpmachine | $(SED) -e s'/-.*//' \
96 -e 's/i.86/i386/' \ 89 -e 's/i.86/i386/' \
97 -e 's/sparc.*/sparc/' \ 90 -e 's/sparc.*/sparc/' \
98 -e 's/arm.*/arm/g' \ 91 -e 's/arm.*/arm/g' \
@@ -107,27 +100,90 @@ TARGET_ARCH:=$(shell $(CC) -dumpmachine | sed -e s'/-.*//' \
107endif 100endif
108 101
109# A nifty macro to make testing gcc features easier, but note that everything 102# A nifty macro to make testing gcc features easier, but note that everything
110# that uses this _must_ use := or it will be re-evaluated for every file. 103# that uses this _must_ use := or it will be re-evaluated everytime it is
104# referenced.
111ifeq ($(strip $(V)),2) 105ifeq ($(strip $(V)),2)
112VERBOSE_CHECK_GCC=echo check_gcc $(1) >> /dev/stderr; 106VERBOSE_CHECK_CC=echo CC=\"$(1)\" check_cc $(2) >&2;
113endif 107endif
114check_gcc=$(shell \ 108check_cc=$(shell \
115 $(VERBOSE_CHECK_GCC)\ 109 $(VERBOSE_CHECK_CC) \
116 if [ "$(1)" != "" ]; then \ 110 if [ "x$(1)" != "x" ] && [ "x$(2)" != "x" ]; then \
117 if $(CC) $(1) -S -o /dev/null -xc /dev/null > /dev/null 2>&1; \ 111 echo "int i;" > ./conftest.c; \
118 then echo "$(1)"; else echo "$(2)"; fi \ 112 if $(1) $(2) -c -o conftest.o conftest.c > /dev/null 2>&1; \
113 then echo "$(2)"; else echo "$(3)"; fi ; \
114 rm -f conftest.c conftest.o; \
119 fi) 115 fi)
120 116
121# A not very robust macro to check for available ld flags 117# A not very robust macro to check for available ld flags
118ifeq ($(strip $(V)),2)
119VERBOSE_CHECK_LD=echo LD=\"$(1)\" check_ld $(2) >&2;
120endif
122check_ld=$(shell \ 121check_ld=$(shell \
123 if [ "x$(1)" != "x" ]; then \ 122 $(VERBOSE_CHECK_LD) \
124 $(LD) --help | grep -q "\$(1)" && echo "-Wl,$(1)" ; \ 123 if [ "x$(1)" != "x" ] && [ "x$(2)" != "x" ]; then \
124 $(1) -o /dev/null -b binary /dev/null > /dev/null 2>&1 && \
125 echo "-Wl,$(2)" ; \
125 fi) 126 fi)
126 127
128# A not very robust macro to check for available strip flags
129ifeq ($(strip $(V)),2)
130VERBOSE_CHECK_STRIP=echo STRIPCMD=\"$(1)\" check_strip $(2) >&2;
131endif
132check_strip=$(shell \
133 $(VERBOSE_CHECK_STRIP) \
134 if [ "x$(1)" != "x" ] && [ "x$(2)" != "x" ]; then \
135 echo "int i;" > ./conftest.c ; \
136 $(CC) -c -o conftest.o conftest.c > /dev/null 2>&1 ; \
137 $(1) $(2) conftest.o > /dev/null 2>&1 && \
138 echo "$(1) $(2)" || echo "$(3)"; \
139 rm -f conftest.c conftest.o > /dev/null 2>&1 ; \
140 fi)
141
142
143
144# Select the compiler needed to build binaries for your development system
145HOSTCC = gcc
146HOSTCFLAGS:=$(call check_cc,$(HOSTCC),-Wall,)
147HOSTCFLAGS+=$(call check_cc,$(HOSTCC),-Wstrict-prototypes,)
148HOSTCFLAGS+=$(call check_cc,$(HOSTCC),-O2,)
149HOSTCFLAGS+=$(call check_cc,$(HOSTCC),-fomit-frame-pointer,)
150
151LD_WHOLE_ARCHIVE:=$(shell echo "int i;" > conftest.c ; \
152 $(CC) -c -o conftest.o conftest.c ; \
153 echo "int main(void){return 0;}" > conftest_main.c ; \
154 $(CC) -c -o conftest_main.o conftest_main.c ; \
155 $(AR) $(ARFLAGS) conftest.a conftest.o ; \
156 $(CC) -Wl,--whole-archive conftest.a -Wl,--no-whole-archive \
157 conftest_main.o -o conftest > /dev/null 2>&1 \
158 && echo "-Wl,--whole-archive" ; \
159 rm conftest_main.o conftest_main.c conftest.o conftest.c \
160 conftest.a conftest > /dev/null 2>&1 ; )
161ifneq ($(findstring whole-archive,$(LD_WHOLE_ARCHIVE)),)
162LD_NO_WHOLE_ARCHIVE:= -Wl,--no-whole-archive
163endif
164
165LD_START_GROUP:=$(shell echo "int bar(void){return 0;}" > conftest.c ; \
166 $(CC) -c -o conftest.o conftest.c ; \
167 echo "int main(void){return bar();}" > conftest_main.c ; \
168 $(CC) -c -o conftest_main.o conftest_main.c ; \
169 $(AR) $(ARFLAGS) conftest.a conftest.o ; \
170 $(CC) -Wl,--start-group conftest.a conftest_main.o -Wl,--end-group \
171 -o conftest > /dev/null 2>&1 && echo "-Wl,--start-group" ; \
172 echo rm conftest_main.o conftest_main.c conftest.o conftest.c \
173 conftest.a conftest > /dev/null 2>&1 ; )
174ifneq ($(findstring start-group,$(LD_START_GROUP)),)
175LD_END_GROUP:= -Wl,--end-group
176endif
177
178CHECKED_LDFLAGS := $(call check_ld,$(LD),--warn-common,)
179
127# Pin CHECKED_CFLAGS with := so it's only evaluated once. 180# Pin CHECKED_CFLAGS with := so it's only evaluated once.
128CHECKED_CFLAGS:=$(call check_gcc,-funsigned-char,) 181CHECKED_CFLAGS:=$(call check_cc,$(CC),-Wall,)
129CHECKED_CFLAGS+=$(call check_gcc,-mmax-stack-frame=256,) 182CHECKED_CFLAGS+=$(call check_cc,$(CC),-Wstrict-prototypes,)
130CHECKED_CFLAGS+=$(call check_gcc,-fno-builtin-strlen) 183CHECKED_CFLAGS+=$(call check_cc,$(CC),-Wshadow,)
184CHECKED_CFLAGS+=$(call check_cc,$(CC),-funsigned-char,)
185CHECKED_CFLAGS+=$(call check_cc,$(CC),-mmax-stack-frame=256,)
186CHECKED_CFLAGS+=$(call check_cc,$(CC),-fno-builtin-strlen)
131 187
132# Preemptively pin this too. 188# Preemptively pin this too.
133PROG_CFLAGS:= 189PROG_CFLAGS:=
@@ -139,26 +195,26 @@ PROG_CFLAGS:=
139# for OPTIMIZATION... 195# for OPTIMIZATION...
140 196
141# use '-Os' optimization if available, else use -O2 197# use '-Os' optimization if available, else use -O2
142OPTIMIZATION:=$(call check_gcc,-Os,-O2) 198OPTIMIZATION:=$(call check_cc,$(CC),-Os,-O2)
143 199
144ifeq ($(CONFIG_BUILD_AT_ONCE),y) 200ifeq ($(CONFIG_BUILD_AT_ONCE),y)
145# gcc 2.95 exits with 0 for "unrecognized option" 201# gcc 2.95 exits with 0 for "unrecognized option"
146ifeq ($(strip $(shell [ $(CC_MAJOR) -ge 3 ] ; echo $$?)),0) 202ifeq ($(strip $(shell [ $(CC_MAJOR) -ge 3 ] ; echo $$?)),0)
147 CFLAGS_COMBINE:=$(call check_gcc,--combine,) 203 CFLAGS_COMBINE:=$(call check_cc,$(CC),--combine,)
148endif 204endif
149OPTIMIZATION+=$(call check_gcc,-funit-at-a-time,) 205OPTIMIZATION+=$(call check_cc,$(CC),-funit-at-a-time,)
150OPTIMIZATION+=$(call check_gcc,-fgcse-after-reload,) 206OPTIMIZATION+=$(call check_cc,$(CC),-fgcse-after-reload,)
151ifneq ($(CONFIG_BUILD_LIBBUSYBOX),y) 207ifneq ($(CONFIG_BUILD_LIBBUSYBOX),y)
152# http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25795 208# http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25795
153# This prevents us from using -fwhole-program when we build the lib 209# This prevents us from using -fwhole-program when we build the lib
154PROG_CFLAGS+=$(call check_gcc,-fwhole-program,) 210PROG_CFLAGS+=$(call check_cc,$(CC),-fwhole-program,)
155endif # CONFIG_BUILD_LIBBUSYBOX 211endif # CONFIG_BUILD_LIBBUSYBOX
156endif # CONFIG_BUILD_AT_ONCE 212endif # CONFIG_BUILD_AT_ONCE
157 213
158LIB_LDFLAGS:=$(call check_ld,--enable-new-dtags,) 214LIB_LDFLAGS:=$(call check_ld,$(LD),--enable-new-dtags,)
159#LIB_LDFLAGS+=$(call check_ld,--reduce-memory-overheads,) 215#LIB_LDFLAGS+=$(call check_ld,$(LD),--reduce-memory-overheads,)
160#LIB_LDFLAGS+=$(call check_ld,--as-needed,) 216#LIB_LDFLAGS+=$(call check_ld,$(LD),--as-needed,)
161#LIB_LDFLAGS+=$(call check_ld,--warn-shared-textrel,) 217#LIB_LDFLAGS+=$(call check_ld,$(LD),--warn-shared-textrel,)
162 218
163 219
164# Some nice architecture specific optimizations 220# Some nice architecture specific optimizations
@@ -166,25 +222,25 @@ ifeq ($(strip $(TARGET_ARCH)),arm)
166 OPTIMIZATION+=-fstrict-aliasing 222 OPTIMIZATION+=-fstrict-aliasing
167endif 223endif
168ifeq ($(strip $(TARGET_ARCH)),i386) 224ifeq ($(strip $(TARGET_ARCH)),i386)
169 OPTIMIZATION+=$(call check_gcc,-march=i386,) 225 OPTIMIZATION+=$(call check_cc,$(CC),-march=i386,)
170# gcc-4.0 and older seem to benefit from these 226# gcc-4.0 and older seem to benefit from these
171#ifneq ($(strip $(shell [ $(CC_MAJOR) -ge 4 -a $(CC_MINOR) -ge 1 ] ; echo $$?)),0) 227#ifneq ($(strip $(shell [ $(CC_MAJOR) -ge 4 -a $(CC_MINOR) -ge 1 ] ; echo $$?)),0)
172 OPTIMIZATION+=$(call check_gcc,-mpreferred-stack-boundary=2,) 228 OPTIMIZATION+=$(call check_cc,$(CC),-mpreferred-stack-boundary=2,)
173 OPTIMIZATION+=$(call check_gcc,-falign-functions=1 -falign-jumps=1 -falign-loops=1,\ 229 OPTIMIZATION+=$(call check_cc,$(CC),-falign-functions=1 -falign-jumps=1 -falign-loops=1,\
174 -malign-functions=0 -malign-jumps=0 -malign-loops=0) 230 -malign-functions=0 -malign-jumps=0 -malign-loops=0)
175#endif # gcc-4.0 and older 231#endif # gcc-4.0 and older
176 232
177# gcc-4.1 and beyond seem to benefit from these 233# gcc-4.1 and beyond seem to benefit from these
178ifeq ($(strip $(shell [ $(CC_MAJOR) -ge 4 -a $(CC_MINOR) -ge 1 ] ; echo $$?)),0) 234ifeq ($(strip $(shell [ $(CC_MAJOR) -ge 4 -a $(CC_MINOR) -ge 1 ] ; echo $$?)),0)
179 # turn off flags which hurt -Os 235 # turn off flags which hurt -Os
180 OPTIMIZATION+=$(call check_gcc,-fno-tree-loop-optimize,) 236 OPTIMIZATION+=$(call check_cc,$(CC),-fno-tree-loop-optimize,)
181 OPTIMIZATION+=$(call check_gcc,-fno-tree-dominator-opts,) 237 OPTIMIZATION+=$(call check_cc,$(CC),-fno-tree-dominator-opts,)
182 OPTIMIZATION+=$(call check_gcc,-fno-strength-reduce,) 238 OPTIMIZATION+=$(call check_cc,$(CC),-fno-strength-reduce,)
183 239
184 OPTIMIZATION+=$(call check_gcc,-fno-branch-count-reg,) 240 OPTIMIZATION+=$(call check_cc,$(CC),-fno-branch-count-reg,)
185endif # gcc-4.1 and beyond 241endif # gcc-4.1 and beyond
186endif 242endif
187OPTIMIZATION+=$(call check_gcc,-fomit-frame-pointer,) 243OPTIMIZATION+=$(call check_cc,$(CC),-fomit-frame-pointer,)
188 244
189# 245#
190#-------------------------------------------------------- 246#--------------------------------------------------------
@@ -215,7 +271,7 @@ ifeq ($(strip $(CONFIG_DEBUG)),y)
215 CFLAGS +=-g 271 CFLAGS +=-g
216else 272else
217 CFLAGS +=-DNDEBUG 273 CFLAGS +=-DNDEBUG
218 LDFLAGS += $(call check_ld,--sort-common,) 274 CHECKED_LDFLAGS += $(call check_ld,$(LD),--sort-common,)
219endif 275endif
220 276
221ifneq ($(strip $(CONFIG_DEBUG_PESSIMIZE)),y) 277ifneq ($(strip $(CONFIG_DEBUG_PESSIMIZE)),y)
@@ -224,27 +280,26 @@ endif
224 280
225# warn a bit more verbosely for non-release versions 281# warn a bit more verbosely for non-release versions
226ifneq ($(EXTRAVERSION),) 282ifneq ($(EXTRAVERSION),)
227 CHECKED_CFLAGS+=$(call check_gcc,-Wstrict-prototypes,) 283 CHECKED_CFLAGS+=$(call check_cc,$(CC),-Wstrict-prototypes,)
228 CHECKED_CFLAGS+=$(call check_gcc,-Wmissing-prototypes,) 284 CHECKED_CFLAGS+=$(call check_cc,$(CC),-Wmissing-prototypes,)
229 CHECKED_CFLAGS+=$(call check_gcc,-Wmissing-declarations,) 285 CHECKED_CFLAGS+=$(call check_cc,$(CC),-Wmissing-declarations,)
230 CHECKED_CFLAGS+=$(call check_gcc,-Wunused,) 286 CHECKED_CFLAGS+=$(call check_cc,$(CC),-Wunused,)
231 CHECKED_CFLAGS+=$(call check_gcc,-Winit-self,) 287 CHECKED_CFLAGS+=$(call check_cc,$(CC),-Winit-self,)
232 CHECKED_CFLAGS+=$(call check_gcc,-Wshadow,) 288 CHECKED_CFLAGS+=$(call check_cc,$(CC),-Wshadow,)
233 CHECKED_CFLAGS+=$(call check_gcc,-Wcast-align,) 289 CHECKED_CFLAGS+=$(call check_cc,$(CC),-Wcast-align,)
234endif 290endif
235STRIPCMD:=$(STRIP) -s --remove-section=.note --remove-section=.comment 291STRIPCMD:=$(call check_strip,$(STRIP),-s --remove-section=.note --remove-section=.comment,$(STRIP))
236ifeq ($(strip $(CONFIG_STATIC)),y) 292ifeq ($(strip $(CONFIG_STATIC)),y)
237 PROG_CFLAGS += $(call check_gcc,-static,) 293 PROG_CFLAGS += $(call check_cc,$(CC),-static,)
238endif 294endif
239CFLAGS_SHARED := $(call check_gcc,-shared,) 295CFLAGS_SHARED := $(call check_cc,$(CC),-shared,)
240LIB_CFLAGS+=$(CFLAGS_SHARED) 296LIB_CFLAGS+=$(CFLAGS_SHARED)
241 297
242ifeq ($(strip $(CONFIG_BUILD_LIBBUSYBOX)),y) 298ifeq ($(strip $(CONFIG_BUILD_LIBBUSYBOX)),y)
243 CFLAGS_PIC:= $(call check_gcc,-fPIC,) 299 CFLAGS_PIC:= $(call check_cc,$(CC),-fPIC,)
244 LIB_CFLAGS+=$(CFLAGS_PIC) 300 LIB_CFLAGS+=$(CFLAGS_PIC)
245endif 301endif
246 302
247
248ifeq ($(strip $(CONFIG_SELINUX)),y) 303ifeq ($(strip $(CONFIG_SELINUX)),y)
249 LIBRARIES += -lselinux 304 LIBRARIES += -lselinux
250endif 305endif
@@ -253,6 +308,10 @@ ifeq ($(strip $(PREFIX)),)
253 PREFIX:=`pwd`/_install 308 PREFIX:=`pwd`/_install
254endif 309endif
255 310
311#ifneq ($(strip $(CONFIG_GETOPT_LONG)),y)
312# CFLAGS += -D__need_getopt
313#endif
314
256# Additional complications due to support for pristine source dir. 315# Additional complications due to support for pristine source dir.
257# Include files in the build directory should take precedence over 316# Include files in the build directory should take precedence over
258# the copy in top_srcdir, both during the compilation phase and the 317# the copy in top_srcdir, both during the compilation phase and the
@@ -261,7 +320,9 @@ endif
261 320
262 321
263OBJECTS:=$(APPLET_SOURCES:.c=.o) busybox.o usage.o applets.o 322OBJECTS:=$(APPLET_SOURCES:.c=.o) busybox.o usage.o applets.o
264CFLAGS += $(CHECKED_CFLAGS) $(CROSS_CFLAGS) 323CFLAGS += $(CHECKED_CFLAGS) $(CROSS_CFLAGS)
324LDFLAGS += $(CHECKED_LDFLAGS)
325
265ifdef BB_INIT_SCRIPT 326ifdef BB_INIT_SCRIPT
266 CFLAGS += -DINIT_SCRIPT='"$(BB_INIT_SCRIPT)"' 327 CFLAGS += -DINIT_SCRIPT='"$(BB_INIT_SCRIPT)"'
267endif 328endif