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