[devel] Revised contrib/pngminim to use the "everything off" option

in pngusr.dfa.
This commit is contained in:
Glenn Randers-Pehrson
2010-04-28 07:54:14 -05:00
parent cd74549840
commit e3e8f6bf02
18 changed files with 447 additions and 289 deletions

View File

@@ -1,9 +1,10 @@
This demonstrates the use of PNG_USER_CONFIG and pngusr.h
This demonstrates the use of PNG_USER_CONFIG, pngusr.h and pngusr.dfa
To build a minimal read-only decoder with embedded libpng and zlib, run
The makefile builds a minimal read-only decoder with embedded libpng
and zlib.
gather.sh # to collect needed files from pngminus, libpng, and zlib
make
Specify the location of the zlib source (1.2.1 or later) as ZLIBSRC
on the make command line.
If you prefer to use the shared libraries, go to contrib/pngminus
and build the png2pnm application there.

View File

@@ -1,15 +0,0 @@
test -n "${PNGSRC}" || PNGSRC=../../..
cp ${PNGSRC}/contrib/pngminus/png2pnm.c pngm2pnm.c
cp "${PNGSRC}"/*.h .
cp "${PNGSRC}"/*.c .
rm example.c pngtest.c pngpread.c pngw*.c
rm -f pnglibconf.h
test -d scripts || mkdir scripts
cp "${PNGSRC}"/scripts/pnglibconf.mak scripts
cp "${PNGSRC}"/scripts/pnglibconf.dfa scripts
cp "${PNGSRC}"/scripts/options.awk scripts
# change the following if zlib is somewhere else
test -n "${ZLIBSRC}" || ZLIBSRC="${PNGSRC}"/../zlib
cp "${ZLIBSRC}"/*.h .
cp "${ZLIBSRC}"/*.c .
rm minigzip.c example.c compress.c deflate.c gz*

View File

@@ -4,24 +4,73 @@
#CC=cc
CC=gcc
LD=$(CC)
STRIP=strip
RM=rm -f
COPY=cp
CFLAGS=-DPNG_USER_CONFIG -DNO_GZCOMPRESS -DNO_GZIP \
-DdeflateParams\(a,b,c\)=Z_OK -I. -O1
CFLAGS=-DPNG_USER_CONFIG -DNO_GZCOMPRESS -DNO_GZIP -I. -O1
C=.c
O=.o
L=.a
E=
ZOBJS = adler32$(O) crc32$(O) \
infback$(O) inffast$(O) inflate$(O) inftrees$(O) \
trees$(O) uncompr$(O) zutil$(O)
# Where to find the source code:
PNGSRC =../../..
ZLIBSRC=$(PNGSRC)/../zlib
PROGSRC=$(PNGSRC)/contrib/pngminus
OBJS = pngm2pnm$(O) png$(O) pngerror$(O) pngget$(O) pngmem$(O) \
# Zlib (minimal inflate requirements - crc32 is used by libpng)
# zutil can be eliminated if you provide your own zcalloc and zcfree
ZSRCS = adler32$(C) crc32$(C) \
inffast$(C) inflate$(C) inftrees$(C) \
zutil$(C)
# Standard headers
ZH = zlib.h crc32.h inffast.h inffixed.h \
inflate.h inftrees.h zutil.h
# Machine generated headers
ZCONF = zconf.h
# Headers callers use
ZINC = zlib.h $(ZCONF)
# Headers the Zlib source uses
ZHDRS = $(ZH) $(ZCONF)
ZOBJS = adler32$(O) crc32$(O) \
inffast$(O) inflate$(O) inftrees$(O) \
zutil$(O)
# libpng
PNGSRCS=png$(C) pngerror$(C) pngget$(C) pngmem$(C) \
pngread$(C) pngrio$(C) pngrtran$(C) pngrutil$(C) \
pngset$(C) pngtrans$(C)
# Standard headres
PNGH =png.h pngconf.h pngdebug.h pnginfo.h pngpriv.h pngstruct.h
# Machine generated headers
PNGCONF=pnglibconf.h
# Headers callers use
PNGINC= png.h pngconf.h pngusr.h $(PNGCONF)
# Headers the PNG library uses
PNGHDRS=$(PNGH) $(PNGCONF) pngusr.h
PNGOBJS=png$(O) pngerror$(O) pngget$(O) pngmem$(O) \
pngread$(O) pngrio$(O) pngrtran$(O) pngrutil$(O) \
pngset$(O) pngtrans$(O) $(ZOBJS)
pngset$(O) pngtrans$(O)
PROGSRCS= pngm2pnm$(C)
PROGHDRS=
PROGDOCS=
PROGOBJS= pngm2pnm$(O)
OBJS = $(PROGOBJS) $(PNGOBJS) $(ZOBJS)
# implicit make rules -------------------------------------------------------
@@ -35,23 +84,63 @@ all: pngm2pnm$(E)
pngm2pnm$(E): $(OBJS)
$(LD) -o pngm2pnm$(E) $(OBJS)
strip pngm2pnm$(E)
$(STRIP) pngm2pnm$(E)
pnglibconf.h: scripts/pnglibconf.mak scripts/pnglibconf.dfa \
scripts/options.awk pngusr.h
rm -f pnglibconf.h
$(MAKE) $(MAKEFLAGS) -f scripts/pnglibconf.mak\
CPPFLAGS=-DPNG_USER_CONFIG $@
# The DFA_XTRA setting turns all libpng options off then
# turns on those required for this minimal build.
# The CPP_FLAGS setting causes pngusr.h to be included in
# both the build of pnglibconf.h and, subsequently, when
# building libpng itself.
$(PNGCONF): $(PNGSRC)/scripts/pnglibconf.mak\
$(PNGSRC)/scripts/pnglibconf.dfa \
$(PNGSRC)/scripts/options.awk pngusr.h pngusr.dfa
$(RM) pnglibconf.h pnglibconf.dfn
$(MAKE) $(MAKEFLAGS) -f $(PNGSRC)/scripts/pnglibconf.mak\
srcdir=$(PNGSRC) CPPFLAGS="-DPNG_USER_CONFIG"\
DFA_XTRA="pngusr.dfa" $@
clean:
$(MAKE) $(MAKEFLAGS) -f scripts/pnglibconf.mak clean
$(MAKE) $(MAKEFLAGS) -f $(PNGSRC)/scripts/pnglibconf.mak\
srcdir=$(PNGSRC) clean
$(RM) pngm2pnm$(O)
$(RM) pngm2pnm$(E)
$(RM) $(OBJS)
$(OBJS): png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h\
pnginfo.h pngdebug.h zlib.h
# distclean also removes the copied source and headers
distclean: clean
$(RM) -r scripts # historical reasons
$(RM) $(PNGSRCS) $(PNGH)
$(RM) $(ZSRCS) $(ZH) $(ZCONF)
$(RM) $(PROGSRCS) $(PROGHDRS) $(PROGDOCS)
# Header file dependencies:
$(PROGOBJS): $(PROGHDRS) $(PNGINC) $(ZINC)
$(PNGOBJS): $(PNGHDRS) $(ZINC)
$(ZOBJS): $(ZHDRS)
# Gather the source code from the respective directories
$(PNGSRCS) $(PNGH): $(PNGSRC)/$@
$(RM) $@
$(COPY) $(PNGSRC)/$@ $@
# No dependency on the ZLIBSRC target so that it only needs
# to be specified once.
$(ZSRCS) $(ZH):
$(RM) $@
$(COPY) $(ZLIBSRC)/$@ $@
# The unconfigured zconf.h varies in name according to the
# zlib release
$(ZCONF):
$(RM) $@
@for f in zconf.h.in zconf.in.h zconf.h; do\
test -r $(ZLIBSRC)/$$f &&\
echo $(COPY) $(ZLIBSRC)/$$f $@ &&\
$(COPY) $(ZLIBSRC)/$$f $@ && exit 0;\
done; echo copy: $(ZLIBSRC)/zconf.h not found; exit 1
pngm2pnm.c: $(PROGSRC)/png2pnm.c
$(RM) $@
$(COPY) $(PROGSRC)/png2pnm.c $@
# End of makefile for pngm2pnm

View File

@@ -0,0 +1,27 @@
# pngminim/decoder/pngusr.dfa
#
# Copyright (c) 2010 Glenn Randers-Pehrson
#
# This code is released under the libpng license.
# For conditions of distribution and use, see the disclaimer
# and license in png.h
# First all the build options off:
everything = off
# All that is required is some read code. This example switches
# on the sequential read code (see ../preader for a progressive
# read example).
option SEQUENTIAL_READ on
# You must choose fixed or floating point arithmetic:
option FLOATING_POINT on
# option FIXED_POINT on
# Your program will probably need other options. The example
# program here, pngm2pnm, requires the following. Take a look
# at pnglibconf.h to find out the full set of what has to be
# enabled to make the following work.
option SETJMP on
option STDIO on
option READ_EXPAND on

View File

@@ -16,64 +16,17 @@
/* No 16-bit support beyond reading with strip_16 */
#endif
#define PNG_USER_PRIVATEBUILD "PNG minimal build"
#define PNG_USER_DLLFNAME_POSTFIX "MN"
/* If pngusr.h is included during the build the following must
* be defined either here or in the .dfa file (pngusr.dfa in
* this case). To include pngusr.h set -DPNG_USER_CONFIG in
* CPPFLAGS
*/
#define PNG_USER_PRIVATEBUILD "libpng minimal conformant PNG decoder"
#define PNG_USER_DLLFNAME_POSTFIX "mr"
/* List options to turn off features of the build that do not
* affect the API (so are not recorded in pnglibconf.h)
*/
#define PNG_NO_WARNINGS
#define PNG_NO_ERROR_TEXT
#define PNG_NO_READ_INT_FUNCTIONS
#define PNG_NO_READ_BGR
#define PNG_NO_READ_GAMMA
#define PNG_NO_READ_BACKGROUND
#define PNG_NO_READ_QUANTIZE
#define PNG_NO_READ_INVERT
#define PNG_NO_READ_SHIFT
#define PNG_NO_READ_PACK
#define PNG_NO_READ_PACKSWAP
#define PNG_NO_READ_FILLER
#define PNG_NO_READ_SWAP
#define PNG_NO_READ_SWAP_ALPHA
#define PNG_NO_READ_INVERT_ALPHA
#define PNG_NO_READ_RGB_TO_GRAY
#define PNG_NO_READ_USER_TRANSFORM
#define PNG_NO_READ_bKGD
#define PNG_NO_READ_cHRM
#define PNG_NO_READ_gAMA
#define PNG_NO_READ_hIST
#define PNG_NO_READ_iCCP
#define PNG_NO_READ_pCAL
#define PNG_NO_READ_pHYs
#define PNG_NO_READ_sBIT
#define PNG_NO_READ_sCAL
#define PNG_NO_READ_sPLT
#define PNG_NO_READ_sRGB
#define PNG_NO_READ_TEXT
#define PNG_NO_READ_tIME
#define PNG_NO_READ_UNKNOWN_CHUNKS
#define PNG_NO_READ_USER_CHUNKS
#define PNG_NO_READ_EMPTY_PLTE
#define PNG_NO_READ_OPT_PLTE
#define PNG_NO_READ_STRIP_ALPHA
#define PNG_NO_READ_oFFs
#define PNG_NO_WRITE_SUPPORTED
#define PNG_NO_INFO_IMAGE
#define PNG_NO_IO_STATE
#define PNG_NO_USER_MEM
#define PNG_NO_FIXED_POINT_SUPPORTED
#define PNG_NO_MNG_FEATURES
#define PNG_NO_USER_TRANSFORM_PTR
#define PNG_NO_HANDLE_AS_UNKNOWN
#define PNG_NO_CONSOLE_IO
#define PNG_NO_ZALLOC_ZERO
#define PNG_NO_ERROR_NUMBERS
#define PNG_NO_EASY_ACCESS
#define PNG_NO_PROGRESSIVE_READ
#define PNG_NO_USER_LIMITS
#define PNG_NO_SET_USER_LIMITS
#define PNG_NO_TIME_RFC1123
#endif /* MINRDPNGCONF_H */