2
0
Эх сурвалжийг харах

* new makefile layout, much more structure and more uniformity

peter 27 жил өмнө
parent
commit
ff6ca07f9f
3 өөрчлөгдсөн 633 нэмэгдсэн , 356 устгасан
  1. 212 111
      rtl/dos/go32v1/makefile
  2. 228 135
      rtl/dos/go32v2/makefile
  3. 193 110
      rtl/linux/makefile

+ 212 - 111
rtl/dos/go32v1/makefile

@@ -1,7 +1,18 @@
-# Makefile for the DOS Go32v1 Run-time library.
-# we need the stupid copies and del because the old FPK Pascal doesn't handle
-# ppc386 ..\crt correct..
 #
+#   $Id$
+#   This file is part of the Free Pascal run time library.
+#   Copyright (c) 1996-98 by Michael van Canneyt
+#
+#   Makefile for the Free Pascal Go32v1 Runtime Library
+#
+#   See the file COPYING.FPC, included in this distribution,
+#   for details about the copyright.
+#
+#   This program is distributed in the hope that it will be useful,
+#   but WITHOUT ANY WARRANTY; without even the implied warranty of
+#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+#
+
 #####################################################################
 # Start of configurable section.
 # Please note that all these must be set in the main makefile, and
@@ -12,7 +23,7 @@
 
 # set the directory where to install the units.
 ifndef UNITINSTALLDIR
-UNITINSTALLDIR=c:\lib\ppc
+UNITINSTALLDIR=c:\lib\ppc\go32v1
 endif
 
 # set the directory where to install libraries
@@ -30,6 +41,12 @@ ifndef OS_TARGET
 OS_TARGET=GO32V1
 endif
 
+# What is the target processor :
+ifndef CPU
+CPU=i386
+#CPU=m68k
+endif
+
 # What compiler to use ?
 # I think ppc386 is better (it's mostly in path) (FK)
 ifndef PP
@@ -54,46 +71,48 @@ endif
 
 # Where are the include files
 INC=../../inc
-
-ifndef CPU
-CPU=i386
-endif
-
 PROCINC=../../$(CPU)
-
+OBJPASDIR=../../objpas
 # Where are the .ppi files.
 PPI=../ppi
 
-ifeq ($(OS_TARGET),$(OS_SRC))
-CROSSCOMPILE=NO
-else
-CROSSCOMPILE=YES
-endif
-
 # To copy pograms
 ifndef COPY
+ifeq ($(DOS),YES)
+COPY=copy
+else
 COPY=cp -p
 endif
+endif
 
-# To delete programs
+# Check delete program
 ifndef DEL
 ifeq ($(DOS),YES)
 DEL=del
 else
-DEL=rm
+DEL=rm -f
 endif
 endif
 
-# To install programs
+# To install files
 ifndef INSTALL
 ifeq ($(DOS),YES)
-INSTALL=cp
+INSTALL=copy
 else
 INSTALL=install -m 644
 endif
 endif
 
+# To install programs
+ifndef INSTALLEXE
+ifeq ($(DOS),YES)
+INSTALLEXE=copy
+else
+INSTALLEXE=install -m 755
+endif
+endif
 
+# To make a directory.
 ifndef MKDIR
 ifeq ($(DOS),YES)
 MKDIR=mkdir
@@ -102,20 +121,6 @@ MKDIR=install -m 755 -d
 endif
 endif
 
-# Check for crosscompile
-ifeq ($(CROSSCOMPILE),YES)
-OPT:=$(OPT) -dCROSSCOMPILE -T$(OS_TARGET)
-endif
-
-# check config file
-ifdef CFGFILE
-OPT:=$(OPT) @$(CFGFILE)
-endif
-
-# to be sure to be able to compile with an older
-# compiler version
-OPT:=$(OPT) -dFPC
-
 # diff program
 ifndef REFPATH
 REFPATH=/usr/local/fpk/work/new/rtl
@@ -127,119 +132,205 @@ ifndef DIFFOPTS
 DIFFOPTS=-b -c
 endif
 
-# os independent depends
-SYSTEMDEPS=$(INC)/system.inc $(INC)/systemh.inc $(INC)/mathh.inc $(INC)/real2str.inc \
-	$(INC)/heaph.inc $(INC)/innr.inc $(INC)/sstrings.inc $(INC)/file.inc \
-	$(INC)/text.inc $(INC)/typefile.inc $(INC)/version.inc $(INC)/filerec.inc \
-	$(INC)/textrec.inc \
-	$(PROCINC)/math.inc $(PROCINC)/set.inc $(PROCINC)/heap.inc $(PROCINC)/$(CPU).inc
+#
+# System independent Commandline Options
+#
 
+# Cross compiling ?
+ifeq ($(OS_TARGET),$(OS_SRC))
+CROSSCOMPILE=NO
+else
+CROSSCOMPILE=YES
+endif
+
+# add required options... (-dFPC is required for older versions)
+override OPT:= $(OPT) -dFPC -d$(CPU)
+
+# Was a config file specified ?
+ifdef CFGFILE
+override OPT:=$(OPT) @$(CFGFILE)
+endif
+
+# Check for crosscompile
+ifeq ($(CROSSCOMPILE),YES)
+override OPT:= $(OPT) -dCROSSCOMPILE -T$(OS_TARGET)
+endif
+
+#
+# System dependent Commandline Options
+#
+
+
+#####################################################################
+# System dependent
+#####################################################################
+
+# Determine needed extensions
 PPUEXT=.pp1
 PPLEXT=.ppl
-# At this moment only static libs under go32v2. When shared libs are made then
-# we should ask what kind of lib user wants, and then set the correct
-# extension... (see linux makefile for example)
-LIBEXT=.a1
 OEXT=.o1
+ASMEXT=.s1
+LIBEXT=.a1
 
-.PHONY: all clean install diffs diffclean
+# Define Linux Units
+SYSTEMPPU=system$(PPUEXT)
+OBJECTS=strings go32 objpas \
+	dos crt objects printer \
+	cpu mmx mouse getopts graph \
 
-all : system$(PPUEXT) prt0$(OEXT) go32$(PPUEXT) strings$(PPUEXT) \
-      objpas$(PPUEXT) \
-      dos$(PPUEXT) crt$(PPUEXT) printer$(PPUEXT) objects$(PPUEXT) \
-      mmx$(PPUEXT) cpu$(PPUEXT) \
-      mouse$(PPUEXT) getopts$(PPUEXT) graph$(PPUEXT) \
+LOADERS=prt0
 
-printer$(PPUEXT) : ../printer.pp system$(PPUEXT)
-	$(COPY) ../printer.pp .
-	$(PP) $(OPT) printer.pp $(REDIR)
-	$(DEL) printer.pp
+#####################################################################
+# System independent Makefile
+#####################################################################
 
-getopts$(PPUEXT) : $(PROCINC)/getopts.pp system$(PPUEXT)
-	$(COPY) $(PROCINC)/getopts.pp .
-	$(PP) $(OPT) getopts.pp $(REDIR)
-	$(DEL) getopts.pp
+# OS Independent Depends
+SYSTEMDEPS=system.inc systemh.inc mathh.inc real2str.inc \
+	heaph.inc innr.inc sstrings.inc file.inc \
+	text.inc typefile.inc version.inc filerec.inc \
+	textrec.inc
 
-graph$(PPUEXT) : ../graph.pp go32$(PPUEXT) system$(PPUEXT) mmx$(PPUEXT) \
-	$(PPI)/arc.ppi $(PPI)/colors.ppi $(PPI)/dpmi2raw.ppi $(PPI)/ellipse.ppi \
-	$(PPI)/fill.ppi $(PPI)/font.ppi $(PPI)/global.ppi $(PPI)/ibm.ppi \
-	$(PPI)/image.ppi $(PPI)/line.ppi $(PPI)/modes.ppi $(PPI)/move.ppi \
-	$(PPI)/palette.ppi $(PPI)/pixel.ppi $(PPI)/stdcolor.ppi $(PPI)/text.ppi \
-	$(PPI)/triangle.ppi $(PPI)/vesadeb.ppi
-	$(COPY) ../graph.pp $(PPI)/*.ppi .
-	$(PP) $(OPT) graph $(REDIR)
-	$(DEL) graph.pp *.ppi
+# Processor Dependent Depends
+SYSPROCDEPS=math.inc set.inc heap.inc $(CPU).inc
 
-mmx$(PPUEXT) : $(PROCINC)/mmx.pp cpu$(PPUEXT) system$(PPUEXT)
-	$(COPY) $(PROCINC)/mmx.pp .
-	$(PP) $(OPT) mmx.pp $(REDIR)
-	$(DEL) mmx.pp
+# Add Prefix and Suffixes
+OBJLOADERS=$(addsuffix $(OEXT), $(LOADERS))
+PPUOBJECTS=$(addsuffix $(PPUEXT), $(OBJECTS))
+DSYSTEMDEPS=$(addprefix $(INC)/, $(SYSTEMDEPS))
+DSYSPROCDEPS=$(addprefix $(PROCINC)/, $(SYSPROCDEPS))
 
-cpu$(PPUEXT) : ../../i386/cpu.pp system$(PPUEXT)
-	$(COPY) ../../i386/cpu.pp .
-	$(PP) $(OPT) cpu $(REDIR)
-	$(DEL) cpu.pp
 
-strings$(PPUEXT) : $(PROCINC)/strings.pp system$(PPUEXT)
+.PHONY : all install clean \
+	 libs libsclean \
+	 diffs diffclean \
+
+all : $(OBJLOADERS) $(PPUOBJECTS)
+
+install : all
+	$(MKDIR) $(UNITINSTALLDIR)
+	$(INSTALL) *$(PPUEXT) *$(OEXT) $(UNITINSTALLDIR)
+
+clean :
+	-$(DEL) *$(OEXT) *$(ASMEXT) *$(PPUEXT) *.PPS log
+
+#####################################################################
+# Files
+#####################################################################
+
+#
+# Loaders
+#
+
+prt0$(OEXT) : prt0.as
+	as -D -o prt0$(OEXT) prt0.as
+
+#
+# Base Units (System, strings, os-dependent-base-unit)
+#
+
+$(SYSTEMPPU) : system.pp $(DSYSTEMDEPS) $(DSYSPROCDEPS)
+	$(COPY) $(DSYSTEMDEPS) .
+	$(COPY) $(DSYSPROCDEPS) .
+	$(PP) $(OPT) -Us -Sg system.pp $(REDIR)
+	$(DEL) $(SYSTEMDEPS)
+	$(DEL) $(SYSPROCDEPS)
+
+strings$(PPUEXT) : $(PROCINC)/strings.pp $(SYSTEMPPU)
 	$(COPY) $(PROCINC)/strings.pp .
 	$(PP) $(OPT) strings.pp $(REDIR)
 	$(DEL) strings.pp
 
+go32$(PPUEXT) : ../go32.pp $(SYSTEMPPU)
+	$(COPY) ../go32.pp .
+	$(PP) $(OPT) go32.pp $(REDIR)
+	$(DEL) go32.pp
+
+#
+# Delphi Object Model
+#
+
+objpas$(PPUEXT) : $(OBJPASDIR)/objpas.pp $(SYSTEMPPU)
+	$(COPY) $(OBJPASDIR)/objpas.pp .
+	$(PP) $(OPT) objpas $(REDIR)
+	$(DEL) objpas.pp
+
+#
+# System Dependent Units
+#
+
+
+#
+# TP7 Compatible RTL Units
+#
+
 dos$(PPUEXT) : ../dos.pp $(INC)/filerec.inc $(INC)/textrec.inc \
-	go32$(PPUEXT) system$(PPUEXT) strings$(PPUEXT)
+	       go32$(PPUEXT) strings$(PPUEXT) $(SYSTEMPPU)
 	$(COPY) ../dos.pp $(INC)/filerec.inc $(INC)/textrec.inc .
 	$(PP) $(OPT) dos $(REDIR)
 	$(DEL) dos.pp filerec.inc textrec.inc
 
-system$(PPUEXT) : system.pp $(SYSTEMDEPS)
-	$(COPY) $(INC)/*.inc $(PROCINC)/*.inc .
-	$(PP) $(OPT) -Us -Sg system $(REDIR)
-	$(DEL) systemh.inc system.inc real2str.inc version.inc $(CPU).inc sstrings.inc
-	$(DEL) mathh.inc math.inc set.inc innr.inc heap.inc heaph.inc
-	$(DEL) filerec.inc textrec.inc file.inc typefile.inc text.inc
-
-prt0$(OEXT) : prt0.as
-	as -D -o prt0$(OEXT) prt0.as
-
-crt$(PPUEXT) : ../crt.pp $(INC)/textrec.inc go32$(PPUEXT) system$(PPUEXT)
+crt$(PPUEXT) : ../crt.pp $(INC)/textrec.inc go32$(PPUEXT) $(SYSTEMPPU)
 	$(COPY) ../crt.pp $(INC)/textrec.inc .
 	$(PP) $(OPT) crt $(REDIR)
 	$(DEL) crt.pp textrec.inc
 
-go32$(PPUEXT) : ../go32.pp system$(PPUEXT)
-	$(COPY) ../go32.pp .
-	$(PP) $(OPT) go32.pp $(REDIR)
-	$(DEL) go32.pp
-
-objects$(PPUEXT) : ../objects.pp system$(PPUEXT)
+objects$(PPUEXT) : ../objects.pp $(SYSTEMPPU)
 	$(COPY) ../objects.pp .
 	$(PP) $(OPT) objects.pp $(REDIR)
 	$(DEL) objects.pp
 
-objpas$(PPUEXT) : ../../objpas/objpas.pp system$(PPUEXT)
-	$(COPY) ../../objpas/objpas.pp .
-	$(PP) $(OPT) objpas $(REDIR)
-	$(DEL) objpas.pp
+printer$(PPUEXT) : ../printer.pp $(SYSTEMPPU)
+	$(COPY) ../printer.pp .
+	$(PP) $(OPT) printer.pp $(REDIR)
+	$(DEL) printer.pp
+
+#
+# Other RTL Units
+#
 
-mouse$(PPUEXT) : ../mouse.pp system$(PPUEXT)
+cpu$(PPUEXT) : $(PROCINC)/cpu.pp $(SYSTEMPPU)
+	$(COPY) $(PROCINC)/cpu.pp .
+	$(PP) $(OPT) cpu.pp $(REDIR)
+	$(DEL) cpu.pp
+
+mmx$(PPUEXT) : $(PROCINC)/mmx.pp cpu$(PPUEXT) $(SYSTEMPPU)
+	$(COPY) $(PROCINC)/mmx.pp .
+	$(PP) $(OPT) mmx.pp $(REDIR)
+	$(DEL) mmx.pp
+
+mouse$(PPUEXT) : ../mouse.pp $(SYSTEMPPU)
 	$(COPY) ../mouse.pp .
 	$(PP) $(OPT) mouse.pp $(REDIR)
 	$(DEL) mouse.pp
 
-clean:
-	-$(DEL) *$(OEXT)
-	-$(DEL) *$(PPUEXT)
-	-$(DEL) *.dif
-	-$(DEL) log
-	-$(DEL) *$(ASMEXT)
+getopts$(PPUEXT) : $(PROCINC)/getopts.pp $(SYSTEMPPU)
+	$(COPY) $(PROCINC)/getopts.pp .
+	$(PP) $(OPT) getopts.pp $(REDIR)
+	$(DEL) getopts.pp
 
-diffclean:
-	-$(DEL) *.dif
+graph$(PPUEXT) : ../graph.pp go32$(PPUEXT) $(SYSTEMPPU) mmx$(PPUEXT) \
+	$(PPI)/arc.ppi $(PPI)/colors.ppi $(PPI)/dpmi2raw.ppi $(PPI)/ellipse.ppi \
+	$(PPI)/fill.ppi $(PPI)/font.ppi $(PPI)/global.ppi $(PPI)/ibm.ppi \
+	$(PPI)/image.ppi $(PPI)/line.ppi $(PPI)/modes.ppi $(PPI)/move.ppi \
+	$(PPI)/palette.ppi $(PPI)/pixel.ppi $(PPI)/stdcolor.ppi $(PPI)/text.ppi \
+	$(PPI)/triangle.ppi $(PPI)/vesadeb.ppi
+	$(COPY) ../graph.pp $(PPI)/*.ppi .
+	$(PP) $(OPT) graph $(REDIR)
+	$(DEL) graph.pp *.ppi
 
-install: all
-	-$(MKDIR) $(LIBINSTALLDIR)/dosunits
-	$(INSTALL) *$(OEXT) $(LIBINSTALLDIR)/dosunits
-	$(INSTALL) *$(PPUEXT) $(LIBINSTALLDIR)/dosunits
+
+#####################################################################
+# Libs
+#####################################################################
+
+libs: all
+
+libsclean : clean
+	-$(DEL) *.$(LIBEXT) *$(PPLEXT)
+
+#####################################################################
+# Diffs
+#####################################################################
 
 %.dif : %.pp
 	-$(DIFF) $(DIFFOPTS) $*.pp $(REFPATH)/dos/go32v1/$*.pp > $*.dif
@@ -250,7 +341,17 @@ install: all
 %.dif : %.as
 	-$(DIFF) $(DIFFOPTS) $*.as $(REFPATH)/dos/go32v1/$*.as > $*.dif
 
+diffclean:
+	-$(DEL) *.dif
+
 makefile.dif : makefile
 	-$(DIFF) $(DIFFOPTS) makefile $(REFPATH)/dos/go32v1/makefile > makefile.dif
 
 diffs: system.dif os.dif makefile.dif prt0.dif
+
+#####################################################################
+# Distribution
+#####################################################################
+
+distclean : clean libsclean diffclean
+

+ 228 - 135
rtl/dos/go32v2/makefile

@@ -1,7 +1,18 @@
-# Makefile for the DOS Go32v2 Run-time library.
-# we need the stupid copies and del because the old FPK Pascal doesn't handle
-# ppc386 ..\crt correct..
 #
+#   $Id$
+#   This file is part of the Free Pascal run time library.
+#   Copyright (c) 1996-98 by Michael van Canneyt
+#
+#   Makefile for the Free Pascal Go32v2 Runtime Library
+#
+#   See the file COPYING.FPC, included in this distribution,
+#   for details about the copyright.
+#
+#   This program is distributed in the hope that it will be useful,
+#   but WITHOUT ANY WARRANTY; without even the implied warranty of
+#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+#
+
 #####################################################################
 # Start of configurable section.
 # Please note that all these must be set in the main makefile, and
@@ -12,7 +23,7 @@
 
 # set the directory where to install the units.
 ifndef UNITINSTALLDIR
-UNITINSTALLDIR=c:\lib\ppc
+UNITINSTALLDIR=c:\lib\ppc\go32v2
 endif
 
 # set the directory where to install libraries
@@ -30,6 +41,12 @@ ifndef OS_TARGET
 OS_TARGET=GO32V2
 endif
 
+# What is the target processor :
+ifndef CPU
+CPU=i386
+#CPU=m68k
+endif
+
 # What compiler to use ?
 # I think ppc386 is better (it's mostly in path) (FK)
 ifndef PP
@@ -54,46 +71,48 @@ endif
 
 # Where are the include files
 INC=../../inc
-
-ifndef CPU
-CPU=i386
-endif
-
 PROCINC=../../$(CPU)
-
+OBJPASDIR=../../objpas
 # Where are the .ppi files.
 PPI=../ppi
 
-ifeq ($(OS_TARGET),$(OS_SRC))
-CROSSCOMPILE=NO
-else
-CROSSCOMPILE=YES
-endif
-
 # To copy pograms
 ifndef COPY
+ifeq ($(DOS),YES)
+COPY=copy
+else
 COPY=cp -p
 endif
+endif
 
-# To delete programs
+# Check delete program
 ifndef DEL
 ifeq ($(DOS),YES)
 DEL=del
 else
-DEL=rm
+DEL=rm -f
 endif
 endif
 
-# To install programs
+# To install files
 ifndef INSTALL
 ifeq ($(DOS),YES)
-INSTALL=cp
+INSTALL=copy
 else
 INSTALL=install -m 644
 endif
 endif
 
+# To install programs
+ifndef INSTALLEXE
+ifeq ($(DOS),YES)
+INSTALLEXE=copy
+else
+INSTALLEXE=install -m 755
+endif
+endif
 
+# To make a directory.
 ifndef MKDIR
 ifeq ($(DOS),YES)
 MKDIR=mkdir
@@ -102,23 +121,9 @@ MKDIR=install -m 755 -d
 endif
 endif
 
-# Check for crosscompile
-ifeq ($(CROSSCOMPILE),YES)
-OPT:=$(OPT) -dCROSSCOMPILE -T$(OS_TARGET)
-endif
-
-# check config file
-ifdef CFGFILE
-OPT:=$(OPT) @$(CFGFILE)
-endif
-
-# to be sure to be able to compile with an older
-# compiler version
-OPT:=$(OPT) -dFPC
-
 # diff program
 ifndef REFPATH
-REFPATH=h:/cvs/rtl
+REFPATH=/usr/local/fpk/work/new/rtl
 endif
 ifndef DIFF
 DIFF=diff
@@ -127,165 +132,253 @@ ifndef DIFFOPTS
 DIFFOPTS=-b -c
 endif
 
-# os independent depends
-SYSTEMDEPS=$(INC)/system.inc $(INC)/systemh.inc $(INC)/mathh.inc $(INC)/real2str.inc \
-	$(INC)/heaph.inc $(INC)/innr.inc $(INC)/sstrings.inc $(INC)/file.inc \
-	$(INC)/text.inc $(INC)/typefile.inc $(INC)/version.inc $(INC)/filerec.inc \
-	$(INC)/textrec.inc \
-	$(PROCINC)/math.inc $(PROCINC)/set.inc $(PROCINC)/heap.inc $(PROCINC)/$(CPU).inc
+#
+# System independent Commandline Options
+#
 
+# Cross compiling ?
+ifeq ($(OS_TARGET),$(OS_SRC))
+CROSSCOMPILE=NO
+else
+CROSSCOMPILE=YES
+endif
+
+# add required options... (-dFPC is required for older versions)
+override OPT:= $(OPT) -dFPC -d$(CPU)
+
+# Was a config file specified ?
+ifdef CFGFILE
+override OPT:=$(OPT) @$(CFGFILE)
+endif
+
+# Check for crosscompile
+ifeq ($(CROSSCOMPILE),YES)
+override OPT:= $(OPT) -dCROSSCOMPILE -T$(OS_TARGET)
+endif
+
+#
+# System dependent Commandline Options
+#
+
+#####################################################################
+# System dependent
+#####################################################################
+
+# Determine needed extensions
 PPUEXT=.ppu
 PPLEXT=.ppl
-# At this moment only static libs under go32v2. When shared libs are made then
-# we should ask what kind of lib user wants, and then set the correct
-# extension... (see linux makefile for example)
-LIBEXT=.a
 OEXT=.o
+ASMEXT=.s
+LIBEXT=.a
 
-.PHONY: all clean install diffs diffclean
+# Define Linux Units
+SYSTEMPPU=system$(PPUEXT)
+OBJECTS=strings go32 objpas \
+	dpmiexcp profile dxeload emu387 \
+	dos crt objects printer \
+	cpu mmx mouse getopts graph \
 
-all : system$(PPUEXT) prt0$(OEXT) go32$(PPUEXT) strings$(PPUEXT) \
-      objpas$(PPUEXT) dpmiexcp$(PPUEXT) exceptn$(OEXT) profile$(PPUEXT) \
-      dxeload$(PPUEXT) fpu$(OEXT) emu387$(PPUEXT) \
-      dos$(PPUEXT) crt$(PPUEXT) printer$(PPUEXT) objects$(PPUEXT) \
-      mmx$(PPUEXT) cpu$(PPUEXT) \
-      mouse$(PPUEXT) getopts$(PPUEXT) graph$(PPUEXT) \
+LOADERS=prt0 exceptn fpu
 
+#####################################################################
+# System independent Makefile
+#####################################################################
+
+# OS Independent Depends
+SYSTEMDEPS=system.inc systemh.inc mathh.inc real2str.inc \
+	heaph.inc innr.inc sstrings.inc file.inc \
+	text.inc typefile.inc version.inc filerec.inc \
+	textrec.inc
+
+# Processor Dependent Depends
+SYSPROCDEPS=math.inc set.inc heap.inc $(CPU).inc
+
+# Add Prefix and Suffixes
+OBJLOADERS=$(addsuffix $(OEXT), $(LOADERS))
+PPUOBJECTS=$(addsuffix $(PPUEXT), $(OBJECTS))
+DSYSTEMDEPS=$(addprefix $(INC)/, $(SYSTEMDEPS))
+DSYSPROCDEPS=$(addprefix $(PROCINC)/, $(SYSPROCDEPS))
+
+
+.PHONY : all install clean \
+	 libs libsclean \
+	 diffs diffclean \
+
+all : $(OBJLOADERS) $(PPUOBJECTS)
+
+install : all
+	$(MKDIR) $(UNITINSTALLDIR)
+	$(INSTALL) *$(PPUEXT) *$(OEXT) $(UNITINSTALLDIR)
+
+clean :
+	-$(DEL) *$(OEXT) *$(ASMEXT) *$(PPUEXT) *.PPS log
+
+#####################################################################
+# Files
+#####################################################################
+
+#
+# Loaders
+#
 
-dxeload$(PPUEXT) : system$(PPUEXT)
-	$(PP) $(OPT) dxeload $(REDIR)
+prt0$(OEXT) : v2prt0.as
+	as -o prt0$(OEXT) v2prt0.as
 
-emu387$(PPUEXT) : system$(PPUEXT) fpu$(OEXT) strings$(PPUEXT) dxeload$(PPUEXT) dpmiexcp$(PPUEXT)
-	$(PP) $(OPT) emu387 $(REDIR)
+exceptn$(OEXT) : exceptn.as
+	as -o exceptn$(OEXT) exceptn.as
 
 fpu$(OEXT) : fpu.as
 	as -o fpu$(OEXT) fpu.as
 
-printer$(PPUEXT) : ../printer.pp system$(PPUEXT)
-	$(COPY) ../printer.pp .
-	$(PP) $(OPT) printer $(REDIR)
-	$(DEL) printer.pp
+#
+# Base Units (System, strings, os-dependent-base-unit)
+#
 
-getopts$(PPUEXT) : $(PROCINC)/getopts.pp system$(PPUEXT)
-	$(COPY) $(PROCINC)/getopts.pp .
-	$(PP) $(OPT) getopts $(REDIR)
-	$(DEL) getopts.pp
+$(SYSTEMPPU) : system.pp $(DSYSTEMDEPS) $(DSYSPROCDEPS)
+	$(COPY) $(DSYSTEMDEPS) .
+	$(COPY) $(DSYSPROCDEPS) .
+	$(PP) $(OPT) -Us -Sg system.pp $(REDIR)
+	$(DEL) $(SYSTEMDEPS)
+	$(DEL) $(SYSPROCDEPS)
 
-graph$(PPUEXT) : ../graph.pp mmx$(PPUEXT) go32$(PPUEXT) system$(PPUEXT) \
-	$(PPI)/arc.ppi $(PPI)/colors.ppi $(PPI)/dpmi2raw.ppi $(PPI)/ellipse.ppi \
-	$(PPI)/fill.ppi $(PPI)/font.ppi $(PPI)/global.ppi $(PPI)/ibm.ppi \
-	$(PPI)/image.ppi $(PPI)/line.ppi $(PPI)/modes.ppi $(PPI)/move.ppi \
-	$(PPI)/palette.ppi $(PPI)/pixel.ppi $(PPI)/stdcolor.ppi $(PPI)/text.ppi \
-	$(PPI)/triangle.ppi $(PPI)/vesadeb.ppi
-	$(COPY) ../graph.pp $(PPI)/*.ppi .
-	$(PP) $(OPT) graph $(REDIR)
-	$(DEL) graph.pp *.ppi
-
-strings$(PPUEXT) : $(PROCINC)/strings.pp system$(PPUEXT)
+strings$(PPUEXT) : $(PROCINC)/strings.pp $(SYSTEMPPU)
 	$(COPY) $(PROCINC)/strings.pp .
-	$(PP) $(OPT) strings $(REDIR)
+	$(PP) $(OPT) strings.pp $(REDIR)
 	$(DEL) strings.pp
 
-dos$(PPUEXT) : ../dos.pp $(INC)/filerec.inc $(INC)/textrec.inc \
-	go32$(PPUEXT) system$(PPUEXT) strings$(PPUEXT)
-	$(COPY) ../dos.pp $(INC)/filerec.inc $(INC)/textrec.inc .
-	$(PP) $(OPT) dos $(REDIR)
-	$(DEL) dos.pp filerec.inc textrec.inc
+go32$(PPUEXT) : ../go32.pp $(SYSTEMPPU)
+	$(COPY) ../go32.pp .
+	$(PP) $(OPT) go32.pp $(REDIR)
+	$(DEL) go32.pp
 
-exceptn$(OEXT) : exceptn.as
-	as -o exceptn$(OEXT) exceptn.as
-#   gcc not need anymore
-#	gcc -c -x assembler-with-cpp -o exceptn$(OEXT) exceptn.AS
+#
+# Delphi Object Model
+#
+
+objpas$(PPUEXT) : $(OBJPASDIR)/objpas.pp $(SYSTEMPPU)
+	$(COPY) $(OBJPASDIR)/objpas.pp .
+	$(PP) $(OPT) objpas.pp $(REDIR)
+	$(DEL) objpas.pp
 
-dpmiexcp$(PPUEXT) : dpmiexcp.pp exceptn$(OEXT)
-	$(PP) $(OPT) -Sg dpmiexcp $(REDIR)
+#
+# System Dependent Units
+#
 
-profile$(PPUEXT) : profile.pp dpmiexcp$(PPUEXT) go32$(PPUEXT)
-	$(PP) $(OPT) profile $(REDIR)
+dpmiexcp$(PPUEXT) : dpmiexcp.pp exceptn$(OEXT) $(SYSTEMPPU)
+	$(PP) $(OPT) -Sg dpmiexcp.pp $(REDIR)
 
-system$(PPUEXT) : system.pp $(SYSTEMDEPS)
-	$(COPY) $(INC)/*.inc $(PROCINC)/*.inc .
-	$(PP) $(OPT) -dI386 -Us -Sg system $(REDIR)
-	$(DEL) systemh.inc system.inc real2str.inc version.inc $(CPU).inc sstrings.inc
-	$(DEL) mathh.inc math.inc set.inc innr.inc heap.inc heaph.inc
-	$(DEL) filerec.inc textrec.inc file.inc typefile.inc text.inc
+profile$(PPUEXT) : profile.pp dpmiexcp$(PPUEXT) go32$(PPUEXT) $(SYSTEMPPU)
+	$(PP) $(OPT) profile.pp $(REDIR)
 
-prt0$(OEXT) : v2prt0.as
-	as -o prt0$(OEXT) v2prt0.as
-#   gcc not need anymore
-#	gcc -c -x assembler-with-cpp -o prt0$(OEXT) v2prt0.AS
+dxeload$(PPUEXT) : $(SYSTEMPPU)
+	$(PP) $(OPT) dxeload.pp $(REDIR)
+
+emu387$(PPUEXT) : emu387.pp fpu$(OEXT) strings$(PPUEXT) dxeload$(PPUEXT) \
+		  dpmiexcp$(PPUEXT) $(SYSTEMPPU)
+	$(PP) $(OPT) emu387.pp $(REDIR)
 
-crt$(PPUEXT) : ../crt.pp $(INC)/textrec.inc go32$(PPUEXT) system$(PPUEXT)
+#
+# TP7 Compatible RTL Units
+#
+
+dos$(PPUEXT) : ../dos.pp $(INC)/filerec.inc $(INC)/textrec.inc \
+	       go32$(PPUEXT) strings$(PPUEXT) $(SYSTEMPPU)
+	$(COPY) ../dos.pp $(INC)/filerec.inc $(INC)/textrec.inc .
+	$(PP) $(OPT) dos $(REDIR)
+	$(DEL) dos.pp filerec.inc textrec.inc
+
+crt$(PPUEXT) : ../crt.pp $(INC)/textrec.inc go32$(PPUEXT) $(SYSTEMPPU)
 	$(COPY) ../crt.pp $(INC)/textrec.inc .
 	$(PP) $(OPT) crt $(REDIR)
 	$(DEL) crt.pp textrec.inc
 
-go32$(PPUEXT) : ../go32.pp system$(PPUEXT)
-	$(COPY) ../go32.pp .
-	$(PP) $(OPT) go32 $(REDIR)
-	$(DEL) go32.pp
+objects$(PPUEXT) : ../objects.pp $(SYSTEMPPU)
+	$(COPY) ../objects.pp .
+	$(PP) $(OPT) objects.pp $(REDIR)
+	$(DEL) objects.pp
 
-mmx$(PPUEXT) : ../../i386/mmx.pp cpu$(PPUEXT) system$(PPUEXT)
-	$(COPY) ../../i386/mmx.pp .
-	$(PP) $(OPT) mmx $(REDIR)
-	$(DEL) mmx.pp
+printer$(PPUEXT) : ../printer.pp $(SYSTEMPPU)
+	$(COPY) ../printer.pp .
+	$(PP) $(OPT) printer.pp $(REDIR)
+	$(DEL) printer.pp
 
-cpu$(PPUEXT) : ../../i386/cpu.pp system$(PPUEXT)
-	$(COPY) ../../i386/cpu.pp .
-	$(PP) $(OPT) cpu $(REDIR)
-	$(DEL) cpu.pp
+#
+# Other RTL Units
+#
 
-objpas$(PPUEXT) : ../../objpas/objpas.pp system$(PPUEXT)
-	$(COPY) ../../objpas/objpas.pp .
-	$(PP) $(OPT) objpas $(REDIR)
-	$(DEL) objpas.pp
+cpu$(PPUEXT) : $(PROCINC)/cpu.pp $(SYSTEMPPU)
+	$(COPY) $(PROCINC)/cpu.pp .
+	$(PP) $(OPT) cpu.pp $(REDIR)
+	$(DEL) cpu.pp
 
-objects$(PPUEXT) : ../objects.pp system$(PPUEXT)
-	$(COPY) ../objects.pp .
-	$(PP) $(OPT) objects $(REDIR)
-	$(DEL) objects.pp
+mmx$(PPUEXT) : $(PROCINC)/mmx.pp cpu$(PPUEXT) $(SYSTEMPPU)
+	$(COPY) $(PROCINC)/mmx.pp .
+	$(PP) $(OPT) mmx.pp $(REDIR)
+	$(DEL) mmx.pp
 
-mouse$(PPUEXT) : ../mouse.pp system$(PPUEXT)
+mouse$(PPUEXT) : ../mouse.pp $(SYSTEMPPU)
 	$(COPY) ../mouse.pp .
-	$(PP) $(OPT) mouse $(REDIR)
+	$(PP) $(OPT) mouse.pp $(REDIR)
 	$(DEL) mouse.pp
 
-libs: libfpc$(LIBEXT)
+getopts$(PPUEXT) : $(PROCINC)/getopts.pp $(SYSTEMPPU)
+	$(COPY) $(PROCINC)/getopts.pp .
+	$(PP) $(OPT) getopts.pp $(REDIR)
+	$(DEL) getopts.pp
 
-libfpc.a: all
-	$(PPUMOVE) -s -o fpc *.ppu
+graph$(PPUEXT) : ../graph.pp go32$(PPUEXT) $(SYSTEMPPU) mmx$(PPUEXT) \
+	$(PPI)/arc.ppi $(PPI)/colors.ppi $(PPI)/dpmi2raw.ppi $(PPI)/ellipse.ppi \
+	$(PPI)/fill.ppi $(PPI)/font.ppi $(PPI)/global.ppi $(PPI)/ibm.ppi \
+	$(PPI)/image.ppi $(PPI)/line.ppi $(PPI)/modes.ppi $(PPI)/move.ppi \
+	$(PPI)/palette.ppi $(PPI)/pixel.ppi $(PPI)/stdcolor.ppi $(PPI)/text.ppi \
+	$(PPI)/triangle.ppi $(PPI)/vesadeb.ppi
+	$(COPY) ../graph.pp $(PPI)/*.ppi .
+	$(PP) $(OPT) graph $(REDIR)
+	$(DEL) graph.pp *.ppi
+
+#####################################################################
+# Libs
+#####################################################################
 
-clean:
-	-$(DEL) *$(OEXT) *$(PPUEXT) *.dif log *.s
+libs: all libfpc$(LIBEXT)
 
-diffclean:
-	-$(DEL) *.dif
+libfpc.a:
+	$(PPUMOVE) -s -o fpc *.ppu
 
-install: all
-	-$(MKDIR) $(UNITINSTALLDIR)/go32unit
-	$(INSTALL) *$(PPUEXT) $(UNITINSTALLDIR)/go32unit
-	$(INSTALL) *$(OEXT)   $(UNITINSTALLDIR)/go32unit
+libsclean : clean
+	-$(DEL) *.$(LIBEXT) *$(PPLEXT)
 
 libinstall: libs
 	$(INSTALL) libfpc$(LIBEXT) $(LIBINSTALLDIR)
 	$(INSTALL) *$(PPLEXT) $(UNITINSTALLDIR)
 
+#####################################################################
+# Diffs
+#####################################################################
+
 %.dif : %.pp
 	-$(DIFF) $(DIFFOPTS) $*.pp $(REFPATH)/dos/go32v2/$*.pp > $*.dif
 
 %.dif : %.inc
 	-$(DIFF) $(DIFFOPTS) $*.inc $(REFPATH)/dos/go32v2/$*.inc > $*.dif
 
-# these must have the lowest priority
-
 %.dif : %.as
 	-$(DIFF) $(DIFFOPTS) $*.as $(REFPATH)/dos/go32v2/$*.as > $*.dif
 
 %.dif : %.asm
 	-$(DIFF) $(DIFFOPTS) $*.asm $(REFPATH)/dos/go32v2/$*.asm > $*.dif
 
+diffclean:
+	-$(DEL) *.dif
+
 makefile.dif : makefile
 	-$(DIFF) $(DIFFOPTS) makefile $(REFPATH)/dos/go32v2/makefile > makefile.dif
 
 diffs: system.dif v2prt0.dif dpmiexcp.dif exceptn.dif profile.dif os.dif \
        sbrk16.dif exit16.dif makefile.dif
+
+#####################################################################
+# Distribution
+#####################################################################
+
+distclean : clean libsclean diffclean

+ 193 - 110
rtl/linux/makefile

@@ -1,6 +1,17 @@
-# makes the SYSTEM-Unit for Linux
 #
-# Copyright (c) 1996 by Michael Van Canneyt
+#   $Id$
+#   This file is part of the Free Pascal run time library.
+#   Copyright (c) 1996-98 by Michael van Canneyt
+#
+#   Makefile for the Free Pascal Linux Runtime Library
+#
+#   See the file COPYING.FPC, included in this distribution,
+#   for details about the copyright.
+#
+#   This program is distributed in the hope that it will be useful,
+#   but WITHOUT ANY WARRANTY; without even the implied warranty of
+#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+#
 
 #####################################################################
 # Start of configurable section.
@@ -10,13 +21,9 @@
 # with the main makefile.
 #####################################################################
 
-# AOUT should be defined in main makefile.
-# But you can set it here too.
-# AOUT = -DAOUT
-
 # set the directory where to install the units.
 ifndef UNITINSTALLDIR
-UNITINSTALLDIR=/usr/lib/ppc/0.99.0
+UNITINSTALLDIR=/usr/lib/ppc/0.99.0/linuxunits
 endif
 
 # set the directory where to install the libs (must exist)
@@ -24,12 +31,6 @@ ifndef LIBINSTALLDIR
 LIBINSTALLDIR=/usr/lib
 endif
 
-# Do you want to link to the C library ?
-# Standard it is NO. You can set it to YES to link in th C library.
-ifndef LINK_TO_C
-LINK_TO_C=NO
-endif
-
 # What is the Operating System ?
 ifndef OS_SRC
 OS_SRC=linux
@@ -65,6 +66,16 @@ endif
 # Set this to 'shared' or 'static'
 LIBTYPE=shared
 
+# AOUT should be defined in main makefile.
+# But you can set it here too.
+# AOUT = -DAOUT
+
+# Do you want to link to the C library ?
+# Standard it is NO. You can set it to YES to link in th C library.
+ifndef LINK_TO_C
+LINK_TO_C=NO
+endif
+
 #####################################################################
 # End of configurable section.
 # Do not edit after this line.
@@ -75,15 +86,6 @@ INC=../inc
 PROCINC=../$(CPU)
 OBJPASDIR=../objpas
 
-# add required options...
-override OPT:= $(OPT) -d$(CPU)
-
-ifeq ($(OS_TARGET),$(OS_SRC))
-CROSSCOMPILE=NO
-else
-CROSSCOMPILE=YES
-endif
-
 # To copy pograms
 ifndef COPY
 ifeq ($(DOS),YES)
@@ -102,12 +104,21 @@ DEL=rm -f
 endif
 endif
 
-# To install programs
+# To install files
 ifndef INSTALL
 ifeq ($(DOS),YES)
 INSTALL=copy
 else
-INSTALL=install
+INSTALL=install -m 644
+endif
+endif
+
+# To install programs
+ifndef INSTALLEXE
+ifeq ($(DOS),YES)
+INSTALLEXE=copy
+else
+INSTALLEXE=install -m 755
 endif
 endif
 
@@ -131,21 +142,43 @@ ifndef DIFFOPTS
 DIFFOPTS=-b -c
 endif
 
+#
+# System independent Commandline Options
+#
+
+# Cross compiling ?
+ifeq ($(OS_TARGET),$(OS_SRC))
+CROSSCOMPILE=NO
+else
+CROSSCOMPILE=YES
+endif
+
+# add required options... (-dFPC is required for older versions)
+override OPT:= $(OPT) -dFPC -d$(CPU)
+
 # Was a config file specified ?
 ifdef CFGFILE
-override OPT:=$(OPT) @$(CONFIG)
+override OPT:=$(OPT) @$(CFGFILE)
 endif
 
 # Check for crosscompile
 ifeq ($(CROSSCOMPILE),YES)
-override OPT:= $(OPT) -dCROSSCOMPILE -TLINUX
+override OPT:= $(OPT) -dCROSSCOMPILE -T$(OS_TARGET)
 endif
 
+#
+# System dependent Commandline Options
+#
+
 # Check if we need C library.
 ifeq ($(LINK_TO_C),YES)
 override OPT:=$(OPT) -dCRTLIB
 endif
 
+#####################################################################
+# System dependent
+#####################################################################
+
 # check whether we make shared or static libs
 ifndef LIBTYPE
 LIBTYPE=shared
@@ -158,41 +191,27 @@ else
 LIBEXT=.so
 endif
 
-# determine needed extensions.
+# Determine needed extensions
 PPUEXT=.ppu
 PPLEXT=.ppl
 OEXT=.o
+ASMEXT=.s
 
-OBJECTS=syslinux strings dos objects linux crt printer getopts errors sockets\
-        objpas
-        
-PPUOBJECTS=$(addsuffix $(PPUEXT), $(OBJECTS))
-
-ifeq ($(LINK_TO_C),NO)
-PPUOBJECTS:= prt0$(OEXT) gprt0$(OEXT) $(PPUOBJECTS)
-endif
-
-# os independent depends
-SYSTEMDEPS=system.inc systemh.inc mathh.inc real2str.inc \
-	heaph.inc innr.inc sstrings.inc file.inc \
-	text.inc typefile.inc version.inc filerec.inc \
-	textrec.inc
-
-DSYSTEMDEPS=$(addprefix $(INC)/, $(SYSTEMDEPS))
+# Define Linux Units
+SYSTEMPPU=syslinux$(PPUEXT)
+OBJECTS=strings linux objpas \
+	dos crt objects printer \
+	getopts errors sockets \
 
+# Extra Syslinux Depends
 ifeq ($(LINK_TO_C),YES)
 SYSLINUXDEPS=lprt$(OEXT)
 else
 SYSLINUXDEPS=sysconst.inc systypes.inc syscalls.inc
 endif
 
-SYSPROCDEPS=math.inc set.inc heap.inc $(CPU).inc
-
-DSYSPROCDEPS=$(addprefix $(PROCINC)/, $(SYSPROCDEPS))
-
-
 # Determine on what dos unit should depend.
-DOSDEPS = dos.pp $(INC)/filerec.inc syslinux$(PPUEXT) strings$(PPUEXT)
+DOSDEPS = dos.pp $(INC)/filerec.inc $(INC)/textrec.inc strings$(PPUEXT)
 ifeq ($(LINK_TO_C),YES)
 DOSDEPS:=$(DOSDEPS) lprt$(OEXT)
 else
@@ -206,72 +225,140 @@ else
 PRT=prt1.as
 endif
 
+# Define Loaders
+ifeq ($(LINK_TO_C),NO)
+LOADERS=prt0 gprt0
+else
+LOADERS=lprt
+endif
 
-.PHONY : all clean diffs install diffclean libs libsclean realclean
+#####################################################################
+# System independent Makefile
+#####################################################################
 
-all : $(PPUOBJECTS)
+# OS Independent Depends
+SYSTEMDEPS=system.inc systemh.inc mathh.inc real2str.inc \
+	heaph.inc innr.inc sstrings.inc file.inc \
+	text.inc typefile.inc version.inc filerec.inc \
+	textrec.inc
 
-syslinux$(PPUEXT) : syslinux.pp $(SYSLINUXDEPS) $(DSYSTEMDEPS) $(DSYSPROCDEPS)
-	$(COPY) $(DSYSTEMDEPS) $(DSYSPROCDEPS) .
-	$(PP) $(OPT) -Us -Sg syslinux $(REDIR)
-	$(DEL) $(SYSTEMDEPS) $(SYSPROCDEPS)
+# Processor Dependent Depends
+SYSPROCDEPS=math.inc set.inc heap.inc $(CPU).inc
 
-dos$(PPUEXT) : $(DOSDEPS)
-	$(COPY) $(INC)/filerec.inc $(INC)/textrec.inc .
-	$(PP) $(OPT) dos $(REDIR)
-	$(DEL) filerec.inc textrec.inc
+# Add Prefix and Suffixes
+OBJLOADERS=$(addsuffix $(OEXT), $(LOADERS))
+PPUOBJECTS=$(addsuffix $(PPUEXT), $(OBJECTS))
+DSYSTEMDEPS=$(addprefix $(INC)/, $(SYSTEMDEPS))
+DSYSPROCDEPS=$(addprefix $(PROCINC)/, $(SYSPROCDEPS))
 
-crt$(PPUEXT) : crt.pp $(INC)/textrec.inc $(INC)/filerec.inc linux$(PPUEXT)\
-	       syslinux$(PPUEXT)
-	$(COPY) $(INC)/filerec.inc $(INC)/textrec.inc .
-	$(PP) $(OPT) crt $(REDIR)
-	$(DEL) filerec.inc textrec.inc
+
+.PHONY : all install clean \
+	 libs libsclean \
+	 diffs diffclean \
+
+all : $(OBJLOADERS) $(PPUOBJECTS)
+
+install : all
+	$(MKDIR) $(UNITINSTALLDIR)
+	$(INSTALL) *$(PPUEXT) *$(OEXT) $(UNITINSTALLDIR)
+
+clean :
+	-$(DEL) *$(OEXT) *$(ASMEXT) *$(PPUEXT) *.PPS log
+
+#####################################################################
+# Files
+#####################################################################
+
+#
+# Loaders
+#
+
+prt0$(OEXT) : $(PRT)
+	-as $(PRT) -o prt0$(OEXT)
+
+gprt0$(OEXT) : gprt1.as
+	-as gprt1.as -o gprt0$(OEXT)
 
 lprt$(OEXT) : lprt.c
 	gcc $(AOUT) -c lprt.c -o lprt$(OEXT)
 
-getopts$(PPUEXT) : $(PROCINC)/getopts.pp syslinux$(PPUEXT)
-	$(COPY) $(PROCINC)/getopts.pp .
-	$(PP) $(OPT) getopts $(REDIR)
-	$(DEL) getopts.pp
+#
+# Base Units (System, strings, os-dependent-base-unit)
+#
+
+$(SYSTEMPPU) : syslinux.pp $(SYSLINUXDEPS) $(DSYSTEMDEPS) $(DSYSPROCDEPS)
+	$(COPY) $(DSYSTEMDEPS) $(DSYSPROCDEPS) .
+	$(PP) $(OPT) -Us -Sg syslinux.pp $(REDIR)
+	$(DEL) $(SYSTEMDEPS) $(SYSPROCDEPS)
 
-strings$(PPUEXT) : $(PROCINC)/strings.pp syslinux$(PPUEXT)
+strings$(PPUEXT) : $(PROCINC)/strings.pp $(SYSTEMPPU)
 	$(COPY) $(PROCINC)/strings.pp .
 	$(PP) $(OPT) strings $(REDIR)
 	$(DEL) strings.pp
 
-objects$(PPUEXT) : objects.pp syslinux$(PPUEXT)
-	$(PP) $(OPT) objects $(REDIR)
-
-printer$(PPUEXT) : printer.pp $(INC)/textrec.inc linux$(PPUEXT) syslinux$(PPUEXT)
-	$(COPY) $(INC)/textrec.inc .
-	$(PP) $(OPT) printer $(REDIR)
-	$(DEL) textrec.inc
-
-linux$(PPUEXT) : linux.pp strings$(PPUEXT) $(INC)/textrec.inc $(INC)/filerec.inc\
-		 syscalls.inc systypes.inc sysconst.inc syslinux$(PPUEXT)
+linux$(PPUEXT) : linux.pp strings$(PPUEXT) $(INC)/textrec.inc $(INC)/filerec.inc \
+		 syscalls.inc systypes.inc sysconst.inc $(SYSTEMPPU)
 	$(COPY) $(INC)/filerec.inc $(INC)/textrec.inc .
 	$(PP) $(OPT) linux.pp $(REDIR)
 	$(DEL) filerec.inc textrec.inc
 
-sockets$(PPUEXT) : sockets.pp linux.ppu $(INC)/textrec.inc $(INC)/filerec.inc
+#
+# Delphi Object Model
+#
+
+objpas$(PPUEXT) : $(OBJPASDIR)/objpas.pp $(SYSTEMPPU)
+	$(COPY) $(OBJPASDIR)/objpas.pp .
+	$(PP) $(OPT) objpas $(REDIR)
+	$(DEL) objpas.pp
+
+#
+# System Dependent Units
+#
+
+sockets$(PPUEXT) : sockets.pp $(INC)/textrec.inc $(INC)/filerec.inc \
+		   linux$(PPUEXT) $(SYSTEMPPU)
 	$(COPY) $(INC)/filerec.inc $(INC)/textrec.inc .
 	$(PP) $(OPT) sockets.pp $(REDIR)
-	$(DEL) filerec.inc textrec.inc 
+	$(DEL) filerec.inc textrec.inc
 
-errors$(PPUEXT) : errors.pp strings.ppu
+errors$(PPUEXT) : errors.pp strings$(PPUEXT) $(SYSTEMPPU)
 	$(PP) $(OPT) errors.pp $(REDIR)
 
-prt0$(OEXT) : $(PRT)
-	-as $(PRT) -o prt0$(OEXT)
+#
+# TP7 Compatible RTL Units
+#
 
-gprt0$(OEXT) : gprt1.as
-	-as gprt1.as -o gprt0$(OEXT)
+dos$(PPUEXT) : $(DOSDEPS) $(SYSTEMPPU)
+	$(COPY) $(INC)/filerec.inc $(INC)/textrec.inc .
+	$(PP) $(OPT) dos $(REDIR)
+	$(DEL) filerec.inc textrec.inc
 
-objpas$(PPUEXT) : $(OBJPASDIR)/objpas.pp syslinux$(PPUEXT)
-	$(COPY) $(OBJPASDIR)/objpas.pp .
-	$(PP) $(OPT) objpas $(REDIR)
-	$(DEL) objpas.pp
+crt$(PPUEXT) : crt.pp $(INC)/textrec.inc $(INC)/filerec.inc linux$(PPUEXT)\
+	       $(SYSTEMPPU)
+	$(COPY) $(INC)/filerec.inc $(INC)/textrec.inc .
+	$(PP) $(OPT) crt $(REDIR)
+	$(DEL) filerec.inc textrec.inc
+
+objects$(PPUEXT) : objects.pp $(SYSTEMPPU)
+	$(PP) $(OPT) objects $(REDIR)
+
+printer$(PPUEXT) : printer.pp $(INC)/textrec.inc linux$(PPUEXT) $(SYSTEMPPU)
+	$(COPY) $(INC)/textrec.inc .
+	$(PP) $(OPT) printer $(REDIR)
+	$(DEL) textrec.inc
+
+#
+# Other RTL Units
+#
+
+getopts$(PPUEXT) : $(PROCINC)/getopts.pp $(SYSTEMPPU)
+	$(COPY) $(PROCINC)/getopts.pp .
+	$(PP) $(OPT) getopts $(REDIR)
+	$(DEL) getopts.pp
+
+#####################################################################
+# Libs
+#####################################################################
 
 libs	: all libfpc$(LIBEXT)
 
@@ -280,30 +367,17 @@ libfpc.so:
 
 libfpc.a:
 	$(PPUMOVE) -s -o fpc *.ppu
-		
-install : all
-	$(MKDIR) $(UNITINSTALLDIR)/linuxunits
-	$(INSTALL) -m 644 *$(PPUEXT) *$(OEXT) $(UNITINSTALLDIR)/linuxunits
 
 libinstall : libs
-	$(INSTALL) -m 755 libfpc$(LIBEXT) $(LIBINSTALLDIR)
-	$(INSTALL) -m 644 *$(PPLEXT) $(UNITINSTALLDIR)/linuxunits
-
-clean :
-	-$(DEL) *$(OEXT)
-	-$(DEL) *.s
-	-$(DEL) *$(PPUEXT)
-	-$(DEL) *.dif
-	-$(DEL) *.PPS
-	-$(DEL) log
+	$(INSTALLEXE) libfpc$(LIBEXT) $(LIBINSTALLDIR)
+	$(INSTALL) *$(PPLEXT) $(UNITINSTALLDIR)
 
 libsclean : clean
 	-$(DEL) *.a *.so *$(PPLEXT)
 
-diffclean :
-	-$(DEL) *.dif
-
-distclean : diffclean libsclean clean 
+#####################################################################
+# Diffs
+#####################################################################
 
 %.dif : %.pp
 	-$(DIFF) $(DIFFOPTS) $*.pp $(REFPATH)/linux/$*.pp >$*.dif
@@ -314,10 +388,19 @@ distclean : diffclean libsclean clean
 %.dif : %.as
 	-$(DIFF) $(DIFFOPTS) $*.s $(REFPATH)/linux/$*.s >$*.dif
 
+diffclean :
+	-$(DEL) *.dif
+
 makefile.dif : makefile
 	-$(DIFF) $(DIFFOPTS) makefile $(REFPATH)/linux/makefile > makefile.dif
 
-
 diffs : dos.dif syslinux.dif objects.dif errno.dif prt0.dif prt1.dif \
 	objects.dif linux.dif printer.dif os.dif syscalls.dif sysnr.dif \
-   makefile.dif
+	makefile.dif
+
+#####################################################################
+# Distribution
+#####################################################################
+
+distclean : clean libsclean diffclean
+