aboutsummaryrefslogtreecommitdiff
path: root/development/astyle/astyle.SlackBuild
blob: 07cf9d9c5783889994fdbad1f4210b9788151f01 (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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
#!/bin/sh

# Slackware build script for Artistic Style

# Copyright 2020 B. Watson <yalhcru@gmail.com>

# Copyright 2017,2018 Nate Bargmann <email removed>

# Ryan P.C. McQuen | Everett, WA | <email removed>

# Formerly maintained by Daniel Jordan <email removed>
#    - updated version number
#    - added default variable options
#    - auto detect ARCH
#    - build and install shared libraries [bkw: say what?]
#
# Originally by Dugan Chen <email removed>

# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version, with the following exception:
# the text of the GPL license may be omitted.

# This program is distributed in the hope that it will be useful, but
# without any warranty; without even the implied warranty of
# merchantability or fitness for a particular purpose. Compiling,
# interpreting, executing or merely reading the text of the program
# may result in lapses of consciousness and/or very being, up to and
# including the end of all existence and the Universe as we know it.
# See the GNU General Public License for more details.

# You may have received a copy of the GNU General Public License
# along with this program (most likely, a file named COPYING). If
# not, see <http://www.gnu.org/licenses/>.

# 20200113 bkw:
# - Take over maintenance.
# - Add man page and privacy patch, BUILD=2.
# - Get rid of "shared" from make command. We weren't installing the
#   shared library anyway, despite the comment above from Daniel
#   Jordan. The only thing that lists astyle as a dependency is ebe,
#   and that's a runtime dep (it executes the astyle command, doesn't
#   link the shared lib). If someone needs the shared lib, I can add
#   it to the build, but for now I'm leaving it alone because the
#   .so isn't versioned (upgrades may cause breakage).
# - Simplify and tweak the script.

PRGNAM=astyle
VERSION=${VERSION:-3.1}
BUILD=${BUILD:-2}
TAG=${TAG:-_SBo}

TARBALL="astyle_${VERSION}_linux.tar.gz"

if [ -z "$ARCH" ]; then
  case "$( uname -m )" in
    i?86) ARCH=i586 ;;
    arm*) ARCH=arm ;;
       *) ARCH=$( uname -m ) ;;
  esac
fi

CWD=$(pwd)
TMP=${TMP:-/tmp/SBo}
PKG=$TMP/package-$PRGNAM
OUTPUT=${OUTPUT:-/tmp}

if [ "$ARCH" = "i586" ]; then
  SLKCFLAGS="-O2 -march=i586 -mtune=i686"
  LIBDIRSUFFIX=""
elif [ "$ARCH" = "i686" ]; then
  SLKCFLAGS="-O2 -march=i686 -mtune=i686"
  LIBDIRSUFFIX=""
elif [ "$ARCH" = "x86_64" ]; then
  SLKCFLAGS="-O2 -fPIC"
  LIBDIRSUFFIX="64"
else
  SLKCFLAGS="-O2"
  LIBDIRSUFFIX=""
fi

set -e

rm -rf $PKG
mkdir -p $TMP $PKG $OUTPUT
cd $TMP
rm -rf $PRGNAM
tar xvf $CWD/$TARBALL
cd $PRGNAM
chown -R root:root .

# Don't change this back to template please. Every file in the tarball
# is +x, and *none* of them need to be.
find -L .  -type d -a -exec chmod 755 {} \+ -o \
           -type f -a -exec chmod 644 {} \+

DOCDIR=$PKG/usr/doc/$PRGNAM-$VERSION

# This patch (from Debian) prevents the user's browser from trying to
# load images from sourceforge, when viewing the *local* HTML docs in
# a browser.
patch -p1 < $CWD/privacy.patch

CFLAGS="$SLKCFLAGS -Wl,-s" \
CXXFLAGS="$SLKCFLAGS -Wl,-s" \
  make -C build/gcc release
  make -C build/gcc install prefix=$PKG/usr SYSCONF_PATH=$DOCDIR

# Man page borrowed from Debian. It's kind of a placeholder, will
# expand it someday.
mkdir -p $PKG/usr/man/man1
sed -e "s|@VERSION@|$VERSION|" \
    -e "s|@DATE@|$( date +"%B %e, %Y" )|" \
    $CWD/$PRGNAM.1 | \
    gzip -9c > $PKG/usr/man/man1/$PRGNAM.1.gz

cp -a *.md file $DOCDIR
sed -i 's,\r,,' $DOCDIR/file/*

cat $CWD/$PRGNAM.SlackBuild > $DOCDIR/$PRGNAM.SlackBuild

mkdir -p $PKG/install
cat $CWD/slack-desc > $PKG/install/slack-desc

cd $PKG
/sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.${PKGTYPE:-tgz}