aboutsummaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile145
1 files changed, 76 insertions, 69 deletions
diff --git a/Makefile b/Makefile
index f71c53694..7f29037f5 100644
--- a/Makefile
+++ b/Makefile
@@ -24,8 +24,6 @@ endif
24export srctree=$(top_srcdir) 24export srctree=$(top_srcdir)
25vpath %/Config.in $(srctree) 25vpath %/Config.in $(srctree)
26 26
27include $(top_srcdir)/Rules.mak
28
29DIRS:=applets archival archival/libunarchive coreutils console-tools \ 27DIRS:=applets archival archival/libunarchive coreutils console-tools \
30 debianutils editors findutils init miscutils modutils networking \ 28 debianutils editors findutils init miscutils modutils networking \
31 networking/libiproute networking/udhcp procps loginutils shell \ 29 networking/libiproute networking/udhcp procps loginutils shell \
@@ -33,28 +31,36 @@ DIRS:=applets archival archival/libunarchive coreutils console-tools \
33 31
34SRC_DIRS:=$(patsubst %,$(top_srcdir)/%,$(DIRS)) 32SRC_DIRS:=$(patsubst %,$(top_srcdir)/%,$(DIRS))
35 33
36ifeq ($(strip $(CONFIG_SELINUX)),y) 34# That's our default target when none is given on the command line
37LIBRARIES += -lselinux 35.PHONY: _all
38endif 36_all:
37
38# All object directories.
39OBJ_DIRS = scripts/config include $(DIRS)
40$(OBJ_DIRS):
41 mkdir -p "$(patsubst %,$(top_builddir)/%,$@)"
42
43scripts/config/Makefile: $(top_srcdir)/scripts/config/Makefile
44 cp -v $< $@
45
46include $(top_srcdir)/Rules.mak
39 47
40CONFIG_CONFIG_IN = $(top_srcdir)/sysdeps/$(TARGET_OS)/Config.in 48CONFIG_CONFIG_IN = $(top_srcdir)/sysdeps/$(TARGET_OS)/Config.in
41CONFIG_DEFCONFIG = $(top_srcdir)/sysdeps/$(TARGET_OS)/defconfig 49CONFIG_DEFCONFIG = $(top_srcdir)/sysdeps/$(TARGET_OS)/defconfig
42 50
43ALL_DIRS:= $(DIRS) scripts/config
44ALL_MAKEFILES:=$(patsubst %,%/Makefile,$(ALL_DIRS))
45
46ifeq ($(KBUILD_SRC),) 51ifeq ($(KBUILD_SRC),)
47 52
48ifdef O 53ifdef O
49 ifeq ("$(origin O)", "command line") 54 ifeq ("$(origin O)", "command line")
50 KBUILD_OUTPUT := $(O) 55 KBUILD_OUTPUT := $(O)
51 endif 56 endif
57else
58# If no alternate output-dir was specified, we build in cwd
59# We are using KBUILD_OUTPUT nevertheless to make sure that we create
60# Rules.mak and the toplevel Makefile, in case they don't exist.
61 KBUILD_OUTPUT := $(top_builddir)
52endif 62endif
53 63
54# That's our default target when none is given on the command line
55.PHONY: _all
56_all:
57
58ifneq ($(KBUILD_OUTPUT),) 64ifneq ($(KBUILD_OUTPUT),)
59# Invoke a second make in the output directory, passing relevant variables 65# Invoke a second make in the output directory, passing relevant variables
60# check that the output directory actually exists 66# check that the output directory actually exists
@@ -63,24 +69,29 @@ KBUILD_OUTPUT := $(shell cd $(KBUILD_OUTPUT) && /bin/pwd)
63$(if $(wildcard $(KBUILD_OUTPUT)),, \ 69$(if $(wildcard $(KBUILD_OUTPUT)),, \
64 $(error output directory "$(saved-output)" does not exist)) 70 $(error output directory "$(saved-output)" does not exist))
65 71
72# We only need a copy of the Makefile for the config targets and reuse
73# the rest from the source directory, i.e. we do not cp ALL_MAKEFILES.
74all_tree: $(OBJ_DIRS) $(KBUILD_OUTPUT)/Rules.mak $(KBUILD_OUTPUT)/Makefile scripts/config/Makefile
75
66.PHONY: $(MAKECMDGOALS) 76.PHONY: $(MAKECMDGOALS)
67 77
68$(filter-out _all,$(MAKECMDGOALS)) _all: $(KBUILD_OUTPUT)/Rules.mak $(KBUILD_OUTPUT)/Makefile 78$(filter-out _all,$(MAKECMDGOALS)) _all: $(KBUILD_OUTPUT)/Rules.mak $(KBUILD_OUTPUT)/Makefile all_tree
79#all:
69 $(MAKE) -C $(KBUILD_OUTPUT) \ 80 $(MAKE) -C $(KBUILD_OUTPUT) \
70 top_srcdir=$(CURDIR) \ 81 top_srcdir=$(top_srcdir) \
71 top_builddir=$(KBUILD_OUTPUT) \ 82 top_builddir=$(top_builddir) \
72 KBUILD_SRC=$(CURDIR) \ 83 KBUILD_SRC=$(top_srcdir) \
73 -f $(CURDIR)/Makefile $@ 84 -f $(CURDIR)/Makefile $@
74 85
75$(KBUILD_OUTPUT)/Rules.mak: 86$(KBUILD_OUTPUT)/Rules.mak:
76 @echo > $@ 87 @echo > $@
77 @echo top_srcdir=$(CURDIR) >> $@ 88 @echo top_srcdir=$(top_srcdir) >> $@
78 @echo top_builddir=$(KBUILD_OUTPUT) >> $@ 89 @echo top_builddir=$(KBUILD_OUTPUT) >> $@
79 @echo include $(top_srcdir)/Rules.mak >> $@ 90 @echo include $(top_srcdir)/Rules.mak >> $@
80 91
81$(KBUILD_OUTPUT)/Makefile: 92$(KBUILD_OUTPUT)/Makefile:
82 @echo > $@ 93 @echo > $@
83 @echo top_srcdir=$(CURDIR) >> $@ 94 @echo top_srcdir=$(top_srcdir) >> $@
84 @echo top_builddir=$(KBUILD_OUTPUT) >> $@ 95 @echo top_builddir=$(KBUILD_OUTPUT) >> $@
85 @echo KBUILD_SRC='$$(top_srcdir)' >> $@ 96 @echo KBUILD_SRC='$$(top_srcdir)' >> $@
86 @echo include '$$(KBUILD_SRC)'/Makefile >> $@ 97 @echo include '$$(KBUILD_SRC)'/Makefile >> $@
@@ -124,21 +135,61 @@ help:
124 @echo ' sizes - show size of all enabled busybox symbols' 135 @echo ' sizes - show size of all enabled busybox symbols'
125 @echo 136 @echo
126 137
127ifeq ($(strip $(HAVE_DOT_CONFIG)),y)
128 138
129all: busybox busybox.links doc 139ifneq ($(strip $(HAVE_DOT_CONFIG)),y)
140
141all: menuconfig
130 142
131all_tree: $(ALL_MAKEFILES) 143# configuration
144# ---------------------------------------------------------------------------
132 145
133$(ALL_MAKEFILES): %/Makefile: $(top_srcdir)/%/Makefile 146scripts/config/conf: scripts/config/Makefile
134 [ -d $(@D) ] || mkdir -p $(@D); cp $< $@ 147 $(MAKE) -C scripts/config conf
148 -@if [ ! -f .config ] ; then \
149 cp $(CONFIG_DEFCONFIG) .config; \
150 fi
151
152scripts/config/mconf: scripts/config/Makefile
153 $(MAKE) -C scripts/config ncurses conf mconf
154 -@if [ ! -f .config ] ; then \
155 cp $(CONFIG_DEFCONFIG) .config; \
156 fi
157
158menuconfig: scripts/config/mconf
159 @./scripts/config/mconf $(CONFIG_CONFIG_IN)
160
161config: scripts/config/conf
162 @./scripts/config/conf $(CONFIG_CONFIG_IN)
163
164oldconfig: scripts/config/conf
165 @./scripts/config/conf -o $(CONFIG_CONFIG_IN)
166
167randconfig: scripts/config/conf
168 @./scripts/config/conf -r $(CONFIG_CONFIG_IN)
169
170allyesconfig: scripts/config/conf
171 @./scripts/config/conf -y $(CONFIG_CONFIG_IN)
172 sed -i -r -e "s/^(CONFIG_DEBUG|USING_CROSS_COMPILER|CONFIG_STATIC|CONFIG_SELINUX).*/# \1 is not set/" .config
173 @./scripts/config/conf -o $(CONFIG_CONFIG_IN)
174
175allnoconfig: scripts/config/conf
176 @./scripts/config/conf -n $(CONFIG_CONFIG_IN)
177
178defconfig: scripts/config/conf
179 @./scripts/config/conf -d $(CONFIG_CONFIG_IN)
180
181else # ifneq ($(strip $(HAVE_DOT_CONFIG)),y)
182
183all: busybox busybox.links doc
135 184
136# In this section, we need .config 185# In this section, we need .config
137-include $(top_builddir)/.config.cmd 186-include $(top_builddir)/.config.cmd
138include $(patsubst %,%/Makefile.in, $(SRC_DIRS)) 187include $(patsubst %,%/Makefile.in, $(SRC_DIRS))
139-include $(top_builddir)/.depend 188-include $(top_builddir)/.depend
140 189
141busybox: $(ALL_MAKEFILES) .depend $(libraries-y) 190endif # ifneq ($(strip $(HAVE_DOT_CONFIG)),y)
191
192busybox: .depend $(libraries-y)
142 $(CC) $(EXTRA_CFLAGS) $(LDFLAGS) -o $@ -Wl,--start-group $(libraries-y) $(LIBRARIES) -Wl,--end-group 193 $(CC) $(EXTRA_CFLAGS) $(LDFLAGS) -o $@ -Wl,--start-group $(libraries-y) $(LIBRARIES) -Wl,--end-group
143 $(STRIPCMD) $@ 194 $(STRIPCMD) $@
144 195
@@ -217,7 +268,7 @@ ifeq ($(strip $(CONFIG_BBCONFIG)),y)
217DEP_INCLUDES += include/bbconfigopts.h 268DEP_INCLUDES += include/bbconfigopts.h
218 269
219include/bbconfigopts.h: .config 270include/bbconfigopts.h: .config
220 scripts/config/mkconfigs > $@ 271 $(top_srcdir)/scripts/config/mkconfigs > $@
221endif 272endif
222 273
223depend dep $(top_builddir)/.depend: .depend 274depend dep $(top_builddir)/.depend: .depend
@@ -245,48 +296,6 @@ finished2:
245 $(SECHO) Finished installing... 296 $(SECHO) Finished installing...
246 $(SECHO) 297 $(SECHO)
247 298
248else # ifeq ($(strip $(HAVE_DOT_CONFIG)),y)
249
250all: menuconfig
251
252# configuration
253# ---------------------------------------------------------------------------
254
255scripts/config/conf: scripts/config/Makefile $(top_srcdir)/Rules.mak
256 $(MAKE) -C scripts/config conf
257 -@if [ ! -f .config ] ; then \
258 cp $(CONFIG_DEFCONFIG) .config; \
259 fi
260
261scripts/config/mconf: scripts/config/Makefile $(top_srcdir)/Rules.mak
262 $(MAKE) -C scripts/config ncurses conf mconf
263 -@if [ ! -f .config ] ; then \
264 cp $(CONFIG_DEFCONFIG) .config; \
265 fi
266
267menuconfig: scripts/config/mconf
268 @./scripts/config/mconf $(CONFIG_CONFIG_IN)
269
270config: scripts/config/conf
271 @./scripts/config/conf $(CONFIG_CONFIG_IN)
272
273oldconfig: scripts/config/conf
274 @./scripts/config/conf -o $(CONFIG_CONFIG_IN)
275
276randconfig: scripts/config/conf
277 @./scripts/config/conf -r $(CONFIG_CONFIG_IN)
278
279allyesconfig: scripts/config/conf
280 @./scripts/config/conf -y $(CONFIG_CONFIG_IN)
281 sed -i -r -e "s/^(CONFIG_DEBUG|USING_CROSS_COMPILER|CONFIG_STATIC|CONFIG_SELINUX).*/# \1 is not set/" .config
282 @./scripts/config/conf -o $(CONFIG_CONFIG_IN)
283
284allnoconfig: scripts/config/conf
285 @./scripts/config/conf -n $(CONFIG_CONFIG_IN)
286
287defconfig: scripts/config/conf
288 @./scripts/config/conf -d $(CONFIG_CONFIG_IN)
289
290clean: 299clean:
291 - $(MAKE) -C scripts/config $@ 300 - $(MAKE) -C scripts/config $@
292 - rm -f docs/busybox.dvi docs/busybox.ps \ 301 - rm -f docs/busybox.dvi docs/busybox.ps \
@@ -327,8 +336,6 @@ tags:
327 ctags -R . 336 ctags -R .
328 337
329 338
330endif # ifeq ($(strip $(HAVE_DOT_CONFIG)),y)
331
332endif # ifeq ($(skip-makefile),) 339endif # ifeq ($(skip-makefile),)
333 340
334.PHONY: dummy subdirs release distclean clean config oldconfig \ 341.PHONY: dummy subdirs release distclean clean config oldconfig \