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