Browse Source

* packages
* lot of other changes

peter 26 years ago
parent
commit
392c44c739
3 changed files with 597 additions and 396 deletions
  1. 244 182
      utils/fpcmake.inc
  2. 115 60
      utils/fpcmake.ini
  3. 238 154
      utils/fpcmake.pp

+ 244 - 182
utils/fpcmake.inc

@@ -1,7 +1,7 @@
 {$ifdef Delphi}
-const fpcmakeini : array[0..93] of string[240]=(
+const fpcmakeini : array[0..99] of string[240]=(
 {$else Delphi}
-const fpcmakeini : array[0..93,1..240] of char=(
+const fpcmakeini : array[0..99,1..240] of char=(
 {$endif Delphi}
   ';'#010+
   '; $Id$'#010+
@@ -320,19 +320,23 @@ const fpcmakeini : array[0..93,1..240] of char=(
   'override ','FPCOPT+=-FU$(UNITTARGETDIR)'#010+
   'endif'#010+
   #010+
-  '[command_smartlink]'#010+
+  '[command_end]'#010+
   '# Smartlinking'#010+
   'ifdef SMARTLINK'#010+
   'override FPCOPT+=-CX'#010+
   'endif'#010+
   #010+
-  '[command_end]'#010+
+  '# Debug'#010+
+  'ifdef DEBUG'#010+
+  'override FPCOPT+=-g'#010+
+  'endif'#010+
+  #010+
   '# Add commandline options'#010+
   'ifdef OPT'#010+
   'override FPCOPT+=$(OPT)'#010+
   'endif'#010+
   'ifdef UNITDIR'#010+
-  'override FPCOPT+=$(addprefix -Fu',',$(UNITDIR))'#010+
+  'overr','ide FPCOPT+=$(addprefix -Fu,$(UNITDIR))'#010+
   'endif'#010+
   'ifdef LIBDIR'#010+
   'override FPCOPT+=$(addprefix -Fl,$(LIBDIR))'#010+
@@ -344,7 +348,7 @@ const fpcmakeini : array[0..93,1..240] of char=(
   'override FPCOPT+=$(addprefix -Fi,$(INCDIR))'#010+
   'endif'#010+
   #010+
-  '# Add defines from FPCOPTDEF to',' FPCOPT'#010+
+  '# Ad','d defines from FPCOPTDEF to FPCOPT'#010+
   'ifdef FPCOPTDEF'#010+
   'override FPCOPT+=$(FPCOPTDEF)'#010+
   'endif'#010+
@@ -358,7 +362,7 @@ const fpcmakeini : array[0..93,1..240] of char=(
   #010+
   #010+
   '[shelltools]'#010+
-  '###############################################','#####################'+
+  '####################','################################################'+
   '#'#010+
   '# Shell tools'#010+
   '#####################################################################'#010+
@@ -370,10 +374,10 @@ const fpcmakeini : array[0..93,1..240] of char=(
   #010+
   '# To move pograms'#010+
   'ifndef MOVE'#010+
-  'export MOVE:=mv -f'#010+
+  'export MOVE:=mv -f',#010+
   'endif'#010+
   #010+
-  '# Check delete prog','ram'#010+
+  '# Check delete program'#010+
   'ifndef DEL'#010+
   'export DEL:=rm -f'#010+
   'endif'#010+
@@ -388,11 +392,11 @@ const fpcmakeini : array[0..93,1..240] of char=(
   'ifdef inlinux'#010+
   'export INSTALL:=install -m 644'#010+
   'else'#010+
-  'export INSTALL:=$(COPY)'#010+
+  'export INSTALL:=$(CO','PY)'#010+
   'endif'#010+
   'endif'#010+
   #010+
-  '# To insta','ll programs'#010+
+  '# To install programs'#010+
   'ifndef INSTALLEXE'#010+
   'ifdef inlinux'#010+
   'export INSTALLEXE:=install -m 755'#010+
@@ -406,7 +410,7 @@ const fpcmakeini : array[0..93,1..240] of char=(
   'ifdef inlinux'#010+
   'export MKDIR:=install -m 755 -d'#010+
   'else'#010+
-  'export MKDIR:=ginstall -m 755 ','-d'#010+
+  'exp','ort MKDIR:=ginstall -m 755 -d'#010+
   'endif'#010+
   'endif'#010+
   #010+
@@ -416,8 +420,8 @@ const fpcmakeini : array[0..93,1..240] of char=(
   '# Default Tools'#010+
   '#####################################################################'#010+
   #010+
-  '# assembler, redefine it if cross compiling'#010+
-  'ifndef ','AS'#010+
+  '# assembler, redefine it',' if cross compiling'#010+
+  'ifndef AS'#010+
   'AS=as'#010+
   'endif'#010+
   #010+
@@ -437,8 +441,8 @@ const fpcmakeini : array[0..93,1..240] of char=(
   'endif'#010+
   'endif'#010+
   #010+
-  '# also call ppas if with command option -s'#010+
-  'ifeq (,$(findst','ring -s ,$(COMPILER)))'#010+
+  '# also call ppas if with comman','d option -s'#010+
+  'ifeq (,$(findstring -s ,$(COMPILER)))'#010+
   'EXECPPAS='#010+
   'else'#010+
   'EXECPPAS=@$(PPAS)'#010+
@@ -453,8 +457,9 @@ const fpcmakeini : array[0..93,1..240] of char=(
   #010+
   '# echo'#010+
   'ifndef ECHO'#010+
-  'ECHO:=$(strip $(wildcard $(addsuffix /echo$(EXEEXT),$(SEARCHPATH))))'#010+
-  'ife','q ($(ECHO),)'#010+
+  'ECHO:=$(strip $(wildcard $(addsuffix /echo$(E','XEEXT),$(SEARCHPATH))))'+
+  #010+
+  'ifeq ($(ECHO),)'#010+
   'export ECHO:=echo'#010+
   'else'#010+
   'export ECHO:=$(firstword $(ECHO))'#010+
@@ -468,9 +473,9 @@ const fpcmakeini : array[0..93,1..240] of char=(
   'PPDEP:=$(strip $(wildcard $(addsuffix /ppdep$(EXEEXT),$(SEARCHPATH))))'+
   #010+
   'ifeq ($(PPDEP),)'#010+
-  'PPDEP='#010+
+  'PPDEP='#010,
   'else'#010+
-  'export PPDEP:=$(firstw','ord $(PPDEP))'#010+
+  'export PPDEP:=$(firstword $(PPDEP))'#010+
   'endif'#010+
   'endif'#010+
   #010+
@@ -482,11 +487,11 @@ const fpcmakeini : array[0..93,1..240] of char=(
   'ifeq ($(PPUMOVE),)'#010+
   'PPUMOVE='#010+
   'else'#010+
-  'export PPUMOVE:=$(firstword $(PPUMOVE))'#010+
+  'export PPUMOVE:=$(firstword $(PPUMOVE)',')'#010+
   'endif'#010+
   'endif'#010+
   #010+
-  '[tool_ppufil','es]'#010+
+  '[tool_ppufiles]'#010+
   '# ppufiles'#010+
   'ifndef PPUFILES'#010+
   'PPUFILES:=$(strip $(wildcard $(addsuffix /ppufiles$(EXEEXT),$(SEARCHPA'+
@@ -498,9 +503,9 @@ const fpcmakeini : array[0..93,1..240] of char=(
   'endif'#010+
   'endif'#010+
   #010+
-  '[tool_data2inc]'#010+
+  '[tool_data2inc]',#010+
   '# data2inc'#010+
-  'ifndef DATA2INC',#010+
+  'ifndef DATA2INC'#010+
   'DATA2INC:=$(strip $(wildcard $(addsuffix /data2inc$(EXEEXT),$(SEARCHPA'+
   'TH))))'#010+
   'ifeq ($(DATA2INC),)'#010+
@@ -513,7 +518,7 @@ const fpcmakeini : array[0..93,1..240] of char=(
   '[tool_diff]'#010+
   '# diff'#010+
   'ifndef DIFF'#010+
-  'DIFF:=$(strip $(wildcard $(addsuffix /dif','f$(EXEEXT),$(SEARCHPATH))))'+
+  'DIFF:=$(strip ','$(wildcard $(addsuffix /diff$(EXEEXT),$(SEARCHPATH))))'+
   #010+
   'ifeq ($(DIFF),)'#010+
   'DIFF='#010+
@@ -527,9 +532,9 @@ const fpcmakeini : array[0..93,1..240] of char=(
   'ifndef CMP'#010+
   'CMP:=$(strip $(wildcard $(addsuffix /cmp$(EXEEXT),$(SEARCHPATH))))'#010+
   'ifeq ($(CMP),)'#010+
-  'CMP='#010+
+  'C','MP='#010+
   'else'#010+
-  'export CMP:=$(firs','tword $(CMP))'#010+
+  'export CMP:=$(firstword $(CMP))'#010+
   'endif'#010+
   'endif'#010+
   #010+
@@ -545,7 +550,7 @@ const fpcmakeini : array[0..93,1..240] of char=(
   'endif'#010+
   #010+
   '[tool_upx]'#010+
-  '# Look if UPX is found for go32v2 and',' win32. We can'#039't use $UPX b'+
+  '# Look if ','UPX is found for go32v2 and win32. We can'#039't use $UPX b'+
   'ecuase'#010+
   '# upx uses that one itself (PFV)'#010+
   'ifndef UPXPROG'#010+
@@ -556,7 +561,7 @@ const fpcmakeini : array[0..93,1..240] of char=(
   'UPXPROG:=1'#010+
   'endif'#010+
   'ifdef UPXPROG'#010+
-  'UPXPROG:=$(strip $(wildcard $(addsuffix /upx$(EXEEXT),$(S','EARCHPATH))'+
+  'UPXPROG:=$(strip $(wildcard $(','addsuffix /upx$(EXEEXT),$(SEARCHPATH))'+
   '))'#010+
   'ifeq ($(UPXPROG),)'#010+
   'UPXPROG='#010+
@@ -571,8 +576,9 @@ const fpcmakeini : array[0..93,1..240] of char=(
   '[tool_date]'#010+
   '# gdate/date'#010+
   'ifndef DATE'#010+
-  'DATE:=$(strip $(wildcard $(addsuffix /date$(EXEEXT),$(SEARCHPATH))))'#010+
-  'ifeq ($(DATE),',')'#010+
+  'DATE:=$(strip $(wildcard $(addsuffix /date$(EXEEXT),$(SE','ARCHPATH))))'+
+  #010+
+  'ifeq ($(DATE),)'#010+
   'DATE:=$(strip $(wildcard $(addsuffix /gdate$(EXEEXT),$(SEACHPATH))))'#010+
   'ifeq ($(DATE),)'#010+
   'DATE='#010+
@@ -585,8 +591,8 @@ const fpcmakeini : array[0..93,1..240] of char=(
   'endif'#010+
   #010+
   'ifdef DATE'#010+
-  'DATESTR:=$(shell $(DATE) +%Y%m%d)'#010+
-  'else'#010,
+  'DATESTR:=$(s','hell $(DATE) +%Y%m%d)'#010+
+  'else'#010+
   'DATESTR='#010+
   'endif'#010+
   #010+
@@ -598,7 +604,7 @@ const fpcmakeini : array[0..93,1..240] of char=(
   'ifeq ($(ZIPPROG),)'#010+
   'ZIPPROG='#010+
   'else'#010+
-  'export ZIPPROG:=$(firstword $(ZIPPROG)) -D9',' -r'#010+
+  'export ZIPPROG:=','$(firstword $(ZIPPROG)) -D9 -r'#010+
   'endif'#010+
   'endif'#010+
   #010+
@@ -610,9 +616,10 @@ const fpcmakeini : array[0..93,1..240] of char=(
   '[extensions]'#010+
   '#####################################################################'#010+
   '# Default extensions'#010+
-  '#####################################################################'#010+
+  '##########################################################','##########'+
+  '#'#010+
   #010+
-  '# Default need','ed extensions (Go32v2,Linux)'#010+
+  '# Default needed extensions (Go32v2,Linux)'#010+
   'LOADEREXT=.as'#010+
   'PPLEXT=.ppl'#010+
   'PPUEXT=.ppu'#010+
@@ -627,9 +634,9 @@ const fpcmakeini : array[0..93,1..240] of char=(
   'ifeq ($(OS_TARGET),go32v1)'#010+
   'PPUEXT=.pp1'#010+
   'OEXT=.o1'#010+
-  'ASMEXT=.s1'#010+
+  'ASMEXT=.s','1'#010+
   'SMARTEXT=.sl1'#010+
-  'STATICLIBEX','T=.a1'#010+
+  'STATICLIBEXT=.a1'#010+
   'SHAREDLIBEXT=.so1'#010+
   'PACKAGESUFFIX=v1'#010+
   'endif'#010+
@@ -646,10 +653,10 @@ const fpcmakeini : array[0..93,1..240] of char=(
   #010+
   '# Win32'#010+
   'ifeq ($(OS_TARGET),win32)'#010+
-  'PPUEXT=.ppw'#010+
+  'PPUEXT=.','ppw'#010+
   'OEXT=.ow'#010+
   'ASMEXT=.sw'#010+
-  'SMA','RTEXT=.slw'#010+
+  'SMARTEXT=.slw'#010+
   'STATICLIBEXT=.aw'#010+
   'SHAREDLIBEXT=.dll'#010+
   'PACKAGESUFFIX=win32'#010+
@@ -666,8 +673,8 @@ const fpcmakeini : array[0..93,1..240] of char=(
   'PACKAGESUFFIX=os2'#010+
   'endif'#010+
   #010+
-  '# library prefix'#010+
-  'LIBPREFIX=l','ib'#010+
+  '#',' library prefix'#010+
+  'LIBPREFIX=lib'#010+
   'ifeq ($(OS_TARGET),go32v2)'#010+
   'LIBPREFIX='#010+
   'endif'#010+
@@ -678,8 +685,8 @@ const fpcmakeini : array[0..93,1..240] of char=(
   '# determine which .pas extension is used'#010+
   'ifndef PASEXT'#010+
   'ifdef EXEOBJECTS'#010+
-  'override TESTPAS:=$(strip $(wildcard $(addsuffix .pas,$(firstword $(EX'+
-  'EOBJEC','TS)))))'#010+
+  'override TESTPAS:=$(strip $(wildcard $(addsuffix ','.pas,$(firstword $('+
+  'EXEOBJECTS)))))'#010+
   'else'#010+
   'override TESTPAS:=$(strip $(wildcard $(addsuffix .pas,$(firstword $(UN'+
   'ITOBJECTS)))))'#010+
@@ -693,52 +700,118 @@ const fpcmakeini : array[0..93,1..240] of char=(
   #010+
   #010+
   '[defaultrules]'#010+
-  '############################################################','########'+
+  '#################################','###################################'+
   '#'#010+
   '# Default rules'#010+
   '#####################################################################'#010+
   #010+
-  '.PHONY: defaultrule all smart shared \'#010+
+  '.PHONY: defaultrule all debug examples test smart shared \'#010+
   '        showinstall install zipinstall zipinstalladd \'#010+
-  '        clean cleanall depend info'#010+
+  '  ','      clean cleanall depend info'#010+
   #010+
   #010+
-  '[compilerule','s]'#010+
+  '[loaderrules]'#010+
   '#####################################################################'#010+
-  '# General compile rules'#010+
+  '# Loaders'#010+
   '#####################################################################'#010+
   #010+
-  '.PHONY: fpc_all fpc_units fpc_exes fpc_loaders'#010+
+  '.PHONY: fpc_loaders'#010+
   #010+
-  '# Create Filenames'#010+
-  'ifdef',' LOADEROBJECTS'#010+
-  'LOADEROFILES=$(addsuffix $(OEXT),$(LOADEROBJECTS))'#010+
-  'endif'#010+
-  'ifdef EXEOBJECTS'#010+
-  'EXEFILES=$(addsuffix $(EXEEXT),$(EXEOBJECTS))'#010+
-  'EXEOFILES=$(addsuffix $(OEXT),$(EXEOBJECTS))'#010+
-  'endif'#010+
-  'ifdef UNITOBJECTS'#010+
-  'UNITPPUFILES=$(addsuffix $(PPUEXT),$','(UNITOBJECTS))'#010+
-  'endif'#010+
+  '%$(OEXT): %$(LOADER','EXT)'#010+
+  '        $(AS) -o $*$(OEXT) $<'#010+
   #010+
-  '.SUFFIXES: $(EXEEXT) $(PPUEXT) $(OEXT) .pas .pp'#010+
+  'override ALLTARGET+=fpc_loaders'#010+
+  'override CLEANTARGET+=fpc_loaders_clean'#010+
+  'override SHOWINSTALLTARGET+=fpc_loaders_showinstall'#010+
+  'override INSTALLTARGET+=fpc_loaders_install'#010+
   #010+
-  'ifdef DEFAULTUNITS'#010+
-  'fpc_all: fpc_loaders fpc_units'#010+
-  'else'#010+
-  'fpc_all: fpc_loaders fpc_units fpc_exes'#010+
-  'endif'#010+
+  'LOADEROFILES=$(addsuffix $(OEXT),$(','LOADEROBJECTS))'#010+
   #010+
   'fpc_loaders: $(LOADEROFILES)'#010+
   #010+
+  'fpc_loaders_clean:'#010+
+  '        -$(DEL) $(LOADEROFILES)'#010+
+  #010+
+  'fpc_loaders_showinstall:'#010+
+  '        @$(ECHO) $(addprefix "\n"$(UNITINSTALLDIR)/,$(LOADEROFILES))'#010+
+  #010+
+  'fpc_loaders_install:'#010+
+  '        $(MKDIR) $(UNITIN','STALLDIR)'#010+
+  '        $(INSTALL) $(LOADEROFILES) $(UNITINSTALLDIR)'#010+
+  #010+
+  #010+
+  '[unitrules]'#010+
+  '#####################################################################'#010+
+  '# Units'#010+
+  '#####################################################################'#010+
+  #010+
+  '.PHONY: fpc_un','its'#010+
+  #010+
+  'override ALLTARGET+=fpc_units'#010+
+  #010+
+  'UNITPPUFILES=$(addsuffix $(PPUEXT),$(UNITOBJECTS))'#010+
+  'override INSTALLPPUFILES+=$(UNITPPUFILES)'#010+
+  'override CLEANPPUFILES+=$(UNITPPUFILES)'#010+
+  #010+
   'fpc_units: $(UNITPPUFILES)'#010+
   #010+
-  'fpc_exes:',' $(EXEFILES)'#010+
+  #010+
+  #010+
+  '[exerules]'#010+
+  '#############################','#######################################'+
+  '#'#010+
+  '# Exes'#010+
+  '#####################################################################'#010+
+  #010+
+  '.PHONY: fpc_exes'#010+
+  #010+
+  'EXEFILES=$(addsuffix $(EXEEXT),$(EXEOBJECTS))'#010+
+  'EXEOFILES=$(addsuffix $(OEXT),$(EXEOBJECTS))'#010+
+  #010+
+  'override AL','LTARGET+=fpc_exes'#010+
+  'override INSTALLEXEFILES+=$(EXEFILES)'#010+
+  'override CLEANEXEFILES+=$(EXEFILES) $(EXEOFILES)'#010+
+  #010+
+  'fpc_exes: $(EXEFILES)'#010+
+  #010+
+  #010+
+  '[examplerules]'#010+
+  '#####################################################################'#010+
+  '# Examples'#010+
+  '##############','######################################################'+
+  '#'#010+
+  #010+
+  '.PHONY: fpc_examples fpc_test'#010+
+  #010+
+  'EXAMPLEFILES=$(addsuffix $(EXEEXT),$(EXAMPLEOBJECTS))'#010+
+  'EXAMPLEOFILES=$(addsuffix $(OEXT),$(EXAMPLEOBJECTS))'#010+
+  #010+
+  'override CLEANEXEFILES+=$(EXAMPLEFILES) $(EX','AMPLEOFILES)'#010+
+  #010+
+  'fpc_examples: all $(EXAMPLEFILES)'#010+
+  #010+
+  'fpc_test: examples'#010+
+  #010+
+  #010+
+  '[compilerules]'#010+
+  '#####################################################################'#010+
+  '# General compile rules'#010+
+  '#############################################################','#######'+
+  '#'#010+
+  #010+
+  '.PHONY: fpc_all fpc_debug'#010+
+  #010+
+  'fpc_all: $(ALLTARGET)'#010+
+  #010+
+  'fpc_debug:'#010+
+  '        $(MAKE) all DEBUG=1'#010+
   #010+
   '# General compile rules, available for both possible PASEXT'#010+
+  #010+
+  '.SUFFIXES: $(EXEEXT) $(PPUEXT) $(OEXT) .pas .pp'#010+
+  #010+
   '%$(PPUEXT): %.pp'#010+
-  '        $(COMPILER) $< $(REDIR)'#010+
+  '        $(COM','PILER) $< $(REDIR)'#010+
   '        $(EXECPASS)'#010+
   #010+
   '%$(PPUEXT): %.pas'#010+
@@ -746,29 +819,25 @@ const fpcmakeini : array[0..93,1..240] of char=(
   '        $(EXECPASS)'#010+
   #010+
   '%$(EXEEXT): %.pp'#010+
-  '        ','$(COMPILER) $< $(REDIR)'#010+
+  '        $(COMPILER) $< $(REDIR)'#010+
   '        $(EXECPASS)'#010+
   #010+
   '%$(EXEEXT): %.pas'#010+
   '        $(COMPILER) $< $(REDIR)'#010+
-  '        $(EXECPASS)'#010+
-  #010+
-  '%$(OEXT): %$(LOADEREXT)'#010+
-  '        $(AS) -o $*$(OEXT) $<'#010+
+  '        $','(EXECPASS)'#010+
   #010+
   #010+
   '[libraryrules]'#010+
-  '#####################################################','###############'+
-  '#'#010+
+  '#####################################################################'#010+
   '# Library'#010+
   '#####################################################################'#010+
   #010+
   '.PHONY: fpc_smart fpc_shared'#010+
   #010+
-  '# Default sharedlib units are all unit objects'#010+
+  '# Default sharedlib units are a','ll unit objects'#010+
   'ifndef SHAREDLIBUNITOBJECTS'#010+
   'SHAREDLIBUNITOBJECTS=$(UNITOBJECTS)'#010+
-  'e','ndif'#010+
+  'endif'#010+
   #010+
   'fpc_smart:'#010+
   '        $(MAKE) all SMARTLINK=1'#010+
@@ -778,23 +847,21 @@ const fpcmakeini : array[0..93,1..240] of char=(
   'ifndef LIBNAME'#010+
   '        @$(ECHO) LIBNAME not set'#010+
   'else'#010+
-  '        $(PPUMOVE) $(SHAREDLIBUNITOBJECTS) -o$(LIBNAME)'#010+
+  '        $(PPUMOVE) $(SHARE','DLIBUNITOBJECTS) -o$(LIBNAME)'#010+
   'endif'#010+
   'else'#010+
-  '        @$(ECHO) Shared Libraries not su','pported'#010+
+  '        @$(ECHO) Shared Libraries not supported'#010+
   'endif'#010+
   #010+
   #010+
   '[installrules]'#010+
   '#####################################################################'#010+
   '# Install rules'#010+
-  '#####################################################################'#010+
+  '##########################################','##########################'+
+  '#'#010+
   #010+
   '.PHONY: fpc_showinstall fpc_install'#010+
   #010+
-  'ifdef UNITPPUFI','LES'#010+
-  'override INSTALLPPUFILES:=$(UNITPPUFILES)'#010+
-  'endif'#010+
   'ifdef EXTRAINSTALLUNITS'#010+
   'override INSTALLPPUFILES+=$(addsuffix $(PPUEXT),$(EXTRAINSTALLUNITS))'#010+
   'endif'#010+
@@ -802,7 +869,7 @@ const fpcmakeini : array[0..93,1..240] of char=(
   'ifdef INSTALLPPUFILES'#010+
   'ifdef PPUFILES'#010+
   'ifdef inlinux'#010+
-  'INSTALLPPULINKFILES=$(shell $(PPUFIL','ES) -S -O $(INSTALLPPUFILES))'#010+
+  'INSTALLPPULINKFILES=$(','shell $(PPUFILES) -S -O $(INSTALLPPUFILES))'#010+
   'INSTALLPPULIBFILES=$(shell $(PPUFILES) -L $(INSTALLPPUFILES))'#010+
   'else'#010+
   'INSTALLPPULINKFILES=$(shell $(PPUFILES) $(INSTALLPPUFILES))'#010+
@@ -810,63 +877,53 @@ const fpcmakeini : array[0..93,1..240] of char=(
   'endif'#010+
   'endif'#010+
   #010+
-  'fpc_showinstall:'#010+
-  'ifndef DEFAULTUNITS'#010+
-  'ifdef EXEOBJECTS'#010+
-  '        @$','(ECHO) $(addprefix "\n"$(BININSTALLDIR)/,$(EXEFILES))'#010+
-  'endif'#010+
-  'endif'#010+
-  'ifdef LOADEROBJECTS'#010+
-  '        @$(ECHO) $(addprefix "\n"$(UNITINSTALLDIR)/,$(LOADEROFILES))'#010+
+  'fpc_showinstall: $(SHOWINSTALLTARGET)'#010+
+  'ifdef INSTAL','LEXEFILES'#010+
+  '        @$(ECHO) $(addprefix "\n"$(BININSTALLDIR)/,$(INSTALLEXEFILES))'+
+  #010+
   'endif'#010+
   'ifdef INSTALLPPUFILES'#010+
-  '        @$(ECHO) $(addprefix "\n"$(UNITINSTALLDIR)/,$(INS','TALLPPUFILE'+
-  'S))'#010+
+  '        @$(ECHO) $(addprefix "\n"$(UNITINSTALLDIR)/,$(INSTALLPPUFILES)'+
+  ')'#010+
   'ifneq ($(INSTALLPPULINKFILES),)'#010+
-  '        @$(ECHO) $(addprefix "\n"$(UNITINSTALLDIR)/,$(INSTALLPPULINKFI'+
-  'LES))'#010+
+  '        @$(ECHO) $(addprefi','x "\n"$(UNITINSTALLDIR)/,$(INSTALLPPULINK'+
+  'FILES))'#010+
   'endif'#010+
   'ifneq ($(INSTALLPPULIBFILES),)'#010+
   '        @$(ECHO) $(addprefix "\n"$(LIBINSTALLDIR)/,$(INSTALLPPULIBFILE'+
   'S))'#010+
-  'endif'#010,
+  'endif'#010+
   'endif'#010+
   'ifdef EXTRAINSTALLFILES'#010+
-  '        @$(ECHO) $(addprefix "\n"$(EXTRAINSTALLDIR)/,$(EXTRAINSTALLFIL'+
-  'ES))'#010+
+  '        @$(ECHO) $(addprefix "\n"$(EXTRAINST','ALLDIR)/,$(EXTRAINSTALLF'+
+  'ILES))'#010+
   'endif'#010+
   #010+
-  'fpc_install:'#010+
+  'fpc_install: $(INSTALLTARGET)'#010+
   '# Create UnitInstallFiles'#010+
-  'ifndef DEFAULTUNITS'#010+
-  'ifdef EXEOBJECTS'#010+
+  'ifdef INSTALLEXEFILES'#010+
   '        $(MKDIR) $(BININSTALLDIR)'#010+
-  '# Compress the exe','s if upx is defined'#010+
+  '# Compress the exes if upx is defined'#010+
   'ifdef UPXPROG'#010+
-  '        -$(UPXPROG) $(EXEFILES)'#010+
-  'endif'#010+
-  '        $(INSTALLEXE) $(EXEFILES) $(BININSTALLDIR)'#010+
+  '        -$(UPXPROG) $(INSTALLEXEFILES)',#010+
   'endif'#010+
-  'endif'#010+
-  'ifdef LOADEROBJECTS'#010+
-  '        $(MKDIR) $(UNITINSTALLDIR)'#010+
-  '        $(INSTALL) $(LOADEROFILES) $(UNITINSTALLDI','R)'#010+
+  '        $(INSTALLEXE) $(INSTALLEXEFILES) $(BININSTALLDIR)'#010+
   'endif'#010+
   'ifdef INSTALLPPUFILES'#010+
   '        $(MKDIR) $(UNITINSTALLDIR)'#010+
   '        $(INSTALL) $(INSTALLPPUFILES) $(UNITINSTALLDIR)'#010+
   'ifneq ($(INSTALLPPULINKFILES),)'#010+
-  '        $(INSTALL) $(INSTALLPPULINKFILES) $(UNITINSTALLDIR)'#010+
+  '        $(INSTALL) $(INS','TALLPPULINKFILES) $(UNITINSTALLDIR)'#010+
   'endif'#010+
-  'ifneq ($(INSTALLPPUL','IBFILES),)'#010+
+  'ifneq ($(INSTALLPPULIBFILES),)'#010+
   '        $(MKDIR) $(LIBINSTALLDIR)'#010+
   '        $(INSTALL) $(INSTALLPPULIBFILES) $(LIBINSTALLDIR)'#010+
   'endif'#010+
   'endif'#010+
   'ifdef EXTRAINSTALLFILES'#010+
   '        $(MKDIR) $(EXTRAINSTALLDIR)'#010+
-  '        $(INSTALL) $(EXTRAINSTALLFILES) $(EXTRAINSTALLDIR)'#010+
-  'endif'#010,
+  '   ','     $(INSTALL) $(EXTRAINSTALLFILES) $(EXTRAINSTALLDIR)'#010+
+  'endif'#010+
   #010+
   #010+
   '[zipinstallrules]'#010+
@@ -874,9 +931,9 @@ const fpcmakeini : array[0..93,1..240] of char=(
   '# Zip'#010+
   '#####################################################################'#010+
   #010+
-  '.PHONY: fpc_zipinstall fpc_zipinstalladd'#010+
+  '.PHONY: fpc','_zipinstall fpc_zipinstalladd'#010+
   #010+
-  '# Temporary path to pack a file',#010+
+  '# Temporary path to pack a file'#010+
   'ifndef PACKDIR'#010+
   'ifndef inlinux'#010+
   'PACKDIR=pack_tmp'#010+
@@ -890,10 +947,10 @@ const fpcmakeini : array[0..93,1..240] of char=(
   'PACKAGEDIR=$(BASEDIR)'#010+
   'endif'#010+
   #010+
-  '# Add .zip/.tar.gz extension'#010+
+  '# Add .zip/.ta','r.gz extension'#010+
   'ifdef ZIPNAME'#010+
   'ifndef inlinux'#010+
-  'override ZIPNAME:=','$(ZIPNAME)$(ZIPEXT)'#010+
+  'override ZIPNAME:=$(ZIPNAME)$(ZIPEXT)'#010+
   'endif'#010+
   'endif'#010+
   #010+
@@ -903,17 +960,17 @@ const fpcmakeini : array[0..93,1..240] of char=(
   'endif'#010+
   #010+
   '# Note: This will not remove the zipfile first'#010+
-  'fpc_zipinstalladd:'#010+
+  'fpc_zipins','talladd:'#010+
   'ifndef ZIPNAME'#010+
-  '        @$(ECHO) Please specify ZIPNAM','E!'#010+
+  '        @$(ECHO) Please specify ZIPNAME!'#010+
   '        @exit'#010+
   'else'#010+
   '        $(MAKE) $(ZIPTARGET) PREFIXINSTALLDIR=$(PACKDIR)'#010+
   'ifdef inlinux'#010+
   '        gzip -d $(PACKAGEDIR)/$(ZIPNAME).tar.gz'#010+
-  '        cd $(PACKDIR) ; tar rv --file $(PACKAGEDIR)/$(ZIPNAME).tar * ;'+
-  ' cd $(BASEDIR)'#010+
-  '        gzip $','(PACKAGEDIR)/$(ZIPNAME).tar'#010+
+  '        cd $(PACKDIR) ; tar rv --file',' $(PACKAGEDIR)/$(ZIPNAME).tar *'+
+  ' ; cd $(BASEDIR)'#010+
+  '        gzip $(PACKAGEDIR)/$(ZIPNAME).tar'#010+
   'else'#010+
   '        cd $(PACKDIR) ; $(ZIPPROG) $(PACKAGEDIR)/$(ZIPNAME) * ; cd $(B'+
   'ASEDIR)'#010+
@@ -921,17 +978,17 @@ const fpcmakeini : array[0..93,1..240] of char=(
   '        $(DELTREE) $(PACKDIR)'#010+
   'endif'#010+
   #010+
-  '# First remove the zip and then install'#010+
+  '# First remove the zip a','nd then install'#010+
   'fpc_zipinstall:'#010+
   'ifndef ZIPNAME'#010+
-  '        @$(ECHO',') Please specify ZIPNAME!'#010+
+  '        @$(ECHO) Please specify ZIPNAME!'#010+
   '        @exit'#010+
   'else'#010+
   '        $(DEL) $(PACKAGEDIR)/$(ZIPNAME)'#010+
   '        $(MAKE) $(ZIPTARGET) PREFIXINSTALLDIR=$(PACKDIR)'#010+
   'ifdef inlinux'#010+
-  '        cd $(PACKDIR) ; tar cvz --file $(PACKAGEDIR)/$(ZIPNAME).tar.gz'+
-  ' * ; cd $(BASE','DIR)'#010+
+  '        cd $(PACKDIR) ','; tar cvz --file $(PACKAGEDIR)/$(ZIPNAME).tar.'+
+  'gz * ; cd $(BASEDIR)'#010+
   'else'#010+
   '        cd $(PACKDIR) ; $(ZIPPROG) $(PACKAGEDIR)/$(ZIPNAME) * ; cd $(B'+
   'ASEDIR)'#010+
@@ -941,32 +998,32 @@ const fpcmakeini : array[0..93,1..240] of char=(
   #010+
   #010+
   '[cleanrules]'#010+
-  '#####################################################################'#010+
-  '# Clean rules'#010+
-  '###########','#########################################################'+
+  '#################################','###################################'+
   '#'#010+
+  '# Clean rules'#010+
+  '#####################################################################'#010+
   #010+
   '.PHONY: fpc_clean fpc_cleanall'#010+
   #010+
-  'ifdef UNITPPUFILES'#010+
-  'override CLEANPPUFILES=$(UNITPPUFILES)'#010+
-  'endif'#010+
   'ifdef EXTRACLEANUNITS'#010+
-  'override CLEANPPUFILES+=$(addsuffix $(PPUEXT),$(EXTRACLEANUNIT','S))'#010+
+  'override CLEANPPUFILES+=$(addsuffix $(PPUEXT),$(EXTRACLEANUNITS)',')'#010+
   'endif'#010+
   #010+
-  'fpc_clean:'#010+
-  'ifdef EXEOBJECTS'#010+
-  '        -$(DEL) $(EXEFILES) $(EXEOFILES)'#010+
+  'ifdef CLEANPPUFILES'#010+
+  'ifdef PPUFILES'#010+
+  'CLEANPPULINKFILES=$(shell $(PPUFILES) $(CLEANPPUFILES))'#010+
   'endif'#010+
-  'ifdef LOADEROBJECTS'#010+
-  '        -$(DEL) $(LOADEROFILES)'#010+
+  'endif'#010+
+  #010+
+  'fpc_clean: $(CLEANTARGET)'#010+
+  'ifdef CLEANEXEFILES'#010+
+  '        -$(DEL) $(CLEANEXEFILES)'#010+
   'endif'#010+
   'ifdef CLEANPPUFILES'#010+
-  '        -$(DEL) $(CLEANPPUFILES)'#010+
-  'ifdef PPUFILES'#010+
-  '        -$(DEL) $(shell $(PP','UFILES) $(CLEANPPUFILES))'#010+
+  '        -$(DEL) $(CLEA','NPPUFILES)'#010+
   'endif'#010+
+  'ifneq ($(CLEANPPULINKFILES),)'#010+
+  '        -$(DEL) $(CLEANPPULINKFILES)'#010+
   'endif'#010+
   'ifdef EXTRACLEANFILES'#010+
   '        -$(DEL) $(EXTRACLEANFILES)'#010+
@@ -974,20 +1031,20 @@ const fpcmakeini : array[0..93,1..240] of char=(
   '        -$(DEL) $(PPAS) link.res log'#010+
   #010+
   'fpc_cleanall:'#010+
-  'ifdef EXEOBJECTS'#010+
-  '        -$(DEL) $(EXEFILES)'#010+
+  'ifdef CLEANEXEFILES'#010+
+  '        -$(DEL)',' $(CLEANEXEFILES)'#010+
   'endif'#010+
-  '        -$(DEL) *$(OEXT) *$(PPUEXT) ','*$(ASMEXT) *$(STATICLIBEXT) *$(S'+
-  'HAREDLIBEXT) *$(PPLEXT)'#010+
+  '        -$(DEL) *$(OEXT) *$(PPUEXT) *$(ASMEXT) *$(STATICLIBEXT) *$(SHA'+
+  'REDLIBEXT) *$(PPLEXT)'#010+
   '        -$(DELTREE) *$(SMARTEXT)'#010+
   '        -$(DEL) $(PPAS) link.res log'#010+
   #010+
   #010+
   '[dependrules]'#010+
-  '#####################################################################'#010+
-  '# Depend rules'#010+
-  '#############','#######################################################'+
+  '######################################','##############################'+
   '#'#010+
+  '# Depend rules'#010+
+  '#####################################################################'#010+
   #010+
   '.PHONY: fpc_depend'#010+
   #010+
@@ -996,10 +1053,10 @@ const fpcmakeini : array[0..93,1..240] of char=(
   #010+
   #010+
   '[inforules]'#010+
-  '#####################################################################'#010+
-  '# Info rules'#010+
-  '#####################','###############################################'+
+  '############################################','########################'+
   '#'#010+
+  '# Info rules'#010+
+  '#####################################################################'#010+
   #010+
   '.PHONY: fpc_info fpc_cfginfo fpc_objectinfo fpc_toolsinfo fpc_installi'+
   'nfo \'#010+
@@ -1007,17 +1064,17 @@ const fpcmakeini : array[0..93,1..240] of char=(
   #010+
   'fpc_info: $(FPCINFO)'#010+
   #010+
-  '[info_cfg]'#010+
+  '[info_cfg]'#010,
   'fpc_infocfg:'#010+
   '        @$(ECHO)'#010+
-  '        @$(ECHO)  == Configura','tion info =='#010+
+  '        @$(ECHO)  == Configuration info =='#010+
   '        @$(ECHO)'#010+
   '        @$(ECHO)  FPC....... $(FPC)'#010+
   '        @$(ECHO)  Version... $(FPC_VERSION)'#010+
   '        @$(ECHO)  CPU....... $(CPU_TARGET)'#010+
-  '        @$(ECHO)  Source.... $(OS_SOURCE)'#010+
+  '        @$(ECHO)  Source...','. $(OS_SOURCE)'#010+
   '        @$(ECHO)  Target.... $(OS_TARGET)'#010+
-  '   ','     @$(ECHO)'#010+
+  '        @$(ECHO)'#010+
   #010+
   '[info_dirs]'#010+
   'fpc_infodirs:'#010+
@@ -1026,30 +1083,30 @@ const fpcmakeini : array[0..93,1..240] of char=(
   '        @$(ECHO)  == Directory info =='#010+
   '        @$(ECHO)'#010+
   'ifdef NEEDGCCLIB'#010+
-  '        @$(ECHO)  GCC library is needed.'#010+
+  '        @$(ECHO)  GCC library is ne','eded.'#010+
   'endif'#010+
   'ifdef NEEDOTHERLIB'#010+
-  '        @$(ECHO)  Other libra','ry is needed.'#010+
+  '        @$(ECHO)  Other library is needed.'#010+
   'endif'#010+
   '        @$(ECHO)  Basedir......... $(BASEDIR)'#010+
   '        @$(ECHO)'#010+
   '        @$(ECHO)  GCC library..... $(GCCLIBDIR)'#010+
-  '        @$(ECHO)  Other library... $(OTHERLIBDIR)'#010+
+  '        @$(ECHO)  Other library... $(OTHERLIBDIR)',#010+
   '        @$(ECHO)'#010+
   'endif'#010+
   #010+
   '[info_tools]'#010+
   'fpc_infotools:'#010+
-  '       ',' @$(ECHO)'#010+
+  '        @$(ECHO)'#010+
   '        @$(ECHO)  == Tools info =='#010+
   '        @$(ECHO)'#010+
   '        @$(ECHO)  Pwd....... $(PWD)'#010+
   '        @$(ECHO)  Echo...... $(ECHO)'#010+
   'ifdef PPDEP'#010+
-  '        @$(ECHO)  PPDep..... $(PPDEP)'#010+
+  '        @$(ECHO)  PPDep..... $(PP','DEP)'#010+
   'endif'#010+
   'ifdef PPUMOVE'#010+
-  '        @$(ECHO)  PPUMove... $(PPUM','OVE)'#010+
+  '        @$(ECHO)  PPUMove... $(PPUMOVE)'#010+
   'endif'#010+
   'ifdef PPUFILES'#010+
   '        @$(ECHO)  PPUFiles.. $(PPUFILES)'#010+
@@ -1058,11 +1115,11 @@ const fpcmakeini : array[0..93,1..240] of char=(
   '        @$(ECHO)  Data2Inc.. $(DATA2INC)'#010+
   'endif'#010+
   'ifdef SED'#010+
-  '        @$(ECHO)  Sed....... $(SED)'#010+
+  '        @$(ECHO)  Sed....... $(SED)',#010+
   'endif'#010+
   'ifdef DATE'#010+
   '        @$(ECHO)  Date...... $(DATE)'#010+
-  'endif',#010+
+  'endif'#010+
   'ifdef DIFF'#010+
   '        @$(ECHO)  Diff...... $(DIFF)'#010+
   'endif'#010+
@@ -1072,10 +1129,10 @@ const fpcmakeini : array[0..93,1..240] of char=(
   'ifdef UPXPROG'#010+
   '        @$(ECHO)  Upx....... $(UPXPROG)'#010+
   'endif'#010+
-  'ifdef ZIPPROG'#010+
+  'ifdef ZIPPROG',#010+
   '        @$(ECHO)  Zip....... $(ZIPPROG)'#010+
   'endif'#010+
-  '        @$(EC','HO)'#010+
+  '        @$(ECHO)'#010+
   #010+
   '[info_objects]'#010+
   'fpc_infoobjects:'#010+
@@ -1083,14 +1140,14 @@ const fpcmakeini : array[0..93,1..240] of char=(
   '        @$(ECHO)  == Object info =='#010+
   '        @$(ECHO)'#010+
   '        @$(ECHO)  LoaderObjects..... $(LOADEROBJECTS)'#010+
-  '        @$(ECHO)  UnitObjects....... $(UNITOBJECTS)'#010+
-  '        @$(ECHO)  ExeObject','s........ $(EXEOBJECTS)'#010+
+  '        @$(ECHO)  U','nitObjects....... $(UNITOBJECTS)'#010+
+  '        @$(ECHO)  ExeObjects........ $(EXEOBJECTS)'#010+
   '        @$(ECHO)'#010+
   '        @$(ECHO)  ExtraCleanUnits... $(EXTRACLEANUNITS)'#010+
   '        @$(ECHO)  ExtraCleanFiles... $(EXTRACLEANFILES)'#010+
   '        @$(ECHO)'#010+
-  '        @$(ECHO)  ExtraInstallUnits. $(EXTRAINSTALLUNITS)'#010+
-  '        @$(E','CHO)  ExtraInstallFiles. $(EXTRAINSTALLFILES)'#010+
+  '        @$','(ECHO)  ExtraInstallUnits. $(EXTRAINSTALLUNITS)'#010+
+  '        @$(ECHO)  ExtraInstallFiles. $(EXTRAINSTALLFILES)'#010+
   '        @$(ECHO)'#010+
   #010+
   '[info_install]'#010+
@@ -1099,30 +1156,35 @@ const fpcmakeini : array[0..93,1..240] of char=(
   '        @$(ECHO)  == Install info =='#010+
   '        @$(ECHO)'#010+
   'ifdef DATE'#010+
-  '        @$(ECHO)  DateStr.............. $(DATESTR)'#010+
+  '  ','      @$(ECHO)  DateStr.............. $(DATESTR)'#010+
   'endif'#010+
-  '     ','   @$(ECHO)  PackageSuffix........ $(PACKAGESUFFIX)'#010+
+  '        @$(ECHO)  PackageSuffix........ $(PACKAGESUFFIX)'#010+
   '        @$(ECHO)'#010+
   '        @$(ECHO)  BaseInstallDir....... $(BASEINSTALLDIR)'#010+
-  '        @$(ECHO)  BinInstallDir........ $(BININSTALLDIR)'#010+
-  '        @$(ECHO)  LibInstallDir........ $(LIBINSTALLDIR)',#010+
+  '        @$(ECHO)  BinInstallDir........ $(BININSTALLD','IR)'#010+
+  '        @$(ECHO)  LibInstallDir........ $(LIBINSTALLDIR)'#010+
   '        @$(ECHO)  UnitInstallDir....... $(UNITINSTALLDIR)'#010+
   '        @$(ECHO)  SourceInstallDir..... $(SOURCEINSTALLDIR)'#010+
   '        @$(ECHO)  DocInstallDir........ $(DOCINSTALLDIR)'#010+
-  '        @$(ECHO)  ExtraInstallDir...... $(EXTRAINSTALLDIR)'#010+
-  '     ','   @$(ECHO)'#010+
+  '    ','    @$(ECHO)  ExtraInstallDir...... $(EXTRAINSTALLDIR)'#010+
+  '        @$(ECHO)'#010+
   #010+
   '[userrules]'#010+
   '#####################################################################'#010+
   '# Users rules'#010+
   '#####################################################################'#010+
-  #010+
+  #010,
+  '[end]'#010+
   ';'#010+
   '; $Log$
-  '; Revision 1.1  1999-11-23 09:43:35  peter
-  ';   + internal .ini file
-  ';   + packages support
-  ';   * ppufiles,data2inc support
+  '; Revision 1.2  1999-11-24 23:53:00  peter
+  ';   * packages
+  ';   * lot of other changes
+  ';'#010+
+  '; Revision 1.7  1999/11/23 09:43:35  peter'#010+
+  ';   + internal .ini file'#010+
+  ';   + packages support'#010+
+  ';   * ppufiles,data2inc support'#010+
   ';'#010+
   ';'#010
 );

+ 115 - 60
utils/fpcmake.ini

@@ -304,13 +304,17 @@ ifdef UNITTARGETDIR
 override FPCOPT+=-FU$(UNITTARGETDIR)
 endif
 
-[command_smartlink]
+[command_end]
 # Smartlinking
 ifdef SMARTLINK
 override FPCOPT+=-CX
 endif
 
-[command_end]
+# Debug
+ifdef DEBUG
+override FPCOPT+=-g
+endif
+
 # Add commandline options
 ifdef OPT
 override FPCOPT+=$(OPT)
@@ -670,45 +674,108 @@ endif
 # Default rules
 #####################################################################
 
-.PHONY: defaultrule all smart shared \
+.PHONY: defaultrule all debug examples test smart shared \
         showinstall install zipinstall zipinstalladd \
         clean cleanall depend info
 
 
-[compilerules]
+[loaderrules]
 #####################################################################
-# General compile rules
+# Loaders
 #####################################################################
 
-.PHONY: fpc_all fpc_units fpc_exes fpc_loaders
+.PHONY: fpc_loaders
 
-# Create Filenames
-ifdef LOADEROBJECTS
-LOADEROFILES=$(addsuffix $(OEXT),$(LOADEROBJECTS))
-endif
-ifdef EXEOBJECTS
-EXEFILES=$(addsuffix $(EXEEXT),$(EXEOBJECTS))
-EXEOFILES=$(addsuffix $(OEXT),$(EXEOBJECTS))
-endif
-ifdef UNITOBJECTS
-UNITPPUFILES=$(addsuffix $(PPUEXT),$(UNITOBJECTS))
-endif
+%$(OEXT): %$(LOADEREXT)
+        $(AS) -o $*$(OEXT) $<
 
-.SUFFIXES: $(EXEEXT) $(PPUEXT) $(OEXT) .pas .pp
+override ALLTARGET+=fpc_loaders
+override CLEANTARGET+=fpc_loaders_clean
+override SHOWINSTALLTARGET+=fpc_loaders_showinstall
+override INSTALLTARGET+=fpc_loaders_install
 
-ifdef DEFAULTUNITS
-fpc_all: fpc_loaders fpc_units
-else
-fpc_all: fpc_loaders fpc_units fpc_exes
-endif
+LOADEROFILES=$(addsuffix $(OEXT),$(LOADEROBJECTS))
 
 fpc_loaders: $(LOADEROFILES)
 
+fpc_loaders_clean:
+        -$(DEL) $(LOADEROFILES)
+
+fpc_loaders_showinstall:
+        @$(ECHO) $(addprefix "\n"$(UNITINSTALLDIR)/,$(LOADEROFILES))
+
+fpc_loaders_install:
+        $(MKDIR) $(UNITINSTALLDIR)
+        $(INSTALL) $(LOADEROFILES) $(UNITINSTALLDIR)
+
+
+[unitrules]
+#####################################################################
+# Units
+#####################################################################
+
+.PHONY: fpc_units
+
+override ALLTARGET+=fpc_units
+
+UNITPPUFILES=$(addsuffix $(PPUEXT),$(UNITOBJECTS))
+override INSTALLPPUFILES+=$(UNITPPUFILES)
+override CLEANPPUFILES+=$(UNITPPUFILES)
+
 fpc_units: $(UNITPPUFILES)
 
+
+
+[exerules]
+#####################################################################
+# Exes
+#####################################################################
+
+.PHONY: fpc_exes
+
+EXEFILES=$(addsuffix $(EXEEXT),$(EXEOBJECTS))
+EXEOFILES=$(addsuffix $(OEXT),$(EXEOBJECTS))
+
+override ALLTARGET+=fpc_exes
+override INSTALLEXEFILES+=$(EXEFILES)
+override CLEANEXEFILES+=$(EXEFILES) $(EXEOFILES)
+
 fpc_exes: $(EXEFILES)
 
+
+[examplerules]
+#####################################################################
+# Examples
+#####################################################################
+
+.PHONY: fpc_examples fpc_test
+
+EXAMPLEFILES=$(addsuffix $(EXEEXT),$(EXAMPLEOBJECTS))
+EXAMPLEOFILES=$(addsuffix $(OEXT),$(EXAMPLEOBJECTS))
+
+override CLEANEXEFILES+=$(EXAMPLEFILES) $(EXAMPLEOFILES)
+
+fpc_examples: all $(EXAMPLEFILES)
+
+fpc_test: examples
+
+
+[compilerules]
+#####################################################################
+# General compile rules
+#####################################################################
+
+.PHONY: fpc_all fpc_debug
+
+fpc_all: $(ALLTARGET)
+
+fpc_debug:
+        $(MAKE) all DEBUG=1
+
 # General compile rules, available for both possible PASEXT
+
+.SUFFIXES: $(EXEEXT) $(PPUEXT) $(OEXT) .pas .pp
+
 %$(PPUEXT): %.pp
         $(COMPILER) $< $(REDIR)
         $(EXECPASS)
@@ -725,9 +792,6 @@ fpc_exes: $(EXEFILES)
         $(COMPILER) $< $(REDIR)
         $(EXECPASS)
 
-%$(OEXT): %$(LOADEREXT)
-        $(AS) -o $*$(OEXT) $<
-
 
 [libraryrules]
 #####################################################################
@@ -763,9 +827,6 @@ endif
 
 .PHONY: fpc_showinstall fpc_install
 
-ifdef UNITPPUFILES
-override INSTALLPPUFILES:=$(UNITPPUFILES)
-endif
 ifdef EXTRAINSTALLUNITS
 override INSTALLPPUFILES+=$(addsuffix $(PPUEXT),$(EXTRAINSTALLUNITS))
 endif
@@ -781,14 +842,9 @@ endif
 endif
 endif
 
-fpc_showinstall:
-ifndef DEFAULTUNITS
-ifdef EXEOBJECTS
-        @$(ECHO) $(addprefix "\n"$(BININSTALLDIR)/,$(EXEFILES))
-endif
-endif
-ifdef LOADEROBJECTS
-        @$(ECHO) $(addprefix "\n"$(UNITINSTALLDIR)/,$(LOADEROFILES))
+fpc_showinstall: $(SHOWINSTALLTARGET)
+ifdef INSTALLEXEFILES
+        @$(ECHO) $(addprefix "\n"$(BININSTALLDIR)/,$(INSTALLEXEFILES))
 endif
 ifdef INSTALLPPUFILES
         @$(ECHO) $(addprefix "\n"$(UNITINSTALLDIR)/,$(INSTALLPPUFILES))
@@ -803,21 +859,15 @@ ifdef EXTRAINSTALLFILES
         @$(ECHO) $(addprefix "\n"$(EXTRAINSTALLDIR)/,$(EXTRAINSTALLFILES))
 endif
 
-fpc_install:
+fpc_install: $(INSTALLTARGET)
 # Create UnitInstallFiles
-ifndef DEFAULTUNITS
-ifdef EXEOBJECTS
+ifdef INSTALLEXEFILES
         $(MKDIR) $(BININSTALLDIR)
 # Compress the exes if upx is defined
 ifdef UPXPROG
-        -$(UPXPROG) $(EXEFILES)
-endif
-        $(INSTALLEXE) $(EXEFILES) $(BININSTALLDIR)
+        -$(UPXPROG) $(INSTALLEXEFILES)
 endif
-endif
-ifdef LOADEROBJECTS
-        $(MKDIR) $(UNITINSTALLDIR)
-        $(INSTALL) $(LOADEROFILES) $(UNITINSTALLDIR)
+        $(INSTALLEXE) $(INSTALLEXEFILES) $(BININSTALLDIR)
 endif
 ifdef INSTALLPPUFILES
         $(MKDIR) $(UNITINSTALLDIR)
@@ -910,25 +960,25 @@ endif
 
 .PHONY: fpc_clean fpc_cleanall
 
-ifdef UNITPPUFILES
-override CLEANPPUFILES=$(UNITPPUFILES)
-endif
 ifdef EXTRACLEANUNITS
 override CLEANPPUFILES+=$(addsuffix $(PPUEXT),$(EXTRACLEANUNITS))
 endif
 
-fpc_clean:
-ifdef EXEOBJECTS
-        -$(DEL) $(EXEFILES) $(EXEOFILES)
+ifdef CLEANPPUFILES
+ifdef PPUFILES
+CLEANPPULINKFILES=$(shell $(PPUFILES) $(CLEANPPUFILES))
 endif
-ifdef LOADEROBJECTS
-        -$(DEL) $(LOADEROFILES)
+endif
+
+fpc_clean: $(CLEANTARGET)
+ifdef CLEANEXEFILES
+        -$(DEL) $(CLEANEXEFILES)
 endif
 ifdef CLEANPPUFILES
         -$(DEL) $(CLEANPPUFILES)
-ifdef PPUFILES
-        -$(DEL) $(shell $(PPUFILES) $(CLEANPPUFILES))
 endif
+ifneq ($(CLEANPPULINKFILES),)
+        -$(DEL) $(CLEANPPULINKFILES)
 endif
 ifdef EXTRACLEANFILES
         -$(DEL) $(EXTRACLEANFILES)
@@ -936,8 +986,8 @@ endif
         -$(DEL) $(PPAS) link.res log
 
 fpc_cleanall:
-ifdef EXEOBJECTS
-        -$(DEL) $(EXEFILES)
+ifdef CLEANEXEFILES
+        -$(DEL) $(CLEANEXEFILES)
 endif
         -$(DEL) *$(OEXT) *$(PPUEXT) *$(ASMEXT) *$(STATICLIBEXT) *$(SHAREDLIBEXT) *$(PPLEXT)
         -$(DELTREE) *$(SMARTEXT)
@@ -1075,9 +1125,14 @@ endif
 # Users rules
 #####################################################################
 
+[end]
 ;
 ; $Log$
-; Revision 1.7  1999-11-23 09:43:35  peter
+; Revision 1.8  1999-11-24 23:53:00  peter
+;   * packages
+;   * lot of other changes
+;
+; Revision 1.7  1999/11/23 09:43:35  peter
 ;   + internal .ini file
 ;   + packages support
 ;   * ppufiles,data2inc support

+ 238 - 154
utils/fpcmake.pp

@@ -22,44 +22,84 @@ uses
   dos,
   sysutils,classes,inifiles;
 
-{ Include default fpcmake.ini }
-{$i fpcmake.inc}
-
 const
   Version='v0.99.13';
   Title='fpcmake '+Version;
 
+{ Include default fpcmake.ini }
+{$i fpcmake.inc}
+
+type
+  tsections=(sec_none,
+    sec_units,sec_exes,sec_loaders,sec_examples,
+    sec_compile,sec_depend,sec_install,sec_zipinstall,
+    sec_clean,sec_libs,sec_command,sec_exts,sec_dirs,sec_tools,sec_info
+  );
+
+const
   EnvVar='FPCMAKEINI'; { should be FPCMAKE in the future }
   TimeFormat='yyyy/mm/dd hh:nn';
 
+  sectionstr : array[tsections] of string=('none',
+    'units','exes','loaders','examples',
+    'compile','depend','install','zipinstall',
+    'clean','libs','command','exts','dirs','tools','info'
+  );
+
+  sectiondef : array[tsections] of boolean=(false,
+    true,true,false,false,
+    true,false,true,true,
+    true,true,true,true,true,true,true
+  );
+
   targets=4;
   targetstr : array[1..targets] of string=(
     'linux','go32v2','win32','os2'
   );
 
+  rules=14;
+  rulestr : array[1..rules] of string=(
+    'all','debug',
+    'examples','test',
+    'smart','shared',
+    'showinstall','install','zipinstall','zipinstalladd',
+    'clean','cleanall',
+    'depend','info'
+  );
+
+  rule2sec : array[1..rules] of tsections=(
+    sec_compile,sec_compile,
+    sec_examples,sec_examples,
+    sec_libs,sec_libs,
+    sec_install,sec_install,sec_zipinstall,sec_zipinstall,
+    sec_clean,sec_clean,
+    sec_depend,sec_info
+  );
+
 { Sections in Makefile.fpc }
-  sec_sections='sections';
-  sec_install='install';
-  sec_clean='clean';
-  sec_dirs='dirs';
-  sec_packages='packages';
-  sec_libs='libs';
-  sec_targets='targets';
-  sec_info='info';
-  sec_defaults='defaults';
-  sec_tools='tools';
+  ini_sections='sections';
+  ini_install='install';
+  ini_clean='clean';
+  ini_dirs='dirs';
+  ini_packages='packages';
+  ini_libs='libs';
+  ini_targets='targets';
+  ini_info='info';
+  ini_defaults='defaults';
+  ini_tools='tools';
 
 type
   TTargetsString=array[0..targets] of string;
   TFpcMake=record
+    TargetDirs,
     TargetLoaders,
     TargetUnits,
     TargetPrograms,
+    TargetExamples,
     InstallUnits,
     InstallFiles,
     CleanUnits,
     CleanFiles     : TTargetsString;
-    DefaultUnits   : boolean;
     DefaultRule,
     DefaultTarget,
     DefaultCPU,
@@ -71,6 +111,7 @@ type
     DirObj,
     DirTarget,
     DirUnitTarget,
+    DirSources,
     DirInc         : string;
     PackageFCL     : boolean;
     Packages       : string;
@@ -83,18 +124,7 @@ type
     InfoTools,
     InfoInstall,
     InfoObjects    : boolean;
-    SectionNone,
-    SectionCompile,
-    SectionDepend,
-    SectionInstall,
-    SectionZipInstall,
-    SectionClean,
-    SectionLibs,
-    SectionCommand,
-    SectionExts,
-    SectionDirs,
-    SectionTools,
-    SectionInfo    : boolean;
+    Section        : array[tsections] of boolean;
     ToolsPPDep,
     ToolsPPUMove,
     ToolsPPUFiles,
@@ -138,6 +168,20 @@ begin
 end;
 
 
+function TargetStringEmpty(const t:TTargetsString):boolean;
+var
+  i : integer;
+begin
+  for i:=0 to targets do
+   if t[i]<>'' then
+    begin
+      TargetStringEmpty:=false;
+      exit;
+    end;
+  TargetStringEmpty:=true;
+end;
+
+
 {*****************************************************************************
                                   TMyMemoryStream
 *****************************************************************************}
@@ -167,6 +211,8 @@ var
      t[i]:=ini.ReadString(sec,name+'_'+targetstr[i],'');
   end;
 
+var
+  sec : tsections;
 begin
   ReadMakefilefpc:=false;
   if FileExists('Makefile.fpc') then
@@ -183,82 +229,74 @@ begin
   with userini,ini do
    begin
    { targets }
-     ReadTargetsString(TargetLoaders,sec_targets,'loaders','');
-     ReadTargetsString(TargetUnits,sec_targets,'units','');
-     ReadTargetsString(TargetPrograms,sec_targets,'programs','');
+     ReadTargetsString(TargetDirs,ini_targets,'dirs','');
+     ReadTargetsString(TargetLoaders,ini_targets,'loaders','');
+     ReadTargetsString(TargetUnits,ini_targets,'units','');
+     ReadTargetsString(TargetPrograms,ini_targets,'programs','');
+     ReadTargetsString(TargetExamples,ini_targets,'examples','');
    { clean }
-     ReadTargetsString(CleanUnits,sec_clean,'units','');
-     ReadTargetsString(CleanFiles,sec_clean,'files','');
+     ReadTargetsString(CleanUnits,ini_clean,'units','');
+     ReadTargetsString(CleanFiles,ini_clean,'files','');
    { install }
-     ReadTargetsString(InstallUnits,sec_install,'units','');
-     ReadTargetsString(InstallFiles,sec_install,'files','');
+     ReadTargetsString(InstallUnits,ini_install,'units','');
+     ReadTargetsString(InstallFiles,ini_install,'files','');
    { 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','');
+     DefaultRule:=ReadString(ini_defaults,'defaultrule','all');
+     DefaultTarget:=ReadString(ini_defaults,'defaulttarget','');
+     DefaultCPU:=ReadString(ini_defaults,'defaultcpu','');
+     DefaultOptions:=ReadString(ini_defaults,'defaultoptions','');
    { packages }
-     Packages:=Readstring(sec_packages,'packages','');
-     PackageFCL:=ReadBool(sec_packages,'fcl',false);
+     Packages:=Readstring(ini_packages,'packages','');
+     PackageFCL:=ReadBool(ini_packages,'fcl',false);
    { dirs }
-     DirFpc:=ReadString(sec_dirs,'fpcdir','');
-     DirPackage:=ReadString(sec_dirs,'packagedir','$(FPCDIR)/packages');
-     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','');
+     DirFpc:=ReadString(ini_dirs,'fpcdir','');
+     DirPackage:=ReadString(ini_dirs,'packagedir','$(FPCDIR)/packages');
+     DirUnit:=ReadString(ini_dirs,'unitdir','');
+     DirLib:=ReadString(ini_dirs,'libdir','');
+     DirObj:=ReadString(ini_dirs,'objdir','');
+     DirTarget:=ReadString(ini_dirs,'targetdir','');
+     DirSources:=ReadString(ini_dirs,'sourcesdir','');
+     DirUnitTarget:=ReadString(ini_dirs,'unittargetdir','');
+     DirInc:=ReadString(ini_dirs,'incdir','');
    { libs }
-     LibName:=ReadString(sec_libs,'libname','');
-     LibUnits:=ReadString(sec_libs,'libunits','');
-     LibGcc:=ReadBool(sec_libs,'libgcc',false);
-     LibOther:=ReadBool(sec_libs,'libother',false);
+     LibName:=ReadString(ini_libs,'libname','');
+     LibUnits:=ReadString(ini_libs,'libunits','');
+     LibGcc:=ReadBool(ini_libs,'libgcc',false);
+     LibOther:=ReadBool(ini_libs,'libother',false);
    { tools }
-     ToolsPPDep:=ReadBool(sec_tools,'toolppdep',true);
-     ToolsPPUMove:=ReadBool(sec_tools,'toolppumove',true);
-     ToolsPPUFiles:=ReadBool(sec_tools,'toolppufiles',true);
-     ToolsSed:=ReadBool(sec_tools,'toolsed',false);
-     ToolsData2Inc:=ReadBool(sec_tools,'tooldata2inc',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);
-   { sections }
-     SectionInstall:=ReadBool(sec_sections,'install',true);
-     SectionZipInstall:=ReadBool(sec_sections,'zipinstall',true);
-     SectionClean:=ReadBool(sec_sections,'clean',true);
-     SectionInfo:=ReadBool(sec_sections,'info',true);
-     SectionTools:=ReadBool(sec_sections,'tools',true);
-     SectionLibs:=ReadBool(sec_sections,'libs',true);
-     SectionExts:=ReadBool(sec_sections,'exts',true);
-     SectionDirs:=ReadBool(sec_sections,'dirs',true);
-     SectionCompile:=ReadBool(sec_sections,'compile',true);
-     SectionDepend:=ReadBool(sec_sections,'depend',true);
-     SectionCommand:=ReadBool(sec_sections,'command',true);
-     SectionNone:=ReadBool(sec_sections,'none',false);
-     if SectionNone then
-      begin
-        SectionInstall:=false;
-        SectionZipInstall:=false;
-        SectionClean:=false;
-        SectionInfo:=false;
-        SectionTools:=false;
-        SectionLibs:=false;
-        SectionExts:=false;
-        SectionDirs:=false;
-        SectionCompile:=false;
-        SectionDepend:=false;
-        SectionCommand:=false;
-      end;
+     ToolsPPDep:=ReadBool(ini_tools,'toolppdep',true);
+     ToolsPPUMove:=ReadBool(ini_tools,'toolppumove',true);
+     ToolsPPUFiles:=ReadBool(ini_tools,'toolppufiles',true);
+     ToolsSed:=ReadBool(ini_tools,'toolsed',false);
+     ToolsData2Inc:=ReadBool(ini_tools,'tooldata2inc',false);
+     ToolsDiff:=ReadBool(ini_tools,'tooldiff',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
+      userini.section[sec_loaders]:=true;
+     if not TargetStringEmpty(TargetUnits) then
+      userini.section[sec_units]:=true;
+     if not TargetStringEmpty(TargetPrograms) then
+      userini.section[sec_exes]:=true;
+     if not TargetStringEmpty(TargetExamples) then
+      userini.section[sec_examples]:=true;
    { info }
-     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);
+     InfoCfg:=ReadBool(ini_info,'infoconfig',true);
+     InfoDirs:=ReadBool(ini_info,'infodirs',false);
+     InfoTools:=ReadBool(ini_info,'infotools',false);
+     InfoInstall:=ReadBool(ini_info,'infoinstall',true);
+     InfoObjects:=ReadBool(ini_info,'infoobjects',true);
    { rules }
      PreSettings:=TStringList.Create;
      ReadSectionRaw('presettings',PreSettings);
@@ -367,6 +405,13 @@ var
      end;
   end;
 
+  procedure AddHead(const s:string);
+  begin
+    mf.Add('');
+    mf.Add('# '+s);
+    mf.Add('');
+  end;
+
   procedure AddSection(b:boolean;s:string);
   begin
     if b then
@@ -378,48 +423,72 @@ var
      end;
   end;
 
-  procedure AddRule(s:string);
+  procedure AddRule(rule:integer);
   var
     i : integer;
+    hs : string;
   begin
     i:=0;
     while (i<userini.rules.Count) do
      begin
-       if (userini.rules[i]<>'') and
-          (userini.rules[i][1]=s[1]) and
-          (Copy(userini.rules[i],1,length(s))=s) then
+       if (length(userini.rules[i])>length(rulestr[rule])) and
+          (userini.rules[i][1]=rulestr[rule][1]) and
+	  ((userini.rules[i][length(rulestr[rule])+1]=':') or
+	   ((length(userini.rules[i])>length(rulestr[rule])+1) and
+	    (userini.rules[i][length(rulestr[rule])+2]=':'))) and
+          (Copy(userini.rules[i],1,length(rulestr[rule]))=rulestr[rule]) then
          exit;
        inc(i);
      end;
-    mf.Add(s+': fpc_'+s);
-    mf.Add('');
+    hs:='';
+    if userini.section[rule2sec[rule]] then
+     hs:=hs+' fpc_'+rulestr[rule];
+    if not TargetStringEmpty(userini.targetdirs) then
+     hs:=hs+' $(addsuffix _'+rulestr[rule]+',$(DIROBJECTS))';
+    if hs<>'' then
+     begin
+       mf.Add(rulestr[rule]+':'+hs);
+       mf.Add('');
+     end;
   end;
 
-  procedure AddTargets(const pre:string;var t:TTargetsString);
+  procedure AddTargets(const pre:string;var t:TTargetsString;wildcard:boolean);
   var
     i : integer;
   begin
-    if t[0]<>'' then
-     mf.Add(pre+'='+t[0]);
-    for i:=1to targets do
+    for i:=0 to targets do
      if (t[i]<>'') then
       begin
-        mf.Add('ifeq ($(OS_TARGET),'+targetstr[i]+')');
+        if i<>0 then
+         mf.Add('ifeq ($(OS_TARGET),'+targetstr[i]+')');
         if t[i]<>'' then
-         mf.Add(pre+'+='+t[i]);
-        mf.Add('endif');
+         begin
+           if wildcard then
+            mf.Add(pre+'+=$(wildcard '+t[i]+')')
+           else
+            mf.Add(pre+'+='+t[i]);
+         end;
+        if i<>0 then
+         mf.Add('endif');
       end;
   end;
 
-  procedure AddHead(const s:string);
+  procedure AddTargetDir(const s:string);
+  var
+    j : integer;
   begin
-    mf.Add('');
-    mf.Add('# '+s);
-    mf.Add('');
+    AddHead('Dir '+s);
+    for j:=1to rules do
+     begin
+       mf.Add(s+'_'+rulestr[j]+':');
+       mf.Add(#9+'$(MAKE) -C '+s+' '+rulestr[j]);
+       mf.Add('');
+     end;
   end;
 
 var
   hs : string;
+  i,j : integer;
 begin
 { Open the Makefile }
   Verbose('Creating Makefile');
@@ -465,29 +534,31 @@ begin
 
    { Targets }
      AddHead('Targets');
-     AddTargets('LOADEROBJECTS',userini.targetloaders);
-     AddTargets('UNITOBJECTS',userini.targetunits);
-     AddTargets('EXEOBJECTS',userini.targetprograms);
+     AddTargets('DIROBJECTS',userini.targetdirs,true);
+     AddTargets('LOADEROBJECTS',userini.targetloaders,false);
+     AddTargets('UNITOBJECTS',userini.targetunits,false);
+     AddTargets('EXEOBJECTS',userini.targetprograms,false);
+     AddTargets('EXAMPLEOBJECTS',userini.targetexamples,false);
 
    { Clean }
      AddHead('Clean');
-     AddTargets('EXTRACLEANUNITS',userini.cleanunits);
-     AddTargets('EXTRACLEANFILES',userini.cleanfiles);
+     AddTargets('EXTRACLEANUNITS',userini.cleanunits,false);
+     AddTargets('EXTRACLEANFILES',userini.cleanfiles,false);
 
    { Install }
      AddHead('Install');
-     AddTargets('EXTRAINSTALLUNITS',userini.installunits);
-     AddTargets('EXTRAINSTALLFILES',userini.installfiles);
+     AddTargets('EXTRAINSTALLUNITS',userini.installunits,false);
+     AddTargets('EXTRAINSTALLFILES',userini.installfiles,false);
 
    { Defaults }
      AddHead('Defaults');
-     if userini.defaultunits then
-      Add('DEFAULTUNITS=1');
      if userini.defaultoptions<>'' then
       Add('override NEEDOPT='+userini.defaultoptions);
 
    { Dirs }
      AddHead('Directories');
+     if userini.dirsources<>'' then
+      Add('vpath %$(PASEXT) '+userini.dirsources);
      if userini.dirfpc<>'' then
       begin
         { this dir can be set in the environment, it's more a default }
@@ -544,7 +615,7 @@ begin
       Add('override NEEDOTHERLIB=1');
 
    { Info }
-     if userini.SectionInfo then
+     if userini.Section[sec_Info] then
       begin
         AddHead('Info');
         hs:='';
@@ -571,7 +642,7 @@ begin
      Add('');
 
    { write dirs }
-     if userini.sectiondirs then
+     if userini.section[sec_dirs] then
       begin
         AddSection(true,'dir_default');
         AddSection(userini.libgcc,'dir_gcclib');
@@ -580,12 +651,11 @@ begin
       end;
 
    { commandline }
-     if userini.sectioncommand then
+     if userini.section[sec_command] then
       begin
         Add('');
         AddSection(true,'command_begin');
-        AddSection(true,'command_rtl');
-        AddSection(true,'command_needopt');
+        AddSection((userini.defaultoptions<>''),'command_needopt');
         AddSection((userini.dirfpc<>''),'command_fpcdir');
         AddSection((userini.dirunit<>'') or (userini.packages<>'') or (userini.packagefcl),'command_needunit');
         AddSection((userini.dirlib<>''),'command_needlib');
@@ -596,12 +666,11 @@ begin
         AddSection((userini.dirinc<>''),'command_inc');
         AddSection((userini.dirtarget<>''),'command_target');
         AddSection((userini.dirunittarget<>''),'command_unittarget');
-        AddSection(true,'command_smartlink');
         AddSection(true,'command_end');
       end;
 
    { write tools }
-     if userini.sectiontools then
+     if userini.section[sec_tools] then
       begin
         AddSection(true,'shelltools');
         AddSection(true,'tool_default');
@@ -618,37 +687,27 @@ begin
       end;
 
    { extensions }
-     if userini.sectionexts then
+     if userini.section[sec_exts] then
       AddSection(true,'extensions');
 
    { add default rules }
      AddSection(true,'defaultrules');
-     AddRule('all');
-     AddRule('smart');
-     AddRule('shared');
-     AddRule('showinstall');
-     AddRule('install');
-     AddRule('zipinstall');
-     AddRule('zipinstalladd');
-     AddRule('clean');
-     AddRule('clean_all');
-     AddRule('depend');
-     AddRule('info');
-
+     for i:=1 to rules do
+      AddRule(i);
+
+   { compile rules for making units/loaders/exes/examples }
+     AddSection(not TargetStringEmpty(userini.targetunits),'unitrules');
+     AddSection(not TargetStringEmpty(userini.targetprograms),'exerules');
+     AddSection(not TargetStringEmpty(userini.targetloaders),'loaderrules');
+     AddSection(not TargetStringEmpty(userini.targetexamples),'examplerules');
    { default fpc_ rules }
-     if userini.SectionCompile then
-      AddSection(true,'compilerules');
-     if userini.SectionLibs then
-      AddSection(true,'libraryrules');
-     if userini.SectionInstall then
-      AddSection(true,'installrules');
-     if userini.SectionZipInstall then
-      AddSection(true,'zipinstallrules');
-     if userini.SectionClean then
-      AddSection(true,'cleanrules');
-     if userini.SectionDepend then
-      AddSection(true,'dependrules');
-     if userini.SectionInfo then
+     AddSection(userini.Section[sec_Compile],'compilerules');
+     AddSection(userini.Section[sec_Libs],'libraryrules');
+     AddSection(userini.Section[sec_Install],'installrules');
+     AddSection(userini.Section[sec_ZipInstall],'zipinstallrules');
+     AddSection(userini.Section[sec_Clean],'cleanrules');
+     AddSection(userini.Section[sec_Depend],'dependrules');
+     if userini.Section[sec_Info] then
       begin
         AddSection(true,'inforules');
         AddSection(userini.infocfg,'info_cfg');
@@ -658,6 +717,27 @@ begin
         AddSection(userini.infoinstall,'info_install');
       end;
 
+   { Target dirs }
+     if not TargetStringEmpty(userini.targetdirs) then
+      begin
+        for j:=0 to targets do
+         if (userini.targetdirs[j]<>'') then
+          begin
+            if j<>0 then
+             mf.Add('ifeq ($(OS_TARGET),'+targetstr[j]+')');
+            hs:=userini.targetdirs[j];
+            repeat
+              i:=pos(' ',hs);
+              if i=0 then
+               i:=length(hs)+1;
+              AddTargetDir(Copy(hs,1,i-1));
+              system.delete(hs,1,i);
+            until hs='';
+            if j<>0 then
+             mf.Add('endif');
+          end;
+      end;
+
    { insert users rules }
      if userini.rules.count>0 then
       begin
@@ -694,7 +774,11 @@ begin
 end.
 {
   $Log$
-  Revision 1.7  1999-11-23 09:43:35  peter
+  Revision 1.8  1999-11-24 23:53:00  peter
+    * packages
+    * lot of other changes
+
+  Revision 1.7  1999/11/23 09:43:35  peter
     + internal .ini file
     + packages support
     * ppufiles,data2inc support