1 # makefile for libpng.a and libpng12.so on Linux ELF with gcc
2 # Copyright (C) 1998, 1999, 2002, 2006 Greg Roelofs and Glenn Randers-Pehrson
3 # Copyright (C) 1996, 1997 Andreas Dilger
4 # For conditions of distribution and use, see copyright notice in png.h
6 # Modified for Debian by Junichi Uekawa and Josselin Mouette
7 # Major modifications are:
8 # * link libpng explicitly with libz and libm
9 # * $(OLDSO).3 is a symlink rather than a different library
16 PNGVER = $(PNGMAJ).$(PNGMIN)
18 # Shared library names:
20 LIBSOMAJ=$(LIBNAME).so.$(PNGMAJ)
21 LIBSOVER=$(LIBNAME).so.$(PNGVER)
24 OLDSOVER=libpng.so.3.$(PNGMIN)
34 # where "make install" puts libpng12.a, libpng12.so*,
35 # libpng12/png.h and libpng12/pngconf.h
36 # Prefix must be a full pathname.
40 # Where the zlib library and include files are located.
41 ZLIBLIB=/usr/local/lib
42 ZLIBINC=/usr/local/include
48 #ALIGN=-malign-loops=2 -malign-functions=2
50 WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow \
51 -Wmissing-declarations -Wtraditional -Wcast-align \
52 -Wstrict-prototypes -Wmissing-prototypes #-Wconversion
54 # for pgcc version 2.95.1, -O3 is buggy; don't use it.
56 CFLAGS=-Wall -D_REENTRANT -O2 \
57 $(ALIGN) # $(WARNMORE) -g -DPNG_DEBUG=5
60 LDFLAGS_A=libpng.a -lz -lm
64 INCPATH=$(prefix)/include
65 LIBPATH=$(exec_prefix)/lib
67 BINPATH=$(exec_prefix)/bin
69 # override DESTDIR= on the make install command line to easily support
70 # installing into a temporary location. Example:
72 # make install DESTDIR=/tmp/build/libpng
74 # If you're going to install into a temporary location
75 # via DESTDIR, $(DESTDIR)$(prefix) must already exist before
76 # you execute make install.
79 DB=$(DESTDIR)$(BINPATH)
80 DI=$(DESTDIR)$(INCPATH)
81 DL=$(DESTDIR)$(LIBPATH)
82 DM=$(DESTDIR)$(MANPATH)
84 OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \
85 pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \
86 pngwtran.o pngmem.o pngerror.o pngpread.o
88 OBJSDLL = $(OBJS:.o=.pic.o)
90 .SUFFIXES: .c .o .pic.o
93 $(CC) -c $(CFLAGS) -fPIC -o $@ $*.c
95 all: libpng.a $(LIBSO) pngtest pngtest-static libpng.pc libpng-config
102 cat scripts/libpng.pc.in | sed -e s\!@PREFIX@!$(prefix)! > libpng.pc
104 libpng.syms: png.h pngconf.h
105 $(CC) $(CFLAGS) -E -DPNG_BUILDSYMS -DPNG_INTERNAL png.h |\
106 awk -F '[\t [\\]();]' -v PNGMAJ=$(PNGMAJ) 'BEGIN{printf("PNG12_%s {global:\n",PNGMAJ)}\
107 { for (i=1;i+2<=NF;++i)\
108 if ($$(i)=="PNG_FUNCTION_EXPORT" && $$(i+2)=="END")\
110 for (i=1;i+1<=NF;++i)\
111 if ($$(i)=="PNG_DATA_EXPORT")\
113 END{print "local: *; };"}' >$@.new
118 ( cat scripts/libpng-config-head.in; \
119 echo prefix=\"$(prefix)\"; \
120 echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \
123 echo libs=\"-lpng12\"; \
124 echo all_libs=\"-lpng12 $(LIBADDFLAGS)\"; \
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) libpng.syms
135 $(CC) -shared -Wl,-soname,$(LIBSOMAJ) \
136 -Wl,-version-script,libpng.syms \
140 $(OLDSOVER): $(OBJSDLL) libpng.syms
141 $(CC) -shared -Wl,-soname,$(OLDSOMAJ) \
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
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 $(DI)/$(LIBNAME)
166 chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h
167 -@$(RM_F) $(DI)/png.h $(DI)/pngconf.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 $(LIBSOVER) libpng.pc \
180 -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi
181 -@$(RM_F) $(DL)/$(LIBSOVER)* $(DL)/$(LIBSO)
182 -@$(RM_F) $(DL)/$(LIBSOMAJ)
183 -@$(RM_F) $(DL)/$(OLDSO)
184 -@$(RM_F) $(DL)/$(OLDSOMAJ)
185 -@$(RM_F) $(DL)/$(OLDSOVER)*
188 chmod 755 $(DL)/$(LIBSOVER)
189 chmod 755 $(DL)/$(OLDSOVER)
191 $(LN_SF) $(OLDSOVER) $(OLDSOMAJ); \
192 $(LN_SF) $(OLDSOMAJ) $(OLDSO); \
193 $(LN_SF) $(LIBSOVER) $(LIBSOMAJ); \
194 $(LN_SF) $(LIBSOMAJ) $(LIBSO))
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) -I$(ZLIBINC) \
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 \
249 DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO
251 chmod a-w *.[ch35] $(DOCS) scripts/*
253 # DO NOT DELETE THIS LINE -- make depend depends on it.
255 png.o png.pic.o: png.h pngconf.h
256 pngerror.o pngerror.pic.o: png.h pngconf.h
257 pngrio.o pngrio.pic.o: png.h pngconf.h
258 pngwio.o pngwio.pic.o: png.h pngconf.h
259 pngmem.o pngmem.pic.o: png.h pngconf.h
260 pngset.o pngset.pic.o: png.h pngconf.h
261 pngget.o pngget.pic.o: png.h pngconf.h
262 pngread.o pngread.pic.o: png.h pngconf.h
263 pngrtran.o pngrtran.pic.o: png.h pngconf.h
264 pngrutil.o pngrutil.pic.o: png.h pngconf.h
265 pngtrans.o pngtrans.pic.o: png.h pngconf.h
266 pngwrite.o pngwrite.pic.o: png.h pngconf.h
267 pngwtran.o pngwtran.pic.o: png.h pngconf.h
268 pngwutil.o pngwutil.pic.o: png.h pngconf.h
269 pngpread.o pngpread.pic.o: png.h pngconf.h
271 pngtest.o: png.h pngconf.h