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