Tagging 1.99.1
[linux_from_scratch.git] / newxml / chapter06 / zlib.xml
blob36f25e203dbcdc6ba03b398f9c16b4b390ea9e96
1 <?xml version="1.0" encoding="ISO-8859-1"?>
2 <!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.3CR2//EN" "http://www.docbook.org/xml/4.3CR2/docbookx.dtd" [
3   <!ENTITY % zlib-entities SYSTEM "../ent/zlib.ent">
4   %zlib-entities;
5 ]>
6 <sect1 id="ch06-zlib">
7 <title>Installing Zlib-&zlib-version;</title>
8 <?dbhtml filename="zlib.html"?>
10 <screen>Estimated build time:           0.1 SBU
11 Estimated required disk space:  1.5 MB</screen>
13 <xi:include xmlns:xi="http://www.w3.org/2003/XInclude" href="../appendixa/zlib-contents.xml"/>
17 <xi:include xmlns:xi="http://www.w3.org/2003/XInclude" href="../appendixa/zlib-deps.xml"/>
22 <sect2>
23 <title>Installation of Zlib</title>
25 <para>Prepare Zlib for compilation:</para>
27 <screen><userinput>./configure --prefix=/usr --shared</userinput></screen>
29 <note><para>Zlib is known to build its shared library incorrectly if CFLAGS is
30 specified in the environment. If you are using your own CFLAGS variable, be
31 sure to add the <emphasis role="strong">-fPIC</emphasis> directive to your
32 CFLAGS for the duration of the above command, then remove it
33 afterwards.</para></note>
35 <para>Compile the package:</para>
37 <screen><userinput>make</userinput></screen>
39 <para>This package has a test suite available which can perform a number of
40 checks to ensure it built correctly. The test suite for Zlib is quick and
41 painless so we recommend it be run. The following command will test the shared
42 library:</para>
44 <screen><userinput>make check</userinput></screen>
46 <para>Install the shared library:</para>
48 <screen><userinput>make install</userinput></screen>
50 <para>Now also build the non-shared (static) library:</para>
51 <screen><userinput>make clean
52 ./configure --prefix=/usr
53 make</userinput></screen>
55 <para>The following command will test the static library:</para>
57 <screen><userinput>make check</userinput></screen>
59 <para>Install the static library:</para>
61 <screen><userinput>make install</userinput></screen>
63 <para>And fix the permissions on the static library:</para>
65 <screen><userinput>chmod 644 /usr/lib/libz.a</userinput></screen>
67 <para>It is good policy and common practice to place important libraries into
68 the <filename class="directory">/lib</filename> directory. This matters most
69 in scenarios where <filename class="directory">/usr</filename> is on a
70 separate partition. Essentially, the run-time components of any libraries
71 depended upon by programs in <filename class="directory">/bin</filename> or
72 <filename class="directory">/sbin</filename> should reside in
73 <filename class="directory">/lib</filename> so that they are on the root
74 partition and available in the event of
75 <filename class="directory">/usr</filename> being inaccessible.</para>
77 <para>Therefore we move the run-time components of the shared Zlib into
78 <filename class="directory">/lib</filename> by issuing the following
79 command:</para>
81 <screen><userinput>mv /usr/lib/libz.so.* /lib</userinput></screen>
83 <para>Now we need to fix up the <filename>/usr/lib/libz.so</filename> symlink
84 because we just moved the location of the file it points to:</para>
86 <screen><userinput>ln -sf ../../lib/libz.so.1 /usr/lib/libz.so</userinput></screen>
88 </sect2>
90 </sect1>