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