Home | History | Annotate | Line # | Download | only in mk
bsd.kinc.mk revision 1.16
      1 #	$NetBSD: bsd.kinc.mk,v 1.16 2000/06/06 09:53:30 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 .if !target(__initialized__)
     33 __initialized__:
     34 .if exists(${.CURDIR}/../Makefile.inc)
     35 .include "${.CURDIR}/../Makefile.inc"
     36 .endif
     37 .include <bsd.own.mk>
     38 .MAIN:		all
     39 .endif
     40 
     41 # Change SYS_INCLUDE in bsd.own.mk or /etc/mk.conf to "symlinks" if you
     42 # don't want copies
     43 SYS_INCLUDE?=	copies
     44 
     45 # If DESTDIR is set, we're probably building a release, so force "copies".
     46 .if defined(DESTDIR) && (${DESTDIR} != "/" && !empty(DESTDIR))
     47 SYS_INCLUDE=	copies
     48 .endif
     49 
     50 
     51 .PHONY:		incinstall
     52 includes:	${INCS} incinstall
     53 
     54 
     55 .if ${SYS_INCLUDE} == "symlinks"
     56 
     57 # don't install includes, just make symlinks.
     58 
     59 .if defined(KDIR)
     60 SYMLINKS+=	${KDIR} ${INCSDIR}
     61 .endif
     62 
     63 .else # not symlinks
     64 
     65 # make sure the directory is OK, and install includes.
     66 
     67 incinstall:: ${DESTDIR}${INCSDIR}
     68 .PRECIOUS: ${DESTDIR}${INCSDIR}
     69 .PHONY: ${DESTDIR}${INCSDIR}
     70 
     71 ${DESTDIR}${INCSDIR}:
     72 	@if [ ! -d ${.TARGET} ] || [ -h ${.TARGET} ] ; then \
     73 		echo creating ${.TARGET}; \
     74 		/bin/rm -rf ${.TARGET}; \
     75 		${INSTALL} ${INSTPRIV} -d -o ${BINOWN} -g ${BINGRP} -m 755 \
     76 		    ${.TARGET}; \
     77 	fi
     78 
     79 .if defined(INCS)
     80 incinstall:: ${INCS:@I@${DESTDIR}${INCSDIR}/$I@}
     81 .PRECIOUS: ${INCS:@I@${DESTDIR}${INCSDIR}/$I@}
     82 .if !defined(UPDATE)
     83 .PHONY: ${INCS:@I@${DESTDIR}${INCSDIR}/$I@}
     84 .endif
     85 
     86 __incinstall: .USE
     87 	@cmp -s ${.ALLSRC} ${.TARGET} > /dev/null 2>&1 || \
     88 	    (echo "${INSTALL} ${RENAME} ${PRESERVE} ${INSTPRIV} -c \
     89 		-o ${BINOWN} -g ${BINGRP} -m ${NONBINMODE} ${.ALLSRC} \
     90 		${.TARGET}" && \
     91 	     ${INSTALL} ${RENAME} ${PRESERVE} ${INSTPRIV} -c -o ${BINOWN} \
     92 		-g ${BINGRP} -m ${NONBINMODE} ${.ALLSRC} ${.TARGET})
     93 
     94 .for I in ${INCS}
     95 ${DESTDIR}${INCSDIR}/$I: $I __incinstall
     96 .endfor
     97 .endif
     98 
     99 .if defined(DEPINCS)
    100 incinstall:: ${DEPINCS:@I@${DESTDIR}${INCSDIR}/$I@}
    101 .PRECIOUS: ${DEPINCS:@I@${DESTDIR}${INCSDIR}/$I@}
    102 .if !defined(UPDATE)
    103 .PHONY: ${DEPINCS:@I@${DESTDIR}${INCSDIR}/$I@}
    104 .endif
    105 
    106 __depincinstall: .USE
    107 	@cmp -s ${.ALLSRC} ${.TARGET} > /dev/null 2>&1 || \
    108 	    (echo "${INSTALL} ${RENAME} ${PRESERVE} -c -o ${BINOWN} \
    109 		-g ${BINGRP} -m ${NONBINMODE} ${.ALLSRC} ${.TARGET}" && \
    110 	     ${INSTALL} ${RENAME} ${PRESERVE} -c -o ${BINOWN} -g ${BINGRP} \
    111 		-m ${NONBINMODE} ${.ALLSRC} ${.TARGET})
    112 
    113 .for I in ${DEPINCS}
    114 ${DESTDIR}${INCSDIR}/$I: $I __depincinstall
    115 .endfor
    116 .endif
    117 
    118 .endif # not symlinks
    119 
    120 .if defined(SYMLINKS) && !empty(SYMLINKS)
    121 incinstall::
    122 	@(set ${SYMLINKS}; \
    123 	 while test $$# -ge 2; do \
    124 		l=$$1; \
    125 		shift; \
    126 		t=${DESTDIR}$$1; \
    127 		shift; \
    128 		if [ -L $$t ]; then \
    129 			cur=`ls -ld $$t | awk '{print $$NF}'` ; \
    130 			if [ "$$cur" = "$$l" ]; then \
    131 				continue ; \
    132 			fi; \
    133 		fi; \
    134 		echo "$$t -> $$l"; \
    135 		rm -rf $$t; ln -s $$l $$t; \
    136 	 done; )
    137 .endif
    138 
    139 .if !target(incinstall)
    140 incinstall::
    141 .endif
    142 
    143 .include <bsd.subdir.mk>
    144