1 # makefile for libpng.a and libpng12.so on Linux ELF with gcc using MMX
3 # Copyright 2002, 2006 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
8 # CAUTION: Do not use this makefile with gcc versions 2.7.2.2 and earlier.
10 # NOTE: When testing MMX performance on a multitasking system, make sure
11 # there are no floating-point programs (e.g., SETI@Home) running in
12 # the background! Context switches between MMX and FPU are expensive.
18 PNGVER = $(PNGMAJ).$(PNGMIN)
20 # Shared library names:
22 LIBSOMAJ=$(LIBNAME).so.$(PNGMAJ)
23 LIBSOVER=$(LIBNAME).so.$(PNGVER)
26 OLDSOVER=libpng.so.3.$(PNGMIN)
37 # where "make install" puts libpng12.a, libpng12.so*,
38 # libpng12/png.h and libpng12/pngconf.h
39 # Prefix must be a full pathname.
43 # Where the zlib library and include files are located.
44 #ZLIBLIB=/usr/local/lib
45 #ZLIBINC=/usr/local/include
51 #ALIGN=-malign-loops=2 -malign-functions=2
53 WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow \
54 -Wmissing-declarations -Wtraditional -Wcast-align \
55 -Wstrict-prototypes -Wmissing-prototypes #-Wconversion
57 # for pgcc version 2.95.1, -O3 is buggy; don't use it.
59 # Remove -DPNG_THREAD_UNSAFE_OK if you need thread safety
61 CFLAGS=-DPNG_THREAD_UNSAFE_OK -I$(ZLIBINC) -Wall -O \
62 $(ALIGN) -funroll-loops \
63 -fomit-frame-pointer # $(WARNMORE) -g -DPNG_DEBUG=5
64 ### for gcc 2.95.2 on 686:
65 #CFLAGS=-DPNG_THREAD_UNSAFE_OK -I$(ZLIBINC) -Wall -O \
66 # -mcpu=i686 -malign-double -ffast-math -fstrict-aliasing \
67 # $(ALIGN) -funroll-loops -funroll-all-loops -fomit-frame-pointer
68 ### for gcc 2.7.2.3 on 486 and up:
69 #CFLAGS=-DPNG_THREAD_UNSAFE_OK -I$(ZLIBINC) -Wall -O \
70 # -m486 -malign-double -ffast-math \
71 # $(ALIGN) -funroll-loops -funroll-all-loops -fomit-frame-pointer
73 LDFLAGS=-L. -Wl,-rpath,. -L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) -lpng12 -lz -lm
74 LDFLAGS_A=-L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) libpng.a -lz -lm
77 INCPATH=$(prefix)/include
78 LIBPATH=$(exec_prefix)/lib
80 BINPATH=$(exec_prefix)/bin
82 # override DESTDIR= on the make install command line to easily support
83 # installing into a temporary location. Example:
85 # make install DESTDIR=/tmp/build/libpng
87 # If you're going to install into a temporary location
88 # via DESTDIR, $(DESTDIR)$(prefix) must already exist before
89 # you execute make install.
92 DB=$(DESTDIR)$(BINPATH)
93 DI=$(DESTDIR)$(INCPATH)
94 DL=$(DESTDIR)$(LIBPATH)
95 DM=$(DESTDIR)$(MANPATH)
97 OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \
98 pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \
99 pngwtran.o pngmem.o pngerror.o pngpread.o
101 OBJSDLL = $(OBJS:.o=.pic.o)
103 .SUFFIXES: .c .o .pic.o
106 $(CC) -c $(CFLAGS) -fPIC -o $@ $*.c
108 all: libpng.a $(LIBSO) pngtest pngtest-static libpng.pc libpng-config
115 cat scripts/libpng.pc.in | sed -e s\!@PREFIX@!$(prefix)! > libpng.pc
118 ( cat scripts/libpng-config-head.in; \
119 echo prefix=\"$(prefix)\"; \
120 echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \
121 echo cppflags=\"-DPNG_THREAD_UNSAFE_OK \"; \
122 echo L_opts=\"-L$(LIBPATH)\"; \
123 echo R_opts=\"-Wl,-rpath,$(LIBPATH)\"; \
124 echo libs=\"-lpng12 -lz -lm\"; \
125 cat scripts/libpng-config-body.in ) > libpng-config
126 chmod +x libpng-config
128 $(LIBSO): $(LIBSOMAJ)
129 $(LN_SF) $(LIBSOMAJ) $(LIBSO)
131 $(LIBSOMAJ): $(LIBSOVER)
132 $(LN_SF) $(LIBSOVER) $(LIBSOMAJ)
134 $(LIBSOVER): $(OBJSDLL)
135 $(CC) -shared -Wl,-soname,$(LIBSOMAJ) \
139 $(OLDSOVER): $(OBJSDLL)
140 $(CC) -shared -Wl,-soname,$(OLDSOMAJ) \
144 pngtest: pngtest.o $(LIBSO)
145 $(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS)
147 pngtest-static: pngtest.o libpng.a
148 $(CC) -o pngtest-static $(CFLAGS) pngtest.o $(LDFLAGS_A)
150 test: pngtest pngtest-static
152 @echo " Running pngtest dynamically linked with $(LIBSO):"
156 @echo " Running pngtest statically linked with libpng.a:"
160 install-headers: png.h pngconf.h
161 -@if [ ! -d $(DI) ]; then $(MKDIR_P) $(DI); fi
162 -@if [ ! -d $(DI)/$(LIBNAME) ]; then $(MKDIR_P) $(DI)/$(LIBNAME); fi
163 cp png.h pngconf.h $(DI)/$(LIBNAME)
164 chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h
165 -@$(RM_F) $(DI)/png.h $(DI)/pngconf.h
166 -@$(RM_F) $(DI)/libpng
167 (cd $(DI); $(LN_SF) $(LIBNAME) libpng; $(LN_SF) $(LIBNAME)/* .)
169 install-static: install-headers libpng.a
170 -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi
171 cp libpng.a $(DL)/$(LIBNAME).a
172 chmod 644 $(DL)/$(LIBNAME).a
173 -@$(RM_F) $(DL)/libpng.a
174 (cd $(DL); $(LN_SF) $(LIBNAME).a libpng.a)
176 install-shared: install-headers $(LIBSOVER) libpng.pc \
178 -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi
179 -@$(RM_F) $(DL)/$(LIBSOVER)* $(DL)/$(LIBSO)
180 -@$(RM_F) $(DL)/$(LIBSOMAJ)
181 -@$(RM_F) $(DL)/$(OLDSO)
182 -@$(RM_F) $(DL)/$(OLDSOMAJ)
183 -@$(RM_F) $(DL)/$(OLDSOVER)*
186 chmod 755 $(DL)/$(LIBSOVER)
187 chmod 755 $(DL)/$(OLDSOVER)
189 $(LN_SF) $(OLDSOVER) $(OLDSOMAJ); \
190 $(LN_SF) $(OLDSOMAJ) $(OLDSO); \
191 $(LN_SF) $(LIBSOVER) $(LIBSOMAJ); \
192 $(LN_SF) $(LIBSOMAJ) $(LIBSO))
193 -@if [ ! -d $(DL)/pkgconfig ]; then $(MKDIR_P) $(DL)/pkgconfig; fi
194 -@$(RM_F) $(DL)/pkgconfig/$(LIBNAME).pc
195 -@$(RM_F) $(DL)/pkgconfig/libpng.pc
196 cp libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc
197 chmod 644 $(DL)/pkgconfig/$(LIBNAME).pc
198 (cd $(DL)/pkgconfig; $(LN_SF) $(LIBNAME).pc libpng.pc)
200 install-man: libpng.3 libpngpf.3 png.5
201 -@if [ ! -d $(DM) ]; then $(MKDIR_P) $(DM); fi
202 -@if [ ! -d $(DM)/man3 ]; then $(MKDIR_P) $(DM)/man3; fi
203 -@$(RM_F) $(DM)/man3/libpng.3
204 -@$(RM_F) $(DM)/man3/libpngpf.3
205 cp libpng.3 $(DM)/man3
206 cp libpngpf.3 $(DM)/man3
207 -@if [ ! -d $(DM)/man5 ]; then $(MKDIR_P) $(DM)/man5; fi
208 -@$(RM_F) $(DM)/man5/png.5
211 install-config: libpng-config
212 -@if [ ! -d $(DB) ]; then $(MKDIR_P) $(DB); fi
213 -@$(RM_F) $(DB)/libpng-config
214 -@$(RM_F) $(DB)/$(LIBNAME)-config
215 cp libpng-config $(DB)/$(LIBNAME)-config
216 chmod 755 $(DB)/$(LIBNAME)-config
217 (cd $(DB); $(LN_SF) $(LIBNAME)-config libpng-config)
219 install: install-static install-shared install-man install-config
221 # If you installed in $(DESTDIR), test-installed won't work until you
222 # move the library to its final location. Use test-dd to test it
227 echo Testing installed dynamic shared library in $(DL).
228 $(CC) -I$(DI) -I$(ZLIBINC) \
229 `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \
230 -L$(DL) -L$(ZLIBLIB) -Wl, -rpath,$(DL) -Wl,-rpath,$(ZLIBLIB) \
231 -o pngtestd `$(BINPATH)/$(LIBNAME)-config --ldflags`
232 ./pngtestd pngtest.png
236 `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \
237 -L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) \
238 -o pngtesti `$(BINPATH)/$(LIBNAME)-config --ldflags`
239 ./pngtesti pngtest.png
242 $(RM_F) *.o libpng.a pngtest pngout.png libpng-config \
243 $(LIBSO) $(LIBSOMAJ)* pngtest-static pngtesti \
247 DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO
249 chmod a-w *.[ch35] $(DOCS) scripts/*
251 png.o png.pic.o: png.h pngconf.h png.c
252 pngerror.o pngerror.pic.o: png.h pngconf.h pngerror.c
253 pngrio.o pngrio.pic.o: png.h pngconf.h pngrio.c
254 pngwio.o pngwio.pic.o: png.h pngconf.h pngwio.c
255 pngmem.o pngmem.pic.o: png.h pngconf.h pngmem.c
256 pngset.o pngset.pic.o: png.h pngconf.h pngset.c
257 pngget.o pngget.pic.o: png.h pngconf.h pngget.c
258 pngread.o pngread.pic.o: png.h pngconf.h pngread.c
259 pngrtran.o pngrtran.pic.o: png.h pngconf.h pngrtran.c
260 pngrutil.o pngrutil.pic.o: png.h pngconf.h pngrutil.c
261 pngtrans.o pngtrans.pic.o: png.h pngconf.h pngtrans.c
262 pngwrite.o pngwrite.pic.o: png.h pngconf.h pngwrite.c
263 pngwtran.o pngwtran.pic.o: png.h pngconf.h pngwtran.c
264 pngwutil.o pngwutil.pic.o: png.h pngconf.h pngwutil.c
265 pngpread.o pngpread.pic.o: png.h pngconf.h pngpread.c
267 pngtest.o: png.h pngconf.h pngtest.c