From owner-freebsd-ports@FreeBSD.ORG Fri Jan 27 16:05:54 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 02DFD106567C for ; Fri, 27 Jan 2012 16:05:54 +0000 (UTC) (envelope-from m.seaman@infracaninophile.co.uk) Received: from smtp.infracaninophile.co.uk (smtp6.infracaninophile.co.uk [IPv6:2001:8b0:151:1:3cd3:cd67:fafa:3d78]) by mx1.freebsd.org (Postfix) with ESMTP id 575658FC17 for ; Fri, 27 Jan 2012 16:05:53 +0000 (UTC) Received: from seedling.black-earth.co.uk (seedling.black-earth.co.uk [IPv6:2001:8b0:151:1:fa1e:dfff:feda:c0bb]) (authenticated bits=0) by smtp.infracaninophile.co.uk (8.14.5/8.14.5) with ESMTP id q0RG5lk0098902 (version=TLSv1/SSLv3 cipher=DHE-RSA-CAMELLIA256-SHA bits=256 verify=NO) for ; Fri, 27 Jan 2012 16:05:47 GMT (envelope-from m.seaman@infracaninophile.co.uk) X-DKIM: OpenDKIM Filter v2.4.3 smtp.infracaninophile.co.uk q0RG5lk0098902 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=infracaninophile.co.uk; s=201001-infracaninophile; t=1327680347; bh=71YwGLDT1hLs6xu37p/OSXMZsUxiazaT8fcVMy0z/rg=; h=Message-ID:Date:From:MIME-Version:To:Subject:Content-Type:Cc: In-Reply-To:References; b=vE5wiRVHyQh6HnOZt+U9XohtXEYQRf7UwFcqx/JutIoYPdRW9FxvXPg9XZs2CCGPc Zi7NuFPPo+YL7ntCk8h9AQwULD1in/VChuwjVXUUIcqljppjosMwNJQNjRJwrwDoZ6 9LLB1DwXwBSQmvwkjSnSSQWGVZvq52GMyrwg4/b4= Message-ID: <4F22CB51.6070507@infracaninophile.co.uk> Date: Fri, 27 Jan 2012 16:05:37 +0000 From: Matthew Seaman User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:9.0) Gecko/20111222 Thunderbird/9.0.1 MIME-Version: 1.0 To: freebsd-ports X-Enigmail-Version: 1.3.4 OpenPGP: id=60AE908C Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enig7FB8387BD1D0D244C3619B35" X-Virus-Scanned: clamav-milter 0.97.3 at lucid-nonsense.infracaninophile.co.uk X-Virus-Status: Clean X-Spam-Status: No, score=-2.7 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU autolearn=ham version=3.3.2 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on lucid-nonsense.infracaninophile.co.uk Cc: Subject: 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:05:54 -0000 This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig7FB8387BD1D0D244C3619B35 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable 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: =2Efor item in ${LIST} =2Eif ${item} =3D=3D ${THING} # Ooops! THING_FOUND=3D 1 =2Eendif =2Eendfor 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 =3D=3D ${THING}) "Makefile", line 9: if-less endif "Makefile", line 7: Malformed conditional (bar =3D=3D ${THING}) "Makefile", line 9: if-less endif "Makefile", line 7: Malformed conditional (baz =3D=3D ${THING}) "Makefile", line 9: if-less endif "Makefile", line 7: Malformed conditional (blurfl =3D=3D ${THING}) "Makefile", line 9: if-less endif make: fatal errors encountered -- cannot continue Instead you should write your loops like this: =2Efor item in ${LIST} =2Eif ${THING} =3D=3D ${item} THING_FOUND=3D 1 =2Eendif =2Eendfor As the make(1) manual page says on the subject of string comparisons using =3D=3D or !=3D : An expression may also be a numeric or string comparison: in this ca= se, the left-hand side must be a variable expansion, whereas the right-h= and 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: =2Efor item in ${LIST} =2Eif ${item} =3D=3D "this" # Ooops THIS_FOUND=3D1 =2Eendif =2Eendfor but have to assign the text "this" to a variable somewhere, and use the second form. Yes, you can use ${LIST:Mthis} instead, but using this construct can be a bit tricky in itself... % cat Makefile LIST=3D foo bar baz blurfl THING=3D baz all: @echo "OK \$${LIST:Mfoo} =3D ${LIST:Mfoo}" @echo "Not OK \$${LIST:M\$${THING}} =3D ${LIST:M${THING}}" % make OK ${LIST:Mfoo} =3D foo Not OK ${LIST:M${THING}} =3D } Cheers, Matthew --=20 Dr Matthew J Seaman MA, D.Phil. 7 Priory Courtyard Flat 3 PGP: http://www.infracaninophile.co.uk/pgpkey Ramsgate JID: matthew@infracaninophile.co.uk Kent, CT11 9PW --------------enig7FB8387BD1D0D244C3619B35 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG/MacGPG2 v2.0.16 (Darwin) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAk8iy1oACgkQ8Mjk52CukIw1EgCeNrwfvkTHm5L8q1bqKhSR4Swv wHIAninG/eNaxfBHO5ajQO8Gzbh1URl4 =bTiN -----END PGP SIGNATURE----- --------------enig7FB8387BD1D0D244C3619B35--