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
|
---|
5 | #
|
---|
6 | # This code is released under the libpng license.
|
---|
7 | # For conditions of distribution and use, see the disclaimer
|
---|
8 | # and license in png.h
|
---|
9 |
|
---|
10 | # Library name:
|
---|
11 | LIBNAME = libpng12
|
---|
12 | PNGMAJ = 0
|
---|
13 | PNGMIN = 1.2.54
|
---|
14 | PNGVER = $(PNGMAJ).$(PNGMIN)
|
---|
15 |
|
---|
16 | # Shared library names:
|
---|
17 | LIBSO=$(LIBNAME).so
|
---|
18 | LIBSOMAJ=$(LIBNAME).so.$(PNGMAJ)
|
---|
19 | LIBSOVER=$(LIBNAME).so.$(PNGVER)
|
---|
20 | OLDSO=libpng.so
|
---|
21 | OLDSOMAJ=libpng.so.3
|
---|
22 | OLDSOVER=libpng.so.3.$(PNGMIN)
|
---|
23 |
|
---|
24 | # Utilities:
|
---|
25 | AR_RC=ar rc
|
---|
26 | CC=gcc
|
---|
27 | MKDIR_P=mkdir -p
|
---|
28 | LN_SF=ln -sf
|
---|
29 | RANLIB=ranlib
|
---|
30 | RM_F=/bin/rm -f
|
---|
31 |
|
---|
32 | # where "make install" puts libpng12.a, libpng12.so*,
|
---|
33 | # libpng12/png.h and libpng12/pngconf.h
|
---|
34 | # Prefix must be a full pathname.
|
---|
35 | prefix=/usr/local
|
---|
36 | exec_prefix=$(prefix)
|
---|
37 |
|
---|
38 | # Where the zlib library and include files are located.
|
---|
39 | #ZLIBLIB=/usr/local/lib
|
---|
40 | #ZLIBINC=/usr/local/include
|
---|
41 | ZLIBLIB=../zlib
|
---|
42 | ZLIBINC=../zlib
|
---|
43 |
|
---|
44 | ALIGN=
|
---|
45 | # for i386:
|
---|
46 | #ALIGN=-malign-loops=2 -malign-functions=2
|
---|
47 |
|
---|
48 | WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow \
|
---|
49 | -Wmissing-declarations -Wtraditional -Wcast-align \
|
---|
50 | -Wstrict-prototypes -Wmissing-prototypes #-Wconversion
|
---|
51 |
|
---|
52 | # for pgcc version 2.95.1, -O3 is buggy; don't use it.
|
---|
53 |
|
---|
54 | CFLAGS=-I$(ZLIBINC) -W -Wall -O3 -funroll-loops -DPNG_NO_MMX_CODE \
|
---|
55 | $(ALIGN) # $(WARNMORE) -g -DPNG_DEBUG=5
|
---|
56 |
|
---|
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
|
---|
59 |
|
---|
60 | INCPATH=$(prefix)/include
|
---|
61 | LIBPATH=$(exec_prefix)/lib
|
---|
62 | MANPATH=$(prefix)/man
|
---|
63 | BINPATH=$(exec_prefix)/bin
|
---|
64 |
|
---|
65 | # override DESTDIR= on the make install command line to easily support
|
---|
66 | # installing into a temporary location. Example:
|
---|
67 | #
|
---|
68 | # make install DESTDIR=/tmp/build/libpng
|
---|
69 | #
|
---|
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.
|
---|
73 | DESTDIR=
|
---|
74 |
|
---|
75 | DB=$(DESTDIR)$(BINPATH)
|
---|
76 | DI=$(DESTDIR)$(INCPATH)
|
---|
77 | DL=$(DESTDIR)$(LIBPATH)
|
---|
78 | DM=$(DESTDIR)$(MANPATH)
|
---|
79 |
|
---|
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
|
---|
83 |
|
---|
84 | OBJSDLL = $(OBJS:.o=.pic.o)
|
---|
85 |
|
---|
86 | .SUFFIXES: .c .o .pic.o
|
---|
87 |
|
---|
88 | .c.pic.o:
|
---|
89 | $(CC) -c $(CFLAGS) -fPIC -o $@ $*.c
|
---|
90 |
|
---|
91 | all: libpng.a $(LIBSO) pngtest pngtest-static libpng.pc libpng-config
|
---|
92 |
|
---|
93 | libpng.a: $(OBJS)
|
---|
94 | $(AR_RC) $@ $(OBJS)
|
---|
95 | $(RANLIB) $@
|
---|
96 |
|
---|
97 | libpng.pc:
|
---|
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
|
---|
105 |
|
---|
106 | libpng-config:
|
---|
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
|
---|
115 |
|
---|
116 | $(LIBSO): $(LIBSOMAJ)
|
---|
117 | $(LN_SF) $(LIBSOMAJ) $(LIBSO)
|
---|
118 |
|
---|
119 | $(LIBSOMAJ): $(LIBSOVER)
|
---|
120 | $(LN_SF) $(LIBSOVER) $(LIBSOMAJ)
|
---|
121 |
|
---|
122 | $(LIBSOVER): $(OBJSDLL)
|
---|
123 | $(CC) -shared -Wl,-soname,$(LIBSOMAJ) -o $(LIBSOVER) $(OBJSDLL)
|
---|
124 |
|
---|
125 | $(OLDSOVER): $(OBJSDLL)
|
---|
126 | $(CC) -shared -Wl,-soname,$(OLDSOMAJ) \
|
---|
127 | -o $(OLDSOVER) \
|
---|
128 | $(OBJSDLL)
|
---|
129 |
|
---|
130 | pngtest: pngtest.o $(LIBSO)
|
---|
131 | $(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS)
|
---|
132 |
|
---|
133 | pngtest-static: pngtest.o libpng.a
|
---|
134 | $(CC) -o pngtest-static $(CFLAGS) pngtest.o $(LDFLAGS_A)
|
---|
135 |
|
---|
136 | test: pngtest pngtest-static
|
---|
137 | @echo ""
|
---|
138 | @echo " Running pngtest dynamically linked with $(LIBSO):"
|
---|
139 | @echo ""
|
---|
140 | ./pngtest
|
---|
141 | @echo ""
|
---|
142 | @echo " Running pngtest statically linked with libpng.a:"
|
---|
143 | @echo ""
|
---|
144 | ./pngtest-static
|
---|
145 |
|
---|
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)/* .)
|
---|
154 |
|
---|
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)
|
---|
161 |
|
---|
162 | install-shared: install-headers $(LIBSOVER) libpng.pc \
|
---|
163 | $(OLDSOVER)
|
---|
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)*
|
---|
170 | cp $(LIBSOVER) $(DL)
|
---|
171 | cp $(OLDSOVER) $(DL)
|
---|
172 | chmod 755 $(DL)/$(LIBSOVER)
|
---|
173 | chmod 755 $(DL)/$(OLDSOVER)
|
---|
174 | (cd $(DL); \
|
---|
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)
|
---|
185 |
|
---|
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
|
---|
195 | cp png.5 $(DM)/man5
|
---|
196 |
|
---|
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)
|
---|
204 |
|
---|
205 | install: install-static install-shared install-man install-config
|
---|
206 |
|
---|
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
|
---|
209 | # before then.
|
---|
210 |
|
---|
211 | test-dd:
|
---|
212 | echo
|
---|
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
|
---|
219 |
|
---|
220 | test-installed:
|
---|
221 | $(CC) -I$(ZLIBINC) \
|
---|
222 | `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \
|
---|
223 | -L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) \
|
---|
224 | -o pngtesti `$(BINPATH)/$(LIBNAME)-config --ldflags`
|
---|
225 | ./pngtesti pngtest.png
|
---|
226 |
|
---|
227 | clean:
|
---|
228 | $(RM_F) *.o libpng.a pngtest pngout.png libpng-config \
|
---|
229 | $(LIBSO) $(LIBSOMAJ)* pngtest-static pngtesti \
|
---|
230 | $(OLDSOVER) \
|
---|
231 | libpng.pc
|
---|
232 |
|
---|
233 | DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO
|
---|
234 | writelock:
|
---|
235 | chmod a-w *.[ch35] $(DOCS) scripts/*
|
---|
236 |
|
---|
237 | # DO NOT DELETE THIS LINE -- make depend depends on it.
|
---|
238 |
|
---|
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
|
---|
254 |
|
---|
255 | pngtest.o: png.h pngconf.h pngtest.c
|
---|