1# makefile for libpng, MACOS X 2# Copyright (C) 2002 Glenn Randers-Pehrson 3# Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc. 4# Modified by Karin Kosina <kyrah@sim.no> 20011010: 5# build shared library (*.dylib) 6# For conditions of distribution and use, see copyright notice in png.h 7 8# where make install puts libpng.a and png.h 9prefix=/usr/local 10 11# Where the zlib library and include files are located 12#ZLIBLIB=/usr/local/lib 13#ZLIBINC=/usr/local/include 14ZLIBLIB=../zlib 15ZLIBINC=../zlib 16 17CC=cc 18 19PNGMAJ = 0 20PNGMIN = 1.2.4 21PNGVER = $(PNGMAJ).$(PNGMIN) 22 23CFLAGS=-fno-common -I$(ZLIBINC) -O # -g -DPNG_DEBUG=5 24LDFLAGS=-L. -L$(ZLIBLIB) -lpng -lz 25LDSHARED=cc -lz -dynamiclib -compatibility_version $(PNGVER) \ 26-current_version $(PNGVER) 27 28LIBNAME=libpng12 29SHAREDLIB_POSTFIX=dylib 30INCPATH=$(prefix)/include 31LIBPATH=$(prefix)/lib 32MANPATH=$(prefix)/man 33BINPATH=$(prefix)/bin 34 35# override DESTDIR= on the make install command line to easily support 36# installing into a temporary location. Example: 37# 38# make install DESTDIR=/tmp/build/libpng 39# 40# If you're going to install into a temporary location 41# via DESTDIR, $(DESTDIR)$(prefix) must already exist before 42# you execute make install. 43DESTDIR= 44 45DB=$(DESTDIR)$(BINPATH) 46DI=$(DESTDIR)$(INCPATH) 47DL=$(DESTDIR)$(LIBPATH) 48DM=$(DESTDIR)$(MANPATH) 49 50#RANLIB=echo 51RANLIB=ranlib 52 53OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \ 54 pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \ 55 pngwtran.o pngmem.o pngerror.o pngpread.o 56 57all: libpng.a pngtest shared libpng.pc libpng-config 58 59shared: $(LIBNAME).$(PNGVER).$(SHAREDLIB_POSTFIX) 60 61libpng.pc: 62 cat scripts/libpng.pc.in | sed -e s\!@PREFIX@!$(prefix)! | \ 63 sed -e s/-lm// > libpng.pc 64 65libpng-config: 66 ( cat scripts/libpng-config-head.in; \ 67 echo prefix=\"$(prefix)\"; \ 68 echo cppflags=\"-I$(INCPATH)/$(LIBNAME)\"; \ 69 echo cflags=\"\"; \ 70 echo ldflags=\"-L$(LIBPATH)\"; \ 71 echo libs=\"-lpng12 -lz\"; \ 72 cat scripts/libpng-config-body.in ) > libpng-config 73 chmod +x libpng-config 74 75libpng.a: $(OBJS) 76 ar rc $@ $(OBJS) 77 $(RANLIB) $@ 78 79$(LIBNAME).$(PNGVER).$(SHAREDLIB_POSTFIX): $(OBJS) 80 $(LDSHARED) -o $@ $(OBJS) 81 82pngtest: pngtest.o libpng.a 83 $(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS) 84 85test: pngtest 86 ./pngtest 87 88install-headers: png.h pngconf.h 89 -@if [ ! -d $(DI) ]; then mkdir $(DI); fi 90 -@if [ ! -d $(DI)/$(LIBNAME) ]; then mkdir $(DI)/$(LIBNAME); fi 91 cp png.h pngconf.h $(DI)/$(LIBNAME) 92 chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h 93 -@/bin/rm -f $(DI)/png.h $(DI)/pngconf.h 94 -@/bin/rm -f $(DI)/libpng 95 (cd $(DI); ln -f -s $(LIBNAME) libpng; ln -f -s $(LIBNAME)/* .) 96 97install-static: install-headers libpng.a 98 -@if [ ! -d $(DL) ]; then mkdir $(DL); fi 99 cp libpng.a $(DL)/$(LIBNAME).a 100 chmod 644 $(DL)/$(LIBNAME).a 101 -@/bin/rm -f $(DL)/libpng.a 102 (cd $(DL); ln -f -s $(LIBNAME).a libpng.a) 103 104install-shared: install-headers $(LIBNAME).$(PNGVER).$(SHAREDLIB_POSTFIX) libpng.pc 105 -@if [ ! -d $(DL) ]; then mkdir $(DL); fi 106 -@/bin/rm -f \ 107 $(DL)/$(LIBNAME).$(PNGMAJ)*.$(SHAREDLIB_POSTFIX) 108 -@/bin/rm -f $(DL)/$(LIBNAME).$(SHAREDLIB_POSTFIX) 109 -@/bin/rm -f libpng.$(SHARED_POSTFIX) 110 -@/bin/rm -f libpng.3.$(SHARED_POSTFIX) 111 -@/bin/rm -f libpng.3.*.$(SHARED_POSTFIX) 112 cp $(LIBNAME).$(PNGVER).$(SHAREDLIB_POSTFIX) $(DL) 113 chmod 755 $(DL)/$(LIBNAME).$(PNGVER).$(SHAREDLIB_POSTFIX) 114 (cd $(DL); \ 115 ln -f -s $(LIBNAME).$(PNGVER).$(SHARED_POSTFIX) \ 116 libpng.$(SHARED_POSTFIX); \ 117 ln -f -s $(LIBNAME).$(PNGVER).$(SHARED_POSTFIX) \ 118 libpng.3.$(SHARED_POSTFIX); \ 119 ln -f -s $(LIBNAME).$(PNGVER).$(SHARED_POSTFIX) \ 120 libpng.3.$(PNGMIN).$(SHARED_POSTFIX); \ 121 ln -f -s $(LIBNAME).$(PNGVER).$(SHAREDLIB_POSTFIX) \ 122 $(LIBNAME).$(PNGMAJ).$(SHAREDLIB_POSTFIX); \ 123 ln -f -s $(LIBNAME).$(PNGMAJ).$(SHAREDLIB_POSTFIX) \ 124 $(LIBNAME).$(SHAREDLIB_POSTFIX)) 125 -@if [ ! -d $(DL)/pkgconfig ]; then mkdir $(DL)/pkgconfig; fi 126 -@/bin/rm -f $(DL)/pkgconfig/$(LIBNAME).pc 127 -@/bin/rm -f $(DL)/pkgconfig/libpng.pc 128 cp libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc 129 chmod 644 $(DL)/pkgconfig/$(LIBNAME).pc 130 (cd $(DL)/pkgconfig; ln -f -s $(LIBNAME).pc libpng.pc) 131 132install-man: libpng.3 libpngpf.3 png.5 133 -@if [ ! -d $(DM) ]; then mkdir $(DM); fi 134 -@if [ ! -d $(DM)/man3 ]; then mkdir $(DM)/man3; fi 135 -@/bin/rm -f $(DM)/man3/libpng.3 136 -@/bin/rm -f $(DM)/man3/libpngpf.3 137 cp libpng.3 $(DM)/man3 138 cp libpngpf.3 $(DM)/man3 139 -@if [ ! -d $(DM)/man5 ]; then mkdir $(DM)/man5; fi 140 -@/bin/rm -f $(DM)/man5/png.5 141 cp png.5 $(DM)/man5 142 143install-config: libpng-config 144 -@if [ ! -d $(DB) ]; then mkdir $(DB); fi 145 -@/bin/rm -f $(DB)/libpng-config 146 -@/bin/rm -f $(DB)/$(LIBNAME)-config 147 cp libpng-config $(DB)/$(LIBNAME)-config 148 chmod 755 $(DB)/$(LIBNAME)-config 149 (cd $(DB); ln -sf $(LIBNAME)-config libpng-config) 150 151install: install-static install-shared install-man install-config 152 153# If you installed in $(DESTDIR), test-installed won't work until you 154# move the library to its final location. 155 156test-installed: 157 $(CC) $(CFLAGS) \ 158 `$(BINPATH)/libpng12-config --cppflags --cflags` pngtest.c \ 159 -L$(ZLIBLIB) \ 160 -o pngtesti `$(BINPATH)/libpng12-config --ldflags --libs` 161 ./pngtesti pngtest.png 162 163clean: 164 rm -f *.o libpng.a pngtest pngout.png libpng.pc libpng-config \ 165 $(LIBNAME).$(PNGVER).$(SHAREDLIB_POSTFIX) \ 166 $(LIBNAME).$(SHAREDLIB_POSTFIX) 167 168DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO 169writelock: 170 chmod a-w *.[ch35] $(DOCS) scripts/* 171 172# DO NOT DELETE THIS LINE -- make depend depends on it. 173 174png.o: png.h pngconf.h 175pngerror.o: png.h pngconf.h 176pngrio.o: png.h pngconf.h 177pngwio.o: png.h pngconf.h 178pngmem.o: png.h pngconf.h 179pngset.o: png.h pngconf.h 180pngget.o: png.h pngconf.h 181pngread.o: png.h pngconf.h 182pngrtran.o: png.h pngconf.h 183pngrutil.o: png.h pngconf.h 184pngtest.o: png.h pngconf.h 185pngtrans.o: png.h pngconf.h 186pngwrite.o: png.h pngconf.h 187pngwtran.o: png.h pngconf.h 188pngwutil.o: png.h pngconf.h 189pngpread.o: png.h pngconf.h 190 191