#!/bin/bash
# SlackBuild pour libXsettings-client
# Version : 1.2.1 (à adapter selon la dernière release)

PRGNAM=libxsettings
VERSION=1.2.1
BUILD=${BUILD:-1}
TAG=${TAG:-_slint}

CWD=$(pwd)
TMP=${TMP:-/tmp/$PRGNAM-build}

mkdir -p $TMP

# Sources
SRCURL="https://gitlab.freedesktop.org/xorg/lib/$PRGNAM/-/archive/$VERSION/$PRGNAM-$VERSION.tar.gz"
SRCTAR="$PRGNAM-$VERSION.tar.gz"

if [ ! -f "$SRCTAR" ]; then
    wget -O "$SRCTAR" "$SRCURL"
fi

# Extraction
rm -rf $TMP/*
tar -xzf $SRCTAR -C $TMP --strip-components=1

cd $TMP

# Préparer la compilation
./autogen.sh --prefix=/usr \
             --disable-static \
             --enable-shared

make || exit 1

# Préparer le package Slackware
PKGDIR="$CWD/packages"
mkdir -p $PKGDIR

rm -rf /tmp/$PRGNAM-pkg
mkdir -p /tmp/$PRGNAM-pkg

make DESTDIR=/tmp/$PRGNAM-pkg install

# Création du package Slackware
cd /tmp/$PRGNAM-pkg
/sbin/makepkg -l y -c n $PKGDIR/${PRGNAM}-${VERSION}-${ARCH}-${BUILD}${TAG}.txz

echo "Package créé dans $PKGDIR"
