t_nwl.pas 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679
  1. {
  2. $Id$
  3. Copyright (c) 1998-2004 by Peter Vreman
  4. This unit implements support import,export,link routines
  5. for the (i386) Netware libc 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. Currently generating NetWare-NLM's only work under Linux and win32.
  18. (see http://home.arcor.de/armin.diehl/fpcnw for binutils working
  19. with win32) while not included in fpc-releases.
  20. The following compiler-swiches are supported for NetWare:
  21. $DESCRIPTION : NLM-Description, will be displayed at load-time
  22. $M : For Stack-Size, Heap-Size will be ignored
  23. 32K is the accepted minimum
  24. $VERSION x.x.x : Sets Major, Minor and Revision
  25. $SCREENNAME : Sets the ScreenName
  26. $THREADNAME : Sets current threadname
  27. Additional parameters for the nlmvonv-inputfile can be passed with
  28. -k, i.e. -kREENTRANT will add the option REENTRANT to the nlmconv
  29. inputfile. A ; will be converted into a newline
  30. Exports will be handled like in win32:
  31. procedure bla; cdecl;
  32. begin
  33. end;
  34. exports foo name 'Bar';
  35. The path to the import-Files must be specified by the library-path.
  36. All external modules are defined as autoload. (Note: the import-files have
  37. to be in unix-format for exe2nlm)
  38. By default, the most import files are included in freepascal.
  39. e.g. function getgrnam(name:Pchar):Pgroup;cdecl;external 'libc' 'getgrnam';
  40. sets IMPORT @libc.imp and MODULE libc.
  41. To avoid setting the autoload, use ! in the name, e.g.
  42. procedure EnterDebugger;cdecl;external '!netware' name 'EnterDebugger';
  43. Function simply defined as external work without generating autoload and
  44. IMPORT but you will get a warning from nlmconv.
  45. If you dont have nlmconv, compile gnu-binutils with
  46. ./configure --enable-targets=i386-netware
  47. make all
  48. Debugging is possible with gdb and a converter from gdb to ndi available
  49. at http://home.arcor.de/armin.diehl/gdbnw
  50. A sample program:
  51. Program Hello;
  52. (*$DESCRIPTION HelloWorldNlm*)
  53. (*$VERSION 1.2.3*)
  54. (*$ScreenName Hello*)
  55. (*$M 60000,60000*)
  56. begin
  57. writeLn ('hello world');
  58. end.
  59. compile with:
  60. ppc386 -Tnetwlibc hello
  61. Libraries are supported but this needs at least netware 5.1 sp6,
  62. 6.0 sp3 or netware 6.5
  63. In case there is a xdc file with the same name as the nlm name,
  64. this file will be used for nlmconv. Otherwise a temp xdc will
  65. be created and used.
  66. ****************************************************************************
  67. }
  68. unit t_nwl;
  69. {$i fpcdefs.inc}
  70. interface
  71. implementation
  72. {$ifdef netwlibc}
  73. {$define netware}
  74. {$endif}
  75. uses
  76. cutils,
  77. verbose,systems,globtype,globals,
  78. symconst,script,
  79. fmodule,aasmbase,aasmtai,aasmcpu,cpubase,symsym,symdef,
  80. import,export,link,i_nwl
  81. {$ifdef netware} ,dos {$endif}
  82. ;
  83. type
  84. timportlibnetwlibc=class(timportlib)
  85. procedure preparelib(const s:string);override;
  86. procedure importprocedure(aprocdef:tprocdef;const module:string;index:longint;const name:string);override;
  87. procedure importvariable(vs:tvarsym;const name,module:string);override;
  88. procedure generatelib;override;
  89. end;
  90. texportlibnetwlibc=class(texportlib)
  91. procedure preparelib(const s : string);override;
  92. procedure exportprocedure(hp : texported_item);override;
  93. procedure exportvar(hp : texported_item);override;
  94. procedure generatelib;override;
  95. end;
  96. tlinkernetwlibc=class(texternallinker)
  97. private
  98. NLMConvLinkFile: TLinkRes; {for second pass, fist pass is ld}
  99. Function WriteResponseFile(isdll:boolean) : Boolean;
  100. public
  101. constructor Create;override;
  102. procedure SetDefaultInfo;override;
  103. function MakeNetwareLoadableModule (isLib : boolean):boolean;
  104. function MakeExecutable:boolean;override;
  105. function MakeSharedLibrary:boolean;override;
  106. end;
  107. Const tmpLinkFileName = '~link~tmp.o';
  108. minStackSize = 32768;
  109. {*****************************************************************************
  110. TIMPORTLIBNETWARE
  111. *****************************************************************************}
  112. procedure timportlibnetwlibc.preparelib(const s : string);
  113. begin
  114. end;
  115. procedure timportlibnetwlibc.importprocedure(aprocdef:tprocdef;const module:string;index:longint;const name:string);
  116. begin
  117. { insert sharedlibrary }
  118. current_module.linkothersharedlibs.add(SplitName(module),link_allways);
  119. { do nothing with the procedure, only set the mangledname }
  120. if name<>'' then
  121. begin
  122. aprocdef.setmangledname(name);
  123. end
  124. else
  125. message(parser_e_empty_import_name);
  126. end;
  127. procedure timportlibnetwlibc.importvariable(vs:tvarsym;const name,module:string);
  128. begin
  129. { insert sharedlibrary }
  130. current_module.linkothersharedlibs.add(SplitName(module),link_allways);
  131. { reset the mangledname and turn off the dll_var option }
  132. vs.set_mangledname(name);
  133. exclude(vs.varoptions,vo_is_dll_var);
  134. end;
  135. procedure timportlibnetwlibc.generatelib;
  136. begin
  137. end;
  138. {*****************************************************************************
  139. TEXPORTLIBNETWARE
  140. *****************************************************************************}
  141. procedure texportlibnetwlibc.preparelib(const s:string);
  142. begin
  143. end;
  144. procedure texportlibnetwlibc.exportprocedure(hp : texported_item);
  145. var
  146. hp2 : texported_item;
  147. begin
  148. { first test the index value }
  149. if (hp.options and eo_index)<>0 then
  150. begin
  151. Comment(V_Error,'can''t export with index under netware');
  152. exit;
  153. end;
  154. { use pascal name is none specified }
  155. if (hp.options and eo_name)=0 then
  156. begin
  157. hp.name:=stringdup(hp.sym.name);
  158. hp.options:=hp.options or eo_name;
  159. end;
  160. { now place in correct order }
  161. hp2:=texported_item(current_module._exports.first);
  162. while assigned(hp2) and
  163. (hp.name^>hp2.name^) do
  164. hp2:=texported_item(hp2.next);
  165. { insert hp there !! }
  166. if assigned(hp2) and (hp2.name^=hp.name^) then
  167. begin
  168. { this is not allowed !! }
  169. Message1(parser_e_export_name_double,hp.name^);
  170. exit;
  171. end;
  172. if hp2=texported_item(current_module._exports.first) then
  173. current_module._exports.insert(hp)
  174. else if assigned(hp2) then
  175. begin
  176. hp.next:=hp2;
  177. hp.previous:=hp2.previous;
  178. if assigned(hp2.previous) then
  179. hp2.previous.next:=hp;
  180. hp2.previous:=hp;
  181. end
  182. else
  183. current_module._exports.concat(hp);
  184. end;
  185. procedure texportlibnetwlibc.exportvar(hp : texported_item);
  186. begin
  187. hp.is_var:=true;
  188. exportprocedure(hp);
  189. end;
  190. procedure texportlibnetwlibc.generatelib;
  191. var
  192. hp2 : texported_item;
  193. begin
  194. hp2:=texported_item(current_module._exports.first);
  195. while assigned(hp2) do
  196. begin
  197. if (not hp2.is_var) and
  198. (hp2.sym.typ=procsym) then
  199. begin
  200. { the manglednames can already be the same when the procedure
  201. is declared with cdecl }
  202. if tprocsym(hp2.sym).first_procdef.mangledname<>hp2.name^ then
  203. begin
  204. {$ifdef i386}
  205. { place jump in codesegment }
  206. codesegment.concat(Tai_align.Create_op(4,$90));
  207. codeSegment.concat(Tai_symbol.Createname_global(hp2.name^,AT_FUNCTION,0));
  208. codeSegment.concat(Taicpu.Op_sym(A_JMP,S_NO,objectlibrary.newasmsymbol(tprocsym(hp2.sym).first_procdef.mangledname,AB_EXTERNAL,AT_FUNCTION)));
  209. codeSegment.concat(Tai_symbol_end.Createname(hp2.name^));
  210. {$endif i386}
  211. end;
  212. end
  213. else
  214. //Comment(V_Error,'Exporting of variables is not supported under netware');
  215. Message1(parser_e_no_export_of_variables_for_target,'netware');
  216. hp2:=texported_item(hp2.next);
  217. end;
  218. end;
  219. {*****************************************************************************
  220. TLINKERNETWARE
  221. *****************************************************************************}
  222. Constructor TLinkerNetwlibc.Create;
  223. begin
  224. Inherited Create;
  225. end;
  226. procedure TLinkerNetwlibc.SetDefaultInfo;
  227. begin
  228. with Info do
  229. begin
  230. {$ifndef netware}
  231. ExeCmd[1]:= 'ld -Ur -T $RES $STRIP -o $TMPOBJ';
  232. ExeCmd[2]:='nlmconv -T$RES';
  233. {$else}
  234. {for running on netware we need absolute pathes since ld has another working directory}
  235. ExeCmd[1]:= 'ld -Ur -T '+FExpand(outputexedir+Info.ResName)+' $STRIP -o '+Fexpand(outputexedir+tmpLinkFileName);
  236. ExeCmd[2]:='nlmconv -T'+FExpand(outputexedir+'n'+Info.ResName);
  237. {$endif}
  238. end;
  239. end;
  240. Function TLinkerNetwlibc.WriteResponseFile(isdll:boolean) : Boolean;
  241. Var
  242. linkres : TLinkRes;
  243. i : longint;
  244. s,s2,s3 : string;
  245. ProgNam : string [80];
  246. NlmNam : string [80];
  247. hp2 : texported_item; { for exports }
  248. p : byte;
  249. begin
  250. WriteResponseFile:=False;
  251. ProgNam := current_module.exefilename^;
  252. i:=Pos(target_info.exeext,ProgNam);
  253. if i>0 then
  254. Delete(ProgNam,i,255);
  255. NlmNam := ProgNam + target_info.exeext;
  256. { Open link.res file }
  257. LinkRes:=TLinkRes.Create(outputexedir+Info.ResName); {for ld}
  258. NLMConvLinkFile:=TLinkRes.Create(outputexedir+'n'+Info.ResName); {for nlmconv, written in CreateExeFile}
  259. p := Pos ('"', Description);
  260. while (p > 0) do
  261. begin
  262. delete (Description,p,1);
  263. p := Pos ('"', Description);
  264. end;
  265. if Description <> '' then
  266. NLMConvLinkFile.Add('DESCRIPTION "' + Description + '"');
  267. NLMConvLinkFile.Add('VERSION '+tostr(dllmajor)+','+tostr(dllminor)+','+tostr(dllrevision));
  268. p := Pos ('"', nwscreenname);
  269. while (p > 0) do
  270. begin
  271. delete (nwscreenname,p,1);
  272. p := Pos ('"', nwscreenname);
  273. end;
  274. p := Pos ('"', nwthreadname);
  275. while (p > 0) do
  276. begin
  277. delete (nwthreadname,p,1);
  278. p := Pos ('"', nwthreadname);
  279. end;
  280. p := Pos ('"', nwcopyright);
  281. while (p > 0) do
  282. begin
  283. delete (nwcopyright,p,1);
  284. p := Pos ('"', nwcopyright);
  285. end;
  286. if nwscreenname <> '' then
  287. NLMConvLinkFile.Add('SCREENNAME "' + nwscreenname + '"');
  288. if nwthreadname <> '' then
  289. NLMConvLinkFile.Add('THREADNAME "' + nwthreadname + '"');
  290. if nwcopyright <> '' then
  291. NLMConvLinkFile.Add('COPYRIGHT "' + nwcopyright + '"');
  292. if stacksize < minStackSize then stacksize := minStackSize;
  293. str (stacksize, s);
  294. NLMConvLinkFile.Add ('STACKSIZE '+s);
  295. {$ifndef netware}
  296. NLMConvLinkFile.Add ('INPUT '+outputexedir+tmpLinkFileName);
  297. {$else}
  298. NLMConvLinkFile.Add ('INPUT '+FExpand(outputexedir+tmpLinkFileName));
  299. {$endif}
  300. { add objectfiles, start with nwpre always }
  301. LinkRes.Add ('INPUT (');
  302. s2 := FindObjectFile('nwplibc','',false);
  303. if s2 = '' then
  304. s2 := FindObjectFile('libcpre.gcc','',false);
  305. Comment (V_Debug,'adding Object File '+s2);
  306. {$ifndef netware} LinkRes.Add (s2); {$else} LinkRes.Add (FExpand(s2)); {$endif}
  307. if isDll then {needed to provide main}
  308. s2 := FindObjectFile('nwl_dlle','',false)
  309. else
  310. s2 := FindObjectFile('nwl_main','',false);
  311. Comment (V_Debug,'adding Object File '+s2);
  312. {$ifndef netware} LinkRes.Add (s2); {$else} LinkRes.Add (FExpand(s2)); {$endif}
  313. { main objectfiles, add to linker input }
  314. while not ObjectFiles.Empty do
  315. begin
  316. s:=ObjectFiles.GetFirst;
  317. if s<>'' then
  318. begin
  319. s2 := FindObjectFile (s,'',false);
  320. Comment (V_Debug,'adding Object File '+s2);
  321. {$ifndef netware} LinkRes.Add (s2); {$else} LinkRes.Add (FExpand(s2)); {$endif}
  322. end;
  323. end;
  324. { output file (nlm), add to nlmconv }
  325. {$ifndef netware}
  326. NLMConvLinkFile.Add ('OUTPUT ' + NlmNam);
  327. {$else}
  328. NLMConvLinkFile.Add ('OUTPUT ' + FExpand(NlmNam));
  329. {$endif}
  330. { start and stop-procedures }
  331. NLMConvLinkFile.Add ('START _LibCPrelude');
  332. NLMConvLinkFile.Add ('EXIT _LibCPostlude');
  333. NLMConvLinkFile.Add ('CHECK _LibCCheckUnload');
  334. NLMConvLinkFile.Add ('REENTRANT'); { needed by older libc versions }
  335. if not (cs_link_strip in aktglobalswitches) then
  336. begin
  337. NLMConvLinkFile.Add ('DEBUG');
  338. Comment(V_Debug,'DEBUG');
  339. end;
  340. { Write staticlibraries, is that correct ? }
  341. if not StaticLibFiles.Empty then
  342. begin
  343. While not StaticLibFiles.Empty do
  344. begin
  345. S:=lower (StaticLibFiles.GetFirst);
  346. if s<>'' then
  347. begin
  348. {ad: that's a hack !
  349. whith -XX we get the .a files as static libs (in addition to the
  350. imported libraries}
  351. if (pos ('.a',s) <> 0) OR (pos ('.A', s) <> 0) then
  352. begin
  353. S2 := FindObjectFile(s,'',false);
  354. {$ifndef netware} LinkRes.Add (s2); {$else} LinkRes.Add (FExpand(s2)); {$endif}
  355. Comment(V_Debug,'adding Object File (StaticLibFiles) '+S2);
  356. end else
  357. begin
  358. i:=Pos(target_info.staticlibext,S);
  359. if i>0 then
  360. Delete(S,i,255);
  361. S := S + '.imp'; S2 := '';
  362. librarysearchpath.FindFile(S,S2);
  363. {$ifdef netware}
  364. Comment(V_Debug,'IMPORT @'+s2);
  365. s2 := FExpand (S2);
  366. {$endif}
  367. NLMConvLinkFile.Add('IMPORT @'+S2);
  368. Comment(V_Debug,'IMPORT @'+s2);
  369. end;
  370. end
  371. end;
  372. end;
  373. if not SharedLibFiles.Empty then
  374. begin
  375. While not SharedLibFiles.Empty do
  376. begin
  377. {becuase of upper/lower case mix, we may get duplicate
  378. names but nlmconv ignores that.
  379. Here we are setting the import-files for nlmconv. I.e. for
  380. the module libc or libc.nlm we add IMPORT @libc.imp and also
  381. the module libc.nlm (autoload)
  382. If a lib name begins with !, only the IMPORT will be generated
  383. ? may it be better to set autoload's via StaticLibFiles ? }
  384. S:=lower (SharedLibFiles.GetFirst);
  385. if s<>'' then
  386. begin
  387. s2:=s;
  388. i:=Pos(target_info.sharedlibext,S);
  389. if i>0 then
  390. Delete(S,i,255);
  391. if s[1] = '!' then
  392. begin // special, with ! only the imp will be included but no module is autoloaded, needed i.e. for netware.imp inlcuded in libc ndk
  393. delete (s,1,1);
  394. S := S + '.imp';
  395. librarysearchpath.FindFile(S,S3);
  396. {$ifdef netware}
  397. Comment(V_Debug,'IMPORT @'+S3);
  398. S3 := FExpand (S3);
  399. {$endif}
  400. NLMConvLinkFile.Add('IMPORT @'+S3);
  401. Comment(V_Debug,'IMPORT @'+S3);
  402. end else
  403. begin
  404. S := S + '.imp';
  405. librarysearchpath.FindFile(S,S3);
  406. {$ifdef netware}
  407. Comment(V_Debug,'IMPORT @'+S3);
  408. S3 := FExpand (S3);
  409. {$endif}
  410. NLMConvLinkFile.Add('IMPORT @'+S3);
  411. NLMConvLinkFile.Add('MODULE '+s2);
  412. Comment(V_Debug,'MODULE '+S2);
  413. Comment(V_Debug,'IMPORT @'+S3);
  414. end;
  415. end
  416. end;
  417. end;
  418. { write exports }
  419. hp2:=texported_item(current_module._exports.first);
  420. while assigned(hp2) do
  421. begin
  422. if not hp2.is_var then
  423. begin
  424. { Export the Symbol }
  425. Comment(V_Debug,'EXPORT '+hp2.name^);
  426. NLMConvLinkFile.Add ('EXPORT '+hp2.name^);
  427. end
  428. else
  429. { really, i think it is possible }
  430. {Comment(V_Error,'Exporting of variables is not supported under netware');}
  431. Message1(parser_e_no_export_of_variables_for_target,'netware');
  432. hp2:=texported_item(hp2.next);
  433. end;
  434. { Write and Close response for ld, response for nlmconv is in NLMConvLinkFile(not written) }
  435. linkres.Add (')');
  436. linkres.writetodisk;
  437. LinkRes.Free;
  438. { pass options from -k to nlmconv, ; is interpreted as newline }
  439. s := ParaLinkOptions;
  440. while(Length(s) > 0) and (s[1] = ' ') do
  441. delete (s,1,1);
  442. p := pos ('"',s);
  443. while p > 0 do
  444. begin
  445. delete (s,p,1);
  446. p := pos ('"',s);
  447. end;
  448. p := pos (';',s);
  449. while p > 0 do
  450. begin
  451. s2 := copy(s,1,p-1);
  452. comment (V_Debug,'adding "'+s2+'" to nlmvonv input');
  453. NLMConvLinkFile.Add(s2);
  454. delete (s,1,p);
  455. p := pos (';',s);
  456. end;
  457. if s <> '' then
  458. begin
  459. comment (V_Debug,'adding "'+s+'" to nlmvonv input');
  460. NLMConvLinkFile.Add(s);
  461. end;
  462. WriteResponseFile:=True;
  463. end;
  464. Const
  465. xdc : Array[0..127] of char = (
  466. 'B','A','G','F',#2,#0,#0,#0,#1,#0,#0,#0,#0,#0,#0,#0,#0,#0,#0,#0,#0,
  467. #0,#0,#0,#0,#0,#0,#0,#0,#0,#0,#0,#2,#0,#0,#0,#0,#0,#0,#0,#16,#0,#0,
  468. #0,#7,'M','P','K','_','B','a','g',#0,#0,#0,#0,#0,#0,#0,#0,#11,'M','T',
  469. ' ','S','a','f','e',' ','N','L','M',#0,#0,#0,#0,#0,#0,#0,#0,#0,#0,#0,
  470. #0,#0,#0,#0,#0,#0,#0,#0,#0,#0,#0,#0,#0,#0,#0,#0,#0,#0,#0,#0,#0,#0,#0,
  471. #0,#0,#0,#0,#0,#0,#1,#0,#0,#0,#0,#0,#0,#0,#0,#0,#0,#0,#0,#0,#0,#0);
  472. function TLinkerNetwlibc.MakeNetwareLoadableModule (isLib : boolean):boolean;
  473. var
  474. binstr,
  475. cmdstr,
  476. xdcname : string;
  477. success : boolean;
  478. StripStr : string[2];
  479. xdcpresent,usexdc : boolean;
  480. f : file;
  481. begin
  482. if not(cs_link_extern in aktglobalswitches) then
  483. Message1(exec_i_linking,current_module.exefilename^);
  484. { Create some replacements }
  485. StripStr:='';
  486. if (cs_link_strip in aktglobalswitches) then
  487. StripStr:='-s';
  488. { Write used files and libraries and create Headerfile for
  489. nlmconv in NLMConvLinkFile }
  490. WriteResponseFile(isLib);
  491. if isLib then
  492. NLMConvLinkFile.Add('FLAG_ON 1024'); {0x400 Specifies whether the NLM is a shared library.}
  493. { if we have a xdc file, dont touch it, otherwise create a new
  494. one and remove it after nlmconv }
  495. xdcname := ForceExtension(current_module.exefilename^,'.xdc');
  496. xdcpresent := FileExists (xdcname);
  497. if not xdcpresent then
  498. begin
  499. assign (f,xdcname);
  500. rewrite(f,1);
  501. if ioresult = 0 then
  502. begin
  503. blockwrite (f,xdc,sizeof(xdc));
  504. close(f);
  505. usexdc := (IOResult = 0);
  506. end else
  507. usexdc := false;
  508. end else
  509. usexdc := true;
  510. if usexdc then
  511. NLMConvLinkFile.Add('XDCDATA '+xdcname);
  512. { Call linker, this will generate a new object file that will be passed
  513. to nlmconv. Otherwise we could not create nlms without debug info }
  514. SplitBinCmd(Info.ExeCmd[1],binstr,cmdstr);
  515. Replace(cmdstr,'$EXE',current_module.exefilename^);
  516. Replace(cmdstr,'$RES',outputexedir+Info.ResName);
  517. Replace(cmdstr,'$STRIP',StripStr);
  518. Replace(cmdstr,'$TMPOBJ',outputexedir+tmpLinkFileName);
  519. Comment (v_debug,'Executing '+BinStr+' '+cmdstr);
  520. success:=DoExec(FindUtil(BinStr),CmdStr,true,false);
  521. { Remove ReponseFile }
  522. if (success) and not(cs_link_extern in aktglobalswitches) then
  523. RemoveFile(outputexedir+Info.ResName);
  524. { Call nlmconv }
  525. if success then
  526. begin
  527. NLMConvLinkFile.writetodisk;
  528. NLMConvLinkFile.Free;
  529. SplitBinCmd(Info.ExeCmd[2],binstr,cmdstr);
  530. Replace(cmdstr,'$RES',outputexedir+'n'+Info.ResName);
  531. Comment (v_debug,'Executing '+BinStr+' '+cmdstr);
  532. success:=DoExec(FindUtil(BinStr),CmdStr,true,false);
  533. if (success) and not(cs_link_extern in aktglobalswitches) then
  534. begin
  535. RemoveFile(outputexedir+'n'+Info.ResName);
  536. RemoveFile(outputexedir+tmpLinkFileName);
  537. if not xdcpresent then
  538. if usexdc then
  539. RemoveFile (xdcname);
  540. end;
  541. end;
  542. MakeNetwareLoadableModule:=success; { otherwise a recursive call to link method }
  543. end;
  544. function TLinkerNetwlibc.MakeExecutable:boolean;
  545. begin
  546. MakeExecutable := MakeNetwareLoadableModule (false);
  547. end;
  548. function TLinkerNetwlibc.MakeSharedLibrary:boolean;
  549. begin
  550. MakeSharedLibrary := MakeNetwareLoadableModule (true);
  551. end;
  552. {*****************************************************************************
  553. Initialize
  554. *****************************************************************************}
  555. initialization
  556. RegisterExternalLinker(system_i386_netwlibc_info,TLinkerNetwlibc);
  557. RegisterImport(system_i386_netwlibc,TImportLibNetwlibc);
  558. RegisterExport(system_i386_netwlibc,TExportLibNetwlibc);
  559. RegisterTarget(system_i386_netwlibc_info);
  560. end.
  561. {
  562. $Log$
  563. Revision 1.3 2004-09-19 18:10:32 armin
  564. * added library support
  565. Revision 1.2 2004/09/19 14:23:43 armin
  566. * support library flag
  567. * automaticly gernerate xdc data
  568. Revision 1.1 2004/09/04 21:18:47 armin
  569. * target netwlibc added (libc is preferred for newer netware versions)
  570. Revision 1.14 2004/08/30 11:17:34 armin
  571. * added support for libc
  572. Revision 1.13 2004/08/01 19:29:06 armin
  573. * changes to compile fpc on netware
  574. Revision 1.12 2004/07/30 16:00:19 armin
  575. * removed -m for nlmconv, it is only valid for ld
  576. Revision 1.11 2004/06/20 08:55:32 florian
  577. * logs truncated
  578. Revision 1.10 2004/03/02 00:36:33 olle
  579. * big transformation of Tai_[const_]Symbol.Create[data]name*
  580. }