#!/bin/sh
# Note that lines preceeded by a comment ending in a backslash are interpreted
# by the shell only, not by tksipp.
# ... \
LD_LIBRARY_PATH=/home/pdw/PROJECTS/TSIPPwb/lib; export LD_LIBRARY_PATH
# ... \
TCL_LIBRARY=/home/pdw/PROJECTS/TSIPPwb/lib;     export TCL_LIBRARY
# ... \
PATH=/home/pdw/PROJECTS/TSIPPwb/bin:$PATH;      export PATH
# ... \
exec tksipp "$0" "$@"

# -----------------------------------------------------------------------------
# TSIPPwb --
#
#       This script creates the release directory structure from the
#       development directory.
# -----------------------------------------------------------------------------
# Copyright 2001 Paul Welton
#       Permission to use, copy, modify, and distribute this software and its
#       documentation for any purpose and without fee is hereby granted,
#       provided that this copyright notice appears in all copies.  No
#       representations are made about the suitability of this software for any
#       purpose.  It is provided "as is" without express or implied warranty.
# -----------------------------------------------------------------------------
# Revision:   1.0   : Initial Release
# -----------------------------------------------------------------------------

    if {$argc == 2} {
        set rel [lindex $argv 1]
    } else {
        puts "Usage: \"createRelease <rel>\""
        exit 1
    }
    
    puts "TSIPPwb release creation executing under tclsh $tcl_patchLevel"
    set relDir /home/pdw/PROJECTS/TSIPPwb$rel
    set devDir /home/pdw/PROJECTS/TSIPPwb
    
    if {[file exists $relDir]} {
        puts "Release directory \"$relDir\" already exists."
        exit 1
    }
    
    puts "Creating release directory $relDir ..."
    file mkdir $relDir
    cd         $relDir
    
    #  files copied directly from development directory ...
    foreach filename {README INSTALL} {
        file copy [file join $devDir $filename] $filename
        exec chmod ugo-w [file join $relDir $filename]
    }
    
    #  directories copied directly from development directory ...
    foreach subDir  {TSIPP_patches classBrowser tcl html images examples
                     examples examples examples examples} \
            pattern {*             *            *   *    *      *.tcl
                     reactor  scratch  crank    hydraulic} {
        if {![file exists $subDir]} {
            file mkdir $subDir
        }
        foreach filename [glob [file join $devDir $subDir $pattern]] {
            file copy [file join $devDir $subDir $filename] $subDir
            exec chmod ugo-w [file join $relDir $subDir [file tail $filename]]
        }
    }
    
    #  The README file in the classBrowser directory causes problems with
    #  the installation procedure on the Contributed Sources Archive.
    file rename [file join classBrowser README]                      \
                [file join classBrowser DESCRIPTION]
    
    #  directories copied from /usr/local ...
    foreach subDir {lib bin} {
        file mkdir $subDir
    }
    
    #  lib directory construction ...
    foreach item {tclConfig.sh             \
                  libtcl8.3.so             \
                  libtclstub8.3.a          \
                  tcl8.3                   \
                  tkConfig.sh              \
                  libtk8.3.so              \
                  libtkstub8.3.a           \
                  tk8.3                    \
                  tclxConfig.sh            \
                  libtclx8.3.a             \
                  libtclx8.3.so            \
                  tclX8.3                  \
                  tkxConfig.sh             \
                  libtkx8.3.a              \
                  libtkx8.3.so             \
                  tkX8.3                   \
                  tsipp3.3b2               \
                  libitcl3.1.so            \
                  libitclstub3.1.a         \
                  itclConfig.sh            \
                  itcl3.1                  \
                  libitk3.1.so             \
                  itk3.1                   \
                  libitkstub3.1.a          \
                  itkConfig.sh             \
                  iwidgets                 \
                  efftcl1.0} {
        file copy [file join /home/pdw/PROJECTS/TSIPPwb/lib $item] lib
    }
    
    #  bin directory construction ...
    foreach item {tksipp libtksipp.a} {
        file copy [file join /home/pdw/PROJECTS/TSIPPwb/bin $item] bin
    }
    
    puts "Release directory \"$relDir\" complete"
    
    #  Exit rather than entering the event loop.
    exit 0

# ------------------------------------------------------------------------------
# End of TCL script
# ------------------------------------------------------------------------------
