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