From 3db44e8d8ede4f2e7a48cdc9861d67fd350218f1 Mon Sep 17 00:00:00 2001
From: Pierre Muller <pierre@freepascal.org>
Date: Wed, 20 Sep 2023 13:49:54 +0200
Subject: [PATCH]   Handle dynlibs unit to support DOTTED version

  * Replace dynlibs by DYNLIBSUNIT variable use everywhere
  * Remove OS specific dynlibs unit rules
  * Set DYNLIBSINCDIR varaible where required
  * Set DYNLIBS_DEPS_OS where needed
---
 rtl/aix/Makefile.fpc       |  9 ++++-----
 rtl/android/Makefile.fpc   |  9 ++++-----
 rtl/beos/Makefile.fpc      |  4 +++-
 rtl/darwin/Makefile.fpc    |  1 +
 rtl/dragonfly/Makefile.fpc | 10 +++++-----
 rtl/freebsd/Makefile.fpc   | 11 +++++------
 rtl/haiku/Makefile.fpc     |  2 +-
 rtl/macos/Makefile.fpc     |  2 ++
 rtl/nativent/Makefile.fpc  |  3 ++-
 rtl/netbsd/Makefile.fpc    |  9 ++++-----
 rtl/netware/Makefile.fpc   |  2 --
 rtl/netwlibc/Makefile.fpc  |  4 +---
 rtl/openbsd/Makefile.fpc   |  9 ++++-----
 rtl/palmos/Makefile.fpc    |  2 +-
 rtl/solaris/Makefile.fpc   | 10 ++++------
 rtl/win16/Makefile.fpc     |  9 +--------
 16 files changed, 42 insertions(+), 54 deletions(-)

diff --git a/rtl/aix/Makefile.fpc b/rtl/aix/Makefile.fpc
index b21e36a93a..cdde4d1390 100644
--- a/rtl/aix/Makefile.fpc
+++ b/rtl/aix/Makefile.fpc
@@ -16,7 +16,7 @@ units=$(SYSTEMUNIT) $(UUCHARUNIT) unixtype ctypes $(STRINGSUNIT) $(OBJPASUNIT) $
       $(CHARSETUNIT) $(CPALLUNIT) $(CHARACTERUNIT) $(UNIXCPUNIT) $(GETOPTSUNIT) \
       $(ERRORSUNIT) \
       # ipc 
-      dl dynlibs \
+      dl $(DYNLIBSUNIT) \
       types sysconst \
       rtlconsts cthreads \
       dos \
@@ -59,6 +59,8 @@ OSPROCINC=$(RTL)/aix/$(CPU_TARGET)
 UNIXINC=$(RTL)/unix
 UNITPREFIX=rtl
 CPU_UNITS=
+DYNLIBS_DEPS_OS=$(DLUNIT)$(PPUEXT)
+DYNLIBSINCDIR=$(UNIXINC)
 
 SYSTEMUNIT=system
 
@@ -185,16 +187,13 @@ endif
 # Other system-dependent RTL Units
 #
 
-dynlibs$(PPUEXT) : $(INC)/dynlibs.pas $(UNIXINC)/dynlibs.inc dl$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)
-	$(COMPILER) $(INC)/dynlibs.pas
-
 termio$(PPUEXT) : termio.pp unixtype$(PPUEXT) baseunix$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)
         $(COMPILER) termio.pp
 
 cthreads$(PPUEXT) : $(UNIXINC)/cthreads.pp sysutils$(PPUEXT) baseunix$(PPUEXT) unixtype$(PPUEXT) unix$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)
 	$(COMPILER) $(UNIXINC)/cthreads.pp
 
-cwstring$(PPUEXT) : $(UNIXINC)/cwstring.pp $(SYSTEMUNIT)$(PPUEXT) sysutils$(PPUEXT) baseunix$(PPUEXT) unix$(PPUEXT) unixtype$(PPUEXT) ctypes$(PPUEXT) dynlibs$(PPUEXT)
+cwstring$(PPUEXT) : $(UNIXINC)/cwstring.pp $(SYSTEMUNIT)$(PPUEXT) sysutils$(PPUEXT) baseunix$(PPUEXT) unix$(PPUEXT) unixtype$(PPUEXT) ctypes$(PPUEXT) $(DYNLIBSUNIT)$(PPUEXT)
 	$(COMPILER) $(UNIXINC)/cwstring.pp
 
 gpm$(PPUEXT): gpm.pp unix$(PPUEXT) baseunix$(PPUEXT) sockets$(PPUEXT)
diff --git a/rtl/android/Makefile.fpc b/rtl/android/Makefile.fpc
index fe64ce624a..6716a8f0f6 100644
--- a/rtl/android/Makefile.fpc
+++ b/rtl/android/Makefile.fpc
@@ -11,7 +11,7 @@ units=$(SYSTEMUNIT) $(SYSINIT_UNITS) $(CPU_UNITS) \
       $(UUCHARUNIT) unixtype ctypes baseunix $(STRINGSUNIT) $(OBJPASUNIT) $(MACPASUNIT) $(ISO7185UNIT) $(EXTPASUNIT) syscall unixutil \
       $(FPINTRESUNIT) $(HEAPTRCUNIT) $(LINEINFOUNIT) $(LNFODWRFUNIT) termio unix $(LINUXUNIT) initc $(CMEMUNIT) \
       $(LINUXVCSUNIT) sysutils typinfo $(MATHUNIT) $(CHARSETUNIT) $(CPALLUNIT) $(CHARACTERUNIT) \
-      $(GETOPTSUNIT) $(ERRORSUNIT) dl dynlibs \
+      $(GETOPTSUNIT) $(ERRORSUNIT) dl $(DYNLIBSUNIT) \
       types  sysconst cthreads $(SORTBASEUNIT) classes $(FGLUNIT)  \
       rtlconsts dos cwstring $(FPCYLIXUNIT) $(UNIXCPUNIT) $(FPWIDESTRINGUNIT) \
       $(SOFTFPUUNIT) $(SFPUX80UNIT) $(UFLOATX80UNIT) $(SFPU128UNIT) $(UFLOAT128UNIT)
@@ -51,6 +51,8 @@ PROCINC=$(RTL)/$(ARCH)
 UNIXINC=$(RTL)/unix
 OSPROCINC=$(RTL)/linux/$(CPU_TARGET)
 LINUXINC=$(RTL)/linux
+DYNLIBS_DEPS_OS=$(DLUNIT)$(PPUEXT)
+DYNLIBSINCDIR=$(UNIXINC)
 
 UNITPREFIX=rtl
 
@@ -155,9 +157,6 @@ baseunix$(PPUEXT) : $(UNIXINC)/baseunix.pp $(LINUXINC)/errno.inc $(LINUXINC)/pty
 dl$(PPUEXT) : $(UNIXINC)/dl.pp $(SYSTEMUNIT)$(PPUEXT) ctypes$(PPUEXT) dlandroid.inc
         $(COMPILER) $(UNIXINC)/dl.pp
 
-dynlibs$(PPUEXT) : $(INC)/dynlibs.pas $(UNIXINC)/dynlibs.inc dl$(PPUEXT) $(OBJPASUNIT)$(PPUEXT)
-        $(COMPILER) $(INC)/dynlibs.pas
-
 initc$(PPUEXT) : $(UNIXINC)/initc.pp ctypes$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)
         $(COMPILER) $(UNIXINC)/initc.pp
 
@@ -207,7 +206,7 @@ endif
 cthreads$(PPUEXT) : $(UNIXINC)/cthreads.pp $(SYSTEMUNIT)$(PPUEXT)
         $(COMPILER) $(UNIXINC)/cthreads.pp
 
-cwstring$(PPUEXT) : cwstring.pp $(SYSTEMUNIT)$(PPUEXT) dynlibs$(PPUEXT)
+cwstring$(PPUEXT) : cwstring.pp $(SYSTEMUNIT)$(PPUEXT) $(DYNLIBSUNIT)$(PPUEXT)
         $(COMPILER) cwstring.pp
 
 ctypes$(PPUEXT) :  $(INC)/ctypes.pp $(SYSTEMUNIT)$(PPUEXT)
diff --git a/rtl/beos/Makefile.fpc b/rtl/beos/Makefile.fpc
index 3b14c6e2bf..cb28d7dd54 100644
--- a/rtl/beos/Makefile.fpc
+++ b/rtl/beos/Makefile.fpc
@@ -44,7 +44,7 @@ libunits=$(SYSTEMUNIT) $(OBJPASUNIT) $(STRINGSUNIT) \
       dos crt  \
       sysutils typinfo $(MATHUNIT) \
       $(CPU_UNITS) $(GETOPTSUNIT) $(HEAPTRCUNIT) \
-      $(ERRORSUNIT) dynlibs
+      $(ERRORSUNIT) $(DYNLIBSUNIT)
 
 
 [prerules]
@@ -58,6 +58,8 @@ BASEUNIXDIR=.
 ifndef FPC_DOTTEDUNITS
 RTLCONSTSUNIT=rtlconst
 endif
+DYNLIBS_DEPS_OS=$(DLUNIT)$(PPUEXT)
+DYNLIBSINCDIR=$(UNIXINC)
 # Use new feature from 1.0.5 version
 # that generates release PPU files
 # which will not be recompiled
diff --git a/rtl/darwin/Makefile.fpc b/rtl/darwin/Makefile.fpc
index b35e44f5e6..6f2db6fc63 100644
--- a/rtl/darwin/Makefile.fpc
+++ b/rtl/darwin/Makefile.fpc
@@ -69,6 +69,7 @@ INITCDIR=$(UNIXINC)
 SYSUTILS_DEPS_OS=$(SYSCTLUNIT)$(PPUEXT) $(BASEUNIXUNIT)$(PPUEXT) $(UNIXUNIT)$(PPUEXT) $(ERRORSUNIT)$(PPUEXT) $(SYSCONSTUNIT)$(PPUEXT) $(UNIXTYPEUNIT)$(PPUEXT)
 BASEUNIX_DEPS_OS=$(SYSCTLUNIT)$(PPUEXT)
 DYNLIBS_DEPS_OS=$(DLUNIT)$(PPUEXT)
+DYNLIBSINCDIR=$(UNIXINC)
 CTYPES_DEPS_OS=$(UNIXTYPEUNIT)$(PPUEXT)
 EXEINFO_DEPS_OS=$(BASEUNIXUNIT)$(PPUEXT)
 FPEXTRES_DEPS_OS=$(BASEUNIXUNIT)$(PPUEXT)
diff --git a/rtl/dragonfly/Makefile.fpc b/rtl/dragonfly/Makefile.fpc
index 4996de02b7..8a1d88938a 100644
--- a/rtl/dragonfly/Makefile.fpc
+++ b/rtl/dragonfly/Makefile.fpc
@@ -14,7 +14,7 @@ units=$(SYSTEMUNIT) $(UUCHARUNIT) unixtype ctypes $(OBJPASUNIT) $(MACPASUNIT) $(
       $(STRINGSUNIT) syscall sysctl baseunix unixutil $(CHARACTERUNIT) \
       unix rtlconsts initc $(CMEMUNIT) \
       dl termio \
-      sysutils $(MATHUNIT) typinfo types $(SORTBASEUNIT) classes $(FGLUNIT) dynlibs \
+      sysutils $(MATHUNIT) typinfo types $(SORTBASEUNIT) classes $(FGLUNIT) $(DYNLIBSUNIT) \
       $(CPU_UNITS) $(CHARSETUNIT) $(CPALLUNIT) $(GETOPTSUNIT) $(HEAPTRCUNIT) $(LNFODWRFUNIT) $(LINEINFOUNIT) \
       $(ERRORSUNIT) bsd \
       console  \
@@ -47,7 +47,7 @@ libunits=$(SYSTEMUNIT) $(OBJPASUNIT) $(STRINGSUNIT) \
       dos  \
       sysutils typinfo $(MATHUNIT) \
       $(CPU_UNITS) $(GETOPTSUNIT) $(HEAPTRCUNIT) \
-      $(ERRORSUNIT) dynlibs
+      $(ERRORSUNIT) $(DYNLIBSUNIT)
 
 [prerules]
 RTL=..
@@ -60,6 +60,8 @@ BSDPROCINC=$(BSDINC)/$(CPU_TARGET)
 UNIXINC=$(RTL)/unix
 UNITPREFIX=rtl
 CPU_UNITS=
+DYNLIBS_DEPS_OS=$(DLUNIT)$(PPUEXT)
+DYNLIBSINCDIR=$(UNIXINC)
 
 SYSTEMUNIT=system
 loaders+=gprt0
@@ -191,9 +193,7 @@ sysctl$(PPUEXT) : $(BSDINC)/sysctl.pp unixtype$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT) s
 
 cthreads$(PPUEXT) : $(UNIXINC)/cthreads.pp $(SYSTEMUNIT)$(PPUEXT)
 
-dynlibs$(PPUEXT) : $(INC)/dynlibs.pas $(UNIXINC)/dynlibs.inc dl$(PPUEXT) $(OBJPASUNIT)$(PPUEXT)
-
 ctypes$(PPUEXT) :  $(INC)/ctypes.pp $(SYSTEMUNIT)$(PPUEXT)
 
-cwstring$(PPUEXT) : $(UNIXINC)/cwstring.pp $(SYSTEMUNIT)$(PPUEXT) sysutils$(PPUEXT) baseunix$(PPUEXT) unix$(PPUEXT) unixtype$(PPUEXT) ctypes$(PPUEXT) dynlibs$(PPUEXT)
+cwstring$(PPUEXT) : $(UNIXINC)/cwstring.pp $(SYSTEMUNIT)$(PPUEXT) sysutils$(PPUEXT) baseunix$(PPUEXT) unix$(PPUEXT) unixtype$(PPUEXT) ctypes$(PPUEXT) $(DYNLIBSUNIT)$(PPUEXT)
 
diff --git a/rtl/freebsd/Makefile.fpc b/rtl/freebsd/Makefile.fpc
index 8a86cc1bb8..682aa7d360 100644
--- a/rtl/freebsd/Makefile.fpc
+++ b/rtl/freebsd/Makefile.fpc
@@ -14,7 +14,7 @@ units=$(SYSTEMUNIT) $(UUCHARUNIT) unixtype ctypes $(OBJPASUNIT) $(MACPASUNIT) $(
       $(STRINGSUNIT) syscall sysctl baseunix unixutil $(CHARACTERUNIT) \
       unix rtlconsts initc $(CMEMUNIT) \
       dl termio \
-      sysutils $(MATHUNIT) typinfo types $(SORTBASEUNIT) classes $(FGLUNIT) dynlibs \
+      sysutils $(MATHUNIT) typinfo types $(SORTBASEUNIT) classes $(FGLUNIT) $(DYNLIBSUNIT) \
       $(CPU_UNITS) $(CHARSETUNIT) $(CPALLUNIT) $(GETOPTSUNIT) $(HEAPTRCUNIT) $(LNFODWRFUNIT) $(LINEINFOUNIT) \
       $(ERRORSUNIT) bsd freebsd \
       console  \
@@ -47,7 +47,7 @@ libunits=$(SYSTEMUNIT) $(OBJPASUNIT) $(STRINGSUNIT) \
       dos  \
       sysutils typinfo $(MATHUNIT) \
       $(CPU_UNITS) $(GETOPTSUNIT) $(HEAPTRCUNIT) \
-      $(ERRORSUNIT) dynlibs
+      $(ERRORSUNIT) $(DYNLIBSUNIT)
 
 [prerules]
 RTL=..
@@ -61,6 +61,8 @@ BSDPROCINC=$(BSDINC)/$(CPU_TARGET)
 UNIXINC=$(RTL)/unix
 UNITPREFIX=rtl
 CPU_UNITS=
+DYNLIBS_DEPS_OS=$(DLUNIT)$(PPUEXT)
+DYNLIBSINCDIR=$(UNIXINC)
 
 SYSTEMUNIT=system
 loaders+=gprt0
@@ -207,16 +209,13 @@ sysctl$(PPUEXT) : $(BSDINC)/sysctl.pp unixtype$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT) s
 cthreads$(PPUEXT) : $(UNIXINC)/cthreads.pp $(SYSTEMUNIT)$(PPUEXT)
         $(COMPILER) $<
 
-dynlibs$(PPUEXT) : $(INC)/dynlibs.pas $(UNIXINC)/dynlibs.inc dl$(PPUEXT) $(OBJPASUNIT)$(PPUEXT)
-        $(COMPILER) $<
-		
 dl$(PPUEXT) : $(UNIXINC)/dl.pp ctypes$(PPUEXT) $(OBJPASUNIT)$(PPUEXT)
         $(COMPILER) $<
 
 ctypes$(PPUEXT) :  $(INC)/ctypes.pp $(SYSTEMUNIT)$(PPUEXT)
         $(COMPILER) $<
 
-cwstring$(PPUEXT) : $(UNIXINC)/cwstring.pp $(SYSTEMUNIT)$(PPUEXT) sysutils$(PPUEXT) baseunix$(PPUEXT) unix$(PPUEXT) unixtype$(PPUEXT) ctypes$(PPUEXT) dynlibs$(PPUEXT)
+cwstring$(PPUEXT) : $(UNIXINC)/cwstring.pp $(SYSTEMUNIT)$(PPUEXT) sysutils$(PPUEXT) baseunix$(PPUEXT) unix$(PPUEXT) unixtype$(PPUEXT) ctypes$(PPUEXT) $(DYNLIBSUNIT)$(PPUEXT)
         $(COMPILER) $<
 
 bsd$(PPUEXT) : $(BSDINC)/bsd.pas initc$(PPUEXT) unix$(PPUEXT) syscall$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)
diff --git a/rtl/haiku/Makefile.fpc b/rtl/haiku/Makefile.fpc
index a16224c284..9fbe71ad4b 100644
--- a/rtl/haiku/Makefile.fpc
+++ b/rtl/haiku/Makefile.fpc
@@ -44,7 +44,7 @@ libunits=$(SYSTEMUNIT) $(OBJPASUNIT) $(STRINGSUNIT) \
       dos \
       sysutils typinfo $(MATHUNIT) \
       $(CPU_UNITS) $(GETOPTSUNIT) $(HEAPTRCUNIT) \
-      $(ERRORSUNIT) dynlibs
+      $(ERRORSUNIT) $(DYNLIBSUNIT)
 
 
 [prerules]
diff --git a/rtl/macos/Makefile.fpc b/rtl/macos/Makefile.fpc
index 59e7aa03c6..2716adf4eb 100644
--- a/rtl/macos/Makefile.fpc
+++ b/rtl/macos/Makefile.fpc
@@ -40,6 +40,8 @@ PROCINC=../$(CPU_TARGET)
 UNIXINC=../unix
 PPUEXT=pput
 ASMEXT=.s
+DYNLIBS_DEPS_OS=$(DLUNIT)$(PPUEXT)
+DYNLIBSINCDIR=$(UNIXINC)
 
 UNITPREFIX=rtl
 SYSTEMUNIT=system
diff --git a/rtl/nativent/Makefile.fpc b/rtl/nativent/Makefile.fpc
index 0d71ef47bc..b34e6805a9 100644
--- a/rtl/nativent/Makefile.fpc
+++ b/rtl/nativent/Makefile.fpc
@@ -12,7 +12,7 @@ units=system $(UUCHARUNIT) $(OBJPASUNIT) $(ISO7185UNIT) $(EXTPASUNIT) $(CPALLUNI
 implicitunits=ndk ndkutils ddk \
       ctypes $(STRINGSUNIT) \
 #      $(HEAPTRCUNIT)
-#      initc $(CMEMUNIT) dynlibs signals \
+#      initc $(CMEMUNIT) $(DYNLIBSUNIT) signals \
       dos \
       rtlconsts sysconst sysutils $(MATHUNIT) types \
       typinfo $(FGLUNIT) classes \
@@ -48,6 +48,7 @@ COMMON=$(RTL)/common
 PROCINC=$(RTL)/$(CPU_TARGET)
 DDKINC=ddk
 NDKINC=ndk
+# Not used DYNLIBSINCDIR=$(WINDIR)
 
 UNITPREFIX=rtl
 SYSTEMUNIT=system
diff --git a/rtl/netbsd/Makefile.fpc b/rtl/netbsd/Makefile.fpc
index 49a3222abb..ae87c7fb87 100644
--- a/rtl/netbsd/Makefile.fpc
+++ b/rtl/netbsd/Makefile.fpc
@@ -14,7 +14,7 @@ units=$(SYSTEMUNIT) $(UUCHARUNIT) unixtype ctypes $(OBJPASUNIT) $(MACPASUNIT) $(
       $(STRINGSUNIT) syscall sysctl  baseunix unixutil $(CHARACTERUNIT) \
       unix rtlconsts initc $(CMEMUNIT) \
       dl termio \
-      sysutils $(MATHUNIT) typinfo types $(SORTBASEUNIT) classes $(FGLUNIT) dynlibs \
+      sysutils $(MATHUNIT) typinfo types $(SORTBASEUNIT) classes $(FGLUNIT) $(DYNLIBSUNIT) \
       $(CPU_UNITS) $(CHARSETUNIT) $(CPALLUNIT) $(GETOPTSUNIT) $(HEAPTRCUNIT) $(LNFODWRFUNIT) $(LINEINFOUNIT) \
       $(ERRORSUNIT) bsd \
       sysconst cthreads dos cwstring \
@@ -59,6 +59,8 @@ BSDPROCINC=$(BSDINC)/$(CPU_TARGET)
 UNIXINC=$(RTL)/unix
 UNITPREFIX=rtl
 TARGETPROCINC=$(RTL)/netbsd/$(CPU_TARGET)
+DYNLIBS_DEPS_OS=$(DLUNIT)$(PPUEXT)
+DYNLIBSINCDIR=$(UNIXINC)
 
 SYSTEMUNIT=system
 LINUXUNIT=
@@ -143,9 +145,6 @@ unix$(PPUEXT) : $(UNIXINC)/unix.pp strings$(PPUEXT) sysctl$(PPUEXT) $(INC)/textr
 dl$(PPUEXT) : $(UNIXINC)/dl.pp $(SYSTEMUNIT)$(PPUEXT)
 	$(COMPILER) $<
 
-dynlibs$(PPUEXT) : $(INC)/dynlibs.pas $(UNIXINC)/dynlibs.inc dl$(PPUEXT) $(OBJPASUNIT)$(PPUEXT)
-	$(COMPILER) $<
-
 #
 # TP7 Compatible RTL Units
 #
@@ -215,7 +214,7 @@ cthreads$(PPUEXT) : $(UNIXINC)/cthreads.pp $(SYSTEMUNIT)$(PPUEXT)
 variants$(PPUEXT) : $(INC)/variants.pp sysutils$(PPUEXT) sysconst$(PPUEXT) varutils$(PPUEXT) typinfo$(PPUEXT) rtlconsts$(PPUEXT) $(MATHUNIT)$(PPUEXT)
         $(COMPILER) -Fi$(INC) $(INC)/variants.pp
 
-cwstring$(PPUEXT) : $(UNIXINC)/cwstring.pp $(SYSTEMUNIT)$(PPUEXT) sysutils$(PPUEXT) baseunix$(PPUEXT) unix$(PPUEXT) unixtype$(PPUEXT) ctypes$(PPUEXT) dynlibs$(PPUEXT)
+cwstring$(PPUEXT) : $(UNIXINC)/cwstring.pp $(SYSTEMUNIT)$(PPUEXT) sysutils$(PPUEXT) baseunix$(PPUEXT) unix$(PPUEXT) unixtype$(PPUEXT) ctypes$(PPUEXT) $(DYNLIBSUNIT)$(PPUEXT)
 	$(COMPILER) $<
 
 bsd$(PPUEXT) : $(BSDINC)/bsd.pas initc$(PPUEXT) unix$(PPUEXT) syscall$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)
diff --git a/rtl/netware/Makefile.fpc b/rtl/netware/Makefile.fpc
index 79ec7032c0..0828d9f9a0 100644
--- a/rtl/netware/Makefile.fpc
+++ b/rtl/netware/Makefile.fpc
@@ -121,8 +121,6 @@ nwpre$(PPUEXT) : nwpre.pp $(SYSTEMUNIT)$(PPUEXT)
 
 netware$(PPUEXT) : netware.pp $(SYSTEMUNIT)$(PPUEXT)
 
-#dynlibs$(PPUEXT) : $(INC)/dynlibs.pas windows$(PPUEXT)
-
 initc$(PPUEXT) : initc.pp ctypes$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)
 
 
diff --git a/rtl/netwlibc/Makefile.fpc b/rtl/netwlibc/Makefile.fpc
index 544896a0b8..b3307857c7 100644
--- a/rtl/netwlibc/Makefile.fpc
+++ b/rtl/netwlibc/Makefile.fpc
@@ -14,7 +14,7 @@ units=$(SYSTEMUNIT) $(UUCHARUNIT) $(OBJPASUNIT) $(MACPASUNIT) $(ISO7185UNIT) $(E
       cpu $(MMXUNIT) $(GETOPTSUNIT) \
       $(CHARSETUNIT) $(CPALLUNIT) \
       rtlconsts $(MATHUNIT) \
-      dynlibs $(CMEMUNIT) ctypes \
+      $(DYNLIBSUNIT) $(CMEMUNIT) ctypes \
       $(SOFTFPUUNIT) $(SFPUX80UNIT) $(UFLOATX80UNIT) $(SFPU128UNIT) $(UFLOAT128UNIT)
 
 rsts=$(MATHUNIT) typinfo classes sysconst rtlconsts system
@@ -131,8 +131,6 @@ netware$(PPUEXT) : netware.pp $(SYSTEMUNIT)$(PPUEXT)
 
 nwsnut$(PPUEXT) : nwsnut.pp ../netware/nwsnut.pp libc$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)
 
-dynlibs$(PPUEXT) : $(INC)/dynlibs.pas libc$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)
-
 initc$(PPUEXT) : initc.pp ctypes$(PPUEXT) libc$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)
 
 
diff --git a/rtl/openbsd/Makefile.fpc b/rtl/openbsd/Makefile.fpc
index 9c28961a65..c1b6cf990b 100644
--- a/rtl/openbsd/Makefile.fpc
+++ b/rtl/openbsd/Makefile.fpc
@@ -17,7 +17,7 @@ units=$(SYSTEMUNIT) $(SYSINIT_UNITS) initc $(UUCHARUNIT) $(OBJPASUNIT) $(MACPASU
       $(CHARSETUNIT) $(CPALLUNIT) $(CHARACTERUNIT) $(GETOPTSUNIT) $(HEAPTRCUNIT) $(LINEINFOUNIT) $(LNFODWRFUNIT) \
       $(ERRORSUNIT) \
       types sysctl sysconst \
-      $(FPINTRESUNIT) dynlibs cwstring $(CMEMUNIT) dl termio \
+      $(FPINTRESUNIT) $(DYNLIBSUNIT) cwstring $(CMEMUNIT) dl termio \
       cthreads $(UNIXCPUNIT) $(FPWIDESTRINGUNIT) \
       $(SOFTFPUUNIT) $(SFPUX80UNIT) $(UFLOATX80UNIT) $(SFPU128UNIT) $(UFLOAT128UNIT)
 
@@ -58,6 +58,8 @@ BSDPROCINC=$(BSDINC)/$(CPU_TARGET)
 UNIXINC=$(RTL)/unix
 UNITPREFIX=rtl
 TARGETPROCINC=$(RTL)/openbsd/$(CPU_TARGET)
+DYNLIBS_DEPS_OS=$(DLUNIT)$(PPUEXT)
+DYNLIBSINCDIR=$(UNIXINC)
 
 SYSTEMUNIT=system
 LINUXUNIT=
@@ -201,10 +203,7 @@ ctypes$(PPUEXT) :  $(INC)/ctypes.pp unixtype$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)
 dl$(PPUEXT) : $(UNIXINC)/dl.pp ctypes$(PPUEXT) $(OBJPASUNIT)$(PPUEXT)
         $(COMPILER) $<
 
-dynlibs$(PPUEXT) : $(INC)/dynlibs.pas $(UNIXINC)/dynlibs.inc dl$(PPUEXT) $(OBJPASUNIT)$(PPUEXT)
-        $(COMPILER) $<
-
-cwstring$(PPUEXT) : $(UNIXINC)/cwstring.pp $(SYSTEMUNIT)$(PPUEXT) sysutils$(PPUEXT) baseunix$(PPUEXT) unix$(PPUEXT) unixtype$(PPUEXT) ctypes$(PPUEXT) dynlibs$(PPUEXT)
+cwstring$(PPUEXT) : $(UNIXINC)/cwstring.pp $(SYSTEMUNIT)$(PPUEXT) sysutils$(PPUEXT) baseunix$(PPUEXT) unix$(PPUEXT) unixtype$(PPUEXT) ctypes$(PPUEXT) $(DYNLIBSUNIT)$(PPUEXT)
         $(COMPILER) $<
 
 #
diff --git a/rtl/palmos/Makefile.fpc b/rtl/palmos/Makefile.fpc
index 9e937a6e3e..ac5b47ae86 100644
--- a/rtl/palmos/Makefile.fpc
+++ b/rtl/palmos/Makefile.fpc
@@ -14,7 +14,7 @@ units=$(SYSTEMUNIT) si_prc $(UUCHARUNIT) objpas $(ISO7185UNIT) $(STRINGSUNIT) \
        systraps pilot
 #units=$(SYSTEMUNIT) $(UUCHARUNIT) ctypes objpas $(MACPASUNIT) $(ISO7185UNIT) $(EXTPASUNIT) $(STRINGSUNIT) \
 #      $(LNFODWRFUNIT) $(LINEINFOUNIT) $(HEAPTRCUNIT) \
-#      windows messages dynlibs \
+#      windows messages $(DYNLIBSUNIT) \
 #      dos objects \
 #      rtlconsts sysconst sysutils \
 #      typinfo types $(FGLUNIT) classes fmtbcd \
diff --git a/rtl/solaris/Makefile.fpc b/rtl/solaris/Makefile.fpc
index feec47802c..9fcb5cebc5 100644
--- a/rtl/solaris/Makefile.fpc
+++ b/rtl/solaris/Makefile.fpc
@@ -14,7 +14,7 @@ units=$(SYSTEMUNIT) $(UUCHARUNIT) unixtype ctypes $(STRINGSUNIT) $(OBJPASUNIT) $
       sysutils typinfo $(MATHUNIT) $(SORTBASEUNIT) $(FGLUNIT) classes \
       $(CHARSETUNIT) $(CPALLUNIT) $(GETOPTSUNIT) \
       $(ERRORSUNIT) \
-      dl dynlibs \
+      dl $(DYNLIBSUNIT) \
       types sysconst $(CHARACTERUNIT) \
       rtlconsts cthreads \
       dos $(FPWIDESTRINGUNIT) \
@@ -58,6 +58,8 @@ OSPROCINC=$(RTL)/solaris/$(CPU_TARGET)
 UNIXINC=$(RTL)/unix
 UNITPREFIX=rtl
 CPU_UNITS=
+DYNLIBS_DEPS_OS=$(DLUNIT)$(PPUEXT)
+DYNLIBSINCDIR=$(UNIXINC)
 
 SYSTEMUNIT=system
 
@@ -184,17 +186,13 @@ endif
 # Other system-dependent RTL Units
 #
 
-
-dynlibs$(PPUEXT) : $(INC)/dynlibs.pas $(UNIXINC)/dynlibs.inc dl$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)
-	$(COMPILER) $(INC)/dynlibs.pas
-
 termio$(PPUEXT) : termio.pp unixtype$(PPUEXT) baseunix$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)
 	$(COMPILER) termio.pp
 
 cthreads$(PPUEXT) : $(UNIXINC)/cthreads.pp sysutils$(PPUEXT) baseunix$(PPUEXT) unixtype$(PPUEXT) unix$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)
 	$(COMPILER) $(UNIXINC)/cthreads.pp
 
-cwstring$(PPUEXT) : $(UNIXINC)/cwstring.pp $(SYSTEMUNIT)$(PPUEXT) sysutils$(PPUEXT) baseunix$(PPUEXT) unix$(PPUEXT) unixtype$(PPUEXT) ctypes$(PPUEXT) dynlibs$(PPUEXT)
+cwstring$(PPUEXT) : $(UNIXINC)/cwstring.pp $(SYSTEMUNIT)$(PPUEXT) sysutils$(PPUEXT) baseunix$(PPUEXT) unix$(PPUEXT) unixtype$(PPUEXT) ctypes$(PPUEXT) $(DYNLIBSUNIT)$(PPUEXT)
 	$(COMPILER) $(UNIXINC)/cwstring.pp
 
 ctypes$(PPUEXT) :  $(INC)/ctypes.pp $(SYSTEMUNIT)$(PPUEXT) unixtype$(PPUEXT)
diff --git a/rtl/win16/Makefile.fpc b/rtl/win16/Makefile.fpc
index 942740fd79..9827dced38 100644
--- a/rtl/win16/Makefile.fpc
+++ b/rtl/win16/Makefile.fpc
@@ -6,7 +6,7 @@ main=rtl
 [target]
 loaders=prt0s prt0m prt0c prt0l prt0h 
 units=system $(UUCHARUNIT) $(OBJPASUNIT) $(STRINGSUNIT) $(ISO7185UNIT) $(EXTPASUNIT) dos \
-      wintypes winprocs win31 $(PORTSUNIT) dynlibs $(SORTBASEUNIT) \
+      wintypes winprocs win31 $(PORTSUNIT) $(DYNLIBSUNIT) $(SORTBASEUNIT) \
       sysconst rtlconsts sysutils $(MATHUNIT) types typinfo $(FGLUNIT) \
       classes $(CHARSETUNIT) cpu $(GETOPTSUNIT) $(CPALLUNIT) \
       $(UNICODEDATAUNIT) $(CHARACTERUNIT) ctypes
@@ -98,13 +98,6 @@ win31$(PPUEXT) : win31.pp system$(PPUEXT) $(OBJPASUNIT)$(PPUEXT) wintypes$(PPUEX
 	$(COMPILER) win31.pp
 	$(EXECPPAS)
 
-#
-# system Dependent Units
-#
-
-dynlibs$(PPUEXT) : $(INC)/dynlibs.pas dynlibs.inc $(OBJPASUNIT)$(PPUEXT) system$(PPUEXT)
-	$(COMPILER) $(INC)/dynlibs.pas
-
 #
 # TP7 Compatible RTL Units
 #