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