1# makefile for libpng.a and libpng16.so on Linux ELF with gcc 2# Copyright (C) 1998, 1999, 2002, 2006, 2008, 2010-2014 Greg Roelofs 3# and Glenn Randers-Pehrson 4# Copyright (C) 1996, 1997 Andreas Dilger 5# 6# This code is released under the libpng license. 7# For conditions of distribution and use, see the disclaimer 8# and license in png.h 9 10# Modified for Debian by Junichi Uekawa and Josselin Mouette 11# Major modifications are: 12# * link libpng explicitly with libz and libm 13# * $(OLDSO).16 is a symlink rather than a different library 14# * versioned symbols 15 16# Library name: 17LIBNAME = libpng16 18PNGMAJ = 16 19 20# Shared library names: 21LIBSO=$(LIBNAME).so 22LIBSOMAJ=$(LIBNAME).so.$(PNGMAJ) 23LIBSOREL=$(LIBSOMAJ).$(RELEASE) 24OLDSO=libpng.so 25OLDSOMAJ=libpng.so.16 26 27# Utilities: 28AR_RC=ar rc 29CC=gcc 30MKDIR_P=mkdir -p 31LN_SF=ln -sf 32RANLIB=ranlib 33RM_F=/bin/rm -f 34 35# where "make install" puts libpng16.a, libpng16.so*, 36# libpng16/png.h, libpng16/pngconf.h, and libpng16/pnglibconf.h 37# Prefix must be a full pathname. 38prefix=/usr/local 39exec_prefix=$(prefix) 40 41# Where the zlib library and include files are located. 42ZLIBLIB=/usr/local/lib 43ZLIBINC=/usr/local/include 44# ZLIBLIB=../zlib 45# ZLIBINC=../zlib 46 47ALIGN= 48# for i386: 49#ALIGN=-malign-loops=2 -malign-functions=2 50 51WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow \ 52 -Wmissing-declarations -Wtraditional -Wcast-align \ 53 -Wstrict-prototypes -Wmissing-prototypes #-Wconversion 54 55# for pgcc version 2.95.1, -O3 is buggy; don't use it. 56 57CPPFLAGS=-D_REENTRANT # -DPNG_DEBUG=5 58CFLAGS=-W -Wall -O2 $(ALIGN) # $(WARNMORE) -g 59 60LDFLAGS=-L. -lpng16 61LDFLAGS_A=libpng.a -lz -lm 62LIBADDFLAGS=-lz -lm 63 64 65INCPATH=$(prefix)/include 66LIBPATH=$(exec_prefix)/lib 67MANPATH=$(prefix)/man 68BINPATH=$(exec_prefix)/bin 69 70# override DESTDIR= on the make install command line to easily support 71# installing into a temporary location. Example: 72# 73# make install DESTDIR=/tmp/build/libpng 74# 75# If you're going to install into a temporary location 76# via DESTDIR, $(DESTDIR)$(prefix) must already exist before 77# you execute make install. 78DESTDIR= 79 80DB=$(DESTDIR)$(BINPATH) 81DI=$(DESTDIR)$(INCPATH) 82DL=$(DESTDIR)$(LIBPATH) 83DM=$(DESTDIR)$(MANPATH) 84 85OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \ 86 pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \ 87 pngwtran.o pngmem.o pngerror.o pngpread.o 88 89OBJSDLL = $(OBJS:.o=.pic.o) 90 91.SUFFIXES: .c .o .pic.o 92 93.c.o: 94 $(CC) -c $(CPPFLAGS) $(CFLAGS) -o $@ $< 95 96.c.pic.o: 97 $(CC) -c $(CFLAGS) -fPIC -o $@ $*.c 98 99all: libpng.a $(LIBSO) pngtest pngtest-static libpng.pc libpng-config 100 101# see scripts/pnglibconf.mak for more options 102pnglibconf.h: scripts/pnglibconf.h.prebuilt 103 cp scripts/pnglibconf.h.prebuilt $@ 104 105libpng.a: $(OBJS) 106 $(AR_RC) $@ $(OBJS) 107 $(RANLIB) $@ 108 109libpng.pc: 110 cat scripts/libpng.pc.in | sed -e s!@prefix@!$(prefix)! \ 111 -e s!@exec_prefix@!$(exec_prefix)! \ 112 -e s!@libdir@!$(LIBPATH)! \ 113 -e s!@includedir@!$(INCPATH)! \ 114 -e s!-lpng16!-lpng16\ -lz\ -lm! > libpng.pc 115 116libpng.syms: png.h pngconf.h pnglibconf.h 117 $(CC) $(CPPFLAGS) $(CFLAGS) -E -DPNG_BUILDSYMS -DPNG_INTERNAL png.h |\ 118 awk -F '[\t [\\]();]' -v PNGMAJ=$(PNGMAJ) 'BEGIN{printf("PNG16_%s {global:\n",PNGMAJ)}\ 119 { for (i=1;i+2<=NF;++i)\ 120 if ($$(i)=="PNG_FUNCTION_EXPORT" && $$(i+2)=="END")\ 121 print $$(i+1) ";";\ 122 for (i=1;i+1<=NF;++i)\ 123 if ($$(i)=="PNG_DATA_EXPORT")\ 124 print $$(i+1) ";";}\ 125 END{print "local: *; };"}' >$@.new 126 $(RM_F) $@ 127 mv $@.new $@ 128 129libpng-config: 130 ( cat scripts/libpng-config-head.in; \ 131 echo prefix=\"$(prefix)\"; \ 132 echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \ 133 echo L_opts=\"\"; \ 134 echo R_opts=\"\"; \ 135 echo libs=\"-lpng16\"; \ 136 echo all_libs=\"-lpng16 $(LIBADDFLAGS)\"; \ 137 cat scripts/libpng-config-body.in ) > libpng-config 138 chmod +x libpng-config 139 140$(LIBSO): $(LIBSOMAJ) 141 $(LN_SF) $(LIBSOMAJ) $(LIBSO) 142 143$(LIBSOMAJ): $(OBJSDLL) libpng.syms 144 $(CC) -shared -Wl,-soname,$(LIBSOMAJ) \ 145 -Wl,-version-script,libpng.syms \ 146 -o $(LIBSOMAJ) \ 147 $(OBJSDLL) 148 149pngtest: pngtest.o $(LIBSO) 150 $(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS) 151 152pngtest-static: pngtest.o libpng.a 153 $(CC) -o pngtest-static $(CFLAGS) pngtest.o $(LDFLAGS_A) 154 155test: pngtest pngtest-static 156 @echo "" 157 @echo " Running pngtest dynamically linked with $(LIBSO):" 158 @echo "" 159 LD_LIBRARY_PATH=".:${LD_LIBRARY_PATH}" ./pngtest 160 @echo "" 161 @echo " Running pngtest statically linked with libpng.a:" 162 @echo "" 163 ./pngtest-static 164 165install-headers: png.h pngconf.h pnglibconf.h 166 -@if [ ! -d $(DI) ]; then $(MKDIR_P) $(DI); fi 167 -@if [ ! -d $(DI)/$(LIBNAME) ]; then $(MKDIR_P) $(DI)/$(LIBNAME); fi 168 cp png.h pngconf.h pnglibconf.h $(DI)/$(LIBNAME) 169 chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h $(DI)/$(LIBNAME)/pnglibconf.h 170 -@$(RM_F) $(DI)/png.h $(DI)/pngconf.h $(DI)/pnglibconf.h 171 -@$(RM_F) $(DI)/libpng 172 (cd $(DI); $(LN_SF) $(LIBNAME) libpng; $(LN_SF) $(LIBNAME)/* .) 173 174install-static: install-headers libpng.a 175 -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi 176 cp libpng.a $(DL)/$(LIBNAME).a 177 chmod 644 $(DL)/$(LIBNAME).a 178 -@$(RM_F) $(DL)/libpng.a 179 (cd $(DL); $(LN_SF) $(LIBNAME).a libpng.a) 180 181install-shared: install-headers $(LIBSOMAJ) libpng.pc 182 -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi 183 -@$(RM_F) $(DL)/$(LIBSO) 184 -@$(RM_F) $(DL)/$(LIBSOREL) 185 -@$(RM_F) $(DL)/$(OLDSO) 186 cp $(LIBSOMAJ) $(DL)/$(LIBSOREL) 187 chmod 755 $(DL)/$(LIBSOREL) 188 (cd $(DL); \ 189 $(LN_SF) $(LIBSOREL) $(LIBSO); \ 190 $(LN_SF) $(LIBSO) $(OLDSO)) 191 -@if [ ! -d $(DL)/pkgconfig ]; then $(MKDIR_P) $(DL)/pkgconfig; fi 192 -@$(RM_F) $(DL)/pkgconfig/$(LIBNAME).pc 193 -@$(RM_F) $(DL)/pkgconfig/libpng.pc 194 cp libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc 195 chmod 644 $(DL)/pkgconfig/$(LIBNAME).pc 196 (cd $(DL)/pkgconfig; $(LN_SF) $(LIBNAME).pc libpng.pc) 197 198install-man: libpng.3 libpngpf.3 png.5 199 -@if [ ! -d $(DM) ]; then $(MKDIR_P) $(DM); fi 200 -@if [ ! -d $(DM)/man3 ]; then $(MKDIR_P) $(DM)/man3; fi 201 -@$(RM_F) $(DM)/man3/libpng.3 202 -@$(RM_F) $(DM)/man3/libpngpf.3 203 cp libpng.3 $(DM)/man3 204 cp libpngpf.3 $(DM)/man3 205 -@if [ ! -d $(DM)/man5 ]; then $(MKDIR_P) $(DM)/man5; fi 206 -@$(RM_F) $(DM)/man5/png.5 207 cp png.5 $(DM)/man5 208 209install-config: libpng-config 210 -@if [ ! -d $(DB) ]; then $(MKDIR_P) $(DB); fi 211 -@$(RM_F) $(DB)/libpng-config 212 -@$(RM_F) $(DB)/$(LIBNAME)-config 213 cp libpng-config $(DB)/$(LIBNAME)-config 214 chmod 755 $(DB)/$(LIBNAME)-config 215 (cd $(DB); $(LN_SF) $(LIBNAME)-config libpng-config) 216 217install: install-static install-shared install-man install-config 218 219# If you installed in $(DESTDIR), test-installed won't work until you 220# move the library to its final location. Use test-dd to test it 221# before then. 222 223test-dd: 224 echo 225 echo Testing installed dynamic shared library in $(DL). 226 $(CC) -I$(DI) $(CPPFLAGS) \ 227 `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \ 228 -L$(DL) -L$(ZLIBLIB) -Wl, -rpath,$(DL) -Wl,-rpath,$(ZLIBLIB) \ 229 -o pngtestd `$(BINPATH)/$(LIBNAME)-config --ldflags` 230 ./pngtestd pngtest.png 231 232test-installed: 233 $(CC) $(CPPFLAGS) \ 234 `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \ 235 -L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) \ 236 -o pngtesti `$(BINPATH)/$(LIBNAME)-config --ldflags` 237 ./pngtesti pngtest.png 238 239clean: 240 $(RM_F) *.o libpng.a libpng.syms pngtest pngout.png libpng-config \ 241 $(LIBSO) $(LIBSOMAJ)* pngtest-static pngtesti \ 242 libpng.pc pnglibconf.h 243 244DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO 245writelock: 246 chmod a-w *.[ch35] $(DOCS) scripts/* 247 248# DO NOT DELETE THIS LINE -- make depend depends on it. 249 250png.o png.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h 251pngerror.o pngerror.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h 252pngrio.o pngrio.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h 253pngwio.o pngwio.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h 254pngmem.o pngmem.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h 255pngset.o pngset.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h 256pngget.o pngget.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h 257pngread.o pngread.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h 258pngrtran.o pngrtran.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h 259pngrutil.o pngrutil.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h 260pngtrans.o pngtrans.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h 261pngwrite.o pngwrite.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h 262pngwtran.o pngwtran.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h 263pngwutil.o pngwutil.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h 264pngpread.o pngpread.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h 265 266pngtest.o: png.h pngconf.h pnglibconf.h 267