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