Home | History | Annotate | Line # | Download | only in mk
bsd.kinc.mk revision 1.35
      1 #	$NetBSD: bsd.kinc.mk,v 1.35 2004/01/29 01:48:45 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 # 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 			${SYSPKGTAG} ${.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 	    (${_MKSHMSG_INSTALL} ${.TARGET}; \
     46 	     ${_MKSHECHO} "${INSTALL_FILE} -c -o ${BINOWN} -g ${BINGRP} \
     47 		-m ${NONBINMODE} ${SYSPKGTAG} ${.ALLSRC} ${.TARGET}" && \
     48 	     ${INSTALL_FILE} -c -o ${BINOWN} -g ${BINGRP} \
     49 		-m ${NONBINMODE} ${SYSPKGTAG} ${.ALLSRC} ${.TARGET})
     50 
     51 .for F in ${INCS:O:u} ${DEPINCS:O:u}
     52 _F:=		${DESTDIR}${INCSDIR}/${F}		# installed path
     53 
     54 .if ${MKUPDATE} == "no"
     55 ${_F}!		${F} __incinstall			# install rule
     56 .else
     57 ${_F}:		${F} __incinstall			# install rule
     58 .endif
     59 
     60 incinstall::	${_F}
     61 .PRECIOUS:	${_F}					# keep if install fails
     62 .endfor
     63 
     64 .undef _F
     65 
     66 .if defined(INCSYMLINKS) && !empty(INCSYMLINKS)
     67 incinstall::
     68 	@(set ${INCSYMLINKS}; \
     69 	 while test $$# -ge 2; do \
     70 		l=$$1; shift; \
     71 		t=${DESTDIR}$$1; shift; \
     72 		if  ttarg=`${TOOL_STAT} -qf '%Y' $$t` && \
     73 		    [ "$$l" = "$$ttarg" ]; then \
     74 			continue ; \
     75 		fi ; \
     76 		${_MKSHMSG_INSTALL} $$t; \
     77 		${_MKSHECHO} ${INSTALL_SYMLINK} ${SYSPKGTAG} $$l $$t; \
     78 		${INSTALL_SYMLINK} ${SYSPKGTAG} $$l $$t; \
     79 	 done; )
     80 .endif
     81 
     82 ##### Pull in related .mk logic
     83 .include <bsd.subdir.mk>
     84 .include <bsd.sys.mk>
     85