t_bsd.pas 21 KB

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