diff options
Diffstat (limited to 'Makefile')
-rw-r--r-- | Makefile | 347 |
1 files changed, 206 insertions, 141 deletions
@@ -10,16 +10,15 @@ | |||
10 | #-------------------------------------------------------------- | 10 | #-------------------------------------------------------------- |
11 | noconfig_targets := menuconfig config oldconfig randconfig \ | 11 | noconfig_targets := menuconfig config oldconfig randconfig \ |
12 | defconfig allyesconfig allnoconfig allbareconfig \ | 12 | defconfig allyesconfig allnoconfig allbareconfig \ |
13 | clean distclean \ | ||
14 | release tags | 13 | release tags |
15 | 14 | ||
16 | # the toplevel sourcedir | 15 | # the toplevel sourcedir |
17 | ifndef top_srcdir | 16 | ifndef top_srcdir |
18 | top_srcdir=$(CURDIR) | 17 | top_srcdir:=$(shell cd $(dir $(firstword $(MAKEFILE_LIST))) && pwd) |
19 | endif | 18 | endif |
20 | # toplevel directory of the object-tree | 19 | # toplevel directory of the object-tree |
21 | ifndef top_builddir | 20 | ifndef top_builddir |
22 | top_builddir=$(CURDIR) | 21 | top_builddir:=$(CURDIR) |
23 | endif | 22 | endif |
24 | 23 | ||
25 | export srctree=$(top_srcdir) | 24 | export srctree=$(top_srcdir) |
@@ -34,79 +33,102 @@ SRC_DIRS:=$(patsubst %,$(top_srcdir)/%,$(DIRS)) | |||
34 | 33 | ||
35 | # That's our default target when none is given on the command line | 34 | # That's our default target when none is given on the command line |
36 | .PHONY: _all | 35 | .PHONY: _all |
37 | _all: | ||
38 | 36 | ||
39 | CONFIG_CONFIG_IN = $(top_srcdir)/Config.in | 37 | _all: all |
40 | 38 | ||
41 | ifeq ($(KBUILD_SRC),) | 39 | # see if we are in verbose mode |
40 | ifdef VERBOSE | ||
41 | CHECK_VERBOSE := -v | ||
42 | PACKAGE_BE_VERBOSE := $(VERBOSE) | ||
43 | endif | ||
44 | ifdef V | ||
45 | CHECK_VERBOSE := -v | ||
46 | PACKAGE_BE_VERBOSE := $(V) | ||
47 | endif | ||
42 | 48 | ||
43 | ifdef O | 49 | ifdef O |
44 | ifeq ("$(origin O)", "command line") | 50 | ifeq ("$(origin O)", "command line") |
45 | KBUILD_OUTPUT := $(O) | 51 | PACKAGE_OUTPUTDIR := $(shell cd $(O) && pwd) |
46 | top_builddir := $(O) | 52 | top_builddir := $(PACKAGE_OUTPUTDIR) |
47 | endif | 53 | endif |
48 | else | 54 | else |
49 | # If no alternate output-dir was specified, we build in cwd | 55 | # If no alternate output-dir was specified, we build in cwd |
50 | # We are using KBUILD_OUTPUT nevertheless to make sure that we create | 56 | PACKAGE_OUTPUTDIR := $(top_builddir) |
51 | # Rules.mak and the toplevel Makefile, in case they don't exist. | ||
52 | KBUILD_OUTPUT := $(top_builddir) | ||
53 | endif | 57 | endif |
54 | 58 | ||
55 | ifneq ($(strip $(HAVE_DOT_CONFIG)),y) | 59 | ####################################################################### |
56 | # pull in OS specific commands like cp, mkdir, etc. early | 60 | # Try to workaround bugs in make |
61 | |||
62 | # Workaround for bugs in make-3.80 | ||
63 | # eval is broken if it is in a conditional | ||
64 | |||
65 | #$ cat 3.80-eval-in-cond.mak | ||
66 | #all:: ; @echo it | ||
67 | #define Y | ||
68 | # all:: ; @echo worked | ||
69 | #endef | ||
70 | #ifdef BAR | ||
71 | #$(eval $(Y)) | ||
72 | #endif | ||
73 | #$ make -f 3.80-eval-in-cond.mak | ||
74 | #it | ||
75 | #$ make -f 3.80-eval-in-cond.mak BAR=set | ||
76 | #3.80-eval-in-cond.mak:5: *** missing `endif'. Stop. | ||
77 | |||
78 | # This was fixed in December 2003. | ||
79 | define check_gcc | ||
80 | $(eval $(1)+=$(if $(2),$(if $(shell $(CC) $(2) -S -o /dev/null -xc /dev/null > /dev/null 2>&1 && echo y),$(2),$(if $(3),$(3))),$(if $(3),$(3)))) | ||
81 | endef | ||
82 | |||
83 | define check_ld | ||
84 | $(eval $(1)+=$(if $(2),$(if $(shell $(LD) $(2) -o /dev/null -b binary /dev/null > /dev/null 2>&1 && echo y),$(shell echo \-Wl,$(2)),$(if $(3),$(3))),$(if $(3),$(3)))) | ||
85 | endef | ||
86 | |||
87 | ####################################################################### | ||
88 | |||
89 | |||
57 | -include $(top_srcdir)/Rules.mak | 90 | -include $(top_srcdir)/Rules.mak |
58 | endif | ||
59 | 91 | ||
60 | # All object directories. | 92 | # Handle building out of tree |
61 | OBJ_DIRS := $(DIRS) | 93 | ifneq ($(top_builddir),$(top_srcdir)) |
62 | all_tree := $(patsubst %,$(top_builddir)/%,$(OBJ_DIRS) scripts scripts/config include) | 94 | all_tree := $(patsubst %,$(top_builddir)/%,$(DIRS) scripts scripts/config include include/config) |
63 | all_tree: $(all_tree) | ||
64 | $(all_tree): | 95 | $(all_tree): |
65 | @mkdir -p "$@" | 96 | @mkdir -p "$@" |
66 | 97 | ||
67 | ifneq ($(KBUILD_OUTPUT),) | 98 | saved-output := $(PACKAGE_OUTPUTDIR) |
68 | # Invoke a second make in the output directory, passing relevant variables | 99 | |
69 | # Check that the output directory actually exists | 100 | $(if $(wildcard $(PACKAGE_OUTPUTDIR)),, \ |
70 | saved-output := $(KBUILD_OUTPUT) | ||
71 | KBUILD_OUTPUT := $(shell cd $(KBUILD_OUTPUT) && /bin/pwd) | ||
72 | $(if $(wildcard $(KBUILD_OUTPUT)),, \ | ||
73 | $(error output directory "$(saved-output)" does not exist)) | 101 | $(error output directory "$(saved-output)" does not exist)) |
74 | 102 | ||
75 | .PHONY: $(MAKECMDGOALS) | 103 | .PHONY: $(MAKECMDGOALS) |
76 | 104 | ||
77 | $(filter-out _all,$(MAKECMDGOALS)) _all: $(KBUILD_OUTPUT)/Rules.mak $(KBUILD_OUTPUT)/Makefile all_tree | 105 | $(PACKAGE_OUTPUTDIR)/Rules.mak: |
78 | $(Q)$(MAKE) -C $(KBUILD_OUTPUT) \ | ||
79 | top_srcdir=$(top_srcdir) \ | ||
80 | top_builddir=$(top_builddir) \ | ||
81 | KBUILD_SRC=$(top_srcdir) \ | ||
82 | -f $(CURDIR)/Makefile $@ | ||
83 | |||
84 | $(KBUILD_OUTPUT)/Rules.mak: | ||
85 | @echo > $@ | 106 | @echo > $@ |
86 | @echo top_srcdir=$(top_srcdir) >> $@ | 107 | @echo top_srcdir=$(top_srcdir) >> $@ |
87 | @echo top_builddir=$(KBUILD_OUTPUT) >> $@ | 108 | @echo top_builddir=$(PACKAGE_OUTPUTDIR) >> $@ |
88 | @echo include $(top_srcdir)/Rules.mak >> $@ | 109 | @echo include $$\(top_srcdir\)/Rules.mak >> $@ |
89 | 110 | ||
90 | $(KBUILD_OUTPUT)/Makefile: | 111 | $(PACKAGE_OUTPUTDIR)/Makefile: |
91 | @echo > $@ | 112 | @echo > $@ |
92 | @echo top_srcdir=$(top_srcdir) >> $@ | 113 | @echo top_srcdir=$(top_srcdir) >> $@ |
93 | @echo top_builddir=$(KBUILD_OUTPUT) >> $@ | 114 | @echo top_builddir=$(PACKAGE_OUTPUTDIR) >> $@ |
94 | @echo KBUILD_SRC='$$(top_srcdir)' >> $@ | 115 | @echo PACKAGE_SOURCEDIR='$$(top_srcdir)' >> $@ |
95 | @echo include '$$(KBUILD_SRC)'/Makefile >> $@ | 116 | @echo include '$$(PACKAGE_SOURCEDIR)'/Makefile >> $@ |
96 | 117 | ||
97 | # Leave processing to above invocation of make | ||
98 | skip-makefile := 1 | ||
99 | endif # ifneq ($(KBUILD_OUTPUT),) | ||
100 | endif # ifeq ($(KBUILD_SRC),) | ||
101 | 118 | ||
102 | ifeq ($(skip-makefile),) | 119 | buildtree := $(all_tree) $(PACKAGE_OUTPUTDIR)/Rules.mak $(PACKAGE_OUTPUTDIR)/Makefile |
103 | 120 | ||
104 | # We only need a copy of the Makefile for the config targets and reuse | 121 | # We only need a copy of the Makefile for the config targets and reuse |
105 | # the rest from the source directory, i.e. we do not cp ALL_MAKEFILES. | 122 | # the rest from the source directory, i.e. we do not cp ALL_MAKEFILES. |
106 | scripts/config/Makefile: $(top_srcdir)/scripts/config/Makefile | 123 | scripts/config/Makefile: $(top_srcdir)/scripts/config/Makefile | $(buildtree) |
107 | cp $< $@ | 124 | @cp $(top_srcdir)/scripts/config/Makefile $@ |
108 | 125 | ||
109 | _all: all | 126 | else |
127 | all_tree := include/config | ||
128 | $(all_tree): | ||
129 | @mkdir -p "$@" | ||
130 | buildtree := $(all_tree) | ||
131 | endif # ifneq ($(PACKAGE_OUTPUTDIR),$(top_srcdir)) | ||
110 | 132 | ||
111 | help: | 133 | help: |
112 | @echo 'Cleaning:' | 134 | @echo 'Cleaning:' |
@@ -137,37 +159,42 @@ help: | |||
137 | @echo ' release - create a distribution tarball' | 159 | @echo ' release - create a distribution tarball' |
138 | @echo ' sizes - show size of all enabled busybox symbols' | 160 | @echo ' sizes - show size of all enabled busybox symbols' |
139 | @echo | 161 | @echo |
140 | 162 | @echo 'Make flags:' | |
141 | 163 | @echo ' V=<number> - print verbose make output (default: unset)' | |
142 | include $(top_srcdir)/Rules.mak | 164 | @echo ' 0 print CC invocations' |
165 | @echo ' 1' | ||
166 | @echo ' 2 also print when make enters a directory' | ||
167 | @echo ' 3 also verbosely print shell invocations' | ||
143 | 168 | ||
144 | ifneq ($(strip $(HAVE_DOT_CONFIG)),y) | 169 | ifneq ($(strip $(HAVE_DOT_CONFIG)),y) |
145 | |||
146 | # Default target if none was requested explicitly | 170 | # Default target if none was requested explicitly |
147 | all: defconfig menuconfig | 171 | all: defconfig menuconfig ; |
148 | 172 | ||
173 | ifneq ($(filter-out $(noconfig_targets),$(MAKECMDGOALS)),) | ||
149 | # warn if no configuration exists and we are asked to build a non-config target | 174 | # warn if no configuration exists and we are asked to build a non-config target |
150 | .config: | 175 | .config: |
151 | @echo "" | 176 | @echo "" |
152 | @echo "No $(top_builddir)/$@ found!" | 177 | @echo "No $(top_builddir)/$@ found!" |
153 | @echo "Please refer to 'make help', section Configuration." | 178 | @echo "Please refer to 'make help', section Configuration." |
154 | @echo "" | 179 | @echo "" |
155 | @exit 1 | 180 | @exit 1 |
181 | else | ||
182 | # Avoid implicit rule to kick in by using an empty command | ||
183 | .config: $(buildtree) ; | ||
184 | endif | ||
185 | endif # ifneq ($(strip $(HAVE_DOT_CONFIG)),y) | ||
186 | |||
156 | 187 | ||
157 | # configuration | 188 | # configuration |
158 | # --------------------------------------------------------------------------- | 189 | # --------------------------------------------------------------------------- |
159 | 190 | ||
191 | CONFIG_CONFIG_IN = $(top_srcdir)/Config.in | ||
192 | |||
160 | scripts/config/conf: scripts/config/Makefile | 193 | scripts/config/conf: scripts/config/Makefile |
161 | $(Q)$(MAKE) -C scripts/config conf | 194 | $(Q)$(MAKE) -C scripts/config conf |
162 | -@if [ ! -f .config ] ; then \ | ||
163 | touch .config; \ | ||
164 | fi | ||
165 | 195 | ||
166 | scripts/config/mconf: scripts/config/Makefile | 196 | scripts/config/mconf: scripts/config/Makefile |
167 | $(Q)$(MAKE) -C scripts/config ncurses conf mconf | 197 | $(Q)$(MAKE) -C scripts/config ncurses conf mconf |
168 | -@if [ ! -f .config ] ; then \ | ||
169 | touch .config; \ | ||
170 | fi | ||
171 | 198 | ||
172 | menuconfig: scripts/config/mconf | 199 | menuconfig: scripts/config/mconf |
173 | @./scripts/config/mconf $(CONFIG_CONFIG_IN) | 200 | @./scripts/config/mconf $(CONFIG_CONFIG_IN) |
@@ -183,7 +210,7 @@ randconfig: scripts/config/conf | |||
183 | 210 | ||
184 | allyesconfig: scripts/config/conf | 211 | allyesconfig: scripts/config/conf |
185 | @./scripts/config/conf -y $(CONFIG_CONFIG_IN) | 212 | @./scripts/config/conf -y $(CONFIG_CONFIG_IN) |
186 | sed -i -r -e "s/^(USING_CROSS_COMPILER)=.*/# \1 is not set/" .config | 213 | @$(SED) -i -r -e "s/^(USING_CROSS_COMPILER)=.*/# \1 is not set/" .config |
187 | @./scripts/config/conf -o $(CONFIG_CONFIG_IN) | 214 | @./scripts/config/conf -o $(CONFIG_CONFIG_IN) |
188 | 215 | ||
189 | allnoconfig: scripts/config/conf | 216 | allnoconfig: scripts/config/conf |
@@ -195,33 +222,68 @@ allnoconfig: scripts/config/conf | |||
195 | 222 | ||
196 | defconfig: scripts/config/conf | 223 | defconfig: scripts/config/conf |
197 | @./scripts/config/conf -y $(CONFIG_CONFIG_IN) | 224 | @./scripts/config/conf -y $(CONFIG_CONFIG_IN) |
198 | sed -i -r -e "s/^(USING_CROSS_COMPILER|CONFIG_(DEBUG.*|STATIC|SELINUX|BUILD_(AT_ONCE|LIBBUSYBOX)|FEATURE_(DEVFS|FULL_LIBBUSYBOX|SHARED_BUSYBOX|MTAB_SUPPORT|CLEAN_UP|UDHCP_DEBUG)|INSTALL_NO_USR))=.*/# \1 is not set/" .config | 225 | @$(SED) -i -r -e "s/^(USING_CROSS_COMPILER|CONFIG_(DEBUG.*|STATIC|SELINUX|BUILD_(AT_ONCE|LIBBUSYBOX)|FEATURE_(DEVFS|FULL_LIBBUSYBOX|SHARED_BUSYBOX|MTAB_SUPPORT|CLEAN_UP|UDHCP_DEBUG)|INSTALL_NO_USR))=.*/# \1 is not set/" .config |
199 | @./scripts/config/conf -o $(CONFIG_CONFIG_IN) | 226 | @./scripts/config/conf -o $(CONFIG_CONFIG_IN) |
200 | 227 | ||
201 | |||
202 | allbareconfig: scripts/config/conf | 228 | allbareconfig: scripts/config/conf |
203 | @./scripts/config/conf -y $(CONFIG_CONFIG_IN) | 229 | @./scripts/config/conf -y $(CONFIG_CONFIG_IN) |
204 | @sed -i -r -e "s/^(USING_CROSS_COMPILER|CONFIG_(DEBUG|STATIC|SELINUX|DEVFSD|NC_GAPING_SECURITY_HOLE|BUILD_AT_ONCE)).*/# \1 is not set/" .config | 230 | @$(SED) -i -r -e "s/^(USING_CROSS_COMPILER|CONFIG_(DEBUG|STATIC|SELINUX|DEVFSD|NC_GAPING_SECURITY_HOLE|BUILD_AT_ONCE)).*/# \1 is not set/" .config |
205 | @sed -i -e "/FEATURE/s/=.*//;/^[^#]/s/.*FEATURE.*/# \0 is not set/;" .config | 231 | @$(SED) -i -e "/FEATURE/s/=.*//;/^[^#]/s/.*FEATURE.*/# \0 is not set/;" .config |
206 | @echo "CONFIG_FEATURE_BUFFERS_GO_ON_STACK=y" >> .config | 232 | @echo "CONFIG_FEATURE_BUFFERS_GO_ON_STACK=y" >> .config |
207 | @./scripts/config/conf -o $(CONFIG_CONFIG_IN) | 233 | @./scripts/config/conf -o $(CONFIG_CONFIG_IN) |
208 | 234 | ||
209 | else # ifneq ($(strip $(HAVE_DOT_CONFIG)),y) | 235 | ifeq ($(strip $(HAVE_DOT_CONFIG)),y) |
210 | |||
211 | all: busybox busybox.links doc | ||
212 | 236 | ||
213 | # In this section, we need .config | 237 | # Load all Config.in |
214 | -include $(top_builddir)/.config.cmd | 238 | -include $(top_builddir)/.config.cmd |
215 | include $(patsubst %,%/Makefile.in, $(SRC_DIRS)) | ||
216 | 239 | ||
217 | endif # ifneq ($(strip $(HAVE_DOT_CONFIG)),y) | 240 | endif # ifeq ($(strip $(HAVE_DOT_CONFIG)),y) |
241 | |||
242 | # convert $(DIRS) to upper case. Use sed instead of tr since we're already | ||
243 | # depending on it. | ||
244 | DIRS_UPPER:=$(shell echo $(DIRS) | $(SED) 'h;y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/') | ||
245 | |||
246 | # First populate the variables ..._OBJ-y ...OBJ-m et al | ||
247 | $(foreach d,$(DIRS_UPPER),$(eval $(notdir $(d))-y:=)) | ||
248 | $(foreach d,$(DIRS_UPPER),$(eval $(notdir $(d))-m:=)) | ||
249 | |||
250 | include $(patsubst %,%/Makefile.in,$(SRC_DIRS)) | ||
218 | 251 | ||
219 | -include $(top_builddir)/.config | 252 | # Then we need the dependencies for ..._OBJ |
253 | define dir_pattern.o | ||
254 | ifeq ($(os),.os) | ||
255 | # write patterns for both .os and .o | ||
256 | $(if $($(1)_OBJ.os),$($(1)_OBJ.os:.os=.o): $(top_builddir)/$(2)/%.o: $(top_srcdir)/$(2)/%.c) | ||
257 | endif | ||
258 | $(if $($(1)_OBJ$(os)),$($(1)_OBJ$(os)): $(top_builddir)/$(2)/%$(os): $(top_srcdir)/$(2)/%.c) | ||
259 | $(if $($(1)_OBJ),$($(1)_OBJ): $(top_builddir)/$(2)/%.o: $(top_srcdir)/$(2)/%.c) | ||
260 | |||
261 | lib-obj-y+=$($(1)_OBJ) $($(1)_OBJ.o) $($(1)_OBJ.os) | ||
262 | lib-mobj-y+=$($(1)_MOBJ.o) $($(1)_MOBJ.os) | ||
263 | bin-obj-y+=$($(1)_OBJ:.os=.o) $($(1)_OBJ.o:.os=.o) $($(1)_OBJ.os:.os=.o) | ||
264 | bin-mobj-y+=$($(1)_MOBJ.o:.osm=.om) $($(1)_MOBJ.os:.osm=.om) | ||
265 | endef | ||
266 | # The actual directory patterns for .o* | ||
267 | $(foreach d,$(DIRS),$(eval $(call dir_pattern.o,$(subst /,_,$(d)),$(d)))) | ||
268 | |||
269 | ifeq ($(strip $(HAVE_DOT_CONFIG)),y) | ||
270 | # Finally pull in the dependencies (headers and other includes) of the | ||
271 | # individual object files | ||
220 | -include $(top_builddir)/.depend | 272 | -include $(top_builddir)/.depend |
221 | 273 | ||
222 | 274 | ||
275 | # Everything is set. | ||
276 | |||
277 | all: busybox busybox.links doc ; | ||
278 | |||
279 | # Two modes of operation: legacy and IMA | ||
280 | # Legacy mode builds each object through an individual invocation of CC | ||
281 | # IMA compiles all sources at once (aka IPO aka IPA etc.) | ||
282 | |||
223 | ifeq ($(strip $(CONFIG_BUILD_AT_ONCE)),y) | 283 | ifeq ($(strip $(CONFIG_BUILD_AT_ONCE)),y) |
224 | libraries-y:= | 284 | # We are not building .o |
285 | bin-obj-y:= | ||
286 | bin-mobj-y:= | ||
225 | # Which parts of the internal libs are requested? | 287 | # Which parts of the internal libs are requested? |
226 | # Per default we only want what was actually selected. | 288 | # Per default we only want what was actually selected. |
227 | # -a denotes all while -y denotes the selected ones. | 289 | # -a denotes all while -y denotes the selected ones. |
@@ -237,19 +299,26 @@ APPLETS_DEFINE:=$(APPLETS_DEFINE-y) | |||
237 | else # CONFIG_BUILD_AT_ONCE | 299 | else # CONFIG_BUILD_AT_ONCE |
238 | # no --combine, build archives out of the individual .o | 300 | # no --combine, build archives out of the individual .o |
239 | # This was the old way the binary was built. | 301 | # This was the old way the binary was built. |
240 | libbusybox-obj:=archival/libunarchive/libunarchive.a \ | 302 | libbusybox-obj:=$(archival_libunarchive_OBJ$(os)) \ |
241 | networking/libiproute/libiproute.a \ | 303 | $(networking_libiproute_OBJ$(os)) \ |
242 | libpwdgrp/libpwdgrp.a \ | 304 | $(libpwdgrp_MOBJ$(os)) \ |
243 | coreutils/libcoreutils/libcoreutils.a \ | 305 | $(coreutils_libcoreutils_OBJ$(os)) \ |
244 | libbb/libbb.a | 306 | $(libbb_OBJ$(os)) $(libbb_MOBJ$(os)) |
245 | libbusybox-obj:=$(patsubst %,$(top_builddir)/%,$(libbusybox-obj)) | ||
246 | 307 | ||
247 | ifeq ($(strip $(CONFIG_FEATURE_SHARED_BUSYBOX)),y) | 308 | ifeq ($(strip $(CONFIG_FEATURE_SHARED_BUSYBOX)),y) |
248 | # linking against libbusybox, so don't build the .a already contained in the .so | 309 | # linking against libbusybox, so don't build the .o already contained in the .so |
249 | libraries-y:=$(filter-out $(libbusybox-obj),$(libraries-y)) | 310 | bin-obj-y:=$(filter-out $(libbusybox-obj) $(libbusybox-obj:.os=.o),$(bin-obj-y)) |
311 | bin-mobj-y:=$(filter-out $(libbusybox-obj) $(libbusybox-obj:.osm=.om),$(bin-mobj-y)) | ||
250 | endif # CONFIG_FEATURE_SHARED_BUSYBOX | 312 | endif # CONFIG_FEATURE_SHARED_BUSYBOX |
251 | endif # CONFIG_BUILD_AT_ONCE | 313 | endif # CONFIG_BUILD_AT_ONCE |
252 | 314 | ||
315 | # build an .a to keep .hash et al small | ||
316 | $(if $(bin-obj-y)$(bin-mobj-y),$(eval applets.a:=$(bin-obj-y) $(bin-mobj-y))) | ||
317 | ifdef applets.a | ||
318 | applets.a: $(applets.a) | ||
319 | $(do_ar) | ||
320 | bin-obj.a=applets.a | ||
321 | endif | ||
253 | 322 | ||
254 | ifeq ($(strip $(CONFIG_BUILD_LIBBUSYBOX)),y) | 323 | ifeq ($(strip $(CONFIG_BUILD_LIBBUSYBOX)),y) |
255 | LD_LIBBUSYBOX:=libbusybox.so | 324 | LD_LIBBUSYBOX:=libbusybox.so |
@@ -258,9 +327,11 @@ DO_INSTALL_LIBS:=$(LD_LIBBUSYBOX) \ | |||
258 | $(LD_LIBBUSYBOX).$(MAJOR_VERSION) \ | 327 | $(LD_LIBBUSYBOX).$(MAJOR_VERSION) \ |
259 | $(LD_LIBBUSYBOX).$(MAJOR_VERSION).$(MINOR_VERSION) | 328 | $(LD_LIBBUSYBOX).$(MAJOR_VERSION).$(MINOR_VERSION) |
260 | 329 | ||
330 | endif # CONFIG_BUILD_LIBBUSYBOX | ||
331 | |||
261 | ifeq ($(strip $(CONFIG_BUILD_AT_ONCE)),y) | 332 | ifeq ($(strip $(CONFIG_BUILD_AT_ONCE)),y) |
262 | ifneq ($(strip $(CONFIG_FEATURE_SHARED_BUSYBOX)),y) | 333 | ifneq ($(strip $(CONFIG_FEATURE_SHARED_BUSYBOX)),y) |
263 | # --combine but not linking against libbusybox, so compile all | 334 | # --combine but not linking against libbusybox, so compile lib*.c |
264 | BUSYBOX_SRC := $(LIBRARY_SRC) | 335 | BUSYBOX_SRC := $(LIBRARY_SRC) |
265 | BUSYBOX_DEFINE:= $(LIBRARY_DEFINE) | 336 | BUSYBOX_DEFINE:= $(LIBRARY_DEFINE) |
266 | endif # !CONFIG_FEATURE_SHARED_BUSYBOX | 337 | endif # !CONFIG_FEATURE_SHARED_BUSYBOX |
@@ -268,7 +339,7 @@ $(LIBBUSYBOX_SONAME): $(LIBRARY_SRC) | |||
268 | else # CONFIG_BUILD_AT_ONCE | 339 | else # CONFIG_BUILD_AT_ONCE |
269 | $(LIBBUSYBOX_SONAME): $(libbusybox-obj) | 340 | $(LIBBUSYBOX_SONAME): $(libbusybox-obj) |
270 | endif # CONFIG_BUILD_AT_ONCE | 341 | endif # CONFIG_BUILD_AT_ONCE |
271 | endif # CONFIG_BUILD_LIBBUSYBOX | 342 | |
272 | 343 | ||
273 | ifeq ($(strip $(CONFIG_FEATURE_SHARED_BUSYBOX)),y) | 344 | ifeq ($(strip $(CONFIG_FEATURE_SHARED_BUSYBOX)),y) |
274 | LDBUSYBOX:=-L$(top_builddir) -lbusybox | 345 | LDBUSYBOX:=-L$(top_builddir) -lbusybox |
@@ -279,24 +350,27 @@ $(LIBBUSYBOX_SONAME): | |||
279 | ifndef MAJOR_VERSION | 350 | ifndef MAJOR_VERSION |
280 | $(error MAJOR_VERSION needed for $@ is not defined) | 351 | $(error MAJOR_VERSION needed for $@ is not defined) |
281 | endif | 352 | endif |
282 | $(do_link) $(LIB_CFLAGS) $(LIB_LDFLAGS) \ | 353 | $(do_link) $(LIB_CFLAGS) $(LIB_LDFLAGS) $(CFLAGS_COMBINE) \ |
283 | -Wl,-soname=$(LD_LIBBUSYBOX).$(MAJOR_VERSION) \ | 354 | -Wl,-soname=$(LD_LIBBUSYBOX).$(MAJOR_VERSION) \ |
284 | -Wl,-z,combreloc $(LIB_LDFLAGS) \ | 355 | -Wl,-z,combreloc $(LIB_LDFLAGS) \ |
285 | -o $(@) \ | 356 | -o $(@) \ |
286 | -Wl,--start-group -Wl,--whole-archive \ | 357 | -Wl,--start-group \ |
287 | $(LIBRARY_DEFINE) $(^) \ | 358 | $(LIBRARY_DEFINE) $(^) \ |
288 | -Wl,--no-whole-archive -Wl,--end-group | 359 | -Wl,--end-group |
289 | $(RM_F) $(DO_INSTALL_LIBS) | 360 | @rm -f $(DO_INSTALL_LIBS) |
290 | for i in $(DO_INSTALL_LIBS); do $(LN_S) -v $(@) $$i ; done | 361 | @for i in $(DO_INSTALL_LIBS); do ln -s $(@) $$i ; done |
291 | $(do_strip) | 362 | $(do_strip) |
292 | 363 | ||
293 | endif # ifeq ($(strip $(CONFIG_BUILD_LIBBUSYBOX)),y) | 364 | endif # ifeq ($(strip $(CONFIG_BUILD_LIBBUSYBOX)),y) |
294 | 365 | ||
295 | busybox: .depend $(LIBBUSYBOX_SONAME) $(BUSYBOX_SRC) $(libraries-y) | 366 | busybox: $(top_builddir)/.depend $(LIBBUSYBOX_SONAME) $(BUSYBOX_SRC) $(APPLET_SRC) $(bin-obj.a) |
296 | $(do_link) $(PROG_CFLAGS) \ | 367 | $(do_link) $(PROG_CFLAGS) $(PROG_LDFLAGS) $(CFLAGS_COMBINE) \ |
297 | -o $@ -Wl,--start-group \ | 368 | $(foreach f,$(^:.o=.c),$(CFLAGS-$(notdir $(patsubst %/$,%,$(dir $(f))))-$(notdir $(f)))) \ |
369 | $(CFLAGS-$(@)) \ | ||
370 | -o $@ -Wl,--start-group \ | ||
298 | $(APPLETS_DEFINE) $(APPLET_SRC) \ | 371 | $(APPLETS_DEFINE) $(APPLET_SRC) \ |
299 | $(BUSYBOX_DEFINE) $(BUSYBOX_SRC) $(libraries-y) \ | 372 | $(BUSYBOX_DEFINE) $(BUSYBOX_SRC) \ |
373 | $(bin-obj.a) \ | ||
300 | $(LDBUSYBOX) $(LIBRARIES) \ | 374 | $(LDBUSYBOX) $(LIBRARIES) \ |
301 | -Wl,--end-group | 375 | -Wl,--end-group |
302 | $(do_strip) | 376 | $(do_strip) |
@@ -305,7 +379,7 @@ busybox.links: $(top_srcdir)/applets/busybox.mkll include/bb_config.h $(top_srcd | |||
305 | $(Q)-$(SHELL) $^ >$@ | 379 | $(Q)-$(SHELL) $^ >$@ |
306 | 380 | ||
307 | install: $(top_srcdir)/applets/install.sh busybox busybox.links | 381 | install: $(top_srcdir)/applets/install.sh busybox busybox.links |
308 | DO_INSTALL_LIBS="$(strip $(LIBBUSYBOX_SONAME) $(DO_INSTALL_LIBS))" \ | 382 | $(Q)DO_INSTALL_LIBS="$(strip $(LIBBUSYBOX_SONAME) $(DO_INSTALL_LIBS))" \ |
309 | $(SHELL) $< $(PREFIX) $(INSTALL_OPTS) | 383 | $(SHELL) $< $(PREFIX) $(INSTALL_OPTS) |
310 | ifeq ($(strip $(CONFIG_FEATURE_SUID)),y) | 384 | ifeq ($(strip $(CONFIG_FEATURE_SUID)),y) |
311 | @echo | 385 | @echo |
@@ -319,44 +393,33 @@ ifeq ($(strip $(CONFIG_FEATURE_SUID)),y) | |||
319 | endif | 393 | endif |
320 | 394 | ||
321 | uninstall: busybox.links | 395 | uninstall: busybox.links |
322 | $(RM_F) $(PREFIX)/bin/busybox | 396 | rm -f $(PREFIX)/bin/busybox |
323 | for i in `cat busybox.links` ; do $(RM_F) $(PREFIX)$$i; done | 397 | for i in `cat busybox.links` ; do rm -f $(PREFIX)$$i; done |
324 | ifneq ($(strip $(DO_INSTALL_LIBS)),n) | 398 | ifneq ($(strip $(DO_INSTALL_LIBS)),n) |
325 | for i in $(LIBBUSYBOX_SONAME) $(DO_INSTALL_LIBS); do \ | 399 | for i in $(LIBBUSYBOX_SONAME) $(DO_INSTALL_LIBS); do \ |
326 | $(RM_F) $(PREFIX)$$i; \ | 400 | rm -f $(PREFIX)$$i; \ |
327 | done | 401 | done |
328 | endif | 402 | endif |
329 | 403 | ||
330 | # see if we are in verbose mode | ||
331 | KBUILD_VERBOSE := | ||
332 | ifdef V | ||
333 | ifeq ("$(origin V)", "command line") | ||
334 | KBUILD_VERBOSE := $(V) | ||
335 | endif | ||
336 | endif | ||
337 | ifneq ($(strip $(KBUILD_VERBOSE)),) | ||
338 | CHECK_VERBOSE := -v | ||
339 | # ARFLAGS+=v | ||
340 | endif | ||
341 | check test: busybox | 404 | check test: busybox |
342 | bindir=$(top_builddir) srcdir=$(top_srcdir)/testsuite \ | 405 | bindir=$(top_builddir) srcdir=$(top_srcdir)/testsuite \ |
343 | $(top_srcdir)/testsuite/runtest $(CHECK_VERBOSE) | 406 | $(top_srcdir)/testsuite/runtest $(CHECK_VERBOSE) |
344 | 407 | ||
345 | sizes: | 408 | sizes: |
346 | -$(RM_F) busybox | 409 | -rm -f busybox |
347 | $(MAKE) top_srcdir=$(top_srcdir) top_builddir=$(top_builddir) \ | 410 | $(MAKE) top_srcdir=$(top_srcdir) top_builddir=$(top_builddir) \ |
348 | -f $(top_srcdir)/Makefile STRIPCMD=/bin/true | 411 | -f $(top_srcdir)/Makefile STRIPCMD=/bin/true |
349 | $(NM) --size-sort busybox | 412 | $(NM) --size-sort busybox |
350 | 413 | ||
351 | # Documentation Targets | 414 | # Documentation Targets |
352 | doc: docs/busybox.pod docs/BusyBox.txt docs/BusyBox.1 docs/BusyBox.html | 415 | doc: docs/busybox.pod docs/BusyBox.txt docs/BusyBox.1 docs/BusyBox.html ; |
353 | 416 | ||
354 | docs/busybox.pod : $(top_srcdir)/docs/busybox_header.pod $(top_srcdir)/include/usage.h $(top_srcdir)/docs/busybox_footer.pod $(top_srcdir)/docs/autodocifier.pl | 417 | docs/busybox.pod : $(top_srcdir)/docs/busybox_header.pod $(top_srcdir)/include/usage.h $(top_srcdir)/docs/busybox_footer.pod $(top_srcdir)/docs/autodocifier.pl |
355 | $(disp_doc) | 418 | $(disp_doc) |
356 | $(Q)-mkdir -p docs | 419 | $(Q)-mkdir -p docs |
357 | $(Q)-( cat $(top_srcdir)/docs/busybox_header.pod; \ | 420 | $(Q)-( cat $(top_srcdir)/docs/busybox_header.pod ; \ |
358 | $(top_srcdir)/docs/autodocifier.pl $(top_srcdir)/include/usage.h; \ | 421 | $(top_srcdir)/docs/autodocifier.pl $(top_srcdir)/include/usage.h ; \ |
359 | cat $(top_srcdir)/docs/busybox_footer.pod ) > docs/busybox.pod | 422 | cat $(top_srcdir)/docs/busybox_footer.pod ; ) > docs/busybox.pod |
360 | 423 | ||
361 | docs/BusyBox.txt: docs/busybox.pod | 424 | docs/BusyBox.txt: docs/busybox.pod |
362 | $(disp_doc) | 425 | $(disp_doc) |
@@ -372,18 +435,18 @@ docs/BusyBox.1: docs/busybox.pod | |||
372 | docs/BusyBox.html: docs/busybox.net/BusyBox.html | 435 | docs/BusyBox.html: docs/busybox.net/BusyBox.html |
373 | $(disp_doc) | 436 | $(disp_doc) |
374 | $(Q)-mkdir -p docs | 437 | $(Q)-mkdir -p docs |
375 | $(Q)-$(RM_F) docs/BusyBox.html | 438 | $(Q)-rm -f docs/BusyBox.html |
376 | $(Q)-cp docs/busybox.net/BusyBox.html docs/BusyBox.html | 439 | $(Q)-cp docs/busybox.net/BusyBox.html docs/BusyBox.html |
377 | 440 | ||
378 | docs/busybox.net/BusyBox.html: docs/busybox.pod | 441 | docs/busybox.net/BusyBox.html: docs/busybox.pod |
379 | $(Q)-mkdir -p docs/busybox.net | 442 | $(Q)-mkdir -p docs/busybox.net |
380 | $(Q)-pod2html --noindex $< > \ | 443 | $(Q)-pod2html --noindex $< > \ |
381 | docs/busybox.net/BusyBox.html | 444 | docs/busybox.net/BusyBox.html |
382 | $(Q)-$(RM_F) pod2htm* | 445 | $(Q)-rm -f pod2htm* |
383 | 446 | ||
384 | # The nifty new buildsystem stuff | 447 | # The nifty new dependency stuff |
385 | scripts/bb_mkdep: $(top_srcdir)/scripts/bb_mkdep.c | 448 | scripts/bb_mkdep: $(top_srcdir)/scripts/bb_mkdep.c |
386 | $(Q)$(HOSTCC) $(HOSTCFLAGS) -o $@ $< | 449 | $(do_link.h) |
387 | 450 | ||
388 | DEP_INCLUDES := include/bb_config.h | 451 | DEP_INCLUDES := include/bb_config.h |
389 | 452 | ||
@@ -395,63 +458,65 @@ include/bbconfigopts.h: .config | |||
395 | $(Q)$(top_srcdir)/scripts/config/mkconfigs > $@ | 458 | $(Q)$(top_srcdir)/scripts/config/mkconfigs > $@ |
396 | endif | 459 | endif |
397 | 460 | ||
398 | depend dep: .depend | 461 | depend dep: $(top_builddir)/.depend ; |
399 | .depend: scripts/bb_mkdep $(DEP_INCLUDES) | 462 | $(top_builddir)/.depend: $(buildtree) scripts/bb_mkdep $(DEP_INCLUDES) |
400 | $(disp_gen) | 463 | $(disp_gen) |
401 | $(Q)$(RM_F) .depend | 464 | $(Q)rm -f .depend |
402 | $(Q)mkdir -p include/config | 465 | $(Q)scripts/bb_mkdep $(MKDEP_ARGS) \ |
403 | $(Q)scripts/bb_mkdep -I $(top_srcdir)/include $(top_srcdir) > $@.tmp | 466 | -I $(top_srcdir)/include $(top_srcdir) > $@.tmp |
404 | $(Q)mv $@.tmp $@ | 467 | $(Q)mv $@.tmp $@ |
405 | 468 | ||
406 | include/bb_config.h: .config | 469 | include/bb_config.h: .config |
407 | @if [ ! -x $(top_builddir)/scripts/config/conf ] ; then \ | 470 | $(disp_gen) |
408 | $(MAKE) -C scripts/config conf; \ | ||
409 | fi; | ||
410 | @$(top_builddir)/scripts/config/conf -o $(CONFIG_CONFIG_IN) | 471 | @$(top_builddir)/scripts/config/conf -o $(CONFIG_CONFIG_IN) |
411 | 472 | ||
473 | endif # ifeq ($(strip $(HAVE_DOT_CONFIG)),y) | ||
474 | |||
412 | clean: | 475 | clean: |
413 | - $(MAKE) -C scripts/config $@ | 476 | - rm -f docs/busybox.dvi docs/busybox.ps \ |
414 | - $(RM_F) docs/busybox.dvi docs/busybox.ps \ | ||
415 | docs/busybox.pod docs/busybox.net/busybox.html \ | 477 | docs/busybox.pod docs/busybox.net/busybox.html \ |
416 | docs/busybox pod2htm* *.gdb *.elf *~ core .*config.log \ | 478 | docs/busybox pod2htm* *.gdb *.elf *~ core .*config.log \ |
417 | docs/BusyBox.txt docs/BusyBox.1 docs/BusyBox.html \ | 479 | docs/BusyBox.txt docs/BusyBox.1 docs/BusyBox.html \ |
418 | docs/busybox.net/BusyBox.html busybox.links \ | 480 | docs/busybox.net/BusyBox.html busybox.links \ |
419 | $(DO_INSTALL_LIBS) $(LIBBUSYBOX_SONAME) \ | 481 | $(DO_INSTALL_LIBS) $(LIBBUSYBOX_SONAME) \ |
420 | .config.old busybox | 482 | .config.old busybox |
421 | - rm -rf _install testsuite/links | 483 | - rm -r -f _install testsuite/links |
422 | - find . -name .\*.flags -exec $(RM_F) {} \; | 484 | - find . -name .\*.flags -exec rm -f {} \; |
423 | - find . -name \*.o -exec $(RM_F) {} \; | 485 | - find . -name \*.o -exec rm -f {} \; |
424 | - find . -name \*.a -exec $(RM_F) {} \; | 486 | - find . -name \*.om -exec rm -f {} \; |
425 | - find . -name \*.so -exec $(RM_F) {} \; | 487 | - find . -name \*.os -exec rm -f {} \; |
488 | - find . -name \*.a -exec rm -f {} \; | ||
426 | 489 | ||
427 | distclean: clean | 490 | distclean: clean |
428 | - $(RM_F) scripts/bb_mkdep | 491 | - $(MAKE) -C scripts/config clean |
429 | - rm -rf include/config $(DEP_INCLUDES) | 492 | - rm -f scripts/bb_mkdep |
430 | - find . -name .depend'*' -exec $(RM_F) {} \; | 493 | - rm -r -f include/config $(DEP_INCLUDES) |
431 | $(RM_F) .config .config.old .config.cmd | 494 | - find . -name .depend'*' -exec rm -f {} \; |
495 | rm -f .config .config.old .config.cmd | ||
432 | 496 | ||
433 | release: distclean #doc | 497 | release: distclean #doc |
434 | cd ..; \ | 498 | cd ..; \ |
435 | rm -rf $(PROG)-$(VERSION); \ | 499 | rm -r -f $(PROG)-$(VERSION); \ |
436 | cp -a busybox $(PROG)-$(VERSION); \ | 500 | cp -a busybox $(PROG)-$(VERSION); \ |
437 | \ | 501 | \ |
438 | find $(PROG)-$(VERSION)/ -type d \ | 502 | find $(PROG)-$(VERSION)/ -type d \ |
439 | -name .svn \ | 503 | -name .svn \ |
440 | -print \ | 504 | -print \ |
441 | -exec rm -rf {} \; ; \ | 505 | -exec rm -r -f {} \; ; \ |
442 | \ | 506 | \ |
443 | find $(PROG)-$(VERSION)/ -type f \ | 507 | find $(PROG)-$(VERSION)/ -type f \ |
444 | -name .\#* \ | 508 | -name .\#* \ |
445 | -print \ | 509 | -print \ |
446 | -exec $(RM_F) {} \; ; \ | 510 | -exec rm -f {} \; ; \ |
447 | \ | 511 | \ |
448 | tar -cvzf $(PROG)-$(VERSION).tar.gz $(PROG)-$(VERSION)/; | 512 | tar -cvzf $(PROG)-$(VERSION).tar.gz $(PROG)-$(VERSION)/; |
449 | 513 | ||
450 | tags: | 514 | tags: |
451 | ctags -R . | 515 | ctags -R . |
452 | 516 | ||
453 | 517 | # keep these in sync with noconfig_targets above! | |
454 | endif # ifeq ($(skip-makefile),) | 518 | .PHONY: dummy subdirs check test depend dep buildtree \ |
455 | 519 | menuconfig config oldconfig randconfig \ | |
456 | .PHONY: dummy subdirs release distclean clean config oldconfig \ | 520 | defconfig allyesconfig allnoconfig allbareconfig \ |
457 | menuconfig tags check test depend dep buildtree | 521 | clean distclean \ |
522 | release tags | ||