# 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="-j1"

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" ||
	"${CATEGORY}/${PN}" == "net-libs/libnetfilter_queue" ]]
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 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}" != "games-strategy/0ad" &&
	"${CATEGORY}/${PN}" != "dev-libs/elfutils" &&
	"${CATEGORY}/${PN}" != "dev-util/cmake" &&
	"${CATEGORY}/${PN}" != "media-libs/libraw" &&
	"${CATEGORY}/${PN}" != "media-libs/gd" &&
	"${CATEGORY}/${PN}" != "media-libs/sdl2-gfx" &&
	"${CATEGORY}/${PN}" != "app-crypt/johntheripper" &&
	"${CATEGORY}/${PN}" != "dev-games/cegui" &&
	"${CATEGORY}/${PN}" != "sys-block/thin-provisioning-tools" &&
	"${CATEGORY}/${PN}" != "sys-apps/paludis" &&
	"${CATEGORY}/${PN}" != "dev-libs/crypto++" &&
	"${CATEGORY}/${PN}" != "sys-power/iasl" &&
	"${CATEGORY}/${PN}" != "net-libs/libmnl" &&
	"${CATEGORY}/${PN}" != "net-libs/opal" &&
	"${CATEGORY}/${PN}" != "x11-libs/pixman"
	]]
then
	CC="clang"
	BUILD_CC="clang"
	CFLAGS+=" -Qunused-arguments -fcolor-diagnostics"
	CXX="clang++"
	BUILD_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


