Makefile.crunch revision 1.24.18.1 1 # $NetBSD: Makefile.crunch,v 1.24.18.1 2014/05/22 12:01:27 yamt 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, and ${USE_INET6} != "no",
13 # add SMALLPROG_INET6=1 to CRUNCHENV. [default: 0]
14 # CRUNCHENV environment to pass to crunchgen(1) and when building
15 # the crunched program with make(1) (as command line
16 # variables, to override any user provided environment
17 # or make(1) cmdline vars).
18 # CRUNCHGEN_FLAGS extra options to crunchgen(1)
19 # DESTDIR destination directory
20 # PARSELISTENV environment variables to set for parselist.awk
21 #
22 # Variables modified by this:
23 # CRUNCHENV may get SMALLPROG=1 or SMALLPROG_INET6=1 added
24 #
25
26 .if !defined(_MAKEFILE_CRUNCH_)
27 _MAKEFILE_CRUNCH_=1
28
29 CRUNCHENV+= AWK=${TOOL_AWK:Q}
30
31 SMALLPROG?= 1
32 SMALLPROG_INET6?= 0
33 .if ${SMALLPROG} # {
34 CRUNCHENV+= SMALLPROG=1
35 .if ${SMALLPROG_INET6} && (${USE_INET6} != "no")
36 CRUNCHENV+= SMALLPROG_INET6=1
37 .endif
38 .endif # }
39
40 .include "${DISTRIBDIR}/common/Makefile.parselist"
41
42 .PHONY: ${CRUNCHBIN}
43 ${CRUNCHBIN}: ${CRUNCHBIN}.mk ${CRUNCHBIN}.cache ${CRUNCHBIN}.c
44 ${MAKE} ${CRUNCHENV} -f ${CRUNCHBIN}.mk ${CRUNCHBIN}.crunched
45
46 ${CRUNCHBIN}.c: ${CRUNCHBIN}.mk
47 [ ! -f ${.TARGET} ] || touch ${.TARGET}
48
49 ${CRUNCHBIN}.cache: ${CRUNCHBIN}.mk
50 [ ! -f ${.TARGET} ] || touch ${.TARGET}
51
52 CRUNCHGEN != command -v ${TOOL_CRUNCHGEN:[-1]} || echo
53
54 ${CRUNCHBIN}.mk: ${CRUNCHBIN}.conf ${CRUNCHGEN}
55 ${CRUNCHENV} ${TOOL_CRUNCHGEN} -f -D ${NETBSDSRCDIR} -d ${DBG:Q} \
56 -L ${DESTDIR}/usr/lib -q ${CRUNCHGEN_FLAGS} ${CRUNCHBIN}.conf
57
58 ${CRUNCHBIN}.conf: ${LISTS} ${PARSELISTDEP}
59 -rm -f ${.TARGET} ${.TARGET}.tmp
60 ${PARSELIST} -v mode=crunch ${LISTS} > ${.TARGET}.tmp \
61 && mv ${.TARGET}.tmp ${.TARGET}
62
63 CLEANFILES+= ${CRUNCHBIN} ${CRUNCHBIN}.conf ${CRUNCHBIN}.conf.tmp \
64 ${CRUNCHBIN}.cache *.o *.cro *.c
65
66 clean cleandir distclean: cleancrunchgen
67
68 .PHONY: cleancrunchgen
69
70 cleancrunchgen:
71 if [ -f ${CRUNCHBIN}.mk ]; then \
72 ${MAKE} -f ${CRUNCHBIN}.mk clean; \
73 fi
74 rm -f ${CRUNCHBIN}.mk
75
76
77 .endif # _MAKEFILE_CRUNCH_
78