diff options
author | Steve Bennett <steveb@workware.net.au> | 2011-08-18 13:43:47 +1000 |
---|---|---|
committer | Steve Bennett <steveb@workware.net.au> | 2011-08-18 20:13:37 +1000 |
commit | 6f288aab0c5797f844ee458dd98f30b1f3db62c6 (patch) | |
tree | 630afcf247b6c60d9f04d31589d9a7a9d64aabb2 | |
parent | 645ed6fd4b6f9038c7e1d85d74c3872b3cb9a507 (diff) | |
download | jimtcl-6f288aab0c5797f844ee458dd98f30b1f3db62c6.zip jimtcl-6f288aab0c5797f844ee458dd98f30b1f3db62c6.tar.gz jimtcl-6f288aab0c5797f844ee458dd98f30b1f3db62c6.tar.bz2 |
Fix build on Solaris (gcc)
inet_ntop needs -lnsl on Solaris
Solaris has sysinfo, but no uptime
Link flags need to be a bit different
Signed-off-by: Steve Bennett <steveb@workware.net.au>
-rw-r--r-- | auto.def | 22 | ||||
-rwxr-xr-x | autosetup/autosetup | 38 | ||||
-rw-r--r-- | autosetup/cc-shared.tcl | 19 | ||||
-rw-r--r-- | autosetup/system.tcl | 52 | ||||
-rw-r--r-- | jim-posix.c | 4 |
5 files changed, 120 insertions, 15 deletions
@@ -64,17 +64,28 @@ cc-check-types "long long" cc-check-includes sys/socket.h netinet/in.h arpa/inet.h netdb.h cc-check-includes sys/un.h dlfcn.h unistd.h crt_externs.h -# Haiku needs -lnetwork -if {[cc-check-function-in-lib inet_ntop network]} { - if {[get-define lib_inet_ntop] ne ""} { - cc-with {-libs -lnetwork} +# Haiku needs -lnetwork, Solaris needs -lnsl +if {[cc-check-function-in-lib inet_ntop {nsl network}]} { + # This does nothing if no libs are needed + cc-with [list -libs [get-define lib_inet_ntop]] +} +# Solaris needs -lsocket, Windows needs -lwsock32 +if {![cc-check-function-in-lib socket socket]} { + # Last resort, may be Windows + if {[string match *mingw* [get-define host]]} { + define-append LIBS -lwsock32 } } -cc-check-functions ualarm sysinfo lstat fork vfork system select +cc-check-functions ualarm lstat fork vfork system select cc-check-functions backtrace geteuid mkstemp realpath strptime gettimeofday cc-check-functions regcomp waitpid sigaction sys_signame sys_siglist cc-check-functions syslog opendir readlink sleep usleep pipe getaddrinfo +if {[cc-check-functions sysinfo]} { + cc-with {-includes sys/sysinfo.h} { + cc-check-members "struct sysinfo.uptime" + } +} define TCL_LIBRARY [get-define prefix]/lib/jim @@ -214,7 +225,6 @@ set dep(rlprompt) readline set dep(tree) oo set dep(binary) pack -set needs(aio) {expr {[cc-check-function-in-lib socket socket] || 1}} set needs(exec) {expr {([have-feature vfork] && [have-feature waitpid]) || [have-feature system]}} set needs(load) {expr {[cc-check-function-in-lib dlopen dl] || [have-feature dlopen-compat]}} set needs(posix) {have-feature waitpid} diff --git a/autosetup/autosetup b/autosetup/autosetup index fae164e..9cd9622 100755 --- a/autosetup/autosetup +++ b/autosetup/autosetup @@ -184,7 +184,7 @@ proc main {argv} { # # Check each of the named, boolean options and return 1 if any of them have # been set by the user. -# +# proc opt-bool {args} { option-check-names {*}$args opt_bool ::useropts {*}$args @@ -200,7 +200,7 @@ proc opt-bool {args} { ## lindex [opt-val $names] end # # If no options were set, $default is returned (exactly, not as a list). -# +# proc opt-val {names {default ""}} { option-check-names {*}$names join [opt_val ::useropts $names $default] @@ -398,7 +398,7 @@ proc options-show {} { # For example, --disable-lfs is an alias for --disable=largefile: # ## lfs=1 largefile=1 => "Disable large file support" -# +# proc options {optlist} { # Allow options as a list or args options-add $optlist "Local Options:" @@ -436,7 +436,7 @@ proc config_sub {alias} { } # @define name ?value=1? -# +# # Defines the named variable to the given value. # These (name, value) pairs represent the results of the configuration check # and are available to be checked, modified and substituted. @@ -567,6 +567,36 @@ proc quote-argv {argv} { join $args } +# @suffix suf list +# +# Takes a list and returns a new list with $suf appended +# to each element +# +## suffix .c {a b c} => {a.c b.c c.c} +# +proc suffix {suf list} { + set result {} + foreach p $list { + lappend result $p$suf + } + return $result +} + +# @prefix pre list +# +# Takes a list and returns a new list with $pre prepended +# to each element +# +## prefix jim- {a.c b.c} => {jim-a.c jim-b.c} +# +proc prefix {pre list} { + set result {} + foreach p $list { + lappend result $pre$p + } + return $result +} + # @find-executable name # # Searches the path for an executable with the given name. diff --git a/autosetup/cc-shared.tcl b/autosetup/cc-shared.tcl index 6de498d..b59816c 100644 --- a/autosetup/cc-shared.tcl +++ b/autosetup/cc-shared.tcl @@ -37,12 +37,27 @@ switch -glob -- [get-define host] { define SH_LDFLAGS -shared define SHOBJ_LDFLAGS -shared } + *-*-solaris* { + # XXX: These haven't been fully tested. + #define SH_LINKFLAGS -Wl,-export-dynamic + define SH_CFLAGS -Kpic + define SHOBJ_CFLAGS -Kpic + define SHOBJ_LDFLAGS "-G" + } + *-*-hpux { + # XXX: These haven't been tested + define SH_LINKFLAGS -Wl,+s + define SH_CFLAGS +z + define SHOBJ_CFLAGS "+O3 +z" + define SHOBJ_LDFLAGS -b + define LD_LIBRARY_PATH SHLIB_PATH + } * { # Generic Unix settings define SH_LINKFLAGS -rdynamic - define SH_CFLAGS -fPIC + define SH_CFLAGS -fpic define SH_LDFLAGS -shared - define SHOBJ_CFLAGS -fPIC + define SHOBJ_CFLAGS -fpic define SHOBJ_LDFLAGS "-shared -nostartfiles" } } diff --git a/autosetup/system.tcl b/autosetup/system.tcl index 8915273..b72dfbc 100644 --- a/autosetup/system.tcl +++ b/autosetup/system.tcl @@ -113,6 +113,24 @@ proc write-if-changed {file buf {script {}}} { # 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] @@ -142,7 +160,39 @@ proc make-template {template {out {}}} { foreach {n v} [array get ::define] { lappend mapping @$n@ $v } - writefile $out [string map $mapping [readfile $infile]]\n + 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]" } diff --git a/jim-posix.c b/jim-posix.c index eeec649..2015f5f 100644 --- a/jim-posix.c +++ b/jim-posix.c @@ -29,7 +29,7 @@ #include "jim.h" #include "jimautoconf.h" -#ifdef HAVE_SYSINFO +#ifdef HAVE_SYS_SYSINFO_H #include <sys/sysinfo.h> #endif @@ -183,7 +183,7 @@ static int Jim_PosixGethostnameCommand(Jim_Interp *interp, int argc, Jim_Obj *co static int Jim_PosixUptimeCommand(Jim_Interp *interp, int argc, Jim_Obj *const *argv) { -#ifdef HAVE_SYSINFO +#ifdef HAVE_STRUCT_SYSINFO_UPTIME struct sysinfo info; if (argc != 1) { |