diff options
author | Steve Bennett <steveb@workware.net.au> | 2013-03-28 07:15:00 +1000 |
---|---|---|
committer | Steve Bennett <steveb@workware.net.au> | 2013-03-28 07:19:55 +1000 |
commit | 738b8b93eec3ffcac1b84ddd85179a4351bc82ef (patch) | |
tree | 13aa0401a28123ea376d3ccd793d928ff894b100 /autosetup/cc-lib.tcl | |
parent | c7e5c48c4434835a19628ebecfa1bf59883f5f58 (diff) | |
download | jimtcl-738b8b93eec3ffcac1b84ddd85179a4351bc82ef.zip jimtcl-738b8b93eec3ffcac1b84ddd85179a4351bc82ef.tar.gz jimtcl-738b8b93eec3ffcac1b84ddd85179a4351bc82ef.tar.bz2 |
Update autosetup to v0.6.5
Includes a fix for -gstabs on newer macs
Signed-off-by: Steve Bennett <steveb@workware.net.au>
Diffstat (limited to 'autosetup/cc-lib.tcl')
-rw-r--r-- | autosetup/cc-lib.tcl | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/autosetup/cc-lib.tcl b/autosetup/cc-lib.tcl index e8e5e86..4df5130 100644 --- a/autosetup/cc-lib.tcl +++ b/autosetup/cc-lib.tcl @@ -75,3 +75,87 @@ proc cc-check-endian {} { } return $rc } + +# @cc-check-flags flag ?...? +# +# Checks whether the given C/C++ compiler flags can be used. Defines feature +# names prefixed with 'HAVE_CFLAG' and 'HAVE_CXXFLAG' respectively, and +# appends working flags to '-cflags' and 'CFLAGS' or 'CXXFLAGS'. +proc cc-check-flags {args} { + set result 1 + array set opts [cc-get-settings] + switch -exact -- $opts(-lang) { + c++ { + set lang C++ + set prefix CXXFLAG + } + c { + set lang C + set prefix CFLAG + } + default { + autosetup-error "cc-check-flags failed with unknown language: $opts(-lang)" + } + } + foreach flag $args { + msg-checking "Checking whether the $lang compiler accepts $flag..." + if {[cctest -cflags $flag]} { + msg-result yes + define-feature $prefix$flag + cc-with [list -cflags [list $flag]] + define-append ${prefix}S $flag + } else { + msg-result no + set result 0 + } + } + return $result +} + +# @cc-check-standards ver ?...? +# +# Checks whether the C/C++ compiler accepts one of the specified '-std=$ver' +# options, and appends the first working one to '-cflags' and 'CFLAGS' or +# 'CXXFLAGS'. +proc cc-check-standards {args} { + array set opts [cc-get-settings] + foreach std $args { + if {[cc-check-flags -std=$std]} { + return $std + } + } + return "" +} + +# Checks whether $keyword is usable as alignof +proc cctest_alignof {keyword} { + msg-checking "Checking for $keyword..." + if {[cctest -code [subst -nobackslashes { + printf("minimum alignment is %d == %d\n", ${keyword}(char), ${keyword}('x')); + }]]} then { + msg-result ok + define-feature $keyword + } else { + msg-result "not found" + } +} + +# @cc-check-c11 +# +# Checks for several C11/C++11 extensions and their alternatives. Currently +# checks for '_Static_assert', '_Alignof', '__alignof__', '__alignof'. +proc cc-check-c11 {} { + msg-checking "Checking for _Static_assert..." + if {[cctest -code { + _Static_assert(1, "static assertions are available"); + }]} then { + msg-result ok + define-feature _Static_assert + } else { + msg-result "not found" + } + + cctest_alignof _Alignof + cctest_alignof __alignof__ + cctest_alignof __alignof +} |