From owner-freebsd-questions@FreeBSD.ORG Mon Jan 28 03:19:19 2008 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3E52316A420 for ; Mon, 28 Jan 2008 03:19:19 +0000 (UTC) (envelope-from rambiusparkisanius@gmail.com) Received: from rv-out-0910.google.com (rv-out-0910.google.com [209.85.198.189]) by mx1.freebsd.org (Postfix) with ESMTP id 13BBF13C45D for ; Mon, 28 Jan 2008 03:19:18 +0000 (UTC) (envelope-from rambiusparkisanius@gmail.com) Received: by rv-out-0910.google.com with SMTP id l15so1489781rvb.43 for ; Sun, 27 Jan 2008 19:19:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; bh=eUEHGHmEB2UsRLk7x538B+q7I0U0VgcdKMjnnyVAZRM=; b=TTPSAGmGiRyMQzSISyOjDkbD2o5do5+1v2Yd9q3aVb4xVYu6Ms7FD3HFZe9qliFd9AY5QHPUgkCeoZB92UUYDVaNPbNaV4Y1jBJtvmiLZWTl80i6vTWHbaw+DGIAKFchBaKJ09dLDr2QVMfp2+lzk58g/ssn0LlzU7XLjasTp2o= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=P6H1Ttv3YmGtDZKT2pRJNsAzpMvjOiljPan22ANzQE3thGdlspwH9pnKtmBh8Mj7urDo5Yv1lp7vhHrNzps00x7CuNr5l24ZV9qf8xqWs9lTftXwqCz7haYk8KRNXU9m1erO8QQDftUmgnEPJiZ6bcBN2NO1t7/6pSLkHbCce6I= Received: by 10.140.126.10 with SMTP id y10mr3095347rvc.214.1201490357182; Sun, 27 Jan 2008 19:19:17 -0800 (PST) Received: by 10.140.161.2 with HTTP; Sun, 27 Jan 2008 19:19:17 -0800 (PST) Message-ID: <89ce7f740801271919n107c20a8v2341687285728fb1@mail.gmail.com> Date: Mon, 28 Jan 2008 05:19:17 +0200 From: "Ivan \"Rambius\" Ivanov" To: "Giorgos Keramidas" In-Reply-To: <20080128005944.GA3072@kobe.laptop> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <89ce7f740801271448x27371cf7lfe5255256fb498ec@mail.gmail.com> <20080128005944.GA3072@kobe.laptop> Cc: freebsd-questions@freebsd.org Subject: Re: Slightly OT: Invoking a shell command from a Makeile X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Jan 2008 03:19:19 -0000 Hello Georgious, On Jan 28, 2008 2:59 AM, Giorgos Keramidas wrote: > On 2008-01-28 00:48, Ivan Rambius Ivanov wrote: > > Hello, > > > > I am developing a FreeBSD port and I would like to invoke a shell > > command from it and assign its output to a variable. The command in > > question is > > > > # make -f /usr/ports/lang/fpc/Makefile -V PORTVERSION > > > > and I have verified that it works on the command line. > > > > I try to use it in my port's Makefile in the following way: > > > > FPCVERSION= `make -f /usr/ports/lang/fpc/Makefile -V PORTVERSION` > > > > but it fails with the following error > > > > Syntax error: EOF in backquote substitution > > Try the BSD-specific syntax which uses bang-equal assignment to grab the > output of a shell command and assign it to a make variable: > > FPCVERSION!= shell cmd here > > i.e. something like: > > FPCVERSION!= make -f ${PORTSDIR}/lang/fpc/Makefile -V PORTVERSION Yes, I found this out after some searching in google. > I'm curious though. Why do you have to find the value of the > {PORTVERSION} from a Ports makefile? > > Perhaps there is already a `standard' feature of the Ports which can do > something similar. Have you asked around in freebsd-ports? The port I am developing builds and installs a software called nbc [1], [2]. It is written in Pascal and uses the freepascal compiler [3] coming from lang/fpc port and some other pascal libraries called units coming from devel/fpc-fcl-base. These units are installed into /usr/local/lib/fpc/, where portversion of_fpc is the version of the freepascal compiler as defined in PORTVERSION variable in fpc's Makefile. Currently it is 2.2.0. I do not want to hardcode that number in nbc port's Makefile - I want to extract it on the fly from fpc port's Makefile, this is why I am doing this trick. Regards Rambius [1] http://bricxcc.sourceforge.net/nbc/ [2] http://www.freebsd.org/cgi/query-pr.cgi?pr=ports/116274 [3] http://www.freepascal.org/ -- Tangra Mega Rock: http://www.radiotangra.com