Some SlackBuild scripts for Slackware.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

155 lines
4.6 KiB

#!/bin/bash
# Build script for Slackware
# Copyright (C) 2008,2009 Damien Goutte-Gattat
#
# Redistribution and use of this script, with or without modifications,
# is permitted provided that the following conditions are met:
#
# 1. Redistributions of this script must retain the above copyright
# notice, this list of conditions and the following disclaimer.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AS IS'' AND ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
# IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
# Contact: Damien Goutte-Gattat <dgouttegattat@incenp.org>
#
# Latest ATLAS sourcecode is available at:
# <http://math-atlas.sourceforge.net/>.
#
# Latest Lapack sourcecode is available at:
# <http://www.netlib.org/lapack/>.
#
# NOTES: The whole purpose of ATLAS is to provide the best performance
# for a given computer. This implies, among other things, that it
# makes little sense to build and install the package on
# different machines, unless they are all powered by the very
# same processor.
#
# To build, the processor must run at *constant full speed*:
# disable cpufreq or use the `performance' governor.
# Source packages infos
ATLAS_NAMESRC=${ATLAS_NAMESRC:-atlas}
ATLAS_VERSION=${ATLAS_VERSION:-3.8.3}
ATLAS_ARCHIVE=${ATLAS_ARCHIVE:-${ATLAS_NAMESRC}$ATLAS_VERSION.tar.gz}
ATLAS_URL=${ATLAS_URL:-http://garr.dl.sourceforge.net/sourceforge/math-atlas}
LAPACK_NAMESRC=${LAPACK_NAMESRC:-lapack}
LAPACK_VERSION=${LAPACK_VERSION:-3.2.1}
LAPACK_ARCHIVE=${LAPACK_ARCHIVE:-$LAPACK_NAMESRC-$LAPACK_VERSION.tgz}
LAPACK_URL=${LAPACK_URL:-http://www.netlib.org/lapack}
# Build infos
NAMEPKG=${NAMEPKG:-libatlas}
VERSION=${VERSION:-$ATLAS_VERSION}
BUILD=${BUILD:-1GGD}
ARCH=${ARCH:-i486}
EXT=${EXT:-txz}
# Directories
TMP=${TMP:-/tmp}
OUT=${OUT:-$TMP/build}
PKG=${PKG:-$OUT/$NAMEPKG}
CWD=$(pwd)
set -e # Quit if a command returns non-zero
# Sanity check
if [ $UID -eq 0 ]; then
echo "You should NOT run this script as ROOT!"
exit 1
fi
if [ ! -d $TMP ]; then
echo "$TMP does not exist or is not a directory!"
exit 1
fi
# Compilation settings
MHZ=$(sed -nre 's/^cpu MHz\s+: ([0-9]+)\.[0-9]{3}/\1/ p' /proc/cpuinfo | \
head -n 1)
case "$ARCH" in
x86_64)
BITS=64
LIBDIRSUFFIX=64
;;
*)
BITS=32
LIBDIRSUFFIX=""
;;
esac
# Get and verify the source archives
if [ ! -r $ATLAS_ARCHIVE ]; then
wget -c -O $ATLAS_ARCHIVE.part "$ATLAS_URL/$ATLAS_ARCHIVE"
mv $ATLAS_ARCHIVE.part $ATLAS_ARCHIVE
fi
if [ ! -r $LAPACK_ARCHIVE ]; then
wget -c -O $LAPACK_ARCHIVE.part "$LAPACK_URL/$LAPACK_ARCHIVE"
mv $LAPACK_ARCHIVE.part $LAPACK_ARCHIVE
fi
sha1sum -c $ATLAS_ARCHIVE.sha1
sha1sum -c $LAPACK_ARCHIVE.sha1
ATLAS_DIRNAME=$(tar ft $ATLAS_ARCHIVE | head -n 1 | cut -d / -f 1)
LAPACK_DIRNAME=$(tar ft $LAPACK_ARCHIVE | head -n 1 | cut -d / -f 1)
# Extract the archives
cd $TMP
tar xf $CWD/$LAPACK_ARCHIVE
tar xf $CWD/$ATLAS_ARCHIVE
# Build the temporary Lapack library
cd $LAPACK_DIRNAME
sed "s/-m32/-m$BITS/" $CWD/make.inc > make.inc
make lib
# Build the ATLAS library (static)
mkdir -p $TMP/$ATLAS_DIRNAME/build
cd $TMP/$ATLAS_DIRNAME/build
../configure \
--prefix=/usr \
--with-netlib-lapack=$TMP/$LAPACK_DIRNAME/lapack_LINUX.a \
-b $BITS -D c -DPentiumCPS=$MHZ -Fa alg -fPIC
make
make install DESTDIR=$PKG/usr
if [ "x$ARCH" = xx86_64 ]; then
mv $PKG/usr/lib $PKG/usr/lib64
fi
# Build the ATLAS library (shared)
cd $TMP/$ATLAS_DIRNAME/build/lib
make shared
install -s -m 0644 *.so $PKG/usr/lib$LIBDIRSUFFIX
# Install documentation
mkdir -p $PKG/usr/doc/$NAMEPKG-$VERSION/lapack
cd $TMP/$LAPACK_DIRNAME
install -m 644 LICENSE README $PKG/usr/doc/$NAMEPKG-$VERSION/lapack
cd $TMP/$ATLAS_DIRNAME
install -m 0644 INSTALL.txt README doc/* $PKG/usr/doc/$NAMEPKG-$VERSION
# Copy slack-desc file
install -D -m 644 $CWD/slack-desc $PKG/install/slack-desc
# Package the tree
cd $PKG
mkdir -p $OUT
PACKAGING="
chown root:root . -R
/sbin/makepkg -l y -c n $OUT/$NAMEPKG-$VERSION-$ARCH-$BUILD.$EXT
rm -rf $PKG
rm -rf $TMP/$LAPACK_DIRNAME $TMP/$ATLAS_DIRNAME
"
if type -p fakeroot ; then
echo "$PACKAGING" | fakeroot
else
su -c "$PACKAGING"
fi