Makefile.crunch revision 1.18 1 # $NetBSD: Makefile.crunch,v 1.18 2005/01/19 01:18:59 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, 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 ${CRUNCHBIN}.mk: ${CRUNCHBIN}.conf
52 ${CRUNCHENV} ${TOOL_CRUNCHGEN} -f -D ${NETBSDSRCDIR} \
53 -L ${DESTDIR}/usr/lib -q ${CRUNCHGEN_FLAGS} ${.ALLSRC}
54
55 ${CRUNCHBIN}.conf: ${LISTS} ${PARSELISTDEP}
56 -rm -f ${.TARGET} ${.TARGET}.tmp
57 ${PARSELIST} -v mode=crunch ${LISTS} > ${.TARGET}.tmp \
58 && mv ${.TARGET}.tmp ${.TARGET}
59
60 CLEANFILES+= ${CRUNCHBIN} ${CRUNCHBIN}.conf ${CRUNCHBIN}.conf.tmp \
61 ${CRUNCHBIN}.cache *.o *.cro *.c
62
63 clean cleandir distclean: cleancrunchgen
64
65 .PHONY: cleancrunchgen
66
67 cleancrunchgen:
68 if [ -f ${CRUNCHBIN}.mk ]; then \
69 ${MAKE} -f ${CRUNCHBIN}.mk clean; \
70 fi
71 rm -f ${CRUNCHBIN}.mk
72
73
74 .endif # _MAKEFILE_CRUNCH_
75