makefile.darwin 6.9 KB
Newer Older
1
# makefile for libpng on Darwin / Mac OS X
2
# Copyright (C) 2002, 2004, 2006, 2008 Glenn Randers-Pehrson
3 4 5 6
# Copyright (C) 2001 Christoph Pfisterer
# derived from makefile.linux:
#  Copyright (C) 1998, 1999 Greg Roelofs
#  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, libpng14.dylib, png.h and pngconf.h
13
prefix=/usr/local
14
exec_prefix=$(prefix)
15 16 17 18 19 20 21

# Where the zlib library and include files are located
#ZLIBLIB=/usr/local/lib
#ZLIBINC=/usr/local/include
ZLIBLIB=../zlib
ZLIBINC=../zlib

22
# Library name:
23
LIBNAME = libpng14
24
PNGMAJ = 14
25
PNGMIN = 1.4.0beta95
26 27 28 29 30 31 32
PNGVER = $(PNGMAJ).$(PNGMIN)

# Shared library names:
LIBSO=$(LIBNAME).dylib
LIBSOMAJ=$(LIBNAME).$(PNGMAJ).dylib
LIBSOVER=$(LIBNAME).$(PNGVER).dylib
OLDSO=libpng.dylib
33 34
OLDSOMAJ=libpng.14.dylib
OLDSOVER=libpng.14.$(PNGMIN).dylib
35 36

# Utilities:
37
CC=cc
38
AR_RC=ar rc
39
MKDIR_P=mkdir -p
40 41 42 43
LN_SF=ln -sf
RANLIB=ranlib
RM_F=/bin/rm -f

44 45
# CFLAGS=--DPNG_CONFIGURE_LIBPNG I$(ZLIBINC) -W -Wall -O3 -funroll-loops
CFLAGS=-DPNG_CONFIGURE_LIBPNG -I$(ZLIBINC) -W -Wall -O -funroll-loops
46
LDFLAGS=-L. -L$(ZLIBLIB) -lpng14 -lz
47

48
INCPATH=$(prefix)/include
49
LIBPATH=$(exec_prefix)/lib
50
MANPATH=$(prefix)/man
51
BINPATH=$(exec_prefix)/bin
52 53 54 55 56 57 58

# override DESTDIR= on the make install command line to easily support
# installing into a temporary location.  Example:
#
#    make install DESTDIR=/tmp/build/libpng
#
# If you're going to install into a temporary location
59
# via DESTDIR, $(DESTDIR)$(prefix) must already exist before
60 61
# you execute make install.
DESTDIR=
62

63 64 65 66
DB=$(DESTDIR)$(BINPATH)
DI=$(DESTDIR)$(INCPATH)
DL=$(DESTDIR)$(LIBPATH)
DM=$(DESTDIR)$(MANPATH)
67

68 69 70 71 72 73 74 75 76 77 78
OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \
	pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \
	pngwtran.o pngmem.o pngerror.o pngpread.o

OBJSDLL = $(OBJS:.o=.pic.o)

.SUFFIXES:      .c .o .pic.o

.c.pic.o:
	$(CC) -c $(CFLAGS) -fno-common -o $@ $*.c

79
all: libpng.a $(LIBSO) pngtest libpng.pc libpng-config
80 81

libpng.a: $(OBJS)
82
	$(AR_RC) $@ $(OBJS)
83 84
	$(RANLIB) $@

85
libpng.pc:
86 87 88 89 90
	cat scripts/libpng.pc.in | sed -e s!@prefix@!$(prefix)! \
	-e s!@exec_prefix@!$(exec_prefix)! \
	-e s!@libdir@!$(LIBPATH)! \
	-e s!@includedir@!$(INCPATH)! \
	-e s!-lpng14!-lpng14\ -lz! > libpng.pc
91 92 93 94

libpng-config:
	( cat scripts/libpng-config-head.in; \
	echo prefix=\"$(prefix)\"; \
95 96
	echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \
	echo L_opts=\"-L$(LIBPATH)\"; \
97
	echo libs=\"-lpng14 -lz\"; \
98 99
	cat scripts/libpng-config-body.in ) > libpng-config
	chmod +x libpng-config
100

101 102
$(LIBSO): $(LIBSOMAJ)
	$(LN_SF) $(LIBSOMAJ) $(LIBSO)
103

104 105
$(LIBSOMAJ): $(LIBSOVER)
	$(LN_SF) $(LIBSOVER) $(LIBSOMAJ)
106

107
$(LIBSOVER): $(OBJSDLL)
108
	$(CC) -dynamiclib \
109
	 -install_name $(LIBPATH)/$(LIBSOMAJ) \
110
	 -current_version 14 -compatibility_version 14 \
111
	 -o $(LIBSOVER) \
112
	 $(OBJSDLL) -L$(ZLIBLIB) -lz
113

114 115 116
$(OLDSOVER): $(OBJSDLL)
	$(CC) -dynamiclib \
	 -install_name $(LIBPATH)/$(OLDSOMAJ) \
117
	 -current_version 14 -compatibility_version 14 \
118 119 120
	 -o $(OLDSOVER) \
	 $(OBJSDLL) -L$(ZLIBLIB) -lz

121
pngtest: pngtest.o $(LIBSO)
122 123 124 125 126
	$(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS)

test: pngtest
	./pngtest

127
install-headers: png.h pngconf.h
128 129
	-@if [ ! -d $(DI) ]; then $(MKDIR_P) $(DI); fi
	-@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 134
	-@$(RM_F) $(DI)/libpng
	(cd $(DI); $(LN_SF) $(LIBNAME) libpng; $(LN_SF) $(LIBNAME)/* .)
135 136

install-static: install-headers libpng.a
137
	-@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi
138 139
	cp libpng.a $(DL)/$(LIBNAME).a
	chmod 644 $(DL)/$(LIBNAME).a
140
	$(RANLIB) $(DL)/$(LIBNAME).a
141 142
	-@$(RM_F) $(DL)/libpng.a
	(cd $(DL); $(LN_SF) $(LIBNAME).a libpng.a)
143

144 145
install-shared: install-headers $(LIBSO) libpng.pc \
	$(OLDSOVER)
146
	-@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi
147 148
	-@$(RM_F) $(DL)/$(LIBNAME).$(PNGVER)*.dylib
	-@$(RM_F) $(DL)/$(LIBNAME).$(PNGMAJ)*.dylib
149 150
	-@$(RM_F) $(DL)/$(LIBSO)
	-@$(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 159
	$(LN_SF) $(OLDSOVER) $(OLDSOMAJ); \
	$(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 164
	-@$(RM_F) $(DL)/pkgconfig/$(LIBNAME).pc
	-@$(RM_F) $(DL)/pkgconfig/libpng.pc
165 166
	cp libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc
	chmod 644 $(DL)/pkgconfig/$(LIBNAME).pc
167
	(cd $(DL)/pkgconfig; $(LN_SF) $(LIBNAME).pc libpng.pc)
168 169

install-man: libpng.3 libpngpf.3 png.5
170 171
	-@if [ ! -d $(DM) ]; then $(MKDIR_P) $(DM); fi
	-@if [ ! -d $(DM)/man3 ]; then $(MKDIR_P) $(DM)/man3; fi
172 173
	-@$(RM_F) $(DM)/man3/libpng.3
	-@$(RM_F) $(DM)/man3/libpngpf.3
174 175
	cp libpng.3 $(DM)/man3
	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

180
install-config: libpng-config
181
	-@if [ ! -d $(DB) ]; then $(MKDIR_P) $(DB); fi
182 183
	-@$(RM_F) $(DB)/libpng-config
	-@$(RM_F) $(DB)/$(LIBNAME)-config
184 185
	cp libpng-config $(DB)/$(LIBNAME)-config
	chmod 755 $(DB)/$(LIBNAME)-config
186
	(cd $(DB); $(LN_SF) $(LIBNAME)-config libpng-config)
187 188

install: install-static install-shared install-man install-config
189

190
# If you installed in $(DESTDIR), test-installed won't work until you
191 192 193 194 195 196 197
# move the library to its final location.  Use test-dd to test it
# before then.

test-dd:
	echo
	echo Testing installed dynamic shared library in $(DL).
	$(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 203 204

test-installed:
	$(CC) $(CFLAGS) \
205
	   `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \
206
	   -L$(ZLIBLIB) \
207
	   -o pngtesti `$(BINPATH)/$(LIBNAME)-config --ldflags`
208
	./pngtesti pngtest.png
209

210
clean:
211
	$(RM_F) *.o libpng.a pngtest pngout.png libpng-config \
212 213
	$(OLDSOVER) \
	libpng.pc $(LIBNAME).*dylib pngtesti
214 215 216 217 218 219 220

DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO
writelock:
	chmod a-w *.[ch35] $(DOCS) scripts/*

# DO NOT DELETE THIS LINE -- make depend depends on it.

221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236
png.o png.pic.o: png.h pngconf.h pngpriv.h
pngerror.o pngerror.pic.o: png.h pngconf.h pngpriv.h
pngrio.o pngrio.pic.o: png.h pngconf.h pngpriv.h
pngwio.o pngwio.pic.o: png.h pngconf.h pngpriv.h
pngmem.o pngmem.pic.o: png.h pngconf.h pngpriv.h
pngset.o pngset.pic.o: png.h pngconf.h pngpriv.h
pngget.o pngget.pic.o: png.h pngconf.h pngpriv.h
pngread.o pngread.pic.o: png.h pngconf.h pngpriv.h
pngrtran.o pngrtran.pic.o: png.h pngconf.h pngpriv.h
pngrutil.o pngrutil.pic.o: png.h pngconf.h pngpriv.h
pngtrans.o pngtrans.pic.o: png.h pngconf.h pngpriv.h
pngwrite.o pngwrite.pic.o: png.h pngconf.h pngpriv.h
pngwtran.o pngwtran.pic.o: png.h pngconf.h pngpriv.h
pngwutil.o pngwutil.pic.o: png.h pngconf.h pngpriv.h
pngpread.o pngpread.pic.o: png.h pngconf.h pngpriv.h

237
pngtest.o: png.h pngconf.h