blob: e39d978013c46f9f3ab18323f7ba7e6087abac8f [file] [log] [blame]
xf.li6c8fc1e2023-08-12 00:11:09 -07001#***************************************************************************
2# _ _ ____ _
3# Project ___| | | | _ \| |
4# / __| | | | |_) | |
5# | (__| |_| | _ <| |___
6# \___|\___/|_| \_\_____|
7#
8# Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al.
9#
10# This software is licensed as described in the file COPYING, which
11# you should have received as part of this distribution. The terms
12# are also available at https://curl.se/docs/copyright.html.
13#
14# You may opt to use, copy, modify, merge, publish, distribute and/or sell
15# copies of the Software, and permit persons to whom the Software is
16# furnished to do so, under the terms of the COPYING file.
17#
18# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19# KIND, either express or implied.
20#
21# SPDX-License-Identifier: curl
22#
23#***************************************************************************
24
25# File version for 'aclocal' use. Keep it a single number.
26# serial 67
27
28
29dnl CURL_CHECK_COMPILER
30dnl -------------------------------------------------
31dnl Verify if the C compiler being used is known.
32
33AC_DEFUN([CURL_CHECK_COMPILER], [
34 #
35 compiler_id="unknown"
36 compiler_num="0"
37 #
38 flags_dbg_yes="unknown"
39 flags_opt_all="unknown"
40 flags_opt_yes="unknown"
41 flags_opt_off="unknown"
42 #
43 flags_prefer_cppflags="no"
44 #
45 CURL_CHECK_COMPILER_DEC_C
46 CURL_CHECK_COMPILER_HPUX_C
47 CURL_CHECK_COMPILER_IBM_C
48 CURL_CHECK_COMPILER_INTEL_C
49 CURL_CHECK_COMPILER_CLANG
50 CURL_CHECK_COMPILER_GNU_C
51 CURL_CHECK_COMPILER_LCC
52 CURL_CHECK_COMPILER_SGI_MIPSPRO_C
53 CURL_CHECK_COMPILER_SGI_MIPS_C
54 CURL_CHECK_COMPILER_SUNPRO_C
55 CURL_CHECK_COMPILER_TINY_C
56 #
57 if test "$compiler_id" = "unknown"; then
58 cat <<_EOF 1>&2
59***
60*** Warning: This configure script does not have information about the
61*** compiler you are using, relative to the flags required to enable or
62*** disable generation of debug info, optimization options or warnings.
63***
64*** Whatever settings are present in CFLAGS will be used for this run.
65***
66*** If you wish to help the curl project to better support your compiler
67*** you can report this and the required info on the libcurl development
68*** mailing list: https://lists.haxx.selistinfo/curl-library/
69***
70_EOF
71 fi
72])
73
74
75dnl CURL_CHECK_COMPILER_CLANG
76dnl -------------------------------------------------
77dnl Verify if compiler being used is clang.
78
79AC_DEFUN([CURL_CHECK_COMPILER_CLANG], [
80 AC_BEFORE([$0],[CURL_CHECK_COMPILER_GNU_C])dnl
81 AC_MSG_CHECKING([if compiler is clang])
82 CURL_CHECK_DEF([__clang__], [], [silent])
83 if test "$curl_cv_have_def___clang__" = "yes"; then
84 AC_MSG_RESULT([yes])
85 AC_MSG_CHECKING([if compiler is xlclang])
86 CURL_CHECK_DEF([__ibmxl__], [], [silent])
87 if test "$curl_cv_have_def___ibmxl__" = "yes" ; then
88 dnl IBM's almost-compatible clang version
89 AC_MSG_RESULT([yes])
90 compiler_id="XLCLANG"
91 else
92 AC_MSG_RESULT([no])
93 compiler_id="CLANG"
94 fi
95 fullclangver=`$CC -v 2>&1 | grep version`
96 clangver=`echo $fullclangver | grep "based on LLVM " | "$SED" 's/.*(based on LLVM \(@<:@0-9@:>@*\.@<:@0-9@:>@*\).*)/\1/'`
97 if test -z "$clangver"; then
98 if echo $fullclangver | grep "Apple LLVM version " >/dev/null; then
99 dnl Starting with XCode 7 / clang 3.7, Apple clang won't tell its upstream version
100 clangver="3.7"
101 else
102 clangver=`echo $fullclangver | "$SED" 's/.*version \(@<:@0-9@:>@*\.@<:@0-9@:>@*\).*/\1/'`
103 fi
104 fi
105 clangvhi=`echo $clangver | cut -d . -f1`
106 clangvlo=`echo $clangver | cut -d . -f2`
107 compiler_num=`(expr $clangvhi "*" 100 + $clangvlo) 2>/dev/null`
108 flags_dbg_yes="-g"
109 flags_opt_all="-O -O0 -O1 -O2 -Os -O3 -O4"
110 flags_opt_yes="-O2"
111 flags_opt_off="-O0"
112 else
113 AC_MSG_RESULT([no])
114 fi
115])
116
117
118dnl CURL_CHECK_COMPILER_DEC_C
119dnl -------------------------------------------------
120dnl Verify if compiler being used is DEC C.
121
122AC_DEFUN([CURL_CHECK_COMPILER_DEC_C], [
123 AC_MSG_CHECKING([if compiler is DEC/Compaq/HP C])
124 CURL_CHECK_DEF([__DECC], [], [silent])
125 CURL_CHECK_DEF([__DECC_VER], [], [silent])
126 if test "$curl_cv_have_def___DECC" = "yes" &&
127 test "$curl_cv_have_def___DECC_VER" = "yes"; then
128 AC_MSG_RESULT([yes])
129 compiler_id="DEC_C"
130 flags_dbg_yes="-g2"
131 flags_opt_all="-O -O0 -O1 -O2 -O3 -O4"
132 flags_opt_yes="-O1"
133 flags_opt_off="-O0"
134 else
135 AC_MSG_RESULT([no])
136 fi
137])
138
139
140dnl CURL_CHECK_COMPILER_GNU_C
141dnl -------------------------------------------------
142dnl Verify if compiler being used is GNU C
143dnl
144dnl $compiler_num will be set to MAJOR * 100 + MINOR for gcc less than version
145dnl 7 and just $MAJOR * 100 for gcc version 7 and later.
146dnl
147dnl Examples:
148dnl Version 1.2.3 => 102
149dnl Version 2.95 => 295
150dnl Version 4.7 => 407
151dnl Version 9.2.1 => 900
152dnl
153AC_DEFUN([CURL_CHECK_COMPILER_GNU_C], [
154 AC_REQUIRE([CURL_CHECK_COMPILER_INTEL_C])dnl
155 AC_REQUIRE([CURL_CHECK_COMPILER_CLANG])dnl
156 AC_MSG_CHECKING([if compiler is GNU C])
157 CURL_CHECK_DEF([__GNUC__], [], [silent])
158 if test "$curl_cv_have_def___GNUC__" = "yes" &&
159 test "$compiler_id" = "unknown"; then
160 AC_MSG_RESULT([yes])
161 compiler_id="GNU_C"
162 gccver=`$CC -dumpversion`
163 gccvhi=`echo $gccver | cut -d . -f1`
164 gccvlo=`echo $gccver | cut -d . -f2`
165 compiler_num=`(expr $gccvhi "*" 100 + $gccvlo) 2>/dev/null`
166 flags_dbg_yes="-g"
167 flags_opt_all="-O -O0 -O1 -O2 -O3 -Os -Og -Ofast"
168 flags_opt_yes="-O2"
169 flags_opt_off="-O0"
170 CURL_CHECK_DEF([_WIN32], [], [silent])
171 else
172 AC_MSG_RESULT([no])
173 fi
174])
175
176
177dnl CURL_CHECK_COMPILER_HPUX_C
178dnl -------------------------------------------------
179dnl Verify if compiler being used is HP-UX C.
180
181AC_DEFUN([CURL_CHECK_COMPILER_HPUX_C], [
182 AC_MSG_CHECKING([if compiler is HP-UX C])
183 CURL_CHECK_DEF([__HP_cc], [], [silent])
184 if test "$curl_cv_have_def___HP_cc" = "yes"; then
185 AC_MSG_RESULT([yes])
186 compiler_id="HP_UX_C"
187 flags_dbg_yes="-g"
188 flags_opt_all="-O +O0 +O1 +O2 +O3 +O4"
189 flags_opt_yes="+O2"
190 flags_opt_off="+O0"
191 else
192 AC_MSG_RESULT([no])
193 fi
194])
195
196
197dnl CURL_CHECK_COMPILER_IBM_C
198dnl -------------------------------------------------
199dnl Verify if compiler being used is IBM C.
200
201AC_DEFUN([CURL_CHECK_COMPILER_IBM_C], [
202 AC_MSG_CHECKING([if compiler is IBM C])
203 CURL_CHECK_DEF([__IBMC__], [], [silent])
204 if test "$curl_cv_have_def___IBMC__" = "yes"; then
205 AC_MSG_RESULT([yes])
206 compiler_id="IBM_C"
207 flags_dbg_yes="-g"
208 flags_opt_all="-O -O0 -O1 -O2 -O3 -O4 -O5"
209 flags_opt_all="$flags_opt_all -qnooptimize"
210 flags_opt_all="$flags_opt_all -qoptimize=0"
211 flags_opt_all="$flags_opt_all -qoptimize=1"
212 flags_opt_all="$flags_opt_all -qoptimize=2"
213 flags_opt_all="$flags_opt_all -qoptimize=3"
214 flags_opt_all="$flags_opt_all -qoptimize=4"
215 flags_opt_all="$flags_opt_all -qoptimize=5"
216 flags_opt_yes="-O2"
217 flags_opt_off="-qnooptimize"
218 flags_prefer_cppflags="yes"
219 else
220 AC_MSG_RESULT([no])
221 fi
222])
223
224
225dnl CURL_CHECK_COMPILER_INTEL_C
226dnl -------------------------------------------------
227dnl Verify if compiler being used is Intel C.
228
229AC_DEFUN([CURL_CHECK_COMPILER_INTEL_C], [
230 AC_BEFORE([$0],[CURL_CHECK_COMPILER_GNU_C])dnl
231 AC_MSG_CHECKING([if compiler is Intel C])
232 CURL_CHECK_DEF([__INTEL_COMPILER], [], [silent])
233 if test "$curl_cv_have_def___INTEL_COMPILER" = "yes"; then
234 AC_MSG_RESULT([yes])
235 compiler_num="$curl_cv_def___INTEL_COMPILER"
236 CURL_CHECK_DEF([__unix__], [], [silent])
237 if test "$curl_cv_have_def___unix__" = "yes"; then
238 compiler_id="INTEL_UNIX_C"
239 flags_dbg_yes="-g"
240 flags_opt_all="-O -O0 -O1 -O2 -O3 -Os"
241 flags_opt_yes="-O2"
242 flags_opt_off="-O0"
243 else
244 compiler_id="INTEL_WINDOWS_C"
245 flags_dbg_yes="/Zi /Oy-"
246 flags_opt_all="/O /O0 /O1 /O2 /O3 /Od /Og /Og- /Oi /Oi-"
247 flags_opt_yes="/O2"
248 flags_opt_off="/Od"
249 fi
250 else
251 AC_MSG_RESULT([no])
252 fi
253])
254
255
256dnl CURL_CHECK_COMPILER_LCC
257dnl -------------------------------------------------
258dnl Verify if compiler being used is LCC.
259
260AC_DEFUN([CURL_CHECK_COMPILER_LCC], [
261 AC_MSG_CHECKING([if compiler is LCC])
262 CURL_CHECK_DEF([__LCC__], [], [silent])
263 if test "$curl_cv_have_def___LCC__" = "yes"; then
264 AC_MSG_RESULT([yes])
265 compiler_id="LCC"
266 flags_dbg_yes="-g"
267 flags_opt_all=""
268 flags_opt_yes=""
269 flags_opt_off=""
270 else
271 AC_MSG_RESULT([no])
272 fi
273])
274
275
276dnl CURL_CHECK_COMPILER_SGI_MIPS_C
277dnl -------------------------------------------------
278dnl Verify if compiler being used is SGI MIPS C.
279
280AC_DEFUN([CURL_CHECK_COMPILER_SGI_MIPS_C], [
281 AC_REQUIRE([CURL_CHECK_COMPILER_SGI_MIPSPRO_C])dnl
282 AC_MSG_CHECKING([if compiler is SGI MIPS C])
283 CURL_CHECK_DEF([__GNUC__], [], [silent])
284 CURL_CHECK_DEF([__sgi], [], [silent])
285 if test "$curl_cv_have_def___GNUC__" = "no" &&
286 test "$curl_cv_have_def___sgi" = "yes" &&
287 test "$compiler_id" = "unknown"; then
288 AC_MSG_RESULT([yes])
289 compiler_id="SGI_MIPS_C"
290 flags_dbg_yes="-g"
291 flags_opt_all="-O -O0 -O1 -O2 -O3 -Ofast"
292 flags_opt_yes="-O2"
293 flags_opt_off="-O0"
294 else
295 AC_MSG_RESULT([no])
296 fi
297])
298
299
300dnl CURL_CHECK_COMPILER_SGI_MIPSPRO_C
301dnl -------------------------------------------------
302dnl Verify if compiler being used is SGI MIPSpro C.
303
304AC_DEFUN([CURL_CHECK_COMPILER_SGI_MIPSPRO_C], [
305 AC_BEFORE([$0],[CURL_CHECK_COMPILER_SGI_MIPS_C])dnl
306 AC_MSG_CHECKING([if compiler is SGI MIPSpro C])
307 CURL_CHECK_DEF([__GNUC__], [], [silent])
308 CURL_CHECK_DEF([_COMPILER_VERSION], [], [silent])
309 CURL_CHECK_DEF([_SGI_COMPILER_VERSION], [], [silent])
310 if test "$curl_cv_have_def___GNUC__" = "no" &&
311 (test "$curl_cv_have_def__SGI_COMPILER_VERSION" = "yes" ||
312 test "$curl_cv_have_def__COMPILER_VERSION" = "yes"); then
313 AC_MSG_RESULT([yes])
314 compiler_id="SGI_MIPSPRO_C"
315 flags_dbg_yes="-g"
316 flags_opt_all="-O -O0 -O1 -O2 -O3 -Ofast"
317 flags_opt_yes="-O2"
318 flags_opt_off="-O0"
319 else
320 AC_MSG_RESULT([no])
321 fi
322])
323
324
325dnl CURL_CHECK_COMPILER_SUNPRO_C
326dnl -------------------------------------------------
327dnl Verify if compiler being used is SunPro C.
328
329AC_DEFUN([CURL_CHECK_COMPILER_SUNPRO_C], [
330 AC_MSG_CHECKING([if compiler is SunPro C])
331 CURL_CHECK_DEF([__SUNPRO_C], [], [silent])
332 if test "$curl_cv_have_def___SUNPRO_C" = "yes"; then
333 AC_MSG_RESULT([yes])
334 compiler_id="SUNPRO_C"
335 flags_dbg_yes="-g"
336 flags_opt_all="-O -xO -xO1 -xO2 -xO3 -xO4 -xO5"
337 flags_opt_yes="-xO2"
338 flags_opt_off=""
339 else
340 AC_MSG_RESULT([no])
341 fi
342])
343
344
345dnl CURL_CHECK_COMPILER_TINY_C
346dnl -------------------------------------------------
347dnl Verify if compiler being used is Tiny C.
348
349AC_DEFUN([CURL_CHECK_COMPILER_TINY_C], [
350 AC_MSG_CHECKING([if compiler is Tiny C])
351 CURL_CHECK_DEF([__TINYC__], [], [silent])
352 if test "$curl_cv_have_def___TINYC__" = "yes"; then
353 AC_MSG_RESULT([yes])
354 compiler_id="TINY_C"
355 flags_dbg_yes="-g"
356 flags_opt_all=""
357 flags_opt_yes=""
358 flags_opt_off=""
359 else
360 AC_MSG_RESULT([no])
361 fi
362])
363
364dnl CURL_CONVERT_INCLUDE_TO_ISYSTEM
365dnl -------------------------------------------------
366dnl Changes standard include paths present in CFLAGS
367dnl and CPPFLAGS into isystem include paths. This is
368dnl done to prevent GNUC from generating warnings on
369dnl headers from these locations, although on ancient
370dnl GNUC versions these warnings are not silenced.
371
372AC_DEFUN([CURL_CONVERT_INCLUDE_TO_ISYSTEM], [
373 AC_REQUIRE([CURL_SHFUNC_SQUEEZE])dnl
374 AC_REQUIRE([CURL_CHECK_COMPILER])dnl
375 AC_MSG_CHECKING([convert -I options to -isystem])
376 if test "$compiler_id" = "GNU_C" ||
377 test "$compiler_id" = "CLANG"; then
378 AC_MSG_RESULT([yes])
379 tmp_has_include="no"
380 tmp_chg_FLAGS="$CFLAGS"
381 for word1 in $tmp_chg_FLAGS; do
382 case "$word1" in
383 -I*)
384 tmp_has_include="yes"
385 ;;
386 esac
387 done
388 if test "$tmp_has_include" = "yes"; then
389 tmp_chg_FLAGS=`echo "$tmp_chg_FLAGS" | "$SED" 's/^-I/ -isystem /g'`
390 tmp_chg_FLAGS=`echo "$tmp_chg_FLAGS" | "$SED" 's/ -I/ -isystem /g'`
391 CFLAGS="$tmp_chg_FLAGS"
392 squeeze CFLAGS
393 fi
394 tmp_has_include="no"
395 tmp_chg_FLAGS="$CPPFLAGS"
396 for word1 in $tmp_chg_FLAGS; do
397 case "$word1" in
398 -I*)
399 tmp_has_include="yes"
400 ;;
401 esac
402 done
403 if test "$tmp_has_include" = "yes"; then
404 tmp_chg_FLAGS=`echo "$tmp_chg_FLAGS" | "$SED" 's/^-I/ -isystem /g'`
405 tmp_chg_FLAGS=`echo "$tmp_chg_FLAGS" | "$SED" 's/ -I/ -isystem /g'`
406 CPPFLAGS="$tmp_chg_FLAGS"
407 squeeze CPPFLAGS
408 fi
409 else
410 AC_MSG_RESULT([no])
411 fi
412])
413
414
415dnl CURL_COMPILER_WORKS_IFELSE ([ACTION-IF-WORKS], [ACTION-IF-NOT-WORKS])
416dnl -------------------------------------------------
417dnl Verify if the C compiler seems to work with the
418dnl settings that are 'active' at the time the test
419dnl is performed.
420
421AC_DEFUN([CURL_COMPILER_WORKS_IFELSE], [
422 dnl compilation capability verification
423 tmp_compiler_works="unknown"
424 AC_COMPILE_IFELSE([
425 AC_LANG_PROGRAM([[
426 ]],[[
427 int i = 1;
428 return i;
429 ]])
430 ],[
431 tmp_compiler_works="yes"
432 ],[
433 tmp_compiler_works="no"
434 echo " " >&6
435 sed 's/^/cc-fail: /' conftest.err >&6
436 echo " " >&6
437 ])
438 dnl linking capability verification
439 if test "$tmp_compiler_works" = "yes"; then
440 AC_LINK_IFELSE([
441 AC_LANG_PROGRAM([[
442 ]],[[
443 int i = 1;
444 return i;
445 ]])
446 ],[
447 tmp_compiler_works="yes"
448 ],[
449 tmp_compiler_works="no"
450 echo " " >&6
451 sed 's/^/link-fail: /' conftest.err >&6
452 echo " " >&6
453 ])
454 fi
455 dnl only do runtime verification when not cross-compiling
456 if test "x$cross_compiling" != "xyes" &&
457 test "$tmp_compiler_works" = "yes"; then
458 CURL_RUN_IFELSE([
459 AC_LANG_PROGRAM([[
460# ifdef __STDC__
461# include <stdlib.h>
462# endif
463 ]],[[
464 int i = 0;
465 exit(i);
466 ]])
467 ],[
468 tmp_compiler_works="yes"
469 ],[
470 tmp_compiler_works="no"
471 echo " " >&6
472 echo "run-fail: test program exited with status $ac_status" >&6
473 echo " " >&6
474 ])
475 fi
476 dnl branch upon test result
477 if test "$tmp_compiler_works" = "yes"; then
478 ifelse($1,,:,[$1])
479 ifelse($2,,,[else
480 $2])
481 fi
482])
483
484
485dnl CURL_SET_COMPILER_BASIC_OPTS
486dnl -------------------------------------------------
487dnl Sets compiler specific options/flags which do not
488dnl depend on configure's debug, optimize or warnings
489dnl options.
490
491AC_DEFUN([CURL_SET_COMPILER_BASIC_OPTS], [
492 AC_REQUIRE([CURL_CHECK_COMPILER])dnl
493 AC_REQUIRE([CURL_SHFUNC_SQUEEZE])dnl
494 #
495 if test "$compiler_id" != "unknown"; then
496 #
497 tmp_save_CPPFLAGS="$CPPFLAGS"
498 tmp_save_CFLAGS="$CFLAGS"
499 tmp_CPPFLAGS=""
500 tmp_CFLAGS=""
501 #
502 case "$compiler_id" in
503 #
504 CLANG)
505 #
506 dnl Disable warnings for unused arguments, otherwise clang will
507 dnl warn about compile-time arguments used during link-time, like
508 dnl -O and -g and -pedantic.
509 tmp_CFLAGS="$tmp_CFLAGS -Qunused-arguments"
510 dnl Disable pointer to bool conversion warnings since they cause
511 dnl lib/securetransp.c cause several warnings for checks we want.
512 tmp_CFLAGS="$tmp_CFLAGS -Wno-pointer-bool-conversion"
513 ;;
514 #
515 DEC_C)
516 #
517 dnl Select strict ANSI C compiler mode
518 tmp_CFLAGS="$tmp_CFLAGS -std1"
519 dnl Turn off optimizer ANSI C aliasing rules
520 tmp_CFLAGS="$tmp_CFLAGS -noansi_alias"
521 dnl Generate warnings for missing function prototypes
522 tmp_CFLAGS="$tmp_CFLAGS -warnprotos"
523 dnl Change some warnings into fatal errors
524 tmp_CFLAGS="$tmp_CFLAGS -msg_fatal toofewargs,toomanyargs"
525 ;;
526 #
527 GNU_C)
528 #
529 dnl turn implicit-function-declaration warning into error,
530 dnl at least gcc 2.95 and later support this
531 if test "$compiler_num" -ge "295"; then
532 tmp_CFLAGS="$tmp_CFLAGS -Werror-implicit-function-declaration"
533 fi
534 ;;
535 #
536 HP_UX_C)
537 #
538 dnl Disallow run-time dereferencing of null pointers
539 tmp_CFLAGS="$tmp_CFLAGS -z"
540 dnl Disable some remarks
541 dnl #4227: padding struct with n bytes to align member
542 dnl #4255: padding size of struct with n bytes to alignment boundary
543 tmp_CFLAGS="$tmp_CFLAGS +W 4227,4255"
544 ;;
545 #
546 IBM_C)
547 #
548 dnl Ensure that compiler optimizations are always thread-safe.
549 tmp_CPPFLAGS="$tmp_CPPFLAGS -qthreaded"
550 dnl Disable type based strict aliasing optimizations, using worst
551 dnl case aliasing assumptions when compiling. Type based aliasing
552 dnl would restrict the lvalues that could be safely used to access
553 dnl a data object.
554 tmp_CPPFLAGS="$tmp_CPPFLAGS -qnoansialias"
555 dnl Force compiler to stop after the compilation phase, without
556 dnl generating an object code file when compilation has errors.
557 tmp_CPPFLAGS="$tmp_CPPFLAGS -qhalt=e"
558 ;;
559 #
560 INTEL_UNIX_C)
561 #
562 dnl On unix this compiler uses gcc's header files, so
563 dnl we select ANSI C89 dialect plus GNU extensions.
564 tmp_CFLAGS="$tmp_CFLAGS -std=gnu89"
565 dnl Change some warnings into errors
566 dnl #140: too many arguments in function call
567 dnl #147: declaration is incompatible with 'previous one'
568 dnl #165: too few arguments in function call
569 dnl #266: function declared implicitly
570 tmp_CPPFLAGS="$tmp_CPPFLAGS -diag-error 140,147,165,266"
571 dnl Disable some remarks
572 dnl #279: controlling expression is constant
573 dnl #981: operands are evaluated in unspecified order
574 dnl #1025: zero extending result of unary operation
575 dnl #1469: "cc" clobber ignored
576 dnl #2259: non-pointer conversion from X to Y may lose significant bits
577 tmp_CPPFLAGS="$tmp_CPPFLAGS -diag-disable 279,981,1025,1469,2259"
578 ;;
579 #
580 INTEL_WINDOWS_C)
581 #
582 dnl Placeholder
583 tmp_CFLAGS="$tmp_CFLAGS"
584 ;;
585 #
586 LCC)
587 #
588 dnl Disallow run-time dereferencing of null pointers
589 tmp_CFLAGS="$tmp_CFLAGS -n"
590 ;;
591 #
592 SGI_MIPS_C)
593 #
594 dnl Placeholder
595 tmp_CFLAGS="$tmp_CFLAGS"
596 ;;
597 #
598 SGI_MIPSPRO_C)
599 #
600 dnl Placeholder
601 tmp_CFLAGS="$tmp_CFLAGS"
602 ;;
603 #
604 SUNPRO_C)
605 #
606 dnl Placeholder
607 tmp_CFLAGS="$tmp_CFLAGS"
608 ;;
609 #
610 TINY_C)
611 #
612 dnl Placeholder
613 tmp_CFLAGS="$tmp_CFLAGS"
614 ;;
615 #
616 esac
617 #
618 squeeze tmp_CPPFLAGS
619 squeeze tmp_CFLAGS
620 #
621 if test ! -z "$tmp_CFLAGS" || test ! -z "$tmp_CPPFLAGS"; then
622 AC_MSG_CHECKING([if compiler accepts some basic options])
623 CPPFLAGS="$tmp_save_CPPFLAGS $tmp_CPPFLAGS"
624 CFLAGS="$tmp_save_CFLAGS $tmp_CFLAGS"
625 squeeze CPPFLAGS
626 squeeze CFLAGS
627 CURL_COMPILER_WORKS_IFELSE([
628 AC_MSG_RESULT([yes])
629 AC_MSG_NOTICE([compiler options added: $tmp_CFLAGS $tmp_CPPFLAGS])
630 ],[
631 AC_MSG_RESULT([no])
632 AC_MSG_WARN([compiler options rejected: $tmp_CFLAGS $tmp_CPPFLAGS])
633 dnl restore initial settings
634 CPPFLAGS="$tmp_save_CPPFLAGS"
635 CFLAGS="$tmp_save_CFLAGS"
636 ])
637 fi
638 #
639 fi
640])
641
642
643dnl CURL_SET_COMPILER_DEBUG_OPTS
644dnl -------------------------------------------------
645dnl Sets compiler specific options/flags which depend
646dnl on configure's debug option.
647
648AC_DEFUN([CURL_SET_COMPILER_DEBUG_OPTS], [
649 AC_REQUIRE([CURL_CHECK_OPTION_DEBUG])dnl
650 AC_REQUIRE([CURL_CHECK_COMPILER])dnl
651 AC_REQUIRE([CURL_SHFUNC_SQUEEZE])dnl
652 #
653 if test "$compiler_id" != "unknown"; then
654 #
655 tmp_save_CFLAGS="$CFLAGS"
656 tmp_save_CPPFLAGS="$CPPFLAGS"
657 #
658 tmp_options=""
659 tmp_CFLAGS="$CFLAGS"
660 tmp_CPPFLAGS="$CPPFLAGS"
661 #
662 if test "$want_debug" = "yes"; then
663 AC_MSG_CHECKING([if compiler accepts debug enabling options])
664 tmp_options="$flags_dbg_yes"
665 fi
666 #
667 if test "$flags_prefer_cppflags" = "yes"; then
668 CPPFLAGS="$tmp_CPPFLAGS $tmp_options"
669 CFLAGS="$tmp_CFLAGS"
670 else
671 CPPFLAGS="$tmp_CPPFLAGS"
672 CFLAGS="$tmp_CFLAGS $tmp_options"
673 fi
674 squeeze CPPFLAGS
675 squeeze CFLAGS
676 fi
677])
678
679
680dnl CURL_SET_COMPILER_OPTIMIZE_OPTS
681dnl -------------------------------------------------
682dnl Sets compiler specific options/flags which depend
683dnl on configure's optimize option.
684
685AC_DEFUN([CURL_SET_COMPILER_OPTIMIZE_OPTS], [
686 AC_REQUIRE([CURL_CHECK_OPTION_OPTIMIZE])dnl
687 AC_REQUIRE([CURL_CHECK_COMPILER])dnl
688 AC_REQUIRE([CURL_SHFUNC_SQUEEZE])dnl
689 #
690 if test "$compiler_id" != "unknown"; then
691 #
692 tmp_save_CFLAGS="$CFLAGS"
693 tmp_save_CPPFLAGS="$CPPFLAGS"
694 #
695 tmp_options=""
696 tmp_CFLAGS="$CFLAGS"
697 tmp_CPPFLAGS="$CPPFLAGS"
698 honor_optimize_option="yes"
699 #
700 dnl If optimization request setting has not been explicitly specified,
701 dnl it has been derived from the debug setting and initially assumed.
702 dnl This initially assumed optimizer setting will finally be ignored
703 dnl if CFLAGS or CPPFLAGS already hold optimizer flags. This implies
704 dnl that an initially assumed optimizer setting might not be honored.
705 #
706 if test "$want_optimize" = "assume_no" ||
707 test "$want_optimize" = "assume_yes"; then
708 AC_MSG_CHECKING([if compiler optimizer assumed setting might be used])
709 CURL_VAR_MATCH_IFELSE([tmp_CFLAGS],[$flags_opt_all],[
710 honor_optimize_option="no"
711 ])
712 CURL_VAR_MATCH_IFELSE([tmp_CPPFLAGS],[$flags_opt_all],[
713 honor_optimize_option="no"
714 ])
715 AC_MSG_RESULT([$honor_optimize_option])
716 if test "$honor_optimize_option" = "yes"; then
717 if test "$want_optimize" = "assume_yes"; then
718 want_optimize="yes"
719 fi
720 if test "$want_optimize" = "assume_no"; then
721 want_optimize="no"
722 fi
723 fi
724 fi
725 #
726 if test "$honor_optimize_option" = "yes"; then
727 CURL_VAR_STRIP([tmp_CFLAGS],[$flags_opt_all])
728 CURL_VAR_STRIP([tmp_CPPFLAGS],[$flags_opt_all])
729 if test "$want_optimize" = "yes"; then
730 AC_MSG_CHECKING([if compiler accepts optimizer enabling options])
731 tmp_options="$flags_opt_yes"
732 fi
733 if test "$want_optimize" = "no"; then
734 AC_MSG_CHECKING([if compiler accepts optimizer disabling options])
735 tmp_options="$flags_opt_off"
736 fi
737 if test "$flags_prefer_cppflags" = "yes"; then
738 CPPFLAGS="$tmp_CPPFLAGS $tmp_options"
739 CFLAGS="$tmp_CFLAGS"
740 else
741 CPPFLAGS="$tmp_CPPFLAGS"
742 CFLAGS="$tmp_CFLAGS $tmp_options"
743 fi
744 squeeze CPPFLAGS
745 squeeze CFLAGS
746 CURL_COMPILER_WORKS_IFELSE([
747 AC_MSG_RESULT([yes])
748 AC_MSG_NOTICE([compiler options added: $tmp_options])
749 ],[
750 AC_MSG_RESULT([no])
751 AC_MSG_WARN([compiler options rejected: $tmp_options])
752 dnl restore initial settings
753 CPPFLAGS="$tmp_save_CPPFLAGS"
754 CFLAGS="$tmp_save_CFLAGS"
755 ])
756 fi
757 #
758 fi
759])
760
761
762dnl CURL_SET_COMPILER_WARNING_OPTS
763dnl -------------------------------------------------
764dnl Sets compiler options/flags which depend on
765dnl configure's warnings given option.
766
767AC_DEFUN([CURL_SET_COMPILER_WARNING_OPTS], [
768 AC_REQUIRE([CURL_CHECK_OPTION_WARNINGS])dnl
769 AC_REQUIRE([CURL_CHECK_COMPILER])dnl
770 AC_REQUIRE([CURL_SHFUNC_SQUEEZE])dnl
771 #
772 if test "$compiler_id" != "unknown"; then
773 #
774 tmp_save_CPPFLAGS="$CPPFLAGS"
775 tmp_save_CFLAGS="$CFLAGS"
776 tmp_CPPFLAGS=""
777 tmp_CFLAGS=""
778 #
779 case "$compiler_id" in
780 #
781 CLANG)
782 #
783 if test "$want_warnings" = "yes"; then
784 tmp_CFLAGS="$tmp_CFLAGS -pedantic"
785 CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [all extra])
786 CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [pointer-arith write-strings])
787 CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [shadow])
788 CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [inline nested-externs])
789 CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [missing-declarations])
790 CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [missing-prototypes])
791 tmp_CFLAGS="$tmp_CFLAGS -Wno-long-long"
792 CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [float-equal])
793 CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [no-multichar sign-compare])
794 CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [undef])
795 tmp_CFLAGS="$tmp_CFLAGS -Wno-format-nonliteral"
796 CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [endif-labels strict-prototypes])
797 CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [declaration-after-statement])
798 CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [cast-align])
799 tmp_CFLAGS="$tmp_CFLAGS -Wno-system-headers"
800 CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [shorten-64-to-32])
801 #
802 dnl Only clang 1.1 or later
803 if test "$compiler_num" -ge "101"; then
804 CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [unused])
805 fi
806 #
807 dnl Only clang 2.8 or later
808 if test "$compiler_num" -ge "208"; then
809 CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [vla])
810 fi
811 #
812 dnl Only clang 2.9 or later
813 if test "$compiler_num" -ge "209"; then
814 CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [shift-sign-overflow])
815 fi
816 #
817 dnl Only clang 3.2 or later
818 if test "$compiler_num" -ge "302"; then
819 case $host_os in
820 cygwin* | mingw*)
821 dnl skip missing-variable-declarations warnings for cygwin and
822 dnl mingw because the libtool wrapper executable causes them
823 ;;
824 *)
825 CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [missing-variable-declarations])
826 ;;
827 esac
828 fi
829 #
830 dnl Only clang 3.6 or later
831 if test "$compiler_num" -ge "306"; then
832 CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [double-promotion])
833 fi
834 #
835 dnl Only clang 3.9 or later
836 if test "$compiler_num" -ge "309"; then
837 CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [comma])
838 # avoid the varargs warning, fixed in 4.0
839 # https://bugs.llvm.org/show_bug.cgi?id=29140
840 if test "$compiler_num" -lt "400"; then
841 tmp_CFLAGS="$tmp_CFLAGS -Wno-varargs"
842 fi
843 fi
844 dnl clang 7 or later
845 if test "$compiler_num" -ge "700"; then
846 CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [assign-enum])
847 CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [extra-semi-stmt])
848 fi
849 fi
850 ;;
851 #
852 DEC_C)
853 #
854 if test "$want_warnings" = "yes"; then
855 dnl Select a higher warning level than default level2
856 tmp_CFLAGS="$tmp_CFLAGS -msg_enable level3"
857 fi
858 ;;
859 #
860 GNU_C)
861 #
862 if test "$want_warnings" = "yes"; then
863 tmp_CFLAGS="$tmp_CFLAGS -std=gnu89"
864 #
865 dnl Do not enable -pedantic when cross-compiling with a gcc older
866 dnl than 3.0, to avoid warnings from third party system headers.
867 if test "x$cross_compiling" != "xyes" ||
868 test "$compiler_num" -ge "300"; then
869 tmp_CFLAGS="$tmp_CFLAGS -pedantic"
870 fi
871 #
872 dnl Set of options we believe *ALL* gcc versions support:
873 CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [all])
874 tmp_CFLAGS="$tmp_CFLAGS -W"
875 #
876 dnl Only gcc 1.4 or later
877 if test "$compiler_num" -ge "104"; then
878 CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [pointer-arith write-strings])
879 dnl If not cross-compiling with a gcc older than 3.0
880 if test "x$cross_compiling" != "xyes" ||
881 test "$compiler_num" -ge "300"; then
882 CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [unused shadow])
883 fi
884 fi
885 #
886 dnl Only gcc 2.7 or later
887 if test "$compiler_num" -ge "207"; then
888 CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [inline nested-externs])
889 dnl If not cross-compiling with a gcc older than 3.0
890 if test "x$cross_compiling" != "xyes" ||
891 test "$compiler_num" -ge "300"; then
892 CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [missing-declarations])
893 CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [missing-prototypes])
894 fi
895 fi
896 #
897 dnl Only gcc 2.95 or later
898 if test "$compiler_num" -ge "295"; then
899 tmp_CFLAGS="$tmp_CFLAGS -Wno-long-long"
900 CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [bad-function-cast])
901 fi
902 #
903 dnl Only gcc 2.96 or later
904 if test "$compiler_num" -ge "296"; then
905 CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [float-equal])
906 tmp_CFLAGS="$tmp_CFLAGS -Wno-multichar"
907 CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [sign-compare])
908 dnl -Wundef used only if gcc is 2.96 or later since we get
909 dnl lots of "`_POSIX_C_SOURCE' is not defined" in system
910 dnl headers with gcc 2.95.4 on FreeBSD 4.9
911 CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [undef])
912 fi
913 #
914 dnl Only gcc 2.97 or later
915 if test "$compiler_num" -ge "297"; then
916 tmp_CFLAGS="$tmp_CFLAGS -Wno-format-nonliteral"
917 fi
918 #
919 dnl Only gcc 3.0 or later
920 if test "$compiler_num" -ge "300"; then
921 dnl -Wunreachable-code seems totally unreliable on my gcc 3.3.2 on
922 dnl on i686-Linux as it gives us heaps with false positives.
923 dnl Also, on gcc 4.0.X it is totally unbearable and complains all
924 dnl over making it unusable for generic purposes. Let's not use it.
925 tmp_CFLAGS="$tmp_CFLAGS"
926 fi
927 #
928 dnl Only gcc 3.3 or later
929 if test "$compiler_num" -ge "303"; then
930 CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [endif-labels strict-prototypes])
931 fi
932 #
933 dnl Only gcc 3.4 or later
934 if test "$compiler_num" -ge "304"; then
935 CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [declaration-after-statement])
936 CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [old-style-definition])
937 fi
938 #
939 dnl Only gcc 4.0 or later
940 if test "$compiler_num" -ge "400"; then
941 tmp_CFLAGS="$tmp_CFLAGS -Wstrict-aliasing=3"
942 fi
943 #
944 dnl Only gcc 4.2 or later
945 if test "$compiler_num" -ge "402"; then
946 CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [cast-align])
947 fi
948 #
949 dnl Only gcc 4.3 or later
950 if test "$compiler_num" -ge "403"; then
951 CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [type-limits old-style-declaration])
952 CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [missing-parameter-type empty-body])
953 CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [clobbered ignored-qualifiers])
954 CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [conversion])
955 tmp_CFLAGS="$tmp_CFLAGS -Wno-sign-conversion"
956 CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [vla])
957 dnl required for -Warray-bounds, included in -Wall
958 tmp_CFLAGS="$tmp_CFLAGS -ftree-vrp"
959 fi
960 #
961 dnl Only gcc 4.5 or later
962 if test "$compiler_num" -ge "405"; then
963 dnl Only windows targets
964 if test "$curl_cv_have_def__WIN32" = "yes"; then
965 tmp_CFLAGS="$tmp_CFLAGS -Wno-pedantic-ms-format"
966 fi
967 fi
968 #
969 dnl Only gcc 4.6 or later
970 if test "$compiler_num" -ge "406"; then
971 CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [double-promotion])
972 fi
973 #
974 dnl only gcc 4.8 or later
975 if test "$compiler_num" -ge "408"; then
976 tmp_CFLAGS="$tmp_CFLAGS -Wformat=2"
977 fi
978 #
979 dnl Only gcc 5 or later
980 if test "$compiler_num" -ge "500"; then
981 tmp_CFLAGS="$tmp_CFLAGS -Warray-bounds=2"
982 fi
983 #
984 dnl Only gcc 6 or later
985 if test "$compiler_num" -ge "600"; then
986 CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [shift-negative-value])
987 tmp_CFLAGS="$tmp_CFLAGS -Wshift-overflow=2"
988 CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [null-dereference])
989 tmp_CFLAGS="$tmp_CFLAGS -fdelete-null-pointer-checks"
990 CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [duplicated-cond])
991 CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [unused-const-variable])
992 fi
993 #
994 dnl Only gcc 7 or later
995 if test "$compiler_num" -ge "700"; then
996 CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [duplicated-branches])
997 CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [restrict])
998 CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [alloc-zero])
999 tmp_CFLAGS="$tmp_CFLAGS -Wformat-overflow=2"
1000 tmp_CFLAGS="$tmp_CFLAGS -Wformat-truncation=2"
1001 if test "$compiler_num" -lt "1200"; then
1002 dnl gcc 12 doesn't acknowledge our comment markups
1003 tmp_CFLAGS="$tmp_CFLAGS -Wimplicit-fallthrough=4"
1004 fi
1005 fi
1006 #
1007 dnl Only gcc 10 or later
1008 if test "$compiler_num" -ge "1000"; then
1009 CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [arith-conversion])
1010 CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [enum-conversion])
1011 fi
1012 #
1013 fi
1014 #
1015 dnl Do not issue warnings for code in system include paths.
1016 if test "$compiler_num" -ge "300"; then
1017 tmp_CFLAGS="$tmp_CFLAGS -Wno-system-headers"
1018 else
1019 dnl When cross-compiling with a gcc older than 3.0, disable
1020 dnl some warnings triggered on third party system headers.
1021 if test "x$cross_compiling" = "xyes"; then
1022 if test "$compiler_num" -ge "104"; then
1023 dnl gcc 1.4 or later
1024 tmp_CFLAGS="$tmp_CFLAGS -Wno-unused -Wno-shadow"
1025 fi
1026 if test "$compiler_num" -ge "207"; then
1027 dnl gcc 2.7 or later
1028 tmp_CFLAGS="$tmp_CFLAGS -Wno-missing-declarations"
1029 tmp_CFLAGS="$tmp_CFLAGS -Wno-missing-prototypes"
1030 fi
1031 fi
1032 fi
1033 ;;
1034 #
1035 HP_UX_C)
1036 #
1037 if test "$want_warnings" = "yes"; then
1038 dnl Issue all warnings
1039 tmp_CFLAGS="$tmp_CFLAGS +w1"
1040 fi
1041 ;;
1042 #
1043 IBM_C)
1044 #
1045 dnl Placeholder
1046 tmp_CFLAGS="$tmp_CFLAGS"
1047 ;;
1048 #
1049 INTEL_UNIX_C)
1050 #
1051 if test "$want_warnings" = "yes"; then
1052 if test "$compiler_num" -gt "600"; then
1053 dnl Show errors, warnings, and remarks
1054 tmp_CPPFLAGS="$tmp_CPPFLAGS -Wall -w2"
1055 dnl Perform extra compile-time code checking
1056 tmp_CPPFLAGS="$tmp_CPPFLAGS -Wcheck"
1057 dnl Warn on nested comments
1058 tmp_CPPFLAGS="$tmp_CPPFLAGS -Wcomment"
1059 dnl Show warnings relative to deprecated features
1060 tmp_CPPFLAGS="$tmp_CPPFLAGS -Wdeprecated"
1061 dnl Enable warnings for missing prototypes
1062 tmp_CPPFLAGS="$tmp_CPPFLAGS -Wmissing-prototypes"
1063 dnl Enable warnings for 64-bit portability issues
1064 tmp_CPPFLAGS="$tmp_CPPFLAGS -Wp64"
1065 dnl Enable warnings for questionable pointer arithmetic
1066 tmp_CPPFLAGS="$tmp_CPPFLAGS -Wpointer-arith"
1067 dnl Check for function return typw issues
1068 tmp_CPPFLAGS="$tmp_CPPFLAGS -Wreturn-type"
1069 dnl Warn on variable declarations hiding a previous one
1070 tmp_CPPFLAGS="$tmp_CPPFLAGS -Wshadow"
1071 dnl Warn when a variable is used before initialized
1072 tmp_CPPFLAGS="$tmp_CPPFLAGS -Wuninitialized"
1073 dnl Warn if a declared function is not used
1074 tmp_CPPFLAGS="$tmp_CPPFLAGS -Wunused-function"
1075 fi
1076 fi
1077 dnl Disable using EBP register in optimizations
1078 tmp_CFLAGS="$tmp_CFLAGS -fno-omit-frame-pointer"
1079 dnl Disable use of ANSI C aliasing rules in optimizations
1080 tmp_CFLAGS="$tmp_CFLAGS -fno-strict-aliasing"
1081 dnl Value-safe optimizations on floating-point data
1082 tmp_CFLAGS="$tmp_CFLAGS -fp-model precise"
1083 ;;
1084 #
1085 INTEL_WINDOWS_C)
1086 #
1087 dnl Placeholder
1088 tmp_CFLAGS="$tmp_CFLAGS"
1089 ;;
1090 #
1091 LCC)
1092 #
1093 if test "$want_warnings" = "yes"; then
1094 dnl Highest warning level is double -A, next is single -A.
1095 dnl Due to the big number of warnings these trigger on third
1096 dnl party header files it is impractical for us to use any of
1097 dnl them here. If you want them simply define it in CPPFLAGS.
1098 tmp_CFLAGS="$tmp_CFLAGS"
1099 fi
1100 ;;
1101 #
1102 SGI_MIPS_C)
1103 #
1104 if test "$want_warnings" = "yes"; then
1105 dnl Perform stricter semantic and lint-like checks
1106 tmp_CFLAGS="$tmp_CFLAGS -fullwarn"
1107 fi
1108 ;;
1109 #
1110 SGI_MIPSPRO_C)
1111 #
1112 if test "$want_warnings" = "yes"; then
1113 dnl Perform stricter semantic and lint-like checks
1114 tmp_CFLAGS="$tmp_CFLAGS -fullwarn"
1115 dnl Disable some remarks
1116 dnl #1209: controlling expression is constant
1117 tmp_CFLAGS="$tmp_CFLAGS -woff 1209"
1118 fi
1119 ;;
1120 #
1121 SUNPRO_C)
1122 #
1123 if test "$want_warnings" = "yes"; then
1124 dnl Perform stricter semantic and lint-like checks
1125 tmp_CFLAGS="$tmp_CFLAGS -v"
1126 fi
1127 ;;
1128 #
1129 TINY_C)
1130 #
1131 if test "$want_warnings" = "yes"; then
1132 dnl Activate all warnings
1133 CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [all])
1134 dnl Make string constants be of type const char *
1135 CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [write-strings])
1136 dnl Warn use of unsupported GCC features ignored by TCC
1137 CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [unsupported])
1138 fi
1139 ;;
1140 #
1141 esac
1142 #
1143 squeeze tmp_CPPFLAGS
1144 squeeze tmp_CFLAGS
1145 #
1146 if test ! -z "$tmp_CFLAGS" || test ! -z "$tmp_CPPFLAGS"; then
1147 AC_MSG_CHECKING([if compiler accepts strict warning options])
1148 CPPFLAGS="$tmp_save_CPPFLAGS $tmp_CPPFLAGS"
1149 CFLAGS="$tmp_save_CFLAGS $tmp_CFLAGS"
1150 squeeze CPPFLAGS
1151 squeeze CFLAGS
1152 CURL_COMPILER_WORKS_IFELSE([
1153 AC_MSG_RESULT([yes])
1154 AC_MSG_NOTICE([compiler options added: $tmp_CFLAGS $tmp_CPPFLAGS])
1155 ],[
1156 AC_MSG_RESULT([no])
1157 AC_MSG_WARN([compiler options rejected: $tmp_CFLAGS $tmp_CPPFLAGS])
1158 dnl restore initial settings
1159 CPPFLAGS="$tmp_save_CPPFLAGS"
1160 CFLAGS="$tmp_save_CFLAGS"
1161 ])
1162 fi
1163 #
1164 fi
1165])
1166
1167
1168dnl CURL_SHFUNC_SQUEEZE
1169dnl -------------------------------------------------
1170dnl Declares a shell function squeeze() which removes
1171dnl redundant whitespace out of a shell variable.
1172
1173AC_DEFUN([CURL_SHFUNC_SQUEEZE], [
1174squeeze() {
1175 _sqz_result=""
1176 eval _sqz_input=\[$][$]1
1177 for _sqz_token in $_sqz_input; do
1178 if test -z "$_sqz_result"; then
1179 _sqz_result="$_sqz_token"
1180 else
1181 _sqz_result="$_sqz_result $_sqz_token"
1182 fi
1183 done
1184 eval [$]1=\$_sqz_result
1185 return 0
1186}
1187])
1188
1189
1190dnl CURL_CHECK_CURLDEBUG
1191dnl -------------------------------------------------
1192dnl Settings which depend on configure's curldebug given
1193dnl option, and other additional configure pre-requisites.
1194dnl Actually the curl debug memory tracking feature can
1195dnl only be used/enabled when libcurl is built as a static
1196dnl library or as a shared one on those systems on which
1197dnl shared libraries support undefined symbols.
1198
1199AC_DEFUN([CURL_CHECK_CURLDEBUG], [
1200 AC_REQUIRE([XC_LIBTOOL])dnl
1201 AC_REQUIRE([CURL_SHFUNC_SQUEEZE])dnl
1202 supports_curldebug="unknown"
1203 if test "$want_curldebug" = "yes"; then
1204 if test "x$enable_shared" != "xno" &&
1205 test "x$enable_shared" != "xyes"; then
1206 AC_MSG_WARN([unknown enable_shared setting.])
1207 supports_curldebug="no"
1208 fi
1209 if test "x$enable_static" != "xno" &&
1210 test "x$enable_static" != "xyes"; then
1211 AC_MSG_WARN([unknown enable_static setting.])
1212 supports_curldebug="no"
1213 fi
1214 if test "$supports_curldebug" != "no"; then
1215 if test "$enable_shared" = "yes" &&
1216 test "x$xc_lt_shlib_use_no_undefined" = 'xyes'; then
1217 supports_curldebug="no"
1218 AC_MSG_WARN([shared library does not support undefined symbols.])
1219 fi
1220 fi
1221 fi
1222 #
1223 if test "$want_curldebug" = "yes"; then
1224 AC_MSG_CHECKING([if curl debug memory tracking can be enabled])
1225 test "$supports_curldebug" = "no" || supports_curldebug="yes"
1226 AC_MSG_RESULT([$supports_curldebug])
1227 if test "$supports_curldebug" = "no"; then
1228 AC_MSG_WARN([cannot enable curl debug memory tracking.])
1229 want_curldebug="no"
1230 fi
1231 fi
1232])
1233
1234
1235
1236dnl CURL_CHECK_COMPILER_HALT_ON_ERROR
1237dnl -------------------------------------------------
1238dnl Verifies if the compiler actually halts after the
1239dnl compilation phase without generating any object
1240dnl code file, when the source compiles with errors.
1241
1242AC_DEFUN([CURL_CHECK_COMPILER_HALT_ON_ERROR], [
1243 AC_MSG_CHECKING([if compiler halts on compilation errors])
1244 AC_COMPILE_IFELSE([
1245 AC_LANG_PROGRAM([[
1246 ]],[[
1247 force compilation error
1248 ]])
1249 ],[
1250 AC_MSG_RESULT([no])
1251 AC_MSG_ERROR([compiler does not halt on compilation errors.])
1252 ],[
1253 AC_MSG_RESULT([yes])
1254 ])
1255])
1256
1257
1258dnl CURL_CHECK_COMPILER_ARRAY_SIZE_NEGATIVE
1259dnl -------------------------------------------------
1260dnl Verifies if the compiler actually halts after the
1261dnl compilation phase without generating any object
1262dnl code file, when the source code tries to define a
1263dnl type for a constant array with negative dimension.
1264
1265AC_DEFUN([CURL_CHECK_COMPILER_ARRAY_SIZE_NEGATIVE], [
1266 AC_REQUIRE([CURL_CHECK_COMPILER_HALT_ON_ERROR])dnl
1267 AC_MSG_CHECKING([if compiler halts on negative sized arrays])
1268 AC_COMPILE_IFELSE([
1269 AC_LANG_PROGRAM([[
1270 typedef char bad_t[sizeof(char) == sizeof(int) ? -1 : -1 ];
1271 ]],[[
1272 bad_t dummy;
1273 ]])
1274 ],[
1275 AC_MSG_RESULT([no])
1276 AC_MSG_ERROR([compiler does not halt on negative sized arrays.])
1277 ],[
1278 AC_MSG_RESULT([yes])
1279 ])
1280])
1281
1282
1283dnl CURL_CHECK_COMPILER_STRUCT_MEMBER_SIZE
1284dnl -------------------------------------------------
1285dnl Verifies if the compiler is capable of handling the
1286dnl size of a struct member, struct which is a function
1287dnl result, as a compilation-time condition inside the
1288dnl type definition of a constant array.
1289
1290AC_DEFUN([CURL_CHECK_COMPILER_STRUCT_MEMBER_SIZE], [
1291 AC_REQUIRE([CURL_CHECK_COMPILER_ARRAY_SIZE_NEGATIVE])dnl
1292 AC_MSG_CHECKING([if compiler struct member size checking works])
1293 tst_compiler_check_one_works="unknown"
1294 AC_COMPILE_IFELSE([
1295 AC_LANG_PROGRAM([[
1296 struct mystruct {
1297 int mi;
1298 char mc;
1299 struct mystruct *next;
1300 };
1301 struct mystruct myfunc();
1302 typedef char good_t1[sizeof(myfunc().mi) == sizeof(int) ? 1 : -1 ];
1303 typedef char good_t2[sizeof(myfunc().mc) == sizeof(char) ? 1 : -1 ];
1304 ]],[[
1305 good_t1 dummy1;
1306 good_t2 dummy2;
1307 ]])
1308 ],[
1309 tst_compiler_check_one_works="yes"
1310 ],[
1311 tst_compiler_check_one_works="no"
1312 sed 's/^/cc-src: /' conftest.$ac_ext >&6
1313 sed 's/^/cc-err: /' conftest.err >&6
1314 ])
1315 tst_compiler_check_two_works="unknown"
1316 AC_COMPILE_IFELSE([
1317 AC_LANG_PROGRAM([[
1318 struct mystruct {
1319 int mi;
1320 char mc;
1321 struct mystruct *next;
1322 };
1323 struct mystruct myfunc();
1324 typedef char bad_t1[sizeof(myfunc().mi) != sizeof(int) ? 1 : -1 ];
1325 typedef char bad_t2[sizeof(myfunc().mc) != sizeof(char) ? 1 : -1 ];
1326 ]],[[
1327 bad_t1 dummy1;
1328 bad_t2 dummy2;
1329 ]])
1330 ],[
1331 tst_compiler_check_two_works="no"
1332 ],[
1333 tst_compiler_check_two_works="yes"
1334 ])
1335 if test "$tst_compiler_check_one_works" = "yes" &&
1336 test "$tst_compiler_check_two_works" = "yes"; then
1337 AC_MSG_RESULT([yes])
1338 else
1339 AC_MSG_RESULT([no])
1340 AC_MSG_ERROR([compiler fails struct member size checking.])
1341 fi
1342])
1343
1344
1345dnl CURL_CHECK_COMPILER_SYMBOL_HIDING
1346dnl -------------------------------------------------
1347dnl Verify if compiler supports hiding library internal symbols, setting
1348dnl shell variable supports_symbol_hiding value as appropriate, as well as
1349dnl variables symbol_hiding_CFLAGS and symbol_hiding_EXTERN when supported.
1350
1351AC_DEFUN([CURL_CHECK_COMPILER_SYMBOL_HIDING], [
1352 AC_REQUIRE([CURL_CHECK_COMPILER])dnl
1353 AC_BEFORE([$0],[CURL_CONFIGURE_SYMBOL_HIDING])dnl
1354 AC_MSG_CHECKING([if compiler supports hiding library internal symbols])
1355 supports_symbol_hiding="no"
1356 symbol_hiding_CFLAGS=""
1357 symbol_hiding_EXTERN=""
1358 tmp_CFLAGS=""
1359 tmp_EXTERN=""
1360 case "$compiler_id" in
1361 CLANG)
1362 dnl All versions of clang support -fvisibility=
1363 tmp_EXTERN="__attribute__ ((__visibility__ (\"default\")))"
1364 tmp_CFLAGS="-fvisibility=hidden"
1365 supports_symbol_hiding="yes"
1366 ;;
1367 GNU_C)
1368 dnl Only gcc 3.4 or later
1369 if test "$compiler_num" -ge "304"; then
1370 if $CC --help --verbose 2>/dev/null | grep fvisibility= >/dev/null ; then
1371 tmp_EXTERN="__attribute__ ((__visibility__ (\"default\")))"
1372 tmp_CFLAGS="-fvisibility=hidden"
1373 supports_symbol_hiding="yes"
1374 fi
1375 fi
1376 ;;
1377 INTEL_UNIX_C)
1378 dnl Only icc 9.0 or later
1379 if test "$compiler_num" -ge "900"; then
1380 if $CC --help --verbose 2>&1 | grep fvisibility= > /dev/null ; then
1381 tmp_save_CFLAGS="$CFLAGS"
1382 CFLAGS="$CFLAGS -fvisibility=hidden"
1383 AC_LINK_IFELSE([
1384 AC_LANG_PROGRAM([[
1385# include <stdio.h>
1386 ]],[[
1387 printf("icc fvisibility bug test");
1388 ]])
1389 ],[
1390 tmp_EXTERN="__attribute__ ((__visibility__ (\"default\")))"
1391 tmp_CFLAGS="-fvisibility=hidden"
1392 supports_symbol_hiding="yes"
1393 ])
1394 CFLAGS="$tmp_save_CFLAGS"
1395 fi
1396 fi
1397 ;;
1398 SUNPRO_C)
1399 if $CC 2>&1 | grep flags >/dev/null && $CC -flags | grep xldscope= >/dev/null ; then
1400 tmp_EXTERN="__global"
1401 tmp_CFLAGS="-xldscope=hidden"
1402 supports_symbol_hiding="yes"
1403 fi
1404 ;;
1405 esac
1406 if test "$supports_symbol_hiding" = "yes"; then
1407 tmp_save_CFLAGS="$CFLAGS"
1408 CFLAGS="$tmp_save_CFLAGS $tmp_CFLAGS"
1409 squeeze CFLAGS
1410 AC_COMPILE_IFELSE([
1411 AC_LANG_PROGRAM([[
1412 $tmp_EXTERN char *dummy(char *buff);
1413 char *dummy(char *buff)
1414 {
1415 if(buff)
1416 return ++buff;
1417 else
1418 return buff;
1419 }
1420 ]],[[
1421 char b[16];
1422 char *r = dummy(&b[0]);
1423 if(r)
1424 return (int)*r;
1425 ]])
1426 ],[
1427 supports_symbol_hiding="yes"
1428 if test -f conftest.err; then
1429 grep 'visibility' conftest.err >/dev/null
1430 if test "$?" -eq "0"; then
1431 supports_symbol_hiding="no"
1432 fi
1433 fi
1434 ],[
1435 supports_symbol_hiding="no"
1436 echo " " >&6
1437 sed 's/^/cc-src: /' conftest.$ac_ext >&6
1438 sed 's/^/cc-err: /' conftest.err >&6
1439 echo " " >&6
1440 ])
1441 CFLAGS="$tmp_save_CFLAGS"
1442 fi
1443 if test "$supports_symbol_hiding" = "yes"; then
1444 AC_MSG_RESULT([yes])
1445 symbol_hiding_CFLAGS="$tmp_CFLAGS"
1446 symbol_hiding_EXTERN="$tmp_EXTERN"
1447 else
1448 AC_MSG_RESULT([no])
1449 fi
1450])
1451
1452
1453dnl CURL_CHECK_COMPILER_PROTOTYPE_MISMATCH
1454dnl -------------------------------------------------
1455dnl Verifies if the compiler actually halts after the
1456dnl compilation phase without generating any object
1457dnl code file, when the source code tries to redefine
1458dnl a prototype which does not match previous one.
1459
1460AC_DEFUN([CURL_CHECK_COMPILER_PROTOTYPE_MISMATCH], [
1461 AC_REQUIRE([CURL_CHECK_COMPILER_HALT_ON_ERROR])dnl
1462 AC_MSG_CHECKING([if compiler halts on function prototype mismatch])
1463 AC_COMPILE_IFELSE([
1464 AC_LANG_PROGRAM([[
1465# include <stdlib.h>
1466 int rand(int n);
1467 int rand(int n)
1468 {
1469 if(n)
1470 return ++n;
1471 else
1472 return n;
1473 }
1474 ]],[[
1475 int i[2]={0,0};
1476 int j = rand(i[0]);
1477 if(j)
1478 return j;
1479 ]])
1480 ],[
1481 AC_MSG_RESULT([no])
1482 AC_MSG_ERROR([compiler does not halt on function prototype mismatch.])
1483 ],[
1484 AC_MSG_RESULT([yes])
1485 ])
1486])
1487
1488
1489dnl CURL_VAR_MATCH (VARNAME, VALUE)
1490dnl -------------------------------------------------
1491dnl Verifies if shell variable VARNAME contains VALUE.
1492dnl Contents of variable VARNAME and VALUE are handled
1493dnl as whitespace separated lists of words. If at least
1494dnl one word of VALUE is present in VARNAME the match
1495dnl is considered positive, otherwise false.
1496
1497AC_DEFUN([CURL_VAR_MATCH], [
1498 ac_var_match_word="no"
1499 for word1 in $[$1]; do
1500 for word2 in [$2]; do
1501 if test "$word1" = "$word2"; then
1502 ac_var_match_word="yes"
1503 fi
1504 done
1505 done
1506])
1507
1508
1509dnl CURL_VAR_MATCH_IFELSE (VARNAME, VALUE,
1510dnl [ACTION-IF-MATCH], [ACTION-IF-NOT-MATCH])
1511dnl -------------------------------------------------
1512dnl This performs a CURL_VAR_MATCH check and executes
1513dnl first branch if the match is positive, otherwise
1514dnl the second branch is executed.
1515
1516AC_DEFUN([CURL_VAR_MATCH_IFELSE], [
1517 CURL_VAR_MATCH([$1],[$2])
1518 if test "$ac_var_match_word" = "yes"; then
1519 ifelse($3,,:,[$3])
1520 ifelse($4,,,[else
1521 $4])
1522 fi
1523])
1524
1525
1526dnl CURL_VAR_STRIP (VARNAME, VALUE)
1527dnl -------------------------------------------------
1528dnl Contents of variable VARNAME and VALUE are handled
1529dnl as whitespace separated lists of words. Each word
1530dnl from VALUE is removed from VARNAME when present.
1531
1532AC_DEFUN([CURL_VAR_STRIP], [
1533 AC_REQUIRE([CURL_SHFUNC_SQUEEZE])dnl
1534 ac_var_stripped=""
1535 for word1 in $[$1]; do
1536 ac_var_strip_word="no"
1537 for word2 in [$2]; do
1538 if test "$word1" = "$word2"; then
1539 ac_var_strip_word="yes"
1540 fi
1541 done
1542 if test "$ac_var_strip_word" = "no"; then
1543 ac_var_stripped="$ac_var_stripped $word1"
1544 fi
1545 done
1546 dnl squeeze whitespace out of result
1547 [$1]="$ac_var_stripped"
1548 squeeze [$1]
1549])
1550
1551dnl CURL_ADD_COMPILER_WARNINGS (WARNING-LIST, NEW-WARNINGS)
1552dnl -------------------------------------------------------
1553dnl Contents of variable WARNING-LIST and NEW-WARNINGS are
1554dnl handled as whitespace separated lists of words.
1555dnl Add each compiler warning from NEW-WARNINGS that has not
1556dnl been disabled via CFLAGS to WARNING-LIST.
1557
1558AC_DEFUN([CURL_ADD_COMPILER_WARNINGS], [
1559 AC_REQUIRE([CURL_SHFUNC_SQUEEZE])dnl
1560 ac_var_added_warnings=""
1561 for warning in [$2]; do
1562 CURL_VAR_MATCH(CFLAGS, [-Wno-$warning -W$warning])
1563 if test "$ac_var_match_word" = "no"; then
1564 ac_var_added_warnings="$ac_var_added_warnings -W$warning"
1565 fi
1566 done
1567 dnl squeeze whitespace out of result
1568 [$1]="$[$1] $ac_var_added_warnings"
1569 squeeze [$1]
1570])