vendor/bmake: upgrade from 20160818 to 20200710
[dragonfly.git] / contrib / bmake / mk / inc.mk
1 # $Id: inc.mk,v 1.7 2017/05/06 17:29:45 sjg Exp $
2 #
3 #       @(#) Copyright (c) 2008, Simon J. Gerraty
4 #
5 #       This file is provided in the hope that it will
6 #       be of use.  There is absolutely NO WARRANTY.
7 #       Permission to copy, redistribute or otherwise
8 #       use this file is hereby granted provided that 
9 #       the above copyright notice and this notice are
10 #       left intact. 
11 #      
12 #       Please send copies of changes and bug-fixes to:
13 #       sjg@crufty.net
14 #
15
16 .include <init.mk>
17
18 .if !empty(LIBOWN)
19 INC_INSTALL_OWN ?= -o ${LIBOWN} -g ${LIBGRP}
20 .endif
21 INCMODE ?= 444
22 INC_COPY ?= -C
23 INCSDIR ?= ${INCDIR}
24
25 STAGE_INCSDIR?= ${STAGE_OBJTOP}${INCSDIR}
26
27 # accommodate folk used to freebsd
28 INCGROUPS ?= ${INCSGROUPS:UINCS}
29 INCGROUPS := ${INCGROUPS:O:u}
30
31 .if !target(buildincludes)
32 .for group in ${INCGROUPS}
33 buildincludes: ${${group}}
34 .endfor
35 .endif
36 buildincludes:
37 includes: buildincludes
38
39 .if !target(incinstall)
40 .for group in ${INCGROUPS}
41 .if !empty(${group})
42 .if ${group} != "INC"
43 ${group}_INSTALL_OWN ?= ${INC_INSTALL_OWN}
44 ${group}DIR ?= ${INCDIR}
45 .endif
46 # incase we are staging
47 STAGE_DIR.${group} ?= ${STAGE_OBJTOP}${${group}DIR}
48
49 .for header in ${${group}:O:u}
50 ${group}_INSTALL_OWN.${header:T} ?= ${${group}_INSTALL_OWN}
51 ${group}DIR.${header:T} ?= ${${group}DIR}
52 inc_mkdir_list += ${${group}DIR.${header:T}}
53
54 .if defined(${group}NAME.${header:T})
55 STAGE_AS_SETS += ${group}
56 STAGE_AS_${header} = ${${group}NAME.${header:T}}
57 stage_as.${group}: ${header}
58
59 incinstall: incinstall.${group}.${header:T}
60 incinstall.${group}.${header:T}: ${header} inc_mkdirs
61         ${INSTALL} ${INC_COPY} ${${group}_INSTALL_OWN.${header:T}} -m ${INCMODE} ${.ALLSRC:Ninc_mkdirs} ${DESTDIR}${${group}DIR}/${${group}NAME.${header:T}}
62
63 .else
64 STAGE_SETS += ${group}
65 stage_files.${group}: ${header}
66 incinstall.${group}: ${header}
67 incinstall: incinstall.${group}
68 .endif
69
70 .endfor                         # header
71
72 incinstall.${group}: inc_mkdirs
73         ${INSTALL} ${INC_COPY} ${${group}_INSTALL_OWN} -m ${INCMODE} \
74         ${.ALLSRC:Ninc_mkdirs:O:u} ${DESTDIR}${${group}DIR}
75
76 .endif                          # !empty
77 .endfor                         # group
78
79 inc_mkdirs:
80         @for d in ${inc_mkdir_list:O:u}; do \
81                 test -d ${DESTDIR}$$d || \
82                 ${INSTALL} -d ${INC_INSTALL_OWN} -m 775 ${DESTDIR}$$d; \
83         done
84
85 .endif                          # !target(incinstall)
86
87 beforeinstall:
88 realinstall:    incinstall
89 .ORDER: beforeinstall incinstall