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