OSDN Git Service

merge in pi-release history after reset to master
[android-x86/external-toybox.git] / scripts / single.sh
1 #!/bin/bash
2
3 # Build a standalone toybox command
4
5 if [ -z "$1" ]
6 then
7   echo "usage: single.sh command..." >&2
8   exit 1
9 fi
10
11 # Harvest TOYBOX_* symbols from .config
12 if [ ! -e .config ]
13 then
14   echo "Need .config for toybox global settings. Run defconfig/menuconfig." >&2
15   exit 1
16 fi
17
18 # Force dependencies to rebuild headers if we build multiplexer after this.
19 touch -c .config
20
21 export KCONFIG_CONFIG=.singleconfig
22 for i in "$@"
23 do
24   echo -n "$i:"
25   TOYFILE="$(egrep -l "TOY[(]($i)[ ,]" toys/*/*.c)"
26
27   if [ -z "$TOYFILE" ]
28   then
29     echo "Unknown command '$i'" >&2
30     exit 1
31   fi
32
33   # Enable stuff this command depends on
34   DEPENDS="$(sed -n "/^config *$i"'$/,/^$/{s/^[ \t]*depends on //;T;s/[!][A-Z0-9_]*//g;s/ *&& */|/g;p}' $TOYFILE | xargs | tr ' ' '|')"
35
36   NAME=$(echo $i | tr a-z- A-Z_)
37   make allnoconfig > /dev/null &&
38   sed -ri -e '/CONFIG_TOYBOX/d' \
39     -e "s/# (CONFIG_($NAME|${NAME}_.*${DEPENDS:+|$DEPENDS})) is not set/\1=y/" \
40     "$KCONFIG_CONFIG" &&
41   echo "# CONFIG_TOYBOX is not set" >> "$KCONFIG_CONFIG" &&
42   grep "CONFIG_TOYBOX_" .config >> "$KCONFIG_CONFIG" &&
43
44   rm -f "$PREFIX$i" &&
45   OUTNAME="$PREFIX$i" scripts/make.sh || exit 1
46 done