Continue with the upgrades...
[dragora.git] / recipes / libs / ncurses / recipe
blobe4fc1a111cc95ca7492880d9c9897d9f9176fe78
1 # Build recipe for ncurses.
3 # Copyright (c) 2016-2022 Matias Fonzo, <selk@dragora.org>.
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
9 #    http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
17 # Exit immediately on any error
18 set -e
20 program=ncurses
21 version=6.3-20220115
22 release=1
24 # Define a category for the output of the package name
25 pkgcategory=libs
27 tarname=${program}-${version}.tgz
28 termcap_file=termcap-20210816.src.gz
30 # Remote source(s)
31 fetch="
32   https://invisible-mirror.net/archives/ncurses/current/$tarname
33   https://invisible-mirror.net/archives/ncurses/current/$termcap_file
36 description="
37 Emulation library of Curses.
39 The Ncurses (new curses) library is a free software emulation of
40 curses in System V Release 4.0.  The ncurses code was developed
41 under GNU/Linux.  It has been in use for some time with OpenBSD
42 as the system curses library, and on FreeBSD and NetBSD as an
43 external package.
45 The distribution includes the library and support utilities,
46 including a terminfo compiler \"tic\", a decompiler \"infocmp\",
47 clear, tput, tset, and a termcap conversion tool \"captoinfo\".
50 homepage=https://www.gnu.org/software/ncurses
51 license=Custom
53 # Source documentation
54 docs="ANNOUNCE AUTHORS COPYING NEWS README TO-DO VERSION"
55 docsdir="${docdir}/${program}-${version}"
57 _DEFAULT_NCURSES_BUILD_OPTIONS="
58   --libdir=/usr/lib${libSuffix} \
59   --mandir=$mandir \
60   --enable-overwrite \
61   --enable-symlinks \
62   --enable-pc-files \
63   --enable-xmc-glitch \
64   --enable-colorfgbg \
65   --enable-hard-tabs \
66   --disable-stripping \
67   --with-pkg-config-libdir=/usr/lib${libSuffix}/pkgconfig \
68   --with-manpage-format=normal \
69   --with-shared \
70   --with-termlib=tinfo \
71   --with-ticlib=tic \
72   --with-gpm \
73   --without-tests \
74   --without-debug \
75   --without-profile \
76   --build="$(gcc -dumpmachine)"
79 build()
81     unpack "${tardir}/$tarname"
83     cd "$srcdir"
85     # Set sane permissions
86     chmod -R u+w,go-w,a+rX-s .
88     unset -v TERMINFO;  # Just in case.
90     ./configure CPPFLAGS="$QICPPFLAGS -D_GNU_SOURCE" \
91     CFLAGS="$QICFLAGS" CXXFLAGS="$QICXXFLAGS" LDFLAGS="$QILDFLAGS" \
92      $configure_args --includedir=/usr/include/ncurses \
93       $_DEFAULT_NCURSES_BUILD_OPTIONS \
94        --with-manpages --enable-widec --with-normal
96     make -j${jobs} V=1
97     make -j${jobs} DESTDIR="$destdir" install
99     unset -v _DEFAULT_NCURSES_BUILD_OPTIONS
101     # Provide non-widec compatibility
103     for name in form panel menu
104     do
105         rm -f "${destdir}/usr/lib${libSuffix}/lib${name}.so" \
106               "${destdir}/usr/lib${libSuffix}/lib${name}.a"
108         echo "INPUT(-l${name}w)" > \
109          "${destdir}/usr/lib${libSuffix}/lib${name}.so"
110         echo "INPUT(-l${name}w)" > \
111          "${destdir}/usr/lib${libSuffix}/lib${name}.a"
113         (
114             cd "${destdir}/usr/lib${libSuffix}/pkgconfig" && \
115              ln -sf ${name}w.pc ${name}.pc
116         )
117     done
118     unset -v name
120     # Do not leave behind this symbolic link for pkgconfig
121     ln -sf ncursesw.pc "${destdir}/usr/lib${libSuffix}/pkgconfig/ncurses.pc"
123     # Make symlinks for compatibility
124     (
125         cd "${destdir}/usr/include" || exit 1
126         ln -sf ncurses ncursesw
127         for header in ncurses/*
128         do
129             ln -sf $header .
130         done
131     )
133     # Insert termcap file provided by "Thomas E. Dickey"
134     mkdir -p "${destdir}/etc"
135     zcat "${tardir}/$termcap_file" > "${destdir}/etc/termcap"
136     chmod 644 "${destdir}/etc/termcap"
137     unset -v termcap_file
139     touch "${destdir}/etc/.graft-config"
141     # Make sure to link against -ltinfo
142     (
143         major_version=$(echo $version | cut -f 1 -d .)
145         cd "${destdir}/usr/lib${libSuffix}" || exit 1
146         rm -f libncursesw.so libncurses.so libncurses.a libtermcap.so libtermcap.a
148         echo "INPUT(libncursesw.so.${major_version} -ltinfo)" > libncurses.so
149         echo "INPUT(libncursesw.a -ltinfo)" > libncurses.a
151         echo "INPUT(libncursesw.so.${major_version} -ltinfo)" > libncursesw.so
153         echo "INPUT(-ltinfo)" > libtermcap.so
154         echo "INPUT(-ltinfo)" > libtermcap.a
155     )
157     # Compress and link man pages (if needed)
158     if test -d "${destdir}/$mandir"
159     then
160         (
161             cd "${destdir}/$mandir"
162             find . -type f -exec lzip -9 {} +
163             find . -type l | while read -r file
164             do
165                 ln -sf "$(readlink -- "$file").lz" "${file}.lz"
166                 rm -- "$file"
167             done
168         )
169     fi
171     # Copy documentation
172     mkdir -p "${destdir}${docsdir}"
173     cp -p $docs "${destdir}${docsdir}/"