Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 13 Nov 2000 19:51:11 +0900
From:      Makoto MATSUSHITA <matusita@jp.FreeBSD.org>
To:        bde@zeta.org.au
Cc:        current@FreeBSD.ORG, stable@FreeBSD.ORG
Subject:   Re: "make modules" kicks the first module directory twice
Message-ID:  <20001113195111R.matusita@jp.FreeBSD.org>
In-Reply-To: <Pine.BSF.4.21.0011131953001.646-100000@besplex.bde.org>
References:  <3A0F9ED8.A56CA34E@cup.hp.com> <Pine.BSF.4.21.0011131953001.646-100000@besplex.bde.org>

next in thread | previous in thread | raw e-mail | index | archive | help

bde> (In the above example, the targets are built concurrently and race
bde> each other.  This is bad when the `all' target wins the race.  The
bde> `obj' target runs faster, so it usually wins the race except in the
bde> first directory (3dfx)).  More .ORDER statements in *.mk are required.

Thank you for giving us a details of this problem. But can we fix this
problem with .ORDER statements? Putting ".ORDER: obj all" or alike to
Makefile doesn't fix to me (maybe I misunderstand the usage of .ORDER
statement)...

bde> `&&' should never be used in shell commands in makefiles, although it
bde> may be only a bad example.  This is because multiple commands are
bde> executed in the same shell in the -j case, and `&&' gives non-simple
bde> commands which may defeat the shell's -e setting.

What should we do if we want to check the existence of a directory and
kick one (not two or more) command after chdir to that directory? Much
Makefiles in our FreeBSD repository employ "cd ${dir} && command" to
do this... Should we say

	if [ -d ${dir} ]; then \
		(cd ${dir}; command) \
	else
		false
	fi	

or exist() directive of make(1) ?

***

Anyway, attached below is current sample patch to fix this problem.
"make obj" and "make all" are separated to two individual commands
(redundant 'cd' clause, but it should work).

-- -
Makoto `MAR' MATSUSHITA

Index: Makefile
===================================================================
RCS file: /lab/FreeBSD/FreeBSD.cvs/src/release/Makefile,v
retrieving revision 1.585
diff -c -r1.585 Makefile
*** Makefile	2000/11/12 11:04:11	1.585
--- Makefile	2000/11/13 05:37:12
***************
*** 831,837 ****
  	@rm -f ${RD}/kernels/*.ko
  	@cd ${.CURDIR}/../sys/${MACHINE}/conf && config ${KERNEL}
  	@cd ${.CURDIR}/../sys/compile/${KERNEL} && \
! 			make kernel-depend && \
  			make ${KERNEL_FLAGS} modules && \
  			make modules-reinstall DESTDIR=${RD}/kernels && \
  
--- 831,837 ----
  	@rm -f ${RD}/kernels/*.ko
  	@cd ${.CURDIR}/../sys/${MACHINE}/conf && config ${KERNEL}
  	@cd ${.CURDIR}/../sys/compile/${KERNEL} && \
! 			make modules-depend && \
  			make ${KERNEL_FLAGS} modules && \
  			make modules-reinstall DESTDIR=${RD}/kernels && \
  
Index: Makefile.alpha
===================================================================
RCS file: /lab/FreeBSD/FreeBSD.cvs/src/sys/conf/Makefile.alpha,v
retrieving revision 1.79
diff -c -r1.79 Makefile.alpha
*** Makefile.alpha	2000/10/29 09:47:50	1.79
--- Makefile.alpha	2000/11/13 10:09:34
***************
*** 310,320 ****
  
  modules:
  	@mkdir -p ${.OBJDIR}/modules
! 	cd $S/modules && env ${MKMODULESENV} ${MAKE} obj all
  
  modules-depend:
  	@mkdir -p ${.OBJDIR}/modules
! 	cd $S/modules && env ${MKMODULESENV} ${MAKE} obj depend
  
  modules-clean:
  	cd $S/modules && env ${MKMODULESENV} ${MAKE} clean
--- 310,322 ----
  
  modules:
  	@mkdir -p ${.OBJDIR}/modules
! 	cd $S/modules && env ${MKMODULESENV} ${MAKE} obj
! 	cd $S/modules && env ${MKMODULESENV} ${MAKE} all
  
  modules-depend:
  	@mkdir -p ${.OBJDIR}/modules
! 	cd $S/modules && env ${MKMODULESENV} ${MAKE} obj
! 	cd $S/modules && env ${MKMODULESENV} ${MAKE} depend
  
  modules-clean:
  	cd $S/modules && env ${MKMODULESENV} ${MAKE} clean
Index: Makefile.i386
===================================================================
RCS file: /lab/FreeBSD/FreeBSD.cvs/src/sys/conf/Makefile.i386,v
retrieving revision 1.212
diff -c -r1.212 Makefile.i386
*** Makefile.i386	2000/10/29 09:47:50	1.212
--- Makefile.i386	2000/11/13 10:10:03
***************
*** 271,281 ****
  
  modules:
  	@mkdir -p ${.OBJDIR}/modules
! 	cd $S/modules && env ${MKMODULESENV} ${MAKE} obj all
  
  modules-depend:
  	@mkdir -p ${.OBJDIR}/modules
! 	cd $S/modules && env ${MKMODULESENV} ${MAKE} obj depend
  
  modules-clean:
  	cd $S/modules && env ${MKMODULESENV} ${MAKE} clean
--- 271,283 ----
  
  modules:
  	@mkdir -p ${.OBJDIR}/modules
! 	cd $S/modules && env ${MKMODULESENV} ${MAKE} obj
! 	cd $S/modules && env ${MKMODULESENV} ${MAKE} all
  
  modules-depend:
  	@mkdir -p ${.OBJDIR}/modules
! 	cd $S/modules && env ${MKMODULESENV} ${MAKE} obj
! 	cd $S/modules && env ${MKMODULESENV} ${MAKE} depend
  
  modules-clean:
  	cd $S/modules && env ${MKMODULESENV} ${MAKE} clean
Index: Makefile.ia64
===================================================================
RCS file: /lab/FreeBSD/FreeBSD.cvs/src/sys/conf/Makefile.ia64,v
retrieving revision 1.4
diff -c -r1.4 Makefile.ia64
*** Makefile.ia64	2000/10/29 09:47:50	1.4
--- Makefile.ia64	2000/11/13 10:10:41
***************
*** 275,285 ****
  
  modules:
  	@mkdir -p ${.OBJDIR}/modules
! 	cd $S/modules && env ${MKMODULESENV} ${MAKE} obj all
  
  modules-depend:
  	@mkdir -p ${.OBJDIR}/modules
! 	cd $S/modules && env ${MKMODULESENV} ${MAKE} obj depend
  
  modules-clean:
  	cd $S/modules && env ${MKMODULESENV} ${MAKE} clean
--- 275,287 ----
  
  modules:
  	@mkdir -p ${.OBJDIR}/modules
! 	cd $S/modules && env ${MKMODULESENV} ${MAKE} obj
! 	cd $S/modules && env ${MKMODULESENV} ${MAKE} all
  
  modules-depend:
  	@mkdir -p ${.OBJDIR}/modules
! 	cd $S/modules && env ${MKMODULESENV} ${MAKE} obj
! 	cd $S/modules && env ${MKMODULESENV} ${MAKE} depend
  
  modules-clean:
  	cd $S/modules && env ${MKMODULESENV} ${MAKE} clean
Index: Makefile.pc98
===================================================================
RCS file: /lab/FreeBSD/FreeBSD.cvs/src/sys/conf/Makefile.pc98,v
retrieving revision 1.110
diff -c -r1.110 Makefile.pc98
*** Makefile.pc98	2000/11/05 14:31:17	1.110
--- Makefile.pc98	2000/11/13 10:11:03
***************
*** 274,284 ****
  
  modules:
  	@mkdir -p ${.OBJDIR}/modules
! 	cd $S/modules && env ${MKMODULESENV} ${MAKE} obj all
  
  modules-depend:
  	@mkdir -p ${.OBJDIR}/modules
! 	cd $S/modules && env ${MKMODULESENV} ${MAKE} obj depend
  
  modules-clean:
  	cd $S/modules && env ${MKMODULESENV} ${MAKE} clean
--- 274,286 ----
  
  modules:
  	@mkdir -p ${.OBJDIR}/modules
! 	cd $S/modules && env ${MKMODULESENV} ${MAKE} obj
! 	cd $S/modules && env ${MKMODULESENV} ${MAKE} all
  
  modules-depend:
  	@mkdir -p ${.OBJDIR}/modules
! 	cd $S/modules && env ${MKMODULESENV} ${MAKE} obj
! 	cd $S/modules && env ${MKMODULESENV} ${MAKE} depend
  
  modules-clean:
  	cd $S/modules && env ${MKMODULESENV} ${MAKE} clean


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




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