SUMMARY="A C library for embedded systems"
DESCRIPTION="Newlib is a C library intended for use on embedded systems. It \
is a conglomeration of several library parts, all under free software \
licenses that make them easily usable on embedded products."
HOMEPAGE="http://www.sourceware.org/newlib/"
# This lists copyrights only for the parts used in this ARM compilation, other
# targets may need more or less. Please update this if making a recipe for
# another arch.
COPYRIGHT="1994-2009  Red Hat, Inc
	1981-2000 The Regents of the University of California
	1991 by AT&T
	1998-2001 by Lucent Technologies
	1989, 1990 Advanced Micro Devices, Inc.
	1993 by Sun Microsystems, Inc.
	1986 HEWLETT-PACKARD COMPANY
	2001 Hans-Peter Nilsson
	2001 Christopher G. Demetriou
	2002 SuperH, Inc.
	1999 Kungliga Tekniska Högskolan
	2000, 2001 Alexey Zelkin
	1997 by Andrey A. Chernov, Moscow, Russia.
	1997-2002 FreeBSD Project.
	1984,2000 S.L. Moshier
	1999 Citrus Project
	1998 Todd C. Miller
	1991 DJ Delorie
	1990-1999, 2000, 2001 Free Software Foundation, Inc.
	2001 Mike Barcroft
	2009 ARM Ltd
	2008 Ed Schouten"
LICENSE="BSD (3-clause)
	GNU LGPL v2.1"
REVISION="3"
SOURCE_URI="ftp://sourceware.org/pub/newlib/newlib-2.1.0.tar.gz"
CHECKSUM_SHA256="3e4d5ab9f0508942b6231b8ade4f8e5048cf92c96ed574c2bd6bd3320a599a48"
SOURCE_DIR="newlib-$portVersion"

ARCHITECTURES="!x86_gcc2"
SECONDARY_ARCHITECTURES="x86"

targetArch="arm-none-eabi"
targetU="arm_none_eabi"

PROVIDES="
	${targetU}_newlib$secondaryArchSuffix = $portVersion
	"
REQUIRES="
	haiku$secondaryArchSuffix
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	"
BUILD_PREREQUIRES="
	cmd:awk
	cmd:gcc$secondaryArchSuffix
	cmd:make
	cmd:makeinfo
	cmd:${targetU}_ld$secondaryArchSuffix
	${targetU}_gcc_nolibc$secondaryArchSuffix
	"

sourceDir=$(pwd)
installDir="$prefix/$relativeInstallDir/develop/tools/"
objectsDir=$(pwd)/../${portVersionedName}-obj

BUILD()
{
	#rm -rf $objectsDir
	mkdir -p $objectsDir
	cd $objectsDir

	runConfigure $sourceDir/configure --target=arm-none-eabi \
		--prefix=$installDir --disable-newlib-supplied-syscalls
	touch $sourceDir/etc/{configure,standards}.info
	make
}

INSTALL()
{
	cd $objectsDir
	make install
}
