PREV UP NEXT

# DOWNLOAD XSCHEM

You should download the xschem sources from one of these repositories:

- From repo.hu with subversion:

      svn checkout svn://repo.hu/xschem/trunk xschem-src

- From sourceforge.net with subversion:

      svn checkout https://svn.code.sf.net/p/xschem/code/ xschem-src

- From github.com with git:

      git clone https://github.com/StefanSchippers/xschem.git xschem-src

## Attention

If you have a binary xschem package installed on the system you should remove it. Packaged xschem versions are too old and they conflict with the one you are building from source. To remove: (this command is for Debian/Ubuntu, use similar commands for other distributions)
`sudo apt-get purge xschem`

# INSTALL XSCHEM

in order to install the program run the following command:

      user:~$ cd xschem-src; ./configure

This will make all the necessary checks for required libraries and system tools.

for Debian and Ubuntu systems these are the packages you should check to be installed. Tck/Tk versions may vary on different systems, 8.4, 8.5, 8.6 versions are all good.

      LIBRARIES                              DEVELOPMENT FILES
    -----------------------------------------------------------
      libx11-6                               libx11-dev
      libxrender1                            libxrender-dev
      libxcb1                                libx11-xcb-dev
      libcairo2                              libcairo2-dev
      tcl8.6                                 tcl8.6-dev
      tk8.6                                  tk8.6-dev
      flex                                   bison
      libxpm4                                libxpm-dev
      libjpeg62-turbo or libjpeg             libjpeg-dev

    # terminal program and editor used by default by xschem:
    # alternative programs can be specified in xschemrc by
    # setting tcl variables 'terminal' and 'editor', respectively.
      xterm vim-gtk3
    # tools that should be available on all systems by default:
      gawk or mawk
    # Suggested (not mandatory for using xschem) packages:
      tcl-tclreadline

If configure ends with no errors we are ready to compile:

      user:~$ make

If we want to install xschem and its required files (execute as root if you plan to do a system-wide installation, for example in /usr/local):

      user:~$ sudo make install

This will install all the runtime needed files into the locations previously configured (can be found in Makefile.conf). To change the default installation prefix (/usr/local), please replace the configure step shown above with:

       ./configure --prefix=new/prefix/path

For testing purposes `xschem` can be run and invoked from the build directory `xschem-<version>/src/` without installation.

      user:~$ cd xschem-2.7.0/src && ./xschem

When xschem is running, type `puts $XSCHEM_LIBRARY_PATH` in the xschem tcl prompt to know the library search path.
Type `puts $XSCHEM_SHAREDIR` to see the installation path.

Sample user design libraries are provided and installed systemwide under `${XSCHEM_SHAREDIR/xschem_library/`. The XSCHEM_START_WINDOW specifies a schematic to preload at startup, to avoid absolute paths use a path that is relative to one of the `XSCHEM_LIBRARY_PATH` directories. XSCHEM will figure out the actual location. You may comment the definition if you don't want any schematic on startup.
If you need to override system settings, create a `~/.xschem/xschemrc`. The easiest way is to copy the system installed version from ${prefix}/share/xschem/xschemrc and then make the necessary changes.

      user:$ mkdir ~/.xschem
      user:$ cp <install root>/share/xschem/xschemrc ~/.xschem/xschemrc

When xschem is run the first time it will do the above operations, create a `${HOME}/.xschem/` directory and place a `xschemrc` into it.

## - Build xschem with a custom tcl-tk installation

If you need to build xschem against a tcl-tk installation located in a non-standard place you must provide additional options to the .configure script.
Suppose there is a tcl-tk version 8.4 installation in `/home/schippes/x/tcltk` then the following commands must be given before runninkg make and make install:

    export LD_LIBRARY_PATH=/home/schippes/x/tcltk/lib

    ./configure \
    --prefix=/home/schippes \
    /arg/tcl-version=8.4 \
    /arg/tk-version=8.4 \
    --prefix/libs/script/tcl=/home/schippes/x/tcltk \
    --prefix/libs/script/tk=/home/schippes/x/tcltk \
    --debug

This is the command I run to build and test xschem with tcl-tk 8.4 which was released 20 years ago.

## -Technical information - Detailed XSCHEM startup sequence

Information here under is not meant to be executed by the user

1. Source system-wide xschemrc if existing: `XSCHEM_SHAREDIR/xschemrc`. This file is by default all commented so it does nothing. See below how `XSCHEM_SHAREDIR` path is generated.
2. If `--rcfile=<rcfile>` is given then source the specified rcfile. Do not load any other rcfile.
3. If `../src/xchem.tcl` with respect to current dir is existing and `../xschem_library` is also existing then we are starting from a build directory, set `XSCHEM_SHAREDIR` to `<current dir>` and also set `XSCHEM_LIBRARY_PATH` to `../xschem_library/devices`.
4. Else use compile-time (generated from configure script) provided `XSCHEM_SHAREDIR`. (default is `/usr/local/share/xschem`).
5. If in current dir there is a `xschemrc` file source it.
6. Else if there is a `USER_CONF_DIR/xschemrc` file source it. `XSCHEM_SHAREDIR` and `USER_CONF_DIR` are preprocessor macros passed at compile time by the configure script. The first one will be overridden only if executing from a build directory, see item 3.
7. If `XSCHEM_SHAREDIR` not defined --> error and quit.
8. Start loading user provided schematic file or start with empty window (or filename specified in `XSCHEM_START_WINDOW` tcl variable).