From owner-freebsd-ports@FreeBSD.ORG Fri Jan 27 16:51:28 2012 Return-Path: Delivered-To: freebsd-ports@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 2CA86106566B for ; Fri, 27 Jan 2012 16:51:28 +0000 (UTC) (envelope-from utisoft@gmail.com) Received: from mail-iy0-f182.google.com (mail-iy0-f182.google.com [209.85.210.182]) by mx1.freebsd.org (Postfix) with ESMTP id E5C9B8FC15 for ; Fri, 27 Jan 2012 16:51:27 +0000 (UTC) Received: by iaeo4 with SMTP id o4so3987128iae.13 for ; Fri, 27 Jan 2012 08:51:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=5IjQdDFSJA3zT/LD33JB6/hrRM0tUSb+KbunMpWCWOw=; b=uHE7gzBmSjFQpgFhQDuStM92hk03iULZBIEDmXmQSSZDr4MOVr9t21QNmm8BHlL7Ty VmU5cJKRvN0KZXxotn2orF5VmLInQyUiQ6RfFqS5X5xCvRe8JyUHBrKu2o342d+MbJgs 3SRJNIXjZg0ektdZ8nqFZB1FPIozzcErprsxU= MIME-Version: 1.0 Received: by 10.42.146.202 with SMTP id k10mr5858030icv.13.1327683087350; Fri, 27 Jan 2012 08:51:27 -0800 (PST) Received: by 10.231.183.21 with HTTP; Fri, 27 Jan 2012 08:51:27 -0800 (PST) Received: by 10.231.183.21 with HTTP; Fri, 27 Jan 2012 08:51:27 -0800 (PST) In-Reply-To: <4F22CB51.6070507@infracaninophile.co.uk> References: <4F22CB51.6070507@infracaninophile.co.uk> Date: Fri, 27 Jan 2012 16:51:27 +0000 Message-ID: From: Chris Rees To: Matthew Seaman Content-Type: text/plain; charset=ISO-8859-1 X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Cc: freebsd-ports Subject: Re: BSD make -- Malformed conditional X-BeenThere: freebsd-ports@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting software to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Jan 2012 16:51:28 -0000 On 27 Jan 2012 16:06, "Matthew Seaman" wrote: > > > Dear all, > > Posting this mostly for the archives, but it's probably relevant to some > people here too. > > When hacking on Makefiles, should you wish to match an item in a list, > you might write something like this: > > .for item in ${LIST} > .if ${item} == ${THING} # Ooops! > THING_FOUND= 1 > .endif > .endfor > > This however is a snare and a delusion, and will lead to much weeping > and wailing, and error messages like so: > > % make > "Makefile", line 7: Malformed conditional (foo == ${THING}) > "Makefile", line 9: if-less endif > "Makefile", line 7: Malformed conditional (bar == ${THING}) > "Makefile", line 9: if-less endif > "Makefile", line 7: Malformed conditional (baz == ${THING}) > "Makefile", line 9: if-less endif > "Makefile", line 7: Malformed conditional (blurfl == ${THING}) > "Makefile", line 9: if-less endif > make: fatal errors encountered -- cannot continue > > Instead you should write your loops like this: > > .for item in ${LIST} > .if ${THING} == ${item} > THING_FOUND= 1 > .endif > .endfor > > As the make(1) manual page says on the subject of string comparisons > using == or != : > > An expression may also be a numeric or string comparison: in this case, > the left-hand side must be a variable expansion, whereas the right-hand > side can be a constant or a variable expansion. > > So it seems that despite appearing and behaving almost exactly like one, > the iterator in a .for loop is not actually a variable as such. It also > means that to match a constant string, you can't just write: > > .for item in ${LIST} > .if ${item} == "this" # Ooops You shouldn't use quotes either. Chris