debuggers: import openocd-0.7.0
Initial check-in of openocd-0.7.0 as it can be downloaded from http://sourceforge.net/projects/openocd/files/openocd/0.7.0/ Any modifications will follow. Change-Id: I6949beaefd589e046395ea0cb80f4e1ab1654d55
This commit is contained in:
35
debuggers/openocd/jimtcl/autosetup/LICENSE
Normal file
35
debuggers/openocd/jimtcl/autosetup/LICENSE
Normal file
@ -0,0 +1,35 @@
|
||||
Unless explicitly stated, all files which form part of autosetup
|
||||
are released under the following license:
|
||||
|
||||
---------------------------------------------------------------------
|
||||
autosetup - A build environment "autoconfigurator"
|
||||
|
||||
Copyright (c) 2010-2011, WorkWare Systems <http://workware.net.au/>
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above
|
||||
copyright notice, this list of conditions and the following
|
||||
disclaimer in the documentation and/or other materials
|
||||
provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE WORKWARE SYSTEMS ``AS IS'' AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
||||
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WORKWARE
|
||||
SYSTEMS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
The views and conclusions contained in the software and documentation
|
||||
are those of the authors and should not be interpreted as representing
|
||||
official policies, either expressed or implied, of WorkWare Systems.
|
||||
1
debuggers/openocd/jimtcl/autosetup/README.autosetup
Normal file
1
debuggers/openocd/jimtcl/autosetup/README.autosetup
Normal file
@ -0,0 +1 @@
|
||||
This is autosetup v0.6.5. See http://msteveb.github.com/autosetup/
|
||||
1898
debuggers/openocd/jimtcl/autosetup/autosetup
Executable file
1898
debuggers/openocd/jimtcl/autosetup/autosetup
Executable file
File diff suppressed because it is too large
Load Diff
15
debuggers/openocd/jimtcl/autosetup/cc-db.tcl
Normal file
15
debuggers/openocd/jimtcl/autosetup/cc-db.tcl
Normal file
@ -0,0 +1,15 @@
|
||||
# Copyright (c) 2011 WorkWare Systems http://www.workware.net.au/
|
||||
# All rights reserved
|
||||
|
||||
# @synopsis:
|
||||
#
|
||||
# The 'cc-db' module provides a knowledge based of system idiosyncracies
|
||||
# In general, this module can always be included
|
||||
|
||||
use cc
|
||||
|
||||
module-options {}
|
||||
|
||||
# openbsd needs sys/types.h to detect some system headers
|
||||
cc-include-needs sys/socket.h sys/types.h
|
||||
cc-include-needs netinet/in.h sys/types.h
|
||||
161
debuggers/openocd/jimtcl/autosetup/cc-lib.tcl
Normal file
161
debuggers/openocd/jimtcl/autosetup/cc-lib.tcl
Normal file
@ -0,0 +1,161 @@
|
||||
# Copyright (c) 2011 WorkWare Systems http://www.workware.net.au/
|
||||
# All rights reserved
|
||||
|
||||
# @synopsis:
|
||||
#
|
||||
# Provides a library of common tests on top of the 'cc' module.
|
||||
|
||||
use cc
|
||||
|
||||
module-options {}
|
||||
|
||||
# @cc-check-lfs
|
||||
#
|
||||
# The equivalent of the AC_SYS_LARGEFILE macro
|
||||
#
|
||||
# defines 'HAVE_LFS' if LFS is available,
|
||||
# and defines '_FILE_OFFSET_BITS=64' if necessary
|
||||
#
|
||||
# Returns 1 if 'LFS' is available or 0 otherwise
|
||||
#
|
||||
proc cc-check-lfs {} {
|
||||
cc-check-includes sys/types.h
|
||||
msg-checking "Checking if -D_FILE_OFFSET_BITS=64 is needed..."
|
||||
set lfs 1
|
||||
if {[msg-quiet cc-with {-includes sys/types.h} {cc-check-sizeof off_t}] == 8} {
|
||||
msg-result no
|
||||
} elseif {[msg-quiet cc-with {-includes sys/types.h -cflags -D_FILE_OFFSET_BITS=64} {cc-check-sizeof off_t}] == 8} {
|
||||
define _FILE_OFFSET_BITS 64
|
||||
msg-result yes
|
||||
} else {
|
||||
set lfs 0
|
||||
msg-result none
|
||||
}
|
||||
define-feature lfs $lfs
|
||||
return $lfs
|
||||
}
|
||||
|
||||
# @cc-check-endian
|
||||
#
|
||||
# The equivalent of the AC_C_BIGENDIAN macro
|
||||
#
|
||||
# defines 'HAVE_BIG_ENDIAN' if endian is known to be big,
|
||||
# or 'HAVE_LITTLE_ENDIAN' if endian is known to be little.
|
||||
#
|
||||
# Returns 1 if determined, or 0 if not.
|
||||
#
|
||||
proc cc-check-endian {} {
|
||||
cc-check-includes sys/types.h sys/param.h
|
||||
set rc 0
|
||||
msg-checking "Checking endian..."
|
||||
cc-with {-includes {sys/types.h sys/param.h}} {
|
||||
if {[cctest -code {
|
||||
#if !defined(BIG_ENDIAN) || !defined(BYTE_ORDER)
|
||||
#error unknown
|
||||
#elif BYTE_ORDER != BIG_ENDIAN
|
||||
#error little
|
||||
#endif
|
||||
}]} {
|
||||
define-feature big-endian
|
||||
msg-result "big"
|
||||
set rc 1
|
||||
} elseif {[cctest -code {
|
||||
#if !defined(LITTLE_ENDIAN) || !defined(BYTE_ORDER)
|
||||
#error unknown
|
||||
#elif BYTE_ORDER != LITTLE_ENDIAN
|
||||
#error big
|
||||
#endif
|
||||
}]} {
|
||||
define-feature little-endian
|
||||
msg-result "little"
|
||||
set rc 1
|
||||
} else {
|
||||
msg-result "unknown"
|
||||
}
|
||||
}
|
||||
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
|
||||
}
|
||||
103
debuggers/openocd/jimtcl/autosetup/cc-shared.tcl
Normal file
103
debuggers/openocd/jimtcl/autosetup/cc-shared.tcl
Normal file
@ -0,0 +1,103 @@
|
||||
# Copyright (c) 2010 WorkWare Systems http://www.workware.net.au/
|
||||
# All rights reserved
|
||||
|
||||
# @synopsis:
|
||||
#
|
||||
# The 'cc-shared' module provides support for shared libraries and shared objects.
|
||||
# It defines the following variables:
|
||||
#
|
||||
## SH_CFLAGS Flags to use compiling sources destined for a shared library
|
||||
## SH_LDFLAGS Flags to use linking (creating) a shared library
|
||||
## SH_SOPREFIX Prefix to use to set the soname when creating a shared library
|
||||
## SH_SOEXT Extension for shared libs
|
||||
## SH_SOEXTVER Format for versioned shared libs - %s = version
|
||||
## SHOBJ_CFLAGS Flags to use compiling sources destined for a shared object
|
||||
## SHOBJ_LDFLAGS Flags to use linking a shared object, undefined symbols allowed
|
||||
## SHOBJ_LDFLAGS_R - as above, but all symbols must be resolved
|
||||
## SH_LINKFLAGS Flags to use linking an executable which will load shared objects
|
||||
## LD_LIBRARY_PATH Environment variable which specifies path to shared libraries
|
||||
## STRIPLIBFLAGS Arguments to strip to strip a dynamic library
|
||||
|
||||
module-options {}
|
||||
|
||||
# Defaults: gcc on unix
|
||||
define SHOBJ_CFLAGS -fpic
|
||||
define SHOBJ_LDFLAGS -shared
|
||||
define SH_CFLAGS -fpic
|
||||
define SH_LDFLAGS -shared
|
||||
define SH_LINKFLAGS -rdynamic
|
||||
define SH_SOEXT .so
|
||||
define SH_SOEXTVER .so.%s
|
||||
define SH_SOPREFIX -Wl,-soname,
|
||||
define LD_LIBRARY_PATH LD_LIBRARY_PATH
|
||||
define STRIPLIBFLAGS --strip-unneeded
|
||||
|
||||
# Note: This is a helpful reference for identifying the toolchain
|
||||
# http://sourceforge.net/apps/mediawiki/predef/index.php?title=Compilers
|
||||
|
||||
switch -glob -- [get-define host] {
|
||||
*-*-darwin* {
|
||||
define SHOBJ_CFLAGS "-dynamic -fno-common"
|
||||
define SHOBJ_LDFLAGS "-bundle -undefined dynamic_lookup"
|
||||
define SHOBJ_LDFLAGS_R -bundle
|
||||
define SH_CFLAGS -dynamic
|
||||
define SH_LDFLAGS -dynamiclib
|
||||
define SH_LINKFLAGS ""
|
||||
define SH_SOEXT .dylib
|
||||
define SH_SOEXTVER .%s.dylib
|
||||
define SH_SOPREFIX -Wl,-install_name,
|
||||
define LD_LIBRARY_PATH DYLD_LIBRARY_PATH
|
||||
define STRIPLIBFLAGS -x
|
||||
}
|
||||
*-*-ming* - *-*-cygwin - *-*-msys {
|
||||
define SHOBJ_CFLAGS ""
|
||||
define SHOBJ_LDFLAGS -shared
|
||||
define SH_CFLAGS ""
|
||||
define SH_LDFLAGS -shared
|
||||
define SH_LINKFLAGS ""
|
||||
define SH_SOEXT .dll
|
||||
define SH_SOEXTVER .dll
|
||||
define SH_SOPREFIX ""
|
||||
define LD_LIBRARY_PATH PATH
|
||||
}
|
||||
sparc* {
|
||||
if {[msg-quiet cc-check-decls __SUNPRO_C]} {
|
||||
msg-result "Found sun stdio compiler"
|
||||
# sun stdio compiler
|
||||
# XXX: These haven't been fully tested.
|
||||
define SHOBJ_CFLAGS -KPIC
|
||||
define SHOBJ_LDFLAGS "-G"
|
||||
define SH_CFLAGS -KPIC
|
||||
define SH_LINKFLAGS -Wl,-export-dynamic
|
||||
define SH_SOPREFIX -Wl,-h,
|
||||
} else {
|
||||
# sparc has a very small GOT table limit, so use -fPIC
|
||||
define SH_CFLAGS -fPIC
|
||||
define SHOBJ_CFLAGS -fPIC
|
||||
}
|
||||
}
|
||||
*-*-solaris* {
|
||||
if {[msg-quiet cc-check-decls __SUNPRO_C]} {
|
||||
msg-result "Found sun stdio compiler"
|
||||
# sun stdio compiler
|
||||
# XXX: These haven't been fully tested.
|
||||
define SHOBJ_CFLAGS -KPIC
|
||||
define SHOBJ_LDFLAGS "-G"
|
||||
define SH_CFLAGS -KPIC
|
||||
define SH_LINKFLAGS -Wl,-export-dynamic
|
||||
define SH_SOPREFIX -Wl,-h,
|
||||
}
|
||||
}
|
||||
*-*-hpux {
|
||||
# XXX: These haven't been tested
|
||||
define SHOBJ_CFLAGS "+O3 +z"
|
||||
define SHOBJ_LDFLAGS -b
|
||||
define SH_CFLAGS +z
|
||||
define SH_LINKFLAGS -Wl,+s
|
||||
define LD_LIBRARY_PATH SHLIB_PATH
|
||||
}
|
||||
}
|
||||
|
||||
if {![is-defined SHOBJ_LDFLAGS_R]} {
|
||||
define SHOBJ_LDFLAGS_R [get-define SHOBJ_LDFLAGS]
|
||||
}
|
||||
697
debuggers/openocd/jimtcl/autosetup/cc.tcl
Normal file
697
debuggers/openocd/jimtcl/autosetup/cc.tcl
Normal file
@ -0,0 +1,697 @@
|
||||
# Copyright (c) 2010 WorkWare Systems http://www.workware.net.au/
|
||||
# All rights reserved
|
||||
|
||||
# @synopsis:
|
||||
#
|
||||
# The 'cc' module supports checking various 'features' of the C or C++
|
||||
# compiler/linker environment. Common commands are cc-check-includes,
|
||||
# cc-check-types, cc-check-functions, cc-with, make-autoconf-h and make-template.
|
||||
#
|
||||
# The following environment variables are used if set:
|
||||
#
|
||||
## CC - C compiler
|
||||
## CXX - C++ compiler
|
||||
## CCACHE - Set to "none" to disable automatic use of ccache
|
||||
## CFLAGS - Additional C compiler flags
|
||||
## CXXFLAGS - Additional C++ compiler flags
|
||||
## LDFLAGS - Additional compiler flags during linking
|
||||
## LIBS - Additional libraries to use (for all tests)
|
||||
## CROSS - Tool prefix for cross compilation
|
||||
#
|
||||
# The following variables are defined from the corresponding
|
||||
# environment variables if set.
|
||||
#
|
||||
## CPPFLAGS
|
||||
## LINKFLAGS
|
||||
## CC_FOR_BUILD
|
||||
## LD
|
||||
|
||||
use system
|
||||
|
||||
module-options {}
|
||||
|
||||
# Note that the return code is not meaningful
|
||||
proc cc-check-something {name code} {
|
||||
uplevel 1 $code
|
||||
}
|
||||
|
||||
# Checks for the existence of the given function by linking
|
||||
#
|
||||
proc cctest_function {function} {
|
||||
cctest -link 1 -declare "extern void $function\(void);" -code "$function\();"
|
||||
}
|
||||
|
||||
# Checks for the existence of the given type by compiling
|
||||
proc cctest_type {type} {
|
||||
cctest -code "$type _x;"
|
||||
}
|
||||
|
||||
# Checks for the existence of the given type/structure member.
|
||||
# e.g. "struct stat.st_mtime"
|
||||
proc cctest_member {struct_member} {
|
||||
lassign [split $struct_member .] struct member
|
||||
cctest -code "static $struct _s; return sizeof(_s.$member);"
|
||||
}
|
||||
|
||||
# Checks for the existence of the given define by compiling
|
||||
#
|
||||
proc cctest_define {name} {
|
||||
cctest -code "#ifndef $name\n#error not defined\n#endif"
|
||||
}
|
||||
|
||||
# Checks for the existence of the given name either as
|
||||
# a macro (#define) or an rvalue (such as an enum)
|
||||
#
|
||||
proc cctest_decl {name} {
|
||||
cctest -code "#ifndef $name\n(void)$name;\n#endif"
|
||||
}
|
||||
|
||||
# @cc-check-sizeof type ...
|
||||
#
|
||||
# Checks the size of the given types (between 1 and 32, inclusive).
|
||||
# Defines a variable with the size determined, or "unknown" otherwise.
|
||||
# e.g. for type 'long long', defines SIZEOF_LONG_LONG.
|
||||
# Returns the size of the last type.
|
||||
#
|
||||
proc cc-check-sizeof {args} {
|
||||
foreach type $args {
|
||||
msg-checking "Checking for sizeof $type..."
|
||||
set size unknown
|
||||
# Try the most common sizes first
|
||||
foreach i {4 8 1 2 16 32} {
|
||||
if {[cctest -code "static int _x\[sizeof($type) == $i ? 1 : -1\] = { 1 };"]} {
|
||||
set size $i
|
||||
break
|
||||
}
|
||||
}
|
||||
msg-result $size
|
||||
set define [feature-define-name $type SIZEOF_]
|
||||
define $define $size
|
||||
}
|
||||
# Return the last result
|
||||
get-define $define
|
||||
}
|
||||
|
||||
# Checks for each feature in $list by using the given script.
|
||||
#
|
||||
# When the script is evaluated, $each is set to the feature
|
||||
# being checked, and $extra is set to any additional cctest args.
|
||||
#
|
||||
# Returns 1 if all features were found, or 0 otherwise.
|
||||
proc cc-check-some-feature {list script} {
|
||||
set ret 1
|
||||
foreach each $list {
|
||||
if {![check-feature $each $script]} {
|
||||
set ret 0
|
||||
}
|
||||
}
|
||||
return $ret
|
||||
}
|
||||
|
||||
# @cc-check-includes includes ...
|
||||
#
|
||||
# Checks that the given include files can be used
|
||||
proc cc-check-includes {args} {
|
||||
cc-check-some-feature $args {
|
||||
set with {}
|
||||
if {[dict exists $::autosetup(cc-include-deps) $each]} {
|
||||
set deps [dict keys [dict get $::autosetup(cc-include-deps) $each]]
|
||||
msg-quiet cc-check-includes {*}$deps
|
||||
foreach i $deps {
|
||||
if {[have-feature $i]} {
|
||||
lappend with $i
|
||||
}
|
||||
}
|
||||
}
|
||||
if {[llength $with]} {
|
||||
cc-with [list -includes $with] {
|
||||
cctest -includes $each
|
||||
}
|
||||
} else {
|
||||
cctest -includes $each
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# @cc-include-needs include required ...
|
||||
#
|
||||
# Ensures that when checking for 'include', a check is first
|
||||
# made for each 'required' file, and if found, it is #included
|
||||
proc cc-include-needs {file args} {
|
||||
foreach depfile $args {
|
||||
dict set ::autosetup(cc-include-deps) $file $depfile 1
|
||||
}
|
||||
}
|
||||
|
||||
# @cc-check-types type ...
|
||||
#
|
||||
# Checks that the types exist.
|
||||
proc cc-check-types {args} {
|
||||
cc-check-some-feature $args {
|
||||
cctest_type $each
|
||||
}
|
||||
}
|
||||
|
||||
# @cc-check-defines define ...
|
||||
#
|
||||
# Checks that the given preprocessor symbol is defined
|
||||
proc cc-check-defines {args} {
|
||||
cc-check-some-feature $args {
|
||||
cctest_define $each
|
||||
}
|
||||
}
|
||||
|
||||
# @cc-check-decls name ...
|
||||
#
|
||||
# Checks that each given name is either a preprocessor symbol or rvalue
|
||||
# such as an enum. Note that the define used for a decl is HAVE_DECL_xxx
|
||||
# rather than HAVE_xxx
|
||||
proc cc-check-decls {args} {
|
||||
set ret 1
|
||||
foreach name $args {
|
||||
msg-checking "Checking for $name..."
|
||||
set r [cctest_decl $name]
|
||||
define-feature "decl $name" $r
|
||||
if {$r} {
|
||||
msg-result "ok"
|
||||
} else {
|
||||
msg-result "not found"
|
||||
set ret 0
|
||||
}
|
||||
}
|
||||
return $ret
|
||||
}
|
||||
|
||||
# @cc-check-functions function ...
|
||||
#
|
||||
# Checks that the given functions exist (can be linked)
|
||||
proc cc-check-functions {args} {
|
||||
cc-check-some-feature $args {
|
||||
cctest_function $each
|
||||
}
|
||||
}
|
||||
|
||||
# @cc-check-members type.member ...
|
||||
#
|
||||
# Checks that the given type/structure members exist.
|
||||
# A structure member is of the form "struct stat.st_mtime"
|
||||
proc cc-check-members {args} {
|
||||
cc-check-some-feature $args {
|
||||
cctest_member $each
|
||||
}
|
||||
}
|
||||
|
||||
# @cc-check-function-in-lib function libs ?otherlibs?
|
||||
#
|
||||
# Checks that the given given function can be found in one of the libs.
|
||||
#
|
||||
# First checks for no library required, then checks each of the libraries
|
||||
# in turn.
|
||||
#
|
||||
# If the function is found, the feature is defined and lib_$function is defined
|
||||
# to -l$lib where the function was found, or "" if no library required.
|
||||
# In addition, -l$lib is added to the LIBS define.
|
||||
#
|
||||
# If additional libraries may be needed for linking, they should be specified
|
||||
# as $extralibs as "-lotherlib1 -lotherlib2".
|
||||
# These libraries are not automatically added to LIBS.
|
||||
#
|
||||
# Returns 1 if found or 0 if not.
|
||||
#
|
||||
proc cc-check-function-in-lib {function libs {otherlibs {}}} {
|
||||
msg-checking "Checking libs for $function..."
|
||||
set found 0
|
||||
cc-with [list -libs $otherlibs] {
|
||||
if {[cctest_function $function]} {
|
||||
msg-result "none needed"
|
||||
define lib_$function ""
|
||||
incr found
|
||||
} else {
|
||||
foreach lib $libs {
|
||||
cc-with [list -libs -l$lib] {
|
||||
if {[cctest_function $function]} {
|
||||
msg-result -l$lib
|
||||
define lib_$function -l$lib
|
||||
define-append LIBS -l$lib
|
||||
incr found
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if {$found} {
|
||||
define [feature-define-name $function]
|
||||
} else {
|
||||
msg-result "no"
|
||||
}
|
||||
return $found
|
||||
}
|
||||
|
||||
# @cc-check-tools tool ...
|
||||
#
|
||||
# Checks for existence of the given compiler tools, taking
|
||||
# into account any cross compilation prefix.
|
||||
#
|
||||
# For example, when checking for "ar", first AR is checked on the command
|
||||
# line and then in the environment. If not found, "${host}-ar" or
|
||||
# simply "ar" is assumed depending upon whether cross compiling.
|
||||
# The path is searched for this executable, and if found AR is defined
|
||||
# to the executable name.
|
||||
# Note that even when cross compiling, the simple "ar" is used as a fallback,
|
||||
# but a warning is generated. This is necessary for some toolchains.
|
||||
#
|
||||
# It is an error if the executable is not found.
|
||||
#
|
||||
proc cc-check-tools {args} {
|
||||
foreach tool $args {
|
||||
set TOOL [string toupper $tool]
|
||||
set exe [get-env $TOOL [get-define cross]$tool]
|
||||
if {[find-executable {*}$exe]} {
|
||||
define $TOOL $exe
|
||||
continue
|
||||
}
|
||||
if {[find-executable {*}$tool]} {
|
||||
msg-result "Warning: Failed to find $exe, falling back to $tool which may be incorrect"
|
||||
define $TOOL $tool
|
||||
continue
|
||||
}
|
||||
user-error "Failed to find $exe"
|
||||
}
|
||||
}
|
||||
|
||||
# @cc-check-progs prog ...
|
||||
#
|
||||
# Checks for existence of the given executables on the path.
|
||||
#
|
||||
# For example, when checking for "grep", the path is searched for
|
||||
# the executable, 'grep', and if found GREP is defined as "grep".
|
||||
#
|
||||
# It the executable is not found, the variable is defined as false.
|
||||
# Returns 1 if all programs were found, or 0 otherwise.
|
||||
#
|
||||
proc cc-check-progs {args} {
|
||||
set failed 0
|
||||
foreach prog $args {
|
||||
set PROG [string toupper $prog]
|
||||
msg-checking "Checking for $prog..."
|
||||
if {![find-executable $prog]} {
|
||||
msg-result no
|
||||
define $PROG false
|
||||
incr failed
|
||||
} else {
|
||||
msg-result ok
|
||||
define $PROG $prog
|
||||
}
|
||||
}
|
||||
expr {!$failed}
|
||||
}
|
||||
|
||||
# Adds the given settings to $::autosetup(ccsettings) and
|
||||
# returns the old settings.
|
||||
#
|
||||
proc cc-add-settings {settings} {
|
||||
if {[llength $settings] % 2} {
|
||||
autosetup-error "settings list is missing a value: $settings"
|
||||
}
|
||||
|
||||
set prev [cc-get-settings]
|
||||
# workaround a bug in some versions of jimsh by forcing
|
||||
# conversion of $prev to a list
|
||||
llength $prev
|
||||
|
||||
array set new $prev
|
||||
|
||||
foreach {name value} $settings {
|
||||
switch -exact -- $name {
|
||||
-cflags - -includes {
|
||||
# These are given as lists
|
||||
lappend new($name) {*}$value
|
||||
}
|
||||
-declare {
|
||||
lappend new($name) $value
|
||||
}
|
||||
-libs {
|
||||
# Note that new libraries are added before previous libraries
|
||||
set new($name) [list {*}$value {*}$new($name)]
|
||||
}
|
||||
-link - -lang {
|
||||
set new($name) $value
|
||||
}
|
||||
-source - -sourcefile - -code {
|
||||
# XXX: These probably are only valid directly from cctest
|
||||
set new($name) $value
|
||||
}
|
||||
default {
|
||||
autosetup-error "unknown cctest setting: $name"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cc-store-settings [array get new]
|
||||
|
||||
return $prev
|
||||
}
|
||||
|
||||
proc cc-store-settings {new} {
|
||||
set ::autosetup(ccsettings) $new
|
||||
}
|
||||
|
||||
proc cc-get-settings {} {
|
||||
return $::autosetup(ccsettings)
|
||||
}
|
||||
|
||||
# Similar to cc-add-settings, but each given setting
|
||||
# simply replaces the existing value.
|
||||
#
|
||||
# Returns the previous settings
|
||||
proc cc-update-settings {args} {
|
||||
set prev [cc-get-settings]
|
||||
cc-store-settings [dict merge $prev $args]
|
||||
return $prev
|
||||
}
|
||||
|
||||
# @cc-with settings ?{ script }?
|
||||
#
|
||||
# Sets the given 'cctest' settings and then runs the tests in 'script'.
|
||||
# Note that settings such as -lang replace the current setting, while
|
||||
# those such as -includes are appended to the existing setting.
|
||||
#
|
||||
# If no script is given, the settings become the default for the remainder
|
||||
# of the auto.def file.
|
||||
#
|
||||
## cc-with {-lang c++} {
|
||||
## # This will check with the C++ compiler
|
||||
## cc-check-types bool
|
||||
## cc-with {-includes signal.h} {
|
||||
## # This will check with the C++ compiler, signal.h and any existing includes.
|
||||
## ...
|
||||
## }
|
||||
## # back to just the C++ compiler
|
||||
## }
|
||||
#
|
||||
# The -libs setting is special in that newer values are added *before* earlier ones.
|
||||
#
|
||||
## cc-with {-libs {-lc -lm}} {
|
||||
## cc-with {-libs -ldl} {
|
||||
## cctest -libs -lsocket ...
|
||||
## # libs will be in this order: -lsocket -ldl -lc -lm
|
||||
## }
|
||||
## }
|
||||
proc cc-with {settings args} {
|
||||
if {[llength $args] == 0} {
|
||||
cc-add-settings $settings
|
||||
} elseif {[llength $args] > 1} {
|
||||
autosetup-error "usage: cc-with settings ?script?"
|
||||
} else {
|
||||
set save [cc-add-settings $settings]
|
||||
set rc [catch {uplevel 1 [lindex $args 0]} result info]
|
||||
cc-store-settings $save
|
||||
if {$rc != 0} {
|
||||
return -code [dict get $info -code] $result
|
||||
}
|
||||
return $result
|
||||
}
|
||||
}
|
||||
|
||||
# @cctest ?settings?
|
||||
#
|
||||
# Low level C compiler checker. Compiles and or links a small C program
|
||||
# according to the arguments and returns 1 if OK, or 0 if not.
|
||||
#
|
||||
# Supported settings are:
|
||||
#
|
||||
## -cflags cflags A list of flags to pass to the compiler
|
||||
## -includes list A list of includes, e.g. {stdlib.h stdio.h}
|
||||
## -declare code Code to declare before main()
|
||||
## -link 1 Don't just compile, link too
|
||||
## -lang c|c++ Use the C (default) or C++ compiler
|
||||
## -libs liblist List of libraries to link, e.g. {-ldl -lm}
|
||||
## -code code Code to compile in the body of main()
|
||||
## -source code Compile a complete program. Ignore -includes, -declare and -code
|
||||
## -sourcefile file Shorthand for -source [readfile [get-define srcdir]/$file]
|
||||
#
|
||||
# Unless -source or -sourcefile is specified, the C program looks like:
|
||||
#
|
||||
## #include <firstinclude> /* same for remaining includes in the list */
|
||||
##
|
||||
## declare-code /* any code in -declare, verbatim */
|
||||
##
|
||||
## int main(void) {
|
||||
## code /* any code in -code, verbatim */
|
||||
## return 0;
|
||||
## }
|
||||
#
|
||||
# Any failures are recorded in 'config.log'
|
||||
#
|
||||
proc cctest {args} {
|
||||
set src conftest__.c
|
||||
set tmp conftest__
|
||||
|
||||
# Easiest way to merge in the settings
|
||||
cc-with $args {
|
||||
array set opts [cc-get-settings]
|
||||
}
|
||||
|
||||
if {[info exists opts(-sourcefile)]} {
|
||||
set opts(-source) [readfile [get-define srcdir]/$opts(-sourcefile) "#error can't find $opts(-sourcefile)"]
|
||||
}
|
||||
if {[info exists opts(-source)]} {
|
||||
set lines $opts(-source)
|
||||
} else {
|
||||
foreach i $opts(-includes) {
|
||||
if {$opts(-code) ne "" && ![feature-checked $i]} {
|
||||
# Compiling real code with an unchecked header file
|
||||
# Quickly (and silently) check for it now
|
||||
|
||||
# Remove all -includes from settings before checking
|
||||
set saveopts [cc-update-settings -includes {}]
|
||||
msg-quiet cc-check-includes $i
|
||||
cc-store-settings $saveopts
|
||||
}
|
||||
if {$opts(-code) eq "" || [have-feature $i]} {
|
||||
lappend source "#include <$i>"
|
||||
}
|
||||
}
|
||||
lappend source {*}$opts(-declare)
|
||||
lappend source "int main(void) {"
|
||||
lappend source $opts(-code)
|
||||
lappend source "return 0;"
|
||||
lappend source "}"
|
||||
|
||||
set lines [join $source \n]
|
||||
}
|
||||
|
||||
# Build the command line
|
||||
set cmdline {}
|
||||
lappend cmdline {*}[get-define CCACHE]
|
||||
switch -exact -- $opts(-lang) {
|
||||
c++ {
|
||||
lappend cmdline {*}[get-define CXX] {*}[get-define CXXFLAGS]
|
||||
}
|
||||
c {
|
||||
lappend cmdline {*}[get-define CC] {*}[get-define CFLAGS]
|
||||
}
|
||||
default {
|
||||
autosetup-error "cctest called with unknown language: $opts(-lang)"
|
||||
}
|
||||
}
|
||||
|
||||
if {!$opts(-link)} {
|
||||
set tmp conftest__.o
|
||||
lappend cmdline -c
|
||||
}
|
||||
lappend cmdline {*}$opts(-cflags) {*}[get-define cc-default-debug ""]
|
||||
|
||||
lappend cmdline $src -o $tmp {*}$opts(-libs)
|
||||
|
||||
# At this point we have the complete command line and the
|
||||
# complete source to be compiled. Get the result from cache if
|
||||
# we can
|
||||
if {[info exists ::cc_cache($cmdline,$lines)]} {
|
||||
msg-checking "(cached) "
|
||||
set ok $::cc_cache($cmdline,$lines)
|
||||
if {$::autosetup(debug)} {
|
||||
configlog "From cache (ok=$ok): [join $cmdline]"
|
||||
configlog "============"
|
||||
configlog $lines
|
||||
configlog "============"
|
||||
}
|
||||
return $ok
|
||||
}
|
||||
|
||||
writefile $src $lines\n
|
||||
|
||||
set ok 1
|
||||
if {[catch {exec-with-stderr {*}$cmdline} result errinfo]} {
|
||||
configlog "Failed: [join $cmdline]"
|
||||
configlog $result
|
||||
configlog "============"
|
||||
configlog "The failed code was:"
|
||||
configlog $lines
|
||||
configlog "============"
|
||||
set ok 0
|
||||
} elseif {$::autosetup(debug)} {
|
||||
configlog "Compiled OK: [join $cmdline]"
|
||||
configlog "============"
|
||||
configlog $lines
|
||||
configlog "============"
|
||||
}
|
||||
file delete $src
|
||||
file delete $tmp
|
||||
|
||||
# cache it
|
||||
set ::cc_cache($cmdline,$lines) $ok
|
||||
|
||||
return $ok
|
||||
}
|
||||
|
||||
# @make-autoconf-h outfile ?auto-patterns=HAVE_*? ?bare-patterns=SIZEOF_*?
|
||||
#
|
||||
# Deprecated - see make-config-header
|
||||
proc make-autoconf-h {file {autopatterns {HAVE_*}} {barepatterns {SIZEOF_* HAVE_DECL_*}}} {
|
||||
user-notice "*** make-autoconf-h is deprecated -- use make-config-header instead"
|
||||
make-config-header $file -auto $autopatterns -bare $barepatterns
|
||||
}
|
||||
|
||||
# @make-config-header outfile ?-auto patternlist? ?-bare patternlist? ?-none patternlist? ?-str patternlist? ...
|
||||
#
|
||||
# Examines all defined variables which match the given patterns
|
||||
# and writes an include file, $file, which defines each of these.
|
||||
# Variables which match '-auto' are output as follows:
|
||||
# - defines which have the value "0" are ignored.
|
||||
# - defines which have integer values are defined as the integer value.
|
||||
# - any other value is defined as a string, e.g. "value"
|
||||
# Variables which match '-bare' are defined as-is.
|
||||
# Variables which match '-str' are defined as a string, e.g. "value"
|
||||
# Variables which match '-none' are omitted.
|
||||
#
|
||||
# Note that order is important. The first pattern which matches is selected
|
||||
# Default behaviour is:
|
||||
#
|
||||
# -bare {SIZEOF_* HAVE_DECL_*} -auto HAVE_* -none *
|
||||
#
|
||||
# If the file would be unchanged, it is not written.
|
||||
proc make-config-header {file args} {
|
||||
set guard _[string toupper [regsub -all {[^a-zA-Z0-9]} [file tail $file] _]]
|
||||
file mkdir [file dirname $file]
|
||||
set lines {}
|
||||
lappend lines "#ifndef $guard"
|
||||
lappend lines "#define $guard"
|
||||
|
||||
# Add some defaults
|
||||
lappend args -bare {SIZEOF_* HAVE_DECL_*} -auto HAVE_*
|
||||
|
||||
foreach n [lsort [dict keys [all-defines]]] {
|
||||
set value [get-define $n]
|
||||
set type [calc-define-output-type $n $args]
|
||||
switch -exact -- $type {
|
||||
-bare {
|
||||
# Just output the value unchanged
|
||||
}
|
||||
-none {
|
||||
continue
|
||||
}
|
||||
-str {
|
||||
set value \"[string map [list \\ \\\\ \" \\\"] $value]\"
|
||||
}
|
||||
-auto {
|
||||
# Automatically determine the type
|
||||
if {$value eq "0"} {
|
||||
lappend lines "/* #undef $n */"
|
||||
continue
|
||||
}
|
||||
if {![string is integer -strict $value]} {
|
||||
set value \"[string map [list \\ \\\\ \" \\\"] $value]\"
|
||||
}
|
||||
}
|
||||
"" {
|
||||
continue
|
||||
}
|
||||
default {
|
||||
autosetup-error "Unknown type in make-config-header: $type"
|
||||
}
|
||||
}
|
||||
lappend lines "#define $n $value"
|
||||
}
|
||||
lappend lines "#endif"
|
||||
set buf [join $lines \n]
|
||||
write-if-changed $file $buf {
|
||||
msg-result "Created $file"
|
||||
}
|
||||
}
|
||||
|
||||
proc calc-define-output-type {name spec} {
|
||||
foreach {type patterns} $spec {
|
||||
foreach pattern $patterns {
|
||||
if {[string match $pattern $name]} {
|
||||
return $type
|
||||
}
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
# Initialise some values from the environment or commandline or default settings
|
||||
foreach i {LDFLAGS LIBS CPPFLAGS LINKFLAGS {CFLAGS "-g -O2"}} {
|
||||
lassign $i var default
|
||||
define $var [get-env $var $default]
|
||||
}
|
||||
|
||||
if {[env-is-set CC]} {
|
||||
# Set by the user, so don't try anything else
|
||||
set try [list [get-env CC ""]]
|
||||
} else {
|
||||
# Try some reasonable options
|
||||
set try [list [get-define cross]cc [get-define cross]gcc]
|
||||
}
|
||||
define CC [find-an-executable {*}$try]
|
||||
if {[get-define CC] eq ""} {
|
||||
user-error "Could not find a C compiler. Tried: [join $try ", "]"
|
||||
}
|
||||
|
||||
define CPP [get-env CPP "[get-define CC] -E"]
|
||||
|
||||
# XXX: Could avoid looking for a C++ compiler until requested
|
||||
# Note that if CXX isn't found, we just set it to "false". It might not be needed.
|
||||
if {[env-is-set CXX]} {
|
||||
define CXX [find-an-executable -required [get-env CXX ""]]
|
||||
} else {
|
||||
define CXX [find-an-executable [get-define cross]c++ [get-define cross]g++ false]
|
||||
}
|
||||
|
||||
# CXXFLAGS default to CFLAGS if not specified
|
||||
define CXXFLAGS [get-env CXXFLAGS [get-define CFLAGS]]
|
||||
|
||||
# May need a CC_FOR_BUILD, so look for one
|
||||
define CC_FOR_BUILD [find-an-executable [get-env CC_FOR_BUILD ""] cc gcc false]
|
||||
|
||||
if {[get-define CC] eq ""} {
|
||||
user-error "Could not find a C compiler. Tried: [join $try ", "]"
|
||||
}
|
||||
|
||||
define CCACHE [find-an-executable [get-env CCACHE ccache]]
|
||||
|
||||
# Initial cctest settings
|
||||
cc-store-settings {-cflags {} -includes {} -declare {} -link 0 -lang c -libs {} -code {}}
|
||||
set autosetup(cc-include-deps) {}
|
||||
|
||||
msg-result "C compiler...[get-define CCACHE] [get-define CC] [get-define CFLAGS]"
|
||||
if {[get-define CXX] ne "false"} {
|
||||
msg-result "C++ compiler...[get-define CCACHE] [get-define CXX] [get-define CXXFLAGS]"
|
||||
}
|
||||
msg-result "Build C compiler...[get-define CC_FOR_BUILD]"
|
||||
|
||||
# On Darwin, we prefer to use -gstabs to avoid creating .dSYM directories
|
||||
# but some compilers don't support -gstabs, so test for it here.
|
||||
switch -glob -- [get-define host] {
|
||||
*-*-darwin* {
|
||||
if {[cctest -cflags {-gstabs}]} {
|
||||
define cc-default-debug -gstabs
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if {![cc-check-includes stdlib.h]} {
|
||||
user-error "Compiler does not work. See config.log"
|
||||
}
|
||||
1511
debuggers/openocd/jimtcl/autosetup/config.guess
vendored
Executable file
1511
debuggers/openocd/jimtcl/autosetup/config.guess
vendored
Executable file
File diff suppressed because it is too large
Load Diff
1743
debuggers/openocd/jimtcl/autosetup/config.sub
vendored
Executable file
1743
debuggers/openocd/jimtcl/autosetup/config.sub
vendored
Executable file
File diff suppressed because it is too large
Load Diff
25
debuggers/openocd/jimtcl/autosetup/default.auto
Normal file
25
debuggers/openocd/jimtcl/autosetup/default.auto
Normal file
@ -0,0 +1,25 @@
|
||||
# Copyright (c) 2012 WorkWare Systems http://www.workware.net.au/
|
||||
# All rights reserved
|
||||
|
||||
# Auto-load module for 'make' build system integration
|
||||
|
||||
use init
|
||||
|
||||
autosetup_add_init_type make {Simple "make" build system} {
|
||||
autosetup_check_create auto.def \
|
||||
{# Initial auto.def created by 'autosetup --init=make'
|
||||
|
||||
use cc
|
||||
|
||||
# Add any user options here
|
||||
options {
|
||||
}
|
||||
|
||||
make-config-header config.h
|
||||
make-template Makefile.in
|
||||
}
|
||||
|
||||
if {![file exists Makefile.in]} {
|
||||
puts "Note: I don't see Makefile.in. You will probably need to create one."
|
||||
}
|
||||
}
|
||||
16
debuggers/openocd/jimtcl/autosetup/find-tclsh
Executable file
16
debuggers/openocd/jimtcl/autosetup/find-tclsh
Executable file
@ -0,0 +1,16 @@
|
||||
#!/bin/sh
|
||||
# Looks for a suitable tclsh or jimsh in the PATH
|
||||
# If not found, builds a bootstrap jimsh from source
|
||||
d=`dirname "$0"`
|
||||
{ "$d/jimsh0" "$d/test-tclsh"; } 2>/dev/null && exit 0
|
||||
PATH="$PATH:$d"; export PATH
|
||||
for tclsh in jimsh tclsh tclsh8.5 tclsh8.6; do
|
||||
{ $tclsh "$d/test-tclsh"; } 2>/dev/null && exit 0
|
||||
done
|
||||
echo 1>&2 "No installed jimsh or tclsh, building local bootstrap jimsh0"
|
||||
for cc in ${CC_FOR_BUILD:-cc} gcc; do
|
||||
{ $cc -o "$d/jimsh0" "$d/jimsh0.c"; } 2>/dev/null || continue
|
||||
"$d/jimsh0" "$d/test-tclsh" && exit 0
|
||||
done
|
||||
echo 1>&2 "No working C compiler found. Tried ${CC_FOR_BUILD:-cc} and gcc."
|
||||
echo false
|
||||
21555
debuggers/openocd/jimtcl/autosetup/jimsh0.c
Normal file
21555
debuggers/openocd/jimtcl/autosetup/jimsh0.c
Normal file
File diff suppressed because it is too large
Load Diff
194
debuggers/openocd/jimtcl/autosetup/local.tcl
Normal file
194
debuggers/openocd/jimtcl/autosetup/local.tcl
Normal file
@ -0,0 +1,194 @@
|
||||
# The complex extension checking is done here.
|
||||
|
||||
global withinfo
|
||||
global extdb
|
||||
|
||||
# Final determination of module status
|
||||
dict set extdb status {}
|
||||
|
||||
# Returns 1 if the extension has the attribute
|
||||
proc ext-has {ext attr} {
|
||||
expr {$attr in [dict get $::extdb attrs $ext]}
|
||||
}
|
||||
|
||||
# Returns an entry from the extension 'info' table, or $default otherwise
|
||||
proc ext-get {ext key {default {}}} {
|
||||
if {[dict exists $::extdb info $ext $key]} {
|
||||
return [dict get $::extdb info $ext $key]
|
||||
} else {
|
||||
return $default
|
||||
}
|
||||
}
|
||||
|
||||
# Set the status of the extension to the given value, and returns the value
|
||||
proc ext-set-status {ext value} {
|
||||
dict set ::extdb status $ext $value
|
||||
return $value
|
||||
}
|
||||
|
||||
# Returns the status of the extension, or ? if unknown
|
||||
proc ext-get-status {ext} {
|
||||
if {[dict exists $::extdb status $ext]} {
|
||||
return [dict get $::extdb status $ext]
|
||||
}
|
||||
return ?
|
||||
}
|
||||
|
||||
proc check-extension-status {ext required} {
|
||||
global withinfo
|
||||
|
||||
set status [ext-get-status $ext]
|
||||
|
||||
if {$ext in $withinfo(without)} {
|
||||
# Disabled without further ado
|
||||
msg-result "Extension $ext...disabled"
|
||||
return [ext-set-status $ext n]
|
||||
}
|
||||
|
||||
if {$status in {m y n}} {
|
||||
return $status
|
||||
}
|
||||
|
||||
# required is "required" if this extension *must* be enabled
|
||||
# required is "wanted" if it is not fatal for this extension
|
||||
# not to be enabled
|
||||
|
||||
array set depinfo {m 0 y 0 n 0}
|
||||
|
||||
# Check direct dependencies
|
||||
if [ext-get $ext check 1] {
|
||||
# "check" conditions are met
|
||||
} else {
|
||||
# not met
|
||||
incr depinfo(n)
|
||||
}
|
||||
|
||||
if {$depinfo(n) == 0} {
|
||||
# Now extension dependencies
|
||||
foreach i [ext-get $ext dep] {
|
||||
set status [check-extension-status $i $required]
|
||||
#puts "$ext: dep $i $required => $status"
|
||||
incr depinfo($status)
|
||||
if {$depinfo(n)} {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#parray depinfo
|
||||
|
||||
if {$depinfo(n)} {
|
||||
msg-checking "Extension $ext..."
|
||||
if {$required eq "required"} {
|
||||
user-error "dependencies not met"
|
||||
}
|
||||
msg-result "disabled (dependencies)"
|
||||
return [ext-set-status $ext n]
|
||||
}
|
||||
|
||||
# Selected as a module?
|
||||
if {$ext in $withinfo(mod)} {
|
||||
if {[ext-has $ext tcl]} {
|
||||
# Easy, a Tcl module
|
||||
msg-result "Extension $ext...tcl"
|
||||
} elseif {[ext-has $ext static]} {
|
||||
user-error "Extension $ext can't be a module"
|
||||
} else {
|
||||
msg-result "Extension $ext...module"
|
||||
foreach i [ext-get $ext libdep] {
|
||||
define-append LDLIBS_$ext [get-define $i ""]
|
||||
}
|
||||
}
|
||||
return [ext-set-status $ext m]
|
||||
}
|
||||
|
||||
# Selected as a static extension?
|
||||
if {[ext-has $ext shared]} {
|
||||
user-error "Extension $ext can only be selected as a module"
|
||||
} elseif {$ext in $withinfo(ext) || $required eq "$required"} {
|
||||
msg-result "Extension $ext...enabled"
|
||||
} elseif {$ext in $withinfo(maybe)} {
|
||||
msg-result "Extension $ext...enabled (default)"
|
||||
} else {
|
||||
# Could be selected, but isn't (yet)
|
||||
return [ext-set-status $ext x]
|
||||
}
|
||||
foreach i [ext-get $ext libdep] {
|
||||
define-append LDLIBS [get-define $i ""]
|
||||
}
|
||||
return [ext-set-status $ext y]
|
||||
}
|
||||
|
||||
# Examines the user options (the $withinfo array)
|
||||
# and the extension database ($extdb) to determine
|
||||
# what is selected, and in what way.
|
||||
#
|
||||
# The results are available via ext-get-status
|
||||
# And a dictionary is returned containing four keys:
|
||||
# static-c extensions which are static C
|
||||
# static-tcl extensions which are static Tcl
|
||||
# module-c extensions which are C modules
|
||||
# module-tcl extensions which are Tcl modules
|
||||
proc check-extensions {} {
|
||||
global extdb withinfo
|
||||
|
||||
# Check valid extension names
|
||||
foreach i [concat $withinfo(ext) $withinfo(mod)] {
|
||||
if {![dict exists $extdb attrs $i]} {
|
||||
user-error "Unknown extension: $i"
|
||||
}
|
||||
}
|
||||
|
||||
set extlist [lsort [dict keys [dict get $extdb attrs]]]
|
||||
|
||||
set withinfo(maybe) {}
|
||||
|
||||
# Now work out the default status. We have.
|
||||
# normal case, include !optional if possible
|
||||
# --without=default, don't include optional
|
||||
if {$withinfo(nodefault)} {
|
||||
lappend withinfo(maybe) stdlib
|
||||
} else {
|
||||
foreach i $extlist {
|
||||
if {![ext-has $i optional]} {
|
||||
lappend withinfo(maybe) $i
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach i $extlist {
|
||||
define LDLIBS_$i ""
|
||||
}
|
||||
|
||||
foreach i [concat $withinfo(ext) $withinfo(mod)] {
|
||||
check-extension-status $i required
|
||||
}
|
||||
foreach i $withinfo(maybe) {
|
||||
check-extension-status $i wanted
|
||||
}
|
||||
|
||||
array set extinfo {static-c {} static-tcl {} module-c {} module-tcl {}}
|
||||
|
||||
foreach i $extlist {
|
||||
set status [ext-get-status $i]
|
||||
set tcl [ext-has $i tcl]
|
||||
switch $status,$tcl {
|
||||
y,1 {
|
||||
define jim_ext_$i
|
||||
lappend extinfo(static-tcl) $i
|
||||
}
|
||||
y,0 {
|
||||
define jim_ext_$i
|
||||
lappend extinfo(static-c) $i
|
||||
# If there are any static C++ extensions, jimsh must be linked using
|
||||
# the C++ compiler
|
||||
if {[ext-has $i cpp]} {
|
||||
define HAVE_CXX_EXTENSIONS
|
||||
}
|
||||
}
|
||||
m,1 { lappend extinfo(module-tcl) $i }
|
||||
m,0 { lappend extinfo(module-c) $i }
|
||||
}
|
||||
}
|
||||
return [array get extinfo]
|
||||
}
|
||||
269
debuggers/openocd/jimtcl/autosetup/system.tcl
Normal file
269
debuggers/openocd/jimtcl/autosetup/system.tcl
Normal file
@ -0,0 +1,269 @@
|
||||
# Copyright (c) 2010 WorkWare Systems http://www.workware.net.au/
|
||||
# All rights reserved
|
||||
|
||||
# @synopsis:
|
||||
#
|
||||
# This module supports common system interrogation and options
|
||||
# such as --host, --build, --prefix, and setting srcdir, builddir, and EXEXT.
|
||||
#
|
||||
# It also support the 'feature' naming convention, where searching
|
||||
# for a feature such as sys/type.h defines HAVE_SYS_TYPES_H
|
||||
#
|
||||
module-options {
|
||||
host:host-alias => {a complete or partial cpu-vendor-opsys for the system where
|
||||
the application will run (defaults to the same value as --build)}
|
||||
build:build-alias => {a complete or partial cpu-vendor-opsys for the system
|
||||
where the application will be built (defaults to the
|
||||
result of running config.guess)}
|
||||
prefix:dir => {the target directory for the build (defaults to /usr/local)}
|
||||
|
||||
# These (hidden) options are supported for autoconf/automake compatibility
|
||||
exec-prefix:
|
||||
bindir:
|
||||
sbindir:
|
||||
includedir:
|
||||
mandir:
|
||||
infodir:
|
||||
libexecdir:
|
||||
datadir:
|
||||
libdir:
|
||||
sysconfdir:
|
||||
sharedstatedir:
|
||||
localstatedir:
|
||||
maintainer-mode=0
|
||||
dependency-tracking=0
|
||||
}
|
||||
|
||||
# Returns 1 if exists, or 0 if not
|
||||
#
|
||||
proc check-feature {name code} {
|
||||
msg-checking "Checking for $name..."
|
||||
set r [uplevel 1 $code]
|
||||
define-feature $name $r
|
||||
if {$r} {
|
||||
msg-result "ok"
|
||||
} else {
|
||||
msg-result "not found"
|
||||
}
|
||||
return $r
|
||||
}
|
||||
|
||||
# @have-feature name ?default=0?
|
||||
#
|
||||
# Returns the value of the feature if defined, or $default if not.
|
||||
# See 'feature-define-name' for how the feature name
|
||||
# is translated into the define name.
|
||||
#
|
||||
proc have-feature {name {default 0}} {
|
||||
get-define [feature-define-name $name] $default
|
||||
}
|
||||
|
||||
# @define-feature name ?value=1?
|
||||
#
|
||||
# Sets the feature 'define' to the given value.
|
||||
# See 'feature-define-name' for how the feature name
|
||||
# is translated into the define name.
|
||||
#
|
||||
proc define-feature {name {value 1}} {
|
||||
define [feature-define-name $name] $value
|
||||
}
|
||||
|
||||
# @feature-checked name
|
||||
#
|
||||
# Returns 1 if the feature has been checked, whether true or not
|
||||
#
|
||||
proc feature-checked {name} {
|
||||
is-defined [feature-define-name $name]
|
||||
}
|
||||
|
||||
# @feature-define-name name ?prefix=HAVE_?
|
||||
#
|
||||
# Converts a name to the corresponding define,
|
||||
# e.g. sys/stat.h becomes HAVE_SYS_STAT_H.
|
||||
#
|
||||
# Converts * to P and all non-alphanumeric to underscore.
|
||||
#
|
||||
proc feature-define-name {name {prefix HAVE_}} {
|
||||
string toupper $prefix[regsub -all {[^a-zA-Z0-9]} [regsub -all {[*]} $name p] _]
|
||||
}
|
||||
|
||||
# If $file doesn't exist, or it's contents are different than $buf,
|
||||
# the file is written and $script is executed.
|
||||
# Otherwise a "file is unchanged" message is displayed.
|
||||
proc write-if-changed {file buf {script {}}} {
|
||||
set old [readfile $file ""]
|
||||
if {$old eq $buf && [file exists $file]} {
|
||||
msg-result "$file is unchanged"
|
||||
} else {
|
||||
writefile $file $buf\n
|
||||
uplevel 1 $script
|
||||
}
|
||||
}
|
||||
|
||||
# @make-template template ?outfile?
|
||||
#
|
||||
# Reads the input file <srcdir>/$template and writes the output file $outfile.
|
||||
# If $outfile is blank/omitted, $template should end with ".in" which
|
||||
# is removed to create the output file name.
|
||||
#
|
||||
# Each pattern of the form @define@ is replaced the the corresponding
|
||||
# define, if it exists, or left unchanged if not.
|
||||
#
|
||||
# The special value @srcdir@ is subsituted with the relative
|
||||
# path to the source directory from the directory where the output
|
||||
# file is created. Use @top_srcdir@ for the absolute path.
|
||||
#
|
||||
# Conditional sections may be specified as follows:
|
||||
## @if name == value
|
||||
## lines
|
||||
## @else
|
||||
## lines
|
||||
## @endif
|
||||
#
|
||||
# Where 'name' is a defined variable name and @else is optional.
|
||||
# If the expression does not match, all lines through '@endif' are ignored.
|
||||
#
|
||||
# The alternative forms may also be used:
|
||||
## @if name
|
||||
## @if name != value
|
||||
#
|
||||
# Where the first form is true if the variable is defined, but not empty or 0
|
||||
#
|
||||
# Currently these expressions can't be nested.
|
||||
#
|
||||
proc make-template {template {out {}}} {
|
||||
set infile [file join $::autosetup(srcdir) $template]
|
||||
|
||||
if {![file exists $infile]} {
|
||||
user-error "Template $template is missing"
|
||||
}
|
||||
|
||||
# Define this as late as possible
|
||||
define AUTODEPS $::autosetup(deps)
|
||||
|
||||
if {$out eq ""} {
|
||||
if {[file ext $template] ne ".in"} {
|
||||
autosetup-error "make_template $template has no target file and can't guess"
|
||||
}
|
||||
set out [file rootname $template]
|
||||
}
|
||||
|
||||
set outdir [file dirname $out]
|
||||
|
||||
# Make sure the directory exists
|
||||
file mkdir $outdir
|
||||
|
||||
# Set up srcdir to be relative to the target dir
|
||||
define srcdir [relative-path [file join $::autosetup(srcdir) $outdir] $outdir]
|
||||
|
||||
set mapping {}
|
||||
foreach {n v} [array get ::define] {
|
||||
lappend mapping @$n@ $v
|
||||
}
|
||||
set result {}
|
||||
foreach line [split [readfile $infile] \n] {
|
||||
if {[info exists cond]} {
|
||||
set l [string trimright $line]
|
||||
if {$l eq "@endif"} {
|
||||
unset cond
|
||||
continue
|
||||
}
|
||||
if {$l eq "@else"} {
|
||||
set cond [expr {!$cond}]
|
||||
continue
|
||||
}
|
||||
if {$cond} {
|
||||
lappend result $line
|
||||
}
|
||||
continue
|
||||
}
|
||||
if {[regexp {^@if\s+(\w+)(.*)} $line -> name expression]} {
|
||||
lassign $expression equal value
|
||||
set varval [get-define $name ""]
|
||||
if {$equal eq ""} {
|
||||
set cond [expr {$varval ni {"" 0}}]
|
||||
} else {
|
||||
set cond [expr {$varval eq $value}]
|
||||
if {$equal ne "=="} {
|
||||
set cond [expr {!$cond}]
|
||||
}
|
||||
}
|
||||
continue
|
||||
}
|
||||
lappend result $line
|
||||
}
|
||||
writefile $out [string map $mapping [join $result \n]]\n
|
||||
|
||||
msg-result "Created [relative-path $out] from [relative-path $template]"
|
||||
}
|
||||
|
||||
# build/host tuples and cross-compilation prefix
|
||||
set build [opt-val build]
|
||||
define build_alias $build
|
||||
if {$build eq ""} {
|
||||
define build [config_guess]
|
||||
} else {
|
||||
define build [config_sub $build]
|
||||
}
|
||||
|
||||
set host [opt-val host]
|
||||
define host_alias $host
|
||||
if {$host eq ""} {
|
||||
define host [get-define build]
|
||||
set cross ""
|
||||
} else {
|
||||
define host [config_sub $host]
|
||||
set cross $host-
|
||||
}
|
||||
define cross [get-env CROSS $cross]
|
||||
|
||||
# Do "define defaultprefix myvalue" to set the default prefix *before* the first "use"
|
||||
set prefix [opt-val prefix [get-define defaultprefix /usr/local]]
|
||||
|
||||
# These are for compatibility with autoconf
|
||||
define target [get-define host]
|
||||
define prefix $prefix
|
||||
define builddir $autosetup(builddir)
|
||||
define srcdir $autosetup(srcdir)
|
||||
# Allow this to come from the environment
|
||||
define top_srcdir [get-env top_srcdir [get-define srcdir]]
|
||||
|
||||
# autoconf supports all of these
|
||||
set exec_prefix [opt-val exec-prefix $prefix]
|
||||
define exec_prefix $exec_prefix
|
||||
foreach {name defpath} {
|
||||
bindir /bin
|
||||
sbindir /sbin
|
||||
libexecdir /libexec
|
||||
libdir /lib
|
||||
} {
|
||||
define $name [opt-val $name $exec_prefix$defpath]
|
||||
}
|
||||
foreach {name defpath} {
|
||||
datadir /share
|
||||
sysconfdir /etc
|
||||
sharedstatedir /com
|
||||
localstatedir /var
|
||||
infodir /share/info
|
||||
mandir /share/man
|
||||
includedir /include
|
||||
} {
|
||||
define $name [opt-val $name $prefix$defpath]
|
||||
}
|
||||
|
||||
define SHELL [get-env SHELL [find-an-executable sh bash ksh]]
|
||||
|
||||
# Windows vs. non-Windows
|
||||
switch -glob -- [get-define host] {
|
||||
*-*-ming* - *-*-cygwin - *-*-msys {
|
||||
define-feature windows
|
||||
define EXEEXT .exe
|
||||
}
|
||||
default {
|
||||
define EXEEXT ""
|
||||
}
|
||||
}
|
||||
|
||||
# Display
|
||||
msg-result "Host System...[get-define host]"
|
||||
msg-result "Build System...[get-define build]"
|
||||
20
debuggers/openocd/jimtcl/autosetup/test-tclsh
Normal file
20
debuggers/openocd/jimtcl/autosetup/test-tclsh
Normal file
@ -0,0 +1,20 @@
|
||||
# A small Tcl script to verify that the chosen
|
||||
# interpreter works. Sometimes we might e.g. pick up
|
||||
# an interpreter for a different arch.
|
||||
# Outputs the full path to the interpreter
|
||||
|
||||
if {[catch {info version} version] == 0} {
|
||||
# This is Jim Tcl
|
||||
if {$version >= 0.72} {
|
||||
# Ensure that regexp works
|
||||
regexp (a.*?) a
|
||||
puts [info nameofexecutable]
|
||||
exit 0
|
||||
}
|
||||
} elseif {[catch {info tclversion} version] == 0} {
|
||||
if {$version >= 8.5 && ![string match 8.5a* [info patchlevel]]} {
|
||||
puts [info nameofexecutable]
|
||||
exit 0
|
||||
}
|
||||
}
|
||||
exit 1
|
||||
Reference in New Issue
Block a user