The Android Open Source Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 1 | # makefile for libpng on Darwin / Mac OS X |
The Android Open Source Project | 4215dd1 | 2009-03-09 11:52:12 -0700 | [diff] [blame] | 2 | # Copyright (C) 2002, 2004, 2006, 2008 Glenn Randers-Pehrson |
The Android Open Source Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 3 | # Copyright (C) 2001 Christoph Pfisterer |
| 4 | # derived from makefile.linux: |
| 5 | # Copyright (C) 1998, 1999 Greg Roelofs |
| 6 | # Copyright (C) 1996, 1997 Andreas Dilger |
Patrick Scott | 5f6bd84 | 2010-06-28 16:55:16 -0400 | [diff] [blame] | 7 | # |
Patrick Scott | a0bb96c | 2009-07-22 11:50:02 -0400 | [diff] [blame] | 8 | # This code is released under the libpng license. |
| 9 | # For conditions of distribution and use, see the disclaimer |
| 10 | # and license in png.h |
The Android Open Source Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 11 | |
| 12 | # where "make install" puts libpng.a, libpng12.dylib, png.h and pngconf.h |
| 13 | prefix=/usr/local |
| 14 | exec_prefix=$(prefix) |
| 15 | |
| 16 | # Where the zlib library and include files are located |
| 17 | #ZLIBLIB=/usr/local/lib |
| 18 | #ZLIBINC=/usr/local/include |
| 19 | ZLIBLIB=../zlib |
| 20 | ZLIBINC=../zlib |
| 21 | |
| 22 | # Library name: |
| 23 | LIBNAME = libpng12 |
The Android Open Source Project | 4215dd1 | 2009-03-09 11:52:12 -0700 | [diff] [blame] | 24 | PNGMAJ = 12 |
Eric Vannier | 66dce0d | 2011-07-20 17:03:29 -0700 | [diff] [blame] | 25 | PNGMIN = 1.2.46 |
The Android Open Source Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 26 | PNGVER = $(PNGMAJ).$(PNGMIN) |
| 27 | |
| 28 | # Shared library names: |
| 29 | LIBSO=$(LIBNAME).dylib |
| 30 | LIBSOMAJ=$(LIBNAME).$(PNGMAJ).dylib |
| 31 | LIBSOVER=$(LIBNAME).$(PNGVER).dylib |
| 32 | OLDSO=libpng.dylib |
| 33 | OLDSOMAJ=libpng.3.dylib |
| 34 | OLDSOVER=libpng.3.$(PNGMIN).dylib |
| 35 | |
| 36 | # Utilities: |
| 37 | CC=cc |
| 38 | AR_RC=ar rc |
| 39 | MKDIR_P=mkdir -p |
| 40 | LN_SF=ln -sf |
| 41 | RANLIB=ranlib |
| 42 | RM_F=/bin/rm -f |
| 43 | |
The Android Open Source Project | 4215dd1 | 2009-03-09 11:52:12 -0700 | [diff] [blame] | 44 | # CFLAGS=-I$(ZLIBINC) -W -Wall -O3 -funroll-loops -DPNG_NO_MMX_CODE |
| 45 | CFLAGS=-I$(ZLIBINC) -W -Wall -O -funroll-loops |
The Android Open Source Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 46 | LDFLAGS=-L. -L$(ZLIBLIB) -lpng12 -lz |
| 47 | |
| 48 | INCPATH=$(prefix)/include |
| 49 | LIBPATH=$(exec_prefix)/lib |
| 50 | MANPATH=$(prefix)/man |
| 51 | BINPATH=$(exec_prefix)/bin |
| 52 | |
| 53 | # override DESTDIR= on the make install command line to easily support |
| 54 | # installing into a temporary location. Example: |
| 55 | # |
| 56 | # make install DESTDIR=/tmp/build/libpng |
| 57 | # |
| 58 | # If you're going to install into a temporary location |
| 59 | # via DESTDIR, $(DESTDIR)$(prefix) must already exist before |
| 60 | # you execute make install. |
| 61 | DESTDIR= |
| 62 | |
| 63 | DB=$(DESTDIR)$(BINPATH) |
| 64 | DI=$(DESTDIR)$(INCPATH) |
| 65 | DL=$(DESTDIR)$(LIBPATH) |
| 66 | DM=$(DESTDIR)$(MANPATH) |
| 67 | |
| 68 | OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \ |
| 69 | pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \ |
| 70 | pngwtran.o pngmem.o pngerror.o pngpread.o |
| 71 | |
| 72 | OBJSDLL = $(OBJS:.o=.pic.o) |
| 73 | |
| 74 | .SUFFIXES: .c .o .pic.o |
| 75 | |
| 76 | .c.pic.o: |
| 77 | $(CC) -c $(CFLAGS) -fno-common -o $@ $*.c |
| 78 | |
| 79 | all: libpng.a $(LIBSO) pngtest libpng.pc libpng-config |
| 80 | |
| 81 | libpng.a: $(OBJS) |
| 82 | $(AR_RC) $@ $(OBJS) |
| 83 | $(RANLIB) $@ |
| 84 | |
| 85 | libpng.pc: |
| 86 | cat scripts/libpng.pc.in | sed -e s!@prefix@!$(prefix)! \ |
| 87 | -e s!@exec_prefix@!$(exec_prefix)! \ |
| 88 | -e s!@libdir@!$(LIBPATH)! \ |
| 89 | -e s!@includedir@!$(INCPATH)! \ |
| 90 | -e s!-lpng12!-lpng12\ -lz! > libpng.pc |
| 91 | |
| 92 | libpng-config: |
| 93 | ( cat scripts/libpng-config-head.in; \ |
| 94 | echo prefix=\"$(prefix)\"; \ |
| 95 | echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \ |
| 96 | echo L_opts=\"-L$(LIBPATH)\"; \ |
| 97 | echo libs=\"-lpng12 -lz\"; \ |
| 98 | cat scripts/libpng-config-body.in ) > libpng-config |
| 99 | chmod +x libpng-config |
| 100 | |
| 101 | $(LIBSO): $(LIBSOMAJ) |
| 102 | $(LN_SF) $(LIBSOMAJ) $(LIBSO) |
| 103 | |
| 104 | $(LIBSOMAJ): $(LIBSOVER) |
| 105 | $(LN_SF) $(LIBSOVER) $(LIBSOMAJ) |
| 106 | |
| 107 | $(LIBSOVER): $(OBJSDLL) |
| 108 | $(CC) -dynamiclib \ |
| 109 | -install_name $(LIBPATH)/$(LIBSOMAJ) \ |
The Android Open Source Project | 4215dd1 | 2009-03-09 11:52:12 -0700 | [diff] [blame] | 110 | -current_version 0 -compatibility_version 0 \ |
The Android Open Source Project | 893912b | 2009-03-03 19:30:05 -0800 | [diff] [blame] | 111 | -o $(LIBSOVER) \ |
| 112 | $(OBJSDLL) -L$(ZLIBLIB) -lz |
| 113 | |
| 114 | $(OLDSOVER): $(OBJSDLL) |
| 115 | $(CC) -dynamiclib \ |
| 116 | -install_name $(LIBPATH)/$(OLDSOMAJ) \ |
| 117 | -current_version 3 -compatibility_version 3 \ |
| 118 | -o $(OLDSOVER) \ |
| 119 | $(OBJSDLL) -L$(ZLIBLIB) -lz |
| 120 | |
| 121 | pngtest: pngtest.o $(LIBSO) |
| 122 | $(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS) |
| 123 | |
| 124 | test: pngtest |
| 125 | ./pngtest |
| 126 | |
| 127 | install-headers: png.h pngconf.h |
| 128 | -@if [ ! -d $(DI) ]; then $(MKDIR_P) $(DI); fi |
| 129 | -@if [ ! -d $(DI)/$(LIBNAME) ]; then $(MKDIR_P) $(DI)/$(LIBNAME); fi |
| 130 | cp png.h pngconf.h $(DI)/$(LIBNAME) |
| 131 | chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h |
| 132 | -@$(RM_F) $(DI)/png.h $(DI)/pngconf.h |
| 133 | -@$(RM_F) $(DI)/libpng |
| 134 | (cd $(DI); $(LN_SF) $(LIBNAME) libpng; $(LN_SF) $(LIBNAME)/* .) |
| 135 | |
| 136 | install-static: install-headers libpng.a |
| 137 | -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi |
| 138 | cp libpng.a $(DL)/$(LIBNAME).a |
| 139 | chmod 644 $(DL)/$(LIBNAME).a |
| 140 | $(RANLIB) $(DL)/$(LIBNAME).a |
| 141 | -@$(RM_F) $(DL)/libpng.a |
| 142 | (cd $(DL); $(LN_SF) $(LIBNAME).a libpng.a) |
| 143 | |
| 144 | install-shared: install-headers $(LIBSO) libpng.pc \ |
| 145 | $(OLDSOVER) |
| 146 | -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi |
| 147 | -@$(RM_F) $(DL)/$(LIBNAME).$(PNGVER)*.dylib |
| 148 | -@$(RM_F) $(DL)/$(LIBNAME).$(PNGMAJ)*.dylib |
| 149 | -@$(RM_F) $(DL)/$(LIBSO) |
| 150 | -@$(RM_F) $(DL)/$(OLDSO) |
| 151 | -@$(RM_F) $(DL)/$(OLDSOMAJ) |
| 152 | -@$(RM_F) $(DL)/libpng.3.$(PNGMIN)*.dylib |
| 153 | cp $(LIBSOVER) $(DL) |
| 154 | cp $(OLDSOVER) $(DL) |
| 155 | chmod 755 $(DL)/$(LIBSOVER) |
| 156 | chmod 755 $(DL)/$(OLDSOVER) |
| 157 | (cd $(DL); \ |
| 158 | $(LN_SF) $(OLDSOVER) $(OLDSOMAJ); \ |
| 159 | $(LN_SF) $(OLDSOMAJ) $(OLDSO); \ |
| 160 | $(LN_SF) $(LIBSOVER) $(LIBSOMAJ); \ |
| 161 | $(LN_SF) $(LIBSOMAJ) $(LIBSO)) |
| 162 | -@if [ ! -d $(DL)/pkgconfig ]; then $(MKDIR_P) $(DL)/pkgconfig; fi |
| 163 | -@$(RM_F) $(DL)/pkgconfig/$(LIBNAME).pc |
| 164 | -@$(RM_F) $(DL)/pkgconfig/libpng.pc |
| 165 | cp libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc |
| 166 | chmod 644 $(DL)/pkgconfig/$(LIBNAME).pc |
| 167 | (cd $(DL)/pkgconfig; $(LN_SF) $(LIBNAME).pc libpng.pc) |
| 168 | |
| 169 | install-man: libpng.3 libpngpf.3 png.5 |
| 170 | -@if [ ! -d $(DM) ]; then $(MKDIR_P) $(DM); fi |
| 171 | -@if [ ! -d $(DM)/man3 ]; then $(MKDIR_P) $(DM)/man3; fi |
| 172 | -@$(RM_F) $(DM)/man3/libpng.3 |
| 173 | -@$(RM_F) $(DM)/man3/libpngpf.3 |
| 174 | cp libpng.3 $(DM)/man3 |
| 175 | cp libpngpf.3 $(DM)/man3 |
| 176 | -@if [ ! -d $(DM)/man5 ]; then $(MKDIR_P) $(DM)/man5; fi |
| 177 | -@$(RM_F) $(DM)/man5/png.5 |
| 178 | cp png.5 $(DM)/man5 |
| 179 | |
| 180 | install-config: libpng-config |
| 181 | -@if [ ! -d $(DB) ]; then $(MKDIR_P) $(DB); fi |
| 182 | -@$(RM_F) $(DB)/libpng-config |
| 183 | -@$(RM_F) $(DB)/$(LIBNAME)-config |
| 184 | cp libpng-config $(DB)/$(LIBNAME)-config |
| 185 | chmod 755 $(DB)/$(LIBNAME)-config |
| 186 | (cd $(DB); $(LN_SF) $(LIBNAME)-config libpng-config) |
| 187 | |
| 188 | install: install-static install-shared install-man install-config |
| 189 | |
| 190 | # If you installed in $(DESTDIR), test-installed won't work until you |
| 191 | # move the library to its final location. Use test-dd to test it |
| 192 | # before then. |
| 193 | |
| 194 | test-dd: |
| 195 | echo |
| 196 | echo Testing installed dynamic shared library in $(DL). |
| 197 | $(CC) -I$(DI) -I$(ZLIBINC) \ |
| 198 | `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \ |
| 199 | -L$(DL) -L$(ZLIBLIB) \ |
| 200 | -o pngtestd `$(BINPATH)/$(LIBNAME)-config --ldflags` |
| 201 | ./pngtestd pngtest.png |
| 202 | |
| 203 | test-installed: |
| 204 | $(CC) $(CFLAGS) \ |
| 205 | `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \ |
| 206 | -L$(ZLIBLIB) \ |
| 207 | -o pngtesti `$(BINPATH)/$(LIBNAME)-config --ldflags` |
| 208 | ./pngtesti pngtest.png |
| 209 | |
| 210 | clean: |
| 211 | $(RM_F) *.o libpng.a pngtest pngout.png libpng-config \ |
| 212 | $(OLDSOVER) \ |
| 213 | libpng.pc $(LIBNAME).*dylib pngtesti |
| 214 | |
| 215 | DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO |
| 216 | writelock: |
| 217 | chmod a-w *.[ch35] $(DOCS) scripts/* |
| 218 | |
| 219 | # DO NOT DELETE THIS LINE -- make depend depends on it. |
| 220 | |
| 221 | png.o png.pic.o: png.h pngconf.h |
| 222 | pngerror.o pngerror.pic.o: png.h pngconf.h |
| 223 | pngrio.o pngrio.pic.o: png.h pngconf.h |
| 224 | pngwio.o pngwio.pic.o: png.h pngconf.h |
| 225 | pngmem.o pngmem.pic.o: png.h pngconf.h |
| 226 | pngset.o pngset.pic.o: png.h pngconf.h |
| 227 | pngget.o pngget.pic.o: png.h pngconf.h |
| 228 | pngread.o pngread.pic.o: png.h pngconf.h |
| 229 | pngrtran.o pngrtran.pic.o: png.h pngconf.h |
| 230 | pngrutil.o pngrutil.pic.o: png.h pngconf.h |
| 231 | pngtrans.o pngtrans.pic.o: png.h pngconf.h |
| 232 | pngwrite.o pngwrite.pic.o: png.h pngconf.h |
| 233 | pngwtran.o pngwtran.pic.o: png.h pngconf.h |
| 234 | pngwutil.o pngwutil.pic.o: png.h pngconf.h |
| 235 | pngpread.o pngpread.pic.o: png.h pngconf.h |
| 236 | |
| 237 | pngtest.o: png.h pngconf.h |