1 # $NetBSD: bsd.kinc.mk,v 1.38 2022/03/29 22:48:04 christos Exp $ 2 3 # Variables: 4 # 5 # INCSDIR Directory to install includes into (and/or make, and/or 6 # symlink, depending on what's going on). 7 # 8 # INCS Headers to install. 9 # 10 # DEPINCS Headers to install which are built dynamically. 11 # 12 # SUBDIR Subdirectories to enter 13 # 14 # INCSYMLINKS Symlinks to make (unconditionally), a la bsd.links.mk. 15 # Note that the original bits will be 'rm -rf'd rather than 16 # just 'rm -f'd, to make the right thing happen with include 17 # directories. 18 # 19 20 .include <bsd.init.mk> 21 22 ##### Basic targets 23 .PRECIOUS: ${DESTDIR}${INCSDIR} 24 includes: ${DESTDIR}${INCSDIR} .WAIT ${INCS} incinstall 25 26 ##### Install rules 27 incinstall:: # ensure existence 28 .PHONY: incinstall 29 30 # make sure the directory is OK, and install includes. 31 32 ${DESTDIR}${INCSDIR}: .EXEC 33 @if [ ! -d ${.TARGET} ] || [ -h ${.TARGET} ] ; then \ 34 ${_MKSHMSG_CREATE} ${.TARGET}; \ 35 /bin/rm -rf ${.TARGET}; \ 36 ${_MKSHECHO} ${INSTALL_DIR} -o ${BINOWN} -g ${BINGRP} -m 755 \ 37 ${.TARGET}; \ 38 ${INSTALL_DIR} -o ${BINOWN} -g ${BINGRP} -m 755 \ 39 ${.TARGET}; \ 40 fi 41 42 __incinstall: .USE 43 @cmp -s ${.ALLSRC} ${.TARGET} > /dev/null 2>&1 || \ 44 (${_MKSHMSG_INSTALL} ${.TARGET}; \ 45 ${_MKSHECHO} "${INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} \ 46 -m ${NONBINMODE} ${.ALLSRC} ${.TARGET}" && \ 47 ${INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} \ 48 -m ${NONBINMODE} ${.ALLSRC} ${.TARGET}) 49 50 .for F in ${INCS:O:u} ${DEPINCS:O:u} 51 _F:= ${DESTDIR}${INCSDIR}/${F} # installed path 52 53 .if ${MKUPDATE} == "no" 54 ${_F}! ${F} __incinstall # install rule 55 .else 56 ${_F}: ${F} __incinstall # install rule 57 .endif 58 59 incinstall:: ${_F} 60 .PRECIOUS: ${_F} # keep if install fails 61 .endfor 62 63 .undef _F 64 65 .if defined(INCSYMLINKS) && !empty(INCSYMLINKS) 66 incinstall:: 67 @(set ${INCSYMLINKS}; \ 68 while test $$# -ge 2; do \ 69 l=$$1; shift; \ 70 t=${DESTDIR}$$1; shift; \ 71 if ttarg=$$(${TOOL_STAT} -qf '%Y' $$t) && \ 72 [ "$$l" = "$$ttarg" ]; then \ 73 continue ; \ 74 fi ; \ 75 ${_MKSHMSG_INSTALL} $$t; \ 76 ${_MKSHECHO} ${INSTALL_SYMLINK} $$l $$t; \ 77 ${INSTALL_SYMLINK} $$l $$t; \ 78 done; ) 79 .endif 80 81 ##### Pull in related .mk logic 82 .include <bsd.subdir.mk> 83 .include <bsd.sys.mk> 84