1# makefile for libpng 2# Copyright (C) 2002, 2006, 2014 Glenn Randers-Pehrson 3# Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc. 4# 5# This code is released under the libpng license. 6# For conditions of distribution and use, see the disclaimer 7# and license in png.h 8 9# where make install puts libpng.a and png.h 10prefix=/usr/local 11INCPATH=$(prefix)/include 12LIBPATH=$(prefix)/lib 13 14# override DESTDIR= on the make install command line to easily support 15# installing into a temporary location. Example: 16# 17# make install DESTDIR=/tmp/build/libpng 18# 19# If you're going to install into a temporary location 20# via DESTDIR, $(DESTDIR)$(prefix) must already exist before 21# you execute make install. 22DESTDIR= 23 24# Where the zlib library and include files are located 25#ZLIBLIB=/usr/local/lib 26#ZLIBINC=/usr/local/include 27ZLIBLIB=../zlib 28ZLIBINC=../zlib 29 30CC = cc 31AR_RC = ar rc 32MKDIR_P = mkdir 33LN_SF = ln -sf 34RANLIB = ranlib 35CP = cp 36RM_F = rm -f 37AWK = awk 38SED = sed 39CPP = $(CC) -E 40ECHO = echo 41 42DFNFLAGS = # DFNFLAGS contains -D options to use in the libpng build 43DFA_EXTRA = # extra files that can be used to control configuration 44CPPFLAGS = -I$(ZLIBINC) # -DPNG_DEBUG=5 45CFLAGS = -O # -g 46LDFLAGS = -L. -L$(ZLIBLIB) -lpng -lz -lm 47 48# Pre-built configuration 49# See scripts/pnglibconf.mak for more options 50PNGLIBCONF_H_PREBUILT = scripts/pnglibconf.h.prebuilt 51 52OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \ 53 pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \ 54 pngwtran.o pngmem.o pngerror.o pngpread.o 55 56.c.o: 57 $(CC) -c $(CPPFLAGS) $(CFLAGS) -o $@ $< 58 59all: libpng.a pngtest 60 61# The standard pnglibconf.h exists as scripts/pnglibconf.h.prebuilt, 62# copy this if the following doesn't work. 63pnglibconf.h: pnglibconf.dfn 64 $(RM_F) $@ pnglibconf.c pnglibconf.out pnglibconf.tmp 65 $(ECHO) '#include "pnglibconf.dfn"' >pnglibconf.c 66 $(ECHO) "If '$(CC) -E' crashes try /lib/cpp (e.g. CPP='/lib/cpp')" >&2 67 $(CPP) $(DFNFLAGS) pnglibconf.c >pnglibconf.out 68 $(AWK) -f "scripts/dfn.awk" out="pnglibconf.tmp" pnglibconf.out 1>&2 69 mv pnglibconf.tmp $@ 70 71pnglibconf.dfn: scripts/pnglibconf.dfa scripts/options.awk pngconf.h pngusr.dfa $(DFA_XTRA) 72 $(RM_F) $@ pnglibconf.pre pnglibconf.tmp 73 $(ECHO) "Calling $(AWK) from scripts/pnglibconf.mak" >&2 74 $(ECHO) "If 'awk' crashes try a better awk (e.g. AWK='nawk')" >&2 75 $(AWK) -f scripts/options.awk out="pnglibconf.pre"\ 76 version=search pngconf.h scripts/pnglibconf.dfa\ 77 pngusr.dfa $(DFA_XTRA) 1>&2 78 $(AWK) -f scripts/options.awk out="pnglibconf.tmp" pnglibconf.pre 1>&2 79 mv pnglibconf.tmp $@ 80 81libpng.a: $(OBJS) 82 $(AR_RC) $@ $(OBJS) 83 $(RANLIB) $@ 84 85pngtest: pngtest.o libpng.a 86 $(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS) 87 88test: pngtest 89 ./pngtest 90 91install: libpng.a pnglibconf.h 92 -@$(MKDIR_P) $(DESTDIR)$(INCPATH) 93 -@$(MKDIR_P) $(DESTDIR)$(INCPATH)/libpng 94 -@$(MKDIR_P) $(DESTDIR)$(LIBPATH) 95 -@$(RM_F) $(DESTDIR)$(INCPATH)/png.h 96 -@$(RM_F) $(DESTDIR)$(INCPATH)/pngconf.h 97 -@$(RM_F) $(DESTDIR)$(INCPATH)/pnglibconf.h 98 cp png.h $(DESTDIR)$(INCPATH)/libpng 99 cp pngconf.h $(DESTDIR)$(INCPATH)/libpng 100 cp pnglibconf.h $(DESTDIR)$(INCPATH)/libpng 101 chmod 644 $(DESTDIR)$(INCPATH)/libpng/png.h 102 chmod 644 $(DESTDIR)$(INCPATH)/libpng/pngconf.h 103 chmod 644 $(DESTDIR)$(INCPATH)/libpng/pnglibconf.h 104 (cd $(DESTDIR)$(INCPATH); ln -f -s libpng/* .) 105 cp libpng.a $(DESTDIR)$(LIBPATH) 106 chmod 644 $(DESTDIR)$(LIBPATH)/libpng.a 107 108clean: 109 $(RM_F) *.o libpng.a pngtest pngout.png pnglibconf.h pnglibconf.c \ 110 pnglibconf.out 111 112DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO 113writelock: 114 chmod a-w *.[ch35] $(DOCS) scripts/* 115 116# DO NOT DELETE THIS LINE -- make depend depends on it. 117 118png.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h 119pngerror.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h 120pngrio.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h 121pngwio.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h 122pngmem.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h 123pngset.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h 124pngget.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h 125pngread.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h 126pngrtran.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h 127pngrutil.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h 128pngtrans.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h 129pngwrite.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h 130pngwtran.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h 131pngwutil.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h 132pngpread.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h 133 134pngtest.o: png.h pngconf.h pnglibconf.h 135