Merge branch 'master' of github.com:yosyshq/yosys into q3k/cirrus
diff --git a/.cirrus.yml b/.cirrus.yml
new file mode 100644
index 0000000..b242dfc
--- /dev/null
+++ b/.cirrus.yml
@@ -0,0 +1,63 @@
+task:
+  name: build-test-trusty-gcc
+  container:
+    cpu: 4
+    memory: 6
+    dockerfile: .cirrus/Dockerfile.ubuntu14.04
+  env:
+    CONFIG: gcc
+  build_script: .cirrus/step-build.sh
+  test_script: .cirrus/step-test.sh
+
+task:
+  name: build-test-trusty-clang
+  container:
+    cpu: 4
+    memory: 6
+    dockerfile: .cirrus/Dockerfile.ubuntu14.04
+  env:
+    CONFIG: clang
+  build_script: .cirrus/step-build.sh
+  test_script: .cirrus/step-test.sh
+
+task:
+  name: build-test-bionic-gcc
+  container:
+    cpu: 4
+    memory: 6
+    dockerfile: .cirrus/Dockerfile.ubuntu18.04
+  env:
+    CONFIG: gcc
+  build_script: .cirrus/step-build.sh
+  test_script: .cirrus/step-test.sh
+
+task:
+  name: build-test-bionic-clang
+  container:
+    cpu: 4
+    memory: 6
+    dockerfile: .cirrus/Dockerfile.ubuntu18.04
+  env:
+    CONFIG: clang
+  build_script: .cirrus/step-build.sh
+  test_script: .cirrus/step-test.sh
+
+task:
+  name: build-test-high-sierra-clang
+  osx_instance:
+    image: high-sierra-xcode-9.4.1
+  env:
+    CONFIG: clang
+  prepare_script: .cirrus/step-macos-prepare.sh
+  build_script: .cirrus/step-build.sh
+  test_script: .cirrus/step-test.sh
+
+task:
+  name: build-test-mojave-clang
+  osx_instance:
+    image: mojave-xcode-10.1
+  env:
+    CONFIG: clang
+  prepare_script: .cirrus/step-macos-prepare.sh
+  build_script: .cirrus/step-build.sh
+  test_script: .cirrus/step-test.sh
diff --git a/.cirrus/Dockerfile.ubuntu14.04 b/.cirrus/Dockerfile.ubuntu14.04
new file mode 100644
index 0000000..35366c1
--- /dev/null
+++ b/.cirrus/Dockerfile.ubuntu14.04
@@ -0,0 +1,20 @@
+FROM ubuntu:trusty-20181115
+
+ENV DEBIAN_FRONTEND=noninteractive
+
+RUN set -e -x ;\
+    apt-get -y update ;\
+    apt-get -y upgrade ;\
+    apt-get -y install build-essential clang gperf bison flex libreadline-dev gawk \
+                       tcl-dev libffi-dev git graphviz xdot pkg-config python autoconf
+
+RUN set -e -x ;\
+    cd /tmp ;\
+    git clone git://github.com/steveicarus/iverilog.git ;\
+    cd iverilog ;\
+    autoconf ;\
+    ./configure ;\
+    make -j $(nproc) ;\
+    make install ;\
+    cd .. ;\
+    rm -rf iverilog
diff --git a/.cirrus/Dockerfile.ubuntu18.04 b/.cirrus/Dockerfile.ubuntu18.04
new file mode 100644
index 0000000..06fa135
--- /dev/null
+++ b/.cirrus/Dockerfile.ubuntu18.04
@@ -0,0 +1,20 @@
+FROM ubuntu:bionic-20181112
+
+ENV DEBIAN_FRONTEND=noninteractive
+
+RUN set -e -x ;\
+    apt-get -y update ;\
+    apt-get -y upgrade ;\
+    apt-get -y install build-essential clang gperf bison flex libreadline-dev gawk \
+                       tcl-dev libffi-dev git graphviz xdot pkg-config python autoconf
+
+RUN set -e -x ;\
+    cd /tmp ;\
+    git clone git://github.com/steveicarus/iverilog.git ;\
+    cd iverilog ;\
+    autoconf ;\
+    ./configure ;\
+    make -j $(nproc) ;\
+    make install ;\
+    cd .. ;\
+    rm -rf iverilog
diff --git a/.cirrus/step-build.sh b/.cirrus/step-build.sh
new file mode 100755
index 0000000..32baf65
--- /dev/null
+++ b/.cirrus/step-build.sh
@@ -0,0 +1,21 @@
+#!/usr/bin/env bash
+
+set -e -x
+
+if [ "$CONFIG" = "gcc" ]; then
+	echo "Configuring for gcc."
+	make config-gcc
+elif [ "$CONFIG" = "clang" ]; then
+	echo "Configuring for clang."
+	make config-clang
+else
+    echo "CONFIG needs to be set to either 'clang' or 'gcc'" >&2
+    exit 1
+fi
+
+ncpu=4
+if nproc; then
+    ncpu=$(nproc)
+fi
+
+make -j ${ncpu}
diff --git a/.cirrus/step-macos-prepare.sh b/.cirrus/step-macos-prepare.sh
new file mode 100755
index 0000000..8323cf2
--- /dev/null
+++ b/.cirrus/step-macos-prepare.sh
@@ -0,0 +1,25 @@
+#!/usr/bin/env bash
+
+# Prepare Homebrew
+
+brew update
+brew tap Homebrew/bundle
+brew bundle
+brew install ccache
+
+# Install Icarus Verilog
+
+mkdir -p ~/.local-src
+mkdir -p ~/.local-bin
+cd ~/.local-src
+git clone git://github.com/steveicarus/iverilog.git
+cd iverilog
+autoconf
+./configure --prefix=$HOME/.local-bin
+make -j $(nproc)
+make install
+
+# Configure new PATH
+
+export PATH="$HOME/.local-bin/bin:$PATH"
+export PATH="/usr/local/opt/ccache/libexec:$PATH"
diff --git a/.cirrus/step-test.sh b/.cirrus/step-test.sh
new file mode 100755
index 0000000..f479886
--- /dev/null
+++ b/.cirrus/step-test.sh
@@ -0,0 +1,5 @@
+#!/usr/bin/env bash
+
+set -e -x
+
+make -j $(nproc) test
diff --git a/.travis.yml b/.travis.yml
deleted file mode 100644
index 8aacbb8..0000000
--- a/.travis.yml
+++ /dev/null
@@ -1,148 +0,0 @@
-sudo: false
-language: cpp
-
-cache:
- ccache: true
- directories:
-  - ~/.local-bin
-
-
-env:
-  global:
-    - MAKEFLAGS="-j 2"
-
-matrix:
-  include:
-    # Latest gcc-4.8, earliest version supported by Travis
-    - os: linux
-      addons:
-        apt:
-          packages:
-            - g++-4.8
-            - gperf
-            - build-essential
-            - bison
-            - flex
-            - libreadline-dev
-            - gawk
-            - tcl-dev
-            - libffi-dev
-            - git
-            - graphviz
-            - xdot
-            - pkg-config
-            - python
-      env:
-        - MATRIX_EVAL="CONFIG=gcc && CC=gcc-4.8 && CXX=g++-4.8"
-
-    # Latest gcc-6 on Travis Linux
-    - os: linux
-      addons:
-        apt:
-          sources:
-            - ubuntu-toolchain-r-test
-          packages:
-            - g++-6
-            - gperf
-            - build-essential
-            - bison
-            - flex
-            - libreadline-dev
-            - gawk
-            - tcl-dev
-            - libffi-dev
-            - git
-            - graphviz
-            - xdot
-            - pkg-config
-            - python
-      env:
-        - MATRIX_EVAL="CONFIG=gcc && CC=gcc-6 && CXX=g++-6"
-
-    # Latest gcc supported on Travis Linux
-    - os: linux
-      addons:
-        apt:
-          sources:
-            - ubuntu-toolchain-r-test
-          packages:
-            - g++-7
-            - gperf
-            - build-essential
-            - bison
-            - flex
-            - libreadline-dev
-            - gawk
-            - tcl-dev
-            - libffi-dev
-            - git
-            - graphviz
-            - xdot
-            - pkg-config
-            - python
-      env:
-        - MATRIX_EVAL="CONFIG=gcc && CC=gcc-7 && CXX=g++-7"
-
-    # Clang which ships on Trusty Linux
-    - os: linux
-      addons:
-        apt:
-          sources:
-            - ubuntu-toolchain-r-test
-            - llvm-toolchain-precise-3.8
-          packages:
-            - clang-3.8
-            - gperf
-            - build-essential
-            - bison
-            - flex
-            - libreadline-dev
-            - gawk
-            - tcl-dev
-            - libffi-dev
-            - git
-            - graphviz
-            - xdot
-            - pkg-config
-            - python
-      env:
-        - MATRIX_EVAL="CONFIG=clang && CC=clang-3.8 && CXX=clang++-3.8"
-
-    # Latest clang supported by Travis Linux
-    - os: linux
-      addons:
-        apt:
-          sources:
-            - llvm-toolchain-trusty-5.0
-          packages:
-            - clang-5.0
-            - gperf
-            - build-essential
-            - bison
-            - flex
-            - libreadline-dev
-            - gawk
-            - tcl-dev
-            - libffi-dev
-            - git
-            - graphviz
-            - xdot
-            - pkg-config
-            - python
-      env:
-        - MATRIX_EVAL="CONFIG=clang && CC=clang-5.0 && CXX=clang++-5.0"
-
-    # Latest clang on Mac OS X
-    - os: osx
-      osx_image: xcode9.4
-      env:
-        - MATRIX_EVAL="CONFIG=clang && CC=clang && CXX=clang++"
-
-before_install:
-  - ./.travis/setup.sh
-
-script:
-  - ./.travis/build-and-test.sh
-
-after_success:
-  - ./.travis/deploy-after-success.sh
diff --git a/.travis/build-and-test.sh b/.travis/build-and-test.sh
deleted file mode 100755
index 096dde6..0000000
--- a/.travis/build-and-test.sh
+++ /dev/null
@@ -1,49 +0,0 @@
-#! /bin/bash
-
-set -e
-
-source .travis/common.sh
-
-##########################################################################
-
-echo
-echo 'Configuring...' && echo -en 'travis_fold:start:script.configure\\r'
-echo
-
-if [ "$CONFIG" = "gcc" ]; then
-	echo "Configuring for gcc."
-	make config-gcc
-elif [ "$CONFIG" = "clang" ]; then
-	echo "Configuring for clang."
-	make config-clang
-fi
-
-echo
-echo -en 'travis_fold:end:script.configure\\r'
-echo
-
-##########################################################################
-
-echo
-echo 'Building...' && echo -en 'travis_fold:start:script.build\\r'
-echo
-
-make
-
-echo
-echo -en 'travis_fold:end:script.build\\r'
-echo
-
-##########################################################################
-
-echo
-echo 'Testing...' && echo -en 'travis_fold:start:script.test\\r'
-echo
-
-make test
-
-echo
-echo -en 'travis_fold:end:script.test\\r'
-echo
-
-##########################################################################
diff --git a/.travis/common.sh b/.travis/common.sh
deleted file mode 100644
index 8eecc4c..0000000
--- a/.travis/common.sh
+++ /dev/null
@@ -1,15 +0,0 @@
-#! /bin/bash
-
-# Setup the CC / CXX from the matrix config
-eval "${MATRIX_EVAL}"
-
-# Look for location binaries first
-export PATH="$HOME/.local-bin/bin:$PATH"
-
-# OS X specific common setup
-if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then
-	export PATH="/usr/local/opt/ccache/libexec:$PATH"
-fi
-
-# Parallel builds!
-MAKEFLAGS="-j 2"
diff --git a/.travis/deploy-after-success.sh b/.travis/deploy-after-success.sh
deleted file mode 100755
index d64e952..0000000
--- a/.travis/deploy-after-success.sh
+++ /dev/null
@@ -1,6 +0,0 @@
-#! /bin/bash
-
-set -x
-set -e
-
-# FIXME: Upload the build results somewhere...
diff --git a/.travis/setup.sh b/.travis/setup.sh
deleted file mode 100755
index d689cd2..0000000
--- a/.travis/setup.sh
+++ /dev/null
@@ -1,96 +0,0 @@
-#! /bin/bash
-
-set -e
-
-source .travis/common.sh
-
-##########################################################################
-
-# Fixing Travis's git clone
-echo
-echo 'Fixing git setup...' && echo -en 'travis_fold:start:before_install.git\\r'
-echo
-git fetch --unshallow && git fetch --tags
-
-# For pull requests, we get more info about the git source.
-if [ z"$TRAVIS_PULL_REQUEST_SLUG" != z ]; then
-	echo "- Fetching from pull request source"
-	git remote add source https://github.com/$TRAVIS_PULL_REQUEST_SLUG.git
-	git fetch source && git fetch --tags
-
-	echo "- Fetching the actual pull request"
-	git fetch origin pull/$TRAVIS_PULL_REQUEST/head:pull-$TRAVIS_PULL_REQUEST-head
-	git fetch origin pull/$TRAVIS_PULL_REQUEST/merge:pull-$TRAVIS_PULL_REQUEST-merge
-
-	git log -n 5 --graph pull-$TRAVIS_PULL_REQUEST-merge
-fi
-
-# For building branches we need to fix the "detached head" state.
-if [ z"$TRAVIS_BRANCH" != z ]; then
-	TRAVIS_COMMIT_ACTUAL=$(git log --pretty=format:'%H' -n 1)
-	echo "- Fixing detached head (current $TRAVIS_COMMIT_ACTUAL -> $TRAVIS_COMMIT)"
-	git remote -v
-	git branch -v
-	if [ x"$(git show-ref -s HEAD)" = x"$TRAVIS_COMMIT" ]; then
-		echo "Checked out at $TRAVIS_COMMIT"
-	else
-		if [ z"$TRAVIS_PULL_REQUEST_SLUG" != z ]; then
-			git fetch source $TRAVIS_COMMIT || echo "Unable to fetch $TRAVIS_COMMIT from source"
-		fi
-		git fetch origin $TRAVIS_COMMIT || echo "Unable to fetch $TRAVIS_COMMIT from origin"
-	fi
-	git branch -D $TRAVIS_BRANCH || true
-	git checkout $TRAVIS_COMMIT -b $TRAVIS_BRANCH
-	git branch -v
-fi
-
-# Output status information.
-git status
-git describe --tags
-git log -n 5 --graph
-echo
-echo -en 'travis_fold:end:before_install.git\\r'
-echo
-
-##########################################################################
-
-# Mac OS X specific setup.
-if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then
-	(
-		echo
-		echo 'Setting up brew...' && echo -en 'travis_fold:start:before_install.brew\\r'
-		echo
-		brew update
-		brew tap Homebrew/bundle
-		brew bundle
-		brew install ccache
-		echo
-		echo -en 'travis_fold:end:before_install.brew\\r'
-		echo
-	)
-fi
-
-##########################################################################
-
-# Install iverilog
-(
-	if [ ! -e ~/.local-bin/bin/iverilog ]; then
-		echo
-		echo 'Building iverilog...' && echo -en 'travis_fold:start:before_install.iverilog\\r'
-		echo
-		mkdir -p ~/.local-src
-		mkdir -p ~/.local-bin
-		cd ~/.local-src
-		git clone git://github.com/steveicarus/iverilog.git
-		cd iverilog
-		autoconf
-		./configure --prefix=$HOME/.local-bin
-		make
-		make install
-		echo
-		echo -en 'travis_fold:end:before_install.iverilog\\r'
-		echo
-	fi
-)
-
-##########################################################################
diff --git a/Brewfile b/Brewfile
index 0c58ce1..f04da33 100644
--- a/Brewfile
+++ b/Brewfile
@@ -1,3 +1,4 @@
+brew "autoconf"
 brew "bison"
 brew "flex"
 brew "gawk"