#!/bin/sh

. config/options

$SCRIPTS/build toolchain
$SCRIPTS/build zlib

export MAKEFLAGS=-j1

case $TARGET_ARCH in
  i386)
    TARGET=linux-elf
    ;;
  x86_64)
    TARGET=linux-x86_64
    ;;
  powerpc)
    TARGET=linux-ppc
    ;;
  powerpc64)
    TARGET=linux-ppc64
    ;;
esac

cd $PKG_BUILD
./Configure \
  --prefix=/usr \
  zlib-dynamic \
  threads \
  shared \
  no-idea \
  no-mdc2 \
  no-rc5 \
  no-krb5 \
  no-ec \
  no-ecdh \
  no-ecdsa \
  $TARGET

$SED -i -e "s:-march=[-a-z0-9] ::" \
        -e "s:-mcpu=[-a-z0-9] ::g" \
        -e "s:-O[0-9]:$CFLAGS:" Makefile

make CC=$CC LD=$LD RANLIB=$RANLIB LIBDIR=lib all build-shared
make CC=$CC LD=$LD RANLIB=$RANLIB LIBDIR=lib do_linux-shared
make CC=$CC LD=$LD RANLIB=$RANLIB LIBDIR=lib INSTALL_PREFIX=$SYSROOT_PREFIX install_sw
