blob: 05388ceca2cae17a910880722397d18da3a6785b [file] [log] [blame]
Glenn Randers-Pehrson5a0be342001-10-18 20:55:13 -05001# makefile for libpng on Darwin / Mac OS X
Glenn Randers-Pehrson9c0f0942002-02-21 23:14:23 -06002# Copyright (C) 2002 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-Pehrson9c0f0942002-02-21 23:14:23 -06009# where "make install" puts libpng.a, libpng12.dylib, png.h and pngconf.h
Glenn Randers-Pehrson5a0be342001-10-18 20:55:13 -050010prefix=/usr/local
11
12# Where the zlib library and include files are located
13#ZLIBLIB=/usr/local/lib
14#ZLIBINC=/usr/local/include
15ZLIBLIB=../zlib
16ZLIBINC=../zlib
17
18CC=cc
19CFLAGS=-I$(ZLIBINC) -Wall -O3 -funroll-loops
Glenn Randers-Pehrsoncfbed9b2002-05-21 18:06:08 -050020LDFLAGS=-L. -L$(ZLIBLIB) -lpng12 -lz
Glenn Randers-Pehrson5a0be342001-10-18 20:55:13 -050021
22#RANLIB=echo
23RANLIB=ranlib
24
Glenn Randers-Pehrson9c0f0942002-02-21 23:14:23 -060025PNGMAJ = 0
Glenn Randers-Pehrsoncfbed9b2002-05-21 18:06:08 -050026PNGMIN = 1.2.3
Glenn Randers-Pehrson5a0be342001-10-18 20:55:13 -050027PNGVER = $(PNGMAJ).$(PNGMIN)
Glenn Randers-Pehrson9c0f0942002-02-21 23:14:23 -060028LIBNAME = libpng12
Glenn Randers-Pehrson5a0be342001-10-18 20:55:13 -050029
30INCPATH=$(prefix)/include
31LIBPATH=$(prefix)/lib
Glenn Randers-Pehrson03008a02002-04-27 10:11:25 -050032MANPATH=$(prefix)/man
Glenn Randers-Pehrson704228f2002-05-02 20:49:40 -050033BINPATH=$(prefix)/bin
Glenn Randers-Pehrson03008a02002-04-27 10:11:25 -050034
35# override DESTDIR= on the make install command line to easily support
36# installing into a temporary location. Example:
37#
38# make install DESTDIR=/tmp/build/libpng
39#
40# If you're going to install into a temporary location
41# via DESTDIR, that location must already exist before
42# you execute make install.
43DESTDIR=
Glenn Randers-Pehrson5a0be342001-10-18 20:55:13 -050044
Glenn Randers-Pehrsoncfbed9b2002-05-21 18:06:08 -050045DB=$(DESTDIR)/$(BINPATH)
46DI=$(DESTDIR)/$(INCPATH)
47DL=$(DESTDIR)/$(LIBPATH)
48DM=$(DESTDIR)/$(MANPATH)
49
Glenn Randers-Pehrson5a0be342001-10-18 20:55:13 -050050OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \
51 pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \
52 pngwtran.o pngmem.o pngerror.o pngpread.o
53
54OBJSDLL = $(OBJS:.o=.pic.o)
55
56.SUFFIXES: .c .o .pic.o
57
58.c.pic.o:
59 $(CC) -c $(CFLAGS) -fno-common -o $@ $*.c
60
Glenn Randers-Pehrson837a3d12002-05-10 20:19:58 -050061all: libpng.a $(LIBNAME).dylib pngtest
Glenn Randers-Pehrson5a0be342001-10-18 20:55:13 -050062
63libpng.a: $(OBJS)
64 ar rc $@ $(OBJS)
65 $(RANLIB) $@
66
Glenn Randers-Pehrson03008a02002-04-27 10:11:25 -050067libpng.pc:
Glenn Randers-Pehrson837a3d12002-05-10 20:19:58 -050068 cat scripts/libpng.pc.in | sed -e s\!@PREFIX@!$(prefix)! | \
69 sed -e s/-lm// > libpng.pc
70
71libpng-config:
72 ( cat scripts/libpng-config-head.in; \
73 echo prefix=\"$(prefix)\"; \
Glenn Randers-Pehrson22f28962002-05-13 18:17:09 -050074 echo cppflags=\"-I$(INCPATH)/$(LIBNAME)\"; \
Glenn Randers-Pehrson837a3d12002-05-10 20:19:58 -050075 echo cflags=\"\"; \
76 echo ldflags=\"-L$(LIBPATH)\"; \
77 echo libs=\"-lpng12 -lz\"; \
78 cat scripts/libpng-config-body.in ) > libpng-config
79 chmod +x libpng-config
Glenn Randers-Pehrson03008a02002-04-27 10:11:25 -050080
Glenn Randers-Pehrson9c0f0942002-02-21 23:14:23 -060081$(LIBNAME).dylib: $(LIBNAME).$(PNGMAJ).dylib
82 ln -sf $(LIBNAME).$(PNGMAJ).dylib $(LIBNAME).dylib
Glenn Randers-Pehrson5a0be342001-10-18 20:55:13 -050083
Glenn Randers-Pehrson9c0f0942002-02-21 23:14:23 -060084$(LIBNAME).$(PNGMAJ).dylib: $(LIBNAME).$(PNGVER).dylib
85 ln -sf $(LIBNAME).$(PNGVER).dylib $(LIBNAME).$(PNGMAJ).dylib
Glenn Randers-Pehrson5a0be342001-10-18 20:55:13 -050086
Glenn Randers-Pehrson9c0f0942002-02-21 23:14:23 -060087$(LIBNAME).$(PNGVER).dylib: $(OBJSDLL)
88 $(CC) -dynamiclib \
Glenn Randers-Pehrsoncfbed9b2002-05-21 18:06:08 -050089 -install_name $(DL)/$(LIBNAME).$(PNGMAJ).dylib \
Glenn Randers-Pehrson5a0be342001-10-18 20:55:13 -050090 -current_version $(PNGMIN) -compatibility_version $(PNGMIN) \
Glenn Randers-Pehrson9c0f0942002-02-21 23:14:23 -060091 -o $(LIBNAME).$(PNGVER).dylib \
Glenn Randers-Pehrson5a0be342001-10-18 20:55:13 -050092 $(OBJSDLL) -L$(ZLIBLIB) -lz
93
Glenn Randers-Pehrson9c0f0942002-02-21 23:14:23 -060094pngtest: pngtest.o $(LIBNAME).dylib
Glenn Randers-Pehrson5a0be342001-10-18 20:55:13 -050095 $(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS)
96
97test: pngtest
98 ./pngtest
99
Glenn Randers-Pehrsonc1bfe682002-03-06 22:08:00 -0600100install-headers: png.h pngconf.h
Glenn Randers-Pehrsoncfbed9b2002-05-21 18:06:08 -0500101 -@if [ ! -d $(DI) ]; then mkdir $(DI); fi
102 -@if [ ! -d $(DI)/$(LIBNAME) ]; then mkdir $(DI)/$(LIBNAME); fi
103 cp png.h pngconf.h $(DI)/$(LIBNAME)
104 chmod 644 $(DI)/$(LIBNAME)/png.h \
105 $(DI)/$(LIBNAME)/pngconf.h
106 -@/bin/rm -f $(DI)/png.h $(DI)/pngconf.h
107 -@/bin/rm -f $(DI)/libpng
108 (cd $(DI); ln -sf $(LIBNAME) libpng; ln -sf $(LIBNAME)/* .)
Glenn Randers-Pehrsonc1bfe682002-03-06 22:08:00 -0600109
110install-static: install-headers libpng.a
Glenn Randers-Pehrsoncfbed9b2002-05-21 18:06:08 -0500111 -@if [ ! -d $(DL) ]; then mkdir $(DL); fi
112 cp libpng.a $(DL)/$(LIBNAME).a
113 chmod 644 $(DL)/$(LIBNAME).a
114 -@/bin/rm -f $(DL)/libpng.a
115 (cd $(DL); ln -sf $(LIBNAME).a libpng.a)
Glenn Randers-Pehrsonc1bfe682002-03-06 22:08:00 -0600116
Glenn Randers-Pehrson25d82242002-05-01 11:51:26 -0500117install-shared: install-headers $(LIBNAME).dylib libpng.pc
Glenn Randers-Pehrsoncfbed9b2002-05-21 18:06:08 -0500118 -@if [ ! -d $(DL) ]; then mkdir $(DL); fi
119 -@/bin/rm -f $(DL)/$(LIBNAME).$(PNGMAJ)*.dylib
120 -@/bin/rm -f $(DL)/$(LIBNAME).dylib
121 -@/bin/rm -f $(DL)/libpng.dylib
122 -@/bin/rm -f $(DL)/libpng.3.dylib
123 -@/bin/rm -f $(DL)/libpng.3.*.dylib
124 cp $(LIBNAME).$(PNGVER).dylib $(DL)
125 chmod 755 $(DL)/$(LIBNAME).$(PNGVER).dylib
126 (cd $(DL); \
Glenn Randers-Pehrson73d57cb2002-03-25 18:49:08 -0600127 ln -sf $(LIBNAME).$(PNGVER).dylib libpng.dylib; \
128 ln -sf $(LIBNAME).$(PNGVER).dylib libpng.3.dylib; \
129 ln -sf $(LIBNAME).$(PNGVER).dylib libpng.3.$(PNGMIN).dylib; \
Glenn Randers-Pehrson9c0f0942002-02-21 23:14:23 -0600130 ln -sf $(LIBNAME).$(PNGVER).dylib $(LIBNAME).$(PNGMAJ).dylib; \
131 ln -sf $(LIBNAME).$(PNGMAJ).dylib $(LIBNAME).dylib)
Glenn Randers-Pehrsoncfbed9b2002-05-21 18:06:08 -0500132 -@if [ ! -d $(DL)/pkgconfig ]; then mkdir $(DL)/pkgconfig; fi
133 -@/bin/rm -f $(DL)/pkgconfig/$(LIBNAME).pc
134 -@/bin/rm -f $(DL)/pkgconfig/libpng.pc
135 cp libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc
136 chmod 644 $(DL)/pkgconfig/$(LIBNAME).pc
137 (cd $(DL)/pkgconfig; ln -sf $(LIBNAME).pc libpng.pc)
Glenn Randers-Pehrsonc1bfe682002-03-06 22:08:00 -0600138
Glenn Randers-Pehrson03008a02002-04-27 10:11:25 -0500139install-man: libpng.3 libpngpf.3 png.5
Glenn Randers-Pehrsoncfbed9b2002-05-21 18:06:08 -0500140 -@if [ ! -d $(DM) ]; then mkdir $(DM); fi
141 -@if [ ! -d $(DM)/man3 ]; then mkdir $(DM)/man3; fi
142 -@/bin/rm -f $(DM)/man3/libpng.3
143 -@/bin/rm -f $(DM)/man3/libpngpf.3
144 cp libpng.3 $(DM)/man3
145 cp libpngpf.3 $(DM)/man3
146 -@if [ ! -d $(DM)/man5 ]; then mkdir $(DM)/man5; fi
147 -@/bin/rm -f $(DM)/man5/png.5
148 cp png.5 $(DM)/man5
Glenn Randers-Pehrson03008a02002-04-27 10:11:25 -0500149
Glenn Randers-Pehrson837a3d12002-05-10 20:19:58 -0500150install-config: libpng-config
Glenn Randers-Pehrsoncfbed9b2002-05-21 18:06:08 -0500151 -@if [ ! -d $(DB) ]; then mkdir $(DB); fi
152 -@/bin/rm -f $(DB)/libpng-config
153 -@/bin/rm -f $(DB)/$(LIBNAME)-config
154 cp libpng-config $(DB)/$(LIBNAME)-config
155 chmod 755 $(DB)/$(LIBNAME)-config
156 (cd $(DB); ln -sf $(LIBNAME)-config libpng-config)
Glenn Randers-Pehrson704228f2002-05-02 20:49:40 -0500157
158install: install-static install-shared install-man install-config
Glenn Randers-Pehrson5a0be342001-10-18 20:55:13 -0500159
160clean:
Glenn Randers-Pehrson9c0f0942002-02-21 23:14:23 -0600161 rm -f *.o libpng.a $(LIBNAME).*dylib pngtest pngout.png
Glenn Randers-Pehrson5a0be342001-10-18 20:55:13 -0500162
163DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO
164writelock:
165 chmod a-w *.[ch35] $(DOCS) scripts/*
166
167# DO NOT DELETE THIS LINE -- make depend depends on it.
168
169png.o png.pic.o: png.h pngconf.h
170pngerror.o pngerror.pic.o: png.h pngconf.h
171pngrio.o pngrio.pic.o: png.h pngconf.h
172pngwio.o pngwio.pic.o: png.h pngconf.h
173pngmem.o pngmem.pic.o: png.h pngconf.h
174pngset.o pngset.pic.o: png.h pngconf.h
175pngget.o pngget.pic.o: png.h pngconf.h
176pngread.o pngread.pic.o: png.h pngconf.h
177pngrtran.o pngrtran.pic.o: png.h pngconf.h
178pngrutil.o pngrutil.pic.o: png.h pngconf.h
179pngtrans.o pngtrans.pic.o: png.h pngconf.h
180pngwrite.o pngwrite.pic.o: png.h pngconf.h
181pngwtran.o pngwtran.pic.o: png.h pngconf.h
182pngwutil.o pngwutil.pic.o: png.h pngconf.h
183pngpread.o pngpread.pic.o: png.h pngconf.h
184
185pngtest.o: png.h pngconf.h