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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
|
# Public macros for the TeX Live (TL) tree.
# Copyright (C) 2009-2012 Peter Breitenlohner <tex-live@tug.org>
#
# This file is free software; the copyright holders
# give unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# KPSE_COMPILER_WARNINGS
# ----------------------
# Set up compiler warnings for C and C++.
# This macro determines and substitutes WARNING_CFLAGS for the C compiler
# and, if applicable, WARNING_CXXFLAGS for the C++ compiler. To activate
# them a Makefile.am must use them, e.g., in AM_CFLAGS or AM_CXXFLAGS.
AC_DEFUN([KPSE_COMPILER_WARNINGS],
[AC_REQUIRE([_KPSE_COMPILER_WARNINGS_OPTION])[]dnl
dnl arrange that AC_PROG_CC uses _KPSE_WARNING_CFLAGS etc.
AC_PROVIDE_IFELSE([AC_PROG_CC],
[_KPSE_WARNING_CFLAGS],
[m4_define([AC_PROG_CC],
m4_defn([AC_PROG_CC])[_KPSE_WARNING_CFLAGS
])])
AC_PROVIDE_IFELSE([AC_PROG_CXX],
[_KPSE_WARNING_CXXFLAGS],
[m4_define([AC_PROG_CXX],
m4_defn([AC_PROG_CXX])[_KPSE_WARNING_CXXFLAGS
])])
AC_PROVIDE_IFELSE([AC_PROG_OBJC],
[_KPSE_WARNING_OBJCFLAGS],
[m4_define([AC_PROG_OBJC],
m4_defn([AC_PROG_OBJC])[_KPSE_WARNING_OBJCFLAGS
])])
AC_PROVIDE_IFELSE([AC_PROG_OBJCXX],
[_KPSE_WARNING_OBJCXXFLAGS],
[m4_define([AC_PROG_OBJCXX],
m4_defn([AC_PROG_OBJCXX])[_KPSE_WARNING_OBJCXXFLAGS
])])
]) # KPSE_COMPILER_WARNINGS
# _KPSE_COMPILER_WARNINGS_OPTION
# ------------------------------
# Internal subroutine.
# Provide configure option `--enable-compiler-warnings=[no|min|yes|max|all]'
# to enable various degrees of compiler warnings.
AC_DEFUN([_KPSE_COMPILER_WARNINGS_OPTION],
[AC_ARG_ENABLE([compiler-warnings],
AS_HELP_STRING([--enable-compiler-warnings=@<:@no|min|yes|max|all@:>@],
[Turn on compiler warnings @<:@default: yes if maintainer-mode,
min otherwise@:>@]))[]dnl
AS_CASE([$enable_compiler_warnings],
[no | min | yes | max | all], [],
[AS_IF([test "x$enable_maintainer_mode" = xyes],
[enable_compiler_warnings=yes],
[enable_compiler_warnings=min])])
]) # _KPSE_COMPILER_WARNINGS_OPTION
_KPSE_WARNING_CFLAGS
# ------------------
# Internal subroutine.
# Determine and substitute WARNING_CFLAGS for C compiler.
AC_DEFUN([_KPSE_WARNING_CFLAGS],
[AC_REQUIRE([_KPSE_COMPILER_WARNINGS_OPTION])[]dnl
AC_REQUIRE([AC_PROG_CC])[]dnl
AC_CACHE_CHECK([what warning flags to pass to the C compiler],
[kpse_cv_warning_cflags],
[dnl
if test "x$GCC" = xyes; then
_KPSE_WARNING_GNU_CFLAGS([CC], [cflags])[]dnl
elif test "x$enable_compiler_warnings" = xno; then
kpse_cv_warning_cflags=
else
kpse_cv_warning_cflags= # FIXME: warning flags for non-GNU C compilers
fi])
WARNING_CFLAGS=$kpse_cv_warning_cflags
AC_SUBST([WARNING_CFLAGS])
m4_define([_KPSE_WARNING_CFLAGS], [])[]dnl
]) # _KPSE_WARNING_CFLAGS
# _KPSE_WARNING_CXXFLAGS
# ----------------------
# Internal subroutine.
# Determine and substitute WARNING_CXXFLAGS for C++ compiler.
m4_define([_KPSE_WARNING_CXXFLAGS],
[AC_CACHE_CHECK([what warning flags to pass to the C++ compiler],
[kpse_cv_warning_cxxflags],
[dnl
if test "x$GXX" = xyes; then
_KPSE_WARNING_GNU_CXXFLAGS([CXX], [cxxflags])[]dnl
elif test "x$enable_compiler_warnings" = xno; then
kpse_cv_warning_cxxflags=
else
kpse_cv_warning_cxxflags= # FIXME: warning flags for non-GNU C++ compilers
fi])
WARNING_CXXFLAGS=$kpse_cv_warning_cxxflags
AC_SUBST([WARNING_CXXFLAGS])
m4_define([_KPSE_WARNING_CXXFLAGS], [])[]dnl
]) # _KPSE_WARNING_CXXFLAGS
_KPSE_WARNING_OBJCFLAGS
# ---------------------
# Internal subroutine.
# Determine and substitute WARNING_OBJCFLAGS for Objective C compiler.
AC_DEFUN([_KPSE_WARNING_OBJCFLAGS],
[AC_REQUIRE([_KPSE_COMPILER_WARNINGS_OPTION])[]dnl
AC_REQUIRE([AC_PROG_OBJC])[]dnl
AC_CACHE_CHECK([what warning flags to pass to the Objective C compiler],
[kpse_cv_warning_objcflags],
[dnl
if test "x$GOBJC" = xyes; then
_KPSE_WARNING_GNU_CFLAGS([OBJC], [objcflags])[]dnl
elif test "x$enable_compiler_warnings" = xno; then
kpse_cv_warning_objcflags=
else
kpse_cv_warning_objcflags= # FIXME: warning flags for non-GNU Objective C compilers
fi])
WARNING_OBJCFLAGS=$kpse_cv_warning_objcflags
AC_SUBST([WARNING_OBJCFLAGS])
m4_define([_KPSE_WARNING_OBJCFLAGS], [])[]dnl
]) # _KPSE_WARNING_OBJCFLAGS
_KPSE_WARNING_OBJCXXFLAGS
# -----------------------
# Internal subroutine.
# Determine and substitute WARNING_OBJCXXFLAGS for Objective C++ compiler.
AC_DEFUN([_KPSE_WARNING_OBJCXXFLAGS],
[AC_REQUIRE([_KPSE_COMPILER_WARNINGS_OPTION])[]dnl
AC_REQUIRE([AC_PROG_OBJCXX])[]dnl
AC_CACHE_CHECK([what warning flags to pass to the Objective C++ compiler],
[kpse_cv_warning_objcxxflags],
[dnl
if test "x$GOBJCXX" = xyes; then
_KPSE_WARNING_GNU_CXXFLAGS([OBJCXX], [objcxxflags])[]dnl
elif test "x$enable_compiler_warnings" = xno; then
kpse_cv_warning_objcxxflags=
else
kpse_cv_warning_objcxxflags= # FIXME: warning flags for non-GNU Objective C++ compilers
fi])
WARNING_OBJCXXFLAGS=$kpse_cv_warning_objcxxflags
AC_SUBST([WARNING_OBJCXXFLAGS])
m4_define([_KPSE_WARNING_OBJCXXFLAGS], [])[]dnl
]) # _KPSE_WARNING_OBJCXXFLAGS
# _KPSE_WARNING_GNU_CFLAGS(COMPILER, TAG)
# ---------------------------------------
# Internal subroutine.
# Determine warning flags for GNU (Objective) C compiler.
m4_define([_KPSE_WARNING_GNU_CFLAGS],
[kpse_cv_warning_$2=
if test "x$enable_compiler_warnings" != xno; then
kpse_cv_warning_$2="-Wimplicit -Wreturn-type"
AS_CASE([`$[]$1 -dumpversion`],
[3.4.* | 4.*],
[kpse_cv_warning_$2="$kpse_cv_warning_$2 -Wdeclaration-after-statement"])
AS_CASE([`$[]$1 -dumpversion`],
[3.@<:@234@:>@.* | 4.*],
[kpse_cv_warning_$2="$kpse_cv_warning_$2 -Wno-unknown-pragmas"])
if test "x$enable_compiler_warnings" != xmin; then
kpse_cv_warning_$2="-Wall -Wunused $kpse_cv_warning_$2"
kpse_cv_warning_$2="$kpse_cv_warning_$2 -Wmissing-prototypes -Wmissing-declarations"
if test "x$enable_compiler_warnings" != xyes; then
kpse_cv_warning_$2="$kpse_cv_warning_$2 -Wparentheses -Wswitch -Wtrigraphs -Wpointer-arith"
kpse_cv_warning_$2="$kpse_cv_warning_$2 -Wcast-qual -Wcast-align -Wwrite-strings"
AS_CASE([`$[]$1 -dumpversion`],
[3.4.* | 4.*],
[kpse_cv_warning_$2="$kpse_cv_warning_$2 -Wold-style-definition"])
if test "x$enable_compiler_warnings" != xmax; then
kpse_cv_warning_$2="$kpse_cv_warning_$2 -Wshadow"
fi
fi
fi
fi
]) # _KPSE_WARNING_GNU_CFLAGS
# _KPSE_WARNING_GNU_CXXFLAGS(COMPILER, TAG)
# -----------------------------------------
# Internal subroutine.
# Determine warning flags for GNU (Objective) C++ compiler.
m4_define([_KPSE_WARNING_GNU_CXXFLAGS],
[kpse_cv_warning_$2=
kpse_warn_strings="-Wno-write-strings"
if test "x$enable_compiler_warnings" != xno; then
kpse_cv_warning_$2="-Wreturn-type"
AS_CASE([`$[]$1 -dumpversion`],
[3.* | 4.@<:@012345@:>@.*],
[kpse_cv_warning_$2="-Wimplicit $kpse_cv_warning_$2"])
AS_CASE([`$[]$1 -dumpversion`],
[3.@<:@234@:>@.* | 4.*],
[kpse_cv_warning_$2="$kpse_cv_warning_$2 -Wno-unknown-pragmas"])
if test "x$enable_compiler_warnings" != xmin; then
kpse_cv_warning_$2="-Wall -Wunused $kpse_cv_warning_$2"
if test "x$enable_compiler_warnings" != xyes; then
kpse_cv_warning_$2="$kpse_cv_warning_$2 -Wparentheses -Wswitch -Wtrigraphs -Wpointer-arith"
kpse_cv_warning_$2="$kpse_cv_warning_$2 -Wcast-qual -Wcast-align"
kpse_warn_strings="-Wwrite-strings"
if test "x$enable_compiler_warnings" != xmax; then
kpse_cv_warning_$2="$kpse_cv_warning_$2 -Wshadow"
fi
fi
fi
fi
kpse_cv_warning_$2="$kpse_cv_warning_$2 $kpse_warn_strings"
]) # _KPSE_WARNING_GNU_CXXFLAGS
|