1 # makefile for libpng on Darwin / Mac OS X
2 # Copyright (C) 2002, 2004, 2006, 2008 Glenn Randers-Pehrson
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
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
12 # where "make install" puts libpng.a, libpng12.dylib, png.h and pngconf.h
16 # Where the zlib library and include files are located
17 #ZLIBLIB=/usr/local/lib
18 #ZLIBINC=/usr/local/include
26 PNGVER = $(PNGMAJ).$(PNGMIN)
28 # Shared library names:
29 LIBSO=$(LIBNAME).dylib
30 LIBSOMAJ=$(LIBNAME).$(PNGMAJ).dylib
31 LIBSOVER=$(LIBNAME).$(PNGVER).dylib
33 OLDSOMAJ=libpng.3.dylib
34 OLDSOVER=libpng.3.$(PNGMIN).dylib
44 # CFLAGS=-I$(ZLIBINC) -W -Wall -O3 -funroll-loops -DPNG_NO_MMX_CODE
45 CFLAGS=-I$(ZLIBINC) -W -Wall -O -funroll-loops
46 LDFLAGS=-L. -L$(ZLIBLIB) -lpng12 -lz
48 INCPATH=$(prefix)/include
49 LIBPATH=$(exec_prefix)/lib
51 BINPATH=$(exec_prefix)/bin
53 # override DESTDIR= on the make install command line to easily support
54 # installing into a temporary location. Example:
56 # make install DESTDIR=/tmp/build/libpng
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.
63 DB=$(DESTDIR)$(BINPATH)
64 DI=$(DESTDIR)$(INCPATH)
65 DL=$(DESTDIR)$(LIBPATH)
66 DM=$(DESTDIR)$(MANPATH)
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
72 OBJSDLL = $(OBJS:.o=.pic.o)
74 .SUFFIXES: .c .o .pic.o
77 $(CC) -c $(CFLAGS) -fno-common -o $@ $*.c
79 all: libpng.a $(LIBSO) pngtest libpng.pc libpng-config
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
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
101 $(LIBSO): $(LIBSOMAJ)
102 $(LN_SF) $(LIBSOMAJ) $(LIBSO)
104 $(LIBSOMAJ): $(LIBSOVER)
105 $(LN_SF) $(LIBSOVER) $(LIBSOMAJ)
107 $(LIBSOVER): $(OBJSDLL)
109 -install_name $(LIBPATH)/$(LIBSOMAJ) \
110 -current_version 0 -compatibility_version 0 \
112 $(OBJSDLL) -L$(ZLIBLIB) -lz
114 $(OLDSOVER): $(OBJSDLL)
116 -install_name $(LIBPATH)/$(OLDSOMAJ) \
117 -current_version 3 -compatibility_version 3 \
119 $(OBJSDLL) -L$(ZLIBLIB) -lz
121 pngtest: pngtest.o $(LIBSO)
122 $(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS)
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)/* .)
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)
144 install-shared: install-headers $(LIBSO) libpng.pc \
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
155 chmod 755 $(DL)/$(LIBSOVER)
156 chmod 755 $(DL)/$(OLDSOVER)
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)
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
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)
188 install: install-static install-shared install-man install-config
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
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
205 `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \
207 -o pngtesti `$(BINPATH)/$(LIBNAME)-config --ldflags`
208 ./pngtesti pngtest.png
211 $(RM_F) *.o libpng.a pngtest pngout.png libpng-config \
213 libpng.pc $(LIBNAME).*dylib pngtesti
215 DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO
217 chmod a-w *.[ch35] $(DOCS) scripts/*
219 # DO NOT DELETE THIS LINE -- make depend depends on it.
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
237 pngtest.o: png.h pngconf.h