From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18413 invoked by alias); 13 Apr 2005 17:32:46 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 18325 invoked from network); 13 Apr 2005 17:32:34 -0000 Received: from unknown (HELO mx1.redhat.com) (66.187.233.31) by sourceware.org with SMTP; 13 Apr 2005 17:32:34 -0000 Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.12.11/8.12.11) with ESMTP id j3DHWYZN001913 for ; Wed, 13 Apr 2005 13:32:34 -0400 Received: from zenia.home.redhat.com (sebastian-int.corp.redhat.com [172.16.52.221]) by int-mx1.corp.redhat.com (8.11.6/8.11.6) with ESMTP id j3DHWWO01085; Wed, 13 Apr 2005 13:32:33 -0400 To: gdb-patches@sources.redhat.com Subject: RFA: respect -k or its absence when building sim subdirs From: Jim Blandy Date: Wed, 13 Apr 2005 17:32:00 -0000 Message-ID: User-Agent: Gnus/5.090 (Gnus v5.9.0) Emacs/21.3 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-SW-Source: 2005-04/txt/msg00115.txt.bz2 Overkill, probably. I just hate this kind of stuff. 2005-04-13 Jim Blandy Fix -k handling when looping over subdirectories. * for-subdirs.sh: New script. * Makefile.in (all clean mostlyclean distclean maintainer-clean realclean install): Use it to loop over subdirectories. Index: sim/for-subdirs.sh =================================================================== RCS file: sim/for-subdirs.sh diff -N sim/for-subdirs.sh *** sim/for-subdirs.sh 1 Jan 1970 00:00:00 -0000 --- sim/for-subdirs.sh 13 Apr 2005 17:29:16 -0000 *************** *** 0 **** --- 1,38 ---- + #!/bin/sh + + # usage: sh for-subdirs.sh MAKEFLAGS COMMAND SUBDIR ... + # + # For every subdirectory SUBDIR ... that is not '.', cd to that subdirectory + # and evaluate COMMAND. + # + # MAKEFLAGS should be the value of the 'make' variable 'MAKEFLAGS'; if + # its value indicates that make is being called with the '-k' flag, + # the subdirectory loop will exit with a non-zero status if any + # evaluation of COMMAND does so. + + makeflags="$1"; shift + command="$1"; shift + + # Delete variable assignments from makeflags. + makeflags="$(echo "$makeflags" | sed -e 's/[^ ][^ ]*=[^ ][^ ]*//g')" + + final_status=0 + + for subdir in "$@"; do + if [ "$subdir" = "." ]; then + true; + elif (cd "$subdir" && eval "$command"); then + true; + else + status="$?" + case "$makeflags" in + *k*) + final_status="$status" + ;; + *) + exit "$status" + ;; + esac + fi + done + exit "$final_status" Index: sim/Makefile.in =================================================================== RCS file: /cvs/src/src/sim/Makefile.in,v retrieving revision 1.6 diff -c -p -r1.6 Makefile.in *** sim/Makefile.in 29 Jan 2005 00:53:13 -0000 1.6 --- sim/Makefile.in 13 Apr 2005 17:29:16 -0000 *************** TARGET_FLAGS_TO_PASS = \ *** 126,169 **** all: @rootme=`pwd` ; export rootme ; \ ! for dir in . `echo ${SUBDIRS} | sed 's/testsuite//'` ; do \ ! if [ "$$dir" = "." ]; then \ ! true; \ ! elif [ -d $$dir ]; then \ ! (cd $$dir; $(MAKE) $(FLAGS_TO_PASS)) || exit 1; \ ! else true; fi; \ ! done clean mostlyclean: @rootme=`pwd` ; export rootme ; \ ! for dir in . ${SUBDIRS}; do \ ! if [ "$$dir" = "." ]; then \ ! true; \ ! elif [ -d $$dir ]; then \ ! (cd $$dir; $(MAKE) $(FLAGS_TO_PASS) $@) || exit 1; \ ! else true; fi; \ ! done distclean maintainer-clean realclean: @rootme=`pwd` ; export rootme ; \ ! for dir in . ${SUBDIRS}; do \ ! if [ "$$dir" = "." ]; then \ ! true; \ ! elif [ -d $$dir ]; then \ ! (cd $$dir; $(MAKE) $(FLAGS_TO_PASS) $@) || exit 1; \ ! else true; fi; \ ! done rm -f Makefile config.cache config.log config.status install: @rootme=`pwd` ; export rootme ; \ ! for dir in . ${SUBDIRS}; do \ ! if [ "$$dir" = "." ]; then \ ! true; \ ! elif [ -d $$dir ]; then \ ! (cd $$dir; $(MAKE) $(FLAGS_TO_PASS) install) || exit 1; \ ! else true; fi; \ ! done installcheck: @echo No installcheck target is available yet for the GNU simulators. --- 126,150 ---- all: @rootme=`pwd` ; export rootme ; \ ! $(SHELL) $(srcdir)/for-subdirs.sh \ ! "$(MAKEFLAGS)" "$(MAKE) "'$(FLAGS_TO_PASS)' \ ! `echo ${SUBDIRS} | sed 's/testsuite//'` clean mostlyclean: @rootme=`pwd` ; export rootme ; \ ! $(SHELL) $(srcdir)/for-subdirs.sh \ ! "$(MAKEFLAGS)" "$(MAKE) "'$(FLAGS_TO_PASS) $@' $(SUBDIRS) distclean maintainer-clean realclean: @rootme=`pwd` ; export rootme ; \ ! $(SHELL) $(srcdir)/for-subdirs.sh \ ! "$(MAKEFLAGS)" "$(MAKE) "'$(FLAGS_TO_PASS) $@' $(SUBDIRS) rm -f Makefile config.cache config.log config.status install: @rootme=`pwd` ; export rootme ; \ ! $(SHELL) $(srcdir)/for-subdirs.sh \ ! "$(MAKEFLAGS)" "$(MAKE) "'$(FLAGS_TO_PASS) install' $(SUBDIRS) installcheck: @echo No installcheck target is available yet for the GNU simulators.