MariaDB is in Gentoo, so the steps to build it are:
emerge --sync
emerge mariadb
© 2019 MariaDB
Licensed under the Creative Commons Attribution 3.0 Unported License and the GNU Free Documentation License.
https://mariadb.com/kb/en/Building_MariaDB_on_Gentoo/