1 # makefile for libpng.a and libpng15.so on Linux ELF with gcc
2 # Copyright (C) 1998, 1999, 2002, 2006, 2008, 2010-2011 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).15 is a symlink rather than a different library
20 # Shared library names:
22 LIBSOMAJ=$(LIBNAME).so.$(PNGMAJ)
23 LIBSOREL=$(LIBSOMAJ).$(RELEASE)
35 # where "make install" puts libpng15.a, libpng15.so*,
36 # libpng15/png.h, libpng15/pngconf.h, and libpng15/pnglibconf.h
37 # Prefix must be a full pathname.
41 # Where the zlib library and include files are located.
42 ZLIBLIB=/usr/local/lib
43 ZLIBINC=/usr/local/include
49 #ALIGN=-malign-loops=2 -malign-functions=2
51 WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow \
52 -Wmissing-declarations -Wtraditional -Wcast-align \
53 -Wstrict-prototypes -Wmissing-prototypes #-Wconversion
55 # for pgcc version 2.95.1, -O3 is buggy; don't use it.
57 CFLAGS=-W -Wall -D_REENTRANT -O2 \
58 $(ALIGN) # $(WARNMORE) -g -DPNG_DEBUG=5
61 LDFLAGS_A=libpng.a -lz -lm
65 INCPATH=$(prefix)/include
66 LIBPATH=$(exec_prefix)/lib
68 BINPATH=$(exec_prefix)/bin
70 # override DESTDIR= on the make install command line to easily support
71 # installing into a temporary location. Example:
73 # make install DESTDIR=/tmp/build/libpng
75 # If you're going to install into a temporary location
76 # via DESTDIR, $(DESTDIR)$(prefix) must already exist before
77 # you execute make install.
80 DB=$(DESTDIR)$(BINPATH)
81 DI=$(DESTDIR)$(INCPATH)
82 DL=$(DESTDIR)$(LIBPATH)
83 DM=$(DESTDIR)$(MANPATH)
85 OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \
86 pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \
87 pngwtran.o pngmem.o pngerror.o pngpread.o
89 OBJSDLL = $(OBJS:.o=.pic.o)
91 .SUFFIXES: .c .o .pic.o
94 $(CC) -c $(CFLAGS) -fPIC -o $@ $*.c
96 all: libpng.a $(LIBSO) pngtest pngtest-static libpng.pc libpng-config
98 # see scripts/pnglibconf.mak for more options
99 pnglibconf.h: scripts/pnglibconf.h.prebuilt
100 cp scripts/pnglibconf.h.prebuilt $@
107 cat scripts/libpng.pc.in | sed -e s!@prefix@!$(prefix)! \
108 -e s!@exec_prefix@!$(exec_prefix)! \
109 -e s!@libdir@!$(LIBPATH)! \
110 -e s!@includedir@!$(INCPATH)! \
111 -e s!-lpng15!-lpng15\ -lz\ -lm! > libpng.pc
113 libpng.syms: png.h pngconf.h pnglibconf.h
114 $(CC) $(CFLAGS) -E -DPNG_BUILDSYMS -DPNG_INTERNAL png.h |\
115 awk -F '[\t [\\]();]' -v PNGMAJ=$(PNGMAJ) 'BEGIN{printf("PNG15_%s {global:\n",PNGMAJ)}\
116 { for (i=1;i+2<=NF;++i)\
117 if ($$(i)=="PNG_FUNCTION_EXPORT" && $$(i+2)=="END")\
119 for (i=1;i+1<=NF;++i)\
120 if ($$(i)=="PNG_DATA_EXPORT")\
122 END{print "local: *; };"}' >$@.new
127 ( cat scripts/libpng-config-head.in; \
128 echo prefix=\"$(prefix)\"; \
129 echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \
132 echo libs=\"-lpng15\"; \
133 echo all_libs=\"-lpng15 $(LIBADDFLAGS)\"; \
134 cat scripts/libpng-config-body.in ) > libpng-config
135 chmod +x libpng-config
137 $(LIBSO): $(LIBSOMAJ)
138 $(LN_SF) $(LIBSOMAJ) $(LIBSO)
140 $(LIBSOMAJ): $(OBJSDLL) libpng.syms
141 $(CC) -shared -Wl,-soname,$(LIBSOMAJ) \
142 -Wl,-version-script,libpng.syms \
146 pngtest: pngtest.o $(LIBSO)
147 $(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS)
149 pngtest-static: pngtest.o libpng.a
150 $(CC) -o pngtest-static $(CFLAGS) pngtest.o $(LDFLAGS_A)
152 test: pngtest pngtest-static
154 @echo " Running pngtest dynamically linked with $(LIBSO):"
156 LD_LIBRARY_PATH=".:${LD_LIBRARY_PATH}" ./pngtest
158 @echo " Running pngtest statically linked with libpng.a:"
162 install-headers: png.h pngconf.h pnglibconf.h
163 -@if [ ! -d $(DI) ]; then $(MKDIR_P) $(DI); fi
164 -@if [ ! -d $(DI)/$(LIBNAME) ]; then $(MKDIR_P) $(DI)/$(LIBNAME); fi
165 cp png.h pngconf.h pnglibconf.h $(DI)/$(LIBNAME)
166 chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h $(DI)/$(LIBNAME)/pnglibconf.h
167 -@$(RM_F) $(DI)/png.h $(DI)/pngconf.h $(DI)/pnglibconf.h
168 -@$(RM_F) $(DI)/libpng
169 (cd $(DI); $(LN_SF) $(LIBNAME) libpng; $(LN_SF) $(LIBNAME)/* .)
171 install-static: install-headers libpng.a
172 -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi
173 cp libpng.a $(DL)/$(LIBNAME).a
174 chmod 644 $(DL)/$(LIBNAME).a
175 -@$(RM_F) $(DL)/libpng.a
176 (cd $(DL); $(LN_SF) $(LIBNAME).a libpng.a)
178 install-shared: install-headers $(LIBSOMAJ) libpng.pc
179 -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi
180 -@$(RM_F) $(DL)/$(LIBSO)
181 -@$(RM_F) $(DL)/$(LIBSOREL)
182 -@$(RM_F) $(DL)/$(OLDSO)
183 cp $(LIBSOMAJ) $(DL)/$(LIBSOREL)
184 chmod 755 $(DL)/$(LIBSOREL)
186 $(LN_SF) $(LIBSOREL) $(LIBSO); \
187 $(LN_SF) $(LIBSO) $(OLDSO))
188 -@if [ ! -d $(DL)/pkgconfig ]; then $(MKDIR_P) $(DL)/pkgconfig; fi
189 -@$(RM_F) $(DL)/pkgconfig/$(LIBNAME).pc
190 -@$(RM_F) $(DL)/pkgconfig/libpng.pc
191 cp libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc
192 chmod 644 $(DL)/pkgconfig/$(LIBNAME).pc
193 (cd $(DL)/pkgconfig; $(LN_SF) $(LIBNAME).pc libpng.pc)
195 install-man: libpng.3 libpngpf.3 png.5
196 -@if [ ! -d $(DM) ]; then $(MKDIR_P) $(DM); fi
197 -@if [ ! -d $(DM)/man3 ]; then $(MKDIR_P) $(DM)/man3; fi
198 -@$(RM_F) $(DM)/man3/libpng.3
199 -@$(RM_F) $(DM)/man3/libpngpf.3
200 cp libpng.3 $(DM)/man3
201 cp libpngpf.3 $(DM)/man3
202 -@if [ ! -d $(DM)/man5 ]; then $(MKDIR_P) $(DM)/man5; fi
203 -@$(RM_F) $(DM)/man5/png.5
206 install-config: libpng-config
207 -@if [ ! -d $(DB) ]; then $(MKDIR_P) $(DB); fi
208 -@$(RM_F) $(DB)/libpng-config
209 -@$(RM_F) $(DB)/$(LIBNAME)-config
210 cp libpng-config $(DB)/$(LIBNAME)-config
211 chmod 755 $(DB)/$(LIBNAME)-config
212 (cd $(DB); $(LN_SF) $(LIBNAME)-config libpng-config)
214 install: install-static install-shared install-man install-config
216 # If you installed in $(DESTDIR), test-installed won't work until you
217 # move the library to its final location. Use test-dd to test it
222 echo Testing installed dynamic shared library in $(DL).
223 $(CC) -I$(DI) -I$(ZLIBINC) \
224 `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \
225 -L$(DL) -L$(ZLIBLIB) -Wl, -rpath,$(DL) -Wl,-rpath,$(ZLIBLIB) \
226 -o pngtestd `$(BINPATH)/$(LIBNAME)-config --ldflags`
227 ./pngtestd pngtest.png
231 `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \
232 -L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) \
233 -o pngtesti `$(BINPATH)/$(LIBNAME)-config --ldflags`
234 ./pngtesti pngtest.png
237 $(RM_F) *.o libpng.a libpng.syms pngtest pngout.png libpng-config \
238 $(LIBSO) $(LIBSOMAJ)* pngtest-static pngtesti \
239 libpng.pc pnglibconf.h
241 DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO
243 chmod a-w *.[ch35] $(DOCS) scripts/*
245 # DO NOT DELETE THIS LINE -- make depend depends on it.
247 png.o png.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
248 pngerror.o pngerror.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
249 pngrio.o pngrio.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
250 pngwio.o pngwio.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
251 pngmem.o pngmem.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
252 pngset.o pngset.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
253 pngget.o pngget.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
254 pngread.o pngread.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
255 pngrtran.o pngrtran.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
256 pngrutil.o pngrutil.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
257 pngtrans.o pngtrans.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
258 pngwrite.o pngwrite.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
259 pngwtran.o pngwtran.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
260 pngwutil.o pngwutil.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
261 pngpread.o pngpread.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
263 pngtest.o: png.h pngconf.h pnglibconf.h