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