1# makefile for libpng
2# Copyright (C) 2007-2009, 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
9PREFIX?= /usr/local
10LIBDIR=	${PREFIX}/lib
11MANDIR= ${PREFIX}/man/cat
12
13SHLIB_MAJOR=	16
14SHLIB_MINOR=	1.6.37
15
16LIB=	png
17SRCS=	png.c pngerror.c pngget.c pngmem.c pngpread.c \
18	pngread.c pngrio.c pngrtran.c pngrutil.c pngset.c pngtrans.c \
19	pngwio.c pngwrite.c pngwtran.c pngwutil.c
20HDRS=	png.h pngconf.h pnglibconf.h
21MAN=	libpng.3 libpngpf.3 png.5
22DOCS=	ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO \
23	libpng-manual.txt
24
25CFLAGS+= -W -Wall
26CPPFLAGS+= -I${.CURDIR}
27
28NOPROFILE= Yes
29
30CLEANFILES+= pngtest.o pngtest pnglibconf.h
31
32# Pre-built configuration
33# See scripts/pnglibconf.mak for more options
34PNGLIBCONF_H_PREBUILT= scripts/pnglibconf.h.prebuilt
35
36.c.o:
37	${CC} -c ${CPPFLAGS} ${CFLAGS} -o $@ $<
38
39pnglibconf.h: ${PNGLIBCONF_H_PREBUILT}
40	cp ${PNGLIBCONF_H_PREBUILT} $@
41
42pngtest.o:	pngtest.c
43	${CC} -c ${CPPFLAGS} ${CFLAGS} ${.ALLSRC} -o ${.TARGET}
44
45pngtest:	pngtest.o
46	${CC} ${LDFLAGS} ${.ALLSRC} -o ${.TARGET} -L${.OBJDIR} -lpng -lz -lm
47
48test:	pngtest
49	cd ${.OBJDIR} && env \
50		LD_LIBRARY_PATH="${.OBJDIR}" ${.OBJDIR}/pngtest
51
52beforeinstall:
53	if [ ! -d ${DESTDIR}${PREFIX}/include/libpng ]; then \
54	  ${INSTALL} -d -o root -g wheel ${DESTDIR}${PREFIX}/include; \
55	fi
56	if [ ! -d ${DESTDIR}${LIBDIR} ]; then \
57	  ${INSTALL} -d -o root -g wheel ${DESTDIR}${LIBDIR}; \
58	fi
59	if [ ! -d ${DESTDIR}${LIBDIR}/debug ]; then \
60	  ${INSTALL} -d -o root -g wheel ${DESTDIR}${LIBDIR}/debug; \
61	fi
62	if [ ! -d ${DESTDIR}${MANDIR}3 ]; then \
63	  ${INSTALL} -d -o root -g wheel ${DESTDIR}${MANDIR}3; \
64	fi
65	if [ ! -d ${DESTDIR}${MANDIR}5 ]; then \
66	  ${INSTALL} -d -o root -g wheel ${DESTDIR}${MANDIR}5; \
67	fi
68	if [ ! -d ${DESTDIR}${PREFIX}/share/doc/png ]; then \
69	  ${INSTALL} -d -o root -g wheel ${DESTDIR}${PREFIX}/share/doc/png; \
70	fi
71
72afterinstall:
73	@rm -f ${DESTDIR}${LIBDIR}/libpng_pic.a
74	@rm -f ${DESTDIR}${LIBDIR}/debug/libpng.a
75	@rm -f ${DESTDIR}${PREFIX}/include/png.h
76	@rm -f ${DESTDIR}${PREFIX}/include/pngconf.h
77	@rm -f ${DESTDIR}${PREFIX}/include/pnglibconf.h
78	@rmdir ${DESTDIR}${LIBDIR}/debug 2>/dev/null || true
79	${INSTALL} ${INSTALL_COPY} -o ${SHAREOWN} -g ${SHAREGRP} \
80		-m ${NONBINMODE} ${HDRS} ${DESTDIR}${PREFIX}/include
81	${INSTALL} ${INSTALL_COPY} -o ${SHAREOWN} -g ${SHAREGRP} \
82		-m ${NONBINMODE} ${HDRS} ${DESTDIR}${PREFIX}/include
83	${INSTALL} ${INSTALL_COPY} -o ${SHAREOWN} -g ${SHAREGRP} \
84		-m ${NONBINMODE} ${DOCS} ${DESTDIR}${PREFIX}/share/doc/png
85
86.include <bsd.lib.mk>
87