--- /dev/null
+From 3ca37e53f22bfbb4ef436829904dc75b1f4940ec Mon Sep 17 00:00:00 2001
+From: Sebastian Pipping <sebastian@pipping.org>
+Date: Sun, 21 Jan 2018 11:16:53 +0100
+Subject: [PATCH] Quickport higan-099-QA.patch to v106r1
+
+---
+ higan/GNUmakefile | 5 ++---
+ higan/target-tomoko/GNUmakefile | 6 +++---
+ icarus/GNUmakefile | 4 ++--
+ nall/GNUmakefile | 19 -------------------
+ 4 files changed, 7 insertions(+), 27 deletions(-)
+
+diff --git a/higan/GNUmakefile b/higan/GNUmakefile
+index 5eac824..2616ed1 100644
+--- a/higan/GNUmakefile
++++ b/higan/GNUmakefile
+@@ -26,7 +26,6 @@ else ifneq ($(filter $(platform),linux bsd),)
+ flags += -fopenmp
+ link += -fopenmp
+ ifeq ($(binary),application)
+- flags += -march=native
+ link += -Wl,-export-dynamic
+ link += -lX11 -lXext
+ else ifeq ($(binary),library)
+@@ -40,9 +39,9 @@ endif
+ compile = \
+ $(strip \
+ $(if $(filter %.c,$<), \
+- $(compiler) $(cflags) $(flags) $1 -c $< -o $@, \
++ $(compiler) $(cflags) $(flags) $(CFLAGS) $1 -c $< -o $@, \
+ $(if $(filter %.cpp,$<), \
+- $(compiler) $(cppflags) $(flags) $1 -c $< -o $@ \
++ $(compiler) $(cppflags) $(flags) $(CXXFLAGS) $1 -c $< -o $@ \
+ ) \
+ ) \
+ )
+diff --git a/higan/target-tomoko/GNUmakefile b/higan/target-tomoko/GNUmakefile
+index bfdcbe2..bdb6d44 100644
+--- a/higan/target-tomoko/GNUmakefile
++++ b/higan/target-tomoko/GNUmakefile
+@@ -48,10 +48,10 @@ objects := $(ui_objects) $(objects)
+ objects := $(patsubst %,obj/%.o,$(objects))
+
+ obj/ruby.o: ../ruby/ruby.cpp $(call rwildcard,../ruby/)
+- $(compiler) $(rubyflags) -c $< -o $@
++ $(compiler) $(rubyflags) $(CXXFLAGS) -c $< -o $@
+
+ obj/hiro.o: ../hiro/hiro.cpp $(call rwildcard,../hiro/)
+- $(compiler) $(hiroflags) -c $< -o $@
++ $(compiler) $(hiroflags) $(CXXFLAGS) -c $< -o $@
+
+ obj/ui-tomoko.o: $(ui)/tomoko.cpp $(call rwildcard,$(ui)/)
+ obj/ui-program.o: $(ui)/program/program.cpp $(call rwildcard,$(ui)/)
+@@ -67,7 +67,7 @@ obj/ui-resource.o:
+
+ # targets
+ build: $(objects)
+- $(strip $(compiler) -o out/$(name) $(objects) $(link))
++ $(strip $(compiler) $(CXXFLAGS) -o out/$(name) $(objects) $(link))
+ ifeq ($(platform),macos)
+ @if [ -d out/$(name).app ]; then rm -r out/$(name).app; fi
+ mkdir -p out/$(name).app/Contents/MacOS/
+diff --git a/icarus/GNUmakefile b/icarus/GNUmakefile
+index d01465e..999c004 100644
+--- a/icarus/GNUmakefile
++++ b/icarus/GNUmakefile
+@@ -3,7 +3,7 @@ include ../nall/GNUmakefile
+ include ../hiro/GNUmakefile
+
+ name := icarus
+-flags += -I..
++flags += -I.. $(CXXFLAGS)
+ link +=
+
+ ifeq ($(platform),windows)
+@@ -15,7 +15,7 @@ objects += obj/icarus.o
+ objects += $(if $(call streq,$(platform),windows),obj/resource.o)
+
+ all: $(objects)
+- $(strip $(compiler) -o out/$(name) $(objects) $(link) $(hirolink))
++ $(strip $(compiler) -o out/$(name) $(objects) $(link) $(hirolink) $(LDFLAGS))
+ ifeq ($(platform),macos)
+ @if [ -d out/$(name).app ]; then rm -r out/$(name).app; fi
+ mkdir -p out/$(name).app/Contents/MacOS/
+diff --git a/nall/GNUmakefile b/nall/GNUmakefile
+index f9865de..f864cde 100644
+--- a/nall/GNUmakefile
++++ b/nall/GNUmakefile
+@@ -59,25 +59,6 @@ ifeq ($(compiler),)
+ endif
+ endif
+
+-# build settings
+-ifeq ($(build),optimize)
+- flags += -O3
+-else ifeq ($(build),release)
+- flags += -O2
+-else ifeq ($(build),stable)
+- flags += -O1
+-else ifeq ($(build),debug)
+- flags += -g
+-else ifeq ($(build),profile)
+- flags += -pg
+- link += -pg
+-else ifeq ($(build),instrument)
+- flags += -O3 -fprofile-generate
+- link += -lgcov
+-else ifeq ($(build),optimize)
+- flags += -O3 -fprofile-use
+-endif
+-
+ # clang settings
+ ifeq ($(findstring clang++,$(compiler)),clang++)
+ flags += -fno-strict-aliasing -fwrapv
+--
+2.16.0.rc2
+
--- /dev/null
+# Copyright 1999-2018 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=6
+
+inherit eutils gnome2-utils toolchain-funcs qmake-utils
+
+MY_COMMIT=41efdba45afa770db99bc7484a8ad340ccc597d2
+
+DESCRIPTION="A multi-system game emulator formerly known as bsnes"
+HOMEPAGE="https://byuu.org/emulation/higan/ https://gitlab.com/higan/higan"
+SRC_URI="https://gitlab.com/higan/higan/repository/${MY_COMMIT}/archive.tar.bz2 -> ${P}.tar.bz2"
+
+LICENSE="GPL-3"
+SLOT="0"
+KEYWORDS="~amd64 ~x86"
+IUSE="ao +alsa +icarus openal opengl oss pulseaudio +sdl udev xv"
+REQUIRED_USE="|| ( ao openal alsa pulseaudio oss )
+ || ( xv opengl sdl )"
+
+RDEPEND="
+ x11-libs/gtk+:2
+ x11-libs/libX11
+ x11-libs/libXext
+ icarus? ( x11-libs/gtksourceview:2.0
+ x11-libs/gtk+:2
+ x11-libs/pango
+ dev-libs/atk
+ x11-libs/cairo
+ x11-libs/gdk-pixbuf
+ dev-libs/glib:2
+ media-libs/fontconfig
+ media-libs/freetype
+ )
+ ao? ( media-libs/libao )
+ openal? ( media-libs/openal )
+ alsa? ( media-libs/alsa-lib )
+ pulseaudio? ( media-sound/pulseaudio )
+ xv? ( x11-libs/libXv )
+ opengl? ( virtual/opengl )
+ sdl? ( media-libs/libsdl[X,joystick,video] )
+ udev? ( virtual/udev )
+"
+DEPEND="${RDEPEND}
+ app-arch/p7zip
+ virtual/pkgconfig"
+
+S=${WORKDIR}/${PN}-${MY_COMMIT}-${MY_COMMIT}
+
+disable_module() {
+ sed -i \
+ -e "s|$1\b||" \
+ "${S}"/higan/target-tomoko/GNUmakefile || die
+}
+
+src_prepare() {
+ epatch "${FILESDIR}"/${P}-header-locations.patch
+ epatch "${FILESDIR}"/${P}-QA.patch
+
+ sed -i \
+ -e "/handle/s#/usr/local/lib#/usr/$(get_libdir)#" \
+ nall/dl.hpp || die "fixing libdir failed!"
+
+ eapply_user
+
+ # audio modules
+ use ao || disable_module audio.ao
+ use openal || disable_module audio.openal
+ use pulseaudio || { disable_module audio.pulseaudio
+ disable_module audio.pulseaudiosimple ;}
+ use oss || disable_module audio.oss
+ use alsa || disable_module audio.alsa
+
+ # video modules
+ use opengl || disable_module video.glx
+ use xv || disable_module video.xvideo
+ use sdl || disable_module video.sdl
+
+ # input modules
+ use sdl || disable_module input.sdl
+ use udev || disable_module input.udev
+}
+
+src_compile() {
+ local mytoolkit
+
+ mytoolkit="gtk"
+
+ if use icarus; then
+ cd "${S}/icarus" || die
+ emake \
+ platform="linux" \
+ compiler="$(tc-getCXX)"
+ fi
+
+ cd "${S}/higan" || die
+ emake \
+ platform="linux" \
+ compiler="$(tc-getCXX)" \
+ hiro="${mytoolkit}"
+}
+
+src_install() {
+ if use icarus; then
+ newbin "${S}"/icarus/out/icarus icarus
+ fi
+ newbin "${S}"/higan/out/${PN} ${PN}.bin
+ newbin "${FILESDIR}"/${P}-wrapper ${PN}
+ make_desktop_entry "${PN}" "${PN}"
+
+ # copy home directory stuff to a global location (matching "${FILESDIR}"/${P}-wrapper)
+ insinto /usr/share/${PN}
+ doins -r higan/systems/*.sys
+
+ doicon -s 512 higan/data/${PN}.png
+ doicon higan/data/${PN}.svg
+}
+
+pkg_preinst() {
+ games_pkg_preinst
+ gnome2_icon_savelist
+}
+
+pkg_postinst() {
+ #elog "optional dependencies:"
+ #elog " dev-games/higan-ananke (extra rom load options)"
+ #elog " games-util/higan-purify (Rom purifier)"
+
+ gnome2_icon_cache_update
+}
+
+pkg_postrm() {
+ gnome2_icon_cache_update
+}