1 # makefile for libpng.a and libpng12.so on Linux ELF with gcc
2 # Copyright (C) 1998, 1999, 2002, 2006-2008 Greg Roelofs and
3 # 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
14 PNGVER = $(PNGMAJ).$(PNGMIN)
16 # Shared library names:
18 LIBSOMAJ=$(LIBNAME).so.$(PNGMAJ)
19 LIBSOVER=$(LIBNAME).so.$(PNGVER)
22 OLDSOVER=libpng.so.3.$(PNGMIN)
32 # where "make install" puts libpng12.a, libpng12.so*,
33 # libpng12/png.h and libpng12/pngconf.h
34 # Prefix must be a full pathname.
38 # Where the zlib library and include files are located.
39 #ZLIBLIB=/usr/local/lib
40 #ZLIBINC=/usr/local/include
46 #ALIGN=-malign-loops=2 -malign-functions=2
48 WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow \
49 -Wmissing-declarations -Wtraditional -Wcast-align \
50 -Wstrict-prototypes -Wmissing-prototypes #-Wconversion
52 # for pgcc version 2.95.1, -O3 is buggy; don't use it.
54 CFLAGS=-I$(ZLIBINC) -W -Wall -O3 -funroll-loops -DPNG_NO_MMX_CODE \
55 $(ALIGN) # $(WARNMORE) -g -DPNG_DEBUG=5
57 LDFLAGS=-L. -Wl,-rpath,. -L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) -lpng12 -lz -lm
58 LDFLAGS_A=-L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) libpng.a -lz -lm
60 INCPATH=$(prefix)/include
61 LIBPATH=$(exec_prefix)/lib
63 BINPATH=$(exec_prefix)/bin
65 # override DESTDIR= on the make install command line to easily support
66 # installing into a temporary location. Example:
68 # make install DESTDIR=/tmp/build/libpng
70 # If you're going to install into a temporary location
71 # via DESTDIR, $(DESTDIR)$(prefix) must already exist before
72 # you execute make install.
75 DB=$(DESTDIR)$(BINPATH)
76 DI=$(DESTDIR)$(INCPATH)
77 DL=$(DESTDIR)$(LIBPATH)
78 DM=$(DESTDIR)$(MANPATH)
80 OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \
81 pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \
82 pngwtran.o pngmem.o pngerror.o pngpread.o
84 OBJSDLL = $(OBJS:.o=.pic.o)
86 .SUFFIXES: .c .o .pic.o
89 $(CC) -c $(CFLAGS) -fPIC -o $@ $*.c
91 all: libpng.a $(LIBSO) pngtest pngtest-static libpng.pc libpng-config
98 cat scripts/libpng.pc.in | sed -e s!@prefix@!$(prefix)! \
99 -e s!@exec_prefix@!$(exec_prefix)! \
100 -e s!@libdir@!$(LIBPATH)! \
101 -e s!@includedir@!$(INCPATH)! \
102 -e s!@includedir@!$(INCPATH)! \
103 -e s!-lpng12!-lpng12\ -lz\ -lm! \
104 -e s!Cflags: !Cflags:\ -DPNG_NO_MMX_CODE!> libpng.pc
107 ( cat scripts/libpng-config-head.in; \
108 echo prefix=\"$(prefix)\"; \
109 echo I_opts=\"-I$(INCPATH)/$(LIBNAME) -DPNG_NO_MMX_CODE\"; \
110 echo L_opts=\"-L$(LIBPATH)\"; \
111 echo R_opts=\"-Wl,-rpath,$(LIBPATH)\"; \
112 echo libs=\"-lpng12 -lz -lm\"; \
113 cat scripts/libpng-config-body.in ) > libpng-config
114 chmod +x libpng-config
116 $(LIBSO): $(LIBSOMAJ)
117 $(LN_SF) $(LIBSOMAJ) $(LIBSO)
119 $(LIBSOMAJ): $(LIBSOVER)
120 $(LN_SF) $(LIBSOVER) $(LIBSOMAJ)
122 $(LIBSOVER): $(OBJSDLL)
123 $(CC) -shared -Wl,-soname,$(LIBSOMAJ) -o $(LIBSOVER) $(OBJSDLL)
125 $(OLDSOVER): $(OBJSDLL)
126 $(CC) -shared -Wl,-soname,$(OLDSOMAJ) \
130 pngtest: pngtest.o $(LIBSO)
131 $(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS)
133 pngtest-static: pngtest.o libpng.a
134 $(CC) -o pngtest-static $(CFLAGS) pngtest.o $(LDFLAGS_A)
136 test: pngtest pngtest-static
138 @echo " Running pngtest dynamically linked with $(LIBSO):"
142 @echo " Running pngtest statically linked with libpng.a:"
146 install-headers: png.h pngconf.h
147 -@if [ ! -d $(DI) ]; then $(MKDIR_P) $(DI); fi
148 -@if [ ! -d $(DI)/$(LIBNAME) ]; then $(MKDIR_P) $(DI)/$(LIBNAME); fi
149 cp png.h pngconf.h $(DI)/$(LIBNAME)
150 chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h
151 -@$(RM_F) $(DI)/png.h $(DI)/pngconf.h
152 -@$(RM_F) $(DI)/libpng
153 (cd $(DI); $(LN_SF) $(LIBNAME) libpng; $(LN_SF) $(LIBNAME)/* .)
155 install-static: install-headers libpng.a
156 -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi
157 cp libpng.a $(DL)/$(LIBNAME).a
158 chmod 644 $(DL)/$(LIBNAME).a
159 -@$(RM_F) $(DL)/libpng.a
160 (cd $(DL); $(LN_SF) $(LIBNAME).a libpng.a)
162 install-shared: install-headers $(LIBSOVER) libpng.pc \
164 -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi
165 -@$(RM_F) $(DL)/$(LIBSOVER)* $(DL)/$(LIBSO)
166 -@$(RM_F) $(DL)/$(LIBSOMAJ)
167 -@$(RM_F) $(DL)/$(OLDSO)
168 -@$(RM_F) $(DL)/$(OLDSOMAJ)
169 -@$(RM_F) $(DL)/$(OLDSOVER)*
172 chmod 755 $(DL)/$(LIBSOVER)
173 chmod 755 $(DL)/$(OLDSOVER)
175 $(LN_SF) $(OLDSOVER) $(OLDSOMAJ); \
176 $(LN_SF) $(OLDSOMAJ) $(OLDSO); \
177 $(LN_SF) $(LIBSOVER) $(LIBSOMAJ); \
178 $(LN_SF) $(LIBSOMAJ) $(LIBSO))
179 -@if [ ! -d $(DL)/pkgconfig ]; then $(MKDIR_P) $(DL)/pkgconfig; fi
180 -@$(RM_F) $(DL)/pkgconfig/$(LIBNAME).pc
181 -@$(RM_F) $(DL)/pkgconfig/libpng.pc
182 cp libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc
183 chmod 644 $(DL)/pkgconfig/$(LIBNAME).pc
184 (cd $(DL)/pkgconfig; $(LN_SF) $(LIBNAME).pc libpng.pc)
186 install-man: libpng.3 libpngpf.3 png.5
187 -@if [ ! -d $(DM) ]; then $(MKDIR_P) $(DM); fi
188 -@if [ ! -d $(DM)/man3 ]; then $(MKDIR_P) $(DM)/man3; fi
189 -@$(RM_F) $(DM)/man3/libpng.3
190 -@$(RM_F) $(DM)/man3/libpngpf.3
191 cp libpng.3 $(DM)/man3
192 cp libpngpf.3 $(DM)/man3
193 -@if [ ! -d $(DM)/man5 ]; then $(MKDIR_P) $(DM)/man5; fi
194 -@$(RM_F) $(DM)/man5/png.5
197 install-config: libpng-config
198 -@if [ ! -d $(DB) ]; then $(MKDIR_P) $(DB); fi
199 -@$(RM_F) $(DB)/libpng-config
200 -@$(RM_F) $(DB)/$(LIBNAME)-config
201 cp libpng-config $(DB)/$(LIBNAME)-config
202 chmod 755 $(DB)/$(LIBNAME)-config
203 (cd $(DB); $(LN_SF) $(LIBNAME)-config libpng-config)
205 install: install-static install-shared install-man install-config
207 # If you installed in $(DESTDIR), test-installed won't work until you
208 # move the library to its final location. Use test-dd to test it
213 echo Testing installed dynamic shared library in $(DL).
214 $(CC) -I$(DI) -I$(ZLIBINC) \
215 `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \
216 -L$(DL) -L$(ZLIBLIB) -Wl, -rpath,$(DL) -Wl,-rpath,$(ZLIBLIB) \
217 -o pngtestd `$(BINPATH)/$(LIBNAME)-config --ldflags`
218 ./pngtestd pngtest.png
222 `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \
223 -L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) \
224 -o pngtesti `$(BINPATH)/$(LIBNAME)-config --ldflags`
225 ./pngtesti pngtest.png
228 $(RM_F) *.o libpng.a pngtest pngout.png libpng-config \
229 $(LIBSO) $(LIBSOMAJ)* pngtest-static pngtesti \
233 DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO
235 chmod a-w *.[ch35] $(DOCS) scripts/*
237 # DO NOT DELETE THIS LINE -- make depend depends on it.
239 png.o png.pic.o: png.h pngconf.h png.c
240 pngerror.o pngerror.pic.o: png.h pngconf.h pngerror.c
241 pngrio.o pngrio.pic.o: png.h pngconf.h pngrio.c
242 pngwio.o pngwio.pic.o: png.h pngconf.h pngwio.c
243 pngmem.o pngmem.pic.o: png.h pngconf.h pngmem.c
244 pngset.o pngset.pic.o: png.h pngconf.h pngset.c
245 pngget.o pngget.pic.o: png.h pngconf.h pngget.c
246 pngread.o pngread.pic.o: png.h pngconf.h pngread.c
247 pngrtran.o pngrtran.pic.o: png.h pngconf.h pngrtran.c
248 pngrutil.o pngrutil.pic.o: png.h pngconf.h pngrutil.c
249 pngtrans.o pngtrans.pic.o: png.h pngconf.h pngtrans.c
250 pngwrite.o pngwrite.pic.o: png.h pngconf.h pngwrite.c
251 pngwtran.o pngwtran.pic.o: png.h pngconf.h pngwtran.c
252 pngwutil.o pngwutil.pic.o: png.h pngconf.h pngwutil.c
253 pngpread.o pngpread.pic.o: png.h pngconf.h pngpread.c
255 pngtest.o: png.h pngconf.h pngtest.c