1 |
All, |
2 |
|
3 |
I created this quick little function to recursively patch Makefiles |
4 |
with custom CFLAGS. |
5 |
|
6 |
custom_cflags() { |
7 |
for directories in * |
8 |
do |
9 |
if [ -d $directories -a -e $directories/Makefile ] |
10 |
then |
11 |
cd $directories |
12 |
for subdirectories in * |
13 |
do |
14 |
if [ -d $subdirectories -a -e $subdirectories/Makefile ] |
15 |
then |
16 |
custom_cflags |
17 |
fi |
18 |
done |
19 |
|
20 |
sed -i \ |
21 |
-e "s:^CFLAGS.*:CFLAGS = ${CFLAGS}:" Makefile \ |
22 |
-e "s:^CXXFLAGS.*:CXXFLAGS = ${CXXFLAGS}:" Makefile \ |
23 |
|| die "Could not patch $directories/Makefile for custom CFLAGS" |
24 |
|
25 |
cd .. |
26 |
fi |
27 |
done |
28 |
} |
29 |
|
30 |
Known issues: |
31 |
|
32 |
if CFLAGS have something such as -Iblah or -D__BREAKS__WITHOUT__THIS__, |
33 |
you're screwed. |
34 |
if CFLAGS are added onto at some point (CFLAGS = $CFLAGS -mnewflag), |
35 |
you're screwed. |
36 |
It's not perfect, but it works for me in most cases. |
37 |
|
38 |
Go ahead and flame, just thought I'd toss it here to make people's lives |
39 |
2% easier :). |
40 |
|
41 |
-- |
42 |
Chris White <chriswhite@g.o> |
43 |
------------------------ |
44 |
Sound | Video | Security |
45 |
Mozilla | Haskell | Lang-misc |
46 |
ChrisWhite @ irc.freenode.net |