##
Unix build

McStas uses autoconf to detect the system configuration and creates the proper Makefiles needed for compilation. On Unix-like systems, you should be able to compile and install McStas using the following steps:

1. Unpack the sources to somewhere convenient and change to the source directory:
   gunzip -c mcstas-1.9-src.tar.gz | tar xf -
   cd mcstas-1.9/
2. Configure and compile McStas:
   ./configure
   make
3. Install McStas (as superuser):
   make install

The installation of McStas in step 3 by default installs in the /usr/local/ directory, which on most systems requires superuser (root) privileges. To install in another directory, use the -prefix= option to configure in step 2. For example,

./configure -prefix=/home/joe

will install the McStas programs in /home/joe/bin/ and the library files needed by McStas in /home/joe/lib/mcstas/.

In case ./configure makes an incorrect guess, some environment variables can be set to override the defaults:

- The CC environment variable may be set to the name of the C compiler to use (this must be an ANSI C compiler). This will also be used for the automatic compilation of McStas simulations in mcgui and mcrun.
- CFLAGS may be set to any options needed by the compiler (eg. for optimization or ANSI C conformance). Also used by mcgui/mcrun.
- PERL may be set to the path of the Perl interpreter to use.

To use these options, set the variables before running ./configure. Eg.

setenv PERL /pub/bin/perl5

./configure

It may be necessary to remove configure's cache of old choices first:

rm -f config.cache

If you experience any problems, or have some questions or ideas concerning McStas, please contact peter.willendup@risoe.dk or the McStas mailing list at neutron-mc@risoe.dk.

You should try to make sure that the directory containing the McStas binaries (mcstas, gscan, mcdisplay, etc.) is contained in the PATH environment variable. The default directory is /usr/local/bin, which is usually, but not always, included in PATH. Alternatively, you can reference the McStas programs using the full path name, ie.

`/usr/local/bin/mcstas my.instr`

`perl /usr/local/bin/mcrun -N10 -n1e5 mysim -f output ARG=42`

`perl /usr/local/bin/mcdisplay --multi mysim ARG=42`

This may also be necessary for the front-end programs if the install procedure could not determine the location of the perl interpreter on your system.

If McStas is installed properly, it should be able to find the files it needs automatically. If not, you should set the MCSTAS environment variable to the directory containing the runtime files "mcstas-r.c" and "mcstas-r.h" and the standard components (*.comp). Use one of

`MCSTAS=/usr/local/lib/mcstas; export MCSTAS # sh, bash`

`setenv MCSTAS /usr/local/lib/mcstas # csh, tcsh`