113498266Sopenharmony_ci#*************************************************************************** 213498266Sopenharmony_ci# _ _ ____ _ 313498266Sopenharmony_ci# Project ___| | | | _ \| | 413498266Sopenharmony_ci# / __| | | | |_) | | 513498266Sopenharmony_ci# | (__| |_| | _ <| |___ 613498266Sopenharmony_ci# \___|\___/|_| \_\_____| 713498266Sopenharmony_ci# 813498266Sopenharmony_ci# Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al. 913498266Sopenharmony_ci# 1013498266Sopenharmony_ci# This software is licensed as described in the file COPYING, which 1113498266Sopenharmony_ci# you should have received as part of this distribution. The terms 1213498266Sopenharmony_ci# are also available at https://curl.se/docs/copyright.html. 1313498266Sopenharmony_ci# 1413498266Sopenharmony_ci# You may opt to use, copy, modify, merge, publish, distribute and/or sell 1513498266Sopenharmony_ci# copies of the Software, and permit persons to whom the Software is 1613498266Sopenharmony_ci# furnished to do so, under the terms of the COPYING file. 1713498266Sopenharmony_ci# 1813498266Sopenharmony_ci# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY 1913498266Sopenharmony_ci# KIND, either express or implied. 2013498266Sopenharmony_ci# 2113498266Sopenharmony_ci# SPDX-License-Identifier: curl 2213498266Sopenharmony_ci# 2313498266Sopenharmony_ci#*************************************************************************** 2413498266Sopenharmony_ci 2513498266Sopenharmony_ci# File version for 'aclocal' use. Keep it a single number. 2613498266Sopenharmony_ci# serial 67 2713498266Sopenharmony_ci 2813498266Sopenharmony_ci 2913498266Sopenharmony_cidnl CURL_CHECK_COMPILER 3013498266Sopenharmony_cidnl ------------------------------------------------- 3113498266Sopenharmony_cidnl Verify if the C compiler being used is known. 3213498266Sopenharmony_ci 3313498266Sopenharmony_ciAC_DEFUN([CURL_CHECK_COMPILER], [ 3413498266Sopenharmony_ci # 3513498266Sopenharmony_ci compiler_id="unknown" 3613498266Sopenharmony_ci compiler_num="0" 3713498266Sopenharmony_ci # 3813498266Sopenharmony_ci flags_dbg_yes="unknown" 3913498266Sopenharmony_ci flags_opt_all="unknown" 4013498266Sopenharmony_ci flags_opt_yes="unknown" 4113498266Sopenharmony_ci flags_opt_off="unknown" 4213498266Sopenharmony_ci # 4313498266Sopenharmony_ci flags_prefer_cppflags="no" 4413498266Sopenharmony_ci # 4513498266Sopenharmony_ci CURL_CHECK_COMPILER_DEC_C 4613498266Sopenharmony_ci CURL_CHECK_COMPILER_HPUX_C 4713498266Sopenharmony_ci CURL_CHECK_COMPILER_IBM_C 4813498266Sopenharmony_ci CURL_CHECK_COMPILER_INTEL_C 4913498266Sopenharmony_ci CURL_CHECK_COMPILER_CLANG 5013498266Sopenharmony_ci CURL_CHECK_COMPILER_GNU_C 5113498266Sopenharmony_ci CURL_CHECK_COMPILER_SGI_MIPSPRO_C 5213498266Sopenharmony_ci CURL_CHECK_COMPILER_SGI_MIPS_C 5313498266Sopenharmony_ci CURL_CHECK_COMPILER_SUNPRO_C 5413498266Sopenharmony_ci CURL_CHECK_COMPILER_TINY_C 5513498266Sopenharmony_ci # 5613498266Sopenharmony_ci if test "$compiler_id" = "unknown"; then 5713498266Sopenharmony_ci cat <<_EOF 1>&2 5813498266Sopenharmony_ci*** 5913498266Sopenharmony_ci*** Warning: This configure script does not have information about the 6013498266Sopenharmony_ci*** compiler you are using, relative to the flags required to enable or 6113498266Sopenharmony_ci*** disable generation of debug info, optimization options or warnings. 6213498266Sopenharmony_ci*** 6313498266Sopenharmony_ci*** Whatever settings are present in CFLAGS will be used for this run. 6413498266Sopenharmony_ci*** 6513498266Sopenharmony_ci*** If you wish to help the curl project to better support your compiler 6613498266Sopenharmony_ci*** you can report this and the required info on the libcurl development 6713498266Sopenharmony_ci*** mailing list: https://lists.haxx.selistinfo/curl-library/ 6813498266Sopenharmony_ci*** 6913498266Sopenharmony_ci_EOF 7013498266Sopenharmony_ci fi 7113498266Sopenharmony_ci]) 7213498266Sopenharmony_ci 7313498266Sopenharmony_ci 7413498266Sopenharmony_cidnl CURL_CHECK_COMPILER_CLANG 7513498266Sopenharmony_cidnl ------------------------------------------------- 7613498266Sopenharmony_cidnl Verify if compiler being used is clang. 7713498266Sopenharmony_ci 7813498266Sopenharmony_ciAC_DEFUN([CURL_CHECK_COMPILER_CLANG], [ 7913498266Sopenharmony_ci AC_BEFORE([$0],[CURL_CHECK_COMPILER_GNU_C])dnl 8013498266Sopenharmony_ci AC_MSG_CHECKING([if compiler is clang]) 8113498266Sopenharmony_ci CURL_CHECK_DEF([__clang__], [], [silent]) 8213498266Sopenharmony_ci if test "$curl_cv_have_def___clang__" = "yes"; then 8313498266Sopenharmony_ci AC_MSG_RESULT([yes]) 8413498266Sopenharmony_ci AC_MSG_CHECKING([if compiler is xlclang]) 8513498266Sopenharmony_ci CURL_CHECK_DEF([__ibmxl__], [], [silent]) 8613498266Sopenharmony_ci if test "$curl_cv_have_def___ibmxl__" = "yes" ; then 8713498266Sopenharmony_ci dnl IBM's almost-compatible clang version 8813498266Sopenharmony_ci AC_MSG_RESULT([yes]) 8913498266Sopenharmony_ci compiler_id="XLCLANG" 9013498266Sopenharmony_ci else 9113498266Sopenharmony_ci AC_MSG_RESULT([no]) 9213498266Sopenharmony_ci compiler_id="CLANG" 9313498266Sopenharmony_ci fi 9413498266Sopenharmony_ci AC_MSG_CHECKING([compiler version]) 9513498266Sopenharmony_ci fullclangver=`$CC -v 2>&1 | grep version` 9613498266Sopenharmony_ci if echo $fullclangver | grep 'Apple' >/dev/null; then 9713498266Sopenharmony_ci appleclang=1 9813498266Sopenharmony_ci else 9913498266Sopenharmony_ci appleclang=0 10013498266Sopenharmony_ci fi 10113498266Sopenharmony_ci clangver=`echo $fullclangver | grep "based on LLVM " | "$SED" 's/.*(based on LLVM \(@<:@0-9@:>@*\.@<:@0-9@:>@*\).*)/\1/'` 10213498266Sopenharmony_ci if test -z "$clangver"; then 10313498266Sopenharmony_ci clangver=`echo $fullclangver | "$SED" 's/.*version \(@<:@0-9@:>@*\.@<:@0-9@:>@*\).*/\1/'` 10413498266Sopenharmony_ci oldapple=0 10513498266Sopenharmony_ci else 10613498266Sopenharmony_ci oldapple=1 10713498266Sopenharmony_ci fi 10813498266Sopenharmony_ci clangvhi=`echo $clangver | cut -d . -f1` 10913498266Sopenharmony_ci clangvlo=`echo $clangver | cut -d . -f2` 11013498266Sopenharmony_ci compiler_num=`(expr $clangvhi "*" 100 + $clangvlo) 2>/dev/null` 11113498266Sopenharmony_ci if test "$appleclang" = '1' && test "$oldapple" = '0'; then 11213498266Sopenharmony_ci dnl Starting with Xcode 7 / clang 3.7, Apple clang won't tell its upstream version 11313498266Sopenharmony_ci if test "$compiler_num" -ge '1300'; then compiler_num='1200' 11413498266Sopenharmony_ci elif test "$compiler_num" -ge '1205'; then compiler_num='1101' 11513498266Sopenharmony_ci elif test "$compiler_num" -ge '1204'; then compiler_num='1000' 11613498266Sopenharmony_ci elif test "$compiler_num" -ge '1107'; then compiler_num='900' 11713498266Sopenharmony_ci elif test "$compiler_num" -ge '1103'; then compiler_num='800' 11813498266Sopenharmony_ci elif test "$compiler_num" -ge '1003'; then compiler_num='700' 11913498266Sopenharmony_ci elif test "$compiler_num" -ge '1001'; then compiler_num='600' 12013498266Sopenharmony_ci elif test "$compiler_num" -ge '904'; then compiler_num='500' 12113498266Sopenharmony_ci elif test "$compiler_num" -ge '902'; then compiler_num='400' 12213498266Sopenharmony_ci elif test "$compiler_num" -ge '803'; then compiler_num='309' 12313498266Sopenharmony_ci elif test "$compiler_num" -ge '703'; then compiler_num='308' 12413498266Sopenharmony_ci else compiler_num='307' 12513498266Sopenharmony_ci fi 12613498266Sopenharmony_ci fi 12713498266Sopenharmony_ci AC_MSG_RESULT([clang '$compiler_num' (raw: '$fullclangver' / '$clangver')]) 12813498266Sopenharmony_ci flags_dbg_yes="-g" 12913498266Sopenharmony_ci flags_opt_all="-O -O0 -O1 -O2 -Os -O3 -O4" 13013498266Sopenharmony_ci flags_opt_yes="-O2" 13113498266Sopenharmony_ci flags_opt_off="-O0" 13213498266Sopenharmony_ci else 13313498266Sopenharmony_ci AC_MSG_RESULT([no]) 13413498266Sopenharmony_ci fi 13513498266Sopenharmony_ci]) 13613498266Sopenharmony_ci 13713498266Sopenharmony_ci 13813498266Sopenharmony_cidnl CURL_CHECK_COMPILER_DEC_C 13913498266Sopenharmony_cidnl ------------------------------------------------- 14013498266Sopenharmony_cidnl Verify if compiler being used is DEC C. 14113498266Sopenharmony_ci 14213498266Sopenharmony_ciAC_DEFUN([CURL_CHECK_COMPILER_DEC_C], [ 14313498266Sopenharmony_ci AC_MSG_CHECKING([if compiler is DEC/Compaq/HP C]) 14413498266Sopenharmony_ci CURL_CHECK_DEF([__DECC], [], [silent]) 14513498266Sopenharmony_ci CURL_CHECK_DEF([__DECC_VER], [], [silent]) 14613498266Sopenharmony_ci if test "$curl_cv_have_def___DECC" = "yes" && 14713498266Sopenharmony_ci test "$curl_cv_have_def___DECC_VER" = "yes"; then 14813498266Sopenharmony_ci AC_MSG_RESULT([yes]) 14913498266Sopenharmony_ci compiler_id="DEC_C" 15013498266Sopenharmony_ci flags_dbg_yes="-g2" 15113498266Sopenharmony_ci flags_opt_all="-O -O0 -O1 -O2 -O3 -O4" 15213498266Sopenharmony_ci flags_opt_yes="-O1" 15313498266Sopenharmony_ci flags_opt_off="-O0" 15413498266Sopenharmony_ci else 15513498266Sopenharmony_ci AC_MSG_RESULT([no]) 15613498266Sopenharmony_ci fi 15713498266Sopenharmony_ci]) 15813498266Sopenharmony_ci 15913498266Sopenharmony_ci 16013498266Sopenharmony_cidnl CURL_CHECK_COMPILER_GNU_C 16113498266Sopenharmony_cidnl ------------------------------------------------- 16213498266Sopenharmony_cidnl Verify if compiler being used is GNU C 16313498266Sopenharmony_cidnl 16413498266Sopenharmony_cidnl $compiler_num will be set to MAJOR * 100 + MINOR for gcc less than version 16513498266Sopenharmony_cidnl 7 and just $MAJOR * 100 for gcc version 7 and later. 16613498266Sopenharmony_cidnl 16713498266Sopenharmony_cidnl Examples: 16813498266Sopenharmony_cidnl Version 1.2.3 => 102 16913498266Sopenharmony_cidnl Version 2.95 => 295 17013498266Sopenharmony_cidnl Version 4.7 => 407 17113498266Sopenharmony_cidnl Version 9.2.1 => 900 17213498266Sopenharmony_cidnl 17313498266Sopenharmony_ciAC_DEFUN([CURL_CHECK_COMPILER_GNU_C], [ 17413498266Sopenharmony_ci AC_REQUIRE([CURL_CHECK_COMPILER_INTEL_C])dnl 17513498266Sopenharmony_ci AC_REQUIRE([CURL_CHECK_COMPILER_CLANG])dnl 17613498266Sopenharmony_ci AC_MSG_CHECKING([if compiler is GNU C]) 17713498266Sopenharmony_ci CURL_CHECK_DEF([__GNUC__], [], [silent]) 17813498266Sopenharmony_ci if test "$curl_cv_have_def___GNUC__" = "yes" && 17913498266Sopenharmony_ci test "$compiler_id" = "unknown"; then 18013498266Sopenharmony_ci AC_MSG_RESULT([yes]) 18113498266Sopenharmony_ci compiler_id="GNU_C" 18213498266Sopenharmony_ci AC_MSG_CHECKING([compiler version]) 18313498266Sopenharmony_ci # strip '-suffix' parts, e.g. Ubuntu Windows cross-gcc returns '10-win32' 18413498266Sopenharmony_ci gccver=`$CC -dumpversion | sed -E 's/-.+$//'` 18513498266Sopenharmony_ci gccvhi=`echo $gccver | cut -d . -f1` 18613498266Sopenharmony_ci if echo $gccver | grep -F '.' >/dev/null; then 18713498266Sopenharmony_ci gccvlo=`echo $gccver | cut -d . -f2` 18813498266Sopenharmony_ci else 18913498266Sopenharmony_ci gccvlo="0" 19013498266Sopenharmony_ci fi 19113498266Sopenharmony_ci compiler_num=`(expr $gccvhi "*" 100 + $gccvlo) 2>/dev/null` 19213498266Sopenharmony_ci AC_MSG_RESULT([gcc '$compiler_num' (raw: '$gccver')]) 19313498266Sopenharmony_ci flags_dbg_yes="-g" 19413498266Sopenharmony_ci flags_opt_all="-O -O0 -O1 -O2 -O3 -Os -Og -Ofast" 19513498266Sopenharmony_ci flags_opt_yes="-O2" 19613498266Sopenharmony_ci flags_opt_off="-O0" 19713498266Sopenharmony_ci else 19813498266Sopenharmony_ci AC_MSG_RESULT([no]) 19913498266Sopenharmony_ci fi 20013498266Sopenharmony_ci]) 20113498266Sopenharmony_ci 20213498266Sopenharmony_ci 20313498266Sopenharmony_cidnl CURL_CHECK_COMPILER_HPUX_C 20413498266Sopenharmony_cidnl ------------------------------------------------- 20513498266Sopenharmony_cidnl Verify if compiler being used is HP-UX C. 20613498266Sopenharmony_ci 20713498266Sopenharmony_ciAC_DEFUN([CURL_CHECK_COMPILER_HPUX_C], [ 20813498266Sopenharmony_ci AC_MSG_CHECKING([if compiler is HP-UX C]) 20913498266Sopenharmony_ci CURL_CHECK_DEF([__HP_cc], [], [silent]) 21013498266Sopenharmony_ci if test "$curl_cv_have_def___HP_cc" = "yes"; then 21113498266Sopenharmony_ci AC_MSG_RESULT([yes]) 21213498266Sopenharmony_ci compiler_id="HP_UX_C" 21313498266Sopenharmony_ci flags_dbg_yes="-g" 21413498266Sopenharmony_ci flags_opt_all="-O +O0 +O1 +O2 +O3 +O4" 21513498266Sopenharmony_ci flags_opt_yes="+O2" 21613498266Sopenharmony_ci flags_opt_off="+O0" 21713498266Sopenharmony_ci else 21813498266Sopenharmony_ci AC_MSG_RESULT([no]) 21913498266Sopenharmony_ci fi 22013498266Sopenharmony_ci]) 22113498266Sopenharmony_ci 22213498266Sopenharmony_ci 22313498266Sopenharmony_cidnl CURL_CHECK_COMPILER_IBM_C 22413498266Sopenharmony_cidnl ------------------------------------------------- 22513498266Sopenharmony_cidnl Verify if compiler being used is IBM C. 22613498266Sopenharmony_ci 22713498266Sopenharmony_ciAC_DEFUN([CURL_CHECK_COMPILER_IBM_C], [ 22813498266Sopenharmony_ci AC_MSG_CHECKING([if compiler is IBM C]) 22913498266Sopenharmony_ci CURL_CHECK_DEF([__IBMC__], [], [silent]) 23013498266Sopenharmony_ci if test "$curl_cv_have_def___IBMC__" = "yes"; then 23113498266Sopenharmony_ci AC_MSG_RESULT([yes]) 23213498266Sopenharmony_ci compiler_id="IBM_C" 23313498266Sopenharmony_ci flags_dbg_yes="-g" 23413498266Sopenharmony_ci flags_opt_all="-O -O0 -O1 -O2 -O3 -O4 -O5" 23513498266Sopenharmony_ci flags_opt_all="$flags_opt_all -qnooptimize" 23613498266Sopenharmony_ci flags_opt_all="$flags_opt_all -qoptimize=0" 23713498266Sopenharmony_ci flags_opt_all="$flags_opt_all -qoptimize=1" 23813498266Sopenharmony_ci flags_opt_all="$flags_opt_all -qoptimize=2" 23913498266Sopenharmony_ci flags_opt_all="$flags_opt_all -qoptimize=3" 24013498266Sopenharmony_ci flags_opt_all="$flags_opt_all -qoptimize=4" 24113498266Sopenharmony_ci flags_opt_all="$flags_opt_all -qoptimize=5" 24213498266Sopenharmony_ci flags_opt_yes="-O2" 24313498266Sopenharmony_ci flags_opt_off="-qnooptimize" 24413498266Sopenharmony_ci flags_prefer_cppflags="yes" 24513498266Sopenharmony_ci else 24613498266Sopenharmony_ci AC_MSG_RESULT([no]) 24713498266Sopenharmony_ci fi 24813498266Sopenharmony_ci]) 24913498266Sopenharmony_ci 25013498266Sopenharmony_ci 25113498266Sopenharmony_cidnl CURL_CHECK_COMPILER_INTEL_C 25213498266Sopenharmony_cidnl ------------------------------------------------- 25313498266Sopenharmony_cidnl Verify if compiler being used is Intel C. 25413498266Sopenharmony_ci 25513498266Sopenharmony_ciAC_DEFUN([CURL_CHECK_COMPILER_INTEL_C], [ 25613498266Sopenharmony_ci AC_BEFORE([$0],[CURL_CHECK_COMPILER_GNU_C])dnl 25713498266Sopenharmony_ci AC_MSG_CHECKING([if compiler is Intel C]) 25813498266Sopenharmony_ci CURL_CHECK_DEF([__INTEL_COMPILER], [], [silent]) 25913498266Sopenharmony_ci if test "$curl_cv_have_def___INTEL_COMPILER" = "yes"; then 26013498266Sopenharmony_ci AC_MSG_RESULT([yes]) 26113498266Sopenharmony_ci AC_MSG_CHECKING([compiler version]) 26213498266Sopenharmony_ci compiler_num="$curl_cv_def___INTEL_COMPILER" 26313498266Sopenharmony_ci AC_MSG_RESULT([Intel C '$compiler_num']) 26413498266Sopenharmony_ci CURL_CHECK_DEF([__unix__], [], [silent]) 26513498266Sopenharmony_ci if test "$curl_cv_have_def___unix__" = "yes"; then 26613498266Sopenharmony_ci compiler_id="INTEL_UNIX_C" 26713498266Sopenharmony_ci flags_dbg_yes="-g" 26813498266Sopenharmony_ci flags_opt_all="-O -O0 -O1 -O2 -O3 -Os" 26913498266Sopenharmony_ci flags_opt_yes="-O2" 27013498266Sopenharmony_ci flags_opt_off="-O0" 27113498266Sopenharmony_ci else 27213498266Sopenharmony_ci compiler_id="INTEL_WINDOWS_C" 27313498266Sopenharmony_ci flags_dbg_yes="/Zi /Oy-" 27413498266Sopenharmony_ci flags_opt_all="/O /O0 /O1 /O2 /O3 /Od /Og /Og- /Oi /Oi-" 27513498266Sopenharmony_ci flags_opt_yes="/O2" 27613498266Sopenharmony_ci flags_opt_off="/Od" 27713498266Sopenharmony_ci fi 27813498266Sopenharmony_ci else 27913498266Sopenharmony_ci AC_MSG_RESULT([no]) 28013498266Sopenharmony_ci fi 28113498266Sopenharmony_ci]) 28213498266Sopenharmony_ci 28313498266Sopenharmony_ci 28413498266Sopenharmony_cidnl CURL_CHECK_COMPILER_SGI_MIPS_C 28513498266Sopenharmony_cidnl ------------------------------------------------- 28613498266Sopenharmony_cidnl Verify if compiler being used is SGI MIPS C. 28713498266Sopenharmony_ci 28813498266Sopenharmony_ciAC_DEFUN([CURL_CHECK_COMPILER_SGI_MIPS_C], [ 28913498266Sopenharmony_ci AC_REQUIRE([CURL_CHECK_COMPILER_SGI_MIPSPRO_C])dnl 29013498266Sopenharmony_ci AC_MSG_CHECKING([if compiler is SGI MIPS C]) 29113498266Sopenharmony_ci CURL_CHECK_DEF([__GNUC__], [], [silent]) 29213498266Sopenharmony_ci CURL_CHECK_DEF([__sgi], [], [silent]) 29313498266Sopenharmony_ci if test "$curl_cv_have_def___GNUC__" = "no" && 29413498266Sopenharmony_ci test "$curl_cv_have_def___sgi" = "yes" && 29513498266Sopenharmony_ci test "$compiler_id" = "unknown"; then 29613498266Sopenharmony_ci AC_MSG_RESULT([yes]) 29713498266Sopenharmony_ci compiler_id="SGI_MIPS_C" 29813498266Sopenharmony_ci flags_dbg_yes="-g" 29913498266Sopenharmony_ci flags_opt_all="-O -O0 -O1 -O2 -O3 -Ofast" 30013498266Sopenharmony_ci flags_opt_yes="-O2" 30113498266Sopenharmony_ci flags_opt_off="-O0" 30213498266Sopenharmony_ci else 30313498266Sopenharmony_ci AC_MSG_RESULT([no]) 30413498266Sopenharmony_ci fi 30513498266Sopenharmony_ci]) 30613498266Sopenharmony_ci 30713498266Sopenharmony_ci 30813498266Sopenharmony_cidnl CURL_CHECK_COMPILER_SGI_MIPSPRO_C 30913498266Sopenharmony_cidnl ------------------------------------------------- 31013498266Sopenharmony_cidnl Verify if compiler being used is SGI MIPSpro C. 31113498266Sopenharmony_ci 31213498266Sopenharmony_ciAC_DEFUN([CURL_CHECK_COMPILER_SGI_MIPSPRO_C], [ 31313498266Sopenharmony_ci AC_BEFORE([$0],[CURL_CHECK_COMPILER_SGI_MIPS_C])dnl 31413498266Sopenharmony_ci AC_MSG_CHECKING([if compiler is SGI MIPSpro C]) 31513498266Sopenharmony_ci CURL_CHECK_DEF([__GNUC__], [], [silent]) 31613498266Sopenharmony_ci CURL_CHECK_DEF([_COMPILER_VERSION], [], [silent]) 31713498266Sopenharmony_ci CURL_CHECK_DEF([_SGI_COMPILER_VERSION], [], [silent]) 31813498266Sopenharmony_ci if test "$curl_cv_have_def___GNUC__" = "no" && 31913498266Sopenharmony_ci (test "$curl_cv_have_def__SGI_COMPILER_VERSION" = "yes" || 32013498266Sopenharmony_ci test "$curl_cv_have_def__COMPILER_VERSION" = "yes"); then 32113498266Sopenharmony_ci AC_MSG_RESULT([yes]) 32213498266Sopenharmony_ci compiler_id="SGI_MIPSPRO_C" 32313498266Sopenharmony_ci flags_dbg_yes="-g" 32413498266Sopenharmony_ci flags_opt_all="-O -O0 -O1 -O2 -O3 -Ofast" 32513498266Sopenharmony_ci flags_opt_yes="-O2" 32613498266Sopenharmony_ci flags_opt_off="-O0" 32713498266Sopenharmony_ci else 32813498266Sopenharmony_ci AC_MSG_RESULT([no]) 32913498266Sopenharmony_ci fi 33013498266Sopenharmony_ci]) 33113498266Sopenharmony_ci 33213498266Sopenharmony_ci 33313498266Sopenharmony_cidnl CURL_CHECK_COMPILER_SUNPRO_C 33413498266Sopenharmony_cidnl ------------------------------------------------- 33513498266Sopenharmony_cidnl Verify if compiler being used is SunPro C. 33613498266Sopenharmony_ci 33713498266Sopenharmony_ciAC_DEFUN([CURL_CHECK_COMPILER_SUNPRO_C], [ 33813498266Sopenharmony_ci AC_MSG_CHECKING([if compiler is SunPro C]) 33913498266Sopenharmony_ci CURL_CHECK_DEF([__SUNPRO_C], [], [silent]) 34013498266Sopenharmony_ci if test "$curl_cv_have_def___SUNPRO_C" = "yes"; then 34113498266Sopenharmony_ci AC_MSG_RESULT([yes]) 34213498266Sopenharmony_ci compiler_id="SUNPRO_C" 34313498266Sopenharmony_ci flags_dbg_yes="-g" 34413498266Sopenharmony_ci flags_opt_all="-O -xO -xO1 -xO2 -xO3 -xO4 -xO5" 34513498266Sopenharmony_ci flags_opt_yes="-xO2" 34613498266Sopenharmony_ci flags_opt_off="" 34713498266Sopenharmony_ci else 34813498266Sopenharmony_ci AC_MSG_RESULT([no]) 34913498266Sopenharmony_ci fi 35013498266Sopenharmony_ci]) 35113498266Sopenharmony_ci 35213498266Sopenharmony_ci 35313498266Sopenharmony_cidnl CURL_CHECK_COMPILER_TINY_C 35413498266Sopenharmony_cidnl ------------------------------------------------- 35513498266Sopenharmony_cidnl Verify if compiler being used is Tiny C. 35613498266Sopenharmony_ci 35713498266Sopenharmony_ciAC_DEFUN([CURL_CHECK_COMPILER_TINY_C], [ 35813498266Sopenharmony_ci AC_MSG_CHECKING([if compiler is Tiny C]) 35913498266Sopenharmony_ci CURL_CHECK_DEF([__TINYC__], [], [silent]) 36013498266Sopenharmony_ci if test "$curl_cv_have_def___TINYC__" = "yes"; then 36113498266Sopenharmony_ci AC_MSG_RESULT([yes]) 36213498266Sopenharmony_ci compiler_id="TINY_C" 36313498266Sopenharmony_ci flags_dbg_yes="-g" 36413498266Sopenharmony_ci flags_opt_all="" 36513498266Sopenharmony_ci flags_opt_yes="" 36613498266Sopenharmony_ci flags_opt_off="" 36713498266Sopenharmony_ci else 36813498266Sopenharmony_ci AC_MSG_RESULT([no]) 36913498266Sopenharmony_ci fi 37013498266Sopenharmony_ci]) 37113498266Sopenharmony_ci 37213498266Sopenharmony_cidnl CURL_CONVERT_INCLUDE_TO_ISYSTEM 37313498266Sopenharmony_cidnl ------------------------------------------------- 37413498266Sopenharmony_cidnl Changes standard include paths present in CFLAGS 37513498266Sopenharmony_cidnl and CPPFLAGS into isystem include paths. This is 37613498266Sopenharmony_cidnl done to prevent GNUC from generating warnings on 37713498266Sopenharmony_cidnl headers from these locations, although on ancient 37813498266Sopenharmony_cidnl GNUC versions these warnings are not silenced. 37913498266Sopenharmony_ci 38013498266Sopenharmony_ciAC_DEFUN([CURL_CONVERT_INCLUDE_TO_ISYSTEM], [ 38113498266Sopenharmony_ci AC_REQUIRE([CURL_SHFUNC_SQUEEZE])dnl 38213498266Sopenharmony_ci AC_REQUIRE([CURL_CHECK_COMPILER])dnl 38313498266Sopenharmony_ci AC_MSG_CHECKING([convert -I options to -isystem]) 38413498266Sopenharmony_ci if test "$compiler_id" = "GNU_C" || 38513498266Sopenharmony_ci test "$compiler_id" = "CLANG"; then 38613498266Sopenharmony_ci AC_MSG_RESULT([yes]) 38713498266Sopenharmony_ci tmp_has_include="no" 38813498266Sopenharmony_ci tmp_chg_FLAGS="$CFLAGS" 38913498266Sopenharmony_ci for word1 in $tmp_chg_FLAGS; do 39013498266Sopenharmony_ci case "$word1" in 39113498266Sopenharmony_ci -I*) 39213498266Sopenharmony_ci tmp_has_include="yes" 39313498266Sopenharmony_ci ;; 39413498266Sopenharmony_ci esac 39513498266Sopenharmony_ci done 39613498266Sopenharmony_ci if test "$tmp_has_include" = "yes"; then 39713498266Sopenharmony_ci tmp_chg_FLAGS=`echo "$tmp_chg_FLAGS" | "$SED" 's/^-I/ -isystem /g'` 39813498266Sopenharmony_ci tmp_chg_FLAGS=`echo "$tmp_chg_FLAGS" | "$SED" 's/ -I/ -isystem /g'` 39913498266Sopenharmony_ci CFLAGS="$tmp_chg_FLAGS" 40013498266Sopenharmony_ci squeeze CFLAGS 40113498266Sopenharmony_ci fi 40213498266Sopenharmony_ci tmp_has_include="no" 40313498266Sopenharmony_ci tmp_chg_FLAGS="$CPPFLAGS" 40413498266Sopenharmony_ci for word1 in $tmp_chg_FLAGS; do 40513498266Sopenharmony_ci case "$word1" in 40613498266Sopenharmony_ci -I*) 40713498266Sopenharmony_ci tmp_has_include="yes" 40813498266Sopenharmony_ci ;; 40913498266Sopenharmony_ci esac 41013498266Sopenharmony_ci done 41113498266Sopenharmony_ci if test "$tmp_has_include" = "yes"; then 41213498266Sopenharmony_ci tmp_chg_FLAGS=`echo "$tmp_chg_FLAGS" | "$SED" 's/^-I/ -isystem /g'` 41313498266Sopenharmony_ci tmp_chg_FLAGS=`echo "$tmp_chg_FLAGS" | "$SED" 's/ -I/ -isystem /g'` 41413498266Sopenharmony_ci CPPFLAGS="$tmp_chg_FLAGS" 41513498266Sopenharmony_ci squeeze CPPFLAGS 41613498266Sopenharmony_ci fi 41713498266Sopenharmony_ci else 41813498266Sopenharmony_ci AC_MSG_RESULT([no]) 41913498266Sopenharmony_ci fi 42013498266Sopenharmony_ci]) 42113498266Sopenharmony_ci 42213498266Sopenharmony_ci 42313498266Sopenharmony_cidnl CURL_COMPILER_WORKS_IFELSE ([ACTION-IF-WORKS], [ACTION-IF-NOT-WORKS]) 42413498266Sopenharmony_cidnl ------------------------------------------------- 42513498266Sopenharmony_cidnl Verify if the C compiler seems to work with the 42613498266Sopenharmony_cidnl settings that are 'active' at the time the test 42713498266Sopenharmony_cidnl is performed. 42813498266Sopenharmony_ci 42913498266Sopenharmony_ciAC_DEFUN([CURL_COMPILER_WORKS_IFELSE], [ 43013498266Sopenharmony_ci dnl compilation capability verification 43113498266Sopenharmony_ci tmp_compiler_works="unknown" 43213498266Sopenharmony_ci AC_COMPILE_IFELSE([ 43313498266Sopenharmony_ci AC_LANG_PROGRAM([[ 43413498266Sopenharmony_ci ]],[[ 43513498266Sopenharmony_ci int i = 1; 43613498266Sopenharmony_ci return i; 43713498266Sopenharmony_ci ]]) 43813498266Sopenharmony_ci ],[ 43913498266Sopenharmony_ci tmp_compiler_works="yes" 44013498266Sopenharmony_ci ],[ 44113498266Sopenharmony_ci tmp_compiler_works="no" 44213498266Sopenharmony_ci echo " " >&6 44313498266Sopenharmony_ci sed 's/^/cc-fail: /' conftest.err >&6 44413498266Sopenharmony_ci echo " " >&6 44513498266Sopenharmony_ci ]) 44613498266Sopenharmony_ci dnl linking capability verification 44713498266Sopenharmony_ci if test "$tmp_compiler_works" = "yes"; then 44813498266Sopenharmony_ci AC_LINK_IFELSE([ 44913498266Sopenharmony_ci AC_LANG_PROGRAM([[ 45013498266Sopenharmony_ci ]],[[ 45113498266Sopenharmony_ci int i = 1; 45213498266Sopenharmony_ci return i; 45313498266Sopenharmony_ci ]]) 45413498266Sopenharmony_ci ],[ 45513498266Sopenharmony_ci tmp_compiler_works="yes" 45613498266Sopenharmony_ci ],[ 45713498266Sopenharmony_ci tmp_compiler_works="no" 45813498266Sopenharmony_ci echo " " >&6 45913498266Sopenharmony_ci sed 's/^/link-fail: /' conftest.err >&6 46013498266Sopenharmony_ci echo " " >&6 46113498266Sopenharmony_ci ]) 46213498266Sopenharmony_ci fi 46313498266Sopenharmony_ci dnl only do runtime verification when not cross-compiling 46413498266Sopenharmony_ci if test "x$cross_compiling" != "xyes" && 46513498266Sopenharmony_ci test "$tmp_compiler_works" = "yes"; then 46613498266Sopenharmony_ci CURL_RUN_IFELSE([ 46713498266Sopenharmony_ci AC_LANG_PROGRAM([[ 46813498266Sopenharmony_ci# ifdef __STDC__ 46913498266Sopenharmony_ci# include <stdlib.h> 47013498266Sopenharmony_ci# endif 47113498266Sopenharmony_ci ]],[[ 47213498266Sopenharmony_ci int i = 0; 47313498266Sopenharmony_ci exit(i); 47413498266Sopenharmony_ci ]]) 47513498266Sopenharmony_ci ],[ 47613498266Sopenharmony_ci tmp_compiler_works="yes" 47713498266Sopenharmony_ci ],[ 47813498266Sopenharmony_ci tmp_compiler_works="no" 47913498266Sopenharmony_ci echo " " >&6 48013498266Sopenharmony_ci echo "run-fail: test program exited with status $ac_status" >&6 48113498266Sopenharmony_ci echo " " >&6 48213498266Sopenharmony_ci ]) 48313498266Sopenharmony_ci fi 48413498266Sopenharmony_ci dnl branch upon test result 48513498266Sopenharmony_ci if test "$tmp_compiler_works" = "yes"; then 48613498266Sopenharmony_ci ifelse($1,,:,[$1]) 48713498266Sopenharmony_ci ifelse($2,,,[else 48813498266Sopenharmony_ci $2]) 48913498266Sopenharmony_ci fi 49013498266Sopenharmony_ci]) 49113498266Sopenharmony_ci 49213498266Sopenharmony_ci 49313498266Sopenharmony_cidnl CURL_SET_COMPILER_BASIC_OPTS 49413498266Sopenharmony_cidnl ------------------------------------------------- 49513498266Sopenharmony_cidnl Sets compiler specific options/flags which do not 49613498266Sopenharmony_cidnl depend on configure's debug, optimize or warnings 49713498266Sopenharmony_cidnl options. 49813498266Sopenharmony_ci 49913498266Sopenharmony_ciAC_DEFUN([CURL_SET_COMPILER_BASIC_OPTS], [ 50013498266Sopenharmony_ci AC_REQUIRE([CURL_CHECK_COMPILER])dnl 50113498266Sopenharmony_ci AC_REQUIRE([CURL_SHFUNC_SQUEEZE])dnl 50213498266Sopenharmony_ci # 50313498266Sopenharmony_ci if test "$compiler_id" != "unknown"; then 50413498266Sopenharmony_ci # 50513498266Sopenharmony_ci tmp_save_CPPFLAGS="$CPPFLAGS" 50613498266Sopenharmony_ci tmp_save_CFLAGS="$CFLAGS" 50713498266Sopenharmony_ci tmp_CPPFLAGS="" 50813498266Sopenharmony_ci tmp_CFLAGS="" 50913498266Sopenharmony_ci # 51013498266Sopenharmony_ci case "$compiler_id" in 51113498266Sopenharmony_ci # 51213498266Sopenharmony_ci CLANG) 51313498266Sopenharmony_ci # 51413498266Sopenharmony_ci dnl Disable warnings for unused arguments, otherwise clang will 51513498266Sopenharmony_ci dnl warn about compile-time arguments used during link-time, like 51613498266Sopenharmony_ci dnl -O and -g and -pedantic. 51713498266Sopenharmony_ci tmp_CFLAGS="$tmp_CFLAGS -Qunused-arguments" 51813498266Sopenharmony_ci ;; 51913498266Sopenharmony_ci # 52013498266Sopenharmony_ci DEC_C) 52113498266Sopenharmony_ci # 52213498266Sopenharmony_ci dnl Select strict ANSI C compiler mode 52313498266Sopenharmony_ci tmp_CFLAGS="$tmp_CFLAGS -std1" 52413498266Sopenharmony_ci dnl Turn off optimizer ANSI C aliasing rules 52513498266Sopenharmony_ci tmp_CFLAGS="$tmp_CFLAGS -noansi_alias" 52613498266Sopenharmony_ci dnl Generate warnings for missing function prototypes 52713498266Sopenharmony_ci tmp_CFLAGS="$tmp_CFLAGS -warnprotos" 52813498266Sopenharmony_ci dnl Change some warnings into fatal errors 52913498266Sopenharmony_ci tmp_CFLAGS="$tmp_CFLAGS -msg_fatal toofewargs,toomanyargs" 53013498266Sopenharmony_ci ;; 53113498266Sopenharmony_ci # 53213498266Sopenharmony_ci GNU_C) 53313498266Sopenharmony_ci # 53413498266Sopenharmony_ci dnl turn implicit-function-declaration warning into error, 53513498266Sopenharmony_ci dnl at least gcc 2.95 and later support this 53613498266Sopenharmony_ci if test "$compiler_num" -ge "295"; then 53713498266Sopenharmony_ci tmp_CFLAGS="$tmp_CFLAGS -Werror-implicit-function-declaration" 53813498266Sopenharmony_ci fi 53913498266Sopenharmony_ci ;; 54013498266Sopenharmony_ci # 54113498266Sopenharmony_ci HP_UX_C) 54213498266Sopenharmony_ci # 54313498266Sopenharmony_ci dnl Disallow run-time dereferencing of null pointers 54413498266Sopenharmony_ci tmp_CFLAGS="$tmp_CFLAGS -z" 54513498266Sopenharmony_ci dnl Disable some remarks 54613498266Sopenharmony_ci dnl #4227: padding struct with n bytes to align member 54713498266Sopenharmony_ci dnl #4255: padding size of struct with n bytes to alignment boundary 54813498266Sopenharmony_ci tmp_CFLAGS="$tmp_CFLAGS +W 4227,4255" 54913498266Sopenharmony_ci ;; 55013498266Sopenharmony_ci # 55113498266Sopenharmony_ci IBM_C) 55213498266Sopenharmony_ci # 55313498266Sopenharmony_ci dnl Ensure that compiler optimizations are always thread-safe. 55413498266Sopenharmony_ci tmp_CPPFLAGS="$tmp_CPPFLAGS -qthreaded" 55513498266Sopenharmony_ci dnl Disable type based strict aliasing optimizations, using worst 55613498266Sopenharmony_ci dnl case aliasing assumptions when compiling. Type based aliasing 55713498266Sopenharmony_ci dnl would restrict the lvalues that could be safely used to access 55813498266Sopenharmony_ci dnl a data object. 55913498266Sopenharmony_ci tmp_CPPFLAGS="$tmp_CPPFLAGS -qnoansialias" 56013498266Sopenharmony_ci dnl Force compiler to stop after the compilation phase, without 56113498266Sopenharmony_ci dnl generating an object code file when compilation has errors. 56213498266Sopenharmony_ci tmp_CPPFLAGS="$tmp_CPPFLAGS -qhalt=e" 56313498266Sopenharmony_ci ;; 56413498266Sopenharmony_ci # 56513498266Sopenharmony_ci INTEL_UNIX_C) 56613498266Sopenharmony_ci # 56713498266Sopenharmony_ci dnl On unix this compiler uses gcc's header files, so 56813498266Sopenharmony_ci dnl we select ANSI C89 dialect plus GNU extensions. 56913498266Sopenharmony_ci tmp_CFLAGS="$tmp_CFLAGS -std=gnu89" 57013498266Sopenharmony_ci dnl Change some warnings into errors 57113498266Sopenharmony_ci dnl #140: too many arguments in function call 57213498266Sopenharmony_ci dnl #147: declaration is incompatible with 'previous one' 57313498266Sopenharmony_ci dnl #165: too few arguments in function call 57413498266Sopenharmony_ci dnl #266: function declared implicitly 57513498266Sopenharmony_ci tmp_CPPFLAGS="$tmp_CPPFLAGS -diag-error 140,147,165,266" 57613498266Sopenharmony_ci dnl Disable some remarks 57713498266Sopenharmony_ci dnl #279: controlling expression is constant 57813498266Sopenharmony_ci dnl #981: operands are evaluated in unspecified order 57913498266Sopenharmony_ci dnl #1025: zero extending result of unary operation 58013498266Sopenharmony_ci dnl #1469: "cc" clobber ignored 58113498266Sopenharmony_ci dnl #2259: non-pointer conversion from X to Y may lose significant bits 58213498266Sopenharmony_ci tmp_CPPFLAGS="$tmp_CPPFLAGS -diag-disable 279,981,1025,1469,2259" 58313498266Sopenharmony_ci ;; 58413498266Sopenharmony_ci # 58513498266Sopenharmony_ci INTEL_WINDOWS_C) 58613498266Sopenharmony_ci # 58713498266Sopenharmony_ci dnl Placeholder 58813498266Sopenharmony_ci tmp_CFLAGS="$tmp_CFLAGS" 58913498266Sopenharmony_ci ;; 59013498266Sopenharmony_ci # 59113498266Sopenharmony_ci SGI_MIPS_C) 59213498266Sopenharmony_ci # 59313498266Sopenharmony_ci dnl Placeholder 59413498266Sopenharmony_ci tmp_CFLAGS="$tmp_CFLAGS" 59513498266Sopenharmony_ci ;; 59613498266Sopenharmony_ci # 59713498266Sopenharmony_ci SGI_MIPSPRO_C) 59813498266Sopenharmony_ci # 59913498266Sopenharmony_ci dnl Placeholder 60013498266Sopenharmony_ci tmp_CFLAGS="$tmp_CFLAGS" 60113498266Sopenharmony_ci ;; 60213498266Sopenharmony_ci # 60313498266Sopenharmony_ci SUNPRO_C) 60413498266Sopenharmony_ci # 60513498266Sopenharmony_ci dnl Placeholder 60613498266Sopenharmony_ci tmp_CFLAGS="$tmp_CFLAGS" 60713498266Sopenharmony_ci ;; 60813498266Sopenharmony_ci # 60913498266Sopenharmony_ci TINY_C) 61013498266Sopenharmony_ci # 61113498266Sopenharmony_ci dnl Placeholder 61213498266Sopenharmony_ci tmp_CFLAGS="$tmp_CFLAGS" 61313498266Sopenharmony_ci ;; 61413498266Sopenharmony_ci # 61513498266Sopenharmony_ci esac 61613498266Sopenharmony_ci # 61713498266Sopenharmony_ci squeeze tmp_CPPFLAGS 61813498266Sopenharmony_ci squeeze tmp_CFLAGS 61913498266Sopenharmony_ci # 62013498266Sopenharmony_ci if test ! -z "$tmp_CFLAGS" || test ! -z "$tmp_CPPFLAGS"; then 62113498266Sopenharmony_ci AC_MSG_CHECKING([if compiler accepts some basic options]) 62213498266Sopenharmony_ci CPPFLAGS="$tmp_save_CPPFLAGS $tmp_CPPFLAGS" 62313498266Sopenharmony_ci CFLAGS="$tmp_save_CFLAGS $tmp_CFLAGS" 62413498266Sopenharmony_ci squeeze CPPFLAGS 62513498266Sopenharmony_ci squeeze CFLAGS 62613498266Sopenharmony_ci CURL_COMPILER_WORKS_IFELSE([ 62713498266Sopenharmony_ci AC_MSG_RESULT([yes]) 62813498266Sopenharmony_ci AC_MSG_NOTICE([compiler options added: $tmp_CFLAGS $tmp_CPPFLAGS]) 62913498266Sopenharmony_ci ],[ 63013498266Sopenharmony_ci AC_MSG_RESULT([no]) 63113498266Sopenharmony_ci AC_MSG_WARN([compiler options rejected: $tmp_CFLAGS $tmp_CPPFLAGS]) 63213498266Sopenharmony_ci dnl restore initial settings 63313498266Sopenharmony_ci CPPFLAGS="$tmp_save_CPPFLAGS" 63413498266Sopenharmony_ci CFLAGS="$tmp_save_CFLAGS" 63513498266Sopenharmony_ci ]) 63613498266Sopenharmony_ci fi 63713498266Sopenharmony_ci # 63813498266Sopenharmony_ci fi 63913498266Sopenharmony_ci]) 64013498266Sopenharmony_ci 64113498266Sopenharmony_ci 64213498266Sopenharmony_cidnl CURL_SET_COMPILER_DEBUG_OPTS 64313498266Sopenharmony_cidnl ------------------------------------------------- 64413498266Sopenharmony_cidnl Sets compiler specific options/flags which depend 64513498266Sopenharmony_cidnl on configure's debug option. 64613498266Sopenharmony_ci 64713498266Sopenharmony_ciAC_DEFUN([CURL_SET_COMPILER_DEBUG_OPTS], [ 64813498266Sopenharmony_ci AC_REQUIRE([CURL_CHECK_OPTION_DEBUG])dnl 64913498266Sopenharmony_ci AC_REQUIRE([CURL_CHECK_COMPILER])dnl 65013498266Sopenharmony_ci AC_REQUIRE([CURL_SHFUNC_SQUEEZE])dnl 65113498266Sopenharmony_ci # 65213498266Sopenharmony_ci if test "$compiler_id" != "unknown"; then 65313498266Sopenharmony_ci # 65413498266Sopenharmony_ci tmp_save_CFLAGS="$CFLAGS" 65513498266Sopenharmony_ci tmp_save_CPPFLAGS="$CPPFLAGS" 65613498266Sopenharmony_ci # 65713498266Sopenharmony_ci tmp_options="" 65813498266Sopenharmony_ci tmp_CFLAGS="$CFLAGS" 65913498266Sopenharmony_ci tmp_CPPFLAGS="$CPPFLAGS" 66013498266Sopenharmony_ci # 66113498266Sopenharmony_ci if test "$want_debug" = "yes"; then 66213498266Sopenharmony_ci AC_MSG_CHECKING([if compiler accepts debug enabling options]) 66313498266Sopenharmony_ci tmp_options="$flags_dbg_yes" 66413498266Sopenharmony_ci fi 66513498266Sopenharmony_ci # 66613498266Sopenharmony_ci if test "$flags_prefer_cppflags" = "yes"; then 66713498266Sopenharmony_ci CPPFLAGS="$tmp_CPPFLAGS $tmp_options" 66813498266Sopenharmony_ci CFLAGS="$tmp_CFLAGS" 66913498266Sopenharmony_ci else 67013498266Sopenharmony_ci CPPFLAGS="$tmp_CPPFLAGS" 67113498266Sopenharmony_ci CFLAGS="$tmp_CFLAGS $tmp_options" 67213498266Sopenharmony_ci fi 67313498266Sopenharmony_ci squeeze CPPFLAGS 67413498266Sopenharmony_ci squeeze CFLAGS 67513498266Sopenharmony_ci fi 67613498266Sopenharmony_ci]) 67713498266Sopenharmony_ci 67813498266Sopenharmony_ci 67913498266Sopenharmony_cidnl CURL_SET_COMPILER_OPTIMIZE_OPTS 68013498266Sopenharmony_cidnl ------------------------------------------------- 68113498266Sopenharmony_cidnl Sets compiler specific options/flags which depend 68213498266Sopenharmony_cidnl on configure's optimize option. 68313498266Sopenharmony_ci 68413498266Sopenharmony_ciAC_DEFUN([CURL_SET_COMPILER_OPTIMIZE_OPTS], [ 68513498266Sopenharmony_ci AC_REQUIRE([CURL_CHECK_OPTION_OPTIMIZE])dnl 68613498266Sopenharmony_ci AC_REQUIRE([CURL_CHECK_COMPILER])dnl 68713498266Sopenharmony_ci AC_REQUIRE([CURL_SHFUNC_SQUEEZE])dnl 68813498266Sopenharmony_ci # 68913498266Sopenharmony_ci if test "$compiler_id" != "unknown"; then 69013498266Sopenharmony_ci # 69113498266Sopenharmony_ci tmp_save_CFLAGS="$CFLAGS" 69213498266Sopenharmony_ci tmp_save_CPPFLAGS="$CPPFLAGS" 69313498266Sopenharmony_ci # 69413498266Sopenharmony_ci tmp_options="" 69513498266Sopenharmony_ci tmp_CFLAGS="$CFLAGS" 69613498266Sopenharmony_ci tmp_CPPFLAGS="$CPPFLAGS" 69713498266Sopenharmony_ci honor_optimize_option="yes" 69813498266Sopenharmony_ci # 69913498266Sopenharmony_ci dnl If optimization request setting has not been explicitly specified, 70013498266Sopenharmony_ci dnl it has been derived from the debug setting and initially assumed. 70113498266Sopenharmony_ci dnl This initially assumed optimizer setting will finally be ignored 70213498266Sopenharmony_ci dnl if CFLAGS or CPPFLAGS already hold optimizer flags. This implies 70313498266Sopenharmony_ci dnl that an initially assumed optimizer setting might not be honored. 70413498266Sopenharmony_ci # 70513498266Sopenharmony_ci if test "$want_optimize" = "assume_no" || 70613498266Sopenharmony_ci test "$want_optimize" = "assume_yes"; then 70713498266Sopenharmony_ci AC_MSG_CHECKING([if compiler optimizer assumed setting might be used]) 70813498266Sopenharmony_ci CURL_VAR_MATCH_IFELSE([tmp_CFLAGS],[$flags_opt_all],[ 70913498266Sopenharmony_ci honor_optimize_option="no" 71013498266Sopenharmony_ci ]) 71113498266Sopenharmony_ci CURL_VAR_MATCH_IFELSE([tmp_CPPFLAGS],[$flags_opt_all],[ 71213498266Sopenharmony_ci honor_optimize_option="no" 71313498266Sopenharmony_ci ]) 71413498266Sopenharmony_ci AC_MSG_RESULT([$honor_optimize_option]) 71513498266Sopenharmony_ci if test "$honor_optimize_option" = "yes"; then 71613498266Sopenharmony_ci if test "$want_optimize" = "assume_yes"; then 71713498266Sopenharmony_ci want_optimize="yes" 71813498266Sopenharmony_ci fi 71913498266Sopenharmony_ci if test "$want_optimize" = "assume_no"; then 72013498266Sopenharmony_ci want_optimize="no" 72113498266Sopenharmony_ci fi 72213498266Sopenharmony_ci fi 72313498266Sopenharmony_ci fi 72413498266Sopenharmony_ci # 72513498266Sopenharmony_ci if test "$honor_optimize_option" = "yes"; then 72613498266Sopenharmony_ci CURL_VAR_STRIP([tmp_CFLAGS],[$flags_opt_all]) 72713498266Sopenharmony_ci CURL_VAR_STRIP([tmp_CPPFLAGS],[$flags_opt_all]) 72813498266Sopenharmony_ci if test "$want_optimize" = "yes"; then 72913498266Sopenharmony_ci AC_MSG_CHECKING([if compiler accepts optimizer enabling options]) 73013498266Sopenharmony_ci tmp_options="$flags_opt_yes" 73113498266Sopenharmony_ci fi 73213498266Sopenharmony_ci if test "$want_optimize" = "no"; then 73313498266Sopenharmony_ci AC_MSG_CHECKING([if compiler accepts optimizer disabling options]) 73413498266Sopenharmony_ci tmp_options="$flags_opt_off" 73513498266Sopenharmony_ci fi 73613498266Sopenharmony_ci if test "$flags_prefer_cppflags" = "yes"; then 73713498266Sopenharmony_ci CPPFLAGS="$tmp_CPPFLAGS $tmp_options" 73813498266Sopenharmony_ci CFLAGS="$tmp_CFLAGS" 73913498266Sopenharmony_ci else 74013498266Sopenharmony_ci CPPFLAGS="$tmp_CPPFLAGS" 74113498266Sopenharmony_ci CFLAGS="$tmp_CFLAGS $tmp_options" 74213498266Sopenharmony_ci fi 74313498266Sopenharmony_ci squeeze CPPFLAGS 74413498266Sopenharmony_ci squeeze CFLAGS 74513498266Sopenharmony_ci CURL_COMPILER_WORKS_IFELSE([ 74613498266Sopenharmony_ci AC_MSG_RESULT([yes]) 74713498266Sopenharmony_ci AC_MSG_NOTICE([compiler options added: $tmp_options]) 74813498266Sopenharmony_ci ],[ 74913498266Sopenharmony_ci AC_MSG_RESULT([no]) 75013498266Sopenharmony_ci AC_MSG_WARN([compiler options rejected: $tmp_options]) 75113498266Sopenharmony_ci dnl restore initial settings 75213498266Sopenharmony_ci CPPFLAGS="$tmp_save_CPPFLAGS" 75313498266Sopenharmony_ci CFLAGS="$tmp_save_CFLAGS" 75413498266Sopenharmony_ci ]) 75513498266Sopenharmony_ci fi 75613498266Sopenharmony_ci # 75713498266Sopenharmony_ci fi 75813498266Sopenharmony_ci]) 75913498266Sopenharmony_ci 76013498266Sopenharmony_ci 76113498266Sopenharmony_cidnl CURL_SET_COMPILER_WARNING_OPTS 76213498266Sopenharmony_cidnl ------------------------------------------------- 76313498266Sopenharmony_cidnl Sets compiler options/flags which depend on 76413498266Sopenharmony_cidnl configure's warnings given option. 76513498266Sopenharmony_ci 76613498266Sopenharmony_ciAC_DEFUN([CURL_SET_COMPILER_WARNING_OPTS], [ 76713498266Sopenharmony_ci AC_REQUIRE([CURL_CHECK_OPTION_WARNINGS])dnl 76813498266Sopenharmony_ci AC_REQUIRE([CURL_CHECK_COMPILER])dnl 76913498266Sopenharmony_ci AC_REQUIRE([CURL_SHFUNC_SQUEEZE])dnl 77013498266Sopenharmony_ci # 77113498266Sopenharmony_ci if test "$compiler_id" != "unknown"; then 77213498266Sopenharmony_ci # 77313498266Sopenharmony_ci tmp_save_CPPFLAGS="$CPPFLAGS" 77413498266Sopenharmony_ci tmp_save_CFLAGS="$CFLAGS" 77513498266Sopenharmony_ci tmp_CPPFLAGS="" 77613498266Sopenharmony_ci tmp_CFLAGS="" 77713498266Sopenharmony_ci # 77813498266Sopenharmony_ci case "$compiler_id" in 77913498266Sopenharmony_ci # 78013498266Sopenharmony_ci CLANG) 78113498266Sopenharmony_ci # 78213498266Sopenharmony_ci if test "$want_warnings" = "yes"; then 78313498266Sopenharmony_ci tmp_CFLAGS="$tmp_CFLAGS -pedantic" 78413498266Sopenharmony_ci CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [all extra]) 78513498266Sopenharmony_ci CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [pointer-arith write-strings]) 78613498266Sopenharmony_ci CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [shadow]) 78713498266Sopenharmony_ci CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [inline nested-externs]) 78813498266Sopenharmony_ci CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [missing-declarations]) 78913498266Sopenharmony_ci CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [missing-prototypes]) 79013498266Sopenharmony_ci tmp_CFLAGS="$tmp_CFLAGS -Wno-long-long" 79113498266Sopenharmony_ci CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [float-equal]) 79213498266Sopenharmony_ci CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [sign-compare]) 79313498266Sopenharmony_ci tmp_CFLAGS="$tmp_CFLAGS -Wno-multichar" 79413498266Sopenharmony_ci CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [undef]) 79513498266Sopenharmony_ci tmp_CFLAGS="$tmp_CFLAGS -Wno-format-nonliteral" 79613498266Sopenharmony_ci CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [endif-labels strict-prototypes]) 79713498266Sopenharmony_ci CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [declaration-after-statement]) 79813498266Sopenharmony_ci CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [cast-align]) 79913498266Sopenharmony_ci tmp_CFLAGS="$tmp_CFLAGS -Wno-system-headers" 80013498266Sopenharmony_ci CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [shorten-64-to-32]) 80113498266Sopenharmony_ci # 80213498266Sopenharmony_ci dnl Only clang 1.1 or later 80313498266Sopenharmony_ci if test "$compiler_num" -ge "101"; then 80413498266Sopenharmony_ci CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [unused]) 80513498266Sopenharmony_ci fi 80613498266Sopenharmony_ci # 80713498266Sopenharmony_ci dnl Only clang 2.7 or later 80813498266Sopenharmony_ci if test "$compiler_num" -ge "207"; then 80913498266Sopenharmony_ci CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [address]) 81013498266Sopenharmony_ci CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [attributes]) 81113498266Sopenharmony_ci CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [bad-function-cast]) 81213498266Sopenharmony_ci CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [conversion]) 81313498266Sopenharmony_ci CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [div-by-zero format-security]) 81413498266Sopenharmony_ci CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [empty-body]) 81513498266Sopenharmony_ci CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [missing-field-initializers]) 81613498266Sopenharmony_ci CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [missing-noreturn]) 81713498266Sopenharmony_ci CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [old-style-definition]) 81813498266Sopenharmony_ci CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [redundant-decls]) 81913498266Sopenharmony_ci # CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [switch-enum]) # Not used because this basically disallows default case 82013498266Sopenharmony_ci CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [type-limits]) 82113498266Sopenharmony_ci # CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [unused-macros]) # Not practical 82213498266Sopenharmony_ci CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [unreachable-code unused-parameter]) 82313498266Sopenharmony_ci fi 82413498266Sopenharmony_ci # 82513498266Sopenharmony_ci dnl Only clang 2.8 or later 82613498266Sopenharmony_ci if test "$compiler_num" -ge "208"; then 82713498266Sopenharmony_ci CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [ignored-qualifiers]) 82813498266Sopenharmony_ci CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [vla]) 82913498266Sopenharmony_ci fi 83013498266Sopenharmony_ci # 83113498266Sopenharmony_ci dnl Only clang 2.9 or later 83213498266Sopenharmony_ci if test "$compiler_num" -ge "209"; then 83313498266Sopenharmony_ci CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [sign-conversion]) 83413498266Sopenharmony_ci tmp_CFLAGS="$tmp_CFLAGS -Wno-error=sign-conversion" # FIXME 83513498266Sopenharmony_ci CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [shift-sign-overflow]) 83613498266Sopenharmony_ci # CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [padded]) # Not used because we cannot change public structs 83713498266Sopenharmony_ci fi 83813498266Sopenharmony_ci # 83913498266Sopenharmony_ci dnl Only clang 3.0 or later 84013498266Sopenharmony_ci if test "$compiler_num" -ge "300"; then 84113498266Sopenharmony_ci CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [language-extension-token]) 84213498266Sopenharmony_ci tmp_CFLAGS="$tmp_CFLAGS -Wformat=2" 84313498266Sopenharmony_ci fi 84413498266Sopenharmony_ci # 84513498266Sopenharmony_ci dnl Only clang 3.2 or later 84613498266Sopenharmony_ci if test "$compiler_num" -ge "302"; then 84713498266Sopenharmony_ci CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [enum-conversion]) 84813498266Sopenharmony_ci CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [sometimes-uninitialized]) 84913498266Sopenharmony_ci case $host_os in 85013498266Sopenharmony_ci cygwin* | mingw*) 85113498266Sopenharmony_ci dnl skip missing-variable-declarations warnings for cygwin and 85213498266Sopenharmony_ci dnl mingw because the libtool wrapper executable causes them 85313498266Sopenharmony_ci ;; 85413498266Sopenharmony_ci *) 85513498266Sopenharmony_ci CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [missing-variable-declarations]) 85613498266Sopenharmony_ci ;; 85713498266Sopenharmony_ci esac 85813498266Sopenharmony_ci fi 85913498266Sopenharmony_ci # 86013498266Sopenharmony_ci dnl Only clang 3.4 or later 86113498266Sopenharmony_ci if test "$compiler_num" -ge "304"; then 86213498266Sopenharmony_ci CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [header-guard]) 86313498266Sopenharmony_ci CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [unused-const-variable]) 86413498266Sopenharmony_ci fi 86513498266Sopenharmony_ci # 86613498266Sopenharmony_ci dnl Only clang 3.5 or later 86713498266Sopenharmony_ci if test "$compiler_num" -ge "305"; then 86813498266Sopenharmony_ci CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [pragmas]) 86913498266Sopenharmony_ci CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [unreachable-code-break]) 87013498266Sopenharmony_ci fi 87113498266Sopenharmony_ci # 87213498266Sopenharmony_ci dnl Only clang 3.6 or later 87313498266Sopenharmony_ci if test "$compiler_num" -ge "306"; then 87413498266Sopenharmony_ci CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [double-promotion]) 87513498266Sopenharmony_ci fi 87613498266Sopenharmony_ci # 87713498266Sopenharmony_ci dnl Only clang 3.9 or later 87813498266Sopenharmony_ci if test "$compiler_num" -ge "309"; then 87913498266Sopenharmony_ci CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [comma]) 88013498266Sopenharmony_ci # avoid the varargs warning, fixed in 4.0 88113498266Sopenharmony_ci # https://bugs.llvm.org/show_bug.cgi?id=29140 88213498266Sopenharmony_ci if test "$compiler_num" -lt "400"; then 88313498266Sopenharmony_ci tmp_CFLAGS="$tmp_CFLAGS -Wno-varargs" 88413498266Sopenharmony_ci fi 88513498266Sopenharmony_ci fi 88613498266Sopenharmony_ci dnl clang 7 or later 88713498266Sopenharmony_ci if test "$compiler_num" -ge "700"; then 88813498266Sopenharmony_ci CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [assign-enum]) 88913498266Sopenharmony_ci CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [extra-semi-stmt]) 89013498266Sopenharmony_ci fi 89113498266Sopenharmony_ci dnl clang 10 or later 89213498266Sopenharmony_ci if test "$compiler_num" -ge "1000"; then 89313498266Sopenharmony_ci tmp_CFLAGS="$tmp_CFLAGS -Wimplicit-fallthrough" # we have silencing markup for clang 10.0 and above only 89413498266Sopenharmony_ci fi 89513498266Sopenharmony_ci fi 89613498266Sopenharmony_ci dnl Disable pointer to bool conversion warnings since they cause 89713498266Sopenharmony_ci dnl lib/securetransp.c cause several warnings for checks we want. 89813498266Sopenharmony_ci dnl This option should be placed after -Wconversion. 89913498266Sopenharmony_ci tmp_CFLAGS="$tmp_CFLAGS -Wno-pointer-bool-conversion" 90013498266Sopenharmony_ci ;; 90113498266Sopenharmony_ci # 90213498266Sopenharmony_ci DEC_C) 90313498266Sopenharmony_ci # 90413498266Sopenharmony_ci if test "$want_warnings" = "yes"; then 90513498266Sopenharmony_ci dnl Select a higher warning level than default level2 90613498266Sopenharmony_ci tmp_CFLAGS="$tmp_CFLAGS -msg_enable level3" 90713498266Sopenharmony_ci fi 90813498266Sopenharmony_ci ;; 90913498266Sopenharmony_ci # 91013498266Sopenharmony_ci GNU_C) 91113498266Sopenharmony_ci # 91213498266Sopenharmony_ci if test "$want_warnings" = "yes"; then 91313498266Sopenharmony_ci # 91413498266Sopenharmony_ci dnl Do not enable -pedantic when cross-compiling with a gcc older 91513498266Sopenharmony_ci dnl than 3.0, to avoid warnings from third party system headers. 91613498266Sopenharmony_ci if test "x$cross_compiling" != "xyes" || 91713498266Sopenharmony_ci test "$compiler_num" -ge "300"; then 91813498266Sopenharmony_ci tmp_CFLAGS="$tmp_CFLAGS -pedantic" 91913498266Sopenharmony_ci fi 92013498266Sopenharmony_ci # 92113498266Sopenharmony_ci dnl Set of options we believe *ALL* gcc versions support: 92213498266Sopenharmony_ci CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [all]) 92313498266Sopenharmony_ci tmp_CFLAGS="$tmp_CFLAGS -W" 92413498266Sopenharmony_ci # 92513498266Sopenharmony_ci dnl Only gcc 1.4 or later 92613498266Sopenharmony_ci if test "$compiler_num" -ge "104"; then 92713498266Sopenharmony_ci CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [pointer-arith write-strings]) 92813498266Sopenharmony_ci dnl If not cross-compiling with a gcc older than 3.0 92913498266Sopenharmony_ci if test "x$cross_compiling" != "xyes" || 93013498266Sopenharmony_ci test "$compiler_num" -ge "300"; then 93113498266Sopenharmony_ci CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [unused shadow]) 93213498266Sopenharmony_ci fi 93313498266Sopenharmony_ci fi 93413498266Sopenharmony_ci # 93513498266Sopenharmony_ci dnl Only gcc 2.7 or later 93613498266Sopenharmony_ci if test "$compiler_num" -ge "207"; then 93713498266Sopenharmony_ci CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [inline nested-externs]) 93813498266Sopenharmony_ci dnl If not cross-compiling with a gcc older than 3.0 93913498266Sopenharmony_ci if test "x$cross_compiling" != "xyes" || 94013498266Sopenharmony_ci test "$compiler_num" -ge "300"; then 94113498266Sopenharmony_ci CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [missing-declarations]) 94213498266Sopenharmony_ci CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [missing-prototypes]) 94313498266Sopenharmony_ci fi 94413498266Sopenharmony_ci fi 94513498266Sopenharmony_ci # 94613498266Sopenharmony_ci dnl Only gcc 2.95 or later 94713498266Sopenharmony_ci if test "$compiler_num" -ge "295"; then 94813498266Sopenharmony_ci tmp_CFLAGS="$tmp_CFLAGS -Wno-long-long" 94913498266Sopenharmony_ci CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [bad-function-cast]) 95013498266Sopenharmony_ci fi 95113498266Sopenharmony_ci # 95213498266Sopenharmony_ci dnl Only gcc 2.96 or later 95313498266Sopenharmony_ci if test "$compiler_num" -ge "296"; then 95413498266Sopenharmony_ci CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [float-equal]) 95513498266Sopenharmony_ci tmp_CFLAGS="$tmp_CFLAGS -Wno-multichar" 95613498266Sopenharmony_ci CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [sign-compare]) 95713498266Sopenharmony_ci dnl -Wundef used only if gcc is 2.96 or later since we get 95813498266Sopenharmony_ci dnl lots of "`_POSIX_C_SOURCE' is not defined" in system 95913498266Sopenharmony_ci dnl headers with gcc 2.95.4 on FreeBSD 4.9 96013498266Sopenharmony_ci CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [undef]) 96113498266Sopenharmony_ci fi 96213498266Sopenharmony_ci # 96313498266Sopenharmony_ci dnl Only gcc 2.97 or later 96413498266Sopenharmony_ci if test "$compiler_num" -ge "297"; then 96513498266Sopenharmony_ci tmp_CFLAGS="$tmp_CFLAGS -Wno-format-nonliteral" 96613498266Sopenharmony_ci fi 96713498266Sopenharmony_ci # 96813498266Sopenharmony_ci dnl Only gcc 3.0 or later 96913498266Sopenharmony_ci if test "$compiler_num" -ge "300"; then 97013498266Sopenharmony_ci dnl -Wunreachable-code seems totally unreliable on my gcc 3.3.2 on 97113498266Sopenharmony_ci dnl on i686-Linux as it gives us heaps with false positives. 97213498266Sopenharmony_ci dnl Also, on gcc 4.0.X it is totally unbearable and complains all 97313498266Sopenharmony_ci dnl over making it unusable for generic purposes. Let's not use it. 97413498266Sopenharmony_ci tmp_CFLAGS="$tmp_CFLAGS" 97513498266Sopenharmony_ci fi 97613498266Sopenharmony_ci # 97713498266Sopenharmony_ci dnl Only gcc 3.3 or later 97813498266Sopenharmony_ci if test "$compiler_num" -ge "303"; then 97913498266Sopenharmony_ci CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [endif-labels strict-prototypes]) 98013498266Sopenharmony_ci fi 98113498266Sopenharmony_ci # 98213498266Sopenharmony_ci dnl Only gcc 3.4 or later 98313498266Sopenharmony_ci if test "$compiler_num" -ge "304"; then 98413498266Sopenharmony_ci CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [declaration-after-statement]) 98513498266Sopenharmony_ci CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [old-style-definition]) 98613498266Sopenharmony_ci fi 98713498266Sopenharmony_ci # 98813498266Sopenharmony_ci dnl Only gcc 4.0 or later 98913498266Sopenharmony_ci if test "$compiler_num" -ge "400"; then 99013498266Sopenharmony_ci tmp_CFLAGS="$tmp_CFLAGS -Wstrict-aliasing=3" 99113498266Sopenharmony_ci fi 99213498266Sopenharmony_ci # 99313498266Sopenharmony_ci dnl Only gcc 4.1 or later 99413498266Sopenharmony_ci if test "$compiler_num" -ge "401"; then 99513498266Sopenharmony_ci CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [attributes]) 99613498266Sopenharmony_ci CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [div-by-zero format-security]) 99713498266Sopenharmony_ci CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [missing-field-initializers]) 99813498266Sopenharmony_ci case $host in 99913498266Sopenharmony_ci *-*-msys*) 100013498266Sopenharmony_ci ;; 100113498266Sopenharmony_ci *) 100213498266Sopenharmony_ci CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [missing-noreturn]) # Seen to clash with libtool-generated stub code 100313498266Sopenharmony_ci ;; 100413498266Sopenharmony_ci esac 100513498266Sopenharmony_ci CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [unreachable-code unused-parameter]) 100613498266Sopenharmony_ci # CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [padded]) # Not used because we cannot change public structs 100713498266Sopenharmony_ci CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [pragmas]) 100813498266Sopenharmony_ci CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [redundant-decls]) 100913498266Sopenharmony_ci # CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [switch-enum]) # Not used because this basically disallows default case 101013498266Sopenharmony_ci # CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [unused-macros]) # Not practical 101113498266Sopenharmony_ci fi 101213498266Sopenharmony_ci # 101313498266Sopenharmony_ci dnl Only gcc 4.2 or later 101413498266Sopenharmony_ci if test "$compiler_num" -ge "402"; then 101513498266Sopenharmony_ci CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [cast-align]) 101613498266Sopenharmony_ci fi 101713498266Sopenharmony_ci # 101813498266Sopenharmony_ci dnl Only gcc 4.3 or later 101913498266Sopenharmony_ci if test "$compiler_num" -ge "403"; then 102013498266Sopenharmony_ci CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [address]) 102113498266Sopenharmony_ci CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [type-limits old-style-declaration]) 102213498266Sopenharmony_ci CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [missing-parameter-type empty-body]) 102313498266Sopenharmony_ci CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [clobbered ignored-qualifiers]) 102413498266Sopenharmony_ci CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [conversion trampolines]) 102513498266Sopenharmony_ci CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [sign-conversion]) 102613498266Sopenharmony_ci tmp_CFLAGS="$tmp_CFLAGS -Wno-error=sign-conversion" # FIXME 102713498266Sopenharmony_ci CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [vla]) 102813498266Sopenharmony_ci dnl required for -Warray-bounds, included in -Wall 102913498266Sopenharmony_ci tmp_CFLAGS="$tmp_CFLAGS -ftree-vrp" 103013498266Sopenharmony_ci fi 103113498266Sopenharmony_ci # 103213498266Sopenharmony_ci dnl Only gcc 4.5 or later 103313498266Sopenharmony_ci if test "$compiler_num" -ge "405"; then 103413498266Sopenharmony_ci dnl Only windows targets 103513498266Sopenharmony_ci if test "$curl_cv_native_windows" = "yes"; then 103613498266Sopenharmony_ci tmp_CFLAGS="$tmp_CFLAGS -Wno-pedantic-ms-format" 103713498266Sopenharmony_ci fi 103813498266Sopenharmony_ci fi 103913498266Sopenharmony_ci # 104013498266Sopenharmony_ci dnl Only gcc 4.6 or later 104113498266Sopenharmony_ci if test "$compiler_num" -ge "406"; then 104213498266Sopenharmony_ci CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [double-promotion]) 104313498266Sopenharmony_ci fi 104413498266Sopenharmony_ci # 104513498266Sopenharmony_ci dnl only gcc 4.8 or later 104613498266Sopenharmony_ci if test "$compiler_num" -ge "408"; then 104713498266Sopenharmony_ci tmp_CFLAGS="$tmp_CFLAGS -Wformat=2" 104813498266Sopenharmony_ci fi 104913498266Sopenharmony_ci # 105013498266Sopenharmony_ci dnl Only gcc 5 or later 105113498266Sopenharmony_ci if test "$compiler_num" -ge "500"; then 105213498266Sopenharmony_ci tmp_CFLAGS="$tmp_CFLAGS -Warray-bounds=2" 105313498266Sopenharmony_ci fi 105413498266Sopenharmony_ci # 105513498266Sopenharmony_ci dnl Only gcc 6 or later 105613498266Sopenharmony_ci if test "$compiler_num" -ge "600"; then 105713498266Sopenharmony_ci CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [shift-negative-value]) 105813498266Sopenharmony_ci tmp_CFLAGS="$tmp_CFLAGS -Wshift-overflow=2" 105913498266Sopenharmony_ci CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [null-dereference]) 106013498266Sopenharmony_ci tmp_CFLAGS="$tmp_CFLAGS -fdelete-null-pointer-checks" 106113498266Sopenharmony_ci CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [duplicated-cond]) 106213498266Sopenharmony_ci CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [unused-const-variable]) 106313498266Sopenharmony_ci fi 106413498266Sopenharmony_ci # 106513498266Sopenharmony_ci dnl Only gcc 7 or later 106613498266Sopenharmony_ci if test "$compiler_num" -ge "700"; then 106713498266Sopenharmony_ci CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [duplicated-branches]) 106813498266Sopenharmony_ci CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [restrict]) 106913498266Sopenharmony_ci CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [alloc-zero]) 107013498266Sopenharmony_ci tmp_CFLAGS="$tmp_CFLAGS -Wformat-overflow=2" 107113498266Sopenharmony_ci tmp_CFLAGS="$tmp_CFLAGS -Wformat-truncation=2" 107213498266Sopenharmony_ci tmp_CFLAGS="$tmp_CFLAGS -Wimplicit-fallthrough" 107313498266Sopenharmony_ci fi 107413498266Sopenharmony_ci # 107513498266Sopenharmony_ci dnl Only gcc 10 or later 107613498266Sopenharmony_ci if test "$compiler_num" -ge "1000"; then 107713498266Sopenharmony_ci CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [arith-conversion]) 107813498266Sopenharmony_ci CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [enum-conversion]) 107913498266Sopenharmony_ci fi 108013498266Sopenharmony_ci # 108113498266Sopenharmony_ci fi 108213498266Sopenharmony_ci # 108313498266Sopenharmony_ci dnl Do not issue warnings for code in system include paths. 108413498266Sopenharmony_ci if test "$compiler_num" -ge "300"; then 108513498266Sopenharmony_ci tmp_CFLAGS="$tmp_CFLAGS -Wno-system-headers" 108613498266Sopenharmony_ci else 108713498266Sopenharmony_ci dnl When cross-compiling with a gcc older than 3.0, disable 108813498266Sopenharmony_ci dnl some warnings triggered on third party system headers. 108913498266Sopenharmony_ci if test "x$cross_compiling" = "xyes"; then 109013498266Sopenharmony_ci if test "$compiler_num" -ge "104"; then 109113498266Sopenharmony_ci dnl gcc 1.4 or later 109213498266Sopenharmony_ci tmp_CFLAGS="$tmp_CFLAGS -Wno-unused -Wno-shadow" 109313498266Sopenharmony_ci fi 109413498266Sopenharmony_ci if test "$compiler_num" -ge "207"; then 109513498266Sopenharmony_ci dnl gcc 2.7 or later 109613498266Sopenharmony_ci tmp_CFLAGS="$tmp_CFLAGS -Wno-missing-declarations" 109713498266Sopenharmony_ci tmp_CFLAGS="$tmp_CFLAGS -Wno-missing-prototypes" 109813498266Sopenharmony_ci fi 109913498266Sopenharmony_ci fi 110013498266Sopenharmony_ci fi 110113498266Sopenharmony_ci ;; 110213498266Sopenharmony_ci # 110313498266Sopenharmony_ci HP_UX_C) 110413498266Sopenharmony_ci # 110513498266Sopenharmony_ci if test "$want_warnings" = "yes"; then 110613498266Sopenharmony_ci dnl Issue all warnings 110713498266Sopenharmony_ci tmp_CFLAGS="$tmp_CFLAGS +w1" 110813498266Sopenharmony_ci fi 110913498266Sopenharmony_ci ;; 111013498266Sopenharmony_ci # 111113498266Sopenharmony_ci IBM_C) 111213498266Sopenharmony_ci # 111313498266Sopenharmony_ci dnl Placeholder 111413498266Sopenharmony_ci tmp_CFLAGS="$tmp_CFLAGS" 111513498266Sopenharmony_ci ;; 111613498266Sopenharmony_ci # 111713498266Sopenharmony_ci INTEL_UNIX_C) 111813498266Sopenharmony_ci # 111913498266Sopenharmony_ci if test "$want_warnings" = "yes"; then 112013498266Sopenharmony_ci if test "$compiler_num" -gt "600"; then 112113498266Sopenharmony_ci dnl Show errors, warnings, and remarks 112213498266Sopenharmony_ci tmp_CPPFLAGS="$tmp_CPPFLAGS -Wall -w2" 112313498266Sopenharmony_ci dnl Perform extra compile-time code checking 112413498266Sopenharmony_ci tmp_CPPFLAGS="$tmp_CPPFLAGS -Wcheck" 112513498266Sopenharmony_ci dnl Warn on nested comments 112613498266Sopenharmony_ci tmp_CPPFLAGS="$tmp_CPPFLAGS -Wcomment" 112713498266Sopenharmony_ci dnl Show warnings relative to deprecated features 112813498266Sopenharmony_ci tmp_CPPFLAGS="$tmp_CPPFLAGS -Wdeprecated" 112913498266Sopenharmony_ci dnl Enable warnings for missing prototypes 113013498266Sopenharmony_ci tmp_CPPFLAGS="$tmp_CPPFLAGS -Wmissing-prototypes" 113113498266Sopenharmony_ci dnl Enable warnings for 64-bit portability issues 113213498266Sopenharmony_ci tmp_CPPFLAGS="$tmp_CPPFLAGS -Wp64" 113313498266Sopenharmony_ci dnl Enable warnings for questionable pointer arithmetic 113413498266Sopenharmony_ci tmp_CPPFLAGS="$tmp_CPPFLAGS -Wpointer-arith" 113513498266Sopenharmony_ci dnl Check for function return typw issues 113613498266Sopenharmony_ci tmp_CPPFLAGS="$tmp_CPPFLAGS -Wreturn-type" 113713498266Sopenharmony_ci dnl Warn on variable declarations hiding a previous one 113813498266Sopenharmony_ci tmp_CPPFLAGS="$tmp_CPPFLAGS -Wshadow" 113913498266Sopenharmony_ci dnl Warn when a variable is used before initialized 114013498266Sopenharmony_ci tmp_CPPFLAGS="$tmp_CPPFLAGS -Wuninitialized" 114113498266Sopenharmony_ci dnl Warn if a declared function is not used 114213498266Sopenharmony_ci tmp_CPPFLAGS="$tmp_CPPFLAGS -Wunused-function" 114313498266Sopenharmony_ci fi 114413498266Sopenharmony_ci fi 114513498266Sopenharmony_ci dnl Disable using EBP register in optimizations 114613498266Sopenharmony_ci tmp_CFLAGS="$tmp_CFLAGS -fno-omit-frame-pointer" 114713498266Sopenharmony_ci dnl Disable use of ANSI C aliasing rules in optimizations 114813498266Sopenharmony_ci tmp_CFLAGS="$tmp_CFLAGS -fno-strict-aliasing" 114913498266Sopenharmony_ci dnl Value-safe optimizations on floating-point data 115013498266Sopenharmony_ci tmp_CFLAGS="$tmp_CFLAGS -fp-model precise" 115113498266Sopenharmony_ci ;; 115213498266Sopenharmony_ci # 115313498266Sopenharmony_ci INTEL_WINDOWS_C) 115413498266Sopenharmony_ci # 115513498266Sopenharmony_ci dnl Placeholder 115613498266Sopenharmony_ci tmp_CFLAGS="$tmp_CFLAGS" 115713498266Sopenharmony_ci ;; 115813498266Sopenharmony_ci # 115913498266Sopenharmony_ci SGI_MIPS_C) 116013498266Sopenharmony_ci # 116113498266Sopenharmony_ci if test "$want_warnings" = "yes"; then 116213498266Sopenharmony_ci dnl Perform stricter semantic and lint-like checks 116313498266Sopenharmony_ci tmp_CFLAGS="$tmp_CFLAGS -fullwarn" 116413498266Sopenharmony_ci fi 116513498266Sopenharmony_ci ;; 116613498266Sopenharmony_ci # 116713498266Sopenharmony_ci SGI_MIPSPRO_C) 116813498266Sopenharmony_ci # 116913498266Sopenharmony_ci if test "$want_warnings" = "yes"; then 117013498266Sopenharmony_ci dnl Perform stricter semantic and lint-like checks 117113498266Sopenharmony_ci tmp_CFLAGS="$tmp_CFLAGS -fullwarn" 117213498266Sopenharmony_ci dnl Disable some remarks 117313498266Sopenharmony_ci dnl #1209: controlling expression is constant 117413498266Sopenharmony_ci tmp_CFLAGS="$tmp_CFLAGS -woff 1209" 117513498266Sopenharmony_ci fi 117613498266Sopenharmony_ci ;; 117713498266Sopenharmony_ci # 117813498266Sopenharmony_ci SUNPRO_C) 117913498266Sopenharmony_ci # 118013498266Sopenharmony_ci if test "$want_warnings" = "yes"; then 118113498266Sopenharmony_ci dnl Perform stricter semantic and lint-like checks 118213498266Sopenharmony_ci tmp_CFLAGS="$tmp_CFLAGS -v" 118313498266Sopenharmony_ci fi 118413498266Sopenharmony_ci ;; 118513498266Sopenharmony_ci # 118613498266Sopenharmony_ci TINY_C) 118713498266Sopenharmony_ci # 118813498266Sopenharmony_ci if test "$want_warnings" = "yes"; then 118913498266Sopenharmony_ci dnl Activate all warnings 119013498266Sopenharmony_ci CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [all]) 119113498266Sopenharmony_ci dnl Make string constants be of type const char * 119213498266Sopenharmony_ci CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [write-strings]) 119313498266Sopenharmony_ci dnl Warn use of unsupported GCC features ignored by TCC 119413498266Sopenharmony_ci CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [unsupported]) 119513498266Sopenharmony_ci fi 119613498266Sopenharmony_ci ;; 119713498266Sopenharmony_ci # 119813498266Sopenharmony_ci esac 119913498266Sopenharmony_ci # 120013498266Sopenharmony_ci squeeze tmp_CPPFLAGS 120113498266Sopenharmony_ci squeeze tmp_CFLAGS 120213498266Sopenharmony_ci # 120313498266Sopenharmony_ci if test ! -z "$tmp_CFLAGS" || test ! -z "$tmp_CPPFLAGS"; then 120413498266Sopenharmony_ci AC_MSG_CHECKING([if compiler accepts strict warning options]) 120513498266Sopenharmony_ci CPPFLAGS="$tmp_save_CPPFLAGS $tmp_CPPFLAGS" 120613498266Sopenharmony_ci CFLAGS="$tmp_save_CFLAGS $tmp_CFLAGS" 120713498266Sopenharmony_ci squeeze CPPFLAGS 120813498266Sopenharmony_ci squeeze CFLAGS 120913498266Sopenharmony_ci CURL_COMPILER_WORKS_IFELSE([ 121013498266Sopenharmony_ci AC_MSG_RESULT([yes]) 121113498266Sopenharmony_ci AC_MSG_NOTICE([compiler options added: $tmp_CFLAGS $tmp_CPPFLAGS]) 121213498266Sopenharmony_ci ],[ 121313498266Sopenharmony_ci AC_MSG_RESULT([no]) 121413498266Sopenharmony_ci AC_MSG_WARN([compiler options rejected: $tmp_CFLAGS $tmp_CPPFLAGS]) 121513498266Sopenharmony_ci dnl restore initial settings 121613498266Sopenharmony_ci CPPFLAGS="$tmp_save_CPPFLAGS" 121713498266Sopenharmony_ci CFLAGS="$tmp_save_CFLAGS" 121813498266Sopenharmony_ci ]) 121913498266Sopenharmony_ci fi 122013498266Sopenharmony_ci # 122113498266Sopenharmony_ci fi 122213498266Sopenharmony_ci]) 122313498266Sopenharmony_ci 122413498266Sopenharmony_ci 122513498266Sopenharmony_cidnl CURL_SHFUNC_SQUEEZE 122613498266Sopenharmony_cidnl ------------------------------------------------- 122713498266Sopenharmony_cidnl Declares a shell function squeeze() which removes 122813498266Sopenharmony_cidnl redundant whitespace out of a shell variable. 122913498266Sopenharmony_ci 123013498266Sopenharmony_ciAC_DEFUN([CURL_SHFUNC_SQUEEZE], [ 123113498266Sopenharmony_cisqueeze() { 123213498266Sopenharmony_ci _sqz_result="" 123313498266Sopenharmony_ci eval _sqz_input=\[$][$]1 123413498266Sopenharmony_ci for _sqz_token in $_sqz_input; do 123513498266Sopenharmony_ci if test -z "$_sqz_result"; then 123613498266Sopenharmony_ci _sqz_result="$_sqz_token" 123713498266Sopenharmony_ci else 123813498266Sopenharmony_ci _sqz_result="$_sqz_result $_sqz_token" 123913498266Sopenharmony_ci fi 124013498266Sopenharmony_ci done 124113498266Sopenharmony_ci eval [$]1=\$_sqz_result 124213498266Sopenharmony_ci return 0 124313498266Sopenharmony_ci} 124413498266Sopenharmony_ci]) 124513498266Sopenharmony_ci 124613498266Sopenharmony_ci 124713498266Sopenharmony_cidnl CURL_CHECK_CURLDEBUG 124813498266Sopenharmony_cidnl ------------------------------------------------- 124913498266Sopenharmony_cidnl Settings which depend on configure's curldebug given 125013498266Sopenharmony_cidnl option, and other additional configure pre-requisites. 125113498266Sopenharmony_cidnl Actually the curl debug memory tracking feature can 125213498266Sopenharmony_cidnl only be used/enabled when libcurl is built as a static 125313498266Sopenharmony_cidnl library or as a shared one on those systems on which 125413498266Sopenharmony_cidnl shared libraries support undefined symbols. 125513498266Sopenharmony_ci 125613498266Sopenharmony_ciAC_DEFUN([CURL_CHECK_CURLDEBUG], [ 125713498266Sopenharmony_ci AC_REQUIRE([XC_LIBTOOL])dnl 125813498266Sopenharmony_ci AC_REQUIRE([CURL_SHFUNC_SQUEEZE])dnl 125913498266Sopenharmony_ci supports_curldebug="unknown" 126013498266Sopenharmony_ci if test "$want_curldebug" = "yes"; then 126113498266Sopenharmony_ci if test "x$enable_shared" != "xno" && 126213498266Sopenharmony_ci test "x$enable_shared" != "xyes"; then 126313498266Sopenharmony_ci AC_MSG_WARN([unknown enable_shared setting.]) 126413498266Sopenharmony_ci supports_curldebug="no" 126513498266Sopenharmony_ci fi 126613498266Sopenharmony_ci if test "x$enable_static" != "xno" && 126713498266Sopenharmony_ci test "x$enable_static" != "xyes"; then 126813498266Sopenharmony_ci AC_MSG_WARN([unknown enable_static setting.]) 126913498266Sopenharmony_ci supports_curldebug="no" 127013498266Sopenharmony_ci fi 127113498266Sopenharmony_ci if test "$supports_curldebug" != "no"; then 127213498266Sopenharmony_ci if test "$enable_shared" = "yes" && 127313498266Sopenharmony_ci test "x$xc_lt_shlib_use_no_undefined" = 'xyes'; then 127413498266Sopenharmony_ci supports_curldebug="no" 127513498266Sopenharmony_ci AC_MSG_WARN([shared library does not support undefined symbols.]) 127613498266Sopenharmony_ci fi 127713498266Sopenharmony_ci fi 127813498266Sopenharmony_ci fi 127913498266Sopenharmony_ci # 128013498266Sopenharmony_ci if test "$want_curldebug" = "yes"; then 128113498266Sopenharmony_ci AC_MSG_CHECKING([if curl debug memory tracking can be enabled]) 128213498266Sopenharmony_ci test "$supports_curldebug" = "no" || supports_curldebug="yes" 128313498266Sopenharmony_ci AC_MSG_RESULT([$supports_curldebug]) 128413498266Sopenharmony_ci if test "$supports_curldebug" = "no"; then 128513498266Sopenharmony_ci AC_MSG_WARN([cannot enable curl debug memory tracking.]) 128613498266Sopenharmony_ci want_curldebug="no" 128713498266Sopenharmony_ci fi 128813498266Sopenharmony_ci fi 128913498266Sopenharmony_ci]) 129013498266Sopenharmony_ci 129113498266Sopenharmony_ci 129213498266Sopenharmony_ci 129313498266Sopenharmony_cidnl CURL_CHECK_COMPILER_HALT_ON_ERROR 129413498266Sopenharmony_cidnl ------------------------------------------------- 129513498266Sopenharmony_cidnl Verifies if the compiler actually halts after the 129613498266Sopenharmony_cidnl compilation phase without generating any object 129713498266Sopenharmony_cidnl code file, when the source compiles with errors. 129813498266Sopenharmony_ci 129913498266Sopenharmony_ciAC_DEFUN([CURL_CHECK_COMPILER_HALT_ON_ERROR], [ 130013498266Sopenharmony_ci AC_MSG_CHECKING([if compiler halts on compilation errors]) 130113498266Sopenharmony_ci AC_COMPILE_IFELSE([ 130213498266Sopenharmony_ci AC_LANG_PROGRAM([[ 130313498266Sopenharmony_ci ]],[[ 130413498266Sopenharmony_ci force compilation error 130513498266Sopenharmony_ci ]]) 130613498266Sopenharmony_ci ],[ 130713498266Sopenharmony_ci AC_MSG_RESULT([no]) 130813498266Sopenharmony_ci AC_MSG_ERROR([compiler does not halt on compilation errors.]) 130913498266Sopenharmony_ci ],[ 131013498266Sopenharmony_ci AC_MSG_RESULT([yes]) 131113498266Sopenharmony_ci ]) 131213498266Sopenharmony_ci]) 131313498266Sopenharmony_ci 131413498266Sopenharmony_ci 131513498266Sopenharmony_cidnl CURL_CHECK_COMPILER_ARRAY_SIZE_NEGATIVE 131613498266Sopenharmony_cidnl ------------------------------------------------- 131713498266Sopenharmony_cidnl Verifies if the compiler actually halts after the 131813498266Sopenharmony_cidnl compilation phase without generating any object 131913498266Sopenharmony_cidnl code file, when the source code tries to define a 132013498266Sopenharmony_cidnl type for a constant array with negative dimension. 132113498266Sopenharmony_ci 132213498266Sopenharmony_ciAC_DEFUN([CURL_CHECK_COMPILER_ARRAY_SIZE_NEGATIVE], [ 132313498266Sopenharmony_ci AC_REQUIRE([CURL_CHECK_COMPILER_HALT_ON_ERROR])dnl 132413498266Sopenharmony_ci AC_MSG_CHECKING([if compiler halts on negative sized arrays]) 132513498266Sopenharmony_ci AC_COMPILE_IFELSE([ 132613498266Sopenharmony_ci AC_LANG_PROGRAM([[ 132713498266Sopenharmony_ci typedef char bad_t[sizeof(char) == sizeof(int) ? -1 : -1 ]; 132813498266Sopenharmony_ci ]],[[ 132913498266Sopenharmony_ci bad_t dummy; 133013498266Sopenharmony_ci ]]) 133113498266Sopenharmony_ci ],[ 133213498266Sopenharmony_ci AC_MSG_RESULT([no]) 133313498266Sopenharmony_ci AC_MSG_ERROR([compiler does not halt on negative sized arrays.]) 133413498266Sopenharmony_ci ],[ 133513498266Sopenharmony_ci AC_MSG_RESULT([yes]) 133613498266Sopenharmony_ci ]) 133713498266Sopenharmony_ci]) 133813498266Sopenharmony_ci 133913498266Sopenharmony_ci 134013498266Sopenharmony_cidnl CURL_CHECK_COMPILER_STRUCT_MEMBER_SIZE 134113498266Sopenharmony_cidnl ------------------------------------------------- 134213498266Sopenharmony_cidnl Verifies if the compiler is capable of handling the 134313498266Sopenharmony_cidnl size of a struct member, struct which is a function 134413498266Sopenharmony_cidnl result, as a compilation-time condition inside the 134513498266Sopenharmony_cidnl type definition of a constant array. 134613498266Sopenharmony_ci 134713498266Sopenharmony_ciAC_DEFUN([CURL_CHECK_COMPILER_STRUCT_MEMBER_SIZE], [ 134813498266Sopenharmony_ci AC_REQUIRE([CURL_CHECK_COMPILER_ARRAY_SIZE_NEGATIVE])dnl 134913498266Sopenharmony_ci AC_MSG_CHECKING([if compiler struct member size checking works]) 135013498266Sopenharmony_ci tst_compiler_check_one_works="unknown" 135113498266Sopenharmony_ci AC_COMPILE_IFELSE([ 135213498266Sopenharmony_ci AC_LANG_PROGRAM([[ 135313498266Sopenharmony_ci struct mystruct { 135413498266Sopenharmony_ci int mi; 135513498266Sopenharmony_ci char mc; 135613498266Sopenharmony_ci struct mystruct *next; 135713498266Sopenharmony_ci }; 135813498266Sopenharmony_ci struct mystruct myfunc(); 135913498266Sopenharmony_ci typedef char good_t1[sizeof(myfunc().mi) == sizeof(int) ? 1 : -1 ]; 136013498266Sopenharmony_ci typedef char good_t2[sizeof(myfunc().mc) == sizeof(char) ? 1 : -1 ]; 136113498266Sopenharmony_ci ]],[[ 136213498266Sopenharmony_ci good_t1 dummy1; 136313498266Sopenharmony_ci good_t2 dummy2; 136413498266Sopenharmony_ci ]]) 136513498266Sopenharmony_ci ],[ 136613498266Sopenharmony_ci tst_compiler_check_one_works="yes" 136713498266Sopenharmony_ci ],[ 136813498266Sopenharmony_ci tst_compiler_check_one_works="no" 136913498266Sopenharmony_ci sed 's/^/cc-src: /' conftest.$ac_ext >&6 137013498266Sopenharmony_ci sed 's/^/cc-err: /' conftest.err >&6 137113498266Sopenharmony_ci ]) 137213498266Sopenharmony_ci tst_compiler_check_two_works="unknown" 137313498266Sopenharmony_ci AC_COMPILE_IFELSE([ 137413498266Sopenharmony_ci AC_LANG_PROGRAM([[ 137513498266Sopenharmony_ci struct mystruct { 137613498266Sopenharmony_ci int mi; 137713498266Sopenharmony_ci char mc; 137813498266Sopenharmony_ci struct mystruct *next; 137913498266Sopenharmony_ci }; 138013498266Sopenharmony_ci struct mystruct myfunc(); 138113498266Sopenharmony_ci typedef char bad_t1[sizeof(myfunc().mi) != sizeof(int) ? 1 : -1 ]; 138213498266Sopenharmony_ci typedef char bad_t2[sizeof(myfunc().mc) != sizeof(char) ? 1 : -1 ]; 138313498266Sopenharmony_ci ]],[[ 138413498266Sopenharmony_ci bad_t1 dummy1; 138513498266Sopenharmony_ci bad_t2 dummy2; 138613498266Sopenharmony_ci ]]) 138713498266Sopenharmony_ci ],[ 138813498266Sopenharmony_ci tst_compiler_check_two_works="no" 138913498266Sopenharmony_ci ],[ 139013498266Sopenharmony_ci tst_compiler_check_two_works="yes" 139113498266Sopenharmony_ci ]) 139213498266Sopenharmony_ci if test "$tst_compiler_check_one_works" = "yes" && 139313498266Sopenharmony_ci test "$tst_compiler_check_two_works" = "yes"; then 139413498266Sopenharmony_ci AC_MSG_RESULT([yes]) 139513498266Sopenharmony_ci else 139613498266Sopenharmony_ci AC_MSG_RESULT([no]) 139713498266Sopenharmony_ci AC_MSG_ERROR([compiler fails struct member size checking.]) 139813498266Sopenharmony_ci fi 139913498266Sopenharmony_ci]) 140013498266Sopenharmony_ci 140113498266Sopenharmony_ci 140213498266Sopenharmony_cidnl CURL_CHECK_COMPILER_SYMBOL_HIDING 140313498266Sopenharmony_cidnl ------------------------------------------------- 140413498266Sopenharmony_cidnl Verify if compiler supports hiding library internal symbols, setting 140513498266Sopenharmony_cidnl shell variable supports_symbol_hiding value as appropriate, as well as 140613498266Sopenharmony_cidnl variables symbol_hiding_CFLAGS and symbol_hiding_EXTERN when supported. 140713498266Sopenharmony_ci 140813498266Sopenharmony_ciAC_DEFUN([CURL_CHECK_COMPILER_SYMBOL_HIDING], [ 140913498266Sopenharmony_ci AC_REQUIRE([CURL_CHECK_COMPILER])dnl 141013498266Sopenharmony_ci AC_BEFORE([$0],[CURL_CONFIGURE_SYMBOL_HIDING])dnl 141113498266Sopenharmony_ci AC_MSG_CHECKING([if compiler supports hiding library internal symbols]) 141213498266Sopenharmony_ci supports_symbol_hiding="no" 141313498266Sopenharmony_ci symbol_hiding_CFLAGS="" 141413498266Sopenharmony_ci symbol_hiding_EXTERN="" 141513498266Sopenharmony_ci tmp_CFLAGS="" 141613498266Sopenharmony_ci tmp_EXTERN="" 141713498266Sopenharmony_ci case "$compiler_id" in 141813498266Sopenharmony_ci CLANG) 141913498266Sopenharmony_ci dnl All versions of clang support -fvisibility= 142013498266Sopenharmony_ci tmp_EXTERN="__attribute__ ((__visibility__ (\"default\")))" 142113498266Sopenharmony_ci tmp_CFLAGS="-fvisibility=hidden" 142213498266Sopenharmony_ci supports_symbol_hiding="yes" 142313498266Sopenharmony_ci ;; 142413498266Sopenharmony_ci GNU_C) 142513498266Sopenharmony_ci dnl Only gcc 3.4 or later 142613498266Sopenharmony_ci if test "$compiler_num" -ge "304"; then 142713498266Sopenharmony_ci if $CC --help --verbose 2>/dev/null | grep fvisibility= >/dev/null ; then 142813498266Sopenharmony_ci tmp_EXTERN="__attribute__ ((__visibility__ (\"default\")))" 142913498266Sopenharmony_ci tmp_CFLAGS="-fvisibility=hidden" 143013498266Sopenharmony_ci supports_symbol_hiding="yes" 143113498266Sopenharmony_ci fi 143213498266Sopenharmony_ci fi 143313498266Sopenharmony_ci ;; 143413498266Sopenharmony_ci INTEL_UNIX_C) 143513498266Sopenharmony_ci dnl Only icc 9.0 or later 143613498266Sopenharmony_ci if test "$compiler_num" -ge "900"; then 143713498266Sopenharmony_ci if $CC --help --verbose 2>&1 | grep fvisibility= > /dev/null ; then 143813498266Sopenharmony_ci tmp_save_CFLAGS="$CFLAGS" 143913498266Sopenharmony_ci CFLAGS="$CFLAGS -fvisibility=hidden" 144013498266Sopenharmony_ci AC_LINK_IFELSE([ 144113498266Sopenharmony_ci AC_LANG_PROGRAM([[ 144213498266Sopenharmony_ci# include <stdio.h> 144313498266Sopenharmony_ci ]],[[ 144413498266Sopenharmony_ci printf("icc fvisibility bug test"); 144513498266Sopenharmony_ci ]]) 144613498266Sopenharmony_ci ],[ 144713498266Sopenharmony_ci tmp_EXTERN="__attribute__ ((__visibility__ (\"default\")))" 144813498266Sopenharmony_ci tmp_CFLAGS="-fvisibility=hidden" 144913498266Sopenharmony_ci supports_symbol_hiding="yes" 145013498266Sopenharmony_ci ]) 145113498266Sopenharmony_ci CFLAGS="$tmp_save_CFLAGS" 145213498266Sopenharmony_ci fi 145313498266Sopenharmony_ci fi 145413498266Sopenharmony_ci ;; 145513498266Sopenharmony_ci SUNPRO_C) 145613498266Sopenharmony_ci if $CC 2>&1 | grep flags >/dev/null && $CC -flags | grep xldscope= >/dev/null ; then 145713498266Sopenharmony_ci tmp_EXTERN="__global" 145813498266Sopenharmony_ci tmp_CFLAGS="-xldscope=hidden" 145913498266Sopenharmony_ci supports_symbol_hiding="yes" 146013498266Sopenharmony_ci fi 146113498266Sopenharmony_ci ;; 146213498266Sopenharmony_ci esac 146313498266Sopenharmony_ci if test "$supports_symbol_hiding" = "yes"; then 146413498266Sopenharmony_ci tmp_save_CFLAGS="$CFLAGS" 146513498266Sopenharmony_ci CFLAGS="$tmp_save_CFLAGS $tmp_CFLAGS" 146613498266Sopenharmony_ci squeeze CFLAGS 146713498266Sopenharmony_ci AC_COMPILE_IFELSE([ 146813498266Sopenharmony_ci AC_LANG_PROGRAM([[ 146913498266Sopenharmony_ci $tmp_EXTERN char *dummy(char *buff); 147013498266Sopenharmony_ci char *dummy(char *buff) 147113498266Sopenharmony_ci { 147213498266Sopenharmony_ci if(buff) 147313498266Sopenharmony_ci return ++buff; 147413498266Sopenharmony_ci else 147513498266Sopenharmony_ci return buff; 147613498266Sopenharmony_ci } 147713498266Sopenharmony_ci ]],[[ 147813498266Sopenharmony_ci char b[16]; 147913498266Sopenharmony_ci char *r = dummy(&b[0]); 148013498266Sopenharmony_ci if(r) 148113498266Sopenharmony_ci return (int)*r; 148213498266Sopenharmony_ci ]]) 148313498266Sopenharmony_ci ],[ 148413498266Sopenharmony_ci supports_symbol_hiding="yes" 148513498266Sopenharmony_ci if test -f conftest.err; then 148613498266Sopenharmony_ci grep 'visibility' conftest.err >/dev/null 148713498266Sopenharmony_ci if test "$?" -eq "0"; then 148813498266Sopenharmony_ci supports_symbol_hiding="no" 148913498266Sopenharmony_ci fi 149013498266Sopenharmony_ci fi 149113498266Sopenharmony_ci ],[ 149213498266Sopenharmony_ci supports_symbol_hiding="no" 149313498266Sopenharmony_ci echo " " >&6 149413498266Sopenharmony_ci sed 's/^/cc-src: /' conftest.$ac_ext >&6 149513498266Sopenharmony_ci sed 's/^/cc-err: /' conftest.err >&6 149613498266Sopenharmony_ci echo " " >&6 149713498266Sopenharmony_ci ]) 149813498266Sopenharmony_ci CFLAGS="$tmp_save_CFLAGS" 149913498266Sopenharmony_ci fi 150013498266Sopenharmony_ci if test "$supports_symbol_hiding" = "yes"; then 150113498266Sopenharmony_ci AC_MSG_RESULT([yes]) 150213498266Sopenharmony_ci symbol_hiding_CFLAGS="$tmp_CFLAGS" 150313498266Sopenharmony_ci symbol_hiding_EXTERN="$tmp_EXTERN" 150413498266Sopenharmony_ci else 150513498266Sopenharmony_ci AC_MSG_RESULT([no]) 150613498266Sopenharmony_ci fi 150713498266Sopenharmony_ci]) 150813498266Sopenharmony_ci 150913498266Sopenharmony_ci 151013498266Sopenharmony_cidnl CURL_CHECK_COMPILER_PROTOTYPE_MISMATCH 151113498266Sopenharmony_cidnl ------------------------------------------------- 151213498266Sopenharmony_cidnl Verifies if the compiler actually halts after the 151313498266Sopenharmony_cidnl compilation phase without generating any object 151413498266Sopenharmony_cidnl code file, when the source code tries to redefine 151513498266Sopenharmony_cidnl a prototype which does not match previous one. 151613498266Sopenharmony_ci 151713498266Sopenharmony_ciAC_DEFUN([CURL_CHECK_COMPILER_PROTOTYPE_MISMATCH], [ 151813498266Sopenharmony_ci AC_REQUIRE([CURL_CHECK_COMPILER_HALT_ON_ERROR])dnl 151913498266Sopenharmony_ci AC_MSG_CHECKING([if compiler halts on function prototype mismatch]) 152013498266Sopenharmony_ci AC_COMPILE_IFELSE([ 152113498266Sopenharmony_ci AC_LANG_PROGRAM([[ 152213498266Sopenharmony_ci# include <stdlib.h> 152313498266Sopenharmony_ci int rand(int n); 152413498266Sopenharmony_ci int rand(int n) 152513498266Sopenharmony_ci { 152613498266Sopenharmony_ci if(n) 152713498266Sopenharmony_ci return ++n; 152813498266Sopenharmony_ci else 152913498266Sopenharmony_ci return n; 153013498266Sopenharmony_ci } 153113498266Sopenharmony_ci ]],[[ 153213498266Sopenharmony_ci int i[2]={0,0}; 153313498266Sopenharmony_ci int j = rand(i[0]); 153413498266Sopenharmony_ci if(j) 153513498266Sopenharmony_ci return j; 153613498266Sopenharmony_ci ]]) 153713498266Sopenharmony_ci ],[ 153813498266Sopenharmony_ci AC_MSG_RESULT([no]) 153913498266Sopenharmony_ci AC_MSG_ERROR([compiler does not halt on function prototype mismatch.]) 154013498266Sopenharmony_ci ],[ 154113498266Sopenharmony_ci AC_MSG_RESULT([yes]) 154213498266Sopenharmony_ci ]) 154313498266Sopenharmony_ci]) 154413498266Sopenharmony_ci 154513498266Sopenharmony_ci 154613498266Sopenharmony_cidnl CURL_VAR_MATCH (VARNAME, VALUE) 154713498266Sopenharmony_cidnl ------------------------------------------------- 154813498266Sopenharmony_cidnl Verifies if shell variable VARNAME contains VALUE. 154913498266Sopenharmony_cidnl Contents of variable VARNAME and VALUE are handled 155013498266Sopenharmony_cidnl as whitespace separated lists of words. If at least 155113498266Sopenharmony_cidnl one word of VALUE is present in VARNAME the match 155213498266Sopenharmony_cidnl is considered positive, otherwise false. 155313498266Sopenharmony_ci 155413498266Sopenharmony_ciAC_DEFUN([CURL_VAR_MATCH], [ 155513498266Sopenharmony_ci ac_var_match_word="no" 155613498266Sopenharmony_ci for word1 in $[$1]; do 155713498266Sopenharmony_ci for word2 in [$2]; do 155813498266Sopenharmony_ci if test "$word1" = "$word2"; then 155913498266Sopenharmony_ci ac_var_match_word="yes" 156013498266Sopenharmony_ci fi 156113498266Sopenharmony_ci done 156213498266Sopenharmony_ci done 156313498266Sopenharmony_ci]) 156413498266Sopenharmony_ci 156513498266Sopenharmony_ci 156613498266Sopenharmony_cidnl CURL_VAR_MATCH_IFELSE (VARNAME, VALUE, 156713498266Sopenharmony_cidnl [ACTION-IF-MATCH], [ACTION-IF-NOT-MATCH]) 156813498266Sopenharmony_cidnl ------------------------------------------------- 156913498266Sopenharmony_cidnl This performs a CURL_VAR_MATCH check and executes 157013498266Sopenharmony_cidnl first branch if the match is positive, otherwise 157113498266Sopenharmony_cidnl the second branch is executed. 157213498266Sopenharmony_ci 157313498266Sopenharmony_ciAC_DEFUN([CURL_VAR_MATCH_IFELSE], [ 157413498266Sopenharmony_ci CURL_VAR_MATCH([$1],[$2]) 157513498266Sopenharmony_ci if test "$ac_var_match_word" = "yes"; then 157613498266Sopenharmony_ci ifelse($3,,:,[$3]) 157713498266Sopenharmony_ci ifelse($4,,,[else 157813498266Sopenharmony_ci $4]) 157913498266Sopenharmony_ci fi 158013498266Sopenharmony_ci]) 158113498266Sopenharmony_ci 158213498266Sopenharmony_ci 158313498266Sopenharmony_cidnl CURL_VAR_STRIP (VARNAME, VALUE) 158413498266Sopenharmony_cidnl ------------------------------------------------- 158513498266Sopenharmony_cidnl Contents of variable VARNAME and VALUE are handled 158613498266Sopenharmony_cidnl as whitespace separated lists of words. Each word 158713498266Sopenharmony_cidnl from VALUE is removed from VARNAME when present. 158813498266Sopenharmony_ci 158913498266Sopenharmony_ciAC_DEFUN([CURL_VAR_STRIP], [ 159013498266Sopenharmony_ci AC_REQUIRE([CURL_SHFUNC_SQUEEZE])dnl 159113498266Sopenharmony_ci ac_var_stripped="" 159213498266Sopenharmony_ci for word1 in $[$1]; do 159313498266Sopenharmony_ci ac_var_strip_word="no" 159413498266Sopenharmony_ci for word2 in [$2]; do 159513498266Sopenharmony_ci if test "$word1" = "$word2"; then 159613498266Sopenharmony_ci ac_var_strip_word="yes" 159713498266Sopenharmony_ci fi 159813498266Sopenharmony_ci done 159913498266Sopenharmony_ci if test "$ac_var_strip_word" = "no"; then 160013498266Sopenharmony_ci ac_var_stripped="$ac_var_stripped $word1" 160113498266Sopenharmony_ci fi 160213498266Sopenharmony_ci done 160313498266Sopenharmony_ci dnl squeeze whitespace out of result 160413498266Sopenharmony_ci [$1]="$ac_var_stripped" 160513498266Sopenharmony_ci squeeze [$1] 160613498266Sopenharmony_ci]) 160713498266Sopenharmony_ci 160813498266Sopenharmony_cidnl CURL_ADD_COMPILER_WARNINGS (WARNING-LIST, NEW-WARNINGS) 160913498266Sopenharmony_cidnl ------------------------------------------------------- 161013498266Sopenharmony_cidnl Contents of variable WARNING-LIST and NEW-WARNINGS are 161113498266Sopenharmony_cidnl handled as whitespace separated lists of words. 161213498266Sopenharmony_cidnl Add each compiler warning from NEW-WARNINGS that has not 161313498266Sopenharmony_cidnl been disabled via CFLAGS to WARNING-LIST. 161413498266Sopenharmony_ci 161513498266Sopenharmony_ciAC_DEFUN([CURL_ADD_COMPILER_WARNINGS], [ 161613498266Sopenharmony_ci AC_REQUIRE([CURL_SHFUNC_SQUEEZE])dnl 161713498266Sopenharmony_ci ac_var_added_warnings="" 161813498266Sopenharmony_ci for warning in [$2]; do 161913498266Sopenharmony_ci CURL_VAR_MATCH(CFLAGS, [-Wno-$warning -W$warning]) 162013498266Sopenharmony_ci if test "$ac_var_match_word" = "no"; then 162113498266Sopenharmony_ci ac_var_added_warnings="$ac_var_added_warnings -W$warning" 162213498266Sopenharmony_ci fi 162313498266Sopenharmony_ci done 162413498266Sopenharmony_ci dnl squeeze whitespace out of result 162513498266Sopenharmony_ci [$1]="$[$1] $ac_var_added_warnings" 162613498266Sopenharmony_ci squeeze [$1] 162713498266Sopenharmony_ci]) 1628