-
Notifications
You must be signed in to change notification settings - Fork 4
/
m_freebsd64_to_freebsd32.pas
101 lines (83 loc) · 2.91 KB
/
m_freebsd64_to_freebsd32.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
unit m_freebsd64_to_freebsd32;
{ Cross compiles from FreeBSD x64 to FreeBSD x86
Needed ports/packages:
- to do: default available with pc bsd; need to find out for freebsd
perhaps something like
cd /usr/src && make build32 install32 && ldconfig -v -m -R /usr/lib32
}
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, m_crossinstaller, fpcuputil;
implementation
type
{ TFreeBSD_win386 }
TFreeBSD64_FreeBSD386 = class(TCrossInstaller)
private
public
function GetLibs(Basepath:string):boolean;override;
function GetLibsLCL(LCL_Platform:string; Basepath:string):boolean;override;
function GetBinUtils(Basepath:string):boolean;override;
constructor Create;
destructor Destroy; override;
end;
{ TFreeBSD64_FreeBSD386 }
function TFreeBSD64_FreeBSD386.GetLibs(Basepath:string): boolean;
begin
FLibsPath:='/usr/lib32';
result:=fileexists(FLibsPath+'/libc.so'); //let the c library be our coalmine canary
if result then
//todo: check if -XR is needed for fpc root dir Prepend <x> to all linker search paths
FFPCCFGSnippet:=FFPCCFGSnippet+LineEnding+
'-Fl'+IncludeTrailingPathDelimiter(FLibsPath) {buildfaq 1.6.4/3.3.1: the directory to look for the target libraries};
end;
function TFreeBSD64_FreeBSD386.GetLibsLCL(LCL_Platform: string; Basepath: string): boolean;
begin
result:=true;
end;
function TFreeBSD64_FreeBSD386.GetBinUtils(Basepath:string): boolean;
begin
inherited;
//todo: remove once done
infoln('TFreeBSD64_FreeBSD386: Experimental, not finished. Stopping now.',etError);
result:=false;
FBinUtilsPath:='/usr/bin'; //try with regular binutils
FBinUtilsPrefix:=''; // we have the "native" names, no prefix
result:=true;
if result then
begin
// Configuration snippet for FPC
FFPCCFGSnippet:=FFPCCFGSnippet+LineEnding+
'-FD'+IncludeTrailingPathDelimiter(FBinUtilsPath)+LineEnding+ {search this directory for compiler utilities}
'-XP'+FBinUtilsPrefix+LineEnding+ {Prepend the binutils names}
'-Tlinux'; {target operating system}
end;
end;
constructor TFreeBSD64_FreeBSD386.Create;
begin
inherited Create;
FCrossModuleName:='FreeBSD64_FreeBSD386';
FTargetCPU:='i386';
FTargetOS:='freebsd';
FBinUtilsPath:='';
FBinUtilsPrefix:='';
FLibsPath:='';
infoln('TFreeBSD64_FreeBSD386 crosscompiler loading',etDebug);
end;
destructor TFreeBSD64_FreeBSD386.Destroy;
begin
inherited Destroy;
end;
var
FreeBSD64_FreeBSD386:TFreeBSD64_FreeBSD386;
//todo: FreeBSD64_FreeBSD386: enable when working. For this, we'll probably need to pass -32 to ld etc. Perhaps do this with batch scripts
{$IFDEF FREEBSD}
{$IFDEF CPUAMD64}
initialization
FreeBSD64_FreeBSD386:=TFreeBSD64_FreeBSD386.Create;
RegisterExtension(FreeBSD64_FreeBSD386.TargetCPU+'-'+FreeBSD64_FreeBSD386.TargetOS,FreeBSD64_FreeBSD386);
finalization
FreeBSD64_FreeBSD386.Destroy;
{$ENDIF CPUAMD64}
{$ENDIF FREEBSD}
end.