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