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