* RFA: respect -k or its absence when building sim subdirs
@ 2005-04-13 17:32 Jim Blandy
2005-04-14 19:25 ` Daniel Jacobowitz
0 siblings, 1 reply; 4+ messages in thread
From: Jim Blandy @ 2005-04-13 17:32 UTC (permalink / raw)
To: gdb-patches
Overkill, probably. I just hate this kind of stuff.
2005-04-13 Jim Blandy <jimb@redhat.com>
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.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: RFA: respect -k or its absence when building sim subdirs
2005-04-13 17:32 RFA: respect -k or its absence when building sim subdirs Jim Blandy
@ 2005-04-14 19:25 ` Daniel Jacobowitz
2005-04-15 0:20 ` Jim Blandy
0 siblings, 1 reply; 4+ messages in thread
From: Daniel Jacobowitz @ 2005-04-14 19:25 UTC (permalink / raw)
To: Jim Blandy; +Cc: gdb-patches
On Wed, Apr 13, 2005 at 12:32:23PM -0500, Jim Blandy wrote:
>
> Overkill, probably. I just hate this kind of stuff.
>
> 2005-04-13 Jim Blandy <jimb@redhat.com>
>
> 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.
Wow... this really is overkill, and I'm not sure that the quoting does
what you want it to. Can't you do this in make more straightforwardly?
I know you can in GNU make, anyway.
--
Daniel Jacobowitz
CodeSourcery, LLC
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: RFA: respect -k or its absence when building sim subdirs
2005-04-14 19:25 ` Daniel Jacobowitz
@ 2005-04-15 0:20 ` Jim Blandy
2005-04-15 0:30 ` Daniel Jacobowitz
0 siblings, 1 reply; 4+ messages in thread
From: Jim Blandy @ 2005-04-15 0:20 UTC (permalink / raw)
To: Daniel Jacobowitz; +Cc: gdb-patches
Daniel Jacobowitz <drow@false.org> writes:
> On Wed, Apr 13, 2005 at 12:32:23PM -0500, Jim Blandy wrote:
> >
> > Overkill, probably. I just hate this kind of stuff.
> >
> > 2005-04-13 Jim Blandy <jimb@redhat.com>
> >
> > 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.
>
> Wow... this really is overkill, and I'm not sure that the quoting does
> what you want it to. Can't you do this in make more straightforwardly?
> I know you can in GNU make, anyway.
Can you suggest a strategy? Whatever you do, you have to replicate it
in each of those targets. If it's not pretty trivial, I don't want to
write it out every time; it belongs in a "function", which, in this
world, is a script.
After I posted, I realized the quoting could be simplified to:
clean mostlyclean:
@rootme=`pwd` ; export rootme ; \
! $(SHELL) $(srcdir)/for-subdirs.sh \
! "$(MAKEFLAGS)" '$(MAKE) $(FLAGS_TO_PASS) $@' $(SUBDIRS)
Where else were you worried about the quoting?
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: RFA: respect -k or its absence when building sim subdirs
2005-04-15 0:20 ` Jim Blandy
@ 2005-04-15 0:30 ` Daniel Jacobowitz
0 siblings, 0 replies; 4+ messages in thread
From: Daniel Jacobowitz @ 2005-04-15 0:30 UTC (permalink / raw)
To: Jim Blandy; +Cc: gdb-patches
On Thu, Apr 14, 2005 at 07:20:06PM -0500, Jim Blandy wrote:
>
> Daniel Jacobowitz <drow@false.org> writes:
> > On Wed, Apr 13, 2005 at 12:32:23PM -0500, Jim Blandy wrote:
> > >
> > > Overkill, probably. I just hate this kind of stuff.
> > >
> > > 2005-04-13 Jim Blandy <jimb@redhat.com>
> > >
> > > 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.
> >
> > Wow... this really is overkill, and I'm not sure that the quoting does
> > what you want it to. Can't you do this in make more straightforwardly?
> > I know you can in GNU make, anyway.
>
> Can you suggest a strategy? Whatever you do, you have to replicate it
> in each of those targets. If it's not pretty trivial, I don't want to
> write it out every time; it belongs in a "function", which, in this
> world, is a script.
>
> After I posted, I realized the quoting could be simplified to:
>
> clean mostlyclean:
> @rootme=`pwd` ; export rootme ; \
> ! $(SHELL) $(srcdir)/for-subdirs.sh \
> ! "$(MAKEFLAGS)" '$(MAKE) $(FLAGS_TO_PASS) $@' $(SUBDIRS)
>
>
> Where else were you worried about the quoting?
Single or double quotation marks in the arguments. Particularly
plausible in $(FLAGS_TO_PASS). Make variable substitution is really
pretty dumb. I'm not sure it's a real problem.
All you want is, iff MAKEFLAGS does not contain -k, to exit if any
submake fails. I don't know what Make bits are and are not portable
very well. You can do this in shell; something like:
if ! $(MAKE) -C subdir; then
if ! echo "$(MAKEFLAGS)" | grep '^[^ ]*k' > /dev/null; then
exit 1
fi
fi
And that whole inner goo can become $(MAKE_K_CHECK).
--
Daniel Jacobowitz
CodeSourcery, LLC
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2005-04-15 0:30 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-04-13 17:32 RFA: respect -k or its absence when building sim subdirs Jim Blandy
2005-04-14 19:25 ` Daniel Jacobowitz
2005-04-15 0:20 ` Jim Blandy
2005-04-15 0:30 ` Daniel Jacobowitz
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox