options.pas 49 KB

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