blob: 55e4c6762a150815438dd4ca89c6fce349c1dbb9 [file] [log] [blame]
Rob Landleyd04dc1f2013-08-30 01:53:31 -05001#!/bin/bash
2
3# Build a standalone toybox command
4
5if [ -z "$1" ]
6then
Rob Landley0b63d262014-09-27 20:31:16 -05007 echo "usage: single.sh command..." >&2
Rob Landleyd04dc1f2013-08-30 01:53:31 -05008 exit 1
9fi
10
Rob Landley6fde0f92015-08-30 04:42:49 -050011# 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
Rob Landley2b4594c2017-02-01 16:13:01 -060018# Force dependencies to rebuild headers if we build multiplexer after this.
19touch -c .config
20
Rob Landley6fde0f92015-08-30 04:42:49 -050021export KCONFIG_CONFIG=.singleconfig
Rob Landley0b63d262014-09-27 20:31:16 -050022for i in "$@"
23do
Rob Landley8cbde4b2016-02-02 14:56:27 -060024 echo -n "$i:"
Rob Landley912b2be2015-02-07 17:20:23 -060025 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
Rob Landley6d364fc2016-03-12 17:47:19 -060033 # 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 ' ' '|')"
Rob Landley912b2be2015-02-07 17:20:23 -060035
Rob Landley0b63d262014-09-27 20:31:16 -050036 NAME=$(echo $i | tr a-z- A-Z_)
Rob Landley0b63d262014-09-27 20:31:16 -050037 make allnoconfig > /dev/null &&
Rob Landley6fde0f92015-08-30 04:42:49 -050038 sed -ri -e '/CONFIG_TOYBOX/d' \
39 -e "s/# (CONFIG_($NAME|${NAME}_.*${DEPENDS:+|$DEPENDS})) is not set/\1=y/" \
Rob Landley912b2be2015-02-07 17:20:23 -060040 "$KCONFIG_CONFIG" &&
Rob Landley6fde0f92015-08-30 04:42:49 -050041 echo "# CONFIG_TOYBOX is not set" >> "$KCONFIG_CONFIG" &&
42 grep "CONFIG_TOYBOX_" .config >> "$KCONFIG_CONFIG" &&
43
Rob Landleya8d0d132016-03-23 03:25:37 -050044 rm -f "$PREFIX$i" &&
45 OUTNAME="$PREFIX$i" scripts/make.sh || exit 1
Rob Landley0b63d262014-09-27 20:31:16 -050046done