xref: /freebsd/lib/libz/Makefile (revision 271171e0d97b88ba2a7c3bf750c9672b484c1c13)
1#
2# $FreeBSD$
3#
4
5PACKAGE=	runtime
6LIB=		z
7SHLIBDIR?=	/lib
8SHLIB_MAJOR=	6
9MAN=		zlib.3 zopen.3
10MLINKS+=	zopen.3 zdopen.3
11
12ZLIBSRC=	${SRCTOP}/sys/contrib/zlib
13
14.PATH:		${ZLIBSRC}
15
16#CFLAGS=-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7
17#CFLAGS=-g -DDEBUG
18#CFLAGS=-O3 -Wall -Wwrite-strings -Wpointer-arith -Wconversion \
19#           -Wstrict-prototypes -Wmissing-prototypes
20
21CFLAGS+=	-D_LARGEFILE64_SOURCE=1 -DHAVE_HIDDEN -I${.CURDIR}
22
23WARNS?=		3
24
25CLEANFILES+=	example.o example foo.gz minigzip.o minigzip
26
27SRCS+=		adler32.c
28SRCS+=		compress.c
29SRCS+=		crc32.c
30SRCS+=		deflate.c
31SRCS+=		gzclose.c
32SRCS+=		gzlib.c
33SRCS+=		gzread.c
34SRCS+=		gzwrite.c
35SRCS+=		infback.c
36SRCS+=		inffast.c
37SRCS+=		inflate.c
38SRCS+=		inftrees.c
39SRCS+=		trees.c
40SRCS+=		uncompr.c
41SRCS+=		zutil.c
42
43# Wrapper relies on FreeBSD-specific fpos_t representation and non-portable
44# funopen. Not needed for bootstrapping, so just disable it.
45.if ${.MAKE.OS} == "FreeBSD" || !defined(BOOTSTRAPPING)
46SRCS+=		zopen.c
47.endif
48
49.if ${MACHINE_ARCH} == "i386" || ${MACHINE_ARCH} == "amd64"
50CFLAGS+=	-DUNALIGNED_OK
51.endif
52
53VERSION_DEF=	${.CURDIR}/Versions.def
54SYMBOL_MAPS=	${.CURDIR}/Symbol.map
55CFLAGS+=	-DSYMBOL_VERSIONING
56
57INCS=		zconf.h zlib.h
58
59.PATH:		${ZLIBSRC}/test
60
61ZLIB_VERSION!=	sed -n '/define.*ZLIB_VERSION/{s,[^0-9.],,gp;q;}' ${ZLIBSRC}/zlib.h
62
63zlib.pc: zlib.pc.in
64	sed -e 's,@prefix@,/usr,g ; \
65		s,@exec_prefix@,$${prefix},g ; \
66		s,@libdir@,${LIBDIR},g ; \
67		s,@sharedlibdir@,${SHLIBDIR},g ; \
68		s,@includedir@,${INCLUDEDIR},g ; \
69		s,@VERSION@,${ZLIB_VERSION},g ;' \
70		${.ALLSRC} > ${.TARGET}
71
72minigzip:	all minigzip.o
73	$(CC) -o minigzip minigzip.o -L. -lz
74
75example:	all example.o
76	$(CC) -o example example.o -L. -lz
77
78test: example minigzip
79	(export LD_LIBRARY_PATH=. ; ./example )
80	(export LD_LIBRARY_PATH=. ; \
81		echo hello world | ./minigzip | ./minigzip -d )
82
83PCFILES=	zlib.pc
84
85.include <bsd.lib.mk>
86