Bläddra i källkod

* Determine and add gcclib path to fpc.cfg configuration file

git-svn-id: trunk@15220 -
joost 15 år sedan
förälder
incheckning
e388ac9770
5 ändrade filer med 233 tillägg och 24 borttagningar
  1. 89 2
      utils/fpcmkcfg/Makefile
  2. 1 1
      utils/fpcmkcfg/Makefile.fpc
  3. 3 3
      utils/fpcmkcfg/fpc.cft
  4. 15 15
      utils/fpcmkcfg/fpccfg.inc
  5. 125 3
      utils/fpcmkcfg/fpcmkcfg.pp

+ 89 - 2
utils/fpcmkcfg/Makefile

@@ -1,5 +1,5 @@
 #
-# Don't edit, this file is generated by FPCMake Version 2.0.0 [2010/04/26]
+# Don't edit, this file is generated by FPCMake Version 2.0.0 [2010/04/27]
 #
 default: all
 MAKEFILETARGETS=i386-linux i386-go32v2 i386-win32 i386-os2 i386-freebsd i386-beos i386-haiku i386-netbsd i386-solaris i386-qnx i386-netware i386-openbsd i386-wdosx i386-darwin i386-emx i386-watcom i386-netwlibc i386-wince i386-embedded i386-symbian i386-nativent m68k-linux m68k-freebsd m68k-netbsd m68k-amiga m68k-atari m68k-openbsd m68k-palmos m68k-embedded powerpc-linux powerpc-netbsd powerpc-amiga powerpc-macos powerpc-darwin powerpc-morphos powerpc-embedded sparc-linux sparc-netbsd sparc-solaris sparc-embedded x86_64-linux x86_64-freebsd x86_64-solaris x86_64-darwin x86_64-win64 x86_64-embedded arm-linux arm-palmos arm-darwin arm-wince arm-gba arm-nds arm-embedded arm-symbian powerpc64-linux powerpc64-darwin powerpc64-embedded avr-embedded armeb-linux armeb-embedded mipsel-linux
@@ -1220,255 +1220,316 @@ else
 TAROPT=vz
 TAREXT=.tar.gz
 endif
-override REQUIRE_PACKAGES=rtl fcl-base
+override REQUIRE_PACKAGES=rtl fcl-base fcl-process
 ifeq ($(FULL_TARGET),i386-linux)
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_FCL-BASE=1
+REQUIRE_PACKAGES_FCL-PROCESS=1
 endif
 ifeq ($(FULL_TARGET),i386-go32v2)
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_FCL-BASE=1
+REQUIRE_PACKAGES_FCL-PROCESS=1
 endif
 ifeq ($(FULL_TARGET),i386-win32)
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_FCL-BASE=1
+REQUIRE_PACKAGES_FCL-PROCESS=1
 endif
 ifeq ($(FULL_TARGET),i386-os2)
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_FCL-BASE=1
+REQUIRE_PACKAGES_FCL-PROCESS=1
 endif
 ifeq ($(FULL_TARGET),i386-freebsd)
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_FCL-BASE=1
+REQUIRE_PACKAGES_FCL-PROCESS=1
 endif
 ifeq ($(FULL_TARGET),i386-beos)
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_FCL-BASE=1
+REQUIRE_PACKAGES_FCL-PROCESS=1
 endif
 ifeq ($(FULL_TARGET),i386-haiku)
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_FCL-BASE=1
+REQUIRE_PACKAGES_FCL-PROCESS=1
 endif
 ifeq ($(FULL_TARGET),i386-netbsd)
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_FCL-BASE=1
+REQUIRE_PACKAGES_FCL-PROCESS=1
 endif
 ifeq ($(FULL_TARGET),i386-solaris)
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_FCL-BASE=1
+REQUIRE_PACKAGES_FCL-PROCESS=1
 endif
 ifeq ($(FULL_TARGET),i386-qnx)
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_FCL-BASE=1
+REQUIRE_PACKAGES_FCL-PROCESS=1
 endif
 ifeq ($(FULL_TARGET),i386-netware)
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_FCL-BASE=1
+REQUIRE_PACKAGES_FCL-PROCESS=1
 endif
 ifeq ($(FULL_TARGET),i386-openbsd)
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_FCL-BASE=1
+REQUIRE_PACKAGES_FCL-PROCESS=1
 endif
 ifeq ($(FULL_TARGET),i386-wdosx)
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_FCL-BASE=1
+REQUIRE_PACKAGES_FCL-PROCESS=1
 endif
 ifeq ($(FULL_TARGET),i386-darwin)
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_UNIVINT=1
 REQUIRE_PACKAGES_FCL-BASE=1
+REQUIRE_PACKAGES_FCL-PROCESS=1
 endif
 ifeq ($(FULL_TARGET),i386-emx)
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_FCL-BASE=1
+REQUIRE_PACKAGES_FCL-PROCESS=1
 endif
 ifeq ($(FULL_TARGET),i386-watcom)
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_FCL-BASE=1
+REQUIRE_PACKAGES_FCL-PROCESS=1
 endif
 ifeq ($(FULL_TARGET),i386-netwlibc)
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_FCL-BASE=1
+REQUIRE_PACKAGES_FCL-PROCESS=1
 endif
 ifeq ($(FULL_TARGET),i386-wince)
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_FCL-BASE=1
+REQUIRE_PACKAGES_FCL-PROCESS=1
 endif
 ifeq ($(FULL_TARGET),i386-embedded)
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_FCL-BASE=1
+REQUIRE_PACKAGES_FCL-PROCESS=1
 endif
 ifeq ($(FULL_TARGET),i386-symbian)
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_FCL-BASE=1
+REQUIRE_PACKAGES_FCL-PROCESS=1
 endif
 ifeq ($(FULL_TARGET),i386-nativent)
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_FCL-BASE=1
+REQUIRE_PACKAGES_FCL-PROCESS=1
 endif
 ifeq ($(FULL_TARGET),m68k-linux)
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_FCL-BASE=1
+REQUIRE_PACKAGES_FCL-PROCESS=1
 endif
 ifeq ($(FULL_TARGET),m68k-freebsd)
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_FCL-BASE=1
+REQUIRE_PACKAGES_FCL-PROCESS=1
 endif
 ifeq ($(FULL_TARGET),m68k-netbsd)
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_FCL-BASE=1
+REQUIRE_PACKAGES_FCL-PROCESS=1
 endif
 ifeq ($(FULL_TARGET),m68k-amiga)
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_FCL-BASE=1
+REQUIRE_PACKAGES_FCL-PROCESS=1
 endif
 ifeq ($(FULL_TARGET),m68k-atari)
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_FCL-BASE=1
+REQUIRE_PACKAGES_FCL-PROCESS=1
 endif
 ifeq ($(FULL_TARGET),m68k-openbsd)
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_FCL-BASE=1
+REQUIRE_PACKAGES_FCL-PROCESS=1
 endif
 ifeq ($(FULL_TARGET),m68k-palmos)
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_FCL-BASE=1
+REQUIRE_PACKAGES_FCL-PROCESS=1
 endif
 ifeq ($(FULL_TARGET),m68k-embedded)
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_FCL-BASE=1
+REQUIRE_PACKAGES_FCL-PROCESS=1
 endif
 ifeq ($(FULL_TARGET),powerpc-linux)
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_FCL-BASE=1
+REQUIRE_PACKAGES_FCL-PROCESS=1
 endif
 ifeq ($(FULL_TARGET),powerpc-netbsd)
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_FCL-BASE=1
+REQUIRE_PACKAGES_FCL-PROCESS=1
 endif
 ifeq ($(FULL_TARGET),powerpc-amiga)
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_FCL-BASE=1
+REQUIRE_PACKAGES_FCL-PROCESS=1
 endif
 ifeq ($(FULL_TARGET),powerpc-macos)
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_FCL-BASE=1
+REQUIRE_PACKAGES_FCL-PROCESS=1
 endif
 ifeq ($(FULL_TARGET),powerpc-darwin)
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_UNIVINT=1
 REQUIRE_PACKAGES_FCL-BASE=1
+REQUIRE_PACKAGES_FCL-PROCESS=1
 endif
 ifeq ($(FULL_TARGET),powerpc-morphos)
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_FCL-BASE=1
+REQUIRE_PACKAGES_FCL-PROCESS=1
 endif
 ifeq ($(FULL_TARGET),powerpc-embedded)
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_FCL-BASE=1
+REQUIRE_PACKAGES_FCL-PROCESS=1
 endif
 ifeq ($(FULL_TARGET),sparc-linux)
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_FCL-BASE=1
+REQUIRE_PACKAGES_FCL-PROCESS=1
 endif
 ifeq ($(FULL_TARGET),sparc-netbsd)
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_FCL-BASE=1
+REQUIRE_PACKAGES_FCL-PROCESS=1
 endif
 ifeq ($(FULL_TARGET),sparc-solaris)
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_FCL-BASE=1
+REQUIRE_PACKAGES_FCL-PROCESS=1
 endif
 ifeq ($(FULL_TARGET),sparc-embedded)
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_FCL-BASE=1
+REQUIRE_PACKAGES_FCL-PROCESS=1
 endif
 ifeq ($(FULL_TARGET),x86_64-linux)
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_FCL-BASE=1
+REQUIRE_PACKAGES_FCL-PROCESS=1
 endif
 ifeq ($(FULL_TARGET),x86_64-freebsd)
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_FCL-BASE=1
+REQUIRE_PACKAGES_FCL-PROCESS=1
 endif
 ifeq ($(FULL_TARGET),x86_64-solaris)
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_FCL-BASE=1
+REQUIRE_PACKAGES_FCL-PROCESS=1
 endif
 ifeq ($(FULL_TARGET),x86_64-darwin)
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_UNIVINT=1
 REQUIRE_PACKAGES_FCL-BASE=1
+REQUIRE_PACKAGES_FCL-PROCESS=1
 endif
 ifeq ($(FULL_TARGET),x86_64-win64)
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_FCL-BASE=1
+REQUIRE_PACKAGES_FCL-PROCESS=1
 endif
 ifeq ($(FULL_TARGET),x86_64-embedded)
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_FCL-BASE=1
+REQUIRE_PACKAGES_FCL-PROCESS=1
 endif
 ifeq ($(FULL_TARGET),arm-linux)
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_FCL-BASE=1
+REQUIRE_PACKAGES_FCL-PROCESS=1
 endif
 ifeq ($(FULL_TARGET),arm-palmos)
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_FCL-BASE=1
+REQUIRE_PACKAGES_FCL-PROCESS=1
 endif
 ifeq ($(FULL_TARGET),arm-darwin)
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_UNIVINT=1
 REQUIRE_PACKAGES_FCL-BASE=1
+REQUIRE_PACKAGES_FCL-PROCESS=1
 endif
 ifeq ($(FULL_TARGET),arm-wince)
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_FCL-BASE=1
+REQUIRE_PACKAGES_FCL-PROCESS=1
 endif
 ifeq ($(FULL_TARGET),arm-gba)
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_FCL-BASE=1
+REQUIRE_PACKAGES_FCL-PROCESS=1
 endif
 ifeq ($(FULL_TARGET),arm-nds)
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_FCL-BASE=1
+REQUIRE_PACKAGES_FCL-PROCESS=1
 endif
 ifeq ($(FULL_TARGET),arm-embedded)
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_FCL-BASE=1
+REQUIRE_PACKAGES_FCL-PROCESS=1
 endif
 ifeq ($(FULL_TARGET),arm-symbian)
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_FCL-BASE=1
+REQUIRE_PACKAGES_FCL-PROCESS=1
 endif
 ifeq ($(FULL_TARGET),powerpc64-linux)
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_FCL-BASE=1
+REQUIRE_PACKAGES_FCL-PROCESS=1
 endif
 ifeq ($(FULL_TARGET),powerpc64-darwin)
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_UNIVINT=1
 REQUIRE_PACKAGES_FCL-BASE=1
+REQUIRE_PACKAGES_FCL-PROCESS=1
 endif
 ifeq ($(FULL_TARGET),powerpc64-embedded)
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_FCL-BASE=1
+REQUIRE_PACKAGES_FCL-PROCESS=1
 endif
 ifeq ($(FULL_TARGET),avr-embedded)
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_FCL-BASE=1
+REQUIRE_PACKAGES_FCL-PROCESS=1
 endif
 ifeq ($(FULL_TARGET),armeb-linux)
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_FCL-BASE=1
+REQUIRE_PACKAGES_FCL-PROCESS=1
 endif
 ifeq ($(FULL_TARGET),armeb-embedded)
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_FCL-BASE=1
+REQUIRE_PACKAGES_FCL-PROCESS=1
 endif
 ifeq ($(FULL_TARGET),mipsel-linux)
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_FCL-BASE=1
+REQUIRE_PACKAGES_FCL-PROCESS=1
 endif
 ifdef REQUIRE_PACKAGES_RTL
 PACKAGEDIR_RTL:=$(firstword $(subst /Makefile.fpc,,$(strip $(wildcard $(addsuffix /rtl/Makefile.fpc,$(PACKAGESDIR))))))
@@ -1522,6 +1583,32 @@ ifdef UNITDIR_FCL-BASE
 override COMPILER_UNITDIR+=$(UNITDIR_FCL-BASE)
 endif
 endif
+ifdef REQUIRE_PACKAGES_FCL-PROCESS
+PACKAGEDIR_FCL-PROCESS:=$(firstword $(subst /Makefile.fpc,,$(strip $(wildcard $(addsuffix /fcl-process/Makefile.fpc,$(PACKAGESDIR))))))
+ifneq ($(PACKAGEDIR_FCL-PROCESS),)
+ifneq ($(wildcard $(PACKAGEDIR_FCL-PROCESS)/units/$(TARGETSUFFIX)),)
+UNITDIR_FCL-PROCESS=$(PACKAGEDIR_FCL-PROCESS)/units/$(TARGETSUFFIX)
+else
+UNITDIR_FCL-PROCESS=$(PACKAGEDIR_FCL-PROCESS)
+endif
+ifdef CHECKDEPEND
+$(PACKAGEDIR_FCL-PROCESS)/$(FPCMADE):
+	$(MAKE) -C $(PACKAGEDIR_FCL-PROCESS) $(FPCMADE)
+override ALLDEPENDENCIES+=$(PACKAGEDIR_FCL-PROCESS)/$(FPCMADE)
+endif
+else
+PACKAGEDIR_FCL-PROCESS=
+UNITDIR_FCL-PROCESS:=$(subst /Package.fpc,,$(strip $(wildcard $(addsuffix /fcl-process/Package.fpc,$(UNITSDIR)))))
+ifneq ($(UNITDIR_FCL-PROCESS),)
+UNITDIR_FCL-PROCESS:=$(firstword $(UNITDIR_FCL-PROCESS))
+else
+UNITDIR_FCL-PROCESS=
+endif
+endif
+ifdef UNITDIR_FCL-PROCESS
+override COMPILER_UNITDIR+=$(UNITDIR_FCL-PROCESS)
+endif
+endif
 ifdef REQUIRE_PACKAGES_UNIVINT
 PACKAGEDIR_UNIVINT:=$(firstword $(subst /Makefile.fpc,,$(strip $(wildcard $(addsuffix /univint/Makefile.fpc,$(PACKAGESDIR))))))
 ifneq ($(PACKAGEDIR_UNIVINT),)

+ 1 - 1
utils/fpcmkcfg/Makefile.fpc

@@ -11,7 +11,7 @@ fpcpackage=y
 
 [require]
 tools=data2inc
-packages=fcl-base
+packages=fcl-base fcl-process
 tools=data2inc
 
 [default]

+ 3 - 3
utils/fpcmkcfg/fpc.cft

@@ -122,9 +122,6 @@
 #-Fr%basepath%/msg/errord.msg
 #-Fr%basepath%/msg/errorr.msg
 
-# path to the gcclib
-#-Fl%basepath%/lib
-
 #IFDEF FPCAPACHE_1_13
 -Fu%basepath%/units/$FPCTARGET/httpd13/
 #ELSE
@@ -140,6 +137,9 @@
 -Fu%basepath%/units/$FPCTARGET/*
 -Fu%basepath%/units/$FPCTARGET/rtl
 
+# path to the gcclib
+%gcclibpath%
+
 # searchpath for libraries
 #-Fl%basepath%/lib
 #-Fl/lib;/usr/lib

+ 15 - 15
utils/fpcmkcfg/fpccfg.inc

@@ -135,16 +135,13 @@ const DefaultConfig : array[0..23,1..240] of char=(
   '#-Fr%basepath%/msg/errord.msg'#010+
   '#-Fr%basepath%/msg/errorr.msg'#010+
   #010+
-  '# path to the gcclib'#010+
-  '#-Fl%basepath%/lib'#010+
-  #010+
   '#IFDEF FPCAPACHE_1_13'#010+
   '-Fu%basepath%/units/$FPCTARGET/httpd13/'#010+
   '#ELSE'#010+
   '#IFDEF FPCAPACHE_2_0'#010+
-  '-Fu%basepath%/units/$FPCTA','RGET/httpd20'#010+
+  '-Fu%basepath%/units/$FPCTARGET/httpd20'#010+
   '#ELSE'#010+
-  '-Fu%basepath%/units/$FPCTARGET/httpd22'#010+
+  '-Fu%basepath%/units/$F','PCTARGET/httpd22'#010+
   '#ENDIF'#010+
   '#ENDIF'#010+
   #010+
@@ -153,7 +150,10 @@ const DefaultConfig : array[0..23,1..240] of char=(
   '-Fu%basepath%/units/$FPCTARGET/*'#010+
   '-Fu%basepath%/units/$FPCTARGET/rtl'#010+
   #010+
-  '# searchp','ath for libraries'#010+
+  '# path to the gcclib'#010+
+  '%gcclibpath%'#010+
+  #010+
+  '# searchpath fo','r libraries'#010+
   '#-Fl%basepath%/lib'#010+
   '#-Fl/lib;/usr/lib'#010+
   #010+
@@ -165,8 +165,8 @@ const DefaultConfig : array[0..23,1..240] of char=(
   '# binutils prefix for cross compiling'#010+
   '#IFDEF FPC_CROSSCOMPILING'#010+
   '#IFDEF NEEDCROSSBINUTILS'#010+
-  '  -XP$FPCTARGET-',#010+
-  '#ENDIF'#010+
+  '  -XP$FPCTARGET-'#010+
+  '#ENDI','F'#010+
   '#ENDIF'#010+
   #010+
   #010+
@@ -179,11 +179,11 @@ const DefaultConfig : array[0..23,1..240] of char=(
   '# process)'#010+
   '#      -gc        generate checks for pointers'#010+
   '#      -gd        use dbx'#010+
-  '#      -gg        use ','gsym'#010+
-  '#      -gh        use heap trace unit (for memory leak 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 debugg','ing info'#010+
+  '#      -gw        generate dwarf debugging in','fo'#010+
   '#'#010+
   '# Enable debuginfo and use the line info unit by default'#010+
   '#-gl'#010+
@@ -199,19 +199,19 @@ const DefaultConfig : array[0..23,1..240] of char=(
   '# Miscellaneous'#010+
   '# -------------'#010+
   #010+
-  '# Write always a nice',' FPC logo ;)'#010+
+  '# Write always a nice FPC l','ogo ;)'#010+
   '-l'#010+
   #010+
   '# Verbosity'#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+
+  '#      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 compatibility m'+
+  '#      b : ','Show all procedure          r : Rhide/GCC compatibility m'+
   'ode'#010+
   '#          declarations if an error    x : Executable info (Win32 only'+
   ')'#010+
@@ -219,6 +219,6 @@ const DefaultConfig : array[0..23,1..240] of char=(
   '#'#010+
   '# Display Info, Warnings, Notes and Hints'#010+
   '-viwn'#010+
-  '# If you don'#039't want so much verbo','sity use'#010+
+  '# If you don'#039't want so much verbosity u','se'#010+
   '#-vw'#010
 );

+ 125 - 3
utils/fpcmkcfg/fpcmkcfg.pp

@@ -16,7 +16,7 @@
  **********************************************************************}
 program fpcmkcfg;
 
-uses SysUtils,Classes,fpTemplate;
+uses SysUtils,Classes,fpTemplate, process;
 
 {
   The inc files must be built from a template with the data2inc
@@ -38,6 +38,11 @@ Const
   BuildVersion={$I %FPCVERSION%};
   BuildTarget={$I %FPCTARGET%};
   BuildOSTarget={$I %FPCTARGETOS%};
+{$ifdef unix}
+  ExeExt = '';
+{$else unix}
+  ExeExt = '.exe';
+{$endif unix}
 
 
 Resourcestring
@@ -64,7 +69,8 @@ Resourcestring
   SErrBackupFailed    = 'Error: Backup of file "%s" to "%s" failed.';
   SErrDelBackupFailed = 'Error: Delete of old backup file "%s" failed.';
   SWarnIgnoringFile   = 'Warning: Ignoring non-existent file: ';
-  SWarnIgnoringPair   = 'Warning: ignoring wrong name/value pair: ';
+  SWarnIgnoringPair   = 'Warning: Ignoring wrong name/value pair: ';
+  SWarngccNotFound    = 'Warning: Could not find gcc. Unable to determine the gcclib path.';
 
 
 Var
@@ -91,7 +97,7 @@ function GetDefaultNeedCrossBinutilsIfdef: string;
 begin
   result := '';
   // On Darwin there is never a need for a crossbinutils prefix
-  if BuildOSTarget='Darwin' then
+  if SameText(BuildOSTarget,'Darwin') then
     Exit;
 
   if (BuildTarget = 'i386') or (BuildTarget = 'x86_64') then
@@ -111,6 +117,121 @@ begin
     result := '#DEFINE NEEDCROSSBINUTILS';
 end;
 
+function GetDefaultGCCDir: string;
+
+var GccExecutable: string;
+
+  function GetGccExecutable: string;
+  begin
+    if GccExecutable='' then
+      begin
+      GccExecutable := ExeSearch('gcc'+ExeExt,GetEnvironmentVariable('PATH'));
+      if GccExecutable='' then
+        begin
+        Writeln(StdErr,SWarngccNotFound);
+        GccExecutable:='-';
+        end;
+      end;
+    if GccExecutable = '-' then
+      result := ''
+    else
+      result := GccExecutable;
+  end;
+
+  function ExecuteProc(const CommandLine: string; ReadStdErr: boolean) : string;
+
+  const BufSize=2048;
+
+  var S: TProcess;
+      buf: array[0..BufSize-1] of byte;
+      count: integer;
+
+  begin
+    S:=TProcess.Create(Nil);
+    try
+      S.Commandline:=CommandLine;
+      S.Options:=[poUsePipes,poWaitOnExit];
+      S.execute;
+      Count:=s.output.read(buf,BufSize);
+      if (count=0) and ReadStdErr then
+        Count:=s.Stderr.read(buf,BufSize);
+      setlength(result,count);
+      move(buf[0],result[1],count);
+    finally
+      S.Free;
+    end;
+  end;
+
+  function Get4thWord(const AString: string): string;
+  var p: pchar;
+      spacecount: integer;
+      StartWord: pchar;
+  begin
+    if length(AString)>6 then
+      begin
+      p := @AString[1];
+      spacecount:=0;
+      StartWord:=nil;
+      while (not (p^ in [#0,#10,#13])) and ((p^<>' ') or (StartWord=nil)) do
+        begin
+        if p^=' ' then
+          begin
+          inc(spacecount);
+          if spacecount=3 then StartWord:=p+1;
+          end;
+        inc(p);
+        end;
+      if StartWord<>nil then
+        begin
+        SetLength(result,p-StartWord);
+        move(StartWord^,result[1],p-StartWord);
+        end
+      else
+        result := '';
+      end;
+  end;
+
+  function GetGccDirArch(const ACpuType, GCCParams: string) : string;
+  var ExecResult: string;
+      libgccFilename: string;
+      gccDir: string;
+  begin
+    ExecResult:=ExecuteProc(GetGccExecutable+' -v '+GCCParams, True);
+    libgccFilename:=Get4thWord(ExecResult);
+    if libgccFilename='' then
+      libgccFilename:=ExecuteProc(GetGccExecutable+' --print-libgcc-file-name '+GCCParams, False);
+    gccDir := ExtractFileDir(libgccFilename);
+    if gccDir='' then
+      result := ''
+    else if ACpuType = '' then
+      result := '-Fl'+gccDir
+    else
+      result := '#ifdef ' + ACpuType + LineEnding + '-Fl' + gccDir + LineEnding + '#endif';
+  end;
+
+begin
+  result := '';
+  GccExecutable:='';
+  if sametext(BuildOSTarget,'Freebsd') or sametext(BuildOSTarget,'Openbsd') then
+    result := '-Fl/usr/local/lib'
+  else if sametext(BuildOSTarget,'Netbsd') then
+    result := '-Fl/usr/pkg/lib'
+  else if sametext(BuildOSTarget,'Linux') then
+    begin
+    if (BuildTarget = 'i386') or (BuildTarget = 'x86_64') then
+      result := GetGccDirArch('cpui386','-m32') + LineEnding +
+                GetGccDirArch('cpux86_64','-m64')
+    else if (BuildTarget = 'powerpc') or (BuildTarget = 'powerpc64') then
+      result := GetGccDirArch('cpupowerpc','-m32') + LineEnding +
+                GetGccDirArch('cpupowerpc64','-m64')
+    end
+  else if sametext(BuildOSTarget,'Darwin') then
+    result := GetGccDirArch('cpupowerpc','-arch ppc') + LineEnding +
+              GetGccDirArch('cpupowerpc64','-arch ppc64') + LineEnding +
+              GetGccDirArch('cpui386','-arch i386') + LineEnding +
+              GetGccDirArch('cpux86_64','-arch x86_64');
+end;
+
 
 procedure Init;
 
@@ -130,6 +251,7 @@ begin
 
   TemplateParser.Values['LOCALREPOSITORY'] := GetDefaultLocalRepository;
   TemplateParser.Values['NEEDCROSSBINUTILSIFDEF'] := GetDefaultNeedCrossBinutilsIfdef;
+  TemplateParser.Values['GCCLIBPATH'] := GetDefaultGCCDIR;
 
   Cfg:=TStringList.Create;
   Cfg.Text:=StrPas(Addr(DefaultConfig[0][1]));