1 # makefile for libpng.a and libpng16.so on Linux ELF with gcc
2 # Copyright (C) 1998, 1999, 2002, 2006, 2008, 2010-2014 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).16 is a symlink rather than a different library
20 # Shared library names:
22 LIBSOMAJ=$(LIBNAME).so.$(PNGMAJ)
23 LIBSOREL=$(LIBSOMAJ).$(RELEASE)
36 # where "make install" puts libpng16.a, libpng16.so*,
37 # libpng16/png.h, libpng16/pngconf.h, and libpng16/pnglibconf.h
38 # Prefix must be a full pathname.
42 # Where the zlib library and include files are located.
43 ZLIBLIB=/usr/local/lib
44 ZLIBINC=/usr/local/include
50 #ALIGN=-malign-loops=2 -malign-functions=2
52 WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow \
53 -Wmissing-declarations -Wtraditional -Wcast-align \
54 -Wstrict-prototypes -Wmissing-prototypes #-Wconversion
56 # for pgcc version 2.95.1, -O3 is buggy; don't use it.
58 CPPFLAGS=-D_REENTRANT # -DPNG_DEBUG=5
59 CFLAGS=-W -Wall -O2 $(ALIGN) # $(WARNMORE) -g
62 LDFLAGS_A=libpng.a -lz -lm
66 INCPATH=$(prefix)/include
67 LIBPATH=$(exec_prefix)/lib
69 BINPATH=$(exec_prefix)/bin
71 # override DESTDIR= on the make install command line to easily support
72 # installing into a temporary location. Example:
74 # make install DESTDIR=/tmp/build/libpng
76 # If you're going to install into a temporary location
77 # via DESTDIR, $(DESTDIR)$(prefix) must already exist before
78 # you execute make install.
81 DB=$(DESTDIR)$(BINPATH)
82 DI=$(DESTDIR)$(INCPATH)
83 DL=$(DESTDIR)$(LIBPATH)
84 DM=$(DESTDIR)$(MANPATH)
86 # Pre-built configuration
87 # See scripts/pnglibconf.mak for more options
88 PNGLIBCONF_H_PREBUILT = scripts/pnglibconf.h.prebuilt
90 OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \
91 pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \
92 pngwtran.o pngmem.o pngerror.o pngpread.o
94 OBJSDLL = $(OBJS:.o=.pic.o)
96 .SUFFIXES: .c .o .pic.o
99 $(CC) -c $(CPPFLAGS) $(CFLAGS) -o $@ $<
102 $(CC) -c $(CFLAGS) -fPIC -o $@ $*.c
104 all: libpng.a $(LIBSO) pngtest pngtest-static libpng.pc libpng-config
106 pnglibconf.h: $(PNGLIBCONF_H_PREBUILT)
114 cat scripts/libpng.pc.in | sed -e s!@prefix@!$(prefix)! \
115 -e s!@exec_prefix@!$(exec_prefix)! \
116 -e s!@libdir@!$(LIBPATH)! \
117 -e s!@includedir@!$(INCPATH)! \
118 -e s!-lpng16!-lpng16\ -lz\ -lm! > libpng.pc
120 libpng.syms: png.h pngconf.h pnglibconf.h
121 $(CC) $(CPPFLAGS) $(CFLAGS) -E -DPNG_BUILDSYMS -DPNG_INTERNAL png.h |\
122 awk -F '[\t [\\]();]' -v PNGMAJ=$(PNGMAJ) 'BEGIN{printf("PNG16_%s {global:\n",PNGMAJ)}\
123 { for (i=1;i+2<=NF;++i)\
124 if ($$(i)=="PNG_FUNCTION_EXPORT" && $$(i+2)=="END")\
126 for (i=1;i+1<=NF;++i)\
127 if ($$(i)=="PNG_DATA_EXPORT")\
129 END{print "local: *; };"}' >$@.new
134 ( cat scripts/libpng-config-head.in; \
135 echo prefix=\"$(prefix)\"; \
136 echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \
139 echo libs=\"-lpng16\"; \
140 echo all_libs=\"-lpng16 $(LIBADDFLAGS)\"; \
141 cat scripts/libpng-config-body.in ) > libpng-config
142 chmod +x libpng-config
144 $(LIBSO): $(LIBSOMAJ)
145 $(LN_SF) $(LIBSOMAJ) $(LIBSO)
147 $(LIBSOMAJ): $(OBJSDLL) libpng.syms
148 $(CC) -shared -Wl,-soname,$(LIBSOMAJ) \
149 -Wl,-version-script,libpng.syms \
153 pngtest: pngtest.o $(LIBSO)
154 $(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS)
156 pngtest-static: pngtest.o libpng.a
157 $(CC) -o pngtest-static $(CFLAGS) pngtest.o $(LDFLAGS_A)
159 test: pngtest pngtest-static
161 @echo " Running pngtest dynamically linked with $(LIBSO):"
163 LD_LIBRARY_PATH=".:${LD_LIBRARY_PATH}" ./pngtest
165 @echo " Running pngtest statically linked with libpng.a:"
169 install-headers: png.h pngconf.h pnglibconf.h
170 -@if [ ! -d $(DI) ]; then $(MKDIR_P) $(DI); fi
171 -@if [ ! -d $(DI)/$(LIBNAME) ]; then $(MKDIR_P) $(DI)/$(LIBNAME); fi
172 cp png.h pngconf.h pnglibconf.h $(DI)/$(LIBNAME)
173 chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h $(DI)/$(LIBNAME)/pnglibconf.h
174 -@$(RM_F) $(DI)/png.h $(DI)/pngconf.h $(DI)/pnglibconf.h
175 -@$(RM_F) $(DI)/libpng
176 (cd $(DI); $(LN_SF) $(LIBNAME) libpng; $(LN_SF) $(LIBNAME)/* .)
178 install-static: install-headers libpng.a
179 -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi
180 cp libpng.a $(DL)/$(LIBNAME).a
181 chmod 644 $(DL)/$(LIBNAME).a
182 -@$(RM_F) $(DL)/libpng.a
183 (cd $(DL); $(LN_SF) $(LIBNAME).a libpng.a)
185 install-shared: install-headers $(LIBSOMAJ) libpng.pc
186 -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi
187 -@$(RM_F) $(DL)/$(LIBSO)
188 -@$(RM_F) $(DL)/$(LIBSOREL)
189 -@$(RM_F) $(DL)/$(OLDSO)
190 cp $(LIBSOMAJ) $(DL)/$(LIBSOREL)
191 chmod 755 $(DL)/$(LIBSOREL)
193 $(LN_SF) $(LIBSOREL) $(LIBSO); \
194 $(LN_SF) $(LIBSO) $(OLDSO))
195 -@if [ ! -d $(DL)/pkgconfig ]; then $(MKDIR_P) $(DL)/pkgconfig; fi
196 -@$(RM_F) $(DL)/pkgconfig/$(LIBNAME).pc
197 -@$(RM_F) $(DL)/pkgconfig/libpng.pc
198 cp libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc
199 chmod 644 $(DL)/pkgconfig/$(LIBNAME).pc
200 (cd $(DL)/pkgconfig; $(LN_SF) $(LIBNAME).pc libpng.pc)
202 install-man: libpng.3 libpngpf.3 png.5
203 -@if [ ! -d $(DM) ]; then $(MKDIR_P) $(DM); fi
204 -@if [ ! -d $(DM)/man3 ]; then $(MKDIR_P) $(DM)/man3; fi
205 -@$(RM_F) $(DM)/man3/libpng.3
206 -@$(RM_F) $(DM)/man3/libpngpf.3
207 cp libpng.3 $(DM)/man3
208 cp libpngpf.3 $(DM)/man3
209 -@if [ ! -d $(DM)/man5 ]; then $(MKDIR_P) $(DM)/man5; fi
210 -@$(RM_F) $(DM)/man5/png.5
213 install-config: libpng-config
214 -@if [ ! -d $(DB) ]; then $(MKDIR_P) $(DB); fi
215 -@$(RM_F) $(DB)/libpng-config
216 -@$(RM_F) $(DB)/$(LIBNAME)-config
217 cp libpng-config $(DB)/$(LIBNAME)-config
218 chmod 755 $(DB)/$(LIBNAME)-config
219 (cd $(DB); $(LN_SF) $(LIBNAME)-config libpng-config)
221 install: install-static install-shared install-man install-config
223 # If you installed in $(DESTDIR), test-installed won't work until you
224 # move the library to its final location. Use test-dd to test it
229 echo Testing installed dynamic shared library in $(DL).
230 $(CC) -I$(DI) $(CPPFLAGS) \
231 `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \
232 -L$(DL) -L$(ZLIBLIB) -Wl, -rpath,$(DL) -Wl,-rpath,$(ZLIBLIB) \
233 -o pngtestd `$(BINPATH)/$(LIBNAME)-config --ldflags`
234 ./pngtestd pngtest.png
238 `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \
239 -L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) \
240 -o pngtesti `$(BINPATH)/$(LIBNAME)-config --ldflags`
241 ./pngtesti pngtest.png
244 $(RM_F) *.o libpng.a libpng.syms pngtest pngout.png libpng-config \
245 $(LIBSO) $(LIBSOMAJ)* pngtest-static pngtesti \
246 libpng.pc pnglibconf.h
248 DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO
250 chmod a-w *.[ch35] $(DOCS) scripts/*
252 # DO NOT DELETE THIS LINE -- make depend depends on it.
254 png.o png.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
255 pngerror.o pngerror.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
256 pngrio.o pngrio.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
257 pngwio.o pngwio.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
258 pngmem.o pngmem.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
259 pngset.o pngset.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
260 pngget.o pngget.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
261 pngread.o pngread.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
262 pngrtran.o pngrtran.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
263 pngrutil.o pngrutil.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
264 pngtrans.o pngtrans.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
265 pngwrite.o pngwrite.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
266 pngwtran.o pngwtran.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
267 pngwutil.o pngwutil.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
268 pngpread.o pngpread.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
270 pngtest.o: png.h pngconf.h pnglibconf.h