relpath
authorCarlos Laviola <claviola@debian.org>
Mon, 13 Oct 2014 19:16:54 +0000 (19:16 +0000)
committerPaul Gevers <elbrus@debian.org>
Mon, 13 Oct 2014 19:16:54 +0000 (19:16 +0000)
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

fpcsrc/utils/Makefile.fpc
fpcsrc/utils/relpath.pas [new file with mode: 0644]
install/man/man1/relpath.1 [new file with mode: 0644]

index ff4c8b6958a1c40b520f41710e6e540e996b4868..de15a0e0daad148032442e8a1f7376cc92a5bda4 100644 (file)
@@ -8,7 +8,7 @@ version=2.6.4
 
 [target]
 dirs=fppkg fpcm tply h2pas fprcp dxegen fpdoc fpcmkcfg pas2ut pas2fpm
-programs=ppdep ptop rstconv data2inc delp bin2obj postw32 rmcvsdir
+programs=ppdep ptop rstconv data2inc delp bin2obj postw32 rmcvsdir relpath
 programs_linux=grab_vcsa
 dirs_win32=fpmc fpcres rmwait instantfpc importtl
 dirs_win64=fpmc fpcres rmwait instantfpc importtl
diff --git a/fpcsrc/utils/relpath.pas b/fpcsrc/utils/relpath.pas
new file mode 100644 (file)
index 0000000..bbf7c3c
--- /dev/null
@@ -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 (file)
index 0000000..0c1c020
--- /dev/null
@@ -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)