OSDN Git Service

Add "make ls" and friends targets, with "make working" and "make pending" lists.
authorRob Landley <rob@landley.net>
Mon, 8 Feb 2016 00:15:53 +0000 (18:15 -0600)
committerRob Landley <rob@landley.net>
Mon, 8 Feb 2016 00:15:53 +0000 (18:15 -0600)
Makefile
scripts/genconfig.sh
scripts/make.sh

index 004293c..92176a2 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -19,9 +19,11 @@ toybox toybox_unstripped: toybox_stuff
        scripts/make.sh
 
 .PHONY: clean distclean baseline bloatcheck install install_flat \
-       uinstall uninstall_flat test tests help toybox_stuff change
+       uinstall uninstall_flat test tests help toybox_stuff change \
+       working pending
 
 include kconfig/Makefile
+-include .singlemake
 
 $(KCONFIG_CONFIG): $(KCONFIG_TOP)
 $(KCONFIG_TOP): generated/Config.in
@@ -54,7 +56,7 @@ clean::
        rm -rf toybox toybox_unstripped generated change .singleconfig*
 
 distclean: clean
-       rm -f toybox_old .config*
+       rm -f toybox_old .config* .singlemake
 
 test: tests
 
@@ -63,6 +65,9 @@ tests:
 
 help::
        @echo  '  toybox          - Build toybox.'
+       @echo  '  COMMANDNAME     - Build individual toybox command as a standalone binary.'
+       @echo  '  working         - List working COMMANDNAMEs.'
+       @echo  '  pending         - List pending (unfinished) COMMANDNAMEs.'
        @echo  '  change          - Build each command standalone under change/.'
        @echo  '  baseline        - Create toybox_old for use by bloatcheck.'
        @echo  '  bloatcheck      - Report size differences between old and current versions'
index ce8c026..7b34f08 100755 (executable)
@@ -119,3 +119,29 @@ genconfig()
 
 probeconfig > generated/Config.probed || rm generated/Config.probed
 genconfig > generated/Config.in || rm generated/Config.in
+
+# Find names of commands that can be built standalone in these C files
+toys()
+{
+  grep 'TOY(.*)' "$@" | grep -v TOYFLAG_NOFORK | \
+    sed -rn 's/([^:]*):.*(OLD|NEW)TOY\( *([a-zA-Z][^,]*) *,.*/\1:\3/p'
+}
+
+WORKING=
+PENDING=
+toys toys/*/*.c | (
+while IFS=":" read FILE NAME
+do
+  [ "$NAME" == help ] && continue
+  [ "$NAME" == install ] && continue
+  echo -e "$NAME:\n\tscripts/single.sh $NAME\n"
+  [ "${FILE/pending//}" != "$FILE" ] &&
+    PENDING="$PENDING $NAME" ||
+    WORKING="$WORKING $NAME"
+done > .singlemake &&
+echo -e "clean::\n\trm -f $WORKING $PENDING" >> .singlemake &&
+echo -e "working:\n\t@echo $(echo $WORKING | tr ' ' '\n' | sort | xargs)" \
+  >> .singlemake &&
+echo -e "pending:\n\t@echo $(echo $PENDING | tr ' ' '\n' | sort | xargs)" \
+  >> .singlemake
+)
index 9fbf086..84dda34 100755 (executable)
@@ -66,7 +66,7 @@ CFLAGS="$CFLAGS $(cat generated/cflags)"
 BUILD="$(echo ${CROSS_COMPILE}${CC} $CFLAGS -I . $OPTIMIZE $GITHASH)"
 FILES="$(echo lib/*.c main.c $TOYFILES)"
 
-if [ "${FILES/pending//}" != "$FILES" ]
+if [ "${TOYFILES/pending//}" != "$TOYFILES" ]
 then
   echo -e "\n\033[1;31mwarning: using unfinished code from toys/pending\033[0m"
 fi