Makefile.crunch revision 1.22 1 # $NetBSD: Makefile.crunch,v 1.22 2005/11/07 22:19:34 dsl 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
30 SMALLPROG?= 1
31 SMALLPROG_INET6?= 0
32 .if ${SMALLPROG} # {
33 CRUNCHENV+= SMALLPROG=1
34 .if ${SMALLPROG_INET6} && (${USE_INET6} != "no")
35 CRUNCHENV+= SMALLPROG_INET6=1
36 .endif
37 .endif # }
38
39 .include "${DISTRIBDIR}/common/Makefile.parselist"
40
41 .PHONY: ${CRUNCHBIN}
42 ${CRUNCHBIN}: ${CRUNCHBIN}.mk ${CRUNCHBIN}.cache ${CRUNCHBIN}.c
43 ${MAKE} ${CRUNCHENV} -f ${CRUNCHBIN}.mk ${CRUNCHBIN}.crunched
44
45 ${CRUNCHBIN}.c: ${CRUNCHBIN}.mk
46 [ ! -f ${.TARGET} ] || touch ${.TARGET}
47
48 ${CRUNCHBIN}.cache: ${CRUNCHBIN}.mk
49 [ ! -f ${.TARGET} ] || touch ${.TARGET}
50
51 CRUNCHGEN != command -v ${TOOL_CRUNCHGEN:[-1]}
52
53 ${CRUNCHBIN}.mk: ${CRUNCHBIN}.conf ${CRUNCHGEN}
54 ${CRUNCHENV} ${TOOL_CRUNCHGEN} -f -D ${NETBSDSRCDIR} \
55 -L ${DESTDIR}/usr/lib -q ${CRUNCHGEN_FLAGS} ${CRUNCHBIN}.conf
56
57 ${CRUNCHBIN}.conf: ${LISTS} ${PARSELISTDEP}
58 -rm -f ${.TARGET} ${.TARGET}.tmp
59 ${PARSELIST} -v mode=crunch ${LISTS} > ${.TARGET}.tmp \
60 && mv ${.TARGET}.tmp ${.TARGET}
61
62 CLEANFILES+= ${CRUNCHBIN} ${CRUNCHBIN}.conf ${CRUNCHBIN}.conf.tmp \
63 ${CRUNCHBIN}.cache *.o *.cro *.c
64
65 clean cleandir distclean: cleancrunchgen
66
67 .PHONY: cleancrunchgen
68
69 cleancrunchgen:
70 if [ -f ${CRUNCHBIN}.mk ]; then \
71 ${MAKE} -f ${CRUNCHBIN}.mk clean; \
72 fi
73 rm -f ${CRUNCHBIN}.mk
74
75
76 .endif # _MAKEFILE_CRUNCH_
77