1 1.27 rin # $NetBSD: Makefile.crunch,v 1.27 2022/05/11 10:45:48 rin 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.26 christos DBG?=-Os 30 1.26 christos CRUNCHGEN_FLAGS?=\ 31 1.26 christos -V LDSTATIC=-static \ 32 1.26 christos -V DBG="${DBG}" \ 33 1.26 christos -V NOMAN= \ 34 1.26 christos -V NOLIBCSANITIZER= \ 35 1.26 christos -V NOSANITIZER= \ 36 1.26 christos -V NOPIE= \ 37 1.26 christos -V NOSSP= \ 38 1.26 christos -V NOFORT= 39 1.26 christos 40 1.24 apb CRUNCHENV+= AWK=${TOOL_AWK:Q} 41 1.12 lukem 42 1.11 lukem SMALLPROG?= 1 43 1.11 lukem SMALLPROG_INET6?= 0 44 1.27 rin NOIEEE80211?= 0 45 1.11 lukem .if ${SMALLPROG} # { 46 1.11 lukem CRUNCHENV+= SMALLPROG=1 47 1.17 lukem .if ${SMALLPROG_INET6} && (${USE_INET6} != "no") 48 1.11 lukem CRUNCHENV+= SMALLPROG_INET6=1 49 1.11 lukem .endif 50 1.27 rin .if ${NOIEEE80211} 51 1.27 rin CRUNCHENV+= NOIEEE80211=1 52 1.27 rin .endif 53 1.11 lukem .endif # } 54 1.4 lukem 55 1.7 lukem .include "${DISTRIBDIR}/common/Makefile.parselist" 56 1.1 lukem 57 1.13 dsl .PHONY: ${CRUNCHBIN} 58 1.1 lukem ${CRUNCHBIN}: ${CRUNCHBIN}.mk ${CRUNCHBIN}.cache ${CRUNCHBIN}.c 59 1.18 lukem ${MAKE} ${CRUNCHENV} -f ${CRUNCHBIN}.mk ${CRUNCHBIN}.crunched 60 1.1 lukem 61 1.14 dsl ${CRUNCHBIN}.c: ${CRUNCHBIN}.mk 62 1.14 dsl [ ! -f ${.TARGET} ] || touch ${.TARGET} 63 1.14 dsl 64 1.14 dsl ${CRUNCHBIN}.cache: ${CRUNCHBIN}.mk 65 1.14 dsl [ ! -f ${.TARGET} ] || touch ${.TARGET} 66 1.14 dsl 67 1.23 dsl CRUNCHGEN != command -v ${TOOL_CRUNCHGEN:[-1]} || echo 68 1.22 dsl 69 1.22 dsl ${CRUNCHBIN}.mk: ${CRUNCHBIN}.conf ${CRUNCHGEN} 70 1.26 christos ${CRUNCHENV} ${TOOL_CRUNCHGEN} -f -D ${NETBSDSRCDIR} \ 71 1.21 dsl -L ${DESTDIR}/usr/lib -q ${CRUNCHGEN_FLAGS} ${CRUNCHBIN}.conf 72 1.1 lukem 73 1.7 lukem ${CRUNCHBIN}.conf: ${LISTS} ${PARSELISTDEP} 74 1.1 lukem -rm -f ${.TARGET} ${.TARGET}.tmp 75 1.7 lukem ${PARSELIST} -v mode=crunch ${LISTS} > ${.TARGET}.tmp \ 76 1.1 lukem && mv ${.TARGET}.tmp ${.TARGET} 77 1.1 lukem 78 1.2 lukem CLEANFILES+= ${CRUNCHBIN} ${CRUNCHBIN}.conf ${CRUNCHBIN}.conf.tmp \ 79 1.2 lukem ${CRUNCHBIN}.cache *.o *.cro *.c 80 1.1 lukem 81 1.1 lukem clean cleandir distclean: cleancrunchgen 82 1.1 lukem 83 1.1 lukem .PHONY: cleancrunchgen 84 1.1 lukem 85 1.1 lukem cleancrunchgen: 86 1.1 lukem if [ -f ${CRUNCHBIN}.mk ]; then \ 87 1.15 lukem ${MAKE} -f ${CRUNCHBIN}.mk clean; \ 88 1.1 lukem fi 89 1.2 lukem rm -f ${CRUNCHBIN}.mk 90 1.12 lukem 91 1.12 lukem 92 1.12 lukem .endif # _MAKEFILE_CRUNCH_ 93