123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136 |
- {
- $Id$
- Copyright (c) 1998-2002 by Florian Klaempfl and Peter Vreman
- Reads command line options and config files
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- ****************************************************************************
- }
- unit options;
- {$i fpcdefs.inc}
- interface
- uses
- globtype,globals,verbose,systems,cpuinfo;
- type
- TOption=class
- FirstPass,
- NoPressEnter,
- DoWriteLogo : boolean;
- FileLevel : longint;
- QuickInfo : string;
- ParaIncludePath,
- ParaUnitPath,
- ParaObjectPath,
- ParaLibraryPath : TSearchPathList;
- ParaAlignment : TAlignmentInfo;
- Constructor Create;
- Destructor Destroy;override;
- procedure WriteLogo;
- procedure WriteInfo;
- procedure WriteHelpPages;
- procedure WriteQuickInfo;
- procedure IllegalPara(const opt:string);
- function Unsetbool(var Opts:string; Pos: Longint):boolean;
- procedure interpret_proc_specific_options(const opt:string);virtual;
- procedure interpret_option(const opt :string;ispara:boolean);
- procedure Interpret_envvar(const envname : string);
- procedure Interpret_file(const filename : string);
- procedure Read_Parameters;
- procedure parsecmd(cmd:string);
- procedure TargetDefines(def:boolean);
- end;
- TOptionClass=class of toption;
- var
- coption : TOptionClass;
- procedure read_arguments(cmd:string);
- implementation
- uses
- widestr,
- {$ifdef Delphi}
- dmisc,
- {$else Delphi}
- dos,
- {$endif Delphi}
- version,
- cutils,cmsgs
- {$ifdef BrowserLog}
- ,browlog
- {$endif BrowserLog}
- ;
- const
- page_size = 24;
- var
- option : toption;
- read_configfile, { read config file, set when a cfgfile is found }
- disable_configfile,
- target_is_set : boolean; { do not allow contradictory target settings }
- asm_is_set : boolean; { -T also change initoutputformat if not set idrectly }
- fpcdir,
- ppccfg,
- ppcaltcfg,
- param_file : string; { file to compile specified on the commandline }
- {****************************************************************************
- Defines
- ****************************************************************************}
- procedure def_symbol(const s : string);
- begin
- if s='' then
- exit;
- initdefines.insert(upper(s));
- Message1(option_defining_symbol,s);
- end;
- procedure undef_symbol(const s : string);
- begin
- if s='' then
- exit;
- InitDefines.Remove(s);
- Message1(option_undefining_symbol,s);
- end;
- function check_symbol(const s:string):boolean;
- begin
- check_symbol:=(initdefines.find(s)<>nil);
- end;
- procedure set_default_link_type;
- begin
- { win32 and wdosx need smartlinking by default to prevent including too much
- dll dependencies }
- if (target_info.system in [system_i386_win32,system_i386_wdosx]) then
- begin
- def_symbol('FPC_LINK_SMART');
- undef_symbol('FPC_LINK_STATIC');
- undef_symbol('FPC_LINK_DYNAMIC');
- initglobalswitches:=initglobalswitches+[cs_link_smart];
- initglobalswitches:=initglobalswitches-[cs_link_shared,cs_link_static];
- end
- else
- begin
- undef_symbol('FPC_LINK_SMART');
- def_symbol('FPC_LINK_STATIC');
- undef_symbol('FPC_LINK_DYNAMIC');
- initglobalswitches:=initglobalswitches+[cs_link_static];
- initglobalswitches:=initglobalswitches-[cs_link_shared,cs_link_smart];
- end;
- end;
- {****************************************************************************
- Toption
- ****************************************************************************}
- procedure StopOptions(err:longint);
- begin
- if assigned(Option) then
- begin
- Option.free;
- Option:=nil;
- end;
- DoneVerbose;
- Stop(err);
- end;
- procedure Toption.WriteLogo;
- var
- p : pchar;
- begin
- p:=MessagePchar(option_logo);
- while assigned(p) do
- Comment(V_Normal,GetMsgLine(p));
- end;
- procedure Toption.WriteInfo;
- var
- p : pchar;
- hs,hs1,s : string;
- target : tsystem;
- begin
- p:=MessagePchar(option_info);
- while assigned(p) do
- begin
- s:=GetMsgLine(p);
- { list OS Targets }
- if pos('$OSTARGETS',s)>0 then
- begin
- for target:=low(tsystem) to high(tsystem) do
- if assigned(targetinfos[target]) then
- begin
- hs:=s;
- hs1:=targetinfos[target]^.name;
- if tf_under_development in targetinfos[target]^.flags then
- hs1:=hs1+' (under development)';
- Replace(hs,'$OSTARGETS',hs1);
- Comment(V_Normal,hs);
- end;
- end
- else
- Comment(V_Normal,s);
- end;
- StopOptions(0);
- end;
- procedure Toption.WriteHelpPages;
- function PadEnd(s:string;i:longint):string;
- begin
- while (length(s)<i) do
- s:=s+' ';
- PadEnd:=s;
- end;
- var
- lastident,
- j,outline,
- ident,
- lines : longint;
- show : boolean;
- opt : string[32];
- input,
- s : string;
- p : pchar;
- begin
- WriteLogo;
- Lines:=4;
- Message1(option_usage,system.paramstr(0));
- lastident:=0;
- p:=MessagePChar(option_help_pages);
- while assigned(p) do
- begin
- { get a line and reset }
- s:=GetMsgLine(p);
- ident:=0;
- show:=false;
- { parse options }
- case s[1] of
- {$ifdef UNITALIASES}
- 'a',
- {$endif}
- {$ifdef EXTDEBUG}
- 'e',
- {$endif EXTDEBUG}
- {$ifdef i386}
- '3',
- {$endif}
- {$ifdef powerpc}
- 'P',
- {$endif}
- {$ifdef vis}
- 'V',
- {$endif}
- {$ifdef sparc}
- 'S',
- {$endif}
- {$ifdef m68k}
- '6',
- {$endif}
- '*' : show:=true;
- end;
- if show then
- begin
- case s[2] of
- {$ifdef GDB}
- 'g',
- {$endif}
- {$ifdef Unix}
- 'L',
- {$endif}
- {$ifdef os2}
- 'O',
- {$endif}
- '*' : show:=true;
- else
- show:=false;
- end;
- end;
- { now we may show the message or not }
- if show then
- begin
- case s[3] of
- '0' : begin
- ident:=0;
- outline:=0;
- end;
- '1' : begin
- ident:=2;
- outline:=7;
- end;
- '2' : begin
- ident:=6;
- outline:=11;
- end;
- '3' : begin
- ident:=9;
- outline:=6;
- end;
- end;
- j:=pos('_',s);
- opt:=Copy(s,4,j-4);
- if opt='*' then
- opt:=''
- else
- if opt=' ' then
- opt:=PadEnd(opt,outline)
- else
- opt:=PadEnd('-'+opt,outline);
- if (ident=0) and (lastident<>0) then
- begin
- Comment(V_Normal,'');
- inc(Lines);
- end;
- { page full ? }
- if (lines >= page_size - 1) then
- begin
- if not NoPressEnter then
- begin
- Message(option_help_press_enter);
- readln(input);
- if upper(input)='Q' then
- StopOptions(0);
- end;
- lines:=0;
- end;
- Comment(V_Normal,PadEnd('',ident)+opt+Copy(s,j+1,255));
- LastIdent:=Ident;
- inc(Lines);
- end;
- end;
- StopOptions(0);
- end;
- procedure Toption.IllegalPara(const opt:string);
- begin
- Message1(option_illegal_para,opt);
- Message(option_help_pages_para);
- StopOptions(1);
- end;
- function Toption.Unsetbool(var Opts:string; Pos: Longint):boolean;
- { checks if the character after pos in Opts is a + or a - and returns resp.
- false or true. If it is another character (or none), it also returns false }
- begin
- UnsetBool := false;
- if Length(Opts)>Pos then
- begin
- inc(Pos);
- UnsetBool := Opts[Pos] = '-';
- if Opts[Pos] in ['-','+']then
- delete(Opts,Pos,1);
- end;
- end;
- procedure TOption.interpret_proc_specific_options(const opt:string);
- begin
- end;
- procedure TOption.interpret_option(const opt:string;ispara:boolean);
- var
- code : integer;
- c : char;
- more : string;
- major,minor : longint;
- error : integer;
- j,l : longint;
- d : DirStr;
- e : ExtStr;
- s : string;
- forceasm : tasm;
- begin
- if opt='' then
- exit;
- { only parse define,undef,target,verbosity and link options the firsttime }
- if firstpass and
- not((opt[1]='-') and (opt[2] in ['i','d','v','T','u','n','X'])) then
- exit;
- Message1(option_handling_option,opt);
- case opt[1] of
- '-' :
- begin
- more:=Copy(opt,3,255);
- if firstpass then
- Message1(option_interpreting_firstpass_option,opt)
- else
- Message1(option_interpreting_option,opt);
- case opt[2] of
- '?' :
- WriteHelpPages;
- 'a' :
- begin
- include(initglobalswitches,cs_asm_leave);
- j:=1;
- while j<=length(more) do
- begin
- case more[j] of
- 'l' :
- include(initglobalswitches,cs_asm_source);
- 'r' :
- include(initglobalswitches,cs_asm_regalloc);
- 't' :
- include(initglobalswitches,cs_asm_tempalloc);
- 'n' :
- include(initglobalswitches,cs_asm_nodes);
- 'p' :
- begin
- exclude(initglobalswitches,cs_asm_leave);
- if UnsetBool(More, 0) then
- exclude(initglobalswitches,cs_asm_pipe)
- else
- include(initglobalswitches,cs_asm_pipe);
- end;
- '-' :
- initglobalswitches:=initglobalswitches -
- [cs_asm_leave, cs_asm_source,cs_asm_regalloc, cs_asm_tempalloc,
- cs_asm_nodes, cs_asm_pipe];
- else
- IllegalPara(opt);
- end;
- inc(j);
- end;
- end;
- 'A' :
- begin
- if set_target_asm_by_string(More) then
- asm_is_set:=true
- else
- IllegalPara(opt);
- end;
- 'b' :
- begin
- {$ifdef supportbrowser}
- if UnsetBool(More,0) then
- begin
- exclude(initmoduleswitches,cs_browser);
- exclude(initmoduleswitches,cs_local_browser);
- {$ifdef BrowserLog}
- exclude(initglobalswitches,cs_browser_log);
- {$endif}
- end
- else
- begin
- include(initmoduleswitches,cs_browser);
- {$ifdef BrowserLog}
- include(initglobalswitches,cs_browser_log);
- {$endif}
- end;
- if More<>'' then
- if (More='l') or (More='l+') then
- include(initmoduleswitches,cs_local_browser)
- else
- if More='l-' then
- exclude(initmoduleswitches,cs_local_browser)
- else
- {$ifdef BrowserLog}
- browserlog.elements_to_list.insert(more);
- {$else}
- IllegalPara(opt);
- {$endif}
- {$endif supportbrowser}
- end;
- 'B' :
- do_build:=not UnSetBool(more,0);
- 'C' :
- begin
- j:=1;
- while j<=length(more) do
- begin
- case more[j] of
- 'a' :
- Message2(option_obsolete_switch_use_new,'-Ca','-Or');
- 'c' :
- begin
- if not SetAktProcCall(upper(copy(more,j+1,length(more)-j)),true) then
- IllegalPara(opt);
- break;
- end;
- {$ifdef cpufpemu}
- 'e' :
- begin
- If UnsetBool(More, j) then
- exclude(initmoduleswitches,cs_fp_emulation)
- Else
- include(initmoduleswitches,cs_fp_emulation);
- end;
- {$endif cpufpemu}
- 'f' :
- begin
- s:=upper(copy(more,j+1,length(more)-j));
- if not(SetFpuType(s,true)) then
- IllegalPara(opt);
- break;
- end;
- 'g' :
- include(initmoduleswitches,cs_create_pic);
- 'h' :
- begin
- val(copy(more,j+1,length(more)-j),heapsize,code);
- if (code<>0) or
- {$WARNING Is the upper limit for heapsize needed / useful?}
- { (heapsize>=67107840) or }
- (heapsize<1024) then
- IllegalPara(opt);
- break;
- end;
- 'i' :
- If UnsetBool(More, j) then
- exclude(initlocalswitches,cs_check_io)
- else
- include(initlocalswitches,cs_check_io);
- 'n' :
- If UnsetBool(More, j) then
- exclude(initglobalswitches,cs_link_extern)
- Else
- include(initglobalswitches,cs_link_extern);
- 'o' :
- If UnsetBool(More, j) then
- exclude(initlocalswitches,cs_check_overflow)
- Else
- include(initlocalswitches,cs_check_overflow);
- 'p' :
- begin
- s:=upper(copy(more,j+1,length(more)-j));
- if not(SetProcessor(s,true)) then
- IllegalPara(opt);
- break;
- end;
- 'r' :
- If UnsetBool(More, j) then
- exclude(initlocalswitches,cs_check_range)
- Else
- include(initlocalswitches,cs_check_range);
- 'R' :
- If UnsetBool(More, j) then
- begin
- exclude(initlocalswitches,cs_check_range);
- exclude(initlocalswitches,cs_check_object);
- end
- Else
- begin
- include(initlocalswitches,cs_check_range);
- include(initlocalswitches,cs_check_object);
- end;
- 's' :
- begin
- val(copy(more,j+1,length(more)-j),stacksize,code);
- if (code<>0) or (stacksize>=67107840) or (stacksize<1024) then
- IllegalPara(opt);
- break;
- end;
- 't' :
- If UnsetBool(More, j) then
- exclude(initlocalswitches,cs_check_stack)
- Else
- include(initlocalswitches,cs_check_stack);
- 'D' :
- If UnsetBool(More, j) then
- exclude(initmoduleswitches,cs_create_dynamic)
- Else
- include(initmoduleswitches,cs_create_dynamic);
- 'X' :
- If UnsetBool(More, j) then
- exclude(initmoduleswitches,cs_create_smart)
- Else
- include(initmoduleswitches,cs_create_smart);
- else
- IllegalPara(opt);
- end;
- inc(j);
- end;
- end;
- 'd' :
- def_symbol(more);
- 'D' :
- begin
- include(initglobalswitches,cs_link_deffile);
- j:=1;
- while j<=length(more) do
- begin
- case more[j] of
- 'd' :
- begin
- description:=Copy(more,j+1,255);
- break;
- end;
- 'v' :
- begin
- dllversion:=Copy(more,j+1,255);
- l:=pos('.',dllversion);
- dllminor:=0;
- error:=0;
- if l>0 then
- begin
- valint(copy(dllversion,l+1,255),minor,error);
- if (error=0) and
- (minor>=0) and (minor<=$ffff) then
- dllminor:=minor
- else
- if error=0 then
- error:=1;
- end;
- if l=0 then
- l:=256;
- dllmajor:=1;
- if error=0 then
- valint(copy(dllversion,1,l-1),major,error);
- if (error=0) and (major>=0) and (major<=$ffff) then
- dllmajor:=major
- else
- if error=0 then
- error:=1;
- if error<>0 then
- Message1(scan_w_wrong_version_ignored,dllversion);
- break;
- end;
- 'w' :
- usewindowapi:=true;
- '-' :
- begin
- exclude(initglobalswitches,cs_link_deffile);
- usewindowapi:=false;
- end;
- else
- IllegalPara(opt);
- end;
- inc(j);
- end;
- end;
- 'e' :
- exepath:=FixPath(FExpand(More),true);
- 'E' :
- begin
- if UnsetBool(More, 0) then
- exclude(initglobalswitches,cs_link_extern)
- else
- include(initglobalswitches,cs_link_extern);
- end;
- 'F' :
- begin
- c:=more[1];
- Delete(more,1,1);
- DefaultReplacements(More);
- case c of
- 'c' :
- begin
- if not(cpavailable(more)) then
- Message1(option_code_page_not_available,more)
- else
- initsourcecodepage:=more;
- end;
- 'D' :
- utilsdirectory:=FixPath(FExpand(More),true);
- 'e' :
- SetRedirectFile(More);
- 'E' :
- OutputExeDir:=FixPath(FExpand(More),true);
- 'i' :
- begin
- if ispara then
- ParaIncludePath.AddPath(More,false)
- else
- includesearchpath.AddPath(More,true);
- end;
- 'g' :
- Message2(option_obsolete_switch_use_new,'-Fg','-Fl');
- 'l' :
- begin
- if ispara then
- ParaLibraryPath.AddPath(More,false)
- else
- LibrarySearchPath.AddPath(More,true);
- end;
- 'L' :
- begin
- if More<>'' then
- ParaDynamicLinker:=More
- else
- IllegalPara(opt);
- end;
- 'o' :
- begin
- if ispara then
- ParaObjectPath.AddPath(More,false)
- else
- ObjectSearchPath.AddPath(More,true);
- end;
- 'r' :
- Msgfilename:=More;
- 'u' :
- begin
- if ispara then
- ParaUnitPath.AddPath(More,false)
- else
- unitsearchpath.AddPath(More,true);
- end;
- 'U' :
- OutputUnitDir:=FixPath(FExpand(More),true);
- else
- IllegalPara(opt);
- end;
- end;
- 'g' : begin
- if UnsetBool(More, 0) then
- begin
- exclude(initmoduleswitches,cs_debuginfo);
- exclude(initglobalswitches,cs_gdb_dbx);
- exclude(initglobalswitches,cs_gdb_gsym);
- exclude(initglobalswitches,cs_gdb_heaptrc);
- exclude(initglobalswitches,cs_gdb_lineinfo);
- exclude(initglobalswitches,cs_checkpointer);
- end
- else
- begin
- {$ifdef GDB}
- include(initmoduleswitches,cs_debuginfo);
- {$else GDB}
- Message(option_no_debug_support);
- Message(option_no_debug_support_recompile_fpc);
- {$endif GDB}
- end;
- {$ifdef GDB}
- if not RelocSectionSetExplicitly then
- RelocSection:=false;
- j:=1;
- while j<=length(more) do
- begin
- case more[j] of
- 'd' :
- begin
- if UnsetBool(More, j) then
- exclude(initglobalswitches,cs_gdb_dbx)
- else
- include(initglobalswitches,cs_gdb_dbx);
- end;
- 'g' :
- begin
- if UnsetBool(More, j) then
- exclude(initglobalswitches,cs_gdb_gsym)
- else
- include(initglobalswitches,cs_gdb_gsym);
- end;
- 'h' :
- begin
- if UnsetBool(More, j) then
- exclude(initglobalswitches,cs_gdb_heaptrc)
- else
- include(initglobalswitches,cs_gdb_heaptrc);
- end;
- 'l' :
- begin
- if UnsetBool(More, j) then
- exclude(initglobalswitches,cs_gdb_lineinfo)
- else
- include(initglobalswitches,cs_gdb_lineinfo);
- end;
- 'c' :
- begin
- if UnsetBool(More, j) then
- exclude(initglobalswitches,cs_checkpointer)
- else
- include(initglobalswitches,cs_checkpointer);
- end;
- 'v' :
- begin
- if UnsetBool(More, j) then
- exclude(initglobalswitches,cs_gdb_valgrind)
- else
- include(initglobalswitches,cs_gdb_valgrind);
- end;
- 'w' :
- begin
- if UnsetBool(More, j) then
- exclude(initglobalswitches,cs_gdb_dwarf)
- else
- include(initglobalswitches,cs_gdb_dwarf);
- end;
- else
- IllegalPara(opt);
- end;
- inc(j);
- end;
- {$endif GDB}
- end;
- 'h' :
- begin
- NoPressEnter:=true;
- WriteHelpPages;
- end;
- 'i' :
- begin
- if More='' then
- WriteInfo
- else
- QuickInfo:=QuickInfo+More;
- end;
- 'I' :
- begin
- if ispara then
- ParaIncludePath.AddPath(More,false)
- else
- includesearchpath.AddPath(More,false);
- end;
- 'k' :
- begin
- if more<>'' then
- ParaLinkOptions:=ParaLinkOptions+' '+More
- else
- IllegalPara(opt);
- end;
- 'l' :
- DoWriteLogo:=not UnSetBool(more,0);
- 'm' :
- parapreprocess:=not UnSetBool(more,0);
- 'n' :
- begin
- if More='' then
- disable_configfile:=true
- else
- IllegalPara(opt);
- end;
- 'o' :
- begin
- if More<>'' then
- Fsplit(More,d,OutputFile,e)
- else
- IllegalPara(opt);
- end;
- 'p' :
- begin
- if UnsetBool(More, 0) then
- begin
- initmoduleswitches:=initmoduleswitches-[cs_profile];
- undef_symbol('FPC_PROFILE');
- end
- else
- if Length(More)=0 then
- IllegalPara(opt)
- else
- case more[1] of
- 'g' : if UnsetBool(more, 1) then
- begin
- exclude(initmoduleswitches,cs_profile);
- undef_symbol('FPC_PROFILE');
- end
- else
- begin
- include(initmoduleswitches,cs_profile);
- def_symbol('FPC_PROFILE');
- end;
- else
- IllegalPara(opt);
- end;
- end;
- {$ifdef Unix}
- 'P' : ; { Ignore used by fpc.pp }
- {$endif Unix}
- 's' :
- begin
- if UnsetBool(More, 0) then
- begin
- initglobalswitches:=initglobalswitches-[cs_asm_extern,cs_link_extern];
- if more<>'' then
- IllegalPara(opt);
- end
- else
- begin
- initglobalswitches:=initglobalswitches+[cs_asm_extern,cs_link_extern];
- if more='h' then
- initglobalswitches:=initglobalswitches-[cs_link_on_target]
- else if more='t' then
- initglobalswitches:=initglobalswitches+[cs_link_on_target]
- else if more='r' then
- initglobalswitches:=initglobalswitches+[cs_asm_leave,cs_no_regalloc]
- else if more<>'' then
- IllegalPara(opt);
- end;
- end;
- 'M' :
- begin
- more:=Upper(more);
- if not SetCompileMode(more, true) then
- IllegalPara(opt);
- end;
- 'S' :
- begin
- if more[1]='I' then
- begin
- if upper(more)='ICOM' then
- initinterfacetype:=it_interfacecom
- else if upper(more)='ICORBA' then
- initinterfacetype:=it_interfacecorba
- else
- IllegalPara(opt);
- end
- else
- begin
- j:=1;
- while j<=length(more) do
- begin
- case more[j] of
- '2' : //an alternative to -Mobjfpc
- SetCompileMode('OBJFPC',true);
- 'a' :
- include(initlocalswitches,cs_do_assertion);
- 'c' :
- include(initmoduleswitches,cs_support_c_operators);
- 'd' : //an alternative to -Mdelphi
- SetCompileMode('DELPHI',true);
- 'e' :
- begin
- SetErrorFlags(copy(more,j+1,length(more)));
- break;
- end;
- 'g' :
- include(initmoduleswitches,cs_support_goto);
- 'h' :
- include(initlocalswitches,cs_ansistrings);
- 'i' :
- include(initmoduleswitches,cs_support_inline);
- 'm' :
- include(initmoduleswitches,cs_support_macro);
- 'o' : //an alternative to -Mtp
- SetCompileMode('TP',true);
- 'p' : //an alternative to -Mgpc
- SetCompileMode('GPC',true);
- 's' :
- include(initglobalswitches,cs_constructor_name);
- 't' :
- include(initmoduleswitches,cs_static_keyword);
- '-' :
- begin
- exclude(initglobalswitches,cs_constructor_name);
- initlocalswitches:=InitLocalswitches - [cs_do_assertion, cs_ansistrings];
- initmoduleswitches:=initmoduleswitches - [cs_support_c_operators, cs_support_goto,
- cs_support_inline, cs_support_macro,
- cs_static_keyword];
- end;
- else
- IllegalPara(opt);
- end;
- inc(j);
- end;
- end;
- end;
- 'T' :
- begin
- more:=Upper(More);
- if not target_is_set then
- begin
- { remove old target define }
- TargetDefines(false);
- { Save assembler if set }
- if asm_is_set then
- forceasm:=target_asm.id;
- { load new target }
- if not(set_target_by_string(More)) then
- IllegalPara(opt);
- { also initialize assembler if not explicitly set }
- if asm_is_set then
- set_target_asm(forceasm);
- { set new define }
- TargetDefines(true);
- target_is_set:=true;
- end
- else
- if More<>upper(target_info.shortname) then
- Message1(option_target_is_already_set,target_info.shortname);
- end;
- 'u' :
- undef_symbol(upper(More));
- 'U' :
- begin
- j:=1;
- while j<=length(more) do
- begin
- case more[j] of
- {$ifdef UNITALIASES}
- 'a' :
- begin
- AddUnitAlias(Copy(More,j+1,255));
- break;
- end;
- {$endif UNITALIASES}
- 'n' :
- exclude(initglobalswitches,cs_check_unit_name);
- 'p' :
- begin
- Message2(option_obsolete_switch_use_new,'-Up','-Fu');
- break;
- end;
- 'r' :
- do_release:=true;
- 's' :
- include(initmoduleswitches,cs_compilesystem);
- '-' :
- begin
- exclude(initmoduleswitches,cs_compilesystem);
- exclude(initglobalswitches,cs_check_unit_name);
- end;
- else
- IllegalPara(opt);
- end;
- inc(j);
- end;
- end;
- 'v' :
- begin
- if not setverbosity(More) then
- IllegalPara(opt);
- end;
- 'V' : ; { Ignore used by fpc }
- 'W' :
- begin
- j:=1;
- while j<=length(More) do
- begin
- case More[j] of
- 'B':
- begin
- { -WB200000 means set trefered base address
- to $200000, but does not change relocsection boolean
- this way we can create both relocatble and
- non relocatable DLL at a specific base address PM }
- if (length(More)>j) then
- begin
- if DLLImageBase=nil then
- DLLImageBase:=StringDup(Copy(More,j+1,255));
- end
- else
- begin
- RelocSection:=true;
- RelocSectionSetExplicitly:=true;
- end;
- break;
- end;
- 'C':
- begin
- if UnsetBool(More, j) then
- apptype:=app_gui
- else
- apptype:=app_cui;
- end;
- 'D':
- begin
- UseDeffileForExports:=not UnsetBool(More, j);
- UseDeffileForExportsSetExplicitly:=true;
- end;
- 'F':
- begin
- if UnsetBool(More, j) then
- apptype:=app_cui
- else
- apptype:=app_fs;
- end;
- 'G':
- begin
- if UnsetBool(More, j) then
- apptype:=app_cui
- else
- apptype:=app_gui;
- end;
- 'T':
- begin
- if UnsetBool(More, j) then
- apptype:=app_cui
- else
- apptype:=app_tool;
- end;
- 'N':
- begin
- RelocSection:=UnsetBool(More,j);
- RelocSectionSetExplicitly:=true;
- end;
- 'R':
- begin
- { support -WR+ / -WR- as synonyms to -WR / -WN }
- RelocSection:=not UnsetBool(More,j);
- RelocSectionSetExplicitly:=true;
- end;
- else
- IllegalPara(opt);
- end;
- inc(j);
- end;
- end;
- 'X' :
- begin
- j:=1;
- while j<=length(more) do
- begin
- case More[j] of
- 'i' :
- include(initglobalswitches,cs_link_internal);
- 'm' :
- include(initglobalswitches,cs_link_map);
- 'f' :
- include(initglobalswitches,cs_link_pthread);
- 's' :
- include(initglobalswitches,cs_link_strip);
- 'c' : Cshared:=TRUE;
- 't' :
- include(initglobalswitches,cs_link_staticflag);
- 'D' :
- begin
- def_symbol('FPC_LINK_DYNAMIC');
- undef_symbol('FPC_LINK_SMART');
- undef_symbol('FPC_LINK_STATIC');
- exclude(initglobalswitches,cs_link_static);
- exclude(initglobalswitches,cs_link_smart);
- include(initglobalswitches,cs_link_shared);
- LinkTypeSetExplicitly:=true;
- end;
- 'd' : Dontlinkstdlibpath:=TRUE;
- 'P' : Begin
- utilsprefix:=Copy(more,2,length(More)-1);
- More:='';
- End;
- 'r' : Begin
- rlinkpath:=Copy(more,2,length(More)-1);
- More:='';
- end;
- 'S' :
- begin
- def_symbol('FPC_LINK_STATIC');
- undef_symbol('FPC_LINK_SMART');
- undef_symbol('FPC_LINK_DYNAMIC');
- include(initglobalswitches,cs_link_static);
- exclude(initglobalswitches,cs_link_smart);
- exclude(initglobalswitches,cs_link_shared);
- LinkTypeSetExplicitly:=true;
- end;
- 'X' :
- begin
- def_symbol('FPC_LINK_SMART');
- undef_symbol('FPC_LINK_STATIC');
- undef_symbol('FPC_LINK_DYNAMIC');
- exclude(initglobalswitches,cs_link_static);
- include(initglobalswitches,cs_link_smart);
- exclude(initglobalswitches,cs_link_shared);
- LinkTypeSetExplicitly:=true;
- end;
- '-' :
- begin
- exclude(initglobalswitches,cs_link_staticflag);
- exclude(initglobalswitches,cs_link_strip);
- exclude(initglobalswitches,cs_link_map);
- set_default_link_type;
- end;
- else
- IllegalPara(opt);
- end;
- inc(j);
- end;
- end;
- { give processor specific options a chance }
- else
- interpret_proc_specific_options(opt);
- end;
- end;
- '@' :
- begin
- Message(option_no_nested_response_file);
- StopOptions(1);
- end;
- else
- begin
- if (length(param_file)<>0) then
- Message(option_only_one_source_support);
- param_file:=opt;
- Message1(option_found_file,opt);
- end;
- end;
- end;
- procedure Toption.Interpret_file(const filename : string);
- procedure RemoveSep(var fn:string);
- var
- i : longint;
- begin
- i:=0;
- while (i<length(fn)) and (fn[i+1] in [',',' ',#9]) do
- inc(i);
- Delete(fn,1,i);
- i:=length(fn);
- while (i>0) and (fn[i] in [',',' ',#9]) do
- dec(i);
- fn:=copy(fn,1,i);
- end;
- function GetName(var fn:string):string;
- var
- i : longint;
- begin
- i:=0;
- while (i<length(fn)) and (fn[i+1] in ['a'..'z','A'..'Z','0'..'9','_','-']) do
- inc(i);
- GetName:=Copy(fn,1,i);
- Delete(fn,1,i);
- end;
- const
- maxlevel=16;
- var
- f : text;
- s,
- opts : string;
- skip : array[0..maxlevel-1] of boolean;
- level : longint;
- option_read : boolean;
- begin
- { avoid infinite loop }
- Inc(FileLevel);
- Option_read:=false;
- If FileLevel>MaxLevel then
- Message(option_too_many_cfg_files);
- { open file }
- Message1(option_using_file,filename);
- assign(f,filename);
- {$I-}
- reset(f);
- {$I+}
- if ioresult<>0 then
- begin
- Message1(option_unable_open_file,filename);
- exit;
- end;
- Message1(option_start_reading_configfile,filename);
- fillchar(skip,sizeof(skip),0);
- level:=0;
- while not eof(f) do
- begin
- readln(f,opts);
- RemoveSep(opts);
- if (opts<>'') and (opts[1]<>';') then
- begin
- if opts[1]='#' then
- begin
- Message1(option_interpreting_file_option,opts);
- Delete(opts,1,1);
- s:=upper(GetName(opts));
- if (s='SECTION') then
- begin
- RemoveSep(opts);
- s:=upper(GetName(opts));
- if level=0 then
- skip[level]:=not (check_symbol(s) or (s='COMMON'));
- end
- else
- if (s='IFDEF') then
- begin
- RemoveSep(opts);
- if Level>=maxlevel then
- begin
- Message(option_too_many_ifdef);
- stopOptions(1);
- end;
- inc(Level);
- skip[level]:=(skip[level-1] or (not check_symbol(upper(GetName(opts)))));
- end
- else
- if (s='IFNDEF') then
- begin
- RemoveSep(opts);
- if Level>=maxlevel then
- begin
- Message(option_too_many_ifdef);
- stopOptions(1);
- end;
- inc(Level);
- skip[level]:=(skip[level-1] or (check_symbol(upper(GetName(opts)))));
- end
- else
- if (s='ELSE') then
- skip[level]:=skip[level-1] or (not skip[level])
- else
- if (s='ENDIF') then
- begin
- skip[level]:=false;
- if Level=0 then
- begin
- Message(option_too_many_endif);
- stopOptions(1);
- end;
- dec(level);
- end
- else
- if (not skip[level]) then
- begin
- if (s='DEFINE') then
- begin
- RemoveSep(opts);
- def_symbol(upper(GetName(opts)));
- end
- else
- if (s='UNDEF') then
- begin
- RemoveSep(opts);
- undef_symbol(upper(GetName(opts)));
- end
- else
- if (s='WRITE') then
- begin
- Delete(opts,1,1);
- WriteLn(opts);
- end
- else
- if (s='INCLUDE') then
- begin
- Delete(opts,1,1);
- Interpret_file(opts);
- end;
- end;
- end
- else
- begin
- if (opts[1]='-') or (opts[1]='@') then
- begin
- if (not skip[level]) then
- interpret_option(opts,false);
- Option_read:=true;
- end
- else
- Message1(option_illegal_para,opts);
- end;
- end;
- end;
- if Level>0 then
- Message(option_too_less_endif);
- if Not Option_read then
- Message1(option_no_option_found,filename)
- else
- Message1(option_end_reading_configfile,filename);
- Close(f);
- Dec(FileLevel);
- end;
- procedure Toption.Interpret_envvar(const envname : string);
- var
- argstart,
- env,
- pc : pchar;
- arglen : longint;
- quote : set of char;
- hs : string;
- begin
- Message1(option_using_env,envname);
- env:=GetEnvPChar(envname);
- pc:=env;
- if assigned(pc) then
- begin
- repeat
- { skip leading spaces }
- while pc^ in [' ',#9,#13] do
- inc(pc);
- case pc^ of
- #0 :
- break;
- '"' :
- begin
- quote:=['"'];
- inc(pc);
- end;
- '''' :
- begin
- quote:=[''''];
- inc(pc);
- end;
- else
- quote:=[' ',#9,#13];
- end;
- { scan until the end of the argument }
- argstart:=pc;
- while (pc^<>#0) and not(pc^ in quote) do
- inc(pc);
- { create argument }
- arglen:=pc-argstart;
- hs[0]:=chr(arglen);
- move(argstart^,hs[1],arglen);
- interpret_option(hs,true);
- { skip quote }
- if pc^ in quote then
- inc(pc);
- until false;
- end
- else
- Message1(option_no_option_found,'(env) '+envname);
- FreeEnvPChar(env);
- end;
- procedure toption.read_parameters;
- var
- opts : string;
- paramindex : longint;
- begin
- paramindex:=0;
- while paramindex<paramcount do
- begin
- inc(paramindex);
- opts:=system.paramstr(paramindex);
- case opts[1] of
- '@' :
- if not firstpass then
- begin
- Delete(opts,1,1);
- Message1(option_reading_further_from,opts);
- interpret_file(opts);
- end;
- '!' :
- if not firstpass then
- begin
- Delete(opts,1,1);
- Message1(option_reading_further_from,'(env) '+opts);
- interpret_envvar(opts);
- end;
- else
- interpret_option(opts,true);
- end;
- end;
- end;
- procedure toption.parsecmd(cmd:string);
- var
- i,ps : longint;
- opts : string;
- begin
- while (cmd<>'') do
- begin
- while cmd[1]=' ' do
- delete(cmd,1,1);
- i:=pos(' ',cmd);
- if i=0 then
- i:=256;
- opts:=Copy(cmd,1,i-1);
- Delete(cmd,1,i);
- case opts[1] of
- '@' :
- if not firstpass then
- begin
- Delete(opts,1,1);
- Message1(option_reading_further_from,opts);
- interpret_file(opts);
- end;
- '!' :
- if not firstpass then
- begin
- Delete(opts,1,1);
- Message1(option_reading_further_from,'(env) '+opts);
- interpret_envvar(opts);
- end;
- '"' :
- begin
- Delete(opts,1,1);
- ps:=pos('"',cmd);
- if (i<>256) and (ps>0) then
- begin
- opts:=opts + ' '+ copy(cmd,1,ps-1);
- cmd:=copy(cmd,ps+1,255);
- end;
- interpret_option(opts,true);
- end;
- else
- interpret_option(opts,true);
- end;
- end;
- end;
- procedure toption.writequickinfo;
- var
- s : string;
- i : longint;
- procedure addinfo(const hs:string);
- begin
- if s<>'' then
- s:=s+' '+hs
- else
- s:=hs;
- end;
- begin
- s:='';
- i:=0;
- while (i<length(quickinfo)) do
- begin
- inc(i);
- case quickinfo[i] of
- 'S' :
- begin
- inc(i);
- case quickinfo[i] of
- 'O' :
- addinfo(lower(source_info.shortname));
- {$ifdef Delphi}
- 'P' :
- addinfo('i386');
- {$else Delphi}
- 'P' :
- addinfo(source_cpu_string);
- {$endif Delphi}
- else
- IllegalPara('-i'+QuickInfo);
- end;
- end;
- 'T' :
- begin
- inc(i);
- case quickinfo[i] of
- 'O' :
- addinfo(lower(target_info.shortname));
- 'P' :
- AddInfo(target_cpu_string);
- else
- IllegalPara('-i'+QuickInfo);
- end;
- end;
- 'V' :
- AddInfo(version_string);
- 'D' :
- AddInfo(date_string);
- '_' :
- ;
- else
- IllegalPara('-i'+QuickInfo);
- end;
- end;
- if s<>'' then
- begin
- writeln(s);
- stopoptions(0);
- end;
- end;
- procedure TOption.TargetDefines(def:boolean);
- var
- s : string;
- i : integer;
- begin
- if def then
- def_symbol(upper(target_info.shortname))
- else
- undef_symbol(upper(target_info.shortname));
- s:=target_info.extradefines;
- while (s<>'') do
- begin
- i:=pos(';',s);
- if i=0 then
- i:=length(s)+1;
- if def then
- def_symbol(Copy(s,1,i-1))
- else
- undef_symbol(Copy(s,1,i-1));
- delete(s,1,i);
- end;
- end;
- constructor TOption.create;
- begin
- DoWriteLogo:=false;
- NoPressEnter:=false;
- FirstPass:=false;
- FileLevel:=0;
- Quickinfo:='';
- ParaIncludePath:=TSearchPathList.Create;
- ParaObjectPath:=TSearchPathList.Create;
- ParaUnitPath:=TSearchPathList.Create;
- ParaLibraryPath:=TSearchPathList.Create;
- FillChar(ParaAlignment,sizeof(ParaAlignment),0);
- end;
- destructor TOption.destroy;
- begin
- ParaIncludePath.Free;
- ParaObjectPath.Free;
- ParaUnitPath.Free;
- ParaLibraryPath.Free;
- end;
- {****************************************************************************
- Callable Routines
- ****************************************************************************}
- function check_configfile(const fn:string;var foundfn:string):boolean;
- function CfgFileExists(const fn:string):boolean;
- begin
- Comment(V_Tried,'Configfile search: '+fn);
- CfgFileExists:=FileExists(fn);
- end;
- var
- configpath : pathstr;
- begin
- foundfn:=fn;
- check_configfile:=true;
- { retrieve configpath }
- {$ifdef Delphi}
- configpath:=FixPath(dmisc.getenv('PPC_CONFIG_PATH'),false);
- {$else Delphi}
- configpath:=FixPath(dos.getenv('PPC_CONFIG_PATH'),false);
- {$endif Delphi}
- {$ifdef Unix}
- if configpath='' then
- configpath:='/etc/';
- {$endif}
- {
- Order to read configuration file :
- try reading fpc.cfg in :
- 1 - current dir
- 2 - configpath
- 3 - compiler path
- }
- if not FileExists(fn) then
- begin
- {$ifdef Unix}
- if (dos.getenv('HOME')<>'') and CfgFileExists(FixPath(dos.getenv('HOME'),false)+'.'+fn) then
- foundfn:=FixPath(dos.getenv('HOME'),false)+'.'+fn
- else
- {$endif}
- if CfgFileExists(configpath+fn) then
- foundfn:=configpath+fn
- else
- {$ifndef Unix}
- if CfgFileExists(exepath+fn) then
- foundfn:=exepath+fn
- else
- {$endif}
- check_configfile:=false;
- end;
- end;
- procedure read_arguments(cmd:string);
- begin
- option:=coption.create;
- disable_configfile:=false;
- { default defines }
- def_symbol(upper(target_info.shortname));
- def_symbol('FPC');
- def_symbol('VER'+version_nr);
- def_symbol('VER'+version_nr+'_'+release_nr);
- def_symbol('VER'+version_nr+'_'+release_nr+'_'+patch_nr);
- { Temporary defines, until things settle down }
- def_symbol('HASWIDECHAR');
- def_symbol('HASWIDESTRING');
- def_symbol('HASOUT');
- def_symbol('HASGLOBALPROPERTY');
- def_symbol('FPC_HASPREFETCH');
- {$ifdef i386}
- def_symbol('HASINTF');
- def_symbol('HASVARIANT');
- {$endif i386}
- {$ifdef x86_64}
- def_symbol('HASINTF');
- def_symbol('HASVARIANT');
- {$endif x86_64}
- {$ifdef powerpc}
- def_symbol('HASINTF');
- def_symbol('HASVARIANT');
- def_symbol('FPC_MTFSB0_CORRECTED');
- {$endif powerpc}
- {$ifdef arm}
- def_symbol('HASINTF');
- def_symbol('HASVARIANT');
- {$endif arm}
- {$ifdef sparc}
- def_symbol('HASINTF');
- def_symbol('HASVARIANT');
- {$endif sparc}
- def_symbol('INTERNSETLENGTH');
- def_symbol('INTERNLENGTH');
- def_symbol('INTERNCOPY');
- def_symbol('INT64FUNCRESOK');
- def_symbol('HAS_ADDR_STACK_ON_STACK');
- def_symbol('NOBOUNDCHECK');
- def_symbol('HASCOMPILERPROC');
- def_symbol('VALUEGETMEM');
- def_symbol('VALUEFREEMEM');
- def_symbol('HASCURRENCY');
- def_symbol('HASTHREADVAR');
- def_symbol('HAS_GENERICCONSTRUCTOR');
- def_symbol('NOCLASSHELPERS');
- if pocall_default = pocall_register then
- def_symbol('REGCALL');
- def_symbol('DECRREFNOTNIL');
- def_symbol('HAS_INTERNAL_INTTYPES');
- def_symbol('STR_USES_VALINT');
- { using a case is pretty useless here (FK) }
- { some stuff for TP compatibility }
- {$ifdef i386}
- def_symbol('CPU86');
- def_symbol('CPU87');
- {$endif}
- {$ifdef m68k}
- def_symbol('CPU68');
- {$endif}
- { new processor stuff }
- {$ifdef i386}
- def_symbol('CPUI386');
- def_symbol('CPU32');
- def_symbol('FPC_HAS_TYPE_EXTENDED');
- def_symbol('FPC_HAS_TYPE_DOUBLE');
- def_symbol('FPC_HAS_TYPE_SINGLE');
- {$endif}
- {$ifdef m68k}
- def_symbol('CPU68K');
- def_symbol('CPUM68K');
- def_symbol('CPU32');
- def_symbol('FPC_CURRENCY_IS_INT64');
- def_symbol('FPC_COMP_IS_INT64');
- {$endif}
- {$ifdef ALPHA}
- def_symbol('CPUALPHA');
- def_symbol('CPU64');
- {$endif}
- {$ifdef powerpc}
- def_symbol('CPUPOWERPC');
- def_symbol('CPUPOWERPC32');
- def_symbol('CPU32');
- def_symbol('FPC_HAS_TYPE_DOUBLE');
- def_symbol('FPC_HAS_TYPE_SINGLE');
- def_symbol('FPC_INCLUDE_SOFTWARE_INT64_TO_DOUBLE');
- def_symbol('FPC_CURRENCY_IS_INT64');
- def_symbol('FPC_COMP_IS_INT64');
- {$endif}
- {$ifdef iA64}
- def_symbol('CPUIA64');
- def_symbol('CPU64');
- {$endif}
- {$ifdef x86_64}
- def_symbol('CPUX86_64');
- def_symbol('CPUAMD64');
- def_symbol('CPU64');
- { not supported for now, afaik (FK)
- def_symbol('FPC_HAS_TYPE_FLOAT128'); }
- def_symbol('FPC_HAS_TYPE_EXTENDED');
- def_symbol('FPC_HAS_TYPE_DOUBLE');
- def_symbol('FPC_HAS_TYPE_SINGLE');
- {$endif}
- {$ifdef sparc}
- def_symbol('CPUSPARC');
- def_symbol('CPUSPARC32');
- def_symbol('CPU32');
- def_symbol('FPC_HAS_TYPE_DOUBLE');
- def_symbol('FPC_HAS_TYPE_SINGLE');
- def_symbol('FPC_INCLUDE_SOFTWARE_INT64_TO_DOUBLE');
- def_symbol('FPC_CURRENCY_IS_INT64');
- def_symbol('FPC_COMP_IS_INT64');
- def_symbol('FPC_REQUIRES_PROPER_ALIGNMENT');
- {$endif}
- {$ifdef vis}
- def_symbol('CPUVIS');
- def_symbol('CPU32');
- {$endif}
- {$ifdef arm}
- def_symbol('CPUARM');
- def_symbol('CPU32');
- def_symbol('FPC_HAS_TYPE_DOUBLE');
- def_symbol('FPC_HAS_TYPE_SINGLE');
- def_symbol('FPC_INCLUDE_SOFTWARE_INT64_TO_DOUBLE');
- def_symbol('FPC_CURRENCY_IS_INT64');
- def_symbol('FPC_COMP_IS_INT64');
- def_symbol('FPC_REQUIRES_PROPER_ALIGNMENT');
- {$endif arm}
- { get default messagefile }
- {$ifdef Delphi}
- msgfilename:=dmisc.getenv('PPC_ERROR_FILE');
- {$else Delphi}
- msgfilename:=dos.getenv('PPC_ERROR_FILE');
- {$endif Delphi}
- { default configfile can be specified on the commandline,
- remove it first }
- if (cmd<>'') and (cmd[1]='[') then
- begin
- ppccfg:=Copy(cmd,2,pos(']',cmd)-2);
- Delete(cmd,1,pos(']',cmd));
- end
- else
- begin
- ppccfg:='fpc.cfg';
- ppcaltcfg:='ppc386.cfg';
- end;
- { read the parameters quick, only -i -v -T }
- option.firstpass:=true;
- if cmd<>'' then
- option.parsecmd(cmd)
- else
- begin
- option.read_parameters;
- { Write only quickinfo }
- if option.quickinfo<>'' then
- option.writequickinfo;
- end;
- option.firstpass:=false;
- { read configuration file }
- if (not disable_configfile) and
- (ppccfg<>'') then
- begin
- read_configfile:=check_configfile(ppccfg,ppccfg);
- { Maybe alternative configfile ? }
- if (not read_configfile) and
- (ppcaltcfg<>'') then
- read_configfile:=check_configfile(ppcaltcfg,ppccfg);
- end
- else
- read_configfile := false;
- { Read commandline and configfile }
- target_is_set:=false;
- asm_is_set:=false;
- param_file:='';
- { read configfile }
- if read_configfile then
- option.interpret_file(ppccfg);
- { read parameters again to override config file }
- if cmd<>'' then
- option.parsecmd(cmd)
- else
- begin
- option.read_parameters;
- { Write only quickinfo }
- if option.quickinfo<>'' then
- option.writequickinfo;
- end;
- { Write help pages }
- if (cmd='') and (paramcount=0) then
- Option.WriteHelpPages;
- { Stop if errors in options }
- if ErrorCount>0 then
- StopOptions(1);
- { Non-core target defines }
- Option.TargetDefines(true);
- { endian define }
- case target_info.endian of
- endian_little :
- begin
- def_symbol('ENDIAN_LITTLE');
- def_symbol('FPC_LITTLE_ENDIAN');
- end;
- endian_big :
- begin
- def_symbol('ENDIAN_BIG');
- def_symbol('FPC_BIG_ENDIAN');
- end;
- end;
- { abi define }
- case target_info.abi of
- abi_powerpc_sysv :
- def_symbol('FPC_ABI_SYSV');
- abi_powerpc_aix :
- def_symbol('FPC_ABI_AIX');
- end;
- {$ifdef m68k}
- if initoptprocessor=MC68020 then
- def_symbol('CPUM68020');
- {$endif m68k}
- { write logo if set }
- if option.DoWriteLogo then
- option.WriteLogo;
- { Check file to compile }
- if param_file='' then
- begin
- Message(option_no_source_found);
- StopOptions(1);
- end;
- {$ifndef Unix}
- param_file:=FixFileName(param_file);
- {$endif}
- fsplit(param_file,inputdir,inputfile,inputextension);
- if inputextension='' then
- begin
- if FileExists(inputdir+inputfile+target_info.sourceext) then
- inputextension:=target_info.sourceext
- else if FileExists(inputdir+inputfile+target_info.pasext) then
- inputextension:=target_info.pasext
- else if (m_mac in aktmodeswitches) and FileExists(inputdir+inputfile+'.p') then
- inputextension:='.p';
- end;
- { Check output dir }
- if (OutputExeDir<>'') and
- not PathExists(OutputExeDir) then
- begin
- Message1(general_e_path_does_not_exists,OutputExeDir);
- StopOptions(1);
- end;
- { Add paths specified with parameters to the searchpaths }
- UnitSearchPath.AddList(option.ParaUnitPath,true);
- ObjectSearchPath.AddList(option.ParaObjectPath,true);
- IncludeSearchPath.AddList(option.ParaIncludePath,true);
- LibrarySearchPath.AddList(option.ParaLibraryPath,true);
- { add unit environment and exepath to the unit search path }
- if inputdir<>'' then
- Unitsearchpath.AddPath(inputdir,true);
- if not disable_configfile then
- begin
- {$ifdef Delphi}
- UnitSearchPath.AddPath(dmisc.getenv(target_info.unit_env),false);
- {$else}
- UnitSearchPath.AddPath(dos.getenv(target_info.unit_env),false);
- {$endif Delphi}
- end;
- {$ifdef Unix}
- fpcdir:=FixPath(getenv('FPCDIR'),false);
- if fpcdir='' then
- begin
- if source_info.cpu<>target_info.cpu then
- begin
- if PathExists('/usr/local/lib/fpc/'+version_string+'/cross/'+cpu2str[target_info.cpu]+'-'+target_info.shortname) then
- fpcdir:='/usr/local/lib/fpc/'+version_string+'/cross/'+cpu2str[target_info.cpu]+'-'+target_info.shortname+'/'
- else
- fpcdir:='/usr/lib/fpc/'+version_string+'/cross/'+cpu2str[target_info.cpu]+'-'+target_info.shortname+'/';
- end
- else
- begin
- if PathExists('/usr/local/lib/fpc/'+version_string) then
- fpcdir:='/usr/local/lib/fpc/'+version_string+'/'
- else
- fpcdir:='/usr/lib/fpc/'+version_string+'/';
- end;
- end;
- {$else}
- fpcdir:=FixPath(getenv('FPCDIR'),false);
- if fpcdir='' then
- begin
- fpcdir:=ExePath+'../';
- if not(PathExists(fpcdir+'/units')) and
- not(PathExists(fpcdir+'/rtl')) then
- fpcdir:=fpcdir+'../';
- end;
- {$endif}
- { first try development RTL, else use the default installation path }
- if not disable_configfile then
- begin
- if source_info.cpu<>target_info.cpu then
- begin
- if PathExists(FpcDir+'rtl/'+lower(target_info.shortname)) then
- UnitSearchPath.AddPath(FpcDir+'rtl/'+lower(target_info.shortname),false)
- else
- begin
- UnitSearchPath.AddPath(FpcDir+'units/',false);
- UnitSearchPath.AddPath(FpcDir+'units/rtl',false);
- end;
- end
- else
- begin
- if PathExists(FpcDir+'rtl/'+lower(target_info.shortname)) then
- UnitSearchPath.AddPath(FpcDir+'rtl/'+lower(target_info.shortname),false)
- else
- begin
- UnitSearchPath.AddPath(FpcDir+'units/'+lower(target_info.shortname),false);
- UnitSearchPath.AddPath(FpcDir+'units/'+lower(target_info.shortname)+'/rtl',false);
- end;
- end;
- end;
- { Add exepath if the exe is not in the current dir, because that is always searched already.
- Do not add it when linking on the target because then we can maybe already find
- .o files that are not for the target }
- if (ExePath<>GetCurrentDir) and
- not(cs_link_on_target in initglobalswitches) then
- UnitSearchPath.AddPath(ExePath,false);
- { Add unit dir to the object and library path }
- objectsearchpath.AddList(unitsearchpath,false);
- librarysearchpath.AddList(unitsearchpath,false);
- { switch assembler if it's binary and we got -a on the cmdline }
- if (cs_asm_leave in initglobalswitches) and
- (af_outputbinary in target_asm.flags) then
- begin
- Message(option_switch_bin_to_src_assembler);
- set_target_asm(target_info.assemextern);
- end;
- if (target_asm.supported_target <> system_any) and
- (target_asm.supported_target <> target_info.system) then
- begin
- Message2(option_incompatible_asm,target_asm.idtxt,target_info.name);
- set_target_asm(target_info.assemextern);
- Message1(option_asm_forced,target_asm.idtxt);
- end;
- { turn off stripping if compiling with debuginfo or profile }
- if (cs_debuginfo in initmoduleswitches) or
- (cs_profile in initmoduleswitches) then
- exclude(initglobalswitches,cs_link_strip);
- {$ifdef x86_64}
- {$warning HACK: turn off smartlinking}
- exclude(initmoduleswitches,cs_create_smart);
- {$endif}
- if not LinkTypeSetExplicitly then
- set_default_link_type;
- { Default alignment settings,
- 1. load the defaults for the target
- 2. override with generic optimizer setting (little size)
- 3. override with the user specified -Oa }
- UpdateAlignment(initalignment,target_info.alignment);
- if (cs_littlesize in aktglobalswitches) then
- begin
- initalignment.procalign:=1;
- initalignment.jumpalign:=1;
- initalignment.loopalign:=1;
- end;
- UpdateAlignment(initalignment,option.paraalignment);
- option.free;
- Option:=nil;
- end;
- initialization
- coption:=toption;
- finalization
- if assigned(option) then
- option.free;
- end.
- {
- $Log$
- Revision 1.143 2004-09-21 17:25:12 peter
- * paraloc branch merged
- Revision 1.142 2004/09/16 16:31:53 peter
- * Use FExpand on paths passed to compiler
- Revision 1.141 2004/09/10 21:00:23 jonas
- * exit with exit code 0 instead of 1 after writing out quick options
- (such as -iV)
- Revision 1.140 2004/09/08 11:23:31 michael
- + Check if outputdir exists, Fix exitcode when displaying help pages
- Revision 1.139.4.1 2004/09/19 20:53:33 peter
- * fixed compile without gdb
- Revision 1.139 2004/08/27 21:59:26 peter
- browser disabled
- uf_local_symtable ppu flag when a localsymtable is stored
- Revision 1.138 2004/07/05 21:26:28 olle
- + allow fileextension .p, in mode macpas
- Revision 1.137 2004/07/04 12:24:04 jonas
- * fixed "-g-l" (and other "-g-*" combinations)
- Revision 1.136 2004/06/20 08:55:30 florian
- * logs truncated
- Revision 1.135 2004/06/16 20:07:09 florian
- * dwarf branch merged
- Revision 1.134 2004/05/06 20:30:51 florian
- * m68k compiler compilation fixed
- Revision 1.133.2.10 2004/05/18 20:24:03 florian
- * fixed crash with unknown symbols
- Revision 1.133.2.9 2004/05/13 20:10:38 florian
- * released variant and interface support
- Revision 1.133.2.8 2004/05/03 14:59:57 peter
- * no dlltool needed for win32 linking executables
- }
|