diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2010-06-06 00:53:45 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2010-06-06 00:53:45 +0200 |
commit | 6c5bf0d347faded028e15d523c26a0d64c6d3920 (patch) | |
tree | 9dbe0229ec0d941c9efabb88571e6140d8e71951 | |
parent | 0e5ba0843b86a78d2d98a5fbaac8d33fe041f10e (diff) | |
download | busybox-w32-6c5bf0d347faded028e15d523c26a0d64c6d3920.tar.gz busybox-w32-6c5bf0d347faded028e15d523c26a0d64c6d3920.tar.bz2 busybox-w32-6c5bf0d347faded028e15d523c26a0d64c6d3920.zip |
make it possible to have include/applets.h-esque entries in .c files
As an example, bunzip2 and bzcat is changed to use it.
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | Makefile | 14 | ||||
-rw-r--r-- | Makefile.custom | 2 | ||||
-rw-r--r-- | applets/Kbuild.src | 6 | ||||
-rw-r--r-- | archival/bbunzip.c | 2 | ||||
-rw-r--r-- | include/applets.src.h (renamed from include/applets.h) | 3 | ||||
-rw-r--r-- | scripts/Makefile.IMA | 2 | ||||
-rwxr-xr-x | scripts/gen_build_files.sh | 31 |
7 files changed, 38 insertions, 22 deletions
@@ -358,11 +358,16 @@ scripts_basic: | |||
358 | # To avoid any implicit rule to kick in, define an empty command. | 358 | # To avoid any implicit rule to kick in, define an empty command. |
359 | scripts/basic/%: scripts_basic ; | 359 | scripts/basic/%: scripts_basic ; |
360 | 360 | ||
361 | # This target generates Kbuild's and Config.in's from *.c files | ||
362 | PHONY += gen_build_files | ||
363 | gen_build_files: | ||
364 | $(Q)$(srctree)/scripts/gen_build_files.sh $(srctree) $(objtree) | ||
365 | |||
361 | # bbox: we have helpers in applets/ | 366 | # bbox: we have helpers in applets/ |
362 | # we depend on scripts_basic, since scripts/basic/fixdep | 367 | # we depend on scripts_basic, since scripts/basic/fixdep |
363 | # must be built before any other host prog | 368 | # must be built before any other host prog |
364 | PHONY += applets_dir | 369 | PHONY += applets_dir |
365 | applets_dir: scripts_basic | 370 | applets_dir: scripts_basic gen_build_files |
366 | $(Q)$(MAKE) $(build)=applets | 371 | $(Q)$(MAKE) $(build)=applets |
367 | 372 | ||
368 | applets/%: applets_dir ; | 373 | applets/%: applets_dir ; |
@@ -377,11 +382,6 @@ ifneq ($(KBUILD_SRC),) | |||
377 | $(srctree) $(objtree) $(VERSION) $(PATCHLEVEL) | 382 | $(srctree) $(objtree) $(VERSION) $(PATCHLEVEL) |
378 | endif | 383 | endif |
379 | 384 | ||
380 | # This target generates Kbuild's and Config.in's from *.c files | ||
381 | PHONY += gen_build_files | ||
382 | gen_build_files: | ||
383 | $(Q)$(srctree)/scripts/gen_build_files.sh $(srctree) $(objtree) | ||
384 | |||
385 | # To make sure we do not include .config for any of the *config targets | 385 | # To make sure we do not include .config for any of the *config targets |
386 | # catch them early, and hand them over to scripts/kconfig/Makefile | 386 | # catch them early, and hand them over to scripts/kconfig/Makefile |
387 | # It is allowed to specify more targets when calling make, including | 387 | # It is allowed to specify more targets when calling make, including |
@@ -446,7 +446,7 @@ else | |||
446 | ifeq ($(KBUILD_EXTMOD),) | 446 | ifeq ($(KBUILD_EXTMOD),) |
447 | # Additional helpers built in scripts/ | 447 | # Additional helpers built in scripts/ |
448 | # Carefully list dependencies so we do not try to build scripts twice | 448 | # Carefully list dependencies so we do not try to build scripts twice |
449 | # in parrallel | 449 | # in parallel |
450 | PHONY += scripts | 450 | PHONY += scripts |
451 | scripts: gen_build_files scripts_basic include/config/MARKER | 451 | scripts: gen_build_files scripts_basic include/config/MARKER |
452 | $(Q)$(MAKE) $(build)=$(@) | 452 | $(Q)$(MAKE) $(build)=$(@) |
diff --git a/Makefile.custom b/Makefile.custom index ecba6bd79..fa69dcebb 100644 --- a/Makefile.custom +++ b/Makefile.custom | |||
@@ -2,7 +2,7 @@ | |||
2 | # Build system | 2 | # Build system |
3 | # ========================================================================== | 3 | # ========================================================================== |
4 | 4 | ||
5 | busybox.links: $(srctree)/applets/busybox.mkll $(objtree)/include/autoconf.h $(srctree)/include/applets.h | 5 | busybox.links: $(srctree)/applets/busybox.mkll $(objtree)/include/autoconf.h include/applets.h |
6 | $(Q)-$(SHELL) $^ >$@ | 6 | $(Q)-$(SHELL) $^ >$@ |
7 | 7 | ||
8 | .PHONY: install | 8 | .PHONY: install |
diff --git a/applets/Kbuild.src b/applets/Kbuild.src index a6b0cf6fb..e3bac9681 100644 --- a/applets/Kbuild.src +++ b/applets/Kbuild.src | |||
@@ -27,9 +27,9 @@ HOSTCFLAGS_usage_pod.o = -I$(srctree_slash)include -Iinclude | |||
27 | 27 | ||
28 | applets/applets.o: include/usage_compressed.h include/applet_tables.h | 28 | applets/applets.o: include/usage_compressed.h include/applet_tables.h |
29 | 29 | ||
30 | applets/applet_tables: .config $(srctree_slash)include/applets.h | 30 | applets/applet_tables: .config include/applets.h |
31 | applets/usage: .config $(srctree_slash)include/applets.h | 31 | applets/usage: .config include/applets.h |
32 | applets/usage_pod: .config include/applet_tables.h $(srctree_slash)include/applets.h | 32 | applets/usage_pod: .config include/applet_tables.h include/applets.h |
33 | 33 | ||
34 | quiet_cmd_gen_usage_compressed = GEN include/usage_compressed.h | 34 | quiet_cmd_gen_usage_compressed = GEN include/usage_compressed.h |
35 | cmd_gen_usage_compressed = $(srctree_slash)applets/usage_compressed include/usage_compressed.h applets | 35 | cmd_gen_usage_compressed = $(srctree_slash)applets/usage_compressed include/usage_compressed.h applets |
diff --git a/archival/bbunzip.c b/archival/bbunzip.c index 08db2752c..ce6223514 100644 --- a/archival/bbunzip.c +++ b/archival/bbunzip.c | |||
@@ -304,6 +304,8 @@ int gunzip_main(int argc UNUSED_PARAM, char **argv) | |||
304 | * | 304 | * |
305 | * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. | 305 | * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. |
306 | */ | 306 | */ |
307 | //applet:IF_BUNZIP2(APPLET(bunzip2, _BB_DIR_USR_BIN, _BB_SUID_DROP)) | ||
308 | //applet:IF_BUNZIP2(APPLET_ODDNAME(bzcat, bunzip2, _BB_DIR_USR_BIN, _BB_SUID_DROP, bzcat)) | ||
307 | #if ENABLE_BUNZIP2 | 309 | #if ENABLE_BUNZIP2 |
308 | static | 310 | static |
309 | IF_DESKTOP(long long) int FAST_FUNC unpack_bunzip2(unpack_info_t *info UNUSED_PARAM) | 311 | IF_DESKTOP(long long) int FAST_FUNC unpack_bunzip2(unpack_info_t *info UNUSED_PARAM) |
diff --git a/include/applets.h b/include/applets.src.h index cf8de8eb6..2998a0ea9 100644 --- a/include/applets.h +++ b/include/applets.src.h | |||
@@ -62,6 +62,7 @@ s - suid type: | |||
62 | #endif | 62 | #endif |
63 | 63 | ||
64 | 64 | ||
65 | INSERT | ||
65 | IF_TEST(APPLET_NOFORK([, test, _BB_DIR_USR_BIN, _BB_SUID_DROP, test)) | 66 | IF_TEST(APPLET_NOFORK([, test, _BB_DIR_USR_BIN, _BB_SUID_DROP, test)) |
66 | IF_TEST(APPLET_NOFORK([[, test, _BB_DIR_USR_BIN, _BB_SUID_DROP, test)) | 67 | IF_TEST(APPLET_NOFORK([[, test, _BB_DIR_USR_BIN, _BB_SUID_DROP, test)) |
67 | IF_ACPID(APPLET(acpid, _BB_DIR_SBIN, _BB_SUID_DROP)) | 68 | IF_ACPID(APPLET(acpid, _BB_DIR_SBIN, _BB_SUID_DROP)) |
@@ -82,8 +83,6 @@ IF_BEEP(APPLET(beep, _BB_DIR_USR_BIN, _BB_SUID_DROP)) | |||
82 | IF_BLKID(APPLET(blkid, _BB_DIR_SBIN, _BB_SUID_DROP)) | 83 | IF_BLKID(APPLET(blkid, _BB_DIR_SBIN, _BB_SUID_DROP)) |
83 | IF_BOOTCHARTD(APPLET(bootchartd, _BB_DIR_SBIN, _BB_SUID_DROP)) | 84 | IF_BOOTCHARTD(APPLET(bootchartd, _BB_DIR_SBIN, _BB_SUID_DROP)) |
84 | IF_BRCTL(APPLET(brctl, _BB_DIR_USR_SBIN, _BB_SUID_DROP)) | 85 | IF_BRCTL(APPLET(brctl, _BB_DIR_USR_SBIN, _BB_SUID_DROP)) |
85 | IF_BUNZIP2(APPLET(bunzip2, _BB_DIR_USR_BIN, _BB_SUID_DROP)) | ||
86 | IF_BUNZIP2(APPLET_ODDNAME(bzcat, bunzip2, _BB_DIR_USR_BIN, _BB_SUID_DROP, bzcat)) | ||
87 | IF_BZIP2(APPLET(bzip2, _BB_DIR_USR_BIN, _BB_SUID_DROP)) | 86 | IF_BZIP2(APPLET(bzip2, _BB_DIR_USR_BIN, _BB_SUID_DROP)) |
88 | IF_CAL(APPLET(cal, _BB_DIR_USR_BIN, _BB_SUID_DROP)) | 87 | IF_CAL(APPLET(cal, _BB_DIR_USR_BIN, _BB_SUID_DROP)) |
89 | IF_CAT(APPLET_NOFORK(cat, cat, _BB_DIR_BIN, _BB_SUID_DROP, cat)) | 88 | IF_CAT(APPLET_NOFORK(cat, cat, _BB_DIR_BIN, _BB_SUID_DROP, cat)) |
diff --git a/scripts/Makefile.IMA b/scripts/Makefile.IMA index a34db50f4..bddd70229 100644 --- a/scripts/Makefile.IMA +++ b/scripts/Makefile.IMA | |||
@@ -203,5 +203,5 @@ applets/applet_tables: include/autoconf.h | |||
203 | include/usage_compressed.h: $(srctree)/include/usage.h applets/usage | 203 | include/usage_compressed.h: $(srctree)/include/usage.h applets/usage |
204 | $(srctree)/applets/usage_compressed include/usage_compressed.h applets | 204 | $(srctree)/applets/usage_compressed include/usage_compressed.h applets |
205 | 205 | ||
206 | include/applet_tables.h: $(srctree)/include/applets.h | 206 | include/applet_tables.h: include/applets.h |
207 | applets/applet_tables include/applet_tables.h | 207 | applets/applet_tables include/applet_tables.h |
diff --git a/scripts/gen_build_files.sh b/scripts/gen_build_files.sh index b3aa132a3..44e8c1744 100755 --- a/scripts/gen_build_files.sh +++ b/scripts/gen_build_files.sh | |||
@@ -7,6 +7,27 @@ cd -- "$2" || { echo "Syntax: $0 SRCTREE OBJTREE"; exit 1; } | |||
7 | 7 | ||
8 | srctree="$1" | 8 | srctree="$1" |
9 | 9 | ||
10 | # (Re)generate include/applets.h | ||
11 | src="$srctree/include/applets.src.h" | ||
12 | dst="include/applets.h" | ||
13 | s=`sed -n 's@^//applet:@@p' -- */*.c */*/*.c` | ||
14 | echo "/* DO NOT EDIT. This file is generated from applets.src.h */" >"$dst.$$.tmp" | ||
15 | # Why "IFS='' read -r REPLY"?? | ||
16 | # This atrocity is needed to read lines without mangling. | ||
17 | # IFS='' prevents whitespace trimming, | ||
18 | # -r suppresses backslash handling. | ||
19 | while IFS='' read -r REPLY; do | ||
20 | test x"$REPLY" = x"INSERT" && REPLY="$s" | ||
21 | printf "%s\n" "$REPLY" | ||
22 | done <"$src" >>"$dst.$$.tmp" | ||
23 | if test -f "$dst" && cmp -s "$dst.$$.tmp" "$dst"; then | ||
24 | rm -- "$dst.$$.tmp" | ||
25 | else | ||
26 | echo " GEN $dst" | ||
27 | mv -- "$dst.$$.tmp" "$dst" | ||
28 | fi | ||
29 | |||
30 | # (Re)generate */Kbuild and */Config.in | ||
10 | find -type d | while read -r d; do | 31 | find -type d | while read -r d; do |
11 | d="${d#./}" | 32 | d="${d#./}" |
12 | src="$srctree/$d/Kbuild.src" | 33 | src="$srctree/$d/Kbuild.src" |
@@ -15,17 +36,12 @@ find -type d | while read -r d; do | |||
15 | #echo " CHK $dst" | 36 | #echo " CHK $dst" |
16 | 37 | ||
17 | s=`sed -n 's@^//kbuild:@@p' -- "$srctree/$d"/*.c` | 38 | s=`sed -n 's@^//kbuild:@@p' -- "$srctree/$d"/*.c` |
18 | echo "# DO NOT EDIT. This file is generated from Kbuild.src" >"$dst.$$.tmp" | ||
19 | 39 | ||
20 | # Why "IFS='' read -r REPLY"?? | 40 | echo "# DO NOT EDIT. This file is generated from Kbuild.src" >"$dst.$$.tmp" |
21 | # This atrocity is needed to read lines without mangling. | ||
22 | # IFS='' prevents whitespace trimming, | ||
23 | # -r suppresses backslash handling. | ||
24 | while IFS='' read -r REPLY; do | 41 | while IFS='' read -r REPLY; do |
25 | test x"$REPLY" = x"INSERT" && REPLY="$s" | 42 | test x"$REPLY" = x"INSERT" && REPLY="$s" |
26 | printf "%s\n" "$REPLY" | 43 | printf "%s\n" "$REPLY" |
27 | done <"$src" >>"$dst.$$.tmp" | 44 | done <"$src" >>"$dst.$$.tmp" |
28 | |||
29 | if test -f "$dst" && cmp -s "$dst.$$.tmp" "$dst"; then | 45 | if test -f "$dst" && cmp -s "$dst.$$.tmp" "$dst"; then |
30 | rm -- "$dst.$$.tmp" | 46 | rm -- "$dst.$$.tmp" |
31 | else | 47 | else |
@@ -40,13 +56,12 @@ find -type d | while read -r d; do | |||
40 | #echo " CHK $dst" | 56 | #echo " CHK $dst" |
41 | 57 | ||
42 | s=`sed -n 's@^//config:@@p' -- "$srctree/$d"/*.c` | 58 | s=`sed -n 's@^//config:@@p' -- "$srctree/$d"/*.c` |
43 | echo "# DO NOT EDIT. This file is generated from Config.src" >"$dst.$$.tmp" | ||
44 | 59 | ||
60 | echo "# DO NOT EDIT. This file is generated from Config.src" >"$dst.$$.tmp" | ||
45 | while IFS='' read -r REPLY; do | 61 | while IFS='' read -r REPLY; do |
46 | test x"$REPLY" = x"INSERT" && REPLY="$s" | 62 | test x"$REPLY" = x"INSERT" && REPLY="$s" |
47 | printf "%s\n" "$REPLY" | 63 | printf "%s\n" "$REPLY" |
48 | done <"$src" >>"$dst.$$.tmp" | 64 | done <"$src" >>"$dst.$$.tmp" |
49 | |||
50 | if test -f "$dst" && cmp -s "$dst.$$.tmp" "$dst"; then | 65 | if test -f "$dst" && cmp -s "$dst.$$.tmp" "$dst"; then |
51 | rm -- "$dst.$$.tmp" | 66 | rm -- "$dst.$$.tmp" |
52 | else | 67 | else |