1 1.26 christos # $NetBSD: Makefile.crunch,v 1.26 2019/12/29 18:26:16 christos 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.11 lukem .if ${SMALLPROG} # { 45 1.11 lukem CRUNCHENV+= SMALLPROG=1 46 1.17 lukem .if ${SMALLPROG_INET6} && (${USE_INET6} != "no") 47 1.11 lukem CRUNCHENV+= SMALLPROG_INET6=1 48 1.11 lukem .endif 49 1.11 lukem .endif # } 50 1.4 lukem 51 1.7 lukem .include "${DISTRIBDIR}/common/Makefile.parselist" 52 1.1 lukem 53 1.13 dsl .PHONY: ${CRUNCHBIN} 54 1.1 lukem ${CRUNCHBIN}: ${CRUNCHBIN}.mk ${CRUNCHBIN}.cache ${CRUNCHBIN}.c 55 1.18 lukem ${MAKE} ${CRUNCHENV} -f ${CRUNCHBIN}.mk ${CRUNCHBIN}.crunched 56 1.1 lukem 57 1.14 dsl ${CRUNCHBIN}.c: ${CRUNCHBIN}.mk 58 1.14 dsl [ ! -f ${.TARGET} ] || touch ${.TARGET} 59 1.14 dsl 60 1.14 dsl ${CRUNCHBIN}.cache: ${CRUNCHBIN}.mk 61 1.14 dsl [ ! -f ${.TARGET} ] || touch ${.TARGET} 62 1.14 dsl 63 1.23 dsl CRUNCHGEN != command -v ${TOOL_CRUNCHGEN:[-1]} || echo 64 1.22 dsl 65 1.22 dsl ${CRUNCHBIN}.mk: ${CRUNCHBIN}.conf ${CRUNCHGEN} 66 1.26 christos ${CRUNCHENV} ${TOOL_CRUNCHGEN} -f -D ${NETBSDSRCDIR} \ 67 1.21 dsl -L ${DESTDIR}/usr/lib -q ${CRUNCHGEN_FLAGS} ${CRUNCHBIN}.conf 68 1.1 lukem 69 1.7 lukem ${CRUNCHBIN}.conf: ${LISTS} ${PARSELISTDEP} 70 1.1 lukem -rm -f ${.TARGET} ${.TARGET}.tmp 71 1.7 lukem ${PARSELIST} -v mode=crunch ${LISTS} > ${.TARGET}.tmp \ 72 1.1 lukem && mv ${.TARGET}.tmp ${.TARGET} 73 1.1 lukem 74 1.2 lukem CLEANFILES+= ${CRUNCHBIN} ${CRUNCHBIN}.conf ${CRUNCHBIN}.conf.tmp \ 75 1.2 lukem ${CRUNCHBIN}.cache *.o *.cro *.c 76 1.1 lukem 77 1.1 lukem clean cleandir distclean: cleancrunchgen 78 1.1 lukem 79 1.1 lukem .PHONY: cleancrunchgen 80 1.1 lukem 81 1.1 lukem cleancrunchgen: 82 1.1 lukem if [ -f ${CRUNCHBIN}.mk ]; then \ 83 1.15 lukem ${MAKE} -f ${CRUNCHBIN}.mk clean; \ 84 1.1 lukem fi 85 1.2 lukem rm -f ${CRUNCHBIN}.mk 86 1.12 lukem 87 1.12 lukem 88 1.12 lukem .endif # _MAKEFILE_CRUNCH_ 89