From owner-svn-src-all@FreeBSD.ORG Tue Mar 20 21:30:31 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4B6951065675; Tue, 20 Mar 2012 21:30:31 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from cyrus.watson.org (cyrus.watson.org [65.122.17.42]) by mx1.freebsd.org (Postfix) with ESMTP id BD87C8FC08; Tue, 20 Mar 2012 21:30:30 +0000 (UTC) Received: from bigwig.baldwin.cx (bigwig.baldwin.cx [96.47.65.170]) by cyrus.watson.org (Postfix) with ESMTPSA id 54E4946B2D; Tue, 20 Mar 2012 17:30:30 -0400 (EDT) Received: from jhbbsd.localnet (unknown [209.249.190.124]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id D6C8AB93E; Tue, 20 Mar 2012 17:30:29 -0400 (EDT) From: John Baldwin To: Chris Rees Date: Tue, 20 Mar 2012 17:28:20 -0400 User-Agent: KMail/1.13.5 (FreeBSD/8.2-CBSD-20110714-p10; KDE/4.5.5; amd64; ; ) References: <201203162319.q2GNJjx5039482@svn.freebsd.org> <201203201019.40486.jhb@freebsd.org> In-Reply-To: MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <201203201728.21049.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.7 (bigwig.baldwin.cx); Tue, 20 Mar 2012 17:30:29 -0400 (EDT) Cc: Doug Barton , svn-src-all@freebsd.org, Dimitry Andric , src-committers@freebsd.org, Bruce Evans , svn-src-head@freebsd.org Subject: Re: svn commit: r233052 - head/share/mk X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 20 Mar 2012 21:30:31 -0000 On Tuesday, March 20, 2012 5:20:04 pm Chris Rees wrote: > On 20 March 2012 14:19, John Baldwin wrote: > > On Monday, March 19, 2012 5:39:53 pm Doug Barton wrote: > >> On 3/19/2012 12:37 PM, Dimitry Andric wrote: > >> > It would be much nicer to be able to write: > >> > > >> > .if defined(FOO) > >> > .if defined(BAR) > >> > CFLAGS+= -DFOO_BAR > >> > .endif > >> > .endif > >> > >> Take a look at /usr/ports/Mk/bsd.port.mk for how this can be done. > > > > Hmm, do yoo have a specific example? The bits in I see in bsd.port.mk suffer > > from the limitation Dimitry raises, e.g.: > > > > .if defined(OPTIONS) > > # include OPTIONSFILE first if exists > > . if exists(${OPTIONSFILE}) && !make(rmconfig) > > . include "${OPTIONSFILE}" > > . endif > > . if exists(${OPTIONSFILE}.local) > > . include "${OPTIONSFILE}.local" > > . endif > > WITHOUT:= > > WITH:= > > . if defined(OPTIONS) > > REALOPTIONS=${OPTIONS:C/".*"//g} > > . for O in ${REALOPTIONS} > > RO:=${O} > > . if ${RO:L} == off > > WITHOUT:= ${WITHOUT} ${OPT} > > . endif > > . if ${RO:L} == on > > WITH:= ${WITH} ${OPT} > > . endif > > OPT:=${RO} > > . endfor > > . endif > > > > That is, all the lines that don't start with a . are not indented, and > > even this indentation is rather horrible (it doesn't nest, and it > > has the odd structure of 'if defined(OPTIONS) { if defined(OPTIONS) {} }'. > > I don't see how it's any more horrible than the kernel style's rules > on indented #ifs (though I can see the reasoning for that) > > It's an unfortunate consequence of the fact that any line starting > with whitespace must be a shell command-- from before Makefiles were > allowed conditionals etc. > > It's got to be an improvement on: > > .if defined(ONE) > .if !defined(TWO) > .for one in two three four > .if ${VAR} == ${one} > .if defined(VERBOSE) > .warning VAR = one > .endif > .endif > .endfor > .elif ${VAR} == four > .if defined(VERBOSE) > .warning VAR = four > .endif > .else > .warning VAR is not four, and VERBOSE is ignored > .endif # XXXX Which one is this for?? > .endif > > which is what a lot of the Makefiles look like... debugging if-less > endifs etc is infinitely easier if we indent, however horrible it > looks. > > We shouldn't be *trying* to make Makefiles hard to read ;) Oh, it may be that I was reading it in less or some such and that bsd.port.mk requires 4 space tabs, so when viewed in things like less the indentation doesn't actually look like indentation. In that respect, this is no better than the above (and is what bsd.ports.mk looks like to me at least): . if defined(ONE) . if !defined(TWO) . for one in two three four etc. To be worthwhile the spacing has to actually look like indentation: .if defined(ONE) . if !defined(TWO) . for one in two three four etc. Regardless, the .if defined(OPTIONS) . if defined(OPTIONS) . endif .endif is lame. You have to admit that at least. :) -- John Baldwin