public inbox for gentoo-dev@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-dev] CUSTOM cflags replacement snippet
@ 2004-11-20  6:14 Chris White
  2004-11-20 11:28 ` Eldad Zack
  2004-11-22 18:27 ` Aron Griffis
  0 siblings, 2 replies; 7+ messages in thread
From: Chris White @ 2004-11-20  6:14 UTC (permalink / raw
  To: gentoo-dev

[-- Attachment #1: Type: text/plain, Size: 1221 bytes --]

All,

    I created this quick little function to recursively patch Makefiles 
with custom CFLAGS.

custom_cflags() {
    for directories in *
    do
        if [ -d $directories -a -e $directories/Makefile ]
        then
            cd $directories
            for subdirectories in *
            do
                if [ -d $subdirectories -a -e $subdirectories/Makefile ]
                then
                    custom_cflags
                fi
            done

            sed -i \
            -e "s:^CFLAGS.*:CFLAGS = ${CFLAGS}:" Makefile \
            -e "s:^CXXFLAGS.*:CXXFLAGS = ${CXXFLAGS}:" Makefile \
            || die "Could not patch $directories/Makefile for custom CFLAGS"

            cd ..
        fi
    done
}

Known issues:

if CFLAGS have something such as -Iblah or -D__BREAKS__WITHOUT__THIS__, 
you're screwed. 
if CFLAGS are added onto at some point (CFLAGS = $CFLAGS -mnewflag), 
you're screwed.
It's not perfect, but it works for me in most cases.

Go ahead and flame, just thought I'd toss it here to make people's lives 
2% easier :).

-- 
Chris White <chriswhite@gentoo.org>
------------------------
Sound   | Video   | Security
Mozilla | Haskell | Lang-misc
ChrisWhite @ irc.freenode.net


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 256 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2004-11-22 18:32 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-11-20  6:14 [gentoo-dev] CUSTOM cflags replacement snippet Chris White
2004-11-20 11:28 ` Eldad Zack
2004-11-20 11:31   ` Eldad Zack
2004-11-20 11:49     ` [gentoo-dev] " Michael Sterrett -Mr. Bones.-
2004-11-20 15:18     ` [gentoo-dev] " Georgi Georgiev
2004-11-22  5:30       ` Aron Griffis
2004-11-22 18:27 ` Aron Griffis

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox