From owner-freebsd-questions@FreeBSD.ORG Wed May 26 04:42:28 2004 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 3E74816A4CE for ; Wed, 26 May 2004 04:42:28 -0700 (PDT) Received: from smtp.infracaninophile.co.uk (smtp.infracaninophile.co.uk [81.2.69.218]) by mx1.FreeBSD.org (Postfix) with ESMTP id 7141543D1F for ; Wed, 26 May 2004 04:42:27 -0700 (PDT) (envelope-from m.seaman@infracaninophile.co.uk) Received: from happy-idiot-talk.infracaninophile.co.uk (localhost [IPv6:::1]) i4QBg1Px027112 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 26 May 2004 12:42:01 +0100 (BST) (envelope-from matthew@happy-idiot-talk.infracaninophile.co.uk) Received: (from matthew@localhost)id i4QBfvcF027105; Wed, 26 May 2004 12:41:57 +0100 (BST) (envelope-from matthew) Date: Wed, 26 May 2004 12:41:57 +0100 From: Matthew Seaman To: "N. Raghavendra" Message-ID: <20040526114157.GE26430@happy-idiot-talk.infracaninophile.co.uk> Mail-Followup-To: Matthew Seaman , "N. Raghavendra" , FreeBSD Questions References: <16563.20591.846129.789297@riemann.mri.ernet.in> <20040525144451.GA49822@happy-idiot-talk.infracaninophile.co.uk> <16564.15653.674179.246862@riemann.mri.ernet.in> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="uCPdOCrL+PnN2Vxy" Content-Disposition: inline In-Reply-To: <16564.15653.674179.246862@riemann.mri.ernet.in> User-Agent: Mutt/1.5.6i X-Virus-Scanned: clamd / ClamAV version devel-20040525, clamav-milter version 0.71 X-Virus-Status: Clean X-Spam-Status: No, hits=-4.8 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=2.63 X-Spam-Checker-Version: SpamAssassin 2.63 (2004-01-11) on happy-idiot-talk.infracaninophile.co.uk cc: FreeBSD Questions Subject: Re: `call' function in `make' X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 26 May 2004 11:42:28 -0000 --uCPdOCrL+PnN2Vxy Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, May 26, 2004 at 12:15:57PM +0530, N. Raghavendra wrote: > At 2004-05-25T15:44:51+01:00, Matthew Seaman wrote: >=20 > > > Is there an analogue in BSD `make' of the `call' function in `gmake': > > > $(call VARIABLE,PARAM,PARAM,...)? > >=20 > > Not as such. You can however use the '!=3D' operator to assign a value > > to a variable based on the output of some external command: > >=20 > > RATIO !=3D sh -c 'echo $$(( $a / $b ))' >=20 > Hi Matthew, >=20 > Thanks for your reply. After writing to the list yesterday, I read > make(1) carefully, and found what I wanted, namely the shell command > for creating `dir1' in this example `Makefile': >=20 > ### Makefile > =20 > ## Create directory FOO if it does not exist. > create_dir =3D if test ! -d foo ; then rm -f foo ; mkdir foo ; fi > =20 > dir1: src1 > $(create_dir:S/foo/$@/g) > =20 > dir2: src2 > $(create_dir:foo=3D$@) > =20 > ### Makefile ends here >=20 > However, I don't understand something. The command for `dir1' works > perfectly well: >=20 > % make dir1 > if test ! -d dir1 ; then rm -f dir1 ; mkdir dir1 ; fi > (`dir1' created) >=20 > OTOH, the command for `dir2' does not work --- `make' is not expanding > the local variable `@': >=20 > % make dir2 > if test ! -d $@ ; then rm -f $@ ; mkdir $@ ; fi > (`dir2' not created) >=20 > Can someone tell me why this is happening? Err... because in the second form the result of the substitution is not run through another round of variable expansion, and in the first for it is? You'ld have to ask the original authors of make(1) why they did it that way. Is there something wrong with the first form of the rule that means you can't use it? You have got a line: .PHONY: dir1 dir2 to force those rules to be applied even if dir1 or dir2 are newer than their sources? Cheers, Matthew --=20 Dr Matthew J Seaman MA, D.Phil. 26 The Paddocks Savill Way PGP: http://www.infracaninophile.co.uk/pgpkey Marlow Tel: +44 1628 476614 Bucks., SL7 1TH UK --uCPdOCrL+PnN2Vxy Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.4 (FreeBSD) iD8DBQFAtIKFiD657aJF7eIRAoPtAJ4nMkOx9eSAaY0AAnBy8dCDqRlDzwCfXMV8 3yhHJCawJtVPNqjDem41JcM= =x2py -----END PGP SIGNATURE----- --uCPdOCrL+PnN2Vxy--