summaryrefslogtreecommitdiff
blob: 24c7493d8a637dec3262e6b43af1f6836b61772d (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
# Copyright 1999-2005 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/sys-libs/ncurses/ncurses-5.4-r5.ebuild,v 1.22 2005/03/22 18:48:59 lanius Exp $

inherit eutils flag-o-matic toolchain-funcs

DESCRIPTION="console display library"
HOMEPAGE="http://www.gnu.org/software/ncurses/ncurses.html"
SRC_URI="mirror://gnu/ncurses/${P}.tar.gz"

LICENSE="MIT"
SLOT="5"
KEYWORDS="alpha amd64 arm hppa ia64 m68k mips ppc ppc64 s390 sh sparc x86"
IUSE="gpm build bootstrap debug doc uclibc unicode nocxx"

DEPEND="gpm? ( sys-libs/gpm )"

pkg_setup() {
	# check for unicode use flag, see bug #78313
	if use !unicode && [ -f /usr/lib/libncursesw.so ] && [ "$COMPILE_NCURSES" != "TRUE" ]; then
		ewarn "Remerging ncurses without unicoe in USE flags will break your system"
		ewarn "For more information see bug #78313"
		ewarn "If you still want continue set COMPILE_NCURSES variable to TRUE"
		die
	fi
}

src_unpack() {
	unpack ${A}
	cd "${S}"
	epatch "${FILESDIR}"/${P}-xterm.patch
	epatch "${FILESDIR}"/${P}-share-sed.patch #42336
}

src_compile() {
	local myconf=

	filter-flags -fno-exceptions

	use debug || myconf="${myconf} --without-debug"

	# Shared objects are compiled properly with -fPIC, but
	# standard libs also require this.
	# Unconditonal use of -fPIC (#55238).
	append-flags -fPIC
	filter-ldflags -pie

	# From version 5.3, ncurses also build c++ bindings, and as
	# we do not have a c++ compiler during bootstrap, disable
	# building it.  We will rebuild ncurses after gcc's second
	# build in bootstrap.sh.
	# <azarah@gentoo.org> (23 Oct 2002)
	( use build || use bootstrap || use nocxx ) \
		&& myconf="${myconf} --without-cxx --without-cxx-binding --without-ada"

	# whee gpm !
	use gpm && myconf="${myconf} --with-gpm"

	# enable utf-8 support
	use unicode && myconf="${myconf} --enable-widec"

	# We need the basic terminfo files in /etc, bug #37026.  We will
	# add '--with-terminfo-dirs' and then populate /etc/terminfo in
	# src_install() ...
	tc-export BUILD_CC
	econf \
		--libdir=/$(get_libdir) \
		--with-terminfo-dirs="/etc/terminfo:/usr/share/terminfo" \
		--disable-termcap \
		--with-shared \
		--with-rcs-ids \
		--without-ada \
		--enable-symlinks \
		--program-prefix="" \
		${myconf} \
		|| die "configure failed"

	# A little hack to fix parallel builds ... they break when
	# generating sources so if we generate the sources first (in
	# non-parallel), we can then build the rest of the package
	# in parallel.  This is not really a perf hit since the source
	# generation is quite small.  -vapier
	emake -j1 sources || die "make sources failed"
	emake || die "make failed"
}

src_install() {
	local x=

	make DESTDIR="${D}" install || die "make install failed"

	# Move static and extraneous ncurses libraries out of /lib
	cd ${D}/$(get_libdir)
	dodir /usr/$(get_libdir)
	mv libform* libmenu* libpanel* *.a ${D}/usr/$(get_libdir)

	if use unicode ; then
		gen_usr_ldscript libncursesw.so || die "gen_usr_ldscript failed"
		gen_usr_ldscript libcursesw.so || die "gen_usr_ldscript failed"
		for i in ${D}/usr/$(get_libdir)/*w.* ; do
			local libncurses=${i/${D}/}
			dosym ${libncurses} ${libncurses/w./.}
		done
		for i in ${D}/$(get_libdir)/libncursesw.so* ; do
			local libncurses=${i/${D}}
			dosym ${libncurses} ${libncurses/w./.}
		done
	else
		# bug #4411
		gen_usr_ldscript libncurses.so || die "gen_usr_ldscript failed"
		gen_usr_ldscript libcurses.so || die "gen_usr_ldscript failed"
	fi

	# We need the basic terminfo files in /etc, bug #37026
	einfo "Installing basic terminfo files in /etc..."
	# added some for uclibc
	#for x in dumb linux rxvt screen sun vt{52,100,102,220} xterm
	for x in ansi console dumb linux rxvt screen sun vt{52,100,102,200,220} xterm xterm-color xterm-xfree86
	do
		local termfile=$(find "${D}"/usr/share/terminfo/ -name "${x}" 2>/dev/null)
		local basedir=$(basename $(dirname "${termfile}"))

		if [[ -n ${termfile} ]] ; then
			dodir /etc/terminfo/${basedir}
			mv ${termfile} ${D}/etc/terminfo/${basedir}/
			dosym ../../../../etc/terminfo/${basedir}/${x} \
				/usr/share/terminfo/${basedir}/${x}
		fi
	done

	# Build fails to create this ...
	dosym ../share/terminfo /usr/$(get_libdir)/terminfo

	dodir /etc/env.d
	echo "CONFIG_PROTECT_MASK=\"/etc/terminfo\"" > ${D}/etc/env.d/50ncurses

	if use build ; then
		cd ${D}
		rm -rf usr/share/man
		cd usr/share/terminfo
		cp -a l/linux n/nxterm v/vt100 ${T}
		rm -rf *
		mkdir l x v
		cp -a ${T}/linux l
		cp -a ${T}/nxterm x/xterm
		cp -a ${T}/vt100 v
		# bash compilation requires static libncurses libraries, so
		# this breaks the "build a new build image" system.  We now
		# need to remove libncurses.a from the build image manually.
		# cd ${D}/usr/lib; rm *.a
		# remove extraneous ncurses libraries
		cd ${D}/usr/$(get_libdir); rm -f lib{form,menu,panel}*
		cd ${D}/usr/include; rm -f {eti,form,menu,panel}.h
	else
		if use bootstrap ; then
			cd ${D}/usr/$(get_libdir); rm -f lib{form,menu,panel,ncurses++}*
			cd ${D}/usr/include; rm -f {eti,form,menu,panel}.h cursesapp.h curses?.h cursslk.h etip.h
		fi
		# Install xterm-debian terminfo entry to satisfy bug #18486
		LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${D}/usr/$(get_libdir):${D}/$(get_libdir) \
			TERMINFO=${D}/usr/share/terminfo \
			${D}/usr/bin/tic ${FILESDIR}/xterm-debian.ti

		if use uclibc ; then
			cp ${D}/usr/share/terminfo/x/xterm-debian ${D}/etc/terminfo/x/
			rm -rf ${D}/usr/share/terminfo/*
		fi

		cd ${S}
		dodoc ANNOUNCE MANIFEST NEWS README* TO-DO doc/*.doc
		use doc && dohtml -r doc/html/
	fi
}

pkg_preinst() {
	if [[ ! -f ${ROOT}/etc/env.d/50ncurses ]] ; then
		mkdir -p "${ROOT}"/etc/env.d
		echo "CONFIG_PROTECT_MASK=\"/etc/terminfo\"" > \
			"${ROOT}"/etc/env.d/50ncurses
	fi
}

pkg_postinst() {
	# Old ncurses may still be around from old build tbz2's.
	rm -f ${ROOT}/lib/libncurses.so.5.[23] ${ROOT}/usr/lib/lib{form,menu,panel}.so.5.[23]
	if [ "$(get_libdir)" != "lib" ] ; then
		rm -f ${ROOT}/$(get_libdir)/libncurses.so.5.[23] \
			${ROOT}/usr/$(get_libdir)/lib{form,menu,panel}.so.5.[23]
	fi
}