options.pas 48 KB

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