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