libpng shared library for Atari (MiNT/MagiC)
============================================

This is an attempt to make libpng, which is used widely by several applications,
available as a shared libary for Atari.

The goal here was to make it as easy as possible to switch from linking a
static version, to use the shared version instead. Remember though that
neither the OS nor the compilers in use have direct support for that,
and that the application needs to support it.


How to use it:
==============

for GCC:
Install the header files from the include directory to /usr/include (or
to your cross installation directory), the libraries to /usr/lib, and
the executables from /mint/slb to a directory where Slbopen can find them
(usually also /mint/slb, or c:/gemsys/slb)

In your application:
- Define -DPNGLIB_SLB and -DZLIB_SLB before including png.h, or include slb/png.h instead
  (both should have the same effect)
- add a call to slb_pnglib_open() before using any function from pnglib. Optionally,
  you can pass in a library search path that is passed along to Slbopen().
- Since pnglib needs zlib to work, it will load that too as a shared library.
  You need the shared library of zlib therefor, too. If you need to call functions
  from Zlib from your application, you can optionally load that yourself before
  pnglib.
- for completeness, you can also add a call to slb_pnglib_close() before your
  application terminates.
- link to libpng.slb.a and libz.slb.a instead of the normal libpng.a and libz.a
- use any function from libpng as usual. No need to pass any extra parameters.

For Pure-C:
Same as for GCC, except:
- You can use the header files from the purec/include directory instead. They
  are identical to the ones for GCC, just converted to have CR/LF endings.
- the static library is named pnglib16.lib, the import library for the
  shared library is pngslb16.lib (16 here stands for the major version of
  the library, not for 16-bit)

That's all!

Note that slb_pnglib_open() contains fallback code for systems lacking Slbopen(),
so this should work even on SingleTOS.



Files in the archive:
=====================

usr/include/png.h
usr/include/pngconf.h
usr/include/pnglibconf.h
    Slightly modified versions from the files of the original distribution,
    intended to be usable for both static and shared linking.
usr/include/slb/png.h
    Include file for using the shared library, with declarations of the above
    mentioned functions.
usr/include/slb/purec/png.h
    Helper macros for Pure-C. Automatically included by slb/png.h
usr/lib/libpng.a
    Static version of the library
usr/lib/libpng.slb.a
    Import library for using the shared library instead
usr/lib/m68020-60/libpng.a
    Static version of the library, compiled for 68020 or better
usr/lib/m68020-60/libpng.slb.a
    Import library for using the shared library instead,
    compiled for 68020 or better
usr/lib/m5475/libpng.a
    Static version of the library, compiled for coldfire
usr/lib/m5475/libpng.slb.a
    Import library for using the shared library instead,
    compiled for coldfire
usr/bin/*
    Some test/example programs from the original distribution.
    example/minigzip are the statically linked versions,
    and examplesh/minigzipsh are linked for the shared library.

purec/include:
    Header files for Pure-C. Same as for GCC, just converted to have CR/LF endings.
purec/lib/000/png.lib
    Static version of the library
purec/lib/000/pngslb.lib
    Import library for using the shared library instead
purec/lib/020/png.lib
    Static version of the library, compiled for 68020 or better
purec/lib/020/pngslb.lib
    Import library for using the shared library instead,
    compiled for 68020 or better
    
mint/slb
    The shared library itself. Use the one appropiate for your system.
    Those were compiled by GCC, but can be used also by Pure-C.


Exported functions:
===================

#0: long pnglib_slb_control(long fn, void *arg)
    - used internally by slb_pnglib_open() to check that
      the correct version of the library was loaded

everything else:
    - all functions publicitly available from png.h.
      Consult that header file, or the man page on
      how to use them.


Known bugs:
===========

- Although the handle of the shared library and its corresponding exec
  function are available to the application, the exec function
  cannot be directly called. Always use the import functions
  (they cover all available functions, anyway).

- When using the library with Pure-C, you may have to change some variables
  from plain "int" to "png_int_t". This is because the library was
  compiled by gcc, and sizeof(int) differs between the two. Look at
  pngtest.c from the source archive where that changes have already been
  made.

- That would also apply to gcc when compiling with --mshort, but you
  shouldn't do that.

- You cannot mix configurations by using a static version of zlib, and a
  shared one of pnglib, or vice versa.

- Since pnglib uses a few math functions, and there is no concept in
  the Pure-C linker of automatically selecting the correct library version,
  the import library actually has 2 different slb_pnglib_open functions,
  and the special header file for Pure-C should automatically select
  the correct version. This is however not well tested yet.
