The GMP package contains math libraries. These have useful functions for arbitrary precision arithmetic.
Create the PKGBUILD for the Gmp package with the following commands:
mkdir /sources/gmp
cd /sources/gmp
cat > PKGBUILD << "REALEOF"
# Maintainer: Linux From Scratch <lfs-dev@lists.linuxfromscratch.org>
pkgname="gmp"
pkgver="6.3.0"
pkgrel="1"
pkgdesc="The GMP package contains math libraries for arbitrary precision arithmetic."
arch=('x86'
'x86_64')
url="https://www.gnu.org/software/gmp/"
license=('GPLv2'
'GPLv3'
'LGPLv3')
groups=('core')
depends=('gcc'
'glibc')
makedepends=('bash'
'binutils'
'coreutils'
'diffutils'
'gawk'
'grep'
'm4'
'make'
'sed'
'texinfo')
source=('https://ftp.gnu.org/gnu/gmp/gmp-6.3.0.tar.xz')
md5sums=('956dc04e864001a9c22429f761f2c283')
build() {
cd "${pkgname}-${pkgver}"
# Enable shadow stack support
LDFLAGS+=' -Wl,-z,shstk' \
./configure --prefix=/usr \
--enable-cxx \
--disable-static \
--build=${CHOST} \
--docdir="/usr/share/doc/${pkgname}-${pkgver}"
# Fix overlinking
sed -i -e 's/ -shared / -Wl,-O1,--as-needed\0/g' libtool
make
make html
}
check() {
cd "${pkgname}-${pkgver}"
make check 2>&1 | tee gmp-check-log
# 1 test is known to fial in some instances
failcount=`awk '/# FAIL:/{total+=$3} ; END{print total}' gmp-check-log`
if $failcount -gt 1; then
echo "Falure in check, failcount=${failcount}"
exit 1
fi
}
package() {
cd "${pkgname}-${pkgver}"
make DESTDIR="${pkgdir}" install
make DESTDIR="${pkgdir}" install-html
}
REALEOF
The meaning of the new configure options:
--enable-cxx
This parameter enables C++ support
--docdir=/usr/share/doc/gmp-6.3.0
This variable specifies the correct place for the documentation.
--build=${CHOST}
This parameter builds for the generic target arch, using
${CHOST} ensures that it's build for the correct target CPU
as defined in /etc/makepkg.conf.
Prepare the build directory for the pacman user and build the package:
chown -R root:pacman . chmod 2775 . chmod 664 PKGBUILD su pacman -c 'makepkg -L --nodeps'
Add the newly created package to the central package repository:
cp gmp-6.3.0-1-$(uname -m).pkg.tar.xz \
/srv/pacman/repos/LFS/
repo-add /srv/pacman/repos/LFS/LFS.db.tar.xz \
/srv/pacman/repos/LFS/gmp-6.3.0-1-$(uname -m).pkg.tar.xz
Update the local cache and install the Gmp package:
pacman -Syu pacman -S gmp --overwrite \* -dd --noconfirm
Finally, copy the source files into the source repository and clean up the build directory:
mkdir /srv/pacman/source/LFS/gmp cp PKGBUILD /srv/pacman/source/LFS/gmp cd /sources rm -rf gmp