1# $NetBSD: bsd.inc.mk,v 1.34 2022/03/29 22:48:04 christos Exp $ 2 3.include <bsd.init.mk> 4 5##### Basic targets 6includes: ${INCS} incinstall inclinkinstall 7 8##### Default values 9INCSYMLINKS?= 10 11##### Install rules 12incinstall:: # ensure existence 13.PHONY: incinstall 14 15__incinstall: .USE 16 @cmp -s ${.ALLSRC} ${.TARGET} > /dev/null 2>&1 || \ 17 (${_MKSHMSG_INSTALL} ${.TARGET}; \ 18 ${_MKSHECHO} "${INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} \ 19 -m ${NONBINMODE} ${.ALLSRC} ${.TARGET}" && \ 20 ${INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} \ 21 -m ${NONBINMODE} ${.ALLSRC} ${.TARGET}) 22 23.for F in ${INCS:O:u} 24_FDIR:= ${INCSDIR_${F:C,/,_,g}:U${INCSDIR}} # dir override 25_FNAME:= ${INCSNAME_${F:C,/,_,g}:U${INCSNAME:U${F}}} # name override 26_F:= ${DESTDIR}${_FDIR}/${_FNAME} # installed path 27 28.if ${MKUPDATE} == "no" 29${_F}! ${F} __incinstall # install rule 30.else 31${_F}: ${F} __incinstall # install rule 32.endif 33 34incinstall:: ${_F} 35.PRECIOUS: ${_F} # keep if install fails 36.endfor 37 38.undef _FDIR 39.undef _FNAME 40.undef _F 41 42inclinkinstall: .PHONY 43.if !empty(INCSYMLINKS) 44 @(set ${INCSYMLINKS}; \ 45 while test $$# -ge 2; do \ 46 l=$$1; shift; \ 47 t=${DESTDIR}$$1; shift; \ 48 if ttarg=$$(${TOOL_STAT} -qf '%Y' $$t) && \ 49 [ "$$l" = "$$ttarg" ]; then \ 50 continue ; \ 51 fi ; \ 52 ${_MKSHMSG_INSTALL} $$t; \ 53 ${_MKSHECHO} ${INSTALL_SYMLINK} $$l $$t; \ 54 ${INSTALL_SYMLINK} $$l $$t; \ 55 done; ) 56.endif 57