blob: e289acad285a124423f2c5ad3ec0b9c5531be190 [file] [log] [blame]
Glenn Randers-Pehrson7455cbf2011-11-24 14:40:36 -06001# makefile for libpng.a and libpng16.so on Linux ELF with gcc
Glenn Randers-Pehrson5c5db5a2011-01-21 23:23:34 -06002# Copyright (C) 1998, 1999, 2002, 2006, 2008, 2010-2011 Greg Roelofs and
Glenn Randers-Pehrson glennrp@comcast.net7ecf7bd2009-05-02 15:36:08 -05003# Glenn Randers-Pehrson
Glenn Randers-Pehrsond4366722000-06-04 14:29:29 -05004# Copyright (C) 1996, 1997 Andreas Dilger
Glenn Randers-Pehrson3e61d792009-06-24 09:31:28 -05005#
Glenn Randers-Pehrsonbfbf8652009-06-26 21:46:52 -05006# This code is released under the libpng license.
Glenn Randers-Pehrsonc332bbc2009-06-25 13:43:50 -05007# For conditions of distribution and use, see the disclaimer
Glenn Randers-Pehrson037023b2009-06-24 10:27:36 -05008# and license in png.h
Guy Schalnat4ee97b01996-01-16 01:51:56 -06009
Glenn Randers-Pehrson4deeb792006-03-22 16:21:59 -060010# Library name:
Glenn Randers-Pehrson7455cbf2011-11-24 14:40:36 -060011LIBNAME = libpng16
12PNGMAJ = 16
Glenn Randers-Pehrson15ea1fa2011-11-23 15:28:01 -060013RELEASE = 0
Glenn Randers-Pehrson9c0f0942002-02-21 23:14:23 -060014
Glenn Randers-Pehrson4deeb792006-03-22 16:21:59 -060015# Shared library names:
16LIBSO=$(LIBNAME).so
17LIBSOMAJ=$(LIBNAME).so.$(PNGMAJ)
Glenn Randers-Pehrsone3f3c4e2010-02-07 18:08:50 -060018LIBSOREL=$(LIBSOMAJ).$(RELEASE)
Glenn Randers-Pehrson4deeb792006-03-22 16:21:59 -060019OLDSO=libpng.so
Glenn Randers-Pehrson4deeb792006-03-22 16:21:59 -060020
21# Utilities:
Glenn Randers-Pehrson5c60b232006-03-07 07:09:22 -060022AR_RC=ar rc
Guy Schalnat4ee97b01996-01-16 01:51:56 -060023CC=gcc
Glenn Randers-Pehrson5c60b232006-03-07 07:09:22 -060024MKDIR_P=mkdir -p
25LN_SF=ln -sf
26RANLIB=ranlib
27RM_F=/bin/rm -f
Andreas Dilger47a0c421997-05-16 02:46:07 -050028
Glenn Randers-Pehrson7455cbf2011-11-24 14:40:36 -060029# where "make install" puts libpng16.a, libpng16.so*,
Glenn Randers-Pehrson0b3634b2011-12-17 09:57:00 -060030# libpng16/png.h, libpng16/pngconf.h, and libpng16/pnglibconf.h
Glenn Randers-Pehrsond1e8c862002-06-20 06:54:34 -050031# Prefix must be a full pathname.
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -060032prefix=/usr/local
Glenn Randers-Pehrsonad310542006-04-18 05:31:20 -050033exec_prefix=$(prefix)
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -060034
Glenn Randers-Pehrsond1e8c862002-06-20 06:54:34 -050035# Where the zlib library and include files are located.
Andreas Dilger47a0c421997-05-16 02:46:07 -050036#ZLIBLIB=/usr/local/lib
37#ZLIBINC=/usr/local/include
38ZLIBLIB=../zlib
39ZLIBINC=../zlib
40
Glenn Randers-Pehrson896239b1998-04-21 15:03:57 -050041ALIGN=
Glenn Randers-Pehrsonf8b008c1999-09-18 10:54:36 -050042# for i386:
Glenn Randers-Pehrson896239b1998-04-21 15:03:57 -050043#ALIGN=-malign-loops=2 -malign-functions=2
44
Andreas Dilger47a0c421997-05-16 02:46:07 -050045WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow \
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -050046 -Wmissing-declarations -Wtraditional -Wcast-align \
47 -Wstrict-prototypes -Wmissing-prototypes #-Wconversion
Glenn Randers-Pehrson896239b1998-04-21 15:03:57 -050048
Glenn Randers-Pehrson6d8f3b01999-10-23 08:39:18 -050049# for pgcc version 2.95.1, -O3 is buggy; don't use it.
Glenn Randers-Pehrsonbcfd15d1999-10-01 14:22:25 -050050
Glenn Randers-Pehrson03f9b022009-12-04 08:40:41 -060051CFLAGS=-I$(ZLIBINC) -W -Wall -O3 -funroll-loops \
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -050052 $(ALIGN) # $(WARNMORE) -g -DPNG_DEBUG=5
Glenn Randers-Pehrson9c0f0942002-02-21 23:14:23 -060053
Glenn Randers-Pehrson7455cbf2011-11-24 14:40:36 -060054LDFLAGS=-L. -Wl,-rpath,. -L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) -lpng16 -lz -lm
Glenn Randers-Pehrson9c0f0942002-02-21 23:14:23 -060055LDFLAGS_A=-L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) libpng.a -lz -lm
Guy Schalnat4ee97b01996-01-16 01:51:56 -060056
Andreas Dilger47a0c421997-05-16 02:46:07 -050057INCPATH=$(prefix)/include
Glenn Randers-Pehrson5c60b232006-03-07 07:09:22 -060058LIBPATH=$(exec_prefix)/lib
Glenn Randers-Pehrson03008a02002-04-27 10:11:25 -050059MANPATH=$(prefix)/man
Glenn Randers-Pehrson5c60b232006-03-07 07:09:22 -060060BINPATH=$(exec_prefix)/bin
Glenn Randers-Pehrson03008a02002-04-27 10:11:25 -050061
62# override DESTDIR= on the make install command line to easily support
63# installing into a temporary location. Example:
64#
65# make install DESTDIR=/tmp/build/libpng
66#
67# If you're going to install into a temporary location
Glenn Randers-Pehrson07748d12002-05-25 11:12:10 -050068# via DESTDIR, $(DESTDIR)$(prefix) must already exist before
Glenn Randers-Pehrson03008a02002-04-27 10:11:25 -050069# you execute make install.
70DESTDIR=
Guy Schalnat4ee97b01996-01-16 01:51:56 -060071
Glenn Randers-Pehrson07748d12002-05-25 11:12:10 -050072DB=$(DESTDIR)$(BINPATH)
73DI=$(DESTDIR)$(INCPATH)
74DL=$(DESTDIR)$(LIBPATH)
75DM=$(DESTDIR)$(MANPATH)
Glenn Randers-Pehrsoncfbed9b2002-05-21 18:06:08 -050076
Glenn Randers-Pehrson glennrp@comcast.net7ecf7bd2009-05-02 15:36:08 -050077OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -050078 pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \
79 pngwtran.o pngmem.o pngerror.o pngpread.o
Guy Schalnat4ee97b01996-01-16 01:51:56 -060080
Glenn Randers-Pehrson2687fcc1998-01-07 20:54:20 -060081OBJSDLL = $(OBJS:.o=.pic.o)
82
83.SUFFIXES: .c .o .pic.o
84
85.c.pic.o:
86 $(CC) -c $(CFLAGS) -fPIC -o $@ $*.c
87
Glenn Randers-Pehrson glennrp@comcast.net7ecf7bd2009-05-02 15:36:08 -050088all: libpng.a $(LIBSO) pngtest pngtest-static libpng.pc libpng-config
Guy Schalnat4ee97b01996-01-16 01:51:56 -060089
Glenn Randers-Pehrson72531442010-04-17 08:17:51 -050090# see scripts/pnglibconf.mak for more options
Glenn Randers-Pehrson8c667862010-08-24 16:16:35 -050091pnglibconf.h: scripts/pnglibconf.h.prebuilt
92 cp scripts/pnglibconf.h.prebuilt $@
Glenn Randers-Pehrson72531442010-04-17 08:17:51 -050093
Guy Schalnat4ee97b01996-01-16 01:51:56 -060094libpng.a: $(OBJS)
Glenn Randers-Pehrson5c60b232006-03-07 07:09:22 -060095 $(AR_RC) $@ $(OBJS)
Guy Schalnat4ee97b01996-01-16 01:51:56 -060096 $(RANLIB) $@
97
Glenn Randers-Pehrson03008a02002-04-27 10:11:25 -050098libpng.pc:
Glenn Randers-Pehrson glennrp@comcast.net7ecf7bd2009-05-02 15:36:08 -050099 cat scripts/libpng.pc.in | sed -e s!@prefix@!$(prefix)! \
100 -e s!@exec_prefix@!$(exec_prefix)! \
101 -e s!@libdir@!$(LIBPATH)! \
102 -e s!@includedir@!$(INCPATH)! \
Glenn Randers-Pehrson7455cbf2011-11-24 14:40:36 -0600103 -e s!-lpng16!-lpng16\ -lz\ -lm! > libpng.pc
Glenn Randers-Pehrson03008a02002-04-27 10:11:25 -0500104
Glenn Randers-Pehrson837a3d12002-05-10 20:19:58 -0500105libpng-config:
106 ( cat scripts/libpng-config-head.in; \
107 echo prefix=\"$(prefix)\"; \
Glenn Randers-Pehrson5ff38d32002-09-17 23:38:46 -0500108 echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \
109 echo L_opts=\"-L$(LIBPATH)\"; \
110 echo R_opts=\"-Wl,-rpath,$(LIBPATH)\"; \
Glenn Randers-Pehrson7455cbf2011-11-24 14:40:36 -0600111 echo libs=\"-lpng16 -lz -lm\"; \
Glenn Randers-Pehrson837a3d12002-05-10 20:19:58 -0500112 cat scripts/libpng-config-body.in ) > libpng-config
113 chmod +x libpng-config
114
Glenn Randers-Pehrson4deeb792006-03-22 16:21:59 -0600115$(LIBSO): $(LIBSOMAJ)
116 $(LN_SF) $(LIBSOMAJ) $(LIBSO)
Guy Schalnat4ee97b01996-01-16 01:51:56 -0600117
Glenn Randers-Pehrsone3f3c4e2010-02-07 18:08:50 -0600118$(LIBSOMAJ): $(OBJSDLL)
119 $(CC) -shared -Wl,-soname,$(LIBSOMAJ) -o $(LIBSOMAJ) $(OBJSDLL)
Glenn Randers-Pehrson glennrp@comcast.net7ecf7bd2009-05-02 15:36:08 -0500120
Glenn Randers-Pehrson4deeb792006-03-22 16:21:59 -0600121pngtest: pngtest.o $(LIBSO)
Glenn Randers-Pehrson2687fcc1998-01-07 20:54:20 -0600122 $(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS)
Guy Schalnat4ee97b01996-01-16 01:51:56 -0600123
Glenn Randers-Pehrson03008a02002-04-27 10:11:25 -0500124pngtest-static: pngtest.o libpng.a
Glenn Randers-Pehrson9c0f0942002-02-21 23:14:23 -0600125 $(CC) -o pngtest-static $(CFLAGS) pngtest.o $(LDFLAGS_A)
Guy Schalnat4ee97b01996-01-16 01:51:56 -0600126
Glenn Randers-Pehrson9c0f0942002-02-21 23:14:23 -0600127test: pngtest pngtest-static
128 @echo ""
Glenn Randers-Pehrson4deeb792006-03-22 16:21:59 -0600129 @echo " Running pngtest dynamically linked with $(LIBSO):"
Glenn Randers-Pehrson9c0f0942002-02-21 23:14:23 -0600130 @echo ""
131 ./pngtest
132 @echo ""
133 @echo " Running pngtest statically linked with libpng.a:"
134 @echo ""
135 ./pngtest-static
136
Glenn Randers-Pehrson0b3634b2011-12-17 09:57:00 -0600137install-headers: png.h pngconf.h pnglibconf.h
Glenn Randers-Pehrson5c60b232006-03-07 07:09:22 -0600138 -@if [ ! -d $(DI) ]; then $(MKDIR_P) $(DI); fi
139 -@if [ ! -d $(DI)/$(LIBNAME) ]; then $(MKDIR_P) $(DI)/$(LIBNAME); fi
Glenn Randers-Pehrson0b3634b2011-12-17 09:57:00 -0600140 cp png.h pngconf.h pnglibconf.h $(DI)/$(LIBNAME)
141 chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h $(DI)/$(LIBNAME)/pnglibconf.h
142 -@$(RM_F) $(DI)/png.h $(DI)/pngconf.h $(DI)/pnglibconf.h
Glenn Randers-Pehrson5c60b232006-03-07 07:09:22 -0600143 -@$(RM_F) $(DI)/libpng
144 (cd $(DI); $(LN_SF) $(LIBNAME) libpng; $(LN_SF) $(LIBNAME)/* .)
Glenn Randers-Pehrsonc1bfe682002-03-06 22:08:00 -0600145
146install-static: install-headers libpng.a
Glenn Randers-Pehrson5c60b232006-03-07 07:09:22 -0600147 -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi
Glenn Randers-Pehrsoncfbed9b2002-05-21 18:06:08 -0500148 cp libpng.a $(DL)/$(LIBNAME).a
149 chmod 644 $(DL)/$(LIBNAME).a
Glenn Randers-Pehrson5c60b232006-03-07 07:09:22 -0600150 -@$(RM_F) $(DL)/libpng.a
151 (cd $(DL); $(LN_SF) $(LIBNAME).a libpng.a)
Glenn Randers-Pehrsonc1bfe682002-03-06 22:08:00 -0600152
Glenn Randers-Pehrsone3f3c4e2010-02-07 18:08:50 -0600153install-shared: install-headers $(LIBSOMAJ) libpng.pc
Glenn Randers-Pehrson5c60b232006-03-07 07:09:22 -0600154 -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi
Glenn Randers-Pehrsone3f3c4e2010-02-07 18:08:50 -0600155 -@$(RM_F) $(DL)/$(LIBSO)
156 -@$(RM_F) $(DL)/$(LIBSOREL)
Glenn Randers-Pehrson4deeb792006-03-22 16:21:59 -0600157 -@$(RM_F) $(DL)/$(OLDSO)
Glenn Randers-Pehrsone3f3c4e2010-02-07 18:08:50 -0600158 cp $(LIBSOMAJ) $(DL)/$(LIBSOREL)
159 chmod 755 $(DL)/$(LIBSOREL)
Glenn Randers-Pehrsoncfbed9b2002-05-21 18:06:08 -0500160 (cd $(DL); \
Glenn Randers-Pehrsone3f3c4e2010-02-07 18:08:50 -0600161 $(LN_SF) $(LIBSOREL) $(LIBSO); \
162 $(LN_SF) $(LIBSO) $(OLDSO))
163
Glenn Randers-Pehrson5c60b232006-03-07 07:09:22 -0600164 -@if [ ! -d $(DL)/pkgconfig ]; then $(MKDIR_P) $(DL)/pkgconfig; fi
165 -@$(RM_F) $(DL)/pkgconfig/$(LIBNAME).pc
166 -@$(RM_F) $(DL)/pkgconfig/libpng.pc
Glenn Randers-Pehrsoncfbed9b2002-05-21 18:06:08 -0500167 cp libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc
168 chmod 644 $(DL)/pkgconfig/$(LIBNAME).pc
Glenn Randers-Pehrson5c60b232006-03-07 07:09:22 -0600169 (cd $(DL)/pkgconfig; $(LN_SF) $(LIBNAME).pc libpng.pc)
Glenn Randers-Pehrsonc1bfe682002-03-06 22:08:00 -0600170
Glenn Randers-Pehrson03008a02002-04-27 10:11:25 -0500171install-man: libpng.3 libpngpf.3 png.5
Glenn Randers-Pehrson5c60b232006-03-07 07:09:22 -0600172 -@if [ ! -d $(DM) ]; then $(MKDIR_P) $(DM); fi
173 -@if [ ! -d $(DM)/man3 ]; then $(MKDIR_P) $(DM)/man3; fi
174 -@$(RM_F) $(DM)/man3/libpng.3
175 -@$(RM_F) $(DM)/man3/libpngpf.3
Glenn Randers-Pehrsoncfbed9b2002-05-21 18:06:08 -0500176 cp libpng.3 $(DM)/man3
177 cp libpngpf.3 $(DM)/man3
Glenn Randers-Pehrson5c60b232006-03-07 07:09:22 -0600178 -@if [ ! -d $(DM)/man5 ]; then $(MKDIR_P) $(DM)/man5; fi
179 -@$(RM_F) $(DM)/man5/png.5
Glenn Randers-Pehrsoncfbed9b2002-05-21 18:06:08 -0500180 cp png.5 $(DM)/man5
Glenn Randers-Pehrsonc1bfe682002-03-06 22:08:00 -0600181
Glenn Randers-Pehrson837a3d12002-05-10 20:19:58 -0500182install-config: libpng-config
Glenn Randers-Pehrson5c60b232006-03-07 07:09:22 -0600183 -@if [ ! -d $(DB) ]; then $(MKDIR_P) $(DB); fi
184 -@$(RM_F) $(DB)/libpng-config
185 -@$(RM_F) $(DB)/$(LIBNAME)-config
Glenn Randers-Pehrsoncfbed9b2002-05-21 18:06:08 -0500186 cp libpng-config $(DB)/$(LIBNAME)-config
187 chmod 755 $(DB)/$(LIBNAME)-config
Glenn Randers-Pehrson5c60b232006-03-07 07:09:22 -0600188 (cd $(DB); $(LN_SF) $(LIBNAME)-config libpng-config)
Glenn Randers-Pehrson704228f2002-05-02 20:49:40 -0500189
190install: install-static install-shared install-man install-config
Guy Schalnat4ee97b01996-01-16 01:51:56 -0600191
Glenn Randers-Pehrsond020e9d2002-06-28 09:34:00 -0500192# If you installed in $(DESTDIR), test-installed won't work until you
Glenn Randers-Pehrsona4981d42004-08-25 22:00:45 -0500193# move the library to its final location. Use test-dd to test it
194# before then.
195
196test-dd:
197 echo
198 echo Testing installed dynamic shared library in $(DL).
199 $(CC) -I$(DI) -I$(ZLIBINC) \
Glenn Randers-Pehrson5c60b232006-03-07 07:09:22 -0600200 `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \
Glenn Randers-Pehrson6bc53be2006-06-16 07:52:03 -0500201 -L$(DL) -L$(ZLIBLIB) -Wl, -rpath,$(DL) -Wl,-rpath,$(ZLIBLIB) \
Glenn Randers-Pehrson5c60b232006-03-07 07:09:22 -0600202 -o pngtestd `$(BINPATH)/$(LIBNAME)-config --ldflags`
Glenn Randers-Pehrsona4981d42004-08-25 22:00:45 -0500203 ./pngtestd pngtest.png
Glenn Randers-Pehrsond020e9d2002-06-28 09:34:00 -0500204
Glenn Randers-Pehrsond1e8c862002-06-20 06:54:34 -0500205test-installed:
206 $(CC) -I$(ZLIBINC) \
Glenn Randers-Pehrson5c60b232006-03-07 07:09:22 -0600207 `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \
Glenn Randers-Pehrsond020e9d2002-06-28 09:34:00 -0500208 -L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) \
Glenn Randers-Pehrson5c60b232006-03-07 07:09:22 -0600209 -o pngtesti `$(BINPATH)/$(LIBNAME)-config --ldflags`
Glenn Randers-Pehrson2ae022d2002-07-01 22:23:46 -0500210 ./pngtesti pngtest.png
Glenn Randers-Pehrsond1e8c862002-06-20 06:54:34 -0500211
Guy Schalnat4ee97b01996-01-16 01:51:56 -0600212clean:
Glenn Randers-Pehrson glennrp@comcast.net7ecf7bd2009-05-02 15:36:08 -0500213 $(RM_F) *.o libpng.a pngtest pngout.png libpng-config \
Glenn Randers-Pehrson4deeb792006-03-22 16:21:59 -0600214 $(LIBSO) $(LIBSOMAJ)* pngtest-static pngtesti \
Glenn Randers-Pehrson72531442010-04-17 08:17:51 -0500215 libpng.pc pnglibconf.h
Guy Schalnat4ee97b01996-01-16 01:51:56 -0600216
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600217DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO
218writelock:
219 chmod a-w *.[ch35] $(DOCS) scripts/*
220
Guy Schalnat4ee97b01996-01-16 01:51:56 -0600221# DO NOT DELETE THIS LINE -- make depend depends on it.
222
John Bowler6f237b62012-03-02 13:13:15 -0600223png.o png.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
224pngerror.o pngerror.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
225pngrio.o pngrio.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
226pngwio.o pngwio.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
227pngmem.o pngmem.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
228pngset.o pngset.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
229pngget.o pngget.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
230pngread.o pngread.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
231pngrtran.o pngrtran.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
232pngrutil.o pngrutil.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
233pngtrans.o pngtrans.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
234pngwrite.o pngwrite.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
235pngwtran.o pngwtran.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
236pngwutil.o pngwutil.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
237pngpread.o pngpread.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
Glenn Randers-Pehrson2687fcc1998-01-07 20:54:20 -0600238
Glenn Randers-Pehrson0b3634b2011-12-17 09:57:00 -0600239pngtest.o: png.h pngconf.h