fdc744d929c99a37731484979f1c0187ac4f2529
[platform/upstream/libpng.git] / scripts / makefile.darwin
1 # makefile for libpng on Darwin / Mac OS X
2 # Copyright (C) 2002, 2004, 2006, 2008, 2010-2014 Glenn Randers-Pehrson
3 # 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 #
8 # This code is released under the libpng license.
9 # For conditions of distribution and use, see the disclaimer
10 # and license in png.h
11
12 # where "make install" puts libpng.a, libpng16.dylib, png.h, pngconf.h,
13 # and pnglibconf.h
14 prefix=/usr/local
15 exec_prefix=$(prefix)
16
17 # Where the zlib library and include files are located
18 ZLIBLIB=/usr/lib
19 ZLIBINC=/usr/include
20
21 # Library name:
22 LIBNAME = libpng16
23 PNGMAJ = 16
24
25 # Shared library names:
26 LIBSO=$(LIBNAME).dylib
27 LIBSOMAJ=$(LIBNAME).$(PNGMAJ).dylib
28 LIBSOREL=$(LIBNAME).$(PNGMAJ).$(RELEASE).dylib
29 OLDSO=libpng.dylib
30
31 # Utilities:
32 CC=cc
33 AR_RC=ar rc
34 MKDIR_P=mkdir -p
35 LN_SF=ln -sf
36 RANLIB=ranlib
37 CP=cp
38 RM_F=/bin/rm -f
39 ARCH=-arch ppc -arch i386 -arch x86_64
40
41 CPPFLAGS=-I$(ZLIBINC)
42 # CFLAGS=-W -Wall -O3 -funroll-loops
43 CFLAGS=-W -Wall -O -funroll-loops $(ARCH)
44 LDFLAGS=-L. -L$(ZLIBLIB) -lpng16 -lz $(ARCH)
45
46 INCPATH=$(prefix)/include
47 LIBPATH=$(exec_prefix)/lib
48 MANPATH=$(prefix)/man
49 BINPATH=$(exec_prefix)/bin
50
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
57 # via DESTDIR, $(DESTDIR)$(prefix) must already exist before
58 # you execute make install.
59 DESTDIR=
60
61 DB=$(DESTDIR)$(BINPATH)
62 DI=$(DESTDIR)$(INCPATH)
63 DL=$(DESTDIR)$(LIBPATH)
64 DM=$(DESTDIR)$(MANPATH)
65
66 # Pre-built configuration
67 # See scripts/pnglibconf.mak for more options
68 PNGLIBCONF_H_PREBUILT = scripts/pnglibconf.h.prebuilt
69
70 OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \
71         pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \
72         pngwtran.o pngmem.o pngerror.o pngpread.o
73
74 OBJSDLL = $(OBJS:.o=.pic.o)
75
76 .SUFFIXES:      .c .o .pic.o
77
78 .c.o:
79         $(CC) -c $(CPPFLAGS) $(CFLAGS) -o $@ $<
80
81 .c.pic.o:
82         $(CC) -c $(CPPFLAGS) $(CFLAGS) -fno-common -o $@ $*.c
83
84 all: libpng.a $(LIBSO) pngtest libpng.pc libpng-config
85
86 pnglibconf.h: $(PNGLIBCONF_H_PREBUILT)
87         $(CP) $(PNGLIBCONF_H_PREBUILT) $@
88
89 libpng.a: $(OBJS)
90         $(AR_RC) $@ $(OBJS)
91         $(RANLIB) $@
92
93 libpng.pc:
94         cat scripts/libpng.pc.in | sed -e s!@prefix@!$(prefix)! \
95         -e s!@exec_prefix@!$(exec_prefix)! \
96         -e s!@libdir@!$(LIBPATH)! \
97         -e s!@includedir@!$(INCPATH)! \
98         -e s!-lpng16!-lpng16\ -lz! > libpng.pc
99
100 libpng-config:
101         ( cat scripts/libpng-config-head.in; \
102         echo prefix=\"$(prefix)\"; \
103         echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \
104         echo L_opts=\"-L$(LIBPATH)\"; \
105         echo libs=\"-lpng16 -lz\"; \
106         cat scripts/libpng-config-body.in ) > libpng-config
107         chmod +x libpng-config
108
109 $(LIBSO): $(LIBSOMAJ)
110         $(LN_SF) $(LIBSOMAJ) $(LIBSO)
111
112 $(LIBSOMAJ): $(OBJSDLL)
113         $(CC) -dynamiclib \
114          -install_name $(LIBPATH)/$(LIBSOMAJ) \
115          -current_version 16 -compatibility_version 16 \
116          $(ARCH) -o $(LIBSOMAJ) \
117          $(OBJSDLL) -L$(ZLIBLIB) -lz
118
119 pngtest: pngtest.o $(LIBSO)
120         $(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS)
121
122 test: pngtest
123         ./pngtest
124
125 install-headers: png.h pngconf.h pnglibconf.h
126         -@if [ ! -d $(DI) ]; then $(MKDIR_P) $(DI); fi
127         -@if [ ! -d $(DI)/$(LIBNAME) ]; then $(MKDIR_P) $(DI)/$(LIBNAME); fi
128         cp png.h pngconf.h pnglibconf.h $(DI)/$(LIBNAME)
129         chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h $(DI)/$(LIBNAME)/pnglibconf.h
130         -@$(RM_F) $(DI)/png.h $(DI)/pngconf.h $(DI)/pnglibconf.h
131         -@$(RM_F) $(DI)/libpng
132         (cd $(DI); $(LN_SF) $(LIBNAME) libpng; $(LN_SF) $(LIBNAME)/* .)
133
134 install-static: install-headers libpng.a
135         -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi
136         cp libpng.a $(DL)/$(LIBNAME).a
137         chmod 644 $(DL)/$(LIBNAME).a
138         $(RANLIB) $(DL)/$(LIBNAME).a
139         -@$(RM_F) $(DL)/libpng.a
140         (cd $(DL); $(LN_SF) $(LIBNAME).a libpng.a)
141
142 install-shared: install-headers $(LIBSOMAJ) libpng.pc
143         -@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi
144         -@$(RM_F) $(DL)/$(LIBSO)
145         -@$(RM_F) $(DL)/$(LIBSOMAJ)
146         -@$(RM_F) $(DL)/$(OLDSO)
147         cp $(LIBSOMAJ) $(DL)
148         chmod 755 $(DL)/$(LIBSOMAJ)
149         (cd $(DL); \
150         $(LN_SF) $(LIBSOREL) $(LIBSO); \
151         $(LN_SF) $(LIBSO) $(OLDSO))
152         -@if [ ! -d $(DL)/pkgconfig ]; then $(MKDIR_P) $(DL)/pkgconfig; fi
153         -@$(RM_F) $(DL)/pkgconfig/$(LIBNAME).pc
154         -@$(RM_F) $(DL)/pkgconfig/libpng.pc
155         cp libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc
156         chmod 644 $(DL)/pkgconfig/$(LIBNAME).pc
157         (cd $(DL)/pkgconfig; $(LN_SF) $(LIBNAME).pc libpng.pc)
158
159 install-man: libpng.3 libpngpf.3 png.5
160         -@if [ ! -d $(DM) ]; then $(MKDIR_P) $(DM); fi
161         -@if [ ! -d $(DM)/man3 ]; then $(MKDIR_P) $(DM)/man3; fi
162         -@$(RM_F) $(DM)/man3/libpng.3
163         -@$(RM_F) $(DM)/man3/libpngpf.3
164         cp libpng.3 $(DM)/man3
165         cp libpngpf.3 $(DM)/man3
166         -@if [ ! -d $(DM)/man5 ]; then $(MKDIR_P) $(DM)/man5; fi
167         -@$(RM_F) $(DM)/man5/png.5
168         cp png.5 $(DM)/man5
169
170 install-config: libpng-config
171         -@if [ ! -d $(DB) ]; then $(MKDIR_P) $(DB); fi
172         -@$(RM_F) $(DB)/libpng-config
173         -@$(RM_F) $(DB)/$(LIBNAME)-config
174         cp libpng-config $(DB)/$(LIBNAME)-config
175         chmod 755 $(DB)/$(LIBNAME)-config
176         (cd $(DB); $(LN_SF) $(LIBNAME)-config libpng-config)
177
178 install: install-static install-shared install-man install-config
179
180 # If you installed in $(DESTDIR), test-installed won't work until you
181 # move the library to its final location.  Use test-dd to test it
182 # before then.
183
184 test-dd:
185         echo
186         echo Testing installed dynamic shared library in $(DL).
187         $(CC) -I$(DI) $(CPPFLAGS) \
188            `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \
189            -L$(DL) -L$(ZLIBLIB) \
190            -o pngtestd `$(BINPATH)/$(LIBNAME)-config --ldflags`
191         ./pngtestd pngtest.png
192
193 test-installed:
194         $(CC) $(CPPFLAGS) $(CFLAGS) \
195            `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \
196            -L$(ZLIBLIB) \
197            -o pngtesti `$(BINPATH)/$(LIBNAME)-config --ldflags`
198         ./pngtesti pngtest.png
199
200 clean:
201         $(RM_F) *.o libpng.a pngtest pngout.png libpng-config \
202         libpng.pc $(LIBNAME).*dylib pngtesti pnglibconf.h
203
204 DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO
205 writelock:
206         chmod a-w *.[ch35] $(DOCS) scripts/*
207
208 # DO NOT DELETE THIS LINE -- make depend depends on it.
209
210 png.o png.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
211 pngerror.o pngerror.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
212 pngrio.o pngrio.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
213 pngwio.o pngwio.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
214 pngmem.o pngmem.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
215 pngset.o pngset.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
216 pngget.o pngget.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
217 pngread.o pngread.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
218 pngrtran.o pngrtran.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
219 pngrutil.o pngrutil.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
220 pngtrans.o pngtrans.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
221 pngwrite.o pngwrite.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
222 pngwtran.o pngwtran.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
223 pngwutil.o pngwutil.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
224 pngpread.o pngpread.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
225
226 pngtest.o: png.h pngconf.h pnglibconf.h