1#!/bin/sh
2#
3# This script starts xcircuit under the Tcl interpreter,
4# reading commands from a special .wishrc script which
5# launches xcircuit and retains the Tcl interactive interpreter.
6#
7
8loclibdir=${XCIRCUIT_LIB_DIR:=XCLIBDIR}
9export XCIRCUIT_LIB_DIR
10XCIRCUIT_WISH=WISH_EXE
11export XCIRCUIT_WISH
12
13# Hacks for Cygwin
14if [ ${TERM:=""} = "cygwin" ]; then
15   export PATH=$PATH:TCLLIBDIR
16   export DISPLAY=${DISPLAY:=":0"}
17fi
18
19TKCON=true
20DNULL=
21for i in $@ ; do
22   case $i in
23      -noc*)
24	   TKCON=;;
25      -now*)
26	   DNULL=true
27	   TKCON=;;
28      --help)
29	   echo "Standard usage:"
30	   echo "   xcircuit [filename]"
31	   echo "Online documentation:"
32	   echo "   http://opencircuitdesign.com/xcircuit"
33	   exit 0
34	   ;;
35      --version)
36	   echo "XCircuit version PROG_VERSION revision PROG_REVISION"
37	   exit 0
38	   ;;
39   esac
40done
41
42if [ $TKCON ]; then
43
44   if [ ! -f ${loclibdir}/CONSOLE ]; then
45      loclibdir=${loclibdir}/tcl
46   fi
47
48   exec ${loclibdir}/CONSOLE \
49	-eval "source ${loclibdir}/CONSOLE_SCRIPT" \
50        -slave "package require Tk; set argc $#; set argv [list $*]; \
51        source ${loclibdir}/WRAPPER_INIT"
52else
53
54#
55# Run the stand-in for wish (xcircexec), which acts exactly like "wish"
56# except that it replaces ~/.wishrc with xcircuit.tcl.  This executable is
57# *only* needed when running without the console; the console itself is
58# capable of sourcing the startup script.
59#
60   if [ $DNULL ]; then
61      exec ${loclibdir}/xcircdnull -- $@
62   else
63      exec ${loclibdir}/xcircexec -- $@
64   fi
65fi
66