Cosmetic fix
[yaz-moved-to-github.git] / doc / installation.xml
1 <!-- $Id: installation.xml,v 1.30 2006-04-30 06:50:09 adam Exp $ -->
2  <chapter id="installation"><title>Compilation and Installation</title>
3   
4   <sect1><title>Introduction</title>
5    <para>
6     The latest version of the software will generally be found at:
7    </para>
8    <para>
9     <ulink url="&url.yaz.download;"/>
10    </para>
11    <para>
12     We have tried our best to keep the software portable, and on many
13     platforms, you should be able to compile everything with little or
14     no changes. 
15    </para>
16
17    <para>
18     The software is regularly tested on
19     <ulink url="&url.debian;">Debian GNU/Linux</ulink>,
20     <ulink url="&url.redhat;">Redhat Linux</ulink>,
21     <ulink url="&url.gentoo;">Gentoo Linux</ulink>,
22     <ulink url="&url.freebsd;">FreeBSD (i386)</ulink>,
23     <ulink url="&url.macosx;">MAC OSX</ulink>,
24     <ulink url="&url.solaris;">SunOS 5.8 (sparc)</ulink>,
25     <ulink url="&url.windows2000;">Windows 2000</ulink>,
26     <ulink url="&url.windows2003server;">Windows 2003 server</ulink>.
27    </para>
28    
29    <para>
30     Some versions have be known to work on HP/UX,
31     DEC Unix, <ulink url="&url.netbsd;">NetBSD</ulink>,
32     <ulink url="&url.openbsd;">OpenBSD</ulink>,
33     IBM AIX,
34     Data General DG/UX (with some CFLAGS tinkering),
35     SGI/IRIX, DDE Supermax, Apple Macintosh (using the Codewarrior programming
36     environment and the GUSI socket libraries),
37     IBM AS/400 .
38    </para>
39
40    <para>
41     If you move the software to other platforms, we'd be grateful if you'd
42     let us know about it. If you run into difficulties, we will try to help
43     if we can, and if you solve the problems, we would be happy to include
44     your fixes in the next release. So far, we have mostly avoided
45     <literal>&num;ifdefs</literal> for individual platforms, and we'd
46     like to keep it that way as far as it makes sense.
47    </para>
48    
49    <para>
50     We maintain a mailing-list for the purpose of announcing new releases and
51     bug-fixes, as well as general discussion. Subscribe by 
52     filling-in the form
53     <ulink url="&url.yaz.mailinglist;">here</ulink>.
54     General questions and problems can be directed at 
55     <ulink url="&url.yaz.mail;"/>, or the address given at the top of
56      this document.
57    </para>
58    
59   </sect1>
60   <sect1 id="installation.unix"><title>UNIX</title>
61
62    <para>
63     We provide 
64     <ulink url="&url.debian;">Debian GNU/Linux</ulink>
65     and 
66     <ulink url="&url.redhat;">Redhat</ulink> packages for &yaz;. 
67     Only i386 binary packages are available. You should be able to
68     create packages for other CPUs by building them from the source
69     package.
70    </para>
71    
72    <sect2 id="installation.source.unix">
73     <title>Compiling from source on Unix</title>
74     
75     <para>
76      Note that if your system doesn't have a native ANSI C compiler, you may
77      have to acquire one separately. We recommend
78      <ulink url="&url.gcc;">GCC</ulink>.
79     </para>
80
81     <para>
82      If you wish to use character set conversion facilities in &yaz; or if you
83      are compiling &yaz; for use with Zebra it is a good idea to ensure that
84      the iconv library is installed. Some Unixes today already have it
85      - if not, we suggest 
86      <ulink url="&url.libiconv;">GNU libiconv</ulink>.
87     </para>
88
89     <para>
90      The XML C library <ulink url="&url.libxml2;">libxml2</ulink>
91      is required if &yaz; is to support SRW and SRU.
92      This library is very portable and should compile out-of-the
93      box on virtually all Unix platforms. It is available in binary
94      forms for Linux and others.
95     </para>
96
97     <para>
98      The GNU tools
99      <ulink url="&url.autoconf;">Autoconf</ulink>,
100      <ulink url="&url.automake;">Automake</ulink> and
101      <ulink url="&url.libtool;">Libtool</ulink>
102      are used to generate Makefiles and configure &yaz; for the system.
103      You do <emphasis>not</emphasis> these tools unless you're using the
104      CVS version of &yaz;.
105     </para>
106
107     <para>
108      The CQL parser for &yaz; is built using
109      GNU <ulink url="&url.bison;">Bison</ulink>.
110      This tool is only needed if you're using the CVS version of &yaz;.
111     </para>
112         
113     <para>
114      &yaz; includes a tiny ASN.1 compiler. This compiler is
115      written in <ulink url="&url.tcl;">Tcl</ulink>.
116      But as for Bison you do not need it unless you're using CVS
117      version of &yaz; or you're using the compiler to built own codecs
118      for private ASN.1. 
119     </para>
120      
121     <para>
122      Generally it should be sufficient to run configure without options,
123      like this:
124     </para>
125     
126     <screen>
127      ./configure
128     </screen>
129     
130     <para>
131      The configure script attempts to use use the C compiler specified by
132      the <literal>CC</literal> environment variable. If not set, GNU C will be
133      used if it is available. The <literal>CFLAGS</literal> environment
134      variable holds options to be passed to the C compiler. If you're using
135      Bourne-compatible shell you may pass something like this to use a
136      particular C compiler with optimization enabled:
137     </para>
138     
139     <screen>
140      CC=/opt/ccs/bin/cc CFLAGS=-O ./configure
141     </screen>
142     
143     <para>
144      To customize &yaz;, the configure script also accepts a set of options.
145      The most important are:
146      
147      <variablelist>
148       <varlistentry><term>
149         <literal>--prefix</literal>=<replaceable>prefix</replaceable></term>
150        <listitem><para>Specifies installation prefix for &yaz;. This is
151          only needed if you run <literal>make install</literal> later to
152          perform a "system" installation. The prefix is
153          <literal>/usr/local</literal> if not specified.
154         </para></listitem>
155       </varlistentry>
156       <varlistentry><term><literal>--enable-tcpd</literal></term>
157        <listitem><para>The front end server will be built using Wietse's
158          <ulink url="&url.tcpwrapper;">TCP wrapper library</ulink>.
159          It allows you to allow/deny clients depending on IP number.
160          The TCP wrapper library is often used in GNU/Linux and
161          BSD distributions.
162          See
163          <citerefentry>
164           <refentrytitle>hosts_access</refentrytitle>
165           <manvolnum>5</manvolnum>
166          </citerefentry>
167          and 
168          <citerefentry>
169           <refentrytitle>tcpd</refentrytitle>
170           <manvolnum>8</manvolnum>
171          </citerefentry>.
172         </para></listitem>
173       </varlistentry>
174
175       <varlistentry><term><literal>--enable-threads</literal></term>
176        <listitem><para>&yaz; will be built using POSIX threads.
177         Specifically, <constant>_REENTRANT</constant> will be defined during
178          compilation.
179         </para></listitem>
180       </varlistentry>
181
182       <varlistentry><term><literal>--enable-shared</literal></term>
183        <listitem><para>The make process will create shared
184          libraries (also known as shared objects <filename>.so</filename>).
185          By default, no shared libraries are created -
186          equivalent to <literal>--disable-shared</literal>.
187         </para></listitem>
188       </varlistentry>
189
190       <varlistentry><term><literal>--disable-shared</literal></term>
191        <listitem><para>The make process will not create
192          static libraries (<filename>.a</filename>).
193          By default, static libraries are created -
194          equivalent to <literal>--enable-static</literal>.
195         </para></listitem>
196       </varlistentry>
197       
198       <varlistentry><term>
199         <literal>--with-iconv</literal>[=<replaceable>prefix</replaceable>]
200        </term>
201        <listitem><para>Compile &yaz; with iconv library in directory
202          <replaceable>prefix</replaceable>. By default configure will
203          search for iconv on your system. Use this option if it
204          doesn't find iconv. Alternatively you can use 
205          <literal>--without-iconv</literal> to force &yaz; not to use
206          iconv.
207         </para></listitem>
208       </varlistentry>
209
210       <varlistentry><term>
211         <literal>--with-xml2</literal>[=<replaceable>prefix</replaceable>]
212        </term>
213        <listitem><para>Compile &yaz; with 
214          <ulink url="&url.libxml2;">libxml2</ulink> in directory
215          <replaceable>prefix</replaceable>. 
216          Use this option if you want SOAP support.
217          By default configure will
218          search for libxml2 on your system. Use this option if it
219          doesn't find libxml2. Alternatively you can use 
220          <literal>--without-xml2</literal> to force &yaz; not to use
221          libxml2.
222         </para></listitem>
223       </varlistentry>
224
225       <varlistentry><term>
226         <literal>--with-openssl</literal>[=<replaceable>prefix</replaceable>]
227        </term>
228        <listitem><para>&yaz; will be linked with the OpenSSL libraries and
229          an SSL COMSTACK will be provided. Note that SSL support is still
230          experimental.
231         </para></listitem>
232       </varlistentry>
233       
234      </variablelist>
235      
236     </para>
237     <para>
238      When configured, build the software by typing:
239      <screen>
240       make
241      </screen>
242     </para>
243     
244     <para>
245      The following files are generated by the make process:
246      <variablelist>
247       <varlistentry><term><filename>src/libyaz.la</filename></term>
248        <listitem><para>
249          Main &yaz; library. This is no ordinary library. It's
250          a Libtool archive.
251          By default, &yaz; creates a static library in 
252          <filename>lib/.libs/libyaz.a</filename>.
253         </para></listitem>
254       </varlistentry>
255       
256       <varlistentry><term><filename>src/libyazthread.la</filename></term>
257        <listitem><para>
258          When threading is supported/enabled by configure this Libtool
259          library is created. It includes functions that allows &yaz;
260          to use threads.
261         </para></listitem>
262       </varlistentry>
263       
264       <varlistentry><term><filename>ztest/yaz-ztest</filename></term>
265        <listitem><para>Test Z39.50 server. 
266         </para></listitem>
267       </varlistentry>
268       
269       <varlistentry><term><filename>client/yaz-client</filename></term>
270        <listitem><para>Z39.50 client for testing the protocol.
271          See chapter <link linkend="client">
272           YAZ client</link> for more information.
273         </para></listitem>
274       </varlistentry>
275       
276       <varlistentry><term><filename>util/yaz-config</filename></term>
277        <listitem><para>A Bourne-shell script, generated by configure, that
278          specifies how external applications should compile - and link with
279          &yaz;.
280         </para></listitem>
281       </varlistentry>
282       
283       <varlistentry><term><filename>util/yaz-asncomp</filename></term>
284        <listitem><para>The ASN.1 compiler for &yaz;. Requires the
285          Tcl Shell, <application>tclsh</application>, in
286          <literal>PATH</literal> to operate.
287         </para></listitem>
288       </varlistentry>
289       
290       <varlistentry><term><filename>util/yaz-iconv</filename></term>
291        <listitem><para>This program converts data in one character set to
292          another. This command exercises the YAZ character set
293          conversion API.
294         </para></listitem>
295       </varlistentry>
296        
297       <varlistentry><term><filename>util/yaz-marcdump</filename></term>
298        <listitem><para>This program parses ISO2709 encoded MARC records
299          and prints them in line-format or XML.
300         </para></listitem>
301       </varlistentry>
302       
303      <varlistentry><term><filename>zoom/zoomsh</filename></term>
304        <listitem><para>
305          A simple shell implemented on top of the 
306          <link linkend="zoom">ZOOM</link> functions.
307          The shell is a command line application that allows you to enter
308          simple commands to perform ZOOM operations.
309         </para></listitem>
310       </varlistentry>
311       
312       <varlistentry><term><filename>zoom/zoomtst1</filename>, 
313         <filename>zoom/zoomtst2</filename>, ..</term>
314        <listitem><para>
315          Several small applications that demonstrates the ZOOM API.
316         </para></listitem>
317       </varlistentry>
318      </variablelist>
319      
320     </para>
321     
322     <para>
323      If you wish to install &yaz; in system directories  
324      <filename>/usr/local/bin</filename>,
325      <filename>/usr/local/lib</filename> .. etc, you can type:
326     </para>
327     
328     <screen>
329      make install
330     </screen>
331    
332     <para>
333      You probably need to have root access in order to perform this.
334      You must specify the <literal>--prefix</literal> option for configure if
335      you wish to install &yaz; in other directories than the default 
336      <filename>/usr/local/</filename>.
337     </para>
338     
339     <para>
340      If you wish to perform an un-installation of &yaz;, use:
341     </para>
342     
343     <screen>
344      make uninstall
345     </screen>
346     
347     <para>
348      This will only work if you haven't reconfigured &yaz; (and therefore
349      changed installation prefix). Note that uninstall will not
350      remove directories created by make install, e.g.
351      <filename>/usr/local/include/yaz</filename>.
352     </para>
353    </sect2>
354
355    <sect2><title>How to make apps using YAZ on UNIX</title>
356     <para>
357      This section describes how to compile - and link your own
358      applications using the &yaz; toolkit.
359      If you're used to Makefiles this shouldn't be hard. As for
360      other libraries you have used before, you have to set a proper include
361      path for your C/C++ compiler and specify the location of
362      &yaz; libraries. You can do it by hand, but generally we suggest
363      you use the <filename>yaz-config</filename> that is generated
364      by <filename>configure</filename>. This is especially
365      important if you're using the threaded version of &yaz; which
366      require you to pass more options to your linker/compiler.
367     </para>
368     <para>
369      The <filename>yaz-config</filename> script accepts command line
370      options that makes the <filename>yaz-config</filename> script print
371      options that you should use in your make process.
372      The most important ones are:
373      <literal>--cflags</literal>, <literal>--libs</literal>
374      which prints C compiler flags, and linker flags respectively.
375      </para>
376     <para>
377      A small and complete <literal>Makefile</literal> for a C
378      application consisting of one source file,
379      <filename>myprog.c</filename>, may look like this:
380      <screen>
381       YAZCONFIG=/usr/local/bin/yaz-config
382       CFLAGS=`$(YAZCONFIG) --cflags`
383       LIBS=`$(YAZCONFIG) --libs`
384       myprog: myprog.o
385          $(CC) $(CFLAGS) -o myprog myprog.o $(LIBS)
386       </screen>
387      </para>
388     <para>
389      The CFLAGS variable consists of a C compiler directive that will set
390      the include path to the <emphasis>parent</emphasis> directory
391      of <filename>yaz</filename>. That is, if &yaz; header files were
392      installed in <filename>/usr/local/include/yaz</filename>,
393      then include path is set to <filename>/usr/local/include</filename>.
394      Therefore, in your applications you should use
395      <screen>
396       #include &lt;yaz/proto.h>
397      </screen>
398      and <emphasis>not</emphasis>
399      <screen>
400       #include &lt;proto.h>
401      </screen>
402     </para> 
403     <para>
404      For Libtool users, the <filename>yaz-config</filename> script provides
405      a different variant of option <literal>--libs</literal>, called
406      <literal>--lalibs</literal> that returns the name of the
407      Libtool acrhive(s) for &yaz; rather than the ordinary ones.
408     </para>
409     <para>
410      For applications using the threaded version of &yaz;,
411      specify <literal>threads</literal> after the
412      other options. When <literal>threads</literal> is given,
413      more flags and linker flags will be printed by
414      <filename>yaz-config</filename>. If our previous example was
415       using threads, you'd have to modify the lines that set
416      <literal>CFLAGS</literal> and <literal>LIBS</literal> as
417      follows:
418      <screen>
419       CFLAGS=`$(YAZCONFIG) --cflags threads`
420       LIBS=`$(YAZCONFIG) --libs threads`
421      </screen>
422      There is no need specify POSIX thread libraries in your Makefile.
423      The <literal>LIBS</literal> variable includes that as well.
424     </para>
425    </sect2>
426   </sect1>
427   <sect1 id="installation.win32"><title>WIN32</title>
428    
429    <para>The easiest way to install YAZ on Windows is by downloading
430     an installer from 
431     <ulink url="&url.yaz.download.win32;">here</ulink>.
432     The installer comes with source too - in case you wish to
433     compile YAZ with different Compiler options etc. 
434    </para>
435    
436    <sect2 id="installation.win32.source">
437     <title>Compiling from Source on WIN32</title>
438     <para>
439      &yaz; is shipped with "makefiles" for the NMAKE tool that comes
440      with <ulink url="&url.vstudio;">
441       Microsoft Visual Studio</ulink>.
442      Version 6 and .NET has been tested. We expect that &yaz; compiles
443      with version 5 as well.
444     </para>
445     <para>
446      Start a command prompt and switch the sub directory
447      <filename>WIN</filename> where the file <filename>makefile</filename>
448      is located. Customize the installation by editing the
449      <filename>makefile</filename> file (for example by using notepad).
450      
451      The following summarizes the most important settings in that file:
452      
453      <variablelist>
454       <varlistentry><term><literal>DEBUG</literal></term>
455        <listitem><para>
456          If set to 1, the software is
457          compiled with debugging libraries (code generation is
458          multi-threaded debug DLL).
459          If set to 0, the software is compiled with release libraries
460          (code generation is multi-threaded DLL).
461         </para></listitem>
462       </varlistentry>
463       <varlistentry>
464        <term><literal>HAVE_TCL</literal>, <literal>TCL</literal></term>
465        <listitem><para>
466          If <literal>HAVE_TCL</literal> is set to 1, nmake will
467          use the ASN.1 compiler (Tcl based). You must set
468          <literal>TCL</literal> to the full path of the Tcl
469          interpreter.
470         </para>
471         <para>
472          If you do not have Tcl installed, set
473          <literal>HAVE_TCL</literal> to 0.
474         </para></listitem>
475       </varlistentry>
476
477       <varlistentry>
478        <term><literal>HAVE_BISON</literal>,
479         <literal>BISON</literal></term>
480        <listitem><para>
481          If GNU Bison is present, you might set <literal>HAVE_ICONV</literal>
482          to 1 and specify the Bison executable in <literal>BISON</literal>.
483          Bison is only required if you use the CVS version of
484          YAZ or if you modify the grammar for CQL
485          (<filename>cql.y</filename>).
486         </para>
487         <para>
488          A Windows version of GNU Bison is part of 
489          <ulink url="&url.unxutils;">unxutils</ulink>.
490         </para></listitem>
491       </varlistentry>
492
493       <varlistentry>
494        <term><literal>HAVE_ICONV</literal>,
495         <literal>ICONV_DIR</literal></term>
496        <listitem><para>
497          If <literal>HAVE_ICONV</literal> is set to 1, YAZ is compiled
498          with iconv support. In this configuration, set 
499          <literal>ICONV_DIR</literal> to the iconv source directory.
500         </para></listitem>
501       </varlistentry>
502       
503       <varlistentry>
504        <term><literal>HAVE_LIBXML2</literal>,
505         <literal>LIBXML2_DIR</literal></term>
506        <listitem>
507         <para>
508          If <literal>HAVE_LIBXML2</literal> is set to 1, YAZ is compiled
509          with SRW and SRU support. In this configuration, set 
510          <literal>LIBXML2_DIR</literal> to the 
511          <ulink url="&url.libxml2;">libxml2</ulink> source directory
512          and
513          <literal>ZLIB_DIR</literal> to the zlib directory.
514         </para>
515
516         <para>
517          Windows versions of libxml2, zlib and iconv can be found
518          <ulink url="&url.libxml2.download.win32;">
519           Igor Zlatkovi&#x0107;' site</ulink>.
520         </para>
521
522         <note>
523          <para>
524           YAZ is not using ZLIB. But libxml2 is.
525          </para>
526         </note>
527        </listitem>
528       </varlistentry>
529
530      </variablelist>
531     </para>
532     <para>
533      When satisfied with the settings in the makefile, type
534      <screen>
535       nmake
536      </screen>
537     </para>
538     <note>
539      <para>
540       If the <filename>nmake</filename> command is not found on your system
541       you probably haven't defined the environment variables required to
542       use that tool. To fix that, find and run the batch file
543       <filename>vcvars32.bat</filename>. You need to run it from within
544       the command prompt or set the environment variables "globally";
545       otherwise it doesn't work.
546      </para>
547     </note>
548     <para>
549      If you wish to recompile &yaz; - for example if you modify
550      settings in the <filename>makefile</filename> you can delete
551      object files, etc by running.
552      <screen>
553       nmake clean
554      </screen>
555     </para>
556     <para>
557      The following files are generated upon successful compilation:
558      
559      <variablelist>
560       <varlistentry><term><filename>bin/yaz.dll</filename></term>
561        <listitem><para>
562          &yaz; release mode multi-threaded Dynamic Link Library.
563         </para></listitem></varlistentry>
564       
565       <varlistentry><term><filename>lib/yaz.lib</filename></term>
566        <listitem><para>
567          Import library for <filename>yaz.dll</filename>.
568         </para></listitem></varlistentry>
569       
570       <varlistentry><term><filename>bin/yazd.dll</filename></term>
571        <listitem><para>
572          &yaz; debug mode multi-threaded Dynamic Link Library.
573         </para></listitem></varlistentry>
574       
575       <varlistentry><term><filename>lib/yazd.lib</filename></term>
576        <listitem><para>
577          Import library for <filename>yazd.dll</filename>.
578         </para></listitem></varlistentry>
579       
580       <varlistentry><term><filename>bin/yaz-client.exe</filename></term>
581        <listitem><para>
582          &yaz; Z39.50 client application. It's a WIN32 console application.
583          See chapter <link linkend="client">YAZ client</link> for more
584          information.
585         </para></listitem></varlistentry>
586       
587       <varlistentry><term><filename>bin/yaz-ztest.exe</filename></term>
588        <listitem><para>
589          Z39.50 multi-threaded test/example server. It's a WIN32
590          console application.
591         </para></listitem></varlistentry>
592       
593       <varlistentry><term><filename>bin/zoomsh.exe</filename></term>
594        <listitem><para>
595          Simple console application implemented on top of the
596          <link linkend="zoom">ZOOM</link> functions.
597          The application is a command line shell that allows you to enter
598          simple commands to perform ZOOM operations.
599         </para></listitem></varlistentry>
600       
601       <varlistentry><term><filename>bin/zoomtst1.exe</filename>, 
602         <filename>bin/zoomtst2.exe</filename>, ..</term>
603        <listitem><para>
604          Several small applications that demonstrates the ZOOM API.
605         </para></listitem></varlistentry>
606       
607      </variablelist>
608      
609     </para>
610    </sect2>
611
612    <sect2><title>How to make apps using YAZ on WIN32</title>
613     <para>
614      This section will go though the process of linking your WIN32
615      applications with &yaz;.
616     </para>
617     <para>
618      Some people are confused by the fact that we use the nmake
619      tool to build &yaz;. They think they have to do that too - in order
620      to make their WIN32 applications work with &yaz;. The good news is that
621      you don't have to. You can use the integrated environment of
622      Visual Studio if desired for your own application.
623     </para>
624     <para>
625      When setting up a project or Makefile you have to set the following:
626      <variablelist>
627       <varlistentry><term>include path</term><listitem><para>
628          Set it to the <filename>include</filename> directory of &yaz;.
629         </para></listitem></varlistentry>
630       <varlistentry><term>import library <filename>yaz.lib</filename>
631        </term><listitem><para>
632          You must link with this library. It's located in the 
633          sub directory <filename>lib</filename> of &yaz;.
634          If you want to link with the debug version of &yaz;, you must
635          link with <filename>yazd.dll</filename> instead.
636         </para></listitem></varlistentry>
637       <varlistentry><term>dynamic link library <filename>yaz.dll</filename>
638        </term><listitem><para>
639          This DLL must be in your execution path when you invoke
640          your application. Specifically, you should distribute this
641          DLL with your application.
642         </para></listitem></varlistentry>
643      </variablelist>
644     </para>
645    </sect2>
646   </sect1>
647  </chapter>
648  
649  <!-- Keep this comment at the end of the file
650  Local variables:
651  mode: sgml
652  sgml-omittag:t
653  sgml-shorttag:t
654  sgml-minimize-attributes:nil
655  sgml-always-quote-attributes:t
656  sgml-indent-step:1
657  sgml-indent-data:t
658  sgml-parent-document: "yaz.xml"
659  sgml-local-catalogs: nil
660  sgml-namecase-general:t
661  End:
662  -->
663