diff options
author | Steve Bennett <steveb@workware.net.au> | 2010-08-17 19:45:23 +1000 |
---|---|---|
committer | Steve Bennett <steveb@workware.net.au> | 2010-10-15 10:11:02 +1000 |
commit | cc08c28c0bc63e5ce95ff4f7ed1cae98cbb27cd8 (patch) | |
tree | 6e6a56923b71423366305d18dda9dbff9a951a6f | |
parent | f116d36df4673b84d5fa991c34fb02f27fa0aa35 (diff) | |
download | jimtcl-cc08c28c0bc63e5ce95ff4f7ed1cae98cbb27cd8.zip jimtcl-cc08c28c0bc63e5ce95ff4f7ed1cae98cbb27cd8.tar.gz jimtcl-cc08c28c0bc63e5ce95ff4f7ed1cae98cbb27cd8.tar.bz2 |
Add autoconf-based build
Signed-off-by: Steve Bennett <steveb@workware.net.au>
-rw-r--r-- | Makefile.in | 54 | ||||
-rw-r--r-- | configure.ac | 46 | ||||
-rw-r--r-- | jim-array-1.0.tcl | 104 | ||||
-rw-r--r-- | jim-glob-1.0.tcl | 133 | ||||
-rw-r--r-- | make-load-extensions.sh | 17 |
5 files changed, 117 insertions, 237 deletions
diff --git a/Makefile.in b/Makefile.in new file mode 100644 index 0000000..f431d65 --- /dev/null +++ b/Makefile.in @@ -0,0 +1,54 @@ +RANLIB ?= ranlib + +# Configuration + +jim_nofork := @JIM_NOFORK@ + +# Defines the extensions to include +EXTENSIONS := @JIM_EXTENSIONS@ + +ALL_EXTENSIONS := aio clock eventloop exec file posix readdir readline regexp sdl sqlite sqlite3 + +# Set an initial, default library and auto_path +CFLAGS += -DTCL_LIBRARY=\"/lib/tcl6\" + +STATIC_LIBTCL := libtcl6.a +CFLAGS += -Wall -g -Os -I. @EXTRA_CFLAGS@ + +.EXPORT_ALL_VARIABLES: + +OBJS := jim-load.o jim-package.o jim-subcmd.o jim-interactive.o jim.o + +SDKHDRS := jim.h jim-subcmd.h + +EXTENSIONS_OBJS := $(patsubst %,jim-%.o,$(EXTENSIONS)) + +# Emulate tinytcl +LIBJIM := libtcl6.a + +ifdef jim_nofork + CFLAGS += -DNO_FORK +endif + +OBJS += load_extensions.o + +TARGETS += jimsh $(LIBJIM) + +all: $(TARGETS) + +jimsh: $(LIBJIM) jimsh.o + $(CC) $(LDFLAGS) -o $@ $^ $(LIBJIM) $(LDLIBS) $(LIBDL) + +$(LIBJIM): $(OBJS) $(EXTENSIONS_OBJS) + $(AR) cr $@ $^ + $(RANLIB) $@ + +load_extensions.c: + sh make-load-extensions.sh $@ $(EXTENSIONS) + +install: + install -d $(DESTDIR)/lib/tcl6 + install -m 644 array.tcl glob.tcl stdio.tcl tcl6.tcl $(DESTDIR)/lib/tcl6 + +clean: + rm -f *.o lib*.a $(TARGETS) load_extensions.c diff --git a/configure.ac b/configure.ac new file mode 100644 index 0000000..ca013b5 --- /dev/null +++ b/configure.ac @@ -0,0 +1,46 @@ +# -*- Autoconf -*- +# Process this file with autoconf to produce a configure script. + +AC_PREREQ(2.57) +AC_INIT([jim], [0.60], [steveb@workware.net.au]) + +AC_SUBST(TARGET_PLATFORM,$ac_cv_host) + +# Checks for programs. +AC_PROG_CC +AC_PROG_MAKE_SET + +AC_ARG_ENABLE(fork, + [ --disable-fork Do not use fork (no exec, etc.)], + [ + if test "x$enableval" = "xno" ; then + AC_MSG_RESULT(* disabling fork) + JIM_NOFORK=1 + fi + ], +) +AC_SUBST(JIM_NOFORK,$JIM_NOFORK) + +jim_extensions= +AC_ARG_WITH(jim-ext, + [ --with-jim-ext Specify jim extensions to build], + [ + if test "x$withval" != "xno" ; then + jim_extensions="$withval" + fi + ] +) +AC_MSG_RESULT(enabling jim extensions: $jim_extensions) +for i in $jim_extensions; do + AC_SUBST(JIM_EXTENSIONS,$jim_extensions) +done + +AC_CHECK_FUNCS([ualarm],EXTRA_CFLAGS="$EXTRA_CFLAGS -DHAVE_UALARM") + +AC_SUBST(JIM_EXTENSIONS,$JIM_EXTENSIONS) +AC_SUBST(EXTRA_CFLAGS,$EXTRA_CFLAGS) + +AC_CHECK_LIB(dl, dlopen,AC_SUBST(LIBDL,-ldl)) + +AC_CONFIG_FILES([Makefile]) +AC_OUTPUT diff --git a/jim-array-1.0.tcl b/jim-array-1.0.tcl deleted file mode 100644 index a1298c0..0000000 --- a/jim-array-1.0.tcl +++ /dev/null @@ -1,104 +0,0 @@ -# (c) 2008 Steve Bennett <steveb@workware.net.au>
-#
-# Implements a Tcl-compatible array command based on dict
-#
-# The FreeBSD license
-#
-# 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 JIM TCL PROJECT ``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 THE
-# JIM TCL PROJECT 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 the Jim Tcl Project.
-
-package provide array 1.0
-
-proc array {subcmd arrayname args} {
- # $name is the name of the array in the caller's context
- upvar $arrayname name
-
- if {$subcmd eq "exists"} {
- return [info exists name]
- }
-
- if {![info exists name]} {
- set name [dict create]
- }
-
- switch $subcmd {
- set {
- # The argument should be a list, but we also
- # support name value pairs
- if {[llength $args] == 1} {
- set args [lindex $args 0]
- }
- foreach {key value} $args {
- dict set name $key $value
- }
- return $name
- }
- size {
- return [/ [llength $name] 2]
- }
- }
-
- # The remaining options take a pattern
- if {[llength $args] > 0} {
- set pattern [lindex $args 0]
- } else {
- set pattern *
- }
-
- switch $subcmd {
- names {
- set keys {}
- foreach {key value} $name {
- if {[string match $pattern $key]} {
- lappend keys $key
- }
- }
- return $keys
- }
- get {
- set list {}
- foreach {key value} $name {
- if {[string match $pattern $key]} {
- lappend list $key $value
- }
- }
- return $list
- }
- unset {
- foreach {key value} $args {
- if {[string match $pattern $key]} {
- dict unset name $key
- }
- }
- return
- }
- }
-
- # Tcl-compatible error message
- error "bad option \"$subcmd\": must be exists, get, names, set, size, or unset"
-}
diff --git a/jim-glob-1.0.tcl b/jim-glob-1.0.tcl deleted file mode 100644 index 9529df0..0000000 --- a/jim-glob-1.0.tcl +++ /dev/null @@ -1,133 +0,0 @@ -# (c) 2008 Steve Bennett <steveb@workware.net.au>
-#
-# Implements a Tcl-compatible glob command based on readdir
-#
-# The FreeBSD license
-#
-# 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 JIM TCL PROJECT ``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 THE
-# JIM TCL PROJECT 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 the Jim Tcl Project.
-
-package provide glob 1.0
-package require readdir 1.0
-
-# If $dir is a directory, return a list of all entries
-# it contains which match $pattern
-#
-proc _glob_readdir_pattern {dir pattern} {
- set result {}
-
- # readdir doesn't return . or .., so simulate it here
- if {$pattern eq "." || $pattern eq ".."} {
- return $pattern
- }
- # Use -nocomplain here to return nothing if $dir is not a directory
- foreach name [readdir -nocomplain $dir] {
- if {[string match $pattern $name]} {
- lappend result $name
- }
- }
-
- return $result
-}
-
-# glob entries in directory $dir and pattern $rem
-#
-proc _glob_do {dir rem} {
- # Take one level from rem
- # Avoid regexp here
- set i [string first / $rem]
- if {$i < 0} {
- set pattern $rem
- set rempattern ""
- } else {
- set j $i
- incr j
- incr i -1
- set pattern [string range $rem 0 $i]
- set rempattern [string range $rem $j end]
- }
-
- # Determine the appropriate separator and globbing dir
- set sep /
- set globdir $dir
- if {[string match "*/" $dir]} {
- set sep ""
- } elseif {$dir eq ""} {
- set globdir .
- set sep ""
- }
-
- set result {}
-
- # Use readdir and select all files which match the pattern
- foreach f [_glob_readdir_pattern $globdir $pattern] {
- if {$rempattern eq ""} {
- # This is a terminal entry, so add it
- lappend result $dir$sep$f
- } else {
- # Expany any entries at this level and add them
- lappend result {expand}[_glob_do $dir$sep$f $rempattern]
- }
- }
- return $result
-}
-
-# Implements the Tcl glob command
-#
-# Usage: glob ?-nocomplain? pattern ...
-#
-# Patterns use string match pattern matching for each
-# directory level.
-#
-# e.g. glob te[a-e]*/*.tcl
-#
-proc glob {args} {
- set nocomplain 0
-
- if {[lindex $args 0] eq "-nocomplain"} {
- set nocomplain 1
- set args [lrange $args 1 end]
- }
-
- set result {}
- foreach pattern $args {
- if {$pattern eq "/"} {
- lappend result /
- } elseif {[string match "/*" $pattern]} {
- lappend result {expand}[_glob_do / [string range $pattern 1 end]]
- } else {
- lappend result {expand}[_glob_do "" $pattern]
- }
- }
-
- if {$nocomplain == 0 && [llength $result] == 0} {
- error "no files matched glob patterns"
- }
-
- return $result
-}
diff --git a/make-load-extensions.sh b/make-load-extensions.sh new file mode 100644 index 0000000..a03a472 --- /dev/null +++ b/make-load-extensions.sh @@ -0,0 +1,17 @@ +#!/bin/sh + +exec >$1 + +shift + +echo '#include "jim.h"' +for i in "$@"; do + name=`echo $i | sed -e 's@.*/\(.*\).c@\1@'` + echo "extern void Jim_${name}Init(Jim_Interp *interp);" +done +echo "void Jim_InitStaticExtensions(Jim_Interp *interp) {" +for i in "$@"; do + name=`echo $i | sed -e 's@.*/\(.*\).c@\1@'` + echo "Jim_${name}Init(interp);" +done +echo "}" |