aboutsummaryrefslogtreecommitdiff
path: root/development/bacon/bacon.SlackBuild
blob: 1191a28ee197a420a9eceae7d707948b395a6309 (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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
#!/bin/bash

# Slackware build script for bacon

# Written by B. Watson (urchlay@slackware.uk)

# Licensed under the WTFPL. See http://www.wtfpl.net/txt/copying/ for details.

# 20250130 bkw: update for v5.0.1.
# 20240812 bkw:
# - update for v5.0.
# - enable the GTK3 GUI.
# 20230814 bkw:
# - update to v4.7.
# - switch to self-hosted download, as upstreams disappears the
#   previous version immediately upon releasing a new one.
# - prescaled icons.
# - add CHANGES to doc dir.

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

PRGNAM=bacon
VERSION=${VERSION:-5.0.1}
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"
  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

# The --enable-gui-* and --disable-gui-* don't actually work.
# We can't run autoreconf either (fails).
# The intent here is to build:
# The GTK3 gui if requested by the user (but never automatically),
# The FLTK gui if fltk is installed and not disabled with FLTK=no,
# or the TK gui if fltk is missing or disabled via FLTK=no.
# Either way, we don't currently support the gtk 2 gui (it depends
# on webkitgtk 2.x, which is outdated and gone from our repo).
if [ "${GTK3:-no}" = "yes" ]; then
  if ! pkg-config --exists gtksourceview-4; then
  cat <<EOF
$0: GTK=3 is set, but gtksourceview4 is not installed. Aborting.
EOF
    exit 1
  fi
  GUI="FLTK=false TK=false GTK3=true LEGACY=false"
  GUITYPE=GTK3
elif [ "${FLTK:-yes}" = "yes" -a -x /usr/bin/fltk-config ]; then
  GUI="FLTK=true TK=false GTK3=false LEGACY=false"
  GUITYPE=FLTK
else
  GUI="FLTK=false TK=true GTK3=false LEGACY=false"
  GUITYPE=TK
fi

rm -rf $PKG
mkdir -p $TMP $PKG $OUTPUT
cd $TMP
rm -rf $PRGNAM-$VERSION
tar xvf $CWD/$PRGNAM-$VERSION.tar.gz
cd $PRGNAM-$VERSION
chown -R root:root .
find -L .  -perm /111 -a \! -perm 755 -a -exec chmod 755 {} \+ -o \
        \! -perm /111 -a \! -perm 644 -a -exec chmod 644 {} \+

# Keep the .xbm icon in a private directory, so nothing else accidentally
# uses it (it's ugly).
sed -i 's,/share/pixmaps/,/share/BaCon/,' bacon.bac

# I use this when editing the script, to avoid the 5+ minute build time.
# The C implementation is thousands of times faster than the shell script.
if [ "${CHEAT:-no}" = "yes" -a -x /usr/bin/bacon ]; then
  sed -i 's,\$(BSHELL) \./bacon\.sh,/usr/bin/bacon,' Makefile.in
fi

CFLAGS="$SLKCFLAGS" \
CXXFLAGS="$SLKCFLAGS" \
./configure \
  --prefix=/usr \
  --libdir=/usr/lib${LIBDIRSUFFIX} \
  --sysconfdir=/etc \
  --localstatedir=/var \
  --mandir=/usr/man \
  --docdir=/usr/doc/$PRGNAM-$VERSION \
  --with-bash \
  --build=$ARCH-slackware-linux

# The -j1 really is needed here. Anyway the build process has a
# 5+ minute "Converting 'bacon.bac'" that has to finish before
# the other make targets can begin, so patching the Makefile to
# support parallelism wouldn't actually speed it up noticeably.
# The fakehome stuff is to keep it from creating or reading a
# /root/.bacon/bacon.cfg file (we don't want to write outside of $TMP).
mkdir -p $( pwd )/fakehome
HOME=$( pwd )/fakehome make -j1 $GUI
make -j1 install DESTDIR=$PKG $GUI

gzip -9 $PKG/usr/man/man*/*

# This is where we patched it to look for this icon:
mv $PKG/usr/share/pixmaps/BaCon.xbm $PKG/usr/share/BaCon/

# Various icons already in /usr/share/pixmaps. Prescale.
for icon in BaCon BaConEyes BaConStrip; do
  PNG=$PKG/usr/share/pixmaps/$icon.png
  for px in 16 22 32 48 64 128 256; do
    sz=${px}x${px}
    dir=$PKG/usr/share/icons/hicolor/$sz/apps
    mkdir -p $dir
    convert -resize $sz $PNG $dir/$icon.png
  done
done

# The GUI has the documentation path baked in, so symlink it to the
# the Slackware doc dir.
PKGDOC=$PKG/usr/doc/$PRGNAM-$VERSION
mkdir -p $PKGDOC
cp -a README* CHANGES* $PKGDOC
ln -s ../../share/BaCon/documentation $PKGDOC/documentation
ln -s ../../share/BaCon/LICENSE $PKGDOC/LICENSE
cat $CWD/$PRGNAM.SlackBuild > $PKGDOC/$PRGNAM.SlackBuild

# The encscript synax file (bacon.st) gets installed to the right place.
# Move the others to the right places.
mkdir -p $PKG/usr/share/vim/vimfiles/syntax/
mv $PKG/usr/share/BaCon/syntax/bacon.vim $PKG/usr/share/vim/vimfiles/syntax/bacon.vim
mkdir -p $PKG/usr/share/gtksourceview-3.0/language-specs/
mkdir -p $PKG/usr/share/gtksourceview-4/language-specs
cp $PKG/usr/share/BaCon/syntax/bacon.lang $PKG/usr/share/gtksourceview-4/language-specs
mv $PKG/usr/share/BaCon/syntax/bacon.lang $PKG/usr/share/gtksourceview-3.0/language-specs/bacon.lang

# The vim syntax file works, but won't be used automatically without this:
mkdir -p $PKG/usr/share/vim/vimfiles/ftdetect
echo "au! BufRead,BufNewFile *.bac,*.bacon   setfiletype bacon" > \
     $PKG/usr/share/vim/vimfiles/ftdetect/bacon.vim

mkdir -p $PKG/install
sed "s,@GUITYPE@,$GUITYPE," < $CWD/slack-desc > $PKG/install/slack-desc
cat $CWD/doinst.sh > $PKG/install/doinst.sh

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