systems.pas 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804
  1. {
  2. Copyright (c) 1998-2002 by Florian Klaempfl
  3. This unit contains information about the target systems supported
  4. (these are not processor specific)
  5. This program is free software; you can redistribute it and/or modify
  6. iu under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 3 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program; if not, write to the Free Software
  15. Foundation, Inc., 675 Mass Ave, Cambridge- MA 02139, USA.
  16. ****************************************************************************
  17. }
  18. unit systems;
  19. {$i fpcdefs.inc}
  20. interface
  21. type
  22. tendian = (endian_little,endian_big);
  23. (*
  24. IMPORTANT NOTE:
  25. The value of this enumeration is stored in PPU files.
  26. Therefore adding new CPU targets should not change the
  27. values of the pre-existing targets. (CEC)
  28. FURTHERMORE : Make sure that this branch values, are
  29. consistant with the main branch version always.
  30. *)
  31. tsystemcpu=
  32. (
  33. cpu_no, { 0 }
  34. cpu_i386, { 1 }
  35. cpu_m68k, { 2 }
  36. cpu_alpha, { 3 }
  37. cpu_powerpc, { 4 }
  38. cpu_sparc, { 5 }
  39. cpu_vm, { 6 }
  40. cpu_iA64, { 7 }
  41. cpu_x86_64, { 8 }
  42. cpu_mips, { 9 }
  43. cpu_arm, { 10 }
  44. cpu_powerpc64 { 11 }
  45. );
  46. tasmmode= (asmmode_none
  47. { standard assembler (cpu dependant) with full parsing }
  48. ,asmmode_standard
  49. ,asmmode_i386_att
  50. ,asmmode_i386_intel
  51. ,asmmode_ppc_gas
  52. ,asmmode_ppc_motorola
  53. ,asmmode_arm_gas
  54. ,asmmode_sparc_gas
  55. ,asmmode_x86_64_gas
  56. ,asmmode_m68k_mot
  57. );
  58. (* IMPORTANT NOTE:
  59. the integer value of this enum is stored in PPU
  60. files to recognize the target, so if you add new targets
  61. allways add them at end PM
  62. FURTHERMORE : Make sure that this branch values are
  63. consistant with the main branch version always. (CEC)
  64. *)
  65. type
  66. tsystem =
  67. (
  68. system_none, { 0 }
  69. obsolete_system_i386_GO32V1,{ 1 }
  70. system_i386_GO32V2, { 2 }
  71. system_i386_linux, { 3 }
  72. system_i386_OS2, { 4 }
  73. system_i386_Win32, { 5 }
  74. system_i386_freebsd, { 6 }
  75. system_m68k_Amiga, { 7 }
  76. system_m68k_Atari, { 8 }
  77. system_m68k_Mac, { 9 }
  78. system_m68k_linux, { 10 }
  79. system_m68k_PalmOS, { 11 }
  80. system_alpha_linux, { 12 }
  81. system_powerpc_linux, { 13 }
  82. system_powerpc_macos, { 14 }
  83. system_i386_solaris, { 15 }
  84. system_i386_beos, { 16 }
  85. system_i386_netbsd, { 17 }
  86. system_m68k_netbsd, { 18 }
  87. system_i386_Netware, { 19 }
  88. system_i386_qnx, { 20 }
  89. system_i386_wdosx, { 21 }
  90. system_sparc_solaris, { 22 }
  91. system_sparc_linux, { 23 }
  92. system_i386_openbsd, { 24 }
  93. system_m68k_openbsd, { 25 }
  94. system_x86_64_linux, { 26 }
  95. system_powerpc_darwin, { 27 }
  96. system_i386_EMX, { 28 }
  97. system_powerpc_netbsd, { 29 }
  98. system_powerpc_openbsd, { 30 }
  99. system_arm_linux, { 31 }
  100. system_i386_watcom, { 32 }
  101. system_powerpc_MorphOS, { 33 }
  102. system_x86_64_freebsd, { 34 }
  103. system_i386_netwlibc, { 35 }
  104. system_powerpc_Amiga, { 36 }
  105. system_x86_64_win64, { 37 }
  106. system_arm_wince, { 38 }
  107. system_ia64_win64, { 39 }
  108. system_i386_wince, { 40 }
  109. system_x86_6432_linux, { 41 }
  110. system_arm_gba, { 42 }
  111. system_powerpc64_linux, { 43 }
  112. system_i386_darwin { 44 }
  113. );
  114. tasm = (as_none
  115. ,as_gas { standard gnu assembler }
  116. ,as_i386_as_aout
  117. ,as_i386_nasmcoff
  118. ,as_i386_nasmwin32
  119. ,as_i386_nasmwdosx
  120. ,as_i386_nasmelf
  121. ,as_i386_nasmobj
  122. ,as_i386_nasmbeos
  123. ,as_i386_tasm
  124. ,as_i386_masm
  125. ,as_i386_wasm
  126. ,as_i386_coff
  127. ,as_i386_pecoff
  128. ,as_i386_elf32
  129. ,as_i386_pecoffwdosx
  130. ,as_m68k_mit
  131. ,as_powerpc_mpw
  132. ,as_darwin
  133. ,as_x86_64_masm
  134. ,as_x86_64_pecoff
  135. ,as_i386_pecoffwince
  136. ,as_arm_pecoffwince
  137. );
  138. tar = (ar_none
  139. ,ar_gnu_ar,ar_mpw_ar
  140. );
  141. tres = (res_none
  142. ,res_gnu_windres,res_emxbind
  143. ,res_m68k_palmos,res_m68k_mpw
  144. ,res_powerpc_mpw,res_elf
  145. ,res_gnu_wince_windres
  146. );
  147. tdbg = (dbg_none
  148. ,dbg_stabs,dbg_dwarf
  149. );
  150. tscripttype = (script_none
  151. ,script_dos,script_unix,script_amiga,
  152. script_mpw
  153. );
  154. tabi = (abi_default
  155. ,abi_powerpc_sysv,abi_powerpc_aix
  156. );
  157. {*****************************************************************************
  158. Structures
  159. *****************************************************************************}
  160. type
  161. { Abstract linker class which is implemented in link module }
  162. TAbstractLinker = class
  163. end;
  164. TAbstractLinkerClass = class of TAbstractLinker;
  165. { Abstract assembler class which is implemented in assemble module }
  166. TAbstractAssembler = class
  167. end;
  168. TAbstractAssemblerClass = class of TAbstractAssembler;
  169. palignmentinfo = ^talignmentinfo;
  170. talignmentinfo = record
  171. procalign,
  172. loopalign,
  173. jumpalign,
  174. constalignmin,
  175. constalignmax,
  176. varalignmin,
  177. varalignmax,
  178. localalignmin,
  179. localalignmax,
  180. recordalignmin,
  181. recordalignmax,
  182. maxCrecordalign : longint;
  183. end;
  184. tasmflags = (af_none,
  185. af_outputbinary,af_allowdirect,
  186. af_needar,af_smartlink_sections,
  187. af_labelprefix_only_inside_procedure,
  188. af_supports_dwarf
  189. );
  190. pasminfo = ^tasminfo;
  191. tasminfo = record
  192. id : tasm;
  193. idtxt : string[12];
  194. asmbin : string[8];
  195. asmcmd : string[50];
  196. supported_target : tsystem;
  197. flags : set of tasmflags;
  198. labelprefix : string[3];
  199. comment : string[3];
  200. end;
  201. parinfo = ^tarinfo;
  202. tarinfo = record
  203. id : tar;
  204. arcmd : string[50];
  205. end;
  206. presinfo = ^tresinfo;
  207. tresinfo = record
  208. id : tres;
  209. resbin : string[8];
  210. rescmd : string[50];
  211. end;
  212. pdbginfo = ^tdbginfo;
  213. tdbginfo = record
  214. id : tdbg;
  215. idtxt : string[12];
  216. end;
  217. tsystemflags = (tf_none,
  218. tf_under_development,
  219. tf_need_export,
  220. tf_needs_isconsole,
  221. tf_code_small,
  222. tf_static_reg_based,
  223. tf_needs_symbol_size,
  224. tf_smartlink_sections,
  225. tf_needs_dwarf_cfi,
  226. tf_use_8_3,
  227. tf_pic_uses_got,
  228. tf_library_needs_pic,
  229. tf_needs_symbol_type,
  230. tf_section_threadvars
  231. );
  232. psysteminfo = ^tsysteminfo;
  233. { using packed causes bus errors on processors which require alignment }
  234. tsysteminfo = record
  235. system : tsystem;
  236. name : string[34];
  237. shortname : string[9];
  238. flags : set of tsystemflags;
  239. cpu : tsystemcpu;
  240. unit_env : string[16];
  241. extradefines : string[40];
  242. exeext,
  243. defext,
  244. scriptext,
  245. smartext,
  246. unitext,
  247. unitlibext,
  248. asmext,
  249. objext,
  250. resext,
  251. resobjext : string[4];
  252. sharedlibext : string[10];
  253. staticlibext,
  254. staticlibprefix : string[4];
  255. sharedlibprefix : string[4];
  256. sharedClibext : string[10];
  257. staticClibext,
  258. staticClibprefix : string[4];
  259. sharedClibprefix : string[4];
  260. p_ext_support:Boolean; {Whether extension .p is supported by default}
  261. Cprefix : string[2];
  262. newline : string[2];
  263. dirsep : char;
  264. files_case_relevent : boolean;
  265. assem : tasm;
  266. assemextern : tasm; { external assembler, used by -a }
  267. link : tabstractlinkerclass;
  268. linkextern : tabstractlinkerclass; { external linker, used by -s }
  269. ar : tar;
  270. res : tres;
  271. dbg : tdbg;
  272. script : tscripttype;
  273. endian : tendian;
  274. alignment : talignmentinfo;
  275. {
  276. Offset from the argument pointer register to the first
  277. argument's address. On some machines it may depend on
  278. the data type of the function.
  279. (see also FIRST_PARM_OFFSET in GCC source)
  280. }
  281. first_parm_offset : longint;
  282. stacksize : longint;
  283. DllScanSupported : boolean;
  284. use_function_relative_addresses : boolean;
  285. abi : tabi;
  286. end;
  287. const
  288. { alias for supported_target field in tasminfo }
  289. system_any = system_none;
  290. system_wince : set of tsystem = [system_arm_wince,system_i386_wince];
  291. system_linux = [system_i386_linux,system_x86_64_linux,system_powerpc_linux,
  292. system_arm_linux,system_sparc_linux,system_alpha_linux,system_m68k_linux,
  293. system_x86_6432_linux];
  294. { all real windows systems, no cripple ones like wince, wdosx et. al. }
  295. system_windows : set of tsystem = [system_i386_win32,system_x86_64_win64,system_ia64_win64];
  296. { all windows systems }
  297. system_all_windows : set of tsystem = [system_i386_win32,system_x86_64_win64,system_ia64_win64,
  298. system_arm_wince,system_i386_wince];
  299. { all systems supporting exports from programs or units }
  300. system_unit_program_exports : set of tsystem = [system_i386_win32,
  301. system_i386_wdosx,
  302. system_i386_Netware,
  303. system_i386_netwlibc,
  304. system_arm_wince,
  305. system_x86_64_win64,
  306. system_ia64_win64]+system_linux;
  307. cpu2str : array[TSystemCpu] of string =
  308. ('','i386','m68k','alpha','powerpc','sparc','vm','ia64','x86_64',
  309. 'mips','arm', 'powerpc64');
  310. var
  311. targetinfos : array[tsystem] of psysteminfo;
  312. arinfos : array[tar] of parinfo;
  313. resinfos : array[tres] of presinfo;
  314. asminfos : array[tasm] of pasminfo;
  315. dbginfos : array[tdbg] of pdbginfo;
  316. source_info : tsysteminfo;
  317. target_cpu : tsystemcpu;
  318. target_info : tsysteminfo;
  319. target_asm : tasminfo;
  320. target_ar : tarinfo;
  321. target_res : tresinfo;
  322. target_dbg : tdbginfo;
  323. target_cpu_string,
  324. target_os_string : string[12]; { for rtl/<X>/,fcl/<X>/, etc. }
  325. target_full_string : string[24];
  326. function set_target(t:tsystem):boolean;
  327. function set_target_asm(t:tasm):boolean;
  328. function set_target_ar(t:tar):boolean;
  329. function set_target_res(t:tres):boolean;
  330. function set_target_dbg(t:tdbg):boolean;
  331. function find_system_by_string(const s : string) : tsystem;
  332. function find_asm_by_string(const s : string) : tasm;
  333. function find_dbg_by_string(const s : string) : tdbg;
  334. procedure set_source_info(const ti : tsysteminfo);
  335. procedure UpdateAlignment(var d:talignmentinfo;const s:talignmentinfo);
  336. procedure RegisterTarget(const r:tsysteminfo);
  337. procedure RegisterRes(const r:tresinfo);
  338. procedure RegisterAr(const r:tarinfo);
  339. { Register the external linker. This routine is called to setup the
  340. class to use for the linker. It returns the tsysteminfo structure
  341. updated with the correct linker class for external linking.
  342. }
  343. procedure RegisterExternalLinker(var system_info: tsysteminfo; c:TAbstractLinkerClass);
  344. { Register the internal linker. This routine is called to setup the
  345. class to use for the linker. It returns the tsysteminfo structure
  346. updated with the correct linker class for internal linking.
  347. If internal linking is not supported, this class can be set
  348. to nil.
  349. }
  350. procedure RegisterInternalLinker(var system_info : tsysteminfo; c:TAbstractLinkerClass);
  351. procedure InitSystems;
  352. {$ifdef FreeBSD}
  353. function GetOSRelDate:Longint;
  354. {$endif}
  355. implementation
  356. uses
  357. cutils{$ifdef FreeBSD},SysCtl,BaseUnix{$endif};
  358. {****************************************************************************
  359. OS runtime version detection utility routine
  360. ****************************************************************************}
  361. {$ifdef FreeBSD}
  362. function GetOSRelDate:Longint;
  363. var
  364. mib : array[0..1] of cint;
  365. rval : cint;
  366. len : size_t;
  367. i : longint;
  368. v : longint;
  369. oerrno : cint;
  370. S : AnsiString;
  371. Begin
  372. s:='ab';
  373. SetLength(S,50);
  374. mib[0] := CTL_KERN;
  375. mib[1] := KERN_OSRELDATE;
  376. len := 4;
  377. oerrno:= fpgeterrno;
  378. if (FPsysctl(@mib, 2, pchar(@v), @len, NIL, 0) = -1) Then
  379. Begin
  380. if (fpgeterrno = ESysENOMEM) Then
  381. fpseterrno(oerrno);
  382. GetOSRelDate:=0;
  383. End
  384. else
  385. GetOSRelDate:=v;
  386. End;
  387. {$endif}
  388. {****************************************************************************
  389. Target setting
  390. ****************************************************************************}
  391. function set_target(t:tsystem):boolean;
  392. begin
  393. set_target:=false;
  394. if assigned(targetinfos[t]) then
  395. begin
  396. target_info:=targetinfos[t]^;
  397. set_target_asm(target_info.assem);
  398. set_target_ar(target_info.ar);
  399. set_target_res(target_info.res);
  400. set_target_dbg(target_info.dbg);
  401. target_cpu:=target_info.cpu;
  402. target_os_string:=lower(target_info.shortname);
  403. target_cpu_string:=cpu2str[target_cpu];
  404. target_full_string:=target_cpu_string+'-'+target_os_string;
  405. set_target:=true;
  406. exit;
  407. end;
  408. end;
  409. function set_target_asm(t:tasm):boolean;
  410. begin
  411. set_target_asm:=false;
  412. if assigned(asminfos[t]) and
  413. ((asminfos[t]^.supported_target=target_info.system) or
  414. (asminfos[t]^.supported_target=system_any)) then
  415. begin
  416. target_asm:=asminfos[t]^;
  417. set_target_asm:=true;
  418. exit;
  419. end;
  420. end;
  421. function set_target_ar(t:tar):boolean;
  422. begin
  423. result:=false;
  424. if assigned(arinfos[t]) then
  425. begin
  426. target_ar:=arinfos[t]^;
  427. result:=true;
  428. exit;
  429. end;
  430. end;
  431. function set_target_res(t:tres):boolean;
  432. begin
  433. result:=false;
  434. if assigned(resinfos[t]) then
  435. begin
  436. target_res:=resinfos[t]^;
  437. result:=true;
  438. exit;
  439. end;
  440. end;
  441. function set_target_dbg(t:tdbg):boolean;
  442. begin
  443. result:=false;
  444. if assigned(dbginfos[t]) then
  445. begin
  446. target_dbg:=dbginfos[t]^;
  447. result:=true;
  448. exit;
  449. end;
  450. end;
  451. function find_system_by_string(const s : string) : tsystem;
  452. var
  453. hs : string;
  454. t : tsystem;
  455. begin
  456. result:=system_none;
  457. hs:=upper(s);
  458. for t:=low(tsystem) to high(tsystem) do
  459. if assigned(targetinfos[t]) and
  460. (upper(targetinfos[t]^.shortname)=hs) then
  461. begin
  462. result:=t;
  463. exit;
  464. end;
  465. end;
  466. function find_asm_by_string(const s : string) : tasm;
  467. var
  468. hs : string;
  469. t : tasm;
  470. begin
  471. result:=as_none;
  472. hs:=upper(s);
  473. for t:=low(tasm) to high(tasm) do
  474. if assigned(asminfos[t]) and
  475. (asminfos[t]^.idtxt=hs) then
  476. begin
  477. result:=t;
  478. exit;
  479. end;
  480. end;
  481. function find_dbg_by_string(const s : string) : tdbg;
  482. var
  483. hs : string;
  484. t : tdbg;
  485. begin
  486. result:=dbg_none;
  487. hs:=upper(s);
  488. for t:=low(tdbg) to high(tdbg) do
  489. if assigned(dbginfos[t]) and
  490. (dbginfos[t]^.idtxt=hs) then
  491. begin
  492. result:=t;
  493. exit;
  494. end;
  495. end;
  496. procedure UpdateAlignment(var d:talignmentinfo;const s:talignmentinfo);
  497. begin
  498. with d do
  499. begin
  500. { general update rules:
  501. minimum: if higher then update
  502. maximum: if lower then update or if undefined then update }
  503. if s.procalign>procalign then
  504. procalign:=s.procalign;
  505. if s.loopalign>loopalign then
  506. loopalign:=s.loopalign;
  507. if s.jumpalign>jumpalign then
  508. jumpalign:=s.jumpalign;
  509. if s.constalignmin>constalignmin then
  510. constalignmin:=s.constalignmin;
  511. if (constalignmax=0) or
  512. ((s.constalignmax>0) and (s.constalignmax<constalignmax)) then
  513. constalignmax:=s.constalignmax;
  514. if s.varalignmin>varalignmin then
  515. varalignmin:=s.varalignmin;
  516. if (varalignmax=0) or
  517. ((s.varalignmax>0) and (s.varalignmax<varalignmax)) then
  518. varalignmax:=s.varalignmax;
  519. if s.localalignmin>localalignmin then
  520. localalignmin:=s.localalignmin;
  521. if (localalignmax=0) or
  522. ((s.localalignmax>0) and (s.localalignmax<localalignmax)) then
  523. localalignmax:=s.localalignmax;
  524. if s.recordalignmin>recordalignmin then
  525. recordalignmin:=s.recordalignmin;
  526. if (recordalignmax=0) or
  527. ((s.recordalignmax>0) and (s.recordalignmax<recordalignmax)) then
  528. recordalignmax:=s.recordalignmax;
  529. if (maxCrecordalign=0) or
  530. ((s.maxCrecordalign>0) and (s.maxCrecordalign<maxCrecordalign)) then
  531. maxCrecordalign:=s.maxCrecordalign;
  532. end;
  533. end;
  534. {****************************************************************************
  535. Target registration
  536. ****************************************************************************}
  537. procedure RegisterTarget(const r:tsysteminfo);
  538. var
  539. t : tsystem;
  540. begin
  541. t:=r.system;
  542. if assigned(targetinfos[t]) then
  543. writeln('Warning: Target is already registered!')
  544. else
  545. Getmem(targetinfos[t],sizeof(tsysteminfo));
  546. targetinfos[t]^:=r;
  547. end;
  548. procedure RegisterRes(const r:tresinfo);
  549. var
  550. t : tres;
  551. begin
  552. t:=r.id;
  553. if assigned(resinfos[t]) then
  554. writeln('Warning: resourcecompiler is already registered!')
  555. else
  556. Getmem(resinfos[t],sizeof(tresinfo));
  557. resinfos[t]^:=r;
  558. end;
  559. procedure RegisterAr(const r:tarinfo);
  560. var
  561. t : tar;
  562. begin
  563. t:=r.id;
  564. if assigned(arinfos[t]) then
  565. writeln('Warning: ar is already registered!')
  566. else
  567. Getmem(arinfos[t],sizeof(tarinfo));
  568. arinfos[t]^:=r;
  569. end;
  570. procedure RegisterExternalLinker(var system_info: tsysteminfo; c:TAbstractLinkerClass);
  571. begin
  572. system_info.linkextern := c;
  573. end;
  574. procedure RegisterInternalLinker(var system_info : tsysteminfo; c:TAbstractLinkerClass);
  575. begin
  576. system_info.link := c;
  577. end;
  578. procedure DeregisterInfos;
  579. var
  580. assem : tasm;
  581. target : tsystem;
  582. ar : tar;
  583. res : tres;
  584. begin
  585. for target:=low(tsystem) to high(tsystem) do
  586. if assigned(targetinfos[target]) then
  587. begin
  588. freemem(targetinfos[target],sizeof(tsysteminfo));
  589. targetinfos[target]:=nil;
  590. end;
  591. for assem:=low(tasm) to high(tasm) do
  592. if assigned(asminfos[assem]) then
  593. begin
  594. freemem(asminfos[assem],sizeof(tasminfo));
  595. asminfos[assem]:=nil;
  596. end;
  597. for ar:=low(tar) to high(tar) do
  598. if assigned(arinfos[ar]) then
  599. begin
  600. freemem(arinfos[ar],sizeof(tarinfo));
  601. arinfos[ar]:=nil;
  602. end;
  603. for res:=low(tres) to high(tres) do
  604. if assigned(resinfos[res]) then
  605. begin
  606. freemem(resinfos[res],sizeof(tresinfo));
  607. resinfos[res]:=nil;
  608. end;
  609. end;
  610. {****************************************************************************
  611. Initialization of default target
  612. ****************************************************************************}
  613. procedure default_target(t:tsystem);
  614. begin
  615. set_target(t);
  616. if source_info.name='' then
  617. source_info:=target_info;
  618. end;
  619. procedure set_source_info(const ti : tsysteminfo);
  620. begin
  621. { can't use message() here (PFV) }
  622. if source_info.name<>'' then
  623. Writeln('Warning: Source OS Redefined!');
  624. source_info:=ti;
  625. end;
  626. procedure InitSystems;
  627. begin
  628. { Now default target, this is dependent on the target cpu define,
  629. when the define is the same as the source cpu then we use the source
  630. os, else we pick a default }
  631. {$ifdef i386}
  632. {$ifdef cpu86}
  633. default_target(source_info.system);
  634. {$else cpu86}
  635. {$ifdef linux}
  636. default_target(system_i386_linux);
  637. {$endif}
  638. {$ifdef freebsd}
  639. default_target(system_i386_freebsd);
  640. {$endif}
  641. {$endif cpu86}
  642. {$endif i386}
  643. {$ifdef x86_64}
  644. {$ifdef cpux86_64}
  645. default_target(source_info.system);
  646. {$define source_system_set}
  647. {$else cpux86_64}
  648. {$ifdef linux}
  649. default_target(system_x86_64_linux);
  650. {$define source_system_set}
  651. {$endif}
  652. {$ifdef freebsd}
  653. default_target(system_x86_64_freebsd);
  654. {$define source_system_set}
  655. {$endif}
  656. { default is linux }
  657. {$ifndef source_system_set}
  658. default_target(system_x86_64_linux);
  659. {$endif source_system_set}
  660. {$endif cpux86_64}
  661. {$endif x86_64}
  662. {$ifdef m68k}
  663. {$ifdef cpu68}
  664. default_target(source_info.target);
  665. {$else cpu68}
  666. default_target(system_m68k_linux);
  667. {$endif cpu68}
  668. {$endif m68k}
  669. {$ifdef alpha}
  670. {$ifdef cpualpha}
  671. default_target(source_info.system);
  672. {$else cpualpha}
  673. default_target(system_alpha_linux);
  674. {$endif cpualpha}
  675. {$endif alpha}
  676. {$ifdef powerpc}
  677. {$ifdef cpupowerpc}
  678. default_target(source_info.system);
  679. {$else cpupowerpc}
  680. default_target(system_powerpc_linux);
  681. {$endif cpupowerpc}
  682. {$endif powerpc}
  683. {$ifdef POWERPC64}
  684. {$ifdef cpupowerpc64}
  685. default_target(source_info.system);
  686. {$else cpupowerpc64}
  687. default_target(system_powerpc64_linux);
  688. {$endif cpupowerpc64}
  689. {$endif POWERPC64}
  690. {$ifdef sparc}
  691. {$ifdef cpusparc}
  692. default_target(source_info.system);
  693. {$else cpusparc}
  694. default_target(system_sparc_linux);
  695. {$endif cpusparc}
  696. {$endif sparc}
  697. {$ifdef arm}
  698. {$ifdef cpuarm}
  699. default_target(source_info.system);
  700. {$else cpuarm}
  701. default_target(system_arm_linux);
  702. {$endif cpuarm}
  703. {$endif arm}
  704. end;
  705. initialization
  706. source_info.name:='';
  707. finalization
  708. DeregisterInfos;
  709. end.