summaryrefslogtreecommitdiffstats
path: root/development/astyle/astyle.SlackBuild
blob: b903f559e02222bbb5d82958f35cb15601282599 (about) (plain) (blame)
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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
#!/bin/bash

# Slackware build script for Artistic Style

# Copyright 2020-2023 B. Watson <urchlay@slackware.uk>

# 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/>.

# 20240313 bkw: update for v3.4.13.
# 20231101 bkw: update for v3.4.10.
# 20230918 bkw: update for v3.4.6, fix zsh completion.

# 20230818 bkw:
# - Update for v3.4.
# - Upstream includes a man page now, use it instead of Debian's.
# - Use sed instead of a patch, for privacy in the HTML files.
# - Move the .ini files to /usr/share/astyle.
# - Install the shell completions (new in 3.4).

# 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.

cd $(dirname $0) ; CWD=$(pwd)

PRGNAM=astyle
VERSION=${VERSION:-3.4.13}
BUILD=${BUILD:-1}
TAG=${TAG:-_SBo}
PKGTYPE=${PKGTYPE:-tgz}

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

if [ ! -z "${PRINT_PACKAGE_NAME}" ]; then
  echo "$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE"
  exit 0
fi

TMP=${TMP:-/tmp/SBo}
PKG=$TMP/package-$PRGNAM
OUTPUT=${OUTPUT:-/tmp}

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

set -e

rm -rf $PKG
mkdir -p $TMP $PKG $OUTPUT
cd $TMP
rm -rf $PRGNAM-$VERSION
tar xvf $CWD/$PRGNAM-$VERSION.tar.bz2
cd $PRGNAM-$VERSION
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 prevents the user's browser from trying to load images from
# sourceforge, when viewing the *local* HTML docs in a browser. It's
# based on a patch from Debian.
sed -i 's,<img[^>]*sflogo\.[^>]*>,Artistic Style on SourceForge.net,' doc/*.html

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

mkdir -p $PKG/usr/man/man1
gzip -9c < man/$PRGNAM.1 > $PKG/usr/man/man1/$PRGNAM.1.gz

# 20230818 bkw: this stuff used to be in the doc dir. Makes more sense
# to keep it in /usr/share... though I'll keep a symlink in the doc dir
# for users of the old package.
mkdir -p $PKG/usr/share/$PRGNAM
cp -a file/* $PKG/usr/share/$PRGNAM
ln -s ../../share/$PRGNAM $DOCDIR/file

# 20230820 bkw: upstream added shell completion support.
# 20230918 bkw: the zsh completion is broken, fix it.
sed -i 's,"\(mode\[\),"--\1,' sh-completion/astyle.zsh
mkdir -p $PKG/usr/share/bash-completion/completions \
         $PKG/usr/share/zsh/site-functions \
         $PKG/etc/fish/completions
install -m0644 sh-completion/astyle.bash $PKG/usr/share/bash-completion/completions/astyle
install -m0644 sh-completion/astyle.zsh  $PKG/usr/share/zsh/site-functions/_astyle
install -m0644 sh-completion/astyle.fish $PKG/etc/fish/completions

cp -a *.md $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