1# makefile for libpng
2# Copyright (C) 2002 Glenn Randers-Pehrson
3# Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc.
4# For conditions of distribution and use, see copyright notice in png.h
5
6# This makefile requires the file ansi2knr.c, which you can get
7# from the Ghostscript ftp site at ftp://ftp.cs.wisc.edu/ghost/
8# If you have libjpeg, you probably already have ansi2knr.c in the jpeg
9# source distribution.
10
11# where make install puts libpng.a and png.h
12prefix=/usr/local
13INCPATH=$(prefix)/include
14LIBPATH=$(prefix)/lib
15
16# override DESTDIR= on the make install command line to easily support
17# installing into a temporary location.  Example:
18#
19#    make install DESTDIR=/tmp/build/libpng
20#
21# If you're going to install into a temporary location
22# via DESTDIR, $(DESTDIR)$(prefix) must already exist before
23# you execute make install.
24DESTDIR=
25
26CC=cc
27CFLAGS=-I../zlib -O
28LDFLAGS=-L. -L../zlib/ -lpng -lz -lm
29# flags for ansi2knr
30ANSI2KNRFLAGS=
31
32RANLIB=ranlib
33#RANLIB=echo
34
35OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \
36	pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \
37	pngwtran.o pngmem.o pngerror.o pngpread.o
38
39all: ansi2knr libpng.a pngtest
40
41# general rule to allow ansi2knr to work
42.c.o:
43	./ansi2knr $*.c T$*.c
44	$(CC) $(CFLAGS) -c T$*.c
45	rm -f T$*.c $*.o
46	mv T$*.o $*.o
47
48ansi2knr: ansi2knr.c
49	$(CC) $(CFLAGS) $(ANSI2KNRFLAGS) -o ansi2knr ansi2knr.c
50
51libpng.a: ansi2knr $(OBJS)
52	ar rc $@  $(OBJS)
53	$(RANLIB) $@
54
55pngtest: pngtest.o libpng.a
56	$(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS)
57
58test: pngtest
59	./pngtest
60
61install: libpng.a
62	-@mkdir $(DESTDIR)$(INCPATH)
63	-@mkdir $(DESTDIR)$(INCPATH)/libpng
64	-@mkdir $(DESTDIR)$(LIBPATH)
65	-@rm -f $(DESTDIR)$(INCPATH)/png.h
66	-@rm -f $(DESTDIR)$(INCPATH)/pngconf.h
67	cp png.h $(DESTDIR)$(INCPATH)/libpng
68	cp pngconf.h $(DESTDIR)$(INCPATH)/libpng
69	chmod 644 $(DESTDIR)$(INCPATH)/libpng/png.h
70	chmod 644 $(DESTDIR)$(INCPATH)/libpng/pngconf.h
71	(cd $(DESTDIR)$(INCPATH); ln -f -s libpng/* .)
72	cp libpng.a $(DESTDIR)$(LIBPATH)
73	chmod 644 $(DESTDIR)$(LIBPATH)/libpng.a
74
75clean:
76	rm -f *.o libpng.a pngtest pngout.png ansi2knr
77
78DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO
79writelock:
80	chmod a-w *.[ch35] $(DOCS) scripts/*
81
82# DO NOT DELETE THIS LINE -- make depend depends on it.
83
84png.o: png.h pngconf.h
85pngerror.o: png.h pngconf.h
86pngrio.o: png.h pngconf.h
87pngwio.o: png.h pngconf.h
88pngmem.o: png.h pngconf.h
89pngset.o: png.h pngconf.h
90pngget.o: png.h pngconf.h
91pngread.o: png.h pngconf.h
92pngpread.o: png.h pngconf.h
93pngrtran.o: png.h pngconf.h
94pngrutil.o: png.h pngconf.h
95pngtest.o: png.h pngconf.h
96pngtrans.o: png.h pngconf.h
97pngwrite.o: png.h pngconf.h
98pngwtran.o: png.h pngconf.h
99pngwutil.o: png.h pngconf.h
100