Home | History | Annotate | Line # | Download | only in mk
bsd.kinc.mk revision 1.4
      1 #	$NetBSD: bsd.kinc.mk,v 1.4 1999/01/15 10:57:36 castor 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 .PRECIOUS: ${DESTDIR}${INCSDIR}
     68 .PHONY: ${DESTDIR}${INCSDIR}
     69 ${DESTDIR}${INCSDIR}:
     70 	@if [ ! -d ${.TARGET} ] || [ -L ${.TARGET} ] ; then \
     71 		echo creating ${.TARGET}; \
     72 		/bin/rm -rf ${.TARGET}; \
     73 		${INSTALL} -d -o ${BINOWN} -g ${BINGRP} -m 755 ${.TARGET}; \
     74 	fi
     75 
     76 incinstall:: ${DESTDIR}${INCSDIR}
     77 
     78 .if defined(INCS)
     79 .for I in ${INCS}
     80 incinstall:: ${DESTDIR}${INCSDIR}/$I
     81 
     82 .PRECIOUS: ${DESTDIR}${INCSDIR}/$I
     83 .if !defined(UPDATE)
     84 .PHONY: ${DESTDIR}${INCSDIR}/$I
     85 .endif
     86 ${DESTDIR}${INCSDIR}/$I: ${DESTDIR}${INCSDIR} $I 
     87 	@cmp -s ${.CURDIR}/$I ${.TARGET} > /dev/null 2>&1 || \
     88 	    (echo "${INSTALL} ${PRESERVE} -c -o ${BINOWN} -g ${BINGRP} \
     89 		-m ${NONBINMODE} ${.CURDIR}/$I ${.TARGET}" && \
     90 	     ${INSTALL} ${PRESERVE} -c -o ${BINOWN} -g ${BINGRP} \
     91 		-m ${NONBINMODE} ${.CURDIR}/$I ${.TARGET})
     92 .endfor
     93 .endif
     94 
     95 .if defined(DEPINCS)
     96 .for I in ${DEPINCS}
     97 incinstall:: ${DESTDIR}${INCSDIR}/$I
     98 
     99 .PRECIOUS: ${DESTDIR}${INCSDIR}/$I
    100 .if !defined(UPDATE)
    101 .PHONY: ${DESTDIR}${INCSDIR}/$I
    102 .endif
    103 ${DESTDIR}${INCSDIR}/$I: ${DESTDIR}${INCSDIR} $I 
    104 	@cmp -s $I ${.TARGET} > /dev/null 2>&1 || \
    105 	    (echo "${INSTALL} ${PRESERVE} -c -o ${BINOWN} -g ${BINGRP} \
    106 		-m ${NONBINMODE} $I ${.TARGET}" && \
    107 	     ${INSTALL} ${PRESERVE} -c -o ${BINOWN} -g ${BINGRP} \
    108 		-m ${NONBINMODE} $I ${.TARGET})
    109 .endfor
    110 .endif
    111 
    112 .endif # not symlinks
    113 
    114 .if defined(SYMLINKS) && !empty(SYMLINKS)
    115 incinstall::
    116 	@set ${SYMLINKS}; \
    117 	 while test $$# -ge 2; do \
    118 		l=$$1; \
    119 		shift; \
    120 		t=${DESTDIR}$$1; \
    121 		shift; \
    122 		echo ".include <bsd.own.mk>"; \
    123 		echo "all:: $$t"; \
    124 		echo ".PHONY: $$t"; \
    125 		echo "$$t:"; \
    126 		echo "	@echo \"$$t -> $$l\""; \
    127 		echo "	@rm -rf $$t"; \
    128 		echo "	@ln -s $$l $$t"; \
    129 	done | ${MAKE} -f-
    130 .endif
    131 
    132 .if !target(incinstall)
    133 incinstall::
    134 .endif
    135 
    136 .include <bsd.subdir.mk>
    137