options.pas 49 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578
  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. 'R' :
  418. If UnsetBool(More, j) then
  419. Begin
  420. initlocalswitches:=initlocalswitches-[cs_check_object_ext];
  421. inc(j);
  422. End
  423. Else
  424. initlocalswitches:=initlocalswitches+[cs_check_object_ext];
  425. 's' :
  426. begin
  427. val(copy(more,j+1,length(more)-j),stacksize,code);
  428. if (code<>0) or (stacksize>=67107840) or (stacksize<1024) then
  429. IllegalPara(opt);
  430. break;
  431. end;
  432. 't' :
  433. If UnsetBool(More, j) then
  434. Begin
  435. initlocalswitches:=initlocalswitches-[cs_check_stack];
  436. inc(j)
  437. End
  438. Else
  439. initlocalswitches:=initlocalswitches+[cs_check_stack];
  440. 'D' :
  441. If UnsetBool(More, j) then
  442. Begin
  443. initmoduleswitches:=initmoduleswitches-[cs_create_dynamic];
  444. inc(j)
  445. End
  446. Else
  447. initmoduleswitches:=initmoduleswitches+[cs_create_dynamic];
  448. 'X' :
  449. If UnsetBool(More, j) then
  450. Begin
  451. initmoduleswitches:=initmoduleswitches-[cs_create_smart];
  452. inc(j)
  453. End
  454. Else
  455. initmoduleswitches:=initmoduleswitches+[cs_create_smart];
  456. else
  457. IllegalPara(opt);
  458. end;
  459. inc(j);
  460. end;
  461. end;
  462. 'd' : def_symbol(more);
  463. 'D' : begin
  464. initglobalswitches:=initglobalswitches+[cs_link_deffile];
  465. for j:=1 to length(more) do
  466. case more[j] of
  467. 'd' : begin
  468. description:=Copy(more,j+1,255);
  469. break;
  470. end;
  471. 'v' : begin
  472. dllversion:=Copy(more,j+1,255);
  473. l:=pos('.',dllversion);
  474. dllminor:=0;
  475. error:=0;
  476. if l>0 then
  477. begin
  478. valint(copy(dllversion,l+1,255),minor,error);
  479. if (error=0) and
  480. (minor>=0) and (minor<=$ffff) then
  481. dllminor:=minor
  482. else if error=0 then
  483. error:=1;
  484. end;
  485. if l=0 then l:=256;
  486. dllmajor:=1;
  487. if error=0 then
  488. valint(copy(dllversion,1,l-1),major,error);
  489. if (error=0) and (major>=0) and (major<=$ffff) then
  490. dllmajor:=major
  491. else if error=0 then
  492. error:=1;
  493. if error<>0 then
  494. Message1(scan_w_wrong_version_ignored,dllversion);
  495. break;
  496. end;
  497. 'w' : usewindowapi:=true;
  498. else
  499. IllegalPara(opt);
  500. end;
  501. end;
  502. 'e' : exepath:=FixPath(More,true);
  503. { Just used by RHIDE }
  504. 'E' : if (length(more)=0) or (UnsetBool(More, 0)) then
  505. initglobalswitches:=initglobalswitches+[cs_link_extern]
  506. else
  507. initglobalswitches:=initglobalswitches-[cs_link_extern];
  508. 'F' : begin
  509. c:=more[1];
  510. Delete(more,1,1);
  511. case c of
  512. 'D' : begin
  513. if not ispara then
  514. DefaultReplacements(More);
  515. utilsdirectory:=FixPath(More,true);
  516. end;
  517. 'e' : SetRedirectFile(More);
  518. 'E' : OutputExeDir:=FixPath(More,true);
  519. 'i' : if ispara then
  520. ParaIncludePath.AddPath(More,false)
  521. else
  522. includesearchpath.AddPath(More,true);
  523. 'g' : Message2(option_obsolete_switch_use_new,'-Fg','-Fl');
  524. 'l' : if ispara then
  525. ParaLibraryPath.AddPath(More,false)
  526. else
  527. LibrarySearchPath.AddPath(More,true);
  528. 'L' : if More<>'' then
  529. ParaDynamicLinker:=More
  530. else
  531. IllegalPara(opt);
  532. 'o' : if ispara then
  533. ParaObjectPath.AddPath(More,false)
  534. else
  535. ObjectSearchPath.AddPath(More,true);
  536. 'r' : Msgfilename:=More;
  537. 'u' : if ispara then
  538. ParaUnitPath.AddPath(More,false)
  539. else
  540. unitsearchpath.AddPath(More,true);
  541. 'U' : OutputUnitDir:=FixPath(More,true);
  542. else
  543. IllegalPara(opt);
  544. end;
  545. end;
  546. 'g' : begin
  547. if UnsetBool(More, 0) then
  548. begin
  549. initmoduleswitches:=initmoduleswitches-[cs_debuginfo];
  550. if (length(More)>1) and (More[2]='l') then
  551. initglobalswitches:=initglobalswitches+[cs_gdb_lineinfo];
  552. end
  553. else
  554. begin
  555. {$ifdef GDB}
  556. initmoduleswitches:=initmoduleswitches+[cs_debuginfo];
  557. if not RelocSectionSetExplicitly then
  558. RelocSection:=false;
  559. for j:=1 to length(more) do
  560. case more[j] of
  561. 'd' : initglobalswitches:=initglobalswitches+[cs_gdb_dbx];
  562. 'g' : initglobalswitches:=initglobalswitches+[cs_gdb_gsym];
  563. 'h' : initglobalswitches:=initglobalswitches+[cs_gdb_heaptrc];
  564. 'l' : initglobalswitches:=initglobalswitches+[cs_gdb_lineinfo];
  565. 'c' : initglobalswitches:=initglobalswitches+[cs_checkpointer];
  566. {$ifdef EXTDEBUG}
  567. 'p' : only_one_pass:=true;
  568. {$endif EXTDEBUG}
  569. else
  570. IllegalPara(opt);
  571. end;
  572. {$else GDB}
  573. Message(option_no_debug_support);
  574. Message(option_no_debug_support_recompile_fpc);
  575. {$endif GDB}
  576. end;
  577. end;
  578. 'h' : begin
  579. NoPressEnter:=true;
  580. WriteHelpPages;
  581. end;
  582. 'i' : if more='' then
  583. WriteInfo
  584. else
  585. begin
  586. { Specific info, which can be used in Makefiles }
  587. case More[1] of
  588. 'S' : begin
  589. case More[2] of
  590. 'O' : QuickInfo(source_os.shortname);
  591. {$ifdef Delphi !!!!!!!!!}
  592. 'P' : QuickInfo('unknown');
  593. {$else}
  594. 'P' : QuickInfo(source_cpu_string);
  595. {$endif}
  596. end;
  597. end;
  598. 'T' : begin
  599. case More[2] of
  600. 'O' : QuickInfo(target_os.shortname);
  601. 'P' : QuickInfo(target_cpu_string);
  602. end;
  603. end;
  604. 'V' : QuickInfo(version_string);
  605. 'D' : QuickInfo(date_string);
  606. else
  607. IllegalPara(Opt);
  608. end;
  609. end;
  610. 'I' : if ispara then
  611. ParaIncludePath.AddPath(More,false)
  612. else
  613. includesearchpath.AddPath(More,false);
  614. 'k' : if more<>'' then
  615. ParaLinkOptions:=ParaLinkOptions+' '+More
  616. else
  617. IllegalPara(opt);
  618. 'l' : if more='' then
  619. DoWriteLogo:=true
  620. else
  621. IllegalPara(opt);
  622. 'm' : parapreprocess:=true;
  623. 'n' : if More='' then
  624. begin
  625. read_configfile:=false;
  626. disable_configfile:=true;
  627. end
  628. else
  629. IllegalPara(opt);
  630. 'o' : if More<>'' then
  631. Fsplit(More,d,OutputFile,e)
  632. else
  633. IllegalPara(opt);
  634. 'p' : begin
  635. if UnsetBool(More, 0) then
  636. begin
  637. initmoduleswitches:=initmoduleswitches-[cs_profile];
  638. undef_symbol('FPC_PROFILE');
  639. end
  640. else
  641. case more[1] of
  642. 'g' : if (length(opt)=3) and UnsetBool(more, 1) then
  643. begin
  644. initmoduleswitches:=initmoduleswitches-[cs_profile];
  645. undef_symbol('FPC_PROFILE');
  646. end
  647. else
  648. begin
  649. initmoduleswitches:=initmoduleswitches+[cs_profile];
  650. def_symbol('FPC_PROFILE');
  651. end;
  652. else
  653. IllegalPara(opt);
  654. end;
  655. end;
  656. {$ifdef linux}
  657. 'P' : initglobalswitches:=initglobalswitches+[cs_asm_pipe];
  658. {$endif}
  659. 's' : initglobalswitches:=initglobalswitches+[cs_asm_extern,cs_link_extern];
  660. 'S' : begin
  661. for j:=1 to length(more) do
  662. case more[j] of
  663. '2' : initmodeswitches:=objfpcmodeswitches;
  664. 'a' : initlocalswitches:=InitLocalswitches+[cs_do_assertion];
  665. 'c' : initmoduleswitches:=initmoduleswitches+[cs_support_c_operators];
  666. 'd' : initmodeswitches:=delphimodeswitches;
  667. 'e' : begin
  668. SetErrorFlags(more);
  669. break;
  670. end;
  671. 'g' : initmoduleswitches:=initmoduleswitches+[cs_support_goto];
  672. 'h' : initlocalswitches:=initlocalswitches+[cs_ansistrings];
  673. 'i' : initmoduleswitches:=initmoduleswitches+[cs_support_inline];
  674. 'm' : initmoduleswitches:=initmoduleswitches+[cs_support_macro];
  675. 'o': initmodeswitches:=tpmodeswitches;
  676. 'p' : initmodeswitches:=gpcmodeswitches;
  677. 's' : initglobalswitches:=initglobalswitches+[cs_constructor_name];
  678. 't' : initmoduleswitches:=initmoduleswitches+[cs_static_keyword];
  679. 'v' : Message1(option_obsolete_switch,'-Sv');
  680. else
  681. IllegalPara(opt);
  682. end;
  683. end;
  684. 'T' : begin
  685. more:=Upper(More);
  686. if not target_is_set then
  687. begin
  688. { remove old target define }
  689. undef_symbol(target_info.short_name);
  690. { load new target }
  691. if not(set_string_target(More)) then
  692. IllegalPara(opt);
  693. { set new define }
  694. def_symbol(target_info.short_name);
  695. if not asm_is_set then
  696. initoutputformat:=target_asm.id;
  697. target_is_set:=true;
  698. end
  699. else
  700. if More<>target_info.short_name then
  701. Message1(option_target_is_already_set,target_info.short_name);
  702. end;
  703. 'u' : undef_symbol(upper(More));
  704. 'U' : begin
  705. for j:=1 to length(more) do
  706. case more[j] of
  707. {$ifdef UNITALIASES}
  708. 'a' : begin
  709. AddUnitAlias(Copy(More,j+1,255));
  710. break;
  711. end;
  712. {$endif UNITALIASES}
  713. 'n' : initglobalswitches:=initglobalswitches-[cs_check_unit_name];
  714. 'p' : begin
  715. Message2(option_obsolete_switch_use_new,'-Up','-Fu');
  716. break;
  717. end;
  718. 's' : initmoduleswitches:=initmoduleswitches+[cs_compilesystem];
  719. else
  720. IllegalPara(opt);
  721. end;
  722. end;
  723. 'v' : if not setverbosity(More) then
  724. IllegalPara(opt);
  725. 'W' : begin
  726. for j:=1 to length(More) do
  727. case More[j] of
  728. 'B': {bind_win32_dll:=true}
  729. begin
  730. { -WB200000 means set prefered base address
  731. to $200000, but does not change relocsection boolean
  732. this way we can create both relocatble and
  733. non relocatable DLL at a specific base address PM }
  734. if (length(More)>j) then
  735. begin
  736. if DLLImageBase=nil then
  737. DLLImageBase:=StringDup(Copy(More,j+1,255));
  738. end
  739. else
  740. begin
  741. RelocSection:=true;
  742. RelocSectionSetExplicitly:=true;
  743. end;
  744. break;
  745. end;
  746. 'C': apptype:=at_cui;
  747. 'D': ForceDeffileForExport:=true;
  748. 'G': apptype:=at_gui;
  749. 'N': begin
  750. RelocSection:=false;
  751. RelocSectionSetExplicitly:=true;
  752. end;
  753. 'R': begin
  754. RelocSection:=true;
  755. RelocSectionSetExplicitly:=true;
  756. end;
  757. else
  758. IllegalPara(opt);
  759. end;
  760. end;
  761. 'X' : begin
  762. for j:=1 to length(More) do
  763. case More[j] of
  764. 'c' : initglobalswitches:=initglobalswitches+[cs_link_toc];
  765. 's' : initglobalswitches:=initglobalswitches+[cs_link_strip];
  766. 't' : initglobalswitches:=initglobalswitches+[cs_link_staticflag];
  767. 'D' : begin
  768. def_symbol('FPC_LINK_DYNAMIC');
  769. undef_symbol('FPC_LINK_SMART');
  770. undef_symbol('FPC_LINK_STATIC');
  771. initglobalswitches:=initglobalswitches+[cs_link_shared];
  772. initglobalswitches:=initglobalswitches-[cs_link_static,cs_link_smart];
  773. end;
  774. 'S' : begin
  775. def_symbol('FPC_LINK_STATIC');
  776. undef_symbol('FPC_LINK_SMART');
  777. undef_symbol('FPC_LINK_DYNAMIC');
  778. initglobalswitches:=initglobalswitches+[cs_link_static];
  779. initglobalswitches:=initglobalswitches-[cs_link_shared,cs_link_smart];
  780. end;
  781. 'X' : begin
  782. def_symbol('FPC_LINK_SMART');
  783. undef_symbol('FPC_LINK_STATIC');
  784. undef_symbol('FPC_LINK_DYNAMIC');
  785. initglobalswitches:=initglobalswitches+[cs_link_smart];
  786. initglobalswitches:=initglobalswitches-[cs_link_shared,cs_link_static];
  787. end;
  788. else
  789. IllegalPara(opt);
  790. end;
  791. end;
  792. { give processor specific options a chance }
  793. else
  794. interpret_proc_specific_options(opt);
  795. end;
  796. end;
  797. '@' : begin
  798. Message(option_no_nested_response_file);
  799. StopOptions;
  800. end;
  801. else
  802. begin
  803. if (length(param_file)<>0) then
  804. Message(option_only_one_source_support);
  805. param_file:=opt;
  806. end;
  807. end;
  808. end;
  809. procedure Toption.Interpret_file(const filename : string);
  810. procedure RemoveSep(var fn:string);
  811. var
  812. i : longint;
  813. begin
  814. i:=0;
  815. while (i<length(fn)) and (fn[i+1] in [',',' ',#9]) do
  816. inc(i);
  817. Delete(fn,1,i);
  818. i:=length(fn);
  819. while (i>0) and (fn[i] in [',',' ',#9]) do
  820. dec(i);
  821. fn:=copy(fn,1,i);
  822. end;
  823. function GetName(var fn:string):string;
  824. var
  825. i : longint;
  826. begin
  827. i:=0;
  828. while (i<length(fn)) and (fn[i+1] in ['a'..'z','A'..'Z','0'..'9','_','-']) do
  829. inc(i);
  830. GetName:=Copy(fn,1,i);
  831. Delete(fn,1,i);
  832. end;
  833. const
  834. maxlevel=16;
  835. var
  836. f : text;
  837. s,
  838. opts : string;
  839. skip : array[0..maxlevel-1] of boolean;
  840. level : longint;
  841. option_read : boolean;
  842. begin
  843. { avoid infinite loop }
  844. Inc(FileLevel);
  845. Option_read:=false;
  846. If FileLevel>MaxLevel then
  847. Message(option_too_many_cfg_files);
  848. { open file }
  849. assign(f,filename);
  850. {$ifdef extdebug}
  851. Comment(V_Info,'trying to open file: '+filename);
  852. {$endif extdebug}
  853. {$I-}
  854. reset(f);
  855. {$I+}
  856. if ioresult<>0 then
  857. begin
  858. Message1(option_unable_open_file,filename);
  859. exit;
  860. end;
  861. fillchar(skip,sizeof(skip),0);
  862. level:=0;
  863. while not eof(f) do
  864. begin
  865. readln(f,opts);
  866. RemoveSep(opts);
  867. if (opts<>'') and (opts[1]<>';') then
  868. begin
  869. if opts[1]='#' then
  870. begin
  871. Delete(opts,1,1);
  872. s:=upper(GetName(opts));
  873. if (s='SECTION') then
  874. begin
  875. RemoveSep(opts);
  876. s:=upper(GetName(opts));
  877. if level=0 then
  878. skip[level]:=not (check_symbol(s) or (s='COMMON'));
  879. end
  880. else
  881. if (s='IFDEF') then
  882. begin
  883. RemoveSep(opts);
  884. if Level>=maxlevel then
  885. begin
  886. Message(option_too_many_ifdef);
  887. stopOptions;
  888. end;
  889. inc(Level);
  890. skip[level]:=(skip[level-1] or (not check_symbol(upper(GetName(opts)))));
  891. end
  892. else
  893. if (s='IFNDEF') then
  894. begin
  895. RemoveSep(opts);
  896. if Level>=maxlevel then
  897. begin
  898. Message(option_too_many_ifdef);
  899. stopOptions;
  900. end;
  901. inc(Level);
  902. skip[level]:=(skip[level-1] or (check_symbol(upper(GetName(opts)))));
  903. end
  904. else
  905. if (s='ELSE') then
  906. skip[level]:=skip[level-1] or (not skip[level])
  907. else
  908. if (s='ENDIF') then
  909. begin
  910. skip[level]:=false;
  911. if Level=0 then
  912. begin
  913. Message(option_too_many_endif);
  914. stopOptions;
  915. end;
  916. dec(level);
  917. end
  918. else
  919. if (not skip[level]) then
  920. begin
  921. if (s='DEFINE') then
  922. begin
  923. RemoveSep(opts);
  924. def_symbol(upper(GetName(opts)));
  925. end
  926. else
  927. if (s='UNDEF') then
  928. begin
  929. RemoveSep(opts);
  930. undef_symbol(upper(GetName(opts)));
  931. end
  932. else
  933. if (s='WRITE') then
  934. begin
  935. Delete(opts,1,1);
  936. WriteLn(opts);
  937. end
  938. else
  939. if (s='INCLUDE') then
  940. begin
  941. Delete(opts,1,1);
  942. Interpret_file(opts);
  943. end;
  944. end;
  945. end
  946. else
  947. begin
  948. if (opts[1]='-') then
  949. begin
  950. if (not skip[level]) then
  951. interpret_option(opts,false);
  952. Option_read:=true;
  953. end
  954. else
  955. Message1(option_illegal_para,opts);
  956. end;
  957. end;
  958. end;
  959. if Level>0 then
  960. Message(option_too_less_endif);
  961. if Not Option_read then
  962. Message1(option_no_option_found,filename);
  963. Close(f);
  964. Dec(FileLevel);
  965. end;
  966. procedure Toption.Interpret_envvar(const envname : string);
  967. var
  968. argstart,
  969. env,
  970. pc : pchar;
  971. arglen : longint;
  972. quote : set of char;
  973. hs : string;
  974. begin
  975. env:=GetEnvPChar(envname);
  976. pc:=env;
  977. if assigned(pc) then
  978. begin
  979. repeat
  980. { skip leading spaces }
  981. while pc^ in [' ',#9,#13] do
  982. inc(pc);
  983. case pc^ of
  984. #0 :
  985. break;
  986. '"' :
  987. begin
  988. quote:=['"'];
  989. inc(pc);
  990. end;
  991. '''' :
  992. begin
  993. quote:=[''''];
  994. inc(pc);
  995. end;
  996. else
  997. quote:=[' ',#9,#13];
  998. end;
  999. { scan until the end of the argument }
  1000. argstart:=pc;
  1001. while (pc^<>#0) and not(pc^ in quote) do
  1002. inc(pc);
  1003. { create argument }
  1004. arglen:=pc-argstart;
  1005. hs[0]:=chr(arglen);
  1006. move(argstart^,hs[1],arglen);
  1007. interpret_option(hs,true);
  1008. { skip quote }
  1009. if pc^ in quote then
  1010. inc(pc);
  1011. until false;
  1012. end
  1013. else
  1014. Message1(option_no_option_found,'(env) '+envname);
  1015. FreeEnvPChar(env);
  1016. end;
  1017. procedure toption.read_parameters;
  1018. var
  1019. opts : string;
  1020. paramindex : longint;
  1021. begin
  1022. paramindex:=0;
  1023. while paramindex<paramcount do
  1024. begin
  1025. inc(paramindex);
  1026. opts:=paramstr(paramindex);
  1027. case opts[1] of
  1028. '@' :
  1029. begin
  1030. Delete(opts,1,1);
  1031. if not firstpass then
  1032. Message1(option_reading_further_from,opts);
  1033. interpret_file(opts);
  1034. end;
  1035. '!' :
  1036. begin
  1037. Delete(opts,1,1);
  1038. if not firstpass then
  1039. Message1(option_reading_further_from,'(env) '+opts);
  1040. interpret_envvar(opts);
  1041. end;
  1042. else
  1043. interpret_option(opts,true);
  1044. end;
  1045. end;
  1046. end;
  1047. procedure toption.parsecmd(cmd:string);
  1048. var
  1049. i,ps : longint;
  1050. opts : string;
  1051. begin
  1052. while (cmd<>'') do
  1053. begin
  1054. while cmd[1]=' ' do
  1055. delete(cmd,1,1);
  1056. i:=pos(' ',cmd);
  1057. if i=0 then
  1058. i:=256;
  1059. opts:=Copy(cmd,1,i-1);
  1060. Delete(cmd,1,i);
  1061. case opts[1] of
  1062. '@' :
  1063. begin
  1064. Delete(opts,1,1);
  1065. if not firstpass then
  1066. Message1(option_reading_further_from,opts);
  1067. interpret_file(opts);
  1068. end;
  1069. '!' :
  1070. begin
  1071. Delete(opts,1,1);
  1072. if not firstpass then
  1073. Message1(option_reading_further_from,'(env) '+opts);
  1074. interpret_envvar(opts);
  1075. end;
  1076. '"' :
  1077. begin
  1078. Delete(opts,1,1);
  1079. ps:=pos('"',cmd);
  1080. if (i<>256) and (ps>0) then
  1081. begin
  1082. opts:=opts + ' '+ copy(cmd,1,ps-1);
  1083. cmd:=copy(cmd,ps+1,255);
  1084. end;
  1085. interpret_option(opts,true);
  1086. end;
  1087. else
  1088. interpret_option(opts,true);
  1089. end;
  1090. end;
  1091. end;
  1092. constructor TOption.Init;
  1093. begin
  1094. DoWriteLogo:=false;
  1095. NoPressEnter:=false;
  1096. FirstPass:=false;
  1097. FileLevel:=0;
  1098. ParaIncludePath.Init;
  1099. ParaObjectPath.Init;
  1100. ParaUnitPath.Init;
  1101. ParaLibraryPath.Init;
  1102. end;
  1103. destructor TOption.Done;
  1104. begin
  1105. ParaIncludePath.Done;
  1106. ParaObjectPath.Done;
  1107. ParaUnitPath.Done;
  1108. ParaLibraryPath.Done;
  1109. end;
  1110. {****************************************************************************
  1111. Callable Routines
  1112. ****************************************************************************}
  1113. procedure read_arguments(cmd:string);
  1114. var
  1115. configpath : pathstr;
  1116. begin
  1117. {$ifdef Delphi}
  1118. option:=new(poption386,Init);
  1119. {$endif Delphi}
  1120. {$ifdef i386}
  1121. option:=new(poption386,Init);
  1122. {$endif}
  1123. {$ifdef m68k}
  1124. option:=new(poption68k,Init);
  1125. {$endif}
  1126. {$ifdef alpha}
  1127. option:=new(poption,Init);
  1128. {$endif}
  1129. {$ifdef powerpc}
  1130. option:=new(poption,Init);
  1131. {$endif}
  1132. { Load messages }
  1133. if (cmd='') and (paramcount=0) then
  1134. Option^.WriteHelpPages;
  1135. disable_configfile:=false;
  1136. { default defines }
  1137. def_symbol(target_info.short_name);
  1138. def_symbol('FPK');
  1139. def_symbol('FPC');
  1140. def_symbol('VER'+version_nr);
  1141. def_symbol('VER'+version_nr+'_'+release_nr);
  1142. def_symbol('VER'+version_nr+'_'+release_nr+'_'+patch_nr);
  1143. {$ifdef newcg}
  1144. def_symbol('WITHNEWCG');
  1145. {$endif}
  1146. { Temporary defines, until things settle down }
  1147. def_symbol('INT64');
  1148. def_symbol('HASRESOURCESTRINGS');
  1149. def_symbol('HASSAVEREGISTERS');
  1150. def_symbol('NEWVMTOFFSET');
  1151. def_symbol('HASINTERNMATH');
  1152. def_symbol('SYSTEMTVARREC');
  1153. def_symbol('INCLUDEOK');
  1154. def_symbol('NEWMM');
  1155. def_symbol('HASWIDECHAR');
  1156. {$ifdef SUPPORT_FIXED}
  1157. def_symbol('HASFIXED');
  1158. {$endif SUPPORT_FIXED}
  1159. {$ifdef cardinalmulfix}
  1160. { for the compiler }
  1161. def_symbol('CARDINALMULFIX');
  1162. { for the RTL }
  1163. def_symbol('CARDINALMULFIXED');
  1164. {$endif cardinalmulfix}
  1165. def_symbol('CORRECTFLDCW');
  1166. def_symbol('ENHANCEDRAISE');
  1167. { some stuff for TP compatibility }
  1168. {$ifdef i386}
  1169. def_symbol('CPU86');
  1170. def_symbol('CPU87');
  1171. {$endif}
  1172. {$ifdef m68k}
  1173. def_symbol('CPU68');
  1174. {$endif}
  1175. { new processor stuff }
  1176. {$ifdef i386}
  1177. def_symbol('CPUI386');
  1178. {$endif}
  1179. {$ifdef m68k}
  1180. def_symbol('CPU68K');
  1181. {$endif}
  1182. {$ifdef ALPHA}
  1183. def_symbol('CPUALPHA');
  1184. {$endif}
  1185. {$ifdef powerpc}
  1186. def_symbol('CPUPOWERPC');
  1187. {$endif}
  1188. { get default messagefile }
  1189. {$ifdef Delphi}
  1190. msgfilename:=dmisc.getenv('PPC_ERROR_FILE');
  1191. {$else Delphi}
  1192. msgfilename:=dos.getenv('PPC_ERROR_FILE');
  1193. {$endif Delphi}
  1194. { default configfile }
  1195. if (cmd<>'') and (cmd[1]='[') then
  1196. begin
  1197. ppccfg:=Copy(cmd,2,pos(']',cmd)-2);
  1198. Delete(cmd,1,pos(']',cmd));
  1199. end
  1200. else
  1201. begin
  1202. {$ifdef i386}
  1203. ppccfg:='ppc386.cfg';
  1204. {$endif i386}
  1205. {$ifdef m68k}
  1206. ppccfg:='ppc.cfg';
  1207. {$endif}
  1208. {$ifdef alpha}
  1209. ppccfg:='ppcalpha.cfg';
  1210. {$endif}
  1211. {$ifdef powerpc}
  1212. ppccfg:='ppcppc.cfg';
  1213. {$endif}
  1214. end;
  1215. { Order to read ppc386.cfg:
  1216. 1 - current dir
  1217. 2 - configpath
  1218. 3 - compiler path }
  1219. {$ifdef Delphi}
  1220. configpath:=FixPath(dmisc.getenv('PPC_CONFIG_PATH'),false);
  1221. {$else Delphi}
  1222. configpath:=FixPath(dos.getenv('PPC_CONFIG_PATH'),false);
  1223. {$endif Delphi}
  1224. {$ifdef linux}
  1225. if configpath='' then
  1226. configpath:='/etc/';
  1227. {$endif}
  1228. if ppccfg<>'' then
  1229. begin
  1230. read_configfile:=true;
  1231. if not FileExists(ppccfg) then
  1232. begin
  1233. {$ifdef linux}
  1234. if (dos.getenv('HOME')<>'') and FileExists(FixPath(dos.getenv('HOME'),false)+'.'+ppccfg) then
  1235. ppccfg:=FixPath(dos.getenv('HOME'),false)+'.'+ppccfg
  1236. else
  1237. {$endif}
  1238. if FileExists(configpath+ppccfg) then
  1239. ppccfg:=configpath+ppccfg
  1240. else
  1241. {$ifndef linux}
  1242. if FileExists(exepath+ppccfg) then
  1243. ppccfg:=exepath+ppccfg
  1244. else
  1245. {$endif}
  1246. read_configfile:=false;
  1247. end;
  1248. end
  1249. else
  1250. read_configfile:=false;
  1251. { Read commandline and configfile }
  1252. target_is_set:=false;
  1253. asm_is_set:=false;
  1254. param_file:='';
  1255. if read_configfile then
  1256. begin
  1257. { read the parameters quick, only -v -T }
  1258. option^.firstpass:=true;
  1259. if cmd<>'' then
  1260. option^.parsecmd(cmd)
  1261. else
  1262. option^.read_parameters;
  1263. option^.firstpass:=false;
  1264. if read_configfile then
  1265. begin
  1266. {$ifdef DEBUG}
  1267. Comment(V_Debug,'read config file: '+ppccfg);
  1268. {$endif DEBUG}
  1269. option^.interpret_file(ppccfg);
  1270. end;
  1271. end;
  1272. if cmd<>'' then
  1273. option^.parsecmd(cmd)
  1274. else
  1275. option^.read_parameters;
  1276. { Stop if errors in options }
  1277. if ErrorCount>0 then
  1278. StopOptions;
  1279. { write logo if set }
  1280. if option^.DoWriteLogo then
  1281. option^.WriteLogo;
  1282. { Check file to compile }
  1283. if param_file='' then
  1284. begin
  1285. Message(option_no_source_found);
  1286. StopOptions;
  1287. end;
  1288. {$ifndef linux}
  1289. param_file:=FixFileName(param_file);
  1290. {$endif}
  1291. fsplit(param_file,inputdir,inputfile,inputextension);
  1292. if inputextension='' then
  1293. begin
  1294. if FileExists(inputdir+inputfile+target_os.sourceext) then
  1295. inputextension:=target_os.sourceext
  1296. else
  1297. if FileExists(inputdir+inputfile+target_os.pasext) then
  1298. inputextension:=target_os.pasext;
  1299. end;
  1300. { Add paths specified with parameters to the searchpaths }
  1301. UnitSearchPath.AddList(Option^.ParaUnitPath,true);
  1302. ObjectSearchPath.AddList(Option^.ParaObjectPath,true);
  1303. IncludeSearchPath.AddList(Option^.ParaIncludePath,true);
  1304. LibrarySearchPath.AddList(Option^.ParaLibraryPath,true);
  1305. { add unit environment and exepath to the unit search path }
  1306. if inputdir<>'' then
  1307. Unitsearchpath.AddPath(inputdir,true);
  1308. if not disable_configfile then
  1309. {$ifdef Delphi}
  1310. UnitSearchPath.AddPath(dmisc.getenv(target_info.unit_env),false);
  1311. {$else}
  1312. UnitSearchPath.AddPath(dos.getenv(target_info.unit_env),false);
  1313. {$endif Delphi}
  1314. {$ifdef linux}
  1315. fpcdir:=FixPath(getenv('FPCDIR'),false);
  1316. if fpcdir='' then
  1317. begin
  1318. if PathExists('/usr/local/lib/fpc/'+version_string) then
  1319. fpcdir:='/usr/local/lib/fpc/'+version_string+'/'
  1320. else
  1321. fpcdir:='/usr/lib/fpc/'+version_string+'/';
  1322. end;
  1323. {$else}
  1324. fpcdir:=FixPath(getenv('FPCDIR'),false);
  1325. if fpcdir='' then
  1326. begin
  1327. fpcdir:=ExePath+'../';
  1328. if not(PathExists(fpcdir+'/units')) and
  1329. not(PathExists(fpcdir+'/rtl')) then
  1330. fpcdir:=fpcdir+'../';
  1331. end;
  1332. {$endif}
  1333. { first try development RTL, else use the default installation path }
  1334. if not disable_configfile then
  1335. begin
  1336. if PathExists(FpcDir+'rtl/'+lower(target_info.short_name)) then
  1337. UnitSearchPath.AddPath(FpcDir+'rtl/'+lower(target_info.short_name),false)
  1338. else
  1339. begin
  1340. UnitSearchPath.AddPath(FpcDir+'units/'+lower(target_info.short_name),false);
  1341. UnitSearchPath.AddPath(FpcDir+'units/'+lower(target_info.short_name)+'/rtl',false);
  1342. end;
  1343. end;
  1344. { Add exepath if the exe is not in the current dir, because that is always searched already }
  1345. if ExePath<>GetCurrentDir then
  1346. UnitSearchPath.AddPath(ExePath,false);
  1347. { Add unit dir to the object and library path }
  1348. objectsearchpath.AddList(unitsearchpath,false);
  1349. librarysearchpath.AddList(unitsearchpath,false);
  1350. { switch assembler if it's binary and we got -a on the cmdline }
  1351. if (cs_asm_leave in initglobalswitches) and
  1352. (target_asm.id in binassem) then
  1353. begin
  1354. Message(option_switch_bin_to_src_assembler);
  1355. set_target_asm(target_info.assemsrc);
  1356. initoutputformat:=target_asm.id;
  1357. end;
  1358. if (target_asm.supported_target <> target_any) and
  1359. (target_asm.supported_target <> target_info.target) then
  1360. begin
  1361. Message2(option_incompatible_asm,target_asm.idtxt,target_os.name);
  1362. { Should we reset to default ??? }
  1363. set_target_asm(target_info.assemsrc);
  1364. Message1(option_asm_forced,target_asm.idtxt);
  1365. initoutputformat:=target_asm.id;
  1366. end;
  1367. { turn off stripping if compiling with debuginfo or profile }
  1368. if (cs_debuginfo in initmoduleswitches) or
  1369. (cs_profile in initmoduleswitches) then
  1370. initglobalswitches:=initglobalswitches-[cs_link_strip];
  1371. { Set defines depending on the target }
  1372. if (target_info.target in [target_i386_GO32V1,target_i386_GO32V2]) then
  1373. def_symbol('DPMI'); { MSDOS is not defined in BP when target is DPMI }
  1374. MaybeLoadMessageFile;
  1375. dispose(option,Done);
  1376. Option:=nil;
  1377. end;
  1378. end.
  1379. {
  1380. $Log$
  1381. Revision 1.69 2000-05-23 21:28:22 pierre
  1382. + check of compatibility between selected assembler
  1383. output and target OS
  1384. Revision 1.68 2000/05/16 20:19:06 pierre
  1385. + -CR option to enable check for object virtual method
  1386. Revision 1.67 2000/05/10 13:40:19 peter
  1387. * -Se<x> option extended to increase errorcount for
  1388. warning,notes or hints
  1389. Revision 1.66 2000/04/24 13:34:29 peter
  1390. * added enhancedraise define
  1391. Revision 1.65 2000/04/10 11:36:19 pierre
  1392. * get -g-l to work
  1393. Revision 1.64 2000/04/07 14:56:18 peter
  1394. * correctfldcw define added
  1395. Revision 1.63 2000/04/05 21:57:34 pierre
  1396. * no unitdir automatically added if -n option present
  1397. Revision 1.62 2000/03/13 20:06:59 michael
  1398. + Added switch to swicth on assertions.
  1399. Revision 1.61 2000/02/15 14:36:45 florian
  1400. * disable FIXED data type per default
  1401. Revision 1.60 2000/02/10 11:45:48 peter
  1402. * addpath fixed with list of paths when inserting at the beginning
  1403. * if exepath=currentdir then it's not inserted in path list
  1404. * searchpaths in ppc386.cfg are now added at the beginning of the
  1405. list instead of at the end. (commandline is not changed)
  1406. * check paths before inserting in list
  1407. Revision 1.59 2000/02/09 13:22:54 peter
  1408. * log truncated
  1409. Revision 1.58 2000/02/09 10:35:48 peter
  1410. * -Xt option to link staticly against c libs
  1411. Revision 1.57 2000/02/06 17:20:52 peter
  1412. * -gl switch for auto lineinfo including
  1413. Revision 1.56 2000/01/31 15:55:42 peter
  1414. * fixed default unit location for linux when fpcdir was not set
  1415. Revision 1.55 2000/01/23 18:20:50 sg
  1416. * Fixed typo in line 1375 ("fpidr" instead of "fpcdir")
  1417. Revision 1.54 2000/01/23 16:36:37 peter
  1418. * better auto RTL dir detection
  1419. Revision 1.53 2000/01/20 10:36:44 daniel
  1420. * also support ; comments in cfg file
  1421. Revision 1.52 2000/01/17 22:50:28 peter
  1422. * fixed interpret_envvar whcih crashed when the envvar was not set
  1423. * also warn if the envvar is empty (=not set)
  1424. Revision 1.51 2000/01/14 15:33:15 pierre
  1425. + parsecmd supports "filename with spaces" for IDE
  1426. Revision 1.50 2000/01/14 14:33:54 pierre
  1427. + some warnings for wrong lines inside config files
  1428. Revision 1.49 2000/01/10 11:14:19 peter
  1429. * fixed memory leak with options, you must use StopOptions instead of
  1430. Stop
  1431. * fixed memory leak with forward resolving, make_ref is now false
  1432. Revision 1.48 2000/01/07 22:22:02 marco
  1433. * Added $target support for -FD
  1434. Revision 1.47 2000/01/07 01:14:27 peter
  1435. * updated copyright to 2000
  1436. Revision 1.46 2000/01/06 15:48:59 peter
  1437. * wildcard support for directory adding, this allows the use of units/*
  1438. in ppc386.cfg
  1439. Revision 1.45 1999/12/20 23:23:30 pierre
  1440. + $description $version
  1441. Revision 1.44 1999/12/20 21:42:36 pierre
  1442. + dllversion global variable
  1443. * FPC_USE_CPREFIX code removed, not necessary anymore
  1444. as we use .edata direct writing by default now.
  1445. Revision 1.43 1999/12/18 14:55:21 florian
  1446. * very basic widestring support
  1447. Revision 1.42 1999/12/11 18:53:31 jonas
  1448. * fixed type conversions of results of operations with cardinals
  1449. (between -dcardinalmulfix)
  1450. Revision 1.41 1999/12/10 10:03:54 peter
  1451. * fixed parameter orderning
  1452. Revision 1.40 1999/12/08 10:40:01 pierre
  1453. + allow use of unit var in exports of DLL for win32
  1454. by using direct export writing by default instead of use of DEFFILE
  1455. that does not allow assembler labels that do not
  1456. start with an underscore.
  1457. Use -WD to force use of Deffile for Win32 DLL
  1458. Revision 1.39 1999/12/06 18:21:03 peter
  1459. * support !ENVVAR for long commandlines
  1460. * win32/go32v2 write short pathnames to link.res so c:\Program Files\ is
  1461. finally supported as installdir.
  1462. }