diff --git a/ide/buildlazdialog.pas b/ide/buildlazdialog.pas index 4650bc7503..e7155757ac 100644 --- a/ide/buildlazdialog.pas +++ b/ide/buildlazdialog.pas @@ -51,6 +51,7 @@ type fCleanAll: boolean; fMakeFilename: string; fExtraOptions: string; + fTargetOS: string; public constructor Create; procedure Load(XMLConfig: TXMLConfig; const Path: string); @@ -65,6 +66,7 @@ type property CleanAll: boolean read fCleanAll write fCleanAll; property MakeFilename: string read fMakeFilename write fMakeFilename; property ExtraOptions: string read fExtraOptions write fExtraOptions; + property TargetOS: string read fTargetOS write fTargetOS; end; TConfigureBuildLazarusDlg = class(TForm) @@ -78,6 +80,8 @@ type BuildExamplesRadioGroup: TRadioGroup; OptionsLabel: TLabel; OptionsEdit: TEdit; + TargetOSLabel: TLabel; + TargetOSEdit: TEdit; OkButton: TButton; CancelButton: TButton; procedure BuildAllButtonClick(Sender: TObject); @@ -142,12 +146,14 @@ function BuildLazarus(Options: TBuildLazarusOptions; var Tool: TExternalToolOptions; - procedure SetMakeParams(MakeMode: TMakeMode; ExtraOpts: string); + procedure SetMakeParams(MakeMode: TMakeMode; ExtraOpts: string; TargetOS: string); begin if MakeMode=mmBuild then Tool.CmdLineParams:='all' else Tool.CmdLineParams:='clean all'; + if TargetOS<>'' then + Tool.CmdLineParams:= 'OS_TARGET='+ TargetOS+' '+Tool.CmdLineParams; if ExtraOpts<>'' then Tool.CmdLineParams:='OPT='''+ExtraOpts+''' '+Tool.CmdLineParams; end; @@ -168,6 +174,8 @@ begin Tool.Title:='Clean Lazarus Source'; Tool.WorkingDirectory:='$(LazarusDir)'; Tool.CmdLineParams:='cleanall'; +// if Options.TargetOS<>'' then +// Tool.CmdLineParams:= 'OS_TARGET='+ Options.TargetOS+' '+Tool.CmdLineParams; Result:=ExternalTools.Run(Tool,Macros); if Result<>mrOk then exit; end; @@ -175,7 +183,7 @@ begin // build lcl Tool.Title:='Build LCL'; Tool.WorkingDirectory:='$(LazarusDir)/lcl'; - SetMakeParams(Options.BuildLCL,Options.ExtraOptions); + SetMakeParams(Options.BuildComponents,Options.ExtraOptions,Options.TargetOS); Result:=ExternalTools.Run(Tool,Macros); if Result<>mrOk then exit; end; @@ -183,7 +191,7 @@ begin // build components Tool.Title:='Build Component'; Tool.WorkingDirectory:='$(LazarusDir)/components'; - SetMakeParams(Options.BuildComponents,Options.ExtraOptions); + SetMakeParams(Options.BuildComponents,Options.ExtraOptions,Options.TargetOS); Result:=ExternalTools.Run(Tool,Macros); if Result<>mrOk then exit; end else begin @@ -191,7 +199,7 @@ begin // build SynEdit Tool.Title:='Build SynEdit'; Tool.WorkingDirectory:='$(LazarusDir)/components/synedit'; - SetMakeParams(Options.BuildSynEdit,Options.ExtraOptions); + SetMakeParams(Options.BuildComponents,Options.ExtraOptions,Options.TargetOS); Result:=ExternalTools.Run(Tool,Macros); if Result<>mrOk then exit; end; @@ -199,7 +207,7 @@ begin // build CodeTools Tool.Title:='Build CodeTools'; Tool.WorkingDirectory:='$(LazarusDir)/components/codetools'; - SetMakeParams(Options.BuildCodeTools,Options.ExtraOptions); + SetMakeParams(Options.BuildComponents,Options.ExtraOptions,Options.TargetOS); Result:=ExternalTools.Run(Tool,Macros); if Result<>mrOk then exit; end; @@ -212,6 +220,8 @@ begin Tool.CmdLineParams:='OPT='''+Options.ExtraOptions+''' ' else Tool.CmdLineParams:=''; + if Options.TargetOS<>'' then + Tool.CmdLineParams:= 'OS_TARGET='+ Options.TargetOS+' '+Tool.CmdLineParams; if Options.BuildIDE=mmBuild then Tool.CmdLineParams:=Tool.CmdLineParams+'ide' else @@ -223,7 +233,7 @@ begin // build Examples Tool.Title:='Build Examples'; Tool.WorkingDirectory:='$(LazarusDir)/examples'; - SetMakeParams(Options.BuildExamples,Options.ExtraOptions); + SetMakeParams(Options.BuildComponents,Options.ExtraOptions,Options.TargetOS); Result:=ExternalTools.Run(Tool,Macros); if Result<>mrOk then exit; end; @@ -241,7 +251,7 @@ begin inherited Create(AnOwner); if LazarusResources.Find(Classname)=nil then begin Width:=350; - Height:=415; + Height:=435; Position:=poScreenCenter; Caption:='Configure "Build Lazarus"'; OnResize:=@ConfigureBuildLazarusDlgResize; @@ -370,6 +380,28 @@ begin Visible:=true; end; + TargetOSLabel:=TLabel.Create(Self); + with TargetOSLabel do begin + Name:='TargetOSLabel'; + Parent:=Self; + SetBounds(10, + OptionsLabel.Top+OptionsLabel.Height+12, + 80,Height); + Caption:='Target OS:'; + Visible:=true; + end; + + TargetOSEdit:=TEdit.Create(Self); + with TargetOSEdit do begin + Name:='TargetOSEdit'; + Parent:=Self; + SetBounds(TargetOSLabel.Left+TargetOSLabel.Width+5, + TargetOSLabel.Top, + OptionsEdit.Width, + Height); + Visible:=true; + end; + OkButton:=TButton.Create(Self); with OkButton do begin Parent:=Self; @@ -445,6 +477,13 @@ begin OptionsLabel.Top, BuildExamplesRadioGroup.Width-OptionsLabel.Width-5, OptionsEdit.Height); + TargetOSLabel.SetBounds(10, + OptionsLabel.Top+OptionsLabel.Height+12, + 80,TargetOsLabel.Height); + TargetOSEdit.SetBounds(TargetOSLabel.Left+TargetOSLabel.Width+5, + TargetOSLabel.Top, + OptionsEdit.Width, + TargetOSEdit.Height); OkButton.SetBounds(Self.ClientWidth-180,Self.ClientHeight-38,80,25); CancelButton.SetBounds(Self.ClientWidth-90,OkButton.Top, OkButton.Width,OkButton.Height); @@ -470,6 +509,7 @@ begin BuildIDERadioGroup.ItemIndex:=MakeModeToInt(Options.BuildIDE); BuildExamplesRadioGroup.ItemIndex:=MakeModeToInt(Options.BuildExamples); OptionsEdit.Text:=Options.ExtraOptions; + TargetOSEdit.Text:=Options.TargetOS; end; procedure TConfigureBuildLazarusDlg.Save(Options: TBuildLazarusOptions); @@ -483,6 +523,7 @@ begin Options.BuildIDE:=IntToMakeMode(BuildIDERadioGroup.ItemIndex); Options.BuildExamples:=IntToMakeMode(BuildExamplesRadioGroup.ItemIndex); Options.ExtraOptions:=OptionsEdit.Text; + Options.TargetOS:=TargetOSEdit.Text; end; function TConfigureBuildLazarusDlg.MakeModeToInt(MakeMode: TMakeMode): integer; @@ -515,6 +556,7 @@ begin XMLConfig.SetValue(Path+'BuildExamples/Value',MakeModeNames[fBuildExamples]); XMLConfig.SetValue(Path+'CleanAll/Value',fCleanAll); XMLConfig.SetValue(Path+'ExtraOptions/Value',fExtraOptions); + XMLConfig.SetValue(Path+'TargetOS/Value',fTargetOS); XMLConfig.SetValue(Path+'MakeFilename/Value',fMakeFilename); end; @@ -534,6 +576,7 @@ begin MakeModeNames[fBuildExamples])); fCleanAll:=XMLConfig.GetValue(Path+'CleanAll/Value',fCleanAll); fExtraOptions:=XMLConfig.GetValue(Path+'ExtraOptions/Value',fExtraOptions); + fTargetOS:=XMLConfig.GetValue(Path+'TargetOS/Value',fTargetOS); fMakeFilename:=XMLConfig.GetValue(Path+'MakeFilename/Value',fMakeFilename); end; diff --git a/ide/compileroptions.pp b/ide/compileroptions.pp index 0b2f01ac28..62f40e70c6 100644 --- a/ide/compileroptions.pp +++ b/ide/compileroptions.pp @@ -80,6 +80,7 @@ type fVarsInReg: Boolean; fUncertainOpt: Boolean; fOptLevel: Integer; + fTargetOS: String; fGenDebugInfo: Boolean; fGenDebugDBX: Boolean; @@ -168,6 +169,7 @@ type property VariablesInRegisters: Boolean read fVarsInReg write fVarsInReg; property UncertainOptimizations: Boolean read fUncertainOpt write fUncertainOpt; property OptimizationLevel: Integer read fOptLevel write fOptLevel; + property TargetOS: string read fTargetOS write fTargetOS; property GenerateDebugInfo: Boolean read fGenDebugInfo write fGenDebugInfo; property GenerateDebugDBX: Boolean read fGenDebugDBX write fGenDebugDBX; @@ -291,6 +293,8 @@ type radOptLevel2: TRadioButton; radOptLevel3: TRadioButton; + TargetOSRadioGroup: TRadioGroup; + { Linking Controls } grpDebugging: TGroupBox; chkDebugGDB: TCheckBox; @@ -466,6 +470,7 @@ begin VariablesInRegisters := XMLConfigFile.GetValue('CompilerOptions/CodeGeneration/Optimizations/VariablesInRegisters/Value', false); UncertainOptimizations := XMLConfigFile.GetValue('CompilerOptions/CodeGeneration/Optimizations/UncertainOptimizations/Value', false); OptimizationLevel := XMLConfigFile.GetValue('CompilerOptions/CodeGeneration/Optimizations/OptimizationLevel/Value', 1); + TargetOS := XMLConfigFile.GetValue('CompilerOptions/CodeGeneration/TargetOS/Value', 'linux'); { Linking } GenerateDebugInfo := XMLConfigFile.GetValue('CompilerOptions/Linking/Debugging/GenerateDebugInfo/Value', false); @@ -568,6 +573,7 @@ begin XMLConfigFile.SetValue('CompilerOptions/CodeGeneration/Optimizations/VariablesInRegisters/Value', VariablesInRegisters); XMLConfigFile.SetValue('CompilerOptions/CodeGeneration/Optimizations/UncertainOptimizations/Value', UncertainOptimizations); XMLConfigFile.SetValue('CompilerOptions/CodeGeneration/Optimizations/OptimizationLevel/Value', OptimizationLevel); + XMLConfigFile.SetValue('CompilerOptions/CodeGeneration/TargetOS/Value', TargetOS); { Linking } XMLConfigFile.SetValue('CompilerOptions/Linking/Debugging/GenerateDebugInfo/Value', GenerateDebugInfo); @@ -629,9 +635,8 @@ begin Ext:=ExtractFileExt(Result); Result:=copy(Result,1,length(Result)-length(Ext)); Result:=lowercase(Result); - {$IFDEF win32} - Result:=Result+'.exe'; - {$ENDIF} + if fTargetOS = 'win32' + then Result:=Result+'.exe'; Result:=ExtractFilePath(MainSourceFileName)+Result; end else Result:=''; @@ -933,6 +938,15 @@ begin 3: switches := switches + 'p3'; end; + { Target OS + GO32V1 = DOS and version 1 of the DJ DELORIE extender (no longer maintained). + GO32V2 = DOS and version 2 of the DJ DELORIE extender. + LINUX = LINUX. + OS2 = OS/2 (2.x) using the EMX extender. + WIN32 = Windows 32 bit. } + { Only linux and win32 are in the dialog at this moment} + if TargetOS<>'' then + switches := switches + ' -T' + TargetOS; { --------------- Linking Tab ------------------- } { Debugging } @@ -1087,12 +1101,6 @@ begin -uxxx = Undefine symbol name xxx -s = Do not call assembler or linker. Write ppas.bat/ppas.sh script. - -T = Target OS - GO32V1 = DOS and version 1 of the DJ DELORIE extender (no longer maintained). - GO32V2 = DOS and version 2 of the DJ DELORIE extender. - LINUX = LINUX. - OS2 = OS/2 (2.x) using the EMX extender. - WIN32 = Windows 32 bit. -Xc = Link with C library (LINUX only) @@ -1226,6 +1234,7 @@ begin fVarsInReg := false; fUncertainOpt := false; fOptLevel := 1; + fTargetOS := 'linux'; fGenDebugInfo := false; fGenDebugDBX := false; @@ -1298,6 +1307,7 @@ begin fVarsInReg := CompOpts.fVarsInReg; fUncertainOpt := CompOpts.fUncertainOpt; fOptLevel := CompOpts.fOptLevel; + fTargetOS := CompOpts.fTargetOS; fGenDebugInfo := CompOpts.fGenDebugInfo; fGenDebugDBX := CompOpts.fGenDebugDBX; @@ -1595,6 +1605,9 @@ begin i:=LCLWidgetTypeRadioGroup.Items.IndexOf(CompilerOpts.LCLWidgetType); if i<0 then i:=0; LCLWidgetTypeRadioGroup.ItemIndex:=i; + i:=TargetOSRadioGroup.Items.IndexOf(CompilerOpts.TargetOS); + if i<0 then i:=0; + TargetOSRadioGroup.ItemIndex:=i; end; {------------------------------------------------------------------------------} @@ -1723,6 +1736,10 @@ begin i:=LCLWidgetTypeRadioGroup.Itemindex; if i<0 then i:=0; CompilerOpts.LCLWidgetType:= LCLWidgetTypeRadioGroup.Items[i]; + + i:=TargetOSRadioGroup.Itemindex; + if i<0 then i:=0; + CompilerOpts.TargetOS:= TargetOSRadioGroup.Items[i]; end; {------------------------------------------------------------------------------} @@ -2229,6 +2246,24 @@ begin Visible := True; end; + TargetOSRadioGroup:=TRadioGroup.Create(Self); + with TargetOSRadioGroup do begin + Name:='TargetOSRadioGroup'; + Parent:=nbMain.Page[Page]; + Left := grpOtherUnits.Left; + Top:=grpOptimizations.Top+grpOptimizations.Height+5; + Width:=150; + Height:=45; + Caption:=dlgTargetOS; + with Items do begin + Add('linux'); + Add('win32'); + end; + Columns:=2; + ItemIndex:=0; + Visible:=true; + end; + end; {------------------------------------------------------------------------------} diff --git a/ide/lazarusidestrconsts.pas b/ide/lazarusidestrconsts.pas index 10c657ecc8..28791aedc6 100644 --- a/ide/lazarusidestrconsts.pas +++ b/ide/lazarusidestrconsts.pas @@ -508,6 +508,7 @@ resourcestring dlgLevel1Opt = 'Level 1 (Quick Optimizations)'; dlgLevel2Opt = 'Level 2 (Level 1 + Slower Optimizations)'; dlgLevel3Opt = 'Level 3 (Level 2 + Uncertain)'; + dlgTargetOS = 'Target OS'; dlgCODebugging = 'Debugging:'; dlgCOGDB = 'Generate Debugging Info For GDB (Slows Compiling)'; dlgCODBX = 'Generate Debugging Info For DBX (Slows Compiling)';