1# makefile for libpng, HPUX (10.20 and 11.00) using the ANSI/C product.
2# Copyright (C) 1999-2002 Glenn Randers-Pehrson
3# Copyright (C) 1995 Guy Eric Schalnat, Group 42
4# contributed by Jim Rice and updated by Chris Schleicher, Hewlett Packard
5# For conditions of distribution and use, see copyright notice in png.h
6
7# Where the zlib library and include files are located
8ZLIBLIB=/opt/zlib/lib
9ZLIBINC=/opt/zlib/include
10
11# Note that if you plan to build a libpng shared library, zlib must also
12# be a shared library, which zlib's configure does not do.  After running
13# zlib's configure, edit the appropriate lines of makefile to read:
14#   CFLAGS=-O1 -DHAVE_UNISTD -DUSE_MAP -fPIC \
15#   LDSHARED=ld -b
16#   SHAREDLIB=libz.sl
17
18CC=cc
19CFLAGS=-I$(ZLIBINC) -O -Ae -Wl,+vnocompatwarnings +DD64 \
20-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 +Z -DHAVE_UNISTD_H -DUSE_MMAP
21# Caution: be sure you have built zlib with the same CFLAGS.
22CCFLAGS=-I$(ZLIBINC) -O -Ae -Wl,+vnocompatwarnings +DD64 \
23-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 +Z -DHAVE_UNISTD_H -DUSE_MMAP
24
25LDFLAGS=-L. -L$(ZLIBLIB) -lpng -lz -lm
26
27RANLIB=ranlib
28
29PNGMAJ = 0
30PNGMIN = 1.2.7
31PNGVER = $(PNGMAJ).$(PNGMIN)
32LIBNAME = libpng12
33
34# where make install puts libpng.a, libpng12.sl, and png.h
35prefix=/opt/libpng
36INCPATH=$(prefix)/include
37LIBPATH=$(prefix)/lib
38MANPATH=$(prefix)/man
39BINPATH=$(prefix)/bin
40
41# override DESTDIR= on the make install command line to easily support
42# installing into a temporary location.  Example:
43#
44#    make install DESTDIR=/tmp/build/libpng
45#
46# If you're going to install into a temporary location
47# via DESTDIR, $(DESTDIR)$(prefix) must already exist before
48# you execute make install.
49DESTDIR=
50
51DB=$(DESTDIR)$(BINPATH)
52DI=$(DESTDIR)$(INCPATH)
53DL=$(DESTDIR)$(LIBPATH)
54DM=$(DESTDIR)$(MANPATH)
55
56OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \
57	pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \
58	pngwtran.o pngmem.o pngerror.o pngpread.o
59
60OBJSDLL = $(OBJS:.o=.pic.o)
61
62.SUFFIXES:	.c .o .pic.o
63
64.c.pic.o:
65	$(CC) -c $(CFLAGS) +z -o $@ $*.c
66
67all: libpng.a $(LIBNAME).sl 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)! > libpng.pc
75
76libpng-config:
77	( cat scripts/libpng-config-head.in; \
78	echo prefix=\"$(prefix)\"; \
79	echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \
80	echo ccopts=\"-Ae +DA1.1 +DS2.0\"; \
81	echo L_opts=\"-L$(LIBPATH)\"; \
82	echo libs=\"-lpng12 -lz -lm\"; \
83	cat scripts/libpng-config-body.in ) > libpng-config
84	chmod +x libpng-config
85
86$(LIBNAME).sl: $(LIBNAME).sl.$(PNGMAJ)
87	ln -sf $(LIBNAME).sl.$(PNGMAJ) $(LIBNAME).sl
88
89$(LIBNAME).sl.$(PNGMAJ): $(LIBNAME).sl.$(PNGVER)
90	ln -sf $(LIBNAME).sl.$(PNGVER) $(LIBNAME).sl.$(PNGMAJ)
91
92$(LIBNAME).sl.$(PNGVER): $(OBJSDLL)
93	$(LD) -b +s \
94	+h $(LIBNAME).sl.$(PNGMAJ) -o $(LIBNAME).sl.$(PNGVER) $(OBJSDLL)
95
96libpng.sl.3.$(PNGMIN): $(OBJSDLL)
97	$(LD) -b +s \
98	+h libpng.sl.3 -o libpng.sl.3.$(PNGMIN) $(OBJSDLL)
99
100pngtest: pngtest.o libpng.a
101	$(CC) -o pngtest $(CCFLAGS) pngtest.o $(LDFLAGS)
102
103test: pngtest
104	./pngtest
105
106install-headers: png.h pngconf.h
107	-@if [ ! -d $(DI) ]; then mkdir $(DI); fi
108	-@if [ ! -d $(DI)/$(LIBNAME) ]; then mkdir $(DI)/$(LIBNAME); fi
109	cp png.h pngconf.h $(DI)/$(LIBNAME)
110	chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h
111	-@/bin/rm -f $(DI)/png.h $(DI)/pngconf.h
112	-@/bin/rm -f $(DI)/libpng
113	(cd $(DI); ln -sf $(LIBNAME) libpng; ln -sf $(LIBNAME)/* .)
114
115install-static: install-headers libpng.a
116	-@if [ ! -d $(DL) ]; then mkdir $(DL); fi
117	cp libpng.a $(DL)/$(LIBNAME).a
118	chmod 644 $(DL)/$(LIBNAME).a
119	-@/bin/rm -f $(DL)/libpng.a
120	(cd $(DL); ln -sf $(LIBNAME).a libpng.a)
121
122install-shared: install-headers $(LIBNAME).sl.$(PNGVER) libpng.pc \
123	libpng.sl.3.$(PNGMIN)
124	-@if [ ! -d $(DL) ]; then mkdir $(DL); fi
125	-@/bin/rm -f $(DL)/$(LIBNAME).sl.$(PNGVER)* $(DL)/$(LIBNAME).sl
126	-@/bin/rm -f $(DL)/$(LIBNAME).sl.$(PNGMAJ)
127	-@/bin/rm -f $(DL)/libpng.sl
128	-@/bin/rm -f $(DL)/libpng.sl.3
129	-@/bin/rm -f $(DL)/libpng.sl.3.$(PNGMIN)*
130	cp $(LIBNAME).sl.$(PNGVER) $(DL)
131	cp libpng.sl.3.$(PNGMIN) $(DL)
132	chmod 755 $(DL)/$(LIBNAME).sl.$(PNGVER)
133	chmod 755 $(DL)/libpng.sl.3.$(PNGMIN)
134	(cd $(DL); \
135	ln -sf libpng.sl.3.$(PNGMIN) libpng.sl.3; \
136	ln -sf libpng.sl.3 libpng.sl; \
137	ln -sf $(LIBNAME).sl.$(PNGVER) $(LIBNAME).sl.$(PNGMAJ); \
138	ln -sf $(LIBNAME).sl.$(PNGMAJ) $(LIBNAME).sl)
139	-@if [ ! -d $(DL)/pkgconfig ]; then mkdir $(DL)/pkgconfig; fi
140	-@/bin/rm -f $(DL)/pkgconfig/$(LIBNAME).pc
141	-@/bin/rm -f $(DL)/pkgconfig/libpng.pc
142	cp libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc
143	chmod 644 $(DL)/pkgconfig/$(LIBNAME).pc
144	(cd $(DL)/pkgconfig; ln -sf $(LIBNAME).pc libpng.pc)
145
146install-man: libpng.3 libpngpf.3 png.5
147	-@if [ ! -d $(DM) ]; then mkdir $(DM); fi
148	-@if [ ! -d $(DM)/man3 ]; then mkdir $(DM)/man3; fi
149	-@/bin/rm -f $(DM)/man3/libpng.3
150	-@/bin/rm -f $(DM)/man3/libpngpf.3
151	cp libpng.3 $(DM)/man3
152	cp libpngpf.3 $(DM)/man3
153	-@if [ ! -d $(DM)/man5 ]; then mkdir $(DM)/man5; fi
154	-@/bin/rm -f $(DM)/man5/png.5
155	cp png.5 $(DM)/man5
156
157install-config: libpng-config
158	-@if [ ! -d $(DB) ]; then mkdir $(DB); fi
159	-@/bin/rm -f $(DB)/libpng-config
160	-@/bin/rm -f $(DB)/$(LIBNAME)-config
161	cp libpng-config $(DB)/$(LIBNAME)-config
162	chmod 755 $(DB)/$(LIBNAME)-config
163	(cd $(DB); ln -sf $(LIBNAME)-config libpng-config)
164
165install: install-static install-shared install-man install-config
166
167# If you installed in $(DESTDIR), test-installed won't work until you
168# move the library to its final location.  Use test-dd to test it
169# before then.
170
171test-dd:
172	echo
173	echo Testing installed dynamic shared library in $(DL).
174	$(CC) -I$(DI) -I$(ZLIBINC) $(CCFLAGS) \
175	   `$(BINPATH)/libpng12-config --cflags` pngtest.c \
176	   -L$(DL) -L$(ZLIBLIB) \
177	   -o pngtestd `$(BINPATH)/libpng12-config --ldflags`
178	./pngtestd pngtest.png
179
180test-installed:
181	echo
182	echo Testing installed dynamic shared library.
183	$(CC) $(CCFLAGS) \
184	   `$(BINPATH)/libpng12-config --cflags` pngtest.c \
185	   -L$(ZLIBLIB) \
186	   -o pngtesti `$(BINPATH)/libpng12-config --ldflags`
187	./pngtesti pngtest.png
188
189clean:
190	/bin/rm -f *.o libpng.a pngtest pngtesti pngout.png \
191	libpng-config $(LIBNAME).sl $(LIBNAME).sl.$(PNGMAJ)* \
192	libpng.sl.3.$(PNGMIN) \
193	libpng.pc
194
195DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO
196writelock:
197	chmod a-w *.[ch35] $(DOCS) scripts/*
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
211pngtest.o: png.h pngconf.h
212pngtrans.o: png.h pngconf.h
213pngwrite.o: png.h pngconf.h
214pngwtran.o: png.h pngconf.h
215pngwutil.o: png.h pngconf.h
216pngpread.o: png.h pngconf.h
217