options.pas 47 KB

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