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
84 ( cat scripts/libpng-config-head.in; \
85 echo prefix=\"$(prefix)\"; \
86 echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \
87 echo L_opts=\"-L$(LIBPATH)\"; \
88 echo R_opts=\"-Wl,-rpath,$(LIBPATH)\"; \
89 echo libs=\"-lpng12 -lz -lm\"; \
90 cat scripts/libpng-config-body.in ) > libpng-config
91 chmod +x libpng-config
93 $(LIBNAME).so: $(LIBNAME).so.$(PNGMAJ)
94 ln -sf $(LIBNAME).so.$(PNGMAJ) $(LIBNAME).so
96 $(LIBNAME).so.$(PNGMAJ): $(LIBNAME).so.$(PNGVER)
97 ln -sf $(LIBNAME).so.$(PNGVER) $(LIBNAME).so.$(PNGMAJ)
99 $(LIBNAME).so.$(PNGVER): $(OBJSDLL)
100 $(CC) -shared -Wl,-soname,$(LIBNAME).so.$(PNGMAJ) \
101 -o $(LIBNAME).so.$(PNGVER) \
104 libpng.so.3.$(PNGMIN): $(OBJSDLL)
105 $(CC) -shared -Wl,-soname,libpng.so.3 \
106 -o libpng.so.3.$(PNGMIN) \
109 pngtest: pngtest.o $(LIBNAME).so
110 $(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS)
112 pngtest-static: pngtest.o libpng.a
113 $(CC) -o pngtest-static $(CFLAGS) pngtest.o $(LDFLAGS_A)
115 test: pngtest pngtest-static
117 @echo " Running pngtest dynamically linked with $(LIBNAME).so:"
121 @echo " Running pngtest statically linked with libpng.a:"
125 install-headers: png.h pngconf.h
126 -@if [ ! -d $(DI) ]; then mkdir $(DI); fi
127 -@if [ ! -d $(DI)/$(LIBNAME) ]; then mkdir $(DI)/$(LIBNAME); fi
128 cp png.h pngconf.h $(DI)/$(LIBNAME)
129 chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h
130 -@/bin/rm -f $(DI)/png.h $(DI)/pngconf.h
131 -@/bin/rm -f $(DI)/libpng
132 (cd $(DI); ln -sf $(LIBNAME) libpng; ln -sf $(LIBNAME)/* .)
134 install-static: install-headers libpng.a
135 -@if [ ! -d $(DL) ]; then mkdir $(DL); fi
136 cp libpng.a $(DL)/$(LIBNAME).a
137 chmod 644 $(DL)/$(LIBNAME).a
138 -@/bin/rm -f $(DL)/libpng.a
139 (cd $(DL); ln -sf $(LIBNAME).a libpng.a)
141 install-shared: install-headers $(LIBNAME).so.$(PNGVER) libpng.pc \
142 libpng.so.3.$(PNGMIN)
143 -@if [ ! -d $(DL) ]; then mkdir $(DL); fi
144 -@/bin/rm -f $(DL)/$(LIBNAME).so.$(PNGVER)* $(DL)/$(LIBNAME).so
145 -@/bin/rm -f $(DL)/libpng.so
146 -@/bin/rm -f $(DL)/libpng.so.3
147 -@/bin/rm -f $(DL)/libpng.so.3.$(PNGMIN)*
148 cp $(LIBNAME).so.$(PNGVER) $(DL)
149 cp libpng.so.3.$(PNGMIN) $(DL)
150 chmod 755 $(DL)/$(LIBNAME).so.$(PNGVER)
151 chmod 755 $(DL)/libpng.so.3.$(PNGMIN)
153 ln -sf libpng.so.3.$(PNGMIN) libpng.so.3; \
154 ln -sf libpng.so.3 libpng.so; \
155 ln -sf $(LIBNAME).so.$(PNGVER) $(LIBNAME).so.$(PNGMAJ); \
156 ln -sf $(LIBNAME).so.$(PNGMAJ) $(LIBNAME).so)
157 -@if [ ! -d $(DL)/pkgconfig ]; then mkdir $(DL)/pkgconfig; fi
158 -@/bin/rm -f $(DL)/pkgconfig/$(LIBNAME).pc
159 -@/bin/rm -f $(DL)/pkgconfig/libpng.pc
160 cp libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc
161 chmod 644 $(DL)/pkgconfig/$(LIBNAME).pc
162 (cd $(DL)/pkgconfig; ln -sf $(LIBNAME).pc libpng.pc)
164 install-man: libpng.3 libpngpf.3 png.5
165 -@if [ ! -d $(DM) ]; then mkdir $(DM); fi
166 -@if [ ! -d $(DM)/man3 ]; then mkdir $(DM)/man3; fi
167 -@/bin/rm -f $(DM)/man3/libpng.3
168 -@/bin/rm -f $(DM)/man3/libpngpf.3
169 cp libpng.3 $(DM)/man3
170 cp libpngpf.3 $(DM)/man3
171 -@if [ ! -d $(DM)/man5 ]; then mkdir $(DM)/man5; fi
172 -@/bin/rm -f $(DM)/man5/png.5
175 install-config: libpng-config
176 -@if [ ! -d $(DB) ]; then mkdir $(DB); fi
177 -@/bin/rm -f $(DB)/libpng-config
178 -@/bin/rm -f $(DB)/$(LIBNAME)-config
179 cp libpng-config $(DB)/$(LIBNAME)-config
180 chmod 755 $(DB)/$(LIBNAME)-config
181 (cd $(DB); ln -sf $(LIBNAME)-config libpng-config)
183 install: install-static install-shared install-man install-config
185 # If you installed in $(DESTDIR), test-installed won't work until you
186 # move the library to its final location.
190 `$(BINPATH)/libpng12-config --cflags` pngtest.c \
191 -L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) \
192 -o pngtesti `$(BINPATH)/libpng12-config --ldflags`
193 ./pngtesti pngtest.png
196 /bin/rm -f *.o libpng.a pngtest pngout.png libpng-config \
197 $(LIBNAME).so $(LIBNAME).so.$(PNGMAJ)* pngtest-static pngtesti \
198 libpng.so.3.$(PNGMIN) \
201 DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO
203 chmod a-w *.[ch35] $(DOCS) scripts/*
205 # DO NOT DELETE THIS LINE -- make depend depends on it.
207 png.o png.pic.o: png.h pngconf.h
208 pngerror.o pngerror.pic.o: png.h pngconf.h
209 pngrio.o pngrio.pic.o: png.h pngconf.h
210 pngwio.o pngwio.pic.o: png.h pngconf.h
211 pngmem.o pngmem.pic.o: png.h pngconf.h
212 pngset.o pngset.pic.o: png.h pngconf.h
213 pngget.o pngget.pic.o: png.h pngconf.h
214 pngread.o pngread.pic.o: png.h pngconf.h
215 pngrtran.o pngrtran.pic.o: png.h pngconf.h
216 pngrutil.o pngrutil.pic.o: png.h pngconf.h
217 pngtrans.o pngtrans.pic.o: png.h pngconf.h
218 pngwrite.o pngwrite.pic.o: png.h pngconf.h
219 pngwtran.o pngwtran.pic.o: png.h pngconf.h
220 pngwutil.o pngwutil.pic.o: png.h pngconf.h
221 pngpread.o pngpread.pic.o: png.h pngconf.h
223 pngtest.o: png.h pngconf.h