xref: /freebsd/share/mk/bsd.confs.mk (revision 0f5ed3c427fff845797c2af2aeceb5855f32a4f4)
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>__:	.NOTMAIN
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# Take groups from both CONFGROUPS and CONFGROUPS.yes, to allow syntax like
26# CONFGROUPS.${MK_FOO}=FOO.  Sort and uniq the list of groups in case of
27# duplicates.
28.if defined(CONFGROUPS) || defined(CONFGROUPS.yes)
29CONFGROUPS:=${CONFGROUPS} ${CONFGROUPS.yes}
30CONFGROUPS:=${CONFGROUPS:O:u}
31.endif
32
33.  for group in ${CONFGROUPS}
34.    if defined(${group}) && !empty(${group})
35
36.      if !target(afterinstallconfig)
37afterinstallconfig:
38.      endif
39.      if !target(beforeinstallconfig)
40beforeinstallconfig:
41.      endif
42installconfig:	beforeinstallconfig realinstallconfig afterinstallconfig
43.ORDER:		beforeinstallconfig realinstallconfig afterinstallconfig
44
45${group}OWN?=	${SHAREOWN}
46${group}GRP?=	${SHAREGRP}
47${group}MODE?=	${CONFMODE}
48${group}DIR?=	${CONFDIR}
49STAGE_SETS+=	${group:C,[/*],_,g}
50
51.      if defined(NO_ROOT)
52.        if !defined(${group}TAGS) || ! ${${group}TAGS:Mpackage=*}
53.          if defined(${group}PACKAGE)
54${group}TAGS+=		package=${${group}PACKAGE:Uutilities}
55.          else
56${group}TAGS+=		package=${PACKAGE:Uutilities}
57.          endif
58.        endif
59${group}TAGS+=		config
60${group}TAG_ARGS=	-T ${${group}TAGS:ts,:[*]}
61.      endif
62
63
64.      if ${${group}DIR:S/^\///} == ${${group}DIR}
65# ${group}DIR specifies a variable that specifies a path
66DIRS+=	${${group}DIR}
67_${group}DIR=	${${group}DIR}
68.      else
69# ${group}DIR specifies a path
70DIRS+=	${group}DIR
71_${group}DIR=	${group}DIR
72.      endif
73
74STAGE_DIR.${group:C,[/*],_,g}= ${STAGE_OBJTOP}${${_${group}DIR}}
75
76.      for cnf in ${${group}}
77${group}OWN_${cnf}?=	${${group}OWN}
78${group}GRP_${cnf}?=	${${group}GRP}
79${group}MODE_${cnf}?=	${${group}MODE}
80${group}DIR_${cnf}?=	${${group}DIR}
81.        if defined(${group}NAME)
82${group}NAME_${cnf}?=	${${group}NAME}
83.        else
84${group}NAME_${cnf}?=	${cnf:T}
85.        endif
86
87
88# Determine the directory for the current file.  Default to the parent group
89# DIR, then check to see how to pass that variable on below.
90${group}DIR_${cnf}?=	${${group}DIR}
91.        if ${${group}DIR_${cnf}:S/^\///} == ${${group}DIR_${cnf}}
92# DIR specifies a variable that specifies a path
93_${group}DIR_${cnf}=	${${group}DIR_${cnf}}
94.        else
95# DIR directly specifies a path
96_${group}DIR_${cnf}=	${group}DIR_${cnf}
97.        endif
98${group}PREFIX_${cnf}=	${DESTDIR}${${_${group}DIR_${cnf}}}
99
100# Append DIR to DIRS if not already in place -- DIRS is already filtered, so
101# this is primarily to ease inspection.
102.        for d in ${DIRS}
103_DIRS+=	${${d}}
104.        endfor
105.        if ${DIRS:M${_${group}DIR_${cnf}}} == ""
106.          if ${_DIRS:M${${_${group}DIR_${cnf}}}} == ""
107DIRS+=	${_${group}DIR_${cnf}}
108.          else
109_${group}DIR_${cnf}=	${group}DIR
110.          endif
111.        endif
112
113.        if defined(${group}NAME)
114${group}NAME_${cnf}?=	${${group}NAME}
115.        else
116${group}NAME_${cnf}?=	${cnf:T}
117.        endif # defined(${group}NAME)
118
119# Work around a bug with install(1) -C and /dev/null
120.        if ${cnf} == "/dev/null"
121INSTALL_COPY=
122.        else
123INSTALL_COPY=  -C
124.        endif
125
126STAGE_AS_SETS+= ${cnf:T}
127STAGE_AS_${cnf:T}= ${${group}NAME_${cnf:T}}
128# XXX {group}OWN,GRP,MODE
129STAGE_DIR.${cnf:T}= ${STAGE_OBJTOP}${${_${group}DIR_${cnf}}}
130stage_as.${cnf:T}: ${cnf}
131
132realinstallconfig: installdirs-${_${group}DIR_${cnf}} _${group}INS_${cnf:T}
133_${group}INS_${cnf:T}: ${cnf}
134	${INSTALL} ${${group}TAG_ARGS} ${INSTALL_COPY} -o ${${group}OWN_${cnf}} \
135	    -g ${${group}GRP_${cnf}} -m ${${group}MODE_${cnf}} \
136	    ${.ALLSRC} ${${group}PREFIX_${cnf}}/${${group}NAME_${cnf}}
137.      endfor # for cnf in ${${group}}
138
139.    endif # defined(${group}) && !empty(${group})
140.  endfor
141
142.if ${MK_STAGING} != "no"
143.  if !empty(STAGE_SETS)
144buildconfig: stage_files
145stage_files:
146.    if !empty(STAGE_AS_SETS)
147buildconfig: stage_as
148stage_as:
149.    endif
150.  endif
151.endif
152
153.endif # !target(__<bsd.confs.mk>__)
154