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 cppflags=\"-I$(INCPATH)/$(LIBNAME)\"; \
88 echo ldflags=\"-L$(LIBPATH) -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) \
102 $(OBJSDLL) -L$(ZLIBLIB) -lz -lm -lc
104 pngtest: pngtest.o $(LIBNAME).so
105 $(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS)
107 pngtest-static: pngtest.o libpng.a
108 $(CC) -o pngtest-static $(CFLAGS) pngtest.o $(LDFLAGS_A)
110 test: pngtest pngtest-static
112 @echo " Running pngtest dynamically linked with $(LIBNAME).so:"
116 @echo " Running pngtest statically linked with libpng.a:"
120 install-headers: png.h pngconf.h
121 -@if [ ! -d $(DI) ]; then mkdir $(DI); fi
122 -@if [ ! -d $(DI)/$(LIBNAME) ]; then mkdir $(DI)/$(LIBNAME); fi
123 cp png.h pngconf.h $(DI)/$(LIBNAME)
124 chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h
125 -@/bin/rm -f $(DI)/png.h $(DI)/pngconf.h
126 -@/bin/rm -f $(DI)/libpng
127 (cd $(DI); ln -sf $(LIBNAME) libpng; ln -sf $(LIBNAME)/* .)
129 install-static: install-headers libpng.a
130 -@if [ ! -d $(DL) ]; then mkdir $(DL); fi
131 cp libpng.a $(DL)/$(LIBNAME).a
132 chmod 644 $(DL)/$(LIBNAME).a
133 -@/bin/rm -f $(DL)/libpng.a
134 (cd $(DL); ln -sf $(LIBNAME).a libpng.a)
136 install-shared: install-headers $(LIBNAME).so.$(PNGVER) libpng.pc
137 -@if [ ! -d $(DL) ]; then mkdir $(DL); fi
138 -@/bin/rm -f $(DL)/$(LIBNAME).so.$(PNGMAJ)* $(DL)/$(LIBNAME).so
139 -@/bin/rm -f $(DL)/libpng.so
140 -@/bin/rm -f $(DL)/libpng.so.3
141 -@/bin/rm -f $(DL)/libpng.so.3.*
142 cp $(LIBNAME).so.$(PNGVER) $(DL)
143 chmod 755 $(DL)/$(LIBNAME).so.$(PNGVER)
145 ln -sf $(LIBNAME).so.$(PNGVER) libpng.so; \
146 ln -sf $(LIBNAME).so.$(PNGVER) libpng.so.3; \
147 ln -sf $(LIBNAME).so.$(PNGVER) libpng.so.3.$(PNGMIN); \
148 ln -sf $(LIBNAME).so.$(PNGVER) $(LIBNAME).so.$(PNGMAJ); \
149 ln -sf $(LIBNAME).so.$(PNGMAJ) $(LIBNAME).so)
150 -@if [ ! -d $(DL)/pkgconfig ]; then mkdir $(DL)/pkgconfig; fi
151 -@/bin/rm -f $(DL)/pkgconfig/$(LIBNAME).pc
152 -@/bin/rm -f $(DL)/pkgconfig/libpng.pc
153 cp libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc
154 chmod 644 $(DL)/pkgconfig/$(LIBNAME).pc
155 (cd $(DL)/pkgconfig; ln -sf $(LIBNAME).pc libpng.pc)
157 install-man: libpng.3 libpngpf.3 png.5
158 -@if [ ! -d $(DM) ]; then mkdir $(DM); fi
159 -@if [ ! -d $(DM)/man3 ]; then mkdir $(DM)/man3; fi
160 -@/bin/rm -f $(DM)/man3/libpng.3
161 -@/bin/rm -f $(DM)/man3/libpngpf.3
162 cp libpng.3 $(DM)/man3
163 cp libpngpf.3 $(DM)/man3
164 -@if [ ! -d $(DM)/man5 ]; then mkdir $(DM)/man5; fi
165 -@/bin/rm -f $(DM)/man5/png.5
168 install-config: libpng-config
169 -@if [ ! -d $(DB) ]; then mkdir $(DB); fi
170 -@/bin/rm -f $(DB)/libpng-config
171 -@/bin/rm -f $(DB)/$(LIBNAME)-config
172 cp libpng-config $(DB)/$(LIBNAME)-config
173 chmod 755 $(DB)/$(LIBNAME)-config
174 (cd $(DB); ln -sf $(LIBNAME)-config libpng-config)
176 install: install-static install-shared install-man install-config
178 # If you installed in $(DESTDIR), test-installed won't work until you
179 # move the library to its final location.
183 `$(BINPATH)/libpng12-config --cppflags --cflags` pngtest.c \
184 -L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) \
185 -o pngtesti `$(BINPATH)/libpng12-config --ldflags --libs`
186 ./pngtesti pngtest.png
189 /bin/rm -f *.o libpng.a pngtest pngout.png libpng.pc libpng-config \
190 $(LIBNAME).so $(LIBNAME).so.$(PNGMAJ)* pngtest-static pngtesti
192 DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO
194 chmod a-w *.[ch35] $(DOCS) scripts/*
196 # DO NOT DELETE THIS LINE -- make depend depends on it.
198 png.o png.pic.o: png.h pngconf.h
199 pngerror.o pngerror.pic.o: png.h pngconf.h
200 pngrio.o pngrio.pic.o: png.h pngconf.h
201 pngwio.o pngwio.pic.o: png.h pngconf.h
202 pngmem.o pngmem.pic.o: png.h pngconf.h
203 pngset.o pngset.pic.o: png.h pngconf.h
204 pngget.o pngget.pic.o: png.h pngconf.h
205 pngread.o pngread.pic.o: png.h pngconf.h
206 pngrtran.o pngrtran.pic.o: png.h pngconf.h
207 pngrutil.o pngrutil.pic.o: png.h pngconf.h
208 pngtrans.o pngtrans.pic.o: png.h pngconf.h
209 pngwrite.o pngwrite.pic.o: png.h pngconf.h
210 pngwtran.o pngwtran.pic.o: png.h pngconf.h
211 pngwutil.o pngwutil.pic.o: png.h pngconf.h
212 pngpread.o pngpread.pic.o: png.h pngconf.h
214 pngtest.o: png.h pngconf.h