Ra with Autoref

    Robotics Erlangen e.V.
    http://www.robotics-erlangen.de/
    info@robotics-erlangen.de


All programs should compile on GNU/Linux (tested on Ubuntu 14.04), Mac OS X 10.9 and Windows >= 7.

In order to build Ra you will need:
 * cmake >= 2.8.9
 * g++ >= 4.6
 * qt >= 5.1.0
 * protobuf >= 2.0.0
 * luajit >= 2.0

Certain features require additional libraries:
 * libusb-1.0          USB communication (version >= 1.0.9)
 * libsdl2             Joystick support (version >= 2.0.2)
 * libudev             Required for joystick support (only required if libsdl2 is not available via the package manager)
 * liblua5.1-socket2   Lua remote debugger (see strategy/test/debug/enable.lua) (version >= 2.1!, https://github.com/diegonehab/luasocket)

Package names for Ubuntu 14.04:
cmake
protobuf-compiler
qtbase5-dev
libudev-dev
libsdl2-dev
libluajit-5.1-dev
libusb-1.0-0-dev
gcc-arm-none-eabi
(and you need g++, since it's not included in the default instalation)

*** Unix ***
The recommended way of building a project with CMake is by doing an
out-of-source build. This can be done like this:

> mkdir build
> cd build
> cmake ..
> make

Ra and the Logplayer can be started from the build/bin/ directory.
To install the desktop files use this command:
> make install-menu

In order to select which Qt-Installation to use specify it using a similar command line:
> cmake -DCMAKE_PREFIX_PATH=~/Qt/5.2.1/gcc_64/lib/cmake ..

To be able to use USB devices (sender, robots) the rights for udev have to be modified.
Just copy the file at data/udev/99-robotics-usb-devices.rules to /etc/udev/rules.d/99-robotics-usb-devices.rules

To use the remote debugger download, compile and install the luasocket library (version >= 2.1!). The libraries must be installed to /usr/local/lib to be recognised by LuaJIT
Compile instructions: (for Ubuntu 12.04)
> make LUAINC_linux=/usr/include/lua5.1
> sudo make install

*** Windows ***
Get dependencies (tested using the given versions):
cmake 2.8.12.2 - http://www.cmake.org/files/v2.8/cmake-2.8.12.2-win32-x86.exe
mingw-get - http://sourceforge.net/projects/mingw/files/Installer/mingw-get-setup.exe

Qt 5.2.1 OpenGL - http://download.qt-project.org/official_releases/qt/5.2/5.2.1/qt-opensource-windows-x86-mingw48_opengl-5.2.1.exe
protobuf 2.5.0 - https://protobuf.googlecode.com/files/protobuf-2.5.0.tar.bz2
luajit 2.0.3 - http://luajit.org/download/LuaJIT-2.0.3.tar.gz
libusbx 1.18 - http://downloads.sourceforge.net/libusb/libusb-1.0.18.tar.bz2
luasocket 3.0-rc? - https://github.com/diegonehab/luasocket/archive/master.zip
libsdl2 2.0.2 - http://libsdl.org/release/SDL2-devel-2.0.2-mingw.tar.gz

install cmake:
	use the installer, select add to PATH

install mingw-get:
	Run installer (use default path C:\MinGW !)
	Install with package manager:
		ming32-base, g++, msys-base, mingw32-gdb-python, msys-patch (vorher mingw32-gdb entfernen!)
	Run: (g++-4.8.1 crashes while compiling bullet)
		> mingw-get remove gcc g++ mpc
		> mingw-get install "gcc<4.8" "g++<4.8" "mpc<1"
	Run C:\mingw\msys\1.0\postinstall\pi.sh set mingw path to c:/mingw
use msys.bat in msys\1.0 to open msys console

!!! USE MSYS TO COMPILE EVERYTHING !!!

compile protobuf:
	> mkdir build && cd build
    > ../configure --prefix=/mingw && make && make install

compile luajit:
	> make && make install PREFIX=/mingw && cp src/lua51.dll /mingw/bin

compile libusb:
	> mkdir build && cd build
	> ../configure --prefix=/mingw && make && make install

install libsdl2(prebuilt mingw package!):
	> make native

compile luasocket2:
	> make PLAT=mingw LUAINC_mingw=/mingw/include/luajit-2.0 LUALIB_mingw=/mingw/bin/lua51.dll
	> make install PLAT=mingw INSTALL_TOP_LDIR=../build/share INSTALL_TOP_CDIR=../build/lib
	
install qt:
run installer (use default install path! ), unselect "Tools/MinGW 4.8"!

compile ra:
	> mkdir build-win && cd build-win
	> cmake -G "MSYS Makefiles" -DCMAKE_PREFIX_PATH=/c/Qt/Qt5.2.1/5.2.1/mingw48_32/lib/cmake -DCMAKE_BUILD_TYPE=Release ..
	
		either set using commandline cmake -DPARAM=VALUE ... or cmake-gui
		set LUA_INCLUDE_DIR to C:/MinGW/include/luajit-2.0
		set LUA_LIBRARIES to C:/mingw/bin/lua51.dll
		set PROTOBUF_INCLUDE_DIR to C:/MinGW/include
		set PROTOBUF_LIBRARY to C:/MinGW/lib/libprotobuf.dll.a
		set SDL2_INCLUDE_DIR to C:/MinGW/msys/1.0/include/SDL2
		set USB_INCLUDE_DIR to C:/MinGW/include/libusb-1.0

	> make
	
		copy config + data directory to "builddir"/bin
		copy libprotobuf-8.dll, libusb-1.0.dll, lua51.dll, mingwm10.dll from C:/MinGW/bin to "builddir"/bin
		copy SDL2.dll from C:/MinGW/msys/1.0/bin
		copy icudt51.dll, icuin51.dll, icuuc51.dll, libgcc_s_dw2-1.dll, libstdc++-6.dll, libwinpthread-1.dll,
			Qt5Core.dll, Qt5Gui.dll, Qt5Network.dll, Qt5OpenGL.dll, Qt5Widgets.dll from C:/Qt/Qt5.2.1/5.2.1/mingw48_32/bin to "builddir"/bin
		copy qwindows.dll from C:/Qt/Qt5.2.1/5.2.1/mingw48_32/plugins/platforms to "builddir"/bin/platforms
		copy the contents of luasocket2/build/lib to "builddir"/bin
Finished!


*** Mac OS X ***
Get dependencies using Homebrew (http://brew.sh):
brew install git sdl2 luajit protobuf libusb
Download Qt 5 from qt-project.org and install
Build using:
> mkdir build-mac && cd build-mac
> cmake -DCMAKE_PREFIX_PATH=~/Qt/5.3/clang_64/lib/cmake -DCMAKE_BUILD_TYPE=Release ..
> make

(If starting ra.app the normal way doesn't work launch it from Qt Creator)
