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-6c5bf0d347faded028e15d523c26a0d64c6d3920.tar.gz
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:
# To avoid any implicit rule to kick in, define an empty command.
scripts/basic/%: scripts_basic ;
+# This target generates Kbuild's and Config.in's from *.c files
+PHONY += gen_build_files
+gen_build_files:
+ $(Q)$(srctree)/scripts/gen_build_files.sh $(srctree) $(objtree)
+
# bbox: we have helpers in applets/
# we depend on scripts_basic, since scripts/basic/fixdep
# must be built before any other host prog
PHONY += applets_dir
-applets_dir: scripts_basic
+applets_dir: scripts_basic gen_build_files
$(Q)$(MAKE) $(build)=applets
applets/%: applets_dir ;
@@ -377,11 +382,6 @@ ifneq ($(KBUILD_SRC),)
$(srctree) $(objtree) $(VERSION) $(PATCHLEVEL)
endif
-# This target generates Kbuild's and Config.in's from *.c files
-PHONY += gen_build_files
-gen_build_files:
- $(Q)$(srctree)/scripts/gen_build_files.sh $(srctree) $(objtree)
-
# To make sure we do not include .config for any of the *config targets
# catch them early, and hand them over to scripts/kconfig/Makefile
# It is allowed to specify more targets when calling make, including
@@ -446,7 +446,7 @@ else
ifeq ($(KBUILD_EXTMOD),)
# Additional helpers built in scripts/
# Carefully list dependencies so we do not try to build scripts twice
-# in parrallel
+# in parallel
PHONY += scripts
scripts: gen_build_files scripts_basic include/config/MARKER
$(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 @@
# Build system
# ==========================================================================
-busybox.links: $(srctree)/applets/busybox.mkll $(objtree)/include/autoconf.h $(srctree)/include/applets.h
+busybox.links: $(srctree)/applets/busybox.mkll $(objtree)/include/autoconf.h include/applets.h
$(Q)-$(SHELL) $^ >$@
.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
applets/applets.o: include/usage_compressed.h include/applet_tables.h
-applets/applet_tables: .config $(srctree_slash)include/applets.h
-applets/usage: .config $(srctree_slash)include/applets.h
-applets/usage_pod: .config include/applet_tables.h $(srctree_slash)include/applets.h
+applets/applet_tables: .config include/applets.h
+applets/usage: .config include/applets.h
+applets/usage_pod: .config include/applet_tables.h include/applets.h
quiet_cmd_gen_usage_compressed = GEN include/usage_compressed.h
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)
*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
+//applet:IF_BUNZIP2(APPLET(bunzip2, _BB_DIR_USR_BIN, _BB_SUID_DROP))
+//applet:IF_BUNZIP2(APPLET_ODDNAME(bzcat, bunzip2, _BB_DIR_USR_BIN, _BB_SUID_DROP, bzcat))
#if ENABLE_BUNZIP2
static
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:
#endif
+INSERT
IF_TEST(APPLET_NOFORK([, test, _BB_DIR_USR_BIN, _BB_SUID_DROP, test))
IF_TEST(APPLET_NOFORK([[, test, _BB_DIR_USR_BIN, _BB_SUID_DROP, test))
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))
IF_BLKID(APPLET(blkid, _BB_DIR_SBIN, _BB_SUID_DROP))
IF_BOOTCHARTD(APPLET(bootchartd, _BB_DIR_SBIN, _BB_SUID_DROP))
IF_BRCTL(APPLET(brctl, _BB_DIR_USR_SBIN, _BB_SUID_DROP))
-IF_BUNZIP2(APPLET(bunzip2, _BB_DIR_USR_BIN, _BB_SUID_DROP))
-IF_BUNZIP2(APPLET_ODDNAME(bzcat, bunzip2, _BB_DIR_USR_BIN, _BB_SUID_DROP, bzcat))
IF_BZIP2(APPLET(bzip2, _BB_DIR_USR_BIN, _BB_SUID_DROP))
IF_CAL(APPLET(cal, _BB_DIR_USR_BIN, _BB_SUID_DROP))
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
include/usage_compressed.h: $(srctree)/include/usage.h applets/usage
$(srctree)/applets/usage_compressed include/usage_compressed.h applets
-include/applet_tables.h: $(srctree)/include/applets.h
+include/applet_tables.h: include/applets.h
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; }
srctree="$1"
+# (Re)generate include/applets.h
+src="$srctree/include/applets.src.h"
+dst="include/applets.h"
+s=`sed -n 's@^//applet:@@p' -- */*.c */*/*.c`
+echo "/* DO NOT EDIT. This file is generated from applets.src.h */" >"$dst.$$.tmp"
+# Why "IFS='' read -r REPLY"??
+# This atrocity is needed to read lines without mangling.
+# IFS='' prevents whitespace trimming,
+# -r suppresses backslash handling.
+while IFS='' read -r REPLY; do
+ test x"$REPLY" = x"INSERT" && REPLY="$s"
+ printf "%s\n" "$REPLY"
+done <"$src" >>"$dst.$$.tmp"
+if test -f "$dst" && cmp -s "$dst.$$.tmp" "$dst"; then
+ rm -- "$dst.$$.tmp"
+else
+ echo " GEN $dst"
+ mv -- "$dst.$$.tmp" "$dst"
+fi
+
+# (Re)generate */Kbuild and */Config.in
find -type d | while read -r d; do
d="${d#./}"
src="$srctree/$d/Kbuild.src"
@@ -15,17 +36,12 @@ find -type d | while read -r d; do
#echo " CHK $dst"
s=`sed -n 's@^//kbuild:@@p' -- "$srctree/$d"/*.c`
- echo "# DO NOT EDIT. This file is generated from Kbuild.src" >"$dst.$$.tmp"
- # Why "IFS='' read -r REPLY"??
- # This atrocity is needed to read lines without mangling.
- # IFS='' prevents whitespace trimming,
- # -r suppresses backslash handling.
+ echo "# DO NOT EDIT. This file is generated from Kbuild.src" >"$dst.$$.tmp"
while IFS='' read -r REPLY; do
test x"$REPLY" = x"INSERT" && REPLY="$s"
printf "%s\n" "$REPLY"
done <"$src" >>"$dst.$$.tmp"
-
if test -f "$dst" && cmp -s "$dst.$$.tmp" "$dst"; then
rm -- "$dst.$$.tmp"
else
@@ -40,13 +56,12 @@ find -type d | while read -r d; do
#echo " CHK $dst"
s=`sed -n 's@^//config:@@p' -- "$srctree/$d"/*.c`
- echo "# DO NOT EDIT. This file is generated from Config.src" >"$dst.$$.tmp"
+ echo "# DO NOT EDIT. This file is generated from Config.src" >"$dst.$$.tmp"
while IFS='' read -r REPLY; do
test x"$REPLY" = x"INSERT" && REPLY="$s"
printf "%s\n" "$REPLY"
done <"$src" >>"$dst.$$.tmp"
-
if test -f "$dst" && cmp -s "$dst.$$.tmp" "$dst"; then
rm -- "$dst.$$.tmp"
else