# bashrc

## global settings
CHOST="x86_64-pc-linux-gnu"
CFLAGS="-march=core-avx2 -O2 -pipe -Wall"
CXXFLAGS="${CFLAGS}"
LDFLAGS="-Wl,-O1 -Wl,--as-needed -Wl,--hash-style=gnu"
MAKEOPTS="-j8"

I_KNOW_WHAT_I_AM_DOING="yes"
I_PROMISE_TO_SUPPLY_PATCHES_WITH_BUGS=1


# git-r3
EGIT_CLONE_TYPE=shallow


GAMES_PREFIX=/usr
GAMES_PREFIX_OPT=/opt
GAMES_DATADIR=/usr/share
GAMES_DATADIR_BASE=/usr/share
GAMES_SYSCONFDIR=/etc
GAMES_STATEDIR=/var/lib
GAMES_LOGDIR=/var/log
GAMES_BINDIR=${GAMES_PREFIX}/bin
GAMES_GROUP=users

# hack to disable actual building of multilib stuff
#MULTILIB_ABIS=amd64


## per-package settings

# no as-needed
if [[ "${CATEGORY}/${PN}" == "net-libs/libeXosip" ]]
then
	LDFLAGS="${LDFLAGS/-Wl,--as-needed/}"
fi

# laptop-compat, keep this at the top
if [[ "${CATEGORY}/${PN}" == "x11-libs/wxGTK" ||
		"${CATEGORY}/${PN}" == "www-client/firefox" ||
		"${CATEGORY}/${PN}" == "www-client/torbrowser" ||
		"${CATEGORY}/${PN}" == "mail-client/thunderbird" ||
		"${CATEGORY}/${PN}" == "app-office/libreoffice" ||
		"${CATEGORY}/${PN}" == "net-libs/webkit-gtk" ||
		"${CATEGORY}/${PN}" == "dev-qt/qtwebkit" ||
		"${CATEGORY}/${PN}" == "app-emulation/wine" ||
		"${CATEGORY}/${PN}" == "sys-devel/llvm" ]]
then
	CFLAGS="-march=core-avx-i -O2 -pipe"
	CXXFLAGS="-march=core-avx-i -O2 -pipe"
fi

# clang
# if [[ "${CATEGORY}/${PN}" == "games-strategy/wesnoth" ||
		# "${CATEGORY}/${PN}" == "games-strategy/hedgewars" ||
		# "${CATEGORY}/${PN}" == "games-strategy/s25rttr" ||
		# "${CATEGORY}/${PN}" == "games-fps/urbanterror" ||
		# "${CATEGORY}/${PN}" == "games-rpg/arx-libertatis" ||
		# "${CATEGORY}/${PN}" == "games-roguelike/stone-soup" ||
		# "${CATEGORY}/${PN}" == "games-rpg/flare" ||
		# "${CATEGORY}/${PN}" == "games-rpg/sumwars" ||
		# "${CATEGORY}/${PN}" == "games-puzzle/meandmyshadow" ||
		# "${CATEGORY}/${PN}" == "games-action/minetest" ||
		# "${CATEGORY}/${PN}" == "games-board/cockatrice" ||
		# "${CATEGORY}/${PN}" == "games-strategy/ja2-stracciatella" ||
		# "${CATEGORY}/${PN}" == "games-strategy/dunelegacy" ||
		# "${CATEGORY}/${PN}" == "games-strategy/0ad" ||
		# "${CATEGORY}/${PN}" == "games-rpg/mana" ||
		# "${CATEGORY}/${PN}" == "games-action/supertuxkart" ||
		# "${CATEGORY}/${PN}" == "games-strategy/megaglest" ||
		# "${CATEGORY}/${PN}" == "games-strategy/freesynd" ||
		# #"${CATEGORY}/${PN}" == "games-engines/scummvm" ||
		# "${CATEGORY}/${PN}" == "games-emulation/zsnes" ||
		# "${CATEGORY}/${PN}" == "games-engines/gemrb" ||
		# "${CATEGORY}/${PN}" == "games-rpg/kqlives" ||
		# "${CATEGORY}/${PN}" == "games-arcade/retrobattle" ||
		# "${CATEGORY}/${PN}" == "games-arcade/commandergenius" ||
		# "${CATEGORY}/${PN}" == "games-strategy/uqm" ||
		# "${CATEGORY}/${PN}" == "games-puzzle/picpuz" ||
		# "${CATEGORY}/${PN}" == "games-fps/quake3" ||
		# "${CATEGORY}/${PN}" == "games-arcade/cervi" ||
		# "${CATEGORY}/${PN}" == "games-arcade/opensonic" ||
		# "${CATEGORY}/${PN}" == "games-action/chromium-bsu" ||
		# "${CATEGORY}/${PN}" == "games-strategy/freeciv" ||
		# "${CATEGORY}/${PN}" == "games-arcade/supertux" ||
		# "${CATEGORY}/${PN}" == "games-board/pioneers" ||
		# "${CATEGORY}/${PN}" == "games-board/ace" ||
		# "${CATEGORY}/${PN}" == "games-fps/sauerbraten" ||
		# "${CATEGORY}/${PN}" == "games-strategy/widelands" ||
		# "${CATEGORY}/${PN}" == "games-engines/residualvm" ||
		# "${CATEGORY}/${PN}" == "games-strategy/zod-engine" ||
		# "${CATEGORY}/${PN}" == "games-arcade/berusky" ||
		# "${CATEGORY}/${PN}" == "games-fps/eduke32" ||
		# "${CATEGORY}/${PN}" == "games-rpg/manaplus" ||
		# "${CATEGORY}/${PN}" == "games-action/d2x-rebirth" ||
		# "${CATEGORY}/${PN}" == "app-arch/innoextract" ||
		# "${CATEGORY}/${PN}" == "dev-util/xfce4-dev-tools" ||
		# "${CATEGORY}" == "xfce-base" ||
		# "${CATEGORY}" == "xfce-extra" ||
		# "${CATEGORY}/${PN}" == "app-editors/bluefish" ||
		# "${CATEGORY}/${PN}" == "media-video/mplayer" ||
		# "${CATEGORY}/${PN}" == "media-video/mplayer2" ||
		# "${CATEGORY}/${PN}" == "media-video/gnome-mplayer" ||
		# "${CATEGORY}/${PN}" == "app-editors/efte" ||
		# "${CATEGORY}/${PN}" == "x11-misc/x11vnc" ||
		# "${CATEGORY}/${PN}" == "app-office/dia" ||
		# "${CATEGORY}/${PN}" == "media-sound/tudor-volumed" ||
		# "${CATEGORY}/${PN}" == "app-cdr/cdemud" ||
		# "${CATEGORY}/${PN}" == "app-cdr/cdemu" ||
		# "${CATEGORY}/${PN}" == "sys-process/htop" ||
		# "${CATEGORY}/${PN}" == "app-office/abiword" ||
		# "${CATEGORY}/${PN}" == "net-misc/remmina" ||
		# "${CATEGORY}/${PN}" == "x11-misc/compton" ||
		# "${CATEGORY}/${PN}" == "media-sound/audacious" ||
		# "${CATEGORY}/${PN}" == "media-plugins/audacious-plugins" ||
		# "${CATEGORY}/${PN}" == "media-gfx/gthumb" ||
		# "${CATEGORY}/${PN}" == "app-arch/file-roller" ||
		# "${CATEGORY}/${PN}" == "x11-libs/gtk+" ||
		# "${CATEGORY}/${PN}" == "x11-terms/sakura" ||
		# "${CATEGORY}/${PN}" == "app-admin/hardinfo" ||
		# "${CATEGORY}/${PN}" == "net-irc/hexchat" ||
		# "${CATEGORY}/${PN}" == "x11-misc/redshift" ||
		# "${CATEGORY}/${PN}" == "app-editors/gvim" ||
		# "${CATEGORY}/${PN}" == "app-editors/vim" ||
		# "${CATEGORY}/${PN}" == "x11-libs/vte:0" ||
		# "${CATEGORY}/${PN}" == "x11-libs/vte:2.90" ||
		# "${CATEGORY}/${PN}" == "x11-misc/parcellite" ||
		# "${CATEGORY}/${PN}" == "x11-misc/wbar" ||
		# "${CATEGORY}/${PN}" == "x11-misc/idesk" ||
		# "${CATEGORY}/${PN}" == "dev-util/geany" ||
		# "${CATEGORY}/${PN}" == "media-gfx/pornview" ||
		# "${CATEGORY}/${PN}" == "x11-wm/openbox" ||
		# "${CATEGORY}/${PN}" == "media-sound/guayadeque" ||
		# "${CATEGORY}/${PN}" == "media-sound/pnmixer" ||
		# "${CATEGORY}/${PN}" == "net-misc/badvpn" ||
		# "${CATEGORY}/${PN}" == "app-admin/mcelog" ||
		# "${CATEGORY}/${PN}" == "net-firewall/pglinux" ||
		# "${CATEGORY}/${PN}" == "dev-lua/luvit" ||
		# "${CATEGORY}/${PN}" == "media-gfx/nvidia-texture-tools" ||
		# "${CATEGORY}/${PN}" == "x11-misc/spacefm" ||
		# "${CATEGORY}/${PN}" == "sys-apps/udevil" ||
		# "${CATEGORY}/${PN}" == "sys-devel/clang" ||
		# "${CATEGORY}/${PN}" == "games-util/desurium" ||
		# "${CATEGORY}/${PN}" == "mail-client/geary" ||
		# "${CATEGORY}/${PN}" == "net-libs/polarssl" ||
		# "${CATEGORY}/${PN}" == "x11-wm/i3" ||
		# "${CATEGORY}/${PN}" == "media-video/mpv" ||
		# "${CATEGORY}/${PN}" == "net-im/utox" ||
		# "${CATEGORY}/${PN}" == "net-libs/tox" ||
		# "${CATEGORY}/${PN}" == "sys-apps/paludis" ||
		# "${CATEGORY}/${PN}:${SLOT}" == "dev-lang/spidermonkey:24"
# ]] ;
# then
	# CC="clang -Qunused-arguments -fcolor-diagnostics"
	# CXX="clang++ -Qunused-arguments -fcolor-diagnostics"
# #	CFLAGS+=" -fsanitize=address -fsanitize=bounds"
# #	CXXFLAGS+=" -fsanitize=address -fsanitize=bounds"
	# #LDFLAGS+=" -Wl,-z,now -Wl,-z,relro"
# fi


# clang incompatible or safety or missing openmp, also see #408963
if [[
	"${CATEGORY}/${PN}" != "sys-devel/binutils" &&
	"${CATEGORY}/${PN}" != "sys-devel/gcc" &&
	"${CATEGORY}/${PN}" != "sys-libs/glibc" &&
	"${CATEGORY}/${PN}" != "sys-apps/coreutils" &&
	"${CATEGORY}/${PN}" != "media-gfx/blender" &&
	"${CATEGORY}/${PN}" != "x11-drivers/nvidia-drivers" &&
	"${CATEGORY}/${PN}" != "media-libs/mesa" &&
	"${CATEGORY}/${PN}" != "x11-base/xorg-server" &&
	"${CATEGORY}/${PN}" != "games-strategy/freeorion" &&
	"${CATEGORY}/${PN}" != "dev-libs/boost" &&
	"${CATEGORY}/${PN}" != "games-engines/openmw" &&
	"${CATEGORY}/${PN}" != "net-p2p/retroshare" &&
	"${CATEGORY}/${PN}" != "app-emulation/virtualbox" &&
	"${CATEGORY}/${PN}" != "app-emulation/virtualbox-modules" &&
	"${CATEGORY}/${PN}" != "media-libs/id3lib" &&
	"${CATEGORY}/${PN}" != "net-firewall/pglinux" &&
	"${CATEGORY}/${PN}" != "app-crypt/gnupg" &&
	"${CATEGORY}/${PN}" != "dev-lang/ruby" &&
	"${CATEGORY}/${PN}" != "mail-client/thunderbird" &&
	"${CATEGORY}/${PN}" != "www-client/firefox" &&
	"${CATEGORY}/${PN}" != "dev-scheme/guile" &&
	"${CATEGORY}/${PN}" != "dev-libs/libixion" &&
	"${CATEGORY}/${PN}" != "dev-lang/gprolog" &&
	"${CATEGORY}/${PN}" != "x11-libs/motif" &&
	"${CATEGORY}/${PN}" != "x11-libs/cairo" &&
	"${CATEGORY}/${PN}" != "media-libs/devil" &&
	"${CATEGORY}/${PN}" != "sys-devel/autogen" &&
	"${CATEGORY}/${PN}" != "games-engines/gemrb" &&
	"${CATEGORY}/${PN}" != "app-emulation/wine" &&
	"${CATEGORY}/${PN}" != "app-text/recode" &&
	"${CATEGORY}/${PN}" != "dev-libs/openssl" &&
	"${CATEGORY}/${PN}" != "dev-games/goatee" &&
	"${CATEGORY}/${PN}" != "games-board/goatee-gtk" &&
	"${CATEGORY}/${PN}" != "www-client/torbrowser" &&
	"${CATEGORY}/${PN}" != "dev-util/nemiver" &&
	"${CATEGORY}/${PN}" != "app-text/aspell" &&
	"${CATEGORY}/${PN}" != "app-text/pandoc" &&
	"${CATEGORY}/${PN}" != "sys-apps/memtest86+" &&
	"${CATEGORY}/${PN}" != "games-engines/OpenJK" &&
	"${CATEGORY}/${PN}" != "dev-lang/luajit" &&
	"${CATEGORY}/${PN}" != "app-admin/haskell-updater" &&
	"${CATEGORY}/${PN}" != "dev-lang/spidermonkey" &&
	"${CATEGORY}/${PN}" != "games-strategy/liquidwar6" &&
	"${CATEGORY}/${PN}" != "sci-mathematics/z3" &&
	"${CATEGORY}" != "dev-haskell" &&
	"${CATEGORY}/${PN}" != "media-libs/libvorbis" &&
	"${CATEGORY}/${PN}" != "games-fps/unvanquished" &&
	"${CATEGORY}/${PN}" != "media-libs/gstreamer" &&
	"${CATEGORY}/${PN}" != "media-video/ffmpeg" &&
	"${CATEGORY}/${PN}" != "dev-libs/libev" &&
	"${CATEGORY}/${PN}" != "x11-libs/pixman"
	]]
then
	CC="clang"
	CFLAGS+=" -Qunused-arguments -fcolor-diagnostics"
	CXX="clang++"
	CXXFLAGS+=" -Qunused-arguments -fcolor-diagnostics"
fi

# missing fpic
# if [[ "${CATEGORY}/${PN}" == "games-emulation/dosbox" ]]
# then
	# CFLAGS+=" -fPIC"
	# CXXFLAGS+=" -fPIC"
# fi


# O3
if [[ "${CATEGORY}" == "games-"* &&
	"${CATEGORY}/${PN}" != "games-engines/OpenJK" ]]
then
	CFLAGS="${CFLAGS} -O3"
	CXXFLAGS="${CXXFLAGS} -O3"
fi


# debug
if [[ "${CATEGORY}/${PN}" == "x11-libs/gtk+" ||
		"${CATEGORY}/${PN}" == "dev-util/glade" ||
		"${CATEGORY}/${PN}" == "dev-libs/libntru" ||
		"${CATEGORY}/${PN}" == "net-misc/curl" ||
		"${CATEGORY}/${PN}" == "games-engines/OpenJK" ||
		"${CATEGORY}/${PN}" == "net-libs/mbedtls" ||
		"${CATEGORY}/${PN}" == "x11-misc/spacefm"
]]
then
	CFLAGS="${CFLAGS} -Wall -g"
	CXXFLAGS="${CXXFLAGS} -Wall -g"
fi


# full debug
if [[ "${CATEGORY}/${PN}" == "games-fps/doomsday"
]]
then
	CFLAGS="${CFLAGS} -Wall -g -O0"
	CXXFLAGS="${CXXFLAGS} -Wall -g -O0"
fi


# nodebug
if [[ "${CATEGORY}/${PN}" == "dev-python/pypy" ||
		"${CATEGORY}/${PN}" == "games-strategy/freeorion" ||
		"${CATEGORY}/${PN}" == "www-client/chromium" ||
		"${CATEGORY}/${PN}" == "sys-devel/clang" ||
		"${CATEGORY}/${PN}" == "sys-devel/llvm" ||
		"${CATEGORY}/${PN}" == "www-client/firefox" ||
		"${CATEGORY}/${PN}" == "www-client/torbrowser" ||
		"${CATEGORY}/${PN}" == "mail-client/thunderbird" ||
		"${CATEGORY}/${PN}" == "app-office/libreoffice" ||
		"${CATEGORY}/${PN}" == "net-libs/webkit-gtk" ||
		"${CATEGORY}/${PN}" == "dev-qt/qtwebkit" ]]
then
	CFLAGS="${CFLAGS} -g0"
	CXXFLAGS="${CXXFLAGS} -g0"
fi


# parallel build broken
if [[ "${CATEGORY}/${PN}" == "dev-libs/openssl" ]]
then
	MAKEOPTS="-j1"
fi


