[deps]
musl
kernel-headers

[main]
filesize=2186738
sha512=089b67cd920f332daf910711739b1e55ba4c76cfa2122dfe5464432e0d76d3af8327837ebc3cc9954deef3e8f766d16a1928aecb2c169fe3de5a722eea7ea3dd

[mirrors]
http://www.busybox.net/downloads/busybox-1.20.2.tar.bz2

[build]

cp "$K/busybox.stage1.config" .config
patch -p1 < "$K/busybox.patch" || exit 1

#__inline seems to get activated when -std=gnu99 is used, causing havoc 
sed -i 's,__inline,,' ./scripts/kconfig/zconf.hash.c_shipped

# --sort-section renders busybox unusable on ARM: http://sourceware.org/bugzilla/show_bug.cgi?id=14156
sed -i 's,SORT_SECTION=,SORT_SECTION= #,' scripts/trylink

if [ ! -z "$DEBUGBUILD" ] ; then
	debugcflags="-O0 -g"
	sed -i 's/# CONFIG_DEBUG is not set/CONFIG_DEBUG=y/' .config
	sed -i 's/# CONFIG_DEBUG_PESSIMIZE is not set/CONFIG_DEBUG_PESSIMIZE=y/' .config
	sed -i 's/CONFIG_NO_DEBUG_LIB=y/# CONFIG_NO_DEBUG_LIB is not set/' .config
fi


make KBUILD_VERBOSE=1 CC="$CC" HOSTCC="$HOSTCC" \
     HOSTCFLAGS=-D_GNU_SOURCE -j$MAKE_THREADS || exit 1

mkdir -p "$butch_install_dir/bin/"
cp busybox "$butch_install_dir/bin/" || exit 1
cd "$butch_install_dir/bin/" || exit 1
./busybox --list >/dev/null || (echo "busybox binary: no list" ; exit 1)
for f in $(./busybox --list); do
  [ ! -f "$R/bin/$f" ] || readlink "$R/bin/$f" | grep "busybox" && ln -sf busybox $f
done
