drh | 4b2266a | 2004-11-27 15:52:16 +0000 | [diff] [blame] | 1 | # This script attempts to install SQLite3 so that it can be used |
| 2 | # by TCL. Invoke this script with single argument which is the |
| 3 | # version number of SQLite. Example: |
| 4 | # |
| 5 | # tclsh tclinstaller.tcl 3.0 |
| 6 | # |
| 7 | set VERSION [lindex $argv 0] |
| 8 | set LIBFILE .libs/libtclsqlite3[info sharedlibextension] |
drh | d5b6b38 | 2005-01-30 22:10:00 +0000 | [diff] [blame] | 9 | if { ![info exists env(DESTDIR)] } { set env(DESTDIR) "" } |
vapier | acf1a93 | 2007-05-03 20:06:11 +0000 | [diff] [blame] | 10 | if { ![info exists env(TCLLIBDIR)] } { set env(TCLLIBDIR) [lindex $auto_path 0] } |
| 11 | set LIBDIR $env(DESTDIR)$env(TCLLIBDIR) |
| 12 | set LIBDIR_INSTALL $env(TCLLIBDIR) |
drh | 4b2266a | 2004-11-27 15:52:16 +0000 | [diff] [blame] | 13 | set LIBNAME [file tail $LIBFILE] |
| 14 | set LIB $LIBDIR/sqlite3/$LIBNAME |
vapier | acf1a93 | 2007-05-03 20:06:11 +0000 | [diff] [blame] | 15 | set LIB_INSTALL $LIBDIR_INSTALL/sqlite3/$LIBNAME |
drh | 4b2266a | 2004-11-27 15:52:16 +0000 | [diff] [blame] | 16 | |
| 17 | file delete -force $LIBDIR/sqlite3 |
| 18 | file mkdir $LIBDIR/sqlite3 |
| 19 | set fd [open $LIBDIR/sqlite3/pkgIndex.tcl w] |
vapier | acf1a93 | 2007-05-03 20:06:11 +0000 | [diff] [blame] | 20 | puts $fd "package ifneeded sqlite3 $VERSION \[list load $LIB_INSTALL sqlite3\]" |
drh | 4b2266a | 2004-11-27 15:52:16 +0000 | [diff] [blame] | 21 | close $fd |
| 22 | |
| 23 | # We cannot use [file copy] because that will just make a copy of |
| 24 | # a symbolic link. We have to open and copy the file for ourselves. |
| 25 | # |
| 26 | set in [open $LIBFILE] |
| 27 | fconfigure $in -translation binary |
| 28 | set out [open $LIB w] |
| 29 | fconfigure $out -translation binary |
| 30 | puts -nonewline $out [read $in] |
| 31 | close $in |
| 32 | close $out |