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