#!/bin/sh

# acpid.SlackBuild
# by Stuart Winter <stuart@armedslack.org> for the Slackware porting Project.
# Based on the original Slackware build script.
# 1-May-2004

# Paths to skeleton port's source & real Slackware source tree:
export CWD=$SLACKSOURCE/$PKGSERIES/$PKGNAM
export PORTCWD=$PWD

# Temporary build locations:
export TMPBUILD=$TMP/build-$PKGNAM
export PKG=$TMP/package-$PKGNAM
mkpkgdirs # Delete and re-create temporary directories

# Extract source:
tar xvvf $CWD/acpid-$VERSION.tar.*
cd $PKGNAM-$VERSION
slackhousekeeping

# Create Package framework:
mkdir -vpm755 $PKG/usr/{bin,sbin,doc/acpid-$VERSION,man/man8}
mkdir -vpm755 $PKG/etc/{acpi/events,rc.d}

# Configure ;-)
sed -ie 's/^CFLAGS =\(.*\)$/CFLAGS = -march=armv4 -mtune=xscale \1/' Makefile

# Build:
make $NUMJOBS || failmake

# Install binaries:
install -vpm755 acpid $PKG/usr/sbin
install -vpm755 acpi_listen $PKG/usr/bin/

# Install man pages:
install -vpm644 acpi_listen.8 acpid.8 $PKG/usr/man/man8

# Install docs:
cp -a Changelog README \
      $PKG/usr/doc/acpid-$VERSION

# Install other bits:
zcat $CWD/acpi_handler.sh.gz > $PKG/etc/acpi/acpi_handler.sh.new
chmod 755 $PKG/etc/acpi/acpi_handler.sh.new
zcat $CWD/default.gz > $PKG/etc/acpi/events/default

# Install run control script:
zcat $CWD/rc.acpid.gz > $PKG/etc/rc.d/rc.acpid
chmod 755 $PKG/etc/rc.d/rc.acpid

# Slackware policies:
cd $PKG
slackstripall   # strip all .a archives and all ELFs
slackgzpages -i # compress man & info pages and delete usr/info/dir
slackslack      # set all files to root.root, chmod -R og-w, slackchown, slack644docs
slackdesc       # install slack-desc and doinst.sh
slackmp         # run makepkg -l y -c n

# Perform any final checks on the package:
cd $PKG
slackhlinks     # search for any hard links

