]>
Commit | Line | Data |
---|---|---|
0272a10d | 1 | # makefile for libpng on Darwin / Mac OS X |
9c0d9ce3 | 2 | # Copyright (C) 2002, 2004, 2006, 2008, 2010-2011 Glenn Randers-Pehrson |
0272a10d VZ |
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 | |
b61cc19c PC |
7 | # |
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 | |
0272a10d | 11 | |
fff5f7d5 | 12 | # where "make install" puts libpng.a, libpng16.dylib, png.h, pngconf.h, |
9c0d9ce3 | 13 | # and pnglibconf.h |
0272a10d VZ |
14 | prefix=/usr/local |
15 | exec_prefix=$(prefix) | |
16 | ||
17 | # Where the zlib library and include files are located | |
fff5f7d5 VZ |
18 | ZLIBLIB=/usr/lib |
19 | ZLIBINC=/usr/include | |
0272a10d VZ |
20 | |
21 | # Library name: | |
fff5f7d5 VZ |
22 | LIBNAME = libpng16 |
23 | PNGMAJ = 16 | |
0272a10d VZ |
24 | |
25 | # Shared library names: | |
26 | LIBSO=$(LIBNAME).dylib | |
27 | LIBSOMAJ=$(LIBNAME).$(PNGMAJ).dylib | |
b61cc19c | 28 | LIBSOREL=$(LIBNAME).$(PNGMAJ).$(RELEASE).dylib |
0272a10d | 29 | OLDSO=libpng.dylib |
0272a10d VZ |
30 | |
31 | # Utilities: | |
32 | CC=cc | |
33 | AR_RC=ar rc | |
34 | MKDIR_P=mkdir -p | |
35 | LN_SF=ln -sf | |
36 | RANLIB=ranlib | |
37 | RM_F=/bin/rm -f | |
fff5f7d5 | 38 | ARCH=-arch ppc -arch i386 -arch x86_64 |
0272a10d | 39 | |
b61cc19c | 40 | # CFLAGS=-I$(ZLIBINC) -W -Wall -O3 -funroll-loops |
9c0d9ce3 | 41 | CFLAGS=-I$(ZLIBINC) -W -Wall -O -funroll-loops $(ARCH) |
fff5f7d5 | 42 | LDFLAGS=-L. -L$(ZLIBLIB) -lpng16 -lz $(ARCH) |
0272a10d VZ |
43 | |
44 | INCPATH=$(prefix)/include | |
45 | LIBPATH=$(exec_prefix)/lib | |
46 | MANPATH=$(prefix)/man | |
47 | BINPATH=$(exec_prefix)/bin | |
48 | ||
49 | # override DESTDIR= on the make install command line to easily support | |
50 | # installing into a temporary location. Example: | |
51 | # | |
52 | # make install DESTDIR=/tmp/build/libpng | |
53 | # | |
54 | # If you're going to install into a temporary location | |
55 | # via DESTDIR, $(DESTDIR)$(prefix) must already exist before | |
56 | # you execute make install. | |
57 | DESTDIR= | |
58 | ||
59 | DB=$(DESTDIR)$(BINPATH) | |
60 | DI=$(DESTDIR)$(INCPATH) | |
61 | DL=$(DESTDIR)$(LIBPATH) | |
62 | DM=$(DESTDIR)$(MANPATH) | |
63 | ||
64 | OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \ | |
65 | pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \ | |
66 | pngwtran.o pngmem.o pngerror.o pngpread.o | |
67 | ||
68 | OBJSDLL = $(OBJS:.o=.pic.o) | |
69 | ||
70 | .SUFFIXES: .c .o .pic.o | |
71 | ||
72 | .c.pic.o: | |
73 | $(CC) -c $(CFLAGS) -fno-common -o $@ $*.c | |
74 | ||
75 | all: libpng.a $(LIBSO) pngtest libpng.pc libpng-config | |
76 | ||
9c0d9ce3 DS |
77 | # see scripts/pnglibconf.mak for more options |
78 | pnglibconf.h: scripts/pnglibconf.h.prebuilt | |
79 | cp scripts/pnglibconf.h.prebuilt $@ | |
80 | ||
0272a10d VZ |
81 | libpng.a: $(OBJS) |
82 | $(AR_RC) $@ $(OBJS) | |
83 | $(RANLIB) $@ | |
84 | ||
85 | libpng.pc: | |
970f6abe VZ |
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)! \ | |
fff5f7d5 | 90 | -e s!-lpng16!-lpng16\ -lz! > libpng.pc |
0272a10d VZ |
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)\"; \ | |
fff5f7d5 | 97 | echo libs=\"-lpng16 -lz\"; \ |
0272a10d VZ |
98 | cat scripts/libpng-config-body.in ) > libpng-config |
99 | chmod +x libpng-config | |
100 | ||
101 | $(LIBSO): $(LIBSOMAJ) | |
102 | $(LN_SF) $(LIBSOMAJ) $(LIBSO) | |
103 | ||
b61cc19c | 104 | $(LIBSOMAJ): $(OBJSDLL) |
0272a10d VZ |
105 | $(CC) -dynamiclib \ |
106 | -install_name $(LIBPATH)/$(LIBSOMAJ) \ | |
fff5f7d5 VZ |
107 | -current_version 16 -compatibility_version 16 \ |
108 | $(ARCH) -o $(LIBSOMAJ) \ | |
0272a10d VZ |
109 | $(OBJSDLL) -L$(ZLIBLIB) -lz |
110 | ||
111 | pngtest: pngtest.o $(LIBSO) | |
112 | $(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS) | |
113 | ||
114 | test: pngtest | |
115 | ./pngtest | |
116 | ||
9c0d9ce3 | 117 | install-headers: png.h pngconf.h pnglibconf.h |
0272a10d VZ |
118 | -@if [ ! -d $(DI) ]; then $(MKDIR_P) $(DI); fi |
119 | -@if [ ! -d $(DI)/$(LIBNAME) ]; then $(MKDIR_P) $(DI)/$(LIBNAME); fi | |
9c0d9ce3 DS |
120 | cp png.h pngconf.h pnglibconf.h $(DI)/$(LIBNAME) |
121 | chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h $(DI)/$(LIBNAME)/pnglibconf.h | |
122 | -@$(RM_F) $(DI)/png.h $(DI)/pngconf.h $(DI)/pnglibconf.h | |
0272a10d VZ |
123 | -@$(RM_F) $(DI)/libpng |
124 | (cd $(DI); $(LN_SF) $(LIBNAME) libpng; $(LN_SF) $(LIBNAME)/* .) | |
125 | ||
126 | install-static: install-headers libpng.a | |
127 | -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi | |
128 | cp libpng.a $(DL)/$(LIBNAME).a | |
129 | chmod 644 $(DL)/$(LIBNAME).a | |
130 | $(RANLIB) $(DL)/$(LIBNAME).a | |
131 | -@$(RM_F) $(DL)/libpng.a | |
132 | (cd $(DL); $(LN_SF) $(LIBNAME).a libpng.a) | |
133 | ||
b61cc19c | 134 | install-shared: install-headers $(LIBSOMAJ) libpng.pc |
0272a10d | 135 | -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi |
0272a10d | 136 | -@$(RM_F) $(DL)/$(LIBSO) |
fff5f7d5 | 137 | -@$(RM_F) $(DL)/$(LIBSOMAJ) |
0272a10d | 138 | -@$(RM_F) $(DL)/$(OLDSO) |
fff5f7d5 VZ |
139 | cp $(LIBSOMAJ) $(DL) |
140 | chmod 755 $(DL)/$(LIBSOMAJ) | |
0272a10d | 141 | (cd $(DL); \ |
b61cc19c PC |
142 | $(LN_SF) $(LIBSOREL) $(LIBSO); \ |
143 | $(LN_SF) $(LIBSO) $(OLDSO)) | |
0272a10d VZ |
144 | -@if [ ! -d $(DL)/pkgconfig ]; then $(MKDIR_P) $(DL)/pkgconfig; fi |
145 | -@$(RM_F) $(DL)/pkgconfig/$(LIBNAME).pc | |
146 | -@$(RM_F) $(DL)/pkgconfig/libpng.pc | |
147 | cp libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc | |
148 | chmod 644 $(DL)/pkgconfig/$(LIBNAME).pc | |
149 | (cd $(DL)/pkgconfig; $(LN_SF) $(LIBNAME).pc libpng.pc) | |
150 | ||
151 | install-man: libpng.3 libpngpf.3 png.5 | |
152 | -@if [ ! -d $(DM) ]; then $(MKDIR_P) $(DM); fi | |
153 | -@if [ ! -d $(DM)/man3 ]; then $(MKDIR_P) $(DM)/man3; fi | |
154 | -@$(RM_F) $(DM)/man3/libpng.3 | |
155 | -@$(RM_F) $(DM)/man3/libpngpf.3 | |
156 | cp libpng.3 $(DM)/man3 | |
157 | cp libpngpf.3 $(DM)/man3 | |
158 | -@if [ ! -d $(DM)/man5 ]; then $(MKDIR_P) $(DM)/man5; fi | |
159 | -@$(RM_F) $(DM)/man5/png.5 | |
160 | cp png.5 $(DM)/man5 | |
161 | ||
162 | install-config: libpng-config | |
163 | -@if [ ! -d $(DB) ]; then $(MKDIR_P) $(DB); fi | |
164 | -@$(RM_F) $(DB)/libpng-config | |
165 | -@$(RM_F) $(DB)/$(LIBNAME)-config | |
166 | cp libpng-config $(DB)/$(LIBNAME)-config | |
167 | chmod 755 $(DB)/$(LIBNAME)-config | |
168 | (cd $(DB); $(LN_SF) $(LIBNAME)-config libpng-config) | |
169 | ||
170 | install: install-static install-shared install-man install-config | |
171 | ||
172 | # If you installed in $(DESTDIR), test-installed won't work until you | |
173 | # move the library to its final location. Use test-dd to test it | |
174 | # before then. | |
175 | ||
176 | test-dd: | |
177 | echo | |
178 | echo Testing installed dynamic shared library in $(DL). | |
179 | $(CC) -I$(DI) -I$(ZLIBINC) \ | |
180 | `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \ | |
181 | -L$(DL) -L$(ZLIBLIB) \ | |
182 | -o pngtestd `$(BINPATH)/$(LIBNAME)-config --ldflags` | |
183 | ./pngtestd pngtest.png | |
184 | ||
185 | test-installed: | |
186 | $(CC) $(CFLAGS) \ | |
187 | `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \ | |
188 | -L$(ZLIBLIB) \ | |
189 | -o pngtesti `$(BINPATH)/$(LIBNAME)-config --ldflags` | |
190 | ./pngtesti pngtest.png | |
191 | ||
192 | clean: | |
193 | $(RM_F) *.o libpng.a pngtest pngout.png libpng-config \ | |
9c0d9ce3 | 194 | libpng.pc $(LIBNAME).*dylib pngtesti pnglibconf.h |
0272a10d VZ |
195 | |
196 | DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO | |
197 | writelock: | |
198 | chmod a-w *.[ch35] $(DOCS) scripts/* | |
199 | ||
200 | # DO NOT DELETE THIS LINE -- make depend depends on it. | |
201 | ||
fff5f7d5 VZ |
202 | png.o png.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h |
203 | pngerror.o pngerror.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h | |
204 | pngrio.o pngrio.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h | |
205 | pngwio.o pngwio.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h | |
206 | pngmem.o pngmem.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h | |
207 | pngset.o pngset.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h | |
208 | pngget.o pngget.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h | |
209 | pngread.o pngread.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h | |
210 | pngrtran.o pngrtran.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h | |
211 | pngrutil.o pngrutil.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h | |
212 | pngtrans.o pngtrans.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h | |
213 | pngwrite.o pngwrite.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h | |
214 | pngwtran.o pngwtran.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h | |
215 | pngwutil.o pngwutil.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h | |
216 | pngpread.o pngpread.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h | |
9c0d9ce3 DS |
217 | |
218 | pngtest.o: png.h pngconf.h pnglibconf.h |