options.pas 68 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329
  1. {
  2. $Id$
  3. Copyright (c) 1998-2002 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. {$i fpcdefs.inc}
  20. interface
  21. uses
  22. globtype,globals,verbose,systems,cpuinfo;
  23. type
  24. TOption=class
  25. FirstPass,
  26. NoPressEnter,
  27. DoWriteLogo : boolean;
  28. FileLevel : longint;
  29. QuickInfo : string;
  30. ParaIncludePath,
  31. ParaUnitPath,
  32. ParaObjectPath,
  33. ParaLibraryPath : TSearchPathList;
  34. ParaAlignment : TAlignmentInfo;
  35. Constructor Create;
  36. Destructor Destroy;override;
  37. procedure WriteLogo;
  38. procedure WriteInfo;
  39. procedure WriteHelpPages;
  40. procedure WriteQuickInfo;
  41. procedure IllegalPara(const opt:string);
  42. function Unsetbool(var Opts:string; Pos: Longint):boolean;
  43. procedure interpret_proc_specific_options(const opt:string);virtual;
  44. procedure interpret_option(const opt :string;ispara:boolean);
  45. procedure Interpret_envvar(const envname : string);
  46. procedure Interpret_file(const filename : string);
  47. procedure Read_Parameters;
  48. procedure parsecmd(cmd:string);
  49. procedure TargetDefines(def:boolean);
  50. end;
  51. TOptionClass=class of toption;
  52. var
  53. coption : TOptionClass;
  54. procedure read_arguments(cmd:string);
  55. implementation
  56. uses
  57. widestr,
  58. {$ifdef Delphi}
  59. dmisc,
  60. {$else Delphi}
  61. dos,
  62. {$endif Delphi}
  63. version,
  64. cutils,cmsgs
  65. {$ifdef BrowserLog}
  66. ,browlog
  67. {$endif BrowserLog}
  68. ;
  69. const
  70. page_size = 24;
  71. var
  72. option : toption;
  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. ppcaltcfg,
  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.insert(upper(s));
  89. Message1(option_defining_symbol,s);
  90. end;
  91. procedure undef_symbol(const s : string);
  92. begin
  93. if s='' then
  94. exit;
  95. InitDefines.Remove(s);
  96. Message1(option_undefining_symbol,s);
  97. end;
  98. function check_symbol(const s:string):boolean;
  99. begin
  100. check_symbol:=(initdefines.find(s)<>nil);
  101. end;
  102. procedure set_default_link_type;
  103. begin
  104. if (target_info.system in [system_i386_win32,system_i386_wdosx]) then
  105. begin
  106. def_symbol('FPC_LINK_SMART');
  107. undef_symbol('FPC_LINK_STATIC');
  108. undef_symbol('FPC_LINK_DYNAMIC');
  109. initglobalswitches:=initglobalswitches+[cs_link_smart];
  110. initglobalswitches:=initglobalswitches-[cs_link_shared,cs_link_static];
  111. end
  112. else
  113. begin
  114. undef_symbol('FPC_LINK_SMART');
  115. def_symbol('FPC_LINK_STATIC');
  116. undef_symbol('FPC_LINK_DYNAMIC');
  117. initglobalswitches:=initglobalswitches+[cs_link_static];
  118. initglobalswitches:=initglobalswitches-[cs_link_shared,cs_link_smart];
  119. end;
  120. end;
  121. {****************************************************************************
  122. Toption
  123. ****************************************************************************}
  124. procedure StopOptions;
  125. begin
  126. if assigned(Option) then
  127. begin
  128. Option.free;
  129. Option:=nil;
  130. end;
  131. DoneVerbose;
  132. Stop;
  133. end;
  134. procedure Toption.WriteLogo;
  135. var
  136. p : pchar;
  137. begin
  138. p:=MessagePchar(option_logo);
  139. while assigned(p) do
  140. Comment(V_Normal,GetMsgLine(p));
  141. end;
  142. procedure Toption.WriteInfo;
  143. var
  144. p : pchar;
  145. hs,hs1,s : string;
  146. target : tsystem;
  147. begin
  148. p:=MessagePchar(option_info);
  149. while assigned(p) do
  150. begin
  151. s:=GetMsgLine(p);
  152. { list OS Targets }
  153. if pos('$OSTARGETS',s)>0 then
  154. begin
  155. for target:=low(tsystem) to high(tsystem) do
  156. if assigned(targetinfos[target]) then
  157. begin
  158. hs:=s;
  159. hs1:=targetinfos[target]^.name;
  160. if tf_under_development in targetinfos[target]^.flags then
  161. hs1:=hs1+' (under development)';
  162. Replace(hs,'$OSTARGETS',hs1);
  163. Comment(V_Normal,hs);
  164. end;
  165. end
  166. else
  167. Comment(V_Normal,s);
  168. end;
  169. StopOptions;
  170. end;
  171. procedure Toption.WriteHelpPages;
  172. function PadEnd(s:string;i:longint):string;
  173. begin
  174. while (length(s)<i) do
  175. s:=s+' ';
  176. PadEnd:=s;
  177. end;
  178. var
  179. lastident,
  180. j,outline,
  181. ident,
  182. lines : longint;
  183. show : boolean;
  184. opt : string[32];
  185. input,
  186. s : string;
  187. p : pchar;
  188. begin
  189. WriteLogo;
  190. Lines:=4;
  191. Message1(option_usage,system.paramstr(0));
  192. lastident:=0;
  193. p:=MessagePChar(option_help_pages);
  194. while assigned(p) do
  195. begin
  196. { get a line and reset }
  197. s:=GetMsgLine(p);
  198. ident:=0;
  199. show:=false;
  200. { parse options }
  201. case s[1] of
  202. {$ifdef UNITALIASES}
  203. 'a',
  204. {$endif}
  205. {$ifdef EXTDEBUG}
  206. 'e',
  207. {$endif EXTDEBUG}
  208. {$ifdef i386}
  209. '3',
  210. {$endif}
  211. {$ifdef powerpc}
  212. 'P',
  213. {$endif}
  214. {$ifdef vis}
  215. 'V',
  216. {$endif}
  217. {$ifdef sparc}
  218. 'S',
  219. {$endif}
  220. {$ifdef m68k}
  221. '6',
  222. {$endif}
  223. '*' : show:=true;
  224. end;
  225. if show then
  226. begin
  227. case s[2] of
  228. {$ifdef GDB}
  229. 'g',
  230. {$endif}
  231. {$ifdef Unix}
  232. 'L',
  233. {$endif}
  234. {$ifdef os2}
  235. 'O',
  236. {$endif}
  237. '*' : show:=true;
  238. else
  239. show:=false;
  240. end;
  241. end;
  242. { now we may show the message or not }
  243. if show then
  244. begin
  245. case s[3] of
  246. '0' : begin
  247. ident:=0;
  248. outline:=0;
  249. end;
  250. '1' : begin
  251. ident:=2;
  252. outline:=7;
  253. end;
  254. '2' : begin
  255. ident:=6;
  256. outline:=11;
  257. end;
  258. '3' : begin
  259. ident:=9;
  260. outline:=6;
  261. end;
  262. end;
  263. j:=pos('_',s);
  264. opt:=Copy(s,4,j-4);
  265. if opt='*' then
  266. opt:=''
  267. else
  268. if opt=' ' then
  269. opt:=PadEnd(opt,outline)
  270. else
  271. opt:=PadEnd('-'+opt,outline);
  272. if (ident=0) and (lastident<>0) then
  273. begin
  274. Comment(V_Normal,'');
  275. inc(Lines);
  276. end;
  277. { page full ? }
  278. if (lines >= page_size - 1) then
  279. begin
  280. if not NoPressEnter then
  281. begin
  282. Message(option_help_press_enter);
  283. readln(input);
  284. if upper(input)='Q' then
  285. StopOptions;
  286. end;
  287. lines:=0;
  288. end;
  289. Comment(V_Normal,PadEnd('',ident)+opt+Copy(s,j+1,255));
  290. LastIdent:=Ident;
  291. inc(Lines);
  292. end;
  293. end;
  294. StopOptions;
  295. end;
  296. procedure Toption.IllegalPara(const opt:string);
  297. begin
  298. Message1(option_illegal_para,opt);
  299. Message(option_help_pages_para);
  300. StopOptions;
  301. end;
  302. function Toption.Unsetbool(var Opts:string; Pos: Longint):boolean;
  303. { checks if the character after pos in Opts is a + or a - and returns resp.
  304. false or true. If it is another character (or none), it also returns false }
  305. begin
  306. UnsetBool := false;
  307. if Length(Opts)>Pos then
  308. begin
  309. inc(Pos);
  310. UnsetBool := Opts[Pos] = '-';
  311. if Opts[Pos] in ['-','+']then
  312. delete(Opts,Pos,1);
  313. end;
  314. end;
  315. procedure TOption.interpret_proc_specific_options(const opt:string);
  316. begin
  317. end;
  318. procedure TOption.interpret_option(const opt:string;ispara:boolean);
  319. var
  320. code : integer;
  321. c : char;
  322. more : string;
  323. major,minor : longint;
  324. error : integer;
  325. j,l : longint;
  326. d : DirStr;
  327. e : ExtStr;
  328. s : string;
  329. forceasm : tasm;
  330. begin
  331. if opt='' then
  332. exit;
  333. { only parse define,undef,target,verbosity and link options the firsttime }
  334. if firstpass and
  335. not((opt[1]='-') and (opt[2] in ['i','d','v','T','u','n','X'])) then
  336. exit;
  337. Message1(option_handling_option,opt);
  338. case opt[1] of
  339. '-' :
  340. begin
  341. more:=Copy(opt,3,255);
  342. if firstpass then
  343. Message1(option_interpreting_firstpass_option,opt)
  344. else
  345. Message1(option_interpreting_option,opt);
  346. case opt[2] of
  347. '?' :
  348. WriteHelpPages;
  349. 'a' :
  350. begin
  351. include(initglobalswitches,cs_asm_leave);
  352. j:=1;
  353. while j<=length(more) do
  354. begin
  355. case more[j] of
  356. 'l' :
  357. include(initglobalswitches,cs_asm_source);
  358. 'r' :
  359. include(initglobalswitches,cs_asm_regalloc);
  360. 't' :
  361. include(initglobalswitches,cs_asm_tempalloc);
  362. 'n' :
  363. include(initglobalswitches,cs_asm_nodes);
  364. 'p' :
  365. begin
  366. exclude(initglobalswitches,cs_asm_leave);
  367. if UnsetBool(More, 0) then
  368. exclude(initglobalswitches,cs_asm_pipe)
  369. else
  370. include(initglobalswitches,cs_asm_pipe);
  371. end;
  372. '-' :
  373. initglobalswitches:=initglobalswitches -
  374. [cs_asm_leave, cs_asm_source,cs_asm_regalloc, cs_asm_tempalloc,
  375. cs_asm_nodes, cs_asm_pipe];
  376. else
  377. IllegalPara(opt);
  378. end;
  379. inc(j);
  380. end;
  381. end;
  382. 'A' :
  383. begin
  384. if set_target_asm_by_string(More) then
  385. asm_is_set:=true
  386. else
  387. IllegalPara(opt);
  388. end;
  389. 'b' :
  390. begin
  391. if UnsetBool(More,0) then
  392. begin
  393. exclude(initmoduleswitches,cs_browser);
  394. exclude(initmoduleswitches,cs_local_browser);
  395. {$ifdef BrowserLog}
  396. exclude(initglobalswitches,cs_browser_log);
  397. {$endif}
  398. end
  399. else
  400. begin
  401. include(initmoduleswitches,cs_browser);
  402. {$ifdef BrowserLog}
  403. include(initglobalswitches,cs_browser_log);
  404. {$endif}
  405. end;
  406. if More<>'' then
  407. if (More='l') or (More='l+') then
  408. include(initmoduleswitches,cs_local_browser)
  409. else
  410. if More='l-' then
  411. exclude(initmoduleswitches,cs_local_browser)
  412. else
  413. {$ifdef BrowserLog}
  414. browserlog.elements_to_list.insert(more);
  415. {$else}
  416. IllegalPara(opt);
  417. {$endif}
  418. end;
  419. 'B' :
  420. do_build:=not UnSetBool(more,0);
  421. 'C' :
  422. begin
  423. j:=1;
  424. while j<=length(more) do
  425. begin
  426. case more[j] of
  427. 'a' :
  428. Message2(option_obsolete_switch_use_new,'-Ca','-Or');
  429. 'c' :
  430. begin
  431. if not SetAktProcCall(upper(copy(more,j+1,length(more)-j)),true) then
  432. IllegalPara(opt);
  433. break;
  434. end;
  435. {$ifdef cpufpemu}
  436. 'e' :
  437. begin
  438. If UnsetBool(More, j) then
  439. exclude(initmoduleswitches,cs_fp_emulation)
  440. Else
  441. include(initmoduleswitches,cs_fp_emulation);
  442. end;
  443. {$endif cpufpemu}
  444. 'f' :
  445. begin
  446. s:=upper(copy(more,j+1,length(more)-j));
  447. if not(SetFpuType(s,true)) then
  448. IllegalPara(opt);
  449. break;
  450. end;
  451. 'g' :
  452. include(initmoduleswitches,cs_create_pic);
  453. 'h' :
  454. begin
  455. val(copy(more,j+1,length(more)-j),heapsize,code);
  456. if (code<>0) or
  457. {$WARNING Is the upper limit for heapsize needed / useful?}
  458. { (heapsize>=67107840) or }
  459. (heapsize<1024) then
  460. IllegalPara(opt);
  461. break;
  462. end;
  463. 'i' :
  464. If UnsetBool(More, j) then
  465. exclude(initlocalswitches,cs_check_io)
  466. else
  467. include(initlocalswitches,cs_check_io);
  468. 'n' :
  469. If UnsetBool(More, j) then
  470. exclude(initglobalswitches,cs_link_extern)
  471. Else
  472. include(initglobalswitches,cs_link_extern);
  473. 'o' :
  474. If UnsetBool(More, j) then
  475. exclude(initlocalswitches,cs_check_overflow)
  476. Else
  477. include(initlocalswitches,cs_check_overflow);
  478. 'p' :
  479. begin
  480. s:=upper(copy(more,j+1,length(more)-j));
  481. if not(SetProcessor(s,true)) then
  482. IllegalPara(opt);
  483. break;
  484. end;
  485. 'r' :
  486. If UnsetBool(More, j) then
  487. exclude(initlocalswitches,cs_check_range)
  488. Else
  489. include(initlocalswitches,cs_check_range);
  490. 'R' :
  491. If UnsetBool(More, j) then
  492. begin
  493. exclude(initlocalswitches,cs_check_range);
  494. exclude(initlocalswitches,cs_check_object);
  495. end
  496. Else
  497. begin
  498. include(initlocalswitches,cs_check_range);
  499. include(initlocalswitches,cs_check_object);
  500. end;
  501. 's' :
  502. begin
  503. val(copy(more,j+1,length(more)-j),stacksize,code);
  504. if (code<>0) or (stacksize>=67107840) or (stacksize<1024) then
  505. IllegalPara(opt);
  506. break;
  507. end;
  508. 't' :
  509. If UnsetBool(More, j) then
  510. exclude(initlocalswitches,cs_check_stack)
  511. Else
  512. include(initlocalswitches,cs_check_stack);
  513. 'D' :
  514. If UnsetBool(More, j) then
  515. exclude(initmoduleswitches,cs_create_dynamic)
  516. Else
  517. include(initmoduleswitches,cs_create_dynamic);
  518. 'X' :
  519. If UnsetBool(More, j) then
  520. exclude(initmoduleswitches,cs_create_smart)
  521. Else
  522. include(initmoduleswitches,cs_create_smart);
  523. else
  524. IllegalPara(opt);
  525. end;
  526. inc(j);
  527. end;
  528. end;
  529. 'd' :
  530. def_symbol(more);
  531. 'D' :
  532. begin
  533. include(initglobalswitches,cs_link_deffile);
  534. j:=1;
  535. while j<=length(more) do
  536. begin
  537. case more[j] of
  538. 'd' :
  539. begin
  540. description:=Copy(more,j+1,255);
  541. break;
  542. end;
  543. 'v' :
  544. begin
  545. dllversion:=Copy(more,j+1,255);
  546. l:=pos('.',dllversion);
  547. dllminor:=0;
  548. error:=0;
  549. if l>0 then
  550. begin
  551. valint(copy(dllversion,l+1,255),minor,error);
  552. if (error=0) and
  553. (minor>=0) and (minor<=$ffff) then
  554. dllminor:=minor
  555. else
  556. if error=0 then
  557. error:=1;
  558. end;
  559. if l=0 then
  560. l:=256;
  561. dllmajor:=1;
  562. if error=0 then
  563. valint(copy(dllversion,1,l-1),major,error);
  564. if (error=0) and (major>=0) and (major<=$ffff) then
  565. dllmajor:=major
  566. else
  567. if error=0 then
  568. error:=1;
  569. if error<>0 then
  570. Message1(scan_w_wrong_version_ignored,dllversion);
  571. break;
  572. end;
  573. 'w' :
  574. usewindowapi:=true;
  575. '-' :
  576. begin
  577. exclude(initglobalswitches,cs_link_deffile);
  578. usewindowapi:=false;
  579. end;
  580. else
  581. IllegalPara(opt);
  582. end;
  583. inc(j);
  584. end;
  585. end;
  586. 'e' :
  587. exepath:=FixPath(More,true);
  588. 'E' :
  589. begin
  590. if UnsetBool(More, 0) then
  591. exclude(initglobalswitches,cs_link_extern)
  592. else
  593. include(initglobalswitches,cs_link_extern);
  594. end;
  595. 'F' :
  596. begin
  597. c:=more[1];
  598. Delete(more,1,1);
  599. DefaultReplacements(More);
  600. case c of
  601. 'c' :
  602. begin
  603. if not(cpavailable(more)) then
  604. Message1(option_code_page_not_available,more)
  605. else
  606. initsourcecodepage:=more;
  607. end;
  608. 'D' :
  609. utilsdirectory:=FixPath(More,true);
  610. 'e' :
  611. SetRedirectFile(More);
  612. 'E' :
  613. OutputExeDir:=FixPath(More,true);
  614. 'i' :
  615. begin
  616. if ispara then
  617. ParaIncludePath.AddPath(More,false)
  618. else
  619. includesearchpath.AddPath(More,true);
  620. end;
  621. 'g' :
  622. Message2(option_obsolete_switch_use_new,'-Fg','-Fl');
  623. 'l' :
  624. begin
  625. if ispara then
  626. ParaLibraryPath.AddPath(More,false)
  627. else
  628. LibrarySearchPath.AddPath(More,true);
  629. end;
  630. 'L' :
  631. begin
  632. if More<>'' then
  633. ParaDynamicLinker:=More
  634. else
  635. IllegalPara(opt);
  636. end;
  637. 'o' :
  638. begin
  639. if ispara then
  640. ParaObjectPath.AddPath(More,false)
  641. else
  642. ObjectSearchPath.AddPath(More,true);
  643. end;
  644. 'r' :
  645. Msgfilename:=More;
  646. 'u' :
  647. begin
  648. if ispara then
  649. ParaUnitPath.AddPath(More,false)
  650. else
  651. unitsearchpath.AddPath(More,true);
  652. end;
  653. 'U' :
  654. OutputUnitDir:=FixPath(More,true);
  655. else
  656. IllegalPara(opt);
  657. end;
  658. end;
  659. 'g' : begin
  660. if UnsetBool(More, 0) then
  661. begin
  662. exclude(initmoduleswitches,cs_debuginfo);
  663. exclude(initglobalswitches,cs_gdb_dbx);
  664. exclude(initglobalswitches,cs_gdb_gsym);
  665. exclude(initglobalswitches,cs_gdb_heaptrc);
  666. exclude(initglobalswitches,cs_gdb_lineinfo);
  667. exclude(initglobalswitches,cs_checkpointer);
  668. end
  669. else
  670. begin
  671. {$ifdef GDB}
  672. include(initmoduleswitches,cs_debuginfo);
  673. if not RelocSectionSetExplicitly then
  674. RelocSection:=false;
  675. j:=1;
  676. while j<=length(more) do
  677. begin
  678. case more[j] of
  679. 'd' :
  680. begin
  681. if UnsetBool(More, j) then
  682. exclude(initglobalswitches,cs_gdb_dbx)
  683. else
  684. include(initglobalswitches,cs_gdb_dbx);
  685. end;
  686. 'g' :
  687. begin
  688. if UnsetBool(More, j) then
  689. exclude(initglobalswitches,cs_gdb_gsym)
  690. else
  691. include(initglobalswitches,cs_gdb_gsym);
  692. end;
  693. 'h' :
  694. begin
  695. if UnsetBool(More, j) then
  696. exclude(initglobalswitches,cs_gdb_heaptrc)
  697. else
  698. include(initglobalswitches,cs_gdb_heaptrc);
  699. end;
  700. 'l' :
  701. begin
  702. if UnsetBool(More, j) then
  703. exclude(initglobalswitches,cs_gdb_lineinfo)
  704. else
  705. include(initglobalswitches,cs_gdb_lineinfo);
  706. end;
  707. 'c' :
  708. begin
  709. if UnsetBool(More, j) then
  710. exclude(initglobalswitches,cs_checkpointer)
  711. else
  712. include(initglobalswitches,cs_checkpointer);
  713. end;
  714. 'v' :
  715. begin
  716. if UnsetBool(More, j) then
  717. exclude(initglobalswitches,cs_gdb_valgrind)
  718. else
  719. include(initglobalswitches,cs_gdb_valgrind);
  720. end;
  721. else
  722. IllegalPara(opt);
  723. end;
  724. inc(j);
  725. end;
  726. {$else GDB}
  727. Message(option_no_debug_support);
  728. Message(option_no_debug_support_recompile_fpc);
  729. {$endif GDB}
  730. end;
  731. end;
  732. 'h' :
  733. begin
  734. NoPressEnter:=true;
  735. WriteHelpPages;
  736. end;
  737. 'i' :
  738. begin
  739. if More='' then
  740. WriteInfo
  741. else
  742. QuickInfo:=QuickInfo+More;
  743. end;
  744. 'I' :
  745. begin
  746. if ispara then
  747. ParaIncludePath.AddPath(More,false)
  748. else
  749. includesearchpath.AddPath(More,false);
  750. end;
  751. 'k' :
  752. begin
  753. if more<>'' then
  754. ParaLinkOptions:=ParaLinkOptions+' '+More
  755. else
  756. IllegalPara(opt);
  757. end;
  758. 'l' :
  759. DoWriteLogo:=not UnSetBool(more,0);
  760. 'm' :
  761. parapreprocess:=not UnSetBool(more,0);
  762. 'n' :
  763. begin
  764. if More='' then
  765. disable_configfile:=true
  766. else
  767. IllegalPara(opt);
  768. end;
  769. 'o' :
  770. begin
  771. if More<>'' then
  772. Fsplit(More,d,OutputFile,e)
  773. else
  774. IllegalPara(opt);
  775. end;
  776. 'p' :
  777. begin
  778. if UnsetBool(More, 0) then
  779. begin
  780. initmoduleswitches:=initmoduleswitches-[cs_profile];
  781. undef_symbol('FPC_PROFILE');
  782. end
  783. else
  784. if Length(More)=0 then
  785. IllegalPara(opt)
  786. else
  787. case more[1] of
  788. 'g' : if UnsetBool(more, 1) then
  789. begin
  790. exclude(initmoduleswitches,cs_profile);
  791. undef_symbol('FPC_PROFILE');
  792. end
  793. else
  794. begin
  795. include(initmoduleswitches,cs_profile);
  796. def_symbol('FPC_PROFILE');
  797. end;
  798. else
  799. IllegalPara(opt);
  800. end;
  801. end;
  802. {$ifdef Unix}
  803. 'P' : ; { Ignore used by fpc.pp }
  804. {$endif Unix}
  805. 's' :
  806. begin
  807. if UnsetBool(More, 0) then
  808. begin
  809. initglobalswitches:=initglobalswitches-[cs_asm_extern,cs_link_extern];
  810. if more<>'' then
  811. IllegalPara(opt);
  812. end
  813. else
  814. begin
  815. initglobalswitches:=initglobalswitches+[cs_asm_extern,cs_link_extern];
  816. if more='h' then
  817. initglobalswitches:=initglobalswitches-[cs_link_on_target]
  818. else if more='t' then
  819. initglobalswitches:=initglobalswitches+[cs_link_on_target]
  820. else if more='r' then
  821. initglobalswitches:=initglobalswitches+[cs_asm_leave,cs_no_regalloc]
  822. else if more<>'' then
  823. IllegalPara(opt);
  824. end;
  825. end;
  826. 'M' :
  827. begin
  828. more:=Upper(more);
  829. if not SetCompileMode(more, true) then
  830. IllegalPara(opt);
  831. end;
  832. 'S' :
  833. begin
  834. if more[1]='I' then
  835. begin
  836. if upper(more)='ICOM' then
  837. initinterfacetype:=it_interfacecom
  838. else if upper(more)='ICORBA' then
  839. initinterfacetype:=it_interfacecorba
  840. else
  841. IllegalPara(opt);
  842. end
  843. else
  844. begin
  845. j:=1;
  846. while j<=length(more) do
  847. begin
  848. case more[j] of
  849. '2' : //an alternative to -Mobjfpc
  850. SetCompileMode('OBJFPC',true);
  851. 'a' :
  852. include(initlocalswitches,cs_do_assertion);
  853. 'c' :
  854. include(initmoduleswitches,cs_support_c_operators);
  855. 'd' : //an alternative to -Mdelphi
  856. SetCompileMode('DELPHI',true);
  857. 'e' :
  858. begin
  859. SetErrorFlags(copy(more,j+1,length(more)));
  860. break;
  861. end;
  862. 'g' :
  863. include(initmoduleswitches,cs_support_goto);
  864. 'h' :
  865. include(initlocalswitches,cs_ansistrings);
  866. 'i' :
  867. include(initmoduleswitches,cs_support_inline);
  868. 'm' :
  869. include(initmoduleswitches,cs_support_macro);
  870. 'o' : //an alternative to -Mtp
  871. SetCompileMode('TP',true);
  872. 'p' : //an alternative to -Mgpc
  873. SetCompileMode('GPC',true);
  874. 's' :
  875. include(initglobalswitches,cs_constructor_name);
  876. 't' :
  877. include(initmoduleswitches,cs_static_keyword);
  878. '-' :
  879. begin
  880. exclude(initglobalswitches,cs_constructor_name);
  881. initlocalswitches:=InitLocalswitches - [cs_do_assertion, cs_ansistrings];
  882. initmoduleswitches:=initmoduleswitches - [cs_support_c_operators, cs_support_goto,
  883. cs_support_inline, cs_support_macro,
  884. cs_static_keyword];
  885. end;
  886. else
  887. IllegalPara(opt);
  888. end;
  889. inc(j);
  890. end;
  891. end;
  892. end;
  893. 'T' :
  894. begin
  895. more:=Upper(More);
  896. if not target_is_set then
  897. begin
  898. { remove old target define }
  899. TargetDefines(false);
  900. { Save assembler if set }
  901. if asm_is_set then
  902. forceasm:=target_asm.id;
  903. { load new target }
  904. if not(set_target_by_string(More)) then
  905. IllegalPara(opt);
  906. { also initialize assembler if not explicitly set }
  907. if asm_is_set then
  908. set_target_asm(forceasm);
  909. { set new define }
  910. TargetDefines(true);
  911. target_is_set:=true;
  912. end
  913. else
  914. if More<>upper(target_info.shortname) then
  915. Message1(option_target_is_already_set,target_info.shortname);
  916. end;
  917. 'u' :
  918. undef_symbol(upper(More));
  919. 'U' :
  920. begin
  921. j:=1;
  922. while j<=length(more) do
  923. begin
  924. case more[j] of
  925. {$ifdef UNITALIASES}
  926. 'a' :
  927. begin
  928. AddUnitAlias(Copy(More,j+1,255));
  929. break;
  930. end;
  931. {$endif UNITALIASES}
  932. 'n' :
  933. exclude(initglobalswitches,cs_check_unit_name);
  934. 'p' :
  935. begin
  936. Message2(option_obsolete_switch_use_new,'-Up','-Fu');
  937. break;
  938. end;
  939. 'r' :
  940. do_release:=true;
  941. 's' :
  942. include(initmoduleswitches,cs_compilesystem);
  943. '-' :
  944. begin
  945. exclude(initmoduleswitches,cs_compilesystem);
  946. exclude(initglobalswitches,cs_check_unit_name);
  947. end;
  948. else
  949. IllegalPara(opt);
  950. end;
  951. inc(j);
  952. end;
  953. end;
  954. 'v' :
  955. begin
  956. if not setverbosity(More) then
  957. IllegalPara(opt);
  958. end;
  959. 'V' : ; { Ignore used by fpc }
  960. 'W' :
  961. begin
  962. j:=1;
  963. while j<=length(More) do
  964. begin
  965. case More[j] of
  966. 'B':
  967. begin
  968. { -WB200000 means set trefered base address
  969. to $200000, but does not change relocsection boolean
  970. this way we can create both relocatble and
  971. non relocatable DLL at a specific base address PM }
  972. if (length(More)>j) then
  973. begin
  974. if DLLImageBase=nil then
  975. DLLImageBase:=StringDup(Copy(More,j+1,255));
  976. end
  977. else
  978. begin
  979. RelocSection:=true;
  980. RelocSectionSetExplicitly:=true;
  981. end;
  982. break;
  983. end;
  984. 'C':
  985. begin
  986. if UnsetBool(More, j) then
  987. apptype:=app_gui
  988. else
  989. apptype:=app_cui;
  990. end;
  991. 'D':
  992. ForceDeffileForExport:=not UnsetBool(More, j);
  993. 'F':
  994. begin
  995. if UnsetBool(More, j) then
  996. apptype:=app_cui
  997. else
  998. apptype:=app_fs;
  999. end;
  1000. 'G':
  1001. begin
  1002. if UnsetBool(More, j) then
  1003. apptype:=app_cui
  1004. else
  1005. apptype:=app_gui;
  1006. end;
  1007. 'N':
  1008. begin
  1009. RelocSection:=UnsetBool(More,j);
  1010. RelocSectionSetExplicitly:=true;
  1011. end;
  1012. 'R':
  1013. begin
  1014. { support -WR+ / -WR- as synonyms to -WR / -WN }
  1015. RelocSection:=not UnsetBool(More,j);
  1016. RelocSectionSetExplicitly:=true;
  1017. end;
  1018. else
  1019. IllegalPara(opt);
  1020. end;
  1021. inc(j);
  1022. end;
  1023. end;
  1024. 'X' :
  1025. begin
  1026. j:=1;
  1027. while j<=length(more) do
  1028. begin
  1029. case More[j] of
  1030. 'i' :
  1031. include(initglobalswitches,cs_link_internal);
  1032. 'm' :
  1033. include(initglobalswitches,cs_link_map);
  1034. 'f' :
  1035. include(initglobalswitches,cs_link_pthread);
  1036. 's' :
  1037. include(initglobalswitches,cs_link_strip);
  1038. 'c' : Cshared:=TRUE;
  1039. 't' :
  1040. include(initglobalswitches,cs_link_staticflag);
  1041. 'D' :
  1042. begin
  1043. def_symbol('FPC_LINK_DYNAMIC');
  1044. undef_symbol('FPC_LINK_SMART');
  1045. undef_symbol('FPC_LINK_STATIC');
  1046. exclude(initglobalswitches,cs_link_static);
  1047. exclude(initglobalswitches,cs_link_smart);
  1048. include(initglobalswitches,cs_link_shared);
  1049. LinkTypeSetExplicitly:=true;
  1050. end;
  1051. 'd' : Dontlinkstdlibpath:=TRUE;
  1052. 'P' : Begin
  1053. utilsprefix:=Copy(more,2,length(More)-1);
  1054. More:='';
  1055. End;
  1056. 'r' : Begin
  1057. rlinkpath:=Copy(more,2,length(More)-1);
  1058. More:='';
  1059. end;
  1060. 'S' :
  1061. begin
  1062. def_symbol('FPC_LINK_STATIC');
  1063. undef_symbol('FPC_LINK_SMART');
  1064. undef_symbol('FPC_LINK_DYNAMIC');
  1065. include(initglobalswitches,cs_link_static);
  1066. exclude(initglobalswitches,cs_link_smart);
  1067. exclude(initglobalswitches,cs_link_shared);
  1068. LinkTypeSetExplicitly:=true;
  1069. end;
  1070. 'X' :
  1071. begin
  1072. def_symbol('FPC_LINK_SMART');
  1073. undef_symbol('FPC_LINK_STATIC');
  1074. undef_symbol('FPC_LINK_DYNAMIC');
  1075. exclude(initglobalswitches,cs_link_static);
  1076. include(initglobalswitches,cs_link_smart);
  1077. exclude(initglobalswitches,cs_link_shared);
  1078. LinkTypeSetExplicitly:=true;
  1079. end;
  1080. '-' :
  1081. begin
  1082. exclude(initglobalswitches,cs_link_staticflag);
  1083. exclude(initglobalswitches,cs_link_strip);
  1084. exclude(initglobalswitches,cs_link_map);
  1085. set_default_link_type;
  1086. end;
  1087. else
  1088. IllegalPara(opt);
  1089. end;
  1090. inc(j);
  1091. end;
  1092. end;
  1093. { give processor specific options a chance }
  1094. else
  1095. interpret_proc_specific_options(opt);
  1096. end;
  1097. end;
  1098. '@' :
  1099. begin
  1100. Message(option_no_nested_response_file);
  1101. StopOptions;
  1102. end;
  1103. else
  1104. begin
  1105. if (length(param_file)<>0) then
  1106. Message(option_only_one_source_support);
  1107. param_file:=opt;
  1108. Message1(option_found_file,opt);
  1109. end;
  1110. end;
  1111. end;
  1112. procedure Toption.Interpret_file(const filename : string);
  1113. procedure RemoveSep(var fn:string);
  1114. var
  1115. i : longint;
  1116. begin
  1117. i:=0;
  1118. while (i<length(fn)) and (fn[i+1] in [',',' ',#9]) do
  1119. inc(i);
  1120. Delete(fn,1,i);
  1121. i:=length(fn);
  1122. while (i>0) and (fn[i] in [',',' ',#9]) do
  1123. dec(i);
  1124. fn:=copy(fn,1,i);
  1125. end;
  1126. function GetName(var fn:string):string;
  1127. var
  1128. i : longint;
  1129. begin
  1130. i:=0;
  1131. while (i<length(fn)) and (fn[i+1] in ['a'..'z','A'..'Z','0'..'9','_','-']) do
  1132. inc(i);
  1133. GetName:=Copy(fn,1,i);
  1134. Delete(fn,1,i);
  1135. end;
  1136. const
  1137. maxlevel=16;
  1138. var
  1139. f : text;
  1140. s,
  1141. opts : string;
  1142. skip : array[0..maxlevel-1] of boolean;
  1143. level : longint;
  1144. option_read : boolean;
  1145. begin
  1146. { avoid infinite loop }
  1147. Inc(FileLevel);
  1148. Option_read:=false;
  1149. If FileLevel>MaxLevel then
  1150. Message(option_too_many_cfg_files);
  1151. { open file }
  1152. Message1(option_using_file,filename);
  1153. assign(f,filename);
  1154. {$I-}
  1155. reset(f);
  1156. {$I+}
  1157. if ioresult<>0 then
  1158. begin
  1159. Message1(option_unable_open_file,filename);
  1160. exit;
  1161. end;
  1162. Message1(option_start_reading_configfile,filename);
  1163. fillchar(skip,sizeof(skip),0);
  1164. level:=0;
  1165. while not eof(f) do
  1166. begin
  1167. readln(f,opts);
  1168. RemoveSep(opts);
  1169. if (opts<>'') and (opts[1]<>';') then
  1170. begin
  1171. if opts[1]='#' then
  1172. begin
  1173. Message1(option_interpreting_file_option,opts);
  1174. Delete(opts,1,1);
  1175. s:=upper(GetName(opts));
  1176. if (s='SECTION') then
  1177. begin
  1178. RemoveSep(opts);
  1179. s:=upper(GetName(opts));
  1180. if level=0 then
  1181. skip[level]:=not (check_symbol(s) or (s='COMMON'));
  1182. end
  1183. else
  1184. if (s='IFDEF') then
  1185. begin
  1186. RemoveSep(opts);
  1187. if Level>=maxlevel then
  1188. begin
  1189. Message(option_too_many_ifdef);
  1190. stopOptions;
  1191. end;
  1192. inc(Level);
  1193. skip[level]:=(skip[level-1] or (not check_symbol(upper(GetName(opts)))));
  1194. end
  1195. else
  1196. if (s='IFNDEF') then
  1197. begin
  1198. RemoveSep(opts);
  1199. if Level>=maxlevel then
  1200. begin
  1201. Message(option_too_many_ifdef);
  1202. stopOptions;
  1203. end;
  1204. inc(Level);
  1205. skip[level]:=(skip[level-1] or (check_symbol(upper(GetName(opts)))));
  1206. end
  1207. else
  1208. if (s='ELSE') then
  1209. skip[level]:=skip[level-1] or (not skip[level])
  1210. else
  1211. if (s='ENDIF') then
  1212. begin
  1213. skip[level]:=false;
  1214. if Level=0 then
  1215. begin
  1216. Message(option_too_many_endif);
  1217. stopOptions;
  1218. end;
  1219. dec(level);
  1220. end
  1221. else
  1222. if (not skip[level]) then
  1223. begin
  1224. if (s='DEFINE') then
  1225. begin
  1226. RemoveSep(opts);
  1227. def_symbol(upper(GetName(opts)));
  1228. end
  1229. else
  1230. if (s='UNDEF') then
  1231. begin
  1232. RemoveSep(opts);
  1233. undef_symbol(upper(GetName(opts)));
  1234. end
  1235. else
  1236. if (s='WRITE') then
  1237. begin
  1238. Delete(opts,1,1);
  1239. WriteLn(opts);
  1240. end
  1241. else
  1242. if (s='INCLUDE') then
  1243. begin
  1244. Delete(opts,1,1);
  1245. Interpret_file(opts);
  1246. end;
  1247. end;
  1248. end
  1249. else
  1250. begin
  1251. if (opts[1]='-') or (opts[1]='@') then
  1252. begin
  1253. if (not skip[level]) then
  1254. interpret_option(opts,false);
  1255. Option_read:=true;
  1256. end
  1257. else
  1258. Message1(option_illegal_para,opts);
  1259. end;
  1260. end;
  1261. end;
  1262. if Level>0 then
  1263. Message(option_too_less_endif);
  1264. if Not Option_read then
  1265. Message1(option_no_option_found,filename)
  1266. else
  1267. Message1(option_end_reading_configfile,filename);
  1268. Close(f);
  1269. Dec(FileLevel);
  1270. end;
  1271. procedure Toption.Interpret_envvar(const envname : string);
  1272. var
  1273. argstart,
  1274. env,
  1275. pc : pchar;
  1276. arglen : longint;
  1277. quote : set of char;
  1278. hs : string;
  1279. begin
  1280. Message1(option_using_env,envname);
  1281. env:=GetEnvPChar(envname);
  1282. pc:=env;
  1283. if assigned(pc) then
  1284. begin
  1285. repeat
  1286. { skip leading spaces }
  1287. while pc^ in [' ',#9,#13] do
  1288. inc(pc);
  1289. case pc^ of
  1290. #0 :
  1291. break;
  1292. '"' :
  1293. begin
  1294. quote:=['"'];
  1295. inc(pc);
  1296. end;
  1297. '''' :
  1298. begin
  1299. quote:=[''''];
  1300. inc(pc);
  1301. end;
  1302. else
  1303. quote:=[' ',#9,#13];
  1304. end;
  1305. { scan until the end of the argument }
  1306. argstart:=pc;
  1307. while (pc^<>#0) and not(pc^ in quote) do
  1308. inc(pc);
  1309. { create argument }
  1310. arglen:=pc-argstart;
  1311. hs[0]:=chr(arglen);
  1312. move(argstart^,hs[1],arglen);
  1313. interpret_option(hs,true);
  1314. { skip quote }
  1315. if pc^ in quote then
  1316. inc(pc);
  1317. until false;
  1318. end
  1319. else
  1320. Message1(option_no_option_found,'(env) '+envname);
  1321. FreeEnvPChar(env);
  1322. end;
  1323. procedure toption.read_parameters;
  1324. var
  1325. opts : string;
  1326. paramindex : longint;
  1327. begin
  1328. paramindex:=0;
  1329. while paramindex<paramcount do
  1330. begin
  1331. inc(paramindex);
  1332. opts:=system.paramstr(paramindex);
  1333. case opts[1] of
  1334. '@' :
  1335. if not firstpass then
  1336. begin
  1337. Delete(opts,1,1);
  1338. Message1(option_reading_further_from,opts);
  1339. interpret_file(opts);
  1340. end;
  1341. '!' :
  1342. if not firstpass then
  1343. begin
  1344. Delete(opts,1,1);
  1345. Message1(option_reading_further_from,'(env) '+opts);
  1346. interpret_envvar(opts);
  1347. end;
  1348. else
  1349. interpret_option(opts,true);
  1350. end;
  1351. end;
  1352. end;
  1353. procedure toption.parsecmd(cmd:string);
  1354. var
  1355. i,ps : longint;
  1356. opts : string;
  1357. begin
  1358. while (cmd<>'') do
  1359. begin
  1360. while cmd[1]=' ' do
  1361. delete(cmd,1,1);
  1362. i:=pos(' ',cmd);
  1363. if i=0 then
  1364. i:=256;
  1365. opts:=Copy(cmd,1,i-1);
  1366. Delete(cmd,1,i);
  1367. case opts[1] of
  1368. '@' :
  1369. if not firstpass then
  1370. begin
  1371. Delete(opts,1,1);
  1372. Message1(option_reading_further_from,opts);
  1373. interpret_file(opts);
  1374. end;
  1375. '!' :
  1376. if not firstpass then
  1377. begin
  1378. Delete(opts,1,1);
  1379. Message1(option_reading_further_from,'(env) '+opts);
  1380. interpret_envvar(opts);
  1381. end;
  1382. '"' :
  1383. begin
  1384. Delete(opts,1,1);
  1385. ps:=pos('"',cmd);
  1386. if (i<>256) and (ps>0) then
  1387. begin
  1388. opts:=opts + ' '+ copy(cmd,1,ps-1);
  1389. cmd:=copy(cmd,ps+1,255);
  1390. end;
  1391. interpret_option(opts,true);
  1392. end;
  1393. else
  1394. interpret_option(opts,true);
  1395. end;
  1396. end;
  1397. end;
  1398. procedure toption.writequickinfo;
  1399. var
  1400. s : string;
  1401. i : longint;
  1402. procedure addinfo(const hs:string);
  1403. begin
  1404. if s<>'' then
  1405. s:=s+' '+hs
  1406. else
  1407. s:=hs;
  1408. end;
  1409. begin
  1410. s:='';
  1411. i:=0;
  1412. while (i<length(quickinfo)) do
  1413. begin
  1414. inc(i);
  1415. case quickinfo[i] of
  1416. 'S' :
  1417. begin
  1418. inc(i);
  1419. case quickinfo[i] of
  1420. 'O' :
  1421. addinfo(lower(source_info.shortname));
  1422. {$ifdef Delphi}
  1423. 'P' :
  1424. addinfo('i386');
  1425. {$else Delphi}
  1426. 'P' :
  1427. addinfo(source_cpu_string);
  1428. {$endif Delphi}
  1429. else
  1430. IllegalPara('-i'+QuickInfo);
  1431. end;
  1432. end;
  1433. 'T' :
  1434. begin
  1435. inc(i);
  1436. case quickinfo[i] of
  1437. 'O' :
  1438. addinfo(lower(target_info.shortname));
  1439. 'P' :
  1440. AddInfo(target_cpu_string);
  1441. else
  1442. IllegalPara('-i'+QuickInfo);
  1443. end;
  1444. end;
  1445. 'V' :
  1446. AddInfo(version_string);
  1447. 'D' :
  1448. AddInfo(date_string);
  1449. '_' :
  1450. ;
  1451. else
  1452. IllegalPara('-i'+QuickInfo);
  1453. end;
  1454. end;
  1455. if s<>'' then
  1456. begin
  1457. writeln(s);
  1458. stopoptions;
  1459. end;
  1460. end;
  1461. procedure TOption.TargetDefines(def:boolean);
  1462. var
  1463. s : string;
  1464. i : integer;
  1465. begin
  1466. if def then
  1467. def_symbol(upper(target_info.shortname))
  1468. else
  1469. undef_symbol(upper(target_info.shortname));
  1470. s:=target_info.extradefines;
  1471. while (s<>'') do
  1472. begin
  1473. i:=pos(';',s);
  1474. if i=0 then
  1475. i:=length(s)+1;
  1476. if def then
  1477. def_symbol(Copy(s,1,i-1))
  1478. else
  1479. undef_symbol(Copy(s,1,i-1));
  1480. delete(s,1,i);
  1481. end;
  1482. end;
  1483. constructor TOption.create;
  1484. begin
  1485. DoWriteLogo:=false;
  1486. NoPressEnter:=false;
  1487. FirstPass:=false;
  1488. FileLevel:=0;
  1489. Quickinfo:='';
  1490. ParaIncludePath:=TSearchPathList.Create;
  1491. ParaObjectPath:=TSearchPathList.Create;
  1492. ParaUnitPath:=TSearchPathList.Create;
  1493. ParaLibraryPath:=TSearchPathList.Create;
  1494. FillChar(ParaAlignment,sizeof(ParaAlignment),0);
  1495. end;
  1496. destructor TOption.destroy;
  1497. begin
  1498. ParaIncludePath.Free;
  1499. ParaObjectPath.Free;
  1500. ParaUnitPath.Free;
  1501. ParaLibraryPath.Free;
  1502. end;
  1503. {****************************************************************************
  1504. Callable Routines
  1505. ****************************************************************************}
  1506. function check_configfile(const fn:string;var foundfn:string):boolean;
  1507. function CfgFileExists(const fn:string):boolean;
  1508. begin
  1509. Comment(V_Tried,'Configfile search: '+fn);
  1510. CfgFileExists:=FileExists(fn);
  1511. end;
  1512. var
  1513. configpath : pathstr;
  1514. begin
  1515. foundfn:=fn;
  1516. check_configfile:=true;
  1517. { retrieve configpath }
  1518. {$ifdef Delphi}
  1519. configpath:=FixPath(dmisc.getenv('PPC_CONFIG_PATH'),false);
  1520. {$else Delphi}
  1521. configpath:=FixPath(dos.getenv('PPC_CONFIG_PATH'),false);
  1522. {$endif Delphi}
  1523. {$ifdef Unix}
  1524. if configpath='' then
  1525. configpath:='/etc/';
  1526. {$endif}
  1527. {
  1528. Order to read configuration file :
  1529. try reading fpc.cfg in :
  1530. 1 - current dir
  1531. 2 - configpath
  1532. 3 - compiler path
  1533. }
  1534. if not FileExists(fn) then
  1535. begin
  1536. {$ifdef Unix}
  1537. if (dos.getenv('HOME')<>'') and CfgFileExists(FixPath(dos.getenv('HOME'),false)+'.'+fn) then
  1538. foundfn:=FixPath(dos.getenv('HOME'),false)+'.'+fn
  1539. else
  1540. {$endif}
  1541. if CfgFileExists(configpath+fn) then
  1542. foundfn:=configpath+fn
  1543. else
  1544. {$ifndef Unix}
  1545. if CfgFileExists(exepath+fn) then
  1546. foundfn:=exepath+fn
  1547. else
  1548. {$endif}
  1549. check_configfile:=false;
  1550. end;
  1551. end;
  1552. procedure read_arguments(cmd:string);
  1553. begin
  1554. option:=coption.create;
  1555. disable_configfile:=false;
  1556. { default defines }
  1557. def_symbol(upper(target_info.shortname));
  1558. def_symbol('FPC');
  1559. def_symbol('VER'+version_nr);
  1560. def_symbol('VER'+version_nr+'_'+release_nr);
  1561. def_symbol('VER'+version_nr+'_'+release_nr+'_'+patch_nr);
  1562. { Temporary defines, until things settle down }
  1563. def_symbol('HASWIDECHAR');
  1564. def_symbol('HASWIDESTRING');
  1565. def_symbol('HASOUT');
  1566. def_symbol('HASGLOBALPROPERTY');
  1567. def_symbol('FPC_HASPREFETCH');
  1568. {$ifdef i386}
  1569. def_symbol('HASINTF');
  1570. def_symbol('HASVARIANT');
  1571. {$endif i386}
  1572. {$ifdef powerpc}
  1573. def_symbol('HASINTF');
  1574. def_symbol('HASVARIANT');
  1575. def_symbol('FPC_MTFSB0_CORRECTED');
  1576. {$endif powerpc}
  1577. {$ifdef arm}
  1578. def_symbol('HASINTF');
  1579. def_symbol('HASVARIANT');
  1580. {$endif arm}
  1581. def_symbol('INTERNSETLENGTH');
  1582. def_symbol('INTERNLENGTH');
  1583. def_symbol('INTERNCOPY');
  1584. def_symbol('INT64FUNCRESOK');
  1585. def_symbol('HAS_ADDR_STACK_ON_STACK');
  1586. def_symbol('NOBOUNDCHECK');
  1587. def_symbol('HASCOMPILERPROC');
  1588. def_symbol('VALUEGETMEM');
  1589. def_symbol('VALUEFREEMEM');
  1590. def_symbol('HASCURRENCY');
  1591. def_symbol('HASTHREADVAR');
  1592. def_symbol('HAS_GENERICCONSTRUCTOR');
  1593. def_symbol('NOCLASSHELPERS');
  1594. if pocall_default = pocall_register then
  1595. def_symbol('REGCALL');
  1596. def_symbol('DECRREFNOTNIL');
  1597. def_symbol('HAS_INTERNAL_INTTYPES');
  1598. { using a case is pretty useless here (FK) }
  1599. { some stuff for TP compatibility }
  1600. {$ifdef i386}
  1601. def_symbol('CPU86');
  1602. def_symbol('CPU87');
  1603. {$endif}
  1604. {$ifdef m68k}
  1605. def_symbol('CPU68');
  1606. {$endif}
  1607. { new processor stuff }
  1608. {$ifdef i386}
  1609. def_symbol('CPUI386');
  1610. def_symbol('CPU32');
  1611. def_symbol('FPC_HAS_TYPE_EXTENDED');
  1612. def_symbol('FPC_HAS_TYPE_DOUBLE');
  1613. def_symbol('FPC_HAS_TYPE_SINGLE');
  1614. {$endif}
  1615. {$ifdef m68k}
  1616. def_symbol('CPU68K');
  1617. def_symbol('CPU32');
  1618. def_symbol('FPC_CURRENCY_IS_INT64');
  1619. {$endif}
  1620. {$ifdef ALPHA}
  1621. def_symbol('CPUALPHA');
  1622. def_symbol('CPU64');
  1623. {$endif}
  1624. {$ifdef powerpc}
  1625. def_symbol('CPUPOWERPC');
  1626. def_symbol('CPUPOWERPC32');
  1627. def_symbol('CPU32');
  1628. def_symbol('FPC_HAS_TYPE_DOUBLE');
  1629. def_symbol('FPC_HAS_TYPE_SINGLE');
  1630. def_symbol('FPC_INCLUDE_SOFTWARE_INT64_TO_DOUBLE');
  1631. def_symbol('FPC_CURRENCY_IS_INT64');
  1632. {$endif}
  1633. {$ifdef iA64}
  1634. def_symbol('CPUIA64');
  1635. def_symbol('CPU64');
  1636. {$endif}
  1637. {$ifdef x86_64}
  1638. def_symbol('CPUX86_64');
  1639. def_symbol('CPU64');
  1640. { not supported for now, afaik (FK)
  1641. def_symbol('FPC_HAS_TYPE_FLOAT128'); }
  1642. def_symbol('FPC_HAS_TYPE_EXTENDED');
  1643. def_symbol('FPC_HAS_TYPE_DOUBLE');
  1644. def_symbol('FPC_HAS_TYPE_SINGLE');
  1645. {$endif}
  1646. {$ifdef sparc}
  1647. def_symbol('CPUSPARC');
  1648. def_symbol('CPUSPARC32');
  1649. def_symbol('CPU32');
  1650. def_symbol('FPC_HAS_TYPE_DOUBLE');
  1651. def_symbol('FPC_HAS_TYPE_SINGLE');
  1652. def_symbol('FPC_INCLUDE_SOFTWARE_INT64_TO_DOUBLE');
  1653. def_symbol('FPC_CURRENCY_IS_INT64');
  1654. {$endif}
  1655. {$ifdef vis}
  1656. def_symbol('CPUVIS');
  1657. def_symbol('CPU32');
  1658. {$endif}
  1659. {$ifdef arm}
  1660. def_symbol('CPUARM');
  1661. def_symbol('CPU32');
  1662. def_symbol('FPC_HAS_TYPE_DOUBLE');
  1663. def_symbol('FPC_HAS_TYPE_SINGLE');
  1664. def_symbol('FPC_CURRENCY_IS_INT64');
  1665. def_symbol('FPC_REQUIRES_PROPER_ALIGNMENT');
  1666. {$endif arm}
  1667. { get default messagefile }
  1668. {$ifdef Delphi}
  1669. msgfilename:=dmisc.getenv('PPC_ERROR_FILE');
  1670. {$else Delphi}
  1671. msgfilename:=dos.getenv('PPC_ERROR_FILE');
  1672. {$endif Delphi}
  1673. { default configfile can be specified on the commandline,
  1674. remove it first }
  1675. if (cmd<>'') and (cmd[1]='[') then
  1676. begin
  1677. ppccfg:=Copy(cmd,2,pos(']',cmd)-2);
  1678. Delete(cmd,1,pos(']',cmd));
  1679. end
  1680. else
  1681. begin
  1682. ppccfg:='fpc.cfg';
  1683. ppcaltcfg:='ppc386.cfg';
  1684. end;
  1685. { read the parameters quick, only -i -v -T }
  1686. option.firstpass:=true;
  1687. if cmd<>'' then
  1688. option.parsecmd(cmd)
  1689. else
  1690. begin
  1691. option.read_parameters;
  1692. { Write only quickinfo }
  1693. if option.quickinfo<>'' then
  1694. option.writequickinfo;
  1695. end;
  1696. option.firstpass:=false;
  1697. { read configuration file }
  1698. if (not disable_configfile) and
  1699. (ppccfg<>'') then
  1700. begin
  1701. read_configfile:=check_configfile(ppccfg,ppccfg);
  1702. { Maybe alternative configfile ? }
  1703. if (not read_configfile) and
  1704. (ppcaltcfg<>'') then
  1705. read_configfile:=check_configfile(ppcaltcfg,ppccfg);
  1706. end
  1707. else
  1708. read_configfile := false;
  1709. { Read commandline and configfile }
  1710. target_is_set:=false;
  1711. asm_is_set:=false;
  1712. param_file:='';
  1713. { read configfile }
  1714. if read_configfile then
  1715. option.interpret_file(ppccfg);
  1716. { read parameters again to override config file }
  1717. if cmd<>'' then
  1718. option.parsecmd(cmd)
  1719. else
  1720. begin
  1721. option.read_parameters;
  1722. { Write only quickinfo }
  1723. if option.quickinfo<>'' then
  1724. option.writequickinfo;
  1725. end;
  1726. { Write help pages }
  1727. if (cmd='') and (paramcount=0) then
  1728. Option.WriteHelpPages;
  1729. { Stop if errors in options }
  1730. if ErrorCount>0 then
  1731. StopOptions;
  1732. { Non-core target defines }
  1733. Option.TargetDefines(true);
  1734. { endian define }
  1735. case target_info.endian of
  1736. endian_little :
  1737. begin
  1738. def_symbol('ENDIAN_LITTLE');
  1739. def_symbol('FPC_LITTLE_ENDIAN');
  1740. end;
  1741. endian_big :
  1742. begin
  1743. def_symbol('ENDIAN_BIG');
  1744. def_symbol('FPC_BIG_ENDIAN');
  1745. end;
  1746. end;
  1747. { abi define }
  1748. case target_info.abi of
  1749. abi_powerpc_sysv :
  1750. def_symbol('FPC_ABI_SYSV');
  1751. abi_powerpc_aix :
  1752. def_symbol('FPC_ABI_AIX');
  1753. end;
  1754. {$ifdef m68k}
  1755. if initoptprocessor=MC68020 then
  1756. def_symbol('CPUM68020');
  1757. {$endif m68k}
  1758. { write logo if set }
  1759. if option.DoWriteLogo then
  1760. option.WriteLogo;
  1761. { Check file to compile }
  1762. if param_file='' then
  1763. begin
  1764. Message(option_no_source_found);
  1765. StopOptions;
  1766. end;
  1767. {$ifndef Unix}
  1768. param_file:=FixFileName(param_file);
  1769. {$endif}
  1770. fsplit(param_file,inputdir,inputfile,inputextension);
  1771. if inputextension='' then
  1772. begin
  1773. if FileExists(inputdir+inputfile+target_info.sourceext) then
  1774. inputextension:=target_info.sourceext
  1775. else
  1776. if FileExists(inputdir+inputfile+target_info.pasext) then
  1777. inputextension:=target_info.pasext;
  1778. end;
  1779. { Add paths specified with parameters to the searchpaths }
  1780. UnitSearchPath.AddList(option.ParaUnitPath,true);
  1781. ObjectSearchPath.AddList(option.ParaObjectPath,true);
  1782. IncludeSearchPath.AddList(option.ParaIncludePath,true);
  1783. LibrarySearchPath.AddList(option.ParaLibraryPath,true);
  1784. { add unit environment and exepath to the unit search path }
  1785. if inputdir<>'' then
  1786. Unitsearchpath.AddPath(inputdir,true);
  1787. if not disable_configfile then
  1788. begin
  1789. {$ifdef Delphi}
  1790. UnitSearchPath.AddPath(dmisc.getenv(target_info.unit_env),false);
  1791. {$else}
  1792. UnitSearchPath.AddPath(dos.getenv(target_info.unit_env),false);
  1793. {$endif Delphi}
  1794. end;
  1795. {$ifdef Unix}
  1796. fpcdir:=FixPath(getenv('FPCDIR'),false);
  1797. if fpcdir='' then
  1798. begin
  1799. if source_info.cpu<>target_info.cpu then
  1800. begin
  1801. if PathExists('/usr/local/lib/fpc/'+version_string+'/cross/'+cpu2str[target_info.cpu]+'-'+target_info.shortname) then
  1802. fpcdir:='/usr/local/lib/fpc/'+version_string+'/cross/'+cpu2str[target_info.cpu]+'-'+target_info.shortname+'/'
  1803. else
  1804. fpcdir:='/usr/lib/fpc/'+version_string+'/cross/'+cpu2str[target_info.cpu]+'-'+target_info.shortname+'/';
  1805. end
  1806. else
  1807. begin
  1808. if PathExists('/usr/local/lib/fpc/'+version_string) then
  1809. fpcdir:='/usr/local/lib/fpc/'+version_string+'/'
  1810. else
  1811. fpcdir:='/usr/lib/fpc/'+version_string+'/';
  1812. end;
  1813. end;
  1814. {$else}
  1815. fpcdir:=FixPath(getenv('FPCDIR'),false);
  1816. if fpcdir='' then
  1817. begin
  1818. fpcdir:=ExePath+'../';
  1819. if not(PathExists(fpcdir+'/units')) and
  1820. not(PathExists(fpcdir+'/rtl')) then
  1821. fpcdir:=fpcdir+'../';
  1822. end;
  1823. {$endif}
  1824. { first try development RTL, else use the default installation path }
  1825. if not disable_configfile then
  1826. begin
  1827. if source_info.cpu<>target_info.cpu then
  1828. begin
  1829. if PathExists(FpcDir+'rtl/'+lower(target_info.shortname)) then
  1830. UnitSearchPath.AddPath(FpcDir+'rtl/'+lower(target_info.shortname),false)
  1831. else
  1832. begin
  1833. UnitSearchPath.AddPath(FpcDir+'units/',false);
  1834. UnitSearchPath.AddPath(FpcDir+'units/rtl',false);
  1835. end;
  1836. end
  1837. else
  1838. begin
  1839. if PathExists(FpcDir+'rtl/'+lower(target_info.shortname)) then
  1840. UnitSearchPath.AddPath(FpcDir+'rtl/'+lower(target_info.shortname),false)
  1841. else
  1842. begin
  1843. UnitSearchPath.AddPath(FpcDir+'units/'+lower(target_info.shortname),false);
  1844. UnitSearchPath.AddPath(FpcDir+'units/'+lower(target_info.shortname)+'/rtl',false);
  1845. end;
  1846. end;
  1847. end;
  1848. { Add exepath if the exe is not in the current dir, because that is always searched already.
  1849. Do not add it when linking on the target because then we can maybe already find
  1850. .o files that are not for the target }
  1851. if (ExePath<>GetCurrentDir) and
  1852. not(cs_link_on_target in initglobalswitches) then
  1853. UnitSearchPath.AddPath(ExePath,false);
  1854. { Add unit dir to the object and library path }
  1855. objectsearchpath.AddList(unitsearchpath,false);
  1856. librarysearchpath.AddList(unitsearchpath,false);
  1857. { switch assembler if it's binary and we got -a on the cmdline }
  1858. if (cs_asm_leave in initglobalswitches) and
  1859. (target_asm.outputbinary) then
  1860. begin
  1861. Message(option_switch_bin_to_src_assembler);
  1862. set_target_asm(target_info.assemextern);
  1863. end;
  1864. if (target_asm.supported_target <> system_any) and
  1865. (target_asm.supported_target <> target_info.system) then
  1866. begin
  1867. Message2(option_incompatible_asm,target_asm.idtxt,target_info.name);
  1868. set_target_asm(target_info.assemextern);
  1869. Message1(option_asm_forced,target_asm.idtxt);
  1870. end;
  1871. { turn off stripping if compiling with debuginfo or profile }
  1872. if (cs_debuginfo in initmoduleswitches) or
  1873. (cs_profile in initmoduleswitches) then
  1874. exclude(initglobalswitches,cs_link_strip);
  1875. if not LinkTypeSetExplicitly then
  1876. set_default_link_type;
  1877. { Default alignment settings,
  1878. 1. load the defaults for the target
  1879. 2. override with generic optimizer setting (little size)
  1880. 3. override with the user specified -Oa }
  1881. UpdateAlignment(initalignment,target_info.alignment);
  1882. if (cs_littlesize in aktglobalswitches) then
  1883. begin
  1884. initalignment.procalign:=1;
  1885. initalignment.jumpalign:=1;
  1886. initalignment.loopalign:=1;
  1887. end;
  1888. UpdateAlignment(initalignment,option.paraalignment);
  1889. option.free;
  1890. Option:=nil;
  1891. end;
  1892. initialization
  1893. coption:=toption;
  1894. finalization
  1895. if assigned(option) then
  1896. option.free;
  1897. end.
  1898. {
  1899. $Log$
  1900. Revision 1.130 2004-03-23 22:34:49 peter
  1901. * constants ordinals now always have a type assigned
  1902. * integer constants have the smallest type, unsigned prefered over
  1903. signed
  1904. Revision 1.129 2004/03/21 22:40:15 florian
  1905. + added interface support for the arm
  1906. * added FPC_REQUIRES_PROPER_ALIGNMENT define for targets which require proper alignment
  1907. Revision 1.128 2004/03/20 22:57:07 florian
  1908. + cross compilation dir search added
  1909. Revision 1.127 2004/03/10 22:52:57 peter
  1910. * more stabs fixes
  1911. * special mode -gv for valgrind compatible stabs
  1912. Revision 1.126 2004/03/02 17:32:12 florian
  1913. * make cycle fixed
  1914. + pic support for darwin
  1915. + support of importing vars from shared libs on darwin implemented
  1916. Revision 1.125 2004/02/22 12:04:04 florian
  1917. + nx86set added
  1918. * some more x86-64 fixes
  1919. Revision 1.124 2004/02/15 16:34:18 marco
  1920. * pthread on -CURRENT related fixes.
  1921. Revision 1.123 2004/02/03 00:42:08 florian
  1922. + FPC_PREFETCH defined
  1923. Revision 1.122 2004/01/24 18:12:40 florian
  1924. * fixed several arm floating point issues
  1925. Revision 1.121 2004/01/21 22:13:20 peter
  1926. * decrrefcount resets temps to nil
  1927. Revision 1.120 2004/01/10 00:16:21 jonas
  1928. * fixed mtfsb0 instruction for assembler reader/writer
  1929. * fixed initialisation of fpscr register to avoid spurious SIGPFE's
  1930. (uses mtfsb0 instruction, so added extra define in options.pas to avoid
  1931. requiring to start with a cross compiler)
  1932. Revision 1.119 2004/01/02 17:19:04 jonas
  1933. * if currency = int64, FPC_CURRENCY_IS_INT64 is defined
  1934. + round and trunc for currency and comp if FPC_CURRENCY_IS_INT64 is
  1935. defined
  1936. * if currency = orddef, prefer currency -> int64/qword conversion over
  1937. currency -> float conversions
  1938. * optimized currency/currency if currency = orddef
  1939. * TODO: write FPC_DIV_CURRENCY and FPC_MUL_CURRENCY routines to prevent
  1940. precision loss if currency=int64 and bestreal = double
  1941. Revision 1.118 2003/12/17 22:50:42 hajny
  1942. * fixed incorrect error message
  1943. Revision 1.117 2003/12/11 18:15:06 florian
  1944. * HASGLOBALPROPERTY define introduce
  1945. Revision 1.116 2003/12/10 01:54:44 florian
  1946. * variants and interfaces on powerpc released
  1947. Revision 1.115 2003/11/11 21:10:34 peter
  1948. * define REGCALL when pocall_default=pocall_register
  1949. Revision 1.114 2003/11/07 15:58:32 florian
  1950. * Florian's culmutative nr. 1; contains:
  1951. - invalid calling conventions for a certain cpu are rejected
  1952. - arm softfloat calling conventions
  1953. - -Sp for cpu dependend code generation
  1954. - several arm fixes
  1955. - remaining code for value open array paras on heap
  1956. Revision 1.113 2003/10/22 15:40:44 marco
  1957. * -Xc -Xr support
  1958. Revision 1.112 2003/10/18 09:14:18 hajny
  1959. * upper limit for heapsize removed
  1960. Revision 1.110 2003/10/14 00:30:48 florian
  1961. + some code for PIC support added
  1962. Revision 1.109 2003/10/11 19:32:04 marco
  1963. * -Xd
  1964. Revision 1.108 2003/10/08 19:17:43 peter
  1965. * -P to -ap
  1966. * -V to -vv
  1967. Revision 1.107 2003/10/03 14:16:48 marco
  1968. * -XP<prefix> support
  1969. Revision 1.106 2003/09/17 21:37:07 olle
  1970. + added command line option for language mode -M<x>
  1971. Revision 1.105 2003/09/14 21:33:11 peter
  1972. * don't check exepath when linking on target
  1973. Revision 1.104 2003/09/06 10:41:54 olle
  1974. + compiler now define abi macros for powerpc FPC_ABI_AIX or FPC_ABI_SYSV
  1975. Revision 1.103 2003/09/05 17:41:12 florian
  1976. * merged Wiktor's Watcom patches in 1.1
  1977. Revision 1.102 2003/09/03 21:06:05 peter
  1978. * powerpc needs software int64 to double
  1979. Revision 1.101 2003/09/03 15:55:01 peter
  1980. * NEWRA branch merged
  1981. Revision 1.100 2003/09/03 11:18:37 florian
  1982. * fixed arm concatcopy
  1983. + arm support in the common compiler sources added
  1984. * moved some generic cg code around
  1985. + tfputype added
  1986. * ...
  1987. Revision 1.99.2.4 2003/09/02 17:48:42 peter
  1988. * sparc need software int64 to double
  1989. Revision 1.99.2.3 2003/09/01 21:02:55 peter
  1990. * sparc updates for new tregister
  1991. Revision 1.99.2.2 2003/08/31 16:18:05 peter
  1992. * more fixes
  1993. Revision 1.99.2.1 2003/08/31 13:50:15 daniel
  1994. * Remove sorting and use pregenerated indexes
  1995. * Some work on making things compile
  1996. Revision 1.99 2003/05/13 19:14:41 peter
  1997. * failn removed
  1998. * inherited result code check moven to pexpr
  1999. Revision 1.98 2003/05/11 19:17:16 florian
  2000. * FPC_LITTLE_ENDIAN and FPC_BIG_ENDIAN is now defined as well
  2001. Revision 1.97 2003/05/01 07:59:42 florian
  2002. * introduced defaultordconsttype to decribe the default size of ordinal constants
  2003. on 64 bit CPUs it's equal to cs64bitdef while on 32 bit CPUs it's equal to s32bitdef
  2004. + added defines CPU32 and CPU64 for 32 bit and 64 bit CPUs
  2005. * int64s/qwords are allowed as for loop counter on 64 bit CPUs
  2006. Revision 1.96 2003/04/30 16:35:00 florian
  2007. * fixed defines for x86-64
  2008. Revision 1.95 2003/04/24 11:21:45 florian
  2009. + HAS_TYPE_* defines for floats on i386 and powerpc added
  2010. Revision 1.94 2003/03/28 19:16:56 peter
  2011. * generic constructor working for i386
  2012. * remove fixed self register
  2013. * esi added as address register for i386
  2014. Revision 1.93 2003/03/23 23:20:38 hajny
  2015. + emx target added
  2016. Revision 1.92 2003/03/08 08:59:07 daniel
  2017. + $define newra will enable new register allocator
  2018. + getregisterint will return imaginary registers with $newra
  2019. + -sr switch added, will skip register allocation so you can see
  2020. the direct output of the code generator before register allocation
  2021. Revision 1.91 2002/12/06 16:56:58 peter
  2022. * only compile cs_fp_emulation support when cpufpuemu is defined
  2023. * define cpufpuemu for m68k only
  2024. Revision 1.90 2002/11/30 23:14:55 carl
  2025. - removed cs_fp_emulation checking for m68k, its now controled
  2026. by a global switch
  2027. + added powerpc/sparc/vis message options support
  2028. Revision 1.89 2002/11/30 21:29:56 carl
  2029. + -Ce for softfpu
  2030. Revision 1.88 2002/11/15 01:58:52 peter
  2031. * merged changes from 1.0.7 up to 04-11
  2032. - -V option for generating bug report tracing
  2033. - more tracing for option parsing
  2034. - errors for cdecl and high()
  2035. - win32 import stabs
  2036. - win32 records<=8 are returned in eax:edx (turned off by default)
  2037. - heaptrc update
  2038. - more info for temp management in .s file with EXTDEBUG
  2039. Revision 1.87 2002/10/23 17:07:40 peter
  2040. * fix -n that was broken in the previous commit
  2041. Revision 1.86 2002/10/23 16:57:16 peter
  2042. * first search for fpc.cfg instead of deprecated ppc386.cfg
  2043. * parse commandline options first before searching configfile so -vt
  2044. can be used to display the searched files
  2045. Revision 1.85 2002/10/13 21:33:01 peter
  2046. * define HASTHREADVAR
  2047. Revision 1.84 2002/10/02 18:20:52 peter
  2048. * Copy() is now internal syssym that calls compilerprocs
  2049. Revision 1.83 2002/09/22 14:02:35 carl
  2050. * stack checking cannot be called before system unit is initialized
  2051. * MC68020 define
  2052. Revision 1.82 2002/08/12 15:08:40 carl
  2053. + stab register indexes for powerpc (moved from gdb to cpubase)
  2054. + tprocessor enumeration moved to cpuinfo
  2055. + linker in target_info is now a class
  2056. * many many updates for m68k (will soon start to compile)
  2057. - removed some ifdef or correct them for correct cpu
  2058. Revision 1.81 2002/08/10 14:46:29 carl
  2059. + moved target_cpu_string to cpuinfo
  2060. * renamed asmmode enum.
  2061. * assembler reader has now less ifdef's
  2062. * move from nppcmem.pas -> ncgmem.pas vec. node.
  2063. Revision 1.80 2002/08/09 19:15:41 carl
  2064. - removed newcg define
  2065. Revision 1.79 2002/07/26 22:22:10 florian
  2066. * several PowerPC related fixes to get forward with system unit compilation
  2067. Revision 1.78 2002/07/26 21:15:39 florian
  2068. * rewrote the system handling
  2069. Revision 1.77 2002/07/20 17:16:03 florian
  2070. + source code page support
  2071. Revision 1.76 2002/07/04 20:43:01 florian
  2072. * first x86-64 patches
  2073. Revision 1.75 2002/07/01 18:46:24 peter
  2074. * internal linker
  2075. * reorganized aasm layer
  2076. Revision 1.74 2002/07/01 16:23:53 peter
  2077. * cg64 patch
  2078. * basics for currency
  2079. * asnode updates for class and interface (not finished)
  2080. Revision 1.73 2002/05/18 13:34:11 peter
  2081. * readded missing revisions
  2082. Revision 1.72 2002/05/16 19:46:41 carl
  2083. + defines.inc -> fpcdefs.inc to avoid conflicts if compiling by hand
  2084. + try to fix temp allocation (still in ifdef)
  2085. + generic constructor calls
  2086. + start of tassembler / tmodulebase class cleanup
  2087. Revision 1.70 2002/05/12 16:53:08 peter
  2088. * moved entry and exitcode to ncgutil and cgobj
  2089. * foreach gets extra argument for passing local data to the
  2090. iterator function
  2091. * -CR checks also class typecasts at runtime by changing them
  2092. into as
  2093. * fixed compiler to cycle with the -CR option
  2094. * fixed stabs with elf writer, finally the global variables can
  2095. be watched
  2096. * removed a lot of routines from cga unit and replaced them by
  2097. calls to cgobj
  2098. * u32bit-s32bit updates for and,or,xor nodes. When one element is
  2099. u32bit then the other is typecasted also to u32bit without giving
  2100. a rangecheck warning/error.
  2101. * fixed pascal calling method with reversing also the high tree in
  2102. the parast, detected by tcalcst3 test
  2103. Revision 1.69 2002/04/21 19:02:04 peter
  2104. * removed newn and disposen nodes, the code is now directly
  2105. inlined from pexpr
  2106. * -an option that will write the secondpass nodes to the .s file, this
  2107. requires EXTDEBUG define to actually write the info
  2108. * fixed various internal errors and crashes due recent code changes
  2109. Revision 1.68 2002/04/20 21:32:24 carl
  2110. + generic FPC_CHECKPOINTER
  2111. + first parameter offset in stack now portable
  2112. * rename some constants
  2113. + move some cpu stuff to other units
  2114. - remove unused constents
  2115. * fix stacksize for some targets
  2116. * fix generic size problems which depend now on EXTEND_SIZE constant
  2117. Revision 1.67 2002/04/07 10:22:35 carl
  2118. + CPU defines now depends on current target
  2119. Revision 1.66 2002/04/04 19:05:58 peter
  2120. * removed unused units
  2121. * use tlocation.size in cg.a_*loc*() routines
  2122. Revision 1.65 2002/04/04 18:39:45 carl
  2123. + added wdosx support (patch from Pavel)
  2124. }