Debian Codegraph @

build/m4/aircrack_ng_compiler.m4

raw
1 dnl Aircrack-ng
2 dnl
3 dnl Copyright (C) 2017 Joseph Benden <[email protected]>
4 dnl
5 dnl Autotool support was written by: Joseph Benden <[email protected]>
6 dnl
7 dnl This program is free software; you can redistribute it and/or modify
8 dnl it under the terms of the GNU General Public License as published by
9 dnl the Free Software Foundation; either version 2 of the License, or
10 dnl (at your option) any later version.
11 dnl
12 dnl This program is distributed in the hope that it will be useful,
13 dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
14 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 dnl GNU General Public License for more details.
16 dnl
17 dnl You should have received a copy of the GNU General Public License
18 dnl along with this program; if not, write to the Free Software
19 dnl Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 dnl
21 dnl In addition, as a special exception, the copyright holders give
22 dnl permission to link the code of portions of this program with the
23 dnl OpenSSL library under certain conditions as described in each
24 dnl individual source file, and distribute linked combinations
25 dnl including the two.
26 dnl
27 dnl You must obey the GNU General Public License in all respects
28 dnl for all of the code used other than OpenSSL.
29 dnl
30 dnl If you modify file(s) with this exception, you may extend this
31 dnl exception to your dnl version of the file(s), but you are not obligated
32 dnl to do so.
33 dnl
34 dnl If you dnl do not wish to do so, delete this exception statement from your
35 dnl version.
36 dnl
37 dnl If you delete this exception statement from all source files in the
38 dnl program, then also delete it here.
39
40 AC_DEFUN([AIRCRACK_NG_COMPILER], [
41 AX_REQUIRE_DEFINED([AX_COMPILER_VENDOR])
42 AX_REQUIRE_DEFINED([AX_COMPILER_VERSION])
43 AX_REQUIRE_DEFINED([AX_COMPARE_VERSION])
44 AX_REQUIRE_DEFINED([AX_CHECK_COMPILE_FLAG])
45 AX_REQUIRE_DEFINED([AX_CFLAGS_WARN_ALL])
46 AX_REQUIRE_DEFINED([AX_CXXFLAGS_WARN_ALL])
47 AX_REQUIRE_DEFINED([AX_APPEND_FLAG])
48
49 AX_COMPILER_VENDOR
50 AX_COMPILER_VERSION
51
52 saved_cflags="$CFLAGS"
53 CFLAGS=""
54 AX_CFLAGS_WARN_ALL
55 AX_APPEND_FLAG($CFLAGS, [opt_cflags])
56 CFLAGS="$saved_cflags"
57
58 saved_cxxflags="$CXXFLAGS"
59 CXXFLAGS=""
60 AX_CXXFLAGS_WARN_ALL
61 AX_APPEND_FLAG($CXXFLAGS, [opt_cxxflags])
62 CXXFLAGS="$saved_cxxflags"
63
64 case "$ax_cv_c_compiler_vendor" in
65 clang)
66 AX_APPEND_FLAG(-Wno-unused-command-line-argument, [opt_cppflags])
67 AX_APPEND_FLAG(-Wno-unused-command-line-argument, [opt_cflags])
68 AX_APPEND_FLAG(-Wno-unused-command-line-argument, [opt_cxxflags])
69 AX_APPEND_FLAG(-Wno-unused-command-line-argument, [opt_ldflags])
70 ;;
71 esac
72
73 AC_ARG_WITH(lto,
74 [AS_HELP_STRING([--with-lto],
75 [enable link-time optimizations])])
76
77 AS_IF([test "x$with_lto" = "xyes"], [
78 AX_CHECK_COMPILE_FLAG([-flto], [
79 AX_APPEND_FLAG(-flto, [opt_[]_AC_LANG_ABBREV[]flags])
80 AX_APPEND_FLAG(-flto, [opt_ldflags])
81 ])
82 ])
83
84 AC_ARG_WITH(opt,
85 [AS_HELP_STRING([--without-opt],
86 [disable -O3 optimizations])])
87
88 AS_IF([test "x$enable_code_coverage" = "xno"], [
89 case $with_opt in
90 yes | "")
91 AX_CHECK_COMPILE_FLAG([-O3], [
92 AX_APPEND_FLAG(-O3, [opt_[]_AC_LANG_ABBREV[]flags])
93 ])
94 ;;
95 esac
96 ])
97
98 AC_LANG_CASE([C], [
99 saved_cflags="$CFLAGS"
100 AX_CHECK_COMPILE_FLAG([-std=gnu99], [
101 AX_APPEND_FLAG(-std=gnu99, [opt_[]_AC_LANG_ABBREV[]flags])
102 ])
103
104 AX_CHECK_COMPILE_FLAG([-fcommon], [
105 AX_APPEND_FLAG(-fcommon, [opt_[]_AC_LANG_ABBREV[]flags])
106 ])
107
108 case "$ax_cv_[]_AC_LANG_ABBREV[]_compiler_vendor" in
109 gnu|clang)
110 AX_CHECK_COMPILE_FLAG([-Wstrict-overflow=2], [
111 AX_APPEND_FLAG(-Wstrict-overflow=2, [opt_[]_AC_LANG_ABBREV[]flags])
112 ])
113 ;;
114 esac
115
116 case "$ax_cv_[]_AC_LANG_ABBREV[]_compiler_vendor" in
117 intel)
118 dnl warning 2218 is: result of call is not used
119 AX_APPEND_FLAG(-diag-disable 2218, [opt_[]_AC_LANG_ABBREV[]flags])
120 ;;
121 esac
122 ])
123
124 AX_CHECK_COMPILE_FLAG([-fvisibility=hidden], [
125 AX_APPEND_FLAG(-fvisibility=hidden, [opt_[]_AC_LANG_ABBREV[]flags])
126 ])
127
128 case "$ax_cv_[]_AC_LANG_ABBREV[]_compiler_vendor" in
129 gnu|clang|intel)
130 AX_COMPARE_VERSION([$ax_cv_[]_AC_LANG_ABBREV[]_compiler_version], [ge], [4.1], [gcc_over41=yes], [gcc_over41=x])
131 AX_COMPARE_VERSION([$ax_cv_[]_AC_LANG_ABBREV[]_compiler_version], [ge], [4.5], [gcc_over45=yes], [gcc_over45=x])
132 AX_COMPARE_VERSION([$ax_cv_[]_AC_LANG_ABBREV[]_compiler_version], [ge], [4.9], [gcc_over49=yes], [gcc_over49=x])
133 ;;
134 esac
135
136 AS_IF([test "x$enable_maintainer_mode" = "xyes"], [
137 AS_IF([test "x$gcc_over49" = "xyes"], [
138 AX_CHECK_COMPILE_FLAG([-pedantic], [
139 AX_APPEND_FLAG(-pedantic, [opt_[]_AC_LANG_ABBREV[]flags])
140
141 case "$ax_cv_c_compiler_vendor" in
142 clang)
143 AX_CHECK_COMPILE_FLAG([-Wno-newline-eof], [
144 AX_APPEND_FLAG(-Wno-newline-eof, [opt_[]_AC_LANG_ABBREV[]flags])
145 ])
146 AX_CHECK_COMPILE_FLAG([-Wno-language-extension-token], [
147 AX_APPEND_FLAG(-Wno-language-extension-token, [opt_[]_AC_LANG_ABBREV[]flags])
148 ])
149 AX_CHECK_COMPILE_FLAG([-Wno-gnu-statement-expression], [
150 AX_APPEND_FLAG(-Wno-gnu-statement-expression, [opt_[]_AC_LANG_ABBREV[]flags])
151 ])
152 ;;
153 esac
154 ])
155 ])
156
157 AX_CHECK_COMPILE_FLAG([-Wextra], [
158 AX_APPEND_FLAG(-Wextra, [opt_[]_AC_LANG_ABBREV[]flags])
159 ])
160
161 case "$ax_cv_[]_AC_LANG_ABBREV[]_compiler_vendor" in
162 intel)
163 AX_APPEND_FLAG(-diag-disable remark, [opt_[]_AC_LANG_ABBREV[]flags])
164 ;;
165 *)
166 AX_CHECK_COMPILE_FLAG([-Werror], [
167 AX_APPEND_FLAG(-Werror, [opt_[]_AC_LANG_ABBREV[]flags])
168 ])
169 ;;
170 esac
171
172 AC_LANG_CASE([C], [
173 case "$ax_cv_[]_AC_LANG_ABBREV[]_compiler_vendor" in
174 gnu|clang|intel)
175 AX_APPEND_FLAG(-Wstrict-prototypes, [opt_[]_AC_LANG_ABBREV[]flags])
176 ;;
177 esac
178 ])
179
180 AX_CHECK_COMPILE_FLAG([-Wpointer-arith], [
181 AX_APPEND_FLAG(-Wpointer-arith, [opt_[]_AC_LANG_ABBREV[]flags])
182 ])
183
184 case "$ax_cv_[]_AC_LANG_ABBREV[]_compiler_vendor" in
185 gnu|clang)
186 dnl BSD systems complain about CMocka using ,##__VA_ARGS__
187 dnl Suppress this warning
188 AX_CHECK_COMPILE_FLAG([-Werror -Wno-gnu-zero-variadic-macro-arguments], [
189 AX_APPEND_FLAG(-Wno-gnu-zero-variadic-macro-arguments, [opt_[]_AC_LANG_ABBREV[]flags])
190 ])
191 ;;
192 esac
193 ])
194 ])
195
196 AC_DEFUN([AIRCRACK_NG_COMPILER_C], [
197 AC_LANG_PUSH([C])
198 AIRCRACK_NG_COMPILER
199 AC_LANG_POP([C])
200 ])
201
202 AC_DEFUN([AIRCRACK_NG_COMPILER_CXX], [
203 AC_LANG_PUSH([C++])
204 AIRCRACK_NG_COMPILER
205 AC_LANG_POP([C++])
206 ])