--------------------------------------------------------------------
            Building and installing Ipe on Unix
--------------------------------------------------------------------


****  For MAC OS X, see the separate document "macos.txt"! ****


Quickstart for Linux
--------------------

If you have a recent Mint, Ubuntu, or Debian system, the following
steps will install the necessary libraries and tools:

    sudo apt-get install checkinstall zlib1g-dev qtbase5-dev qtbase5-dev-tools
    sudo apt-get install libfreetype6-dev libcairo2-dev libjpeg8-dev
    sudo apt-get install libpng12-dev liblua5.2-dev gsfonts

Now you can compile and install Ipe into /usr/local:
(Note that 7.x.y has to be replaced by the current Ipe version!)

    cd src
    make IPEPREFIX=/usr/local IPE_USE_ICONV=-DIPE_USE_ICONV
    sudo checkinstall --pkgname=ipe --pkgversion=7.x.y --backup=no \
    	 --fstrans=no --default make install IPEPREFIX=/usr/local
    sudo cp ../fontmaps/gsfonts-fontmap.xml \
    	    /usr/local/share/ipe/7.x.y/fontmap.xml
    sudo ldconfig

The line with "checkinstall" makes sure that Ipe is installed as
package "ipe".  If you no longer need Ipe, or to remove it before
compiling the next release, you can completely remove it from your
system by saying

    sudo rm /usr/local/share/ipe/7.x.y/fontmap.xml
    sudo apt-get remove ipe

If something doesn't work for you, please read below to check the
details!


--------------------------------------------------------------------
Detailed instructions
--------------------------------------------------------------------


Required components
-------------------

Before you can compile Ipe, you will need to have the following tools
and libraries:

 * GNU make

   The Ipe makefiles are written for GNU make.  A Linux system will
   already have it.  On other Unix systems, GNU make is often
   installed as 'gmake'.  Otherwise, install it yourself from
   www.gnu.org. Other "make" implementations will not work!

 * The compression library 'zlib'

   Very likely you already have it on your system (check for the
   include file "zlib.h").  If not, obtain it from "www.gzip.org/zlib"
   and install it.

 * The font library 'Freetype 2'

   On Linux, you most likely already have this on your system.  You
   will need the development package (on Debian/Ubuntu, this is
   "libfreetype6-dev").  

   The original sources are at "www.freetype.org".  You need version
   2.1.8 or newer.

 * The Cairo library (version 1.8.0 or higher)

   The Gnome desktop uses this high-quality rendering library, so you
   may already have it.  You will need the development package,
   e.g. on Debian/Ubuntu "libcairo2-dev".  

   You can also install from sources at "www.cairographics.org".  If
   you compile Cairo yourself, note that you only need the image,
   Postscript, and svg surfaces (backends).  You also need freetype
   support, but no fontconfig.  Since Ipe does not need any
   platform-dependent backends, Cairo should compile fine on any
   platform.

 * The libpng library

   You'll need the development package, e.g. on Debian/Ubuntu
   "libpng12-dev". You can also install from source at
   "http://www.libpng.org".

 * The libjpeg library (version 6 or higher)

   You'll need the development package, e.g. on Debian/Ubuntu
   "libjpeg8-dev".  You can also use libjpeg-turbo instead (the
   package "libjpeg-turbo8-dev"), from http://libjpeg-turbo.virtualgl.org/.

 * The Lua language (version 5.2 or 5.3)

   Lua is an embeddable scripting language. On Debian/Ubuntu, install
   "liblua5.2-dev".  Or compile from source at "www.lua.org" - the
   sources are ANSI C and compile very easily.  Ipe requires Lua 5.2
   or Lua 5.3, and will not work with Lua 5.1.

   Make sure that you build a DYNAMIC library.  Ipe will not work if
   Lua is linked statically (linking statically would include three
   copies of the Lua interpreter, resulting in random crashes).

 * The Qt toolkit (version 4.5 or higher)

   Ipe will compile and work with both Qt 4 and Qt 5.
   
   On Linux, you most likely already have it. On Debian/Ubuntu, you
   would need the packages "qtbase5-dev" and "qtbase5-dev-tools".

   You download binaries or sources at "www.qt.io/".  You only need
   the Qt5Core, Qt5Gui, and Qt5Widgets libraries.

 * The 14 standard Postscript fonts

   If you create text objects using the 14 standard Postscript fonts
   (Times, Helvetica, Courier) the font doesn't need to be embedded in
   the PDF file. Still, Ipe needs access to the font to display it on
   the screen, and that's why you need to provide these 14 font files.

   The path of least resistance would be to download the fonts as
   "urw-fonts.zip" from the same place where you got Ipe.  Use the
   supplied file "urw-fontmap.xml" as the fontmap for these fonts (see
   below for installation of the fontmap).

   However, very likely you have these fonts already on your system,
   for instance in "/usr/share/fonts/type1/gsfonts/" under the names:

   n019003l.pfb n019004l.pfb n019023l.pfb n019024l.pfb n021003l.pfb
   n021004l.pfb n021023l.pfb n021024l.pfb n022003l.pfb n022004l.pfb
   n022023l.pfb n022024l.pfb s050000l.pfb d050000l.pfb

   Identical fonts may also be in subdirectories of
   "/usr/share/texmf/fonts/type1/urw" or
   "/usr/share/texmf-texlive/fonts/type1/urw", under the names
   
   ucrb8a.pfb ucrbo8a.pfb ucrr8a.pfb ucrro8a.pfb uhvb8a.pfb
   uhvbo8a.pfb uhvr8a.pfb uhvro8a.pfb usyr.pfb utmb8a.pfb utmbi8a.pfb
   utmr8a.pfb utmri8a.pfb uzdr.pfb

   Your system may have a fontmap file describing all the fonts on the
   system in XML-format, similar to the supplied files
   "gsfonts-fontmap.xml" and "texlive-fontmap.xml".  If so, Ipe can
   directly read this file and find the fonts, and all you need to do
   is to provide the path to the fontmap.

   If not, one of the supplied fontmaps may already be correct.  On
   Debian/Ubuntu, "gsfonts-fontmap.xml" should be correct if you have
   the "gsfonts" package installed.

   Otherwise you can check for the location of the necessary files,
   and create your own fontmap.  If you use relative paths in the
   fontmap, they are interpreted relative to the directory containing
   the fontmap file.

 * Pdflatex

   Ipe uses Pdflatex, a PDF-producing version of Latex, to convert
   Latex source code to Postscript/PDF.  Every modern TeX installation
   includes it.

   If you still have a version of Pdftex earlier than 1.40, set the
   environment variable IPEANCIENTPDFTEX when running Ipe.


Configuring and building Ipe
----------------------------

There are some pieces of information you need to provide to the Ipe
build process by editing "src/config.mak" (in many cases you can also
just give the definitions on the make command line, see below).

You first have to indicate the location of the required components
listed above.  On Linux, you probably have a correctly working
'pkg-config' script, and the default settings should work.  

You'll have to check that the Lua package name is correct - try saying

     pkg-config --modversion lua5.2

If the package isn't found, try 'lua' or 'lua52'.

Second, you have to define the Ipe directory structure.  Normally, you
would only need to define IPEPREFIX properly, depending on where you
want Ipe to be installed.

Indicate in IPEFONTMAP the path for "fontmap.xml" (if you are using a
system fontmap, indicate the correct path; if you are using/making one
specifically for Ipe place the fontmap in this location).

These steps will then build Ipe:

     cd src
     make
     make install

Instead of editing "src/config.mak", you can also set the variables in
the make call, e.g.:

    cd src
    make IPEPREFIX=/usr IPEFONTMAP=/etc/ipe/fontmap.xml
    sudo make install IPEPREFIX=/usr/local

You may need to do "make install" as root (depending on whether you
have write permission to the installation location).


Installing a fontmap
--------------------

If you have made a "fontmap.xml" for Ipe, move it into the location
you specified in "config.mak".  In case you are using "urw-fonts.zip",
move "urw-fontmap.xml" to "IPEPREFIX/share/ipe/IPEVERS/fontmap.xml",
and unpack the 14 fonts from "urw-fonts.zip" into
"IPEPREFIX/share/ipe/IPEVERS/fonts" (assuming you haven't changed the
standard definition of IPEFONTMAP).  Note that "make install" DOES NOT
install any fontmap - you have to do this one step manually.


Dynamic linking
---------------

The Ipe libraries are shared libraries, and so your dynamic linker has
to find "libipe*.so".  If you have chosen a standard library directory
for IPELIBDIR, saying "sudo ldconfig" will be enough to run Ipe.

If you installed in a different location, such as "/opt/ipe7", you
can make a small script called "ipe" like the following, and put it in
your path:

#!/bin/sh
export LD_LIBRARY_PATH="/opt/ipe7/lib/:$LD_LIBRARY_PATH"
/opt/ipe7/bin/ipe $* &

Alternatively, you could put links to the library in a standard
location:

    sudo ln -f -s IPELIBDIR/lib* /usr/lib
    sudo ldconfig

--------------------------------------------------------------------
