sci-electronics/iverilog: Import iverilog-11.0 from Gentoo

Icarus Verilog is a run dependency for Yosys (sci-electronics/yosys).

Comparing with the sci-electronics/iverilog directory from Gentoo
upstream it was needed to:
* remove iverilog-10.3 and iverilog-9999 ebuilds along with their patches,
* adapt KEYWORDS in iverilog-11.0.ebuild,
* add OWNERS.

BUG=chromium:1225099
TEST=FEATURES="test" emerge sci-electronics/iverilog

Change-Id: Ib27f8deebe8b15df5e3854fc2dc80890b96f5b61
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/overlays/portage-stable/+/3041520
Tested-by: Adam Jelinski <ajelinski@antmicro.com>
Reviewed-by: Mike Frysinger <vapier@chromium.org>
Reviewed-by: Chris McDonald <cjmcdonald@chromium.org>
Reviewed-by: Dan Callaghan <dcallagh@chromium.org>
Commit-Queue: Dan Callaghan <dcallagh@chromium.org>
diff --git a/sci-electronics/iverilog/Manifest b/sci-electronics/iverilog/Manifest
new file mode 100644
index 0000000..7fe42d1
--- /dev/null
+++ b/sci-electronics/iverilog/Manifest
@@ -0,0 +1,2 @@
+DIST iverilog-10.3.tar.gz 1600835 BLAKE2B 107c57c61fb27c18f4020f7853bf6ca83d1a86fdc73c57ea207828baf6b7a26d42e43ce7b33580f050a4c0b8f63bca6accecf678323a3bbbee1eb9c1d8fa2caa SHA512 67076e19a208576c21a0462ff7d15d00a9d47740c47518a5523bd928b3118360d85eb84c317963717d15e5246ece3727259f6ff3baf59e195340530cc9086a1d
+DIST iverilog-11.0.tar.gz 1682457 BLAKE2B ba90574e1453a095143e76e5dc79bb2357a721fc62c24f0fb23d220458819cb3b8ea8494410ce956e68831b682b61f27f64e94e9c166a69e5f6d5d30a8269a11 SHA512 5d6a65e1c3b6b62e99af708cd5a259cc69c6b789dd6eff69e225903d9b8c115d9e5d6f7635b30c6558197cd0ee6fd8196a163fbd98956e24c211d97328b85056
diff --git a/sci-electronics/iverilog/OWNERS b/sci-electronics/iverilog/OWNERS
new file mode 100644
index 0000000..f855b6f
--- /dev/null
+++ b/sci-electronics/iverilog/OWNERS
@@ -0,0 +1 @@
+include chromiumos/platform2:/hps/OWNERS
diff --git a/sci-electronics/iverilog/files/iverilog-11.0-autoconf-2.70.patch b/sci-electronics/iverilog/files/iverilog-11.0-autoconf-2.70.patch
new file mode 100644
index 0000000..83864af
--- /dev/null
+++ b/sci-electronics/iverilog/files/iverilog-11.0-autoconf-2.70.patch
@@ -0,0 +1,304 @@
+From 4b3e1099e5517333dd690ba948bce1236466a395 Mon Sep 17 00:00:00 2001
+From: Martin Whitaker <icarus@martin-whitaker.me.uk>
+Date: Fri, 1 Jan 2021 18:42:01 +0000
+Subject: [PATCH] Fix configure scripts to work with autoconf 2.70.
+
+Numerous deprecated features have now become obsolete. Mostly done by
+running autoupdate, but that left a few fixes to be done manually.
+
+This includes the latest version of AX_PROG_CC_FOR_BUILD from
+https://www.gnu.org/software/autoconf-archive/ax_prog_cc_for_build.html
+---
+ INSTALL                      |  5 ++--
+ Makefile.in                  |  2 +-
+ README.txt                   |  2 +-
+ aclocal.m4                   | 57 ++++++++++++++++++++++--------------
+ configure.in => configure.ac | 45 +++++++++++++---------------
+ 5 files changed, 59 insertions(+), 52 deletions(-)
+ rename configure.in => configure.ac (87%)
+
+diff --git a/INSTALL b/INSTALL
+index a2c8722cc..95b403761 100644
+--- a/INSTALL
++++ b/INSTALL
+@@ -19,8 +19,8 @@ diffs or instructions to the address given in the `README' so they can
+ be considered for the next release.  If at some point `config.cache'
+ contains results you don't want to keep, you may remove or edit it.
+ 
+-   The file `configure.in' is used to create `configure' by a program
+-called `autoconf'.  You only need `configure.in' if you want to change
++   The file `configure.ac' is used to create `configure' by a program
++called `autoconf'.  You only need `configure.ac' if you want to change
+ it or regenerate `configure' using a newer version of `autoconf'.
+ 
+ The simplest way to compile this package is:
+@@ -178,4 +178,3 @@ operates.
+      script, and exit.
+ 
+ `configure' also accepts some other, not widely useful, options.
+-
+diff --git a/Makefile.in b/Makefile.in
+index 974593374..90ecadeb5 100644
+--- a/Makefile.in
++++ b/Makefile.in
+@@ -202,7 +202,7 @@ stamp-_pli_types-h: $(srcdir)/_pli_types.h.in config.status
+ 	./config.status _pli_types.h
+ _pli_types.h: stamp-_pli_types-h
+ 
+-$(srcdir)/configure: $(srcdir)/configure.in $(srcdir)/aclocal.m4
++$(srcdir)/configure: $(srcdir)/configure.ac $(srcdir)/aclocal.m4
+ 	cd $(srcdir) && autoconf
+ 
+ config.status: $(srcdir)/configure
+diff --git a/README.txt b/README.txt
+index 26533ebcf..d04dab88c 100644
+--- a/README.txt
++++ b/README.txt
+@@ -72,7 +72,7 @@ If you are building from git, you will also need software to generate
+ the configure scripts.
+ 
+ 	- autoconf 2.53 or later
+-	  This generates configure scripts from configure.in. The 2.53
++	  This generates configure scripts from configure.ac. The 2.53
+ 	  or later versions are known to work, autoconf 2.13 is
+ 	  reported to *not* work.
+ 
+diff --git a/aclocal.m4 b/aclocal.m4
+index 1b2dd6a1e..5fcc7cbf2 100644
+--- a/aclocal.m4
++++ b/aclocal.m4
+@@ -6,7 +6,7 @@
+ # different builds. Remember to change the default suffix string to some
+ # value appropriate for the current version.
+ AC_DEFUN([AX_ENABLE_SUFFIX],
+-[AC_ARG_ENABLE([suffix],[AC_HELP_STRING([--enable-suffix],
++[AC_ARG_ENABLE([suffix],[AS_HELP_STRING([--enable-suffix],
+                                         [Use/set the installation command suffix])],
+                [true],[enable_suffix=no])
+ if test X$enable_suffix = Xyes; then
+@@ -250,7 +250,7 @@ echo "timestamp for $_config_header" > `AS_DIRNAME(["$_config_header"])`/[]$_sta
+ ]) #_AC_AM_CONFIG_HEADER_HOOK
+ 
+ # ===========================================================================
+-#   http://www.gnu.org/software/autoconf-archive/ax_prog_cc_for_build.html
++#   https://www.gnu.org/software/autoconf-archive/ax_prog_cc_for_build.html
+ # ===========================================================================
+ #
+ # SYNOPSIS
+@@ -283,31 +283,35 @@ echo "timestamp for $_config_header" > `AS_DIRNAME(["$_config_header"])`/[]$_sta
+ #   and this notice are preserved. This file is offered as-is, without any
+ #   warranty.
+ 
+-#serial 8
++#serial 18
+ 
+ AU_ALIAS([AC_PROG_CC_FOR_BUILD], [AX_PROG_CC_FOR_BUILD])
+ AC_DEFUN([AX_PROG_CC_FOR_BUILD], [dnl
+ AC_REQUIRE([AC_PROG_CC])dnl
+ AC_REQUIRE([AC_PROG_CPP])dnl
+-AC_REQUIRE([AC_EXEEXT])dnl
+-AC_REQUIRE([AC_CANONICAL_HOST])dnl
++AC_REQUIRE([AC_CANONICAL_BUILD])dnl
+ 
+ dnl Use the standard macros, but make them use other variable names
+ dnl
+ pushdef([ac_cv_prog_CPP], ac_cv_build_prog_CPP)dnl
++pushdef([ac_cv_prog_cc_c89], ac_cv_build_prog_cc_c89)dnl
+ pushdef([ac_cv_prog_gcc], ac_cv_build_prog_gcc)dnl
+ pushdef([ac_cv_prog_cc_works], ac_cv_build_prog_cc_works)dnl
+ pushdef([ac_cv_prog_cc_cross], ac_cv_build_prog_cc_cross)dnl
+ pushdef([ac_cv_prog_cc_g], ac_cv_build_prog_cc_g)dnl
++pushdef([ac_cv_c_compiler_gnu], ac_cv_build_c_compiler_gnu)dnl
+ pushdef([ac_cv_exeext], ac_cv_build_exeext)dnl
+ pushdef([ac_cv_objext], ac_cv_build_objext)dnl
+ pushdef([ac_exeext], ac_build_exeext)dnl
+ pushdef([ac_objext], ac_build_objext)dnl
+ pushdef([CC], CC_FOR_BUILD)dnl
+ pushdef([CPP], CPP_FOR_BUILD)dnl
++pushdef([GCC], GCC_FOR_BUILD)dnl
+ pushdef([CFLAGS], CFLAGS_FOR_BUILD)dnl
+ pushdef([CPPFLAGS], CPPFLAGS_FOR_BUILD)dnl
++pushdef([EXEEXT], BUILD_EXEEXT)dnl
+ pushdef([LDFLAGS], LDFLAGS_FOR_BUILD)dnl
++pushdef([OBJEXT], BUILD_OBJEXT)dnl
+ pushdef([host], build)dnl
+ pushdef([host_alias], build_alias)dnl
+ pushdef([host_cpu], build_cpu)dnl
+@@ -318,27 +322,29 @@ pushdef([ac_cv_host_alias], ac_cv_build_alias)dnl
+ pushdef([ac_cv_host_cpu], ac_cv_build_cpu)dnl
+ pushdef([ac_cv_host_vendor], ac_cv_build_vendor)dnl
+ pushdef([ac_cv_host_os], ac_cv_build_os)dnl
+-pushdef([ac_cpp], ac_build_cpp)dnl
+-pushdef([ac_compile], ac_build_compile)dnl
+-pushdef([ac_link], ac_build_link)dnl
++pushdef([ac_tool_prefix], ac_build_tool_prefix)dnl
++pushdef([am_cv_CC_dependencies_compiler_type], am_cv_build_CC_dependencies_compiler_type)dnl
++pushdef([am_cv_prog_cc_c_o], am_cv_build_prog_cc_c_o)dnl
++pushdef([cross_compiling], cross_compiling_build)dnl
+ 
+-save_cross_compiling=$cross_compiling
+-save_ac_tool_prefix=$ac_tool_prefix
+-cross_compiling=no
+-ac_tool_prefix=
++cross_compiling_build=no
+ 
++ac_build_tool_prefix=
++AS_IF([test -n "$build"],      [ac_build_tool_prefix="$build-"],
++      [test -n "$build_alias"],[ac_build_tool_prefix="$build_alias-"])
++
++AC_LANG_PUSH([C])
+ AC_PROG_CC
++_AC_COMPILER_EXEEXT
++_AC_COMPILER_OBJEXT
+ AC_PROG_CPP
+-AC_EXEEXT
+-
+-ac_tool_prefix=$save_ac_tool_prefix
+-cross_compiling=$save_cross_compiling
+ 
+ dnl Restore the old definitions
+ dnl
+-popdef([ac_link])dnl
+-popdef([ac_compile])dnl
+-popdef([ac_cpp])dnl
++popdef([cross_compiling])dnl
++popdef([am_cv_prog_cc_c_o])dnl
++popdef([am_cv_CC_dependencies_compiler_type])dnl
++popdef([ac_tool_prefix])dnl
+ popdef([ac_cv_host_os])dnl
+ popdef([ac_cv_host_vendor])dnl
+ popdef([ac_cv_host_cpu])dnl
+@@ -349,29 +355,36 @@ popdef([host_vendor])dnl
+ popdef([host_cpu])dnl
+ popdef([host_alias])dnl
+ popdef([host])dnl
++popdef([OBJEXT])dnl
+ popdef([LDFLAGS])dnl
++popdef([EXEEXT])dnl
+ popdef([CPPFLAGS])dnl
+ popdef([CFLAGS])dnl
++popdef([GCC])dnl
+ popdef([CPP])dnl
+ popdef([CC])dnl
+ popdef([ac_objext])dnl
+ popdef([ac_exeext])dnl
+ popdef([ac_cv_objext])dnl
+ popdef([ac_cv_exeext])dnl
++popdef([ac_cv_c_compiler_gnu])dnl
+ popdef([ac_cv_prog_cc_g])dnl
+ popdef([ac_cv_prog_cc_cross])dnl
+ popdef([ac_cv_prog_cc_works])dnl
++popdef([ac_cv_prog_cc_c89])dnl
+ popdef([ac_cv_prog_gcc])dnl
+ popdef([ac_cv_prog_CPP])dnl
+ 
++dnl restore global variables ac_ext, ac_cpp, ac_compile,
++dnl ac_link, ac_compiler_gnu (dependant on the current
++dnl language after popping):
++AC_LANG_POP([C])
++
+ dnl Finally, set Makefile variables
+ dnl
+-BUILD_EXEEXT=$ac_build_exeext
+-BUILD_OBJEXT=$ac_build_objext
+ AC_SUBST(BUILD_EXEEXT)dnl
+ AC_SUBST(BUILD_OBJEXT)dnl
+ AC_SUBST([CFLAGS_FOR_BUILD])dnl
+ AC_SUBST([CPPFLAGS_FOR_BUILD])dnl
+ AC_SUBST([LDFLAGS_FOR_BUILD])dnl
+ ])
+-
+diff --git a/configure.in b/configure.ac
+similarity index 87%
+rename from configure.in
+rename to configure.ac
+index 83e0fe50e..8913fb74c 100644
+--- a/configure.in
++++ b/configure.ac
+@@ -1,21 +1,19 @@
+ dnl Process this file with autoconf to produce a configure script.
+-AC_INIT(netlist.h)
+-AC_CONFIG_HEADER(config.h)
+-AC_CONFIG_HEADER(_pli_types.h)
+-AC_CONFIG_HEADER(vhdlpp/vhdlpp_config.h)
+-AC_CONFIG_HEADER(vvp/config.h)
+-AC_CONFIG_HEADER(vpi/vpi_config.h)
+-AC_CONFIG_HEADER(libveriuser/config.h)
+-AC_CONFIG_HEADER(tgt-vvp/vvp_config.h)
+-AC_CONFIG_HEADER(tgt-vhdl/vhdl_config.h)
+-AC_CONFIG_HEADER(tgt-pcb/pcb_config.h)
++AC_INIT
++AC_CONFIG_SRCDIR([netlist.h])
++AC_CONFIG_HEADERS([config.h])
++AC_CONFIG_HEADERS([_pli_types.h])
++AC_CONFIG_HEADERS([vhdlpp/vhdlpp_config.h])
++AC_CONFIG_HEADERS([vvp/config.h])
++AC_CONFIG_HEADERS([vpi/vpi_config.h])
++AC_CONFIG_HEADERS([libveriuser/config.h])
++AC_CONFIG_HEADERS([tgt-vvp/vvp_config.h])
++AC_CONFIG_HEADERS([tgt-vhdl/vhdl_config.h])
++AC_CONFIG_HEADERS([tgt-pcb/pcb_config.h])
+ 
+ AC_CANONICAL_HOST
+ dnl Checks for programs.
+ AC_PROG_CC
+-# AC_PROG_CC_C99 is only available in autoconf version 2.60 and later.
+-AC_PREREQ([2.60])
+-AC_PROG_CC_C99
+ AC_PROG_CXX
+ AC_PROG_RANLIB
+ AC_CHECK_TOOL(LD, ld, false)
+@@ -92,7 +90,7 @@ fi
+ 
+ AC_LANG(C++)
+ 
+-AC_ARG_WITH([m32], [AC_HELP_STRING([--with-m32], [Compile 32-bit on x86_64])],
++AC_ARG_WITH([m32], [AS_HELP_STRING([--with-m32],[Compile 32-bit on x86_64])],
+             [ with_m32=yes ],[ with_m32=no ])
+ 
+ AS_IF( [test "x$with_m32" = xyes],
+@@ -170,8 +168,7 @@ AC_FUNC_ALLOCA
+ AC_FUNC_FSEEKO
+ 
+ # valgrind checks
+-AC_ARG_WITH([valgrind], [AC_HELP_STRING([--with-valgrind],
+-                                        [Add valgrind hooks])],
++AC_ARG_WITH([valgrind], [AS_HELP_STRING([--with-valgrind],[Add valgrind hooks])],
+             [], [check_valgrind=yes])
+ 
+ AS_IF([test "x$check_valgrind" = xyes],
+@@ -182,14 +179,11 @@ AS_IF([test "x$check_valgrind" = xyes],
+                        [AC_MSG_ERROR([Could not find <valgrind/memcheck.h>])])])
+ 
+ AC_MSG_CHECKING(for sys/times)
+-AC_TRY_LINK(
+-#include <unistd.h>
++AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>
+ #include <sys/times.h>
+-,{clock_t a = times(0)/sysconf(_SC_CLK_TCK);},
+-do_times=yes
+-AC_DEFINE([HAVE_TIMES], [1], [The times system call is available in the host operating system.]),
+-do_times=no
+-)
++]], [[{clock_t a = times(0)/sysconf(_SC_CLK_TCK);}]])],[do_times=yes
++AC_DEFINE(HAVE_TIMES, 1, The times system call is available in the host operating system.)],[do_times=no
++])
+ AC_MSG_RESULT($do_times)
+ 
+ # --
+@@ -262,7 +256,7 @@ AC_CHECK_FUNCS(fopen64)
+ # The following math functions may be defined in the math library so look
+ # in the default libraries first and then look in -lm for them. On some
+ # systems we may need to use the compiler in C99 mode to get a definition.
+-# We requested C99 mode earlier with AC_PROG_CC_C99.
++# Modern versions of autoconf will enable C99 if it is available.
+ AC_SEARCH_LIBS([lround], [m], [AC_DEFINE([HAVE_LROUND], [1])])
+ AC_SEARCH_LIBS([llround], [m], [AC_DEFINE([HAVE_LLROUND], [1])])
+ AC_SEARCH_LIBS([nan], [m], [AC_DEFINE([HAVE_NAN], [1])])
+@@ -337,4 +331,5 @@ AC_MSG_ERROR(cannot configure white space in libdir: $libdir)
+ fi
+ AC_MSG_RESULT(ok)
+ AX_PROG_CC_FOR_BUILD
+-AC_OUTPUT(Makefile ivlpp/Makefile vhdlpp/Makefile vvp/Makefile vpi/Makefile driver/Makefile driver-vpi/Makefile cadpli/Makefile libveriuser/Makefile tgt-null/Makefile tgt-stub/Makefile tgt-vvp/Makefile tgt-vhdl/Makefile tgt-fpga/Makefile tgt-verilog/Makefile tgt-pal/Makefile tgt-vlog95/Makefile tgt-pcb/Makefile tgt-blif/Makefile tgt-sizer/Makefile)
++AC_CONFIG_FILES([Makefile ivlpp/Makefile vhdlpp/Makefile vvp/Makefile vpi/Makefile driver/Makefile driver-vpi/Makefile cadpli/Makefile libveriuser/Makefile tgt-null/Makefile tgt-stub/Makefile tgt-vvp/Makefile tgt-vhdl/Makefile tgt-fpga/Makefile tgt-verilog/Makefile tgt-pal/Makefile tgt-vlog95/Makefile tgt-pcb/Makefile tgt-blif/Makefile tgt-sizer/Makefile])
++AC_OUTPUT
diff --git a/sci-electronics/iverilog/iverilog-11.0.ebuild b/sci-electronics/iverilog/iverilog-11.0.ebuild
new file mode 100644
index 0000000..bd2ca96
--- /dev/null
+++ b/sci-electronics/iverilog/iverilog-11.0.ebuild
@@ -0,0 +1,68 @@
+# Copyright 1999-2021 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=7
+
+inherit autotools
+
+GITHUB_PV=$(ver_rs 1- '_')
+
+DESCRIPTION="A Verilog simulation and synthesis tool"
+HOMEPAGE="
+	http://iverilog.icarus.com
+	https://github.com/steveicarus/iverilog
+"
+
+if [[ ${PV} == "9999" ]] ; then
+	inherit git-r3
+	EGIT_REPO_URI="https://github.com/steveicarus/${PN}.git"
+	KEYWORDS="~*"
+else
+	SRC_URI="https://github.com/steveicarus/${PN}/archive/v${GITHUB_PV}.tar.gz -> ${P}.tar.gz"
+	KEYWORDS="*"
+	S="${WORKDIR}/${PN}-${GITHUB_PV}"
+fi
+
+LICENSE="LGPL-2.1"
+SLOT="0"
+
+DEPEND="
+	sys-libs/readline:=
+	sys-libs/zlib
+"
+RDEPEND="${DEPEND}"
+BDEPEND="
+	dev-util/gperf
+	sys-devel/bison
+	sys-devel/flex
+"
+
+PATCHES=(
+	"${FILESDIR}/${P}-autoconf-2.70.patch" #749870
+)
+
+src_prepare() {
+	default
+
+	# From upstreams autoconf.sh, to make it utilize the autotools eclass
+	# Here translate the autoconf.sh, equivalent to the following code
+	# > sh autoconf.sh
+
+	# Autoconf in root ...
+	eautoconf
+
+	# Precompiling lexor_keyword.gperf
+	gperf -o -i 7 -C -k 1-4,6,9,\$ -H keyword_hash -N check_identifier -t ./lexor_keyword.gperf > lexor_keyword.cc || die
+	# Precompiling vhdlpp/lexor_keyword.gperf
+	cd vhdlpp || die
+	gperf -o -i 7 --ignore-case -C -k 1-4,6,9,\$ -H keyword_hash -N check_identifier -t ./lexor_keyword.gperf > lexor_keyword.cc || die
+}
+
+src_install() {
+	local DOCS=( *.txt )
+
+	default
+
+	dodoc -r examples
+	docompress -x /usr/share/doc/${PF}/examples
+}
diff --git a/sci-electronics/iverilog/metadata.xml b/sci-electronics/iverilog/metadata.xml
new file mode 100644
index 0000000..a69157e
--- /dev/null
+++ b/sci-electronics/iverilog/metadata.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
+<pkgmetadata>
+	<maintainer type="person" proxied="yes">
+		<email>vowstar@gmail.com</email>
+		<name>Huang Rui</name>
+	</maintainer>
+	<maintainer type="project">
+		<email>sci-electronics@gentoo.org</email>
+		<name>Gentoo Electronics Project</name>
+	</maintainer>
+	<maintainer type="project" proxied="proxy">
+		<email>proxy-maint@gentoo.org</email>
+		<name>Proxy Maintainers</name>
+	</maintainer>
+	<upstream>
+		<remote-id type="github">steveicarus/iverilog</remote-id>
+	</upstream>
+	<longdescription>
+	Icarus Verilog is a Verilog simulation and synthesis tool. It operates as a
+	compiler, compiling source code writen in Verilog (IEEE-1364) into some target
+	format. The compiler proper is intended to parse and elaborate design
+	descriptions written to the IEEE standard IEEE Std 1364-2001.
+	</longdescription>
+</pkgmetadata>