toybox/scripts/single.sh
<<
>>
Prefs
   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
  11# Harvest TOYBOX_* symbols from .config
  12if [ ! -e .config ]
  13then
  14  echo "Need .config for toybox global settings. Run defconfig/menuconfig." >&2
  15  exit 1
  16fi
  17
  18# Force dependencies to rebuild headers if we build multiplexer after this.
  19touch -c .config
  20
  21export KCONFIG_CONFIG=.singleconfig
  22for i in "$@"
  23do
  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
  46done
  47