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