Move commands into "posix", "lsb", and "other" menus/directories.
authorRob Landley <rob@landley.net>
Sat, 25 Aug 2012 19:25:22 +0000 (14:25 -0500)
committerRob Landley <rob@landley.net>
Sat, 25 Aug 2012 19:25:22 +0000 (14:25 -0500)
96 files changed:
Config.in
Makefile
scripts/genconfig.sh
scripts/make.sh
toys/lsb/dmesg.c [moved from toys/dmesg.c with 100% similarity]
toys/lsb/hostname.c [moved from toys/hostname.c with 100% similarity]
toys/lsb/killall.c [moved from toys/killall.c with 100% similarity]
toys/lsb/mknod.c [moved from toys/mknod.c with 100% similarity]
toys/lsb/mktemp.c [moved from toys/mktemp.c with 100% similarity]
toys/lsb/passwd.c [moved from toys/passwd.c with 100% similarity]
toys/lsb/pidof.c [moved from toys/pidof.c with 100% similarity]
toys/lsb/seq.c [moved from toys/seq.c with 100% similarity]
toys/lsb/sync.c [moved from toys/sync.c with 100% similarity]
toys/other/bzcat.c [moved from toys/bzcat.c with 100% similarity]
toys/other/catv.c [moved from toys/catv.c with 100% similarity]
toys/other/chroot.c [moved from toys/chroot.c with 100% similarity]
toys/other/chvt.c [moved from toys/chvt.c with 100% similarity]
toys/other/clear.c [moved from toys/clear.c with 100% similarity]
toys/other/count.c [moved from toys/count.c with 100% similarity]
toys/other/dos2unix.c [moved from toys/dos2unix.c with 100% similarity]
toys/other/free.c [moved from toys/free.c with 100% similarity]
toys/other/hello.c [moved from toys/hello.c with 100% similarity]
toys/other/help.c [moved from toys/help.c with 100% similarity]
toys/other/insmod.c [moved from toys/insmod.c with 100% similarity]
toys/other/login.c [moved from toys/login.c with 100% similarity]
toys/other/lsmod.c [moved from toys/lsmod.c with 100% similarity]
toys/other/mdev.c [moved from toys/mdev.c with 100% similarity]
toys/other/mke2fs.c [moved from toys/mke2fs.c with 100% similarity]
toys/other/mkswap.c [moved from toys/mkswap.c with 100% similarity]
toys/other/modinfo.c [moved from toys/modinfo.c with 100% similarity]
toys/other/mountpoint.c [moved from toys/mountpoint.c with 100% similarity]
toys/other/netcat.c [moved from toys/netcat.c with 100% similarity]
toys/other/oneit.c [moved from toys/oneit.c with 100% similarity]
toys/other/printenv.c [moved from toys/printenv.c with 100% similarity]
toys/other/readlink.c [moved from toys/readlink.c with 100% similarity]
toys/other/realpath.c [moved from toys/realpath.c with 100% similarity]
toys/other/rmmod.c [moved from toys/rmmod.c with 100% similarity]
toys/other/setsid.c [moved from toys/setsid.c with 100% similarity]
toys/other/sha1sum.c [moved from toys/sha1sum.c with 100% similarity]
toys/other/swapoff.c [moved from toys/swapoff.c with 100% similarity]
toys/other/swapon.c [moved from toys/swapon.c with 100% similarity]
toys/other/tac.c [moved from toys/tac.c with 100% similarity]
toys/other/taskset.c [moved from toys/taskset.c with 100% similarity]
toys/other/toysh.c [moved from toys/toysh.c with 100% similarity]
toys/other/truncate.c [moved from toys/truncate.c with 100% similarity]
toys/other/unshare.c [moved from toys/unshare.c with 100% similarity]
toys/other/uptime.c [moved from toys/uptime.c with 100% similarity]
toys/other/usleep.c [moved from toys/usleep.c with 100% similarity]
toys/other/vmstat.c [moved from toys/vmstat.c with 100% similarity]
toys/other/w.c [moved from toys/w.c with 100% similarity]
toys/other/which.c [moved from toys/which.c with 100% similarity]
toys/other/whoami.c [moved from toys/whoami.c with 100% similarity]
toys/other/yes.c [moved from toys/yes.c with 100% similarity]
toys/posix/basename.c [moved from toys/basename.c with 100% similarity]
toys/posix/cal.c [moved from toys/cal.c with 100% similarity]
toys/posix/cat.c [moved from toys/cat.c with 100% similarity]
toys/posix/chgrp.c [moved from toys/chgrp.c with 100% similarity]
toys/posix/chmod.c [moved from toys/chmod.c with 100% similarity]
toys/posix/cksum.c [moved from toys/cksum.c with 100% similarity]
toys/posix/cmp.c [moved from toys/cmp.c with 100% similarity]
toys/posix/comm.c [moved from toys/comm.c with 100% similarity]
toys/posix/cp.c [moved from toys/cp.c with 100% similarity]
toys/posix/date.c [moved from toys/date.c with 100% similarity]
toys/posix/df.c [moved from toys/df.c with 100% similarity]
toys/posix/dirname.c [moved from toys/dirname.c with 100% similarity]
toys/posix/echo.c [moved from toys/echo.c with 100% similarity]
toys/posix/env.c [moved from toys/env.c with 100% similarity]
toys/posix/false.c [moved from toys/false.c with 100% similarity]
toys/posix/head.c [moved from toys/head.c with 100% similarity]
toys/posix/id.c [moved from toys/id.c with 100% similarity]
toys/posix/kill.c [moved from toys/kill.c with 100% similarity]
toys/posix/link.c [moved from toys/link.c with 100% similarity]
toys/posix/ln.c [moved from toys/ln.c with 100% similarity]
toys/posix/logname.c [moved from toys/logname.c with 100% similarity]
toys/posix/ls.c [moved from toys/ls.c with 100% similarity]
toys/posix/mkdir.c [moved from toys/mkdir.c with 100% similarity]
toys/posix/mkfifo.c [moved from toys/mkfifo.c with 100% similarity]
toys/posix/nice.c [moved from toys/nice.c with 100% similarity]
toys/posix/nohup.c [moved from toys/nohup.c with 100% similarity]
toys/posix/od.c [moved from toys/od.c with 100% similarity]
toys/posix/patch.c [moved from toys/patch.c with 100% similarity]
toys/posix/pwd.c [moved from toys/pwd.c with 100% similarity]
toys/posix/rmdir.c [moved from toys/rmdir.c with 100% similarity]
toys/posix/sed.c [moved from toys/sed.c with 100% similarity]
toys/posix/sleep.c [moved from toys/sleep.c with 100% similarity]
toys/posix/sort.c [moved from toys/sort.c with 100% similarity]
toys/posix/tail.c [moved from toys/tail.c with 100% similarity]
toys/posix/tee.c [moved from toys/tee.c with 100% similarity]
toys/posix/true.c [moved from toys/true.c with 100% similarity]
toys/posix/tty.c [moved from toys/tty.c with 100% similarity]
toys/posix/uname.c [moved from toys/uname.c with 100% similarity]
toys/posix/uniq.c [moved from toys/uniq.c with 100% similarity]
toys/posix/unlink.c [moved from toys/unlink.c with 100% similarity]
toys/posix/wc.c [moved from toys/wc.c with 100% similarity]
toys/posix/who.c [moved from toys/who.c with 100% similarity]
toys/posix/xargs.c [moved from toys/xargs.c with 100% similarity]

index 7378fbc..02137d8 100644 (file)
--- a/Config.in
+++ b/Config.in
@@ -1,6 +1,6 @@
 mainmenu "ToyBox Configuration"
 
-menu "Global settings"
+menu "Toybox global settings"
 
 config TOYBOX
        bool
@@ -46,6 +46,6 @@ endmenu
 
 source generated/Config.probed
 
-menu "Toys"
+comment ""
+
 source generated/Config.in
-endmenu
index b224f3e..bbab258 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -3,7 +3,7 @@
 
 all: toybox
 
-toybox toybox_unstripped: .config *.[ch] lib/*.[ch] toys/*.[ch] scripts/*.sh
+toybox toybox_unstripped: .config *.[ch] lib/*.[ch] toys/*.h toys/*/*.c scripts/*.sh
        scripts/make.sh
 
 .PHONY: clean distclean baseline bloatcheck install install_flat \
@@ -12,7 +12,7 @@ toybox toybox_unstripped: .config *.[ch] lib/*.[ch] toys/*.[ch] scripts/*.sh
 include kconfig/Makefile
 
 $(KCONFIG_TOP): generated/Config.in
-generated/Config.in: toys/*.c scripts/genconfig.sh
+generated/Config.in: toys/*/*.c scripts/genconfig.sh
        scripts/genconfig.sh
 
 HOSTCC?=cc
index 2334d8a..accf0db 100755 (executable)
@@ -26,14 +26,25 @@ EOF
 
 genconfig()
 {
-  # extract config stanzas from each command source file, in alphabetical order
-
-  for i in $(ls -1 toys/*.c)
+  # I could query the directory here, but I want to control the order
+  # and capitalization in the menu
+  for j in Posix LSB Other
   do
-    # Grab the config block for Config.in
-    echo "# $i"
-    sed -n '/^\*\//q;/^config [A-Z]/,$p' $i || return 1
+    echo "menu \"$j commands\""
     echo
+
+    DIR=$(echo $j | tr A-Z a-z)
+
+    # extract config stanzas from each source file, in alphabetical order
+    for i in $(ls -1 toys/$DIR/*.c)
+    do
+      # Grab the config block for Config.in
+      echo "# $i"
+      sed -n '/^\*\//q;/^config [A-Z]/,$p' $i || return 1
+      echo
+    done
+
+    echo endmenu
   done
 }
 
index b61d5b9..2f52b21 100755 (executable)
@@ -4,19 +4,27 @@
 
 source ./configure
 
+if [ -z ".config" ]
+then
+  echo "No .config (see "make help" for configuration options)."
+  exit 1
+fi
+
 echo "Extract configuration information from toys/*.c files..."
 scripts/genconfig.sh
 
-echo "Generate headers from toys/*.c..."
+echo "Generate headers from toys/*/*.c..."
 
 # Create a list of all the applets toybox can provide.  Note that the first
 # entry is out of order on purpose (the toybox multiplexer applet must be the
 # first element of the array).  The rest must be sorted in alphabetical order
 # for fast binary search.
 
+echo "generated/newtoys.h"
+
 function newtoys()
 {
-  for i in toys/*.c
+  for i in toys/*/*.c
   do
     sed -n -e '1,/^config [A-Z]/s/^USE_/&/p' $i || exit 1
   done
@@ -25,13 +33,13 @@ echo "NEWTOY(toybox, NULL, TOYFLAG_STAYROOT)" > generated/newtoys.h
 newtoys | sed 's/\(.*TOY(\)\([^,]*\),\(.*\)/\2 \1\2,\3/' | sort -k 1,1 \
        | sed 's/[^ ]* //'  >> generated/newtoys.h
 
-# Extract global structure definitions and flag definitions from toys/*.c
+# Extract global structure definitions and flag definitions from toys/*/*.c
 
 function getglobals()
 {
-  for i in toys/*.c
+  for i in toys/*/*.c
   do
-    NAME="$(echo $i | sed 's@toys/\(.*\)\.c@\1@')"
+    NAME="$(echo $i | sed 's@.*/\(.*\)\.c@\1@')"
 
     echo -e "// $i\n"
     sed -n -e '/^DEFINE_GLOBALS(/,/^)/b got;b;:got' \
@@ -58,6 +66,8 @@ function getglobals()
   done
 }
 
+echo "generated/globals.h"
+
 GLOBSTRUCT="$(getglobals)"
 (
   echo "$GLOBSTRUCT"
@@ -67,6 +77,7 @@ GLOBSTRUCT="$(getglobals)"
   echo "} this;"
 ) > generated/globals.h
 
+echo "generated/help.h"
 # Only recreate generated/help.h if python is installed
 if [ ! -z "$(which python)" ] && [ ! -z "$(grep 'CONFIG_HELP=y' .config)" ]
 then
@@ -100,20 +111,24 @@ sed -n \
   -e 's/.*/#define USE_&(...) __VA_ARGS__/p' \
   .config > generated/config.h || exit 1
 
-# Extract a list of toys/*.c files to compile from the data in ".config" with
-# sed, sort, and tr:
+# Extract a list of toys/*/*.c files to compile from the data in ".config":
 
 # 1) Grab the XXX part of all CONFIG_XXX entries, removing everything after the
 # second underline
 # 2) Sort the list, keeping only one of each entry.
 # 3) Convert to lower case.
 # 4) Remove toybox itself from the list (as that indicates global symbols).
-# 5) Add "toys/" prefix and ".c" suffix.
+# 5) Add "toys/*/" prefix and ".c" suffix.
 
-TOYFILES=$(cat .config | sed -nre 's/^CONFIG_(.*)=y/\1/;t skip;b;:skip;s/_.*//;p' | sort -u | tr A-Z a-z | grep -v '^toybox$' | sed 's@\(.*\)@toys/\1.c@' )
+TOYFILES=$(sed -nre 's/^CONFIG_(.*)=y/\1/;t skip;b;:skip;s/_.*//;p' < .config | sort -u | tr A-Z a-z | grep -v '^toybox$' | sed 's@\(.*\)@toys/\*/\1.c@')
 
 echo "Library probe..."
 
+# We trust --as-needed to remove each library if we don't use any symbols
+# out of it, this loop is because the compiler has no way to ignore a library
+# that doesn't exist, so we have to detect and skip nonexistent libraries
+# for it.
+
 OPTLIBS="$(for i in util crypt m; do echo "int main(int argc, char *argv[]) {return 0;}" | ${CROSS_COMPILE}${CC} -xc - -o /dev/null -Wl,--as-needed -l$i > /dev/null 2>/dev/null && echo -l$i; done)"
 
 echo "Compile toybox..."
similarity index 100%
rename from toys/dmesg.c
rename to toys/lsb/dmesg.c
similarity index 100%
rename from toys/hostname.c
rename to toys/lsb/hostname.c
similarity index 100%
rename from toys/killall.c
rename to toys/lsb/killall.c
similarity index 100%
rename from toys/mknod.c
rename to toys/lsb/mknod.c
similarity index 100%
rename from toys/mktemp.c
rename to toys/lsb/mktemp.c
similarity index 100%
rename from toys/passwd.c
rename to toys/lsb/passwd.c
similarity index 100%
rename from toys/pidof.c
rename to toys/lsb/pidof.c
similarity index 100%
rename from toys/seq.c
rename to toys/lsb/seq.c
similarity index 100%
rename from toys/sync.c
rename to toys/lsb/sync.c
similarity index 100%
rename from toys/bzcat.c
rename to toys/other/bzcat.c
similarity index 100%
rename from toys/catv.c
rename to toys/other/catv.c
similarity index 100%
rename from toys/chroot.c
rename to toys/other/chroot.c
similarity index 100%
rename from toys/chvt.c
rename to toys/other/chvt.c
similarity index 100%
rename from toys/clear.c
rename to toys/other/clear.c
similarity index 100%
rename from toys/count.c
rename to toys/other/count.c
similarity index 100%
rename from toys/dos2unix.c
rename to toys/other/dos2unix.c
similarity index 100%
rename from toys/free.c
rename to toys/other/free.c
similarity index 100%
rename from toys/hello.c
rename to toys/other/hello.c
similarity index 100%
rename from toys/help.c
rename to toys/other/help.c
similarity index 100%
rename from toys/insmod.c
rename to toys/other/insmod.c
similarity index 100%
rename from toys/login.c
rename to toys/other/login.c
similarity index 100%
rename from toys/lsmod.c
rename to toys/other/lsmod.c
similarity index 100%
rename from toys/mdev.c
rename to toys/other/mdev.c
similarity index 100%
rename from toys/mke2fs.c
rename to toys/other/mke2fs.c
similarity index 100%
rename from toys/mkswap.c
rename to toys/other/mkswap.c
similarity index 100%
rename from toys/modinfo.c
rename to toys/other/modinfo.c
similarity index 100%
rename from toys/mountpoint.c
rename to toys/other/mountpoint.c
similarity index 100%
rename from toys/netcat.c
rename to toys/other/netcat.c
similarity index 100%
rename from toys/oneit.c
rename to toys/other/oneit.c
similarity index 100%
rename from toys/printenv.c
rename to toys/other/printenv.c
similarity index 100%
rename from toys/readlink.c
rename to toys/other/readlink.c
similarity index 100%
rename from toys/realpath.c
rename to toys/other/realpath.c
similarity index 100%
rename from toys/rmmod.c
rename to toys/other/rmmod.c
similarity index 100%
rename from toys/setsid.c
rename to toys/other/setsid.c
similarity index 100%
rename from toys/sha1sum.c
rename to toys/other/sha1sum.c
similarity index 100%
rename from toys/swapoff.c
rename to toys/other/swapoff.c
similarity index 100%
rename from toys/swapon.c
rename to toys/other/swapon.c
similarity index 100%
rename from toys/tac.c
rename to toys/other/tac.c
similarity index 100%
rename from toys/taskset.c
rename to toys/other/taskset.c
similarity index 100%
rename from toys/toysh.c
rename to toys/other/toysh.c
similarity index 100%
rename from toys/truncate.c
rename to toys/other/truncate.c
similarity index 100%
rename from toys/unshare.c
rename to toys/other/unshare.c
similarity index 100%
rename from toys/uptime.c
rename to toys/other/uptime.c
similarity index 100%
rename from toys/usleep.c
rename to toys/other/usleep.c
similarity index 100%
rename from toys/vmstat.c
rename to toys/other/vmstat.c
similarity index 100%
rename from toys/w.c
rename to toys/other/w.c
similarity index 100%
rename from toys/which.c
rename to toys/other/which.c
similarity index 100%
rename from toys/whoami.c
rename to toys/other/whoami.c
similarity index 100%
rename from toys/yes.c
rename to toys/other/yes.c
similarity index 100%
rename from toys/basename.c
rename to toys/posix/basename.c
similarity index 100%
rename from toys/cal.c
rename to toys/posix/cal.c
similarity index 100%
rename from toys/cat.c
rename to toys/posix/cat.c
similarity index 100%
rename from toys/chgrp.c
rename to toys/posix/chgrp.c
similarity index 100%
rename from toys/chmod.c
rename to toys/posix/chmod.c
similarity index 100%
rename from toys/cksum.c
rename to toys/posix/cksum.c
similarity index 100%
rename from toys/cmp.c
rename to toys/posix/cmp.c
similarity index 100%
rename from toys/comm.c
rename to toys/posix/comm.c
similarity index 100%
rename from toys/cp.c
rename to toys/posix/cp.c
similarity index 100%
rename from toys/date.c
rename to toys/posix/date.c
similarity index 100%
rename from toys/df.c
rename to toys/posix/df.c
similarity index 100%
rename from toys/dirname.c
rename to toys/posix/dirname.c
similarity index 100%
rename from toys/echo.c
rename to toys/posix/echo.c
similarity index 100%
rename from toys/env.c
rename to toys/posix/env.c
similarity index 100%
rename from toys/false.c
rename to toys/posix/false.c
similarity index 100%
rename from toys/head.c
rename to toys/posix/head.c
similarity index 100%
rename from toys/id.c
rename to toys/posix/id.c
similarity index 100%
rename from toys/kill.c
rename to toys/posix/kill.c
similarity index 100%
rename from toys/link.c
rename to toys/posix/link.c
similarity index 100%
rename from toys/ln.c
rename to toys/posix/ln.c
similarity index 100%
rename from toys/logname.c
rename to toys/posix/logname.c
similarity index 100%
rename from toys/ls.c
rename to toys/posix/ls.c
similarity index 100%
rename from toys/mkdir.c
rename to toys/posix/mkdir.c
similarity index 100%
rename from toys/mkfifo.c
rename to toys/posix/mkfifo.c
similarity index 100%
rename from toys/nice.c
rename to toys/posix/nice.c
similarity index 100%
rename from toys/nohup.c
rename to toys/posix/nohup.c
similarity index 100%
rename from toys/od.c
rename to toys/posix/od.c
similarity index 100%
rename from toys/patch.c
rename to toys/posix/patch.c
similarity index 100%
rename from toys/pwd.c
rename to toys/posix/pwd.c
similarity index 100%
rename from toys/rmdir.c
rename to toys/posix/rmdir.c
similarity index 100%
rename from toys/sed.c
rename to toys/posix/sed.c
similarity index 100%
rename from toys/sleep.c
rename to toys/posix/sleep.c
similarity index 100%
rename from toys/sort.c
rename to toys/posix/sort.c
similarity index 100%
rename from toys/tail.c
rename to toys/posix/tail.c
similarity index 100%
rename from toys/tee.c
rename to toys/posix/tee.c
similarity index 100%
rename from toys/true.c
rename to toys/posix/true.c
similarity index 100%
rename from toys/tty.c
rename to toys/posix/tty.c
similarity index 100%
rename from toys/uname.c
rename to toys/posix/uname.c
similarity index 100%
rename from toys/uniq.c
rename to toys/posix/uniq.c
similarity index 100%
rename from toys/unlink.c
rename to toys/posix/unlink.c
similarity index 100%
rename from toys/wc.c
rename to toys/posix/wc.c
similarity index 100%
rename from toys/who.c
rename to toys/posix/who.c
similarity index 100%
rename from toys/xargs.c
rename to toys/posix/xargs.c