From: Pascal Packaging Team Date: Thu, 30 Mar 2023 19:31:30 +0000 (+0100) Subject: relpath X-Git-Tag: archive/raspbian/3.2.2+dfsg-20+rpi1^2~34 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=42a69bf73780e0097c0c083e6295576c8731ea57;p=fpc.git relpath This patch adds an utility for computing relative path according to a given base directory. This is useful for libraries that are to install .lpk in order to be used with lazarus. As these libraries may be compiled without need to build depend on Lazarus, we add it in fp-utils package which is likely to be used by any big project which build depends on fp-compiler. Gbp-Pq: Name relpath.patch --- diff --git a/fpcsrc/utils/fpmake.pp b/fpcsrc/utils/fpmake.pp index ccd705b4..fc2c0719 100644 --- a/fpcsrc/utils/fpmake.pp +++ b/fpcsrc/utils/fpmake.pp @@ -89,6 +89,7 @@ begin P.Targets.AddProgram('mkinsadd.pp'); P.Targets.AddProgram('postw32.pp'); P.Targets.AddProgram('rmcvsdir.pp'); + P.Targets.AddProgram('relpath.pas'); P.Targets.AddProgram('grab_vcsa.pp',[linux]); T:=P.Targets.AddProgram('fpcsubst.pp'); T.Dependencies.AddUnit('usubst'); diff --git a/fpcsrc/utils/relpath.pas b/fpcsrc/utils/relpath.pas new file mode 100644 index 00000000..bbf7c3c5 --- /dev/null +++ b/fpcsrc/utils/relpath.pas @@ -0,0 +1,16 @@ +program relpath; +uses + SysUtils; + +var + BaseDir: string; + TargetDir: string; +begin + TargetDir := ParamStr(1); + BaseDir := ParamStr(2); + if BaseDir = '' + then begin + BaseDir := GetCurrentDir; + end; + WriteLn(ExtractRelativePath(IncludeTrailingPathDelimiter(BaseDir), TargetDir)); +end. diff --git a/install/man/man1/relpath.1 b/install/man/man1/relpath.1 new file mode 100644 index 00000000..0c1c0206 --- /dev/null +++ b/install/man/man1/relpath.1 @@ -0,0 +1,32 @@ +.TH relpath 1 "7 May 2013" "Free Pascal" "Relative path computing tool" +.SH NAME +relpath \- The Free Pascal file deletion tool. + +.SH SYNOPSIS + +.B relpath +[\fIfile or directory\fR] [\fIbase directory\fR] + +.SH DESCRIPTION + +.B relpath +This is an utility for computing relative path according to a given base +directory. This is useful for libraries that are to install .lpk in order to be +used with lazarus. As these libraries may be compiled without need to build +depend on Lazarus, we add it in fp-utils package which is likely to be used by +any big project which build depends on fp-compiler. + +.SH USAGE + +.B relpath +takes the following arguments: +.TP +.B file or directory +The target file or directory for which relative path should be computed. +.TP +.B base directory +The base directory according to which the relative patch should be computed. + +.SH SEE ALSO +.IP +.BR readlink (1)