1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
|
Index: b/configure.in
===================================================================
--- a/configure.in 2007-04-03 00:36:44.000000000 -0400
+++ b/configure.in 2007-04-26 02:16:37.000000000 -0400
@@ -235,78 +235,48 @@
#### gcc warning flags
-if test "x$GCC" = "xyes"; then
- changequote(,)dnl
- case " $CFLAGS " in
- *[\ \ ]-Wall[\ \ ]*) ;;
- *) CFLAGS="$CFLAGS -Wall" ;;
- esac
-
- case " $CFLAGS " in
- *[\ \ ]-Wchar-subscripts[\ \ ]*) ;;
- *) CFLAGS="$CFLAGS -Wchar-subscripts" ;;
- esac
+dnl Use as many warning flags as possible with gcc and compatible compilers
- case " $CFLAGS " in
- *[\ \ ]-Wmissing-declarations[\ \ ]*) ;;
- *) CFLAGS="$CFLAGS -Wmissing-declarations" ;;
- esac
+dnl If you change anything below in the variable, the cache is automatically
+dnl ignored and everything is rechecked. So just add a flag and that's it.
+dnl if you need to force a recheck, add a whitespace somewhere
+dnl Also take note of order of flags, you should have the big inclusive flags
+dnl first, and the negating flags last
- case " $CFLAGS " in
- *[\ \ ]-Wnested-externs[\ \ ]*) ;;
- *) CFLAGS="$CFLAGS -Wnested-externs" ;;
- esac
+MAYBE_WARN="-Wall -Wextra \
+-Wchar-subscripts -Wmissing-declarations -Wnested-externs \
+-Wpointer-arith -Wcast-align -Wsign-compare -Wbad-function-cast \
+-Waggregate-return -Wcast-align -Wcast-qual -Wshadow -Wredundant-decls"
- case " $CFLAGS " in
- *[\ \ ]-Wpointer-arith[\ \ ]*) ;;
- *) CFLAGS="$CFLAGS -Wpointer-arith" ;;
- esac
-
- case " $CFLAGS " in
- *[\ \ ]-Wcast-align[\ \ ]*) ;;
- *) CFLAGS="$CFLAGS -Wcast-align" ;;
- esac
+dnl invalidate cache if MAYBE_WARN has changed
+if test "x$hal_cv_warn_maybe" != "x$MAYBE_WARN"; then
+ unset hal_cv_warn_cflags
+fi
- case " $CFLAGS " in
- *[\ \ ]-Wsign-compare[\ \ ]*) ;;
- *) CFLAGS="$CFLAGS -Wsign-compare" ;;
- esac
+AC_CACHE_CHECK([for supported warning flags], hal_cv_warn_cflags, [
+ echo
- if test "x$enable_ansi" = "xyes"; then
- case " $CFLAGS " in
- *[\ \ ]-ansi[\ \ ]*) ;;
- *) CFLAGS="$CFLAGS -ansi" ;;
- esac
+ for W in $MAYBE_WARN; do
+ AC_CC_TRY_FLAG([$W], [CFLAGS="$CFLAGS $W"])
+ done
- case " $CFLAGS " in
- *[\ \ ]-D_POSIX_C_SOURCE*) ;;
- *) CFLAGS="$CFLAGS -D_POSIX_C_SOURCE=199309L" ;;
- esac
+ hal_cv_warn_cflags=$CFLAGS
+ hal_cv_warn_maybe=$MAYBE_WARN
- case " $CFLAGS " in
- *[\ \ ]-D_BSD_SOURCE[\ \ ]*) ;;
- *) CFLAGS="$CFLAGS -D_BSD_SOURCE" ;;
- esac
+ AC_MSG_CHECKING([which warning flags were supported])
+])
- case " $CFLAGS " in
- *[\ \ ]-pedantic[\ \ ]*) ;;
- *) CFLAGS="$CFLAGS -pedantic" ;;
- esac
+if test "x$GCC" = "xyes"; then
+ if test "x$enable_ansi" = "xyes"; then
+ AC_CC_TRY_FLAG([-ansi], [CFLAGS="$CFLAGS -ansi"])
+ AC_CC_TRY_FLAG([-pedanitc], [CFLAGS="$CFLAGS -pedantic"])
+ CFLAGS="$CFLAGS -D_POSIX_C_SOURCE=199309L -D_BSD_SOURCE"
fi
- if test x$enable_gcov = xyes; then
- case " $CFLAGS " in
- *[\ \ ]-fprofile-arcs[\ \ ]*) ;;
- *) CFLAGS="$CFLAGS -fprofile-arcs" ;;
- esac
- case " $CFLAGS " in
- *[\ \ ]-ftest-coverage[\ \ ]*) ;;
- *) CFLAGS="$CFLAGS -ftest-coverage" ;;
- esac
- ## remove optimization
- CFLAGS=`echo "$CFLAGS" | sed -e 's/-O[0-9]*//g'`
+ if test "x$enable_gcov" = "xyes"; then
+ AC_CC_TRY_FLAG([-fprofile-arcs], [CFLAGS="$CFLAGS -fprofile-arcs"])
+ AC_CC_TRY_FLAG([-ftest-coverage], [CFLAGS="$CFLAGS -ftest-coverage"])
fi
- changequote([,])dnl
else
if test x$enable_gcov = xyes; then
AC_MSG_ERROR([--enable-gcov can only be used with gcc])
Index: b/m4/try_flag.m4
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ b/m4/try_flag.m4 2007-04-26 02:15:05.000000000 -0400
@@ -0,0 +1,23 @@
+dnl Copied from Cairo configure.in
+dnl Tweaked for more general use by Doug Goldstein <cardoe@gentoo.org>
+dnl
+dnl check compiler flags
+dnl $1 - flag to check
+dnl $2 - when successful do this
+dnl $3 - when not successful, do this
+AC_DEFUN([AC_CC_TRY_FLAG], [
+ AC_MSG_CHECKING([whether $CC supports $1])
+
+ ac_save_CFLAGS="$CFLAGS"
+ CFLAGS="$CFLAGS $1"
+ AC_COMPILE_IFELSE([ ], [ac_cc_flag=yes], [ac_cc_flag=no])
+ CFLAGS="$ac_save_CFLAGS"
+
+ if test "x$ac_cc_flag" = "xyes"; then
+ ifelse([$2], , :, [$2])
+ else
+ ifelse([$3], , :, [$3])
+ fi
+
+ AC_MSG_RESULT([$ac_cc_flag])
+])
Index: b/Makefile.am
===================================================================
--- a/Makefile.am 2007-03-07 16:52:19.000000000 -0500
+++ b/Makefile.am 2007-04-26 02:15:42.000000000 -0400
@@ -3,6 +3,8 @@
SUBDIRS = libhal libhal-storage partutil hald hald-runner tools \
fdi doc po privileges
+ACLOCAL_AMFLAGS = -I m4
+
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = hal.pc hal-storage.pc
|