1# $NetBSD: bsd.kinc.mk,v 1.22 2002/02/11 21:14:59 mycroft Exp $ 2 3# System configuration variables: 4# 5# SYS_INCLUDE "symlinks": symlinks to include directories are created. 6# This may not work 100% properly for all headers. 7# 8# "copies": directories are made, if necessary, and headers 9# are installed into them. 10# 11# Variables: 12# 13# INCSDIR Directory to install includes into (and/or make, and/or 14# symlink, depending on what's going on). 15# 16# KDIR Kernel directory to symlink to, if SYS_INCLUDE is symlinks. 17# If unspecified, no action will be taken when making include 18# for the directory if SYS_INCLUDE is symlinks. 19# 20# INCS Headers to install, if SYS_INCLUDE is copies. 21# 22# DEPINCS Headers to install which are built dynamically. 23# 24# SUBDIR Subdirectories to enter 25# 26# SYMLINKS Symlinks to make (unconditionally), a la bsd.links.mk. 27# Note that the original bits will be 'rm -rf'd rather than 28# just 'rm -f'd, to make the right thing happen with include 29# directories. 30# 31 32.include <bsd.init.mk> 33 34##### Basic targets 35.PHONY: incinstall 36includes: ${INCS} incinstall 37 38##### Default values 39# Change SYS_INCLUDE in bsd.own.mk or /etc/mk.conf to "symlinks" if you 40# don't want copies 41SYS_INCLUDE?= copies 42 43# If DESTDIR is set, we're probably building a release, so force "copies". 44.if defined(DESTDIR) && (${DESTDIR} != "/" && !empty(DESTDIR)) 45SYS_INCLUDE= copies 46.endif 47 48##### Install rules 49incinstall:: # ensure existence 50 51.if ${SYS_INCLUDE} == "symlinks" 52 53# don't install includes, just make symlinks. 54.if defined(KDIR) 55SYMLINKS+= ${KDIR} ${INCSDIR} 56.endif 57 58.else # ${SYS_INCLUDE} != "symlinks" 59 60# make sure the directory is OK, and install includes. 61incinstall:: ${DESTDIR}${INCSDIR} 62.PRECIOUS: ${DESTDIR}${INCSDIR} 63.PHONY: ${DESTDIR}${INCSDIR} 64 65${DESTDIR}${INCSDIR}: 66 @if [ ! -d ${.TARGET} ] || [ -h ${.TARGET} ] ; then \ 67 echo creating ${.TARGET}; \ 68 /bin/rm -rf ${.TARGET}; \ 69 ${INSTALL_DIR} -o ${BINOWN} -g ${BINGRP} -m 755 ${.TARGET}; \ 70 fi 71 72# -c is forced on here, in order to preserve modtimes for "make depend" 73__incinstall: .USE 74 @cmp -s ${.ALLSRC} ${.TARGET} > /dev/null 2>&1 || \ 75 (echo "${INSTALL_FILE:N-c} -c -o ${BINOWN} -g ${BINGRP} \ 76 -m ${NONBINMODE} ${.ALLSRC} ${.TARGET}" && \ 77 ${INSTALL_FILE:N-c} -c -o ${BINOWN} -g ${BINGRP} \ 78 -m ${NONBINMODE} ${.ALLSRC} ${.TARGET}) 79 80.for F in ${INCS:O:u} ${DEPINCS:O:u} 81_F:= ${DESTDIR}${INCSDIR}/${F} # installed path 82 83.if !defined(UPDATE) 84${_F}! ${F} __incinstall # install rule 85.else 86${_F}: ${F} __incinstall # install rule 87.endif 88 89incinstall:: ${_F} 90.PRECIOUS: ${_F} # keep if install fails 91.endfor 92 93.undef _F 94 95.endif # ${SYS_INCLUDE} ?= "symlinks" 96 97.if defined(SYMLINKS) && !empty(SYMLINKS) 98incinstall:: 99 @(set ${SYMLINKS}; \ 100 while test $$# -ge 2; do \ 101 l=$$1; shift; \ 102 t=${DESTDIR}$$1; shift; \ 103 if [ -h $$t ]; then \ 104 cur=`ls -ld $$t | awk '{print $$NF}'` ; \ 105 if [ "$$cur" = "$$l" ]; then \ 106 continue ; \ 107 fi; \ 108 fi; \ 109 echo "$$t -> $$l"; \ 110 rm -rf $$t; ${INSTALL_SYMLINK} $$l $$t; \ 111 done; ) 112.endif 113 114##### Pull in related .mk logic 115.include <bsd.subdir.mk> 116