Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 15 Dec 1999 11:06:45 +0100
From:      Marcel Moolenaar <marcel@scc.nl>
To:        hackers@FreeBSD.org
Subject:   Re: Using make to allow parallel operations?
Message-ID:  <38576835.2BEC9E67@scc.nl>
References:  <3857041C.146D0F35@hiwaay.net>

next in thread | previous in thread | raw e-mail | index | archive | help
Kris Kirby wrote:

> In my project root, I have the following makefile:
> SUBDIR = 1 2 3 4 5 6 7 8 9
> .include <bsd.subdir.mk>

Assuming you have an `encode' target that you want to run in parallel;
you need something like:

.for entry in ${SUBDIR}
${entry}.encode__D: .PHONY
	@if test -d ${.CURDIR}/${entry}.${MACHINE_ARCH}; then \
		${ECHODIR} "===> ${DIRPRFX}${entry}.${MACHINE_ARCH}"; \
		edir=${entry}.${MACHINE_ARCH}; \
		cd ${.CURDIR}/$${edir}; \
	else \
		${ECHODIR} "===> ${DIRPRFX}${entry}"; \
		edir=${entry}; \
		cd ${.CURDIR}/$${edir}; \
	fi; \
	${MAKE} encode DIRPRFX=${DIRPRFX}$${edir}/
.endfor

par-encode: ${SUBDIR:S/$/.encode__D/}

(Taken from src/Makefile.inc1)

By having all the subdirs as dependencies for the par-encode target,
make will start doing them in parallel.

>         @for prog in ${OBJ} ; do \
>                 ${PROG} ${PAF}/$$prog ; \
>         done
> 
> I am thinking that the for loop is not the way to run things parallel,
> but I see no other option. This is a batch MP3 encode, not a compling
> run, but the concepts are similar (programs and thier arguments).

Correct. The for-loop is expanded before any targets are made. That's
why the normal use of SUBDIR is non-parallel; it's used in a for-loop.

-- 
Marcel Moolenaar                        mailto:marcel@scc.nl
SCC Internetworking & Databases           http://www.scc.nl/
The FreeBSD project                mailto:marcel@FreeBSD.org


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?38576835.2BEC9E67>