From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <gentoo-commits+bounces-1409382-garchives=archives.gentoo.org@lists.gentoo.org>
Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature RSA-PSS (2048 bits))
	(No client certificate requested)
	by finch.gentoo.org (Postfix) with ESMTPS id 32788158092
	for <garchives@archives.gentoo.org>; Fri, 17 Jun 2022 12:11:37 +0000 (UTC)
Received: from pigeon.gentoo.org (localhost [127.0.0.1])
	by pigeon.gentoo.org (Postfix) with SMTP id 72CCDE088B;
	Fri, 17 Jun 2022 12:11:36 +0000 (UTC)
Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature RSA-PSS (4096 bits))
	(No client certificate requested)
	by pigeon.gentoo.org (Postfix) with ESMTPS id 57908E088B
	for <gentoo-commits@lists.gentoo.org>; Fri, 17 Jun 2022 12:11:36 +0000 (UTC)
Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature RSA-PSS (4096 bits))
	(No client certificate requested)
	by smtp.gentoo.org (Postfix) with ESMTPS id 6D068341991
	for <gentoo-commits@lists.gentoo.org>; Fri, 17 Jun 2022 12:11:35 +0000 (UTC)
Received: from localhost.localdomain (localhost [IPv6:::1])
	by oystercatcher.gentoo.org (Postfix) with ESMTP id 8883150B
	for <gentoo-commits@lists.gentoo.org>; Fri, 17 Jun 2022 12:11:32 +0000 (UTC)
From: "Sam James" <sam@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Content-Transfer-Encoding: 8bit
Content-type: text/plain; charset=UTF-8
Reply-To: gentoo-dev@lists.gentoo.org, "Sam James" <sam@gentoo.org>
Message-ID: <1655467806.4d77781e2db7bb8bef7f390c43efc04ba58ff7bb.sam@gentoo>
Subject: [gentoo-commits] repo/gentoo:master commit in: sys-devel/flex/
X-VCS-Repository: repo/gentoo
X-VCS-Files: sys-devel/flex/flex-2.6.4-r2.ebuild
X-VCS-Directories: sys-devel/flex/
X-VCS-Committer: sam
X-VCS-Committer-Name: Sam James
X-VCS-Revision: 4d77781e2db7bb8bef7f390c43efc04ba58ff7bb
X-VCS-Branch: master
Date: Fri, 17 Jun 2022 12:11:32 +0000 (UTC)
Precedence: bulk
List-Post: <mailto:gentoo-commits@lists.gentoo.org>
List-Help: <mailto:gentoo-commits+help@lists.gentoo.org>
List-Unsubscribe: <mailto:gentoo-commits+unsubscribe@lists.gentoo.org>
List-Subscribe: <mailto:gentoo-commits+subscribe@lists.gentoo.org>
List-Id: Gentoo Linux mail <gentoo-commits.gentoo.org>
X-BeenThere: gentoo-commits@lists.gentoo.org
X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply
X-Archives-Salt: 7dac2bbf-9d6b-4c1e-9ef3-7ea57cb50a4d
X-Archives-Hash: cf3b2975e591eb2db4fd589b7a8e6952

commit:     4d77781e2db7bb8bef7f390c43efc04ba58ff7bb
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Fri Jun 17 02:23:18 2022 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Fri Jun 17 12:10:06 2022 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=4d77781e

sys-devel/flex: fix segfault when cross-compiling

Temporary workaround until new crossdev is tagged, stabled,
and propagates.

Closes: https://bugs.gentoo.org/705800
Signed-off-by: Sam James <sam <AT> gentoo.org>

 sys-devel/flex/flex-2.6.4-r2.ebuild | 94 +++++++++++++++++++++++++++++++++++++
 1 file changed, 94 insertions(+)

diff --git a/sys-devel/flex/flex-2.6.4-r2.ebuild b/sys-devel/flex/flex-2.6.4-r2.ebuild
new file mode 100644
index 000000000000..b1e13e873c6d
--- /dev/null
+++ b/sys-devel/flex/flex-2.6.4-r2.ebuild
@@ -0,0 +1,94 @@
+# Copyright 1999-2022 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+inherit flag-o-matic libtool multilib-minimal toolchain-funcs
+
+DESCRIPTION="The Fast Lexical Analyzer"
+HOMEPAGE="https://github.com/westes/flex"
+SRC_URI="https://github.com/westes/${PN}/releases/download/v${PV}/${P}.tar.gz"
+
+LICENSE="FLEX"
+SLOT="0"
+KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~loong ~m68k ~mips ~ppc ~ppc64 ~riscv ~s390 ~sparc ~x86 ~x64-cygwin ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris"
+IUSE="nls static test"
+RESTRICT="!test? ( test )"
+
+# We want bison explicitly and not yacc in general, bug #381273
+RDEPEND="sys-devel/m4"
+BDEPEND="${RDEPEND}
+	nls? ( sys-devel/gettext )
+	test? ( sys-devel/bison )"
+
+PATCHES=(
+	"${FILESDIR}"/${PN}-2.6.4-libobjdir.patch
+	"${FILESDIR}"/${PN}-2.6.4-fix-build-with-glibc2.6+.patch
+)
+
+src_prepare() {
+	default
+
+	# Disable running in the tests/ subdir as it has a bunch of built sources
+	# that cannot be made conditional (automake limitation). bug #568842
+	if ! use test ; then
+		sed -i \
+			-e '/^SUBDIRS =/,/^$/{/tests/d}' \
+			Makefile.in || die
+	fi
+
+	# Prefix always needs this
+	elibtoolize
+}
+
+src_configure() {
+	use static && append-ldflags -static
+
+	multilib-minimal_src_configure
+}
+
+multilib_src_configure() {
+	if tc-is-cross-compiler ; then
+		# Similar to workaround for procps:
+		# - bug #705800
+		# - https://sourceforge.net/p/psmisc/bugs/71/
+		# - https://lists.gnu.org/archive/html/autoconf/2011-04/msg00019.html
+		export ac_cv_func_malloc_0_nonnull=yes \
+			ac_cv_func_realloc_0_nonnull=yes
+	fi
+
+	# Do not install shared libs, #503522
+	ECONF_SOURCE="${S}" econf \
+		CC_FOR_BUILD="$(tc-getBUILD_CC)" \
+		--disable-shared \
+		$(use_enable nls)
+}
+
+multilib_src_compile() {
+	if multilib_is_native_abi; then
+		default
+	else
+		emake -C src -f Makefile -f - lib <<< 'lib: $(lib_LTLIBRARIES)'
+	fi
+}
+
+multilib_src_test() {
+	multilib_is_native_abi && emake check
+}
+
+multilib_src_install() {
+	if multilib_is_native_abi; then
+		default
+	else
+		emake -C src DESTDIR="${D}" install-libLTLIBRARIES install-includeHEADERS
+	fi
+}
+
+multilib_src_install_all() {
+	einstalldocs
+	dodoc ONEWS
+	find "${ED}" -name '*.la' -type f -delete || die
+	rm "${ED}"/usr/share/doc/${PF}/COPYING || die
+
+	dosym flex /usr/bin/lex
+}