@chapter Getting and installing Searduino

To use Searduino you need some software installed (see Required
software). To developer searduino you need some additional tools in order to
create the makefiles, configure scripts etc. The latter will not be
discussed in this manual. Instead, we will focus on how to use, and
build Searduino.

You have a couple of options to build and install the software. The
options we provide, until software packages for your distributions
are available, are:

@itemize @bullet
@item Install a prebuilt binary version
@item Build and install from a released version
@item Build and install from the source code repository
@end itemize

@i{Note: The first option is easiest. Only downside is that you have
to live with our fixed installation path (/opt/searduino)}
@*
@*
For some OS/distributions we have prepared scripts for setup and build
our software. To see if your distribution is supported clone the git
repository and look for files in the bin folder coresponding to your
dist. If you, as an example, are using Debian you can setup your
development environment and build the software this way:

@itemize @bullet
@item @code{bin/setup-debian.sh}
@item @code{bin/build-debian.sh}
@end itemize
@*
@i{Note: Check the content in the scripts above to see if the settings
fits your environment}
@*
@*
@*
@section Required software
@*
@subsection Debian based GNU/Linux distributions:
@itemize @bullet
@item gcc-avr
@item g++
@item binutils-avr
@item avrdude
@item avrprog
@item avr-libc
@item openjdk-6-jdk  (or openjdk-7-jdk)
@end itemize

@subsection Windows:
@itemize @bullet
@item Arduino (we need the avrdue program in there)
@item Win-AVR
@item cygwin (gcc-core, gcc-g++, make)
@end itemize

@subsection Mac:
@itemize @bullet
@item Xcode
@item MacPorts - http://www.macports.org/install.php
@item and via MacPorts install avrdude, avr-libc, gcc-avr, gcc, make
@item Java JDK
@end itemize

@section Binary releases

@subsection GNU/Linux
@*
@b{Create a installation directiory (e.g /opt/searduino)}
@*
@code{mkdir -p /opt/}
@*
@*
@b{Go to the installation directory}
@*
@code{cd /opt/}
@*
@*
@b{Download a release from}
@*
@url{http://download.savannah.gnu.org/releases/searduino/bin/}
@*
E.g http://download.savannah.gnu.org/releases/searduino/bin/searduino-bin-0.4-x86.tar.gz
@*
@*
@b{Unpack}
@*
@code{tar zxvf searduino-bin-0.4-x86.tar.gz}
@*
@*


@section Released version of the source code 
@*
Download from 
@*
@url{http://download.savannah.gnu.org/releases/searduino/}

@subsection Installing a released version
You must first configure the makefile etc by typing:
@*
@code{./configure}
@*
@*
The configure script accepts several option. Type @code{./configure
--help} to see them.

@i{Note: The configure script cannot find the jni.h file needed when
building java extension and the Jearduino simulator frontend. To help
the configure script you need use both the CFLAGS and CXXFLAGS to
point out the directory of the jni.h file.}


@*
@*
and then continue with building 
@*
@*
@code{make}
@*
@*
and then continue with installating
@*
@*
@code{make install}

@i{Note: You can configure Searduino in several ways (e.g with or
without Python). See Configuring Searduino for more information}

@section Getting the latest source code

We try to keep the latest version in the repository working but
there's no guarantee. If you want to play safe use the released
versions (see above). 

@subsection Getting a tgz/tar.gz file from the git repository
@*
Download from 
@*
@url{http://git.savannah.gnu.org/gitweb/?p=searduino.git;a=snapshot;h=HEAD;sf=tgz}
@*
@*
Info on how to install below

@subsection Cloning git repository
@*
Download from 
@*
@code{git clone git://git.savannah.nongnu.org/searduino.git}
@*
@*


@subsection Building the latest version
First, create tke configure script to set up the Makefiles
@*
@code{make -f Makefile.git}
@*
@*
After this, you should follow the procedures for Installing a released
version (see above).


@section Verify installation

@subsection With Arduino examples

To verify the Searduino installation we have developed a script. To use it, type:
@*
@*
@code{cd /opt/searduino}
@*
@*
@code{./scripts/verify-install.sh}
@*
@*
You can upload all built program to the uno boards by adding the option @code{--upload}
@*
@*
@code{scripts/verify-install.sh --upload}
@*
@*
@i{Note: this only uploads to the Uno boards}
@*
@*
@b{Experimental feature!!}
You can also execute each shared library in the stream simulator, by
using the option @code{--simulate}
@*
@*
@code{scripts/verify-install.sh --simulate}
@*
@*
@i{Note: Since the Arduino code will execute for ever, you must stop
the simulator each time it is loaded with a shread library. You stop
the simulator by pressing pressing Ctrl-c}
@*
@*

@subsection With the digpins example

Copy the digpins example directory.
@*
@*
@code{cp -r /opt/searduino/share/searduino/example/digpins /tmp}
@*
@*
Enter the digpins example directory.
@*
@*
@code{cd /tmp/digpins}
@*
@*
Make sure that the SEARDUINO_PATH in the Makefile points to your
Searduino installation dir. 
@*
@*
@*
@b{Build blinker program for PC}
@*
@*
@code{make prog}
@*
@*
@b{Execute blinker}
@*
@*
@code{./blinker}
@*
@*
The blinker program should run and print out (the printouts comes from
the stub libraries). Interrupt the program by sending a signal, e g by
pressing Ctrl-C.
@*
@*
@b{Build blinker lib for use in simulator}
@*
@*
@code{make shlib}
@*
@*
There should be a shared library file called @code{libdigpins.so} in the
current directory. You can load this shared library (think of it as a
plugin) in any of the simulators. We will load it in the stream
simulator.
@*
@*
@code{/opt/searduino/bin/searduino-stream-sim  --arduino-code ./libdigpins.so }
@*
@*
You should now see printouts from the Searduino simulator. You can
stop the program by pressing Ctrl-C ('Control key' and 'c key' at the
same time). 
@*
@*
To load the library in the graphical simulator, type:
@*
@*
@code{/opt/searduino/bin/searduino-jearduino.sh  --arduino-code ./libdigpins.so }
@*
@*
To load the entire project in the graphical simulator, type:
@*
@*
@code{/opt/searduino/bin/searduino-jearduino.sh  --searduino-project ../digpins}

@section Configuring Searduino

@subsection Java support
By default Searduino builds a Java extension. To disable this support, configure with the option
@code{--disable-java-extension}:
@*
@code{./configure --disable-java-extension}:
@*
@*

@subsection Graphical Simulator support
By default Searduino builds a graphical simulator. To disable this support, configure with the option
@code{--disable-jeardunio}:
@*
@code{./configure --disable-jearduino}:
@*
@*

@subsection Python support
Searduino has an unmaintained Python extension and a
Simulator GUI. These are diabled by default. To enable this support, configure with the option
@code{--enable-python-extension}:
@code{--enable-pearduino}:
@*
@code{./configure --enable-python-extension --enable-pearduino}:
@*
@*


@subsection Enable unit tests with check
Configure with the option @code{--enable-unittest}
@*
@code{./configure --enable-unittest}:
@*
@i{Note: The unit test software package check must be installed.}

