blob: 337a8151eb5e35aa635580492d70772b8692385d [file] [log] [blame]
Glenn Randers-Pehrson5a0be342001-10-18 20:55:13 -05001# makefile for libpng on Darwin / Mac OS X
Glenn Randers-Pehrson5c5db5a2011-01-21 23:23:34 -06002# Copyright (C) 2002, 2004, 2006, 2008, 2010-2011 Glenn Randers-Pehrson
Glenn Randers-Pehrson5a0be342001-10-18 20:55:13 -05003# Copyright (C) 2001 Christoph Pfisterer
4# derived from makefile.linux:
5# Copyright (C) 1998, 1999 Greg Roelofs
6# Copyright (C) 1996, 1997 Andreas Dilger
Glenn Randers-Pehrson3e61d792009-06-24 09:31:28 -05007#
Glenn Randers-Pehrsonbfbf8652009-06-26 21:46:52 -05008# This code is released under the libpng license.
Glenn Randers-Pehrsonc332bbc2009-06-25 13:43:50 -05009# For conditions of distribution and use, see the disclaimer
Glenn Randers-Pehrson037023b2009-06-24 10:27:36 -050010# and license in png.h
Glenn Randers-Pehrson5a0be342001-10-18 20:55:13 -050011
Glenn Randers-Pehrson72531442010-04-17 08:17:51 -050012# where "make install" puts libpng.a, libpng15.dylib, png.h, pngconf.h,
13# and pnglibconf.h
Glenn Randers-Pehrson5a0be342001-10-18 20:55:13 -050014prefix=/usr/local
Glenn Randers-Pehrsonad310542006-04-18 05:31:20 -050015exec_prefix=$(prefix)
Glenn Randers-Pehrson5a0be342001-10-18 20:55:13 -050016
17# Where the zlib library and include files are located
18#ZLIBLIB=/usr/local/lib
19#ZLIBINC=/usr/local/include
20ZLIBLIB=../zlib
21ZLIBINC=../zlib
22
Glenn Randers-Pehrson4deeb792006-03-22 16:21:59 -060023# Library name:
Glenn Randers-Pehrson3c6df192010-02-08 15:40:53 -060024LIBNAME = libpng15
25PNGMAJ = 15
Glenn Randers-Pehrson4deeb792006-03-22 16:21:59 -060026
27# Shared library names:
28LIBSO=$(LIBNAME).dylib
29LIBSOMAJ=$(LIBNAME).$(PNGMAJ).dylib
Glenn Randers-Pehrsone3f3c4e2010-02-07 18:08:50 -060030LIBSOREL=$(LIBNAME).$(PNGMAJ).$(RELEASE).dylib
Glenn Randers-Pehrson4deeb792006-03-22 16:21:59 -060031OLDSO=libpng.dylib
Glenn Randers-Pehrson4deeb792006-03-22 16:21:59 -060032
33# Utilities:
Glenn Randers-Pehrson5a0be342001-10-18 20:55:13 -050034CC=cc
Glenn Randers-Pehrson5c60b232006-03-07 07:09:22 -060035AR_RC=ar rc
Glenn Randers-Pehrson170b70c2006-03-10 10:19:04 -060036MKDIR_P=mkdir -p
Glenn Randers-Pehrson5c60b232006-03-07 07:09:22 -060037LN_SF=ln -sf
38RANLIB=ranlib
39RM_F=/bin/rm -f
Glenn Randers-Pehrson44271392011-08-29 12:26:24 -050040ARCH="-arch i386 -arch x86_64"
Glenn Randers-Pehrson5c60b232006-03-07 07:09:22 -060041
Glenn Randers-Pehrson03f9b022009-12-04 08:40:41 -060042# CFLAGS=-I$(ZLIBINC) -W -Wall -O3 -funroll-loops
Glenn Randers-Pehrsonb2933342011-08-29 07:22:13 -050043CFLAGS=-I$(ZLIBINC) -W -Wall -O -funroll-loops $(ARCH)
44LDFLAGS=-L. -L$(ZLIBLIB) -lpng15 -lz $(ARCH)
Glenn Randers-Pehrson761bf9f2002-10-31 19:53:20 -060045
Glenn Randers-Pehrson5a0be342001-10-18 20:55:13 -050046INCPATH=$(prefix)/include
Glenn Randers-Pehrson5c60b232006-03-07 07:09:22 -060047LIBPATH=$(exec_prefix)/lib
Glenn Randers-Pehrson03008a02002-04-27 10:11:25 -050048MANPATH=$(prefix)/man
Glenn Randers-Pehrson5c60b232006-03-07 07:09:22 -060049BINPATH=$(exec_prefix)/bin
Glenn Randers-Pehrson03008a02002-04-27 10:11:25 -050050
51# override DESTDIR= on the make install command line to easily support
52# installing into a temporary location. Example:
53#
54# make install DESTDIR=/tmp/build/libpng
55#
56# If you're going to install into a temporary location
Glenn Randers-Pehrson07748d12002-05-25 11:12:10 -050057# via DESTDIR, $(DESTDIR)$(prefix) must already exist before
Glenn Randers-Pehrson03008a02002-04-27 10:11:25 -050058# you execute make install.
59DESTDIR=
Glenn Randers-Pehrson5a0be342001-10-18 20:55:13 -050060
Glenn Randers-Pehrson07748d12002-05-25 11:12:10 -050061DB=$(DESTDIR)$(BINPATH)
62DI=$(DESTDIR)$(INCPATH)
63DL=$(DESTDIR)$(LIBPATH)
64DM=$(DESTDIR)$(MANPATH)
Glenn Randers-Pehrsoncfbed9b2002-05-21 18:06:08 -050065
Glenn Randers-Pehrson5a0be342001-10-18 20:55:13 -050066OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \
67 pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \
68 pngwtran.o pngmem.o pngerror.o pngpread.o
69
70OBJSDLL = $(OBJS:.o=.pic.o)
71
72.SUFFIXES: .c .o .pic.o
73
74.c.pic.o:
75 $(CC) -c $(CFLAGS) -fno-common -o $@ $*.c
76
Glenn Randers-Pehrsoneb580912008-07-30 14:47:09 -050077all: libpng.a $(LIBSO) pngtest libpng.pc libpng-config
Glenn Randers-Pehrson5a0be342001-10-18 20:55:13 -050078
Glenn Randers-Pehrson72531442010-04-17 08:17:51 -050079# see scripts/pnglibconf.mak for more options
Glenn Randers-Pehrson8c667862010-08-24 16:16:35 -050080pnglibconf.h: scripts/pnglibconf.h.prebuilt
81 cp scripts/pnglibconf.h.prebuilt $@
Glenn Randers-Pehrson72531442010-04-17 08:17:51 -050082
Glenn Randers-Pehrson5a0be342001-10-18 20:55:13 -050083libpng.a: $(OBJS)
Glenn Randers-Pehrson5c60b232006-03-07 07:09:22 -060084 $(AR_RC) $@ $(OBJS)
Glenn Randers-Pehrson5a0be342001-10-18 20:55:13 -050085 $(RANLIB) $@
86
Glenn Randers-Pehrson03008a02002-04-27 10:11:25 -050087libpng.pc:
Glenn Randers-Pehrsoneb580912008-07-30 14:47:09 -050088 cat scripts/libpng.pc.in | sed -e s!@prefix@!$(prefix)! \
89 -e s!@exec_prefix@!$(exec_prefix)! \
90 -e s!@libdir@!$(LIBPATH)! \
91 -e s!@includedir@!$(INCPATH)! \
Glenn Randers-Pehrson3c6df192010-02-08 15:40:53 -060092 -e s!-lpng15!-lpng15\ -lz! > libpng.pc
Glenn Randers-Pehrson837a3d12002-05-10 20:19:58 -050093
94libpng-config:
95 ( cat scripts/libpng-config-head.in; \
96 echo prefix=\"$(prefix)\"; \
Glenn Randers-Pehrson5ff38d32002-09-17 23:38:46 -050097 echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \
98 echo L_opts=\"-L$(LIBPATH)\"; \
Glenn Randers-Pehrson3c6df192010-02-08 15:40:53 -060099 echo libs=\"-lpng15 -lz\"; \
Glenn Randers-Pehrson837a3d12002-05-10 20:19:58 -0500100 cat scripts/libpng-config-body.in ) > libpng-config
101 chmod +x libpng-config
Glenn Randers-Pehrson03008a02002-04-27 10:11:25 -0500102
Glenn Randers-Pehrson4deeb792006-03-22 16:21:59 -0600103$(LIBSO): $(LIBSOMAJ)
104 $(LN_SF) $(LIBSOMAJ) $(LIBSO)
Glenn Randers-Pehrson5a0be342001-10-18 20:55:13 -0500105
Glenn Randers-Pehrsone3f3c4e2010-02-07 18:08:50 -0600106$(LIBSOMAJ): $(OBJSDLL)
Glenn Randers-Pehrson9c0f0942002-02-21 23:14:23 -0600107 $(CC) -dynamiclib \
Glenn Randers-Pehrson4deeb792006-03-22 16:21:59 -0600108 -install_name $(LIBPATH)/$(LIBSOMAJ) \
Glenn Randers-Pehrson3c6df192010-02-08 15:40:53 -0600109 -current_version 15 -compatibility_version 15 \
Glenn Randers-Pehrsone3f3c4e2010-02-07 18:08:50 -0600110 -o $(LIBSOMAJ) \
Glenn Randers-Pehrsoneb580912008-07-30 14:47:09 -0500111 $(OBJSDLL) -L$(ZLIBLIB) -lz
112
Glenn Randers-Pehrson4deeb792006-03-22 16:21:59 -0600113pngtest: pngtest.o $(LIBSO)
Glenn Randers-Pehrson5a0be342001-10-18 20:55:13 -0500114 $(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS)
115
116test: pngtest
117 ./pngtest
118
Glenn Randers-Pehrson72531442010-04-17 08:17:51 -0500119install-headers: png.h pngconf.h pnglibconf.h
Glenn Randers-Pehrson1ce08362006-03-08 23:35:59 -0600120 -@if [ ! -d $(DI) ]; then $(MKDIR_P) $(DI); fi
121 -@if [ ! -d $(DI)/$(LIBNAME) ]; then $(MKDIR_P) $(DI)/$(LIBNAME); fi
Glenn Randers-Pehrson72531442010-04-17 08:17:51 -0500122 cp png.h pngconf.h pnglibconf.h $(DI)/$(LIBNAME)
123 chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h $(DI)/$(LIBNAME)/pnglibconf.h
124 -@$(RM_F) $(DI)/png.h $(DI)/pngconf.h $(DI)/pnglibconf.h
Glenn Randers-Pehrson5c60b232006-03-07 07:09:22 -0600125 -@$(RM_F) $(DI)/libpng
126 (cd $(DI); $(LN_SF) $(LIBNAME) libpng; $(LN_SF) $(LIBNAME)/* .)
Glenn Randers-Pehrsonc1bfe682002-03-06 22:08:00 -0600127
128install-static: install-headers libpng.a
Glenn Randers-Pehrson1ce08362006-03-08 23:35:59 -0600129 -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi
Glenn Randers-Pehrsoncfbed9b2002-05-21 18:06:08 -0500130 cp libpng.a $(DL)/$(LIBNAME).a
131 chmod 644 $(DL)/$(LIBNAME).a
Glenn Randers-Pehrson272489d2004-08-04 06:34:52 -0500132 $(RANLIB) $(DL)/$(LIBNAME).a
Glenn Randers-Pehrson5c60b232006-03-07 07:09:22 -0600133 -@$(RM_F) $(DL)/libpng.a
134 (cd $(DL); $(LN_SF) $(LIBNAME).a libpng.a)
Glenn Randers-Pehrsonc1bfe682002-03-06 22:08:00 -0600135
Glenn Randers-Pehrsone3f3c4e2010-02-07 18:08:50 -0600136install-shared: install-headers $(LIBSOMAJ) libpng.pc
Glenn Randers-Pehrson1ce08362006-03-08 23:35:59 -0600137 -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi
Glenn Randers-Pehrson4deeb792006-03-22 16:21:59 -0600138 -@$(RM_F) $(DL)/$(LIBSO)
Glenn Randers-Pehrsone3f3c4e2010-02-07 18:08:50 -0600139 -@$(RM_F) $(DL)/$(LIBSOREL)
Glenn Randers-Pehrson4deeb792006-03-22 16:21:59 -0600140 -@$(RM_F) $(DL)/$(OLDSO)
Glenn Randers-Pehrsone3f3c4e2010-02-07 18:08:50 -0600141 cp $(LIBSOMAJ) $(DL)/$(LIBSOREL)
142 chmod 755 $(DL)/$(LIBSOREL)
Glenn Randers-Pehrsoncfbed9b2002-05-21 18:06:08 -0500143 (cd $(DL); \
Glenn Randers-Pehrsone3f3c4e2010-02-07 18:08:50 -0600144 $(LN_SF) $(LIBSOREL) $(LIBSO); \
145 $(LN_SF) $(LIBSO) $(OLDSO))
Glenn Randers-Pehrson1ce08362006-03-08 23:35:59 -0600146 -@if [ ! -d $(DL)/pkgconfig ]; then $(MKDIR_P) $(DL)/pkgconfig; fi
Glenn Randers-Pehrson5c60b232006-03-07 07:09:22 -0600147 -@$(RM_F) $(DL)/pkgconfig/$(LIBNAME).pc
148 -@$(RM_F) $(DL)/pkgconfig/libpng.pc
Glenn Randers-Pehrsoncfbed9b2002-05-21 18:06:08 -0500149 cp libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc
150 chmod 644 $(DL)/pkgconfig/$(LIBNAME).pc
Glenn Randers-Pehrson5c60b232006-03-07 07:09:22 -0600151 (cd $(DL)/pkgconfig; $(LN_SF) $(LIBNAME).pc libpng.pc)
Glenn Randers-Pehrsonc1bfe682002-03-06 22:08:00 -0600152
Glenn Randers-Pehrson03008a02002-04-27 10:11:25 -0500153install-man: libpng.3 libpngpf.3 png.5
Glenn Randers-Pehrson1ce08362006-03-08 23:35:59 -0600154 -@if [ ! -d $(DM) ]; then $(MKDIR_P) $(DM); fi
155 -@if [ ! -d $(DM)/man3 ]; then $(MKDIR_P) $(DM)/man3; fi
Glenn Randers-Pehrson5c60b232006-03-07 07:09:22 -0600156 -@$(RM_F) $(DM)/man3/libpng.3
157 -@$(RM_F) $(DM)/man3/libpngpf.3
Glenn Randers-Pehrsoncfbed9b2002-05-21 18:06:08 -0500158 cp libpng.3 $(DM)/man3
159 cp libpngpf.3 $(DM)/man3
Glenn Randers-Pehrson1ce08362006-03-08 23:35:59 -0600160 -@if [ ! -d $(DM)/man5 ]; then $(MKDIR_P) $(DM)/man5; fi
Glenn Randers-Pehrson5c60b232006-03-07 07:09:22 -0600161 -@$(RM_F) $(DM)/man5/png.5
Glenn Randers-Pehrsoncfbed9b2002-05-21 18:06:08 -0500162 cp png.5 $(DM)/man5
Glenn Randers-Pehrson03008a02002-04-27 10:11:25 -0500163
Glenn Randers-Pehrson837a3d12002-05-10 20:19:58 -0500164install-config: libpng-config
Glenn Randers-Pehrson1ce08362006-03-08 23:35:59 -0600165 -@if [ ! -d $(DB) ]; then $(MKDIR_P) $(DB); fi
Glenn Randers-Pehrson5c60b232006-03-07 07:09:22 -0600166 -@$(RM_F) $(DB)/libpng-config
167 -@$(RM_F) $(DB)/$(LIBNAME)-config
Glenn Randers-Pehrsoncfbed9b2002-05-21 18:06:08 -0500168 cp libpng-config $(DB)/$(LIBNAME)-config
169 chmod 755 $(DB)/$(LIBNAME)-config
Glenn Randers-Pehrson5c60b232006-03-07 07:09:22 -0600170 (cd $(DB); $(LN_SF) $(LIBNAME)-config libpng-config)
Glenn Randers-Pehrson704228f2002-05-02 20:49:40 -0500171
172install: install-static install-shared install-man install-config
Glenn Randers-Pehrson5a0be342001-10-18 20:55:13 -0500173
Glenn Randers-Pehrsond020e9d2002-06-28 09:34:00 -0500174# If you installed in $(DESTDIR), test-installed won't work until you
Glenn Randers-Pehrsona4981d42004-08-25 22:00:45 -0500175# move the library to its final location. Use test-dd to test it
176# before then.
177
178test-dd:
179 echo
180 echo Testing installed dynamic shared library in $(DL).
181 $(CC) -I$(DI) -I$(ZLIBINC) \
Glenn Randers-Pehrson5c60b232006-03-07 07:09:22 -0600182 `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \
Glenn Randers-Pehrsona4981d42004-08-25 22:00:45 -0500183 -L$(DL) -L$(ZLIBLIB) \
Glenn Randers-Pehrson5c60b232006-03-07 07:09:22 -0600184 -o pngtestd `$(BINPATH)/$(LIBNAME)-config --ldflags`
Glenn Randers-Pehrsona4981d42004-08-25 22:00:45 -0500185 ./pngtestd pngtest.png
Glenn Randers-Pehrsond020e9d2002-06-28 09:34:00 -0500186
187test-installed:
188 $(CC) $(CFLAGS) \
Glenn Randers-Pehrson5c60b232006-03-07 07:09:22 -0600189 `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \
Glenn Randers-Pehrsond020e9d2002-06-28 09:34:00 -0500190 -L$(ZLIBLIB) \
Glenn Randers-Pehrson5c60b232006-03-07 07:09:22 -0600191 -o pngtesti `$(BINPATH)/$(LIBNAME)-config --ldflags`
Glenn Randers-Pehrson2ae022d2002-07-01 22:23:46 -0500192 ./pngtesti pngtest.png
Glenn Randers-Pehrsond020e9d2002-06-28 09:34:00 -0500193
Glenn Randers-Pehrson5a0be342001-10-18 20:55:13 -0500194clean:
Glenn Randers-Pehrson5c60b232006-03-07 07:09:22 -0600195 $(RM_F) *.o libpng.a pngtest pngout.png libpng-config \
Glenn Randers-Pehrson72531442010-04-17 08:17:51 -0500196 libpng.pc $(LIBNAME).*dylib pngtesti pnglibconf.h
Glenn Randers-Pehrson5a0be342001-10-18 20:55:13 -0500197
198DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO
199writelock:
200 chmod a-w *.[ch35] $(DOCS) scripts/*
201
202# DO NOT DELETE THIS LINE -- make depend depends on it.
203
Glenn Randers-Pehrson72531442010-04-17 08:17:51 -0500204png.o png.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
205pngerror.o pngerror.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
206pngrio.o pngrio.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
207pngwio.o pngwio.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
208pngmem.o pngmem.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
209pngset.o pngset.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
210pngget.o pngget.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
211pngread.o pngread.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
212pngrtran.o pngrtran.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
213pngrutil.o pngrutil.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
214pngtrans.o pngtrans.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
215pngwrite.o pngwrite.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
216pngwtran.o pngwtran.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
217pngwutil.o pngwutil.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
218pngpread.o pngpread.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
Glenn Randers-Pehrson5a0be342001-10-18 20:55:13 -0500219
Glenn Randers-Pehrson72531442010-04-17 08:17:51 -0500220pngtest.o: png.h pngconf.h pnglibconf.h