OSDN Git Service

Add -h and -L to file.
[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 export KCONFIG_CONFIG=.singleconfig
19 for i in "$@"
20 do
21   echo -n "$i:"
22   TOYFILE="$(egrep -l "TOY[(]($i)[ ,]" toys/*/*.c)"
23
24   if [ -z "$TOYFILE" ]
25   then
26     echo "Unknown command '$i'" >&2
27     exit 1
28   fi
29
30   # Enable stuff this command depends on
31   DEPENDS="$(sed -n "/^config *$i"'$/,/^$/{s/^[ \t]*depends on //;T;s/[!][A-Z0-9_]*//g;s/ *&& */|/g;p}' $TOYFILE | xargs | tr ' ' '|')"
32
33   NAME=$(echo $i | tr a-z- A-Z_)
34   make allnoconfig > /dev/null &&
35   sed -ri -e '/CONFIG_TOYBOX/d' \
36     -e "s/# (CONFIG_($NAME|${NAME}_.*${DEPENDS:+|$DEPENDS})) is not set/\1=y/" \
37     "$KCONFIG_CONFIG" &&
38   echo "# CONFIG_TOYBOX is not set" >> "$KCONFIG_CONFIG" &&
39   grep "CONFIG_TOYBOX_" .config >> "$KCONFIG_CONFIG" &&
40
41   rm -f "$PREFIX$i" &&
42   OUTNAME="$PREFIX$i" scripts/make.sh || exit 1
43 done