summaryrefslogtreecommitdiff
path: root/source/l/ncurses/ncurses.SlackBuild
blob: 992789e368e64692dddf2673b3b17a068836dc95 (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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
#!/bin/sh

# Copyright 2000-2011, 2013, 2014, 2015  Patrick J. Volkerding, Sebeka, MN, USA
# 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.

PKGNAM=ncurses
VERSION=${VERSION:-$(echo $PKGNAM-*.tar.?z | rev | cut -f 3- -d . | cut -f 1 -d - | rev)}
BUILD=${BUILD:-4}

# Automatically determine the architecture we're building on:
if [ -z "$ARCH" ]; then
  case "$( uname -m )" in
    i?86) export ARCH=i486 ;;
    arm*) export ARCH=arm ;;
    # Unless $ARCH is already set, use uname -m for all other archs:
       *) export ARCH=$( uname -m ) ;;
  esac
fi

CWD=$(pwd)
TMP=${TMP:-/tmp}
PKG=$TMP/package-ncurses

if [ "$ARCH" = "i486" ]; then
  SLKCFLAGS="-O2 -march=i486 -mtune=i686"
  LIBDIRSUFFIX=""
elif [ "$ARCH" = "s390" ]; then
  SLKCFLAGS="-O2"
  LIBDIRSUFFIX=""
elif [ "$ARCH" = "x86_64" ]; then
  SLKCFLAGS="-O2 -fPIC"
  X86_64OPTS=" --with-chtype=long --with-mmask-t=long "
  LIBDIRSUFFIX="64"
else
  SLKCFLAGS="-O2"
  LIBDIRSUFFIX=""
fi

ncurses_configure() {
CFLAGS="$SLKCFLAGS" \
./configure \
  --prefix=/usr \
  --libdir=/usr/lib${LIBDIRSUFFIX} \
  --mandir=/usr/man \
  --with-gpm \
  --disable-termcap \
  --with-shared \
  --with-cxx-shared \
  --without-normal \
  --without-debug \
  --without-profile \
  --enable-symlinks \
  --enable-pc-files \
  --with-pkg-config-libdir=/usr/lib${LIBDIRSUFFIX}/pkgconfig \
  --without-ada \
  $X86_64OPTS \
  --program-suffix="" \
  --program-prefix="" \
  $WIDEC \
  --build=$ARCH-slackware-linux
}

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

cd $TMP
rm -rf ncurses-$VERSION
tar xvf $CWD/ncurses-$VERSION.tar.?z || exit 1
cd ncurses-$VERSION || exit 1
chown -R root:root .

# This allows some other patches to come first by making them bz2...  gz next
if [ ! -z "$(ls $CWD/patches/ncurses*bz2 2> /dev/null)" ]; then
  bzcat $CWD/patches/ncurses*bz2 > tmp-patch.sh
  bash tmp-patch.sh || exit 1
fi
# Apply official upstream patches.
if [ ! -z "$(ls $CWD/patches/ncurses-$VERSION-2*.patch.gz 2> /dev/null)" ]; then
  for file in $CWD/patches/ncurses-$VERSION-2*.patch.gz ; do
    zcat $file | patch -p1 --verbose || exit 1
  done
fi

# Apply upstream patch collection:
xzcat $CWD/ncurses-5.9-20141206-patch.sh.xz > ncurses-5.9-20141206-patch.sh
sh ncurses-5.9-20141206-patch.sh

zcat $CWD/ncurses.mkhashsize.diff.gz | patch -p1 --verbose || exit 1

ncurses_configure
make -j4 || exit 1
# Spamming the partition.
# Sorry, but it's about the only way to get a good 'tic'.
make install
# Install the package:
make install DESTDIR=$PKG

# Build/install again with wide character support:
make clean
WIDEC=--enable-widec
ncurses_configure
make -j4 || exit 1
make install
make install DESTDIR=$PKG

if [ ! -d $PKG/usr/include/ncursesw -a ! -L $PKG/usr/include/ncursesw ]; then
  ( cd $PKG/usr/include ; ln -sf ncurses ncursesw )
fi

# Strip stuff:
find $PKG | xargs file | grep -e "executable" -e "shared object" \
  | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null

# Move the include files from /usr/include into
# /usr/include/ncurses, then make symlinks back
# into /usr/include.
( cd $PKG/usr/include
  rm -rf ncurses
  mkdir ncurses
  mv *.h ncurses
  for file in ncurses/* ; do
    ln -sf $file .
  done
  # This shouldn't clobber the real one:
  mv termcap.h termcap-ncurses.h
)

# Move the ncurses libraries into /lib, since they're important:
mkdir -p $PKG/lib${LIBDIRSUFFIX}
( cd $PKG/usr/lib${LIBDIRSUFFIX}
  chmod 755 *.so
  chmod 644 *.a
  mv libncurses.so.5* $PKG/lib${LIBDIRSUFFIX}
  mv libncursesw.so.5* $PKG/lib${LIBDIRSUFFIX}
  rm -f libncurses.so
  ln -sf /lib${LIBDIRSUFFIX}/libncurses.so.5 libncurses.so
  rm -f libncursesw.so
  ln -sf /lib${LIBDIRSUFFIX}/libncursesw.so.5 libncursesw.so
  # Olde obsolete names, just in case
  rm -f libcurses.so
  ln -sf libncurses.so libcurses.so
  rm -f libcursesw.so
  ln -sf libncursesw.so libcursesw.so
)

# Set TERMINFO to point to the package:
export TERMINFO=$PKG/usr/share/terminfo
# Fix the xterm, screen, rxvt, and Eterm entries:
for tfile in $CWD/xterm.terminfo $CWD/screeninfo.src $CWD/rxvt.terminfo $CWD/Eterm.ti ; do
  if [ -r $tfile ]; then
    progs/tic -v $tfile
  fi
done
unset TERMINFO

# Then, add /usr/doc/ncurses-xxxxx with appropriate files.
mkdir -p $PKG/usr/doc/ncurses-$VERSION
cp -a \
  ANNOUNCE INSTALL MANIFEST NEWS README* TO-DO \
  $PKG/usr/doc/ncurses-$VERSION
mkdir -p $PKG/usr/doc/ncurses-$VERSION/c++
cp -a \
  c++/NEWS c++/PROBLEMS c++/README-first \
  $PKG/usr/doc/ncurses-$VERSION/c++
if [ -r $PKG/usr/man/man1/tack.1 ]; then
  gzip -9 --force $PKG/usr/man/man1/tack.1
fi

# We don't need the log of every change here, but we'll take some.
# If you need the whole thing probably you already extracted the
# sources...
if [ -r NEWS ]; then
  DOCSDIR=$(echo $PKG/usr/doc/${PKGNAM}-$VERSION)
  cat NEWS | head -n 1000 > $DOCSDIR/NEWS
  echo >> $DOCSDIR/NEWS
  echo "        +++  SNIP  +++  " >> $DOCSDIR/NEWS
  echo >> $DOCSDIR/NEWS
  echo "  see source code for full file  " >> $DOCSDIR/NEWS
  echo >> $DOCSDIR/NEWS
  touch -r NEWS $DOCSDIR/NEWS
fi

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

cd $PKG
/sbin/makepkg -l y -c n $TMP/ncurses-$VERSION-$ARCH-$BUILD.txz