From owner-freebsd-hackers@FreeBSD.ORG Wed Jun 23 09:32:56 2010 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 852A8106566B for ; Wed, 23 Jun 2010 09:32:56 +0000 (UTC) (envelope-from des@des.no) Received: from smtp.des.no (smtp.des.no [194.63.250.102]) by mx1.freebsd.org (Postfix) with ESMTP id 473898FC2F for ; Wed, 23 Jun 2010 09:32:56 +0000 (UTC) Received: from ds4.des.no (des.no [84.49.246.2]) by smtp.des.no (Postfix) with ESMTP id 7B07B1FFC34; Wed, 23 Jun 2010 09:32:54 +0000 (UTC) Received: by ds4.des.no (Postfix, from userid 1001) id C19158454A; Wed, 23 Jun 2010 11:30:43 +0200 (CEST) From: =?utf-8?Q?Dag-Erling_Sm=C3=B8rgrav?= To: Patrick Mahan References: <4C21A743.6040306@mahan.org> Date: Wed, 23 Jun 2010 11:30:43 +0200 In-Reply-To: <4C21A743.6040306@mahan.org> (Patrick Mahan's message of "Tue, 22 Jun 2010 23:18:43 -0700") Message-ID: <86hbkujdto.fsf@ds4.des.no> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (berkeley-unix) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Cc: freebsd-hackers@freebsd.org Subject: Re: Help with some makefile hackery X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 23 Jun 2010 09:32:56 -0000 Patrick Mahan writes: > My issue is that if there is a build failure at any point, the > status does not seem to be propagated upward. For example, if > the kernel fails to build due to incorrect code, the script > -kernel64.sh stops (verifable by examining the logfile), > however, the make will continue to the next target, src-world, > and continue building. How do I propagate the status up to the > top-level make? Your shell script needs to exit with a non-zero status if it fails. There are several ways to do this. For instance, if your shell script looks like this: #!/bin/sh make TARGET=3Damd64 kernel-toolchain you can: - prefix "make" with "exec": sh will exec make instead of running it in a subshell, and the exit status will be whatever make returns. - add the following line at the bottom: exit $? which causes the shell script to exit with the same exit status as the last command it ran, in this case make. - append "|| exit 1" to the the "make" command line; this will cause the script to exit immediately with status 1 if make fails, otherwise it will continue (in case you want to do something else if make succeeds) - wrap the make command line in an if statement, which allows you do additional work depending on the outcome, and end the failure case with "exit 1" or similar - insert the following line at any point between the shebang and the make command line: set -e this will cause sh to terminate the script immediately with a non-zero exit status if any command after the "set" line fails. However, I don't see the point of using shell scripts in the first place... DES --=20 Dag-Erling Sm=C3=B8rgrav - des@des.no