### this file is sourced not run
PKGVER=6.1.2
PKGBUILD=1

TARBALL=gmp-$PKGVER.tar.xz
MD5SUM=f58fa8001d60c4c77595fbbb62b63c1d
BUNDLE=fatdog-base-8.2.tar
SRC_URL=http://distro.ibiblio.org/fatdog/source/800/$BUNDLE

SLACKREQ=
SLACKDESC="libgmp: libgmp $PKGVER (multiprecision arithmetic library)  
libgmp:  
libgmp: The GMP package contains math libraries. These have useful functions for 
libgmp: arbitrary precision arithmetic. This package is also needed by GCC (the 
libgmp: GNU C Compiler).  
libgmp: 
libgmp: 
libgmp: 
libgmp: 
libgmp: 
libgmp:
"

### override download for LFS sources bundle
# $1-src-dir $2-tarball 
pkg_download() {
	echo downloading $BUNDLE for $TARBALL
	wget -P $1 $SRC_URL
	tar -xf $1/$BUNDLE --strip-components=1 -C $1 
	rm $1/$BUNDLE
}

### default pkg_prepare
### default pkg_package
### build
pkg_build() {
	cd /tmp/gmp*

	# don't optimise only for build-machine
	mv -v config{fsf,}.guess &&
	mv -v config{fsf,}.sub	&&

	CC="gcc -isystem /usr/include ${BUILD64}" \
	CXX="g++ -isystem /usr/include ${BUILD64}" \
	LDFLAGS="-Wl,-rpath-link,/usr/lib64:/lib64 ${BUILD64}" \
	  ./configure --prefix=/usr \
		--libdir=/usr/lib64 --enable-cxx \
		--docdir=/usr/share/doc/gmp-$PKGVER &&
	  
	make $MAKEFLAGS && make html && 
	make install && make install-html &&
	
	mv -v /usr/include/gmp{,-64}.h &&
	
	# stub header
	cat << "EOF" > /usr/include/gmp.h &&
/* gmp.h - Stub Header  */
#ifndef __STUB__GMP_H__
#define __STUB__GMP_H__

#if defined(__x86_64__) || \
    defined(__sparc64__) || \
    defined(__arch64__) || \
    defined(__powerpc64__) || \
    defined (__s390x__)
# include "gmp-64.h"
#else
# include "gmp-32.h"
#endif

#endif /* __STUB__GMP_H__ */
EOF
	pkg_build_slackdesc
}
