1#!/bin/bash 2 3# Build a standalone toybox command 4 5if [ -z "$1" ] 6then 7 echo "usage: single.sh command..." >&2 8 exit 1 9fi 10 11for i in "$@" 12do 13 14 TOYFILE="$(egrep -l "TOY[(]($i)[ ,]" toys/*/*.c)" 15 16 if [ -z "$TOYFILE" ] 17 then 18 echo "Unknown command '$i'" >&2 19 exit 1 20 fi 21 22 DEPENDS="$(sed -n 's/^[ \t]*depends on //;T;s/[!][A-Z0-9_]*//g;s/ *&& */|/g;p' $TOYFILE | grep -v SMACK | xargs | tr ' ' '|')" 23 24 NAME=$(echo $i | tr a-z- A-Z_) 25 export KCONFIG_CONFIG=.singleconfig 26 27 make allnoconfig > /dev/null && 28 sed -ri -e "s/CONFIG_TOYBOX=y/# CONFIG_TOYBOX is not set/;t" \ 29 -e "s/# (CONFIG_(TOYBOX(|_HELP.*|_I18N|_FLOAT)|$NAME|${NAME}_.*${DEPENDS:+|$DEPENDS})) is not set/\1=y/" \ 30 "$KCONFIG_CONFIG" && 31 make && 32 mv toybox $PREFIX$i || exit 1 33done 34