freebsd-dev/share/mk/bsd.files.mk
Ruslan Ermilov badb7c1c6b Try really hard to fix parallel installs. Add a bunch of .ORDER
directives to ensure that all realinstall sub-tasks are executed
after beforeinstall, similarly ensure that all afterinstall sub-
tasks are executed after realinstall.  Demonstration:

all: task1 task2
.ORDER: task1 task2

task2: task2_subtask
.ORDER: task1 task2_subtask

task1 task2 task2_subtask:
	@sleep `jot -r 1 0 1.0`
	@echo ${.TARGET}

Without the second .ORDER directive, task2_subtask can be run in
parallel with task1.

Spotted by:	Andrea Campi <andrea@webcom.it>
2002-07-03 12:28:03 +00:00

70 lines
1.8 KiB
Makefile

# $FreeBSD$
.if !target(__<bsd.init.mk>__)
.error bsd.files.mk cannot be included directly.
.endif
FILESGROUPS?= FILES
.if !target(buildfiles)
.for group in ${FILESGROUPS}
buildfiles: ${${group}}
.endfor
.endif
all: buildfiles
.if !target(installfiles)
.for group in ${FILESGROUPS}
.if defined(${group}) && !empty(${group})
${group}OWN?= ${SHAREOWN}
${group}GRP?= ${SHAREGRP}
${group}MODE?= ${SHAREMODE}
${group}DIR?= ${BINDIR}
_${group}FILES=
.for file in ${${group}}
.if defined(${group}OWN_${file:T}) || defined(${group}GRP_${file:T}) || \
defined(${group}MODE_${file:T}) || defined(${group}DIR_${file:T}) || \
defined(${group}NAME_${file:T})
${group}OWN_${file:T}?= ${${group}OWN}
${group}GRP_${file:T}?= ${${group}GRP}
${group}MODE_${file:T}?= ${${group}MODE}
${group}DIR_${file:T}?= ${${group}DIR}
.if defined(${group}NAME)
${group}NAME_${file:T}?= ${${group}NAME}
.else
${group}NAME_${file:T}?= ${file:T}
.endif
installfiles: _${group}INS_${file:T}
_${group}INS_${file:T}: ${file}
${INSTALL} ${COPY} -o ${${group}OWN_${.ALLSRC:T}} \
-g ${${group}GRP_${.ALLSRC:T}} -m ${${group}MODE_${.ALLSRC:T}} \
${.ALLSRC} \
${DESTDIR}${${group}DIR_${.ALLSRC:T}}/${${group}NAME_${.ALLSRC:T}}
.else
_${group}FILES+= ${file}
.endif
.endfor
.if !empty(_${group}FILES)
installfiles: _${group}INS
_${group}INS: ${_${group}FILES}
.if defined(${group}NAME)
${INSTALL} ${COPY} -o ${${group}OWN} -g ${${group}GRP} \
-m ${${group}MODE} ${.ALLSRC} \
${DESTDIR}${${group}DIR}/${${group}NAME}
.else
${INSTALL} ${COPY} -o ${${group}OWN} -g ${${group}GRP} \
-m ${${group}MODE} ${.ALLSRC} ${DESTDIR}${${group}DIR}
.endif
.endif
.endif defined(${group}) && !empty(${group})
.endfor
.endif !target(installfiles)
realinstall: installfiles
.ORDER: beforeinstall installfiles