]> git.saurik.com Git - wxWidgets.git/blame - src/png/scripts/makefile.elf
guard code for mac / quickdraw
[wxWidgets.git] / src / png / scripts / makefile.elf
CommitLineData
0272a10d
VZ
1# makefile for libpng.a and libpng12.so on Linux ELF with gcc
2# Copyright (C) 1998, 1999, 2002, 2006 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# Modified for Debian by Junichi Uekawa and Josselin Mouette
7# Major modifications are:
8# * link libpng explicitly with libz and libm
9# * $(OLDSO).3 is a symlink rather than a different library
10# * versioned symbols
11
12# Library name:
13LIBNAME = libpng12
14PNGMAJ = 0
15PNGMIN = 1.2.20
16PNGVER = $(PNGMAJ).$(PNGMIN)
17
18# Shared library names:
19LIBSO=$(LIBNAME).so
20LIBSOMAJ=$(LIBNAME).so.$(PNGMAJ)
21LIBSOVER=$(LIBNAME).so.$(PNGVER)
22OLDSO=libpng.so
23OLDSOMAJ=libpng.so.3
24OLDSOVER=libpng.so.3.$(PNGMIN)
25
26# Utilities:
27AR_RC=ar rc
28CC=gcc
29MKDIR_P=mkdir -p
30LN_SF=ln -sf
31RANLIB=ranlib
32RM_F=/bin/rm -f
33
34# where "make install" puts libpng12.a, libpng12.so*,
35# libpng12/png.h and libpng12/pngconf.h
36# Prefix must be a full pathname.
37prefix=/usr/local
38exec_prefix=$(prefix)
39
40# Where the zlib library and include files are located.
41ZLIBLIB=/usr/local/lib
42ZLIBINC=/usr/local/include
43# ZLIBLIB=../zlib
44# ZLIBINC=../zlib
45
46ALIGN=
47# for i386:
48#ALIGN=-malign-loops=2 -malign-functions=2
49
50WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow \
51 -Wmissing-declarations -Wtraditional -Wcast-align \
52 -Wstrict-prototypes -Wmissing-prototypes #-Wconversion
53
54# for pgcc version 2.95.1, -O3 is buggy; don't use it.
55
56CFLAGS=-Wall -D_REENTRANT -O2 \
57 $(ALIGN) # $(WARNMORE) -g -DPNG_DEBUG=5
58
59LDFLAGS=-L. -lpng12
60LDFLAGS_A=libpng.a -lz -lm
61LIBADDFLAGS=-lz -lm
62
63
64INCPATH=$(prefix)/include
65LIBPATH=$(exec_prefix)/lib
66MANPATH=$(prefix)/man
67BINPATH=$(exec_prefix)/bin
68
69# override DESTDIR= on the make install command line to easily support
70# installing into a temporary location. Example:
71#
72# make install DESTDIR=/tmp/build/libpng
73#
74# If you're going to install into a temporary location
75# via DESTDIR, $(DESTDIR)$(prefix) must already exist before
76# you execute make install.
77DESTDIR=
78
79DB=$(DESTDIR)$(BINPATH)
80DI=$(DESTDIR)$(INCPATH)
81DL=$(DESTDIR)$(LIBPATH)
82DM=$(DESTDIR)$(MANPATH)
83
84OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \
85 pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \
86 pngwtran.o pngmem.o pngerror.o pngpread.o
87
88OBJSDLL = $(OBJS:.o=.pic.o)
89
90.SUFFIXES: .c .o .pic.o
91
92.c.pic.o:
93 $(CC) -c $(CFLAGS) -fPIC -o $@ $*.c
94
95all: libpng.a $(LIBSO) pngtest pngtest-static libpng.pc libpng-config
96
97libpng.a: $(OBJS)
98 $(AR_RC) $@ $(OBJS)
99 $(RANLIB) $@
100
101libpng.pc:
102 cat scripts/libpng.pc.in | sed -e s\!@PREFIX@!$(prefix)! > libpng.pc
103
104libpng.syms: png.h pngconf.h
105 $(CC) $(CFLAGS) -E -DPNG_BUILDSYMS -DPNG_INTERNAL png.h |\
106 awk -F '[\t [\\]();]' -v PNGMAJ=$(PNGMAJ) 'BEGIN{printf("PNG12_%s {global:\n",PNGMAJ)}\
107 { for (i=1;i+2<=NF;++i)\
108 if ($$(i)=="PNG_FUNCTION_EXPORT" && $$(i+2)=="END")\
109 print $$(i+1) ";";\
110 for (i=1;i+1<=NF;++i)\
111 if ($$(i)=="PNG_DATA_EXPORT")\
112 print $$(i+1) ";";}\
113 END{print "local: *; };"}' >$@.new
114 $(RM_F) $@
115 mv $@.new $@
116
117libpng-config:
118 ( cat scripts/libpng-config-head.in; \
119 echo prefix=\"$(prefix)\"; \
120 echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \
121 echo L_opts=\"\"; \
122 echo R_opts=\"\"; \
123 echo libs=\"-lpng12\"; \
124 echo all_libs=\"-lpng12 $(LIBADDFLAGS)\"; \
125 cat scripts/libpng-config-body.in ) > libpng-config
126 chmod +x libpng-config
127
128$(LIBSO): $(LIBSOMAJ)
129 $(LN_SF) $(LIBSOMAJ) $(LIBSO)
130
131$(LIBSOMAJ): $(LIBSOVER)
132 $(LN_SF) $(LIBSOVER) $(LIBSOMAJ)
133
134$(LIBSOVER): $(OBJSDLL) libpng.syms
135 $(CC) -shared -Wl,-soname,$(LIBSOMAJ) \
136 -Wl,-version-script,libpng.syms \
137 -o $(LIBSOVER) \
138 $(OBJSDLL)
139
140$(OLDSOVER): $(OBJSDLL) libpng.syms
141 $(CC) -shared -Wl,-soname,$(OLDSOMAJ) \
142 -Wl,-version-script,libpng.syms \
143 -o $(OLDSOVER) \
144 $(OBJSDLL)
145
146pngtest: pngtest.o $(LIBSO)
147 $(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS)
148
149pngtest-static: pngtest.o libpng.a
150 $(CC) -o pngtest-static $(CFLAGS) pngtest.o $(LDFLAGS_A)
151
152test: pngtest pngtest-static
153 @echo ""
154 @echo " Running pngtest dynamically linked with $(LIBSO):"
155 @echo ""
156 LD_LIBRARY_PATH=".:${LD_LIBRARY_PATH}" ./pngtest
157 @echo ""
158 @echo " Running pngtest statically linked with libpng.a:"
159 @echo ""
160 ./pngtest-static
161
162install-headers: png.h pngconf.h
163 -@if [ ! -d $(DI) ]; then $(MKDIR_P) $(DI); fi
164 -@if [ ! -d $(DI)/$(LIBNAME) ]; then $(MKDIR_P) $(DI)/$(LIBNAME); fi
165 cp png.h pngconf.h $(DI)/$(LIBNAME)
166 chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h
167 -@$(RM_F) $(DI)/png.h $(DI)/pngconf.h
168 -@$(RM_F) $(DI)/libpng
169 (cd $(DI); $(LN_SF) $(LIBNAME) libpng; $(LN_SF) $(LIBNAME)/* .)
170
171install-static: install-headers libpng.a
172 -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi
173 cp libpng.a $(DL)/$(LIBNAME).a
174 chmod 644 $(DL)/$(LIBNAME).a
175 -@$(RM_F) $(DL)/libpng.a
176 (cd $(DL); $(LN_SF) $(LIBNAME).a libpng.a)
177
178install-shared: install-headers $(LIBSOVER) libpng.pc \
179 $(OLDSOVER)
180 -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi
181 -@$(RM_F) $(DL)/$(LIBSOVER)* $(DL)/$(LIBSO)
182 -@$(RM_F) $(DL)/$(LIBSOMAJ)
183 -@$(RM_F) $(DL)/$(OLDSO)
184 -@$(RM_F) $(DL)/$(OLDSOMAJ)
185 -@$(RM_F) $(DL)/$(OLDSOVER)*
186 cp $(LIBSOVER) $(DL)
187 cp $(OLDSOVER) $(DL)
188 chmod 755 $(DL)/$(LIBSOVER)
189 chmod 755 $(DL)/$(OLDSOVER)
190 (cd $(DL); \
191 $(LN_SF) $(OLDSOVER) $(OLDSOMAJ); \
192 $(LN_SF) $(OLDSOMAJ) $(OLDSO); \
193 $(LN_SF) $(LIBSOVER) $(LIBSOMAJ); \
194 $(LN_SF) $(LIBSOMAJ) $(LIBSO))
195 -@if [ ! -d $(DL)/pkgconfig ]; then $(MKDIR_P) $(DL)/pkgconfig; fi
196 -@$(RM_F) $(DL)/pkgconfig/$(LIBNAME).pc
197 -@$(RM_F) $(DL)/pkgconfig/libpng.pc
198 cp libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc
199 chmod 644 $(DL)/pkgconfig/$(LIBNAME).pc
200 (cd $(DL)/pkgconfig; $(LN_SF) $(LIBNAME).pc libpng.pc)
201
202install-man: libpng.3 libpngpf.3 png.5
203 -@if [ ! -d $(DM) ]; then $(MKDIR_P) $(DM); fi
204 -@if [ ! -d $(DM)/man3 ]; then $(MKDIR_P) $(DM)/man3; fi
205 -@$(RM_F) $(DM)/man3/libpng.3
206 -@$(RM_F) $(DM)/man3/libpngpf.3
207 cp libpng.3 $(DM)/man3
208 cp libpngpf.3 $(DM)/man3
209 -@if [ ! -d $(DM)/man5 ]; then $(MKDIR_P) $(DM)/man5; fi
210 -@$(RM_F) $(DM)/man5/png.5
211 cp png.5 $(DM)/man5
212
213install-config: libpng-config
214 -@if [ ! -d $(DB) ]; then $(MKDIR_P) $(DB); fi
215 -@$(RM_F) $(DB)/libpng-config
216 -@$(RM_F) $(DB)/$(LIBNAME)-config
217 cp libpng-config $(DB)/$(LIBNAME)-config
218 chmod 755 $(DB)/$(LIBNAME)-config
219 (cd $(DB); $(LN_SF) $(LIBNAME)-config libpng-config)
220
221install: install-static install-shared install-man install-config
222
223# If you installed in $(DESTDIR), test-installed won't work until you
224# move the library to its final location. Use test-dd to test it
225# before then.
226
227test-dd:
228 echo
229 echo Testing installed dynamic shared library in $(DL).
230 $(CC) -I$(DI) -I$(ZLIBINC) \
231 `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \
232 -L$(DL) -L$(ZLIBLIB) -Wl, -rpath,$(DL) -Wl,-rpath,$(ZLIBLIB) \
233 -o pngtestd `$(BINPATH)/$(LIBNAME)-config --ldflags`
234 ./pngtestd pngtest.png
235
236test-installed:
237 $(CC) -I$(ZLIBINC) \
238 `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \
239 -L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) \
240 -o pngtesti `$(BINPATH)/$(LIBNAME)-config --ldflags`
241 ./pngtesti pngtest.png
242
243clean:
244 $(RM_F) *.o libpng.a libpng.syms pngtest pngout.png libpng-config \
245 $(LIBSO) $(LIBSOMAJ)* pngtest-static pngtesti \
246 $(OLDSOVER) \
247 libpng.pc
248
249DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO
250writelock:
251 chmod a-w *.[ch35] $(DOCS) scripts/*
252
253# DO NOT DELETE THIS LINE -- make depend depends on it.
254
255png.o png.pic.o: png.h pngconf.h
256pngerror.o pngerror.pic.o: png.h pngconf.h
257pngrio.o pngrio.pic.o: png.h pngconf.h
258pngwio.o pngwio.pic.o: png.h pngconf.h
259pngmem.o pngmem.pic.o: png.h pngconf.h
260pngset.o pngset.pic.o: png.h pngconf.h
261pngget.o pngget.pic.o: png.h pngconf.h
262pngread.o pngread.pic.o: png.h pngconf.h
263pngrtran.o pngrtran.pic.o: png.h pngconf.h
264pngrutil.o pngrutil.pic.o: png.h pngconf.h
265pngtrans.o pngtrans.pic.o: png.h pngconf.h
266pngwrite.o pngwrite.pic.o: png.h pngconf.h
267pngwtran.o pngwtran.pic.o: png.h pngconf.h
268pngwutil.o pngwutil.pic.o: png.h pngconf.h
269pngpread.o pngpread.pic.o: png.h pngconf.h
270
271pngtest.o: png.h pngconf.h