1# makefile for libpng on DEC Alpha Unix
2# Copyright (C) 2000-2002, 2006 Glenn Randers-Pehrson
3# Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc.
4#
5# This code is released under the libpng license.
6# For conditions of distribution and use, see the disclaimer
7# and license in png.h
8
9# Library name:
10PNGMAJ = 0
11PNGMIN = 1.2.46
12PNGVER = $(PNGMAJ).$(PNGMIN)
13LIBNAME = libpng12
14
15# Shared library names:
16LIBSO=$(LIBNAME).so
17LIBSOMAJ=$(LIBNAME).so.$(PNGMAJ)
18LIBSOVER=$(LIBNAME).so.$(PNGVER)
19OLDSO=libpng.so
20OLDSOMAJ=libpng.so.3
21OLDSOVER=libpng.so.3.$(PNGMIN)
22
23# Utilities:
24AR_RC=ar rc
25CC=cc
26MKDIR_P=mkdir
27LN_SF=ln -f -s
28RANLIB=ranlib
29RM_F=/bin/rm -f
30
31# where make install puts libpng.a and png.h
32prefix=/usr/local
33exec_prefix=$(prefix)
34INCPATH=$(prefix)/include
35LIBPATH=$(exec_prefix)/lib
36MANPATH=$(prefix)/man
37BINPATH=$(exec_prefix)/bin
38
39# override DESTDIR= on the make install command line to easily support
40# installing into a temporary location.  Example:
41#
42#    make install DESTDIR=/tmp/build/libpng
43#
44# If you're going to install into a temporary location
45# via DESTDIR, $(DESTDIR)$(prefix) must already exist before
46# you execute make install.
47DESTDIR=
48
49DB=$(DESTDIR)$(BINPATH)
50DI=$(DESTDIR)$(INCPATH)
51DL=$(DESTDIR)$(LIBPATH)
52DM=$(DESTDIR)$(MANPATH)
53
54# Where the zlib library and include files are located
55#ZLIBLIB=/usr/local/lib
56#ZLIBINC=/usr/local/include
57ZLIBLIB=../zlib
58ZLIBINC=../zlib
59
60CFLAGS=-std -w1 -I$(ZLIBINC) -O # -g -DPNG_DEBUG=1
61LDFLAGS=-L$(ZLIBLIB) -rpath $(ZLIBLIB) libpng.a -lz -lm
62
63OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \
64	pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \
65	pngwtran.o pngmem.o pngerror.o pngpread.o
66
67all: $(LIBSO) libpng.a pngtest libpng.pc libpng-config
68
69libpng.a: $(OBJS)
70	$(AR_RC) $@  $(OBJS)
71	$(RANLIB) $@
72
73libpng.pc:
74	cat scripts/libpng.pc.in | sed -e s!@prefix@!$(prefix)! \
75	-e s!@exec_prefix@!$(exec_prefix)! \
76	-e s!@libdir@!$(LIBPATH)! \
77	-e s!@includedir@!$(INCPATH)! \
78	-e s!-lpng12!-lpng12\ -lz\ -lm! > libpng.pc
79
80libpng-config:
81	( cat scripts/libpng-config-head.in; \
82	echo prefix=\"$(prefix)\"; \
83	echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \
84	echo ccopts=\"-std\"; \
85	echo L_opts=\"-L$(LIBPATH)\"; \
86	echo libs=\"-lpng12 -lz -lm\"; \
87	cat scripts/libpng-config-body.in ) > libpng-config
88	chmod +x libpng-config
89
90$(LIBSO): $(LIBSOMAJ)
91	$(LN_SF) $(LIBSOMAJ) $(LIBSO)
92
93$(LIBSOMAJ): $(LIBSOVER)
94	$(LN_SF) $(LIBSOVER) $(LIBSOMAJ)
95
96$(LIBSOVER): $(OBJS)
97	$(CC) -shared -o $@ $(OBJS) -L$(ZLIBLIB) \
98	-soname $(LIBSOMAJ)
99
100$(OLDSOVER): $(OBJS)
101	$(CC) -shared -o $@ $(OBJS) -L$(ZLIBLIB) \
102	-soname $(OLDSOMAJ)
103
104pngtest: pngtest.o libpng.a
105	$(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS)
106
107test: pngtest
108	./pngtest
109
110install-headers: png.h pngconf.h
111	-@if [ ! -d $(DI) ]; then $(MKDIR_P) $(DI); fi
112	-@if [ ! -d $(DI)/$(LIBNAME) ]; then $(MKDIR_P) $(DI)/$(LIBNAME); fi
113	cp png.h pngconf.h $(DI)/$(LIBNAME)
114	chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h
115	-@/bin/rm -f $(DI)/png.h $(DI)/pngconf.h
116	-@/bin/rm -f $(DI)/libpng
117	(cd $(DI); $(LN_SF)(LIBNAME) libpng; $(LN_SF)(LIBNAME)/* .)
118
119install-static: install-headers libpng.a
120	-@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi
121	cp libpng.a $(DL)/$(LIBNAME).a
122	chmod 644 $(DL)/$(LIBNAME).a
123	-@/bin/rm -f $(DL)/libpng.a
124	(cd $(DL); $(LN_SF)(LIBNAME).a libpng.a)
125
126install-shared: install-headers $(LIBSOVER) libpng.pc \
127	$(OLDSOVER)
128	-@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi
129	-@/bin/rm -f $(DL)/$(LIBSOVER)* $(DL)/$(LIBSO)
130	-@/bin/rm -f $(DL)/$(LIBSOMAJ)
131	-@/bin/rm -f $(DL)/$(OLDSO)
132	-@/bin/rm -f $(DL)/$(OLDSOMAJ)
133	-@/bin/rm -f $(DL)/$(OLDSOVER)*
134	cp $(LIBSOVER) $(DL)
135	cp $(OLDSOVER) $(DL)
136	chmod 755 $(DL)/$(LIBSOVER)
137	chmod 755 $(DL)/$(OLDSOVER)
138	(cd $(DL); \
139	$(LN_SF) $(OLDSOVER) $(OLDSOMAJ); \
140	$(LN_SF) $(OLDSOMAJ) $(OLDSO); \
141	$(LN_SF)(LIBSOVER) $(LIBSOMAJ); \
142	$(LN_SF)(LIBSOMAJ) $(LIBSO))
143	-@if [ ! -d $(DL)/pkgconfig ]; then $(MKDIR_P) $(DL)/pkgconfig; fi
144	-@/bin/rm -f $(DL)/pkgconfig/$(LIBNAME).pc
145	-@/bin/rm -f $(DL)/pkgconfig/libpng.pc
146	cp libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc
147	chmod 644 $(DL)/pkgconfig/$(LIBNAME).pc
148	(cd $(DL)/pkgconfig; $(LN_SF)(LIBNAME).pc libpng.pc)
149
150install-man: libpng.3 libpngpf.3 png.5
151	-@if [ ! -d $(DM) ]; then $(MKDIR_P) $(DM); fi
152	-@if [ ! -d $(DM)/man3 ]; then $(MKDIR_P) $(DM)/man3; fi
153	-@/bin/rm -f $(DM)/man3/libpng.3
154	-@/bin/rm -f $(DM)/man3/libpngpf.3
155	cp libpng.3 $(DM)/man3
156	cp libpngpf.3 $(DM)/man3
157	-@if [ ! -d $(DM)/man5 ]; then $(MKDIR_P) $(DM)/man5; fi
158	-@/bin/rm -f $(DM)/man5/png.5
159	cp png.5 $(DM)/man5
160
161install-config: libpng-config
162	-@if [ ! -d $(DB) ]; then $(MKDIR_P) $(DB); fi
163	-@/bin/rm -f $(DB)/libpng-config
164	-@/bin/rm -f $(DB)/$(LIBNAME)-config
165	cp libpng-config $(DB)/$(LIBNAME)-config
166	chmod 755 $(DB)/$(LIBNAME)-config
167	(cd $(DB); $(LN_SF)(LIBNAME)-config libpng-config)
168
169install: install-static install-shared install-man install-config
170
171# If you installed in $(DESTDIR), test-installed won't work until you
172# move the library to its final location.  Use test-dd to test it
173# before then.
174
175test-dd:
176	echo
177	echo Testing installed dynamic shared library in $(DL).
178	$(CC) -w1 -I$(DI) -I$(ZLIBINC) \
179	   `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \
180	   -L$(DL) -L$(ZLIBLIB)  -R$(ZLIBLIB) -R$(DL) \
181	   -o pngtestd `$(BINPATH)/$(LIBNAME)-config --ldflags`
182	./pngtestd pngtest.png
183
184test-installed:
185	echo
186	echo Testing installed dynamic shared library.
187	$(CC) -w1 -I$(ZLIBINC) \
188	   `$(BINPATH)/$(LIBNAME)-config --cflags` pngtest.c \
189	   -L$(ZLIBLIB) -R$(ZLIBLIB) \
190	   -o pngtesti `$(BINPATH)/$(LIBNAME)-config --ldflags`
191	./pngtesti pngtest.png
192
193clean:
194	/bin/rm -f *.o libpng.a pngtest pngtesti pngout.png \
195	libpng-config $(LIBSO) $(LIBSOMAJ)* \
196	$(OLDSOVER) \
197	libpng.pc
198
199# DO NOT DELETE THIS LINE -- make depend depends on it.
200
201png.o: png.h pngconf.h
202pngerror.o: png.h pngconf.h
203pngrio.o: png.h pngconf.h
204pngwio.o: png.h pngconf.h
205pngmem.o: png.h pngconf.h
206pngset.o: png.h pngconf.h
207pngget.o: png.h pngconf.h
208pngread.o: png.h pngconf.h
209pngrtran.o: png.h pngconf.h
210pngrutil.o: png.h pngconf.h
211pngtrans.o: png.h pngconf.h
212pngwrite.o: png.h pngconf.h
213pngwtran.o: png.h pngconf.h
214pngwutil.o: png.h pngconf.h
215pngpread.o: png.h pngconf.h
216
217pngtest.o: png.h pngconf.h
218