From 32d5cbb90bcca185eb2f96307f1fc644c612178d Mon Sep 17 00:00:00 2001 From: Aki Date: Wed, 29 Sep 2021 21:56:06 +0200 Subject: Squashed 'libpng/' content from commit 3d3aae16 git-subtree-dir: libpng git-subtree-split: 3d3aae1697897e92176530bc6e85c551772614ea --- contrib/pngminim/decoder/README | 10 +++ contrib/pngminim/decoder/makefile | 149 ++++++++++++++++++++++++++++++++++++ contrib/pngminim/decoder/pngusr.dfa | 39 ++++++++++ contrib/pngminim/decoder/pngusr.h | 23 ++++++ 4 files changed, 221 insertions(+) create mode 100644 contrib/pngminim/decoder/README create mode 100644 contrib/pngminim/decoder/makefile create mode 100644 contrib/pngminim/decoder/pngusr.dfa create mode 100644 contrib/pngminim/decoder/pngusr.h (limited to 'contrib/pngminim/decoder') diff --git a/contrib/pngminim/decoder/README b/contrib/pngminim/decoder/README new file mode 100644 index 0000000..5618cb7 --- /dev/null +++ b/contrib/pngminim/decoder/README @@ -0,0 +1,10 @@ +This demonstrates the use of PNG_USER_CONFIG, pngusr.h and pngusr.dfa + +The makefile builds a minimal read-only decoder with embedded libpng +and zlib. + +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. diff --git a/contrib/pngminim/decoder/makefile b/contrib/pngminim/decoder/makefile new file mode 100644 index 0000000..43e45bd --- /dev/null +++ b/contrib/pngminim/decoder/makefile @@ -0,0 +1,149 @@ +# Makefile for PngMinus (pngm2pnm) +# Linux / Unix + +#CC=cc +CC=gcc +LD=$(CC) +STRIP=strip + +# If awk fails try +# make AWK=nawk + +RM=rm -f +COPY=cp + +CFLAGS=-DPNG_USER_CONFIG -DNO_GZCOMPRESS -DNO_GZIP -I. -O1 + +C=.c +O=.o +L=.a +E= + +# Where to find the source code: +PNGSRC =../../.. +ZLIBSRC=$(PNGSRC)/../zlib +PROGSRC=$(PNGSRC)/contrib/pngminus + +# 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 headers +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) + +PROGSRCS= pngm2pnm$(C) +PROGHDRS= +PROGDOCS= +PROGOBJS= pngm2pnm$(O) + +OBJS = $(PROGOBJS) $(PNGOBJS) $(ZOBJS) + +# implicit make rules ------------------------------------------------------- + +# note: dependencies do not work on implicit rule lines +.c$(O): + $(CC) -c $(CFLAGS) $< + +# dependencies + +all: pngm2pnm$(E) + +pngm2pnm$(E): $(OBJS) + $(LD) -o pngm2pnm$(E) $(OBJS) + $(STRIP) pngm2pnm$(E) + +# 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 $(PNGSRC)/scripts/pnglibconf.mak\ + srcdir=$(PNGSRC) clean + $(RM) pngm2pnm$(O) + $(RM) pngm2pnm$(E) + $(RM) $(OBJS) + +# 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 diff --git a/contrib/pngminim/decoder/pngusr.dfa b/contrib/pngminim/decoder/pngusr.dfa new file mode 100644 index 0000000..9653cd1 --- /dev/null +++ b/contrib/pngminim/decoder/pngusr.dfa @@ -0,0 +1,39 @@ +# pngminim/decoder/pngusr.dfa +# +# Copyright (c) 2010-2011 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 + +# You must chose the internal fixed point implementation or to +# use the system floating point. The latter is considerably +# smaller (by about 1kbyte on an x86 system): +# option FLOATING_ARITHMETIC on + +option FLOATING_ARITHMETIC off + +# 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 +option READ_16_TO_8 on diff --git a/contrib/pngminim/decoder/pngusr.h b/contrib/pngminim/decoder/pngusr.h new file mode 100644 index 0000000..ce85537 --- /dev/null +++ b/contrib/pngminim/decoder/pngusr.h @@ -0,0 +1,23 @@ +/* minrdpngconf.h: headers to make a minimal png-read-only library + * + * Copyright (c) 2007, 2010-2011 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 + * + * Derived from pngcrush.h, Copyright 1998-2007, Glenn Randers-Pehrson + */ + +#ifndef MINRDPNGCONF_H +#define MINRDPNGCONF_H + +/* To include pngusr.h set -DPNG_USER_CONFIG in CPPFLAGS */ + +/* 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 + +#endif /* MINRDPNGCONF_H */ -- cgit v1.1