Move NEWTOY() list from end of toylist.h to generated/newtoys.h.
diff --git a/toys/basename.c b/toys/basename.c
index ffcb5bb..70ffe5b 100644
--- a/toys/basename.c
+++ b/toys/basename.c
@@ -6,6 +6,8 @@
*
* See http://www.opengroup.org/onlinepubs/009695399/utilities/basename.html
+USE_BASENAME(NEWTOY(basename, "<1>2", TOYFLAG_BIN))
+
config BASENAME
bool "basename"
default y
diff --git a/toys/bzcat.c b/toys/bzcat.c
index 39b962e..d540524 100644
--- a/toys/bzcat.c
+++ b/toys/bzcat.c
@@ -6,6 +6,8 @@
*
* Not in SUSv3.
+USE_BZCAT(NEWTOY(bzcat, NULL, TOYFLAG_USR|TOYFLAG_BIN))
+
config BZCAT
bool "bzcat"
default n
diff --git a/toys/catv.c b/toys/catv.c
index aa1bfd5..c4479d9 100644
--- a/toys/catv.c
+++ b/toys/catv.c
@@ -7,6 +7,8 @@
* Not in SUSv3, but see "Cat -v considered harmful" at
* http://cm.bell-labs.com/cm/cs/doc/84/kp.ps.gz
+USE_CATV(NEWTOY(catv, "vte", TOYFLAG_USR|TOYFLAG_BIN))
+
config CATV
bool "catv"
default y
diff --git a/toys/chroot.c b/toys/chroot.c
index 305d4fb..a3a5f53 100644
--- a/toys/chroot.c
+++ b/toys/chroot.c
@@ -6,6 +6,8 @@
*
* Not in SUSv3.
+USE_CHROOT(NEWTOY(chroot, "<1", TOYFLAG_USR|TOYFLAG_SBIN))
+
config CHROOT
bool "chroot"
default y
diff --git a/toys/chvt.c b/toys/chvt.c
index fbee391..c32a021 100644
--- a/toys/chvt.c
+++ b/toys/chvt.c
@@ -6,6 +6,8 @@
*
* Not in SUSv3.
+USE_CHVT(NEWTOY(chvt, "<1", TOYFLAG_USR|TOYFLAG_SBIN))
+
config CHVT
bool "chvt"
default y
diff --git a/toys/count.c b/toys/count.c
index b4e2433..96102e4 100644
--- a/toys/count.c
+++ b/toys/count.c
@@ -6,6 +6,8 @@
*
* Not in SUSv3.
+USE_COUNT(NEWTOY(count, NULL, TOYFLAG_USR|TOYFLAG_BIN))
+
config COUNT
bool "count"
default y
diff --git a/toys/df.c b/toys/df.c
index da0d94b..6cc9e27 100644
--- a/toys/df.c
+++ b/toys/df.c
@@ -6,6 +6,8 @@
*
* See http://www.opengroup.org/onlinepubs/009695399/utilities/df.html
+USE_DF(NEWTOY(df, "Pkt*a", TOYFLAG_USR|TOYFLAG_SBIN))
+
config DF
bool "df (disk free)"
default y
diff --git a/toys/dirname.c b/toys/dirname.c
index 9d1ad43..7300c7a 100644
--- a/toys/dirname.c
+++ b/toys/dirname.c
@@ -6,6 +6,8 @@
*
* See http://www.opengroup.org/onlinepubs/009695399/utilities/dirname.html
+USE_DIRNAME(NEWTOY(dirname, "<1>1", TOYFLAG_BIN))
+
config DIRNAME
bool "dirname"
default y
diff --git a/toys/dmesg.c b/toys/dmesg.c
index a16b8d0..a02de5a 100644
--- a/toys/dmesg.c
+++ b/toys/dmesg.c
@@ -6,6 +6,8 @@
*
* Not in SUSv3.
+USE_DMESG(NEWTOY(dmesg, "s#n#c", TOYFLAG_BIN))
+
config DMESG
bool "dmesg"
default y
diff --git a/toys/echo.c b/toys/echo.c
index 7c475ca..8b4d7c5 100644
--- a/toys/echo.c
+++ b/toys/echo.c
@@ -6,6 +6,8 @@
*
* See http://www.opengroup.org/onlinepubs/009695399/utilities/echo.html
+USE_ECHO(NEWTOY(echo, "+en", TOYFLAG_BIN))
+
config ECHO
bool "echo"
default y
diff --git a/toys/false.c b/toys/false.c
index ac6bf64..7b570bd 100644
--- a/toys/false.c
+++ b/toys/false.c
@@ -6,6 +6,7 @@
*
* See http://www.opengroup.org/onlinepubs/009695399/utilities/false.html
+USE_FALSE(NEWTOY(false, NULL, TOYFLAG_BIN))
config FALSE
bool "false"
diff --git a/toys/hello.c b/toys/hello.c
index 278fa0a..a8caeef 100644
--- a/toys/hello.c
+++ b/toys/hello.c
@@ -7,6 +7,8 @@
* Not in SUSv3.
* See http://www.opengroup.org/onlinepubs/009695399/utilities/
+USE_HELLO(NEWTOY(hello, NULL, TOYFLAG_USR|TOYFLAG_BIN))
+
config HELLO
bool "hello"
default y
diff --git a/toys/help.c b/toys/help.c
index 472ccde..515a09b 100644
--- a/toys/help.c
+++ b/toys/help.c
@@ -6,6 +6,8 @@
*
* Not in SUSv3, but exists as a bash builtin.
+USE_HELP(NEWTOY(help, "<1", TOYFLAG_BIN))
+
config HELP
bool "help"
default y
@@ -31,7 +33,7 @@
#define NEWTOY(name,opt,flags) help_##name "\0"
#define OLDTOY(name,oldname,opts,flags) "\xff" #oldname "\0"
static char *help_data =
-#include "toys/toylist.h"
+#include "generated/newtoys.h"
;
void help_main(void)
diff --git a/toys/mke2fs.c b/toys/mke2fs.c
index 405ed94..5b8af52 100644
--- a/toys/mke2fs.c
+++ b/toys/mke2fs.c
@@ -6,6 +6,8 @@
*
* Not in SUSv3.
+USE_MKE2FS(NEWTOY(mke2fs, MKE2FS_OPTSTRING, TOYFLAG_SBIN))
+
config MKE2FS
bool "mke2fs"
default n
diff --git a/toys/mkfifo.c b/toys/mkfifo.c
index 77cb73e..5ddfa6c 100644
--- a/toys/mkfifo.c
+++ b/toys/mkfifo.c
@@ -4,6 +4,8 @@
*
* See http://www.opengroup.org/onlinepubs/009695399/utilities/mkfifo.html
+USE_MKFIFO(NEWTOY(mkfifo, "<1m:", TOYFLAG_BIN))
+
config MKFIFO
bool "mkfifo"
default y
diff --git a/toys/netcat.c b/toys/netcat.c
index 573a76c..ed7a887 100644
--- a/toys/netcat.c
+++ b/toys/netcat.c
@@ -6,6 +6,9 @@
*
* Not in SUSv3.
+USE_NETCAT(OLDTOY(nc, netcat, "i#w#l@p#s:q#f:e", TOYFLAG_BIN))
+USE_NETCAT(NEWTOY(netcat, "i#w#l@p#s:q#f:e", TOYFLAG_BIN))
+
config NETCAT
bool "netcat"
default n
diff --git a/toys/oneit.c b/toys/oneit.c
index a05e926..991eba1 100644
--- a/toys/oneit.c
+++ b/toys/oneit.c
@@ -6,6 +6,8 @@
*
* Not in SUSv3.
+USE_ONEIT(NEWTOY(oneit, "+<1c:p", TOYFLAG_SBIN))
+
config ONEIT
bool "oneit"
default y
diff --git a/toys/patch.c b/toys/patch.c
index 53be263..9ec748e 100644
--- a/toys/patch.c
+++ b/toys/patch.c
@@ -21,6 +21,8 @@
* -F fuzz (number, default 2)
* [file] which file to patch
+USE_PATCH(NEWTOY(patch, "up#i:R", TOYFLAG_USR|TOYFLAG_BIN))
+
config PATCH
bool "patch"
default y
diff --git a/toys/pwd.c b/toys/pwd.c
index d0c4dfa..d84c504 100644
--- a/toys/pwd.c
+++ b/toys/pwd.c
@@ -8,6 +8,8 @@
*
* TODO: add -L -P
+USE_PWD(NEWTOY(pwd, NULL, TOYFLAG_BIN))
+
config PWD
bool "pwd"
default y
diff --git a/toys/readlink.c b/toys/readlink.c
index 89aff10..882fddc 100644
--- a/toys/readlink.c
+++ b/toys/readlink.c
@@ -6,6 +6,8 @@
*
* Not in SUSv3.
+USE_READLINK(NEWTOY(readlink, "<1f", TOYFLAG_BIN))
+
config READLINK
bool "readlink"
default n
diff --git a/toys/sed.c b/toys/sed.c
index ffd0a2a..b3800d8 100644
--- a/toys/sed.c
+++ b/toys/sed.c
@@ -6,6 +6,8 @@
*
* See http://www.opengroup.org/onlinepubs/009695399/utilities/sed.c
+USE_SED(NEWTOY(sed, "irne*", TOYFLAG_BIN))
+
config SED
bool "sed"
default n
diff --git a/toys/sha1sum.c b/toys/sha1sum.c
index 2a1b11e..3229cd1 100644
--- a/toys/sha1sum.c
+++ b/toys/sha1sum.c
@@ -9,6 +9,8 @@
*
* Not in SUSv3.
+USE_SHA1SUM(NEWTOY(sha1sum, NULL, TOYFLAG_USR|TOYFLAG_BIN))
+
config SHA1SUM
bool "sha1sum"
default y
diff --git a/toys/sleep.c b/toys/sleep.c
index 205adf2..55a6b97 100644
--- a/toys/sleep.c
+++ b/toys/sleep.c
@@ -6,6 +6,8 @@
*
* See http://www.opengroup.org/onlinepubs/009695399/utilities/sleep.html
+USE_SLEEP(NEWTOY(sleep, "<1", TOYFLAG_BIN))
+
config SLEEP
bool "sleep"
default y
diff --git a/toys/sync.c b/toys/sync.c
index 96c3677..e6990fd 100644
--- a/toys/sync.c
+++ b/toys/sync.c
@@ -6,6 +6,8 @@
*
* Not in SUSv3.
+USE_SYNC(NEWTOY(sync, NULL, TOYFLAG_BIN))
+
config SYNC
bool "sync"
default y
diff --git a/toys/touch.c b/toys/touch.c
index 8c9b7aa..65afe58 100644
--- a/toys/touch.c
+++ b/toys/touch.c
@@ -6,6 +6,8 @@
*
* See http://www.opengroup.org/onlinepubs/009695399/utilities/touch.html
+USE_TOUCH(NEWTOY(touch, "l#t:r:mca", TOYFLAG_BIN))
+
config TOUCH
bool "touch"
default y
diff --git a/toys/toylist.h b/toys/toylist.h
index 1f01c54..74a4619 100644
--- a/toys/toylist.h
+++ b/toys/toylist.h
@@ -5,13 +5,6 @@
*/
-// Provide function declarations and structs. Note that main.c #includes this
-// file twice (with different macros) to populate toy_list[].
-
-#ifndef NEWTOY
-#define NEWTOY(name, opts, flags) void name##_main(void);
-#define OLDTOY(name, oldname, opts, flags)
-
struct df_data {
struct arg_list *fstype;
@@ -126,48 +119,3 @@
char *options;
int flags;
} toy_list[];
-
-#endif
-
-// List of all the applets toybox can provide.
-
-// This one is out of order on purpose: it's the first element in the array.
-
-NEWTOY(toybox, NULL, 0)
-
-// The rest of these are alphabetical, for binary search.
-
-USE_BASENAME(NEWTOY(basename, "<1>2", TOYFLAG_BIN))
-USE_BZCAT(NEWTOY(bzcat, NULL, TOYFLAG_USR|TOYFLAG_BIN))
-USE_CATV(NEWTOY(catv, "vte", TOYFLAG_USR|TOYFLAG_BIN))
-USE_CHROOT(NEWTOY(chroot, "<1", TOYFLAG_USR|TOYFLAG_SBIN))
-USE_CHVT(NEWTOY(chvt, "<1", TOYFLAG_USR|TOYFLAG_SBIN))
-USE_COUNT(NEWTOY(count, NULL, TOYFLAG_USR|TOYFLAG_BIN))
-USE_TOYSH(NEWTOY(cd, NULL, TOYFLAG_NOFORK))
-USE_DF(NEWTOY(df, "Pkt*a", TOYFLAG_USR|TOYFLAG_SBIN))
-USE_DIRNAME(NEWTOY(dirname, "<1>1", TOYFLAG_BIN))
-USE_DMESG(NEWTOY(dmesg, "s#n#c", TOYFLAG_BIN))
-USE_ECHO(NEWTOY(echo, "+en", TOYFLAG_BIN))
-USE_TOYSH(NEWTOY(exit, NULL, TOYFLAG_NOFORK))
-USE_FALSE(NEWTOY(false, NULL, TOYFLAG_BIN))
-USE_HELLO(NEWTOY(hello, NULL, TOYFLAG_USR|TOYFLAG_BIN))
-USE_HELP(NEWTOY(help, "<1", TOYFLAG_BIN))
-USE_MKE2FS(NEWTOY(mke2fs, MKE2FS_OPTSTRING, TOYFLAG_SBIN))
-USE_MKFIFO(NEWTOY(mkfifo, "<1m:", TOYFLAG_BIN))
-USE_NETCAT(OLDTOY(nc, netcat, "i#w#l@p#s:q#f:e", TOYFLAG_BIN))
-USE_NETCAT(NEWTOY(netcat, "i#w#l@p#s:q#f:e", TOYFLAG_BIN))
-USE_ONEIT(NEWTOY(oneit, "+<1c:p", TOYFLAG_SBIN))
-USE_PATCH(NEWTOY(patch, "up#i:R", TOYFLAG_USR|TOYFLAG_BIN))
-USE_PWD(NEWTOY(pwd, NULL, TOYFLAG_BIN))
-USE_READLINK(NEWTOY(readlink, "<1f", TOYFLAG_BIN))
-USE_SED(NEWTOY(sed, "irne*", TOYFLAG_BIN))
-USE_TOYSH(OLDTOY(sh, toysh, "c:i", TOYFLAG_BIN))
-USE_SHA1SUM(NEWTOY(sha1sum, NULL, TOYFLAG_USR|TOYFLAG_BIN))
-USE_SLEEP(NEWTOY(sleep, "<1", TOYFLAG_BIN))
-USE_SYNC(NEWTOY(sync, NULL, TOYFLAG_BIN))
-USE_TOUCH(NEWTOY(touch, "l#t:r:mca", TOYFLAG_BIN))
-USE_TOYSH(NEWTOY(toysh, "c:i", TOYFLAG_BIN))
-USE_TRUE(NEWTOY(true, NULL, TOYFLAG_BIN))
-USE_TTY(NEWTOY(tty, "s", TOYFLAG_BIN))
-USE_WHICH(NEWTOY(which, "a", TOYFLAG_USR|TOYFLAG_BIN))
-USE_YES(NEWTOY(yes, NULL, TOYFLAG_USR|TOYFLAG_BIN))
diff --git a/toys/toysh.c b/toys/toysh.c
index 353d215..15c7811 100644
--- a/toys/toysh.c
+++ b/toys/toysh.c
@@ -16,6 +16,11 @@
*
* TODO: // Handle embedded NUL bytes in the command line.
+USE_TOYSH(NEWTOY(cd, NULL, TOYFLAG_NOFORK))
+USE_TOYSH(NEWTOY(exit, NULL, TOYFLAG_NOFORK))
+USE_TOYSH(OLDTOY(sh, toysh, "c:i", TOYFLAG_BIN))
+USE_TOYSH(NEWTOY(toysh, "c:i", TOYFLAG_BIN))
+
config TOYSH
bool "sh (toysh)"
default y
diff --git a/toys/true.c b/toys/true.c
index 88e9590..582b2ca 100644
--- a/toys/true.c
+++ b/toys/true.c
@@ -6,6 +6,8 @@
*
* See http://www.opengroup.org/onlinepubs/009695399/utilities/true.html
+USE_TRUE(NEWTOY(true, NULL, TOYFLAG_BIN))
+
config TRUE
bool "true"
default y
diff --git a/toys/tty.c b/toys/tty.c
index a603e3e..6bc9cd3 100644
--- a/toys/tty.c
+++ b/toys/tty.c
@@ -5,6 +5,8 @@
*
* See http://www.opengroup.org/onlinepubs/009695399/utilities/tty.html
+USE_TTY(NEWTOY(tty, "s", TOYFLAG_BIN))
+
config TTY
bool "tty"
default y
diff --git a/toys/which.c b/toys/which.c
index d7205fd..63e12aa 100644
--- a/toys/which.c
+++ b/toys/which.c
@@ -6,6 +6,8 @@
*
* Not in SUSv3.
+USE_WHICH(NEWTOY(which, "a", TOYFLAG_USR|TOYFLAG_BIN))
+
config WHICH
bool "which"
default y
diff --git a/toys/yes.c b/toys/yes.c
index 501ea3a..a44937b 100644
--- a/toys/yes.c
+++ b/toys/yes.c
@@ -6,6 +6,8 @@
*
* Not in SUSv3.
+USE_YES(NEWTOY(yes, NULL, TOYFLAG_USR|TOYFLAG_BIN))
+
config YES
bool "yes"
default y