I found a neat script to parse a package.cflags file and use them for per-package cflags written by Ned Ludd. I modified it a bit. It now uses 3 files: /etc/portage/package.cflags, /etc/portage/package.cxxflags, and /etc/portage/features to allow one to OVERRIDE CFLAGS, CXXFLAGS and FEATURES in make.conf
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.

Here's a sample file that would work for package.cflags OR package.cxxflags

Code:

# 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

This script will sift through package.[argument] and combine all the flags for each package and sort everything, eliminating duplicate lines. You can even call 'cleanfile use' and it will even warn you of combining -flag and flag for the same package if you've accidentally done this on different lines.

Joined: 23 Dec 2004Posts: 790Location: under a car or on top of a keyboard

Posted: Fri Feb 25, 2005 8:07 pm Post subject:

I believe it's planned for the next major version. Probably won't be using a bashrc, tho. Funny thing is, it's not that useful unless you're trying to run your system on the edge. You'd think this is something the dev's wouldn't particularly care for owing to all the false bugreports people like me can generate <flame protection> I don't, I make sure on another system before filing</flame protection>

Well , I deffinitely try to run the system on the edge. But I still want it to run, though Per-package CFLAGS can actually help bring down the number of false bug-reports. You will be able to heavily optimize only the parts of the system that matter and are ( considered ) safe. This is better than having global agressive CFLAGS , I guess.

Joined: 23 Dec 2004Posts: 790Location: under a car or on top of a keyboard

Posted: Thu Mar 03, 2005 9:55 am Post subject:

now there's no need to change make.conf for packages broken by userpriv or sandboxing! I just added package.features support and fixed the use of GLOBALCFLAGS and the like in the config files (which were broken the whole time and I never realized it )

The use of GLOBALwhatever is as follows

Code:

##/etc/portage/package.features
x11-wm/fluxbox GLOBALFEATURES cvs

Please note the absense of $ or {}, which is intentional.

Last edited by thebigslide on Thu Mar 03, 2005 11:28 am; edited 1 time in total

Joined: 23 Dec 2004Posts: 790Location: under a car or on top of a keyboard

Posted: Thu Mar 03, 2005 11:26 am Post subject:

Here's another little tastey that will remove duplicate entries in /etc/portage/package.use, cflags, cxxflags, features, merge and sort the arguments and warn of opposing USE flags.
EDIT: Merged into the first post for clarity of use.
If it breaks anything, the old filenames are prepended with a '.'

Anyways, I decided to add a little feature to it, namely package.ldflags - along the way I kind of moved all the repetative code into one big function. So feel free to add changes or not or whatever - here's what I ended up with (not sure how well it works):

i tried SoTired's script because right now i need per-package LDFLAGS management, but it doesn't seem to be working. it looks like the values set in make.conf are getting wiped for all packages, whether they have an entry in the new package files or not.

i changed the bzip2 ebuild to print the environment info emerge was seeing.

with package.cflags/cxxflags/ldflags/features empty:

Code:

CFLAGS:
CXXFLAGS:
LDFLAGS:
FEATURES:

added some flags using the syntax 'app-arch/bzip2 [flags]':

Code:

CFLAGS: -O2 -fweb
CXXFLAGS: -O2 -fweb
LDFLAGS: -Wl,-O1
FEATURES: test

which is what i entered so that bit works. but here's something strange i found when i added the GLOBAL stuff in each file.

so it does have my make.conf values stored, it's just not using them when it should. i have no idea why the flags i added to the package files all get appended 3 times to the end though.

i'll give thebigslide's bashrc a try and see if works and if it does what the difference is..

[edit]
thebigslide's bashrc also has the triple-flag thing when using GLOBALs but otherwise works as advertised. i think that all that needs fixing is detecting whether a package is actually in the package files and carrying over the make.conf values when it's not._________________by design, by neglect
for a fact or just for effect

The flags being added three times is (I believe) a problem with portage. It definitely calls the bashrc more than once, but perhaps it is supposed to do so. In any case having the flags more than once doesn't hurt anything.

About my modifications breaking everything: Oops. I think I fixed it, I had a line in the wrong place.

attemp_override()
{
local setting=$1
local global_setting=`eval echo '$'$setting`
local include_global_setting=GLOBAL$setting
local package_pattern="^[[:space:]]*${CATEGORY}/${PN}[[:space:]]"
local category_pattern="^[[:space:]]*${CATEGORY}[[:space:]]"