1#	$OpenBSD: Makefile.inc,v 1.1 1997/05/05 06:01:58 millert Exp $
2#	$NetBSD: Makefile.inc,v 1.2 1997/01/23 22:29:09 cgd Exp $
3#
4#	Configuration variables (default values are below):
5#
6#	S	must be set to the top of the 'sys' tree.
7#	ZDST	may be set to the location of the directory where library
8#		objects are to be built.  Defaults to ${.OBJDIR}/lib/z.
9#	Z_AS	may be set to 'obj' to build a object from the library's
10#		object files.  (Otherwise, a library will be built.)
11#		Defaults to 'library'.
12#	ZMISCMAKEFLAGS
13#		Miscellaneous flags to be passed to the library's Makefile when
14#		building.  See library's Makefile for more details about
15#		supported flags and their default values.
16
17# Default values:
18ZDST?=		${.OBJDIR}/lib/z
19Z_AS?=		library
20
21ZDIR=		$S/lib/libz
22.if (${Z_AS} == "obj")
23ZLIB=		${ZDST}/libz.o
24ZLIB_PROF=	${ZDST}/libz.po
25.else
26ZLIB=		${ZDST}/libz.a
27ZLIB_PROF=	${ZDST}/libz_p.a
28.endif
29
30ZMAKE= \
31	cd ${ZDIR} && MAKEOBJDIR=${ZDST} ${MAKE} \
32	    CC="${CC}" CFLAGS="${CFLAGS}" \
33	    AS=${AS} AFLAGS="${AFLAGS}" \
34	    LD=${LD} STRIP=${STRIP} \
35	    MACHINE=${MACHINE} MACHINE_ARCH=${MACHINE_ARCH} \
36	    ZCPPFLAGS="${CPPFLAGS:S@^-I.@-I../../.@g}" \
37	    ${ZMISCMAKEFLAGS}
38
39${ZLIB}:		.NOTMAIN __always_make_zlib
40	@echo making sure the z library is up to date...
41.if (${Z_AS} == "library")
42	${ZMAKE} libz.a
43.else
44	@${ZMAKE} libz.o
45.endif
46
47${ZLIB_PROF}:		.NOTMAIN __always_make_zlib
48	@echo making sure the profiled z library is up to date...
49.if (${Z_AS} == "library")
50	@${ZMAKE} libz_p.a
51.else
52	@${ZMAKE} libz.po
53.endif
54
55clean:			.NOTMAIN cleanzlib
56cleanzlib:		.NOTMAIN __always_make_zlib
57	@echo cleaning the z library objects
58	@${ZMAKE} clean
59
60cleandir:		.NOTMAIN cleandirzlib
61cleandirzlib:		.NOTMAIN __always_make_zlib
62	@echo cleandiring the z library objects
63	@${ZMAKE} cleandir
64
65depend:			.NOTMAIN dependzlib
66dependzlib:		.NOTMAIN __always_make_zlib
67	@echo depending the z library objects
68	@${ZMAKE} depend
69
70__always_make_zlib:	.NOTMAIN
71	@mkdir -p ${ZDST}
72