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
|
---|
5 |
|
---|
6 | LIBNAME = libpng12
|
---|
7 | PNGMAJ = 0
|
---|
8 | PNGMIN = 1.2.8
|
---|
9 | PNGVER = $(PNGMAJ).$(PNGMIN)
|
---|
10 |
|
---|
11 | CC=gcc
|
---|
12 |
|
---|
13 | # where "make install" puts libpng12.a, libpng12.so*,
|
---|
14 | # libpng12/png.h and libpng12/pngconf.h
|
---|
15 | # Prefix must be a full pathname.
|
---|
16 | prefix=/usr/local
|
---|
17 |
|
---|
18 | # Where the zlib library and include files are located.
|
---|
19 | #ZLIBLIB=/usr/local/lib
|
---|
20 | #ZLIBINC=/usr/local/include
|
---|
21 | ZLIBLIB=../zlib
|
---|
22 | ZLIBINC=../zlib
|
---|
23 |
|
---|
24 | ALIGN=
|
---|
25 | # for i386:
|
---|
26 | #ALIGN=-malign-loops=2 -malign-functions=2
|
---|
27 |
|
---|
28 | WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow \
|
---|
29 | -Wmissing-declarations -Wtraditional -Wcast-align \
|
---|
30 | -Wstrict-prototypes -Wmissing-prototypes #-Wconversion
|
---|
31 |
|
---|
32 | # for pgcc version 2.95.1, -O3 is buggy; don't use it.
|
---|
33 |
|
---|
34 | CFLAGS=-I$(ZLIBINC) -Wall -O3 -funroll-loops \
|
---|
35 | $(ALIGN) # $(WARNMORE) -g -DPNG_DEBUG=5
|
---|
36 |
|
---|
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
|
---|
39 |
|
---|
40 | RANLIB=ranlib
|
---|
41 | #RANLIB=echo
|
---|
42 |
|
---|
43 | INCPATH=$(prefix)/include
|
---|
44 | LIBPATH=$(prefix)/lib
|
---|
45 | MANPATH=$(prefix)/man
|
---|
46 | BINPATH=$(prefix)/bin
|
---|
47 |
|
---|
48 | # override DESTDIR= on the make install command line to easily support
|
---|
49 | # installing into a temporary location. Example:
|
---|
50 | #
|
---|
51 | # make install DESTDIR=/tmp/build/libpng
|
---|
52 | #
|
---|
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.
|
---|
56 | DESTDIR=
|
---|
57 |
|
---|
58 | DB=$(DESTDIR)$(BINPATH)
|
---|
59 | DI=$(DESTDIR)$(INCPATH)
|
---|
60 | DL=$(DESTDIR)$(LIBPATH)
|
---|
61 | DM=$(DESTDIR)$(MANPATH)
|
---|
62 |
|
---|
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
|
---|
66 |
|
---|
67 | OBJSDLL = $(OBJS:.o=.pic.o)
|
---|
68 |
|
---|
69 | .SUFFIXES: .c .o .pic.o
|
---|
70 |
|
---|
71 | .c.pic.o:
|
---|
72 | $(CC) -c $(CFLAGS) -fPIC -o $@ $*.c
|
---|
73 |
|
---|
74 | all: libpng.a $(LIBNAME).so pngtest pngtest-static libpng.pc libpng-config
|
---|
75 |
|
---|
76 | libpng.a: $(OBJS)
|
---|
77 | ar rc $@ $(OBJS)
|
---|
78 | $(RANLIB) $@
|
---|
79 |
|
---|
80 | libpng.pc:
|
---|
81 | cat scripts/libpng.pc.in | sed -e s\!@PREFIX@!$(prefix)! > libpng.pc
|
---|
82 |
|
---|
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")\
|
---|
88 | print $$(i+1) ";";\
|
---|
89 | for (i=1;i+1<=NF;++i)\
|
---|
90 | if ($$(i)=="PNG_DATA_EXPORT")\
|
---|
91 | print $$(i+1) ";";}\
|
---|
92 | END{print "local: *; };"}' >[email protected]
|
---|
93 | rm -f $@
|
---|
94 | mv [email protected] $@
|
---|
95 |
|
---|
96 | libpng-config:
|
---|
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
|
---|
105 |
|
---|
106 | $(LIBNAME).so: $(LIBNAME).so.$(PNGMAJ)
|
---|
107 | ln -sf $(LIBNAME).so.$(PNGMAJ) $(LIBNAME).so
|
---|
108 |
|
---|
109 | $(LIBNAME).so.$(PNGMAJ): $(LIBNAME).so.$(PNGVER)
|
---|
110 | ln -sf $(LIBNAME).so.$(PNGVER) $(LIBNAME).so.$(PNGMAJ)
|
---|
111 |
|
---|
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) \
|
---|
116 | $(OBJSDLL)
|
---|
117 |
|
---|
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) \
|
---|
122 | $(OBJSDLL)
|
---|
123 |
|
---|
124 | pngtest: pngtest.o $(LIBNAME).so
|
---|
125 | $(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS)
|
---|
126 |
|
---|
127 | pngtest-static: pngtest.o libpng.a
|
---|
128 | $(CC) -o pngtest-static $(CFLAGS) pngtest.o $(LDFLAGS_A)
|
---|
129 |
|
---|
130 | test: pngtest pngtest-static
|
---|
131 | @echo ""
|
---|
132 | @echo " Running pngtest dynamically linked with $(LIBNAME).so:"
|
---|
133 | @echo ""
|
---|
134 | ./pngtest
|
---|
135 | @echo ""
|
---|
136 | @echo " Running pngtest statically linked with libpng.a:"
|
---|
137 | @echo ""
|
---|
138 | ./pngtest-static
|
---|
139 |
|
---|
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)/* .)
|
---|
148 |
|
---|
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)
|
---|
155 |
|
---|
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)
|
---|
168 | (cd $(DL); \
|
---|
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)
|
---|
179 |
|
---|
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
|
---|
189 | cp png.5 $(DM)/man5
|
---|
190 |
|
---|
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)
|
---|
198 |
|
---|
199 | install: install-static install-shared install-man install-config
|
---|
200 |
|
---|
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
|
---|
203 | # before then.
|
---|
204 |
|
---|
205 | test-dd:
|
---|
206 | echo
|
---|
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
|
---|
213 |
|
---|
214 | test-installed:
|
---|
215 | $(CC) -I$(ZLIBINC) \
|
---|
216 | `$(BINPATH)/libpng12-config --cflags` pngtest.c \
|
---|
217 | -L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) \
|
---|
218 | -o pngtesti `$(BINPATH)/libpng12-config --ldflags`
|
---|
219 | ./pngtesti pngtest.png
|
---|
220 |
|
---|
221 | clean:
|
---|
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) \
|
---|
225 | libpng.pc
|
---|
226 |
|
---|
227 | DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO
|
---|
228 | writelock:
|
---|
229 | chmod a-w *.[ch35] $(DOCS) scripts/*
|
---|
230 |
|
---|
231 | # DO NOT DELETE THIS LINE -- make depend depends on it.
|
---|
232 |
|
---|
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
|
---|
248 |
|
---|
249 | pngtest.o: png.h pngconf.h
|
---|