t_bsd.pas 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663
  1. {
  2. Copyright (c) 1998-2002 by Peter Vreman (original Linux)
  3. (c) 2000 by Marco van de Voort (FreeBSD mods)
  4. This unit implements support import,export,link routines
  5. for the (i386)FreeBSD target
  6. This program is free software; you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation; either version 2 of the License, or
  9. (at your option) any later version.
  10. This program is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. GNU General Public License for more details.
  14. You should have received a copy of the GNU General Public License
  15. along with this program; if not, write to the Free Software
  16. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  17. ****************************************************************************
  18. }
  19. unit t_bsd;
  20. {$i fpcdefs.inc}
  21. interface
  22. implementation
  23. uses
  24. cutils,cclasses,
  25. {$ifdef USE_SYSUTILS}
  26. sysutils,
  27. {$else USE_SYSUTILS}
  28. dos,
  29. {$endif USE_SYSUTILS}
  30. verbose,systems,globtype,globals,
  31. symconst,script,
  32. fmodule,aasmbase,aasmtai,aasmdata,aasmcpu,cpubase,symsym,symdef,
  33. import,export,link,i_bsd,
  34. cgutils,cgbase,cgobj,cpuinfo,ogbase;
  35. type
  36. timportlibdarwin=class(timportlib)
  37. procedure generatelib;override;
  38. end;
  39. timportlibbsd=class(timportlib)
  40. procedure generatelib;override;
  41. end;
  42. texportlibbsd=class(texportlib)
  43. procedure preparelib(const s : string);override;
  44. procedure exportprocedure(hp : texported_item);override;
  45. procedure exportvar(hp : texported_item);override;
  46. procedure generatelib;override;
  47. end;
  48. tlinkerbsd=class(texternallinker)
  49. private
  50. LdSupportsNoResponseFile : boolean;
  51. LibrarySuffix : Char;
  52. Function WriteResponseFile(isdll:boolean) : Boolean;
  53. public
  54. constructor Create;override;
  55. procedure SetDefaultInfo;override;
  56. function MakeExecutable:boolean;override;
  57. function MakeSharedLibrary:boolean;override;
  58. procedure LoadPredefinedLibraryOrder; override;
  59. end;
  60. {*****************************************************************************
  61. TIMPORTLIBDARWIN
  62. *****************************************************************************}
  63. procedure timportlibdarwin.generatelib;
  64. begin
  65. end;
  66. {*****************************************************************************
  67. TIMPORTLIBBSD
  68. *****************************************************************************}
  69. procedure timportlibbsd.generatelib;
  70. var
  71. i : longint;
  72. ImportLibrary : TImportLibrary;
  73. begin
  74. for i:=0 to current_module.ImportLibraryList.Count-1 do
  75. begin
  76. ImportLibrary:=TImportLibrary(current_module.ImportLibraryList[i]);
  77. current_module.linkothersharedlibs.add(ImportLibrary.Name,link_always);
  78. end;
  79. end;
  80. {*****************************************************************************
  81. TEXPORTLIBBSD
  82. *****************************************************************************}
  83. procedure texportlibbsd.preparelib(const s:string);
  84. begin
  85. end;
  86. procedure texportlibbsd.exportprocedure(hp : texported_item);
  87. var
  88. hp2 : texported_item;
  89. begin
  90. { first test the index value }
  91. if (hp.options and eo_index)<>0 then
  92. begin
  93. Message1(parser_e_no_export_with_index_for_target,'*bsd/darwin');
  94. exit;
  95. end;
  96. { now place in correct order }
  97. hp2:=texported_item(current_module._exports.first);
  98. while assigned(hp2) and
  99. (hp.name^>hp2.name^) do
  100. hp2:=texported_item(hp2.next);
  101. { insert hp there !! }
  102. if assigned(hp2) and (hp2.name^=hp.name^) then
  103. begin
  104. { this is not allowed !! }
  105. Message1(parser_e_export_name_double,hp.name^);
  106. exit;
  107. end;
  108. if hp2=texported_item(current_module._exports.first) then
  109. current_module._exports.concat(hp)
  110. else if assigned(hp2) then
  111. begin
  112. hp.next:=hp2;
  113. hp.previous:=hp2.previous;
  114. if assigned(hp2.previous) then
  115. hp2.previous.next:=hp;
  116. hp2.previous:=hp;
  117. end
  118. else
  119. current_module._exports.concat(hp);
  120. end;
  121. procedure texportlibbsd.exportvar(hp : texported_item);
  122. begin
  123. hp.is_var:=true;
  124. exportprocedure(hp);
  125. end;
  126. procedure texportlibbsd.generatelib; // straight t_linux copy for now.
  127. var
  128. hp2 : texported_item;
  129. {$ifdef x86}
  130. sym : tasmsymbol;
  131. r : treference;
  132. {$endif x86}
  133. begin
  134. new_section(current_asmdata.asmlists[al_procedures],sec_code,'',0);
  135. hp2:=texported_item(current_module._exports.first);
  136. while assigned(hp2) do
  137. begin
  138. if (not hp2.is_var) and
  139. (hp2.sym.typ=procsym) then
  140. begin
  141. { the manglednames can already be the same when the procedure
  142. is declared with cdecl }
  143. if tprocsym(hp2.sym).first_procdef.mangledname<>hp2.name^ then
  144. begin
  145. { place jump in al_procedures }
  146. current_asmdata.asmlists[al_procedures].concat(tai_align.create(target_info.alignment.procalign));
  147. current_asmdata.asmlists[al_procedures].concat(Tai_symbol.Createname_global(hp2.name^,AT_FUNCTION,0));
  148. if (cs_create_pic in aktmoduleswitches) and
  149. { other targets need to be checked how it works }
  150. (target_info.system in [system_i386_freebsd]) then
  151. begin
  152. {$ifdef x86}
  153. sym:=current_asmdata.RefAsmSymbol(tprocsym(hp2.sym).first_procdef.mangledname);
  154. reference_reset_symbol(r,sym,0);
  155. if cs_create_pic in aktmoduleswitches then
  156. r.refaddr:=addr_pic
  157. else
  158. r.refaddr:=addr_full;
  159. current_asmdata.asmlists[al_procedures].concat(taicpu.op_ref(A_JMP,S_NO,r));
  160. {$endif x86}
  161. end
  162. else
  163. cg.a_jmp_name(current_asmdata.asmlists[al_procedures],tprocsym(hp2.sym).first_procdef.mangledname);
  164. current_asmdata.asmlists[al_procedures].concat(Tai_symbol_end.Createname(hp2.name^));
  165. end;
  166. end
  167. else
  168. Message1(parser_e_no_export_of_variables_for_target,'*bsd/darwin');
  169. hp2:=texported_item(hp2.next);
  170. end;
  171. end;
  172. {*****************************************************************************
  173. TLINKERBSD
  174. *****************************************************************************}
  175. Constructor TLinkerBSD.Create;
  176. begin
  177. Inherited Create;
  178. if not Dontlinkstdlibpath Then
  179. if not(target_info.system in [system_powerpc_darwin,system_i386_darwin]) then
  180. LibrarySearchPath.AddPath('/lib;/usr/lib;/usr/X11R6/lib',true)
  181. else
  182. { Mac OS X doesn't have a /lib }
  183. LibrarySearchPath.AddPath('/usr/lib',true)
  184. end;
  185. procedure TLinkerBSD.SetDefaultInfo;
  186. {
  187. This will also detect which libc version will be used
  188. }
  189. begin
  190. LibrarySuffix:=' ';
  191. LdSupportsNoResponseFile := (target_info.system in [system_m68k_netbsd,system_powerpc_darwin,system_i386_darwin]);
  192. with Info do
  193. begin
  194. if LdSupportsNoResponseFile then
  195. begin
  196. if not(target_info.system in [system_powerpc_darwin,system_i386_darwin]) then
  197. begin
  198. ExeCmd[1]:='ld $OPT $DYNLINK $STATIC $GCSECTIONS $STRIP -L. -o $EXE `cat $RES`';
  199. DllCmd[1]:='ld $OPT -shared -L. -o $EXE `cat $RES`'
  200. end
  201. else
  202. begin
  203. ExeCmd[1]:='ld $OPT $DYNLINK $STATIC $GCSECTIONS $STRIP -multiply_defined suppress -L. -o $EXE `cat $RES`';
  204. DllCmd[1]:='libtool $OPT -dynamic -multiply_defined suppress -L. -o $EXE `cat $RES`'
  205. end
  206. end
  207. else
  208. begin
  209. ExeCmd[1]:='ld $OPT $DYNLINK $STATIC $GCSECTIONS $STRIP -L. -o $EXE $RES';
  210. DllCmd[1]:='ld $OPT $INIT $FINI $SONAME -shared -L. -o $EXE $RES';
  211. end;
  212. if not(target_info.system in [system_powerpc_darwin,system_i386_darwin]) then
  213. DllCmd[2]:='strip --strip-unneeded $EXE'
  214. else
  215. DllCmd[2]:='strip -x $EXE';
  216. DynamicLinker:='';
  217. end;
  218. end;
  219. procedure TLinkerBSD.LoadPredefinedLibraryOrder;
  220. // put your linkorder/linkalias overrides here.
  221. // Note: assumes only called when reordering/aliasing is used.
  222. Begin
  223. if not(target_info.system in [system_powerpc_darwin,system_i386_darwin]) then
  224. begin
  225. if (target_info.system =system_i386_freebsd) and
  226. not (cs_link_no_default_lib_order in aktglobalswitches) Then
  227. Begin
  228. LinkLibraryOrder.add('gcc','',15);
  229. LinkLibraryOrder.add('c','',50); // c and c_p mutual. excl?
  230. LinkLibraryOrder.add('c_p','',55);
  231. LinkLibraryOrder.add('pthread','',75); // pthread and c_r should be mutually exclusive
  232. LinkLibraryOrder.add('c_r','',76);
  233. LinkLibraryOrder.add('kvm','',80); // must be before ncurses
  234. if (cs_link_pthread in aktglobalswitches) Then // convert libpthread to libc_r.
  235. LinkLibraryAliases.add('pthread','c_r');
  236. end;
  237. end
  238. else
  239. begin
  240. LinkLibraryOrder.add('gcc','',15);
  241. LinkLibraryOrder.add('c','',50);
  242. end;
  243. End;
  244. Function TLinkerBSD.WriteResponseFile(isdll:boolean) : Boolean;
  245. Var
  246. linkres : TLinkRes;
  247. i : longint;
  248. cprtobj,
  249. gprtobj,
  250. prtobj : string[80];
  251. HPath : TStringListItem;
  252. s,s1,s2 : string;
  253. linkdynamic,
  254. linklibc : boolean;
  255. Fl1,Fl2 : Boolean;
  256. IsDarwin : Boolean;
  257. ReOrder : Boolean;
  258. begin
  259. WriteResponseFile:=False;
  260. ReOrder:=False;
  261. IsDarwin:=target_info.system in [system_powerpc_darwin,system_i386_darwin];
  262. { set special options for some targets }
  263. if not IsDarwin Then
  264. begin
  265. prtobj:='prt0';
  266. cprtobj:='cprt0';
  267. gprtobj:='gprt0';
  268. linkdynamic:=not(SharedLibFiles.empty);
  269. linklibc:=(SharedLibFiles.Find('c')<>nil);
  270. // this one is a bit complex.
  271. // Only reorder for now if -XL or -XO params are given
  272. // or when -Xf.
  273. reorder:= linklibc and
  274. (
  275. ReorderEntries
  276. or
  277. (cs_link_pthread in aktglobalswitches));
  278. if cs_profile in aktmoduleswitches then
  279. begin
  280. prtobj:=gprtobj;
  281. AddSharedLibrary('c');
  282. LibrarySuffix:='p';
  283. linklibc:=true;
  284. end
  285. else
  286. begin
  287. if linklibc then
  288. prtobj:=cprtobj;
  289. end;
  290. // after this point addition of shared libs not allowed.
  291. end
  292. else
  293. begin
  294. { for darwin: always link dynamically against libc }
  295. linklibc := true;
  296. reorder:=reorderentries;
  297. if not(isdll) then
  298. if not(cs_profile in aktmoduleswitches) then
  299. begin
  300. if librarysearchpath.FindFile('crt1.o',s) then
  301. prtobj:=s
  302. else
  303. prtobj:='/usr/lib/crt1.o';
  304. end
  305. else
  306. prtobj:='/usr/lib/gcrt1.o'
  307. else
  308. prtobj:='';
  309. end;
  310. if reorder Then
  311. ExpandAndApplyOrder(SharedLibFiles);
  312. { Open link.res file }
  313. LinkRes:=TLinkRes.Create(outputexedir+Info.ResName);
  314. if (not isdll) then
  315. begin
  316. case target_info.system of
  317. system_powerpc_darwin:
  318. LinkRes.Add('-arch ppc');
  319. system_i386_darwin:
  320. LinkRes.Add('-arch i386');
  321. end;
  322. end;
  323. { Write path to search libraries }
  324. HPath:=TStringListItem(current_module.locallibrarysearchpath.First);
  325. while assigned(HPath) do
  326. begin
  327. if LdSupportsNoResponseFile then
  328. LinkRes.Add(maybequoted('-L'+HPath.Str))
  329. else
  330. LinkRes.Add('SEARCH_DIR('+maybequoted(HPath.Str)+')');
  331. HPath:=TStringListItem(HPath.Next);
  332. end;
  333. HPath:=TStringListItem(LibrarySearchPath.First);
  334. while assigned(HPath) do
  335. begin
  336. if LdSupportsNoResponseFile then
  337. LinkRes.Add(maybequoted('-L'+HPath.Str))
  338. else
  339. LinkRes.Add('SEARCH_DIR('+maybequoted(HPath.Str)+')');
  340. HPath:=TStringListItem(HPath.Next);
  341. end;
  342. if not LdSupportsNoResponseFile then
  343. LinkRes.Add('INPUT(');
  344. { add objectfiles, start with prt0 always }
  345. if prtobj<>'' then
  346. LinkRes.AddFileName(FindObjectFile(prtobj,'',false));
  347. { try to add crti and crtbegin if linking to C }
  348. if linklibc and
  349. not IsDarwin Then
  350. begin
  351. if librarysearchpath.FindFile('crtbegin.o',s) then
  352. LinkRes.AddFileName(s);
  353. if librarysearchpath.FindFile('crti.o',s) then
  354. LinkRes.AddFileName(s);
  355. end;
  356. { main objectfiles }
  357. while not ObjectFiles.Empty do
  358. begin
  359. s:=ObjectFiles.GetFirst;
  360. if s<>'' then
  361. LinkRes.AddFileName(maybequoted(s));
  362. end;
  363. if not LdSupportsNoResponseFile then
  364. LinkRes.Add(')');
  365. { Write staticlibraries }
  366. if not StaticLibFiles.Empty then
  367. begin
  368. if not LdSupportsNoResponseFile then
  369. LinkRes.Add('GROUP(');
  370. While not StaticLibFiles.Empty do
  371. begin
  372. S:=StaticLibFiles.GetFirst;
  373. LinkRes.AddFileName(maybequoted(s))
  374. end;
  375. if not LdSupportsNoResponseFile then
  376. LinkRes.Add(')');
  377. end;
  378. { Write sharedlibraries like -l<lib>, also add the needed dynamic linker
  379. here to be sure that it gets linked this is needed for glibc2 systems (PFV) }
  380. if not SharedLibFiles.Empty then
  381. begin
  382. if not LdSupportsNoResponseFile then
  383. LinkRes.Add('INPUT(');
  384. While not SharedLibFiles.Empty do
  385. begin
  386. S:=SharedLibFiles.GetFirst;
  387. if (s<>'c') or reorder then
  388. begin
  389. i:=Pos(target_info.sharedlibext,S);
  390. if i>0 then
  391. Delete(S,i,255);
  392. LinkRes.Add('-l'+s);
  393. end
  394. else
  395. begin
  396. linklibc:=true;
  397. linkdynamic:=false; { libc will include the ld-* for us }
  398. end;
  399. end;
  400. { be sure that libc is the last lib }
  401. if linklibc and not reorder then
  402. Begin
  403. If LibrarySuffix=' ' Then
  404. LinkRes.Add('-lc')
  405. else
  406. LinkRes.Add('-lc_'+LibrarySuffix);
  407. If LibrarySuffix='r' Then
  408. LinkRes.Add('-lc');
  409. end;
  410. { when we have -static for the linker the we also need libgcc }
  411. if (cs_link_staticflag in aktglobalswitches) then
  412. LinkRes.Add('-lgcc');
  413. if linkdynamic and (Info.DynamicLinker<>'') then
  414. LinkRes.AddFileName(Info.DynamicLinker);
  415. if not LdSupportsNoResponseFile then
  416. LinkRes.Add(')');
  417. end;
  418. { objects which must be at the end }
  419. if linklibc and
  420. not IsDarwin Then
  421. begin
  422. Fl1:=librarysearchpath.FindFile('crtend.o',s1);
  423. Fl2:=librarysearchpath.FindFile('crtn.o',s2);
  424. if Fl1 or Fl2 then
  425. begin
  426. LinkRes.Add('INPUT(');
  427. If Fl1 Then
  428. LinkRes.AddFileName(s1);
  429. If Fl2 Then
  430. LinkRes.AddFileName(s2);
  431. LinkRes.Add(')');
  432. end;
  433. end;
  434. { ignore the fact that our relocations are in non-writable sections, }
  435. { will be fixed once we have pic support }
  436. if isdll and IsDarwin Then
  437. LinkRes.Add('-read_only_relocs suppress');
  438. { Write and Close response }
  439. linkres.writetodisk;
  440. linkres.Free;
  441. WriteResponseFile:=True;
  442. end;
  443. function TLinkerBSD.MakeExecutable:boolean;
  444. var
  445. binstr : String;
  446. cmdstr : TCmdStr;
  447. success : boolean;
  448. DynLinkStr : string[60];
  449. GCSectionsStr,
  450. StaticStr,
  451. StripStr : string[40];
  452. begin
  453. if not(cs_link_nolink in aktglobalswitches) then
  454. Message1(exec_i_linking,current_module.exefilename^);
  455. { Create some replacements }
  456. StaticStr:='';
  457. StripStr:='';
  458. DynLinkStr:='';
  459. GCSectionsStr:='';
  460. if (cs_link_staticflag in aktglobalswitches) then
  461. begin
  462. if (target_info.system=system_m68k_netbsd) and
  463. ((cs_link_on_target in aktglobalswitches) or
  464. (target_info.system=source_info.system)) then
  465. StaticStr:='-Bstatic'
  466. else
  467. StaticStr:='-static';
  468. end;
  469. if (cs_link_strip in aktglobalswitches) then
  470. StripStr:='-s';
  471. if (cs_link_smart in aktglobalswitches) and
  472. (tf_smartlink_sections in target_info.flags) then
  473. if not(target_info.system in [system_powerpc_darwin,system_i386_darwin]) then
  474. GCSectionsStr:='--gc-sections'
  475. else
  476. // warning: this option only exists for 32 bit under Mac OS X, maybe the default for 64 bit?
  477. GCSectionsStr:='-dead_strip';
  478. If (cs_profile in aktmoduleswitches) or
  479. ((Info.DynamicLinker<>'') and (not SharedLibFiles.Empty)) then
  480. DynLinkStr:='-dynamic-linker='+Info.DynamicLinker;
  481. if CShared Then
  482. begin
  483. if not(target_info.system in [system_powerpc_darwin,system_i386_darwin]) then
  484. DynLinKStr:=DynLinkStr+' --shared'
  485. else
  486. DynLinKStr:=DynLinkStr+' -dynamic'; // one dash!
  487. end;
  488. { Write used files and libraries }
  489. WriteResponseFile(false);
  490. { Call linker }
  491. SplitBinCmd(Info.ExeCmd[1],binstr,cmdstr);
  492. Replace(cmdstr,'$EXE',maybequoted(current_module.exefilename^));
  493. Replace(cmdstr,'$OPT',Info.ExtraOptions);
  494. Replace(cmdstr,'$RES',maybequoted(outputexedir+Info.ResName));
  495. Replace(cmdstr,'$STATIC',StaticStr);
  496. Replace(cmdstr,'$STRIP',StripStr);
  497. Replace(cmdstr,'$GCSECTIONS',GCSectionsStr);
  498. Replace(cmdstr,'$DYNLINK',DynLinkStr);
  499. success:=DoExec(FindUtil(utilsprefix+BinStr),CmdStr,true,LdSupportsNoResponseFile);
  500. { Remove ReponseFile }
  501. if (success) and not(cs_link_nolink in aktglobalswitches) then
  502. RemoveFile(outputexedir+Info.ResName);
  503. MakeExecutable:=success; { otherwise a recursive call to link method }
  504. end;
  505. Function TLinkerBSD.MakeSharedLibrary:boolean;
  506. var
  507. InitStr,
  508. FiniStr,
  509. SoNameStr : string[80];
  510. binstr : String;
  511. cmdstr : TCmdStr;
  512. success : boolean;
  513. begin
  514. MakeSharedLibrary:=false;
  515. if not(cs_link_nolink in aktglobalswitches) then
  516. Message1(exec_i_linking,current_module.sharedlibfilename^);
  517. { Write used files and libraries }
  518. WriteResponseFile(true);
  519. InitStr:='-init FPC_LIB_START';
  520. FiniStr:='-fini FPC_LIB_EXIT';
  521. SoNameStr:='-soname '+SplitFileName(current_module.sharedlibfilename^);
  522. { Call linker }
  523. SplitBinCmd(Info.DllCmd[1],binstr,cmdstr);
  524. {$ifndef darwin}
  525. Replace(cmdstr,'$EXE',maybequoted(current_module.sharedlibfilename^));
  526. {$else darwin}
  527. {$ifdef USE_SYSUTILS}
  528. Replace(cmdstr,'$EXE',maybequoted(ExpandFileName(current_module.sharedlibfilename^)));
  529. {$else USE_SYSUTILS}
  530. Replace(cmdstr,'$EXE',maybequoted(FExpand(current_module.sharedlibfilename^)));
  531. {$endif USE_SYSUTILS}
  532. {$endif darwin}
  533. Replace(cmdstr,'$OPT',Info.ExtraOptions);
  534. Replace(cmdstr,'$RES',maybequoted(outputexedir+Info.ResName));
  535. Replace(cmdstr,'$INIT',InitStr);
  536. Replace(cmdstr,'$FINI',FiniStr);
  537. Replace(cmdstr,'$SONAME',SoNameStr);
  538. success:=DoExec(FindUtil(utilsprefix+binstr),cmdstr,true,LdSupportsNoResponseFile);
  539. { Strip the library ? }
  540. if success and (cs_link_strip in aktglobalswitches) then
  541. begin
  542. SplitBinCmd(Info.DllCmd[2],binstr,cmdstr);
  543. Replace(cmdstr,'$EXE',maybequoted(current_module.sharedlibfilename^));
  544. success:=DoExec(FindUtil(utilsprefix+binstr),cmdstr,true,false);
  545. end;
  546. { Remove ReponseFile }
  547. if (success) and not(cs_link_nolink in aktglobalswitches) then
  548. RemoveFile(outputexedir+Info.ResName);
  549. MakeSharedLibrary:=success; { otherwise a recursive call to link method }
  550. end;
  551. {*****************************************************************************
  552. Initialize
  553. *****************************************************************************}
  554. initialization
  555. {$ifdef x86_64}
  556. RegisterExternalLinker(system_x86_64_FreeBSD_info,TLinkerBSD);
  557. RegisterImport(system_x86_64_freebsd,timportlibbsd);
  558. RegisterExport(system_x86_64_freebsd,texportlibbsd);
  559. RegisterTarget(system_x86_64_freebsd_info);
  560. {$endif}
  561. {$ifdef i386}
  562. RegisterExternalLinker(system_i386_FreeBSD_info,TLinkerBSD);
  563. RegisterExternalLinker(system_i386_NetBSD_info,TLinkerBSD);
  564. RegisterExternalLinker(system_i386_OpenBSD_info,TLinkerBSD);
  565. RegisterImport(system_i386_freebsd,timportlibbsd);
  566. RegisterExport(system_i386_freebsd,texportlibbsd);
  567. RegisterTarget(system_i386_freebsd_info);
  568. RegisterImport(system_i386_netbsd,timportlibbsd);
  569. RegisterExport(system_i386_netbsd,texportlibbsd);
  570. RegisterTarget(system_i386_netbsd_info);
  571. RegisterImport(system_i386_openbsd,timportlibbsd);
  572. RegisterExport(system_i386_openbsd,texportlibbsd);
  573. RegisterTarget(system_i386_openbsd_info);
  574. RegisterExternalLinker(system_i386_darwin_info,TLinkerBSD);
  575. RegisterImport(system_i386_darwin,timportlibdarwin);
  576. RegisterExport(system_i386_darwin,texportlibbsd);
  577. RegisterTarget(system_i386_darwin_info);
  578. {$endif i386}
  579. {$ifdef m68k}
  580. // RegisterExternalLinker(system_m68k_FreeBSD_info,TLinkerBSD);
  581. RegisterExternalLinker(system_m68k_NetBSD_info,TLinkerBSD);
  582. RegisterImport(system_m68k_netbsd,timportlibbsd);
  583. RegisterExport(system_m68k_netbsd,texportlibbsd);
  584. RegisterTarget(system_m68k_netbsd_info);
  585. {$endif m68k}
  586. {$ifdef powerpc}
  587. // RegisterExternalLinker(system_m68k_FreeBSD_info,TLinkerBSD);
  588. RegisterExternalLinker(system_powerpc_darwin_info,TLinkerBSD);
  589. RegisterImport(system_powerpc_darwin,timportlibdarwin);
  590. RegisterExport(system_powerpc_darwin,texportlibbsd);
  591. RegisterTarget(system_powerpc_darwin_info);
  592. RegisterExternalLinker(system_powerpc_netbsd_info,TLinkerBSD);
  593. RegisterImport(system_powerpc_netbsd,timportlibbsd);
  594. RegisterExport(system_powerpc_netbsd,texportlibbsd);
  595. RegisterTarget(system_powerpc_netbsd_info);
  596. {$endif powerpc}
  597. end.