]> granicus.if.org Git - zziplib/blob - docs/configs.htm
indent-check
[zziplib] / docs / configs.htm
1 <section> <date> February 2003 </date>
2 <h2> Configuration </h2>                    of other projects using zziplib
3
4 <!--border-->
5
6 <P>
7   If using the zziplib with other project then you can use a number
8   of possibility to configure and link. The zziplib had been usually
9   included within the projects that made use of it - some did even
10   pick up the advantage to be allowed to staticlink in a limited
11   set of conditions. Recently however, the zziplib is shipped as a
12   standard library of various linux/freebsd distros - mostly for
13   the usage by the php-zip module. This allows third party software
14   makers to link to the preinstalled library in the system and
15   consequently reduce the memory consumption - even more than now
16   with the zziplib being a lightweight anyway (the i386 .so is 
17   usually less than 20k)
18 </P>
19
20 <section>
21 <h3> pkg-config --libs </h3>
22
23 <P>
24   Within modern software development, one should be advised to use
25   pkg-config as soon as it is available. The pkg-config helper can
26   handle a lot of problems that can usually come up with linking
27   to third party libraries in case that those link again dynamically
28   with other libraries themselves. It does correctly order the
29   list of "libs", it can throw away duplicate "-L" hints, and same
30   for cflags "-I" hints, plus it will throw away some sys-includes
31   that gcc3.2 will warn about with a false positive.
32 </P>
33 <P>
34   There is a number of pkg-config targets installed in the system
35   but the one you want to use is <b>pkg-config zziplib</b>. 
36   Therefore, a simple Makefile could read like
37   <pre>
38     PROGRAM = my_prog
39     CFLAGS = -Dhappy `pkg-config zziplib --cflags`
40     LIBS   = -Wl,-E  `pkg-config zziplib --libs`
41
42     my_prog.o : my_prog.c
43        $(CC) $(CFLAGS) $&lt; -o $@
44     my_prog : my_prog.o
45        $(LINK) $&lt; $(LIBS)
46   </pre>
47 </P>
48 <P>
49    The `pkg-config zziplibs --libs` will usually expand to 
50    something like <code>-lzzip -lz</code> which are the
51    two (!!) libraries that you need to link with - in that
52    order. The zziplib builds on top of the z-lib algorithms
53    for compression of files within the zip-archive. That's
54    the same for other lib-parts of the zziplib project as
55    well, e.g. the sdl-rwops part which does also need to
56    link with the sdl-lib - and that's where the pkg-config
57    infrastructure can be of great help. That's the reason
58    why zziplib installs a few more ".pc" files, you can
59    get a list of them like this:
60    <pre>
61    $ pkg-config --list-all | sort | grep zzip
62    zziplib               zziplib - ZZipLib - libZ-based ZIP-access Library
63    zzip-sdl-config       zzip-sdl-config - SDL Config (for ZZipLib)
64    zzip-sdl-rwops        zzip-sdl-rwops - SDL_rwops for ZZipLib
65    zzipwrap              zzipwrap - Callback Wrappers for ZZipLib
66    zzip-zlib-config      zzip-zlib-config - ZLib Config (for ZZipLib)
67    </pre>
68 </P><P>
69    The two entries like "zzip-sdl-config" and "zzip-zlib-config"
70    happen to be ".pc" files for the libz.so and libSDL.so that
71    were seen at configure-time of zziplib - you may want to reuse
72    these in your projects as well whenever you need to link to
73    either of zlib or libsdl even in places where there is no direct
74    need for zziplib. It basically looks like:
75    <pre>
76    $ pkg-config zzip-zlib-config --modversion
77    1.1.4
78    $ pkg-config zzip-zlib-config --libs      
79     -lz  
80    </pre>
81 </P>
82
83 </section><section>
84 <h3> zzip-config </h3>
85 <P>
86    The pkg-config ".pc" files are relativly young in the history of
87    zziplib. A long time before that there was the `zzip-config`
88    script installed in the system. These `*-config` were common
89    before the pkg-config came about, and in fact the pkg-config
90    infrastructure was invented to flatten away the problems of
91    using multiple `*-config` scripts for a project. As long as you
92    do not combine multiple `*-config`s then it should be well okay
93    to use the `zzip-config` directly - it does also kill another
94    dependency on the `pkg-config` tool to build your project, the
95    zziplib is all that's needed.
96 </P>
97 <P>
98    In its call-structure the `zzip-config` script uses the same
99    options as `pkg-config`, (well they are historic cousins anyway).
100    and that simply means you can replace each call above like
101    `pkg-config zziplib...` with `zzip-config...`.
102
103   <pre>
104     PROGRAM = my_prog
105     CFLAGS = -Dhappy `zzip-config --cflags`
106     LIBS   = -Wl,-E  `zzip-config --libs`
107
108     my_prog.o : my_prog.c
109        $(CC) $(CFLAGS) $&lt; -o $@
110     my_prog : my_prog.o
111        $(LINK) $&lt; $(LIBS)
112   </pre>
113 </P>
114 <P>
115    Be informed that the zzip-config script is low-maintained and
116    starting with 2004 it will be replaced with a one-line script 
117    that simply reads `pkg-config zziplib $*`. By that time the
118    rpm/deb packages will also list "pkgconfig" as a dependency
119    on the zziplib-devel/zziplib-dev part.
120 </P>
121
122 </section><section>
123 <h3> autoconf macro </h3>
124
125 <P>
126   There is currently an autoconf macro installed along into
127   the usual /usr/share/aclocal space for making it easier for
128   you to pick up the configure-time cflags/libs needed to
129   build/link with zziplib. In any way it does look like
130   this:
131   <pre>
132   dnl PKG_CHECK_ZZIPLIB(ZSTUFF, min-version, action-if, action-not)
133   AC_DEFUN([PKG_CHECK_ZZIPLIB],[dnl
134   PKG_CHECK_MODULES([$1], [zziplib $2], [$3], [$4])])
135   </pre>
136 </P>
137 <P>
138   You are strongly advised to take advantage of the pkgconfig's
139   macro directly - you can find the macro in
140   <code>/usr/share/aclocal/pkg.m4</code> and it allows to
141   combine the flags of a list of library modules that you
142   want to have. If it is only zziplib, than you could simply
143   use this in your configure.ac:
144 <pre>
145   <b>PKG_CHECK_MODULES</b>([<b>ZZIP</b>],[zziplib &gt;= 0.10.75])
146   </pre>
147 </P><P>
148   which will provide you with two autoconf/automake variables
149   named <b><code>ZZIP_CFLAGS</code></b> and <b><code>ZZIP_LIBS</code></b> 
150   respectivly.
151 </P>
152 <P>
153   Up to 2004, the macro in zziplib.m4 will be however carry
154   a copy of the pkg.m4 so that you do not need another
155   dependency for your software project. The macro is called
156   like shown above PKG_CHECK_ZZIPLIB and you would call it
157   like
158 <br><code>&nbsp;&nbsp;&nbsp;&nbsp;
159   PKG_CHECK_ZZIPLIB([ZZIP],[0.10.75])</code><br>
160   which will give you the two autoconf/automake variables
161   as well,  <code>ZZIP_CFLAGS</code> and <code>ZZIP_LIBS</code>
162 </P>
163
164 </section></section>