From owner-freebsd-ports@FreeBSD.ORG Thu Dec 30 21:58:04 2004 Return-Path: Delivered-To: freebsd-ports@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id AA6BC16A4CE for ; Thu, 30 Dec 2004 21:58:04 +0000 (GMT) Received: from gate.xbsd.org (xbsd.org [81.56.254.23]) by mx1.FreeBSD.org (Postfix) with ESMTP id 7A5C743D39 for ; Thu, 30 Dec 2004 21:58:01 +0000 (GMT) (envelope-from flz@xbsd.org) Received: from localhost (localhost.xbsd.org [127.0.0.1]) by gate.xbsd.org (Postfix) with ESMTP id 020E41181D; Thu, 30 Dec 2004 23:03:35 +0100 (CET) Received: from gate.xbsd.org ([127.0.0.1]) by localhost (gate.xbsd.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 07959-01; Thu, 30 Dec 2004 23:03:29 +0100 (CET) Received: from [192.168.42.3] (innercity.xbsd.org [192.168.42.3]) by gate.xbsd.org (Postfix) with ESMTP id ACF54116AA; Thu, 30 Dec 2004 23:03:28 +0100 (CET) Message-ID: <41D479D8.9010808@xbsd.org> Date: Thu, 30 Dec 2004 22:57:44 +0100 From: Florent Thoumie User-Agent: Mozilla Thunderbird 0.7.2 (Windows/20040707) X-Accept-Language: fr, en MIME-Version: 1.0 To: Frank Behrens References: <200412131138.iBDBceAj064131@moon.behrens> In-Reply-To: <200412131138.iBDBceAj064131@moon.behrens> X-Enigmail-Version: 0.85.0.0 X-Enigmail-Supports: pgp-inline, pgp-mime Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit X-Virus-Scanned: amavisd-new at xbsd.org cc: freebsd-ports@freebsd.org Subject: Re: Beginner Question: Best way to substitute variables X-BeenThere: freebsd-ports@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Porting software to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 30 Dec 2004 21:58:04 -0000 Frank Behrens a écrit : > Meanwhile I use FreeBSD for several years and now comes the time to > give something back. I'm creating a port and could not find an answer > to my question: > > What is the best way to set variables in scripts (e.g. pkg-install) > and text files (e.g. pkg-message) depending from Makefile variables > (e.g. PREFIX)? > I understand the Makefile rules and it is no problem to use variable > paths depending from $PREFIX, $DOCSDIR and other, but how they are > later used in scripts, like pkg-install and rc.d/scripts? IMHO > changing these and other variables in the Makefile should be enough > to adjust the complete port. > > As a possible solution I see: > Put all files in a separate directory, create Makefile dependencies > and replace the desired strings with "sed". But this seems to be not > the usual way, I could not find any example port. > > Please, could you point me to an example port, where this problem has > been solved in a practical way conform to FreeBSd development rules. The question is some weeks old now but I think I can add some piece of answer to the thread. Recently, 2 new variables appeared in bsd.port.mk that handles this kind of situation for you. See SUB_FILES and SUB_LIST in Mk/bsd.port.mk and net/bnbt or net/ldapsh for examples. Basically, you put file.in in ${FILESDIR} and set SUB_FILES=file. Substitution works like with pkg-plist, you can use %%VAR%% and it'll be replaced automagically. Some variables are added by default to SUB_LIST but you can add some (eg. SUB_LIST= RC_SUBR=$RC_SUBR). I began to wrote some documentation to add to the PH but I accidentally lost it. I'll try to do this ASAP. Best Regards. -- Florent Thoumie flz@xbsd.org