How to personalize a package’s CFLAGS in Gentoo

Ok, last attempt to revive this blog ;-)

Well, there’s a little trick that I’d like to share with you guys that use Gentoo. Some time ago, I had to modify the value of the $CFLAGS environment variable for 2 packages in the Portage because they had some problems when the debugging option was enabled for configure. After some search, I’ve found the solution for this. Here goes the step-by-step (it’s pretty easy, I promise):

1) First, find the package’s path inside the Portage. This path is basically compounded by <category>/<package_name>. Let’s suppose that this path is app-editors/vim, so if your Portage is under /etc/portage, you should have a directory called /usr/portage/app-editors/vim/.

2) Now, you should create a file named /etc/portage/env/<category>/<package_name>, just like that:

#> touch /etc/portage/env/app-editors/vim

3) Edit this file with you preferred editor and put there the $CFLAGS value that you want, like that:

CFLAGS=”-D_HAVE_XYZ_”

If you want to append some value to the existing $CFLAGS, just do it:

CFLAGS=”${CFLAGS} –D_HAVE_XYZ_”

4) You are ready to go! :D

See? It’s pretty easy. Note that you can also add other variables (like $LDFLAGS), and emerge will handle them for you. If you have some trouble with the procedure, just let me know :-).

See ya!

Advertisements