Core/glibc/PKGBUILD
2024-09-07 23:20:23 +08:00

132 lines
4.2 KiB
Bash

# This is an example PKGBUILD file. Use this as a start to creating your own,
# and remove these comments. For more information, see 'man PKGBUILD'.
# NOTE: Please fill out the license field for your package! If it is unknown,
# then please put 'unknown'.
# Maintainer: Future Linux Team <future_linux@163.com>
pkgname=(glibc glibc-32bit)
pkgbase=glibc
pkgver=2.40
pkgrel=1
arch=('x86_64')
url="https://www.gnu.org/software/libc/"
license=('GPL-2.0-or-later' 'LGPL-2.1-or-later')
options=('staticlibs' '!lto')
source=(https://ftp.gnu.org/gnu/${pkgbase}/${pkgbase}-${pkgver}.tar.xz
${pkgbase}-${pkgver}-fhs-1.patch
nsswitch.conf
ld.so.conf)
sha256sums=(19a890175e9263d748f627993de6f4b1af9cd21e03f080e4bfb3a1fac10205a2
643552db030e2f2d7ffde4f558e0f5f83d3fabf34a2e0e56ebdb49750ac27b0d
f86fc39cffef8960af4006d478f2e33d1aba708c019e0337cceed8b2c4853b58
71315fb19572420138b2974acd8a2d836ef1f1889599775cf0361d73d9e86d6a)
prepare() {
cd ${pkgbase}-${pkgver}
patch -Np1 -i ${srcdir}/${pkgbase}-${pkgver}-fhs-1.patch
install -vd ${pkgbase}-build ${pkgbase}-32bit-build
}
build() {
cd ${srcdir}/${pkgbase}-${pkgver}/${pkgbase}-build
CFLAGS=${CFLAGS/-Wp,-D_FORTIFY_SOURCE=3/}
echo "slibdir=/usr/lib64" >> configparms
echo "rtlddir=/usr/lib64" >> configparms
echo "sbindir=/usr/bin" >> configparms
echo "rootsbindir=/usr/sbin" >> configparms
echo "complocaledir=/usr/lib/locale" >> configparms
${BUILD_CONFIGURE} \
--disable-werror \
--enable-kernel=4.19 \
--with-headers=/usr/include \
--enable-stack-protector=strong \
--disable-nscd \
--disable-timezone-tools \
--enable-cet
make
cd ${srcdir}/${pkgbase}-${pkgver}/${pkgbase}-32bit-build
CFLAGS=${CFLAGS/-fno-omit-frame-pointer -mno-omit-leaf-frame-pointer/}
echo "slibdir=/usr/lib32" >> configparms
echo "rtlddir=/usr/lib32" >> configparms
echo "sbindir=/usr/bin" >> configparms
echo "rootsbindir=/usr/sbin" >> configparms
echo "complocaledir=/usr/lib/locale" >> configparms
CC="${CHOST}-gcc -m32 -mstackrealign" \
CXX="${CHOST}-g++ -m32 -mstackrealign" \
${BUILD_CONFIGURE} \
--host=${CHOST32} \
--build=$(../scripts/config.guess) \
--enable-kernel=4.19 \
--disable-nscd \
--libdir=/usr/lib32 \
--libexecdir=/usr/lib32 \
--disable-timezone-tools
make
}
package_glibc() {
pkgdesc="GNU C Library"
groups=('base')
depends=('linux-api-headers' 'tzdata')
backup=(etc/nsswitch.conf
etc/ld.so.conf)
cd ${srcdir}/${pkgbase}-${pkgver}/${pkgbase}-build
make DESTDIR=${pkgdir} install
install -vdm755 ${pkgdir}/usr/lib/locale
${pkgdir}/usr/bin/localedef --prefix=${pkgdir} -i C -f UTF-8 C.UTF-8
${pkgdir}/usr/bin/localedef --prefix=${pkgdir} -i en_US -f ISO-8859-1 en_US
${pkgdir}/usr/bin/localedef --prefix=${pkgdir} -i en_US -f UTF-8 en_US.UTF-8
${pkgdir}/usr/bin/localedef --prefix=${pkgdir} -i zh_CN -f GB18030 zh_CN.GB18030
if LOCALE=`grep "zh_CN.UTF-8/" ../localedata/SUPPORTED`; then
CHARMAP=`echo $LOCALE | sed 's,[^/]*/\([^ ]*\) [\],\1,'`
INPUT=`echo $LOCALE | sed 's,[/.].*,,'`
LOCALE=`echo $LOCALE | sed 's,/.*,,'`
${pkgdir}/usr/bin/localedef --prefix=${pkgdir} -i $INPUT -f $CHARMAP $LOCALE
fi
install -vm644 ${srcdir}/nsswitch.conf ${pkgdir}/etc/
install -vm644 ${srcdir}/ld.so.conf ${pkgdir}/etc/
install -vdm755 ${pkgdir}/etc/ld.so.conf.d
}
package_glibc-32bit() {
pkgdesc="GNU C Library (32-bit)"
depends=("glibc=${pkgver}")
backup=(etc/ld.so.conf.d/glibc-32bit.conf)
options+=('!emptydirs')
cd ${srcdir}/${pkgbase}-${pkgver}/${pkgbase}-32bit-build
make DESTDIR=$PWD/DESTDIR install
install -vdm755 ${pkgdir}/usr/{lib32,include/gnu}
ln -sv /usr/lib32 ${pkgdir}/lib32
cp -a DESTDIR/usr/lib32/* ${pkgdir}/usr/lib32/
install -vm644 DESTDIR/usr/include/gnu/{lib-names,stubs}-32.h \
${pkgdir}/usr/include/gnu/
install -vdm755 ${pkgdir}/usr/lib64
ln -s ../lib32/ld-linux.so.2 ${pkgdir}/usr/lib64/
install -vdm755 ${pkgdir}/etc/ld.so.conf.d
echo "/usr/lib32" > ${pkgdir}/etc/ld.so.conf.d/glibc-32bit.conf
}