1 # makefile for libpng, MACOS X
2 # Copyright (C) 2002 Glenn Randers-Pehrson
3 # Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc.
4 # Modified by Karin Kosina <kyrah@sim.no> 20011010:
5 # build shared library (*.dylib)
6 # For conditions of distribution and use, see copyright notice in png.h
8 # where make install puts libpng.a and png.h
11 # Where the zlib library and include files are located
12 #ZLIBLIB=/usr/local/lib
13 #ZLIBINC=/usr/local/include
21 PNGVER = $(PNGMAJ).$(PNGMIN)
23 CFLAGS+=-fno-common -I$(ZLIBINC) -O # -g -DPNG_DEBUG=5
24 LDFLAGS+=-L. -L$(ZLIBLIB) -lpng -lz
27 SHAREDLIB_POSTFIX=dylib
28 INCPATH=$(prefix)/include
33 # override DESTDIR= on the make install command line to easily support
34 # installing into a temporary location. Example:
36 # make install DESTDIR=/tmp/build/libpng
38 # If you're going to install into a temporary location
39 # via DESTDIR, $(DESTDIR)$(prefix) must already exist before
40 # you execute make install.
43 DB=$(DESTDIR)$(BINPATH)
44 DI=$(DESTDIR)$(INCPATH)
45 DL=$(DESTDIR)$(LIBPATH)
46 DM=$(DESTDIR)$(MANPATH)
51 OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \
52 pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \
53 pngwtran.o pngmem.o pngerror.o pngpread.o
55 all: libpng.a pngtest shared libpng.pc libpng-config
57 shared: $(LIBNAME).$(PNGVER).$(SHAREDLIB_POSTFIX)
60 cat scripts/libpng.pc.in | sed -e s\!@PREFIX@!$(prefix)! | \
61 sed -e s/-lm// > libpng.pc
64 ( cat scripts/libpng-config-head.in; \
65 echo prefix=\"$(prefix)\"; \
66 echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \
67 echo L_opts=\"-L$(LIBPATH)\"; \
68 echo libs=\"-lpng12 -lz\"; \
69 cat scripts/libpng-config-body.in ) > libpng-config
70 chmod +x libpng-config
73 $(CC) -static -nodefaultlibs -o $@ $(OBJS)
74 # ar rc $(ARCHFLAGS) $@ $(OBJS)
77 $(LIBNAME).$(PNGVER).$(SHAREDLIB_POSTFIX): $(OBJS)
78 $(CC) -dynamiclib -flat_namespace -undefined suppress -o $@ $(OBJS)
80 libpng.3.$(PNGMIN).$(SHAREDLIB_POSTFIX): $(OBJS)
81 $(CC) -dynamiclib -compatibility_version 3 -flat_namespace \
82 -undefined suppress -o $@ $(OBJS)
84 pngtest: pngtest.o libpng.a
85 $(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS)
90 install-headers: png.h pngconf.h
91 -@if [ ! -d $(DI) ]; then mkdir $(DI); fi
92 -@if [ ! -d $(DI)/$(LIBNAME) ]; then mkdir $(DI)/$(LIBNAME); fi
93 cp png.h pngconf.h $(DI)/$(LIBNAME)
94 chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h
95 -@/bin/rm -f $(DI)/png.h $(DI)/pngconf.h
96 -@/bin/rm -f $(DI)/libpng
97 (cd $(DI); ln -f -s $(LIBNAME) libpng; ln -f -s $(LIBNAME)/* .)
99 install-static: install-headers libpng.a
100 -@if [ ! -d $(DL) ]; then mkdir $(DL); fi
101 cp libpng.a $(DL)/$(LIBNAME).a
102 chmod 644 $(DL)/$(LIBNAME).a
103 -@/bin/rm -f $(DL)/libpng.a
104 (cd $(DL); ln -f -s $(LIBNAME).a libpng.a)
106 install-shared: install-headers $(LIBNAME).$(PNGVER).$(SHAREDLIB_POSTFIX) \
107 libpng.pc libpng.3.$(PNGMIN).$(SHAREDLIB_POSTFIX)
108 -@if [ ! -d $(DL) ]; then mkdir $(DL); fi
110 $(DL)/$(LIBNAME).$(PNGVER)*.$(SHAREDLIB_POSTFIX)
111 -@/bin/rm -f $(DL)/$(LIBNAME).$(SHAREDLIB_POSTFIX)
112 # -@/bin/rm -f libpng.$(SHAREDLIB_POSTFIX)
113 # -@/bin/rm -f libpng.3.$(SHAREDLIB_POSTFIX)
114 # -@/bin/rm -f libpng.3.$(PNGMIN)*.$(SHAREDLIB_POSTFIX)
115 cp libpng.3.$(PNGMIN).$(SHAREDLIB_POSTFIX) $(DL)
116 cp $(LIBNAME).$(PNGVER).$(SHAREDLIB_POSTFIX) $(DL)
117 chmod 755 $(DL)/$(LIBNAME).$(PNGVER).$(SHAREDLIB_POSTFIX)
118 chmod 755 $(DL)/libpng.3.$(PNGMIN).$(SHAREDLIB_POSTFIX)
120 ln -f -s libpng.3.$(PNGMIN).$(SHAREDLIB_POSTFIX) \
121 libpng.3.$(SHAREDLIB_POSTFIX); \
122 ln -f -s libpng.3.$(SHAREDLIB_POSTFIX) libpng.$(SHAREDLIB_POSTFIX); \
123 ln -f -s $(LIBNAME).$(PNGVER).$(SHAREDLIB_POSTFIX) \
124 libpng.$(SHAREDLIB_POSTFIX); \
125 ln -f -s libpng.3.$(PNGMIN).$(SHAREDLIB_POSTFIX) \
126 libpng.3.$(SHAREDLIB_POSTFIX); \
127 ln -f -s $(LIBNAME).$(PNGVER).$(SHAREDLIB_POSTFIX) \
128 $(LIBNAME).$(PNGMAJ).$(SHAREDLIB_POSTFIX); \
129 ln -f -s $(LIBNAME).$(PNGMAJ).$(SHAREDLIB_POSTFIX) \
130 $(LIBNAME).$(SHAREDLIB_POSTFIX))
131 -@if [ ! -d $(DL)/pkgconfig ]; then mkdir $(DL)/pkgconfig; fi
132 -@/bin/rm -f $(DL)/pkgconfig/$(LIBNAME).pc
133 -@/bin/rm -f $(DL)/pkgconfig/libpng.pc
134 cp libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc
135 chmod 644 $(DL)/pkgconfig/$(LIBNAME).pc
136 (cd $(DL)/pkgconfig; ln -f -s $(LIBNAME).pc libpng.pc)
138 install-man: libpng.3 libpngpf.3 png.5
139 -@if [ ! -d $(DM) ]; then mkdir $(DM); fi
140 -@if [ ! -d $(DM)/man3 ]; then mkdir $(DM)/man3; fi
141 -@/bin/rm -f $(DM)/man3/libpng.3
142 -@/bin/rm -f $(DM)/man3/libpngpf.3
143 cp libpng.3 $(DM)/man3
144 cp libpngpf.3 $(DM)/man3
145 -@if [ ! -d $(DM)/man5 ]; then mkdir $(DM)/man5; fi
146 -@/bin/rm -f $(DM)/man5/png.5
149 install-config: libpng-config
150 -@if [ ! -d $(DB) ]; then mkdir $(DB); fi
151 -@/bin/rm -f $(DB)/libpng-config
152 -@/bin/rm -f $(DB)/$(LIBNAME)-config
153 cp libpng-config $(DB)/$(LIBNAME)-config
154 chmod 755 $(DB)/$(LIBNAME)-config
155 (cd $(DB); ln -sf $(LIBNAME)-config libpng-config)
157 install: install-static install-shared install-man install-config
159 # If you installed in $(DESTDIR), test-installed won't work until you
160 # move the library to its final location.
164 `$(BINPATH)/libpng12-config --cflags` pngtest.c \
166 -o pngtesti `$(BINPATH)/libpng12-config --ldflags`
167 ./pngtesti pngtest.png
170 rm -f *.o libpng.a pngtest pngout.png libpng-config \
171 $(LIBNAME).$(PNGVER).$(SHAREDLIB_POSTFIX) \
172 $(LIBNAME).$(SHAREDLIB_POSTFIX) \
173 libpng.3.$(PNGMIN).$(SHAREDLIB_POSTFIX) \
176 DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO
178 chmod a-w *.[ch35] $(DOCS) scripts/*
180 # DO NOT DELETE THIS LINE -- make depend depends on it.
182 png.o: png.h pngconf.h
183 pngerror.o: png.h pngconf.h
184 pngrio.o: png.h pngconf.h
185 pngwio.o: png.h pngconf.h
186 pngmem.o: png.h pngconf.h
187 pngset.o: png.h pngconf.h
188 pngget.o: png.h pngconf.h
189 pngread.o: png.h pngconf.h
190 pngrtran.o: png.h pngconf.h
191 pngrutil.o: png.h pngconf.h
192 pngtest.o: png.h pngconf.h
193 pngtrans.o: png.h pngconf.h
194 pngwrite.o: png.h pngconf.h
195 pngwtran.o: png.h pngconf.h
196 pngwutil.o: png.h pngconf.h
197 pngpread.o: png.h pngconf.h