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