diff options
Diffstat (limited to 'Makefile')
-rw-r--r-- | Makefile | 122 |
1 files changed, 33 insertions, 89 deletions
@@ -13,15 +13,16 @@ noconfig_targets := menuconfig config oldconfig randconfig \ | |||
13 | clean distclean \ | 13 | clean distclean \ |
14 | release tags | 14 | release tags |
15 | 15 | ||
16 | # make-3.79.1 didn't support MAKEFILE_LIST | ||
17 | # for building out-of-tree, users of make-3.79 still have to pass top_srcdir= | ||
18 | # to make: make -f /srcs/busybox/Makefile top_srcdir=/srcs/busybox | ||
19 | ifndef MAKEFILE_LIST | ||
20 | MAKEFILE_LIST=. | ||
21 | endif | ||
22 | # the toplevel sourcedir | 16 | # the toplevel sourcedir |
23 | ifndef top_srcdir | 17 | ifndef top_srcdir |
18 | # make-3.79.1 didn't support MAKEFILE_LIST | ||
19 | # for building out-of-tree, users of make-3.79.1 still have to pass top_srcdir= | ||
20 | # to make: make -f /srcs/busybox/Makefile top_srcdir=/srcs/busybox | ||
21 | ifdef MAKEFILE_LIST | ||
24 | top_srcdir:=$(shell cd $(dir $(firstword $(MAKEFILE_LIST))) && pwd) | 22 | top_srcdir:=$(shell cd $(dir $(firstword $(MAKEFILE_LIST))) && pwd) |
23 | else | ||
24 | top_srcdir:=$(CURDIR) | ||
25 | endif | ||
25 | endif | 26 | endif |
26 | # toplevel directory of the object-tree | 27 | # toplevel directory of the object-tree |
27 | ifndef top_builddir | 28 | ifndef top_builddir |
@@ -63,44 +64,22 @@ else | |||
63 | PACKAGE_OUTPUTDIR := $(top_builddir) | 64 | PACKAGE_OUTPUTDIR := $(top_builddir) |
64 | endif | 65 | endif |
65 | 66 | ||
66 | ####################################################################### | ||
67 | # Try to workaround bugs in make | ||
68 | |||
69 | # make-3.79.1 didn't understand order-only prerequisites ('|'). | ||
70 | # Just treat them as normal prerequisites. Note that this will lead to | ||
71 | # spurious rebuilds. | ||
72 | ifeq ($(MAKE_VERSION),3.79.1) | ||
73 | |: ; | ||
74 | endif | ||
75 | |||
76 | # Workaround for bugs in make-3.80 | ||
77 | # eval is broken if it is in a conditional | ||
78 | |||
79 | #$ cat 3.80-eval-in-cond.mak | ||
80 | #all:: ; @echo it | ||
81 | #define Y | ||
82 | # all:: ; @echo worked | ||
83 | #endef | ||
84 | #ifdef BAR | ||
85 | #$(eval $(Y)) | ||
86 | #endif | ||
87 | #$ make -f 3.80-eval-in-cond.mak | ||
88 | #it | ||
89 | #$ make -f 3.80-eval-in-cond.mak BAR=set | ||
90 | #3.80-eval-in-cond.mak:5: *** missing `endif'. Stop. | ||
91 | |||
92 | # This was fixed in December 2003. | ||
93 | define check_gcc | 67 | define check_gcc |
94 | $(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)))) | 68 | $(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))) |
95 | endef | 69 | endef |
96 | 70 | ||
97 | define check_ld | 71 | define check_ld |
98 | $(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)))) | 72 | $(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))) |
99 | endef | 73 | endef |
100 | 74 | ||
101 | ####################################################################### | 75 | ####################################################################### |
76 | # make-3.79.1 doesn't support order-only prerequisites.. | ||
77 | ifeq ($(MAKE_VERSION),3.79.1) | ||
78 | |: $(^) ; | ||
79 | endif | ||
80 | ####################################################################### | ||
81 | |||
102 | 82 | ||
103 | -include $(top_srcdir)/Rules.mak | ||
104 | 83 | ||
105 | # Handle building out of tree | 84 | # Handle building out of tree |
106 | ifneq ($(top_builddir),$(top_srcdir)) | 85 | ifneq ($(top_builddir),$(top_srcdir)) |
@@ -179,6 +158,8 @@ help: | |||
179 | @echo ' 2 also print when make enters a directory' | 158 | @echo ' 2 also print when make enters a directory' |
180 | @echo ' 3 also verbosely print shell invocations' | 159 | @echo ' 3 also verbosely print shell invocations' |
181 | 160 | ||
161 | -include $(top_srcdir)/Rules.mak | ||
162 | |||
182 | ifneq ($(strip $(HAVE_DOT_CONFIG)),y) | 163 | ifneq ($(strip $(HAVE_DOT_CONFIG)),y) |
183 | # Default target if none was requested explicitly | 164 | # Default target if none was requested explicitly |
184 | all: defconfig menuconfig ; | 165 | all: defconfig menuconfig ; |
@@ -252,33 +233,8 @@ ifeq ($(strip $(HAVE_DOT_CONFIG)),y) | |||
252 | 233 | ||
253 | endif # ifeq ($(strip $(HAVE_DOT_CONFIG)),y) | 234 | endif # ifeq ($(strip $(HAVE_DOT_CONFIG)),y) |
254 | 235 | ||
255 | # convert $(DIRS) to upper case. Use sed instead of tr since we're already | ||
256 | # depending on it. | ||
257 | DIRS_UPPER:=$(shell echo $(DIRS) | $(SED) 'h;y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/') | ||
258 | |||
259 | # First populate the variables ..._OBJ-y et al | ||
260 | $(foreach d,$(DIRS_UPPER),$(eval $(notdir $(d))-y:=)) | ||
261 | |||
262 | include $(patsubst %,%/Makefile.in,$(SRC_DIRS)) | 236 | include $(patsubst %,%/Makefile.in,$(SRC_DIRS)) |
263 | 237 | ||
264 | # Then we need the dependencies for ..._OBJ | ||
265 | define dir_pattern.o | ||
266 | ifeq ($(os),.os) | ||
267 | $(if $($(1)_OBJ.os),$($(1)_OBJ.os:.os=.o): $(top_builddir)/$(2)/%.o: $(top_srcdir)/$(2)/%.c) | ||
268 | endif | ||
269 | $(if $($(1)_OBJ$(os)),$($(1)_OBJ$(os)): $(top_builddir)/$(2)/%$(os): $(top_srcdir)/$(2)/%.c) | ||
270 | $(if $($(1)_OBJ),$($(1)_OBJ): $(top_builddir)/$(2)/%.o: $(top_srcdir)/$(2)/%.c) | ||
271 | endef | ||
272 | |||
273 | # The actual directory patterns for .o* | ||
274 | $(foreach d,$(DIRS),$(eval $(call dir_pattern.o,$(subst /,_,$(d)),$(d)))) | ||
275 | |||
276 | define file_lists | ||
277 | $($(1)$(2)) $($(1)$(2).o) $($(1)$(2).os) | ||
278 | endef | ||
279 | bin-obj-y:=$(subst .os,.o,$(foreach d,$(DIRS),$(call file_lists,$(subst /,_,$(d)),_OBJ))) | ||
280 | bin-mobj-y:=$(subst .osm,.om,$(foreach d,$(DIRS),$(call file_lists,$(subst /,_,$(d)),_MOBJ))) | ||
281 | |||
282 | ifeq ($(strip $(HAVE_DOT_CONFIG)),y) | 238 | ifeq ($(strip $(HAVE_DOT_CONFIG)),y) |
283 | # Finally pull in the dependencies (headers and other includes) of the | 239 | # Finally pull in the dependencies (headers and other includes) of the |
284 | # individual object files | 240 | # individual object files |
@@ -294,9 +250,7 @@ all: busybox busybox.links doc ; | |||
294 | # IMA compiles all sources at once (aka IPO aka IPA etc.) | 250 | # IMA compiles all sources at once (aka IPO aka IPA etc.) |
295 | 251 | ||
296 | ifeq ($(strip $(CONFIG_BUILD_AT_ONCE)),y) | 252 | ifeq ($(strip $(CONFIG_BUILD_AT_ONCE)),y) |
297 | # We are not building .o | 253 | libraries-y:= |
298 | bin-obj-y:= | ||
299 | bin-mobj-y:= | ||
300 | # Which parts of the internal libs are requested? | 254 | # Which parts of the internal libs are requested? |
301 | # Per default we only want what was actually selected. | 255 | # Per default we only want what was actually selected. |
302 | # -a denotes all while -y denotes the selected ones. | 256 | # -a denotes all while -y denotes the selected ones. |
@@ -312,30 +266,17 @@ APPLETS_DEFINE:=$(APPLETS_DEFINE-y) | |||
312 | else # CONFIG_BUILD_AT_ONCE | 266 | else # CONFIG_BUILD_AT_ONCE |
313 | # no --combine, build archives out of the individual .o | 267 | # no --combine, build archives out of the individual .o |
314 | # This was the old way the binary was built. | 268 | # This was the old way the binary was built. |
315 | libbusybox-obj:=$(archival_libunarchive_OBJ$(os)) \ | 269 | libbusybox-obj:=archival/libunarchive/libunarchive.a \ |
316 | $(networking_libiproute_OBJ$(os)) \ | 270 | networking/libiproute/libiproute.a \ |
317 | $(libpwdgrp_MOBJ$(os)) \ | 271 | libpwdgrp/libpwdgrp.a coreutils/libcoreutils/libcoreutils.a \ |
318 | $(coreutils_libcoreutils_OBJ$(os)) \ | 272 | libbb/libbb.a |
319 | $(libbb_OBJ$(os)) $(libbb_MOBJ$(os)) | 273 | libbusybox-obj:=$(patsubst %,$(top_builddir)/%,$(libbusybox-obj)) |
320 | |||
321 | ifeq ($(strip $(CONFIG_FEATURE_SHARED_BUSYBOX)),y) | 274 | ifeq ($(strip $(CONFIG_FEATURE_SHARED_BUSYBOX)),y) |
322 | # linking against libbusybox, so don't build the .o already contained in the .so | 275 | # linking against libbusybox, so don't build the .a already contained in the .so |
323 | bin-obj-y:=$(filter-out $(libbusybox-obj) $(libbusybox-obj:.os=.o),$(bin-obj-y)) | 276 | libraries-y:=$(filter-out $(libbusybox-obj),$(libraries-y)) |
324 | bin-mobj-y:=$(filter-out $(libbusybox-obj) $(libbusybox-obj:.osm=.om),$(bin-mobj-y)) | ||
325 | endif # CONFIG_FEATURE_SHARED_BUSYBOX | 277 | endif # CONFIG_FEATURE_SHARED_BUSYBOX |
326 | endif # CONFIG_BUILD_AT_ONCE | ||
327 | |||
328 | # build an .a to keep .hash et al small | ||
329 | ifneq ($(bin-obj-y)$(bin-mobj-y),) | ||
330 | applets.a:=$(bin-obj-y) $(bin-mobj-y) | ||
331 | endif | ||
332 | ifdef applets.a | ||
333 | applets.a: $(applets.a) | ||
334 | $(Q)-rm -f $(@) | ||
335 | $(do_ar) | ||
336 | 278 | ||
337 | bin-obj.a=applets.a | 279 | endif # CONFIG_BUILD_AT_ONCE |
338 | endif | ||
339 | 280 | ||
340 | ifeq ($(strip $(CONFIG_BUILD_LIBBUSYBOX)),y) | 281 | ifeq ($(strip $(CONFIG_BUILD_LIBBUSYBOX)),y) |
341 | LD_LIBBUSYBOX:=libbusybox.so | 282 | LD_LIBBUSYBOX:=libbusybox.so |
@@ -355,6 +296,8 @@ endif # !CONFIG_FEATURE_SHARED_BUSYBOX | |||
355 | $(LIBBUSYBOX_SONAME): $(LIBRARY_SRC) | 296 | $(LIBBUSYBOX_SONAME): $(LIBRARY_SRC) |
356 | else # CONFIG_BUILD_AT_ONCE | 297 | else # CONFIG_BUILD_AT_ONCE |
357 | $(LIBBUSYBOX_SONAME): $(libbusybox-obj) | 298 | $(LIBBUSYBOX_SONAME): $(libbusybox-obj) |
299 | AR_INTRO:=-Wl,--whole-archive | ||
300 | AR_EXTRO:=-Wl,--no-whole-archive | ||
358 | endif # CONFIG_BUILD_AT_ONCE | 301 | endif # CONFIG_BUILD_AT_ONCE |
359 | 302 | ||
360 | 303 | ||
@@ -367,12 +310,12 @@ $(LIBBUSYBOX_SONAME): | |||
367 | ifndef MAJOR_VERSION | 310 | ifndef MAJOR_VERSION |
368 | $(error MAJOR_VERSION needed for $@ is not defined) | 311 | $(error MAJOR_VERSION needed for $@ is not defined) |
369 | endif | 312 | endif |
370 | $(do_link) $(LIB_CFLAGS) $(LIB_LDFLAGS) $(CFLAGS_COMBINE) \ | 313 | $(do_link) $(LIB_CFLAGS) $(CFLAGS_COMBINE) \ |
371 | -Wl,-soname=$(LD_LIBBUSYBOX).$(MAJOR_VERSION) \ | 314 | -Wl,-soname=$(LD_LIBBUSYBOX).$(MAJOR_VERSION) \ |
372 | -Wl,-z,combreloc $(LIB_LDFLAGS) \ | 315 | -Wl,-z,combreloc $(LIB_LDFLAGS) \ |
373 | -o $(@) \ | 316 | -o $(@) \ |
374 | -Wl,--start-group \ | 317 | -Wl,--start-group \ |
375 | $(LIBRARY_DEFINE) $(^) \ | 318 | $(LIBRARY_DEFINE) $(AR_INTRO) $(^) $(AR_EXTRO) \ |
376 | -Wl,--end-group | 319 | -Wl,--end-group |
377 | @rm -f $(DO_INSTALL_LIBS) | 320 | @rm -f $(DO_INSTALL_LIBS) |
378 | @for i in $(DO_INSTALL_LIBS); do ln -s $(@) $$i ; done | 321 | @for i in $(DO_INSTALL_LIBS); do ln -s $(@) $$i ; done |
@@ -380,14 +323,14 @@ endif | |||
380 | 323 | ||
381 | endif # ifeq ($(strip $(CONFIG_BUILD_LIBBUSYBOX)),y) | 324 | endif # ifeq ($(strip $(CONFIG_BUILD_LIBBUSYBOX)),y) |
382 | 325 | ||
383 | busybox_unstripped: $(top_builddir)/.depend $(LIBBUSYBOX_SONAME) $(BUSYBOX_SRC) $(APPLET_SRC) $(bin-obj.a) | 326 | busybox_unstripped: $(top_builddir)/.depend $(LIBBUSYBOX_SONAME) $(BUSYBOX_SRC) $(APPLET_SRC) $(libraries-y) |
384 | $(do_link) $(PROG_CFLAGS) $(PROG_LDFLAGS) $(CFLAGS_COMBINE) \ | 327 | $(do_link) $(PROG_CFLAGS) $(PROG_LDFLAGS) $(CFLAGS_COMBINE) \ |
385 | $(foreach f,$(^:.o=.c),$(CFLAGS-$(notdir $(patsubst %/$,%,$(dir $(f))))-$(notdir $(f)))) \ | 328 | $(foreach f,$(^:.o=.c),$(CFLAGS-$(notdir $(patsubst %/$,%,$(dir $(f))))-$(notdir $(f)))) \ |
386 | $(CFLAGS-$(@)) \ | 329 | $(CFLAGS-$(@)) \ |
387 | -o $@ -Wl,--start-group \ | 330 | -o $@ -Wl,--start-group \ |
388 | $(APPLETS_DEFINE) $(APPLET_SRC) \ | 331 | $(APPLETS_DEFINE) $(APPLET_SRC) \ |
389 | $(BUSYBOX_DEFINE) $(BUSYBOX_SRC) \ | 332 | $(BUSYBOX_DEFINE) $(BUSYBOX_SRC) \ |
390 | $(bin-obj.a) \ | 333 | $(libraries-y) \ |
391 | $(LDBUSYBOX) $(LIBRARIES) \ | 334 | $(LDBUSYBOX) $(LIBRARIES) \ |
392 | -Wl,--end-group | 335 | -Wl,--end-group |
393 | 336 | ||
@@ -538,3 +481,4 @@ tags: | |||
538 | defconfig allyesconfig allnoconfig allbareconfig \ | 481 | defconfig allyesconfig allnoconfig allbareconfig \ |
539 | clean distclean \ | 482 | clean distclean \ |
540 | release tags | 483 | release tags |
484 | |||