You can define a category specific rule or a package specific rule:
any CFLAGS you put in will OVERRIDE the setting in make.conf, also, one can use GLOBALCFLAGS, GLOBALCXXFLAGS, and GLOBALFEATURES in packages.c{,xx}flags and package.features if you want to include the flags set in make.conf.
This is a bashrc that should be moved to /etc/portage/bashrc.
Code: Select all
## Copyright 1999-2005 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /etc/portage/bashrc$
# Originally written by Ned Ludd (solar_at_gentoo.org)
# modifications by Ryan McIntosh (thebigslide_at_gmail.com)
# V1.0_rc1
# - /etc/portage/bashrc
if [ "$0" = "/usr/lib/portage/bin/ebuild.sh" -o "$0" = "/usr/lib/portage/bin/ebuild-daemon.sh" ]; then
append-cflags() {
export CFLAGS="${CFLAGS} $*"
return 0
}
append-cxxflags() {
export CXXFLAGS="${CXXFLAGS} $*"
return 0
}
append-features() {
export FEATURES="${FEATURES} $*"
return 0
}
package-cflags() {
# bail if file does not exist or is not readable.
[ -r ${ROOT}/etc/portage/package.cflags ] || return 0
while read -a target; do
if [ "${target}" = "${CATEGORY}" ]; then
unset CFLAGS
for i in `/bin/seq 20`; do #linelength
if [ "${target[$i]}" = "GLOBALCFLAGS" ]; then
append-cflags $GLOBALCFLAGS
else
if [ "${target[$i]}" = "GLOBALCXXFLAGS" ]; then
append-cflags $GLOBALCXXFLAGS
else
append-cflags ${target[$i]}
fi
fi
done
export -n CFLAGS
else
if [ "${target}" = "${CATEGORY}/${PN}" ]; then
unset CFLAGS
for i in `/bin/seq 20`; do #linelength
if [ "${target[$i]}" = "GLOBALCFLAGS" ]; then
append-cflags $GLOBALCFLAGS
else
if [ "${target[$i]}" = "GLOBALCXXFLAGS" ]; then
append-cflags $GLOBALCXXFLAGS
else
append-cflags ${target[$i]}
fi
fi
done
export -n CFLAGS
fi
fi
done < ${ROOT}/etc/portage/package.cflags
}
package-cxxflags() {
# bail if file does not exist or is not readable.
[ -r ${ROOT}/etc/portage/package.cxxflags ] || return 0
while read -a target; do
if [ "${target}" = "${CATEGORY}" ]; then
unset CXXFLAGS
for i in `/bin/seq 20`; do #linelength
if [ "${target[$i]}" = "GLOBALCXXFLAGS" ]; then
append-cxxflags $GLOBALCXXFLAGS
else
if [ "${target[$i]}" = "GLOBALCFLAGS" ]; then
append-cxxflags $GLOBALCFLAGS
else
append-cxxflags ${target[$i]}
fi
fi
done
export -n CXXFLAGS
else
if [ "${target}" = "${CATEGORY}/${PN}" ]; then
unset CXXFLAGS
for i in `/bin/seq 20`; do #linelength
if [ "${target[$i]}" = "GLOBALCXXFLAGS" ]; then
append-cxxflags $GLOBALCXXFLAGS
else
if [ "${target[$i]}" = "GLOBALCFLAGS" ]; then
append-cxxflags $GLOBALCFLAGS
else
append-cxxflags ${target[$i]}
fi
fi
done
export -n CXXFLAGS
fi
fi
done < $ROOT/etc/portage/package.cxxflags
}
package-features() {
# bail if file does not exist or is not readable.
[ -r ${ROOT}/etc/portage/package.features ] || return 0
while read -a target; do
if [ "${target}" = "${CATEGORY}" ]; then
unset FEATURES
for i in `/bin/seq 20`; do #linelength
if [ "${target[$i]}" = "GLOBALFEATURES" ]; then
append-features $GLOBALFEATURES
else
append-features ${target[$i]}
fi
done
export -n FEATURES
else
if [ "${target}" = "${CATEGORY}/${PN}" ]; then
unset FEATURES
for i in `/bin/seq 20`; do #linelength
if [ "${target[$i]}" = "GLOBALFEATURES" ]; then
append-features $GLOBALFEATURES
else
append-features ${target[$i]}
fi
done
export -n FEATURES
fi
fi
done < $ROOT/etc/portage/package.features
}
export GLOBALCFLAGS=$CFLAGS
export GLOBALCXXFLAGS=$CXXFLAGS
export GLOBALFEATURES=$FEATURES
package-cflags
package-cxxflags
package-features
unset GLOBALCFLAGS
unset GLOBALCXXFLAG
unset GLOBALFEATURES
else
echo "This bashrc does not know anything about $0"
fiCode: Select all
# Copyright 1999-2005 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $
# - /etc/portage/package.cflags and /etc/portage/package/cxxflags=
##############
# Important: #
##############
# >=dev-blah/blah syntax is not supported by this files.
# We can take individual category names
# Or we can take individual ebuild names
# Changes to this file OVERRIDE settings in make.conf
##############
# CATEGORIES #
##############
app-editors -Os -march=-686
sys-apps GLOBALCFLAGS -Os
sys-fs GLOBALCFLAGS -Os
dev-libs -O1
net-misc -O2
net-www -O2
sys-boot -fno-stack-protector-all
sys-libs -O1
sys-devel -Os
gnome-base GLOBALCXXFLAGS -Wl,-O1
gnome-extra -Wl,-O1
media-libs -O1
x11-misc -Wl,-O1
x11-wm -Wl,-O1
#################
# PACKAGE NAMES #
#################
net-www/mozilla -O3 -Wl,-01
sys-apps/chpax -O1
sys-apps/paxctl -O1
mail-client/evolution -Wl,-O1
media-video/mplayer -O3 -mno-sse2 -fno-stack-protector -fno-stack-protector-all
*****UPDATE: You can now make tweaks to packages by doing
Code: Select all
echo app-type/package-name -flag >> /etc/portage/package.cflags && cleanfile cflagsCode: Select all
##/sbin/cleanfile
#!/bin/bash
cleanfile() {
local PKGLIST USEFLAGS TEMPUSE ANTIFLAG DUPTEST I J
PKGLIST=`cat /etc/portage/package.${1} | cut -d " " -f1 | sort -u`
for I in $PKGLIST
do
USEFLAGS=`grep "$I" /etc/portage/package.${1} | cut -d " " -f2-`
echo -n "$I " >> /etc/portage/package.${1}.temp
rm -f /etc/portage/.TEMP &>/dev/null
for J in $USEFLAGS;
do
echo $J >> /etc/portage/.TEMP
if [ `echo $J | cut -c 1` = "-" ]; then
ANTIFLAG=`echo $J | cut -d "-" -f2`
DUPTEST=`echo $USEFLAGS | grep " $ANTIFLAG"`
if [ "$DUPTEST" != "" ]; then
echo "$I USEs both $J and $ANTIFLAG!!!"
fi
fi
done
echo `sort -u < /etc/portage/.TEMP` >> /etc/portage/package.${1}.temp
rm -f /etc/portage/.TEMP &>/dev/null
done
}
cleanfile $1






