Home | History | Annotate | Line # | Download | only in common
Makefile.crunch revision 1.24.18.1
      1  1.24.18.1   yamt #	$NetBSD: Makefile.crunch,v 1.24.18.1 2014/05/22 12:01:27 yamt Exp $
      2        1.1  lukem #
      3        1.1  lukem # Makefile snippet to build a crunchgen(1)ed binary from the provided lists
      4        1.1  lukem #
      5        1.1  lukem # Required variables:
      6        1.8  lukem #	NETBSDSRCDIR	top level of src tree (set by <bsd.own.mk>)
      7        1.1  lukem #	CRUNCHBIN	name of crunchgen(1)ed binary
      8        1.1  lukem #	LISTS		list file(s) to use
      9        1.1  lukem #
     10        1.4  lukem # Optional variables:
     11       1.11  lukem #	SMALLPROG	if != 0, add SMALLPROG=1 to CRUNCHENV.  [default: 1]
     12       1.17  lukem #	SMALLPROG_INET6	if != 0 and SMALLPROG != 0, and ${USE_INET6} != "no",
     13       1.17  lukem #			add SMALLPROG_INET6=1 to CRUNCHENV.  [default: 0]
     14        1.9  lukem #	CRUNCHENV	environment to pass to crunchgen(1) and when building
     15       1.18  lukem #			the crunched program with make(1) (as command line
     16       1.18  lukem #			variables, to override any user provided environment
     17       1.18  lukem #			or make(1) cmdline vars).
     18        1.6  lukem #	CRUNCHGEN_FLAGS	extra options to crunchgen(1)
     19        1.4  lukem #	DESTDIR		destination directory
     20        1.4  lukem #	PARSELISTENV	environment variables to set for parselist.awk
     21        1.4  lukem #
     22        1.9  lukem # Variables modified by this:
     23       1.11  lukem #	CRUNCHENV	may get SMALLPROG=1 or SMALLPROG_INET6=1 added
     24       1.11  lukem #
     25        1.9  lukem 
     26       1.12  lukem .if !defined(_MAKEFILE_CRUNCH_)
     27       1.12  lukem _MAKEFILE_CRUNCH_=1
     28       1.12  lukem 
     29       1.24    apb CRUNCHENV+=		AWK=${TOOL_AWK:Q}
     30       1.12  lukem 
     31       1.11  lukem SMALLPROG?=		1
     32       1.11  lukem SMALLPROG_INET6?=	0
     33       1.11  lukem .if ${SMALLPROG}				# {
     34       1.11  lukem CRUNCHENV+=		SMALLPROG=1
     35       1.17  lukem .if ${SMALLPROG_INET6} && (${USE_INET6} != "no")
     36       1.11  lukem CRUNCHENV+=		SMALLPROG_INET6=1
     37       1.11  lukem .endif
     38       1.11  lukem .endif						# }
     39        1.4  lukem 
     40        1.7  lukem .include "${DISTRIBDIR}/common/Makefile.parselist"
     41        1.1  lukem 
     42       1.13    dsl .PHONY:	${CRUNCHBIN}
     43        1.1  lukem ${CRUNCHBIN}: ${CRUNCHBIN}.mk ${CRUNCHBIN}.cache ${CRUNCHBIN}.c
     44       1.18  lukem 	${MAKE} ${CRUNCHENV} -f ${CRUNCHBIN}.mk ${CRUNCHBIN}.crunched
     45        1.1  lukem 
     46       1.14    dsl ${CRUNCHBIN}.c: ${CRUNCHBIN}.mk
     47       1.14    dsl 	[ ! -f ${.TARGET} ] || touch ${.TARGET}
     48       1.14    dsl 
     49       1.14    dsl ${CRUNCHBIN}.cache: ${CRUNCHBIN}.mk
     50       1.14    dsl 	[ ! -f ${.TARGET} ] || touch ${.TARGET}
     51       1.14    dsl 
     52       1.23    dsl CRUNCHGEN != command -v ${TOOL_CRUNCHGEN:[-1]} || echo
     53       1.22    dsl 
     54       1.22    dsl ${CRUNCHBIN}.mk: ${CRUNCHBIN}.conf  ${CRUNCHGEN}
     55  1.24.18.1   yamt 	${CRUNCHENV} ${TOOL_CRUNCHGEN} -f -D ${NETBSDSRCDIR} -d ${DBG:Q} \
     56       1.21    dsl 	    -L ${DESTDIR}/usr/lib -q ${CRUNCHGEN_FLAGS} ${CRUNCHBIN}.conf
     57        1.1  lukem 
     58        1.7  lukem ${CRUNCHBIN}.conf: ${LISTS} ${PARSELISTDEP}
     59        1.1  lukem 	-rm -f ${.TARGET} ${.TARGET}.tmp
     60        1.7  lukem 	${PARSELIST} -v mode=crunch ${LISTS} > ${.TARGET}.tmp \
     61        1.1  lukem 	&& mv ${.TARGET}.tmp ${.TARGET}
     62        1.1  lukem 
     63        1.2  lukem CLEANFILES+=	${CRUNCHBIN} ${CRUNCHBIN}.conf ${CRUNCHBIN}.conf.tmp \
     64        1.2  lukem 		${CRUNCHBIN}.cache *.o *.cro *.c
     65        1.1  lukem 
     66        1.1  lukem clean cleandir distclean: cleancrunchgen
     67        1.1  lukem 
     68        1.1  lukem .PHONY: cleancrunchgen
     69        1.1  lukem 
     70        1.1  lukem cleancrunchgen:
     71        1.1  lukem 	if [ -f ${CRUNCHBIN}.mk ]; then \
     72       1.15  lukem 		${MAKE} -f ${CRUNCHBIN}.mk clean; \
     73        1.1  lukem 	fi
     74        1.2  lukem 	rm -f ${CRUNCHBIN}.mk
     75       1.12  lukem 
     76       1.12  lukem 
     77       1.12  lukem .endif	# _MAKEFILE_CRUNCH_
     78