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