fukasawa e60969
# Makefile for PngMinus (pnm2pngm)
fukasawa e60969
# Linux / Unix
fukasawa e60969
fukasawa e60969
#CC=cc
fukasawa e60969
CC=gcc
fukasawa e60969
LD=$(CC)
fukasawa e60969
fukasawa e60969
# If awk fails try
fukasawa e60969
# make AWK=nawk
fukasawa e60969
fukasawa e60969
# If cpp fails try
fukasawa e60969
# make CPP=/lib/cpp
fukasawa e60969
fukasawa e60969
RM=rm -f
fukasawa e60969
COPY=cp
fukasawa e60969
fukasawa e60969
CPPFLAGS=-I. -DPNG_USER_CONFIG -DNO_GZCOMPRESS -DZ_SOLO -DNO_GZIP
fukasawa e60969
CFLAGS=-O1 -Wall
fukasawa e60969
fukasawa e60969
C=.c
fukasawa e60969
O=.o
fukasawa e60969
L=.a
fukasawa e60969
E=
fukasawa e60969
fukasawa e60969
# Where to find the source code:
fukasawa e60969
PNGSRC =../../..
fukasawa e60969
ZLIBSRC=$(PNGSRC)/../zlib
fukasawa e60969
PROGSRC=$(PNGSRC)/contrib/pngminus
fukasawa e60969
fukasawa e60969
# Zlib
fukasawa e60969
ZSRCS  = adler32$(C) compress$(C) crc32$(C) deflate$(C) \
fukasawa e60969
	 trees$(C) zutil$(C)
fukasawa e60969
fukasawa e60969
# Standard headers
fukasawa e60969
#ZH     = zlib.h crc32.h deflate.h trees.h zutil.h
fukasawa e60969
ZH     = zlib.h crc32.h deflate.h trees.h zutil.h
fukasawa e60969
fukasawa e60969
# Machine generated headers
fukasawa e60969
ZCONF  = zconf.h
fukasawa e60969
fukasawa e60969
# Headers callers use
fukasawa e60969
ZINC   = zlib.h $(ZCONF)
fukasawa e60969
fukasawa e60969
# Headers the Zlib source uses
fukasawa e60969
ZHDRS  = $(ZH) $(ZCONF)
fukasawa e60969
fukasawa e60969
# compress is not required; it is needed to link the zlib
fukasawa e60969
# code because deflate defines an unused API function deflateBound
fukasawa e60969
# which itself calls compressBound from compress.
fukasawa e60969
ZOBJS  = adler32$(O) compress$(O) crc32$(O) deflate$(O) \
fukasawa e60969
	 trees$(O) zutil$(O)
fukasawa e60969
fukasawa e60969
# libpng
fukasawa e60969
PNGSRCS=png$(C) pngerror$(C) pngget$(C) pngmem$(C) \
fukasawa e60969
	pngset$(C) pngtrans$(C) pngwio$(C) pngwrite$(C) \
fukasawa e60969
	pngwtran$(C) pngwutil$(C)
fukasawa e60969
fukasawa e60969
# Standard headers
fukasawa e60969
PNGH   =png.h pngconf.h pngdebug.h pnginfo.h pngpriv.h pngstruct.h
fukasawa e60969
fukasawa e60969
# Machine generated headers
fukasawa e60969
PNGCONF=pnglibconf.h
fukasawa e60969
fukasawa e60969
# Headers callers use
fukasawa e60969
PNGINC= png.h pngconf.h pngusr.h $(PNGCONF)
fukasawa e60969
fukasawa e60969
# Headers the PNG library uses
fukasawa e60969
PNGHDRS=$(PNGH) $(PNGCONF) pngusr.h
fukasawa e60969
fukasawa e60969
PNGOBJS=png$(O) pngerror$(O) pngget$(O) pngmem$(O) \
fukasawa e60969
	pngset$(O) pngtrans$(O) pngwio$(O) pngwrite$(O) \
fukasawa e60969
	pngwtran$(O) pngwutil$(O)
fukasawa e60969
fukasawa e60969
PROGSRCS= pnm2pngm$(C)
fukasawa e60969
PROGHDRS=
fukasawa e60969
PROGDOCS=
fukasawa e60969
PROGOBJS= pnm2pngm$(O)
fukasawa e60969
fukasawa e60969
OBJS    = $(PROGOBJS) $(PNGOBJS) $(ZOBJS)
fukasawa e60969
fukasawa e60969
# implicit make rules -------------------------------------------------------
fukasawa e60969
fukasawa e60969
.c$(O):
fukasawa e60969
	$(CC) -c $(CPPFLAGS) $(CFLAGS) $<
fukasawa e60969
fukasawa e60969
# dependencies
fukasawa e60969
fukasawa e60969
all: pnm2pngm$(E)
fukasawa e60969
fukasawa e60969
pnm2pngm$(E): $(OBJS)
fukasawa e60969
	$(LD) -o pnm2pngm$(E) $(OBJS)
fukasawa e60969
fukasawa e60969
# The DFA_XTRA setting turns all libpng options off then
fukasawa e60969
# turns on those required for this minimal build.
fukasawa e60969
# The CPP_FLAGS setting causes pngusr.h to be included in
fukasawa e60969
# both the build of pnglibconf.h and, subsequently, when
fukasawa e60969
# building libpng itself.
fukasawa e60969
$(PNGCONF): $(PNGSRC)/scripts/pnglibconf.mak $(ZH)\
fukasawa e60969
	$(PNGSRC)/scripts/pnglibconf.dfa \
fukasawa e60969
	$(PNGSRC)/scripts/options.awk pngusr.h pngusr.dfa
fukasawa e60969
	$(RM) pnglibconf.h pnglibconf.dfn
fukasawa e60969
	$(MAKE) -f $(PNGSRC)/scripts/pnglibconf.mak $(MAKEFLAGS)\
fukasawa e60969
	    srcdir=$(PNGSRC) CPPFLAGS="-DPNG_USER_CONFIG -I."\
fukasawa e60969
	    DFA_XTRA="pngusr.dfa" $@
fukasawa e60969
fukasawa e60969
clean:
fukasawa e60969
	$(MAKE) -f $(PNGSRC)/scripts/pnglibconf.mak $(MAKEFLAGS)\
fukasawa e60969
	    srcdir=$(PNGSRC) clean
fukasawa e60969
	$(RM) pnm2pngm$(O)
fukasawa e60969
	$(RM) pnm2pngm$(E)
fukasawa e60969
	$(RM) $(OBJS)
fukasawa e60969
fukasawa e60969
# distclean also removes the copied source and headers
fukasawa e60969
distclean: clean
fukasawa e60969
	$(RM) -r scripts # historical reasons
fukasawa e60969
	$(RM) $(PNGSRCS) $(PNGH)
fukasawa e60969
	$(RM) $(ZSRCS) $(ZH) $(ZCONF)
fukasawa e60969
	$(RM) $(PROGSRCS) $(PROGHDRS) $(PROGDOCS)
fukasawa e60969
fukasawa e60969
# Header file dependencies:
fukasawa e60969
$(PROGOBJS): $(PROGHDRS) $(PNGINC) $(ZINC)
fukasawa e60969
$(PNGOBJS): $(PNGHDRS) $(ZINC)
fukasawa e60969
$(ZOBJS): $(ZHDRS)
fukasawa e60969
fukasawa e60969
# Gather the source code from the respective directories
fukasawa e60969
$(PNGSRCS) $(PNGH): $(PNGSRC)/$@
fukasawa e60969
	$(RM) $@
fukasawa e60969
	$(COPY) $(PNGSRC)/$@ $@
fukasawa e60969
fukasawa e60969
# No dependency on the ZLIBSRC target so that it only needs
fukasawa e60969
# to be specified once.
fukasawa e60969
$(ZSRCS) $(ZH):
fukasawa e60969
	$(RM) $@
fukasawa e60969
	$(COPY) $(ZLIBSRC)/$@ $@
fukasawa e60969
fukasawa e60969
# The unconfigured zconf.h varies in name according to the
fukasawa e60969
# zlib release
fukasawa e60969
$(ZCONF):
fukasawa e60969
	$(RM) $@
fukasawa e60969
	@for f in zconf.h.in zconf.in.h zconf.h; do\
fukasawa e60969
	    test -r $(ZLIBSRC)/$$f &&\
fukasawa e60969
	    echo $(COPY) $(ZLIBSRC)/$$f $@ &&\
fukasawa e60969
	    $(COPY) $(ZLIBSRC)/$$f $@ && exit 0;\
fukasawa e60969
	done; echo copy: $(ZLIBSRC)/zconf.h not found; exit 1
fukasawa e60969
fukasawa e60969
pnm2pngm.c: $(PROGSRC)/pnm2png.c
fukasawa e60969
	$(RM) $@
fukasawa e60969
	$(COPY) $(PROGSRC)/pnm2png.c $@
fukasawa e60969
fukasawa e60969
# End of makefile for pnm2pngm