]>
Commit | Line | Data |
---|---|---|
c6b71bff GD |
1 | # makefile for libpng.a and libpng12.so on Linux ELF with gcc using MMX |
2 | # assembler code | |
3 | # Copyright 2002 Greg Roelofs and Glenn Randers-Pehrson | |
4 | # Copyright 1998-2001 Greg Roelofs | |
5 | # Copyright 1996-1997 Andreas Dilger | |
6 | # For conditions of distribution and use, see copyright notice in png.h | |
7 | ||
8 | # CAUTION: Do not use this makefile with gcc versions 2.7.2.2 and earlier. | |
9 | ||
10 | # WARNING: The assembler code in pnggccrd.c may not be thread safe. | |
11 | ||
12 | # NOTE: When testing MMX performance on a multitasking system, make sure | |
13 | # there are no floating-point programs (e.g., SETI@Home) running in | |
14 | # the background! Context switches between MMX and FPU are expensive. | |
15 | ||
16 | LIBNAME = libpng12 | |
17 | PNGMAJ = 0 | |
880c38ba | 18 | PNGMIN = 1.2.7 |
c6b71bff GD |
19 | PNGVER = $(PNGMAJ).$(PNGMIN) |
20 | ||
21 | CC=gcc | |
22 | ||
23 | # where "make install" puts libpng12.a, libpng12.so*, | |
24 | # libpng12/png.h and libpng12/pngconf.h | |
25 | # Prefix must be a full pathname. | |
26 | prefix=/usr/local | |
27 | ||
28 | # Where the zlib library and include files are located. | |
29 | #ZLIBLIB=/usr/local/lib | |
30 | #ZLIBINC=/usr/local/include | |
31 | ZLIBLIB=../zlib | |
32 | ZLIBINC=../zlib | |
33 | ||
34 | ALIGN= | |
35 | # for i386: | |
36 | #ALIGN=-malign-loops=2 -malign-functions=2 | |
37 | ||
38 | WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow \ | |
39 | -Wmissing-declarations -Wtraditional -Wcast-align \ | |
40 | -Wstrict-prototypes -Wmissing-prototypes #-Wconversion | |
41 | ||
42 | # for pgcc version 2.95.1, -O3 is buggy; don't use it. | |
43 | ||
44 | # Remove -DPNG_THREAD_UNSAFE_OK if you need thread safety | |
45 | ### for generic gcc: | |
46 | CFLAGS=-DPNG_THREAD_UNSAFE_OK -DPNG_USE_PNGGCCRD -I$(ZLIBINC) -Wall \ | |
47 | -O3 $(ALIGN) -funroll-loops \ | |
48 | -fomit-frame-pointer # $(WARNMORE) -g -DPNG_DEBUG=5 | |
49 | ### for gcc 2.95.2 on 686: | |
50 | #CFLAGS=-DPNG_THREAD_UNSAFE_OK -DPNG_USE_PNGGCCRD -I$(ZLIBINC) -Wall -O3 \ | |
51 | # -mcpu=i686 -malign-double -ffast-math -fstrict-aliasing \ | |
52 | # $(ALIGN) -funroll-loops -funroll-all-loops -fomit-frame-pointer | |
53 | ### for gcc 2.7.2.3 on 486 and up: | |
54 | #CFLAGS=-DPNG_THREAD_UNSAFE_OK -DPNG_USE_PNGGCCRD -I$(ZLIBINC) -Wall -O3 \ | |
55 | # -m486 -malign-double -ffast-math \ | |
56 | # $(ALIGN) -funroll-loops -funroll-all-loops -fomit-frame-pointer | |
57 | ||
58 | LDFLAGS=-L. -Wl,-rpath,. -L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) -lpng12 -lz -lm | |
59 | LDFLAGS_A=-L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) libpng.a -lz -lm | |
60 | ||
61 | RANLIB=ranlib | |
62 | #RANLIB=echo | |
63 | ||
64 | INCPATH=$(prefix)/include | |
65 | LIBPATH=$(prefix)/lib | |
66 | MANPATH=$(prefix)/man | |
67 | BINPATH=$(prefix)/bin | |
68 | ||
69 | # override DESTDIR= on the make install command line to easily support | |
70 | # installing into a temporary location. Example: | |
71 | # | |
72 | # make install DESTDIR=/tmp/build/libpng | |
73 | # | |
74 | # If you're going to install into a temporary location | |
75 | # via DESTDIR, $(DESTDIR)$(prefix) must already exist before | |
76 | # you execute make install. | |
77 | DESTDIR= | |
78 | ||
79 | DB=$(DESTDIR)$(BINPATH) | |
80 | DI=$(DESTDIR)$(INCPATH) | |
81 | DL=$(DESTDIR)$(LIBPATH) | |
82 | DM=$(DESTDIR)$(MANPATH) | |
83 | ||
84 | OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \ | |
85 | pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \ | |
86 | pngwtran.o pngmem.o pngerror.o pngpread.o pnggccrd.o | |
87 | ||
88 | OBJSDLL = $(OBJS:.o=.pic.o) | |
89 | ||
90 | .SUFFIXES: .c .o .pic.o | |
91 | ||
92 | .c.pic.o: | |
93 | $(CC) -c $(CFLAGS) -fPIC -o $@ $*.c | |
94 | ||
95 | all: libpng.a $(LIBNAME).so pngtest pngtest-static libpng.pc libpng-config | |
96 | ||
97 | libpng.a: $(OBJS) | |
98 | ar rc $@ $(OBJS) | |
99 | $(RANLIB) $@ | |
100 | ||
101 | libpng.pc: | |
102 | cat scripts/libpng.pc.in | sed -e s\!@PREFIX@!$(prefix)! > libpng.pc | |
103 | ||
104 | libpng-config: | |
105 | ( cat scripts/libpng-config-head.in; \ | |
106 | echo prefix=\"$(prefix)\"; \ | |
3d11a79a VS |
107 | echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \ |
108 | echo cppflags=\"-DPNG_THREAD_UNSAFE_OK -DPNG_USE_PNGGCCRD\"; \ | |
109 | echo L_opts=\"-L$(LIBPATH)\"; \ | |
110 | echo R_opts=\"-Wl,-rpath,$(LIBPATH)\"; \ | |
c6b71bff GD |
111 | echo libs=\"-lpng12 -lz -lm\"; \ |
112 | cat scripts/libpng-config-body.in ) > libpng-config | |
113 | chmod +x libpng-config | |
114 | ||
115 | pnggccrd.o: pnggccrd.c png.h pngconf.h | |
116 | $(CC) -c $(CFLAGS) -o $@ $*.c | |
117 | ||
118 | pnggccrd.pic.o: pnggccrd.c png.h pngconf.h | |
119 | $(CC) -c $(CFLAGS) -fPIC -o $@ pnggccrd.c | |
120 | ||
121 | $(LIBNAME).so: $(LIBNAME).so.$(PNGMAJ) | |
122 | ln -sf $(LIBNAME).so.$(PNGMAJ) $(LIBNAME).so | |
123 | ||
124 | $(LIBNAME).so.$(PNGMAJ): $(LIBNAME).so.$(PNGVER) | |
125 | ln -sf $(LIBNAME).so.$(PNGVER) $(LIBNAME).so.$(PNGMAJ) | |
126 | ||
127 | $(LIBNAME).so.$(PNGVER): $(OBJSDLL) | |
128 | $(CC) -shared -Wl,-soname,$(LIBNAME).so.$(PNGMAJ) \ | |
129 | -o $(LIBNAME).so.$(PNGVER) \ | |
3d11a79a VS |
130 | $(OBJSDLL) |
131 | ||
132 | libpng.so.3.$(PNGMIN): $(OBJSDLL) | |
133 | $(CC) -shared -Wl,-soname,libpng.so.3 \ | |
134 | -o libpng.so.3.$(PNGMIN) \ | |
135 | $(OBJSDLL) | |
c6b71bff GD |
136 | |
137 | pngtest: pngtest.o $(LIBNAME).so | |
138 | $(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS) | |
139 | ||
140 | pngtest-static: pngtest.o libpng.a | |
141 | $(CC) -o pngtest-static $(CFLAGS) pngtest.o $(LDFLAGS_A) | |
142 | ||
143 | test: pngtest pngtest-static | |
144 | @echo "" | |
145 | @echo " Running pngtest dynamically linked with $(LIBNAME).so:" | |
146 | @echo "" | |
147 | ./pngtest | |
148 | @echo "" | |
149 | @echo " Running pngtest statically linked with libpng.a:" | |
150 | @echo "" | |
151 | ./pngtest-static | |
152 | ||
153 | install-headers: png.h pngconf.h | |
154 | -@if [ ! -d $(DI) ]; then mkdir $(DI); fi | |
155 | -@if [ ! -d $(DI)/$(LIBNAME) ]; then mkdir $(DI)/$(LIBNAME); fi | |
156 | cp png.h pngconf.h $(DI)/$(LIBNAME) | |
157 | chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h | |
158 | -@/bin/rm -f $(DI)/png.h $(DI)/pngconf.h | |
159 | -@/bin/rm -f $(DI)/libpng | |
160 | (cd $(DI); ln -sf $(LIBNAME) libpng; ln -sf $(LIBNAME)/* .) | |
161 | ||
162 | install-static: install-headers libpng.a | |
163 | -@if [ ! -d $(DL) ]; then mkdir $(DL); fi | |
164 | cp libpng.a $(DL)/$(LIBNAME).a | |
165 | chmod 644 $(DL)/$(LIBNAME).a | |
166 | -@/bin/rm -f $(DL)/libpng.a | |
167 | (cd $(DL); ln -sf $(LIBNAME).a libpng.a) | |
168 | ||
3d11a79a VS |
169 | install-shared: install-headers $(LIBNAME).so.$(PNGVER) libpng.pc \ |
170 | libpng.so.3.$(PNGMIN) | |
c6b71bff | 171 | -@if [ ! -d $(DL) ]; then mkdir $(DL); fi |
3d11a79a VS |
172 | -@/bin/rm -f $(DL)/$(LIBNAME).so.$(PNGVER)* $(DL)/$(LIBNAME).so |
173 | -@/bin/rm -f $(DL)/$(LIBNAME).so.$(PNGMAJ) | |
c6b71bff GD |
174 | -@/bin/rm -f $(DL)/libpng.so |
175 | -@/bin/rm -f $(DL)/libpng.so.3 | |
3d11a79a | 176 | -@/bin/rm -f $(DL)/libpng.so.3.$(PNGMIN)* |
c6b71bff | 177 | cp $(LIBNAME).so.$(PNGVER) $(DL) |
3d11a79a | 178 | cp libpng.so.3.$(PNGMIN) $(DL) |
c6b71bff | 179 | chmod 755 $(DL)/$(LIBNAME).so.$(PNGVER) |
3d11a79a | 180 | chmod 755 $(DL)/libpng.so.3.$(PNGMIN) |
c6b71bff | 181 | (cd $(DL); \ |
3d11a79a VS |
182 | ln -sf libpng.so.3.$(PNGMIN) libpng.so.3; \ |
183 | ln -sf libpng.so.3 libpng.so; \ | |
c6b71bff GD |
184 | ln -sf $(LIBNAME).so.$(PNGVER) $(LIBNAME).so.$(PNGMAJ); \ |
185 | ln -sf $(LIBNAME).so.$(PNGMAJ) $(LIBNAME).so) | |
186 | -@if [ ! -d $(DL)/pkgconfig ]; then mkdir $(DL)/pkgconfig; fi | |
187 | -@/bin/rm -f $(DL)/pkgconfig/$(LIBNAME).pc | |
188 | -@/bin/rm -f $(DL)/pkgconfig/libpng.pc | |
189 | cp libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc | |
190 | chmod 644 $(DL)/pkgconfig/$(LIBNAME).pc | |
191 | (cd $(DL)/pkgconfig; ln -sf $(LIBNAME).pc libpng.pc) | |
192 | ||
193 | install-man: libpng.3 libpngpf.3 png.5 | |
194 | -@if [ ! -d $(DM) ]; then mkdir $(DM); fi | |
195 | -@if [ ! -d $(DM)/man3 ]; then mkdir $(DM)/man3; fi | |
196 | -@/bin/rm -f $(DM)/man3/libpng.3 | |
197 | -@/bin/rm -f $(DM)/man3/libpngpf.3 | |
198 | cp libpng.3 $(DM)/man3 | |
199 | cp libpngpf.3 $(DM)/man3 | |
200 | -@if [ ! -d $(DM)/man5 ]; then mkdir $(DM)/man5; fi | |
201 | -@/bin/rm -f $(DM)/man5/png.5 | |
202 | cp png.5 $(DM)/man5 | |
203 | ||
204 | install-config: libpng-config | |
205 | -@if [ ! -d $(DB) ]; then mkdir $(DB); fi | |
206 | -@/bin/rm -f $(DB)/libpng-config | |
207 | -@/bin/rm -f $(DB)/$(LIBNAME)-config | |
208 | cp libpng-config $(DB)/$(LIBNAME)-config | |
209 | chmod 755 $(DB)/$(LIBNAME)-config | |
210 | (cd $(DB); ln -sf $(LIBNAME)-config libpng-config) | |
211 | ||
212 | install: install-static install-shared install-man install-config | |
213 | ||
214 | # If you installed in $(DESTDIR), test-installed won't work until you | |
880c38ba VS |
215 | # move the library to its final location. Use test-dd to test it |
216 | # before then. | |
217 | ||
218 | test-dd: | |
219 | echo | |
220 | echo Testing installed dynamic shared library in $(DL). | |
221 | $(CC) -I$(DI) -I$(ZLIBINC) \ | |
222 | `$(BINPATH)/libpng12-config --cflags` pngtest.c \ | |
223 | -L$(DL) -L$(ZLIBLIB) -W1, -rpath,$(DL) -Wl,-rpath,$(ZLIBLIB) \ | |
224 | -o pngtestd `$(BINPATH)/libpng12-config --ldflags` | |
225 | ./pngtestd pngtest.png | |
c6b71bff GD |
226 | |
227 | test-installed: | |
228 | $(CC) -I$(ZLIBINC) \ | |
3d11a79a | 229 | `$(BINPATH)/libpng12-config --cflags` pngtest.c \ |
c6b71bff | 230 | -L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) \ |
3d11a79a | 231 | -o pngtesti `$(BINPATH)/libpng12-config --ldflags` |
c6b71bff GD |
232 | ./pngtesti pngtest.png |
233 | ||
234 | clean: | |
3d11a79a VS |
235 | /bin/rm -f *.o libpng.a pngtest pngout.png libpng-config \ |
236 | $(LIBNAME).so $(LIBNAME).so.$(PNGMAJ)* pngtest-static pngtesti \ | |
237 | libpng.so.3.$(PNGMIN) \ | |
238 | libpng.pc | |
c6b71bff GD |
239 | |
240 | DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO | |
241 | writelock: | |
242 | chmod a-w *.[ch35] $(DOCS) scripts/* | |
243 | ||
244 | png.o png.pic.o: png.h pngconf.h png.c | |
245 | pngerror.o pngerror.pic.o: png.h pngconf.h pngerror.c | |
246 | pngrio.o pngrio.pic.o: png.h pngconf.h pngrio.c | |
247 | pngwio.o pngwio.pic.o: png.h pngconf.h pngwio.c | |
248 | pngmem.o pngmem.pic.o: png.h pngconf.h pngmem.c | |
249 | pngset.o pngset.pic.o: png.h pngconf.h pngset.c | |
250 | pngget.o pngget.pic.o: png.h pngconf.h pngget.c | |
251 | pngread.o pngread.pic.o: png.h pngconf.h pngread.c | |
252 | pngrtran.o pngrtran.pic.o: png.h pngconf.h pngrtran.c | |
253 | pngrutil.o pngrutil.pic.o: png.h pngconf.h pngrutil.c | |
254 | pngtrans.o pngtrans.pic.o: png.h pngconf.h pngtrans.c | |
255 | pngwrite.o pngwrite.pic.o: png.h pngconf.h pngwrite.c | |
256 | pngwtran.o pngwtran.pic.o: png.h pngconf.h pngwtran.c | |
257 | pngwutil.o pngwutil.pic.o: png.h pngconf.h pngwutil.c | |
258 | pngpread.o pngpread.pic.o: png.h pngconf.h pngpread.c | |
259 | ||
260 | pngtest.o: png.h pngconf.h pngtest.c |