diff options
author | Eric Andersen <andersen@codepoet.org> | 2004-10-08 07:46:08 +0000 |
---|---|---|
committer | Eric Andersen <andersen@codepoet.org> | 2004-10-08 07:46:08 +0000 |
commit | 7daa076d3e24e84ce1f4e9b6133783816575c4c8 (patch) | |
tree | e81ce57a92acc0653374e1d262039562855d16ec /Makefile | |
parent | 2842659cc02233274ca165ffb83a31b161d815cd (diff) | |
download | busybox-w32-7daa076d3e24e84ce1f4e9b6133783816575c4c8.tar.gz busybox-w32-7daa076d3e24e84ce1f4e9b6133783816575c4c8.tar.bz2 busybox-w32-7daa076d3e24e84ce1f4e9b6133783816575c4c8.zip |
egor duda writes:
Hi!
I've created a patch to busybox' build system to allow building it in
separate tree in a manner similar to kbuild from kernel version 2.6.
That is, one runs command like
'make O=/build/some/where/for/specific/target/and/options'
and everything is built in this exact directory, provided that it exists.
I understand that applyingc such invasive changes during 'release
candidates' stage of development is at best unwise. So, i'm currently
asking for comments about this patch, starting from whether such thing
is needed at all to whether it coded properly.
'make check' should work now, and one make creates Makefile in build
directory, so one can run 'make' in build directory after that.
One possible caveat is that if we build in some directory other than
source one, the source directory should be 'distclean'ed first.
egor
Diffstat (limited to 'Makefile')
-rw-r--r-- | Makefile | 145 |
1 files changed, 111 insertions, 34 deletions
@@ -22,37 +22,112 @@ | |||
22 | #-------------------------------------------------------------- | 22 | #-------------------------------------------------------------- |
23 | noconfig_targets := menuconfig config oldconfig randconfig \ | 23 | noconfig_targets := menuconfig config oldconfig randconfig \ |
24 | defconfig allyesconfig allnoconfig clean distclean \ | 24 | defconfig allyesconfig allnoconfig clean distclean \ |
25 | release tags | 25 | release tags |
26 | TOPDIR=./ | 26 | |
27 | include Rules.mak | 27 | ifndef TOPDIR |
28 | TOPDIR=$(CURDIR)/ | ||
29 | endif | ||
30 | ifndef top_srcdir | ||
31 | top_srcdir=$(CURDIR) | ||
32 | endif | ||
33 | ifndef top_builddir | ||
34 | top_builddir=$(CURDIR) | ||
35 | endif | ||
36 | |||
37 | srctree=$(top_srcdir) | ||
38 | vpath %/Config.in $(srctree) | ||
39 | |||
40 | include $(top_builddir)/Rules.mak | ||
28 | 41 | ||
29 | DIRS:=applets archival archival/libunarchive coreutils console-tools \ | 42 | DIRS:=applets archival archival/libunarchive coreutils console-tools \ |
30 | debianutils editors findutils init miscutils modutils networking \ | 43 | debianutils editors findutils init miscutils modutils networking \ |
31 | networking/libiproute networking/udhcp procps loginutils shell \ | 44 | networking/libiproute networking/udhcp procps loginutils shell \ |
32 | sysklogd util-linux libpwdgrp coreutils/libcoreutils libbb | 45 | sysklogd util-linux libpwdgrp coreutils/libcoreutils libbb |
33 | 46 | ||
47 | SRC_DIRS:=$(patsubst %,$(top_srcdir)/%,$(DIRS)) | ||
48 | |||
34 | ifeq ($(strip $(CONFIG_SELINUX)),y) | 49 | ifeq ($(strip $(CONFIG_SELINUX)),y) |
35 | CFLAGS += -I/usr/include/selinux | 50 | CFLAGS += -I/usr/include/selinux |
36 | LIBRARIES += -lsecure | 51 | LIBRARIES += -lsecure |
37 | endif | 52 | endif |
38 | 53 | ||
39 | CONFIG_CONFIG_IN = sysdeps/$(TARGET_OS)/Config.in | 54 | CONFIG_CONFIG_IN = $(top_srcdir)/sysdeps/$(TARGET_OS)/Config.in |
40 | CONFIG_DEFCONFIG = sysdeps/$(TARGET_OS)/defconfig | 55 | CONFIG_DEFCONFIG = $(top_srcdir)/sysdeps/$(TARGET_OS)/defconfig |
56 | |||
57 | ALL_DIRS:= $(DIRS) scripts/config | ||
58 | ALL_MAKEFILES:=$(patsubst %,%/Makefile,$(ALL_DIRS)) | ||
59 | |||
60 | ifeq ($(KBUILD_SRC),) | ||
61 | |||
62 | ifdef O | ||
63 | ifeq ("$(origin O)", "command line") | ||
64 | KBUILD_OUTPUT := $(O) | ||
65 | endif | ||
66 | endif | ||
67 | |||
68 | # That's our default target when none is given on the command line | ||
69 | .PHONY: _all | ||
70 | _all: | ||
71 | |||
72 | ifneq ($(KBUILD_OUTPUT),) | ||
73 | # Invoke a second make in the output directory, passing relevant variables | ||
74 | # check that the output directory actually exists | ||
75 | saved-output := $(KBUILD_OUTPUT) | ||
76 | KBUILD_OUTPUT := $(shell cd $(KBUILD_OUTPUT) && /bin/pwd) | ||
77 | $(if $(wildcard $(KBUILD_OUTPUT)),, \ | ||
78 | $(error output directory "$(saved-output)" does not exist)) | ||
79 | |||
80 | .PHONY: $(MAKECMDGOALS) | ||
81 | |||
82 | $(filter-out _all,$(MAKECMDGOALS)) _all: $(KBUILD_OUTPUT)/Rules.mak $(KBUILD_OUTPUT)/Makefile | ||
83 | $(MAKE) -C $(KBUILD_OUTPUT) \ | ||
84 | top_srcdir=$(CURDIR) \ | ||
85 | top_builddir=$(KBUILD_OUTPUT) \ | ||
86 | TOPDIR=$(KBUILD_OUTPUT) \ | ||
87 | KBUILD_SRC=$(CURDIR) \ | ||
88 | -f $(CURDIR)/Makefile $@ | ||
89 | |||
90 | $(KBUILD_OUTPUT)/Rules.mak: | ||
91 | @echo > $@ | ||
92 | @echo top_srcdir=$(CURDIR) >> $@ | ||
93 | @echo top_builddir=$(KBUILD_OUTPUT) >> $@ | ||
94 | @echo include $(top_srcdir)/Rules.mak >> $@ | ||
95 | |||
96 | $(KBUILD_OUTPUT)/Makefile: | ||
97 | @echo > $@ | ||
98 | @echo top_srcdir=$(CURDIR) >> $@ | ||
99 | @echo top_builddir=$(KBUILD_OUTPUT) >> $@ | ||
100 | @echo KBUILD_SRC='$$(top_srcdir)' >> $@ | ||
101 | @echo include '$$(KBUILD_SRC)'/Makefile >> $@ | ||
102 | |||
103 | # Leave processing to above invocation of make | ||
104 | skip-makefile := 1 | ||
105 | endif # ifneq ($(KBUILD_OUTPUT),) | ||
106 | endif # ifeq ($(KBUILD_SRC),) | ||
107 | |||
108 | ifeq ($(skip-makefile),) | ||
109 | |||
110 | _all: all | ||
41 | 111 | ||
42 | ifeq ($(strip $(HAVE_DOT_CONFIG)),y) | 112 | ifeq ($(strip $(HAVE_DOT_CONFIG)),y) |
43 | 113 | ||
44 | all: busybox busybox.links doc | 114 | all: busybox busybox.links doc |
45 | 115 | ||
116 | all_tree: $(ALL_MAKEFILES) | ||
117 | |||
118 | $(ALL_MAKEFILES): %/Makefile: $(top_srcdir)/%/Makefile | ||
119 | d=`dirname $@`; [ -d "$$d" ] || mkdir -p "$$d"; cp $< $@ | ||
120 | |||
46 | # In this section, we need .config | 121 | # In this section, we need .config |
47 | -include .config.cmd | 122 | -include $(top_builddir)/.config.cmd |
48 | include $(patsubst %,%/Makefile.in, $(DIRS)) | 123 | include $(patsubst %,%/Makefile.in, $(SRC_DIRS)) |
49 | -include $(TOPDIR).depend | 124 | -include $(top_builddir)/.depend |
50 | 125 | ||
51 | busybox: .depend include/config.h $(libraries-y) | 126 | busybox: $(ALL_MAKEFILES) .depend include/config.h $(libraries-y) |
52 | $(CC) $(LDFLAGS) -o $@ -Wl,--start-group $(libraries-y) $(LIBRARIES) -Wl,--end-group | 127 | $(CC) $(LDFLAGS) -o $@ -Wl,--start-group $(libraries-y) $(LIBRARIES) -Wl,--end-group |
53 | $(STRIPCMD) $@ | 128 | $(STRIPCMD) $@ |
54 | 129 | ||
55 | busybox.links: applets/busybox.mkll include/config.h | 130 | busybox.links: $(top_srcdir)/applets/busybox.mkll include/config.h $(top_srcdir)/include/applets.h |
56 | - $(SHELL) $^ >$@ | 131 | - $(SHELL) $^ >$@ |
57 | 132 | ||
58 | install: applets/install.sh busybox busybox.links | 133 | install: applets/install.sh busybox busybox.links |
@@ -75,14 +150,18 @@ uninstall: busybox.links | |||
75 | install-hardlinks: applets/install.sh busybox busybox.links | 150 | install-hardlinks: applets/install.sh busybox busybox.links |
76 | $(SHELL) $< $(PREFIX) --hardlinks | 151 | $(SHELL) $< $(PREFIX) --hardlinks |
77 | 152 | ||
153 | check: busybox | ||
154 | bindir=$(top_builddir) srcdir=$(top_srcdir)/testsuite \ | ||
155 | $(top_srcdir)/testsuite/runtest | ||
78 | 156 | ||
79 | # Documentation Targets | 157 | # Documentation Targets |
80 | doc: docs/busybox.pod docs/BusyBox.txt docs/BusyBox.1 docs/BusyBox.html | 158 | doc: docs/busybox.pod docs/BusyBox.txt docs/BusyBox.1 docs/BusyBox.html |
81 | 159 | ||
82 | docs/busybox.pod : docs/busybox_header.pod include/usage.h docs/busybox_footer.pod | 160 | docs/busybox.pod : $(top_srcdir)/docs/busybox_header.pod $(top_srcdir)/include/usage.h $(top_srcdir)/docs/busybox_footer.pod |
83 | - ( cat docs/busybox_header.pod; \ | 161 | -mkdir -p docs |
84 | docs/autodocifier.pl include/usage.h; \ | 162 | - ( cat $(top_srcdir)/docs/busybox_header.pod; \ |
85 | cat docs/busybox_footer.pod ) > docs/busybox.pod | 163 | $(top_srcdir)/docs/autodocifier.pl $(top_srcdir)/include/usage.h; \ |
164 | cat $(top_srcdir)/docs/busybox_footer.pod ) > docs/busybox.pod | ||
86 | 165 | ||
87 | docs/BusyBox.txt: docs/busybox.pod | 166 | docs/BusyBox.txt: docs/busybox.pod |
88 | @echo | 167 | @echo |
@@ -99,7 +178,7 @@ docs/BusyBox.1: docs/busybox.pod | |||
99 | docs/BusyBox.html: docs/busybox.net/BusyBox.html | 178 | docs/BusyBox.html: docs/busybox.net/BusyBox.html |
100 | - mkdir -p docs | 179 | - mkdir -p docs |
101 | -@ rm -f docs/BusyBox.html | 180 | -@ rm -f docs/BusyBox.html |
102 | -@ ln -s busybox.net/BusyBox.html docs/BusyBox.html | 181 | -@ cp docs/busybox.net/BusyBox.html docs/BusyBox.html |
103 | 182 | ||
104 | docs/busybox.net/BusyBox.html: docs/busybox.pod | 183 | docs/busybox.net/BusyBox.html: docs/busybox.pod |
105 | -@ mkdir -p docs/busybox.net | 184 | -@ mkdir -p docs/busybox.net |
@@ -108,20 +187,19 @@ docs/busybox.net/BusyBox.html: docs/busybox.pod | |||
108 | -@ rm -f pod2htm* | 187 | -@ rm -f pod2htm* |
109 | 188 | ||
110 | # The nifty new buildsystem stuff | 189 | # The nifty new buildsystem stuff |
111 | scripts/mkdep: scripts/mkdep.c | 190 | scripts/mkdep: $(top_srcdir)/scripts/mkdep.c |
112 | $(HOSTCC) $(HOSTCFLAGS) -o scripts/mkdep scripts/mkdep.c | 191 | $(HOSTCC) $(HOSTCFLAGS) -o $@ $< |
113 | 192 | ||
114 | scripts/split-include: scripts/split-include.c | 193 | scripts/split-include: $(top_srcdir)/scripts/split-include.c |
115 | $(HOSTCC) $(HOSTCFLAGS) -o scripts/split-include scripts/split-include.c | 194 | $(HOSTCC) $(HOSTCFLAGS) -o $@ $< |
116 | 195 | ||
117 | .depend: scripts/mkdep | 196 | .depend: scripts/mkdep |
118 | rm -f .depend .hdepend; | 197 | rm -f .depend .hdepend; |
119 | mkdir -p include/config; | 198 | mkdir -p include/config; |
120 | $(HOSTCC) $(HOSTCFLAGS) -o scripts/mkdep scripts/mkdep.c | ||
121 | scripts/mkdep -I include -- \ | 199 | scripts/mkdep -I include -- \ |
122 | `find -name \*.c -print | sed -e "s,^./,,"` >> .depend; | 200 | `find $(top_srcdir) -name \*.c -print | sed -e "s,^./,,"` >> .depend; |
123 | scripts/mkdep -I include -- \ | 201 | scripts/mkdep -I include -- \ |
124 | `find -name \*.h -print | sed -e "s,^./,,"` >> .hdepend; | 202 | `find $(top_srcdir) -name \*.h -print | sed -e "s,^./,,"` >> .hdepend; |
125 | 203 | ||
126 | depend dep: include/config.h .depend | 204 | depend dep: include/config.h .depend |
127 | 205 | ||
@@ -130,13 +208,10 @@ include/config/MARKER: depend scripts/split-include | |||
130 | @ touch include/config/MARKER | 208 | @ touch include/config/MARKER |
131 | 209 | ||
132 | include/config.h: .config | 210 | include/config.h: .config |
133 | @if [ ! -x ./scripts/config/conf ] ; then \ | 211 | @if [ ! -x $(top_builddir)/scripts/config/conf ] ; then \ |
134 | $(MAKE) -C scripts/config conf; \ | 212 | $(MAKE) -C scripts/config conf; \ |
135 | fi; | 213 | fi; |
136 | @./scripts/config/conf -o $(CONFIG_CONFIG_IN) | 214 | @$(top_builddir)/scripts/config/conf -o $(CONFIG_CONFIG_IN) |
137 | |||
138 | %.o: %.c | ||
139 | $(CC) $(CFLAGS) $(EXTRA_CFLAGS) -c -o $@ $< | ||
140 | 215 | ||
141 | finished2: | 216 | finished2: |
142 | @echo | 217 | @echo |
@@ -150,12 +225,16 @@ all: menuconfig | |||
150 | # configuration | 225 | # configuration |
151 | # --------------------------------------------------------------------------- | 226 | # --------------------------------------------------------------------------- |
152 | 227 | ||
153 | scripts/config/conf: | 228 | $(ALL_MAKEFILES): %/Makefile: $(top_srcdir)/%/Makefile |
229 | d=`dirname $@`; [ -d "$$d" ] || mkdir -p "$$d"; cp $< $@ | ||
230 | |||
231 | scripts/config/conf: scripts/config/Makefile Rules.mak | ||
154 | $(MAKE) -C scripts/config conf | 232 | $(MAKE) -C scripts/config conf |
155 | -@if [ ! -f .config ] ; then \ | 233 | -@if [ ! -f .config ] ; then \ |
156 | cp $(CONFIG_DEFCONFIG) .config; \ | 234 | cp $(CONFIG_DEFCONFIG) .config; \ |
157 | fi | 235 | fi |
158 | scripts/config/mconf: | 236 | |
237 | scripts/config/mconf: scripts/config/Makefile Rules.mak | ||
159 | $(MAKE) -C scripts/config ncurses conf mconf | 238 | $(MAKE) -C scripts/config ncurses conf mconf |
160 | -@if [ ! -f .config ] ; then \ | 239 | -@if [ ! -f .config ] ; then \ |
161 | cp $(CONFIG_DEFCONFIG) .config; \ | 240 | cp $(CONFIG_DEFCONFIG) .config; \ |
@@ -187,9 +266,6 @@ allnoconfig: scripts/config/conf | |||
187 | defconfig: scripts/config/conf | 266 | defconfig: scripts/config/conf |
188 | @./scripts/config/conf -d $(CONFIG_CONFIG_IN) | 267 | @./scripts/config/conf -d $(CONFIG_CONFIG_IN) |
189 | 268 | ||
190 | check: busybox | ||
191 | cd testsuite && ./runtest | ||
192 | |||
193 | clean: | 269 | clean: |
194 | - rm -f docs/busybox.dvi docs/busybox.ps \ | 270 | - rm -f docs/busybox.dvi docs/busybox.ps \ |
195 | docs/busybox.pod docs/busybox.net/busybox.html \ | 271 | docs/busybox.pod docs/busybox.net/busybox.html \ |
@@ -232,7 +308,8 @@ tags: | |||
232 | 308 | ||
233 | endif # ifeq ($(strip $(HAVE_DOT_CONFIG)),y) | 309 | endif # ifeq ($(strip $(HAVE_DOT_CONFIG)),y) |
234 | 310 | ||
235 | .PHONY: dummy subdirs release distclean clean config oldconfig \ | 311 | endif # ifeq ($(skip-makefile),) |
236 | menuconfig tags check test depend | ||
237 | 312 | ||
313 | .PHONY: dummy subdirs release distclean clean config oldconfig \ | ||
314 | menuconfig tags check test depend buildtree | ||
238 | 315 | ||