1 # makefile for libpng.a and libpng12.so on Linux ELF with gcc
2 # Copyright (C) 1998, 1999, 2002, 2006, 2008 Greg Roelofs
3 # and Glenn Randers-Pehrson
4 # Copyright (C) 1996, 1997 Andreas Dilger
6 # This code is released under the libpng license.
7 # For conditions of distribution and use, see the disclaimer
10 # Modified for Debian by Junichi Uekawa and Josselin Mouette
11 # Major modifications are:
12 # * link libpng explicitly with libz and libm
13 # * $(OLDSO).3 is a symlink rather than a different library
20 PNGVER = $(PNGMAJ).$(PNGMIN)
22 # Shared library names:
24 LIBSOMAJ=$(LIBNAME).so.$(PNGMAJ)
25 LIBSOVER=$(LIBNAME).so.$(PNGVER)
28 OLDSOVER=libpng.so.3.$(PNGMIN)
38 # where "make install" puts libpng12.a, libpng12.so*,
39 # libpng12/png.h and libpng12/pngconf.h
40 # Prefix must be a full pathname.
44 # Where the zlib library and include files are located.
45 ZLIBLIB=/usr/local/lib
46 ZLIBINC=/usr/local/include
52 #ALIGN=-malign-loops=2 -malign-functions=2
54 WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow \
55 -Wmissing-declarations -Wtraditional -Wcast-align \
56 -Wstrict-prototypes -Wmissing-prototypes #-Wconversion
58 # for pgcc version 2.95.1, -O3 is buggy; don't use it.
60 CFLAGS=-W -Wall -D_REENTRANT -O2 \
61 $(ALIGN) # $(WARNMORE) -g -DPNG_DEBUG=5
64 LDFLAGS_A=libpng.a -lz -lm
68 INCPATH=$(prefix)/include
69 LIBPATH=$(exec_prefix)/lib
71 BINPATH=$(exec_prefix)/bin
73 # override DESTDIR= on the make install command line to easily support
74 # installing into a temporary location. Example:
76 # make install DESTDIR=/tmp/build/libpng
78 # If you're going to install into a temporary location
79 # via DESTDIR, $(DESTDIR)$(prefix) must already exist before
80 # you execute make install.
83 DB=$(DESTDIR)$(BINPATH)
84 DI=$(DESTDIR)$(INCPATH)
85 DL=$(DESTDIR)$(LIBPATH)
86 DM=$(DESTDIR)$(MANPATH)
88 OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \
89 pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \
90 pngwtran.o pngmem.o pngerror.o pngpread.o
92 OBJSDLL = $(OBJS:.o=.pic.o)
94 .SUFFIXES: .c .o .pic.o
97 $(CC) -c $(CFLAGS) -fPIC -o $@ $*.c
99 all: libpng.a $(LIBSO) pngtest pngtest-static libpng.pc libpng-config
106 cat scripts/libpng.pc.in | sed -e s!@prefix@!$(prefix)! \
107 -e s!@exec_prefix@!$(exec_prefix)! \
108 -e s!@libdir@!$(LIBPATH)! \
109 -e s!@includedir@!$(INCPATH)! \
110 -e s!-lpng12!-lpng12\ -lz\ -lm! > libpng.pc
112 libpng.syms: png.h pngconf.h
113 $(CC) $(CFLAGS) -E -DPNG_BUILDSYMS -DPNG_INTERNAL png.h |\
114 awk -F '[\t [\\]();]' -v PNGMAJ=$(PNGMAJ) 'BEGIN{printf("PNG12_%s {global:\n",PNGMAJ)}\
115 { for (i=1;i+2<=NF;++i)\
116 if ($$(i)=="PNG_FUNCTION_EXPORT" && $$(i+2)=="END")\
118 for (i=1;i+1<=NF;++i)\
119 if ($$(i)=="PNG_DATA_EXPORT")\
121 END{print "local: *; };"}' >$@.new
126 ( cat scripts/libpng-config-head.in; \
127 echo prefix=\"$(prefix)\"; \
128 echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \
131 echo libs=\"-lpng12\"; \
132 echo all_libs=\"-lpng12 $(LIBADDFLAGS)\"; \
133 cat scripts/libpng-config-body.in ) > libpng-config
134 chmod +x libpng-config
136 $(LIBSO): $(LIBSOMAJ)
137 $(LN_SF) $(LIBSOMAJ) $(LIBSO)
139 $(LIBSOMAJ): $(LIBSOVER)
140 $(LN_SF) $(LIBSOVER) $(LIBSOMAJ)
142 $(LIBSOVER): $(OBJSDLL) libpng.syms
143 $(CC) -shared -Wl,-soname,$(LIBSOMAJ) \
144 -Wl,-version-script,libpng.syms \
148 $(OLDSOVER): $(OBJSDLL) libpng.syms
149 $(CC) -shared -Wl,-soname,$(OLDSOMAJ) \
150 -Wl,-version-script,libpng.syms \
154 pngtest: pngtest.o $(LIBSO)
155 $(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS)
157 pngtest-static: pngtest.o libpng.a
158 $(CC) -o pngtest-static $(CFLAGS) pngtest.o $(LDFLAGS_A)
160 test: pngtest pngtest-static
162 @echo " Running pngtest dynamically linked with $(LIBSO):"
164 LD_LIBRARY_PATH=".:${LD_LIBRARY_PATH}" ./pngtest
166 @echo " Running pngtest statically linked with libpng.a:"
170 install-headers: png.h pngconf.h
171 -@if [ ! -d $(DI) ]; then $(MKDIR_P) $(DI); fi
172 -@if [ ! -d $(DI)/$(LIBNAME) ]; then $(MKDIR_P) $(DI)/$(LIBNAME); fi
173 cp png.h pngconf.h $(DI)/$(LIBNAME)
174 chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h
175 -@$(RM_F) $(DI)/png.h $(DI)/pngconf.h
176 -@$(RM_F) $(DI)/libpng
177 (cd $(DI); $(LN_SF) $(LIBNAME) libpng; $(LN_SF) $(LIBNAME)/* .)
179 install-static: install-headers libpng.a
180 -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi
181 cp libpng.a $(DL)/$(LIBNAME).a
182 chmod 644 $(DL)/$(LIBNAME).a
183 -@$(RM_F) $(DL)/libpng.a
184 (cd $(DL); $(LN_SF) $(LIBNAME).a libpng.a)
186 install-shared: install-headers $(LIBSOVER) libpng.pc \
188 -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi
189 -@$(RM_F) $(DL)/$(LIBSOVER)* $(DL)/$(LIBSO)
190 -@$(RM_F) $(DL)/$(LIBSOMAJ)
191 -@$(RM_F) $(DL)/$(OLDSO)
192 -@$(RM_F) $(DL)/$(OLDSOMAJ)
193 -@$(RM_F) $(DL)/$(OLDSOVER)*
196 chmod 755 $(DL)/$(LIBSOVER)
197 chmod 755 $(DL)/$(OLDSOVER)
199 $(LN_SF) $(OLDSOVER) $(OLDSOMAJ); \
200 $(LN_SF) $(OLDSOMAJ) $(OLDSO); \
201 $(LN_SF) $(LIBSOVER) $(LIBSOMAJ); \
202 $(LN_SF) $(LIBSOMAJ) $(LIBSO))
203 -@if [ ! -d $(DL)/pkgconfig ]; then $(MKDIR_P) $(DL)/pkgconfig; fi
204 -@$(RM_F) $(DL)/pkgconfig/$(LIBNAME).pc
205 -@$(RM_F) $(DL)/pkgconfig/libpng.pc
206 cp libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc
207 chmod 644 $(DL)/pkgconfig/$(LIBNAME).pc
208 (cd $(DL)/pkgconfig; $(LN_SF) $(LIBNAME).pc libpng.pc)
210 install-man: libpng.3 libpngpf.3 png.5
211 -@if [ ! -d $(DM) ]; then $(MKDIR_P) $(DM); fi
212 -@if [ ! -d $(DM)/man3 ]; then $(MKDIR_P) $(DM)/man3; fi
213 -@$(RM_F) $(DM)/man3/libpng.3
214 -@$(RM_F) $(DM)/man3/libpngpf.3
215 cp libpng.3 $(DM)/man3
216 cp libpngpf.3 $(DM)/man3
217 -@if [ ! -d $(DM)/man5 ]; then $(MKDIR_P) $(DM)/man5; fi
218 -@$(RM_F) $(DM)/man5/png.5
221 install-config: libpng-config
222 -@if [ ! -d $(DB) ]; then $(MKDIR_P) $(DB); fi
223 -@$(RM_F) $(DB)/libpng-config
224 -@$(RM_F) $(DB)/$(LIBNAME)-config
225 cp libpng-config $(DB)/$(LIBNAME)-config
226 chmod 755 $(DB)/$(LIBNAME)-config
227 (cd $(DB); $(LN_SF) $(LIBNAME)-config libpng-config)
229 install: install-static install-shared install-man install-config
231 # If you installed in $(DESTDIR), test-installed won't work until you
232 # move the library to its final location. Use test-dd to test it
237 echo Testing installed dynamic shared library in $(DL).
238 $(CC) -I$(DI) -I$(ZLIBINC) \
239 `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \
240 -L$(DL) -L$(ZLIBLIB) -Wl, -rpath,$(DL) -Wl,-rpath,$(ZLIBLIB) \
241 -o pngtestd `$(BINPATH)/$(LIBNAME)-config --ldflags`
242 ./pngtestd pngtest.png
246 `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \
247 -L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) \
248 -o pngtesti `$(BINPATH)/$(LIBNAME)-config --ldflags`
249 ./pngtesti pngtest.png
252 $(RM_F) *.o libpng.a libpng.syms pngtest pngout.png libpng-config \
253 $(LIBSO) $(LIBSOMAJ)* pngtest-static pngtesti \
257 DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO
259 chmod a-w *.[ch35] $(DOCS) scripts/*
261 # DO NOT DELETE THIS LINE -- make depend depends on it.
263 png.o png.pic.o: png.h pngconf.h
264 pngerror.o pngerror.pic.o: png.h pngconf.h
265 pngrio.o pngrio.pic.o: png.h pngconf.h
266 pngwio.o pngwio.pic.o: png.h pngconf.h
267 pngmem.o pngmem.pic.o: png.h pngconf.h
268 pngset.o pngset.pic.o: png.h pngconf.h
269 pngget.o pngget.pic.o: png.h pngconf.h
270 pngread.o pngread.pic.o: png.h pngconf.h
271 pngrtran.o pngrtran.pic.o: png.h pngconf.h
272 pngrutil.o pngrutil.pic.o: png.h pngconf.h
273 pngtrans.o pngtrans.pic.o: png.h pngconf.h
274 pngwrite.o pngwrite.pic.o: png.h pngconf.h
275 pngwtran.o pngwtran.pic.o: png.h pngconf.h
276 pngwutil.o pngwutil.pic.o: png.h pngconf.h
277 pngpread.o pngpread.pic.o: png.h pngconf.h
279 pngtest.o: png.h pngconf.h