[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,14 +1,15 @@
This demonstrates the use of PNG_USER_CONFIG and pngusr.h
To build a minimal read-only progressive decoder embedded libpng and
zlib and with your system's X library, run
The makefile builds a minimal read-only progressive decoder with
embedded libpng, zlib and your system's X library.
gather.sh # to collect needed files from gregbook, libpng, and zlib
Specify the location of the zlib source (1.2.1 or later) as ZLIBSRC
on the make command line.
Edit makefile if required, to find your X library and include files,
then
make
make ZLIBSRC=directory
If you prefer to use the shared libraries, go to contrib/gregbook
and build the rpng2-x application there.

View File

@@ -1,18 +0,0 @@
test -n "${PNGSRC}" || PNGSRC=../../..
cp "${PNGSRC}"/contrib/gregbook/rpng2-x.c .
cp "${PNGSRC}"/contrib/gregbook/readpng2.[ch] .
cp "${PNGSRC}"/contrib/gregbook/COPYING .
cp "${PNGSRC}"/contrib/gregbook/LICENSE .
cp "${PNGSRC}"/*.h .
cp "${PNGSRC}"/*.c .
rm example.c pngtest.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,8 +4,10 @@
#CC=cc
CC=gcc
LD=$(CC)
STRIP=strip
RM=rm -f
COPY=cp
#XINC = -I/usr/include # old-style, stock X distributions
#XLIB = -L/usr/lib/X11 -lX11 # (including SGI IRIX)
@@ -23,21 +25,68 @@ XLIB = -L/usr/X11R6/lib -lX11
#LIBS = $(XLIB)
LIBS = $(XLIB) -lm #platforms that need libm
CFLAGS=-DPNG_USER_CONFIG -DNO_GZCOMPRESS -DNO_GZIP \
-DdeflateParams\(a,b,c\)=Z_OK -I. $(XINC) -O1
CFLAGS=-DPNG_USER_CONFIG -DNO_GZCOMPRESS -DNO_GZIP -I. $(XINC) -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/gregbook
OBJS = rpng2-x$(O) readpng2$(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) \
pngpread$(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) \
pngpread$(O) pngread$(O) pngrio$(O) pngrtran$(O) pngrutil$(O) \
pngset$(O) pngtrans$(O) $(ZOBJS)
pngset$(O) pngtrans$(O)
PROGSRCS= rpng2-x$(C) readpng2$(C)
PROGHDRS= readpng2.h
PROGDOCS= COPYING LICENSE
PROGOBJS= rpng2-x$(O) readpng2$(O)
OBJS = $(PROGOBJS) $(PNGOBJS) $(ZOBJS)
# implicit make rules -------------------------------------------------------
@@ -46,22 +95,67 @@ OBJS = rpng2-x$(O) readpng2$(O) png$(O) pngerror$(O) pngget$(O) pngmem$(O) \
# dependencies
all: rpng2-x$(E)
all: $(PROGDOCS) rpng2-x$(E)
rpng2-x$(E): $(OBJS)
$(LD) -o rpng2-x$(E) $(OBJS) $(LIBS)
strip rpng2-x$(E)
$(STRIP) rpng2-x$(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) rpng2-x$(O)
$(RM) rpng2-x$(E)
$(RM) $(OBJS)
$(OBJS): png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h readpng2.h pngusr.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
$(PROGSRCS) $(PROGHDRS) $(PROGDOCS): $(PROGSRC)/$@
$(RM) $@
$(COPY) $(PROGSRC)/$@ $@
# End of makefile for rpng2-x

View File

@@ -0,0 +1,29 @@
# pngminim/preader/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
# Just switch on the progressive read code
option PROGRESSIVE_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, rpng2-x, 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_bKGD on
option READ_GAMMA on
option READ_EXPAND on
option READ_16_TO_8 on
option READ_GRAY_TO_RGB on

View File

@@ -12,57 +12,17 @@
#ifndef MINPRDPNGCONF_H
#define MINPRDPNGCONF_H
#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 progressive reader"
#define PNG_USER_DLLFNAME_POSTFIX "mp"
/* 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_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_cHRM
#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_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_USER_LIMITS
#define PNG_NO_SET_USER_LIMITS
#define PNG_NO_TIME_RFC1123
#endif /* MINPRDPNGCONF_H */