Browse Source

* lot of updates

peter 26 years ago
parent
commit
bdd4bf7169
3 changed files with 354 additions and 157 deletions
  1. 102 77
      utils/fpcmake.ini
  2. 176 61
      utils/fpcmake.pp
  3. 76 19
      utils/makefile.exm

+ 102 - 77
utils/fpcmake.ini

@@ -4,6 +4,11 @@
 ; Templates used by fpcmake to create a Makefile from Makefile.fpc
 ; Templates used by fpcmake to create a Makefile from Makefile.fpc
 ;
 ;
 
 
+[makefilerule]
+Makefile: Makefile.fpc
+        fpcmake
+        $(MAKE)
+
 [osdetect]
 [osdetect]
 #####################################################################
 #####################################################################
 # Autodetect OS (Linux or Dos or Windows NT)
 # Autodetect OS (Linux or Dos or Windows NT)
@@ -15,9 +20,9 @@
 override PATH:=$(subst \,/,$(PATH))
 override PATH:=$(subst \,/,$(PATH))
 
 
 # Search for PWD and determine also if we are under linux
 # Search for PWD and determine also if we are under linux
-PWD=$(strip $(wildcard $(addsuffix /pwd.exe,$(subst ;, ,$(PATH)))))
+PWD:=$(strip $(wildcard $(addsuffix /pwd.exe,$(subst ;, ,$(PATH)))))
 ifeq ($(PWD),)
 ifeq ($(PWD),)
-PWD=$(strip $(wildcard $(addsuffix /pwd,$(subst :, ,$(PATH)))))
+PWD:=$(strip $(wildcard $(addsuffix /pwd,$(subst :, ,$(PATH)))))
 ifeq ($(PWD),)
 ifeq ($(PWD),)
 nopwd:
 nopwd:
         @echo You need the GNU utils package to use this Makefile!
         @echo You need the GNU utils package to use this Makefile!
@@ -60,6 +65,10 @@ else
 SEARCHPATH=$(subst ;, ,$(PATH))
 SEARCHPATH=$(subst ;, ,$(PATH))
 endif
 endif
 
 
+[defaulttarget]
+#####################################################################
+# Default target
+#####################################################################
 
 
 [fpcdetect]
 [fpcdetect]
 #####################################################################
 #####################################################################
@@ -77,22 +86,27 @@ endif
 
 
 # Target OS
 # Target OS
 ifndef OS_TARGET
 ifndef OS_TARGET
-export OS_TARGET=$(shell $(FPC) -iTO)
+export OS_TARGET:=$(shell $(FPC) -iTO)
 endif
 endif
 
 
 # Source OS
 # Source OS
 ifndef OS_SOURCE
 ifndef OS_SOURCE
-export OS_SOURCE=$(shell $(FPC) -iSO)
+export OS_SOURCE:=$(shell $(FPC) -iSO)
+endif
+
+# Target CPU
+ifndef CPU_TARGET
+export CPU_TARGET:=$(shell $(FPC) -iTP)
 endif
 endif
 
 
-# FPC_CPU
-ifndef FPC_CPU
-export FPC_CPU=$(shell $(FPC) -iTP)
+# Source CPU
+ifndef CPU_SOURCE
+export CPU_SOURCE:=$(shell $(FPC) -iSP)
 endif
 endif
 
 
 # FPC version
 # FPC version
 ifndef FPC_VERSION
 ifndef FPC_VERSION
-export FPC_VERSION=$(shell $(FPC) -iV)
+export FPC_VERSION:=$(shell $(FPC) -iV)
 endif
 endif
 
 
 
 
@@ -136,10 +150,13 @@ ifdef NEEDOPT
 override FPCOPT+=$(NEEDOPT)
 override FPCOPT+=$(NEEDOPT)
 endif
 endif
 
 
-[command_rtl]
-# RTL first and then Unit dir (a unit can override RTLunit)
-ifdef RTLDIR
-override FPCOPT+=$(addprefix -Fu,$(RTLDIR))
+[command_fpcdir]
+# RTL first and then Unit dir (a unit can override RTLunit). Don't add the
+# dirs if fpcdir=. which can be used for the rtl makefiles
+ifdef FPCDIR
+ifneq ($(FPCDIR),.)
+override FPCOPT+=-Fu$(FPCDIR)/rtl/$(OS_TARGET) -Fu$(FPCDIR)/units/$(OS_TARGET)
+endif
 endif
 endif
 
 
 [command_needunit]
 [command_needunit]
@@ -157,6 +174,11 @@ ifdef NEEDOBJDIR
 override FPCOPT+=$(addprefix -Fo,$(NEEDOBJDIR))
 override FPCOPT+=$(addprefix -Fo,$(NEEDOBJDIR))
 endif
 endif
 
 
+[command_needinc]
+ifdef NEEDINCDIR
+override FPCOPT+=$(addprefix -Fi,$(NEEDINCDIR))
+endif
+
 [command_gcclib]
 [command_gcclib]
 # Add GCC lib path if asked
 # Add GCC lib path if asked
 ifdef GCCLIBDIR
 ifdef GCCLIBDIR
@@ -169,22 +191,6 @@ ifdef OTHERLIBDIR
 override FPCOPT+=$(addprefix -Fl,$(OTHERLIBDIR))
 override FPCOPT+=$(addprefix -Fl,$(OTHERLIBDIR))
 endif
 endif
 
 
-[command_inc]
-# Add include dirs INC and PROCINC and OSINC
-ifdef INC
-override FPCOPT+=$(addprefix -Fi,$(INC))
-endif
-
-[command_procinc]
-ifdef PROCINC
-override FPCOPT+=$(addprefix -Fi,$(PROCINC))
-endif
-
-[command_osinc]
-ifdef OSINC
-override FPCOPT+=$(addprefix -Fi,$(OSINC))
-endif
-
 [command_target]
 [command_target]
 # Target dirs
 # Target dirs
 ifdef TARGETDIR
 ifdef TARGETDIR
@@ -205,7 +211,7 @@ endif
 [command_end]
 [command_end]
 # Add commandline options
 # Add commandline options
 ifdef OPT
 ifdef OPT
-override FPCOPT+=OPT
+override FPCOPT+=$(OPT)
 endif
 endif
 ifdef UNITDIR
 ifdef UNITDIR
 override FPCOPT+=$(addprefix -Fu,$(UNITDIR))
 override FPCOPT+=$(addprefix -Fu,$(UNITDIR))
@@ -216,6 +222,9 @@ endif
 ifdef OBJDIR
 ifdef OBJDIR
 override FPCOPT+=$(addprefix -Fo,$(OBJDIR))
 override FPCOPT+=$(addprefix -Fo,$(OBJDIR))
 endif
 endif
+ifdef INCDIR
+override FPCOPT+=$(addprefix -Fi,$(INCDIR))
+endif
 
 
 # Add defines from FPCOPTDEF to FPCOPT
 # Add defines from FPCOPTDEF to FPCOPT
 ifdef FPCOPTDEF
 ifdef FPCOPTDEF
@@ -237,52 +246,48 @@ override COMPILER=$(FPC) $(FPCOPT)
 
 
 # To copy pograms
 # To copy pograms
 ifndef COPY
 ifndef COPY
-export COPY=cp -fp
+export COPY:=cp -fp
 endif
 endif
 
 
 # To move pograms
 # To move pograms
 ifndef MOVE
 ifndef MOVE
-export MOVE=mv -f
+export MOVE:=mv -f
 endif
 endif
 
 
 # Check delete program
 # Check delete program
 ifndef DEL
 ifndef DEL
-export DEL=rm -f
+export DEL:=rm -f
 endif
 endif
 
 
 # Check deltree program
 # Check deltree program
 ifndef DELTREE
 ifndef DELTREE
-export DELTREE=rm -rf
+export DELTREE:=rm -rf
 endif
 endif
 
 
 # To install files
 # To install files
 ifndef INSTALL
 ifndef INSTALL
 ifdef inlinux
 ifdef inlinux
-export INSTALL=install -m 644
+export INSTALL:=install -m 644
 else
 else
-export INSTALL=$(COPY)
-# ginstall has the strange thing to stubify all .o files !
-#INSTALL=ginstall -m 644
+export INSTALL:=$(COPY)
 endif
 endif
 endif
 endif
 
 
 # To install programs
 # To install programs
 ifndef INSTALLEXE
 ifndef INSTALLEXE
 ifdef inlinux
 ifdef inlinux
-export INSTALLEXE=install -m 755
+export INSTALLEXE:=install -m 755
 else
 else
-export INSTALLEXE=$(COPY)
-# ginstall has the strange thing to stubify all .o files !
-#INSTALLEXE=ginstall -m 755
+export INSTALLEXE:=$(COPY)
 endif
 endif
 endif
 endif
 
 
 # To make a directory.
 # To make a directory.
 ifndef MKDIR
 ifndef MKDIR
 ifdef inlinux
 ifdef inlinux
-export MKDIR=install -m 755 -d
+export MKDIR:=install -m 755 -d
 else
 else
-export MKDIR=ginstall -m 755 -d
+export MKDIR:=ginstall -m 755 -d
 endif
 endif
 endif
 endif
 
 
@@ -307,6 +312,11 @@ ifndef PPUMOVE
 PPUMOVE=ppumove
 PPUMOVE=ppumove
 endif
 endif
 
 
+# Where is the ppdep program ?
+ifndef PPDEP
+PPDEP=ppdep
+endif
+
 # ppas.bat / ppas.sh
 # ppas.bat / ppas.sh
 ifdef inlinux
 ifdef inlinux
 PPAS=ppas.sh
 PPAS=ppas.sh
@@ -334,7 +344,7 @@ endif
 
 
 # echo
 # echo
 ifndef ECHO
 ifndef ECHO
-ECHO=$(strip $(wildcard $(addsuffix /echo$(EXEEXT),$(SEARCHPATH))))
+ECHO:=$(strip $(wildcard $(addsuffix /echo$(EXEEXT),$(SEARCHPATH))))
 ifeq ($(ECHO),)
 ifeq ($(ECHO),)
 export ECHO:=echo
 export ECHO:=echo
 else
 else
@@ -346,7 +356,7 @@ endif
 [tool_diff]
 [tool_diff]
 # diff
 # diff
 ifndef DIFF
 ifndef DIFF
-DIFF=$(strip $(wildcard $(addsuffix /diff$(EXEEXT),$(SEARCHPATH))))
+DIFF:=$(strip $(wildcard $(addsuffix /diff$(EXEEXT),$(SEARCHPATH))))
 ifeq ($(DIFF),)
 ifeq ($(DIFF),)
 DIFF=
 DIFF=
 else
 else
@@ -357,7 +367,7 @@ endif
 [tool_cmp]
 [tool_cmp]
 # cmp
 # cmp
 ifndef CMP
 ifndef CMP
-CMP=$(strip $(wildcard $(addsuffix /cmp$(EXEEXT),$(SEARCHPATH))))
+CMP:=$(strip $(wildcard $(addsuffix /cmp$(EXEEXT),$(SEARCHPATH))))
 ifeq ($(CMP),)
 ifeq ($(CMP),)
 CMP=
 CMP=
 else
 else
@@ -368,7 +378,7 @@ endif
 [tool_sed]
 [tool_sed]
 # Sed
 # Sed
 ifndef SED
 ifndef SED
-SED=$(strip $(wildcard $(addsuffix /sed$(EXEEXT),$(SEARCHPATH))))
+SED:=$(strip $(wildcard $(addsuffix /sed$(EXEEXT),$(SEARCHPATH))))
 ifeq ($(SED),)
 ifeq ($(SED),)
 SED=
 SED=
 else
 else
@@ -381,13 +391,13 @@ endif
 # upx uses that one itself (PFV)
 # upx uses that one itself (PFV)
 ifndef UPXPROG
 ifndef UPXPROG
 ifeq ($(OS_TARGET),go32v2)
 ifeq ($(OS_TARGET),go32v2)
-UPXPROG=1
+UPXPROG:=1
 endif
 endif
 ifeq ($(OS_TARGET),win32)
 ifeq ($(OS_TARGET),win32)
-UPXPROG=1
+UPXPROG:=1
 endif
 endif
 ifdef UPXPROG
 ifdef UPXPROG
-UPXPROG=$(strip $(wildcard $(addsuffix /upx$(EXEEXT),$(SEARCHPATH))))
+UPXPROG:=$(strip $(wildcard $(addsuffix /upx$(EXEEXT),$(SEARCHPATH))))
 ifeq ($(UPX),)
 ifeq ($(UPX),)
 UPXPROG=
 UPXPROG=
 else
 else
@@ -401,9 +411,9 @@ endif
 [tool_date]
 [tool_date]
 # gdate/date
 # gdate/date
 ifndef DATE
 ifndef DATE
-DATE=$(strip $(wildcard $(addsuffix /date$(EXEEXT),$(SEARCHPATH))))
+DATE:=$(strip $(wildcard $(addsuffix /date$(EXEEXT),$(SEARCHPATH))))
 ifeq ($(DATE),)
 ifeq ($(DATE),)
-DATE=$(strip $(wildcard $(addsuffix /gdate$(EXEEXT),$(SEACHPATH))))
+DATE:=$(strip $(wildcard $(addsuffix /gdate$(EXEEXT),$(SEACHPATH))))
 ifeq ($(DATE),)
 ifeq ($(DATE),)
 DATE=
 DATE=
 else
 else
@@ -415,7 +425,7 @@ endif
 endif
 endif
 
 
 ifdef DATE
 ifdef DATE
-DATESTR=$(shell $(DATE) +%Y%m%d)
+DATESTR:=$(shell $(DATE) +%Y%m%d)
 else
 else
 DATESTR=
 DATESTR=
 endif
 endif
@@ -423,7 +433,7 @@ endif
 [tool_zip]
 [tool_zip]
 # ZipProg, you can't use Zip as the var name (PFV)
 # ZipProg, you can't use Zip as the var name (PFV)
 ifndef ZIPPROG
 ifndef ZIPPROG
-ZIPPROG=$(strip $(wildcard $(addsuffix /zip$(EXEEXT),$(SEARCHPATH))))
+ZIPPROG:=$(strip $(wildcard $(addsuffix /zip$(EXEEXT),$(SEARCHPATH))))
 ifeq ($(ZIPPROG),)
 ifeq ($(ZIPPROG),)
 ZIPPROG=
 ZIPPROG=
 else
 else
@@ -680,8 +690,9 @@ endif
 # Default rules
 # Default rules
 #####################################################################
 #####################################################################
 
 
-.PHONY: all staticlib sharedlib install staticinstall sharedinstall \
-        libinstall zipinstall zipinstalladd clean depend info
+.PHONY: defaultrule all staticlib sharedlib showinstall install \
+        staticinstall sharedinstall libinstall zipinstall zipinstalladd \
+        clean cleanall depend info
 
 
 
 
 [compilerules]
 [compilerules]
@@ -769,6 +780,13 @@ endif
 
 
 .PHONY: fpc_showinstallfiles fpc_install
 .PHONY: fpc_showinstallfiles fpc_install
 
 
+ifdef EXTRAINSTALLUNITS
+override EXTRAINSTALLFILES=$(wildcard $(addsuffix $(OEXT),$(EXTRAINSTALLUNITS)) $(addsuffix $(STATICLIBEXT),$(EXTRAINSTALLUNITS)) $(addsuffix $(PPUEXT),$(EXTRAINSTALLUNITS)))
+endif
+ifdef UNITOBJECTS
+override UNITINSTALLFILES=$(wildcard $(UNITPPUFILES) $(UNITOFILES) $(UNITAFILES))
+endif
+
 fpc_showinstallfiles : all
 fpc_showinstallfiles : all
 ifndef DEFAULTUNITS
 ifndef DEFAULTUNITS
 ifdef EXEOBJECTS
 ifdef EXEOBJECTS
@@ -778,18 +796,15 @@ endif
 ifdef LOADEROBJECTS
 ifdef LOADEROBJECTS
         @$(ECHO) $(addprefix "\n"$(UNITINSTALLDIR)/,$(LOADEROFILES))
         @$(ECHO) $(addprefix "\n"$(UNITINSTALLDIR)/,$(LOADEROFILES))
 endif
 endif
-ifdef UNITOBJECTS
-        @$(ECHO) $(addprefix "\n"$(UNITINSTALLDIR)/,$(wildcard $(UNITPPUFILES) $(UNITOFILES) $(UNITAFILES)))
+ifdef UNITINSTALLFILES
+        @$(ECHO) $(addprefix "\n"$(UNITINSTALLDIR)/,$(UNITINSTALLFILES))
 endif
 endif
-ifdef EXTRAINSTALLUNITS
-        @$(ECHO) $(addprefix "\n"$(UNITINSTALLDIR)/,$(wildcard $(addsuffix $(OEXT),$(EXTRAINSTALLUNITS)) $(addsuffix $(STATICLIBEXT),$(EXTRAINSTALLUNITS)) $(addsuffix $(PPUEXT),$(EXTRAINSTALLUNITS))))
+ifdef EXTRAINSTALLFILES
+        @$(ECHO) $(addprefix "\n"$(UNITINSTALLDIR)/,$(EXTRAINSTALLFILES))
 endif
 endif
 
 
 fpc_install:
 fpc_install:
 # Create UnitInstallFiles
 # Create UnitInstallFiles
-ifdef EXTRAINSTALLUNITS
-override EXTRAINSTALLFILES=$(wildcard $(addsuffix $(OEXT),$(EXTRAINSTALLUNITS)) $(addsuffix $(STATICLIBEXT),$(EXTRAINSTALLUNITS)) $(addsuffix $(PPUEXT),$(EXTRAINSTALLUNITS)))
-endif
 ifndef DEFAULTUNITS
 ifndef DEFAULTUNITS
 ifdef EXEOBJECTS
 ifdef EXEOBJECTS
         $(MKDIR) $(BININSTALLDIR)
         $(MKDIR) $(BININSTALLDIR)
@@ -804,13 +819,13 @@ ifdef LOADEROBJECTS
         $(MKDIR) $(UNITINSTALLDIR)
         $(MKDIR) $(UNITINSTALLDIR)
         $(INSTALL) $(LOADEROFILES) $(UNITINSTALLDIR)
         $(INSTALL) $(LOADEROFILES) $(UNITINSTALLDIR)
 endif
 endif
-ifdef UNITOBJECTS
+ifdef UNITINSTALLFILES
         $(MKDIR) $(UNITINSTALLDIR)
         $(MKDIR) $(UNITINSTALLDIR)
-        $(INSTALL) $(wildcard $(UNITPPUFILES) $(UNITOFILES) $(UNITAFILES)) $(UNITINSTALLDIR)
+        $(INSTALL) $(UNITINSTALLFILES) $(UNITINSTALLDIR)
 endif
 endif
-ifneq ($(wildcard $(addsuffix $(OEXT),$(EXTRAINSTALLUNITS)) $(addsuffix $(STATICLIBEXT),$(EXTRAINSTALLUNITS)) $(addsuffix $(PPUEXT),$(EXTRAINSTALLUNITS))),)
+ifdef EXTRAINSTALLFILES
         $(MKDIR) $(UNITINSTALLDIR)
         $(MKDIR) $(UNITINSTALLDIR)
-        $(INSTALL) $(wildcard $(addsuffix $(OEXT),$(EXTRAINSTALLUNITS)) $(addsuffix $(STATICLIBEXT),$(EXTRAINSTALLUNITS)) $(addsuffix $(PPUEXT),$(EXTRAINSTALLUNITS))) $(UNITINSTALLDIR)
+        $(INSTALL) $(EXTRAINSTALLFILES) $(UNITINSTALLDIR)
 endif
 endif
 
 
 
 
@@ -917,6 +932,13 @@ endif
 
 
 .PHONY: fpc_clean fpc_libsclean fpc_cleanall
 .PHONY: fpc_clean fpc_libsclean fpc_cleanall
 
 
+ifdef UNITOBJECTS
+override UNITCLEANFILES=$(wildcard $(UNITPPUFILES) $(UNITOFILES) $(UNITAFILES))
+endif
+ifdef EXTRACLEANUNITS
+override EXTRACLEANFILES=$(wildcard $(addsuffix $(OEXT),$(EXTRACLEANUNITS)) $(addsuffix $(STATICLIBEXT),$(EXTRACLEANUNITS)) $(addsuffix $(PPUEXT),$(EXTRACLEANUNITS)))
+endif
+
 fpc_clean:
 fpc_clean:
 ifdef EXEOBJECTS
 ifdef EXEOBJECTS
         -$(DEL) $(EXEFILES) $(EXEOFILES)
         -$(DEL) $(EXEFILES) $(EXEOFILES)
@@ -924,11 +946,11 @@ endif
 ifdef LOADEROBJECTS
 ifdef LOADEROBJECTS
         -$(DEL) $(LOADEROFILES)
         -$(DEL) $(LOADEROFILES)
 endif
 endif
-ifdef UNITOBJECTS
-        -$(DEL) $(wildcard $(UNITPPUFILES) $(UNITOFILES) $(UNITAFILES))
+ifdef UNITCLEANFILES
+        -$(DEL) $(UNITCLEANFILES)
 endif
 endif
-ifneq ($(wildcard $(addsuffix $(OEXT),$(EXTRACLEANUNITS)) $(addsuffix $(STATICLIBEXT),$(EXTRACLEANUNITS)) $(addsuffix $(PPUEXT),$(EXTRACLEANUNITS))) ,)
-        -$(DEL) $(wildcard $(addsuffix $(OEXT),$(EXTRACLEANUNITS)) $(addsuffix $(STATICLIBEXT),$(EXTRACLEANUNITS)) $(addsuffix $(PPUEXT),$(EXTRACLEANUNITS)))
+ifdef EXTRACLEANFILES
+        -$(DEL) $(EXTRACLEANFILES)
 endif
 endif
         -$(DEL) $(PPAS) link.res log
         -$(DEL) $(PPAS) link.res log
 
 
@@ -951,7 +973,7 @@ endif
 .PHONY: fpc_depend
 .PHONY: fpc_depend
 
 
 fpc_depend:
 fpc_depend:
-        makedep $(UNITOBJECTS)
+        $(PPDEP) $(UNITOBJECTS)
 
 
 
 
 [inforules]
 [inforules]
@@ -971,13 +993,13 @@ fpc_infocfg:
         @$(ECHO)
         @$(ECHO)
         @$(ECHO)  FPC....... $(FPC)
         @$(ECHO)  FPC....... $(FPC)
         @$(ECHO)  Version... $(FPC_VERSION)
         @$(ECHO)  Version... $(FPC_VERSION)
-        @$(ECHO)  CPU....... $(FPC_CPU)
+        @$(ECHO)  CPU....... $(CPU_TARGET)
         @$(ECHO)  Source.... $(OS_SOURCE)
         @$(ECHO)  Source.... $(OS_SOURCE)
         @$(ECHO)  Target.... $(OS_TARGET)
         @$(ECHO)  Target.... $(OS_TARGET)
         @$(ECHO)
         @$(ECHO)
 
 
-[info_dir]
-fpc_infodir:
+[info_dirs]
+fpc_infodirs:
 ifdef inlinux
 ifdef inlinux
         @$(ECHO)
         @$(ECHO)
         @$(ECHO)  == Directory info ==
         @$(ECHO)  == Directory info ==
@@ -1023,7 +1045,7 @@ endif
         @$(ECHO)
         @$(ECHO)
 
 
 [info_object]
 [info_object]
-fpc_infoobject:
+fpc_infoobjects:
         @$(ECHO)
         @$(ECHO)
         @$(ECHO)  == Object info ==
         @$(ECHO)  == Object info ==
         @$(ECHO)
         @$(ECHO)
@@ -1097,7 +1119,10 @@ endif
 
 
 ;
 ;
 ; $Log$
 ; $Log$
-; Revision 1.1  1999-11-02 23:57:40  peter
+; Revision 1.2  1999-11-03 23:39:53  peter
+;   * lot of updates
+;
+; Revision 1.1  1999/11/02 23:57:40  peter
 ;   * initial version
 ;   * initial version
 ;
 ;
 ;
 ;

+ 176 - 61
utils/fpcmake.pp

@@ -19,25 +19,39 @@ uses
 {$ifdef go32v2}
 {$ifdef go32v2}
   dpmiexcp,
   dpmiexcp,
 {$endif}
 {$endif}
+  dos,
   sysutils,classes,inifiles;
   sysutils,classes,inifiles;
 
 
 const
 const
   Version='v0.99.13';
   Version='v0.99.13';
   Title='fpcmake '+Version;
   Title='fpcmake '+Version;
 
 
-const
+  EnvVar='FPCMAKEINI'; { should be FPCMAKE in the future }
+  TimeFormat='yyyy/mm/dd hh:nn';
+
+  targets=4;
+  targetstr : array[1..targets] of string=(
+    'linux','go32v2','win32','os2'
+  );
+
+{ Sections in Makefile.fpc }
   sec_dirs='dirs';
   sec_dirs='dirs';
   sec_libs='libs';
   sec_libs='libs';
   sec_targets='targets';
   sec_targets='targets';
   sec_info='info';
   sec_info='info';
-  sec_misc='misc';
-  sec_rules='rules';
+  sec_defaults='defaults';
+  sec_tools='tools';
 
 
 type
 type
   TFpcMake=record
   TFpcMake=record
-    DefaultUnits   : boolean;
     TargetUnits,
     TargetUnits,
-    TargetPrograms : string;
+    TargetPrograms : array[0..targets] of string;
+    DefaultUnits   : boolean;
+    DefaultRule,
+    DefaultTarget,
+    DefaultCPU,
+    DefaultOptions : string;
+    DirFpc,
     DirUnit,
     DirUnit,
     DirLib,
     DirLib,
     DirObj,
     DirObj,
@@ -49,11 +63,19 @@ type
     LibGCC,
     LibGCC,
     LibOther       : boolean;
     LibOther       : boolean;
     InfoCfg,
     InfoCfg,
-    InfoDir,
+    InfoDirs,
     InfoTools,
     InfoTools,
     InfoInstall,
     InfoInstall,
     InfoObjects,
     InfoObjects,
     InfoFiles      : boolean;
     InfoFiles      : boolean;
+    ToolsSed,
+    ToolsDiff,
+    ToolsCmp,
+    ToolsUpx,
+    ToolsDate,
+    ToolsZip       : boolean;
+    PreSettings,
+    PostSettings,
     Rules          : TStringList;
     Rules          : TStringList;
   end;
   end;
 
 
@@ -86,6 +108,7 @@ function ReadMakefilefpc:boolean;
 var
 var
   fn  : string;
   fn  : string;
   ini : TIniFile;
   ini : TIniFile;
+  i   : integer;
 begin
 begin
   ReadMakefilefpc:=false;
   ReadMakefilefpc:=false;
   if FileExists('Makefile.fpc') then
   if FileExists('Makefile.fpc') then
@@ -102,31 +125,55 @@ begin
   with userini,ini do
   with userini,ini do
    begin
    begin
    { targets }
    { targets }
-     DefaultUnits:=ReadBool(sec_targets,'defaultunits',false);
-     TargetUnits:=ReadString(sec_targets,'units','');
-     TargetPrograms:=ReadString(sec_targets,'programs','');
+     TargetUnits[0]:=ReadString(sec_targets,'units','');
+     TargetPrograms[0]:=ReadString(sec_targets,'programs','');
+     for i:=1 to targets do
+      begin
+        TargetUnits[i]:=ReadString(sec_targets,'units_'+targetstr[i],'');
+        TargetPrograms[i]:=ReadString(sec_targets,'programs_'+targetstr[i],'');
+      end;
+   { defaults }
+     DefaultUnits:=ReadBool(sec_defaults,'defaultunits',false);
+     DefaultRule:=ReadString(sec_defaults,'defaultrule','all');
+     DefaultTarget:=ReadString(sec_defaults,'defaulttarget','');
+     DefaultCPU:=ReadString(sec_defaults,'defaultcpu','');
+     DefaultOptions:=ReadString(sec_defaults,'defaultoptions','');
    { dirs }
    { dirs }
-     DirUnit:=ReadString(sec_dirs,'unit','');
-     DirLib:=ReadString(sec_dirs,'lib','');
-     DirObj:=ReadString(sec_dirs,'obj','');
-     DirTarget:=ReadString(sec_dirs,'target','');
-     DirUnitTarget:=ReadString(sec_dirs,'unittarget','');
-     DirInc:=ReadString(sec_dirs,'inc','');
-     DirProcInc:=ReadString(sec_dirs,'procinc','');
-     DirOSInc:=ReadString(sec_dirs,'osinc','');
+     DirFpc:=ReadString(sec_dirs,'fpcdir','');
+     DirUnit:=ReadString(sec_dirs,'unitdir','');
+     DirLib:=ReadString(sec_dirs,'libdir','');
+     DirObj:=ReadString(sec_dirs,'objdir','');
+     DirTarget:=ReadString(sec_dirs,'targetdir','');
+     DirUnitTarget:=ReadString(sec_dirs,'unittargetdir','');
+     DirInc:=ReadString(sec_dirs,'incdir','');
+     DirProcInc:=ReadString(sec_dirs,'procincdir','');
+     DirOSInc:=ReadString(sec_dirs,'osincdir','');
    { libs }
    { libs }
-     LibGcc:=ReadBool(sec_libs,'gcc',false);
-     LibOther:=ReadBool(sec_libs,'other',false);
+     LibGcc:=ReadBool(sec_libs,'libgcc',false);
+     LibOther:=ReadBool(sec_libs,'libother',false);
+   { tools }
+     ToolsSed:=ReadBool(sec_tools,'toolsed',false);
+     ToolsDiff:=ReadBool(sec_tools,'tooldiff',false);
+     ToolsCmp:=ReadBool(sec_tools,'toolcmp',false);
+     ToolsUpx:=ReadBool(sec_tools,'toolupx',true);
+     ToolsDate:=ReadBool(sec_tools,'tooldate',true);
+     ToolsZip:=ReadBool(sec_tools,'toolzip',true);
    { info }
    { info }
-     InfoCfg:=ReadBool(sec_info,'config',true);
-     InfoDir:=ReadBool(sec_info,'dir',false);
-     InfoTools:=ReadBool(sec_info,'tools',false);
-     InfoInstall:=ReadBool(sec_info,'install',true);
-     InfoObjects:=ReadBool(sec_info,'objects',true);
-     InfoFiles:=ReadBool(sec_info,'files',false);
+     InfoCfg:=ReadBool(sec_info,'infoconfig',true);
+     InfoDirs:=ReadBool(sec_info,'infodirs',false);
+     InfoTools:=ReadBool(sec_info,'infotools',false);
+     InfoInstall:=ReadBool(sec_info,'infoinstall',true);
+     InfoObjects:=ReadBool(sec_info,'infoobjects',true);
+     InfoFiles:=ReadBool(sec_info,'infofiles',false);
+   { rules }
+     PreSettings:=TStringList.Create;
+     ReadSectionRaw('presettings',PreSettings);
+   { rules }
+     PostSettings:=TStringList.Create;
+     ReadSectionRaw('postsettings',PostSettings);
    { rules }
    { rules }
      rules:=TStringList.Create;
      rules:=TStringList.Create;
-     ReadSectionRaw(sec_rules,rules);
+     ReadSectionRaw('rules',rules);
    end;
    end;
 
 
   ini.Destroy;
   ini.Destroy;
@@ -143,15 +190,18 @@ var
   fn : string;
   fn : string;
 begin
 begin
   ReadFpcMakeIni:=nil;
   ReadFpcMakeIni:=nil;
-  if FileExists('userini.ini') then
-   fn:='userini.ini'
+  if FileExists('fpcmake.ini') then
+   fn:='fpcmake.ini'
+  else
+   if (FileExists(GetEnv('FPCMAKEINI'))) then
+    fn:=GetEnv('FPCMAKEINI')
   else
   else
 {$ifdef linux}
 {$ifdef linux}
-   if FileExists('/usr/lib/fpc/userini.ini') then
-    fn:='/usr/lib/fpc/userini.ini'
+   if FileExists('/usr/lib/fpc/fpcmake.ini') then
+    fn:='/usr/lib/fpc/fpcmake.ini'
 {$else}
 {$else}
-   if FileExists(paramstr(0)+'/userini.ini') then
-    fn:=paramstr(0)+'/userini.ini'
+   if FileExists(ChangeFileExt(paramstr(0),'.ini')) then
+    fn:=ChangeFileExt(paramstr(0),'.ini')
 {$endif}
 {$endif}
   else
   else
    exit;
    exit;
@@ -178,7 +228,7 @@ var
     i:=0;
     i:=0;
     while (i<sl.Count) do
     while (i<sl.Count) do
      begin
      begin
-       if sl[i][1] in [' ',#9] then
+       if (sl[i]<>'') and (sl[i][1] in [' ',#9]) then
         begin
         begin
           s:=sl[i];
           s:=sl[i];
           k:=0;
           k:=0;
@@ -233,7 +283,8 @@ var
     i:=0;
     i:=0;
     while (i<userini.rules.Count) do
     while (i<userini.rules.Count) do
      begin
      begin
-       if (userini.rules[i][1]=s[1]) and
+       if (userini.rules[i]<>'') and
+          (userini.rules[i][1]=s[1]) and
           (Copy(userini.rules[i],1,length(s))=s) then
           (Copy(userini.rules[i],1,length(s))=s) then
          exit;
          exit;
        inc(i);
        inc(i);
@@ -244,6 +295,7 @@ var
 
 
 var
 var
   hs : string;
   hs : string;
+  i  : integer;
 begin
 begin
 { Open the Makefile }
 { Open the Makefile }
   Verbose('Creating Makefile');
   Verbose('Creating Makefile');
@@ -255,69 +307,127 @@ begin
    begin
    begin
    { write header & autodetection }
    { write header & autodetection }
      Add('#');
      Add('#');
-     Add('# Makefile generated from Makefile.fpc by '+Title);
+     Add('# Makefile generated from Makefile.fpc on '+FormatDateTime(TimeFormat,Now));
      Add('#');
      Add('#');
      Add('');
      Add('');
+     Add('defaultrule: Makefile '+userini.defaultrule);
+     Add('');
+     AddSection(true,'makefilerule');
      AddSection(true,'osdetect');
      AddSection(true,'osdetect');
+
+   { set the forced target os/cpu }
+     if (userini.defaulttarget<>'') or (userini.defaultcpu<>'') then
+      begin
+        AddSection(true,'defaulttarget');
+        if userini.defaulttarget<>'' then
+         Add('override OS_TARGET:='+userini.defaulttarget);
+        if userini.defaultcpu<>'' then
+         Add('override CPU_TARGET:='+userini.defaultcpu);
+        Add('');
+      end;
+
+   { fpc detection }
      AddSection(true,'fpcdetect');
      AddSection(true,'fpcdetect');
 
 
    { write the default & user settings }
    { write the default & user settings }
      AddSection(true,'defaultsettings');
      AddSection(true,'defaultsettings');
      AddSection(true,'usersettings');
      AddSection(true,'usersettings');
 
 
+   { Pre Settings }
+     if userini.PreSettings.count>0 then
+      AddStrings(userini.PreSettings);
+
    { Targets }
    { Targets }
+     Add('');
+     Add('UNITOBJECTS='+userini.targetunits[0]);
+     Add('EXEOBJECTS='+userini.targetprograms[0]);
+     for i:=1to targets do
+      if (userini.targetunits[i]<>'') or
+         (userini.targetprograms[i]<>'') then
+      begin
+        Add('ifeq ($(OS_TARGET),'+targetstr[i]+')');
+        if userini.targetunits[i]<>'' then
+         Add('UNITOBJECTS+='+userini.targetunits[i]);
+        if userini.targetprograms[i]<>'' then
+         Add('EXEOBJECTS+='+userini.targetprograms[i]);
+        Add('endif');
+      end;
+
+   { Defaults }
+     Add('');
      if userini.defaultunits then
      if userini.defaultunits then
       Add('DEFAULTUNITS=1');
       Add('DEFAULTUNITS=1');
-     Add('UNITOBJECTS='+userini.targetunits);
-     Add('EXEOBJECTS='+userini.targetprograms);
+     if userini.defaultoptions<>'' then
+      Add('override NEEDOPT='+userini.defaultoptions);
 
 
    { Dirs }
    { Dirs }
+     Add('');
+     if userini.dirfpc<>'' then
+      begin
+        { this dir can be set in the environment, it's more a default }
+        Add('ifndef FPCDIR');
+        Add('FPCDIR='+userini.dirfpc);
+        Add('endif');
+      end;
      if userini.dirunit<>'' then
      if userini.dirunit<>'' then
-      Add('NEEDUNITDIR='+userini.dirunit);
+      Add('override NEEDUNITDIR='+userini.dirunit);
      if userini.dirlib<>'' then
      if userini.dirlib<>'' then
-      Add('NEEDLIBDIR='+userini.dirlib);
+      Add('override NEEDLIBDIR='+userini.dirlib);
      if userini.dirobj<>'' then
      if userini.dirobj<>'' then
-      Add('NEEDOBJDIR='+userini.dirobj);
+      Add('override NEEDOBJDIR='+userini.dirobj);
      if userini.dirinc<>'' then
      if userini.dirinc<>'' then
-      Add('INC='+userini.dirinc);
-     if userini.dirprocinc<>'' then
-      Add('PROCINC='+userini.dirprocinc);
-     if userini.dirosinc<>'' then
-      Add('OSINC='+userini.dirosinc);
+      Add('override NEEDINCDIR='+userini.dirinc);
      if userini.dirtarget<>'' then
      if userini.dirtarget<>'' then
-      Add('TARGETDIR='+userini.dirtarget);
+      begin
+        Add('ifndef TARGETDIR');
+        Add('TARGETDIR='+userini.dirtarget);
+        Add('endif');
+      end;
      if userini.dirunittarget<>'' then
      if userini.dirunittarget<>'' then
-      Add('UNITTARGETDIR='+userini.dirunittarget);
+      begin
+        Add('ifndef UNITTARGETDIR');
+        Add('UNITTARGETDIR='+userini.dirunittarget);
+        Add('endif');
+      end;
 
 
    { Libs }
    { Libs }
+     Add('');
      if userini.libgcc then
      if userini.libgcc then
-      Add('NEEDGCCLIB=1');
+      Add('override NEEDGCCLIB=1');
      if userini.libother then
      if userini.libother then
-      Add('NEEDOTHERLIB=1');
+      Add('override NEEDOTHERLIB=1');
 
 
    { Info }
    { Info }
      Add('');
      Add('');
      hs:='';
      hs:='';
      if userini.infocfg then
      if userini.infocfg then
       hs:=hs+'fpc_infocfg ';
       hs:=hs+'fpc_infocfg ';
-     if userini.infodir then
-      hs:=hs+'fpc_infodir ';
+     if userini.infodirs then
+      hs:=hs+'fpc_infodirs ';
      if userini.infotools then
      if userini.infotools then
       hs:=hs+'fpc_infotools ';
       hs:=hs+'fpc_infotools ';
+     if userini.infoobjects then
+      hs:=hs+'fpc_infoobjects ';
      if userini.infoinstall then
      if userini.infoinstall then
       hs:=hs+'fpc_infoinstall ';
       hs:=hs+'fpc_infoinstall ';
      if userini.infofiles then
      if userini.infofiles then
       hs:=hs+'fpc_infofiles ';
       hs:=hs+'fpc_infofiles ';
      Add('FPCINFO='+hs);
      Add('FPCINFO='+hs);
 
 
+   { Post Settings }
+     if userini.PostSettings.count>0 then
+      AddStrings(userini.PostSettings);
+
    { commandline }
    { commandline }
      Add('');
      Add('');
      AddSection(true,'command_begin');
      AddSection(true,'command_begin');
      AddSection(true,'command_rtl');
      AddSection(true,'command_rtl');
      AddSection(true,'command_needopt');
      AddSection(true,'command_needopt');
+     AddSection((userini.dirfpc<>''),'command_fpcdir');
      AddSection((userini.dirunit<>''),'command_needunit');
      AddSection((userini.dirunit<>''),'command_needunit');
      AddSection((userini.dirlib<>''),'command_needlib');
      AddSection((userini.dirlib<>''),'command_needlib');
      AddSection((userini.dirobj<>''),'command_needobj');
      AddSection((userini.dirobj<>''),'command_needobj');
+     AddSection((userini.dirinc<>''),'command_needinc');
      AddSection(userini.libgcc,'command_gcclib');
      AddSection(userini.libgcc,'command_gcclib');
      AddSection(userini.libother,'command_otherlib');
      AddSection(userini.libother,'command_otherlib');
      AddSection((userini.dirinc<>''),'command_inc');
      AddSection((userini.dirinc<>''),'command_inc');
@@ -331,12 +441,12 @@ begin
    { write tools }
    { write tools }
      AddSection(true,'shelltools');
      AddSection(true,'shelltools');
      AddSection(true,'tool_default');
      AddSection(true,'tool_default');
-     AddSection(true,'tool_upx');
-     AddSection(true,'tool_sed');
-     AddSection(true,'tool_date');
-     AddSection(true,'tool_zip');
-     AddSection(true,'tool_cmp');
-     AddSection(true,'tool_diff');
+     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');
 
 
    { write dirs }
    { write dirs }
      AddSection(true,'dir_default');
      AddSection(true,'dir_default');
@@ -354,6 +464,7 @@ begin
      AddRule('all');
      AddRule('all');
      AddRule('staticlib');
      AddRule('staticlib');
      AddRule('sharedlib');
      AddRule('sharedlib');
+     AddRule('showinstall');
      AddRule('install');
      AddRule('install');
      AddRule('staticinstall');
      AddRule('staticinstall');
      AddRule('sharedinstall');
      AddRule('sharedinstall');
@@ -361,6 +472,7 @@ begin
      AddRule('zipinstall');
      AddRule('zipinstall');
      AddRule('zipinstalladd');
      AddRule('zipinstalladd');
      AddRule('clean');
      AddRule('clean');
+     AddRule('clean_all');
      AddRule('depend');
      AddRule('depend');
      AddRule('info');
      AddRule('info');
 
 
@@ -373,9 +485,9 @@ begin
      AddSection(true,'dependrules');
      AddSection(true,'dependrules');
      AddSection(true,'inforules');
      AddSection(true,'inforules');
      AddSection(userini.infocfg,'info_cfg');
      AddSection(userini.infocfg,'info_cfg');
-     AddSection(userini.infodir,'info_dir');
+     AddSection(userini.infodirs,'info_dirs');
      AddSection(userini.infotools,'info_tools');
      AddSection(userini.infotools,'info_tools');
-     AddSection(userini.infoobjects,'info_object');
+     AddSection(userini.infoobjects,'info_objects');
      AddSection(userini.infoinstall,'info_install');
      AddSection(userini.infoinstall,'info_install');
      AddSection(userini.infofiles,'info_files');
      AddSection(userini.infofiles,'info_files');
 
 
@@ -401,7 +513,7 @@ begin
 { Open userini.ini }
 { Open userini.ini }
   fpcini:=ReadFpcMakeIni;
   fpcini:=ReadFpcMakeIni;
   if not assigned(fpcini) then
   if not assigned(fpcini) then
-   Error('Can''t read userini.ini');
+   Error('Can''t read fpcmake.ini');
 
 
 { Open Makefile.fpc }
 { Open Makefile.fpc }
   if not ReadMakefilefpc then
   if not ReadMakefilefpc then
@@ -415,7 +527,10 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.1  1999-11-02 23:57:40  peter
+  Revision 1.2  1999-11-03 23:39:53  peter
+    * lot of updates
+
+  Revision 1.1  1999/11/02 23:57:40  peter
     * initial version
     * initial version
 
 
 }
 }

+ 76 - 19
utils/makefile.exm

@@ -5,31 +5,88 @@
 #
 #
 
 
 [targets]
 [targets]
-;defaultunits=0
-units=<your units>
-programs=<your programs>
+; The units which should be compiled
+units=
+; The programs which should be compiled
+programs=
+
+
+[defaults]
+; the default build target should only compile the units ?
+defaultunits=0
+; What is the default rule to call
+defaultrule=all
+; force target OS
+defaulttarget=
+; force target CPU
+defaultcpu=
+; options needed to compile (like -S2 or -Sg)
+defaultoptions=
+
 
 
 [dirs]
 [dirs]
-;unitdir=
-;libdir=
-;objdir=
-;incdir=
-;procincdir=
-;osincdir=
-;targetdir=
-;unittargetdir=
+; what is the default location of FPC
+fpcdir=
+; which dirs need to be searched for units
+unitdir=
+; which dirs need to be searched for libs
+libdir=
+; which dirs need to be searched for object files
+objdir=
+; which dirs need to be searched for include files
+incdir=
+; where to place the created units/files
+targetdir=
+; where to place the created units
+unittargetdir=
+
 
 
 [libs]
 [libs]
-;libgcc=0
-;libother=0
+; linking with libgcc.a needed ?
+libgcc=0
+; linking with other libraries needed (not in the /lib;/usr/lib;/usr/X11R6/lib)
+libother=0
+
+
+[tools]
+; sed needed?
+toolsed=0
+; cmp needed?
+toolcmp=0
+; diff needed?
+tooldiff=0
+; try to use upx for compression ?
+toolupx=1
+; date needed?
+tooldate=1
+; zip needed?
+toolzip=1
+
 
 
 [info]
 [info]
-;infocfg=1
-;infodir=0
-;infotools=0
-;infoinstall=1
-;infoobjects=1
-;infofiles=0
+; show configuration info
+infocfg=1
+; show directory info
+infodir=0
+; show which tools are found
+infotools=0
+; show install dirs
+infoinstall=1
+; show build objects
+infoobjects=1
+; show files found in current dir
+infofiles=0
+
+
+[presettings]
+; Add here the makefile commands which need to be done at the beginning
+; of the user settings section
+
+
+[postsettings]
+; Add here the makefile commands which need to be done at the end
+; of the user settings section
+
 
 
 [rules]
 [rules]
 ; here you can add your own rules, the general rules will automaticly
 ; here you can add your own rules, the general rules will automaticly