summaryrefslogtreecommitdiffstats
path: root/packaging/slackware/eulogium.SlackBuild
blob: 664134eec0e0c1fd6f051207158e6a0d5fee4ab5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#!/bin/bash
#
# Begin eulogium.SlackBuild
#
# Copyright (C) 2012-2013  Jerome Pinot <ngc891@gmail.com>
# All rights reserved.
#
# Redistribution and use of this script, with or without modification, 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.

NAME=eulogium
BUILD=${BUILD:-1jp}
CWD=$(pwd)
TMP=${TMP:-/tmp}
PKG=${TMP}/package-${NAME}

# First check if we are in the right folder
if [ -f ./${NAME}.SlackBuild ]; then
  echo 'Found SlackBuild'
else
  echo 'Error: You must run this script from the packaging/slackware sub-folder!'
  exit 1
fi

# Get the version number from configure.ac
if [ -f ../../configure.ac ];then
  VERSION=`grep "AC_INIT" ../../configure.ac | cut -d' ' -f2 | sed -e 's/\[//' -e 's/\],//'`
else
  echo "Error: can't find configure.ac!"
  exit 2
fi

# if ${ARCH} is unset, we have to guess it with uname
if [ -z "${ARCH}" ]; then
  case "$(uname -m)" in
    i?86) export ARCH=i486 ;;
    arm*) export ARCH=arm ;;
    *)    export ARCH=$(uname -m) ;;
  esac
fi

# Set generic flags for gcc
SCFLAGS='-O2'
if [ "${ARCH}" = "i486" ]; then
  SCFLAGS="${SCFLAGS} -march=i486 -mtune=i686"
  LIBDIR="/usr/lib"
elif [ "${ARCH}" = "x86_64" ]; then
  SCFLAGS="${SCFLAGS} -fPIC"
  LIBDIR="/usr/lib64"
elif [ "${ARCH}" = "arm" ]; then
  SCFLAGS="${SCFLAGS} -march=armv4 -mtune=xscale"
  LIBDIR="/usr/lib"
fi

# Creating directories
if [ ! -d ${TMP} ]; then
  mkdir -p ${TMP}
fi
rm -rf ${PKG}
mkdir -p ${PKG}

# Configuring
cd ../..
CFLAGS="${SCFLAGS}" \
  ./configure \
    --prefix=/usr \
    --libdir=${LIBDIR} \
    --mandir=/usr/man \
    --docdir=/usr/doc/${NAME}-${VERSION}

# Building
make

# Installing
make DESTDIR=${PKG} install

# Cleaning
cd ${PKG}
gzip -9 usr/man/man1/${NAME}.1

find ${PKG} | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null
find ${PKG} | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null

# Building the package
mkdir install
install -m644 ${CWD}/doinst.sh install/
install -m644 ${CWD}/slack-desc install/
install -m644 ${CWD}/slack-required install/
makepkg -l y -c n ${CWD}/${NAME}-${VERSION}-${ARCH}-${BUILD}.txz
rm -rf ${PKG}

# End eulogium.SlackBuild