blob: 29a8022f75220c53e7f7ffd5670f5622ec9c49bd [file] [log] [blame]
Glenn Randers-Pehrson9c0f0942002-02-21 23:14:23 -06001# makefile for libpng.a and libpng12.so on Linux ELF with gcc using MMX
2# assembler code
3# Copyright 2002 Greg Roelofs and Glenn Randers-Pehrson
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -06004# Copyright 1998-2001 Greg Roelofs
Glenn Randers-Pehrson9c0f0942002-02-21 23:14:23 -06005# Copyright 1996-1997 Andreas Dilger
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -06006# For conditions of distribution and use, see copyright notice in png.h
7
Glenn Randers-Pehrsona4d54bd2000-07-14 08:15:12 -05008# CAUTION: Do not use this makefile with gcc versions 2.7.2.2 and earlier.
9
Glenn Randers-Pehrson1ea0ff32001-08-07 22:25:59 -050010# WARNING: The assembler code in pnggccrd.c may not be thread safe.
11
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -060012# NOTE: When testing MMX performance on a multitasking system, make sure
13# there are no floating-point programs (e.g., SETI@Home) running in
14# the background! Context switches between MMX and FPU are expensive.
15
Glenn Randers-Pehrson9c0f0942002-02-21 23:14:23 -060016LIBNAME = libpng12
17PNGMAJ = 0
Glenn Randers-Pehrsona4981d42004-08-25 22:00:45 -050018PNGMIN = 1.2.7beta1
Glenn Randers-Pehrson9c0f0942002-02-21 23:14:23 -060019PNGVER = $(PNGMAJ).$(PNGMIN)
20
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -060021CC=gcc
22
Glenn Randers-Pehrsond1e8c862002-06-20 06:54:34 -050023# where "make install" puts libpng12.a, libpng12.so*,
24# libpng12/png.h and libpng12/pngconf.h
25# Prefix must be a full pathname.
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -060026prefix=/usr/local
27
Glenn Randers-Pehrsond1e8c862002-06-20 06:54:34 -050028# Where the zlib library and include files are located.
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -060029#ZLIBLIB=/usr/local/lib
30#ZLIBINC=/usr/local/include
31ZLIBLIB=../zlib
32ZLIBINC=../zlib
33
34ALIGN=
35# for i386:
36#ALIGN=-malign-loops=2 -malign-functions=2
37
38WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow \
39 -Wmissing-declarations -Wtraditional -Wcast-align \
40 -Wstrict-prototypes -Wmissing-prototypes #-Wconversion
41
42# for pgcc version 2.95.1, -O3 is buggy; don't use it.
43
Glenn Randers-Pehrson1ea0ff32001-08-07 22:25:59 -050044# Remove -DPNG_THREAD_UNSAFE_OK if you need thread safety
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -060045### for generic gcc:
Glenn Randers-Pehrson1ea0ff32001-08-07 22:25:59 -050046CFLAGS=-DPNG_THREAD_UNSAFE_OK -DPNG_USE_PNGGCCRD -I$(ZLIBINC) -Wall \
Glenn Randers-Pehrson4fb046a2002-04-15 09:25:51 -050047 -O3 $(ALIGN) -funroll-loops \
Glenn Randers-Pehrsond56aca72000-11-23 11:51:42 -060048 -fomit-frame-pointer # $(WARNMORE) -g -DPNG_DEBUG=5
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -060049### for gcc 2.95.2 on 686:
Glenn Randers-Pehrson1ea0ff32001-08-07 22:25:59 -050050#CFLAGS=-DPNG_THREAD_UNSAFE_OK -DPNG_USE_PNGGCCRD -I$(ZLIBINC) -Wall -O3 \
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -060051# -mcpu=i686 -malign-double -ffast-math -fstrict-aliasing \
52# $(ALIGN) -funroll-loops -funroll-all-loops -fomit-frame-pointer
53### for gcc 2.7.2.3 on 486 and up:
Glenn Randers-Pehrson1ea0ff32001-08-07 22:25:59 -050054#CFLAGS=-DPNG_THREAD_UNSAFE_OK -DPNG_USE_PNGGCCRD -I$(ZLIBINC) -Wall -O3 \
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -060055# -m486 -malign-double -ffast-math \
56# $(ALIGN) -funroll-loops -funroll-all-loops -fomit-frame-pointer
57
Glenn Randers-Pehrson9c0f0942002-02-21 23:14:23 -060058LDFLAGS=-L. -Wl,-rpath,. -L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) -lpng12 -lz -lm
Glenn Randers-Pehrson5e5c1e12000-11-10 12:26:19 -060059LDFLAGS_A=-L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) libpng.a -lz -lm
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -060060
Glenn Randers-Pehrson5b5dcf82004-07-17 22:45:44 -050061RANLIB=ranlib
62#RANLIB=echo
63
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -060064INCPATH=$(prefix)/include
65LIBPATH=$(prefix)/lib
Glenn Randers-Pehrson03008a02002-04-27 10:11:25 -050066MANPATH=$(prefix)/man
Glenn Randers-Pehrson704228f2002-05-02 20:49:40 -050067BINPATH=$(prefix)/bin
Glenn Randers-Pehrson03008a02002-04-27 10:11:25 -050068
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
Glenn Randers-Pehrson07748d12002-05-25 11:12:10 -050075# via DESTDIR, $(DESTDIR)$(prefix) must already exist before
Glenn Randers-Pehrson03008a02002-04-27 10:11:25 -050076# you execute make install.
77DESTDIR=
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -060078
Glenn Randers-Pehrson07748d12002-05-25 11:12:10 -050079DB=$(DESTDIR)$(BINPATH)
80DI=$(DESTDIR)$(INCPATH)
81DL=$(DESTDIR)$(LIBPATH)
82DM=$(DESTDIR)$(MANPATH)
Glenn Randers-Pehrsoncfbed9b2002-05-21 18:06:08 -050083
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -060084OBJS = 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 pnggccrd.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
Glenn Randers-Pehrson07748d12002-05-25 11:12:10 -050095all: libpng.a $(LIBNAME).so pngtest pngtest-static libpng.pc libpng-config
Glenn Randers-Pehrson03008a02002-04-27 10:11:25 -050096
Glenn Randers-Pehrsond1e8c862002-06-20 06:54:34 -050097libpng.a: $(OBJS)
Glenn Randers-Pehrson5b5dcf82004-07-17 22:45:44 -050098 ar rc $@ $(OBJS)
Glenn Randers-Pehrsond1e8c862002-06-20 06:54:34 -050099 $(RANLIB) $@
100
Glenn Randers-Pehrson03008a02002-04-27 10:11:25 -0500101libpng.pc:
102 cat scripts/libpng.pc.in | sed -e s\!@PREFIX@!$(prefix)! > libpng.pc
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600103
Glenn Randers-Pehrson837a3d12002-05-10 20:19:58 -0500104libpng-config:
105 ( cat scripts/libpng-config-head.in; \
106 echo prefix=\"$(prefix)\"; \
Glenn Randers-Pehrson5ff38d32002-09-17 23:38:46 -0500107 echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \
108 echo cppflags=\"-DPNG_THREAD_UNSAFE_OK -DPNG_USE_PNGGCCRD\"; \
109 echo L_opts=\"-L$(LIBPATH)\"; \
110 echo R_opts=\"-Wl,-rpath,$(LIBPATH)\"; \
Glenn Randers-Pehrson837a3d12002-05-10 20:19:58 -0500111 echo libs=\"-lpng12 -lz -lm\"; \
112 cat scripts/libpng-config-body.in ) > libpng-config
113 chmod +x libpng-config
114
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600115pnggccrd.o: pnggccrd.c png.h pngconf.h
Glenn Randers-Pehrson520a7642000-03-21 05:13:06 -0600116 $(CC) -c $(CFLAGS) -o $@ $*.c
117
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600118pnggccrd.pic.o: pnggccrd.c png.h pngconf.h
Glenn Randers-Pehrson520a7642000-03-21 05:13:06 -0600119 $(CC) -c $(CFLAGS) -fPIC -o $@ pnggccrd.c
120
Glenn Randers-Pehrson9c0f0942002-02-21 23:14:23 -0600121$(LIBNAME).so: $(LIBNAME).so.$(PNGMAJ)
122 ln -sf $(LIBNAME).so.$(PNGMAJ) $(LIBNAME).so
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600123
Glenn Randers-Pehrson9c0f0942002-02-21 23:14:23 -0600124$(LIBNAME).so.$(PNGMAJ): $(LIBNAME).so.$(PNGVER)
125 ln -sf $(LIBNAME).so.$(PNGVER) $(LIBNAME).so.$(PNGMAJ)
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600126
Glenn Randers-Pehrson9c0f0942002-02-21 23:14:23 -0600127$(LIBNAME).so.$(PNGVER): $(OBJSDLL)
Glenn Randers-Pehrsond1e8c862002-06-20 06:54:34 -0500128 $(CC) -shared -Wl,-soname,$(LIBNAME).so.$(PNGMAJ) \
129 -o $(LIBNAME).so.$(PNGVER) \
Glenn Randers-Pehrson865f4f02002-09-15 20:30:38 -0500130 $(OBJSDLL)
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600131
Glenn Randers-Pehrson8a7df002002-08-15 22:02:57 -0500132libpng.so.3.$(PNGMIN): $(OBJSDLL)
133 $(CC) -shared -Wl,-soname,libpng.so.3 \
134 -o libpng.so.3.$(PNGMIN) \
Glenn Randers-Pehrson865f4f02002-09-15 20:30:38 -0500135 $(OBJSDLL)
Glenn Randers-Pehrson8a7df002002-08-15 22:02:57 -0500136
Glenn Randers-Pehrson9c0f0942002-02-21 23:14:23 -0600137pngtest: pngtest.o $(LIBNAME).so
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600138 $(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS)
139
Glenn Randers-Pehrson03008a02002-04-27 10:11:25 -0500140pngtest-static: pngtest.o libpng.a
Glenn Randers-Pehrson5e5c1e12000-11-10 12:26:19 -0600141 $(CC) -o pngtest-static $(CFLAGS) pngtest.o $(LDFLAGS_A)
142
143test: pngtest pngtest-static
144 @echo ""
Glenn Randers-Pehrson837a3d12002-05-10 20:19:58 -0500145 @echo " Running pngtest dynamically linked with $(LIBNAME).so:"
Glenn Randers-Pehrson5e5c1e12000-11-10 12:26:19 -0600146 @echo ""
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600147 ./pngtest
Glenn Randers-Pehrson5e5c1e12000-11-10 12:26:19 -0600148 @echo ""
Glenn Randers-Pehrson9c0f0942002-02-21 23:14:23 -0600149 @echo " Running pngtest statically linked with libpng.a:"
Glenn Randers-Pehrson5e5c1e12000-11-10 12:26:19 -0600150 @echo ""
151 ./pngtest-static
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600152
Glenn Randers-Pehrsonc1bfe682002-03-06 22:08:00 -0600153install-headers: png.h pngconf.h
Glenn Randers-Pehrsoncfbed9b2002-05-21 18:06:08 -0500154 -@if [ ! -d $(DI) ]; then mkdir $(DI); fi
155 -@if [ ! -d $(DI)/$(LIBNAME) ]; then mkdir $(DI)/$(LIBNAME); fi
156 cp png.h pngconf.h $(DI)/$(LIBNAME)
Glenn Randers-Pehrson07748d12002-05-25 11:12:10 -0500157 chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h
Glenn Randers-Pehrsoncfbed9b2002-05-21 18:06:08 -0500158 -@/bin/rm -f $(DI)/png.h $(DI)/pngconf.h
159 -@/bin/rm -f $(DI)/libpng
160 (cd $(DI); ln -sf $(LIBNAME) libpng; ln -sf $(LIBNAME)/* .)
Glenn Randers-Pehrsonc1bfe682002-03-06 22:08:00 -0600161
162install-static: install-headers libpng.a
Glenn Randers-Pehrsoncfbed9b2002-05-21 18:06:08 -0500163 -@if [ ! -d $(DL) ]; then mkdir $(DL); fi
164 cp libpng.a $(DL)/$(LIBNAME).a
165 chmod 644 $(DL)/$(LIBNAME).a
166 -@/bin/rm -f $(DL)/libpng.a
167 (cd $(DL); ln -sf $(LIBNAME).a libpng.a)
Glenn Randers-Pehrsonc1bfe682002-03-06 22:08:00 -0600168
Glenn Randers-Pehrson8a7df002002-08-15 22:02:57 -0500169install-shared: install-headers $(LIBNAME).so.$(PNGVER) libpng.pc \
170 libpng.so.3.$(PNGMIN)
Glenn Randers-Pehrsoncfbed9b2002-05-21 18:06:08 -0500171 -@if [ ! -d $(DL) ]; then mkdir $(DL); fi
Glenn Randers-Pehrson51d92502002-08-23 23:07:42 -0500172 -@/bin/rm -f $(DL)/$(LIBNAME).so.$(PNGVER)* $(DL)/$(LIBNAME).so
Glenn Randers-Pehrsondff799e2004-08-07 21:42:49 -0500173 -@/bin/rm -f $(DL)/$(LIBNAME).so.$(PNGMAJ)
Glenn Randers-Pehrsoncfbed9b2002-05-21 18:06:08 -0500174 -@/bin/rm -f $(DL)/libpng.so
175 -@/bin/rm -f $(DL)/libpng.so.3
Glenn Randers-Pehrson51d92502002-08-23 23:07:42 -0500176 -@/bin/rm -f $(DL)/libpng.so.3.$(PNGMIN)*
Glenn Randers-Pehrsoncfbed9b2002-05-21 18:06:08 -0500177 cp $(LIBNAME).so.$(PNGVER) $(DL)
Glenn Randers-Pehrson8a7df002002-08-15 22:02:57 -0500178 cp libpng.so.3.$(PNGMIN) $(DL)
Glenn Randers-Pehrsoncfbed9b2002-05-21 18:06:08 -0500179 chmod 755 $(DL)/$(LIBNAME).so.$(PNGVER)
Glenn Randers-Pehrson8a7df002002-08-15 22:02:57 -0500180 chmod 755 $(DL)/libpng.so.3.$(PNGMIN)
Glenn Randers-Pehrsoncfbed9b2002-05-21 18:06:08 -0500181 (cd $(DL); \
Glenn Randers-Pehrson8a7df002002-08-15 22:02:57 -0500182 ln -sf libpng.so.3.$(PNGMIN) libpng.so.3; \
Glenn Randers-Pehrson51d92502002-08-23 23:07:42 -0500183 ln -sf libpng.so.3 libpng.so; \
Glenn Randers-Pehrsonc1bfe682002-03-06 22:08:00 -0600184 ln -sf $(LIBNAME).so.$(PNGVER) $(LIBNAME).so.$(PNGMAJ); \
185 ln -sf $(LIBNAME).so.$(PNGMAJ) $(LIBNAME).so)
Glenn Randers-Pehrsoncfbed9b2002-05-21 18:06:08 -0500186 -@if [ ! -d $(DL)/pkgconfig ]; then mkdir $(DL)/pkgconfig; fi
187 -@/bin/rm -f $(DL)/pkgconfig/$(LIBNAME).pc
188 -@/bin/rm -f $(DL)/pkgconfig/libpng.pc
189 cp libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc
190 chmod 644 $(DL)/pkgconfig/$(LIBNAME).pc
191 (cd $(DL)/pkgconfig; ln -sf $(LIBNAME).pc libpng.pc)
Glenn Randers-Pehrsonc1bfe682002-03-06 22:08:00 -0600192
Glenn Randers-Pehrson03008a02002-04-27 10:11:25 -0500193install-man: libpng.3 libpngpf.3 png.5
Glenn Randers-Pehrsoncfbed9b2002-05-21 18:06:08 -0500194 -@if [ ! -d $(DM) ]; then mkdir $(DM); fi
195 -@if [ ! -d $(DM)/man3 ]; then mkdir $(DM)/man3; fi
196 -@/bin/rm -f $(DM)/man3/libpng.3
197 -@/bin/rm -f $(DM)/man3/libpngpf.3
198 cp libpng.3 $(DM)/man3
199 cp libpngpf.3 $(DM)/man3
200 -@if [ ! -d $(DM)/man5 ]; then mkdir $(DM)/man5; fi
201 -@/bin/rm -f $(DM)/man5/png.5
202 cp png.5 $(DM)/man5
Glenn Randers-Pehrson03008a02002-04-27 10:11:25 -0500203
Glenn Randers-Pehrson837a3d12002-05-10 20:19:58 -0500204install-config: libpng-config
Glenn Randers-Pehrsoncfbed9b2002-05-21 18:06:08 -0500205 -@if [ ! -d $(DB) ]; then mkdir $(DB); fi
206 -@/bin/rm -f $(DB)/libpng-config
207 -@/bin/rm -f $(DB)/$(LIBNAME)-config
208 cp libpng-config $(DB)/$(LIBNAME)-config
209 chmod 755 $(DB)/$(LIBNAME)-config
210 (cd $(DB); ln -sf $(LIBNAME)-config libpng-config)
Glenn Randers-Pehrson704228f2002-05-02 20:49:40 -0500211
212install: install-static install-shared install-man install-config
Glenn Randers-Pehrsonc1bfe682002-03-06 22:08:00 -0600213
Glenn Randers-Pehrsond020e9d2002-06-28 09:34:00 -0500214# If you installed in $(DESTDIR), test-installed won't work until you
Glenn Randers-Pehrsona4981d42004-08-25 22:00:45 -0500215# move the library to its final location. Use test-dd to test it
216# before then.
217
218test-dd:
219 echo
220 echo Testing installed dynamic shared library in $(DL).
221 $(CC) -I$(DI) -I$(ZLIBINC) \
222 `$(BINPATH)/libpng12-config --cflags` pngtest.c \
223 -L$(DL) -L$(ZLIBLIB) -W1, -rpath,$(DL) -Wl,-rpath,$(ZLIBLIB) \
224 -o pngtestd `$(BINPATH)/libpng12-config --ldflags`
225 ./pngtestd pngtest.png
Glenn Randers-Pehrsond020e9d2002-06-28 09:34:00 -0500226
Glenn Randers-Pehrsond1e8c862002-06-20 06:54:34 -0500227test-installed:
228 $(CC) -I$(ZLIBINC) \
Glenn Randers-Pehrson5ff38d32002-09-17 23:38:46 -0500229 `$(BINPATH)/libpng12-config --cflags` pngtest.c \
Glenn Randers-Pehrsond020e9d2002-06-28 09:34:00 -0500230 -L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) \
Glenn Randers-Pehrson5ff38d32002-09-17 23:38:46 -0500231 -o pngtesti `$(BINPATH)/libpng12-config --ldflags`
Glenn Randers-Pehrson2ae022d2002-07-01 22:23:46 -0500232 ./pngtesti pngtest.png
Glenn Randers-Pehrsond1e8c862002-06-20 06:54:34 -0500233
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600234clean:
Glenn Randers-Pehrson51d92502002-08-23 23:07:42 -0500235 /bin/rm -f *.o libpng.a pngtest pngout.png libpng-config \
Glenn Randers-Pehrson8a7df002002-08-15 22:02:57 -0500236 $(LIBNAME).so $(LIBNAME).so.$(PNGMAJ)* pngtest-static pngtesti \
Glenn Randers-Pehrson51d92502002-08-23 23:07:42 -0500237 libpng.so.3.$(PNGMIN) \
238 libpng.pc
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600239
240DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO
241writelock:
242 chmod a-w *.[ch35] $(DOCS) scripts/*
243
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600244png.o png.pic.o: png.h pngconf.h png.c
Glenn Randers-Pehrson316f97a2000-07-08 13:19:41 -0500245pngerror.o pngerror.pic.o: png.h pngconf.h pngerror.c
246pngrio.o pngrio.pic.o: png.h pngconf.h pngrio.c
247pngwio.o pngwio.pic.o: png.h pngconf.h pngwio.c
248pngmem.o pngmem.pic.o: png.h pngconf.h pngmem.c
249pngset.o pngset.pic.o: png.h pngconf.h pngset.c
250pngget.o pngget.pic.o: png.h pngconf.h pngget.c
251pngread.o pngread.pic.o: png.h pngconf.h pngread.c
252pngrtran.o pngrtran.pic.o: png.h pngconf.h pngrtran.c
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -0600253pngrutil.o pngrutil.pic.o: png.h pngconf.h pngrutil.c
Glenn Randers-Pehrson316f97a2000-07-08 13:19:41 -0500254pngtrans.o pngtrans.pic.o: png.h pngconf.h pngtrans.c
255pngwrite.o pngwrite.pic.o: png.h pngconf.h pngwrite.c
256pngwtran.o pngwtran.pic.o: png.h pngconf.h pngwtran.c
257pngwutil.o pngwutil.pic.o: png.h pngconf.h pngwutil.c
258pngpread.o pngpread.pic.o: png.h pngconf.h pngpread.c
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600259
Glenn Randers-Pehrson316f97a2000-07-08 13:19:41 -0500260pngtest.o: png.h pngconf.h pngtest.c