diff options
Diffstat (limited to 'Makefile')
-rw-r--r-- | Makefile | 145 |
1 files changed, 76 insertions, 69 deletions
@@ -24,8 +24,6 @@ endif | |||
24 | export srctree=$(top_srcdir) | 24 | export srctree=$(top_srcdir) |
25 | vpath %/Config.in $(srctree) | 25 | vpath %/Config.in $(srctree) |
26 | 26 | ||
27 | include $(top_srcdir)/Rules.mak | ||
28 | |||
29 | DIRS:=applets archival archival/libunarchive coreutils console-tools \ | 27 | DIRS:=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 | ||
34 | SRC_DIRS:=$(patsubst %,$(top_srcdir)/%,$(DIRS)) | 32 | SRC_DIRS:=$(patsubst %,$(top_srcdir)/%,$(DIRS)) |
35 | 33 | ||
36 | ifeq ($(strip $(CONFIG_SELINUX)),y) | 34 | # That's our default target when none is given on the command line |
37 | LIBRARIES += -lselinux | 35 | .PHONY: _all |
38 | endif | 36 | _all: |
37 | |||
38 | # All object directories. | ||
39 | OBJ_DIRS = scripts/config include $(DIRS) | ||
40 | $(OBJ_DIRS): | ||
41 | mkdir -p "$(patsubst %,$(top_builddir)/%,$@)" | ||
42 | |||
43 | scripts/config/Makefile: $(top_srcdir)/scripts/config/Makefile | ||
44 | cp -v $< $@ | ||
45 | |||
46 | include $(top_srcdir)/Rules.mak | ||
39 | 47 | ||
40 | CONFIG_CONFIG_IN = $(top_srcdir)/sysdeps/$(TARGET_OS)/Config.in | 48 | CONFIG_CONFIG_IN = $(top_srcdir)/sysdeps/$(TARGET_OS)/Config.in |
41 | CONFIG_DEFCONFIG = $(top_srcdir)/sysdeps/$(TARGET_OS)/defconfig | 49 | CONFIG_DEFCONFIG = $(top_srcdir)/sysdeps/$(TARGET_OS)/defconfig |
42 | 50 | ||
43 | ALL_DIRS:= $(DIRS) scripts/config | ||
44 | ALL_MAKEFILES:=$(patsubst %,%/Makefile,$(ALL_DIRS)) | ||
45 | |||
46 | ifeq ($(KBUILD_SRC),) | 51 | ifeq ($(KBUILD_SRC),) |
47 | 52 | ||
48 | ifdef O | 53 | ifdef 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 |
57 | else | ||
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) | ||
52 | endif | 62 | endif |
53 | 63 | ||
54 | # That's our default target when none is given on the command line | ||
55 | .PHONY: _all | ||
56 | _all: | ||
57 | |||
58 | ifneq ($(KBUILD_OUTPUT),) | 64 | ifneq ($(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. | ||
74 | all_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 | ||
127 | ifeq ($(strip $(HAVE_DOT_CONFIG)),y) | ||
128 | 138 | ||
129 | all: busybox busybox.links doc | 139 | ifneq ($(strip $(HAVE_DOT_CONFIG)),y) |
140 | |||
141 | all: menuconfig | ||
130 | 142 | ||
131 | all_tree: $(ALL_MAKEFILES) | 143 | # configuration |
144 | # --------------------------------------------------------------------------- | ||
132 | 145 | ||
133 | $(ALL_MAKEFILES): %/Makefile: $(top_srcdir)/%/Makefile | 146 | scripts/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 | |||
152 | scripts/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 | |||
158 | menuconfig: scripts/config/mconf | ||
159 | @./scripts/config/mconf $(CONFIG_CONFIG_IN) | ||
160 | |||
161 | config: scripts/config/conf | ||
162 | @./scripts/config/conf $(CONFIG_CONFIG_IN) | ||
163 | |||
164 | oldconfig: scripts/config/conf | ||
165 | @./scripts/config/conf -o $(CONFIG_CONFIG_IN) | ||
166 | |||
167 | randconfig: scripts/config/conf | ||
168 | @./scripts/config/conf -r $(CONFIG_CONFIG_IN) | ||
169 | |||
170 | allyesconfig: 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 | |||
175 | allnoconfig: scripts/config/conf | ||
176 | @./scripts/config/conf -n $(CONFIG_CONFIG_IN) | ||
177 | |||
178 | defconfig: scripts/config/conf | ||
179 | @./scripts/config/conf -d $(CONFIG_CONFIG_IN) | ||
180 | |||
181 | else # ifneq ($(strip $(HAVE_DOT_CONFIG)),y) | ||
182 | |||
183 | all: 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 |
138 | include $(patsubst %,%/Makefile.in, $(SRC_DIRS)) | 187 | include $(patsubst %,%/Makefile.in, $(SRC_DIRS)) |
139 | -include $(top_builddir)/.depend | 188 | -include $(top_builddir)/.depend |
140 | 189 | ||
141 | busybox: $(ALL_MAKEFILES) .depend $(libraries-y) | 190 | endif # ifneq ($(strip $(HAVE_DOT_CONFIG)),y) |
191 | |||
192 | busybox: .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) | |||
217 | DEP_INCLUDES += include/bbconfigopts.h | 268 | DEP_INCLUDES += include/bbconfigopts.h |
218 | 269 | ||
219 | include/bbconfigopts.h: .config | 270 | include/bbconfigopts.h: .config |
220 | scripts/config/mkconfigs > $@ | 271 | $(top_srcdir)/scripts/config/mkconfigs > $@ |
221 | endif | 272 | endif |
222 | 273 | ||
223 | depend dep $(top_builddir)/.depend: .depend | 274 | depend dep $(top_builddir)/.depend: .depend |
@@ -245,48 +296,6 @@ finished2: | |||
245 | $(SECHO) Finished installing... | 296 | $(SECHO) Finished installing... |
246 | $(SECHO) | 297 | $(SECHO) |
247 | 298 | ||
248 | else # ifeq ($(strip $(HAVE_DOT_CONFIG)),y) | ||
249 | |||
250 | all: menuconfig | ||
251 | |||
252 | # configuration | ||
253 | # --------------------------------------------------------------------------- | ||
254 | |||
255 | scripts/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 | |||
261 | scripts/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 | |||
267 | menuconfig: scripts/config/mconf | ||
268 | @./scripts/config/mconf $(CONFIG_CONFIG_IN) | ||
269 | |||
270 | config: scripts/config/conf | ||
271 | @./scripts/config/conf $(CONFIG_CONFIG_IN) | ||
272 | |||
273 | oldconfig: scripts/config/conf | ||
274 | @./scripts/config/conf -o $(CONFIG_CONFIG_IN) | ||
275 | |||
276 | randconfig: scripts/config/conf | ||
277 | @./scripts/config/conf -r $(CONFIG_CONFIG_IN) | ||
278 | |||
279 | allyesconfig: 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 | |||
284 | allnoconfig: scripts/config/conf | ||
285 | @./scripts/config/conf -n $(CONFIG_CONFIG_IN) | ||
286 | |||
287 | defconfig: scripts/config/conf | ||
288 | @./scripts/config/conf -d $(CONFIG_CONFIG_IN) | ||
289 | |||
290 | clean: | 299 | clean: |
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 | ||
330 | endif # ifeq ($(strip $(HAVE_DOT_CONFIG)),y) | ||
331 | |||
332 | endif # ifeq ($(skip-makefile),) | 339 | endif # ifeq ($(skip-makefile),) |
333 | 340 | ||
334 | .PHONY: dummy subdirs release distclean clean config oldconfig \ | 341 | .PHONY: dummy subdirs release distclean clean config oldconfig \ |