options.pas 48 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555
  1. {
  2. $Id$
  3. Copyright (c) 1998-2000 by Florian Klaempfl and Peter Vreman
  4. Reads command line options and config files
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 2 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program; if not, write to the Free Software
  15. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  16. ****************************************************************************
  17. }
  18. unit options;
  19. interface
  20. uses
  21. globtype,globals,verbose;
  22. type
  23. POption=^TOption;
  24. TOption=object
  25. FirstPass,
  26. NoPressEnter,
  27. DoWriteLogo : boolean;
  28. FileLevel : longint;
  29. ParaIncludePath,
  30. ParaUnitPath,
  31. ParaObjectPath,
  32. ParaLibraryPath : TSearchPathList;
  33. Constructor Init;
  34. Destructor Done;
  35. procedure WriteLogo;
  36. procedure WriteInfo;
  37. procedure WriteHelpPages;
  38. procedure QuickInfo(const s:string);
  39. procedure IllegalPara(const opt:string);
  40. function Unsetbool(const opts:string; pos: Longint):boolean;
  41. procedure interpret_proc_specific_options(const opt:string);virtual;
  42. procedure interpret_option(const opt :string;ispara:boolean);
  43. procedure Interpret_envvar(const envname : string);
  44. procedure Interpret_file(const filename : string);
  45. procedure Read_Parameters;
  46. procedure parsecmd(cmd:string);
  47. end;
  48. procedure read_arguments(cmd:string);
  49. implementation
  50. uses
  51. {$ifdef Delphi}
  52. dmisc,
  53. {$else Delphi}
  54. dos,
  55. {$endif Delphi}
  56. version,systems,
  57. cobjects,
  58. symtable,scanner,link,messages
  59. {$ifdef BrowserLog}
  60. ,browlog
  61. {$endif BrowserLog}
  62. {$ifdef i386}
  63. ,opts386
  64. {$endif}
  65. {$ifdef m68k}
  66. ,opts68k
  67. {$endif}
  68. ;
  69. const
  70. page_size = 24;
  71. var
  72. option : poption;
  73. read_configfile, { read config file, set when a cfgfile is found }
  74. disable_configfile,
  75. target_is_set : boolean; { do not allow contradictory target settings }
  76. asm_is_set : boolean; { -T also change initoutputformat if not set idrectly }
  77. fpcdir,
  78. ppccfg,
  79. msgfilename,
  80. param_file : string; { file to compile specified on the commandline }
  81. {****************************************************************************
  82. Defines
  83. ****************************************************************************}
  84. procedure def_symbol(const s : string);
  85. begin
  86. if s='' then
  87. exit;
  88. initdefines.concat(new(pstring_item,init(upper(s))));
  89. end;
  90. procedure undef_symbol(const s : string);
  91. var
  92. item,next : pstring_item;
  93. begin
  94. if s='' then
  95. exit;
  96. item:=pstring_item(initdefines.first);
  97. while assigned(item) do
  98. begin
  99. if (item^.str^=s) then
  100. begin
  101. next:=pstring_item(item^.next);
  102. initdefines.remove(item);
  103. dispose(item,done);
  104. item:=next;
  105. end
  106. else
  107. if item<>pstring_item(item^.next) then
  108. item:=pstring_item(item^.next)
  109. else
  110. break;
  111. end;
  112. end;
  113. function check_symbol(const s:string):boolean;
  114. var
  115. hp : pstring_item;
  116. begin
  117. hp:=pstring_item(initdefines.first);
  118. while assigned(hp) do
  119. begin
  120. if (hp^.str^=s) then
  121. begin
  122. check_symbol:=true;
  123. exit;
  124. end;
  125. hp:=pstring_item(hp^.next);
  126. end;
  127. check_symbol:=false;
  128. end;
  129. procedure MaybeLoadMessageFile;
  130. begin
  131. { Load new message file }
  132. if (msgfilename<>'') then
  133. begin
  134. if fileexists(msgfilename) then
  135. LoadMsgFile(msgfilename);
  136. msgfilename:='';
  137. end;
  138. end;
  139. {****************************************************************************
  140. Toption
  141. ****************************************************************************}
  142. procedure StopOptions;
  143. begin
  144. if assigned(Option) then
  145. begin
  146. dispose(Option,Done);
  147. Option:=nil;
  148. end;
  149. DoneVerbose;
  150. Stop;
  151. end;
  152. procedure Toption.WriteLogo;
  153. var
  154. i : tmsgconst;
  155. begin
  156. MaybeLoadMessageFile;
  157. for i:=option_logo_start to option_logo_end do
  158. Message1(i,target_cpu_string);
  159. end;
  160. procedure Toption.WriteInfo;
  161. var
  162. i : tmsgconst;
  163. begin
  164. MaybeLoadMessageFile;
  165. for i:=option_info_start to option_info_end do
  166. Message(i);
  167. StopOptions;
  168. end;
  169. procedure Toption.WriteHelpPages;
  170. function PadEnd(s:string;i:longint):string;
  171. begin
  172. while (length(s)<i) do
  173. s:=s+' ';
  174. PadEnd:=s;
  175. end;
  176. var
  177. idx,
  178. lastident,
  179. j,outline,
  180. ident,
  181. lines : longint;
  182. show : boolean;
  183. opt : string[32];
  184. input,
  185. s : string;
  186. begin
  187. MaybeLoadMessageFile;
  188. Message1(option_usage,paramstr(0));
  189. lastident:=0;
  190. if DoWriteLogo then
  191. lines:=3
  192. else
  193. lines:=1;
  194. for idx:=ord(ol_begin) to ord(ol_end) do
  195. begin
  196. { get a line and reset }
  197. s:=msg^.Get(idx);
  198. ident:=0;
  199. show:=false;
  200. { parse options }
  201. case s[1] of
  202. {$ifdef i386}
  203. '3',
  204. {$endif}
  205. {$ifdef m68k}
  206. '6',
  207. {$endif}
  208. '*' : show:=true;
  209. end;
  210. if show then
  211. begin
  212. case s[2] of
  213. {$ifdef TP}
  214. 't',
  215. {$endif}
  216. {$ifdef GDB}
  217. 'g',
  218. {$endif}
  219. {$ifdef linux}
  220. 'L',
  221. {$endif}
  222. {$ifdef os2}
  223. 'O',
  224. {$endif}
  225. '*' : show:=true;
  226. else
  227. show:=false;
  228. end;
  229. end;
  230. { now we may show the message or not }
  231. if show then
  232. begin
  233. case s[3] of
  234. '0' : begin
  235. ident:=0;
  236. outline:=0;
  237. end;
  238. '1' : begin
  239. ident:=2;
  240. outline:=7;
  241. end;
  242. '2' : begin
  243. ident:=11;
  244. outline:=11;
  245. end;
  246. '3' : begin
  247. ident:=21;
  248. outline:=6;
  249. end;
  250. end;
  251. j:=pos('_',s);
  252. opt:=Copy(s,4,j-4);
  253. if opt='*' then
  254. opt:=''
  255. else
  256. opt:=PadEnd('-'+opt,outline);
  257. if (ident=0) and (lastident<>0) then
  258. begin
  259. Comment(V_Normal,'');
  260. inc(Lines);
  261. end;
  262. { page full ? }
  263. if (lines>=page_size) then
  264. begin
  265. if not NoPressEnter then
  266. begin
  267. write('*** press enter ***');
  268. readln(input);
  269. if upper(input)='Q' then
  270. StopOptions;
  271. end;
  272. lines:=0;
  273. end;
  274. Comment(V_Normal,PadEnd('',ident)+opt+Copy(s,j+1,255));
  275. LastIdent:=Ident;
  276. inc(Lines);
  277. end;
  278. end;
  279. StopOptions;
  280. end;
  281. procedure Toption.QuickInfo(const s:string);
  282. begin
  283. if source_os.newline=#13#10 then
  284. Write(s+#10)
  285. else
  286. Writeln(s);
  287. StopOptions;
  288. end;
  289. procedure Toption.IllegalPara(const opt:string);
  290. begin
  291. Message1(option_illegal_para,opt);
  292. Message(option_help_pages_para);
  293. StopOptions;
  294. end;
  295. function Toption.Unsetbool(const opts:string; pos: Longint):boolean;
  296. { checks if the character after pos in Opts is a + or a - and returns resp.
  297. false or true. If it is another character (or none), it also returns false }
  298. begin
  299. UnsetBool := (Length(Opts) > Pos) And (Opts[Succ(Pos)] = '-');
  300. end;
  301. procedure TOption.interpret_proc_specific_options(const opt:string);
  302. begin
  303. end;
  304. procedure TOption.interpret_option(const opt:string;ispara:boolean);
  305. var
  306. code : integer;
  307. c : char;
  308. more : string;
  309. major,minor : longint;
  310. error : integer;
  311. j,l : longint;
  312. d : DirStr;
  313. e : ExtStr;
  314. begin
  315. if opt='' then
  316. exit;
  317. { only parse define,undef,target,verbosity and link options the firsttime }
  318. if firstpass and
  319. not((opt[1]='-') and (opt[2] in ['i','d','v','T','u','n','X'])) then
  320. exit;
  321. case opt[1] of
  322. '-' : begin
  323. more:=Copy(opt,3,255);
  324. case opt[2] of
  325. '!' : initlocalswitches:=initlocalswitches+[cs_ansistrings];
  326. '?' : WriteHelpPages;
  327. 'a' : begin
  328. initglobalswitches:=initglobalswitches+[cs_asm_leave];
  329. for j:=1 to length(more) do
  330. case more[j] of
  331. 'l' : initglobalswitches:=initglobalswitches+[cs_asm_source];
  332. 'r' : initglobalswitches:=initglobalswitches+[cs_asm_regalloc];
  333. 't' : initglobalswitches:=initglobalswitches+[cs_asm_tempalloc];
  334. '-' : initglobalswitches:=initglobalswitches-[cs_asm_leave,cs_asm_source,cs_asm_regalloc];
  335. else
  336. IllegalPara(opt);
  337. end;
  338. end;
  339. 'A' : begin
  340. if set_string_asm(More) then
  341. begin
  342. initoutputformat:=target_asm.id;
  343. asm_is_set:=true;
  344. end
  345. else
  346. IllegalPara(opt);
  347. end;
  348. 'b' : begin
  349. {$ifdef BrowserLog}
  350. initglobalswitches:=initglobalswitches+[cs_browser_log];
  351. {$endif}
  352. if More<>'' then
  353. if More='l' then
  354. initmoduleswitches:=initmoduleswitches+[cs_local_browser]
  355. else if More='-' then
  356. begin
  357. initmoduleswitches:=initmoduleswitches-[cs_browser,cs_local_browser];
  358. {$ifdef BrowserLog}
  359. initglobalswitches:=initglobalswitches-[cs_browser_log];
  360. {$endif}
  361. end
  362. else if More<>'+' then
  363. {$ifdef BrowserLog}
  364. browserlog.elements_to_list^.insert(more);
  365. {$else}
  366. IllegalPara(opt);
  367. {$endif}
  368. end;
  369. 'B' : if more='' then
  370. do_build:=true
  371. else
  372. if more = '-' then
  373. do_build := False
  374. else
  375. IllegalPara(opt);
  376. 'C' : begin
  377. j := 1;
  378. while j <= length(more) Do
  379. Begin
  380. case more[j] of
  381. 'a' : Simplify_ppu:=true;
  382. 'h' :
  383. begin
  384. val(copy(more,j+1,length(more)-j),heapsize,code);
  385. if (code<>0) or (heapsize>=67107840) or (heapsize<1024) then
  386. IllegalPara(opt);
  387. break;
  388. end;
  389. 'i' : If UnsetBool(More, j) then
  390. Begin
  391. initlocalswitches:=initlocalswitches-[cs_check_io];
  392. inc(j)
  393. End
  394. else initlocalswitches:=initlocalswitches+[cs_check_io];
  395. 'n' : If UnsetBool(More, j) then
  396. Begin
  397. initglobalswitches:=initglobalswitches-[cs_link_extern];
  398. inc(j)
  399. End
  400. Else initglobalswitches:=initglobalswitches+[cs_link_extern];
  401. 'o' :
  402. If UnsetBool(More, j) then
  403. Begin
  404. initlocalswitches:=initlocalswitches-[cs_check_overflow];
  405. inc(j);
  406. End
  407. Else
  408. initlocalswitches:=initlocalswitches+[cs_check_overflow];
  409. 'r' :
  410. If UnsetBool(More, j) then
  411. Begin
  412. initlocalswitches:=initlocalswitches-[cs_check_range];
  413. inc(j);
  414. End
  415. Else
  416. initlocalswitches:=initlocalswitches+[cs_check_range];
  417. 's' :
  418. begin
  419. val(copy(more,j+1,length(more)-j),stacksize,code);
  420. if (code<>0) or (stacksize>=67107840) or (stacksize<1024) then
  421. IllegalPara(opt);
  422. break;
  423. end;
  424. 't' :
  425. If UnsetBool(More, j) then
  426. Begin
  427. initlocalswitches:=initlocalswitches-[cs_check_stack];
  428. inc(j)
  429. End
  430. Else
  431. initlocalswitches:=initlocalswitches+[cs_check_stack];
  432. 'D' :
  433. If UnsetBool(More, j) then
  434. Begin
  435. initmoduleswitches:=initmoduleswitches-[cs_create_dynamic];
  436. inc(j)
  437. End
  438. Else
  439. initmoduleswitches:=initmoduleswitches+[cs_create_dynamic];
  440. 'X' :
  441. If UnsetBool(More, j) then
  442. Begin
  443. initmoduleswitches:=initmoduleswitches-[cs_create_smart];
  444. inc(j)
  445. End
  446. Else
  447. initmoduleswitches:=initmoduleswitches+[cs_create_smart];
  448. else
  449. IllegalPara(opt);
  450. end;
  451. inc(j);
  452. end;
  453. end;
  454. 'd' : def_symbol(more);
  455. 'D' : begin
  456. initglobalswitches:=initglobalswitches+[cs_link_deffile];
  457. for j:=1 to length(more) do
  458. case more[j] of
  459. 'd' : begin
  460. description:=Copy(more,j+1,255);
  461. break;
  462. end;
  463. 'v' : begin
  464. dllversion:=Copy(more,j+1,255);
  465. l:=pos('.',dllversion);
  466. dllminor:=0;
  467. error:=0;
  468. if l>0 then
  469. begin
  470. valint(copy(dllversion,l+1,255),minor,error);
  471. if (error=0) and
  472. (minor>=0) and (minor<=$ffff) then
  473. dllminor:=minor
  474. else if error=0 then
  475. error:=1;
  476. end;
  477. if l=0 then l:=256;
  478. dllmajor:=1;
  479. if error=0 then
  480. valint(copy(dllversion,1,l-1),major,error);
  481. if (error=0) and (major>=0) and (major<=$ffff) then
  482. dllmajor:=major
  483. else if error=0 then
  484. error:=1;
  485. if error<>0 then
  486. Message1(scan_w_wrong_version_ignored,dllversion);
  487. break;
  488. end;
  489. 'w' : usewindowapi:=true;
  490. else
  491. IllegalPara(opt);
  492. end;
  493. end;
  494. 'e' : exepath:=FixPath(More,true);
  495. { Just used by RHIDE }
  496. 'E' : if (length(more)=0) or (UnsetBool(More, 0)) then
  497. initglobalswitches:=initglobalswitches+[cs_link_extern]
  498. else
  499. initglobalswitches:=initglobalswitches-[cs_link_extern];
  500. 'F' : begin
  501. c:=more[1];
  502. Delete(more,1,1);
  503. case c of
  504. 'D' : begin
  505. if not ispara then
  506. DefaultReplacements(More);
  507. utilsdirectory:=FixPath(More,true);
  508. end;
  509. 'e' : SetRedirectFile(More);
  510. 'E' : OutputExeDir:=FixPath(More,true);
  511. 'i' : if ispara then
  512. ParaIncludePath.AddPath(More,false)
  513. else
  514. includesearchpath.AddPath(More,true);
  515. 'g' : Message2(option_obsolete_switch_use_new,'-Fg','-Fl');
  516. 'l' : if ispara then
  517. ParaLibraryPath.AddPath(More,false)
  518. else
  519. LibrarySearchPath.AddPath(More,true);
  520. 'L' : if More<>'' then
  521. ParaDynamicLinker:=More
  522. else
  523. IllegalPara(opt);
  524. 'o' : if ispara then
  525. ParaObjectPath.AddPath(More,false)
  526. else
  527. ObjectSearchPath.AddPath(More,true);
  528. 'r' : Msgfilename:=More;
  529. 'u' : if ispara then
  530. ParaUnitPath.AddPath(More,false)
  531. else
  532. unitsearchpath.AddPath(More,true);
  533. 'U' : OutputUnitDir:=FixPath(More,true);
  534. else
  535. IllegalPara(opt);
  536. end;
  537. end;
  538. 'g' : begin
  539. if UnsetBool(More, 0) then
  540. begin
  541. initmoduleswitches:=initmoduleswitches-[cs_debuginfo];
  542. if (length(More)>1) and (More[2]='l') then
  543. initglobalswitches:=initglobalswitches+[cs_gdb_lineinfo];
  544. end
  545. else
  546. begin
  547. {$ifdef GDB}
  548. initmoduleswitches:=initmoduleswitches+[cs_debuginfo];
  549. if not RelocSectionSetExplicitly then
  550. RelocSection:=false;
  551. for j:=1 to length(more) do
  552. case more[j] of
  553. 'd' : initglobalswitches:=initglobalswitches+[cs_gdb_dbx];
  554. 'g' : initglobalswitches:=initglobalswitches+[cs_gdb_gsym];
  555. 'h' : initglobalswitches:=initglobalswitches+[cs_gdb_heaptrc];
  556. 'l' : initglobalswitches:=initglobalswitches+[cs_gdb_lineinfo];
  557. 'c' : initglobalswitches:=initglobalswitches+[cs_checkpointer];
  558. {$ifdef EXTDEBUG}
  559. 'p' : only_one_pass:=true;
  560. {$endif EXTDEBUG}
  561. else
  562. IllegalPara(opt);
  563. end;
  564. {$else GDB}
  565. Message(option_no_debug_support);
  566. Message(option_no_debug_support_recompile_fpc);
  567. {$endif GDB}
  568. end;
  569. end;
  570. 'h' : begin
  571. NoPressEnter:=true;
  572. WriteHelpPages;
  573. end;
  574. 'i' : if more='' then
  575. WriteInfo
  576. else
  577. begin
  578. { Specific info, which can be used in Makefiles }
  579. case More[1] of
  580. 'S' : begin
  581. case More[2] of
  582. 'O' : QuickInfo(source_os.shortname);
  583. {$ifdef Delphi !!!!!!!!!}
  584. 'P' : QuickInfo('unknown');
  585. {$else}
  586. 'P' : QuickInfo(source_cpu_string);
  587. {$endif}
  588. end;
  589. end;
  590. 'T' : begin
  591. case More[2] of
  592. 'O' : QuickInfo(target_os.shortname);
  593. 'P' : QuickInfo(target_cpu_string);
  594. end;
  595. end;
  596. 'V' : QuickInfo(version_string);
  597. 'D' : QuickInfo(date_string);
  598. else
  599. IllegalPara(Opt);
  600. end;
  601. end;
  602. 'I' : if ispara then
  603. ParaIncludePath.AddPath(More,false)
  604. else
  605. includesearchpath.AddPath(More,false);
  606. 'k' : if more<>'' then
  607. ParaLinkOptions:=ParaLinkOptions+' '+More
  608. else
  609. IllegalPara(opt);
  610. 'l' : if more='' then
  611. DoWriteLogo:=true
  612. else
  613. IllegalPara(opt);
  614. 'm' : parapreprocess:=true;
  615. 'n' : if More='' then
  616. begin
  617. read_configfile:=false;
  618. disable_configfile:=true;
  619. end
  620. else
  621. IllegalPara(opt);
  622. 'o' : if More<>'' then
  623. Fsplit(More,d,OutputFile,e)
  624. else
  625. IllegalPara(opt);
  626. 'p' : begin
  627. if UnsetBool(More, 0) then
  628. begin
  629. initmoduleswitches:=initmoduleswitches-[cs_profile];
  630. undef_symbol('FPC_PROFILE');
  631. end
  632. else
  633. case more[1] of
  634. 'g' : if (length(opt)=3) and UnsetBool(more, 1) then
  635. begin
  636. initmoduleswitches:=initmoduleswitches-[cs_profile];
  637. undef_symbol('FPC_PROFILE');
  638. end
  639. else
  640. begin
  641. initmoduleswitches:=initmoduleswitches+[cs_profile];
  642. def_symbol('FPC_PROFILE');
  643. end;
  644. else
  645. IllegalPara(opt);
  646. end;
  647. end;
  648. {$ifdef linux}
  649. 'P' : initglobalswitches:=initglobalswitches+[cs_asm_pipe];
  650. {$endif}
  651. 's' : initglobalswitches:=initglobalswitches+[cs_asm_extern,cs_link_extern];
  652. 'S' : begin
  653. for j:=1 to length(more) do
  654. case more[j] of
  655. '2' : initmodeswitches:=objfpcmodeswitches;
  656. 'a' : initlocalswitches:=InitLocalswitches+[cs_do_assertion];
  657. 'c' : initmoduleswitches:=initmoduleswitches+[cs_support_c_operators];
  658. 'd' : initmodeswitches:=delphimodeswitches;
  659. 'e' : begin
  660. val(copy(more,j+1,length(more)-j),l,code);
  661. if (code<>0) then
  662. SetMaxErrorCount(1)
  663. else
  664. begin
  665. SetMaxErrorCount(l);
  666. break;
  667. end;
  668. end;
  669. 'g' : initmoduleswitches:=initmoduleswitches+[cs_support_goto];
  670. 'h' : initlocalswitches:=initlocalswitches+[cs_ansistrings];
  671. 'i' : initmoduleswitches:=initmoduleswitches+[cs_support_inline];
  672. 'm' : initmoduleswitches:=initmoduleswitches+[cs_support_macro];
  673. 'o': initmodeswitches:=tpmodeswitches;
  674. 'p' : initmodeswitches:=gpcmodeswitches;
  675. 's' : initglobalswitches:=initglobalswitches+[cs_constructor_name];
  676. 't' : initmoduleswitches:=initmoduleswitches+[cs_static_keyword];
  677. 'v' : Message1(option_obsolete_switch,'-Sv');
  678. else
  679. IllegalPara(opt);
  680. end;
  681. end;
  682. 'T' : begin
  683. more:=Upper(More);
  684. if not target_is_set then
  685. begin
  686. { remove old target define }
  687. undef_symbol(target_info.short_name);
  688. { load new target }
  689. if not(set_string_target(More)) then
  690. IllegalPara(opt);
  691. { set new define }
  692. def_symbol(target_info.short_name);
  693. if not asm_is_set then
  694. initoutputformat:=target_asm.id;
  695. target_is_set:=true;
  696. end
  697. else
  698. if More<>target_info.short_name then
  699. Message1(option_target_is_already_set,target_info.short_name);
  700. end;
  701. 'u' : undef_symbol(upper(More));
  702. 'U' : begin
  703. for j:=1 to length(more) do
  704. case more[j] of
  705. {$ifdef UNITALIASES}
  706. 'a' : begin
  707. AddUnitAlias(Copy(More,j+1,255));
  708. break;
  709. end;
  710. {$endif UNITALIASES}
  711. 'n' : initglobalswitches:=initglobalswitches-[cs_check_unit_name];
  712. 'p' : begin
  713. Message2(option_obsolete_switch_use_new,'-Up','-Fu');
  714. break;
  715. end;
  716. 's' : initmoduleswitches:=initmoduleswitches+[cs_compilesystem];
  717. else
  718. IllegalPara(opt);
  719. end;
  720. end;
  721. 'v' : if not setverbosity(More) then
  722. IllegalPara(opt);
  723. 'W' : begin
  724. for j:=1 to length(More) do
  725. case More[j] of
  726. 'B': {bind_win32_dll:=true}
  727. begin
  728. { -WB200000 means set prefered base address
  729. to $200000, but does not change relocsection boolean
  730. this way we can create both relocatble and
  731. non relocatable DLL at a specific base address PM }
  732. if (length(More)>j) then
  733. begin
  734. if DLLImageBase=nil then
  735. DLLImageBase:=StringDup(Copy(More,j+1,255));
  736. end
  737. else
  738. begin
  739. RelocSection:=true;
  740. RelocSectionSetExplicitly:=true;
  741. end;
  742. break;
  743. end;
  744. 'C': apptype:=at_cui;
  745. 'D': ForceDeffileForExport:=true;
  746. 'G': apptype:=at_gui;
  747. 'N': begin
  748. RelocSection:=false;
  749. RelocSectionSetExplicitly:=true;
  750. end;
  751. 'R': begin
  752. RelocSection:=true;
  753. RelocSectionSetExplicitly:=true;
  754. end;
  755. else
  756. IllegalPara(opt);
  757. end;
  758. end;
  759. 'X' : begin
  760. for j:=1 to length(More) do
  761. case More[j] of
  762. 'c' : initglobalswitches:=initglobalswitches+[cs_link_toc];
  763. 's' : initglobalswitches:=initglobalswitches+[cs_link_strip];
  764. 't' : initglobalswitches:=initglobalswitches+[cs_link_staticflag];
  765. 'D' : begin
  766. def_symbol('FPC_LINK_DYNAMIC');
  767. undef_symbol('FPC_LINK_SMART');
  768. undef_symbol('FPC_LINK_STATIC');
  769. initglobalswitches:=initglobalswitches+[cs_link_shared];
  770. initglobalswitches:=initglobalswitches-[cs_link_static,cs_link_smart];
  771. end;
  772. 'S' : begin
  773. def_symbol('FPC_LINK_STATIC');
  774. undef_symbol('FPC_LINK_SMART');
  775. undef_symbol('FPC_LINK_DYNAMIC');
  776. initglobalswitches:=initglobalswitches+[cs_link_static];
  777. initglobalswitches:=initglobalswitches-[cs_link_shared,cs_link_smart];
  778. end;
  779. 'X' : begin
  780. def_symbol('FPC_LINK_SMART');
  781. undef_symbol('FPC_LINK_STATIC');
  782. undef_symbol('FPC_LINK_DYNAMIC');
  783. initglobalswitches:=initglobalswitches+[cs_link_smart];
  784. initglobalswitches:=initglobalswitches-[cs_link_shared,cs_link_static];
  785. end;
  786. else
  787. IllegalPara(opt);
  788. end;
  789. end;
  790. { give processor specific options a chance }
  791. else
  792. interpret_proc_specific_options(opt);
  793. end;
  794. end;
  795. '@' : begin
  796. Message(option_no_nested_response_file);
  797. StopOptions;
  798. end;
  799. else
  800. begin
  801. if (length(param_file)<>0) then
  802. Message(option_only_one_source_support);
  803. param_file:=opt;
  804. end;
  805. end;
  806. end;
  807. procedure Toption.Interpret_file(const filename : string);
  808. procedure RemoveSep(var fn:string);
  809. var
  810. i : longint;
  811. begin
  812. i:=0;
  813. while (i<length(fn)) and (fn[i+1] in [',',' ',#9]) do
  814. inc(i);
  815. Delete(fn,1,i);
  816. i:=length(fn);
  817. while (i>0) and (fn[i] in [',',' ',#9]) do
  818. dec(i);
  819. fn:=copy(fn,1,i);
  820. end;
  821. function GetName(var fn:string):string;
  822. var
  823. i : longint;
  824. begin
  825. i:=0;
  826. while (i<length(fn)) and (fn[i+1] in ['a'..'z','A'..'Z','0'..'9','_','-']) do
  827. inc(i);
  828. GetName:=Copy(fn,1,i);
  829. Delete(fn,1,i);
  830. end;
  831. const
  832. maxlevel=16;
  833. var
  834. f : text;
  835. s,
  836. opts : string;
  837. skip : array[0..maxlevel-1] of boolean;
  838. level : longint;
  839. option_read : boolean;
  840. begin
  841. { avoid infinite loop }
  842. Inc(FileLevel);
  843. Option_read:=false;
  844. If FileLevel>MaxLevel then
  845. Message(option_too_many_cfg_files);
  846. { open file }
  847. assign(f,filename);
  848. {$ifdef extdebug}
  849. Comment(V_Info,'trying to open file: '+filename);
  850. {$endif extdebug}
  851. {$I-}
  852. reset(f);
  853. {$I+}
  854. if ioresult<>0 then
  855. begin
  856. Message1(option_unable_open_file,filename);
  857. exit;
  858. end;
  859. fillchar(skip,sizeof(skip),0);
  860. level:=0;
  861. while not eof(f) do
  862. begin
  863. readln(f,opts);
  864. RemoveSep(opts);
  865. if (opts<>'') and (opts[1]<>';') then
  866. begin
  867. if opts[1]='#' then
  868. begin
  869. Delete(opts,1,1);
  870. s:=upper(GetName(opts));
  871. if (s='SECTION') then
  872. begin
  873. RemoveSep(opts);
  874. s:=upper(GetName(opts));
  875. if level=0 then
  876. skip[level]:=not (check_symbol(s) or (s='COMMON'));
  877. end
  878. else
  879. if (s='IFDEF') then
  880. begin
  881. RemoveSep(opts);
  882. if Level>=maxlevel then
  883. begin
  884. Message(option_too_many_ifdef);
  885. stopOptions;
  886. end;
  887. inc(Level);
  888. skip[level]:=(skip[level-1] or (not check_symbol(upper(GetName(opts)))));
  889. end
  890. else
  891. if (s='IFNDEF') then
  892. begin
  893. RemoveSep(opts);
  894. if Level>=maxlevel then
  895. begin
  896. Message(option_too_many_ifdef);
  897. stopOptions;
  898. end;
  899. inc(Level);
  900. skip[level]:=(skip[level-1] or (check_symbol(upper(GetName(opts)))));
  901. end
  902. else
  903. if (s='ELSE') then
  904. skip[level]:=skip[level-1] or (not skip[level])
  905. else
  906. if (s='ENDIF') then
  907. begin
  908. skip[level]:=false;
  909. if Level=0 then
  910. begin
  911. Message(option_too_many_endif);
  912. stopOptions;
  913. end;
  914. dec(level);
  915. end
  916. else
  917. if (not skip[level]) then
  918. begin
  919. if (s='DEFINE') then
  920. begin
  921. RemoveSep(opts);
  922. def_symbol(upper(GetName(opts)));
  923. end
  924. else
  925. if (s='UNDEF') then
  926. begin
  927. RemoveSep(opts);
  928. undef_symbol(upper(GetName(opts)));
  929. end
  930. else
  931. if (s='WRITE') then
  932. begin
  933. Delete(opts,1,1);
  934. WriteLn(opts);
  935. end
  936. else
  937. if (s='INCLUDE') then
  938. begin
  939. Delete(opts,1,1);
  940. Interpret_file(opts);
  941. end;
  942. end;
  943. end
  944. else
  945. begin
  946. if (opts[1]='-') then
  947. begin
  948. if (not skip[level]) then
  949. interpret_option(opts,false);
  950. Option_read:=true;
  951. end
  952. else
  953. Message1(option_illegal_para,opts);
  954. end;
  955. end;
  956. end;
  957. if Level>0 then
  958. Message(option_too_less_endif);
  959. if Not Option_read then
  960. Message1(option_no_option_found,filename);
  961. Close(f);
  962. Dec(FileLevel);
  963. end;
  964. procedure Toption.Interpret_envvar(const envname : string);
  965. var
  966. argstart,
  967. env,
  968. pc : pchar;
  969. arglen : longint;
  970. quote : set of char;
  971. hs : string;
  972. begin
  973. env:=GetEnvPChar(envname);
  974. pc:=env;
  975. if assigned(pc) then
  976. begin
  977. repeat
  978. { skip leading spaces }
  979. while pc^ in [' ',#9,#13] do
  980. inc(pc);
  981. case pc^ of
  982. #0 :
  983. break;
  984. '"' :
  985. begin
  986. quote:=['"'];
  987. inc(pc);
  988. end;
  989. '''' :
  990. begin
  991. quote:=[''''];
  992. inc(pc);
  993. end;
  994. else
  995. quote:=[' ',#9,#13];
  996. end;
  997. { scan until the end of the argument }
  998. argstart:=pc;
  999. while (pc^<>#0) and not(pc^ in quote) do
  1000. inc(pc);
  1001. { create argument }
  1002. arglen:=pc-argstart;
  1003. hs[0]:=chr(arglen);
  1004. move(argstart^,hs[1],arglen);
  1005. interpret_option(hs,true);
  1006. { skip quote }
  1007. if pc^ in quote then
  1008. inc(pc);
  1009. until false;
  1010. end
  1011. else
  1012. Message1(option_no_option_found,'(env) '+envname);
  1013. FreeEnvPChar(env);
  1014. end;
  1015. procedure toption.read_parameters;
  1016. var
  1017. opts : string;
  1018. paramindex : longint;
  1019. begin
  1020. paramindex:=0;
  1021. while paramindex<paramcount do
  1022. begin
  1023. inc(paramindex);
  1024. opts:=paramstr(paramindex);
  1025. case opts[1] of
  1026. '@' :
  1027. begin
  1028. Delete(opts,1,1);
  1029. if not firstpass then
  1030. Message1(option_reading_further_from,opts);
  1031. interpret_file(opts);
  1032. end;
  1033. '!' :
  1034. begin
  1035. Delete(opts,1,1);
  1036. if not firstpass then
  1037. Message1(option_reading_further_from,'(env) '+opts);
  1038. interpret_envvar(opts);
  1039. end;
  1040. else
  1041. interpret_option(opts,true);
  1042. end;
  1043. end;
  1044. end;
  1045. procedure toption.parsecmd(cmd:string);
  1046. var
  1047. i,ps : longint;
  1048. opts : string;
  1049. begin
  1050. while (cmd<>'') do
  1051. begin
  1052. while cmd[1]=' ' do
  1053. delete(cmd,1,1);
  1054. i:=pos(' ',cmd);
  1055. if i=0 then
  1056. i:=256;
  1057. opts:=Copy(cmd,1,i-1);
  1058. Delete(cmd,1,i);
  1059. case opts[1] of
  1060. '@' :
  1061. begin
  1062. Delete(opts,1,1);
  1063. if not firstpass then
  1064. Message1(option_reading_further_from,opts);
  1065. interpret_file(opts);
  1066. end;
  1067. '!' :
  1068. begin
  1069. Delete(opts,1,1);
  1070. if not firstpass then
  1071. Message1(option_reading_further_from,'(env) '+opts);
  1072. interpret_envvar(opts);
  1073. end;
  1074. '"' :
  1075. begin
  1076. Delete(opts,1,1);
  1077. ps:=pos('"',cmd);
  1078. if (i<>256) and (ps>0) then
  1079. begin
  1080. opts:=opts + ' '+ copy(cmd,1,ps-1);
  1081. cmd:=copy(cmd,ps+1,255);
  1082. end;
  1083. interpret_option(opts,true);
  1084. end;
  1085. else
  1086. interpret_option(opts,true);
  1087. end;
  1088. end;
  1089. end;
  1090. constructor TOption.Init;
  1091. begin
  1092. DoWriteLogo:=false;
  1093. NoPressEnter:=false;
  1094. FirstPass:=false;
  1095. FileLevel:=0;
  1096. ParaIncludePath.Init;
  1097. ParaObjectPath.Init;
  1098. ParaUnitPath.Init;
  1099. ParaLibraryPath.Init;
  1100. end;
  1101. destructor TOption.Done;
  1102. begin
  1103. ParaIncludePath.Done;
  1104. ParaObjectPath.Done;
  1105. ParaUnitPath.Done;
  1106. ParaLibraryPath.Done;
  1107. end;
  1108. {****************************************************************************
  1109. Callable Routines
  1110. ****************************************************************************}
  1111. procedure read_arguments(cmd:string);
  1112. var
  1113. configpath : pathstr;
  1114. begin
  1115. {$ifdef Delphi}
  1116. option:=new(poption386,Init);
  1117. {$endif Delphi}
  1118. {$ifdef i386}
  1119. option:=new(poption386,Init);
  1120. {$endif}
  1121. {$ifdef m68k}
  1122. option:=new(poption68k,Init);
  1123. {$endif}
  1124. {$ifdef alpha}
  1125. option:=new(poption,Init);
  1126. {$endif}
  1127. {$ifdef powerpc}
  1128. option:=new(poption,Init);
  1129. {$endif}
  1130. { Load messages }
  1131. if (cmd='') and (paramcount=0) then
  1132. Option^.WriteHelpPages;
  1133. disable_configfile:=false;
  1134. { default defines }
  1135. def_symbol(target_info.short_name);
  1136. def_symbol('FPK');
  1137. def_symbol('FPC');
  1138. def_symbol('VER'+version_nr);
  1139. def_symbol('VER'+version_nr+'_'+release_nr);
  1140. def_symbol('VER'+version_nr+'_'+release_nr+'_'+patch_nr);
  1141. {$ifdef newcg}
  1142. def_symbol('WITHNEWCG');
  1143. {$endif}
  1144. { Temporary defines, until things settle down }
  1145. def_symbol('INT64');
  1146. def_symbol('HASRESOURCESTRINGS');
  1147. def_symbol('HASSAVEREGISTERS');
  1148. def_symbol('NEWVMTOFFSET');
  1149. def_symbol('HASINTERNMATH');
  1150. def_symbol('SYSTEMTVARREC');
  1151. def_symbol('INCLUDEOK');
  1152. def_symbol('NEWMM');
  1153. def_symbol('HASWIDECHAR');
  1154. {$ifdef SUPPORT_FIXED}
  1155. def_symbol('HASFIXED');
  1156. {$endif SUPPORT_FIXED}
  1157. {$ifdef cardinalmulfix}
  1158. { for the compiler }
  1159. def_symbol('CARDINALMULFIX');
  1160. { for the RTL }
  1161. def_symbol('CARDINALMULFIXED');
  1162. {$endif cardinalmulfix}
  1163. def_symbol('CORRECTFLDCW');
  1164. def_symbol('ENHANCEDRAISE');
  1165. { some stuff for TP compatibility }
  1166. {$ifdef i386}
  1167. def_symbol('CPU86');
  1168. def_symbol('CPU87');
  1169. {$endif}
  1170. {$ifdef m68k}
  1171. def_symbol('CPU68');
  1172. {$endif}
  1173. { new processor stuff }
  1174. {$ifdef i386}
  1175. def_symbol('CPUI386');
  1176. {$endif}
  1177. {$ifdef m68k}
  1178. def_symbol('CPU68K');
  1179. {$endif}
  1180. {$ifdef ALPHA}
  1181. def_symbol('CPUALPHA');
  1182. {$endif}
  1183. {$ifdef powerpc}
  1184. def_symbol('CPUPOWERPC');
  1185. {$endif}
  1186. { get default messagefile }
  1187. {$ifdef Delphi}
  1188. msgfilename:=dmisc.getenv('PPC_ERROR_FILE');
  1189. {$else Delphi}
  1190. msgfilename:=dos.getenv('PPC_ERROR_FILE');
  1191. {$endif Delphi}
  1192. { default configfile }
  1193. if (cmd<>'') and (cmd[1]='[') then
  1194. begin
  1195. ppccfg:=Copy(cmd,2,pos(']',cmd)-2);
  1196. Delete(cmd,1,pos(']',cmd));
  1197. end
  1198. else
  1199. begin
  1200. {$ifdef i386}
  1201. ppccfg:='ppc386.cfg';
  1202. {$endif i386}
  1203. {$ifdef m68k}
  1204. ppccfg:='ppc.cfg';
  1205. {$endif}
  1206. {$ifdef alpha}
  1207. ppccfg:='ppcalpha.cfg';
  1208. {$endif}
  1209. {$ifdef powerpc}
  1210. ppccfg:='ppcppc.cfg';
  1211. {$endif}
  1212. end;
  1213. { Order to read ppc386.cfg:
  1214. 1 - current dir
  1215. 2 - configpath
  1216. 3 - compiler path }
  1217. {$ifdef Delphi}
  1218. configpath:=FixPath(dmisc.getenv('PPC_CONFIG_PATH'),false);
  1219. {$else Delphi}
  1220. configpath:=FixPath(dos.getenv('PPC_CONFIG_PATH'),false);
  1221. {$endif Delphi}
  1222. {$ifdef linux}
  1223. if configpath='' then
  1224. configpath:='/etc/';
  1225. {$endif}
  1226. if ppccfg<>'' then
  1227. begin
  1228. read_configfile:=true;
  1229. if not FileExists(ppccfg) then
  1230. begin
  1231. {$ifdef linux}
  1232. if (dos.getenv('HOME')<>'') and FileExists(FixPath(dos.getenv('HOME'),false)+'.'+ppccfg) then
  1233. ppccfg:=FixPath(dos.getenv('HOME'),false)+'.'+ppccfg
  1234. else
  1235. {$endif}
  1236. if FileExists(configpath+ppccfg) then
  1237. ppccfg:=configpath+ppccfg
  1238. else
  1239. {$ifndef linux}
  1240. if FileExists(exepath+ppccfg) then
  1241. ppccfg:=exepath+ppccfg
  1242. else
  1243. {$endif}
  1244. read_configfile:=false;
  1245. end;
  1246. end
  1247. else
  1248. read_configfile:=false;
  1249. { Read commandline and configfile }
  1250. target_is_set:=false;
  1251. asm_is_set:=false;
  1252. param_file:='';
  1253. if read_configfile then
  1254. begin
  1255. { read the parameters quick, only -v -T }
  1256. option^.firstpass:=true;
  1257. if cmd<>'' then
  1258. option^.parsecmd(cmd)
  1259. else
  1260. option^.read_parameters;
  1261. option^.firstpass:=false;
  1262. if read_configfile then
  1263. begin
  1264. {$ifdef DEBUG}
  1265. Comment(V_Debug,'read config file: '+ppccfg);
  1266. {$endif DEBUG}
  1267. option^.interpret_file(ppccfg);
  1268. end;
  1269. end;
  1270. if cmd<>'' then
  1271. option^.parsecmd(cmd)
  1272. else
  1273. option^.read_parameters;
  1274. { Stop if errors in options }
  1275. if ErrorCount>0 then
  1276. StopOptions;
  1277. { write logo if set }
  1278. if option^.DoWriteLogo then
  1279. option^.WriteLogo;
  1280. { Check file to compile }
  1281. if param_file='' then
  1282. begin
  1283. Message(option_no_source_found);
  1284. StopOptions;
  1285. end;
  1286. {$ifndef linux}
  1287. param_file:=FixFileName(param_file);
  1288. {$endif}
  1289. fsplit(param_file,inputdir,inputfile,inputextension);
  1290. if inputextension='' then
  1291. begin
  1292. if FileExists(inputdir+inputfile+target_os.sourceext) then
  1293. inputextension:=target_os.sourceext
  1294. else
  1295. if FileExists(inputdir+inputfile+target_os.pasext) then
  1296. inputextension:=target_os.pasext;
  1297. end;
  1298. { Add paths specified with parameters to the searchpaths }
  1299. UnitSearchPath.AddList(Option^.ParaUnitPath,true);
  1300. ObjectSearchPath.AddList(Option^.ParaObjectPath,true);
  1301. IncludeSearchPath.AddList(Option^.ParaIncludePath,true);
  1302. LibrarySearchPath.AddList(Option^.ParaLibraryPath,true);
  1303. { add unit environment and exepath to the unit search path }
  1304. if inputdir<>'' then
  1305. Unitsearchpath.AddPath(inputdir,true);
  1306. if not disable_configfile then
  1307. {$ifdef Delphi}
  1308. UnitSearchPath.AddPath(dmisc.getenv(target_info.unit_env),false);
  1309. {$else}
  1310. UnitSearchPath.AddPath(dos.getenv(target_info.unit_env),false);
  1311. {$endif Delphi}
  1312. {$ifdef linux}
  1313. fpcdir:=FixPath(getenv('FPCDIR'),false);
  1314. if fpcdir='' then
  1315. begin
  1316. if PathExists('/usr/local/lib/fpc/'+version_string) then
  1317. fpcdir:='/usr/local/lib/fpc/'+version_string+'/'
  1318. else
  1319. fpcdir:='/usr/lib/fpc/'+version_string+'/';
  1320. end;
  1321. {$else}
  1322. fpcdir:=FixPath(getenv('FPCDIR'),false);
  1323. if fpcdir='' then
  1324. begin
  1325. fpcdir:=ExePath+'../';
  1326. if not(PathExists(fpcdir+'/units')) and
  1327. not(PathExists(fpcdir+'/rtl')) then
  1328. fpcdir:=fpcdir+'../';
  1329. end;
  1330. {$endif}
  1331. { first try development RTL, else use the default installation path }
  1332. if not disable_configfile then
  1333. begin
  1334. if PathExists(FpcDir+'rtl/'+lower(target_info.short_name)) then
  1335. UnitSearchPath.AddPath(FpcDir+'rtl/'+lower(target_info.short_name),false)
  1336. else
  1337. begin
  1338. UnitSearchPath.AddPath(FpcDir+'units/'+lower(target_info.short_name),false);
  1339. UnitSearchPath.AddPath(FpcDir+'units/'+lower(target_info.short_name)+'/rtl',false);
  1340. end;
  1341. end;
  1342. { Add exepath if the exe is not in the current dir, because that is always searched already }
  1343. if ExePath<>GetCurrentDir then
  1344. UnitSearchPath.AddPath(ExePath,false);
  1345. { Add unit dir to the object and library path }
  1346. objectsearchpath.AddList(unitsearchpath,false);
  1347. librarysearchpath.AddList(unitsearchpath,false);
  1348. { switch assembler if it's binary and we got -a on the cmdline }
  1349. if (cs_asm_leave in initglobalswitches) and
  1350. (target_asm.id in binassem) then
  1351. begin
  1352. Message(option_switch_bin_to_src_assembler);
  1353. set_target_asm(target_info.assemsrc);
  1354. initoutputformat:=target_asm.id;
  1355. end;
  1356. { turn off stripping if compiling with debuginfo or profile }
  1357. if (cs_debuginfo in initmoduleswitches) or
  1358. (cs_profile in initmoduleswitches) then
  1359. initglobalswitches:=initglobalswitches-[cs_link_strip];
  1360. { Set defines depending on the target }
  1361. if (target_info.target in [target_i386_GO32V1,target_i386_GO32V2]) then
  1362. def_symbol('DPMI'); { MSDOS is not defined in BP when target is DPMI }
  1363. MaybeLoadMessageFile;
  1364. dispose(option,Done);
  1365. Option:=nil;
  1366. end;
  1367. end.
  1368. {
  1369. $Log$
  1370. Revision 1.66 2000-04-24 13:34:29 peter
  1371. * added enhancedraise define
  1372. Revision 1.65 2000/04/10 11:36:19 pierre
  1373. * get -g-l to work
  1374. Revision 1.64 2000/04/07 14:56:18 peter
  1375. * correctfldcw define added
  1376. Revision 1.63 2000/04/05 21:57:34 pierre
  1377. * no unitdir automatically added if -n option present
  1378. Revision 1.62 2000/03/13 20:06:59 michael
  1379. + Added switch to swicth on assertions.
  1380. Revision 1.61 2000/02/15 14:36:45 florian
  1381. * disable FIXED data type per default
  1382. Revision 1.60 2000/02/10 11:45:48 peter
  1383. * addpath fixed with list of paths when inserting at the beginning
  1384. * if exepath=currentdir then it's not inserted in path list
  1385. * searchpaths in ppc386.cfg are now added at the beginning of the
  1386. list instead of at the end. (commandline is not changed)
  1387. * check paths before inserting in list
  1388. Revision 1.59 2000/02/09 13:22:54 peter
  1389. * log truncated
  1390. Revision 1.58 2000/02/09 10:35:48 peter
  1391. * -Xt option to link staticly against c libs
  1392. Revision 1.57 2000/02/06 17:20:52 peter
  1393. * -gl switch for auto lineinfo including
  1394. Revision 1.56 2000/01/31 15:55:42 peter
  1395. * fixed default unit location for linux when fpcdir was not set
  1396. Revision 1.55 2000/01/23 18:20:50 sg
  1397. * Fixed typo in line 1375 ("fpidr" instead of "fpcdir")
  1398. Revision 1.54 2000/01/23 16:36:37 peter
  1399. * better auto RTL dir detection
  1400. Revision 1.53 2000/01/20 10:36:44 daniel
  1401. * also support ; comments in cfg file
  1402. Revision 1.52 2000/01/17 22:50:28 peter
  1403. * fixed interpret_envvar whcih crashed when the envvar was not set
  1404. * also warn if the envvar is empty (=not set)
  1405. Revision 1.51 2000/01/14 15:33:15 pierre
  1406. + parsecmd supports "filename with spaces" for IDE
  1407. Revision 1.50 2000/01/14 14:33:54 pierre
  1408. + some warnings for wrong lines inside config files
  1409. Revision 1.49 2000/01/10 11:14:19 peter
  1410. * fixed memory leak with options, you must use StopOptions instead of
  1411. Stop
  1412. * fixed memory leak with forward resolving, make_ref is now false
  1413. Revision 1.48 2000/01/07 22:22:02 marco
  1414. * Added $target support for -FD
  1415. Revision 1.47 2000/01/07 01:14:27 peter
  1416. * updated copyright to 2000
  1417. Revision 1.46 2000/01/06 15:48:59 peter
  1418. * wildcard support for directory adding, this allows the use of units/*
  1419. in ppc386.cfg
  1420. Revision 1.45 1999/12/20 23:23:30 pierre
  1421. + $description $version
  1422. Revision 1.44 1999/12/20 21:42:36 pierre
  1423. + dllversion global variable
  1424. * FPC_USE_CPREFIX code removed, not necessary anymore
  1425. as we use .edata direct writing by default now.
  1426. Revision 1.43 1999/12/18 14:55:21 florian
  1427. * very basic widestring support
  1428. Revision 1.42 1999/12/11 18:53:31 jonas
  1429. * fixed type conversions of results of operations with cardinals
  1430. (between -dcardinalmulfix)
  1431. Revision 1.41 1999/12/10 10:03:54 peter
  1432. * fixed parameter orderning
  1433. Revision 1.40 1999/12/08 10:40:01 pierre
  1434. + allow use of unit var in exports of DLL for win32
  1435. by using direct export writing by default instead of use of DEFFILE
  1436. that does not allow assembler labels that do not
  1437. start with an underscore.
  1438. Use -WD to force use of Deffile for Win32 DLL
  1439. Revision 1.39 1999/12/06 18:21:03 peter
  1440. * support !ENVVAR for long commandlines
  1441. * win32/go32v2 write short pathnames to link.res so c:\Program Files\ is
  1442. finally supported as installdir.
  1443. }