Home | History | Annotate | Line # | Download | only in common
Makefile.crunch revision 1.13
      1 #	$NetBSD: Makefile.crunch,v 1.13 2003/05/09 12:20:04 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, add SMALLPROG_INET6=1
     13 #			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}
     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} -j 1 -f ${CRUNCHBIN}.mk all
     42 
     43 ${CRUNCHBIN}.mk ${CRUNCHBIN}.cache ${CRUNCHBIN}.c: ${CRUNCHBIN}.conf
     44 	${CRUNCHENV} ${CRUNCHGEN} -f -D ${NETBSDSRCDIR} -L ${DESTDIR}/usr/lib \
     45 	    -q ${CRUNCHGEN_FLAGS} ${.ALLSRC}
     46 
     47 ${CRUNCHBIN}.conf: ${LISTS} ${PARSELISTDEP}
     48 	-rm -f ${.TARGET} ${.TARGET}.tmp
     49 	${PARSELIST} -v mode=crunch ${LISTS} > ${.TARGET}.tmp \
     50 	&& mv ${.TARGET}.tmp ${.TARGET}
     51 
     52 CLEANFILES+=	${CRUNCHBIN} ${CRUNCHBIN}.conf ${CRUNCHBIN}.conf.tmp \
     53 		${CRUNCHBIN}.cache *.o *.cro *.c
     54 
     55 clean cleandir distclean: cleancrunchgen
     56 
     57 .PHONY: cleancrunchgen
     58 
     59 cleancrunchgen:
     60 	if [ -f ${CRUNCHBIN}.mk ]; then \
     61 		${MAKE} -j 1 -f ${CRUNCHBIN}.mk clean; \
     62 	fi
     63 	rm -f ${CRUNCHBIN}.mk
     64 
     65 
     66 .endif	# _MAKEFILE_CRUNCH_
     67