1# $MirOS: src/kern/z/Makefile.inc,v 1.6 2013/08/05 21:27:30 tg Exp $
2
3.include "${KERNBASE}/Makefile.inc"
4
5.PATH: ${KERNBASE}/z
6
7ZLIB_GENHDRS=	crc32.h inffixed.h trees.h
8ZLIB_CLEANFLS=	${ZLIB_GENHDRS} {mk_crc32,mk_inffixed,mk_trees}*
9ZLIB_SRCS=	adler32cb.c compress.c crc32.c deflate.c gzclose.c gzlib.c \
10		gzread.c gzwrite.c infback.c inffast.c inflate.c inftrees.c \
11		trees.c uncompr.c zutil.c
12ZLIB_SRCS+=	crc32_combine.c
13ZLIB_CLEANFLS+=	crc32_combine.c
14ZLIB_OBJS=	${ZLIB_SRCS:S/.c$/.o/}
15HOSTCC?=	${CC}
16HOSTCFLAGS?=	${CFLAGS}
17HOSTLDFLAGS?=	${LDFLAGS}
18HOSTCPPFLAGS?=	${CPPFLAGS}
19.if ${CPPFLAGS:N1:S-I${KERNBASE}/z1:M1} == ""
20CPPFLAGS+=	-I${KERNBASE}/z
21.endif
22.if ${CPPFLAGS:M-I.} == ""
23CPPFLAGS+=	-I.
24.endif
25.if ${HOSTCPPFLAGS:N1:S-I${KERNBASE}/z1:M1} == ""
26HOSTCPPFLAGS+=	-I${KERNBASE}/z
27.endif
28.if ${HOSTCPPFLAGS:M-I.} == ""
29HOSTCPPFLAGS+=	-I.
30.endif
31
32crc32.h: mk_crc32
33	./mk_crc32
34
35inffixed.h: mk_inffixed
36	./mk_inffixed >$@
37
38trees.h: mk_trees
39	./mk_trees
40
41mk_crc32.c:
42	print 'void get_crc_table(void);' >$@
43	print >>$@
44	print 'int' >>$@
45	print 'main(void)' >>$@
46	print '{' >>$@
47	print '\tget_crc_table();' >>$@
48	print '\treturn (0);' >>$@
49	print '}' >>$@
50
51mk_crc32: mk_crc32.c crc32.c
52	${HOSTCC} ${LDSTATIC} ${HOSTCFLAGS} ${HOSTCPPFLAGS} \
53	    ${HOSTLDFLAGS} -DMAKECRCH -DZLIB_NO_CRC32PUSH $> -o $@
54
55mk_inffixed.c: crc32.h
56	print 'void makefixed(void);' >$@
57	print >>$@
58	print 'int' >>$@
59	print 'main(void)' >>$@
60	print '{' >>$@
61	print '\tmakefixed();' >>$@
62	print '\treturn (0);' >>$@
63	print '}' >>$@
64
65mk_inffixed: mk_inffixed.c inflate.c \
66    adler32s.c crc32.c inffast.c inftrees.c zutil.c
67	${HOSTCC} ${LDSTATIC} ${HOSTCFLAGS} ${HOSTCPPFLAGS} \
68	    ${HOSTLDFLAGS} -DMAKEFIXED -DZLIB_NO_ADLERPUSH $> -o $@
69
70mk_trees.c:
71	print '#include "deflate.h"' >$@
72	print '#include <string.h>' >>$@
73	print >>$@
74	print 'int' >>$@
75	print 'main(void)' >>$@
76	print '{' >>$@
77	print '\tdeflate_state s;' >>$@
78	print >>$@
79	print '\tbzero(&s, sizeof (s));' >>$@
80	print '\t_tr_init(&s);' >>$@
81	print '\treturn (0);' >>$@
82	print '}' >>$@
83
84mk_trees: mk_trees.c trees.c
85	${HOSTCC} ${LDSTATIC} ${HOSTCFLAGS} ${HOSTCPPFLAGS} \
86	    ${HOSTLDFLAGS} -DGEN_TREES_H $> -o $@
87
88crc32_combine.c: crc32.c
89	-unifdef -DL_crc32_combine $> >$@
90