Installation Instructions
=========================

This directory contains the FOV simulator and the image generator of the
observation in planetary explorations.

It is now possible to automatically configure and build both of
simulator and renderer with one command.  To build all contained herein,
run the ``configure'' script here, e.g.:

        ./configure --with-cspice=/path/to/cspice
        make

To install them (by default in /usr/local/bin),
then do:
        make install


Required Packages
=========================

Lua, libxml2, cspice are required. At least, one of libjpeg, libpng, or CFITSIO must be included to
perform rendering. Texture images must be prepared in the specified formats corresponding to the
configure options. Defaults for the options are specified in brackets.

Lua options
-----------

  --with-lua-prefix[=DIR]    Use Lua from given prefix.
  --with-lua-inc[=DIR]       You can also specify Lua's include dir. Default is $LUA_DIR/include
  --with-lua-lib[=DIR]       You can also specify Lua's library dir. Default is $LUA_DIR/lib
  --with-lua-suffix[=SUFFIX] Versioning suffix to use in Lua filenames. Default is "".

  Lua is required to compile this software. If configure cannot find lua-related files, compilation
  will be failed.


Spice options
-------------

  --with-cspice=DIR          Use cspice from given prefix.
  --with-cspice-inc=DIR      You can also specify cspice's include dir. Default is $CSPICE_DIR/include
  --with-cspice-lib=DIR      You can also specify cspice's library dir. Default is $CSPICE_DIR/lib

  Cspice is required to compile this software. If configure cannot find cspice-related files, compilation
  will be failed.


libxml2 options
---------------

  --with-libxml-prefix=DIR   Specify location of libxml config
  --with-libxml-inc=DIR      Specify location of libxml headers
  --with-libxml-lib=DIR      Specify location of libxml libraries

  libxml2 is required to compile this software. If configure cannot find libxml2-related files, compilation
  will be failed.


Optional Packages
=================

JPEG support
------------

  --without-libjpeg          Disable JPEG support
  --with-libjpeg[=DIR]       Include JPEG support (DIR is libjpeg's install dir).


  JPEG support is optional, but it will be included by default if configure
  finds libjpeg on your system.

  Use --without-libjpeg to explicitly disable JPEG support.

  Use the --with-libjpeg=DIR option to use a copy of libjpeg installed in
  directory "DIR".  Make sure that this copy of libjpeg is compiled before
  using this option.


PNG support
-----------

  --without-libpng           Disable PNG support
  --with-libpng[=DIR]        Include PNG support (DIR is libpng's install dir).


  PNG support is optional, but it will be included by default if configure
  finds libpng on your system.

  Use --without-libpng to explicitly disable PNG support.

  Use the --with-libpng=DIR option to use a copy of libpng installed in
  directory "DIR".  Make sure that this copy of libpng is compiled before
  using this option.


FITS support:
-------------

  Unlike the JPEG and PNG supports, FITS support enables to output a simple FITS
  output which includes World Coordinated System headers.

  --without-cfitsio          Disable FITS support
  --with-cfitsio[=DIR]       Include FITS support (DIR is cfitsio's install dir).


  FITS support is optional, but it will be included by default if configure
  finds cfitsio on your system.

  Use --without-cfitsio to explicitly disable FITS support.

  Use the --with-cfitsio=DIR option to use a copy of cfitsio installed in
  directory "DIR". Make sure that this copy of cfitsio is compiled before
  using this option.


OGC WMS Support
---------------

  --disable-wms              Disable OGC WMS Client support
  --enable-wms               Enable OGC WMS Client support (libcurl required)

  OGS WMS support is optional. This option enables users to download a planetary
  texture from a WMS server.
  It requires libcurl (see --with-curl-config option below).


Curl support
------------

  --with-curl-config=PATH    Specify path to curl-config.

  The Curl library (http://curl.haxx.se/libcurl/) is used by the WMS
  support option to connect to remote servers via HTTP.

  If libcurl is installed in the default system directories then it
  should automatically be detected by configure.  Otherwise use the
  --with-curl-config option to specify the path where the curl-config
  script is located.
  e.g.

     ./configure .... --with-curl-config=/usr/local/bin/curl-config


SPICE DSK support
-----------------

  --enable-spice-dsk          Enable SPICE DSK support

  SPICE DSK support is optional. This option enables SPICE DSK Type 2 format
  in addition to the STL format as a shape model. SPICE Toolkit Version N66 or
  later is required.

  The previous version alpha_dsk_c is also supported.
  Use --with-cspice=/path/to/alpha_dsk_c option to use a copy of the alpha test
  DSK Prototype Toolkit (ftp://naif.jpl.nasa.gov/pub/naif/misc/alpha_dsk/).


Build Examples
=========================

The compilation in several operating systems are listed for further information.
The followings are examples, and there is no warranty.

CentOS 6.3 (x86_64)
-------------------

[~]$ su
[~]# yum -y install gcc make libpng-devel libjpeg-devel libcurl-devel libxml2-devel lua-devel tcsh
[~]# exit
[~]$ mkdir tmp
[~]$ cd tmp
[~/tmp]$ curl -O ftp://heasarc.gsfc.nasa.gov/software/fitsio/c/cfitsio3370.tar.gz
[~/tmp]$ tar zxvf cfitsio3370.tar.gz
[~/tmp]$ cd cfitsio
[~/tmp/cfitsio]$ ./configure
[~/tmp/cfitsio]$ make
[~/tmp/cfitsio]$ cd ..
[~/tmp]$ curl -O ftp://naif.jpl.nasa.gov/pub/naif/toolkit/C/PC_Linux_GCC_64bit/packages/cspice.tar.Z
[~/tmp]$ tar zxvf cspice.tar.Z
[~/tmp]$ cd cspice
[~/tmp/cspice]$ csh makeall.csh
[~/tmp/cspice]$ cd ..
[~/tmp]$ curl -O https://darts.isas.jaxa.jp/planet/tools/flow/flow-1.5.tar.gz
[~/tmp]$ tar zxvf flow-1.5.tar.gz
[~/tmp]$ cd flow-1.5
[~/tmp/flow-1.5]$ ./configure \
--with-cfitsio=$HOME/tmp/cfitsio \
--with-cspice=$HOME/tmp/cspice \
--enable-wms
[~/tmp/flow-1.5]$ make


Ubuntu 12.04 (x86_64)
---------------------
[~]$ sudo apt-get install libpng-dev libjpeg-dev libcurl4-nss-dev libxml2-dev lua5.2 lua5.2-dev libcfitsio3-dev csh
[~]$ mkdir tmp
[~]$ cd tmp
[~/tmp]$ wget ftp://naif.jpl.nasa.gov/pub/naif/toolkit/C/PC_Linux_GCC_64bit/packages/cspice.tar.Z
[~/tmp]$ tar zxvf cspice.tar.Z
[~/tmp]$ cd cspice
[~/tmp/cspice]$ csh makeall.csh
[~/tmp/cspice]$ cd ..
[~/tmp]$ wget https://darts.isas.jaxa.jp/planet/tools/flow/flow-1.5.tar.gz
[~/tmp]$ tar zxvf flow-1.5.tar.gz
[~/tmp]$ cd flow-1.5
[~/tmp/flow-1.5]$ ./configure \
--with-lua-inc=/usr/include/lua5.2 \
--with-lua-suffix=5.2 \
--with-cspice=$HOME/tmp/cspice \
--enable-wms
[~/tmp/flow-1.5]$ make

OS X v10.9 Mavericks (x86_64) + fink-0.36.4
-------------------------------------------
Install Fink 0.36.4 (See http://www.finkproject.org/)

[~]$ sudo apt-get lua52 lua52-dev cfitsio libpng16 libjpeg
[~]$ mkdir tmp
[~/tmp]$ curl -O ftp://naif.jpl.nasa.gov/pub/naif/toolkit/C/MacIntel_OSX_AppleC_64bit/packages/cspice.tar.Z
[~/tmp]$ tar zxvf cspice.tar.Z
[~/tmp]$ cd cspice
[~/tmp/cspice]$ csh makeall.csh
[~/tmp/cspice]$ cd ..
[~/tmp]$ curl -O https://darts.isas.jaxa.jp/planet/tools/flow/flow-1.5.tar.gz
[~/tmp]$ tar zxvf flow-1.5.tar.gz
[~/tmp]$ cd flow-1.5
[~/tmp/flow-1.5]$ export PKG_CONFIG_PATH=/sw/lib/pkgconfig
[~/tmp/flow-1.5]$ ./configure \
--prefix=/sw \
--with-lua-inc=/sw/include \
--with-lua-lib=/sw/lib \
--with-libpng \
--with-libjpeg=/sw \
--with-cfitsio=/sw \
--with-cspice=$HOME/tmp/cspice \
--enable-wms
[~/tmp/flow-1.5]$ make
[~/tmp/flow-1.5]$ sudo make install


OS X v10.7 Lion (x86_64) + MacPorts 2.1.2
-----------------------------------------
Install Mac Ports 2.1.2 (See http://www.macports.org)

[~]$ export PATH=/opt/local/bin:$PATH
[~]$ sudo port install pkgconfig libpng jpeg cfitsio
[~]$ mkdir tmp
[~]$ cd tmp
[~/tmp]$ curl -O http://www.lua.org/ftp/lua-5.2.1.tar.gz
[~/tmp]$ tar zxvf lua-5.2.1.tar.gz
[~/tmp]$ cd lua-5.2.1
[~/tmp/lua-5.2.1]$ make macosx
[~/tmp/lua-5.2.1]$ sudo make install INSTALL_TOP=/opt/local
[~/tmp/lua-5.2.1]$ cd ..
[~/tmp]$ curl -O ftp://naif.jpl.nasa.gov/pub/naif/toolkit/C/MacIntel_OSX_AppleC_64bit/packages/cspice.tar.Z
[~/tmp]$ tar zxvf cspice.tar.Z
[~/tmp]$ cd cspice
[~/tmp/cspice]$ csh makeall.csh
[~/tmp/cspice]$ cd ..
[~/tmp]$ curl -O https://darts.isas.jaxa.jp/planet/tools/flow/flow-1.5.tar.gz
[~/tmp]$ tar zxvf flow-1.5.tar.gz
[~/tmp]$ cd flow-1.5
[~/tmp/flow-1.5]$ ./configure \
--with-lua-prefix=/opt/local \
--with-libjpeg=/opt/local \
--with-cfitsio=/opt/local \
--with-cspice=$HOME/tmp/cspice \
--enable-wms
[~/tmp/flow-1.5]$ make


Mac OS X v10.6 Snow Leopard (i386) + Homebrew 0.9.4
--------------------------------------------------

[~]$ brew install lua cfitsio libpng pkg-config jpeg
[~/tmp]$ curl -O ftp://naif.jpl.nasa.gov/pub/naif/toolkit/C/MacIntel_OSX_AppleC_32bit/packages/cspice.tar.Z
[~/tmp]$ tar zxvf cspice.tar.Z
[~/tmp]$ cd cspice
[~/tmp/cspice]$ csh makeall.csh
[~/tmp/cspice]$ cd ..
[~/tmp]$ curl -O https://darts.isas.jaxa.jp/planet/tools/flow/flow-1.5.tar.gz
[~/tmp]$ tar zxvf flow-1.5.tar.gz
[~/tmp]$ cd flow-1.5
[~/tmp/flow-1.5]$ export PKG_CONFIG_PATH=/usr/local/Cellar/libpng/1.5.14/lib/pkgconfig
[~/tmp/flow-1.5]$ CFLAGS="-I/usr/local/Cellar/jpeg/8d/include" ./configure \
--with-libpng \
--with-libjpeg=/usr/local/Cellar/jpeg/8d \
--with-cfitsio \
--with-cspice=$HOME/tmp/cspice \
--enable-wms
[~/tmp/flow-1.5]$ make
[~/tmp/flow-1.5]$ sudo make install

The "flow_ig" command may occur the following error:
dyld: Library not loaded: /usr/local/opt/jpeg/lib/libjpeg.8.dylib

Then, try the following command to set the environment vairable DYLD_LIBRARY_PATH:
[~]$ export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:/usr/local/Cellar/jpeg/8d/lib


Mac OS X v10.5 Leopard (i386) + MacPorts 2.1.2
----------------------------------------------
Install Mac Ports 2.1.2 (See http://www.macports.org)

[~]$ export PATH=/opt/local/bin:$PATH
[~]$ sudo port install pkgconfig libpng jpeg cfitsio libxml2
[~/tmp]$ curl -O http://www.lua.org/ftp/lua-5.2.1.tar.gz
[~/tmp]$ tar zxvf lua-5.2.1.tar.gz
[~/tmp]$ cd lua-5.2.1
[~/tmp/lua-5.2.1]$ make macosx
[~/tmp/lua-5.2.1]$ sudo make install INSTALL_TOP=/opt/local
[~/tmp/lua-5.2.1]$ cd ..
[~/tmp]$ curl -O ftp://naif.jpl.nasa.gov/pub/naif/toolkit/C/MacIntel_OSX_AppleC_32bit/packages/cspice.tar.Z
[~/tmp]$ tar zxvf cspice.tar.Z
[~/tmp]$ cd cspice
[~/tmp/cspice]$ csh makeall.csh
[~/tmp/cspice]$ cd ..
[~/tmp]$ curl -O https://darts.isas.jaxa.jp/planet/tools/flow/flow-1.5.tar.gz
[~/tmp]$ tar zxvf flow-1.5.tar.gz
[~/tmp]$ cd flow-1.5
[~/tmp/flow-1.5]$ LDFLAGS="-L/opt/local/lib" ./configure \
--with-lua-prefix=/opt/local \
--with-libjpeg=/opt/local \
--with-cfitsio=/opt/local \
--with-cspice=$HOME/tmp/cspice \
--enable-wms
[~/tmp/flow-1.5]$ make

The default libxml2 in Mac OS X v10.5 Leopard does not contain a "xmlFirstElementChild" function which is used in wms_parser.c.
Installing libxml2 via MacPorts, and specifying LDFLAGS="-L/opt/local/lib" at compiling FLOW resolve this problem.


OpenSUSE 12.1 (x86_64)
----------------------
[~]$ su
[~]# zipper install libjpeg62-devel libcurl-devel lua-devel libcfitsio-devel libxml2-devel
[~]# exit
[~]$ mkdir tmp
[~]$ cd tmp
[~/tmp]$ wget ftp://naif.jpl.nasa.gov/pub/naif/toolkit/C/PC_Linux_GCC_64bit/packages/cspice.tar.Z
[~/tmp]$ tar zxvf cspice.tar.Z
[~/tmp]$ cd cspice
[~/tmp/cspice]$ csh makeall.csh
[~/tmp/cspice]$ cd ..
[~/tmp]$ tar zxvf flow-1.5.tar.gz
[~/tmp]$ wget https://darts.isas.jaxa.jp/planet/tools/flow/flow-1.5.tar.gz
[~/tmp]$ cd flow-1.5
[~/tmp/flow-1.5]$ ./configure \
--with-cfitsio-inc=/usr/include/libcfitsio0 \
--with-cspice=$HOME/tmp/cspice \
--enable-wms
[~/tmp/flow-1.5]$ make


FreeBSD 9.0 (amd64)
-------------------
[~]$ su -
[~]# sysinstall

install following packages:

astro
  cfitsio-3.250
ftp
  curl-7.21.3_2
graphics
  jpeg-8_3
  png-1.4.8
lang
  lua-5.1.4_6
textproc
  libxml2-2.7.8_1

[~]# exit
[~]$ mkdir tmp
[~/tmp]$ wget ftp://naif.jpl.nasa.gov/pub/naif/toolkit/C/PC_Linux_GCC_64bit/packages/cspice.tar.Z
[~/tmp]$ tar zxvf cspice.tar.Z
[~/tmp]$ cd cspice
[~/tmp/cspice]$ csh makeall.csh
[~/tmp/cspice]$ cd ..
[~/tmp]$ setenv LDFLAGS "-L/usr/local/lib -L/usr/lib -L/lib"
[~/tmp]$ wget https://darts.isas.jaxa.jp/planet/tools/flow/flow-1.5.tar.gz
[~/tmp]$ tar zxvf flow-1.5.tar.gz
[~/tmp]$ cd flow-1.5
[~/tmp/flow-1.5]$ ./configure \
--with-libjpeg=/usr/local \
--with-lua-prefix=/usr/local
--with-lua-inc=/usr/local/include/lua51 \
--with-lua-suffix=-5.1 \
--with-cspice=$HOME/tmp/cspice \
--enable-wms
[~/tmp/flow-1.5]$ make

Solaris 11 (i386)
-----------------
[~]$ su -
[~]# pkg install developer/gcc-45
[~]# pkg install system/header
[~]# pkg install developer/build/make
[~]# pkg install developer/gnome/gettext
[~]# pkg install runtime/lua
[~]# pkg install image/library/libpng
[~]# pkg install image/library/libjpeg
[~]# pkg install library/libxml2
[~]# exit
[~]$ mkdir tmp
[~]$ cd tmp
[~/tmp]$ wget ftp://heasarc.gsfc.nasa.gov/software/fitsio/c/cfitsio3370.tar.gz
[~/tmp]$ tar zxvf cfitsio3370.tar.gz
[~/tmp]$ cd cfitsio
[~/tmp/cfitsio]$ ./configure
[~/tmp/cfitsio]$ make
[~/tmp/cfitsio]$ cd ..
[~/tmp]$ wget ftp://naif.jpl.nasa.gov/pub/naif/toolkit/C/SunIntel_Solaris_SunC_32bit/packages/cspice.tar.Z
[~/tmp]$ tar zxvf cspice.tar.Z
[~/tmp]$ cd cspice
[~/tmp/cspice]$ TKCOMPILER=gcc TKCOMPILEOPTIONS="-c -fPIC -O2" csh makeall.csh
[~/tmp/cspice]$ cd ..
[~/tmp]$ wget https://darts.isas.jaxa.jp/planet/tools/flow/flow-1.5.tar.gz
[~/tmp]$ tar zxvf flow-1.5.tar.gz
[~/tmp]$ cd flow-1.5
[~/tmp/flow-1.5]$ ./configure --with-cfitsio=$HOME/tmp/cfitsio --with-cspice=$HOME/tmp/cspice
[~/tmp/flow-1.5]$ make

cygwin (i386)
-------------

Install following packages from setup.exe:

Devel:
  gcc4-core      (4.5.3-3)
  make           (3.82.90-1)
  pkg-config     (0.23b-10)
  libxml2-devel  (2.8.0-1)
  libpng15-devel (1.5.12-1)
  libjpeg-devel  (8b-1)

Web:
  curl           (7.27.0-1)
  libcurl-devel  (7.27.0-1)

Shells:
  tcsh           (6.18.01-1)


[~]$ mkdir tmp
[~]$ cd tmp
[~/tmp]$ curl -O http://www.lua.org/ftp/lua-5.2.1.tar.gz
[~/tmp]$ tar zxvf lua-5.2.1.tar.gz
[~/tmp]$ cd lua-5.2.1
[~/tmp/lua-5.2.1]$ make posix
[~/tmp/lua-5.2.1]$ make install
[~/tmp/lua-5.2.1]$ cd ..
[~/]$ cd tmp
[~/tmp]$ curl -O ftp://heasarc.gsfc.nasa.gov/software/fitsio/c/cfitsio3370.tar.gz
[~/tmp]$ tar zxvf cfitsio3370.tar.gz
[~/tmp]$ cd cfitsio
[~/tmp/cfitsio]$ ./configure
[~/tmp/cfitsio]$ make
[~/tmp/cfitsio]$ cd ..
[~/tmp]$ curl -O ftp://naif.jpl.nasa.gov/pub/naif/toolkit/C/PC_Cygwin_GCC_32bit/packages/cspice.tar.Z
[~/tmp]$ tar zxvf cspice.tar.Z
[~/tmp]$ cd cspice
[~/tmp/cspice]$ csh make.csh
[~/tmp/cspice]$ cd ..
[~/tmp]$ curl -O https://darts.isas.jaxa.jp/planet/tools/flow/flow-1.5.tar.gz
[~/tmp]$ tar zxvf flow-1.5.tar.gz
[~/tmp]$ cd flow-1.5
[~/tmp]$ ./configure \
--with-lua-prefix=/usr/local \
--with-cfitsio=$HOME/tmp/cfitsio \
--with-cspice=$HOME/tmp/cspice \
--enable-wms
[~/tmp]$ make


CentOS 6.5 (x86_64) with alpha-dsk
----------------------------------

[~]$ su
[~]# yum -y install gcc make libpng-devel libjpeg-devel libcurl-devel libxml2-devel lua-devel tcsh
[~]# exit
[~]$ mkdir tmp
[~]$ cd tmp
[~/tmp]$ curl -O ftp://heasarc.gsfc.nasa.gov/software/fitsio/c/cfitsio3370.tar.gz
[~/tmp]$ tar zxvf cfitsio3370.tar.gz
[~/tmp]$ cd cfitsio
[~/tmp/cfitsio]$ ./configure
[~/tmp/cfitsio]$ make
[~/tmp/cfitsio]$ cd ..
[~/tmp]$ curl -O http://naif.jpl.nasa.gov/pub/naif/misc/alpha_dsk/C/PC_Linux_GCC_64bit/packages/alpha_dsk_c.tar.Z
[~/tmp]$ tar zxvf alpha_dsk_c.tar.Z
[~/tmp]$ cd alpha_dsk_c
[~/tmp/alpha_dsk_c]$ csh makeall.csh
[~/tmp/alpha_dsk_c]$ cd ..
[~/tmp]$ curl -O https://darts.isas.jaxa.jp/planet/tools/flow/flow-1.5.tar.gz
[~/tmp]$ tar zxvf flow-1.5.tar.gz
[~/tmp]$ cd flow-1.5
[~/tmp/flow-1.5]$ ./configure \
--with-cfitsio=$HOME/tmp/cfitsio \
--with-cspice=$HOME/tmp/alpha_dsk_c \
--enable-wms --enable-spice-dsk
[~/tmp/flow-1.5]$ make
