Skip to content

Commit

Permalink
Add ncurses, enable Ada95 binding
Browse files Browse the repository at this point in the history
  • Loading branch information
qunying committed Jan 8, 2015
1 parent c7f9ab7 commit 9c11bae
Show file tree
Hide file tree
Showing 9 changed files with 2,466 additions and 0 deletions.
150 changes: 150 additions & 0 deletions ncurses/Eterm.ti
@@ -0,0 +1,150 @@
# Eterm terminfo file

Eterm|Eterm Terminal Emulator (X11 Window System),
# FIXME: xterm does not specify bce, bw, eo, or xon. Should we?
am, bw, bce, km, mir, msgr, xenl, xon, eo, mc5i,
cols#80, lines#24, it#8, lm#0, btns#5,
cr=\r, bel=^G,
colors#8, pairs#64,

# Scroll text down/up one line
ind=\n, ri=\eM,

# Clear entire screen (home, then clear to EOS), EOS, EOL, BOL
clear=\e[H\e[2J, ed=\e[J, el=\e[K, el1=\e[1K,

# Change scrolling region to lines $1+1 to $2+1
# %i means add one to params 1 and 2; convert from 0-based to
# 1-based counting.
csr=\e[%i%p1%d;%p2%dr,

# Move cursor to row $1+1, column $2+1. Can end with H or f
cup=\e[%i%p1%d;%p2%dH,
# Move cursor to column n, same row; or row n, same column
hpa=\e[%i%p1%dG, vpa=\e[%i%p1%dd,
# Move cursor up/down/forward/back by n chars
cuu=\e[%p1%dA, cud=\e[%p1%dB, cuf=\e[%p1%dC, cub=\e[%p1%dD,
# Move cursor up/down/forward/back by 1 char
cuu1=\e[A, cud1=\e[B, cuf1=\e[C, cub1=\b,
# Home cursor (row 1, col 1). Was \e[1;1H but 1's are redundant
home=\e[H,

# Enter/leave insert mode
smir=\e[4h, rmir=\e[4l,

# Set tab stops, clear tab stops, tab character
hts=\eH, tbc=\e[3g, ht=\t,

# Turn on/off auto margins
smam=\e[?7h, rmam=\e[?7l,
# Make cursor invisible, normal (bold cursor cvvis not supported)
civis=\e[?25l, cnorm=\e[?25h,
# Save/restore cursor position
sc=\e7, rc=\e8,

# Alternate character set (line drawing), enable/enter/exit ACS
acsc=``aaffggjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~,
# The line below is used by some vtXXX emulators, but I don't think it's right for us.
# acsc=+\020\,\021-\030.^Y0\333`\004a\261f\370g\361h\260i\316j\331k\277l\332m\300n\305o~p\304q\304r\304s_t\303u\264v\301w\302x\263y\363z\362{\343|\330}\234~\376,
enacs=\e)0, smacs=^N, rmacs=^O,

# Delete/insert n chars, 1 char
dch=\e[%p1%dP, ich=\e[%p1%d@, dch1=\e[P, ich1=\e[@,
# Delete/insert n lines, 1 line
dl=\e[%p1%dM, il=\e[%p1%dL, dl1=\e[M, il1=\e[L,
# Erase next n chars
ech=\e[%p1%dX,

# Activate SGR mode: bold, reverse video, blink (bright bg color)
bold=\e[1m, rev=\e[7m, blink=\e[5m,
# Start/stop underline, standout (reverse video)
smul=\e[4m, rmul=\e[24m, smso=\e[7m, rmso=\e[27m,
# Turn off all attributes (exit_attribute_mode)
sgr0=\e[m^O,
# Flash the screen (sets and resets reverse video for the whole screen)
flash=\e[?5h\e[?5l,

# Enter/leave application keypad mode. We always send the ANSI values
# because that seems to be the most portable solution. The valid escape
# sequences are here but are commented out for this reason. The 1st set
# is for keypad cursor keys, the second is for application cursor key
# mode. The third is what gets sent by default.
## smkx=\e=, rmkx=\e>,
smkx=, rmkx=,
## kcuu1=\e[Ox, kcud1=\e[Or, kcuf1=\e[Ov, kcub1=\e[Ot,
## kcuu1=\eOA, kcud1=\eOB, kcuf1=\eOC, kcub1=\eOD,
kcuu1=\e[A, kcud1=\e[B, kcuf1=\e[C, kcub1=\e[D,

# Keypad 7, 9, 5, 1, and 3. The 1st set are the appl. keypad mode
# sequences. The 2nd set are the values for Home/End/PgUp/PgDn.
# The 5 key is the same either way.
## ka1=\eOw, ka3=\eOy, kb2=\eOu, kc1=\eOq, kc3=\eOs,
ka1=\e[7~, ka3=\e[5~, kb2=\eOu, kc1=\e[8~, kc3=\e[6~,

# Function keys
kf1=\e[11~, kf2=\e[12~, kf3=\e[13~, kf4=\e[14~, kf5=\e[15~,
kf6=\e[17~, kf7=\e[18~, kf8=\e[19~, kf9=\e[20~, kf10=\e[21~,
kf11=\e[23~, kf12=\e[24~, kf13=\e[25~, kf14=\e[26~, kf15=\e[28~,
kf16=\e[29~, kf17=\e[31~, kf18=\e[32~, kf19=\e[33~, kf20=\e[34~,

# Find, Insert, Delete, Select, Prior (PgUp), Next (PgDn). The first set of
# sequences are accurate. The second set lets Find/Select act like Home/End.
kfnd=\e[1~, kich1=\e[2~, kdch1=\e[3~, kslt=\e[4~, kpp=\e[5~, knp=\e[6~,
## kfnd=\e[7~, kich1=\e[2~, kdch1=\e[3~, kslt=\e[8~, kpp=\e[5~, knp=\e[6~,

# Home (vt100 may use khome=\e[H), End, Backspace, Keypad Enter, Shift-Tab
# The 1st set is the default. The 2nd set is based on Linux console/vt220
# settings for Home/End and Backspace sending Delete (^?). The 3rd set gives
# xterm's settings for Home/End.
khome=\e[7~, kend=\e[8~, kbs=\010, kent=\eOM, kcbt=\e[Z,
## khome=\e[1~, kend=\e[4~, kbs=\177, kent=\eOM, kcbt=\e[Z,
## khome=\e[H, kend=\e[F, kbs=\010, kent=\eOM, kcbt=\e[Z,

# Help and Begin keys
khlp=\e[28~, kbeg=\eOu,
# "Shifted" right and left (actually Ctrl, not Shift)
kRIT=\e[c, kLFT=\e[d,
# Shift-Prior/Next (PgUp/PgDn). Usually, these key combos scroll.
kPRV=\e[5$, kNXT=\e[6$,
# Shift-Delete/Home/End and Ctrl-End. It's a $ instead of a ~ for
# Shift-, a ^ for Ctrl-, and @ for Ctrl-Shift-.
kDC=\e[3$, kHOM=\e[7$, kEND=\e[8$, kel=\e[8\^,

# Reset terminal, turn off all attributes
rs1=\e>\e[1;3;4;5;6l\e[?7h\e[m\e[r\e[2J\e[H,
rs2=\e[r\e[m\e[2J\e[H\e[?7h\e[?1;3;4;6l\e[4l\e>,
# Init terminal
is1=\e[?47l\e>\e[?1l,
is2=\e[r\e[m\e[2J\e[H\e[?7h\e[?1;3;4;6l\e[4l,

# Enter/leave cursor address mode. The 1st set uses the
# secondary screen. The 2nd one doesn't.
smcup=\e7\e[?47h, rmcup=\e[2J\e[?47l\e8,
## smcup=\e7, rmcup=\e8,

# Start/stop redirection to the printpipe
mc4=\e[4i, mc5=\e[5i,

# User-defined string capabilities
# Cursor Position Report (CPR)
u6=\e[%i%d;%dR,
# Report current screen position (DSR 6) (replies with u6)
u7=\e[6n,
# vt100 answerback
u8=\e[?1;2c,
# Request identity (replies with u8) If VT100_ANS is enabled, use
# the first value. If ENQ_ANS is enabled, use the second value.
u9=\e[c,
## u9=^E,

# Add ANSI color support
sgr=\e[0%?%p1%p6%|%t;1%;%?%p2%t;4%;%?%p1%p3%|%t;7%;%?%p4%t;5%;m%?%p9%t^N%e^O%;,
## sgr=\e[%?%p1%t;7%;%?%p2%t;4%;%?%p3%t;7%;%?%p4%t;5%;%?%p6%t;1%;m,

# Mouse info packet introducer
kmous=\e[M,

# Revert to the original foreground/background pair
op=\e[39;49m,
# Set foreground color, background color
setaf=\e[3%p1%dm, setab=\e[4%p1%dm,
Binary file added ncurses/ncurses-5.9-20140308-patch.sh.xz
Binary file not shown.
217 changes: 217 additions & 0 deletions ncurses/ncurses.SlackBuild
@@ -0,0 +1,217 @@
#!/bin/sh

# Copyright 2000-2011, 2013, 2014 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:-3}

# 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-normal \
--with-shared \
--enable-symlinks \
--enable-pc-files \
--with-pkg-config-libdir=/usr/lib${LIBDIRSUFFIX}/pkgconfig \
--without-debug \
--without-profile \
$ADA_SUPPORT \
$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-20140308-patch.sh.xz > ncurses-5.9-20140308-patch.sh
sh ncurses-5.9-20140308-patch.sh

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

ADA_SUPPORT="--with-ada-include=/usr/include/ncurses-ada \
--with-ada-objects=/usr/lib$LIBDIRSUFFIX/ncurses-ada"
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
(cd $PKG/usr/lib$LIBDIRSUFFIX && mv libAdaCurses* ncruses-ada)

# Build/install again with wide character support:
make clean
WIDEC=--enable-widec
ADA_SUPPORT="" # currently Ada binding does not link with ncursesw
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 doc/* \
$PKG/usr/doc/ncurses-$VERSION
mkdir -p $PKG/usr/doc/ncurses-$VERSION/Ada
cp -a Ada95/samples $PKG/usr/doc/ncurses-$VERSION/Ada
( cd $PKG/usr/doc/ncurses-$VERSION/Ada/samples && rm *ali *.o)

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

#Copy Ada project files
mkdir -p $PKG/usr/lib$LIBDIRSUFFIX/gnat
cp $CWD/ncurses.gpr $PKG/usr/lib$LIBDIRSUFFIX/gnat

# 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

13 changes: 13 additions & 0 deletions ncurses/ncurses.gpr
@@ -0,0 +1,13 @@
project ncurses is

for Languages use ("Ada");

for Source_Dirs use ("../../include/ncurses-ada");

for Library_Dir use "../ncurses-ada";
for Library_Name use "AdaCurses";
for Library_Kind use "static";

for Externally_Built use "true";

end ncruses;
Binary file added ncurses/ncurses.mkhashsize.diff.gz
Binary file not shown.

0 comments on commit 9c11bae

Please sign in to comment.