Преглед изворни кода

* -r option to process target dirs also
* default changed to build only for current target
* removed auto building of required packages
* removed makefile target because it causes problems with
an internal rule of make

peter пре 24 година
родитељ
комит
3a853dae8e
6 измењених фајлова са 426 додато и 307 уклоњено
  1. 39 35
      utils/fpcm/Makefile
  2. 183 161
      utils/fpcm/fpcmake.inc
  3. 51 19
      utils/fpcm/fpcmake.ini
  4. 54 26
      utils/fpcm/fpcmake.pp
  5. 61 11
      utils/fpcm/fpcmmain.pp
  6. 38 55
      utils/fpcm/fpcmwr.pp

+ 39 - 35
utils/fpcm/Makefile

@@ -1,7 +1,8 @@
 #
-# Don't edit, this file is generated by FPCMake Version 1.1 [2002/01/06]
+# Don't edit, this file is generated by FPCMake Version 1.1 [2002/01/27]
 #
 default: all
+MAKEFILETARGETS=linux go32v2 win32 os2 freebsd beos netbsd amiga atari sunos qnx
 override PATH:=$(subst \,/,$(PATH))
 ifeq ($(findstring ;,$(PATH)),)
 inUnix=1
@@ -13,10 +14,7 @@ PWD:=$(strip $(wildcard $(addsuffix /pwd.exe,$(SEARCHPATH))))
 ifeq ($(PWD),)
 PWD:=$(strip $(wildcard $(addsuffix /pwd,$(SEARCHPATH))))
 ifeq ($(PWD),)
-nopwd:
-	@echo You need the GNU utils package to use this Makefile!
-	@echo Get ftp://ftp.freepascal.org/pub/fpc/dist/go32v2/utilgo32.zip
-	@exit
+$(error You need the GNU utils package to use this Makefile)
 else
 PWD:=$(firstword $(PWD))
 SRCEXEEXT=
@@ -94,23 +92,44 @@ ifndef FPC_VERSION
 FPC_VERSION:=$(shell $(FPC) -iV)
 endif
 export FPC FPC_VERSION
+ifeq ($(findstring 1.0.,$(FPC_VERSION)),)
+COMPILERINFO:=$(shell $(FPC) -iSP -iTP -iSO -iTO)
+ifndef CPU_SOURCE
+CPU_SOURCE:=$(word 1,$(COMPILERINFO))
+endif
 ifndef CPU_TARGET
-CPU_TARGET:=$(shell $(FPC) -iTP)
+CPU_TARGET:=$(word 2,$(COMPILERINFO))
+endif
+ifndef OS_SOURCE
+OS_SOURCE:=$(word 3,$(COMPILERINFO))
 endif
+ifndef OS_TARGET
+OS_TARGET:=$(word 4,$(COMPILERINFO))
+endif
+else
 ifndef CPU_SOURCE
 CPU_SOURCE:=$(shell $(FPC) -iSP)
 endif
-ifndef OS_TARGET
-OS_TARGET:=$(shell $(FPC) -iTO)
+ifndef CPU_TARGET
+CPU_TARGET:=$(shell $(FPC) -iTP)
 endif
 ifndef OS_SOURCE
 OS_SOURCE:=$(shell $(FPC) -iSO)
 endif
+ifndef OS_TARGET
+OS_TARGET:=$(shell $(FPC) -iTO)
+endif
+endif
 FULL_TARGET=$(CPU_TARGET)-$(OS_TARGET)
 FULL_SOURCE=$(CPU_SOURCE)-$(OS_SOURCE)
 ifneq ($(FULL_TARGET),$(FULL_SOURCE))
 CROSSCOMPILE=1
 endif
+ifeq ($(findstring makefile,$(MAKECMDGOALS)),)
+ifeq ($(findstring $(OS_TARGET),$(MAKEFILETARGETS)),)
+$(error The Makefile doesn't support target $(OS_TARGET), please run fpcmake first)
+endif
+endif
 export OS_TARGET OS_SOURCE CPU_TARGET CPU_SOURCE FULL_TARGET FULL_SOURCE CROSSCOMPILE
 ifdef FPCDIR
 override FPCDIR:=$(subst \,/,$(FPCDIR))
@@ -691,6 +710,7 @@ else
 TAROPT=vz
 TAREXT=.tar.gz
 endif
+override REQUIRE_PACKAGES=rtl fcl
 ifeq ($(OS_TARGET),linux)
 REQUIRE_PACKAGES_RTL=1
 REQUIRE_PACKAGES_PASZLIB=1
@@ -758,9 +778,6 @@ endif
 ifdef REQUIRE_PACKAGES_RTL
 PACKAGEDIR_RTL:=$(firstword $(subst /Makefile.fpc,,$(strip $(wildcard $(addsuffix /rtl/$(OS_TARGET)/Makefile.fpc,$(PACKAGESDIR))))))
 ifneq ($(PACKAGEDIR_RTL),)
-override COMPILEPACKAGES+=$(PACKAGEDIR_RTL)/$(FPCMADE)
-$(PACKAGEDIR_RTL)/$(FPCMADE):
-	$(MAKE) -C $(PACKAGEDIR_RTL) all
 ifneq ($(wildcard $(PACKAGEDIR_RTL)/$(OS_TARGET)),)
 UNITDIR_RTL=$(PACKAGEDIR_RTL)/$(OS_TARGET)
 else
@@ -782,9 +799,6 @@ endif
 ifdef REQUIRE_PACKAGES_PASZLIB
 PACKAGEDIR_PASZLIB:=$(firstword $(subst /Makefile.fpc,,$(strip $(wildcard $(addsuffix /paszlib/Makefile.fpc,$(PACKAGESDIR))))))
 ifneq ($(PACKAGEDIR_PASZLIB),)
-override COMPILEPACKAGES+=$(PACKAGEDIR_PASZLIB)/$(FPCMADE)
-$(PACKAGEDIR_PASZLIB)/$(FPCMADE):
-	$(MAKE) -C $(PACKAGEDIR_PASZLIB) all
 ifneq ($(wildcard $(PACKAGEDIR_PASZLIB)/$(OS_TARGET)),)
 UNITDIR_PASZLIB=$(PACKAGEDIR_PASZLIB)/$(OS_TARGET)
 else
@@ -806,9 +820,6 @@ endif
 ifdef REQUIRE_PACKAGES_INET
 PACKAGEDIR_INET:=$(firstword $(subst /Makefile.fpc,,$(strip $(wildcard $(addsuffix /inet/Makefile.fpc,$(PACKAGESDIR))))))
 ifneq ($(PACKAGEDIR_INET),)
-override COMPILEPACKAGES+=$(PACKAGEDIR_INET)/$(FPCMADE)
-$(PACKAGEDIR_INET)/$(FPCMADE):
-	$(MAKE) -C $(PACKAGEDIR_INET) all
 ifneq ($(wildcard $(PACKAGEDIR_INET)/$(OS_TARGET)),)
 UNITDIR_INET=$(PACKAGEDIR_INET)/$(OS_TARGET)
 else
@@ -830,9 +841,6 @@ endif
 ifdef REQUIRE_PACKAGES_FCL
 PACKAGEDIR_FCL:=$(firstword $(subst /Makefile.fpc,,$(strip $(wildcard $(addsuffix /fcl/Makefile.fpc,$(PACKAGESDIR))))))
 ifneq ($(PACKAGEDIR_FCL),)
-override COMPILEPACKAGES+=$(PACKAGEDIR_FCL)/$(FPCMADE)
-$(PACKAGEDIR_FCL)/$(FPCMADE):
-	$(MAKE) -C $(PACKAGEDIR_FCL) all
 ifneq ($(wildcard $(PACKAGEDIR_FCL)/$(OS_TARGET)),)
 UNITDIR_FCL=$(PACKAGEDIR_FCL)/$(OS_TARGET)
 else
@@ -854,9 +862,6 @@ endif
 ifdef REQUIRE_PACKAGES_MYSQL
 PACKAGEDIR_MYSQL:=$(firstword $(subst /Makefile.fpc,,$(strip $(wildcard $(addsuffix /mysql/Makefile.fpc,$(PACKAGESDIR))))))
 ifneq ($(PACKAGEDIR_MYSQL),)
-override COMPILEPACKAGES+=$(PACKAGEDIR_MYSQL)/$(FPCMADE)
-$(PACKAGEDIR_MYSQL)/$(FPCMADE):
-	$(MAKE) -C $(PACKAGEDIR_MYSQL) all
 ifneq ($(wildcard $(PACKAGEDIR_MYSQL)/$(OS_TARGET)),)
 UNITDIR_MYSQL=$(PACKAGEDIR_MYSQL)/$(OS_TARGET)
 else
@@ -878,9 +883,6 @@ endif
 ifdef REQUIRE_PACKAGES_IBASE
 PACKAGEDIR_IBASE:=$(firstword $(subst /Makefile.fpc,,$(strip $(wildcard $(addsuffix /ibase/Makefile.fpc,$(PACKAGESDIR))))))
 ifneq ($(PACKAGEDIR_IBASE),)
-override COMPILEPACKAGES+=$(PACKAGEDIR_IBASE)/$(FPCMADE)
-$(PACKAGEDIR_IBASE)/$(FPCMADE):
-	$(MAKE) -C $(PACKAGEDIR_IBASE) all
 ifneq ($(wildcard $(PACKAGEDIR_IBASE)/$(OS_TARGET)),)
 UNITDIR_IBASE=$(PACKAGEDIR_IBASE)/$(OS_TARGET)
 else
@@ -1030,15 +1032,16 @@ ifdef TARGET_RSTS
 override RSTFILES=$(addsuffix $(RSTEXT),$(TARGET_RSTS))
 override CLEANRSTFILES+=$(RSTFILES)
 endif
-.PHONY: fpc_packages fpc_all fpc_smart fpc_debug
+.PHONY: fpc_all fpc_smart fpc_debug fpc_release
 $(FPCMADE): $(ALLTARGET)
 	@$(ECHOREDIR) Compiled > $(FPCMADE)
-fpc_packages: $(COMPILEPACKAGES)
-fpc_all: fpc_packages $(FPCMADE)
+fpc_all: $(FPCMADE)
 fpc_smart:
 	$(MAKE) all LINKSMART=1 CREATESMART=1
 fpc_debug:
 	$(MAKE) all DEBUG=1
+fpc_release:
+	$(MAKE) all RELEASE=1
 .SUFFIXES: $(EXEEXT) $(PPUEXT) $(OEXT) .pas .pp .rc .res
 %$(PPUEXT): %.pp
 	$(COMPILER) $<
@@ -1190,6 +1193,8 @@ fpc_baseinfo:
 	@$(ECHO)
 	@$(ECHO)  == Directory info ==
 	@$(ECHO)
+	@$(ECHO)  Required pkgs... $(REQUIRE_PACKAGES)
+	@$(ECHO)
 	@$(ECHO)  Basedir......... $(BASEDIR)
 	@$(ECHO)  FPCDir.......... $(FPCDIR)
 	@$(ECHO)  CrossBinDir..... $(CROSSBINDIR)
@@ -1257,13 +1262,13 @@ fpc_info: $(INFORULES)
 .PHONY: fpc_makefile fpc_makefiles fpc_makefile_sub1 fpc_makefile_sub2 \
 	fpc_makefile_dirs
 fpc_makefile:
-	$(FPCMAKE) -w Makefile.fpc
+	$(FPCMAKE) -w -T$(OS_TARGET) Makefile.fpc
 fpc_makefile_sub1:
 ifdef TARGET_DIRS
-	$(FPCMAKE) -w $(addsuffix /Makefile.fpc,$(TARGET_DIRS))
+	$(FPCMAKE) -w -T$(OS_TARGET) $(addsuffix /Makefile.fpc,$(TARGET_DIRS))
 endif
 ifdef TARGET_EXAMPLEDIRS
-	$(FPCMAKE) -w $(addsuffix /Makefile.fpc,$(TARGET_EXAMPLEDIRS))
+	$(FPCMAKE) -w -T$(OS_TARGET) $(addsuffix /Makefile.fpc,$(TARGET_EXAMPLEDIRS))
 endif
 fpc_makefile_sub2: $(addsuffix _makefile_dirs,$(TARGET_DIRS) $(TARGET_EXAMPLEDIRS))
 fpc_makefile_dirs: fpc_makefile_sub1 fpc_makefile_sub2
@@ -1280,6 +1285,7 @@ export DATA2INC
 all: fpc_all
 debug: fpc_debug
 smart: fpc_smart
+release: fpc_release
 examples:
 shared:
 install: fpc_install
@@ -1294,10 +1300,8 @@ clean: fpc_clean
 distclean: fpc_distclean
 cleanall: fpc_cleanall
 info: fpc_info
-makefile: fpc_makefile
 makefiles: fpc_makefiles
-makefile_dirs: fpc_makefile_dirs
-.PHONY: all debug smart examples shared install sourceinstall exampleinstall distinstall zipinstall zipsourceinstall zipexampleinstall zipdistinstall clean distclean cleanall info makefile makefiles makefile_dirs
+.PHONY: all debug smart release examples shared install sourceinstall exampleinstall distinstall zipinstall zipsourceinstall zipexampleinstall zipdistinstall clean distclean cleanall info makefiles
 ifneq ($(wildcard fpcmake.loc),)
 include fpcmake.loc
 endif

Разлика између датотеке није приказан због своје велике величине
+ 183 - 161
utils/fpcm/fpcmake.inc


+ 51 - 19
utils/fpcm/fpcmake.ini

@@ -29,10 +29,7 @@ PWD:=$(strip $(wildcard $(addsuffix /pwd.exe,$(SEARCHPATH))))
 ifeq ($(PWD),)
 PWD:=$(strip $(wildcard $(addsuffix /pwd,$(SEARCHPATH))))
 ifeq ($(PWD),)
-nopwd:
-        @echo You need the GNU utils package to use this Makefile!
-        @echo Get ftp://ftp.freepascal.org/pub/fpc/dist/go32v2/utilgo32.zip
-        @exit
+$(error You need the GNU utils package to use this Makefile)
 else
 PWD:=$(firstword $(PWD))
 SRCEXEEXT=
@@ -152,34 +149,62 @@ export FPC FPC_VERSION
 # FPC Target Detection
 #####################################################################
 
-# Target CPU
+# For 1.1 and up we can use a single compiler call to retrieve
+# all needed information
+ifeq ($(findstring 1.0.,$(FPC_VERSION)),)
+
+COMPILERINFO:=$(shell $(FPC) -iSP -iTP -iSO -iTO)
+
+# Retrieve Target/Source CPU and Target/Source OS
+ifndef CPU_SOURCE
+CPU_SOURCE:=$(word 1,$(COMPILERINFO))
+endif
 ifndef CPU_TARGET
-CPU_TARGET:=$(shell $(FPC) -iTP)
+CPU_TARGET:=$(word 2,$(COMPILERINFO))
+endif
+ifndef OS_SOURCE
+OS_SOURCE:=$(word 3,$(COMPILERINFO))
 endif
+ifndef OS_TARGET
+OS_TARGET:=$(word 4,$(COMPILERINFO))
+endif
+
+else
 
-# Source CPU
+# Retrieve Target/Source CPU and Target/Source OS
 ifndef CPU_SOURCE
 CPU_SOURCE:=$(shell $(FPC) -iSP)
 endif
-
-# Target OS
+ifndef CPU_TARGET
+CPU_TARGET:=$(shell $(FPC) -iTP)
+endif
+ifndef OS_SOURCE
+OS_SOURCE:=$(shell $(FPC) -iSO)
+endif
 ifndef OS_TARGET
 OS_TARGET:=$(shell $(FPC) -iTO)
 endif
 
-# Source OS
-ifndef OS_SOURCE
-OS_SOURCE:=$(shell $(FPC) -iSO)
 endif
 
+
 # Full name of the target, including CPU and OS
 FULL_TARGET=$(CPU_TARGET)-$(OS_TARGET)
 FULL_SOURCE=$(CPU_SOURCE)-$(OS_SOURCE)
 
+# Cross compile flag
 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)),)
+ifeq ($(findstring $(OS_TARGET),$(MAKEFILETARGETS)),)
+$(error The Makefile doesn't support target $(OS_TARGET), please run fpcmake first)
+endif
+endif
+
 export OS_TARGET OS_SOURCE CPU_TARGET CPU_SOURCE FULL_TARGET FULL_SOURCE CROSSCOMPILE
 
 
@@ -1100,14 +1125,12 @@ fpc_examples: all $(EXAMPLEFILES) $(addsuffix _all,$(TARGET_EXAMPLEDIRS))
 # General compile rules
 #####################################################################
 
-.PHONY: fpc_packages fpc_all fpc_smart fpc_debug
+.PHONY: fpc_all fpc_smart fpc_debug fpc_release
 
 $(FPCMADE): $(ALLTARGET)
         @$(ECHOREDIR) Compiled > $(FPCMADE)
 
-fpc_packages: $(COMPILEPACKAGES)
-
-fpc_all: fpc_packages $(FPCMADE)
+fpc_all: $(FPCMADE)
 
 fpc_smart:
         $(MAKE) all LINKSMART=1 CREATESMART=1
@@ -1115,6 +1138,9 @@ fpc_smart:
 fpc_debug:
         $(MAKE) all DEBUG=1
 
+fpc_release:
+        $(MAKE) all RELEASE=1
+
 # General compile rules, available for both possible .pp and .pas extensions
 
 .SUFFIXES: $(EXEEXT) $(PPUEXT) $(OEXT) .pas .pp .rc .res
@@ -1460,6 +1486,8 @@ fpc_baseinfo:
         @$(ECHO)
         @$(ECHO)  == Directory info ==
         @$(ECHO)
+        @$(ECHO)  Required pkgs... $(REQUIRE_PACKAGES)
+        @$(ECHO)
         @$(ECHO)  Basedir......... $(BASEDIR)
         @$(ECHO)  FPCDir.......... $(FPCDIR)
         @$(ECHO)  CrossBinDir..... $(CROSSBINDIR)
@@ -1541,14 +1569,14 @@ fpc_info: $(INFORULES)
         fpc_makefile_dirs
 
 fpc_makefile:
-        $(FPCMAKE) -w Makefile.fpc
+        $(FPCMAKE) -w -T$(OS_TARGET) Makefile.fpc
 
 fpc_makefile_sub1:
 ifdef TARGET_DIRS
-        $(FPCMAKE) -w $(addsuffix /Makefile.fpc,$(TARGET_DIRS))
+        $(FPCMAKE) -w -T$(OS_TARGET) $(addsuffix /Makefile.fpc,$(TARGET_DIRS))
 endif
 ifdef TARGET_EXAMPLEDIRS
-        $(FPCMAKE) -w $(addsuffix /Makefile.fpc,$(TARGET_EXAMPLEDIRS))
+        $(FPCMAKE) -w -T$(OS_TARGET) $(addsuffix /Makefile.fpc,$(TARGET_EXAMPLEDIRS))
 endif
 
 fpc_makefile_sub2: $(addsuffix _makefile_dirs,$(TARGET_DIRS) $(TARGET_EXAMPLEDIRS))
@@ -1579,8 +1607,12 @@ endif
 
 # LCL Platform
 ifndef LCL_PLATFORM
+ifeq ($(OS_TARGET),win32)
+LCL_PLATFORM=win32
+else
 LCL_PLATFORM=gtk
 endif
+endif
 export LCL_PLATFORM
 
 # Check if the specified LCLDIR is correct

+ 54 - 26
utils/fpcm/fpcmake.pp

@@ -39,6 +39,7 @@ program fpcmake;
       ParaMode : TMode;
       ParaVerboseLevel : TVerboseLevel;
       ParaTargets : string;
+      ParaRecursive : boolean;
 
 
 {*****************************************************************************
@@ -85,10 +86,8 @@ program fpcmake;
       var
         CurrFPCMake : TFPCMakeConsole;
         CurrMakefile : TMakefileWriter;
-{$ifdef SUBDIRS}
-        s,Subdirs : string;
+        s,s2,Subdirs : string;
         t : ttarget;
-{$endif SUBDIRS}
       begin
         Show(V_Default,'Processing '+fn);
         CurrFPCMake:=nil;
@@ -102,11 +101,31 @@ program fpcmake;
           CurrFPCMake.LoadMakefileFPC;
 //          CurrFPCMake.Print;
 
-{$ifdef SUBDIRS}
+          { Add the subdirs }
           subdirs:=CurrFPCMake.GetVariable('target_dirs',true);
           for t:=low(ttarget) to high(ttarget) do
-           subdirs:=subdirs+' '+CurrFPCMake.GetVariable('target_dirs'+targetsuffix[t],true);
-{$endif SUBDIRS}
+           if t in CurrFPCMake.IncludeTargets then
+            begin
+              s2:=CurrFPCMake.GetVariable('target_dirs'+targetsuffix[t],true);
+              repeat
+                s:=GetToken(s2,' ');
+                if s='' then
+                 break;
+                AddTokenNoDup(subdirs,s,' ');
+              until false;
+            end;
+          AddToken(subdirs,CurrFPCMake.GetVariable('target_exampledirs',true),' ');
+          for t:=low(ttarget) to high(ttarget) do
+           if t in CurrFPCMake.IncludeTargets then
+            begin
+              s2:=CurrFPCMake.GetVariable('target_exampledirs'+targetsuffix[t],true);
+              repeat
+                s:=GetToken(s2,' ');
+                if s='' then
+                 break;
+                AddTokenNoDup(subdirs,s,' ');
+              until false;
+            end;
 
           { Write Makefile }
           CurrMakefile:=TMakefileWriter.Create(CurrFPCMake,ExtractFilePath(fn)+'Makefile');
@@ -118,24 +137,24 @@ program fpcmake;
           on e : exception do
            begin
              Error(e.message);
-  {$ifdef SUBDIRS}
              Subdirs:='';
-  {$endif SUBDIRS}
            end;
         end;
 {$endif NOEXCEPT}
         CurrFPCMake.Free;
 
-{$ifdef SUBDIRS}
         { Process subdirs }
-        writeln('Subdirs found: ',subdirs);
-        repeat
-          s:=GetToken(subdirs);
-          if s='' then
-           break;
-          ProcessFile(ExtractFilePath(fn)+s+'/Makefile.fpc');
-        until false;
-{$endif SUBDIRS}
+        if (Subdirs<>'') and
+           ParaRecursive then
+         begin
+           Show(v_Verbose,'Subdirs found: '+subdirs);
+           repeat
+             s:=GetToken(subdirs,' ');
+             if s='' then
+              break;
+             ProcessFile_Makefile(ExtractFilePath(fn)+s+'/Makefile.fpc');
+           until false;
+         end;
 
       end;
 
@@ -222,10 +241,11 @@ begin
   writeln(' -w  Write Makefile');
   writeln('');
   writeln('Options:');
-  writeln(' -T<target>[,target]   Support only specified targets');
-  writeln(' -v                    Be more verbose');
-  writeln(' -q                    Be quiet');
-  writeln(' -h                    This help screen');
+  writeln(' -T<target>[,target] Support only specified targets');
+  writeln(' -r                  Recursively process target directories from Makefile.fpc');
+  writeln(' -v                  Be more verbose');
+  writeln(' -q                  Be quiet');
+  writeln(' -h                  This help screen');
   Halt(0);
 end;
 
@@ -236,15 +256,15 @@ Procedure ProcessOpts;
   Process command line opions, and checks if command line options OK.
 }
 const
-  ShortOpts = 'pwqvhT:';
+  ShortOpts = 'pwqrvhT:';
 var
   C : char;
 begin
-  if paramcount=0 then
-   usage;
 { Reset }
-  ParaMode:=m_none;
+  ParaMode:=m_Makefile;
   ParaVerboseLevel:=v_default;
+  ParaTargets:=LowerCase({$I %FPCTARGETOS});
+{ Parse options }
   repeat
     c:=Getopt (ShortOpts);
     Case C of
@@ -252,6 +272,7 @@ begin
       'p' : ParaMode:=m_PackageFpc;
       'w' : ParaMode:=m_Makefile;
       'q' : ParaVerboseLevel:=v_quiet;
+      'r' : ParaRecursive:=true;
       'v' : ParaVerboseLevel:=v_verbose;
       'T' : ParaTargets:=OptArg;
       '?' : Usage;
@@ -270,7 +291,14 @@ begin
 end.
 {
   $Log$
-  Revision 1.6  2001-08-02 20:50:29  peter
+  Revision 1.7  2002-01-27 21:42:35  peter
+    * -r option to process target dirs also
+    * default changed to build only for current target
+    * removed auto building of required packages
+    * removed makefile target because it causes problems with
+      an internal rule of make
+
+  Revision 1.6  2001/08/02 20:50:29  peter
     * -T<target> support
     * better error reporting for not found dirs
     * some cleanups and nicer strings

+ 61 - 11
utils/fpcm/fpcmmain.pp

@@ -172,6 +172,7 @@ interface
     function posidx(const substr,s : string;idx:integer):integer;
     function GetToken(var s:string;sep:char):string;
     procedure AddToken(var s:string;const tok:string;sep:char);
+    procedure AddTokenNoDup(var s:string;const s2:string;sep:char);
 
 
 implementation
@@ -275,6 +276,45 @@ implementation
       end;
 
 
+    procedure AddTokenNoDup(var s:string;const s2:string;sep:char);
+      var
+        i,idx : integer;
+        again,add : boolean;
+      begin
+        add:=false;
+        idx:=0;
+        repeat
+          again:=false;
+          i:=posidx(s2,s,idx);
+          if (i=0) then
+           add:=true
+          else
+           if (i=1) then
+            begin
+              if (length(s)>length(s2)) and
+                 (s[length(s2)+1]<>sep) then
+               add:=true;
+            end
+          else
+           if (i>1) and
+              ((s[i-1]<>sep) or
+               ((length(s)>=i+length(s2)) and (s[i+length(s2)]<>sep))) then
+            begin
+              idx:=i+length(s2);
+              again:=true;
+            end;
+        until not again;
+        if add then
+         begin
+           if s='' then
+            s:=s2
+           else
+            s:=s+sep+s2;
+         end;
+      end;
+
+
+
 {****************************************************************************
                                TKeyValueItem
 ****************************************************************************}
@@ -640,6 +680,13 @@ implementation
           hs:=LowerCase(GetToken(hslst,','));
           if hs='' then
            break;
+          { target 'all' includes all targets }
+          if hs='all' then
+           begin
+             for t:=low(TTarget) to high(TTarget) do
+              include(FIncludeTargets,t);
+             break;
+           end;
           for t:=low(TTarget) to high(TTarget) do
            if hs=TargetStr[t] then
             include(FIncludeTargets,t);
@@ -1088,17 +1135,13 @@ implementation
       var
         hs,s : string;
       begin
-        { LCL Platform }
-        s:=GetVariable('lcl_platform',true);
-        if s='' then
-         SetVariable('lcl_platform','gtk',false);
         { Already set LCLDIR }
-        hs:=SubstVariables('$(wildcard $(LCLDIR)/units/$(LCL_PLATFORM))');
+        hs:=SubstVariables('$(wildcard $(LCLDIR)/units)');
         { Load from environment }
         if hs='' then
          begin
            SetVariable('LCLDIR',GetEnv('LCLDIR'),false);
-           hs:=SubstVariables('$(wildcard $(LCLDIR)/units/$(LCL_PLATFORM))');
+           hs:=SubstVariables('$(wildcard $(LCLDIR)/units)');
          end;
         { default_lcldir }
         if hs='' then
@@ -1114,20 +1157,20 @@ implementation
 {$endif}
                s:=ExtractFilePath(FFileName)+s;
               SetVariable('LCLDIR',s,false);
-              hs:=SubstVariables('$(wildcard $(LCLDIR)/units/$(LCL_PLATFORM))');
+              hs:=SubstVariables('$(wildcard $(LCLDIR)/units)');
             end
          end;
         { OS defaults }
-{$ifdef UNIX}
         if hs='' then
          begin
-           hs:=SubstVariables('$(subst /units/$(LCL_PLATFORM),,$(firstword $(wildcard $(addsuffix /units/$(LCL_PLATFORM),$(BASEDIR)/lcl $(BASEDIR)))))');
+           hs:=SubstVariables('$(subst /units,,$(firstword $(wildcard $(addsuffix /units,$(BASEDIR)/lcl $(BASEDIR)))))');
            if hs<>'' then
             SetVariable('LCLDIR',hs,false);
          end;
+{$ifdef UNIX}
         if hs='' then
          begin
-           hs:=SubstVariables('$(subst /units/$(LCL_PLATFORM),,$(firstword $(wildcard $(addsuffix /lib/lazarus/units/$(LCL_PLATFORM),/usr/local /usr))))');
+           hs:=SubstVariables('$(subst /units,,$(firstword $(wildcard $(addsuffix /lib/lazarus/units,/usr/local /usr))))');
            if hs<>'' then
             SetVariable('LCLDIR',hs,false);
          end;
@@ -1434,7 +1477,14 @@ implementation
 end.
 {
   $Log$
-  Revision 1.19  2002-01-06 21:50:04  peter
+  Revision 1.20  2002-01-27 21:42:35  peter
+    * -r option to process target dirs also
+    * default changed to build only for current target
+    * removed auto building of required packages
+    * removed makefile target because it causes problems with
+      an internal rule of make
+
+  Revision 1.19  2002/01/06 21:50:04  peter
     * lcl updates
     * small optimizes for package check
 

+ 38 - 55
utils/fpcm/fpcmwr.pp

@@ -30,35 +30,35 @@ interface
       );
 
       trules=(
-        r_all,r_debug,r_smart,
+        r_all,r_debug,r_smart,r_release,
         r_examples,
         r_shared,
         r_install,r_sourceinstall,r_exampleinstall,r_distinstall,
         r_zipinstall,r_zipsourceinstall,r_zipexampleinstall,r_zipdistinstall,
         r_clean,r_distclean,r_cleanall,
-        r_info,r_makefile,r_makefiles,r_makefile_dirs
+        r_info,r_makefiles
       );
 
 
     const
       rule2str : array[trules] of string=(
-        'all','debug','smart',
+        'all','debug','smart','release',
         'examples',
         'shared',
         'install','sourceinstall','exampleinstall','distinstall',
         'zipinstall','zipsourceinstall','zipexampleinstall','zipdistinstall',
         'clean','distclean','cleanall',
-        'info','makefile','makefiles','makefile_dirs'
+        'info','makefiles'
       );
 
       rule2sec : array[trules] of tsections=(
-        sec_compile,sec_compile,sec_compile,
+        sec_compile,sec_compile,sec_compile,sec_compile,
         sec_examples,
         sec_libs,
         sec_install,sec_install,sec_install,sec_distinstall,
         sec_zipinstall,sec_zipinstall,sec_zipinstall,sec_zipinstall,
         sec_clean,sec_clean,sec_clean,
-        sec_info,sec_makefile,sec_makefile,sec_makefile
+        sec_info,sec_makefile
       );
 
 
@@ -88,6 +88,7 @@ interface
         function  CheckTargetVariable(const inivar:string):boolean;
         function  CheckVariable(const inivar:string):boolean;
         procedure AddDefaultTools;
+        procedure AddMakefileTargets;
         procedure OptimizeSections;
       public
         constructor Create(AFPCMake:TFPCMake;const AFileName:string);
@@ -154,44 +155,6 @@ implementation
       end;
 
 
-    procedure AddStrNoDup(var s:string;const s2:string);
-      var
-        i,idx : longint;
-        again,add : boolean;
-      begin
-        add:=false;
-        idx:=0;
-        repeat
-          again:=false;
-          i:=posidx(s2,s,idx);
-          if (i=0) then
-           add:=true
-          else
-           if (i=1) then
-            begin
-              if (length(s)>length(s2)) and
-                 (s[length(s2)+1]<>' ') then
-               add:=true;
-            end
-          else
-           if (i>1) and
-              ((s[i-1]<>' ') or
-               ((length(s)>=i+length(s2)) and (s[i+length(s2)]<>' '))) then
-            begin
-              idx:=i+length(s2);
-              again:=true;
-            end;
-        until not again;
-        if add then
-         begin
-           if s='' then
-            s:=s2
-           else
-            s:=s+' '+s2;
-         end;
-      end;
-
-
     procedure FixTab(sl:TStringList);
       var
         i,j,k : integer;
@@ -394,7 +357,7 @@ implementation
            end;
           FOutput.Add(prefix+VarName(name)+'=1');
           { add to the list of dirs without duplicates }
-          AddStrNoDup(result,name);
+          AddTokenNoDup(result,name,' ');
         until false;
         for t:=low(TTarget) to high(TTarget) do
          if t in FInput.IncludeTargets then
@@ -418,7 +381,7 @@ implementation
                   end;
                  FOutput.Add(prefix+VarName(name)+'=1');
                  { add to the list of dirs without duplicates }
-                 AddStrNoDup(result,name);
+                 AddTokenNoDup(result,name,' ');
                until false;
                FOutput.Add('endif');
              end;
@@ -499,14 +462,14 @@ implementation
             call other targets with a only extra settings, if the
             section was not included, then still process the targets }
           if CheckTargetVariable('target_dirs') and
-             (not(rule in [r_info,r_shared,r_smart,r_debug,r_distinstall]) or
+             (not(rule in [r_info,r_shared,r_smart,r_debug,r_release,r_distinstall]) or
               not FHasSection[Rule2Sec[rule]]) then
            begin
              if CheckVariable('default_dir') then
               hs:=hs+' $(addsuffix _'+rule2str[rule]+',$(DEFAULT_DIR))'
              else
               if not(rule in [r_sourceinstall,r_zipinstall,r_zipsourceinstall,
-                              r_makefile,r_makefiles,r_makefile_dirs]) or
+                              r_makefiles]) or
                  not(CheckVariable('package_name')) then
                hs:=hs+' $(addsuffix _'+rule2str[rule]+',$(TARGET_DIRS))';
            end;
@@ -592,13 +555,9 @@ implementation
             direct in the corresponding target directory }
           if pack='rtl' then
            FOutput.Add(packdirvar+':=$(firstword $(subst /Makefile.fpc,,$(strip $(wildcard $(addsuffix /'+pack+'/$(OS_TARGET)/Makefile.fpc,$(PACKAGESDIR))))))')
-          else 
+          else
            FOutput.Add(packdirvar+':=$(firstword $(subst /Makefile.fpc,,$(strip $(wildcard $(addsuffix /'+pack+'/Makefile.fpc,$(PACKAGESDIR))))))');
           FOutput.Add('ifneq ($('+packdirvar+'),)');
-          { If Packagedir found look for FPCMade }
-          FOutput.Add('override COMPILEPACKAGES+=$('+packdirvar+')/$(FPCMADE)');
-          FOutput.Add('$('+packdirvar+')/$(FPCMADE):');
-          FOutput.Add(#9'$(MAKE) -C $('+packdirvar+') all');
           { Create unit dir, check if os dependent dir exists }
           FOutput.Add('ifneq ($(wildcard $('+packdirvar+')/$(OS_TARGET)),)');
           FOutput.Add(unitdirvar+'=$('+packdirvar+')/$(OS_TARGET)');
@@ -644,7 +603,7 @@ implementation
                for i:=0 to sl.count-1 do
                 begin
                   FOutput.Add(prefix+VarName(sl[i])+'=1');
-                  AddStrNoDup(reqs,sl[i]);
+                  AddTokenNoDup(reqs,sl[i],' ');
                 end;
                FOutput.Add('endif');
              end;
@@ -677,6 +636,20 @@ implementation
         AddIniSection('defaulttools');
       end;
 
+    procedure TMakefileWriter.AddMakefileTargets;
+      var
+        s : string;
+        t : Ttarget;
+      begin
+        s:='';
+        for t:=low(ttarget) to high(ttarget) do
+         if t in FInput.IncludeTargets then
+          begin
+            AddToken(s,TargetStr[t],' ');
+          end;
+        FOutput.Add('MAKEFILETARGETS='+s);
+      end;
+
     procedure TMakefileWriter.OptimizeSections;
       var
         SkippedSecs :integer;
@@ -747,6 +720,8 @@ implementation
             Add('default: '+FInput.GetVariable('default_rule',false))
            else
             Add('default: all');
+           { Supported targets by this Makefile }
+           AddMakefileTargets;
            { Add automatic detect sections }
            AddIniSection('osdetect');
            { Forced target }
@@ -825,6 +800,7 @@ implementation
            { Add default tools }
            AddDefaultTools;
            { Required packages }
+           AddVariable('require_packages');
            AddRequiredPackages;
            { commandline }
            AddIniSection('command_begin');
@@ -884,7 +860,14 @@ implementation
 end.
 {
   $Log$
-  Revision 1.19  2002-01-06 21:50:05  peter
+  Revision 1.20  2002-01-27 21:42:35  peter
+    * -r option to process target dirs also
+    * default changed to build only for current target
+    * removed auto building of required packages
+    * removed makefile target because it causes problems with
+      an internal rule of make
+
+  Revision 1.19  2002/01/06 21:50:05  peter
     * lcl updates
     * small optimizes for package check
 

Неке датотеке нису приказане због велике количине промена