Index: head/en_US.ISO8859-1/books/porters-handbook/plist/chapter.xml =================================================================== --- head/en_US.ISO8859-1/books/porters-handbook/plist/chapter.xml +++ head/en_US.ISO8859-1/books/porters-handbook/plist/chapter.xml @@ -288,6 +288,82 @@ must be listed as specified in the shared libraries section. + + + Expanding <varname>PLIST_SUB</varname> With Regular + Expressions + + Strings to be replaced sometimes need to be very specific + to avoid undesired replacements. This is a common problem + with shorter values. + + To address this problem, for each + PLACEHOLDER=value, + a + PLACEHOLDER_regex=regex + can be set, with the + regex part + matching value more + precisely. + + + Using PLIST_SUB With Regular Expressions + + Perl ports can install + architecture dependant files in a specific tree. On &os; to + ease porting, this tree is called mach. + For example, a port that installs a file whose path contains + mach could have that part of the path + string replaced with the wrong values. Consider this + Makefile: + + PORTNAME= Machine-Build +PORTVERSION= 1 +CATEGORIES= devel perl5 +MASTER_SITES= CPAN +PKGNAMEPREFIX= p5- + +MAINTAINER= perl@FreeBSD.org +COMMENT= Building machine + +USES= perl5 +USE_PERL5= configure + +PLIST_SUB= PERL_ARCH=mach + + The files installed by the port are: + + /usr/local/bin/machine-build +/usr/local/lib/perl5/site_perl/man/man1/machine-build.1.gz +/usr/local/lib/perl5/site_perl/man/man3/Machine::Build.3.gz +/usr/local/lib/perl5/site_perl/Machine/Build.pm +/usr/local/lib/perl5/site_perl/mach/5.20/Machine/Build/Build.so + + Runnig make makeplist wrongly + generates: + + bin/%%PERL_ARCH%%ine-build +%%PERL5_MAN1%%/%%PERL_ARCH%%ine-build.1.gz +%%PERL5_MAN3%%/Machine::Build.3.gz +%%SITE_PERL%%/Machine/Build.pm +%%SITE_PERL%%/%%PERL_ARCH%%/%%PERL_VER%%/Machine/Build/Build.so + + Change the PLIST_SUB line from the + Makefile to: + + PLIST_SUB= PERL_ARCH=mach \ + PERL_ARCH_regex=\bmach\b + + Now make makeplist correctly + generates: + + bin/machine-build +%%PERL5_MAN1%%/machine-build.1.gz +%%PERL5_MAN3%%/Machine::Build.3.gz +%%SITE_PERL%%/Machine/Build.pm +%%SITE_PERL%%/%%PERL_ARCH%%/%%PERL_VER%%/Machine/Build/Build.so + +