1# $NetBSD: bsd.kinc.mk,v 1.25 2002/11/26 23:15:54 lukem 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# SYMLINKS 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.PHONY: incinstall 24includes: ${INCS} incinstall 25 26##### Install rules 27incinstall:: # ensure existence 28 29# make sure the directory is OK, and install includes. 30incinstall:: ${DESTDIR}${INCSDIR} 31.PRECIOUS: ${DESTDIR}${INCSDIR} 32.PHONY: ${DESTDIR}${INCSDIR} 33 34${DESTDIR}${INCSDIR}: 35 @if [ ! -d ${.TARGET} ] || [ -h ${.TARGET} ] ; then \ 36 echo creating ${.TARGET}; \ 37 /bin/rm -rf ${.TARGET}; \ 38 ${INSTALL_DIR} -o ${BINOWN} -g ${BINGRP} -m 755 \ 39 ${SYSPKGTAG} ${.TARGET}; \ 40 fi 41 42# -c is forced on here, in order to preserve modtimes for "make depend" 43__incinstall: .USE 44 @cmp -s ${.ALLSRC} ${.TARGET} > /dev/null 2>&1 || \ 45 (echo "${INSTALL_FILE:N-c} -c -o ${BINOWN} -g ${BINGRP} \ 46 -m ${NONBINMODE} ${SYSPKGTAG} ${.ALLSRC} ${.TARGET}" && \ 47 ${INSTALL_FILE:N-c} -c -o ${BINOWN} -g ${BINGRP} \ 48 -m ${NONBINMODE} ${SYSPKGTAG} ${.ALLSRC} ${.TARGET}) 49 50.for F in ${INCS:O:u} ${DEPINCS:O:u} 51_F:= ${DESTDIR}${INCSDIR}/${F} # installed path 52 53.if !defined(UPDATE) 54${_F}! ${F} __incinstall # install rule 55.else 56${_F}: ${F} __incinstall # install rule 57.endif 58 59incinstall:: ${_F} 60.PRECIOUS: ${_F} # keep if install fails 61.endfor 62 63.undef _F 64 65.if defined(SYMLINKS) && !empty(SYMLINKS) 66incinstall:: 67 @(set ${SYMLINKS}; \ 68 while test $$# -ge 2; do \ 69 l=$$1; shift; \ 70 t=${DESTDIR}$$1; shift; \ 71 if [ -h $$t ]; then \ 72 cur=`ls -ld $$t | awk '{print $$NF}'` ; \ 73 if [ "$$cur" = "$$l" ]; then \ 74 continue ; \ 75 fi; \ 76 fi; \ 77 echo "$$t -> $$l"; \ 78 ${INSTALL_SYMLINK} ${SYSPKGTAG} $$l $$t; \ 79 done; ) 80.endif 81 82##### Pull in related .mk logic 83.include <bsd.subdir.mk> 84