From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15924 invoked by alias); 18 Dec 2011 16:05:37 -0000 Received: (qmail 15913 invoked by uid 22791); 18 Dec 2011 16:05:36 -0000 X-SWARE-Spam-Status: No, hits=-3.3 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sun, 18 Dec 2011 16:05:19 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 7D1E62BB0BC; Sun, 18 Dec 2011 11:05:18 -0500 (EST) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id anDB-JQqbDTO; Sun, 18 Dec 2011 11:05:18 -0500 (EST) Received: from joel.gnat.com (localhost.localdomain [127.0.0.1]) by rock.gnat.com (Postfix) with ESMTP id CCF2F2BAFFD; Sun, 18 Dec 2011 11:05:17 -0500 (EST) Received: by joel.gnat.com (Postfix, from userid 1000) id 26E13145615; Sun, 18 Dec 2011 08:05:08 -0800 (PST) From: Joel Brobecker To: gdb-patches@sourceware.org Cc: Mike Frysinger , Joel Brobecker Subject: [RFA/commit] Work around Solaris bourne shell limitation when building the sim Date: Sun, 18 Dec 2011 16:35:00 -0000 Message-Id: <1324224294-22559-1-git-send-email-brobecker@adacore.com> Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2011-12/txt/msg00603.txt.bz2 Hello, Building the sim on a sparc-solaris 2.8 machine fails when configured with no extra sim hardware: > for hw in ; do \ > echo "extern const struct hw_descriptor > dv_${hw}_descriptor[];" ; \ > done >> tmp-hw.h > echo 'const char version[] = "'"`sed q > /[...]/../../gdb/version.in`"'";' > >> version.c-tmp > /bin/sh: -c: line 1: syntax error near unexpected token `;' > /bin/sh: -c: line 1: `for hw in ; do \' > make[3]: *** [hw-config.h] Error 2 The same thing happens with the version of bash that we got from Sun as well (which is very old: 2.03.0(1)-release). The problems comes from the fact that both shells are buggy, and reject the following script: for hw in ; do [...] done The above is what sim/common/Makefile.in tries to execute when generating hw-config.h. In order to allow users to build out of the box on these machines, this patch works around this bug. It does rely on the fact that none of the tokens in SIM_HW contain whitespaces. I don't think that this is going to be a problem in practice. sim/common/ChangeLog: * Make-common.in (hw-config.h): Work around bug in Solaris 2.8 system bourne shell. Tested on sparc-solaris with both /bin/sh and /bin/bash. Would that be OK? PS: An alternate approach, which I think might be better (although this might depend on taste), is to do use config.h and define macros there depending on which hw capability is being configured in. Then hw-config.h no longer needs to be generated. It becomes a regular source file with #ifdef's in them. I didn't do it because it's probably a significant amount of work, and I am not convinced that it's that better. --- sim/common/Make-common.in | 7 +++++-- 1 files changed, 5 insertions(+), 2 deletions(-) diff --git a/sim/common/Make-common.in b/sim/common/Make-common.in index c12d155..7c76f50 100644 --- a/sim/common/Make-common.in +++ b/sim/common/Make-common.in @@ -459,14 +459,17 @@ sim-inline.c: $(srccom)/sim-inline.c $(SHELL) $(srcdir)/../../move-if-change tmp-$@ $@ # FIXME This is one very simple-minded way of generating the file hw-config.h +# The use of the "`echo $(SIM_HW)`" in the for loops below is to work around +# bugs in certain system shells (such as the Solaris 2.8 bourne shell) +# which break when the for list is empty. hw-config.h: Makefile.in $(srccom)/Make-common.in config.status Makefile rm -f tmp-hw.h echo "/* generated by Makefile */" > tmp-hw.h - for hw in $(SIM_HW) ; do \ + for hw in `echo $(SIM_HW)` ; do \ echo "extern const struct hw_descriptor dv_$${hw}_descriptor[];" ; \ done >> tmp-hw.h echo "const struct hw_descriptor *hw_descriptors[] = {" >> tmp-hw.h - for hw in $(SIM_HW) ; do \ + for hw in `echo $(SIM_HW)` ; do \ echo " dv_$${hw}_descriptor," ; \ done >> tmp-hw.h echo " NULL," >> tmp-hw.h -- 1.7.1