blob: 60efa5b761422d4d8d845872b6e37032b361cc34 [file] [log] [blame]
Glenn Randers-Pehrson5a0be342001-10-18 20:55:13 -05001# makefile for libpng on Darwin / Mac OS X
Glenn Randers-Pehrson5c60b232006-03-07 07:09:22 -06002# Copyright (C) 2002, 2004, 2006 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
7# For conditions of distribution and use, see copyright notice in png.h
8
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -05009# where "make install" puts libpng.a, libpng14.dylib, png.h and pngconf.h
Glenn Randers-Pehrson5a0be342001-10-18 20:55:13 -050010prefix=/usr/local
Glenn Randers-Pehrsonad310542006-04-18 05:31:20 -050011exec_prefix=$(prefix)
Glenn Randers-Pehrson5a0be342001-10-18 20:55:13 -050012
13# Where the zlib library and include files are located
14#ZLIBLIB=/usr/local/lib
15#ZLIBINC=/usr/local/include
16ZLIBLIB=../zlib
17ZLIBINC=../zlib
18
Glenn Randers-Pehrson4deeb792006-03-22 16:21:59 -060019# Library name:
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -050020LIBNAME = libpng14
Glenn Randers-Pehrsoneb580912008-07-30 14:47:09 -050021PNGMAJ = 12
Glenn Randers-Pehrson43aaf6e2008-08-05 22:17:03 -050022PNGMIN = 1.4.0beta28
Glenn Randers-Pehrson4deeb792006-03-22 16:21:59 -060023PNGVER = $(PNGMAJ).$(PNGMIN)
24
25# Shared library names:
26LIBSO=$(LIBNAME).dylib
27LIBSOMAJ=$(LIBNAME).$(PNGMAJ).dylib
28LIBSOVER=$(LIBNAME).$(PNGVER).dylib
29OLDSO=libpng.dylib
Glenn Randers-Pehrsoneb580912008-07-30 14:47:09 -050030OLDSOMAJ=libpng.14.dylib
31OLDSOVER=libpng.14.$(PNGMIN).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
40
Glenn Randers-Pehrson79084212008-08-04 13:31:41 -050041# CFLAGS=-I$(ZLIBINC) -W -Wall -O3 -funroll-loops -DPNG_NO_MMX_CODE
42CFLAGS=-I$(ZLIBINC) -W -Wall -O -funroll-loops
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -050043LDFLAGS=-L. -L$(ZLIBLIB) -lpng14 -lz
Glenn Randers-Pehrson761bf9f2002-10-31 19:53:20 -060044
Glenn Randers-Pehrson5a0be342001-10-18 20:55:13 -050045INCPATH=$(prefix)/include
Glenn Randers-Pehrson5c60b232006-03-07 07:09:22 -060046LIBPATH=$(exec_prefix)/lib
Glenn Randers-Pehrson03008a02002-04-27 10:11:25 -050047MANPATH=$(prefix)/man
Glenn Randers-Pehrson5c60b232006-03-07 07:09:22 -060048BINPATH=$(exec_prefix)/bin
Glenn Randers-Pehrson03008a02002-04-27 10:11:25 -050049
50# override DESTDIR= on the make install command line to easily support
51# installing into a temporary location. Example:
52#
53# make install DESTDIR=/tmp/build/libpng
54#
55# If you're going to install into a temporary location
Glenn Randers-Pehrson07748d12002-05-25 11:12:10 -050056# via DESTDIR, $(DESTDIR)$(prefix) must already exist before
Glenn Randers-Pehrson03008a02002-04-27 10:11:25 -050057# you execute make install.
58DESTDIR=
Glenn Randers-Pehrson5a0be342001-10-18 20:55:13 -050059
Glenn Randers-Pehrson07748d12002-05-25 11:12:10 -050060DB=$(DESTDIR)$(BINPATH)
61DI=$(DESTDIR)$(INCPATH)
62DL=$(DESTDIR)$(LIBPATH)
63DM=$(DESTDIR)$(MANPATH)
Glenn Randers-Pehrsoncfbed9b2002-05-21 18:06:08 -050064
Glenn Randers-Pehrson5a0be342001-10-18 20:55:13 -050065OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \
66 pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \
67 pngwtran.o pngmem.o pngerror.o pngpread.o
68
69OBJSDLL = $(OBJS:.o=.pic.o)
70
71.SUFFIXES: .c .o .pic.o
72
73.c.pic.o:
74 $(CC) -c $(CFLAGS) -fno-common -o $@ $*.c
75
Glenn Randers-Pehrsoneb580912008-07-30 14:47:09 -050076all: libpng.a $(LIBSO) pngtest libpng.pc libpng-config
Glenn Randers-Pehrson5a0be342001-10-18 20:55:13 -050077
78libpng.a: $(OBJS)
Glenn Randers-Pehrson5c60b232006-03-07 07:09:22 -060079 $(AR_RC) $@ $(OBJS)
Glenn Randers-Pehrson5a0be342001-10-18 20:55:13 -050080 $(RANLIB) $@
81
Glenn Randers-Pehrson03008a02002-04-27 10:11:25 -050082libpng.pc:
Glenn Randers-Pehrsoneb580912008-07-30 14:47:09 -050083 cat scripts/libpng.pc.in | sed -e s!@prefix@!$(prefix)! \
84 -e s!@exec_prefix@!$(exec_prefix)! \
85 -e s!@libdir@!$(LIBPATH)! \
86 -e s!@includedir@!$(INCPATH)! \
87 -e s!-lpng14!-lpng14\ -lz! > libpng.pc
Glenn Randers-Pehrson837a3d12002-05-10 20:19:58 -050088
89libpng-config:
90 ( cat scripts/libpng-config-head.in; \
91 echo prefix=\"$(prefix)\"; \
Glenn Randers-Pehrson5ff38d32002-09-17 23:38:46 -050092 echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \
93 echo L_opts=\"-L$(LIBPATH)\"; \
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -050094 echo libs=\"-lpng14 -lz\"; \
Glenn Randers-Pehrson837a3d12002-05-10 20:19:58 -050095 cat scripts/libpng-config-body.in ) > libpng-config
96 chmod +x libpng-config
Glenn Randers-Pehrson03008a02002-04-27 10:11:25 -050097
Glenn Randers-Pehrson4deeb792006-03-22 16:21:59 -060098$(LIBSO): $(LIBSOMAJ)
99 $(LN_SF) $(LIBSOMAJ) $(LIBSO)
Glenn Randers-Pehrson5a0be342001-10-18 20:55:13 -0500100
Glenn Randers-Pehrson4deeb792006-03-22 16:21:59 -0600101$(LIBSOMAJ): $(LIBSOVER)
102 $(LN_SF) $(LIBSOVER) $(LIBSOMAJ)
Glenn Randers-Pehrson5a0be342001-10-18 20:55:13 -0500103
Glenn Randers-Pehrson4deeb792006-03-22 16:21:59 -0600104$(LIBSOVER): $(OBJSDLL)
Glenn Randers-Pehrson9c0f0942002-02-21 23:14:23 -0600105 $(CC) -dynamiclib \
Glenn Randers-Pehrson4deeb792006-03-22 16:21:59 -0600106 -install_name $(LIBPATH)/$(LIBSOMAJ) \
Glenn Randers-Pehrson272489d2004-08-04 06:34:52 -0500107 -current_version $(PNGVER) -compatibility_version $(PNGVER) \
Glenn Randers-Pehrson4deeb792006-03-22 16:21:59 -0600108 -o $(LIBSOVER) \
Glenn Randers-Pehrson272489d2004-08-04 06:34:52 -0500109 $(OBJSDLL) -L$(ZLIBLIB) -lz
Glenn Randers-Pehrson5a0be342001-10-18 20:55:13 -0500110
Glenn Randers-Pehrsoneb580912008-07-30 14:47:09 -0500111$(OLDSOVER): $(OBJSDLL)
112 $(CC) -dynamiclib \
113 -install_name $(LIBPATH)/$(OLDSOMAJ) \
114 -current_version 3 -compatibility_version 3 \
115 -o $(OLDSOVER) \
116 $(OBJSDLL) -L$(ZLIBLIB) -lz
117
Glenn Randers-Pehrson4deeb792006-03-22 16:21:59 -0600118pngtest: pngtest.o $(LIBSO)
Glenn Randers-Pehrson5a0be342001-10-18 20:55:13 -0500119 $(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS)
120
121test: pngtest
122 ./pngtest
123
Glenn Randers-Pehrsoneb580912008-07-30 14:47:09 -0500124install-headers: png.h pngconf.h
Glenn Randers-Pehrson1ce08362006-03-08 23:35:59 -0600125 -@if [ ! -d $(DI) ]; then $(MKDIR_P) $(DI); fi
126 -@if [ ! -d $(DI)/$(LIBNAME) ]; then $(MKDIR_P) $(DI)/$(LIBNAME); fi
Glenn Randers-Pehrsoneb580912008-07-30 14:47:09 -0500127 cp png.h pngconf.h $(DI)/$(LIBNAME)
Glenn Randers-Pehrson07748d12002-05-25 11:12:10 -0500128 chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h
Glenn Randers-Pehrsoneb580912008-07-30 14:47:09 -0500129 -@$(RM_F) $(DI)/png.h $(DI)/pngconf.h
Glenn Randers-Pehrson5c60b232006-03-07 07:09:22 -0600130 -@$(RM_F) $(DI)/libpng
131 (cd $(DI); $(LN_SF) $(LIBNAME) libpng; $(LN_SF) $(LIBNAME)/* .)
Glenn Randers-Pehrsonc1bfe682002-03-06 22:08:00 -0600132
133install-static: install-headers libpng.a
Glenn Randers-Pehrson1ce08362006-03-08 23:35:59 -0600134 -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi
Glenn Randers-Pehrsoncfbed9b2002-05-21 18:06:08 -0500135 cp libpng.a $(DL)/$(LIBNAME).a
136 chmod 644 $(DL)/$(LIBNAME).a
Glenn Randers-Pehrson272489d2004-08-04 06:34:52 -0500137 $(RANLIB) $(DL)/$(LIBNAME).a
Glenn Randers-Pehrson5c60b232006-03-07 07:09:22 -0600138 -@$(RM_F) $(DL)/libpng.a
139 (cd $(DL); $(LN_SF) $(LIBNAME).a libpng.a)
Glenn Randers-Pehrsonc1bfe682002-03-06 22:08:00 -0600140
Glenn Randers-Pehrsoneb580912008-07-30 14:47:09 -0500141install-shared: install-headers $(LIBSO) libpng.pc \
142 $(OLDSOVER)
Glenn Randers-Pehrson1ce08362006-03-08 23:35:59 -0600143 -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi
Glenn Randers-Pehrson5c60b232006-03-07 07:09:22 -0600144 -@$(RM_F) $(DL)/$(LIBNAME).$(PNGVER)*.dylib
145 -@$(RM_F) $(DL)/$(LIBNAME).$(PNGMAJ)*.dylib
Glenn Randers-Pehrson4deeb792006-03-22 16:21:59 -0600146 -@$(RM_F) $(DL)/$(LIBSO)
147 -@$(RM_F) $(DL)/$(OLDSO)
Glenn Randers-Pehrsoneb580912008-07-30 14:47:09 -0500148 -@$(RM_F) $(DL)/$(OLDSOMAJ)
Glenn Randers-Pehrson5c60b232006-03-07 07:09:22 -0600149 -@$(RM_F) $(DL)/libpng.3.$(PNGMIN)*.dylib
Glenn Randers-Pehrson4deeb792006-03-22 16:21:59 -0600150 cp $(LIBSOVER) $(DL)
Glenn Randers-Pehrsoneb580912008-07-30 14:47:09 -0500151 cp $(OLDSOVER) $(DL)
Glenn Randers-Pehrson4deeb792006-03-22 16:21:59 -0600152 chmod 755 $(DL)/$(LIBSOVER)
Glenn Randers-Pehrsoneb580912008-07-30 14:47:09 -0500153 chmod 755 $(DL)/$(OLDSOVER)
Glenn Randers-Pehrsoncfbed9b2002-05-21 18:06:08 -0500154 (cd $(DL); \
Glenn Randers-Pehrsoneb580912008-07-30 14:47:09 -0500155 $(LN_SF) $(OLDSOVER) $(OLDSOMAJ); \
156 $(LN_SF) $(OLDSOMAJ) $(OLDSO); \
Glenn Randers-Pehrson4deeb792006-03-22 16:21:59 -0600157 $(LN_SF) $(LIBSOVER) $(LIBSOMAJ); \
Glenn Randers-Pehrsoneb580912008-07-30 14:47:09 -0500158 $(LN_SF) $(LIBSOMAJ) $(LIBSO))
Glenn Randers-Pehrson1ce08362006-03-08 23:35:59 -0600159 -@if [ ! -d $(DL)/pkgconfig ]; then $(MKDIR_P) $(DL)/pkgconfig; fi
Glenn Randers-Pehrson5c60b232006-03-07 07:09:22 -0600160 -@$(RM_F) $(DL)/pkgconfig/$(LIBNAME).pc
161 -@$(RM_F) $(DL)/pkgconfig/libpng.pc
Glenn Randers-Pehrsoncfbed9b2002-05-21 18:06:08 -0500162 cp libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc
163 chmod 644 $(DL)/pkgconfig/$(LIBNAME).pc
Glenn Randers-Pehrson5c60b232006-03-07 07:09:22 -0600164 (cd $(DL)/pkgconfig; $(LN_SF) $(LIBNAME).pc libpng.pc)
Glenn Randers-Pehrsonc1bfe682002-03-06 22:08:00 -0600165
Glenn Randers-Pehrson03008a02002-04-27 10:11:25 -0500166install-man: libpng.3 libpngpf.3 png.5
Glenn Randers-Pehrson1ce08362006-03-08 23:35:59 -0600167 -@if [ ! -d $(DM) ]; then $(MKDIR_P) $(DM); fi
168 -@if [ ! -d $(DM)/man3 ]; then $(MKDIR_P) $(DM)/man3; fi
Glenn Randers-Pehrson5c60b232006-03-07 07:09:22 -0600169 -@$(RM_F) $(DM)/man3/libpng.3
170 -@$(RM_F) $(DM)/man3/libpngpf.3
Glenn Randers-Pehrsoncfbed9b2002-05-21 18:06:08 -0500171 cp libpng.3 $(DM)/man3
172 cp libpngpf.3 $(DM)/man3
Glenn Randers-Pehrson1ce08362006-03-08 23:35:59 -0600173 -@if [ ! -d $(DM)/man5 ]; then $(MKDIR_P) $(DM)/man5; fi
Glenn Randers-Pehrson5c60b232006-03-07 07:09:22 -0600174 -@$(RM_F) $(DM)/man5/png.5
Glenn Randers-Pehrsoncfbed9b2002-05-21 18:06:08 -0500175 cp png.5 $(DM)/man5
Glenn Randers-Pehrson03008a02002-04-27 10:11:25 -0500176
Glenn Randers-Pehrson837a3d12002-05-10 20:19:58 -0500177install-config: libpng-config
Glenn Randers-Pehrson1ce08362006-03-08 23:35:59 -0600178 -@if [ ! -d $(DB) ]; then $(MKDIR_P) $(DB); fi
Glenn Randers-Pehrson5c60b232006-03-07 07:09:22 -0600179 -@$(RM_F) $(DB)/libpng-config
180 -@$(RM_F) $(DB)/$(LIBNAME)-config
Glenn Randers-Pehrsoncfbed9b2002-05-21 18:06:08 -0500181 cp libpng-config $(DB)/$(LIBNAME)-config
182 chmod 755 $(DB)/$(LIBNAME)-config
Glenn Randers-Pehrson5c60b232006-03-07 07:09:22 -0600183 (cd $(DB); $(LN_SF) $(LIBNAME)-config libpng-config)
Glenn Randers-Pehrson704228f2002-05-02 20:49:40 -0500184
185install: install-static install-shared install-man install-config
Glenn Randers-Pehrson5a0be342001-10-18 20:55:13 -0500186
Glenn Randers-Pehrsond020e9d2002-06-28 09:34:00 -0500187# If you installed in $(DESTDIR), test-installed won't work until you
Glenn Randers-Pehrsona4981d42004-08-25 22:00:45 -0500188# move the library to its final location. Use test-dd to test it
189# before then.
190
191test-dd:
192 echo
193 echo Testing installed dynamic shared library in $(DL).
194 $(CC) -I$(DI) -I$(ZLIBINC) \
Glenn Randers-Pehrson5c60b232006-03-07 07:09:22 -0600195 `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \
Glenn Randers-Pehrsona4981d42004-08-25 22:00:45 -0500196 -L$(DL) -L$(ZLIBLIB) \
Glenn Randers-Pehrson5c60b232006-03-07 07:09:22 -0600197 -o pngtestd `$(BINPATH)/$(LIBNAME)-config --ldflags`
Glenn Randers-Pehrsona4981d42004-08-25 22:00:45 -0500198 ./pngtestd pngtest.png
Glenn Randers-Pehrsond020e9d2002-06-28 09:34:00 -0500199
200test-installed:
201 $(CC) $(CFLAGS) \
Glenn Randers-Pehrson5c60b232006-03-07 07:09:22 -0600202 `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \
Glenn Randers-Pehrsond020e9d2002-06-28 09:34:00 -0500203 -L$(ZLIBLIB) \
Glenn Randers-Pehrson5c60b232006-03-07 07:09:22 -0600204 -o pngtesti `$(BINPATH)/$(LIBNAME)-config --ldflags`
Glenn Randers-Pehrson2ae022d2002-07-01 22:23:46 -0500205 ./pngtesti pngtest.png
Glenn Randers-Pehrsond020e9d2002-06-28 09:34:00 -0500206
Glenn Randers-Pehrson5a0be342001-10-18 20:55:13 -0500207clean:
Glenn Randers-Pehrson5c60b232006-03-07 07:09:22 -0600208 $(RM_F) *.o libpng.a pngtest pngout.png libpng-config \
Glenn Randers-Pehrsoneb580912008-07-30 14:47:09 -0500209 $(OLDSOVER) \
210 libpng.pc $(LIBNAME).*dylib pngtesti
Glenn Randers-Pehrson5a0be342001-10-18 20:55:13 -0500211
212DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO
213writelock:
214 chmod a-w *.[ch35] $(DOCS) scripts/*
215
216# DO NOT DELETE THIS LINE -- make depend depends on it.
217
Glenn Randers-Pehrsoneb580912008-07-30 14:47:09 -0500218png.o png.pic.o: png.h pngconf.h
219pngerror.o pngerror.pic.o: png.h pngconf.h
220pngrio.o pngrio.pic.o: png.h pngconf.h
221pngwio.o pngwio.pic.o: png.h pngconf.h
222pngmem.o pngmem.pic.o: png.h pngconf.h
223pngset.o pngset.pic.o: png.h pngconf.h
224pngget.o pngget.pic.o: png.h pngconf.h
225pngread.o pngread.pic.o: png.h pngconf.h
226pngrtran.o pngrtran.pic.o: png.h pngconf.h
227pngrutil.o pngrutil.pic.o: png.h pngconf.h
228pngtrans.o pngtrans.pic.o: png.h pngconf.h
229pngwrite.o pngwrite.pic.o: png.h pngconf.h
230pngwtran.o pngwtran.pic.o: png.h pngconf.h
231pngwutil.o pngwutil.pic.o: png.h pngconf.h
232pngpread.o pngpread.pic.o: png.h pngconf.h
Glenn Randers-Pehrson5a0be342001-10-18 20:55:13 -0500233
Glenn Randers-Pehrsoneb580912008-07-30 14:47:09 -0500234pngtest.o: png.h pngconf.h