#!/bin/sh

. config/options $1

if [ -f $PROJECT_DIR/$PROJECT/busybox/$1.conf ]; then
  BUSYBOX_CFG_FILE=$PROJECT_DIR/$PROJECT/busybox/$1.conf
else
  BUSYBOX_CFG_FILE=$ROOT/$PKG_DIR/config/$1.conf
fi

# optimize for size
  CFLAGS=`echo $CFLAGS | sed -e "s|-O.|-Os|"`

LDFLAGS="$LDFLAGS -fwhole-program"

cd $BUILD/busybox*

# Build Busybox for system
  make distclean
  cp $BUSYBOX_CFG_FILE .config
  make oldconfig

  make ARCH=$TARGET_ARCH \
       HOSTCC=$HOST_CC \
       CROSS_COMPILE=$TARGET_PREFIX \
       KBUILD_VERBOSE="1" \
       install
