summaryrefslogtreecommitdiff
path: root/network/irssi_otr/irssi_otr.SlackBuild
blob: c95c59c4b02d0e3a9acb3fd2be70abb472b7c626 (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
#!/bin/sh

# Slackware build script for irssi_otr

# Written by B. Watson (yalhcru@gmail.com)

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

# 20130326 bkw:
# - Use a private copy of libotr 3.x, statically built.
#   Needed because SBo libotr has upgraded to 4.0, which this
#   plugin won't build with. Removed libotr from REQUIRES in .info file.
# - Add xchat support (upstream already supported it, no patching needed)
# - Better template compliance (cmake in a build dir, actually use SLKCFLAGS)
# - Bumped BUILD to 2

# For anyone that gets tempted to try the latest git irssi-otr code, here's
# what I found when I messed with a git checkout from 20130326:

# Pros: libotr 4.0 is supported
#       weechat support has been added
# Cons: xchat support is totally broken
#       irssi segfaults on plugin load, unless the plugin is built with -O0
#       the weechat support doesn't work without patching

# In view of the above, I decided to stick with the irssi_otr 0.3 release.
# Sorry, weechat users.

PRGNAM=irssi_otr
VERSION=${VERSION:-0.3}
BUILD=${BUILD:-2}
TAG=${TAG:-_SBo}

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

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

if [ "$ARCH" = "i486" ]; then
  SLKCFLAGS="-O2 -march=i486 -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

TARNAM=$( echo $PRGNAM | sed 's/_/-/g' )
LIBOTR_VERSION=3.2.1

IRSSI=${IRSSI:-yes}
IRSSI_PLUGIN="libotr.so"
IRSSI_PLUGIN_DIR=$PKG/usr/lib$LIBDIRSUFFIX/irssi/modules

XCHAT=${XCHAT:-yes}
XCHAT_PLUGIN="libxchatotr.so"
XCHAT_PLUGIN_DIR=$PKG/usr/lib$LIBDIRSUFFIX/xchat/plugins

if [ "$IRSSI" != "yes" -a "$XCHAT" != "yes" ]; then
  echo "Can't build with both irssi and xchat disabled (nothing to build)" 2>&1
  exit 1
fi

set -e

rm -rf $PKG
mkdir -p $TMP $PKG $OUTPUT
cd $TMP

# First, build our static libotr3. It won't get installed as part of
# the package.
rm -rf libotr-$LIBOTR_VERSION
tar xvf $CWD/libotr-$LIBOTR_VERSION.tar.gz
cd libotr-$LIBOTR_VERSION

CFLAGS="$SLKCFLAGS" \
CXXFLAGS="$SLKCFLAGS" \
./configure --prefix=$( pwd )/installed \
  --enable-static \
  --disable-shared \
  --sysconfdir=/etc \
  --localstatedir=/var \
  --build=$ARCH-slackware-linux

make
make install

# Now we can build irssi_otr.
cd $TMP
rm -rf $TARNAM-$VERSION
tar xvf $CWD/$TARNAM-$VERSION.tar.gz
cd $TARNAM-$VERSION
chown -R root:root .
find -L . \
 \( -perm 777 -o -perm 775 -o -perm 750 -o -perm 711 -o -perm 555 \
  -o -perm 511 \) -exec chmod 755 {} \; -o \
 \( -perm 666 -o -perm 664 -o -perm 640 -o -perm 600 -o -perm 444 \
 -o -perm 440 -o -perm 400 \) -exec chmod 644 {} \;

mkdir build
cd build

if [ "$IRSSI" = "yes" ]; then
  CLIENTS=" irssi"
  cmake -DCMAKE_C_FLAGS_RELEASE="$SLKCFLAGS" \
        -DCMAKE_BUILD_TYPE="release"  \
        -DLIBOTR_INCLUDE_DIR=$TMP/libotr-$LIBOTR_VERSION/installed/include \
        -DLIBOTR_LIBRARY=$TMP/libotr-$LIBOTR_VERSION/installed/lib/libotr.a \
        ..
  make

  # Easier to manually install than to coerce cmake's install
  # target into using LIBDIRSUFFIX
  mkdir -p $IRSSI_PLUGIN_DIR
  install -s -o root -g root -m 0755 $IRSSI_PLUGIN $IRSSI_PLUGIN_DIR
fi

if [ "$XCHAT" = "yes" ]; then
  CLIENTS="$CLIENTS xchat"
  rm -rf *
  sed -i 's,irssi,xchat,' ../tarballdefs.cmake
  cmake -DCMAKE_C_FLAGS_RELEASE="$SLKCFLAGS" \
      -DCMAKE_BUILD_TYPE="release"  \
      -DLIBOTR_INCLUDE_DIR=$TMP/libotr-$LIBOTR_VERSION/installed/include \
      -DLIBOTR_LIBRARY=$TMP/libotr-$LIBOTR_VERSION/installed/lib/libotr.a \
      -DXCHAT_INCLUDE_DIR=$CWD \
      ..

  make
  mkdir -p $XCHAT_PLUGIN_DIR
  install -s -o root -g root -m 0755 $XCHAT_PLUGIN $XCHAT_PLUGIN_DIR
fi

cd ..

mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION
cp -a LICENSE README ChangeLog *.txt $PKG/usr/doc/$PRGNAM-$VERSION
[ "$XCHAT" = "yes" ] && cp -a README.xchat $PKG/usr/doc/$PRGNAM-$VERSION
cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild

mkdir -p $PKG/install
sed "s/@CLIENTS@/$CLIENTS/" $CWD/slack-desc > $PKG/install/slack-desc

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