t_bsd.pas 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668
  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,aasmcpu,cpubase,symsym,symdef,
  33. import,export,link,i_bsd,
  34. cgutils,cgbase,cgobj,cpuinfo;
  35. type
  36. tdarwinimported_item = class(timported_item)
  37. procdef : tprocdef;
  38. end;
  39. timportlibdarwin=class(timportlib)
  40. procedure preparelib(const s:string);override;
  41. procedure importprocedure(aprocdef:tprocdef;const module:string;index:longint;const name:string);override;
  42. procedure importvariable(vs:tglobalvarsym;const name,module:string);override;
  43. procedure generatelib;override;
  44. procedure generatesmartlib;override;
  45. end;
  46. timportlibbsd=class(timportlib)
  47. procedure preparelib(const s:string);override;
  48. procedure importprocedure(aprocdef:tprocdef;const module:string;index:longint;const name:string);override;
  49. procedure importvariable(vs:tglobalvarsym;const name,module:string);override;
  50. procedure generatelib;override;
  51. end;
  52. texportlibbsd=class(texportlib)
  53. procedure preparelib(const s : string);override;
  54. procedure exportprocedure(hp : texported_item);override;
  55. procedure exportvar(hp : texported_item);override;
  56. procedure generatelib;override;
  57. end;
  58. tlinkerbsd=class(texternallinker)
  59. private
  60. LdSupportsNoResponseFile : boolean;
  61. LibrarySuffix : Char;
  62. Function WriteResponseFile(isdll:boolean) : Boolean;
  63. public
  64. constructor Create;override;
  65. procedure SetDefaultInfo;override;
  66. function MakeExecutable:boolean;override;
  67. function MakeSharedLibrary:boolean;override;
  68. end;
  69. {*****************************************************************************
  70. TIMPORTLIBDARWIN
  71. *****************************************************************************}
  72. procedure timportlibdarwin.preparelib(const s : string);
  73. begin
  74. if asmlist[al_imports]=nil then
  75. asmlist[al_imports]:=TAAsmoutput.create;
  76. end;
  77. procedure timportlibdarwin.importprocedure(aprocdef:tprocdef;const module : string;index : longint;const name : string);
  78. begin
  79. { insert sharedlibrary }
  80. { current_module.linkothersharedlibs.add(SplitName(module),link_allways); }
  81. end;
  82. procedure timportlibdarwin.importvariable(vs:tglobalvarsym;const name,module:string);
  83. begin
  84. { insert sharedlibrary }
  85. { current_module.linkothersharedlibs.add(SplitName(module),link_allways); }
  86. { the rest is handled in the nppcld.pas tppcloadnode }
  87. vs.set_mangledname(name);
  88. end;
  89. procedure timportlibdarwin.generatesmartlib;
  90. begin
  91. generatelib;
  92. end;
  93. procedure timportlibdarwin.generatelib;
  94. begin
  95. end;
  96. {*****************************************************************************
  97. TIMPORTLIBBSD
  98. *****************************************************************************}
  99. procedure timportlibbsd.preparelib(const s : string);
  100. begin
  101. end;
  102. procedure timportlibbsd.importprocedure(aprocdef:tprocdef;const module:string;index:longint;const name:string);
  103. begin
  104. { insert sharedlibrary }
  105. current_module.linkothersharedlibs.add(SplitName(module),link_allways);
  106. end;
  107. procedure timportlibbsd.importvariable(vs:tglobalvarsym;const name,module:string);
  108. begin
  109. { insert sharedlibrary }
  110. current_module.linkothersharedlibs.add(SplitName(module),link_allways);
  111. { reset the mangledname and turn off the dll_var option }
  112. vs.set_mangledname(name);
  113. exclude(vs.varoptions,vo_is_dll_var);
  114. end;
  115. procedure timportlibbsd.generatelib;
  116. begin
  117. end;
  118. {*****************************************************************************
  119. TEXPORTLIBBSD
  120. *****************************************************************************}
  121. procedure texportlibbsd.preparelib(const s:string);
  122. begin
  123. end;
  124. procedure texportlibbsd.exportprocedure(hp : texported_item);
  125. var
  126. hp2 : texported_item;
  127. begin
  128. { first test the index value }
  129. if (hp.options and eo_index)<>0 then
  130. begin
  131. Message1(parser_e_no_export_with_index_for_target,'*bsd/darwin');
  132. exit;
  133. end;
  134. { now place in correct order }
  135. hp2:=texported_item(current_module._exports.first);
  136. while assigned(hp2) and
  137. (hp.name^>hp2.name^) do
  138. hp2:=texported_item(hp2.next);
  139. { insert hp there !! }
  140. if assigned(hp2) and (hp2.name^=hp.name^) then
  141. begin
  142. { this is not allowed !! }
  143. Message1(parser_e_export_name_double,hp.name^);
  144. exit;
  145. end;
  146. if hp2=texported_item(current_module._exports.first) then
  147. current_module._exports.concat(hp)
  148. else if assigned(hp2) then
  149. begin
  150. hp.next:=hp2;
  151. hp.previous:=hp2.previous;
  152. if assigned(hp2.previous) then
  153. hp2.previous.next:=hp;
  154. hp2.previous:=hp;
  155. end
  156. else
  157. current_module._exports.concat(hp);
  158. end;
  159. procedure texportlibbsd.exportvar(hp : texported_item);
  160. begin
  161. hp.is_var:=true;
  162. exportprocedure(hp);
  163. end;
  164. procedure texportlibbsd.generatelib;
  165. var
  166. hp2 : texported_item;
  167. begin
  168. hp2:=texported_item(current_module._exports.first);
  169. while assigned(hp2) do
  170. begin
  171. if (not hp2.is_var) and
  172. (hp2.sym.typ=procsym) then
  173. begin
  174. { the manglednames can already be the same when the procedure
  175. is declared with cdecl }
  176. if tprocsym(hp2.sym).first_procdef.mangledname<>hp2.name^ then
  177. begin
  178. {$ifdef i386}
  179. { place jump in al_procedures }
  180. asmlist[al_procedures].concat(Tai_align.Create_op(4,$90));
  181. asmlist[al_procedures].concat(Tai_symbol.Createname_global(hp2.name^,AT_FUNCTION,0));
  182. asmlist[al_procedures].concat(Taicpu.Op_sym(A_JMP,S_NO,objectlibrary.newasmsymbol(tprocsym(hp2.sym).first_procdef.mangledname,AB_EXTERNAL,AT_FUNCTION)));
  183. asmlist[al_procedures].concat(Tai_symbol_end.Createname(hp2.name^));
  184. {$endif i386}
  185. {$ifdef powerpc}
  186. asmlist[al_procedures].concat(Tai_align.create(16));
  187. asmlist[al_procedures].concat(Tai_symbol.Createname_global(hp2.name^,AT_FUNCTION,0));
  188. asmlist[al_procedures].concat(Taicpu.Op_sym(A_B,objectlibrary.newasmsymbol(tprocsym(hp2.sym).first_procdef.mangledname,AB_EXTERNAL,AT_FUNCTION)));
  189. asmlist[al_procedures].concat(Tai_symbol_end.Createname(hp2.name^));
  190. {$endif powerpc}
  191. end;
  192. end
  193. else
  194. Message1(parser_e_no_export_of_variables_for_target,'*bsd/darwin');
  195. hp2:=texported_item(hp2.next);
  196. end;
  197. end;
  198. {*****************************************************************************
  199. TLINKERLINUX
  200. *****************************************************************************}
  201. Constructor TLinkerBSD.Create;
  202. begin
  203. Inherited Create;
  204. if not Dontlinkstdlibpath Then
  205. if (target_info.system <> system_powerpc_darwin) then
  206. LibrarySearchPath.AddPath('/lib;/usr/lib;/usr/X11R6/lib',true)
  207. else
  208. { Mac OS X doesn't have a /lib }
  209. LibrarySearchPath.AddPath('/usr/lib',true)
  210. end;
  211. procedure TLinkerBSD.SetDefaultInfo;
  212. {
  213. This will also detect which libc version will be used
  214. }
  215. begin
  216. LibrarySuffix:=' ';
  217. LdSupportsNoResponseFile := (target_info.system in [system_m68k_netbsd,system_powerpc_darwin]);
  218. with Info do
  219. begin
  220. if LdSupportsNoResponseFile then
  221. begin
  222. if (target_info.system <> system_powerpc_darwin) then
  223. begin
  224. ExeCmd[1]:='ld $OPT $DYNLINK $STATIC $GCSECTIONS $STRIP -L. -o $EXE `cat $RES`';
  225. DllCmd[1]:='ld $OPT -shared -L. -o $EXE `cat $RES`'
  226. end
  227. else
  228. begin
  229. ExeCmd[1]:='ld $OPT $DYNLINK $STATIC $GCSECTIONS $STRIP -multiply_defined suppress -L. -o $EXE `cat $RES`';
  230. DllCmd[1]:='libtool $OPT -dynamic -init PASCALMAIN -multiply_defined suppress -L. -o $EXE `cat $RES`'
  231. end
  232. end
  233. else
  234. begin
  235. ExeCmd[1]:='ld $OPT $DYNLINK $STATIC $GCSECTIONS $STRIP -L. -o $EXE $RES';
  236. DllCmd[1]:='ld $OPT $INIT $FINI $SONAME -shared -L. -o $EXE $RES';
  237. end;
  238. if (target_info.system <> system_powerpc_darwin) then
  239. DllCmd[2]:='strip --strip-unneeded $EXE'
  240. else
  241. DllCmd[2]:='strip -x $EXE';
  242. { first try glibc2 }
  243. {$ifdef GLIBC2} {Keep linux code in place. FBSD might go to a different
  244. glibc too once}
  245. DynamicLinker:='/lib/ld-linux.so.2';
  246. if FileExists(DynamicLinker) then
  247. begin
  248. Glibc2:=true;
  249. { Check for 2.0 files, else use the glibc 2.1 stub }
  250. if FileExists('/lib/ld-2.0.*') then
  251. Glibc21:=false
  252. else
  253. Glibc21:=true;
  254. end
  255. else
  256. DynamicLinker:='/lib/ld-linux.so.1';
  257. {$else}
  258. DynamicLinker:='';
  259. {$endif}
  260. end;
  261. end;
  262. Function TLinkerBSD.WriteResponseFile(isdll:boolean) : Boolean;
  263. Var
  264. linkres : TLinkRes;
  265. i : longint;
  266. cprtobj,
  267. gprtobj,
  268. prtobj : string[80];
  269. HPath : TStringListItem;
  270. s,s1,s2 : string;
  271. linkpthread,
  272. linkdynamic,
  273. linklibc : boolean;
  274. Fl1,Fl2 : Boolean;
  275. begin
  276. WriteResponseFile:=False;
  277. { set special options for some targets }
  278. if target_info.system <> system_powerpc_darwin then
  279. begin
  280. linkdynamic:=not(SharedLibFiles.empty);
  281. linklibc:=(SharedLibFiles.Find('c')<>nil);
  282. linkpthread:=(SharedLibFiles.Find('pthread')<>nil);
  283. if (target_info.system =system_i386_freebsd) and linkpthread Then
  284. Begin
  285. if not (cs_link_pthread in aktglobalswitches) Then
  286. begin
  287. {delete pthreads from list, in this case it is in libc_r}
  288. SharedLibFiles.Remove(SharedLibFiles.Find('pthread').str);
  289. LibrarySuffix:='r';
  290. end;
  291. End;
  292. prtobj:='prt0';
  293. cprtobj:='cprt0';
  294. gprtobj:='gprt0';
  295. if cs_profile in aktmoduleswitches then
  296. begin
  297. prtobj:=gprtobj;
  298. AddSharedLibrary('c');
  299. LibrarySuffix:='p';
  300. linklibc:=true;
  301. end
  302. else
  303. begin
  304. if linklibc then
  305. prtobj:=cprtobj;
  306. end;
  307. end
  308. else
  309. begin
  310. { for darwin: always link dynamically against libc }
  311. linklibc := true;
  312. if not(isdll) then
  313. if not(cs_profile in aktmoduleswitches) then
  314. prtobj:='/usr/lib/crt1.o'
  315. else
  316. prtobj:='/usr/lib/gcrt1.o'
  317. else
  318. prtobj:='';
  319. end;
  320. { Open link.res file }
  321. LinkRes:=TLinkRes.Create(outputexedir+Info.ResName);
  322. { Write path to search libraries }
  323. HPath:=TStringListItem(current_module.locallibrarysearchpath.First);
  324. while assigned(HPath) do
  325. begin
  326. if LdSupportsNoResponseFile then
  327. LinkRes.Add(maybequoted('-L'+HPath.Str))
  328. else
  329. LinkRes.Add('SEARCH_DIR('+maybequoted(HPath.Str)+')');
  330. HPath:=TStringListItem(HPath.Next);
  331. end;
  332. HPath:=TStringListItem(LibrarySearchPath.First);
  333. while assigned(HPath) do
  334. begin
  335. if LdSupportsNoResponseFile then
  336. LinkRes.Add(maybequoted('-L'+HPath.Str))
  337. else
  338. LinkRes.Add('SEARCH_DIR('+maybequoted(HPath.Str)+')');
  339. HPath:=TStringListItem(HPath.Next);
  340. end;
  341. if not LdSupportsNoResponseFile then
  342. LinkRes.Add('INPUT(');
  343. { add objectfiles, start with prt0 always }
  344. if prtobj<>'' then
  345. LinkRes.AddFileName(FindObjectFile(prtobj,'',false));
  346. { try to add crti and crtbegin if linking to C }
  347. if linklibc and
  348. (target_info.system <> system_powerpc_darwin) then
  349. begin
  350. if librarysearchpath.FindFile('crtbegin.o',s) then
  351. LinkRes.AddFileName(s);
  352. if librarysearchpath.FindFile('crti.o',s) then
  353. LinkRes.AddFileName(s);
  354. end;
  355. { main objectfiles }
  356. while not ObjectFiles.Empty do
  357. begin
  358. s:=ObjectFiles.GetFirst;
  359. if s<>'' then
  360. LinkRes.AddFileName(maybequoted(s));
  361. end;
  362. if not LdSupportsNoResponseFile then
  363. LinkRes.Add(')');
  364. { Write staticlibraries }
  365. if not StaticLibFiles.Empty then
  366. begin
  367. if not LdSupportsNoResponseFile then
  368. LinkRes.Add('GROUP(');
  369. While not StaticLibFiles.Empty do
  370. begin
  371. S:=StaticLibFiles.GetFirst;
  372. LinkRes.AddFileName(maybequoted(s))
  373. end;
  374. if not LdSupportsNoResponseFile then
  375. LinkRes.Add(')');
  376. end;
  377. { Write sharedlibraries like -l<lib>, also add the needed dynamic linker
  378. here to be sure that it gets linked this is needed for glibc2 systems (PFV) }
  379. if not SharedLibFiles.Empty then
  380. begin
  381. if not LdSupportsNoResponseFile then
  382. LinkRes.Add('INPUT(');
  383. While not SharedLibFiles.Empty do
  384. begin
  385. S:=SharedLibFiles.GetFirst;
  386. if s<>'c' then
  387. begin
  388. i:=Pos(target_info.sharedlibext,S);
  389. if i>0 then
  390. Delete(S,i,255);
  391. LinkRes.Add('-l'+s);
  392. end
  393. else
  394. begin
  395. linklibc:=true;
  396. linkdynamic:=false; { libc will include the ld-linux for us }
  397. end;
  398. end;
  399. { be sure that libc is the last lib }
  400. if linklibc then
  401. Begin
  402. If LibrarySuffix=' ' Then
  403. LinkRes.Add('-lc')
  404. else
  405. LinkRes.Add('-lc_'+LibrarySuffix);
  406. If LibrarySuffix='r' Then
  407. LinkRes.Add('-lc');
  408. end;
  409. { when we have -static for the linker the we also need libgcc }
  410. if (cs_link_staticflag in aktglobalswitches) then
  411. LinkRes.Add('-lgcc');
  412. if linkdynamic and (Info.DynamicLinker<>'') then
  413. LinkRes.AddFileName(Info.DynamicLinker);
  414. if not LdSupportsNoResponseFile then
  415. LinkRes.Add(')');
  416. end;
  417. { objects which must be at the end }
  418. if linklibc and
  419. (target_info.system <> system_powerpc_darwin) then
  420. begin
  421. Fl1:=librarysearchpath.FindFile('crtend.o',s1);
  422. Fl2:=librarysearchpath.FindFile('crtn.o',s2);
  423. if Fl1 or Fl2 then
  424. begin
  425. LinkRes.Add('INPUT(');
  426. If Fl1 Then
  427. LinkRes.AddFileName(s1);
  428. If Fl2 Then
  429. LinkRes.AddFileName(s2);
  430. LinkRes.Add(')');
  431. end;
  432. end;
  433. { ignore the fact that our relocations are in non-writable sections, }
  434. { will be fixed once we have pic support }
  435. if isdll and
  436. (target_info.system = system_powerpc_darwin) 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_extern 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. if (target_info.system <> system_powerpc_darwin) then
  471. StripStr:='-s'
  472. else
  473. StripStr:='-x';
  474. if (cs_link_smart in aktglobalswitches) and
  475. (tf_smartlink_sections in target_info.flags) then
  476. GCSectionsStr:='--gc-sections';
  477. If (cs_profile in aktmoduleswitches) or
  478. ((Info.DynamicLinker<>'') and (not SharedLibFiles.Empty)) then
  479. DynLinkStr:='-dynamic-linker='+Info.DynamicLinker;
  480. if CShared Then
  481. DynLinKStr:=DynLinkStr+' --shared';
  482. { Write used files and libraries }
  483. WriteResponseFile(false);
  484. { Call linker }
  485. SplitBinCmd(Info.ExeCmd[1],binstr,cmdstr);
  486. Replace(cmdstr,'$EXE',maybequoted(current_module.exefilename^));
  487. Replace(cmdstr,'$OPT',Info.ExtraOptions);
  488. Replace(cmdstr,'$RES',maybequoted(outputexedir+Info.ResName));
  489. Replace(cmdstr,'$STATIC',StaticStr);
  490. Replace(cmdstr,'$STRIP',StripStr);
  491. Replace(cmdstr,'$GCSECTIONS',GCSectionsStr);
  492. Replace(cmdstr,'$DYNLINK',DynLinkStr);
  493. success:=DoExec(FindUtil(utilsprefix+BinStr),CmdStr,true,LdSupportsNoResponseFile);
  494. { Remove ReponseFile }
  495. if (success) and not(cs_link_extern in aktglobalswitches) then
  496. RemoveFile(outputexedir+Info.ResName);
  497. MakeExecutable:=success; { otherwise a recursive call to link method }
  498. end;
  499. Function TLinkerBSD.MakeSharedLibrary:boolean;
  500. var
  501. InitStr,
  502. FiniStr,
  503. SoNameStr : string[80];
  504. binstr : String;
  505. cmdstr : TCmdStr;
  506. success : boolean;
  507. begin
  508. MakeSharedLibrary:=false;
  509. if not(cs_link_extern in aktglobalswitches) then
  510. Message1(exec_i_linking,current_module.sharedlibfilename^);
  511. { Write used files and libraries }
  512. WriteResponseFile(true);
  513. InitStr:='-init FPC_LIB_START';
  514. FiniStr:='-fini FPC_LIB_EXIT';
  515. SoNameStr:='-soname '+SplitFileName(current_module.sharedlibfilename^);
  516. { Call linker }
  517. SplitBinCmd(Info.DllCmd[1],binstr,cmdstr);
  518. {$ifndef darwin}
  519. Replace(cmdstr,'$EXE',maybequoted(current_module.sharedlibfilename^));
  520. {$else darwin}
  521. {$ifdef USE_SYSUTILS}
  522. Replace(cmdstr,'$EXE',maybequoted(ExpandFileName(current_module.sharedlibfilename^)));
  523. {$else USE_SYSUTILS}
  524. Replace(cmdstr,'$EXE',maybequoted(FExpand(current_module.sharedlibfilename^)));
  525. {$endif USE_SYSUTILS}
  526. {$endif darwin}
  527. Replace(cmdstr,'$OPT',Info.ExtraOptions);
  528. Replace(cmdstr,'$RES',maybequoted(outputexedir+Info.ResName));
  529. Replace(cmdstr,'$INIT',InitStr);
  530. Replace(cmdstr,'$FINI',FiniStr);
  531. Replace(cmdstr,'$SONAME',SoNameStr);
  532. success:=DoExec(FindUtil(utilsprefix+binstr),cmdstr,true,LdSupportsNoResponseFile);
  533. { Strip the library ? }
  534. if success and (cs_link_strip in aktglobalswitches) then
  535. begin
  536. SplitBinCmd(Info.DllCmd[2],binstr,cmdstr);
  537. Replace(cmdstr,'$EXE',maybequoted(current_module.sharedlibfilename^));
  538. success:=DoExec(FindUtil(utilsprefix+binstr),cmdstr,true,false);
  539. end;
  540. { Remove ReponseFile }
  541. if (success) and not(cs_link_extern in aktglobalswitches) then
  542. RemoveFile(outputexedir+Info.ResName);
  543. MakeSharedLibrary:=success; { otherwise a recursive call to link method }
  544. end;
  545. {*****************************************************************************
  546. Initialize
  547. *****************************************************************************}
  548. initialization
  549. {$ifdef x86_64}
  550. RegisterExternalLinker(system_x86_64_FreeBSD_info,TLinkerBSD);
  551. RegisterImport(system_x86_64_freebsd,timportlibbsd);
  552. RegisterExport(system_x86_64_freebsd,texportlibbsd);
  553. RegisterTarget(system_x86_64_freebsd_info);
  554. {$endif}
  555. {$ifdef i386}
  556. RegisterExternalLinker(system_i386_FreeBSD_info,TLinkerBSD);
  557. RegisterExternalLinker(system_i386_NetBSD_info,TLinkerBSD);
  558. RegisterExternalLinker(system_i386_OpenBSD_info,TLinkerBSD);
  559. RegisterImport(system_i386_freebsd,timportlibbsd);
  560. RegisterExport(system_i386_freebsd,texportlibbsd);
  561. RegisterTarget(system_i386_freebsd_info);
  562. RegisterImport(system_i386_netbsd,timportlibbsd);
  563. RegisterExport(system_i386_netbsd,texportlibbsd);
  564. RegisterTarget(system_i386_netbsd_info);
  565. RegisterImport(system_i386_openbsd,timportlibbsd);
  566. RegisterExport(system_i386_openbsd,texportlibbsd);
  567. RegisterTarget(system_i386_openbsd_info);
  568. {$endif i386}
  569. {$ifdef m68k}
  570. // RegisterExternalLinker(system_m68k_FreeBSD_info,TLinkerBSD);
  571. RegisterExternalLinker(system_m68k_NetBSD_info,TLinkerBSD);
  572. RegisterImport(system_m68k_netbsd,timportlibbsd);
  573. RegisterExport(system_m68k_netbsd,texportlibbsd);
  574. RegisterTarget(system_m68k_netbsd_info);
  575. {$endif m68k}
  576. {$ifdef powerpc}
  577. // RegisterExternalLinker(system_m68k_FreeBSD_info,TLinkerBSD);
  578. RegisterExternalLinker(system_powerpc_darwin_info,TLinkerBSD);
  579. RegisterImport(system_powerpc_darwin,timportlibdarwin);
  580. RegisterExport(system_powerpc_darwin,texportlibbsd);
  581. RegisterTarget(system_powerpc_darwin_info);
  582. RegisterExternalLinker(system_powerpc_netbsd_info,TLinkerBSD);
  583. RegisterImport(system_powerpc_netbsd,timportlibbsd);
  584. RegisterExport(system_powerpc_netbsd,texportlibbsd);
  585. RegisterTarget(system_powerpc_netbsd_info);
  586. {$endif powerpc}
  587. end.