+ ----------------------
+ -- Create_Sym_Links --
+ ----------------------
+
+ procedure Create_Sym_Links
+ (Lib_Path : String;
+ Lib_Version : String;
+ Lib_Dir : String;
+ Maj_Version : String)
+ is
+ function Symlink
+ (Oldpath : System.Address;
+ Newpath : System.Address) return Integer;
+ pragma Import (C, Symlink, "__gnat_symlink");
+
+ Version_Path : String_Access;
+
+ Success : Boolean;
+ Result : Integer;
+ pragma Unreferenced (Success, Result);
+
+ begin
+ Version_Path := new String (1 .. Lib_Version'Length + 1);
+ Version_Path (1 .. Lib_Version'Length) := Lib_Version;
+ Version_Path (Version_Path'Last) := ASCII.NUL;
+
+ if Maj_Version'Length = 0 then
+ declare
+ Newpath : String (1 .. Lib_Path'Length + 1);
+ begin
+ Newpath (1 .. Lib_Path'Length) := Lib_Path;
+ Newpath (Newpath'Last) := ASCII.NUL;
+ Delete_File (Lib_Path, Success);
+ Result := Symlink (Version_Path (1)'Address, Newpath'Address);
+ end;
+
+ else
+ declare
+ Newpath1 : String (1 .. Lib_Path'Length + 1);
+ Maj_Path : constant String :=
+ Lib_Dir & Directory_Separator & Maj_Version;
+ Newpath2 : String (1 .. Maj_Path'Length + 1);
+ Maj_Ver : String (1 .. Maj_Version'Length + 1);
+
+ begin
+ Newpath1 (1 .. Lib_Path'Length) := Lib_Path;
+ Newpath1 (Newpath1'Last) := ASCII.NUL;
+
+ Newpath2 (1 .. Maj_Path'Length) := Maj_Path;
+ Newpath2 (Newpath2'Last) := ASCII.NUL;
+
+ Maj_Ver (1 .. Maj_Version'Length) := Maj_Version;
+ Maj_Ver (Maj_Ver'Last) := ASCII.NUL;
+
+ Delete_File (Maj_Path, Success);
+
+ Result := Symlink (Version_Path (1)'Address, Newpath2'Address);
+
+ Delete_File (Lib_Path, Success);
+
+ Result := Symlink (Maj_Ver'Address, Newpath1'Address);
+ end;
+ end if;
+ end Create_Sym_Links;
+