Ah, looks like attachment isn't attached, post my ebuild in plain text.
EAPI=7
inherit multilib toolchain-funcs
DESCRIPTION="Open source assembly language compiler"
HOMEPAGE="https://flatassembler.net"
SRC_URI="https://flatassembler.net/${P}.tgz"
LICENSE="MIT"
SLOT="0"
KEYWORDS="amd64 x86"
IUSE="-tools -libc"
DEPEND=""
RDEPEND=""
S="${WORKDIR}/${PN}"
PATCHES=( "${FILESDIR}/1-fix-gnu-stack.patch" )
TOOLS=(listing prepsrc symbols)
pkg_setup() {
if use tools || use libc; then
if [[ ${ARCH} = "amd64" && ! $(get_all_abis) =~ "x86" ]]; then
die "Multilib profile must be selected to build 32-bit tools or
libc-linked FASM for amd64 target"
fi
fi
CC=$(tc-getCC)
}
src_compile() {
# fasm is written on itself; so, if fasm already installed,
# assemble it with system fasm, otherwise assemble it
# with binary provided in tarball
if has_version -b "${CATEGORY}/${PN}"; then
FASM="${PN}"
is_bootstrap=1
elif [[ ${ARCH} = "x86" ]]; then
einfo "Bootstrapping fasm from binary"
FASM="./${PN}"
else # amd64
einfo "Bootstrapping fasm from binary"
FASM="./${PN}.x64"
fi
if ! use libc; then
if [[ ${ARCH} = "x86" ]]; then
${FASM} "source/Linux/${PN}.asm" "${T}/${PN}" || die
else # amd64
${FASM} "source/Linux/x64/${PN}.asm" "${T}/${PN}" || die
fi
else
${FASM} "source/libc/fasm.asm" || die
${CC} -m32 ${LDFLAGS} -o "${T}/${PN}" "source/libc/fasm.o" ||
die
fi
if use tools; then
# bootstrapping is done at this point, we can use
# our homebrewed binary for building tools
[[ -v is_bootstrap ]] && FASM="${T}/${PN}"
for tool in "${TOOLS[@]}"; do
${FASM} "tools/libc/${tool}.asm" || die
${CC} -m32 ${LDFLAGS} -o "${T}/${tool}"
"tools/libc/${tool}.o" || die
done
fi
}
src_install() {
exeinto /usr/bin
doexe "${T}/${PN}"
dodoc "${PN}.txt"
if use tools; then
for tool in "${TOOLS[@]}"; do
doexe "${T}/${tool}"
done
dodoc "tools/fas.txt"
fi
}