Home | History | Annotate | Line # | Download | only in mk
bsd.kinc.mk revision 1.24
      1  1.24     perry #	$NetBSD: bsd.kinc.mk,v 1.24 2002/10/22 18:48:27 perry Exp $
      2   1.1       cgd 
      3   1.1       cgd # System configuration variables:
      4   1.1       cgd #
      5   1.1       cgd # SYS_INCLUDE	"symlinks": symlinks to include directories are created.
      6   1.1       cgd #		This may not work 100% properly for all headers.
      7   1.1       cgd #
      8   1.1       cgd #		"copies": directories are made, if necessary, and headers
      9   1.1       cgd #		are installed into them.
     10   1.1       cgd #
     11   1.1       cgd # Variables:
     12   1.1       cgd #
     13   1.1       cgd # INCSDIR	Directory to install includes into (and/or make, and/or
     14   1.1       cgd #		symlink, depending on what's going on).
     15   1.1       cgd #
     16   1.1       cgd # KDIR		Kernel directory to symlink to, if SYS_INCLUDE is symlinks.
     17   1.1       cgd #		If unspecified, no action will be taken when making include
     18   1.1       cgd #		for the directory if SYS_INCLUDE is symlinks.
     19   1.1       cgd #
     20   1.1       cgd # INCS		Headers to install, if SYS_INCLUDE is copies.
     21   1.1       cgd #
     22   1.4    castor # DEPINCS	Headers to install which are built dynamically.
     23   1.4    castor #
     24   1.1       cgd # SUBDIR	Subdirectories to enter
     25   1.1       cgd #
     26   1.1       cgd # SYMLINKS	Symlinks to make (unconditionally), a la bsd.links.mk.
     27   1.1       cgd #		Note that the original bits will be 'rm -rf'd rather than
     28   1.1       cgd #		just 'rm -f'd, to make the right thing happen with include
     29   1.1       cgd #		directories.
     30   1.1       cgd #
     31   1.1       cgd 
     32  1.19        tv .include <bsd.init.mk>
     33  1.19        tv 
     34  1.19        tv ##### Basic targets
     35  1.19        tv .PHONY:		incinstall
     36  1.19        tv includes:	${INCS} incinstall
     37   1.1       cgd 
     38  1.19        tv ##### Default values
     39   1.1       cgd # Change SYS_INCLUDE in bsd.own.mk or /etc/mk.conf to "symlinks" if you
     40   1.1       cgd # don't want copies
     41  1.13    simonb SYS_INCLUDE?=	copies
     42   1.1       cgd 
     43   1.1       cgd # If DESTDIR is set, we're probably building a release, so force "copies".
     44   1.1       cgd .if defined(DESTDIR) && (${DESTDIR} != "/" && !empty(DESTDIR))
     45  1.13    simonb SYS_INCLUDE=	copies
     46   1.1       cgd .endif
     47   1.1       cgd 
     48  1.19        tv ##### Install rules
     49  1.19        tv incinstall::	# ensure existence
     50   1.1       cgd 
     51   1.1       cgd .if ${SYS_INCLUDE} == "symlinks"
     52   1.1       cgd 
     53   1.1       cgd # don't install includes, just make symlinks.
     54   1.1       cgd .if defined(KDIR)
     55   1.1       cgd SYMLINKS+=	${KDIR} ${INCSDIR}
     56   1.1       cgd .endif
     57   1.1       cgd 
     58  1.19        tv .else # ${SYS_INCLUDE} != "symlinks"
     59   1.1       cgd 
     60   1.1       cgd # make sure the directory is OK, and install includes.
     61  1.19        tv incinstall::	${DESTDIR}${INCSDIR}
     62  1.19        tv .PRECIOUS:	${DESTDIR}${INCSDIR}
     63  1.19        tv .PHONY:		${DESTDIR}${INCSDIR}
     64  1.15   mycroft 
     65   1.1       cgd ${DESTDIR}${INCSDIR}:
     66   1.7    kleink 	@if [ ! -d ${.TARGET} ] || [ -h ${.TARGET} ] ; then \
     67   1.1       cgd 		echo creating ${.TARGET}; \
     68   1.1       cgd 		/bin/rm -rf ${.TARGET}; \
     69  1.24     perry 		${INSTALL_DIR} -o ${BINOWN} -g ${BINGRP} -m 755 \
     70  1.24     perry 			${SYSPKGTAG} ${.TARGET}; \
     71   1.1       cgd 	fi
     72   1.1       cgd 
     73  1.19        tv # -c is forced on here, in order to preserve modtimes for "make depend"
     74  1.16   mycroft __incinstall: .USE
     75  1.16   mycroft 	@cmp -s ${.ALLSRC} ${.TARGET} > /dev/null 2>&1 || \
     76  1.19        tv 	    (echo "${INSTALL_FILE:N-c} -c -o ${BINOWN} -g ${BINGRP} \
     77  1.24     perry 		-m ${NONBINMODE} ${SYSPKGTAG} ${.ALLSRC} ${.TARGET}" && \
     78  1.19        tv 	     ${INSTALL_FILE:N-c} -c -o ${BINOWN} -g ${BINGRP} \
     79  1.24     perry 		-m ${NONBINMODE} ${SYSPKGTAG} ${.ALLSRC} ${.TARGET})
     80  1.19        tv 
     81  1.19        tv .for F in ${INCS:O:u} ${DEPINCS:O:u}
     82  1.19        tv _F:=		${DESTDIR}${INCSDIR}/${F}		# installed path
     83  1.16   mycroft 
     84  1.22   mycroft .if !defined(UPDATE)
     85  1.22   mycroft ${_F}!		${F} __incinstall			# install rule
     86  1.22   mycroft .else
     87  1.19        tv ${_F}:		${F} __incinstall			# install rule
     88  1.22   mycroft .endif
     89  1.22   mycroft 
     90  1.19        tv incinstall::	${_F}
     91  1.19        tv .PRECIOUS:	${_F}					# keep if install fails
     92   1.4    castor .endfor
     93   1.4    castor 
     94  1.19        tv .undef _F
     95  1.14   mycroft 
     96  1.19        tv .endif # ${SYS_INCLUDE} ?= "symlinks"
     97   1.1       cgd 
     98   1.1       cgd .if defined(SYMLINKS) && !empty(SYMLINKS)
     99   1.1       cgd incinstall::
    100  1.10  drochner 	@(set ${SYMLINKS}; \
    101   1.1       cgd 	 while test $$# -ge 2; do \
    102  1.19        tv 		l=$$1; shift; \
    103  1.19        tv 		t=${DESTDIR}$$1; shift; \
    104  1.17       cgd 		if [ -h $$t ]; then \
    105  1.12    simonb 			cur=`ls -ld $$t | awk '{print $$NF}'` ; \
    106  1.12    simonb 			if [ "$$cur" = "$$l" ]; then \
    107  1.12    simonb 				continue ; \
    108  1.12    simonb 			fi; \
    109  1.12    simonb 		fi; \
    110  1.12    simonb 		echo "$$t -> $$l"; \
    111  1.24     perry 		${INSTALL_SYMLINK} ${SYSPKGTAG} $$l $$t; \
    112  1.12    simonb 	 done; )
    113   1.1       cgd .endif
    114   1.1       cgd 
    115  1.19        tv ##### Pull in related .mk logic
    116   1.1       cgd .include <bsd.subdir.mk>
    117