Browse Source

* Not in all cross-compile cases the -XP$FPCTARGET- option is necessary

git-svn-id: trunk@15219 -
joost 15 years ago
parent
commit
c7d5057127
3 changed files with 49 additions and 14 deletions
  1. 4 0
      utils/fpcmkcfg/fpc.cft
  2. 18 14
      utils/fpcmkcfg/fpccfg.inc
  3. 27 0
      utils/fpcmkcfg/fpcmkcfg.pp

+ 4 - 0
utils/fpcmkcfg/fpc.cft

@@ -147,10 +147,14 @@
 # searchpath for tools
 -FD%basepath%/bin/$FPCTARGET
 
+%NEEDCROSSBINUTILSIFDEF%
+
 # binutils prefix for cross compiling
 #IFDEF FPC_CROSSCOMPILING
+#IFDEF NEEDCROSSBINUTILS
   -XP$FPCTARGET-
 #ENDIF
+#ENDIF
 
 
 # -------------

+ 18 - 14
utils/fpcmkcfg/fpccfg.inc

@@ -1,7 +1,7 @@
 {$ifdef Delphi}
-const DefaultConfig : array[0..22] of string[240]=(
+const DefaultConfig : array[0..23] of string[240]=(
 {$else Delphi}
-const DefaultConfig : array[0..22,1..240] of char=(
+const DefaultConfig : array[0..23,1..240] of char=(
 {$endif Delphi}
   '#'#010+
   '# Config file generated by fpcmkcfg on %BUILDDATE% - %BUILDTIME%'#010+
@@ -160,28 +160,32 @@ const DefaultConfig : array[0..22,1..240] of char=(
   '# searchpath for tools'#010+
   '-FD%basepath%/bin/$FPCTARGET'#010+
   #010+
+  '%NEEDCROSSBINUTILSIFDEF%'#010+
+  #010+
   '# binutils prefix for cross compiling'#010+
   '#IFDEF FPC_CROSSCOMPILING'#010+
-  '  -XP$FPCTARGET-'#010+
+  '#IFDEF NEEDCROSSBINUTILS'#010+
+  '  -XP$FPCTARGET-',#010+
+  '#ENDIF'#010+
   '#ENDIF'#010+
   #010+
   #010+
   '# -------------'#010+
   '# Linking'#010+
-  '# -------------',#010+
+  '# -------------'#010+
   #010+
   '# generate always debugging information for GDB (slows down the compil'+
   'ing'#010+
   '# process)'#010+
   '#      -gc        generate checks for pointers'#010+
   '#      -gd        use dbx'#010+
-  '#      -gg        use gsym'#010+
-  '#      -gh        use heap trace unit (for memory lea','k debugging)'#010+
+  '#      -gg        use ','gsym'#010+
+  '#      -gh        use heap trace unit (for memory leak debugging)'#010+
   '#      -gl        use line info unit to show more info for backtraces'#010+
   '#      -gv        generates programs tracable with valgrind'#010+
-  '#      -gw        generate dwarf debugging info'#010+
+  '#      -gw        generate dwarf debugg','ing info'#010+
   '#'#010+
-  '# Enable debuginfo and use the line info unit b','y default'#010+
+  '# Enable debuginfo and use the line info unit by default'#010+
   '#-gl'#010+
   #010+
   '# always pass an option to the linker'#010+
@@ -195,19 +199,19 @@ const DefaultConfig : array[0..22,1..240] of char=(
   '# Miscellaneous'#010+
   '# -------------'#010+
   #010+
-  '# Write always a nice FPC logo ;)'#010+
+  '# Write always a nice',' FPC logo ;)'#010+
   '-l'#010+
   #010+
   '# Verbosity'#010+
-  '#      e : Show errors (defau','lt)       d : Show debug info'#010+
+  '#      e : Show errors (default)       d : Show debug info'#010+
   '#      w : Show warnings               u : Show unit info'#010+
   '#      n : Show notes                  t : Show tried/used files'#010+
-  '#      h : Show hints                  m : Show defined macros'#010+
-  '#      i : Show general ','info           p : Show compiled procedures'#010+
+  '#      h : Show hints        ','          m : Show defined macros'#010+
+  '#      i : Show general info           p : Show compiled procedures'#010+
   '#      l : Show linenumbers            c : Show conditionals'#010+
   '#      a : Show everything             0 : Show nothing (except errors'+
   ')'#010+
-  '#      b : Show all procedure          r : Rhide/GCC compatibil','ity m'+
+  '#    ','  b : Show all procedure          r : Rhide/GCC compatibility m'+
   'ode'#010+
   '#          declarations if an error    x : Executable info (Win32 only'+
   ')'#010+
@@ -215,6 +219,6 @@ const DefaultConfig : array[0..22,1..240] of char=(
   '#'#010+
   '# Display Info, Warnings, Notes and Hints'#010+
   '-viwn'#010+
-  '# If you don'#039't want so much verbosity use'#010+
+  '# If you don'#039't want so much verbo','sity use'#010+
   '#-vw'#010
 );

+ 27 - 0
utils/fpcmkcfg/fpcmkcfg.pp

@@ -86,6 +86,32 @@ begin
 {$ENDIF Unix}
 end;
 
+function GetDefaultNeedCrossBinutilsIfdef: string;
+
+begin
+  result := '';
+  // On Darwin there is never a need for a crossbinutils prefix
+  if BuildOSTarget='Darwin' then
+    Exit;
+
+  if (BuildTarget = 'i386') or (BuildTarget = 'x86_64') then
+    begin
+    // Cross-binutils are not needed to compile for i386 on an x86_64 system
+    result := '#IFNDEF CPUI386' + LineEnding +
+              '#IFNDEF CPUAMD64' + LineEnding +
+              '#DEFINE NEEDCROSSBINUTILS' + LineEnding +
+              '#ENDIF' + LineEnding +
+              '#ENDIF' + LineEnding +
+              LineEnding +
+              '#IFNDEF ' + BuildOSTarget + LineEnding +
+              '#DEFINE NEEDCROSSBINUTILS' + LineEnding +
+              '#ENDIF';
+    end
+  else
+    result := '#DEFINE NEEDCROSSBINUTILS';
+end;
+
+
 procedure Init;
 
 begin
@@ -103,6 +129,7 @@ begin
   TemplateParser.Values['BUILDTIME'] := TimeToStr(Time);
 
   TemplateParser.Values['LOCALREPOSITORY'] := GetDefaultLocalRepository;
+  TemplateParser.Values['NEEDCROSSBINUTILSIFDEF'] := GetDefaultNeedCrossBinutilsIfdef;
 
   Cfg:=TStringList.Create;
   Cfg.Text:=StrPas(Addr(DefaultConfig[0][1]));