options.pas 63 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152
  1. {
  2. Copyright (c) 1998-2002 by Florian Klaempfl and Peter Vreman
  3. Reads command line options and config files
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program; if not, write to the Free Software
  14. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  15. ****************************************************************************
  16. }
  17. unit options;
  18. {$i fpcdefs.inc}
  19. interface
  20. uses
  21. globtype,globals,verbose,systems,cpuinfo;
  22. type
  23. TOption=class
  24. FirstPass,
  25. ParaLogo,
  26. NoPressEnter,
  27. LogoWritten : 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 USE_SYSUTILS}
  59. SysUtils,
  60. {$ELSE USE_SYSUTILS}
  61. dos,
  62. {$ENDIF USE_SYSUTILS}
  63. version,
  64. cutils,cmsgs,
  65. comphook,
  66. symtable,scanner
  67. {$ifdef BrowserLog}
  68. ,browlog
  69. {$endif BrowserLog}
  70. ;
  71. const
  72. page_size = 24;
  73. var
  74. option : toption;
  75. read_configfile, { read config file, set when a cfgfile is found }
  76. disable_configfile : boolean;
  77. fpcdir,
  78. ppccfg,
  79. ppcaltcfg,
  80. param_file : string; { file to compile specified on the commandline }
  81. {****************************************************************************
  82. Defines
  83. ****************************************************************************}
  84. procedure set_default_link_type;
  85. begin
  86. { win32 and wdosx need smartlinking by default to prevent including too much
  87. dll dependencies }
  88. if (target_info.system in [system_i386_win32,system_i386_wdosx]) then
  89. begin
  90. def_system_macro('FPC_LINK_SMART');
  91. undef_system_macro('FPC_LINK_STATIC');
  92. undef_system_macro('FPC_LINK_DYNAMIC');
  93. initglobalswitches:=initglobalswitches+[cs_link_smart];
  94. initglobalswitches:=initglobalswitches-[cs_link_shared,cs_link_static];
  95. end
  96. else
  97. begin
  98. undef_system_macro('FPC_LINK_SMART');
  99. def_system_macro('FPC_LINK_STATIC');
  100. undef_system_macro('FPC_LINK_DYNAMIC');
  101. initglobalswitches:=initglobalswitches+[cs_link_static];
  102. initglobalswitches:=initglobalswitches-[cs_link_shared,cs_link_smart];
  103. end;
  104. end;
  105. {****************************************************************************
  106. Toption
  107. ****************************************************************************}
  108. procedure StopOptions(err:longint);
  109. begin
  110. if assigned(Option) then
  111. begin
  112. Option.free;
  113. Option:=nil;
  114. end;
  115. raise ECompilerAbortSilent.Create;
  116. end;
  117. procedure Toption.WriteLogo;
  118. var
  119. p : pchar;
  120. begin
  121. if not LogoWritten then
  122. begin
  123. p:=MessagePchar(option_logo);
  124. while assigned(p) do
  125. Comment(V_Normal,GetMsgLine(p));
  126. LogoWritten:= true;
  127. end;
  128. end;
  129. procedure Toption.WriteInfo;
  130. var
  131. p : pchar;
  132. hs,hs1,s : TCmdStr;
  133. target : tsystem;
  134. cpu : tprocessors;
  135. fpu : tfputype;
  136. begin
  137. p:=MessagePchar(option_info);
  138. while assigned(p) do
  139. begin
  140. s:=GetMsgLine(p);
  141. { list OS Targets }
  142. if pos('$OSTARGETS',s)>0 then
  143. begin
  144. for target:=low(tsystem) to high(tsystem) do
  145. if assigned(targetinfos[target]) then
  146. begin
  147. hs:=s;
  148. hs1:=targetinfos[target]^.name;
  149. if tf_under_development in targetinfos[target]^.flags then
  150. hs1:=hs1+' (under development)';
  151. Replace(hs,'$OSTARGETS',hs1);
  152. Comment(V_Normal,hs);
  153. end;
  154. end
  155. else if pos('$INSTRUCTIONSETS',s)>0 then
  156. begin
  157. for cpu:=low(tprocessors) to high(tprocessors) do
  158. begin
  159. hs:=s;
  160. hs1:=processorsstr[cpu];
  161. if hs1<>'' then
  162. begin
  163. Replace(hs,'$INSTRUCTIONSETS',hs1);
  164. Comment(V_Normal,hs);
  165. end;
  166. end;
  167. end
  168. else if pos('$FPUINSTRUCTIONSETS',s)>0 then
  169. begin
  170. for fpu:=low(tfputype) to high(tfputype) do
  171. begin
  172. hs:=s;
  173. hs1:=fputypestr[fpu];
  174. if hs1<>'' then
  175. begin
  176. Replace(hs,'$FPUINSTRUCTIONSETS',hs1);
  177. Comment(V_Normal,hs);
  178. end;
  179. end;
  180. end
  181. else
  182. Comment(V_Normal,s);
  183. end;
  184. StopOptions(0);
  185. end;
  186. procedure Toption.WriteHelpPages;
  187. function PadEnd(s:string;i:longint):string;
  188. begin
  189. while (length(s)<i) do
  190. s:=s+' ';
  191. PadEnd:=s;
  192. end;
  193. var
  194. lastident,
  195. j,outline,
  196. ident,
  197. lines : longint;
  198. show : boolean;
  199. opt : string[32];
  200. input,
  201. s : string;
  202. p : pchar;
  203. begin
  204. WriteLogo;
  205. Lines:=4;
  206. Message1(option_usage,FixFileName(system.paramstr(0)));
  207. lastident:=0;
  208. p:=MessagePChar(option_help_pages);
  209. while assigned(p) do
  210. begin
  211. { get a line and reset }
  212. s:=GetMsgLine(p);
  213. ident:=0;
  214. show:=false;
  215. { parse options }
  216. case s[1] of
  217. {$ifdef UNITALIASES}
  218. 'a',
  219. {$endif}
  220. {$ifdef EXTDEBUG}
  221. 'e',
  222. {$endif EXTDEBUG}
  223. {$ifdef i386}
  224. '3',
  225. {$endif}
  226. {$ifdef x86_64}
  227. '4',
  228. {$endif}
  229. {$ifdef m68k}
  230. '6',
  231. {$endif}
  232. {$ifdef arm}
  233. 'A',
  234. {$endif}
  235. {$ifdef powerpc}
  236. 'P',
  237. {$endif}
  238. {$ifdef sparc}
  239. 'S',
  240. {$endif}
  241. {$ifdef vis}
  242. 'V',
  243. {$endif}
  244. '*' : show:=true;
  245. end;
  246. if show then
  247. begin
  248. case s[2] of
  249. 'g',
  250. {$ifdef Unix}
  251. 'L',
  252. {$endif}
  253. {$ifdef os2}
  254. 'O',
  255. {$endif}
  256. '*' : show:=true;
  257. else
  258. show:=false;
  259. end;
  260. end;
  261. { now we may show the message or not }
  262. if show then
  263. begin
  264. case s[3] of
  265. '0' : begin
  266. ident:=0;
  267. outline:=0;
  268. end;
  269. '1' : begin
  270. ident:=2;
  271. outline:=7;
  272. end;
  273. '2' : begin
  274. ident:=6;
  275. outline:=11;
  276. end;
  277. '3' : begin
  278. ident:=9;
  279. outline:=11;
  280. end;
  281. end;
  282. j:=pos('_',s);
  283. opt:=Copy(s,4,j-4);
  284. if opt='*' then
  285. opt:=''
  286. else
  287. if opt=' ' then
  288. opt:=PadEnd(opt,outline)
  289. else
  290. opt:=PadEnd('-'+opt,outline);
  291. if (ident=0) and (lastident<>0) then
  292. begin
  293. Comment(V_Normal,'');
  294. inc(Lines);
  295. end;
  296. { page full ? }
  297. if (lines >= page_size - 1) then
  298. begin
  299. if not NoPressEnter then
  300. begin
  301. Message(option_help_press_enter);
  302. readln(input);
  303. if upper(input)='Q' then
  304. StopOptions(0);
  305. end;
  306. lines:=0;
  307. end;
  308. Comment(V_Normal,PadEnd('',ident)+opt+Copy(s,j+1,255));
  309. LastIdent:=Ident;
  310. inc(Lines);
  311. end;
  312. end;
  313. StopOptions(0);
  314. end;
  315. procedure Toption.IllegalPara(const opt:string);
  316. begin
  317. Message1(option_illegal_para,opt);
  318. Message(option_help_pages_para);
  319. StopOptions(1);
  320. end;
  321. function Toption.Unsetbool(var Opts:string; Pos: Longint):boolean;
  322. { checks if the character after pos in Opts is a + or a - and returns resp.
  323. false or true. If it is another character (or none), it also returns false }
  324. begin
  325. UnsetBool := false;
  326. if Length(Opts)>Pos then
  327. begin
  328. inc(Pos);
  329. UnsetBool := Opts[Pos] = '-';
  330. if Opts[Pos] in ['-','+']then
  331. delete(Opts,Pos,1);
  332. end;
  333. end;
  334. procedure TOption.interpret_proc_specific_options(const opt:string);
  335. begin
  336. end;
  337. procedure TOption.interpret_option(const opt:string;ispara:boolean);
  338. var
  339. code : integer;
  340. c : char;
  341. more : string;
  342. major,minor : longint;
  343. error : integer;
  344. j,l : longint;
  345. d : DirStr;
  346. e : ExtStr;
  347. s : string;
  348. begin
  349. if opt='' then
  350. exit;
  351. { only parse define,undef,target,verbosity,link etc options the firsttime }
  352. if firstpass and
  353. not(
  354. (opt[1]='-') and
  355. (
  356. ((length(opt)>1) and (opt[2] in ['i','d','v','T','u','n','X','l'])) or
  357. ((length(opt)>3) and (opt[2]='F') and (opt[3]='e'))
  358. )
  359. ) then
  360. exit;
  361. Message1(option_handling_option,opt);
  362. case opt[1] of
  363. '-' :
  364. begin
  365. more:=Copy(opt,3,255);
  366. if firstpass then
  367. Message1(option_interpreting_firstpass_option,opt)
  368. else
  369. Message1(option_interpreting_option,opt);
  370. case opt[2] of
  371. '?' :
  372. WriteHelpPages;
  373. 'a' :
  374. begin
  375. include(initglobalswitches,cs_asm_leave);
  376. j:=1;
  377. while j<=length(more) do
  378. begin
  379. case more[j] of
  380. 'l' :
  381. include(initglobalswitches,cs_asm_source);
  382. 'r' :
  383. include(initglobalswitches,cs_asm_regalloc);
  384. 't' :
  385. include(initglobalswitches,cs_asm_tempalloc);
  386. 'n' :
  387. include(initglobalswitches,cs_asm_nodes);
  388. 'p' :
  389. begin
  390. exclude(initglobalswitches,cs_asm_leave);
  391. if UnsetBool(More, 0) then
  392. exclude(initglobalswitches,cs_asm_pipe)
  393. else
  394. include(initglobalswitches,cs_asm_pipe);
  395. end;
  396. '-' :
  397. initglobalswitches:=initglobalswitches -
  398. [cs_asm_leave, cs_asm_source,cs_asm_regalloc, cs_asm_tempalloc,
  399. cs_asm_nodes, cs_asm_pipe];
  400. else
  401. IllegalPara(opt);
  402. end;
  403. inc(j);
  404. end;
  405. end;
  406. 'A' :
  407. begin
  408. paratargetasm:=find_asm_by_string(More);
  409. if paratargetasm=as_none then
  410. IllegalPara(opt);
  411. end;
  412. 'b' :
  413. begin
  414. {$ifdef supportbrowser}
  415. if UnsetBool(More,0) then
  416. begin
  417. exclude(initmoduleswitches,cs_browser);
  418. exclude(initmoduleswitches,cs_local_browser);
  419. {$ifdef BrowserLog}
  420. exclude(initglobalswitches,cs_browser_log);
  421. {$endif}
  422. end
  423. else
  424. begin
  425. include(initmoduleswitches,cs_browser);
  426. {$ifdef BrowserLog}
  427. include(initglobalswitches,cs_browser_log);
  428. {$endif}
  429. end;
  430. if More<>'' then
  431. if (More='l') or (More='l+') then
  432. include(initmoduleswitches,cs_local_browser)
  433. else
  434. if More='l-' then
  435. exclude(initmoduleswitches,cs_local_browser)
  436. else
  437. {$ifdef BrowserLog}
  438. browserlog.elements_to_list.insert(more);
  439. {$else}
  440. IllegalPara(opt);
  441. {$endif}
  442. {$endif supportbrowser}
  443. end;
  444. 'B' :
  445. do_build:=not UnSetBool(more,0);
  446. 'C' :
  447. begin
  448. j:=1;
  449. while j<=length(more) do
  450. begin
  451. case more[j] of
  452. 'a' :
  453. Message2(option_obsolete_switch_use_new,'-Ca','-Or');
  454. 'c' :
  455. begin
  456. if not SetAktProcCall(upper(copy(more,j+1,length(more)-j)),true) then
  457. IllegalPara(opt);
  458. break;
  459. end;
  460. {$ifdef cpufpemu}
  461. 'e' :
  462. begin
  463. If UnsetBool(More, j) then
  464. exclude(initmoduleswitches,cs_fp_emulation)
  465. Else
  466. include(initmoduleswitches,cs_fp_emulation);
  467. end;
  468. {$endif cpufpemu}
  469. 'f' :
  470. begin
  471. s:=upper(copy(more,j+1,length(more)-j));
  472. if not(SetFpuType(s,true)) then
  473. IllegalPara(opt);
  474. break;
  475. end;
  476. 'g' :
  477. include(initmoduleswitches,cs_create_pic);
  478. 'h' :
  479. begin
  480. val(copy(more,j+1,length(more)-j),heapsize,code);
  481. if (code<>0) or (heapsize<1024) then
  482. IllegalPara(opt);
  483. break;
  484. end;
  485. 'i' :
  486. If UnsetBool(More, j) then
  487. exclude(initlocalswitches,cs_check_io)
  488. else
  489. include(initlocalswitches,cs_check_io);
  490. 'n' :
  491. If UnsetBool(More, j) then
  492. exclude(initglobalswitches,cs_link_extern)
  493. Else
  494. include(initglobalswitches,cs_link_extern);
  495. 'o' :
  496. If UnsetBool(More, j) then
  497. exclude(initlocalswitches,cs_check_overflow)
  498. Else
  499. include(initlocalswitches,cs_check_overflow);
  500. 'p' :
  501. begin
  502. s:=upper(copy(more,j+1,length(more)-j));
  503. if not(SetProcessor(s,true)) then
  504. IllegalPara(opt);
  505. break;
  506. end;
  507. 'r' :
  508. If UnsetBool(More, j) then
  509. exclude(initlocalswitches,cs_check_range)
  510. Else
  511. include(initlocalswitches,cs_check_range);
  512. 'R' :
  513. If UnsetBool(More, j) then
  514. begin
  515. exclude(initlocalswitches,cs_check_range);
  516. exclude(initlocalswitches,cs_check_object);
  517. end
  518. Else
  519. begin
  520. include(initlocalswitches,cs_check_range);
  521. include(initlocalswitches,cs_check_object);
  522. end;
  523. 's' :
  524. begin
  525. val(copy(more,j+1,length(more)-j),stacksize,code);
  526. if (code<>0) or (stacksize>=67107840) or (stacksize<1024) then
  527. IllegalPara(opt);
  528. break;
  529. end;
  530. 't' :
  531. If UnsetBool(More, j) then
  532. exclude(initlocalswitches,cs_check_stack)
  533. Else
  534. include(initlocalswitches,cs_check_stack);
  535. 'D' :
  536. If UnsetBool(More, j) then
  537. exclude(initmoduleswitches,cs_create_dynamic)
  538. Else
  539. include(initmoduleswitches,cs_create_dynamic);
  540. 'X' :
  541. If UnsetBool(More, j) then
  542. exclude(initmoduleswitches,cs_create_smart)
  543. Else
  544. include(initmoduleswitches,cs_create_smart);
  545. else
  546. IllegalPara(opt);
  547. end;
  548. inc(j);
  549. end;
  550. end;
  551. 'd' :
  552. if more <> '' then
  553. begin
  554. l:=Pos(':=',more);
  555. if l>0 then
  556. set_system_compvar(Copy(more,1,l-1),Copy(more,l+2,255))
  557. else
  558. def_system_macro(more);
  559. end;
  560. 'D' :
  561. begin
  562. include(initglobalswitches,cs_link_deffile);
  563. j:=1;
  564. while j<=length(more) do
  565. begin
  566. case more[j] of
  567. 'd' :
  568. begin
  569. description:=Copy(more,j+1,255);
  570. break;
  571. end;
  572. 'v' :
  573. begin
  574. dllversion:=Copy(more,j+1,255);
  575. l:=pos('.',dllversion);
  576. dllminor:=0;
  577. error:=0;
  578. if l>0 then
  579. begin
  580. val(copy(dllversion,l+1,255),minor,error);
  581. if (error=0) and
  582. (minor>=0) and (minor<=$ffff) then
  583. dllminor:=minor
  584. else
  585. if error=0 then
  586. error:=1;
  587. end;
  588. if l=0 then
  589. l:=256;
  590. dllmajor:=1;
  591. if error=0 then
  592. val(copy(dllversion,1,l-1),major,error);
  593. if (error=0) and (major>=0) and (major<=$ffff) then
  594. dllmajor:=major
  595. else
  596. if error=0 then
  597. error:=1;
  598. if error<>0 then
  599. Message1(scan_w_wrong_version_ignored,dllversion);
  600. break;
  601. end;
  602. 'w' :
  603. usewindowapi:=true;
  604. '-' :
  605. begin
  606. exclude(initglobalswitches,cs_link_deffile);
  607. usewindowapi:=false;
  608. end;
  609. else
  610. IllegalPara(opt);
  611. end;
  612. inc(j);
  613. end;
  614. end;
  615. 'e' :
  616. exepath:=FixPath(More,true);
  617. 'E' :
  618. begin
  619. if UnsetBool(More, 0) then
  620. exclude(initglobalswitches,cs_link_extern)
  621. else
  622. include(initglobalswitches,cs_link_extern);
  623. end;
  624. 'F' :
  625. begin
  626. c:=more[1];
  627. Delete(more,1,1);
  628. DefaultReplacements(More);
  629. case c of
  630. 'a' :
  631. autoloadunits:=more;
  632. 'c' :
  633. begin
  634. if (upper(more)='UTF8') or (upper(more)='UTF-8') then
  635. initsourcecodepage:='utf8'
  636. else if not(cpavailable(more)) then
  637. Message1(option_code_page_not_available,more)
  638. else
  639. initsourcecodepage:=more;
  640. end;
  641. 'D' :
  642. utilsdirectory:=FixPath(More,true);
  643. 'e' :
  644. SetRedirectFile(More);
  645. 'E' :
  646. OutputExeDir:=FixPath(More,true);
  647. 'i' :
  648. begin
  649. if ispara then
  650. ParaIncludePath.AddPath(More,false)
  651. else
  652. includesearchpath.AddPath(More,true);
  653. end;
  654. 'g' :
  655. Message2(option_obsolete_switch_use_new,'-Fg','-Fl');
  656. 'l' :
  657. begin
  658. if ispara then
  659. ParaLibraryPath.AddPath(More,false)
  660. else
  661. LibrarySearchPath.AddPath(More,true);
  662. end;
  663. 'L' :
  664. begin
  665. if More<>'' then
  666. ParaDynamicLinker:=More
  667. else
  668. IllegalPara(opt);
  669. end;
  670. 'o' :
  671. begin
  672. if ispara then
  673. ParaObjectPath.AddPath(More,false)
  674. else
  675. ObjectSearchPath.AddPath(More,true);
  676. end;
  677. 'r' :
  678. Msgfilename:=More;
  679. 'u' :
  680. begin
  681. if ispara then
  682. ParaUnitPath.AddPath(More,false)
  683. else
  684. unitsearchpath.AddPath(More,true);
  685. end;
  686. 'U' :
  687. OutputUnitDir:=FixPath(More,true);
  688. else
  689. IllegalPara(opt);
  690. end;
  691. end;
  692. 'g' : begin
  693. if UnsetBool(More, 0) then
  694. begin
  695. exclude(initmoduleswitches,cs_debuginfo);
  696. exclude(initglobalswitches,cs_use_heaptrc);
  697. exclude(initglobalswitches,cs_use_lineinfo);
  698. exclude(initlocalswitches,cs_checkpointer);
  699. end
  700. else
  701. begin
  702. include(initmoduleswitches,cs_debuginfo);
  703. end;
  704. if not RelocSectionSetExplicitly then
  705. RelocSection:=false;
  706. j:=1;
  707. while j<=length(more) do
  708. begin
  709. case more[j] of
  710. 'c' :
  711. begin
  712. if UnsetBool(More, j) then
  713. exclude(initlocalswitches,cs_checkpointer)
  714. else
  715. include(initlocalswitches,cs_checkpointer);
  716. end;
  717. 'd' :
  718. begin
  719. paratargetdbg:=dbg_dwarf;
  720. end;
  721. 'h' :
  722. begin
  723. if UnsetBool(More, j) then
  724. exclude(initglobalswitches,cs_use_heaptrc)
  725. else
  726. include(initglobalswitches,cs_use_heaptrc);
  727. end;
  728. 'l' :
  729. begin
  730. if UnsetBool(More, j) then
  731. exclude(initglobalswitches,cs_use_lineinfo)
  732. else
  733. include(initglobalswitches,cs_use_lineinfo);
  734. end;
  735. 's' :
  736. begin
  737. paratargetdbg:=dbg_stabs;
  738. end;
  739. 'v' :
  740. begin
  741. if UnsetBool(More, j) then
  742. exclude(initglobalswitches,cs_gdb_valgrind)
  743. else
  744. include(initglobalswitches,cs_gdb_valgrind);
  745. end;
  746. else
  747. IllegalPara(opt);
  748. end;
  749. inc(j);
  750. end;
  751. end;
  752. 'h' :
  753. begin
  754. NoPressEnter:=true;
  755. WriteHelpPages;
  756. end;
  757. 'i' :
  758. begin
  759. if More='' then
  760. WriteInfo
  761. else
  762. QuickInfo:=QuickInfo+More;
  763. end;
  764. 'I' :
  765. begin
  766. if ispara then
  767. ParaIncludePath.AddPath(More,false)
  768. else
  769. includesearchpath.AddPath(More,false);
  770. end;
  771. 'k' :
  772. begin
  773. if more<>'' then
  774. ParaLinkOptions:=ParaLinkOptions+' '+More
  775. else
  776. IllegalPara(opt);
  777. end;
  778. 'l' :
  779. if not UnSetBool(more,0) then
  780. ParaLogo:=true;
  781. 'm' :
  782. parapreprocess:=not UnSetBool(more,0);
  783. 'M' :
  784. begin
  785. more:=Upper(more);
  786. if not SetCompileMode(more, true) then
  787. IllegalPara(opt);
  788. end;
  789. 'n' :
  790. begin
  791. if More='' then
  792. disable_configfile:=true
  793. else
  794. IllegalPara(opt);
  795. end;
  796. 'N' :
  797. begin
  798. j:=1;
  799. while j<=length(more) do
  800. begin
  801. case more[j] of
  802. 'u' :
  803. initglobalswitches:=initglobalswitches+[cs_loopunroll];
  804. else
  805. IllegalPara(opt);
  806. end;
  807. inc(j);
  808. end;
  809. end;
  810. 'o' :
  811. begin
  812. if More<>'' then
  813. begin
  814. {$IFDEF USE_SYSUTILS}
  815. D:=SplitPath(More);
  816. OutputFile:=SplitFileName(More);
  817. OutputExtension:=SplitExtension(More);
  818. {$ELSE USE_SYSUTILS}
  819. FSplit(More,D,OutputFile,OutputExtension);
  820. {$ENDIF USE_SYSUTILS}
  821. if (D<>'') then
  822. OutputExeDir:=FixPath(D,True);
  823. end
  824. else
  825. IllegalPara(opt);
  826. end;
  827. 'p' :
  828. begin
  829. if UnsetBool(More, 0) then
  830. begin
  831. initmoduleswitches:=initmoduleswitches-[cs_profile];
  832. undef_system_macro('FPC_PROFILE');
  833. end
  834. else
  835. if Length(More)=0 then
  836. IllegalPara(opt)
  837. else
  838. case more[1] of
  839. 'g' : if UnsetBool(more, 1) then
  840. begin
  841. exclude(initmoduleswitches,cs_profile);
  842. undef_system_macro('FPC_PROFILE');
  843. end
  844. else
  845. begin
  846. include(initmoduleswitches,cs_profile);
  847. def_system_macro('FPC_PROFILE');
  848. end;
  849. else
  850. IllegalPara(opt);
  851. end;
  852. end;
  853. 'P' : ; { Ignore used by fpc.pp }
  854. 's' :
  855. begin
  856. if UnsetBool(More, 0) then
  857. begin
  858. initglobalswitches:=initglobalswitches-[cs_asm_extern,cs_link_extern];
  859. if more<>'' then
  860. IllegalPara(opt);
  861. end
  862. else
  863. begin
  864. initglobalswitches:=initglobalswitches+[cs_asm_extern,cs_link_extern];
  865. if more='h' then
  866. initglobalswitches:=initglobalswitches-[cs_link_on_target]
  867. else if more='t' then
  868. initglobalswitches:=initglobalswitches+[cs_link_on_target]
  869. else if more='r' then
  870. initglobalswitches:=initglobalswitches+[cs_asm_leave,cs_no_regalloc]
  871. else if more<>'' then
  872. IllegalPara(opt);
  873. end;
  874. end;
  875. 'S' :
  876. begin
  877. if more[1]='I' then
  878. begin
  879. if upper(more)='ICOM' then
  880. initinterfacetype:=it_interfacecom
  881. else if upper(more)='ICORBA' then
  882. initinterfacetype:=it_interfacecorba
  883. else
  884. IllegalPara(opt);
  885. end
  886. else
  887. begin
  888. j:=1;
  889. while j<=length(more) do
  890. begin
  891. case more[j] of
  892. '2' : //an alternative to -Mobjfpc
  893. SetCompileMode('OBJFPC',true);
  894. 'a' :
  895. include(initlocalswitches,cs_do_assertion);
  896. 'c' :
  897. include(initmoduleswitches,cs_support_c_operators);
  898. 'd' : //an alternative to -Mdelphi
  899. SetCompileMode('DELPHI',true);
  900. 'e' :
  901. begin
  902. SetErrorFlags(copy(more,j+1,length(more)));
  903. break;
  904. end;
  905. 'g' :
  906. include(initmoduleswitches,cs_support_goto);
  907. 'h' :
  908. include(initlocalswitches,cs_ansistrings);
  909. 'i' :
  910. include(initmoduleswitches,cs_support_inline);
  911. 'k' :
  912. include(initglobalswitches,cs_load_fpcylix_unit);
  913. 'm' :
  914. include(initmoduleswitches,cs_support_macro);
  915. 'o' : //an alternative to -Mtp
  916. SetCompileMode('TP',true);
  917. 'p' : //an alternative to -Mgpc
  918. SetCompileMode('GPC',true);
  919. 's' :
  920. include(initglobalswitches,cs_constructor_name);
  921. 't' :
  922. include(initmoduleswitches,cs_static_keyword);
  923. '-' :
  924. begin
  925. exclude(initglobalswitches,cs_constructor_name);
  926. initlocalswitches:=InitLocalswitches - [cs_do_assertion, cs_ansistrings];
  927. initmoduleswitches:=initmoduleswitches - [cs_support_c_operators, cs_support_goto,
  928. cs_support_inline, cs_support_macro,
  929. cs_static_keyword];
  930. end;
  931. else
  932. IllegalPara(opt);
  933. end;
  934. inc(j);
  935. end;
  936. end;
  937. end;
  938. 'T' :
  939. begin
  940. more:=Upper(More);
  941. if paratarget=system_none then
  942. begin
  943. { remove old target define }
  944. TargetDefines(false);
  945. { load new target }
  946. paratarget:=find_system_by_string(More);
  947. if paratarget<>system_none then
  948. set_target(paratarget)
  949. else
  950. IllegalPara(opt);
  951. { set new define }
  952. TargetDefines(true);
  953. end
  954. else
  955. if More<>upper(target_info.shortname) then
  956. Message1(option_target_is_already_set,target_info.shortname);
  957. end;
  958. 'u' :
  959. if more <> '' then
  960. undef_system_macro(more);
  961. 'U' :
  962. begin
  963. j:=1;
  964. while j<=length(more) do
  965. begin
  966. case more[j] of
  967. {$ifdef UNITALIASES}
  968. 'a' :
  969. begin
  970. AddUnitAlias(Copy(More,j+1,255));
  971. break;
  972. end;
  973. {$endif UNITALIASES}
  974. 'n' :
  975. exclude(initglobalswitches,cs_check_unit_name);
  976. 'p' :
  977. begin
  978. Message2(option_obsolete_switch_use_new,'-Up','-Fu');
  979. break;
  980. end;
  981. 'r' :
  982. do_release:=true;
  983. 's' :
  984. include(initmoduleswitches,cs_compilesystem);
  985. '-' :
  986. begin
  987. exclude(initmoduleswitches,cs_compilesystem);
  988. exclude(initglobalswitches,cs_check_unit_name);
  989. end;
  990. else
  991. IllegalPara(opt);
  992. end;
  993. inc(j);
  994. end;
  995. end;
  996. 'v' :
  997. begin
  998. if not setverbosity(More) then
  999. IllegalPara(opt);
  1000. end;
  1001. 'V' : ; { Ignore used by fpc }
  1002. 'W' :
  1003. begin
  1004. j:=1;
  1005. while j<=length(More) do
  1006. begin
  1007. case More[j] of
  1008. 'A':
  1009. begin
  1010. if UnsetBool(More, j) then
  1011. apptype:=app_native
  1012. else
  1013. apptype:=app_cui;
  1014. end;
  1015. 'B':
  1016. begin
  1017. { -WB200000 means set trefered base address
  1018. to $200000, but does not change relocsection boolean
  1019. this way we can create both relocatble and
  1020. non relocatable DLL at a specific base address PM }
  1021. if (length(More)>j) then
  1022. begin
  1023. if DLLImageBase=nil then
  1024. DLLImageBase:=StringDup(Copy(More,j+1,255));
  1025. end
  1026. else
  1027. begin
  1028. RelocSection:=true;
  1029. RelocSectionSetExplicitly:=true;
  1030. end;
  1031. break;
  1032. end;
  1033. 'C':
  1034. begin
  1035. if UnsetBool(More, j) then
  1036. apptype:=app_gui
  1037. else
  1038. apptype:=app_cui;
  1039. end;
  1040. 'D':
  1041. begin
  1042. UseDeffileForExports:=not UnsetBool(More, j);
  1043. UseDeffileForExportsSetExplicitly:=true;
  1044. end;
  1045. 'F':
  1046. begin
  1047. if UnsetBool(More, j) then
  1048. apptype:=app_cui
  1049. else
  1050. apptype:=app_fs;
  1051. end;
  1052. 'G':
  1053. begin
  1054. if UnsetBool(More, j) then
  1055. apptype:=app_cui
  1056. else
  1057. apptype:=app_gui;
  1058. end;
  1059. 'I':
  1060. begin
  1061. GenerateImportSection:=UnsetBool(More,j);
  1062. end;
  1063. 'N':
  1064. begin
  1065. RelocSection:=UnsetBool(More,j);
  1066. RelocSectionSetExplicitly:=true;
  1067. end;
  1068. 'R':
  1069. begin
  1070. { support -WR+ / -WR- as synonyms to -WR / -WN }
  1071. RelocSection:=not UnsetBool(More,j);
  1072. RelocSectionSetExplicitly:=true;
  1073. end;
  1074. 'T':
  1075. begin
  1076. if UnsetBool(More, j) then
  1077. apptype:=app_cui
  1078. else
  1079. apptype:=app_tool;
  1080. end;
  1081. else
  1082. IllegalPara(opt);
  1083. end;
  1084. inc(j);
  1085. end;
  1086. end;
  1087. 'X' :
  1088. begin
  1089. j:=1;
  1090. while j<=length(more) do
  1091. begin
  1092. case More[j] of
  1093. 'i' :
  1094. include(initglobalswitches,cs_link_internal);
  1095. 'm' :
  1096. include(initglobalswitches,cs_link_map);
  1097. 'f' :
  1098. include(initglobalswitches,cs_link_pthread);
  1099. 's' :
  1100. include(initglobalswitches,cs_link_strip);
  1101. 'c' : Cshared:=TRUE;
  1102. 't' :
  1103. include(initglobalswitches,cs_link_staticflag);
  1104. 'D' :
  1105. begin
  1106. def_system_macro('FPC_LINK_DYNAMIC');
  1107. undef_system_macro('FPC_LINK_SMART');
  1108. undef_system_macro('FPC_LINK_STATIC');
  1109. exclude(initglobalswitches,cs_link_static);
  1110. exclude(initglobalswitches,cs_link_smart);
  1111. include(initglobalswitches,cs_link_shared);
  1112. LinkTypeSetExplicitly:=true;
  1113. end;
  1114. 'd' : Dontlinkstdlibpath:=TRUE;
  1115. 'P' : Begin
  1116. utilsprefix:=Copy(more,2,length(More)-1);
  1117. DefaultReplacements(utilsprefix);
  1118. More:='';
  1119. End;
  1120. 'r' : Begin
  1121. rlinkpath:=Copy(more,2,length(More)-1);
  1122. DefaultReplacements(rlinkpath);
  1123. More:='';
  1124. end;
  1125. 'S' :
  1126. begin
  1127. def_system_macro('FPC_LINK_STATIC');
  1128. undef_system_macro('FPC_LINK_SMART');
  1129. undef_system_macro('FPC_LINK_DYNAMIC');
  1130. include(initglobalswitches,cs_link_static);
  1131. exclude(initglobalswitches,cs_link_smart);
  1132. exclude(initglobalswitches,cs_link_shared);
  1133. LinkTypeSetExplicitly:=true;
  1134. end;
  1135. 'X' :
  1136. begin
  1137. def_system_macro('FPC_LINK_SMART');
  1138. undef_system_macro('FPC_LINK_STATIC');
  1139. undef_system_macro('FPC_LINK_DYNAMIC');
  1140. exclude(initglobalswitches,cs_link_static);
  1141. include(initglobalswitches,cs_link_smart);
  1142. exclude(initglobalswitches,cs_link_shared);
  1143. LinkTypeSetExplicitly:=true;
  1144. end;
  1145. 'M' :
  1146. begin
  1147. mainaliasname:=Copy(more,2,length(More)-1);
  1148. More:='';
  1149. end;
  1150. '-' :
  1151. begin
  1152. exclude(initglobalswitches,cs_link_staticflag);
  1153. exclude(initglobalswitches,cs_link_strip);
  1154. exclude(initglobalswitches,cs_link_map);
  1155. set_default_link_type;
  1156. end;
  1157. else
  1158. IllegalPara(opt);
  1159. end;
  1160. inc(j);
  1161. end;
  1162. end;
  1163. { give processor specific options a chance }
  1164. else
  1165. interpret_proc_specific_options(opt);
  1166. end;
  1167. end;
  1168. '@' :
  1169. begin
  1170. Message(option_no_nested_response_file);
  1171. StopOptions(1);
  1172. end;
  1173. else
  1174. begin
  1175. if (length(param_file)<>0) then
  1176. Message(option_only_one_source_support);
  1177. param_file:=opt;
  1178. Message1(option_found_file,opt);
  1179. end;
  1180. end;
  1181. end;
  1182. procedure Toption.Interpret_file(const filename : string);
  1183. procedure RemoveSep(var fn:string);
  1184. var
  1185. i : longint;
  1186. begin
  1187. i:=0;
  1188. while (i<length(fn)) and (fn[i+1] in [',',' ',#9]) do
  1189. inc(i);
  1190. Delete(fn,1,i);
  1191. i:=length(fn);
  1192. while (i>0) and (fn[i] in [',',' ',#9]) do
  1193. dec(i);
  1194. fn:=copy(fn,1,i);
  1195. end;
  1196. function GetName(var fn:string):string;
  1197. var
  1198. i : longint;
  1199. begin
  1200. i:=0;
  1201. while (i<length(fn)) and (fn[i+1] in ['a'..'z','A'..'Z','0'..'9','_','-']) do
  1202. inc(i);
  1203. GetName:=Copy(fn,1,i);
  1204. Delete(fn,1,i);
  1205. end;
  1206. const
  1207. maxlevel=16;
  1208. var
  1209. f : text;
  1210. s, tmp,
  1211. opts : string;
  1212. skip : array[0..maxlevel-1] of boolean;
  1213. level : longint;
  1214. option_read : boolean;
  1215. begin
  1216. { avoid infinite loop }
  1217. Inc(FileLevel);
  1218. Option_read:=false;
  1219. If FileLevel>MaxLevel then
  1220. Message(option_too_many_cfg_files);
  1221. { Maybe It's Directory ?} //Jaro Change:
  1222. if DirectoryExists(filename) then
  1223. begin
  1224. Message1(option_config_is_dir,filename);
  1225. exit;
  1226. end;
  1227. { open file }
  1228. Message1(option_using_file,filename);
  1229. {$ifdef USE_SYSUTILS}
  1230. assign(f,ExpandFileName(filename));
  1231. {$else USE_SYSUTILS}
  1232. assign(f,FExpand(filename));
  1233. {$endif USE_SYsUTILS}
  1234. {$I-}
  1235. reset(f);
  1236. {$I+}
  1237. if ioresult<>0 then
  1238. begin
  1239. Message1(option_unable_open_file,filename);
  1240. exit;
  1241. end;
  1242. Message1(option_start_reading_configfile,filename);
  1243. fillchar(skip,sizeof(skip),0);
  1244. level:=0;
  1245. while not eof(f) do
  1246. begin
  1247. readln(f,opts);
  1248. RemoveSep(opts);
  1249. if (opts<>'') and (opts[1]<>';') then
  1250. begin
  1251. if opts[1]='#' then
  1252. begin
  1253. Message1(option_interpreting_file_option,opts);
  1254. Delete(opts,1,1);
  1255. s:=upper(GetName(opts));
  1256. if (s='SECTION') then
  1257. begin
  1258. RemoveSep(opts);
  1259. s:=upper(GetName(opts));
  1260. if level=0 then
  1261. skip[level]:=not (assigned(search_macro(s)) or (s='COMMON'));
  1262. end
  1263. else
  1264. if (s='IFDEF') then
  1265. begin
  1266. RemoveSep(opts);
  1267. if Level>=maxlevel then
  1268. begin
  1269. Message(option_too_many_ifdef);
  1270. stopOptions(1);
  1271. end;
  1272. inc(Level);
  1273. skip[level]:=(skip[level-1] or not assigned(search_macro(upper(GetName(opts)))));
  1274. end
  1275. else
  1276. if (s='IFNDEF') then
  1277. begin
  1278. RemoveSep(opts);
  1279. if Level>=maxlevel then
  1280. begin
  1281. Message(option_too_many_ifdef);
  1282. stopOptions(1);
  1283. end;
  1284. inc(Level);
  1285. skip[level]:=(skip[level-1] or assigned(search_macro(upper(GetName(opts)))));
  1286. end
  1287. else
  1288. if (s='ELSE') then
  1289. skip[level]:=skip[level-1] or (not skip[level])
  1290. else
  1291. if (s='ENDIF') then
  1292. begin
  1293. skip[level]:=false;
  1294. if Level=0 then
  1295. begin
  1296. Message(option_too_many_endif);
  1297. stopOptions(1);
  1298. end;
  1299. dec(level);
  1300. end
  1301. else
  1302. if (not skip[level]) then
  1303. begin
  1304. if (s='DEFINE') then
  1305. begin
  1306. RemoveSep(opts);
  1307. tmp:= GetName(opts);
  1308. if tmp <> '' then
  1309. def_system_macro(tmp);
  1310. end
  1311. else
  1312. if (s='UNDEF') then
  1313. begin
  1314. RemoveSep(opts);
  1315. tmp:= GetName(opts);
  1316. if tmp <> '' then
  1317. undef_system_macro(tmp);
  1318. end
  1319. else
  1320. if (s='WRITE') then
  1321. begin
  1322. Delete(opts,1,1);
  1323. WriteLn(opts);
  1324. end
  1325. else
  1326. if (s='INCLUDE') then
  1327. begin
  1328. Delete(opts,1,1);
  1329. Interpret_file(opts);
  1330. end;
  1331. end;
  1332. end
  1333. else
  1334. begin
  1335. if (opts[1]='-') or (opts[1]='@') then
  1336. begin
  1337. if (not skip[level]) then
  1338. interpret_option(opts,false);
  1339. Option_read:=true;
  1340. end
  1341. else
  1342. Message1(option_illegal_para,opts);
  1343. end;
  1344. end;
  1345. end;
  1346. if Level>0 then
  1347. Message(option_too_less_endif);
  1348. if Not Option_read then
  1349. Message1(option_no_option_found,filename)
  1350. else
  1351. Message1(option_end_reading_configfile,filename);
  1352. Close(f);
  1353. Dec(FileLevel);
  1354. end;
  1355. procedure Toption.Interpret_envvar(const envname : string);
  1356. var
  1357. argstart,
  1358. env,
  1359. pc : pchar;
  1360. arglen : longint;
  1361. quote : set of char;
  1362. hs : string;
  1363. begin
  1364. Message1(option_using_env,envname);
  1365. env:=GetEnvPChar(envname);
  1366. pc:=env;
  1367. if assigned(pc) then
  1368. begin
  1369. repeat
  1370. { skip leading spaces }
  1371. while pc^ in [' ',#9,#13] do
  1372. inc(pc);
  1373. case pc^ of
  1374. #0 :
  1375. break;
  1376. '"' :
  1377. begin
  1378. quote:=['"'];
  1379. inc(pc);
  1380. end;
  1381. '''' :
  1382. begin
  1383. quote:=[''''];
  1384. inc(pc);
  1385. end;
  1386. else
  1387. quote:=[' ',#9,#13];
  1388. end;
  1389. { scan until the end of the argument }
  1390. argstart:=pc;
  1391. while (pc^<>#0) and not(pc^ in quote) do
  1392. inc(pc);
  1393. { create argument }
  1394. arglen:=pc-argstart;
  1395. hs[0]:=chr(arglen);
  1396. move(argstart^,hs[1],arglen);
  1397. interpret_option(hs,true);
  1398. { skip quote }
  1399. if pc^ in quote then
  1400. inc(pc);
  1401. until false;
  1402. end
  1403. else
  1404. Message1(option_no_option_found,'(env) '+envname);
  1405. FreeEnvPChar(env);
  1406. end;
  1407. procedure toption.read_parameters;
  1408. var
  1409. opts : string;
  1410. paramindex : longint;
  1411. begin
  1412. paramindex:=0;
  1413. while paramindex<paramcount do
  1414. begin
  1415. inc(paramindex);
  1416. opts:=system.paramstr(paramindex);
  1417. case opts[1] of
  1418. '@' :
  1419. if not firstpass then
  1420. begin
  1421. Delete(opts,1,1);
  1422. Message1(option_reading_further_from,opts);
  1423. interpret_file(opts);
  1424. end;
  1425. '!' :
  1426. if not firstpass then
  1427. begin
  1428. Delete(opts,1,1);
  1429. Message1(option_reading_further_from,'(env) '+opts);
  1430. interpret_envvar(opts);
  1431. end;
  1432. else
  1433. interpret_option(opts,true);
  1434. end;
  1435. end;
  1436. end;
  1437. procedure toption.parsecmd(cmd:string);
  1438. var
  1439. i,ps : longint;
  1440. opts : string;
  1441. begin
  1442. while (cmd<>'') do
  1443. begin
  1444. while cmd[1]=' ' do
  1445. delete(cmd,1,1);
  1446. i:=pos(' ',cmd);
  1447. if i=0 then
  1448. i:=256;
  1449. opts:=Copy(cmd,1,i-1);
  1450. Delete(cmd,1,i);
  1451. case opts[1] of
  1452. '@' :
  1453. if not firstpass then
  1454. begin
  1455. Delete(opts,1,1);
  1456. Message1(option_reading_further_from,opts);
  1457. interpret_file(opts);
  1458. end;
  1459. '!' :
  1460. if not firstpass then
  1461. begin
  1462. Delete(opts,1,1);
  1463. Message1(option_reading_further_from,'(env) '+opts);
  1464. interpret_envvar(opts);
  1465. end;
  1466. '"' :
  1467. begin
  1468. Delete(opts,1,1);
  1469. ps:=pos('"',cmd);
  1470. if (i<>256) and (ps>0) then
  1471. begin
  1472. opts:=opts + ' '+ copy(cmd,1,ps-1);
  1473. cmd:=copy(cmd,ps+1,255);
  1474. end;
  1475. interpret_option(opts,true);
  1476. end;
  1477. else
  1478. interpret_option(opts,true);
  1479. end;
  1480. end;
  1481. end;
  1482. procedure toption.writequickinfo;
  1483. var
  1484. s : string;
  1485. i : longint;
  1486. procedure addinfo(const hs:string);
  1487. begin
  1488. if s<>'' then
  1489. s:=s+' '+hs
  1490. else
  1491. s:=hs;
  1492. end;
  1493. begin
  1494. s:='';
  1495. i:=0;
  1496. while (i<length(quickinfo)) do
  1497. begin
  1498. inc(i);
  1499. case quickinfo[i] of
  1500. 'S' :
  1501. begin
  1502. inc(i);
  1503. case quickinfo[i] of
  1504. 'O' :
  1505. addinfo(lower(source_info.shortname));
  1506. 'P' :
  1507. addinfo(source_cpu_string);
  1508. else
  1509. IllegalPara('-i'+QuickInfo);
  1510. end;
  1511. end;
  1512. 'T' :
  1513. begin
  1514. inc(i);
  1515. case quickinfo[i] of
  1516. 'O' :
  1517. addinfo(lower(target_info.shortname));
  1518. 'P' :
  1519. AddInfo(target_cpu_string);
  1520. else
  1521. IllegalPara('-i'+QuickInfo);
  1522. end;
  1523. end;
  1524. 'V' :
  1525. AddInfo(version_string);
  1526. 'D' :
  1527. AddInfo(date_string);
  1528. '_' :
  1529. ;
  1530. else
  1531. IllegalPara('-i'+QuickInfo);
  1532. end;
  1533. end;
  1534. if s<>'' then
  1535. begin
  1536. writeln(s);
  1537. stopoptions(0);
  1538. end;
  1539. end;
  1540. procedure TOption.TargetDefines(def:boolean);
  1541. var
  1542. s : string;
  1543. i : integer;
  1544. begin
  1545. if def then
  1546. def_system_macro(target_info.shortname)
  1547. else
  1548. undef_system_macro(target_info.shortname);
  1549. s:=target_info.extradefines;
  1550. while (s<>'') do
  1551. begin
  1552. i:=pos(';',s);
  1553. if i=0 then
  1554. i:=length(s)+1;
  1555. if def then
  1556. def_system_macro(Copy(s,1,i-1))
  1557. else
  1558. undef_system_macro(Copy(s,1,i-1));
  1559. delete(s,1,i);
  1560. end;
  1561. end;
  1562. constructor TOption.create;
  1563. begin
  1564. LogoWritten:=false;
  1565. NoPressEnter:=false;
  1566. FirstPass:=false;
  1567. FileLevel:=0;
  1568. Quickinfo:='';
  1569. ParaIncludePath:=TSearchPathList.Create;
  1570. ParaObjectPath:=TSearchPathList.Create;
  1571. ParaUnitPath:=TSearchPathList.Create;
  1572. ParaLibraryPath:=TSearchPathList.Create;
  1573. FillChar(ParaAlignment,sizeof(ParaAlignment),0);
  1574. end;
  1575. destructor TOption.destroy;
  1576. begin
  1577. ParaIncludePath.Free;
  1578. ParaObjectPath.Free;
  1579. ParaUnitPath.Free;
  1580. ParaLibraryPath.Free;
  1581. end;
  1582. {****************************************************************************
  1583. Callable Routines
  1584. ****************************************************************************}
  1585. function check_configfile(const fn:string;var foundfn:string):boolean;
  1586. function CfgFileExists(const fn:string):boolean;
  1587. begin
  1588. Comment(V_Tried,'Configfile search: '+fn);
  1589. CfgFileExists:=FileExists(fn);
  1590. end;
  1591. var
  1592. configpath : pathstr;
  1593. begin
  1594. foundfn:=fn;
  1595. check_configfile:=true;
  1596. { retrieve configpath }
  1597. {$IFDEF USE_SYSUTILS}
  1598. configpath:=FixPath(GetEnvironmentVariable('PPC_CONFIG_PATH'),false);
  1599. {$ELSE USE_SYSUTILS}
  1600. configpath:=FixPath(dos.getenv('PPC_CONFIG_PATH'),false);
  1601. {$ENDIF USE_SYSUTILS}
  1602. {$ifdef Unix}
  1603. if configpath='' then
  1604. configpath:=CleanPath(FixPath(exepath+'../etc/',false));
  1605. {$endif}
  1606. {
  1607. Order to read configuration file :
  1608. try reading fpc.cfg in :
  1609. 1 - current dir
  1610. 2 - configpath
  1611. 3 - compiler path
  1612. }
  1613. if not FileExists(fn) then
  1614. begin
  1615. {$ifdef Unix}
  1616. {$IFDEF USE_SYSUTILS}
  1617. if (GetEnvironmentVariable('HOME')<>'') and CfgFileExists(FixPath(GetEnvironmentVariable('HOME'),false)+'.'+fn) then
  1618. foundfn:=FixPath(GetEnvironmentVariable('HOME'),false)+'.'+fn
  1619. {$ELSE USE_SYSUTILS}
  1620. if (dos.getenv('HOME')<>'') and CfgFileExists(FixPath(dos.getenv('HOME'),false)+'.'+fn) then
  1621. foundfn:=FixPath(dos.getenv('HOME'),false)+'.'+fn
  1622. {$ENDIF USE_SYSUTILS}
  1623. else
  1624. {$endif}
  1625. if CfgFileExists(configpath+fn) then
  1626. foundfn:=configpath+fn
  1627. else
  1628. {$ifndef Unix}
  1629. if CfgFileExists(exepath+fn) then
  1630. foundfn:=exepath+fn
  1631. else
  1632. {$else}
  1633. if CfgFileExists('/etc/'+fn) then
  1634. foundfn:='/etc/'+fn
  1635. else
  1636. {$endif}
  1637. check_configfile:=false;
  1638. end;
  1639. end;
  1640. procedure read_arguments(cmd:string);
  1641. begin
  1642. option:=coption.create;
  1643. disable_configfile:=false;
  1644. { get default messagefile }
  1645. {$IFDEF USE_SYSUTILS}
  1646. msgfilename:=GetEnvironmentVariable('PPC_ERROR_FILE');
  1647. {$ELSE USE_SYSUTILS}
  1648. msgfilename:=dos.getenv('PPC_ERROR_FILE');
  1649. {$ENDIF USE_SYSUTILS}
  1650. { default configfile can be specified on the commandline,
  1651. remove it first }
  1652. if (cmd<>'') and (cmd[1]='[') then
  1653. begin
  1654. ppccfg:=Copy(cmd,2,pos(']',cmd)-2);
  1655. Delete(cmd,1,pos(']',cmd));
  1656. end
  1657. else
  1658. begin
  1659. ppccfg:='fpc.cfg';
  1660. ppcaltcfg:='ppc386.cfg';
  1661. end;
  1662. { first pass reading of parameters, only -i -v -T etc.}
  1663. option.firstpass:=true;
  1664. if cmd<>'' then
  1665. option.parsecmd(cmd)
  1666. else
  1667. begin
  1668. option.read_parameters;
  1669. { Write only quickinfo }
  1670. if option.quickinfo<>'' then
  1671. option.writequickinfo;
  1672. end;
  1673. option.firstpass:=false;
  1674. { target is set here, for wince the default app type is gui }
  1675. if target_info.system in system_wince then
  1676. apptype:=app_gui;
  1677. { default defines }
  1678. def_system_macro(target_info.shortname);
  1679. def_system_macro('FPC');
  1680. def_system_macro('VER'+version_nr);
  1681. def_system_macro('VER'+version_nr+'_'+release_nr);
  1682. def_system_macro('VER'+version_nr+'_'+release_nr+'_'+patch_nr);
  1683. { Temporary defines, until things settle down }
  1684. { "main" symbol is generated in the main program, and left out of the system unit }
  1685. def_system_macro('FPC_DARWIN_PASCALMAIN');
  1686. def_system_macro('COMPPROCINLINEFIXED');
  1687. if pocall_default = pocall_register then
  1688. def_system_macro('REGCALL');
  1689. { using a case is pretty useless here (FK) }
  1690. { some stuff for TP compatibility }
  1691. {$ifdef i386}
  1692. def_system_macro('CPU86');
  1693. def_system_macro('CPU87');
  1694. {$endif}
  1695. {$ifdef m68k}
  1696. def_system_macro('CPU68');
  1697. {$endif}
  1698. { new processor stuff }
  1699. {$ifdef i386}
  1700. def_system_macro('CPUI386');
  1701. def_system_macro('CPU32');
  1702. def_system_macro('FPC_HAS_TYPE_EXTENDED');
  1703. def_system_macro('FPC_HAS_TYPE_DOUBLE');
  1704. def_system_macro('FPC_HAS_TYPE_SINGLE');
  1705. def_system_macro('FPC_HAS_RESOURCES');
  1706. {$endif}
  1707. {$ifdef m68k}
  1708. def_system_macro('CPU68K');
  1709. def_system_macro('CPUM68K');
  1710. def_system_macro('CPU32');
  1711. def_system_macro('FPC_CURRENCY_IS_INT64');
  1712. def_system_macro('FPC_COMP_IS_INT64');
  1713. {$endif}
  1714. {$ifdef ALPHA}
  1715. def_system_macro('CPUALPHA');
  1716. def_system_macro('CPU64');
  1717. {$endif}
  1718. {$ifdef powerpc}
  1719. def_system_macro('CPUPOWERPC');
  1720. def_system_macro('CPUPOWERPC32');
  1721. def_system_macro('CPU32');
  1722. def_system_macro('FPC_HAS_TYPE_DOUBLE');
  1723. def_system_macro('FPC_HAS_TYPE_SINGLE');
  1724. def_system_macro('FPC_INCLUDE_SOFTWARE_INT64_TO_DOUBLE');
  1725. def_system_macro('FPC_CURRENCY_IS_INT64');
  1726. def_system_macro('FPC_COMP_IS_INT64');
  1727. {$endif}
  1728. {$ifdef POWERPC64}
  1729. def_system_macro('CPUPOWERPC');
  1730. def_system_macro('CPUPOWERPC64');
  1731. def_system_macro('CPU64');
  1732. def_system_macro('FPC_HAS_TYPE_DOUBLE');
  1733. def_system_macro('FPC_HAS_TYPE_SINGLE');
  1734. def_system_macro('FPC_INCLUDE_SOFTWARE_INT64_TO_DOUBLE');
  1735. def_system_macro('FPC_CURRENCY_IS_INT64');
  1736. def_system_macro('FPC_COMP_IS_INT64');
  1737. def_system_macro('FPC_REQUIRES_PROPER_ALIGNMENT');
  1738. {$endif}
  1739. {$ifdef iA64}
  1740. def_system_macro('CPUIA64');
  1741. def_system_macro('CPU64');
  1742. {$endif}
  1743. {$ifdef x86_64}
  1744. def_system_macro('CPUX86_64');
  1745. def_system_macro('CPUAMD64');
  1746. def_system_macro('CPU64');
  1747. { not supported for now, afaik (FK)
  1748. def_system_macro('FPC_HAS_TYPE_FLOAT128'); }
  1749. { win64 doesn't support the legacy fpu }
  1750. if target_info.system<>system_x86_64_win64 then
  1751. def_system_macro('FPC_HAS_TYPE_EXTENDED')
  1752. else
  1753. begin
  1754. def_system_macro('FPC_CURRENCY_IS_INT64');
  1755. def_system_macro('FPC_COMP_IS_INT64');
  1756. undef_system_macro('FPC_HAS_TYPE_EXTENDED');
  1757. end;
  1758. def_system_macro('FPC_HAS_TYPE_DOUBLE');
  1759. def_system_macro('FPC_HAS_TYPE_SINGLE');
  1760. {$endif}
  1761. {$ifdef sparc}
  1762. def_system_macro('CPUSPARC');
  1763. def_system_macro('CPUSPARC32');
  1764. def_system_macro('CPU32');
  1765. def_system_macro('FPC_HAS_TYPE_DOUBLE');
  1766. def_system_macro('FPC_HAS_TYPE_SINGLE');
  1767. def_system_macro('FPC_INCLUDE_SOFTWARE_INT64_TO_DOUBLE');
  1768. def_system_macro('FPC_CURRENCY_IS_INT64');
  1769. def_system_macro('FPC_COMP_IS_INT64');
  1770. def_system_macro('FPC_REQUIRES_PROPER_ALIGNMENT');
  1771. {$endif}
  1772. {$ifdef vis}
  1773. def_system_macro('CPUVIS');
  1774. def_system_macro('CPU32');
  1775. {$endif}
  1776. {$ifdef arm}
  1777. def_system_macro('CPUARM');
  1778. def_system_macro('FPUFPA');
  1779. def_system_macro('CPU32');
  1780. def_system_macro('FPC_HAS_TYPE_DOUBLE');
  1781. def_system_macro('FPC_HAS_TYPE_SINGLE');
  1782. def_system_macro('FPC_INCLUDE_SOFTWARE_INT64_TO_DOUBLE');
  1783. def_system_macro('FPC_CURRENCY_IS_INT64');
  1784. def_system_macro('FPC_COMP_IS_INT64');
  1785. def_system_macro('FPC_REQUIRES_PROPER_ALIGNMENT');
  1786. {$endif arm}
  1787. if source_info.system<>target_info.system then
  1788. def_system_macro('FPC_CROSSCOMPILING');
  1789. if source_info.cpu<>target_info.cpu then
  1790. def_system_macro('FPC_CPUCROSSCOMPILING');
  1791. { read configuration file }
  1792. if (not disable_configfile) and
  1793. (ppccfg<>'') then
  1794. begin
  1795. read_configfile:=check_configfile(ppccfg,ppccfg);
  1796. { Maybe alternative configfile ? }
  1797. if (not read_configfile) and
  1798. (ppcaltcfg<>'') then
  1799. read_configfile:=check_configfile(ppcaltcfg,ppccfg);
  1800. end
  1801. else
  1802. read_configfile := false;
  1803. { Read commandline and configfile }
  1804. param_file:='';
  1805. { read configfile }
  1806. if read_configfile then
  1807. option.interpret_file(ppccfg);
  1808. { read parameters again to override config file }
  1809. if cmd<>'' then
  1810. option.parsecmd(cmd)
  1811. else
  1812. begin
  1813. { Write help pages if no parameters are passed }
  1814. if (paramcount=0) then
  1815. Option.WriteHelpPages;
  1816. option.read_parameters;
  1817. { Write only quickinfo }
  1818. if option.quickinfo<>'' then
  1819. option.writequickinfo;
  1820. end;
  1821. { Stop if errors in options }
  1822. if ErrorCount>0 then
  1823. StopOptions(1);
  1824. { Write logo }
  1825. if option.ParaLogo then
  1826. option.writelogo;
  1827. { Non-core target defines }
  1828. Option.TargetDefines(true);
  1829. { endian define }
  1830. case target_info.endian of
  1831. endian_little :
  1832. begin
  1833. def_system_macro('ENDIAN_LITTLE');
  1834. def_system_macro('FPC_LITTLE_ENDIAN');
  1835. end;
  1836. endian_big :
  1837. begin
  1838. def_system_macro('ENDIAN_BIG');
  1839. def_system_macro('FPC_BIG_ENDIAN');
  1840. end;
  1841. end;
  1842. { abi define }
  1843. case target_info.abi of
  1844. abi_powerpc_sysv :
  1845. def_system_macro('FPC_ABI_SYSV');
  1846. abi_powerpc_aix :
  1847. def_system_macro('FPC_ABI_AIX');
  1848. end;
  1849. {$ifdef m68k}
  1850. if initoptprocessor=MC68020 then
  1851. def_system_macro('CPUM68020');
  1852. {$endif m68k}
  1853. { Check file to compile }
  1854. if param_file='' then
  1855. begin
  1856. Message(option_no_source_found);
  1857. StopOptions(1);
  1858. end;
  1859. {$ifndef Unix}
  1860. param_file:=FixFileName(param_file);
  1861. {$endif}
  1862. {$IFDEF USE_SYSUTILS}
  1863. inputdir := SplitPath(param_file);
  1864. inputfile := SplitName(param_file);
  1865. inputextension := SplitExtension(param_file);
  1866. {$ELSE USE_SYSUTILS}
  1867. fsplit(param_file,inputdir,inputfile,inputextension);
  1868. {$ENDIF USE_SYSUTILS}
  1869. if inputextension='' then
  1870. begin
  1871. if FileExists(inputdir+inputfile+sourceext) then
  1872. inputextension:=sourceext
  1873. else if FileExists(inputdir+inputfile+pasext) then
  1874. inputextension:=pasext
  1875. else if ((m_mac in aktmodeswitches) or
  1876. (tf_p_ext_support in target_info.flags))
  1877. and FileExists(inputdir+inputfile+pext) then
  1878. inputextension:=pext;
  1879. end;
  1880. { Check output dir }
  1881. if (OutputExeDir<>'') and
  1882. not PathExists(OutputExeDir) then
  1883. begin
  1884. Message1(general_e_path_does_not_exist,OutputExeDir);
  1885. StopOptions(1);
  1886. end;
  1887. { Add paths specified with parameters to the searchpaths }
  1888. UnitSearchPath.AddList(option.ParaUnitPath,true);
  1889. ObjectSearchPath.AddList(option.ParaObjectPath,true);
  1890. IncludeSearchPath.AddList(option.ParaIncludePath,true);
  1891. LibrarySearchPath.AddList(option.ParaLibraryPath,true);
  1892. { add unit environment and exepath to the unit search path }
  1893. if inputdir<>'' then
  1894. Unitsearchpath.AddPath(inputdir,true);
  1895. if not disable_configfile then
  1896. begin
  1897. {$IFDEF USE_SYSUTILS}
  1898. UnitSearchPath.AddPath(GetEnvironmentVariable(target_info.unit_env),false);
  1899. {$ELSE USE_SYSUTILS}
  1900. UnitSearchPath.AddPath(dos.getenv(target_info.unit_env),false);
  1901. {$ENDIF USE_SYSUTILS}
  1902. end;
  1903. {$ifdef Unix}
  1904. {$IFDEF USE_SYSUTILS}
  1905. fpcdir:=FixPath(GetEnvironmentVariable('FPCDIR'),false);
  1906. {$ELSE USE_SYSUTILS}
  1907. fpcdir:=FixPath(getenv('FPCDIR'),false);
  1908. {$ENDIF USE_SYSUTILS}
  1909. if fpcdir='' then
  1910. begin
  1911. if PathExists('/usr/local/lib/fpc/'+version_string) then
  1912. fpcdir:='/usr/local/lib/fpc/'+version_string+'/'
  1913. else
  1914. fpcdir:='/usr/lib/fpc/'+version_string+'/';
  1915. end;
  1916. {$else}
  1917. {$IFDEF USE_SYSUTILS}
  1918. fpcdir:=FixPath(GetEnvironmentVariable('FPCDIR'),false);
  1919. {$ELSE USE_SYSUTILS}
  1920. fpcdir:=FixPath(getenv('FPCDIR'),false);
  1921. {$ENDIF USE_SYSUTILS}
  1922. if fpcdir='' then
  1923. begin
  1924. fpcdir:=ExePath+'../';
  1925. if not(PathExists(fpcdir+'/units')) and
  1926. not(PathExists(fpcdir+'/rtl')) then
  1927. fpcdir:=fpcdir+'../';
  1928. end;
  1929. {$endif}
  1930. { first try development RTL, else use the default installation path }
  1931. if not disable_configfile then
  1932. begin
  1933. if PathExists(FpcDir+'rtl') then
  1934. if tf_use_8_3 in Source_Info.Flags then
  1935. UnitSearchPath.AddPath(FpcDir+'rtl/'+target_os_string,false)
  1936. else
  1937. UnitSearchPath.AddPath(FpcDir+'rtl/'+target_full_string,false)
  1938. else
  1939. if tf_use_8_3 in Source_Info.Flags then
  1940. UnitSearchPath.AddPath(FpcDir+'units/'+target_os_string+'/rtl',false)
  1941. else
  1942. UnitSearchPath.AddPath(FpcDir+'units/'+target_full_string+'/rtl',false);
  1943. end;
  1944. { Add exepath if the exe is not in the current dir, because that is always searched already.
  1945. Do not add it when linking on the target because then we can maybe already find
  1946. .o files that are not for the target }
  1947. if (ExePath<>GetCurrentDir) and
  1948. not(cs_link_on_target in initglobalswitches) then
  1949. UnitSearchPath.AddPath(ExePath,false);
  1950. { Add unit dir to the object and library path }
  1951. objectsearchpath.AddList(unitsearchpath,false);
  1952. librarysearchpath.AddList(unitsearchpath,false);
  1953. { maybe override debug info format }
  1954. if (paratargetdbg<>dbg_none) then
  1955. set_target_dbg(paratargetdbg);
  1956. { maybe override assembler }
  1957. if (paratargetasm<>as_none) then
  1958. set_target_asm(paratargetasm);
  1959. { switch assembler if it's binary and we got -a on the cmdline }
  1960. if (cs_asm_leave in initglobalswitches) and
  1961. (af_outputbinary in target_asm.flags) then
  1962. begin
  1963. Message(option_switch_bin_to_src_assembler);
  1964. set_target_asm(target_info.assemextern);
  1965. end;
  1966. if (target_asm.supported_target <> system_any) and
  1967. (target_asm.supported_target <> target_info.system) then
  1968. begin
  1969. Message2(option_incompatible_asm,target_asm.idtxt,target_info.name);
  1970. set_target_asm(target_info.assemextern);
  1971. Message1(option_asm_forced,target_asm.idtxt);
  1972. end;
  1973. { turn off stripping if compiling with debuginfo or profile }
  1974. if (cs_debuginfo in initmoduleswitches) or
  1975. (cs_profile in initmoduleswitches) then
  1976. exclude(initglobalswitches,cs_link_strip);
  1977. { force fpu emulation on arm/wince }
  1978. if target_info.system=system_arm_wince then
  1979. include(initmoduleswitches,cs_fp_emulation);
  1980. {$ifdef x86_64}
  1981. {$warning HACK: turn off smartlinking}
  1982. exclude(initmoduleswitches,cs_create_smart);
  1983. {$endif}
  1984. if not LinkTypeSetExplicitly then
  1985. set_default_link_type;
  1986. { Default alignment settings,
  1987. 1. load the defaults for the target
  1988. 2. override with generic optimizer setting (little size)
  1989. 3. override with the user specified -Oa }
  1990. UpdateAlignment(initalignment,target_info.alignment);
  1991. if (cs_littlesize in aktglobalswitches) then
  1992. begin
  1993. initalignment.procalign:=1;
  1994. initalignment.jumpalign:=1;
  1995. initalignment.loopalign:=1;
  1996. end;
  1997. UpdateAlignment(initalignment,option.paraalignment);
  1998. set_system_macro('FPC_VERSION',version_nr);
  1999. set_system_macro('FPC_RELEASE',release_nr);
  2000. set_system_macro('FPC_PATCH',patch_nr);
  2001. option.free;
  2002. Option:=nil;
  2003. end;
  2004. initialization
  2005. coption:=toption;
  2006. finalization
  2007. if assigned(option) then
  2008. option.free;
  2009. end.