Browse Source

* zipsourcesinstall
* zip fixes, bzip2 support with USETAR=bz2
* multi pkg's support to include several dirs

peter 25 years ago
parent
commit
9c2c5c7c8e
3 changed files with 536 additions and 347 deletions
  1. 213 206
      utils/fpcmake.inc
  2. 66 48
      utils/fpcmake.ini
  3. 257 93
      utils/fpcmake.pp

File diff suppressed because it is too large
+ 213 - 206
utils/fpcmake.inc


+ 66 - 48
utils/fpcmake.ini

@@ -440,8 +440,27 @@ endif
 endif
 endif
 export ZIPPROG
 export ZIPPROG
 
 
-ifndef ZIPEXT
+ZIPOPT=-9
 ZIPEXT=.zip
 ZIPEXT=.zip
+
+[tool_tar]
+# Tar
+ifndef TARPROG
+TARPROG:=$(strip $(wildcard $(addsuffix /tar$(EXEEXT),$(SEARCHPATH))))
+ifeq ($(TARPROG),)
+TARPROG=
+else
+TARPROG:=$(firstword $(TARPROG))
+endif
+endif
+export TARPROG
+
+ifeq ($(USETAR),bz2)
+TAROPT=vI
+TAREXT=.tar.bz2
+else
+TAROPT=vz
+TAREXT=.tar.gz
 endif
 endif
 
 
 
 
@@ -460,7 +479,6 @@ SMARTEXT=.sl
 STATICLIBEXT=.a
 STATICLIBEXT=.a
 SHAREDLIBEXT=.so
 SHAREDLIBEXT=.so
 RSTEXT=.rst
 RSTEXT=.rst
-PACKAGESUFFIX=
 FPCMADE=fpcmade
 FPCMADE=fpcmade
 
 
 # Go32v1
 # Go32v1
@@ -471,19 +489,16 @@ ASMEXT=.s1
 SMARTEXT=.sl1
 SMARTEXT=.sl1
 STATICLIBEXT=.a1
 STATICLIBEXT=.a1
 SHAREDLIBEXT=.so1
 SHAREDLIBEXT=.so1
-PACKAGESUFFIX=v1
 FPCMADE=fpcmade.v1
 FPCMADE=fpcmade.v1
 endif
 endif
 
 
 # Go32v2
 # Go32v2
 ifeq ($(OS_TARGET),go32v2)
 ifeq ($(OS_TARGET),go32v2)
-PACKAGESUFFIX=go32
 FPCMADE=fpcmade.dos
 FPCMADE=fpcmade.dos
 endif
 endif
 
 
 # Linux
 # Linux
 ifeq ($(OS_TARGET),linux)
 ifeq ($(OS_TARGET),linux)
-PACKAGESUFFIX=linux
 FPCMADE=fpcmade.lnx
 FPCMADE=fpcmade.lnx
 endif
 endif
 
 
@@ -495,7 +510,6 @@ ASMEXT=.sw
 SMARTEXT=.slw
 SMARTEXT=.slw
 STATICLIBEXT=.aw
 STATICLIBEXT=.aw
 SHAREDLIBEXT=.dll
 SHAREDLIBEXT=.dll
-PACKAGESUFFIX=w32
 FPCMADE=fpcmade.w32
 FPCMADE=fpcmade.w32
 endif
 endif
 
 
@@ -507,7 +521,6 @@ OEXT=.oo2
 SMARTEXT=.so
 SMARTEXT=.so
 STATICLIBEXT=.ao2
 STATICLIBEXT=.ao2
 SHAREDLIBEXT=.dll
 SHAREDLIBEXT=.dll
-PACKAGESUFFIX=os2
 FPCMADE=fpcmade.os2
 FPCMADE=fpcmade.os2
 endif
 endif
 
 
@@ -550,6 +563,12 @@ endif
 endif
 endif
 export PREFIXINSTALLDIR
 export PREFIXINSTALLDIR
 
 
+# Where to place the resulting zip files
+ifndef DESTZIPDIR
+DESTZIPDIR:=$(BASEDIR)
+endif
+export DESTZIPDIR
+
 
 
 [dir_install]
 [dir_install]
 #####################################################################
 #####################################################################
@@ -598,6 +617,9 @@ SOURCEINSTALLDIR=$(PREFIXINSTALLDIR)/src/fpc-$(FPC_VERSION)
 else
 else
 SOURCEINSTALLDIR=$(BASEINSTALLDIR)/source
 SOURCEINSTALLDIR=$(BASEINSTALLDIR)/source
 endif
 endif
+ifdef SOURCESUBDIR
+SOURCEINSTALLDIR:=$(SOURCEINSTALLDIR)/$(SOURCESUBDIR)
+endif
 endif
 endif
 
 
 # Where the doc files will be stored
 # Where the doc files will be stored
@@ -802,6 +824,7 @@ override COMPILER:=$(FPC) $(FPCOPT)
 # Package depends
 # Package depends
 #####################################################################
 #####################################################################
 
 
+
 [loaderrules]
 [loaderrules]
 #####################################################################
 #####################################################################
 # Loaders
 # Loaders
@@ -893,7 +916,6 @@ fpc_examples: all $(EXAMPLEFILES)
 fpc_test: examples
 fpc_test: examples
 
 
 
 
-
 [compilerules]
 [compilerules]
 #####################################################################
 #####################################################################
 # General compile rules
 # General compile rules
@@ -964,7 +986,7 @@ endif
 # Install rules
 # Install rules
 #####################################################################
 #####################################################################
 
 
-.PHONY: fpc_showinstall fpc_install
+.PHONY: fpc_showinstall fpc_install fpc_sourceinstall
 
 
 ifdef EXTRAINSTALLUNITS
 ifdef EXTRAINSTALLUNITS
 override INSTALLPPUFILES+=$(addsuffix $(PPUEXT),$(EXTRAINSTALLUNITS))
 override INSTALLPPUFILES+=$(addsuffix $(PPUEXT),$(EXTRAINSTALLUNITS))
@@ -1026,24 +1048,32 @@ ifdef EXTRAINSTALLFILES
         $(INSTALL) $(EXTRAINSTALLFILES) $(DATAINSTALLDIR)
         $(INSTALL) $(EXTRAINSTALLFILES) $(DATAINSTALLDIR)
 endif
 endif
 
 
-
-[sourceinstallrules]
-#####################################################################
-# Source install rules
-#####################################################################
-
-.PHONY: fpc_sourceinstall
+ifndef SOURCETOPDIR
+SOURCETOPDIR=$(BASEDIR)
+endif
 
 
 fpc_sourceinstall: clean
 fpc_sourceinstall: clean
         $(MKDIR) $(SOURCEINSTALLDIR)
         $(MKDIR) $(SOURCEINSTALLDIR)
-        $(COPYTREE) $(BASEDIR) $(SOURCEINSTALLDIR)
+        $(COPYTREE) $(SOURCETOPDIR) $(SOURCEINSTALLDIR)
+
 
 
 [zipinstallrules]
 [zipinstallrules]
 #####################################################################
 #####################################################################
 # Zip
 # Zip
 #####################################################################
 #####################################################################
 
 
-.PHONY: fpc_zipinstall fpc_zipinstalladd
+.PHONY: fpc_zipinstall fpc_zipsourceinstall
+
+# Create suffix to add
+ifndef PACKAGESUFFIX
+PACKAGESUFFIX=$(OS_TARGET)
+ifeq ($(OS_TARGET),go32v2)
+PACKAGESUFFIX=dos
+endif
+ifeq ($(OS_TARGET),win32)
+PACKAGESUFFIX=w32
+endif
+endif
 
 
 # Temporary path to pack a file
 # Temporary path to pack a file
 ifndef PACKDIR
 ifndef PACKDIR
@@ -1054,43 +1084,20 @@ PACKDIR=/tmp/fpc-pack
 endif
 endif
 endif
 endif
 
 
-# Test dir if none specified
-ifndef DESTZIPDIR
-DESTZIPDIR:=$(BASEDIR)
-endif
-
 # Maybe create default zipname from packagename
 # Maybe create default zipname from packagename
 ifndef ZIPNAME
 ifndef ZIPNAME
 ifdef PACKAGENAME
 ifdef PACKAGENAME
-ZIPNAME=$(PACKAGENAME)$(PACKAGESUFFIX)
-endif
-endif
-
-# Add .zip/.tar.gz extension
-ifdef ZIPNAME
-ifndef inlinux
-override ZIPNAME:=$(ZIPNAME)$(ZIPEXT)
+ZIPNAME=$(PACKAGEPREFIX)$(PACKAGENAME)$(PACKAGESUFFIX)
 endif
 endif
 endif
 endif
 
 
-# Note: This will not remove the zipfile first
-fpc_zipinstalladd:
-ifndef ZIPNAME
-        @$(ECHO) "Please specify ZIPNAME!"
-        @exit 1
-else
-        $(MAKE) $(ZIPTARGET) PREFIXINSTALLDIR=$(PACKDIR)
+# Use tar by default under linux
+ifndef USEZIP
 ifdef inlinux
 ifdef inlinux
-        gzip -d $(DESTZIPDIR)/$(ZIPNAME).tar.gz
-        cd $(PACKDIR) ; tar rv --file $(DESTZIPDIR)/$(ZIPNAME).tar * ; cd $(BASEDIR)
-        gzip $(DESTZIPDIR)/$(ZIPNAME).tar
-else
-        cd $(PACKDIR) ; $(ZIPPROG) $(DESTZIPDIR)/$(ZIPNAME) * ; cd $(BASEDIR)
+USETAR=1
 endif
 endif
-        $(DELTREE) $(PACKDIR)
 endif
 endif
 
 
-# First remove the zip and then install
 fpc_zipinstall:
 fpc_zipinstall:
 ifndef ZIPNAME
 ifndef ZIPNAME
         @$(ECHO) "Please specify ZIPNAME!"
         @$(ECHO) "Please specify ZIPNAME!"
@@ -1098,14 +1105,17 @@ ifndef ZIPNAME
 else
 else
         $(DEL) $(DESTZIPDIR)/$(ZIPNAME)
         $(DEL) $(DESTZIPDIR)/$(ZIPNAME)
         $(MAKE) $(ZIPTARGET) PREFIXINSTALLDIR=$(PACKDIR)
         $(MAKE) $(ZIPTARGET) PREFIXINSTALLDIR=$(PACKDIR)
-ifdef inlinux
-        cd $(PACKDIR) ; tar cvz --file $(DESTZIPDIR)/$(ZIPNAME).tar.gz * ; cd $(BASEDIR)
+ifdef USETAR
+        cd $(PACKDIR) ; $(TARPROG) c$(TAROPT) --file $(DESTZIPDIR)/$(ZIPNAME)$(TAREXT) * ; cd $(BASEDIR)
 else
 else
-        cd $(PACKDIR) ; $(ZIPPROG) $(DESTZIPDIR)/$(ZIPNAME) * ; cd $(BASEDIR)
+        cd $(PACKDIR) ; $(ZIPPROG) -Dr $(ZIPOPT) $(DESTZIPDIR)/$(ZIPNAME)$(ZIPEXT) * ; cd $(BASEDIR)
 endif
 endif
         $(DELTREE) $(PACKDIR)
         $(DELTREE) $(PACKDIR)
 endif
 endif
 
 
+fpc_zipsourceinstall:
+        $(MAKE) fpc_zipinstall ZIPTARGET=sourceinstall PACKAGESUFFIX=src
+
 
 
 [cleanrules]
 [cleanrules]
 #####################################################################
 #####################################################################
@@ -1268,6 +1278,9 @@ fpc_infoinstall:
 ifdef DATE
 ifdef DATE
         @$(ECHO)  DateStr.............. $(DATESTR)
         @$(ECHO)  DateStr.............. $(DATESTR)
 endif
 endif
+ifdef PACKAGEPREFIX
+        @$(ECHO)  PackagePrefix........ $(PACKAGEPREFIX)
+endif
 ifdef PACKAGENAME
 ifdef PACKAGENAME
         @$(ECHO)  PackageName.......... $(PACKAGENAME)
         @$(ECHO)  PackageName.......... $(PACKAGENAME)
 endif
 endif
@@ -1285,6 +1298,11 @@ endif
         @$(ECHO)  ZipName.............. $(ZIPNAME)
         @$(ECHO)  ZipName.............. $(ZIPNAME)
         @$(ECHO)
         @$(ECHO)
 
 
+[directorytargets]
+#####################################################################
+# Directories
+#####################################################################
+
 [localmakefile]
 [localmakefile]
 #####################################################################
 #####################################################################
 # Local Makefile
 # Local Makefile

+ 257 - 93
utils/fpcmake.pp

@@ -37,7 +37,7 @@ type
     sec_clean,sec_libs,sec_command,sec_exts,sec_dirs,sec_tools,sec_info
     sec_clean,sec_libs,sec_command,sec_exts,sec_dirs,sec_tools,sec_info
   );
   );
 
 
-  tbic=(bic_none,bic_build,bic_install,bic_clean);
+  tbic=(bic_none,bic_build,bic_install,bic_zipinstall,bic_clean);
 
 
   tspecialdir=record
   tspecialdir=record
     dir,unitdir,packdir : string;
     dir,unitdir,packdir : string;
@@ -69,7 +69,7 @@ const
     'all','debug',
     'all','debug',
     'examples','test',
     'examples','test',
     'smart','shared',
     'smart','shared',
-    'showinstall','install','sourceinstall','zipinstall','zipinstalladd',
+    'showinstall','install','sourceinstall','zipinstall','zipsourceinstall',
     'clean','cleanall',
     'clean','cleanall',
     'require','info'
     'require','info'
   );
   );
@@ -87,7 +87,7 @@ const
     bic_build,bic_build,
     bic_build,bic_build,
     bic_build,bic_build,
     bic_build,bic_build,
     bic_build,bic_build,
     bic_build,bic_build,
-    bic_install,bic_install,bic_install,bic_install,bic_install,
+    bic_install,bic_install,bic_install,bic_zipinstall,bic_zipinstall,
     bic_clean,bic_clean,
     bic_clean,bic_clean,
     bic_none,bic_none
     bic_none,bic_none
   );
   );
@@ -130,11 +130,14 @@ type
     TargetUnits,
     TargetUnits,
     TargetPrograms,
     TargetPrograms,
     TargetExamples,
     TargetExamples,
+    TargetPkgs,
     TargetRST      : TTargetsString;
     TargetRST      : TTargetsString;
     InstallPackageName,
     InstallPackageName,
     InstallUnitSubDir,
     InstallUnitSubDir,
     InstallPrefixDir,
     InstallPrefixDir,
     InstallDataDir,
     InstallDataDir,
+    InstallSourceSubDir,
+    InstallSourceTopDir,
     InstallBaseDir : string;
     InstallBaseDir : string;
     InstallUnits,
     InstallUnits,
     InstallFiles   : TTargetsString;
     InstallFiles   : TTargetsString;
@@ -145,6 +148,7 @@ type
     DefaultRule,
     DefaultRule,
     DefaultBuildDir,
     DefaultBuildDir,
     DefaultInstallDir,
     DefaultInstallDir,
+    DefaultZipInstallDir,
     DefaultCleanDir,
     DefaultCleanDir,
     DefaultDir,
     DefaultDir,
     DefaultTarget,
     DefaultTarget,
@@ -159,7 +163,7 @@ type
     DirTarget,
     DirTarget,
     DirUnitTarget,
     DirUnitTarget,
     DirSources,
     DirSources,
-    DirInc         : string;
+    DirInc          : string;
     RequireRTL      : boolean;
     RequireRTL      : boolean;
     RequireOptions  : string;
     RequireOptions  : string;
     RequireToolkits,
     RequireToolkits,
@@ -184,7 +188,8 @@ type
     ToolsCmp,
     ToolsCmp,
     ToolsUpx,
     ToolsUpx,
     ToolsDate,
     ToolsDate,
-    ToolsZip       : boolean;
+    ToolsZip,
+    ToolsTar       : boolean;
     MultiPacks,
     MultiPacks,
     PreSettings,
     PreSettings,
     PostSettings,
     PostSettings,
@@ -219,6 +224,27 @@ begin
 end;
 end;
 
 
 
 
+function posidx(const substr,s : string;idx:integer):integer;
+var
+  i,j : integer;
+  e   : boolean;
+begin
+  i := idx;
+  j := 0;
+  e:=(length(SubStr)>0);
+  while e and (i<=Length(s)-Length(SubStr)) do
+   begin
+     inc(i);
+     if (SubStr[1]=s[i]) and (Substr=Copy(s,i,Length(SubStr))) then
+      begin
+        j:=i;
+        e:=false;
+      end;
+   end;
+  PosIdx:=j;
+end;
+
+
 function TargetStringEmpty(const t:TTargetsString):boolean;
 function TargetStringEmpty(const t:TTargetsString):boolean;
 var
 var
   i : integer;
   i : integer;
@@ -235,25 +261,32 @@ end;
 
 
 procedure AddStrNoDup(var s:string;const s2:string);
 procedure AddStrNoDup(var s:string;const s2:string);
 var
 var
-  i : longint;
-  add : boolean;
+  i,idx : longint;
+  again,add : boolean;
 begin
 begin
   add:=false;
   add:=false;
-  i:=pos(s2,s);
-  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
-    add:=true;
+  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
   if add then
    begin
    begin
      if s='' then
      if s='' then
@@ -294,6 +327,7 @@ var
 
 
 var
 var
   sec : tsections;
   sec : tsections;
+  b   : boolean;
 begin
 begin
   ReadMakefilefpc:=false;
   ReadMakefilefpc:=false;
 
 
@@ -309,6 +343,9 @@ begin
      ReadTargetsString(TargetPrograms,ini_targets,'programs','');
      ReadTargetsString(TargetPrograms,ini_targets,'programs','');
      ReadTargetsString(TargetExamples,ini_targets,'examples','');
      ReadTargetsString(TargetExamples,ini_targets,'examples','');
      ReadTargetsString(TargetRST,ini_targets,'rst','');
      ReadTargetsString(TargetRST,ini_targets,'rst','');
+     ReadTargetsString(TargetPkgs,ini_targets,'pkgs','');
+     if not TargetStringEmpty(TargetPkgs) then
+      TargetPkgs[0]:='all '+TargetPkgs[0];
    { clean }
    { clean }
      ReadTargetsString(CleanUnits,ini_clean,'units','');
      ReadTargetsString(CleanUnits,ini_clean,'units','');
      ReadTargetsString(CleanFiles,ini_clean,'files','');
      ReadTargetsString(CleanFiles,ini_clean,'files','');
@@ -318,6 +355,8 @@ begin
      InstallBaseDir:=ReadString(ini_install,'basedir','');
      InstallBaseDir:=ReadString(ini_install,'basedir','');
      InstallDataDir:=ReadString(ini_install,'datadir','');
      InstallDataDir:=ReadString(ini_install,'datadir','');
      InstallUnitSubDir:=ReadString(ini_install,'unitsubdir','');
      InstallUnitSubDir:=ReadString(ini_install,'unitsubdir','');
+     InstallSourceSubDir:=ReadString(ini_install,'sourcesubdir','');
+     InstallSourceTopDir:=ReadString(ini_install,'sourcetopdir','');
      ReadTargetsString(InstallUnits,ini_install,'units','');
      ReadTargetsString(InstallUnits,ini_install,'units','');
      ReadTargetsString(InstallFiles,ini_install,'files','');
      ReadTargetsString(InstallFiles,ini_install,'files','');
    { zip }
    { zip }
@@ -327,12 +366,14 @@ begin
      DefaultDir:=ReadString(ini_defaults,'defaultdir','');
      DefaultDir:=ReadString(ini_defaults,'defaultdir','');
      DefaultBuildDir:=ReadString(ini_defaults,'defaultbuilddir','');
      DefaultBuildDir:=ReadString(ini_defaults,'defaultbuilddir','');
      DefaultInstallDir:=ReadString(ini_defaults,'defaultinstalldir','');
      DefaultInstallDir:=ReadString(ini_defaults,'defaultinstalldir','');
+     DefaultZipInstallDir:=ReadString(ini_defaults,'defaultzipinstalldir','');
      DefaultCleanDir:=ReadString(ini_defaults,'defaultcleandir','');
      DefaultCleanDir:=ReadString(ini_defaults,'defaultcleandir','');
      DefaultRule:=ReadString(ini_defaults,'defaultrule','all');
      DefaultRule:=ReadString(ini_defaults,'defaultrule','all');
      DefaultTarget:=ReadString(ini_defaults,'defaulttarget','');
      DefaultTarget:=ReadString(ini_defaults,'defaulttarget','');
      DefaultCPU:=ReadString(ini_defaults,'defaultcpu','');
      DefaultCPU:=ReadString(ini_defaults,'defaultcpu','');
    { require }
    { require }
-     RequireRTL:=ReadBool(ini_require,'rtl',true);
+     b:=not(TargetStringEmpty(targetunits) and TargetStringEmpty(targetprograms) and TargetStringEmpty(targetexamples));
+     RequireRTL:=ReadBool(ini_require,'rtl',b);
      RequireOptions:=ReadString(ini_require,'options','');
      RequireOptions:=ReadString(ini_require,'options','');
      ReadTargetsString(requireToolkits,ini_require,'toolkit','');
      ReadTargetsString(requireToolkits,ini_require,'toolkit','');
      ReadTargetsString(requirePackages,ini_require,'packages','');
      ReadTargetsString(requirePackages,ini_require,'packages','');
@@ -344,6 +385,23 @@ begin
         else
         else
          userini.Requirepackages[0]:='rtl';
          userini.Requirepackages[0]:='rtl';
       end;
       end;
+   { sections, but allow overriding the 'none' option to include a few sects only }
+     for sec:=low(tsections) to high(tsections) do
+      Section[sec]:=sectiondef[sec];
+     Section[sec_None]:=ReadBool(ini_sections,sectionstr[sec_none],sectiondef[sec_none]);
+     if Section[sec_None] then
+      FillChar(Section,sizeof(Section),0);
+     for sec:=low(tsections) to high(tsections) do
+      Section[sec]:=ReadBool(ini_sections,sectionstr[sec],section[sec]);
+     { turn on needed sections }
+     if not TargetStringEmpty(TargetLoaders) then
+      section[sec_loaders]:=true;
+     if not TargetStringEmpty(TargetUnits) then
+      section[sec_units]:=true;
+     if not TargetStringEmpty(TargetPrograms) then
+      section[sec_exes]:=true;
+     if not TargetStringEmpty(TargetExamples) then
+      section[sec_examples]:=true;
    { dirs }
    { dirs }
      DirFpc:=ReadString(ini_dirs,'fpcdir','');
      DirFpc:=ReadString(ini_dirs,'fpcdir','');
      DirPackage:=ReadString(ini_dirs,'packagedir','$(FPCDIR)/packages');
      DirPackage:=ReadString(ini_dirs,'packagedir','$(FPCDIR)/packages');
@@ -362,33 +420,17 @@ begin
      LibGcc:=ReadBool(ini_libs,'libgcc',false);
      LibGcc:=ReadBool(ini_libs,'libgcc',false);
      LibOther:=ReadBool(ini_libs,'libother',false);
      LibOther:=ReadBool(ini_libs,'libother',false);
    { tools }
    { tools }
-     ToolsPPDep:=ReadBool(ini_tools,'toolppdep',true);
-     ToolsPPUMove:=ReadBool(ini_tools,'toolppumove',true);
-     ToolsPPUFiles:=ReadBool(ini_tools,'toolppufiles',true);
+     ToolsPPUMove:=ReadBool(ini_tools,'toolppumove',section[sec_compile]);
+     ToolsPPUFiles:=ReadBool(ini_tools,'toolppufiles',section[sec_install] or section[sec_clean]);
+     ToolsUpx:=ReadBool(ini_tools,'toolupx',section[sec_install]);
+     ToolsZip:=ReadBool(ini_tools,'toolzip',section[sec_zipinstall]);
+     ToolsTar:=ReadBool(ini_tools,'tooltar',section[sec_zipinstall]);
+     ToolsPPDep:=ReadBool(ini_tools,'toolppdep',false);
      ToolsSed:=ReadBool(ini_tools,'toolsed',false);
      ToolsSed:=ReadBool(ini_tools,'toolsed',false);
      ToolsData2Inc:=ReadBool(ini_tools,'tooldata2inc',false);
      ToolsData2Inc:=ReadBool(ini_tools,'tooldata2inc',false);
      ToolsDiff:=ReadBool(ini_tools,'tooldiff',false);
      ToolsDiff:=ReadBool(ini_tools,'tooldiff',false);
      ToolsCmp:=ReadBool(ini_tools,'toolcmp',false);
      ToolsCmp:=ReadBool(ini_tools,'toolcmp',false);
-     ToolsUpx:=ReadBool(ini_tools,'toolupx',true);
-     ToolsDate:=ReadBool(ini_tools,'tooldate',true);
-     ToolsZip:=ReadBool(ini_tools,'toolzip',true);
-   { sections, but allow overriding the 'none' option to include a few sects only }
-     for sec:=low(tsections) to high(tsections) do
-      Section[sec]:=sectiondef[sec];
-     Section[sec_None]:=ReadBool(ini_sections,sectionstr[sec_none],sectiondef[sec_none]);
-     if Section[sec_None] then
-      FillChar(Section,sizeof(Section),0);
-     for sec:=low(tsections) to high(tsections) do
-      Section[sec]:=ReadBool(ini_sections,sectionstr[sec],section[sec]);
-     { turn on needed sections }
-     if not TargetStringEmpty(TargetLoaders) then
-      section[sec_loaders]:=true;
-     if not TargetStringEmpty(TargetUnits) then
-      section[sec_units]:=true;
-     if not TargetStringEmpty(TargetPrograms) then
-      section[sec_exes]:=true;
-     if not TargetStringEmpty(TargetExamples) then
-      section[sec_examples]:=true;
+     ToolsDate:=ReadBool(ini_tools,'tooldate',false);
    { info }
    { info }
      InfoCfg:=ReadBool(ini_info,'infoconfig',true);
      InfoCfg:=ReadBool(ini_info,'infoconfig',true);
      InfoDirs:=ReadBool(ini_info,'infodirs',false);
      InfoDirs:=ReadBool(ini_info,'infodirs',false);
@@ -458,7 +500,7 @@ end;
 
 
 function VarName(const s:string):string;
 function VarName(const s:string):string;
 var
 var
-  i : longint;
+  i,j : longint;
 begin
 begin
   i:=0;
   i:=0;
   result:=s;
   result:=s;
@@ -466,6 +508,16 @@ begin
    begin
    begin
      inc(i);
      inc(i);
      case result[i] of
      case result[i] of
+       '{' :
+         begin
+           { this are pkgs which are hold the dirs between the accolades }
+           j:=PosIdx('}',result,i);
+           if j>0 then
+            Delete(result,i,j-i+1)
+           else
+            Delete(result,i,1);
+           dec(i);
+         end;
        '$','(',')' :
        '$','(',')' :
          begin
          begin
            Delete(result,i,1);
            Delete(result,i,1);
@@ -564,22 +616,33 @@ var
        inc(i);
        inc(i);
      end;
      end;
     hs:='';
     hs:='';
-    if userini.section[rule2sec[rule]] then
-     hs:=hs+' fpc_'+rulestr[rule];
-    if userini.DefaultDir<>'' then
-     hs:=hs+' $(addsuffix _'+rulestr[rule]+','+userini.defaultdir+')'
-    else
-     if (userini.DefaultBuildDir<>'') and (rule2bic[rule]=bic_build) then
-      hs:=hs+' $(addsuffix _'+rulestr[rule]+','+userini.defaultbuilddir+')'
-    else
-     if (userini.DefaultInstallDir<>'') and (rule2bic[rule]=bic_install) then
-      hs:=hs+' $(addsuffix _'+rulestr[rule]+','+userini.defaultinstalldir+')'
-    else
-     if (userini.DefaultCleanDir<>'') and (rule2bic[rule]=bic_clean) then
-      hs:=hs+' $(addsuffix _'+rulestr[rule]+','+userini.defaultcleandir+')'
+    { zipinstall is special, it allows packages }
+    if ((rulestr[rule]='zipinstall') or
+        (rulestr[rule]='zipsourceinstall')) and
+       (not TargetStringEmpty(userini.targetpkgs)) then
+     hs:=hs+' $(addsuffix _'+rulestr[rule]+',$(PKGOBJECTS))'
     else
     else
-     if rulediralso[rule] and (not TargetStringEmpty(userini.targetdirs)) then
-      hs:=hs+' $(addsuffix _'+rulestr[rule]+',$(DIROBJECTS))';
+     begin
+       if userini.section[rule2sec[rule]] then
+        hs:=hs+' fpc_'+rulestr[rule];
+       if userini.DefaultDir<>'' then
+        hs:=hs+' $(addsuffix _'+rulestr[rule]+','+userini.defaultdir+')'
+       else
+        if (userini.DefaultBuildDir<>'') and (rule2bic[rule]=bic_build) then
+         hs:=hs+' $(addsuffix _'+rulestr[rule]+','+userini.defaultbuilddir+')'
+       else
+        if (userini.DefaultInstallDir<>'') and (rule2bic[rule]=bic_install) then
+         hs:=hs+' $(addsuffix _'+rulestr[rule]+','+userini.defaultinstalldir+')'
+       else
+        if (userini.DefaultZipInstallDir<>'') and (rule2bic[rule]=bic_zipinstall) then
+         hs:=hs+' $(addsuffix _'+rulestr[rule]+','+userini.defaultzipinstalldir+')'
+       else
+        if (userini.DefaultCleanDir<>'') and (rule2bic[rule]=bic_clean) then
+         hs:=hs+' $(addsuffix _'+rulestr[rule]+','+userini.defaultcleandir+')'
+       else
+        if rulediralso[rule] and (not TargetStringEmpty(userini.targetdirs)) then
+         hs:=hs+' $(addsuffix _'+rulestr[rule]+',$(DIROBJECTS))';
+     end;
     if hs<>'' then
     if hs<>'' then
      begin
      begin
        Phony:=Phony+' '+rulestr[rule];
        Phony:=Phony+' '+rulestr[rule];
@@ -633,8 +696,8 @@ var
 
 
   function AddTargetDefines(const ts:TTargetsString;const prefix:string):string;
   function AddTargetDefines(const ts:TTargetsString;const prefix:string):string;
   var
   var
-    j,i : integer;
-    hs,hs2 : string;
+    k1,k2,j,i : integer;
+    name,hs,hs2,hs3 : string;
   begin
   begin
     hs2:='';
     hs2:='';
     for j:=0 to targets do
     for j:=0 to targets do
@@ -647,9 +710,27 @@ var
           i:=pos(' ',hs);
           i:=pos(' ',hs);
           if i=0 then
           if i=0 then
            i:=length(hs)+1;
            i:=length(hs)+1;
-          mf.Add(prefix+VarName(Copy(hs,1,i-1))+'=1');
+          name:=Copy(hs,1,i-1);
+          k1:=pos('{',name);
+          if k1>0 then
+           begin
+             k2:=PosIdx('}',name,k1);
+             if k2=0 then
+              begin
+                Writeln('Error: missing closing } for "',name,'"');
+                k2:=length(name)+1;
+              end;
+             hs3:=Copy(name,k1+1,k2-k1-1);
+             for j:=1to length(hs3) do
+              if hs3[j]=',' then
+               hs3[j]:=' ';
+             name:=Copy(name,1,k1-1);
+             mf.Add(prefix+VarName(name)+'='+hs3);
+           end
+          else
+           mf.Add(prefix+VarName(name)+'=1');
           { add to the list of dirs without duplicates }
           { add to the list of dirs without duplicates }
-          AddStrNoDup(hs2,Copy(hs,1,i-1));
+          AddStrNoDup(hs2,name);
           system.delete(hs,1,i);
           system.delete(hs,1,i);
         until hs='';
         until hs='';
         if j<>0 then
         if j<>0 then
@@ -740,6 +821,75 @@ var
       end;
       end;
   end;
   end;
 
 
+  procedure AddPkg(const pack:string);
+  var
+    j  : integer;
+    packname,pkgdirsvar,hs : string;
+  begin
+    packname:=pack;
+    AddHead('Pkg '+packname);
+    mf.Add('ifdef PKG'+VarName(packname));
+    hs:='.PHONY: ';
+    for j:=1 to rules do
+     hs:=hs+' pkg'+packname+'_'+rulestr[j];
+    mf.Add(hs);
+    mf.Add('');
+    { pkgall is special which processes all directories }
+    if pack='all' then
+     pkgdirsvar:='DIROBJECTS'
+    else
+     begin
+       mf.Add('override PKGOBJECTS+=pkg'+packname);
+       pkgdirsvar:='PKG'+VarName(packname);
+     end;
+    for j:=1to rules do
+     if rulediralso[j] then
+      begin
+        mf.Add('pkg'+packname+'_'+rulestr[j]+': $(addsuffix _'+rulestr[j]+',$('+pkgdirsvar+'))');
+        if j<rules then
+         mf.Add('');
+      end
+     else
+      begin
+        { zipinstall is special for pkgs }
+        if (rulestr[j]='zipinstall') or (rulestr[j]='zipsourceinstall') then
+         begin
+           mf.Add('pkg'+packname+'_'+rulestr[j]+':');
+           mf.Add(#9'$(MAKE) fpc_'+rulestr[j]+' PACKAGENAME='+packname+' ZIPTARGET=pkg'+packname+'_'+Copy(rulestr[j],4,length(rulestr[j])-3));
+           if j<rules then
+            mf.Add('');
+         end;
+      end;
+    mf.Add('endif');
+  end;
+
+  procedure AddTargetsPkgs(const ts:TTargetsString);
+  var
+    Phony,hs : string;
+    i  : integer;
+  begin
+   { Components }
+     Phony:='';
+     if not TargetStringEmpty(ts) then
+      begin
+        hs:=AddTargetDefines(ts,'PKG');
+        mf.Add('');
+        repeat
+          i:=pos(' ',hs);
+          if i=0 then
+           i:=length(hs)+1;
+          AddPkg(Copy(hs,1,i-1));
+          system.delete(hs,1,i);
+        until hs='';
+        mf.Add('');
+      end;
+     if Phony<>'' then
+      begin
+        mf.Add('.PHONY: '+Phony);
+        mf.Add('');
+      end;
+  end;
+
 var
 var
   hs  : string;
   hs  : string;
   i : integer;
   i : integer;
@@ -797,16 +947,20 @@ begin
      AddSection(true,'fpcdirdetect');
      AddSection(true,'fpcdirdetect');
 
 
    { fpcdir subdirs }
    { fpcdir subdirs }
-     Add('ifndef PACKAGESDIR');
-     Add('PACKAGESDIR='+userini.dirpackage);
-     Add('endif');
-     Add('ifndef TOOLKITSDIR');
-     Add('TOOLKITSDIR='+userini.dirtoolkit);
-     Add('endif');
-     Add('ifndef COMPONENTSDIR');
-     Add('COMPONENTSDIR='+userini.dircomponent);
-     Add('endif');
-     AddSection(userini.requirertl,'fpcdirsubs');
+     if userini.RequireRTL then
+      begin
+        Add('ifndef PACKAGESDIR');
+        Add('PACKAGESDIR='+userini.dirpackage);
+        Add('endif');
+        Add('ifndef TOOLKITSDIR');
+        Add('TOOLKITSDIR='+userini.dirtoolkit);
+        Add('endif');
+        Add('ifndef COMPONENTSDIR');
+        Add('COMPONENTSDIR='+userini.dircomponent);
+        Add('endif');
+        Add('');
+        AddSection(true,'fpcdirsubs');
+      end;
 
 
    { write the default & user settings }
    { write the default & user settings }
      AddSection(true,'usersettings');
      AddSection(true,'usersettings');
@@ -837,6 +991,10 @@ begin
       Add('DATAINSTALLDIR='+userini.installdatadir);
       Add('DATAINSTALLDIR='+userini.installdatadir);
      if userini.InstallUnitSubDir<>'' then
      if userini.InstallUnitSubDir<>'' then
       Add('UNITSUBDIR='+userini.InstallUnitSubDir);
       Add('UNITSUBDIR='+userini.InstallUnitSubDir);
+     if userini.InstallSourceSubDir<>'' then
+      Add('SOURCESUBDIR='+userini.InstallSourceSubDir);
+     if userini.InstallSourceTopDir<>'' then
+      Add('SOURCETOPDIR='+userini.InstallSourceTopDir);
      if userini.installpackagename<>'' then
      if userini.installpackagename<>'' then
       Add('PACKAGENAME='+userini.installpackagename);
       Add('PACKAGENAME='+userini.installpackagename);
 
 
@@ -930,20 +1088,18 @@ begin
      AddSection(userini.section[sec_command] or userini.section[sec_tools],'shelltools');
      AddSection(userini.section[sec_command] or userini.section[sec_tools],'shelltools');
 
 
    { write tools }
    { write tools }
-     if userini.section[sec_tools] then
-      begin
-        AddSection(true,'tool_default');
-        AddSection(userini.toolsppdep,'tool_ppdep');
-        AddSection(userini.toolsppumove,'tool_ppumove');
-        AddSection(userini.toolsppufiles,'tool_ppufiles');
-        AddSection(userini.toolsdata2inc,'tool_data2inc');
-        AddSection(userini.toolsupx,'tool_upx');
-        AddSection(userini.toolssed,'tool_sed');
-        AddSection(userini.toolsdate,'tool_date');
-        AddSection(userini.toolszip,'tool_zip');
-        AddSection(userini.toolscmp,'tool_cmp');
-        AddSection(userini.toolsdiff,'tool_diff');
-      end;
+     AddSection(userini.section[sec_tools],'tool_default');
+     AddSection(userini.toolsppdep,'tool_ppdep');
+     AddSection(userini.toolsppumove,'tool_ppumove');
+     AddSection(userini.toolsppufiles,'tool_ppufiles');
+     AddSection(userini.toolsdata2inc,'tool_data2inc');
+     AddSection(userini.toolsupx,'tool_upx');
+     AddSection(userini.toolssed,'tool_sed');
+     AddSection(userini.toolscmp,'tool_cmp');
+     AddSection(userini.toolsdiff,'tool_diff');
+     AddSection(userini.toolsdate,'tool_date');
+     AddSection(userini.toolszip,'tool_zip');
+     AddSection(userini.toolstar,'tool_tar');
 
 
    { extensions }
    { extensions }
      if userini.section[sec_exts] then
      if userini.section[sec_exts] then
@@ -957,10 +1113,13 @@ begin
      AddTargetsPackages('$(COMPONENTSDIR)',userini.Requirecomponents);
      AddTargetsPackages('$(COMPONENTSDIR)',userini.Requirecomponents);
      Add('');
      Add('');
 
 
+   { Pkgs }
+     AddTargetsPkgs(userini.targetpkgs);
+
    { write dirs }
    { write dirs }
+     AddSection(true,'dir_default');
      if userini.section[sec_dirs] then
      if userini.section[sec_dirs] then
       begin
       begin
-        AddSection(true,'dir_default');
         AddSection(userini.libgcc,'dir_gcclib');
         AddSection(userini.libgcc,'dir_gcclib');
         AddSection(userini.libother,'dir_otherlib');
         AddSection(userini.libother,'dir_otherlib');
         AddSection(true,'dir_install');
         AddSection(true,'dir_install');
@@ -1031,7 +1190,7 @@ begin
    { Target dirs }
    { Target dirs }
      if not TargetStringEmpty(userini.targetdirs) then
      if not TargetStringEmpty(userini.targetdirs) then
       begin
       begin
-        AddHead('Target Dirs');
+        AddSection(true,'directorytargets');
         hs:=AddTargetDefines(userini.targetdirs,'OBJECTDIR');
         hs:=AddTargetDefines(userini.targetdirs,'OBJECTDIR');
         repeat
         repeat
           i:=pos(' ',hs);
           i:=pos(' ',hs);
@@ -1114,7 +1273,12 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.24  2000-01-13 11:34:26  peter
+  Revision 1.25  2000-01-13 21:08:46  peter
+    * zipsourcesinstall
+    * zip fixes, bzip2 support with USETAR=bz2
+    * multi pkg's support to include several dirs
+
+  Revision 1.24  2000/01/13 11:34:26  peter
     * better package dep creation
     * better package dep creation
 
 
   Revision 1.23  2000/01/12 23:20:37  peter
   Revision 1.23  2000/01/12 23:20:37  peter

Some files were not shown because too many files changed in this diff