Makefile.crunch revision 1.12 1 # $NetBSD: Makefile.crunch,v 1.12 2003/03/11 07:18:38 lukem Exp $
2 #
3 # Makefile snippet to build a crunchgen(1)ed binary from the provided lists
4 #
5 # Required variables:
6 # NETBSDSRCDIR top level of src tree (set by <bsd.own.mk>)
7 # CRUNCHBIN name of crunchgen(1)ed binary
8 # LISTS list file(s) to use
9 #
10 # Optional variables:
11 # SMALLPROG if != 0, add SMALLPROG=1 to CRUNCHENV. [default: 1]
12 # SMALLPROG_INET6 if != 0 and SMALLPROG != 0, add SMALLPROG_INET6=1
13 # to CRUNCHENV. [default: 0]
14 # CRUNCHENV environment to pass to crunchgen(1) and when building
15 # the crunched program.
16 # CRUNCHGEN_FLAGS extra options to crunchgen(1)
17 # DESTDIR destination directory
18 # PARSELISTENV environment variables to set for parselist.awk
19 #
20 # Variables modified by this:
21 # CRUNCHENV may get SMALLPROG=1 or SMALLPROG_INET6=1 added
22 #
23
24 .if !defined(_MAKEFILE_CRUNCH_)
25 _MAKEFILE_CRUNCH_=1
26
27
28 SMALLPROG?= 1
29 SMALLPROG_INET6?= 0
30 .if ${SMALLPROG} # {
31 CRUNCHENV+= SMALLPROG=1
32 .if ${SMALLPROG_INET6}
33 CRUNCHENV+= SMALLPROG_INET6=1
34 .endif
35 .endif # }
36
37 .include "${DISTRIBDIR}/common/Makefile.parselist"
38
39 ${CRUNCHBIN}: ${CRUNCHBIN}.mk ${CRUNCHBIN}.cache ${CRUNCHBIN}.c
40 ${CRUNCHENV} ${MAKE} -j 1 -f ${CRUNCHBIN}.mk all
41
42 ${CRUNCHBIN}.mk ${CRUNCHBIN}.cache ${CRUNCHBIN}.c: ${CRUNCHBIN}.conf
43 ${CRUNCHENV} ${CRUNCHGEN} -f -D ${NETBSDSRCDIR} -L ${DESTDIR}/usr/lib \
44 -q ${CRUNCHGEN_FLAGS} ${.ALLSRC}
45
46 ${CRUNCHBIN}.conf: ${LISTS} ${PARSELISTDEP}
47 -rm -f ${.TARGET} ${.TARGET}.tmp
48 ${PARSELIST} -v mode=crunch ${LISTS} > ${.TARGET}.tmp \
49 && mv ${.TARGET}.tmp ${.TARGET}
50
51 CLEANFILES+= ${CRUNCHBIN} ${CRUNCHBIN}.conf ${CRUNCHBIN}.conf.tmp \
52 ${CRUNCHBIN}.cache *.o *.cro *.c
53
54 clean cleandir distclean: cleancrunchgen
55
56 .PHONY: cleancrunchgen
57
58 cleancrunchgen:
59 if [ -f ${CRUNCHBIN}.mk ]; then \
60 ${MAKE} -j 1 -f ${CRUNCHBIN}.mk clean; \
61 fi
62 rm -f ${CRUNCHBIN}.mk
63
64
65 .endif # _MAKEFILE_CRUNCH_
66