]> git.saurik.com Git - wxWidgets.git/blob - src/png/scripts/makefile.linux
added IsFalse() to simplify code doing HasOption(very-long-option-name) && !GetOption...
[wxWidgets.git] / src / png / scripts / makefile.linux
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.7
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-config:
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
92
93 $(LIBNAME).so: $(LIBNAME).so.$(PNGMAJ)
94 ln -sf $(LIBNAME).so.$(PNGMAJ) $(LIBNAME).so
95
96 $(LIBNAME).so.$(PNGMAJ): $(LIBNAME).so.$(PNGVER)
97 ln -sf $(LIBNAME).so.$(PNGVER) $(LIBNAME).so.$(PNGMAJ)
98
99 $(LIBNAME).so.$(PNGVER): $(OBJSDLL)
100 $(CC) -shared -Wl,-soname,$(LIBNAME).so.$(PNGMAJ) \
101 -o $(LIBNAME).so.$(PNGVER) \
102 $(OBJSDLL)
103
104 libpng.so.3.$(PNGMIN): $(OBJSDLL)
105 $(CC) -shared -Wl,-soname,libpng.so.3 \
106 -o libpng.so.3.$(PNGMIN) \
107 $(OBJSDLL)
108
109 pngtest: pngtest.o $(LIBNAME).so
110 $(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS)
111
112 pngtest-static: pngtest.o libpng.a
113 $(CC) -o pngtest-static $(CFLAGS) pngtest.o $(LDFLAGS_A)
114
115 test: pngtest pngtest-static
116 @echo ""
117 @echo " Running pngtest dynamically linked with $(LIBNAME).so:"
118 @echo ""
119 ./pngtest
120 @echo ""
121 @echo " Running pngtest statically linked with libpng.a:"
122 @echo ""
123 ./pngtest-static
124
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)/* .)
133
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)
140
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)/$(LIBNAME).so.$(PNGMAJ)
146 -@/bin/rm -f $(DL)/libpng.so
147 -@/bin/rm -f $(DL)/libpng.so.3
148 -@/bin/rm -f $(DL)/libpng.so.3.$(PNGMIN)*
149 cp $(LIBNAME).so.$(PNGVER) $(DL)
150 cp libpng.so.3.$(PNGMIN) $(DL)
151 chmod 755 $(DL)/$(LIBNAME).so.$(PNGVER)
152 chmod 755 $(DL)/libpng.so.3.$(PNGMIN)
153 (cd $(DL); \
154 ln -sf libpng.so.3.$(PNGMIN) libpng.so.3; \
155 ln -sf libpng.so.3 libpng.so; \
156 ln -sf $(LIBNAME).so.$(PNGVER) $(LIBNAME).so.$(PNGMAJ); \
157 ln -sf $(LIBNAME).so.$(PNGMAJ) $(LIBNAME).so)
158 -@if [ ! -d $(DL)/pkgconfig ]; then mkdir $(DL)/pkgconfig; fi
159 -@/bin/rm -f $(DL)/pkgconfig/$(LIBNAME).pc
160 -@/bin/rm -f $(DL)/pkgconfig/libpng.pc
161 cp libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc
162 chmod 644 $(DL)/pkgconfig/$(LIBNAME).pc
163 (cd $(DL)/pkgconfig; ln -sf $(LIBNAME).pc libpng.pc)
164
165 install-man: libpng.3 libpngpf.3 png.5
166 -@if [ ! -d $(DM) ]; then mkdir $(DM); fi
167 -@if [ ! -d $(DM)/man3 ]; then mkdir $(DM)/man3; fi
168 -@/bin/rm -f $(DM)/man3/libpng.3
169 -@/bin/rm -f $(DM)/man3/libpngpf.3
170 cp libpng.3 $(DM)/man3
171 cp libpngpf.3 $(DM)/man3
172 -@if [ ! -d $(DM)/man5 ]; then mkdir $(DM)/man5; fi
173 -@/bin/rm -f $(DM)/man5/png.5
174 cp png.5 $(DM)/man5
175
176 install-config: libpng-config
177 -@if [ ! -d $(DB) ]; then mkdir $(DB); fi
178 -@/bin/rm -f $(DB)/libpng-config
179 -@/bin/rm -f $(DB)/$(LIBNAME)-config
180 cp libpng-config $(DB)/$(LIBNAME)-config
181 chmod 755 $(DB)/$(LIBNAME)-config
182 (cd $(DB); ln -sf $(LIBNAME)-config libpng-config)
183
184 install: install-static install-shared install-man install-config
185
186 # If you installed in $(DESTDIR), test-installed won't work until you
187 # move the library to its final location. Use test-dd to test it
188 # before then.
189
190 test-dd:
191 echo
192 echo Testing installed dynamic shared library in $(DL).
193 $(CC) -I$(DI) -I$(ZLIBINC) \
194 `$(BINPATH)/libpng12-config --cflags` pngtest.c \
195 -L$(DL) -L$(ZLIBLIB) -W1, -rpath,$(DL) -Wl,-rpath,$(ZLIBLIB) \
196 -o pngtestd `$(BINPATH)/libpng12-config --ldflags`
197 ./pngtestd pngtest.png
198
199 test-installed:
200 $(CC) -I$(ZLIBINC) \
201 `$(BINPATH)/libpng12-config --cflags` pngtest.c \
202 -L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) \
203 -o pngtesti `$(BINPATH)/libpng12-config --ldflags`
204 ./pngtesti pngtest.png
205
206 clean:
207 /bin/rm -f *.o libpng.a pngtest pngout.png libpng-config \
208 $(LIBNAME).so $(LIBNAME).so.$(PNGMAJ)* pngtest-static pngtesti \
209 libpng.so.3.$(PNGMIN) \
210 libpng.pc
211
212 DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO
213 writelock:
214 chmod a-w *.[ch35] $(DOCS) scripts/*
215
216 # DO NOT DELETE THIS LINE -- make depend depends on it.
217
218 png.o png.pic.o: png.h pngconf.h
219 pngerror.o pngerror.pic.o: png.h pngconf.h
220 pngrio.o pngrio.pic.o: png.h pngconf.h
221 pngwio.o pngwio.pic.o: png.h pngconf.h
222 pngmem.o pngmem.pic.o: png.h pngconf.h
223 pngset.o pngset.pic.o: png.h pngconf.h
224 pngget.o pngget.pic.o: png.h pngconf.h
225 pngread.o pngread.pic.o: png.h pngconf.h
226 pngrtran.o pngrtran.pic.o: png.h pngconf.h
227 pngrutil.o pngrutil.pic.o: png.h pngconf.h
228 pngtrans.o pngtrans.pic.o: png.h pngconf.h
229 pngwrite.o pngwrite.pic.o: png.h pngconf.h
230 pngwtran.o pngwtran.pic.o: png.h pngconf.h
231 pngwutil.o pngwutil.pic.o: png.h pngconf.h
232 pngpread.o pngpread.pic.o: png.h pngconf.h
233
234 pngtest.o: png.h pngconf.h