1 # makefile for libpng.a and libpng12.so on Linux ELF with gcc
2 # Copyright (C) 1998, 1999, 2002 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
9 PNGVER = $(PNGMAJ).$(PNGMIN)
13 # where "make install" puts libpng12.a, libpng12.so*,
14 # libpng12/png.h and libpng12/pngconf.h
15 # Prefix must be a full pathname.
18 # Where the zlib library and include files are located.
19 #ZLIBLIB=/usr/local/lib
20 #ZLIBINC=/usr/local/include
26 #ALIGN=-malign-loops=2 -malign-functions=2
28 WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow \
29 -Wmissing-declarations -Wtraditional -Wcast-align \
30 -Wstrict-prototypes -Wmissing-prototypes #-Wconversion
32 # for pgcc version 2.95.1, -O3 is buggy; don't use it.
34 CFLAGS=-I$(ZLIBINC) -Wall -O3 -funroll-loops \
35 $(ALIGN) # $(WARNMORE) -g -DPNG_DEBUG=5
37 LDFLAGS=-L. -Wl,-rpath,. -L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) -lpng12 -lz -lm
38 LDFLAGS_A=-L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) libpng.a -lz -lm
43 INCPATH=$(prefix)/include
48 # override DESTDIR= on the make install command line to easily support
49 # installing into a temporary location. Example:
51 # make install DESTDIR=/tmp/build/libpng
53 # If you're going to install into a temporary location
54 # via DESTDIR, $(DESTDIR)$(prefix) must already exist before
55 # you execute make install.
58 DB=$(DESTDIR)$(BINPATH)
59 DI=$(DESTDIR)$(INCPATH)
60 DL=$(DESTDIR)$(LIBPATH)
61 DM=$(DESTDIR)$(MANPATH)
63 OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \
64 pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \
65 pngwtran.o pngmem.o pngerror.o pngpread.o
67 OBJSDLL = $(OBJS:.o=.pic.o)
69 .SUFFIXES: .c .o .pic.o
72 $(CC) -c $(CFLAGS) -fPIC -o $@ $*.c
74 all: libpng.a $(LIBNAME).so pngtest pngtest-static libpng.pc libpng-config
81 cat scripts/libpng.pc.in | sed -e s\!@PREFIX@!$(prefix)! > libpng.pc
83 libpng.syms: png.h pngconf.h
84 $(CC) $(CFLAGS) -E -DPNG_BUILDSYMS png.h |\
85 awk -F '[\t [\]();]' 'BEGIN{print "{global:"}\
86 { for (i=1;i+2<=NF;++i)\
87 if ($$(i)=="PNG_FUNCTION_EXPORT" && $$(i+2)=="END")\
89 for (i=1;i+1<=NF;++i)\
90 if ($$(i)=="PNG_DATA_EXPORT")\
92 END{print "local: *; };"}' >$@.new
97 ( cat scripts/libpng-config-head.in; \
98 echo prefix=\"$(prefix)\"; \
99 echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \
100 echo L_opts=\"-L$(LIBPATH)\"; \
101 echo R_opts=\"-Wl,-rpath,$(LIBPATH)\"; \
102 echo libs=\"-lpng12 -lz -lm\"; \
103 cat scripts/libpng-config-body.in ) > libpng-config
104 chmod +x libpng-config
106 $(LIBNAME).so: $(LIBNAME).so.$(PNGMAJ)
107 ln -sf $(LIBNAME).so.$(PNGMAJ) $(LIBNAME).so
109 $(LIBNAME).so.$(PNGMAJ): $(LIBNAME).so.$(PNGVER)
110 ln -sf $(LIBNAME).so.$(PNGVER) $(LIBNAME).so.$(PNGMAJ)
112 $(LIBNAME).so.$(PNGVER): $(OBJSDLL) libpng.syms
113 $(CC) -shared -Wl,-soname,$(LIBNAME).so.$(PNGMAJ) \
114 -Wl,-version-script,libpng.syms \
115 -o $(LIBNAME).so.$(PNGVER) \
118 libpng.so.3.$(PNGMIN): $(OBJSDLL) libpng.syms
119 $(CC) -shared -Wl,-soname,libpng.so.3 \
120 -Wl,-version-script,libpng.syms \
121 -o libpng.so.3.$(PNGMIN) \
124 pngtest: pngtest.o $(LIBNAME).so
125 $(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS)
127 pngtest-static: pngtest.o libpng.a
128 $(CC) -o pngtest-static $(CFLAGS) pngtest.o $(LDFLAGS_A)
130 test: pngtest pngtest-static
132 @echo " Running pngtest dynamically linked with $(LIBNAME).so:"
136 @echo " Running pngtest statically linked with libpng.a:"
140 install-headers: png.h pngconf.h
141 -@if [ ! -d $(DI) ]; then mkdir $(DI); fi
142 -@if [ ! -d $(DI)/$(LIBNAME) ]; then mkdir $(DI)/$(LIBNAME); fi
143 cp png.h pngconf.h $(DI)/$(LIBNAME)
144 chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h
145 -@/bin/rm -f $(DI)/png.h $(DI)/pngconf.h
146 -@/bin/rm -f $(DI)/libpng
147 (cd $(DI); ln -sf $(LIBNAME) libpng; ln -sf $(LIBNAME)/* .)
149 install-static: install-headers libpng.a
150 -@if [ ! -d $(DL) ]; then mkdir $(DL); fi
151 cp libpng.a $(DL)/$(LIBNAME).a
152 chmod 644 $(DL)/$(LIBNAME).a
153 -@/bin/rm -f $(DL)/libpng.a
154 (cd $(DL); ln -sf $(LIBNAME).a libpng.a)
156 install-shared: install-headers $(LIBNAME).so.$(PNGVER) libpng.pc \
157 libpng.so.3.$(PNGMIN)
158 -@if [ ! -d $(DL) ]; then mkdir $(DL); fi
159 -@/bin/rm -f $(DL)/$(LIBNAME).so.$(PNGVER)* $(DL)/$(LIBNAME).so
160 -@/bin/rm -f $(DL)/$(LIBNAME).so.$(PNGMAJ)
161 -@/bin/rm -f $(DL)/libpng.so
162 -@/bin/rm -f $(DL)/libpng.so.3
163 -@/bin/rm -f $(DL)/libpng.so.3.$(PNGMIN)*
164 cp $(LIBNAME).so.$(PNGVER) $(DL)
165 cp libpng.so.3.$(PNGMIN) $(DL)
166 chmod 755 $(DL)/$(LIBNAME).so.$(PNGVER)
167 chmod 755 $(DL)/libpng.so.3.$(PNGMIN)
169 ln -sf libpng.so.3.$(PNGMIN) libpng.so.3; \
170 ln -sf libpng.so.3 libpng.so; \
171 ln -sf $(LIBNAME).so.$(PNGVER) $(LIBNAME).so.$(PNGMAJ); \
172 ln -sf $(LIBNAME).so.$(PNGMAJ) $(LIBNAME).so)
173 -@if [ ! -d $(DL)/pkgconfig ]; then mkdir $(DL)/pkgconfig; fi
174 -@/bin/rm -f $(DL)/pkgconfig/$(LIBNAME).pc
175 -@/bin/rm -f $(DL)/pkgconfig/libpng.pc
176 cp libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc
177 chmod 644 $(DL)/pkgconfig/$(LIBNAME).pc
178 (cd $(DL)/pkgconfig; ln -sf $(LIBNAME).pc libpng.pc)
180 install-man: libpng.3 libpngpf.3 png.5
181 -@if [ ! -d $(DM) ]; then mkdir $(DM); fi
182 -@if [ ! -d $(DM)/man3 ]; then mkdir $(DM)/man3; fi
183 -@/bin/rm -f $(DM)/man3/libpng.3
184 -@/bin/rm -f $(DM)/man3/libpngpf.3
185 cp libpng.3 $(DM)/man3
186 cp libpngpf.3 $(DM)/man3
187 -@if [ ! -d $(DM)/man5 ]; then mkdir $(DM)/man5; fi
188 -@/bin/rm -f $(DM)/man5/png.5
191 install-config: libpng-config
192 -@if [ ! -d $(DB) ]; then mkdir $(DB); fi
193 -@/bin/rm -f $(DB)/libpng-config
194 -@/bin/rm -f $(DB)/$(LIBNAME)-config
195 cp libpng-config $(DB)/$(LIBNAME)-config
196 chmod 755 $(DB)/$(LIBNAME)-config
197 (cd $(DB); ln -sf $(LIBNAME)-config libpng-config)
199 install: install-static install-shared install-man install-config
201 # If you installed in $(DESTDIR), test-installed won't work until you
202 # move the library to its final location. Use test-dd to test it
207 echo Testing installed dynamic shared library in $(DL).
208 $(CC) -I$(DI) -I$(ZLIBINC) \
209 `$(BINPATH)/libpng12-config --cflags` pngtest.c \
210 -L$(DL) -L$(ZLIBLIB) -W1, -rpath,$(DL) -Wl,-rpath,$(ZLIBLIB) \
211 -o pngtestd `$(BINPATH)/libpng12-config --ldflags`
212 ./pngtestd pngtest.png
216 `$(BINPATH)/libpng12-config --cflags` pngtest.c \
217 -L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) \
218 -o pngtesti `$(BINPATH)/libpng12-config --ldflags`
219 ./pngtesti pngtest.png
222 /bin/rm -f *.o libpng.a libpng.syms pngtest pngout.png libpng-config \
223 $(LIBNAME).so $(LIBNAME).so.$(PNGMAJ)* pngtest-static pngtesti \
224 libpng.so.3.$(PNGMIN) \
227 DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO
229 chmod a-w *.[ch35] $(DOCS) scripts/*
231 # DO NOT DELETE THIS LINE -- make depend depends on it.
233 png.o png.pic.o: png.h pngconf.h
234 pngerror.o pngerror.pic.o: png.h pngconf.h
235 pngrio.o pngrio.pic.o: png.h pngconf.h
236 pngwio.o pngwio.pic.o: png.h pngconf.h
237 pngmem.o pngmem.pic.o: png.h pngconf.h
238 pngset.o pngset.pic.o: png.h pngconf.h
239 pngget.o pngget.pic.o: png.h pngconf.h
240 pngread.o pngread.pic.o: png.h pngconf.h
241 pngrtran.o pngrtran.pic.o: png.h pngconf.h
242 pngrutil.o pngrutil.pic.o: png.h pngconf.h
243 pngtrans.o pngtrans.pic.o: png.h pngconf.h
244 pngwrite.o pngwrite.pic.o: png.h pngconf.h
245 pngwtran.o pngwtran.pic.o: png.h pngconf.h
246 pngwutil.o pngwutil.pic.o: png.h pngconf.h
247 pngpread.o pngpread.pic.o: png.h pngconf.h
249 pngtest.o: png.h pngconf.h