Ver Fonte

o based on a patch by ccrause:
+ support cpu-os-subarch-abi quadrupels also
* some issues fixed with my initial implementation

florian há 3 anos atrás
pai
commit
8c33de66cd

+ 16 - 0
packages/Makefile.fpc

@@ -27,6 +27,15 @@ endif
 ifdef CPU_TARGET
 FPC_TARGETOPT+=--cpu=$(CPU_TARGET)
 endif
+
+# CC
+ifdef SUBARCH
+FPC_TARGETOPT+=--subarch=$(SUBARCH)
+endif
+ifdef ABI
+FPC_TARGETOPT+=--abi=$(ABI)
+endif
+
 FPMAKE_BIN_CLEAN=$(wildcard ./fpmake$(SRCEXEEXT))
 LOCALFPMAKE=./fpmake$(SRCEXEEXT)
 # Get the location of the bootstrap-fpmkunit units
@@ -55,6 +64,13 @@ SUB_FPMAKE_SRCS=$(wildcard */fpmake.pp)
 # Do not pass the Makefile's unit and binary target locations. Fpmake uses it's own.
 override FPCOPT:=$(filter-out -FU%,$(FPCOPT))
 override FPCOPT:=$(filter-out -FE%,$(FPCOPT))
+
+# CC
+override FPCOPT:=$(filter-out -Cp%,$(FPCOPT))
+override FPCOPT:=$(filter-out -P%,$(FPCOPT))
+override FPCOPT:=$(filter-out -T%,$(FPCOPT))
+override FPCOPT:=$(filter-out -Ca%,$(FPCOPT))
+
 # Do not pass the package-unitdirectories. Fpmake adds those and this way they don't apear in the .fpm
 override FPCOPT:=$(filter-out $(addprefix -Fu,$(COMPILER_UNITDIR)),$(FPCOPT))# Compose general fpmake-parameters
 # Compose general fpmake-parameters

+ 46 - 0
packages/fpmkunit/src/fpmkunit.pp

@@ -1060,6 +1060,8 @@ Type
     FOptions: TStrings;
     FCPU: TCPU;
     FOS: TOS;
+    FSubArch: string;
+    FABI: string;
     FSourceCPU: TCPU;
     FSourceOS: TOS;
     FMode : TCompilerMode;
@@ -1114,6 +1116,11 @@ Type
     procedure SetCPU(const AValue: TCPU);
     procedure SetOptions(const AValue: TStrings);
     procedure SetOS(const AValue: TOS);
+
+    // CC
+    Property SubArch: string read FSubArch write FSubArch;
+    Property ABI: string read FABI write FABI;
+
     procedure SetPrefix(const AValue: String);
     procedure SetSearchPath(AValue: TStrings);
     procedure SetTarget(const AValue: String);
@@ -1887,6 +1894,11 @@ ResourceString
   SHelpCmdOptions     = 'Where options is one or more of the following:';
   SHelpCPU            = 'Compile for indicated CPU.';
   SHelpOS             = 'Compile for indicated OS';
+
+  // CC
+  SHelpSubArch        = 'Compile for indicated subarchitecture (if supported by CPU).';
+  SHelpABI            = 'Compile for indicated ABI.';
+
   SHelpTarget         = 'Compile for indicated target';
   SHelpList           = 'list commands instead of actually executing them.';
   SHelpPrefix         = 'Use indicated prefix directory for all commands.';
@@ -2473,7 +2485,17 @@ begin
   if ALimit83 then
     Result := OSToString(OS)
   else
+  begin
     Result:=CPUToString(CPU)+'-'+OSToString(OS);
+
+    // CC
+    if (CPU in [avr, arm]) and (Defaults.SubArch <> '') then
+    begin
+      result := result + '-' + Defaults.SubArch;
+      if (CPU = arm) and (Defaults.ABI <> '') then
+        result := result + '-' + Defaults.ABI;
+    end;
+  end;
 end;
 
 Function MakeTargetString(CPU : TCPU;OS: TOS) : String;
@@ -5015,6 +5037,11 @@ begin
   FNoFPCCfg:=False;
   FCPU:=cpuNone;
   FOS:=osNone;
+
+  // CC
+  FSubArch := '';
+  FABI := '';
+
   FUnitInstallDir:='$(baseinstalldir)units/$(target)/$(packagename)';
   FUnitConfigFilesInstallDir:='fpmkinst/$(target)';
   FBuildMode:=bmOneByOne;
@@ -5631,6 +5658,13 @@ begin
         Defaults.OS:=StringToOS(OptionArg(I));
         Defaults.ExplicitOSNone := OptionArg(I) = OSToString(osNone);
       end
+
+    // CC
+    else if Checkoption(I,'S','subarch') then
+      Defaults.SubArch := lowercase(OptionArg(I))
+    else if Checkoption(I,'ab','abi') then
+      Defaults.ABI := lowercase(OptionArg(I))
+
     else if Checkoption(I,'t','target') then
       Defaults.Target:=OptionArg(I)
     else if CheckOption(I,'lc','list-commands') then
@@ -5785,6 +5819,11 @@ begin
   LogOption('io','ignoreinvalidoption',SHelpIgnoreInvOpt);
   LogArgOption('C','cpu',SHelpCPU);
   LogArgOption('O','os',SHelpOS);
+
+  // CC
+  LogArgOption('S','subarch',SHelpSubArch);
+  LogArgOption('ab','abi',SHelpABI);
+
   LogArgOption('t','target',SHelpTarget);
   LogArgOption('P','prefix',SHelpPrefix);
   LogArgOption('B','baseinstalldir',SHelpBaseInstalldir);
@@ -7190,6 +7229,13 @@ begin
   if ExtractFileName(GetCompiler) = 'fpc' then
     Args.Add('-P'+CPUToString(Defaults.CPU));
 
+  // CC
+  // Add subarch and ABI if used
+  if Defaults.SubArch <> '' then
+    Args.Add('-Cp' + Defaults.SubArch);
+  if Defaults.ABI <> '' then
+    Args.Add('-Ca' + Defaults.ABI);
+
   // Compile mode
   If ATarget.Mode<>cmFPC then
     Args.Add('-M'+ModeToString(ATarget.Mode))

+ 16 - 0
packages/rtl-extra/Makefile.fpc

@@ -23,12 +23,28 @@ endif
 ifdef CPU_TARGET
 FPC_TARGETOPT+=--cpu=$(CPU_TARGET)
 endif
+
+# CC
+ifdef SUBARCH
+FPC_TARGETOPT+=--subarch=$(SUBARCH)
+endif
+ifdef ABI
+FPC_TARGETOPT+=--abi=$(ABI)
+endif
+
 LOCALFPMAKE=./fpmake$(SRCEXEEXT)
 
 [rules]
 # Do not pass the Makefile's unit and binary target locations. Fpmake uses it's own.
 override FPCOPT:=$(filter-out -FU%,$(FPCOPT))
 override FPCOPT:=$(filter-out -FE%,$(FPCOPT))
+
+# CC
+override FPCOPT:=$(filter-out -Cp%,$(FPCOPT))
+override FPCOPT:=$(filter-out -P%,$(FPCOPT))
+override FPCOPT:=$(filter-out -T%,$(FPCOPT))
+override FPCOPT:=$(filter-out -Ca%,$(FPCOPT))
+
 # Do not pass the package-unitdirectories. Fpmake adds those and this way they don't apear in the .fpm
 override FPCOPT:=$(filter-out $(addprefix -Fu,$(COMPILER_UNITDIR)),$(FPCOPT))# Compose general fpmake-parameters
 # Compose general fpmake-parameters

Diff do ficheiro suprimidas por serem muito extensas
+ 212 - 181
utils/fpcm/fpcmake.inc


+ 30 - 15
utils/fpcm/fpcmake.ini

@@ -258,6 +258,9 @@ else
 override FPCOPT+=-Ca$(ABI)
 endif
 
+# CC
+SUBARCH_ABI_SUFFIX=
+
 ifeq ($(CPU_TARGET),armeb)
 ARCH=arm
 override FPCOPT+=-Cb
@@ -281,6 +284,14 @@ ifeq ($(SUBARCH),)
 $(error When compiling for arm-embedded, a sub-architecture (e.g. SUBARCH=armv4t or SUBARCH=armv7m) must be defined)
 endif
 override FPCOPT+=-Cp$(SUBARCH)
+
+# CC
+ifeq ($(ABI),)
+SUBARCH_ABI_SUFFIX=-$(SUBARCH)
+else
+SUBARCH_ABI_SUFFIX=-$(SUBARCH)-$(ABI)
+endif
+
 endif
 
 ifeq ($(FULL_TARGET),avr-embedded)
@@ -289,6 +300,10 @@ ifeq ($(SUBARCH),)
 $(error When compiling for avr-embedded, a sub-architecture (e.g. SUBARCH=avr25 or SUBARCH=avr35) must be defined)
 endif
 override FPCOPT+=-Cp$(SUBARCH)
+
+# CC
+SUBARCH_ABI_SUFFIX=-$(SUBARCH)
+
 endif
 
 ifeq ($(FULL_TARGET),mipsel-embedded)
@@ -297,6 +312,10 @@ ifeq ($(SUBARCH),)
 $(error When compiling for mipsel-embedded, a sub-architecture (e.g. SUBARCH=pic32mx) must be defined)
 endif
 override FPCOPT+=-Cp$(SUBARCH)
+
+# CC
+SUBARCH_ABI_SUFFIX=-$(SUBARCH)
+
 endif
 
 ifeq ($(FULL_TARGET),xtensa-embedded)
@@ -329,7 +348,10 @@ else
 ifneq ($(filter $(OS_TARGET),$(LIMIT83fs)),)
 TARGETSUFFIX=$(OS_TARGET)
 else
-TARGETSUFFIX=$(FULL_TARGET)
+
+# CC
+TARGETSUFFIX=$(FULL_TARGET)$(SUBARCH_ABI_SUFFIX)
+
 endif
 SOURCESUFFIX=$(FULL_SOURCE)
 endif
@@ -339,6 +361,8 @@ ifneq ($(FULL_TARGET),$(FULL_SOURCE))
 CROSSCOMPILE=1
 endif
 
+
+
 # Check if the Makefile supports this target, but not
 # when the make target is to rebuild the makefile
 ifeq ($(findstring makefile,$(MAKECMDGOALS)),)
@@ -513,10 +537,7 @@ UNITSDIR:=$(wildcard $(FPCDIR)/units/$(TARGETSUFFIX))
 ifeq ($(UNITSDIR),)
 UNITSDIR:=$(wildcard $(FPCDIR)/units/$(OS_TARGET))
 endif
-# encode subarch?
-ifneq ($(SUBARCH),)
-UNITSDIR:=$(UNITSDIR)/$(SUBARCH)-$(ABI)
-endif
+
 
 # Packages dir
 PACKAGESDIR:=$(wildcard $(FPCDIR) $(FPCDIR)/packages)
@@ -663,9 +684,6 @@ COMPILER_UNITTARGETDIR=$(PACKAGEDIR_MAIN)/units/$(TARGETSUFFIX)
 else
 COMPILER_UNITTARGETDIR=units/$(TARGETSUFFIX)
 endif
-ifneq ($(SUBARCH),)
-COMPILER_UNITTARGETDIR:=$(COMPILER_UNITTARGETDIR)/$(SUBARCH)-$(ABI)
-endif
 endif
 ifndef COMPILER_TARGETDIR
 COMPILER_TARGETDIR=.
@@ -718,10 +736,6 @@ ifdef PACKAGE_NAME
 INSTALL_UNITDIR:=$(INSTALL_UNITDIR)/$(PACKAGE_NAME)
 endif
 endif
-# encode subarch?
-ifneq ($(SUBARCH),)
-INSTALL_UNITDIR:=$(INSTALL_UNITDIR)/$(SUBARCH)-$(ABI)
-endif
 endif
 
 # Where to install shared libraries
@@ -1286,9 +1300,10 @@ ZIPSOURCESUFFIX=.source
 ZIPEXAMPLESUFFIX=.examples
 ifdef CROSSCOMPILE
 ZIPSUFFIX=.$(SOURCESUFFIX)
-ZIPCROSSPREFIX=$(TARGETSUFFIX)-
+ZIPCROSSPREFIX=$(TARGETSUFFIX)
 else
-ZIPSUFFIX=.$(TARGETSUFFIX)
+ZIPSUFFIX=.$(TARGETSUFFIX)$(FILESUFFIX)
+
 ZIPCROSSPREFIX=
 endif
 endif
@@ -2024,7 +2039,7 @@ endif
 endif
 
 ifndef FULLZIPNAME
-FULLZIPNAME=$(ZIPCROSSPREFIX)$(ZIPPREFIX)$(ZIPNAME)$(ZIPSUFFIX)
+FULLZIPNAME=$(ZIPCROSSPREFIX)$(ZIPPREFIX)-$(ZIPNAME)$(ZIPSUFFIX)
 endif
 
 # ZipTarget

+ 1 - 1
utils/fpcm/revision.inc

@@ -1 +1 @@
-'2022-01-05 hash 53e5a4a03a'
+'2022-01-16 hash ad297f309d'

Alguns ficheiros não foram mostrados porque muitos ficheiros mudaram neste diff