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 # WARNING: The assembler code in pnggccrd.c may not be thread safe.
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.
20 PNGVER = $(PNGMAJ).$(PNGMIN)
22 # Shared library names:
24 LIBSOMAJ=$(LIBNAME).so.$(PNGMAJ)
25 LIBSOVER=$(LIBNAME).so.$(PNGVER)
28 OLDSOVER=libpng.so.3.$(PNGMIN)
39 # where "make install" puts libpng12.a, libpng12.so*,
40 # libpng12/png.h and libpng12/pngconf.h
41 # Prefix must be a full pathname.
45 # Where the zlib library and include files are located.
46 #ZLIBLIB=/usr/local/lib
47 #ZLIBINC=/usr/local/include
53 #ALIGN=-malign-loops=2 -malign-functions=2
55 WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow \
56 -Wmissing-declarations -Wtraditional -Wcast-align \
57 -Wstrict-prototypes -Wmissing-prototypes #-Wconversion
59 # for pgcc version 2.95.1, -O3 is buggy; don't use it.
61 # Remove -DPNG_THREAD_UNSAFE_OK if you need thread safety
63 CFLAGS=-DPNG_THREAD_UNSAFE_OK -DPNG_USE_PNGGCCRD -I$(ZLIBINC) -Wall \
64 -O3 $(ALIGN) -funroll-loops \
65 -fomit-frame-pointer # $(WARNMORE) -g -DPNG_DEBUG=5
66 ### for gcc 2.95.2 on 686:
67 #CFLAGS=-DPNG_THREAD_UNSAFE_OK -DPNG_USE_PNGGCCRD -I$(ZLIBINC) -Wall -O3 \
68 # -mcpu=i686 -malign-double -ffast-math -fstrict-aliasing \
69 # $(ALIGN) -funroll-loops -funroll-all-loops -fomit-frame-pointer
70 ### for gcc 2.7.2.3 on 486 and up:
71 #CFLAGS=-DPNG_THREAD_UNSAFE_OK -DPNG_USE_PNGGCCRD -I$(ZLIBINC) -Wall -O3 \
72 # -m486 -malign-double -ffast-math \
73 # $(ALIGN) -funroll-loops -funroll-all-loops -fomit-frame-pointer
75 LDFLAGS=-L. -Wl,-rpath,. -L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) -lpng12 -lz -lm
76 LDFLAGS_A=-L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) libpng.a -lz -lm
79 INCPATH=$(prefix)/include
80 LIBPATH=$(exec_prefix)/lib
82 BINPATH=$(exec_prefix)/bin
84 # override DESTDIR= on the make install command line to easily support
85 # installing into a temporary location. Example:
87 # make install DESTDIR=/tmp/build/libpng
89 # If you're going to install into a temporary location
90 # via DESTDIR, $(DESTDIR)$(prefix) must already exist before
91 # you execute make install.
94 DB=$(DESTDIR)$(BINPATH)
95 DI=$(DESTDIR)$(INCPATH)
96 DL=$(DESTDIR)$(LIBPATH)
97 DM=$(DESTDIR)$(MANPATH)
99 OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \
100 pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \
101 pngwtran.o pngmem.o pngerror.o pngpread.o pnggccrd.o
103 OBJSDLL = $(OBJS:.o=.pic.o)
105 .SUFFIXES: .c .o .pic.o
108 $(CC) -c $(CFLAGS) -fPIC -o $@ $*.c
110 all: libpng.a $(LIBSO) pngtest pngtest-static libpng.pc libpng-config
117 cat scripts/libpng.pc.in | sed -e s\!@PREFIX@!$(prefix)! > libpng.pc
120 ( cat scripts/libpng-config-head.in; \
121 echo prefix=\"$(prefix)\"; \
122 echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \
123 echo cppflags=\"-DPNG_THREAD_UNSAFE_OK -DPNG_USE_PNGGCCRD\"; \
124 echo L_opts=\"-L$(LIBPATH)\"; \
125 echo R_opts=\"-Wl,-rpath,$(LIBPATH)\"; \
126 echo libs=\"-lpng12 -lz -lm\"; \
127 cat scripts/libpng-config-body.in ) > libpng-config
128 chmod +x libpng-config
130 pnggccrd.o: pnggccrd.c png.h pngconf.h
131 $(CC) -c $(CFLAGS) -o $@ $*.c
133 pnggccrd.pic.o: pnggccrd.c png.h pngconf.h
134 $(CC) -c $(CFLAGS) -fPIC -o $@ pnggccrd.c
136 $(LIBSO): $(LIBSOMAJ)
137 $(LN_SF) $(LIBSOMAJ) $(LIBSO)
139 $(LIBSOMAJ): $(LIBSOVER)
140 $(LN_SF) $(LIBSOVER) $(LIBSOMAJ)
142 $(LIBSOVER): $(OBJSDLL)
143 $(CC) -shared -Wl,-soname,$(LIBSOMAJ) \
147 $(OLDSOVER): $(OBJSDLL)
148 $(CC) -shared -Wl,-soname,$(OLDSOMAJ) \
152 pngtest: pngtest.o $(LIBSO)
153 $(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS)
155 pngtest-static: pngtest.o libpng.a
156 $(CC) -o pngtest-static $(CFLAGS) pngtest.o $(LDFLAGS_A)
158 test: pngtest pngtest-static
160 @echo " Running pngtest dynamically linked with $(LIBSO):"
164 @echo " Running pngtest statically linked with libpng.a:"
168 install-headers: png.h pngconf.h
169 -@if [ ! -d $(DI) ]; then $(MKDIR_P) $(DI); fi
170 -@if [ ! -d $(DI)/$(LIBNAME) ]; then $(MKDIR_P) $(DI)/$(LIBNAME); fi
171 cp png.h pngconf.h $(DI)/$(LIBNAME)
172 chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h
173 -@$(RM_F) $(DI)/png.h $(DI)/pngconf.h
174 -@$(RM_F) $(DI)/libpng
175 (cd $(DI); $(LN_SF) $(LIBNAME) libpng; $(LN_SF) $(LIBNAME)/* .)
177 install-static: install-headers libpng.a
178 -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi
179 cp libpng.a $(DL)/$(LIBNAME).a
180 chmod 644 $(DL)/$(LIBNAME).a
181 -@$(RM_F) $(DL)/libpng.a
182 (cd $(DL); $(LN_SF) $(LIBNAME).a libpng.a)
184 install-shared: install-headers $(LIBSOVER) libpng.pc \
186 -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi
187 -@$(RM_F) $(DL)/$(LIBSOVER)* $(DL)/$(LIBSO)
188 -@$(RM_F) $(DL)/$(LIBSOMAJ)
189 -@$(RM_F) $(DL)/$(OLDSO)
190 -@$(RM_F) $(DL)/$(OLDSOMAJ)
191 -@$(RM_F) $(DL)/$(OLDSOVER)*
194 chmod 755 $(DL)/$(LIBSOVER)
195 chmod 755 $(DL)/$(OLDSOVER)
197 $(LN_SF) $(OLDSOVER) $(OLDSOMAJ); \
198 $(LN_SF) $(OLDSOMAJ) $(OLDSO); \
199 $(LN_SF) $(LIBSOVER) $(LIBSOMAJ); \
200 $(LN_SF) $(LIBSOMAJ) $(LIBSO))
201 -@if [ ! -d $(DL)/pkgconfig ]; then $(MKDIR_P) $(DL)/pkgconfig; fi
202 -@$(RM_F) $(DL)/pkgconfig/$(LIBNAME).pc
203 -@$(RM_F) $(DL)/pkgconfig/libpng.pc
204 cp libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc
205 chmod 644 $(DL)/pkgconfig/$(LIBNAME).pc
206 (cd $(DL)/pkgconfig; $(LN_SF) $(LIBNAME).pc libpng.pc)
208 install-man: libpng.3 libpngpf.3 png.5
209 -@if [ ! -d $(DM) ]; then $(MKDIR_P) $(DM); fi
210 -@if [ ! -d $(DM)/man3 ]; then $(MKDIR_P) $(DM)/man3; fi
211 -@$(RM_F) $(DM)/man3/libpng.3
212 -@$(RM_F) $(DM)/man3/libpngpf.3
213 cp libpng.3 $(DM)/man3
214 cp libpngpf.3 $(DM)/man3
215 -@if [ ! -d $(DM)/man5 ]; then $(MKDIR_P) $(DM)/man5; fi
216 -@$(RM_F) $(DM)/man5/png.5
219 install-config: libpng-config
220 -@if [ ! -d $(DB) ]; then $(MKDIR_P) $(DB); fi
221 -@$(RM_F) $(DB)/libpng-config
222 -@$(RM_F) $(DB)/$(LIBNAME)-config
223 cp libpng-config $(DB)/$(LIBNAME)-config
224 chmod 755 $(DB)/$(LIBNAME)-config
225 (cd $(DB); $(LN_SF) $(LIBNAME)-config libpng-config)
227 install: install-static install-shared install-man install-config
229 # If you installed in $(DESTDIR), test-installed won't work until you
230 # move the library to its final location. Use test-dd to test it
235 echo Testing installed dynamic shared library in $(DL).
236 $(CC) -I$(DI) -I$(ZLIBINC) \
237 `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \
238 -L$(DL) -L$(ZLIBLIB) -Wl, -rpath,$(DL) -Wl,-rpath,$(ZLIBLIB) \
239 -o pngtestd `$(BINPATH)/$(LIBNAME)-config --ldflags`
240 ./pngtestd pngtest.png
244 `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \
245 -L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) \
246 -o pngtesti `$(BINPATH)/$(LIBNAME)-config --ldflags`
247 ./pngtesti pngtest.png
250 $(RM_F) *.o libpng.a pngtest pngout.png libpng-config \
251 $(LIBSO) $(LIBSOMAJ)* pngtest-static pngtesti \
255 DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO
257 chmod a-w *.[ch35] $(DOCS) scripts/*
259 png.o png.pic.o: png.h pngconf.h png.c
260 pngerror.o pngerror.pic.o: png.h pngconf.h pngerror.c
261 pngrio.o pngrio.pic.o: png.h pngconf.h pngrio.c
262 pngwio.o pngwio.pic.o: png.h pngconf.h pngwio.c
263 pngmem.o pngmem.pic.o: png.h pngconf.h pngmem.c
264 pngset.o pngset.pic.o: png.h pngconf.h pngset.c
265 pngget.o pngget.pic.o: png.h pngconf.h pngget.c
266 pngread.o pngread.pic.o: png.h pngconf.h pngread.c
267 pngrtran.o pngrtran.pic.o: png.h pngconf.h pngrtran.c
268 pngrutil.o pngrutil.pic.o: png.h pngconf.h pngrutil.c
269 pngtrans.o pngtrans.pic.o: png.h pngconf.h pngtrans.c
270 pngwrite.o pngwrite.pic.o: png.h pngconf.h pngwrite.c
271 pngwtran.o pngwtran.pic.o: png.h pngconf.h pngwtran.c
272 pngwutil.o pngwutil.pic.o: png.h pngconf.h pngwutil.c
273 pngpread.o pngpread.pic.o: png.h pngconf.h pngpread.c
275 pngtest.o: png.h pngconf.h pngtest.c