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."
LICENSE="
	BSD (3-clause)
	GNU LGPL v2.1
"
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 <phantom@FreeBSD.org>
1997 by Andrey A. Chernov, Moscow, Russia.
1997-2002 FreeBSD Project.
1984,2000 S.L. Moshier
1999 Citrus Project
1998 Todd C. Miller <Todd.Miller@courtesan.com>
1991 DJ Delorie
1990-1999, 2000, 2001    Free Software Foundation, Inc.
2001 Mike Barcroft <mike@FreeBSD.org>
2009 ARM Ltd
2008 Ed Schouten <ed@FreeBSD.org>
"
REVISION="2"

ARCHITECTURES=""
if [ $effectiveTargetArchitecture != x86_gcc2 ]; then
	# x86_gcc2 is fine as primary target architecture as long as we're building
	# for a different secondary architecture.
	ARCHITECTURES="$ARCHITECTURES x86_gcc2"
fi
SECONDARY_ARCHITECTURES="x86"

SOURCE_URI="ftp://sourceware.org/pub/newlib/newlib-2.1.0.tar.gz"
SOURCE_DIR="newlib-$portVersion"
CHECKSUM_SHA256="3e4d5ab9f0508942b6231b8ade4f8e5048cf92c96ed574c2bd6bd3320a599a48"

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

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

BUILD_PREREQUIRES="
	haiku${secondaryArchSuffix}_devel
	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
	make
}

INSTALL()
{
	cd $objectsDir
	make install
}
