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