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