\documentclass[11pt]{amsart}
\usepackage{geometry}                % See geometry.pdf to learn the layout options. There are lots.
\geometry{letterpaper}                   % ... or a4paper or a5paper or ... 
%\geometry{landscape}                % Activate for for rotated page geometry
\usepackage[parfill]{parskip}    % Activate to begin paragraphs with an empty line rather than an indent
\usepackage{graphicx}
\usepackage{amssymb}
\usepackage{url}
\usepackage{epstopdf}
\DeclareGraphicsRule{.tif}{png}{.png}{`convert #1 `dirname #1`/`basename #1 .tif`.png}

\title{Building Convert and Image Magick}
\author{Richard Koch}
\date{\today}                                           % Activate to display a given date or no date

\begin{document}
\maketitle

This package installs a single binary, convert, in /usr/local/bin. This binary is just one portion of Image Magick, which we used to install. The binary can convert between different file formats using a simple shell command. For example
\begin{verbatim}
     convert mypicture.tiff mypicture.png
\end{verbatim}
converts a tiff file to a png file, leaving the original tiff file in place. Many file formats are covered, including tiff, jpg, png, pdf, and eps.

There are two main uses for the binary. Pdftex does not understand tiff files but does understand png files. With the proper header command, the graphicx package can automatically convert tiff files to png files during typesetting.

The TeX4ht package converts TeX files to html files. It uses convert extensively. I verified with Eitan Gurari that no other part of Image Magick is used. While TeX4ht is in TeX Live, convert is not.

\section{Compiling}

Compiling convert is tricky. Image Magick constructs shared libraries which all of its components call, and it requires other libraries: libjpeg, png, freetype, tiff, zlib. We don't want to install the Image Magick shared libraries or these extra libraries. The trick is to compile Image Magick using static libraries and then pull out convert.

Start by renaming the old /usr/local in /usr, and rename X11 and/or X11R6 so X11 support won't be added.


We compile on OS X 10.5 for PPC and for Intel.  

%OS X 10.4 on Intel to get a binary which works on all systems. Unfortunately, the "make" utility supplied on 10.3 PPC is out of date, so the first step on PPC is to obtain an updated "make" file. This source is at \url{http://ftp.gnu.org/pub/gnu/make/}. Obtain this, change to the source directory, and
%\begin{verbatim}
%          ./configure
%          make
%          sudo make install
%\end{verbatim}
%Then in Terminal type
%\begin{verbatim}
%          PATH=/usr/local/bin:$PATH; export PATH
%\end{verbatim}     
%
%On Intel the previous step is unnecessary. From this point on, the same techniques work on both machines.
%

First install the required libraries in /usr/local. We need the following libraries:
\begin{verbatim}
zlib     http://www.zlib.net/                         Ver 1.2.7: May 2, 2012
libjpeg  http://www.ijg.org                           Ver 8d: January 15, 2012     
freetype http://freetype.sourceforge.net/index2.html  Ver 2.4.11: December 20, 2012
libpng   http://www.libpng.org/pub/png/libpng.html    Ver 1.5.14: January 24, 2013
libtiff  http://www.remotesensing.org/libtiff/        Ver 4.0.3 September 22, 2012
bzip2    http://bzip.org/                             Ver 1.0.6; September 20, 2010

\end{verbatim}

The latest version of libjpeg is Ver 9, but that version has a bug which affects libtiff. So we downgrade to Ver 8d.

Compile and install libjpeg first. Use the following instructions:
\begin{verbatim}
     make clean
     ./configure --enable-shared --enable-static
     
     rm libtool
     ln -s `which glibtool` ./libtool
     
     make

     sudo mkdir -p /usr/local/include

     sudo mkdir -p /usr/local/lib
     sudo mkdir -p /usr/local/man/man1
     sudo mkdir -p /usr/local/bin

     sudo make install
\end{verbatim}

Then change to /usr/local/lib and remove all files except libjpeg.a.

Compile zlib, libtiff, libpng,  freetype, and bzip2 in that order, using the standard commands (bzip2 doesn't have a .configure step):

\begin{verbatim}
          make clean
          ./configure
          make
          sudo make install
\end{verbatim}

After each step, remove all .dylib and .la files in /usr/local/lib.


 
Next go to /usr/local and remove everything in the bin directory. % except ``make''. 
Also remove the man, and share directories, leaving only the include and lib directories. 

Obtain the ImageMagick source code at 
\begin{verbatim}
   http://www.imagemagick.org/script/install-source.php#unix
\end{verbatim}
This contains version 6.8.3-3 released February 19, 2013.

Go to IM/ImageMagick-6.8.3-3 and compile Image Magick using the sequence
\begin{verbatim}
          make clean
          ./configure --disable-shared
          make
          sudo make install 
\end{verbatim}
It helps to look at the configure output and confirm that shared libraries are disabled. 

Now go to /usr/local and remove the include library. Also in /usr/local/lib, remove the ``old'' directory and all libraries, leaving only the folder named ``ImageMagick-6.8.3''.

Finally, move the entire remaining contents of /usr/local to Universal/local-i386 or Universal/local-ppc depending on whether you compiled on Intel  or on PPC. 

Make sure the Universal folder has a subfolder named ``local'' containing a subfolder named ``bin''. Change directory to Universal, strip the binaries, and lipo them together using the following commands:
\begin{verbatim}
          cd local-i386/bin
          strip *
          cd ../..
          cd local-ppc/bin
          strip *
          cd ../..
          sh liposcript
\end{verbatim}

Finally, execute the build instruction using the command
\begin{verbatim}
          sudo sh buildRoot.sh
\end{verbatim}




\end{document} 


