summaryrefslogtreecommitdiffstats
path: root/source/l/ncurses/ncurses.SlackBuild
blob: ae7e0e2e4b495dd5ec05597fabbc1e23fe653034 (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
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
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
#!/bin/bash

# Copyright 2000-2011, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2024  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.

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

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

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

# If the variable PRINT_PACKAGE_NAME is set, then this script will report what
# the name of the created package would be, and then exit. This information
# could be useful to other scripts.
if [ ! -z "${PRINT_PACKAGE_NAME}" ]; then
  echo "$PKGNAM-$(echo $VERSION | tr - _)-$ARCH-$BUILD.txz"
  exit 0
fi

NUMJOBS=${NUMJOBS:-" -j$(expr $(nproc) + 1) "}

TMP=${TMP:-/tmp}
PKG=$TMP/package-ncurses

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

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 .

CFLAGS="$SLKCFLAGS" \
./configure \
  --prefix=/usr \
  --libdir=/usr/lib${LIBDIRSUFFIX} \
  --mandir=/usr/man \
  --with-manpage-format=normal \
  --enable-widec \
  --enable-colorfgbg \
  --enable-hard-tabs \
  --enable-overwrite \
  --enable-xmc-glitch \
  --with-cxx-binding \
  --with-cxx-shared \
  --with-shared \
  --with-versioned-syms \
  --with-termlib=tinfo \
  --with-ticlib=tic \
  --without-debug \
  --without-normal \
  --without-profile \
  --enable-symlinks \
  --enable-pc-files \
  --with-pkg-config-libdir=/usr/lib${LIBDIRSUFFIX}/pkgconfig \
  --without-ada \
  --program-suffix="" \
  --program-prefix="" \
  --build=$ARCH-slackware-linux || exit 1

make $NUMJOBS || exit 1
make install DESTDIR=$PKG || exit 1

# Make a termcap file in case anyone actually needs it:
echo "#       /etc/termcap" > misc/termcap
grep \$Revision: misc/terminfo.src >> misc/termcap
grep \$Date: misc/terminfo.src >> misc/termcap
echo "#" >> misc/termcap
echo "#       Converted from terminfo.src for Slackware:" >> misc/termcap
echo "#       tic -C -t terminfo.src > termcap" >> misc/termcap
echo "#" >> misc/termcap
echo "#       This file is included to support legacy applications using libtermcap." >> misc/termcap
echo "#       Modern applications will use ncurses/terminfo instead." >> misc/termcap
echo "#" >> misc/termcap
echo "#------------------------------------------------------------------------------" >> misc/termcap
echo "#" >> misc/termcap
tic -C -t misc/terminfo.src >> misc/termcap
touch -r misc/terminfo.src misc/termcap
mkdir $PKG/etc
cp -a misc/termcap $PKG/etc/termcap

# 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 ncurses libraries into /lib (for no reason basically, because we DO
# NOT officially support a separate /usr partition):
mkdir -p $PKG/lib${LIBDIRSUFFIX}
( cd $PKG/usr/lib${LIBDIRSUFFIX}
  mv lib*.so.?.? lib*.so.? $PKG/lib${LIBDIRSUFFIX}
  for file in *.so ; do
    if [ -L $file ]; then
      rm $file
      ln -sf ../../lib${LIBDIRSUFFIX}/${file}.? $file
    fi
  done
)

# Make sure anything requesting the non-wide libraries will be directed to
# the wide ones:
for library in form menu ncurses ncurses++ panel ; do
  # Add a loader script:
  echo "INPUT(-l${library}w)" > $PKG/usr/lib${LIBDIRSUFFIX}/lib${library}.so
  # Make a pkg-config file symlink:
  ln -sf ${library}w.pc $PKG/usr/lib${LIBDIRSUFFIX}/pkgconfig/${library}.pc
done

# Support the obsolete:
echo "INPUT(-ltinfo)" > $PKG/usr/lib${LIBDIRSUFFIX}/libtermcap.so

# In case anything is linked to the non-wide ncurses libraries, make some
# compatibility symlinks:
( cd $PKG/lib${LIBDIRSUFFIX}
  SONAME=$(echo libncursesw.so.? | rev | cut -f 1 -d .)
  for library in form menu ncurses ncurses++ panel ; do
    ln -sf lib${library}w.so.$SONAME lib${library}.so.$SONAME
  done
)

# Use linker loader scripts to make sure -tinfo dependency works:
( cd $PKG/usr/lib${LIBDIRSUFFIX}
  rm -f libcurses.so libcursesw.so libncurses.so libncursesw.so libtermcap.so
  echo "INPUT(-lncurses)" > libcurses.so
  echo "INPUT(-lncursesw)" > libcursesw.so
  echo "INPUT(libncurses.so.6 -ltinfo)" > libncurses.so
  echo "INPUT(libncursesw.so.6 -ltinfo)" > libncursesw.so
  echo "INPUT(-ltinfo)" > libtermcap.so
)

# NOTE 2024-04-29: I'm not sure these changes are still needed.
# Maybe GazL knows.
#
# Use various upstream/fixed/better terminfo files to update the terminfo
# database. Only *.terminfo files in $CWD/terminfo will be used.
export TERMINFO=$PKG/usr/share/terminfo
for tfile in $CWD/terminfo/*.terminfo ; do
  if [ -r $tfile ]; then
    progs/tic -v $tfile
  fi
done
unset TERMINFO

# Compress manual pages:
find $PKG/usr/man -type f -exec gzip -9 {} \+
for i in $( find $PKG/usr/man -type l ) ; do
  ln -s $( readlink $i ).gz $i.gz
  rm $i
done

# Add /usr/doc/ncurses-xxxxx with appropriate files:
mkdir -p $PKG/usr/doc/ncurses-$VERSION
cp -a \
  ANNOUNCE AUTHORS COPYING* INSTALL MANIFEST NEWS README* TO-DO VERSION \
  $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++
mkdir -p $PKG/usr/doc/ncurses-$VERSION/html
cp -a \
  doc/html/*.html \
  $PKG/usr/doc/ncurses-$VERSION/html

# 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

mkdir -p $PKG/install
zcat $CWD/doinst.sh.gz | sed "s,usr/lib,usr/lib${LIBDIRSUFFIX},g" > $PKG/install/doinst.sh
cat $CWD/slack-desc > $PKG/install/slack-desc

cd $PKG
/sbin/makepkg -l y -c n $TMP/ncurses-$(echo $VERSION | tr - _)-$ARCH-$BUILD.txz