xref: /freebsd/share/mk/bsd.confs.mk (revision 734e82fe33aa764367791a7d603b383996c6b40b)
1
2.if !target(__<bsd.init.mk>__)
3.  error bsd.conf.mk cannot be included directly.
4.endif
5
6.if !target(__<bsd.confs.mk>__)
7.  if target(__<bsd.dirs.mk>__)
8.    error bsd.dirs.mk must be included after bsd.confs.mk.
9.  endif
10
11__<bsd.confs.mk>__:
12
13CONFGROUPS?=	CONFS
14
15.  if !target(buildconfig)
16.    for group in ${CONFGROUPS}
17buildconfig: ${${group}}
18.    endfor
19.  endif
20
21.  if !defined(_SKIP_BUILD)
22all: buildconfig
23.  endif
24
25.  for group in ${CONFGROUPS}
26.    if defined(${group}) && !empty(${group})
27
28.      if !target(afterinstallconfig)
29afterinstallconfig:
30.      endif
31.      if !target(beforeinstallconfig)
32beforeinstallconfig:
33.      endif
34installconfig:	beforeinstallconfig realinstallconfig afterinstallconfig
35.ORDER:		beforeinstallconfig realinstallconfig afterinstallconfig
36
37${group}OWN?=	${SHAREOWN}
38${group}GRP?=	${SHAREGRP}
39${group}MODE?=	${CONFMODE}
40${group}DIR?=	${CONFDIR}
41STAGE_SETS+=	${group:C,[/*],_,g}
42
43.      if defined(NO_ROOT)
44.        if !defined(${group}TAGS) || ! ${${group}TAGS:Mpackage=*}
45.          if defined(${group}PACKAGE)
46${group}TAGS+=		package=${${group}PACKAGE:Uutilities}
47.          else
48${group}TAGS+=		package=${PACKAGE:Uutilities}
49.          endif
50.        endif
51${group}TAGS+=		config
52${group}TAG_ARGS=	-T ${${group}TAGS:[*]:S/ /,/g}
53.      endif
54
55
56.      if ${${group}DIR:S/^\///} == ${${group}DIR}
57# ${group}DIR specifies a variable that specifies a path
58DIRS+=	${${group}DIR}
59_${group}DIR=	${${group}DIR}
60.      else
61# ${group}DIR specifies a path
62DIRS+=	${group}DIR
63_${group}DIR=	${group}DIR
64.      endif
65
66STAGE_DIR.${group:C,[/*],_,g}= ${STAGE_OBJTOP}${${_${group}DIR}}
67
68.      for cnf in ${${group}}
69${group}OWN_${cnf}?=	${${group}OWN}
70${group}GRP_${cnf}?=	${${group}GRP}
71${group}MODE_${cnf}?=	${${group}MODE}
72${group}DIR_${cnf}?=	${${group}DIR}
73.        if defined(${group}NAME)
74${group}NAME_${cnf}?=	${${group}NAME}
75.        else
76${group}NAME_${cnf}?=	${cnf:T}
77.        endif
78
79
80# Determine the directory for the current file.  Default to the parent group
81# DIR, then check to see how to pass that variable on below.
82${group}DIR_${cnf}?=	${${group}DIR}
83.        if ${${group}DIR_${cnf}:S/^\///} == ${${group}DIR_${cnf}}
84# DIR specifies a variable that specifies a path
85_${group}DIR_${cnf}=	${${group}DIR_${cnf}}
86.        else
87# DIR directly specifies a path
88_${group}DIR_${cnf}=	${group}DIR_${cnf}
89.        endif
90${group}PREFIX_${cnf}=	${DESTDIR}${${_${group}DIR_${cnf}}}
91
92# Append DIR to DIRS if not already in place -- DIRS is already filtered, so
93# this is primarily to ease inspection.
94.        for d in ${DIRS}
95_DIRS+=	${${d}}
96.        endfor
97.        if ${DIRS:M${_${group}DIR_${cnf}}} == ""
98.          if ${_DIRS:M${${_${group}DIR_${cnf}}}} == ""
99DIRS+=	${_${group}DIR_${cnf}}
100.          else
101_${group}DIR_${cnf}=	${group}DIR
102.          endif
103.        endif
104
105.        if defined(${group}NAME)
106${group}NAME_${cnf}?=	${${group}NAME}
107.        else
108${group}NAME_${cnf}?=	${cnf:T}
109.        endif # defined(${group}NAME)
110
111# Work around a bug with install(1) -C and /dev/null
112.        if ${cnf} == "/dev/null"
113INSTALL_COPY=
114.        else
115INSTALL_COPY=  -C
116.        endif
117
118STAGE_AS_SETS+= ${cnf:T}
119STAGE_AS_${cnf:T}= ${${group}NAME_${cnf:T}}
120# XXX {group}OWN,GRP,MODE
121STAGE_DIR.${cnf:T}= ${STAGE_OBJTOP}${${_${group}DIR_${cnf}}}
122stage_as.${cnf:T}: ${cnf}
123
124realinstallconfig: installdirs-${_${group}DIR_${cnf}} _${group}INS_${cnf:T}
125_${group}INS_${cnf:T}: ${cnf}
126	${INSTALL} ${${group}TAG_ARGS} ${INSTALL_COPY} -o ${${group}OWN_${cnf}} \
127	    -g ${${group}GRP_${cnf}} -m ${${group}MODE_${cnf}} \
128	    ${.ALLSRC} ${${group}PREFIX_${cnf}}/${${group}NAME_${cnf}}
129.      endfor # for cnf in ${${group}}
130
131.    endif # defined(${group}) && !empty(${group})
132.  endfor
133
134.if ${MK_STAGING} != "no"
135.  if !empty(STAGE_SETS)
136buildconfig: stage_files
137stage_files:
138.    if !empty(STAGE_AS_SETS)
139buildconfig: stage_as
140stage_as:
141.    endif
142.  endif
143.endif
144
145.endif # !target(__<bsd.confs.mk>__)
146