slackbuilds/ap/ch341prog/ch341prog.SlackBuild

105 lines
2.8 KiB
Bash
Executable File

#!/bin/sh
# Set initial variables:
CWD=$(pwd)
APP=ch341prog
VERSION=$(ls $APP-*.tar.?z* | sed -e 's/\.tar\..z.*//' | rev | cut -d- -f1 | rev)
MARCH=${MARCH:-sandybridge}
ARCH=${ARCH:-x86_64}
BUILD=${BUILD:-1}
TAG=${TAG:-micu}
LIBSUFFIX=""
if [ "$MARCH" = "i386" ]; then
SLKCFLAGS="-O2 -march=i386 -mtune=i686"
elif [ "$MARCH" = "i486" ]; then
SLKCFLAGS="-O2 -march=i486 -mtune=i686"
elif [ "$MARCH" = "i586" ]; then
SLKCFLAGS="-O2 -march=i586 -mtune=i686"
elif [ "$MARCH" = "i686" ]; then
SLKCFLAGS="-O2 -march=i686"
elif [ "$MARCH" = "nocona" ]; then
SLKCFLAGS="-O2 -march=nocona -mtune=generic -mmmx -msse -msse2 -msse3"
elif [ "$MARCH" = "core2" ]; then
SLKCFLAGS="-O2 -march=core2 -mtune=core2 -mmmx -msse -msse2 -msse3"
elif [ "$MARCH" = "atom" ]; then
SLKCFLAGS="-O2 -march=core2 -mcx16 -msahf --param l1-cache-size=24 --param l1-cache-line-size=64 --param l2-cache-size=512 -mtune=core2 -mfpmath=sse -mmmx -msse -msse2 -msse3"
elif [ "$MARCH" = "sandybridge" ]; then
SLKCFLAGS="-O2 -march=sandybridge"
elif [ "$MARCH" = "pentium3" ]; then
SLKCFLAGS="-O2 -march=pentium3 -mmmx -msse"
elif [ "$MARCH" = "pentium2" ]; then
SLKCFLAGS="-O2 -march=pentium2 -mmmx"
elif [ "$MARCH" = "s390" ]; then
SLKCFLAGS="-O2"
else
SLKCFLAGS="-O2 -march=$ARCH"
fi
if [ "$ARCH" = "x86_64" ]; then
LIBSUFFIX=${LIBSUFFIX:-64}
SLKCFLAGS="$SLKCFLAGS -fPIC -m64"
fi
MAKE="make"
if [ "$TMP" = "" ]; then
TMP=/tmp
fi
PKG=$TMP/package-$APP
rm -rf $PKG
mkdir -p $PKG
cd $TMP
rm -rf $APP-$VERSION
tar xvf $CWD/$APP-$VERSION.tar.?z* || exit 1
cd $APP-$VERSION || exit 1
chown -R root.root .
find . -perm 444 -exec chmod 644 {} \;
find . -perm 777 -exec chmod 755 {} \;
find . -perm 666 -exec chmod 644 {} \;
patch -p1 < $CWD/makefile-cflags.patch || exit 1
patch -p1 < $CWD/udev-rule-plugdev.patch || exit 1
CFLAGS="$SLKCFLAGS" \
$MAKE || exit 1
# install manually
mkdir -p $PKG/usr/bin && \
cp $APP $PKG/usr/bin && \
chown -R root.bin $PKG/usr/bin/${APP} && \
chmod 755 $PKG/usr/bin/${APP}
mkdir -p $PKG/etc/udev/rules.d && \
cp -v *.rules $PKG/etc/udev/rules.d && \
chown root.root $PKG/etc/udev/rules.d/* && \
chmod 644 $PKG/etc/udev/rules.d/*
strip --strip-unneeded $PKG/usr/bin/${APP} 2>/dev/null
mkdir -p $PKG/usr/doc/$APP-$VERSION
cp -a COPYING README.md \
$PKG/usr/doc/$APP-$VERSION
mkdir -p $PKG/install
[ -f $CWD/doinst.sh ] && cat $CWD/doinst.sh > $PKG/install/doinst.sh
[ -f $CWD/doinst.sh.gz ] && zcat $CWD/doinst.sh.gz > $PKG/install/doinst.sh
cat $CWD/slack-desc > $PKG/install/slack-desc
# Allow to run as non-root until now:
if [ $(id -u) -ne 0 ]; then
echo "*** Running as non-root, skipping makepkg."
echo "*** Package contents is in $PKG directory."
exit 0
fi
cd $PKG
makepkg -l y -c n $TMP/$APP-$VERSION-$ARCH-${BUILD}${TAG}.txz
# Clean up the extra stuff:
if [ "$1" = "--cleanup" ]; then
rm -rf $TMP/$APP-$VERSION
rm -rf $PKG
fi