aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2010-06-06 00:53:45 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2010-06-06 00:53:45 +0200
commit6c5bf0d347faded028e15d523c26a0d64c6d3920 (patch)
tree9dbe0229ec0d941c9efabb88571e6140d8e71951
parent0e5ba0843b86a78d2d98a5fbaac8d33fe041f10e (diff)
downloadbusybox-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--Makefile14
-rw-r--r--Makefile.custom2
-rw-r--r--applets/Kbuild.src6
-rw-r--r--archival/bbunzip.c2
-rw-r--r--include/applets.src.h (renamed from include/applets.h)3
-rw-r--r--scripts/Makefile.IMA2
-rwxr-xr-xscripts/gen_build_files.sh31
7 files changed, 38 insertions, 22 deletions
diff --git a/Makefile b/Makefile
index c231092be..483842f06 100644
--- a/Makefile
+++ b/Makefile
@@ -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.
359scripts/basic/%: scripts_basic ; 359scripts/basic/%: scripts_basic ;
360 360
361# This target generates Kbuild's and Config.in's from *.c files
362PHONY += gen_build_files
363gen_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
364PHONY += applets_dir 369PHONY += applets_dir
365applets_dir: scripts_basic 370applets_dir: scripts_basic gen_build_files
366 $(Q)$(MAKE) $(build)=applets 371 $(Q)$(MAKE) $(build)=applets
367 372
368applets/%: applets_dir ; 373applets/%: applets_dir ;
@@ -377,11 +382,6 @@ ifneq ($(KBUILD_SRC),)
377 $(srctree) $(objtree) $(VERSION) $(PATCHLEVEL) 382 $(srctree) $(objtree) $(VERSION) $(PATCHLEVEL)
378endif 383endif
379 384
380# This target generates Kbuild's and Config.in's from *.c files
381PHONY += gen_build_files
382gen_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
446ifeq ($(KBUILD_EXTMOD),) 446ifeq ($(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
450PHONY += scripts 450PHONY += scripts
451scripts: gen_build_files scripts_basic include/config/MARKER 451scripts: 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
5busybox.links: $(srctree)/applets/busybox.mkll $(objtree)/include/autoconf.h $(srctree)/include/applets.h 5busybox.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
28applets/applets.o: include/usage_compressed.h include/applet_tables.h 28applets/applets.o: include/usage_compressed.h include/applet_tables.h
29 29
30applets/applet_tables: .config $(srctree_slash)include/applets.h 30applets/applet_tables: .config include/applets.h
31applets/usage: .config $(srctree_slash)include/applets.h 31applets/usage: .config include/applets.h
32applets/usage_pod: .config include/applet_tables.h $(srctree_slash)include/applets.h 32applets/usage_pod: .config include/applet_tables.h include/applets.h
33 33
34quiet_cmd_gen_usage_compressed = GEN include/usage_compressed.h 34quiet_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
308static 310static
309IF_DESKTOP(long long) int FAST_FUNC unpack_bunzip2(unpack_info_t *info UNUSED_PARAM) 311IF_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
65INSERT
65IF_TEST(APPLET_NOFORK([, test, _BB_DIR_USR_BIN, _BB_SUID_DROP, test)) 66IF_TEST(APPLET_NOFORK([, test, _BB_DIR_USR_BIN, _BB_SUID_DROP, test))
66IF_TEST(APPLET_NOFORK([[, test, _BB_DIR_USR_BIN, _BB_SUID_DROP, test)) 67IF_TEST(APPLET_NOFORK([[, test, _BB_DIR_USR_BIN, _BB_SUID_DROP, test))
67IF_ACPID(APPLET(acpid, _BB_DIR_SBIN, _BB_SUID_DROP)) 68IF_ACPID(APPLET(acpid, _BB_DIR_SBIN, _BB_SUID_DROP))
@@ -82,8 +83,6 @@ IF_BEEP(APPLET(beep, _BB_DIR_USR_BIN, _BB_SUID_DROP))
82IF_BLKID(APPLET(blkid, _BB_DIR_SBIN, _BB_SUID_DROP)) 83IF_BLKID(APPLET(blkid, _BB_DIR_SBIN, _BB_SUID_DROP))
83IF_BOOTCHARTD(APPLET(bootchartd, _BB_DIR_SBIN, _BB_SUID_DROP)) 84IF_BOOTCHARTD(APPLET(bootchartd, _BB_DIR_SBIN, _BB_SUID_DROP))
84IF_BRCTL(APPLET(brctl, _BB_DIR_USR_SBIN, _BB_SUID_DROP)) 85IF_BRCTL(APPLET(brctl, _BB_DIR_USR_SBIN, _BB_SUID_DROP))
85IF_BUNZIP2(APPLET(bunzip2, _BB_DIR_USR_BIN, _BB_SUID_DROP))
86IF_BUNZIP2(APPLET_ODDNAME(bzcat, bunzip2, _BB_DIR_USR_BIN, _BB_SUID_DROP, bzcat))
87IF_BZIP2(APPLET(bzip2, _BB_DIR_USR_BIN, _BB_SUID_DROP)) 86IF_BZIP2(APPLET(bzip2, _BB_DIR_USR_BIN, _BB_SUID_DROP))
88IF_CAL(APPLET(cal, _BB_DIR_USR_BIN, _BB_SUID_DROP)) 87IF_CAL(APPLET(cal, _BB_DIR_USR_BIN, _BB_SUID_DROP))
89IF_CAT(APPLET_NOFORK(cat, cat, _BB_DIR_BIN, _BB_SUID_DROP, cat)) 88IF_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
203include/usage_compressed.h: $(srctree)/include/usage.h applets/usage 203include/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
206include/applet_tables.h: $(srctree)/include/applets.h 206include/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
8srctree="$1" 8srctree="$1"
9 9
10# (Re)generate include/applets.h
11src="$srctree/include/applets.src.h"
12dst="include/applets.h"
13s=`sed -n 's@^//applet:@@p' -- */*.c */*/*.c`
14echo "/* 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.
19while IFS='' read -r REPLY; do
20 test x"$REPLY" = x"INSERT" && REPLY="$s"
21 printf "%s\n" "$REPLY"
22done <"$src" >>"$dst.$$.tmp"
23if test -f "$dst" && cmp -s "$dst.$$.tmp" "$dst"; then
24 rm -- "$dst.$$.tmp"
25else
26 echo " GEN $dst"
27 mv -- "$dst.$$.tmp" "$dst"
28fi
29
30# (Re)generate */Kbuild and */Config.in
10find -type d | while read -r d; do 31find -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