blob: 5b53046a36d621e03a43cc45fad85453a10ee967 [file] [log] [blame]
The Android Open Source Project893912b2009-03-03 19:30:05 -08001# makefile for libpng on Darwin / Mac OS X
The Android Open Source Project4215dd12009-03-09 11:52:12 -07002# Copyright (C) 2002, 2004, 2006, 2008 Glenn Randers-Pehrson
The Android Open Source Project893912b2009-03-03 19:30:05 -08003# Copyright (C) 2001 Christoph Pfisterer
4# derived from makefile.linux:
5# Copyright (C) 1998, 1999 Greg Roelofs
6# Copyright (C) 1996, 1997 Andreas Dilger
Patrick Scott5f6bd842010-06-28 16:55:16 -04007#
Patrick Scotta0bb96c2009-07-22 11:50:02 -04008# This code is released under the libpng license.
9# For conditions of distribution and use, see the disclaimer
10# and license in png.h
The Android Open Source Project893912b2009-03-03 19:30:05 -080011
12# where "make install" puts libpng.a, libpng12.dylib, png.h and pngconf.h
13prefix=/usr/local
14exec_prefix=$(prefix)
15
16# Where the zlib library and include files are located
17#ZLIBLIB=/usr/local/lib
18#ZLIBINC=/usr/local/include
19ZLIBLIB=../zlib
20ZLIBINC=../zlib
21
22# Library name:
23LIBNAME = libpng12
The Android Open Source Project4215dd12009-03-09 11:52:12 -070024PNGMAJ = 12
Eric Vannier66dce0d2011-07-20 17:03:29 -070025PNGMIN = 1.2.46
The Android Open Source Project893912b2009-03-03 19:30:05 -080026PNGVER = $(PNGMAJ).$(PNGMIN)
27
28# Shared library names:
29LIBSO=$(LIBNAME).dylib
30LIBSOMAJ=$(LIBNAME).$(PNGMAJ).dylib
31LIBSOVER=$(LIBNAME).$(PNGVER).dylib
32OLDSO=libpng.dylib
33OLDSOMAJ=libpng.3.dylib
34OLDSOVER=libpng.3.$(PNGMIN).dylib
35
36# Utilities:
37CC=cc
38AR_RC=ar rc
39MKDIR_P=mkdir -p
40LN_SF=ln -sf
41RANLIB=ranlib
42RM_F=/bin/rm -f
43
The Android Open Source Project4215dd12009-03-09 11:52:12 -070044# CFLAGS=-I$(ZLIBINC) -W -Wall -O3 -funroll-loops -DPNG_NO_MMX_CODE
45CFLAGS=-I$(ZLIBINC) -W -Wall -O -funroll-loops
The Android Open Source Project893912b2009-03-03 19:30:05 -080046LDFLAGS=-L. -L$(ZLIBLIB) -lpng12 -lz
47
48INCPATH=$(prefix)/include
49LIBPATH=$(exec_prefix)/lib
50MANPATH=$(prefix)/man
51BINPATH=$(exec_prefix)/bin
52
53# override DESTDIR= on the make install command line to easily support
54# installing into a temporary location. Example:
55#
56# make install DESTDIR=/tmp/build/libpng
57#
58# If you're going to install into a temporary location
59# via DESTDIR, $(DESTDIR)$(prefix) must already exist before
60# you execute make install.
61DESTDIR=
62
63DB=$(DESTDIR)$(BINPATH)
64DI=$(DESTDIR)$(INCPATH)
65DL=$(DESTDIR)$(LIBPATH)
66DM=$(DESTDIR)$(MANPATH)
67
68OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \
69 pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \
70 pngwtran.o pngmem.o pngerror.o pngpread.o
71
72OBJSDLL = $(OBJS:.o=.pic.o)
73
74.SUFFIXES: .c .o .pic.o
75
76.c.pic.o:
77 $(CC) -c $(CFLAGS) -fno-common -o $@ $*.c
78
79all: libpng.a $(LIBSO) pngtest libpng.pc libpng-config
80
81libpng.a: $(OBJS)
82 $(AR_RC) $@ $(OBJS)
83 $(RANLIB) $@
84
85libpng.pc:
86 cat scripts/libpng.pc.in | sed -e s!@prefix@!$(prefix)! \
87 -e s!@exec_prefix@!$(exec_prefix)! \
88 -e s!@libdir@!$(LIBPATH)! \
89 -e s!@includedir@!$(INCPATH)! \
90 -e s!-lpng12!-lpng12\ -lz! > libpng.pc
91
92libpng-config:
93 ( cat scripts/libpng-config-head.in; \
94 echo prefix=\"$(prefix)\"; \
95 echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \
96 echo L_opts=\"-L$(LIBPATH)\"; \
97 echo libs=\"-lpng12 -lz\"; \
98 cat scripts/libpng-config-body.in ) > libpng-config
99 chmod +x libpng-config
100
101$(LIBSO): $(LIBSOMAJ)
102 $(LN_SF) $(LIBSOMAJ) $(LIBSO)
103
104$(LIBSOMAJ): $(LIBSOVER)
105 $(LN_SF) $(LIBSOVER) $(LIBSOMAJ)
106
107$(LIBSOVER): $(OBJSDLL)
108 $(CC) -dynamiclib \
109 -install_name $(LIBPATH)/$(LIBSOMAJ) \
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700110 -current_version 0 -compatibility_version 0 \
The Android Open Source Project893912b2009-03-03 19:30:05 -0800111 -o $(LIBSOVER) \
112 $(OBJSDLL) -L$(ZLIBLIB) -lz
113
114$(OLDSOVER): $(OBJSDLL)
115 $(CC) -dynamiclib \
116 -install_name $(LIBPATH)/$(OLDSOMAJ) \
117 -current_version 3 -compatibility_version 3 \
118 -o $(OLDSOVER) \
119 $(OBJSDLL) -L$(ZLIBLIB) -lz
120
121pngtest: pngtest.o $(LIBSO)
122 $(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS)
123
124test: pngtest
125 ./pngtest
126
127install-headers: png.h pngconf.h
128 -@if [ ! -d $(DI) ]; then $(MKDIR_P) $(DI); fi
129 -@if [ ! -d $(DI)/$(LIBNAME) ]; then $(MKDIR_P) $(DI)/$(LIBNAME); fi
130 cp png.h pngconf.h $(DI)/$(LIBNAME)
131 chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h
132 -@$(RM_F) $(DI)/png.h $(DI)/pngconf.h
133 -@$(RM_F) $(DI)/libpng
134 (cd $(DI); $(LN_SF) $(LIBNAME) libpng; $(LN_SF) $(LIBNAME)/* .)
135
136install-static: install-headers libpng.a
137 -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi
138 cp libpng.a $(DL)/$(LIBNAME).a
139 chmod 644 $(DL)/$(LIBNAME).a
140 $(RANLIB) $(DL)/$(LIBNAME).a
141 -@$(RM_F) $(DL)/libpng.a
142 (cd $(DL); $(LN_SF) $(LIBNAME).a libpng.a)
143
144install-shared: install-headers $(LIBSO) libpng.pc \
145 $(OLDSOVER)
146 -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi
147 -@$(RM_F) $(DL)/$(LIBNAME).$(PNGVER)*.dylib
148 -@$(RM_F) $(DL)/$(LIBNAME).$(PNGMAJ)*.dylib
149 -@$(RM_F) $(DL)/$(LIBSO)
150 -@$(RM_F) $(DL)/$(OLDSO)
151 -@$(RM_F) $(DL)/$(OLDSOMAJ)
152 -@$(RM_F) $(DL)/libpng.3.$(PNGMIN)*.dylib
153 cp $(LIBSOVER) $(DL)
154 cp $(OLDSOVER) $(DL)
155 chmod 755 $(DL)/$(LIBSOVER)
156 chmod 755 $(DL)/$(OLDSOVER)
157 (cd $(DL); \
158 $(LN_SF) $(OLDSOVER) $(OLDSOMAJ); \
159 $(LN_SF) $(OLDSOMAJ) $(OLDSO); \
160 $(LN_SF) $(LIBSOVER) $(LIBSOMAJ); \
161 $(LN_SF) $(LIBSOMAJ) $(LIBSO))
162 -@if [ ! -d $(DL)/pkgconfig ]; then $(MKDIR_P) $(DL)/pkgconfig; fi
163 -@$(RM_F) $(DL)/pkgconfig/$(LIBNAME).pc
164 -@$(RM_F) $(DL)/pkgconfig/libpng.pc
165 cp libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc
166 chmod 644 $(DL)/pkgconfig/$(LIBNAME).pc
167 (cd $(DL)/pkgconfig; $(LN_SF) $(LIBNAME).pc libpng.pc)
168
169install-man: libpng.3 libpngpf.3 png.5
170 -@if [ ! -d $(DM) ]; then $(MKDIR_P) $(DM); fi
171 -@if [ ! -d $(DM)/man3 ]; then $(MKDIR_P) $(DM)/man3; fi
172 -@$(RM_F) $(DM)/man3/libpng.3
173 -@$(RM_F) $(DM)/man3/libpngpf.3
174 cp libpng.3 $(DM)/man3
175 cp libpngpf.3 $(DM)/man3
176 -@if [ ! -d $(DM)/man5 ]; then $(MKDIR_P) $(DM)/man5; fi
177 -@$(RM_F) $(DM)/man5/png.5
178 cp png.5 $(DM)/man5
179
180install-config: libpng-config
181 -@if [ ! -d $(DB) ]; then $(MKDIR_P) $(DB); fi
182 -@$(RM_F) $(DB)/libpng-config
183 -@$(RM_F) $(DB)/$(LIBNAME)-config
184 cp libpng-config $(DB)/$(LIBNAME)-config
185 chmod 755 $(DB)/$(LIBNAME)-config
186 (cd $(DB); $(LN_SF) $(LIBNAME)-config libpng-config)
187
188install: install-static install-shared install-man install-config
189
190# If you installed in $(DESTDIR), test-installed won't work until you
191# move the library to its final location. Use test-dd to test it
192# before then.
193
194test-dd:
195 echo
196 echo Testing installed dynamic shared library in $(DL).
197 $(CC) -I$(DI) -I$(ZLIBINC) \
198 `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \
199 -L$(DL) -L$(ZLIBLIB) \
200 -o pngtestd `$(BINPATH)/$(LIBNAME)-config --ldflags`
201 ./pngtestd pngtest.png
202
203test-installed:
204 $(CC) $(CFLAGS) \
205 `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \
206 -L$(ZLIBLIB) \
207 -o pngtesti `$(BINPATH)/$(LIBNAME)-config --ldflags`
208 ./pngtesti pngtest.png
209
210clean:
211 $(RM_F) *.o libpng.a pngtest pngout.png libpng-config \
212 $(OLDSOVER) \
213 libpng.pc $(LIBNAME).*dylib pngtesti
214
215DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO
216writelock:
217 chmod a-w *.[ch35] $(DOCS) scripts/*
218
219# DO NOT DELETE THIS LINE -- make depend depends on it.
220
221png.o png.pic.o: png.h pngconf.h
222pngerror.o pngerror.pic.o: png.h pngconf.h
223pngrio.o pngrio.pic.o: png.h pngconf.h
224pngwio.o pngwio.pic.o: png.h pngconf.h
225pngmem.o pngmem.pic.o: png.h pngconf.h
226pngset.o pngset.pic.o: png.h pngconf.h
227pngget.o pngget.pic.o: png.h pngconf.h
228pngread.o pngread.pic.o: png.h pngconf.h
229pngrtran.o pngrtran.pic.o: png.h pngconf.h
230pngrutil.o pngrutil.pic.o: png.h pngconf.h
231pngtrans.o pngtrans.pic.o: png.h pngconf.h
232pngwrite.o pngwrite.pic.o: png.h pngconf.h
233pngwtran.o pngwtran.pic.o: png.h pngconf.h
234pngwutil.o pngwutil.pic.o: png.h pngconf.h
235pngpread.o pngpread.pic.o: png.h pngconf.h
236
237pngtest.o: png.h pngconf.h