options.pas 47 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528
  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. 'a' : initlocalswitches:=InitLocalswitches+[cs_do_assertion];
  649. 'c' : initmoduleswitches:=initmoduleswitches+[cs_support_c_operators];
  650. 'd' : initmodeswitches:=delphimodeswitches;
  651. 'e' : begin
  652. val(copy(more,j+1,length(more)-j),l,code);
  653. if (code<>0) then
  654. SetMaxErrorCount(1)
  655. else
  656. begin
  657. SetMaxErrorCount(l);
  658. break;
  659. end;
  660. end;
  661. 'g' : initmoduleswitches:=initmoduleswitches+[cs_support_goto];
  662. 'h' : initlocalswitches:=initlocalswitches+[cs_ansistrings];
  663. 'i' : initmoduleswitches:=initmoduleswitches+[cs_support_inline];
  664. 'm' : initmoduleswitches:=initmoduleswitches+[cs_support_macro];
  665. 'o': initmodeswitches:=tpmodeswitches;
  666. 'p' : initmodeswitches:=gpcmodeswitches;
  667. 's' : initglobalswitches:=initglobalswitches+[cs_constructor_name];
  668. 't' : initmoduleswitches:=initmoduleswitches+[cs_static_keyword];
  669. 'v' : Message1(option_obsolete_switch,'-Sv');
  670. else
  671. IllegalPara(opt);
  672. end;
  673. end;
  674. 'T' : begin
  675. more:=Upper(More);
  676. if not target_is_set then
  677. begin
  678. { remove old target define }
  679. undef_symbol(target_info.short_name);
  680. { load new target }
  681. if not(set_string_target(More)) then
  682. IllegalPara(opt);
  683. { set new define }
  684. def_symbol(target_info.short_name);
  685. if not asm_is_set then
  686. initoutputformat:=target_asm.id;
  687. target_is_set:=true;
  688. end
  689. else
  690. if More<>target_info.short_name then
  691. Message1(option_target_is_already_set,target_info.short_name);
  692. end;
  693. 'u' : undef_symbol(upper(More));
  694. 'U' : begin
  695. for j:=1 to length(more) do
  696. case more[j] of
  697. {$ifdef UNITALIASES}
  698. 'a' : begin
  699. AddUnitAlias(Copy(More,j+1,255));
  700. break;
  701. end;
  702. {$endif UNITALIASES}
  703. 'n' : initglobalswitches:=initglobalswitches-[cs_check_unit_name];
  704. 'p' : begin
  705. Message2(option_obsolete_switch_use_new,'-Up','-Fu');
  706. break;
  707. end;
  708. 's' : initmoduleswitches:=initmoduleswitches+[cs_compilesystem];
  709. else
  710. IllegalPara(opt);
  711. end;
  712. end;
  713. 'v' : if not setverbosity(More) then
  714. IllegalPara(opt);
  715. 'W' : begin
  716. for j:=1 to length(More) do
  717. case More[j] of
  718. 'B': {bind_win32_dll:=true}
  719. begin
  720. { -WB200000 means set prefered base address
  721. to $200000, but does not change relocsection boolean
  722. this way we can create both relocatble and
  723. non relocatable DLL at a specific base address PM }
  724. if (length(More)>j) then
  725. begin
  726. if DLLImageBase=nil then
  727. DLLImageBase:=StringDup(Copy(More,j+1,255));
  728. end
  729. else
  730. begin
  731. RelocSection:=true;
  732. RelocSectionSetExplicitly:=true;
  733. end;
  734. break;
  735. end;
  736. 'C': apptype:=at_cui;
  737. 'D': ForceDeffileForExport:=true;
  738. 'G': apptype:=at_gui;
  739. 'N': begin
  740. RelocSection:=false;
  741. RelocSectionSetExplicitly:=true;
  742. end;
  743. 'R': begin
  744. RelocSection:=true;
  745. RelocSectionSetExplicitly:=true;
  746. end;
  747. else
  748. IllegalPara(opt);
  749. end;
  750. end;
  751. 'X' : begin
  752. for j:=1 to length(More) do
  753. case More[j] of
  754. 'c' : initglobalswitches:=initglobalswitches+[cs_link_toc];
  755. 's' : initglobalswitches:=initglobalswitches+[cs_link_strip];
  756. 't' : initglobalswitches:=initglobalswitches+[cs_link_staticflag];
  757. 'D' : begin
  758. def_symbol('FPC_LINK_DYNAMIC');
  759. undef_symbol('FPC_LINK_SMART');
  760. undef_symbol('FPC_LINK_STATIC');
  761. initglobalswitches:=initglobalswitches+[cs_link_shared];
  762. initglobalswitches:=initglobalswitches-[cs_link_static,cs_link_smart];
  763. end;
  764. 'S' : begin
  765. def_symbol('FPC_LINK_STATIC');
  766. undef_symbol('FPC_LINK_SMART');
  767. undef_symbol('FPC_LINK_DYNAMIC');
  768. initglobalswitches:=initglobalswitches+[cs_link_static];
  769. initglobalswitches:=initglobalswitches-[cs_link_shared,cs_link_smart];
  770. end;
  771. 'X' : begin
  772. def_symbol('FPC_LINK_SMART');
  773. undef_symbol('FPC_LINK_STATIC');
  774. undef_symbol('FPC_LINK_DYNAMIC');
  775. initglobalswitches:=initglobalswitches+[cs_link_smart];
  776. initglobalswitches:=initglobalswitches-[cs_link_shared,cs_link_static];
  777. end;
  778. else
  779. IllegalPara(opt);
  780. end;
  781. end;
  782. { give processor specific options a chance }
  783. else
  784. interpret_proc_specific_options(opt);
  785. end;
  786. end;
  787. '@' : begin
  788. Message(option_no_nested_response_file);
  789. StopOptions;
  790. end;
  791. else
  792. begin
  793. if (length(param_file)<>0) then
  794. Message(option_only_one_source_support);
  795. param_file:=opt;
  796. end;
  797. end;
  798. end;
  799. procedure Toption.Interpret_file(const filename : string);
  800. procedure RemoveSep(var fn:string);
  801. var
  802. i : longint;
  803. begin
  804. i:=0;
  805. while (i<length(fn)) and (fn[i+1] in [',',' ',#9]) do
  806. inc(i);
  807. Delete(fn,1,i);
  808. i:=length(fn);
  809. while (i>0) and (fn[i] in [',',' ',#9]) do
  810. dec(i);
  811. fn:=copy(fn,1,i);
  812. end;
  813. function GetName(var fn:string):string;
  814. var
  815. i : longint;
  816. begin
  817. i:=0;
  818. while (i<length(fn)) and (fn[i+1] in ['a'..'z','A'..'Z','0'..'9','_','-']) do
  819. inc(i);
  820. GetName:=Copy(fn,1,i);
  821. Delete(fn,1,i);
  822. end;
  823. const
  824. maxlevel=16;
  825. var
  826. f : text;
  827. s,
  828. opts : string;
  829. skip : array[0..maxlevel-1] of boolean;
  830. level : longint;
  831. option_read : boolean;
  832. begin
  833. { avoid infinite loop }
  834. Inc(FileLevel);
  835. Option_read:=false;
  836. If FileLevel>MaxLevel then
  837. Message(option_too_many_cfg_files);
  838. { open file }
  839. assign(f,filename);
  840. {$ifdef extdebug}
  841. Comment(V_Info,'trying to open file: '+filename);
  842. {$endif extdebug}
  843. {$I-}
  844. reset(f);
  845. {$I+}
  846. if ioresult<>0 then
  847. begin
  848. Message1(option_unable_open_file,filename);
  849. exit;
  850. end;
  851. fillchar(skip,sizeof(skip),0);
  852. level:=0;
  853. while not eof(f) do
  854. begin
  855. readln(f,opts);
  856. RemoveSep(opts);
  857. if (opts<>'') and (opts[1]<>';') then
  858. begin
  859. if opts[1]='#' then
  860. begin
  861. Delete(opts,1,1);
  862. s:=upper(GetName(opts));
  863. if (s='SECTION') then
  864. begin
  865. RemoveSep(opts);
  866. s:=upper(GetName(opts));
  867. if level=0 then
  868. skip[level]:=not (check_symbol(s) or (s='COMMON'));
  869. end
  870. else
  871. if (s='IFDEF') then
  872. begin
  873. RemoveSep(opts);
  874. if Level>=maxlevel then
  875. begin
  876. Message(option_too_many_ifdef);
  877. stopOptions;
  878. end;
  879. inc(Level);
  880. skip[level]:=(skip[level-1] or (not check_symbol(upper(GetName(opts)))));
  881. end
  882. else
  883. if (s='IFNDEF') then
  884. begin
  885. RemoveSep(opts);
  886. if Level>=maxlevel then
  887. begin
  888. Message(option_too_many_ifdef);
  889. stopOptions;
  890. end;
  891. inc(Level);
  892. skip[level]:=(skip[level-1] or (check_symbol(upper(GetName(opts)))));
  893. end
  894. else
  895. if (s='ELSE') then
  896. skip[level]:=skip[level-1] or (not skip[level])
  897. else
  898. if (s='ENDIF') then
  899. begin
  900. skip[level]:=false;
  901. if Level=0 then
  902. begin
  903. Message(option_too_many_endif);
  904. stopOptions;
  905. end;
  906. dec(level);
  907. end
  908. else
  909. if (not skip[level]) then
  910. begin
  911. if (s='DEFINE') then
  912. begin
  913. RemoveSep(opts);
  914. def_symbol(upper(GetName(opts)));
  915. end
  916. else
  917. if (s='UNDEF') then
  918. begin
  919. RemoveSep(opts);
  920. undef_symbol(upper(GetName(opts)));
  921. end
  922. else
  923. if (s='WRITE') then
  924. begin
  925. Delete(opts,1,1);
  926. WriteLn(opts);
  927. end
  928. else
  929. if (s='INCLUDE') then
  930. begin
  931. Delete(opts,1,1);
  932. Interpret_file(opts);
  933. end;
  934. end;
  935. end
  936. else
  937. begin
  938. if (opts[1]='-') then
  939. begin
  940. if (not skip[level]) then
  941. interpret_option(opts,false);
  942. Option_read:=true;
  943. end
  944. else
  945. Message1(option_illegal_para,opts);
  946. end;
  947. end;
  948. end;
  949. if Level>0 then
  950. Message(option_too_less_endif);
  951. if Not Option_read then
  952. Message1(option_no_option_found,filename);
  953. Close(f);
  954. Dec(FileLevel);
  955. end;
  956. procedure Toption.Interpret_envvar(const envname : string);
  957. var
  958. argstart,
  959. env,
  960. pc : pchar;
  961. arglen : longint;
  962. quote : set of char;
  963. hs : string;
  964. begin
  965. env:=GetEnvPChar(envname);
  966. pc:=env;
  967. if assigned(pc) then
  968. begin
  969. repeat
  970. { skip leading spaces }
  971. while pc^ in [' ',#9,#13] do
  972. inc(pc);
  973. case pc^ of
  974. #0 :
  975. break;
  976. '"' :
  977. begin
  978. quote:=['"'];
  979. inc(pc);
  980. end;
  981. '''' :
  982. begin
  983. quote:=[''''];
  984. inc(pc);
  985. end;
  986. else
  987. quote:=[' ',#9,#13];
  988. end;
  989. { scan until the end of the argument }
  990. argstart:=pc;
  991. while (pc^<>#0) and not(pc^ in quote) do
  992. inc(pc);
  993. { create argument }
  994. arglen:=pc-argstart;
  995. hs[0]:=chr(arglen);
  996. move(argstart^,hs[1],arglen);
  997. interpret_option(hs,true);
  998. { skip quote }
  999. if pc^ in quote then
  1000. inc(pc);
  1001. until false;
  1002. end
  1003. else
  1004. Message1(option_no_option_found,'(env) '+envname);
  1005. FreeEnvPChar(env);
  1006. end;
  1007. procedure toption.read_parameters;
  1008. var
  1009. opts : string;
  1010. paramindex : longint;
  1011. begin
  1012. paramindex:=0;
  1013. while paramindex<paramcount do
  1014. begin
  1015. inc(paramindex);
  1016. opts:=paramstr(paramindex);
  1017. case opts[1] of
  1018. '@' :
  1019. begin
  1020. Delete(opts,1,1);
  1021. if not firstpass then
  1022. Message1(option_reading_further_from,opts);
  1023. interpret_file(opts);
  1024. end;
  1025. '!' :
  1026. begin
  1027. Delete(opts,1,1);
  1028. if not firstpass then
  1029. Message1(option_reading_further_from,'(env) '+opts);
  1030. interpret_envvar(opts);
  1031. end;
  1032. else
  1033. interpret_option(opts,true);
  1034. end;
  1035. end;
  1036. end;
  1037. procedure toption.parsecmd(cmd:string);
  1038. var
  1039. i,ps : longint;
  1040. opts : string;
  1041. begin
  1042. while (cmd<>'') do
  1043. begin
  1044. while cmd[1]=' ' do
  1045. delete(cmd,1,1);
  1046. i:=pos(' ',cmd);
  1047. if i=0 then
  1048. i:=256;
  1049. opts:=Copy(cmd,1,i-1);
  1050. Delete(cmd,1,i);
  1051. case opts[1] of
  1052. '@' :
  1053. begin
  1054. Delete(opts,1,1);
  1055. if not firstpass then
  1056. Message1(option_reading_further_from,opts);
  1057. interpret_file(opts);
  1058. end;
  1059. '!' :
  1060. begin
  1061. Delete(opts,1,1);
  1062. if not firstpass then
  1063. Message1(option_reading_further_from,'(env) '+opts);
  1064. interpret_envvar(opts);
  1065. end;
  1066. '"' :
  1067. begin
  1068. Delete(opts,1,1);
  1069. ps:=pos('"',cmd);
  1070. if (i<>256) and (ps>0) then
  1071. begin
  1072. opts:=opts + ' '+ copy(cmd,1,ps-1);
  1073. cmd:=copy(cmd,ps+1,255);
  1074. end;
  1075. interpret_option(opts,true);
  1076. end;
  1077. else
  1078. interpret_option(opts,true);
  1079. end;
  1080. end;
  1081. end;
  1082. constructor TOption.Init;
  1083. begin
  1084. DoWriteLogo:=false;
  1085. NoPressEnter:=false;
  1086. FirstPass:=false;
  1087. FileLevel:=0;
  1088. ParaIncludePath.Init;
  1089. ParaObjectPath.Init;
  1090. ParaUnitPath.Init;
  1091. ParaLibraryPath.Init;
  1092. end;
  1093. destructor TOption.Done;
  1094. begin
  1095. ParaIncludePath.Done;
  1096. ParaObjectPath.Done;
  1097. ParaUnitPath.Done;
  1098. ParaLibraryPath.Done;
  1099. end;
  1100. {****************************************************************************
  1101. Callable Routines
  1102. ****************************************************************************}
  1103. procedure read_arguments(cmd:string);
  1104. var
  1105. configpath : pathstr;
  1106. begin
  1107. {$ifdef Delphi}
  1108. option:=new(poption386,Init);
  1109. {$endif Delphi}
  1110. {$ifdef i386}
  1111. option:=new(poption386,Init);
  1112. {$endif}
  1113. {$ifdef m68k}
  1114. option:=new(poption68k,Init);
  1115. {$endif}
  1116. {$ifdef alpha}
  1117. option:=new(poption,Init);
  1118. {$endif}
  1119. {$ifdef powerpc}
  1120. option:=new(poption,Init);
  1121. {$endif}
  1122. { Load messages }
  1123. if (cmd='') and (paramcount=0) then
  1124. Option^.WriteHelpPages;
  1125. { default defines }
  1126. def_symbol(target_info.short_name);
  1127. def_symbol('FPK');
  1128. def_symbol('FPC');
  1129. def_symbol('VER'+version_nr);
  1130. def_symbol('VER'+version_nr+'_'+release_nr);
  1131. def_symbol('VER'+version_nr+'_'+release_nr+'_'+patch_nr);
  1132. {$ifdef newcg}
  1133. def_symbol('WITHNEWCG');
  1134. {$endif}
  1135. { Temporary defines, until things settle down }
  1136. def_symbol('INT64');
  1137. def_symbol('HASRESOURCESTRINGS');
  1138. def_symbol('HASSAVEREGISTERS');
  1139. def_symbol('NEWVMTOFFSET');
  1140. def_symbol('HASINTERNMATH');
  1141. def_symbol('SYSTEMTVARREC');
  1142. def_symbol('INCLUDEOK');
  1143. def_symbol('NEWMM');
  1144. def_symbol('HASWIDECHAR');
  1145. {$ifdef SUPPORT_FIXED}
  1146. def_symbol('HASFIXED');
  1147. {$endif SUPPORT_FIXED}
  1148. {$ifdef cardinalmulfix}
  1149. { for the compiler }
  1150. def_symbol('CARDINALMULFIX');
  1151. { for the RTL }
  1152. def_symbol('CARDINALMULFIXED');
  1153. {$endif cardinalmulfix}
  1154. { some stuff for TP compatibility }
  1155. {$ifdef i386}
  1156. def_symbol('CPU86');
  1157. def_symbol('CPU87');
  1158. {$endif}
  1159. {$ifdef m68k}
  1160. def_symbol('CPU68');
  1161. {$endif}
  1162. { new processor stuff }
  1163. {$ifdef i386}
  1164. def_symbol('CPUI386');
  1165. {$endif}
  1166. {$ifdef m68k}
  1167. def_symbol('CPU68K');
  1168. {$endif}
  1169. {$ifdef ALPHA}
  1170. def_symbol('CPUALPHA');
  1171. {$endif}
  1172. {$ifdef powerpc}
  1173. def_symbol('CPUPOWERPC');
  1174. {$endif}
  1175. { get default messagefile }
  1176. {$ifdef Delphi}
  1177. msgfilename:=dmisc.getenv('PPC_ERROR_FILE');
  1178. {$else Delphi}
  1179. msgfilename:=dos.getenv('PPC_ERROR_FILE');
  1180. {$endif Delphi}
  1181. { default configfile }
  1182. if (cmd<>'') and (cmd[1]='[') then
  1183. begin
  1184. ppccfg:=Copy(cmd,2,pos(']',cmd)-2);
  1185. Delete(cmd,1,pos(']',cmd));
  1186. end
  1187. else
  1188. begin
  1189. {$ifdef i386}
  1190. ppccfg:='ppc386.cfg';
  1191. {$endif i386}
  1192. {$ifdef m68k}
  1193. ppccfg:='ppc.cfg';
  1194. {$endif}
  1195. {$ifdef alpha}
  1196. ppccfg:='ppcalpha.cfg';
  1197. {$endif}
  1198. {$ifdef powerpc}
  1199. ppccfg:='ppcppc.cfg';
  1200. {$endif}
  1201. end;
  1202. { Order to read ppc386.cfg:
  1203. 1 - current dir
  1204. 2 - configpath
  1205. 3 - compiler path }
  1206. {$ifdef Delphi}
  1207. configpath:=FixPath(dmisc.getenv('PPC_CONFIG_PATH'),false);
  1208. {$else Delphi}
  1209. configpath:=FixPath(dos.getenv('PPC_CONFIG_PATH'),false);
  1210. {$endif Delphi}
  1211. {$ifdef linux}
  1212. if configpath='' then
  1213. configpath:='/etc/';
  1214. {$endif}
  1215. if ppccfg<>'' then
  1216. begin
  1217. read_configfile:=true;
  1218. if not FileExists(ppccfg) then
  1219. begin
  1220. {$ifdef linux}
  1221. if (dos.getenv('HOME')<>'') and FileExists(FixPath(dos.getenv('HOME'),false)+'.'+ppccfg) then
  1222. ppccfg:=FixPath(dos.getenv('HOME'),false)+'.'+ppccfg
  1223. else
  1224. {$endif}
  1225. if FileExists(configpath+ppccfg) then
  1226. ppccfg:=configpath+ppccfg
  1227. else
  1228. {$ifndef linux}
  1229. if FileExists(exepath+ppccfg) then
  1230. ppccfg:=exepath+ppccfg
  1231. else
  1232. {$endif}
  1233. read_configfile:=false;
  1234. end;
  1235. end
  1236. else
  1237. read_configfile:=false;
  1238. { Read commandline and configfile }
  1239. target_is_set:=false;
  1240. asm_is_set:=false;
  1241. param_file:='';
  1242. if read_configfile then
  1243. begin
  1244. { read the parameters quick, only -v -T }
  1245. option^.firstpass:=true;
  1246. if cmd<>'' then
  1247. option^.parsecmd(cmd)
  1248. else
  1249. option^.read_parameters;
  1250. option^.firstpass:=false;
  1251. if read_configfile then
  1252. begin
  1253. {$ifdef EXTDEBUG}
  1254. Comment(V_Debug,'read config file: '+ppccfg);
  1255. {$endif EXTDEBUG}
  1256. option^.interpret_file(ppccfg);
  1257. end;
  1258. end;
  1259. if cmd<>'' then
  1260. option^.parsecmd(cmd)
  1261. else
  1262. option^.read_parameters;
  1263. { Stop if errors in options }
  1264. if ErrorCount>0 then
  1265. StopOptions;
  1266. { write logo if set }
  1267. if option^.DoWriteLogo then
  1268. option^.WriteLogo;
  1269. { Check file to compile }
  1270. if param_file='' then
  1271. begin
  1272. Message(option_no_source_found);
  1273. StopOptions;
  1274. end;
  1275. {$ifndef linux}
  1276. param_file:=FixFileName(param_file);
  1277. {$endif}
  1278. fsplit(param_file,inputdir,inputfile,inputextension);
  1279. if inputextension='' then
  1280. begin
  1281. if FileExists(inputdir+inputfile+target_os.sourceext) then
  1282. inputextension:=target_os.sourceext
  1283. else
  1284. if FileExists(inputdir+inputfile+target_os.pasext) then
  1285. inputextension:=target_os.pasext;
  1286. end;
  1287. { Add paths specified with parameters to the searchpaths }
  1288. UnitSearchPath.AddList(Option^.ParaUnitPath,true);
  1289. ObjectSearchPath.AddList(Option^.ParaObjectPath,true);
  1290. IncludeSearchPath.AddList(Option^.ParaIncludePath,true);
  1291. LibrarySearchPath.AddList(Option^.ParaLibraryPath,true);
  1292. { add unit environment and exepath to the unit search path }
  1293. if inputdir<>'' then
  1294. Unitsearchpath.AddPath(inputdir,true);
  1295. {$ifdef Delphi}
  1296. UnitSearchPath.AddPath(dmisc.getenv(target_info.unit_env),false);
  1297. {$else}
  1298. UnitSearchPath.AddPath(dos.getenv(target_info.unit_env),false);
  1299. {$endif Delphi}
  1300. {$ifdef linux}
  1301. fpcdir:=FixPath(getenv('FPCDIR'),false);
  1302. if fpcdir='' then
  1303. begin
  1304. if PathExists('/usr/local/lib/fpc/'+version_string) then
  1305. fpcdir:='/usr/local/lib/fpc/'+version_string+'/'
  1306. else
  1307. fpcdir:='/usr/lib/fpc/'+version_string+'/';
  1308. end;
  1309. {$else}
  1310. fpcdir:=FixPath(getenv('FPCDIR'),false);
  1311. if fpcdir='' then
  1312. begin
  1313. fpcdir:=ExePath+'../';
  1314. if not(PathExists(fpcdir+'/units')) and
  1315. not(PathExists(fpcdir+'/rtl')) then
  1316. fpcdir:=fpcdir+'../';
  1317. end;
  1318. {$endif}
  1319. { first try development RTL, else use the default installation path }
  1320. if PathExists(FpcDir+'rtl/'+lower(target_info.short_name)) then
  1321. UnitSearchPath.AddPath(FpcDir+'rtl/'+lower(target_info.short_name),false)
  1322. else
  1323. begin
  1324. UnitSearchPath.AddPath(FpcDir+'units/'+lower(target_info.short_name),false);
  1325. UnitSearchPath.AddPath(FpcDir+'units/'+lower(target_info.short_name)+'/rtl',false);
  1326. end;
  1327. { Add exepath if the exe is not in the current dir, because that is always searched already }
  1328. if ExePath<>GetCurrentDir then
  1329. UnitSearchPath.AddPath(ExePath,false);
  1330. { Add unit dir to the object and library path }
  1331. objectsearchpath.AddList(unitsearchpath,false);
  1332. librarysearchpath.AddList(unitsearchpath,false);
  1333. { switch assembler if it's binary and we got -a on the cmdline }
  1334. if (cs_asm_leave in initglobalswitches) and
  1335. (target_asm.id in binassem) then
  1336. begin
  1337. Message(option_switch_bin_to_src_assembler);
  1338. set_target_asm(target_info.assemsrc);
  1339. initoutputformat:=target_asm.id;
  1340. end;
  1341. { turn off stripping if compiling with debuginfo or profile }
  1342. if (cs_debuginfo in initmoduleswitches) or
  1343. (cs_profile in initmoduleswitches) then
  1344. initglobalswitches:=initglobalswitches-[cs_link_strip];
  1345. { Set defines depending on the target }
  1346. if (target_info.target in [target_i386_GO32V1,target_i386_GO32V2]) then
  1347. def_symbol('DPMI'); { MSDOS is not defined in BP when target is DPMI }
  1348. MaybeLoadMessageFile;
  1349. dispose(option,Done);
  1350. Option:=nil;
  1351. end;
  1352. end.
  1353. {
  1354. $Log$
  1355. Revision 1.62 2000-03-13 20:06:59 michael
  1356. + Added switch to swicth on assertions.
  1357. Revision 1.61 2000/02/15 14:36:45 florian
  1358. * disable FIXED data type per default
  1359. Revision 1.60 2000/02/10 11:45:48 peter
  1360. * addpath fixed with list of paths when inserting at the beginning
  1361. * if exepath=currentdir then it's not inserted in path list
  1362. * searchpaths in ppc386.cfg are now added at the beginning of the
  1363. list instead of at the end. (commandline is not changed)
  1364. * check paths before inserting in list
  1365. Revision 1.59 2000/02/09 13:22:54 peter
  1366. * log truncated
  1367. Revision 1.58 2000/02/09 10:35:48 peter
  1368. * -Xt option to link staticly against c libs
  1369. Revision 1.57 2000/02/06 17:20:52 peter
  1370. * -gl switch for auto lineinfo including
  1371. Revision 1.56 2000/01/31 15:55:42 peter
  1372. * fixed default unit location for linux when fpcdir was not set
  1373. Revision 1.55 2000/01/23 18:20:50 sg
  1374. * Fixed typo in line 1375 ("fpidr" instead of "fpcdir")
  1375. Revision 1.54 2000/01/23 16:36:37 peter
  1376. * better auto RTL dir detection
  1377. Revision 1.53 2000/01/20 10:36:44 daniel
  1378. * also support ; comments in cfg file
  1379. Revision 1.52 2000/01/17 22:50:28 peter
  1380. * fixed interpret_envvar whcih crashed when the envvar was not set
  1381. * also warn if the envvar is empty (=not set)
  1382. Revision 1.51 2000/01/14 15:33:15 pierre
  1383. + parsecmd supports "filename with spaces" for IDE
  1384. Revision 1.50 2000/01/14 14:33:54 pierre
  1385. + some warnings for wrong lines inside config files
  1386. Revision 1.49 2000/01/10 11:14:19 peter
  1387. * fixed memory leak with options, you must use StopOptions instead of
  1388. Stop
  1389. * fixed memory leak with forward resolving, make_ref is now false
  1390. Revision 1.48 2000/01/07 22:22:02 marco
  1391. * Added $target support for -FD
  1392. Revision 1.47 2000/01/07 01:14:27 peter
  1393. * updated copyright to 2000
  1394. Revision 1.46 2000/01/06 15:48:59 peter
  1395. * wildcard support for directory adding, this allows the use of units/*
  1396. in ppc386.cfg
  1397. Revision 1.45 1999/12/20 23:23:30 pierre
  1398. + $description $version
  1399. Revision 1.44 1999/12/20 21:42:36 pierre
  1400. + dllversion global variable
  1401. * FPC_USE_CPREFIX code removed, not necessary anymore
  1402. as we use .edata direct writing by default now.
  1403. Revision 1.43 1999/12/18 14:55:21 florian
  1404. * very basic widestring support
  1405. Revision 1.42 1999/12/11 18:53:31 jonas
  1406. * fixed type conversions of results of operations with cardinals
  1407. (between -dcardinalmulfix)
  1408. Revision 1.41 1999/12/10 10:03:54 peter
  1409. * fixed parameter orderning
  1410. Revision 1.40 1999/12/08 10:40:01 pierre
  1411. + allow use of unit var in exports of DLL for win32
  1412. by using direct export writing by default instead of use of DEFFILE
  1413. that does not allow assembler labels that do not
  1414. start with an underscore.
  1415. Use -WD to force use of Deffile for Win32 DLL
  1416. Revision 1.39 1999/12/06 18:21:03 peter
  1417. * support !ENVVAR for long commandlines
  1418. * win32/go32v2 write short pathnames to link.res so c:\Program Files\ is
  1419. finally supported as installdir.
  1420. }