diff options
author | Bernhard Reutner-Fischer <rep.dot.nop@gmail.com> | 2006-05-26 13:22:57 +0000 |
---|---|---|
committer | Bernhard Reutner-Fischer <rep.dot.nop@gmail.com> | 2006-05-26 13:22:57 +0000 |
commit | e28d1d6fdc27aa16c2c3a5bbf06cba36798bff5a (patch) | |
tree | a28c70ce8e2dc7cf38c003a1d88c69ebaed3126d | |
parent | 6d0dbeb55017985fa5d476b99427f7bf525e9a14 (diff) | |
download | busybox-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-- | Makefile | 34 | ||||
-rw-r--r-- | Rules.mak | 171 |
2 files changed, 141 insertions, 64 deletions
@@ -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 | #-------------------------------------------------------------- |
11 | noconfig_targets := menuconfig config oldconfig randconfig \ | 11 | noconfig_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 | ||
217 | hosttools: | ||
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 | |||
213 | else # ifneq ($(strip $(HAVE_DOT_CONFIG)),y) | 229 | else # ifneq ($(strip $(HAVE_DOT_CONFIG)),y) |
214 | 230 | ||
215 | all: busybox busybox.links doc | 231 | all: 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 | ||
299 | busybox_unstripped: .depend $(LIBBUSYBOX_SONAME) $(BUSYBOX_SRC) $(APPLET_SRC) $(libraries-y) | 315 | busybox_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 | ||
307 | busybox: busybox_unstripped | 323 | busybox: 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 |
350 | endif | 366 | endif |
351 | check test: busybox | 367 | check 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 |
356 | checkhelp: | 372 | checkhelp: |
@@ -422,7 +438,7 @@ $(USAGE_BIN): $(top_srcdir)/scripts/usage.c | |||
422 | DEP_INCLUDES += include/usage_compressed.h | 438 | DEP_INCLUDES += include/usage_compressed.h |
423 | 439 | ||
424 | include/usage_compressed.h: .config $(USAGE_BIN) | 440 | include/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" > $@ |
426 | endif # CONFIG_FEATURE_COMPRESS_USAGE | 442 | endif # 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: | |||
486 | endif # ifeq ($(skip-makefile),) | 502 | endif # 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 |
@@ -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 |
34 | CROSS =$(subst ",, $(strip $(CROSS_COMPILER_PREFIX))) | 34 | CROSS =$(strip $(subst ",, $(strip $(CROSS_COMPILER_PREFIX)))) |
35 | # be gentle to vi coloring.. ")) | ||
35 | CC = $(CROSS)gcc | 36 | CC = $(CROSS)gcc |
36 | AR = $(CROSS)ar | 37 | AR = $(CROSS)ar |
37 | AS = $(CROSS)as | 38 | AS = $(CROSS)as |
@@ -41,16 +42,13 @@ STRIP = $(CROSS)strip | |||
41 | ELF2FLT = $(CROSS)elf2flt | 42 | ELF2FLT = $(CROSS)elf2flt |
42 | CPP = $(CC) -E | 43 | CPP = $(CC) -E |
43 | SED ?= sed | 44 | SED ?= sed |
45 | BZIP2 ?= 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. |
48 | TARGET_OS=linux | 50 | TARGET_OS=linux |
49 | 51 | ||
50 | # Select the compiler needed to build binaries for your development system | ||
51 | HOSTCC = gcc | ||
52 | HOSTCFLAGS= -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. |
55 | LC_ALL:= C | 53 | LC_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. |
77 | INCS:=-I$(top_builddir)/include -I$(top_srcdir)/include | 75 | INCS:=-I$(top_builddir)/include -I$(top_srcdir)/include |
@@ -79,11 +77,6 @@ CFLAGS=$(INCS) -I$(srcdir) -D_GNU_SOURCE | |||
79 | CFLAGS+=$(CHECKED_CFLAGS) | 77 | CFLAGS+=$(CHECKED_CFLAGS) |
80 | ARFLAGS=cru | 78 | ARFLAGS=cru |
81 | 79 | ||
82 | # Warnings | ||
83 | |||
84 | CFLAGS += -Wall -Wstrict-prototypes -Wshadow | ||
85 | LDFLAGS += $(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 |
89 | CC_MAJOR:=$(shell printf "%02d" $(shell echo __GNUC__ | $(CC) -E -xc - | tail -n 1)) | 82 | CC_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 | #-------------------------------------------------------- |
93 | export VERSION BUILDTIME HOSTCC HOSTCFLAGS CROSS CC AR AS LD NM STRIP CPP | 86 | export VERSION BUILDTIME HOSTCC HOSTCFLAGS CROSS CC AR AS LD NM STRIP CPP |
94 | ifeq ($(strip $(TARGET_ARCH)),) | 87 | ifeq ($(strip $(TARGET_ARCH)),) |
95 | TARGET_ARCH:=$(shell $(CC) -dumpmachine | sed -e s'/-.*//' \ | 88 | TARGET_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'/-.*//' \ | |||
107 | endif | 100 | endif |
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. | ||
111 | ifeq ($(strip $(V)),2) | 105 | ifeq ($(strip $(V)),2) |
112 | VERBOSE_CHECK_GCC=echo check_gcc $(1) >> /dev/stderr; | 106 | VERBOSE_CHECK_CC=echo CC=\"$(1)\" check_cc $(2) >&2; |
113 | endif | 107 | endif |
114 | check_gcc=$(shell \ | 108 | check_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 |
118 | ifeq ($(strip $(V)),2) | ||
119 | VERBOSE_CHECK_LD=echo LD=\"$(1)\" check_ld $(2) >&2; | ||
120 | endif | ||
122 | check_ld=$(shell \ | 121 | check_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 | ||
129 | ifeq ($(strip $(V)),2) | ||
130 | VERBOSE_CHECK_STRIP=echo STRIPCMD=\"$(1)\" check_strip $(2) >&2; | ||
131 | endif | ||
132 | check_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 | ||
145 | HOSTCC = gcc | ||
146 | HOSTCFLAGS:=$(call check_cc,$(HOSTCC),-Wall,) | ||
147 | HOSTCFLAGS+=$(call check_cc,$(HOSTCC),-Wstrict-prototypes,) | ||
148 | HOSTCFLAGS+=$(call check_cc,$(HOSTCC),-O2,) | ||
149 | HOSTCFLAGS+=$(call check_cc,$(HOSTCC),-fomit-frame-pointer,) | ||
150 | |||
151 | LD_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 ; ) | ||
161 | ifneq ($(findstring whole-archive,$(LD_WHOLE_ARCHIVE)),) | ||
162 | LD_NO_WHOLE_ARCHIVE:= -Wl,--no-whole-archive | ||
163 | endif | ||
164 | |||
165 | LD_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 ; ) | ||
174 | ifneq ($(findstring start-group,$(LD_START_GROUP)),) | ||
175 | LD_END_GROUP:= -Wl,--end-group | ||
176 | endif | ||
177 | |||
178 | CHECKED_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. |
128 | CHECKED_CFLAGS:=$(call check_gcc,-funsigned-char,) | 181 | CHECKED_CFLAGS:=$(call check_cc,$(CC),-Wall,) |
129 | CHECKED_CFLAGS+=$(call check_gcc,-mmax-stack-frame=256,) | 182 | CHECKED_CFLAGS+=$(call check_cc,$(CC),-Wstrict-prototypes,) |
130 | CHECKED_CFLAGS+=$(call check_gcc,-fno-builtin-strlen) | 183 | CHECKED_CFLAGS+=$(call check_cc,$(CC),-Wshadow,) |
184 | CHECKED_CFLAGS+=$(call check_cc,$(CC),-funsigned-char,) | ||
185 | CHECKED_CFLAGS+=$(call check_cc,$(CC),-mmax-stack-frame=256,) | ||
186 | CHECKED_CFLAGS+=$(call check_cc,$(CC),-fno-builtin-strlen) | ||
131 | 187 | ||
132 | # Preemptively pin this too. | 188 | # Preemptively pin this too. |
133 | PROG_CFLAGS:= | 189 | PROG_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 |
142 | OPTIMIZATION:=$(call check_gcc,-Os,-O2) | 198 | OPTIMIZATION:=$(call check_cc,$(CC),-Os,-O2) |
143 | 199 | ||
144 | ifeq ($(CONFIG_BUILD_AT_ONCE),y) | 200 | ifeq ($(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" |
146 | ifeq ($(strip $(shell [ $(CC_MAJOR) -ge 3 ] ; echo $$?)),0) | 202 | ifeq ($(strip $(shell [ $(CC_MAJOR) -ge 3 ] ; echo $$?)),0) |
147 | CFLAGS_COMBINE:=$(call check_gcc,--combine,) | 203 | CFLAGS_COMBINE:=$(call check_cc,$(CC),--combine,) |
148 | endif | 204 | endif |
149 | OPTIMIZATION+=$(call check_gcc,-funit-at-a-time,) | 205 | OPTIMIZATION+=$(call check_cc,$(CC),-funit-at-a-time,) |
150 | OPTIMIZATION+=$(call check_gcc,-fgcse-after-reload,) | 206 | OPTIMIZATION+=$(call check_cc,$(CC),-fgcse-after-reload,) |
151 | ifneq ($(CONFIG_BUILD_LIBBUSYBOX),y) | 207 | ifneq ($(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 |
154 | PROG_CFLAGS+=$(call check_gcc,-fwhole-program,) | 210 | PROG_CFLAGS+=$(call check_cc,$(CC),-fwhole-program,) |
155 | endif # CONFIG_BUILD_LIBBUSYBOX | 211 | endif # CONFIG_BUILD_LIBBUSYBOX |
156 | endif # CONFIG_BUILD_AT_ONCE | 212 | endif # CONFIG_BUILD_AT_ONCE |
157 | 213 | ||
158 | LIB_LDFLAGS:=$(call check_ld,--enable-new-dtags,) | 214 | LIB_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 |
167 | endif | 223 | endif |
168 | ifeq ($(strip $(TARGET_ARCH)),i386) | 224 | ifeq ($(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 |
178 | ifeq ($(strip $(shell [ $(CC_MAJOR) -ge 4 -a $(CC_MINOR) -ge 1 ] ; echo $$?)),0) | 234 | ifeq ($(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,) |
185 | endif # gcc-4.1 and beyond | 241 | endif # gcc-4.1 and beyond |
186 | endif | 242 | endif |
187 | OPTIMIZATION+=$(call check_gcc,-fomit-frame-pointer,) | 243 | OPTIMIZATION+=$(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 |
216 | else | 272 | else |
217 | CFLAGS +=-DNDEBUG | 273 | CFLAGS +=-DNDEBUG |
218 | LDFLAGS += $(call check_ld,--sort-common,) | 274 | CHECKED_LDFLAGS += $(call check_ld,$(LD),--sort-common,) |
219 | endif | 275 | endif |
220 | 276 | ||
221 | ifneq ($(strip $(CONFIG_DEBUG_PESSIMIZE)),y) | 277 | ifneq ($(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 |
226 | ifneq ($(EXTRAVERSION),) | 282 | ifneq ($(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,) |
234 | endif | 290 | endif |
235 | STRIPCMD:=$(STRIP) -s --remove-section=.note --remove-section=.comment | 291 | STRIPCMD:=$(call check_strip,$(STRIP),-s --remove-section=.note --remove-section=.comment,$(STRIP)) |
236 | ifeq ($(strip $(CONFIG_STATIC)),y) | 292 | ifeq ($(strip $(CONFIG_STATIC)),y) |
237 | PROG_CFLAGS += $(call check_gcc,-static,) | 293 | PROG_CFLAGS += $(call check_cc,$(CC),-static,) |
238 | endif | 294 | endif |
239 | CFLAGS_SHARED := $(call check_gcc,-shared,) | 295 | CFLAGS_SHARED := $(call check_cc,$(CC),-shared,) |
240 | LIB_CFLAGS+=$(CFLAGS_SHARED) | 296 | LIB_CFLAGS+=$(CFLAGS_SHARED) |
241 | 297 | ||
242 | ifeq ($(strip $(CONFIG_BUILD_LIBBUSYBOX)),y) | 298 | ifeq ($(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) |
245 | endif | 301 | endif |
246 | 302 | ||
247 | |||
248 | ifeq ($(strip $(CONFIG_SELINUX)),y) | 303 | ifeq ($(strip $(CONFIG_SELINUX)),y) |
249 | LIBRARIES += -lselinux | 304 | LIBRARIES += -lselinux |
250 | endif | 305 | endif |
@@ -253,6 +308,10 @@ ifeq ($(strip $(PREFIX)),) | |||
253 | PREFIX:=`pwd`/_install | 308 | PREFIX:=`pwd`/_install |
254 | endif | 309 | endif |
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 | ||
263 | OBJECTS:=$(APPLET_SOURCES:.c=.o) busybox.o usage.o applets.o | 322 | OBJECTS:=$(APPLET_SOURCES:.c=.o) busybox.o usage.o applets.o |
264 | CFLAGS += $(CHECKED_CFLAGS) $(CROSS_CFLAGS) | 323 | CFLAGS += $(CHECKED_CFLAGS) $(CROSS_CFLAGS) |
324 | LDFLAGS += $(CHECKED_LDFLAGS) | ||
325 | |||
265 | ifdef BB_INIT_SCRIPT | 326 | ifdef BB_INIT_SCRIPT |
266 | CFLAGS += -DINIT_SCRIPT='"$(BB_INIT_SCRIPT)"' | 327 | CFLAGS += -DINIT_SCRIPT='"$(BB_INIT_SCRIPT)"' |
267 | endif | 328 | endif |