Browse Source

* splitted to base and extra

peter 23 years ago
parent
commit
a83ac235b9
100 changed files with 53395 additions and 0 deletions
  1. 1067 0
      packages/Makefile
  2. 12 0
      packages/Makefile.fpc
  3. 1419 0
      packages/base/Makefile
  4. 21 0
      packages/base/Makefile.fpc
  5. 1312 0
      packages/base/gdbint/Makefile
  6. 109 0
      packages/base/gdbint/Makefile.fpc
  7. 270 0
      packages/base/gdbint/gdbcon.pp
  8. 2561 0
      packages/base/gdbint/gdbint.pp
  9. 192 0
      packages/base/gdbint/gdbobjs.inc
  10. 93 0
      packages/base/gdbint/gdbver.pp
  11. 977 0
      packages/base/gdbint/libgdb/Makefile
  12. 10 0
      packages/base/gdbint/libgdb/Makefile.fpc
  13. 142 0
      packages/base/gdbint/libgdb/go32v2/Makefile
  14. 142 0
      packages/base/gdbint/libgdb/linux/Makefile
  15. 142 0
      packages/base/gdbint/libgdb/netbsd/Makefile
  16. 142 0
      packages/base/gdbint/libgdb/win32/Makefile
  17. 87 0
      packages/base/gdbint/symify.pp
  18. 64 0
      packages/base/gdbint/testgdb.pp
  19. 1254 0
      packages/base/ibase/Makefile
  20. 20 0
      packages/base/ibase/Makefile.fpc
  21. 43 0
      packages/base/ibase/README
  22. 1856 0
      packages/base/ibase/ibase40.pp
  23. 2657 0
      packages/base/ibase/ibase60.h
  24. 2233 0
      packages/base/ibase/ibase60.pp
  25. 37 0
      packages/base/ibase/mkdb
  26. 26 0
      packages/base/ibase/mkdb.bat
  27. 13 0
      packages/base/ibase/mkdb.sqd
  28. 159 0
      packages/base/ibase/testib40.pp
  29. 163 0
      packages/base/ibase/testib60.pp
  30. 1234 0
      packages/base/inet/Makefile
  31. 17 0
      packages/base/inet/Makefile.fpc
  32. 541 0
      packages/base/inet/inet.pp
  33. 62 0
      packages/base/inet/pfinger.pp
  34. 256 0
      packages/base/inet/testinet.pp
  35. 1225 0
      packages/base/libasync/Makefile
  36. 24 0
      packages/base/libasync/Makefile.fpc
  37. 123 0
      packages/base/libasync/libasync.inc
  38. 528 0
      packages/base/libasync/unix/libasync.pp
  39. 1254 0
      packages/base/mysql/Makefile
  40. 20 0
      packages/base/mysql/Makefile.fpc
  41. 30 0
      packages/base/mysql/README
  42. 28 0
      packages/base/mysql/mkdb
  43. 340 0
      packages/base/mysql/mysql.pp
  44. 241 0
      packages/base/mysql/mysql_com.pp
  45. 27 0
      packages/base/mysql/mysql_version.pp
  46. 27 0
      packages/base/mysql/mysqls.c
  47. 29 0
      packages/base/mysql/mysqls.pp
  48. 16 0
      packages/base/mysql/rmdb
  49. 91 0
      packages/base/mysql/testdb.pp
  50. 1298 0
      packages/base/oracle/Makefile
  51. 25 0
      packages/base/oracle/Makefile.fpc
  52. 20 0
      packages/base/oracle/README
  53. 1341 0
      packages/base/oracle/example/Makefile
  54. 21 0
      packages/base/oracle/example/Makefile.fpc
  55. 457 0
      packages/base/oracle/example/oraclew.pp
  56. 60 0
      packages/base/oracle/example/test01.pp
  57. 1954 0
      packages/base/oracle/oraoci.pp
  58. 1234 0
      packages/base/paszlib/Makefile
  59. 17 0
      packages/base/paszlib/Makefile.fpc
  60. 114 0
      packages/base/paszlib/adler.pas
  61. 12 0
      packages/base/paszlib/changes.txt
  62. 704 0
      packages/base/paszlib/example.pas
  63. 237 0
      packages/base/paszlib/gzcrc.pas
  64. 1192 0
      packages/base/paszlib/gzio.pas
  65. 954 0
      packages/base/paszlib/infblock.pas
  66. 576 0
      packages/base/paszlib/infcodes.pas
  67. 318 0
      packages/base/paszlib/inffast.pas
  68. 780 0
      packages/base/paszlib/inftrees.pas
  69. 222 0
      packages/base/paszlib/infutil.pas
  70. 251 0
      packages/base/paszlib/minigzip.pas
  71. 332 0
      packages/base/paszlib/paszlib.pas
  72. 118 0
      packages/base/paszlib/readme.txt
  73. 2257 0
      packages/base/paszlib/trees.pas
  74. 515 0
      packages/base/paszlib/zbase.pas
  75. 122 0
      packages/base/paszlib/zcompres.pas
  76. 33 0
      packages/base/paszlib/zconf.inc
  77. 2144 0
      packages/base/paszlib/zdeflate.pas
  78. 746 0
      packages/base/paszlib/zinflate.pas
  79. 92 0
      packages/base/paszlib/zuncompr.pas
  80. 519 0
      packages/base/paszlib/zutil.pas
  81. 1254 0
      packages/base/postgres/Makefile
  82. 20 0
      packages/base/postgres/Makefile.fpc
  83. 21 0
      packages/base/postgres/README
  84. 86 0
      packages/base/postgres/dllist.pp
  85. 26 0
      packages/base/postgres/mkdb
  86. 340 0
      packages/base/postgres/postgres.pp
  87. 16 0
      packages/base/postgres/rmdb
  88. 113 0
      packages/base/postgres/testpg1.pp
  89. 85 0
      packages/base/postgres/testpg2.pp
  90. 1235 0
      packages/base/regexpr/Makefile
  91. 20 0
      packages/base/regexpr/Makefile.fpc
  92. 610 0
      packages/base/regexpr/regexpr.pp
  93. 147 0
      packages/base/regexpr/testreg1.pp
  94. 1839 0
      packages/extra/Makefile
  95. 28 0
      packages/extra/Makefile.fpc
  96. 1218 0
      packages/extra/bfd/Makefile
  97. 20 0
      packages/extra/bfd/Makefile.fpc
  98. 3065 0
      packages/extra/bfd/bfd.pas
  99. 1234 0
      packages/extra/cmem/Makefile
  100. 17 0
      packages/extra/cmem/Makefile.fpc

+ 1067 - 0
packages/Makefile

@@ -0,0 +1,1067 @@
+#
+# Don't edit, this file is generated by FPCMake Version 1.1 [2002/01/29]
+#
+default: all
+MAKEFILETARGETS=linux go32v2 win32 os2 freebsd beos netbsd amiga atari sunos qnx
+override PATH:=$(subst \,/,$(PATH))
+ifeq ($(findstring ;,$(PATH)),)
+inUnix=1
+SEARCHPATH:=$(filter-out .,$(subst :, ,$(PATH)))
+else
+SEARCHPATH:=$(subst ;, ,$(PATH))
+endif
+PWD:=$(strip $(wildcard $(addsuffix /pwd.exe,$(SEARCHPATH))))
+ifeq ($(PWD),)
+PWD:=$(strip $(wildcard $(addsuffix /pwd,$(SEARCHPATH))))
+ifeq ($(PWD),)
+$(error You need the GNU utils package to use this Makefile)
+else
+PWD:=$(firstword $(PWD))
+SRCEXEEXT=
+endif
+else
+PWD:=$(firstword $(PWD))
+SRCEXEEXT=.exe
+endif
+ifndef inUnix
+ifeq ($(OS),Windows_NT)
+inWinNT=1
+else
+ifdef OS2_SHELL
+inOS2=1
+endif
+endif
+else
+ifneq ($(findstring cygwin,$(MACHTYPE)),)
+inCygWin=1
+endif
+endif
+ifeq ($(OS_TARGET),freebsd)
+BSDhier=1
+endif
+ifeq ($(OS_TARGET),netbsd)
+BSDhier=1
+endif
+ifdef inUnix
+BATCHEXT=.sh
+else
+ifdef inOS2
+BATCHEXT=.cmd
+else
+BATCHEXT=.bat
+endif
+endif
+ifdef inUnix
+PATHSEP=/
+else
+PATHSEP:=$(subst /,\,/)
+endif
+ifdef PWD
+BASEDIR:=$(subst \,/,$(shell $(PWD)))
+ifdef inCygWin
+ifneq ($(findstring /cygdrive/,$(BASEDIR)),)
+BASENODIR:=$(patsubst /cygdrive%,%,$(BASEDIR))
+BASEDRIVE:=$(firstword $(subst /, ,$(BASENODIR)))
+BASEDIR:=$(subst /cygdrive/$(BASEDRIVE)/,$(BASEDRIVE):/,$(BASEDIR))
+endif
+endif
+else
+BASEDIR=.
+endif
+override DEFAULT_FPCDIR=..
+ifndef FPC
+ifdef PP
+FPC=$(PP)
+endif
+endif
+ifndef FPC
+FPCPROG:=$(strip $(wildcard $(addsuffix /fpc$(SRCEXEEXT),$(SEARCHPATH))))
+ifneq ($(FPCPROG),)
+FPCPROG:=$(firstword $(FPCPROG))
+FPC:=$(shell $(FPCPROG) -PB)
+ifneq ($(findstring Error,$(FPC)),)
+override FPC=ppc386
+endif
+else
+override FPC=ppc386
+endif
+endif
+override FPC:=$(subst $(SRCEXEEXT),,$(FPC))
+override FPC:=$(subst \,/,$(FPC))$(SRCEXEEXT)
+ifndef FPC_VERSION
+FPC_VERSION:=$(shell $(FPC) -iV)
+endif
+export FPC FPC_VERSION
+ifeq ($(findstring 1.0.,$(FPC_VERSION)),)
+COMPILERINFO:=$(shell $(FPC) -iSP -iTP -iSO -iTO)
+ifndef CPU_SOURCE
+CPU_SOURCE:=$(word 1,$(COMPILERINFO))
+endif
+ifndef CPU_TARGET
+CPU_TARGET:=$(word 2,$(COMPILERINFO))
+endif
+ifndef OS_SOURCE
+OS_SOURCE:=$(word 3,$(COMPILERINFO))
+endif
+ifndef OS_TARGET
+OS_TARGET:=$(word 4,$(COMPILERINFO))
+endif
+else
+ifndef CPU_SOURCE
+CPU_SOURCE:=$(shell $(FPC) -iSP)
+endif
+ifndef CPU_TARGET
+CPU_TARGET:=$(shell $(FPC) -iTP)
+endif
+ifndef OS_SOURCE
+OS_SOURCE:=$(shell $(FPC) -iSO)
+endif
+ifndef OS_TARGET
+OS_TARGET:=$(shell $(FPC) -iTO)
+endif
+endif
+FULL_TARGET=$(CPU_TARGET)-$(OS_TARGET)
+FULL_SOURCE=$(CPU_SOURCE)-$(OS_SOURCE)
+ifneq ($(FULL_TARGET),$(FULL_SOURCE))
+CROSSCOMPILE=1
+endif
+ifeq ($(findstring makefile,$(MAKECMDGOALS)),)
+ifeq ($(findstring $(OS_TARGET),$(MAKEFILETARGETS)),)
+$(error The Makefile doesn't support target $(OS_TARGET), please run fpcmake first)
+endif
+endif
+export OS_TARGET OS_SOURCE CPU_TARGET CPU_SOURCE FULL_TARGET FULL_SOURCE CROSSCOMPILE
+ifdef FPCDIR
+override FPCDIR:=$(subst \,/,$(FPCDIR))
+ifeq ($(wildcard $(addprefix $(FPCDIR)/,rtl units)),)
+override FPCDIR=wrong
+endif
+else
+override FPCDIR=wrong
+endif
+ifdef DEFAULT_FPCDIR
+ifeq ($(FPCDIR),wrong)
+override FPCDIR:=$(subst \,/,$(DEFAULT_FPCDIR))
+ifeq ($(wildcard $(addprefix $(FPCDIR)/,rtl units)),)
+override FPCDIR=wrong
+endif
+endif
+endif
+ifeq ($(FPCDIR),wrong)
+ifdef inUnix
+override FPCDIR=/usr/local/lib/fpc/$(FPC_VERSION)
+ifeq ($(wildcard $(FPCDIR)/units),)
+override FPCDIR=/usr/lib/fpc/$(FPC_VERSION)
+endif
+else
+override FPCDIR:=$(subst /$(FPC),,$(firstword $(strip $(wildcard $(addsuffix /$(FPC),$(SEARCHPATH))))))
+override FPCDIR:=$(FPCDIR)/..
+ifeq ($(wildcard $(addprefix $(FPCDIR)/,rtl units)),)
+override FPCDIR:=$(FPCDIR)/..
+ifeq ($(wildcard $(addprefix $(FPCDIR)/,rtl units)),)
+override FPCDIR=c:/pp
+endif
+endif
+endif
+endif
+ifndef CROSSDIR
+CROSSDIR:=$(FPCDIR)/cross/$(FULL_TARGET)
+endif
+ifndef CROSSTARGETDIR
+CROSSTARGETDIR=$(CROSSDIR)/$(FULL_TARGET)
+endif
+ifdef CROSSCOMPILE
+UNITSDIR:=$(wildcard $(CROSSTARGETDIR)/units)
+ifeq ($(UNITSDIR),)
+UNITSDIR:=$(wildcard $(FPCDIR)/units/$(OS_TARGET))
+endif
+else
+UNITSDIR:=$(wildcard $(FPCDIR)/units/$(OS_TARGET))
+endif
+PACKAGESDIR:=$(wildcard $(FPCDIR) $(FPCDIR)/packages/base $(FPCDIR)/packages/extra)
+override TARGET_DIRS+=base extra
+override INSTALL_FPCPACKAGE=y
+ifdef REQUIRE_UNITSDIR
+override UNITSDIR+=$(REQUIRE_UNITSDIR)
+endif
+ifdef REQUIRE_PACKAGESDIR
+override PACKAGESDIR+=$(REQUIRE_PACKAGESDIR)
+endif
+ifdef ZIPINSTALL
+ifeq ($(OS_TARGET),linux)
+UNIXINSTALLDIR=1
+endif
+ifeq ($(OS_TARGET),freebsd)
+UNIXINSTALLDIR=1
+endif
+ifeq ($(OS_TARGET),netbsd)
+UNIXINSTALLDIR=1
+endif
+ifeq ($(OS_TARGET),sunos)
+UNIXINSTALLDIR=1
+endif
+else
+ifeq ($(OS_SOURCE),linux)
+UNIXINSTALLDIR=1
+endif
+ifeq ($(OS_SOURCE),freebsd)
+UNIXINSTALLDIR=1
+endif
+ifeq ($(OS_SOURCE),netbsd)
+UNIXINSTALLDIR=1
+endif
+ifeq ($(OS_TARGET),sunos)
+UNIXINSTALLDIR=1
+endif
+endif
+ifndef INSTALL_PREFIX
+ifdef PREFIX
+INSTALL_PREFIX=$(PREFIX)
+endif
+endif
+ifndef INSTALL_PREFIX
+ifdef UNIXINSTALLDIR
+INSTALL_PREFIX=/usr/local
+else
+ifdef INSTALL_FPCPACKAGE
+INSTALL_BASEDIR:=/pp
+else
+INSTALL_BASEDIR:=/$(PACKAGE_NAME)
+endif
+endif
+endif
+export INSTALL_PREFIX
+ifndef DIST_DESTDIR
+DIST_DESTDIR:=$(BASEDIR)
+endif
+export DIST_DESTDIR
+ifndef INSTALL_BASEDIR
+ifdef UNIXINSTALLDIR
+ifdef INSTALL_FPCPACKAGE
+INSTALL_BASEDIR:=$(INSTALL_PREFIX)/lib/fpc/$(FPC_VERSION)
+else
+INSTALL_BASEDIR:=$(INSTALL_PREFIX)/lib/$(PACKAGE_NAME)
+endif
+else
+INSTALL_BASEDIR:=$(INSTALL_PREFIX)
+endif
+endif
+ifndef INSTALL_BINDIR
+ifdef UNIXINSTALLDIR
+INSTALL_BINDIR:=$(INSTALL_PREFIX)/bin
+else
+INSTALL_BINDIR:=$(INSTALL_BASEDIR)/bin
+ifdef INSTALL_FPCPACKAGE
+INSTALL_BINDIR:=$(INSTALL_BINDIR)/$(OS_TARGET)
+endif
+endif
+endif
+ifndef INSTALL_UNITDIR
+ifdef CROSSCOMPILE
+INSTALL_UNITDIR:=$(INSTALL_BASEDIR)/cross/$(FULL_TARGET)/units
+else
+INSTALL_UNITDIR:=$(INSTALL_BASEDIR)/units/$(OS_TARGET)
+endif
+ifdef INSTALL_FPCPACKAGE
+ifdef PACKAGE_NAME
+INSTALL_UNITDIR:=$(INSTALL_UNITDIR)/$(PACKAGE_NAME)
+endif
+endif
+endif
+ifndef INSTALL_LIBDIR
+ifdef UNIXINSTALLDIR
+INSTALL_LIBDIR:=$(INSTALL_PREFIX)/lib
+else
+INSTALL_LIBDIR:=$(INSTALL_UNITDIR)
+endif
+endif
+ifndef INSTALL_SOURCEDIR
+ifdef UNIXINSTALLDIR
+ifdef INSTALL_FPCPACKAGE
+ifdef BSDhier
+INSTALL_SOURCEDIR:=$(INSTALL_PREFIX)/share/src/fpc-$(FPC_VERSION)/$(PACKAGE_NAME)
+else
+INSTALL_SOURCEDIR:=$(INSTALL_PREFIX)/src/fpc-$(FPC_VERSION)/$(PACKAGE_NAME)
+endif
+else
+ifdef BSDhier
+INSTALL_SOURCEDIR:=$(INSTALL_PREFIX)/share/src/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
+else
+INSTALL_SOURCEDIR:=$(INSTALL_PREFIX)/src/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
+endif
+endif
+else
+ifdef INSTALL_FPCPACKAGE
+INSTALL_SOURCEDIR:=$(INSTALL_BASEDIR)/source/$(PACKAGE_NAME)
+else
+INSTALL_SOURCEDIRL:=$(INSTALL_BASEDIR)/source
+endif
+endif
+endif
+ifndef INSTALL_DOCDIR
+ifdef UNIXINSTALLDIR
+ifdef INSTALL_FPCPACKAGE
+ifdef BSDhier
+INSTALL_DOCDIR:=$(INSTALL_PREFIX)/share/doc/fpc-$(FPC_VERSION)/$(PACKAGE_NAME)
+else
+INSTALL_DOCDIR:=$(INSTALL_PREFIX)/doc/fpc-$(FPC_VERSION)/$(PACKAGE_NAME)
+endif
+else
+ifdef BSDhier
+INSTALL_DOCDIR:=$(INSTALL_PREFIX)/share/doc/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
+else
+INSTALL_DOCDIR:=$(INSTALL_PREFIX)/doc/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
+endif
+endif
+else
+ifdef INSTALL_FPCPACKAGE
+INSTALL_DOCDIR:=$(INSTALL_BASEDIR)/doc/$(PACKAGE_NAME)
+else
+INSTALL_DOCDIR:=$(INSTALL_BASEDIR)/doc
+endif
+endif
+endif
+ifndef INSTALL_EXAMPLEDIR
+ifdef UNIXINSTALLDIR
+ifdef INSTALL_FPCPACKAGE
+ifdef BSDhier
+INSTALL_EXAMPLEDIR:=$(INSTALL_PREFIX)/share/examples/fpc-$(FPC_VERSION)/$(PACKAGE_NAME)
+else
+INSTALL_EXAMPLEDIR:=$(INSTALL_PREFIX)/doc/fpc-$(FPC_VERSION)/examples/$(PACKAGE_NAME)
+endif
+else
+ifdef BSDhier
+INSTALL_EXAMPLEDIR:=$(INSTALL_PREFIX)/share/examples/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
+else
+INSTALL_EXAMPLEDIR:=$(INSTALL_PREFIX)/doc/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
+endif
+endif
+else
+ifdef INSTALL_FPCPACKAGE
+INSTALL_EXAMPLEDIR:=$(INSTALL_BASEDIR)/examples/$(PACKAGE_NAME)
+else
+INSTALL_EXAMPLEDIR:=$(INSTALL_BASEDIR)/examples
+endif
+endif
+endif
+ifndef INSTALL_DATADIR
+INSTALL_DATADIR=$(INSTALL_BASEDIR)
+endif
+ifdef CROSSCOMPILE
+ifndef CROSSBINDIR
+CROSSBINDIR:=$(wildcard $(CROSSTARGETDIR)/bin/$(FULL_SOURCE))
+ifeq ($(CROSSBINDIR),)
+CROSSBINDIR:=$(wildcard $(INSTALL_BASEDIR)/cross/$(FULL_TARGET)/bin/$(FULL_SOURCE))
+endif
+endif
+else
+CROSSBINDIR=
+endif
+LOADEREXT=.as
+EXEEXT=.exe
+PPLEXT=.ppl
+PPUEXT=.ppu
+OEXT=.o
+ASMEXT=.s
+SMARTEXT=.sl
+STATICLIBEXT=.a
+SHAREDLIBEXT=.so
+STATICLIBPREFIX=libp
+RSTEXT=.rst
+FPCMADE=fpcmade
+ifeq ($(OS_TARGET),go32v1)
+PPUEXT=.pp1
+OEXT=.o1
+ASMEXT=.s1
+SMARTEXT=.sl1
+STATICLIBEXT=.a1
+SHAREDLIBEXT=.so1
+STATICLIBPREFIX=
+FPCMADE=fpcmade.v1
+PACKAGESUFFIX=v1
+endif
+ifeq ($(OS_TARGET),go32v2)
+STATICLIBPREFIX=
+FPCMADE=fpcmade.dos
+ZIPSUFFIX=go32
+endif
+ifeq ($(OS_TARGET),linux)
+EXEEXT=
+HASSHAREDLIB=1
+FPCMADE=fpcmade.lnx
+ZIPSUFFIX=linux
+endif
+ifeq ($(OS_TARGET),freebsd)
+EXEEXT=
+HASSHAREDLIB=1
+FPCMADE=fpcmade.freebsd
+ZIPSUFFIX=freebsd
+endif
+ifeq ($(OS_TARGET),netbsd)
+EXEEXT=
+HASSHAREDLIB=1
+FPCMADE=fpcmade.netbsd
+ZIPSUFFIX=netbsd
+endif
+ifeq ($(OS_TARGET),win32)
+PPUEXT=.ppw
+OEXT=.ow
+ASMEXT=.sw
+SMARTEXT=.slw
+STATICLIBEXT=.aw
+SHAREDLIBEXT=.dll
+FPCMADE=fpcmade.w32
+ZIPSUFFIX=w32
+endif
+ifeq ($(OS_TARGET),os2)
+PPUEXT=.ppo
+ASMEXT=.so2
+OEXT=.oo2
+AOUTEXT=.out
+SMARTEXT=.so
+STATICLIBEXT=.ao2
+SHAREDLIBEXT=.dll
+FPCMADE=fpcmade.os2
+ZIPSUFFIX=emx
+endif
+ifeq ($(OS_TARGET),amiga)
+EXEEXT=
+PPUEXT=.ppa
+ASMEXT=.asm
+OEXT=.o
+SMARTEXT=.sl
+STATICLIBEXT=.a
+SHAREDLIBEXT=.library
+FPCMADE=fpcmade.amg
+endif
+ifeq ($(OS_TARGET),atari)
+PPUEXT=.ppt
+ASMEXT=.s
+OEXT=.o
+SMARTEXT=.sl
+STATICLIBEXT=.a
+EXEEXT=.ttp
+FPCMADE=fpcmade.ata
+endif
+ifeq ($(OS_TARGET),beos)
+PPUEXT=.ppu
+ASMEXT=.s
+OEXT=.o
+SMARTEXT=.sl
+STATICLIBEXT=.a
+EXEEXT=
+FPCMADE=fpcmade.be
+ZIPSUFFIX=be
+endif
+ifeq ($(OS_TARGET),sunos)
+PPUEXT=.ppu
+ASMEXT=.s
+OEXT=.o
+SMARTEXT=.sl
+STATICLIBEXT=.a
+EXEEXT=
+FPCMADE=fpcmade.sun
+ZIPSUFFIX=sun
+endif
+ifeq ($(OS_TARGET),qnx)
+PPUEXT=.ppu
+ASMEXT=.s
+OEXT=.o
+SMARTEXT=.sl
+STATICLIBEXT=.a
+EXEEXT=
+FPCMADE=fpcmade.qnx
+ZIPSUFFIX=qnx
+endif
+ifndef ECHO
+ECHO:=$(strip $(wildcard $(addsuffix /gecho$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(ECHO),)
+ECHO:=$(strip $(wildcard $(addsuffix /echo$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(ECHO),)
+ECHO=
+else
+ECHO:=$(firstword $(ECHO))
+endif
+else
+ECHO:=$(firstword $(ECHO))
+endif
+endif
+export ECHO
+ifndef DATE
+DATE:=$(strip $(wildcard $(addsuffix /gdate$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(DATE),)
+DATE:=$(strip $(wildcard $(addsuffix /date$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(DATE),)
+DATE=
+else
+DATE:=$(firstword $(DATE))
+endif
+else
+DATE:=$(firstword $(DATE))
+endif
+endif
+export DATE
+ifndef GINSTALL
+GINSTALL:=$(strip $(wildcard $(addsuffix /ginstall$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(GINSTALL),)
+GINSTALL:=$(strip $(wildcard $(addsuffix /install$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(GINSTALL),)
+GINSTALL=
+else
+GINSTALL:=$(firstword $(GINSTALL))
+endif
+else
+GINSTALL:=$(firstword $(GINSTALL))
+endif
+endif
+export GINSTALL
+ifndef CPPROG
+CPPROG:=$(strip $(wildcard $(addsuffix /cp$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(CPPROG),)
+CPPROG=
+else
+CPPROG:=$(firstword $(CPPROG))
+endif
+endif
+export CPPROG
+ifndef RMPROG
+RMPROG:=$(strip $(wildcard $(addsuffix /rm$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(RMPROG),)
+RMPROG=
+else
+RMPROG:=$(firstword $(RMPROG))
+endif
+endif
+export RMPROG
+ifndef MVPROG
+MVPROG:=$(strip $(wildcard $(addsuffix /mv$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(MVPROG),)
+MVPROG=
+else
+MVPROG:=$(firstword $(MVPROG))
+endif
+endif
+export MVPROG
+ifndef ECHOREDIR
+ECHOREDIR:=$(subst /,$(PATHSEP),$(ECHO))
+endif
+ifndef COPY
+COPY:=$(CPPROG) -fp
+endif
+ifndef COPYTREE
+COPYTREE:=$(CPPROG) -rfp
+endif
+ifndef MOVE
+MOVE:=$(MVPROG) -f
+endif
+ifndef DEL
+DEL:=$(RMPROG) -f
+endif
+ifndef DELTREE
+DELTREE:=$(RMPROG) -rf
+endif
+ifndef INSTALL
+ifdef inUnix
+INSTALL:=$(GINSTALL) -c -m 644
+else
+INSTALL:=$(COPY)
+endif
+endif
+ifndef INSTALLEXE
+ifdef inUnix
+INSTALLEXE:=$(GINSTALL) -c -m 755
+else
+INSTALLEXE:=$(COPY)
+endif
+endif
+ifndef MKDIR
+MKDIR:=$(GINSTALL) -m 755 -d
+endif
+export ECHOREDIR COPY COPYTREE MOVE DEL DELTREE INSTALL INSTALLEXE MKDIR
+ifndef PPUMOVE
+PPUMOVE:=$(strip $(wildcard $(addsuffix /ppumove$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(PPUMOVE),)
+PPUMOVE=
+else
+PPUMOVE:=$(firstword $(PPUMOVE))
+endif
+endif
+export PPUMOVE
+ifndef FPCMAKE
+FPCMAKE:=$(strip $(wildcard $(addsuffix /fpcmake$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(FPCMAKE),)
+FPCMAKE=
+else
+FPCMAKE:=$(firstword $(FPCMAKE))
+endif
+endif
+export FPCMAKE
+ifndef ZIPPROG
+ZIPPROG:=$(strip $(wildcard $(addsuffix /zip$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(ZIPPROG),)
+ZIPPROG=
+else
+ZIPPROG:=$(firstword $(ZIPPROG))
+endif
+endif
+export ZIPPROG
+ifndef TARPROG
+TARPROG:=$(strip $(wildcard $(addsuffix /tar$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(TARPROG),)
+TARPROG=
+else
+TARPROG:=$(firstword $(TARPROG))
+endif
+endif
+export TARPROG
+ASNAME=as
+LDNAME=ld
+ARNAME=ar
+RCNAME=rc
+ifeq ($(OS_TARGET),win32)
+ASNAME=asw
+LDNAME=ldw
+ARNAME=arw
+endif
+ifndef ASPROG
+ifdef CROSSBINDIR
+ASPROG=$(CROSSBINDIR)/$(ASNAME)$(SRCEXEEXT)
+else
+ASPROG=$(ASNAME)
+endif
+endif
+ifndef LDPROG
+ifdef CROSSBINDIR
+LDPROG=$(CROSSBINDIR)/$(LDNAME)$(SRCEXEEXT)
+else
+LDPROG=$(LDNAME)
+endif
+endif
+ifndef RCPROG
+ifdef CROSSBINDIR
+RCPROG=$(CROSSBINDIR)/$(RCNAME)$(SRCEXEEXT)
+else
+RCPROG=$(RCNAME)
+endif
+endif
+ifndef ARPROG
+ifdef CROSSBINDIR
+ARPROG=$(CROSSBINDIR)/$(ARNAME)$(SRCEXEEXT)
+else
+ARPROG=$(ARNAME)
+endif
+endif
+AS=$(ASPROG)
+LD=$(LDPROG)
+RC=$(RCPROG)
+AR=$(ARPROG)
+PPAS=ppas$(BATCHEXT)
+ifdef inUnix
+LDCONFIG=ldconfig
+else
+LDCONFIG=
+endif
+ifdef DATE
+DATESTR:=$(shell $(DATE) +%Y%m%d)
+else
+DATESTR=
+endif
+ifndef UPXPROG
+ifeq ($(OS_TARGET),go32v2)
+UPXPROG:=1
+endif
+ifeq ($(OS_TARGET),win32)
+UPXPROG:=1
+endif
+ifdef UPXPROG
+UPXPROG:=$(strip $(wildcard $(addsuffix /upx$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(UPXPROG),)
+UPXPROG=
+else
+UPXPROG:=$(firstword $(UPXPROG))
+endif
+else
+UPXPROG=
+endif
+endif
+export UPXPROG
+ZIPOPT=-9
+ZIPEXT=.zip
+ifeq ($(USETAR),bz2)
+TAROPT=vI
+TAREXT=.tar.bz2
+else
+TAROPT=vz
+TAREXT=.tar.gz
+endif
+ifndef NOCPUDEF
+override FPCOPTDEF=$(CPU_TARGET)
+endif
+ifneq ($(OS_TARGET),$(OS_SOURCE))
+override FPCOPT+=-T$(OS_TARGET)
+endif
+ifdef UNITDIR
+override FPCOPT+=$(addprefix -Fu,$(UNITDIR))
+endif
+ifdef LIBDIR
+override FPCOPT+=$(addprefix -Fl,$(LIBDIR))
+endif
+ifdef OBJDIR
+override FPCOPT+=$(addprefix -Fo,$(OBJDIR))
+endif
+ifdef INCDIR
+override FPCOPT+=$(addprefix -Fi,$(INCDIR))
+endif
+ifdef LINKSMART
+override FPCOPT+=-XX
+endif
+ifdef CREATESMART
+override FPCOPT+=-CX
+endif
+ifdef DEBUG
+override FPCOPT+=-gl
+override FPCOPTDEF+=DEBUG
+endif
+ifdef RELEASE
+ifeq ($(CPU_TARGET),i386)
+FPCCPUOPT:=-OG2p3
+else
+FPCCPUOPT:=
+endif
+override FPCOPT+=-Xs $(FPCCPUOPT) -n
+override FPCOPTDEF+=RELEASE
+endif
+ifdef STRIP
+override FPCOPT+=-Xs
+endif
+ifdef OPTIMIZE
+ifeq ($(CPU_TARGET),i386)
+override FPCOPT+=-OG2p3
+endif
+endif
+ifdef VERBOSE
+override FPCOPT+=-vwni
+endif
+ifdef COMPILER_OPTIONS
+override FPCOPT+=$(COMPILER_OPTIONS)
+endif
+ifdef COMPILER_UNITDIR
+override FPCOPT+=$(addprefix -Fu,$(COMPILER_UNITDIR))
+endif
+ifdef COMPILER_LIBRARYDIR
+override FPCOPT+=$(addprefix -Fl,$(COMPILER_LIBRARYDIR))
+endif
+ifdef COMPILER_OBJECTDIR
+override FPCOPT+=$(addprefix -Fo,$(COMPILER_OBJECTDIR))
+endif
+ifdef COMPILER_INCLUDEDIR
+override FPCOPT+=$(addprefix -Fi,$(COMPILER_INCLUDEDIR))
+endif
+ifdef CROSSBINDIR
+override FPCOPT+=-FD$(CROSSBINDIR)
+endif
+ifdef COMPILER_TARGETDIR
+override FPCOPT+=-FE$(COMPILER_TARGETDIR)
+ifeq ($(COMPILER_TARGETDIR),.)
+override TARGETDIRPREFIX=
+else
+override TARGETDIRPREFIX=$(COMPILER_TARGETDIR)/
+endif
+endif
+ifdef COMPILER_UNITTARGETDIR
+override FPCOPT+=-FU$(COMPILER_UNITTARGETDIR)
+ifeq ($(COMPILER_UNITTARGETDIR),.)
+override UNITTARGETDIRPREFIX=
+else
+override UNITTARGETDIRPREFIX=$(COMPILER_UNITTARGETDIR)/
+endif
+else
+ifdef COMPILER_TARGETDIR
+override COMPILER_UNITTARGETDIR=$(COMPILER_TARGETDIR)
+override UNITTARGETDIRPREFIX=$(TARGETDIRPREFIX)
+endif
+endif
+ifdef OPT
+override FPCOPT+=$(OPT)
+endif
+ifdef FPCOPTDEF
+override FPCOPT+=$(addprefix -d,$(FPCOPTDEF))
+endif
+ifdef CFGFILE
+override FPCOPT+=@$(CFGFILE)
+endif
+ifdef USEENV
+override FPCEXTCMD:=$(FPCOPT)
+override FPCOPT:=!FPCEXTCMD
+export FPCEXTCMD
+endif
+override COMPILER:=$(FPC) $(FPCOPT)
+ifeq (,$(findstring -s ,$(COMPILER)))
+EXECPPAS=
+else
+ifeq ($(OS_SOURCE),$(OS_TARGET))
+EXECPPAS:=@$(PPAS)
+endif
+endif
+ifdef TARGET_RSTS
+override RSTFILES=$(addsuffix $(RSTEXT),$(TARGET_RSTS))
+override CLEANRSTFILES+=$(RSTFILES)
+endif
+.PHONY: fpc_clean fpc_cleanall fpc_distclean
+ifdef EXEFILES
+override CLEANEXEFILES:=$(addprefix $(TARGETDIRPREFIX),$(CLEANEXEFILES))
+endif
+ifdef CLEAN_UNITS
+override CLEANPPUFILES+=$(addsuffix $(PPUEXT),$(CLEAN_UNITS))
+endif
+ifdef CLEANPPUFILES
+override CLEANPPULINKFILES:=$(subst $(PPUEXT),$(OEXT),$(CLEANPPUFILES)) $(addprefix $(STATICLIBPREFIX),$(subst $(PPUEXT),$(STATICLIBEXT),$(CLEANPPUFILES)))
+override CLEANPPUFILES:=$(addprefix $(UNITTARGETDIRPREFIX),$(CLEANPPUFILES))
+override CLEANPPULINKFILES:=$(wildcard $(addprefix $(UNITTARGETDIRPREFIX),$(CLEANPPULINKFILES)))
+endif
+fpc_clean: $(CLEANTARGET)
+ifdef CLEANEXEFILES
+	-$(DEL) $(CLEANEXEFILES)
+endif
+ifdef CLEANPPUFILES
+	-$(DEL) $(CLEANPPUFILES)
+endif
+ifneq ($(CLEANPPULINKFILES),)
+	-$(DEL) $(CLEANPPULINKFILES)
+endif
+ifdef CLEANRSTFILES
+	-$(DEL) $(addprefix $(UNITTARGETDIRPREFIX),$(CLEANRSTFILES))
+endif
+ifdef CLEAN_FILES
+	-$(DEL) $(CLEAN_FILES)
+endif
+ifdef LIB_NAME
+	-$(DEL) $(LIB_NAME) $(LIB_FULLNAME)
+endif
+	-$(DEL) $(FPCMADE) Package.fpc $(PPAS) script.res link.res $(FPCEXTFILE) $(REDIRFILE)
+fpc_distclean: clean
+ifdef COMPILER_UNITTARGETDIR
+TARGETDIRCLEAN=fpc_clean
+endif
+fpc_cleanall: $(CLEANTARGET) $(TARGETDIRCLEAN)
+ifdef CLEANEXEFILES
+	-$(DEL) $(CLEANEXEFILES)
+endif
+	-$(DEL) *$(OEXT) *$(PPUEXT) *$(RSTEXT) *$(ASMEXT) *$(STATICLIBEXT) *$(SHAREDLIBEXT) *$(PPLEXT)
+	-$(DELTREE) *$(SMARTEXT)
+	-$(DEL) $(FPCMADE) Package.fpc $(PPAS) script.res link.res $(FPCEXTFILE) $(REDIRFILE)
+ifdef AOUTEXT
+	-$(DEL) *$(AOUTEXT)
+endif
+.PHONY: fpc_baseinfo
+override INFORULES+=fpc_baseinfo
+fpc_baseinfo:
+	@$(ECHO)
+	@$(ECHO)  == Package info ==
+	@$(ECHO)  Package Name..... $(PACKAGE_NAME)
+	@$(ECHO)  Package Version.. $(PACKAGE_VERSION)
+	@$(ECHO)
+	@$(ECHO)  == Configuration info ==
+	@$(ECHO)
+	@$(ECHO)  FPC.......... $(FPC)
+	@$(ECHO)  FPC Version.. $(FPC_VERSION)
+	@$(ECHO)  Source CPU... $(CPU_SOURCE)
+	@$(ECHO)  Target CPU... $(CPU_TARGET)
+	@$(ECHO)  Source OS.... $(OS_SOURCE)
+	@$(ECHO)  Target OS.... $(OS_TARGET)
+	@$(ECHO)  Full Target.. $(FULL_SOURCE)
+	@$(ECHO)  Full Source.. $(FULL_TARGET)
+	@$(ECHO)
+	@$(ECHO)  == Directory info ==
+	@$(ECHO)
+	@$(ECHO)  Required pkgs... $(REQUIRE_PACKAGES)
+	@$(ECHO)
+	@$(ECHO)  Basedir......... $(BASEDIR)
+	@$(ECHO)  FPCDir.......... $(FPCDIR)
+	@$(ECHO)  CrossBinDir..... $(CROSSBINDIR)
+	@$(ECHO)  UnitsDir........ $(UNITSDIR)
+	@$(ECHO)  PackagesDir..... $(PACKAGESDIR)
+	@$(ECHO)
+	@$(ECHO)  GCC library..... $(GCCLIBDIR)
+	@$(ECHO)  Other library... $(OTHERLIBDIR)
+	@$(ECHO)
+	@$(ECHO)  == Tools info ==
+	@$(ECHO)
+	@$(ECHO)  As........ $(AS)
+	@$(ECHO)  Ld........ $(LD)
+	@$(ECHO)  Ar........ $(AR)
+	@$(ECHO)  Rc........ $(RC)
+	@$(ECHO)
+	@$(ECHO)  Mv........ $(MVPROG)
+	@$(ECHO)  Cp........ $(CPPROG)
+	@$(ECHO)  Rm........ $(RMPROG)
+	@$(ECHO)  GInstall.. $(GINSTALL)
+	@$(ECHO)  Echo...... $(ECHO)
+	@$(ECHO)  Date...... $(DATE)
+	@$(ECHO)  FPCMake... $(FPCMAKE)
+	@$(ECHO)  PPUMove... $(PPUMOVE)
+	@$(ECHO)  Upx....... $(UPXPROG)
+	@$(ECHO)  Zip....... $(ZIPPROG)
+	@$(ECHO)
+	@$(ECHO)  == Object info ==
+	@$(ECHO)
+	@$(ECHO)  Target Loaders........ $(TARGET_LOADERS)
+	@$(ECHO)  Target Units.......... $(TARGET_UNITS)
+	@$(ECHO)  Target Implicit Units. $(TARGET_IMPLICITUNITS)
+	@$(ECHO)  Target Programs....... $(TARGET_PROGRAMS)
+	@$(ECHO)  Target Dirs........... $(TARGET_DIRS)
+	@$(ECHO)  Target Examples....... $(TARGET_EXAMPLES)
+	@$(ECHO)  Target ExampleDirs.... $(TARGET_EXAMPLEDIRS)
+	@$(ECHO)
+	@$(ECHO)  Clean Units......... $(CLEAN_UNITS)
+	@$(ECHO)  Clean Files......... $(CLEAN_FILES)
+	@$(ECHO)
+	@$(ECHO)  Install Units....... $(INSTALL_UNITS)
+	@$(ECHO)  Install Files....... $(INSTALL_FILES)
+	@$(ECHO)
+	@$(ECHO)  == Install info ==
+	@$(ECHO)
+	@$(ECHO)  DateStr.............. $(DATESTR)
+	@$(ECHO)  ZipPrefix............ $(ZIPPREFIX)
+	@$(ECHO)  ZipSuffix............ $(ZIPSUFFIX)
+	@$(ECHO)  Install FPC Package.. $(INSTALL_FPCPACKAGE)
+	@$(ECHO)
+	@$(ECHO)  Install base dir..... $(INSTALL_BASEDIR)
+	@$(ECHO)  Install binary dir... $(INSTALL_BINDIR)
+	@$(ECHO)  Install library dir.. $(INSTALL_LIBDIR)
+	@$(ECHO)  Install units dir.... $(INSTALL_UNITDIR)
+	@$(ECHO)  Install source dir... $(INSTALL_SOURCEDIR)
+	@$(ECHO)  Install doc dir...... $(INSTALL_DOCDIR)
+	@$(ECHO)  Install example dir.. $(INSTALL_EXAMPLEDIR)
+	@$(ECHO)  Install data dir..... $(INSTALL_DATADIR)
+	@$(ECHO)
+	@$(ECHO)  Dist destination dir. $(DIST_DESTDIR)
+	@$(ECHO)  Dist zip name........ $(DIST_ZIPNAME)
+	@$(ECHO)
+.PHONY: fpc_info
+fpc_info: $(INFORULES)
+.PHONY: fpc_makefile fpc_makefiles fpc_makefile_sub1 fpc_makefile_sub2 \
+	fpc_makefile_dirs
+fpc_makefile:
+	$(FPCMAKE) -w -T$(OS_TARGET) Makefile.fpc
+fpc_makefile_sub1:
+ifdef TARGET_DIRS
+	$(FPCMAKE) -w -T$(OS_TARGET) $(addsuffix /Makefile.fpc,$(TARGET_DIRS))
+endif
+ifdef TARGET_EXAMPLEDIRS
+	$(FPCMAKE) -w -T$(OS_TARGET) $(addsuffix /Makefile.fpc,$(TARGET_EXAMPLEDIRS))
+endif
+fpc_makefile_sub2: $(addsuffix _makefile_dirs,$(TARGET_DIRS) $(TARGET_EXAMPLEDIRS))
+fpc_makefile_dirs: fpc_makefile_sub1 fpc_makefile_sub2
+fpc_makefiles: fpc_makefile fpc_makefile_dirs
+TARGET_DIRS_BASE=1
+TARGET_DIRS_EXTRA=1
+ifdef TARGET_DIRS_BASE
+base_all:
+	$(MAKE) -C base all
+base_debug:
+	$(MAKE) -C base debug
+base_smart:
+	$(MAKE) -C base smart
+base_release:
+	$(MAKE) -C base release
+base_examples:
+	$(MAKE) -C base examples
+base_shared:
+	$(MAKE) -C base shared
+base_install:
+	$(MAKE) -C base install
+base_sourceinstall:
+	$(MAKE) -C base sourceinstall
+base_exampleinstall:
+	$(MAKE) -C base exampleinstall
+base_distinstall:
+	$(MAKE) -C base distinstall
+base_zipinstall:
+	$(MAKE) -C base zipinstall
+base_zipsourceinstall:
+	$(MAKE) -C base zipsourceinstall
+base_zipexampleinstall:
+	$(MAKE) -C base zipexampleinstall
+base_zipdistinstall:
+	$(MAKE) -C base zipdistinstall
+base_clean:
+	$(MAKE) -C base clean
+base_distclean:
+	$(MAKE) -C base distclean
+base_cleanall:
+	$(MAKE) -C base cleanall
+base_info:
+	$(MAKE) -C base info
+base_makefiles:
+	$(MAKE) -C base makefiles
+base:
+	$(MAKE) -C base all
+.PHONY: base_all base_debug base_smart base_release base_examples base_shared base_install base_sourceinstall base_exampleinstall base_distinstall base_zipinstall base_zipsourceinstall base_zipexampleinstall base_zipdistinstall base_clean base_distclean base_cleanall base_info base_makefiles base
+endif
+ifdef TARGET_DIRS_EXTRA
+extra_all:
+	$(MAKE) -C extra all
+extra_debug:
+	$(MAKE) -C extra debug
+extra_smart:
+	$(MAKE) -C extra smart
+extra_release:
+	$(MAKE) -C extra release
+extra_examples:
+	$(MAKE) -C extra examples
+extra_shared:
+	$(MAKE) -C extra shared
+extra_install:
+	$(MAKE) -C extra install
+extra_sourceinstall:
+	$(MAKE) -C extra sourceinstall
+extra_exampleinstall:
+	$(MAKE) -C extra exampleinstall
+extra_distinstall:
+	$(MAKE) -C extra distinstall
+extra_zipinstall:
+	$(MAKE) -C extra zipinstall
+extra_zipsourceinstall:
+	$(MAKE) -C extra zipsourceinstall
+extra_zipexampleinstall:
+	$(MAKE) -C extra zipexampleinstall
+extra_zipdistinstall:
+	$(MAKE) -C extra zipdistinstall
+extra_clean:
+	$(MAKE) -C extra clean
+extra_distclean:
+	$(MAKE) -C extra distclean
+extra_cleanall:
+	$(MAKE) -C extra cleanall
+extra_info:
+	$(MAKE) -C extra info
+extra_makefiles:
+	$(MAKE) -C extra makefiles
+extra:
+	$(MAKE) -C extra all
+.PHONY: extra_all extra_debug extra_smart extra_release extra_examples extra_shared extra_install extra_sourceinstall extra_exampleinstall extra_distinstall extra_zipinstall extra_zipsourceinstall extra_zipexampleinstall extra_zipdistinstall extra_clean extra_distclean extra_cleanall extra_info extra_makefiles extra
+endif
+all: $(addsuffix _all,$(TARGET_DIRS))
+debug: $(addsuffix _debug,$(TARGET_DIRS))
+smart: $(addsuffix _smart,$(TARGET_DIRS))
+release: $(addsuffix _release,$(TARGET_DIRS))
+examples: $(addsuffix _examples,$(TARGET_DIRS))
+shared: $(addsuffix _shared,$(TARGET_DIRS))
+install: $(addsuffix _install,$(TARGET_DIRS))
+sourceinstall: $(addsuffix _sourceinstall,$(TARGET_DIRS))
+exampleinstall: $(addsuffix _exampleinstall,$(TARGET_DIRS))
+distinstall: $(addsuffix _distinstall,$(TARGET_DIRS))
+zipinstall: $(addsuffix _zipinstall,$(TARGET_DIRS))
+zipsourceinstall: $(addsuffix _zipsourceinstall,$(TARGET_DIRS))
+zipexampleinstall: $(addsuffix _zipexampleinstall,$(TARGET_DIRS))
+zipdistinstall: $(addsuffix _zipdistinstall,$(TARGET_DIRS))
+clean: $(addsuffix _clean,$(TARGET_DIRS))
+distclean: $(addsuffix _distclean,$(TARGET_DIRS))
+cleanall: $(addsuffix _cleanall,$(TARGET_DIRS))
+info: fpc_info
+makefiles: fpc_makefiles $(addsuffix _makefiles,$(TARGET_DIRS))
+.PHONY: all debug smart release examples shared install sourceinstall exampleinstall distinstall zipinstall zipsourceinstall zipexampleinstall zipdistinstall clean distclean cleanall info makefiles
+ifneq ($(wildcard fpcmake.loc),)
+include fpcmake.loc
+endif

+ 12 - 0
packages/Makefile.fpc

@@ -0,0 +1,12 @@
+#
+#   Makefile.fpc for Free Pascal Packages
+#
+
+[target]
+dirs=base extra
+
+[install]
+fpcpackage=y
+
+[default]
+fpcdir=..

+ 1419 - 0
packages/base/Makefile

@@ -0,0 +1,1419 @@
+#
+# Don't edit, this file is generated by FPCMake Version 1.1 [2002/01/29]
+#
+default: all
+MAKEFILETARGETS=linux go32v2 win32 os2 freebsd beos netbsd amiga atari sunos qnx
+override PATH:=$(subst \,/,$(PATH))
+ifeq ($(findstring ;,$(PATH)),)
+inUnix=1
+SEARCHPATH:=$(filter-out .,$(subst :, ,$(PATH)))
+else
+SEARCHPATH:=$(subst ;, ,$(PATH))
+endif
+PWD:=$(strip $(wildcard $(addsuffix /pwd.exe,$(SEARCHPATH))))
+ifeq ($(PWD),)
+PWD:=$(strip $(wildcard $(addsuffix /pwd,$(SEARCHPATH))))
+ifeq ($(PWD),)
+$(error You need the GNU utils package to use this Makefile)
+else
+PWD:=$(firstword $(PWD))
+SRCEXEEXT=
+endif
+else
+PWD:=$(firstword $(PWD))
+SRCEXEEXT=.exe
+endif
+ifndef inUnix
+ifeq ($(OS),Windows_NT)
+inWinNT=1
+else
+ifdef OS2_SHELL
+inOS2=1
+endif
+endif
+else
+ifneq ($(findstring cygwin,$(MACHTYPE)),)
+inCygWin=1
+endif
+endif
+ifeq ($(OS_TARGET),freebsd)
+BSDhier=1
+endif
+ifeq ($(OS_TARGET),netbsd)
+BSDhier=1
+endif
+ifdef inUnix
+BATCHEXT=.sh
+else
+ifdef inOS2
+BATCHEXT=.cmd
+else
+BATCHEXT=.bat
+endif
+endif
+ifdef inUnix
+PATHSEP=/
+else
+PATHSEP:=$(subst /,\,/)
+endif
+ifdef PWD
+BASEDIR:=$(subst \,/,$(shell $(PWD)))
+ifdef inCygWin
+ifneq ($(findstring /cygdrive/,$(BASEDIR)),)
+BASENODIR:=$(patsubst /cygdrive%,%,$(BASEDIR))
+BASEDRIVE:=$(firstword $(subst /, ,$(BASENODIR)))
+BASEDIR:=$(subst /cygdrive/$(BASEDRIVE)/,$(BASEDRIVE):/,$(BASEDIR))
+endif
+endif
+else
+BASEDIR=.
+endif
+override DEFAULT_FPCDIR=../..
+ifndef FPC
+ifdef PP
+FPC=$(PP)
+endif
+endif
+ifndef FPC
+FPCPROG:=$(strip $(wildcard $(addsuffix /fpc$(SRCEXEEXT),$(SEARCHPATH))))
+ifneq ($(FPCPROG),)
+FPCPROG:=$(firstword $(FPCPROG))
+FPC:=$(shell $(FPCPROG) -PB)
+ifneq ($(findstring Error,$(FPC)),)
+override FPC=ppc386
+endif
+else
+override FPC=ppc386
+endif
+endif
+override FPC:=$(subst $(SRCEXEEXT),,$(FPC))
+override FPC:=$(subst \,/,$(FPC))$(SRCEXEEXT)
+ifndef FPC_VERSION
+FPC_VERSION:=$(shell $(FPC) -iV)
+endif
+export FPC FPC_VERSION
+ifeq ($(findstring 1.0.,$(FPC_VERSION)),)
+COMPILERINFO:=$(shell $(FPC) -iSP -iTP -iSO -iTO)
+ifndef CPU_SOURCE
+CPU_SOURCE:=$(word 1,$(COMPILERINFO))
+endif
+ifndef CPU_TARGET
+CPU_TARGET:=$(word 2,$(COMPILERINFO))
+endif
+ifndef OS_SOURCE
+OS_SOURCE:=$(word 3,$(COMPILERINFO))
+endif
+ifndef OS_TARGET
+OS_TARGET:=$(word 4,$(COMPILERINFO))
+endif
+else
+ifndef CPU_SOURCE
+CPU_SOURCE:=$(shell $(FPC) -iSP)
+endif
+ifndef CPU_TARGET
+CPU_TARGET:=$(shell $(FPC) -iTP)
+endif
+ifndef OS_SOURCE
+OS_SOURCE:=$(shell $(FPC) -iSO)
+endif
+ifndef OS_TARGET
+OS_TARGET:=$(shell $(FPC) -iTO)
+endif
+endif
+FULL_TARGET=$(CPU_TARGET)-$(OS_TARGET)
+FULL_SOURCE=$(CPU_SOURCE)-$(OS_SOURCE)
+ifneq ($(FULL_TARGET),$(FULL_SOURCE))
+CROSSCOMPILE=1
+endif
+ifeq ($(findstring makefile,$(MAKECMDGOALS)),)
+ifeq ($(findstring $(OS_TARGET),$(MAKEFILETARGETS)),)
+$(error The Makefile doesn't support target $(OS_TARGET), please run fpcmake first)
+endif
+endif
+export OS_TARGET OS_SOURCE CPU_TARGET CPU_SOURCE FULL_TARGET FULL_SOURCE CROSSCOMPILE
+ifdef FPCDIR
+override FPCDIR:=$(subst \,/,$(FPCDIR))
+ifeq ($(wildcard $(addprefix $(FPCDIR)/,rtl units)),)
+override FPCDIR=wrong
+endif
+else
+override FPCDIR=wrong
+endif
+ifdef DEFAULT_FPCDIR
+ifeq ($(FPCDIR),wrong)
+override FPCDIR:=$(subst \,/,$(DEFAULT_FPCDIR))
+ifeq ($(wildcard $(addprefix $(FPCDIR)/,rtl units)),)
+override FPCDIR=wrong
+endif
+endif
+endif
+ifeq ($(FPCDIR),wrong)
+ifdef inUnix
+override FPCDIR=/usr/local/lib/fpc/$(FPC_VERSION)
+ifeq ($(wildcard $(FPCDIR)/units),)
+override FPCDIR=/usr/lib/fpc/$(FPC_VERSION)
+endif
+else
+override FPCDIR:=$(subst /$(FPC),,$(firstword $(strip $(wildcard $(addsuffix /$(FPC),$(SEARCHPATH))))))
+override FPCDIR:=$(FPCDIR)/..
+ifeq ($(wildcard $(addprefix $(FPCDIR)/,rtl units)),)
+override FPCDIR:=$(FPCDIR)/..
+ifeq ($(wildcard $(addprefix $(FPCDIR)/,rtl units)),)
+override FPCDIR=c:/pp
+endif
+endif
+endif
+endif
+ifndef CROSSDIR
+CROSSDIR:=$(FPCDIR)/cross/$(FULL_TARGET)
+endif
+ifndef CROSSTARGETDIR
+CROSSTARGETDIR=$(CROSSDIR)/$(FULL_TARGET)
+endif
+ifdef CROSSCOMPILE
+UNITSDIR:=$(wildcard $(CROSSTARGETDIR)/units)
+ifeq ($(UNITSDIR),)
+UNITSDIR:=$(wildcard $(FPCDIR)/units/$(OS_TARGET))
+endif
+else
+UNITSDIR:=$(wildcard $(FPCDIR)/units/$(OS_TARGET))
+endif
+PACKAGESDIR:=$(wildcard $(FPCDIR) $(FPCDIR)/packages/base $(FPCDIR)/packages/extra)
+override TARGET_DIRS+=paszlib regexpr
+ifeq ($(OS_TARGET),linux)
+override TARGET_DIRS+=inet gdbint libasync mysql ibase postgres oracle
+endif
+ifeq ($(OS_TARGET),go32v2)
+override TARGET_DIRS+=gdbint
+endif
+ifeq ($(OS_TARGET),win32)
+override TARGET_DIRS+=inet gdbint mysql ibase
+endif
+ifeq ($(OS_TARGET),freebsd)
+override TARGET_DIRS+=inet gdbint libasync mysql ibase postgres oracle
+endif
+ifeq ($(OS_TARGET),netbsd)
+override TARGET_DIRS+=inet gdbint libasync mysql ibase postgres oracle
+endif
+override INSTALL_FPCPACKAGE=y
+ifdef REQUIRE_UNITSDIR
+override UNITSDIR+=$(REQUIRE_UNITSDIR)
+endif
+ifdef REQUIRE_PACKAGESDIR
+override PACKAGESDIR+=$(REQUIRE_PACKAGESDIR)
+endif
+ifdef ZIPINSTALL
+ifeq ($(OS_TARGET),linux)
+UNIXINSTALLDIR=1
+endif
+ifeq ($(OS_TARGET),freebsd)
+UNIXINSTALLDIR=1
+endif
+ifeq ($(OS_TARGET),netbsd)
+UNIXINSTALLDIR=1
+endif
+ifeq ($(OS_TARGET),sunos)
+UNIXINSTALLDIR=1
+endif
+else
+ifeq ($(OS_SOURCE),linux)
+UNIXINSTALLDIR=1
+endif
+ifeq ($(OS_SOURCE),freebsd)
+UNIXINSTALLDIR=1
+endif
+ifeq ($(OS_SOURCE),netbsd)
+UNIXINSTALLDIR=1
+endif
+ifeq ($(OS_TARGET),sunos)
+UNIXINSTALLDIR=1
+endif
+endif
+ifndef INSTALL_PREFIX
+ifdef PREFIX
+INSTALL_PREFIX=$(PREFIX)
+endif
+endif
+ifndef INSTALL_PREFIX
+ifdef UNIXINSTALLDIR
+INSTALL_PREFIX=/usr/local
+else
+ifdef INSTALL_FPCPACKAGE
+INSTALL_BASEDIR:=/pp
+else
+INSTALL_BASEDIR:=/$(PACKAGE_NAME)
+endif
+endif
+endif
+export INSTALL_PREFIX
+ifndef DIST_DESTDIR
+DIST_DESTDIR:=$(BASEDIR)
+endif
+export DIST_DESTDIR
+ifndef INSTALL_BASEDIR
+ifdef UNIXINSTALLDIR
+ifdef INSTALL_FPCPACKAGE
+INSTALL_BASEDIR:=$(INSTALL_PREFIX)/lib/fpc/$(FPC_VERSION)
+else
+INSTALL_BASEDIR:=$(INSTALL_PREFIX)/lib/$(PACKAGE_NAME)
+endif
+else
+INSTALL_BASEDIR:=$(INSTALL_PREFIX)
+endif
+endif
+ifndef INSTALL_BINDIR
+ifdef UNIXINSTALLDIR
+INSTALL_BINDIR:=$(INSTALL_PREFIX)/bin
+else
+INSTALL_BINDIR:=$(INSTALL_BASEDIR)/bin
+ifdef INSTALL_FPCPACKAGE
+INSTALL_BINDIR:=$(INSTALL_BINDIR)/$(OS_TARGET)
+endif
+endif
+endif
+ifndef INSTALL_UNITDIR
+ifdef CROSSCOMPILE
+INSTALL_UNITDIR:=$(INSTALL_BASEDIR)/cross/$(FULL_TARGET)/units
+else
+INSTALL_UNITDIR:=$(INSTALL_BASEDIR)/units/$(OS_TARGET)
+endif
+ifdef INSTALL_FPCPACKAGE
+ifdef PACKAGE_NAME
+INSTALL_UNITDIR:=$(INSTALL_UNITDIR)/$(PACKAGE_NAME)
+endif
+endif
+endif
+ifndef INSTALL_LIBDIR
+ifdef UNIXINSTALLDIR
+INSTALL_LIBDIR:=$(INSTALL_PREFIX)/lib
+else
+INSTALL_LIBDIR:=$(INSTALL_UNITDIR)
+endif
+endif
+ifndef INSTALL_SOURCEDIR
+ifdef UNIXINSTALLDIR
+ifdef INSTALL_FPCPACKAGE
+ifdef BSDhier
+INSTALL_SOURCEDIR:=$(INSTALL_PREFIX)/share/src/fpc-$(FPC_VERSION)/$(PACKAGE_NAME)
+else
+INSTALL_SOURCEDIR:=$(INSTALL_PREFIX)/src/fpc-$(FPC_VERSION)/$(PACKAGE_NAME)
+endif
+else
+ifdef BSDhier
+INSTALL_SOURCEDIR:=$(INSTALL_PREFIX)/share/src/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
+else
+INSTALL_SOURCEDIR:=$(INSTALL_PREFIX)/src/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
+endif
+endif
+else
+ifdef INSTALL_FPCPACKAGE
+INSTALL_SOURCEDIR:=$(INSTALL_BASEDIR)/source/$(PACKAGE_NAME)
+else
+INSTALL_SOURCEDIRL:=$(INSTALL_BASEDIR)/source
+endif
+endif
+endif
+ifndef INSTALL_DOCDIR
+ifdef UNIXINSTALLDIR
+ifdef INSTALL_FPCPACKAGE
+ifdef BSDhier
+INSTALL_DOCDIR:=$(INSTALL_PREFIX)/share/doc/fpc-$(FPC_VERSION)/$(PACKAGE_NAME)
+else
+INSTALL_DOCDIR:=$(INSTALL_PREFIX)/doc/fpc-$(FPC_VERSION)/$(PACKAGE_NAME)
+endif
+else
+ifdef BSDhier
+INSTALL_DOCDIR:=$(INSTALL_PREFIX)/share/doc/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
+else
+INSTALL_DOCDIR:=$(INSTALL_PREFIX)/doc/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
+endif
+endif
+else
+ifdef INSTALL_FPCPACKAGE
+INSTALL_DOCDIR:=$(INSTALL_BASEDIR)/doc/$(PACKAGE_NAME)
+else
+INSTALL_DOCDIR:=$(INSTALL_BASEDIR)/doc
+endif
+endif
+endif
+ifndef INSTALL_EXAMPLEDIR
+ifdef UNIXINSTALLDIR
+ifdef INSTALL_FPCPACKAGE
+ifdef BSDhier
+INSTALL_EXAMPLEDIR:=$(INSTALL_PREFIX)/share/examples/fpc-$(FPC_VERSION)/$(PACKAGE_NAME)
+else
+INSTALL_EXAMPLEDIR:=$(INSTALL_PREFIX)/doc/fpc-$(FPC_VERSION)/examples/$(PACKAGE_NAME)
+endif
+else
+ifdef BSDhier
+INSTALL_EXAMPLEDIR:=$(INSTALL_PREFIX)/share/examples/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
+else
+INSTALL_EXAMPLEDIR:=$(INSTALL_PREFIX)/doc/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
+endif
+endif
+else
+ifdef INSTALL_FPCPACKAGE
+INSTALL_EXAMPLEDIR:=$(INSTALL_BASEDIR)/examples/$(PACKAGE_NAME)
+else
+INSTALL_EXAMPLEDIR:=$(INSTALL_BASEDIR)/examples
+endif
+endif
+endif
+ifndef INSTALL_DATADIR
+INSTALL_DATADIR=$(INSTALL_BASEDIR)
+endif
+ifdef CROSSCOMPILE
+ifndef CROSSBINDIR
+CROSSBINDIR:=$(wildcard $(CROSSTARGETDIR)/bin/$(FULL_SOURCE))
+ifeq ($(CROSSBINDIR),)
+CROSSBINDIR:=$(wildcard $(INSTALL_BASEDIR)/cross/$(FULL_TARGET)/bin/$(FULL_SOURCE))
+endif
+endif
+else
+CROSSBINDIR=
+endif
+LOADEREXT=.as
+EXEEXT=.exe
+PPLEXT=.ppl
+PPUEXT=.ppu
+OEXT=.o
+ASMEXT=.s
+SMARTEXT=.sl
+STATICLIBEXT=.a
+SHAREDLIBEXT=.so
+STATICLIBPREFIX=libp
+RSTEXT=.rst
+FPCMADE=fpcmade
+ifeq ($(OS_TARGET),go32v1)
+PPUEXT=.pp1
+OEXT=.o1
+ASMEXT=.s1
+SMARTEXT=.sl1
+STATICLIBEXT=.a1
+SHAREDLIBEXT=.so1
+STATICLIBPREFIX=
+FPCMADE=fpcmade.v1
+PACKAGESUFFIX=v1
+endif
+ifeq ($(OS_TARGET),go32v2)
+STATICLIBPREFIX=
+FPCMADE=fpcmade.dos
+ZIPSUFFIX=go32
+endif
+ifeq ($(OS_TARGET),linux)
+EXEEXT=
+HASSHAREDLIB=1
+FPCMADE=fpcmade.lnx
+ZIPSUFFIX=linux
+endif
+ifeq ($(OS_TARGET),freebsd)
+EXEEXT=
+HASSHAREDLIB=1
+FPCMADE=fpcmade.freebsd
+ZIPSUFFIX=freebsd
+endif
+ifeq ($(OS_TARGET),netbsd)
+EXEEXT=
+HASSHAREDLIB=1
+FPCMADE=fpcmade.netbsd
+ZIPSUFFIX=netbsd
+endif
+ifeq ($(OS_TARGET),win32)
+PPUEXT=.ppw
+OEXT=.ow
+ASMEXT=.sw
+SMARTEXT=.slw
+STATICLIBEXT=.aw
+SHAREDLIBEXT=.dll
+FPCMADE=fpcmade.w32
+ZIPSUFFIX=w32
+endif
+ifeq ($(OS_TARGET),os2)
+PPUEXT=.ppo
+ASMEXT=.so2
+OEXT=.oo2
+AOUTEXT=.out
+SMARTEXT=.so
+STATICLIBEXT=.ao2
+SHAREDLIBEXT=.dll
+FPCMADE=fpcmade.os2
+ZIPSUFFIX=emx
+endif
+ifeq ($(OS_TARGET),amiga)
+EXEEXT=
+PPUEXT=.ppa
+ASMEXT=.asm
+OEXT=.o
+SMARTEXT=.sl
+STATICLIBEXT=.a
+SHAREDLIBEXT=.library
+FPCMADE=fpcmade.amg
+endif
+ifeq ($(OS_TARGET),atari)
+PPUEXT=.ppt
+ASMEXT=.s
+OEXT=.o
+SMARTEXT=.sl
+STATICLIBEXT=.a
+EXEEXT=.ttp
+FPCMADE=fpcmade.ata
+endif
+ifeq ($(OS_TARGET),beos)
+PPUEXT=.ppu
+ASMEXT=.s
+OEXT=.o
+SMARTEXT=.sl
+STATICLIBEXT=.a
+EXEEXT=
+FPCMADE=fpcmade.be
+ZIPSUFFIX=be
+endif
+ifeq ($(OS_TARGET),sunos)
+PPUEXT=.ppu
+ASMEXT=.s
+OEXT=.o
+SMARTEXT=.sl
+STATICLIBEXT=.a
+EXEEXT=
+FPCMADE=fpcmade.sun
+ZIPSUFFIX=sun
+endif
+ifeq ($(OS_TARGET),qnx)
+PPUEXT=.ppu
+ASMEXT=.s
+OEXT=.o
+SMARTEXT=.sl
+STATICLIBEXT=.a
+EXEEXT=
+FPCMADE=fpcmade.qnx
+ZIPSUFFIX=qnx
+endif
+ifndef ECHO
+ECHO:=$(strip $(wildcard $(addsuffix /gecho$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(ECHO),)
+ECHO:=$(strip $(wildcard $(addsuffix /echo$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(ECHO),)
+ECHO=
+else
+ECHO:=$(firstword $(ECHO))
+endif
+else
+ECHO:=$(firstword $(ECHO))
+endif
+endif
+export ECHO
+ifndef DATE
+DATE:=$(strip $(wildcard $(addsuffix /gdate$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(DATE),)
+DATE:=$(strip $(wildcard $(addsuffix /date$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(DATE),)
+DATE=
+else
+DATE:=$(firstword $(DATE))
+endif
+else
+DATE:=$(firstword $(DATE))
+endif
+endif
+export DATE
+ifndef GINSTALL
+GINSTALL:=$(strip $(wildcard $(addsuffix /ginstall$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(GINSTALL),)
+GINSTALL:=$(strip $(wildcard $(addsuffix /install$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(GINSTALL),)
+GINSTALL=
+else
+GINSTALL:=$(firstword $(GINSTALL))
+endif
+else
+GINSTALL:=$(firstword $(GINSTALL))
+endif
+endif
+export GINSTALL
+ifndef CPPROG
+CPPROG:=$(strip $(wildcard $(addsuffix /cp$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(CPPROG),)
+CPPROG=
+else
+CPPROG:=$(firstword $(CPPROG))
+endif
+endif
+export CPPROG
+ifndef RMPROG
+RMPROG:=$(strip $(wildcard $(addsuffix /rm$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(RMPROG),)
+RMPROG=
+else
+RMPROG:=$(firstword $(RMPROG))
+endif
+endif
+export RMPROG
+ifndef MVPROG
+MVPROG:=$(strip $(wildcard $(addsuffix /mv$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(MVPROG),)
+MVPROG=
+else
+MVPROG:=$(firstword $(MVPROG))
+endif
+endif
+export MVPROG
+ifndef ECHOREDIR
+ECHOREDIR:=$(subst /,$(PATHSEP),$(ECHO))
+endif
+ifndef COPY
+COPY:=$(CPPROG) -fp
+endif
+ifndef COPYTREE
+COPYTREE:=$(CPPROG) -rfp
+endif
+ifndef MOVE
+MOVE:=$(MVPROG) -f
+endif
+ifndef DEL
+DEL:=$(RMPROG) -f
+endif
+ifndef DELTREE
+DELTREE:=$(RMPROG) -rf
+endif
+ifndef INSTALL
+ifdef inUnix
+INSTALL:=$(GINSTALL) -c -m 644
+else
+INSTALL:=$(COPY)
+endif
+endif
+ifndef INSTALLEXE
+ifdef inUnix
+INSTALLEXE:=$(GINSTALL) -c -m 755
+else
+INSTALLEXE:=$(COPY)
+endif
+endif
+ifndef MKDIR
+MKDIR:=$(GINSTALL) -m 755 -d
+endif
+export ECHOREDIR COPY COPYTREE MOVE DEL DELTREE INSTALL INSTALLEXE MKDIR
+ifndef PPUMOVE
+PPUMOVE:=$(strip $(wildcard $(addsuffix /ppumove$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(PPUMOVE),)
+PPUMOVE=
+else
+PPUMOVE:=$(firstword $(PPUMOVE))
+endif
+endif
+export PPUMOVE
+ifndef FPCMAKE
+FPCMAKE:=$(strip $(wildcard $(addsuffix /fpcmake$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(FPCMAKE),)
+FPCMAKE=
+else
+FPCMAKE:=$(firstword $(FPCMAKE))
+endif
+endif
+export FPCMAKE
+ifndef ZIPPROG
+ZIPPROG:=$(strip $(wildcard $(addsuffix /zip$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(ZIPPROG),)
+ZIPPROG=
+else
+ZIPPROG:=$(firstword $(ZIPPROG))
+endif
+endif
+export ZIPPROG
+ifndef TARPROG
+TARPROG:=$(strip $(wildcard $(addsuffix /tar$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(TARPROG),)
+TARPROG=
+else
+TARPROG:=$(firstword $(TARPROG))
+endif
+endif
+export TARPROG
+ASNAME=as
+LDNAME=ld
+ARNAME=ar
+RCNAME=rc
+ifeq ($(OS_TARGET),win32)
+ASNAME=asw
+LDNAME=ldw
+ARNAME=arw
+endif
+ifndef ASPROG
+ifdef CROSSBINDIR
+ASPROG=$(CROSSBINDIR)/$(ASNAME)$(SRCEXEEXT)
+else
+ASPROG=$(ASNAME)
+endif
+endif
+ifndef LDPROG
+ifdef CROSSBINDIR
+LDPROG=$(CROSSBINDIR)/$(LDNAME)$(SRCEXEEXT)
+else
+LDPROG=$(LDNAME)
+endif
+endif
+ifndef RCPROG
+ifdef CROSSBINDIR
+RCPROG=$(CROSSBINDIR)/$(RCNAME)$(SRCEXEEXT)
+else
+RCPROG=$(RCNAME)
+endif
+endif
+ifndef ARPROG
+ifdef CROSSBINDIR
+ARPROG=$(CROSSBINDIR)/$(ARNAME)$(SRCEXEEXT)
+else
+ARPROG=$(ARNAME)
+endif
+endif
+AS=$(ASPROG)
+LD=$(LDPROG)
+RC=$(RCPROG)
+AR=$(ARPROG)
+PPAS=ppas$(BATCHEXT)
+ifdef inUnix
+LDCONFIG=ldconfig
+else
+LDCONFIG=
+endif
+ifdef DATE
+DATESTR:=$(shell $(DATE) +%Y%m%d)
+else
+DATESTR=
+endif
+ifndef UPXPROG
+ifeq ($(OS_TARGET),go32v2)
+UPXPROG:=1
+endif
+ifeq ($(OS_TARGET),win32)
+UPXPROG:=1
+endif
+ifdef UPXPROG
+UPXPROG:=$(strip $(wildcard $(addsuffix /upx$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(UPXPROG),)
+UPXPROG=
+else
+UPXPROG:=$(firstword $(UPXPROG))
+endif
+else
+UPXPROG=
+endif
+endif
+export UPXPROG
+ZIPOPT=-9
+ZIPEXT=.zip
+ifeq ($(USETAR),bz2)
+TAROPT=vI
+TAREXT=.tar.bz2
+else
+TAROPT=vz
+TAREXT=.tar.gz
+endif
+ifndef NOCPUDEF
+override FPCOPTDEF=$(CPU_TARGET)
+endif
+ifneq ($(OS_TARGET),$(OS_SOURCE))
+override FPCOPT+=-T$(OS_TARGET)
+endif
+ifdef UNITDIR
+override FPCOPT+=$(addprefix -Fu,$(UNITDIR))
+endif
+ifdef LIBDIR
+override FPCOPT+=$(addprefix -Fl,$(LIBDIR))
+endif
+ifdef OBJDIR
+override FPCOPT+=$(addprefix -Fo,$(OBJDIR))
+endif
+ifdef INCDIR
+override FPCOPT+=$(addprefix -Fi,$(INCDIR))
+endif
+ifdef LINKSMART
+override FPCOPT+=-XX
+endif
+ifdef CREATESMART
+override FPCOPT+=-CX
+endif
+ifdef DEBUG
+override FPCOPT+=-gl
+override FPCOPTDEF+=DEBUG
+endif
+ifdef RELEASE
+ifeq ($(CPU_TARGET),i386)
+FPCCPUOPT:=-OG2p3
+else
+FPCCPUOPT:=
+endif
+override FPCOPT+=-Xs $(FPCCPUOPT) -n
+override FPCOPTDEF+=RELEASE
+endif
+ifdef STRIP
+override FPCOPT+=-Xs
+endif
+ifdef OPTIMIZE
+ifeq ($(CPU_TARGET),i386)
+override FPCOPT+=-OG2p3
+endif
+endif
+ifdef VERBOSE
+override FPCOPT+=-vwni
+endif
+ifdef COMPILER_OPTIONS
+override FPCOPT+=$(COMPILER_OPTIONS)
+endif
+ifdef COMPILER_UNITDIR
+override FPCOPT+=$(addprefix -Fu,$(COMPILER_UNITDIR))
+endif
+ifdef COMPILER_LIBRARYDIR
+override FPCOPT+=$(addprefix -Fl,$(COMPILER_LIBRARYDIR))
+endif
+ifdef COMPILER_OBJECTDIR
+override FPCOPT+=$(addprefix -Fo,$(COMPILER_OBJECTDIR))
+endif
+ifdef COMPILER_INCLUDEDIR
+override FPCOPT+=$(addprefix -Fi,$(COMPILER_INCLUDEDIR))
+endif
+ifdef CROSSBINDIR
+override FPCOPT+=-FD$(CROSSBINDIR)
+endif
+ifdef COMPILER_TARGETDIR
+override FPCOPT+=-FE$(COMPILER_TARGETDIR)
+ifeq ($(COMPILER_TARGETDIR),.)
+override TARGETDIRPREFIX=
+else
+override TARGETDIRPREFIX=$(COMPILER_TARGETDIR)/
+endif
+endif
+ifdef COMPILER_UNITTARGETDIR
+override FPCOPT+=-FU$(COMPILER_UNITTARGETDIR)
+ifeq ($(COMPILER_UNITTARGETDIR),.)
+override UNITTARGETDIRPREFIX=
+else
+override UNITTARGETDIRPREFIX=$(COMPILER_UNITTARGETDIR)/
+endif
+else
+ifdef COMPILER_TARGETDIR
+override COMPILER_UNITTARGETDIR=$(COMPILER_TARGETDIR)
+override UNITTARGETDIRPREFIX=$(TARGETDIRPREFIX)
+endif
+endif
+ifdef OPT
+override FPCOPT+=$(OPT)
+endif
+ifdef FPCOPTDEF
+override FPCOPT+=$(addprefix -d,$(FPCOPTDEF))
+endif
+ifdef CFGFILE
+override FPCOPT+=@$(CFGFILE)
+endif
+ifdef USEENV
+override FPCEXTCMD:=$(FPCOPT)
+override FPCOPT:=!FPCEXTCMD
+export FPCEXTCMD
+endif
+override COMPILER:=$(FPC) $(FPCOPT)
+ifeq (,$(findstring -s ,$(COMPILER)))
+EXECPPAS=
+else
+ifeq ($(OS_SOURCE),$(OS_TARGET))
+EXECPPAS:=@$(PPAS)
+endif
+endif
+ifdef TARGET_RSTS
+override RSTFILES=$(addsuffix $(RSTEXT),$(TARGET_RSTS))
+override CLEANRSTFILES+=$(RSTFILES)
+endif
+.PHONY: fpc_clean fpc_cleanall fpc_distclean
+ifdef EXEFILES
+override CLEANEXEFILES:=$(addprefix $(TARGETDIRPREFIX),$(CLEANEXEFILES))
+endif
+ifdef CLEAN_UNITS
+override CLEANPPUFILES+=$(addsuffix $(PPUEXT),$(CLEAN_UNITS))
+endif
+ifdef CLEANPPUFILES
+override CLEANPPULINKFILES:=$(subst $(PPUEXT),$(OEXT),$(CLEANPPUFILES)) $(addprefix $(STATICLIBPREFIX),$(subst $(PPUEXT),$(STATICLIBEXT),$(CLEANPPUFILES)))
+override CLEANPPUFILES:=$(addprefix $(UNITTARGETDIRPREFIX),$(CLEANPPUFILES))
+override CLEANPPULINKFILES:=$(wildcard $(addprefix $(UNITTARGETDIRPREFIX),$(CLEANPPULINKFILES)))
+endif
+fpc_clean: $(CLEANTARGET)
+ifdef CLEANEXEFILES
+	-$(DEL) $(CLEANEXEFILES)
+endif
+ifdef CLEANPPUFILES
+	-$(DEL) $(CLEANPPUFILES)
+endif
+ifneq ($(CLEANPPULINKFILES),)
+	-$(DEL) $(CLEANPPULINKFILES)
+endif
+ifdef CLEANRSTFILES
+	-$(DEL) $(addprefix $(UNITTARGETDIRPREFIX),$(CLEANRSTFILES))
+endif
+ifdef CLEAN_FILES
+	-$(DEL) $(CLEAN_FILES)
+endif
+ifdef LIB_NAME
+	-$(DEL) $(LIB_NAME) $(LIB_FULLNAME)
+endif
+	-$(DEL) $(FPCMADE) Package.fpc $(PPAS) script.res link.res $(FPCEXTFILE) $(REDIRFILE)
+fpc_distclean: clean
+ifdef COMPILER_UNITTARGETDIR
+TARGETDIRCLEAN=fpc_clean
+endif
+fpc_cleanall: $(CLEANTARGET) $(TARGETDIRCLEAN)
+ifdef CLEANEXEFILES
+	-$(DEL) $(CLEANEXEFILES)
+endif
+	-$(DEL) *$(OEXT) *$(PPUEXT) *$(RSTEXT) *$(ASMEXT) *$(STATICLIBEXT) *$(SHAREDLIBEXT) *$(PPLEXT)
+	-$(DELTREE) *$(SMARTEXT)
+	-$(DEL) $(FPCMADE) Package.fpc $(PPAS) script.res link.res $(FPCEXTFILE) $(REDIRFILE)
+ifdef AOUTEXT
+	-$(DEL) *$(AOUTEXT)
+endif
+.PHONY: fpc_baseinfo
+override INFORULES+=fpc_baseinfo
+fpc_baseinfo:
+	@$(ECHO)
+	@$(ECHO)  == Package info ==
+	@$(ECHO)  Package Name..... $(PACKAGE_NAME)
+	@$(ECHO)  Package Version.. $(PACKAGE_VERSION)
+	@$(ECHO)
+	@$(ECHO)  == Configuration info ==
+	@$(ECHO)
+	@$(ECHO)  FPC.......... $(FPC)
+	@$(ECHO)  FPC Version.. $(FPC_VERSION)
+	@$(ECHO)  Source CPU... $(CPU_SOURCE)
+	@$(ECHO)  Target CPU... $(CPU_TARGET)
+	@$(ECHO)  Source OS.... $(OS_SOURCE)
+	@$(ECHO)  Target OS.... $(OS_TARGET)
+	@$(ECHO)  Full Target.. $(FULL_SOURCE)
+	@$(ECHO)  Full Source.. $(FULL_TARGET)
+	@$(ECHO)
+	@$(ECHO)  == Directory info ==
+	@$(ECHO)
+	@$(ECHO)  Required pkgs... $(REQUIRE_PACKAGES)
+	@$(ECHO)
+	@$(ECHO)  Basedir......... $(BASEDIR)
+	@$(ECHO)  FPCDir.......... $(FPCDIR)
+	@$(ECHO)  CrossBinDir..... $(CROSSBINDIR)
+	@$(ECHO)  UnitsDir........ $(UNITSDIR)
+	@$(ECHO)  PackagesDir..... $(PACKAGESDIR)
+	@$(ECHO)
+	@$(ECHO)  GCC library..... $(GCCLIBDIR)
+	@$(ECHO)  Other library... $(OTHERLIBDIR)
+	@$(ECHO)
+	@$(ECHO)  == Tools info ==
+	@$(ECHO)
+	@$(ECHO)  As........ $(AS)
+	@$(ECHO)  Ld........ $(LD)
+	@$(ECHO)  Ar........ $(AR)
+	@$(ECHO)  Rc........ $(RC)
+	@$(ECHO)
+	@$(ECHO)  Mv........ $(MVPROG)
+	@$(ECHO)  Cp........ $(CPPROG)
+	@$(ECHO)  Rm........ $(RMPROG)
+	@$(ECHO)  GInstall.. $(GINSTALL)
+	@$(ECHO)  Echo...... $(ECHO)
+	@$(ECHO)  Date...... $(DATE)
+	@$(ECHO)  FPCMake... $(FPCMAKE)
+	@$(ECHO)  PPUMove... $(PPUMOVE)
+	@$(ECHO)  Upx....... $(UPXPROG)
+	@$(ECHO)  Zip....... $(ZIPPROG)
+	@$(ECHO)
+	@$(ECHO)  == Object info ==
+	@$(ECHO)
+	@$(ECHO)  Target Loaders........ $(TARGET_LOADERS)
+	@$(ECHO)  Target Units.......... $(TARGET_UNITS)
+	@$(ECHO)  Target Implicit Units. $(TARGET_IMPLICITUNITS)
+	@$(ECHO)  Target Programs....... $(TARGET_PROGRAMS)
+	@$(ECHO)  Target Dirs........... $(TARGET_DIRS)
+	@$(ECHO)  Target Examples....... $(TARGET_EXAMPLES)
+	@$(ECHO)  Target ExampleDirs.... $(TARGET_EXAMPLEDIRS)
+	@$(ECHO)
+	@$(ECHO)  Clean Units......... $(CLEAN_UNITS)
+	@$(ECHO)  Clean Files......... $(CLEAN_FILES)
+	@$(ECHO)
+	@$(ECHO)  Install Units....... $(INSTALL_UNITS)
+	@$(ECHO)  Install Files....... $(INSTALL_FILES)
+	@$(ECHO)
+	@$(ECHO)  == Install info ==
+	@$(ECHO)
+	@$(ECHO)  DateStr.............. $(DATESTR)
+	@$(ECHO)  ZipPrefix............ $(ZIPPREFIX)
+	@$(ECHO)  ZipSuffix............ $(ZIPSUFFIX)
+	@$(ECHO)  Install FPC Package.. $(INSTALL_FPCPACKAGE)
+	@$(ECHO)
+	@$(ECHO)  Install base dir..... $(INSTALL_BASEDIR)
+	@$(ECHO)  Install binary dir... $(INSTALL_BINDIR)
+	@$(ECHO)  Install library dir.. $(INSTALL_LIBDIR)
+	@$(ECHO)  Install units dir.... $(INSTALL_UNITDIR)
+	@$(ECHO)  Install source dir... $(INSTALL_SOURCEDIR)
+	@$(ECHO)  Install doc dir...... $(INSTALL_DOCDIR)
+	@$(ECHO)  Install example dir.. $(INSTALL_EXAMPLEDIR)
+	@$(ECHO)  Install data dir..... $(INSTALL_DATADIR)
+	@$(ECHO)
+	@$(ECHO)  Dist destination dir. $(DIST_DESTDIR)
+	@$(ECHO)  Dist zip name........ $(DIST_ZIPNAME)
+	@$(ECHO)
+.PHONY: fpc_info
+fpc_info: $(INFORULES)
+.PHONY: fpc_makefile fpc_makefiles fpc_makefile_sub1 fpc_makefile_sub2 \
+	fpc_makefile_dirs
+fpc_makefile:
+	$(FPCMAKE) -w -T$(OS_TARGET) Makefile.fpc
+fpc_makefile_sub1:
+ifdef TARGET_DIRS
+	$(FPCMAKE) -w -T$(OS_TARGET) $(addsuffix /Makefile.fpc,$(TARGET_DIRS))
+endif
+ifdef TARGET_EXAMPLEDIRS
+	$(FPCMAKE) -w -T$(OS_TARGET) $(addsuffix /Makefile.fpc,$(TARGET_EXAMPLEDIRS))
+endif
+fpc_makefile_sub2: $(addsuffix _makefile_dirs,$(TARGET_DIRS) $(TARGET_EXAMPLEDIRS))
+fpc_makefile_dirs: fpc_makefile_sub1 fpc_makefile_sub2
+fpc_makefiles: fpc_makefile fpc_makefile_dirs
+TARGET_DIRS_PASZLIB=1
+TARGET_DIRS_REGEXPR=1
+ifeq ($(OS_TARGET),linux)
+TARGET_DIRS_INET=1
+TARGET_DIRS_GDBINT=1
+TARGET_DIRS_LIBASYNC=1
+TARGET_DIRS_MYSQL=1
+TARGET_DIRS_IBASE=1
+TARGET_DIRS_POSTGRES=1
+TARGET_DIRS_ORACLE=1
+endif
+ifeq ($(OS_TARGET),go32v2)
+TARGET_DIRS_GDBINT=1
+endif
+ifeq ($(OS_TARGET),win32)
+TARGET_DIRS_INET=1
+TARGET_DIRS_GDBINT=1
+TARGET_DIRS_MYSQL=1
+TARGET_DIRS_IBASE=1
+endif
+ifeq ($(OS_TARGET),freebsd)
+TARGET_DIRS_INET=1
+TARGET_DIRS_GDBINT=1
+TARGET_DIRS_LIBASYNC=1
+TARGET_DIRS_MYSQL=1
+TARGET_DIRS_IBASE=1
+TARGET_DIRS_POSTGRES=1
+TARGET_DIRS_ORACLE=1
+endif
+ifeq ($(OS_TARGET),netbsd)
+TARGET_DIRS_INET=1
+TARGET_DIRS_GDBINT=1
+TARGET_DIRS_LIBASYNC=1
+TARGET_DIRS_MYSQL=1
+TARGET_DIRS_IBASE=1
+TARGET_DIRS_POSTGRES=1
+TARGET_DIRS_ORACLE=1
+endif
+ifdef TARGET_DIRS_PASZLIB
+paszlib_all:
+	$(MAKE) -C paszlib all
+paszlib_debug:
+	$(MAKE) -C paszlib debug
+paszlib_smart:
+	$(MAKE) -C paszlib smart
+paszlib_release:
+	$(MAKE) -C paszlib release
+paszlib_examples:
+	$(MAKE) -C paszlib examples
+paszlib_shared:
+	$(MAKE) -C paszlib shared
+paszlib_install:
+	$(MAKE) -C paszlib install
+paszlib_sourceinstall:
+	$(MAKE) -C paszlib sourceinstall
+paszlib_exampleinstall:
+	$(MAKE) -C paszlib exampleinstall
+paszlib_distinstall:
+	$(MAKE) -C paszlib distinstall
+paszlib_zipinstall:
+	$(MAKE) -C paszlib zipinstall
+paszlib_zipsourceinstall:
+	$(MAKE) -C paszlib zipsourceinstall
+paszlib_zipexampleinstall:
+	$(MAKE) -C paszlib zipexampleinstall
+paszlib_zipdistinstall:
+	$(MAKE) -C paszlib zipdistinstall
+paszlib_clean:
+	$(MAKE) -C paszlib clean
+paszlib_distclean:
+	$(MAKE) -C paszlib distclean
+paszlib_cleanall:
+	$(MAKE) -C paszlib cleanall
+paszlib_info:
+	$(MAKE) -C paszlib info
+paszlib_makefiles:
+	$(MAKE) -C paszlib makefiles
+paszlib:
+	$(MAKE) -C paszlib all
+.PHONY: paszlib_all paszlib_debug paszlib_smart paszlib_release paszlib_examples paszlib_shared paszlib_install paszlib_sourceinstall paszlib_exampleinstall paszlib_distinstall paszlib_zipinstall paszlib_zipsourceinstall paszlib_zipexampleinstall paszlib_zipdistinstall paszlib_clean paszlib_distclean paszlib_cleanall paszlib_info paszlib_makefiles paszlib
+endif
+ifdef TARGET_DIRS_REGEXPR
+regexpr_all:
+	$(MAKE) -C regexpr all
+regexpr_debug:
+	$(MAKE) -C regexpr debug
+regexpr_smart:
+	$(MAKE) -C regexpr smart
+regexpr_release:
+	$(MAKE) -C regexpr release
+regexpr_examples:
+	$(MAKE) -C regexpr examples
+regexpr_shared:
+	$(MAKE) -C regexpr shared
+regexpr_install:
+	$(MAKE) -C regexpr install
+regexpr_sourceinstall:
+	$(MAKE) -C regexpr sourceinstall
+regexpr_exampleinstall:
+	$(MAKE) -C regexpr exampleinstall
+regexpr_distinstall:
+	$(MAKE) -C regexpr distinstall
+regexpr_zipinstall:
+	$(MAKE) -C regexpr zipinstall
+regexpr_zipsourceinstall:
+	$(MAKE) -C regexpr zipsourceinstall
+regexpr_zipexampleinstall:
+	$(MAKE) -C regexpr zipexampleinstall
+regexpr_zipdistinstall:
+	$(MAKE) -C regexpr zipdistinstall
+regexpr_clean:
+	$(MAKE) -C regexpr clean
+regexpr_distclean:
+	$(MAKE) -C regexpr distclean
+regexpr_cleanall:
+	$(MAKE) -C regexpr cleanall
+regexpr_info:
+	$(MAKE) -C regexpr info
+regexpr_makefiles:
+	$(MAKE) -C regexpr makefiles
+regexpr:
+	$(MAKE) -C regexpr all
+.PHONY: regexpr_all regexpr_debug regexpr_smart regexpr_release regexpr_examples regexpr_shared regexpr_install regexpr_sourceinstall regexpr_exampleinstall regexpr_distinstall regexpr_zipinstall regexpr_zipsourceinstall regexpr_zipexampleinstall regexpr_zipdistinstall regexpr_clean regexpr_distclean regexpr_cleanall regexpr_info regexpr_makefiles regexpr
+endif
+ifdef TARGET_DIRS_INET
+inet_all:
+	$(MAKE) -C inet all
+inet_debug:
+	$(MAKE) -C inet debug
+inet_smart:
+	$(MAKE) -C inet smart
+inet_release:
+	$(MAKE) -C inet release
+inet_examples:
+	$(MAKE) -C inet examples
+inet_shared:
+	$(MAKE) -C inet shared
+inet_install:
+	$(MAKE) -C inet install
+inet_sourceinstall:
+	$(MAKE) -C inet sourceinstall
+inet_exampleinstall:
+	$(MAKE) -C inet exampleinstall
+inet_distinstall:
+	$(MAKE) -C inet distinstall
+inet_zipinstall:
+	$(MAKE) -C inet zipinstall
+inet_zipsourceinstall:
+	$(MAKE) -C inet zipsourceinstall
+inet_zipexampleinstall:
+	$(MAKE) -C inet zipexampleinstall
+inet_zipdistinstall:
+	$(MAKE) -C inet zipdistinstall
+inet_clean:
+	$(MAKE) -C inet clean
+inet_distclean:
+	$(MAKE) -C inet distclean
+inet_cleanall:
+	$(MAKE) -C inet cleanall
+inet_info:
+	$(MAKE) -C inet info
+inet_makefiles:
+	$(MAKE) -C inet makefiles
+inet:
+	$(MAKE) -C inet all
+.PHONY: inet_all inet_debug inet_smart inet_release inet_examples inet_shared inet_install inet_sourceinstall inet_exampleinstall inet_distinstall inet_zipinstall inet_zipsourceinstall inet_zipexampleinstall inet_zipdistinstall inet_clean inet_distclean inet_cleanall inet_info inet_makefiles inet
+endif
+ifdef TARGET_DIRS_GDBINT
+gdbint_all:
+	$(MAKE) -C gdbint all
+gdbint_debug:
+	$(MAKE) -C gdbint debug
+gdbint_smart:
+	$(MAKE) -C gdbint smart
+gdbint_release:
+	$(MAKE) -C gdbint release
+gdbint_examples:
+	$(MAKE) -C gdbint examples
+gdbint_shared:
+	$(MAKE) -C gdbint shared
+gdbint_install:
+	$(MAKE) -C gdbint install
+gdbint_sourceinstall:
+	$(MAKE) -C gdbint sourceinstall
+gdbint_exampleinstall:
+	$(MAKE) -C gdbint exampleinstall
+gdbint_distinstall:
+	$(MAKE) -C gdbint distinstall
+gdbint_zipinstall:
+	$(MAKE) -C gdbint zipinstall
+gdbint_zipsourceinstall:
+	$(MAKE) -C gdbint zipsourceinstall
+gdbint_zipexampleinstall:
+	$(MAKE) -C gdbint zipexampleinstall
+gdbint_zipdistinstall:
+	$(MAKE) -C gdbint zipdistinstall
+gdbint_clean:
+	$(MAKE) -C gdbint clean
+gdbint_distclean:
+	$(MAKE) -C gdbint distclean
+gdbint_cleanall:
+	$(MAKE) -C gdbint cleanall
+gdbint_info:
+	$(MAKE) -C gdbint info
+gdbint_makefiles:
+	$(MAKE) -C gdbint makefiles
+gdbint:
+	$(MAKE) -C gdbint all
+.PHONY: gdbint_all gdbint_debug gdbint_smart gdbint_release gdbint_examples gdbint_shared gdbint_install gdbint_sourceinstall gdbint_exampleinstall gdbint_distinstall gdbint_zipinstall gdbint_zipsourceinstall gdbint_zipexampleinstall gdbint_zipdistinstall gdbint_clean gdbint_distclean gdbint_cleanall gdbint_info gdbint_makefiles gdbint
+endif
+ifdef TARGET_DIRS_LIBASYNC
+libasync_all:
+	$(MAKE) -C libasync all
+libasync_debug:
+	$(MAKE) -C libasync debug
+libasync_smart:
+	$(MAKE) -C libasync smart
+libasync_release:
+	$(MAKE) -C libasync release
+libasync_examples:
+	$(MAKE) -C libasync examples
+libasync_shared:
+	$(MAKE) -C libasync shared
+libasync_install:
+	$(MAKE) -C libasync install
+libasync_sourceinstall:
+	$(MAKE) -C libasync sourceinstall
+libasync_exampleinstall:
+	$(MAKE) -C libasync exampleinstall
+libasync_distinstall:
+	$(MAKE) -C libasync distinstall
+libasync_zipinstall:
+	$(MAKE) -C libasync zipinstall
+libasync_zipsourceinstall:
+	$(MAKE) -C libasync zipsourceinstall
+libasync_zipexampleinstall:
+	$(MAKE) -C libasync zipexampleinstall
+libasync_zipdistinstall:
+	$(MAKE) -C libasync zipdistinstall
+libasync_clean:
+	$(MAKE) -C libasync clean
+libasync_distclean:
+	$(MAKE) -C libasync distclean
+libasync_cleanall:
+	$(MAKE) -C libasync cleanall
+libasync_info:
+	$(MAKE) -C libasync info
+libasync_makefiles:
+	$(MAKE) -C libasync makefiles
+libasync:
+	$(MAKE) -C libasync all
+.PHONY: libasync_all libasync_debug libasync_smart libasync_release libasync_examples libasync_shared libasync_install libasync_sourceinstall libasync_exampleinstall libasync_distinstall libasync_zipinstall libasync_zipsourceinstall libasync_zipexampleinstall libasync_zipdistinstall libasync_clean libasync_distclean libasync_cleanall libasync_info libasync_makefiles libasync
+endif
+ifdef TARGET_DIRS_MYSQL
+mysql_all:
+	$(MAKE) -C mysql all
+mysql_debug:
+	$(MAKE) -C mysql debug
+mysql_smart:
+	$(MAKE) -C mysql smart
+mysql_release:
+	$(MAKE) -C mysql release
+mysql_examples:
+	$(MAKE) -C mysql examples
+mysql_shared:
+	$(MAKE) -C mysql shared
+mysql_install:
+	$(MAKE) -C mysql install
+mysql_sourceinstall:
+	$(MAKE) -C mysql sourceinstall
+mysql_exampleinstall:
+	$(MAKE) -C mysql exampleinstall
+mysql_distinstall:
+	$(MAKE) -C mysql distinstall
+mysql_zipinstall:
+	$(MAKE) -C mysql zipinstall
+mysql_zipsourceinstall:
+	$(MAKE) -C mysql zipsourceinstall
+mysql_zipexampleinstall:
+	$(MAKE) -C mysql zipexampleinstall
+mysql_zipdistinstall:
+	$(MAKE) -C mysql zipdistinstall
+mysql_clean:
+	$(MAKE) -C mysql clean
+mysql_distclean:
+	$(MAKE) -C mysql distclean
+mysql_cleanall:
+	$(MAKE) -C mysql cleanall
+mysql_info:
+	$(MAKE) -C mysql info
+mysql_makefiles:
+	$(MAKE) -C mysql makefiles
+mysql:
+	$(MAKE) -C mysql all
+.PHONY: mysql_all mysql_debug mysql_smart mysql_release mysql_examples mysql_shared mysql_install mysql_sourceinstall mysql_exampleinstall mysql_distinstall mysql_zipinstall mysql_zipsourceinstall mysql_zipexampleinstall mysql_zipdistinstall mysql_clean mysql_distclean mysql_cleanall mysql_info mysql_makefiles mysql
+endif
+ifdef TARGET_DIRS_IBASE
+ibase_all:
+	$(MAKE) -C ibase all
+ibase_debug:
+	$(MAKE) -C ibase debug
+ibase_smart:
+	$(MAKE) -C ibase smart
+ibase_release:
+	$(MAKE) -C ibase release
+ibase_examples:
+	$(MAKE) -C ibase examples
+ibase_shared:
+	$(MAKE) -C ibase shared
+ibase_install:
+	$(MAKE) -C ibase install
+ibase_sourceinstall:
+	$(MAKE) -C ibase sourceinstall
+ibase_exampleinstall:
+	$(MAKE) -C ibase exampleinstall
+ibase_distinstall:
+	$(MAKE) -C ibase distinstall
+ibase_zipinstall:
+	$(MAKE) -C ibase zipinstall
+ibase_zipsourceinstall:
+	$(MAKE) -C ibase zipsourceinstall
+ibase_zipexampleinstall:
+	$(MAKE) -C ibase zipexampleinstall
+ibase_zipdistinstall:
+	$(MAKE) -C ibase zipdistinstall
+ibase_clean:
+	$(MAKE) -C ibase clean
+ibase_distclean:
+	$(MAKE) -C ibase distclean
+ibase_cleanall:
+	$(MAKE) -C ibase cleanall
+ibase_info:
+	$(MAKE) -C ibase info
+ibase_makefiles:
+	$(MAKE) -C ibase makefiles
+ibase:
+	$(MAKE) -C ibase all
+.PHONY: ibase_all ibase_debug ibase_smart ibase_release ibase_examples ibase_shared ibase_install ibase_sourceinstall ibase_exampleinstall ibase_distinstall ibase_zipinstall ibase_zipsourceinstall ibase_zipexampleinstall ibase_zipdistinstall ibase_clean ibase_distclean ibase_cleanall ibase_info ibase_makefiles ibase
+endif
+ifdef TARGET_DIRS_POSTGRES
+postgres_all:
+	$(MAKE) -C postgres all
+postgres_debug:
+	$(MAKE) -C postgres debug
+postgres_smart:
+	$(MAKE) -C postgres smart
+postgres_release:
+	$(MAKE) -C postgres release
+postgres_examples:
+	$(MAKE) -C postgres examples
+postgres_shared:
+	$(MAKE) -C postgres shared
+postgres_install:
+	$(MAKE) -C postgres install
+postgres_sourceinstall:
+	$(MAKE) -C postgres sourceinstall
+postgres_exampleinstall:
+	$(MAKE) -C postgres exampleinstall
+postgres_distinstall:
+	$(MAKE) -C postgres distinstall
+postgres_zipinstall:
+	$(MAKE) -C postgres zipinstall
+postgres_zipsourceinstall:
+	$(MAKE) -C postgres zipsourceinstall
+postgres_zipexampleinstall:
+	$(MAKE) -C postgres zipexampleinstall
+postgres_zipdistinstall:
+	$(MAKE) -C postgres zipdistinstall
+postgres_clean:
+	$(MAKE) -C postgres clean
+postgres_distclean:
+	$(MAKE) -C postgres distclean
+postgres_cleanall:
+	$(MAKE) -C postgres cleanall
+postgres_info:
+	$(MAKE) -C postgres info
+postgres_makefiles:
+	$(MAKE) -C postgres makefiles
+postgres:
+	$(MAKE) -C postgres all
+.PHONY: postgres_all postgres_debug postgres_smart postgres_release postgres_examples postgres_shared postgres_install postgres_sourceinstall postgres_exampleinstall postgres_distinstall postgres_zipinstall postgres_zipsourceinstall postgres_zipexampleinstall postgres_zipdistinstall postgres_clean postgres_distclean postgres_cleanall postgres_info postgres_makefiles postgres
+endif
+ifdef TARGET_DIRS_ORACLE
+oracle_all:
+	$(MAKE) -C oracle all
+oracle_debug:
+	$(MAKE) -C oracle debug
+oracle_smart:
+	$(MAKE) -C oracle smart
+oracle_release:
+	$(MAKE) -C oracle release
+oracle_examples:
+	$(MAKE) -C oracle examples
+oracle_shared:
+	$(MAKE) -C oracle shared
+oracle_install:
+	$(MAKE) -C oracle install
+oracle_sourceinstall:
+	$(MAKE) -C oracle sourceinstall
+oracle_exampleinstall:
+	$(MAKE) -C oracle exampleinstall
+oracle_distinstall:
+	$(MAKE) -C oracle distinstall
+oracle_zipinstall:
+	$(MAKE) -C oracle zipinstall
+oracle_zipsourceinstall:
+	$(MAKE) -C oracle zipsourceinstall
+oracle_zipexampleinstall:
+	$(MAKE) -C oracle zipexampleinstall
+oracle_zipdistinstall:
+	$(MAKE) -C oracle zipdistinstall
+oracle_clean:
+	$(MAKE) -C oracle clean
+oracle_distclean:
+	$(MAKE) -C oracle distclean
+oracle_cleanall:
+	$(MAKE) -C oracle cleanall
+oracle_info:
+	$(MAKE) -C oracle info
+oracle_makefiles:
+	$(MAKE) -C oracle makefiles
+oracle:
+	$(MAKE) -C oracle all
+.PHONY: oracle_all oracle_debug oracle_smart oracle_release oracle_examples oracle_shared oracle_install oracle_sourceinstall oracle_exampleinstall oracle_distinstall oracle_zipinstall oracle_zipsourceinstall oracle_zipexampleinstall oracle_zipdistinstall oracle_clean oracle_distclean oracle_cleanall oracle_info oracle_makefiles oracle
+endif
+all: $(addsuffix _all,$(TARGET_DIRS))
+debug: $(addsuffix _debug,$(TARGET_DIRS))
+smart: $(addsuffix _smart,$(TARGET_DIRS))
+release: $(addsuffix _release,$(TARGET_DIRS))
+examples: $(addsuffix _examples,$(TARGET_DIRS))
+shared: $(addsuffix _shared,$(TARGET_DIRS))
+install: $(addsuffix _install,$(TARGET_DIRS))
+sourceinstall: $(addsuffix _sourceinstall,$(TARGET_DIRS))
+exampleinstall: $(addsuffix _exampleinstall,$(TARGET_DIRS))
+distinstall: $(addsuffix _distinstall,$(TARGET_DIRS))
+zipinstall: $(addsuffix _zipinstall,$(TARGET_DIRS))
+zipsourceinstall: $(addsuffix _zipsourceinstall,$(TARGET_DIRS))
+zipexampleinstall: $(addsuffix _zipexampleinstall,$(TARGET_DIRS))
+zipdistinstall: $(addsuffix _zipdistinstall,$(TARGET_DIRS))
+clean: $(addsuffix _clean,$(TARGET_DIRS))
+distclean: $(addsuffix _distclean,$(TARGET_DIRS))
+cleanall: $(addsuffix _cleanall,$(TARGET_DIRS))
+info: fpc_info
+makefiles: fpc_makefiles $(addsuffix _makefiles,$(TARGET_DIRS))
+.PHONY: all debug smart release examples shared install sourceinstall exampleinstall distinstall zipinstall zipsourceinstall zipexampleinstall zipdistinstall clean distclean cleanall info makefiles
+ifneq ($(wildcard fpcmake.loc),)
+include fpcmake.loc
+endif

+ 21 - 0
packages/base/Makefile.fpc

@@ -0,0 +1,21 @@
+#
+#   Makefile.fpc for Free Pascal Packages
+#
+
+[target]
+dirs=paszlib regexpr
+dirs_linux=inet gdbint libasync \
+           mysql ibase postgres oracle
+dirs_win32=inet gdbint \
+           mysql ibase
+dirs_go32v2=gdbint
+dirs_netbsd=inet gdbint libasync \
+            mysql ibase postgres oracle
+dirs_freebsd=inet gdbint libasync \
+             mysql ibase postgres oracle
+
+[install]
+fpcpackage=y
+
+[default]
+fpcdir=../..

+ 1312 - 0
packages/base/gdbint/Makefile

@@ -0,0 +1,1312 @@
+#
+# Don't edit, this file is generated by FPCMake Version 1.1 [2002/01/29]
+#
+default: all
+MAKEFILETARGETS=linux go32v2 win32 os2 freebsd beos netbsd amiga atari sunos qnx
+override PATH:=$(subst \,/,$(PATH))
+ifeq ($(findstring ;,$(PATH)),)
+inUnix=1
+SEARCHPATH:=$(filter-out .,$(subst :, ,$(PATH)))
+else
+SEARCHPATH:=$(subst ;, ,$(PATH))
+endif
+PWD:=$(strip $(wildcard $(addsuffix /pwd.exe,$(SEARCHPATH))))
+ifeq ($(PWD),)
+PWD:=$(strip $(wildcard $(addsuffix /pwd,$(SEARCHPATH))))
+ifeq ($(PWD),)
+$(error You need the GNU utils package to use this Makefile)
+else
+PWD:=$(firstword $(PWD))
+SRCEXEEXT=
+endif
+else
+PWD:=$(firstword $(PWD))
+SRCEXEEXT=.exe
+endif
+ifndef inUnix
+ifeq ($(OS),Windows_NT)
+inWinNT=1
+else
+ifdef OS2_SHELL
+inOS2=1
+endif
+endif
+else
+ifneq ($(findstring cygwin,$(MACHTYPE)),)
+inCygWin=1
+endif
+endif
+ifeq ($(OS_TARGET),freebsd)
+BSDhier=1
+endif
+ifeq ($(OS_TARGET),netbsd)
+BSDhier=1
+endif
+ifdef inUnix
+BATCHEXT=.sh
+else
+ifdef inOS2
+BATCHEXT=.cmd
+else
+BATCHEXT=.bat
+endif
+endif
+ifdef inUnix
+PATHSEP=/
+else
+PATHSEP:=$(subst /,\,/)
+endif
+ifdef PWD
+BASEDIR:=$(subst \,/,$(shell $(PWD)))
+ifdef inCygWin
+ifneq ($(findstring /cygdrive/,$(BASEDIR)),)
+BASENODIR:=$(patsubst /cygdrive%,%,$(BASEDIR))
+BASEDRIVE:=$(firstword $(subst /, ,$(BASENODIR)))
+BASEDIR:=$(subst /cygdrive/$(BASEDRIVE)/,$(BASEDRIVE):/,$(BASEDIR))
+endif
+endif
+else
+BASEDIR=.
+endif
+override DEFAULT_FPCDIR=../../..
+ifndef FPC
+ifdef PP
+FPC=$(PP)
+endif
+endif
+ifndef FPC
+FPCPROG:=$(strip $(wildcard $(addsuffix /fpc$(SRCEXEEXT),$(SEARCHPATH))))
+ifneq ($(FPCPROG),)
+FPCPROG:=$(firstword $(FPCPROG))
+FPC:=$(shell $(FPCPROG) -PB)
+ifneq ($(findstring Error,$(FPC)),)
+override FPC=ppc386
+endif
+else
+override FPC=ppc386
+endif
+endif
+override FPC:=$(subst $(SRCEXEEXT),,$(FPC))
+override FPC:=$(subst \,/,$(FPC))$(SRCEXEEXT)
+ifndef FPC_VERSION
+FPC_VERSION:=$(shell $(FPC) -iV)
+endif
+export FPC FPC_VERSION
+ifeq ($(findstring 1.0.,$(FPC_VERSION)),)
+COMPILERINFO:=$(shell $(FPC) -iSP -iTP -iSO -iTO)
+ifndef CPU_SOURCE
+CPU_SOURCE:=$(word 1,$(COMPILERINFO))
+endif
+ifndef CPU_TARGET
+CPU_TARGET:=$(word 2,$(COMPILERINFO))
+endif
+ifndef OS_SOURCE
+OS_SOURCE:=$(word 3,$(COMPILERINFO))
+endif
+ifndef OS_TARGET
+OS_TARGET:=$(word 4,$(COMPILERINFO))
+endif
+else
+ifndef CPU_SOURCE
+CPU_SOURCE:=$(shell $(FPC) -iSP)
+endif
+ifndef CPU_TARGET
+CPU_TARGET:=$(shell $(FPC) -iTP)
+endif
+ifndef OS_SOURCE
+OS_SOURCE:=$(shell $(FPC) -iSO)
+endif
+ifndef OS_TARGET
+OS_TARGET:=$(shell $(FPC) -iTO)
+endif
+endif
+FULL_TARGET=$(CPU_TARGET)-$(OS_TARGET)
+FULL_SOURCE=$(CPU_SOURCE)-$(OS_SOURCE)
+ifneq ($(FULL_TARGET),$(FULL_SOURCE))
+CROSSCOMPILE=1
+endif
+ifeq ($(findstring makefile,$(MAKECMDGOALS)),)
+ifeq ($(findstring $(OS_TARGET),$(MAKEFILETARGETS)),)
+$(error The Makefile doesn't support target $(OS_TARGET), please run fpcmake first)
+endif
+endif
+export OS_TARGET OS_SOURCE CPU_TARGET CPU_SOURCE FULL_TARGET FULL_SOURCE CROSSCOMPILE
+ifdef FPCDIR
+override FPCDIR:=$(subst \,/,$(FPCDIR))
+ifeq ($(wildcard $(addprefix $(FPCDIR)/,rtl units)),)
+override FPCDIR=wrong
+endif
+else
+override FPCDIR=wrong
+endif
+ifdef DEFAULT_FPCDIR
+ifeq ($(FPCDIR),wrong)
+override FPCDIR:=$(subst \,/,$(DEFAULT_FPCDIR))
+ifeq ($(wildcard $(addprefix $(FPCDIR)/,rtl units)),)
+override FPCDIR=wrong
+endif
+endif
+endif
+ifeq ($(FPCDIR),wrong)
+ifdef inUnix
+override FPCDIR=/usr/local/lib/fpc/$(FPC_VERSION)
+ifeq ($(wildcard $(FPCDIR)/units),)
+override FPCDIR=/usr/lib/fpc/$(FPC_VERSION)
+endif
+else
+override FPCDIR:=$(subst /$(FPC),,$(firstword $(strip $(wildcard $(addsuffix /$(FPC),$(SEARCHPATH))))))
+override FPCDIR:=$(FPCDIR)/..
+ifeq ($(wildcard $(addprefix $(FPCDIR)/,rtl units)),)
+override FPCDIR:=$(FPCDIR)/..
+ifeq ($(wildcard $(addprefix $(FPCDIR)/,rtl units)),)
+override FPCDIR=c:/pp
+endif
+endif
+endif
+endif
+ifndef CROSSDIR
+CROSSDIR:=$(FPCDIR)/cross/$(FULL_TARGET)
+endif
+ifndef CROSSTARGETDIR
+CROSSTARGETDIR=$(CROSSDIR)/$(FULL_TARGET)
+endif
+ifdef CROSSCOMPILE
+UNITSDIR:=$(wildcard $(CROSSTARGETDIR)/units)
+ifeq ($(UNITSDIR),)
+UNITSDIR:=$(wildcard $(FPCDIR)/units/$(OS_TARGET))
+endif
+else
+UNITSDIR:=$(wildcard $(FPCDIR)/units/$(OS_TARGET))
+endif
+PACKAGESDIR:=$(wildcard $(FPCDIR) $(FPCDIR)/packages/base $(FPCDIR)/packages/extra)
+override PACKAGE_NAME=gdbint
+override PACKAGE_VERSION=1.0.6
+override TARGET_UNITS+=gdbint gdbcon
+override TARGET_EXAMPLES+=testgdb symify
+override INSTALL_FPCPACKAGE=y
+override COMPILER_OBJECTDIR+=libgdb/$(OS_TARGET)
+override COMPILER_LIBRARYDIR+=libgdb/$(OS_TARGET)
+ifdef REQUIRE_UNITSDIR
+override UNITSDIR+=$(REQUIRE_UNITSDIR)
+endif
+ifdef REQUIRE_PACKAGESDIR
+override PACKAGESDIR+=$(REQUIRE_PACKAGESDIR)
+endif
+ifdef ZIPINSTALL
+ifeq ($(OS_TARGET),linux)
+UNIXINSTALLDIR=1
+endif
+ifeq ($(OS_TARGET),freebsd)
+UNIXINSTALLDIR=1
+endif
+ifeq ($(OS_TARGET),netbsd)
+UNIXINSTALLDIR=1
+endif
+ifeq ($(OS_TARGET),sunos)
+UNIXINSTALLDIR=1
+endif
+else
+ifeq ($(OS_SOURCE),linux)
+UNIXINSTALLDIR=1
+endif
+ifeq ($(OS_SOURCE),freebsd)
+UNIXINSTALLDIR=1
+endif
+ifeq ($(OS_SOURCE),netbsd)
+UNIXINSTALLDIR=1
+endif
+ifeq ($(OS_TARGET),sunos)
+UNIXINSTALLDIR=1
+endif
+endif
+ifndef INSTALL_PREFIX
+ifdef PREFIX
+INSTALL_PREFIX=$(PREFIX)
+endif
+endif
+ifndef INSTALL_PREFIX
+ifdef UNIXINSTALLDIR
+INSTALL_PREFIX=/usr/local
+else
+ifdef INSTALL_FPCPACKAGE
+INSTALL_BASEDIR:=/pp
+else
+INSTALL_BASEDIR:=/$(PACKAGE_NAME)
+endif
+endif
+endif
+export INSTALL_PREFIX
+ifndef DIST_DESTDIR
+DIST_DESTDIR:=$(BASEDIR)
+endif
+export DIST_DESTDIR
+ifndef INSTALL_BASEDIR
+ifdef UNIXINSTALLDIR
+ifdef INSTALL_FPCPACKAGE
+INSTALL_BASEDIR:=$(INSTALL_PREFIX)/lib/fpc/$(FPC_VERSION)
+else
+INSTALL_BASEDIR:=$(INSTALL_PREFIX)/lib/$(PACKAGE_NAME)
+endif
+else
+INSTALL_BASEDIR:=$(INSTALL_PREFIX)
+endif
+endif
+ifndef INSTALL_BINDIR
+ifdef UNIXINSTALLDIR
+INSTALL_BINDIR:=$(INSTALL_PREFIX)/bin
+else
+INSTALL_BINDIR:=$(INSTALL_BASEDIR)/bin
+ifdef INSTALL_FPCPACKAGE
+INSTALL_BINDIR:=$(INSTALL_BINDIR)/$(OS_TARGET)
+endif
+endif
+endif
+ifndef INSTALL_UNITDIR
+ifdef CROSSCOMPILE
+INSTALL_UNITDIR:=$(INSTALL_BASEDIR)/cross/$(FULL_TARGET)/units
+else
+INSTALL_UNITDIR:=$(INSTALL_BASEDIR)/units/$(OS_TARGET)
+endif
+ifdef INSTALL_FPCPACKAGE
+ifdef PACKAGE_NAME
+INSTALL_UNITDIR:=$(INSTALL_UNITDIR)/$(PACKAGE_NAME)
+endif
+endif
+endif
+ifndef INSTALL_LIBDIR
+ifdef UNIXINSTALLDIR
+INSTALL_LIBDIR:=$(INSTALL_PREFIX)/lib
+else
+INSTALL_LIBDIR:=$(INSTALL_UNITDIR)
+endif
+endif
+ifndef INSTALL_SOURCEDIR
+ifdef UNIXINSTALLDIR
+ifdef INSTALL_FPCPACKAGE
+ifdef BSDhier
+INSTALL_SOURCEDIR:=$(INSTALL_PREFIX)/share/src/fpc-$(FPC_VERSION)/$(PACKAGE_NAME)
+else
+INSTALL_SOURCEDIR:=$(INSTALL_PREFIX)/src/fpc-$(FPC_VERSION)/$(PACKAGE_NAME)
+endif
+else
+ifdef BSDhier
+INSTALL_SOURCEDIR:=$(INSTALL_PREFIX)/share/src/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
+else
+INSTALL_SOURCEDIR:=$(INSTALL_PREFIX)/src/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
+endif
+endif
+else
+ifdef INSTALL_FPCPACKAGE
+INSTALL_SOURCEDIR:=$(INSTALL_BASEDIR)/source/$(PACKAGE_NAME)
+else
+INSTALL_SOURCEDIRL:=$(INSTALL_BASEDIR)/source
+endif
+endif
+endif
+ifndef INSTALL_DOCDIR
+ifdef UNIXINSTALLDIR
+ifdef INSTALL_FPCPACKAGE
+ifdef BSDhier
+INSTALL_DOCDIR:=$(INSTALL_PREFIX)/share/doc/fpc-$(FPC_VERSION)/$(PACKAGE_NAME)
+else
+INSTALL_DOCDIR:=$(INSTALL_PREFIX)/doc/fpc-$(FPC_VERSION)/$(PACKAGE_NAME)
+endif
+else
+ifdef BSDhier
+INSTALL_DOCDIR:=$(INSTALL_PREFIX)/share/doc/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
+else
+INSTALL_DOCDIR:=$(INSTALL_PREFIX)/doc/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
+endif
+endif
+else
+ifdef INSTALL_FPCPACKAGE
+INSTALL_DOCDIR:=$(INSTALL_BASEDIR)/doc/$(PACKAGE_NAME)
+else
+INSTALL_DOCDIR:=$(INSTALL_BASEDIR)/doc
+endif
+endif
+endif
+ifndef INSTALL_EXAMPLEDIR
+ifdef UNIXINSTALLDIR
+ifdef INSTALL_FPCPACKAGE
+ifdef BSDhier
+INSTALL_EXAMPLEDIR:=$(INSTALL_PREFIX)/share/examples/fpc-$(FPC_VERSION)/$(PACKAGE_NAME)
+else
+INSTALL_EXAMPLEDIR:=$(INSTALL_PREFIX)/doc/fpc-$(FPC_VERSION)/examples/$(PACKAGE_NAME)
+endif
+else
+ifdef BSDhier
+INSTALL_EXAMPLEDIR:=$(INSTALL_PREFIX)/share/examples/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
+else
+INSTALL_EXAMPLEDIR:=$(INSTALL_PREFIX)/doc/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
+endif
+endif
+else
+ifdef INSTALL_FPCPACKAGE
+INSTALL_EXAMPLEDIR:=$(INSTALL_BASEDIR)/examples/$(PACKAGE_NAME)
+else
+INSTALL_EXAMPLEDIR:=$(INSTALL_BASEDIR)/examples
+endif
+endif
+endif
+ifndef INSTALL_DATADIR
+INSTALL_DATADIR=$(INSTALL_BASEDIR)
+endif
+ifdef CROSSCOMPILE
+ifndef CROSSBINDIR
+CROSSBINDIR:=$(wildcard $(CROSSTARGETDIR)/bin/$(FULL_SOURCE))
+ifeq ($(CROSSBINDIR),)
+CROSSBINDIR:=$(wildcard $(INSTALL_BASEDIR)/cross/$(FULL_TARGET)/bin/$(FULL_SOURCE))
+endif
+endif
+else
+CROSSBINDIR=
+endif
+ifdef inUnix
+ifndef GCCLIBDIR
+GCCLIBDIR:=$(shell dirname `(gcc -v 2>&1)| head -n 1| awk '{ print $$4 } '`)
+endif
+ifeq ($(OS_TARGET),linux)
+ifndef OTHERLIBDIR
+OTHERLIBDIR:=$(shell grep -v "^\#" /etc/ld.so.conf | awk '{ ORS=" "; print $1 }')
+endif
+endif
+ifeq ($(OS_TARGET),netbsd)
+OTHERLIBDIR+=/usr/pkg/lib
+endif
+export GCCLIBDIR OTHERLIB
+endif
+LOADEREXT=.as
+EXEEXT=.exe
+PPLEXT=.ppl
+PPUEXT=.ppu
+OEXT=.o
+ASMEXT=.s
+SMARTEXT=.sl
+STATICLIBEXT=.a
+SHAREDLIBEXT=.so
+STATICLIBPREFIX=libp
+RSTEXT=.rst
+FPCMADE=fpcmade
+ifeq ($(OS_TARGET),go32v1)
+PPUEXT=.pp1
+OEXT=.o1
+ASMEXT=.s1
+SMARTEXT=.sl1
+STATICLIBEXT=.a1
+SHAREDLIBEXT=.so1
+STATICLIBPREFIX=
+FPCMADE=fpcmade.v1
+PACKAGESUFFIX=v1
+endif
+ifeq ($(OS_TARGET),go32v2)
+STATICLIBPREFIX=
+FPCMADE=fpcmade.dos
+ZIPSUFFIX=go32
+endif
+ifeq ($(OS_TARGET),linux)
+EXEEXT=
+HASSHAREDLIB=1
+FPCMADE=fpcmade.lnx
+ZIPSUFFIX=linux
+endif
+ifeq ($(OS_TARGET),freebsd)
+EXEEXT=
+HASSHAREDLIB=1
+FPCMADE=fpcmade.freebsd
+ZIPSUFFIX=freebsd
+endif
+ifeq ($(OS_TARGET),netbsd)
+EXEEXT=
+HASSHAREDLIB=1
+FPCMADE=fpcmade.netbsd
+ZIPSUFFIX=netbsd
+endif
+ifeq ($(OS_TARGET),win32)
+PPUEXT=.ppw
+OEXT=.ow
+ASMEXT=.sw
+SMARTEXT=.slw
+STATICLIBEXT=.aw
+SHAREDLIBEXT=.dll
+FPCMADE=fpcmade.w32
+ZIPSUFFIX=w32
+endif
+ifeq ($(OS_TARGET),os2)
+PPUEXT=.ppo
+ASMEXT=.so2
+OEXT=.oo2
+AOUTEXT=.out
+SMARTEXT=.so
+STATICLIBEXT=.ao2
+SHAREDLIBEXT=.dll
+FPCMADE=fpcmade.os2
+ZIPSUFFIX=emx
+endif
+ifeq ($(OS_TARGET),amiga)
+EXEEXT=
+PPUEXT=.ppa
+ASMEXT=.asm
+OEXT=.o
+SMARTEXT=.sl
+STATICLIBEXT=.a
+SHAREDLIBEXT=.library
+FPCMADE=fpcmade.amg
+endif
+ifeq ($(OS_TARGET),atari)
+PPUEXT=.ppt
+ASMEXT=.s
+OEXT=.o
+SMARTEXT=.sl
+STATICLIBEXT=.a
+EXEEXT=.ttp
+FPCMADE=fpcmade.ata
+endif
+ifeq ($(OS_TARGET),beos)
+PPUEXT=.ppu
+ASMEXT=.s
+OEXT=.o
+SMARTEXT=.sl
+STATICLIBEXT=.a
+EXEEXT=
+FPCMADE=fpcmade.be
+ZIPSUFFIX=be
+endif
+ifeq ($(OS_TARGET),sunos)
+PPUEXT=.ppu
+ASMEXT=.s
+OEXT=.o
+SMARTEXT=.sl
+STATICLIBEXT=.a
+EXEEXT=
+FPCMADE=fpcmade.sun
+ZIPSUFFIX=sun
+endif
+ifeq ($(OS_TARGET),qnx)
+PPUEXT=.ppu
+ASMEXT=.s
+OEXT=.o
+SMARTEXT=.sl
+STATICLIBEXT=.a
+EXEEXT=
+FPCMADE=fpcmade.qnx
+ZIPSUFFIX=qnx
+endif
+ifndef ECHO
+ECHO:=$(strip $(wildcard $(addsuffix /gecho$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(ECHO),)
+ECHO:=$(strip $(wildcard $(addsuffix /echo$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(ECHO),)
+ECHO=
+else
+ECHO:=$(firstword $(ECHO))
+endif
+else
+ECHO:=$(firstword $(ECHO))
+endif
+endif
+export ECHO
+ifndef DATE
+DATE:=$(strip $(wildcard $(addsuffix /gdate$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(DATE),)
+DATE:=$(strip $(wildcard $(addsuffix /date$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(DATE),)
+DATE=
+else
+DATE:=$(firstword $(DATE))
+endif
+else
+DATE:=$(firstword $(DATE))
+endif
+endif
+export DATE
+ifndef GINSTALL
+GINSTALL:=$(strip $(wildcard $(addsuffix /ginstall$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(GINSTALL),)
+GINSTALL:=$(strip $(wildcard $(addsuffix /install$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(GINSTALL),)
+GINSTALL=
+else
+GINSTALL:=$(firstword $(GINSTALL))
+endif
+else
+GINSTALL:=$(firstword $(GINSTALL))
+endif
+endif
+export GINSTALL
+ifndef CPPROG
+CPPROG:=$(strip $(wildcard $(addsuffix /cp$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(CPPROG),)
+CPPROG=
+else
+CPPROG:=$(firstword $(CPPROG))
+endif
+endif
+export CPPROG
+ifndef RMPROG
+RMPROG:=$(strip $(wildcard $(addsuffix /rm$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(RMPROG),)
+RMPROG=
+else
+RMPROG:=$(firstword $(RMPROG))
+endif
+endif
+export RMPROG
+ifndef MVPROG
+MVPROG:=$(strip $(wildcard $(addsuffix /mv$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(MVPROG),)
+MVPROG=
+else
+MVPROG:=$(firstword $(MVPROG))
+endif
+endif
+export MVPROG
+ifndef ECHOREDIR
+ECHOREDIR:=$(subst /,$(PATHSEP),$(ECHO))
+endif
+ifndef COPY
+COPY:=$(CPPROG) -fp
+endif
+ifndef COPYTREE
+COPYTREE:=$(CPPROG) -rfp
+endif
+ifndef MOVE
+MOVE:=$(MVPROG) -f
+endif
+ifndef DEL
+DEL:=$(RMPROG) -f
+endif
+ifndef DELTREE
+DELTREE:=$(RMPROG) -rf
+endif
+ifndef INSTALL
+ifdef inUnix
+INSTALL:=$(GINSTALL) -c -m 644
+else
+INSTALL:=$(COPY)
+endif
+endif
+ifndef INSTALLEXE
+ifdef inUnix
+INSTALLEXE:=$(GINSTALL) -c -m 755
+else
+INSTALLEXE:=$(COPY)
+endif
+endif
+ifndef MKDIR
+MKDIR:=$(GINSTALL) -m 755 -d
+endif
+export ECHOREDIR COPY COPYTREE MOVE DEL DELTREE INSTALL INSTALLEXE MKDIR
+ifndef PPUMOVE
+PPUMOVE:=$(strip $(wildcard $(addsuffix /ppumove$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(PPUMOVE),)
+PPUMOVE=
+else
+PPUMOVE:=$(firstword $(PPUMOVE))
+endif
+endif
+export PPUMOVE
+ifndef FPCMAKE
+FPCMAKE:=$(strip $(wildcard $(addsuffix /fpcmake$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(FPCMAKE),)
+FPCMAKE=
+else
+FPCMAKE:=$(firstword $(FPCMAKE))
+endif
+endif
+export FPCMAKE
+ifndef ZIPPROG
+ZIPPROG:=$(strip $(wildcard $(addsuffix /zip$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(ZIPPROG),)
+ZIPPROG=
+else
+ZIPPROG:=$(firstword $(ZIPPROG))
+endif
+endif
+export ZIPPROG
+ifndef TARPROG
+TARPROG:=$(strip $(wildcard $(addsuffix /tar$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(TARPROG),)
+TARPROG=
+else
+TARPROG:=$(firstword $(TARPROG))
+endif
+endif
+export TARPROG
+ASNAME=as
+LDNAME=ld
+ARNAME=ar
+RCNAME=rc
+ifeq ($(OS_TARGET),win32)
+ASNAME=asw
+LDNAME=ldw
+ARNAME=arw
+endif
+ifndef ASPROG
+ifdef CROSSBINDIR
+ASPROG=$(CROSSBINDIR)/$(ASNAME)$(SRCEXEEXT)
+else
+ASPROG=$(ASNAME)
+endif
+endif
+ifndef LDPROG
+ifdef CROSSBINDIR
+LDPROG=$(CROSSBINDIR)/$(LDNAME)$(SRCEXEEXT)
+else
+LDPROG=$(LDNAME)
+endif
+endif
+ifndef RCPROG
+ifdef CROSSBINDIR
+RCPROG=$(CROSSBINDIR)/$(RCNAME)$(SRCEXEEXT)
+else
+RCPROG=$(RCNAME)
+endif
+endif
+ifndef ARPROG
+ifdef CROSSBINDIR
+ARPROG=$(CROSSBINDIR)/$(ARNAME)$(SRCEXEEXT)
+else
+ARPROG=$(ARNAME)
+endif
+endif
+AS=$(ASPROG)
+LD=$(LDPROG)
+RC=$(RCPROG)
+AR=$(ARPROG)
+PPAS=ppas$(BATCHEXT)
+ifdef inUnix
+LDCONFIG=ldconfig
+else
+LDCONFIG=
+endif
+ifdef DATE
+DATESTR:=$(shell $(DATE) +%Y%m%d)
+else
+DATESTR=
+endif
+ifndef UPXPROG
+ifeq ($(OS_TARGET),go32v2)
+UPXPROG:=1
+endif
+ifeq ($(OS_TARGET),win32)
+UPXPROG:=1
+endif
+ifdef UPXPROG
+UPXPROG:=$(strip $(wildcard $(addsuffix /upx$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(UPXPROG),)
+UPXPROG=
+else
+UPXPROG:=$(firstword $(UPXPROG))
+endif
+else
+UPXPROG=
+endif
+endif
+export UPXPROG
+ZIPOPT=-9
+ZIPEXT=.zip
+ifeq ($(USETAR),bz2)
+TAROPT=vI
+TAREXT=.tar.bz2
+else
+TAROPT=vz
+TAREXT=.tar.gz
+endif
+override REQUIRE_PACKAGES=rtl 
+ifeq ($(OS_TARGET),linux)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(OS_TARGET),go32v2)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(OS_TARGET),win32)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(OS_TARGET),os2)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(OS_TARGET),freebsd)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(OS_TARGET),beos)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(OS_TARGET),netbsd)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(OS_TARGET),amiga)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(OS_TARGET),atari)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(OS_TARGET),sunos)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(OS_TARGET),qnx)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifdef REQUIRE_PACKAGES_RTL
+PACKAGEDIR_RTL:=$(firstword $(subst /Makefile.fpc,,$(strip $(wildcard $(addsuffix /rtl/$(OS_TARGET)/Makefile.fpc,$(PACKAGESDIR))))))
+ifneq ($(PACKAGEDIR_RTL),)
+ifneq ($(wildcard $(PACKAGEDIR_RTL)/$(OS_TARGET)),)
+UNITDIR_RTL=$(PACKAGEDIR_RTL)/$(OS_TARGET)
+else
+UNITDIR_RTL=$(PACKAGEDIR_RTL)
+endif
+else
+PACKAGEDIR_RTL=
+UNITDIR_RTL:=$(subst /Package.fpc,,$(strip $(wildcard $(addsuffix /rtl/Package.fpc,$(UNITSDIR)))))
+ifneq ($(UNITDIR_RTL),)
+UNITDIR_RTL:=$(firstword $(UNITDIR_RTL))
+else
+UNITDIR_RTL=
+endif
+endif
+ifdef UNITDIR_RTL
+override COMPILER_UNITDIR+=$(UNITDIR_RTL)
+endif
+endif
+ifndef NOCPUDEF
+override FPCOPTDEF=$(CPU_TARGET)
+endif
+ifneq ($(OS_TARGET),$(OS_SOURCE))
+override FPCOPT+=-T$(OS_TARGET)
+endif
+ifdef UNITDIR
+override FPCOPT+=$(addprefix -Fu,$(UNITDIR))
+endif
+ifdef LIBDIR
+override FPCOPT+=$(addprefix -Fl,$(LIBDIR))
+endif
+ifdef OBJDIR
+override FPCOPT+=$(addprefix -Fo,$(OBJDIR))
+endif
+ifdef INCDIR
+override FPCOPT+=$(addprefix -Fi,$(INCDIR))
+endif
+ifdef LINKSMART
+override FPCOPT+=-XX
+endif
+ifdef CREATESMART
+override FPCOPT+=-CX
+endif
+ifdef DEBUG
+override FPCOPT+=-gl
+override FPCOPTDEF+=DEBUG
+endif
+ifdef RELEASE
+ifeq ($(CPU_TARGET),i386)
+FPCCPUOPT:=-OG2p3
+else
+FPCCPUOPT:=
+endif
+override FPCOPT+=-Xs $(FPCCPUOPT) -n
+override FPCOPTDEF+=RELEASE
+endif
+ifdef STRIP
+override FPCOPT+=-Xs
+endif
+ifdef OPTIMIZE
+ifeq ($(CPU_TARGET),i386)
+override FPCOPT+=-OG2p3
+endif
+endif
+ifdef VERBOSE
+override FPCOPT+=-vwni
+endif
+ifdef COMPILER_OPTIONS
+override FPCOPT+=$(COMPILER_OPTIONS)
+endif
+ifdef COMPILER_UNITDIR
+override FPCOPT+=$(addprefix -Fu,$(COMPILER_UNITDIR))
+endif
+ifdef COMPILER_LIBRARYDIR
+override FPCOPT+=$(addprefix -Fl,$(COMPILER_LIBRARYDIR))
+endif
+ifdef COMPILER_OBJECTDIR
+override FPCOPT+=$(addprefix -Fo,$(COMPILER_OBJECTDIR))
+endif
+ifdef COMPILER_INCLUDEDIR
+override FPCOPT+=$(addprefix -Fi,$(COMPILER_INCLUDEDIR))
+endif
+ifdef CROSSBINDIR
+override FPCOPT+=-FD$(CROSSBINDIR)
+endif
+ifdef COMPILER_TARGETDIR
+override FPCOPT+=-FE$(COMPILER_TARGETDIR)
+ifeq ($(COMPILER_TARGETDIR),.)
+override TARGETDIRPREFIX=
+else
+override TARGETDIRPREFIX=$(COMPILER_TARGETDIR)/
+endif
+endif
+ifdef COMPILER_UNITTARGETDIR
+override FPCOPT+=-FU$(COMPILER_UNITTARGETDIR)
+ifeq ($(COMPILER_UNITTARGETDIR),.)
+override UNITTARGETDIRPREFIX=
+else
+override UNITTARGETDIRPREFIX=$(COMPILER_UNITTARGETDIR)/
+endif
+else
+ifdef COMPILER_TARGETDIR
+override COMPILER_UNITTARGETDIR=$(COMPILER_TARGETDIR)
+override UNITTARGETDIRPREFIX=$(TARGETDIRPREFIX)
+endif
+endif
+ifdef GCCLIBDIR
+override FPCOPT+=-Fl$(GCCLIBDIR)
+endif
+ifdef OTHERLIBDIR
+override FPCOPT+=$(addprefix -Fl,$(OTHERLIBDIR))
+endif
+ifdef OPT
+override FPCOPT+=$(OPT)
+endif
+ifdef FPCOPTDEF
+override FPCOPT+=$(addprefix -d,$(FPCOPTDEF))
+endif
+ifdef CFGFILE
+override FPCOPT+=@$(CFGFILE)
+endif
+ifdef USEENV
+override FPCEXTCMD:=$(FPCOPT)
+override FPCOPT:=!FPCEXTCMD
+export FPCEXTCMD
+endif
+override COMPILER:=$(FPC) $(FPCOPT)
+ifeq (,$(findstring -s ,$(COMPILER)))
+EXECPPAS=
+else
+ifeq ($(OS_SOURCE),$(OS_TARGET))
+EXECPPAS:=@$(PPAS)
+endif
+endif
+.PHONY: fpc_units
+ifdef TARGET_UNITS
+override ALLTARGET+=fpc_units
+override UNITPPUFILES=$(addsuffix $(PPUEXT),$(TARGET_UNITS))
+override IMPLICITUNITPPUFILES=$(addsuffix $(PPUEXT),$(TARGET_IMPLICITUNITS))
+override INSTALLPPUFILES+=$(UNITPPUFILES) $(IMPLICITUNITPPUFILES)
+override CLEANPPUFILES+=$(UNITPPUFILES) $(IMPLICITUNITPPUFILES)
+endif
+fpc_units: $(UNITPPUFILES)
+ifdef TARGET_RSTS
+override RSTFILES=$(addsuffix $(RSTEXT),$(TARGET_RSTS))
+override CLEANRSTFILES+=$(RSTFILES)
+endif
+.PHONY: fpc_examples
+ifdef TARGET_EXAMPLES
+HASEXAMPLES=1
+override EXAMPLESOURCEFILES:=$(wildcard $(addsuffix .pp,$(TARGET_EXAMPLES)) $(addsuffix .pas,$(TARGET_EXAMPLES)))
+override EXAMPLEFILES:=$(addsuffix $(EXEEXT),$(TARGET_EXAMPLES))
+override EXAMPLEOFILES:=$(addsuffix $(OEXT),$(TARGET_EXAMPLES)) $(addprefix $(STATICLIBPREFIX),$(addsuffix $(STATICLIBEXT),$(TARGET_EXAMPLES)))
+override CLEANEXEFILES+=$(EXAMPLEFILES) $(EXAMPLEOFILES)
+ifeq ($(OS_TARGET),os2)
+override CLEANEXEFILES+=$(addsuffix $(AOUTEXT),$(TARGET_EXAMPLES))
+endif
+endif
+ifdef TARGET_EXAMPLEDIRS
+HASEXAMPLES=1
+endif
+fpc_examples: all $(EXAMPLEFILES) $(addsuffix _all,$(TARGET_EXAMPLEDIRS))
+.PHONY: fpc_all fpc_smart fpc_debug fpc_release
+$(FPCMADE): $(ALLTARGET)
+	@$(ECHOREDIR) Compiled > $(FPCMADE)
+fpc_all: $(FPCMADE)
+fpc_smart:
+	$(MAKE) all LINKSMART=1 CREATESMART=1
+fpc_debug:
+	$(MAKE) all DEBUG=1
+fpc_release:
+	$(MAKE) all RELEASE=1
+.SUFFIXES: $(EXEEXT) $(PPUEXT) $(OEXT) .pas .pp .rc .res
+%$(PPUEXT): %.pp
+	$(COMPILER) $<
+	$(EXECPPAS)
+%$(PPUEXT): %.pas
+	$(COMPILER) $<
+	$(EXECPPAS)
+%$(EXEEXT): %.pp
+	$(COMPILER) $<
+	$(EXECPPAS)
+%$(EXEEXT): %.pas
+	$(COMPILER) $<
+	$(EXECPPAS)
+%.res: %.rc
+	windres -i $< -o $@
+vpath %.pp $(COMPILER_SOURCEDIR) $(COMPILER_INCLUDEDIR)
+vpath %.pas $(COMPILER_SOURCEDIR) $(COMPILER_INCLUDEDIR)
+vpath %$(PPUEXT) $(COMPILER_UNITTARGETDIR)
+.PHONY: fpc_install fpc_sourceinstall fpc_exampleinstall
+ifdef INSTALL_UNITS
+override INSTALLPPUFILES+=$(addsuffix $(PPUEXT),$(INSTALL_UNITS))
+endif
+ifdef INSTALL_BUILDUNIT
+override INSTALLPPUFILES:=$(filter-out $(INSTALL_BUILDUNIT),$(INSTALLPPUFILES))
+endif
+ifdef INSTALLPPUFILES
+override INSTALLPPULINKFILES:=$(subst $(PPUEXT),$(OEXT),$(INSTALLPPUFILES)) $(addprefix $(STATICLIBPREFIX),$(subst $(PPUEXT),$(STATICLIBEXT),$(INSTALLPPUFILES)))
+override INSTALLPPUFILES:=$(addprefix $(UNITTARGETDIRPREFIX),$(INSTALLPPUFILES))
+override INSTALLPPULINKFILES:=$(wildcard $(addprefix $(UNITTARGETDIRPREFIX),$(INSTALLPPULINKFILES)))
+override INSTALL_CREATEPACKAGEFPC=1
+endif
+ifdef INSTALLEXEFILES
+override INSTALLEXEFILES:=$(addprefix $(TARGETDIRPREFIX),$(INSTALLEXEFILES))
+endif
+fpc_install: all $(INSTALLTARGET)
+ifdef INSTALLEXEFILES
+	$(MKDIR) $(INSTALL_BINDIR)
+ifdef UPXPROG
+	-$(UPXPROG) $(INSTALLEXEFILES)
+endif
+	$(INSTALLEXE) $(INSTALLEXEFILES) $(INSTALL_BINDIR)
+endif
+ifdef INSTALL_CREATEPACKAGEFPC
+ifdef FPCMAKE
+ifdef PACKAGE_VERSION
+ifneq ($(wildcard Makefile.fpc),)
+	$(FPCMAKE) -p -T$(OS_TARGET) Makefile.fpc
+	$(MKDIR) $(INSTALL_UNITDIR)
+	$(INSTALL) Package.fpc $(INSTALL_UNITDIR)
+endif
+endif
+endif
+endif
+ifdef INSTALLPPUFILES
+	$(MKDIR) $(INSTALL_UNITDIR)
+	$(INSTALL) $(INSTALLPPUFILES) $(INSTALL_UNITDIR)
+ifneq ($(INSTALLPPULINKFILES),)
+	$(INSTALL) $(INSTALLPPULINKFILES) $(INSTALL_UNITDIR)
+endif
+ifneq ($(wildcard $(LIB_FULLNAME)),)
+	$(MKDIR) $(INSTALL_LIBDIR)
+	$(INSTALL) $(LIB_FULLNAME) $(INSTALL_LIBDIR)
+ifdef inUnix
+	ln -sf $(LIB_FULLNAME) $(INSTALL_LIBDIR)/$(LIB_NAME)
+endif
+endif
+endif
+ifdef INSTALL_FILES
+	$(MKDIR) $(INSTALL_DATADIR)
+	$(INSTALL) $(INSTALL_FILES) $(INSTALL_DATADIR)
+endif
+fpc_sourceinstall: distclean
+	$(MKDIR) $(INSTALL_SOURCEDIR)
+	$(COPYTREE) $(BASEDIR) $(INSTALL_SOURCEDIR)
+fpc_exampleinstall: $(addsuffix _distclean,$(TARGET_EXAMPLEDIRS))
+ifdef HASEXAMPLES
+	$(MKDIR) $(INSTALL_EXAMPLEDIR)
+endif
+ifdef EXAMPLESOURCEFILES
+	$(COPY) $(EXAMPLESOURCEFILES) $(INSTALL_EXAMPLEDIR)
+endif
+ifdef TARGET_EXAMPLEDIRS
+	$(COPYTREE) $(addsuffix /*,$(TARGET_EXAMPLEDIRS)) $(INSTALL_EXAMPLEDIR)
+endif
+.PHONY: fpc_distinstall
+fpc_distinstall: install exampleinstall
+.PHONY: fpc_zipinstall fpc_zipsourceinstall fpc_zipexampleinstall
+ifndef PACKDIR
+ifndef inUnix
+PACKDIR=$(BASEDIR)/../fpc-pack
+else
+PACKDIR=/tmp/fpc-pack
+endif
+endif
+ifndef ZIPNAME
+ifdef DIST_ZIPNAME
+ZIPNAME=$(DIST_ZIPNAME)
+else
+ZIPNAME=$(ZIPPREFIX)$(PACKAGE_NAME)$(ZIPSUFFIX)
+endif
+endif
+ifndef ZIPTARGET
+ifdef DIST_ZIPTARGET
+ZIPTARGET=DIST_ZIPTARGET
+else
+ZIPTARGET=install
+endif
+endif
+ifndef USEZIP
+ifdef inUnix
+USETAR=1
+endif
+endif
+ifndef inUnix
+USEZIPWRAPPER=1
+endif
+ifdef USEZIPWRAPPER
+ZIPPATHSEP=$(PATHSEP)
+ZIPWRAPPER=$(subst /,$(PATHSEP),$(DIST_DESTDIR)/fpczip$(BATCHEXT))
+else
+ZIPPATHSEP=/
+endif
+ZIPCMD_CDPACK:=cd $(subst /,$(ZIPPATHSEP),$(PACKDIR))
+ZIPCMD_CDBASE:=cd $(subst /,$(ZIPPATHSEP),$(BASEDIR))
+ifdef USETAR
+ZIPDESTFILE:=$(DIST_DESTDIR)/$(ZIPNAME)$(TAREXT)
+ZIPCMD_ZIP:=$(TARPROG) cf$(TAROPT) $(ZIPDESTFILE) *
+else
+ZIPDESTFILE:=$(DIST_DESTDIR)/$(ZIPNAME)$(ZIPEXT)
+ZIPCMD_ZIP:=$(subst /,$(ZIPPATHSEP),$(ZIPPROG)) -Dr $(ZIPOPT) $(ZIPDESTFILE) *
+endif
+fpc_zipinstall:
+	$(MAKE) $(ZIPTARGET) INSTALL_PREFIX=$(PACKDIR) ZIPINSTALL=1
+	$(MKDIR) $(DIST_DESTDIR)
+	$(DEL) $(ZIPDESTFILE)
+ifdef USEZIPWRAPPER
+ifneq ($(ECHOREDIR),echo)
+	$(ECHOREDIR) -e "$(subst \,\\,$(ZIPCMD_CDPACK))" > $(ZIPWRAPPER)
+	$(ECHOREDIR) -e "$(subst \,\\,$(ZIPCMD_ZIP))" >> $(ZIPWRAPPER)
+	$(ECHOREDIR) -e "$(subst \,\\,$(ZIPCMD_CDBASE))" >> $(ZIPWRAPPER)
+else
+	echo $(ZIPCMD_CDPACK) > $(ZIPWRAPPER)
+	echo $(ZIPCMD_ZIP) >> $(ZIPWRAPPER)
+	echo $(ZIPCMD_CDBASE) >> $(ZIPWRAPPER)
+endif
+ifdef inUnix
+	/bin/sh $(ZIPWRAPPER)
+else
+	$(ZIPWRAPPER)
+endif
+	$(DEL) $(ZIPWRAPPER)
+else
+	$(ZIPCMD_CDPACK) ; $(ZIPCMD_ZIP) ; $(ZIPCMD_CDBASE)
+endif
+	$(DELTREE) $(PACKDIR)
+fpc_zipsourceinstall:
+	$(MAKE) fpc_zipinstall ZIPTARGET=sourceinstall ZIPSUFFIX=src
+fpc_zipexampleinstall:
+ifdef HASEXAMPLES
+	$(MAKE) fpc_zipinstall ZIPTARGET=exampleinstall ZIPSUFFIX=exm
+endif
+fpc_zipdistinstall:
+	$(MAKE) fpc_zipinstall ZIPTARGET=distinstall
+.PHONY: fpc_clean fpc_cleanall fpc_distclean
+ifdef EXEFILES
+override CLEANEXEFILES:=$(addprefix $(TARGETDIRPREFIX),$(CLEANEXEFILES))
+endif
+ifdef CLEAN_UNITS
+override CLEANPPUFILES+=$(addsuffix $(PPUEXT),$(CLEAN_UNITS))
+endif
+ifdef CLEANPPUFILES
+override CLEANPPULINKFILES:=$(subst $(PPUEXT),$(OEXT),$(CLEANPPUFILES)) $(addprefix $(STATICLIBPREFIX),$(subst $(PPUEXT),$(STATICLIBEXT),$(CLEANPPUFILES)))
+override CLEANPPUFILES:=$(addprefix $(UNITTARGETDIRPREFIX),$(CLEANPPUFILES))
+override CLEANPPULINKFILES:=$(wildcard $(addprefix $(UNITTARGETDIRPREFIX),$(CLEANPPULINKFILES)))
+endif
+fpc_clean: $(CLEANTARGET)
+ifdef CLEANEXEFILES
+	-$(DEL) $(CLEANEXEFILES)
+endif
+ifdef CLEANPPUFILES
+	-$(DEL) $(CLEANPPUFILES)
+endif
+ifneq ($(CLEANPPULINKFILES),)
+	-$(DEL) $(CLEANPPULINKFILES)
+endif
+ifdef CLEANRSTFILES
+	-$(DEL) $(addprefix $(UNITTARGETDIRPREFIX),$(CLEANRSTFILES))
+endif
+ifdef CLEAN_FILES
+	-$(DEL) $(CLEAN_FILES)
+endif
+ifdef LIB_NAME
+	-$(DEL) $(LIB_NAME) $(LIB_FULLNAME)
+endif
+	-$(DEL) $(FPCMADE) Package.fpc $(PPAS) script.res link.res $(FPCEXTFILE) $(REDIRFILE)
+fpc_distclean: clean
+ifdef COMPILER_UNITTARGETDIR
+TARGETDIRCLEAN=fpc_clean
+endif
+fpc_cleanall: $(CLEANTARGET) $(TARGETDIRCLEAN)
+ifdef CLEANEXEFILES
+	-$(DEL) $(CLEANEXEFILES)
+endif
+	-$(DEL) *$(OEXT) *$(PPUEXT) *$(RSTEXT) *$(ASMEXT) *$(STATICLIBEXT) *$(SHAREDLIBEXT) *$(PPLEXT)
+	-$(DELTREE) *$(SMARTEXT)
+	-$(DEL) $(FPCMADE) Package.fpc $(PPAS) script.res link.res $(FPCEXTFILE) $(REDIRFILE)
+ifdef AOUTEXT
+	-$(DEL) *$(AOUTEXT)
+endif
+.PHONY: fpc_baseinfo
+override INFORULES+=fpc_baseinfo
+fpc_baseinfo:
+	@$(ECHO)
+	@$(ECHO)  == Package info ==
+	@$(ECHO)  Package Name..... $(PACKAGE_NAME)
+	@$(ECHO)  Package Version.. $(PACKAGE_VERSION)
+	@$(ECHO)
+	@$(ECHO)  == Configuration info ==
+	@$(ECHO)
+	@$(ECHO)  FPC.......... $(FPC)
+	@$(ECHO)  FPC Version.. $(FPC_VERSION)
+	@$(ECHO)  Source CPU... $(CPU_SOURCE)
+	@$(ECHO)  Target CPU... $(CPU_TARGET)
+	@$(ECHO)  Source OS.... $(OS_SOURCE)
+	@$(ECHO)  Target OS.... $(OS_TARGET)
+	@$(ECHO)  Full Target.. $(FULL_SOURCE)
+	@$(ECHO)  Full Source.. $(FULL_TARGET)
+	@$(ECHO)
+	@$(ECHO)  == Directory info ==
+	@$(ECHO)
+	@$(ECHO)  Required pkgs... $(REQUIRE_PACKAGES)
+	@$(ECHO)
+	@$(ECHO)  Basedir......... $(BASEDIR)
+	@$(ECHO)  FPCDir.......... $(FPCDIR)
+	@$(ECHO)  CrossBinDir..... $(CROSSBINDIR)
+	@$(ECHO)  UnitsDir........ $(UNITSDIR)
+	@$(ECHO)  PackagesDir..... $(PACKAGESDIR)
+	@$(ECHO)
+	@$(ECHO)  GCC library..... $(GCCLIBDIR)
+	@$(ECHO)  Other library... $(OTHERLIBDIR)
+	@$(ECHO)
+	@$(ECHO)  == Tools info ==
+	@$(ECHO)
+	@$(ECHO)  As........ $(AS)
+	@$(ECHO)  Ld........ $(LD)
+	@$(ECHO)  Ar........ $(AR)
+	@$(ECHO)  Rc........ $(RC)
+	@$(ECHO)
+	@$(ECHO)  Mv........ $(MVPROG)
+	@$(ECHO)  Cp........ $(CPPROG)
+	@$(ECHO)  Rm........ $(RMPROG)
+	@$(ECHO)  GInstall.. $(GINSTALL)
+	@$(ECHO)  Echo...... $(ECHO)
+	@$(ECHO)  Date...... $(DATE)
+	@$(ECHO)  FPCMake... $(FPCMAKE)
+	@$(ECHO)  PPUMove... $(PPUMOVE)
+	@$(ECHO)  Upx....... $(UPXPROG)
+	@$(ECHO)  Zip....... $(ZIPPROG)
+	@$(ECHO)
+	@$(ECHO)  == Object info ==
+	@$(ECHO)
+	@$(ECHO)  Target Loaders........ $(TARGET_LOADERS)
+	@$(ECHO)  Target Units.......... $(TARGET_UNITS)
+	@$(ECHO)  Target Implicit Units. $(TARGET_IMPLICITUNITS)
+	@$(ECHO)  Target Programs....... $(TARGET_PROGRAMS)
+	@$(ECHO)  Target Dirs........... $(TARGET_DIRS)
+	@$(ECHO)  Target Examples....... $(TARGET_EXAMPLES)
+	@$(ECHO)  Target ExampleDirs.... $(TARGET_EXAMPLEDIRS)
+	@$(ECHO)
+	@$(ECHO)  Clean Units......... $(CLEAN_UNITS)
+	@$(ECHO)  Clean Files......... $(CLEAN_FILES)
+	@$(ECHO)
+	@$(ECHO)  Install Units....... $(INSTALL_UNITS)
+	@$(ECHO)  Install Files....... $(INSTALL_FILES)
+	@$(ECHO)
+	@$(ECHO)  == Install info ==
+	@$(ECHO)
+	@$(ECHO)  DateStr.............. $(DATESTR)
+	@$(ECHO)  ZipPrefix............ $(ZIPPREFIX)
+	@$(ECHO)  ZipSuffix............ $(ZIPSUFFIX)
+	@$(ECHO)  Install FPC Package.. $(INSTALL_FPCPACKAGE)
+	@$(ECHO)
+	@$(ECHO)  Install base dir..... $(INSTALL_BASEDIR)
+	@$(ECHO)  Install binary dir... $(INSTALL_BINDIR)
+	@$(ECHO)  Install library dir.. $(INSTALL_LIBDIR)
+	@$(ECHO)  Install units dir.... $(INSTALL_UNITDIR)
+	@$(ECHO)  Install source dir... $(INSTALL_SOURCEDIR)
+	@$(ECHO)  Install doc dir...... $(INSTALL_DOCDIR)
+	@$(ECHO)  Install example dir.. $(INSTALL_EXAMPLEDIR)
+	@$(ECHO)  Install data dir..... $(INSTALL_DATADIR)
+	@$(ECHO)
+	@$(ECHO)  Dist destination dir. $(DIST_DESTDIR)
+	@$(ECHO)  Dist zip name........ $(DIST_ZIPNAME)
+	@$(ECHO)
+.PHONY: fpc_info
+fpc_info: $(INFORULES)
+.PHONY: fpc_makefile fpc_makefiles fpc_makefile_sub1 fpc_makefile_sub2 \
+	fpc_makefile_dirs
+fpc_makefile:
+	$(FPCMAKE) -w -T$(OS_TARGET) Makefile.fpc
+fpc_makefile_sub1:
+ifdef TARGET_DIRS
+	$(FPCMAKE) -w -T$(OS_TARGET) $(addsuffix /Makefile.fpc,$(TARGET_DIRS))
+endif
+ifdef TARGET_EXAMPLEDIRS
+	$(FPCMAKE) -w -T$(OS_TARGET) $(addsuffix /Makefile.fpc,$(TARGET_EXAMPLEDIRS))
+endif
+fpc_makefile_sub2: $(addsuffix _makefile_dirs,$(TARGET_DIRS) $(TARGET_EXAMPLEDIRS))
+fpc_makefile_dirs: fpc_makefile_sub1 fpc_makefile_sub2
+fpc_makefiles: fpc_makefile fpc_makefile_dirs
+all: fpc_all
+debug: fpc_debug
+smart: fpc_smart
+release: fpc_release
+examples: fpc_examples
+shared:
+install: fpc_install
+sourceinstall: fpc_sourceinstall
+exampleinstall: fpc_exampleinstall
+distinstall: fpc_distinstall
+zipinstall: fpc_zipinstall
+zipsourceinstall: fpc_zipsourceinstall
+zipexampleinstall: fpc_zipexampleinstall
+zipdistinstall: fpc_zipdistinstall
+distclean: fpc_distclean
+cleanall: fpc_cleanall
+info: fpc_info
+makefiles: fpc_makefiles
+.PHONY: all debug smart release examples shared install sourceinstall exampleinstall distinstall zipinstall zipsourceinstall zipexampleinstall zipdistinstall distclean cleanall info makefiles
+ifneq ($(wildcard fpcmake.loc),)
+include fpcmake.loc
+endif
+ifdef inUnix
+CURRDIR=./
+else
+CURRDIR=
+endif
+GDBLIBDIR+=libgdb/$(OS_TARGET)
+ifeq ($(OS_TARGET),go32v2)
+ifneq ($(DJDIR),)
+GDBLIBDIR+=$(DJDIR)/lib
+endif
+endif
+override LIBGDB:=$(firstword $(wildcard $(addsuffix /libgdb.a,$(GDBLIBDIR))))
+ifeq ($(LIBGDB),)
+GDBFOUND=0
+else
+GDBFOUND=1
+endif
+ifeq ($(GDBFOUND),1)
+$(CURRDIR)getver$(EXEEXT) : gdbver.pp
+	$(COMPILER) -o$(CURRDIR)getver$(EXEEXT) gdbver.pp
+ifndef GOTGDBVER
+gdbint$(PPUEXT): $(CURRDIR)gdbver$(EXEEXT)
+	$(MAKE) gdbint$(PPUEXT) GOTGDBVER=1
+else
+GDBVER:=GDB_V$(strip $(shell $(CURRDIR)gdbver$(EXEEXT) -n))
+gdbint$(PPUEXT): gdbint.pp
+	@$(ECHO) Using GDB $(GDBVER)
+	$(COMPILER) -d$(GDBVER) gdbint.pp
+	$(DEL) gdbver$(EXEEXT) gdbver$(OEXT)
+endif
+else
+GDBVER=GDB_V5
+gdbint$(PPUEXT): gdbint.pp
+	@$(ECHO) libgdb.a not found, using default GDB $(GDBVER)
+	$(COMPILER) -d$(GDBVER) gdbint.pp
+endif
+gdbcon$(PPUEXT): gdbcon.pp gdbint$(PPUEXT)
+ifeq ($(OS_TARGET),go32v2)
+DBGCOM=dbgcom$(OEXT)
+else
+DBGCOM=
+endif
+ifdef $(COMPILEDBGCOM)
+$(DBGCOM): ../v4.16/dbgcom.c
+	gcc -c -DFPC -Dother_sel -gstabs -o dbgcom.o -I../v4.16 ../v4.16/dbgcom.c
+else
+$(DBGCOM):
+endif
+simple: $(DBGCOM)
+	-rm gdbint.ppu
+	ppc386 -dUSE_LIBGDB gdbint
+	ppc386 testgdb
+testgdb$(EXEEXT): testgdb.pp gdbint$(PPUEXT) gdbcon$(PPUEXT) $(DBGCOM)
+.PHONY: test
+test: examples
+clean: fpc_clean
+	$(DEL) gdbver$(EXEEXT) gdbver$(OEXT)

+ 109 - 0
packages/base/gdbint/Makefile.fpc

@@ -0,0 +1,109 @@
+#
+#   Makefile.fpc for Free Pascal GDB Interface
+#
+
+[package]
+name=gdbint
+version=1.0.6
+
+[target]
+units=gdbint gdbcon
+examples=testgdb symify
+
+[compiler]
+objectdir=libgdb/$(OS_TARGET)
+librarydir=libgdb/$(OS_TARGET)
+
+[require]
+libc=y
+
+[install]
+fpcpackage=y
+
+[default]
+fpcdir=../../..
+
+
+[rules]
+# For unix be sure to use the locally created gdbver
+ifdef inUnix
+CURRDIR=./
+else
+CURRDIR=
+endif
+
+GDBLIBDIR+=libgdb/$(OS_TARGET)
+ifeq ($(OS_TARGET),go32v2)
+ifneq ($(DJDIR),)
+GDBLIBDIR+=$(DJDIR)/lib
+endif
+endif
+# Detect if libgdb.a is available
+override LIBGDB:=$(firstword $(wildcard $(addsuffix /libgdb.a,$(GDBLIBDIR))))
+ifeq ($(LIBGDB),)
+GDBFOUND=0
+else
+GDBFOUND=1
+endif
+
+ifeq ($(GDBFOUND),1)
+# libgdb.a found
+
+$(CURRDIR)getver$(EXEEXT) : gdbver.pp
+        $(COMPILER) -o$(CURRDIR)getver$(EXEEXT) gdbver.pp
+
+ifndef GOTGDBVER
+# gdbver doesn't exists, build it first
+gdbint$(PPUEXT): $(CURRDIR)gdbver$(EXEEXT)
+        $(MAKE) gdbint$(PPUEXT) GOTGDBVER=1
+else
+# gdbver exists
+GDBVER:=GDB_V$(strip $(shell $(CURRDIR)gdbver$(EXEEXT) -n))
+gdbint$(PPUEXT): gdbint.pp
+        @$(ECHO) Using GDB $(GDBVER)
+        $(COMPILER) -d$(GDBVER) gdbint.pp
+        $(DEL) gdbver$(EXEEXT) gdbver$(OEXT)
+endif
+
+else
+# libgdb.a not found, default to libgdb v5
+GDBVER=GDB_V5
+gdbint$(PPUEXT): gdbint.pp
+        @$(ECHO) libgdb.a not found, using default GDB $(GDBVER)
+        $(COMPILER) -d$(GDBVER) gdbint.pp
+endif
+
+gdbcon$(PPUEXT): gdbcon.pp gdbint$(PPUEXT)
+
+ifeq ($(OS_TARGET),go32v2)
+DBGCOM=dbgcom$(OEXT)
+else
+DBGCOM=
+endif
+
+ifdef $(COMPILEDBGCOM)
+# FPC conditionnal remove the file watching mecanism introduced
+# in v2.02 of dbgcom.c because it relies
+# on the fact that all files are opened via C lib calls
+# which is wrong for FPC !!
+$(DBGCOM): ../v4.16/dbgcom.c
+        gcc -c -DFPC -Dother_sel -gstabs -o dbgcom.o -I../v4.16 ../v4.16/dbgcom.c
+else
+$(DBGCOM):
+endif
+
+simple: $(DBGCOM)
+        -rm gdbint.ppu
+        ppc386 -dUSE_LIBGDB gdbint
+        ppc386 testgdb
+
+testgdb$(EXEEXT): testgdb.pp gdbint$(PPUEXT) gdbcon$(PPUEXT) $(DBGCOM)
+
+# Allow test for example
+.PHONY: test
+
+test: examples
+
+clean: fpc_clean
+        $(DEL) gdbver$(EXEEXT) gdbver$(OEXT)
+

+ 270 - 0
packages/base/gdbint/gdbcon.pp

@@ -0,0 +1,270 @@
+{
+    $Id$
+    Copyright (c) 1998 by Peter Vreman
+
+    Lowlevel GDB interface which communicates directly with libgdb
+
+    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.
+
+ **********************************************************************}
+unit GDBCon;
+interface
+
+uses
+  GDBInt;
+
+type
+  PGDBController=^TGDBController;
+  TGDBController=object(TGDBInterface)
+    progname   : pchar;
+    progargs   : pchar;
+    in_command,
+    init_count : longint;
+    constructor Init;
+    destructor  Done;
+    procedure CommandBegin(const s:string);virtual;
+    procedure Command(const s:string);
+    procedure CommandEnd(const s:string);virtual;
+    procedure Reset;virtual;
+    { tracing }
+    procedure StartTrace;
+    procedure Run;virtual;
+    procedure TraceStep;virtual;
+    procedure TraceNext;virtual;
+    procedure TraceStepI;virtual;
+    procedure TraceNextI;virtual;
+    procedure Continue;virtual;
+    { needed for dos because newlines are only #10 (PM) }
+    procedure WriteErrorBuf;
+    procedure WriteOutputBuf;
+    function  GetOutput : Pchar;
+    function  GetError : Pchar;
+    function  LoadFile(var fn:string):boolean;
+    procedure SetArgs(const s : string);
+    procedure ClearSymbols;
+  end;
+
+procedure UnixDir(var s : string);
+
+implementation
+
+uses
+  strings;
+
+procedure UnixDir(var s : string);
+var i : longint;
+begin
+  for i:=1 to length(s) do
+    if s[i]='\' then s[i]:='/';
+end;
+
+constructor TGDBController.Init;
+begin
+  inherited init;
+end;
+
+
+destructor TGDBController.Done;
+begin
+  if assigned(progname) then
+    strdispose(progname);
+  if assigned(progargs) then
+    strdispose(progargs);
+  inherited done;
+end;
+
+
+procedure TGDBController.Command(const s:string);
+begin
+  CommandBegin(s);
+  gdboutputbuf.reset;
+  gdberrorbuf.reset;
+  inc(in_command);
+  gdb_command(s);
+  dec(in_command);
+  {
+    What is that for ?? PM
+    I had to comment it because
+    it resets the debuggere after each command !!
+    Maybe it can happen on errors ??
+  if in_command<0 then
+   begin
+     in_command:=0;
+     inc(in_command);
+     Reset;
+     dec(in_command);
+   end; }
+  CommandEnd(s);
+end;
+
+procedure TGDBController.CommandBegin(const s:string);
+begin
+end;
+
+procedure TGDBController.CommandEnd(const s:string);
+begin
+end;
+
+function TGDBController.LoadFile(var fn:string):boolean;
+var
+  cmd : string;
+begin
+  getdir(0,cmd);
+  UnixDir(cmd);
+  cmd:='cd '+cmd;
+  Command(cmd);
+  GDB__Init;
+  UnixDir(fn);
+  if assigned(progname) then
+    strdispose(progname);
+  getmem(progname,length(fn)+1);
+  strpcopy(progname,fn);
+  if fn<>'' then
+    Command('file '+fn);
+  LoadFile:=true;
+end;
+
+procedure TGDBController.SetArgs(const s : string);
+begin
+  if assigned(progargs) then
+    strdispose(progargs);
+  getmem(progargs,length(s)+1);
+  strpcopy(progargs,s);
+  command('set args '+s);
+end;
+
+procedure TGDBController.Reset;
+begin
+  call_reset:=false;
+{ DeleteBreakPoints(); }
+  if debuggee_started then
+   begin
+     reset_command:=true;
+     BreakSession;
+     Command('kill');
+     reset_command:=false;
+     debuggee_started:=false;
+   end;
+end;
+
+procedure TGDBController.StartTrace;
+begin
+  Command('tbreak PASCALMAIN');
+  Run;
+end;
+
+procedure TGDBController.Run;
+begin
+  Command('run');
+  inc(init_count);
+end;
+
+
+procedure TGDBController.TraceStep;
+begin
+  Command('step');
+end;
+
+
+procedure TGDBController.TraceNext;
+begin
+  Command('next');
+end;
+
+
+procedure TGDBController.TraceStepI;
+begin
+  Command('stepi');
+end;
+
+
+procedure TGDBController.TraceNextI;
+begin
+  Command('nexti');
+end;
+
+
+procedure TGDBController.Continue;
+begin
+  Command('continue');
+end;
+
+
+procedure TGDBController.ClearSymbols;
+begin
+  if debuggee_started then
+   Reset;
+  if init_count>0 then
+   Command('file');
+end;
+
+
+procedure BufWrite(Buf : pchar);
+  var p,pe : pchar;
+begin
+  p:=buf;
+  While assigned(p) do
+    begin
+       pe:=strscan(p,#10);
+       if pe<>nil then
+         pe^:=#0;
+       Writeln(p);
+       { restore for dispose }
+       if pe<>nil then
+         pe^:=#10;
+       if pe=nil then
+         p:=nil
+       else
+         begin
+           p:=pe;
+           inc(p);
+         end;
+    end;
+end;
+
+
+function  TGDBController.GetOutput : Pchar;
+begin
+  GetOutput:=gdboutputbuf.buf;
+end;
+
+function  TGDBController.GetError : Pchar;
+var p : pchar;
+begin
+  p:=gdberrorbuf.buf;
+  if (p^=#0) and got_error then
+    GetError:=pchar(longint(gdboutputbuf.buf)+gdboutputbuf.idx)
+  else
+    GetError:=p;
+end;
+
+procedure TGDBController.WriteErrorBuf;
+begin
+   BufWrite(gdberrorbuf.buf);
+end;
+
+
+procedure TGDBController.WriteOutputBuf;
+begin
+   BufWrite(gdboutputbuf.buf);
+end;
+
+
+end.
+{
+  $Log$
+  Revision 1.1  2002-01-29 17:54:49  peter
+    * splitted to base and extra
+
+  Revision 1.3  2001/04/08 11:43:39  peter
+    * merged changes from fixes branch
+
+  Revision 1.2  2000/07/13 11:33:15  michael
+  + removed logs
+
+}

+ 2561 - 0
packages/base/gdbint/gdbint.pp

@@ -0,0 +1,2561 @@
+{
+    $Id$
+    Copyright (c) 1998 by Peter Vreman
+
+    Lowlevel GDB interface which communicates directly with libgdb
+
+    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.
+
+ **********************************************************************}
+unit GdbInt;
+interface
+
+{$smartlink off}
+
+{ this is not needed (PM) $output_format as}
+
+{.$define Verbose}
+{.$define DebugCommand}
+{$define NotImplemented}
+
+
+{ Default version for GDB 5 is 5.01 for now PM }
+
+{$ifdef GDB_V5}
+  {$ifndef GDB_V500}
+    {$define GDB_V501}
+  {$endif ndef GDB_V500}
+{$endif def GDB_V5}
+
+{$ifdef GDB_V502}
+  {$define GDB_V501}
+  {$define GDB_USES_PTID}
+  {$define GDB_V5}
+{$endif GDB_V502}
+
+{$ifdef GDB_V501}
+  {$define GDB_USES_PTID}
+  {$define GDB_V5}
+{$endif GDB_V501}
+
+{$ifdef GDB_V500}
+  {$define GDB_V5}
+{$endif GDB_V500}
+
+{ V4.18 is default for now }
+{ set when starting v5 support PM }
+{$ifndef GDB_V5}
+  {$ifndef GDB_V416}
+    {$define GDB_V418}
+  {$endif GDB_V416}
+{$endif GDB_V5}
+
+{$ifdef go32v2}
+  {$undef NotImplemented}
+  { ifdef GDB_V418 changed to ifndef GDB_V416}
+  {$ifdef USE_GDB_OBJS}
+    {$include gdbobjs.inc}
+  {$else USE_GDB_OBJS}
+    {$LINKLIB gdb}
+    {$ifdef GDB_V5}
+      {$LINKLIB bfd}
+      {$LINKLIB readline}
+      {$LINKLIB opcodes}
+      {$LINKLIB history}
+      {$LINKLIB iberty}
+      {$LINKLIB intl}
+    {$endif GDB_V5}
+  {$endif ndef USE_GDB_OBJS}
+  {$LINKLIB dbg}
+  {$LINKLIB c}
+{$endif go32v2}
+
+{$ifndef bsd}
+{$ifdef linux}
+  {$undef NotImplemented}
+ {$ifndef GDB_V5}
+  {$LINKLIB ncurses}
+ {$endif not GDB_V5}
+  {$LINKLIB gdb}
+    {$ifdef GDB_V5}
+      {$LINKLIB bfd}
+      {$LINKLIB readline}
+      {$LINKLIB opcodes}
+      {$LINKLIB history}
+      {$LINKLIB iberty}
+      {$LINKLIB ncurses}
+      {$LINKLIB m}
+      {$LINKLIB iberty}
+      {$LINKLIB dl}
+    {$endif GDB_V5}
+  {$LINKLIB c}
+  {$LINKLIB gcc}
+{$endif linux}
+{$endif bsd}
+
+{$ifdef freebsd}
+  {$undef NotImplemented}
+ {$ifndef GDB_V5}
+  {$LINKLIB ncurses}
+ {$endif not GDB_V5}
+  {$LINKLIB gdb}
+    {$ifdef GDB_V5}
+      {$LINKLIB bfd}
+      {$LINKLIB readline}
+      {$LINKLIB opcodes}
+      {$LINKLIB history}
+      {$LINKLIB iberty}
+      {$LINKLIB ncurses}
+      {$LINKLIB m}
+      {$LINKLIB iberty}
+      {$LINKLIB dl}
+    {$endif GDB_V5}
+  {$LINKLIB c}
+  {$LINKLIB gcc}
+{$endif freebsd}
+
+{$ifdef netbsd}
+  {$undef NotImplemented}
+ {$ifndef GDB_V5}
+  {$LINKLIB ncurses}
+ {$endif not GDB_V5}
+  {$LINKLIB gdb}
+    {$ifdef GDB_V5}
+      {$LINKLIB bfd}
+      {$LINKLIB readline}
+      {$LINKLIB opcodes}
+      {$LINKLIB history}
+      {$LINKLIB iberty}
+      {$LINKLIB ncurses}
+      {$LINKLIB m}
+      {$LINKLIB iberty}
+      {$LINKLIB intl}
+      { does not seem to exist on netbsd LINKLIB dl}
+    {$endif GDB_V5}
+  {$LINKLIB c}
+  {$LINKLIB gcc}
+{$endif netbsd}
+
+{$ifdef win32}
+  {$undef NotImplemented}
+{$ifndef GDB_V5}
+  {$LINKLIB cygwin}
+  {$LINKLIB gdb}
+  {$ifdef USE_TERMCAP}
+    {$LINKLIB termcap}
+  {$else not USE_TERMCAP}
+    {$LINKLIB ncurses}
+  {$endif not USE_TERMCAP}
+  {$LINKLIB gcc}
+  {$LINKLIB c}
+  {$LINKLIB cygwin}
+  { all those are maybe not necessary
+    but at least user32 is required
+    because of clipboard handling PM }
+  {$LINKLIB kernel32}
+  {$LINKLIB user32}
+{$else GDB_V5}
+  {$LINKLIB gdb}
+  {$LINKLIB bfd}
+  {$LINKLIB readline}
+  {$LINKLIB opcodes}
+  {$LINKLIB intl}
+  {$LINKLIB iberty}
+  {$LINKLIB termcap}
+  {$LINKLIB gcc}
+  {$LINKLIB cygwin} { alias of libm.a and libc.a }
+  {$LINKLIB iberty}
+  {$LINKLIB imagehlp}
+  {$LINKLIB kernel32}
+  {$LINKLIB user32}
+{$endif GDB_V5}
+
+{$endif win32}
+
+{$ifdef go32v2}
+  {$define supportexceptions}
+{$endif go32v2}
+{$ifdef linux}
+  {$define supportexceptions}
+{$endif linux}
+{$ifdef freebsd}
+   {$define supportexceptions}
+{$endif}
+
+{$ifdef NotImplemented}
+  {$fatal This OS is not yet supported !!!}
+{$endif NotImplemented}
+
+{$packrecords C}
+
+type
+  psyminfo=^tsyminfo;
+  tsyminfo=record
+    address  : longint;
+    fname    : pchar;
+    line     : longint;
+    funcname : pchar;
+    offset   : longint;
+  end;
+
+  tframeentry = object
+    file_name : pchar;
+    function_name : pchar;
+    args : pchar;
+    line_number : longint;
+    address : longint;
+    level : longint;
+    constructor init;
+    destructor done;
+    procedure reset;
+    procedure clear;
+  end;
+  pframeentry=^tframeentry;
+  ppframeentry=^pframeentry;
+
+{$ifndef GDB_V416}
+{ needed for handles }
+{not anymore I textrec.inc}
+
+
+type
+  CORE_ADDR = cardinal; { might be target dependent PM }
+  streamtype = (afile,astring);
+  C_FILE     = longint; { at least under DJGPP }
+  P_C_FILE   = ^C_FILE;
+
+{$ifdef GDB_V418}
+{ GDB_FILE type }
+type
+  PGDB_FILE = ^TGDB_FILE;
+  TGDB_FILE = record
+              ts_streamtype : streamtype;
+              ts_filestream : P_C_FILE;
+              ts_strbuf : pchar;
+              ts_buflen : longint;
+              end;
+{$endif GDB_V418}
+
+{$ifdef GDB_V5}
+type
+
+  pui_file = ^ui_file;
+
+  ui_file_flush_ftype = procedure(stream : pui_file);cdecl;
+  ui_file_write_ftype = procedure(stream : pui_file;buf : pchar;len : longint);cdecl;
+  ui_file_fputs_ftype = procedure(buf : pchar; stream : pui_file);cdecl;
+  ui_file_delete_ftype = procedure(stream : pui_file);cdecl;
+  ui_file_isatty_ftype = function(stream : pui_file) : longbool;cdecl;
+  ui_file_rewind_ftype = procedure(stream : pui_file);cdecl;
+  ui_file_put_method_ftype = procedure(var _object; buffer : pchar;length_buffer : longint);cdecl;
+  ui_file_put_ftype = procedure(stream : pui_file;method : ui_file_put_method_ftype;var context);cdecl;
+
+  plongint = ^longint;
+
+  ui_file = record
+      magic : plongint;
+      to_flush  : ui_file_flush_ftype;
+      to_write  : ui_file_write_ftype;
+      to_fputs  : ui_file_fputs_ftype;
+      to_delete : ui_file_delete_ftype;
+      to_isatty : ui_file_isatty_ftype;
+      to_rewind : ui_file_rewind_ftype;
+      to_put    : ui_file_put_ftype;
+      to_data   : pointer;
+    end;
+
+  { used to delete stdio_ui_file  gdb_stdout and gdb_stderr }
+  procedure ui_file_delete(stream : pui_file);cdecl;external;
+
+  { used to recreate gdb_stdout and gdb_stderr as memory streams }
+  function mem_fileopen : pui_file;cdecl;external;
+
+  { used to change the write procvar to ours }
+
+  procedure set_ui_file_write(stream : pui_file;write : ui_file_write_ftype);cdecl;external;
+
+
+{$endif GDB_V5}
+
+{$ifdef GDB_USES_PTID}
+  type
+
+  (* struct ptid
+  {
+    /* Process id */
+    int pid;
+
+    /* Lightweight process id */
+    long lwp;
+
+    /* Thread id */
+    long tid;
+  }; *)
+   pinferior_ptid = ^tinferior_ptid;
+   tinferior_ptid = record
+      pid : longint{C int};
+      lwp : longint{ C long};
+      tid : longint{ C long};
+     end;
+{$endif}
+
+{$ifdef win32}
+
+type
+  { from sys/reent.h
+    real structure is bigger but only std.. are wanted here PM }
+  REENT = record
+    err : longint;
+    stdin,stdout,stderr : P_C_FILE;
+  end;
+  PREENT = ^REENT;
+
+var _impure_ptr : PREENT;cvar;external;
+
+{$endif win32}
+
+{$endif not GDB_V416}
+
+type
+  tgdbbuffer=object
+    buf   : pchar;
+    size,
+    idx   : longint;
+{$ifdef GDB_V418}
+    link  : pgdb_file;
+{$endif not GDB_V418}
+{$ifdef GDB_V5}
+    gdb_file  : pui_file;
+{$endif not GDB_V5}
+    constructor Init;
+    destructor  Done;
+    procedure Reset;
+    procedure Resize(nsize : longint);
+    procedure Append(p:pchar);
+    procedure lappend(p:pchar;len : longint);
+  end;
+
+  pgdbinterface=^tgdbinterface;
+  tgdbinterface=object
+    gdberrorbuf,
+    gdboutputbuf  : tgdbbuffer;
+    got_error,
+    reset_command,
+    call_reset,
+    Debuggee_started : boolean;
+    { frames and frame info while recording a frame }
+    frames        : ppframeentry;
+    frame_size,
+    frame_count   : longint;
+    record_frames,
+    frame_begin_seen : boolean;
+    frame_level,
+    command_level,
+    stop_breakpoint_number,
+    current_address,
+    current_line_number,
+    signal_start,
+    signal_end,
+    error_start,
+    error_end,
+    function_start,
+    function_end,
+    args_start,
+    args_end,
+    file_start,
+    file_end,
+    line_start,
+    line_end : longint;
+    current_pc      : CORE_ADDR;
+    { breakpoint }
+    last_breakpoint_number,
+    last_breakpoint_address,
+    last_breakpoint_line : longint;
+    last_breakpoint_file : pchar;
+    invalid_breakpoint_line : boolean;
+    { init }
+    constructor init;
+    destructor  done;
+    { Lowlevel }
+    function  error:boolean;
+    function  error_num:longint;
+    procedure gdb_command(const s:string);
+    procedure gdb__init;
+    procedure gdb_done;
+    procedure resize_frames;
+    function  add_frameentry:pframeentry;
+    function  get_frameentry(level : longint):pframeentry;
+    function  get_current_frame : longint;
+    function  set_current_frame(level : longint) : boolean;
+    procedure clear_frames;
+    { Highlevel }
+    user_screen_shown,
+    switch_to_user     : boolean;
+    procedure GetAddrSyminfo(addr:longint;var si:tsyminfo);
+    procedure SelectSourceline(fn:pchar;line:longint);
+    procedure StartSession;
+    procedure BreakSession;
+    procedure EndSession(code:longint);
+    procedure DebuggerScreen;
+    procedure UserScreen;
+    { Hooks }
+    procedure DoSelectSourceline(const fn:string;line:longint);virtual;
+    procedure DoStartSession;virtual;
+    procedure DoBreakSession;virtual;
+    procedure DoEndSession(code:longint);virtual;
+    procedure DoDebuggerScreen;virtual;
+    procedure DoUserScreen;virtual;
+    function  AllowQuit : boolean;virtual;
+  end;
+
+
+function  GDBVersion : string;
+
+var
+  curr_gdb : pgdbinterface;
+
+const
+  use_gdb_file : boolean = false;
+var
+  gdb_file : text;
+{$ifdef GDB_USES_PTID}
+  inferior_ptid : tinferior_ptid;cvar;external;
+{$else}
+  inferior_pid : longint;cvar;external;
+{$endif}
+
+{$ifdef go32v2}
+  { needed to be sure %fs contains the DOS memory selector
+    used in Mem[] code PM }
+  procedure reload_fs;
+{$endif go32v2}
+
+{$ifdef GDB_USES_PTID}
+function inferior_pid : longint;
+{$endif}
+
+implementation
+
+uses
+{$ifdef win32}
+  initc,
+{$endif win32}
+{$ifdef linux}
+ {$ifndef freebsd}
+  {$ifdef ver1_0}
+    linux,
+  {$else}
+    unix,
+  {$endif}
+ {$endif}
+{$endif}
+{$ifdef freebsd}
+  {$ifdef ver1_0}
+    linux,
+  {$else}
+    unix,
+  {$endif}
+{$endif}
+{$ifdef go32v2}
+  go32,
+  dpmiexcp,
+  initc,
+{$endif}
+  strings;
+
+{*****************************************************************************
+                          Types used by libgdb.a
+*****************************************************************************}
+
+{$ifdef go32v2}
+type
+  jmp_buf = dpmi_jmp_buf;
+  pjmp_buf = pdpmi_jmp_buf;
+
+  function setjmp(var rec : jmp_buf) : longint;cdecl;external;
+
+  procedure longjmp(var rec : jmp_buf;return_value : longint);cdecl;external;
+
+  procedure reload_fs;assembler;
+  asm
+     movw  dosmemselector,%ax
+     movw  %ax,%fs
+  end['EAX'];
+
+{$endif}
+{$ifdef win32}
+type
+  jmp_buf = record
+  case byte of
+    0 :
+    { greatest value found in cygwin machine/setjmp.h for i386 }
+    (unknown_field : array [1..13] of longint;);
+    1 :
+    (eax,ebx,ecx,edx : longint;
+    esi,edi,ebp,esp,eip : longint;);
+  end;
+
+  pjmp_buf = ^jmp_buf;
+
+  function setjmp(var rec : jmp_buf) : longint;cdecl;external;
+
+  procedure longjmp(var rec : jmp_buf;return_value : longint);cdecl;external;
+
+{$ifndef supportexceptions}
+type
+  { I don't think FPC would accept that
+    the funcvar return type is the funcvar type itself ! PM }
+  SignalHandler   = Procedure(Sig : LongInt);cdecl;
+  function signal(sig : longint;new_signal : SignalHandler) : SignalHandler;cdecl;external;
+
+{define supportexceptions not yet working }
+{$endif now exceptions are supported for win32}
+{$endif win32}
+
+  type
+     pCORE_ADDR = ^CORE_ADDR;
+     pblock = ^block;
+
+     tlanguage = (language_unknown,language_auto,language_c,
+       language_cplus,language_java,language_chill,
+       language_fortran,language_m2,language_asm,
+       language_scm,language_pascal,language_objc);
+
+     bptype = (bp_breakpoint,bp_hardware_breakpoint,
+       bp_until,bp_finish,bp_watchpoint,bp_hardware_watchpoint,
+       bp_read_watchpoint,bp_access_watchpoint,
+       bp_longjmp,bp_longjmp_resume,bp_step_resume,
+       bp_through_sigtramp,bp_watchpoint_scope,
+       bp_call_dummy,bp_shlib_event);
+
+     tenable = (disabled,enabled,shlib_disabled);
+
+     bpdisp = (del,del_at_next_stop,disable,donttouch);
+
+{$PACKRECORDS 4}
+     pbreakpoint = ^breakpoint;
+     breakpoint = record
+          next : pbreakpoint;
+          typ : bptype;
+          enable : tenable;
+          disposition : bpdisp;
+          number : longint;
+          address : CORE_ADDR;
+          line_number : longint;
+          source_file : pchar;
+          silent : byte;
+          ignore_count : longint;
+          shadow_contents : array[0..15] of char;
+          inserted : char;
+          duplicate : char;
+          commands : pointer; {^command_line}
+          frame : CORE_ADDR;
+          cond : pointer; {^expression}
+          addr_string : ^char;
+          language : tlanguage;
+          input_radix : longint;
+          cond_string : ^char;
+          exp_string : ^char;
+          exp : pointer; {^expression}
+          exp_valid_block : pblock; {^block;}
+          val : pointer; {value_ptr;}
+          val_chain : pointer; {value_ptr;}
+          related_breakpoint : pbreakpoint;
+          watchpoint_frame : CORE_ADDR;
+          thread : longint;
+          hit_count : longint;
+          section : pointer; {^asection}
+       end;
+
+     tfreecode=(free_nothing,free_contents,free_linetable);
+
+     psymtab = ^symtab;
+     symtab = record
+          next : psymtab;
+          blockvector : pointer; {^blockvector;}
+          linetable : pointer; {^linetable;}
+          block_line_section : longint;
+          primary : longint;
+          filename : pchar;
+          dirname : pchar;
+          free_code : tfreecode;
+          free_ptr : pchar;
+          nlines : longint;
+          line_charpos : ^longint;
+          language : tlanguage;
+          Debugformat : pchar;
+          version : pchar;
+          fullname : pchar;
+          objfile : pointer; {^objfile;}
+       end;
+
+     psymtab_and_line = ^symtab_and_line;
+     symtab_and_line = record
+          symtab : psymtab;
+{$ifndef GDB_V416}
+          { v4.16 does not have the section field !! }
+          section : pointer; {^asection;}
+{$endif GDB_V416}
+          line : longint;
+          pc : CORE_ADDR;
+          _end : CORE_ADDR;
+       end;
+
+     symtabs_and_lines = record
+          sals : ^symtab_and_line;
+          nelts : longint;
+       end;
+
+    psymbol = ^symbol;
+    pminimal_symbol = ^minimal_symbol;
+
+    general_symbol_info = record
+  (* Name of the symbol.  This is a required field.  Storage for the name is
+     allocated on the psymbol_obstack or symbol_obstack for the associated
+     objfile. *)
+
+      _name : pchar;
+
+  (* Value of the symbol.  Which member of this union to use, and what
+     it means, depends on what kind of symbol this is and its
+     SYMBOL_CLASS.  See comments there for more details.  All of these
+     are in host byte order (though what they point to might be in
+     target byte order, e.g. LOC_CONST_BYTES).  *)
+     value : record
+       case integer of
+      (* The fact that this is a long not a LONGEST mainly limits the
+         range of a LOC_CONST.  Since LOC_CONST_BYTES exists, I'm not
+         sure that is a big deal.  *)
+       0 : (ivalue : longint;);
+
+       1 : (block  : pblock;);
+
+       2 : (bytes  : pchar;);
+
+       3 : (address : CORE_ADDR;);
+
+      (* for opaque typedef struct chain *)
+
+       4 : (chain : psymbol;);
+      end;
+
+  (* Since one and only one language can apply, wrap the language specific
+     information inside a union. *)
+
+   (* union
+    {
+      struct cplus_specific      /* For C++ */
+                                /*  and Java */
+        {
+          char *demangled_name;
+        } cplus_specific;
+      struct chill_specific      /* For Chill */
+        {
+          char *demangled_name;
+        } chill_specific;
+    } language_specific; *)
+     demangled_name : pchar;
+
+  (* Record the source code language that applies to this symbol.
+     This is used to select one of the fields from the language specific
+     union above. *)
+
+    language : tlanguage;
+
+  (* Which section is this symbol in?  This is an index into
+     section_offsets for this objfile.  Negative means that the symbol
+     does not get relocated relative to a section.
+     Disclaimer: currently this is just used for xcoff, so don't
+     expect all symbol-reading code to set it correctly (the ELF code
+     also tries to set it correctly).  *)
+
+    section : word;
+
+  (* The bfd section associated with this symbol. *)
+
+    bfd_section : pointer {^asection};
+  end; { of general_symbol_info record declaration }
+
+  tminimal_symbol_type =
+    (
+      mst_unknown := 0,         (* Unknown type, the default *)
+      mst_text,                 (* Generally executable instructions *)
+      mst_data,                 (* Generally initialized data *)
+      mst_bss,                  (* Generally uninitialized data *)
+      mst_abs,                  (* Generally absolute (nonrelocatable) *)
+      (* GDB uses mst_solib_trampoline for the start address of a shared
+         library trampoline entry.  Breakpoints for shared library functions
+         are put there if the shared library is not yet loaded.
+         After the shared library is loaded, lookup_minimal_symbol will
+         prefer the minimal symbol from the shared library (usually
+         a mst_text symbol) over the mst_solib_trampoline symbol, and the
+         breakpoints will be moved to their true address in the shared
+         library via breakpoint_re_set.  *)
+      mst_solib_trampoline,     (* Shared library trampoline code *)
+      (* For the mst_file* types, the names are only guaranteed to be unique
+         within a given .o file.  *)
+      mst_file_text,            (* Static version of mst_text *)
+      mst_file_data,            (* Static version of mst_data *)
+      mst_file_bss              (* Static version of mst_bss *)
+    );
+
+  namespace_enum = (
+  (* UNDEF_NAMESPACE is used when a namespace has not been discovered or
+     none of the following apply.  This usually indicates an error either
+     in the symbol information or in gdb's handling of symbols. *)
+  UNDEF_NAMESPACE,
+
+  (* VAR_NAMESPACE is the usual namespace.  In C, this contains variables,
+     function names, typedef names and enum type values. *)
+  VAR_NAMESPACE,
+
+  (* STRUCT_NAMESPACE is used in C to hold struct, union and enum type names.
+     Thus, if `struct foo' is used in a C program, it produces a symbol named
+     `foo' in the STRUCT_NAMESPACE. *)
+  STRUCT_NAMESPACE,
+
+  (* LABEL_NAMESPACE may be used for names of labels (for gotos);
+     currently it is not used and labels are not recorded at all.  *)
+  LABEL_NAMESPACE,
+
+  (* Searching namespaces. These overlap with VAR_NAMESPACE, providing
+     some granularity with the search_symbols function. *)
+  (* Everything in VAR_NAMESPACE minus FUNCTIONS_-, TYPES_-, and
+     METHODS_NAMESPACE *)
+  VARIABLES_NAMESPACE,
+
+  (* All functions -- for some reason not methods, though. *)
+  FUNCTIONS_NAMESPACE,
+
+  (* All defined types *)
+  TYPES_NAMESPACE,
+
+  (* All class methods -- why is this separated out? *)
+  METHODS_NAMESPACE
+
+  );
+  address_class = (
+  (* Not used; catches errors *)
+  LOC_UNDEF,
+
+  (* Value is constant int SYMBOL_VALUE, host byteorder *)
+  LOC_CONST,
+
+  (* Value is at fixed address SYMBOL_VALUE_ADDRESS *)
+  LOC_STATIC,
+
+  (* Value is in register.  SYMBOL_VALUE is the register number.  *)
+  LOC_REGISTER,
+
+  (* It's an argument; the value is at SYMBOL_VALUE offset in arglist.  *)
+  LOC_ARG,
+
+  (* Value address is at SYMBOL_VALUE offset in arglist.  *)
+  LOC_REF_ARG,
+
+  (* Value is in register number SYMBOL_VALUE.  Just like LOC_REGISTER
+     except this is an argument.  Probably the cleaner way to handle
+     this would be to separate address_class (which would include
+     separate ARG and LOCAL to deal with FRAME_ARGS_ADDRESS versus
+     FRAME_LOCALS_ADDRESS), and an is_argument flag.
+
+     For some symbol formats (stabs, for some compilers at least),
+     the compiler generates two symbols, an argument and a register.
+     In some cases we combine them to a single LOC_REGPARM in symbol
+     reading, but currently not for all cases (e.g. it's passed on the
+     stack and then loaded into a register).  *)
+  LOC_REGPARM,
+
+  (* Value is in specified register.  Just like LOC_REGPARM except the
+     register holds the address of the argument instead of the argument
+     itself. This is currently used for the passing of structs and unions
+     on sparc and hppa.  It is also used for call by reference where the
+     address is in a register, at least by mipsread.c.  *)
+  LOC_REGPARM_ADDR,
+
+  (* Value is a local variable at SYMBOL_VALUE offset in stack frame.  *)
+  LOC_LOCAL,
+
+  (* Value not used; definition in SYMBOL_TYPE.  Symbols in the namespace
+     STRUCT_NAMESPACE all have this class.  *)
+  LOC_TYPEDEF,
+
+  (* Value is address SYMBOL_VALUE_ADDRESS in the code *)
+  LOC_LABEL,
+
+  (* In a symbol table, value is SYMBOL_BLOCK_VALUE of a `struct block'.
+     In a partial symbol table, SYMBOL_VALUE_ADDRESS is the start address
+     of the block.  Function names have this class. *)
+  LOC_BLOCK,
+
+  (* Value is a constant byte-sequence pointed to by SYMBOL_VALUE_BYTES, in
+     target byte order.  *)
+  LOC_CONST_BYTES,
+
+  (* Value is arg at SYMBOL_VALUE offset in stack frame. Differs from
+     LOC_LOCAL in that symbol is an argument; differs from LOC_ARG in
+     that we find it in the frame (FRAME_LOCALS_ADDRESS), not in the
+     arglist (FRAME_ARGS_ADDRESS).  Added for i960, which passes args
+     in regs then copies to frame.  *)
+  LOC_LOCAL_ARG,
+
+  (* Value is at SYMBOL_VALUE offset from the current value of
+     register number SYMBOL_BASEREG.  This exists mainly for the same
+     things that LOC_LOCAL and LOC_ARG do; but we need to do this
+     instead because on 88k DWARF gives us the offset from the
+     frame/stack pointer, rather than the offset from the "canonical
+     frame address" used by COFF, stabs, etc., and we don't know how
+     to convert between these until we start examining prologues.
+
+     Note that LOC_BASEREG is much less general than a DWARF expression.
+     We don't need the generality (at least not yet), and storing a general
+     DWARF expression would presumably take up more space than the existing
+     scheme.  *)
+  LOC_BASEREG,
+
+  (* Same as LOC_BASEREG but it is an argument.  *)
+  LOC_BASEREG_ARG,
+
+  (* Value is at fixed address, but the address of the variable has
+     to be determined from the minimal symbol table whenever the
+     variable is referenced.
+     This happens if debugging information for a global symbol is
+     emitted and the corresponding minimal symbol is defined
+     in another object file or runtime common storage.
+     The linker might even remove the minimal symbol if the global
+     symbol is never referenced, in which case the symbol remains
+     unresolved.  *)
+  LOC_UNRESOLVED,
+
+  (* Value is at a thread-specific location calculated by a
+     target-specific method. *)
+  LOC_THREAD_LOCAL_STATIC,
+
+  (* The variable does not actually exist in the program.
+     The value is ignored.  *)
+  LOC_OPTIMIZED_OUT,
+
+  (* The variable is static, but actually lives at * (address).
+   * I.e. do an extra indirection to get to it.
+   * This is used on HP-UX to get at globals that are allocated
+   * in shared libraries, where references from images other
+   * than the one where the global was allocated are done
+   * with a level of indirection.
+   *)
+  LOC_INDIRECT
+  );
+
+   minimal_symbol = record
+  (* The general symbol info required for all types of symbols.
+     The SYMBOL_VALUE_ADDRESS contains the address that this symbol
+     corresponds to.  *)
+    ginfo : general_symbol_info;
+
+  (* The info field is available for caching machine-specific information
+     so it doesn't have to rederive the info constantly (over a serial line).
+     It is initialized to zero and stays that way until target-dependent code
+     sets it.  Storage for any data pointed to by this field should be allo-
+     cated on the symbol_obstack for the associated objfile.
+     The type would be "void *" except for reasons of compatibility with older
+     compilers.  This field is optional.
+
+     Currently, the AMD 29000 tdep.c uses it to remember things it has decoded
+     from the instructions in the function header, and the MIPS-16 code uses
+     it to identify 16-bit procedures.  *)
+
+    info : pchar;
+
+{$ifdef SOFUN_ADDRESS_MAYBE_MISSING}
+  (* Which source file is this symbol in?  Only relevant for mst_file_*.  *)
+    filename : pchar;
+{$endif}
+
+  (* Classification types for this symbol.  These should be taken as "advisory
+     only", since if gdb can't easily figure out a classification it simply
+     selects mst_unknown.  It may also have to guess when it can't figure out
+     which is a better match between two types (mst_data versus mst_bss) for
+     example.  Since the minimal symbol info is sometimes derived from the
+     BFD library's view of a file, we need to live with what information bfd
+     supplies. *)
+
+    minimal_symbol_type : tminimal_symbol_type;
+  end{ of minimal_symbol};
+
+  block = record
+  (* Addresses in the executable code that are in this block.  *)
+  startaddr,
+  endaddr : CORE_ADDR ;
+
+  (* The symbol that names this block, if the block is the body of a
+     function; otherwise, zero.  *)
+  _function : psymbol;
+
+  (* The `struct block' for the containing block, or 0 if none.
+     The superblock of a top-level local block (i.e. a function in the
+     case of C) is the STATIC_BLOCK.  The superblock of the
+     STATIC_BLOCK is the GLOBAL_BLOCK.  *)
+
+  superblock : pblock;
+
+  (* Version of GCC used to compile the function corresponding
+     to this block, or 0 if not compiled with GCC.  When possible,
+     GCC should be compatible with the native compiler, or if that
+     is not feasible, the differences should be fixed during symbol
+     reading.  As of 16 Apr 93, this flag is never used to distinguish
+     between gcc2 and the native compiler.
+
+     If there is no function corresponding to this block, this meaning
+     of this flag is undefined.  *)
+
+  gcc_compile_flag : byte;
+
+  (* Number of local symbols.  *)
+  nsyms : longint;
+
+  (* The symbols.  If some of them are arguments, then they must be
+     in the order in which we would like to print them.  *)
+  sym : array [0..0] of psymbol;
+  end { of block definition };
+
+  symbol = record
+  (* The general symbol info required for all types of symbols. *)
+    ginfo : general_symbol_info;
+
+  (* Data type of value *)
+    _type : pointer{ptype};
+
+  (* Name space code.  *)
+  namespace : namespace_enum;
+
+  (* Address class *)
+
+  aclass : address_class;
+
+  (* Line number of definition.  FIXME:  Should we really make the assumption
+     that nobody will try to debug files longer than 64K lines?  What about
+     machine generated programs? *)
+
+  line : word;
+
+  (* Some symbols require an additional value to be recorded on a per-
+     symbol basis.  Stash those values here. *)
+
+  (*union
+    {
+      /* Used by LOC_BASEREG and LOC_BASEREG_ARG.  */
+      short basereg;
+    } *)
+  aux_value_base_reg : word;
+
+  (* Link to a list of aliases for this symbol.
+     Only a "primary/main symbol may have aliases.  *)
+  aliases : pointer{palias_list};
+
+  (* List of ranges where this symbol is active.  This is only
+     used by alias symbols at the current time.  *)
+  ranges : pointer{prange_list};
+  end;
+
+     target_signal = (TARGET_SIGNAL_FIRST := 0,
+       TARGET_SIGNAL_HUP := 1,TARGET_SIGNAL_INT := 2,
+       TARGET_SIGNAL_QUIT := 3,TARGET_SIGNAL_ILL := 4,
+       TARGET_SIGNAL_TRAP := 5,TARGET_SIGNAL_ABRT := 6,
+       TARGET_SIGNAL_EMT := 7,TARGET_SIGNAL_FPE := 8,
+       TARGET_SIGNAL_KILL := 9,TARGET_SIGNAL_BUS := 10,
+       TARGET_SIGNAL_SEGV := 11,TARGET_SIGNAL_SYS := 12,
+       TARGET_SIGNAL_PIPE := 13,TARGET_SIGNAL_ALRM := 14,
+       TARGET_SIGNAL_TERM := 15,TARGET_SIGNAL_URG := 16,
+       TARGET_SIGNAL_STOP := 17,TARGET_SIGNAL_TSTP := 18,
+       TARGET_SIGNAL_CONT := 19,TARGET_SIGNAL_CHLD := 20,
+       TARGET_SIGNAL_TTIN := 21,TARGET_SIGNAL_TTOU := 22,
+       TARGET_SIGNAL_IO := 23,TARGET_SIGNAL_XCPU := 24,
+       TARGET_SIGNAL_XFSZ := 25,TARGET_SIGNAL_VTALRM := 26,
+       TARGET_SIGNAL_PROF := 27,TARGET_SIGNAL_WINCH := 28,
+       TARGET_SIGNAL_LOST := 29,TARGET_SIGNAL_USR1 := 30,
+       TARGET_SIGNAL_USR2 := 31,TARGET_SIGNAL_PWR := 32,
+       TARGET_SIGNAL_POLL := 33,TARGET_SIGNAL_WIND := 34,
+       TARGET_SIGNAL_PHONE := 35,TARGET_SIGNAL_WAITING := 36,
+       TARGET_SIGNAL_LWP := 37,TARGET_SIGNAL_DANGER := 38,
+       TARGET_SIGNAL_GRANT := 39,TARGET_SIGNAL_RETRACT := 40,
+       TARGET_SIGNAL_MSG := 41,TARGET_SIGNAL_SOUND := 42,
+       TARGET_SIGNAL_SAK := 43,TARGET_SIGNAL_PRIO := 44,
+       TARGET_SIGNAL_REALTIME_33 := 45,TARGET_SIGNAL_REALTIME_34 := 46,
+       TARGET_SIGNAL_REALTIME_35 := 47,TARGET_SIGNAL_REALTIME_36 := 48,
+       TARGET_SIGNAL_REALTIME_37 := 49,TARGET_SIGNAL_REALTIME_38 := 50,
+       TARGET_SIGNAL_REALTIME_39 := 51,TARGET_SIGNAL_REALTIME_40 := 52,
+       TARGET_SIGNAL_REALTIME_41 := 53,TARGET_SIGNAL_REALTIME_42 := 54,
+       TARGET_SIGNAL_REALTIME_43 := 55,TARGET_SIGNAL_REALTIME_44 := 56,
+       TARGET_SIGNAL_REALTIME_45 := 57,TARGET_SIGNAL_REALTIME_46 := 58,
+       TARGET_SIGNAL_REALTIME_47 := 59,TARGET_SIGNAL_REALTIME_48 := 60,
+       TARGET_SIGNAL_REALTIME_49 := 61,TARGET_SIGNAL_REALTIME_50 := 62,
+       TARGET_SIGNAL_REALTIME_51 := 63,TARGET_SIGNAL_REALTIME_52 := 64,
+       TARGET_SIGNAL_REALTIME_53 := 65,TARGET_SIGNAL_REALTIME_54 := 66,
+       TARGET_SIGNAL_REALTIME_55 := 67,TARGET_SIGNAL_REALTIME_56 := 68,
+       TARGET_SIGNAL_REALTIME_57 := 69,TARGET_SIGNAL_REALTIME_58 := 70,
+       TARGET_SIGNAL_REALTIME_59 := 71,TARGET_SIGNAL_REALTIME_60 := 72,
+       TARGET_SIGNAL_REALTIME_61 := 73,TARGET_SIGNAL_REALTIME_62 := 74,
+       TARGET_SIGNAL_REALTIME_63 := 75,TARGET_SIGNAL_UNKNOWN,
+       TARGET_SIGNAL_DEFAULT,TARGET_SIGNAL_LAST
+       );
+
+     strata = (dummy_stratum,file_stratum,core_stratum,download_stratum,process_stratum);
+
+     ptarget_ops = ^target_ops;
+     target_ops = record
+          to_shortname : pchar;
+          to_longname : pchar;
+          to_doc : pchar;
+          to_open : procedure (_para1:pchar; _para2:longint);
+          to_close : procedure (_para1:longint);
+          to_attach : procedure (_para1:pchar; _para2:longint);
+          to_detach : procedure (_para1:pchar; _para2:longint);
+          to_resume : procedure (_para1:longint; _para2:longint; _para3:target_signal);
+          to_wait : pointer; {function (_para1:longint; _para2:ptarget_waitstatus):longint;}
+          to_fetch_registers : procedure (_para1:longint);
+          to_store_registers : procedure (_para1:longint);
+          to_prepare_to_store : procedure ;
+          to_xfer_memory : function (memaddr:CORE_ADDR; myaddr:pchar; len:longint; write:longint; target:ptarget_ops):longint;
+          to_files_info : procedure (_para1:ptarget_ops);
+          to_insert_breakpoint : function (_para1:CORE_ADDR; _para2:pchar):longint;
+          to_remove_breakpoint : function (_para1:CORE_ADDR; _para2:pchar):longint;
+          to_terminal_init : procedure ;
+          to_terminal_inferior : procedure ;
+          to_terminal_ours_for_output : procedure ;
+          to_terminal_ours : procedure ;
+          to_terminal_info : procedure (_para1:pchar; _para2:longint);
+          to_kill : procedure ;
+          to_load : procedure (_para1:pchar; _para2:longint);
+          to_lookup_symbol : function (_para1:pchar; _para2:pCORE_ADDR):longint;
+          to_create_inferior : procedure (_para1:pchar; _para2:pchar; _para3:ppchar);
+          to_mourn_inferior : procedure ;
+          to_can_run : function :longint;
+          to_notice_signals : procedure (pid:longint);
+          to_thread_alive : function (pid:longint):longint;
+          to_stop : procedure ;
+          to_stratum : strata;
+          DONT_USE : pointer;
+          to_has_all_memory : longint;
+          to_has_memory : longint;
+          to_has_stack : longint;
+          to_has_registers : longint;
+          to_has_execution : longint;
+          to_sections : pointer; {^section_table}
+          to_sections_end : pointer; {^section_table}
+          to_magic : longint;
+       end;
+
+{$PACKRECORDS NORMAL}
+
+{*****************************************************************************
+                   Define external calls to libgdb.a
+*****************************************************************************}
+
+var
+{ external variables }
+  error_return : jmp_buf;cvar;{$ifndef GDB_V5}external;{$endif}
+  quit_return  : jmp_buf;cvar;{$ifndef GDB_V5}external;{$endif}
+  create_breakpoint_hook : pointer;cvar;external;
+  current_target : target_ops;cvar;external;
+  stop_pc      : CORE_ADDR;cvar;external;
+  { Only used from GDB 5.01 but doesn't hurst otherwise }
+  interpreter_p : pchar;cvar;
+
+{ we need also to declare some vars }
+  watchdog      : longint;cvar;public;
+  gdb_error     : longint;cvar;public;
+  display_time  : longbool;cvar;public;
+  display_space : longbool;cvar;public;
+
+{$ifndef GDB_V416}
+{ the following are also needed from version 4.18 }
+
+{ Whether this is the command line version or not }
+  tui_version : longint;cvar;public;
+
+{ Whether xdb commands will be handled }
+  xdb_commands : longint;cvar;public;
+
+{ Whether dbx commands will be handled }
+  dbx_commands : longint;cvar;public;
+
+{$ifndef GDB_V5}
+var
+  gdb_stdout : PGDB_FILE;cvar;public;
+  gdb_stderr : PGDB_FILE;cvar;public;
+{$else GDB_V5}
+var
+  gdb_stdout : pui_file;cvar;public;
+  gdb_stderr : pui_file;cvar;public;
+  gdb_stdlog : pui_file;cvar;public;
+  gdb_stdtarg : pui_file;cvar;public;
+  event_loop_p : longint;cvar;public;
+{$endif GDB_V5}
+
+{ used for gdb_stdout and gdb_stderr }
+function xmalloc(size : longint) : pointer;cdecl;external;
+
+{$endif not GDB_V416}
+
+function  find_pc_line(i:CORE_ADDR;l:longint):symtab_and_line;cdecl;external;
+function  find_pc_function(i:CORE_ADDR):psymbol;cdecl;external;
+function  lookup_minimal_symbol_by_pc(i : CORE_ADDR):pminimal_symbol;cdecl;external;
+procedure gdb_init;cdecl;external;
+procedure execute_command(p:pchar;i:longint);cdecl;external;
+procedure target_kill;cdecl;external;
+procedure target_close(i:longint);cdecl;external;
+
+
+{*****************************************************************************
+                                 Helpers
+*****************************************************************************}
+
+procedure Debug(const s:string);
+begin
+  if use_gdb_file then
+    Writeln(gdb_file,s)
+  else
+    Writeln(s);
+end;
+
+
+{*****************************************************************************
+                               TFrameEntry
+*****************************************************************************}
+
+constructor tframeentry.init;
+begin
+  Reset;
+end;
+
+destructor tframeentry.done;
+begin
+  Clear;
+end;
+
+procedure tframeentry.reset;
+begin
+  file_name:=nil;
+  function_name:=nil;
+  args:=nil;
+  line_number:=0;
+  address:=0;
+end;
+
+procedure tframeentry.clear;
+begin
+  if assigned(file_name) then
+   strdispose(file_name);
+  if assigned(function_name) then
+   strdispose(function_name);
+  if assigned(args) then
+   strdispose(args);
+  reset;
+end;
+
+
+{*****************************************************************************
+                                 tgdbbuffer
+*****************************************************************************}
+
+const
+  blocksize=2048;
+
+constructor tgdbbuffer.init;
+begin
+  Buf:=nil;
+{$ifdef GDB_V418}
+  link:=nil;
+{$endif GDB_V418}
+{$ifdef GDB_V5}
+  gdb_file:=nil;
+{$endif GDB_V5}
+  Size:=0;
+  Resize(blocksize);
+  Reset;
+end;
+
+
+destructor tgdbbuffer.done;
+begin
+  if assigned(buf) then
+    freemem(buf,size);
+{$ifdef GDB_V418}
+  if assigned(link) then
+    begin
+      link^.ts_streamtype:=afile;
+      link^.ts_strbuf:=nil;
+      link^.ts_buflen:=0;
+    end;
+{$endif GDB_V418}
+end;
+
+
+
+procedure tgdbbuffer.reset;
+begin
+  idx:=0;
+  Buf[0]:=#0;
+end;
+
+
+procedure tgdbbuffer.append(p:pchar);
+var
+  len : longint;
+begin
+  if not assigned(p) then
+   exit;
+  len:=Strlen(p);
+  if len+idx>size then
+   Resize(len+idx);
+  Move(p^,buf[idx],len);
+  inc(idx,len);
+  buf[idx]:=#0;
+end;
+
+
+procedure tgdbbuffer.lappend(p:pchar;len : longint);
+begin
+  if not assigned(p) then
+   exit;
+  if len+idx>size then
+   Resize(len+idx);
+  Move(p^,buf[idx],len);
+  inc(idx,len);
+  buf[idx]:=#0;
+end;
+
+
+procedure tgdbbuffer.resize(nsize : longint);
+var
+  np    : pchar;
+begin
+  nsize:=((nsize+blocksize-1) div blocksize)*blocksize;
+  getmem(np,nsize);
+  if assigned(buf) then
+    begin
+       move(buf^,np^,size);
+       freemem(buf,size);
+    end;
+  buf:=np;
+  size:=nsize;
+{$ifdef GDB_V418}
+  if assigned(link) then
+    begin
+      link^.ts_strbuf:=buf;
+      link^.ts_buflen:=size;
+    end;
+{$endif GDB_V418}
+end;
+
+
+{*****************************************************************************
+                         Hook calls from libgdb.a
+*****************************************************************************}
+
+{$ifdef go32v2}
+procedure gdbpas_prev_exception_handler;cdecl;public;
+begin
+end;
+{$endif go32v2}
+
+procedure init_proc;cdecl;public;
+begin
+end;
+
+
+procedure annotate_signalled;cdecl;public;
+begin
+{$ifdef Verbose}
+  Debug('|signalled|');
+{$endif}
+end;
+
+
+procedure annotate_signal_name;cdecl;public;
+begin
+{$ifdef Verbose}
+  Debug('|signal_name|');
+  with curr_gdb^ do
+   signal_start:=gdboutputbuf.idx;
+{$endif}
+end;
+
+
+procedure annotate_signal_name_end;cdecl;public;
+begin
+{$ifdef Verbose}
+  Debug('|signal_name_end|');
+{$endif}
+end;
+
+
+procedure annotate_signal_string;cdecl;public;
+begin
+{$ifdef Verbose}
+  Debug('|signal_string|');
+{$endif}
+end;
+
+
+procedure annotate_signal_string_end;cdecl;public;
+begin
+{$ifdef Verbose}
+  Debug('|signal_string_end|');
+{$endif}
+  with curr_gdb^ do
+   begin
+     signal_end:=gdboutputbuf.idx;
+{
+  signal = (char *)alloca(signal_end-signal_start+1);
+  strncpy(signal,gdb_output_buffer+signal_start,signal_end-signal_start);
+  signal[signal_end-signal_start] = 0;
+  if (user_screen_shown)
+    __DebuggerScreen();
+    _UserWarning(WARN_SIGNALED,signal);
+    __UserScreen();
+  else
+    _UserWarning(WARN_SIGNALED,signal); }
+     call_reset:=true;
+   end;
+end;
+
+
+procedure annotate_signal;cdecl;public;
+begin
+{$ifdef Verbose}
+  Debug('|signal|');
+{$endif}
+end;
+
+
+procedure annotate_exited(exitstatus:longint);cdecl;public;
+begin
+{$ifdef Verbose}
+  Debug('|exited|');
+{$endif}
+{#ifdef __DJGPP__
+ /* this is very important. The exit code of a djgpp program
+   disables interrupts and after this there is no other interrupt
+   called, which enables interrupts with the iret. */
+  __dpmi_get_and_enable_virtual_interrupt_state();
+#endif }
+{$ifdef go32v2}
+   {$asmmode att}
+     asm
+        movw $0x901,%ax
+        int  $0x31
+     end;
+   {$asmmode default}
+   reload_fs;
+{$endif def go32v2}
+
+  curr_gdb^.DebuggerScreen;
+{  DeleteBreakPoints; }
+  curr_gdb^.EndSession(exitstatus);
+end;
+
+
+procedure annotate_error;cdecl;public;
+begin
+{$ifdef Verbose}
+  Debug('|error|');
+{$endif}
+end;
+
+
+procedure annotate_error_begin;cdecl;public;
+begin
+{$ifdef Verbose}
+  Debug('|error begin|');
+{$endif}
+  with curr_gdb^ do
+   begin
+     error_start:=gdboutputbuf.idx+strlen(gdboutputbuf.buf);
+     got_error:=true;
+   end;
+{$ifdef Verbose}
+  Debug('|end of error begin|');
+{$endif}
+end;
+
+
+procedure annotate_starting;cdecl;public;
+begin
+{$ifdef Verbose}
+  Debug('|starting|');
+{$endif}
+{$ifdef go32v2}
+     reload_fs;
+{$endif go32v2}
+  curr_gdb^.UserScreen;
+end;
+
+
+procedure annotate_stopped;cdecl;public;
+var
+  sym : symtab_and_line;
+  fname : pchar;
+begin
+{$ifdef Verbose}
+  Debug('|stopped|');
+{$endif}
+  with curr_gdb^ do
+   begin
+{$ifdef go32v2}
+     reload_fs;
+{$endif go32v2}
+     DebuggerScreen;
+     current_pc:=stop_pc;
+     Debuggee_started:=inferior_pid<>0;
+     if not Debuggee_started then exit;
+     if reset_command then exit;
+      sym:=find_pc_line(stop_pc,0);
+     if assigned(sym.symtab) then
+      fname:=sym.symtab^.filename
+     else
+      fname:=nil;
+     SelectSourceLine(fname,sym.line);
+   end;
+end;
+
+{$ifdef GDB_USES_PTID}
+function inferior_pid : longint;
+begin
+  inferior_pid:=inferior_ptid.pid;
+end;
+{$endif}
+
+procedure proc_remove_foreign(pid:longint);cdecl;public;
+begin
+end;
+
+
+procedure breakpoints_changed;cdecl;public;
+begin
+{$ifdef Verbose}
+  Debug('|breakpoints_changed|');
+{$endif}
+end;
+
+{ only from version 5.0 }
+procedure annotate_ignore_count_change;cdecl;public;
+begin
+{$ifdef Verbose}
+  Debug('|annotate_ignore_count_change()|');
+{$endif}
+end;
+
+
+procedure annotate_breakpoint(num:longint);cdecl;public;
+begin
+{$ifdef Verbose}
+  Debug('|breakpoint(%d)|');
+{$endif}
+  With Curr_gdb^ do
+    stop_breakpoint_number:=num;
+end;
+
+
+procedure annotate_watchpoint(num:longint);cdecl;public;
+begin
+{$ifdef Verbose}
+  Debug('|watchpoint(%d)|');
+{$endif}
+  With Curr_gdb^ do
+    stop_breakpoint_number:=num;
+end;
+
+procedure annotate_catchpoint(num:longint);cdecl;public;
+begin
+{$ifdef Verbose}
+  Debug('|catchpoint(%d)|');
+{$endif}
+  With Curr_gdb^ do
+    stop_breakpoint_number:=num;
+end;
+
+
+procedure annotate_breakpoints_headers;cdecl;public;
+begin
+{$ifdef Verbose}
+  Debug('|breakpoints_headers|');
+{$endif}
+end;
+
+
+procedure annotate_breakpoints_table;cdecl;public;
+begin
+{$ifdef Verbose}
+  Debug('|breakpoints_table|');
+{$endif}
+end;
+
+
+procedure annotate_record;cdecl;public;
+begin
+{$ifdef Verbose}
+  Debug('|record|');
+{$endif}
+end;
+
+
+procedure annotate_breakpoints_table_end;cdecl;public;
+begin
+{$ifdef Verbose}
+  Debug('|breakpoints_table_end|');
+{$endif}
+end;
+
+
+procedure annotate_frames_invalid;cdecl;public;
+begin
+{$ifdef Verbose}
+  Debug('|frames_invalid|');
+{$endif}
+end;
+
+
+procedure annotate_frame_begin(level:longint;pc:CORE_ADDR);cdecl;public;
+begin
+{$ifdef Verbose}
+  Debug('|frame_begin(%d,%ld)|');
+{$endif}
+  with curr_gdb^ do
+   begin
+     frame_begin_seen:=true;
+     frame_level:=level;
+     current_address:=pc;
+     current_line_number:=-1;
+     function_start:=-1;
+     function_end:=-1;
+     args_start:=-1;
+     args_end:=-1;
+     file_start:=-1;
+     file_end:=-1;
+     line_start:=-1;
+     line_end:=-1;
+   end;
+end;
+
+
+procedure annotate_frame_address;cdecl;public;
+begin
+{$ifdef Verbose}
+  Debug('|frame_address|');
+{$endif}
+end;
+
+
+procedure annotate_frame_address_end;cdecl;public;
+begin
+{$ifdef Verbose}
+  Debug('|frame_address_end|');
+{$endif}
+end;
+
+procedure annotate_frame_function_name;cdecl;public;
+begin
+{$ifdef Verbose}
+  Debug('|frame_function_name|');
+{$endif}
+  with curr_gdb^ do
+   function_start:=gdboutputbuf.idx;
+end;
+
+
+procedure annotate_frame_args;cdecl;public;
+begin
+{$ifdef Verbose}
+  Debug('|frame_args|');
+{$endif}
+  with curr_gdb^ do
+   begin
+     function_end:=gdboutputbuf.idx;
+     args_start:=gdboutputbuf.idx;
+   end;
+end;
+
+procedure annotate_frame_source_begin;cdecl;public;
+begin
+{$ifdef Verbose}
+  Debug('|frame_source_begin|');
+{$endif}
+  with curr_gdb^ do
+   args_end:=gdboutputbuf.idx;
+end;
+
+
+procedure annotate_frame_source_file;cdecl;public;
+begin
+{$ifdef Verbose}
+  Debug('|frame_source_file|');
+{$endif}
+  with curr_gdb^ do
+   file_start:=gdboutputbuf.idx;
+end;
+
+procedure annotate_frame_source_file_end;cdecl;public;
+begin
+{$ifdef Verbose}
+  Debug('|frame_source_file_end|');
+{$endif}
+  with curr_gdb^ do
+   file_end:=gdboutputbuf.idx;
+end;
+
+
+procedure annotate_frame_source_line;cdecl;public;
+begin
+{$ifdef Verbose}
+  Debug('|frame_source_line|');
+{$endif}
+  with curr_gdb^ do
+   line_start:=gdboutputbuf.idx;
+end;
+
+
+procedure annotate_frame_source_end;cdecl;public;
+begin
+{$ifdef Verbose}
+  Debug('|frame_source_end|');
+{$endif}
+  with curr_gdb^ do
+   line_end:=gdboutputbuf.idx;
+end;
+
+
+procedure annotate_frame_where;cdecl;public;
+begin
+{$ifdef Verbose}
+  Debug('|frame_where|');
+{$endif}
+end;
+
+
+procedure annotate_frame_end;cdecl;public;
+var
+  fe : pframeentry;
+  c  : char;
+  err : integer;
+begin
+{$ifdef Verbose}
+  Debug('|frame_end|');
+{$endif}
+  with curr_gdb^ do
+   begin
+     if (not record_frames) or (not frame_begin_seen) then
+      exit;
+     { This can happen, when the function has no Debugging information }
+     if (args_start >= 0) and (args_end < 0) then
+      args_end:=gdboutputbuf.idx;
+     frame_begin_seen:=false;
+     fe:=get_frameentry(frame_level);
+     fe^.address:=current_address;
+     fe^.level:=frame_level;
+     if (function_start>=0) then
+      begin
+        c:=gdboutputbuf.buf[function_end];
+        gdboutputbuf.buf[function_end]:=#0;
+        fe^.function_name:=strnew(gdboutputbuf.buf+function_start);
+        gdboutputbuf.buf[function_end]:=c;
+      end;
+     if (file_start>=0)  then
+      begin
+        c:=gdboutputbuf.buf[file_end];
+        gdboutputbuf.buf[file_end]:=#0;
+        fe^.file_name:=strnew(gdboutputbuf.buf+file_start);
+        gdboutputbuf.buf[file_end]:=c;
+      end;
+     if (args_start>=0) then
+      begin
+        if (gdboutputbuf.buf[args_end-1]=#10) then
+         dec(args_end);
+        c:=gdboutputbuf.buf[args_end];
+        gdboutputbuf.buf[args_end]:=#0;
+        fe^.args:=strnew(gdboutputbuf.buf+args_start);
+        gdboutputbuf.buf[args_end]:=c;
+      end;
+     if (line_start>=0) then
+      begin
+        c:=gdboutputbuf.buf[line_end];
+        gdboutputbuf.buf[line_end]:=#0;
+{     sscanf(gdb_output_buffer+line_start,'%d',&fe^.line_number); }
+        val(strpas(pchar(@gdboutputbuf.buf[line_start])),fe^.line_number,err);
+        gdboutputbuf.buf[line_end]:=c;
+      end;
+   end;
+end;
+
+
+procedure annotate_quit;cdecl;public;
+begin
+{$ifdef Verbose}
+  Debug('|quit|');
+{$endif}
+end;
+
+
+procedure annotate_arg_begin;cdecl;public;
+begin
+{$ifdef Verbose}
+  Debug('|arg_begin|');
+{$endif}
+end;
+
+
+procedure annotate_arg_name_end;cdecl;public;
+begin
+{$ifdef Verbose}
+  Debug('|arg_name_end|');
+{$endif}
+end;
+
+
+procedure annotate_arg_value(typ:pointer);cdecl;public;
+begin
+{$ifdef Verbose}
+  Debug('|arg_value|');
+{$endif}
+end;
+
+
+procedure annotate_arg_end;cdecl;public;
+begin
+{$ifdef Verbose}
+  Debug('|arg_end|');
+{$endif}
+end;
+
+procedure annotate_source(filename:pchar;line,character,mid:longint;pc:CORE_ADDR);cdecl;public;
+begin
+{$ifdef Verbose}
+  Debug('|source|');
+{$endif}
+end;
+
+
+procedure annotate_function_call;cdecl;public;
+begin
+{$ifdef Verbose}
+  Debug('|function_call|');
+{$endif}
+end;
+
+
+procedure annotate_signal_handler_caller;cdecl;public;
+begin
+{$ifdef Verbose}
+  Debug('|signal_handler_caller|');
+{$endif}
+end;
+
+
+procedure annotate_array_section_begin(index:longint;elttype:pointer);cdecl;public;
+begin
+{$ifdef Verbose}
+  Debug('|array_section_begin()|');
+{$endif}
+end;
+
+
+procedure annotate_elt_rep(repcount:longint);cdecl;public;
+begin
+{$ifdef Verbose}
+  Debug('|elt_rep()|');
+{$endif}
+end;
+
+procedure annotate_elt_rep_end;cdecl;public;
+begin
+{$ifdef Verbose}
+  Debug('|elt_rep_end|');
+{$endif}
+end;
+
+
+procedure annotate_elt;cdecl;public;
+begin
+{$ifdef Verbose}
+  Debug('|elt|');
+{$endif}
+end;
+
+
+procedure annotate_array_section_end;cdecl;public;
+begin
+{$ifdef Verbose}
+  Debug('|array_section_end|');
+{$endif}
+end;
+
+procedure annotate_display_begin;cdecl;public;
+begin
+{$ifdef Verbose}
+  Debug('|display_begin|');
+{$endif}
+end;
+
+
+procedure annotate_display_number_end;cdecl;public;
+begin
+{$ifdef Verbose}
+  Debug('|display_number_end|');
+{$endif}
+end;
+
+
+procedure annotate_display_format;cdecl;public;
+begin
+{$ifdef Verbose}
+  Debug('|display_format|');
+{$endif}
+end;
+
+procedure annotate_display_expression;cdecl;public;
+begin
+{$ifdef Verbose}
+  Debug('|display_expression|');
+{$endif}
+end;
+
+
+procedure annotate_display_expression_end;cdecl;public;
+begin
+{$ifdef Verbose}
+  Debug('|display_expression_end|');
+{$endif}
+end;
+
+
+procedure annotate_display_value;cdecl;public;
+begin
+{$ifdef Verbose}
+  Debug('|display_value|');
+{$endif}
+end;
+
+
+procedure annotate_display_end;cdecl;public;
+begin
+{$ifdef Verbose}
+  Debug('|display_end|');
+{$endif}
+end;
+
+
+procedure annotate_field (num:longint);cdecl;public;
+begin
+{$ifdef Verbose}
+  Debug('a_field(%d)');
+{$endif}
+end;
+
+
+procedure annotate_field_begin(typ:pointer);cdecl;public;
+begin
+{$ifdef Verbose}
+  Debug('a_field_begin\n');
+{$endif}
+end;
+
+
+procedure annotate_field_name_end;cdecl;public;
+begin
+{$ifdef Verbose}
+  Debug('a_field_name_end\n');
+{$endif}
+end;
+
+
+procedure annotate_field_value;cdecl;public;
+begin
+{$ifdef Verbose}
+  Debug('a_field_value\n');
+{$endif}
+end;
+
+
+procedure annotate_field_end;cdecl;public;
+begin
+{$ifdef Verbose}
+  Debug('a_field_end\n');
+{$endif}
+end;
+
+
+procedure annotate_value_history_begin (histindex:longint;typ:pointer);cdecl;public;
+begin
+{$ifdef Verbose}
+  Debug('a_value_history_begin(%d)\n');
+{$endif}
+end;
+
+
+procedure annotate_value_begin (typ:pointer);cdecl;public;
+begin
+{$ifdef Verbose}
+  Debug('a_value_begin\n');
+{$endif}
+end;
+
+
+procedure annotate_value_history_value;cdecl;public;
+begin
+{$ifdef Verbose}
+  Debug('a_value_history_value\n');
+{$endif}
+end;
+
+
+procedure annotate_value_history_end;cdecl;public;
+begin
+{$ifdef Verbose}
+  Debug('a_value_history_end\n');
+{$endif}
+end;
+
+
+procedure annotate_value_end;cdecl;public;
+begin
+{$ifdef Verbose}
+  Debug('a_value_end\n');
+{$endif}
+end;
+
+
+procedure _initialize_annotate;cdecl;public;
+begin
+end;
+
+{$ifndef GDB_V5}
+procedure fputs_unfiltered(linebuffer:pchar;stream:pointer);cdecl;public;
+begin
+  with curr_gdb^ do
+{$ifdef gdb_v418}
+  if stream = gdb_stderr then
+     gdberrorbuf.append(linebuffer)
+  else
+{$endif gdb_v418}
+     gdboutputbuf.append(linebuffer);
+end;
+{$else GDB_V5}
+
+procedure gdbint_ui_file_write(stream : pui_file; p : pchar; len : longint);cdecl;
+begin
+  if assigned(curr_gdb) then
+   with curr_gdb^ do
+    if stream = gdb_stderr then
+       gdberrorbuf.lappend(p,len)
+    else if stream = gdb_stdout then
+       gdboutputbuf.lappend(p,len)
+    else
+      begin
+       gdberrorbuf.append('Unknown gdb ui_file');
+       gdberrorbuf.lappend(p,len);
+      end;
+end;
+{$endif GDB_V5}
+
+
+procedure CreateBreakPointHook(var b:breakpoint);cdecl;
+var
+  sym : symtab_and_line;
+
+{ this procedure is only here to avoid the problems
+  with different version of gcc having different stack
+  handling:
+  on older versions find_pc_line uses just "ret"
+  while on newer gcc version "ret $4" is used
+  if this call is within the CreateBreakPointHook function
+  it changes %esp and thus the registers are
+  not restored correctly PM }
+  procedure get_pc_line;
+    begin
+      sym:=find_pc_line(b.address,0);
+    end;
+begin
+  get_pc_line;
+  with curr_gdb^ do
+   begin
+     last_breakpoint_number:=b.number;
+     { function breakpoints have zero as file and as line !!
+       but they are valid !! }
+     invalid_breakpoint_line:=(b.line_number<>sym.line) and (b.line_number<>0);
+     last_breakpoint_address:=b.address;
+     last_breakpoint_line:=sym.line;
+     if assigned(sym.symtab) then
+      last_breakpoint_file:=sym.symtab^.filename
+     else
+      last_breakpoint_file:=nil;
+   end;
+end;
+
+
+{*****************************************************************************
+                                 tgdbinterface
+*****************************************************************************}
+
+constructor tgdbinterface.init;
+begin
+  gdboutputbuf.init;
+  gdberrorbuf.init;
+  record_frames:=true;
+{$ifdef GDB_V418}
+(* GDB_FILE *
+  gdb_file_init_astring (n)
+    int n;
+  should we use xmalloc ?
+  gdb could resize the buffer => crash,
+  but normally it should not if unfiltered !! PM *)
+  gdb_stdout^.ts_streamtype := astring;
+  gdb_stdout^.ts_strbuf := gdboutputbuf.buf;
+  gdb_stdout^.ts_buflen := gdboutputbuf.size;
+  gdboutputbuf.link:=gdb_stdout;
+
+  gdb_stderr^.ts_streamtype := astring;
+  gdb_stderr^.ts_strbuf := gdberrorbuf.buf;
+  gdb_stderr^.ts_buflen := gdberrorbuf.size;
+  gdberrorbuf.link:=gdb_stderr;
+{$endif GDB_V418}
+
+{$ifdef GDB_V5}
+
+{$endif GDB_V5}
+  { This must be placed before gdb__init is called
+    as gdb_init might issue output PM }
+  curr_gdb:=@self;
+  gdb__init;
+  command_level:=0;
+{ set output mode for GDB }
+{ only these values disable filtering
+  DONT CHANGE THEM !!! PM }
+  gdb_command('set width 0xffffffff');
+  gdb_command('set height 0xffffffff');
+{ other standard commands used for fpc debugging }
+  gdb_command('set print demangle off');
+  gdb_command('set gnutarget auto');
+  gdb_command('set language auto');
+  gdb_command('set print vtbl on');
+  gdb_command('set print object on');
+  gdb_command('set print null-stop');
+end;
+
+
+destructor tgdbinterface.done;
+begin
+  clear_frames;
+  gdb_done;
+  gdboutputbuf.done;
+  gdberrorbuf.done;
+end;
+
+
+procedure tgdbinterface.gdb__init;
+begin
+  gdboutputbuf.reset;
+  gdberrorbuf.reset;
+  create_breakpoint_hook:=@CreateBreakPointHook;
+end;
+
+
+
+procedure tgdbinterface.gdb_done;
+begin
+  if debuggee_started then
+    begin
+      current_target.to_kill;
+      current_target.to_close(1);
+    end;
+  create_breakpoint_hook:=nil;
+end;
+
+
+function tgdbinterface.error:boolean;
+begin
+  error:=got_error;
+end;
+
+function tgdbinterface.error_num:longint;
+begin
+  error_num:=gdb_error;
+end;
+
+var
+   top_level_val : longint;
+
+{$ifdef GDB_V5}
+function catch_errors(func : pointer; command : pchar; from_tty,mask : longint) : longint;cdecl;external;
+
+function gdbint_execute_command(command : pchar; from_tty,mask : longint) : longint;cdecl;
+begin
+  gdbint_execute_command:=1;
+  execute_command(command,from_tty);
+  gdbint_execute_command:=0;
+end;
+{$endif GDB_V5}
+
+procedure tgdbinterface.gdb_command(const s:string);
+var
+  command          : array[0..256] of char;
+{$ifdef GDB_V5}
+  mask : longint;
+{$endif GDB_V5}
+  s2 : string;
+  old_quit_return,
+  old_error_return : jmp_buf;
+begin
+  inc(command_level);
+  move(s[1],command,length(s));
+  command[length(s)]:=#0;
+  old_quit_return:=quit_return;
+  old_error_return:=error_return;
+  gdb_error:=0;
+  got_error:=false;
+  stop_breakpoint_number:=0;
+  { Trap quit commands }
+  s2:=s;
+  while (length(s2)>0) and ((s2[1]=' ') or (s2[1]=#9)) do
+    s2:=copy(s2,2,255);
+  if (length(s2)>0) and
+     (UpCase(s2[1])='Q') and
+     ((length(s2)=1) or
+      (s2[2]=' ') or
+      ((UpCase(s2[2])='U') and
+      ((length(s2)=2) or
+       (s2[3]=' ') or
+       ((UpCase(s2[3])='I') and
+        ((length(s2)=3) or
+         (s2[4]=' ') or
+         ((UpCase(s2[4])='T') and
+          ((length(s2)=4) or
+           (s2[5]=' ')
+     ))))))) then
+    begin
+      if not AllowQuit then
+        exit;
+    end;
+{$ifdef DebugCommand}
+  Debug('start of handle_gdb_command ('+s+')');
+{$endif}
+  top_level_val:=setjmp(error_return);
+  if top_level_val=0 then
+   begin
+     quit_return:=error_return;
+{$ifdef GDB_V5}
+     mask:=$ffffffff;
+     catch_errors(@gdbint_execute_command,@command,0,mask);
+{$else not  GDB_V5}
+     execute_command(@command,0);
+{$endif not  GDB_V5}
+{$ifdef go32v2}
+     reload_fs;
+{$endif go32v2}
+   end
+  else
+{$ifdef Verbose}
+    Debug('error longjmp in handle_gdb_command ('+s+')');
+{$endif}
+   ;
+{$ifdef DebugCommand}
+  Debug('end of handle_gdb_command ('+s+')');
+{$endif}
+  quit_return:=old_quit_return;
+  error_return:=old_error_return;
+  dec(command_level);
+end;
+
+
+procedure tgdbinterface.resize_frames;
+var
+  i : longint;
+  new_frames : ppframeentry;
+begin
+  if (frame_count>=frame_size) then
+   begin
+     getmem(new_frames,sizeof(pointer)*(frame_count+1));
+     for i:=0 to frame_size-1 do
+       new_frames[i]:=frames[i];
+     if assigned(frames) then
+       freemem(frames,sizeof(pointer)*frame_size);
+     frames:=new_frames;
+     frame_size:=frame_count+1;
+     for i:=frame_count to frame_size-1 do
+      frames[i]:=new(pframeentry,init);
+  end;
+end;
+
+
+function tgdbinterface.add_frameentry:pframeentry;
+begin
+  resize_frames;
+  add_frameentry:=frames[frame_count];
+  inc(frame_count);
+end;
+
+function tgdbinterface.get_frameentry(level : longint) : pframeentry;
+begin
+  { only climb values one by one PM }
+  if level>=frame_count then
+    resize_frames;
+  get_frameentry:=frames[level];
+  frames[level]^.clear;
+  if level>=frame_count then
+    inc(frame_count);
+end;
+
+
+procedure tgdbinterface.clear_frames;
+var
+  i : longint;
+begin
+  for i:=0 to frame_size-1 do
+   dispose(frames[i],done);
+  freemem(frames,sizeof(pointer)*Frame_size);
+  frame_count:=0;
+  frame_size:=0;
+end;
+
+function tgdbinterface.get_current_frame : longint;
+begin
+  record_frames:=false;
+  gdb_command('f');
+  get_current_frame:=frame_level;
+  record_frames:=true;
+end;
+
+function tgdbinterface.set_current_frame(level : longint) : boolean;
+var
+  s : string;
+begin
+  record_frames:=false;
+  str(level,s);
+  gdb_command('f '+s);
+  if level=frame_level then
+    set_current_frame:=true
+  else
+    set_current_frame:=false;
+  record_frames:=true;
+end;
+
+
+{*****************************************************************************
+                      Highlevel tgdbinterface
+*****************************************************************************}
+
+procedure tgdbinterface.GetAddrSyminfo(addr:longint;var si:tsyminfo);
+var
+  sym : symtab_and_line;
+  symbol : psymbol;
+begin
+  sym:=find_pc_line(addr,1);
+  fillchar(si,sizeof(tsyminfo),0);
+  si.address:=addr;
+  si.offset:=addr-sym.pc;
+  if assigned(sym.symtab) then
+   si.fname:=sym.symtab^.filename
+  else
+   si.fname:=nil;
+  si.line:=sym.line;
+  symbol:=find_pc_function(addr);
+  if assigned(symbol) then
+   si.funcname:=symbol^.ginfo._name
+  else
+   si.funcname:=nil;
+end;
+
+
+procedure tgdbinterface.SelectSourceLine(fn:pchar;line:longint);
+begin
+  if assigned(fn) then
+   DoSelectSourceLine(StrPas(fn),line)
+  else
+   DoSelectSourceLine('',line);
+end;
+
+
+procedure tgdbinterface.StartSession;
+begin
+  DoStartSession;
+end;
+
+
+procedure tgdbinterface.BreakSession;
+begin
+  DoBreakSession;
+end;
+
+
+procedure tgdbinterface.EndSession(code:longint);
+begin
+  Debuggee_started:=false;
+{$ifdef Go32v2}
+{$ifdef GDB_USES_PTID}
+  inferior_ptid.pid:=0;
+{$else}
+  inferior_pid:=0;
+{$endif}
+{$endif}
+  DoEndSession(code);
+end;
+
+
+procedure tgdbinterface.DebuggerScreen;
+begin
+{$ifdef Verbose}
+  Debug('|DebuggerScreen|');
+{$endif}
+  if user_screen_shown then
+   DoDebuggerScreen;
+  user_screen_shown:=false;
+end;
+
+
+procedure tgdbinterface.UserScreen;
+begin
+{$ifdef Verbose}
+  Debug('|UserScreen|');
+{$endif}
+  if switch_to_user then
+   begin
+     if (not user_screen_shown) then
+      DoUserScreen;
+     user_screen_shown:=true;
+   end;
+end;
+
+
+
+{---------------------------------------
+          Default Hooks
+---------------------------------------}
+
+procedure tgdbinterface.DoSelectSourceLine(const fn:string;line:longint);
+{$ifdef Verbose}
+var
+  s : string;
+{$endif}
+begin
+{$ifdef Verbose}
+  Str(line,S);
+  Debug('|SelectSource '+fn+':'+s+'|');
+{$endif}
+end;
+
+procedure tgdbinterface.DoStartSession;
+begin
+end;
+
+procedure tgdbinterface.DoBreakSession;
+begin
+end;
+
+procedure tgdbinterface.DoEndSession(code:longint);
+begin
+end;
+
+procedure tgdbinterface.DoDebuggerScreen;
+begin
+end;
+
+procedure tgdbinterface.DoUserScreen;
+begin
+end;
+
+function  tgdbinterface.AllowQuit : boolean;
+begin
+  AllowQuit:=true;
+end;
+
+{$ifdef GDB_V5}
+var
+  version : array[0..0] of char;cvar;external;
+
+procedure error_init;cdecl;external;
+
+{$else}
+var
+  version : pchar;cvar;
+{$endif}
+
+function  GDBVersion : string;
+begin
+  GDBVersion:='GDB '+StrPas(version);
+end;
+
+
+const next_exit : pointer = nil;
+procedure DoneLibGDB;
+begin
+  exitproc:=next_exit;
+{$ifdef GDB_V418}
+  if assigned(gdb_stdout) then
+    dispose(gdb_stdout);
+  gdb_stdout:=nil;
+  if assigned(gdb_stderr) then
+    dispose(gdb_stderr);
+  gdb_stderr:=nil;
+{$endif GDB_V418}
+end;
+
+{$ifdef go32v2}
+var
+  c_environ : ppchar;external name '_environ';
+  c_argc : longint;external name '___crt0_argc';
+  c_argv : ppchar;external name '___crt0_argv';
+{$endif def go32v2}
+
+{$ifdef GDB_V418}
+{$ifndef go32v2}
+{$ifndef win32}
+var
+   stdout : p_c_file;cvar;external;
+   stderr : p_c_file;cvar;external;
+{$endif win32}
+{$else go32v2}
+{ the type is not really important
+  for external cvars PM
+  but the main problem is that stdout and stderr
+  and defined as macros under DJGPP !! }
+var
+   __dj_stdout : c_file;cvar;external;
+   __dj_stderr : c_file;cvar;external;
+{$endif go32v2}
+{$endif not GDB_V418}
+
+procedure InitLibGDB;
+{$ifdef supportexceptions}
+var
+  OldSigInt : SignalHandler;
+{$endif supportexceptions}
+begin
+{$ifdef go32v2}
+  c_environ:=system.envp;
+  c_argc:=system.argc;
+  c_argv:=system.argv;
+{$endif def go32v2}
+{$ifdef supportexceptions}
+{$ifdef go32v2}
+  OldSigInt:=Signal(SIGINT,SignalHandler(@SIG_DFL));
+{$else}
+  OldSigInt:=Signal(SIGINT,SignalHandler(SIG_DFL));
+{$endif}
+{$endif supportexceptions}
+
+{$ifdef GDB_V418}
+  new(gdb_stdout);
+
+  gdb_stdout^.ts_streamtype := afile;
+{$ifndef go32v2}
+{$ifdef win32}
+ gdb_stdout^.ts_filestream := _impure_ptr^.stdout;
+{$else not win32 }
+ gdb_stdout^.ts_filestream := stdout;{p_c_file(textrec(output).handle); was wrong PM }
+{$endif not win32 }
+{$else go32v2}
+  gdb_stdout^.ts_filestream := @__dj_stdout;
+{$endif go32v2}
+  gdb_stdout^.ts_strbuf := nil;
+  gdb_stdout^.ts_buflen := 0;
+
+  new(gdb_stderr);
+  gdb_stderr^.ts_streamtype := afile;
+{$ifndef go32v2}
+{$ifdef win32}
+  gdb_stderr^.ts_filestream := _impure_ptr^.stderr;
+{$else not win32 }
+  gdb_stderr^.ts_filestream := stderr;
+{$endif not win32 }
+{$else go32v2}
+  gdb_stderr^.ts_filestream := @__dj_stderr;
+{$endif go32v2}
+  gdb_stderr^.ts_strbuf := nil;
+  gdb_stderr^.ts_buflen := 0;
+{$endif  GDB_V418}
+
+{$ifdef GDB_V5}
+  if assigned(gdb_stderr) then
+    ui_file_delete(gdb_stderr);
+  if assigned(gdb_stdout) then
+    ui_file_delete(gdb_stdout);
+  gdb_stderr:=mem_fileopen;
+  gdb_stdout:=mem_fileopen;
+  gdb_stdlog:=gdb_stderr;
+  gdb_stdtarg:=gdb_stderr;
+  set_ui_file_write(gdb_stdout,@gdbint_ui_file_write);
+  set_ui_file_write(gdb_stderr,@gdbint_ui_file_write);
+  error_init;
+{$endif GDB_V5}
+
+  next_exit:=exitproc;
+  exitproc:=@DoneLibGDB;
+  gdb_init;
+{$ifdef supportexceptions}
+  Signal(SIGINT,OldSigInt);
+{$endif supportexceptions}
+  if setjmp(error_return)=0 then
+    begin
+       quit_return:=error_return;
+       exit;
+    end
+  else
+    begin
+{$ifdef Verbose}
+       Debug('|LongJump to Init|');
+{$endif}
+{$ifdef go32v2}
+       RunError(99);
+{$endif def go32v2}
+    end;
+  WatchDog:=0;
+end;
+
+
+begin
+  InitLibGDB;
+end.
+{
+  $Log$
+  Revision 1.1  2002-01-29 17:54:49  peter
+    * splitted to base and extra
+
+  Revision 1.13  2002/01/25 22:39:29  pierre
+   * fix problem with 5.0 lib version
+
+  Revision 1.12  2002/01/24 12:31:51  pierre
+   * fix go32v2 compilation for gdb 5.1
+
+  Revision 1.11  2002/01/24 09:14:39  pierre
+   * adapt to GDB 5.1
+
+  Revision 1.10  2002/01/07 10:31:57  pierre
+   * avoid problem if gdb start generates output
+
+  Revision 1.9  2001/09/19 15:25:56  pierre
+   + define inferior_pid as a function for 5.01
+
+  Revision 1.8  2001/09/11 10:22:36  pierre
+   + NetBSD support
+
+  Revision 1.7  2001/07/31 15:42:11  pierre
+   + first lines to support coming 5.1 release
+
+  Revision 1.6  2001/04/20 18:43:00  marco
+   * Freebsd fix
+
+  Revision 1.5  2001/04/08 11:43:39  peter
+    * merged changes from fixes branch
+
+  Revision 1.4  2001/01/21 21:38:52  marco
+   * renamefest in packages
+
+  Revision 1.3  2000/10/08 10:07:22  peter
+    * merged fixes from Pierre
+
+  Revision 1.2  2000/07/13 11:33:15  michael
+  + removed logs
+}

+ 192 - 0
packages/base/gdbint/gdbobjs.inc

@@ -0,0 +1,192 @@
+{
+    $Id$
+    Copyright (c) 1999 by Pierre Muller
+    
+    direct GDB objects linking for debug info
+
+    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.
+
+ **********************************************************************}
+
+{ gdb-version/gdb directory must be in objects path }
+{ use ifdef or ifndef GDB_V416 to change objects needed for
+  different gdb versions }
+
+{$L infcmd.o}
+{$L symtab.o}
+{$L top.o}
+{$L target.o}
+{$L utils.o}
+{$L breakpoi.o}
+{$L corefile.o}
+{$L symfile.o}
+{$L ../libibert/concat.o}
+{$L environ.o}
+{$L eval.o}
+{$L infrun.o}
+{$L blockfra.o}
+{$L findvar.o}
+{$L printcmd.o}
+{$L i386-tde.o}
+{$L minsyms.o}
+{$L stack.o}
+{$L gdbtypes.o}
+{$L valops.o}
+{$L values.o}
+{$L valprint.o}
+{$L language.o}
+{$L source.o}
+{$L i387-tde.o}
+{$L command.o}
+{$L objfiles.o}
+{$L demangle.o}
+{$L ../libibert/cplus-de.o}
+{$L gnu-rege.o}
+{$L c-typepr.o}
+{$L typeprin.o}
+{$L init.o}
+{$L parse.o}
+{$L serial.o}
+{$L ../libibert/getrunti.o}
+{$L ../readline/complete.o}
+{$L ../readline/readline.o}
+{$L ../readline/history.o}
+{$L ../gdb/version.o}
+{$L inflow.o}
+{$L ../readline/tilde.o}
+{$L ../readline/bind.o}
+{$L mem-brea.o}
+{$L ../libibert/strsigna.o}
+{$L ../bfd/bfd.o}
+{$L ../libibert/vasprint.o}
+{$L ch-lang.o}
+{$ifdef GDB_V416}
+{$L go32targ.o}
+{$else}
+{$L go32-nat.o}
+{$endif}
+{$L thread.o}
+{$L valarith.o}
+{$L expprint.o}
+{$L exec.o}
+{$L ../bfd/corefile.o}
+{$L ../libibert/obstack.o}
+{$L ../bfd/section.o}
+{$L complain.o}
+{$L ../libibert/argv.o}
+{$L ../bfd/opncls.o}
+{$L ../bfd/format.o}
+{$L bcache.o}
+{$L symmisc.o}
+{$L f-lang.o}
+{$L f-valpri.o}
+{$L cp-valpr.o}
+{$L ../opcodes/dis-buf.o}
+{$L ../opcodes/i386-dis.o}
+{$L scm-lang.o}
+{$L ../libibert/basename.o}
+{$L ../libibert/floatfor.o}
+{$L copying.o}
+{$L ser-go32.o}
+{$L remote.o}
+{$L dcache.o}
+{$L remote-u.o}
+{$L buildsym.o}
+{$L maint.o}
+{$L dbxread.o}
+{$L coffread.o}
+{$L elfread.o}
+{$L mipsread.o}
+{$L stabsrea.o}
+{$L c-lang.o}
+{$L m2-lang.o}
+{$L nlmread.o}
+{$L mdebugre.o}
+{$L os9kread.o}
+{$L p-lang.o}
+{$L p-valpri.o}
+{$L ../readline/display.o}
+{$L ../readline/keymaps.o}
+{$L ../readline/rltty.o}
+{$L ../readline/vi_mode.o}
+{$L ../readline/funmap.o}
+{$L ../readline/parens.o}
+{$L ../bfd/cache.o}
+{$L ch-exp.o}
+{$L ch-typep.o}
+{$L ch-valpr.o}
+{$L ../bfd/libbfd.o}
+{$L ../bfd/archures.o}
+{$L ../bfd/targets.o}
+{$L ../bfd/binary.o}
+{$L f-exp_ta.o}
+{$L f-typepr.o}
+{$L c-valpri.o}
+{$L scm-exp.o}
+{$L c-exp_ta.o}
+{$L scm-valp.o}
+{$L dwarfrea.o}
+{$L m2-exp_t.o}
+{$L m2-typep.o}
+{$L m2-valpr.o}
+{$L p-exp_ta.o}
+{$L p-typepr.o}
+{$L ../readline/isearch.o}
+{$L ../readline/search.o}
+{$L ../bfd/cpu-i386.o}
+{$L ../bfd/coff-go3.o}
+{$L ../bfd/srec.o}
+{$L ../bfd/tekhex.o}
+{$L ../bfd/ihex.o}
+{$L ../bfd/syms.o}
+{$L ../bfd/archive.o}
+{$L ../bfd/reloc.o}
+{$L ../bfd/linker.o}
+{$L ../bfd/coffgen.o}
+{$L ../bfd/cofflink.o}
+{$L ../libibert/hex.o}
+{$L ../bfd/hash.o}
+{$L ../bfd/stabs.o}
+{$ifdef GDB_V418}
+{$L ../readline/histexpa.o}
+{$L ../readline/histfile.o}
+{$L gdbarch.o}
+{$L tracepoi.o}
+{$L ax-gdb.o}
+{$L jv-lang.o}
+{$L ../readline/input.o}
+{$L ../readline/util.o}
+{$L ../readline/terminal.o}
+{$L ../readline/undo.o}
+{$L ../readline/macro.o}
+{$L ../readline/shell.o}
+{$L ../readline/nls.o}
+{$L ../readline/kill.o}
+{$L ../libibert/xstrerro.o}
+{$L ../libibert/objalloc.o}
+{$L dwarf2re.o}
+{$L ../bfd/coff-stg.o}
+{$L ../bfd/i386aout.o}
+{$L ../libibert/fnmatch.o}
+{$L ../readline/histsear.o}
+{$L ax-gener.o}
+{$L jv-exp_t.o}
+{$L jv-typep.o}
+{$L jv-valpr.o}
+{$L ../bfd/aout32.o}
+{$L ../bfd/stab-sym.o}
+{$endif GDB_V418}
+{
+  $Log$
+  Revision 1.1  2002-01-29 17:54:49  peter
+    * splitted to base and extra
+
+  Revision 1.2  2000/07/13 11:33:16  michael
+  + removed logs
+ 
+}

+ 93 - 0
packages/base/gdbint/gdbver.pp

@@ -0,0 +1,93 @@
+{
+  $Id$
+
+  Program to detect the version of libgdb that will be
+  used for linking
+}
+program find_gdb_version;
+
+{$Linklib gdb}
+
+uses
+  strings;
+
+const
+{$ifdef unix}
+  ver_name = 'version';
+{$else not unix}
+  ver_name = '_version';
+{$endif}
+  { This variable should be change with
+    change in GDB CVS PM }
+  Current_cvs_version : longint = 502;
+  Max_version_length = 25;
+
+var
+  v5_version : array[0..0] of char;external name ver_name;
+  v4_version : pchar;external name ver_name;
+  version : pchar;
+  subver_str : string;
+  i, version_number,
+  subversion_number : longint;
+  error : word;
+  only_ver : boolean;
+
+begin
+  only_ver:=(Paramcount>0) and (ParamStr(1)='-n');
+  getmem(version,Max_version_length+1);
+  strlcopy(version,@v5_version,Max_version_length);
+  version[Max_version_length]:=#0;
+  if (version[0] in ['4','5','6','7','8','9']) and (version[1]='.') then
+    begin
+      if not only_ver then
+        Writeln('GDB version is ',pchar(@v5_version));
+      version_number:=ord(version[0])-ord('0');
+      i:=2;
+      subver_str:='';
+      while version[i] in ['0'..'9'] do
+        begin
+          subver_str:=subver_str+version[i];
+          inc(i);
+        end;
+      val(subver_str,subversion_number,error);
+      if (error=0) and (subversion_number>=0) and
+         (subversion_number<=99) then
+        version_number:=version_number*100+subversion_number;
+    end
+  else if (version[0]='2') and (version[1]='0') and
+          (version[2] in ['0'..'9']) and (version[3] in ['0'..'9']) then
+    begin
+      { CVS version from 2000 to 2099,
+        assume current_cvs_version  PM }
+      version_number:=Current_cvs_version;
+    end
+  else
+    begin
+      if not only_ver then
+        Writeln('GDB version is ',v4_version);
+      version_number:=ord(v4_version[0])-ord('0');
+    end;
+  freemem(version,Max_version_length+1);
+  if only_ver then
+    Write(version_number);
+  Halt(version_number);
+end.
+
+{
+  $Log$
+  Revision 1.1  2002-01-29 17:54:49  peter
+    * splitted to base and extra
+
+  Revision 1.5  2002/01/25 08:56:50  pierre
+   + add subversion for version output
+
+  Revision 1.4  2002/01/24 09:14:40  pierre
+   * adapt to GDB 5.1
+
+  Revision 1.3  2001/09/11 10:22:09  pierre
+   * Hack to allow to recognize CVS version as 5.01
+
+  Revision 1.2  2001/04/08 11:44:01  peter
+    * new file
+
+}

+ 977 - 0
packages/base/gdbint/libgdb/Makefile

@@ -0,0 +1,977 @@
+#
+# Don't edit, this file is generated by FPCMake Version 1.1 [2002/01/27]
+#
+default: all
+MAKEFILETARGETS=linux go32v2 win32 os2 freebsd beos netbsd amiga atari sunos qnx
+override PATH:=$(subst \,/,$(PATH))
+ifeq ($(findstring ;,$(PATH)),)
+inUnix=1
+SEARCHPATH:=$(filter-out .,$(subst :, ,$(PATH)))
+else
+SEARCHPATH:=$(subst ;, ,$(PATH))
+endif
+PWD:=$(strip $(wildcard $(addsuffix /pwd.exe,$(SEARCHPATH))))
+ifeq ($(PWD),)
+PWD:=$(strip $(wildcard $(addsuffix /pwd,$(SEARCHPATH))))
+ifeq ($(PWD),)
+$(error You need the GNU utils package to use this Makefile)
+else
+PWD:=$(firstword $(PWD))
+SRCEXEEXT=
+endif
+else
+PWD:=$(firstword $(PWD))
+SRCEXEEXT=.exe
+endif
+ifndef inUnix
+ifeq ($(OS),Windows_NT)
+inWinNT=1
+else
+ifdef OS2_SHELL
+inOS2=1
+endif
+endif
+else
+ifneq ($(findstring cygwin,$(MACHTYPE)),)
+inCygWin=1
+endif
+endif
+ifeq ($(OS_TARGET),freebsd)
+BSDhier=1
+endif
+ifeq ($(OS_TARGET),netbsd)
+BSDhier=1
+endif
+ifdef inUnix
+BATCHEXT=.sh
+else
+ifdef inOS2
+BATCHEXT=.cmd
+else
+BATCHEXT=.bat
+endif
+endif
+ifdef inUnix
+PATHSEP=/
+else
+PATHSEP:=$(subst /,\,/)
+endif
+ifdef PWD
+BASEDIR:=$(subst \,/,$(shell $(PWD)))
+ifdef inCygWin
+ifneq ($(findstring /cygdrive/,$(BASEDIR)),)
+BASENODIR:=$(patsubst /cygdrive%,%,$(BASEDIR))
+BASEDRIVE:=$(firstword $(subst /, ,$(BASENODIR)))
+BASEDIR:=$(subst /cygdrive/$(BASEDRIVE)/,$(BASEDRIVE):/,$(BASEDIR))
+endif
+endif
+else
+BASEDIR=.
+endif
+ifndef FPC
+ifdef PP
+FPC=$(PP)
+endif
+endif
+ifndef FPC
+FPCPROG:=$(strip $(wildcard $(addsuffix /fpc$(SRCEXEEXT),$(SEARCHPATH))))
+ifneq ($(FPCPROG),)
+FPCPROG:=$(firstword $(FPCPROG))
+FPC:=$(shell $(FPCPROG) -PB)
+ifneq ($(findstring Error,$(FPC)),)
+override FPC=ppc386
+endif
+else
+override FPC=ppc386
+endif
+endif
+override FPC:=$(subst $(SRCEXEEXT),,$(FPC))
+override FPC:=$(subst \,/,$(FPC))$(SRCEXEEXT)
+ifndef FPC_VERSION
+FPC_VERSION:=$(shell $(FPC) -iV)
+endif
+export FPC FPC_VERSION
+ifeq ($(findstring 1.0.,$(FPC_VERSION)),)
+COMPILERINFO:=$(shell $(FPC) -iSP -iTP -iSO -iTO)
+ifndef CPU_SOURCE
+CPU_SOURCE:=$(word 1,$(COMPILERINFO))
+endif
+ifndef CPU_TARGET
+CPU_TARGET:=$(word 2,$(COMPILERINFO))
+endif
+ifndef OS_SOURCE
+OS_SOURCE:=$(word 3,$(COMPILERINFO))
+endif
+ifndef OS_TARGET
+OS_TARGET:=$(word 4,$(COMPILERINFO))
+endif
+else
+ifndef CPU_SOURCE
+CPU_SOURCE:=$(shell $(FPC) -iSP)
+endif
+ifndef CPU_TARGET
+CPU_TARGET:=$(shell $(FPC) -iTP)
+endif
+ifndef OS_SOURCE
+OS_SOURCE:=$(shell $(FPC) -iSO)
+endif
+ifndef OS_TARGET
+OS_TARGET:=$(shell $(FPC) -iTO)
+endif
+endif
+FULL_TARGET=$(CPU_TARGET)-$(OS_TARGET)
+FULL_SOURCE=$(CPU_SOURCE)-$(OS_SOURCE)
+ifneq ($(FULL_TARGET),$(FULL_SOURCE))
+CROSSCOMPILE=1
+endif
+ifeq ($(findstring makefile,$(MAKECMDGOALS)),)
+ifeq ($(findstring $(OS_TARGET),$(MAKEFILETARGETS)),)
+$(error The Makefile doesn't support target $(OS_TARGET), please run fpcmake first)
+endif
+endif
+export OS_TARGET OS_SOURCE CPU_TARGET CPU_SOURCE FULL_TARGET FULL_SOURCE CROSSCOMPILE
+ifdef FPCDIR
+override FPCDIR:=$(subst \,/,$(FPCDIR))
+ifeq ($(wildcard $(addprefix $(FPCDIR)/,rtl units)),)
+override FPCDIR=wrong
+endif
+else
+override FPCDIR=wrong
+endif
+ifdef DEFAULT_FPCDIR
+ifeq ($(FPCDIR),wrong)
+override FPCDIR:=$(subst \,/,$(DEFAULT_FPCDIR))
+ifeq ($(wildcard $(addprefix $(FPCDIR)/,rtl units)),)
+override FPCDIR=wrong
+endif
+endif
+endif
+ifeq ($(FPCDIR),wrong)
+ifdef inUnix
+override FPCDIR=/usr/local/lib/fpc/$(FPC_VERSION)
+ifeq ($(wildcard $(FPCDIR)/units),)
+override FPCDIR=/usr/lib/fpc/$(FPC_VERSION)
+endif
+else
+override FPCDIR:=$(subst /$(FPC),,$(firstword $(strip $(wildcard $(addsuffix /$(FPC),$(SEARCHPATH))))))
+override FPCDIR:=$(FPCDIR)/..
+ifeq ($(wildcard $(addprefix $(FPCDIR)/,rtl units)),)
+override FPCDIR:=$(FPCDIR)/..
+ifeq ($(wildcard $(addprefix $(FPCDIR)/,rtl units)),)
+override FPCDIR=c:/pp
+endif
+endif
+endif
+endif
+ifndef CROSSDIR
+CROSSDIR:=$(FPCDIR)/cross/$(FULL_TARGET)
+endif
+ifndef CROSSTARGETDIR
+CROSSTARGETDIR=$(CROSSDIR)/$(FULL_TARGET)
+endif
+ifdef CROSSCOMPILE
+UNITSDIR:=$(wildcard $(CROSSTARGETDIR)/units)
+ifeq ($(UNITSDIR),)
+UNITSDIR:=$(wildcard $(FPCDIR)/units/$(OS_TARGET))
+endif
+else
+UNITSDIR:=$(wildcard $(FPCDIR)/units/$(OS_TARGET))
+endif
+PACKAGESDIR:=$(wildcard $(FPCDIR) $(FPCDIR)/packages)
+ifdef REQUIRE_UNITSDIR
+override UNITSDIR+=$(REQUIRE_UNITSDIR)
+endif
+ifdef REQUIRE_PACKAGESDIR
+override PACKAGESDIR+=$(REQUIRE_PACKAGESDIR)
+endif
+ifdef ZIPINSTALL
+ifeq ($(OS_TARGET),linux)
+UNIXINSTALLDIR=1
+endif
+ifeq ($(OS_TARGET),freebsd)
+UNIXINSTALLDIR=1
+endif
+ifeq ($(OS_TARGET),netbsd)
+UNIXINSTALLDIR=1
+endif
+ifeq ($(OS_TARGET),sunos)
+UNIXINSTALLDIR=1
+endif
+else
+ifeq ($(OS_SOURCE),linux)
+UNIXINSTALLDIR=1
+endif
+ifeq ($(OS_SOURCE),freebsd)
+UNIXINSTALLDIR=1
+endif
+ifeq ($(OS_SOURCE),netbsd)
+UNIXINSTALLDIR=1
+endif
+ifeq ($(OS_TARGET),sunos)
+UNIXINSTALLDIR=1
+endif
+endif
+ifndef INSTALL_PREFIX
+ifdef PREFIX
+INSTALL_PREFIX=$(PREFIX)
+endif
+endif
+ifndef INSTALL_PREFIX
+ifdef UNIXINSTALLDIR
+INSTALL_PREFIX=/usr/local
+else
+ifdef INSTALL_FPCPACKAGE
+INSTALL_BASEDIR:=/pp
+else
+INSTALL_BASEDIR:=/$(PACKAGE_NAME)
+endif
+endif
+endif
+export INSTALL_PREFIX
+ifndef DIST_DESTDIR
+DIST_DESTDIR:=$(BASEDIR)
+endif
+export DIST_DESTDIR
+ifndef INSTALL_BASEDIR
+ifdef UNIXINSTALLDIR
+ifdef INSTALL_FPCPACKAGE
+INSTALL_BASEDIR:=$(INSTALL_PREFIX)/lib/fpc/$(FPC_VERSION)
+else
+INSTALL_BASEDIR:=$(INSTALL_PREFIX)/lib/$(PACKAGE_NAME)
+endif
+else
+INSTALL_BASEDIR:=$(INSTALL_PREFIX)
+endif
+endif
+ifndef INSTALL_BINDIR
+ifdef UNIXINSTALLDIR
+INSTALL_BINDIR:=$(INSTALL_PREFIX)/bin
+else
+INSTALL_BINDIR:=$(INSTALL_BASEDIR)/bin
+ifdef INSTALL_FPCPACKAGE
+INSTALL_BINDIR:=$(INSTALL_BINDIR)/$(OS_TARGET)
+endif
+endif
+endif
+ifndef INSTALL_UNITDIR
+ifdef CROSSCOMPILE
+INSTALL_UNITDIR:=$(INSTALL_BASEDIR)/cross/$(FULL_TARGET)/units
+else
+INSTALL_UNITDIR:=$(INSTALL_BASEDIR)/units/$(OS_TARGET)
+endif
+ifdef INSTALL_FPCPACKAGE
+ifdef PACKAGE_NAME
+INSTALL_UNITDIR:=$(INSTALL_UNITDIR)/$(PACKAGE_NAME)
+endif
+endif
+endif
+ifndef INSTALL_LIBDIR
+ifdef UNIXINSTALLDIR
+INSTALL_LIBDIR:=$(INSTALL_PREFIX)/lib
+else
+INSTALL_LIBDIR:=$(INSTALL_UNITDIR)
+endif
+endif
+ifndef INSTALL_SOURCEDIR
+ifdef UNIXINSTALLDIR
+ifdef INSTALL_FPCPACKAGE
+ifdef BSDhier
+INSTALL_SOURCEDIR:=$(INSTALL_PREFIX)/share/src/fpc-$(FPC_VERSION)/$(PACKAGE_NAME)
+else
+INSTALL_SOURCEDIR:=$(INSTALL_PREFIX)/src/fpc-$(FPC_VERSION)/$(PACKAGE_NAME)
+endif
+else
+ifdef BSDhier
+INSTALL_SOURCEDIR:=$(INSTALL_PREFIX)/share/src/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
+else
+INSTALL_SOURCEDIR:=$(INSTALL_PREFIX)/src/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
+endif
+endif
+else
+ifdef INSTALL_FPCPACKAGE
+INSTALL_SOURCEDIR:=$(INSTALL_BASEDIR)/source/$(PACKAGE_NAME)
+else
+INSTALL_SOURCEDIRL:=$(INSTALL_BASEDIR)/source
+endif
+endif
+endif
+ifndef INSTALL_DOCDIR
+ifdef UNIXINSTALLDIR
+ifdef INSTALL_FPCPACKAGE
+ifdef BSDhier
+INSTALL_DOCDIR:=$(INSTALL_PREFIX)/share/doc/fpc-$(FPC_VERSION)/$(PACKAGE_NAME)
+else
+INSTALL_DOCDIR:=$(INSTALL_PREFIX)/doc/fpc-$(FPC_VERSION)/$(PACKAGE_NAME)
+endif
+else
+ifdef BSDhier
+INSTALL_DOCDIR:=$(INSTALL_PREFIX)/share/doc/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
+else
+INSTALL_DOCDIR:=$(INSTALL_PREFIX)/doc/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
+endif
+endif
+else
+ifdef INSTALL_FPCPACKAGE
+INSTALL_DOCDIR:=$(INSTALL_BASEDIR)/doc/$(PACKAGE_NAME)
+else
+INSTALL_DOCDIR:=$(INSTALL_BASEDIR)/doc
+endif
+endif
+endif
+ifndef INSTALL_EXAMPLEDIR
+ifdef UNIXINSTALLDIR
+ifdef INSTALL_FPCPACKAGE
+ifdef BSDhier
+INSTALL_EXAMPLEDIR:=$(INSTALL_PREFIX)/share/examples/fpc-$(FPC_VERSION)/$(PACKAGE_NAME)
+else
+INSTALL_EXAMPLEDIR:=$(INSTALL_PREFIX)/doc/fpc-$(FPC_VERSION)/examples/$(PACKAGE_NAME)
+endif
+else
+ifdef BSDhier
+INSTALL_EXAMPLEDIR:=$(INSTALL_PREFIX)/share/examples/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
+else
+INSTALL_EXAMPLEDIR:=$(INSTALL_PREFIX)/doc/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
+endif
+endif
+else
+ifdef INSTALL_FPCPACKAGE
+INSTALL_EXAMPLEDIR:=$(INSTALL_BASEDIR)/examples/$(PACKAGE_NAME)
+else
+INSTALL_EXAMPLEDIR:=$(INSTALL_BASEDIR)/examples
+endif
+endif
+endif
+ifndef INSTALL_DATADIR
+INSTALL_DATADIR=$(INSTALL_BASEDIR)
+endif
+ifdef CROSSCOMPILE
+ifndef CROSSBINDIR
+CROSSBINDIR:=$(wildcard $(CROSSTARGETDIR)/bin/$(FULL_SOURCE))
+ifeq ($(CROSSBINDIR),)
+CROSSBINDIR:=$(wildcard $(INSTALL_BASEDIR)/cross/$(FULL_TARGET)/bin/$(FULL_SOURCE))
+endif
+endif
+else
+CROSSBINDIR=
+endif
+LOADEREXT=.as
+EXEEXT=.exe
+PPLEXT=.ppl
+PPUEXT=.ppu
+OEXT=.o
+ASMEXT=.s
+SMARTEXT=.sl
+STATICLIBEXT=.a
+SHAREDLIBEXT=.so
+STATICLIBPREFIX=libp
+RSTEXT=.rst
+FPCMADE=fpcmade
+ifeq ($(OS_TARGET),go32v1)
+PPUEXT=.pp1
+OEXT=.o1
+ASMEXT=.s1
+SMARTEXT=.sl1
+STATICLIBEXT=.a1
+SHAREDLIBEXT=.so1
+STATICLIBPREFIX=
+FPCMADE=fpcmade.v1
+PACKAGESUFFIX=v1
+endif
+ifeq ($(OS_TARGET),go32v2)
+STATICLIBPREFIX=
+FPCMADE=fpcmade.dos
+ZIPSUFFIX=go32
+endif
+ifeq ($(OS_TARGET),linux)
+EXEEXT=
+HASSHAREDLIB=1
+FPCMADE=fpcmade.lnx
+ZIPSUFFIX=linux
+endif
+ifeq ($(OS_TARGET),freebsd)
+EXEEXT=
+HASSHAREDLIB=1
+FPCMADE=fpcmade.freebsd
+ZIPSUFFIX=freebsd
+endif
+ifeq ($(OS_TARGET),netbsd)
+EXEEXT=
+HASSHAREDLIB=1
+FPCMADE=fpcmade.netbsd
+ZIPSUFFIX=netbsd
+endif
+ifeq ($(OS_TARGET),win32)
+PPUEXT=.ppw
+OEXT=.ow
+ASMEXT=.sw
+SMARTEXT=.slw
+STATICLIBEXT=.aw
+SHAREDLIBEXT=.dll
+FPCMADE=fpcmade.w32
+ZIPSUFFIX=w32
+endif
+ifeq ($(OS_TARGET),os2)
+PPUEXT=.ppo
+ASMEXT=.so2
+OEXT=.oo2
+AOUTEXT=.out
+SMARTEXT=.so
+STATICLIBEXT=.ao2
+SHAREDLIBEXT=.dll
+FPCMADE=fpcmade.os2
+ZIPSUFFIX=emx
+endif
+ifeq ($(OS_TARGET),amiga)
+EXEEXT=
+PPUEXT=.ppa
+ASMEXT=.asm
+OEXT=.o
+SMARTEXT=.sl
+STATICLIBEXT=.a
+SHAREDLIBEXT=.library
+FPCMADE=fpcmade.amg
+endif
+ifeq ($(OS_TARGET),atari)
+PPUEXT=.ppt
+ASMEXT=.s
+OEXT=.o
+SMARTEXT=.sl
+STATICLIBEXT=.a
+EXEEXT=.ttp
+FPCMADE=fpcmade.ata
+endif
+ifeq ($(OS_TARGET),beos)
+PPUEXT=.ppu
+ASMEXT=.s
+OEXT=.o
+SMARTEXT=.sl
+STATICLIBEXT=.a
+EXEEXT=
+FPCMADE=fpcmade.be
+ZIPSUFFIX=be
+endif
+ifeq ($(OS_TARGET),sunos)
+PPUEXT=.ppu
+ASMEXT=.s
+OEXT=.o
+SMARTEXT=.sl
+STATICLIBEXT=.a
+EXEEXT=
+FPCMADE=fpcmade.sun
+ZIPSUFFIX=sun
+endif
+ifeq ($(OS_TARGET),qnx)
+PPUEXT=.ppu
+ASMEXT=.s
+OEXT=.o
+SMARTEXT=.sl
+STATICLIBEXT=.a
+EXEEXT=
+FPCMADE=fpcmade.qnx
+ZIPSUFFIX=qnx
+endif
+ifndef ECHO
+ECHO:=$(strip $(wildcard $(addsuffix /gecho$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(ECHO),)
+ECHO:=$(strip $(wildcard $(addsuffix /echo$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(ECHO),)
+ECHO=
+else
+ECHO:=$(firstword $(ECHO))
+endif
+else
+ECHO:=$(firstword $(ECHO))
+endif
+endif
+export ECHO
+ifndef DATE
+DATE:=$(strip $(wildcard $(addsuffix /gdate$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(DATE),)
+DATE:=$(strip $(wildcard $(addsuffix /date$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(DATE),)
+DATE=
+else
+DATE:=$(firstword $(DATE))
+endif
+else
+DATE:=$(firstword $(DATE))
+endif
+endif
+export DATE
+ifndef GINSTALL
+GINSTALL:=$(strip $(wildcard $(addsuffix /ginstall$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(GINSTALL),)
+GINSTALL:=$(strip $(wildcard $(addsuffix /install$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(GINSTALL),)
+GINSTALL=
+else
+GINSTALL:=$(firstword $(GINSTALL))
+endif
+else
+GINSTALL:=$(firstword $(GINSTALL))
+endif
+endif
+export GINSTALL
+ifndef CPPROG
+CPPROG:=$(strip $(wildcard $(addsuffix /cp$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(CPPROG),)
+CPPROG=
+else
+CPPROG:=$(firstword $(CPPROG))
+endif
+endif
+export CPPROG
+ifndef RMPROG
+RMPROG:=$(strip $(wildcard $(addsuffix /rm$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(RMPROG),)
+RMPROG=
+else
+RMPROG:=$(firstword $(RMPROG))
+endif
+endif
+export RMPROG
+ifndef MVPROG
+MVPROG:=$(strip $(wildcard $(addsuffix /mv$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(MVPROG),)
+MVPROG=
+else
+MVPROG:=$(firstword $(MVPROG))
+endif
+endif
+export MVPROG
+ifndef ECHOREDIR
+ECHOREDIR:=$(subst /,$(PATHSEP),$(ECHO))
+endif
+ifndef COPY
+COPY:=$(CPPROG) -fp
+endif
+ifndef COPYTREE
+COPYTREE:=$(CPPROG) -rfp
+endif
+ifndef MOVE
+MOVE:=$(MVPROG) -f
+endif
+ifndef DEL
+DEL:=$(RMPROG) -f
+endif
+ifndef DELTREE
+DELTREE:=$(RMPROG) -rf
+endif
+ifndef INSTALL
+ifdef inUnix
+INSTALL:=$(GINSTALL) -c -m 644
+else
+INSTALL:=$(COPY)
+endif
+endif
+ifndef INSTALLEXE
+ifdef inUnix
+INSTALLEXE:=$(GINSTALL) -c -m 755
+else
+INSTALLEXE:=$(COPY)
+endif
+endif
+ifndef MKDIR
+MKDIR:=$(GINSTALL) -m 755 -d
+endif
+export ECHOREDIR COPY COPYTREE MOVE DEL DELTREE INSTALL INSTALLEXE MKDIR
+ifndef PPUMOVE
+PPUMOVE:=$(strip $(wildcard $(addsuffix /ppumove$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(PPUMOVE),)
+PPUMOVE=
+else
+PPUMOVE:=$(firstword $(PPUMOVE))
+endif
+endif
+export PPUMOVE
+ifndef FPCMAKE
+FPCMAKE:=$(strip $(wildcard $(addsuffix /fpcmake$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(FPCMAKE),)
+FPCMAKE=
+else
+FPCMAKE:=$(firstword $(FPCMAKE))
+endif
+endif
+export FPCMAKE
+ifndef ZIPPROG
+ZIPPROG:=$(strip $(wildcard $(addsuffix /zip$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(ZIPPROG),)
+ZIPPROG=
+else
+ZIPPROG:=$(firstword $(ZIPPROG))
+endif
+endif
+export ZIPPROG
+ifndef TARPROG
+TARPROG:=$(strip $(wildcard $(addsuffix /tar$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(TARPROG),)
+TARPROG=
+else
+TARPROG:=$(firstword $(TARPROG))
+endif
+endif
+export TARPROG
+ASNAME=as
+LDNAME=ld
+ARNAME=ar
+RCNAME=rc
+ifeq ($(OS_TARGET),win32)
+ASNAME=asw
+LDNAME=ldw
+ARNAME=arw
+endif
+ifndef ASPROG
+ifdef CROSSBINDIR
+ASPROG=$(CROSSBINDIR)/$(ASNAME)$(SRCEXEEXT)
+else
+ASPROG=$(ASNAME)
+endif
+endif
+ifndef LDPROG
+ifdef CROSSBINDIR
+LDPROG=$(CROSSBINDIR)/$(LDNAME)$(SRCEXEEXT)
+else
+LDPROG=$(LDNAME)
+endif
+endif
+ifndef RCPROG
+ifdef CROSSBINDIR
+RCPROG=$(CROSSBINDIR)/$(RCNAME)$(SRCEXEEXT)
+else
+RCPROG=$(RCNAME)
+endif
+endif
+ifndef ARPROG
+ifdef CROSSBINDIR
+ARPROG=$(CROSSBINDIR)/$(ARNAME)$(SRCEXEEXT)
+else
+ARPROG=$(ARNAME)
+endif
+endif
+AS=$(ASPROG)
+LD=$(LDPROG)
+RC=$(RCPROG)
+AR=$(ARPROG)
+PPAS=ppas$(BATCHEXT)
+ifdef inUnix
+LDCONFIG=ldconfig
+else
+LDCONFIG=
+endif
+ifdef DATE
+DATESTR:=$(shell $(DATE) +%Y%m%d)
+else
+DATESTR=
+endif
+ifndef UPXPROG
+ifeq ($(OS_TARGET),go32v2)
+UPXPROG:=1
+endif
+ifeq ($(OS_TARGET),win32)
+UPXPROG:=1
+endif
+ifdef UPXPROG
+UPXPROG:=$(strip $(wildcard $(addsuffix /upx$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(UPXPROG),)
+UPXPROG=
+else
+UPXPROG:=$(firstword $(UPXPROG))
+endif
+else
+UPXPROG=
+endif
+endif
+export UPXPROG
+ZIPOPT=-9
+ZIPEXT=.zip
+ifeq ($(USETAR),bz2)
+TAROPT=vI
+TAREXT=.tar.bz2
+else
+TAROPT=vz
+TAREXT=.tar.gz
+endif
+ifndef NOCPUDEF
+override FPCOPTDEF=$(CPU_TARGET)
+endif
+ifneq ($(OS_TARGET),$(OS_SOURCE))
+override FPCOPT+=-T$(OS_TARGET)
+endif
+ifdef UNITDIR
+override FPCOPT+=$(addprefix -Fu,$(UNITDIR))
+endif
+ifdef LIBDIR
+override FPCOPT+=$(addprefix -Fl,$(LIBDIR))
+endif
+ifdef OBJDIR
+override FPCOPT+=$(addprefix -Fo,$(OBJDIR))
+endif
+ifdef INCDIR
+override FPCOPT+=$(addprefix -Fi,$(INCDIR))
+endif
+ifdef LINKSMART
+override FPCOPT+=-XX
+endif
+ifdef CREATESMART
+override FPCOPT+=-CX
+endif
+ifdef DEBUG
+override FPCOPT+=-gl
+override FPCOPTDEF+=DEBUG
+endif
+ifdef RELEASE
+ifeq ($(CPU_TARGET),i386)
+FPCCPUOPT:=-OG2p3
+else
+FPCCPUOPT:=
+endif
+override FPCOPT+=-Xs $(FPCCPUOPT) -n
+override FPCOPTDEF+=RELEASE
+endif
+ifdef STRIP
+override FPCOPT+=-Xs
+endif
+ifdef OPTIMIZE
+ifeq ($(CPU_TARGET),i386)
+override FPCOPT+=-OG2p3
+endif
+endif
+ifdef VERBOSE
+override FPCOPT+=-vwni
+endif
+ifdef COMPILER_OPTIONS
+override FPCOPT+=$(COMPILER_OPTIONS)
+endif
+ifdef COMPILER_UNITDIR
+override FPCOPT+=$(addprefix -Fu,$(COMPILER_UNITDIR))
+endif
+ifdef COMPILER_LIBRARYDIR
+override FPCOPT+=$(addprefix -Fl,$(COMPILER_LIBRARYDIR))
+endif
+ifdef COMPILER_OBJECTDIR
+override FPCOPT+=$(addprefix -Fo,$(COMPILER_OBJECTDIR))
+endif
+ifdef COMPILER_INCLUDEDIR
+override FPCOPT+=$(addprefix -Fi,$(COMPILER_INCLUDEDIR))
+endif
+ifdef CROSSBINDIR
+override FPCOPT+=-FD$(CROSSBINDIR)
+endif
+ifdef COMPILER_TARGETDIR
+override FPCOPT+=-FE$(COMPILER_TARGETDIR)
+ifeq ($(COMPILER_TARGETDIR),.)
+override TARGETDIRPREFIX=
+else
+override TARGETDIRPREFIX=$(COMPILER_TARGETDIR)/
+endif
+endif
+ifdef COMPILER_UNITTARGETDIR
+override FPCOPT+=-FU$(COMPILER_UNITTARGETDIR)
+ifeq ($(COMPILER_UNITTARGETDIR),.)
+override UNITTARGETDIRPREFIX=
+else
+override UNITTARGETDIRPREFIX=$(COMPILER_UNITTARGETDIR)/
+endif
+else
+ifdef COMPILER_TARGETDIR
+override COMPILER_UNITTARGETDIR=$(COMPILER_TARGETDIR)
+override UNITTARGETDIRPREFIX=$(TARGETDIRPREFIX)
+endif
+endif
+ifdef OPT
+override FPCOPT+=$(OPT)
+endif
+ifdef FPCOPTDEF
+override FPCOPT+=$(addprefix -d,$(FPCOPTDEF))
+endif
+ifdef CFGFILE
+override FPCOPT+=@$(CFGFILE)
+endif
+ifdef USEENV
+override FPCEXTCMD:=$(FPCOPT)
+override FPCOPT:=!FPCEXTCMD
+export FPCEXTCMD
+endif
+override COMPILER:=$(FPC) $(FPCOPT)
+ifeq (,$(findstring -s ,$(COMPILER)))
+EXECPPAS=
+else
+ifeq ($(OS_SOURCE),$(OS_TARGET))
+EXECPPAS:=@$(PPAS)
+endif
+endif
+ifdef TARGET_RSTS
+override RSTFILES=$(addsuffix $(RSTEXT),$(TARGET_RSTS))
+override CLEANRSTFILES+=$(RSTFILES)
+endif
+.PHONY: fpc_clean fpc_cleanall fpc_distclean
+ifdef EXEFILES
+override CLEANEXEFILES:=$(addprefix $(TARGETDIRPREFIX),$(CLEANEXEFILES))
+endif
+ifdef CLEAN_UNITS
+override CLEANPPUFILES+=$(addsuffix $(PPUEXT),$(CLEAN_UNITS))
+endif
+ifdef CLEANPPUFILES
+override CLEANPPULINKFILES:=$(subst $(PPUEXT),$(OEXT),$(CLEANPPUFILES)) $(addprefix $(STATICLIBPREFIX),$(subst $(PPUEXT),$(STATICLIBEXT),$(CLEANPPUFILES)))
+override CLEANPPUFILES:=$(addprefix $(UNITTARGETDIRPREFIX),$(CLEANPPUFILES))
+override CLEANPPULINKFILES:=$(wildcard $(addprefix $(UNITTARGETDIRPREFIX),$(CLEANPPULINKFILES)))
+endif
+fpc_clean: $(CLEANTARGET)
+ifdef CLEANEXEFILES
+	-$(DEL) $(CLEANEXEFILES)
+endif
+ifdef CLEANPPUFILES
+	-$(DEL) $(CLEANPPUFILES)
+endif
+ifneq ($(CLEANPPULINKFILES),)
+	-$(DEL) $(CLEANPPULINKFILES)
+endif
+ifdef CLEANRSTFILES
+	-$(DEL) $(addprefix $(UNITTARGETDIRPREFIX),$(CLEANRSTFILES))
+endif
+ifdef CLEAN_FILES
+	-$(DEL) $(CLEAN_FILES)
+endif
+ifdef LIB_NAME
+	-$(DEL) $(LIB_NAME) $(LIB_FULLNAME)
+endif
+	-$(DEL) $(FPCMADE) Package.fpc $(PPAS) script.res link.res $(FPCEXTFILE) $(REDIRFILE)
+fpc_distclean: clean
+ifdef COMPILER_UNITTARGETDIR
+TARGETDIRCLEAN=fpc_clean
+endif
+fpc_cleanall: $(CLEANTARGET) $(TARGETDIRCLEAN)
+ifdef CLEANEXEFILES
+	-$(DEL) $(CLEANEXEFILES)
+endif
+	-$(DEL) *$(OEXT) *$(PPUEXT) *$(RSTEXT) *$(ASMEXT) *$(STATICLIBEXT) *$(SHAREDLIBEXT) *$(PPLEXT)
+	-$(DELTREE) *$(SMARTEXT)
+	-$(DEL) $(FPCMADE) Package.fpc $(PPAS) script.res link.res $(FPCEXTFILE) $(REDIRFILE)
+ifdef AOUTEXT
+	-$(DEL) *$(AOUTEXT)
+endif
+.PHONY: fpc_baseinfo
+override INFORULES+=fpc_baseinfo
+fpc_baseinfo:
+	@$(ECHO)
+	@$(ECHO)  == Package info ==
+	@$(ECHO)  Package Name..... $(PACKAGE_NAME)
+	@$(ECHO)  Package Version.. $(PACKAGE_VERSION)
+	@$(ECHO)
+	@$(ECHO)  == Configuration info ==
+	@$(ECHO)
+	@$(ECHO)  FPC.......... $(FPC)
+	@$(ECHO)  FPC Version.. $(FPC_VERSION)
+	@$(ECHO)  Source CPU... $(CPU_SOURCE)
+	@$(ECHO)  Target CPU... $(CPU_TARGET)
+	@$(ECHO)  Source OS.... $(OS_SOURCE)
+	@$(ECHO)  Target OS.... $(OS_TARGET)
+	@$(ECHO)  Full Target.. $(FULL_SOURCE)
+	@$(ECHO)  Full Source.. $(FULL_TARGET)
+	@$(ECHO)
+	@$(ECHO)  == Directory info ==
+	@$(ECHO)
+	@$(ECHO)  Required pkgs... $(REQUIRE_PACKAGES)
+	@$(ECHO)
+	@$(ECHO)  Basedir......... $(BASEDIR)
+	@$(ECHO)  FPCDir.......... $(FPCDIR)
+	@$(ECHO)  CrossBinDir..... $(CROSSBINDIR)
+	@$(ECHO)  UnitsDir........ $(UNITSDIR)
+	@$(ECHO)  PackagesDir..... $(PACKAGESDIR)
+	@$(ECHO)
+	@$(ECHO)  GCC library..... $(GCCLIBDIR)
+	@$(ECHO)  Other library... $(OTHERLIBDIR)
+	@$(ECHO)
+	@$(ECHO)  == Tools info ==
+	@$(ECHO)
+	@$(ECHO)  As........ $(AS)
+	@$(ECHO)  Ld........ $(LD)
+	@$(ECHO)  Ar........ $(AR)
+	@$(ECHO)  Rc........ $(RC)
+	@$(ECHO)
+	@$(ECHO)  Mv........ $(MVPROG)
+	@$(ECHO)  Cp........ $(CPPROG)
+	@$(ECHO)  Rm........ $(RMPROG)
+	@$(ECHO)  GInstall.. $(GINSTALL)
+	@$(ECHO)  Echo...... $(ECHO)
+	@$(ECHO)  Date...... $(DATE)
+	@$(ECHO)  FPCMake... $(FPCMAKE)
+	@$(ECHO)  PPUMove... $(PPUMOVE)
+	@$(ECHO)  Upx....... $(UPXPROG)
+	@$(ECHO)  Zip....... $(ZIPPROG)
+	@$(ECHO)
+	@$(ECHO)  == Object info ==
+	@$(ECHO)
+	@$(ECHO)  Target Loaders........ $(TARGET_LOADERS)
+	@$(ECHO)  Target Units.......... $(TARGET_UNITS)
+	@$(ECHO)  Target Implicit Units. $(TARGET_IMPLICITUNITS)
+	@$(ECHO)  Target Programs....... $(TARGET_PROGRAMS)
+	@$(ECHO)  Target Dirs........... $(TARGET_DIRS)
+	@$(ECHO)  Target Examples....... $(TARGET_EXAMPLES)
+	@$(ECHO)  Target ExampleDirs.... $(TARGET_EXAMPLEDIRS)
+	@$(ECHO)
+	@$(ECHO)  Clean Units......... $(CLEAN_UNITS)
+	@$(ECHO)  Clean Files......... $(CLEAN_FILES)
+	@$(ECHO)
+	@$(ECHO)  Install Units....... $(INSTALL_UNITS)
+	@$(ECHO)  Install Files....... $(INSTALL_FILES)
+	@$(ECHO)
+	@$(ECHO)  == Install info ==
+	@$(ECHO)
+	@$(ECHO)  DateStr.............. $(DATESTR)
+	@$(ECHO)  ZipPrefix............ $(ZIPPREFIX)
+	@$(ECHO)  ZipSuffix............ $(ZIPSUFFIX)
+	@$(ECHO)  Install FPC Package.. $(INSTALL_FPCPACKAGE)
+	@$(ECHO)
+	@$(ECHO)  Install base dir..... $(INSTALL_BASEDIR)
+	@$(ECHO)  Install binary dir... $(INSTALL_BINDIR)
+	@$(ECHO)  Install library dir.. $(INSTALL_LIBDIR)
+	@$(ECHO)  Install units dir.... $(INSTALL_UNITDIR)
+	@$(ECHO)  Install source dir... $(INSTALL_SOURCEDIR)
+	@$(ECHO)  Install doc dir...... $(INSTALL_DOCDIR)
+	@$(ECHO)  Install example dir.. $(INSTALL_EXAMPLEDIR)
+	@$(ECHO)  Install data dir..... $(INSTALL_DATADIR)
+	@$(ECHO)
+	@$(ECHO)  Dist destination dir. $(DIST_DESTDIR)
+	@$(ECHO)  Dist zip name........ $(DIST_ZIPNAME)
+	@$(ECHO)
+.PHONY: fpc_info
+fpc_info: $(INFORULES)
+.PHONY: fpc_makefile fpc_makefiles fpc_makefile_sub1 fpc_makefile_sub2 \
+	fpc_makefile_dirs
+fpc_makefile:
+	$(FPCMAKE) -w -T$(OS_TARGET) Makefile.fpc
+fpc_makefile_sub1:
+ifdef TARGET_DIRS
+	$(FPCMAKE) -w -T$(OS_TARGET) $(addsuffix /Makefile.fpc,$(TARGET_DIRS))
+endif
+ifdef TARGET_EXAMPLEDIRS
+	$(FPCMAKE) -w -T$(OS_TARGET) $(addsuffix /Makefile.fpc,$(TARGET_EXAMPLEDIRS))
+endif
+fpc_makefile_sub2: $(addsuffix _makefile_dirs,$(TARGET_DIRS) $(TARGET_EXAMPLEDIRS))
+fpc_makefile_dirs: fpc_makefile_sub1 fpc_makefile_sub2
+fpc_makefiles: fpc_makefile fpc_makefile_dirs
+debug:
+smart:
+release:
+examples:
+shared:
+install:
+sourceinstall:
+exampleinstall:
+distinstall:
+zipinstall:
+zipsourceinstall:
+zipexampleinstall:
+zipdistinstall:
+clean:
+distclean:
+cleanall:
+info: fpc_info
+makefiles: fpc_makefiles
+.PHONY: debug smart release examples shared install sourceinstall exampleinstall distinstall zipinstall zipsourceinstall zipexampleinstall zipdistinstall clean distclean cleanall info makefiles
+ifneq ($(wildcard fpcmake.loc),)
+include fpcmake.loc
+endif
+all:
+	$(MAKE) -C $(OS_TARGET) all

+ 10 - 0
packages/base/gdbint/libgdb/Makefile.fpc

@@ -0,0 +1,10 @@
+#
+#   Makefile.fpc for Free Component Library
+#
+
+[sections]
+none=1
+
+[rules]
+all:
+        $(MAKE) -C $(OS_TARGET) all

+ 142 - 0
packages/base/gdbint/libgdb/go32v2/Makefile

@@ -0,0 +1,142 @@
+#
+# $Id$
+#
+# Makefile to create libgdb.a / libgdb.so
+#
+
+ifeq ($(GDB_SRC),)
+ifeq ($(OS),DJGPP)
+GDB_SRC=$(DJDIR)/gnu/gdb-4.18
+else
+ifeq ($(OS_TARGET),win32)
+GDB_SRC=d:/cygwin/cygwin-b20/gnu/gdb-4.18
+else
+GDB_SRC=/usr/src/gdb-4.17
+endif
+endif
+endif
+
+ifeq ($(GDB_OBJ),)
+GDB_OBJ=$(GDB_SRC)
+endif
+
+ifeq ($(OS)),DJGPP)
+OS_CFLAGS=-DMAINTENANCE_CMDS=0 -DHAVE_CONFIG_H -O2 -DHAVE_LONG_DOUBLE=1 \
+	  -DPRINTF_HAS_LONG_DOUBLE=1
+OS_FLAGS=
+MMALLOC_INC=
+MMALLOC_CFLAGS=-DNO_MMALLOC -DNO_MMALLOC_CHECK
+MMALLOC_LIB=
+MMALLOC_LIB_DIR=
+OS_FLAGS+=MMALLOC=$(MMALLOC) MMALLOC_CFLAGS="$(MMALLOC_CFLAGS)"
+CHECKS=check_echo check_awk
+EXCLUDE_REGEX=
+else
+OS_CFLAGS=-DMAINTENANCE_CMDS=1 -DHAVE_CONFIG_H -O2 -DNO_MMALLOC
+#MMALLOC=../mmalloc/libmmalloc.a
+#MMALLOC_INC=o_gdb/mmalloc s_gdb/mmalloc
+#CHECKS=
+#EXCLUDE_REGEX=| sed -e '/.*gnu-regex.*/d'
+endif
+
+MMALLOC_LIB=$(subst ..,$(GDB_OBJ),$(MMALLOC))
+MMALLOC_LIB_DIR=$(subst /libmmalloc.a,,$(MMALLOC_LIB))
+
+vpath %.a $(GDB_OBJ)/bfd $(GDB_OBJ)/intl $(GDB_OBJ)/libiberty $(GDB_OBJ)/opcodes $(GDB_OBJ)/readline $(MMALLOC_LIB_DIR)
+
+_INCS=o_gdb/gdb s_gdb/gdb s_gdb/include s_gdb/gdb/config \
+	o_gdb/bfd s_gdb/bfd \
+	o_gdb/opcodes s_gdb/opcodes \
+	o_gdb/intl s_gdb/intl \
+	o_gdb/readline s_gdb/readline \
+	o_gdb/libiberty s_gdb/libiberty \
+	$(MMALLOC_INC)
+
+INCS=$(subst s_gdb,$(GDB_SRC),$(subst o_gdb,$(GDB_OBJ),$(_INCS)))
+
+INC_PATH=$(addprefix -I,$(INCS))
+
+all:: libgdb.a
+
+libgdb.c: Makefile
+	echo '#include <defs.h>' > libgdb.c
+	echo '#include <breakpoint.h>' >> libgdb.c
+	echo '#include <symtab.h>' >> libgdb.c
+	echo '#include <symfile.h>' >> libgdb.c
+	echo '#include <objfiles.h>' >> libgdb.c
+	echo '#include <inferior.h>' >> libgdb.c
+	echo '#include <gnu-regex.h>' >> libgdb.c
+	echo '#include <expression.h>' >> libgdb.c
+	echo '#include <language.h>' >> libgdb.c
+	echo '#include <complaints.h>' >> libgdb.c
+	echo '#include <coff/internal.h>' >> libgdb.c
+	echo '#include <libcoff.h>' >> libgdb.c
+	echo '#include <ctype.h>' >> libgdb.c
+	echo '#include <string.h>' >> libgdb.c
+	echo '#include <buildsym.h>' >> libgdb.c
+	echo '#include <gdb-stabs.h>' >> libgdb.c
+	echo '#include <stabsread.h>' >> libgdb.c
+	echo '#include <gdbcmd.h>' >> libgdb.c
+	echo '#include <setjmp.h>' >> libgdb.c
+	echo '#include <demangle.h>' >> libgdb.c
+	echo '#include <annotate.h>' >> libgdb.c
+	echo '#include <top.h>' >> libgdb.c
+
+LIBGDB_FLAGS+=$(OS_FLAGS)
+CFLAGS+=$(OS_CFLAGS)
+
+$(GDB_OBJ)/bfd/bfd.h:
+	$(MAKE) -C $(dir $@) $(notdir $@)
+
+ifneq ($(LIBGDB_H),)
+libgdb.h: $(LIBGDB_H)
+	ln -sf $(LIBGDB_H) libgdb.h
+else
+libgdb.h: $(GDB_OBJ)/bfd/bfd.h libgdb.c
+	gcc -E -P $(INC_PATH) $(CFLAGS) $(MMALLOC_CFLAGS) libgdb.c \
+	  | sed -e '/^[ 	]*$$/d' > libgdb.h
+	gcc -E -P -dM $(INC_PATH) $(CFLAGS) $(MMALLOC_CFLAGS) libgdb.c \
+	  | sed -e '/^[ 	]*$$/d' >> libgdb.h
+endif
+
+gdb.t: $(GDB_OBJ)/gdb/libgdb-files
+	printf "%s\n" $(shell cat $<) | sed -n -e 's,^.*\.o,$(dir $<)&,p' $(EXCLUDE_REGEX) > $@
+
+%.t: %.a
+	ar t $< | sed -e 's,^.*\.o,$(dir $<)&,' > $@
+
+libbfd.t: $(GDB_OBJ)/bfd/libbfd.a
+libintl.t: $(GDB_OBJ)/intl/libintl.a
+libiberty.t: $(GDB_OBJ)/libiberty/libiberty.a
+libopcodes.t: $(GDB_OBJ)/opcodes/libopcodes.a
+libreadline.t: $(GDB_OBJ)/readline/libreadline.a
+libmmalloc.t: $(GDB_OBJ)/mmalloc/libmmalloc.a
+
+$(GDB_OBJ)/%.a:
+	$(MAKE) -C $(dir $@) CFLAGS="$(CFLAGS)" $(LIBGDB_FLAGS)
+
+$(GDB_OBJ)/gdb/libgdb-files:
+# this is needed, because the file is part of the src distrib, but
+# the object files not (at least in DJGPP)
+	rm -f $@
+	$(MAKE) -C $(dir $@) $(notdir $@) CFLAGS="$(CFLAGS)" $(LIBGDB_FLAGS)
+
+T_FILES= libbfd.t libiberty.t libintl.t libopcodes.t libreadline.t $(notdir $(subst .a,.t,$(MMALLOC_LIB))) gdb.t
+
+list: $(T_FILES)
+
+libgdb.a: $(CHECKS) list
+	rm -f libgdb.a
+# do not use any xmalloc.o, because it is defined in utils.o
+	ar rcs $@ $(shell cat $(T_FILES) | sed -e '/.*xmalloc.*/d')
+#        rm -f $(T_FILES)
+
+lib.zip : libgdb.a
+	zip lib libgdb.a
+	
+libgdb.so: $(CHECKS) list
+	rm -f libgdb.so
+# do not use any xmalloc.o, because it is defined in utils.o
+	ld -shared -o $@ $(shell cat $(T_FILES) | sed -e '/.*xmalloc.*/d')
+	rm -f $(T_FILES)
+

+ 142 - 0
packages/base/gdbint/libgdb/linux/Makefile

@@ -0,0 +1,142 @@
+#
+# $Id$
+#
+# Makefile to create libgdb.a / libgdb.so
+#
+
+ifeq ($(GDB_SRC),)
+ifeq ($(OS),DJGPP)
+GDB_SRC=$(DJDIR)/gnu/gdb-4.18
+else
+ifeq ($(OS_TARGET),win32)
+GDB_SRC=d:/cygwin/cygwin-b20/gnu/gdb-4.18
+else
+GDB_SRC=/usr/src/gdb-4.18
+endif
+endif
+endif
+
+ifeq ($(GDB_OBJ),)
+GDB_OBJ=$(GDB_SRC)
+endif
+
+ifeq ($(OS)),DJGPP)
+OS_CFLAGS=-DMAINTENANCE_CMDS=0 -DHAVE_CONFIG_H -O2 -DHAVE_LONG_DOUBLE=1 \
+	  -DPRINTF_HAS_LONG_DOUBLE=1
+OS_FLAGS=
+MMALLOC_INC=
+MMALLOC_CFLAGS=-DNO_MMALLOC -DNO_MMALLOC_CHECK
+MMALLOC_LIB=
+MMALLOC_LIB_DIR=
+OS_FLAGS+=MMALLOC=$(MMALLOC) MMALLOC_CFLAGS="$(MMALLOC_CFLAGS)"
+CHECKS=check_echo check_awk
+EXCLUDE_REGEX=
+else
+OS_CFLAGS=-DMAINTENANCE_CMDS=1 -DHAVE_CONFIG_H -O2 -DNO_MMALLOC
+#MMALLOC=../mmalloc/libmmalloc.a
+#MMALLOC_INC=o_gdb/mmalloc s_gdb/mmalloc
+#CHECKS=
+#EXCLUDE_REGEX=| sed -e '/.*gnu-regex.*/d'
+endif
+
+MMALLOC_LIB=$(subst ..,$(GDB_OBJ),$(MMALLOC))
+MMALLOC_LIB_DIR=$(subst /libmmalloc.a,,$(MMALLOC_LIB))
+
+vpath %.a $(GDB_OBJ)/bfd $(GDB_OBJ)/intl $(GDB_OBJ)/libiberty $(GDB_OBJ)/opcodes $(GDB_OBJ)/readline $(MMALLOC_LIB_DIR)
+
+_INCS=o_gdb/gdb s_gdb/gdb s_gdb/include s_gdb/gdb/config \
+	o_gdb/bfd s_gdb/bfd \
+	o_gdb/opcodes s_gdb/opcodes \
+	o_gdb/intl s_gdb/intl \
+	o_gdb/readline s_gdb/readline \
+	o_gdb/libiberty s_gdb/libiberty \
+	$(MMALLOC_INC)
+
+INCS=$(subst s_gdb,$(GDB_SRC),$(subst o_gdb,$(GDB_OBJ),$(_INCS)))
+
+INC_PATH=$(addprefix -I,$(INCS))
+
+all:: libgdb.a
+
+libgdb.c: Makefile
+	echo '#include <defs.h>' > libgdb.c
+	echo '#include <breakpoint.h>' >> libgdb.c
+	echo '#include <symtab.h>' >> libgdb.c
+	echo '#include <symfile.h>' >> libgdb.c
+	echo '#include <objfiles.h>' >> libgdb.c
+	echo '#include <inferior.h>' >> libgdb.c
+	echo '#include <gnu-regex.h>' >> libgdb.c
+	echo '#include <expression.h>' >> libgdb.c
+	echo '#include <language.h>' >> libgdb.c
+	echo '#include <complaints.h>' >> libgdb.c
+	echo '#include <coff/internal.h>' >> libgdb.c
+	echo '#include <libcoff.h>' >> libgdb.c
+	echo '#include <ctype.h>' >> libgdb.c
+	echo '#include <string.h>' >> libgdb.c
+	echo '#include <buildsym.h>' >> libgdb.c
+	echo '#include <gdb-stabs.h>' >> libgdb.c
+	echo '#include <stabsread.h>' >> libgdb.c
+	echo '#include <gdbcmd.h>' >> libgdb.c
+	echo '#include <setjmp.h>' >> libgdb.c
+	echo '#include <demangle.h>' >> libgdb.c
+	echo '#include <annotate.h>' >> libgdb.c
+	echo '#include <top.h>' >> libgdb.c
+
+LIBGDB_FLAGS+=$(OS_FLAGS)
+CFLAGS+=$(OS_CFLAGS)
+
+$(GDB_OBJ)/bfd/bfd.h:
+	$(MAKE) -C $(dir $@) $(notdir $@)
+
+ifneq ($(LIBGDB_H),)
+libgdb.h: $(LIBGDB_H)
+	ln -sf $(LIBGDB_H) libgdb.h
+else
+libgdb.h: $(GDB_OBJ)/bfd/bfd.h libgdb.c
+	gcc -E -P $(INC_PATH) $(CFLAGS) $(MMALLOC_CFLAGS) libgdb.c \
+	  | sed -e '/^[ 	]*$$/d' > libgdb.h
+	gcc -E -P -dM $(INC_PATH) $(CFLAGS) $(MMALLOC_CFLAGS) libgdb.c \
+	  | sed -e '/^[ 	]*$$/d' >> libgdb.h
+endif
+
+gdb.t: $(GDB_OBJ)/gdb/libgdb-files
+	printf "%s\n" $(shell cat $<) | sed -n -e 's,^.*\.o,$(dir $<)&,p' $(EXCLUDE_REGEX) > $@
+
+%.t: %.a
+	ar t $< | sed -e 's,^.*\.o,$(dir $<)&,' > $@
+
+libbfd.t: $(GDB_OBJ)/bfd/libbfd.a
+libintl.t: $(GDB_OBJ)/intl/libintl.a
+libiberty.t: $(GDB_OBJ)/libiberty/libiberty.a
+libopcodes.t: $(GDB_OBJ)/opcodes/libopcodes.a
+libreadline.t: $(GDB_OBJ)/readline/libreadline.a
+libmmalloc.t: $(GDB_OBJ)/mmalloc/libmmalloc.a
+
+$(GDB_OBJ)/%.a:
+	$(MAKE) -C $(dir $@) CFLAGS="$(CFLAGS)" $(LIBGDB_FLAGS)
+
+$(GDB_OBJ)/gdb/libgdb-files:
+# this is needed, because the file is part of the src distrib, but
+# the object files not (at least in DJGPP)
+	rm -f $@
+	$(MAKE) -C $(dir $@) $(notdir $@) CFLAGS="$(CFLAGS)" $(LIBGDB_FLAGS)
+
+T_FILES= libbfd.t libiberty.t libintl.t libopcodes.t libreadline.t $(notdir $(subst .a,.t,$(MMALLOC_LIB))) gdb.t
+
+list: $(T_FILES)
+
+libgdb.a: $(CHECKS) list
+	rm -f libgdb.a
+# do not use any xmalloc.o, because it is defined in utils.o
+	ar rcs $@ $(shell cat $(T_FILES) | sed -e '/.*xmalloc.*/d')
+	rm -f $(T_FILES)
+
+libgdb.so: $(CHECKS) list
+	rm -f libgdb.so
+# do not use any xmalloc.o, because it is defined in utils.o
+	ld -shared -o $@ $(shell cat $(T_FILES) | sed -e '/.*xmalloc.*/d')
+	rm -f $(T_FILES)
+
+lib.zip : libgdb.a
+	zip lib libgdb.a
+

+ 142 - 0
packages/base/gdbint/libgdb/netbsd/Makefile

@@ -0,0 +1,142 @@
+#
+# $Id$
+#
+# Makefile to create libgdb.a / libgdb.so
+#
+
+ifeq ($(GDB_SRC),)
+ifeq ($(OS),DJGPP)
+GDB_SRC=$(DJDIR)/gnu/gdb-4.18
+else
+ifeq ($(OS_TARGET),win32)
+GDB_SRC=d:/cygwin/cygwin-b20/gnu/gdb-4.18
+else
+GDB_SRC=/usr/src/gdb-4.18
+endif
+endif
+endif
+
+ifeq ($(GDB_OBJ),)
+GDB_OBJ=$(GDB_SRC)
+endif
+
+ifeq ($(OS)),DJGPP)
+OS_CFLAGS=-DMAINTENANCE_CMDS=0 -DHAVE_CONFIG_H -O2 -DHAVE_LONG_DOUBLE=1 \
+	  -DPRINTF_HAS_LONG_DOUBLE=1
+OS_FLAGS=
+MMALLOC_INC=
+MMALLOC_CFLAGS=-DNO_MMALLOC -DNO_MMALLOC_CHECK
+MMALLOC_LIB=
+MMALLOC_LIB_DIR=
+OS_FLAGS+=MMALLOC=$(MMALLOC) MMALLOC_CFLAGS="$(MMALLOC_CFLAGS)"
+CHECKS=check_echo check_awk
+EXCLUDE_REGEX=
+else
+OS_CFLAGS=-DMAINTENANCE_CMDS=1 -DHAVE_CONFIG_H -O2 -DNO_MMALLOC
+#MMALLOC=../mmalloc/libmmalloc.a
+#MMALLOC_INC=o_gdb/mmalloc s_gdb/mmalloc
+#CHECKS=
+#EXCLUDE_REGEX=| sed -e '/.*gnu-regex.*/d'
+endif
+
+MMALLOC_LIB=$(subst ..,$(GDB_OBJ),$(MMALLOC))
+MMALLOC_LIB_DIR=$(subst /libmmalloc.a,,$(MMALLOC_LIB))
+
+vpath %.a $(GDB_OBJ)/bfd $(GDB_OBJ)/intl $(GDB_OBJ)/libiberty $(GDB_OBJ)/opcodes $(GDB_OBJ)/readline $(MMALLOC_LIB_DIR)
+
+_INCS=o_gdb/gdb s_gdb/gdb s_gdb/include s_gdb/gdb/config \
+	o_gdb/bfd s_gdb/bfd \
+	o_gdb/opcodes s_gdb/opcodes \
+	o_gdb/intl s_gdb/intl \
+	o_gdb/readline s_gdb/readline \
+	o_gdb/libiberty s_gdb/libiberty \
+	$(MMALLOC_INC)
+
+INCS=$(subst s_gdb,$(GDB_SRC),$(subst o_gdb,$(GDB_OBJ),$(_INCS)))
+
+INC_PATH=$(addprefix -I,$(INCS))
+
+all:: libgdb.a
+
+libgdb.c: Makefile
+	echo '#include <defs.h>' > libgdb.c
+	echo '#include <breakpoint.h>' >> libgdb.c
+	echo '#include <symtab.h>' >> libgdb.c
+	echo '#include <symfile.h>' >> libgdb.c
+	echo '#include <objfiles.h>' >> libgdb.c
+	echo '#include <inferior.h>' >> libgdb.c
+	echo '#include <gnu-regex.h>' >> libgdb.c
+	echo '#include <expression.h>' >> libgdb.c
+	echo '#include <language.h>' >> libgdb.c
+	echo '#include <complaints.h>' >> libgdb.c
+	echo '#include <coff/internal.h>' >> libgdb.c
+	echo '#include <libcoff.h>' >> libgdb.c
+	echo '#include <ctype.h>' >> libgdb.c
+	echo '#include <string.h>' >> libgdb.c
+	echo '#include <buildsym.h>' >> libgdb.c
+	echo '#include <gdb-stabs.h>' >> libgdb.c
+	echo '#include <stabsread.h>' >> libgdb.c
+	echo '#include <gdbcmd.h>' >> libgdb.c
+	echo '#include <setjmp.h>' >> libgdb.c
+	echo '#include <demangle.h>' >> libgdb.c
+	echo '#include <annotate.h>' >> libgdb.c
+	echo '#include <top.h>' >> libgdb.c
+
+LIBGDB_FLAGS+=$(OS_FLAGS)
+CFLAGS+=$(OS_CFLAGS)
+
+$(GDB_OBJ)/bfd/bfd.h:
+	$(MAKE) -C $(dir $@) $(notdir $@)
+
+ifneq ($(LIBGDB_H),)
+libgdb.h: $(LIBGDB_H)
+	ln -sf $(LIBGDB_H) libgdb.h
+else
+libgdb.h: $(GDB_OBJ)/bfd/bfd.h libgdb.c
+	gcc -E -P $(INC_PATH) $(CFLAGS) $(MMALLOC_CFLAGS) libgdb.c \
+	  | sed -e '/^[ 	]*$$/d' > libgdb.h
+	gcc -E -P -dM $(INC_PATH) $(CFLAGS) $(MMALLOC_CFLAGS) libgdb.c \
+	  | sed -e '/^[ 	]*$$/d' >> libgdb.h
+endif
+
+gdb.t: $(GDB_OBJ)/gdb/libgdb-files
+	printf "%s\n" $(shell cat $<) | sed -n -e 's,^.*\.o,$(dir $<)&,p' $(EXCLUDE_REGEX) > $@
+
+%.t: %.a
+	ar t $< | sed -e 's,^.*\.o,$(dir $<)&,' > $@
+
+libbfd.t: $(GDB_OBJ)/bfd/libbfd.a
+libintl.t: $(GDB_OBJ)/intl/libintl.a
+libiberty.t: $(GDB_OBJ)/libiberty/libiberty.a
+libopcodes.t: $(GDB_OBJ)/opcodes/libopcodes.a
+libreadline.t: $(GDB_OBJ)/readline/libreadline.a
+libmmalloc.t: $(GDB_OBJ)/mmalloc/libmmalloc.a
+
+$(GDB_OBJ)/%.a:
+	$(MAKE) -C $(dir $@) CFLAGS="$(CFLAGS)" $(LIBGDB_FLAGS)
+
+$(GDB_OBJ)/gdb/libgdb-files:
+# this is needed, because the file is part of the src distrib, but
+# the object files not (at least in DJGPP)
+	rm -f $@
+	$(MAKE) -C $(dir $@) $(notdir $@) CFLAGS="$(CFLAGS)" $(LIBGDB_FLAGS)
+
+T_FILES= libbfd.t libiberty.t libintl.t libopcodes.t libreadline.t $(notdir $(subst .a,.t,$(MMALLOC_LIB))) gdb.t
+
+list: $(T_FILES)
+
+libgdb.a: $(CHECKS) list
+	rm -f libgdb.a
+# do not use any xmalloc.o, because it is defined in utils.o
+	ar rcs $@ $(shell cat $(T_FILES) | sed -e '/.*xmalloc.*/d')
+	rm -f $(T_FILES)
+
+libgdb.so: $(CHECKS) list
+	rm -f libgdb.so
+# do not use any xmalloc.o, because it is defined in utils.o
+	ld -shared -o $@ $(shell cat $(T_FILES) | sed -e '/.*xmalloc.*/d')
+	rm -f $(T_FILES)
+
+lib.zip : libgdb.a
+	zip lib libgdb.a
+

+ 142 - 0
packages/base/gdbint/libgdb/win32/Makefile

@@ -0,0 +1,142 @@
+#
+# $Id$
+#
+# Makefile to create libgdb.a / libgdb.so
+#
+
+ifeq ($(GDB_SRC),)
+ifeq ($(OS),DJGPP)
+GDB_SRC=$(DJDIR)/gnu/gdb-4.18
+else
+ifeq ($(OS_TARGET),win32)
+GDB_SRC=/cygwin/cygwin-b20/gnu/gdb/gdb-4.18
+else
+GDB_SRC=/usr/src/gdb-4.17
+endif
+endif
+endif
+
+ifeq ($(GDB_OBJ),)
+GDB_OBJ=$(GDB_SRC)
+endif
+
+ifeq ($(OS)),DJGPP)
+OS_CFLAGS=-DMAINTENANCE_CMDS=0 -DHAVE_CONFIG_H -O2 -DHAVE_LONG_DOUBLE=1 \
+	  -DPRINTF_HAS_LONG_DOUBLE=1
+OS_FLAGS=
+MMALLOC_INC=
+MMALLOC_CFLAGS=-DNO_MMALLOC -DNO_MMALLOC_CHECK
+MMALLOC_LIB=
+MMALLOC_LIB_DIR=
+OS_FLAGS+=MMALLOC=$(MMALLOC) MMALLOC_CFLAGS="$(MMALLOC_CFLAGS)"
+CHECKS=check_echo check_awk
+EXCLUDE_REGEX=
+else
+OS_CFLAGS=-DMAINTENANCE_CMDS=1 -DHAVE_CONFIG_H -O2 -DNO_MMALLOC
+#MMALLOC=../mmalloc/libmmalloc.a
+#MMALLOC_INC=o_gdb/mmalloc s_gdb/mmalloc
+#CHECKS=
+#EXCLUDE_REGEX=| sed -e '/.*gnu-regex.*/d'
+endif
+
+MMALLOC_LIB=$(subst ..,$(GDB_OBJ),$(MMALLOC))
+MMALLOC_LIB_DIR=$(subst /libmmalloc.a,,$(MMALLOC_LIB))
+
+vpath %.a $(GDB_OBJ)/bfd $(GDB_OBJ)/intl $(GDB_OBJ)/libiberty $(GDB_OBJ)/opcodes $(GDB_OBJ)/readline $(MMALLOC_LIB_DIR)
+
+_INCS=o_gdb/gdb s_gdb/gdb s_gdb/include s_gdb/gdb/config \
+	o_gdb/bfd s_gdb/bfd \
+	o_gdb/opcodes s_gdb/opcodes \
+	o_gdb/intl s_gdb/intl \
+	o_gdb/readline s_gdb/readline \
+	o_gdb/libiberty s_gdb/libiberty \
+	$(MMALLOC_INC)
+
+INCS=$(subst s_gdb,$(GDB_SRC),$(subst o_gdb,$(GDB_OBJ),$(_INCS)))
+
+INC_PATH=$(addprefix -I,$(INCS))
+
+all:: libgdb.a
+
+libgdb.c: Makefile
+	echo '#include <defs.h>' > libgdb.c
+	echo '#include <breakpoint.h>' >> libgdb.c
+	echo '#include <symtab.h>' >> libgdb.c
+	echo '#include <symfile.h>' >> libgdb.c
+	echo '#include <objfiles.h>' >> libgdb.c
+	echo '#include <inferior.h>' >> libgdb.c
+	echo '#include <gnu-regex.h>' >> libgdb.c
+	echo '#include <expression.h>' >> libgdb.c
+	echo '#include <language.h>' >> libgdb.c
+	echo '#include <complaints.h>' >> libgdb.c
+	echo '#include <coff/internal.h>' >> libgdb.c
+	echo '#include <libcoff.h>' >> libgdb.c
+	echo '#include <ctype.h>' >> libgdb.c
+	echo '#include <string.h>' >> libgdb.c
+	echo '#include <buildsym.h>' >> libgdb.c
+	echo '#include <gdb-stabs.h>' >> libgdb.c
+	echo '#include <stabsread.h>' >> libgdb.c
+	echo '#include <gdbcmd.h>' >> libgdb.c
+	echo '#include <setjmp.h>' >> libgdb.c
+	echo '#include <demangle.h>' >> libgdb.c
+	echo '#include <annotate.h>' >> libgdb.c
+	echo '#include <top.h>' >> libgdb.c
+
+LIBGDB_FLAGS+=$(OS_FLAGS)
+CFLAGS+=$(OS_CFLAGS)
+
+$(GDB_OBJ)/bfd/bfd.h:
+	$(MAKE) -C $(dir $@) $(notdir $@)
+
+ifneq ($(LIBGDB_H),)
+libgdb.h: $(LIBGDB_H)
+	ln -sf $(LIBGDB_H) libgdb.h
+else
+libgdb.h: $(GDB_OBJ)/bfd/bfd.h libgdb.c
+	gcc -E -P $(INC_PATH) $(CFLAGS) $(MMALLOC_CFLAGS) libgdb.c \
+	  | sed -e '/^[ 	]*$$/d' > libgdb.h
+	gcc -E -P -dM $(INC_PATH) $(CFLAGS) $(MMALLOC_CFLAGS) libgdb.c \
+	  | sed -e '/^[ 	]*$$/d' >> libgdb.h
+endif
+
+gdb.t: $(GDB_OBJ)/gdb/libgdb-files
+	printf "%s\n" $(shell cat $<) | sed -n -e 's,^.*\.o,$(dir $<)&,p' $(EXCLUDE_REGEX) > $@
+
+%.t: %.a
+	ar t $< | sed -e 's,^.*\.o,$(dir $<)&,' > $@
+
+libbfd.t: $(GDB_OBJ)/bfd/libbfd.a
+libintl.t: $(GDB_OBJ)/intl/libintl.a
+libiberty.t: $(GDB_OBJ)/libiberty/libiberty.a
+libopcodes.t: $(GDB_OBJ)/opcodes/libopcodes.a
+libreadline.t: $(GDB_OBJ)/readline/libreadline.a
+libmmalloc.t: $(GDB_OBJ)/mmalloc/libmmalloc.a
+
+$(GDB_OBJ)/%.a:
+	$(MAKE) -C $(dir $@) CFLAGS="$(CFLAGS)" $(LIBGDB_FLAGS)
+
+$(GDB_OBJ)/gdb/libgdb-files:
+# this is needed, because the file is part of the src distrib, but
+# the object files not (at least in DJGPP)
+	rm -f $@
+	$(MAKE) -C $(dir $@) $(notdir $@) CFLAGS="$(CFLAGS)" $(LIBGDB_FLAGS)
+
+T_FILES= libbfd.t libiberty.t libintl.t libopcodes.t libreadline.t $(notdir $(subst .a,.t,$(MMALLOC_LIB))) gdb.t
+
+list: $(T_FILES)
+
+libgdb.a: $(CHECKS) list
+	rm -f libgdb.a
+# do not use any xmalloc.o, because it is defined in utils.o
+	ar rcs $@ $(shell cat $(T_FILES) | sed -e '/.*xmalloc.*/d')
+#        rm -f $(T_FILES)
+
+lib.zip : libgdb.a
+	zip lib libgdb.a
+	
+libgdb.so: $(CHECKS) list
+	rm -f libgdb.so
+# do not use any xmalloc.o, because it is defined in utils.o
+	ld -shared -o $@ $(shell cat $(T_FILES) | sed -e '/.*xmalloc.*/d')
+	rm -f $(T_FILES)
+

+ 87 - 0
packages/base/gdbint/symify.pp

@@ -0,0 +1,87 @@
+{
+    $Id$
+    Copyright (c) 1998 by Peter Vreman
+
+    Translate backtrace addresses into file and line info
+
+    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.
+
+ **********************************************************************}
+program symify;
+uses GDBInt;
+
+var
+  gdb : tgdbinterface;
+
+
+procedure processlog(const fn:string);
+var
+  t    : text;
+  hs,s : string;
+  code : word;
+  i,
+  addr : longint;
+  sym  : tsyminfo;
+begin
+  assign(t,fn);
+  {$I-}
+   reset(t);
+  {$I+}
+  if ioresult<>0 then
+   exit;
+  while not eof(t) do
+   begin
+     readln(t,s);
+     i:=pos('0x',s);
+     if i=3 then
+      begin
+        hs:='$'+Copy(s,5,8);
+        Val(hs,addr,code);
+        if code=0 then
+         begin
+           gdb.GetAddrSymInfo(addr,sym);
+           Write(Copy(s,1,12));
+           if assigned(sym.funcname) then
+             write(' in ',sym.funcname,'+',sym.offset);
+           if assigned(sym.fname) then
+             writeln(' ',sym.fname,':',sym.line)
+           else
+             writeln;
+         end
+        else
+         writeln(s);
+      end
+     else
+      writeln(s);
+   end;
+  close(t);
+end;
+
+
+begin
+  if paramcount<2 then
+   begin
+     writeln('usage: symify <log> <file>');
+     halt(1);
+   end;
+  gdb.init;
+  writeln('loading ',paramstr(2));
+  gdb.gdb_command('file '+paramstr(2));
+  writeln('parsing ',paramstr(1));
+  processlog(paramstr(1));
+  gdb.done;
+end.
+{
+  $Log$
+  Revision 1.1  2002-01-29 17:54:49  peter
+    * splitted to base and extra
+
+  Revision 1.2  2000/07/13 11:33:16  michael
+  + removed logs
+ 
+}

+ 64 - 0
packages/base/gdbint/testgdb.pp

@@ -0,0 +1,64 @@
+{
+    $Id$
+    Copyright (c) 1998 by Peter Vreman
+
+    Small example program to the GDB
+
+    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.
+
+ **********************************************************************}
+program testgdb;
+uses gdbcon;
+var
+  last,s,parafile : string;
+  gdb : tgdbcontroller;
+begin
+  gdb.init;
+  if paramcount=1 then
+    parafile:=paramstr(1)
+  else
+    parafile:='test';
+  gdb.loadfile(parafile);
+  Writeln('Welcome to the pascal GDB...');
+  Writeln('Type "q" to exit...');
+  last:='';
+  repeat
+    write('>');
+    readln(s);
+    if (s='a') then
+     gdb.starttrace
+    else
+     if (s='s') then
+      gdb.tracestep
+    else
+     if (s='n') then
+      gdb.tracenext
+    else
+     if (s='q') then
+      break
+    else
+     begin
+       if s='' then
+         s:=last;
+       GDB.Command(s);
+       GDB.WriteErrorBuf;
+       GDB.WriteOutputBuf;
+       last:=s;
+     end;
+  until false;
+  Writeln('End of pascal GDB...');
+end.
+{
+  $Log$
+  Revision 1.1  2002-01-29 17:54:49  peter
+    * splitted to base and extra
+
+  Revision 1.2  2000/07/13 11:33:16  michael
+  + removed logs
+ 
+}

+ 1254 - 0
packages/base/ibase/Makefile

@@ -0,0 +1,1254 @@
+#
+# Don't edit, this file is generated by FPCMake Version 1.1 [2002/01/29]
+#
+default: all
+MAKEFILETARGETS=linux go32v2 win32 os2 freebsd beos netbsd amiga atari sunos qnx
+override PATH:=$(subst \,/,$(PATH))
+ifeq ($(findstring ;,$(PATH)),)
+inUnix=1
+SEARCHPATH:=$(filter-out .,$(subst :, ,$(PATH)))
+else
+SEARCHPATH:=$(subst ;, ,$(PATH))
+endif
+PWD:=$(strip $(wildcard $(addsuffix /pwd.exe,$(SEARCHPATH))))
+ifeq ($(PWD),)
+PWD:=$(strip $(wildcard $(addsuffix /pwd,$(SEARCHPATH))))
+ifeq ($(PWD),)
+$(error You need the GNU utils package to use this Makefile)
+else
+PWD:=$(firstword $(PWD))
+SRCEXEEXT=
+endif
+else
+PWD:=$(firstword $(PWD))
+SRCEXEEXT=.exe
+endif
+ifndef inUnix
+ifeq ($(OS),Windows_NT)
+inWinNT=1
+else
+ifdef OS2_SHELL
+inOS2=1
+endif
+endif
+else
+ifneq ($(findstring cygwin,$(MACHTYPE)),)
+inCygWin=1
+endif
+endif
+ifeq ($(OS_TARGET),freebsd)
+BSDhier=1
+endif
+ifeq ($(OS_TARGET),netbsd)
+BSDhier=1
+endif
+ifdef inUnix
+BATCHEXT=.sh
+else
+ifdef inOS2
+BATCHEXT=.cmd
+else
+BATCHEXT=.bat
+endif
+endif
+ifdef inUnix
+PATHSEP=/
+else
+PATHSEP:=$(subst /,\,/)
+endif
+ifdef PWD
+BASEDIR:=$(subst \,/,$(shell $(PWD)))
+ifdef inCygWin
+ifneq ($(findstring /cygdrive/,$(BASEDIR)),)
+BASENODIR:=$(patsubst /cygdrive%,%,$(BASEDIR))
+BASEDRIVE:=$(firstword $(subst /, ,$(BASENODIR)))
+BASEDIR:=$(subst /cygdrive/$(BASEDRIVE)/,$(BASEDRIVE):/,$(BASEDIR))
+endif
+endif
+else
+BASEDIR=.
+endif
+override DEFAULT_FPCDIR=../../..
+ifndef FPC
+ifdef PP
+FPC=$(PP)
+endif
+endif
+ifndef FPC
+FPCPROG:=$(strip $(wildcard $(addsuffix /fpc$(SRCEXEEXT),$(SEARCHPATH))))
+ifneq ($(FPCPROG),)
+FPCPROG:=$(firstword $(FPCPROG))
+FPC:=$(shell $(FPCPROG) -PB)
+ifneq ($(findstring Error,$(FPC)),)
+override FPC=ppc386
+endif
+else
+override FPC=ppc386
+endif
+endif
+override FPC:=$(subst $(SRCEXEEXT),,$(FPC))
+override FPC:=$(subst \,/,$(FPC))$(SRCEXEEXT)
+ifndef FPC_VERSION
+FPC_VERSION:=$(shell $(FPC) -iV)
+endif
+export FPC FPC_VERSION
+ifeq ($(findstring 1.0.,$(FPC_VERSION)),)
+COMPILERINFO:=$(shell $(FPC) -iSP -iTP -iSO -iTO)
+ifndef CPU_SOURCE
+CPU_SOURCE:=$(word 1,$(COMPILERINFO))
+endif
+ifndef CPU_TARGET
+CPU_TARGET:=$(word 2,$(COMPILERINFO))
+endif
+ifndef OS_SOURCE
+OS_SOURCE:=$(word 3,$(COMPILERINFO))
+endif
+ifndef OS_TARGET
+OS_TARGET:=$(word 4,$(COMPILERINFO))
+endif
+else
+ifndef CPU_SOURCE
+CPU_SOURCE:=$(shell $(FPC) -iSP)
+endif
+ifndef CPU_TARGET
+CPU_TARGET:=$(shell $(FPC) -iTP)
+endif
+ifndef OS_SOURCE
+OS_SOURCE:=$(shell $(FPC) -iSO)
+endif
+ifndef OS_TARGET
+OS_TARGET:=$(shell $(FPC) -iTO)
+endif
+endif
+FULL_TARGET=$(CPU_TARGET)-$(OS_TARGET)
+FULL_SOURCE=$(CPU_SOURCE)-$(OS_SOURCE)
+ifneq ($(FULL_TARGET),$(FULL_SOURCE))
+CROSSCOMPILE=1
+endif
+ifeq ($(findstring makefile,$(MAKECMDGOALS)),)
+ifeq ($(findstring $(OS_TARGET),$(MAKEFILETARGETS)),)
+$(error The Makefile doesn't support target $(OS_TARGET), please run fpcmake first)
+endif
+endif
+export OS_TARGET OS_SOURCE CPU_TARGET CPU_SOURCE FULL_TARGET FULL_SOURCE CROSSCOMPILE
+ifdef FPCDIR
+override FPCDIR:=$(subst \,/,$(FPCDIR))
+ifeq ($(wildcard $(addprefix $(FPCDIR)/,rtl units)),)
+override FPCDIR=wrong
+endif
+else
+override FPCDIR=wrong
+endif
+ifdef DEFAULT_FPCDIR
+ifeq ($(FPCDIR),wrong)
+override FPCDIR:=$(subst \,/,$(DEFAULT_FPCDIR))
+ifeq ($(wildcard $(addprefix $(FPCDIR)/,rtl units)),)
+override FPCDIR=wrong
+endif
+endif
+endif
+ifeq ($(FPCDIR),wrong)
+ifdef inUnix
+override FPCDIR=/usr/local/lib/fpc/$(FPC_VERSION)
+ifeq ($(wildcard $(FPCDIR)/units),)
+override FPCDIR=/usr/lib/fpc/$(FPC_VERSION)
+endif
+else
+override FPCDIR:=$(subst /$(FPC),,$(firstword $(strip $(wildcard $(addsuffix /$(FPC),$(SEARCHPATH))))))
+override FPCDIR:=$(FPCDIR)/..
+ifeq ($(wildcard $(addprefix $(FPCDIR)/,rtl units)),)
+override FPCDIR:=$(FPCDIR)/..
+ifeq ($(wildcard $(addprefix $(FPCDIR)/,rtl units)),)
+override FPCDIR=c:/pp
+endif
+endif
+endif
+endif
+ifndef CROSSDIR
+CROSSDIR:=$(FPCDIR)/cross/$(FULL_TARGET)
+endif
+ifndef CROSSTARGETDIR
+CROSSTARGETDIR=$(CROSSDIR)/$(FULL_TARGET)
+endif
+ifdef CROSSCOMPILE
+UNITSDIR:=$(wildcard $(CROSSTARGETDIR)/units)
+ifeq ($(UNITSDIR),)
+UNITSDIR:=$(wildcard $(FPCDIR)/units/$(OS_TARGET))
+endif
+else
+UNITSDIR:=$(wildcard $(FPCDIR)/units/$(OS_TARGET))
+endif
+PACKAGESDIR:=$(wildcard $(FPCDIR) $(FPCDIR)/packages/base $(FPCDIR)/packages/extra)
+override PACKAGE_NAME=ibase
+override PACKAGE_VERSION=1.0.6
+override TARGET_UNITS+=ibase40 ibase60
+override TARGET_EXAMPLES+=testib40 testib60
+override INSTALL_FPCPACKAGE=y
+ifdef REQUIRE_UNITSDIR
+override UNITSDIR+=$(REQUIRE_UNITSDIR)
+endif
+ifdef REQUIRE_PACKAGESDIR
+override PACKAGESDIR+=$(REQUIRE_PACKAGESDIR)
+endif
+ifdef ZIPINSTALL
+ifeq ($(OS_TARGET),linux)
+UNIXINSTALLDIR=1
+endif
+ifeq ($(OS_TARGET),freebsd)
+UNIXINSTALLDIR=1
+endif
+ifeq ($(OS_TARGET),netbsd)
+UNIXINSTALLDIR=1
+endif
+ifeq ($(OS_TARGET),sunos)
+UNIXINSTALLDIR=1
+endif
+else
+ifeq ($(OS_SOURCE),linux)
+UNIXINSTALLDIR=1
+endif
+ifeq ($(OS_SOURCE),freebsd)
+UNIXINSTALLDIR=1
+endif
+ifeq ($(OS_SOURCE),netbsd)
+UNIXINSTALLDIR=1
+endif
+ifeq ($(OS_TARGET),sunos)
+UNIXINSTALLDIR=1
+endif
+endif
+ifndef INSTALL_PREFIX
+ifdef PREFIX
+INSTALL_PREFIX=$(PREFIX)
+endif
+endif
+ifndef INSTALL_PREFIX
+ifdef UNIXINSTALLDIR
+INSTALL_PREFIX=/usr/local
+else
+ifdef INSTALL_FPCPACKAGE
+INSTALL_BASEDIR:=/pp
+else
+INSTALL_BASEDIR:=/$(PACKAGE_NAME)
+endif
+endif
+endif
+export INSTALL_PREFIX
+ifndef DIST_DESTDIR
+DIST_DESTDIR:=$(BASEDIR)
+endif
+export DIST_DESTDIR
+ifndef INSTALL_BASEDIR
+ifdef UNIXINSTALLDIR
+ifdef INSTALL_FPCPACKAGE
+INSTALL_BASEDIR:=$(INSTALL_PREFIX)/lib/fpc/$(FPC_VERSION)
+else
+INSTALL_BASEDIR:=$(INSTALL_PREFIX)/lib/$(PACKAGE_NAME)
+endif
+else
+INSTALL_BASEDIR:=$(INSTALL_PREFIX)
+endif
+endif
+ifndef INSTALL_BINDIR
+ifdef UNIXINSTALLDIR
+INSTALL_BINDIR:=$(INSTALL_PREFIX)/bin
+else
+INSTALL_BINDIR:=$(INSTALL_BASEDIR)/bin
+ifdef INSTALL_FPCPACKAGE
+INSTALL_BINDIR:=$(INSTALL_BINDIR)/$(OS_TARGET)
+endif
+endif
+endif
+ifndef INSTALL_UNITDIR
+ifdef CROSSCOMPILE
+INSTALL_UNITDIR:=$(INSTALL_BASEDIR)/cross/$(FULL_TARGET)/units
+else
+INSTALL_UNITDIR:=$(INSTALL_BASEDIR)/units/$(OS_TARGET)
+endif
+ifdef INSTALL_FPCPACKAGE
+ifdef PACKAGE_NAME
+INSTALL_UNITDIR:=$(INSTALL_UNITDIR)/$(PACKAGE_NAME)
+endif
+endif
+endif
+ifndef INSTALL_LIBDIR
+ifdef UNIXINSTALLDIR
+INSTALL_LIBDIR:=$(INSTALL_PREFIX)/lib
+else
+INSTALL_LIBDIR:=$(INSTALL_UNITDIR)
+endif
+endif
+ifndef INSTALL_SOURCEDIR
+ifdef UNIXINSTALLDIR
+ifdef INSTALL_FPCPACKAGE
+ifdef BSDhier
+INSTALL_SOURCEDIR:=$(INSTALL_PREFIX)/share/src/fpc-$(FPC_VERSION)/$(PACKAGE_NAME)
+else
+INSTALL_SOURCEDIR:=$(INSTALL_PREFIX)/src/fpc-$(FPC_VERSION)/$(PACKAGE_NAME)
+endif
+else
+ifdef BSDhier
+INSTALL_SOURCEDIR:=$(INSTALL_PREFIX)/share/src/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
+else
+INSTALL_SOURCEDIR:=$(INSTALL_PREFIX)/src/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
+endif
+endif
+else
+ifdef INSTALL_FPCPACKAGE
+INSTALL_SOURCEDIR:=$(INSTALL_BASEDIR)/source/$(PACKAGE_NAME)
+else
+INSTALL_SOURCEDIRL:=$(INSTALL_BASEDIR)/source
+endif
+endif
+endif
+ifndef INSTALL_DOCDIR
+ifdef UNIXINSTALLDIR
+ifdef INSTALL_FPCPACKAGE
+ifdef BSDhier
+INSTALL_DOCDIR:=$(INSTALL_PREFIX)/share/doc/fpc-$(FPC_VERSION)/$(PACKAGE_NAME)
+else
+INSTALL_DOCDIR:=$(INSTALL_PREFIX)/doc/fpc-$(FPC_VERSION)/$(PACKAGE_NAME)
+endif
+else
+ifdef BSDhier
+INSTALL_DOCDIR:=$(INSTALL_PREFIX)/share/doc/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
+else
+INSTALL_DOCDIR:=$(INSTALL_PREFIX)/doc/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
+endif
+endif
+else
+ifdef INSTALL_FPCPACKAGE
+INSTALL_DOCDIR:=$(INSTALL_BASEDIR)/doc/$(PACKAGE_NAME)
+else
+INSTALL_DOCDIR:=$(INSTALL_BASEDIR)/doc
+endif
+endif
+endif
+ifndef INSTALL_EXAMPLEDIR
+ifdef UNIXINSTALLDIR
+ifdef INSTALL_FPCPACKAGE
+ifdef BSDhier
+INSTALL_EXAMPLEDIR:=$(INSTALL_PREFIX)/share/examples/fpc-$(FPC_VERSION)/$(PACKAGE_NAME)
+else
+INSTALL_EXAMPLEDIR:=$(INSTALL_PREFIX)/doc/fpc-$(FPC_VERSION)/examples/$(PACKAGE_NAME)
+endif
+else
+ifdef BSDhier
+INSTALL_EXAMPLEDIR:=$(INSTALL_PREFIX)/share/examples/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
+else
+INSTALL_EXAMPLEDIR:=$(INSTALL_PREFIX)/doc/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
+endif
+endif
+else
+ifdef INSTALL_FPCPACKAGE
+INSTALL_EXAMPLEDIR:=$(INSTALL_BASEDIR)/examples/$(PACKAGE_NAME)
+else
+INSTALL_EXAMPLEDIR:=$(INSTALL_BASEDIR)/examples
+endif
+endif
+endif
+ifndef INSTALL_DATADIR
+INSTALL_DATADIR=$(INSTALL_BASEDIR)
+endif
+ifdef CROSSCOMPILE
+ifndef CROSSBINDIR
+CROSSBINDIR:=$(wildcard $(CROSSTARGETDIR)/bin/$(FULL_SOURCE))
+ifeq ($(CROSSBINDIR),)
+CROSSBINDIR:=$(wildcard $(INSTALL_BASEDIR)/cross/$(FULL_TARGET)/bin/$(FULL_SOURCE))
+endif
+endif
+else
+CROSSBINDIR=
+endif
+ifdef inUnix
+ifndef GCCLIBDIR
+GCCLIBDIR:=$(shell dirname `(gcc -v 2>&1)| head -n 1| awk '{ print $$4 } '`)
+endif
+ifeq ($(OS_TARGET),linux)
+ifndef OTHERLIBDIR
+OTHERLIBDIR:=$(shell grep -v "^\#" /etc/ld.so.conf | awk '{ ORS=" "; print $1 }')
+endif
+endif
+ifeq ($(OS_TARGET),netbsd)
+OTHERLIBDIR+=/usr/pkg/lib
+endif
+export GCCLIBDIR OTHERLIB
+endif
+LOADEREXT=.as
+EXEEXT=.exe
+PPLEXT=.ppl
+PPUEXT=.ppu
+OEXT=.o
+ASMEXT=.s
+SMARTEXT=.sl
+STATICLIBEXT=.a
+SHAREDLIBEXT=.so
+STATICLIBPREFIX=libp
+RSTEXT=.rst
+FPCMADE=fpcmade
+ifeq ($(OS_TARGET),go32v1)
+PPUEXT=.pp1
+OEXT=.o1
+ASMEXT=.s1
+SMARTEXT=.sl1
+STATICLIBEXT=.a1
+SHAREDLIBEXT=.so1
+STATICLIBPREFIX=
+FPCMADE=fpcmade.v1
+PACKAGESUFFIX=v1
+endif
+ifeq ($(OS_TARGET),go32v2)
+STATICLIBPREFIX=
+FPCMADE=fpcmade.dos
+ZIPSUFFIX=go32
+endif
+ifeq ($(OS_TARGET),linux)
+EXEEXT=
+HASSHAREDLIB=1
+FPCMADE=fpcmade.lnx
+ZIPSUFFIX=linux
+endif
+ifeq ($(OS_TARGET),freebsd)
+EXEEXT=
+HASSHAREDLIB=1
+FPCMADE=fpcmade.freebsd
+ZIPSUFFIX=freebsd
+endif
+ifeq ($(OS_TARGET),netbsd)
+EXEEXT=
+HASSHAREDLIB=1
+FPCMADE=fpcmade.netbsd
+ZIPSUFFIX=netbsd
+endif
+ifeq ($(OS_TARGET),win32)
+PPUEXT=.ppw
+OEXT=.ow
+ASMEXT=.sw
+SMARTEXT=.slw
+STATICLIBEXT=.aw
+SHAREDLIBEXT=.dll
+FPCMADE=fpcmade.w32
+ZIPSUFFIX=w32
+endif
+ifeq ($(OS_TARGET),os2)
+PPUEXT=.ppo
+ASMEXT=.so2
+OEXT=.oo2
+AOUTEXT=.out
+SMARTEXT=.so
+STATICLIBEXT=.ao2
+SHAREDLIBEXT=.dll
+FPCMADE=fpcmade.os2
+ZIPSUFFIX=emx
+endif
+ifeq ($(OS_TARGET),amiga)
+EXEEXT=
+PPUEXT=.ppa
+ASMEXT=.asm
+OEXT=.o
+SMARTEXT=.sl
+STATICLIBEXT=.a
+SHAREDLIBEXT=.library
+FPCMADE=fpcmade.amg
+endif
+ifeq ($(OS_TARGET),atari)
+PPUEXT=.ppt
+ASMEXT=.s
+OEXT=.o
+SMARTEXT=.sl
+STATICLIBEXT=.a
+EXEEXT=.ttp
+FPCMADE=fpcmade.ata
+endif
+ifeq ($(OS_TARGET),beos)
+PPUEXT=.ppu
+ASMEXT=.s
+OEXT=.o
+SMARTEXT=.sl
+STATICLIBEXT=.a
+EXEEXT=
+FPCMADE=fpcmade.be
+ZIPSUFFIX=be
+endif
+ifeq ($(OS_TARGET),sunos)
+PPUEXT=.ppu
+ASMEXT=.s
+OEXT=.o
+SMARTEXT=.sl
+STATICLIBEXT=.a
+EXEEXT=
+FPCMADE=fpcmade.sun
+ZIPSUFFIX=sun
+endif
+ifeq ($(OS_TARGET),qnx)
+PPUEXT=.ppu
+ASMEXT=.s
+OEXT=.o
+SMARTEXT=.sl
+STATICLIBEXT=.a
+EXEEXT=
+FPCMADE=fpcmade.qnx
+ZIPSUFFIX=qnx
+endif
+ifndef ECHO
+ECHO:=$(strip $(wildcard $(addsuffix /gecho$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(ECHO),)
+ECHO:=$(strip $(wildcard $(addsuffix /echo$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(ECHO),)
+ECHO=
+else
+ECHO:=$(firstword $(ECHO))
+endif
+else
+ECHO:=$(firstword $(ECHO))
+endif
+endif
+export ECHO
+ifndef DATE
+DATE:=$(strip $(wildcard $(addsuffix /gdate$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(DATE),)
+DATE:=$(strip $(wildcard $(addsuffix /date$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(DATE),)
+DATE=
+else
+DATE:=$(firstword $(DATE))
+endif
+else
+DATE:=$(firstword $(DATE))
+endif
+endif
+export DATE
+ifndef GINSTALL
+GINSTALL:=$(strip $(wildcard $(addsuffix /ginstall$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(GINSTALL),)
+GINSTALL:=$(strip $(wildcard $(addsuffix /install$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(GINSTALL),)
+GINSTALL=
+else
+GINSTALL:=$(firstword $(GINSTALL))
+endif
+else
+GINSTALL:=$(firstword $(GINSTALL))
+endif
+endif
+export GINSTALL
+ifndef CPPROG
+CPPROG:=$(strip $(wildcard $(addsuffix /cp$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(CPPROG),)
+CPPROG=
+else
+CPPROG:=$(firstword $(CPPROG))
+endif
+endif
+export CPPROG
+ifndef RMPROG
+RMPROG:=$(strip $(wildcard $(addsuffix /rm$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(RMPROG),)
+RMPROG=
+else
+RMPROG:=$(firstword $(RMPROG))
+endif
+endif
+export RMPROG
+ifndef MVPROG
+MVPROG:=$(strip $(wildcard $(addsuffix /mv$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(MVPROG),)
+MVPROG=
+else
+MVPROG:=$(firstword $(MVPROG))
+endif
+endif
+export MVPROG
+ifndef ECHOREDIR
+ECHOREDIR:=$(subst /,$(PATHSEP),$(ECHO))
+endif
+ifndef COPY
+COPY:=$(CPPROG) -fp
+endif
+ifndef COPYTREE
+COPYTREE:=$(CPPROG) -rfp
+endif
+ifndef MOVE
+MOVE:=$(MVPROG) -f
+endif
+ifndef DEL
+DEL:=$(RMPROG) -f
+endif
+ifndef DELTREE
+DELTREE:=$(RMPROG) -rf
+endif
+ifndef INSTALL
+ifdef inUnix
+INSTALL:=$(GINSTALL) -c -m 644
+else
+INSTALL:=$(COPY)
+endif
+endif
+ifndef INSTALLEXE
+ifdef inUnix
+INSTALLEXE:=$(GINSTALL) -c -m 755
+else
+INSTALLEXE:=$(COPY)
+endif
+endif
+ifndef MKDIR
+MKDIR:=$(GINSTALL) -m 755 -d
+endif
+export ECHOREDIR COPY COPYTREE MOVE DEL DELTREE INSTALL INSTALLEXE MKDIR
+ifndef PPUMOVE
+PPUMOVE:=$(strip $(wildcard $(addsuffix /ppumove$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(PPUMOVE),)
+PPUMOVE=
+else
+PPUMOVE:=$(firstword $(PPUMOVE))
+endif
+endif
+export PPUMOVE
+ifndef FPCMAKE
+FPCMAKE:=$(strip $(wildcard $(addsuffix /fpcmake$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(FPCMAKE),)
+FPCMAKE=
+else
+FPCMAKE:=$(firstword $(FPCMAKE))
+endif
+endif
+export FPCMAKE
+ifndef ZIPPROG
+ZIPPROG:=$(strip $(wildcard $(addsuffix /zip$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(ZIPPROG),)
+ZIPPROG=
+else
+ZIPPROG:=$(firstword $(ZIPPROG))
+endif
+endif
+export ZIPPROG
+ifndef TARPROG
+TARPROG:=$(strip $(wildcard $(addsuffix /tar$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(TARPROG),)
+TARPROG=
+else
+TARPROG:=$(firstword $(TARPROG))
+endif
+endif
+export TARPROG
+ASNAME=as
+LDNAME=ld
+ARNAME=ar
+RCNAME=rc
+ifeq ($(OS_TARGET),win32)
+ASNAME=asw
+LDNAME=ldw
+ARNAME=arw
+endif
+ifndef ASPROG
+ifdef CROSSBINDIR
+ASPROG=$(CROSSBINDIR)/$(ASNAME)$(SRCEXEEXT)
+else
+ASPROG=$(ASNAME)
+endif
+endif
+ifndef LDPROG
+ifdef CROSSBINDIR
+LDPROG=$(CROSSBINDIR)/$(LDNAME)$(SRCEXEEXT)
+else
+LDPROG=$(LDNAME)
+endif
+endif
+ifndef RCPROG
+ifdef CROSSBINDIR
+RCPROG=$(CROSSBINDIR)/$(RCNAME)$(SRCEXEEXT)
+else
+RCPROG=$(RCNAME)
+endif
+endif
+ifndef ARPROG
+ifdef CROSSBINDIR
+ARPROG=$(CROSSBINDIR)/$(ARNAME)$(SRCEXEEXT)
+else
+ARPROG=$(ARNAME)
+endif
+endif
+AS=$(ASPROG)
+LD=$(LDPROG)
+RC=$(RCPROG)
+AR=$(ARPROG)
+PPAS=ppas$(BATCHEXT)
+ifdef inUnix
+LDCONFIG=ldconfig
+else
+LDCONFIG=
+endif
+ifdef DATE
+DATESTR:=$(shell $(DATE) +%Y%m%d)
+else
+DATESTR=
+endif
+ifndef UPXPROG
+ifeq ($(OS_TARGET),go32v2)
+UPXPROG:=1
+endif
+ifeq ($(OS_TARGET),win32)
+UPXPROG:=1
+endif
+ifdef UPXPROG
+UPXPROG:=$(strip $(wildcard $(addsuffix /upx$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(UPXPROG),)
+UPXPROG=
+else
+UPXPROG:=$(firstword $(UPXPROG))
+endif
+else
+UPXPROG=
+endif
+endif
+export UPXPROG
+ZIPOPT=-9
+ZIPEXT=.zip
+ifeq ($(USETAR),bz2)
+TAROPT=vI
+TAREXT=.tar.bz2
+else
+TAROPT=vz
+TAREXT=.tar.gz
+endif
+override REQUIRE_PACKAGES=rtl 
+ifeq ($(OS_TARGET),linux)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(OS_TARGET),go32v2)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(OS_TARGET),win32)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(OS_TARGET),os2)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(OS_TARGET),freebsd)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(OS_TARGET),beos)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(OS_TARGET),netbsd)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(OS_TARGET),amiga)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(OS_TARGET),atari)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(OS_TARGET),sunos)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(OS_TARGET),qnx)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifdef REQUIRE_PACKAGES_RTL
+PACKAGEDIR_RTL:=$(firstword $(subst /Makefile.fpc,,$(strip $(wildcard $(addsuffix /rtl/$(OS_TARGET)/Makefile.fpc,$(PACKAGESDIR))))))
+ifneq ($(PACKAGEDIR_RTL),)
+ifneq ($(wildcard $(PACKAGEDIR_RTL)/$(OS_TARGET)),)
+UNITDIR_RTL=$(PACKAGEDIR_RTL)/$(OS_TARGET)
+else
+UNITDIR_RTL=$(PACKAGEDIR_RTL)
+endif
+else
+PACKAGEDIR_RTL=
+UNITDIR_RTL:=$(subst /Package.fpc,,$(strip $(wildcard $(addsuffix /rtl/Package.fpc,$(UNITSDIR)))))
+ifneq ($(UNITDIR_RTL),)
+UNITDIR_RTL:=$(firstword $(UNITDIR_RTL))
+else
+UNITDIR_RTL=
+endif
+endif
+ifdef UNITDIR_RTL
+override COMPILER_UNITDIR+=$(UNITDIR_RTL)
+endif
+endif
+ifndef NOCPUDEF
+override FPCOPTDEF=$(CPU_TARGET)
+endif
+ifneq ($(OS_TARGET),$(OS_SOURCE))
+override FPCOPT+=-T$(OS_TARGET)
+endif
+ifdef UNITDIR
+override FPCOPT+=$(addprefix -Fu,$(UNITDIR))
+endif
+ifdef LIBDIR
+override FPCOPT+=$(addprefix -Fl,$(LIBDIR))
+endif
+ifdef OBJDIR
+override FPCOPT+=$(addprefix -Fo,$(OBJDIR))
+endif
+ifdef INCDIR
+override FPCOPT+=$(addprefix -Fi,$(INCDIR))
+endif
+ifdef LINKSMART
+override FPCOPT+=-XX
+endif
+ifdef CREATESMART
+override FPCOPT+=-CX
+endif
+ifdef DEBUG
+override FPCOPT+=-gl
+override FPCOPTDEF+=DEBUG
+endif
+ifdef RELEASE
+ifeq ($(CPU_TARGET),i386)
+FPCCPUOPT:=-OG2p3
+else
+FPCCPUOPT:=
+endif
+override FPCOPT+=-Xs $(FPCCPUOPT) -n
+override FPCOPTDEF+=RELEASE
+endif
+ifdef STRIP
+override FPCOPT+=-Xs
+endif
+ifdef OPTIMIZE
+ifeq ($(CPU_TARGET),i386)
+override FPCOPT+=-OG2p3
+endif
+endif
+ifdef VERBOSE
+override FPCOPT+=-vwni
+endif
+ifdef COMPILER_OPTIONS
+override FPCOPT+=$(COMPILER_OPTIONS)
+endif
+ifdef COMPILER_UNITDIR
+override FPCOPT+=$(addprefix -Fu,$(COMPILER_UNITDIR))
+endif
+ifdef COMPILER_LIBRARYDIR
+override FPCOPT+=$(addprefix -Fl,$(COMPILER_LIBRARYDIR))
+endif
+ifdef COMPILER_OBJECTDIR
+override FPCOPT+=$(addprefix -Fo,$(COMPILER_OBJECTDIR))
+endif
+ifdef COMPILER_INCLUDEDIR
+override FPCOPT+=$(addprefix -Fi,$(COMPILER_INCLUDEDIR))
+endif
+ifdef CROSSBINDIR
+override FPCOPT+=-FD$(CROSSBINDIR)
+endif
+ifdef COMPILER_TARGETDIR
+override FPCOPT+=-FE$(COMPILER_TARGETDIR)
+ifeq ($(COMPILER_TARGETDIR),.)
+override TARGETDIRPREFIX=
+else
+override TARGETDIRPREFIX=$(COMPILER_TARGETDIR)/
+endif
+endif
+ifdef COMPILER_UNITTARGETDIR
+override FPCOPT+=-FU$(COMPILER_UNITTARGETDIR)
+ifeq ($(COMPILER_UNITTARGETDIR),.)
+override UNITTARGETDIRPREFIX=
+else
+override UNITTARGETDIRPREFIX=$(COMPILER_UNITTARGETDIR)/
+endif
+else
+ifdef COMPILER_TARGETDIR
+override COMPILER_UNITTARGETDIR=$(COMPILER_TARGETDIR)
+override UNITTARGETDIRPREFIX=$(TARGETDIRPREFIX)
+endif
+endif
+ifdef GCCLIBDIR
+override FPCOPT+=-Fl$(GCCLIBDIR)
+endif
+ifdef OTHERLIBDIR
+override FPCOPT+=$(addprefix -Fl,$(OTHERLIBDIR))
+endif
+ifdef OPT
+override FPCOPT+=$(OPT)
+endif
+ifdef FPCOPTDEF
+override FPCOPT+=$(addprefix -d,$(FPCOPTDEF))
+endif
+ifdef CFGFILE
+override FPCOPT+=@$(CFGFILE)
+endif
+ifdef USEENV
+override FPCEXTCMD:=$(FPCOPT)
+override FPCOPT:=!FPCEXTCMD
+export FPCEXTCMD
+endif
+override COMPILER:=$(FPC) $(FPCOPT)
+ifeq (,$(findstring -s ,$(COMPILER)))
+EXECPPAS=
+else
+ifeq ($(OS_SOURCE),$(OS_TARGET))
+EXECPPAS:=@$(PPAS)
+endif
+endif
+.PHONY: fpc_units
+ifdef TARGET_UNITS
+override ALLTARGET+=fpc_units
+override UNITPPUFILES=$(addsuffix $(PPUEXT),$(TARGET_UNITS))
+override IMPLICITUNITPPUFILES=$(addsuffix $(PPUEXT),$(TARGET_IMPLICITUNITS))
+override INSTALLPPUFILES+=$(UNITPPUFILES) $(IMPLICITUNITPPUFILES)
+override CLEANPPUFILES+=$(UNITPPUFILES) $(IMPLICITUNITPPUFILES)
+endif
+fpc_units: $(UNITPPUFILES)
+ifdef TARGET_RSTS
+override RSTFILES=$(addsuffix $(RSTEXT),$(TARGET_RSTS))
+override CLEANRSTFILES+=$(RSTFILES)
+endif
+.PHONY: fpc_examples
+ifdef TARGET_EXAMPLES
+HASEXAMPLES=1
+override EXAMPLESOURCEFILES:=$(wildcard $(addsuffix .pp,$(TARGET_EXAMPLES)) $(addsuffix .pas,$(TARGET_EXAMPLES)))
+override EXAMPLEFILES:=$(addsuffix $(EXEEXT),$(TARGET_EXAMPLES))
+override EXAMPLEOFILES:=$(addsuffix $(OEXT),$(TARGET_EXAMPLES)) $(addprefix $(STATICLIBPREFIX),$(addsuffix $(STATICLIBEXT),$(TARGET_EXAMPLES)))
+override CLEANEXEFILES+=$(EXAMPLEFILES) $(EXAMPLEOFILES)
+ifeq ($(OS_TARGET),os2)
+override CLEANEXEFILES+=$(addsuffix $(AOUTEXT),$(TARGET_EXAMPLES))
+endif
+endif
+ifdef TARGET_EXAMPLEDIRS
+HASEXAMPLES=1
+endif
+fpc_examples: all $(EXAMPLEFILES) $(addsuffix _all,$(TARGET_EXAMPLEDIRS))
+.PHONY: fpc_all fpc_smart fpc_debug fpc_release
+$(FPCMADE): $(ALLTARGET)
+	@$(ECHOREDIR) Compiled > $(FPCMADE)
+fpc_all: $(FPCMADE)
+fpc_smart:
+	$(MAKE) all LINKSMART=1 CREATESMART=1
+fpc_debug:
+	$(MAKE) all DEBUG=1
+fpc_release:
+	$(MAKE) all RELEASE=1
+.SUFFIXES: $(EXEEXT) $(PPUEXT) $(OEXT) .pas .pp .rc .res
+%$(PPUEXT): %.pp
+	$(COMPILER) $<
+	$(EXECPPAS)
+%$(PPUEXT): %.pas
+	$(COMPILER) $<
+	$(EXECPPAS)
+%$(EXEEXT): %.pp
+	$(COMPILER) $<
+	$(EXECPPAS)
+%$(EXEEXT): %.pas
+	$(COMPILER) $<
+	$(EXECPPAS)
+%.res: %.rc
+	windres -i $< -o $@
+vpath %.pp $(COMPILER_SOURCEDIR) $(COMPILER_INCLUDEDIR)
+vpath %.pas $(COMPILER_SOURCEDIR) $(COMPILER_INCLUDEDIR)
+vpath %$(PPUEXT) $(COMPILER_UNITTARGETDIR)
+.PHONY: fpc_install fpc_sourceinstall fpc_exampleinstall
+ifdef INSTALL_UNITS
+override INSTALLPPUFILES+=$(addsuffix $(PPUEXT),$(INSTALL_UNITS))
+endif
+ifdef INSTALL_BUILDUNIT
+override INSTALLPPUFILES:=$(filter-out $(INSTALL_BUILDUNIT),$(INSTALLPPUFILES))
+endif
+ifdef INSTALLPPUFILES
+override INSTALLPPULINKFILES:=$(subst $(PPUEXT),$(OEXT),$(INSTALLPPUFILES)) $(addprefix $(STATICLIBPREFIX),$(subst $(PPUEXT),$(STATICLIBEXT),$(INSTALLPPUFILES)))
+override INSTALLPPUFILES:=$(addprefix $(UNITTARGETDIRPREFIX),$(INSTALLPPUFILES))
+override INSTALLPPULINKFILES:=$(wildcard $(addprefix $(UNITTARGETDIRPREFIX),$(INSTALLPPULINKFILES)))
+override INSTALL_CREATEPACKAGEFPC=1
+endif
+ifdef INSTALLEXEFILES
+override INSTALLEXEFILES:=$(addprefix $(TARGETDIRPREFIX),$(INSTALLEXEFILES))
+endif
+fpc_install: all $(INSTALLTARGET)
+ifdef INSTALLEXEFILES
+	$(MKDIR) $(INSTALL_BINDIR)
+ifdef UPXPROG
+	-$(UPXPROG) $(INSTALLEXEFILES)
+endif
+	$(INSTALLEXE) $(INSTALLEXEFILES) $(INSTALL_BINDIR)
+endif
+ifdef INSTALL_CREATEPACKAGEFPC
+ifdef FPCMAKE
+ifdef PACKAGE_VERSION
+ifneq ($(wildcard Makefile.fpc),)
+	$(FPCMAKE) -p -T$(OS_TARGET) Makefile.fpc
+	$(MKDIR) $(INSTALL_UNITDIR)
+	$(INSTALL) Package.fpc $(INSTALL_UNITDIR)
+endif
+endif
+endif
+endif
+ifdef INSTALLPPUFILES
+	$(MKDIR) $(INSTALL_UNITDIR)
+	$(INSTALL) $(INSTALLPPUFILES) $(INSTALL_UNITDIR)
+ifneq ($(INSTALLPPULINKFILES),)
+	$(INSTALL) $(INSTALLPPULINKFILES) $(INSTALL_UNITDIR)
+endif
+ifneq ($(wildcard $(LIB_FULLNAME)),)
+	$(MKDIR) $(INSTALL_LIBDIR)
+	$(INSTALL) $(LIB_FULLNAME) $(INSTALL_LIBDIR)
+ifdef inUnix
+	ln -sf $(LIB_FULLNAME) $(INSTALL_LIBDIR)/$(LIB_NAME)
+endif
+endif
+endif
+ifdef INSTALL_FILES
+	$(MKDIR) $(INSTALL_DATADIR)
+	$(INSTALL) $(INSTALL_FILES) $(INSTALL_DATADIR)
+endif
+fpc_sourceinstall: distclean
+	$(MKDIR) $(INSTALL_SOURCEDIR)
+	$(COPYTREE) $(BASEDIR) $(INSTALL_SOURCEDIR)
+fpc_exampleinstall: $(addsuffix _distclean,$(TARGET_EXAMPLEDIRS))
+ifdef HASEXAMPLES
+	$(MKDIR) $(INSTALL_EXAMPLEDIR)
+endif
+ifdef EXAMPLESOURCEFILES
+	$(COPY) $(EXAMPLESOURCEFILES) $(INSTALL_EXAMPLEDIR)
+endif
+ifdef TARGET_EXAMPLEDIRS
+	$(COPYTREE) $(addsuffix /*,$(TARGET_EXAMPLEDIRS)) $(INSTALL_EXAMPLEDIR)
+endif
+.PHONY: fpc_distinstall
+fpc_distinstall: install exampleinstall
+.PHONY: fpc_zipinstall fpc_zipsourceinstall fpc_zipexampleinstall
+ifndef PACKDIR
+ifndef inUnix
+PACKDIR=$(BASEDIR)/../fpc-pack
+else
+PACKDIR=/tmp/fpc-pack
+endif
+endif
+ifndef ZIPNAME
+ifdef DIST_ZIPNAME
+ZIPNAME=$(DIST_ZIPNAME)
+else
+ZIPNAME=$(ZIPPREFIX)$(PACKAGE_NAME)$(ZIPSUFFIX)
+endif
+endif
+ifndef ZIPTARGET
+ifdef DIST_ZIPTARGET
+ZIPTARGET=DIST_ZIPTARGET
+else
+ZIPTARGET=install
+endif
+endif
+ifndef USEZIP
+ifdef inUnix
+USETAR=1
+endif
+endif
+ifndef inUnix
+USEZIPWRAPPER=1
+endif
+ifdef USEZIPWRAPPER
+ZIPPATHSEP=$(PATHSEP)
+ZIPWRAPPER=$(subst /,$(PATHSEP),$(DIST_DESTDIR)/fpczip$(BATCHEXT))
+else
+ZIPPATHSEP=/
+endif
+ZIPCMD_CDPACK:=cd $(subst /,$(ZIPPATHSEP),$(PACKDIR))
+ZIPCMD_CDBASE:=cd $(subst /,$(ZIPPATHSEP),$(BASEDIR))
+ifdef USETAR
+ZIPDESTFILE:=$(DIST_DESTDIR)/$(ZIPNAME)$(TAREXT)
+ZIPCMD_ZIP:=$(TARPROG) cf$(TAROPT) $(ZIPDESTFILE) *
+else
+ZIPDESTFILE:=$(DIST_DESTDIR)/$(ZIPNAME)$(ZIPEXT)
+ZIPCMD_ZIP:=$(subst /,$(ZIPPATHSEP),$(ZIPPROG)) -Dr $(ZIPOPT) $(ZIPDESTFILE) *
+endif
+fpc_zipinstall:
+	$(MAKE) $(ZIPTARGET) INSTALL_PREFIX=$(PACKDIR) ZIPINSTALL=1
+	$(MKDIR) $(DIST_DESTDIR)
+	$(DEL) $(ZIPDESTFILE)
+ifdef USEZIPWRAPPER
+ifneq ($(ECHOREDIR),echo)
+	$(ECHOREDIR) -e "$(subst \,\\,$(ZIPCMD_CDPACK))" > $(ZIPWRAPPER)
+	$(ECHOREDIR) -e "$(subst \,\\,$(ZIPCMD_ZIP))" >> $(ZIPWRAPPER)
+	$(ECHOREDIR) -e "$(subst \,\\,$(ZIPCMD_CDBASE))" >> $(ZIPWRAPPER)
+else
+	echo $(ZIPCMD_CDPACK) > $(ZIPWRAPPER)
+	echo $(ZIPCMD_ZIP) >> $(ZIPWRAPPER)
+	echo $(ZIPCMD_CDBASE) >> $(ZIPWRAPPER)
+endif
+ifdef inUnix
+	/bin/sh $(ZIPWRAPPER)
+else
+	$(ZIPWRAPPER)
+endif
+	$(DEL) $(ZIPWRAPPER)
+else
+	$(ZIPCMD_CDPACK) ; $(ZIPCMD_ZIP) ; $(ZIPCMD_CDBASE)
+endif
+	$(DELTREE) $(PACKDIR)
+fpc_zipsourceinstall:
+	$(MAKE) fpc_zipinstall ZIPTARGET=sourceinstall ZIPSUFFIX=src
+fpc_zipexampleinstall:
+ifdef HASEXAMPLES
+	$(MAKE) fpc_zipinstall ZIPTARGET=exampleinstall ZIPSUFFIX=exm
+endif
+fpc_zipdistinstall:
+	$(MAKE) fpc_zipinstall ZIPTARGET=distinstall
+.PHONY: fpc_clean fpc_cleanall fpc_distclean
+ifdef EXEFILES
+override CLEANEXEFILES:=$(addprefix $(TARGETDIRPREFIX),$(CLEANEXEFILES))
+endif
+ifdef CLEAN_UNITS
+override CLEANPPUFILES+=$(addsuffix $(PPUEXT),$(CLEAN_UNITS))
+endif
+ifdef CLEANPPUFILES
+override CLEANPPULINKFILES:=$(subst $(PPUEXT),$(OEXT),$(CLEANPPUFILES)) $(addprefix $(STATICLIBPREFIX),$(subst $(PPUEXT),$(STATICLIBEXT),$(CLEANPPUFILES)))
+override CLEANPPUFILES:=$(addprefix $(UNITTARGETDIRPREFIX),$(CLEANPPUFILES))
+override CLEANPPULINKFILES:=$(wildcard $(addprefix $(UNITTARGETDIRPREFIX),$(CLEANPPULINKFILES)))
+endif
+fpc_clean: $(CLEANTARGET)
+ifdef CLEANEXEFILES
+	-$(DEL) $(CLEANEXEFILES)
+endif
+ifdef CLEANPPUFILES
+	-$(DEL) $(CLEANPPUFILES)
+endif
+ifneq ($(CLEANPPULINKFILES),)
+	-$(DEL) $(CLEANPPULINKFILES)
+endif
+ifdef CLEANRSTFILES
+	-$(DEL) $(addprefix $(UNITTARGETDIRPREFIX),$(CLEANRSTFILES))
+endif
+ifdef CLEAN_FILES
+	-$(DEL) $(CLEAN_FILES)
+endif
+ifdef LIB_NAME
+	-$(DEL) $(LIB_NAME) $(LIB_FULLNAME)
+endif
+	-$(DEL) $(FPCMADE) Package.fpc $(PPAS) script.res link.res $(FPCEXTFILE) $(REDIRFILE)
+fpc_distclean: clean
+ifdef COMPILER_UNITTARGETDIR
+TARGETDIRCLEAN=fpc_clean
+endif
+fpc_cleanall: $(CLEANTARGET) $(TARGETDIRCLEAN)
+ifdef CLEANEXEFILES
+	-$(DEL) $(CLEANEXEFILES)
+endif
+	-$(DEL) *$(OEXT) *$(PPUEXT) *$(RSTEXT) *$(ASMEXT) *$(STATICLIBEXT) *$(SHAREDLIBEXT) *$(PPLEXT)
+	-$(DELTREE) *$(SMARTEXT)
+	-$(DEL) $(FPCMADE) Package.fpc $(PPAS) script.res link.res $(FPCEXTFILE) $(REDIRFILE)
+ifdef AOUTEXT
+	-$(DEL) *$(AOUTEXT)
+endif
+.PHONY: fpc_baseinfo
+override INFORULES+=fpc_baseinfo
+fpc_baseinfo:
+	@$(ECHO)
+	@$(ECHO)  == Package info ==
+	@$(ECHO)  Package Name..... $(PACKAGE_NAME)
+	@$(ECHO)  Package Version.. $(PACKAGE_VERSION)
+	@$(ECHO)
+	@$(ECHO)  == Configuration info ==
+	@$(ECHO)
+	@$(ECHO)  FPC.......... $(FPC)
+	@$(ECHO)  FPC Version.. $(FPC_VERSION)
+	@$(ECHO)  Source CPU... $(CPU_SOURCE)
+	@$(ECHO)  Target CPU... $(CPU_TARGET)
+	@$(ECHO)  Source OS.... $(OS_SOURCE)
+	@$(ECHO)  Target OS.... $(OS_TARGET)
+	@$(ECHO)  Full Target.. $(FULL_SOURCE)
+	@$(ECHO)  Full Source.. $(FULL_TARGET)
+	@$(ECHO)
+	@$(ECHO)  == Directory info ==
+	@$(ECHO)
+	@$(ECHO)  Required pkgs... $(REQUIRE_PACKAGES)
+	@$(ECHO)
+	@$(ECHO)  Basedir......... $(BASEDIR)
+	@$(ECHO)  FPCDir.......... $(FPCDIR)
+	@$(ECHO)  CrossBinDir..... $(CROSSBINDIR)
+	@$(ECHO)  UnitsDir........ $(UNITSDIR)
+	@$(ECHO)  PackagesDir..... $(PACKAGESDIR)
+	@$(ECHO)
+	@$(ECHO)  GCC library..... $(GCCLIBDIR)
+	@$(ECHO)  Other library... $(OTHERLIBDIR)
+	@$(ECHO)
+	@$(ECHO)  == Tools info ==
+	@$(ECHO)
+	@$(ECHO)  As........ $(AS)
+	@$(ECHO)  Ld........ $(LD)
+	@$(ECHO)  Ar........ $(AR)
+	@$(ECHO)  Rc........ $(RC)
+	@$(ECHO)
+	@$(ECHO)  Mv........ $(MVPROG)
+	@$(ECHO)  Cp........ $(CPPROG)
+	@$(ECHO)  Rm........ $(RMPROG)
+	@$(ECHO)  GInstall.. $(GINSTALL)
+	@$(ECHO)  Echo...... $(ECHO)
+	@$(ECHO)  Date...... $(DATE)
+	@$(ECHO)  FPCMake... $(FPCMAKE)
+	@$(ECHO)  PPUMove... $(PPUMOVE)
+	@$(ECHO)  Upx....... $(UPXPROG)
+	@$(ECHO)  Zip....... $(ZIPPROG)
+	@$(ECHO)
+	@$(ECHO)  == Object info ==
+	@$(ECHO)
+	@$(ECHO)  Target Loaders........ $(TARGET_LOADERS)
+	@$(ECHO)  Target Units.......... $(TARGET_UNITS)
+	@$(ECHO)  Target Implicit Units. $(TARGET_IMPLICITUNITS)
+	@$(ECHO)  Target Programs....... $(TARGET_PROGRAMS)
+	@$(ECHO)  Target Dirs........... $(TARGET_DIRS)
+	@$(ECHO)  Target Examples....... $(TARGET_EXAMPLES)
+	@$(ECHO)  Target ExampleDirs.... $(TARGET_EXAMPLEDIRS)
+	@$(ECHO)
+	@$(ECHO)  Clean Units......... $(CLEAN_UNITS)
+	@$(ECHO)  Clean Files......... $(CLEAN_FILES)
+	@$(ECHO)
+	@$(ECHO)  Install Units....... $(INSTALL_UNITS)
+	@$(ECHO)  Install Files....... $(INSTALL_FILES)
+	@$(ECHO)
+	@$(ECHO)  == Install info ==
+	@$(ECHO)
+	@$(ECHO)  DateStr.............. $(DATESTR)
+	@$(ECHO)  ZipPrefix............ $(ZIPPREFIX)
+	@$(ECHO)  ZipSuffix............ $(ZIPSUFFIX)
+	@$(ECHO)  Install FPC Package.. $(INSTALL_FPCPACKAGE)
+	@$(ECHO)
+	@$(ECHO)  Install base dir..... $(INSTALL_BASEDIR)
+	@$(ECHO)  Install binary dir... $(INSTALL_BINDIR)
+	@$(ECHO)  Install library dir.. $(INSTALL_LIBDIR)
+	@$(ECHO)  Install units dir.... $(INSTALL_UNITDIR)
+	@$(ECHO)  Install source dir... $(INSTALL_SOURCEDIR)
+	@$(ECHO)  Install doc dir...... $(INSTALL_DOCDIR)
+	@$(ECHO)  Install example dir.. $(INSTALL_EXAMPLEDIR)
+	@$(ECHO)  Install data dir..... $(INSTALL_DATADIR)
+	@$(ECHO)
+	@$(ECHO)  Dist destination dir. $(DIST_DESTDIR)
+	@$(ECHO)  Dist zip name........ $(DIST_ZIPNAME)
+	@$(ECHO)
+.PHONY: fpc_info
+fpc_info: $(INFORULES)
+.PHONY: fpc_makefile fpc_makefiles fpc_makefile_sub1 fpc_makefile_sub2 \
+	fpc_makefile_dirs
+fpc_makefile:
+	$(FPCMAKE) -w -T$(OS_TARGET) Makefile.fpc
+fpc_makefile_sub1:
+ifdef TARGET_DIRS
+	$(FPCMAKE) -w -T$(OS_TARGET) $(addsuffix /Makefile.fpc,$(TARGET_DIRS))
+endif
+ifdef TARGET_EXAMPLEDIRS
+	$(FPCMAKE) -w -T$(OS_TARGET) $(addsuffix /Makefile.fpc,$(TARGET_EXAMPLEDIRS))
+endif
+fpc_makefile_sub2: $(addsuffix _makefile_dirs,$(TARGET_DIRS) $(TARGET_EXAMPLEDIRS))
+fpc_makefile_dirs: fpc_makefile_sub1 fpc_makefile_sub2
+fpc_makefiles: fpc_makefile fpc_makefile_dirs
+all: fpc_all
+debug: fpc_debug
+smart: fpc_smart
+release: fpc_release
+examples: fpc_examples
+shared:
+install: fpc_install
+sourceinstall: fpc_sourceinstall
+exampleinstall: fpc_exampleinstall
+distinstall: fpc_distinstall
+zipinstall: fpc_zipinstall
+zipsourceinstall: fpc_zipsourceinstall
+zipexampleinstall: fpc_zipexampleinstall
+zipdistinstall: fpc_zipdistinstall
+clean: fpc_clean
+distclean: fpc_distclean
+cleanall: fpc_cleanall
+info: fpc_info
+makefiles: fpc_makefiles
+.PHONY: all debug smart release examples shared install sourceinstall exampleinstall distinstall zipinstall zipsourceinstall zipexampleinstall zipdistinstall clean distclean cleanall info makefiles
+ifneq ($(wildcard fpcmake.loc),)
+include fpcmake.loc
+endif

+ 20 - 0
packages/base/ibase/Makefile.fpc

@@ -0,0 +1,20 @@
+#
+#   Makefile.fpc for InterBase bindings
+#
+
+[package]
+name=ibase
+version=1.0.6
+
+[target]
+units=ibase40 ibase60
+examples=testib40 testib60
+
+[require]
+libc=y
+
+[install]
+fpcpackage=y
+
+[default]
+fpcdir=../../..

+ 43 - 0
packages/base/ibase/README

@@ -0,0 +1,43 @@
+This is the README file for the INTERBASE package of FPC
+
+How to compile
+--------------
+
+You can compile by hand, or use the makefile. The makefile uses the
+makefile.fpc that is distributed by the FPC team.
+
+1) Using the makefile.
+   Edit the makefile: 
+     set the DEFAULTFPCDIR
+     if libgds is not in /usr/lib, set GDSLIBDIR
+   type 'make'. It should all compiler
+
+2) By hand:
+   simply type:
+   ppc386 -S2 ibase60
+   (or ibase40 if you have the older version)
+
+   If your libgds.so file is not in /usr/lib, you may need to add
+   -Fl/path/to/libgds
+
+Using the testprogram
+---------------------
+
+The mkdb script (mkdb.pas batch file) creates a database.
+default testdb.gdb is assumed. You can override that by 
+specifying an alternate database as an option.
+
+The testib program connects to the testdatabase. You must edit
+the testib.pp file and set the database, password and username.
+After editing, compile the program. 
+Run it and it will display the contents of the database.
+
+Enjoy !
+
+Michael.
+
+   
+
+   
+
+

+ 1856 - 0
packages/base/ibase/ibase40.pp

@@ -0,0 +1,1856 @@
+{
+  $Id$
+}
+unit ibase40;
+
+interface
+
+const
+  {$ifdef linux}
+  LibName = 'gds';
+  {$linklib c}
+  {$else}
+  LibName = 'gds32.dll';
+  {$endif}
+
+
+{ C Compatibility types }
+
+type
+  {  Unsigned types }
+
+  UChar                = Byte;
+  UShort               = Word;
+  UInt                 = DWord;
+  ULong                = DWord;
+
+  { Signed types }
+
+  Int                  = LongInt;
+  Long                 = LongInt;
+  Short                = Integer;
+  Float                = Single;
+
+  { Pointers to basic types }
+
+  PInt                 = ^Int;
+  PShort               = ^Short;
+  PUShort              = ^UShort;
+  PLong                = ^Long;
+  PULong               = ^ULong;
+  PFloat               = ^Float;
+  PUChar               = ^UChar;
+  PVoid                = ^Pointer;
+
+  { Interbase redefinitions }
+
+  ISC_LONG             = Long;
+  UISC_LONG            = ULong;
+  ISC_STATUS           = Long;
+  UISC_STATUS          = ULong;
+  Void                 = Pointer;
+  PISC_LONG            = ^ISC_LONG;
+  PUISC_LONG           = ^UISC_LONG;
+  PISC_STATUS          = ^ISC_STATUS;
+  PPISC_STATUS         = ^PISC_STATUS;
+  PUISC_STATUS         = ^UISC_STATUS;
+
+  { C Date/Time Structure }
+  TCTimeStructure = record
+    tm_sec,
+    tm_min,
+    tm_hour,
+    tm_mday,
+    tm_mon,
+    tm_year,
+    tm_wday,
+    tm_yday,
+    tm_isdst : Longint;
+  end;
+  PCTimeStructure = ^TCTimeStructure;
+  TM              = TCTimeStructure;
+  PTM             = ^TM;
+
+  TISC_VARYING = record
+    strlen: Short;
+    str: array[0..0] of Char;
+  end;
+
+  TISC_BlobGetSegment = function(BlobHandle: PInt; Buffer: PChar; BufferSize: Long; var ResultLength: Long): Short; cdecl;
+  TISC_BlobPutSegment = procedure(BlobHandle: PInt; Buffer: PChar; BufferLength: Short); cdecl;
+
+  TBlob = record
+    GetSegment         : TISC_BlobGetSegment;
+    BlobHandle         : PInt;
+    SegmentCount       : Long;
+    MaxSegmentLength   : Long;
+    TotalSize          : Long;
+    PutSegment         : TISC_BlobPutSegment;
+  end;
+  PBlob = ^TBlob;
+
+Const
+  {
+    Huge amount of constants.
+    Look for TYPESTART to get to types,
+    Look For FUNCSTART to get to functions and procedures
+  }
+
+  ISC_TRUE = 1;
+  ISC_FALSE = 0;
+  DSQL_close = 1;
+  DSQL_drop = 2;
+
+  sec_uid_spec = $01;
+  sec_gid_spec = $02;
+  sec_server_spec = $04;
+  sec_password_spec = $08;
+  sec_group_name_spec = $10;
+  sec_first_name_spec = $20;
+  sec_middle_name_spec = $40;
+  sec_last_name_spec = $80;
+  sec_dba_user_name_spec = $100;
+  sec_dba_password_spec = $200;
+  sec_protocol_tcpip = 1;
+  sec_protocol_netbeui = 2;
+  sec_protocol_spx = 3;
+  sec_protocol_local = 4;
+
+  isc_blob_filter_open = 0;
+  isc_blob_filter_get_segment = 1;
+  isc_blob_filter_close = 2;
+  isc_blob_filter_create = 3;
+  isc_blob_filter_put_segment = 4;
+  isc_blob_filter_alloc = 5;
+  isc_blob_filter_free = 6;
+  isc_blob_filter_seek = 7;
+
+  blr_text = 14;
+  blr_text2 = 15;
+  blr_short = 7;
+  blr_long = 8;
+  blr_quad = 9;
+  blr_float = 10;
+  blr_double = 27;
+  blr_d_float = 11;
+  blr_date = 35;
+  blr_varying = 37;
+  blr_varying2 = 38;
+  blr_blob = 261;
+  blr_cstring = 40;
+  blr_cstring2 = 41;
+  blr_blob_id = 45;
+
+  blr_inner = 0;
+  blr_left = 1;
+  blr_right = 2;
+  blr_full = 3;
+
+  blr_gds_code = 0;
+  blr_sql_code = 1;
+  blr_exception = 2;
+  blr_trigger_code = 3;
+  blr_default_code = 4;
+
+  blr_version4 = 4;
+  blr_eoc = 76;
+  blr_end = -1;
+
+  blr_assignment = 1;
+  blr_begin = 2;
+  blr_dcl_variable = 3;
+  blr_message = 4;
+  blr_erase = 5;
+  blr_fetch = 6;
+  blr_for = 7;
+  blr_if = 8;
+  blr_loop = 9;
+  blr_modify = 10;
+  blr_handler = 11;
+  blr_receive = 12;
+  blr_select = 13;
+  blr_send = 14;
+  blr_store = 15;
+  blr_label = 17;
+  blr_leave = 18;
+  blr_store2 = 19;
+  blr_post = 20;
+
+  blr_literal = 21;
+  blr_dbkey = 22;
+  blr_field = 23;
+  blr_fid = 24;
+  blr_parameter = 25;
+  blr_variable = 26;
+  blr_average = 27;
+  blr_count = 28;
+  blr_maximum = 29;
+  blr_minimum = 30;
+  blr_total = 31;
+  blr_add = 34;
+  blr_subtract = 35;
+  blr_multiply = 36;
+  blr_divide = 37;
+  blr_negate = 38;
+  blr_concatenate = 39;
+  blr_substring = 40;
+  blr_parameter2 = 41;
+  blr_from = 42;
+  blr_via = 43;
+  blr_user_name = 44;
+  blr_null = 45;
+
+  blr_eql = 47;
+  blr_neq = 48;
+  blr_gtr = 49;
+  blr_geq = 50;
+  blr_lss = 51;
+  blr_leq = 52;
+  blr_containing = 53;
+  blr_matching = 54;
+  blr_starting = 55;
+  blr_between = 56;
+  blr_or = 57;
+  blr_and = 58;
+  blr_not = 59;
+  blr_any = 60;
+  blr_missing = 61;
+  blr_unique = 62;
+  blr_like = 63;
+
+  blr_stream = 65;
+  blr_set_index = 66;
+  blr_rse = 67;
+  blr_first = 68;
+  blr_project = 69;
+  blr_sort = 70;
+  blr_boolean = 71;
+  blr_ascending = 72;
+  blr_descending = 73;
+  blr_relation = 74;
+  blr_rid = 75;
+  blr_union = 76;
+  blr_map = 77;
+  blr_group_by = 78;
+  blr_aggregate = 79;
+  blr_join_type = 80;
+
+  blr_agg_count = 83;
+  blr_agg_max = 84;
+  blr_agg_min = 85;
+  blr_agg_total = 86;
+  blr_agg_average = 87;
+  blr_parameter3 = 88;
+  blr_run_count = 118;
+  blr_run_max = 89;
+  blr_run_min = 90;
+  blr_run_total = 91;
+  blr_run_average = 92;
+  blr_agg_count2 = 93;
+  blr_agg_count_distinct = 94;
+  blr_agg_total_distinct = 95;
+  blr_agg_average_distinct = 96;
+
+  blr_function = 100;
+  blr_gen_id = 101;
+  blr_prot_mask = 102;
+  blr_upcase = 103;
+  blr_lock_state = 104;
+  blr_value_if = 105;
+  blr_matching2 = 106;
+  blr_index = 107;
+  blr_ansi_like = 108;
+  blr_bookmark = 109;
+  blr_crack = 110;
+  blr_force_crack = 111;
+  blr_seek = 112;
+  blr_find = 113;
+
+  blr_continue = 0;
+  blr_forward = 1;
+  blr_backward = 2;
+  blr_bof_forward = 3;
+  blr_eof_backward = 4;
+
+  blr_lock_relation = 114;
+  blr_lock_record = 115;
+  blr_set_bookmark = 116;
+  blr_get_bookmark = 117;
+  blr_rs_stream = 119;
+  blr_exec_proc = 120;
+  blr_begin_range = 121;
+  blr_end_range = 122;
+  blr_delete_range = 123;
+  blr_procedure = 124;
+  blr_pid = 125;
+  blr_exec_pid = 126;
+  blr_singular = 127;
+  blr_abort = 128;
+  blr_block = 129;
+  blr_error_handler = 130;
+  blr_cast = 131;
+  blr_release_lock = 132;
+  blr_release_locks = 133;
+  blr_start_savepoint = 134;
+  blr_end_savepoint = 135;
+  blr_find_dbkey = 136;
+  blr_range_relation = 137;
+  blr_delete_ranges = 138;
+
+  blr_plan = 139;
+  blr_merge = 140;
+  blr_join = 141;
+  blr_sequential = 142;
+  blr_navigational = 143;
+  blr_indices = 144;
+  blr_retrieve = 145;
+
+  blr_relation2 = 146;
+  blr_rid2 = 147;
+  blr_reset_stream = 148;
+  blr_release_bookmark = 149;
+  blr_set_generator = 150;
+  blr_ansi_any = 151;
+  blr_exists = 152;
+  blr_cardinality = 153;
+
+  blr_record_version = 154;
+  blr_stall = 155;
+  blr_seek_no_warn = 156;
+  blr_find_dbkey_version = 157;
+  blr_ansi_all = 158;
+
+  isc_dpb_version1 = 1;
+  isc_dpb_cdd_pathname = 1;
+  isc_dpb_allocation = 2;
+  isc_dpb_journal = 3;
+  isc_dpb_page_size = 4;
+  isc_dpb_num_buffers = 5;
+  isc_dpb_buffer_length = 6;
+  isc_dpb_debug = 7;
+  isc_dpb_garbage_collect = 8;
+  isc_dpb_verify = 9;
+  isc_dpb_sweep = 10;
+  isc_dpb_enable_journal = 11;
+  isc_dpb_disable_journal = 12;
+  isc_dpb_dbkey_scope = 13;
+  isc_dpb_number_of_users = 14;
+  isc_dpb_trace = 15;
+  isc_dpb_no_garbage_collect = 16;
+  isc_dpb_damaged = 17;
+  isc_dpb_license = 18;
+  isc_dpb_sys_user_name = 19;
+  isc_dpb_encrypt_key = 20;
+  isc_dpb_activate_shadow = 21;
+  isc_dpb_sweep_interval = 22;
+  isc_dpb_delete_shadow = 23;
+  isc_dpb_force_write = 24;
+  isc_dpb_begin_log = 25;
+  isc_dpb_quit_log = 26;
+  isc_dpb_no_reserve = 27;
+  isc_dpb_user_name = 28;
+  isc_dpb_password = 29;
+  isc_dpb_password_enc = 30;
+  isc_dpb_sys_user_name_enc = 31;
+  isc_dpb_interp = 32;
+  isc_dpb_online_dump = 33;
+  isc_dpb_old_file_size = 34;
+  isc_dpb_old_num_files = 35;
+  isc_dpb_old_file = 36;
+  isc_dpb_old_start_page = 37;
+  isc_dpb_old_start_seqno = 38;
+  isc_dpb_old_start_file = 39;
+  isc_dpb_drop_walfile = 40;
+  isc_dpb_old_dump_id = 41;
+  isc_dpb_wal_backup_dir = 42;
+  isc_dpb_wal_chkptlen = 43;
+  isc_dpb_wal_numbufs = 44;
+  isc_dpb_wal_bufsize = 45;
+  isc_dpb_wal_grp_cmt_wait = 46;
+  isc_dpb_lc_messages = 47;
+  isc_dpb_lc_ctype = 48;
+  isc_dpb_cache_manager = 49;
+  isc_dpb_shutdown = 50;
+  isc_dpb_online = 51;
+  isc_dpb_shutdown_delay = 52;
+  isc_dpb_reserved = 53;
+  isc_dpb_overwrite = 54;
+  isc_dpb_sec_attach = 55;
+  isc_dpb_disable_wal = 56;
+  isc_dpb_connect_timeout = 57;
+  isc_dpb_dummy_packet_interval = 58;
+  isc_dpb_gbak_attach = 59;
+  isc_dpb_sql_role_name = 60;
+  isc_dpb_set_page_buffers = 61;
+  isc_dpb_working_directory = 62;
+  isc_dpb_last_dpb_constant = isc_dpb_working_directory;
+
+
+  isc_dpb_pages = 1;
+  isc_dpb_records = 2;
+  isc_dpb_indices = 4;
+  isc_dpb_transactions = 8;
+  isc_dpb_no_update = 16;
+  isc_dpb_repair = 32;
+  isc_dpb_ignore = 64;
+
+  isc_dpb_shut_cache = 1;
+  isc_dpb_shut_attachment = 2;
+  isc_dpb_shut_transaction = 4;
+  isc_dpb_shut_force = 8;
+
+  RDB_system = 1;
+  RDB_id_assigned = 2;
+
+
+  isc_tpb_version1 = 1;
+  isc_tpb_version3 = 3;
+  isc_tpb_consistency = 1;
+  isc_tpb_concurrency = 2;
+  isc_tpb_shared = 3;
+  isc_tpb_protected = 4;
+  isc_tpb_exclusive = 5;
+  isc_tpb_wait = 6;
+  isc_tpb_nowait = 7;
+  isc_tpb_read = 8;
+  isc_tpb_write = 9;
+  isc_tpb_lock_read = 10;
+  isc_tpb_lock_write = 11;
+  isc_tpb_verb_time = 12;
+  isc_tpb_commit_time = 13;
+  isc_tpb_ignore_limbo = 14;
+  isc_tpb_read_committed = 15;
+  isc_tpb_autocommit = 16;
+  isc_tpb_rec_version = 17;
+  isc_tpb_no_rec_version = 18;
+  isc_tpb_restart_requests = 19;
+  isc_tpb_no_auto_undo = 20;
+  isc_tpb_last_tpb_constant = isc_tpb_no_auto_undo;
+
+
+  isc_bpb_version1 = 1;
+  isc_bpb_source_type = 1;
+  isc_bpb_target_type = 2;
+  isc_bpb_type = 3;
+  isc_bpb_source_interp = 4;
+  isc_bpb_target_interp = 5;
+  isc_bpb_filter_parameter = 6;
+
+  isc_bpb_type_segmented = 0;
+  isc_bpb_type_stream = 1;
+
+
+  isc_spb_version1 = 1;
+  isc_spb_user_name = 2;
+  isc_spb_sys_user_name = 3;
+  isc_spb_sys_user_name_enc = 4;
+  isc_spb_password = 5;
+  isc_spb_password_enc = 6;
+  isc_spb_command_line = 7;
+  isc_spb_connect_timeout = isc_dpb_connect_timeout;
+  isc_spb_dummy_packet_interval = isc_dpb_dummy_packet_interval;
+  isc_spb_sql_role_name = isc_dpb_sql_role_name;
+
+
+
+  isc_info_end = 1;
+  isc_info_truncated = 2;
+  isc_info_error = 3;
+
+  isc_info_db_id = 4;
+  isc_info_reads = 5;
+  isc_info_writes = 6;
+  isc_info_fetches = 7;
+  isc_info_marks = 8;
+  isc_info_implementation = 11;
+  isc_info_version = 12;
+  isc_info_base_level = 13;
+  isc_info_page_size = 14;
+  isc_info_num_buffers = 15;
+  isc_info_limbo = 16;
+  isc_info_current_memory = 17;
+  isc_info_max_memory = 18;
+  isc_info_window_turns = 19;
+  isc_info_license = 20;
+  isc_info_allocation = 21;
+  isc_info_attachment_id = 22;
+  isc_info_read_seq_count = 23;
+  isc_info_read_idx_count = 24;
+  isc_info_insert_count = 25;
+  isc_info_update_count = 26;
+  isc_info_delete_count = 27;
+  isc_info_backout_count = 28;
+  isc_info_purge_count = 29;
+  isc_info_expunge_count = 30;
+  isc_info_sweep_interval = 31;
+  isc_info_ods_version = 32;
+  isc_info_ods_minor_version = 33;
+  isc_info_no_reserve = 34;
+  isc_info_logfile = 35;
+  isc_info_cur_logfile_name = 36;
+  isc_info_cur_log_part_offset = 37;
+  isc_info_num_wal_buffers = 38;
+  isc_info_wal_buffer_size = 39;
+  isc_info_wal_ckpt_length = 40;
+  isc_info_wal_cur_ckpt_interval = 41;
+  isc_info_wal_prv_ckpt_fname = 42;
+  isc_info_wal_prv_ckpt_poffset = 43;
+  isc_info_wal_recv_ckpt_fname = 44;
+  isc_info_wal_recv_ckpt_poffset = 45;
+  isc_info_wal_grpc_wait_usecs = 47;
+  isc_info_wal_num_io = 48;
+  isc_info_wal_avg_io_size = 49;
+  isc_info_wal_num_commits = 50;
+  isc_info_wal_avg_grpc_size = 51;
+  isc_info_forced_writes = 52;
+  isc_info_user_names = 53;
+  isc_info_page_errors = 54;
+  isc_info_record_errors = 55;
+  isc_info_bpage_errors = 56;
+  isc_info_dpage_errors = 57;
+  isc_info_ipage_errors = 58;
+  isc_info_ppage_errors = 59;
+  isc_info_tpage_errors = 60;
+  isc_info_set_page_buffers = 61;
+
+  isc_info_db_impl_rdb_vms = 1;
+  isc_info_db_impl_rdb_eln = 2;
+  isc_info_db_impl_rdb_eln_dev = 3;
+  isc_info_db_impl_rdb_vms_y = 4;
+  isc_info_db_impl_rdb_eln_y = 5;
+  isc_info_db_impl_jri = 6;
+  isc_info_db_impl_jsv = 7;
+  isc_info_db_impl_isc_a = 25;
+  isc_info_db_impl_isc_u = 26;
+  isc_info_db_impl_isc_v = 27;
+  isc_info_db_impl_isc_s = 28;
+  isc_info_db_impl_isc_apl_68K = 25;
+  isc_info_db_impl_isc_vax_ultr = 26;
+  isc_info_db_impl_isc_vms = 27;
+  isc_info_db_impl_isc_sun_68k = 28;
+  isc_info_db_impl_isc_os2 = 29;
+  isc_info_db_impl_isc_sun4 = 30;
+  isc_info_db_impl_isc_hp_ux = 31;
+  isc_info_db_impl_isc_sun_386i = 32;
+  isc_info_db_impl_isc_vms_orcl = 33;
+  isc_info_db_impl_isc_mac_aux = 34;
+  isc_info_db_impl_isc_rt_aix = 35;
+  isc_info_db_impl_isc_mips_ult = 36;
+  isc_info_db_impl_isc_xenix = 37;
+  isc_info_db_impl_isc_dg = 38;
+  isc_info_db_impl_isc_hp_mpexl = 39;
+  isc_info_db_impl_isc_hp_ux68K = 40;
+  isc_info_db_impl_isc_sgi = 41;
+  isc_info_db_impl_isc_sco_unix = 42;
+  isc_info_db_impl_isc_cray = 43;
+  isc_info_db_impl_isc_imp = 44;
+  isc_info_db_impl_isc_delta = 45;
+  isc_info_db_impl_isc_next = 46;
+  isc_info_db_impl_isc_dos = 47;
+  isc_info_db_impl_isc_winnt = 48;
+  isc_info_db_impl_isc_epson = 49;
+
+  isc_info_db_class_access = 1;
+  isc_info_db_class_y_valve = 2;
+  isc_info_db_class_rem_int = 3;
+  isc_info_db_class_rem_srvr = 4;
+  isc_info_db_class_pipe_int = 7;
+  isc_info_db_class_pipe_srvr = 8;
+  isc_info_db_class_sam_int = 9;
+  isc_info_db_class_sam_srvr = 10;
+  isc_info_db_class_gateway = 11;
+  isc_info_db_class_cache = 12;
+
+  isc_info_number_messages = 4;
+  isc_info_max_message = 5;
+  isc_info_max_send = 6;
+  isc_info_max_receive = 7;
+  isc_info_state = 8;
+  isc_info_message_number = 9;
+  isc_info_message_size = 10;
+  isc_info_request_cost = 11;
+  isc_info_access_path = 12;
+  isc_info_req_select_count = 13;
+  isc_info_req_insert_count = 14;
+  isc_info_req_update_count = 15;
+  isc_info_req_delete_count = 16;
+
+
+  isc_info_rsb_end = 0;
+  isc_info_rsb_begin = 1;
+  isc_info_rsb_type = 2;
+  isc_info_rsb_relation = 3;
+  isc_info_rsb_plan = 4;
+
+  isc_info_rsb_unknown = 1;
+  isc_info_rsb_indexed = 2;
+  isc_info_rsb_navigate = 3;
+  isc_info_rsb_sequential = 4;
+  isc_info_rsb_cross = 5;
+  isc_info_rsb_sort = 6;
+  isc_info_rsb_first = 7;
+  isc_info_rsb_boolean = 8;
+  isc_info_rsb_union = 9;
+  isc_info_rsb_aggregate = 10;
+  isc_info_rsb_merge = 11;
+  isc_info_rsb_ext_sequential = 12;
+  isc_info_rsb_ext_indexed = 13;
+  isc_info_rsb_ext_dbkey = 14;
+  isc_info_rsb_left_cross = 15;
+  isc_info_rsb_select = 16;
+  isc_info_rsb_sql_join = 17;
+  isc_info_rsb_simulate = 18;
+  isc_info_rsb_sim_cross = 19;
+  isc_info_rsb_once = 20;
+  isc_info_rsb_procedure = 21;
+
+  isc_info_rsb_and = 1;
+  isc_info_rsb_or = 2;
+  isc_info_rsb_dbkey = 3;
+  isc_info_rsb_index = 4;
+
+  isc_info_req_active = 2;
+  isc_info_req_inactive = 3;
+  isc_info_req_send = 4;
+  isc_info_req_receive = 5;
+  isc_info_req_select = 6;
+  isc_info_req_sql_stall = 7;
+
+  isc_info_blob_num_segments = 4;
+  isc_info_blob_max_segment = 5;
+  isc_info_blob_total_length = 6;
+  isc_info_blob_type = 7;
+
+  isc_info_tra_id = 4;
+
+  isc_info_svc_version = 4;
+  isc_info_svc_message = 5;
+  isc_info_svc_total_length = 6;
+  isc_info_svc_response = 7;
+  isc_info_svc_response_more = 8;
+  isc_info_svc_line = 9;
+  isc_info_svc_to_eof = 10;
+  isc_info_svc_timeout = 11;
+  isc_info_svc_server_version = 12;
+  isc_info_svc_implementation = 13;
+  isc_info_svc_capabilities = 14;
+  isc_info_svc_user_dbpath = 15;
+  isc_info_svc_svr_db_info = 16;
+  isc_info_svc_svr_online = 17;
+  isc_info_svc_svr_offline = 18;
+  isc_info_svc_get_config = 19;
+  isc_info_svc_set_config = 20;
+  isc_info_svc_default_config = 21;
+  isc_info_svc_get_env = 22;
+  isc_info_svc_get_env_lock = 23;
+  isc_info_svc_get_env_msg = 24;
+
+  isc_info_sql_select = 4;
+  isc_info_sql_bind = 5;
+  isc_info_sql_num_variables = 6;
+  isc_info_sql_describe_vars = 7;
+  isc_info_sql_describe_end = 8;
+  isc_info_sql_sqlda_seq = 9;
+  isc_info_sql_message_seq = 10;
+  isc_info_sql_type = 11;
+  isc_info_sql_sub_type = 12;
+  isc_info_sql_scale = 13;
+  isc_info_sql_length = 14;
+  isc_info_sql_null_ind = 15;
+  isc_info_sql_field = 16;
+  isc_info_sql_relation = 17;
+  isc_info_sql_owner = 18;
+  isc_info_sql_alias = 19;
+  isc_info_sql_sqlda_start = 20;
+  isc_info_sql_stmt_type = 21;
+  isc_info_sql_get_plan = 22;
+  isc_info_sql_records = 23;
+  isc_info_sql_batch_fetch = 24;
+
+  isc_info_sql_stmt_select = 1;
+  isc_info_sql_stmt_insert = 2;
+  isc_info_sql_stmt_update = 3;
+  isc_info_sql_stmt_delete = 4;
+  isc_info_sql_stmt_ddl = 5;
+  isc_info_sql_stmt_get_segment = 6;
+  isc_info_sql_stmt_put_segment = 7;
+  isc_info_sql_stmt_exec_procedure = 8;
+  isc_info_sql_stmt_start_trans = 9;
+  isc_info_sql_stmt_commit = 10;
+  isc_info_sql_stmt_rollback = 11;
+  isc_info_sql_stmt_select_for_upd = 12;
+  isc_info_sql_stmt_set_generator = 13;
+
+
+  ISCCFG_LOCKMEM_KEY = 0;
+  ISCCFG_LOCKSEM_KEY = 1;
+  ISCCFG_LOCKSIG_KEY = 2;
+  ISCCFG_EVNTMEM_KEY = 3;
+  ISCCFG_DBCACHE_KEY = 4;
+  ISCCFG_PRIORITY_KEY = 5;
+  ISCCFG_IPCMAP_KEY = 6;
+  ISCCFG_MEMMIN_KEY = 7;
+  ISCCFG_MEMMAX_KEY = 8;
+  ISCCFG_LOCKORDER_KEY = 9;
+  ISCCFG_ANYLOCKMEM_KEY = 10;
+  ISCCFG_ANYLOCKSEM_KEY = 11;
+  ISCCFG_ANYLOCKSIG_KEY = 12;
+  ISCCFG_ANYEVNTMEM_KEY = 13;
+  ISCCFG_LOCKHASH_KEY = 14;
+  ISCCFG_DEADLOCK_KEY = 15;
+  ISCCFG_LOCKSPIN_KEY = 16;
+  ISCCFG_CONN_TIMEOUT_KEY = 17;
+  ISCCFG_DUMMY_INTRVL_KEY = 18;
+
+
+  isc_facility = 20;
+  isc_err_base = 335544320;
+  isc_err_factor = 1;
+  isc_arg_end = 0;
+  isc_arg_gds = 1;
+  isc_arg_string = 2;
+  isc_arg_cstring = 3;
+  isc_arg_number = 4;
+  isc_arg_interpreted = 5;
+  isc_arg_vms = 6;
+  isc_arg_unix = 7;
+  isc_arg_domain = 8;
+  isc_arg_dos = 9;
+  isc_arg_mpexl = 10;
+  isc_arg_mpexl_ipc = 11;
+  isc_arg_next_mach = 15;
+  isc_arg_netware = 16;
+  isc_arg_win32 = 17;
+
+  isc_arith_except = 335544321;
+  isc_bad_dbkey = 335544322;
+  isc_bad_db_format = 335544323;
+  isc_bad_db_handle = 335544324;
+  isc_bad_dpb_content = 335544325;
+  isc_bad_dpb_form = 335544326;
+  isc_bad_req_handle = 335544327;
+  isc_bad_segstr_handle = 335544328;
+  isc_bad_segstr_id = 335544329;
+  isc_bad_tpb_content = 335544330;
+  isc_bad_tpb_form = 335544331;
+  isc_bad_trans_handle = 335544332;
+  isc_bug_check = 335544333;
+  isc_convert_error = 335544334;
+  isc_db_corrupt = 335544335;
+  isc_deadlock = 335544336;
+  isc_excess_trans = 335544337;
+  isc_from_no_match = 335544338;
+  isc_infinap = 335544339;
+  isc_infona = 335544340;
+  isc_infunk = 335544341;
+  isc_integ_fail = 335544342;
+  isc_invalid_blr = 335544343;
+  isc_io_error = 335544344;
+  isc_lock_conflict = 335544345;
+  isc_metadata_corrupt = 335544346;
+  isc_not_valid = 335544347;
+  isc_no_cur_rec = 335544348;
+  isc_no_dup = 335544349;
+  isc_no_finish = 335544350;
+  isc_no_meta_update = 335544351;
+  isc_no_priv = 335544352;
+  isc_no_recon = 335544353;
+  isc_no_record = 335544354;
+  isc_no_segstr_close = 335544355;
+  isc_obsolete_metadata = 335544356;
+  isc_open_trans = 335544357;
+  isc_port_len = 335544358;
+  isc_read_only_field = 335544359;
+  isc_read_only_rel = 335544360;
+  isc_read_only_trans = 335544361;
+  isc_read_only_view = 335544362;
+  isc_req_no_trans = 335544363;
+  isc_req_sync = 335544364;
+  isc_req_wrong_db = 335544365;
+  isc_segment = 335544366;
+  isc_segstr_eof = 335544367;
+  isc_segstr_no_op = 335544368;
+  isc_segstr_no_read = 335544369;
+  isc_segstr_no_trans = 335544370;
+  isc_segstr_no_write = 335544371;
+  isc_segstr_wrong_db = 335544372;
+  isc_sys_request = 335544373;
+  isc_stream_eof = 335544374;
+  isc_unavailable = 335544375;
+  isc_unres_rel = 335544376;
+  isc_uns_ext = 335544377;
+  isc_wish_list = 335544378;
+  isc_wrong_ods = 335544379;
+  isc_wronumarg = 335544380;
+  isc_imp_exc = 335544381;
+  isc_random = 335544382;
+  isc_fatal_conflict = 335544383;
+  isc_badblk = 335544384;
+  isc_invpoolcl = 335544385;
+  isc_nopoolids = 335544386;
+  isc_relbadblk = 335544387;
+  isc_blktoobig = 335544388;
+  isc_bufexh = 335544389;
+  isc_syntaxerr = 335544390;
+  isc_bufinuse = 335544391;
+  isc_bdbincon = 335544392;
+  isc_reqinuse = 335544393;
+  isc_badodsver = 335544394;
+  isc_relnotdef = 335544395;
+  isc_fldnotdef = 335544396;
+  isc_dirtypage = 335544397;
+  isc_waifortra = 335544398;
+  isc_doubleloc = 335544399;
+  isc_nodnotfnd = 335544400;
+  isc_dupnodfnd = 335544401;
+  isc_locnotmar = 335544402;
+  isc_badpagtyp = 335544403;
+  isc_corrupt = 335544404;
+  isc_badpage = 335544405;
+  isc_badindex = 335544406;
+  isc_dbbnotzer = 335544407;
+  isc_tranotzer = 335544408;
+  isc_trareqmis = 335544409;
+  isc_badhndcnt = 335544410;
+  isc_wrotpbver = 335544411;
+  isc_wroblrver = 335544412;
+  isc_wrodpbver = 335544413;
+  isc_blobnotsup = 335544414;
+  isc_badrelation = 335544415;
+  isc_nodetach = 335544416;
+  isc_notremote = 335544417;
+  isc_trainlim = 335544418;
+  isc_notinlim = 335544419;
+  isc_traoutsta = 335544420;
+  isc_connect_reject = 335544421;
+  isc_dbfile = 335544422;
+  isc_orphan = 335544423;
+  isc_no_lock_mgr = 335544424;
+  isc_ctxinuse = 335544425;
+  isc_ctxnotdef = 335544426;
+  isc_datnotsup = 335544427;
+  isc_badmsgnum = 335544428;
+  isc_badparnum = 335544429;
+  isc_virmemexh = 335544430;
+  isc_blocking_signal = 335544431;
+  isc_lockmanerr = 335544432;
+  isc_journerr = 335544433;
+  isc_keytoobig = 335544434;
+  isc_nullsegkey = 335544435;
+  isc_sqlerr = 335544436;
+  isc_wrodynver = 335544437;
+  isc_funnotdef = 335544438;
+  isc_funmismat = 335544439;
+  isc_bad_msg_vec = 335544440;
+  isc_bad_detach = 335544441;
+  isc_noargacc_read = 335544442;
+  isc_noargacc_write = 335544443;
+  isc_read_only = 335544444;
+  isc_ext_err = 335544445;
+  isc_non_updatable = 335544446;
+  isc_no_rollback = 335544447;
+  isc_bad_sec_info = 335544448;
+  isc_invalid_sec_info = 335544449;
+  isc_misc_interpreted = 335544450;
+  isc_update_conflict = 335544451;
+  isc_unlicensed = 335544452;
+  isc_obj_in_use = 335544453;
+  isc_nofilter = 335544454;
+  isc_shadow_accessed = 335544455;
+  isc_invalid_sdl = 335544456;
+  isc_out_of_bounds = 335544457;
+  isc_invalid_dimension = 335544458;
+  isc_rec_in_limbo = 335544459;
+  isc_shadow_missing = 335544460;
+  isc_cant_validate = 335544461;
+  isc_cant_start_journal = 335544462;
+  isc_gennotdef = 335544463;
+  isc_cant_start_logging = 335544464;
+  isc_bad_segstr_type = 335544465;
+  isc_foreign_key = 335544466;
+  isc_high_minor = 335544467;
+  isc_tra_state = 335544468;
+  isc_trans_invalid = 335544469;
+  isc_buf_invalid = 335544470;
+  isc_indexnotdefined = 335544471;
+  isc_login = 335544472;
+  isc_invalid_bookmark = 335544473;
+  isc_bad_lock_level = 335544474;
+  isc_relation_lock = 335544475;
+  isc_record_lock = 335544476;
+  isc_max_idx = 335544477;
+  isc_jrn_enable = 335544478;
+  isc_old_failure = 335544479;
+  isc_old_in_progress = 335544480;
+  isc_old_no_space = 335544481;
+  isc_no_wal_no_jrn = 335544482;
+  isc_num_old_files = 335544483;
+  isc_wal_file_open = 335544484;
+  isc_bad_stmt_handle = 335544485;
+  isc_wal_failure = 335544486;
+  isc_walw_err = 335544487;
+  isc_logh_small = 335544488;
+  isc_logh_inv_version = 335544489;
+  isc_logh_open_flag = 335544490;
+  isc_logh_open_flag2 = 335544491;
+  isc_logh_diff_dbname = 335544492;
+  isc_logf_unexpected_eof = 335544493;
+  isc_logr_incomplete = 335544494;
+  isc_logr_header_small = 335544495;
+  isc_logb_small = 335544496;
+  isc_wal_illegal_attach = 335544497;
+  isc_wal_invalid_wpb = 335544498;
+  isc_wal_err_rollover = 335544499;
+  isc_no_wal = 335544500;
+  isc_drop_wal = 335544501;
+  isc_stream_not_defined = 335544502;
+  isc_wal_subsys_error = 335544503;
+  isc_wal_subsys_corrupt = 335544504;
+  isc_no_archive = 335544505;
+  isc_shutinprog = 335544506;
+  isc_range_in_use = 335544507;
+  isc_range_not_found = 335544508;
+  isc_charset_not_found = 335544509;
+  isc_lock_timeout = 335544510;
+  isc_prcnotdef = 335544511;
+  isc_prcmismat = 335544512;
+  isc_wal_bugcheck = 335544513;
+  isc_wal_cant_expand = 335544514;
+  isc_codnotdef = 335544515;
+  isc_xcpnotdef = 335544516;
+  isc_except = 335544517;
+  isc_cache_restart = 335544518;
+  isc_bad_lock_handle = 335544519;
+  isc_jrn_present = 335544520;
+  isc_wal_err_rollover2 = 335544521;
+  isc_wal_err_logwrite = 335544522;
+  isc_wal_err_jrn_comm = 335544523;
+  isc_wal_err_expansion = 335544524;
+  isc_wal_err_setup = 335544525;
+  isc_wal_err_ww_sync = 335544526;
+  isc_wal_err_ww_start = 335544527;
+  isc_shutdown = 335544528;
+  isc_existing_priv_mod = 335544529;
+  isc_primary_key_ref = 335544530;
+  isc_primary_key_notnull = 335544531;
+  isc_ref_cnstrnt_notfound = 335544532;
+  isc_foreign_key_notfound = 335544533;
+  isc_ref_cnstrnt_update = 335544534;
+  isc_check_cnstrnt_update = 335544535;
+  isc_check_cnstrnt_del = 335544536;
+  isc_integ_index_seg_del = 335544537;
+  isc_integ_index_seg_mod = 335544538;
+  isc_integ_index_del = 335544539;
+  isc_integ_index_mod = 335544540;
+  isc_check_trig_del = 335544541;
+  isc_check_trig_update = 335544542;
+  isc_cnstrnt_fld_del = 335544543;
+  isc_cnstrnt_fld_rename = 335544544;
+  isc_rel_cnstrnt_update = 335544545;
+  isc_constaint_on_view = 335544546;
+  isc_invld_cnstrnt_type = 335544547;
+  isc_primary_key_exists = 335544548;
+  isc_systrig_update = 335544549;
+  isc_not_rel_owner = 335544550;
+  isc_grant_obj_notfound = 335544551;
+  isc_grant_fld_notfound = 335544552;
+  isc_grant_nopriv = 335544553;
+  isc_nonsql_security_rel = 335544554;
+  isc_nonsql_security_fld = 335544555;
+  isc_wal_cache_err = 335544556;
+  isc_shutfail = 335544557;
+  isc_check_constraint = 335544558;
+  isc_bad_svc_handle = 335544559;
+  isc_shutwarn = 335544560;
+  isc_wrospbver = 335544561;
+  isc_bad_spb_form = 335544562;
+  isc_svcnotdef = 335544563;
+  isc_no_jrn = 335544564;
+  isc_transliteration_failed = 335544565;
+  isc_start_cm_for_wal = 335544566;
+  isc_wal_ovflow_log_required = 335544567;
+  isc_text_subtype = 335544568;
+  isc_dsql_error = 335544569;
+  isc_dsql_command_err = 335544570;
+  isc_dsql_constant_err = 335544571;
+  isc_dsql_cursor_err = 335544572;
+  isc_dsql_datatype_err = 335544573;
+  isc_dsql_decl_err = 335544574;
+  isc_dsql_cursor_update_err = 335544575;
+  isc_dsql_cursor_open_err = 335544576;
+  isc_dsql_cursor_close_err = 335544577;
+  isc_dsql_field_err = 335544578;
+  isc_dsql_internal_err = 335544579;
+  isc_dsql_relation_err = 335544580;
+  isc_dsql_procedure_err = 335544581;
+  isc_dsql_request_err = 335544582;
+  isc_dsql_sqlda_err = 335544583;
+  isc_dsql_var_count_err = 335544584;
+  isc_dsql_stmt_handle = 335544585;
+  isc_dsql_function_err = 335544586;
+  isc_dsql_blob_err = 335544587;
+  isc_collation_not_found = 335544588;
+  isc_collation_not_for_charset = 335544589;
+  isc_dsql_dup_option = 335544590;
+  isc_dsql_tran_err = 335544591;
+  isc_dsql_invalid_array = 335544592;
+  isc_dsql_max_arr_dim_exceeded = 335544593;
+  isc_dsql_arr_range_error = 335544594;
+  isc_dsql_trigger_err = 335544595;
+  isc_dsql_subselect_err = 335544596;
+  isc_dsql_crdb_prepare_err = 335544597;
+  isc_specify_field_err = 335544598;
+  isc_num_field_err = 335544599;
+  isc_col_name_err = 335544600;
+  isc_where_err = 335544601;
+  isc_table_view_err = 335544602;
+  isc_distinct_err = 335544603;
+  isc_key_field_count_err = 335544604;
+  isc_subquery_err = 335544605;
+  isc_expression_eval_err = 335544606;
+  isc_node_err = 335544607;
+  isc_command_end_err = 335544608;
+  isc_index_name = 335544609;
+  isc_exception_name = 335544610;
+  isc_field_name = 335544611;
+  isc_token_err = 335544612;
+  isc_union_err = 335544613;
+  isc_dsql_construct_err = 335544614;
+  isc_field_aggregate_err = 335544615;
+  isc_field_ref_err = 335544616;
+  isc_order_by_err = 335544617;
+  isc_return_mode_err = 335544618;
+  isc_extern_func_err = 335544619;
+  isc_alias_conflict_err = 335544620;
+  isc_procedure_conflict_error = 335544621;
+  isc_relation_conflict_err = 335544622;
+  isc_dsql_domain_err = 335544623;
+  isc_idx_seg_err = 335544624;
+  isc_node_name_err = 335544625;
+  isc_table_name = 335544626;
+  isc_proc_name = 335544627;
+  isc_idx_create_err = 335544628;
+  isc_wal_shadow_err = 335544629;
+  isc_dependency = 335544630;
+  isc_idx_key_err = 335544631;
+  isc_dsql_file_length_err = 335544632;
+  isc_dsql_shadow_number_err = 335544633;
+  isc_dsql_token_unk_err = 335544634;
+  isc_dsql_no_relation_alias = 335544635;
+  isc_indexname = 335544636;
+  isc_no_stream_plan = 335544637;
+  isc_stream_twice = 335544638;
+  isc_stream_not_found = 335544639;
+  isc_collation_requires_text = 335544640;
+  isc_dsql_domain_not_found = 335544641;
+  isc_index_unused = 335544642;
+  isc_dsql_self_join = 335544643;
+  isc_stream_bof = 335544644;
+  isc_stream_crack = 335544645;
+  isc_db_or_file_exists = 335544646;
+  isc_invalid_operator = 335544647;
+  isc_conn_lost = 335544648;
+  isc_bad_checksum = 335544649;
+  isc_page_type_err = 335544650;
+  isc_ext_readonly_err = 335544651;
+  isc_sing_select_err = 335544652;
+  isc_psw_attach = 335544653;
+  isc_psw_start_trans = 335544654;
+  isc_invalid_direction = 335544655;
+  isc_dsql_var_conflict = 335544656;
+  isc_dsql_no_blob_array = 335544657;
+  isc_dsql_base_table = 335544658;
+  isc_duplicate_base_table = 335544659;
+  isc_view_alias = 335544660;
+  isc_index_root_page_full = 335544661;
+  isc_dsql_blob_type_unknown = 335544662;
+  isc_req_max_clones_exceeded = 335544663;
+  isc_dsql_duplicate_spec = 335544664;
+  isc_unique_key_violation = 335544665;
+  isc_srvr_version_too_old = 335544666;
+  isc_drdb_completed_with_errs = 335544667;
+  isc_dsql_procedure_use_err = 335544668;
+  isc_dsql_count_mismatch = 335544669;
+  isc_blob_idx_err = 335544670;
+  isc_array_idx_err = 335544671;
+  isc_key_field_err = 335544672;
+  isc_no_delete = 335544673;
+  isc_del_last_field = 335544674;
+  isc_sort_err = 335544675;
+  isc_sort_mem_err = 335544676;
+  isc_version_err = 335544677;
+  isc_inval_key_posn = 335544678;
+  isc_no_segments_err = 335544679;
+  isc_crrp_data_err = 335544680;
+  isc_rec_size_err = 335544681;
+  isc_dsql_field_ref = 335544682;
+  isc_req_depth_exceeded = 335544683;
+  isc_no_field_access = 335544684;
+  isc_no_dbkey = 335544685;
+  isc_jrn_format_err = 335544686;
+  isc_jrn_file_full = 335544687;
+  isc_dsql_open_cursor_request = 335544688;
+  isc_ib_error = 335544689;
+  isc_cache_redef = 335544690;
+  isc_cache_too_small = 335544691;
+  isc_log_redef = 335544692;
+  isc_log_too_small = 335544693;
+  isc_partition_too_small = 335544694;
+  isc_partition_not_supp = 335544695;
+  isc_log_length_spec = 335544696;
+  isc_precision_err = 335544697;
+  isc_scale_nogt = 335544698;
+  isc_expec_short = 335544699;
+  isc_expec_long = 335544700;
+  isc_expec_ushort = 335544701;
+  isc_like_escape_invalid = 335544702;
+  isc_svcnoexe = 335544703;
+  isc_net_lookup_err = 335544704;
+  isc_service_unknown = 335544705;
+  isc_host_unknown = 335544706;
+  isc_grant_nopriv_on_base = 335544707;
+  isc_dyn_fld_ambiguous = 335544708;
+  isc_dsql_agg_ref_err = 335544709;
+  isc_complex_view = 335544710;
+  isc_unprepared_stmt = 335544711;
+  isc_expec_positive = 335544712;
+  isc_dsql_sqlda_value_err = 335544713;
+  isc_invalid_array_id = 335544714;
+  isc_extfile_uns_op = 335544715;
+  isc_svc_in_use = 335544716;
+  isc_err_stack_limit = 335544717;
+  isc_invalid_key = 335544718;
+  isc_net_init_error = 335544719;
+  isc_loadlib_failure = 335544720;
+  isc_network_error = 335544721;
+  isc_net_connect_err = 335544722;
+  isc_net_connect_listen_err = 335544723;
+  isc_net_event_connect_err = 335544724;
+  isc_net_event_listen_err = 335544725;
+  isc_net_read_err = 335544726;
+  isc_net_write_err = 335544727;
+  isc_integ_index_deactivate = 335544728;
+  isc_integ_deactivate_primary = 335544729;
+  isc_cse_not_supported = 335544730;
+  isc_tra_must_sweep = 335544731;
+  isc_unsupported_network_drive = 335544732;
+  isc_io_create_err = 335544733;
+  isc_io_open_err = 335544734;
+  isc_io_close_err = 335544735;
+  isc_io_read_err = 335544736;
+  isc_io_write_err = 335544737;
+  isc_io_delete_err = 335544738;
+  isc_io_access_err = 335544739;
+  isc_udf_exception = 335544740;
+  isc_lost_db_connection = 335544741;
+  isc_no_write_user_priv = 335544742;
+  isc_token_too_long = 335544743;
+  isc_max_att_exceeded = 335544744;
+  isc_login_same_as_role_name = 335544745;
+  isc_usrname_too_long = 335544747;
+  isc_password_too_long = 335544748;
+  isc_usrname_required = 335544749;
+  isc_password_required = 335544750;
+  isc_bad_protocol = 335544751;
+  isc_dup_usrname_found = 335544752;
+  isc_usrname_not_found = 335544753;
+  isc_error_adding_sec_record = 335544754;
+  isc_error_modifying_sec_record = 335544755;
+  isc_error_deleting_sec_record = 335544756;
+  isc_error_updating_sec_db = 335544757;
+  isc_err_max = 425;
+
+
+  isc_dyn_version_1 = 1;
+  isc_dyn_eoc = -1;
+
+  isc_dyn_begin = 2;
+  isc_dyn_end = 3;
+  isc_dyn_if = 4;
+  isc_dyn_def_database = 5;
+  isc_dyn_def_global_fld = 6;
+  isc_dyn_def_local_fld = 7;
+  isc_dyn_def_idx = 8;
+  isc_dyn_def_rel = 9;
+  isc_dyn_def_sql_fld = 10;
+  isc_dyn_def_view = 12;
+  isc_dyn_def_trigger = 15;
+  isc_dyn_def_security_class = 120;
+  isc_dyn_def_dimension = 140;
+  isc_dyn_def_generator = 24;
+  isc_dyn_def_function = 25;
+  isc_dyn_def_filter = 26;
+  isc_dyn_def_function_arg = 27;
+  isc_dyn_def_shadow = 34;
+  isc_dyn_def_trigger_msg = 17;
+  isc_dyn_def_file = 36;
+  isc_dyn_mod_database = 39;
+  isc_dyn_mod_rel = 11;
+  isc_dyn_mod_global_fld = 13;
+  isc_dyn_mod_idx = 102;
+  isc_dyn_mod_local_fld = 14;
+  isc_dyn_mod_view = 16;
+  isc_dyn_mod_security_class = 122;
+  isc_dyn_mod_trigger = 113;
+  isc_dyn_mod_trigger_msg = 28;
+  isc_dyn_delete_database = 18;
+  isc_dyn_delete_rel = 19;
+  isc_dyn_delete_global_fld = 20;
+  isc_dyn_delete_local_fld = 21;
+  isc_dyn_delete_idx = 22;
+  isc_dyn_delete_security_class = 123;
+  isc_dyn_delete_dimensions = 143;
+  isc_dyn_delete_trigger = 23;
+  isc_dyn_delete_trigger_msg = 29;
+  isc_dyn_delete_filter = 32;
+  isc_dyn_delete_function = 33;
+  isc_dyn_delete_shadow = 35;
+  isc_dyn_grant = 30;
+  isc_dyn_revoke = 31;
+  isc_dyn_def_primary_key = 37;
+  isc_dyn_def_foreign_key = 38;
+  isc_dyn_def_unique = 40;
+  isc_dyn_def_procedure = 164;
+  isc_dyn_delete_procedure = 165;
+  isc_dyn_def_parameter = 135;
+  isc_dyn_delete_parameter = 136;
+  isc_dyn_mod_procedure = 175;
+  isc_dyn_def_log_file = 176;
+  isc_dyn_def_cache_file = 180;
+  isc_dyn_def_exception = 181;
+  isc_dyn_mod_exception = 182;
+  isc_dyn_del_exception = 183;
+  isc_dyn_drop_log = 194;
+  isc_dyn_drop_cache = 195;
+  isc_dyn_def_default_log = 202;
+
+  isc_dyn_view_blr = 43;
+  isc_dyn_view_source = 44;
+  isc_dyn_view_relation = 45;
+  isc_dyn_view_context = 46;
+  isc_dyn_view_context_name = 47;
+
+  isc_dyn_rel_name = 50;
+  isc_dyn_fld_name = 51;
+  isc_dyn_idx_name = 52;
+  isc_dyn_description = 53;
+  isc_dyn_security_class = 54;
+  isc_dyn_system_flag = 55;
+  isc_dyn_update_flag = 56;
+  isc_dyn_prc_name = 166;
+  isc_dyn_prm_name = 137;
+  isc_dyn_sql_object = 196;
+  isc_dyn_fld_character_set_name = 174;
+
+  isc_dyn_rel_dbkey_length = 61;
+  isc_dyn_rel_store_trig = 62;
+  isc_dyn_rel_modify_trig = 63;
+  isc_dyn_rel_erase_trig = 64;
+  isc_dyn_rel_store_trig_source = 65;
+  isc_dyn_rel_modify_trig_source = 66;
+  isc_dyn_rel_erase_trig_source = 67;
+  isc_dyn_rel_ext_file = 68;
+  isc_dyn_rel_sql_protection = 69;
+  isc_dyn_rel_constraint = 162;
+  isc_dyn_delete_rel_constraint = 163;
+
+  isc_dyn_fld_type = 70;
+  isc_dyn_fld_length = 71;
+  isc_dyn_fld_scale = 72;
+  isc_dyn_fld_sub_type = 73;
+  isc_dyn_fld_segment_length = 74;
+  isc_dyn_fld_query_header = 75;
+  isc_dyn_fld_edit_string = 76;
+  isc_dyn_fld_validation_blr = 77;
+  isc_dyn_fld_validation_source = 78;
+  isc_dyn_fld_computed_blr = 79;
+  isc_dyn_fld_computed_source = 80;
+  isc_dyn_fld_missing_value = 81;
+  isc_dyn_fld_default_value = 82;
+  isc_dyn_fld_query_name = 83;
+  isc_dyn_fld_dimensions = 84;
+  isc_dyn_fld_not_null = 85;
+  isc_dyn_fld_char_length = 172;
+  isc_dyn_fld_collation = 173;
+  isc_dyn_fld_default_source = 193;
+  isc_dyn_del_default = 197;
+  isc_dyn_del_validation = 198;
+  isc_dyn_single_validation = 199;
+  isc_dyn_fld_character_set = 203;
+
+  isc_dyn_fld_source = 90;
+  isc_dyn_fld_base_fld = 91;
+  isc_dyn_fld_position = 92;
+  isc_dyn_fld_update_flag = 93;
+
+  isc_dyn_idx_unique = 100;
+  isc_dyn_idx_inactive = 101;
+  isc_dyn_idx_type = 103;
+  isc_dyn_idx_foreign_key = 104;
+  isc_dyn_idx_ref_column = 105;
+  isc_dyn_idx_statistic = 204;
+
+  isc_dyn_trg_type = 110;
+  isc_dyn_trg_blr = 111;
+  isc_dyn_trg_source = 112;
+  isc_dyn_trg_name = 114;
+  isc_dyn_trg_sequence = 115;
+  isc_dyn_trg_inactive = 116;
+  isc_dyn_trg_msg_number = 117;
+  isc_dyn_trg_msg = 118;
+
+  isc_dyn_scl_acl = 121;
+  isc_dyn_grant_user = 130;
+  isc_dyn_grant_proc = 186;
+  isc_dyn_grant_trig = 187;
+  isc_dyn_grant_view = 188;
+  isc_dyn_grant_options = 132;
+  isc_dyn_grant_user_group = 205;
+
+  isc_dyn_dim_lower = 141;
+  isc_dyn_dim_upper = 142;
+
+  isc_dyn_file_name = 125;
+  isc_dyn_file_start = 126;
+  isc_dyn_file_length = 127;
+  isc_dyn_shadow_number = 128;
+  isc_dyn_shadow_man_auto = 129;
+  isc_dyn_shadow_conditional = 130;
+
+  isc_dyn_log_file_sequence = 177;
+  isc_dyn_log_file_partitions = 178;
+  isc_dyn_log_file_serial = 179;
+  isc_dyn_log_file_overflow = 200;
+  isc_dyn_log_file_raw = 201;
+
+  isc_dyn_log_group_commit_wait = 189;
+   isc_dyn_log_buffer_size = 190;
+  isc_dyn_log_check_point_length = 191;
+  isc_dyn_log_num_of_buffers = 192;
+
+  isc_dyn_function_name = 145;
+  isc_dyn_function_type = 146;
+  isc_dyn_func_module_name = 147;
+  isc_dyn_func_entry_point = 148;
+  isc_dyn_func_return_argument = 149;
+  isc_dyn_func_arg_position = 150;
+  isc_dyn_func_mechanism = 151;
+  isc_dyn_filter_in_subtype = 152;
+  isc_dyn_filter_out_subtype = 153;
+
+  isc_dyn_description2 = 154;
+    isc_dyn_fld_computed_source2 = 155;
+    isc_dyn_fld_edit_string2 = 156;
+  isc_dyn_fld_query_header2 = 157;
+  isc_dyn_fld_validation_source2 = 158;
+  isc_dyn_trg_msg2 = 159;
+  isc_dyn_trg_source2 = 160;
+  isc_dyn_view_source2 = 161;
+  isc_dyn_xcp_msg2 = 184;
+
+  isc_dyn_generator_name = 95;
+  isc_dyn_generator_id = 96;
+
+  isc_dyn_prc_inputs = 167;
+  isc_dyn_prc_outputs = 168;
+  isc_dyn_prc_source = 169;
+  isc_dyn_prc_blr = 170;
+  isc_dyn_prc_source2 = 171;
+
+  isc_dyn_prm_number = 138;
+  isc_dyn_prm_type = 139;
+
+  isc_dyn_xcp_msg = 185;
+
+  isc_dyn_foreign_key_update = 205;
+  isc_dyn_foreign_key_delete = 206;
+  isc_dyn_foreign_key_cascade = 207;
+  isc_dyn_foreign_key_default = 208;
+  isc_dyn_foreign_key_null = 209;
+  isc_dyn_foreign_key_none = 210;
+
+  isc_dyn_def_sql_role = 211;
+  isc_dyn_sql_role_name = 212;
+  isc_dyn_grant_admin_options = 213;
+  isc_dyn_del_sql_role = 214;
+
+  isc_dyn_last_dyn_value = 214;
+
+  isc_sdl_version1 = 1;
+  isc_sdl_eoc = -1;
+  isc_sdl_relation = 2;
+  isc_sdl_rid = 3;
+  isc_sdl_field = 4;
+  isc_sdl_fid = 5;
+  isc_sdl_struct = 6;
+  isc_sdl_variable = 7;
+  isc_sdl_scalar = 8;
+  isc_sdl_tiny_integer = 9;
+  isc_sdl_short_integer = 10;
+  isc_sdl_long_integer = 11;
+  isc_sdl_literal = 12;
+  isc_sdl_add = 13;
+  isc_sdl_subtract = 14;
+  isc_sdl_multiply = 15;
+  isc_sdl_divide = 16;
+  isc_sdl_negate = 17;
+  isc_sdl_eql = 18;
+  isc_sdl_neq = 19;
+  isc_sdl_gtr = 20;
+  isc_sdl_geq = 21;
+  isc_sdl_lss = 22;
+  isc_sdl_leq = 23;
+  isc_sdl_and = 24;
+  isc_sdl_or = 25;
+  isc_sdl_not = 26;
+  isc_sdl_while = 27;
+  isc_sdl_assignment = 28;
+  isc_sdl_label = 29;
+  isc_sdl_leave = 30;
+  isc_sdl_begin = 31;
+  isc_sdl_end = 32;
+  isc_sdl_do3 = 33;
+  isc_sdl_do2 = 34;
+  isc_sdl_do1 = 35;
+  isc_sdl_element = 36;
+
+  isc_interp_eng_ascii = 0;
+  isc_interp_jpn_sjis = 5;
+  isc_interp_jpn_euc = 6;
+
+  isc_fetch_next = 0;
+  isc_fetch_prior = 1;
+  isc_fetch_first = 2;
+  isc_fetch_last = 3;
+  isc_fetch_absolute = 4;
+  isc_fetch_relative = 5;
+
+  SQLDA_VERSION1 = 1;
+
+  SQL_VARYING = 448;
+  SQL_TEXT = 452;
+  SQL_DOUBLE = 480;
+  SQL_FLOAT = 482;
+  SQL_LONG = 496;
+  SQL_SHORT = 500;
+  SQL_DATE = 510;
+  SQL_BLOB = 520;
+  SQL_D_FLOAT = 530;
+  SQL_ARRAY = 540;
+  SQL_QUAD = 550;
+
+
+  isc_blob_untyped = 0;
+
+  isc_blob_text = 1;
+  isc_blob_blr = 2;
+  isc_blob_acl = 3;
+  isc_blob_ranges = 4;
+  isc_blob_summary = 5;
+  isc_blob_format = 6;
+  isc_blob_tra = 7;
+  isc_blob_extfile = 8;
+
+  isc_blob_formatted_memo = 20;
+  isc_blob_paradox_ole = 21;
+  isc_blob_graphic = 22;
+  isc_blob_dbase_ole = 23;
+  isc_blob_typed_binary = 24;
+
+  // TYPESTART  (to quickly get here, look for TYPESTART)
+
+type
+
+  TISC_ATT_HANDLE = PVoid;
+  PISC_ATT_HANDLE = ^TISC_ATT_HANDLE;
+  TISC_BLOB_HANDLE = PVoid;
+  PISC_BLOB_HANDLE = ^TISC_BLOB_HANDLE;
+  TISC_DB_HANDLE = PVoid;
+  PISC_DB_HANDLE = ^TISC_DB_HANDLE;
+  TISC_FORM_HANDLE = PVoid;
+  PISC_FORM_HANDLE = ^TISC_FORM_HANDLE;
+  TISC_REQ_HANDLE = PVoid;
+  PISC_REQ_HANDLE = ^TISC_REQ_HANDLE;
+  TISC_STMT_HANDLE = PVoid;
+  PISC_STMT_HANDLE = ^TISC_STMT_HANDLE;
+  TISC_SVC_HANDLE = PVoid;
+  PISC_SVC_HANDLE = ^TISC_SVC_HANDLE;
+  TISC_TR_HANDLE = PVoid;
+  PISC_TR_HANDLE = ^TISC_TR_HANDLE;
+  TISC_WIN_HANDLE = PVoid;
+  PISC_WIN_HANDLE = ^TISC_WIN_HANDLE;
+  TISC_CALLBACK = procedure;
+
+  TGDS_QUAD = record
+    gds_quad_high : ISC_LONG;
+    gds_quad_low : UISC_LONG;
+  end;
+  TGDS__QUAD = TGDS_QUAD;
+  TISC_QUAD = TGDS_QUAD;
+  PGDS_QUAD = ^TGDS_QUAD;
+  PGDS__QUAD = ^TGDS__QUAD;
+  PISC_QUAD = ^TISC_QUAD;
+
+  TISC_ARRAY_BOUND = record
+    array_bound_lower : short;
+    array_bound_upper : short;
+  end;
+  PISC_ARRAY_BOUND = ^TISC_ARRAY_BOUND;
+  TISC_ARRAY_DESC = record
+    array_desc_dtype : UChar;
+    array_desc_scale : Char;
+    array_desc_length : UShort;
+    array_desc_field_name : array[0..31] of Char;
+    array_desc_relation_name : array[0..31] of Char;
+    array_desc_dimensions : Short;
+    array_desc_flags : Short;
+    array_desc_bounds : array[0..15] of TISC_ARRAY_BOUND;
+  end;
+  PISC_ARRAY_DESC = ^TISC_ARRAY_DESC;
+
+  TISC_BLOB_DESC = record
+    blob_desc_subtype : Short;
+    blob_desc_charset : Short;
+    blob_desc_segment_size : Short;
+    blob_desc_field_name : array[0..31] of UChar;
+    blob_desc_relation_name : array[0..31] of UChar;
+  end;
+  PISC_BLOB_DESC = ^TISC_BLOB_DESC;
+
+  TISC_BLOB_CTL_SOURCE_FUNCTION = function : ISC_STATUS; // ISC_FAR
+  PISC_BLOB_CTL = ^TISC_BLOB_CTL;        // ISC_FAR
+  TISC_BLOB_CTL = record
+    ctl_source : TISC_BLOB_CTL_SOURCE_FUNCTION;
+    ctl_source_handle : PISC_BLOB_CTL;
+    ctl_to_sub_type : Short;
+    ctl_from_sub_type : Short;
+    ctl_buffer_length : UShort;
+    ctl_segment_length : UShort;
+    ctl_bpb_length : UShort;
+    ctl_bpb : PChar;
+    ctl_buffer : PUChar;
+    ctl_max_segment : ISC_LONG;
+    ctl_number_segments : ISC_LONG;
+    ctl_total_length : ISC_LONG;
+    ctl_status : PISC_STATUS;
+    ctl_data : array[0..7] of long;
+  end;
+
+  TBSTREAM = record
+    bstr_blob : PVoid;
+    bstr_buffer : PChar;
+    bstr_ptr : PChar;
+    bstr_length : Short;
+    bstr_cnt : Short;
+    bstr_mode : Char;
+  end;
+  PBSTREAM = ^TBSTREAM;
+
+  TSQLVAR = record
+    sqltype : Short;
+    sqllen : Short;
+    sqldata : PChar;
+    sqlind : PShort;
+    sqlname_length : Short;
+    sqlname : array[0..29] of Char;
+  end;
+  PSQLVAR = ^TSQLVAR;
+
+  TSQLDA = record
+    sqldaid : array[0..7] of Char;
+    sqldabc : ISC_LONG;
+    sqln : Short;
+    sqld : Short;
+    sqlvar : array[0..0] of TSQLVAR;
+  end;
+  PSQLDA = ^TSQLDA;
+
+  TXSQLVAR = record
+    sqltype : Short;
+    sqlscale : Short;
+    sqlsubtype : Short;
+    sqllen : Short;
+    sqldata : PChar;
+    sqlind : PShort;
+    sqlname_length : Short;
+    sqlname : array[0..31] of Char;
+    relname_length : Short;
+    relname : array[0..31] of Char;
+    ownname_length : Short;
+    ownname : array[0..31] of Char;
+    aliasname_length : Short;
+    aliasname : array[0..31] of Char;
+  end;
+  PXSQLVAR = ^TXSQLVAR;
+
+  TXSQLDA = record
+    version : Short;
+    pad : Short;
+    sqldaid : array[0..7] of Char;
+    sqldabc : ISC_LONG;
+    sqln : Short;
+    sqld : Short;
+    sqlvar : array[0..0] of TXSQLVAR;
+  end;
+  PXSQLDA = ^TXSQLDA;
+
+  TISC_START_TRANS = record
+    db_handle : PISC_DB_HANDLE;
+    tpb_length : UShort;   // Should it be long?
+    tpb_address : PChar;
+  end;
+
+  TISC_TEB = record
+    db_handle : PISC_DB_HANDLE;
+    tpb_length : Long;
+    tpb_address : PChar;
+  end;
+  PISC_TEB = ^TISC_TEB;
+  TISC_TEB_ARRAY = array[0..0] of TISC_TEB;
+  PISC_TEB_ARRAY = ^TISC_TEB_ARRAY;
+
+TUserSecData = record
+  sec_flags : Short;
+  uid : Int;
+  gid : int;
+  protocol : Int;
+  server : PChar;
+  user_name : PChar;
+  password : PChar;
+  group_name : PChar;
+  first_name : PChar;
+  middle_name : PChar;
+  last_name : PChar;
+  dba_user_name : PChar;
+  dba_password : PChar;
+  end;
+PUserSecData = ^TUserSecData;
+
+// FUNCSTART  (to quickly get here, look for FUNCSTART)
+
+function isc_attach_database (status_vector : PISC_STATUS;db_name_length: Short;db_name: PChar;db_handle: PISC_DB_HANDLE;parm_buffer_length:Short;parm_buffer: PChar): ISC_STATUS; stdcall; external LibName;
+function isc_array_gen_sdl (status_vector : PISC_STATUS;isc_array_desc: PISC_ARRAY_DESC;isc_arg3 : PShort;isc_arg4 : PChar;isc_arg5 : PShort): ISC_STATUS;stdcall; external LibName;
+function isc_array_get_slice (status_vector : PISC_STATUS;db_handle: PISC_DB_HANDLE;trans_handle : PISC_TR_HANDLE;array_id                 : PISC_QUAD;descriptor               : PISC_ARRAY_DESC;dest_array : PVoid;slice_length : ISC_LONG): ISC_STATUS;stdcall; external LibName;
+function isc_array_lookup_bounds (status_vector : PISC_STATUS;db_handle: PISC_DB_HANDLE;trans_handle : PISC_TR_HANDLE;table_name,column_name              : PChar;descriptor               : PISC_ARRAY_DESC): ISC_STATUS;stdcall; external LibName;
+function isc_array_lookup_desc (status_vector : PISC_STATUS;db_handle : PISC_DB_HANDLE;trans_handle : PISC_TR_HANDLE;table_name,column_name : PChar;descriptor : PISC_ARRAY_DESC) : ISC_STATUS; stdcall; external LibName;
+function isc_array_set_desc (status_vector : PISC_STATUS;table_name : PChar;column_name : PChar;sql_dtype,sql_length,sql_dimensions : PShort;descriptor : PISC_ARRAY_DESC) : ISC_STATUS;stdcall; external LibName;
+function isc_array_put_slice (status_vector : PISC_STATUS;db_handle : PISC_DB_HANDLE;trans_handle : PISC_TR_HANDLE;array_id : PISC_QUAD;descriptor : PISC_ARRAY_DESC;source_array : PVoid;slice_length : PISC_LONG) : ISC_STATUS;stdcall; external LibName;
+procedure isc_blob_default_desc (descriptor : PISC_BLOB_DESC;table_name : PUChar;column_name : PUChar);stdcall; external LibName;
+function isc_blob_gen_bpb (status_vector : PISC_STATUS;to_descriptor,from_descriptor : PISC_BLOB_DESC;bpb_buffer_length : UShort;bpb_buffer : PUChar;bpb_length : PUShort) : ISC_STATUS;stdcall; external LibName;
+function isc_blob_info (status_vector : PISC_STATUS;blob_handle : PISC_BLOB_HANDLE;item_list_buffer_length : Short;item_list_buffer : PChar;result_buffer_length : Short;result_buffer : PChar) : ISC_STATUS;stdcall; external LibName;
+function isc_blob_lookup_desc (status_vector : PISC_STATUS;db_handle : PISC_DB_HANDLE;trans_handle : PISC_TR_HANDLE;table_name,column_name : PChar;descriptor : PISC_BLOB_DESC;global : PUChar) : ISC_STATUS;stdcall; external LibName;
+function isc_blob_set_desc (status_vector : PISC_STATUS;table_name,column_name : PChar;subtype,charset,segment_size : Short;descriptor : PISC_BLOB_DESC) : ISC_STATUS;stdcall; external LibName;
+function isc_cancel_blob (status_vector : PISC_STATUS;blob_handle : PISC_BLOB_HANDLE) : ISC_STATUS;stdcall; external LibName;
+function isc_cancel_events (status_vector : PISC_STATUS;db_handle : PISC_DB_HANDLE;event_id : PISC_LONG) : ISC_STATUS;stdcall; external LibName;
+function isc_close_blob (status_vector : PISC_STATUS;blob_handle : PISC_BLOB_HANDLE) : ISC_STATUS;stdcall; external LibName;
+function isc_commit_retaining (status_vector : PISC_STATUS;tran_handle : PISC_TR_HANDLE) : ISC_STATUS;stdcall; external LibName;
+function isc_commit_transaction (status_vector : PISC_STATUS;tran_handle : PISC_TR_HANDLE) : ISC_STATUS;stdcall; external LibName;
+function isc_create_blob (status_vector : PISC_STATUS;db_handle : PISC_DB_HANDLE;tran_handle : PISC_TR_HANDLE;blob_handle : PISC_BLOB_HANDLE;blob_id : PISC_QUAD) : ISC_STATUS;stdcall; external LibName;
+function isc_create_blob2 (status_vector : PISC_STATUS;db_handle : PISC_DB_HANDLE;tran_handle : PISC_TR_HANDLE;blob_handle : PISC_BLOB_HANDLE;blob_id : PISC_QUAD;bpb_length : Short;bpb_address : PChar) : ISC_STATUS;stdcall; external LibName;
+function isc_create_database (status_vector : PISC_STATUS;isc_arg2 : Short;isc_arg3 : PChar;db_handle : PISC_DB_HANDLE;isc_arg5 : Short;isc_arg6 : PChar;isc_arg7 : Short) : ISC_STATUS;stdcall; external LibName;
+function isc_database_info (status_vector : PISC_STATUS;db_handle : PISC_DB_HANDLE;item_list_buffer_length : Short;item_list_buffer : PChar;result_buffer_length : Short;result_buffer : PChar) : ISC_STATUS;stdcall; external LibName;
+procedure isc_decode_date (ib_date : PISC_QUAD;tm_date : PCTimeStructure);stdcall; external LibName;
+function isc_detach_database (status_vector : PISC_STATUS;db_handle : PISC_DB_HANDLE) : ISC_STATUS;stdcall; external LibName;
+function isc_drop_database (status_vector : PISC_STATUS;db_handle : PISC_DB_HANDLE) : ISC_STATUS;stdcall; external LibName;
+function SQLDA_LENGTH (n : Long) : Long;function XSQLDA_LENGTH (n : Long) : Long;function isc_dsql_allocate_statement (status_vector : PISC_STATUS;db_handle : PISC_DB_HANDLE;stmt_handle : PISC_STMT_HANDLE) : ISC_STATUS;stdcall; external LibName;
+function isc_dsql_alloc_statement2 (status_vector : PISC_STATUS;db_handle : PISC_DB_HANDLE;stmt_handle : PISC_STMT_HANDLE) : ISC_STATUS;stdcall; external LibName;
+function isc_dsql_describe (status_vector : PISC_STATUS;stmt_handle : PISC_STMT_HANDLE;dialect : UShort;xsqlda : PXSQLDA) : ISC_STATUS;stdcall; external LibName;
+function isc_dsql_describe_bind (status_vector : PISC_STATUS;stmt_handle : PISC_STMT_HANDLE;dialect : UShort;xsqlda : PXSQLDA) : ISC_STATUS;stdcall; external LibName;
+function isc_dsql_exec_immed2 (status_vector : PISC_STATUS;db_handle : PISC_DB_HANDLE;tran_handle : PISC_TR_HANDLE;length : UShort;statement : PChar;dialect : UShort;in_xsqlda,out_xsqlda : PXSQLDA) : ISC_STATUS;stdcall; external LibName;
+function isc_dsql_execute (status_vector : PISC_STATUS;tran_handle : PISC_TR_HANDLE;stmt_handle : PISC_STMT_HANDLE;dialect : UShort;xsqlda : PXSQLDA) : ISC_STATUS;stdcall; external LibName;
+function isc_dsql_execute2 (status_vector : PISC_STATUS;tran_handle : PISC_TR_HANDLE;stmt_handle : PISC_STMT_HANDLE;dialect : UShort;in_xsqlda,out_xsqlda : PXSQLDA) : ISC_STATUS;stdcall; external LibName;
+function isc_dsql_execute_immediate (status_vector : PISC_STATUS;db_handle : PISC_DB_HANDLE;tran_handle : PISC_TR_HANDLE;length : UShort;statement : PChar;dialect : UShort;xsqlda : PXSQLDA) : ISC_STATUS;stdcall; external LibName;
+function isc_dsql_fetch (status_vector : PISC_STATUS;stmt_handle : PISC_STMT_HANDLE;dialect : UShort;xsqlda : PXSQLDA) : ISC_STATUS;stdcall; external LibName;
+function isc_dsql_finish (db_handle : PISC_DB_HANDLE) : ISC_STATUS;stdcall; external LibName;
+function isc_dsql_free_statement (status_vector : PISC_STATUS;stmt_handle : PISC_STMT_HANDLE;options : UShort) : ISC_STATUS; stdcall; external LibName;
+function isc_dsql_insert (status_vector : PISC_STATUS;stmt_handle : PISC_STMT_HANDLE;arg3 : UShort;xsqlda : PXSQLDA) : ISC_STATUS;stdcall; external LibName;
+function isc_dsql_prepare (status_vector : PISC_STATUS;tran_handle : PISC_TR_HANDLE;stmt_handle : PISC_STMT_HANDLE;length : UShort;statement : PChar;dialect : UShort;xsqlda : PXSQLDA) : ISC_STATUS;stdcall; external LibName;
+function isc_dsql_set_cursor_name (status_vector : PISC_STATUS;stmt_handle : PISC_STMT_HANDLE;cursor_name : PChar;_type : UShort) : ISC_STATUS;stdcall; external LibName;
+function isc_dsql_sql_info (status_vector : PISC_STATUS;stmt_handle : PISC_STMT_HANDLE;item_length : UShort; items : PChar;buffer_length : UShort; buffer : PChar) : ISC_STATUS;stdcall; external LibName;
+procedure isc_encode_date (tm_date : PCTimeStructure;ib_date : PISC_QUAD);stdcall; external LibName;
+function  isc_event_block (event_buffer : PPChar;result_buffer : PPChar;id_count : UShort;event_list : array of PChar) : ISC_LONG;cdecl; external LibName;
+procedure isc_event_counts (status_vector : PISC_STATUS;buffer_length : Short;event_buffer : PChar;result_buffer : PChar);stdcall; external LibName;
+procedure isc_expand_dpb (dpb : PPChar;dpb_length : PShort;item_list : array of Pointer);cdecl; external LibName;
+function isc_modify_dpb (dpb : PPChar;isc_arg2,isc_arg3 : PShort;isc_arg4 : UShort;isc_arg5 : PChar;isc_arg6 : Short) : Int;stdcall; external LibName;
+function isc_free (isc_arg1 : PChar) : ISC_LONG;stdcall; external LibName;
+function isc_get_segment (status_vector : PISC_STATUS;blob_handle : PISC_BLOB_HANDLE;actual_seg_length : PUShort;seg_buffer_length : UShort;seg_buffer : PChar) : ISC_STATUS;stdcall; external LibName;
+function isc_get_slice (status_vector : PISC_STATUS;db_handle : PISC_DB_HANDLE;tran_handle : PISC_TR_HANDLE;isc_arg4 : PISC_QUAD;isc_arg5 : Short;isc_arg6 : PChar;isc_arg7 : Short;isc_arg8 : PISC_LONG;isc_arg9 : ISC_LONG;isc_arg10 : PVoid;isc_arg11 : PISC_LONG) : ISC_STATUS;stdcall; external LibName;
+function isc_interprete (buffer : PChar;status_vector : PPISC_STATUS) : ISC_STATUS;stdcall; external LibName;
+function isc_open_blob (status_vector : PISC_STATUS;db_handle : PISC_DB_HANDLE;tran_handle : PISC_TR_HANDLE;blob_handle : PISC_BLOB_HANDLE;blob_id : PISC_QUAD) : ISC_STATUS;stdcall; external LibName;
+function isc_open_blob2 (status_vector : PISC_STATUS;db_handle : PISC_DB_HANDLE;tran_handle : PISC_TR_HANDLE;blob_handle : PISC_BLOB_HANDLE;blob_id : PISC_QUAD;bpb_length : Short;bpb_buffer : PChar) : ISC_STATUS;stdcall; external LibName;
+function isc_prepare_transaction2 (status_vector : PISC_STATUS;tran_handle : PISC_TR_HANDLE;msg_length : Short;msg : PChar) : ISC_STATUS;stdcall; external LibName;
+procedure isc_print_sqlerror (sqlcode : Short;status_vector : PISC_STATUS);stdcall; external LibName;
+function isc_print_status (status_vector : PISC_STATUS) : ISC_STATUS;stdcall; external LibName;
+function isc_put_segment (status_vector : PISC_STATUS;blob_handle : PISC_BLOB_HANDLE;seg_buffer_len : UShort;seg_buffer : PChar) : ISC_STATUS;stdcall; external LibName;
+function isc_put_slice (status_vector : PISC_STATUS;db_handle : PISC_DB_HANDLE;tran_handle : PISC_TR_HANDLE;isc_arg4 : PISC_QUAD;isc_arg5 : Short;isc_arg6 : PChar;isc_arg7 : Short;isc_arg8 : PISC_LONG;isc_arg9 : ISC_LONG;isc_arg10 : PVoid) : ISC_STATUS;stdcall; external LibName;
+function isc_que_events (status_vector : PISC_STATUS;db_handle : PISC_DB_HANDLE;event_id : PISC_LONG;length : Short;event_buffer : PChar;event_function : TISC_CALLBACK;event_function_arg : PVoid) : ISC_STATUS;stdcall; external LibName;
+function isc_rollback_transaction (status_vector : PISC_STATUS;tran_handle : PISC_TR_HANDLE) : ISC_STATUS;stdcall; external LibName;
+function isc_start_multiple (status_vector : PISC_STATUS;tran_handle : PISC_TR_HANDLE;db_handle_count : Short;teb_vector_address : PISC_TEB) : ISC_STATUS;stdcall; external LibName;
+function isc_start_transaction (status_vector : PISC_STATUS;tran_handle : PISC_TR_HANDLE;db_handle_count : Short;db_handle : PISC_DB_HANDLE;tpb_length : UShort;tpb_address : PChar) : ISC_STATUS;cdecl; external LibName;
+function isc_sqlcode (status_vector : PISC_STATUS) : ISC_LONG;stdcall; external LibName;
+procedure isc_sql_interprete (sqlcode : Short;buffer : PChar;buffer_length : Short);stdcall; external LibName;
+function isc_transaction_info (status_vector : PISC_STATUS;tran_handle : PISC_TR_HANDLE;item_list_buffer_length : Short;item_list_buffer : PChar;result_buffer_length : Short;result_buffer : PChar) : ISC_STATUS;stdcall; external LibName;
+function isc_transact_request (status_vector : PISC_STATUS;db_handle : PISC_DB_HANDLE;tran_handle : PISC_TR_HANDLE;isc_arg4 : UShort;isc_arg5 : PChar;isc_arg6 : UShort;isc_arg7 : PChar;isc_arg8 : UShort;isc_arg9 : PChar) : ISC_STATUS;stdcall; external LibName;
+function isc_vax_integer (buffer : PChar;length : Short) : ISC_LONG;stdcall; external LibName;
+function isc_add_user (status_vector : PISC_STATUS;user_sec_data : PUserSecData) : ISC_STATUS;stdcall; external LibName;
+function isc_delete_user (status_vector : PISC_STATUS;user_sec_data : PUserSecData) : ISC_STATUS;stdcall; external LibName;
+function isc_modify_user (status_vector : PISC_STATUS;user_sec_data : PUserSecData) : ISC_STATUS;stdcall; external LibName;
+function isc_compile_request (status_vector : PISC_STATUS;db_handle : PISC_DB_HANDLE;request_handle : PISC_REQ_HANDLE;isc_arg4 : Short;isc_arg5 : PChar) : ISC_STATUS;stdcall; external LibName;
+function isc_compile_request2 (status_vector : PISC_STATUS;db_handle : PISC_DB_HANDLE;request_handle : PISC_REQ_HANDLE;isc_arg4 : Short;isc_arg5 : PChar) : ISC_STATUS;stdcall; external LibName;
+function isc_ddl (status_vector : PISC_STATUS;db_handle : PISC_DB_HANDLE;tran_handle : PISC_TR_HANDLE;isc_arg4 : Short;isc_arg5 : PChar) : ISC_STATUS;stdcall; external LibName;
+function isc_prepare_transaction (status_vector : PISC_STATUS;tran_handle : PISC_TR_HANDLE) : ISC_STATUS;stdcall; external LibName;
+function isc_receive (status_vector : PISC_STATUS;request_handle : PISC_REQ_HANDLE;isc_arg3,isc_arg4 : Short;isc_arg5 : PVoid;isc_arg6 : Short) : ISC_STATUS;stdcall; external LibName;{$ifndef fpc}function isc_receive2 (status_vector : PISC_STATUS;request_handle : PISC_REQ_HANDLE;isc_arg3,isc_arg4 : Short;isc_arg5 : PVoid;isc_arg6,isc_arg7 : Short;isc_arg8 : Long) : ISC_STATUS;stdcall; external LibName;{$endif}
+function isc_reconnect_transaction (status_vector : PISC_STATUS;db_handle : PISC_DB_HANDLE;tran_handle : PISC_TR_HANDLE;isc_arg4 : Short;isc_arg5 : PChar) : ISC_STATUS;stdcall; external LibName;
+function isc_release_request (status_vector : PISC_STATUS;request_handle : PISC_REQ_HANDLE) : ISC_STATUS;stdcall; external LibName;
+function isc_request_info (status_vector : PISC_STATUS;request_handle : PISC_REQ_HANDLE;isc_arg3 : Short;isc_arg4 : Short;isc_arg5 : PChar;isc_arg6 : Short;isc_arg7 : PChar) : ISC_STATUS;stdcall; external LibName;
+function isc_seek_blob (status_vector : PISC_STATUS;blob_handle : PISC_BLOB_HANDLE;isc_arg3 : Short;isc_arg4 : ISC_LONG;isc_arg5 : PISC_LONG) : ISC_STATUS;stdcall; external LibName;
+function isc_send (status_vector : PISC_STATUS;request_handle : PISC_REQ_HANDLE;isc_arg3,isc_arg4 : Short;isc_arg5 : PVoid;isc_arg6 : Short) : ISC_STATUS;stdcall; external LibName;
+function isc_start_and_send (status_vector : PISC_STATUS;request_handle : PISC_REQ_HANDLE;tran_handle : PISC_TR_HANDLE;isc_arg4,isc_arg5 : Short;isc_arg6 : PVoid;isc_arg7 : Short) : ISC_STATUS;stdcall; external LibName;
+function isc_start_request (status_vector : PISC_STATUS;request_handle : PISC_REQ_HANDLE;tran_handle : PISC_TR_HANDLE;isc_arg4 : Short) : ISC_STATUS;stdcall; external LibName;
+function isc_unwind_request (status_vector : PISC_STATUS;tran_handle : PISC_TR_HANDLE;isc_arg3 : Short) : ISC_STATUS;stdcall; external LibName;
+function isc_wait_for_event (status_vector : PISC_STATUS;db_handle : PISC_DB_HANDLE;length : Short;event_buffer,result_buffer : PChar) : ISC_STATUS;stdcall; external LibName;
+function isc_close (status_vector : PISC_STATUS;isc_arg2 : PChar) : ISC_STATUS;stdcall; external LibName;
+function isc_declare (status_vector : PISC_STATUS;isc_arg2,isc_arg3 : PChar) : ISC_STATUS;stdcall; external LibName;
+function isc_describe (status_vector : PISC_STATUS;isc_arg2 : PChar;isc_arg3 : PSQLDA) : ISC_STATUS;stdcall; external LibName;
+function isc_describe_bind (status_vector : PISC_STATUS;isc_arg2 : PChar;isc_arg3 : PSQLDA) : ISC_STATUS;stdcall; external LibName;
+function isc_execute (status_vector : PISC_STATUS;tran_handle : PISC_TR_HANDLE;isc_arg3 : PChar;isc_arg4 : PSQLDA) : ISC_STATUS;stdcall; external LibName;
+function isc_execute_immediate (status_vector : PISC_STATUS;db_handle : PISC_DB_HANDLE;tran_handle : PISC_TR_HANDLE;isc_arg4 : PShort;isc_arg5 : PChar) : ISC_STATUS;stdcall; external LibName;
+function isc_fetch (status_vector : PISC_STATUS;isc_arg2 : PChar;isc_arg3 : PSQLDA) : ISC_STATUS;stdcall; external LibName;
+function isc_open (status_vector : PISC_STATUS;tran_handle : PISC_TR_HANDLE;isc_arg3 : PChar;isc_arg4 : PSQLDA) : ISC_STATUS;stdcall; external LibName;
+function isc_prepare (status_vector : PISC_STATUS;db_handle : PISC_DB_HANDLE;tran_handle : PISC_TR_HANDLE;isc_arg4 : PChar;isc_arg5 : PShort;isc_arg6 : PChar;isc_arg7 : PSQLDA) : ISC_STATUS;stdcall; external LibName;
+function isc_dsql_execute_m (status_vector : PISC_STATUS;tran_handle : PISC_TR_HANDLE;statement_handle : PISC_STMT_HANDLE;isc_arg4 : UShort;isc_arg5 : PChar;isc_arg6 : UShort;isc_arg7 : UShort;isc_arg8 : PChar) : ISC_STATUS;stdcall; external LibName;
+function isc_dsql_execute2_m (status_vector : PISC_STATUS;tran_handle : PISC_TR_HANDLE;statement_handle : PISC_STMT_HANDLE;isc_arg4 : UShort;isc_arg5 : PChar;isc_arg6 : UShort;isc_arg7 : UShort;isc_arg8 : PChar;isc_arg9 : UShort;isc_arg10 : PChar;isc_arg11 : UShort;isc_arg12 : UShort;isc_arg13 : PChar) : ISC_STATUS;stdcall; external LibName;
+function isc_dsql_execute_immediate_m (status_vector : PISC_STATUS;db_handle : PISC_DB_HANDLE;tran_handle : PISC_TR_HANDLE;isc_arg4 : UShort;isc_arg5 : PChar;isc_arg6 : UShort;isc_arg7 : UShort;isc_arg8 : PChar;isc_arg9 : UShort;isc_arg10 : UShort;isc_arg11 : PChar) : ISC_STATUS;stdcall; external LibName;
+function isc_dsql_exec_immed3_m (status_vector : PISC_STATUS;db_handle : PISC_DB_HANDLE;tran_handle : PISC_TR_HANDLE;isc_arg4 : UShort;isc_arg5 : PChar;isc_arg6 : UShort;isc_arg7 : UShort;isc_arg8 : PChar;isc_arg9 : UShort;isc_arg10 : UShort;isc_arg11 : PChar;isc_arg12 : UShort;isc_arg13 : PChar;isc_arg14 : UShort;isc_arg15 : UShort;isc_arg16 : PChar) : ISC_STATUS;stdcall; external LibName;
+function isc_dsql_fetch_m (status_vector : PISC_STATUS;statement_handle : PISC_STMT_HANDLE;isc_arg3 : UShort;isc_arg4 : PChar;isc_arg5 : UShort;isc_arg6 : UShort;isc_arg7 : PChar) : ISC_STATUS;stdcall; external LibName;
+function isc_dsql_insert_m (status_vector : PISC_STATUS;statement_handle : PISC_STMT_HANDLE;isc_arg3 : UShort;isc_arg4 : PChar;isc_arg5 : UShort;isc_arg6 : UShort;isc_arg7 : PChar) : ISC_STATUS;stdcall; external LibName;
+function isc_dsql_prepare_m (status_vector : PISC_STATUS;tran_handle : PISC_TR_HANDLE;statement_handle : PISC_STMT_HANDLE;isc_arg4 : UShort;isc_arg5 : PChar;isc_arg6 : UShort;isc_arg7 : UShort;isc_arg8 : PChar;isc_arg9 : UShort;isc_arg10 : PChar) : ISC_STATUS;stdcall; external LibName;
+function isc_dsql_release (status_vector : PISC_STATUS;isc_arg2 : PChar) : ISC_STATUS;stdcall; external LibName;
+function isc_embed_dsql_close (status_vector : PISC_STATUS;isc_arg2 : PChar) : ISC_STATUS;stdcall; external LibName;
+function isc_embed_dsql_declare (status_vector : PISC_STATUS;isc_arg2 : PChar;isc_arg3 : PChar) : ISC_STATUS;stdcall; external LibName;
+function isc_embed_dsql_describe (status_vector : PISC_STATUS;isc_arg2 : PChar;isc_arg3 : UShort;isc_arg4 : PXSQLDA) : ISC_STATUS;stdcall; external LibName;
+function isc_embed_dsql_describe_bind (status_vector : PISC_STATUS;isc_arg2 : PChar;isc_arg3 : UShort;isc_arg4 : PXSQLDA) : ISC_STATUS;stdcall; external LibName;
+function isc_embed_dsql_execute (status_vector : PISC_STATUS;tran_handle : PISC_TR_HANDLE;isc_arg3 : PChar;isc_arg4 : UShort;isc_arg5 : PXSQLDA) : ISC_STATUS;stdcall; external LibName;
+function isc_embed_dsql_execute2 (status_vector : PISC_STATUS;tran_handle : PISC_TR_HANDLE;isc_arg3 : PChar;isc_arg4 : UShort;isc_arg5 : PXSQLDA;isc_arg6 : PXSQLDA) : ISC_STATUS;stdcall; external LibName;
+function isc_embed_dsql_execute_immed (status_vector : PISC_STATUS;db_handle : PISC_DB_HANDLE;tran_handle : PISC_TR_HANDLE;isc_arg4 : UShort;isc_arg5 : PChar;isc_arg6 : UShort;isc_arg7 : PXSQLDA) : ISC_STATUS;stdcall; external LibName;
+function isc_embed_dsql_fetch (status_vector : PISC_STATUS;isc_arg2 : PChar;isc_arg3 : UShort;isc_arg4 : PXSQLDA) : ISC_STATUS;stdcall; external LibName;
+function isc_embed_dsql_open (status_vector : PISC_STATUS;tran_handle : PISC_TR_HANDLE;isc_arg3 : PChar;isc_arg4 : UShort;isc_arg5 : PXSQLDA) : ISC_STATUS;stdcall; external LibName;
+function isc_embed_dsql_open2 (status_vector : PISC_STATUS;tran_handle : PISC_TR_HANDLE;isc_arg3 : PChar;isc_arg4 : UShort;isc_arg5 : PXSQLDA;isc_arg6 : PXSQLDA) : ISC_STATUS;stdcall; external LibName;
+function isc_embed_dsql_insert (status_vector : PISC_STATUS;isc_arg2 : PChar;isc_arg3 : UShort;isc_arg4 : PXSQLDA) : ISC_STATUS;stdcall; external LibName;
+function isc_embed_dsql_prepare (status_vector : PISC_STATUS;db_handle : PISC_DB_HANDLE;tran_handle : PISC_TR_HANDLE;isc_arg4 : PChar;isc_arg5 : UShort;isc_arg6 : PChar;isc_arg7 : UShort;isc_arg8 : PXSQLDA) : ISC_STATUS;stdcall; external LibName;
+function isc_embed_dsql_release (status_vector : PISC_STATUS;isc_arg2 : PChar) : ISC_STATUS;stdcall; external LibName;
+function BLOB_open (blob_handle : TISC_BLOB_HANDLE;isc_arg2 : PChar;isc_arg3 : int) : PBSTREAM;stdcall; external LibName;
+function BLOB_put (isc_arg1 : char;isc_arg2 : PBSTREAM) : Int;stdcall; external LibName;
+function BLOB_close (isc_arg1 : PBSTREAM) : Int;stdcall; external LibName;
+function BLOB_get (isc_arg1 : PBSTREAM) : Int;stdcall; external LibName;
+function BLOB_display (isc_arg1 : PISC_QUAD;db_handle : TISC_DB_HANDLE;tran_handle : TISC_TR_HANDLE;isc_arg4 : PChar) : Int;stdcall; external LibName;
+function BLOB_dump (isc_arg1 : PISC_QUAD;db_handle : TISC_DB_HANDLE;tran_handle : TISC_TR_HANDLE;isc_arg4 : PChar) : Int;stdcall; external LibName;
+function BLOB_edit (isc_arg1 : PISC_QUAD;db_handle : TISC_DB_HANDLE;tran_handle : TISC_TR_HANDLE;isc_arg4 : PChar) : Int;stdcall; external LibName;
+function BLOB_load (isc_arg1 : PISC_QUAD;db_handle : TISC_DB_HANDLE;tran_handle : TISC_TR_HANDLE;isc_arg4 : PChar) : Int;stdcall; external LibName;
+function BLOB_text_dump (isc_arg1 : PISC_QUAD;db_handle : TISC_DB_HANDLE;tran_handle : TISC_TR_HANDLE;isc_arg4 : PChar) : Int;stdcall; external LibName;
+function BLOB_text_load (isc_arg1 : PISC_QUAD;db_handle : TISC_DB_HANDLE;tran_handle : TISC_TR_HANDLE;isc_arg4 : PChar) : Int;stdcall; external LibName;
+function Bopen (isc_arg1 : PISC_QUAD;db_handle : TISC_DB_HANDLE;tran_handle : TISC_TR_HANDLE;isc_arg4 : PChar) : Int;stdcall; external LibName;
+function isc_ftof (isc_arg1 : PChar;isc_arg2 : UShort;isc_arg3 : PChar;isc_arg4 : UShort) : ISC_LONG;stdcall; external LibName;
+function isc_print_blr (isc_arg1 : PChar;isc_arg2 : TISC_CALLBACK;isc_arg3 : PVoid;isc_arg4 : Short) : ISC_STATUS;stdcall; external LibName;
+procedure isc_set_debug (isc_arg1 : Int);stdcall; external LibName;
+procedure isc_qtoq (isc_arg1 : PISC_QUAD;isc_arg2 : PISC_QUAD);stdcall; external LibName;
+procedure isc_vtof (isc_arg1 : PChar;isc_arg2 : PChar;isc_arg3 : UShort);stdcall; external LibName;
+procedure isc_vtov (isc_arg1 : PChar;isc_arg2 : PChar;isc_arg3 : Short);stdcall; external LibName;
+function isc_version (db_handle : PISC_DB_HANDLE;isc_arg2 : TISC_CALLBACK;isc_arg3 : PVoid) : Int;stdcall; external LibName;
+function isc_attach_service (status_vector : PISC_STATUS;isc_arg2 : UShort;isc_arg3 : PChar;service_handle : PISC_SVC_HANDLE;isc_arg5 : UShort;isc_arg6 : PChar) : ISC_STATUS;stdcall; external LibName;
+function isc_detach_service (status_vector : PISC_STATUS;service_handle : PISC_SVC_HANDLE) : ISC_STATUS;stdcall; external LibName;
+function isc_query_service (status_vector : PISC_STATUS;service_handle : PISC_SVC_HANDLE;isc_arg3 : UShort;isc_arg4 : PChar;isc_arg5 : UShort;isc_arg6 : PChar;isc_arg7 : UShort;isc_arg8 : PChar) : ISC_STATUS;stdcall; external LibName;
+
+{$ifdef IB_CURSORS}
+function isc_embed_dsql_fetch2 (status_vector : PISC_STATUS;isc_arg2 : PChar;isc_arg3 : UShort;isc_arg4 : PXSQLDA;isc_arg5 : UShort;isc_arg6 : Long) : ISC_STATUS;stdcall; external LibName;
+function isc_dsql_fetch2 (status_vector : PISC_STATUS;stmt_handle : PISC_STMT_HANDLE;dialect : UShort;xsqlda : PXSQLDA;isc_arg5 : UShort;isc_arg6 : Long) : ISC_STATUS;stdcall; external LibName;
+function isc_dsql_fetch2_m (status_vector : PISC_STATUS;statement_handle : PISC_STMT_HANDLE;isc_arg3 : UShort;isc_arg4 : PChar;isc_arg5 : UShort;isc_arg6 : UShort;isc_arg7 : PChar;isc_arg8 : UShort;isc_arg9 : Long) : ISC_STATUS;stdcall; external LibName;
+{$endif}
+
+{$ifdef IB_Extensions}
+function Bopen2 (isc_arg1 : PISC_QUAD;db_handle : TISC_DB_HANDLE;tran_handle : TISC_TR_HANDLE;isc_arg4 : PChar;isc_arg5 : UShort) : PBSTREAM;stdcall; external LibName;
+function isc_reset_fpe (isc_arg1 : UShort) : ISC_LONG;stdcall; external LibName;
+function isc_compile_map (status_vector : PISC_STATUS;form_handle : PISC_FORM_HANDLE;request_handle : PISC_REQ_HANDLE;isc_arg4 : PShort;isc_arg5 : PChar) : ISC_STATUS;stdcall; external LibName;
+function isc_compile_menu (status_vector : PISC_STATUS;form_handle : PISC_FORM_HANDLE;request_handle : PISC_REQ_HANDLE;isc_arg4 : PShort;isc_arg5 : PChar) : ISC_STATUS;stdcall; external LibName;
+function isc_compile_sub_map (status_vector : PISC_STATUS;win_handle : PISC_WIN_HANDLE;request_handle : PISC_REQ_HANDLE;isc_arg4 : PShort;isc_arg5 : PChar) : ISC_STATUS;stdcall; external LibName;
+function isc_create_window (status_vector : PISC_STATUS;win_handle : PISC_WIN_HANDLE;isc_arg3 : PShort;isc_arg4 : PChar;isc_arg5 : PShort;isc_arg6 : PShort) : ISC_STATUS;stdcall; external LibName;
+function isc_delete_window (status_vector : PISC_STATUS;win_handle : PISC_WIN_HANDLE) : ISC_STATUS;stdcall; external LibName;
+function isc_drive_form (status_vector : PISC_STATUS;db_handle : PISC_DB_HANDLE;tran_handle : PISC_TR_HANDLE;win_handle : PISC_WIN_HANDLE;request_handle : PISC_REQ_HANDLE;isc_arg6 : PUChar;isc_arg7 : PUChar) : ISC_STATUS;stdcall; external LibName;
+function isc_drive_menu (status_vector : PISC_STATUS;win_handle : PISC_WIN_HANDLE;request_handle : PISC_REQ_HANDLE;isc_arg4 : PShort;isc_arg5 : PChar;isc_arg6 : PShort;isc_arg7 : PChar;isc_arg8 : PShort;isc_arg9 : PShort;isc_arg10 : PChar;isc_arg11 : PISC_LONG) : ISC_STATUS;stdcall; external LibName;
+function isc_form_delete (status_vector : PISC_STATUS;form_handle : PISC_FORM_HANDLE) : ISC_STATUS;stdcall; external LibName;
+function isc_form_fetch (status_vector : PISC_STATUS;db_handle : PISC_DB_HANDLE;tran_handle : PISC_TR_HANDLE;request_handle : PISC_REQ_HANDLE;isc_arg5 : PUChar) : ISC_STATUS;stdcall; external LibName;
+function isc_form_insert (status_vector : PISC_STATUS;db_handle : PISC_DB_HANDLE;tran_handle : PISC_TR_HANDLE;request_handle : PISC_REQ_HANDLE;isc_arg5 : PUChar) : ISC_STATUS;stdcall; external LibName;
+function isc_get_entree (status_vector : PISC_STATUS;request_handle : PISC_REQ_HANDLE;isc_arg3 : PShort;isc_arg4 : PChar;isc_arg5 : PISC_LONG;isc_arg6 : PShort) : ISC_STATUS;stdcall; external LibName;
+function isc_initialize_menu (status_vector : PISC_STATUS;request_handle : PISC_REQ_HANDLE) : ISC_STATUS;stdcall; external LibName;
+function isc_menu (status_vector : PISC_STATUS;win_handle : PISC_WIN_HANDLE;request_handle : PISC_REQ_HANDLE;isc_arg4 : PShort;isc_arg5 : PChar) : ISC_STATUS;stdcall; external LibName;
+function isc_load_form (status_vector : PISC_STATUS;db_handle : PISC_DB_HANDLE;tran_handle : PISC_TR_HANDLE;form_handle : PISC_FORM_HANDLE;isc_arg5 : PShort;isc_arg6 : PChar) : ISC_STATUS;stdcall; external LibName;
+function isc_pop_window (status_vector : PISC_STATUS;win_handle : PISC_WIN_HANDLE) : ISC_STATUS;stdcall; external LibName;
+function isc_put_entree (status_vector : PISC_STATUS;request_handle : PISC_REQ_HANDLE;isc_arg3 : PShort;isc_arg4 : PChar;isc_arg5 : PISC_LONG) : ISC_STATUS;stdcall; external LibName;
+function isc_reset_form (status_vector : PISC_STATUS;request_handle : PISC_REQ_HANDLE) : ISC_STATUS;stdcall; external LibName;
+function isc_suspend_window (status_vector : PISC_STATUS;win_handle : PISC_WIN_HANDLE) : ISC_STATUS;stdcall; external LibName;
+{$endif}
+
+
+implementation
+
+function SQLDA_LENGTH(n: Long): Long;
+begin
+  SQLDA_LENGTH := sizeof(TSQLDA) + ((n - 1) * sizeof(TSQLVAR));
+end;
+
+
+function XSQLDA_LENGTH(n: Long): Long;
+begin
+  XSQLDA_LENGTH := SizeOf(TXSQLDA) + ((n - 1) * SizeOf(TXSQLVAR));
+end;
+
+
+function getb(p: PBSTREAM): Char;
+begin
+  Dec(p^.bstr_cnt);
+  if (p^.bstr_cnt >= 0) then
+    begin
+    getb := Chr(Byte(p^.bstr_ptr^) and 248);
+    Inc(p^.bstr_ptr);
+    end
+  else
+    getb := Char(BLOB_get(p));
+end;
+
+
+function putb(x: Char; p: PBSTREAM): Int;
+begin
+  Dec(p^.bstr_cnt);
+  if (x = Chr(Byte('n') - Byte('a'))) or (p^.bstr_cnt = 0) then
+    putb := BLOB_put(x, p)
+      else
+      begin    p^.bstr_ptr^ := Char(x);
+    putb := Byte(x);
+    Inc(p^.bstr_ptr^);
+  end;
+end;
+
+
+function putbx(x: Char; p: PBSTREAM): Int;
+begin  Dec(p^.bstr_cnt);
+  if (p^.bstr_cnt = 0) then
+    putbx := BLOB_put(x, p)
+  else
+    begin
+    p^.bstr_ptr^ := Char(x);
+    Inc(p^.bstr_ptr^);
+    putbx := Byte(x);
+  end;
+end;
+
+
+end.
+{
+  $Log$
+  Revision 1.1  2002-01-29 17:54:50  peter
+    * splitted to base and extra
+
+  Revision 1.3  2001/04/10 23:30:03  peter
+    * regenerated
+
+}

+ 2657 - 0
packages/base/ibase/ibase60.h

@@ -0,0 +1,2657 @@
+/*
+ *	MODULE:		ibase.h
+ *	DESCRIPTION:	OSRI entrypoints and defines
+ *
+ * copyright (c) 1998, 1999 by InterBase Software Corporation
+ */
+
+#ifndef _JRD_IBASE_H_
+#define _JRD_IBASE_H_
+
+#ifndef HARBOR_MERGE
+#define HARBOR_MERGE
+#endif
+
+#define isc_version4
+
+#define  ISC_TRUE	1
+#define  ISC_FALSE	0
+#if !(defined __cplusplus)
+#define  ISC__TRUE	ISC_TRUE
+#define  ISC__FALSE	ISC_FALSE
+#endif
+
+
+/*!!MVC
+#define  ISC_USHORT	unsigned short
+#define  ISC_STATUS	long
+!!MVC*/
+
+#define  DSQL_close     1
+#define  DSQL_drop      2
+
+
+/******************************************************************/
+/* Define type, export and other stuff based on c/c++ and Windows */
+/******************************************************************/
+
+/*!!MVC
+#if (defined(_MSC_VER) && defined(_WIN32)) || \
+    (defined(__BORLANDC__) && (defined(__WIN32__) || defined(__OS2__)))
+#define  ISC_FAR
+#define  ISC_EXPORT	__stdcall
+#define  ISC_EXPORT_VARARG	__cdecl
+typedef           __int64  ISC_INT64;
+typedef  unsigned __int64  ISC_UINT64;
+#define  ISC_INT64_DEFINED
+#else					
+#if (defined(__IBMC__) && defined(__OS2__))
+#define  ISC_FAR
+#define  ISC_EXPORT	_System
+#define  ISC_EXPORT_VARARG	ISC_EXPORT
+#else					
+#if ( defined( _Windows) || defined( _WINDOWS))
+#define  ISC_FAR	__far
+#define  ISC_EXPORT     ISC_FAR __cdecl __loadds __export
+#define  ISC_EXPORT_VARARG	ISC_EXPORT
+#else					
+#define  ISC_FAR
+#define  ISC_EXPORT
+#define  ISC_EXPORT_VARARG
+#endif
+#endif
+#endif
+!!MVC*/
+
+/*!!MVC
+  Removed all ISC_FAR, ISC_EXPORT_VARARG and ISC_EXPORT 
+  macros. 
+  They confuse h2pas...
+!!MVC*/
+
+/*******************************************************************/
+/* 64 bit Integers                                                 */
+/*******************************************************************/
+
+/*!!MVC
+#ifndef  ISC_INT64_DEFINED              
+typedef           long long int  ISC_INT64;	
+typedef  unsigned long long int  ISC_UINT64;	
+#else
+#undef  ISC_INT64_DEFINED
+#endif
+!!MVC*/
+
+/*******************************************************************/
+/* Time & Date Support                                             */
+/*******************************************************************/
+
+#ifndef _ISC_TIMESTAMP_
+typedef long		ISC_DATE;
+typedef unsigned long	ISC_TIME;
+typedef struct {
+    ISC_DATE 	timestamp_date;
+    ISC_TIME	timestamp_time;
+} ISC_TIMESTAMP;
+#define _ISC_TIMESTAMP_			1
+#endif
+
+#define ISC_TIME_SECONDS_PRECISION          10000L
+#define ISC_TIME_SECONDS_PRECISION_SCALE    -4
+
+/*******************************************************************/
+/* Blob id structure                                               */
+/*******************************************************************/
+
+/*!!MVC
+typedef struct {
+    ISC_LONG		gds_quad_high;
+    unsigned ISC_LONG	gds_quad_low;
+} GDS_QUAD;
+!!MVC*/
+
+#if !(defined __cplusplus)
+typedef GDS_QUAD	GDS__QUAD;
+#endif					/* !(defined __cplusplus) */
+
+#define	ISC_QUAD	GDS_QUAD
+#define	isc_quad_high	gds_quad_high
+#define	isc_quad_low	gds_quad_low
+
+typedef struct {
+    short       	array_bound_lower;
+    short       	array_bound_upper;
+} ISC_ARRAY_BOUND;
+
+typedef struct {
+    unsigned char       array_desc_dtype;
+    char                array_desc_scale;
+    unsigned short      array_desc_length;
+    char                array_desc_field_name [32];
+    char                array_desc_relation_name [32];
+    short               array_desc_dimensions;
+    short               array_desc_flags;
+    ISC_ARRAY_BOUND     array_desc_bounds [16];
+} ISC_ARRAY_DESC;
+
+typedef struct {
+    short               blob_desc_subtype;
+    short               blob_desc_charset;
+    short               blob_desc_segment_size;
+    unsigned char       blob_desc_field_name [32];
+    unsigned char       blob_desc_relation_name [32];
+} ISC_BLOB_DESC;
+
+
+/***************************/
+/* Blob control structure  */
+/***************************/
+
+typedef struct isc_blob_ctl{
+/*!!MVC
+    ISC_STATUS      ( *ctl_source)();
+!!MVC*/    	/* Source filter */
+/*!!MVC
+    struct isc_blob_ctl  *ctl_source_handle; 
+!!MVC*/ /* Argument to pass to source */
+						/* filter */
+    short		  ctl_to_sub_type;  	/* Target type */
+    short		  ctl_from_sub_type;	/* Source type */
+    unsigned short  	  ctl_buffer_length;	/* Length of buffer */
+    unsigned short  	  ctl_segment_length;  	/* Length of current segment */
+    unsigned short  	  ctl_bpb_length;	/* Length of blob parameter */
+					    	/* block */
+    char	   *ctl_bpb;		/* Address of blob parameter */ 
+						/* block */
+    unsigned char  *ctl_buffer;		/* Address of segment buffer */
+    ISC_LONG     	  ctl_max_segment;	/* Length of longest segment */
+    ISC_LONG	 	  ctl_number_segments; 	/* Total number of segments */
+    ISC_LONG  		  ctl_total_length;  	/* Total length of blob */
+    ISC_STATUS	   *ctl_status;		/* Address of status vector */
+    long		  ctl_data [8];	  	/* Application specific data */
+}  *ISC_BLOB_CTL;
+
+/***************************/
+/* Blob stream definitions */ 
+/***************************/
+
+typedef struct bstream {
+    void	 *bstr_blob;  	/* Blob handle */
+    char	 *bstr_buffer;	/* Address of buffer */
+    char	 *bstr_ptr;	/* Next character */
+    short	  bstr_length;		/* Length of buffer */
+    short	  bstr_cnt;		/* Characters in buffer */
+    char      	  bstr_mode;  		/* (mode) ? OUTPUT : INPUT */
+} BSTREAM;
+
+/*!!MVC
+
+#define getb(p)	(--(p)->bstr_cnt >= 0 ? *(p)->bstr_ptr++ & 0377: BLOB_get (p))
+#define putb(x,p) (((x) == '\n' || (!(--(p)->bstr_cnt))) ? BLOB_put ((x),p) : ((int) (*(p)->bstr_ptr++ = (unsigned) (x))))
+#define putbx(x,p) ((!(--(p)->bstr_cnt)) ? BLOB_put ((x),p) : ((int) (*(p)->bstr_ptr++ = (unsigned) (x))))
+
+!!MVC */
+
+/***************************/
+/* Dynamic SQL definitions */
+/***************************/
+ 
+/******************************/
+/* Declare the extended SQLDA */
+/******************************/
+
+typedef struct {
+    short	sqltype;		/* datatype of field */
+    short	sqlscale;		/* scale factor */
+    short	sqlsubtype;		/* datatype subtype - BLOBs & Text */
+					/* types only */
+    short	sqllen;			/* length of data area */
+    char   *sqldata;		/* address of data */
+    short  *sqlind;		/* address of indicator variable */
+    short  	sqlname_length;		/* length of sqlname field */
+    char	sqlname [32];		/* name of field, name length + space */
+					/* for NULL */
+    short	relname_length;		/* length of relation name */
+    char	relname [32];		/* field's relation name + space for */
+					/* NULL */
+    short	ownname_length;		/* length of owner name */
+    char	ownname [32];		/* relation's owner name + space for */
+					/* NULL */
+    short	aliasname_length; 	/* length of alias name */
+    char	aliasname [32];		/* relation's alias name + space for */
+					/* NULL */
+} XSQLVAR;
+
+typedef struct {
+    short	version;		/* version of this XSQLDA */
+    char	sqldaid [8];		/* XSQLDA name field */
+    ISC_LONG	sqldabc;		/* length in bytes of SQLDA */
+    short	sqln;			/* number of fields allocated */
+    short	sqld;			/* actual number of fields */
+    XSQLVAR	sqlvar [1];		/* first field address */
+} XSQLDA;
+
+#define XSQLDA_LENGTH(n)	(sizeof (XSQLDA) + ((n)-1) * sizeof (XSQLVAR))
+
+#define SQLDA_VERSION1			1
+
+#define SQL_DIALECT_V5			1/* meaning is same as DIALECT_xsqlda */
+#define SQL_DIALECT_V6_TRANSITION	2/* flagging anything that is delimited
+                                            by double quotes as an error and
+                                            flagging keyword DATE as an error */
+#define SQL_DIALECT_V6			3/* supports SQL delimited identifier,
+                                            SQLDATE/DATE, TIME, TIMESTAMP,
+                                            CURRENT_DATE, CURRENT_TIME,
+                                            CURRENT_TIMESTAMP, and 64-bit exact
+                                            numeric type */
+#define SQL_DIALECT_CURRENT		SQL_DIALECT_V6/* latest IB DIALECT */
+
+/********************************/
+/* InterBase Handle Definitions */
+/********************************/
+
+typedef void      *isc_att_handle;
+
+typedef void      *isc_blob_handle;
+typedef void      *isc_db_handle;
+typedef void      *isc_form_handle;
+typedef void      *isc_req_handle;
+typedef void      *isc_stmt_handle;
+typedef void      *isc_svc_handle;
+typedef void      *isc_tr_handle;
+typedef void      *isc_win_handle;
+typedef void    ( *isc_callback)();
+typedef ISC_LONG	 isc_resv_handle;
+
+/***************************/
+/* OSRI database functions */
+/***************************/
+
+/*!!MVC
+#if defined(__cplusplus) || defined(__STDC__) || defined(_Windows) || \
+    (defined(_MSC_VER) && defined(WIN32)) || defined( _WINDOWS) || \
+    (defined(__BORLANDC__) && (defined(__WIN32__) || defined(__OS2__))) || \
+    (defined(__IBMC__) && defined(__OS2__)) || defined(AIX_PPC)
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+!!MVC*/
+
+ISC_STATUS   isc_attach_database (ISC_STATUS  *, 
+					    short, 
+					    char  *, 
+					    isc_db_handle  *, 
+					    short, 
+					    char  *);
+
+ISC_STATUS   isc_array_gen_sdl (ISC_STATUS  *, 
+					  ISC_ARRAY_DESC  *,
+					  short  *, 
+					  char  *, 
+					  short  *);
+
+ISC_STATUS   isc_array_get_slice (ISC_STATUS  *, 
+					    isc_db_handle  *, 
+					    isc_tr_handle  *, 
+					    ISC_QUAD  *, 
+					    ISC_ARRAY_DESC  *, 
+					    void  *, 
+					    ISC_LONG  *);
+
+ISC_STATUS   isc_array_lookup_bounds (ISC_STATUS  *, 
+						isc_db_handle  *, 
+						isc_tr_handle  *, 
+						char  *,
+						char  *, 
+						ISC_ARRAY_DESC  *);
+
+ISC_STATUS   isc_array_lookup_desc (ISC_STATUS  *, 
+					      isc_db_handle  *,
+					      isc_tr_handle  *, 
+					      char  *, 
+					      char  *, 
+					      ISC_ARRAY_DESC  *);
+
+ISC_STATUS   isc_array_set_desc (ISC_STATUS  *, 
+					   char  *, 
+					   char  *,
+					   short  *, 
+					   short  *, 
+					   short  *, 
+					   ISC_ARRAY_DESC  *);
+
+ISC_STATUS   isc_array_put_slice (ISC_STATUS  *, 
+					    isc_db_handle  *, 
+					    isc_tr_handle  *, 
+					    ISC_QUAD  *, 
+					    ISC_ARRAY_DESC  *, 
+					    void  *, 
+					    ISC_LONG  *);
+
+void        isc_blob_default_desc (ISC_BLOB_DESC  *,
+                                        unsigned char  *,
+                                        unsigned char  *);
+
+ISC_STATUS  isc_blob_gen_bpb (ISC_STATUS  *,
+					ISC_BLOB_DESC  *,
+					ISC_BLOB_DESC  *,
+					unsigned short,
+					unsigned char  *,
+					unsigned short  *);
+
+ISC_STATUS   isc_blob_info (ISC_STATUS  *, 
+				      isc_blob_handle  *, 
+				      short,
+ 				      char  *, 
+				      short, 
+				      char  *);
+
+ISC_STATUS  isc_blob_lookup_desc (ISC_STATUS  *,
+					    isc_db_handle  *,
+					    isc_tr_handle  *,
+					    unsigned char  *,
+					    unsigned char  *,
+					    ISC_BLOB_DESC  *,
+					    unsigned char  *);
+
+ISC_STATUS  isc_blob_set_desc (ISC_STATUS  *,
+					 unsigned char  *,
+					 unsigned char  *,
+					 short,
+					 short,
+					 short,
+					 ISC_BLOB_DESC  *);
+
+ISC_STATUS   isc_cancel_blob (ISC_STATUS  *, 
+				        isc_blob_handle  *);
+
+ISC_STATUS   isc_cancel_events (ISC_STATUS  *, 
+					  isc_db_handle  *, 
+					  ISC_LONG  *);
+
+ISC_STATUS   isc_close_blob (ISC_STATUS  *, 
+				       isc_blob_handle  *);
+
+ISC_STATUS   isc_commit_retaining (ISC_STATUS  *, 
+					     isc_tr_handle  *);
+
+ISC_STATUS   isc_commit_transaction (ISC_STATUS  *, 
+					       isc_tr_handle  *);
+
+ISC_STATUS   isc_create_blob (ISC_STATUS  *, 
+					isc_db_handle  *, 
+					isc_tr_handle  *, 
+					isc_blob_handle  *, 
+					ISC_QUAD  *);
+
+ISC_STATUS   isc_create_blob2 (ISC_STATUS  *, 
+					 isc_db_handle  *, 
+					 isc_tr_handle  *, 
+					 isc_blob_handle  *, 
+					 ISC_QUAD  *, 
+					 short,  
+					 char  *); 
+
+ISC_STATUS   isc_create_database (ISC_STATUS  *, 
+					    short, 
+					    char  *, 
+					    isc_db_handle  *, 
+					    short, 
+					    char  *, 
+					    short);
+
+ISC_STATUS   isc_database_info (ISC_STATUS  *, 
+					  isc_db_handle  *, 
+					  short, 
+					  char  *, 
+					  short, 
+					  char  *);
+
+void         isc_decode_date (ISC_QUAD  *, 
+					void  *);
+
+void         isc_decode_sql_date (ISC_DATE  *, 
+					void  *);
+
+void         isc_decode_sql_time (ISC_TIME  *, 
+					void  *);
+
+void         isc_decode_timestamp (ISC_TIMESTAMP  *, 
+					void  *);
+
+ISC_STATUS   isc_detach_database (ISC_STATUS  *,  
+					    isc_db_handle  *);
+
+ISC_STATUS   isc_drop_database (ISC_STATUS  *,  
+					  isc_db_handle  *);
+
+ISC_STATUS   isc_dsql_allocate_statement (ISC_STATUS  *, 
+						    isc_db_handle  *, 
+						    isc_stmt_handle  *);
+
+ISC_STATUS   isc_dsql_alloc_statement2 (ISC_STATUS  *, 
+						  isc_db_handle  *, 
+						  isc_stmt_handle  *);
+
+ISC_STATUS   isc_dsql_describe (ISC_STATUS  *, 
+					  isc_stmt_handle  *, 
+					  unsigned short, 
+					  XSQLDA  *);
+
+ISC_STATUS   isc_dsql_describe_bind (ISC_STATUS  *, 
+					       isc_stmt_handle  *, 
+					       unsigned short, 
+					       XSQLDA  *);
+
+ISC_STATUS   isc_dsql_exec_immed2 (ISC_STATUS  *, 
+					     isc_db_handle  *, 
+					     isc_tr_handle  *, 
+					     unsigned short, 
+					     char  *, 
+					     unsigned short, 
+					     XSQLDA  *, 
+					     XSQLDA  *);
+
+ISC_STATUS   isc_dsql_execute (ISC_STATUS  *, 
+					 isc_tr_handle  *,
+					 isc_stmt_handle  *, 
+					 unsigned short, 
+					 XSQLDA  *);
+
+ISC_STATUS   isc_dsql_execute2 (ISC_STATUS  *, 
+					  isc_tr_handle  *,
+					  isc_stmt_handle  *, 
+					  unsigned short, 
+					  XSQLDA  *,
+					  XSQLDA  *);
+
+ISC_STATUS   isc_dsql_execute_immediate (ISC_STATUS  *, 
+						   isc_db_handle  *, 
+						   isc_tr_handle  *, 
+						   unsigned short, 
+						   char  *, 
+						   unsigned short, 
+						   XSQLDA  *);
+
+ISC_STATUS   isc_dsql_fetch (ISC_STATUS  *, 
+				       isc_stmt_handle  *, 
+				       unsigned short, 
+				       XSQLDA  *);
+
+ISC_STATUS   isc_dsql_finish (isc_db_handle  *);
+
+ISC_STATUS   isc_dsql_free_statement (ISC_STATUS  *, 
+						isc_stmt_handle  *, 
+						unsigned short);
+
+ISC_STATUS   isc_dsql_insert (ISC_STATUS  *, 
+				       isc_stmt_handle  *, 
+				       unsigned short, 
+				       XSQLDA  *);
+
+ISC_STATUS   isc_dsql_prepare (ISC_STATUS  *, 
+					 isc_tr_handle  *, 
+					 isc_stmt_handle  *, 
+					 unsigned short, 
+					 char  *, 
+					 unsigned short, 
+				 	 XSQLDA  *);
+
+ISC_STATUS   isc_dsql_set_cursor_name (ISC_STATUS  *, 
+						 isc_stmt_handle  *, 
+						 char  *, 
+						 unsigned short);
+
+ISC_STATUS   isc_dsql_sql_info (ISC_STATUS  *, 
+					  isc_stmt_handle  *, 
+					  short, 
+					  char  *, 
+					  short, 
+					  char  *);
+
+void         isc_encode_date (void  *, 
+					ISC_QUAD  *);
+
+void         isc_encode_sql_date (void  *, 
+					ISC_DATE  *);
+
+void         isc_encode_sql_time (void  *, 
+					ISC_TIME  *);
+
+void         isc_encode_timestamp (void  *, 
+					ISC_TIMESTAMP  *);
+
+ISC_LONG     isc_event_block (char  *  *, 
+					       char  *  *, 
+					       unsigned short, ...);
+
+/*!!MVC
+void         isc_event_counts (unsigned ISC_LONG  *, 
+					 short, 
+					 char  *,
+					 char  *);
+!!MVC*/
+
+void         isc_expand_dpb (char  *  *, 
+					      short  *, 
+					      ...);
+
+int         isc_modify_dpb (char  *  *, 
+					 short  *, unsigned short,
+					 char  *, short );
+
+ISC_LONG     isc_free (char  *);
+
+ISC_STATUS   isc_get_segment (ISC_STATUS  *, 
+				        isc_blob_handle  *, 
+				        unsigned short  *, 
+				        unsigned short, 
+				        char  *);
+
+ISC_STATUS   isc_get_slice (ISC_STATUS  *, 
+				      isc_db_handle  *, 
+				      isc_tr_handle  *, 
+ 				      ISC_QUAD  *, 
+ 				      short, 
+				      char  *, 
+				      short, 
+				      ISC_LONG  *, 
+				      ISC_LONG, 
+				      void  *, 
+				      ISC_LONG  *);
+
+ISC_STATUS   isc_interprete (char  *, 
+				       ISC_STATUS  *  *);
+
+ISC_STATUS   isc_open_blob (ISC_STATUS  *, 
+				      isc_db_handle  *, 
+				      isc_tr_handle  *, 
+				      isc_blob_handle  *, 
+				      ISC_QUAD  *);
+
+ISC_STATUS   isc_open_blob2 (ISC_STATUS  *, 
+				       isc_db_handle  *, 
+				       isc_tr_handle  *,
+				       isc_blob_handle  *, 
+				       ISC_QUAD  *, 
+				       short,  
+				       char  *);
+
+ISC_STATUS   isc_prepare_transaction2 (ISC_STATUS  *, 
+						 isc_tr_handle  *, 
+						 short, 
+						 char  *);
+
+void         isc_print_sqlerror (short, 
+					   ISC_STATUS  *);
+
+ISC_STATUS   isc_print_status (ISC_STATUS  *);
+
+ISC_STATUS   isc_put_segment (ISC_STATUS  *, 
+					isc_blob_handle  *, 
+					unsigned short, 
+					char  *);
+
+ISC_STATUS   isc_put_slice (ISC_STATUS  *, 
+				      isc_db_handle  *, 
+				      isc_tr_handle  *, 
+				      ISC_QUAD  *, 
+				      short, 
+				      char  *, 
+				      short, 
+				      ISC_LONG  *, 
+				      ISC_LONG, 
+				      void  *);
+
+ISC_STATUS   isc_que_events (ISC_STATUS  *, 
+				       isc_db_handle  *, 
+				       ISC_LONG  *, 
+				       short, 
+				       char  *, 
+				       isc_callback, 
+				       void  *);
+
+ISC_STATUS   isc_rollback_retaining (ISC_STATUS  *, 
+						 isc_tr_handle  *);
+
+ISC_STATUS   isc_rollback_transaction (ISC_STATUS  *, 
+						 isc_tr_handle  *);
+
+ISC_STATUS   isc_start_multiple (ISC_STATUS  *, 
+					   isc_tr_handle  *, 
+					   short, 
+					   void  *);
+
+ISC_STATUS   isc_start_transaction (ISC_STATUS  *, 
+						     isc_tr_handle  *,
+						     short, ...);
+
+ISC_LONG     isc_sqlcode (ISC_STATUS  *);
+
+void         isc_sql_interprete (short, 
+					   char  *, 
+					   short);
+
+ISC_STATUS   isc_transaction_info (ISC_STATUS  *,  
+					     isc_tr_handle  *, 
+					     short, 
+					     char  *, 
+					     short,  
+					     char  *);
+
+ISC_STATUS   isc_transact_request (ISC_STATUS  *,  
+					     isc_db_handle  *, 
+					     isc_tr_handle  *,
+					     unsigned short, 
+					     char  *, 
+					     unsigned short,  
+					     char  *,
+					     unsigned short,
+					     char  *);
+
+ISC_LONG     isc_vax_integer (char  *, 
+					short);
+
+ISC_INT64    isc_portable_integer  (unsigned char  *,
+                                              short);
+
+/*************************************/
+/* Security Functions and structures */
+/*************************************/
+
+#define sec_uid_spec		    0x01
+#define sec_gid_spec		    0x02
+#define sec_server_spec		    0x04
+#define sec_password_spec	    0x08
+#define sec_group_name_spec	    0x10
+#define sec_first_name_spec	    0x20
+#define sec_middle_name_spec        0x40
+#define sec_last_name_spec	    0x80
+#define sec_dba_user_name_spec      0x100
+#define sec_dba_password_spec       0x200
+
+#define sec_protocol_tcpip            1
+#define sec_protocol_netbeui          2
+#define sec_protocol_spx              3
+#define sec_protocol_local            4
+
+typedef struct {
+    short  sec_flags;		     /* which fields are specified */
+    int    uid;			     /* the user's id */
+    int	   gid;			     /* the user's group id */
+    int    protocol;		     /* protocol to use for connection */
+    char    *server;          /* server to administer */
+    char    *user_name;       /* the user's name */
+    char    *password;        /* the user's password */
+    char    *group_name;      /* the group name */
+    char    *first_name;	     /* the user's first name */
+    char    *middle_name;     /* the user's middle name */
+    char    *last_name;	     /* the user's last name */
+    char    *dba_user_name;   /* the dba user name */
+    char    *dba_password;    /* the dba password */
+} USER_SEC_DATA;
+
+int  isc_add_user (ISC_STATUS  *, USER_SEC_DATA *);
+
+int  isc_delete_user (ISC_STATUS  *, USER_SEC_DATA *);
+
+int  isc_modify_user (ISC_STATUS  *, USER_SEC_DATA *);
+
+/**********************************/
+/*  Other OSRI functions          */
+/**********************************/
+                                          
+ISC_STATUS   isc_compile_request (ISC_STATUS  *, 
+					    isc_db_handle  *,
+		  			    isc_req_handle  *, 
+					    short, 
+					    char  *);
+
+ISC_STATUS   isc_compile_request2 (ISC_STATUS  *, 
+					     isc_db_handle  *,
+					     isc_req_handle  *, 
+					     short, 
+					     char  *);
+
+ISC_STATUS   isc_ddl (ISC_STATUS  *,
+			        isc_db_handle  *, 
+			        isc_tr_handle  *,
+			        short, 
+			        char  *);
+
+ISC_STATUS   isc_prepare_transaction (ISC_STATUS  *, 
+						isc_tr_handle  *);
+
+
+ISC_STATUS   isc_receive (ISC_STATUS  *, 
+				    isc_req_handle  *, 
+				    short, 
+			 	    short, 
+				    void  *, 
+				    short);
+
+ISC_STATUS   isc_reconnect_transaction (ISC_STATUS  *,
+						  isc_db_handle  *, 
+						  isc_tr_handle  *, 
+						  short, 
+						  char  *);
+
+ISC_STATUS   isc_release_request (ISC_STATUS  *, 
+					    isc_req_handle  *);
+
+ISC_STATUS   isc_request_info (ISC_STATUS  *,  
+					 isc_req_handle  *, 
+					 short, 
+	  				 short, 
+					 char  *, 
+					 short, 
+					 char  *);	 
+
+ISC_STATUS   isc_seek_blob (ISC_STATUS  *, 
+				      isc_blob_handle  *, 
+				      short, 
+				      ISC_LONG, 
+				      ISC_LONG  *);
+
+ISC_STATUS   isc_send (ISC_STATUS  *, 
+				 isc_req_handle  *, 
+				 short, 
+				 short,
+				 void  *, 
+				 short);
+
+ISC_STATUS   isc_start_and_send (ISC_STATUS  *, 
+					   isc_req_handle  *, 
+					   isc_tr_handle  *, 
+					   short, 
+					   short, 
+					   void  *, 
+					   short);
+
+ISC_STATUS   isc_start_request (ISC_STATUS  *, 
+					  isc_req_handle  *,
+					  isc_tr_handle  *,
+					  short);
+
+ISC_STATUS   isc_unwind_request (ISC_STATUS  *, 
+					   isc_tr_handle  *,
+					   short);
+
+ISC_STATUS   isc_wait_for_event (ISC_STATUS  *, 
+					   isc_db_handle  *, 
+					   short, 
+					   char  *, 
+					   char  *);
+
+/*****************************/
+/* Other Sql functions       */
+/*****************************/
+
+ISC_STATUS   isc_close (ISC_STATUS  *, 
+				  char  *);
+
+ISC_STATUS   isc_declare (ISC_STATUS  *, 
+				    char  *, 
+				    char  *);
+
+ISC_STATUS   isc_describe (ISC_STATUS  *, 
+				    char  *, 
+				    XSQLDA  *);
+
+ISC_STATUS   isc_describe_bind (ISC_STATUS  *, 
+					  char  *, 
+					  XSQLDA  *);
+
+ISC_STATUS   isc_execute (ISC_STATUS  *, 
+				    isc_tr_handle  *, 
+				    char  *, 
+				    XSQLDA  *);
+
+ISC_STATUS   isc_execute_immediate (ISC_STATUS  *, 
+					      isc_db_handle  *,
+					      isc_tr_handle  *, 
+					      short  *, 
+					      char  *);
+
+ISC_STATUS   isc_fetch (ISC_STATUS  *, 
+				  char  *, 
+				  XSQLDA  *);
+
+ISC_STATUS   isc_open (ISC_STATUS  *, 
+				 isc_tr_handle  *, 
+				 char  *, 
+				 XSQLDA  *);
+
+ISC_STATUS   isc_prepare (ISC_STATUS  *, 
+				    isc_db_handle  *, 
+				    isc_tr_handle  *, 
+				    char  *, 
+				    short  *, 
+				    char  *, 
+				    XSQLDA  *);
+
+/*************************************/
+/* Other Dynamic sql functions       */
+/*************************************/
+
+ISC_STATUS   isc_dsql_execute_m (ISC_STATUS  *, 
+					   isc_tr_handle  *,
+					   isc_stmt_handle  *, 
+					   unsigned short, 
+					   char  *, 
+					   unsigned short, 
+					   unsigned short, 
+					   char  *);
+
+ISC_STATUS   isc_dsql_execute2_m (ISC_STATUS  *, 
+					   isc_tr_handle  *,
+					   isc_stmt_handle  *, 
+					   unsigned short, 
+					   char  *, 
+					   unsigned short, 
+					   unsigned short, 
+					   char  *,
+					   unsigned short, 
+					   char  *, 
+					   unsigned short, 
+					   unsigned short, 
+					   char  *);
+
+ISC_STATUS   isc_dsql_execute_immediate_m (ISC_STATUS  *, 
+						     isc_db_handle  *, 
+						     isc_tr_handle  *, 
+						     unsigned short, 
+						     char  *, 
+						     unsigned short, 
+						     unsigned short, 
+						     char  *,
+						     unsigned short,
+						     unsigned short,
+						     char  *);
+
+ISC_STATUS   isc_dsql_exec_immed3_m (ISC_STATUS  *, 
+					       isc_db_handle  *, 
+					       isc_tr_handle  *, 
+					       unsigned short, 
+					       char  *, 
+					       unsigned short, 
+					       unsigned short, 
+					       char  *,
+					       unsigned short,
+					       unsigned short,
+					       char  *,
+					       unsigned short, 
+					       char  *,
+					       unsigned short,
+					       unsigned short,
+					       char  *);
+
+ISC_STATUS   isc_dsql_fetch_m (ISC_STATUS  *, 
+					 isc_stmt_handle  *, 
+					 unsigned short, 
+					 char  *, 
+					 unsigned short, 
+					 unsigned short, 
+					 char  *);
+
+ISC_STATUS   isc_dsql_insert_m (ISC_STATUS  *, 
+					  isc_stmt_handle  *, 
+					  unsigned short, 
+					  char  *, 
+					  unsigned short, 
+					  unsigned short, 
+					  char  *);
+
+ISC_STATUS   isc_dsql_prepare_m (ISC_STATUS  *, 
+					   isc_tr_handle  *,
+				 	   isc_stmt_handle  *, 
+					   unsigned short,  
+					   char  *, 
+					   unsigned short,
+					   unsigned short, 
+				  	   char  *, 
+				 	   unsigned short,
+					   char  *);
+
+ISC_STATUS   isc_dsql_release (ISC_STATUS  *, 
+					 char  *);
+
+ISC_STATUS   isc_embed_dsql_close (ISC_STATUS  *, 
+					     char  *);
+
+ISC_STATUS   isc_embed_dsql_declare (ISC_STATUS  *, 
+					      char  *, 
+					      char  *);
+
+ISC_STATUS   isc_embed_dsql_describe (ISC_STATUS  *, 
+						char  *, 
+						unsigned short, 
+						XSQLDA  *);
+
+ISC_STATUS   isc_embed_dsql_describe_bind (ISC_STATUS  *, 
+						     char  *, 
+						     unsigned short, 
+						     XSQLDA  *);
+
+ISC_STATUS   isc_embed_dsql_execute (ISC_STATUS  *, 
+					       isc_tr_handle  *,
+					       char  *, 
+					       unsigned short, 
+					       XSQLDA  *);
+
+ISC_STATUS   isc_embed_dsql_execute2 (ISC_STATUS  *,
+						isc_tr_handle  *,
+						char  *,
+						unsigned short,
+						XSQLDA  *,
+						XSQLDA  *);
+
+ISC_STATUS   isc_embed_dsql_execute_immed (ISC_STATUS  *, 
+						     isc_db_handle  *, 
+						     isc_tr_handle  *, 
+						     unsigned short, 
+						     char  *, 	
+						     unsigned short, 
+						     XSQLDA  *);
+
+ISC_STATUS   isc_embed_dsql_fetch (ISC_STATUS  *, 
+					     char  *, 
+					     unsigned short, 
+					     XSQLDA  *);
+
+ISC_STATUS   isc_embed_dsql_open (ISC_STATUS  *, 
+					    isc_tr_handle  *, 
+					    char  *, 
+					    unsigned short, 
+					    XSQLDA  *);
+
+ISC_STATUS   isc_embed_dsql_open2 (ISC_STATUS  *, 
+					     isc_tr_handle  *, 
+					     char  *, 
+					     unsigned short, 
+					     XSQLDA  *,
+					     XSQLDA  *);
+
+ISC_STATUS   isc_embed_dsql_insert (ISC_STATUS  *, 
+					      char  *, 
+					      unsigned short, 
+					      XSQLDA  *);
+
+ISC_STATUS   isc_embed_dsql_prepare (ISC_STATUS  *, 
+					       isc_db_handle  *,
+					       isc_tr_handle  *, 
+					       char  *, 
+					       unsigned short, 
+					       char  *, 
+					       unsigned short, 
+					       XSQLDA  *);
+
+ISC_STATUS   isc_embed_dsql_release (ISC_STATUS  *, 
+					       char  *);
+
+/******************************/
+/* Other Blob functions       */
+/******************************/
+
+BSTREAM      *  BLOB_open (isc_blob_handle,  
+				        char  *,  
+				        int);
+
+int  	     BLOB_put (char, 
+				 BSTREAM  *);
+
+int  	     BLOB_close (BSTREAM  *);
+
+int  	     BLOB_get (BSTREAM  *);
+
+int          BLOB_display (ISC_QUAD  *, 
+				     isc_db_handle, 
+				     isc_tr_handle,
+				     char  *);
+
+int          BLOB_dump (ISC_QUAD  *, 
+				  isc_db_handle, 
+				  isc_tr_handle,
+				  char  *);
+
+int          BLOB_edit (ISC_QUAD  *, 
+				  isc_db_handle, 
+				  isc_tr_handle,
+				  char  *);
+
+int          BLOB_load (ISC_QUAD  *, 
+				  isc_db_handle, 
+				  isc_tr_handle,
+				  char  *);
+
+int          BLOB_text_dump (ISC_QUAD  *, 
+				  isc_db_handle, 
+				  isc_tr_handle,
+				  char  *);
+
+int          BLOB_text_load (ISC_QUAD  *, 
+				  isc_db_handle, 
+				  isc_tr_handle,
+				  char  *);
+
+BSTREAM      *  Bopen (ISC_QUAD  *, 
+			       	    isc_db_handle, 
+			       	    isc_tr_handle,  
+			       	    char  *);
+
+BSTREAM      *  Bopen2 (ISC_QUAD  *, 
+				     isc_db_handle,  
+				     isc_tr_handle,  
+				     char  *,
+				     unsigned short);
+
+/******************************/
+/* Other Misc functions       */
+/******************************/
+
+ISC_LONG     isc_ftof (char  *, 
+				 unsigned short, 
+				 char  *, 
+				 unsigned short);
+
+ISC_STATUS   isc_print_blr (char  *, 
+				      isc_callback, 
+				      void  *, 
+				      short);
+
+void         isc_set_debug (int);
+
+void         isc_qtoq (ISC_QUAD  *, 
+				 ISC_QUAD  *);
+
+void         isc_vtof (char  *, 
+				 char  *,
+				 unsigned short);
+
+void         isc_vtov (char  *, 
+				 char  *, 
+				 short);
+
+int          isc_version (isc_db_handle  *, 
+				    isc_callback, 
+				    void  *);
+
+ISC_LONG     isc_reset_fpe (unsigned short);
+
+/*****************************************/
+/* Service manager functions             */
+/*****************************************/
+
+/*!!MVC
+#define ADD_SPB_LENGTH(p, length)	{*(p)++ = (length); \
+    					 *(p)++ = (length) >> 8;}
+
+#define ADD_SPB_NUMERIC(p, data)	{*(p)++ = (data); \
+    					 *(p)++ = (data) >> 8; \
+					 *(p)++ = (data) >> 16; \
+					 *(p)++ = (data) >> 24;}
+!!MVC*/
+
+ISC_STATUS   isc_service_attach (ISC_STATUS  *, 
+					   unsigned short, 
+					   char  *,
+					   isc_svc_handle  *, 
+					   unsigned short, 
+					   char  *);
+
+ISC_STATUS   isc_service_detach (ISC_STATUS  *, 
+					   isc_svc_handle  *);
+
+ISC_STATUS   isc_service_query (ISC_STATUS  *, 
+					  isc_svc_handle  *,
+                      		          isc_resv_handle  *,
+					  unsigned short, 
+					  char  *, 
+					  unsigned short, 
+					  char  *, 
+					  unsigned short, 
+					  char  *);
+
+ISC_STATUS  isc_service_start (ISC_STATUS  *,
+    					 isc_svc_handle  *,
+                         		 isc_resv_handle  *,
+    					 unsigned short,
+    					 char *);
+
+/*******************************/
+/* Forms functions             */
+/*******************************/
+
+ISC_STATUS   isc_compile_map (ISC_STATUS  *, 
+					isc_form_handle  *,
+					isc_req_handle  *, 
+					short  *, 
+					char  *);
+
+ISC_STATUS   isc_compile_menu (ISC_STATUS  *, 
+					 isc_form_handle  *,
+					 isc_req_handle  *, 
+					 short  *, 
+				 	 char  *);
+
+ISC_STATUS   isc_compile_sub_map (ISC_STATUS  *, 
+					    isc_win_handle  *,
+					    isc_req_handle  *, 
+					    short  *, 
+					    char  *);
+
+ISC_STATUS   isc_create_window (ISC_STATUS  *, 
+					  isc_win_handle  *, 
+					  short  *, 
+					  char  *, 
+					  short  *, 
+					  short  *);
+
+ISC_STATUS   isc_delete_window (ISC_STATUS  *, 
+					  isc_win_handle  *);
+
+ISC_STATUS   isc_drive_form (ISC_STATUS  *, 
+				       isc_db_handle  *, 
+				       isc_tr_handle  *, 
+				       isc_win_handle  *, 
+				       isc_req_handle  *, 
+				       unsigned char  *, 
+				       unsigned char  *);
+
+ISC_STATUS   isc_drive_menu (ISC_STATUS  *, 
+				       isc_win_handle  *, 
+				       isc_req_handle  *, 
+				       short  *, 
+				       char  *, 
+				       short  *, 
+				       char  *,
+				       short  *, 
+				       short  *, 
+				       char  *, 
+				       ISC_LONG  *);
+
+ISC_STATUS   isc_form_delete (ISC_STATUS  *, 
+					isc_form_handle  *);
+
+ISC_STATUS   isc_form_fetch (ISC_STATUS  *, 
+				       isc_db_handle  *, 
+				       isc_tr_handle  *, 
+				       isc_req_handle  *, 
+				       unsigned char  *);
+
+ISC_STATUS   isc_form_insert (ISC_STATUS  *, 
+					isc_db_handle  *, 
+					isc_tr_handle  *, 
+					isc_req_handle  *, 
+					unsigned char  *);
+
+ISC_STATUS   isc_get_entree (ISC_STATUS  *, 
+				       isc_req_handle  *, 
+				       short  *, 
+				       char  *, 
+				       ISC_LONG  *, 
+				       short  *);
+
+ISC_STATUS   isc_initialize_menu (ISC_STATUS  *, 
+					    isc_req_handle  *);
+
+ISC_STATUS   isc_menu (ISC_STATUS  *, 
+				 isc_win_handle  *, 
+				 isc_req_handle  *, 
+			 	 short  *, 
+				 char  *);
+
+ISC_STATUS   isc_load_form (ISC_STATUS  *, 
+				      isc_db_handle  *, 
+				      isc_tr_handle  *, 
+				      isc_form_handle  *, 
+				      short  *, 
+				      char  *);
+																
+ISC_STATUS   isc_pop_window (ISC_STATUS  *, 
+				       isc_win_handle  *);
+
+ISC_STATUS   isc_put_entree (ISC_STATUS  *, 
+				       isc_req_handle  *, 
+				       short  *, 
+				       char  *, 
+				       ISC_LONG  *);
+
+ISC_STATUS   isc_reset_form (ISC_STATUS  *, 
+				       isc_req_handle  *);
+
+ISC_STATUS   isc_suspend_window (ISC_STATUS  *, 
+					   isc_win_handle  *);
+/*!!MVC
+#ifdef __cplusplus
+};
+#endif
+
+#else
+!!MVC */
+ 
+ISC_STATUS   isc_attach_database();
+ISC_STATUS   isc_array_gen_sdl();
+ISC_STATUS   isc_array_get_slice();
+ISC_STATUS   isc_array_lookup_bounds();
+ISC_STATUS   isc_array_lookup_desc();
+ISC_STATUS   isc_array_set_desc();
+ISC_STATUS   isc_array_put_slice();
+ISC_STATUS   isc_blob_gen_bpb();
+ISC_STATUS   isc_blob_info();
+ISC_STATUS   isc_blob_lookup_desc();
+ISC_STATUS   isc_blob_set_desc();
+ISC_STATUS   isc_cancel_blob();
+ISC_STATUS   isc_cancel_events();
+ISC_STATUS   isc_close_blob();
+ISC_STATUS   isc_commit_retaining();
+ISC_STATUS   isc_commit_transaction();
+ISC_STATUS   isc_compile_request();
+ISC_STATUS   isc_compile_request2();
+ISC_STATUS   isc_create_blob();
+ISC_STATUS   isc_create_blob2();
+ISC_STATUS   isc_create_database();
+ISC_STATUS   isc_database_info();
+ISC_STATUS   isc_ddl();
+void         isc_decode_date();
+void         isc_decode_sql_date();
+void         isc_decode_sql_time();
+void         isc_decode_timestamp();
+ISC_STATUS   isc_detach_database();
+ISC_STATUS   isc_drop_database();
+void         isc_encode_date();
+void         isc_encode_sql_date();
+void         isc_encode_sql_time();
+void         isc_encode_timestamp();
+ISC_LONG     isc_event_block();
+void         isc_event_counts();
+void         isc_expand_dpb();
+int          isc_modify_dpb();
+ISC_LONG     isc_free();
+ISC_STATUS   isc_get_segment();
+ISC_STATUS   isc_get_slice();
+ISC_STATUS   isc_interprete();
+ISC_STATUS   isc_open_blob();
+ISC_STATUS   isc_open_blob2();
+ISC_STATUS   isc_prepare_transaction();
+ISC_STATUS   isc_prepare_transaction2();
+void         isc_print_sqlerror();
+ISC_STATUS   isc_print_status();
+ISC_STATUS   isc_put_segment();
+ISC_STATUS   isc_put_slice();
+ISC_STATUS   isc_que_events();
+ISC_STATUS   isc_receive();
+ISC_STATUS   isc_reconnect_transaction();
+ISC_STATUS   isc_release_request();
+ISC_STATUS   isc_request_info();
+ISC_LONG     isc_reset_fpe ();
+ISC_STATUS   isc_rollback_transaction();
+ISC_STATUS   isc_rollback_retaining();
+ISC_STATUS   isc_seek_blob();
+ISC_STATUS   isc_send();
+ISC_STATUS   isc_service_attach();
+ISC_STATUS   isc_service_detach();
+ISC_STATUS   isc_service_query();
+ISC_STATUS   isc_service_start();
+ISC_STATUS   isc_start_and_send();
+ISC_STATUS   isc_start_multiple();
+ISC_STATUS   isc_start_request();
+ISC_STATUS   isc_start_transaction();
+ISC_LONG     isc_sqlcode();
+ISC_STATUS   isc_transaction_info();
+ISC_STATUS   isc_transact_request();
+ISC_STATUS   isc_unwind_request();
+ISC_STATUS   isc_wait_for_event();
+ISC_LONG     isc_ftof();
+ISC_STATUS   isc_print_blr();
+void         isc_set_debug();
+void         isc_qtoq();
+ISC_LONG     isc_vax_integer();
+void         isc_vtof();
+void         isc_vtov();
+int          isc_version();
+
+#ifndef __STDC__
+
+/******************/
+/* Blob functions */
+/******************/
+
+BSTREAM    *  Bopen();
+BSTREAM    *  BLOB_open();
+BSTREAM    *  Bopen2();
+#endif					/* __STDC__ */
+
+#endif                                  /* __cplusplus || __STDC__ */
+
+/***************************************************/
+/* Actions to pass to the blob filter (ctl_source) */
+/***************************************************/
+
+#define isc_blob_filter_open             0
+#define isc_blob_filter_get_segment      1
+#define isc_blob_filter_close            2
+#define isc_blob_filter_create           3
+#define isc_blob_filter_put_segment      4
+#define isc_blob_filter_alloc            5
+#define isc_blob_filter_free             6
+#define isc_blob_filter_seek             7
+
+/*******************/
+/* Blr definitions */
+/*******************/
+
+#ifndef _JRD_BLR_H_
+
+/*!!MVC
+#define blr_word(n) ((n) % 256), ((n) / 256)
+!!MVC*/
+
+#define blr_text                           14
+#define blr_text2                          15
+#define blr_short                          7
+#define blr_long                           8
+#define blr_quad                           9
+#define blr_int64                          16
+#define blr_float                          10
+#define blr_double                         27
+#define blr_d_float                        11
+#define blr_timestamp                      35
+#define blr_varying                        37
+#define blr_varying2                       38
+#define blr_blob                           261
+#define blr_cstring                        40
+#define blr_cstring2                       41	
+#define blr_blob_id                        45
+#define blr_sql_date                       12
+#define blr_sql_time                       13
+
+/* Historical alias for pre V6 applications */
+#define blr_date                           blr_timestamp
+
+#define blr_inner                          0
+#define blr_left                           1
+#define blr_right                          2
+#define blr_full                           3
+
+#define blr_gds_code                       0
+#define blr_sql_code                       1
+#define blr_exception                      2
+#define blr_trigger_code                   3
+#define blr_default_code                   4
+
+#define blr_version4                       4
+#define blr_version5                       5
+#define blr_eoc                            76
+#define blr_end                            255
+
+#define blr_assignment                     1
+#define blr_begin                          2
+#define blr_dcl_variable                   3
+#define blr_message                        4
+#define blr_erase                          5
+#define blr_fetch                          6
+#define blr_for                            7
+#define blr_if                             8
+#define blr_loop                           9
+#define blr_modify                         10
+#define blr_handler                        11
+#define blr_receive                        12
+#define blr_select                         13
+#define blr_send                           14
+#define blr_store                          15
+#define blr_label                          17
+#define blr_leave                          18
+#define blr_store2                         19
+#define blr_post                           20
+
+#define blr_literal                        21
+#define blr_dbkey                          22
+#define blr_field                          23
+#define blr_fid                            24
+#define blr_parameter                      25
+#define blr_variable                       26
+#define blr_average                        27
+#define blr_count                          28
+#define blr_maximum                        29
+#define blr_minimum                        30
+#define blr_total                          31
+#define blr_add                            34
+#define blr_subtract                       35
+#define blr_multiply                       36
+#define blr_divide                         37
+#define blr_negate                         38
+#define blr_concatenate                    39
+#define blr_substring                      40
+#define blr_parameter2                     41
+#define blr_from                           42
+#define blr_via                            43
+#define blr_user_name                      44
+#define blr_null                           45
+
+#define blr_eql                            47
+#define blr_neq                            48
+#define blr_gtr                            49
+#define blr_geq                            50
+#define blr_lss                            51
+#define blr_leq                            52
+#define blr_containing                     53
+#define blr_matching                       54
+#define blr_starting                       55
+#define blr_between                        56
+#define blr_or                             57
+#define blr_and                            58
+#define blr_not                            59
+#define blr_any                            60
+#define blr_missing                        61
+#define blr_unique                         62
+#define blr_like                           63
+
+#define blr_stream                         65
+#define blr_set_index                      66
+#define blr_rse                            67
+#define blr_first                          68
+#define blr_project                        69
+#define blr_sort                           70
+#define blr_boolean                        71
+#define blr_ascending                      72
+#define blr_descending                     73
+#define blr_relation                       74
+#define blr_rid                            75
+#define blr_union                          76
+#define blr_map                            77
+#define blr_group_by                       78
+#define blr_aggregate                      79
+#define blr_join_type                      80
+
+#define blr_agg_count                      83
+#define blr_agg_max                        84
+#define blr_agg_min                        85
+#define blr_agg_total                      86
+#define blr_agg_average                    87
+#define blr_parameter3                     88
+#define	blr_run_count                      118
+#define	blr_run_max                        89
+#define	blr_run_min                        90
+#define	blr_run_total                      91
+#define	blr_run_average                    92
+#define blr_agg_count2                     93
+#define blr_agg_count_distinct             94
+#define blr_agg_total_distinct             95
+#define blr_agg_average_distinct           96
+
+#define blr_function                       100
+#define blr_gen_id                         101
+#define blr_prot_mask                      102
+#define blr_upcase                         103
+#define blr_lock_state                     104
+#define blr_value_if                       105
+#define blr_matching2                      106
+#define blr_index                          107
+#define blr_ansi_like                      108
+#define blr_bookmark                       109
+#define blr_crack                          110
+#define blr_force_crack                    111
+#define blr_seek                           112
+#define blr_find                           113
+
+#define blr_continue                       0
+#define blr_forward                        1
+#define blr_backward                       2
+#define blr_bof_forward                    3
+#define blr_eof_backward                   4
+
+#define blr_lock_relation                  114
+#define blr_lock_record                    115
+#define blr_set_bookmark		   116
+#define blr_get_bookmark		   117
+#define blr_rs_stream                      119
+#define blr_exec_proc                      120
+#define blr_begin_range                    121
+#define blr_end_range                      122
+#define blr_delete_range                   123
+#define blr_procedure                      124
+#define blr_pid                            125
+#define blr_exec_pid                       126
+#define blr_singular                       127
+#define blr_abort                          128
+#define blr_block                          129
+#define blr_error_handler                  130
+#define blr_cast                           131
+#define blr_release_lock                   132
+#define blr_release_locks                  133
+#define blr_start_savepoint                134
+#define blr_end_savepoint                  135
+#define blr_find_dbkey                     136
+#define blr_range_relation                 137
+#define blr_delete_ranges                  138
+
+#define blr_plan                           139
+#define blr_merge                          140
+#define blr_join                           141
+#define blr_sequential                     142
+#define blr_navigational                   143
+#define blr_indices                        144
+#define blr_retrieve                       145
+
+#define blr_relation2                      146
+#define blr_rid2                           147
+#define blr_reset_stream                   148
+#define blr_release_bookmark               149
+#define blr_set_generator                  150
+#define blr_ansi_any			   151   
+#define blr_exists			   152
+#define blr_cardinality			   153
+
+#define blr_record_version		   154		/* get tid of record */
+#define blr_stall			   155		/* fake server stall */
+#define blr_seek_no_warn		   156
+#define blr_find_dbkey_version		   157
+#define blr_ansi_all			   158   
+
+#define blr_extract                        159
+
+/* sub parameters for blr_extract */
+
+#define blr_extract_year                   0
+#define blr_extract_month                  1
+#define blr_extract_day	                   2
+#define blr_extract_hour                   3
+#define blr_extract_minute                 4
+#define blr_extract_second                 5
+#define blr_extract_weekday                6
+#define blr_extract_yearday                7
+
+#define blr_current_date                   160
+#define blr_current_timestamp              161
+#define blr_current_time                   162
+
+/* These verbs were added in 6.0, primarily to support 64-bit integers */
+
+#define blr_add2	          163
+#define blr_subtract2	          164
+#define blr_multiply2             165
+#define blr_divide2	          166
+#define blr_agg_total2            167
+#define blr_agg_total_distinct2   168
+#define blr_agg_average2          169
+#define blr_agg_average_distinct2 170
+#define blr_average2		  171
+#define blr_gen_id2		  172
+#define blr_set_generator2        173
+#endif					/* _JRD_BLR_H_ */
+
+/**********************************/
+/* Database parameter block stuff */
+/**********************************/
+
+#define isc_dpb_version1                  1
+#define isc_dpb_cdd_pathname              1
+#define isc_dpb_allocation                2
+#define isc_dpb_journal                   3
+#define isc_dpb_page_size                 4
+#define isc_dpb_num_buffers               5
+#define isc_dpb_buffer_length             6
+#define isc_dpb_debug                     7
+#define isc_dpb_garbage_collect           8
+#define isc_dpb_verify                    9
+#define isc_dpb_sweep                     10
+#define isc_dpb_enable_journal            11
+#define isc_dpb_disable_journal           12
+#define isc_dpb_dbkey_scope               13
+#define isc_dpb_number_of_users           14
+#define isc_dpb_trace                     15
+#define isc_dpb_no_garbage_collect        16
+#define isc_dpb_damaged                   17
+#define isc_dpb_license                   18
+#define isc_dpb_sys_user_name             19
+#define isc_dpb_encrypt_key               20
+#define isc_dpb_activate_shadow           21
+#define isc_dpb_sweep_interval            22
+#define isc_dpb_delete_shadow             23
+#define isc_dpb_force_write               24
+#define isc_dpb_begin_log                 25
+#define isc_dpb_quit_log                  26
+#define isc_dpb_no_reserve                27
+#define isc_dpb_user_name                 28
+#define isc_dpb_password                  29
+#define isc_dpb_password_enc              30
+#define isc_dpb_sys_user_name_enc         31
+#define isc_dpb_interp                    32
+#define isc_dpb_online_dump               33
+#define isc_dpb_old_file_size             34
+#define isc_dpb_old_num_files             35
+#define isc_dpb_old_file                  36
+#define isc_dpb_old_start_page            37
+#define isc_dpb_old_start_seqno           38
+#define isc_dpb_old_start_file            39
+#define isc_dpb_drop_walfile              40
+#define isc_dpb_old_dump_id               41
+#define isc_dpb_wal_backup_dir            42
+#define isc_dpb_wal_chkptlen              43
+#define isc_dpb_wal_numbufs               44
+#define isc_dpb_wal_bufsize               45
+#define isc_dpb_wal_grp_cmt_wait          46
+#define isc_dpb_lc_messages               47
+#define isc_dpb_lc_ctype                  48
+#define isc_dpb_cache_manager		  49
+#define isc_dpb_shutdown		  50
+#define isc_dpb_online			  51
+#define isc_dpb_shutdown_delay		  52
+#define isc_dpb_reserved		  53
+#define isc_dpb_overwrite		  54
+#define isc_dpb_sec_attach		  55
+#define isc_dpb_disable_wal		  56
+#define isc_dpb_connect_timeout           57
+#define isc_dpb_dummy_packet_interval     58
+#define isc_dpb_gbak_attach               59
+#define isc_dpb_sql_role_name             60
+#define isc_dpb_set_page_buffers          61
+#define isc_dpb_working_directory         62
+#define isc_dpb_SQL_dialect               63
+#define isc_dpb_set_db_readonly           64
+#define isc_dpb_set_db_SQL_dialect        65
+#define isc_dpb_gfix_attach		  66
+#define isc_dpb_gstat_attach		  67
+
+/*********************************/
+/* isc_dpb_verify specific flags */
+/*********************************/
+
+#define isc_dpb_pages                     1
+#define isc_dpb_records                   2
+#define isc_dpb_indices                   4
+#define isc_dpb_transactions              8
+#define isc_dpb_no_update                 16
+#define isc_dpb_repair                    32
+#define isc_dpb_ignore                    64
+
+/***********************************/
+/* isc_dpb_shutdown specific flags */
+/***********************************/
+
+#define isc_dpb_shut_cache               1
+#define isc_dpb_shut_attachment          2
+#define isc_dpb_shut_transaction         4
+#define isc_dpb_shut_force               8
+
+/**************************************/
+/* Bit assignments in RDB$SYSTEM_FLAG */
+/**************************************/
+
+#define RDB_system                         1
+#define RDB_id_assigned                    2
+
+/*************************************/
+/* Transaction parameter block stuff */
+/*************************************/
+
+#define isc_tpb_version1                  1
+#define isc_tpb_version3                  3
+#define isc_tpb_consistency               1
+#define isc_tpb_concurrency               2
+#define isc_tpb_shared                    3
+#define isc_tpb_protected                 4
+#define isc_tpb_exclusive                 5
+#define isc_tpb_wait                      6
+#define isc_tpb_nowait                    7
+#define isc_tpb_read                      8
+#define isc_tpb_write                     9
+#define isc_tpb_lock_read                 10
+#define isc_tpb_lock_write                11
+#define isc_tpb_verb_time                 12
+#define isc_tpb_commit_time               13
+#define isc_tpb_ignore_limbo              14
+#define isc_tpb_read_committed		  15
+#define isc_tpb_autocommit		  16
+#define isc_tpb_rec_version		  17
+#define isc_tpb_no_rec_version		  18
+#define isc_tpb_restart_requests	  19
+#define isc_tpb_no_auto_undo              20
+
+/************************/
+/* Blob Parameter Block */
+/************************/
+
+#define isc_bpb_version1                  1
+#define isc_bpb_source_type               1
+#define isc_bpb_target_type               2
+#define isc_bpb_type                      3
+#define isc_bpb_source_interp             4
+#define isc_bpb_target_interp             5
+#define isc_bpb_filter_parameter          6
+
+#define isc_bpb_type_segmented            0
+#define isc_bpb_type_stream               1
+
+/*********************************/
+/* Service parameter block stuff */
+/*********************************/
+
+#define isc_spb_version1                  1
+#define isc_spb_current_version           2
+#define isc_spb_version			  isc_spb_current_version
+#define isc_spb_user_name                 isc_dpb_user_name 
+#define isc_spb_sys_user_name             isc_dpb_sys_user_name
+#define isc_spb_sys_user_name_enc         isc_dpb_sys_user_name_enc
+#define isc_spb_password                  isc_dpb_password
+#define isc_spb_password_enc              isc_dpb_password_enc
+#define isc_spb_command_line              105
+#define isc_spb_dbname                    106
+#define isc_spb_verbose                   107
+#define isc_spb_options                   108
+
+#define isc_spb_connect_timeout           isc_dpb_connect_timeout
+#define isc_spb_dummy_packet_interval     isc_dpb_dummy_packet_interval
+#define isc_spb_sql_role_name             isc_dpb_sql_role_name
+
+/*********************************/
+/* Information call declarations */
+/*********************************/
+
+/****************************/
+/* Common, structural codes */
+/****************************/
+
+#define isc_info_end                      1
+#define isc_info_truncated                2
+#define isc_info_error                    3
+#define isc_info_data_not_ready	          4
+#define isc_info_flag_end		  127
+
+/******************************/
+/* Database information items */
+/******************************/
+
+#define isc_info_db_id                    4
+#define isc_info_reads                    5
+#define isc_info_writes                   6
+#define isc_info_fetches                  7
+#define isc_info_marks                    8
+#define isc_info_implementation           11
+#define isc_info_version                  12
+#define isc_info_base_level               13
+#define isc_info_page_size                14
+#define isc_info_num_buffers              15
+#define isc_info_limbo                    16
+#define isc_info_current_memory           17
+#define isc_info_max_memory               18
+#define isc_info_window_turns             19
+#define isc_info_license                  20
+#define isc_info_allocation               21
+#define isc_info_attachment_id            22
+#define isc_info_read_seq_count           23
+#define isc_info_read_idx_count           24
+#define isc_info_insert_count             25
+#define isc_info_update_count             26
+#define isc_info_delete_count             27
+#define isc_info_backout_count            28
+#define isc_info_purge_count              29
+#define isc_info_expunge_count            30
+#define isc_info_sweep_interval           31
+#define isc_info_ods_version              32
+#define isc_info_ods_minor_version        33
+#define isc_info_no_reserve               34
+#define isc_info_logfile                  35
+#define isc_info_cur_logfile_name         36
+#define isc_info_cur_log_part_offset      37
+#define isc_info_num_wal_buffers          38
+#define isc_info_wal_buffer_size          39
+#define isc_info_wal_ckpt_length          40
+#define isc_info_wal_cur_ckpt_interval    41
+#define isc_info_wal_prv_ckpt_fname       42
+#define isc_info_wal_prv_ckpt_poffset     43
+#define isc_info_wal_recv_ckpt_fname      44
+#define isc_info_wal_recv_ckpt_poffset    45
+#define isc_info_wal_grpc_wait_usecs      47
+#define isc_info_wal_num_io               48
+#define isc_info_wal_avg_io_size          49
+#define isc_info_wal_num_commits          50
+#define isc_info_wal_avg_grpc_size        51
+#define isc_info_forced_writes		  52
+#define isc_info_user_names		  53
+#define isc_info_page_errors		  54
+#define isc_info_record_errors		  55
+#define isc_info_bpage_errors		  56
+#define isc_info_dpage_errors	  	  57
+#define isc_info_ipage_errors	  	  58
+#define isc_info_ppage_errors		  59
+#define isc_info_tpage_errors	  	  60
+#define isc_info_set_page_buffers         61
+#define isc_info_db_SQL_dialect           62
+#define isc_info_db_read_only             63
+#define isc_info_db_size_in_pages	  64
+
+/**************************************/
+/* Database information return values */
+/**************************************/
+
+#define isc_info_db_impl_rdb_vms          1
+#define isc_info_db_impl_rdb_eln          2
+#define isc_info_db_impl_rdb_eln_dev      3
+#define isc_info_db_impl_rdb_vms_y        4
+#define isc_info_db_impl_rdb_eln_y        5
+#define isc_info_db_impl_jri              6
+#define isc_info_db_impl_jsv              7
+#define isc_info_db_impl_isc_a            25
+#define isc_info_db_impl_isc_u            26
+#define isc_info_db_impl_isc_v            27
+#define isc_info_db_impl_isc_s            28
+#define isc_info_db_impl_isc_apl_68K      25
+#define isc_info_db_impl_isc_vax_ultr     26
+#define isc_info_db_impl_isc_vms          27
+#define isc_info_db_impl_isc_sun_68k      28
+#define isc_info_db_impl_isc_os2          29
+#define isc_info_db_impl_isc_sun4         30
+#define isc_info_db_impl_isc_hp_ux        31
+#define isc_info_db_impl_isc_sun_386i     32
+#define isc_info_db_impl_isc_vms_orcl     33
+#define isc_info_db_impl_isc_mac_aux      34
+#define isc_info_db_impl_isc_rt_aix       35
+#define isc_info_db_impl_isc_mips_ult     36
+#define isc_info_db_impl_isc_xenix        37
+#define isc_info_db_impl_isc_dg           38
+#define isc_info_db_impl_isc_hp_mpexl     39
+#define isc_info_db_impl_isc_hp_ux68K     40
+#define isc_info_db_impl_isc_sgi          41
+#define isc_info_db_impl_isc_sco_unix     42
+#define isc_info_db_impl_isc_cray         43
+#define isc_info_db_impl_isc_imp          44
+#define isc_info_db_impl_isc_delta        45
+#define isc_info_db_impl_isc_next         46
+#define isc_info_db_impl_isc_dos          47
+#define isc_info_db_impl_isc_winnt        48
+#define isc_info_db_impl_isc_epson        49
+
+#define isc_info_db_class_access          1
+#define isc_info_db_class_y_valve         2
+#define isc_info_db_class_rem_int         3
+#define isc_info_db_class_rem_srvr        4
+#define isc_info_db_class_pipe_int        7
+#define isc_info_db_class_pipe_srvr       8
+#define isc_info_db_class_sam_int         9
+#define isc_info_db_class_sam_srvr        10
+#define isc_info_db_class_gateway         11
+#define isc_info_db_class_cache           12
+
+/*****************************/
+/* Request information items */
+/*****************************/
+
+#define isc_info_number_messages          4
+#define isc_info_max_message              5
+#define isc_info_max_send                 6
+#define isc_info_max_receive              7
+#define isc_info_state                    8
+#define isc_info_message_number           9
+#define isc_info_message_size             10
+#define isc_info_request_cost             11
+#define isc_info_access_path              12
+#define isc_info_req_select_count         13
+#define isc_info_req_insert_count         14
+#define isc_info_req_update_count         15
+#define isc_info_req_delete_count         16
+
+/*********************/
+/* Access path items */
+/*********************/
+
+#define isc_info_rsb_end		   0
+#define isc_info_rsb_begin		   1
+#define isc_info_rsb_type		   2
+#define isc_info_rsb_relation		   3
+#define isc_info_rsb_plan                  4
+
+/*************/
+/* Rsb types */
+/*************/
+
+#define isc_info_rsb_unknown		   1
+#define isc_info_rsb_indexed		   2
+#define isc_info_rsb_navigate		   3
+#define isc_info_rsb_sequential	 	   4
+#define isc_info_rsb_cross		   5
+#define isc_info_rsb_sort		   6
+#define isc_info_rsb_first		   7
+#define isc_info_rsb_boolean		   8
+#define isc_info_rsb_union		   9
+#define isc_info_rsb_aggregate		  10
+#define isc_info_rsb_merge		  11
+#define isc_info_rsb_ext_sequential	  12
+#define isc_info_rsb_ext_indexed	  13
+#define isc_info_rsb_ext_dbkey		  14
+#define isc_info_rsb_left_cross	 	  15
+#define isc_info_rsb_select		  16
+#define isc_info_rsb_sql_join		  17
+#define isc_info_rsb_simulate		  18
+#define isc_info_rsb_sim_cross		  19
+#define isc_info_rsb_once		  20
+#define isc_info_rsb_procedure		  21
+
+/**********************/
+/* Bitmap expressions */
+/**********************/
+
+#define isc_info_rsb_and		1
+#define isc_info_rsb_or			2
+#define isc_info_rsb_dbkey		3
+#define isc_info_rsb_index		4
+
+#define isc_info_req_active               2
+#define isc_info_req_inactive             3
+#define isc_info_req_send                 4
+#define isc_info_req_receive              5
+#define isc_info_req_select               6
+#define isc_info_req_sql_stall		  7
+
+/**************************/
+/* Blob information items */
+/**************************/
+
+#define isc_info_blob_num_segments        4
+#define isc_info_blob_max_segment         5
+#define isc_info_blob_total_length        6
+#define isc_info_blob_type                7
+
+/*********************************/
+/* Transaction information items */
+/*********************************/
+
+#define isc_info_tra_id                   4
+
+/*****************************
+ * Service action items      *
+ *****************************/
+
+#define isc_action_svc_backup          1 /* Starts database backup process on the server */ 
+#define isc_action_svc_restore         2 /* Starts database restore process on the server */ 
+#define isc_action_svc_repair          3 /* Starts database repair process on the server */ 
+#define isc_action_svc_add_user        4 /* Adds a new user to the security database */ 
+#define isc_action_svc_delete_user     5 /* Deletes a user record from the security database */ 
+#define isc_action_svc_modify_user     6 /* Modifies a user record in the security database */
+#define isc_action_svc_display_user    7 /* Displays a user record from the security database */
+#define isc_action_svc_properties      8 /* Sets database properties */ 
+#define isc_action_svc_add_license     9 /* Adds a license to the license file */ 
+#define isc_action_svc_remove_license 10 /* Removes a license from the license file */ 
+#define isc_action_svc_db_stats	      11 /* Retrieves database statistics */
+#define isc_action_svc_get_ib_log     12 /* Retrieves the InterBase log file from the server */
+
+/*****************************
+ * Service information items *
+ *****************************/
+
+#define isc_info_svc_svr_db_info      50 /* Retrieves the number of attachments and databases */ 
+#define isc_info_svc_get_license      51 /* Retrieves all license keys and IDs from the license file */
+#define isc_info_svc_get_license_mask 52 /* Retrieves a bitmask representing licensed options on the server */ 
+#define isc_info_svc_get_config       53 /* Retrieves the parameters and values for IB_CONFIG */ 
+#define isc_info_svc_version          54 /* Retrieves the version of the services manager */ 
+#define isc_info_svc_server_version   55 /* Retrieves the version of the InterBase server */ 
+#define isc_info_svc_implementation   56 /* Retrieves the implementation of the InterBase server */ 
+#define isc_info_svc_capabilities     57 /* Retrieves a bitmask representing the server's capabilities */ 
+#define isc_info_svc_user_dbpath      58 /* Retrieves the path to the security database in use by the server */ 
+#define isc_info_svc_get_env	      59 /* Retrieves the setting of $INTERBASE */
+#define isc_info_svc_get_env_lock     60 /* Retrieves the setting of $INTERBASE_LCK */
+#define isc_info_svc_get_env_msg      61 /* Retrieves the setting of $INTERBASE_MSG */
+#define isc_info_svc_line             62 /* Retrieves 1 line of service output per call */
+#define isc_info_svc_to_eof           63 /* Retrieves as much of the server output as will fit in the supplied buffer */
+#define isc_info_svc_timeout          64 /* Sets / signifies a timeout value for reading service information */
+#define isc_info_svc_get_licensed_users 65 /* Retrieves the number of users licensed for accessing the server */
+#define isc_info_svc_limbo_trans	66 /* Retrieve the limbo transactions */
+#define isc_info_svc_running		67 /* Checks to see if a service is running on an attachment */
+#define isc_info_svc_get_users		68 /* Returns the user information from isc_action_svc_display_users */
+
+/******************************************************
+ * Parameters for isc_action_{add|delete|modify)_user *
+ ******************************************************/
+
+#define isc_spb_sec_userid            5
+#define isc_spb_sec_groupid           6
+#define isc_spb_sec_username          7
+#define isc_spb_sec_password          8
+#define isc_spb_sec_groupname         9
+#define isc_spb_sec_firstname         10
+#define isc_spb_sec_middlename        11
+#define isc_spb_sec_lastname          12
+
+/*******************************************************
+ * Parameters for isc_action_svc_(add|remove)_license, *
+ * isc_info_svc_get_license                            *
+ *******************************************************/
+
+#define isc_spb_lic_key               5
+#define isc_spb_lic_id                6
+#define isc_spb_lic_desc              7
+
+
+/*****************************************
+ * Parameters for isc_action_svc_backup  *
+ *****************************************/
+
+#define isc_spb_bkp_file                 5 
+#define isc_spb_bkp_factor               6
+#define isc_spb_bkp_length               7
+#define isc_spb_bkp_ignore_checksums     0x01
+#define isc_spb_bkp_ignore_limbo         0x02
+#define isc_spb_bkp_metadata_only        0x04
+#define isc_spb_bkp_no_garbage_collect   0x08
+#define isc_spb_bkp_old_descriptions     0x10
+#define isc_spb_bkp_non_transportable    0x20
+#define isc_spb_bkp_convert              0x40
+#define isc_spb_bkp_expand		 0x80
+
+/********************************************
+ * Parameters for isc_action_svc_properties *
+ ********************************************/
+
+#define isc_spb_prp_page_buffers		5
+#define isc_spb_prp_sweep_interval		6
+#define isc_spb_prp_shutdown_db			7
+#define isc_spb_prp_deny_new_attachments	9
+#define isc_spb_prp_deny_new_transactions	10
+#define isc_spb_prp_reserve_space		11
+#define isc_spb_prp_write_mode			12
+#define isc_spb_prp_access_mode			13
+#define isc_spb_prp_set_sql_dialect		14
+#define isc_spb_prp_activate			0x0100
+#define isc_spb_prp_db_online			0x0200
+
+/********************************************
+ * Parameters for isc_spb_prp_reserve_space *
+ ********************************************/
+
+#define isc_spb_prp_res_use_full	35
+#define isc_spb_prp_res			36
+
+/******************************************
+ * Parameters for isc_spb_prp_write_mode  *
+ ******************************************/
+
+#define isc_spb_prp_wm_async		37
+#define isc_spb_prp_wm_sync		38
+
+/******************************************
+ * Parameters for isc_spb_prp_access_mode *
+ ******************************************/
+
+#define isc_spb_prp_am_readonly		39
+#define isc_spb_prp_am_readwrite	40
+
+/*****************************************
+ * Parameters for isc_action_svc_repair  *
+ *****************************************/
+
+#define isc_spb_rpr_commit_trans		15
+#define isc_spb_rpr_rollback_trans		34
+#define isc_spb_rpr_recover_two_phase		17
+#define isc_spb_tra_id                     	18
+#define isc_spb_single_tra_id			19
+#define isc_spb_multi_tra_id			20
+#define isc_spb_tra_state			21
+#define isc_spb_tra_state_limbo			22
+#define isc_spb_tra_state_commit		23
+#define isc_spb_tra_state_rollback		24
+#define isc_spb_tra_state_unknown		25
+#define isc_spb_tra_host_site			26
+#define isc_spb_tra_remote_site			27
+#define isc_spb_tra_db_path			28
+#define isc_spb_tra_advise			29
+#define isc_spb_tra_advise_commit		30
+#define isc_spb_tra_advise_rollback		31
+#define isc_spb_tra_advise_unknown		33
+
+#define isc_spb_rpr_validate_db			0x01
+#define isc_spb_rpr_sweep_db			0x02
+#define isc_spb_rpr_mend_db			0x04
+#define isc_spb_rpr_list_limbo_trans		0x08
+#define isc_spb_rpr_check_db			0x10
+#define isc_spb_rpr_ignore_checksum		0x20
+#define isc_spb_rpr_kill_shadows		0x40
+#define isc_spb_rpr_full			0x80
+
+/*****************************************
+ * Parameters for isc_action_svc_restore *
+ *****************************************/
+
+#define isc_spb_res_buffers			9
+#define isc_spb_res_page_size			10 
+#define isc_spb_res_length			11
+#define isc_spb_res_access_mode			12
+#define isc_spb_res_deactivate_idx		0x0100
+#define isc_spb_res_no_shadow			0x0200
+#define isc_spb_res_no_validity			0x0400
+#define isc_spb_res_one_at_a_time		0x0800
+#define isc_spb_res_replace			0x1000
+#define isc_spb_res_create			0x2000
+#define isc_spb_res_use_all_space		0x4000
+
+/******************************************
+ * Parameters for isc_spb_res_access_mode  *
+ ******************************************/
+
+#define isc_spb_res_am_readonly			isc_spb_prp_am_readonly
+#define isc_spb_res_am_readwrite		isc_spb_prp_am_readwrite
+
+/*******************************************
+ * Parameters for isc_info_svc_svr_db_info *
+ *******************************************/
+
+#define isc_spb_num_att               5 
+#define isc_spb_num_db                6
+
+/*****************************************
+ * Parameters for isc_info_svc_db_stats  *
+ *****************************************/
+
+#define isc_spb_sts_data_pages		0x01
+#define isc_spb_sts_db_log		0x02
+#define isc_spb_sts_hdr_pages		0x04
+#define isc_spb_sts_idx_pages		0x08
+#define isc_spb_sts_sys_relations	0x10
+
+/*************************/
+/* SQL information items */
+/*************************/
+
+#define isc_info_sql_select               4
+#define isc_info_sql_bind                 5
+#define isc_info_sql_num_variables        6
+#define isc_info_sql_describe_vars        7
+#define isc_info_sql_describe_end         8
+#define isc_info_sql_sqlda_seq            9
+#define isc_info_sql_message_seq          10
+#define isc_info_sql_type                 11
+#define isc_info_sql_sub_type             12
+#define isc_info_sql_scale                13
+#define isc_info_sql_length               14
+#define isc_info_sql_null_ind             15
+#define isc_info_sql_field                16
+#define isc_info_sql_relation             17
+#define isc_info_sql_owner                18
+#define isc_info_sql_alias                19
+#define isc_info_sql_sqlda_start          20
+#define isc_info_sql_stmt_type            21
+#define isc_info_sql_get_plan             22
+#define isc_info_sql_records		  23
+#define isc_info_sql_batch_fetch	  24
+
+/*********************************/
+/* SQL information return values */
+/*********************************/
+
+#define isc_info_sql_stmt_select          1
+#define isc_info_sql_stmt_insert          2
+#define isc_info_sql_stmt_update          3
+#define isc_info_sql_stmt_delete          4
+#define isc_info_sql_stmt_ddl             5
+#define isc_info_sql_stmt_get_segment     6
+#define isc_info_sql_stmt_put_segment     7
+#define isc_info_sql_stmt_exec_procedure  8
+#define isc_info_sql_stmt_start_trans     9
+#define isc_info_sql_stmt_commit          10
+#define isc_info_sql_stmt_rollback        11
+#define isc_info_sql_stmt_select_for_upd  12
+#define isc_info_sql_stmt_set_generator   13
+
+/***********************************/
+/* Server configuration key values */
+/***********************************/
+
+#define	ISCCFG_LOCKMEM_KEY	0
+#define ISCCFG_LOCKSEM_KEY	1
+#define ISCCFG_LOCKSIG_KEY	2
+#define ISCCFG_EVNTMEM_KEY	3
+#define ISCCFG_DBCACHE_KEY	4
+#define ISCCFG_PRIORITY_KEY	5
+#define ISCCFG_IPCMAP_KEY	6
+#define ISCCFG_MEMMIN_KEY	7
+#define ISCCFG_MEMMAX_KEY	8
+#define	ISCCFG_LOCKORDER_KEY	9
+#define	ISCCFG_ANYLOCKMEM_KEY	10
+#define ISCCFG_ANYLOCKSEM_KEY	11
+#define ISCCFG_ANYLOCKSIG_KEY	12
+#define ISCCFG_ANYEVNTMEM_KEY	13
+#define ISCCFG_LOCKHASH_KEY	14
+#define ISCCFG_DEADLOCK_KEY	15
+#define ISCCFG_LOCKSPIN_KEY	16
+#define ISCCFG_CONN_TIMEOUT_KEY 17
+#define ISCCFG_DUMMY_INTRVL_KEY 18
+#define ISCCFG_TRACE_POOLS_KEY  19   /* Internal Use only */
+#define ISCCFG_REMOTE_BUFFER_KEY	20
+
+/***************/
+/* Error codes */
+/***************/
+
+#define isc_facility                       20
+#define isc_err_base                       335544320L
+#define isc_err_factor                     1
+#define isc_arg_end                        0
+#define isc_arg_gds                        1
+#define isc_arg_string                     2
+#define isc_arg_cstring                    3
+#define isc_arg_number                     4
+#define isc_arg_interpreted                5
+#define isc_arg_vms                        6
+#define isc_arg_unix                       7
+#define isc_arg_domain                     8
+#define isc_arg_dos                        9
+#define isc_arg_mpexl                      10
+#define isc_arg_mpexl_ipc                  11
+#define isc_arg_next_mach		   15
+#define isc_arg_netware		           16
+#define isc_arg_win32                      17
+#define isc_arg_warning                    18
+
+#include <iberror.h>
+
+/**********************************************/
+/* Dynamic Data Definition Language operators */
+/**********************************************/
+
+/******************/
+/* Version number */
+/******************/
+
+#define isc_dyn_version_1                 1
+#define isc_dyn_eoc                       255
+
+/******************************/
+/* Operations (may be nested) */
+/******************************/
+
+#define isc_dyn_begin                     2
+#define isc_dyn_end                       3
+#define isc_dyn_if                        4
+#define isc_dyn_def_database              5
+#define isc_dyn_def_global_fld            6
+#define isc_dyn_def_local_fld             7
+#define isc_dyn_def_idx                   8
+#define isc_dyn_def_rel                   9
+#define isc_dyn_def_sql_fld               10
+#define isc_dyn_def_view                  12
+#define isc_dyn_def_trigger               15
+#define isc_dyn_def_security_class        120
+#define isc_dyn_def_dimension             140
+#define isc_dyn_def_generator             24
+#define isc_dyn_def_function              25
+#define isc_dyn_def_filter                26
+#define isc_dyn_def_function_arg          27
+#define isc_dyn_def_shadow                34
+#define isc_dyn_def_trigger_msg           17
+#define isc_dyn_def_file                  36
+#define isc_dyn_mod_database              39
+#define isc_dyn_mod_rel                   11
+#define isc_dyn_mod_global_fld            13
+#define isc_dyn_mod_idx                   102
+#define isc_dyn_mod_local_fld             14
+#define isc_dyn_mod_sql_fld		  216
+#define isc_dyn_mod_view                  16
+#define isc_dyn_mod_security_class        122
+#define isc_dyn_mod_trigger               113
+#define isc_dyn_mod_trigger_msg           28
+#define isc_dyn_delete_database           18
+#define isc_dyn_delete_rel                19
+#define isc_dyn_delete_global_fld         20
+#define isc_dyn_delete_local_fld          21
+#define isc_dyn_delete_idx                22
+#define isc_dyn_delete_security_class     123
+#define isc_dyn_delete_dimensions         143
+#define isc_dyn_delete_trigger            23
+#define isc_dyn_delete_trigger_msg        29
+#define isc_dyn_delete_filter             32
+#define isc_dyn_delete_function           33
+#define isc_dyn_delete_shadow             35
+#define isc_dyn_grant                     30
+#define isc_dyn_revoke                    31
+#define isc_dyn_def_primary_key           37
+#define isc_dyn_def_foreign_key           38
+#define isc_dyn_def_unique                40
+#define isc_dyn_def_procedure             164
+#define isc_dyn_delete_procedure          165
+#define isc_dyn_def_parameter             135
+#define isc_dyn_delete_parameter          136
+#define isc_dyn_mod_procedure             175
+#define isc_dyn_def_log_file              176
+#define isc_dyn_def_cache_file            180
+#define isc_dyn_def_exception             181
+#define isc_dyn_mod_exception             182
+#define isc_dyn_del_exception             183
+#define isc_dyn_drop_log                  194
+#define isc_dyn_drop_cache                195
+#define isc_dyn_def_default_log           202
+
+/***********************/
+/* View specific stuff */
+/***********************/
+
+#define isc_dyn_view_blr                  43
+#define isc_dyn_view_source               44
+#define isc_dyn_view_relation             45
+#define isc_dyn_view_context              46
+#define isc_dyn_view_context_name         47
+
+/**********************/
+/* Generic attributes */
+/**********************/
+
+#define isc_dyn_rel_name                  50
+#define isc_dyn_fld_name                  51
+#define isc_dyn_new_fld_name		  215
+#define isc_dyn_idx_name                  52
+#define isc_dyn_description               53
+#define isc_dyn_security_class            54
+#define isc_dyn_system_flag               55
+#define isc_dyn_update_flag               56
+#define isc_dyn_prc_name                  166
+#define isc_dyn_prm_name                  137
+#define isc_dyn_sql_object                196
+#define isc_dyn_fld_character_set_name    174
+
+/********************************/
+/* Relation specific attributes */
+/********************************/
+
+#define isc_dyn_rel_dbkey_length          61
+#define isc_dyn_rel_store_trig            62
+#define isc_dyn_rel_modify_trig           63
+#define isc_dyn_rel_erase_trig            64
+#define isc_dyn_rel_store_trig_source     65
+#define isc_dyn_rel_modify_trig_source    66
+#define isc_dyn_rel_erase_trig_source     67
+#define isc_dyn_rel_ext_file              68
+#define isc_dyn_rel_sql_protection        69
+#define isc_dyn_rel_constraint            162
+#define isc_dyn_delete_rel_constraint     163
+
+/************************************/
+/* Global field specific attributes */
+/************************************/
+
+#define isc_dyn_fld_type                  70
+#define isc_dyn_fld_length                71
+#define isc_dyn_fld_scale                 72
+#define isc_dyn_fld_sub_type              73
+#define isc_dyn_fld_segment_length        74
+#define isc_dyn_fld_query_header          75
+#define isc_dyn_fld_edit_string           76
+#define isc_dyn_fld_validation_blr        77
+#define isc_dyn_fld_validation_source     78
+#define isc_dyn_fld_computed_blr          79
+#define isc_dyn_fld_computed_source       80
+#define isc_dyn_fld_missing_value         81
+#define isc_dyn_fld_default_value         82
+#define isc_dyn_fld_query_name            83
+#define isc_dyn_fld_dimensions            84
+#define isc_dyn_fld_not_null              85
+#define isc_dyn_fld_precision             86
+#define isc_dyn_fld_char_length           172
+#define isc_dyn_fld_collation             173
+#define isc_dyn_fld_default_source        193
+#define isc_dyn_del_default               197
+#define isc_dyn_del_validation            198
+#define isc_dyn_single_validation         199
+#define isc_dyn_fld_character_set         203
+
+/***********************************/
+/* Local field specific attributes */
+/***********************************/
+
+#define isc_dyn_fld_source                90
+#define isc_dyn_fld_base_fld              91
+#define isc_dyn_fld_position              92
+#define isc_dyn_fld_update_flag           93
+
+/*****************************/
+/* Index specific attributes */
+/*****************************/
+
+#define isc_dyn_idx_unique                100
+#define isc_dyn_idx_inactive              101
+#define isc_dyn_idx_type                  103
+#define isc_dyn_idx_foreign_key           104
+#define isc_dyn_idx_ref_column            105
+#define isc_dyn_idx_statistic		  204
+
+/*******************************/
+/* Trigger specific attributes */
+/*******************************/
+
+#define isc_dyn_trg_type                  110
+#define isc_dyn_trg_blr                   111
+#define isc_dyn_trg_source                112
+#define isc_dyn_trg_name                  114
+#define isc_dyn_trg_sequence              115
+#define isc_dyn_trg_inactive              116
+#define isc_dyn_trg_msg_number            117
+#define isc_dyn_trg_msg                   118
+
+/**************************************/
+/* Security Class specific attributes */
+/**************************************/
+
+#define isc_dyn_scl_acl                   121
+#define isc_dyn_grant_user                130
+#define isc_dyn_grant_proc                186
+#define isc_dyn_grant_trig                187
+#define isc_dyn_grant_view                188
+#define isc_dyn_grant_options             132
+#define isc_dyn_grant_user_group          205
+
+
+/**********************************/
+/* Dimension specific information */
+/**********************************/
+
+#define isc_dyn_dim_lower                 141
+#define isc_dyn_dim_upper                 142
+
+/****************************/
+/* File specific attributes */
+/****************************/
+
+#define isc_dyn_file_name                 125
+#define isc_dyn_file_start                126
+#define isc_dyn_file_length               127
+#define isc_dyn_shadow_number             128
+#define isc_dyn_shadow_man_auto           129
+#define isc_dyn_shadow_conditional        130
+
+/********************************/
+/* Log file specific attributes */
+/********************************/
+
+#define isc_dyn_log_file_sequence         177
+#define isc_dyn_log_file_partitions       178
+#define isc_dyn_log_file_serial           179
+#define isc_dyn_log_file_overflow         200
+#define isc_dyn_log_file_raw		  201
+
+/***************************/
+/* Log specific attributes */
+/***************************/
+
+#define isc_dyn_log_group_commit_wait     189 
+#define isc_dyn_log_buffer_size           190
+#define isc_dyn_log_check_point_length    191
+#define isc_dyn_log_num_of_buffers        192
+
+/********************************/
+/* Function specific attributes */
+/********************************/
+
+#define isc_dyn_function_name             145
+#define isc_dyn_function_type             146
+#define isc_dyn_func_module_name          147
+#define isc_dyn_func_entry_point          148
+#define isc_dyn_func_return_argument      149
+#define isc_dyn_func_arg_position         150
+#define isc_dyn_func_mechanism            151
+#define isc_dyn_filter_in_subtype         152
+#define isc_dyn_filter_out_subtype        153
+
+
+#define isc_dyn_description2		  154	
+#define isc_dyn_fld_computed_source2	  155	
+#define isc_dyn_fld_edit_string2	  156
+#define isc_dyn_fld_query_header2	  157
+#define isc_dyn_fld_validation_source2	  158
+#define isc_dyn_trg_msg2		  159
+#define isc_dyn_trg_source2		  160
+#define isc_dyn_view_source2		  161
+#define isc_dyn_xcp_msg2		  184
+
+/*********************************/
+/* Generator specific attributes */
+/*********************************/
+
+#define isc_dyn_generator_name            95
+#define isc_dyn_generator_id              96
+
+/*********************************/
+/* Procedure specific attributes */
+/*********************************/
+
+#define isc_dyn_prc_inputs                167
+#define isc_dyn_prc_outputs               168
+#define isc_dyn_prc_source                169
+#define isc_dyn_prc_blr                   170
+#define isc_dyn_prc_source2               171
+
+/*********************************/
+/* Parameter specific attributes */
+/*********************************/
+
+#define isc_dyn_prm_number                138
+#define isc_dyn_prm_type                  139
+
+/********************************/
+/* Relation specific attributes */
+/********************************/
+
+#define isc_dyn_xcp_msg                   185
+
+/**********************************************/
+/* Cascading referential integrity values     */
+/**********************************************/
+#define isc_dyn_foreign_key_update        205
+#define isc_dyn_foreign_key_delete        206
+#define isc_dyn_foreign_key_cascade       207
+#define isc_dyn_foreign_key_default       208
+#define isc_dyn_foreign_key_null          209
+#define isc_dyn_foreign_key_none          210
+
+/***********************/
+/* SQL role values     */
+/***********************/
+#define isc_dyn_def_sql_role              211
+#define isc_dyn_sql_role_name             212
+#define isc_dyn_grant_admin_options       213
+#define isc_dyn_del_sql_role              214
+
+/****************************/
+/* Last $dyn value assigned */
+/****************************/
+
+#define isc_dyn_last_dyn_value            216
+
+/******************************************/
+/* Array slice description language (SDL) */
+/******************************************/
+
+#define isc_sdl_version1                  1
+#define isc_sdl_eoc                       255
+#define isc_sdl_relation                  2
+#define isc_sdl_rid                       3
+#define isc_sdl_field                     4
+#define isc_sdl_fid                       5
+#define isc_sdl_struct                    6
+#define isc_sdl_variable                  7
+#define isc_sdl_scalar                    8
+#define isc_sdl_tiny_integer              9
+#define isc_sdl_short_integer             10
+#define isc_sdl_long_integer              11
+#define isc_sdl_literal                   12
+#define isc_sdl_add                       13
+#define isc_sdl_subtract                  14
+#define isc_sdl_multiply                  15
+#define isc_sdl_divide                    16
+#define isc_sdl_negate                    17
+#define isc_sdl_eql                       18
+#define isc_sdl_neq                       19
+#define isc_sdl_gtr                       20
+#define isc_sdl_geq                       21
+#define isc_sdl_lss                       22
+#define isc_sdl_leq                       23
+#define isc_sdl_and                       24
+#define isc_sdl_or                        25
+#define isc_sdl_not                       26
+#define isc_sdl_while                     27
+#define isc_sdl_assignment                28
+#define isc_sdl_label                     29
+#define isc_sdl_leave                     30
+#define isc_sdl_begin                     31
+#define isc_sdl_end                       32
+#define isc_sdl_do3                       33
+#define isc_sdl_do2                       34
+#define isc_sdl_do1                       35
+#define isc_sdl_element                   36
+
+/********************************************/
+/* International text interpretation values */
+/********************************************/
+
+#define isc_interp_eng_ascii              0
+#define isc_interp_jpn_sjis               5
+#define isc_interp_jpn_euc                6
+
+/*******************/
+/* SQL definitions */
+/*******************/
+
+#define SQL_TEXT                           452
+#define SQL_VARYING                        448
+#define SQL_SHORT                          500
+#define SQL_LONG                           496
+#define SQL_FLOAT                          482
+#define SQL_DOUBLE                         480
+#define SQL_D_FLOAT                        530
+#define SQL_TIMESTAMP                      510
+#define SQL_BLOB                           520
+#define SQL_ARRAY                          540
+#define SQL_QUAD                           550
+#define SQL_TYPE_TIME			   560
+#define SQL_TYPE_DATE                      570
+#define SQL_INT64			   580
+
+/* Historical alias for pre V6 applications */
+#define SQL_DATE			SQL_TIMESTAMP
+
+/*****************/
+/* Blob Subtypes */
+/*****************/
+
+/* types less than zero are reserved for customer use */
+
+#define isc_blob_untyped                   0
+
+/* internal subtypes */
+
+#define isc_blob_text                      1
+#define isc_blob_blr                       2
+#define isc_blob_acl                       3
+#define isc_blob_ranges                    4
+#define isc_blob_summary                   5
+#define isc_blob_format                    6
+#define isc_blob_tra                       7
+#define isc_blob_extfile                   8
+
+/* the range 20-30 is reserved for dBASE and Paradox types */
+
+#define isc_blob_formatted_memo            20
+#define isc_blob_paradox_ole               21
+#define isc_blob_graphic                   22
+#define isc_blob_dbase_ole                 23
+#define isc_blob_typed_binary              24
+
+#endif  				/* _JRD_IBASE_H_ */

+ 2233 - 0
packages/base/ibase/ibase60.pp

@@ -0,0 +1,2233 @@
+{
+  $Id$
+}
+unit ibase60;
+
+{$MODE objfpc}
+{$MACRO on}
+
+interface
+
+{$IFDEF Unix}
+  {$LINKLIB c}
+  {$DEFINE gdsdecl:=cdecl}
+  const
+    gdslib = 'gds';
+{$ENDIF}
+{$IFDEF Win32}
+  {$DEFINE gdsdecl:=stdcall}
+  const
+    gdslib = 'gds32.dll';
+{$ENDIF}
+
+type
+  {  Unsigned types }
+
+  UChar                = Byte;
+  UShort               = Word;
+  UInt                 = DWord;
+  ULong                = DWord;
+
+  { Signed types }
+
+  Int                  = LongInt;
+  Long                 = LongInt;
+  Short                = Integer;
+  Float                = Single;
+
+  { Pointers to basic types }
+
+  PByte                = ^Byte;
+  PInt                 = ^Int;
+  PShort               = ^Short;
+  PUShort              = ^UShort;
+  PLong                = ^Long;
+  PULong               = ^ULong;
+  PFloat               = ^Float;
+  PUChar               = ^UChar;
+  PVoid                = ^Pointer;
+  PSmallint            = ^Smallint;
+  PWOrd                = ^Word;
+
+
+{$PACKRECORDS C}
+
+  const
+     ISC_TRUE = 1;
+     ISC_FALSE = 0;
+  const
+     ISC__TRUE = ISC_TRUE;
+     ISC__FALSE = ISC_FALSE;
+
+Type
+   ISC_USHORT    = word;
+   ISC_STATUS    = longint;
+   ISC_INT64     = int64;
+   ISC_UINT64    = qword;
+   ISC_LONG      = Longint;
+
+   PISC_USHORT = ^ISC_USHORT;
+   PISC_STATUS = ^ISC_STATUS;
+   PPISC_STATUS = ^PISC_STATUS;
+   PISC_INT64 = ^ISC_INT64;
+   PISC_UINT64 = ^ISC_UINT64;
+   PISC_LONG = ^ISC_LONG;
+
+  const
+     DSQL_close = 1;
+     DSQL_drop = 2;
+
+  {!!MVC
+    Removed all ISC_FAR, ISC_EXPORT_VARARG and ISC_EXPORT
+    macros.
+    They confuse h2pas...
+  !!MVC }
+  {                                                                  }
+  { Time & Date Support                                              }
+  {                                                                  }
+{$ifndef _ISC_TIMESTAMP_}
+
+  type
+
+     ISC_DATE = longint;
+     ISC_TIME = dword;
+     ISC_TIMESTAMP = record
+          timestamp_date : ISC_DATE;
+          timestamp_time : ISC_TIME;
+       end;
+     TISC_DATE = ISC_DATE;
+     TISC_TIME = ISC_TIME;
+     TISC_TIMESTAMP = ISC_TIMESTAMP;
+     PISC_DATE = ^ISC_DATE;
+     PISC_TIME = ^ISC_TIME;
+     PISC_TIMESTAMP = ^ISC_TIMESTAMP;
+  const
+     _ISC_TIMESTAMP_ = 1;
+{$endif}
+
+  const
+     ISC_TIME_SECONDS_PRECISION = 10000;
+     ISC_TIME_SECONDS_PRECISION_SCALE = -4;
+  {                                                                  }
+  { Blob id structure                                                }
+  {                                                                  }
+
+Type
+
+   GDS_QUAD = record
+      gds_quad_high : ISC_LONG;
+      gds_quad_low : ISC_LONG;
+   end;
+   TGDS_QUAD = GDS_QUAD;
+   PGDS_QUAD = ^GDS_QUAD;
+
+Type
+     ISC_QUAD = GDS_QUAD;
+     TISC_QUAD = ISC_QUAD;
+     PISC_QUAD = ^ISC_QUAD;
+
+{ !!field redefinitions !!
+     isc_quad_high = gds_quad_high;
+     isc_quad_low = gds_quad_low;
+}
+
+type
+
+     ISC_ARRAY_BOUND = record
+          array_bound_lower : smallint;
+          array_bound_upper : smallint;
+       end;
+     TISC_ARRAY_BOUND = ISC_ARRAY_BOUND;
+     PISC_ARRAY_BOUND = ^ISC_ARRAY_BOUND;
+
+     ISC_ARRAY_DESC = record
+          array_desc_dtype : byte;
+          array_desc_scale : char;
+          array_desc_length : word;
+          array_desc_field_name : array[0..31] of char;
+          array_desc_relation_name : array[0..31] of char;
+          array_desc_dimensions : smallint;
+          array_desc_flags : smallint;
+          array_desc_bounds : array[0..15] of ISC_ARRAY_BOUND;
+       end;
+     TISC_ARRAY_DESC = ISC_ARRAY_DESC;
+     PISC_ARRAY_DESC = ^ISC_ARRAY_DESC;
+
+     ISC_BLOB_DESC = record
+          blob_desc_subtype : smallint;
+          blob_desc_charset : smallint;
+          blob_desc_segment_size : smallint;
+          blob_desc_field_name : array[0..31] of byte;
+          blob_desc_relation_name : array[0..31] of byte;
+       end;
+     TISC_BLOB_DESC = ISC_BLOB_DESC;
+     PISC_BLOB_DESC = ^ISC_BLOB_DESC ;
+  {                          }
+  { Blob control structure   }
+  {                          }
+  {!!MVC
+  !!MVC }
+  { Source filter  }
+  {!!MVC
+  !!MVC }
+  { Argument to pass to source  }
+  { filter  }
+  { Target type  }
+  { Source type  }
+  { Length of buffer  }
+  { Length of current segment  }
+  { Length of blob parameter  }
+  { block  }
+  { Address of blob parameter  }
+  { block  }
+  { Address of segment buffer  }
+  { Length of longest segment  }
+  { Total number of segments  }
+  { Total length of blob  }
+  { Address of status vector  }
+  { Application specific data  }
+  TCTLSourceFunction  = function : isc_long;
+
+     PISC_BLOB_CTL = ^ISC_BLOB_CTL ;
+     ISC_BLOB_CTL = record
+          ctl_source : TCTLSourceFunction;     //  was ISC_STATUS ( *ctl_source)();
+          ctl_source_handle : pisc_blob_ctl  ; // was struct isc_blob_ctl  * ctl_source_handle;
+          ctl_to_sub_type : smallint;
+          ctl_from_sub_type : smallint;
+          ctl_buffer_length : word;
+          ctl_segment_length : word;
+          ctl_bpb_length : word;
+          ctl_bpb : Pchar;
+          ctl_buffer : Pbyte;
+          ctl_max_segment : ISC_LONG;
+          ctl_number_segments : ISC_LONG;
+          ctl_total_length : ISC_LONG;
+          ctl_status : PISC_STATUS;
+          ctl_data : array[0..7] of longint;
+       end;
+     TISC_BLOB_CTL = ISC_BLOB_CTL;
+
+  {                          }
+  { Blob stream definitions  }
+  {                          }
+  { Blob handle  }
+  { Address of buffer  }
+  { Next character  }
+  { Length of buffer  }
+  { Characters in buffer  }
+  { (mode) ? OUTPUT : INPUT  }
+
+     BSTREAM = record
+          bstr_blob : pointer;
+          bstr_buffer : Pchar;
+          bstr_ptr : Pchar;
+          bstr_length : smallint;
+          bstr_cnt : smallint;
+          bstr_mode : char;
+       end;
+     TBSTREAM = BSTREAM;
+     PBstream = ^BSTREAM;
+  {!!MVC
+
+  #define getb(p)       (--(p)->bstr_cnt >= 0 ?  (p)->bstr_ptr++ & 0377: BLOB_get (p))
+  #define putb(x,p) (((x) == '\n' || (!(--(p)->bstr_cnt))) ? BLOB_put ((x),p) : ((int) ( (p)->bstr_ptr++ = (unsigned) (x))))
+  #define putbx(x,p) ((!(--(p)->bstr_cnt)) ? BLOB_put ((x),p) : ((int) ( (p)->bstr_ptr++ = (unsigned) (x))))
+
+  !!MVC  }
+  {                          }
+  { Dynamic SQL definitions  }
+  {                          }
+  {                             }
+  { Declare the extended SQLDA  }
+  {                             }
+  { datatype of field  }
+  { scale factor  }
+  { datatype subtype - BLOBs & Text  }
+  { types only  }
+  { length of data area  }
+  { address of data  }
+  { address of indicator variable  }
+  { length of sqlname field  }
+  { name of field, name length + space  }
+  { for NULL  }
+  { length of relation name  }
+  { field's relation name + space for  }
+  { NULL  }
+  { length of owner name  }
+  { relation's owner name + space for  }
+  { NULL  }
+  { length of alias name  }
+  { relation's alias name + space for  }
+  { NULL  }
+
+     XSQLVAR = record
+          sqltype : smallint;
+          sqlscale : smallint;
+          sqlsubtype : smallint;
+          sqllen : smallint;
+          sqldata : Pchar;
+          sqlind : Psmallint;
+          sqlname_length : smallint;
+          sqlname : array[0..31] of char;
+          relname_length : smallint;
+          relname : array[0..31] of char;
+          ownname_length : smallint;
+          ownname : array[0..31] of char;
+          aliasname_length : smallint;
+          aliasname : array[0..31] of char;
+       end;
+     TXSQLVAR = XSQLVAR;
+     PXSQLVAR =^XSQLVAR;
+  { version of this XSQLDA  }
+  { XSQLDA name field  }
+  { length in bytes of SQLDA  }
+  { number of fields allocated  }
+  { actual number of fields  }
+  { first field address  }
+
+     XSQLDA = record
+          version : smallint;
+          sqldaid : array[0..7] of char;
+          sqldabc : ISC_LONG;
+          sqln : smallint;
+          sqld : smallint;
+          sqlvar : array[0..0] of XSQLVAR;
+       end;
+     TXSQLDA = XSQLDA;
+     PXSQLDA =^XSQLDA;
+
+  function XSQLDA_LENGTH(n: Integer): Integer;
+
+
+  const
+     SQLDA_VERSION1 = 1;
+  { meaning is same as DIALECT_xsqlda  }
+     SQL_DIALECT_V5 = 1;
+  { flagging anything that is delimited
+                                              by double quotes as an error and
+                                              flagging keyword DATE as an error  }
+     SQL_DIALECT_V6_TRANSITION = 2;
+  { supports SQL delimited identifier,
+                                              SQLDATE/DATE, TIME, TIMESTAMP,
+                                              CURRENT_DATE, CURRENT_TIME,
+                                              CURRENT_TIMESTAMP, and 64-bit exact
+                                              numeric type  }
+     SQL_DIALECT_V6 = 3;
+  { latest IB DIALECT  }
+     SQL_DIALECT_CURRENT = SQL_DIALECT_V6;
+  {                               }
+  { InterBase Handle Definitions  }
+  {                               }
+
+  type
+     isc_att_handle = pointer;
+     isc_blob_handle = pointer;
+     isc_db_handle = pointer;
+     isc_form_handle = pointer;
+     isc_req_handle = pointer;
+     isc_stmt_handle = pointer;
+     isc_svc_handle = pointer;
+     isc_tr_handle = pointer;
+     isc_win_handle = pointer;
+     isc_callback = procedure ;gdsdecl;
+     isc_resv_handle = ISC_LONG;
+     tisc_att_handle = isc_att_handle;
+     tisc_blob_handle = isc_blob_handle;
+     tisc_db_handle = isc_db_handle;
+     tisc_form_handle = isc_form_handle;
+     tisc_req_handle = isc_req_handle;
+     tisc_stmt_handle = isc_stmt_handle;
+     tisc_svc_handle = isc_svc_handle;
+     tisc_tr_handle = isc_tr_handle;
+     tisc_win_handle = isc_win_handle;
+     tisc_callback = isc_callback;
+     tisc_resv_handle = isc_resv_handle;
+     pisc_att_handle  =^isc_att_handle ;
+     pisc_blob_handle  =^isc_blob_handle ;
+     pisc_db_handle  =^isc_db_handle ;
+     pisc_form_handle  =^isc_form_handle ;
+     pisc_req_handle  =^isc_req_handle ;
+     pisc_stmt_handle  =^isc_stmt_handle ;
+     pisc_svc_handle  =^isc_svc_handle ;
+     pisc_tr_handle  =^isc_tr_handle ;
+     pisc_win_handle  =^isc_win_handle ;
+     pisc_callback  = ^isc_callback;
+     pisc_resv_handle  =^isc_resv_handle ;
+
+  {                          }
+  { OSRI database functions  }
+  {                          }
+
+  function isc_attach_database(_para1:PISC_STATUS; _para2:smallint; _para3:Pchar; _para4:Pisc_db_handle; _para5:smallint;
+             _para6:Pchar):ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_array_gen_sdl(_para1:PISC_STATUS; _para2:PISC_ARRAY_DESC; _para3:Psmallint; _para4:Pchar; _para5:Psmallint):ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_array_get_slice(_para1:PISC_STATUS; _para2:Pisc_db_handle; _para3:Pisc_tr_handle; _para4:PISC_QUAD; _para5:PISC_ARRAY_DESC;
+             _para6:pointer; _para7:PISC_LONG):ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_array_lookup_bounds(_para1:PISC_STATUS; _para2:Pisc_db_handle; _para3:Pisc_tr_handle; _para4:Pchar; _para5:Pchar;
+             _para6:PISC_ARRAY_DESC):ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_array_lookup_desc(_para1:PISC_STATUS; _para2:Pisc_db_handle; _para3:Pisc_tr_handle; _para4:Pchar; _para5:Pchar;
+             _para6:PISC_ARRAY_DESC):ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_array_set_desc(_para1:PISC_STATUS; _para2:Pchar; _para3:Pchar; _para4:Psmallint; _para5:Psmallint;
+             _para6:Psmallint; _para7:PISC_ARRAY_DESC):ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_array_put_slice(_para1:PISC_STATUS; _para2:Pisc_db_handle; _para3:Pisc_tr_handle; _para4:PISC_QUAD; _para5:PISC_ARRAY_DESC;
+             _para6:pointer; _para7:PISC_LONG):ISC_STATUS; gdsdecl; external gdslib;
+
+  procedure isc_blob_default_desc(_para1:PISC_BLOB_DESC; _para2:Pbyte; _para3:Pbyte); gdsdecl; external gdslib;
+
+  function isc_blob_gen_bpb(_para1:PISC_STATUS; _para2:PISC_BLOB_DESC; _para3:PISC_BLOB_DESC; _para4:word; _para5:Pbyte;
+             _para6:Pword):ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_blob_info(_para1:PISC_STATUS; _para2:Pisc_blob_handle; _para3:smallint; _para4:Pchar; _para5:smallint;
+             _para6:Pchar):ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_blob_lookup_desc(_para1:PISC_STATUS; _para2:Pisc_db_handle; _para3:Pisc_tr_handle; _para4:Pbyte; _para5:Pbyte;
+             _para6:PISC_BLOB_DESC; _para7:Pbyte):ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_blob_set_desc(_para1:PISC_STATUS; _para2:Pbyte; _para3:Pbyte; _para4:smallint; _para5:smallint;
+             _para6:smallint; _para7:PISC_BLOB_DESC):ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_cancel_blob(_para1:PISC_STATUS; _para2:Pisc_blob_handle):ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_cancel_events(_para1:PISC_STATUS; _para2:Pisc_db_handle; _para3:PISC_LONG):ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_close_blob(_para1:PISC_STATUS; _para2:Pisc_blob_handle):ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_commit_retaining(_para1:PISC_STATUS; _para2:Pisc_tr_handle):ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_commit_transaction(_para1:PISC_STATUS; _para2:Pisc_tr_handle):ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_create_blob(_para1:PISC_STATUS; _para2:Pisc_db_handle; _para3:Pisc_tr_handle; _para4:Pisc_blob_handle; _para5:PISC_QUAD):ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_create_blob2(_para1:PISC_STATUS; _para2:Pisc_db_handle; _para3:Pisc_tr_handle; _para4:Pisc_blob_handle; _para5:PISC_QUAD;
+             _para6:smallint; _para7:Pchar):ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_create_database(_para1:PISC_STATUS; _para2:smallint; _para3:Pchar; _para4:Pisc_db_handle; _para5:smallint;
+             _para6:Pchar; _para7:smallint):ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_database_info(_para1:PISC_STATUS; _para2:Pisc_db_handle; _para3:smallint; _para4:Pchar; _para5:smallint;
+             _para6:Pchar):ISC_STATUS; gdsdecl; external gdslib;
+
+  procedure isc_decode_date(_para1:PISC_QUAD; _para2:pointer); gdsdecl; external gdslib;
+
+  procedure isc_decode_sql_date(_para1:PISC_DATE; _para2:pointer); gdsdecl; external gdslib;
+
+  procedure isc_decode_sql_time(_para1:PISC_TIME; _para2:pointer); gdsdecl; external gdslib;
+
+  procedure isc_decode_timestamp(_para1:PISC_TIMESTAMP; _para2:pointer); gdsdecl; external gdslib;
+
+  function isc_detach_database(_para1:PISC_STATUS; _para2:Pisc_db_handle):ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_drop_database(_para1:PISC_STATUS; _para2:Pisc_db_handle):ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_dsql_allocate_statement(_para1:PISC_STATUS; _para2:Pisc_db_handle; _para3:Pisc_stmt_handle):ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_dsql_alloc_statement2(_para1:PISC_STATUS; _para2:Pisc_db_handle; _para3:Pisc_stmt_handle):ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_dsql_describe(_para1:PISC_STATUS; _para2:Pisc_stmt_handle; _para3:word; _para4:PXSQLDA):ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_dsql_describe_bind(_para1:PISC_STATUS; _para2:Pisc_stmt_handle; _para3:word; _para4:PXSQLDA):ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_dsql_exec_immed2(_para1:PISC_STATUS; _para2:Pisc_db_handle; _para3:Pisc_tr_handle; _para4:word; _para5:Pchar;
+             _para6:word; _para7:PXSQLDA; _para8:PXSQLDA):ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_dsql_execute(_para1:PISC_STATUS; _para2:Pisc_tr_handle; _para3:Pisc_stmt_handle; _para4:word; _para5:PXSQLDA):ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_dsql_execute2(_para1:PISC_STATUS; _para2:Pisc_tr_handle; _para3:Pisc_stmt_handle; _para4:word; _para5:PXSQLDA;
+             _para6:PXSQLDA):ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_dsql_execute_immediate(_para1:PISC_STATUS; _para2:Pisc_db_handle; _para3:Pisc_tr_handle; _para4:word; _para5:Pchar;
+             _para6:word; _para7:PXSQLDA):ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_dsql_fetch(_para1:PISC_STATUS; _para2:Pisc_stmt_handle; _para3:word; _para4:PXSQLDA):ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_dsql_finish(_para1:Pisc_db_handle):ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_dsql_free_statement(_para1:PISC_STATUS; _para2:Pisc_stmt_handle; _para3:word):ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_dsql_insert(_para1:PISC_STATUS; _para2:Pisc_stmt_handle; _para3:word; _para4:PXSQLDA):ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_dsql_prepare(_para1:PISC_STATUS; _para2:Pisc_tr_handle; _para3:Pisc_stmt_handle; _para4:word; _para5:Pchar;
+             _para6:word; _para7:PXSQLDA):ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_dsql_set_cursor_name(_para1:PISC_STATUS; _para2:Pisc_stmt_handle; _para3:Pchar; _para4:word):ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_dsql_sql_info(_para1:PISC_STATUS; _para2:Pisc_stmt_handle; _para3:smallint; _para4:Pchar; _para5:smallint;
+             _para6:Pchar):ISC_STATUS; gdsdecl; external gdslib;
+
+  procedure isc_encode_date(_para1:pointer; _para2:PISC_QUAD); gdsdecl; external gdslib;
+
+  procedure isc_encode_sql_date(_para1:pointer; _para2:PISC_DATE); gdsdecl; external gdslib;
+
+  procedure isc_encode_sql_time(_para1:pointer; _para2:PISC_TIME); gdsdecl; external gdslib;
+
+  procedure isc_encode_timestamp(_para1:pointer; _para2:PISC_TIMESTAMP); gdsdecl; external gdslib;
+
+  function isc_event_block(_para1:PPchar; _para2:PPchar; _para3:word; args:array of const):ISC_LONG; cdecl; external gdslib;
+
+  {!!MVC
+  void         isc_event_counts (unsigned ISC_LONG   ,
+                                         short,
+                                         char   ,
+                                         char   ); gdsdecl; external gdslib;
+  !!MVC }
+  procedure isc_expand_dpb(_para1:PPchar; _para2:Psmallint; args:array of const); cdecl; external gdslib;
+
+  function isc_modify_dpb(_para1:PPchar; _para2:Psmallint; _para3:word; _para4:Pchar; _para5:smallint):longint; gdsdecl; external gdslib;
+
+  function isc_free(_para1:Pchar):ISC_LONG; gdsdecl; external gdslib;
+
+  function isc_get_segment(_para1:PISC_STATUS; _para2:Pisc_blob_handle; _para3:Pword; _para4:word; _para5:Pchar):ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_get_slice(_para1:PISC_STATUS; _para2:Pisc_db_handle; _para3:Pisc_tr_handle; _para4:PISC_QUAD; _para5:smallint;
+             _para6:Pchar; _para7:smallint; _para8:PISC_LONG; _para9:ISC_LONG; _para10:pointer;
+             _para11:PISC_LONG):ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_interprete(_para1:Pchar; _para2:PPISC_STATUS):ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_open_blob(_para1:PISC_STATUS; _para2:Pisc_db_handle; _para3:Pisc_tr_handle; _para4:Pisc_blob_handle; _para5:PISC_QUAD):ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_open_blob2(_para1:PISC_STATUS; _para2:Pisc_db_handle; _para3:Pisc_tr_handle; _para4:Pisc_blob_handle; _para5:PISC_QUAD;
+             _para6:smallint; _para7:Pchar):ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_prepare_transaction2(_para1:PISC_STATUS; _para2:Pisc_tr_handle; _para3:smallint; _para4:Pchar):ISC_STATUS; gdsdecl; external gdslib;
+
+  procedure isc_print_sqlerror(_para1:smallint; _para2:PISC_STATUS); gdsdecl; external gdslib;
+
+  function isc_print_status(_para1:PISC_STATUS):ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_put_segment(_para1:PISC_STATUS; _para2:Pisc_blob_handle; _para3:word; _para4:Pchar):ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_put_slice(_para1:PISC_STATUS; _para2:Pisc_db_handle; _para3:Pisc_tr_handle; _para4:PISC_QUAD; _para5:smallint;
+             _para6:Pchar; _para7:smallint; _para8:PISC_LONG; _para9:ISC_LONG; _para10:pointer):ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_que_events(_para1:PISC_STATUS; _para2:Pisc_db_handle; _para3:PISC_LONG; _para4:smallint; _para5:Pchar;
+             _para6:isc_callback; _para7:pointer):ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_rollback_retaining(_para1:PISC_STATUS; _para2:Pisc_tr_handle):ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_rollback_transaction(_para1:PISC_STATUS; _para2:Pisc_tr_handle):ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_start_multiple(_para1:PISC_STATUS; _para2:Pisc_tr_handle; _para3:smallint; _para4:pointer):ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_start_transaction(_para1:PISC_STATUS; _para2:Pisc_tr_handle; _para3:smallint; args:array of const):ISC_STATUS; cdecl; external gdslib;
+
+  function isc_sqlcode(_para1:PISC_STATUS):ISC_LONG; gdsdecl; external gdslib;
+
+  procedure isc_sql_interprete(_para1:smallint; _para2:Pchar; _para3:smallint); gdsdecl; external gdslib;
+
+  function isc_transaction_info(_para1:PISC_STATUS; _para2:Pisc_tr_handle; _para3:smallint; _para4:Pchar; _para5:smallint;
+             _para6:Pchar):ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_transact_request(_para1:PISC_STATUS; _para2:Pisc_db_handle; _para3:Pisc_tr_handle; _para4:word; _para5:Pchar;
+             _para6:word; _para7:Pchar; _para8:word; _para9:Pchar):ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_vax_integer(_para1:Pchar; _para2:smallint):ISC_LONG; gdsdecl; external gdslib;
+
+  function isc_portable_integer(_para1:Pbyte; _para2:smallint):ISC_INT64; gdsdecl; external gdslib;
+
+  {                                    }
+  { Security Functions and structures  }
+  {                                    }
+
+  const
+     sec_uid_spec = $01;
+     sec_gid_spec = $02;
+     sec_server_spec = $04;
+     sec_password_spec = $08;
+     sec_group_name_spec = $10;
+     sec_first_name_spec = $20;
+     sec_middle_name_spec = $40;
+     sec_last_name_spec = $80;
+     sec_dba_user_name_spec = $100;
+     sec_dba_password_spec = $200;
+     sec_protocol_tcpip = 1;
+     sec_protocol_netbeui = 2;
+     sec_protocol_spx = 3;
+     sec_protocol_local = 4;
+  { which fields are specified  }
+  { the user's id  }
+  { the user's group id  }
+  { protocol to use for connection  }
+  { server to administer  }
+  { the user's name  }
+  { the user's password  }
+  { the group name  }
+  { the user's first name  }
+  { the user's middle name  }
+  { the user's last name  }
+  { the dba user name  }
+  { the dba password  }
+
+  type
+
+     USER_SEC_DATA = record
+          sec_flags : smallint;
+          uid : longint;
+          gid : longint;
+          protocol : longint;
+          server : Pchar;
+          user_name : Pchar;
+          password : Pchar;
+          group_name : Pchar;
+          first_name : Pchar;
+          middle_name : Pchar;
+          last_name : Pchar;
+          dba_user_name : Pchar;
+          dba_password : Pchar;
+       end;
+     TUSER_SEC_DATA = USER_SEC_DATA;
+     PUSER_SEC_DATA = ^USER_SEC_DATA;
+
+  function isc_add_user(_para1:PISC_STATUS; _para2:PUSER_SEC_DATA):longint; gdsdecl; external gdslib;
+
+  function isc_delete_user(_para1:PISC_STATUS; _para2:PUSER_SEC_DATA):longint; gdsdecl; external gdslib;
+
+  function isc_modify_user(_para1:PISC_STATUS; _para2:PUSER_SEC_DATA):longint; gdsdecl; external gdslib;
+
+  {                                 }
+  {  Other OSRI functions           }
+  {                                 }
+  function isc_compile_request(_para1:PISC_STATUS; _para2:Pisc_db_handle; _para3:Pisc_req_handle; _para4:smallint; _para5:Pchar):ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_compile_request2(_para1:PISC_STATUS; _para2:Pisc_db_handle; _para3:Pisc_req_handle; _para4:smallint; _para5:Pchar):ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_ddl(_para1:PISC_STATUS; _para2:Pisc_db_handle; _para3:Pisc_tr_handle; _para4:smallint; _para5:Pchar):ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_prepare_transaction(_para1:PISC_STATUS; _para2:Pisc_tr_handle):ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_receive(_para1:PISC_STATUS; _para2:Pisc_req_handle; _para3:smallint; _para4:smallint; _para5:pointer;
+             _para6:smallint):ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_reconnect_transaction(_para1:PISC_STATUS; _para2:Pisc_db_handle; _para3:Pisc_tr_handle; _para4:smallint; _para5:Pchar):ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_release_request(_para1:PISC_STATUS; _para2:Pisc_req_handle):ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_request_info(_para1:PISC_STATUS; _para2:Pisc_req_handle; _para3:smallint; _para4:smallint; _para5:Pchar;
+             _para6:smallint; _para7:Pchar):ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_seek_blob(_para1:PISC_STATUS; _para2:Pisc_blob_handle; _para3:smallint; _para4:ISC_LONG; _para5:PISC_LONG):ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_send(_para1:PISC_STATUS; _para2:Pisc_req_handle; _para3:smallint; _para4:smallint; _para5:pointer;
+             _para6:smallint):ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_start_and_send(_para1:PISC_STATUS; _para2:Pisc_req_handle; _para3:Pisc_tr_handle; _para4:smallint; _para5:smallint;
+             _para6:pointer; _para7:smallint):ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_start_request(_para1:PISC_STATUS; _para2:Pisc_req_handle; _para3:Pisc_tr_handle; _para4:smallint):ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_unwind_request(_para1:PISC_STATUS; _para2:Pisc_tr_handle; _para3:smallint):ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_wait_for_event(_para1:PISC_STATUS; _para2:Pisc_db_handle; _para3:smallint; _para4:Pchar; _para5:Pchar):ISC_STATUS; gdsdecl; external gdslib;
+
+  {                            }
+  { Other Sql functions        }
+  {                            }
+  function isc_close(_para1:PISC_STATUS; _para2:Pchar):ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_declare(_para1:PISC_STATUS; _para2:Pchar; _para3:Pchar):ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_describe(_para1:PISC_STATUS; _para2:Pchar; _para3:PXSQLDA):ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_describe_bind(_para1:PISC_STATUS; _para2:Pchar; _para3:PXSQLDA):ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_execute(_para1:PISC_STATUS; _para2:Pisc_tr_handle; _para3:Pchar; _para4:PXSQLDA):ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_execute_immediate(_para1:PISC_STATUS; _para2:Pisc_db_handle; _para3:Pisc_tr_handle; _para4:Psmallint; _para5:Pchar):ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_fetch(_para1:PISC_STATUS; _para2:Pchar; _para3:PXSQLDA):ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_open(_para1:PISC_STATUS; _para2:Pisc_tr_handle; _para3:Pchar; _para4:PXSQLDA):ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_prepare(_para1:PISC_STATUS; _para2:Pisc_db_handle; _para3:Pisc_tr_handle; _para4:Pchar; _para5:Psmallint;
+             _para6:Pchar; _para7:PXSQLDA):ISC_STATUS; gdsdecl; external gdslib;
+
+  {                                    }
+  { Other Dynamic sql functions        }
+  {                                    }
+  function isc_dsql_execute_m(_para1:PISC_STATUS; _para2:Pisc_tr_handle; _para3:Pisc_stmt_handle; _para4:word; _para5:Pchar;
+             _para6:word; _para7:word; _para8:Pchar):ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_dsql_execute2_m(_para1:PISC_STATUS; _para2:Pisc_tr_handle; _para3:Pisc_stmt_handle; _para4:word; _para5:Pchar;
+             _para6:word; _para7:word; _para8:Pchar; _para9:word; _para10:Pchar;
+             _para11:word; _para12:word; _para13:Pchar):ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_dsql_execute_immediate_m(_para1:PISC_STATUS; _para2:Pisc_db_handle; _para3:Pisc_tr_handle; _para4:word; _para5:Pchar;
+             _para6:word; _para7:word; _para8:Pchar; _para9:word; _para10:word;
+             _para11:Pchar):ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_dsql_exec_immed3_m(_para1:PISC_STATUS; _para2:Pisc_db_handle; _para3:Pisc_tr_handle; _para4:word; _para5:Pchar;
+             _para6:word; _para7:word; _para8:Pchar; _para9:word; _para10:word;
+             _para11:Pchar; _para12:word; _para13:Pchar; _para14:word; _para15:word;
+             _para16:Pchar):ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_dsql_fetch_m(_para1:PISC_STATUS; _para2:Pisc_stmt_handle; _para3:word; _para4:Pchar; _para5:word;
+             _para6:word; _para7:Pchar):ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_dsql_insert_m(_para1:PISC_STATUS; _para2:Pisc_stmt_handle; _para3:word; _para4:Pchar; _para5:word;
+             _para6:word; _para7:Pchar):ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_dsql_prepare_m(_para1:PISC_STATUS; _para2:Pisc_tr_handle; _para3:Pisc_stmt_handle; _para4:word; _para5:Pchar;
+             _para6:word; _para7:word; _para8:Pchar; _para9:word; _para10:Pchar):ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_dsql_release(_para1:PISC_STATUS; _para2:Pchar):ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_embed_dsql_close(_para1:PISC_STATUS; _para2:Pchar):ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_embed_dsql_declare(_para1:PISC_STATUS; _para2:Pchar; _para3:Pchar):ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_embed_dsql_describe(_para1:PISC_STATUS; _para2:Pchar; _para3:word; _para4:PXSQLDA):ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_embed_dsql_describe_bind(_para1:PISC_STATUS; _para2:Pchar; _para3:word; _para4:PXSQLDA):ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_embed_dsql_execute(_para1:PISC_STATUS; _para2:Pisc_tr_handle; _para3:Pchar; _para4:word; _para5:PXSQLDA):ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_embed_dsql_execute2(_para1:PISC_STATUS; _para2:Pisc_tr_handle; _para3:Pchar; _para4:word; _para5:PXSQLDA;
+             _para6:PXSQLDA):ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_embed_dsql_execute_immed(_para1:PISC_STATUS; _para2:Pisc_db_handle; _para3:Pisc_tr_handle; _para4:word; _para5:Pchar;
+             _para6:word; _para7:PXSQLDA):ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_embed_dsql_fetch(_para1:PISC_STATUS; _para2:Pchar; _para3:word; _para4:PXSQLDA):ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_embed_dsql_open(_para1:PISC_STATUS; _para2:Pisc_tr_handle; _para3:Pchar; _para4:word; _para5:PXSQLDA):ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_embed_dsql_open2(_para1:PISC_STATUS; _para2:Pisc_tr_handle; _para3:Pchar; _para4:word; _para5:PXSQLDA;
+             _para6:PXSQLDA):ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_embed_dsql_insert(_para1:PISC_STATUS; _para2:Pchar; _para3:word; _para4:PXSQLDA):ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_embed_dsql_prepare(_para1:PISC_STATUS; _para2:Pisc_db_handle; _para3:Pisc_tr_handle; _para4:Pchar; _para5:word;
+             _para6:Pchar; _para7:word; _para8:PXSQLDA):ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_embed_dsql_release(_para1:PISC_STATUS; _para2:Pchar):ISC_STATUS; gdsdecl; external gdslib;
+
+  {                             }
+  { Other Blob functions        }
+  {                             }
+  function BLOB_open(_para1:isc_blob_handle; _para2:Pchar; _para3:longint):PBSTREAM; gdsdecl; external gdslib;
+
+  function BLOB_put(_para1:char; _para2:PBSTREAM):longint; gdsdecl; external gdslib;
+
+  function BLOB_close(_para1:PBSTREAM):longint; gdsdecl; external gdslib;
+
+  function BLOB_get(_para1:PBSTREAM):longint; gdsdecl; external gdslib;
+
+  function BLOB_display(_para1:PISC_QUAD; _para2:isc_db_handle; _para3:isc_tr_handle; _para4:Pchar):longint; gdsdecl; external gdslib;
+
+  function BLOB_dump(_para1:PISC_QUAD; _para2:isc_db_handle; _para3:isc_tr_handle; _para4:Pchar):longint; gdsdecl; external gdslib;
+
+  function BLOB_edit(_para1:PISC_QUAD; _para2:isc_db_handle; _para3:isc_tr_handle; _para4:Pchar):longint; gdsdecl; external gdslib;
+
+  function BLOB_load(_para1:PISC_QUAD; _para2:isc_db_handle; _para3:isc_tr_handle; _para4:Pchar):longint; gdsdecl; external gdslib;
+
+  function BLOB_text_dump(_para1:PISC_QUAD; _para2:isc_db_handle; _para3:isc_tr_handle; _para4:Pchar):longint; gdsdecl; external gdslib;
+
+  function BLOB_text_load(_para1:PISC_QUAD; _para2:isc_db_handle; _para3:isc_tr_handle; _para4:Pchar):longint; gdsdecl; external gdslib;
+
+  function Bopen(_para1:PISC_QUAD; _para2:isc_db_handle; _para3:isc_tr_handle; _para4:Pchar):PBSTREAM; gdsdecl; external gdslib;
+
+{$IFDEF Unix}
+  function Bopen2(_para1:PISC_QUAD; _para2:isc_db_handle; _para3:isc_tr_handle; _para4:Pchar; _para5:word):PBSTREAM; gdsdecl; external gdslib;
+{$ENDIF}
+
+  {                             }
+  { Other Misc functions        }
+  {                             }
+  function isc_ftof(_para1:Pchar; _para2:word; _para3:Pchar; _para4:word):ISC_LONG; gdsdecl; external gdslib;
+
+  function isc_print_blr(_para1:Pchar; _para2:isc_callback; _para3:pointer; _para4:smallint):ISC_STATUS; gdsdecl; external gdslib;
+
+  procedure isc_set_debug(_para1:longint); gdsdecl; external gdslib;
+
+  procedure isc_qtoq(_para1:PISC_QUAD; _para2:PISC_QUAD); gdsdecl; external gdslib;
+
+  procedure isc_vtof(_para1:Pchar; _para2:Pchar; _para3:word); gdsdecl; external gdslib;
+
+  procedure isc_vtov(_para1:Pchar; _para2:Pchar; _para3:smallint); gdsdecl; external gdslib;
+
+  function isc_version(_para1:Pisc_db_handle; _para2:isc_callback; _para3:pointer):longint; gdsdecl; external gdslib;
+
+{$IFDEF Unix}
+  function isc_reset_fpe(_para1:word):ISC_LONG; gdsdecl; external gdslib;
+{$ENDIF}
+
+  {                                        }
+  { Service manager functions              }
+  {                                        }
+  (*!!MVC
+  #define ADD_SPB_LENGTH(p, length)     { (p)++ = (length); \
+                                          (p)++ = (length) >> 8;}
+
+  #define ADD_SPB_NUMERIC(p, data)      { (p)++ = (data); \
+                                          (p)++ = (data) >> 8; \
+                                          (p)++ = (data) >> 16; \
+                                          (p)++ = (data) >> 24;}
+  !!MVC *)
+
+  function isc_service_attach(_para1:PISC_STATUS; _para2:word; _para3:Pchar; _para4:Pisc_svc_handle; _para5:word;
+             _para6:Pchar):ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_service_detach(_para1:PISC_STATUS; _para2:Pisc_svc_handle):ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_service_query(_para1:PISC_STATUS; _para2:Pisc_svc_handle; _para3:Pisc_resv_handle; _para4:word; _para5:Pchar;
+             _para6:word; _para7:Pchar; _para8:word; _para9:Pchar):ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_service_start(_para1:PISC_STATUS; _para2:Pisc_svc_handle; _para3:Pisc_resv_handle; _para4:word; _para5:Pchar):ISC_STATUS; gdsdecl; external gdslib;
+
+  {                              }
+  { Forms functions              }
+  {                              }
+{$IFDEF Unix}
+  function isc_compile_map(_para1:PISC_STATUS; _para2:Pisc_form_handle; _para3:Pisc_req_handle; _para4:Psmallint; _para5:Pchar):ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_compile_menu(_para1:PISC_STATUS; _para2:Pisc_form_handle; _para3:Pisc_req_handle; _para4:Psmallint; _para5:Pchar):ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_compile_sub_map(_para1:PISC_STATUS; _para2:Pisc_win_handle; _para3:Pisc_req_handle; _para4:Psmallint; _para5:Pchar):ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_create_window(_para1:PISC_STATUS; _para2:Pisc_win_handle; _para3:Psmallint; _para4:Pchar; _para5:Psmallint;
+             _para6:Psmallint):ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_delete_window(_para1:PISC_STATUS; _para2:Pisc_win_handle):ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_drive_form(_para1:PISC_STATUS; _para2:Pisc_db_handle; _para3:Pisc_tr_handle; _para4:Pisc_win_handle; _para5:Pisc_req_handle;
+             _para6:Pbyte; _para7:Pbyte):ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_drive_menu(_para1:PISC_STATUS; _para2:Pisc_win_handle; _para3:Pisc_req_handle; _para4:Psmallint; _para5:Pchar;
+             _para6:Psmallint; _para7:Pchar; _para8:Psmallint; _para9:Psmallint; _para10:Pchar;
+             _para11:PISC_LONG):ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_form_delete(_para1:PISC_STATUS; _para2:Pisc_form_handle):ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_form_fetch(_para1:PISC_STATUS; _para2:Pisc_db_handle; _para3:Pisc_tr_handle; _para4:Pisc_req_handle; _para5:Pbyte):ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_form_insert(_para1:PISC_STATUS; _para2:Pisc_db_handle; _para3:Pisc_tr_handle; _para4:Pisc_req_handle; _para5:Pbyte):ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_get_entree(_para1:PISC_STATUS; _para2:Pisc_req_handle; _para3:Psmallint; _para4:Pchar; _para5:PISC_LONG;
+             _para6:Psmallint):ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_initialize_menu(_para1:PISC_STATUS; _para2:Pisc_req_handle):ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_menu(_para1:PISC_STATUS; _para2:Pisc_win_handle; _para3:Pisc_req_handle; _para4:Psmallint; _para5:Pchar):ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_load_form(_para1:PISC_STATUS; _para2:Pisc_db_handle; _para3:Pisc_tr_handle; _para4:Pisc_form_handle; _para5:Psmallint;
+             _para6:Pchar):ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_pop_window(_para1:PISC_STATUS; _para2:Pisc_win_handle):ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_put_entree(_para1:PISC_STATUS; _para2:Pisc_req_handle; _para3:Psmallint; _para4:Pchar; _para5:PISC_LONG):ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_reset_form(_para1:PISC_STATUS; _para2:Pisc_req_handle):ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_suspend_window(_para1:PISC_STATUS; _para2:Pisc_win_handle):ISC_STATUS; gdsdecl; external gdslib;
+{$ENDIF}
+
+  function isc_attach_database:ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_array_gen_sdl:ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_array_get_slice:ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_array_lookup_bounds:ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_array_lookup_desc:ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_array_set_desc:ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_array_put_slice:ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_blob_gen_bpb:ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_blob_info:ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_blob_lookup_desc:ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_blob_set_desc:ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_cancel_blob:ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_cancel_events:ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_close_blob:ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_commit_retaining:ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_commit_transaction:ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_compile_request:ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_compile_request2:ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_create_blob:ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_create_blob2:ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_create_database:ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_database_info:ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_ddl:ISC_STATUS; gdsdecl; external gdslib;
+
+  procedure isc_decode_date; gdsdecl; external gdslib;
+
+  procedure isc_decode_sql_date; gdsdecl; external gdslib;
+
+  procedure isc_decode_sql_time; gdsdecl; external gdslib;
+
+  procedure isc_decode_timestamp; gdsdecl; external gdslib;
+
+  function isc_detach_database:ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_drop_database:ISC_STATUS; gdsdecl; external gdslib;
+
+  procedure isc_encode_date; gdsdecl; external gdslib;
+
+  procedure isc_encode_sql_date; gdsdecl; external gdslib;
+
+  procedure isc_encode_sql_time; gdsdecl; external gdslib;
+
+  procedure isc_encode_timestamp; gdsdecl; external gdslib;
+
+  function isc_event_block:ISC_LONG; cdecl; external gdslib;
+
+  procedure isc_event_counts; gdsdecl; external gdslib;
+
+  procedure isc_expand_dpb; cdecl; external gdslib;
+
+  function isc_modify_dpb:longint; gdsdecl; external gdslib;
+
+  function isc_free:ISC_LONG; gdsdecl; external gdslib;
+
+  function isc_get_segment:ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_get_slice:ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_interprete:ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_open_blob:ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_open_blob2:ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_prepare_transaction:ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_prepare_transaction2:ISC_STATUS; gdsdecl; external gdslib;
+
+  procedure isc_print_sqlerror; gdsdecl; external gdslib;
+
+  function isc_print_status:ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_put_segment:ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_put_slice:ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_que_events:ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_receive:ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_reconnect_transaction:ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_release_request:ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_request_info:ISC_STATUS; gdsdecl; external gdslib;
+
+{$IFDEF Unix}
+  function isc_reset_fpe:ISC_LONG; gdsdecl; external gdslib;
+{$ENDIF}
+
+  function isc_rollback_transaction:ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_rollback_retaining:ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_seek_blob:ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_send:ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_service_attach:ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_service_detach:ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_service_query:ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_service_start:ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_start_and_send:ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_start_multiple:ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_start_request:ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_start_transaction:ISC_STATUS; cdecl; external gdslib;
+
+  function isc_sqlcode:ISC_LONG; gdsdecl; external gdslib;
+
+  function isc_transaction_info:ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_transact_request:ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_unwind_request:ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_wait_for_event:ISC_STATUS; gdsdecl; external gdslib;
+
+  function isc_ftof:ISC_LONG; gdsdecl; external gdslib;
+
+  function isc_print_blr:ISC_STATUS; gdsdecl; external gdslib;
+
+  procedure isc_set_debug; gdsdecl; external gdslib;
+
+  procedure isc_qtoq; gdsdecl; external gdslib;
+
+  function isc_vax_integer:ISC_LONG; gdsdecl; external gdslib;
+
+  procedure isc_vtof; gdsdecl; external gdslib;
+
+  procedure isc_vtov; gdsdecl; external gdslib;
+
+  function isc_version:longint; gdsdecl; external gdslib;
+
+  {                 }
+  { Blob functions  }
+  {                 }
+
+  function Bopen:PBSTREAM; gdsdecl; external gdslib;
+
+  function BLOB_open:PBSTREAM; gdsdecl; external gdslib;
+
+{$IFDEF Unix}
+  function Bopen2:PBSTREAM; gdsdecl; external gdslib;
+{$ENDIF}
+
+  { __cplusplus || __STDC__  }
+  {                                                  }
+  { Actions to pass to the blob filter (ctl_source)  }
+  {                                                  }
+
+  const
+     isc_blob_filter_open = 0;
+     isc_blob_filter_get_segment = 1;
+     isc_blob_filter_close = 2;
+     isc_blob_filter_create = 3;
+     isc_blob_filter_put_segment = 4;
+     isc_blob_filter_alloc = 5;
+     isc_blob_filter_free = 6;
+     isc_blob_filter_seek = 7;
+  {                  }
+  { Blr definitions  }
+  {                  }
+{$ifndef _JRD_BLR_H_}
+  {!!MVC
+  #define blr_word(n) ((n) % 256), ((n) / 256)
+  !!MVC }
+
+  const
+     blr_text = 14;
+     blr_text2 = 15;
+     blr_short = 7;
+     blr_long = 8;
+     blr_quad = 9;
+     blr_int64 = 16;
+     blr_float = 10;
+     blr_double = 27;
+     blr_d_float = 11;
+     blr_timestamp = 35;
+     blr_varying = 37;
+     blr_varying2 = 38;
+     blr_blob = 261;
+     blr_cstring = 40;
+     blr_cstring2 = 41;
+     blr_blob_id = 45;
+     blr_sql_date = 12;
+     blr_sql_time = 13;
+  { Historical alias for pre V6 applications  }
+     blr_date = blr_timestamp;
+     blr_inner = 0;
+     blr_left = 1;
+     blr_right = 2;
+     blr_full = 3;
+     blr_gds_code = 0;
+     blr_sql_code = 1;
+     blr_exception = 2;
+     blr_trigger_code = 3;
+     blr_default_code = 4;
+     blr_version4 = 4;
+     blr_version5 = 5;
+     blr_eoc = 76;
+     blr_end = 255;
+     blr_assignment = 1;
+     blr_begin = 2;
+     blr_dcl_variable = 3;
+     blr_message = 4;
+     blr_erase = 5;
+     blr_fetch = 6;
+     blr_for = 7;
+     blr_if = 8;
+     blr_loop = 9;
+     blr_modify = 10;
+     blr_handler = 11;
+     blr_receive = 12;
+     blr_select = 13;
+     blr_send = 14;
+     blr_store = 15;
+     blr_label = 17;
+     blr_leave = 18;
+     blr_store2 = 19;
+     blr_post = 20;
+     blr_literal = 21;
+     blr_dbkey = 22;
+     blr_field = 23;
+     blr_fid = 24;
+     blr_parameter = 25;
+     blr_variable = 26;
+     blr_average = 27;
+     blr_count = 28;
+     blr_maximum = 29;
+     blr_minimum = 30;
+     blr_total = 31;
+     blr_add = 34;
+     blr_subtract = 35;
+     blr_multiply = 36;
+     blr_divide = 37;
+     blr_negate = 38;
+     blr_concatenate = 39;
+     blr_substring = 40;
+     blr_parameter2 = 41;
+     blr_from = 42;
+     blr_via = 43;
+     blr_user_name = 44;
+     blr_null = 45;
+     blr_eql = 47;
+     blr_neq = 48;
+     blr_gtr = 49;
+     blr_geq = 50;
+     blr_lss = 51;
+     blr_leq = 52;
+     blr_containing = 53;
+     blr_matching = 54;
+     blr_starting = 55;
+     blr_between = 56;
+     blr_or = 57;
+     blr_and = 58;
+     blr_not = 59;
+     blr_any = 60;
+     blr_missing = 61;
+     blr_unique = 62;
+     blr_like = 63;
+     blr_stream = 65;
+     blr_set_index = 66;
+     blr_rse = 67;
+     blr_first = 68;
+     blr_project = 69;
+     blr_sort = 70;
+     blr_boolean = 71;
+     blr_ascending = 72;
+     blr_descending = 73;
+     blr_relation = 74;
+     blr_rid = 75;
+     blr_union = 76;
+     blr_map = 77;
+     blr_group_by = 78;
+     blr_aggregate = 79;
+     blr_join_type = 80;
+     blr_agg_count = 83;
+     blr_agg_max = 84;
+     blr_agg_min = 85;
+     blr_agg_total = 86;
+     blr_agg_average = 87;
+     blr_parameter3 = 88;
+     blr_run_count = 118;
+     blr_run_max = 89;
+     blr_run_min = 90;
+     blr_run_total = 91;
+     blr_run_average = 92;
+     blr_agg_count2 = 93;
+     blr_agg_count_distinct = 94;
+     blr_agg_total_distinct = 95;
+     blr_agg_average_distinct = 96;
+     blr_function = 100;
+     blr_gen_id = 101;
+     blr_prot_mask = 102;
+     blr_upcase = 103;
+     blr_lock_state = 104;
+     blr_value_if = 105;
+     blr_matching2 = 106;
+     blr_index = 107;
+     blr_ansi_like = 108;
+     blr_bookmark = 109;
+     blr_crack = 110;
+     blr_force_crack = 111;
+     blr_seek = 112;
+     blr_find = 113;
+     blr_continue = 0;
+     blr_forward = 1;
+     blr_backward = 2;
+     blr_bof_forward = 3;
+     blr_eof_backward = 4;
+     blr_lock_relation = 114;
+     blr_lock_record = 115;
+     blr_set_bookmark = 116;
+     blr_get_bookmark = 117;
+     blr_rs_stream = 119;
+     blr_exec_proc = 120;
+     blr_begin_range = 121;
+     blr_end_range = 122;
+     blr_delete_range = 123;
+     blr_procedure = 124;
+     blr_pid = 125;
+     blr_exec_pid = 126;
+     blr_singular = 127;
+     blr_abort = 128;
+     blr_block = 129;
+     blr_error_handler = 130;
+     blr_cast = 131;
+     blr_release_lock = 132;
+     blr_release_locks = 133;
+     blr_start_savepoint = 134;
+     blr_end_savepoint = 135;
+     blr_find_dbkey = 136;
+     blr_range_relation = 137;
+     blr_delete_ranges = 138;
+     blr_plan = 139;
+     blr_merge = 140;
+     blr_join = 141;
+     blr_sequential = 142;
+     blr_navigational = 143;
+     blr_indices = 144;
+     blr_retrieve = 145;
+     blr_relation2 = 146;
+     blr_rid2 = 147;
+     blr_reset_stream = 148;
+     blr_release_bookmark = 149;
+     blr_set_generator = 150;
+     blr_ansi_any = 151;
+     blr_exists = 152;
+     blr_cardinality = 153;
+  { get tid of record  }
+     blr_record_version = 154;
+  { fake server stall  }
+     blr_stall = 155;
+     blr_seek_no_warn = 156;
+     blr_find_dbkey_version = 157;
+     blr_ansi_all = 158;
+     blr_extract = 159;
+  { sub parameters for blr_extract  }
+     blr_extract_year = 0;
+     blr_extract_month = 1;
+     blr_extract_day = 2;
+     blr_extract_hour = 3;
+     blr_extract_minute = 4;
+     blr_extract_second = 5;
+     blr_extract_weekday = 6;
+     blr_extract_yearday = 7;
+     blr_current_date = 160;
+     blr_current_timestamp = 161;
+     blr_current_time = 162;
+  { These verbs were added in 6.0, primarily to support 64-bit integers  }
+     blr_add2 = 163;
+     blr_subtract2 = 164;
+     blr_multiply2 = 165;
+     blr_divide2 = 166;
+     blr_agg_total2 = 167;
+     blr_agg_total_distinct2 = 168;
+     blr_agg_average2 = 169;
+     blr_agg_average_distinct2 = 170;
+     blr_average2 = 171;
+     blr_gen_id2 = 172;
+     blr_set_generator2 = 173;
+{$endif}
+  { _JRD_BLR_H_  }
+  {                                 }
+  { Database parameter block stuff  }
+  {                                 }
+
+  const
+     isc_dpb_version1 = 1;
+     isc_dpb_cdd_pathname = 1;
+     isc_dpb_allocation = 2;
+     isc_dpb_journal = 3;
+     isc_dpb_page_size = 4;
+     isc_dpb_num_buffers = 5;
+     isc_dpb_buffer_length = 6;
+     isc_dpb_debug = 7;
+     isc_dpb_garbage_collect = 8;
+     isc_dpb_verify = 9;
+     isc_dpb_sweep = 10;
+     isc_dpb_enable_journal = 11;
+     isc_dpb_disable_journal = 12;
+     isc_dpb_dbkey_scope = 13;
+     isc_dpb_number_of_users = 14;
+     isc_dpb_trace = 15;
+     isc_dpb_no_garbage_collect = 16;
+     isc_dpb_damaged = 17;
+     isc_dpb_license = 18;
+     isc_dpb_sys_user_name = 19;
+     isc_dpb_encrypt_key = 20;
+     isc_dpb_activate_shadow = 21;
+     isc_dpb_sweep_interval = 22;
+     isc_dpb_delete_shadow = 23;
+     isc_dpb_force_write = 24;
+     isc_dpb_begin_log = 25;
+     isc_dpb_quit_log = 26;
+     isc_dpb_no_reserve = 27;
+     isc_dpb_user_name = 28;
+     isc_dpb_password = 29;
+     isc_dpb_password_enc = 30;
+     isc_dpb_sys_user_name_enc = 31;
+     isc_dpb_interp = 32;
+     isc_dpb_online_dump = 33;
+     isc_dpb_old_file_size = 34;
+     isc_dpb_old_num_files = 35;
+     isc_dpb_old_file = 36;
+     isc_dpb_old_start_page = 37;
+     isc_dpb_old_start_seqno = 38;
+     isc_dpb_old_start_file = 39;
+     isc_dpb_drop_walfile = 40;
+     isc_dpb_old_dump_id = 41;
+     isc_dpb_wal_backup_dir = 42;
+     isc_dpb_wal_chkptlen = 43;
+     isc_dpb_wal_numbufs = 44;
+     isc_dpb_wal_bufsize = 45;
+     isc_dpb_wal_grp_cmt_wait = 46;
+     isc_dpb_lc_messages = 47;
+     isc_dpb_lc_ctype = 48;
+     isc_dpb_cache_manager = 49;
+     isc_dpb_shutdown = 50;
+     isc_dpb_online = 51;
+     isc_dpb_shutdown_delay = 52;
+     isc_dpb_reserved = 53;
+     isc_dpb_overwrite = 54;
+     isc_dpb_sec_attach = 55;
+     isc_dpb_disable_wal = 56;
+     isc_dpb_connect_timeout = 57;
+     isc_dpb_dummy_packet_interval = 58;
+     isc_dpb_gbak_attach = 59;
+     isc_dpb_sql_role_name = 60;
+     isc_dpb_set_page_buffers = 61;
+     isc_dpb_working_directory = 62;
+     isc_dpb_SQL_dialect = 63;
+     isc_dpb_set_db_readonly = 64;
+     isc_dpb_set_db_SQL_dialect = 65;
+     isc_dpb_gfix_attach = 66;
+     isc_dpb_gstat_attach = 67;
+  {                                }
+  { isc_dpb_verify specific flags  }
+  {                                }
+     isc_dpb_pages = 1;
+     isc_dpb_records = 2;
+     isc_dpb_indices = 4;
+     isc_dpb_transactions = 8;
+     isc_dpb_no_update = 16;
+     isc_dpb_repair = 32;
+     isc_dpb_ignore = 64;
+  {                                  }
+  { isc_dpb_shutdown specific flags  }
+  {                                  }
+     isc_dpb_shut_cache = 1;
+     isc_dpb_shut_attachment = 2;
+     isc_dpb_shut_transaction = 4;
+     isc_dpb_shut_force = 8;
+  {                                     }
+  { Bit assignments in RDB$SYSTEM_FLAG  }
+  {                                     }
+     RDB_system = 1;
+     RDB_id_assigned = 2;
+  {                                    }
+  { Transaction parameter block stuff  }
+  {                                    }
+     isc_tpb_version1 = 1;
+     isc_tpb_version3 = 3;
+     isc_tpb_consistency = 1;
+     isc_tpb_concurrency = 2;
+     isc_tpb_shared = 3;
+     isc_tpb_protected = 4;
+     isc_tpb_exclusive = 5;
+     isc_tpb_wait = 6;
+     isc_tpb_nowait = 7;
+     isc_tpb_read = 8;
+     isc_tpb_write = 9;
+     isc_tpb_lock_read = 10;
+     isc_tpb_lock_write = 11;
+     isc_tpb_verb_time = 12;
+     isc_tpb_commit_time = 13;
+     isc_tpb_ignore_limbo = 14;
+     isc_tpb_read_committed = 15;
+     isc_tpb_autocommit = 16;
+     isc_tpb_rec_version = 17;
+     isc_tpb_no_rec_version = 18;
+     isc_tpb_restart_requests = 19;
+     isc_tpb_no_auto_undo = 20;
+  {                       }
+  { Blob Parameter Block  }
+  {                       }
+     isc_bpb_version1 = 1;
+     isc_bpb_source_type = 1;
+     isc_bpb_target_type = 2;
+     isc_bpb_type = 3;
+     isc_bpb_source_interp = 4;
+     isc_bpb_target_interp = 5;
+     isc_bpb_filter_parameter = 6;
+     isc_bpb_type_segmented = 0;
+     isc_bpb_type_stream = 1;
+  {                                }
+  { Service parameter block stuff  }
+  {                                }
+     isc_spb_version1 = 1;
+     isc_spb_current_version = 2;
+     isc_spb_version = isc_spb_current_version;
+     isc_spb_user_name = isc_dpb_user_name;
+     isc_spb_sys_user_name = isc_dpb_sys_user_name;
+     isc_spb_sys_user_name_enc = isc_dpb_sys_user_name_enc;
+     isc_spb_password = isc_dpb_password;
+     isc_spb_password_enc = isc_dpb_password_enc;
+     isc_spb_command_line = 105;
+     isc_spb_dbname = 106;
+     isc_spb_verbose = 107;
+     isc_spb_options = 108;
+     isc_spb_connect_timeout = isc_dpb_connect_timeout;
+     isc_spb_dummy_packet_interval = isc_dpb_dummy_packet_interval;
+     isc_spb_sql_role_name = isc_dpb_sql_role_name;
+  {                                }
+  { Information call declarations  }
+  {                                }
+  {                           }
+  { Common, structural codes  }
+  {                           }
+     isc_info_end = 1;
+     isc_info_truncated = 2;
+     isc_info_error = 3;
+     isc_info_data_not_ready = 4;
+     isc_info_flag_end = 127;
+  {                             }
+  { Database information items  }
+  {                             }
+     isc_info_db_id = 4;
+     isc_info_reads = 5;
+     isc_info_writes = 6;
+     isc_info_fetches = 7;
+     isc_info_marks = 8;
+     isc_info_implementation = 11;
+     isc_info_version = 12;
+     isc_info_base_level = 13;
+     isc_info_page_size = 14;
+     isc_info_num_buffers = 15;
+     isc_info_limbo = 16;
+     isc_info_current_memory = 17;
+     isc_info_max_memory = 18;
+     isc_info_window_turns = 19;
+     isc_info_license = 20;
+     isc_info_allocation = 21;
+     isc_info_attachment_id = 22;
+     isc_info_read_seq_count = 23;
+     isc_info_read_idx_count = 24;
+     isc_info_insert_count = 25;
+     isc_info_update_count = 26;
+     isc_info_delete_count = 27;
+     isc_info_backout_count = 28;
+     isc_info_purge_count = 29;
+     isc_info_expunge_count = 30;
+     isc_info_sweep_interval = 31;
+     isc_info_ods_version = 32;
+     isc_info_ods_minor_version = 33;
+     isc_info_no_reserve = 34;
+     isc_info_logfile = 35;
+     isc_info_cur_logfile_name = 36;
+     isc_info_cur_log_part_offset = 37;
+     isc_info_num_wal_buffers = 38;
+     isc_info_wal_buffer_size = 39;
+     isc_info_wal_ckpt_length = 40;
+     isc_info_wal_cur_ckpt_interval = 41;
+     isc_info_wal_prv_ckpt_fname = 42;
+     isc_info_wal_prv_ckpt_poffset = 43;
+     isc_info_wal_recv_ckpt_fname = 44;
+     isc_info_wal_recv_ckpt_poffset = 45;
+     isc_info_wal_grpc_wait_usecs = 47;
+     isc_info_wal_num_io = 48;
+     isc_info_wal_avg_io_size = 49;
+     isc_info_wal_num_commits = 50;
+     isc_info_wal_avg_grpc_size = 51;
+     isc_info_forced_writes = 52;
+     isc_info_user_names = 53;
+     isc_info_page_errors = 54;
+     isc_info_record_errors = 55;
+     isc_info_bpage_errors = 56;
+     isc_info_dpage_errors = 57;
+     isc_info_ipage_errors = 58;
+     isc_info_ppage_errors = 59;
+     isc_info_tpage_errors = 60;
+     isc_info_set_page_buffers = 61;
+     isc_info_db_SQL_dialect = 62;
+     isc_info_db_read_only = 63;
+     isc_info_db_size_in_pages = 64;
+  {                                     }
+  { Database information return values  }
+  {                                     }
+     isc_info_db_impl_rdb_vms = 1;
+     isc_info_db_impl_rdb_eln = 2;
+     isc_info_db_impl_rdb_eln_dev = 3;
+     isc_info_db_impl_rdb_vms_y = 4;
+     isc_info_db_impl_rdb_eln_y = 5;
+     isc_info_db_impl_jri = 6;
+     isc_info_db_impl_jsv = 7;
+     isc_info_db_impl_isc_a = 25;
+     isc_info_db_impl_isc_u = 26;
+     isc_info_db_impl_isc_v = 27;
+     isc_info_db_impl_isc_s = 28;
+     isc_info_db_impl_isc_apl_68K = 25;
+     isc_info_db_impl_isc_vax_ultr = 26;
+     isc_info_db_impl_isc_vms = 27;
+     isc_info_db_impl_isc_sun_68k = 28;
+     isc_info_db_impl_isc_os2 = 29;
+     isc_info_db_impl_isc_sun4 = 30;
+     isc_info_db_impl_isc_hp_ux = 31;
+     isc_info_db_impl_isc_sun_386i = 32;
+     isc_info_db_impl_isc_vms_orcl = 33;
+     isc_info_db_impl_isc_mac_aux = 34;
+     isc_info_db_impl_isc_rt_aix = 35;
+     isc_info_db_impl_isc_mips_ult = 36;
+     isc_info_db_impl_isc_xenix = 37;
+     isc_info_db_impl_isc_dg = 38;
+     isc_info_db_impl_isc_hp_mpexl = 39;
+     isc_info_db_impl_isc_hp_ux68K = 40;
+     isc_info_db_impl_isc_sgi = 41;
+     isc_info_db_impl_isc_sco_unix = 42;
+     isc_info_db_impl_isc_cray = 43;
+     isc_info_db_impl_isc_imp = 44;
+     isc_info_db_impl_isc_delta = 45;
+     isc_info_db_impl_isc_next = 46;
+     isc_info_db_impl_isc_dos = 47;
+     isc_info_db_impl_isc_winnt = 48;
+     isc_info_db_impl_isc_epson = 49;
+     isc_info_db_class_access = 1;
+     isc_info_db_class_y_valve = 2;
+     isc_info_db_class_rem_int = 3;
+     isc_info_db_class_rem_srvr = 4;
+     isc_info_db_class_pipe_int = 7;
+     isc_info_db_class_pipe_srvr = 8;
+     isc_info_db_class_sam_int = 9;
+     isc_info_db_class_sam_srvr = 10;
+     isc_info_db_class_gateway = 11;
+     isc_info_db_class_cache = 12;
+  {                            }
+  { Request information items  }
+  {                            }
+     isc_info_number_messages = 4;
+     isc_info_max_message = 5;
+     isc_info_max_send = 6;
+     isc_info_max_receive = 7;
+     isc_info_state = 8;
+     isc_info_message_number = 9;
+     isc_info_message_size = 10;
+     isc_info_request_cost = 11;
+     isc_info_access_path = 12;
+     isc_info_req_select_count = 13;
+     isc_info_req_insert_count = 14;
+     isc_info_req_update_count = 15;
+     isc_info_req_delete_count = 16;
+  {                    }
+  { Access path items  }
+  {                    }
+     isc_info_rsb_end = 0;
+     isc_info_rsb_begin = 1;
+     isc_info_rsb_type = 2;
+     isc_info_rsb_relation = 3;
+     isc_info_rsb_plan = 4;
+  {            }
+  { Rsb types  }
+  {            }
+     isc_info_rsb_unknown = 1;
+     isc_info_rsb_indexed = 2;
+     isc_info_rsb_navigate = 3;
+     isc_info_rsb_sequential = 4;
+     isc_info_rsb_cross = 5;
+     isc_info_rsb_sort = 6;
+     isc_info_rsb_first = 7;
+     isc_info_rsb_boolean = 8;
+     isc_info_rsb_union = 9;
+     isc_info_rsb_aggregate = 10;
+     isc_info_rsb_merge = 11;
+     isc_info_rsb_ext_sequential = 12;
+     isc_info_rsb_ext_indexed = 13;
+     isc_info_rsb_ext_dbkey = 14;
+     isc_info_rsb_left_cross = 15;
+     isc_info_rsb_select = 16;
+     isc_info_rsb_sql_join = 17;
+     isc_info_rsb_simulate = 18;
+     isc_info_rsb_sim_cross = 19;
+     isc_info_rsb_once = 20;
+     isc_info_rsb_procedure = 21;
+  {                     }
+  { Bitmap expressions  }
+  {                     }
+     isc_info_rsb_and = 1;
+     isc_info_rsb_or = 2;
+     isc_info_rsb_dbkey = 3;
+     isc_info_rsb_index = 4;
+     isc_info_req_active = 2;
+     isc_info_req_inactive = 3;
+     isc_info_req_send = 4;
+     isc_info_req_receive = 5;
+     isc_info_req_select = 6;
+     isc_info_req_sql_stall = 7;
+  {                         }
+  { Blob information items  }
+  {                         }
+     isc_info_blob_num_segments = 4;
+     isc_info_blob_max_segment = 5;
+     isc_info_blob_total_length = 6;
+     isc_info_blob_type = 7;
+  {                                }
+  { Transaction information items  }
+  {                                }
+     isc_info_tra_id = 4;
+  {
+     Service action items
+                                }
+  { Starts database backup process on the server  }
+     isc_action_svc_backup = 1;
+  { Starts database restore process on the server  }
+     isc_action_svc_restore = 2;
+  { Starts database repair process on the server  }
+     isc_action_svc_repair = 3;
+  { Adds a new user to the security database  }
+     isc_action_svc_add_user = 4;
+  { Deletes a user record from the security database  }
+     isc_action_svc_delete_user = 5;
+  { Modifies a user record in the security database  }
+     isc_action_svc_modify_user = 6;
+  { Displays a user record from the security database  }
+     isc_action_svc_display_user = 7;
+  { Sets database properties  }
+     isc_action_svc_properties = 8;
+  { Adds a license to the license file  }
+     isc_action_svc_add_license = 9;
+  { Removes a license from the license file  }
+     isc_action_svc_remove_license = 10;
+  { Retrieves database statistics  }
+     isc_action_svc_db_stats = 11;
+  { Retrieves the InterBase log file from the server  }
+     isc_action_svc_get_ib_log = 12;
+  {
+     Service information items
+                                }
+  { Retrieves the number of attachments and databases  }
+     isc_info_svc_svr_db_info = 50;
+  { Retrieves all license keys and IDs from the license file  }
+     isc_info_svc_get_license = 51;
+  { Retrieves a bitmask representing licensed options on the server  }
+     isc_info_svc_get_license_mask = 52;
+  { Retrieves the parameters and values for IB_CONFIG  }
+     isc_info_svc_get_config = 53;
+  { Retrieves the version of the services manager  }
+     isc_info_svc_version = 54;
+  { Retrieves the version of the InterBase server  }
+     isc_info_svc_server_version = 55;
+  { Retrieves the implementation of the InterBase server  }
+     isc_info_svc_implementation = 56;
+  { Retrieves a bitmask representing the server's capabilities  }
+     isc_info_svc_capabilities = 57;
+  { Retrieves the path to the security database in use by the server  }
+     isc_info_svc_user_dbpath = 58;
+  { Retrieves the setting of $INTERBASE  }
+     isc_info_svc_get_env = 59;
+  { Retrieves the setting of $INTERBASE_LCK  }
+     isc_info_svc_get_env_lock = 60;
+  { Retrieves the setting of $INTERBASE_MSG  }
+     isc_info_svc_get_env_msg = 61;
+  { Retrieves 1 line of service output per call  }
+     isc_info_svc_line = 62;
+  { Retrieves as much of the server output as will fit in the supplied buffer  }
+     isc_info_svc_to_eof = 63;
+  { Sets / signifies a timeout value for reading service information  }
+     isc_info_svc_timeout = 64;
+  { Retrieves the number of users licensed for accessing the server  }
+     isc_info_svc_get_licensed_users = 65;
+  { Retrieve the limbo transactions  }
+     isc_info_svc_limbo_trans = 66;
+  { Checks to see if a service is running on an attachment  }
+     isc_info_svc_running = 67;
+  { Returns the user information from isc_action_svc_display_users  }
+     isc_info_svc_get_users = 68;
+  {
+     Parameters for isc_action_(add|delete|modify)_user
+   }
+     isc_spb_sec_userid = 5;
+     isc_spb_sec_groupid = 6;
+     isc_spb_sec_username = 7;
+     isc_spb_sec_password = 8;
+     isc_spb_sec_groupname = 9;
+     isc_spb_sec_firstname = 10;
+     isc_spb_sec_middlename = 11;
+     isc_spb_sec_lastname = 12;
+  {
+     Parameters for isc_action_svc_(add|remove)_license,
+     isc_info_svc_get_license
+                                                          }
+     isc_spb_lic_key = 5;
+     isc_spb_lic_id = 6;
+     isc_spb_lic_desc = 7;
+  {
+     Parameters for isc_action_svc_backup
+                                            }
+     isc_spb_bkp_file = 5;
+     isc_spb_bkp_factor = 6;
+     isc_spb_bkp_length = 7;
+     isc_spb_bkp_ignore_checksums = $01;
+     isc_spb_bkp_ignore_limbo = $02;
+     isc_spb_bkp_metadata_only = $04;
+     isc_spb_bkp_no_garbage_collect = $08;
+     isc_spb_bkp_old_descriptions = $10;
+     isc_spb_bkp_non_transportable = $20;
+     isc_spb_bkp_convert = $40;
+     isc_spb_bkp_expand = $80;
+  {
+     Parameters for isc_action_svc_properties
+                                               }
+     isc_spb_prp_page_buffers = 5;
+     isc_spb_prp_sweep_interval = 6;
+     isc_spb_prp_shutdown_db = 7;
+     isc_spb_prp_deny_new_attachments = 9;
+     isc_spb_prp_deny_new_transactions = 10;
+     isc_spb_prp_reserve_space = 11;
+     isc_spb_prp_write_mode = 12;
+     isc_spb_prp_access_mode = 13;
+     isc_spb_prp_set_sql_dialect = 14;
+     isc_spb_prp_activate = $0100;
+     isc_spb_prp_db_online = $0200;
+  {
+     Parameters for isc_spb_prp_reserve_space
+                                               }
+     isc_spb_prp_res_use_full = 35;
+     isc_spb_prp_res = 36;
+  {
+     Parameters for isc_spb_prp_write_mode
+                                             }
+     isc_spb_prp_wm_async = 37;
+     isc_spb_prp_wm_sync = 38;
+  {
+     Parameters for isc_spb_prp_access_mode
+                                             }
+     isc_spb_prp_am_readonly = 39;
+     isc_spb_prp_am_readwrite = 40;
+  {
+     Parameters for isc_action_svc_repair
+                                            }
+     isc_spb_rpr_commit_trans = 15;
+     isc_spb_rpr_rollback_trans = 34;
+     isc_spb_rpr_recover_two_phase = 17;
+     isc_spb_tra_id = 18;
+     isc_spb_single_tra_id = 19;
+     isc_spb_multi_tra_id = 20;
+     isc_spb_tra_state = 21;
+     isc_spb_tra_state_limbo = 22;
+     isc_spb_tra_state_commit = 23;
+     isc_spb_tra_state_rollback = 24;
+     isc_spb_tra_state_unknown = 25;
+     isc_spb_tra_host_site = 26;
+     isc_spb_tra_remote_site = 27;
+     isc_spb_tra_db_path = 28;
+     isc_spb_tra_advise = 29;
+     isc_spb_tra_advise_commit = 30;
+     isc_spb_tra_advise_rollback = 31;
+     isc_spb_tra_advise_unknown = 33;
+     isc_spb_rpr_validate_db = $01;
+     isc_spb_rpr_sweep_db = $02;
+     isc_spb_rpr_mend_db = $04;
+     isc_spb_rpr_list_limbo_trans = $08;
+     isc_spb_rpr_check_db = $10;
+     isc_spb_rpr_ignore_checksum = $20;
+     isc_spb_rpr_kill_shadows = $40;
+     isc_spb_rpr_full = $80;
+  {
+     Parameters for isc_action_svc_restore
+                                            }
+     isc_spb_res_buffers = 9;
+     isc_spb_res_page_size = 10;
+     isc_spb_res_length = 11;
+     isc_spb_res_access_mode = 12;
+     isc_spb_res_deactivate_idx = $0100;
+     isc_spb_res_no_shadow = $0200;
+     isc_spb_res_no_validity = $0400;
+     isc_spb_res_one_at_a_time = $0800;
+     isc_spb_res_replace = $1000;
+     isc_spb_res_create = $2000;
+     isc_spb_res_use_all_space = $4000;
+  {
+     Parameters for isc_spb_res_access_mode
+                                             }
+     isc_spb_res_am_readonly = isc_spb_prp_am_readonly;
+     isc_spb_res_am_readwrite = isc_spb_prp_am_readwrite;
+  {
+     Parameters for isc_info_svc_svr_db_info
+                                              }
+     isc_spb_num_att = 5;
+     isc_spb_num_db = 6;
+  {
+     Parameters for isc_info_svc_db_stats
+                                            }
+     isc_spb_sts_data_pages = $01;
+     isc_spb_sts_db_log = $02;
+     isc_spb_sts_hdr_pages = $04;
+     isc_spb_sts_idx_pages = $08;
+     isc_spb_sts_sys_relations = $10;
+  {                        }
+  { SQL information items  }
+  {                        }
+     isc_info_sql_select = 4;
+     isc_info_sql_bind = 5;
+     isc_info_sql_num_variables = 6;
+     isc_info_sql_describe_vars = 7;
+     isc_info_sql_describe_end = 8;
+     isc_info_sql_sqlda_seq = 9;
+     isc_info_sql_message_seq = 10;
+     isc_info_sql_type = 11;
+     isc_info_sql_sub_type = 12;
+     isc_info_sql_scale = 13;
+     isc_info_sql_length = 14;
+     isc_info_sql_null_ind = 15;
+     isc_info_sql_field = 16;
+     isc_info_sql_relation = 17;
+     isc_info_sql_owner = 18;
+     isc_info_sql_alias = 19;
+     isc_info_sql_sqlda_start = 20;
+     isc_info_sql_stmt_type = 21;
+     isc_info_sql_get_plan = 22;
+     isc_info_sql_records = 23;
+     isc_info_sql_batch_fetch = 24;
+  {                                }
+  { SQL information return values  }
+  {                                }
+     isc_info_sql_stmt_select = 1;
+     isc_info_sql_stmt_insert = 2;
+     isc_info_sql_stmt_update = 3;
+     isc_info_sql_stmt_delete = 4;
+     isc_info_sql_stmt_ddl = 5;
+     isc_info_sql_stmt_get_segment = 6;
+     isc_info_sql_stmt_put_segment = 7;
+     isc_info_sql_stmt_exec_procedure = 8;
+     isc_info_sql_stmt_start_trans = 9;
+     isc_info_sql_stmt_commit = 10;
+     isc_info_sql_stmt_rollback = 11;
+     isc_info_sql_stmt_select_for_upd = 12;
+     isc_info_sql_stmt_set_generator = 13;
+  {                                  }
+  { Server configuration key values  }
+  {                                  }
+     ISCCFG_LOCKMEM_KEY = 0;
+     ISCCFG_LOCKSEM_KEY = 1;
+     ISCCFG_LOCKSIG_KEY = 2;
+     ISCCFG_EVNTMEM_KEY = 3;
+     ISCCFG_DBCACHE_KEY = 4;
+     ISCCFG_PRIORITY_KEY = 5;
+     ISCCFG_IPCMAP_KEY = 6;
+     ISCCFG_MEMMIN_KEY = 7;
+     ISCCFG_MEMMAX_KEY = 8;
+     ISCCFG_LOCKORDER_KEY = 9;
+     ISCCFG_ANYLOCKMEM_KEY = 10;
+     ISCCFG_ANYLOCKSEM_KEY = 11;
+     ISCCFG_ANYLOCKSIG_KEY = 12;
+     ISCCFG_ANYEVNTMEM_KEY = 13;
+     ISCCFG_LOCKHASH_KEY = 14;
+     ISCCFG_DEADLOCK_KEY = 15;
+     ISCCFG_LOCKSPIN_KEY = 16;
+     ISCCFG_CONN_TIMEOUT_KEY = 17;
+     ISCCFG_DUMMY_INTRVL_KEY = 18;
+  { Internal Use only  }
+     ISCCFG_TRACE_POOLS_KEY = 19;
+     ISCCFG_REMOTE_BUFFER_KEY = 20;
+  {              }
+  { Error codes  }
+  {              }
+     isc_facility = 20;
+     isc_err_base = 335544320;
+     isc_err_factor = 1;
+     isc_arg_end = 0;
+     isc_arg_gds = 1;
+     isc_arg_string = 2;
+     isc_arg_cstring = 3;
+     isc_arg_number = 4;
+     isc_arg_interpreted = 5;
+     isc_arg_vms = 6;
+     isc_arg_unix = 7;
+     isc_arg_domain = 8;
+     isc_arg_dos = 9;
+     isc_arg_mpexl = 10;
+     isc_arg_mpexl_ipc = 11;
+     isc_arg_next_mach = 15;
+     isc_arg_netware = 16;
+     isc_arg_win32 = 17;
+     isc_arg_warning = 18;
+
+  {                                             }
+  { Dynamic Data Definition Language operators  }
+  {                                             }
+  {                 }
+  { Version number  }
+  {                 }
+
+  const
+     isc_dyn_version_1 = 1;
+     isc_dyn_eoc = 255;
+  {                             }
+  { Operations (may be nested)  }
+  {                             }
+     isc_dyn_begin = 2;
+     isc_dyn_end = 3;
+     isc_dyn_if = 4;
+     isc_dyn_def_database = 5;
+     isc_dyn_def_global_fld = 6;
+     isc_dyn_def_local_fld = 7;
+     isc_dyn_def_idx = 8;
+     isc_dyn_def_rel = 9;
+     isc_dyn_def_sql_fld = 10;
+     isc_dyn_def_view = 12;
+     isc_dyn_def_trigger = 15;
+     isc_dyn_def_security_class = 120;
+     isc_dyn_def_dimension = 140;
+     isc_dyn_def_generator = 24;
+     isc_dyn_def_function = 25;
+     isc_dyn_def_filter = 26;
+     isc_dyn_def_function_arg = 27;
+     isc_dyn_def_shadow = 34;
+     isc_dyn_def_trigger_msg = 17;
+     isc_dyn_def_file = 36;
+     isc_dyn_mod_database = 39;
+     isc_dyn_mod_rel = 11;
+     isc_dyn_mod_global_fld = 13;
+     isc_dyn_mod_idx = 102;
+     isc_dyn_mod_local_fld = 14;
+     isc_dyn_mod_sql_fld = 216;
+     isc_dyn_mod_view = 16;
+     isc_dyn_mod_security_class = 122;
+     isc_dyn_mod_trigger = 113;
+     isc_dyn_mod_trigger_msg = 28;
+     isc_dyn_delete_database = 18;
+     isc_dyn_delete_rel = 19;
+     isc_dyn_delete_global_fld = 20;
+     isc_dyn_delete_local_fld = 21;
+     isc_dyn_delete_idx = 22;
+     isc_dyn_delete_security_class = 123;
+     isc_dyn_delete_dimensions = 143;
+     isc_dyn_delete_trigger = 23;
+     isc_dyn_delete_trigger_msg = 29;
+     isc_dyn_delete_filter = 32;
+     isc_dyn_delete_function = 33;
+     isc_dyn_delete_shadow = 35;
+     isc_dyn_grant = 30;
+     isc_dyn_revoke = 31;
+     isc_dyn_def_primary_key = 37;
+     isc_dyn_def_foreign_key = 38;
+     isc_dyn_def_unique = 40;
+     isc_dyn_def_procedure = 164;
+     isc_dyn_delete_procedure = 165;
+     isc_dyn_def_parameter = 135;
+     isc_dyn_delete_parameter = 136;
+     isc_dyn_mod_procedure = 175;
+     isc_dyn_def_log_file = 176;
+     isc_dyn_def_cache_file = 180;
+     isc_dyn_def_exception = 181;
+     isc_dyn_mod_exception = 182;
+     isc_dyn_del_exception = 183;
+     isc_dyn_drop_log = 194;
+     isc_dyn_drop_cache = 195;
+     isc_dyn_def_default_log = 202;
+  {                      }
+  { View specific stuff  }
+  {                      }
+     isc_dyn_view_blr = 43;
+     isc_dyn_view_source = 44;
+     isc_dyn_view_relation = 45;
+     isc_dyn_view_context = 46;
+     isc_dyn_view_context_name = 47;
+  {                     }
+  { Generic attributes  }
+  {                     }
+     isc_dyn_rel_name = 50;
+     isc_dyn_fld_name = 51;
+     isc_dyn_new_fld_name = 215;
+     isc_dyn_idx_name = 52;
+     isc_dyn_description = 53;
+     isc_dyn_security_class = 54;
+     isc_dyn_system_flag = 55;
+     isc_dyn_update_flag = 56;
+     isc_dyn_prc_name = 166;
+     isc_dyn_prm_name = 137;
+     isc_dyn_sql_object = 196;
+     isc_dyn_fld_character_set_name = 174;
+  {                               }
+  { Relation specific attributes  }
+  {                               }
+     isc_dyn_rel_dbkey_length = 61;
+     isc_dyn_rel_store_trig = 62;
+     isc_dyn_rel_modify_trig = 63;
+     isc_dyn_rel_erase_trig = 64;
+     isc_dyn_rel_store_trig_source = 65;
+     isc_dyn_rel_modify_trig_source = 66;
+     isc_dyn_rel_erase_trig_source = 67;
+     isc_dyn_rel_ext_file = 68;
+     isc_dyn_rel_sql_protection = 69;
+     isc_dyn_rel_constraint = 162;
+     isc_dyn_delete_rel_constraint = 163;
+  {                                   }
+  { Global field specific attributes  }
+  {                                   }
+     isc_dyn_fld_type = 70;
+     isc_dyn_fld_length = 71;
+     isc_dyn_fld_scale = 72;
+     isc_dyn_fld_sub_type = 73;
+     isc_dyn_fld_segment_length = 74;
+     isc_dyn_fld_query_header = 75;
+     isc_dyn_fld_edit_string = 76;
+     isc_dyn_fld_validation_blr = 77;
+     isc_dyn_fld_validation_source = 78;
+     isc_dyn_fld_computed_blr = 79;
+     isc_dyn_fld_computed_source = 80;
+     isc_dyn_fld_missing_value = 81;
+     isc_dyn_fld_default_value = 82;
+     isc_dyn_fld_query_name = 83;
+     isc_dyn_fld_dimensions = 84;
+     isc_dyn_fld_not_null = 85;
+     isc_dyn_fld_precision = 86;
+     isc_dyn_fld_char_length = 172;
+     isc_dyn_fld_collation = 173;
+     isc_dyn_fld_default_source = 193;
+     isc_dyn_del_default = 197;
+     isc_dyn_del_validation = 198;
+     isc_dyn_single_validation = 199;
+     isc_dyn_fld_character_set = 203;
+  {                                  }
+  { Local field specific attributes  }
+  {                                  }
+     isc_dyn_fld_source = 90;
+     isc_dyn_fld_base_fld = 91;
+     isc_dyn_fld_position = 92;
+     isc_dyn_fld_update_flag = 93;
+  {                            }
+  { Index specific attributes  }
+  {                            }
+     isc_dyn_idx_unique = 100;
+     isc_dyn_idx_inactive = 101;
+     isc_dyn_idx_type = 103;
+     isc_dyn_idx_foreign_key = 104;
+     isc_dyn_idx_ref_column = 105;
+     isc_dyn_idx_statistic = 204;
+  {                              }
+  { Trigger specific attributes  }
+  {                              }
+     isc_dyn_trg_type = 110;
+     isc_dyn_trg_blr = 111;
+     isc_dyn_trg_source = 112;
+     isc_dyn_trg_name = 114;
+     isc_dyn_trg_sequence = 115;
+     isc_dyn_trg_inactive = 116;
+     isc_dyn_trg_msg_number = 117;
+     isc_dyn_trg_msg = 118;
+  {                                     }
+  { Security Class specific attributes  }
+  {                                     }
+     isc_dyn_scl_acl = 121;
+     isc_dyn_grant_user = 130;
+     isc_dyn_grant_proc = 186;
+     isc_dyn_grant_trig = 187;
+     isc_dyn_grant_view = 188;
+     isc_dyn_grant_options = 132;
+     isc_dyn_grant_user_group = 205;
+  {                                 }
+  { Dimension specific information  }
+  {                                 }
+     isc_dyn_dim_lower = 141;
+     isc_dyn_dim_upper = 142;
+  {                           }
+  { File specific attributes  }
+  {                           }
+     isc_dyn_file_name = 125;
+     isc_dyn_file_start = 126;
+     isc_dyn_file_length = 127;
+     isc_dyn_shadow_number = 128;
+     isc_dyn_shadow_man_auto = 129;
+     isc_dyn_shadow_conditional = 130;
+  {                               }
+  { Log file specific attributes  }
+  {                               }
+     isc_dyn_log_file_sequence = 177;
+     isc_dyn_log_file_partitions = 178;
+     isc_dyn_log_file_serial = 179;
+     isc_dyn_log_file_overflow = 200;
+     isc_dyn_log_file_raw = 201;
+  {                          }
+  { Log specific attributes  }
+  {                          }
+     isc_dyn_log_group_commit_wait = 189;
+     isc_dyn_log_buffer_size = 190;
+     isc_dyn_log_check_point_length = 191;
+     isc_dyn_log_num_of_buffers = 192;
+  {                               }
+  { Function specific attributes  }
+  {                               }
+     isc_dyn_function_name = 145;
+     isc_dyn_function_type = 146;
+     isc_dyn_func_module_name = 147;
+     isc_dyn_func_entry_point = 148;
+     isc_dyn_func_return_argument = 149;
+     isc_dyn_func_arg_position = 150;
+     isc_dyn_func_mechanism = 151;
+     isc_dyn_filter_in_subtype = 152;
+     isc_dyn_filter_out_subtype = 153;
+     isc_dyn_description2 = 154;
+     isc_dyn_fld_computed_source2 = 155;
+     isc_dyn_fld_edit_string2 = 156;
+     isc_dyn_fld_query_header2 = 157;
+     isc_dyn_fld_validation_source2 = 158;
+     isc_dyn_trg_msg2 = 159;
+     isc_dyn_trg_source2 = 160;
+     isc_dyn_view_source2 = 161;
+     isc_dyn_xcp_msg2 = 184;
+  {                                }
+  { Generator specific attributes  }
+  {                                }
+     isc_dyn_generator_name = 95;
+     isc_dyn_generator_id = 96;
+  {                                }
+  { Procedure specific attributes  }
+  {                                }
+     isc_dyn_prc_inputs = 167;
+     isc_dyn_prc_outputs = 168;
+     isc_dyn_prc_source = 169;
+     isc_dyn_prc_blr = 170;
+     isc_dyn_prc_source2 = 171;
+  {                                }
+  { Parameter specific attributes  }
+  {                                }
+     isc_dyn_prm_number = 138;
+     isc_dyn_prm_type = 139;
+  {                               }
+  { Relation specific attributes  }
+  {                               }
+     isc_dyn_xcp_msg = 185;
+  {                                             }
+  { Cascading referential integrity values      }
+  {                                             }
+     isc_dyn_foreign_key_update = 205;
+     isc_dyn_foreign_key_delete = 206;
+     isc_dyn_foreign_key_cascade = 207;
+     isc_dyn_foreign_key_default = 208;
+     isc_dyn_foreign_key_null = 209;
+     isc_dyn_foreign_key_none = 210;
+  {                      }
+  { SQL role values      }
+  {                      }
+     isc_dyn_def_sql_role = 211;
+     isc_dyn_sql_role_name = 212;
+     isc_dyn_grant_admin_options = 213;
+     isc_dyn_del_sql_role = 214;
+  {                           }
+  { Last $dyn value assigned  }
+  {                           }
+     isc_dyn_last_dyn_value = 216;
+  {                                         }
+  { Array slice description language (SDL)  }
+  {                                         }
+     isc_sdl_version1 = 1;
+     isc_sdl_eoc = 255;
+     isc_sdl_relation = 2;
+     isc_sdl_rid = 3;
+     isc_sdl_field = 4;
+     isc_sdl_fid = 5;
+     isc_sdl_struct = 6;
+     isc_sdl_variable = 7;
+     isc_sdl_scalar = 8;
+     isc_sdl_tiny_integer = 9;
+     isc_sdl_short_integer = 10;
+     isc_sdl_long_integer = 11;
+     isc_sdl_literal = 12;
+     isc_sdl_add = 13;
+     isc_sdl_subtract = 14;
+     isc_sdl_multiply = 15;
+     isc_sdl_divide = 16;
+     isc_sdl_negate = 17;
+     isc_sdl_eql = 18;
+     isc_sdl_neq = 19;
+     isc_sdl_gtr = 20;
+     isc_sdl_geq = 21;
+     isc_sdl_lss = 22;
+     isc_sdl_leq = 23;
+     isc_sdl_and = 24;
+     isc_sdl_or = 25;
+     isc_sdl_not = 26;
+     isc_sdl_while = 27;
+     isc_sdl_assignment = 28;
+     isc_sdl_label = 29;
+     isc_sdl_leave = 30;
+     isc_sdl_begin = 31;
+     isc_sdl_end = 32;
+     isc_sdl_do3 = 33;
+     isc_sdl_do2 = 34;
+     isc_sdl_do1 = 35;
+     isc_sdl_element = 36;
+  {                                           }
+  { International text interpretation values  }
+  {                                           }
+     isc_interp_eng_ascii = 0;
+     isc_interp_jpn_sjis = 5;
+     isc_interp_jpn_euc = 6;
+  {                  }
+  { SQL definitions  }
+  {                  }
+     SQL_TEXT = 452;
+     SQL_VARYING = 448;
+     SQL_SHORT = 500;
+     SQL_LONG = 496;
+     SQL_FLOAT = 482;
+     SQL_DOUBLE = 480;
+     SQL_D_FLOAT = 530;
+     SQL_TIMESTAMP = 510;
+     SQL_BLOB = 520;
+     SQL_ARRAY = 540;
+     SQL_QUAD = 550;
+     SQL_TYPE_TIME = 560;
+     SQL_TYPE_DATE = 570;
+     SQL_INT64 = 580;
+  { Historical alias for pre V6 applications  }
+     SQL_DATE = SQL_TIMESTAMP;
+  {                }
+  { Blob Subtypes  }
+  {                }
+  { types less than zero are reserved for customer use  }
+     isc_blob_untyped = 0;
+  { internal subtypes  }
+     isc_blob_text = 1;
+     isc_blob_blr = 2;
+     isc_blob_acl = 3;
+     isc_blob_ranges = 4;
+     isc_blob_summary = 5;
+     isc_blob_format = 6;
+     isc_blob_tra = 7;
+     isc_blob_extfile = 8;
+  { the range 20-30 is reserved for dBASE and Paradox types  }
+     isc_blob_formatted_memo = 20;
+     isc_blob_paradox_ole = 21;
+     isc_blob_graphic = 22;
+     isc_blob_dbase_ole = 23;
+     isc_blob_typed_binary = 24;
+
+  implementation
+
+
+function XSQLDA_LENGTH(n: Integer): Integer;
+begin
+  Result := SizeOf(XSQLDA) + (n - 1) * SizeOf(XSQLVAR);
+end;
+
+
+end.
+{
+  $Log$
+  Revision 1.1  2002-01-29 17:54:51  peter
+    * splitted to base and extra
+
+  Revision 1.3  2001/04/10 23:30:03  peter
+    * regenerated
+
+}

+ 37 - 0
packages/base/ibase/mkdb

@@ -0,0 +1,37 @@
+#!/bin/sh
+#
+# Script to create a table 'FPdev' and to fill it with data.
+# The script accepts an optional argument : 
+# A database to connect to. (default 'testdb')
+#
+# Collect  the database
+DATABASE=${1-./testdb.gdb}
+# Choose one of the following:
+# ISQL=isql
+ISQL=/opt/interbase/i586_V4.0G/bin/isql
+#
+# Don't edit after this.
+#
+echo -n "Creating and filling table FPdev in database $DATABASE..."
+${ISQL} << EOF >/dev/null 2>&1
+CREATE DATABASE "$DATABASE";
+create table FPdev ( 
+id INT NOT NULL,
+UserName CHAR(255),
+InstEmail CHAR(255),
+PRIMARY KEY (id));
+insert into FPdev values ('1','Michael Van Canneyt','[email protected]');
+insert into FPdev values ('2','Florian Klaempfl','[email protected]');
+insert into FPdev values ('3','Carl-Eric Codere','[email protected]');
+insert into FPdev values ('4','Daniel Mantione','[email protected]');
+insert into FPdev values ('5','Pierre Muller','[email protected]');
+insert into FPdev values ('6','Jonas Maebe','[email protected]');
+insert into FPdev values ('7','Peter Vreman','[email protected]');
+insert into FPdev values ('8','Gerry Dubois','[email protected]');
+EOF
+if [ ! $? = 0 ]; then
+  echo "Failed."
+else
+  echo "Done."
+fi
+# Ready

+ 26 - 0
packages/base/ibase/mkdb.bat

@@ -0,0 +1,26 @@
+@echo off
+rem
+rem Set database
+rem 
+set DATABASE=testdb.gdb
+if not "$1"=="" goto NODB
+set DATABASE=%1
+:NODB
+rem
+rem  Choose one of the following:
+rem 
+set ISQL=isql
+rem set ISQL=/opt/interbase/i586_V4.0G/bin/isql
+#
+# Don't edit after this.
+#
+echo Creating and filling table FPdev in database %DATABASE%...
+echo CREATE DATABASE "%DATABASE%"; >mkdb.sql
+type mkdb.sqd >>mkdb.sql
+%ISQL% <mkdb.sql >nul
+if not errorlevel goto ok
+echo Failed.
+goto end
+:ok
+  echo "Done."
+:end

+ 13 - 0
packages/base/ibase/mkdb.sqd

@@ -0,0 +1,13 @@
+create table FPdev ( 
+id INT NOT NULL,
+UserName CHAR(255),
+InstEmail CHAR(255),
+PRIMARY KEY (id));
+insert into FPdev values ('1','Michael Van Canneyt','[email protected]');
+insert into FPdev values ('2','Florian Klaempfl','[email protected]');
+insert into FPdev values ('3','Carl-Eric Codere','[email protected]');
+insert into FPdev values ('4','Daniel Mantione','[email protected]');
+insert into FPdev values ('5','Pierre Muller','[email protected]');
+insert into FPdev values ('6','Jonas Maebe','[email protected]');
+insert into FPdev values ('7','Peter Vreman','[email protected]');
+insert into FPdev values ('8','Gerry Dubois','[email protected]');

+ 159 - 0
packages/base/ibase/testib40.pp

@@ -0,0 +1,159 @@
+{
+  $Id$
+}
+program testib;
+
+uses Ibase40, strings;
+
+{$h-}
+
+Const
+     { Change to YOUR database server }
+
+     ServerDb : pchar =  'testdb.gdb';
+
+     { CHange to YOUR username and password. These may be empty }
+
+      username = '';
+      PWD = '';
+
+     { Don't edit after this }
+
+      dbinfo : array [1..3] of byte
+             = (isc_info_page_size,isc_info_num_buffers,isc_info_end);
+      query : pchar = 'select * from FPDev;';
+      flag : array[0..2] of shortint = (0,0,0);
+
+Type
+  TStatusArray = Array[0..19] of ISC_Status;
+
+Var
+  DB : Tisc_db_handle;
+  TA : TISC_tr_handle;
+  statement : TISC_stmt_handle;
+  DPB : String;
+  Status : TStatusArray;
+  sqlda : PXSQLDA;
+  name,email : String;
+  i,id : longint;
+  fs : longint;
+
+Function CheckIBstatus (Const Status : TStatusArray) : Boolean;
+
+begin
+  CheckIBstatus:=Not ((Status[0]=1) and (status[1]<>0))
+end;
+
+Procedure DoError (Const status : TStatusArray);
+
+begin
+  Writeln ('Failed:');
+  isc_print_status(@status);
+  halt(1);
+end;
+
+begin
+  db:=Nil;
+  dpb:=chr(isc_dpb_version1);
+  If UserName<>'' then
+    begin
+    dpb:=dpb+chr(isc_dpb_user_name)+chr(length(UserName))+username;
+    If pwd<>'' then
+      dpb:=dpb+chr(isc_dpb_password)+chr(length(pwd))+pwd;
+    end;
+  Write ('Connecting to ',serverdb,': ');
+  isc_attach_database(@Status[0],strlen(serverdb),serverdb,@db,length(dpb),@dpb[1]);
+  if Not CheckIBStatus(Status) then
+    DoError(status)
+  else
+    Writeln ('OK.');
+  Write ('Starting Transaction : ');
+  If ISC_start_transaction (@status[0],@ta,1,@db,0,Nil)<>0 then
+    DoError(Status)
+  else
+    Writeln ('OK.');
+  getmem (sqlda,XSQLDA_Length(3));
+  sqlda^.sqln:=3;
+  sqlda^.sqld:=3;
+  sqlda^.version:=1;
+  Write('Allocating statement : ');
+  If isc_dsql_allocate_statement(@status ,@db,@statement)<>0 then
+    DoError(Status)
+  else
+    Writeln ('OK.');
+  Write ('Preparing statement : ');
+  if ISC_dsql_prepare(@status,@ta,@statement,0,query,1,sqlda)<>0 then
+    DoError(Status)
+  else
+    Writeln ('OK.');
+  I:=0;
+  With sqlda^.sqlvar[i] do
+    begin
+    sqldata := @id;
+    sqltype := sql_long;
+    sqlind  := @flag[0];
+    end;
+  inc(i);
+  With sqlda^.sqlvar[i] do
+    begin
+    sqldata := @name[1];
+    sqltype := sql_text;
+    sqlind  := @flag[1];
+    end;
+  inc(i);
+  With sqlda^.sqlvar[i] do
+    begin
+    sqldata := @email[1];
+    sqltype := sql_text;
+    sqlind  := @flag[2];
+    end;
+  Write ('Executing statement : ');
+  if isc_dsql_execute(@status,@ta,@statement,1,Nil)<>0 then
+    DoError(Status)
+  else
+    Writeln ('OK.');
+
+  Writeln ('Fetching rows :');
+  Repeat
+    FS:=isc_dsql_fetch(@status,@statement,1,sqlda);
+    If FS=0 then
+      begin
+      I:=255;
+      While Name[I]=' ' do Dec(i);
+      setlength(Name,i);
+      I:=255;
+      While Email[I]=' ' do Dec(i);
+      setlength(email,i);
+      Writeln ('(',ID,',',name,',',email,')');
+      end;
+  until FS<>0;
+  If FS<>100 then
+    DoError(status)
+  else
+    Writeln ('At end.');
+  Write ('Freeing statement : ');
+  if isc_dsql_free_statement(@status,@statement,DSQL_Close)<>0 then
+    DoError(Status)
+  else
+    Writeln ('OK.');
+  Write ('Committing transaction : ');
+  If ISC_Commit_transaction(@status,@ta)<>0 then
+    doerror(status)
+  else
+    Writeln ('OK.');
+  Write ('Disconnecting from database: ');
+  isc_detach_database(@status,@db);
+  If CheckIBStatus (Status) Then
+    Writeln ('OK.')
+  else
+    doerror(status);
+end.
+{
+  $Log$
+  Revision 1.1  2002-01-29 17:54:52  peter
+    * splitted to base and extra
+
+  Revision 1.3  2001/04/10 23:30:04  peter
+    * regenerated
+
+}

+ 163 - 0
packages/base/ibase/testib60.pp

@@ -0,0 +1,163 @@
+{
+  $Id$
+}
+program testib;
+
+{$IFDEF Unix}
+{$LINKLIB dl}
+{$ENDIF}
+
+uses Ibase60, strings;
+
+{$h-}
+
+Const
+     { Change to YOUR database server }
+
+     ServerDb : pchar =  'testdb.gdb';
+
+     { CHange to YOUR username and password. These may be empty }
+
+      username = '';
+      PWD = '';
+
+     { Don't edit after this }
+
+      dbinfo : array [1..3] of byte
+             = (isc_info_page_size,isc_info_num_buffers,isc_info_end);
+      query : pchar = 'select * from FPDev;';
+      flag : array[0..2] of shortint = (0,0,0);
+
+Type
+  TStatusArray = Array[0..19] of ISC_Status;
+
+Var
+  DB : Tisc_db_handle;
+  TA : TISC_tr_handle;
+  statement : TISC_stmt_handle;
+  DPB : String;
+  Status : TStatusArray;
+  sqlda : PXSQLDA;
+  name,email : String;
+  i,id : longint;
+  fs : longint;
+
+Function CheckIBstatus (Const Status : TStatusArray) : Boolean;
+
+begin
+  CheckIBstatus:=Not ((Status[0]=1) and (status[1]<>0))
+end;
+
+Procedure DoError (Const status : TStatusArray);
+
+begin
+  Writeln ('Failed:');
+  isc_print_status(@status);
+  halt(1);
+end;
+
+begin
+  db:=Nil;
+  dpb:=chr(isc_dpb_version1);
+  If UserName<>'' then
+    begin
+    dpb:=dpb+chr(isc_dpb_user_name)+chr(length(UserName))+username;
+    If pwd<>'' then
+      dpb:=dpb+chr(isc_dpb_password)+chr(length(pwd))+pwd;
+    end;
+  Write ('Connecting to ',serverdb,': ');
+  isc_attach_database(@Status[0],strlen(serverdb),serverdb,@db,length(dpb),@dpb[1]);
+  if Not CheckIBStatus(Status) then
+    DoError(status)
+  else
+    Writeln ('OK.');
+  Write ('Starting Transaction : ');
+  If ISC_start_transaction (@status[0],@ta,1,[@db,0,Nil])<>0 then
+    DoError(Status)
+  else
+    Writeln ('OK.');
+  getmem (sqlda,XSQLDA_Length(3));
+  sqlda^.sqln:=3;
+  sqlda^.sqld:=3;
+  sqlda^.version:=1;
+  Write('Allocating statement : ');
+  If isc_dsql_allocate_statement(@status ,@db,@statement)<>0 then
+    DoError(Status)
+  else
+    Writeln ('OK.');
+  Write ('Preparing statement : ');
+  if ISC_dsql_prepare(@status,@ta,@statement,0,query,1,sqlda)<>0 then
+    DoError(Status)
+  else
+    Writeln ('OK.');
+  I:=0;
+  With sqlda^.sqlvar[i] do
+    begin
+    sqldata := @id;
+    sqltype := sql_long;
+    sqlind  := @flag[0];
+    end;
+  inc(i);
+  With sqlda^.sqlvar[i] do
+    begin
+    sqldata := @name[1];
+    sqltype := sql_text;
+    sqlind  := @flag[1];
+    end;
+  inc(i);
+  With sqlda^.sqlvar[i] do
+    begin
+    sqldata := @email[1];
+    sqltype := sql_text;
+    sqlind  := @flag[2];
+    end;
+  Write ('Executing statement : ');
+  if isc_dsql_execute(@status,@ta,@statement,1,Nil)<>0 then
+    DoError(Status)
+  else
+    Writeln ('OK.');
+
+  Writeln ('Fetching rows :');
+  Repeat
+    FS:=isc_dsql_fetch(@status,@statement,1,sqlda);
+    If FS=0 then
+      begin
+      I:=255;
+      While Name[I]=' ' do Dec(i);
+      setlength(Name,i);
+      I:=255;
+      While Email[I]=' ' do Dec(i);
+      setlength(email,i);
+      Writeln ('(',ID,',',name,',',email,')');
+      end;
+  until FS<>0;
+  If FS<>100 then
+    DoError(status)
+  else
+    Writeln ('At end.');
+  Write ('Freeing statement : ');
+  if isc_dsql_free_statement(@status,@statement,DSQL_Close)<>0 then
+    DoError(Status)
+  else
+    Writeln ('OK.');
+  Write ('Committing transaction : ');
+  If ISC_Commit_transaction(@status,@ta)<>0 then
+    doerror(status)
+  else
+    Writeln ('OK.');
+  Write ('Disconnecting from database: ');
+  isc_detach_database(@status,@db);
+  If CheckIBStatus (Status) Then
+    Writeln ('OK.')
+  else
+    doerror(status);
+end.
+{
+  $Log$
+  Revision 1.1  2002-01-29 17:54:53  peter
+    * splitted to base and extra
+
+  Revision 1.3  2001/04/10 23:30:04  peter
+    * regenerated
+
+}

+ 1234 - 0
packages/base/inet/Makefile

@@ -0,0 +1,1234 @@
+#
+# Don't edit, this file is generated by FPCMake Version 1.1 [2002/01/29]
+#
+default: all
+MAKEFILETARGETS=linux go32v2 win32 os2 freebsd beos netbsd amiga atari sunos qnx
+override PATH:=$(subst \,/,$(PATH))
+ifeq ($(findstring ;,$(PATH)),)
+inUnix=1
+SEARCHPATH:=$(filter-out .,$(subst :, ,$(PATH)))
+else
+SEARCHPATH:=$(subst ;, ,$(PATH))
+endif
+PWD:=$(strip $(wildcard $(addsuffix /pwd.exe,$(SEARCHPATH))))
+ifeq ($(PWD),)
+PWD:=$(strip $(wildcard $(addsuffix /pwd,$(SEARCHPATH))))
+ifeq ($(PWD),)
+$(error You need the GNU utils package to use this Makefile)
+else
+PWD:=$(firstword $(PWD))
+SRCEXEEXT=
+endif
+else
+PWD:=$(firstword $(PWD))
+SRCEXEEXT=.exe
+endif
+ifndef inUnix
+ifeq ($(OS),Windows_NT)
+inWinNT=1
+else
+ifdef OS2_SHELL
+inOS2=1
+endif
+endif
+else
+ifneq ($(findstring cygwin,$(MACHTYPE)),)
+inCygWin=1
+endif
+endif
+ifeq ($(OS_TARGET),freebsd)
+BSDhier=1
+endif
+ifeq ($(OS_TARGET),netbsd)
+BSDhier=1
+endif
+ifdef inUnix
+BATCHEXT=.sh
+else
+ifdef inOS2
+BATCHEXT=.cmd
+else
+BATCHEXT=.bat
+endif
+endif
+ifdef inUnix
+PATHSEP=/
+else
+PATHSEP:=$(subst /,\,/)
+endif
+ifdef PWD
+BASEDIR:=$(subst \,/,$(shell $(PWD)))
+ifdef inCygWin
+ifneq ($(findstring /cygdrive/,$(BASEDIR)),)
+BASENODIR:=$(patsubst /cygdrive%,%,$(BASEDIR))
+BASEDRIVE:=$(firstword $(subst /, ,$(BASENODIR)))
+BASEDIR:=$(subst /cygdrive/$(BASEDRIVE)/,$(BASEDRIVE):/,$(BASEDIR))
+endif
+endif
+else
+BASEDIR=.
+endif
+override DEFAULT_FPCDIR=../../..
+ifndef FPC
+ifdef PP
+FPC=$(PP)
+endif
+endif
+ifndef FPC
+FPCPROG:=$(strip $(wildcard $(addsuffix /fpc$(SRCEXEEXT),$(SEARCHPATH))))
+ifneq ($(FPCPROG),)
+FPCPROG:=$(firstword $(FPCPROG))
+FPC:=$(shell $(FPCPROG) -PB)
+ifneq ($(findstring Error,$(FPC)),)
+override FPC=ppc386
+endif
+else
+override FPC=ppc386
+endif
+endif
+override FPC:=$(subst $(SRCEXEEXT),,$(FPC))
+override FPC:=$(subst \,/,$(FPC))$(SRCEXEEXT)
+ifndef FPC_VERSION
+FPC_VERSION:=$(shell $(FPC) -iV)
+endif
+export FPC FPC_VERSION
+ifeq ($(findstring 1.0.,$(FPC_VERSION)),)
+COMPILERINFO:=$(shell $(FPC) -iSP -iTP -iSO -iTO)
+ifndef CPU_SOURCE
+CPU_SOURCE:=$(word 1,$(COMPILERINFO))
+endif
+ifndef CPU_TARGET
+CPU_TARGET:=$(word 2,$(COMPILERINFO))
+endif
+ifndef OS_SOURCE
+OS_SOURCE:=$(word 3,$(COMPILERINFO))
+endif
+ifndef OS_TARGET
+OS_TARGET:=$(word 4,$(COMPILERINFO))
+endif
+else
+ifndef CPU_SOURCE
+CPU_SOURCE:=$(shell $(FPC) -iSP)
+endif
+ifndef CPU_TARGET
+CPU_TARGET:=$(shell $(FPC) -iTP)
+endif
+ifndef OS_SOURCE
+OS_SOURCE:=$(shell $(FPC) -iSO)
+endif
+ifndef OS_TARGET
+OS_TARGET:=$(shell $(FPC) -iTO)
+endif
+endif
+FULL_TARGET=$(CPU_TARGET)-$(OS_TARGET)
+FULL_SOURCE=$(CPU_SOURCE)-$(OS_SOURCE)
+ifneq ($(FULL_TARGET),$(FULL_SOURCE))
+CROSSCOMPILE=1
+endif
+ifeq ($(findstring makefile,$(MAKECMDGOALS)),)
+ifeq ($(findstring $(OS_TARGET),$(MAKEFILETARGETS)),)
+$(error The Makefile doesn't support target $(OS_TARGET), please run fpcmake first)
+endif
+endif
+export OS_TARGET OS_SOURCE CPU_TARGET CPU_SOURCE FULL_TARGET FULL_SOURCE CROSSCOMPILE
+ifdef FPCDIR
+override FPCDIR:=$(subst \,/,$(FPCDIR))
+ifeq ($(wildcard $(addprefix $(FPCDIR)/,rtl units)),)
+override FPCDIR=wrong
+endif
+else
+override FPCDIR=wrong
+endif
+ifdef DEFAULT_FPCDIR
+ifeq ($(FPCDIR),wrong)
+override FPCDIR:=$(subst \,/,$(DEFAULT_FPCDIR))
+ifeq ($(wildcard $(addprefix $(FPCDIR)/,rtl units)),)
+override FPCDIR=wrong
+endif
+endif
+endif
+ifeq ($(FPCDIR),wrong)
+ifdef inUnix
+override FPCDIR=/usr/local/lib/fpc/$(FPC_VERSION)
+ifeq ($(wildcard $(FPCDIR)/units),)
+override FPCDIR=/usr/lib/fpc/$(FPC_VERSION)
+endif
+else
+override FPCDIR:=$(subst /$(FPC),,$(firstword $(strip $(wildcard $(addsuffix /$(FPC),$(SEARCHPATH))))))
+override FPCDIR:=$(FPCDIR)/..
+ifeq ($(wildcard $(addprefix $(FPCDIR)/,rtl units)),)
+override FPCDIR:=$(FPCDIR)/..
+ifeq ($(wildcard $(addprefix $(FPCDIR)/,rtl units)),)
+override FPCDIR=c:/pp
+endif
+endif
+endif
+endif
+ifndef CROSSDIR
+CROSSDIR:=$(FPCDIR)/cross/$(FULL_TARGET)
+endif
+ifndef CROSSTARGETDIR
+CROSSTARGETDIR=$(CROSSDIR)/$(FULL_TARGET)
+endif
+ifdef CROSSCOMPILE
+UNITSDIR:=$(wildcard $(CROSSTARGETDIR)/units)
+ifeq ($(UNITSDIR),)
+UNITSDIR:=$(wildcard $(FPCDIR)/units/$(OS_TARGET))
+endif
+else
+UNITSDIR:=$(wildcard $(FPCDIR)/units/$(OS_TARGET))
+endif
+PACKAGESDIR:=$(wildcard $(FPCDIR) $(FPCDIR)/packages/base $(FPCDIR)/packages/extra)
+override PACKAGE_NAME=inet
+override PACKAGE_VERSION=1.0.6
+override TARGET_UNITS+=inet
+override TARGET_EXAMPLES+=testinet pfinger
+override INSTALL_FPCPACKAGE=y
+ifdef REQUIRE_UNITSDIR
+override UNITSDIR+=$(REQUIRE_UNITSDIR)
+endif
+ifdef REQUIRE_PACKAGESDIR
+override PACKAGESDIR+=$(REQUIRE_PACKAGESDIR)
+endif
+ifdef ZIPINSTALL
+ifeq ($(OS_TARGET),linux)
+UNIXINSTALLDIR=1
+endif
+ifeq ($(OS_TARGET),freebsd)
+UNIXINSTALLDIR=1
+endif
+ifeq ($(OS_TARGET),netbsd)
+UNIXINSTALLDIR=1
+endif
+ifeq ($(OS_TARGET),sunos)
+UNIXINSTALLDIR=1
+endif
+else
+ifeq ($(OS_SOURCE),linux)
+UNIXINSTALLDIR=1
+endif
+ifeq ($(OS_SOURCE),freebsd)
+UNIXINSTALLDIR=1
+endif
+ifeq ($(OS_SOURCE),netbsd)
+UNIXINSTALLDIR=1
+endif
+ifeq ($(OS_TARGET),sunos)
+UNIXINSTALLDIR=1
+endif
+endif
+ifndef INSTALL_PREFIX
+ifdef PREFIX
+INSTALL_PREFIX=$(PREFIX)
+endif
+endif
+ifndef INSTALL_PREFIX
+ifdef UNIXINSTALLDIR
+INSTALL_PREFIX=/usr/local
+else
+ifdef INSTALL_FPCPACKAGE
+INSTALL_BASEDIR:=/pp
+else
+INSTALL_BASEDIR:=/$(PACKAGE_NAME)
+endif
+endif
+endif
+export INSTALL_PREFIX
+ifndef DIST_DESTDIR
+DIST_DESTDIR:=$(BASEDIR)
+endif
+export DIST_DESTDIR
+ifndef INSTALL_BASEDIR
+ifdef UNIXINSTALLDIR
+ifdef INSTALL_FPCPACKAGE
+INSTALL_BASEDIR:=$(INSTALL_PREFIX)/lib/fpc/$(FPC_VERSION)
+else
+INSTALL_BASEDIR:=$(INSTALL_PREFIX)/lib/$(PACKAGE_NAME)
+endif
+else
+INSTALL_BASEDIR:=$(INSTALL_PREFIX)
+endif
+endif
+ifndef INSTALL_BINDIR
+ifdef UNIXINSTALLDIR
+INSTALL_BINDIR:=$(INSTALL_PREFIX)/bin
+else
+INSTALL_BINDIR:=$(INSTALL_BASEDIR)/bin
+ifdef INSTALL_FPCPACKAGE
+INSTALL_BINDIR:=$(INSTALL_BINDIR)/$(OS_TARGET)
+endif
+endif
+endif
+ifndef INSTALL_UNITDIR
+ifdef CROSSCOMPILE
+INSTALL_UNITDIR:=$(INSTALL_BASEDIR)/cross/$(FULL_TARGET)/units
+else
+INSTALL_UNITDIR:=$(INSTALL_BASEDIR)/units/$(OS_TARGET)
+endif
+ifdef INSTALL_FPCPACKAGE
+ifdef PACKAGE_NAME
+INSTALL_UNITDIR:=$(INSTALL_UNITDIR)/$(PACKAGE_NAME)
+endif
+endif
+endif
+ifndef INSTALL_LIBDIR
+ifdef UNIXINSTALLDIR
+INSTALL_LIBDIR:=$(INSTALL_PREFIX)/lib
+else
+INSTALL_LIBDIR:=$(INSTALL_UNITDIR)
+endif
+endif
+ifndef INSTALL_SOURCEDIR
+ifdef UNIXINSTALLDIR
+ifdef INSTALL_FPCPACKAGE
+ifdef BSDhier
+INSTALL_SOURCEDIR:=$(INSTALL_PREFIX)/share/src/fpc-$(FPC_VERSION)/$(PACKAGE_NAME)
+else
+INSTALL_SOURCEDIR:=$(INSTALL_PREFIX)/src/fpc-$(FPC_VERSION)/$(PACKAGE_NAME)
+endif
+else
+ifdef BSDhier
+INSTALL_SOURCEDIR:=$(INSTALL_PREFIX)/share/src/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
+else
+INSTALL_SOURCEDIR:=$(INSTALL_PREFIX)/src/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
+endif
+endif
+else
+ifdef INSTALL_FPCPACKAGE
+INSTALL_SOURCEDIR:=$(INSTALL_BASEDIR)/source/$(PACKAGE_NAME)
+else
+INSTALL_SOURCEDIRL:=$(INSTALL_BASEDIR)/source
+endif
+endif
+endif
+ifndef INSTALL_DOCDIR
+ifdef UNIXINSTALLDIR
+ifdef INSTALL_FPCPACKAGE
+ifdef BSDhier
+INSTALL_DOCDIR:=$(INSTALL_PREFIX)/share/doc/fpc-$(FPC_VERSION)/$(PACKAGE_NAME)
+else
+INSTALL_DOCDIR:=$(INSTALL_PREFIX)/doc/fpc-$(FPC_VERSION)/$(PACKAGE_NAME)
+endif
+else
+ifdef BSDhier
+INSTALL_DOCDIR:=$(INSTALL_PREFIX)/share/doc/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
+else
+INSTALL_DOCDIR:=$(INSTALL_PREFIX)/doc/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
+endif
+endif
+else
+ifdef INSTALL_FPCPACKAGE
+INSTALL_DOCDIR:=$(INSTALL_BASEDIR)/doc/$(PACKAGE_NAME)
+else
+INSTALL_DOCDIR:=$(INSTALL_BASEDIR)/doc
+endif
+endif
+endif
+ifndef INSTALL_EXAMPLEDIR
+ifdef UNIXINSTALLDIR
+ifdef INSTALL_FPCPACKAGE
+ifdef BSDhier
+INSTALL_EXAMPLEDIR:=$(INSTALL_PREFIX)/share/examples/fpc-$(FPC_VERSION)/$(PACKAGE_NAME)
+else
+INSTALL_EXAMPLEDIR:=$(INSTALL_PREFIX)/doc/fpc-$(FPC_VERSION)/examples/$(PACKAGE_NAME)
+endif
+else
+ifdef BSDhier
+INSTALL_EXAMPLEDIR:=$(INSTALL_PREFIX)/share/examples/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
+else
+INSTALL_EXAMPLEDIR:=$(INSTALL_PREFIX)/doc/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
+endif
+endif
+else
+ifdef INSTALL_FPCPACKAGE
+INSTALL_EXAMPLEDIR:=$(INSTALL_BASEDIR)/examples/$(PACKAGE_NAME)
+else
+INSTALL_EXAMPLEDIR:=$(INSTALL_BASEDIR)/examples
+endif
+endif
+endif
+ifndef INSTALL_DATADIR
+INSTALL_DATADIR=$(INSTALL_BASEDIR)
+endif
+ifdef CROSSCOMPILE
+ifndef CROSSBINDIR
+CROSSBINDIR:=$(wildcard $(CROSSTARGETDIR)/bin/$(FULL_SOURCE))
+ifeq ($(CROSSBINDIR),)
+CROSSBINDIR:=$(wildcard $(INSTALL_BASEDIR)/cross/$(FULL_TARGET)/bin/$(FULL_SOURCE))
+endif
+endif
+else
+CROSSBINDIR=
+endif
+LOADEREXT=.as
+EXEEXT=.exe
+PPLEXT=.ppl
+PPUEXT=.ppu
+OEXT=.o
+ASMEXT=.s
+SMARTEXT=.sl
+STATICLIBEXT=.a
+SHAREDLIBEXT=.so
+STATICLIBPREFIX=libp
+RSTEXT=.rst
+FPCMADE=fpcmade
+ifeq ($(OS_TARGET),go32v1)
+PPUEXT=.pp1
+OEXT=.o1
+ASMEXT=.s1
+SMARTEXT=.sl1
+STATICLIBEXT=.a1
+SHAREDLIBEXT=.so1
+STATICLIBPREFIX=
+FPCMADE=fpcmade.v1
+PACKAGESUFFIX=v1
+endif
+ifeq ($(OS_TARGET),go32v2)
+STATICLIBPREFIX=
+FPCMADE=fpcmade.dos
+ZIPSUFFIX=go32
+endif
+ifeq ($(OS_TARGET),linux)
+EXEEXT=
+HASSHAREDLIB=1
+FPCMADE=fpcmade.lnx
+ZIPSUFFIX=linux
+endif
+ifeq ($(OS_TARGET),freebsd)
+EXEEXT=
+HASSHAREDLIB=1
+FPCMADE=fpcmade.freebsd
+ZIPSUFFIX=freebsd
+endif
+ifeq ($(OS_TARGET),netbsd)
+EXEEXT=
+HASSHAREDLIB=1
+FPCMADE=fpcmade.netbsd
+ZIPSUFFIX=netbsd
+endif
+ifeq ($(OS_TARGET),win32)
+PPUEXT=.ppw
+OEXT=.ow
+ASMEXT=.sw
+SMARTEXT=.slw
+STATICLIBEXT=.aw
+SHAREDLIBEXT=.dll
+FPCMADE=fpcmade.w32
+ZIPSUFFIX=w32
+endif
+ifeq ($(OS_TARGET),os2)
+PPUEXT=.ppo
+ASMEXT=.so2
+OEXT=.oo2
+AOUTEXT=.out
+SMARTEXT=.so
+STATICLIBEXT=.ao2
+SHAREDLIBEXT=.dll
+FPCMADE=fpcmade.os2
+ZIPSUFFIX=emx
+endif
+ifeq ($(OS_TARGET),amiga)
+EXEEXT=
+PPUEXT=.ppa
+ASMEXT=.asm
+OEXT=.o
+SMARTEXT=.sl
+STATICLIBEXT=.a
+SHAREDLIBEXT=.library
+FPCMADE=fpcmade.amg
+endif
+ifeq ($(OS_TARGET),atari)
+PPUEXT=.ppt
+ASMEXT=.s
+OEXT=.o
+SMARTEXT=.sl
+STATICLIBEXT=.a
+EXEEXT=.ttp
+FPCMADE=fpcmade.ata
+endif
+ifeq ($(OS_TARGET),beos)
+PPUEXT=.ppu
+ASMEXT=.s
+OEXT=.o
+SMARTEXT=.sl
+STATICLIBEXT=.a
+EXEEXT=
+FPCMADE=fpcmade.be
+ZIPSUFFIX=be
+endif
+ifeq ($(OS_TARGET),sunos)
+PPUEXT=.ppu
+ASMEXT=.s
+OEXT=.o
+SMARTEXT=.sl
+STATICLIBEXT=.a
+EXEEXT=
+FPCMADE=fpcmade.sun
+ZIPSUFFIX=sun
+endif
+ifeq ($(OS_TARGET),qnx)
+PPUEXT=.ppu
+ASMEXT=.s
+OEXT=.o
+SMARTEXT=.sl
+STATICLIBEXT=.a
+EXEEXT=
+FPCMADE=fpcmade.qnx
+ZIPSUFFIX=qnx
+endif
+ifndef ECHO
+ECHO:=$(strip $(wildcard $(addsuffix /gecho$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(ECHO),)
+ECHO:=$(strip $(wildcard $(addsuffix /echo$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(ECHO),)
+ECHO=
+else
+ECHO:=$(firstword $(ECHO))
+endif
+else
+ECHO:=$(firstword $(ECHO))
+endif
+endif
+export ECHO
+ifndef DATE
+DATE:=$(strip $(wildcard $(addsuffix /gdate$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(DATE),)
+DATE:=$(strip $(wildcard $(addsuffix /date$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(DATE),)
+DATE=
+else
+DATE:=$(firstword $(DATE))
+endif
+else
+DATE:=$(firstword $(DATE))
+endif
+endif
+export DATE
+ifndef GINSTALL
+GINSTALL:=$(strip $(wildcard $(addsuffix /ginstall$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(GINSTALL),)
+GINSTALL:=$(strip $(wildcard $(addsuffix /install$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(GINSTALL),)
+GINSTALL=
+else
+GINSTALL:=$(firstword $(GINSTALL))
+endif
+else
+GINSTALL:=$(firstword $(GINSTALL))
+endif
+endif
+export GINSTALL
+ifndef CPPROG
+CPPROG:=$(strip $(wildcard $(addsuffix /cp$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(CPPROG),)
+CPPROG=
+else
+CPPROG:=$(firstword $(CPPROG))
+endif
+endif
+export CPPROG
+ifndef RMPROG
+RMPROG:=$(strip $(wildcard $(addsuffix /rm$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(RMPROG),)
+RMPROG=
+else
+RMPROG:=$(firstword $(RMPROG))
+endif
+endif
+export RMPROG
+ifndef MVPROG
+MVPROG:=$(strip $(wildcard $(addsuffix /mv$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(MVPROG),)
+MVPROG=
+else
+MVPROG:=$(firstword $(MVPROG))
+endif
+endif
+export MVPROG
+ifndef ECHOREDIR
+ECHOREDIR:=$(subst /,$(PATHSEP),$(ECHO))
+endif
+ifndef COPY
+COPY:=$(CPPROG) -fp
+endif
+ifndef COPYTREE
+COPYTREE:=$(CPPROG) -rfp
+endif
+ifndef MOVE
+MOVE:=$(MVPROG) -f
+endif
+ifndef DEL
+DEL:=$(RMPROG) -f
+endif
+ifndef DELTREE
+DELTREE:=$(RMPROG) -rf
+endif
+ifndef INSTALL
+ifdef inUnix
+INSTALL:=$(GINSTALL) -c -m 644
+else
+INSTALL:=$(COPY)
+endif
+endif
+ifndef INSTALLEXE
+ifdef inUnix
+INSTALLEXE:=$(GINSTALL) -c -m 755
+else
+INSTALLEXE:=$(COPY)
+endif
+endif
+ifndef MKDIR
+MKDIR:=$(GINSTALL) -m 755 -d
+endif
+export ECHOREDIR COPY COPYTREE MOVE DEL DELTREE INSTALL INSTALLEXE MKDIR
+ifndef PPUMOVE
+PPUMOVE:=$(strip $(wildcard $(addsuffix /ppumove$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(PPUMOVE),)
+PPUMOVE=
+else
+PPUMOVE:=$(firstword $(PPUMOVE))
+endif
+endif
+export PPUMOVE
+ifndef FPCMAKE
+FPCMAKE:=$(strip $(wildcard $(addsuffix /fpcmake$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(FPCMAKE),)
+FPCMAKE=
+else
+FPCMAKE:=$(firstword $(FPCMAKE))
+endif
+endif
+export FPCMAKE
+ifndef ZIPPROG
+ZIPPROG:=$(strip $(wildcard $(addsuffix /zip$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(ZIPPROG),)
+ZIPPROG=
+else
+ZIPPROG:=$(firstword $(ZIPPROG))
+endif
+endif
+export ZIPPROG
+ifndef TARPROG
+TARPROG:=$(strip $(wildcard $(addsuffix /tar$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(TARPROG),)
+TARPROG=
+else
+TARPROG:=$(firstword $(TARPROG))
+endif
+endif
+export TARPROG
+ASNAME=as
+LDNAME=ld
+ARNAME=ar
+RCNAME=rc
+ifeq ($(OS_TARGET),win32)
+ASNAME=asw
+LDNAME=ldw
+ARNAME=arw
+endif
+ifndef ASPROG
+ifdef CROSSBINDIR
+ASPROG=$(CROSSBINDIR)/$(ASNAME)$(SRCEXEEXT)
+else
+ASPROG=$(ASNAME)
+endif
+endif
+ifndef LDPROG
+ifdef CROSSBINDIR
+LDPROG=$(CROSSBINDIR)/$(LDNAME)$(SRCEXEEXT)
+else
+LDPROG=$(LDNAME)
+endif
+endif
+ifndef RCPROG
+ifdef CROSSBINDIR
+RCPROG=$(CROSSBINDIR)/$(RCNAME)$(SRCEXEEXT)
+else
+RCPROG=$(RCNAME)
+endif
+endif
+ifndef ARPROG
+ifdef CROSSBINDIR
+ARPROG=$(CROSSBINDIR)/$(ARNAME)$(SRCEXEEXT)
+else
+ARPROG=$(ARNAME)
+endif
+endif
+AS=$(ASPROG)
+LD=$(LDPROG)
+RC=$(RCPROG)
+AR=$(ARPROG)
+PPAS=ppas$(BATCHEXT)
+ifdef inUnix
+LDCONFIG=ldconfig
+else
+LDCONFIG=
+endif
+ifdef DATE
+DATESTR:=$(shell $(DATE) +%Y%m%d)
+else
+DATESTR=
+endif
+ifndef UPXPROG
+ifeq ($(OS_TARGET),go32v2)
+UPXPROG:=1
+endif
+ifeq ($(OS_TARGET),win32)
+UPXPROG:=1
+endif
+ifdef UPXPROG
+UPXPROG:=$(strip $(wildcard $(addsuffix /upx$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(UPXPROG),)
+UPXPROG=
+else
+UPXPROG:=$(firstword $(UPXPROG))
+endif
+else
+UPXPROG=
+endif
+endif
+export UPXPROG
+ZIPOPT=-9
+ZIPEXT=.zip
+ifeq ($(USETAR),bz2)
+TAROPT=vI
+TAREXT=.tar.bz2
+else
+TAROPT=vz
+TAREXT=.tar.gz
+endif
+override REQUIRE_PACKAGES=rtl 
+ifeq ($(OS_TARGET),linux)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(OS_TARGET),go32v2)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(OS_TARGET),win32)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(OS_TARGET),os2)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(OS_TARGET),freebsd)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(OS_TARGET),beos)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(OS_TARGET),netbsd)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(OS_TARGET),amiga)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(OS_TARGET),atari)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(OS_TARGET),sunos)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(OS_TARGET),qnx)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifdef REQUIRE_PACKAGES_RTL
+PACKAGEDIR_RTL:=$(firstword $(subst /Makefile.fpc,,$(strip $(wildcard $(addsuffix /rtl/$(OS_TARGET)/Makefile.fpc,$(PACKAGESDIR))))))
+ifneq ($(PACKAGEDIR_RTL),)
+ifneq ($(wildcard $(PACKAGEDIR_RTL)/$(OS_TARGET)),)
+UNITDIR_RTL=$(PACKAGEDIR_RTL)/$(OS_TARGET)
+else
+UNITDIR_RTL=$(PACKAGEDIR_RTL)
+endif
+else
+PACKAGEDIR_RTL=
+UNITDIR_RTL:=$(subst /Package.fpc,,$(strip $(wildcard $(addsuffix /rtl/Package.fpc,$(UNITSDIR)))))
+ifneq ($(UNITDIR_RTL),)
+UNITDIR_RTL:=$(firstword $(UNITDIR_RTL))
+else
+UNITDIR_RTL=
+endif
+endif
+ifdef UNITDIR_RTL
+override COMPILER_UNITDIR+=$(UNITDIR_RTL)
+endif
+endif
+ifndef NOCPUDEF
+override FPCOPTDEF=$(CPU_TARGET)
+endif
+ifneq ($(OS_TARGET),$(OS_SOURCE))
+override FPCOPT+=-T$(OS_TARGET)
+endif
+ifdef UNITDIR
+override FPCOPT+=$(addprefix -Fu,$(UNITDIR))
+endif
+ifdef LIBDIR
+override FPCOPT+=$(addprefix -Fl,$(LIBDIR))
+endif
+ifdef OBJDIR
+override FPCOPT+=$(addprefix -Fo,$(OBJDIR))
+endif
+ifdef INCDIR
+override FPCOPT+=$(addprefix -Fi,$(INCDIR))
+endif
+ifdef LINKSMART
+override FPCOPT+=-XX
+endif
+ifdef CREATESMART
+override FPCOPT+=-CX
+endif
+ifdef DEBUG
+override FPCOPT+=-gl
+override FPCOPTDEF+=DEBUG
+endif
+ifdef RELEASE
+ifeq ($(CPU_TARGET),i386)
+FPCCPUOPT:=-OG2p3
+else
+FPCCPUOPT:=
+endif
+override FPCOPT+=-Xs $(FPCCPUOPT) -n
+override FPCOPTDEF+=RELEASE
+endif
+ifdef STRIP
+override FPCOPT+=-Xs
+endif
+ifdef OPTIMIZE
+ifeq ($(CPU_TARGET),i386)
+override FPCOPT+=-OG2p3
+endif
+endif
+ifdef VERBOSE
+override FPCOPT+=-vwni
+endif
+ifdef COMPILER_OPTIONS
+override FPCOPT+=$(COMPILER_OPTIONS)
+endif
+ifdef COMPILER_UNITDIR
+override FPCOPT+=$(addprefix -Fu,$(COMPILER_UNITDIR))
+endif
+ifdef COMPILER_LIBRARYDIR
+override FPCOPT+=$(addprefix -Fl,$(COMPILER_LIBRARYDIR))
+endif
+ifdef COMPILER_OBJECTDIR
+override FPCOPT+=$(addprefix -Fo,$(COMPILER_OBJECTDIR))
+endif
+ifdef COMPILER_INCLUDEDIR
+override FPCOPT+=$(addprefix -Fi,$(COMPILER_INCLUDEDIR))
+endif
+ifdef CROSSBINDIR
+override FPCOPT+=-FD$(CROSSBINDIR)
+endif
+ifdef COMPILER_TARGETDIR
+override FPCOPT+=-FE$(COMPILER_TARGETDIR)
+ifeq ($(COMPILER_TARGETDIR),.)
+override TARGETDIRPREFIX=
+else
+override TARGETDIRPREFIX=$(COMPILER_TARGETDIR)/
+endif
+endif
+ifdef COMPILER_UNITTARGETDIR
+override FPCOPT+=-FU$(COMPILER_UNITTARGETDIR)
+ifeq ($(COMPILER_UNITTARGETDIR),.)
+override UNITTARGETDIRPREFIX=
+else
+override UNITTARGETDIRPREFIX=$(COMPILER_UNITTARGETDIR)/
+endif
+else
+ifdef COMPILER_TARGETDIR
+override COMPILER_UNITTARGETDIR=$(COMPILER_TARGETDIR)
+override UNITTARGETDIRPREFIX=$(TARGETDIRPREFIX)
+endif
+endif
+ifdef OPT
+override FPCOPT+=$(OPT)
+endif
+ifdef FPCOPTDEF
+override FPCOPT+=$(addprefix -d,$(FPCOPTDEF))
+endif
+ifdef CFGFILE
+override FPCOPT+=@$(CFGFILE)
+endif
+ifdef USEENV
+override FPCEXTCMD:=$(FPCOPT)
+override FPCOPT:=!FPCEXTCMD
+export FPCEXTCMD
+endif
+override COMPILER:=$(FPC) $(FPCOPT)
+ifeq (,$(findstring -s ,$(COMPILER)))
+EXECPPAS=
+else
+ifeq ($(OS_SOURCE),$(OS_TARGET))
+EXECPPAS:=@$(PPAS)
+endif
+endif
+.PHONY: fpc_units
+ifdef TARGET_UNITS
+override ALLTARGET+=fpc_units
+override UNITPPUFILES=$(addsuffix $(PPUEXT),$(TARGET_UNITS))
+override IMPLICITUNITPPUFILES=$(addsuffix $(PPUEXT),$(TARGET_IMPLICITUNITS))
+override INSTALLPPUFILES+=$(UNITPPUFILES) $(IMPLICITUNITPPUFILES)
+override CLEANPPUFILES+=$(UNITPPUFILES) $(IMPLICITUNITPPUFILES)
+endif
+fpc_units: $(UNITPPUFILES)
+ifdef TARGET_RSTS
+override RSTFILES=$(addsuffix $(RSTEXT),$(TARGET_RSTS))
+override CLEANRSTFILES+=$(RSTFILES)
+endif
+.PHONY: fpc_examples
+ifdef TARGET_EXAMPLES
+HASEXAMPLES=1
+override EXAMPLESOURCEFILES:=$(wildcard $(addsuffix .pp,$(TARGET_EXAMPLES)) $(addsuffix .pas,$(TARGET_EXAMPLES)))
+override EXAMPLEFILES:=$(addsuffix $(EXEEXT),$(TARGET_EXAMPLES))
+override EXAMPLEOFILES:=$(addsuffix $(OEXT),$(TARGET_EXAMPLES)) $(addprefix $(STATICLIBPREFIX),$(addsuffix $(STATICLIBEXT),$(TARGET_EXAMPLES)))
+override CLEANEXEFILES+=$(EXAMPLEFILES) $(EXAMPLEOFILES)
+ifeq ($(OS_TARGET),os2)
+override CLEANEXEFILES+=$(addsuffix $(AOUTEXT),$(TARGET_EXAMPLES))
+endif
+endif
+ifdef TARGET_EXAMPLEDIRS
+HASEXAMPLES=1
+endif
+fpc_examples: all $(EXAMPLEFILES) $(addsuffix _all,$(TARGET_EXAMPLEDIRS))
+.PHONY: fpc_all fpc_smart fpc_debug fpc_release
+$(FPCMADE): $(ALLTARGET)
+	@$(ECHOREDIR) Compiled > $(FPCMADE)
+fpc_all: $(FPCMADE)
+fpc_smart:
+	$(MAKE) all LINKSMART=1 CREATESMART=1
+fpc_debug:
+	$(MAKE) all DEBUG=1
+fpc_release:
+	$(MAKE) all RELEASE=1
+.SUFFIXES: $(EXEEXT) $(PPUEXT) $(OEXT) .pas .pp .rc .res
+%$(PPUEXT): %.pp
+	$(COMPILER) $<
+	$(EXECPPAS)
+%$(PPUEXT): %.pas
+	$(COMPILER) $<
+	$(EXECPPAS)
+%$(EXEEXT): %.pp
+	$(COMPILER) $<
+	$(EXECPPAS)
+%$(EXEEXT): %.pas
+	$(COMPILER) $<
+	$(EXECPPAS)
+%.res: %.rc
+	windres -i $< -o $@
+vpath %.pp $(COMPILER_SOURCEDIR) $(COMPILER_INCLUDEDIR)
+vpath %.pas $(COMPILER_SOURCEDIR) $(COMPILER_INCLUDEDIR)
+vpath %$(PPUEXT) $(COMPILER_UNITTARGETDIR)
+.PHONY: fpc_install fpc_sourceinstall fpc_exampleinstall
+ifdef INSTALL_UNITS
+override INSTALLPPUFILES+=$(addsuffix $(PPUEXT),$(INSTALL_UNITS))
+endif
+ifdef INSTALL_BUILDUNIT
+override INSTALLPPUFILES:=$(filter-out $(INSTALL_BUILDUNIT),$(INSTALLPPUFILES))
+endif
+ifdef INSTALLPPUFILES
+override INSTALLPPULINKFILES:=$(subst $(PPUEXT),$(OEXT),$(INSTALLPPUFILES)) $(addprefix $(STATICLIBPREFIX),$(subst $(PPUEXT),$(STATICLIBEXT),$(INSTALLPPUFILES)))
+override INSTALLPPUFILES:=$(addprefix $(UNITTARGETDIRPREFIX),$(INSTALLPPUFILES))
+override INSTALLPPULINKFILES:=$(wildcard $(addprefix $(UNITTARGETDIRPREFIX),$(INSTALLPPULINKFILES)))
+override INSTALL_CREATEPACKAGEFPC=1
+endif
+ifdef INSTALLEXEFILES
+override INSTALLEXEFILES:=$(addprefix $(TARGETDIRPREFIX),$(INSTALLEXEFILES))
+endif
+fpc_install: all $(INSTALLTARGET)
+ifdef INSTALLEXEFILES
+	$(MKDIR) $(INSTALL_BINDIR)
+ifdef UPXPROG
+	-$(UPXPROG) $(INSTALLEXEFILES)
+endif
+	$(INSTALLEXE) $(INSTALLEXEFILES) $(INSTALL_BINDIR)
+endif
+ifdef INSTALL_CREATEPACKAGEFPC
+ifdef FPCMAKE
+ifdef PACKAGE_VERSION
+ifneq ($(wildcard Makefile.fpc),)
+	$(FPCMAKE) -p -T$(OS_TARGET) Makefile.fpc
+	$(MKDIR) $(INSTALL_UNITDIR)
+	$(INSTALL) Package.fpc $(INSTALL_UNITDIR)
+endif
+endif
+endif
+endif
+ifdef INSTALLPPUFILES
+	$(MKDIR) $(INSTALL_UNITDIR)
+	$(INSTALL) $(INSTALLPPUFILES) $(INSTALL_UNITDIR)
+ifneq ($(INSTALLPPULINKFILES),)
+	$(INSTALL) $(INSTALLPPULINKFILES) $(INSTALL_UNITDIR)
+endif
+ifneq ($(wildcard $(LIB_FULLNAME)),)
+	$(MKDIR) $(INSTALL_LIBDIR)
+	$(INSTALL) $(LIB_FULLNAME) $(INSTALL_LIBDIR)
+ifdef inUnix
+	ln -sf $(LIB_FULLNAME) $(INSTALL_LIBDIR)/$(LIB_NAME)
+endif
+endif
+endif
+ifdef INSTALL_FILES
+	$(MKDIR) $(INSTALL_DATADIR)
+	$(INSTALL) $(INSTALL_FILES) $(INSTALL_DATADIR)
+endif
+fpc_sourceinstall: distclean
+	$(MKDIR) $(INSTALL_SOURCEDIR)
+	$(COPYTREE) $(BASEDIR) $(INSTALL_SOURCEDIR)
+fpc_exampleinstall: $(addsuffix _distclean,$(TARGET_EXAMPLEDIRS))
+ifdef HASEXAMPLES
+	$(MKDIR) $(INSTALL_EXAMPLEDIR)
+endif
+ifdef EXAMPLESOURCEFILES
+	$(COPY) $(EXAMPLESOURCEFILES) $(INSTALL_EXAMPLEDIR)
+endif
+ifdef TARGET_EXAMPLEDIRS
+	$(COPYTREE) $(addsuffix /*,$(TARGET_EXAMPLEDIRS)) $(INSTALL_EXAMPLEDIR)
+endif
+.PHONY: fpc_distinstall
+fpc_distinstall: install exampleinstall
+.PHONY: fpc_zipinstall fpc_zipsourceinstall fpc_zipexampleinstall
+ifndef PACKDIR
+ifndef inUnix
+PACKDIR=$(BASEDIR)/../fpc-pack
+else
+PACKDIR=/tmp/fpc-pack
+endif
+endif
+ifndef ZIPNAME
+ifdef DIST_ZIPNAME
+ZIPNAME=$(DIST_ZIPNAME)
+else
+ZIPNAME=$(ZIPPREFIX)$(PACKAGE_NAME)$(ZIPSUFFIX)
+endif
+endif
+ifndef ZIPTARGET
+ifdef DIST_ZIPTARGET
+ZIPTARGET=DIST_ZIPTARGET
+else
+ZIPTARGET=install
+endif
+endif
+ifndef USEZIP
+ifdef inUnix
+USETAR=1
+endif
+endif
+ifndef inUnix
+USEZIPWRAPPER=1
+endif
+ifdef USEZIPWRAPPER
+ZIPPATHSEP=$(PATHSEP)
+ZIPWRAPPER=$(subst /,$(PATHSEP),$(DIST_DESTDIR)/fpczip$(BATCHEXT))
+else
+ZIPPATHSEP=/
+endif
+ZIPCMD_CDPACK:=cd $(subst /,$(ZIPPATHSEP),$(PACKDIR))
+ZIPCMD_CDBASE:=cd $(subst /,$(ZIPPATHSEP),$(BASEDIR))
+ifdef USETAR
+ZIPDESTFILE:=$(DIST_DESTDIR)/$(ZIPNAME)$(TAREXT)
+ZIPCMD_ZIP:=$(TARPROG) cf$(TAROPT) $(ZIPDESTFILE) *
+else
+ZIPDESTFILE:=$(DIST_DESTDIR)/$(ZIPNAME)$(ZIPEXT)
+ZIPCMD_ZIP:=$(subst /,$(ZIPPATHSEP),$(ZIPPROG)) -Dr $(ZIPOPT) $(ZIPDESTFILE) *
+endif
+fpc_zipinstall:
+	$(MAKE) $(ZIPTARGET) INSTALL_PREFIX=$(PACKDIR) ZIPINSTALL=1
+	$(MKDIR) $(DIST_DESTDIR)
+	$(DEL) $(ZIPDESTFILE)
+ifdef USEZIPWRAPPER
+ifneq ($(ECHOREDIR),echo)
+	$(ECHOREDIR) -e "$(subst \,\\,$(ZIPCMD_CDPACK))" > $(ZIPWRAPPER)
+	$(ECHOREDIR) -e "$(subst \,\\,$(ZIPCMD_ZIP))" >> $(ZIPWRAPPER)
+	$(ECHOREDIR) -e "$(subst \,\\,$(ZIPCMD_CDBASE))" >> $(ZIPWRAPPER)
+else
+	echo $(ZIPCMD_CDPACK) > $(ZIPWRAPPER)
+	echo $(ZIPCMD_ZIP) >> $(ZIPWRAPPER)
+	echo $(ZIPCMD_CDBASE) >> $(ZIPWRAPPER)
+endif
+ifdef inUnix
+	/bin/sh $(ZIPWRAPPER)
+else
+	$(ZIPWRAPPER)
+endif
+	$(DEL) $(ZIPWRAPPER)
+else
+	$(ZIPCMD_CDPACK) ; $(ZIPCMD_ZIP) ; $(ZIPCMD_CDBASE)
+endif
+	$(DELTREE) $(PACKDIR)
+fpc_zipsourceinstall:
+	$(MAKE) fpc_zipinstall ZIPTARGET=sourceinstall ZIPSUFFIX=src
+fpc_zipexampleinstall:
+ifdef HASEXAMPLES
+	$(MAKE) fpc_zipinstall ZIPTARGET=exampleinstall ZIPSUFFIX=exm
+endif
+fpc_zipdistinstall:
+	$(MAKE) fpc_zipinstall ZIPTARGET=distinstall
+.PHONY: fpc_clean fpc_cleanall fpc_distclean
+ifdef EXEFILES
+override CLEANEXEFILES:=$(addprefix $(TARGETDIRPREFIX),$(CLEANEXEFILES))
+endif
+ifdef CLEAN_UNITS
+override CLEANPPUFILES+=$(addsuffix $(PPUEXT),$(CLEAN_UNITS))
+endif
+ifdef CLEANPPUFILES
+override CLEANPPULINKFILES:=$(subst $(PPUEXT),$(OEXT),$(CLEANPPUFILES)) $(addprefix $(STATICLIBPREFIX),$(subst $(PPUEXT),$(STATICLIBEXT),$(CLEANPPUFILES)))
+override CLEANPPUFILES:=$(addprefix $(UNITTARGETDIRPREFIX),$(CLEANPPUFILES))
+override CLEANPPULINKFILES:=$(wildcard $(addprefix $(UNITTARGETDIRPREFIX),$(CLEANPPULINKFILES)))
+endif
+fpc_clean: $(CLEANTARGET)
+ifdef CLEANEXEFILES
+	-$(DEL) $(CLEANEXEFILES)
+endif
+ifdef CLEANPPUFILES
+	-$(DEL) $(CLEANPPUFILES)
+endif
+ifneq ($(CLEANPPULINKFILES),)
+	-$(DEL) $(CLEANPPULINKFILES)
+endif
+ifdef CLEANRSTFILES
+	-$(DEL) $(addprefix $(UNITTARGETDIRPREFIX),$(CLEANRSTFILES))
+endif
+ifdef CLEAN_FILES
+	-$(DEL) $(CLEAN_FILES)
+endif
+ifdef LIB_NAME
+	-$(DEL) $(LIB_NAME) $(LIB_FULLNAME)
+endif
+	-$(DEL) $(FPCMADE) Package.fpc $(PPAS) script.res link.res $(FPCEXTFILE) $(REDIRFILE)
+fpc_distclean: clean
+ifdef COMPILER_UNITTARGETDIR
+TARGETDIRCLEAN=fpc_clean
+endif
+fpc_cleanall: $(CLEANTARGET) $(TARGETDIRCLEAN)
+ifdef CLEANEXEFILES
+	-$(DEL) $(CLEANEXEFILES)
+endif
+	-$(DEL) *$(OEXT) *$(PPUEXT) *$(RSTEXT) *$(ASMEXT) *$(STATICLIBEXT) *$(SHAREDLIBEXT) *$(PPLEXT)
+	-$(DELTREE) *$(SMARTEXT)
+	-$(DEL) $(FPCMADE) Package.fpc $(PPAS) script.res link.res $(FPCEXTFILE) $(REDIRFILE)
+ifdef AOUTEXT
+	-$(DEL) *$(AOUTEXT)
+endif
+.PHONY: fpc_baseinfo
+override INFORULES+=fpc_baseinfo
+fpc_baseinfo:
+	@$(ECHO)
+	@$(ECHO)  == Package info ==
+	@$(ECHO)  Package Name..... $(PACKAGE_NAME)
+	@$(ECHO)  Package Version.. $(PACKAGE_VERSION)
+	@$(ECHO)
+	@$(ECHO)  == Configuration info ==
+	@$(ECHO)
+	@$(ECHO)  FPC.......... $(FPC)
+	@$(ECHO)  FPC Version.. $(FPC_VERSION)
+	@$(ECHO)  Source CPU... $(CPU_SOURCE)
+	@$(ECHO)  Target CPU... $(CPU_TARGET)
+	@$(ECHO)  Source OS.... $(OS_SOURCE)
+	@$(ECHO)  Target OS.... $(OS_TARGET)
+	@$(ECHO)  Full Target.. $(FULL_SOURCE)
+	@$(ECHO)  Full Source.. $(FULL_TARGET)
+	@$(ECHO)
+	@$(ECHO)  == Directory info ==
+	@$(ECHO)
+	@$(ECHO)  Required pkgs... $(REQUIRE_PACKAGES)
+	@$(ECHO)
+	@$(ECHO)  Basedir......... $(BASEDIR)
+	@$(ECHO)  FPCDir.......... $(FPCDIR)
+	@$(ECHO)  CrossBinDir..... $(CROSSBINDIR)
+	@$(ECHO)  UnitsDir........ $(UNITSDIR)
+	@$(ECHO)  PackagesDir..... $(PACKAGESDIR)
+	@$(ECHO)
+	@$(ECHO)  GCC library..... $(GCCLIBDIR)
+	@$(ECHO)  Other library... $(OTHERLIBDIR)
+	@$(ECHO)
+	@$(ECHO)  == Tools info ==
+	@$(ECHO)
+	@$(ECHO)  As........ $(AS)
+	@$(ECHO)  Ld........ $(LD)
+	@$(ECHO)  Ar........ $(AR)
+	@$(ECHO)  Rc........ $(RC)
+	@$(ECHO)
+	@$(ECHO)  Mv........ $(MVPROG)
+	@$(ECHO)  Cp........ $(CPPROG)
+	@$(ECHO)  Rm........ $(RMPROG)
+	@$(ECHO)  GInstall.. $(GINSTALL)
+	@$(ECHO)  Echo...... $(ECHO)
+	@$(ECHO)  Date...... $(DATE)
+	@$(ECHO)  FPCMake... $(FPCMAKE)
+	@$(ECHO)  PPUMove... $(PPUMOVE)
+	@$(ECHO)  Upx....... $(UPXPROG)
+	@$(ECHO)  Zip....... $(ZIPPROG)
+	@$(ECHO)
+	@$(ECHO)  == Object info ==
+	@$(ECHO)
+	@$(ECHO)  Target Loaders........ $(TARGET_LOADERS)
+	@$(ECHO)  Target Units.......... $(TARGET_UNITS)
+	@$(ECHO)  Target Implicit Units. $(TARGET_IMPLICITUNITS)
+	@$(ECHO)  Target Programs....... $(TARGET_PROGRAMS)
+	@$(ECHO)  Target Dirs........... $(TARGET_DIRS)
+	@$(ECHO)  Target Examples....... $(TARGET_EXAMPLES)
+	@$(ECHO)  Target ExampleDirs.... $(TARGET_EXAMPLEDIRS)
+	@$(ECHO)
+	@$(ECHO)  Clean Units......... $(CLEAN_UNITS)
+	@$(ECHO)  Clean Files......... $(CLEAN_FILES)
+	@$(ECHO)
+	@$(ECHO)  Install Units....... $(INSTALL_UNITS)
+	@$(ECHO)  Install Files....... $(INSTALL_FILES)
+	@$(ECHO)
+	@$(ECHO)  == Install info ==
+	@$(ECHO)
+	@$(ECHO)  DateStr.............. $(DATESTR)
+	@$(ECHO)  ZipPrefix............ $(ZIPPREFIX)
+	@$(ECHO)  ZipSuffix............ $(ZIPSUFFIX)
+	@$(ECHO)  Install FPC Package.. $(INSTALL_FPCPACKAGE)
+	@$(ECHO)
+	@$(ECHO)  Install base dir..... $(INSTALL_BASEDIR)
+	@$(ECHO)  Install binary dir... $(INSTALL_BINDIR)
+	@$(ECHO)  Install library dir.. $(INSTALL_LIBDIR)
+	@$(ECHO)  Install units dir.... $(INSTALL_UNITDIR)
+	@$(ECHO)  Install source dir... $(INSTALL_SOURCEDIR)
+	@$(ECHO)  Install doc dir...... $(INSTALL_DOCDIR)
+	@$(ECHO)  Install example dir.. $(INSTALL_EXAMPLEDIR)
+	@$(ECHO)  Install data dir..... $(INSTALL_DATADIR)
+	@$(ECHO)
+	@$(ECHO)  Dist destination dir. $(DIST_DESTDIR)
+	@$(ECHO)  Dist zip name........ $(DIST_ZIPNAME)
+	@$(ECHO)
+.PHONY: fpc_info
+fpc_info: $(INFORULES)
+.PHONY: fpc_makefile fpc_makefiles fpc_makefile_sub1 fpc_makefile_sub2 \
+	fpc_makefile_dirs
+fpc_makefile:
+	$(FPCMAKE) -w -T$(OS_TARGET) Makefile.fpc
+fpc_makefile_sub1:
+ifdef TARGET_DIRS
+	$(FPCMAKE) -w -T$(OS_TARGET) $(addsuffix /Makefile.fpc,$(TARGET_DIRS))
+endif
+ifdef TARGET_EXAMPLEDIRS
+	$(FPCMAKE) -w -T$(OS_TARGET) $(addsuffix /Makefile.fpc,$(TARGET_EXAMPLEDIRS))
+endif
+fpc_makefile_sub2: $(addsuffix _makefile_dirs,$(TARGET_DIRS) $(TARGET_EXAMPLEDIRS))
+fpc_makefile_dirs: fpc_makefile_sub1 fpc_makefile_sub2
+fpc_makefiles: fpc_makefile fpc_makefile_dirs
+all: fpc_all
+debug: fpc_debug
+smart: fpc_smart
+release: fpc_release
+examples: fpc_examples
+shared:
+install: fpc_install
+sourceinstall: fpc_sourceinstall
+exampleinstall: fpc_exampleinstall
+distinstall: fpc_distinstall
+zipinstall: fpc_zipinstall
+zipsourceinstall: fpc_zipsourceinstall
+zipexampleinstall: fpc_zipexampleinstall
+zipdistinstall: fpc_zipdistinstall
+clean: fpc_clean
+distclean: fpc_distclean
+cleanall: fpc_cleanall
+info: fpc_info
+makefiles: fpc_makefiles
+.PHONY: all debug smart release examples shared install sourceinstall exampleinstall distinstall zipinstall zipsourceinstall zipexampleinstall zipdistinstall clean distclean cleanall info makefiles
+ifneq ($(wildcard fpcmake.loc),)
+include fpcmake.loc
+endif

+ 17 - 0
packages/base/inet/Makefile.fpc

@@ -0,0 +1,17 @@
+#
+#   Makefile.fpc for Internet Units
+#
+
+[package]
+name=inet
+version=1.0.6
+
+[target]
+units=inet
+examples=testinet pfinger
+
+[install]
+fpcpackage=y
+
+[default]
+fpcdir=../../..

+ 541 - 0
packages/base/inet/inet.pp

@@ -0,0 +1,541 @@
+Unit inet;
+
+{ --------------------------------------------------------------------
+  Unit for internet domain calls.
+  Copyright (C) 1997  Michael Van Canneyt
+
+  This program is free software; you can redistribute it and/or modify
+  it under the terms of the GNU General Public License as published by
+  the Free Software Foundation; either version 1, or (at your option)
+  any later version.
+
+  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.  See the
+  GNU General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with this program; if not, write to the Free Software
+  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+  ChangeLog
+  ---------
+
+  Current version is 0.6
+
+  Version          Date             Remarks
+  -------          ----             ----
+  0.1              07/16/97         Unit started. Michael.
+  0.2              07/06/98         Updated for version 0.99.5
+  0.4              08/01/98         Objects for name lookup implemented
+  0.5              09/10/98         Updated calls for 0.99.8.
+  0.6              05/04/99         Added explicit asmmode.
+
+  ------------------------------------------------------------------- }
+
+
+interface
+
+{$LINKLIB c}
+
+Const
+  { Net type }
+  AF_INET = 2;
+
+  { Error constants. Returned by LastError method of THost, TNet}
+
+  NETDB_INTERNAL= -1;       { see errno }
+  NETDB_SUCCESS = 0;        { no problem }
+  HOST_NOT_FOUND= 1;        { Authoritative Answer Host not found }
+  TRY_AGAIN     = 2;        { Non-Authoritive Host not found, or SERVERFAIL }
+  NO_RECOVERY   = 3;        { Non recoverable errors, FORMERR, REFUSED, NOTIMP }
+  NO_DATA       = 4;        { Valid name, no data record of requested type }
+  NO_ADDRESS    = NO_DATA;  { no address, look for MX record }
+
+
+
+
+Type
+  THostAddr = array[1..4] of byte;
+  PHostAddr = ^THostAddr;
+
+Const
+  NoAddress : THostAddr = (0,0,0,0);
+
+Type
+
+  { THostEnt Object }
+  THostEnt = record
+    Name     : pchar;   { Official name }
+    Aliases  : ppchar;  { Null-terminated list of aliases}
+    Addrtype : longint; { Host address type }
+    Addrlen  : longint; { Length of address }
+    Addrlist : ppchar;  { null-terminated list of adresses }
+  end;
+  PHostEnt = ^THostEnt;
+
+  { TNetEnt object }
+  TNetEnt = record
+    Name     : pchar;   { Official name }
+    Aliases  : ppchar;  { Nill-terminated alias list }
+    AddrType : longint; { Net address type }
+    net      : Longint; { Network number }
+  end;
+  PNetEnt = ^TNetEnt;
+
+  TServEnt = record
+    name    : pchar;    { Service name }
+    aliases : ppchar;   { Null-terminated alias list }
+    port    : longint;  { Port number }
+    proto   : pchar;    { Protocol to use }
+  end;
+  PServEnt = ^TServEnt;
+
+  { Pascal Wrapper objects }
+
+  TSelectType = (stFirst,stNext,stPrevious);
+
+  THost = Object
+    FHostEntry : PHostEnt;
+    FAlias,FAddr,FError : Longint;
+    Constructor NameLookup (HostName : String);
+    Constructor AddressLookup (Const Address : THostAddr);
+    Destructor Done;
+    Function Name : String;
+    Function GetAddress (Select : TSelectType) : String;
+    Function GetAlias (Select : TSelectType) : String;
+    Function IPAddress : THostAddr;
+    Function IPString : String;
+    Function LastError : Longint;
+  end;
+
+  TNet = Object
+    FNetEntry : PNetEnt;
+    FAlias,FError : Longint;
+    Constructor NameLookup (NetName : String);
+    Constructor AddressLookup (Const Address : Longint);
+    Destructor Done;
+    Function Name : String;
+    Function GetAlias (Select : TSelectType) : String;
+    Function IPAddress : Longint;
+    Function IPString : String;
+    Function LastError : Longint;
+  end;
+
+  TService = Object
+    FServiceEntry : PServEnt;
+    FAlias,FError : Longint;
+    Constructor NameLookup (ServiceName,Proto : String);
+    Constructor PortLookup (APort : Longint; Proto: string);
+    Destructor Done;
+    Function Name : String;
+    Function Protocol : String;
+    Function GetAlias (Select : TSelectType) : String;
+    Function Port : Longint;
+    Function LastError : Longint;
+  end;
+
+
+
+{ Pascal style calls }
+
+function HostAddrToStr (Entry : THostAddr) : String;
+function StrToHostAddr (IP : String) : THostAddr;
+function NetAddrToStr (Entry : Longint) : String;
+function StrToNetAddr (IP : String) : Longint;
+Function HostToNet (Host : Longint) : Longint;
+Function NetToHost (Net : Longint) : Longint;
+Function ShortHostToNet (Host : Word) : Word;
+Function ShortNetToHost (Net : Word) : Word;
+
+{ C style calls, linked in from Libc }
+
+function gethostent : PHostEnt; cdecl; external;
+function gethostbyname ( Name : Pchar) : PHostEnt; cdecl; external;
+function gethostbyaddr ( Addr : PHostAddr; Len : Longint; HType : Longint) : PHostent ; cdecl; external;
+procedure sethostent (stayopen : longint); cdecl; external;
+procedure endhostent; cdecl; external;
+
+function getnetent : PNetEnt; cdecl; external;
+function getnetbyname ( Name : pchar) : PNetEnt; cdecl; external;
+function getnetbyaddr ( Net : Longint; nettype : Longint) : PNetEnt; cdecl; external;
+procedure setnetent ( Stayopen : Longint);  cdecl; external;
+procedure endnetent; cdecl; external;
+
+function getservent : PServEnt; cdecl; external;
+function getservbyname (name : pchar  ; protocol : pchar) : PServEnt; cdecl; external;
+function getservbyport (port : longint; protocol : pchar) : PServEnt; cdecl; external;
+procedure setservent (StayOpen : longint); cdecl; external;
+procedure endservent; cdecl; external;
+
+var
+  GetDNSError : longint;external name 'h_errno';
+
+
+implementation
+
+Uses strings;
+
+
+function HostAddrToStr (Entry : THostAddr) : String;
+
+Var Dummy : String[4];
+    I : Longint;
+
+begin
+  HostAddrToStr:='';
+  For I:=1 to 4 do
+   begin
+   Str(Entry[I],Dummy);
+   HostAddrToStr:=HostAddrToStr+Dummy;
+   If I<4 Then HostAddrToStr:=HostAddrToStr+'.';
+   end;
+end;
+
+function StrToHostAddr(IP : String) : THostAddr ;
+
+Var Dummy : String[4];
+    I : Longint;
+    J : Integer;
+    Temp : THostAddr;
+
+begin
+  StrToHostAddr:=NoAddress;
+  For I:=1 to 4 do
+   begin
+   If I<4 Then
+     begin
+     J:=Pos('.',IP);
+     If J=0 then exit;
+     Dummy:=Copy(IP,1,J-1);
+     Delete (IP,1,J);
+     end
+   else
+     Dummy:=IP;
+   Val (Dummy,Temp[I],J);
+   If J<>0 then Exit;
+   end;
+ StrToHostAddr:=Temp;
+end;
+
+function NetAddrToStr (Entry : longint) : String;
+
+Var Dummy : String[4];
+    I : Longint;
+
+begin
+  NetAddrToStr:='';
+  For I:=4 downto 1 do
+   begin
+   Str(THostAddr(Entry)[I],Dummy);
+   NetAddrToStr:=NetAddrToStr+Dummy;
+   If I>1 Then NetAddrToStr:=NetAddrToStr+'.';
+   end;
+end;
+
+function StrToNetAddr(IP : String) : Longint;
+
+begin
+  StrToNetAddr:=Longint(StrToHostAddr(IP));
+end;
+
+
+Constructor THost.NameLookup (HostName : String);
+
+begin
+  HostName:=HostName+#0;
+  FHostEntry:=GetHostByName(pchar(@HostName[1]));
+  If FHostEntry=Nil then
+    FError:=GetDNSError
+  else
+    begin
+    FAlias:=0;
+    FAddr:=0;
+    Ferror:=0;
+    end;
+end;
+
+Constructor THost.AddressLookup (Const Address: THostAddr);
+
+begin
+  FHostEntry:=GetHostByAddr(PHostAddr(@Address),SizeOf(Address),AF_INET);
+  If FHostEntry=Nil then
+    FError:=GetDNSError
+  else
+    begin
+    FAlias:=0;
+    FAddr:=0;
+    FError:=0;
+    end;
+end;
+
+
+Function THost.Name : String;
+
+begin
+  Name:='';
+  If (FHostEntry=Nil) or (FError<>0) then exit;
+  Name:=StrPas(FHostEntry^.Name);
+end;
+
+Function THost.GetAlias (Select : TSelectType) : String;
+
+begin
+  GetAlias:='';
+  If (FHostEntry=Nil) or (FError<>0) then exit;
+  Case Select of
+    stFirst     : FAlias:=0;
+    stnext      : If FHostEntry^.Aliases[FAlias]<>Nil then
+                    Falias:=Falias+1;
+    stprevious  : If FAlias=0 Then Exit else FAlias:=FAlias-1;
+  end;
+  If FHostEntry^.Aliases[FAlias]<>Nil then
+    GetAlias:=StrPas(FHostEntry^.Aliases[FAlias]);
+end;
+
+Function THost.GetAddress (Select : TSelectType) : String;
+
+begin
+  GetAddress:='';
+  If (FHostEntry=Nil) or (FError<>0) then exit;
+  Case Select of
+    stFirst     : FAddr:=0;
+    stnext      : If FHostEntry^.AddrList[FAddr]<>Nil then
+                    FAddr:=FAddr+1;
+    stprevious  : If FAddr=0 Then Exit else FAddr:=FAddr-1;
+  end;
+  If FHostEntry^.AddrList[FAddr]<>Nil then
+    GetAddress:=HostAddrToStr(PHostAddr(FHostEntry^.AddrList[FAddr])^);
+end;
+
+Function THost.IPstring : String;
+
+begin
+  IPString:='';
+  If (FHostEntry=Nil) or (FError<>0) then exit;
+  If FHostEntry^.AddrList[0]<>Nil then
+    IPString:=HostAddrToStr(PHostAddr(FHostEntry^.AddrList[0])^);
+end;
+
+Function THost.IPaddress : THostAddr;
+
+begin
+  IPAddress:=NoAddress;
+  If (FHostEntry=Nil) or (FError<>0) then exit;
+  IPAddress:=PHostAddr(FHostEntry^.AddrList[0])^;
+end;
+
+Destructor THost.Done;
+
+begin
+end;
+
+Function THost.LastError : Longint;
+
+begin
+  LastError:=FError;
+end;
+
+Constructor TNet.NameLookup (NetName : String);
+
+begin
+  NetName:=NetName+#0;
+  FNetEntry:=GetNetByName(pchar(@NetName[1]));
+  If FNetEntry=Nil then
+    FError:=GetDNSError
+  else
+    begin
+    FAlias:=0;
+    Ferror:=0;
+    end;
+end;
+
+Constructor TNet.AddressLookup (Const Address: Longint);
+
+begin
+  FNetEntry:=GetNetByAddr(Address,AF_INET);
+  If FNetEntry=Nil then
+    FError:=GetDNSError
+  else
+    begin
+    FAlias:=0;
+    FError:=0;
+    end;
+end;
+
+
+Function TNet.Name : String;
+
+begin
+  Name:='';
+  If (FNetEntry=Nil) or (FError<>0) then exit;
+  Name:=StrPas(FNetEntry^.Name);
+end;
+
+Function TNet.GetAlias (Select : TSelectType) : String;
+
+begin
+  GetAlias:='';
+  If (FNetEntry=Nil) or (FError<>0) then exit;
+  Case Select of
+    stFirst     : FAlias:=0;
+    stnext      : If FNetEntry^.Aliases[FAlias]<>Nil then
+                    Falias:=Falias+1;
+    stprevious  : If FAlias=0 Then Exit else FAlias:=FAlias-1;
+  end;
+  If FNetEntry^.Aliases[FAlias]<>Nil then
+    GetAlias:=StrPas(FNetEntry^.Aliases[FAlias]);
+end;
+
+Function TNet.IPstring : String;
+
+begin
+  IPString:='';
+  If (FNetEntry=Nil) or (FError<>0) then exit;
+  IPString:=NetAddrToStr(FNetEntry^.Net);
+end;
+
+Function TNet.IPaddress : Longint;
+
+begin
+  IPAddress:=0;
+  If (FNetEntry=Nil) or (FError<>0) then exit;
+  IPAddress:=FNetEntry^.Net;
+end;
+
+Destructor TNet.Done;
+
+begin
+end;
+
+Function TNet.LastError : Longint;
+
+begin
+  LastError:=FError;
+end;
+
+Constructor TService.NameLookup (ServiceName,Proto : String);
+
+begin
+  ServiceName:=ServiceName+#0;
+  Proto:=Proto+#0;
+  FServiceEntry:=GetServByName(pchar(@ServiceName[1]),pchar(@Proto[1]));
+  If FServiceEntry=Nil then
+    FError:=GetDNSError
+  else
+    begin
+    FAlias:=0;
+    Ferror:=0;
+    end;
+end;
+
+Constructor TService.PortLookup (APort: Longint; Proto : String);
+
+begin
+  Proto:=proto+#0;
+  FServiceEntry:=GetServByPort(APort,pchar(@proto[1]));
+  If FServiceEntry=Nil then
+    FError:=GetDNSError
+  else
+    begin
+    FAlias:=0;
+    FError:=0;
+    end;
+end;
+
+
+Function TService.Name : String;
+
+begin
+  Name:='';
+  If (FServiceEntry=Nil) or (FError<>0) then exit;
+  Name:=StrPas(FServiceEntry^.Name);
+end;
+
+Function TService.GetAlias (Select : TSelectType) : String;
+
+begin
+  GetAlias:='';
+  If (FServiceEntry=Nil) or (FError<>0) then exit;
+  Case Select of
+    stFirst     : FAlias:=0;
+    stnext      : If FServiceEntry^.Aliases[FAlias]<>Nil then
+                    Falias:=Falias+1;
+    stprevious  : If FAlias=0 Then Exit else FAlias:=FAlias-1;
+  end;
+  If FServiceEntry^.Aliases[FAlias]<>Nil then
+    GetAlias:=StrPas(FServiceEntry^.Aliases[FAlias]);
+end;
+
+Function TService.Protocol : String;
+
+begin
+  Protocol:='';
+  If (FServiceEntry=Nil) or (FError<>0) then exit;
+  Protocol:=Strpas(FServiceEntry^.proto);
+end;
+
+Function TService.Port : Longint;
+
+begin
+  Port:=0;
+  If (FServiceEntry=Nil) or (FError<>0) then exit;
+  Port:=FServiceEntry^.Port;
+end;
+
+Destructor TService.Done;
+
+begin
+end;
+
+Function TService.LastError : Longint;
+
+begin
+  LastError:=FError;
+end;
+
+Function HostToNet (Host : Longint) : Longint;
+
+begin
+  HostToNet:=THostAddr(host)[1];
+  HostToNEt:=HostTONet or ( (THostAddr(host)[2]) shl 8);
+  HostToNEt:=HostToNet or ( (THostAddr(host)[3]) shl 16);
+  HostToNEt:=HostToNet or ( (THostAddr(host)[4]) shl 24);
+end;
+
+Function NetToHost (Net : Longint) : Longint;
+
+begin
+  NetToHost:=THostAddr(Net)[1];
+  NetToHost:=NetToHost or ( (THostAddr(Net)[2]) shl 8);
+  NetToHost:=NetToHost or ( (THostAddr(Net)[3]) shl 16);
+  NetToHost:=NetToHost or ( (THostAddr(Net)[4]) shl 24);
+end;
+
+Function ShortHostToNet (Host : Word) : Word;
+
+begin
+  ShortHostToNet:=lo(host)*256+Hi(Host);
+end;
+
+Function ShortNetToHost (Net : Word) : Word;
+
+begin
+  ShortNetToHost:=lo(Net)*256+Hi(Net);
+end;
+
+end.
+
+
+   $Log$
+   Revision 1.1  2002-01-29 17:54:53  peter
+     * splitted to base and extra
+
+   Revision 1.3  2001/12/17 20:29:00  sg
+   * Now uses 'word' instead of 'integer' for short<->net conversions, as the
+     short conversions are used for port numbers, which are unsigned.
+
+   Revision 1.2  2000/07/13 11:33:26  michael
+   + removed logs
+ 
+}

+ 62 - 0
packages/base/inet/pfinger.pp

@@ -0,0 +1,62 @@
+program pfinger;
+
+uses sockets,errors,inet;
+
+Var Addr : TInetSockAddr;
+    S : Longint;
+    Sin,Sout : Text;
+    Line : string;
+    hostname,username : string;
+    host : THost;
+
+begin
+  if paramcount<>1 then
+    begin
+    writeln ('Usage : pfinger username@hostname');
+    end;
+  HostName:=Paramstr(1);
+  If pos('@',HostName)<>0 then
+    begin
+    username:=copy(HostName,1,pos('@',hostname)-1);
+    hostname:=copy(HostName,pos('@',HostName)+1,255);
+    end
+  else 
+    username:='';
+  Host.NameLookup(HostName);
+  If Host.LastError<>0 then
+    begin
+    writeln ('Unknown host : ',host.name);
+    halt(1);
+    end;
+  Addr.family:=AF_INET;
+  { port 78 in network order }
+  Addr.port:=ShortHostToNet(79);
+  { localhost : 127.0.0.1 in network order }
+  Addr.addr:=HostTonet(Longint(Host.IPAddress));
+  S:=Socket(AF_INET,SOCK_STREAM,0);
+  If Not Connect (S,ADDR,SIN,SOUT) Then
+    begin
+    Writeln ('Couldn''t connect to localhost');
+    Writeln ('Socket error : ',strerror(SocketError));
+    halt(1);
+    end;
+  rewrite (sout);
+  reset(sin);
+  writeln (sout,username);
+  flush(sout);
+  while not eof(sin) do 
+    begin
+    readln (Sin,line);
+    writeln (line);
+    end;
+  close (sin);
+  close (sout);
+end.
+  $Log$
+  Revision 1.1  2002-01-29 17:54:53  peter
+    * splitted to base and extra
+
+  Revision 1.2  2000/07/13 11:33:26  michael
+  + removed logs
+ 
+}

+ 256 - 0
packages/base/inet/testinet.pp

@@ -0,0 +1,256 @@
+program testinet;
+
+{
+   Program to test the inet unit.
+  (C) 1997,1998 by Michael Van Canneyt 
+}
+
+uses inet;
+
+var p : PHostEnt;
+    ph : Phostaddr;
+    pn : PNetEnt;
+    ps : PServEnt;
+    pp : ppchar;
+    host : THost;
+    Net : TNet;
+    service : TService;
+    S : String;
+    TheAddr : THostAddr;
+
+const
+    { Lily is my machine. This may not work of you're on a 
+      standalone machine. In that case, replace the address by
+      an address known to your machine, or, as a last resort, 127.0.0.1 }
+
+    lily : THostAddr = (134,58,81,164);
+    {lily : THostAddr = (127,0,0,1);}
+
+begin
+  p:=gethostbyname ('LocalHost');
+  if p=nil then
+    begin 
+    Writeln ('GetHostByname : No entry');
+    end
+  else
+    begin
+    Writeln ('Data for localhost : ');
+    with p^ do
+      begin
+      writeln ('Name   : ',name);
+      writeln ('Length : ',Addrlen);
+      pp:=aliases;
+      while pp^<>nil do
+        begin
+        writeln ('Alias : ',pp^);
+        inc(longint(pp),4);
+        end;
+      ph:=PHostAddr(addrlist^);
+      writeln ('Addres : ',ph^[1],'.',ph^[2],'.',ph^[3],'.',ph^[4]);
+      end;
+    end;
+  p:=gethostbyaddr (@lily,4,2);  
+  if p=nil then
+    begin 
+    Writeln ('Gethostbyaddr : No entry');
+    end
+  else
+    begin
+    Writeln ('Data for ',lily[1],'.',lily[2],'.',lily[3],'.',lily[4] );
+    with p^ do
+      begin
+      writeln ('Name   : ',name);
+      writeln ('Length : ',Addrlen);
+      pp:=aliases;
+      while pp^<>nil do
+        begin
+        writeln ('Alias : ',pp^);
+        inc(longint(pp),4);
+        end;
+      ph:=PHostAddr(addrlist^);
+      writeln ('Addres : ',ph^[1],'.',ph^[2],'.',ph^[3],'.',ph^[4]);
+      end;
+    end;
+  pn:=GetNetByName ('loopback');
+  if pn=nil then
+    begin
+    writeln ('GetNetByName : No entry');
+    end
+  else
+    begin
+    Writeln ('Data for loopback : ');
+    with pn^ do
+      begin
+      writeln ('Name   : ',name);
+      writeln ('Type   : ',AddrType);
+      pp:=aliases;
+      while pp^<>nil do
+        begin
+        writeln ('Alias : ',pp^);
+        inc(longint(pp),4);
+        end;
+      ph:=PHostAddr(@net);
+      writeln ('Addres : ',ph^[4],'.',ph^[3],'.',ph^[2],'.',ph^[1]);
+      end;
+    end;
+  pn:=GetNetByAddr ((127 shl 24),2);
+  if pn=nil then
+    begin
+    writeln ('GetNetByAddr : No entry');
+    end
+  else
+    begin
+    Writeln ('Data for 127.0.0.0 : ');
+    with pn^ do
+      begin
+      writeln ('Name   : ',name);
+      writeln ('Type   : ',AddrType);
+      pp:=aliases;
+      while pp^<>nil do
+        begin
+        writeln ('Alias : ',pp^);
+        inc(longint(pp),4);
+        end;
+      ph:=PHostAddr(@net);
+      writeln ('Addres : ',ph^[4],'.',ph^[3],'.',ph^[2],'.',ph^[1]);
+      end;
+    end;
+  ps:=GetServByName ('telnet','tcp');
+  if ps=nil then
+    begin
+    writeln ('GetServByName : No entry ');
+    end
+  else
+    with ps^ do 
+      begin
+      writeln ('Name : ',name);
+      writeln ('Protocol : ',proto);
+      writeln ('Port ',port shr 8);
+      pp:=aliases;
+      while pp^<>nil do
+        begin
+        writeln ('Alias : ',pp^);
+        inc(longint(pp),4);
+        end;
+      end;
+  ps:=GetServByPort (23 shl 8 ,'tcp');
+  if ps=nil then
+    begin
+    writeln ('GetServByPort : No entry ');
+    end
+  else
+    with ps^ do 
+      begin
+      writeln ('Name : ',name);
+      writeln ('Protocol : ',proto);
+      writeln ('Port ',port shr 8);
+      pp:=aliases;
+      while pp^<>nil do
+        begin
+        writeln ('Alias : ',pp^);
+        inc(longint(pp),4);
+        end;
+      end;
+  Writeln ('Creating Host Object with namelookup(tflily)');
+  Host.NameLookup ('tflily');
+  If Host.LastError=0 then
+    begin
+    Writeln   ('Name       : ',host.name);
+    S:=Host.GetAlias (stfirst);
+    While S<>'' do
+      begin
+      Writeln ('Host alias : ',S);
+      S:=Host.GetAlias(stnext);
+      end;
+    S:=Host.GetAddress (stfirst);
+    While S<>'' do
+      begin
+      Writeln ('Host address : ',S);
+      S:=Host.GetAddress(stnext);
+      end;
+    end;
+  Writeln ('Creating Host Object with Addresslookup(''tflily'')');
+  Host.AddressLookup (lily);
+  If Host.LastError=0 then
+    begin
+    Writeln   ('Name       : ',host.name);
+    Writeln   ('IP Address : ',host.IPstring);
+    S:=Host.GetAlias (stfirst);
+    While S<>'' do
+      begin
+      Writeln ('Host alias : ',S);
+      S:=Host.GetAlias(stnext);
+      end;
+    S:=Host.GetAddress (stfirst);
+    While S<>'' do
+      begin
+      Writeln ('Host address : ',S);
+      S:=Host.GetAddress(stnext);
+      end;
+    end;
+  Writeln ('Creating net Object with namelookup(''loopback'')');
+  net.NameLookup ('loopback');
+  If net.LastError=0 then
+    begin
+    Writeln   ('Name       : ',net.name);
+    Writeln   ('IP address : ',net.IPstring);
+    S:=net.GetAlias (stfirst);
+    While S<>'' do
+      begin
+      Writeln ('net alias : ',S);
+      S:=net.GetAlias(stnext);
+      end;
+    end;
+  Writeln ('Creating net Object with Addrlookup((127 shl 24))');
+  net.AddressLookup ((127 shl 24));
+  If net.LastError=0 then
+    begin
+    Writeln   ('Name       : ',net.name);
+    Writeln   ('IP address : ',net.IPstring);
+    S:=net.GetAlias (stfirst);
+    While S<>'' do
+      begin
+      Writeln ('net alias : ',S);
+      S:=net.GetAlias(stnext);
+      end;
+    end;
+  S:='134.58.81.164';
+  TheAddr:=StrToHostAddr (S);
+  Writeln (S,' = ',TheAddr[1],'.',theaddr[2],'.',theaddr[3],'.',theaddr[4]);
+  Writeln ('Creating Service Object with Namelookup(''telnet'',''tcp'')');
+  Service.Namelookup('telnet','tcp');
+  If Service.LastError=0 then
+    begin
+    Writeln   ('Name       : ',Service.name);
+    Writeln   ('Protocol   : ',service.protocol);
+    Writeln   ('Port       : ',ShortNetToHost(service.port));
+    S:=service.GetAlias (stfirst);
+    While S<>'' do
+      begin
+      Writeln ('service alias : ',S);
+      S:=service.GetAlias(stnext);
+      end;
+    end;
+  Writeln ('Creating Service Object with Portlookup(23 shl 8 ,''tcp'')');
+  Service.Portlookup(23 shl 8,'tcp');
+  If Service.LastError=0 then
+    begin
+    Writeln   ('Name       : ',Service.name);
+    Writeln   ('Protocol   : ',service.protocol);
+    Writeln   ('Port       : ',ShortNetToHost(service.port));
+    S:=service.GetAlias (stfirst);
+    While S<>'' do
+      begin
+      Writeln ('service alias : ',S);
+      S:=service.GetAlias(stnext);
+      end;
+    end;
+    
+end.  $Log$
+end.  Revision 1.1  2002-01-29 17:54:53  peter
+end.    * splitted to base and extra
+end.
+end.  Revision 1.2  2000/07/13 11:33:26  michael
+end.  + removed logs
+end. 
+}

+ 1225 - 0
packages/base/libasync/Makefile

@@ -0,0 +1,1225 @@
+#
+# Don't edit, this file is generated by FPCMake Version 1.1 [2002/01/29]
+#
+default: all
+MAKEFILETARGETS=linux go32v2 win32 os2 freebsd beos netbsd amiga atari sunos qnx
+override PATH:=$(subst \,/,$(PATH))
+ifeq ($(findstring ;,$(PATH)),)
+inUnix=1
+SEARCHPATH:=$(filter-out .,$(subst :, ,$(PATH)))
+else
+SEARCHPATH:=$(subst ;, ,$(PATH))
+endif
+PWD:=$(strip $(wildcard $(addsuffix /pwd.exe,$(SEARCHPATH))))
+ifeq ($(PWD),)
+PWD:=$(strip $(wildcard $(addsuffix /pwd,$(SEARCHPATH))))
+ifeq ($(PWD),)
+$(error You need the GNU utils package to use this Makefile)
+else
+PWD:=$(firstword $(PWD))
+SRCEXEEXT=
+endif
+else
+PWD:=$(firstword $(PWD))
+SRCEXEEXT=.exe
+endif
+ifndef inUnix
+ifeq ($(OS),Windows_NT)
+inWinNT=1
+else
+ifdef OS2_SHELL
+inOS2=1
+endif
+endif
+else
+ifneq ($(findstring cygwin,$(MACHTYPE)),)
+inCygWin=1
+endif
+endif
+ifeq ($(OS_TARGET),freebsd)
+BSDhier=1
+endif
+ifeq ($(OS_TARGET),netbsd)
+BSDhier=1
+endif
+ifdef inUnix
+BATCHEXT=.sh
+else
+ifdef inOS2
+BATCHEXT=.cmd
+else
+BATCHEXT=.bat
+endif
+endif
+ifdef inUnix
+PATHSEP=/
+else
+PATHSEP:=$(subst /,\,/)
+endif
+ifdef PWD
+BASEDIR:=$(subst \,/,$(shell $(PWD)))
+ifdef inCygWin
+ifneq ($(findstring /cygdrive/,$(BASEDIR)),)
+BASENODIR:=$(patsubst /cygdrive%,%,$(BASEDIR))
+BASEDRIVE:=$(firstword $(subst /, ,$(BASENODIR)))
+BASEDIR:=$(subst /cygdrive/$(BASEDRIVE)/,$(BASEDRIVE):/,$(BASEDIR))
+endif
+endif
+else
+BASEDIR=.
+endif
+override DEFAULT_FPCDIR=../../..
+ifndef FPC
+ifdef PP
+FPC=$(PP)
+endif
+endif
+ifndef FPC
+FPCPROG:=$(strip $(wildcard $(addsuffix /fpc$(SRCEXEEXT),$(SEARCHPATH))))
+ifneq ($(FPCPROG),)
+FPCPROG:=$(firstword $(FPCPROG))
+FPC:=$(shell $(FPCPROG) -PB)
+ifneq ($(findstring Error,$(FPC)),)
+override FPC=ppc386
+endif
+else
+override FPC=ppc386
+endif
+endif
+override FPC:=$(subst $(SRCEXEEXT),,$(FPC))
+override FPC:=$(subst \,/,$(FPC))$(SRCEXEEXT)
+ifndef FPC_VERSION
+FPC_VERSION:=$(shell $(FPC) -iV)
+endif
+export FPC FPC_VERSION
+ifeq ($(findstring 1.0.,$(FPC_VERSION)),)
+COMPILERINFO:=$(shell $(FPC) -iSP -iTP -iSO -iTO)
+ifndef CPU_SOURCE
+CPU_SOURCE:=$(word 1,$(COMPILERINFO))
+endif
+ifndef CPU_TARGET
+CPU_TARGET:=$(word 2,$(COMPILERINFO))
+endif
+ifndef OS_SOURCE
+OS_SOURCE:=$(word 3,$(COMPILERINFO))
+endif
+ifndef OS_TARGET
+OS_TARGET:=$(word 4,$(COMPILERINFO))
+endif
+else
+ifndef CPU_SOURCE
+CPU_SOURCE:=$(shell $(FPC) -iSP)
+endif
+ifndef CPU_TARGET
+CPU_TARGET:=$(shell $(FPC) -iTP)
+endif
+ifndef OS_SOURCE
+OS_SOURCE:=$(shell $(FPC) -iSO)
+endif
+ifndef OS_TARGET
+OS_TARGET:=$(shell $(FPC) -iTO)
+endif
+endif
+FULL_TARGET=$(CPU_TARGET)-$(OS_TARGET)
+FULL_SOURCE=$(CPU_SOURCE)-$(OS_SOURCE)
+ifneq ($(FULL_TARGET),$(FULL_SOURCE))
+CROSSCOMPILE=1
+endif
+ifeq ($(findstring makefile,$(MAKECMDGOALS)),)
+ifeq ($(findstring $(OS_TARGET),$(MAKEFILETARGETS)),)
+$(error The Makefile doesn't support target $(OS_TARGET), please run fpcmake first)
+endif
+endif
+export OS_TARGET OS_SOURCE CPU_TARGET CPU_SOURCE FULL_TARGET FULL_SOURCE CROSSCOMPILE
+ifdef FPCDIR
+override FPCDIR:=$(subst \,/,$(FPCDIR))
+ifeq ($(wildcard $(addprefix $(FPCDIR)/,rtl units)),)
+override FPCDIR=wrong
+endif
+else
+override FPCDIR=wrong
+endif
+ifdef DEFAULT_FPCDIR
+ifeq ($(FPCDIR),wrong)
+override FPCDIR:=$(subst \,/,$(DEFAULT_FPCDIR))
+ifeq ($(wildcard $(addprefix $(FPCDIR)/,rtl units)),)
+override FPCDIR=wrong
+endif
+endif
+endif
+ifeq ($(FPCDIR),wrong)
+ifdef inUnix
+override FPCDIR=/usr/local/lib/fpc/$(FPC_VERSION)
+ifeq ($(wildcard $(FPCDIR)/units),)
+override FPCDIR=/usr/lib/fpc/$(FPC_VERSION)
+endif
+else
+override FPCDIR:=$(subst /$(FPC),,$(firstword $(strip $(wildcard $(addsuffix /$(FPC),$(SEARCHPATH))))))
+override FPCDIR:=$(FPCDIR)/..
+ifeq ($(wildcard $(addprefix $(FPCDIR)/,rtl units)),)
+override FPCDIR:=$(FPCDIR)/..
+ifeq ($(wildcard $(addprefix $(FPCDIR)/,rtl units)),)
+override FPCDIR=c:/pp
+endif
+endif
+endif
+endif
+ifndef CROSSDIR
+CROSSDIR:=$(FPCDIR)/cross/$(FULL_TARGET)
+endif
+ifndef CROSSTARGETDIR
+CROSSTARGETDIR=$(CROSSDIR)/$(FULL_TARGET)
+endif
+ifdef CROSSCOMPILE
+UNITSDIR:=$(wildcard $(CROSSTARGETDIR)/units)
+ifeq ($(UNITSDIR),)
+UNITSDIR:=$(wildcard $(FPCDIR)/units/$(OS_TARGET))
+endif
+else
+UNITSDIR:=$(wildcard $(FPCDIR)/units/$(OS_TARGET))
+endif
+PACKAGESDIR:=$(wildcard $(FPCDIR) $(FPCDIR)/packages/base $(FPCDIR)/packages/extra)
+override PACKAGE_NAME=libasync
+override PACKAGE_VERSION=1.0.6
+override TARGET_UNITS+=libasync
+override INSTALL_FPCPACKAGE=y
+ifeq ($(OS_TARGET),linux)
+override COMPILER_SOURCEDIR+=unix
+endif
+ifeq ($(OS_TARGET),freebsd)
+override COMPILER_SOURCEDIR+=unix
+endif
+override COMPILER_TARGETDIR+=.
+ifdef REQUIRE_UNITSDIR
+override UNITSDIR+=$(REQUIRE_UNITSDIR)
+endif
+ifdef REQUIRE_PACKAGESDIR
+override PACKAGESDIR+=$(REQUIRE_PACKAGESDIR)
+endif
+ifdef ZIPINSTALL
+ifeq ($(OS_TARGET),linux)
+UNIXINSTALLDIR=1
+endif
+ifeq ($(OS_TARGET),freebsd)
+UNIXINSTALLDIR=1
+endif
+ifeq ($(OS_TARGET),netbsd)
+UNIXINSTALLDIR=1
+endif
+ifeq ($(OS_TARGET),sunos)
+UNIXINSTALLDIR=1
+endif
+else
+ifeq ($(OS_SOURCE),linux)
+UNIXINSTALLDIR=1
+endif
+ifeq ($(OS_SOURCE),freebsd)
+UNIXINSTALLDIR=1
+endif
+ifeq ($(OS_SOURCE),netbsd)
+UNIXINSTALLDIR=1
+endif
+ifeq ($(OS_TARGET),sunos)
+UNIXINSTALLDIR=1
+endif
+endif
+ifndef INSTALL_PREFIX
+ifdef PREFIX
+INSTALL_PREFIX=$(PREFIX)
+endif
+endif
+ifndef INSTALL_PREFIX
+ifdef UNIXINSTALLDIR
+INSTALL_PREFIX=/usr/local
+else
+ifdef INSTALL_FPCPACKAGE
+INSTALL_BASEDIR:=/pp
+else
+INSTALL_BASEDIR:=/$(PACKAGE_NAME)
+endif
+endif
+endif
+export INSTALL_PREFIX
+ifndef DIST_DESTDIR
+DIST_DESTDIR:=$(BASEDIR)
+endif
+export DIST_DESTDIR
+ifndef INSTALL_BASEDIR
+ifdef UNIXINSTALLDIR
+ifdef INSTALL_FPCPACKAGE
+INSTALL_BASEDIR:=$(INSTALL_PREFIX)/lib/fpc/$(FPC_VERSION)
+else
+INSTALL_BASEDIR:=$(INSTALL_PREFIX)/lib/$(PACKAGE_NAME)
+endif
+else
+INSTALL_BASEDIR:=$(INSTALL_PREFIX)
+endif
+endif
+ifndef INSTALL_BINDIR
+ifdef UNIXINSTALLDIR
+INSTALL_BINDIR:=$(INSTALL_PREFIX)/bin
+else
+INSTALL_BINDIR:=$(INSTALL_BASEDIR)/bin
+ifdef INSTALL_FPCPACKAGE
+INSTALL_BINDIR:=$(INSTALL_BINDIR)/$(OS_TARGET)
+endif
+endif
+endif
+ifndef INSTALL_UNITDIR
+ifdef CROSSCOMPILE
+INSTALL_UNITDIR:=$(INSTALL_BASEDIR)/cross/$(FULL_TARGET)/units
+else
+INSTALL_UNITDIR:=$(INSTALL_BASEDIR)/units/$(OS_TARGET)
+endif
+ifdef INSTALL_FPCPACKAGE
+ifdef PACKAGE_NAME
+INSTALL_UNITDIR:=$(INSTALL_UNITDIR)/$(PACKAGE_NAME)
+endif
+endif
+endif
+ifndef INSTALL_LIBDIR
+ifdef UNIXINSTALLDIR
+INSTALL_LIBDIR:=$(INSTALL_PREFIX)/lib
+else
+INSTALL_LIBDIR:=$(INSTALL_UNITDIR)
+endif
+endif
+ifndef INSTALL_SOURCEDIR
+ifdef UNIXINSTALLDIR
+ifdef INSTALL_FPCPACKAGE
+ifdef BSDhier
+INSTALL_SOURCEDIR:=$(INSTALL_PREFIX)/share/src/fpc-$(FPC_VERSION)/$(PACKAGE_NAME)
+else
+INSTALL_SOURCEDIR:=$(INSTALL_PREFIX)/src/fpc-$(FPC_VERSION)/$(PACKAGE_NAME)
+endif
+else
+ifdef BSDhier
+INSTALL_SOURCEDIR:=$(INSTALL_PREFIX)/share/src/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
+else
+INSTALL_SOURCEDIR:=$(INSTALL_PREFIX)/src/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
+endif
+endif
+else
+ifdef INSTALL_FPCPACKAGE
+INSTALL_SOURCEDIR:=$(INSTALL_BASEDIR)/source/$(PACKAGE_NAME)
+else
+INSTALL_SOURCEDIRL:=$(INSTALL_BASEDIR)/source
+endif
+endif
+endif
+ifndef INSTALL_DOCDIR
+ifdef UNIXINSTALLDIR
+ifdef INSTALL_FPCPACKAGE
+ifdef BSDhier
+INSTALL_DOCDIR:=$(INSTALL_PREFIX)/share/doc/fpc-$(FPC_VERSION)/$(PACKAGE_NAME)
+else
+INSTALL_DOCDIR:=$(INSTALL_PREFIX)/doc/fpc-$(FPC_VERSION)/$(PACKAGE_NAME)
+endif
+else
+ifdef BSDhier
+INSTALL_DOCDIR:=$(INSTALL_PREFIX)/share/doc/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
+else
+INSTALL_DOCDIR:=$(INSTALL_PREFIX)/doc/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
+endif
+endif
+else
+ifdef INSTALL_FPCPACKAGE
+INSTALL_DOCDIR:=$(INSTALL_BASEDIR)/doc/$(PACKAGE_NAME)
+else
+INSTALL_DOCDIR:=$(INSTALL_BASEDIR)/doc
+endif
+endif
+endif
+ifndef INSTALL_EXAMPLEDIR
+ifdef UNIXINSTALLDIR
+ifdef INSTALL_FPCPACKAGE
+ifdef BSDhier
+INSTALL_EXAMPLEDIR:=$(INSTALL_PREFIX)/share/examples/fpc-$(FPC_VERSION)/$(PACKAGE_NAME)
+else
+INSTALL_EXAMPLEDIR:=$(INSTALL_PREFIX)/doc/fpc-$(FPC_VERSION)/examples/$(PACKAGE_NAME)
+endif
+else
+ifdef BSDhier
+INSTALL_EXAMPLEDIR:=$(INSTALL_PREFIX)/share/examples/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
+else
+INSTALL_EXAMPLEDIR:=$(INSTALL_PREFIX)/doc/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
+endif
+endif
+else
+ifdef INSTALL_FPCPACKAGE
+INSTALL_EXAMPLEDIR:=$(INSTALL_BASEDIR)/examples/$(PACKAGE_NAME)
+else
+INSTALL_EXAMPLEDIR:=$(INSTALL_BASEDIR)/examples
+endif
+endif
+endif
+ifndef INSTALL_DATADIR
+INSTALL_DATADIR=$(INSTALL_BASEDIR)
+endif
+ifdef CROSSCOMPILE
+ifndef CROSSBINDIR
+CROSSBINDIR:=$(wildcard $(CROSSTARGETDIR)/bin/$(FULL_SOURCE))
+ifeq ($(CROSSBINDIR),)
+CROSSBINDIR:=$(wildcard $(INSTALL_BASEDIR)/cross/$(FULL_TARGET)/bin/$(FULL_SOURCE))
+endif
+endif
+else
+CROSSBINDIR=
+endif
+LOADEREXT=.as
+EXEEXT=.exe
+PPLEXT=.ppl
+PPUEXT=.ppu
+OEXT=.o
+ASMEXT=.s
+SMARTEXT=.sl
+STATICLIBEXT=.a
+SHAREDLIBEXT=.so
+STATICLIBPREFIX=libp
+RSTEXT=.rst
+FPCMADE=fpcmade
+ifeq ($(OS_TARGET),go32v1)
+PPUEXT=.pp1
+OEXT=.o1
+ASMEXT=.s1
+SMARTEXT=.sl1
+STATICLIBEXT=.a1
+SHAREDLIBEXT=.so1
+STATICLIBPREFIX=
+FPCMADE=fpcmade.v1
+PACKAGESUFFIX=v1
+endif
+ifeq ($(OS_TARGET),go32v2)
+STATICLIBPREFIX=
+FPCMADE=fpcmade.dos
+ZIPSUFFIX=go32
+endif
+ifeq ($(OS_TARGET),linux)
+EXEEXT=
+HASSHAREDLIB=1
+FPCMADE=fpcmade.lnx
+ZIPSUFFIX=linux
+endif
+ifeq ($(OS_TARGET),freebsd)
+EXEEXT=
+HASSHAREDLIB=1
+FPCMADE=fpcmade.freebsd
+ZIPSUFFIX=freebsd
+endif
+ifeq ($(OS_TARGET),netbsd)
+EXEEXT=
+HASSHAREDLIB=1
+FPCMADE=fpcmade.netbsd
+ZIPSUFFIX=netbsd
+endif
+ifeq ($(OS_TARGET),win32)
+PPUEXT=.ppw
+OEXT=.ow
+ASMEXT=.sw
+SMARTEXT=.slw
+STATICLIBEXT=.aw
+SHAREDLIBEXT=.dll
+FPCMADE=fpcmade.w32
+ZIPSUFFIX=w32
+endif
+ifeq ($(OS_TARGET),os2)
+PPUEXT=.ppo
+ASMEXT=.so2
+OEXT=.oo2
+AOUTEXT=.out
+SMARTEXT=.so
+STATICLIBEXT=.ao2
+SHAREDLIBEXT=.dll
+FPCMADE=fpcmade.os2
+ZIPSUFFIX=emx
+endif
+ifeq ($(OS_TARGET),amiga)
+EXEEXT=
+PPUEXT=.ppa
+ASMEXT=.asm
+OEXT=.o
+SMARTEXT=.sl
+STATICLIBEXT=.a
+SHAREDLIBEXT=.library
+FPCMADE=fpcmade.amg
+endif
+ifeq ($(OS_TARGET),atari)
+PPUEXT=.ppt
+ASMEXT=.s
+OEXT=.o
+SMARTEXT=.sl
+STATICLIBEXT=.a
+EXEEXT=.ttp
+FPCMADE=fpcmade.ata
+endif
+ifeq ($(OS_TARGET),beos)
+PPUEXT=.ppu
+ASMEXT=.s
+OEXT=.o
+SMARTEXT=.sl
+STATICLIBEXT=.a
+EXEEXT=
+FPCMADE=fpcmade.be
+ZIPSUFFIX=be
+endif
+ifeq ($(OS_TARGET),sunos)
+PPUEXT=.ppu
+ASMEXT=.s
+OEXT=.o
+SMARTEXT=.sl
+STATICLIBEXT=.a
+EXEEXT=
+FPCMADE=fpcmade.sun
+ZIPSUFFIX=sun
+endif
+ifeq ($(OS_TARGET),qnx)
+PPUEXT=.ppu
+ASMEXT=.s
+OEXT=.o
+SMARTEXT=.sl
+STATICLIBEXT=.a
+EXEEXT=
+FPCMADE=fpcmade.qnx
+ZIPSUFFIX=qnx
+endif
+ifndef ECHO
+ECHO:=$(strip $(wildcard $(addsuffix /gecho$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(ECHO),)
+ECHO:=$(strip $(wildcard $(addsuffix /echo$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(ECHO),)
+ECHO=
+else
+ECHO:=$(firstword $(ECHO))
+endif
+else
+ECHO:=$(firstword $(ECHO))
+endif
+endif
+export ECHO
+ifndef DATE
+DATE:=$(strip $(wildcard $(addsuffix /gdate$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(DATE),)
+DATE:=$(strip $(wildcard $(addsuffix /date$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(DATE),)
+DATE=
+else
+DATE:=$(firstword $(DATE))
+endif
+else
+DATE:=$(firstword $(DATE))
+endif
+endif
+export DATE
+ifndef GINSTALL
+GINSTALL:=$(strip $(wildcard $(addsuffix /ginstall$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(GINSTALL),)
+GINSTALL:=$(strip $(wildcard $(addsuffix /install$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(GINSTALL),)
+GINSTALL=
+else
+GINSTALL:=$(firstword $(GINSTALL))
+endif
+else
+GINSTALL:=$(firstword $(GINSTALL))
+endif
+endif
+export GINSTALL
+ifndef CPPROG
+CPPROG:=$(strip $(wildcard $(addsuffix /cp$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(CPPROG),)
+CPPROG=
+else
+CPPROG:=$(firstword $(CPPROG))
+endif
+endif
+export CPPROG
+ifndef RMPROG
+RMPROG:=$(strip $(wildcard $(addsuffix /rm$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(RMPROG),)
+RMPROG=
+else
+RMPROG:=$(firstword $(RMPROG))
+endif
+endif
+export RMPROG
+ifndef MVPROG
+MVPROG:=$(strip $(wildcard $(addsuffix /mv$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(MVPROG),)
+MVPROG=
+else
+MVPROG:=$(firstword $(MVPROG))
+endif
+endif
+export MVPROG
+ifndef ECHOREDIR
+ECHOREDIR:=$(subst /,$(PATHSEP),$(ECHO))
+endif
+ifndef COPY
+COPY:=$(CPPROG) -fp
+endif
+ifndef COPYTREE
+COPYTREE:=$(CPPROG) -rfp
+endif
+ifndef MOVE
+MOVE:=$(MVPROG) -f
+endif
+ifndef DEL
+DEL:=$(RMPROG) -f
+endif
+ifndef DELTREE
+DELTREE:=$(RMPROG) -rf
+endif
+ifndef INSTALL
+ifdef inUnix
+INSTALL:=$(GINSTALL) -c -m 644
+else
+INSTALL:=$(COPY)
+endif
+endif
+ifndef INSTALLEXE
+ifdef inUnix
+INSTALLEXE:=$(GINSTALL) -c -m 755
+else
+INSTALLEXE:=$(COPY)
+endif
+endif
+ifndef MKDIR
+MKDIR:=$(GINSTALL) -m 755 -d
+endif
+export ECHOREDIR COPY COPYTREE MOVE DEL DELTREE INSTALL INSTALLEXE MKDIR
+ifndef PPUMOVE
+PPUMOVE:=$(strip $(wildcard $(addsuffix /ppumove$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(PPUMOVE),)
+PPUMOVE=
+else
+PPUMOVE:=$(firstword $(PPUMOVE))
+endif
+endif
+export PPUMOVE
+ifndef FPCMAKE
+FPCMAKE:=$(strip $(wildcard $(addsuffix /fpcmake$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(FPCMAKE),)
+FPCMAKE=
+else
+FPCMAKE:=$(firstword $(FPCMAKE))
+endif
+endif
+export FPCMAKE
+ifndef ZIPPROG
+ZIPPROG:=$(strip $(wildcard $(addsuffix /zip$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(ZIPPROG),)
+ZIPPROG=
+else
+ZIPPROG:=$(firstword $(ZIPPROG))
+endif
+endif
+export ZIPPROG
+ifndef TARPROG
+TARPROG:=$(strip $(wildcard $(addsuffix /tar$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(TARPROG),)
+TARPROG=
+else
+TARPROG:=$(firstword $(TARPROG))
+endif
+endif
+export TARPROG
+ASNAME=as
+LDNAME=ld
+ARNAME=ar
+RCNAME=rc
+ifeq ($(OS_TARGET),win32)
+ASNAME=asw
+LDNAME=ldw
+ARNAME=arw
+endif
+ifndef ASPROG
+ifdef CROSSBINDIR
+ASPROG=$(CROSSBINDIR)/$(ASNAME)$(SRCEXEEXT)
+else
+ASPROG=$(ASNAME)
+endif
+endif
+ifndef LDPROG
+ifdef CROSSBINDIR
+LDPROG=$(CROSSBINDIR)/$(LDNAME)$(SRCEXEEXT)
+else
+LDPROG=$(LDNAME)
+endif
+endif
+ifndef RCPROG
+ifdef CROSSBINDIR
+RCPROG=$(CROSSBINDIR)/$(RCNAME)$(SRCEXEEXT)
+else
+RCPROG=$(RCNAME)
+endif
+endif
+ifndef ARPROG
+ifdef CROSSBINDIR
+ARPROG=$(CROSSBINDIR)/$(ARNAME)$(SRCEXEEXT)
+else
+ARPROG=$(ARNAME)
+endif
+endif
+AS=$(ASPROG)
+LD=$(LDPROG)
+RC=$(RCPROG)
+AR=$(ARPROG)
+PPAS=ppas$(BATCHEXT)
+ifdef inUnix
+LDCONFIG=ldconfig
+else
+LDCONFIG=
+endif
+ifdef DATE
+DATESTR:=$(shell $(DATE) +%Y%m%d)
+else
+DATESTR=
+endif
+ifndef UPXPROG
+ifeq ($(OS_TARGET),go32v2)
+UPXPROG:=1
+endif
+ifeq ($(OS_TARGET),win32)
+UPXPROG:=1
+endif
+ifdef UPXPROG
+UPXPROG:=$(strip $(wildcard $(addsuffix /upx$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(UPXPROG),)
+UPXPROG=
+else
+UPXPROG:=$(firstword $(UPXPROG))
+endif
+else
+UPXPROG=
+endif
+endif
+export UPXPROG
+ZIPOPT=-9
+ZIPEXT=.zip
+ifeq ($(USETAR),bz2)
+TAROPT=vI
+TAREXT=.tar.bz2
+else
+TAROPT=vz
+TAREXT=.tar.gz
+endif
+override REQUIRE_PACKAGES=rtl rtl
+ifeq ($(OS_TARGET),linux)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(OS_TARGET),go32v2)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(OS_TARGET),win32)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(OS_TARGET),os2)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(OS_TARGET),freebsd)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(OS_TARGET),beos)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(OS_TARGET),netbsd)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(OS_TARGET),amiga)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(OS_TARGET),atari)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(OS_TARGET),sunos)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(OS_TARGET),qnx)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifdef REQUIRE_PACKAGES_RTL
+PACKAGEDIR_RTL:=$(firstword $(subst /Makefile.fpc,,$(strip $(wildcard $(addsuffix /rtl/$(OS_TARGET)/Makefile.fpc,$(PACKAGESDIR))))))
+ifneq ($(PACKAGEDIR_RTL),)
+ifneq ($(wildcard $(PACKAGEDIR_RTL)/$(OS_TARGET)),)
+UNITDIR_RTL=$(PACKAGEDIR_RTL)/$(OS_TARGET)
+else
+UNITDIR_RTL=$(PACKAGEDIR_RTL)
+endif
+else
+PACKAGEDIR_RTL=
+UNITDIR_RTL:=$(subst /Package.fpc,,$(strip $(wildcard $(addsuffix /rtl/Package.fpc,$(UNITSDIR)))))
+ifneq ($(UNITDIR_RTL),)
+UNITDIR_RTL:=$(firstword $(UNITDIR_RTL))
+else
+UNITDIR_RTL=
+endif
+endif
+ifdef UNITDIR_RTL
+override COMPILER_UNITDIR+=$(UNITDIR_RTL)
+endif
+endif
+ifndef NOCPUDEF
+override FPCOPTDEF=$(CPU_TARGET)
+endif
+ifneq ($(OS_TARGET),$(OS_SOURCE))
+override FPCOPT+=-T$(OS_TARGET)
+endif
+ifdef UNITDIR
+override FPCOPT+=$(addprefix -Fu,$(UNITDIR))
+endif
+ifdef LIBDIR
+override FPCOPT+=$(addprefix -Fl,$(LIBDIR))
+endif
+ifdef OBJDIR
+override FPCOPT+=$(addprefix -Fo,$(OBJDIR))
+endif
+ifdef INCDIR
+override FPCOPT+=$(addprefix -Fi,$(INCDIR))
+endif
+ifdef LINKSMART
+override FPCOPT+=-XX
+endif
+ifdef CREATESMART
+override FPCOPT+=-CX
+endif
+ifdef DEBUG
+override FPCOPT+=-gl
+override FPCOPTDEF+=DEBUG
+endif
+ifdef RELEASE
+ifeq ($(CPU_TARGET),i386)
+FPCCPUOPT:=-OG2p3
+else
+FPCCPUOPT:=
+endif
+override FPCOPT+=-Xs $(FPCCPUOPT) -n
+override FPCOPTDEF+=RELEASE
+endif
+ifdef STRIP
+override FPCOPT+=-Xs
+endif
+ifdef OPTIMIZE
+ifeq ($(CPU_TARGET),i386)
+override FPCOPT+=-OG2p3
+endif
+endif
+ifdef VERBOSE
+override FPCOPT+=-vwni
+endif
+ifdef COMPILER_OPTIONS
+override FPCOPT+=$(COMPILER_OPTIONS)
+endif
+ifdef COMPILER_UNITDIR
+override FPCOPT+=$(addprefix -Fu,$(COMPILER_UNITDIR))
+endif
+ifdef COMPILER_LIBRARYDIR
+override FPCOPT+=$(addprefix -Fl,$(COMPILER_LIBRARYDIR))
+endif
+ifdef COMPILER_OBJECTDIR
+override FPCOPT+=$(addprefix -Fo,$(COMPILER_OBJECTDIR))
+endif
+ifdef COMPILER_INCLUDEDIR
+override FPCOPT+=$(addprefix -Fi,$(COMPILER_INCLUDEDIR))
+endif
+ifdef CROSSBINDIR
+override FPCOPT+=-FD$(CROSSBINDIR)
+endif
+ifdef COMPILER_TARGETDIR
+override FPCOPT+=-FE$(COMPILER_TARGETDIR)
+ifeq ($(COMPILER_TARGETDIR),.)
+override TARGETDIRPREFIX=
+else
+override TARGETDIRPREFIX=$(COMPILER_TARGETDIR)/
+endif
+endif
+ifdef COMPILER_UNITTARGETDIR
+override FPCOPT+=-FU$(COMPILER_UNITTARGETDIR)
+ifeq ($(COMPILER_UNITTARGETDIR),.)
+override UNITTARGETDIRPREFIX=
+else
+override UNITTARGETDIRPREFIX=$(COMPILER_UNITTARGETDIR)/
+endif
+else
+ifdef COMPILER_TARGETDIR
+override COMPILER_UNITTARGETDIR=$(COMPILER_TARGETDIR)
+override UNITTARGETDIRPREFIX=$(TARGETDIRPREFIX)
+endif
+endif
+ifdef OPT
+override FPCOPT+=$(OPT)
+endif
+ifdef FPCOPTDEF
+override FPCOPT+=$(addprefix -d,$(FPCOPTDEF))
+endif
+ifdef CFGFILE
+override FPCOPT+=@$(CFGFILE)
+endif
+ifdef USEENV
+override FPCEXTCMD:=$(FPCOPT)
+override FPCOPT:=!FPCEXTCMD
+export FPCEXTCMD
+endif
+override COMPILER:=$(FPC) $(FPCOPT)
+ifeq (,$(findstring -s ,$(COMPILER)))
+EXECPPAS=
+else
+ifeq ($(OS_SOURCE),$(OS_TARGET))
+EXECPPAS:=@$(PPAS)
+endif
+endif
+.PHONY: fpc_units
+ifdef TARGET_UNITS
+override ALLTARGET+=fpc_units
+override UNITPPUFILES=$(addsuffix $(PPUEXT),$(TARGET_UNITS))
+override IMPLICITUNITPPUFILES=$(addsuffix $(PPUEXT),$(TARGET_IMPLICITUNITS))
+override INSTALLPPUFILES+=$(UNITPPUFILES) $(IMPLICITUNITPPUFILES)
+override CLEANPPUFILES+=$(UNITPPUFILES) $(IMPLICITUNITPPUFILES)
+endif
+fpc_units: $(UNITPPUFILES)
+ifdef TARGET_RSTS
+override RSTFILES=$(addsuffix $(RSTEXT),$(TARGET_RSTS))
+override CLEANRSTFILES+=$(RSTFILES)
+endif
+.PHONY: fpc_all fpc_smart fpc_debug fpc_release
+$(FPCMADE): $(ALLTARGET)
+	@$(ECHOREDIR) Compiled > $(FPCMADE)
+fpc_all: $(FPCMADE)
+fpc_smart:
+	$(MAKE) all LINKSMART=1 CREATESMART=1
+fpc_debug:
+	$(MAKE) all DEBUG=1
+fpc_release:
+	$(MAKE) all RELEASE=1
+.SUFFIXES: $(EXEEXT) $(PPUEXT) $(OEXT) .pas .pp .rc .res
+%$(PPUEXT): %.pp
+	$(COMPILER) $<
+	$(EXECPPAS)
+%$(PPUEXT): %.pas
+	$(COMPILER) $<
+	$(EXECPPAS)
+%$(EXEEXT): %.pp
+	$(COMPILER) $<
+	$(EXECPPAS)
+%$(EXEEXT): %.pas
+	$(COMPILER) $<
+	$(EXECPPAS)
+%.res: %.rc
+	windres -i $< -o $@
+vpath %.pp $(COMPILER_SOURCEDIR) $(COMPILER_INCLUDEDIR)
+vpath %.pas $(COMPILER_SOURCEDIR) $(COMPILER_INCLUDEDIR)
+vpath %$(PPUEXT) $(COMPILER_UNITTARGETDIR)
+.PHONY: fpc_install fpc_sourceinstall fpc_exampleinstall
+ifdef INSTALL_UNITS
+override INSTALLPPUFILES+=$(addsuffix $(PPUEXT),$(INSTALL_UNITS))
+endif
+ifdef INSTALL_BUILDUNIT
+override INSTALLPPUFILES:=$(filter-out $(INSTALL_BUILDUNIT),$(INSTALLPPUFILES))
+endif
+ifdef INSTALLPPUFILES
+override INSTALLPPULINKFILES:=$(subst $(PPUEXT),$(OEXT),$(INSTALLPPUFILES)) $(addprefix $(STATICLIBPREFIX),$(subst $(PPUEXT),$(STATICLIBEXT),$(INSTALLPPUFILES)))
+override INSTALLPPUFILES:=$(addprefix $(UNITTARGETDIRPREFIX),$(INSTALLPPUFILES))
+override INSTALLPPULINKFILES:=$(wildcard $(addprefix $(UNITTARGETDIRPREFIX),$(INSTALLPPULINKFILES)))
+override INSTALL_CREATEPACKAGEFPC=1
+endif
+ifdef INSTALLEXEFILES
+override INSTALLEXEFILES:=$(addprefix $(TARGETDIRPREFIX),$(INSTALLEXEFILES))
+endif
+fpc_install: all $(INSTALLTARGET)
+ifdef INSTALLEXEFILES
+	$(MKDIR) $(INSTALL_BINDIR)
+ifdef UPXPROG
+	-$(UPXPROG) $(INSTALLEXEFILES)
+endif
+	$(INSTALLEXE) $(INSTALLEXEFILES) $(INSTALL_BINDIR)
+endif
+ifdef INSTALL_CREATEPACKAGEFPC
+ifdef FPCMAKE
+ifdef PACKAGE_VERSION
+ifneq ($(wildcard Makefile.fpc),)
+	$(FPCMAKE) -p -T$(OS_TARGET) Makefile.fpc
+	$(MKDIR) $(INSTALL_UNITDIR)
+	$(INSTALL) Package.fpc $(INSTALL_UNITDIR)
+endif
+endif
+endif
+endif
+ifdef INSTALLPPUFILES
+	$(MKDIR) $(INSTALL_UNITDIR)
+	$(INSTALL) $(INSTALLPPUFILES) $(INSTALL_UNITDIR)
+ifneq ($(INSTALLPPULINKFILES),)
+	$(INSTALL) $(INSTALLPPULINKFILES) $(INSTALL_UNITDIR)
+endif
+ifneq ($(wildcard $(LIB_FULLNAME)),)
+	$(MKDIR) $(INSTALL_LIBDIR)
+	$(INSTALL) $(LIB_FULLNAME) $(INSTALL_LIBDIR)
+ifdef inUnix
+	ln -sf $(LIB_FULLNAME) $(INSTALL_LIBDIR)/$(LIB_NAME)
+endif
+endif
+endif
+ifdef INSTALL_FILES
+	$(MKDIR) $(INSTALL_DATADIR)
+	$(INSTALL) $(INSTALL_FILES) $(INSTALL_DATADIR)
+endif
+fpc_sourceinstall: distclean
+	$(MKDIR) $(INSTALL_SOURCEDIR)
+	$(COPYTREE) $(BASEDIR) $(INSTALL_SOURCEDIR)
+fpc_exampleinstall: $(addsuffix _distclean,$(TARGET_EXAMPLEDIRS))
+ifdef HASEXAMPLES
+	$(MKDIR) $(INSTALL_EXAMPLEDIR)
+endif
+ifdef EXAMPLESOURCEFILES
+	$(COPY) $(EXAMPLESOURCEFILES) $(INSTALL_EXAMPLEDIR)
+endif
+ifdef TARGET_EXAMPLEDIRS
+	$(COPYTREE) $(addsuffix /*,$(TARGET_EXAMPLEDIRS)) $(INSTALL_EXAMPLEDIR)
+endif
+.PHONY: fpc_distinstall
+fpc_distinstall: install exampleinstall
+.PHONY: fpc_zipinstall fpc_zipsourceinstall fpc_zipexampleinstall
+ifndef PACKDIR
+ifndef inUnix
+PACKDIR=$(BASEDIR)/../fpc-pack
+else
+PACKDIR=/tmp/fpc-pack
+endif
+endif
+ifndef ZIPNAME
+ifdef DIST_ZIPNAME
+ZIPNAME=$(DIST_ZIPNAME)
+else
+ZIPNAME=$(ZIPPREFIX)$(PACKAGE_NAME)$(ZIPSUFFIX)
+endif
+endif
+ifndef ZIPTARGET
+ifdef DIST_ZIPTARGET
+ZIPTARGET=DIST_ZIPTARGET
+else
+ZIPTARGET=install
+endif
+endif
+ifndef USEZIP
+ifdef inUnix
+USETAR=1
+endif
+endif
+ifndef inUnix
+USEZIPWRAPPER=1
+endif
+ifdef USEZIPWRAPPER
+ZIPPATHSEP=$(PATHSEP)
+ZIPWRAPPER=$(subst /,$(PATHSEP),$(DIST_DESTDIR)/fpczip$(BATCHEXT))
+else
+ZIPPATHSEP=/
+endif
+ZIPCMD_CDPACK:=cd $(subst /,$(ZIPPATHSEP),$(PACKDIR))
+ZIPCMD_CDBASE:=cd $(subst /,$(ZIPPATHSEP),$(BASEDIR))
+ifdef USETAR
+ZIPDESTFILE:=$(DIST_DESTDIR)/$(ZIPNAME)$(TAREXT)
+ZIPCMD_ZIP:=$(TARPROG) cf$(TAROPT) $(ZIPDESTFILE) *
+else
+ZIPDESTFILE:=$(DIST_DESTDIR)/$(ZIPNAME)$(ZIPEXT)
+ZIPCMD_ZIP:=$(subst /,$(ZIPPATHSEP),$(ZIPPROG)) -Dr $(ZIPOPT) $(ZIPDESTFILE) *
+endif
+fpc_zipinstall:
+	$(MAKE) $(ZIPTARGET) INSTALL_PREFIX=$(PACKDIR) ZIPINSTALL=1
+	$(MKDIR) $(DIST_DESTDIR)
+	$(DEL) $(ZIPDESTFILE)
+ifdef USEZIPWRAPPER
+ifneq ($(ECHOREDIR),echo)
+	$(ECHOREDIR) -e "$(subst \,\\,$(ZIPCMD_CDPACK))" > $(ZIPWRAPPER)
+	$(ECHOREDIR) -e "$(subst \,\\,$(ZIPCMD_ZIP))" >> $(ZIPWRAPPER)
+	$(ECHOREDIR) -e "$(subst \,\\,$(ZIPCMD_CDBASE))" >> $(ZIPWRAPPER)
+else
+	echo $(ZIPCMD_CDPACK) > $(ZIPWRAPPER)
+	echo $(ZIPCMD_ZIP) >> $(ZIPWRAPPER)
+	echo $(ZIPCMD_CDBASE) >> $(ZIPWRAPPER)
+endif
+ifdef inUnix
+	/bin/sh $(ZIPWRAPPER)
+else
+	$(ZIPWRAPPER)
+endif
+	$(DEL) $(ZIPWRAPPER)
+else
+	$(ZIPCMD_CDPACK) ; $(ZIPCMD_ZIP) ; $(ZIPCMD_CDBASE)
+endif
+	$(DELTREE) $(PACKDIR)
+fpc_zipsourceinstall:
+	$(MAKE) fpc_zipinstall ZIPTARGET=sourceinstall ZIPSUFFIX=src
+fpc_zipexampleinstall:
+ifdef HASEXAMPLES
+	$(MAKE) fpc_zipinstall ZIPTARGET=exampleinstall ZIPSUFFIX=exm
+endif
+fpc_zipdistinstall:
+	$(MAKE) fpc_zipinstall ZIPTARGET=distinstall
+.PHONY: fpc_clean fpc_cleanall fpc_distclean
+ifdef EXEFILES
+override CLEANEXEFILES:=$(addprefix $(TARGETDIRPREFIX),$(CLEANEXEFILES))
+endif
+ifdef CLEAN_UNITS
+override CLEANPPUFILES+=$(addsuffix $(PPUEXT),$(CLEAN_UNITS))
+endif
+ifdef CLEANPPUFILES
+override CLEANPPULINKFILES:=$(subst $(PPUEXT),$(OEXT),$(CLEANPPUFILES)) $(addprefix $(STATICLIBPREFIX),$(subst $(PPUEXT),$(STATICLIBEXT),$(CLEANPPUFILES)))
+override CLEANPPUFILES:=$(addprefix $(UNITTARGETDIRPREFIX),$(CLEANPPUFILES))
+override CLEANPPULINKFILES:=$(wildcard $(addprefix $(UNITTARGETDIRPREFIX),$(CLEANPPULINKFILES)))
+endif
+fpc_clean: $(CLEANTARGET)
+ifdef CLEANEXEFILES
+	-$(DEL) $(CLEANEXEFILES)
+endif
+ifdef CLEANPPUFILES
+	-$(DEL) $(CLEANPPUFILES)
+endif
+ifneq ($(CLEANPPULINKFILES),)
+	-$(DEL) $(CLEANPPULINKFILES)
+endif
+ifdef CLEANRSTFILES
+	-$(DEL) $(addprefix $(UNITTARGETDIRPREFIX),$(CLEANRSTFILES))
+endif
+ifdef CLEAN_FILES
+	-$(DEL) $(CLEAN_FILES)
+endif
+ifdef LIB_NAME
+	-$(DEL) $(LIB_NAME) $(LIB_FULLNAME)
+endif
+	-$(DEL) $(FPCMADE) Package.fpc $(PPAS) script.res link.res $(FPCEXTFILE) $(REDIRFILE)
+fpc_distclean: clean
+ifdef COMPILER_UNITTARGETDIR
+TARGETDIRCLEAN=fpc_clean
+endif
+fpc_cleanall: $(CLEANTARGET) $(TARGETDIRCLEAN)
+ifdef CLEANEXEFILES
+	-$(DEL) $(CLEANEXEFILES)
+endif
+	-$(DEL) *$(OEXT) *$(PPUEXT) *$(RSTEXT) *$(ASMEXT) *$(STATICLIBEXT) *$(SHAREDLIBEXT) *$(PPLEXT)
+	-$(DELTREE) *$(SMARTEXT)
+	-$(DEL) $(FPCMADE) Package.fpc $(PPAS) script.res link.res $(FPCEXTFILE) $(REDIRFILE)
+ifdef AOUTEXT
+	-$(DEL) *$(AOUTEXT)
+endif
+.PHONY: fpc_baseinfo
+override INFORULES+=fpc_baseinfo
+fpc_baseinfo:
+	@$(ECHO)
+	@$(ECHO)  == Package info ==
+	@$(ECHO)  Package Name..... $(PACKAGE_NAME)
+	@$(ECHO)  Package Version.. $(PACKAGE_VERSION)
+	@$(ECHO)
+	@$(ECHO)  == Configuration info ==
+	@$(ECHO)
+	@$(ECHO)  FPC.......... $(FPC)
+	@$(ECHO)  FPC Version.. $(FPC_VERSION)
+	@$(ECHO)  Source CPU... $(CPU_SOURCE)
+	@$(ECHO)  Target CPU... $(CPU_TARGET)
+	@$(ECHO)  Source OS.... $(OS_SOURCE)
+	@$(ECHO)  Target OS.... $(OS_TARGET)
+	@$(ECHO)  Full Target.. $(FULL_SOURCE)
+	@$(ECHO)  Full Source.. $(FULL_TARGET)
+	@$(ECHO)
+	@$(ECHO)  == Directory info ==
+	@$(ECHO)
+	@$(ECHO)  Required pkgs... $(REQUIRE_PACKAGES)
+	@$(ECHO)
+	@$(ECHO)  Basedir......... $(BASEDIR)
+	@$(ECHO)  FPCDir.......... $(FPCDIR)
+	@$(ECHO)  CrossBinDir..... $(CROSSBINDIR)
+	@$(ECHO)  UnitsDir........ $(UNITSDIR)
+	@$(ECHO)  PackagesDir..... $(PACKAGESDIR)
+	@$(ECHO)
+	@$(ECHO)  GCC library..... $(GCCLIBDIR)
+	@$(ECHO)  Other library... $(OTHERLIBDIR)
+	@$(ECHO)
+	@$(ECHO)  == Tools info ==
+	@$(ECHO)
+	@$(ECHO)  As........ $(AS)
+	@$(ECHO)  Ld........ $(LD)
+	@$(ECHO)  Ar........ $(AR)
+	@$(ECHO)  Rc........ $(RC)
+	@$(ECHO)
+	@$(ECHO)  Mv........ $(MVPROG)
+	@$(ECHO)  Cp........ $(CPPROG)
+	@$(ECHO)  Rm........ $(RMPROG)
+	@$(ECHO)  GInstall.. $(GINSTALL)
+	@$(ECHO)  Echo...... $(ECHO)
+	@$(ECHO)  Date...... $(DATE)
+	@$(ECHO)  FPCMake... $(FPCMAKE)
+	@$(ECHO)  PPUMove... $(PPUMOVE)
+	@$(ECHO)  Upx....... $(UPXPROG)
+	@$(ECHO)  Zip....... $(ZIPPROG)
+	@$(ECHO)
+	@$(ECHO)  == Object info ==
+	@$(ECHO)
+	@$(ECHO)  Target Loaders........ $(TARGET_LOADERS)
+	@$(ECHO)  Target Units.......... $(TARGET_UNITS)
+	@$(ECHO)  Target Implicit Units. $(TARGET_IMPLICITUNITS)
+	@$(ECHO)  Target Programs....... $(TARGET_PROGRAMS)
+	@$(ECHO)  Target Dirs........... $(TARGET_DIRS)
+	@$(ECHO)  Target Examples....... $(TARGET_EXAMPLES)
+	@$(ECHO)  Target ExampleDirs.... $(TARGET_EXAMPLEDIRS)
+	@$(ECHO)
+	@$(ECHO)  Clean Units......... $(CLEAN_UNITS)
+	@$(ECHO)  Clean Files......... $(CLEAN_FILES)
+	@$(ECHO)
+	@$(ECHO)  Install Units....... $(INSTALL_UNITS)
+	@$(ECHO)  Install Files....... $(INSTALL_FILES)
+	@$(ECHO)
+	@$(ECHO)  == Install info ==
+	@$(ECHO)
+	@$(ECHO)  DateStr.............. $(DATESTR)
+	@$(ECHO)  ZipPrefix............ $(ZIPPREFIX)
+	@$(ECHO)  ZipSuffix............ $(ZIPSUFFIX)
+	@$(ECHO)  Install FPC Package.. $(INSTALL_FPCPACKAGE)
+	@$(ECHO)
+	@$(ECHO)  Install base dir..... $(INSTALL_BASEDIR)
+	@$(ECHO)  Install binary dir... $(INSTALL_BINDIR)
+	@$(ECHO)  Install library dir.. $(INSTALL_LIBDIR)
+	@$(ECHO)  Install units dir.... $(INSTALL_UNITDIR)
+	@$(ECHO)  Install source dir... $(INSTALL_SOURCEDIR)
+	@$(ECHO)  Install doc dir...... $(INSTALL_DOCDIR)
+	@$(ECHO)  Install example dir.. $(INSTALL_EXAMPLEDIR)
+	@$(ECHO)  Install data dir..... $(INSTALL_DATADIR)
+	@$(ECHO)
+	@$(ECHO)  Dist destination dir. $(DIST_DESTDIR)
+	@$(ECHO)  Dist zip name........ $(DIST_ZIPNAME)
+	@$(ECHO)
+.PHONY: fpc_info
+fpc_info: $(INFORULES)
+.PHONY: fpc_makefile fpc_makefiles fpc_makefile_sub1 fpc_makefile_sub2 \
+	fpc_makefile_dirs
+fpc_makefile:
+	$(FPCMAKE) -w -T$(OS_TARGET) Makefile.fpc
+fpc_makefile_sub1:
+ifdef TARGET_DIRS
+	$(FPCMAKE) -w -T$(OS_TARGET) $(addsuffix /Makefile.fpc,$(TARGET_DIRS))
+endif
+ifdef TARGET_EXAMPLEDIRS
+	$(FPCMAKE) -w -T$(OS_TARGET) $(addsuffix /Makefile.fpc,$(TARGET_EXAMPLEDIRS))
+endif
+fpc_makefile_sub2: $(addsuffix _makefile_dirs,$(TARGET_DIRS) $(TARGET_EXAMPLEDIRS))
+fpc_makefile_dirs: fpc_makefile_sub1 fpc_makefile_sub2
+fpc_makefiles: fpc_makefile fpc_makefile_dirs
+all: fpc_all
+debug: fpc_debug
+smart: fpc_smart
+release: fpc_release
+examples:
+shared:
+install: fpc_install
+sourceinstall: fpc_sourceinstall
+exampleinstall: fpc_exampleinstall
+distinstall: fpc_distinstall
+zipinstall: fpc_zipinstall
+zipsourceinstall: fpc_zipsourceinstall
+zipexampleinstall: fpc_zipexampleinstall
+zipdistinstall: fpc_zipdistinstall
+clean: fpc_clean
+distclean: fpc_distclean
+cleanall: fpc_cleanall
+info: fpc_info
+makefiles: fpc_makefiles
+.PHONY: all debug smart release examples shared install sourceinstall exampleinstall distinstall zipinstall zipsourceinstall zipexampleinstall zipdistinstall clean distclean cleanall info makefiles
+ifneq ($(wildcard fpcmake.loc),)
+include fpcmake.loc
+endif

+ 24 - 0
packages/base/libasync/Makefile.fpc

@@ -0,0 +1,24 @@
+#
+#   Makefile.fpc for libasync
+#
+
+[package]
+name=libasync
+version=1.0.6
+
+[target]
+units=libasync
+
+[install]
+fpcpackage=y
+
+[compiler]
+sourcedir_linux=unix
+sourcedir_freebsd=unix
+targetdir=.
+
+[require]
+packages=rtl
+
+[default]
+fpcdir=../../..

+ 123 - 0
packages/base/libasync/libasync.inc

@@ -0,0 +1,123 @@
+{
+    $Id$
+
+    libasync: Asynchronous event management
+    Copyright (C) 2001 by
+      Areca Systems GmbH / Sebastian Guenther, [email protected]
+
+    Common interface declaration
+
+    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.
+}
+
+type
+  TAsyncHandleStruct = packed record
+    UserData: Pointer;
+    Data: TAsyncData;
+  end;
+  TAsyncHandle = ^TAsyncHandleStruct;
+
+  TAsyncTimer = Pointer;
+
+  TAsyncCallback = procedure(UserData: Pointer); cdecl;
+
+
+// Construction and destruction
+
+procedure asyncInit(
+  Handle: TAsyncHandle); cdecl;
+
+procedure asyncFree(
+  Handle: TAsyncHandle); cdecl;
+
+
+// Running and stopping the event loop
+
+procedure asyncRun(
+  Handle: TAsyncHandle); cdecl;
+
+procedure asyncBreak(
+  Handle: TAsyncHandle); cdecl;
+
+
+// Status information
+
+function asyncIsRunning(
+  Handle: TAsyncHandle
+  ): Boolean; cdecl;
+
+function asyncGetTicks: Int64; cdecl;
+
+
+// Timer management
+
+function asyncAddTimer(
+  Handle: TAsyncHandle;
+  MSec: LongInt;
+  Periodic: Boolean;		// False = One-shot timer, True = Periodic timer
+  Callback: TAsyncCallback;
+  UserData: Pointer		// User data for callback
+  ): TAsyncTimer; cdecl;
+
+procedure asyncRemoveTimer(
+  Handle: TAsyncHandle;
+  Timer: TASyncTimer); cdecl;
+
+
+// I/O callback management
+
+procedure asyncSetIOCallback(
+  Handle: TAsyncHandle;
+  IOHandle: LongInt;
+  Callback: TAsyncCallback;
+  UserData: Pointer); cdecl;
+
+procedure asyncClearIOCallback(
+  Handle: TAsyncHandle;
+  IOHandle: LongInt); cdecl;
+
+procedure asyncSetDataAvailableCallback(
+  Handle: TAsyncHandle;
+  IOHandle: LongInt;
+  Callback: TAsyncCallback;
+  UserData: Pointer); cdecl;
+
+procedure asyncClearDataAvailableCallback(
+  Handle: TAsyncHandle;
+  IOHandle: LongInt); cdecl;
+
+procedure asyncSetCanWriteCallback(
+  Handle: TAsyncHandle;
+  IOHandle: LongInt;
+  Callback: TAsyncCallback;
+  UserData: Pointer); cdecl;
+
+procedure asyncClearCanWriteCallback(
+  Handle: TAsyncHandle;
+  IOHandle: LongInt); cdecl;
+
+
+{
+  $Log$
+  Revision 1.1  2002-01-29 17:54:53  peter
+    * splitted to base and extra
+
+  Revision 1.2  2001/12/11 17:45:28  marco
+   * was only commited to fixes.
+
+  Revision 1.1.2.2  2001/11/16 12:51:41  sg
+  * Now different handlers for available data and space in write buffer can
+    be set
+  * LOTS of bugfixes in the implementation
+  * fpAsync now has a write buffer class (a read buffer class for reading
+    line by line will be included in the next release)
+
+  Revision 1.1.2.1  2001/09/08 15:43:24  sg
+  * First public version
+
+}

+ 528 - 0
packages/base/libasync/unix/libasync.pp

@@ -0,0 +1,528 @@
+{
+    $Id$
+
+    libasync: Asynchronous event management
+    Copyright (C) 2001 by
+      Areca Systems GmbH / Sebastian Guenther, [email protected]
+
+    Unix implementation
+
+    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.
+}
+
+unit libasync;
+
+{$MODE objfpc}
+
+interface
+
+type
+
+  TAsyncData = record
+    IsRunning, DoBreak: Boolean;
+    HasCallbacks: Boolean;	// True as long as callbacks are set
+    FirstTimer: Pointer;
+    FirstIOCallback: Pointer;
+    FDData: Pointer;
+    HighestHandle: LongInt;
+  end;
+
+{$INCLUDE libasync.inc}
+
+
+
+implementation
+
+{$ifdef VER1_0}
+uses Linux;
+{$else}
+Uses Unix;
+{$endif}
+
+const
+  MaxHandle = SizeOf(TFDSet) * 8 - 1;
+
+type
+  PTimerData = ^TTimerData;
+  TTimerData = record
+    Next: PTimerData;
+    MSec: LongInt;
+    NextTick: Int64;
+    Callback: TAsyncCallback;
+    UserData: Pointer;
+    Periodic: Boolean;
+  end;
+
+  PIOCallbackData = ^TIOCallbackData;
+  TIOCallbackData = record
+    Next: PIOCallbackData;
+    IOHandle: LongInt;
+    ReadCallback, WriteCallback: TAsyncCallback;
+    ReadUserData, WriteUserData: Pointer;
+    SavedHandleFlags: LongInt;
+  end;
+
+
+
+procedure InitIOCallback(Handle: TAsyncHandle; IOHandle: LongInt;
+  ARead: Boolean; ReadCallback: TAsyncCallback; ReadUserData: Pointer;
+  AWrite: Boolean; WriteCallback: TAsyncCallback; WriteUserData: Pointer);
+var
+  Data: PIOCallbackData;
+  i: LongInt;
+  NeedData: Boolean;
+begin
+  if IOHandle > MaxHandle then
+    exit;
+
+  NeedData := True;
+  Data := Handle^.Data.FirstIOCallback;
+  while Assigned(Data) do
+  begin
+    if Data^.IOHandle = IOHandle then
+    begin
+      if ARead then
+      begin
+        Data^.ReadCallback := ReadCallback;
+	Data^.ReadUserData := ReadUserData;
+      end;
+      if AWrite then
+      begin
+        Data^.WriteCallback := WriteCallback;
+	Data^.WriteUserData := WriteUserData;
+      end;
+      NeedData := False;
+      break;
+    end;
+    Data := Data^.Next;
+  end;
+
+  if NeedData then
+  begin
+    New(Data);
+    Data^.Next := Handle^.Data.FirstIOCallback;
+    Handle^.Data.FirstIOCallback := Data;
+    Data^.IOHandle := IOHandle;
+    if ARead then
+    begin
+      Data^.ReadCallback := ReadCallback;
+      Data^.ReadUserData := ReadUserData;
+    end else
+      Data^.ReadCallback := nil;
+    if AWrite then
+    begin
+      Data^.WriteCallback := WriteCallback;
+      Data^.WriteUserData := WriteUserData;
+    end else
+      Data^.WriteCallback := nil;
+
+    if not Assigned(Handle^.Data.FDData) then
+    begin
+      GetMem(Handle^.Data.FDData, SizeOf(TFDSet) * 2);
+      FD_Zero(PFDSet(Handle^.Data.FDData)[0]);
+      FD_Zero(PFDSet(Handle^.Data.FDData)[1]);
+    end;
+    if IOHandle > Handle^.Data.HighestHandle then
+      Handle^.Data.HighestHandle := IOHandle;
+  end;
+
+  Data^.SavedHandleFlags := fcntl(IOHandle, F_GetFl);
+  fcntl(IOHandle, F_SetFl, Data^.SavedHandleFlags or Open_NonBlock);
+
+  case IOHandle of
+    StdInputHandle:
+      i := Open_RdOnly;
+    StdOutputHandle, StdErrorHandle:
+      i := Open_WrOnly;
+    else
+      i := Data^.SavedHandleFlags and Open_Accmode;
+  end;
+
+  case i of
+    Open_RdOnly:
+      if ARead then
+        FD_Set(IOHandle, PFDSet(Handle^.Data.FDData)[0]);
+    Open_WrOnly:
+      if AWrite then
+        FD_Set(IOHandle, PFDSet(Handle^.Data.FDData)[1]);
+    Open_RdWr:
+      begin
+        if ARead then
+	  FD_Set(IOHandle, PFDSet(Handle^.Data.FDData)[0]);
+	if AWrite then
+	  FD_Set(IOHandle, PFDSet(Handle^.Data.FDData)[1]);
+      end;
+  end;
+
+  Handle^.Data.HasCallbacks := True;
+end;
+
+procedure CheckForCallbacks(Handle: TAsyncHandle);
+var
+  Data: PIOCallbackData;
+begin
+  if (Handle^.Data.HasCallbacks) and
+    (not Assigned(Handle^.Data.FirstIOCallback)) and
+    (not Assigned(Handle^.Data.FirstTimer)) then
+    Handle^.Data.HasCallbacks := False;
+end;
+
+
+
+procedure asyncInit(Handle: TAsyncHandle); cdecl;
+begin
+  Handle^.Data.HighestHandle := -1;
+end;
+
+procedure asyncFree(Handle: TAsyncHandle); cdecl;
+var
+  Timer, NextTimer: PTimerData;
+  IOCallback, NextIOCallback: PIOCallbackData;
+begin
+  Timer := PTimerData(Handle^.Data.FirstTimer);
+  while Assigned(Timer) do
+  begin
+    NextTimer := Timer^.Next;
+    Dispose(Timer);
+    Timer := NextTimer;
+  end;
+
+  IOCallback := PIOCallbackData(Handle^.Data.FirstIOCallback);
+  while Assigned(IOCallback) do
+  begin
+    if (IOCallback^.SavedHandleFlags and Open_NonBlock) = 0 then
+      fcntl(IOCallback^.IOHandle, F_SetFl, IOCallback^.SavedHandleFlags);
+    NextIOCallback := IOCallback^.Next;
+    Dispose(IOCallback);
+    IOCallback := NextIOCallback;
+  end;
+
+  if Assigned(Handle^.Data.FDData) then
+    FreeMem(Handle^.Data.FDData);
+end;
+
+procedure asyncRun(Handle: TAsyncHandle); cdecl;
+var
+  Timer, NextTimer: PTimerData;
+  TimeOut, AsyncResult: Integer;
+  CurTime, NextTick: Int64;
+  CurReadFDSet, CurWriteFDSet: TFDSet;
+  IOCallback: PIOCallbackData;
+begin
+  if Handle^.Data.IsRunning then
+    exit;
+
+  Handle^.Data.DoBreak := False;
+  Handle^.Data.IsRunning := True;
+
+  // Prepare timers
+  if Assigned(Handle^.Data.FirstTimer) then
+  begin
+    CurTime := asyncGetTicks;
+    Timer := Handle^.Data.FirstTimer;
+    while Assigned(Timer) do
+    begin
+      Timer^.NextTick := CurTime + Timer^.MSec;
+      Timer := Timer^.Next;
+    end;
+  end;
+
+  while (not Handle^.Data.DoBreak) and Handle^.Data.HasCallbacks do
+  begin
+    Timer := Handle^.Data.FirstTimer;
+    if Assigned(Handle^.Data.FirstTimer) then
+    begin
+      // Determine when the next timer tick will happen
+      CurTime := asyncGetTicks;
+      NextTick := High(Int64);
+      Timer := Handle^.Data.FirstTimer;
+      while Assigned(Timer) do
+      begin
+        if Timer^.NextTick < NextTick then
+	  NextTick := Timer^.NextTick;
+	Timer := Timer^.Next;
+      end;
+      TimeOut := NextTick - CurTime;
+      if TimeOut < 0 then
+        TimeOut := 0;
+    end else
+      TimeOut := -1;
+
+    if Handle^.Data.HighestHandle >= 0 then
+    begin
+      CurReadFDSet := PFDSet(Handle^.Data.FDData)[0];
+      CurWriteFDSet := PFDSet(Handle^.Data.FDData)[1];
+      AsyncResult := Select(Handle^.Data.HighestHandle + 1,
+        @CurReadFDSet, @CurWriteFDSet, nil, TimeOut);
+    end else
+      AsyncResult := Select(0, nil, nil, nil, TimeOut);
+
+    if Assigned(Handle^.Data.FirstTimer) then
+    begin
+      // Check for triggered timers
+      CurTime := asyncGetTicks;
+      Timer := Handle^.Data.FirstTimer;
+      while Assigned(Timer) do
+      begin
+        if Timer^.NextTick <= CurTime then
+	begin
+	  Timer^.Callback(Timer^.UserData);
+	  NextTimer := Timer^.Next;
+	  if Timer^.Periodic then
+	    Inc(Timer^.NextTick, Timer^.MSec)
+	  else
+	    asyncRemoveTimer(Handle, Timer);
+	  if Handle^.Data.DoBreak then
+	    break;
+	  Timer := NextTimer;
+	end else
+	  Timer := Timer^.Next;
+      end;
+    end;
+
+    if (AsyncResult > 0) and not Handle^.Data.DoBreak then
+    begin
+      // Check for I/O events
+      IOCallback := Handle^.Data.FirstIOCallback;
+      while Assigned(IOCallback) do
+      begin
+	if FD_IsSet(IOCallback^.IOHandle, CurReadFDSet) and
+	  FD_IsSet(IOCallback^.IOHandle, PFDSet(Handle^.Data.FDData)[0]) then
+	begin
+	  IOCallback^.ReadCallback(IOCallback^.ReadUserData);
+	  if Handle^.Data.DoBreak then
+	    break;
+	end;
+
+	if FD_IsSet(IOCallback^.IOHandle, CurWriteFDSet) and
+	  FD_IsSet(IOCallback^.IOHandle, PFDSet(Handle^.Data.FDData)[1]) then
+	begin
+	  IOCallback^.WriteCallback(IOCallback^.WriteUserData);
+	  if Handle^.Data.DoBreak then
+	    break;
+	end;
+
+	IOCallback := IOCallback^.Next;
+      end;
+    end;
+  end;
+  Handle^.Data.IsRunning := False;
+end;
+
+procedure asyncBreak(Handle: TAsyncHandle); cdecl;
+begin
+  Handle^.Data.DoBreak := True;
+end;
+
+function asyncIsRunning(Handle: TAsyncHandle): Boolean; cdecl;
+begin
+  Result := Handle^.Data.IsRunning;
+end;
+
+function asyncGetTicks: Int64; cdecl;
+var
+  Time: TimeVal;
+begin
+  GetTimeOfDay(Time);
+  Result := Int64(Time.Sec) * 1000 + Int64(Time.USec div 1000);
+end;
+
+function asyncAddTimer(
+  Handle: TAsyncHandle;
+  MSec: LongInt;
+  Periodic: Boolean;
+  Callback: TAsyncCallback;
+  UserData: Pointer
+  ): TAsyncTimer; cdecl;
+var
+  Data: PTimerData;
+begin
+  if not Assigned(Callback) then
+    exit;
+
+  New(Data);
+  Result := Data;
+  Data^.Next := Handle^.Data.FirstTimer;
+  Handle^.Data.FirstTimer := Data;
+  Data^.MSec := MSec;
+  Data^.Periodic := Periodic;
+  Data^.Callback := Callback;
+  Data^.UserData := UserData;
+  if Handle^.Data.IsRunning then
+    Data^.NextTick := asyncGetTicks + MSec;
+
+  Handle^.Data.HasCallbacks := True;
+end;
+
+procedure asyncRemoveTimer(
+  Handle: TAsyncHandle;
+  Timer: TASyncTimer); cdecl;
+var
+  Data, CurData, PrevData, NextData: PTimerData;
+begin
+  Data := PTimerData(Timer);
+  CurData := Handle^.Data.FirstTimer;
+  PrevData := nil;
+  while Assigned(CurData) do
+  begin
+    NextData := CurData^.Next;
+    if CurData = Data then
+    begin
+      if Assigned(PrevData) then
+        PrevData^.Next := NextData
+      else
+        Handle^.Data.FirstTimer := NextData;
+      break;
+    end;
+    PrevData := CurData;
+    CurData := NextData;
+  end;
+  Dispose(Data);
+  CheckForCallbacks(Handle);
+end;
+
+procedure asyncSetIOCallback(
+  Handle: TAsyncHandle;
+  IOHandle: LongInt;
+  Callback: TAsyncCallback;
+  UserData: Pointer); cdecl;
+begin
+  InitIOCallback(Handle, IOHandle, True, Callback, UserData,
+    True, Callback, UserData);
+end;
+
+procedure asyncClearIOCallback(Handle: TAsyncHandle;
+  IOHandle: LongInt); cdecl;
+var
+  CurData, PrevData, NextData: PIOCallbackData;
+begin
+  CurData := Handle^.Data.FirstIOCallback;
+  PrevData := nil;
+  while Assigned(CurData) do
+  begin
+    NextData := CurData^.Next;
+    if CurData^.IOHandle = IOHandle then
+    begin
+      FD_Clr(IOHandle, PFDSet(Handle^.Data.FDData)[0]);
+      FD_Clr(IOHandle, PFDSet(Handle^.Data.FDData)[1]);
+      if Assigned(PrevData) then
+        PrevData^.Next := NextData
+      else
+        Handle^.Data.FirstIOCallback := NextData;
+      Dispose(CurData);
+      break;
+    end;
+    PrevData := CurData;
+    CurData := NextData;
+  end;
+  CheckForCallbacks(Handle);
+end;
+
+procedure asyncSetDataAvailableCallback(
+  Handle: TAsyncHandle;
+  IOHandle: LongInt;
+  Callback: TAsyncCallback;
+  UserData: Pointer); cdecl;
+begin
+  InitIOCallback(Handle, IOHandle, True, Callback, UserData, False, nil, nil);
+end;
+
+procedure asyncClearDataAvailableCallback(Handle: TAsyncHandle;
+  IOHandle: LongInt); cdecl;
+var
+  CurData, PrevData, NextData: PIOCallbackData;
+begin
+  CurData := Handle^.Data.FirstIOCallback;
+  PrevData := nil;
+  while Assigned(CurData) do
+  begin
+    NextData := CurData^.Next;
+    if CurData^.IOHandle = IOHandle then
+    begin
+      FD_Clr(IOHandle, PFDSet(Handle^.Data.FDData)[0]);
+      if Assigned(CurData^.WriteCallback) then
+        CurData^.ReadCallback := nil
+      else
+      begin
+        if Assigned(PrevData) then
+          PrevData^.Next := NextData
+        else
+          Handle^.Data.FirstIOCallback := NextData;
+        Dispose(CurData);
+      end;
+      break;
+    end;
+    PrevData := CurData;
+    CurData := NextData;
+  end;
+  CheckForCallbacks(Handle);
+end;
+
+procedure asyncSetCanWriteCallback(
+  Handle: TAsyncHandle;
+  IOHandle: LongInt;
+  Callback: TAsyncCallback;
+  UserData: Pointer); cdecl;
+begin
+  InitIOCallback(Handle, IOHandle, False, nil, nil, True, Callback, UserData);
+end;
+
+procedure asyncClearCanWriteCallback(Handle: TAsyncHandle;
+  IOHandle: LongInt); cdecl;
+var
+  CurData, PrevData, NextData: PIOCallbackData;
+begin
+  CurData := Handle^.Data.FirstIOCallback;
+  PrevData := nil;
+  while Assigned(CurData) do
+  begin
+    NextData := CurData^.Next;
+    if CurData^.IOHandle = IOHandle then
+    begin
+      FD_Clr(IOHandle, PFDSet(Handle^.Data.FDData)[1]);
+      if Assigned(CurData^.ReadCallback) then
+        CurData^.WriteCallback := nil
+      else
+      begin
+        if Assigned(PrevData) then
+          PrevData^.Next := NextData
+        else
+          Handle^.Data.FirstIOCallback := NextData;
+        Dispose(CurData);
+      end;
+      break;
+    end;
+    PrevData := CurData;
+    CurData := NextData;
+  end;
+  CheckForCallbacks(Handle);
+end;
+
+
+end.
+
+
+{
+  $Log$
+  Revision 1.1  2002-01-29 17:54:53  peter
+    * splitted to base and extra
+
+  Revision 1.2  2001/12/11 19:06:16  marco
+   * from fixes to devel.
+
+  Revision 1.1.2.2  2001/11/16 12:51:41  sg
+  * Now different handlers for available data and space in write buffer can
+    be set
+  * LOTS of bugfixes in the implementation
+  * fpAsync now has a write buffer class (a read buffer class for reading
+    line by line will be included in the next release)
+
+  Revision 1.1.2.1  2001/09/08 15:43:24  sg
+  * First public version
+
+}

+ 1254 - 0
packages/base/mysql/Makefile

@@ -0,0 +1,1254 @@
+#
+# Don't edit, this file is generated by FPCMake Version 1.1 [2002/01/29]
+#
+default: all
+MAKEFILETARGETS=linux go32v2 win32 os2 freebsd beos netbsd amiga atari sunos qnx
+override PATH:=$(subst \,/,$(PATH))
+ifeq ($(findstring ;,$(PATH)),)
+inUnix=1
+SEARCHPATH:=$(filter-out .,$(subst :, ,$(PATH)))
+else
+SEARCHPATH:=$(subst ;, ,$(PATH))
+endif
+PWD:=$(strip $(wildcard $(addsuffix /pwd.exe,$(SEARCHPATH))))
+ifeq ($(PWD),)
+PWD:=$(strip $(wildcard $(addsuffix /pwd,$(SEARCHPATH))))
+ifeq ($(PWD),)
+$(error You need the GNU utils package to use this Makefile)
+else
+PWD:=$(firstword $(PWD))
+SRCEXEEXT=
+endif
+else
+PWD:=$(firstword $(PWD))
+SRCEXEEXT=.exe
+endif
+ifndef inUnix
+ifeq ($(OS),Windows_NT)
+inWinNT=1
+else
+ifdef OS2_SHELL
+inOS2=1
+endif
+endif
+else
+ifneq ($(findstring cygwin,$(MACHTYPE)),)
+inCygWin=1
+endif
+endif
+ifeq ($(OS_TARGET),freebsd)
+BSDhier=1
+endif
+ifeq ($(OS_TARGET),netbsd)
+BSDhier=1
+endif
+ifdef inUnix
+BATCHEXT=.sh
+else
+ifdef inOS2
+BATCHEXT=.cmd
+else
+BATCHEXT=.bat
+endif
+endif
+ifdef inUnix
+PATHSEP=/
+else
+PATHSEP:=$(subst /,\,/)
+endif
+ifdef PWD
+BASEDIR:=$(subst \,/,$(shell $(PWD)))
+ifdef inCygWin
+ifneq ($(findstring /cygdrive/,$(BASEDIR)),)
+BASENODIR:=$(patsubst /cygdrive%,%,$(BASEDIR))
+BASEDRIVE:=$(firstword $(subst /, ,$(BASENODIR)))
+BASEDIR:=$(subst /cygdrive/$(BASEDRIVE)/,$(BASEDRIVE):/,$(BASEDIR))
+endif
+endif
+else
+BASEDIR=.
+endif
+override DEFAULT_FPCDIR=../../..
+ifndef FPC
+ifdef PP
+FPC=$(PP)
+endif
+endif
+ifndef FPC
+FPCPROG:=$(strip $(wildcard $(addsuffix /fpc$(SRCEXEEXT),$(SEARCHPATH))))
+ifneq ($(FPCPROG),)
+FPCPROG:=$(firstword $(FPCPROG))
+FPC:=$(shell $(FPCPROG) -PB)
+ifneq ($(findstring Error,$(FPC)),)
+override FPC=ppc386
+endif
+else
+override FPC=ppc386
+endif
+endif
+override FPC:=$(subst $(SRCEXEEXT),,$(FPC))
+override FPC:=$(subst \,/,$(FPC))$(SRCEXEEXT)
+ifndef FPC_VERSION
+FPC_VERSION:=$(shell $(FPC) -iV)
+endif
+export FPC FPC_VERSION
+ifeq ($(findstring 1.0.,$(FPC_VERSION)),)
+COMPILERINFO:=$(shell $(FPC) -iSP -iTP -iSO -iTO)
+ifndef CPU_SOURCE
+CPU_SOURCE:=$(word 1,$(COMPILERINFO))
+endif
+ifndef CPU_TARGET
+CPU_TARGET:=$(word 2,$(COMPILERINFO))
+endif
+ifndef OS_SOURCE
+OS_SOURCE:=$(word 3,$(COMPILERINFO))
+endif
+ifndef OS_TARGET
+OS_TARGET:=$(word 4,$(COMPILERINFO))
+endif
+else
+ifndef CPU_SOURCE
+CPU_SOURCE:=$(shell $(FPC) -iSP)
+endif
+ifndef CPU_TARGET
+CPU_TARGET:=$(shell $(FPC) -iTP)
+endif
+ifndef OS_SOURCE
+OS_SOURCE:=$(shell $(FPC) -iSO)
+endif
+ifndef OS_TARGET
+OS_TARGET:=$(shell $(FPC) -iTO)
+endif
+endif
+FULL_TARGET=$(CPU_TARGET)-$(OS_TARGET)
+FULL_SOURCE=$(CPU_SOURCE)-$(OS_SOURCE)
+ifneq ($(FULL_TARGET),$(FULL_SOURCE))
+CROSSCOMPILE=1
+endif
+ifeq ($(findstring makefile,$(MAKECMDGOALS)),)
+ifeq ($(findstring $(OS_TARGET),$(MAKEFILETARGETS)),)
+$(error The Makefile doesn't support target $(OS_TARGET), please run fpcmake first)
+endif
+endif
+export OS_TARGET OS_SOURCE CPU_TARGET CPU_SOURCE FULL_TARGET FULL_SOURCE CROSSCOMPILE
+ifdef FPCDIR
+override FPCDIR:=$(subst \,/,$(FPCDIR))
+ifeq ($(wildcard $(addprefix $(FPCDIR)/,rtl units)),)
+override FPCDIR=wrong
+endif
+else
+override FPCDIR=wrong
+endif
+ifdef DEFAULT_FPCDIR
+ifeq ($(FPCDIR),wrong)
+override FPCDIR:=$(subst \,/,$(DEFAULT_FPCDIR))
+ifeq ($(wildcard $(addprefix $(FPCDIR)/,rtl units)),)
+override FPCDIR=wrong
+endif
+endif
+endif
+ifeq ($(FPCDIR),wrong)
+ifdef inUnix
+override FPCDIR=/usr/local/lib/fpc/$(FPC_VERSION)
+ifeq ($(wildcard $(FPCDIR)/units),)
+override FPCDIR=/usr/lib/fpc/$(FPC_VERSION)
+endif
+else
+override FPCDIR:=$(subst /$(FPC),,$(firstword $(strip $(wildcard $(addsuffix /$(FPC),$(SEARCHPATH))))))
+override FPCDIR:=$(FPCDIR)/..
+ifeq ($(wildcard $(addprefix $(FPCDIR)/,rtl units)),)
+override FPCDIR:=$(FPCDIR)/..
+ifeq ($(wildcard $(addprefix $(FPCDIR)/,rtl units)),)
+override FPCDIR=c:/pp
+endif
+endif
+endif
+endif
+ifndef CROSSDIR
+CROSSDIR:=$(FPCDIR)/cross/$(FULL_TARGET)
+endif
+ifndef CROSSTARGETDIR
+CROSSTARGETDIR=$(CROSSDIR)/$(FULL_TARGET)
+endif
+ifdef CROSSCOMPILE
+UNITSDIR:=$(wildcard $(CROSSTARGETDIR)/units)
+ifeq ($(UNITSDIR),)
+UNITSDIR:=$(wildcard $(FPCDIR)/units/$(OS_TARGET))
+endif
+else
+UNITSDIR:=$(wildcard $(FPCDIR)/units/$(OS_TARGET))
+endif
+PACKAGESDIR:=$(wildcard $(FPCDIR) $(FPCDIR)/packages/base $(FPCDIR)/packages/extra)
+override PACKAGE_NAME=mysql
+override PACKAGE_VERSION=1.0.6
+override TARGET_UNITS+=mysql_com mysql_version mysql
+override TARGET_EXAMPLES+=testdb
+override INSTALL_FPCPACKAGE=y
+ifdef REQUIRE_UNITSDIR
+override UNITSDIR+=$(REQUIRE_UNITSDIR)
+endif
+ifdef REQUIRE_PACKAGESDIR
+override PACKAGESDIR+=$(REQUIRE_PACKAGESDIR)
+endif
+ifdef ZIPINSTALL
+ifeq ($(OS_TARGET),linux)
+UNIXINSTALLDIR=1
+endif
+ifeq ($(OS_TARGET),freebsd)
+UNIXINSTALLDIR=1
+endif
+ifeq ($(OS_TARGET),netbsd)
+UNIXINSTALLDIR=1
+endif
+ifeq ($(OS_TARGET),sunos)
+UNIXINSTALLDIR=1
+endif
+else
+ifeq ($(OS_SOURCE),linux)
+UNIXINSTALLDIR=1
+endif
+ifeq ($(OS_SOURCE),freebsd)
+UNIXINSTALLDIR=1
+endif
+ifeq ($(OS_SOURCE),netbsd)
+UNIXINSTALLDIR=1
+endif
+ifeq ($(OS_TARGET),sunos)
+UNIXINSTALLDIR=1
+endif
+endif
+ifndef INSTALL_PREFIX
+ifdef PREFIX
+INSTALL_PREFIX=$(PREFIX)
+endif
+endif
+ifndef INSTALL_PREFIX
+ifdef UNIXINSTALLDIR
+INSTALL_PREFIX=/usr/local
+else
+ifdef INSTALL_FPCPACKAGE
+INSTALL_BASEDIR:=/pp
+else
+INSTALL_BASEDIR:=/$(PACKAGE_NAME)
+endif
+endif
+endif
+export INSTALL_PREFIX
+ifndef DIST_DESTDIR
+DIST_DESTDIR:=$(BASEDIR)
+endif
+export DIST_DESTDIR
+ifndef INSTALL_BASEDIR
+ifdef UNIXINSTALLDIR
+ifdef INSTALL_FPCPACKAGE
+INSTALL_BASEDIR:=$(INSTALL_PREFIX)/lib/fpc/$(FPC_VERSION)
+else
+INSTALL_BASEDIR:=$(INSTALL_PREFIX)/lib/$(PACKAGE_NAME)
+endif
+else
+INSTALL_BASEDIR:=$(INSTALL_PREFIX)
+endif
+endif
+ifndef INSTALL_BINDIR
+ifdef UNIXINSTALLDIR
+INSTALL_BINDIR:=$(INSTALL_PREFIX)/bin
+else
+INSTALL_BINDIR:=$(INSTALL_BASEDIR)/bin
+ifdef INSTALL_FPCPACKAGE
+INSTALL_BINDIR:=$(INSTALL_BINDIR)/$(OS_TARGET)
+endif
+endif
+endif
+ifndef INSTALL_UNITDIR
+ifdef CROSSCOMPILE
+INSTALL_UNITDIR:=$(INSTALL_BASEDIR)/cross/$(FULL_TARGET)/units
+else
+INSTALL_UNITDIR:=$(INSTALL_BASEDIR)/units/$(OS_TARGET)
+endif
+ifdef INSTALL_FPCPACKAGE
+ifdef PACKAGE_NAME
+INSTALL_UNITDIR:=$(INSTALL_UNITDIR)/$(PACKAGE_NAME)
+endif
+endif
+endif
+ifndef INSTALL_LIBDIR
+ifdef UNIXINSTALLDIR
+INSTALL_LIBDIR:=$(INSTALL_PREFIX)/lib
+else
+INSTALL_LIBDIR:=$(INSTALL_UNITDIR)
+endif
+endif
+ifndef INSTALL_SOURCEDIR
+ifdef UNIXINSTALLDIR
+ifdef INSTALL_FPCPACKAGE
+ifdef BSDhier
+INSTALL_SOURCEDIR:=$(INSTALL_PREFIX)/share/src/fpc-$(FPC_VERSION)/$(PACKAGE_NAME)
+else
+INSTALL_SOURCEDIR:=$(INSTALL_PREFIX)/src/fpc-$(FPC_VERSION)/$(PACKAGE_NAME)
+endif
+else
+ifdef BSDhier
+INSTALL_SOURCEDIR:=$(INSTALL_PREFIX)/share/src/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
+else
+INSTALL_SOURCEDIR:=$(INSTALL_PREFIX)/src/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
+endif
+endif
+else
+ifdef INSTALL_FPCPACKAGE
+INSTALL_SOURCEDIR:=$(INSTALL_BASEDIR)/source/$(PACKAGE_NAME)
+else
+INSTALL_SOURCEDIRL:=$(INSTALL_BASEDIR)/source
+endif
+endif
+endif
+ifndef INSTALL_DOCDIR
+ifdef UNIXINSTALLDIR
+ifdef INSTALL_FPCPACKAGE
+ifdef BSDhier
+INSTALL_DOCDIR:=$(INSTALL_PREFIX)/share/doc/fpc-$(FPC_VERSION)/$(PACKAGE_NAME)
+else
+INSTALL_DOCDIR:=$(INSTALL_PREFIX)/doc/fpc-$(FPC_VERSION)/$(PACKAGE_NAME)
+endif
+else
+ifdef BSDhier
+INSTALL_DOCDIR:=$(INSTALL_PREFIX)/share/doc/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
+else
+INSTALL_DOCDIR:=$(INSTALL_PREFIX)/doc/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
+endif
+endif
+else
+ifdef INSTALL_FPCPACKAGE
+INSTALL_DOCDIR:=$(INSTALL_BASEDIR)/doc/$(PACKAGE_NAME)
+else
+INSTALL_DOCDIR:=$(INSTALL_BASEDIR)/doc
+endif
+endif
+endif
+ifndef INSTALL_EXAMPLEDIR
+ifdef UNIXINSTALLDIR
+ifdef INSTALL_FPCPACKAGE
+ifdef BSDhier
+INSTALL_EXAMPLEDIR:=$(INSTALL_PREFIX)/share/examples/fpc-$(FPC_VERSION)/$(PACKAGE_NAME)
+else
+INSTALL_EXAMPLEDIR:=$(INSTALL_PREFIX)/doc/fpc-$(FPC_VERSION)/examples/$(PACKAGE_NAME)
+endif
+else
+ifdef BSDhier
+INSTALL_EXAMPLEDIR:=$(INSTALL_PREFIX)/share/examples/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
+else
+INSTALL_EXAMPLEDIR:=$(INSTALL_PREFIX)/doc/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
+endif
+endif
+else
+ifdef INSTALL_FPCPACKAGE
+INSTALL_EXAMPLEDIR:=$(INSTALL_BASEDIR)/examples/$(PACKAGE_NAME)
+else
+INSTALL_EXAMPLEDIR:=$(INSTALL_BASEDIR)/examples
+endif
+endif
+endif
+ifndef INSTALL_DATADIR
+INSTALL_DATADIR=$(INSTALL_BASEDIR)
+endif
+ifdef CROSSCOMPILE
+ifndef CROSSBINDIR
+CROSSBINDIR:=$(wildcard $(CROSSTARGETDIR)/bin/$(FULL_SOURCE))
+ifeq ($(CROSSBINDIR),)
+CROSSBINDIR:=$(wildcard $(INSTALL_BASEDIR)/cross/$(FULL_TARGET)/bin/$(FULL_SOURCE))
+endif
+endif
+else
+CROSSBINDIR=
+endif
+ifdef inUnix
+ifndef GCCLIBDIR
+GCCLIBDIR:=$(shell dirname `(gcc -v 2>&1)| head -n 1| awk '{ print $$4 } '`)
+endif
+ifeq ($(OS_TARGET),linux)
+ifndef OTHERLIBDIR
+OTHERLIBDIR:=$(shell grep -v "^\#" /etc/ld.so.conf | awk '{ ORS=" "; print $1 }')
+endif
+endif
+ifeq ($(OS_TARGET),netbsd)
+OTHERLIBDIR+=/usr/pkg/lib
+endif
+export GCCLIBDIR OTHERLIB
+endif
+LOADEREXT=.as
+EXEEXT=.exe
+PPLEXT=.ppl
+PPUEXT=.ppu
+OEXT=.o
+ASMEXT=.s
+SMARTEXT=.sl
+STATICLIBEXT=.a
+SHAREDLIBEXT=.so
+STATICLIBPREFIX=libp
+RSTEXT=.rst
+FPCMADE=fpcmade
+ifeq ($(OS_TARGET),go32v1)
+PPUEXT=.pp1
+OEXT=.o1
+ASMEXT=.s1
+SMARTEXT=.sl1
+STATICLIBEXT=.a1
+SHAREDLIBEXT=.so1
+STATICLIBPREFIX=
+FPCMADE=fpcmade.v1
+PACKAGESUFFIX=v1
+endif
+ifeq ($(OS_TARGET),go32v2)
+STATICLIBPREFIX=
+FPCMADE=fpcmade.dos
+ZIPSUFFIX=go32
+endif
+ifeq ($(OS_TARGET),linux)
+EXEEXT=
+HASSHAREDLIB=1
+FPCMADE=fpcmade.lnx
+ZIPSUFFIX=linux
+endif
+ifeq ($(OS_TARGET),freebsd)
+EXEEXT=
+HASSHAREDLIB=1
+FPCMADE=fpcmade.freebsd
+ZIPSUFFIX=freebsd
+endif
+ifeq ($(OS_TARGET),netbsd)
+EXEEXT=
+HASSHAREDLIB=1
+FPCMADE=fpcmade.netbsd
+ZIPSUFFIX=netbsd
+endif
+ifeq ($(OS_TARGET),win32)
+PPUEXT=.ppw
+OEXT=.ow
+ASMEXT=.sw
+SMARTEXT=.slw
+STATICLIBEXT=.aw
+SHAREDLIBEXT=.dll
+FPCMADE=fpcmade.w32
+ZIPSUFFIX=w32
+endif
+ifeq ($(OS_TARGET),os2)
+PPUEXT=.ppo
+ASMEXT=.so2
+OEXT=.oo2
+AOUTEXT=.out
+SMARTEXT=.so
+STATICLIBEXT=.ao2
+SHAREDLIBEXT=.dll
+FPCMADE=fpcmade.os2
+ZIPSUFFIX=emx
+endif
+ifeq ($(OS_TARGET),amiga)
+EXEEXT=
+PPUEXT=.ppa
+ASMEXT=.asm
+OEXT=.o
+SMARTEXT=.sl
+STATICLIBEXT=.a
+SHAREDLIBEXT=.library
+FPCMADE=fpcmade.amg
+endif
+ifeq ($(OS_TARGET),atari)
+PPUEXT=.ppt
+ASMEXT=.s
+OEXT=.o
+SMARTEXT=.sl
+STATICLIBEXT=.a
+EXEEXT=.ttp
+FPCMADE=fpcmade.ata
+endif
+ifeq ($(OS_TARGET),beos)
+PPUEXT=.ppu
+ASMEXT=.s
+OEXT=.o
+SMARTEXT=.sl
+STATICLIBEXT=.a
+EXEEXT=
+FPCMADE=fpcmade.be
+ZIPSUFFIX=be
+endif
+ifeq ($(OS_TARGET),sunos)
+PPUEXT=.ppu
+ASMEXT=.s
+OEXT=.o
+SMARTEXT=.sl
+STATICLIBEXT=.a
+EXEEXT=
+FPCMADE=fpcmade.sun
+ZIPSUFFIX=sun
+endif
+ifeq ($(OS_TARGET),qnx)
+PPUEXT=.ppu
+ASMEXT=.s
+OEXT=.o
+SMARTEXT=.sl
+STATICLIBEXT=.a
+EXEEXT=
+FPCMADE=fpcmade.qnx
+ZIPSUFFIX=qnx
+endif
+ifndef ECHO
+ECHO:=$(strip $(wildcard $(addsuffix /gecho$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(ECHO),)
+ECHO:=$(strip $(wildcard $(addsuffix /echo$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(ECHO),)
+ECHO=
+else
+ECHO:=$(firstword $(ECHO))
+endif
+else
+ECHO:=$(firstword $(ECHO))
+endif
+endif
+export ECHO
+ifndef DATE
+DATE:=$(strip $(wildcard $(addsuffix /gdate$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(DATE),)
+DATE:=$(strip $(wildcard $(addsuffix /date$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(DATE),)
+DATE=
+else
+DATE:=$(firstword $(DATE))
+endif
+else
+DATE:=$(firstword $(DATE))
+endif
+endif
+export DATE
+ifndef GINSTALL
+GINSTALL:=$(strip $(wildcard $(addsuffix /ginstall$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(GINSTALL),)
+GINSTALL:=$(strip $(wildcard $(addsuffix /install$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(GINSTALL),)
+GINSTALL=
+else
+GINSTALL:=$(firstword $(GINSTALL))
+endif
+else
+GINSTALL:=$(firstword $(GINSTALL))
+endif
+endif
+export GINSTALL
+ifndef CPPROG
+CPPROG:=$(strip $(wildcard $(addsuffix /cp$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(CPPROG),)
+CPPROG=
+else
+CPPROG:=$(firstword $(CPPROG))
+endif
+endif
+export CPPROG
+ifndef RMPROG
+RMPROG:=$(strip $(wildcard $(addsuffix /rm$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(RMPROG),)
+RMPROG=
+else
+RMPROG:=$(firstword $(RMPROG))
+endif
+endif
+export RMPROG
+ifndef MVPROG
+MVPROG:=$(strip $(wildcard $(addsuffix /mv$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(MVPROG),)
+MVPROG=
+else
+MVPROG:=$(firstword $(MVPROG))
+endif
+endif
+export MVPROG
+ifndef ECHOREDIR
+ECHOREDIR:=$(subst /,$(PATHSEP),$(ECHO))
+endif
+ifndef COPY
+COPY:=$(CPPROG) -fp
+endif
+ifndef COPYTREE
+COPYTREE:=$(CPPROG) -rfp
+endif
+ifndef MOVE
+MOVE:=$(MVPROG) -f
+endif
+ifndef DEL
+DEL:=$(RMPROG) -f
+endif
+ifndef DELTREE
+DELTREE:=$(RMPROG) -rf
+endif
+ifndef INSTALL
+ifdef inUnix
+INSTALL:=$(GINSTALL) -c -m 644
+else
+INSTALL:=$(COPY)
+endif
+endif
+ifndef INSTALLEXE
+ifdef inUnix
+INSTALLEXE:=$(GINSTALL) -c -m 755
+else
+INSTALLEXE:=$(COPY)
+endif
+endif
+ifndef MKDIR
+MKDIR:=$(GINSTALL) -m 755 -d
+endif
+export ECHOREDIR COPY COPYTREE MOVE DEL DELTREE INSTALL INSTALLEXE MKDIR
+ifndef PPUMOVE
+PPUMOVE:=$(strip $(wildcard $(addsuffix /ppumove$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(PPUMOVE),)
+PPUMOVE=
+else
+PPUMOVE:=$(firstword $(PPUMOVE))
+endif
+endif
+export PPUMOVE
+ifndef FPCMAKE
+FPCMAKE:=$(strip $(wildcard $(addsuffix /fpcmake$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(FPCMAKE),)
+FPCMAKE=
+else
+FPCMAKE:=$(firstword $(FPCMAKE))
+endif
+endif
+export FPCMAKE
+ifndef ZIPPROG
+ZIPPROG:=$(strip $(wildcard $(addsuffix /zip$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(ZIPPROG),)
+ZIPPROG=
+else
+ZIPPROG:=$(firstword $(ZIPPROG))
+endif
+endif
+export ZIPPROG
+ifndef TARPROG
+TARPROG:=$(strip $(wildcard $(addsuffix /tar$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(TARPROG),)
+TARPROG=
+else
+TARPROG:=$(firstword $(TARPROG))
+endif
+endif
+export TARPROG
+ASNAME=as
+LDNAME=ld
+ARNAME=ar
+RCNAME=rc
+ifeq ($(OS_TARGET),win32)
+ASNAME=asw
+LDNAME=ldw
+ARNAME=arw
+endif
+ifndef ASPROG
+ifdef CROSSBINDIR
+ASPROG=$(CROSSBINDIR)/$(ASNAME)$(SRCEXEEXT)
+else
+ASPROG=$(ASNAME)
+endif
+endif
+ifndef LDPROG
+ifdef CROSSBINDIR
+LDPROG=$(CROSSBINDIR)/$(LDNAME)$(SRCEXEEXT)
+else
+LDPROG=$(LDNAME)
+endif
+endif
+ifndef RCPROG
+ifdef CROSSBINDIR
+RCPROG=$(CROSSBINDIR)/$(RCNAME)$(SRCEXEEXT)
+else
+RCPROG=$(RCNAME)
+endif
+endif
+ifndef ARPROG
+ifdef CROSSBINDIR
+ARPROG=$(CROSSBINDIR)/$(ARNAME)$(SRCEXEEXT)
+else
+ARPROG=$(ARNAME)
+endif
+endif
+AS=$(ASPROG)
+LD=$(LDPROG)
+RC=$(RCPROG)
+AR=$(ARPROG)
+PPAS=ppas$(BATCHEXT)
+ifdef inUnix
+LDCONFIG=ldconfig
+else
+LDCONFIG=
+endif
+ifdef DATE
+DATESTR:=$(shell $(DATE) +%Y%m%d)
+else
+DATESTR=
+endif
+ifndef UPXPROG
+ifeq ($(OS_TARGET),go32v2)
+UPXPROG:=1
+endif
+ifeq ($(OS_TARGET),win32)
+UPXPROG:=1
+endif
+ifdef UPXPROG
+UPXPROG:=$(strip $(wildcard $(addsuffix /upx$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(UPXPROG),)
+UPXPROG=
+else
+UPXPROG:=$(firstword $(UPXPROG))
+endif
+else
+UPXPROG=
+endif
+endif
+export UPXPROG
+ZIPOPT=-9
+ZIPEXT=.zip
+ifeq ($(USETAR),bz2)
+TAROPT=vI
+TAREXT=.tar.bz2
+else
+TAROPT=vz
+TAREXT=.tar.gz
+endif
+override REQUIRE_PACKAGES=rtl 
+ifeq ($(OS_TARGET),linux)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(OS_TARGET),go32v2)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(OS_TARGET),win32)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(OS_TARGET),os2)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(OS_TARGET),freebsd)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(OS_TARGET),beos)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(OS_TARGET),netbsd)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(OS_TARGET),amiga)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(OS_TARGET),atari)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(OS_TARGET),sunos)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(OS_TARGET),qnx)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifdef REQUIRE_PACKAGES_RTL
+PACKAGEDIR_RTL:=$(firstword $(subst /Makefile.fpc,,$(strip $(wildcard $(addsuffix /rtl/$(OS_TARGET)/Makefile.fpc,$(PACKAGESDIR))))))
+ifneq ($(PACKAGEDIR_RTL),)
+ifneq ($(wildcard $(PACKAGEDIR_RTL)/$(OS_TARGET)),)
+UNITDIR_RTL=$(PACKAGEDIR_RTL)/$(OS_TARGET)
+else
+UNITDIR_RTL=$(PACKAGEDIR_RTL)
+endif
+else
+PACKAGEDIR_RTL=
+UNITDIR_RTL:=$(subst /Package.fpc,,$(strip $(wildcard $(addsuffix /rtl/Package.fpc,$(UNITSDIR)))))
+ifneq ($(UNITDIR_RTL),)
+UNITDIR_RTL:=$(firstword $(UNITDIR_RTL))
+else
+UNITDIR_RTL=
+endif
+endif
+ifdef UNITDIR_RTL
+override COMPILER_UNITDIR+=$(UNITDIR_RTL)
+endif
+endif
+ifndef NOCPUDEF
+override FPCOPTDEF=$(CPU_TARGET)
+endif
+ifneq ($(OS_TARGET),$(OS_SOURCE))
+override FPCOPT+=-T$(OS_TARGET)
+endif
+ifdef UNITDIR
+override FPCOPT+=$(addprefix -Fu,$(UNITDIR))
+endif
+ifdef LIBDIR
+override FPCOPT+=$(addprefix -Fl,$(LIBDIR))
+endif
+ifdef OBJDIR
+override FPCOPT+=$(addprefix -Fo,$(OBJDIR))
+endif
+ifdef INCDIR
+override FPCOPT+=$(addprefix -Fi,$(INCDIR))
+endif
+ifdef LINKSMART
+override FPCOPT+=-XX
+endif
+ifdef CREATESMART
+override FPCOPT+=-CX
+endif
+ifdef DEBUG
+override FPCOPT+=-gl
+override FPCOPTDEF+=DEBUG
+endif
+ifdef RELEASE
+ifeq ($(CPU_TARGET),i386)
+FPCCPUOPT:=-OG2p3
+else
+FPCCPUOPT:=
+endif
+override FPCOPT+=-Xs $(FPCCPUOPT) -n
+override FPCOPTDEF+=RELEASE
+endif
+ifdef STRIP
+override FPCOPT+=-Xs
+endif
+ifdef OPTIMIZE
+ifeq ($(CPU_TARGET),i386)
+override FPCOPT+=-OG2p3
+endif
+endif
+ifdef VERBOSE
+override FPCOPT+=-vwni
+endif
+ifdef COMPILER_OPTIONS
+override FPCOPT+=$(COMPILER_OPTIONS)
+endif
+ifdef COMPILER_UNITDIR
+override FPCOPT+=$(addprefix -Fu,$(COMPILER_UNITDIR))
+endif
+ifdef COMPILER_LIBRARYDIR
+override FPCOPT+=$(addprefix -Fl,$(COMPILER_LIBRARYDIR))
+endif
+ifdef COMPILER_OBJECTDIR
+override FPCOPT+=$(addprefix -Fo,$(COMPILER_OBJECTDIR))
+endif
+ifdef COMPILER_INCLUDEDIR
+override FPCOPT+=$(addprefix -Fi,$(COMPILER_INCLUDEDIR))
+endif
+ifdef CROSSBINDIR
+override FPCOPT+=-FD$(CROSSBINDIR)
+endif
+ifdef COMPILER_TARGETDIR
+override FPCOPT+=-FE$(COMPILER_TARGETDIR)
+ifeq ($(COMPILER_TARGETDIR),.)
+override TARGETDIRPREFIX=
+else
+override TARGETDIRPREFIX=$(COMPILER_TARGETDIR)/
+endif
+endif
+ifdef COMPILER_UNITTARGETDIR
+override FPCOPT+=-FU$(COMPILER_UNITTARGETDIR)
+ifeq ($(COMPILER_UNITTARGETDIR),.)
+override UNITTARGETDIRPREFIX=
+else
+override UNITTARGETDIRPREFIX=$(COMPILER_UNITTARGETDIR)/
+endif
+else
+ifdef COMPILER_TARGETDIR
+override COMPILER_UNITTARGETDIR=$(COMPILER_TARGETDIR)
+override UNITTARGETDIRPREFIX=$(TARGETDIRPREFIX)
+endif
+endif
+ifdef GCCLIBDIR
+override FPCOPT+=-Fl$(GCCLIBDIR)
+endif
+ifdef OTHERLIBDIR
+override FPCOPT+=$(addprefix -Fl,$(OTHERLIBDIR))
+endif
+ifdef OPT
+override FPCOPT+=$(OPT)
+endif
+ifdef FPCOPTDEF
+override FPCOPT+=$(addprefix -d,$(FPCOPTDEF))
+endif
+ifdef CFGFILE
+override FPCOPT+=@$(CFGFILE)
+endif
+ifdef USEENV
+override FPCEXTCMD:=$(FPCOPT)
+override FPCOPT:=!FPCEXTCMD
+export FPCEXTCMD
+endif
+override COMPILER:=$(FPC) $(FPCOPT)
+ifeq (,$(findstring -s ,$(COMPILER)))
+EXECPPAS=
+else
+ifeq ($(OS_SOURCE),$(OS_TARGET))
+EXECPPAS:=@$(PPAS)
+endif
+endif
+.PHONY: fpc_units
+ifdef TARGET_UNITS
+override ALLTARGET+=fpc_units
+override UNITPPUFILES=$(addsuffix $(PPUEXT),$(TARGET_UNITS))
+override IMPLICITUNITPPUFILES=$(addsuffix $(PPUEXT),$(TARGET_IMPLICITUNITS))
+override INSTALLPPUFILES+=$(UNITPPUFILES) $(IMPLICITUNITPPUFILES)
+override CLEANPPUFILES+=$(UNITPPUFILES) $(IMPLICITUNITPPUFILES)
+endif
+fpc_units: $(UNITPPUFILES)
+ifdef TARGET_RSTS
+override RSTFILES=$(addsuffix $(RSTEXT),$(TARGET_RSTS))
+override CLEANRSTFILES+=$(RSTFILES)
+endif
+.PHONY: fpc_examples
+ifdef TARGET_EXAMPLES
+HASEXAMPLES=1
+override EXAMPLESOURCEFILES:=$(wildcard $(addsuffix .pp,$(TARGET_EXAMPLES)) $(addsuffix .pas,$(TARGET_EXAMPLES)))
+override EXAMPLEFILES:=$(addsuffix $(EXEEXT),$(TARGET_EXAMPLES))
+override EXAMPLEOFILES:=$(addsuffix $(OEXT),$(TARGET_EXAMPLES)) $(addprefix $(STATICLIBPREFIX),$(addsuffix $(STATICLIBEXT),$(TARGET_EXAMPLES)))
+override CLEANEXEFILES+=$(EXAMPLEFILES) $(EXAMPLEOFILES)
+ifeq ($(OS_TARGET),os2)
+override CLEANEXEFILES+=$(addsuffix $(AOUTEXT),$(TARGET_EXAMPLES))
+endif
+endif
+ifdef TARGET_EXAMPLEDIRS
+HASEXAMPLES=1
+endif
+fpc_examples: all $(EXAMPLEFILES) $(addsuffix _all,$(TARGET_EXAMPLEDIRS))
+.PHONY: fpc_all fpc_smart fpc_debug fpc_release
+$(FPCMADE): $(ALLTARGET)
+	@$(ECHOREDIR) Compiled > $(FPCMADE)
+fpc_all: $(FPCMADE)
+fpc_smart:
+	$(MAKE) all LINKSMART=1 CREATESMART=1
+fpc_debug:
+	$(MAKE) all DEBUG=1
+fpc_release:
+	$(MAKE) all RELEASE=1
+.SUFFIXES: $(EXEEXT) $(PPUEXT) $(OEXT) .pas .pp .rc .res
+%$(PPUEXT): %.pp
+	$(COMPILER) $<
+	$(EXECPPAS)
+%$(PPUEXT): %.pas
+	$(COMPILER) $<
+	$(EXECPPAS)
+%$(EXEEXT): %.pp
+	$(COMPILER) $<
+	$(EXECPPAS)
+%$(EXEEXT): %.pas
+	$(COMPILER) $<
+	$(EXECPPAS)
+%.res: %.rc
+	windres -i $< -o $@
+vpath %.pp $(COMPILER_SOURCEDIR) $(COMPILER_INCLUDEDIR)
+vpath %.pas $(COMPILER_SOURCEDIR) $(COMPILER_INCLUDEDIR)
+vpath %$(PPUEXT) $(COMPILER_UNITTARGETDIR)
+.PHONY: fpc_install fpc_sourceinstall fpc_exampleinstall
+ifdef INSTALL_UNITS
+override INSTALLPPUFILES+=$(addsuffix $(PPUEXT),$(INSTALL_UNITS))
+endif
+ifdef INSTALL_BUILDUNIT
+override INSTALLPPUFILES:=$(filter-out $(INSTALL_BUILDUNIT),$(INSTALLPPUFILES))
+endif
+ifdef INSTALLPPUFILES
+override INSTALLPPULINKFILES:=$(subst $(PPUEXT),$(OEXT),$(INSTALLPPUFILES)) $(addprefix $(STATICLIBPREFIX),$(subst $(PPUEXT),$(STATICLIBEXT),$(INSTALLPPUFILES)))
+override INSTALLPPUFILES:=$(addprefix $(UNITTARGETDIRPREFIX),$(INSTALLPPUFILES))
+override INSTALLPPULINKFILES:=$(wildcard $(addprefix $(UNITTARGETDIRPREFIX),$(INSTALLPPULINKFILES)))
+override INSTALL_CREATEPACKAGEFPC=1
+endif
+ifdef INSTALLEXEFILES
+override INSTALLEXEFILES:=$(addprefix $(TARGETDIRPREFIX),$(INSTALLEXEFILES))
+endif
+fpc_install: all $(INSTALLTARGET)
+ifdef INSTALLEXEFILES
+	$(MKDIR) $(INSTALL_BINDIR)
+ifdef UPXPROG
+	-$(UPXPROG) $(INSTALLEXEFILES)
+endif
+	$(INSTALLEXE) $(INSTALLEXEFILES) $(INSTALL_BINDIR)
+endif
+ifdef INSTALL_CREATEPACKAGEFPC
+ifdef FPCMAKE
+ifdef PACKAGE_VERSION
+ifneq ($(wildcard Makefile.fpc),)
+	$(FPCMAKE) -p -T$(OS_TARGET) Makefile.fpc
+	$(MKDIR) $(INSTALL_UNITDIR)
+	$(INSTALL) Package.fpc $(INSTALL_UNITDIR)
+endif
+endif
+endif
+endif
+ifdef INSTALLPPUFILES
+	$(MKDIR) $(INSTALL_UNITDIR)
+	$(INSTALL) $(INSTALLPPUFILES) $(INSTALL_UNITDIR)
+ifneq ($(INSTALLPPULINKFILES),)
+	$(INSTALL) $(INSTALLPPULINKFILES) $(INSTALL_UNITDIR)
+endif
+ifneq ($(wildcard $(LIB_FULLNAME)),)
+	$(MKDIR) $(INSTALL_LIBDIR)
+	$(INSTALL) $(LIB_FULLNAME) $(INSTALL_LIBDIR)
+ifdef inUnix
+	ln -sf $(LIB_FULLNAME) $(INSTALL_LIBDIR)/$(LIB_NAME)
+endif
+endif
+endif
+ifdef INSTALL_FILES
+	$(MKDIR) $(INSTALL_DATADIR)
+	$(INSTALL) $(INSTALL_FILES) $(INSTALL_DATADIR)
+endif
+fpc_sourceinstall: distclean
+	$(MKDIR) $(INSTALL_SOURCEDIR)
+	$(COPYTREE) $(BASEDIR) $(INSTALL_SOURCEDIR)
+fpc_exampleinstall: $(addsuffix _distclean,$(TARGET_EXAMPLEDIRS))
+ifdef HASEXAMPLES
+	$(MKDIR) $(INSTALL_EXAMPLEDIR)
+endif
+ifdef EXAMPLESOURCEFILES
+	$(COPY) $(EXAMPLESOURCEFILES) $(INSTALL_EXAMPLEDIR)
+endif
+ifdef TARGET_EXAMPLEDIRS
+	$(COPYTREE) $(addsuffix /*,$(TARGET_EXAMPLEDIRS)) $(INSTALL_EXAMPLEDIR)
+endif
+.PHONY: fpc_distinstall
+fpc_distinstall: install exampleinstall
+.PHONY: fpc_zipinstall fpc_zipsourceinstall fpc_zipexampleinstall
+ifndef PACKDIR
+ifndef inUnix
+PACKDIR=$(BASEDIR)/../fpc-pack
+else
+PACKDIR=/tmp/fpc-pack
+endif
+endif
+ifndef ZIPNAME
+ifdef DIST_ZIPNAME
+ZIPNAME=$(DIST_ZIPNAME)
+else
+ZIPNAME=$(ZIPPREFIX)$(PACKAGE_NAME)$(ZIPSUFFIX)
+endif
+endif
+ifndef ZIPTARGET
+ifdef DIST_ZIPTARGET
+ZIPTARGET=DIST_ZIPTARGET
+else
+ZIPTARGET=install
+endif
+endif
+ifndef USEZIP
+ifdef inUnix
+USETAR=1
+endif
+endif
+ifndef inUnix
+USEZIPWRAPPER=1
+endif
+ifdef USEZIPWRAPPER
+ZIPPATHSEP=$(PATHSEP)
+ZIPWRAPPER=$(subst /,$(PATHSEP),$(DIST_DESTDIR)/fpczip$(BATCHEXT))
+else
+ZIPPATHSEP=/
+endif
+ZIPCMD_CDPACK:=cd $(subst /,$(ZIPPATHSEP),$(PACKDIR))
+ZIPCMD_CDBASE:=cd $(subst /,$(ZIPPATHSEP),$(BASEDIR))
+ifdef USETAR
+ZIPDESTFILE:=$(DIST_DESTDIR)/$(ZIPNAME)$(TAREXT)
+ZIPCMD_ZIP:=$(TARPROG) cf$(TAROPT) $(ZIPDESTFILE) *
+else
+ZIPDESTFILE:=$(DIST_DESTDIR)/$(ZIPNAME)$(ZIPEXT)
+ZIPCMD_ZIP:=$(subst /,$(ZIPPATHSEP),$(ZIPPROG)) -Dr $(ZIPOPT) $(ZIPDESTFILE) *
+endif
+fpc_zipinstall:
+	$(MAKE) $(ZIPTARGET) INSTALL_PREFIX=$(PACKDIR) ZIPINSTALL=1
+	$(MKDIR) $(DIST_DESTDIR)
+	$(DEL) $(ZIPDESTFILE)
+ifdef USEZIPWRAPPER
+ifneq ($(ECHOREDIR),echo)
+	$(ECHOREDIR) -e "$(subst \,\\,$(ZIPCMD_CDPACK))" > $(ZIPWRAPPER)
+	$(ECHOREDIR) -e "$(subst \,\\,$(ZIPCMD_ZIP))" >> $(ZIPWRAPPER)
+	$(ECHOREDIR) -e "$(subst \,\\,$(ZIPCMD_CDBASE))" >> $(ZIPWRAPPER)
+else
+	echo $(ZIPCMD_CDPACK) > $(ZIPWRAPPER)
+	echo $(ZIPCMD_ZIP) >> $(ZIPWRAPPER)
+	echo $(ZIPCMD_CDBASE) >> $(ZIPWRAPPER)
+endif
+ifdef inUnix
+	/bin/sh $(ZIPWRAPPER)
+else
+	$(ZIPWRAPPER)
+endif
+	$(DEL) $(ZIPWRAPPER)
+else
+	$(ZIPCMD_CDPACK) ; $(ZIPCMD_ZIP) ; $(ZIPCMD_CDBASE)
+endif
+	$(DELTREE) $(PACKDIR)
+fpc_zipsourceinstall:
+	$(MAKE) fpc_zipinstall ZIPTARGET=sourceinstall ZIPSUFFIX=src
+fpc_zipexampleinstall:
+ifdef HASEXAMPLES
+	$(MAKE) fpc_zipinstall ZIPTARGET=exampleinstall ZIPSUFFIX=exm
+endif
+fpc_zipdistinstall:
+	$(MAKE) fpc_zipinstall ZIPTARGET=distinstall
+.PHONY: fpc_clean fpc_cleanall fpc_distclean
+ifdef EXEFILES
+override CLEANEXEFILES:=$(addprefix $(TARGETDIRPREFIX),$(CLEANEXEFILES))
+endif
+ifdef CLEAN_UNITS
+override CLEANPPUFILES+=$(addsuffix $(PPUEXT),$(CLEAN_UNITS))
+endif
+ifdef CLEANPPUFILES
+override CLEANPPULINKFILES:=$(subst $(PPUEXT),$(OEXT),$(CLEANPPUFILES)) $(addprefix $(STATICLIBPREFIX),$(subst $(PPUEXT),$(STATICLIBEXT),$(CLEANPPUFILES)))
+override CLEANPPUFILES:=$(addprefix $(UNITTARGETDIRPREFIX),$(CLEANPPUFILES))
+override CLEANPPULINKFILES:=$(wildcard $(addprefix $(UNITTARGETDIRPREFIX),$(CLEANPPULINKFILES)))
+endif
+fpc_clean: $(CLEANTARGET)
+ifdef CLEANEXEFILES
+	-$(DEL) $(CLEANEXEFILES)
+endif
+ifdef CLEANPPUFILES
+	-$(DEL) $(CLEANPPUFILES)
+endif
+ifneq ($(CLEANPPULINKFILES),)
+	-$(DEL) $(CLEANPPULINKFILES)
+endif
+ifdef CLEANRSTFILES
+	-$(DEL) $(addprefix $(UNITTARGETDIRPREFIX),$(CLEANRSTFILES))
+endif
+ifdef CLEAN_FILES
+	-$(DEL) $(CLEAN_FILES)
+endif
+ifdef LIB_NAME
+	-$(DEL) $(LIB_NAME) $(LIB_FULLNAME)
+endif
+	-$(DEL) $(FPCMADE) Package.fpc $(PPAS) script.res link.res $(FPCEXTFILE) $(REDIRFILE)
+fpc_distclean: clean
+ifdef COMPILER_UNITTARGETDIR
+TARGETDIRCLEAN=fpc_clean
+endif
+fpc_cleanall: $(CLEANTARGET) $(TARGETDIRCLEAN)
+ifdef CLEANEXEFILES
+	-$(DEL) $(CLEANEXEFILES)
+endif
+	-$(DEL) *$(OEXT) *$(PPUEXT) *$(RSTEXT) *$(ASMEXT) *$(STATICLIBEXT) *$(SHAREDLIBEXT) *$(PPLEXT)
+	-$(DELTREE) *$(SMARTEXT)
+	-$(DEL) $(FPCMADE) Package.fpc $(PPAS) script.res link.res $(FPCEXTFILE) $(REDIRFILE)
+ifdef AOUTEXT
+	-$(DEL) *$(AOUTEXT)
+endif
+.PHONY: fpc_baseinfo
+override INFORULES+=fpc_baseinfo
+fpc_baseinfo:
+	@$(ECHO)
+	@$(ECHO)  == Package info ==
+	@$(ECHO)  Package Name..... $(PACKAGE_NAME)
+	@$(ECHO)  Package Version.. $(PACKAGE_VERSION)
+	@$(ECHO)
+	@$(ECHO)  == Configuration info ==
+	@$(ECHO)
+	@$(ECHO)  FPC.......... $(FPC)
+	@$(ECHO)  FPC Version.. $(FPC_VERSION)
+	@$(ECHO)  Source CPU... $(CPU_SOURCE)
+	@$(ECHO)  Target CPU... $(CPU_TARGET)
+	@$(ECHO)  Source OS.... $(OS_SOURCE)
+	@$(ECHO)  Target OS.... $(OS_TARGET)
+	@$(ECHO)  Full Target.. $(FULL_SOURCE)
+	@$(ECHO)  Full Source.. $(FULL_TARGET)
+	@$(ECHO)
+	@$(ECHO)  == Directory info ==
+	@$(ECHO)
+	@$(ECHO)  Required pkgs... $(REQUIRE_PACKAGES)
+	@$(ECHO)
+	@$(ECHO)  Basedir......... $(BASEDIR)
+	@$(ECHO)  FPCDir.......... $(FPCDIR)
+	@$(ECHO)  CrossBinDir..... $(CROSSBINDIR)
+	@$(ECHO)  UnitsDir........ $(UNITSDIR)
+	@$(ECHO)  PackagesDir..... $(PACKAGESDIR)
+	@$(ECHO)
+	@$(ECHO)  GCC library..... $(GCCLIBDIR)
+	@$(ECHO)  Other library... $(OTHERLIBDIR)
+	@$(ECHO)
+	@$(ECHO)  == Tools info ==
+	@$(ECHO)
+	@$(ECHO)  As........ $(AS)
+	@$(ECHO)  Ld........ $(LD)
+	@$(ECHO)  Ar........ $(AR)
+	@$(ECHO)  Rc........ $(RC)
+	@$(ECHO)
+	@$(ECHO)  Mv........ $(MVPROG)
+	@$(ECHO)  Cp........ $(CPPROG)
+	@$(ECHO)  Rm........ $(RMPROG)
+	@$(ECHO)  GInstall.. $(GINSTALL)
+	@$(ECHO)  Echo...... $(ECHO)
+	@$(ECHO)  Date...... $(DATE)
+	@$(ECHO)  FPCMake... $(FPCMAKE)
+	@$(ECHO)  PPUMove... $(PPUMOVE)
+	@$(ECHO)  Upx....... $(UPXPROG)
+	@$(ECHO)  Zip....... $(ZIPPROG)
+	@$(ECHO)
+	@$(ECHO)  == Object info ==
+	@$(ECHO)
+	@$(ECHO)  Target Loaders........ $(TARGET_LOADERS)
+	@$(ECHO)  Target Units.......... $(TARGET_UNITS)
+	@$(ECHO)  Target Implicit Units. $(TARGET_IMPLICITUNITS)
+	@$(ECHO)  Target Programs....... $(TARGET_PROGRAMS)
+	@$(ECHO)  Target Dirs........... $(TARGET_DIRS)
+	@$(ECHO)  Target Examples....... $(TARGET_EXAMPLES)
+	@$(ECHO)  Target ExampleDirs.... $(TARGET_EXAMPLEDIRS)
+	@$(ECHO)
+	@$(ECHO)  Clean Units......... $(CLEAN_UNITS)
+	@$(ECHO)  Clean Files......... $(CLEAN_FILES)
+	@$(ECHO)
+	@$(ECHO)  Install Units....... $(INSTALL_UNITS)
+	@$(ECHO)  Install Files....... $(INSTALL_FILES)
+	@$(ECHO)
+	@$(ECHO)  == Install info ==
+	@$(ECHO)
+	@$(ECHO)  DateStr.............. $(DATESTR)
+	@$(ECHO)  ZipPrefix............ $(ZIPPREFIX)
+	@$(ECHO)  ZipSuffix............ $(ZIPSUFFIX)
+	@$(ECHO)  Install FPC Package.. $(INSTALL_FPCPACKAGE)
+	@$(ECHO)
+	@$(ECHO)  Install base dir..... $(INSTALL_BASEDIR)
+	@$(ECHO)  Install binary dir... $(INSTALL_BINDIR)
+	@$(ECHO)  Install library dir.. $(INSTALL_LIBDIR)
+	@$(ECHO)  Install units dir.... $(INSTALL_UNITDIR)
+	@$(ECHO)  Install source dir... $(INSTALL_SOURCEDIR)
+	@$(ECHO)  Install doc dir...... $(INSTALL_DOCDIR)
+	@$(ECHO)  Install example dir.. $(INSTALL_EXAMPLEDIR)
+	@$(ECHO)  Install data dir..... $(INSTALL_DATADIR)
+	@$(ECHO)
+	@$(ECHO)  Dist destination dir. $(DIST_DESTDIR)
+	@$(ECHO)  Dist zip name........ $(DIST_ZIPNAME)
+	@$(ECHO)
+.PHONY: fpc_info
+fpc_info: $(INFORULES)
+.PHONY: fpc_makefile fpc_makefiles fpc_makefile_sub1 fpc_makefile_sub2 \
+	fpc_makefile_dirs
+fpc_makefile:
+	$(FPCMAKE) -w -T$(OS_TARGET) Makefile.fpc
+fpc_makefile_sub1:
+ifdef TARGET_DIRS
+	$(FPCMAKE) -w -T$(OS_TARGET) $(addsuffix /Makefile.fpc,$(TARGET_DIRS))
+endif
+ifdef TARGET_EXAMPLEDIRS
+	$(FPCMAKE) -w -T$(OS_TARGET) $(addsuffix /Makefile.fpc,$(TARGET_EXAMPLEDIRS))
+endif
+fpc_makefile_sub2: $(addsuffix _makefile_dirs,$(TARGET_DIRS) $(TARGET_EXAMPLEDIRS))
+fpc_makefile_dirs: fpc_makefile_sub1 fpc_makefile_sub2
+fpc_makefiles: fpc_makefile fpc_makefile_dirs
+all: fpc_all
+debug: fpc_debug
+smart: fpc_smart
+release: fpc_release
+examples: fpc_examples
+shared:
+install: fpc_install
+sourceinstall: fpc_sourceinstall
+exampleinstall: fpc_exampleinstall
+distinstall: fpc_distinstall
+zipinstall: fpc_zipinstall
+zipsourceinstall: fpc_zipsourceinstall
+zipexampleinstall: fpc_zipexampleinstall
+zipdistinstall: fpc_zipdistinstall
+clean: fpc_clean
+distclean: fpc_distclean
+cleanall: fpc_cleanall
+info: fpc_info
+makefiles: fpc_makefiles
+.PHONY: all debug smart release examples shared install sourceinstall exampleinstall distinstall zipinstall zipsourceinstall zipexampleinstall zipdistinstall clean distclean cleanall info makefiles
+ifneq ($(wildcard fpcmake.loc),)
+include fpcmake.loc
+endif

+ 20 - 0
packages/base/mysql/Makefile.fpc

@@ -0,0 +1,20 @@
+#
+#   Makefile.fpc for MySql bindings
+#
+
+[package]
+name=mysql
+version=1.0.6
+
+[target]
+units=mysql_com mysql_version mysql
+examples=testdb
+
+[require]
+libc=y
+
+[install]
+fpcpackage=y
+
+[default]
+fpcdir=../../..

+ 30 - 0
packages/base/mysql/README

@@ -0,0 +1,30 @@
+This is the MySQL interface of Free Pascal.
+
+You need at least compiler version 0.99.8 to compile this.
+
+To Compile under Linux
+- You must know where the mysql libraries are.
+- You must know where libgcc is.
+
+Both these things must be set in the Makefile. After that a simple 'make'
+and 'make install' should compile and install everything.
+
+You can test with 'make test', but this supposes that there is a 'testdb'
+database available. If not, you must run
+  mkdb databasename
+  testdb databasename
+  rmdb databasename
+manually. You need create permission on the database for this to work.
+
+Redhat 5.1 and later users: You must ADD to the path the location of the
+libc5 libraries. It will NOT work with glibc 6. I hope to fix this in the
+future.
+
+Win32 users: There are multiple .dll files circulating around. 
+you should fix the statement
+mysqllib = 'libmysql'
+in the mysql unit, so it matches the version you have.
+
+Enjoy !
+
+Michael.

+ 28 - 0
packages/base/mysql/mkdb

@@ -0,0 +1,28 @@
+#!/bin/sh
+#
+# Script to create a table 'FPdev' and to fill it with data.
+# The script accepts an optional argument : 
+# A database to connect to. (default 'testdb')
+echo -n "Creating and filling table FPdev in database ${1-testdb}..."
+mysql ${1-testdb} << EOF >/dev/null
+create table FPdev ( 
+id INT NOT NULL,
+UserName CHAR(255),
+InstEmail CHAR(255),
+PRIMARY KEY (id),
+INDEX (id) );
+insert into FPdev values ('1','Michael Van Canneyt','[email protected]');
+insert into FPdev values ('2','Florian Klaempfl','[email protected]');
+insert into FPdev values ('3','Carl-Eric Codere','[email protected]');
+insert into FPdev values ('4','Daniel Mantione','[email protected]');
+insert into FPdev values ('5','Pierre Muller','[email protected]');
+insert into FPdev values ('6','Jonas Maebe','[email protected]');
+insert into FPdev values ('7','Peter Vreman','[email protected]');
+insert into FPdev values ('8','Gerry Dubois','[email protected]');
+EOF
+if [ ! $? = 0 ]; then
+  echo "Failed."
+else
+  echo "Done."
+fi
+# Ready

+ 340 - 0
packages/base/mysql/mysql.pp

@@ -0,0 +1,340 @@
+{ $Id$ }
+
+unit mysql;
+
+{
+  Import unit for the mysql header files.
+  Translated form the original mysql.h by Michael Van Canneyt
+  ([email protected])
+  
+}
+
+interface
+
+uses mysql_com;
+{$ifdef win32}
+Const mysqllib = 'libmysql';
+{$else}
+Const mysqllib = 'mysqlclient';
+{$endif}
+
+{$ifndef win32}
+{$linklib c}
+{$linklib m}
+{$endif}
+
+{ All is 4-byte aligned on my machine. }
+{$packrecords 4}
+
+type 
+   my_bool = byte;
+   gptr   = pchar;
+   Socket = Longint;
+   PCardinal = ^Cardinal;    
+
+{$ifdef Unix}    
+Var
+  mysql_port : cardinal; external name 'mysql_port';
+  mysql_unix_port : pchar; external name 'mysql_unix_port';
+{$endif}
+
+{
+#define IS_PRI_KEY(n)	((n) & PRI_KEY_FLAG)
+#define IS_NOT_NULL(n)	((n) & NOT_NULL_FLAG)
+#define IS_BLOB(n)	((n) & BLOB_FLAG)
+#define IS_NUM(t)	((t) <= FIELD_TYPE_INT24)
+}
+Type
+st_mysql_field = record 
+  name : Pchar;			{ Name of column }
+  table : pchar;		{ Table of column if column was a field }
+  def: pchar;			{ Default value (set by mysql_list_fields) }
+  ftype : enum_field_types;	{ Type of field. See mysql_com.h for types }
+  length : cardinal;		{ Width of column }
+  max_length : cardinal;	{ Max width of selected set }
+  flags : cardinal;		{ Div flags }
+  decimals : cardinal;	{ Number of decimals in field }
+end;
+TMYSQL_FIELD = st_mysql_field;
+PMYSQL_FIELD = ^TMYSQL_FIELD;
+
+TMYSQL_ROW = PPchar;		 { return data as array of strings }
+TMYSQL_FIELD_OFFSET = cardinal;  { offset to current field }
+
+{$ifndef oldmysql}
+  my_ulonglong=qword;
+{$else}
+  my_longlong=cardinal;
+{$endif}
+
+PST_MYSQL_Rows = ^st_mysql_rows;
+st_mysql_rows = Record
+  next : pst_mysql_rows;		{ list of rows }
+  Data : TMYSQL_ROW;
+end;
+TMYSQL_ROWS = st_mysql_rows;
+PMYSQL_ROWS = ^TMYSQL_ROWS;
+
+
+TMYSQL_ROW_OFFSET = PMYSQL_ROWS;	{ offset to current row }
+
+st_mysql_data  = record
+  rows   : my_ulonglong; 
+  fields : cardinal;
+  data : PMYSQL_ROWS;
+  alloc : TMEM_ROOT;
+end;
+
+TMYSQL_DATA = st_mysql_data;
+PMYSQL_DATA = ^TMYSQL_DATA;
+
+st_mysql_options = record 
+  connect_timeout,client_flag : cardinal;
+  compress,named_pipe : my_bool;
+  port : cardinal;
+  host,init_command,user,password,unix_socket,db : pchar;
+  my_cnf_file,my_cnf_group : pchar;
+end;  
+
+mysql_status = (MYSQL_STATUS_READY,
+                MYSQL_STATUS_GET_RESULT,
+                MYSQL_STATUS_USE_RESULT);
+
+
+st_mysql = Record
+  NET : TNET;			{ Communication parameters }
+  host,user,passwd,unix_socket,server_version,host_info,
+  info,db : pchar;
+  port,client_flag,server_capabilities : cardinal;
+  protocol_version : cardinal;
+  field_count : cardinal;
+  thread_id : cardinal;		{ Id for connection in server }
+  affected_rows : my_ulonglong;
+  insert_id : my_ulonglong;		{ id if insert on table with NEXTNR }
+  extra_info : my_ulonglong;    	{ Used by mysqlshow }
+  packet_length : cardinal; 
+  status : mysql_status;
+  fields : PMYSQL_FIELD;
+  field_alloc : TMEM_ROOT;
+  free_me : my_bool;		{ If free in mysql_close }
+  reconnect : my_bool;		{ set to 1 if automatic reconnect }
+  options : st_mysql_options;   
+end;
+TMYSQL = st_mysql;
+PMYSQL = ^TMYSQL;
+
+
+st_mysql_res = record
+  row_count : my_ulonglong; 
+  field_count, current_field : cardinal;
+  fields :         PMYSQL_FIELD;
+  data :           PMYSQL_DATA;
+  data_cursor :    PMYSQL_ROWS;
+  field_alloc :    TMEM_ROOT;
+  row :            TMYSQL_ROW;			{ If unbuffered read }
+  current_row :    TMYSQL_ROW;		{ buffer to current row }
+  lengths :        pcardinal;		{ column lengths of current row }
+  handle :         PMYSQL;		{ for unbuffered reads }
+  eof :            my_bool;			{ Used my mysql_fetch_row }
+end;
+TMYSQL_RES  = st_mysql_res;
+PMYSQL_RES  = ^TMYSQL_RES;
+
+
+{ Translated Macros }
+
+Function mysql_num_rows (res : PMYSQL_RES) : my_ulonglong;
+Function mysql_num_fields(res : PMYSQL_RES) : Cardinal;
+Function mysql_eof(res : PMYSQL_RES) : my_bool; 
+Function mysql_fetch_field_direct(res : PMYSQL_RES; fieldnr : Cardinal) : TMYSQL_FIELD; 
+Function mysql_fetch_fields(res : PMYSQL_RES) : PMYSQL_FIELD; 
+Function mysql_row_tell(res : PMYSQL_RES) : PMYSQL_ROWS;
+Function mysql_field_tell(res : PMYSQL_RES) : Cardinal;
+Function mysql_affected_rows(mysql : PMYSQL): my_ulonglong;  
+Function mysql_insert_id(mysql : PMYSQL): my_ulonglong;  
+Function mysql_errno(mysql : PMYSQL) : Cardinal;
+Function mysql_info(mysql : PMYSQL): Pchar;
+Function mysql_reload(mysql : PMYSQL) : Longint; 
+Function mysql_thread_id(mysql : PMYSQL) : Cardinal; 
+Function mysql_error(mysql : PMYSQL) : pchar; 
+
+{ Original functions }
+
+Function mysql_connect (mysql : PMYSQL; host,user,passwd: pchar) : PMYSQL; {$ifdef win32} stdcall {$else} cdecl {$endif};
+Function mysql_real_connect (mysql : PMYSQL; const host,user,passwd : pchar;
+				   port : cardinal;
+				   unix_socket : pchar;
+				   clientflag : cardinal) : PMYSQL;{$ifdef win32} stdcall {$else} cdecl {$endif};
+				   
+Function mysql_close(sock : PMYSQL) : longint; {$ifdef win32} stdcall {$else} cdecl {$endif};
+Function mysql_select_db(MYSQL : PMYSQL; db : Pchar) : longint; {$ifdef win32} stdcall {$else} cdecl {$endif};
+Function mysql_query(mysql : PMYSQL; q : pchar) : longint; {$ifdef win32} stdcall {$else} cdecl {$endif};
+Function mysql_real_query(mysql : PMYSQL; q : Pchar; length : longint) : longint; {$ifdef win32} stdcall {$else} cdecl {$endif};
+Function mysql_create_db(mysql : PMYSQL; db : pchar) : longint; {$ifdef win32} stdcall {$else} cdecl {$endif};
+Function mysql_drop_db(mysql : PMYSQL; DB : Pchar) : longint; {$ifdef win32} stdcall {$else} cdecl {$endif};
+Function mysql_shutdown(mysql : PMYSQL) : longint; {$ifdef win32} stdcall {$else} cdecl {$endif};
+Function mysql_dump_debug_info(mysql : PMYSQL) : longint; {$ifdef win32} stdcall {$else} cdecl {$endif};
+Function mysql_refresh(mysql : PMYSQL; refresh_options : cardinal) : longint; {$ifdef win32} stdcall {$else} cdecl {$endif};
+Function mysql_kill(mysql : PMYSQL; pid : Cardinal) : longint; {$ifdef win32} stdcall {$else} cdecl {$endif};
+Function mysql_stat(mysql : PMYSQL) : Pchar; {$ifdef win32} stdcall {$else} cdecl {$endif};
+Function mysql_get_server_info(mysql : PMYSQL) : pchar; {$ifdef win32} stdcall {$else} cdecl {$endif};
+Function mysql_get_client_info : pchar; {$ifdef win32} stdcall {$else} cdecl {$endif};
+Function mysql_get_host_info(mysql : PMYSQL) : pchar; {$ifdef win32} stdcall {$else} cdecl {$endif};
+Function mysql_get_proto_info(mysql : PMYSQL) : Cardinal; {$ifdef win32} stdcall {$else} cdecl {$endif};
+Function mysql_list_dbs(mysql : PMYSQL;wild : Pchar) : PMYSQL_RES; {$ifdef win32} stdcall {$else} cdecl {$endif};
+Function  mysql_list_tables(mysql : PMYSQL;Wild : Pchar) : PMYSQL_RES; {$ifdef win32} stdcall {$else} cdecl {$endif};
+Function  mysql_list_fields(mysql : PMYSQL; table,wild : pchar) : PMYSQL_RES; {$ifdef win32} stdcall {$else} cdecl {$endif};
+Function  mysql_list_processes(mysql : PMYSQL) : PMYSQL_RES; {$ifdef win32} stdcall {$else} cdecl {$endif};
+Function  mysql_store_result(mysql : PMYSQL) : PMYSQL_RES; {$ifdef win32} stdcall {$else} cdecl {$endif};
+Function  mysql_use_result(mysql : PMYSQL) : PMYSQL_RES; {$ifdef win32} stdcall {$else} cdecl {$endif};
+Procedure mysql_free_result(res : PMYSQL_RES);{$ifdef win32} stdcall {$else} cdecl {$endif};
+Procedure mysql_data_seek(mysql : PMYSQL_RES; offs : cardinal);{$ifdef win32} stdcall {$else} cdecl {$endif};
+Function mysql_row_seek(mysql : PMYSQL_RES; Offs: TMYSQL_ROW_OFFSET): TMYSQL_ROW_OFFSET; {$ifdef win32} stdcall {$else} cdecl {$endif};
+Function mysql_field_seek(musql : PMYSQL_RES;offs : TMYSQL_FIELD_OFFSET): TMYSQL_FIELD_OFFSET; {$ifdef win32} stdcall {$else} cdecl {$endif};
+Function mysql_fetch_row(mysql : PMYSQL_RES) : TMYSQL_ROW; {$ifdef win32} stdcall {$else} cdecl {$endif};
+Function mysql_fetch_lengths(mysql : PMYSQL_RES) : PCardinal; {$ifdef win32} stdcall {$else} cdecl {$endif};
+Function mysql_fetch_field(handle : PMYSQL_RES) : PMYSQL_FIELD; {$ifdef win32} stdcall {$else} cdecl {$endif};
+Function mysql_escape_string(escto,escfrom : pchar; length : Cardinal) : cardinal; {$ifdef win32} stdcall {$else} cdecl {$endif};
+Procedure mysql_debug(debug : pchar);{$ifdef win32} stdcall {$else} cdecl {$endif};
+
+implementation
+
+
+function mysql_connect (mysql : PMYSQL; host,user,passwd: pchar) : PMYSQL;{$ifdef win32} stdcall {$else} cdecl {$endif}; external mysqllib name 'mysql_connect';
+function mysql_real_connect (mysql : PMYSQL; const host,user,passwd : pchar;
+				   port : cardinal;
+				   unix_socket : pchar;
+				   clientflag : cardinal) : PMYSQL;{$ifdef win32} stdcall {$else} cdecl {$endif}; external mysqllib;
+				   
+function mysql_close(sock : PMYSQL) : longint ;{$ifdef win32} stdcall {$else} cdecl {$endif}; external mysqllib name 'mysql_close';
+function mysql_select_db(MYSQL : PMYSQL; db : Pchar) : longint;{$ifdef win32} stdcall {$else} cdecl {$endif}; external mysqllib name 'mysql_select_db';
+function mysql_query(mysql : PMYSQL; q : pchar) : longint;{$ifdef win32} stdcall {$else} cdecl {$endif}; external mysqllib name 'mysql_query';
+function mysql_real_query(mysql : PMYSQL; q : Pchar; length : longint) : longint;{$ifdef win32} stdcall {$else} cdecl {$endif}; external mysqllib name 'mysql_real_query';
+function mysql_create_db(mysql : PMYSQL; db : pchar) : longint;{$ifdef win32} stdcall {$else} cdecl {$endif}; external mysqllib name 'mysql_create_db';
+Function mysql_drop_db(mysql : PMYSQL; DB : Pchar) : longint;{$ifdef win32} stdcall {$else} cdecl {$endif}; external mysqllib name 'mysql_drop_db';
+Function mysql_shutdown(mysql : PMYSQL) : longint;{$ifdef win32} stdcall {$else} cdecl {$endif}; external mysqllib name 'mysql_shutdown';
+Function mysql_dump_debug_info(mysql : PMYSQL) : longint;{$ifdef win32} stdcall {$else} cdecl {$endif}; external mysqllib name 'mysql_dump_debug_info';
+Function mysql_refresh(mysql : PMYSQL; refresh_options : cardinal) : longint;{$ifdef win32} stdcall {$else} cdecl {$endif}; external mysqllib name 'mysql_refresh';
+Function mysql_kill(mysql : PMYSQL; pid : Cardinal) : longint;{$ifdef win32} stdcall {$else} cdecl {$endif}; external mysqllib name 'mysql_kill';
+Function mysql_stat(mysql : PMYSQL) : Pchar;{$ifdef win32} stdcall {$else} cdecl {$endif}; external mysqllib name 'mysql_stat';
+Function mysql_get_server_info(mysql : PMYSQL) : pchar;{$ifdef win32} stdcall {$else} cdecl {$endif}; external mysqllib name 'mysql_get_server_info';
+Function mysql_get_client_info : pchar;{$ifdef win32} stdcall {$else} cdecl {$endif}; external mysqllib;
+Function mysql_get_host_info(mysql : PMYSQL) : pchar;{$ifdef win32} stdcall {$else} cdecl {$endif}; external mysqllib name 'mysql_get_host_info';
+Function mysql_get_proto_info(mysql : PMYSQL) : Cardinal;{$ifdef win32} stdcall {$else} cdecl {$endif}; external mysqllib name 'mysql_get_proto_info';
+Function mysql_list_dbs(mysql : PMYSQL;wild : Pchar) : PMYSQL_RES;{$ifdef win32} stdcall {$else} cdecl {$endif}; external mysqllib name 'mysql_list_dbs';
+Function mysql_list_tables(mysql : PMYSQL;Wild : Pchar) : PMYSQL_RES;{$ifdef win32} stdcall {$else} cdecl {$endif}; external mysqllib name 'mysql_list_tables';
+Function mysql_list_fields(mysql : PMYSQL; table,wild : pchar) : PMYSQL_RES;{$ifdef win32} stdcall {$else} cdecl {$endif}; external mysqllib name 'mysql_list_fields';
+Function mysql_list_processes(mysql : PMYSQL) : PMYSQL_RES;{$ifdef win32} stdcall {$else} cdecl {$endif}; external mysqllib name 'mysql_list_processes';
+Function mysql_store_result(mysql : PMYSQL) : PMYSQL_RES;{$ifdef win32} stdcall {$else} cdecl {$endif}; external mysqllib name 'mysql_store_result';
+Function mysql_use_result(mysql : PMYSQL) : PMYSQL_RES;{$ifdef win32} stdcall {$else} cdecl {$endif}; external mysqllib name 'mysql_use_result';
+Procedure mysql_free_result(res : PMYSQL_RES);{$ifdef win32} stdcall {$else} cdecl {$endif}; external mysqllib name 'mysql_free_result';
+Procedure mysql_data_seek(mysql : PMYSQL_RES; offs : cardinal);{$ifdef win32} stdcall {$else} cdecl {$endif}; external mysqllib name 'mysql_data_seek';
+Function mysql_row_seek(mysql : PMYSQL_RES; Offs: TMYSQL_ROW_OFFSET): TMYSQL_ROW_OFFSET;{$ifdef win32} stdcall {$else} cdecl {$endif}; external mysqllib name 'mysql_row_seek';
+Function mysql_field_seek(musql : PMYSQL_RES;offs : TMYSQL_FIELD_OFFSET): TMYSQL_FIELD_OFFSET;{$ifdef win32} stdcall {$else} cdecl {$endif}; external mysqllib name 'mysql_field_seek';
+function mysql_fetch_row(mysql : PMYSQL_RES) : TMYSQL_ROW;{$ifdef win32} stdcall {$else} cdecl {$endif}; external mysqllib name 'mysql_fetch_row';
+function mysql_fetch_lengths(mysql : PMYSQL_RES) : PCardinal;{$ifdef win32} stdcall {$else} cdecl {$endif}; external mysqllib name 'mysql_fetch_lengths';
+function mysql_fetch_field(handle : PMYSQL_RES) : PMYSQL_FIELD;{$ifdef win32} stdcall {$else} cdecl {$endif}; external mysqllib name 'mysql_fetch_field';
+Function mysql_escape_string(escto,escfrom : pchar; length : Cardinal) : cardinal;{$ifdef win32} stdcall {$else} cdecl {$endif}; external mysqllib name 'mysql_escape_string';
+Procedure mysql_debug(debug : pchar);{$ifdef win32} stdcall {$else} cdecl {$endif}; external mysqllib name 'mysql_debug';
+
+Function  mysql_error(mysql : PMYSQL) : pchar;
+
+begin
+ mysql_error:=mysql^.net.last_error
+end;
+
+Function mysql_num_rows (res : PMYSQL_RES) : my_ulonglong;  
+
+begin
+  mysql_num_rows:=res^.row_count
+end;
+
+Function mysql_num_fields(res : PMYSQL_RES) : Cardinal;
+
+begin
+  mysql_num_fields:=res^.field_count
+end;
+
+Function mysql_eof(res : PMYSQL_RES) : my_bool;
+
+begin
+  mysql_eof:=res^.eof
+end;
+
+Function mysql_fetch_field_direct(res : PMYSQL_RES; fieldnr : Cardinal) : TMYSQL_FIELD;
+
+begin
+  mysql_fetch_field_direct:=res^.fields[fieldnr];
+end;
+
+Function mysql_fetch_fields(res : PMYSQL_RES) : PMYSQL_FIELD;
+
+begin
+ mysql_fetch_fields:=res^.fields
+end;
+
+Function mysql_row_tell(res : PMYSQL_RES) : PMYSQL_ROWS;
+
+begin
+  mysql_row_tell:=res^.data_cursor
+end;
+
+Function mysql_field_tell(res : PMYSQL_RES) : Cardinal;
+
+begin
+  mysql_field_tell:=res^.current_field
+end;
+
+Function mysql_affected_rows(mysql : PMYSQL): my_ulonglong; 
+
+begin
+  mysql_affected_rows:=mysql^.affected_rows
+end;
+
+Function mysql_insert_id(mysql : PMYSQL): my_ulonglong; 
+
+begin
+  mysql_insert_id:=mysql^.insert_id
+end;
+
+Function mysql_errno(mysql : PMYSQL) : Cardinal;
+
+begin
+  mysql_errno:=mysql^.net.last_errno
+end;
+
+Function mysql_info(mysql : PMYSQL): Pchar;
+
+begin
+  mysql_info:=mysql^.info
+end;
+
+Function mysql_reload(mysql : PMYSQL) : Longint;
+
+begin
+   mysql_reload:=mysql_refresh(mysql,REFRESH_GRANT)
+end;
+
+Function mysql_thread_id(mysql : PMysql) : Cardinal;
+
+begin
+  mysql_thread_id:=mysql^.thread_id
+end;
+
+end.
+
+{
+  $Log$
+  Revision 1.1  2002-01-29 17:54:53  peter
+    * splitted to base and extra
+
+  Revision 1.5  2001/03/13 08:50:38  michael
+  + merged Fixed calling convention for win32
+
+  Revision 1.4  2000/12/03 13:41:39  sg
+  * Fixed small merging bug by Michael
+
+  Revision 1.3  2000/12/02 15:24:37  michael
+  + Merged changes from fixbranch
+
+}

+ 241 - 0
packages/base/mysql/mysql_com.pp

@@ -0,0 +1,241 @@
+unit mysql_com;
+
+interface
+
+{$ifndef win32}
+  {$linklib mysqlclient}
+  {$linklib m}
+  {$linklib c}
+{$endif}
+
+{
+ Common definition between mysql server & client
+}
+
+{$packrecords 4}
+{ Extra types introduced for pascal }
+Type
+  pbyte = ^byte;
+  pcardinal = ^cardinal;
+  Socket = longint;
+  my_bool = byte;
+
+Const
+ NAME_LEN  = 64 ;               { Field/table name length }
+ LOCAL_HOST : pchar = 'localhost' ;
+
+ MYSQL_PORT = 3306;             { Alloced by ISI for MySQL }
+ MYSQL_UNIX_ADDR  : pchar = '/tmp/mysql.sock';
+
+Type
+ enum_server_command = ( COM_SLEEP,COM_QUIT,COM_INIT_DB,COM_QUERY,
+                          COM_FIELD_LIST,COM_CREATE_DB,COM_DROP_DB,COM_REFRESH,
+                          COM_SHUTDOWN,COM_STATISTICS,
+                          COM_PROCESS_INFO,COM_CONNECT,COM_PROCESS_KILL,
+                          COM_DEBUG);
+
+Const
+ NOT_NULL_FLAG       = 1;               { Field can't be NULL }
+ PRI_KEY_FLAG        = 2;               { Field is part of a primary key }
+ UNIQUE_KEY_FLAG     = 4;               { Field is part of a unique key }
+ MULTIPLE_KEY_FLAG   = 8;               { Field is part of a key }
+ BLOB_FLAG           = 16;              { Field is a blob }
+ UNSIGNED_FLAG       = 32;              { Field is unsigned }
+ ZEROFILL_FLAG       = 64;              { Field is zerofill }
+ BINARY_FLAG         = 128;
+{ The following are only sent to new clients }
+ ENUM_FLAG           = 256;             { field is an enum }
+ AUTO_INCREMENT_FLAG = 512;             { field is a autoincrement field }
+ TIMESTAMP_FLAG      = 1024;            { Field is a timestamp }
+ PART_KEY_FLAG       = 16384;           { Intern; Part of some key }
+ GROUP_FLAG          = 32768;           { Intern group field }
+
+ REFRESH_GRANT          = 1;    { Refresh grant tables }
+ REFRESH_LOG            = 2;    { Start on new log file }
+ REFRESH_TABLES         = 4;    { close all tables }
+
+ CLIENT_LONG_PASSWORD   = 1;    { new more secure passwords }
+ CLIENT_FOUND_ROWS      = 2;    { Found instead of affected rows }
+ CLIENT_LONG_FLAG       = 4;    { Get all column flags }
+
+Type
+pst_used_mem = ^st_used_mem;
+st_used_mem  = record                           { struct for once_alloc }
+  next : pst_used_mem;                          { Next block in use }
+  left : cardinal;                              { memory left in block  }
+  size : cardinal;                              { size of block }
+end;
+
+TUSED_MEM = st_used_mem;
+PUSED_MEM = ^TUSED_MEM;
+
+TError_handler = Procedure;
+
+st_mem_root =  record
+  free : PUSED_MEM;
+  used : PUSED_MEM;
+  min_malloc : cardinal;
+  block_size : cardinal;
+  error_handler : TERROR_Handler;
+end;
+TMEM_ROOT = st_mem_root;
+PMEM_ROOT = ^TMEM_ROOT;
+
+Const
+ MYSQL_ERRMSG_SIZE = 200;
+
+Type
+net_type = (NET_TYPE_TCPIP, NET_TYPE_SOCKET, NETTYPE_NAMEDPIPE);
+st_net  = record
+  nettype : net_type; //DT
+  fd : Socket;
+  fcntl : Longint;
+  buff,buff_end,write_pos,read_pos : Pchar;//DT
+  last_error : array [0..MYSQL_ERRMSG_SIZE-1] of char;
+  last_errno,max_packet,timeout,pkt_nr : Cardinal;
+  error,return_errno : my_bool;
+  compress : my_bool; //DT
+
+  remain_in_buf,r_length, buf_length, where_b : cardinal; //DT
+  more : my_bool;//DT
+  save_char : char; //DT
+end;
+TNET = st_net;
+PNET = ^TNET;
+
+Const
+  packet_error : longint = -1;
+
+Type
+ enum_field_types = ( FIELD_TYPE_DECIMAL, FIELD_TYPE_TINY,
+                        FIELD_TYPE_SHORT,  FIELD_TYPE_LONG,
+                        FIELD_TYPE_FLOAT,  FIELD_TYPE_DOUBLE,
+                        FIELD_TYPE_NULL,   FIELD_TYPE_TIMESTAMP,
+                        FIELD_TYPE_LONGLONG,FIELD_TYPE_INT24,
+                        FIELD_TYPE_DATE,   FIELD_TYPE_TIME,
+                        FIELD_TYPE_DATETIME,
+                        FIELD_TYPE_ENUM := 247,
+                        FIELD_TYPE_SET := 248,
+                        FIELD_TYPE_TINY_BLOB := 249,
+                        FIELD_TYPE_MEDIUM_BLOB := 250,
+                        FIELD_TYPE_LONG_BLOB :=251,
+                        FIELD_TYPE_BLOB :=252,
+                        FIELD_TYPE_VAR_STRING :=253,
+                        FIELD_TYPE_STRING:=254);
+
+Const
+FIELD_TYPE_CHAR = FIELD_TYPE_TINY;              { For compability }
+FIELD_TYPE_INTERVAL = FIELD_TYPE_ENUM;          { For compability }
+
+Procedure sql_free (root : PMEM_ROOT);{$ifdef win32} stdcall {$else} cdecl {$endif};
+Procedure init_alloc_root (root: PMEM_ROOT;block_size : Cardinal);{$ifdef win32} stdcall {$else} cdecl {$endif};
+Function sql_alloc_first_block(root : PMEM_ROOT) : my_bool;{$ifdef win32} stdcall {$else} cdecl {$endif};
+Function sql_alloc_root(mem_root : PMEM_ROOT;len : Cardinal) : longint;{$ifdef win32} stdcall {$else} cdecl {$endif};
+Function sql_strdup_root(root : PMEM_ROOT;st : pchar) : pchar;{$ifdef win32} stdcall {$else} cdecl {$endif};
+Function sql_memdup_root(root: PMEM_ROOT;st : pchar; len : Cardinal): longint;{$ifdef win32} stdcall {$else} cdecl {$endif};
+
+{
+extern unsigned long max_allowed_packet;
+extern unsigned long net_buffer_length;
+}
+
+{
+#define net_new_transaction(net) ((net)->pkt_nr=0)
+}
+
+Function  my_net_init(net :PNET; fd : Socket) : Longint;{$ifdef win32} stdcall {$else} cdecl {$endif};
+procedure net_end(net : PNET);{$ifdef win32} stdcall {$else} cdecl {$endif};
+Procedure net_clear(net : PNET);{$ifdef win32} stdcall {$else} cdecl {$endif};
+Function  net_flush(net : PNET) : longint;{$ifdef win32} stdcall {$else} cdecl {$endif};
+Function  my_net_write(net : PNET;packet : pbyte;len : cardinal) : longint;{$ifdef win32} stdcall {$else} cdecl {$endif};
+Function  net_write_command(net : PNET; command : char;packet : pbyte;len : cardinal) : longint;{$ifdef win32} stdcall {$else} cdecl {$endif};
+Function  net_real_write(net : PNET;packet : pbyte; len : Cardinal) : longint;{$ifdef win32} stdcall {$else} cdecl {$endif};
+Function  my_net_read(net : PNET) : Cardinal;{$ifdef win32} stdcall {$else} cdecl {$endif};
+
+Type
+TRand_struct  = record
+  seed,seed2,max_value : Cardinal;
+  max_value_dbl : double;
+end;
+PRand_struct = ^TRand_struct;
+
+{ The following is for user defined functions }
+
+Item_result = (STRING_RESULT,REAL_RESULT,INT_RESULT);
+
+st_udf_args = record
+  arg_count : cardinal;                 { Number of arguments }
+  arg_type : ^Item_result;              { Pointer to item_results }
+  args : ppchar;                        { Pointer to argument }
+  lengths : PCardinal;                  { Length of string arguments }
+end;
+TUDF_ARGS = st_udf_args;
+PUDPF_ARGS = ^TUDF_ARGS;
+
+  { This holds information about the result }
+
+st_udf_init = record
+  maybe_null : my_bool;                 { 1 if function can return NULL }
+  decimals : cardinal;                  { for real functions }
+  max_length : Cardinal;                { For string functions }
+  ptr : PChar;                          { free pointer for function data }
+end;
+TUDF_INIT = st_udf_init;
+PUDF_INIT = TUDF_INIT;
+
+  { Prototypes to password functions }
+
+procedure randominit(rand : Prand_struct; seed1,seed2 : Cardinal);{$ifdef win32} stdcall {$else} cdecl {$endif};
+Function  rnd(rand : Prand_struct) : double;{$ifdef win32} stdcall {$else} cdecl {$endif};
+procedure make_scrambled_password(toarg, passwd : Pchar);{$ifdef win32} stdcall {$else} cdecl {$endif};
+procedure get_salt_from_password(res : pcardinal; password : pchar);{$ifdef win32} stdcall {$else} cdecl {$endif};
+procedure scramble(toarg,message,password : pchar; old_ver : my_bool);{$ifdef win32} stdcall {$else} cdecl {$endif};
+function  check_scramble(scramble,message : pchar; salt : cardinal;old_ver:my_bool) : my_bool;{$ifdef win32} stdcall {$else} cdecl {$endif};
+function  get_tty_password(opt_message:  pchar) : pchar;{$ifdef win32} stdcall {$else} cdecl {$endif};
+
+{
+#define NULL_LENGTH ((unsigned long) ~0) { For net_store_length }
+}
+
+implementation
+
+Procedure sql_free (root : PMEM_ROOT);{$ifdef win32} stdcall {$else} cdecl {$endif};external;
+Procedure init_alloc_root (root: PMEM_ROOT;block_size : Cardinal);{$ifdef win32} stdcall {$else} cdecl {$endif};external;
+Function sql_alloc_first_block(root : PMEM_ROOT) : my_bool;{$ifdef win32} stdcall {$else} cdecl {$endif};external;
+Function sql_alloc_root(mem_root : PMEM_ROOT;len : Cardinal) : longint;{$ifdef win32} stdcall {$else} cdecl {$endif};external;
+Function sql_strdup_root(root : PMEM_ROOT;st : pchar) : pchar;{$ifdef win32} stdcall {$else} cdecl {$endif};external;
+Function sql_memdup_root(root: PMEM_ROOT;st : pchar; len : Cardinal) : longint;{$ifdef win32} stdcall {$else} cdecl {$endif};external;
+Function  my_net_init(net :PNET; fd : Socket) : Longint;{$ifdef win32} stdcall {$else} cdecl {$endif};external;
+procedure net_end(net : PNET);{$ifdef win32} stdcall {$else} cdecl {$endif};external;
+Procedure net_clear(net : PNET);{$ifdef win32} stdcall {$else} cdecl {$endif};external;
+Function  net_flush(net : PNET) : longint;{$ifdef win32} stdcall {$else} cdecl {$endif};external;
+Function  my_net_write(net : PNET;packet : pbyte;len : cardinal) : longint;{$ifdef win32} stdcall {$else} cdecl {$endif};external;
+Function  net_write_command(net : PNET; command : char;packet : pbyte;len : cardinal) : longint;{$ifdef win32} stdcall {$else} cdecl {$endif};external;
+Function  net_real_write(net : PNET;packet : pbyte; len : Cardinal) : longint;{$ifdef win32} stdcall {$else} cdecl {$endif};external;
+Function  my_net_read(net : PNET) : Cardinal;{$ifdef win32} stdcall {$else} cdecl {$endif};external;
+procedure randominit(rand : Prand_struct; seed1,seed2 : Cardinal);{$ifdef win32} stdcall {$else} cdecl {$endif};external;
+Function  rnd(rand : Prand_struct) : double;{$ifdef win32} stdcall {$else} cdecl {$endif};external;
+procedure make_scrambled_password(toarg, passwd : Pchar);{$ifdef win32} stdcall {$else} cdecl {$endif};external;
+procedure get_salt_from_password(res : pcardinal; password : pchar);{$ifdef win32} stdcall {$else} cdecl {$endif};external;
+procedure scramble(toarg,message,password : pchar; old_ver : my_bool);{$ifdef win32} stdcall {$else} cdecl {$endif};external;
+function  check_scramble(scramble,message : pchar; salt : cardinal;old_ver:my_bool) : my_bool;{$ifdef win32} stdcall {$else} cdecl {$endif};external;
+function  get_tty_password(opt_message:  pchar) : pchar;{$ifdef win32} stdcall {$else} cdecl {$endif};external;
+
+end.
+  $Log$
+  Revision 1.1  2002-01-29 17:54:53  peter
+    * splitted to base and extra
+
+  Revision 1.5  2001/04/13 18:04:56  peter
+    * added missing $ifndef win32
+
+  Revision 1.4  2001/03/13 08:50:38  michael
+  + merged Fixed calling convention for win32
+
+  Revision 1.3  2000/12/02 15:24:37  michael
+  + Merged changes from fixbranch
+
+  Revision 1.2  2000/07/13 11:33:26  michael
+  + removed logs
+
+}

+ 27 - 0
packages/base/mysql/mysql_version.pp

@@ -0,0 +1,27 @@
+unit mysql_version;
+
+{
+  Translated from mysql_version.h by Michael Van Canneyt
+  ([email protected])
+}
+
+interface
+
+{ Version numbers for protocol & mysqld }
+Const
+
+ MYSQL_SERVER_VERSION : pchar ='3.21.28-gamma';
+ FRM_VER = 6;
+ MYSQL_VERSION_ID =32128;
+
+implementation
+
+end.
+  $Log$
+  Revision 1.1  2002-01-29 17:54:53  peter
+    * splitted to base and extra
+
+  Revision 1.2  2000/07/13 11:33:26  michael
+  + removed logs
+ 
+}

+ 27 - 0
packages/base/mysql/mysqls.c

@@ -0,0 +1,27 @@
+#include <mysql.h>
+#include <mysql_com.h>
+#include <stdio.h>
+
+main ()
+{
+  my_bool i;
+  NET n;
+  enum enum_net_type nettype;
+  struct st_mysql_options options;
+  my_ulonglong llong;
+  
+  printf ("MYSQL : %d options : %d\n",sizeof(MYSQL),sizeof(options));
+  printf ("MYSQL_DATA : %d\n",sizeof(MYSQL_DATA));
+  printf ("MYSQL_ROWS : %d\n",sizeof(MYSQL_ROWS));
+  printf ("MYSQL_ROW : %d\n",sizeof(MYSQL_ROW));
+  printf ("MYSQL_FIELD : %d\n",sizeof(MYSQL_FIELD));
+  printf ("MYSQL_RES : %d\n",sizeof(MYSQL_RES));
+  printf ("MEM_ROOT : %d\n",sizeof(MEM_ROOT));
+  printf ("my_bool : %d\n",sizeof(my_bool));
+  printf ("NET : %d NET.nettype : %d\n",sizeof(NET),sizeof(nettype));
+  printf ("USED_MEM : %d\n",sizeof(USED_MEM));
+  printf ("new: %d\n",sizeof(char [MYSQL_ERRMSG_SIZE]));
+  printf ("longlong: %d\n",sizeof(llong));
+  i=n.error;
+}
+

+ 29 - 0
packages/base/mysql/mysqls.pp

@@ -0,0 +1,29 @@
+program mysqls;
+
+uses mysql,mysql_com;
+
+
+begin
+  Writeln('PASCAL');
+  Writeln ('MYSQL : ',sizeof(TMYSQL),' options : ',sizeof(st_mysql_options));
+  writeln ('MYSQL_DATA : ',sizeof(TMYSQL_DATA));
+  writeln ('MYSQL_ROWS : ',sizeof(TMYSQL_ROWS));
+  writeln ('MYSQL_ROW : ',sizeof(TMYSQL_ROW));
+  writeln ('MYSQL_FIELD : ',sizeof(TMYSQL_FIELD));
+  writeln ('MYSQL_RES : ',sizeof(TMYSQL_RES));
+  writeln ('MEM_ROOT : ',sizeof(TMEM_ROOT));
+  writeln ('my_bool : ',sizeof(my_bool));
+  writeln ('TNET : ',sizeof(TNET),' TNET.nettype : ',SizeOf(net_type));
+  writeln ('USED_MEM : ',sizeof(TUSED_MEM));
+end.
+  $Log$
+  Revision 1.1  2002-01-29 17:54:54  peter
+    * splitted to base and extra
+
+  Revision 1.3  2000/12/02 15:24:37  michael
+  + Merged changes from fixbranch
+
+  Revision 1.2  2000/07/13 11:33:26  michael
+  + removed logs
+ 
+}

+ 16 - 0
packages/base/mysql/rmdb

@@ -0,0 +1,16 @@
+#!/bin/sh
+#
+# Small script to remove the demo database again.
+# This script accepts 1 (optional) argument : 
+# a database you can connect to. Default is 'testdb'
+# 
+echo -n "Removing table FPdev from db ${1-testdb}..." 
+mysql ${1-testdb} << EOF >/dev/null
+drop table FPdev
+EOF
+if [ ! $? = 0 ]; then
+  echo "Failed."
+else
+  echo "Done."
+fi
+# Ready

+ 91 - 0
packages/base/mysql/testdb.pp

@@ -0,0 +1,91 @@
+program qtest;
+
+uses mysql;
+
+Const
+  DataBase : Pchar = 'testdb';
+  Query    : Pchar = 'Select * from FPdev';
+
+var
+  count,num : longint;
+  code : integer;
+  sock : PMYSQL;
+  qmysql : TMYSQL;
+  qbuf : string [160];
+  rowbuf : TMYSQL_ROW;
+  dummy : string;
+  recbuf : PMYSQL_RES;
+
+begin
+  if paramcount=1 then
+    begin
+    Dummy:=Paramstr(1)+#0;
+    DataBase:=@Dummy[1];
+    end;  
+  Write ('Connecting to MySQL...');
+  sock :=  mysql_connect(PMysql(@qmysql),nil,nil,nil);
+  if sock=Nil then 
+    begin
+    Writeln (stderr,'Couldn''t connect to MySQL.');
+    Writeln (stderr,mysql_error(@qmysql));
+    halt(1); 
+    end;
+  Writeln ('Done.');
+  Writeln ('Connection data:');
+{$ifdef linux}  
+  writeln ('Mysql_port      : ',mysql_port);
+  writeln ('Mysql_unix_port : ',mysql_unix_port);
+{$endif}  
+  writeln ('Host info       : ',mysql_get_host_info(sock));
+  writeln ('Server info     : ',mysql_stat(sock)); 
+  writeln ('Client info     : ',mysql_get_client_info);
+  
+  Writeln ('Selecting Database ',DataBase,'...');  
+  if mysql_select_db(sock,DataBase) < 0 then 
+    begin
+    Writeln (stderr,'Couldn''t select database ',Database);
+    Writeln (stderr,mysql_error(sock));
+    halt (1);
+    end;
+  
+  writeln ('Executing query : ',Query,'...'); 
+    if (mysql_query(sock,Query) < 0) then
+      begin
+      Writeln (stderr,'Query failed ');
+      writeln (stderr,mysql_error(sock));
+      Halt(1);
+      end;                      
+
+  recbuf := mysql_store_result(sock); 
+  if RecBuf=Nil then
+    begin
+    Writeln ('Query returned nil result.');
+    mysql_close(sock);
+    halt (1);
+    end;
+  Writeln ('Number of records returned  : ',mysql_num_rows (recbuf));
+  Writeln ('Number of fields per record : ',mysql_num_fields(recbuf));
+  
+  rowbuf := mysql_fetch_row(recbuf);
+  while (rowbuf <>nil) do
+       begin
+       Write  ('(Id: ', rowbuf[0]);
+       Write  (', Name: ', rowbuf[1]);
+       Writeln(', Email : ', rowbuf[2],')');
+       rowbuf := mysql_fetch_row(recbuf);
+       end;
+  Writeln ('Freeing memory occupied by result set...');
+  mysql_free_result (recbuf); 
+
+  Writeln ('Closing connection with MySQL.');
+  mysql_close(sock);
+  halt(0);
+end.
+  $Log$
+  Revision 1.1  2002-01-29 17:54:54  peter
+    * splitted to base and extra
+
+  Revision 1.2  2000/07/13 11:33:26  michael
+  + removed logs
+ 
+}

+ 1298 - 0
packages/base/oracle/Makefile

@@ -0,0 +1,1298 @@
+#
+# Don't edit, this file is generated by FPCMake Version 1.1 [2002/01/29]
+#
+default: all
+MAKEFILETARGETS=linux go32v2 win32 os2 freebsd beos netbsd amiga atari sunos qnx
+override PATH:=$(subst \,/,$(PATH))
+ifeq ($(findstring ;,$(PATH)),)
+inUnix=1
+SEARCHPATH:=$(filter-out .,$(subst :, ,$(PATH)))
+else
+SEARCHPATH:=$(subst ;, ,$(PATH))
+endif
+PWD:=$(strip $(wildcard $(addsuffix /pwd.exe,$(SEARCHPATH))))
+ifeq ($(PWD),)
+PWD:=$(strip $(wildcard $(addsuffix /pwd,$(SEARCHPATH))))
+ifeq ($(PWD),)
+$(error You need the GNU utils package to use this Makefile)
+else
+PWD:=$(firstword $(PWD))
+SRCEXEEXT=
+endif
+else
+PWD:=$(firstword $(PWD))
+SRCEXEEXT=.exe
+endif
+ifndef inUnix
+ifeq ($(OS),Windows_NT)
+inWinNT=1
+else
+ifdef OS2_SHELL
+inOS2=1
+endif
+endif
+else
+ifneq ($(findstring cygwin,$(MACHTYPE)),)
+inCygWin=1
+endif
+endif
+ifeq ($(OS_TARGET),freebsd)
+BSDhier=1
+endif
+ifeq ($(OS_TARGET),netbsd)
+BSDhier=1
+endif
+ifdef inUnix
+BATCHEXT=.sh
+else
+ifdef inOS2
+BATCHEXT=.cmd
+else
+BATCHEXT=.bat
+endif
+endif
+ifdef inUnix
+PATHSEP=/
+else
+PATHSEP:=$(subst /,\,/)
+endif
+ifdef PWD
+BASEDIR:=$(subst \,/,$(shell $(PWD)))
+ifdef inCygWin
+ifneq ($(findstring /cygdrive/,$(BASEDIR)),)
+BASENODIR:=$(patsubst /cygdrive%,%,$(BASEDIR))
+BASEDRIVE:=$(firstword $(subst /, ,$(BASENODIR)))
+BASEDIR:=$(subst /cygdrive/$(BASEDRIVE)/,$(BASEDRIVE):/,$(BASEDIR))
+endif
+endif
+else
+BASEDIR=.
+endif
+override DEFAULT_FPCDIR=../../..
+ifndef FPC
+ifdef PP
+FPC=$(PP)
+endif
+endif
+ifndef FPC
+FPCPROG:=$(strip $(wildcard $(addsuffix /fpc$(SRCEXEEXT),$(SEARCHPATH))))
+ifneq ($(FPCPROG),)
+FPCPROG:=$(firstword $(FPCPROG))
+FPC:=$(shell $(FPCPROG) -PB)
+ifneq ($(findstring Error,$(FPC)),)
+override FPC=ppc386
+endif
+else
+override FPC=ppc386
+endif
+endif
+override FPC:=$(subst $(SRCEXEEXT),,$(FPC))
+override FPC:=$(subst \,/,$(FPC))$(SRCEXEEXT)
+ifndef FPC_VERSION
+FPC_VERSION:=$(shell $(FPC) -iV)
+endif
+export FPC FPC_VERSION
+ifeq ($(findstring 1.0.,$(FPC_VERSION)),)
+COMPILERINFO:=$(shell $(FPC) -iSP -iTP -iSO -iTO)
+ifndef CPU_SOURCE
+CPU_SOURCE:=$(word 1,$(COMPILERINFO))
+endif
+ifndef CPU_TARGET
+CPU_TARGET:=$(word 2,$(COMPILERINFO))
+endif
+ifndef OS_SOURCE
+OS_SOURCE:=$(word 3,$(COMPILERINFO))
+endif
+ifndef OS_TARGET
+OS_TARGET:=$(word 4,$(COMPILERINFO))
+endif
+else
+ifndef CPU_SOURCE
+CPU_SOURCE:=$(shell $(FPC) -iSP)
+endif
+ifndef CPU_TARGET
+CPU_TARGET:=$(shell $(FPC) -iTP)
+endif
+ifndef OS_SOURCE
+OS_SOURCE:=$(shell $(FPC) -iSO)
+endif
+ifndef OS_TARGET
+OS_TARGET:=$(shell $(FPC) -iTO)
+endif
+endif
+FULL_TARGET=$(CPU_TARGET)-$(OS_TARGET)
+FULL_SOURCE=$(CPU_SOURCE)-$(OS_SOURCE)
+ifneq ($(FULL_TARGET),$(FULL_SOURCE))
+CROSSCOMPILE=1
+endif
+ifeq ($(findstring makefile,$(MAKECMDGOALS)),)
+ifeq ($(findstring $(OS_TARGET),$(MAKEFILETARGETS)),)
+$(error The Makefile doesn't support target $(OS_TARGET), please run fpcmake first)
+endif
+endif
+export OS_TARGET OS_SOURCE CPU_TARGET CPU_SOURCE FULL_TARGET FULL_SOURCE CROSSCOMPILE
+ifdef FPCDIR
+override FPCDIR:=$(subst \,/,$(FPCDIR))
+ifeq ($(wildcard $(addprefix $(FPCDIR)/,rtl units)),)
+override FPCDIR=wrong
+endif
+else
+override FPCDIR=wrong
+endif
+ifdef DEFAULT_FPCDIR
+ifeq ($(FPCDIR),wrong)
+override FPCDIR:=$(subst \,/,$(DEFAULT_FPCDIR))
+ifeq ($(wildcard $(addprefix $(FPCDIR)/,rtl units)),)
+override FPCDIR=wrong
+endif
+endif
+endif
+ifeq ($(FPCDIR),wrong)
+ifdef inUnix
+override FPCDIR=/usr/local/lib/fpc/$(FPC_VERSION)
+ifeq ($(wildcard $(FPCDIR)/units),)
+override FPCDIR=/usr/lib/fpc/$(FPC_VERSION)
+endif
+else
+override FPCDIR:=$(subst /$(FPC),,$(firstword $(strip $(wildcard $(addsuffix /$(FPC),$(SEARCHPATH))))))
+override FPCDIR:=$(FPCDIR)/..
+ifeq ($(wildcard $(addprefix $(FPCDIR)/,rtl units)),)
+override FPCDIR:=$(FPCDIR)/..
+ifeq ($(wildcard $(addprefix $(FPCDIR)/,rtl units)),)
+override FPCDIR=c:/pp
+endif
+endif
+endif
+endif
+ifndef CROSSDIR
+CROSSDIR:=$(FPCDIR)/cross/$(FULL_TARGET)
+endif
+ifndef CROSSTARGETDIR
+CROSSTARGETDIR=$(CROSSDIR)/$(FULL_TARGET)
+endif
+ifdef CROSSCOMPILE
+UNITSDIR:=$(wildcard $(CROSSTARGETDIR)/units)
+ifeq ($(UNITSDIR),)
+UNITSDIR:=$(wildcard $(FPCDIR)/units/$(OS_TARGET))
+endif
+else
+UNITSDIR:=$(wildcard $(FPCDIR)/units/$(OS_TARGET))
+endif
+PACKAGESDIR:=$(wildcard $(FPCDIR) $(FPCDIR)/packages/base $(FPCDIR)/packages/extra)
+override PACKAGE_NAME=oracle
+override PACKAGE_VERSION=1.0.6
+override TARGET_UNITS+=oraoci
+override TARGET_EXAMPLEDIRS+=example
+override INSTALL_FPCPACKAGE=y
+ifdef REQUIRE_UNITSDIR
+override UNITSDIR+=$(REQUIRE_UNITSDIR)
+endif
+ifdef REQUIRE_PACKAGESDIR
+override PACKAGESDIR+=$(REQUIRE_PACKAGESDIR)
+endif
+ifdef ZIPINSTALL
+ifeq ($(OS_TARGET),linux)
+UNIXINSTALLDIR=1
+endif
+ifeq ($(OS_TARGET),freebsd)
+UNIXINSTALLDIR=1
+endif
+ifeq ($(OS_TARGET),netbsd)
+UNIXINSTALLDIR=1
+endif
+ifeq ($(OS_TARGET),sunos)
+UNIXINSTALLDIR=1
+endif
+else
+ifeq ($(OS_SOURCE),linux)
+UNIXINSTALLDIR=1
+endif
+ifeq ($(OS_SOURCE),freebsd)
+UNIXINSTALLDIR=1
+endif
+ifeq ($(OS_SOURCE),netbsd)
+UNIXINSTALLDIR=1
+endif
+ifeq ($(OS_TARGET),sunos)
+UNIXINSTALLDIR=1
+endif
+endif
+ifndef INSTALL_PREFIX
+ifdef PREFIX
+INSTALL_PREFIX=$(PREFIX)
+endif
+endif
+ifndef INSTALL_PREFIX
+ifdef UNIXINSTALLDIR
+INSTALL_PREFIX=/usr/local
+else
+ifdef INSTALL_FPCPACKAGE
+INSTALL_BASEDIR:=/pp
+else
+INSTALL_BASEDIR:=/$(PACKAGE_NAME)
+endif
+endif
+endif
+export INSTALL_PREFIX
+ifndef DIST_DESTDIR
+DIST_DESTDIR:=$(BASEDIR)
+endif
+export DIST_DESTDIR
+ifndef INSTALL_BASEDIR
+ifdef UNIXINSTALLDIR
+ifdef INSTALL_FPCPACKAGE
+INSTALL_BASEDIR:=$(INSTALL_PREFIX)/lib/fpc/$(FPC_VERSION)
+else
+INSTALL_BASEDIR:=$(INSTALL_PREFIX)/lib/$(PACKAGE_NAME)
+endif
+else
+INSTALL_BASEDIR:=$(INSTALL_PREFIX)
+endif
+endif
+ifndef INSTALL_BINDIR
+ifdef UNIXINSTALLDIR
+INSTALL_BINDIR:=$(INSTALL_PREFIX)/bin
+else
+INSTALL_BINDIR:=$(INSTALL_BASEDIR)/bin
+ifdef INSTALL_FPCPACKAGE
+INSTALL_BINDIR:=$(INSTALL_BINDIR)/$(OS_TARGET)
+endif
+endif
+endif
+ifndef INSTALL_UNITDIR
+ifdef CROSSCOMPILE
+INSTALL_UNITDIR:=$(INSTALL_BASEDIR)/cross/$(FULL_TARGET)/units
+else
+INSTALL_UNITDIR:=$(INSTALL_BASEDIR)/units/$(OS_TARGET)
+endif
+ifdef INSTALL_FPCPACKAGE
+ifdef PACKAGE_NAME
+INSTALL_UNITDIR:=$(INSTALL_UNITDIR)/$(PACKAGE_NAME)
+endif
+endif
+endif
+ifndef INSTALL_LIBDIR
+ifdef UNIXINSTALLDIR
+INSTALL_LIBDIR:=$(INSTALL_PREFIX)/lib
+else
+INSTALL_LIBDIR:=$(INSTALL_UNITDIR)
+endif
+endif
+ifndef INSTALL_SOURCEDIR
+ifdef UNIXINSTALLDIR
+ifdef INSTALL_FPCPACKAGE
+ifdef BSDhier
+INSTALL_SOURCEDIR:=$(INSTALL_PREFIX)/share/src/fpc-$(FPC_VERSION)/$(PACKAGE_NAME)
+else
+INSTALL_SOURCEDIR:=$(INSTALL_PREFIX)/src/fpc-$(FPC_VERSION)/$(PACKAGE_NAME)
+endif
+else
+ifdef BSDhier
+INSTALL_SOURCEDIR:=$(INSTALL_PREFIX)/share/src/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
+else
+INSTALL_SOURCEDIR:=$(INSTALL_PREFIX)/src/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
+endif
+endif
+else
+ifdef INSTALL_FPCPACKAGE
+INSTALL_SOURCEDIR:=$(INSTALL_BASEDIR)/source/$(PACKAGE_NAME)
+else
+INSTALL_SOURCEDIRL:=$(INSTALL_BASEDIR)/source
+endif
+endif
+endif
+ifndef INSTALL_DOCDIR
+ifdef UNIXINSTALLDIR
+ifdef INSTALL_FPCPACKAGE
+ifdef BSDhier
+INSTALL_DOCDIR:=$(INSTALL_PREFIX)/share/doc/fpc-$(FPC_VERSION)/$(PACKAGE_NAME)
+else
+INSTALL_DOCDIR:=$(INSTALL_PREFIX)/doc/fpc-$(FPC_VERSION)/$(PACKAGE_NAME)
+endif
+else
+ifdef BSDhier
+INSTALL_DOCDIR:=$(INSTALL_PREFIX)/share/doc/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
+else
+INSTALL_DOCDIR:=$(INSTALL_PREFIX)/doc/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
+endif
+endif
+else
+ifdef INSTALL_FPCPACKAGE
+INSTALL_DOCDIR:=$(INSTALL_BASEDIR)/doc/$(PACKAGE_NAME)
+else
+INSTALL_DOCDIR:=$(INSTALL_BASEDIR)/doc
+endif
+endif
+endif
+ifndef INSTALL_EXAMPLEDIR
+ifdef UNIXINSTALLDIR
+ifdef INSTALL_FPCPACKAGE
+ifdef BSDhier
+INSTALL_EXAMPLEDIR:=$(INSTALL_PREFIX)/share/examples/fpc-$(FPC_VERSION)/$(PACKAGE_NAME)
+else
+INSTALL_EXAMPLEDIR:=$(INSTALL_PREFIX)/doc/fpc-$(FPC_VERSION)/examples/$(PACKAGE_NAME)
+endif
+else
+ifdef BSDhier
+INSTALL_EXAMPLEDIR:=$(INSTALL_PREFIX)/share/examples/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
+else
+INSTALL_EXAMPLEDIR:=$(INSTALL_PREFIX)/doc/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
+endif
+endif
+else
+ifdef INSTALL_FPCPACKAGE
+INSTALL_EXAMPLEDIR:=$(INSTALL_BASEDIR)/examples/$(PACKAGE_NAME)
+else
+INSTALL_EXAMPLEDIR:=$(INSTALL_BASEDIR)/examples
+endif
+endif
+endif
+ifndef INSTALL_DATADIR
+INSTALL_DATADIR=$(INSTALL_BASEDIR)
+endif
+ifdef CROSSCOMPILE
+ifndef CROSSBINDIR
+CROSSBINDIR:=$(wildcard $(CROSSTARGETDIR)/bin/$(FULL_SOURCE))
+ifeq ($(CROSSBINDIR),)
+CROSSBINDIR:=$(wildcard $(INSTALL_BASEDIR)/cross/$(FULL_TARGET)/bin/$(FULL_SOURCE))
+endif
+endif
+else
+CROSSBINDIR=
+endif
+ifdef inUnix
+ifndef GCCLIBDIR
+GCCLIBDIR:=$(shell dirname `(gcc -v 2>&1)| head -n 1| awk '{ print $$4 } '`)
+endif
+ifeq ($(OS_TARGET),linux)
+ifndef OTHERLIBDIR
+OTHERLIBDIR:=$(shell grep -v "^\#" /etc/ld.so.conf | awk '{ ORS=" "; print $1 }')
+endif
+endif
+ifeq ($(OS_TARGET),netbsd)
+OTHERLIBDIR+=/usr/pkg/lib
+endif
+export GCCLIBDIR OTHERLIB
+endif
+LOADEREXT=.as
+EXEEXT=.exe
+PPLEXT=.ppl
+PPUEXT=.ppu
+OEXT=.o
+ASMEXT=.s
+SMARTEXT=.sl
+STATICLIBEXT=.a
+SHAREDLIBEXT=.so
+STATICLIBPREFIX=libp
+RSTEXT=.rst
+FPCMADE=fpcmade
+ifeq ($(OS_TARGET),go32v1)
+PPUEXT=.pp1
+OEXT=.o1
+ASMEXT=.s1
+SMARTEXT=.sl1
+STATICLIBEXT=.a1
+SHAREDLIBEXT=.so1
+STATICLIBPREFIX=
+FPCMADE=fpcmade.v1
+PACKAGESUFFIX=v1
+endif
+ifeq ($(OS_TARGET),go32v2)
+STATICLIBPREFIX=
+FPCMADE=fpcmade.dos
+ZIPSUFFIX=go32
+endif
+ifeq ($(OS_TARGET),linux)
+EXEEXT=
+HASSHAREDLIB=1
+FPCMADE=fpcmade.lnx
+ZIPSUFFIX=linux
+endif
+ifeq ($(OS_TARGET),freebsd)
+EXEEXT=
+HASSHAREDLIB=1
+FPCMADE=fpcmade.freebsd
+ZIPSUFFIX=freebsd
+endif
+ifeq ($(OS_TARGET),netbsd)
+EXEEXT=
+HASSHAREDLIB=1
+FPCMADE=fpcmade.netbsd
+ZIPSUFFIX=netbsd
+endif
+ifeq ($(OS_TARGET),win32)
+PPUEXT=.ppw
+OEXT=.ow
+ASMEXT=.sw
+SMARTEXT=.slw
+STATICLIBEXT=.aw
+SHAREDLIBEXT=.dll
+FPCMADE=fpcmade.w32
+ZIPSUFFIX=w32
+endif
+ifeq ($(OS_TARGET),os2)
+PPUEXT=.ppo
+ASMEXT=.so2
+OEXT=.oo2
+AOUTEXT=.out
+SMARTEXT=.so
+STATICLIBEXT=.ao2
+SHAREDLIBEXT=.dll
+FPCMADE=fpcmade.os2
+ZIPSUFFIX=emx
+endif
+ifeq ($(OS_TARGET),amiga)
+EXEEXT=
+PPUEXT=.ppa
+ASMEXT=.asm
+OEXT=.o
+SMARTEXT=.sl
+STATICLIBEXT=.a
+SHAREDLIBEXT=.library
+FPCMADE=fpcmade.amg
+endif
+ifeq ($(OS_TARGET),atari)
+PPUEXT=.ppt
+ASMEXT=.s
+OEXT=.o
+SMARTEXT=.sl
+STATICLIBEXT=.a
+EXEEXT=.ttp
+FPCMADE=fpcmade.ata
+endif
+ifeq ($(OS_TARGET),beos)
+PPUEXT=.ppu
+ASMEXT=.s
+OEXT=.o
+SMARTEXT=.sl
+STATICLIBEXT=.a
+EXEEXT=
+FPCMADE=fpcmade.be
+ZIPSUFFIX=be
+endif
+ifeq ($(OS_TARGET),sunos)
+PPUEXT=.ppu
+ASMEXT=.s
+OEXT=.o
+SMARTEXT=.sl
+STATICLIBEXT=.a
+EXEEXT=
+FPCMADE=fpcmade.sun
+ZIPSUFFIX=sun
+endif
+ifeq ($(OS_TARGET),qnx)
+PPUEXT=.ppu
+ASMEXT=.s
+OEXT=.o
+SMARTEXT=.sl
+STATICLIBEXT=.a
+EXEEXT=
+FPCMADE=fpcmade.qnx
+ZIPSUFFIX=qnx
+endif
+ifndef ECHO
+ECHO:=$(strip $(wildcard $(addsuffix /gecho$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(ECHO),)
+ECHO:=$(strip $(wildcard $(addsuffix /echo$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(ECHO),)
+ECHO=
+else
+ECHO:=$(firstword $(ECHO))
+endif
+else
+ECHO:=$(firstword $(ECHO))
+endif
+endif
+export ECHO
+ifndef DATE
+DATE:=$(strip $(wildcard $(addsuffix /gdate$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(DATE),)
+DATE:=$(strip $(wildcard $(addsuffix /date$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(DATE),)
+DATE=
+else
+DATE:=$(firstword $(DATE))
+endif
+else
+DATE:=$(firstword $(DATE))
+endif
+endif
+export DATE
+ifndef GINSTALL
+GINSTALL:=$(strip $(wildcard $(addsuffix /ginstall$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(GINSTALL),)
+GINSTALL:=$(strip $(wildcard $(addsuffix /install$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(GINSTALL),)
+GINSTALL=
+else
+GINSTALL:=$(firstword $(GINSTALL))
+endif
+else
+GINSTALL:=$(firstword $(GINSTALL))
+endif
+endif
+export GINSTALL
+ifndef CPPROG
+CPPROG:=$(strip $(wildcard $(addsuffix /cp$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(CPPROG),)
+CPPROG=
+else
+CPPROG:=$(firstword $(CPPROG))
+endif
+endif
+export CPPROG
+ifndef RMPROG
+RMPROG:=$(strip $(wildcard $(addsuffix /rm$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(RMPROG),)
+RMPROG=
+else
+RMPROG:=$(firstword $(RMPROG))
+endif
+endif
+export RMPROG
+ifndef MVPROG
+MVPROG:=$(strip $(wildcard $(addsuffix /mv$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(MVPROG),)
+MVPROG=
+else
+MVPROG:=$(firstword $(MVPROG))
+endif
+endif
+export MVPROG
+ifndef ECHOREDIR
+ECHOREDIR:=$(subst /,$(PATHSEP),$(ECHO))
+endif
+ifndef COPY
+COPY:=$(CPPROG) -fp
+endif
+ifndef COPYTREE
+COPYTREE:=$(CPPROG) -rfp
+endif
+ifndef MOVE
+MOVE:=$(MVPROG) -f
+endif
+ifndef DEL
+DEL:=$(RMPROG) -f
+endif
+ifndef DELTREE
+DELTREE:=$(RMPROG) -rf
+endif
+ifndef INSTALL
+ifdef inUnix
+INSTALL:=$(GINSTALL) -c -m 644
+else
+INSTALL:=$(COPY)
+endif
+endif
+ifndef INSTALLEXE
+ifdef inUnix
+INSTALLEXE:=$(GINSTALL) -c -m 755
+else
+INSTALLEXE:=$(COPY)
+endif
+endif
+ifndef MKDIR
+MKDIR:=$(GINSTALL) -m 755 -d
+endif
+export ECHOREDIR COPY COPYTREE MOVE DEL DELTREE INSTALL INSTALLEXE MKDIR
+ifndef PPUMOVE
+PPUMOVE:=$(strip $(wildcard $(addsuffix /ppumove$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(PPUMOVE),)
+PPUMOVE=
+else
+PPUMOVE:=$(firstword $(PPUMOVE))
+endif
+endif
+export PPUMOVE
+ifndef FPCMAKE
+FPCMAKE:=$(strip $(wildcard $(addsuffix /fpcmake$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(FPCMAKE),)
+FPCMAKE=
+else
+FPCMAKE:=$(firstword $(FPCMAKE))
+endif
+endif
+export FPCMAKE
+ifndef ZIPPROG
+ZIPPROG:=$(strip $(wildcard $(addsuffix /zip$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(ZIPPROG),)
+ZIPPROG=
+else
+ZIPPROG:=$(firstword $(ZIPPROG))
+endif
+endif
+export ZIPPROG
+ifndef TARPROG
+TARPROG:=$(strip $(wildcard $(addsuffix /tar$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(TARPROG),)
+TARPROG=
+else
+TARPROG:=$(firstword $(TARPROG))
+endif
+endif
+export TARPROG
+ASNAME=as
+LDNAME=ld
+ARNAME=ar
+RCNAME=rc
+ifeq ($(OS_TARGET),win32)
+ASNAME=asw
+LDNAME=ldw
+ARNAME=arw
+endif
+ifndef ASPROG
+ifdef CROSSBINDIR
+ASPROG=$(CROSSBINDIR)/$(ASNAME)$(SRCEXEEXT)
+else
+ASPROG=$(ASNAME)
+endif
+endif
+ifndef LDPROG
+ifdef CROSSBINDIR
+LDPROG=$(CROSSBINDIR)/$(LDNAME)$(SRCEXEEXT)
+else
+LDPROG=$(LDNAME)
+endif
+endif
+ifndef RCPROG
+ifdef CROSSBINDIR
+RCPROG=$(CROSSBINDIR)/$(RCNAME)$(SRCEXEEXT)
+else
+RCPROG=$(RCNAME)
+endif
+endif
+ifndef ARPROG
+ifdef CROSSBINDIR
+ARPROG=$(CROSSBINDIR)/$(ARNAME)$(SRCEXEEXT)
+else
+ARPROG=$(ARNAME)
+endif
+endif
+AS=$(ASPROG)
+LD=$(LDPROG)
+RC=$(RCPROG)
+AR=$(ARPROG)
+PPAS=ppas$(BATCHEXT)
+ifdef inUnix
+LDCONFIG=ldconfig
+else
+LDCONFIG=
+endif
+ifdef DATE
+DATESTR:=$(shell $(DATE) +%Y%m%d)
+else
+DATESTR=
+endif
+ifndef UPXPROG
+ifeq ($(OS_TARGET),go32v2)
+UPXPROG:=1
+endif
+ifeq ($(OS_TARGET),win32)
+UPXPROG:=1
+endif
+ifdef UPXPROG
+UPXPROG:=$(strip $(wildcard $(addsuffix /upx$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(UPXPROG),)
+UPXPROG=
+else
+UPXPROG:=$(firstword $(UPXPROG))
+endif
+else
+UPXPROG=
+endif
+endif
+export UPXPROG
+ZIPOPT=-9
+ZIPEXT=.zip
+ifeq ($(USETAR),bz2)
+TAROPT=vI
+TAREXT=.tar.bz2
+else
+TAROPT=vz
+TAREXT=.tar.gz
+endif
+override REQUIRE_PACKAGES=rtl 
+ifeq ($(OS_TARGET),linux)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(OS_TARGET),go32v2)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(OS_TARGET),win32)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(OS_TARGET),os2)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(OS_TARGET),freebsd)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(OS_TARGET),beos)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(OS_TARGET),netbsd)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(OS_TARGET),amiga)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(OS_TARGET),atari)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(OS_TARGET),sunos)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(OS_TARGET),qnx)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifdef REQUIRE_PACKAGES_RTL
+PACKAGEDIR_RTL:=$(firstword $(subst /Makefile.fpc,,$(strip $(wildcard $(addsuffix /rtl/$(OS_TARGET)/Makefile.fpc,$(PACKAGESDIR))))))
+ifneq ($(PACKAGEDIR_RTL),)
+ifneq ($(wildcard $(PACKAGEDIR_RTL)/$(OS_TARGET)),)
+UNITDIR_RTL=$(PACKAGEDIR_RTL)/$(OS_TARGET)
+else
+UNITDIR_RTL=$(PACKAGEDIR_RTL)
+endif
+else
+PACKAGEDIR_RTL=
+UNITDIR_RTL:=$(subst /Package.fpc,,$(strip $(wildcard $(addsuffix /rtl/Package.fpc,$(UNITSDIR)))))
+ifneq ($(UNITDIR_RTL),)
+UNITDIR_RTL:=$(firstword $(UNITDIR_RTL))
+else
+UNITDIR_RTL=
+endif
+endif
+ifdef UNITDIR_RTL
+override COMPILER_UNITDIR+=$(UNITDIR_RTL)
+endif
+endif
+ifndef NOCPUDEF
+override FPCOPTDEF=$(CPU_TARGET)
+endif
+ifneq ($(OS_TARGET),$(OS_SOURCE))
+override FPCOPT+=-T$(OS_TARGET)
+endif
+ifdef UNITDIR
+override FPCOPT+=$(addprefix -Fu,$(UNITDIR))
+endif
+ifdef LIBDIR
+override FPCOPT+=$(addprefix -Fl,$(LIBDIR))
+endif
+ifdef OBJDIR
+override FPCOPT+=$(addprefix -Fo,$(OBJDIR))
+endif
+ifdef INCDIR
+override FPCOPT+=$(addprefix -Fi,$(INCDIR))
+endif
+ifdef LINKSMART
+override FPCOPT+=-XX
+endif
+ifdef CREATESMART
+override FPCOPT+=-CX
+endif
+ifdef DEBUG
+override FPCOPT+=-gl
+override FPCOPTDEF+=DEBUG
+endif
+ifdef RELEASE
+ifeq ($(CPU_TARGET),i386)
+FPCCPUOPT:=-OG2p3
+else
+FPCCPUOPT:=
+endif
+override FPCOPT+=-Xs $(FPCCPUOPT) -n
+override FPCOPTDEF+=RELEASE
+endif
+ifdef STRIP
+override FPCOPT+=-Xs
+endif
+ifdef OPTIMIZE
+ifeq ($(CPU_TARGET),i386)
+override FPCOPT+=-OG2p3
+endif
+endif
+ifdef VERBOSE
+override FPCOPT+=-vwni
+endif
+ifdef COMPILER_OPTIONS
+override FPCOPT+=$(COMPILER_OPTIONS)
+endif
+ifdef COMPILER_UNITDIR
+override FPCOPT+=$(addprefix -Fu,$(COMPILER_UNITDIR))
+endif
+ifdef COMPILER_LIBRARYDIR
+override FPCOPT+=$(addprefix -Fl,$(COMPILER_LIBRARYDIR))
+endif
+ifdef COMPILER_OBJECTDIR
+override FPCOPT+=$(addprefix -Fo,$(COMPILER_OBJECTDIR))
+endif
+ifdef COMPILER_INCLUDEDIR
+override FPCOPT+=$(addprefix -Fi,$(COMPILER_INCLUDEDIR))
+endif
+ifdef CROSSBINDIR
+override FPCOPT+=-FD$(CROSSBINDIR)
+endif
+ifdef COMPILER_TARGETDIR
+override FPCOPT+=-FE$(COMPILER_TARGETDIR)
+ifeq ($(COMPILER_TARGETDIR),.)
+override TARGETDIRPREFIX=
+else
+override TARGETDIRPREFIX=$(COMPILER_TARGETDIR)/
+endif
+endif
+ifdef COMPILER_UNITTARGETDIR
+override FPCOPT+=-FU$(COMPILER_UNITTARGETDIR)
+ifeq ($(COMPILER_UNITTARGETDIR),.)
+override UNITTARGETDIRPREFIX=
+else
+override UNITTARGETDIRPREFIX=$(COMPILER_UNITTARGETDIR)/
+endif
+else
+ifdef COMPILER_TARGETDIR
+override COMPILER_UNITTARGETDIR=$(COMPILER_TARGETDIR)
+override UNITTARGETDIRPREFIX=$(TARGETDIRPREFIX)
+endif
+endif
+ifdef GCCLIBDIR
+override FPCOPT+=-Fl$(GCCLIBDIR)
+endif
+ifdef OTHERLIBDIR
+override FPCOPT+=$(addprefix -Fl,$(OTHERLIBDIR))
+endif
+ifdef OPT
+override FPCOPT+=$(OPT)
+endif
+ifdef FPCOPTDEF
+override FPCOPT+=$(addprefix -d,$(FPCOPTDEF))
+endif
+ifdef CFGFILE
+override FPCOPT+=@$(CFGFILE)
+endif
+ifdef USEENV
+override FPCEXTCMD:=$(FPCOPT)
+override FPCOPT:=!FPCEXTCMD
+export FPCEXTCMD
+endif
+override COMPILER:=$(FPC) $(FPCOPT)
+ifeq (,$(findstring -s ,$(COMPILER)))
+EXECPPAS=
+else
+ifeq ($(OS_SOURCE),$(OS_TARGET))
+EXECPPAS:=@$(PPAS)
+endif
+endif
+.PHONY: fpc_units
+ifdef TARGET_UNITS
+override ALLTARGET+=fpc_units
+override UNITPPUFILES=$(addsuffix $(PPUEXT),$(TARGET_UNITS))
+override IMPLICITUNITPPUFILES=$(addsuffix $(PPUEXT),$(TARGET_IMPLICITUNITS))
+override INSTALLPPUFILES+=$(UNITPPUFILES) $(IMPLICITUNITPPUFILES)
+override CLEANPPUFILES+=$(UNITPPUFILES) $(IMPLICITUNITPPUFILES)
+endif
+fpc_units: $(UNITPPUFILES)
+ifdef TARGET_RSTS
+override RSTFILES=$(addsuffix $(RSTEXT),$(TARGET_RSTS))
+override CLEANRSTFILES+=$(RSTFILES)
+endif
+.PHONY: fpc_examples
+ifdef TARGET_EXAMPLES
+HASEXAMPLES=1
+override EXAMPLESOURCEFILES:=$(wildcard $(addsuffix .pp,$(TARGET_EXAMPLES)) $(addsuffix .pas,$(TARGET_EXAMPLES)))
+override EXAMPLEFILES:=$(addsuffix $(EXEEXT),$(TARGET_EXAMPLES))
+override EXAMPLEOFILES:=$(addsuffix $(OEXT),$(TARGET_EXAMPLES)) $(addprefix $(STATICLIBPREFIX),$(addsuffix $(STATICLIBEXT),$(TARGET_EXAMPLES)))
+override CLEANEXEFILES+=$(EXAMPLEFILES) $(EXAMPLEOFILES)
+ifeq ($(OS_TARGET),os2)
+override CLEANEXEFILES+=$(addsuffix $(AOUTEXT),$(TARGET_EXAMPLES))
+endif
+endif
+ifdef TARGET_EXAMPLEDIRS
+HASEXAMPLES=1
+endif
+fpc_examples: all $(EXAMPLEFILES) $(addsuffix _all,$(TARGET_EXAMPLEDIRS))
+.PHONY: fpc_all fpc_smart fpc_debug fpc_release
+$(FPCMADE): $(ALLTARGET)
+	@$(ECHOREDIR) Compiled > $(FPCMADE)
+fpc_all: $(FPCMADE)
+fpc_smart:
+	$(MAKE) all LINKSMART=1 CREATESMART=1
+fpc_debug:
+	$(MAKE) all DEBUG=1
+fpc_release:
+	$(MAKE) all RELEASE=1
+.SUFFIXES: $(EXEEXT) $(PPUEXT) $(OEXT) .pas .pp .rc .res
+%$(PPUEXT): %.pp
+	$(COMPILER) $<
+	$(EXECPPAS)
+%$(PPUEXT): %.pas
+	$(COMPILER) $<
+	$(EXECPPAS)
+%$(EXEEXT): %.pp
+	$(COMPILER) $<
+	$(EXECPPAS)
+%$(EXEEXT): %.pas
+	$(COMPILER) $<
+	$(EXECPPAS)
+%.res: %.rc
+	windres -i $< -o $@
+vpath %.pp $(COMPILER_SOURCEDIR) $(COMPILER_INCLUDEDIR)
+vpath %.pas $(COMPILER_SOURCEDIR) $(COMPILER_INCLUDEDIR)
+vpath %$(PPUEXT) $(COMPILER_UNITTARGETDIR)
+.PHONY: fpc_install fpc_sourceinstall fpc_exampleinstall
+ifdef INSTALL_UNITS
+override INSTALLPPUFILES+=$(addsuffix $(PPUEXT),$(INSTALL_UNITS))
+endif
+ifdef INSTALL_BUILDUNIT
+override INSTALLPPUFILES:=$(filter-out $(INSTALL_BUILDUNIT),$(INSTALLPPUFILES))
+endif
+ifdef INSTALLPPUFILES
+override INSTALLPPULINKFILES:=$(subst $(PPUEXT),$(OEXT),$(INSTALLPPUFILES)) $(addprefix $(STATICLIBPREFIX),$(subst $(PPUEXT),$(STATICLIBEXT),$(INSTALLPPUFILES)))
+override INSTALLPPUFILES:=$(addprefix $(UNITTARGETDIRPREFIX),$(INSTALLPPUFILES))
+override INSTALLPPULINKFILES:=$(wildcard $(addprefix $(UNITTARGETDIRPREFIX),$(INSTALLPPULINKFILES)))
+override INSTALL_CREATEPACKAGEFPC=1
+endif
+ifdef INSTALLEXEFILES
+override INSTALLEXEFILES:=$(addprefix $(TARGETDIRPREFIX),$(INSTALLEXEFILES))
+endif
+fpc_install: all $(INSTALLTARGET)
+ifdef INSTALLEXEFILES
+	$(MKDIR) $(INSTALL_BINDIR)
+ifdef UPXPROG
+	-$(UPXPROG) $(INSTALLEXEFILES)
+endif
+	$(INSTALLEXE) $(INSTALLEXEFILES) $(INSTALL_BINDIR)
+endif
+ifdef INSTALL_CREATEPACKAGEFPC
+ifdef FPCMAKE
+ifdef PACKAGE_VERSION
+ifneq ($(wildcard Makefile.fpc),)
+	$(FPCMAKE) -p -T$(OS_TARGET) Makefile.fpc
+	$(MKDIR) $(INSTALL_UNITDIR)
+	$(INSTALL) Package.fpc $(INSTALL_UNITDIR)
+endif
+endif
+endif
+endif
+ifdef INSTALLPPUFILES
+	$(MKDIR) $(INSTALL_UNITDIR)
+	$(INSTALL) $(INSTALLPPUFILES) $(INSTALL_UNITDIR)
+ifneq ($(INSTALLPPULINKFILES),)
+	$(INSTALL) $(INSTALLPPULINKFILES) $(INSTALL_UNITDIR)
+endif
+ifneq ($(wildcard $(LIB_FULLNAME)),)
+	$(MKDIR) $(INSTALL_LIBDIR)
+	$(INSTALL) $(LIB_FULLNAME) $(INSTALL_LIBDIR)
+ifdef inUnix
+	ln -sf $(LIB_FULLNAME) $(INSTALL_LIBDIR)/$(LIB_NAME)
+endif
+endif
+endif
+ifdef INSTALL_FILES
+	$(MKDIR) $(INSTALL_DATADIR)
+	$(INSTALL) $(INSTALL_FILES) $(INSTALL_DATADIR)
+endif
+fpc_sourceinstall: distclean
+	$(MKDIR) $(INSTALL_SOURCEDIR)
+	$(COPYTREE) $(BASEDIR) $(INSTALL_SOURCEDIR)
+fpc_exampleinstall: $(addsuffix _distclean,$(TARGET_EXAMPLEDIRS))
+ifdef HASEXAMPLES
+	$(MKDIR) $(INSTALL_EXAMPLEDIR)
+endif
+ifdef EXAMPLESOURCEFILES
+	$(COPY) $(EXAMPLESOURCEFILES) $(INSTALL_EXAMPLEDIR)
+endif
+ifdef TARGET_EXAMPLEDIRS
+	$(COPYTREE) $(addsuffix /*,$(TARGET_EXAMPLEDIRS)) $(INSTALL_EXAMPLEDIR)
+endif
+.PHONY: fpc_distinstall
+fpc_distinstall: install exampleinstall
+.PHONY: fpc_zipinstall fpc_zipsourceinstall fpc_zipexampleinstall
+ifndef PACKDIR
+ifndef inUnix
+PACKDIR=$(BASEDIR)/../fpc-pack
+else
+PACKDIR=/tmp/fpc-pack
+endif
+endif
+ifndef ZIPNAME
+ifdef DIST_ZIPNAME
+ZIPNAME=$(DIST_ZIPNAME)
+else
+ZIPNAME=$(ZIPPREFIX)$(PACKAGE_NAME)$(ZIPSUFFIX)
+endif
+endif
+ifndef ZIPTARGET
+ifdef DIST_ZIPTARGET
+ZIPTARGET=DIST_ZIPTARGET
+else
+ZIPTARGET=install
+endif
+endif
+ifndef USEZIP
+ifdef inUnix
+USETAR=1
+endif
+endif
+ifndef inUnix
+USEZIPWRAPPER=1
+endif
+ifdef USEZIPWRAPPER
+ZIPPATHSEP=$(PATHSEP)
+ZIPWRAPPER=$(subst /,$(PATHSEP),$(DIST_DESTDIR)/fpczip$(BATCHEXT))
+else
+ZIPPATHSEP=/
+endif
+ZIPCMD_CDPACK:=cd $(subst /,$(ZIPPATHSEP),$(PACKDIR))
+ZIPCMD_CDBASE:=cd $(subst /,$(ZIPPATHSEP),$(BASEDIR))
+ifdef USETAR
+ZIPDESTFILE:=$(DIST_DESTDIR)/$(ZIPNAME)$(TAREXT)
+ZIPCMD_ZIP:=$(TARPROG) cf$(TAROPT) $(ZIPDESTFILE) *
+else
+ZIPDESTFILE:=$(DIST_DESTDIR)/$(ZIPNAME)$(ZIPEXT)
+ZIPCMD_ZIP:=$(subst /,$(ZIPPATHSEP),$(ZIPPROG)) -Dr $(ZIPOPT) $(ZIPDESTFILE) *
+endif
+fpc_zipinstall:
+	$(MAKE) $(ZIPTARGET) INSTALL_PREFIX=$(PACKDIR) ZIPINSTALL=1
+	$(MKDIR) $(DIST_DESTDIR)
+	$(DEL) $(ZIPDESTFILE)
+ifdef USEZIPWRAPPER
+ifneq ($(ECHOREDIR),echo)
+	$(ECHOREDIR) -e "$(subst \,\\,$(ZIPCMD_CDPACK))" > $(ZIPWRAPPER)
+	$(ECHOREDIR) -e "$(subst \,\\,$(ZIPCMD_ZIP))" >> $(ZIPWRAPPER)
+	$(ECHOREDIR) -e "$(subst \,\\,$(ZIPCMD_CDBASE))" >> $(ZIPWRAPPER)
+else
+	echo $(ZIPCMD_CDPACK) > $(ZIPWRAPPER)
+	echo $(ZIPCMD_ZIP) >> $(ZIPWRAPPER)
+	echo $(ZIPCMD_CDBASE) >> $(ZIPWRAPPER)
+endif
+ifdef inUnix
+	/bin/sh $(ZIPWRAPPER)
+else
+	$(ZIPWRAPPER)
+endif
+	$(DEL) $(ZIPWRAPPER)
+else
+	$(ZIPCMD_CDPACK) ; $(ZIPCMD_ZIP) ; $(ZIPCMD_CDBASE)
+endif
+	$(DELTREE) $(PACKDIR)
+fpc_zipsourceinstall:
+	$(MAKE) fpc_zipinstall ZIPTARGET=sourceinstall ZIPSUFFIX=src
+fpc_zipexampleinstall:
+ifdef HASEXAMPLES
+	$(MAKE) fpc_zipinstall ZIPTARGET=exampleinstall ZIPSUFFIX=exm
+endif
+fpc_zipdistinstall:
+	$(MAKE) fpc_zipinstall ZIPTARGET=distinstall
+.PHONY: fpc_clean fpc_cleanall fpc_distclean
+ifdef EXEFILES
+override CLEANEXEFILES:=$(addprefix $(TARGETDIRPREFIX),$(CLEANEXEFILES))
+endif
+ifdef CLEAN_UNITS
+override CLEANPPUFILES+=$(addsuffix $(PPUEXT),$(CLEAN_UNITS))
+endif
+ifdef CLEANPPUFILES
+override CLEANPPULINKFILES:=$(subst $(PPUEXT),$(OEXT),$(CLEANPPUFILES)) $(addprefix $(STATICLIBPREFIX),$(subst $(PPUEXT),$(STATICLIBEXT),$(CLEANPPUFILES)))
+override CLEANPPUFILES:=$(addprefix $(UNITTARGETDIRPREFIX),$(CLEANPPUFILES))
+override CLEANPPULINKFILES:=$(wildcard $(addprefix $(UNITTARGETDIRPREFIX),$(CLEANPPULINKFILES)))
+endif
+fpc_clean: $(CLEANTARGET)
+ifdef CLEANEXEFILES
+	-$(DEL) $(CLEANEXEFILES)
+endif
+ifdef CLEANPPUFILES
+	-$(DEL) $(CLEANPPUFILES)
+endif
+ifneq ($(CLEANPPULINKFILES),)
+	-$(DEL) $(CLEANPPULINKFILES)
+endif
+ifdef CLEANRSTFILES
+	-$(DEL) $(addprefix $(UNITTARGETDIRPREFIX),$(CLEANRSTFILES))
+endif
+ifdef CLEAN_FILES
+	-$(DEL) $(CLEAN_FILES)
+endif
+ifdef LIB_NAME
+	-$(DEL) $(LIB_NAME) $(LIB_FULLNAME)
+endif
+	-$(DEL) $(FPCMADE) Package.fpc $(PPAS) script.res link.res $(FPCEXTFILE) $(REDIRFILE)
+fpc_distclean: clean
+ifdef COMPILER_UNITTARGETDIR
+TARGETDIRCLEAN=fpc_clean
+endif
+fpc_cleanall: $(CLEANTARGET) $(TARGETDIRCLEAN)
+ifdef CLEANEXEFILES
+	-$(DEL) $(CLEANEXEFILES)
+endif
+	-$(DEL) *$(OEXT) *$(PPUEXT) *$(RSTEXT) *$(ASMEXT) *$(STATICLIBEXT) *$(SHAREDLIBEXT) *$(PPLEXT)
+	-$(DELTREE) *$(SMARTEXT)
+	-$(DEL) $(FPCMADE) Package.fpc $(PPAS) script.res link.res $(FPCEXTFILE) $(REDIRFILE)
+ifdef AOUTEXT
+	-$(DEL) *$(AOUTEXT)
+endif
+.PHONY: fpc_baseinfo
+override INFORULES+=fpc_baseinfo
+fpc_baseinfo:
+	@$(ECHO)
+	@$(ECHO)  == Package info ==
+	@$(ECHO)  Package Name..... $(PACKAGE_NAME)
+	@$(ECHO)  Package Version.. $(PACKAGE_VERSION)
+	@$(ECHO)
+	@$(ECHO)  == Configuration info ==
+	@$(ECHO)
+	@$(ECHO)  FPC.......... $(FPC)
+	@$(ECHO)  FPC Version.. $(FPC_VERSION)
+	@$(ECHO)  Source CPU... $(CPU_SOURCE)
+	@$(ECHO)  Target CPU... $(CPU_TARGET)
+	@$(ECHO)  Source OS.... $(OS_SOURCE)
+	@$(ECHO)  Target OS.... $(OS_TARGET)
+	@$(ECHO)  Full Target.. $(FULL_SOURCE)
+	@$(ECHO)  Full Source.. $(FULL_TARGET)
+	@$(ECHO)
+	@$(ECHO)  == Directory info ==
+	@$(ECHO)
+	@$(ECHO)  Required pkgs... $(REQUIRE_PACKAGES)
+	@$(ECHO)
+	@$(ECHO)  Basedir......... $(BASEDIR)
+	@$(ECHO)  FPCDir.......... $(FPCDIR)
+	@$(ECHO)  CrossBinDir..... $(CROSSBINDIR)
+	@$(ECHO)  UnitsDir........ $(UNITSDIR)
+	@$(ECHO)  PackagesDir..... $(PACKAGESDIR)
+	@$(ECHO)
+	@$(ECHO)  GCC library..... $(GCCLIBDIR)
+	@$(ECHO)  Other library... $(OTHERLIBDIR)
+	@$(ECHO)
+	@$(ECHO)  == Tools info ==
+	@$(ECHO)
+	@$(ECHO)  As........ $(AS)
+	@$(ECHO)  Ld........ $(LD)
+	@$(ECHO)  Ar........ $(AR)
+	@$(ECHO)  Rc........ $(RC)
+	@$(ECHO)
+	@$(ECHO)  Mv........ $(MVPROG)
+	@$(ECHO)  Cp........ $(CPPROG)
+	@$(ECHO)  Rm........ $(RMPROG)
+	@$(ECHO)  GInstall.. $(GINSTALL)
+	@$(ECHO)  Echo...... $(ECHO)
+	@$(ECHO)  Date...... $(DATE)
+	@$(ECHO)  FPCMake... $(FPCMAKE)
+	@$(ECHO)  PPUMove... $(PPUMOVE)
+	@$(ECHO)  Upx....... $(UPXPROG)
+	@$(ECHO)  Zip....... $(ZIPPROG)
+	@$(ECHO)
+	@$(ECHO)  == Object info ==
+	@$(ECHO)
+	@$(ECHO)  Target Loaders........ $(TARGET_LOADERS)
+	@$(ECHO)  Target Units.......... $(TARGET_UNITS)
+	@$(ECHO)  Target Implicit Units. $(TARGET_IMPLICITUNITS)
+	@$(ECHO)  Target Programs....... $(TARGET_PROGRAMS)
+	@$(ECHO)  Target Dirs........... $(TARGET_DIRS)
+	@$(ECHO)  Target Examples....... $(TARGET_EXAMPLES)
+	@$(ECHO)  Target ExampleDirs.... $(TARGET_EXAMPLEDIRS)
+	@$(ECHO)
+	@$(ECHO)  Clean Units......... $(CLEAN_UNITS)
+	@$(ECHO)  Clean Files......... $(CLEAN_FILES)
+	@$(ECHO)
+	@$(ECHO)  Install Units....... $(INSTALL_UNITS)
+	@$(ECHO)  Install Files....... $(INSTALL_FILES)
+	@$(ECHO)
+	@$(ECHO)  == Install info ==
+	@$(ECHO)
+	@$(ECHO)  DateStr.............. $(DATESTR)
+	@$(ECHO)  ZipPrefix............ $(ZIPPREFIX)
+	@$(ECHO)  ZipSuffix............ $(ZIPSUFFIX)
+	@$(ECHO)  Install FPC Package.. $(INSTALL_FPCPACKAGE)
+	@$(ECHO)
+	@$(ECHO)  Install base dir..... $(INSTALL_BASEDIR)
+	@$(ECHO)  Install binary dir... $(INSTALL_BINDIR)
+	@$(ECHO)  Install library dir.. $(INSTALL_LIBDIR)
+	@$(ECHO)  Install units dir.... $(INSTALL_UNITDIR)
+	@$(ECHO)  Install source dir... $(INSTALL_SOURCEDIR)
+	@$(ECHO)  Install doc dir...... $(INSTALL_DOCDIR)
+	@$(ECHO)  Install example dir.. $(INSTALL_EXAMPLEDIR)
+	@$(ECHO)  Install data dir..... $(INSTALL_DATADIR)
+	@$(ECHO)
+	@$(ECHO)  Dist destination dir. $(DIST_DESTDIR)
+	@$(ECHO)  Dist zip name........ $(DIST_ZIPNAME)
+	@$(ECHO)
+.PHONY: fpc_info
+fpc_info: $(INFORULES)
+.PHONY: fpc_makefile fpc_makefiles fpc_makefile_sub1 fpc_makefile_sub2 \
+	fpc_makefile_dirs
+fpc_makefile:
+	$(FPCMAKE) -w -T$(OS_TARGET) Makefile.fpc
+fpc_makefile_sub1:
+ifdef TARGET_DIRS
+	$(FPCMAKE) -w -T$(OS_TARGET) $(addsuffix /Makefile.fpc,$(TARGET_DIRS))
+endif
+ifdef TARGET_EXAMPLEDIRS
+	$(FPCMAKE) -w -T$(OS_TARGET) $(addsuffix /Makefile.fpc,$(TARGET_EXAMPLEDIRS))
+endif
+fpc_makefile_sub2: $(addsuffix _makefile_dirs,$(TARGET_DIRS) $(TARGET_EXAMPLEDIRS))
+fpc_makefile_dirs: fpc_makefile_sub1 fpc_makefile_sub2
+fpc_makefiles: fpc_makefile fpc_makefile_dirs
+TARGET_EXAMPLEDIRS_EXAMPLE=1
+ifdef TARGET_EXAMPLEDIRS_EXAMPLE
+example_all:
+	$(MAKE) -C example all
+example_debug:
+	$(MAKE) -C example debug
+example_smart:
+	$(MAKE) -C example smart
+example_release:
+	$(MAKE) -C example release
+example_examples:
+	$(MAKE) -C example examples
+example_shared:
+	$(MAKE) -C example shared
+example_install:
+	$(MAKE) -C example install
+example_sourceinstall:
+	$(MAKE) -C example sourceinstall
+example_exampleinstall:
+	$(MAKE) -C example exampleinstall
+example_distinstall:
+	$(MAKE) -C example distinstall
+example_zipinstall:
+	$(MAKE) -C example zipinstall
+example_zipsourceinstall:
+	$(MAKE) -C example zipsourceinstall
+example_zipexampleinstall:
+	$(MAKE) -C example zipexampleinstall
+example_zipdistinstall:
+	$(MAKE) -C example zipdistinstall
+example_clean:
+	$(MAKE) -C example clean
+example_distclean:
+	$(MAKE) -C example distclean
+example_cleanall:
+	$(MAKE) -C example cleanall
+example_info:
+	$(MAKE) -C example info
+example_makefiles:
+	$(MAKE) -C example makefiles
+example:
+	$(MAKE) -C example all
+.PHONY: example_all example_debug example_smart example_release example_examples example_shared example_install example_sourceinstall example_exampleinstall example_distinstall example_zipinstall example_zipsourceinstall example_zipexampleinstall example_zipdistinstall example_clean example_distclean example_cleanall example_info example_makefiles example
+endif
+all: fpc_all
+debug: fpc_debug
+smart: fpc_smart
+release: fpc_release
+examples: fpc_examples
+shared:
+install: fpc_install
+sourceinstall: fpc_sourceinstall
+exampleinstall: fpc_exampleinstall
+distinstall: fpc_distinstall
+zipinstall: fpc_zipinstall
+zipsourceinstall: fpc_zipsourceinstall
+zipexampleinstall: fpc_zipexampleinstall
+zipdistinstall: fpc_zipdistinstall
+clean: fpc_clean $(addsuffix _clean,$(TARGET_EXAMPLEDIRS))
+distclean: fpc_distclean
+cleanall: fpc_cleanall
+info: fpc_info
+makefiles: fpc_makefiles
+.PHONY: all debug smart release examples shared install sourceinstall exampleinstall distinstall zipinstall zipsourceinstall zipexampleinstall zipdistinstall clean distclean cleanall info makefiles
+ifneq ($(wildcard fpcmake.loc),)
+include fpcmake.loc
+endif

+ 25 - 0
packages/base/oracle/Makefile.fpc

@@ -0,0 +1,25 @@
+#
+#  Makefile.fpc for oracle units
+#
+
+[package]
+name=oracle
+version=1.0.6
+
+[target]
+units=oraoci
+exampledirs=example
+
+[require]
+libc=y
+
+[install]
+fpcpackage=y
+
+[default]
+fpcdir=../../..
+
+# in libdir variable must be path to libraries
+# libclntsh.*,libnlsrtl3.*
+#[compiler]
+#libdir=/usr/local/oracle8cli/lib

+ 20 - 0
packages/base/oracle/README

@@ -0,0 +1,20 @@
+  These units provides interface to Oracle Call Interface.
+Object workaround (TOraDatabase etc...) is on the way.
+
+  Unit oraclew contains some procedures and functions,
+which makes usage of oraoci not so painfull... But - 
+if you wanna to program in RAW OCI, you really can ;)
+
+To compile you need oracle server installed, these units
+was tested and performed on Oracle 8.0.1.5 Standard
+server. One developer license of Oracle server is free
+of charge...
+
+You need to have oracle lib directory in ldpath, too,
+or you can this path set in Makefile.fpc (is commented
+there)
+
+After all this, run 'make examples' and enjoy!
+
+Pavel Stingl
[email protected]

+ 1341 - 0
packages/base/oracle/example/Makefile

@@ -0,0 +1,1341 @@
+#
+# Don't edit, this file is generated by FPCMake Version 1.1 [2002/01/29]
+#
+default: all
+MAKEFILETARGETS=linux go32v2 win32 os2 freebsd beos netbsd amiga atari sunos qnx
+override PATH:=$(subst \,/,$(PATH))
+ifeq ($(findstring ;,$(PATH)),)
+inUnix=1
+SEARCHPATH:=$(filter-out .,$(subst :, ,$(PATH)))
+else
+SEARCHPATH:=$(subst ;, ,$(PATH))
+endif
+PWD:=$(strip $(wildcard $(addsuffix /pwd.exe,$(SEARCHPATH))))
+ifeq ($(PWD),)
+PWD:=$(strip $(wildcard $(addsuffix /pwd,$(SEARCHPATH))))
+ifeq ($(PWD),)
+$(error You need the GNU utils package to use this Makefile)
+else
+PWD:=$(firstword $(PWD))
+SRCEXEEXT=
+endif
+else
+PWD:=$(firstword $(PWD))
+SRCEXEEXT=.exe
+endif
+ifndef inUnix
+ifeq ($(OS),Windows_NT)
+inWinNT=1
+else
+ifdef OS2_SHELL
+inOS2=1
+endif
+endif
+else
+ifneq ($(findstring cygwin,$(MACHTYPE)),)
+inCygWin=1
+endif
+endif
+ifeq ($(OS_TARGET),freebsd)
+BSDhier=1
+endif
+ifeq ($(OS_TARGET),netbsd)
+BSDhier=1
+endif
+ifdef inUnix
+BATCHEXT=.sh
+else
+ifdef inOS2
+BATCHEXT=.cmd
+else
+BATCHEXT=.bat
+endif
+endif
+ifdef inUnix
+PATHSEP=/
+else
+PATHSEP:=$(subst /,\,/)
+endif
+ifdef PWD
+BASEDIR:=$(subst \,/,$(shell $(PWD)))
+ifdef inCygWin
+ifneq ($(findstring /cygdrive/,$(BASEDIR)),)
+BASENODIR:=$(patsubst /cygdrive%,%,$(BASEDIR))
+BASEDRIVE:=$(firstword $(subst /, ,$(BASENODIR)))
+BASEDIR:=$(subst /cygdrive/$(BASEDRIVE)/,$(BASEDRIVE):/,$(BASEDIR))
+endif
+endif
+else
+BASEDIR=.
+endif
+override DEFAULT_FPCDIR=../../../..
+ifndef FPC
+ifdef PP
+FPC=$(PP)
+endif
+endif
+ifndef FPC
+FPCPROG:=$(strip $(wildcard $(addsuffix /fpc$(SRCEXEEXT),$(SEARCHPATH))))
+ifneq ($(FPCPROG),)
+FPCPROG:=$(firstword $(FPCPROG))
+FPC:=$(shell $(FPCPROG) -PB)
+ifneq ($(findstring Error,$(FPC)),)
+override FPC=ppc386
+endif
+else
+override FPC=ppc386
+endif
+endif
+override FPC:=$(subst $(SRCEXEEXT),,$(FPC))
+override FPC:=$(subst \,/,$(FPC))$(SRCEXEEXT)
+ifndef FPC_VERSION
+FPC_VERSION:=$(shell $(FPC) -iV)
+endif
+export FPC FPC_VERSION
+ifeq ($(findstring 1.0.,$(FPC_VERSION)),)
+COMPILERINFO:=$(shell $(FPC) -iSP -iTP -iSO -iTO)
+ifndef CPU_SOURCE
+CPU_SOURCE:=$(word 1,$(COMPILERINFO))
+endif
+ifndef CPU_TARGET
+CPU_TARGET:=$(word 2,$(COMPILERINFO))
+endif
+ifndef OS_SOURCE
+OS_SOURCE:=$(word 3,$(COMPILERINFO))
+endif
+ifndef OS_TARGET
+OS_TARGET:=$(word 4,$(COMPILERINFO))
+endif
+else
+ifndef CPU_SOURCE
+CPU_SOURCE:=$(shell $(FPC) -iSP)
+endif
+ifndef CPU_TARGET
+CPU_TARGET:=$(shell $(FPC) -iTP)
+endif
+ifndef OS_SOURCE
+OS_SOURCE:=$(shell $(FPC) -iSO)
+endif
+ifndef OS_TARGET
+OS_TARGET:=$(shell $(FPC) -iTO)
+endif
+endif
+FULL_TARGET=$(CPU_TARGET)-$(OS_TARGET)
+FULL_SOURCE=$(CPU_SOURCE)-$(OS_SOURCE)
+ifneq ($(FULL_TARGET),$(FULL_SOURCE))
+CROSSCOMPILE=1
+endif
+ifeq ($(findstring makefile,$(MAKECMDGOALS)),)
+ifeq ($(findstring $(OS_TARGET),$(MAKEFILETARGETS)),)
+$(error The Makefile doesn't support target $(OS_TARGET), please run fpcmake first)
+endif
+endif
+export OS_TARGET OS_SOURCE CPU_TARGET CPU_SOURCE FULL_TARGET FULL_SOURCE CROSSCOMPILE
+ifdef FPCDIR
+override FPCDIR:=$(subst \,/,$(FPCDIR))
+ifeq ($(wildcard $(addprefix $(FPCDIR)/,rtl units)),)
+override FPCDIR=wrong
+endif
+else
+override FPCDIR=wrong
+endif
+ifdef DEFAULT_FPCDIR
+ifeq ($(FPCDIR),wrong)
+override FPCDIR:=$(subst \,/,$(DEFAULT_FPCDIR))
+ifeq ($(wildcard $(addprefix $(FPCDIR)/,rtl units)),)
+override FPCDIR=wrong
+endif
+endif
+endif
+ifeq ($(FPCDIR),wrong)
+ifdef inUnix
+override FPCDIR=/usr/local/lib/fpc/$(FPC_VERSION)
+ifeq ($(wildcard $(FPCDIR)/units),)
+override FPCDIR=/usr/lib/fpc/$(FPC_VERSION)
+endif
+else
+override FPCDIR:=$(subst /$(FPC),,$(firstword $(strip $(wildcard $(addsuffix /$(FPC),$(SEARCHPATH))))))
+override FPCDIR:=$(FPCDIR)/..
+ifeq ($(wildcard $(addprefix $(FPCDIR)/,rtl units)),)
+override FPCDIR:=$(FPCDIR)/..
+ifeq ($(wildcard $(addprefix $(FPCDIR)/,rtl units)),)
+override FPCDIR=c:/pp
+endif
+endif
+endif
+endif
+ifndef CROSSDIR
+CROSSDIR:=$(FPCDIR)/cross/$(FULL_TARGET)
+endif
+ifndef CROSSTARGETDIR
+CROSSTARGETDIR=$(CROSSDIR)/$(FULL_TARGET)
+endif
+ifdef CROSSCOMPILE
+UNITSDIR:=$(wildcard $(CROSSTARGETDIR)/units)
+ifeq ($(UNITSDIR),)
+UNITSDIR:=$(wildcard $(FPCDIR)/units/$(OS_TARGET))
+endif
+else
+UNITSDIR:=$(wildcard $(FPCDIR)/units/$(OS_TARGET))
+endif
+PACKAGESDIR:=$(wildcard $(FPCDIR) $(FPCDIR)/packages/base $(FPCDIR)/packages/extra)
+override TARGET_UNITS+=oraclew
+override TARGET_EXAMPLES+=test01
+override INSTALL_FPCPACKAGE=y
+ifdef REQUIRE_UNITSDIR
+override UNITSDIR+=$(REQUIRE_UNITSDIR)
+endif
+ifdef REQUIRE_PACKAGESDIR
+override PACKAGESDIR+=$(REQUIRE_PACKAGESDIR)
+endif
+ifdef ZIPINSTALL
+ifeq ($(OS_TARGET),linux)
+UNIXINSTALLDIR=1
+endif
+ifeq ($(OS_TARGET),freebsd)
+UNIXINSTALLDIR=1
+endif
+ifeq ($(OS_TARGET),netbsd)
+UNIXINSTALLDIR=1
+endif
+ifeq ($(OS_TARGET),sunos)
+UNIXINSTALLDIR=1
+endif
+else
+ifeq ($(OS_SOURCE),linux)
+UNIXINSTALLDIR=1
+endif
+ifeq ($(OS_SOURCE),freebsd)
+UNIXINSTALLDIR=1
+endif
+ifeq ($(OS_SOURCE),netbsd)
+UNIXINSTALLDIR=1
+endif
+ifeq ($(OS_TARGET),sunos)
+UNIXINSTALLDIR=1
+endif
+endif
+ifndef INSTALL_PREFIX
+ifdef PREFIX
+INSTALL_PREFIX=$(PREFIX)
+endif
+endif
+ifndef INSTALL_PREFIX
+ifdef UNIXINSTALLDIR
+INSTALL_PREFIX=/usr/local
+else
+ifdef INSTALL_FPCPACKAGE
+INSTALL_BASEDIR:=/pp
+else
+INSTALL_BASEDIR:=/$(PACKAGE_NAME)
+endif
+endif
+endif
+export INSTALL_PREFIX
+ifndef DIST_DESTDIR
+DIST_DESTDIR:=$(BASEDIR)
+endif
+export DIST_DESTDIR
+ifndef INSTALL_BASEDIR
+ifdef UNIXINSTALLDIR
+ifdef INSTALL_FPCPACKAGE
+INSTALL_BASEDIR:=$(INSTALL_PREFIX)/lib/fpc/$(FPC_VERSION)
+else
+INSTALL_BASEDIR:=$(INSTALL_PREFIX)/lib/$(PACKAGE_NAME)
+endif
+else
+INSTALL_BASEDIR:=$(INSTALL_PREFIX)
+endif
+endif
+ifndef INSTALL_BINDIR
+ifdef UNIXINSTALLDIR
+INSTALL_BINDIR:=$(INSTALL_PREFIX)/bin
+else
+INSTALL_BINDIR:=$(INSTALL_BASEDIR)/bin
+ifdef INSTALL_FPCPACKAGE
+INSTALL_BINDIR:=$(INSTALL_BINDIR)/$(OS_TARGET)
+endif
+endif
+endif
+ifndef INSTALL_UNITDIR
+ifdef CROSSCOMPILE
+INSTALL_UNITDIR:=$(INSTALL_BASEDIR)/cross/$(FULL_TARGET)/units
+else
+INSTALL_UNITDIR:=$(INSTALL_BASEDIR)/units/$(OS_TARGET)
+endif
+ifdef INSTALL_FPCPACKAGE
+ifdef PACKAGE_NAME
+INSTALL_UNITDIR:=$(INSTALL_UNITDIR)/$(PACKAGE_NAME)
+endif
+endif
+endif
+ifndef INSTALL_LIBDIR
+ifdef UNIXINSTALLDIR
+INSTALL_LIBDIR:=$(INSTALL_PREFIX)/lib
+else
+INSTALL_LIBDIR:=$(INSTALL_UNITDIR)
+endif
+endif
+ifndef INSTALL_SOURCEDIR
+ifdef UNIXINSTALLDIR
+ifdef INSTALL_FPCPACKAGE
+ifdef BSDhier
+INSTALL_SOURCEDIR:=$(INSTALL_PREFIX)/share/src/fpc-$(FPC_VERSION)/$(PACKAGE_NAME)
+else
+INSTALL_SOURCEDIR:=$(INSTALL_PREFIX)/src/fpc-$(FPC_VERSION)/$(PACKAGE_NAME)
+endif
+else
+ifdef BSDhier
+INSTALL_SOURCEDIR:=$(INSTALL_PREFIX)/share/src/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
+else
+INSTALL_SOURCEDIR:=$(INSTALL_PREFIX)/src/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
+endif
+endif
+else
+ifdef INSTALL_FPCPACKAGE
+INSTALL_SOURCEDIR:=$(INSTALL_BASEDIR)/source/$(PACKAGE_NAME)
+else
+INSTALL_SOURCEDIRL:=$(INSTALL_BASEDIR)/source
+endif
+endif
+endif
+ifndef INSTALL_DOCDIR
+ifdef UNIXINSTALLDIR
+ifdef INSTALL_FPCPACKAGE
+ifdef BSDhier
+INSTALL_DOCDIR:=$(INSTALL_PREFIX)/share/doc/fpc-$(FPC_VERSION)/$(PACKAGE_NAME)
+else
+INSTALL_DOCDIR:=$(INSTALL_PREFIX)/doc/fpc-$(FPC_VERSION)/$(PACKAGE_NAME)
+endif
+else
+ifdef BSDhier
+INSTALL_DOCDIR:=$(INSTALL_PREFIX)/share/doc/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
+else
+INSTALL_DOCDIR:=$(INSTALL_PREFIX)/doc/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
+endif
+endif
+else
+ifdef INSTALL_FPCPACKAGE
+INSTALL_DOCDIR:=$(INSTALL_BASEDIR)/doc/$(PACKAGE_NAME)
+else
+INSTALL_DOCDIR:=$(INSTALL_BASEDIR)/doc
+endif
+endif
+endif
+ifndef INSTALL_EXAMPLEDIR
+ifdef UNIXINSTALLDIR
+ifdef INSTALL_FPCPACKAGE
+ifdef BSDhier
+INSTALL_EXAMPLEDIR:=$(INSTALL_PREFIX)/share/examples/fpc-$(FPC_VERSION)/$(PACKAGE_NAME)
+else
+INSTALL_EXAMPLEDIR:=$(INSTALL_PREFIX)/doc/fpc-$(FPC_VERSION)/examples/$(PACKAGE_NAME)
+endif
+else
+ifdef BSDhier
+INSTALL_EXAMPLEDIR:=$(INSTALL_PREFIX)/share/examples/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
+else
+INSTALL_EXAMPLEDIR:=$(INSTALL_PREFIX)/doc/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
+endif
+endif
+else
+ifdef INSTALL_FPCPACKAGE
+INSTALL_EXAMPLEDIR:=$(INSTALL_BASEDIR)/examples/$(PACKAGE_NAME)
+else
+INSTALL_EXAMPLEDIR:=$(INSTALL_BASEDIR)/examples
+endif
+endif
+endif
+ifndef INSTALL_DATADIR
+INSTALL_DATADIR=$(INSTALL_BASEDIR)
+endif
+ifdef CROSSCOMPILE
+ifndef CROSSBINDIR
+CROSSBINDIR:=$(wildcard $(CROSSTARGETDIR)/bin/$(FULL_SOURCE))
+ifeq ($(CROSSBINDIR),)
+CROSSBINDIR:=$(wildcard $(INSTALL_BASEDIR)/cross/$(FULL_TARGET)/bin/$(FULL_SOURCE))
+endif
+endif
+else
+CROSSBINDIR=
+endif
+ifdef inUnix
+ifndef GCCLIBDIR
+GCCLIBDIR:=$(shell dirname `(gcc -v 2>&1)| head -n 1| awk '{ print $$4 } '`)
+endif
+ifeq ($(OS_TARGET),linux)
+ifndef OTHERLIBDIR
+OTHERLIBDIR:=$(shell grep -v "^\#" /etc/ld.so.conf | awk '{ ORS=" "; print $1 }')
+endif
+endif
+ifeq ($(OS_TARGET),netbsd)
+OTHERLIBDIR+=/usr/pkg/lib
+endif
+export GCCLIBDIR OTHERLIB
+endif
+LOADEREXT=.as
+EXEEXT=.exe
+PPLEXT=.ppl
+PPUEXT=.ppu
+OEXT=.o
+ASMEXT=.s
+SMARTEXT=.sl
+STATICLIBEXT=.a
+SHAREDLIBEXT=.so
+STATICLIBPREFIX=libp
+RSTEXT=.rst
+FPCMADE=fpcmade
+ifeq ($(OS_TARGET),go32v1)
+PPUEXT=.pp1
+OEXT=.o1
+ASMEXT=.s1
+SMARTEXT=.sl1
+STATICLIBEXT=.a1
+SHAREDLIBEXT=.so1
+STATICLIBPREFIX=
+FPCMADE=fpcmade.v1
+PACKAGESUFFIX=v1
+endif
+ifeq ($(OS_TARGET),go32v2)
+STATICLIBPREFIX=
+FPCMADE=fpcmade.dos
+ZIPSUFFIX=go32
+endif
+ifeq ($(OS_TARGET),linux)
+EXEEXT=
+HASSHAREDLIB=1
+FPCMADE=fpcmade.lnx
+ZIPSUFFIX=linux
+endif
+ifeq ($(OS_TARGET),freebsd)
+EXEEXT=
+HASSHAREDLIB=1
+FPCMADE=fpcmade.freebsd
+ZIPSUFFIX=freebsd
+endif
+ifeq ($(OS_TARGET),netbsd)
+EXEEXT=
+HASSHAREDLIB=1
+FPCMADE=fpcmade.netbsd
+ZIPSUFFIX=netbsd
+endif
+ifeq ($(OS_TARGET),win32)
+PPUEXT=.ppw
+OEXT=.ow
+ASMEXT=.sw
+SMARTEXT=.slw
+STATICLIBEXT=.aw
+SHAREDLIBEXT=.dll
+FPCMADE=fpcmade.w32
+ZIPSUFFIX=w32
+endif
+ifeq ($(OS_TARGET),os2)
+PPUEXT=.ppo
+ASMEXT=.so2
+OEXT=.oo2
+AOUTEXT=.out
+SMARTEXT=.so
+STATICLIBEXT=.ao2
+SHAREDLIBEXT=.dll
+FPCMADE=fpcmade.os2
+ZIPSUFFIX=emx
+endif
+ifeq ($(OS_TARGET),amiga)
+EXEEXT=
+PPUEXT=.ppa
+ASMEXT=.asm
+OEXT=.o
+SMARTEXT=.sl
+STATICLIBEXT=.a
+SHAREDLIBEXT=.library
+FPCMADE=fpcmade.amg
+endif
+ifeq ($(OS_TARGET),atari)
+PPUEXT=.ppt
+ASMEXT=.s
+OEXT=.o
+SMARTEXT=.sl
+STATICLIBEXT=.a
+EXEEXT=.ttp
+FPCMADE=fpcmade.ata
+endif
+ifeq ($(OS_TARGET),beos)
+PPUEXT=.ppu
+ASMEXT=.s
+OEXT=.o
+SMARTEXT=.sl
+STATICLIBEXT=.a
+EXEEXT=
+FPCMADE=fpcmade.be
+ZIPSUFFIX=be
+endif
+ifeq ($(OS_TARGET),sunos)
+PPUEXT=.ppu
+ASMEXT=.s
+OEXT=.o
+SMARTEXT=.sl
+STATICLIBEXT=.a
+EXEEXT=
+FPCMADE=fpcmade.sun
+ZIPSUFFIX=sun
+endif
+ifeq ($(OS_TARGET),qnx)
+PPUEXT=.ppu
+ASMEXT=.s
+OEXT=.o
+SMARTEXT=.sl
+STATICLIBEXT=.a
+EXEEXT=
+FPCMADE=fpcmade.qnx
+ZIPSUFFIX=qnx
+endif
+ifndef ECHO
+ECHO:=$(strip $(wildcard $(addsuffix /gecho$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(ECHO),)
+ECHO:=$(strip $(wildcard $(addsuffix /echo$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(ECHO),)
+ECHO=
+else
+ECHO:=$(firstword $(ECHO))
+endif
+else
+ECHO:=$(firstword $(ECHO))
+endif
+endif
+export ECHO
+ifndef DATE
+DATE:=$(strip $(wildcard $(addsuffix /gdate$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(DATE),)
+DATE:=$(strip $(wildcard $(addsuffix /date$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(DATE),)
+DATE=
+else
+DATE:=$(firstword $(DATE))
+endif
+else
+DATE:=$(firstword $(DATE))
+endif
+endif
+export DATE
+ifndef GINSTALL
+GINSTALL:=$(strip $(wildcard $(addsuffix /ginstall$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(GINSTALL),)
+GINSTALL:=$(strip $(wildcard $(addsuffix /install$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(GINSTALL),)
+GINSTALL=
+else
+GINSTALL:=$(firstword $(GINSTALL))
+endif
+else
+GINSTALL:=$(firstword $(GINSTALL))
+endif
+endif
+export GINSTALL
+ifndef CPPROG
+CPPROG:=$(strip $(wildcard $(addsuffix /cp$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(CPPROG),)
+CPPROG=
+else
+CPPROG:=$(firstword $(CPPROG))
+endif
+endif
+export CPPROG
+ifndef RMPROG
+RMPROG:=$(strip $(wildcard $(addsuffix /rm$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(RMPROG),)
+RMPROG=
+else
+RMPROG:=$(firstword $(RMPROG))
+endif
+endif
+export RMPROG
+ifndef MVPROG
+MVPROG:=$(strip $(wildcard $(addsuffix /mv$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(MVPROG),)
+MVPROG=
+else
+MVPROG:=$(firstword $(MVPROG))
+endif
+endif
+export MVPROG
+ifndef ECHOREDIR
+ECHOREDIR:=$(subst /,$(PATHSEP),$(ECHO))
+endif
+ifndef COPY
+COPY:=$(CPPROG) -fp
+endif
+ifndef COPYTREE
+COPYTREE:=$(CPPROG) -rfp
+endif
+ifndef MOVE
+MOVE:=$(MVPROG) -f
+endif
+ifndef DEL
+DEL:=$(RMPROG) -f
+endif
+ifndef DELTREE
+DELTREE:=$(RMPROG) -rf
+endif
+ifndef INSTALL
+ifdef inUnix
+INSTALL:=$(GINSTALL) -c -m 644
+else
+INSTALL:=$(COPY)
+endif
+endif
+ifndef INSTALLEXE
+ifdef inUnix
+INSTALLEXE:=$(GINSTALL) -c -m 755
+else
+INSTALLEXE:=$(COPY)
+endif
+endif
+ifndef MKDIR
+MKDIR:=$(GINSTALL) -m 755 -d
+endif
+export ECHOREDIR COPY COPYTREE MOVE DEL DELTREE INSTALL INSTALLEXE MKDIR
+ifndef PPUMOVE
+PPUMOVE:=$(strip $(wildcard $(addsuffix /ppumove$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(PPUMOVE),)
+PPUMOVE=
+else
+PPUMOVE:=$(firstword $(PPUMOVE))
+endif
+endif
+export PPUMOVE
+ifndef FPCMAKE
+FPCMAKE:=$(strip $(wildcard $(addsuffix /fpcmake$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(FPCMAKE),)
+FPCMAKE=
+else
+FPCMAKE:=$(firstword $(FPCMAKE))
+endif
+endif
+export FPCMAKE
+ifndef ZIPPROG
+ZIPPROG:=$(strip $(wildcard $(addsuffix /zip$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(ZIPPROG),)
+ZIPPROG=
+else
+ZIPPROG:=$(firstword $(ZIPPROG))
+endif
+endif
+export ZIPPROG
+ifndef TARPROG
+TARPROG:=$(strip $(wildcard $(addsuffix /tar$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(TARPROG),)
+TARPROG=
+else
+TARPROG:=$(firstword $(TARPROG))
+endif
+endif
+export TARPROG
+ASNAME=as
+LDNAME=ld
+ARNAME=ar
+RCNAME=rc
+ifeq ($(OS_TARGET),win32)
+ASNAME=asw
+LDNAME=ldw
+ARNAME=arw
+endif
+ifndef ASPROG
+ifdef CROSSBINDIR
+ASPROG=$(CROSSBINDIR)/$(ASNAME)$(SRCEXEEXT)
+else
+ASPROG=$(ASNAME)
+endif
+endif
+ifndef LDPROG
+ifdef CROSSBINDIR
+LDPROG=$(CROSSBINDIR)/$(LDNAME)$(SRCEXEEXT)
+else
+LDPROG=$(LDNAME)
+endif
+endif
+ifndef RCPROG
+ifdef CROSSBINDIR
+RCPROG=$(CROSSBINDIR)/$(RCNAME)$(SRCEXEEXT)
+else
+RCPROG=$(RCNAME)
+endif
+endif
+ifndef ARPROG
+ifdef CROSSBINDIR
+ARPROG=$(CROSSBINDIR)/$(ARNAME)$(SRCEXEEXT)
+else
+ARPROG=$(ARNAME)
+endif
+endif
+AS=$(ASPROG)
+LD=$(LDPROG)
+RC=$(RCPROG)
+AR=$(ARPROG)
+PPAS=ppas$(BATCHEXT)
+ifdef inUnix
+LDCONFIG=ldconfig
+else
+LDCONFIG=
+endif
+ifdef DATE
+DATESTR:=$(shell $(DATE) +%Y%m%d)
+else
+DATESTR=
+endif
+ifndef UPXPROG
+ifeq ($(OS_TARGET),go32v2)
+UPXPROG:=1
+endif
+ifeq ($(OS_TARGET),win32)
+UPXPROG:=1
+endif
+ifdef UPXPROG
+UPXPROG:=$(strip $(wildcard $(addsuffix /upx$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(UPXPROG),)
+UPXPROG=
+else
+UPXPROG:=$(firstword $(UPXPROG))
+endif
+else
+UPXPROG=
+endif
+endif
+export UPXPROG
+ZIPOPT=-9
+ZIPEXT=.zip
+ifeq ($(USETAR),bz2)
+TAROPT=vI
+TAREXT=.tar.bz2
+else
+TAROPT=vz
+TAREXT=.tar.gz
+endif
+override REQUIRE_PACKAGES=rtl oracle fcl
+ifeq ($(OS_TARGET),linux)
+REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_ORACLE=1
+REQUIRE_PACKAGES_PASZLIB=1
+REQUIRE_PACKAGES_INET=1
+REQUIRE_PACKAGES_FCL=1
+REQUIRE_PACKAGES_MYSQL=1
+REQUIRE_PACKAGES_IBASE=1
+endif
+ifeq ($(OS_TARGET),go32v2)
+REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_ORACLE=1
+REQUIRE_PACKAGES_PASZLIB=1
+REQUIRE_PACKAGES_FCL=1
+endif
+ifeq ($(OS_TARGET),win32)
+REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_ORACLE=1
+REQUIRE_PACKAGES_PASZLIB=1
+REQUIRE_PACKAGES_FCL=1
+REQUIRE_PACKAGES_MYSQL=1
+REQUIRE_PACKAGES_IBASE=1
+endif
+ifeq ($(OS_TARGET),os2)
+REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_ORACLE=1
+REQUIRE_PACKAGES_PASZLIB=1
+REQUIRE_PACKAGES_FCL=1
+endif
+ifeq ($(OS_TARGET),freebsd)
+REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_ORACLE=1
+REQUIRE_PACKAGES_PASZLIB=1
+REQUIRE_PACKAGES_INET=1
+REQUIRE_PACKAGES_FCL=1
+REQUIRE_PACKAGES_MYSQL=1
+REQUIRE_PACKAGES_IBASE=1
+endif
+ifeq ($(OS_TARGET),beos)
+REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_ORACLE=1
+REQUIRE_PACKAGES_PASZLIB=1
+REQUIRE_PACKAGES_FCL=1
+endif
+ifeq ($(OS_TARGET),netbsd)
+REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_ORACLE=1
+REQUIRE_PACKAGES_PASZLIB=1
+REQUIRE_PACKAGES_INET=1
+REQUIRE_PACKAGES_FCL=1
+endif
+ifeq ($(OS_TARGET),amiga)
+REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_ORACLE=1
+REQUIRE_PACKAGES_PASZLIB=1
+REQUIRE_PACKAGES_FCL=1
+endif
+ifeq ($(OS_TARGET),atari)
+REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_ORACLE=1
+REQUIRE_PACKAGES_PASZLIB=1
+REQUIRE_PACKAGES_FCL=1
+endif
+ifeq ($(OS_TARGET),sunos)
+REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_ORACLE=1
+REQUIRE_PACKAGES_PASZLIB=1
+REQUIRE_PACKAGES_FCL=1
+endif
+ifeq ($(OS_TARGET),qnx)
+REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_ORACLE=1
+REQUIRE_PACKAGES_PASZLIB=1
+REQUIRE_PACKAGES_FCL=1
+endif
+ifdef REQUIRE_PACKAGES_RTL
+PACKAGEDIR_RTL:=$(firstword $(subst /Makefile.fpc,,$(strip $(wildcard $(addsuffix /rtl/$(OS_TARGET)/Makefile.fpc,$(PACKAGESDIR))))))
+ifneq ($(PACKAGEDIR_RTL),)
+ifneq ($(wildcard $(PACKAGEDIR_RTL)/$(OS_TARGET)),)
+UNITDIR_RTL=$(PACKAGEDIR_RTL)/$(OS_TARGET)
+else
+UNITDIR_RTL=$(PACKAGEDIR_RTL)
+endif
+else
+PACKAGEDIR_RTL=
+UNITDIR_RTL:=$(subst /Package.fpc,,$(strip $(wildcard $(addsuffix /rtl/Package.fpc,$(UNITSDIR)))))
+ifneq ($(UNITDIR_RTL),)
+UNITDIR_RTL:=$(firstword $(UNITDIR_RTL))
+else
+UNITDIR_RTL=
+endif
+endif
+ifdef UNITDIR_RTL
+override COMPILER_UNITDIR+=$(UNITDIR_RTL)
+endif
+endif
+ifdef REQUIRE_PACKAGES_ORACLE
+PACKAGEDIR_ORACLE:=$(firstword $(subst /Makefile.fpc,,$(strip $(wildcard $(addsuffix /oracle/Makefile.fpc,$(PACKAGESDIR))))))
+ifneq ($(PACKAGEDIR_ORACLE),)
+ifneq ($(wildcard $(PACKAGEDIR_ORACLE)/$(OS_TARGET)),)
+UNITDIR_ORACLE=$(PACKAGEDIR_ORACLE)/$(OS_TARGET)
+else
+UNITDIR_ORACLE=$(PACKAGEDIR_ORACLE)
+endif
+else
+PACKAGEDIR_ORACLE=
+UNITDIR_ORACLE:=$(subst /Package.fpc,,$(strip $(wildcard $(addsuffix /oracle/Package.fpc,$(UNITSDIR)))))
+ifneq ($(UNITDIR_ORACLE),)
+UNITDIR_ORACLE:=$(firstword $(UNITDIR_ORACLE))
+else
+UNITDIR_ORACLE=
+endif
+endif
+ifdef UNITDIR_ORACLE
+override COMPILER_UNITDIR+=$(UNITDIR_ORACLE)
+endif
+endif
+ifdef REQUIRE_PACKAGES_PASZLIB
+PACKAGEDIR_PASZLIB:=$(firstword $(subst /Makefile.fpc,,$(strip $(wildcard $(addsuffix /paszlib/Makefile.fpc,$(PACKAGESDIR))))))
+ifneq ($(PACKAGEDIR_PASZLIB),)
+ifneq ($(wildcard $(PACKAGEDIR_PASZLIB)/$(OS_TARGET)),)
+UNITDIR_PASZLIB=$(PACKAGEDIR_PASZLIB)/$(OS_TARGET)
+else
+UNITDIR_PASZLIB=$(PACKAGEDIR_PASZLIB)
+endif
+else
+PACKAGEDIR_PASZLIB=
+UNITDIR_PASZLIB:=$(subst /Package.fpc,,$(strip $(wildcard $(addsuffix /paszlib/Package.fpc,$(UNITSDIR)))))
+ifneq ($(UNITDIR_PASZLIB),)
+UNITDIR_PASZLIB:=$(firstword $(UNITDIR_PASZLIB))
+else
+UNITDIR_PASZLIB=
+endif
+endif
+ifdef UNITDIR_PASZLIB
+override COMPILER_UNITDIR+=$(UNITDIR_PASZLIB)
+endif
+endif
+ifdef REQUIRE_PACKAGES_INET
+PACKAGEDIR_INET:=$(firstword $(subst /Makefile.fpc,,$(strip $(wildcard $(addsuffix /inet/Makefile.fpc,$(PACKAGESDIR))))))
+ifneq ($(PACKAGEDIR_INET),)
+ifneq ($(wildcard $(PACKAGEDIR_INET)/$(OS_TARGET)),)
+UNITDIR_INET=$(PACKAGEDIR_INET)/$(OS_TARGET)
+else
+UNITDIR_INET=$(PACKAGEDIR_INET)
+endif
+else
+PACKAGEDIR_INET=
+UNITDIR_INET:=$(subst /Package.fpc,,$(strip $(wildcard $(addsuffix /inet/Package.fpc,$(UNITSDIR)))))
+ifneq ($(UNITDIR_INET),)
+UNITDIR_INET:=$(firstword $(UNITDIR_INET))
+else
+UNITDIR_INET=
+endif
+endif
+ifdef UNITDIR_INET
+override COMPILER_UNITDIR+=$(UNITDIR_INET)
+endif
+endif
+ifdef REQUIRE_PACKAGES_FCL
+PACKAGEDIR_FCL:=$(firstword $(subst /Makefile.fpc,,$(strip $(wildcard $(addsuffix /fcl/Makefile.fpc,$(PACKAGESDIR))))))
+ifneq ($(PACKAGEDIR_FCL),)
+ifneq ($(wildcard $(PACKAGEDIR_FCL)/$(OS_TARGET)),)
+UNITDIR_FCL=$(PACKAGEDIR_FCL)/$(OS_TARGET)
+else
+UNITDIR_FCL=$(PACKAGEDIR_FCL)
+endif
+else
+PACKAGEDIR_FCL=
+UNITDIR_FCL:=$(subst /Package.fpc,,$(strip $(wildcard $(addsuffix /fcl/Package.fpc,$(UNITSDIR)))))
+ifneq ($(UNITDIR_FCL),)
+UNITDIR_FCL:=$(firstword $(UNITDIR_FCL))
+else
+UNITDIR_FCL=
+endif
+endif
+ifdef UNITDIR_FCL
+override COMPILER_UNITDIR+=$(UNITDIR_FCL)
+endif
+endif
+ifdef REQUIRE_PACKAGES_MYSQL
+PACKAGEDIR_MYSQL:=$(firstword $(subst /Makefile.fpc,,$(strip $(wildcard $(addsuffix /mysql/Makefile.fpc,$(PACKAGESDIR))))))
+ifneq ($(PACKAGEDIR_MYSQL),)
+ifneq ($(wildcard $(PACKAGEDIR_MYSQL)/$(OS_TARGET)),)
+UNITDIR_MYSQL=$(PACKAGEDIR_MYSQL)/$(OS_TARGET)
+else
+UNITDIR_MYSQL=$(PACKAGEDIR_MYSQL)
+endif
+else
+PACKAGEDIR_MYSQL=
+UNITDIR_MYSQL:=$(subst /Package.fpc,,$(strip $(wildcard $(addsuffix /mysql/Package.fpc,$(UNITSDIR)))))
+ifneq ($(UNITDIR_MYSQL),)
+UNITDIR_MYSQL:=$(firstword $(UNITDIR_MYSQL))
+else
+UNITDIR_MYSQL=
+endif
+endif
+ifdef UNITDIR_MYSQL
+override COMPILER_UNITDIR+=$(UNITDIR_MYSQL)
+endif
+endif
+ifdef REQUIRE_PACKAGES_IBASE
+PACKAGEDIR_IBASE:=$(firstword $(subst /Makefile.fpc,,$(strip $(wildcard $(addsuffix /ibase/Makefile.fpc,$(PACKAGESDIR))))))
+ifneq ($(PACKAGEDIR_IBASE),)
+ifneq ($(wildcard $(PACKAGEDIR_IBASE)/$(OS_TARGET)),)
+UNITDIR_IBASE=$(PACKAGEDIR_IBASE)/$(OS_TARGET)
+else
+UNITDIR_IBASE=$(PACKAGEDIR_IBASE)
+endif
+else
+PACKAGEDIR_IBASE=
+UNITDIR_IBASE:=$(subst /Package.fpc,,$(strip $(wildcard $(addsuffix /ibase/Package.fpc,$(UNITSDIR)))))
+ifneq ($(UNITDIR_IBASE),)
+UNITDIR_IBASE:=$(firstword $(UNITDIR_IBASE))
+else
+UNITDIR_IBASE=
+endif
+endif
+ifdef UNITDIR_IBASE
+override COMPILER_UNITDIR+=$(UNITDIR_IBASE)
+endif
+endif
+ifndef NOCPUDEF
+override FPCOPTDEF=$(CPU_TARGET)
+endif
+ifneq ($(OS_TARGET),$(OS_SOURCE))
+override FPCOPT+=-T$(OS_TARGET)
+endif
+ifdef UNITDIR
+override FPCOPT+=$(addprefix -Fu,$(UNITDIR))
+endif
+ifdef LIBDIR
+override FPCOPT+=$(addprefix -Fl,$(LIBDIR))
+endif
+ifdef OBJDIR
+override FPCOPT+=$(addprefix -Fo,$(OBJDIR))
+endif
+ifdef INCDIR
+override FPCOPT+=$(addprefix -Fi,$(INCDIR))
+endif
+ifdef LINKSMART
+override FPCOPT+=-XX
+endif
+ifdef CREATESMART
+override FPCOPT+=-CX
+endif
+ifdef DEBUG
+override FPCOPT+=-gl
+override FPCOPTDEF+=DEBUG
+endif
+ifdef RELEASE
+ifeq ($(CPU_TARGET),i386)
+FPCCPUOPT:=-OG2p3
+else
+FPCCPUOPT:=
+endif
+override FPCOPT+=-Xs $(FPCCPUOPT) -n
+override FPCOPTDEF+=RELEASE
+endif
+ifdef STRIP
+override FPCOPT+=-Xs
+endif
+ifdef OPTIMIZE
+ifeq ($(CPU_TARGET),i386)
+override FPCOPT+=-OG2p3
+endif
+endif
+ifdef VERBOSE
+override FPCOPT+=-vwni
+endif
+ifdef COMPILER_OPTIONS
+override FPCOPT+=$(COMPILER_OPTIONS)
+endif
+ifdef COMPILER_UNITDIR
+override FPCOPT+=$(addprefix -Fu,$(COMPILER_UNITDIR))
+endif
+ifdef COMPILER_LIBRARYDIR
+override FPCOPT+=$(addprefix -Fl,$(COMPILER_LIBRARYDIR))
+endif
+ifdef COMPILER_OBJECTDIR
+override FPCOPT+=$(addprefix -Fo,$(COMPILER_OBJECTDIR))
+endif
+ifdef COMPILER_INCLUDEDIR
+override FPCOPT+=$(addprefix -Fi,$(COMPILER_INCLUDEDIR))
+endif
+ifdef CROSSBINDIR
+override FPCOPT+=-FD$(CROSSBINDIR)
+endif
+ifdef COMPILER_TARGETDIR
+override FPCOPT+=-FE$(COMPILER_TARGETDIR)
+ifeq ($(COMPILER_TARGETDIR),.)
+override TARGETDIRPREFIX=
+else
+override TARGETDIRPREFIX=$(COMPILER_TARGETDIR)/
+endif
+endif
+ifdef COMPILER_UNITTARGETDIR
+override FPCOPT+=-FU$(COMPILER_UNITTARGETDIR)
+ifeq ($(COMPILER_UNITTARGETDIR),.)
+override UNITTARGETDIRPREFIX=
+else
+override UNITTARGETDIRPREFIX=$(COMPILER_UNITTARGETDIR)/
+endif
+else
+ifdef COMPILER_TARGETDIR
+override COMPILER_UNITTARGETDIR=$(COMPILER_TARGETDIR)
+override UNITTARGETDIRPREFIX=$(TARGETDIRPREFIX)
+endif
+endif
+ifdef GCCLIBDIR
+override FPCOPT+=-Fl$(GCCLIBDIR)
+endif
+ifdef OTHERLIBDIR
+override FPCOPT+=$(addprefix -Fl,$(OTHERLIBDIR))
+endif
+ifdef OPT
+override FPCOPT+=$(OPT)
+endif
+ifdef FPCOPTDEF
+override FPCOPT+=$(addprefix -d,$(FPCOPTDEF))
+endif
+ifdef CFGFILE
+override FPCOPT+=@$(CFGFILE)
+endif
+ifdef USEENV
+override FPCEXTCMD:=$(FPCOPT)
+override FPCOPT:=!FPCEXTCMD
+export FPCEXTCMD
+endif
+override COMPILER:=$(FPC) $(FPCOPT)
+ifeq (,$(findstring -s ,$(COMPILER)))
+EXECPPAS=
+else
+ifeq ($(OS_SOURCE),$(OS_TARGET))
+EXECPPAS:=@$(PPAS)
+endif
+endif
+.PHONY: fpc_units
+ifdef TARGET_UNITS
+override ALLTARGET+=fpc_units
+override UNITPPUFILES=$(addsuffix $(PPUEXT),$(TARGET_UNITS))
+override IMPLICITUNITPPUFILES=$(addsuffix $(PPUEXT),$(TARGET_IMPLICITUNITS))
+override INSTALLPPUFILES+=$(UNITPPUFILES) $(IMPLICITUNITPPUFILES)
+override CLEANPPUFILES+=$(UNITPPUFILES) $(IMPLICITUNITPPUFILES)
+endif
+fpc_units: $(UNITPPUFILES)
+ifdef TARGET_RSTS
+override RSTFILES=$(addsuffix $(RSTEXT),$(TARGET_RSTS))
+override CLEANRSTFILES+=$(RSTFILES)
+endif
+.PHONY: fpc_examples
+ifdef TARGET_EXAMPLES
+HASEXAMPLES=1
+override EXAMPLESOURCEFILES:=$(wildcard $(addsuffix .pp,$(TARGET_EXAMPLES)) $(addsuffix .pas,$(TARGET_EXAMPLES)))
+override EXAMPLEFILES:=$(addsuffix $(EXEEXT),$(TARGET_EXAMPLES))
+override EXAMPLEOFILES:=$(addsuffix $(OEXT),$(TARGET_EXAMPLES)) $(addprefix $(STATICLIBPREFIX),$(addsuffix $(STATICLIBEXT),$(TARGET_EXAMPLES)))
+override CLEANEXEFILES+=$(EXAMPLEFILES) $(EXAMPLEOFILES)
+ifeq ($(OS_TARGET),os2)
+override CLEANEXEFILES+=$(addsuffix $(AOUTEXT),$(TARGET_EXAMPLES))
+endif
+endif
+ifdef TARGET_EXAMPLEDIRS
+HASEXAMPLES=1
+endif
+fpc_examples: all $(EXAMPLEFILES) $(addsuffix _all,$(TARGET_EXAMPLEDIRS))
+.PHONY: fpc_all fpc_smart fpc_debug fpc_release
+$(FPCMADE): $(ALLTARGET)
+	@$(ECHOREDIR) Compiled > $(FPCMADE)
+fpc_all: $(FPCMADE)
+fpc_smart:
+	$(MAKE) all LINKSMART=1 CREATESMART=1
+fpc_debug:
+	$(MAKE) all DEBUG=1
+fpc_release:
+	$(MAKE) all RELEASE=1
+.SUFFIXES: $(EXEEXT) $(PPUEXT) $(OEXT) .pas .pp .rc .res
+%$(PPUEXT): %.pp
+	$(COMPILER) $<
+	$(EXECPPAS)
+%$(PPUEXT): %.pas
+	$(COMPILER) $<
+	$(EXECPPAS)
+%$(EXEEXT): %.pp
+	$(COMPILER) $<
+	$(EXECPPAS)
+%$(EXEEXT): %.pas
+	$(COMPILER) $<
+	$(EXECPPAS)
+%.res: %.rc
+	windres -i $< -o $@
+vpath %.pp $(COMPILER_SOURCEDIR) $(COMPILER_INCLUDEDIR)
+vpath %.pas $(COMPILER_SOURCEDIR) $(COMPILER_INCLUDEDIR)
+vpath %$(PPUEXT) $(COMPILER_UNITTARGETDIR)
+.PHONY: fpc_install fpc_sourceinstall fpc_exampleinstall
+ifdef INSTALL_UNITS
+override INSTALLPPUFILES+=$(addsuffix $(PPUEXT),$(INSTALL_UNITS))
+endif
+ifdef INSTALL_BUILDUNIT
+override INSTALLPPUFILES:=$(filter-out $(INSTALL_BUILDUNIT),$(INSTALLPPUFILES))
+endif
+ifdef INSTALLPPUFILES
+override INSTALLPPULINKFILES:=$(subst $(PPUEXT),$(OEXT),$(INSTALLPPUFILES)) $(addprefix $(STATICLIBPREFIX),$(subst $(PPUEXT),$(STATICLIBEXT),$(INSTALLPPUFILES)))
+override INSTALLPPUFILES:=$(addprefix $(UNITTARGETDIRPREFIX),$(INSTALLPPUFILES))
+override INSTALLPPULINKFILES:=$(wildcard $(addprefix $(UNITTARGETDIRPREFIX),$(INSTALLPPULINKFILES)))
+override INSTALL_CREATEPACKAGEFPC=1
+endif
+ifdef INSTALLEXEFILES
+override INSTALLEXEFILES:=$(addprefix $(TARGETDIRPREFIX),$(INSTALLEXEFILES))
+endif
+fpc_install: all $(INSTALLTARGET)
+ifdef INSTALLEXEFILES
+	$(MKDIR) $(INSTALL_BINDIR)
+ifdef UPXPROG
+	-$(UPXPROG) $(INSTALLEXEFILES)
+endif
+	$(INSTALLEXE) $(INSTALLEXEFILES) $(INSTALL_BINDIR)
+endif
+ifdef INSTALL_CREATEPACKAGEFPC
+ifdef FPCMAKE
+ifdef PACKAGE_VERSION
+ifneq ($(wildcard Makefile.fpc),)
+	$(FPCMAKE) -p -T$(OS_TARGET) Makefile.fpc
+	$(MKDIR) $(INSTALL_UNITDIR)
+	$(INSTALL) Package.fpc $(INSTALL_UNITDIR)
+endif
+endif
+endif
+endif
+ifdef INSTALLPPUFILES
+	$(MKDIR) $(INSTALL_UNITDIR)
+	$(INSTALL) $(INSTALLPPUFILES) $(INSTALL_UNITDIR)
+ifneq ($(INSTALLPPULINKFILES),)
+	$(INSTALL) $(INSTALLPPULINKFILES) $(INSTALL_UNITDIR)
+endif
+ifneq ($(wildcard $(LIB_FULLNAME)),)
+	$(MKDIR) $(INSTALL_LIBDIR)
+	$(INSTALL) $(LIB_FULLNAME) $(INSTALL_LIBDIR)
+ifdef inUnix
+	ln -sf $(LIB_FULLNAME) $(INSTALL_LIBDIR)/$(LIB_NAME)
+endif
+endif
+endif
+ifdef INSTALL_FILES
+	$(MKDIR) $(INSTALL_DATADIR)
+	$(INSTALL) $(INSTALL_FILES) $(INSTALL_DATADIR)
+endif
+fpc_sourceinstall: distclean
+	$(MKDIR) $(INSTALL_SOURCEDIR)
+	$(COPYTREE) $(BASEDIR) $(INSTALL_SOURCEDIR)
+fpc_exampleinstall: $(addsuffix _distclean,$(TARGET_EXAMPLEDIRS))
+ifdef HASEXAMPLES
+	$(MKDIR) $(INSTALL_EXAMPLEDIR)
+endif
+ifdef EXAMPLESOURCEFILES
+	$(COPY) $(EXAMPLESOURCEFILES) $(INSTALL_EXAMPLEDIR)
+endif
+ifdef TARGET_EXAMPLEDIRS
+	$(COPYTREE) $(addsuffix /*,$(TARGET_EXAMPLEDIRS)) $(INSTALL_EXAMPLEDIR)
+endif
+.PHONY: fpc_clean fpc_cleanall fpc_distclean
+ifdef EXEFILES
+override CLEANEXEFILES:=$(addprefix $(TARGETDIRPREFIX),$(CLEANEXEFILES))
+endif
+ifdef CLEAN_UNITS
+override CLEANPPUFILES+=$(addsuffix $(PPUEXT),$(CLEAN_UNITS))
+endif
+ifdef CLEANPPUFILES
+override CLEANPPULINKFILES:=$(subst $(PPUEXT),$(OEXT),$(CLEANPPUFILES)) $(addprefix $(STATICLIBPREFIX),$(subst $(PPUEXT),$(STATICLIBEXT),$(CLEANPPUFILES)))
+override CLEANPPUFILES:=$(addprefix $(UNITTARGETDIRPREFIX),$(CLEANPPUFILES))
+override CLEANPPULINKFILES:=$(wildcard $(addprefix $(UNITTARGETDIRPREFIX),$(CLEANPPULINKFILES)))
+endif
+fpc_clean: $(CLEANTARGET)
+ifdef CLEANEXEFILES
+	-$(DEL) $(CLEANEXEFILES)
+endif
+ifdef CLEANPPUFILES
+	-$(DEL) $(CLEANPPUFILES)
+endif
+ifneq ($(CLEANPPULINKFILES),)
+	-$(DEL) $(CLEANPPULINKFILES)
+endif
+ifdef CLEANRSTFILES
+	-$(DEL) $(addprefix $(UNITTARGETDIRPREFIX),$(CLEANRSTFILES))
+endif
+ifdef CLEAN_FILES
+	-$(DEL) $(CLEAN_FILES)
+endif
+ifdef LIB_NAME
+	-$(DEL) $(LIB_NAME) $(LIB_FULLNAME)
+endif
+	-$(DEL) $(FPCMADE) Package.fpc $(PPAS) script.res link.res $(FPCEXTFILE) $(REDIRFILE)
+fpc_distclean: clean
+ifdef COMPILER_UNITTARGETDIR
+TARGETDIRCLEAN=fpc_clean
+endif
+fpc_cleanall: $(CLEANTARGET) $(TARGETDIRCLEAN)
+ifdef CLEANEXEFILES
+	-$(DEL) $(CLEANEXEFILES)
+endif
+	-$(DEL) *$(OEXT) *$(PPUEXT) *$(RSTEXT) *$(ASMEXT) *$(STATICLIBEXT) *$(SHAREDLIBEXT) *$(PPLEXT)
+	-$(DELTREE) *$(SMARTEXT)
+	-$(DEL) $(FPCMADE) Package.fpc $(PPAS) script.res link.res $(FPCEXTFILE) $(REDIRFILE)
+ifdef AOUTEXT
+	-$(DEL) *$(AOUTEXT)
+endif
+.PHONY: fpc_baseinfo
+override INFORULES+=fpc_baseinfo
+fpc_baseinfo:
+	@$(ECHO)
+	@$(ECHO)  == Package info ==
+	@$(ECHO)  Package Name..... $(PACKAGE_NAME)
+	@$(ECHO)  Package Version.. $(PACKAGE_VERSION)
+	@$(ECHO)
+	@$(ECHO)  == Configuration info ==
+	@$(ECHO)
+	@$(ECHO)  FPC.......... $(FPC)
+	@$(ECHO)  FPC Version.. $(FPC_VERSION)
+	@$(ECHO)  Source CPU... $(CPU_SOURCE)
+	@$(ECHO)  Target CPU... $(CPU_TARGET)
+	@$(ECHO)  Source OS.... $(OS_SOURCE)
+	@$(ECHO)  Target OS.... $(OS_TARGET)
+	@$(ECHO)  Full Target.. $(FULL_SOURCE)
+	@$(ECHO)  Full Source.. $(FULL_TARGET)
+	@$(ECHO)
+	@$(ECHO)  == Directory info ==
+	@$(ECHO)
+	@$(ECHO)  Required pkgs... $(REQUIRE_PACKAGES)
+	@$(ECHO)
+	@$(ECHO)  Basedir......... $(BASEDIR)
+	@$(ECHO)  FPCDir.......... $(FPCDIR)
+	@$(ECHO)  CrossBinDir..... $(CROSSBINDIR)
+	@$(ECHO)  UnitsDir........ $(UNITSDIR)
+	@$(ECHO)  PackagesDir..... $(PACKAGESDIR)
+	@$(ECHO)
+	@$(ECHO)  GCC library..... $(GCCLIBDIR)
+	@$(ECHO)  Other library... $(OTHERLIBDIR)
+	@$(ECHO)
+	@$(ECHO)  == Tools info ==
+	@$(ECHO)
+	@$(ECHO)  As........ $(AS)
+	@$(ECHO)  Ld........ $(LD)
+	@$(ECHO)  Ar........ $(AR)
+	@$(ECHO)  Rc........ $(RC)
+	@$(ECHO)
+	@$(ECHO)  Mv........ $(MVPROG)
+	@$(ECHO)  Cp........ $(CPPROG)
+	@$(ECHO)  Rm........ $(RMPROG)
+	@$(ECHO)  GInstall.. $(GINSTALL)
+	@$(ECHO)  Echo...... $(ECHO)
+	@$(ECHO)  Date...... $(DATE)
+	@$(ECHO)  FPCMake... $(FPCMAKE)
+	@$(ECHO)  PPUMove... $(PPUMOVE)
+	@$(ECHO)  Upx....... $(UPXPROG)
+	@$(ECHO)  Zip....... $(ZIPPROG)
+	@$(ECHO)
+	@$(ECHO)  == Object info ==
+	@$(ECHO)
+	@$(ECHO)  Target Loaders........ $(TARGET_LOADERS)
+	@$(ECHO)  Target Units.......... $(TARGET_UNITS)
+	@$(ECHO)  Target Implicit Units. $(TARGET_IMPLICITUNITS)
+	@$(ECHO)  Target Programs....... $(TARGET_PROGRAMS)
+	@$(ECHO)  Target Dirs........... $(TARGET_DIRS)
+	@$(ECHO)  Target Examples....... $(TARGET_EXAMPLES)
+	@$(ECHO)  Target ExampleDirs.... $(TARGET_EXAMPLEDIRS)
+	@$(ECHO)
+	@$(ECHO)  Clean Units......... $(CLEAN_UNITS)
+	@$(ECHO)  Clean Files......... $(CLEAN_FILES)
+	@$(ECHO)
+	@$(ECHO)  Install Units....... $(INSTALL_UNITS)
+	@$(ECHO)  Install Files....... $(INSTALL_FILES)
+	@$(ECHO)
+	@$(ECHO)  == Install info ==
+	@$(ECHO)
+	@$(ECHO)  DateStr.............. $(DATESTR)
+	@$(ECHO)  ZipPrefix............ $(ZIPPREFIX)
+	@$(ECHO)  ZipSuffix............ $(ZIPSUFFIX)
+	@$(ECHO)  Install FPC Package.. $(INSTALL_FPCPACKAGE)
+	@$(ECHO)
+	@$(ECHO)  Install base dir..... $(INSTALL_BASEDIR)
+	@$(ECHO)  Install binary dir... $(INSTALL_BINDIR)
+	@$(ECHO)  Install library dir.. $(INSTALL_LIBDIR)
+	@$(ECHO)  Install units dir.... $(INSTALL_UNITDIR)
+	@$(ECHO)  Install source dir... $(INSTALL_SOURCEDIR)
+	@$(ECHO)  Install doc dir...... $(INSTALL_DOCDIR)
+	@$(ECHO)  Install example dir.. $(INSTALL_EXAMPLEDIR)
+	@$(ECHO)  Install data dir..... $(INSTALL_DATADIR)
+	@$(ECHO)
+	@$(ECHO)  Dist destination dir. $(DIST_DESTDIR)
+	@$(ECHO)  Dist zip name........ $(DIST_ZIPNAME)
+	@$(ECHO)
+.PHONY: fpc_info
+fpc_info: $(INFORULES)
+.PHONY: fpc_makefile fpc_makefiles fpc_makefile_sub1 fpc_makefile_sub2 \
+	fpc_makefile_dirs
+fpc_makefile:
+	$(FPCMAKE) -w -T$(OS_TARGET) Makefile.fpc
+fpc_makefile_sub1:
+ifdef TARGET_DIRS
+	$(FPCMAKE) -w -T$(OS_TARGET) $(addsuffix /Makefile.fpc,$(TARGET_DIRS))
+endif
+ifdef TARGET_EXAMPLEDIRS
+	$(FPCMAKE) -w -T$(OS_TARGET) $(addsuffix /Makefile.fpc,$(TARGET_EXAMPLEDIRS))
+endif
+fpc_makefile_sub2: $(addsuffix _makefile_dirs,$(TARGET_DIRS) $(TARGET_EXAMPLEDIRS))
+fpc_makefile_dirs: fpc_makefile_sub1 fpc_makefile_sub2
+fpc_makefiles: fpc_makefile fpc_makefile_dirs
+all: fpc_all
+debug: fpc_debug
+smart: fpc_smart
+release: fpc_release
+examples: fpc_examples
+shared:
+install: fpc_install
+sourceinstall: fpc_sourceinstall
+exampleinstall: fpc_exampleinstall
+distinstall:
+zipinstall:
+zipsourceinstall:
+zipexampleinstall:
+zipdistinstall:
+clean: fpc_clean
+distclean: fpc_distclean
+cleanall: fpc_cleanall
+info: fpc_info
+makefiles: fpc_makefiles
+.PHONY: all debug smart release examples shared install sourceinstall exampleinstall distinstall zipinstall zipsourceinstall zipexampleinstall zipdistinstall clean distclean cleanall info makefiles
+ifneq ($(wildcard fpcmake.loc),)
+include fpcmake.loc
+endif

+ 21 - 0
packages/base/oracle/example/Makefile.fpc

@@ -0,0 +1,21 @@
+#
+#  Makefile.fpc for oracle units example
+#
+
+[target]
+units=oraclew
+examples=test01
+
+[require]
+packages=oracle fcl
+
+[install]
+fpcpackage=y
+
+[default]
+fpcdir=../../../..
+
+# in libdir variable must be path to libraries
+# libclntsh.*,libnlsrtl3.*
+#[compiler]
+#libdir=/usr/local/oracle8cli/lib

+ 457 - 0
packages/base/oracle/example/oraclew.pp

@@ -0,0 +1,457 @@
+{
+    $Id$
+    Copyright (c) 1999-2000 by Pavel Stingl <[email protected]>
+
+
+    OCI workaround
+
+    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.
+
+ **********************************************************************}
+unit oraclew;
+
+interface
+
+{$H+}
+{$mode objfpc}
+
+uses OraOCI, Classes, SysUtils;
+
+{ all pos parameters are indexed from 1..x! }
+
+    procedure OraInit;
+    procedure OraFin;
+    procedure OraLogin(name, pass, server: string);
+    procedure OraLogout;
+    procedure OraSQLExec(sql: string);
+    function OraGetFieldAsString(pos : integer) : string;
+    function OraGetFieldAsInteger(pos : integer) : longint;
+    function OraNext: boolean;
+    function OraGetFieldCount: integer;
+    function OraGetFieldName(pos : integer) : string;
+    function OraGetFieldType(pos : integer) : longint;
+    function IsFieldDate(Pos : integer): boolean;
+    procedure OraError(errcode: integer; err: OCIError; msg : string);
+    
+const
+    cDescribeBuf = 1024;
+    cPCharBufLen = 4097;
+    cPrefetchCnt = 100;
+
+type
+
+  PDescribeRec = ^TDescribeRec;
+  TDescribeRec = record
+    dbsize	: sb4;
+    dbtype	: sb2;
+    buf		: array [0..cDescribeBuf] of char;
+    buflen	: sb4;
+    dsize 	: sb4;
+    precision 	: sb2;
+    scale 	: sb2;
+    nullok 	: sb2;
+    
+    // Define part
+      valbuf	: array [0..cDescribeBuf] of char;
+      flt_buf	: double;
+      int_buf	: cardinal;
+      int64_buf : int64;
+      indp	: sb2;
+      col_retlen: ub2;
+      col_retcode: ub2;
+  end;
+  
+var
+    Env : OCIEnv; 
+    Err : OCIError;
+    Svc : OCISvcCtx;
+    Stmt: OCIStmt;
+    FieldList : TList;
+    
+    ecode : integer;
+
+implementation
+
+  function DecodeDataType(dtype : longint): string;
+  begin
+    case dtype of
+	SQLT_CHR : DecodeDataType := '(ORANET TYPE) character string';
+	SQLT_NUM : DecodeDataType := '(ORANET TYPE) oracle numeric';
+   	SQLT_INT : DecodeDataType := '(ORANET TYPE) integer';
+   	SQLT_FLT : DecodeDataType := '(ORANET TYPE) Floating point number';
+   	SQLT_STR : DecodeDataType := 'zero terminated string';
+   	SQLT_VNU : DecodeDataType := 'NUM with preceding length byte';
+   	SQLT_PDN : DecodeDataType := '(ORANET TYPE) Packed Decimal Numeric';
+   	SQLT_LNG : DecodeDataType := 'long';
+   	SQLT_VCS : DecodeDataType := 'Variable character string';
+   	SQLT_NON : DecodeDataType := 'Null/empty PCC Descriptor entry';
+	SQLT_RID : DecodeDataType := 'rowid';
+	SQLT_DAT : DecodeDataType := 'date in oracle format';
+	SQLT_VBI : DecodeDataType := 'binary in VCS format';
+	SQLT_BIN : DecodeDataType := 'binary data(DTYBIN)';
+	SQLT_LBI : DecodeDataType := 'long binary';
+	SQLT_UIN : DecodeDataType := 'unsigned integer';
+	SQLT_SLS : DecodeDataType := 'Display sign leading separate';
+	SQLT_LVC : DecodeDataType := 'Longer longs (char)';
+	SQLT_LVB : DecodeDataType := 'Longer long binary';
+	SQLT_AFC : DecodeDataType := 'Ansi fixed char';
+	SQLT_AVC : DecodeDataType := 'Ansi Var char';
+	SQLT_CUR : DecodeDataType := 'cursor  type';
+	SQLT_RDD : DecodeDataType := 'rowid descriptor'; 
+	SQLT_LAB : DecodeDataType := 'label type'; 
+	SQLT_OSL : DecodeDataType := 'oslabel type'; 
+	SQLT_NTY : DecodeDataType := 'named object type'; 
+	SQLT_REF : DecodeDataType := 'ref type'; 
+	SQLT_CLOB : DecodeDataType := 'character lob'; 
+	SQLT_BLOB : DecodeDataType := 'binary lob'; 
+	SQLT_BFILEE : DecodeDataType := 'binary file lob';
+	SQLT_CFILEE : DecodeDataType := 'character file lob'; 
+	SQLT_RSET : DecodeDataType := 'result set type'; 
+	SQLT_NCO : DecodeDataType := 'named collection type (varray or nested table)';
+	SQLT_VST : DecodeDataType := 'OCIString type'; 
+	SQLT_ODT : DecodeDataType := 'OCIDate type'; 
+    else DecodeDataType := 'Unknown';
+    end;
+  end;
+    
+  procedure FieldListClear;
+  var
+   	x: longint;
+   	PDesc: PDescribeRec;
+  begin
+   	if FieldList.Count = 0 then Exit;
+   	for x := 0 to FieldList.Count - 1 do
+   	begin
+   	    PDesc := FieldList[x];
+   	    Dispose(PDesc);
+   	end;
+   	FieldList.Clear;
+  end;
+   
+       procedure Describe;
+       var
+   	fldc	: longint;
+   	paramd	: OCIParam;
+   	colname : PChar;
+   	colsize : ub4;
+   	Rec	: PDescribeRec;
+       begin
+   	fldc := 1;
+   	
+   	FieldListClear;
+   	ecode := OCIParamGet(Stmt, OCI_HTYPE_STMT, Err, @paramd, fldc);
+   	if ecode <> OCI_SUCCESS then
+   	    ORAError(ecode, Err, 'OCIParamGetError');
+   	while ecode = OCI_SUCCESS do
+   	begin
+   	    New(Rec);
+   	    FillChar(Rec^.buf, sizeof(Rec^.buf), #0);
+   	    ecode := OCIAttrGet(paramd, OCI_DTYPE_PARAM, @Rec^.dbtype, 0, 
+   		OCI_ATTR_DATA_TYPE, Err);
+   	    if ecode <> 0 then
+   	    begin
+   		ORAError(ecode, Err, 'Retrieving DTYPE_PARAM:');
+   	    end;
+   	    colsize := 0;
+   	    colname := nil;
+   	    ecode := OCIAttrGet(paramd, OCI_DTYPE_PARAM, @colname, @colsize, 
+   		OCI_ATTR_NAME, Err);
+   	    if ecode <> 0 then
+   	    begin
+   		ORAError(ecode, Err, 'Retrieving DTYPE_PARAM:');
+   	    end;
+   	    Move(Colname^,Rec^.buf, colsize);
+   	    Rec^.buflen := colsize;
+//   	    WriteLn('Column: ',Rec^.buf:15,'	DataType: ',DecodeDataType(Rec^.dbtype));
+   	    inc(fldc);
+   	    
+   	    FieldList.Add(Rec);
+   	    ecode := OCIParamGet(Stmt, OCI_HTYPE_STMT, Err, @paramd, fldc);
+   	end;
+    end;
+    
+    procedure Define;
+    var
+	x : longint;
+	def: OCIDefine;
+	PDesc : PDescribeRec;
+	defptr: pointer;
+	deflen: sword;
+	deftyp: sword;
+    begin
+	def := nil;
+	for x := 0 to FieldList.Count - 1 do
+	begin
+	    PDesc := FieldList[x];
+	    case PDesc^.dbtype of
+		NUMBER_TYPE: begin
+		    if PDesc^.scale <> 0 then
+		    begin
+			defptr := @PDesc^.flt_buf;
+			deflen := SizeOf(PDesc^.flt_buf);
+			deftyp := FLOAT_TYPE;
+			PDesc^.dbtype := FLOAT_TYPE;
+		    end
+		    else begin
+              if PDesc^.dbsize > 4 then
+              begin
+                // WriteLn('BIG FAT WARNING!!!! dbsize int > 4 (',PDesc^.dbsize,')');
+                defptr := @PDesc^.int64_buf;
+                deflen := SizeOf(PDesc^.int64_buf);
+                deftyp := INT_TYPE;
+                PDesc^.dbtype := INT_TYPE;
+              end
+              else begin
+                defptr := @PDesc^.int_buf;
+			    deflen := SizeOf(PDesc^.int_buf);
+			    deftyp := INT_TYPE;
+			    PDesc^.dbtype := INT_TYPE;
+              end;
+		    end;
+		end;
+		else begin
+		    defptr := @PDesc^.valbuf;
+		    deflen := cDescribeBuf;
+		    deftyp := PDesc^.dbtype;
+		end;
+	    end;
+	    ecode := OCIDefineByPos(Stmt, @def, Err, x + 1, defptr, 
+		deflen,	deftyp, @PDesc^.indp, @PDesc^.col_retlen, 
+		@PDesc^.col_retcode, OCI_DEFAULT);
+	    if ecode <> 0 then
+	    begin
+		OraError(ecode, Err, 'OCIDefineByPos: ');
+	    end;
+	end;
+    end;
+
+    procedure OraError( errcode : integer; err: OCIError; msg : string );
+    var
+	buff : array [0..1024] of char;
+	xp : PLongint;
+    begin
+	if err <> nil then
+	begin
+	    case errcode of
+		OCI_INVALID_HANDLE: Msg := Msg + ' OCI_INVALID_HANDLE';
+	    end;
+	    xp := @errcode;
+	    OCIErrorGet( err, 1, nil, xp, @buff[0], 1024, OCI_HTYPE_ERROR);
+	    writeln(stderr, msg, ' ', buff);
+	end
+	else begin
+	    WriteLn(stderr, msg);
+	    Halt(1);
+	end;
+    end;
+
+    procedure OraInit;
+    begin
+	ecode := OCIInitialize({OCI_DEFAULT or }OCI_OBJECT, nil, nil, nil, nil);
+	if ecode <> 0 then OraError( ecode, nil, 'Error initializing OCI');
+	ecode := OCIEnvInit(Env, OCI_DEFAULT, 0, nil);
+	if ecode <> 0 then OraError( ecode, nil, 'Error initializing OCI environment');
+	ecode := OCIHandleAlloc(Env, Err, OCI_HTYPE_ERROR, 0, nil);
+	if ecode <> 0 then OraError( ecode, nil, 'Error allocating error handle');
+	ecode := OCIHandleAlloc(Env, Stmt, OCI_HTYPE_STMT, 0, nil);
+	if ecode <> 0 then OraError( ecode, nil, 'Error allocating statement handle');
+    end;
+    
+    procedure OraLogin(name, pass, server: string);
+    begin
+	ecode := OCILogon(Env, Err, Svc, @name[1], Length(name),
+	    @pass[1], Length(pass), @server[1], Length(server));
+	if ecode <> 0 then OraError(ecode, Err, ''); 	
+    end;
+    
+    procedure OraLogout;
+    begin
+	ecode := OCILogoff(Svc, Err);
+	if ecode <> 0 then
+	    OraError(ecode, Err, 'OCILogoff: ');
+    end;
+    
+    procedure OraFin;
+    begin
+	OCIHandleFree(Stmt, OCI_HTYPE_STMT);
+	OCIHandleFree(Err, OCI_HTYPE_ERROR);
+    end;
+    
+    procedure OraSQLExec(sql: string);
+    var
+	dtype: longint;
+    begin
+//    writeLn(Length(sql));
+	ecode := OCIStmtPrepare(Stmt, Err, @sql[1], Length(sql),
+	    OCI_NTV_SYNTAX, OCI_DEFAULT);
+	if ecode <> 0 then 
+	begin
+	    OraError(ecode, Err, 'OCIStmtPrepare:');
+	    Exit;
+	end;
+    
+    dtype := cPrefetchCnt;
+    ecode := OCIAttrSet(Stmt, OCI_HTYPE_STMT, @dtype, 
+      SizeOf(dtype), OCI_ATTR_PREFETCH_ROWS, Err);
+	if ecode <> 0 then 
+	begin
+	    OraError(ecode, Err, 'ociattrset:');
+	    Exit;
+	end;
+
+	dtype := 0;
+	ecode := OCIAttrGet(Stmt, OCI_HTYPE_STMT, @dtype, 4, 
+	    OCI_ATTR_STMT_TYPE, Err);
+	if ecode <> 0 then 
+	begin
+	    OraError(ecode, Err, 'ociattrget:');
+	    Exit;
+	end;
+    
+	ecode := 0;
+	if dtype = OCI_STMT_SELECT then
+	    ecode := OCIStmtExecute(Svc, Stmt, Err, 0, 0, nil, nil, OCI_DEFAULT)
+	else ecode := OCIStmtExecute(Svc, Stmt, Err, 1, 0, nil, nil, OCI_DEFAULT);
+	if ecode <> 0 then
+	begin
+	    OraError(ecode, Err, 'OCIStmtExecute:');
+	    Exit;
+	end;
+	
+	if dtype = OCI_STMT_SELECT then
+	begin
+	    Describe;
+	    Define;
+	end;
+    end;
+    
+    function OraGetFieldCount : integer;
+    begin
+	OraGetFieldCount := FieldList.Count;
+    end;
+
+    function IsFieldDate(Pos : integer): boolean;
+    var
+      Desc : TDescribeRec;      
+    begin
+      Result := False;
+      if (Pos > FieldList.Count) or (Pos < 1) then
+        Exit;
+      Desc := TDescribeRec(FieldList[Pos-1]^);
+      Result := (Desc.dbtype = DATE_TYPE);
+    end;
+    
+    function OraGetFieldAsString(pos : integer) : string;
+    var
+	Desc : TDescribeRec;
+    Date : array [0..6] of byte;
+    begin
+	if (Pos > FieldList.Count) or (Pos < 1) then
+	    Exit;
+	Desc := TDescribeRec(FieldList[pos-1]^);
+    if Desc.indp < 0 then
+    begin
+      OraGetFieldAsString := 'null';
+      Exit;
+    end;
+	if Desc.dbtype = STRING_TYPE then
+	begin
+	    Desc.valbuf[Desc.col_retlen] := #0;
+	    OraGetFieldAsString := Desc.valbuf;
+	end
+	else if Desc.dbtype = VARCHAR2_TYPE then
+	begin
+	    Desc.valbuf[Desc.col_retlen] := #0;
+	    OraGetFieldAsString := Desc.valbuf;
+	end
+  	else if Desc.dbtype = INT_TYPE then
+    begin
+	    OraGetFieldAsString := IntToStr(Desc.int_buf);
+    end
+	else if Desc.dbtype = FLOAT_TYPE then
+	    OraGetFieldAsString := FloatToStr(Desc.flt_buf)
+	else if Desc.dbtype = DATE_TYPE then
+    begin
+        Move(Desc.valbuf,Date,SizeOf(Date));
+	    OraGetFieldAsString := 
+          Format('%0.2d.%0.2d.%0.4d %0.2d:%0.2d:%0.2d',
+          [Date[3],Date[2],(((Date[0]-100)*100)+(Date[1] - 100)),
+           Date[4]-1,
+           Date[5]-1,
+           Date[6]-1]);
+    end
+	else if Desc.dbtype = SQLT_AFC then
+	begin
+	    Desc.valbuf[Desc.col_retlen] := #0;
+	    OraGetFieldAsString := Desc.valbuf;
+	end
+	else OraGetFieldAsString := 'dbtype not implemented ' + IntToStr(Desc.dbtype);
+    end;
+    
+    function OraGetFieldAsInteger(pos : integer) : longint;
+    begin
+	OraGetFieldAsInteger := 0;
+    end;
+    
+    function OraNext: boolean;
+    begin
+	ecode := OCIStmtFetch(Stmt, Err, 1, OCI_FETCH_NEXT, OCI_DEFAULT);
+	if ecode = 0 then
+	    OraNext := true
+	else if ecode = OCI_SUCCESS_WITH_INFO then
+	    OraNext := false
+	else if ecode = OCI_NO_DATA then
+	    OraNext := false
+	else begin
+	    OraNext := false;
+	    OraError(ecode, err, 'OCIStmtFetch:');
+	end;
+    end;
+    
+    function OraGetFieldType(pos : integer) : longint;
+    begin
+      if (Pos > FieldList.Count) or (pos < 1) then
+        Exit;
+      OraGetFieldType := TDescribeRec(FieldList[pos-1]^).dbtype;    
+    end;
+
+    function OraGetFieldName(pos : integer) : string;
+    begin
+	if (Pos > FieldList.Count) or (Pos < 1) then
+	    Exit;
+	OraGetFieldName := TDescribeRec(FieldList[pos-1]^).buf;	
+    end;
+    
+initialization
+    
+    FieldList := TList.Create;
+
+finalization
+
+    FieldListClear;
+    FieldList.Free;
+
+end.
+
+{
+  $Log$
+  Revision 1.1  2002-01-29 17:54:54  peter
+    * splitted to base and extra
+
+  Revision 1.1  2001/04/08 12:23:49  peter
+    * moved oraclew and test01 to example subdir to remove the dependency
+      on the fcl. This dependency is now only required when building the
+      examples
+
+  Revision 1.1  2000/12/02 15:14:14  michael
+  + Initial implementation of Pavel Stingl
+
+  Revision 1.1.1.1  2000/10/11 07:48:28  stingp1
+    * Import to cvs
+
+}

+ 60 - 0
packages/base/oracle/example/test01.pp

@@ -0,0 +1,60 @@
+{
+    $Id$
+    Copyright (c) 1999-2000 by Pavel Stingl <[email protected]>
+
+
+    Test program for OraOCI units
+
+    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.
+
+ **********************************************************************}
+program test01;
+
+uses
+  oraclew,
+  oraoci;
+
+{$H+}
+
+{
+    Constants user, pass & tnsc you must set by hand to values,
+    which you prefer.
+
+    user = username
+    pass = password
+    tnsc = TNS connect string
+ **********************************************************************}
+
+const
+  user = 'every';
+  pass = 'tisova';
+  tnsc = 'etil.world';
+
+var
+  x : integer;
+  p : integer;
+begin
+  OraInit;
+  OraLogin(user,pass,tnsc);
+  OraSQLExec('select sysdate from sys.dual');
+  writeln(OraGetFieldName(1):20);
+  p := OraGetFieldCount;
+  for x := 1 to p do
+  write(OraGetFieldName(x), ';');
+  WriteLn;
+  while OraNext do
+  begin
+    for x := 1 to p do
+      write(OraGetFieldAsString(x), ';');
+    writeln;
+  end;
+
+  OraLogout;
+  OraFin;
+end.
+

+ 1954 - 0
packages/base/oracle/oraoci.pp

@@ -0,0 +1,1954 @@
+{
+    $Id$
+    Copyright (c) 1999-2000 by Pavel Stingl <[email protected]>
+    
+
+    Oracle Call Interface Translation
+
+    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.
+
+ **********************************************************************}
+unit OraOCI;
+
+{$MODE FPC}
+{$linklib clntsh}
+{$linklib common}
+{$linklib core4}
+{$linklib nlsrtl3}
+{$linklib dl}
+{$linklib c}
+
+interface
+
+  type
+    sb1			= shortint;
+    ub1			= byte;
+    sb2			= integer;
+    ub2			= word;
+    sb4			= longint;
+    ub4			= cardinal;
+    eb1			= byte;
+    eb2			= word;
+    eb4			= cardinal;
+    sword		= integer;
+    uword		= integer;
+    eword		= integer;
+    PDouble		= ^double;
+    PLongint		= ^longint;
+    PPointer		= ^pointer;
+    PWord		= ^word;
+    PBoolean		= ^boolean;
+    PCardinal		= ^cardinal;
+    PByte		= ^byte;
+    
+
+    POCITime = ^OCITime;
+    OCITime = packed record
+      OCITimeHH      : ub1;
+      OCITimeMM      : ub1;
+      OCITimeSS      : ub1;
+    end;
+  
+    POCIDate = ^OCIDate;
+    OCIDate = packed record
+      OCIDateYYYY    : sb2;
+      OCIDateMM      : ub1;
+      OCIDateDD      : ub1;
+      OCIDateTime    : OCITime;
+    end;
+    
+    POCIDateTime = ^TOCIDate;
+    TOCIDate = packed record    
+      Year           : sb2;
+      Month          : ub1;
+      Day            : ub1;
+      Hour           : ub1;
+      Min            : ub1;
+      Sec            : ub1;    
+    end;
+
+    PCDA_DEF = ^TCDA_DEF;
+    TCDA_DEF = packed record
+      v2_rc 		: sb2;
+      ft 		: ub2;
+      rpc 		: ub4;
+      peo 		: ub2;
+      fc 		: ub1;
+      rcs1 		: ub1;
+      rc 		: ub2;
+      wrn 		: ub1;
+      rcs2 		: ub1;
+      rcs3 		: sword;
+        rid 		: record
+          rd 		: record
+            rcs4 	: ub4;
+            rcs5 	: ub2;
+            rcs6 	: ub1;
+          end;
+          rcs7 		: ub4;
+          rcs8	 	: ub2;
+        end;
+      ose 		: sword;
+      chk 		: ub1;
+      rcsp 		: pointer;
+      filler		: array [39..64] of byte;
+    end;
+    
+    PLDA_DEF		= ^TCDA_DEF;
+    TLDA_DEF		= TCDA_DEF;
+    
+    
+
+  const
+    EB4MAXVAL    	= 2147483647;
+    EB4MINVAL    	= 0;
+    UB4MAXVAL    	= $FFFFFFFF;
+    UB4MINVAL    	= 0;
+    SB4MAXVAL    	= 2147483647;
+    SB4MINVAL    	= -2147483647;
+    MINEB4MAXVAL 	= 2147483647;
+    MAXEB4MINVAL 	= 0;
+    MINUB4MAXVAL 	= $FFFFFFFF;
+    MAXUB4MINVAL 	= 0;
+    MINSB4MAXVAL 	= 2147483647;
+    MAXSB4MINVAL 	= -2147483647;
+
+  const
+     VARCHAR2_TYPE = 1;
+     NUMBER_TYPE = 2;
+     INT_TYPE = 3;
+     FLOAT_TYPE = 4;
+     STRING_TYPE = 5;
+     ROWID_TYPE = 11;
+     DATE_TYPE = 12;
+
+     { OCI Environment Modes for opinit call  }
+     OCI_EV_DEF = 0;  		{ default single-threaded environment  }
+     OCI_EV_TSF = 1;  		{ thread-safe environment  }
+
+     { OCI Logon Modes for olog call  }
+     OCI_LM_DEF = 0;  		{ default login  }
+     OCI_LM_NBL = 1;  		{ non-blocking logon  }
+
+     OCI_ONE_PIECE = 0;  	{ there or this is the only piece  }
+     OCI_FIRST_PIECE = 1;  	{ the first of many pieces  }
+     OCI_NEXT_PIECE = 2;  	{ the next of many pieces  }
+     OCI_LAST_PIECE = 3;  	{ the last piece of this column  }
+
+     { input data types  }
+     SQLT_CHR = 1;  		{ (ORANET TYPE) character string  }
+     SQLT_NUM = 2;  		{ (ORANET TYPE) oracle numeric  }
+     SQLT_INT = 3;  		{ (ORANET TYPE) integer  }
+     SQLT_FLT = 4;  		{ (ORANET TYPE) Floating point number  }
+     SQLT_STR = 5;  		{ zero terminated string  }
+     SQLT_VNU = 6;  		{ NUM with preceding length byte  }
+     SQLT_PDN = 7;  		{ (ORANET TYPE) Packed Decimal Numeric  }
+     SQLT_LNG = 8;  		{ long  }
+     SQLT_VCS = 9;  		{ Variable character string  }
+     SQLT_NON = 10;  		{ Null/empty PCC Descriptor entry  }
+     SQLT_RID = 11;  		{ rowid  }
+     SQLT_DAT = 12;  		{ date in oracle format  }
+     SQLT_VBI = 15;  		{ binary in VCS format  }
+     SQLT_BIN = 23;  		{ binary data(DTYBIN)  }
+     SQLT_LBI = 24;  		{ long binary  }
+     SQLT_UIN = 68;  		{ unsigned integer  }
+     SQLT_SLS = 91;  		{ Display sign leading separate  }
+     SQLT_LVC = 94;  		{ Longer longs (char)  }
+     SQLT_LVB = 95;  		{ Longer long binary  }
+     SQLT_AFC = 96;  		{ Ansi fixed char  }
+     SQLT_AVC = 97;  		{ Ansi Var char  }
+     SQLT_CUR = 102;  		{ cursor  type  }
+     SQLT_RDD = 104;  		{ rowid descriptor  }
+     SQLT_LAB = 105;  		{ label type  }
+     SQLT_OSL = 106;  		{ oslabel type  }
+     SQLT_NTY = 108;  		{ named object type  }
+     SQLT_REF = 110;  		{ ref type  }
+     SQLT_CLOB = 112;  		{ character lob  }
+     SQLT_BLOB = 113;  		{ binary lob  }
+     SQLT_BFILEE = 114;  	{ binary file lob  }
+     SQLT_CFILEE = 115;  	{ character file lob  }
+     SQLT_RSET = 116;  		{ result set type  }
+     SQLT_NCO = 122;  		{ named collection type (varray or nested table)  }
+     SQLT_VST = 155;  		{ OCIString type  }
+     SQLT_ODT = 156;  		{ OCIDate type  }
+
+     { binary file lob  }
+     SQLT_FILE = SQLT_BFILEE;
+     SQLT_CFILE = SQLT_CFILEE;
+     SQLT_BFILE = SQLT_BFILEE;
+
+     { CHAR/NCHAR/VARCHAR2/NVARCHAR2/CLOB/NCLOB char set "form" information  }
+     SQLCS_IMPLICIT = 1;  	{ for CHAR, VARCHAR2, CLOB w/o a specified set  }
+     SQLCS_NCHAR = 2;  		{ for NCHAR, NCHAR VARYING, NCLOB  }
+     SQLCS_EXPLICIT = 3;  	{ for CHAR, etc, with "CHARACTER SET ..." syntax  }
+     SQLCS_FLEXIBLE = 4;  	{ for PL/SQL "flexible" parameters  }
+     SQLCS_LIT_NULL = 5;  	{ for typecheck of NULL and empty_clob() lits  }
+     
+     { OCI Modes }
+     OCI_DEFAULT = $00;  { the default value for parameters and attributes  }
+     OCI_THREADED = $01;  { the application is in threaded environment  }
+     OCI_OBJECT = $02;  { the application is in object environment  }
+     OCI_NON_BLOCKING = $04;  { non blocking mode of operation  }
+     OCI_ENV_NO_MUTEX = $08;  { the environment handle will not be protected
+  				 by a mutex internally  }
+
+     { OCI Handle Types }
+     { handle types range from 1 - 49  }
+     OCI_HTYPE_FIRST = 1;  { start value of handle type  }
+     OCI_HTYPE_ENV = 1;  { environment handle  }
+     OCI_HTYPE_ERROR = 2;  { error handle  }
+     OCI_HTYPE_SVCCTX = 3;  { service handle  }
+     OCI_HTYPE_STMT = 4;  { statement handle  }
+     OCI_HTYPE_BIND = 5;  { bind handle  }
+     OCI_HTYPE_DEFINE = 6;  { define handle  }
+     OCI_HTYPE_DESCRIBE = 7;  { describe handle  }
+     OCI_HTYPE_SERVER = 8;  { server handle  }
+     OCI_HTYPE_SESSION = 9;  { authentication handle  }
+     OCI_HTYPE_TRANS = 10;  { transaction handle  }
+     OCI_HTYPE_COMPLEXOBJECT = 11;  { complex object retrieval handle  }
+     OCI_HTYPE_SECURITY = 12;  { security handle  }
+     OCI_HTYPE_LAST = 12;  { last value of a handle type  }
+
+     { Descriptor Types }
+     { descriptor values range from 50 - 255  }
+     OCI_DTYPE_FIRST = 50;  { start value of descriptor type  }
+     OCI_DTYPE_LOB = 50;  { lob  locator  }
+     OCI_DTYPE_SNAP = 51;  { snapshot descriptor  }
+     OCI_DTYPE_RSET = 52;  { result set descriptor  }
+     OCI_DTYPE_PARAM = 53;  { a parameter descriptor obtained from ocigparm  }
+     OCI_DTYPE_ROWID = 54;  { rowid descriptor  }
+     OCI_DTYPE_COMPLEXOBJECTCOMP = 55;  { complex object retrieval descriptor  }
+     OCI_DTYPE_FILE = 56;  { File Lob locator  }
+     OCI_DTYPE_AQENQ_OPTIONS = 57;  { enqueue options  }
+     OCI_DTYPE_AQDEQ_OPTIONS = 58;  { dequeue options  }
+     OCI_DTYPE_AQMSG_PROPERTIES = 59;  { message properties  }
+     OCI_DTYPE_AQAGENT = 60;  { aq agent  }
+     OCI_DTYPE_LAST = 60;  { last value of a descriptor type  }
+
+     { Object Ptr Types }
+     OCI_OTYPE_NAME = 1;  { object name  }
+     OCI_OTYPE_REF = 2;  { REF to TDO  }
+     OCI_OTYPE_PTR = 3;  { PTR to TDO  }
+
+  { Attribute Types }
+  { the OCI function code  }
+     OCI_ATTR_FNCODE = 1;  { the OCI function code  }
+     OCI_ATTR_OBJECT = 2;  { is the environment initialized in object mode  }
+     OCI_ATTR_NONBLOCKING_MODE = 3;  { non blocking mode  }
+     OCI_ATTR_SQLCODE = 4;  { the SQL verb  }
+     OCI_ATTR_ENV = 5;  { the environment handle  }
+     OCI_ATTR_SERVER = 6;  { the server handle  }
+     OCI_ATTR_SESSION = 7;  { the user session handle  }
+     OCI_ATTR_TRANS = 8;  { the transaction handle  }
+     OCI_ATTR_ROW_COUNT = 9;  { the rows processed so far  }
+     OCI_ATTR_SQLFNCODE = 10;  { the SQL verb of the statement  }
+     OCI_ATTR_PREFETCH_ROWS = 11;  { sets the number of rows to prefetch  }
+     OCI_ATTR_NESTED_PREFETCH_ROWS = 12;  { the prefetch rows of nested table }
+     OCI_ATTR_PREFETCH_MEMORY = 13;  { memory limit for rows fetched  }
+     OCI_ATTR_NESTED_PREFETCH_MEMORY = 14;  { memory limit for nested rows  }
+     OCI_ATTR_CHAR_COUNT = 15;  { this specifies the bind and define size in characters  }
+     OCI_ATTR_PDSCL = 16;  { packed decimal scale  }
+     OCI_ATTR_PDFMT = 17;  { packed decimal format  }
+     OCI_ATTR_PARAM_COUNT = 18;  { number of column in the select list  }
+     OCI_ATTR_ROWID = 19;  { the rowid  }
+     OCI_ATTR_CHARSET = 20;  { the character set value  }
+     OCI_ATTR_NCHAR = 21;  { NCHAR type  }
+     OCI_ATTR_USERNAME = 22;  { username attribute  }
+     OCI_ATTR_PASSWORD = 23;  { password attribute  }
+     OCI_ATTR_STMT_TYPE = 24;  { statement type  }
+     OCI_ATTR_INTERNAL_NAME = 25;  { user friendly global name  }
+     OCI_ATTR_EXTERNAL_NAME = 26;  { the internal name for global txn  }
+     OCI_ATTR_XID = 27;  { XOPEN defined global transaction id  }
+     OCI_ATTR_TRANS_LOCK = 28;  { transaction lock }
+     OCI_ATTR_TRANS_NAME = 29;  { string to identify a global transaction  }
+     OCI_ATTR_HEAPALLOC = 30;  { memory allocated on the heap  }
+     OCI_ATTR_CHARSET_ID = 31;  { Character Set ID  }
+     OCI_ATTR_CHARSET_FORM = 32;  { Character Set Form  }
+     OCI_ATTR_MAXDATA_SIZE = 33;  { Maximumsize of data on the server   }
+     OCI_ATTR_CACHE_OPT_SIZE = 34;  { object cache optimal size  }
+     OCI_ATTR_CACHE_MAX_SIZE = 35;  { object cache maximum size percentage  }
+     OCI_ATTR_PINOPTION = 36;  { object cache default pin option  }
+     OCI_ATTR_ALLOC_DURATION = 37;  { object cache default allocation duration  }
+     OCI_ATTR_PIN_DURATION = 38;  { object cache default pin duration  }
+     OCI_ATTR_FDO = 39;  { Format Descriptor object attribute  }
+     OCI_ATTR_POSTPROCESSING_CALLBACK = 40;  { Callback to process outbind data  }
+     OCI_ATTR_POSTPROCESSING_CONTEXT = 41;  { Callback context to process outbind data  }
+     OCI_ATTR_ROWS_RETURNED = 42;  { Number of rows returned in current iter - for Bind handles  }
+     OCI_ATTR_FOCBK = 43;  { Failover Callback attribute  }
+     OCI_ATTR_IN_V8_MODE = 44;  { is the server/service context in V8 mode  }
+     OCI_ATTR_LOBEMPTY = 45;  { empty lob ?  }
+     OCI_ATTR_SESSLANG = 46;  { session language handle  }
+
+  { Enqueue Options }
+     OCI_ATTR_VISIBILITY = 47;  { visibility  }
+     OCI_ATTR_RELATIVE_MSGID = 48;  { relative message id  }
+     OCI_ATTR_SEQUENCE_DEVIATION = 49;  { sequence deviation  }
+
+  { Dequeue Options }
+     OCI_ATTR_CONSUMER_NAME = 50;  { consumer name  }
+     OCI_ATTR_DEQ_MODE = 51;  { dequeue mode  }
+     OCI_ATTR_NAVIGATION = 52;  { navigation  }
+     OCI_ATTR_WAIT = 53;  { wait  }
+     OCI_ATTR_DEQ_MSGID = 54;  { dequeue message id  }
+
+  { Message Properties }
+     OCI_ATTR_PRIORITY = 55;  { priority  }
+     OCI_ATTR_DELAY = 56;  { delay  }
+     OCI_ATTR_EXPIRATION = 57;  { expiration  }
+     OCI_ATTR_CORRELATION = 58;  { correlation id  }
+     OCI_ATTR_ATTEMPTS = 59;  { # of attempts  }
+     OCI_ATTR_RECIPIENT_LIST = 60;  { recipient list  }
+     OCI_ATTR_EXCEPTION_QUEUE = 61;  { exception queue name  }
+     OCI_ATTR_ENQ_TIME = 62;  { enqueue time (only OCIAttrGet)  }
+     OCI_ATTR_MSG_STATE = 63;  { message state (only OCIAttrGet)  }
+
+  { AQ Agent }
+     OCI_ATTR_AGENT_NAME = 64;  { agent name  }
+     OCI_ATTR_AGENT_ADDRESS = 65;  { agent address  }
+     OCI_ATTR_AGENT_PROTOCOL = 66;  { agent protocol  }
+
+  { Parameter Attribute Types }
+     OCI_ATTR_UNK = 101;  { unknown attribute  }
+     OCI_ATTR_NUM_COLS = 102;  { number of columns  }
+     OCI_ATTR_LIST_COLUMNS = 103;  { parameter of the column list  }
+     OCI_ATTR_RDBA = 104;  { DBA of the segment header  }
+     OCI_ATTR_CLUSTERED = 105;  { whether the table is clustered  }
+     OCI_ATTR_PARTITIONED = 106;  { whether the table is partitioned  }
+     OCI_ATTR_INDEX_ONLY = 107;  { whether the table is index only  }
+     OCI_ATTR_LIST_ARGUMENTS = 108;  { parameter of the argument list  }
+     OCI_ATTR_LIST_SUBPROGRAMS = 109;  { parameter of the subprogram list  }
+     OCI_ATTR_REF_TDO = 110;  { REF to the type descriptor  }
+     OCI_ATTR_LINK = 111;  { the database link name  }
+     OCI_ATTR_MIN = 112;  { minimum value  }
+     OCI_ATTR_MAX = 113;  { maximum value  }
+     OCI_ATTR_INCR = 114;  { increment value  }
+     OCI_ATTR_CACHE = 115;  { number of sequence numbers cached  }
+     OCI_ATTR_ORDER = 116;  { whether the sequence is ordered  }
+     OCI_ATTR_HW_MARK = 117;  { high-water mark  }
+     OCI_ATTR_TYPE_SCHEMA = 118;  { type's schema name  }
+     OCI_ATTR_TIMESTAMP = 119;  { timestamp of the object  }
+     OCI_ATTR_NUM_ATTRS = 120;  { number of attributes  }
+     OCI_ATTR_NUM_PARAMS = 121;  { number of parameters  }
+     OCI_ATTR_OBJID = 122;  { object id for a table or view  }
+     OCI_ATTR_PTYPE = 123;  { type of info described by  }
+     OCI_ATTR_PARAM = 124;  { parameter descriptor  }
+     OCI_ATTR_OVERLOAD_ID = 125;  { overload ID for funcs and procs  }
+     OCI_ATTR_TABLESPACE = 126;  { table name space  }
+     OCI_ATTR_TDO = 127;  { TDO of a type  }
+     OCI_ATTR_PARSE_ERROR_OFFSET = 128;  { Parse Error offset  }
+
+  { Credential Types }
+     OCI_CRED_RDBMS = 1;  { database username/password  }
+     OCI_CRED_EXT = 2;  { externally provided credentials  }
+
+  { Error Return Values }
+     OCI_SUCCESS = 0;  { maps to SQL_SUCCESS of SAG CLI  }
+     OCI_SUCCESS_WITH_INFO = 1;  { maps to SQL_SUCCESS_WITH_INFO  }
+     OCI_NO_DATA = 100;  { maps to SQL_NO_DATA  }
+     OCI_ERROR = -(1);  { maps to SQL_ERROR  }
+     OCI_INVALID_HANDLE = -(2);  { maps to SQL_INVALID_HANDLE  }
+     OCI_NEED_DATA = 99;  { maps to SQL_NEED_DATA  }
+     OCI_STILL_EXECUTING = -(3123);  { OCI would block error  }
+     OCI_CONTINUE = -(24200);  { Continue with the body of the OCI function  }
+
+  { Parsing Syntax Types }
+     OCI_V7_SYNTAX = 2;  { V7 language  }
+     OCI_V8_SYNTAX = 3;  { V8 language  }
+     OCI_NTV_SYNTAX = 1;  
+     { Use what so ever is the native lang of server  }
+     { these values must match the values defined in kpul.h  }
+
+  { Scrollable Cursor Options }
+     OCI_FETCH_NEXT = $02;  { next row  }
+     OCI_FETCH_FIRST = $04;  { first row of the result set  }
+     OCI_FETCH_LAST = $08;  { the last row of the result set  }
+     OCI_FETCH_PRIOR = $10;  { the previous row relative to current  }
+     OCI_FETCH_ABSOLUTE = $20;  { absolute offset from first  }
+     OCI_FETCH_RELATIVE = $40;  { offset relative to current  }
+
+  { Bind and Define Options }
+     OCI_SB2_IND_PTR = $01;  { unused  }
+     OCI_DATA_AT_EXEC = $02;  { data at execute time  }
+     OCI_DYNAMIC_FETCH = $02;  { fetch dynamically  }
+     OCI_PIECEWISE = $04;  { piecewise DMLs or fetch  }
+
+  { Execution Modes }
+     OCI_BATCH_MODE = $01;  { batch the oci statement for execution  }
+     OCI_EXACT_FETCH = $02;  { fetch the exact rows specified  }
+     OCI_KEEP_FETCH_STATE = $04;  { unused  }
+     OCI_SCROLLABLE_CURSOR = $08;  { cursor scrollable  }
+     OCI_DESCRIBE_ONLY = $10;  { only describe the statement  }
+     OCI_COMMIT_ON_SUCCESS = $20;  { commit, if successful execution  }
+
+  { Authentication Modes }
+     OCI_MIGRATE = $0001;  { migratable auth context  }
+     OCI_SYSDBA = $0002;  { for SYSDBA authorization  }
+     OCI_SYSOPER = $0004;  { for SYSOPER authorization  }
+     OCI_PRELIM_AUTH = $0008;  { for preliminary authorization  }
+
+  { Piece Information }
+     OCI_PARAM_IN = $01;  { in parameter  }
+     OCI_PARAM_OUT = $02;  { out parameter  }
+
+  { Transaction Start Flags }
+  { NOTE: OCI_TRANS_JOIN and OCI_TRANS_NOMIGRATE not supported in 8.0.X        }
+  { starts a new transaction branch  }
+     OCI_TRANS_NEW = $00000001;  { starts a new transaction branch  }
+     OCI_TRANS_JOIN = $00000002;  { join an existing transaction  }
+     OCI_TRANS_RESUME = $00000004;  { resume this transaction  }
+     OCI_TRANS_STARTMASK = $000000ff;
+     OCI_TRANS_READONLY = $00000100;  { starts a readonly transaction  }
+     OCI_TRANS_READWRITE = $00000200;  { starts a read-write transaction  }
+     OCI_TRANS_SERIALIZABLE = $00000400;  { starts a serializable transaction  }
+     OCI_TRANS_ISOLMASK = $0000ff00;
+     OCI_TRANS_LOOSE = $00010000;  { a loosely coupled branch  }
+     OCI_TRANS_TIGHT = $00020000;  { a tightly coupled branch  }
+     OCI_TRANS_TYPEMASK = $000f0000;
+     OCI_TRANS_NOMIGRATE = $00100000;  { non migratable transaction  }
+
+  { Transaction End Flags }
+     OCI_TRANS_TWOPHASE = $01000000;  { use two phase commit  }
+
+  { AQ Constants 
+     NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE
+     The following constants must match the PL/SQL dbms_aq constants
+     NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE
+    }
+  { Visibility flags }
+     OCI_ENQ_IMMEDIATE = 1;  { enqueue is an independent transaction  }
+     OCI_ENQ_ON_COMMIT = 2;  { enqueue is part of current transaction  }
+     
+     OCI_DEQ_BROWSE = 1;  { read message without acquiring a lock  }
+     OCI_DEQ_LOCKED = 2;  { read and obtain write lock on message  }
+     OCI_DEQ_REMOVE = 3;  { read the message and delete it  }
+
+  { Dequeue navigation flags }
+     OCI_DEQ_FIRST_MSG = 1;  { get first message at head of queue  }
+     OCI_DEQ_NEXT_MSG = 3;  { next message that is available  }
+     OCI_DEQ_NEXT_TRANSACTION = 2;  { get first message of next txn group  }
+
+  { Message states }
+     OCI_MSG_WAITING = 1;  { the message delay has not yet completed  }
+     OCI_MSG_READY = 0;  { the message is ready to be processed  }
+     OCI_MSG_PROCESSED = 2;  { the message has been processed  }
+     OCI_MSG_EXPIRED = 3;  { message has moved to exception queue  }
+
+  { Sequence deviation }
+     OCI_ENQ_BEFORE = 2;  { enqueue message before another message  }
+     OCI_ENQ_TOP = 3;  { enqueue message before all messages  }
+
+  { Visibility flags }
+     OCI_DEQ_IMMEDIATE = 1;  { dequeue is an independent transaction  }
+     OCI_DEQ_ON_COMMIT = 2;  { dequeue is part of current transaction  }
+
+  { Wait }
+     OCI_DEQ_WAIT_FOREVER = -(1);  { wait forever if no message available  }
+     OCI_DEQ_NO_WAIT = 0;  { do not wait if no message is available  }
+
+  { Delay }
+     OCI_MSG_NO_DELAY = 0;  { message is available immediately  }
+
+  { Expiration }
+     OCI_MSG_NO_EXPIRATION = -(1);  { message will never expire  }
+
+  { -------------------------- END AQ Constants -----------------------------  }
+  {-----------Object Types      Not to be Used      -------------------------- }
+  { Deprecated  }
+     OCI_OTYPE_UNK = 0;
+     OCI_OTYPE_TABLE = 1;
+     OCI_OTYPE_VIEW = 2;
+     OCI_OTYPE_SYN = 3;
+     OCI_OTYPE_PROC = 4;
+     OCI_OTYPE_FUNC = 5;
+     OCI_OTYPE_PKG = 6;
+     OCI_OTYPE_STMT = 7;
+
+  { Describe Handle Parameter Attributes }
+  { Attributes common to Columns and Stored Procs  }
+     OCI_ATTR_DATA_SIZE = 1;  { maximum size of the data  }
+     OCI_ATTR_DATA_TYPE = 2;  { the SQL type of the column/argument  }
+     OCI_ATTR_DISP_SIZE = 3;  { the display size  }
+     OCI_ATTR_NAME = 4;  { the name of the column/argument  }
+     OCI_ATTR_PRECISION = 5;  { precision if number type  }
+     OCI_ATTR_SCALE = 6;  { scale if number type  }
+     OCI_ATTR_IS_NULL = 7;  { is it null ?  }
+     OCI_ATTR_TYPE_NAME = 8;  { name of the named data type or a package name for package private types  }
+     OCI_ATTR_SCHEMA_NAME = 9;  { the schema name  }
+     OCI_ATTR_SUB_NAME = 10;  { type name if package private type  }
+     OCI_ATTR_POSITION = 11;  { relative position of col/arg in the list of cols/args  }
+     OCI_ATTR_COMPLEXOBJECTCOMP_TYPE = 50;  { complex object retrieval parameter attributes  }
+     OCI_ATTR_COMPLEXOBJECTCOMP_TYPE_LEVEL = 51;
+     OCI_ATTR_COMPLEXOBJECT_LEVEL = 52;
+     OCI_ATTR_COMPLEXOBJECT_COLL_OUTOFLINE = 53;
+
+  { Only Columns  }
+     OCI_ATTR_DISP_NAME = 100;  { the display name  }
+
+  {Only Stored Procs  }
+     OCI_ATTR_OVERLOAD = 210;  { is this position overloaded  }
+     OCI_ATTR_LEVEL = 211;  { level for structured types  }
+     OCI_ATTR_HAS_DEFAULT = 212;  { has a default value  }
+     OCI_ATTR_IOMODE = 213;  { in, out inout  }
+     OCI_ATTR_RADIX = 214;  { returns a radix  }
+     OCI_ATTR_NUM_ARGS = 215;  { total number of arguments  }
+
+  { only named type attributes  }
+     OCI_ATTR_TYPECODE = 216;  { object or collection  }
+     OCI_ATTR_COLLECTION_TYPECODE = 217;  { varray or nested table  }
+     OCI_ATTR_VERSION = 218;  { user assigned version  }
+     OCI_ATTR_IS_INCOMPLETE_TYPE = 219;  { is this an incomplete type  }
+     OCI_ATTR_IS_SYSTEM_TYPE = 220;  { a system type  }
+     OCI_ATTR_IS_PREDEFINED_TYPE = 221;  { a predefined type  }
+     OCI_ATTR_IS_TRANSIENT_TYPE = 222;  { a transient type  }
+     OCI_ATTR_IS_SYSTEM_GENERATED_TYPE = 223;  { system generated type  }
+     OCI_ATTR_HAS_NESTED_TABLE = 224;  { contains nested table attr  }
+     OCI_ATTR_HAS_LOB = 225;  { has a lob attribute  }
+     OCI_ATTR_HAS_FILE = 226;  { has a file attribute  }
+     OCI_ATTR_COLLECTION_ELEMENT = 227;  { has a collection attribute  }
+     OCI_ATTR_NUM_TYPE_ATTRS = 228;  { number of attribute types  }
+     OCI_ATTR_LIST_TYPE_ATTRS = 229;  { list of type attributes  }
+     OCI_ATTR_NUM_TYPE_METHODS = 230;  { number of type methods  }
+     OCI_ATTR_LIST_TYPE_METHODS = 231;  { list of type methods  }
+     OCI_ATTR_MAP_METHOD = 232;  { map method of type  }
+     OCI_ATTR_ORDER_METHOD = 233;  { order method of type  }
+
+  { only collection element  }
+     OCI_ATTR_NUM_ELEMS = 234;  { number of elements  }
+
+  { only type methods  }
+     OCI_ATTR_ENCAPSULATION = 235;  { encapsulation level  }
+     OCI_ATTR_IS_SELFISH = 236;  { method selfish  }
+     OCI_ATTR_IS_VIRTUAL = 237;  { virtual  }
+     OCI_ATTR_IS_INLINE = 238;  { inline  }
+     OCI_ATTR_IS_CONSTANT = 239;  { constant  }
+     OCI_ATTR_HAS_RESULT = 240;  { has result  }
+     OCI_ATTR_IS_CONSTRUCTOR = 241;  { constructor  }
+     OCI_ATTR_IS_DESTRUCTOR = 242;  { destructor  }
+     OCI_ATTR_IS_OPERATOR = 243;  { operator  }
+     OCI_ATTR_IS_MAP = 244;  { a map method  }
+     OCI_ATTR_IS_ORDER = 245;  { order method  }
+     OCI_ATTR_IS_RNDS = 246;  { read no data state method  }
+     OCI_ATTR_IS_RNPS = 247;  { read no process state  }
+     OCI_ATTR_IS_WNDS = 248;  { write no data state method  }
+     OCI_ATTR_IS_WNPS = 249;  { write no process state  }
+
+  { describing public objects  }
+     OCI_ATTR_DESC_PUBLIC = 250;  { public object  }
+
+  {---------------------------OCIPasswordChange------------------------------- }
+     OCI_AUTH = $08;  { Change the password but do not login  }
+
+  {------------------------Other Constants------------------------------------ }
+     OCI_MAX_FNS = 100;  { max number of OCI Functions  }
+     OCI_SQLSTATE_SIZE = 5;
+     OCI_ERROR_MAXMSG_SIZE = 1024;  { max size of an error message  }
+     OCI_LOBMAXSIZE = MINUB4MAXVAL;  { maximum lob data size  }
+     OCI_ROWID_LEN = 23;
+  {------------------------ Fail Over Events --------------------------------- }
+     OCI_FO_END = $00000001;
+     OCI_FO_ABORT = $00000002;
+     OCI_FO_REAUTH = $00000004;
+     OCI_FO_BEGIN = $00000008;
+     OCI_FO_ERROR = $00000010;
+  {------------------------- Fail Over Types --------------------------------- }
+     OCI_FO_NONE = $00000001;
+     OCI_FO_SESSION = $00000002;
+     OCI_FO_SELECT = $00000004;
+     OCI_FO_TXNAL = $00000008;
+  {-----------------------Function Codes-------------------------------------- }
+  { OCIInitialize  }
+     OCI_FNCODE_INITIALIZE = 1;
+  { OCIHandleAlloc  }
+     OCI_FNCODE_HANDLEALLOC = 2;
+  { OCIHandleFree  }
+     OCI_FNCODE_HANDLEFREE = 3;
+  { OCIDescriptorAlloc  }
+     OCI_FNCODE_DESCRIPTORALLOC = 4;
+  { OCIDescriptorFree  }
+     OCI_FNCODE_DESCRIPTORFREE = 5;
+  { OCIEnvInit  }
+     OCI_FNCODE_ENVINIT = 6;
+  { OCIServerAttach  }
+     OCI_FNCODE_SERVERATTACH = 7;
+  { OCIServerDetach  }
+     OCI_FNCODE_SERVERDETACH = 8;
+  { unused         9  }
+  { OCISessionBegin  }
+     OCI_FNCODE_SESSIONBEGIN = 10;
+  { OCISessionEnd  }
+     OCI_FNCODE_SESSIONEND = 11;
+  { OCIPasswordChange  }
+     OCI_FNCODE_PASSWORDCHANGE = 12;
+  { OCIStmtPrepare  }
+     OCI_FNCODE_STMTPREPARE = 13;
+  { unused       14- 16  }
+  { OCIBindDynamic  }
+     OCI_FNCODE_BINDDYNAMIC = 17;
+  { OCIBindObject  }
+     OCI_FNCODE_BINDOBJECT = 18;
+  { 19 unused  }
+  { OCIBindArrayOfStruct  }
+     OCI_FNCODE_BINDARRAYOFSTRUCT = 20;
+  { OCIStmtExecute  }
+     OCI_FNCODE_STMTEXECUTE = 21;
+  { unused 22-24  }
+  { OCIDefineObject  }
+     OCI_FNCODE_DEFINEOBJECT = 25;
+  { OCIDefineDynamic  }
+     OCI_FNCODE_DEFINEDYNAMIC = 26;
+  { OCIDefineArrayOfStruct  }
+     OCI_FNCODE_DEFINEARRAYOFSTRUCT = 27;
+  { OCIStmtFetch  }
+     OCI_FNCODE_STMTFETCH = 28;
+  { OCIStmtGetBindInfo  }
+     OCI_FNCODE_STMTGETBIND = 29;
+  { 30, 31 unused  }
+  { OCIDescribeAny  }
+     OCI_FNCODE_DESCRIBEANY = 32;
+  { OCITransStart  }
+     OCI_FNCODE_TRANSSTART = 33;
+  { OCITransDetach  }
+     OCI_FNCODE_TRANSDETACH = 34;
+  { OCITransCommit  }
+     OCI_FNCODE_TRANSCOMMIT = 35;
+  { 36 unused  }
+  { OCIErrorGet  }
+     OCI_FNCODE_ERRORGET = 37;
+  { OCILobFileOpen  }
+     OCI_FNCODE_LOBOPENFILE = 38;
+  { OCILobFileClose  }
+     OCI_FNCODE_LOBCLOSEFILE = 39;
+  { 40 was LOBCREATEFILE, unused  }
+  { 41 was OCILobFileDelete, unused   }
+  { OCILobCopy  }
+     OCI_FNCODE_LOBCOPY = 42;
+  { OCILobAppend  }
+     OCI_FNCODE_LOBAPPEND = 43;
+  { OCILobErase  }
+     OCI_FNCODE_LOBERASE = 44;
+  { OCILobGetLength  }
+     OCI_FNCODE_LOBLENGTH = 45;
+  { OCILobTrim  }
+     OCI_FNCODE_LOBTRIM = 46;
+  { OCILobRead  }
+     OCI_FNCODE_LOBREAD = 47;
+  { OCILobWrite  }
+     OCI_FNCODE_LOBWRITE = 48;
+  { 49 unused  }
+  { OCIBreak  }
+     OCI_FNCODE_SVCCTXBREAK = 50;
+  { OCIServerVersion  }
+     OCI_FNCODE_SERVERVERSION = 51;
+  { unused 52, 53  }
+  { OCIAttrGet  }
+     OCI_FNCODE_ATTRGET = 54;
+  { OCIAttrSet  }
+     OCI_FNCODE_ATTRSET = 55;
+  { OCIParamSet  }
+     OCI_FNCODE_PARAMSET = 56;
+  { OCIParamGet  }
+     OCI_FNCODE_PARAMGET = 57;
+  { OCIStmtGetPieceInfo  }
+     OCI_FNCODE_STMTGETPIECEINFO = 58;
+  { OCILdaToSvcCtx  }
+     OCI_FNCODE_LDATOSVCCTX = 59;
+  { 60 unused  }
+  { OCIStmtSetPieceInfo  }
+     OCI_FNCODE_STMTSETPIECEINFO = 61;
+  { OCITransForget  }
+     OCI_FNCODE_TRANSFORGET = 62;
+  { OCITransPrepare  }
+     OCI_FNCODE_TRANSPREPARE = 63;
+  { OCITransRollback  }
+     OCI_FNCODE_TRANSROLLBACK = 64;
+  { OCIDefineByPos  }
+     OCI_FNCODE_DEFINEBYPOS = 65;
+  { OCIBindByPos  }
+     OCI_FNCODE_BINDBYPOS = 66;
+  { OCIBindByName  }
+     OCI_FNCODE_BINDBYNAME = 67;
+  { OCILobAssign  }
+     OCI_FNCODE_LOBASSIGN = 68;
+  { OCILobIsEqual  }
+     OCI_FNCODE_LOBISEQUAL = 69;
+  { OCILobLocatorIsInit  }
+     OCI_FNCODE_LOBISINIT = 70;
+  { 71 was lob locator size in beta2  }
+  { OCILobEnableBuffering  }
+     OCI_FNCODE_LOBENABLEBUFFERING = 71;
+  { OCILobCharSetID  }
+     OCI_FNCODE_LOBCHARSETID = 72;
+  { OCILobCharSetForm  }
+     OCI_FNCODE_LOBCHARSETFORM = 73;
+  { OCILobFileSetName  }
+     OCI_FNCODE_LOBFILESETNAME = 74;
+  { OCILobFileGetName  }
+     OCI_FNCODE_LOBFILEGETNAME = 75;
+  { OCILogon  }
+     OCI_FNCODE_LOGON = 76;
+  { OCILogoff  }
+     OCI_FNCODE_LOGOFF = 77;
+  { OCILobDisableBuffering  }
+     OCI_FNCODE_LOBDISABLEBUFFERING = 78;
+  { OCILobFlushBuffer  }
+     OCI_FNCODE_LOBFLUSHBUFFER = 79;
+  { OCILobLoadFromFile  }
+     OCI_FNCODE_LOBLOADFROMFILE = 80;
+     
+  {--------------------------- FILE open modes ------------------------------- }
+     OCI_FILE_READONLY = 1;  { readonly mode open for FILE types  }
+
+  {----------------------- LOB Buffering Flush Flags ------------------------- }
+     OCI_LOB_BUFFER_FREE = 1;
+     OCI_LOB_BUFFER_NOFREE = 2;
+
+  {--------------------------- OCI Statement Types --------------------------- }
+     OCI_STMT_SELECT = 1;  { select statement  }
+     OCI_STMT_UPDATE = 2;  { update statement  }
+     OCI_STMT_DELETE = 3;  { delete statement  }
+     OCI_STMT_INSERT = 4;  { Insert Statement  }
+     OCI_STMT_CREATE = 5;  { create statement  }
+     OCI_STMT_DROP = 6;  { drop statement  }
+     OCI_STMT_ALTER = 7;  { alter statement  }
+     OCI_STMT_BEGIN = 8;  { begin ... (pl/sql statement) }
+     OCI_STMT_DECLARE = 9;  { declare .. (pl/sql statement )  }
+
+  {--------------------------- OCI Parameter Types --------------------------- }
+     OCI_PTYPE_UNK = 0;  { unknown    }
+     OCI_PTYPE_TABLE = 1;  { table      }
+     OCI_PTYPE_VIEW = 2;  { view       }
+     OCI_PTYPE_PROC = 3;  { procedure  }
+     OCI_PTYPE_FUNC = 4;  { function   }
+     OCI_PTYPE_PKG = 5;  { package    }
+     OCI_PTYPE_TYPE = 6;  { user-defined type  }
+     OCI_PTYPE_SYN = 7;  { synonym    }
+     OCI_PTYPE_SEQ = 8;  { sequence   }
+     OCI_PTYPE_COL = 9;  { column     }
+     OCI_PTYPE_ARG = 10;  { argument   }
+     OCI_PTYPE_LIST = 11;  { list       }
+     OCI_PTYPE_TYPE_ATTR = 12;  { user-defined type's attribute  }
+     OCI_PTYPE_TYPE_COLL = 13;  { collection type's element  }
+     OCI_PTYPE_TYPE_METHOD = 14;  { collection type's element  }
+     OCI_PTYPE_TYPE_ARG = 15;  { user-defined type method's argument  }
+     OCI_PTYPE_TYPE_RESULT = 16;  { user-defined type method's result  }
+
+  {----------------------------- OCI List Types ------------------------------ }
+     OCI_LTYPE_UNK = 0;  { unknown    }
+     OCI_LTYPE_COLUMN = 1;  { column list  }
+     OCI_LTYPE_ARG_PROC = 2;  { procedure argument list  }
+     OCI_LTYPE_ARG_FUNC = 3;  { function argument list  }
+     OCI_LTYPE_SUBPRG = 4;  { subprogram list  }
+     OCI_LTYPE_TYPE_ATTR = 5;  { type attribute  }
+     OCI_LTYPE_TYPE_METHOD = 6;  { type method  }
+     OCI_LTYPE_TYPE_ARG_PROC = 7;  { type method w/o result argument list  }
+     OCI_LTYPE_TYPE_ARG_FUNC = 8;  { type method w/result argument list  }
+
+type { Handle Definitions
 }
+  OCIEnv           = pointer;  { OCI environment handle
 }
+  OCIError         = pointer;  { OCI error handle
 }
+  OCISvcCtx        = pointer;  { OCI service handle }
+  OCIStmt          = pointer;  { OCI statement handle }
+  OCIBind          = pointer;  { OCI bind handle
 }
+  OCIDefine        = pointer;  { OCI Define handle
 }
+  OCIDescribe      = pointer;  { OCI Describe handle
 }
+  OCIServer        = pointer;  { OCI Server handle
 }
+  OCISession       = pointer;  { OCI Authentication handle
 }
+  OCIComplexObject = pointer;  { OCI COR handle
 }
+  OCITrans         = pointer;  { OCI Transaction handle
 }
+  OCISecurity      = pointer;  { OCI Security handle
 }
+  OCIDirPathCtx    = pointer;  { OCI Direct Path handle
 }
+
+type
+  OCILobLocator	   	= pointer;  { OCI LOB Locator }
+  OCIType	   	= pointer;
+  OCICallbackInBind	= pointer;
+  OCICallbackOutBind   	= pointer;
+  OCISnapshot		= pointer;
+  OCIResult		= pointer;
+  OCICallbackDefine	= pointer;
+  OCIParam		= pointer;
+  
+
+  function OCIErrorGet(
+          hndlp:pointer; 
+	  recordno:cardinal; 
+	  sqlstate:PChar; 
+	  var errcodep:plongint; 
+	  bufp:PChar; 
+          bufsiz:cardinal; 
+	  AType:cardinal):sword;cdecl;
+
+  function OCIInitialize(
+          mode:cardinal; 
+	  ctxp:pointer; 
+	  malocfp:pointer; 
+	  ralocfp:pointer; 
+	  mfreefp:pointer):sword;cdecl;
+	  
+  function OCIHandleAlloc(
+          parenth:pointer; 
+	  var hndlpp:pointer; 
+	  AType:cardinal; 
+	  xtramem_sz:cardinal; 
+	  usrmempp:pointer):sword;cdecl;
+
+  function OCIHandleFree(
+          hndlp:pointer; 
+	  AType:cardinal):sword;cdecl;
+
+  function OCIEnvInit(
+	  var envp: OCIEnv;
+	    
+	  mode: ub4;
+	  xtramemsz: Integer;
+	  usrmempp: pointer): sword; cdecl;
+	  
+  function OCIDescriptorAlloc(
+          parenth:pointer; 
+	  descpp:pointer; 
+	  AType:cardinal; 
+	  xtramem_sz:cardinal; 
+	  usrmempp:pointer):sword;cdecl;
+
+  function OCIDescriptorFree(
+          descp:pointer;
+	  AType:cardinal):sword;cdecl;
+
+  function OCIServerAttach(
+          srvhp:OCIServer; 
+	  errhp:OCIError; 
+	  dblink:PChar; 
+	  dblink_len:longint; 
+	  mode:cardinal):sword;cdecl;
+
+  function OCIServerDetach(
+          srvhp:OCIServer; 
+	  errhp:OCIError; 
+	  mode:cardinal):sword;cdecl;
+
+  function OCISessionBegin(
+          svchp:OCISvcCtx; 
+	  errhp:OCIError; 
+	  usrhp:OCISession; 
+	  credt:cardinal; 
+	  mode:cardinal):sword;cdecl;
+
+  function OCISessionEnd(
+          svchp:OCISvcCtx; 
+	  errhp:OCIError; 
+	  usrhp:OCISession; 
+	  mode:cardinal):sword;cdecl;
+
+  function OCILogon(
+          envhp:OCIEnv; 
+	  errhp:OCIError; 
+	  var svchp:OCISvcCtx; 
+	  username:PChar; 
+	  uname_len:cardinal; 
+          password:PChar; 
+	  passwd_len:cardinal; 
+	  dbname:PChar; 
+	  dbname_len:cardinal):sword;cdecl;
+
+  function OCILogoff(
+          svchp:OCISvcCtx; 
+	  errhp:OCIError):sword;cdecl;
+	  
+  {----------------------------------------------------------------------------}
+
+  function OCIPasswordChange(
+          svchp:OCISvcCtx; 
+	  errhp:OCIError; 
+	  user_name:PChar; 
+	  usernm_len:cardinal; 
+	  opasswd:PChar; 
+	  opasswd_len:cardinal; 
+	  npasswd:PChar; 
+	  npasswd_len:cardinal; 
+	  mode:cardinal):sword;cdecl;
+
+  function OCIStmtPrepare(
+          stmtp:OCIStmt; 
+	  errhp:OCIError; 
+	  stmt:PChar; 
+	  stmt_len:cardinal; 
+	  language:cardinal; 
+	  mode:cardinal):sword;cdecl;
+
+  function OCIBindByPos(
+          stmtp:OCIStmt; 
+	  bindp:OCIBind; 
+	  errhp:OCIError; 
+	  position:cardinal; 
+	  valuep:pointer; 
+	  value_sz:longint; 
+	  dty:word; 
+	  indp:pointer; 
+	  alenp:pword; rcodep:pword; 
+	  maxarr_len:cardinal; 
+	  curelep:pcardinal; 
+	  mode:cardinal):sword;cdecl;
+
+  function OCIBindByName(
+          stmtp:OCIStmt; 
+	  bindp:OCIBind; 
+	  errhp:OCIError; 
+	  placeholder:PChar; 
+	  placeh_len:longint; 
+	  valuep:pointer; 
+	  value_sz:longint; 
+	  dty:word; 
+	  indp:pointer; 
+	  alenp:pword; 
+	  rcodep:pword; 
+	  maxarr_len:cardinal; 
+	  curelep:pcardinal; 
+	  mode:cardinal):sword;cdecl;
+
+  function OCIBindObject(
+          bindp:OCIBind; 
+	  errhp:OCIError; 
+	  AType:OCIType; 
+	  pgvpp:pointer; 
+	  pvszsp:pcardinal; 
+	  indpp:pointer; 
+	  indszp:pcardinal):sword;cdecl;
+
+  function OCIBindDynamic(
+          bindp:OCIBind; 
+	  errhp:OCIError; 
+	  ictxp:pointer; 
+	  icbfp:OCICallbackInBind; 
+	  octxp:pointer; 
+          ocbfp:OCICallbackOutBind):sword;cdecl;
+
+  function OCIBindArrayOfStruct(
+          bindp:OCIBind; 
+	  errhp:OCIError; 
+	  pvskip:cardinal; 
+	  indskip:cardinal; 
+	  alskip:cardinal; 
+          rcskip:cardinal):sword;cdecl;
+
+  function OCIStmtGetPieceInfo(
+          stmtp:OCIStmt; 
+	  errhp:OCIError; 
+	  hndlpp:pointer; 
+	  typep:pcardinal; 
+	  in_outp:pbyte; 
+          iterp:pcardinal; 
+	  idxp:pcardinal; 
+	  piecep:pbyte):sword;cdecl;
+
+  function OCIStmtSetPieceInfo(
+          hndlp:pointer; 
+	  AType:cardinal; 
+	  errhp:OCIError; 
+	  bufp:pointer; 
+	  alenp:pcardinal; 
+	  piece:byte; 
+	  indp:pointer; 
+	  rcodep:pword):sword;cdecl;
+
+  function OCIStmtExecute(
+          svchp:OCISvcCtx; 
+	  stmtp:OCIStmt; 
+	  errhp:OCIError; 
+	  iters:cardinal; 
+	  rowoff:cardinal; 
+          snap_in:OCISnapshot; 
+	  snap_out:OCISnapshot; 
+	  mode:cardinal):sword;cdecl;
+
+  function OCIDefineByPos(
+          stmtp:OCIStmt; 
+	  defnp:OCIDefine; 
+	  errhp:OCIError; 
+	  position:cardinal; 
+	  valuep:pointer; 
+          value_sz:longint; 
+	  dty:word; 
+	  indp:pointer; 
+	  rlenp:pword; 
+	  rcodep:pword; 
+          mode:cardinal):sword;cdecl;
+
+  function OCIDefineObject(
+          defnp:OCIDefine; 
+	  errhp:OCIError; 
+	  AType:OCIType; 
+	  pgvpp:pointer; 
+	  pvszsp:pcardinal; 
+    	  indpp:pointer; 
+	  indszp:pcardinal):sword;cdecl;
+
+  function OCIDefineDynamic(
+          defnp:OCIDefine; 
+	  errhp:OCIError; 
+	  octxp:pointer; 
+	  ocbfp:OCICallbackDefine):sword;cdecl;
+
+  function OCIDefineArrayOfStruct(
+          defnp:OCIDefine; 
+	  errhp:OCIError; 
+	  pvskip:cardinal; 
+	  indskip:cardinal; 
+	  rlskip:cardinal; 
+          rcskip:cardinal):sword;cdecl;
+
+  function OCIStmtFetch(
+          stmtp:OCIStmt; 
+	  errhp:OCIError; 
+	  nrows:cardinal; 
+	  orientation:word; 
+	  mode:cardinal):sword;cdecl;
+
+  function OCIStmtGetBindInfo(
+          stmtp:OCIStmt; 
+	  errhp:OCIError; 
+	  size:cardinal; 
+	  startloc:cardinal; 
+	  found:plongint; 
+          bvnp:PChar; 
+	  bvnl:byte; 
+	  invp:PChar; 
+	  inpl:byte; 
+	  dupl:byte; 
+          hndl:OCIBind):sword;cdecl;
+
+  function OCIDescribeAny(
+          svchp:OCISvcCtx; 
+	  errhp:OCIError; 
+	  objptr:pointer; 
+	  objnm_len:cardinal; 
+	  objptr_typ:byte; 
+          info_level:byte; 
+	  objtyp:byte; 
+	  dschp:OCIDescribe):sword;cdecl;
+
+  function OCIParamGet(
+          hndlp:pointer; 
+	  htype:cardinal; 
+	  errhp:OCIError; 
+	  parmdpp:pointer; 
+	  pos:cardinal):sword;cdecl;
+
+  function OCIParamSet(
+          hdlp:pointer; 
+	  htyp:cardinal; 
+	  errhp:OCIError; 
+	  dscp:pointer; 
+	  dtyp:cardinal; 
+          pos:cardinal):sword;cdecl;
+
+  function OCITransStart(
+          svchp:OCISvcCtx; 
+	  errhp:OCIError; 
+	  timeout:uword; 
+	  flags:cardinal):sword;cdecl;
+
+  function OCITransDetach(
+          svchp:OCISvcCtx; 
+	  errhp:OCIError; 
+	  flags:cardinal):sword;cdecl;
+
+  function OCITransCommit(
+          svchp:OCISvcCtx; 
+	  errhp:OCIError; 
+	  flags:cardinal):sword;cdecl;
+
+  function OCITransRollback(
+          svchp:OCISvcCtx; 
+	  errhp:OCIError; 
+	  flags:cardinal):sword;cdecl;
+
+  function OCITransPrepare(
+          svchp:OCISvcCtx; 
+	  errhp:OCIError; 
+	  flags:cardinal):sword;cdecl;
+
+  function OCITransForget(
+          svchp:OCISvcCtx; 
+	  errhp:OCIError; 
+	  flags:cardinal):sword;cdecl;
+
+  function OCILobAppend(
+          svchp:OCISvcCtx; 
+	  errhp:OCIError; 
+	  dst_locp:OCILobLocator; 
+	  src_locp:OCILobLocator):sword;cdecl;
+
+  function OCILobAssign(
+          envhp:OCIEnv; 
+	  errhp:OCIError; 
+	  src_locp:OCILobLocator; 
+	  dst_locpp:OCILobLocator):sword;cdecl;
+
+  function OCILobCharSetForm(
+          envhp:OCIEnv; 
+	  errhp:OCIError; 
+	  locp:OCILobLocator; 
+	  csfrm:pbyte):sword;cdecl;
+
+  function OCILobCharSetId(
+          envhp:OCIEnv; 
+	  errhp:OCIError; 
+	  locp:OCILobLocator; 
+	  csid:pword):sword;cdecl;
+
+  function OCILobCopy(
+          svchp:OCISvcCtx; 
+	  errhp:OCIError; 
+	  dst_locp:OCILobLocator; 
+	  src_locp:OCILobLocator; 
+	  amount:cardinal; 
+          dst_offset:cardinal; 
+	  src_offset:cardinal):sword;cdecl;
+
+  function OCILobDisableBuffering(
+          svchp:OCISvcCtx; 
+	  errhp:OCIError; 
+	  locp:OCILobLocator):sword;cdecl;
+
+  function OCILobEnableBuffering(
+          svchp:OCISvcCtx;
+	  errhp:OCIError; 
+	  locp:OCILobLocator):sword;cdecl;
+
+  function OCILobErase(
+          svchp:OCISvcCtx; 
+	  errhp:OCIError; 
+	  locp:OCILobLocator; 
+	  amount:pcardinal; 
+	  offset:cardinal):sword;cdecl;
+
+  function OCILobFileClose(
+          svchp:OCISvcCtx; 
+	  errhp:OCIError; 
+	  filep:OCILobLocator):sword;cdecl;
+
+  function OCILobFileCloseAll(
+          svchp:OCISvcCtx; 
+	  errhp:OCIError):sword;cdecl;
+
+  function OCILobFileExists(
+          svchp:OCISvcCtx; 
+	  errhp:OCIError; 
+	  filep:OCILobLocator; 
+	  flag:pboolean):sword;cdecl;
+
+  function OCILobFileGetName(
+          envhp:OCIEnv; 
+	  errhp:OCIError; 
+	  filep:OCILobLocator; 
+	  dir_alias:PChar; 
+	  d_length:pword; 
+    	  filename:PChar; 
+	  f_length:pword):sword;cdecl;
+
+  function OCILobFileIsOpen(
+          svchp:OCISvcCtx; 
+	  errhp:OCIError; 
+	  filep:OCILobLocator; 
+	  flag:pboolean):sword;cdecl;
+
+  function OCILobFileOpen(
+          svchp:OCISvcCtx; 
+	  errhp:OCIError; 
+	  filep:OCILobLocator; 
+	  mode:byte):sword;cdecl;
+
+  function OCILobFileSetName(
+          envhp:OCIEnv; 
+	  errhp:OCIError; 
+	  filepp:OCILobLocator; 
+	  dir_alias:PChar; 
+	  d_length:word; 
+    	  filename:PChar; 
+	  f_length:word):sword;cdecl;
+
+  function OCILobFlushBuffer(
+          svchp:OCISvcCtx; 
+	  errhp:OCIError; 
+	  locp:OCILobLocator; 
+	  flag:cardinal):sword;cdecl;
+
+  function OCILobGetLength(
+          svchp:OCISvcCtx; 
+	  errhp:OCIError; 
+	  locp:OCILobLocator; 
+	  lenp:pcardinal):sword;cdecl;
+
+  function OCILobIsEqual(
+          envhp:OCIEnv; 
+	  x:OCILobLocator; 
+	  y:OCILobLocator; 
+	  is_equal:pboolean):sword;cdecl;
+
+  function OCILobLoadFromFile(
+          svchp:OCISvcCtx; 
+	  errhp:OCIError; 
+	  dst_locp:OCILobLocator; 
+	  src_filep:OCILobLocator; 
+	  amount:cardinal; 
+	  dst_offset:cardinal; 
+	  src_offset:cardinal):sword;cdecl;
+
+  function OCILobLocatorIsInit(
+          envhp:OCIEnv; 
+	  errhp:OCIError; 
+	  locp:OCILobLocator; 
+	  is_initialized:pboolean):sword;cdecl;
+
+  function OCILobRead(
+          svchp:OCISvcCtx; 
+	  errhp:OCIError; 
+	  locp:OCILobLocator; 
+	  amtp:pcardinal; 
+	  offset:cardinal; 
+    	  bufp:pointer; 
+	  bufl:cardinal; 
+	  ctxp:pointer; 
+	  cbfp:pointer; 
+	  csid:word; 
+          csfrm:byte):sword;cdecl;
+
+  function OCILobTrim(
+          svchp:OCISvcCtx; 
+	  errhp:OCIError; 
+	  locp:OCILobLocator; 
+	  newlen:cardinal):sword;cdecl;
+
+  function OCILobWrite(
+          svchp:OCISvcCtx; 
+	  errhp:OCIError; 
+	  locp:OCILobLocator; 
+	  amtp:pcardinal; 
+	  offset:cardinal; 
+          bufp:pointer; 
+	  buflen:cardinal; 
+	  piece:byte; 
+	  ctxp:pointer; 
+	  cbfp:pointer; 
+          csid:word; 
+	  csfrm:byte):sword;cdecl;
+
+  function OCIBreak(
+          hndlp:pointer; 
+	  errhp:OCIError):sword;cdecl;
+
+  function OCIReset(
+          hndlp:pointer; 
+	  errhp:OCIError):sword;cdecl;
+
+  function OCIServerVersion(
+          hndlp:pointer; 
+	  errhp:OCIError; 
+	  bufp:PChar; 
+	  bufsz:cardinal; 
+	  hndltype:byte):sword;cdecl;
+
+  function OCIAttrGet(
+          trgthndlp:pointer; 
+	  trghndltyp:cardinal; 
+	  attributep:pointer; 
+	  sizep:pcardinal; 
+	  attrtype:cardinal; 
+          errhp:OCIError):sword;cdecl;
+
+  function OCIAttrSet(
+          trgthndlp:pointer; 
+	  trghndltyp:cardinal; 
+	  attributep:pointer; 
+	  size:cardinal; 
+	  attrtype:cardinal; 
+          errhp:OCIError):sword;cdecl;
+
+  function OCISvcCtxToLda(
+          svchp:OCISvcCtx; 
+	  errhp:OCIError; 
+	  ldap:pLda_Def):sword;cdecl;
+
+  function OCILdaToSvcCtx(
+          svchpp:OCISvcCtx; 
+	  errhp:OCIError; 
+	  ldap:pLda_Def):sword;cdecl;
+
+  function OCIResultSetToStmt(
+          rsetdp:OCIResult; 
+	  errhp:OCIError):sword;cdecl;
+
+  {-------------------------------------------------------------------------------------------}
+  { Security Package                                                                          }
+  {-------------------------------------------------------------------------------------------}
+  {
+  function OCISecurityInitialize(sechandle:pOCISecurity; error_handle:OCIError):sword;cdecl;
+
+  function OCISecurityTerminate(sechandle:pOCISecurity; error_handle:OCIError):sword;cdecl;
+
+  function OCISecurityOpenWallet(osshandle:pOCISecurity; error_handle:OCIError; wrllen:size_t; wallet_resource_locator:PChar; pwdlen:size_t; 
+             password:PChar; wallet:pnzttWallet):sword;cdecl;
+
+  function OCISecurityCloseWallet(osshandle:pOCISecurity; error_handle:OCIError; wallet:pnzttWallet):sword;cdecl;
+
+  function OCISecurityCreateWallet(osshandle:pOCISecurity; error_handle:OCIError; wrllen:size_t; wallet_resource_locator:PChar; pwdlen:size_t; 
+             password:PChar; wallet:pnzttWallet):sword;cdecl;
+
+  function OCISecurityDestroyWallet(osshandle:pOCISecurity; error_handle:OCIError; wrllen:size_t; wallet_resource_locator:PChar; pwdlen:size_t; 
+             password:PChar):sword;cdecl;
+
+  function OCISecurityStorePersona(osshandle:pOCISecurity; error_handle:OCIError; persona:ppnzttPersona; wallet:pnzttWallet):sword;cdecl;
+
+  function OCISecurityOpenPersona(osshandle:pOCISecurity; error_handle:OCIError; persona:pnzttPersona):sword;cdecl;
+
+  function OCISecurityClosePersona(osshandle:pOCISecurity; error_handle:OCIError; persona:pnzttPersona):sword;cdecl;
+
+  function OCISecurityRemovePersona(osshandle:pOCISecurity; error_handle:OCIError; persona:ppnzttPersona):sword;cdecl;
+
+  function OCISecurityCreatePersona(osshandle:pOCISecurity; error_handle:OCIError; identity_type:nzttIdentType; cipher_type:nzttCipherType; desc:pnzttPersonaDesc; 
+             persona:ppnzttPersona):sword;cdecl;
+
+  function OCISecuritySetProtection(osshandle:pOCISecurity; error_handle:OCIError; persona:pnzttPersona; crypto_engine_function:nzttcef; data_unit_format:nztttdufmt; 
+             protection_info:pnzttProtInfo):sword;cdecl;
+
+  function OCISecurityGetProtection(osshandle:pOCISecurity; error_handle:OCIError; persona:pnzttPersona; crypto_engine_function:nzttcef; data_unit_format_ptr:pnztttdufmt; 
+             protection_info:pnzttProtInfo):sword;cdecl;
+
+  function OCISecurityRemoveIdentity(osshandle:pOCISecurity; error_handle:OCIError; identity_ptr:ppnzttIdentity):sword;cdecl;
+
+  function OCISecurityCreateIdentity(osshandle:pOCISecurity; error_handle:OCIError; AType:nzttIdentType; desc:pnzttIdentityDesc; identity_ptr:ppnzttIdentity):sword;cdecl;
+
+  function OCISecurityAbortIdentity(osshandle:pOCISecurity; error_handle:OCIError; identity_ptr:ppnzttIdentity):sword;cdecl;
+
+  function OCISecurityFreeIdentity(osshandle:pOCISecurity; error_handle:OCIError; identity_ptr:ppnzttIdentity):sword;cdecl;
+
+  function OCISecurityStoreTrustedIdentity(osshandle:pOCISecurity; error_handle:OCIError; identity_ptr:ppnzttIdentity; persona:pnzttPersona):sword;cdecl;
+
+  function OCISecuritySign(osshandle:pOCISecurity; error_handle:OCIError; persona:pnzttPersona; signature_state:nzttces; input_length:size_t; 
+             input:pbyte; buffer_block:pnzttBufferBlock):sword;cdecl;
+
+  function OCISecuritySignExpansion(osshandle:pOCISecurity; error_handle:OCIError; persona:pnzttPersona; inputlen:size_t; signature_length:psize_t):sword;cdecl;
+
+  function OCISecurityVerify(osshandle:pOCISecurity; error_handle:OCIError; persona:pnzttPersona; signature_state:nzttces; siglen:size_t; 
+             signature:pbyte; extracted_message:pnzttBufferBlock; verified:pboolean; validated:pboolean; signing_party_identity:ppnzttIdentity):sword;cdecl;
+
+  function OCISecurityValidate(osshandle:pOCISecurity; error_handle:OCIError; persona:pnzttPersona; identity:pnzttIdentity; validated:pboolean):sword;cdecl;
+
+  function OCISecuritySignDetached(osshandle:pOCISecurity; error_handle:OCIError; persona:pnzttPersona; signature_state:nzttces; input_length:size_t; 
+             input:pbyte; signature:pnzttBufferBlock):sword;cdecl;
+
+  function OCISecuritySignDetExpansion(osshandle:pOCISecurity; error_handle:OCIError; persona:pnzttPersona; input_length:size_t; required_buffer_length:psize_t):sword;cdecl;
+
+  function OCISecurityVerifyDetached(osshandle:pOCISecurity; error_handle:OCIError; persona:pnzttPersona; signature_state:nzttces; data_length:size_t; 
+             data:pbyte; siglen:size_t; signature:pbyte; verified:pboolean; validated:pboolean; 
+             signing_party_identity:ppnzttIdentity):sword;cdecl;
+
+  function OCISecurity_PKEncrypt(osshandle:pOCISecurity; error_handle:OCIError; persona:pnzttPersona; number_of_recipients:size_t; recipient_list:pnzttIdentity; 
+             encryption_state:nzttces; input_length:size_t; input:pbyte; encrypted_data:pnzttBufferBlock):sword;cdecl;
+
+  function OCISecurityPKEncryptExpansion(osshandle:pOCISecurity; error_handle:OCIError; persona:pnzttPersona; number_recipients:size_t; input_length:size_t; 
+             buffer_length_required:psize_t):sword;cdecl;
+
+  function OCISecurityPKDecrypt(osshandle:pOCISecurity; error_handle:OCIError; persona:pnzttPersona; encryption_state:nzttces; input_length:size_t; 
+             input:pbyte; encrypted_data:pnzttBufferBlock):sword;cdecl;
+
+  function OCISecurityEncrypt(osshandle:pOCISecurity; error_handle:OCIError; persona:pnzttPersona; encryption_state:nzttces; input_length:size_t; 
+             input:pbyte; encrypted_data:pnzttBufferBlock):sword;cdecl;
+
+  function OCISecurityEncryptExpansion(osshandle:pOCISecurity; error_handle:OCIError; persona:pnzttPersona; input_length:size_t; encrypted_data_length:psize_t):sword;cdecl;
+
+  function OCISecurityDecrypt(osshandle:pOCISecurity; error_handle:OCIError; persona:pnzttPersona; decryption_state:nzttces; input_length:size_t; 
+             input:pbyte; decrypted_data:pnzttBufferBlock):sword;cdecl;
+
+  function OCISecurityEnvelope(osshandle:pOCISecurity; error_handle:OCIError; persona:pnzttPersona; number_of_recipients:size_t; identity:pnzttIdentity; 
+             encryption_state:nzttces; input_length:size_t; input:pbyte; enveloped_data:pnzttBufferBlock):sword;cdecl;
+
+  function OCISecurityDeEnvelope(osshandle:pOCISecurity; error_handle:OCIError; persona:pnzttPersona; decryption_state:nzttces; input_length:size_t; 
+             input:pbyte; output_message:pnzttBufferBlock; verified:pboolean; validated:pboolean; sender_identity:ppnzttIdentity):sword;cdecl;
+
+  function OCISecurityKeyedHash(osshandle:pOCISecurity; error_handle:OCIError; persona:pnzttPersona; hash_state:nzttces; input_length:size_t; 
+             input:pbyte; keyed_hash:pnzttBufferBlock):sword;cdecl;
+
+  function OCISecurityKeyedHashExpansion(osshandle:pOCISecurity; error_handle:OCIError; persona:pnzttPersona; input_length:size_t; required_buffer_length:psize_t):sword;cdecl;
+
+  function OCISecurityHash(osshandle:pOCISecurity; error_handle:OCIError; persona:pnzttPersona; hash_state:nzttces; input:size_t; 
+             input_length:pbyte; hash:pnzttBufferBlock):sword;cdecl;
+
+  function OCISecurityHashExpansion(osshandle:pOCISecurity; error_handle:OCIError; persona:pnzttPersona; input_length:size_t; required_buffer_length:psize_t):sword;cdecl;
+
+  function OCISecuritySeedRandom(osshandle:pOCISecurity; error_handle:OCIError; persona:pnzttPersona; seed_length:size_t; seed:pbyte):sword;cdecl;
+
+  function OCISecurityRandomBytes(osshandle:pOCISecurity; error_handle:OCIError; persona:pnzttPersona; number_of_bytes_desired:size_t; random_bytes:pnzttBufferBlock):sword;cdecl;
+
+  function OCISecurityRandomNumber(osshandle:pOCISecurity; error_handle:OCIError; persona:pnzttPersona; random_number_ptr:puword):sword;cdecl;
+
+  function OCISecurityInitBlock(osshandle:pOCISecurity; error_handle:OCIError; buffer_block:pnzttBufferBlock):sword;cdecl;
+
+  function OCISecurityReuseBlock(osshandle:pOCISecurity; error_handle:OCIError; buffer_block:pnzttBufferBlock):sword;cdecl;
+
+  function OCISecurityPurgeBlock(osshandle:pOCISecurity; error_handle:OCIError; buffer_block:pnzttBufferBlock):sword;cdecl;
+
+  function OCISecuritySetBlock(osshandle:pOCISecurity; error_handle:OCIError; flags_to_set:uword; buffer_length:size_t; used_buffer_length:size_t; 
+             buffer:pbyte; buffer_block:pnzttBufferBlock):sword;cdecl;
+
+  function OCISecurityGetIdentity(osshandle:pOCISecurity; error_handle:OCIError; namelen:size_t; distinguished_name:PChar; identity:ppnzttIdentity):sword;cdecl;
+
+  function OCIAQEnq(svchp:OCISvcCtx; errhp:OCIError; queue_name:PChar; enqopt:pOCIAQEnqOptions; msgprop:pOCIAQMsgProperties; 
+             payload_tdo:pOCIType; payload:ppointer; payload_ind:ppointer; msgid:ppOCIRaw; flags:cardinal):sword;cdecl;
+
+  function OCIAQDeq(svchp:OCISvcCtx; errhp:OCIError; queue_name:PChar; deqopt:pOCIAQDeqOptions; msgprop:pOCIAQMsgProperties; 
+             payload_tdo:pOCIType; payload:ppointer; payload_ind:ppointer; msgid:ppOCIRaw; flags:cardinal):sword;cdecl;
+}
+
+  {-------------------------------------------------------------------------------------------}
+  { Datatype Mapping                                                                          }
+  {-------------------------------------------------------------------------------------------}
+
+  function OCIDateToText(
+      err:OCIError; 
+	  date:POCIDate; 
+	  fmt:PChar; 
+	  fmt_length:ub1; 
+	  lang_name:PChar; 
+      lang_length:ub4; 
+	  buf_size:PCardinal; 
+	  buf:PChar):sword;cdecl;
+
+implementation
+
+  function OCIInitialize(
+          mode:cardinal; 
+	  ctxp:pointer; 
+	  malocfp:pointer; 
+	  ralocfp:pointer; 
+	  mfreefp:pointer):sword;cdecl;external;
+
+  function OCIHandleAlloc(
+          parenth:pointer; 
+	  var hndlpp:pointer; 
+	  AType:cardinal; 
+	  xtramem_sz:cardinal; 
+	  usrmempp:pointer):sword;cdecl;external;
+
+  function OCIHandleFree(
+          hndlp:pointer; 
+	  AType:cardinal):sword;cdecl;external;
+
+  function OCIEnvInit(
+	  var envp: OCIEnv;
+	    
+	  mode: ub4;
+	  xtramemsz: Integer;
+	  usrmempp: pointer): sword; cdecl;external;
+
+  function OCIDescriptorAlloc(
+          parenth:pointer; 
+	  descpp:pointer; 
+	  AType:cardinal; 
+	  xtramem_sz:cardinal; 
+	  usrmempp:pointer):sword;cdecl;external;
+
+  function OCIDescriptorFree(
+          descp:pointer;
+	  AType:cardinal):sword;cdecl;external;
+
+  function OCIServerAttach(
+          srvhp:OCIServer; 
+	  errhp:OCIError; 
+	  dblink:PChar; 
+	  dblink_len:longint; 
+	  mode:cardinal):sword;cdecl;external;
+
+  function OCIServerDetach(
+          srvhp:OCIServer; 
+	  errhp:OCIError; 
+	  mode:cardinal):sword;cdecl;external;
+
+  function OCISessionBegin(
+          svchp:OCISvcCtx; 
+	  errhp:OCIError; 
+	  usrhp:OCISession; 
+	  credt:cardinal; 
+	  mode:cardinal):sword;cdecl;external;
+
+  function OCISessionEnd(
+          svchp:OCISvcCtx; 
+	  errhp:OCIError; 
+	  usrhp:OCISession; 
+	  mode:cardinal):sword;cdecl;external;
+
+  function OCILogon(
+          envhp:OCIEnv; 
+	  errhp:OCIError; 
+	  var svchp:OCISvcCtx; 
+	  username:PChar; 
+	  uname_len:cardinal; 
+          password:PChar; 
+	  passwd_len:cardinal; 
+	  dbname:PChar; 
+	  dbname_len:cardinal):sword;cdecl;external;
+
+  function OCILogoff(
+          svchp:OCISvcCtx; 
+	  errhp:OCIError):sword;cdecl;external;
+
+  function OCIErrorGet(
+          hndlp:pointer; 
+	  recordno:cardinal; 
+	  sqlstate:PChar; 
+	  var errcodep:PLongint; 
+	  bufp:PChar; 
+          bufsiz:cardinal; 
+	  AType:cardinal):sword;cdecl;external;
+
+  function OCIPasswordChange(
+          svchp:OCISvcCtx; 
+	  errhp:OCIError; 
+	  user_name:PChar; 
+	  usernm_len:cardinal; 
+	  opasswd:PChar; 
+	  opasswd_len:cardinal; 
+	  npasswd:PChar; 
+	  npasswd_len:cardinal; 
+	  mode:cardinal):sword;cdecl;external;
+
+  function OCIStmtPrepare(
+          stmtp:OCIStmt; 
+	  errhp:OCIError; 
+	  stmt:PChar; 
+	  stmt_len:cardinal; 
+	  language:cardinal; 
+	  mode:cardinal):sword;cdecl;external;
+
+  function OCIBindByPos(
+          stmtp:OCIStmt; 
+	  bindp:OCIBind; 
+	  errhp:OCIError; 
+	  position:cardinal; 
+	  valuep:pointer; 
+	  value_sz:longint; 
+	  dty:word; 
+	  indp:pointer; 
+	  alenp:pword; rcodep:pword; 
+	  maxarr_len:cardinal; 
+	  curelep:pcardinal; 
+	  mode:cardinal):sword;cdecl;external;
+
+  function OCIBindByName(
+          stmtp:OCIStmt; 
+	  bindp:OCIBind; 
+	  errhp:OCIError; 
+	  placeholder:PChar; 
+	  placeh_len:longint; 
+	  valuep:pointer; 
+	  value_sz:longint; 
+	  dty:word; 
+	  indp:pointer; 
+	  alenp:pword; 
+	  rcodep:pword; 
+	  maxarr_len:cardinal; 
+	  curelep:pcardinal; 
+	  mode:cardinal):sword;cdecl;external;
+
+  function OCIBindObject(
+          bindp:OCIBind; 
+	  errhp:OCIError; 
+	  AType:OCIType; 
+	  pgvpp:pointer; 
+	  pvszsp:pcardinal; 
+	  indpp:pointer; 
+	  indszp:pcardinal):sword;cdecl;external;
+
+  function OCIBindDynamic(
+          bindp:OCIBind; 
+	  errhp:OCIError; 
+	  ictxp:pointer; 
+	  icbfp:OCICallbackInBind; 
+	  octxp:pointer; 
+          ocbfp:OCICallbackOutBind):sword;cdecl;external;
+
+  function OCIBindArrayOfStruct(
+          bindp:OCIBind; 
+	  errhp:OCIError; 
+	  pvskip:cardinal; 
+	  indskip:cardinal; 
+	  alskip:cardinal; 
+          rcskip:cardinal):sword;cdecl;external;
+
+  function OCIStmtGetPieceInfo(
+          stmtp:OCIStmt; 
+	  errhp:OCIError; 
+	  hndlpp:pointer; 
+	  typep:pcardinal; 
+	  in_outp:pbyte; 
+          iterp:pcardinal; 
+	  idxp:pcardinal; 
+	  piecep:pbyte):sword;cdecl;external;
+
+  function OCIStmtSetPieceInfo(
+          hndlp:pointer; 
+	  AType:cardinal; 
+	  errhp:OCIError; 
+	  bufp:pointer; 
+	  alenp:pcardinal; 
+	  piece:byte; 
+	  indp:pointer; 
+	  rcodep:pword):sword;cdecl;external;
+
+  function OCIStmtExecute(
+          svchp:OCISvcCtx; 
+	  stmtp:OCIStmt; 
+	  errhp:OCIError; 
+	  iters:cardinal; 
+	  rowoff:cardinal; 
+          snap_in:OCISnapshot; 
+	  snap_out:OCISnapshot; 
+	  mode:cardinal):sword;cdecl;external;
+
+  function OCIDefineByPos(
+          stmtp:OCIStmt; 
+	  defnp:OCIDefine; 
+	  errhp:OCIError; 
+	  position:cardinal; 
+	  valuep:pointer; 
+          value_sz:longint; 
+	  dty:word; 
+	  indp:pointer; 
+	  rlenp:pword; 
+	  rcodep:pword; 
+          mode:cardinal):sword;cdecl;external;
+
+  function OCIDefineObject(
+          defnp:OCIDefine; 
+	  errhp:OCIError; 
+	  AType:OCIType; 
+	  pgvpp:pointer; 
+	  pvszsp:pcardinal; 
+    	  indpp:pointer; 
+	  indszp:pcardinal):sword;cdecl;external;
+
+  function OCIDefineDynamic(
+          defnp:OCIDefine; 
+	  errhp:OCIError; 
+	  octxp:pointer; 
+	  ocbfp:OCICallbackDefine):sword;cdecl;external;
+
+  function OCIDefineArrayOfStruct(
+          defnp:OCIDefine; 
+	  errhp:OCIError; 
+	  pvskip:cardinal; 
+	  indskip:cardinal; 
+	  rlskip:cardinal; 
+          rcskip:cardinal):sword;cdecl;external;
+
+  function OCIStmtFetch(
+          stmtp:OCIStmt; 
+	  errhp:OCIError; 
+	  nrows:cardinal; 
+	  orientation:word; 
+	  mode:cardinal):sword;cdecl;external;
+
+  function OCIStmtGetBindInfo(
+          stmtp:OCIStmt; 
+	  errhp:OCIError; 
+	  size:cardinal; 
+	  startloc:cardinal; 
+	  found:plongint; 
+          bvnp:PChar; 
+	  bvnl:byte; 
+	  invp:PChar; 
+	  inpl:byte; 
+	  dupl:byte; 
+          hndl:OCIBind):sword;cdecl;external;
+
+  function OCIDescribeAny(
+          svchp:OCISvcCtx; 
+	  errhp:OCIError; 
+	  objptr:pointer; 
+	  objnm_len:cardinal; 
+	  objptr_typ:byte; 
+          info_level:byte; 
+	  objtyp:byte; 
+	  dschp:OCIDescribe):sword;cdecl;external;
+
+  function OCIParamGet(
+          hndlp:pointer; 
+	  htype:cardinal; 
+	  errhp:OCIError; 
+	  parmdpp:pointer; 
+	  pos:cardinal):sword;cdecl;external;
+
+  function OCIParamSet(
+          hdlp:pointer; 
+	  htyp:cardinal; 
+	  errhp:OCIError; 
+	  dscp:pointer; 
+	  dtyp:cardinal; 
+          pos:cardinal):sword;cdecl;external;
+
+  function OCITransStart(
+          svchp:OCISvcCtx; 
+	  errhp:OCIError; 
+	  timeout:uword; 
+	  flags:cardinal):sword;cdecl;external;
+
+  function OCITransDetach(
+          svchp:OCISvcCtx; 
+	  errhp:OCIError; 
+	  flags:cardinal):sword;cdecl;external;
+
+  function OCITransCommit(
+          svchp:OCISvcCtx; 
+	  errhp:OCIError; 
+	  flags:cardinal):sword;cdecl;external;
+
+  function OCITransRollback(
+          svchp:OCISvcCtx; 
+	  errhp:OCIError; 
+	  flags:cardinal):sword;cdecl;external;
+
+  function OCITransPrepare(
+          svchp:OCISvcCtx; 
+	  errhp:OCIError; 
+	  flags:cardinal):sword;cdecl;external;
+
+  function OCITransForget(
+          svchp:OCISvcCtx; 
+	  errhp:OCIError; 
+	  flags:cardinal):sword;cdecl;external;
+
+  function OCILobAppend(
+          svchp:OCISvcCtx; 
+	  errhp:OCIError; 
+	  dst_locp:OCILobLocator; 
+	  src_locp:OCILobLocator):sword;cdecl;external;
+
+  function OCILobAssign(
+          envhp:OCIEnv; 
+	  errhp:OCIError; 
+	  src_locp:OCILobLocator; 
+	  dst_locpp:OCILobLocator):sword;cdecl;external;
+
+  function OCILobCharSetForm(
+          envhp:OCIEnv; 
+	  errhp:OCIError; 
+	  locp:OCILobLocator; 
+	  csfrm:pbyte):sword;cdecl;external;
+
+  function OCILobCharSetId(
+          envhp:OCIEnv; 
+	  errhp:OCIError; 
+	  locp:OCILobLocator; 
+	  csid:pword):sword;cdecl;external;
+
+  function OCILobCopy(
+          svchp:OCISvcCtx; 
+	  errhp:OCIError; 
+	  dst_locp:OCILobLocator; 
+	  src_locp:OCILobLocator; 
+	  amount:cardinal; 
+          dst_offset:cardinal; 
+	  src_offset:cardinal):sword;cdecl;external;
+
+  function OCILobDisableBuffering(
+          svchp:OCISvcCtx; 
+	  errhp:OCIError; 
+	  locp:OCILobLocator):sword;cdecl;external;
+
+  function OCILobEnableBuffering(
+          svchp:OCISvcCtx;
+	  errhp:OCIError; 
+	  locp:OCILobLocator):sword;cdecl;external;
+
+  function OCILobErase(
+          svchp:OCISvcCtx; 
+	  errhp:OCIError; 
+	  locp:OCILobLocator; 
+	  amount:pcardinal; 
+	  offset:cardinal):sword;cdecl;external;
+
+  function OCILobFileClose(
+          svchp:OCISvcCtx; 
+	  errhp:OCIError; 
+	  filep:OCILobLocator):sword;cdecl;external;
+
+  function OCILobFileCloseAll(
+          svchp:OCISvcCtx; 
+	  errhp:OCIError):sword;cdecl;external;
+
+  function OCILobFileExists(
+          svchp:OCISvcCtx; 
+	  errhp:OCIError; 
+	  filep:OCILobLocator; 
+	  flag:pboolean):sword;cdecl;external;
+
+  function OCILobFileGetName(
+          envhp:OCIEnv; 
+	  errhp:OCIError; 
+	  filep:OCILobLocator; 
+	  dir_alias:PChar; 
+	  d_length:pword; 
+    	  filename:PChar; 
+	  f_length:pword):sword;cdecl;external;
+
+  function OCILobFileIsOpen(
+          svchp:OCISvcCtx; 
+	  errhp:OCIError; 
+	  filep:OCILobLocator; 
+	  flag:pboolean):sword;cdecl;external;
+
+  function OCILobFileOpen(
+          svchp:OCISvcCtx; 
+	  errhp:OCIError; 
+	  filep:OCILobLocator; 
+	  mode:byte):sword;cdecl;external;
+
+  function OCILobFileSetName(
+          envhp:OCIEnv; 
+	  errhp:OCIError; 
+	  filepp:OCILobLocator; 
+	  dir_alias:PChar; 
+	  d_length:word; 
+    	  filename:PChar; 
+	  f_length:word):sword;cdecl;external;
+
+  function OCILobFlushBuffer(
+          svchp:OCISvcCtx; 
+	  errhp:OCIError; 
+	  locp:OCILobLocator; 
+	  flag:cardinal):sword;cdecl;external;
+
+  function OCILobGetLength(
+          svchp:OCISvcCtx; 
+	  errhp:OCIError; 
+	  locp:OCILobLocator; 
+	  lenp:pcardinal):sword;cdecl;external;
+
+  function OCILobIsEqual(
+          envhp:OCIEnv; 
+	  x:OCILobLocator; 
+	  y:OCILobLocator; 
+	  is_equal:pboolean):sword;cdecl;external;
+
+  function OCILobLoadFromFile(
+          svchp:OCISvcCtx; 
+	  errhp:OCIError; 
+	  dst_locp:OCILobLocator; 
+	  src_filep:OCILobLocator; 
+	  amount:cardinal; 
+	  dst_offset:cardinal; 
+	  src_offset:cardinal):sword;cdecl;external;
+
+  function OCILobLocatorIsInit(
+          envhp:OCIEnv; 
+	  errhp:OCIError; 
+	  locp:OCILobLocator; 
+	  is_initialized:pboolean):sword;cdecl;external;
+
+  function OCILobRead(
+          svchp:OCISvcCtx; 
+	  errhp:OCIError; 
+	  locp:OCILobLocator; 
+	  amtp:pcardinal; 
+	  offset:cardinal; 
+    	  bufp:pointer; 
+	  bufl:cardinal; 
+	  ctxp:pointer; 
+	  cbfp:pointer; 
+	  csid:word; 
+          csfrm:byte):sword;cdecl;external;
+
+  function OCILobTrim(
+          svchp:OCISvcCtx; 
+	  errhp:OCIError; 
+	  locp:OCILobLocator; 
+	  newlen:cardinal):sword;cdecl;external;
+
+  function OCILobWrite(
+          svchp:OCISvcCtx; 
+	  errhp:OCIError; 
+	  locp:OCILobLocator; 
+	  amtp:pcardinal; 
+	  offset:cardinal; 
+          bufp:pointer; 
+	  buflen:cardinal; 
+	  piece:byte; 
+	  ctxp:pointer; 
+	  cbfp:pointer; 
+          csid:word; 
+	  csfrm:byte):sword;cdecl;external;
+
+  function OCIBreak(
+          hndlp:pointer; 
+	  errhp:OCIError):sword;cdecl;external;
+
+  function OCIReset(
+          hndlp:pointer; 
+	  errhp:OCIError):sword;cdecl;external;
+
+  function OCIServerVersion(
+          hndlp:pointer; 
+	  errhp:OCIError; 
+	  bufp:PChar; 
+	  bufsz:cardinal; 
+	  hndltype:byte):sword;cdecl;external;
+
+  function OCIAttrGet(
+          trgthndlp:pointer; 
+	  trghndltyp:cardinal; 
+	  attributep:pointer; 
+	  sizep:pcardinal; 
+	  attrtype:cardinal; 
+          errhp:OCIError):sword;cdecl;external;
+
+  function OCIAttrSet(
+          trgthndlp:pointer; 
+	  trghndltyp:cardinal; 
+	  attributep:pointer; 
+	  size:cardinal; 
+	  attrtype:cardinal; 
+          errhp:OCIError):sword;cdecl;external;
+
+  function OCISvcCtxToLda(
+          svchp:OCISvcCtx; 
+	  errhp:OCIError; 
+	  ldap:pLda_Def):sword;cdecl;external;
+
+  function OCILdaToSvcCtx(
+          svchpp:OCISvcCtx; 
+	  errhp:OCIError; 
+	  ldap:pLda_Def):sword;cdecl;external;
+
+  function OCIResultSetToStmt(
+          rsetdp:OCIResult; 
+	  errhp:OCIError):sword;cdecl;external;
+
+  function OCIDateToText(
+      err:OCIError; 
+	  date:POCIDate; 
+	  fmt:PChar; 
+	  fmt_length:ub1; 
+	  lang_name:PChar; 
+      lang_length:ub4; 
+	  buf_size:PCardinal; 
+	  buf:PChar):sword;cdecl;external;
+
+end.
+
+{
+  $Log$
+  Revision 1.1  2002-01-29 17:54:54  peter
+    * splitted to base and extra
+
+  Revision 1.1  2000/12/02 15:14:15  michael
+  + Initial implementation of Pavel Stingl
+
+  Revision 1.1.1.1  2000/10/11 07:48:28  stingp1
+    * Import to cvs
+
+}

+ 1234 - 0
packages/base/paszlib/Makefile

@@ -0,0 +1,1234 @@
+#
+# Don't edit, this file is generated by FPCMake Version 1.1 [2002/01/29]
+#
+default: all
+MAKEFILETARGETS=linux go32v2 win32 os2 freebsd beos netbsd amiga atari sunos qnx
+override PATH:=$(subst \,/,$(PATH))
+ifeq ($(findstring ;,$(PATH)),)
+inUnix=1
+SEARCHPATH:=$(filter-out .,$(subst :, ,$(PATH)))
+else
+SEARCHPATH:=$(subst ;, ,$(PATH))
+endif
+PWD:=$(strip $(wildcard $(addsuffix /pwd.exe,$(SEARCHPATH))))
+ifeq ($(PWD),)
+PWD:=$(strip $(wildcard $(addsuffix /pwd,$(SEARCHPATH))))
+ifeq ($(PWD),)
+$(error You need the GNU utils package to use this Makefile)
+else
+PWD:=$(firstword $(PWD))
+SRCEXEEXT=
+endif
+else
+PWD:=$(firstword $(PWD))
+SRCEXEEXT=.exe
+endif
+ifndef inUnix
+ifeq ($(OS),Windows_NT)
+inWinNT=1
+else
+ifdef OS2_SHELL
+inOS2=1
+endif
+endif
+else
+ifneq ($(findstring cygwin,$(MACHTYPE)),)
+inCygWin=1
+endif
+endif
+ifeq ($(OS_TARGET),freebsd)
+BSDhier=1
+endif
+ifeq ($(OS_TARGET),netbsd)
+BSDhier=1
+endif
+ifdef inUnix
+BATCHEXT=.sh
+else
+ifdef inOS2
+BATCHEXT=.cmd
+else
+BATCHEXT=.bat
+endif
+endif
+ifdef inUnix
+PATHSEP=/
+else
+PATHSEP:=$(subst /,\,/)
+endif
+ifdef PWD
+BASEDIR:=$(subst \,/,$(shell $(PWD)))
+ifdef inCygWin
+ifneq ($(findstring /cygdrive/,$(BASEDIR)),)
+BASENODIR:=$(patsubst /cygdrive%,%,$(BASEDIR))
+BASEDRIVE:=$(firstword $(subst /, ,$(BASENODIR)))
+BASEDIR:=$(subst /cygdrive/$(BASEDRIVE)/,$(BASEDRIVE):/,$(BASEDIR))
+endif
+endif
+else
+BASEDIR=.
+endif
+override DEFAULT_FPCDIR=../../..
+ifndef FPC
+ifdef PP
+FPC=$(PP)
+endif
+endif
+ifndef FPC
+FPCPROG:=$(strip $(wildcard $(addsuffix /fpc$(SRCEXEEXT),$(SEARCHPATH))))
+ifneq ($(FPCPROG),)
+FPCPROG:=$(firstword $(FPCPROG))
+FPC:=$(shell $(FPCPROG) -PB)
+ifneq ($(findstring Error,$(FPC)),)
+override FPC=ppc386
+endif
+else
+override FPC=ppc386
+endif
+endif
+override FPC:=$(subst $(SRCEXEEXT),,$(FPC))
+override FPC:=$(subst \,/,$(FPC))$(SRCEXEEXT)
+ifndef FPC_VERSION
+FPC_VERSION:=$(shell $(FPC) -iV)
+endif
+export FPC FPC_VERSION
+ifeq ($(findstring 1.0.,$(FPC_VERSION)),)
+COMPILERINFO:=$(shell $(FPC) -iSP -iTP -iSO -iTO)
+ifndef CPU_SOURCE
+CPU_SOURCE:=$(word 1,$(COMPILERINFO))
+endif
+ifndef CPU_TARGET
+CPU_TARGET:=$(word 2,$(COMPILERINFO))
+endif
+ifndef OS_SOURCE
+OS_SOURCE:=$(word 3,$(COMPILERINFO))
+endif
+ifndef OS_TARGET
+OS_TARGET:=$(word 4,$(COMPILERINFO))
+endif
+else
+ifndef CPU_SOURCE
+CPU_SOURCE:=$(shell $(FPC) -iSP)
+endif
+ifndef CPU_TARGET
+CPU_TARGET:=$(shell $(FPC) -iTP)
+endif
+ifndef OS_SOURCE
+OS_SOURCE:=$(shell $(FPC) -iSO)
+endif
+ifndef OS_TARGET
+OS_TARGET:=$(shell $(FPC) -iTO)
+endif
+endif
+FULL_TARGET=$(CPU_TARGET)-$(OS_TARGET)
+FULL_SOURCE=$(CPU_SOURCE)-$(OS_SOURCE)
+ifneq ($(FULL_TARGET),$(FULL_SOURCE))
+CROSSCOMPILE=1
+endif
+ifeq ($(findstring makefile,$(MAKECMDGOALS)),)
+ifeq ($(findstring $(OS_TARGET),$(MAKEFILETARGETS)),)
+$(error The Makefile doesn't support target $(OS_TARGET), please run fpcmake first)
+endif
+endif
+export OS_TARGET OS_SOURCE CPU_TARGET CPU_SOURCE FULL_TARGET FULL_SOURCE CROSSCOMPILE
+ifdef FPCDIR
+override FPCDIR:=$(subst \,/,$(FPCDIR))
+ifeq ($(wildcard $(addprefix $(FPCDIR)/,rtl units)),)
+override FPCDIR=wrong
+endif
+else
+override FPCDIR=wrong
+endif
+ifdef DEFAULT_FPCDIR
+ifeq ($(FPCDIR),wrong)
+override FPCDIR:=$(subst \,/,$(DEFAULT_FPCDIR))
+ifeq ($(wildcard $(addprefix $(FPCDIR)/,rtl units)),)
+override FPCDIR=wrong
+endif
+endif
+endif
+ifeq ($(FPCDIR),wrong)
+ifdef inUnix
+override FPCDIR=/usr/local/lib/fpc/$(FPC_VERSION)
+ifeq ($(wildcard $(FPCDIR)/units),)
+override FPCDIR=/usr/lib/fpc/$(FPC_VERSION)
+endif
+else
+override FPCDIR:=$(subst /$(FPC),,$(firstword $(strip $(wildcard $(addsuffix /$(FPC),$(SEARCHPATH))))))
+override FPCDIR:=$(FPCDIR)/..
+ifeq ($(wildcard $(addprefix $(FPCDIR)/,rtl units)),)
+override FPCDIR:=$(FPCDIR)/..
+ifeq ($(wildcard $(addprefix $(FPCDIR)/,rtl units)),)
+override FPCDIR=c:/pp
+endif
+endif
+endif
+endif
+ifndef CROSSDIR
+CROSSDIR:=$(FPCDIR)/cross/$(FULL_TARGET)
+endif
+ifndef CROSSTARGETDIR
+CROSSTARGETDIR=$(CROSSDIR)/$(FULL_TARGET)
+endif
+ifdef CROSSCOMPILE
+UNITSDIR:=$(wildcard $(CROSSTARGETDIR)/units)
+ifeq ($(UNITSDIR),)
+UNITSDIR:=$(wildcard $(FPCDIR)/units/$(OS_TARGET))
+endif
+else
+UNITSDIR:=$(wildcard $(FPCDIR)/units/$(OS_TARGET))
+endif
+PACKAGESDIR:=$(wildcard $(FPCDIR) $(FPCDIR)/packages/base $(FPCDIR)/packages/extra)
+override PACKAGE_NAME=paszlib
+override PACKAGE_VERSION=1.0.6
+override TARGET_UNITS+=paszlib adler gzcrc gzio infblock infcodes inffast inftrees infutil trees zcompres zdeflate zinflate zbase zuncompr zutil
+override TARGET_EXAMPLES+=example minigzip
+override INSTALL_FPCPACKAGE=y
+ifdef REQUIRE_UNITSDIR
+override UNITSDIR+=$(REQUIRE_UNITSDIR)
+endif
+ifdef REQUIRE_PACKAGESDIR
+override PACKAGESDIR+=$(REQUIRE_PACKAGESDIR)
+endif
+ifdef ZIPINSTALL
+ifeq ($(OS_TARGET),linux)
+UNIXINSTALLDIR=1
+endif
+ifeq ($(OS_TARGET),freebsd)
+UNIXINSTALLDIR=1
+endif
+ifeq ($(OS_TARGET),netbsd)
+UNIXINSTALLDIR=1
+endif
+ifeq ($(OS_TARGET),sunos)
+UNIXINSTALLDIR=1
+endif
+else
+ifeq ($(OS_SOURCE),linux)
+UNIXINSTALLDIR=1
+endif
+ifeq ($(OS_SOURCE),freebsd)
+UNIXINSTALLDIR=1
+endif
+ifeq ($(OS_SOURCE),netbsd)
+UNIXINSTALLDIR=1
+endif
+ifeq ($(OS_TARGET),sunos)
+UNIXINSTALLDIR=1
+endif
+endif
+ifndef INSTALL_PREFIX
+ifdef PREFIX
+INSTALL_PREFIX=$(PREFIX)
+endif
+endif
+ifndef INSTALL_PREFIX
+ifdef UNIXINSTALLDIR
+INSTALL_PREFIX=/usr/local
+else
+ifdef INSTALL_FPCPACKAGE
+INSTALL_BASEDIR:=/pp
+else
+INSTALL_BASEDIR:=/$(PACKAGE_NAME)
+endif
+endif
+endif
+export INSTALL_PREFIX
+ifndef DIST_DESTDIR
+DIST_DESTDIR:=$(BASEDIR)
+endif
+export DIST_DESTDIR
+ifndef INSTALL_BASEDIR
+ifdef UNIXINSTALLDIR
+ifdef INSTALL_FPCPACKAGE
+INSTALL_BASEDIR:=$(INSTALL_PREFIX)/lib/fpc/$(FPC_VERSION)
+else
+INSTALL_BASEDIR:=$(INSTALL_PREFIX)/lib/$(PACKAGE_NAME)
+endif
+else
+INSTALL_BASEDIR:=$(INSTALL_PREFIX)
+endif
+endif
+ifndef INSTALL_BINDIR
+ifdef UNIXINSTALLDIR
+INSTALL_BINDIR:=$(INSTALL_PREFIX)/bin
+else
+INSTALL_BINDIR:=$(INSTALL_BASEDIR)/bin
+ifdef INSTALL_FPCPACKAGE
+INSTALL_BINDIR:=$(INSTALL_BINDIR)/$(OS_TARGET)
+endif
+endif
+endif
+ifndef INSTALL_UNITDIR
+ifdef CROSSCOMPILE
+INSTALL_UNITDIR:=$(INSTALL_BASEDIR)/cross/$(FULL_TARGET)/units
+else
+INSTALL_UNITDIR:=$(INSTALL_BASEDIR)/units/$(OS_TARGET)
+endif
+ifdef INSTALL_FPCPACKAGE
+ifdef PACKAGE_NAME
+INSTALL_UNITDIR:=$(INSTALL_UNITDIR)/$(PACKAGE_NAME)
+endif
+endif
+endif
+ifndef INSTALL_LIBDIR
+ifdef UNIXINSTALLDIR
+INSTALL_LIBDIR:=$(INSTALL_PREFIX)/lib
+else
+INSTALL_LIBDIR:=$(INSTALL_UNITDIR)
+endif
+endif
+ifndef INSTALL_SOURCEDIR
+ifdef UNIXINSTALLDIR
+ifdef INSTALL_FPCPACKAGE
+ifdef BSDhier
+INSTALL_SOURCEDIR:=$(INSTALL_PREFIX)/share/src/fpc-$(FPC_VERSION)/$(PACKAGE_NAME)
+else
+INSTALL_SOURCEDIR:=$(INSTALL_PREFIX)/src/fpc-$(FPC_VERSION)/$(PACKAGE_NAME)
+endif
+else
+ifdef BSDhier
+INSTALL_SOURCEDIR:=$(INSTALL_PREFIX)/share/src/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
+else
+INSTALL_SOURCEDIR:=$(INSTALL_PREFIX)/src/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
+endif
+endif
+else
+ifdef INSTALL_FPCPACKAGE
+INSTALL_SOURCEDIR:=$(INSTALL_BASEDIR)/source/$(PACKAGE_NAME)
+else
+INSTALL_SOURCEDIRL:=$(INSTALL_BASEDIR)/source
+endif
+endif
+endif
+ifndef INSTALL_DOCDIR
+ifdef UNIXINSTALLDIR
+ifdef INSTALL_FPCPACKAGE
+ifdef BSDhier
+INSTALL_DOCDIR:=$(INSTALL_PREFIX)/share/doc/fpc-$(FPC_VERSION)/$(PACKAGE_NAME)
+else
+INSTALL_DOCDIR:=$(INSTALL_PREFIX)/doc/fpc-$(FPC_VERSION)/$(PACKAGE_NAME)
+endif
+else
+ifdef BSDhier
+INSTALL_DOCDIR:=$(INSTALL_PREFIX)/share/doc/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
+else
+INSTALL_DOCDIR:=$(INSTALL_PREFIX)/doc/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
+endif
+endif
+else
+ifdef INSTALL_FPCPACKAGE
+INSTALL_DOCDIR:=$(INSTALL_BASEDIR)/doc/$(PACKAGE_NAME)
+else
+INSTALL_DOCDIR:=$(INSTALL_BASEDIR)/doc
+endif
+endif
+endif
+ifndef INSTALL_EXAMPLEDIR
+ifdef UNIXINSTALLDIR
+ifdef INSTALL_FPCPACKAGE
+ifdef BSDhier
+INSTALL_EXAMPLEDIR:=$(INSTALL_PREFIX)/share/examples/fpc-$(FPC_VERSION)/$(PACKAGE_NAME)
+else
+INSTALL_EXAMPLEDIR:=$(INSTALL_PREFIX)/doc/fpc-$(FPC_VERSION)/examples/$(PACKAGE_NAME)
+endif
+else
+ifdef BSDhier
+INSTALL_EXAMPLEDIR:=$(INSTALL_PREFIX)/share/examples/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
+else
+INSTALL_EXAMPLEDIR:=$(INSTALL_PREFIX)/doc/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
+endif
+endif
+else
+ifdef INSTALL_FPCPACKAGE
+INSTALL_EXAMPLEDIR:=$(INSTALL_BASEDIR)/examples/$(PACKAGE_NAME)
+else
+INSTALL_EXAMPLEDIR:=$(INSTALL_BASEDIR)/examples
+endif
+endif
+endif
+ifndef INSTALL_DATADIR
+INSTALL_DATADIR=$(INSTALL_BASEDIR)
+endif
+ifdef CROSSCOMPILE
+ifndef CROSSBINDIR
+CROSSBINDIR:=$(wildcard $(CROSSTARGETDIR)/bin/$(FULL_SOURCE))
+ifeq ($(CROSSBINDIR),)
+CROSSBINDIR:=$(wildcard $(INSTALL_BASEDIR)/cross/$(FULL_TARGET)/bin/$(FULL_SOURCE))
+endif
+endif
+else
+CROSSBINDIR=
+endif
+LOADEREXT=.as
+EXEEXT=.exe
+PPLEXT=.ppl
+PPUEXT=.ppu
+OEXT=.o
+ASMEXT=.s
+SMARTEXT=.sl
+STATICLIBEXT=.a
+SHAREDLIBEXT=.so
+STATICLIBPREFIX=libp
+RSTEXT=.rst
+FPCMADE=fpcmade
+ifeq ($(OS_TARGET),go32v1)
+PPUEXT=.pp1
+OEXT=.o1
+ASMEXT=.s1
+SMARTEXT=.sl1
+STATICLIBEXT=.a1
+SHAREDLIBEXT=.so1
+STATICLIBPREFIX=
+FPCMADE=fpcmade.v1
+PACKAGESUFFIX=v1
+endif
+ifeq ($(OS_TARGET),go32v2)
+STATICLIBPREFIX=
+FPCMADE=fpcmade.dos
+ZIPSUFFIX=go32
+endif
+ifeq ($(OS_TARGET),linux)
+EXEEXT=
+HASSHAREDLIB=1
+FPCMADE=fpcmade.lnx
+ZIPSUFFIX=linux
+endif
+ifeq ($(OS_TARGET),freebsd)
+EXEEXT=
+HASSHAREDLIB=1
+FPCMADE=fpcmade.freebsd
+ZIPSUFFIX=freebsd
+endif
+ifeq ($(OS_TARGET),netbsd)
+EXEEXT=
+HASSHAREDLIB=1
+FPCMADE=fpcmade.netbsd
+ZIPSUFFIX=netbsd
+endif
+ifeq ($(OS_TARGET),win32)
+PPUEXT=.ppw
+OEXT=.ow
+ASMEXT=.sw
+SMARTEXT=.slw
+STATICLIBEXT=.aw
+SHAREDLIBEXT=.dll
+FPCMADE=fpcmade.w32
+ZIPSUFFIX=w32
+endif
+ifeq ($(OS_TARGET),os2)
+PPUEXT=.ppo
+ASMEXT=.so2
+OEXT=.oo2
+AOUTEXT=.out
+SMARTEXT=.so
+STATICLIBEXT=.ao2
+SHAREDLIBEXT=.dll
+FPCMADE=fpcmade.os2
+ZIPSUFFIX=emx
+endif
+ifeq ($(OS_TARGET),amiga)
+EXEEXT=
+PPUEXT=.ppa
+ASMEXT=.asm
+OEXT=.o
+SMARTEXT=.sl
+STATICLIBEXT=.a
+SHAREDLIBEXT=.library
+FPCMADE=fpcmade.amg
+endif
+ifeq ($(OS_TARGET),atari)
+PPUEXT=.ppt
+ASMEXT=.s
+OEXT=.o
+SMARTEXT=.sl
+STATICLIBEXT=.a
+EXEEXT=.ttp
+FPCMADE=fpcmade.ata
+endif
+ifeq ($(OS_TARGET),beos)
+PPUEXT=.ppu
+ASMEXT=.s
+OEXT=.o
+SMARTEXT=.sl
+STATICLIBEXT=.a
+EXEEXT=
+FPCMADE=fpcmade.be
+ZIPSUFFIX=be
+endif
+ifeq ($(OS_TARGET),sunos)
+PPUEXT=.ppu
+ASMEXT=.s
+OEXT=.o
+SMARTEXT=.sl
+STATICLIBEXT=.a
+EXEEXT=
+FPCMADE=fpcmade.sun
+ZIPSUFFIX=sun
+endif
+ifeq ($(OS_TARGET),qnx)
+PPUEXT=.ppu
+ASMEXT=.s
+OEXT=.o
+SMARTEXT=.sl
+STATICLIBEXT=.a
+EXEEXT=
+FPCMADE=fpcmade.qnx
+ZIPSUFFIX=qnx
+endif
+ifndef ECHO
+ECHO:=$(strip $(wildcard $(addsuffix /gecho$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(ECHO),)
+ECHO:=$(strip $(wildcard $(addsuffix /echo$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(ECHO),)
+ECHO=
+else
+ECHO:=$(firstword $(ECHO))
+endif
+else
+ECHO:=$(firstword $(ECHO))
+endif
+endif
+export ECHO
+ifndef DATE
+DATE:=$(strip $(wildcard $(addsuffix /gdate$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(DATE),)
+DATE:=$(strip $(wildcard $(addsuffix /date$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(DATE),)
+DATE=
+else
+DATE:=$(firstword $(DATE))
+endif
+else
+DATE:=$(firstword $(DATE))
+endif
+endif
+export DATE
+ifndef GINSTALL
+GINSTALL:=$(strip $(wildcard $(addsuffix /ginstall$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(GINSTALL),)
+GINSTALL:=$(strip $(wildcard $(addsuffix /install$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(GINSTALL),)
+GINSTALL=
+else
+GINSTALL:=$(firstword $(GINSTALL))
+endif
+else
+GINSTALL:=$(firstword $(GINSTALL))
+endif
+endif
+export GINSTALL
+ifndef CPPROG
+CPPROG:=$(strip $(wildcard $(addsuffix /cp$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(CPPROG),)
+CPPROG=
+else
+CPPROG:=$(firstword $(CPPROG))
+endif
+endif
+export CPPROG
+ifndef RMPROG
+RMPROG:=$(strip $(wildcard $(addsuffix /rm$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(RMPROG),)
+RMPROG=
+else
+RMPROG:=$(firstword $(RMPROG))
+endif
+endif
+export RMPROG
+ifndef MVPROG
+MVPROG:=$(strip $(wildcard $(addsuffix /mv$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(MVPROG),)
+MVPROG=
+else
+MVPROG:=$(firstword $(MVPROG))
+endif
+endif
+export MVPROG
+ifndef ECHOREDIR
+ECHOREDIR:=$(subst /,$(PATHSEP),$(ECHO))
+endif
+ifndef COPY
+COPY:=$(CPPROG) -fp
+endif
+ifndef COPYTREE
+COPYTREE:=$(CPPROG) -rfp
+endif
+ifndef MOVE
+MOVE:=$(MVPROG) -f
+endif
+ifndef DEL
+DEL:=$(RMPROG) -f
+endif
+ifndef DELTREE
+DELTREE:=$(RMPROG) -rf
+endif
+ifndef INSTALL
+ifdef inUnix
+INSTALL:=$(GINSTALL) -c -m 644
+else
+INSTALL:=$(COPY)
+endif
+endif
+ifndef INSTALLEXE
+ifdef inUnix
+INSTALLEXE:=$(GINSTALL) -c -m 755
+else
+INSTALLEXE:=$(COPY)
+endif
+endif
+ifndef MKDIR
+MKDIR:=$(GINSTALL) -m 755 -d
+endif
+export ECHOREDIR COPY COPYTREE MOVE DEL DELTREE INSTALL INSTALLEXE MKDIR
+ifndef PPUMOVE
+PPUMOVE:=$(strip $(wildcard $(addsuffix /ppumove$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(PPUMOVE),)
+PPUMOVE=
+else
+PPUMOVE:=$(firstword $(PPUMOVE))
+endif
+endif
+export PPUMOVE
+ifndef FPCMAKE
+FPCMAKE:=$(strip $(wildcard $(addsuffix /fpcmake$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(FPCMAKE),)
+FPCMAKE=
+else
+FPCMAKE:=$(firstword $(FPCMAKE))
+endif
+endif
+export FPCMAKE
+ifndef ZIPPROG
+ZIPPROG:=$(strip $(wildcard $(addsuffix /zip$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(ZIPPROG),)
+ZIPPROG=
+else
+ZIPPROG:=$(firstword $(ZIPPROG))
+endif
+endif
+export ZIPPROG
+ifndef TARPROG
+TARPROG:=$(strip $(wildcard $(addsuffix /tar$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(TARPROG),)
+TARPROG=
+else
+TARPROG:=$(firstword $(TARPROG))
+endif
+endif
+export TARPROG
+ASNAME=as
+LDNAME=ld
+ARNAME=ar
+RCNAME=rc
+ifeq ($(OS_TARGET),win32)
+ASNAME=asw
+LDNAME=ldw
+ARNAME=arw
+endif
+ifndef ASPROG
+ifdef CROSSBINDIR
+ASPROG=$(CROSSBINDIR)/$(ASNAME)$(SRCEXEEXT)
+else
+ASPROG=$(ASNAME)
+endif
+endif
+ifndef LDPROG
+ifdef CROSSBINDIR
+LDPROG=$(CROSSBINDIR)/$(LDNAME)$(SRCEXEEXT)
+else
+LDPROG=$(LDNAME)
+endif
+endif
+ifndef RCPROG
+ifdef CROSSBINDIR
+RCPROG=$(CROSSBINDIR)/$(RCNAME)$(SRCEXEEXT)
+else
+RCPROG=$(RCNAME)
+endif
+endif
+ifndef ARPROG
+ifdef CROSSBINDIR
+ARPROG=$(CROSSBINDIR)/$(ARNAME)$(SRCEXEEXT)
+else
+ARPROG=$(ARNAME)
+endif
+endif
+AS=$(ASPROG)
+LD=$(LDPROG)
+RC=$(RCPROG)
+AR=$(ARPROG)
+PPAS=ppas$(BATCHEXT)
+ifdef inUnix
+LDCONFIG=ldconfig
+else
+LDCONFIG=
+endif
+ifdef DATE
+DATESTR:=$(shell $(DATE) +%Y%m%d)
+else
+DATESTR=
+endif
+ifndef UPXPROG
+ifeq ($(OS_TARGET),go32v2)
+UPXPROG:=1
+endif
+ifeq ($(OS_TARGET),win32)
+UPXPROG:=1
+endif
+ifdef UPXPROG
+UPXPROG:=$(strip $(wildcard $(addsuffix /upx$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(UPXPROG),)
+UPXPROG=
+else
+UPXPROG:=$(firstword $(UPXPROG))
+endif
+else
+UPXPROG=
+endif
+endif
+export UPXPROG
+ZIPOPT=-9
+ZIPEXT=.zip
+ifeq ($(USETAR),bz2)
+TAROPT=vI
+TAREXT=.tar.bz2
+else
+TAROPT=vz
+TAREXT=.tar.gz
+endif
+override REQUIRE_PACKAGES=rtl 
+ifeq ($(OS_TARGET),linux)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(OS_TARGET),go32v2)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(OS_TARGET),win32)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(OS_TARGET),os2)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(OS_TARGET),freebsd)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(OS_TARGET),beos)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(OS_TARGET),netbsd)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(OS_TARGET),amiga)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(OS_TARGET),atari)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(OS_TARGET),sunos)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(OS_TARGET),qnx)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifdef REQUIRE_PACKAGES_RTL
+PACKAGEDIR_RTL:=$(firstword $(subst /Makefile.fpc,,$(strip $(wildcard $(addsuffix /rtl/$(OS_TARGET)/Makefile.fpc,$(PACKAGESDIR))))))
+ifneq ($(PACKAGEDIR_RTL),)
+ifneq ($(wildcard $(PACKAGEDIR_RTL)/$(OS_TARGET)),)
+UNITDIR_RTL=$(PACKAGEDIR_RTL)/$(OS_TARGET)
+else
+UNITDIR_RTL=$(PACKAGEDIR_RTL)
+endif
+else
+PACKAGEDIR_RTL=
+UNITDIR_RTL:=$(subst /Package.fpc,,$(strip $(wildcard $(addsuffix /rtl/Package.fpc,$(UNITSDIR)))))
+ifneq ($(UNITDIR_RTL),)
+UNITDIR_RTL:=$(firstword $(UNITDIR_RTL))
+else
+UNITDIR_RTL=
+endif
+endif
+ifdef UNITDIR_RTL
+override COMPILER_UNITDIR+=$(UNITDIR_RTL)
+endif
+endif
+ifndef NOCPUDEF
+override FPCOPTDEF=$(CPU_TARGET)
+endif
+ifneq ($(OS_TARGET),$(OS_SOURCE))
+override FPCOPT+=-T$(OS_TARGET)
+endif
+ifdef UNITDIR
+override FPCOPT+=$(addprefix -Fu,$(UNITDIR))
+endif
+ifdef LIBDIR
+override FPCOPT+=$(addprefix -Fl,$(LIBDIR))
+endif
+ifdef OBJDIR
+override FPCOPT+=$(addprefix -Fo,$(OBJDIR))
+endif
+ifdef INCDIR
+override FPCOPT+=$(addprefix -Fi,$(INCDIR))
+endif
+ifdef LINKSMART
+override FPCOPT+=-XX
+endif
+ifdef CREATESMART
+override FPCOPT+=-CX
+endif
+ifdef DEBUG
+override FPCOPT+=-gl
+override FPCOPTDEF+=DEBUG
+endif
+ifdef RELEASE
+ifeq ($(CPU_TARGET),i386)
+FPCCPUOPT:=-OG2p3
+else
+FPCCPUOPT:=
+endif
+override FPCOPT+=-Xs $(FPCCPUOPT) -n
+override FPCOPTDEF+=RELEASE
+endif
+ifdef STRIP
+override FPCOPT+=-Xs
+endif
+ifdef OPTIMIZE
+ifeq ($(CPU_TARGET),i386)
+override FPCOPT+=-OG2p3
+endif
+endif
+ifdef VERBOSE
+override FPCOPT+=-vwni
+endif
+ifdef COMPILER_OPTIONS
+override FPCOPT+=$(COMPILER_OPTIONS)
+endif
+ifdef COMPILER_UNITDIR
+override FPCOPT+=$(addprefix -Fu,$(COMPILER_UNITDIR))
+endif
+ifdef COMPILER_LIBRARYDIR
+override FPCOPT+=$(addprefix -Fl,$(COMPILER_LIBRARYDIR))
+endif
+ifdef COMPILER_OBJECTDIR
+override FPCOPT+=$(addprefix -Fo,$(COMPILER_OBJECTDIR))
+endif
+ifdef COMPILER_INCLUDEDIR
+override FPCOPT+=$(addprefix -Fi,$(COMPILER_INCLUDEDIR))
+endif
+ifdef CROSSBINDIR
+override FPCOPT+=-FD$(CROSSBINDIR)
+endif
+ifdef COMPILER_TARGETDIR
+override FPCOPT+=-FE$(COMPILER_TARGETDIR)
+ifeq ($(COMPILER_TARGETDIR),.)
+override TARGETDIRPREFIX=
+else
+override TARGETDIRPREFIX=$(COMPILER_TARGETDIR)/
+endif
+endif
+ifdef COMPILER_UNITTARGETDIR
+override FPCOPT+=-FU$(COMPILER_UNITTARGETDIR)
+ifeq ($(COMPILER_UNITTARGETDIR),.)
+override UNITTARGETDIRPREFIX=
+else
+override UNITTARGETDIRPREFIX=$(COMPILER_UNITTARGETDIR)/
+endif
+else
+ifdef COMPILER_TARGETDIR
+override COMPILER_UNITTARGETDIR=$(COMPILER_TARGETDIR)
+override UNITTARGETDIRPREFIX=$(TARGETDIRPREFIX)
+endif
+endif
+ifdef OPT
+override FPCOPT+=$(OPT)
+endif
+ifdef FPCOPTDEF
+override FPCOPT+=$(addprefix -d,$(FPCOPTDEF))
+endif
+ifdef CFGFILE
+override FPCOPT+=@$(CFGFILE)
+endif
+ifdef USEENV
+override FPCEXTCMD:=$(FPCOPT)
+override FPCOPT:=!FPCEXTCMD
+export FPCEXTCMD
+endif
+override COMPILER:=$(FPC) $(FPCOPT)
+ifeq (,$(findstring -s ,$(COMPILER)))
+EXECPPAS=
+else
+ifeq ($(OS_SOURCE),$(OS_TARGET))
+EXECPPAS:=@$(PPAS)
+endif
+endif
+.PHONY: fpc_units
+ifdef TARGET_UNITS
+override ALLTARGET+=fpc_units
+override UNITPPUFILES=$(addsuffix $(PPUEXT),$(TARGET_UNITS))
+override IMPLICITUNITPPUFILES=$(addsuffix $(PPUEXT),$(TARGET_IMPLICITUNITS))
+override INSTALLPPUFILES+=$(UNITPPUFILES) $(IMPLICITUNITPPUFILES)
+override CLEANPPUFILES+=$(UNITPPUFILES) $(IMPLICITUNITPPUFILES)
+endif
+fpc_units: $(UNITPPUFILES)
+ifdef TARGET_RSTS
+override RSTFILES=$(addsuffix $(RSTEXT),$(TARGET_RSTS))
+override CLEANRSTFILES+=$(RSTFILES)
+endif
+.PHONY: fpc_examples
+ifdef TARGET_EXAMPLES
+HASEXAMPLES=1
+override EXAMPLESOURCEFILES:=$(wildcard $(addsuffix .pp,$(TARGET_EXAMPLES)) $(addsuffix .pas,$(TARGET_EXAMPLES)))
+override EXAMPLEFILES:=$(addsuffix $(EXEEXT),$(TARGET_EXAMPLES))
+override EXAMPLEOFILES:=$(addsuffix $(OEXT),$(TARGET_EXAMPLES)) $(addprefix $(STATICLIBPREFIX),$(addsuffix $(STATICLIBEXT),$(TARGET_EXAMPLES)))
+override CLEANEXEFILES+=$(EXAMPLEFILES) $(EXAMPLEOFILES)
+ifeq ($(OS_TARGET),os2)
+override CLEANEXEFILES+=$(addsuffix $(AOUTEXT),$(TARGET_EXAMPLES))
+endif
+endif
+ifdef TARGET_EXAMPLEDIRS
+HASEXAMPLES=1
+endif
+fpc_examples: all $(EXAMPLEFILES) $(addsuffix _all,$(TARGET_EXAMPLEDIRS))
+.PHONY: fpc_all fpc_smart fpc_debug fpc_release
+$(FPCMADE): $(ALLTARGET)
+	@$(ECHOREDIR) Compiled > $(FPCMADE)
+fpc_all: $(FPCMADE)
+fpc_smart:
+	$(MAKE) all LINKSMART=1 CREATESMART=1
+fpc_debug:
+	$(MAKE) all DEBUG=1
+fpc_release:
+	$(MAKE) all RELEASE=1
+.SUFFIXES: $(EXEEXT) $(PPUEXT) $(OEXT) .pas .pp .rc .res
+%$(PPUEXT): %.pp
+	$(COMPILER) $<
+	$(EXECPPAS)
+%$(PPUEXT): %.pas
+	$(COMPILER) $<
+	$(EXECPPAS)
+%$(EXEEXT): %.pp
+	$(COMPILER) $<
+	$(EXECPPAS)
+%$(EXEEXT): %.pas
+	$(COMPILER) $<
+	$(EXECPPAS)
+%.res: %.rc
+	windres -i $< -o $@
+vpath %.pp $(COMPILER_SOURCEDIR) $(COMPILER_INCLUDEDIR)
+vpath %.pas $(COMPILER_SOURCEDIR) $(COMPILER_INCLUDEDIR)
+vpath %$(PPUEXT) $(COMPILER_UNITTARGETDIR)
+.PHONY: fpc_install fpc_sourceinstall fpc_exampleinstall
+ifdef INSTALL_UNITS
+override INSTALLPPUFILES+=$(addsuffix $(PPUEXT),$(INSTALL_UNITS))
+endif
+ifdef INSTALL_BUILDUNIT
+override INSTALLPPUFILES:=$(filter-out $(INSTALL_BUILDUNIT),$(INSTALLPPUFILES))
+endif
+ifdef INSTALLPPUFILES
+override INSTALLPPULINKFILES:=$(subst $(PPUEXT),$(OEXT),$(INSTALLPPUFILES)) $(addprefix $(STATICLIBPREFIX),$(subst $(PPUEXT),$(STATICLIBEXT),$(INSTALLPPUFILES)))
+override INSTALLPPUFILES:=$(addprefix $(UNITTARGETDIRPREFIX),$(INSTALLPPUFILES))
+override INSTALLPPULINKFILES:=$(wildcard $(addprefix $(UNITTARGETDIRPREFIX),$(INSTALLPPULINKFILES)))
+override INSTALL_CREATEPACKAGEFPC=1
+endif
+ifdef INSTALLEXEFILES
+override INSTALLEXEFILES:=$(addprefix $(TARGETDIRPREFIX),$(INSTALLEXEFILES))
+endif
+fpc_install: all $(INSTALLTARGET)
+ifdef INSTALLEXEFILES
+	$(MKDIR) $(INSTALL_BINDIR)
+ifdef UPXPROG
+	-$(UPXPROG) $(INSTALLEXEFILES)
+endif
+	$(INSTALLEXE) $(INSTALLEXEFILES) $(INSTALL_BINDIR)
+endif
+ifdef INSTALL_CREATEPACKAGEFPC
+ifdef FPCMAKE
+ifdef PACKAGE_VERSION
+ifneq ($(wildcard Makefile.fpc),)
+	$(FPCMAKE) -p -T$(OS_TARGET) Makefile.fpc
+	$(MKDIR) $(INSTALL_UNITDIR)
+	$(INSTALL) Package.fpc $(INSTALL_UNITDIR)
+endif
+endif
+endif
+endif
+ifdef INSTALLPPUFILES
+	$(MKDIR) $(INSTALL_UNITDIR)
+	$(INSTALL) $(INSTALLPPUFILES) $(INSTALL_UNITDIR)
+ifneq ($(INSTALLPPULINKFILES),)
+	$(INSTALL) $(INSTALLPPULINKFILES) $(INSTALL_UNITDIR)
+endif
+ifneq ($(wildcard $(LIB_FULLNAME)),)
+	$(MKDIR) $(INSTALL_LIBDIR)
+	$(INSTALL) $(LIB_FULLNAME) $(INSTALL_LIBDIR)
+ifdef inUnix
+	ln -sf $(LIB_FULLNAME) $(INSTALL_LIBDIR)/$(LIB_NAME)
+endif
+endif
+endif
+ifdef INSTALL_FILES
+	$(MKDIR) $(INSTALL_DATADIR)
+	$(INSTALL) $(INSTALL_FILES) $(INSTALL_DATADIR)
+endif
+fpc_sourceinstall: distclean
+	$(MKDIR) $(INSTALL_SOURCEDIR)
+	$(COPYTREE) $(BASEDIR) $(INSTALL_SOURCEDIR)
+fpc_exampleinstall: $(addsuffix _distclean,$(TARGET_EXAMPLEDIRS))
+ifdef HASEXAMPLES
+	$(MKDIR) $(INSTALL_EXAMPLEDIR)
+endif
+ifdef EXAMPLESOURCEFILES
+	$(COPY) $(EXAMPLESOURCEFILES) $(INSTALL_EXAMPLEDIR)
+endif
+ifdef TARGET_EXAMPLEDIRS
+	$(COPYTREE) $(addsuffix /*,$(TARGET_EXAMPLEDIRS)) $(INSTALL_EXAMPLEDIR)
+endif
+.PHONY: fpc_distinstall
+fpc_distinstall: install exampleinstall
+.PHONY: fpc_zipinstall fpc_zipsourceinstall fpc_zipexampleinstall
+ifndef PACKDIR
+ifndef inUnix
+PACKDIR=$(BASEDIR)/../fpc-pack
+else
+PACKDIR=/tmp/fpc-pack
+endif
+endif
+ifndef ZIPNAME
+ifdef DIST_ZIPNAME
+ZIPNAME=$(DIST_ZIPNAME)
+else
+ZIPNAME=$(ZIPPREFIX)$(PACKAGE_NAME)$(ZIPSUFFIX)
+endif
+endif
+ifndef ZIPTARGET
+ifdef DIST_ZIPTARGET
+ZIPTARGET=DIST_ZIPTARGET
+else
+ZIPTARGET=install
+endif
+endif
+ifndef USEZIP
+ifdef inUnix
+USETAR=1
+endif
+endif
+ifndef inUnix
+USEZIPWRAPPER=1
+endif
+ifdef USEZIPWRAPPER
+ZIPPATHSEP=$(PATHSEP)
+ZIPWRAPPER=$(subst /,$(PATHSEP),$(DIST_DESTDIR)/fpczip$(BATCHEXT))
+else
+ZIPPATHSEP=/
+endif
+ZIPCMD_CDPACK:=cd $(subst /,$(ZIPPATHSEP),$(PACKDIR))
+ZIPCMD_CDBASE:=cd $(subst /,$(ZIPPATHSEP),$(BASEDIR))
+ifdef USETAR
+ZIPDESTFILE:=$(DIST_DESTDIR)/$(ZIPNAME)$(TAREXT)
+ZIPCMD_ZIP:=$(TARPROG) cf$(TAROPT) $(ZIPDESTFILE) *
+else
+ZIPDESTFILE:=$(DIST_DESTDIR)/$(ZIPNAME)$(ZIPEXT)
+ZIPCMD_ZIP:=$(subst /,$(ZIPPATHSEP),$(ZIPPROG)) -Dr $(ZIPOPT) $(ZIPDESTFILE) *
+endif
+fpc_zipinstall:
+	$(MAKE) $(ZIPTARGET) INSTALL_PREFIX=$(PACKDIR) ZIPINSTALL=1
+	$(MKDIR) $(DIST_DESTDIR)
+	$(DEL) $(ZIPDESTFILE)
+ifdef USEZIPWRAPPER
+ifneq ($(ECHOREDIR),echo)
+	$(ECHOREDIR) -e "$(subst \,\\,$(ZIPCMD_CDPACK))" > $(ZIPWRAPPER)
+	$(ECHOREDIR) -e "$(subst \,\\,$(ZIPCMD_ZIP))" >> $(ZIPWRAPPER)
+	$(ECHOREDIR) -e "$(subst \,\\,$(ZIPCMD_CDBASE))" >> $(ZIPWRAPPER)
+else
+	echo $(ZIPCMD_CDPACK) > $(ZIPWRAPPER)
+	echo $(ZIPCMD_ZIP) >> $(ZIPWRAPPER)
+	echo $(ZIPCMD_CDBASE) >> $(ZIPWRAPPER)
+endif
+ifdef inUnix
+	/bin/sh $(ZIPWRAPPER)
+else
+	$(ZIPWRAPPER)
+endif
+	$(DEL) $(ZIPWRAPPER)
+else
+	$(ZIPCMD_CDPACK) ; $(ZIPCMD_ZIP) ; $(ZIPCMD_CDBASE)
+endif
+	$(DELTREE) $(PACKDIR)
+fpc_zipsourceinstall:
+	$(MAKE) fpc_zipinstall ZIPTARGET=sourceinstall ZIPSUFFIX=src
+fpc_zipexampleinstall:
+ifdef HASEXAMPLES
+	$(MAKE) fpc_zipinstall ZIPTARGET=exampleinstall ZIPSUFFIX=exm
+endif
+fpc_zipdistinstall:
+	$(MAKE) fpc_zipinstall ZIPTARGET=distinstall
+.PHONY: fpc_clean fpc_cleanall fpc_distclean
+ifdef EXEFILES
+override CLEANEXEFILES:=$(addprefix $(TARGETDIRPREFIX),$(CLEANEXEFILES))
+endif
+ifdef CLEAN_UNITS
+override CLEANPPUFILES+=$(addsuffix $(PPUEXT),$(CLEAN_UNITS))
+endif
+ifdef CLEANPPUFILES
+override CLEANPPULINKFILES:=$(subst $(PPUEXT),$(OEXT),$(CLEANPPUFILES)) $(addprefix $(STATICLIBPREFIX),$(subst $(PPUEXT),$(STATICLIBEXT),$(CLEANPPUFILES)))
+override CLEANPPUFILES:=$(addprefix $(UNITTARGETDIRPREFIX),$(CLEANPPUFILES))
+override CLEANPPULINKFILES:=$(wildcard $(addprefix $(UNITTARGETDIRPREFIX),$(CLEANPPULINKFILES)))
+endif
+fpc_clean: $(CLEANTARGET)
+ifdef CLEANEXEFILES
+	-$(DEL) $(CLEANEXEFILES)
+endif
+ifdef CLEANPPUFILES
+	-$(DEL) $(CLEANPPUFILES)
+endif
+ifneq ($(CLEANPPULINKFILES),)
+	-$(DEL) $(CLEANPPULINKFILES)
+endif
+ifdef CLEANRSTFILES
+	-$(DEL) $(addprefix $(UNITTARGETDIRPREFIX),$(CLEANRSTFILES))
+endif
+ifdef CLEAN_FILES
+	-$(DEL) $(CLEAN_FILES)
+endif
+ifdef LIB_NAME
+	-$(DEL) $(LIB_NAME) $(LIB_FULLNAME)
+endif
+	-$(DEL) $(FPCMADE) Package.fpc $(PPAS) script.res link.res $(FPCEXTFILE) $(REDIRFILE)
+fpc_distclean: clean
+ifdef COMPILER_UNITTARGETDIR
+TARGETDIRCLEAN=fpc_clean
+endif
+fpc_cleanall: $(CLEANTARGET) $(TARGETDIRCLEAN)
+ifdef CLEANEXEFILES
+	-$(DEL) $(CLEANEXEFILES)
+endif
+	-$(DEL) *$(OEXT) *$(PPUEXT) *$(RSTEXT) *$(ASMEXT) *$(STATICLIBEXT) *$(SHAREDLIBEXT) *$(PPLEXT)
+	-$(DELTREE) *$(SMARTEXT)
+	-$(DEL) $(FPCMADE) Package.fpc $(PPAS) script.res link.res $(FPCEXTFILE) $(REDIRFILE)
+ifdef AOUTEXT
+	-$(DEL) *$(AOUTEXT)
+endif
+.PHONY: fpc_baseinfo
+override INFORULES+=fpc_baseinfo
+fpc_baseinfo:
+	@$(ECHO)
+	@$(ECHO)  == Package info ==
+	@$(ECHO)  Package Name..... $(PACKAGE_NAME)
+	@$(ECHO)  Package Version.. $(PACKAGE_VERSION)
+	@$(ECHO)
+	@$(ECHO)  == Configuration info ==
+	@$(ECHO)
+	@$(ECHO)  FPC.......... $(FPC)
+	@$(ECHO)  FPC Version.. $(FPC_VERSION)
+	@$(ECHO)  Source CPU... $(CPU_SOURCE)
+	@$(ECHO)  Target CPU... $(CPU_TARGET)
+	@$(ECHO)  Source OS.... $(OS_SOURCE)
+	@$(ECHO)  Target OS.... $(OS_TARGET)
+	@$(ECHO)  Full Target.. $(FULL_SOURCE)
+	@$(ECHO)  Full Source.. $(FULL_TARGET)
+	@$(ECHO)
+	@$(ECHO)  == Directory info ==
+	@$(ECHO)
+	@$(ECHO)  Required pkgs... $(REQUIRE_PACKAGES)
+	@$(ECHO)
+	@$(ECHO)  Basedir......... $(BASEDIR)
+	@$(ECHO)  FPCDir.......... $(FPCDIR)
+	@$(ECHO)  CrossBinDir..... $(CROSSBINDIR)
+	@$(ECHO)  UnitsDir........ $(UNITSDIR)
+	@$(ECHO)  PackagesDir..... $(PACKAGESDIR)
+	@$(ECHO)
+	@$(ECHO)  GCC library..... $(GCCLIBDIR)
+	@$(ECHO)  Other library... $(OTHERLIBDIR)
+	@$(ECHO)
+	@$(ECHO)  == Tools info ==
+	@$(ECHO)
+	@$(ECHO)  As........ $(AS)
+	@$(ECHO)  Ld........ $(LD)
+	@$(ECHO)  Ar........ $(AR)
+	@$(ECHO)  Rc........ $(RC)
+	@$(ECHO)
+	@$(ECHO)  Mv........ $(MVPROG)
+	@$(ECHO)  Cp........ $(CPPROG)
+	@$(ECHO)  Rm........ $(RMPROG)
+	@$(ECHO)  GInstall.. $(GINSTALL)
+	@$(ECHO)  Echo...... $(ECHO)
+	@$(ECHO)  Date...... $(DATE)
+	@$(ECHO)  FPCMake... $(FPCMAKE)
+	@$(ECHO)  PPUMove... $(PPUMOVE)
+	@$(ECHO)  Upx....... $(UPXPROG)
+	@$(ECHO)  Zip....... $(ZIPPROG)
+	@$(ECHO)
+	@$(ECHO)  == Object info ==
+	@$(ECHO)
+	@$(ECHO)  Target Loaders........ $(TARGET_LOADERS)
+	@$(ECHO)  Target Units.......... $(TARGET_UNITS)
+	@$(ECHO)  Target Implicit Units. $(TARGET_IMPLICITUNITS)
+	@$(ECHO)  Target Programs....... $(TARGET_PROGRAMS)
+	@$(ECHO)  Target Dirs........... $(TARGET_DIRS)
+	@$(ECHO)  Target Examples....... $(TARGET_EXAMPLES)
+	@$(ECHO)  Target ExampleDirs.... $(TARGET_EXAMPLEDIRS)
+	@$(ECHO)
+	@$(ECHO)  Clean Units......... $(CLEAN_UNITS)
+	@$(ECHO)  Clean Files......... $(CLEAN_FILES)
+	@$(ECHO)
+	@$(ECHO)  Install Units....... $(INSTALL_UNITS)
+	@$(ECHO)  Install Files....... $(INSTALL_FILES)
+	@$(ECHO)
+	@$(ECHO)  == Install info ==
+	@$(ECHO)
+	@$(ECHO)  DateStr.............. $(DATESTR)
+	@$(ECHO)  ZipPrefix............ $(ZIPPREFIX)
+	@$(ECHO)  ZipSuffix............ $(ZIPSUFFIX)
+	@$(ECHO)  Install FPC Package.. $(INSTALL_FPCPACKAGE)
+	@$(ECHO)
+	@$(ECHO)  Install base dir..... $(INSTALL_BASEDIR)
+	@$(ECHO)  Install binary dir... $(INSTALL_BINDIR)
+	@$(ECHO)  Install library dir.. $(INSTALL_LIBDIR)
+	@$(ECHO)  Install units dir.... $(INSTALL_UNITDIR)
+	@$(ECHO)  Install source dir... $(INSTALL_SOURCEDIR)
+	@$(ECHO)  Install doc dir...... $(INSTALL_DOCDIR)
+	@$(ECHO)  Install example dir.. $(INSTALL_EXAMPLEDIR)
+	@$(ECHO)  Install data dir..... $(INSTALL_DATADIR)
+	@$(ECHO)
+	@$(ECHO)  Dist destination dir. $(DIST_DESTDIR)
+	@$(ECHO)  Dist zip name........ $(DIST_ZIPNAME)
+	@$(ECHO)
+.PHONY: fpc_info
+fpc_info: $(INFORULES)
+.PHONY: fpc_makefile fpc_makefiles fpc_makefile_sub1 fpc_makefile_sub2 \
+	fpc_makefile_dirs
+fpc_makefile:
+	$(FPCMAKE) -w -T$(OS_TARGET) Makefile.fpc
+fpc_makefile_sub1:
+ifdef TARGET_DIRS
+	$(FPCMAKE) -w -T$(OS_TARGET) $(addsuffix /Makefile.fpc,$(TARGET_DIRS))
+endif
+ifdef TARGET_EXAMPLEDIRS
+	$(FPCMAKE) -w -T$(OS_TARGET) $(addsuffix /Makefile.fpc,$(TARGET_EXAMPLEDIRS))
+endif
+fpc_makefile_sub2: $(addsuffix _makefile_dirs,$(TARGET_DIRS) $(TARGET_EXAMPLEDIRS))
+fpc_makefile_dirs: fpc_makefile_sub1 fpc_makefile_sub2
+fpc_makefiles: fpc_makefile fpc_makefile_dirs
+all: fpc_all
+debug: fpc_debug
+smart: fpc_smart
+release: fpc_release
+examples: fpc_examples
+shared:
+install: fpc_install
+sourceinstall: fpc_sourceinstall
+exampleinstall: fpc_exampleinstall
+distinstall: fpc_distinstall
+zipinstall: fpc_zipinstall
+zipsourceinstall: fpc_zipsourceinstall
+zipexampleinstall: fpc_zipexampleinstall
+zipdistinstall: fpc_zipdistinstall
+clean: fpc_clean
+distclean: fpc_distclean
+cleanall: fpc_cleanall
+info: fpc_info
+makefiles: fpc_makefiles
+.PHONY: all debug smart release examples shared install sourceinstall exampleinstall distinstall zipinstall zipsourceinstall zipexampleinstall zipdistinstall clean distclean cleanall info makefiles
+ifneq ($(wildcard fpcmake.loc),)
+include fpcmake.loc
+endif

+ 17 - 0
packages/base/paszlib/Makefile.fpc

@@ -0,0 +1,17 @@
+#
+#   Makefile.fpc for PasZLib
+#
+
+[package]
+name=paszlib
+version=1.0.6
+
+[target]
+units=paszlib adler gzcrc gzio infblock infcodes inffast inftrees infutil trees zcompres zdeflate zinflate zbase zuncompr zutil
+examples=example minigzip
+
+[install]
+fpcpackage=y
+
+[default]
+fpcdir=../../..

+ 114 - 0
packages/base/paszlib/adler.pas

@@ -0,0 +1,114 @@
+Unit Adler;
+
+{
+  adler32.c -- compute the Adler-32 checksum of a data stream
+  Copyright (C) 1995-1998 Mark Adler
+
+  Pascal tranlastion
+  Copyright (C) 1998 by Jacques Nomssi Nzali
+  For conditions of distribution and use, see copyright notice in readme.txt
+}
+
+interface
+
+{$I zconf.inc}
+
+uses
+  zutil;
+
+function adler32(adler : uLong; buf : pBytef; len : uInt) : uLong;
+
+{    Update a running Adler-32 checksum with the bytes buf[0..len-1] and
+   return the updated checksum. If buf is NIL, this function returns
+   the required initial value for the checksum.
+   An Adler-32 checksum is almost as reliable as a CRC32 but can be computed
+   much faster. Usage example:
+
+   var
+     adler : uLong;
+   begin
+     adler := adler32(0, Z_NULL, 0);
+
+     while (read_buffer(buffer, length) <> EOF) do
+       adler := adler32(adler, buffer, length);
+
+     if (adler <> original_adler) then
+       error();
+   end;
+}
+
+implementation
+
+const
+  BASE = Long(65521); { largest prime smaller than 65536 }
+  {NMAX = 5552; original code with unsigned 32 bit integer }
+  { NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 }
+  NMAX = 3854;        { code with signed 32 bit integer }
+  { NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^31-1 }
+  { The penalty is the time loss in the extra MOD-calls. }
+
+
+{ ========================================================================= }
+
+function adler32(adler : uLong; buf : pBytef; len : uInt) : uLong;
+var
+  s1, s2 : uLong;
+  k : int;
+begin
+  s1 := adler and $ffff;
+  s2 := (adler shr 16) and $ffff;
+
+  if not Assigned(buf) then
+  begin
+    adler32 := uLong(1);
+    exit;
+  end;
+
+  while (len > 0) do
+  begin
+    if len < NMAX then
+      k := len
+    else
+      k := NMAX;
+    Dec(len, k);
+    {
+    while (k >= 16) do
+    begin
+      DO16(buf);
+      Inc(buf, 16);
+      Dec(k, 16);
+    end;
+    if (k <> 0) then
+    repeat
+      Inc(s1, buf^);
+      Inc(puf);
+      Inc(s2, s1);
+      Dec(k);
+    until (k = 0);
+    }
+    while (k > 0) do
+    begin
+      Inc(s1, buf^);
+      Inc(s2, s1);
+      Inc(buf);
+      Dec(k);
+    end;
+    s1 := s1 mod BASE;
+    s2 := s2 mod BASE;
+  end;
+  adler32 := (s2 shl 16) or s1;
+end;
+
+{
+#define DO1(buf,i)
+  begin
+    Inc(s1, buf[i]);
+    Inc(s2, s1);
+  end;
+#define DO2(buf,i)  DO1(buf,i); DO1(buf,i+1);
+#define DO4(buf,i)  DO2(buf,i); DO2(buf,i+2);
+#define DO8(buf,i)  DO4(buf,i); DO4(buf,i+4);
+#define DO16(buf)   DO8(buf,0); DO8(buf,8);
+}
+end.
+

+ 12 - 0
packages/base/paszlib/changes.txt

@@ -0,0 +1,12 @@
+
+Changes to the last version of PASZLIB (http://www.tu-chemnitz.de/~nomssi)
+required for FPC-pascal:
+
+(Standard adding of @ for assignment of procedure variables)
+Zdeflate 532 and 536 added an @
+zinflate 259 263 294 added an @
+
+Warning only:
+inflatetrees  inflate_tree_fixed has two uint parameters in the interface, and
+        two uintf's in the implementation. Only a warning is issued btw, so
+        this is not critical.

+ 704 - 0
packages/base/paszlib/example.pas

@@ -0,0 +1,704 @@
+program example;
+
+{ example.c -- usage example of the zlib compression library
+  Copyright (C) 1995-1998 Jean-loup Gailly.
+
+  Pascal tranlastion
+  Copyright (C) 1998 by Jacques Nomssi Nzali
+  For conditions of distribution and use, see copyright notice in readme.txt
+}
+{-$define MemCheck}
+{$IFNDEF FPC}
+  {$DEFINE TEST_COMPRESS}
+{$ENDIF}
+{$DEFINE TEST_GZIO}
+{$DEFINE TEST_INFLATE}
+{$DEFINE TEST_DEFLATE}
+{$DEFINE TEST_SYNC}
+{$DEFINE TEST_DICT}
+{$DEFINE TEST_FLUSH}
+
+uses
+{$ifdef ver80}
+ WinCrt,
+{$endif}
+  strings,
+{$ifndef MSDOS}
+  SysUtils,
+{$endif}
+  zutil,
+  zbase,
+  gzIo,
+  zInflate,
+  zDeflate,
+  zCompres,
+  zUnCompr
+{$ifdef MemCheck}
+  , MemCheck in '..\..\monotekt\pas\memcheck\memcheck.pas'
+{$endif}
+;
+
+procedure Stop;
+begin
+  Write('Program halted...');
+  ReadLn;
+  Halt(1);
+end;
+
+procedure CHECK_ERR(err : int; msg : string);
+begin
+  if (err <> Z_OK) then
+  begin
+    Write(msg, ' error: ', err);
+    Stop;
+  end;
+end;
+
+const
+  hello : PChar = 'hello, hello!';
+{ "hello world" would be more standard, but the repeated "hello"
+  stresses the compression code better, sorry... }
+
+{$IFDEF TEST_DICT}
+const
+  dictionary : PChar = 'hello';
+var
+  dictId : uLong; { Adler32 value of the dictionary }
+{$ENDIF}
+
+{ ===========================================================================
+  Test compress() and uncompress() }
+
+{$IFDEF TEST_COMPRESS}
+procedure test_compress(compr : pBytef; var comprLen : uLong;
+                        uncompr : pBytef; uncomprLen : uLong);
+var
+  err : int;
+  len : uLong;
+begin
+  len := strlen(hello)+1;
+  err := compress(compr, comprLen, pBytef(hello)^, len);
+  CHECK_ERR(err, 'compress');
+
+  strcopy(PChar(uncompr), 'garbage');
+
+  err := uncompress(uncompr, uncomprLen, compr^, comprLen);
+  CHECK_ERR(err, 'uncompress');
+
+  if (strcomp(PChar(uncompr), hello)) <> 0 then
+  begin
+    WriteLn('bad uncompress');
+    Stop;
+  end
+  else
+    WriteLn('uncompress(): ', StrPas(PChar(uncompr)));
+end;
+{$ENDIF}
+
+{ ===========================================================================
+  Test read/write of .gz files }
+
+{$IFDEF TEST_GZIO}
+procedure test_gzio(const outf : string; { output file }
+                    const inf : string;  { input file }
+                    uncompr : pBytef;
+                    uncomprLen : int);
+var
+  err : int;
+  len : int;
+var
+  zfile : gzFile;
+  pos : z_off_t;
+begin
+  len := strlen(hello)+1;
+
+  zfile := gzopen(outf, 'w');
+  if (zfile = NIL) then
+  begin
+    WriteLn('_gzopen error');
+    Stop;
+  end;
+  gzputc(zfile, 'h');
+  if (gzputs(zfile, 'ello') <> 4) then
+  begin
+    WriteLn('gzputs err: ', gzerror(zfile, err));
+    Stop;
+  end;
+  {$ifdef GZ_FORMAT_STRING}
+  if (gzprintf(zfile, ', %s!', 'hello') <> 8) then
+  begin
+    WriteLn('gzprintf err: ', gzerror(zfile, err));
+    Stop;
+  end;
+  {$else}
+  if (gzputs(zfile, ', hello!') <> 8) then
+  begin
+    WriteLn('gzputs err: ', gzerror(zfile, err));
+    Stop;
+  end;
+  {$ENDIF}
+  gzseek(zfile, Long(1), SEEK_CUR); { add one zero byte }
+  gzclose(zfile);
+
+  zfile := gzopen(inf, 'r');
+  if (zfile = NIL) then
+    WriteLn('gzopen error');
+
+  strcopy(pchar(uncompr), 'garbage');
+
+  uncomprLen := gzread(zfile, uncompr, uInt(uncomprLen));
+  if (uncomprLen <> len) then
+  begin
+    WriteLn('gzread err: ', gzerror(zfile, err));
+    Stop;
+  end;
+  if (strcomp(pchar(uncompr), hello)) <> 0 then
+  begin
+    WriteLn('bad gzread: ', pchar(uncompr));
+    Stop;
+  end
+  else
+    WriteLn('gzread(): ', pchar(uncompr));
+
+  pos := gzseek(zfile, Long(-8), SEEK_CUR);
+  if (pos <> 6) or (gztell(zfile) <> pos) then
+  begin
+    WriteLn('gzseek error, pos=',pos,', gztell=',gztell(zfile));
+    Stop;
+  end;
+
+  if (char(gzgetc(zfile)) <> ' ') then
+  begin
+    WriteLn('gzgetc error');
+    Stop;
+  end;
+
+  gzgets(zfile, pchar(uncompr), uncomprLen);
+  uncomprLen := strlen(pchar(uncompr));
+  if (uncomprLen <> 6) then
+  begin { "hello!" }
+    WriteLn('gzgets err after gzseek: ', gzerror(zfile, err));
+    Stop;
+  end;
+  if (strcomp(pchar(uncompr), hello+7)) <> 0 then
+  begin
+    WriteLn('bad gzgets after gzseek');
+    Stop;
+  end
+  else
+    WriteLn('gzgets() after gzseek: ', PChar(uncompr));
+
+  gzclose(zfile);
+end;
+{$ENDIF}
+
+{ ===========================================================================
+  Test deflate() with small buffers }
+
+{$IFDEF TEST_DEFLATE}
+procedure test_deflate(compr : pBytef; comprLen : uLong);
+var
+  c_stream : z_stream; { compression stream }
+  err : int;
+  len : int;
+begin
+  len := strlen(hello)+1;
+  c_stream.zalloc := NIL; {alloc_func(0);}
+  c_stream.zfree := NIL;  {free_func(0);}
+  c_stream.opaque := NIL; {voidpf(0);}
+
+  err := deflateInit(c_stream, Z_DEFAULT_COMPRESSION);
+  CHECK_ERR(err, 'deflateInit');
+
+  c_stream.next_in  := pBytef(hello);
+  c_stream.next_out := compr;
+
+  while (c_stream.total_in <> uLong(len)) and (c_stream.total_out < comprLen) do
+  begin
+    c_stream.avail_out := 1; { force small buffers }
+    c_stream.avail_in := 1;
+    err := deflate(c_stream, Z_NO_FLUSH);
+    CHECK_ERR(err, 'deflate');
+  end;
+
+  { Finish the stream, still forcing small buffers: }
+  while TRUE do
+  begin
+    c_stream.avail_out := 1;
+    err := deflate(c_stream, Z_FINISH);
+    if (err = Z_STREAM_END) then
+      break;
+    CHECK_ERR(err, 'deflate');
+  end;
+
+  err := deflateEnd(c_stream);
+  CHECK_ERR(err, 'deflateEnd');
+end;
+{$ENDIF}
+
+{ ===========================================================================
+  Test inflate() with small buffers
+}
+
+{$IFDEF TEST_INFLATE}
+procedure test_inflate(compr : pBytef; comprLen : uLong;
+                       uncompr : pBytef;  uncomprLen : uLong);
+var
+  err : int;
+  d_stream : z_stream; { decompression stream }
+begin
+  strcopy(PChar(uncompr), 'garbage');
+
+  d_stream.zalloc := NIL; {alloc_func(0);}
+  d_stream.zfree := NIL; {free_func(0);}
+  d_stream.opaque := NIL; {voidpf(0);}
+
+  d_stream.next_in  := compr;
+  d_stream.avail_in := 0;
+  d_stream.next_out := uncompr;
+
+  err := inflateInit(d_stream);
+  CHECK_ERR(err, 'inflateInit');
+
+  while (d_stream.total_out < uncomprLen) and
+        (d_stream.total_in < comprLen) do
+  begin
+    d_stream.avail_out := 1; { force small buffers }
+    d_stream.avail_in := 1;
+    err := inflate(d_stream, Z_NO_FLUSH);
+    if (err = Z_STREAM_END) then
+      break;
+    CHECK_ERR(err, 'inflate');
+  end;
+
+  err := inflateEnd(d_stream);
+  CHECK_ERR(err, 'inflateEnd');
+
+  if (strcomp(PChar(uncompr), hello) <> 0) then
+  begin
+    WriteLn('bad inflate');
+    exit;
+  end
+  else
+  begin
+    WriteLn('inflate(): ', StrPas(PChar(uncompr)));
+  end;
+end;
+{$ENDIF}
+
+{ ===========================================================================
+  Test deflate() with large buffers and dynamic change of compression level
+ }
+
+{$IFDEF TEST_DEFLATE}
+procedure test_large_deflate(compr : pBytef; comprLen : uLong;
+                             uncompr : pBytef;  uncomprLen : uLong);
+var
+  c_stream : z_stream; { compression stream }
+  err : int;
+begin
+  c_stream.zalloc := NIL; {alloc_func(0);}
+  c_stream.zfree := NIL;  {free_func(0);}
+  c_stream.opaque := NIL; {voidpf(0);}
+
+  err := deflateInit(c_stream, Z_BEST_SPEED);
+  CHECK_ERR(err, 'deflateInit');
+
+  c_stream.next_out := compr;
+  c_stream.avail_out := uInt(comprLen);
+
+  { At this point, uncompr is still mostly zeroes, so it should compress
+    very well: }
+
+  c_stream.next_in := uncompr;
+  c_stream.avail_in := uInt(uncomprLen);
+  err := deflate(c_stream, Z_NO_FLUSH);
+  CHECK_ERR(err, 'deflate');
+  if (c_stream.avail_in <> 0) then
+  begin
+    WriteLn('deflate not greedy');
+    exit;
+  end;
+
+  { Feed in already compressed data and switch to no compression: }
+  deflateParams(c_stream, Z_NO_COMPRESSION, Z_DEFAULT_STRATEGY);
+  c_stream.next_in := compr;
+  c_stream.avail_in := uInt(comprLen div 2);
+  err := deflate(c_stream, Z_NO_FLUSH);
+  CHECK_ERR(err, 'deflate');
+
+  { Switch back to compressing mode: }
+  deflateParams(c_stream, Z_BEST_COMPRESSION, Z_FILTERED);
+  c_stream.next_in := uncompr;
+  c_stream.avail_in := uInt(uncomprLen);
+  err := deflate(c_stream, Z_NO_FLUSH);
+  CHECK_ERR(err, 'deflate');
+
+  err := deflate(c_stream, Z_FINISH);
+  if (err <> Z_STREAM_END) then
+  begin
+    WriteLn('deflate should report Z_STREAM_END');
+    exit;
+  end;
+  err := deflateEnd(c_stream);
+  CHECK_ERR(err, 'deflateEnd');
+end;
+{$ENDIF}
+
+{ ===========================================================================
+  Test inflate() with large buffers }
+
+{$IFDEF TEST_INFLATE}
+procedure test_large_inflate(compr : pBytef; comprLen : uLong;
+                             uncompr : pBytef;  uncomprLen : uLong);
+var
+  err : int;
+  d_stream : z_stream; { decompression stream }
+begin
+  strcopy(PChar(uncompr), 'garbage');
+
+  d_stream.zalloc := NIL; {alloc_func(0);}
+  d_stream.zfree := NIL; {free_func(0);}
+  d_stream.opaque := NIL; {voidpf(0);}
+
+  d_stream.next_in  := compr;
+  d_stream.avail_in := uInt(comprLen);
+
+  err := inflateInit(d_stream);
+  CHECK_ERR(err, 'inflateInit');
+
+  while TRUE do
+  begin
+    d_stream.next_out := uncompr;            { discard the output }
+    d_stream.avail_out := uInt(uncomprLen);
+    err := inflate(d_stream, Z_NO_FLUSH);
+    if (err = Z_STREAM_END) then
+      break;
+    CHECK_ERR(err, 'large inflate');
+  end;
+
+  err := inflateEnd(d_stream);
+  CHECK_ERR(err, 'inflateEnd');
+
+  if (d_stream.total_out <> 2*uncomprLen + comprLen div 2) then
+  begin
+    WriteLn('bad large inflate: ', d_stream.total_out);
+    Stop;
+  end
+  else
+    WriteLn('large_inflate(): OK');
+end;
+{$ENDIF}
+
+{ ===========================================================================
+  Test deflate() with full flush
+ }
+{$IFDEF TEST_FLUSH}
+procedure test_flush(compr : pBytef; var comprLen : uLong);
+var
+  c_stream : z_stream; { compression stream }
+  err : int;
+  len : int;
+
+begin
+  len := strlen(hello)+1;
+  c_stream.zalloc := NIL;       {alloc_func(0);}
+  c_stream.zfree := NIL;        {free_func(0);}
+  c_stream.opaque := NIL;       {voidpf(0);}
+
+  err := deflateInit(c_stream, Z_DEFAULT_COMPRESSION);
+  CHECK_ERR(err, 'deflateInit');
+
+  c_stream.next_in := pBytef(hello);
+  c_stream.next_out := compr;
+  c_stream.avail_in := 3;
+  c_stream.avail_out := uInt(comprLen);
+
+  err := deflate(c_stream, Z_FULL_FLUSH);
+  CHECK_ERR(err, 'deflate');
+
+  Inc(pzByteArray(compr)^[3]); { force an error in first compressed block }
+  c_stream.avail_in := len - 3;
+
+  err := deflate(c_stream, Z_FINISH);
+  if (err <> Z_STREAM_END) then
+    CHECK_ERR(err, 'deflate');
+
+  err := deflateEnd(c_stream);
+    CHECK_ERR(err, 'deflateEnd');
+
+  comprLen := c_stream.total_out;
+end;
+{$ENDIF}
+
+{ ===========================================================================
+  Test inflateSync()
+ }
+{$IFDEF TEST_SYNC}
+procedure test_sync(compr : pBytef; comprLen : uLong;
+                    uncompr : pBytef; uncomprLen : uLong);
+var
+  err : int;
+  d_stream : z_stream; { decompression stream }
+begin
+  strcopy(PChar(uncompr), 'garbage');
+
+  d_stream.zalloc := NIL;            {alloc_func(0);}
+  d_stream.zfree := NIL;             {free_func(0);}
+  d_stream.opaque := NIL;            {voidpf(0);}
+
+  d_stream.next_in  := compr;
+  d_stream.avail_in := 2; { just read the zlib header }
+
+  err := inflateInit(d_stream);
+  CHECK_ERR(err, 'inflateInit');
+
+  d_stream.next_out := uncompr;
+  d_stream.avail_out := uInt(uncomprLen);
+
+  inflate(d_stream, Z_NO_FLUSH);
+  CHECK_ERR(err, 'inflate');
+
+  d_stream.avail_in := uInt(comprLen-2);   { read all compressed data }
+  err := inflateSync(d_stream);           { but skip the damaged part }
+  CHECK_ERR(err, 'inflateSync');
+
+  err := inflate(d_stream, Z_FINISH);
+  if (err <> Z_DATA_ERROR) then
+  begin
+    WriteLn('inflate should report DATA_ERROR');
+      { Because of incorrect adler32 }
+    Stop;
+  end;
+  err := inflateEnd(d_stream);
+  CHECK_ERR(err, 'inflateEnd');
+
+  WriteLn('after inflateSync(): hel', StrPas(PChar(uncompr)));
+end;
+{$ENDIF}
+
+{ ===========================================================================
+  Test deflate() with preset dictionary
+ }
+{$IFDEF TEST_DICT}
+procedure test_dict_deflate(compr : pBytef; comprLen : uLong);
+var
+  c_stream : z_stream; { compression stream }
+  err : int;
+begin
+  c_stream.zalloc := NIL; {(alloc_func)0;}
+  c_stream.zfree := NIL; {(free_func)0;}
+  c_stream.opaque := NIL; {(voidpf)0;}
+
+  err := deflateInit(c_stream, Z_BEST_COMPRESSION);
+  CHECK_ERR(err, 'deflateInit');
+
+  err := deflateSetDictionary(c_stream,
+                              pBytef(dictionary), StrLen(dictionary));
+  CHECK_ERR(err, 'deflateSetDictionary');
+
+  dictId := c_stream.adler;
+  c_stream.next_out := compr;
+  c_stream.avail_out := uInt(comprLen);
+
+  c_stream.next_in := pBytef(hello);
+  c_stream.avail_in := uInt(strlen(hello)+1);
+
+  err := deflate(c_stream, Z_FINISH);
+  if (err <> Z_STREAM_END) then
+  begin
+    WriteLn('deflate should report Z_STREAM_END');
+    exit;
+  end;
+  err := deflateEnd(c_stream);
+  CHECK_ERR(err, 'deflateEnd');
+end;
+
+{ ===========================================================================
+  Test inflate() with a preset dictionary }
+
+procedure test_dict_inflate(compr : pBytef; comprLen : uLong;
+                            uncompr : pBytef; uncomprLen : uLong);
+var
+  err : int;
+  d_stream : z_stream; { decompression stream }
+begin
+  strcopy(PChar(uncompr), 'garbage');
+
+  d_stream.zalloc := NIL;              { alloc_func(0); }
+  d_stream.zfree := NIL;               { free_func(0); }
+  d_stream.opaque := NIL;              { voidpf(0); }
+
+  d_stream.next_in  := compr;
+  d_stream.avail_in := uInt(comprLen);
+
+  err := inflateInit(d_stream);
+  CHECK_ERR(err, 'inflateInit');
+
+  d_stream.next_out := uncompr;
+  d_stream.avail_out := uInt(uncomprLen);
+
+  while TRUE do
+  begin
+    err := inflate(d_stream, Z_NO_FLUSH);
+    if (err = Z_STREAM_END) then
+      break;
+    if (err = Z_NEED_DICT) then
+    begin
+      if (d_stream.adler <> dictId) then
+      begin
+        WriteLn('unexpected dictionary');
+        Stop;
+      end;
+      err := inflateSetDictionary(d_stream, pBytef(dictionary),
+                                     StrLen(dictionary));
+    end;
+    CHECK_ERR(err, 'inflate with dict');
+  end;
+
+  err := inflateEnd(d_stream);
+  CHECK_ERR(err, 'inflateEnd');
+
+  if (strcomp(PChar(uncompr), hello)) <> 0 then
+  begin
+    WriteLn('bad inflate with dict');
+    Stop;
+  end
+  else
+  begin
+    WriteLn('inflate with dictionary: ', StrPas(PChar(uncompr)));
+  end;
+end;
+{$ENDIF}
+
+function GetFromFile(buf : pBytef; FName : string;
+                     var MaxLen : uInt) : boolean;
+const
+  zOfs = 0;
+var
+  f : file;
+  Len : uLong;
+begin
+  assign(f, FName);
+  GetFromFile := false;
+  {$I-}
+  filemode := 0; { read only }
+  reset(f, 1);
+  if IOresult = 0 then
+  begin
+    Len := FileSize(f)-zOfs;
+    Seek(f, zOfs);
+    if Len < MaxLen then
+      MaxLen := Len;
+    BlockRead(f, buf^, MaxLen);
+    close(f);
+    WriteLn(FName);
+    GetFromFile := (IOresult = 0) and (MaxLen > 0);
+  end
+  else
+    WriteLn('Could not open ', FName);
+end;
+
+{ ===========================================================================
+  Usage:  example [output.gz  [input.gz]]
+}
+
+var
+  compr, uncompr : pBytef;
+const
+  msdoslen = 25000;
+  comprLenL : uLong = msdoslen div sizeof(uInt); { don't overflow on MSDOS }
+  uncomprLenL : uLong = msdoslen div sizeof(uInt);
+var
+  zVersion,
+  myVersion : string;
+var
+  comprLen : uInt;
+  uncomprLen : uInt;
+begin
+  {$ifdef MemCheck}
+  MemChk;
+  {$endif}
+  comprLen := comprLenL;
+  uncomprLen := uncomprLenL;
+
+  myVersion := ZLIB_VERSION;
+  zVersion := zlibVersion;
+  if (zVersion[1] <> myVersion[1]) then
+  begin
+    WriteLn('incompatible zlib version');
+    Stop;
+  end
+  else
+    if (zVersion <> ZLIB_VERSION) then
+    begin
+      WriteLn('warning: different zlib version');
+    end;
+
+  GetMem(compr, comprLen*sizeof(uInt));
+  GetMem(uncompr, uncomprLen*sizeof(uInt));
+  { compr and uncompr are cleared to avoid reading uninitialized
+    data and to ensure that uncompr compresses well. }
+
+  if (compr = Z_NULL) or (uncompr = Z_NULL) then
+  begin
+    WriteLn('out of memory');
+    Stop;
+  end;
+  FillChar(compr^, comprLen*sizeof(uInt), 0);
+  FillChar(uncompr^, uncomprLen*sizeof(uInt), 0);
+
+  if (compr = Z_NULL) or (uncompr = Z_NULL) then
+  begin
+    WriteLn('out of memory');
+    Stop;
+  end;
+  {$IFDEF TEST_COMPRESS}
+  test_compress(compr, comprLenL, uncompr, uncomprLen);
+  {$ENDIF}
+
+  {$IFDEF TEST_GZIO}
+  Case ParamCount of
+    0:  test_gzio('foo.gz', 'foo.gz', uncompr, int(uncomprLen));
+    1:  test_gzio(ParamStr(1), 'foo.gz', uncompr, int(uncomprLen));
+  else
+    test_gzio(ParamStr(1), ParamStr(2), uncompr, int(uncomprLen));
+  end;
+  {$ENDIF}
+
+  {$IFDEF TEST_DEFLATE}
+  WriteLn('small buffer Deflate');
+  test_deflate(compr, comprLen);
+  {$ENDIF}
+  {$IFDEF TEST_INFLATE}
+  {$IFNDEF TEST_DEFLATE}
+  WriteLn('small buffer Inflate');
+  if GetFromFile(compr, 'u:\nomssi\paszlib\new\test0.z', comprLen) then
+  {$ENDIF}
+    test_inflate(compr, comprLen, uncompr, uncomprLen);
+  {$ENDIF}
+  readln;
+  {$IFDEF TEST_DEFLATE}
+  WriteLn('large buffer Deflate');
+  test_large_deflate(compr, comprLen, uncompr, uncomprLen);
+  {$ENDIF}
+  {$IFDEF TEST_INFLATE}
+  WriteLn('large buffer Inflate');
+  test_large_inflate(compr, comprLen, uncompr, uncomprLen);
+  {$ENDIF}
+  {$IFDEF TEST_FLUSH}
+  test_flush(compr, comprLenL);
+  {$ENDIF}
+  {$IFDEF TEST_SYNC}
+  test_sync(compr, comprLen, uncompr, uncomprLen);
+  {$ENDIF}
+  comprLen := uncomprLen;
+
+  {$IFDEF TEST_DICT}
+  test_dict_deflate(compr, comprLen);
+  test_dict_inflate(compr, comprLen, uncompr, uncomprLen);
+  {$ENDIF}
+  readln;
+  FreeMem(compr, comprLen*sizeof(uInt));
+  FreeMem(uncompr, uncomprLen*sizeof(uInt));
+end.

+ 237 - 0
packages/base/paszlib/gzcrc.pas

@@ -0,0 +1,237 @@
+Unit gzCrc;
+
+{
+  crc32.c -- compute the CRC-32 of a data stream
+  Copyright (C) 1995-1998 Mark Adler
+
+  Pascal tranlastion
+  Copyright (C) 1998 by Jacques Nomssi Nzali
+  For conditions of distribution and use, see copyright notice in readme.txt
+}
+
+interface
+
+{$I zconf.inc}
+
+uses
+  zutil, zbase;
+
+
+function crc32(crc : uLong; buf : pBytef; len : uInt) : uLong;
+
+{  Update a running crc with the bytes buf[0..len-1] and return the updated
+   crc. If buf is NULL, this function returns the required initial value
+   for the crc. Pre- and post-conditioning (one's complement) is performed
+   within this function so it shouldn't be done by the application.
+   Usage example:
+
+    var
+      crc : uLong;
+    begin
+      crc := crc32(0, Z_NULL, 0);
+
+      while (read_buffer(buffer, length) <> EOF) do
+        crc := crc32(crc, buffer, length);
+
+      if (crc <> original_crc) then error();
+    end;
+
+}
+
+function get_crc_table : pointer;  { can be used by asm versions of crc32() }
+
+
+implementation
+
+{$IFDEF DYNAMIC_CRC_TABLE}
+
+{local}
+const
+  crc_table_empty : boolean = TRUE;
+{local}
+var
+  crc_table : array[0..256-1] of uLongf;
+
+
+{
+  Generate a table for a byte-wise 32-bit CRC calculation on the polynomial:
+  x^32+x^26+x^23+x^22+x^16+x^12+x^11+x^10+x^8+x^7+x^5+x^4+x^2+x+1.
+
+  Polynomials over GF(2) are represented in binary, one bit per coefficient,
+  with the lowest powers in the most significant bit.  Then adding polynomials
+  is just exclusive-or, and multiplying a polynomial by x is a right shift by
+  one.  If we call the above polynomial p, and represent a byte as the
+  polynomial q, also with the lowest power in the most significant bit (so the
+  byte 0xb1 is the polynomial x^7+x^3+x+1), then the CRC is (q*x^32) mod p,
+  where a mod b means the remainder after dividing a by b.
+
+  This calculation is done using the shift-register method of multiplying and
+  taking the remainder.  The register is initialized to zero, and for each
+  incoming bit, x^32 is added mod p to the register if the bit is a one (where
+  x^32 mod p is p+x^32 = x^26+...+1), and the register is multiplied mod p by
+  x (which is shifting right by one and adding x^32 mod p if the bit shifted
+  out is a one).  We start with the highest power (least significant bit) of
+  q and repeat for all eight bits of q.
+
+  The table is simply the CRC of all possible eight bit values.  This is all
+  the information needed to generate CRC's on data a byte at a time for all
+  combinations of CRC register values and incoming bytes.
+}
+{local}
+procedure make_crc_table;
+var
+ c    : uLong;
+ n,k  : int;
+ poly : uLong; { polynomial exclusive-or pattern }
+
+const
+ { terms of polynomial defining this crc (except x^32): }
+ p: array [0..13] of Byte = (0,1,2,4,5,7,8,10,11,12,16,22,23,26);
+
+begin
+  { make exclusive-or pattern from polynomial ($EDB88320) }
+  poly := Long(0);
+  for n := 0 to (sizeof(p) div sizeof(Byte))-1 do
+    poly := poly or (Long(1) shl (31 - p[n]));
+
+  for n := 0 to 255 do
+  begin
+    c := uLong(n);
+    for k := 0 to 7 do
+    begin
+      if (c and 1) <> 0 then
+        c := poly xor (c shr 1)
+      else
+        c := (c shr 1);
+    end;
+    crc_table[n] := c;
+  end;
+  crc_table_empty := FALSE;
+end;
+
+{$ELSE}
+
+{ ========================================================================
+  Table of CRC-32's of all single-byte values (made by make_crc_table) }
+
+{local}
+const
+  crc_table : array[0..256-1] of uLongf = (
+  $00000000, $77073096, $ee0e612c, $990951ba, $076dc419,
+  $706af48f, $e963a535, $9e6495a3, $0edb8832, $79dcb8a4,
+  $e0d5e91e, $97d2d988, $09b64c2b, $7eb17cbd, $e7b82d07,
+  $90bf1d91, $1db71064, $6ab020f2, $f3b97148, $84be41de,
+  $1adad47d, $6ddde4eb, $f4d4b551, $83d385c7, $136c9856,
+  $646ba8c0, $fd62f97a, $8a65c9ec, $14015c4f, $63066cd9,
+  $fa0f3d63, $8d080df5, $3b6e20c8, $4c69105e, $d56041e4,
+  $a2677172, $3c03e4d1, $4b04d447, $d20d85fd, $a50ab56b,
+  $35b5a8fa, $42b2986c, $dbbbc9d6, $acbcf940, $32d86ce3,
+  $45df5c75, $dcd60dcf, $abd13d59, $26d930ac, $51de003a,
+  $c8d75180, $bfd06116, $21b4f4b5, $56b3c423, $cfba9599,
+  $b8bda50f, $2802b89e, $5f058808, $c60cd9b2, $b10be924,
+  $2f6f7c87, $58684c11, $c1611dab, $b6662d3d, $76dc4190,
+  $01db7106, $98d220bc, $efd5102a, $71b18589, $06b6b51f,
+  $9fbfe4a5, $e8b8d433, $7807c9a2, $0f00f934, $9609a88e,
+  $e10e9818, $7f6a0dbb, $086d3d2d, $91646c97, $e6635c01,
+  $6b6b51f4, $1c6c6162, $856530d8, $f262004e, $6c0695ed,
+  $1b01a57b, $8208f4c1, $f50fc457, $65b0d9c6, $12b7e950,
+  $8bbeb8ea, $fcb9887c, $62dd1ddf, $15da2d49, $8cd37cf3,
+  $fbd44c65, $4db26158, $3ab551ce, $a3bc0074, $d4bb30e2,
+  $4adfa541, $3dd895d7, $a4d1c46d, $d3d6f4fb, $4369e96a,
+  $346ed9fc, $ad678846, $da60b8d0, $44042d73, $33031de5,
+  $aa0a4c5f, $dd0d7cc9, $5005713c, $270241aa, $be0b1010,
+  $c90c2086, $5768b525, $206f85b3, $b966d409, $ce61e49f,
+  $5edef90e, $29d9c998, $b0d09822, $c7d7a8b4, $59b33d17,
+  $2eb40d81, $b7bd5c3b, $c0ba6cad, $edb88320, $9abfb3b6,
+  $03b6e20c, $74b1d29a, $ead54739, $9dd277af, $04db2615,
+  $73dc1683, $e3630b12, $94643b84, $0d6d6a3e, $7a6a5aa8,
+  $e40ecf0b, $9309ff9d, $0a00ae27, $7d079eb1, $f00f9344,
+  $8708a3d2, $1e01f268, $6906c2fe, $f762575d, $806567cb,
+  $196c3671, $6e6b06e7, $fed41b76, $89d32be0, $10da7a5a,
+  $67dd4acc, $f9b9df6f, $8ebeeff9, $17b7be43, $60b08ed5,
+  $d6d6a3e8, $a1d1937e, $38d8c2c4, $4fdff252, $d1bb67f1,
+  $a6bc5767, $3fb506dd, $48b2364b, $d80d2bda, $af0a1b4c,
+  $36034af6, $41047a60, $df60efc3, $a867df55, $316e8eef,
+  $4669be79, $cb61b38c, $bc66831a, $256fd2a0, $5268e236,
+  $cc0c7795, $bb0b4703, $220216b9, $5505262f, $c5ba3bbe,
+  $b2bd0b28, $2bb45a92, $5cb36a04, $c2d7ffa7, $b5d0cf31,
+  $2cd99e8b, $5bdeae1d, $9b64c2b0, $ec63f226, $756aa39c,
+  $026d930a, $9c0906a9, $eb0e363f, $72076785, $05005713,
+  $95bf4a82, $e2b87a14, $7bb12bae, $0cb61b38, $92d28e9b,
+  $e5d5be0d, $7cdcefb7, $0bdbdf21, $86d3d2d4, $f1d4e242,
+  $68ddb3f8, $1fda836e, $81be16cd, $f6b9265b, $6fb077e1,
+  $18b74777, $88085ae6, $ff0f6a70, $66063bca, $11010b5c,
+  $8f659eff, $f862ae69, $616bffd3, $166ccf45, $a00ae278,
+  $d70dd2ee, $4e048354, $3903b3c2, $a7672661, $d06016f7,
+  $4969474d, $3e6e77db, $aed16a4a, $d9d65adc, $40df0b66,
+  $37d83bf0, $a9bcae53, $debb9ec5, $47b2cf7f, $30b5ffe9,
+  $bdbdf21c, $cabac28a, $53b39330, $24b4a3a6, $bad03605,
+  $cdd70693, $54de5729, $23d967bf, $b3667a2e, $c4614ab8,
+  $5d681b02, $2a6f2b94, $b40bbe37, $c30c8ea1, $5a05df1b,
+  $2d02ef8d);
+
+{$ENDIF}
+
+{ =========================================================================
+  This function can be used by asm versions of crc32() }
+
+function get_crc_table : {const} pointer;
+begin
+{$ifdef DYNAMIC_CRC_TABLE}
+  if (crc_table_empty) then
+    make_crc_table;
+{$endif}
+  get_crc_table :=  {const} pointer(@crc_table);
+end;
+
+{ ========================================================================= }
+
+function crc32 (crc : uLong; buf : pBytef; len : uInt): uLong;
+begin
+  if (buf = Z_NULL) then
+    crc32 := Long(0)
+  else
+  begin
+
+{$IFDEF DYNAMIC_CRC_TABLE}
+    if crc_table_empty then
+      make_crc_table;
+{$ENDIF}
+
+    crc := crc xor ULong($ffffffff);
+    while (len >= 8) do
+    begin
+      {DO8(buf)}
+      crc := crc_table[(int(crc) xor buf^) and $ff] xor (crc shr 8);
+      inc(buf);
+      crc := crc_table[(int(crc) xor buf^) and $ff] xor (crc shr 8);
+      inc(buf);
+      crc := crc_table[(int(crc) xor buf^) and $ff] xor (crc shr 8);
+      inc(buf);
+      crc := crc_table[(int(crc) xor buf^) and $ff] xor (crc shr 8);
+      inc(buf);
+      crc := crc_table[(int(crc) xor buf^) and $ff] xor (crc shr 8);
+      inc(buf);
+      crc := crc_table[(int(crc) xor buf^) and $ff] xor (crc shr 8);
+      inc(buf);
+      crc := crc_table[(int(crc) xor buf^) and $ff] xor (crc shr 8);
+      inc(buf);
+      crc := crc_table[(int(crc) xor buf^) and $ff] xor (crc shr 8);
+      inc(buf);
+
+      Dec(len, 8);
+    end;
+    if (len <> 0) then
+    repeat
+      {DO1(buf)}
+      crc := crc_table[(int(crc) xor buf^) and $ff] xor (crc shr 8);
+      inc(buf);
+
+      Dec(len);
+    until (len = 0);
+    crc32 := crc xor ULong($ffffffff);
+  end;
+end;
+
+
+end.

+ 1192 - 0
packages/base/paszlib/gzio.pas

@@ -0,0 +1,1192 @@
+Unit gzIO;
+
+{
+  Pascal unit based on gzio.c -- IO on .gz files
+  Copyright (C) 1995-1998 Jean-loup Gailly.
+
+  Define NO_DEFLATE to compile this file without the compression code
+
+  Pascal tranlastion based on code contributed by Francisco Javier Crespo
+  Copyright (C) 1998 by Jacques Nomssi Nzali
+  For conditions of distribution and use, see copyright notice in readme.txt
+}
+
+interface
+
+{$I zconf.inc}
+
+uses
+  {$ifdef MSDOS}
+  dos, strings,
+  {$else}
+  SysUtils,
+  {$endif}
+  zutil, zbase, gzcrc, zdeflate, zinflate;
+
+type gzFile = voidp;
+type z_off_t = long;
+
+function gzopen  (path:string; mode:string) : gzFile;
+function gzsetparams (f:gzfile; level:int; strategy:int) : int;
+function gzread  (f:gzFile; buf:voidp; len:uInt) : int;
+function gzgetc  (f:gzfile) : int;
+function gzgets  (f:gzfile; buf:PChar; len:int) : PChar;
+
+{$ifndef NO_DEFLATE}
+function gzwrite (f:gzFile; buf:voidp; len:uInt) : int;
+function gzputc  (f:gzfile; c:char) : int;
+function gzputs  (f:gzfile; s:PChar) : int;
+function gzflush (f:gzFile; flush:int)           : int;
+  {$ifdef GZ_FORMAT_STRING}
+  function gzprintf (zfile : gzFile;
+                     const format : string;
+                     a : array of int);    { doesn't compile }
+  {$endif}
+{$endif}
+
+function gzseek   (f:gzfile; offset:z_off_t; whence:int) : z_off_t;
+function gzrewind (f:gzFile) : int;
+function gztell   (f:gzfile) : z_off_t;
+function gzeof    (f:gzfile) : boolean;
+function gzclose  (f:gzFile)                      : int;
+function gzerror  (f:gzFile; var errnum:Int)      : string;
+
+const
+  SEEK_SET {: z_off_t} = 0; { seek from beginning of file }
+  SEEK_CUR {: z_off_t} = 1; { seek from current position }
+  SEEK_END {: z_off_t} = 2;
+
+implementation
+
+const
+  Z_EOF = -1;         { same value as in STDIO.H }
+  Z_BUFSIZE = 16384;
+  { Z_PRINTF_BUFSIZE = 4096; }
+
+
+  gz_magic : array[0..1] of byte = ($1F, $8B); { gzip magic header }
+
+  { gzip flag byte }
+
+  ASCII_FLAG  = $01; { bit 0 set: file probably ascii text }
+  HEAD_CRC    = $02; { bit 1 set: header CRC present }
+  EXTRA_FIELD = $04; { bit 2 set: extra field present }
+  ORIG_NAME   = $08; { bit 3 set: original file name present }
+  COMMENT     = $10; { bit 4 set: file comment present }
+  RESERVED    = $E0; { bits 5..7: reserved }
+
+type gz_stream = record
+  stream      : z_stream;
+  z_err       : int;      { error code for last stream operation }
+  z_eof       : boolean;  { set if end of input file }
+  gzfile      : file;     { .gz file }
+  inbuf       : pBytef;   { input buffer }
+  outbuf      : pBytef;   { output buffer }
+  crc         : uLong;    { crc32 of uncompressed data }
+  msg,                    { error message - limit 79 chars }
+  path        : string[79];   { path name for debugging only - limit 79 chars }
+  transparent : boolean;  { true if input file is not a .gz file }
+  mode        : char;     { 'w' or 'r' }
+  startpos    : long;     { start of compressed data in file (header skipped) }
+end;
+
+type gz_streamp = ^gz_stream;
+
+function destroy (var s:gz_streamp) : int; forward;
+procedure check_header(s:gz_streamp); forward;
+
+
+{ GZOPEN ====================================================================
+
+  Opens a gzip (.gz) file for reading or writing. As Pascal does not use
+  file descriptors, the code has been changed to accept only path names.
+
+  The mode parameter defaults to BINARY read or write operations ('r' or 'w')
+  but can also include a compression level ('w9') or a strategy: Z_FILTERED
+  as in 'w6f' or Z_HUFFMAN_ONLY as in 'w1h'. (See the description of
+  deflateInit2 for more information about the strategy parameter.)
+
+  gzopen can be used to open a file which is not in gzip format; in this
+  case, gzread will directly read from the file without decompression.
+
+  gzopen returns NIL if the file could not be opened (non-zero IOResult)
+  or if there was insufficient memory to allocate the (de)compression state
+  (zlib error is Z_MEM_ERROR).
+
+============================================================================}
+
+function gzopen (path:string; mode:string) : gzFile;
+
+var
+
+  i        : uInt;
+  err      : int;
+  level    : int;        { compression level }
+  strategy : int;        { compression strategy }
+  s        : gz_streamp;
+{$IFDEF MSDOS}
+  attr     : word;       { file attributes }
+{$ENDIF}
+
+{$IFNDEF NO_DEFLATE}
+  gzheader : array [0..9] of byte;
+{$ENDIF}
+
+begin
+
+  if (path='') or (mode='') then begin
+    gzopen := Z_NULL;
+    exit;
+  end;
+
+  GetMem (s,sizeof(gz_stream));
+  if not Assigned (s) then begin
+    gzopen := Z_NULL;
+    exit;
+  end;
+
+  level := Z_DEFAULT_COMPRESSION;
+  strategy := Z_DEFAULT_STRATEGY;
+
+  s^.stream.zalloc := NIL;     { (alloc_func)0 }
+  s^.stream.zfree := NIL;      { (free_func)0 }
+  s^.stream.opaque := NIL;     { (voidpf)0 }
+  s^.stream.next_in := Z_NULL;
+  s^.stream.next_out := Z_NULL;
+  s^.stream.avail_in := 0;
+  s^.stream.avail_out := 0;
+  s^.z_err := Z_OK;
+  s^.z_eof := false;
+  s^.inbuf := Z_NULL;
+  s^.outbuf := Z_NULL;
+  s^.crc := crc32(0, Z_NULL, 0);
+  s^.msg := '';
+  s^.transparent := false;
+
+  s^.path := path; { limit to 255 chars }
+
+  s^.mode := chr(0);
+  for i:=1 to Length(mode) do begin
+    case mode[i] of
+      'r'      : s^.mode := 'r';
+      'w'      : s^.mode := 'w';
+      '0'..'9' : level := Ord(mode[i])-Ord('0');
+      'f'      : strategy := Z_FILTERED;
+      'h'      : strategy := Z_HUFFMAN_ONLY;
+    end;
+  end;
+  if (s^.mode=chr(0)) then begin
+    destroy(s);
+    gzopen := gzFile(Z_NULL);
+    exit;
+  end;
+
+  if (s^.mode='w') then begin
+{$IFDEF NO_DEFLATE}
+    err := Z_STREAM_ERROR;
+{$ELSE}
+    err := deflateInit2 (s^.stream, level, Z_DEFLATED, -MAX_WBITS,
+                         DEF_MEM_LEVEL, strategy);
+        { windowBits is passed < 0 to suppress zlib header }
+
+    GetMem (s^.outbuf, Z_BUFSIZE);
+    s^.stream.next_out := s^.outbuf;
+{$ENDIF}
+    if (err <> Z_OK) or (s^.outbuf = Z_NULL) then begin
+      destroy(s);
+      gzopen := gzFile(Z_NULL);
+      exit;
+    end;
+  end
+
+  else begin
+    GetMem (s^.inbuf, Z_BUFSIZE);
+    s^.stream.next_in := s^.inbuf;
+
+    err := inflateInit2_ (s^.stream, -MAX_WBITS, ZLIB_VERSION, sizeof(z_stream));
+        { windowBits is passed < 0 to tell that there is no zlib header }
+
+    if (err <> Z_OK) or (s^.inbuf = Z_NULL) then begin
+      destroy(s);
+      gzopen := gzFile(Z_NULL);
+      exit;
+    end;
+  end;
+
+  s^.stream.avail_out := Z_BUFSIZE;
+
+  {$IFOPT I+} {$I-} {$define IOcheck} {$ENDIF}
+  Assign (s^.gzfile, s^.path);
+  {$ifdef MSDOS}
+  GetFAttr(s^.gzfile, Attr);
+  if (DosError <> 0) and (s^.mode='w') then
+    ReWrite (s^.gzfile,1)
+  else
+    Reset (s^.gzfile,1);
+  {$else}
+  if (not FileExists(s^.path)) and (s^.mode='w') then
+    ReWrite (s^.gzfile,1)
+  else
+    Reset (s^.gzfile,1);
+  {$endif}
+  {$IFDEF IOCheck} {$I+} {$ENDIF}
+  if (IOResult <> 0) then begin
+    destroy(s);
+    gzopen := gzFile(Z_NULL);
+    exit;
+  end;
+
+  if (s^.mode = 'w') then begin { Write a very simple .gz header }
+{$IFNDEF NO_DEFLATE}
+    gzheader [0] := gz_magic [0];
+    gzheader [1] := gz_magic [1];
+    gzheader [2] := Z_DEFLATED;   { method }
+    gzheader [3] := 0;            { flags }
+    gzheader [4] := 0;            { time[0] }
+    gzheader [5] := 0;            { time[1] }
+    gzheader [6] := 0;            { time[2] }
+    gzheader [7] := 0;            { time[3] }
+    gzheader [8] := 0;            { xflags }
+    gzheader [9] := 0;            { OS code = MS-DOS }
+    blockwrite (s^.gzfile, gzheader, 10);
+    s^.startpos := LONG(10);
+{$ENDIF}
+  end
+  else begin
+    check_header(s); { skip the .gz header }
+    s^.startpos := FilePos(s^.gzfile) - s^.stream.avail_in;
+  end;
+
+  gzopen := gzFile(s);
+end;
+
+
+{ GZSETPARAMS ===============================================================
+
+  Update the compression level and strategy.
+
+============================================================================}
+
+function gzsetparams (f:gzfile; level:int; strategy:int) : int;
+
+var
+
+  s : gz_streamp;
+  written: integer;
+
+begin
+
+  s := gz_streamp(f);
+
+  if (s = NIL) or (s^.mode <> 'w') then begin
+    gzsetparams := Z_STREAM_ERROR;
+    exit;
+  end;
+
+  { Make room to allow flushing }
+  if (s^.stream.avail_out = 0) then begin
+    s^.stream.next_out := s^.outbuf;
+    blockwrite(s^.gzfile, s^.outbuf^, Z_BUFSIZE, written);
+    if (written <> Z_BUFSIZE) then s^.z_err := Z_ERRNO;
+    s^.stream.avail_out := Z_BUFSIZE;
+  end;
+
+  gzsetparams := deflateParams (s^.stream, level, strategy);
+end;
+
+
+{ GET_BYTE ==================================================================
+
+  Read a byte from a gz_stream. Updates next_in and avail_in.
+  Returns EOF for end of file.
+  IN assertion: the stream s has been sucessfully opened for reading.
+
+============================================================================}
+
+function get_byte (s:gz_streamp) : int;
+
+begin
+
+  if (s^.z_eof = true) then begin
+    get_byte := Z_EOF;
+    exit;
+  end;
+
+  if (s^.stream.avail_in = 0) then begin
+    {$I-}
+    blockread (s^.gzfile, s^.inbuf^, Z_BUFSIZE, Int(s^.stream.avail_in));
+    {$I+}
+    if (s^.stream.avail_in = 0) then begin
+      s^.z_eof := true;
+      if (IOResult <> 0) then s^.z_err := Z_ERRNO;
+      get_byte := Z_EOF;
+      exit;
+    end;
+    s^.stream.next_in := s^.inbuf;
+  end;
+
+  Dec(s^.stream.avail_in);
+  get_byte := s^.stream.next_in^;
+  Inc(s^.stream.next_in);
+
+end;
+
+
+{ GETLONG ===================================================================
+
+   Reads a Longint in LSB order from the given gz_stream.
+
+============================================================================}
+{
+function getLong (s:gz_streamp) : uLong;
+var
+  x  : array [0..3] of byte;
+  i  : byte;
+  c  : int;
+  n1 : longint;
+  n2 : longint;
+begin
+
+  for i:=0 to 3 do begin
+    c := get_byte(s);
+    if (c = Z_EOF) then s^.z_err := Z_DATA_ERROR;
+    x[i] := (c and $FF)
+  end;
+  n1 := (ush(x[3] shl 8)) or x[2];
+  n2 := (ush(x[1] shl 8)) or x[0];
+  getlong := (n1 shl 16) or n2;
+end;
+}
+function getLong(s : gz_streamp) : uLong;
+var
+  x : packed array [0..3] of byte;
+  c : int;
+begin
+  { x := uLong(get_byte(s));  - you can't do this with TP, no unsigned long }
+  { the following assumes a little endian machine and TP }
+  x[0] := Byte(get_byte(s));
+  x[1] := Byte(get_byte(s));
+  x[2] := Byte(get_byte(s));
+  c := get_byte(s);
+  x[3] := Byte(c);
+  if (c = Z_EOF) then
+    s^.z_err := Z_DATA_ERROR;
+  GetLong := uLong(longint(x));
+end;
+
+
+{ CHECK_HEADER ==============================================================
+
+  Check the gzip header of a gz_stream opened for reading.
+  Set the stream mode to transparent if the gzip magic header is not present.
+  Set s^.err  to Z_DATA_ERROR if the magic header is present but the rest of
+  the header is incorrect.
+
+  IN assertion: the stream s has already been created sucessfully;
+  s^.stream.avail_in is zero for the first time, but may be non-zero
+  for concatenated .gz files
+
+============================================================================}
+
+procedure check_header (s:gz_streamp);
+
+var
+
+  method : int;  { method byte }
+  flags  : int;  { flags byte }
+  len    : uInt;
+  c      : int;
+
+begin
+
+  { Check the gzip magic header }
+  for len := 0 to 1 do begin
+    c := get_byte(s);
+    if (c <> gz_magic[len]) then begin
+      if (len <> 0) then begin
+        Inc(s^.stream.avail_in);
+        Dec(s^.stream.next_in);
+      end;
+      if (c <> Z_EOF) then begin
+        Inc(s^.stream.avail_in);
+        Dec(s^.stream.next_in);
+        s^.transparent := TRUE;
+      end;
+      if (s^.stream.avail_in <> 0) then s^.z_err := Z_OK
+      else s^.z_err := Z_STREAM_END;
+      exit;
+    end;
+  end;
+
+  method := get_byte(s);
+  flags := get_byte(s);
+  if (method <> Z_DEFLATED) or ((flags and RESERVED) <> 0) then begin
+    s^.z_err := Z_DATA_ERROR;
+    exit;
+  end;
+
+  for len := 0 to 5 do get_byte(s); { Discard time, xflags and OS code }
+
+  if ((flags and EXTRA_FIELD) <> 0) then begin { skip the extra field }
+    len := uInt(get_byte(s));
+    len := len + (uInt(get_byte(s)) shr 8);
+    { len is garbage if EOF but the loop below will quit anyway }
+    while (len <> 0) and (get_byte(s) <> Z_EOF) do Dec(len);
+  end;
+
+  if ((flags and ORIG_NAME) <> 0) then begin { skip the original file name }
+    repeat
+      c := get_byte(s);
+    until (c = 0) or (c = Z_EOF);
+  end;
+
+  if ((flags and COMMENT) <> 0) then begin { skip the .gz file comment }
+    repeat
+      c := get_byte(s);
+    until (c = 0) or (c = Z_EOF);
+  end;
+
+  if ((flags and HEAD_CRC) <> 0) then begin { skip the header crc }
+    get_byte(s);
+    get_byte(s);
+  end;
+
+  if (s^.z_eof = true) then
+    s^.z_err := Z_DATA_ERROR
+  else
+    s^.z_err := Z_OK;
+
+end;
+
+
+{ DESTROY ===================================================================
+
+  Cleanup then free the given gz_stream. Return a zlib error code.
+  Try freeing in the reverse order of allocations.
+
+============================================================================}
+
+function destroy (var s:gz_streamp) : int;
+
+begin
+
+  destroy := Z_OK;
+
+  if not Assigned (s) then begin
+    destroy := Z_STREAM_ERROR;
+    exit;
+  end;
+
+  if (s^.stream.state <> NIL) then begin
+    if (s^.mode = 'w') then begin
+{$IFDEF NO_DEFLATE}
+      destroy := Z_STREAM_ERROR;
+{$ELSE}
+      destroy := deflateEnd(s^.stream);
+{$ENDIF}
+    end
+    else if (s^.mode = 'r') then begin
+      destroy := inflateEnd(s^.stream);
+    end;
+  end;
+
+  if (s^.path <> '') then begin
+    {$I-}
+    close(s^.gzfile);
+    {$I+}
+    if (IOResult <> 0) then destroy := Z_ERRNO;
+  end;
+
+  if (s^.z_err < 0) then destroy := s^.z_err;
+
+  if Assigned (s^.inbuf) then
+    FreeMem(s^.inbuf, Z_BUFSIZE);
+  if Assigned (s^.outbuf) then
+    FreeMem(s^.outbuf, Z_BUFSIZE);
+  FreeMem(s, sizeof(gz_stream));
+
+end;
+
+
+{ GZREAD ====================================================================
+
+  Reads the given number of uncompressed bytes from the compressed file.
+  If the input file was not in gzip format, gzread copies the given number
+  of bytes into the buffer.
+
+  gzread returns the number of uncompressed bytes actually read
+  (0 for end of file, -1 for error).
+
+============================================================================}
+
+function gzread (f:gzFile; buf:voidp; len:uInt) : int;
+
+var
+
+  s         : gz_streamp;
+  start     : pBytef;
+  next_out  : pBytef;
+  n         : uInt;
+  crclen    : uInt;  { Buffer length to update CRC32 }
+  filecrc   : uLong; { CRC32 stored in GZIP'ed file }
+  filelen   : uLong; { Total lenght of uncompressed file }
+  bytes     : integer;  { bytes actually read in I/O blockread }
+  total_in  : uLong;
+  total_out : uLong;
+
+begin
+
+  s := gz_streamp(f);
+  start := pBytef(buf); { starting point for crc computation }
+
+  if (s = NIL) or (s^.mode <> 'r') then begin
+    gzread := Z_STREAM_ERROR;
+    exit;
+  end;
+
+  if (s^.z_err = Z_DATA_ERROR) or (s^.z_err = Z_ERRNO) then begin
+    gzread := -1;
+    exit;
+  end;
+
+  if (s^.z_err = Z_STREAM_END) then begin
+    gzread := 0;  { EOF }
+    exit;
+  end;
+
+  s^.stream.next_out := pBytef(buf);
+  s^.stream.avail_out := len;
+
+  while (s^.stream.avail_out <> 0) do begin
+
+    if (s^.transparent = true) then begin
+      { Copy first the lookahead bytes: }
+      n := s^.stream.avail_in;
+      if (n > s^.stream.avail_out) then n := s^.stream.avail_out;
+      if (n > 0) then begin
+        zmemcpy(s^.stream.next_out, s^.stream.next_in, n);
+        inc (s^.stream.next_out, n);
+        inc (s^.stream.next_in, n);
+        dec (s^.stream.avail_out, n);
+        dec (s^.stream.avail_in, n);
+      end;
+      if (s^.stream.avail_out > 0) then begin
+        blockread (s^.gzfile, s^.stream.next_out^, s^.stream.avail_out, bytes);
+        dec (s^.stream.avail_out, uInt(bytes));
+      end;
+      dec (len, s^.stream.avail_out);
+      inc (s^.stream.total_in, uLong(len));
+      inc (s^.stream.total_out, uLong(len));
+      gzread := int(len);
+      exit;
+    end; { IF transparent }
+
+    if (s^.stream.avail_in = 0) and (s^.z_eof = false) then begin
+      {$I-}
+      blockread (s^.gzfile, s^.inbuf^, Z_BUFSIZE, Int(s^.stream.avail_in));
+      {$I+}
+      if (s^.stream.avail_in = 0) then begin
+        s^.z_eof := true;
+        if (IOResult <> 0) then begin
+          s^.z_err := Z_ERRNO;
+          break;
+        end;
+      end;
+      s^.stream.next_in := s^.inbuf;
+    end;
+
+    s^.z_err := inflate(s^.stream, Z_NO_FLUSH);
+
+    if (s^.z_err = Z_STREAM_END) then begin
+      crclen := 0;
+      next_out := s^.stream.next_out;
+      while (next_out <> start ) do begin
+        dec (next_out);
+        inc (crclen);   { Hack because Pascal cannot substract pointers }
+      end;
+      { Check CRC and original size }
+      s^.crc := crc32(s^.crc, start, crclen);
+      start := s^.stream.next_out;
+
+      filecrc := getLong (s);
+      filelen := getLong (s);
+
+      if (s^.crc <> filecrc) or (s^.stream.total_out <> filelen)
+        then s^.z_err := Z_DATA_ERROR
+        else begin
+          { Check for concatenated .gz files: }
+          check_header(s);
+          if (s^.z_err = Z_OK) then begin
+            total_in := s^.stream.total_in;
+            total_out := s^.stream.total_out;
+
+            inflateReset (s^.stream);
+            s^.stream.total_in := total_in;
+            s^.stream.total_out := total_out;
+            s^.crc := crc32 (0, Z_NULL, 0);
+          end;
+      end; {IF-THEN-ELSE}
+    end;
+
+    if (s^.z_err <> Z_OK) or (s^.z_eof = true) then break;
+
+  end; {WHILE}
+
+  crclen := 0;
+  next_out := s^.stream.next_out;
+  while (next_out <> start ) do begin
+    dec (next_out);
+    inc (crclen);   { Hack because Pascal cannot substract pointers }
+  end;
+  s^.crc := crc32 (s^.crc, start, crclen);
+
+  gzread := int(len - s^.stream.avail_out);
+
+end;
+
+
+{ GZGETC ====================================================================
+
+  Reads one byte from the compressed file.
+  gzgetc returns this byte or -1 in case of end of file or error.
+
+============================================================================}
+
+function gzgetc (f:gzfile) : int;
+
+var c:byte;
+
+begin
+
+  if (gzread (f,@c,1) = 1) then gzgetc := c else gzgetc := -1;
+
+end;
+
+
+{ GZGETS ====================================================================
+
+  Reads bytes from the compressed file until len-1 characters are read,
+  or a newline character is read and transferred to buf, or an end-of-file
+  condition is encountered. The string is then Null-terminated.
+
+  gzgets returns buf, or Z_NULL in case of error.
+  The current implementation is not optimized at all.
+
+============================================================================}
+
+function gzgets (f:gzfile; buf:PChar; len:int) : PChar;
+
+var
+
+  b      : PChar; { start of buffer }
+  bytes  : Int;   { number of bytes read by gzread }
+  gzchar : char;  { char read by gzread }
+
+begin
+
+    if (buf = Z_NULL) or (len <= 0) then begin
+      gzgets := Z_NULL;
+      exit;
+    end;
+
+    b := buf;
+    repeat
+      dec (len);
+      bytes := gzread (f, buf, 1);
+      gzchar := buf^;
+      inc (buf);
+    until (len = 0) or (bytes <> 1) or (gzchar = Chr(13));
+
+    buf^ := Chr(0);
+    if (b = buf) and (len > 0) then gzgets := Z_NULL else gzgets := b;
+
+end;
+
+
+{$IFNDEF NO_DEFLATE}
+
+{ GZWRITE ===================================================================
+
+  Writes the given number of uncompressed bytes into the compressed file.
+  gzwrite returns the number of uncompressed bytes actually written
+  (0 in case of error).
+
+============================================================================}
+
+function gzwrite (f:gzfile; buf:voidp; len:uInt) : int;
+
+var
+
+  s : gz_streamp;
+  written : integer;
+
+begin
+
+    s := gz_streamp(f);
+
+    if (s = NIL) or (s^.mode <> 'w') then begin
+      gzwrite := Z_STREAM_ERROR;
+      exit;
+    end;
+
+    s^.stream.next_in := pBytef(buf);
+    s^.stream.avail_in := len;
+
+    while (s^.stream.avail_in <> 0) do begin
+
+      if (s^.stream.avail_out = 0) then begin
+        s^.stream.next_out := s^.outbuf;
+        blockwrite (s^.gzfile, s^.outbuf^, Z_BUFSIZE, written);
+        if (written <> Z_BUFSIZE) then begin
+          s^.z_err := Z_ERRNO;
+          break;
+        end;
+        s^.stream.avail_out := Z_BUFSIZE;
+      end;
+
+      s^.z_err := deflate(s^.stream, Z_NO_FLUSH);
+      if (s^.z_err <> Z_OK) then break;
+
+    end; {WHILE}
+
+    s^.crc := crc32(s^.crc, buf, len);
+    gzwrite := int(len - s^.stream.avail_in);
+
+end;
+
+
+{ ===========================================================================
+   Converts, formats, and writes the args to the compressed file under
+   control of the format string, as in fprintf. gzprintf returns the number of
+   uncompressed bytes actually written (0 in case of error).
+}
+
+{$IFDEF GZ_FORMAT_STRING}
+function gzprintf (zfile : gzFile;
+                   const format : string;
+                   a : array of int) : int;
+var
+  buf : array[0..Z_PRINTF_BUFSIZE-1] of char;
+  len : int;
+begin
+{$ifdef HAS_snprintf}
+    snprintf(buf, sizeof(buf), format, a1, a2, a3, a4, a5, a6, a7, a8,
+             a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20);
+{$else}
+    sprintf(buf, format, a1, a2, a3, a4, a5, a6, a7, a8,
+            a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20);
+{$endif}
+    len := strlen(buf); { old sprintf doesn't return the nb of bytes written }
+    if (len <= 0) return 0;
+
+    gzprintf := gzwrite(file, buf, len);
+end;
+{$ENDIF}
+
+
+{ GZPUTC ====================================================================
+
+  Writes c, converted to an unsigned char, into the compressed file.
+  gzputc returns the value that was written, or -1 in case of error.
+
+============================================================================}
+
+function gzputc (f:gzfile; c:char) : int;
+begin
+  if (gzwrite (f,@c,1) = 1) then
+  {$IFDEF FPC}
+    gzputc := int(ord(c))
+  {$ELSE}
+    gzputc := int(c)
+  {$ENDIF}
+  else
+    gzputc := -1;
+end;
+
+
+{ GZPUTS ====================================================================
+
+  Writes the given null-terminated string to the compressed file, excluding
+  the terminating null character.
+  gzputs returns the number of characters written, or -1 in case of error.
+
+============================================================================}
+
+function gzputs (f:gzfile; s:PChar) : int;
+begin
+  gzputs := gzwrite (f, voidp(s), strlen(s));
+end;
+
+
+{ DO_FLUSH ==================================================================
+
+  Flushes all pending output into the compressed file.
+  The parameter flush is as in the zdeflate() function.
+
+============================================================================}
+
+function do_flush (f:gzfile; flush:int) : int;
+var
+  len     : uInt;
+  done    : boolean;
+  s       : gz_streamp;
+  written : integer;
+begin
+  done := false;
+  s := gz_streamp(f);
+
+  if (s = NIL) or (s^.mode <> 'w') then begin
+    do_flush := Z_STREAM_ERROR;
+    exit;
+  end;
+
+  s^.stream.avail_in := 0; { should be zero already anyway }
+
+  while true do begin
+
+    len := Z_BUFSIZE - s^.stream.avail_out;
+
+    if (len <> 0) then begin
+      {$I-}
+      blockwrite(s^.gzfile, s^.outbuf^, len, written);
+      {$I+}
+      if (written <> len) then begin
+        s^.z_err := Z_ERRNO;
+        do_flush := Z_ERRNO;
+        exit;
+      end;
+      s^.stream.next_out := s^.outbuf;
+      s^.stream.avail_out := Z_BUFSIZE;
+    end;
+
+    if (done = true) then break;
+    s^.z_err := deflate(s^.stream, flush);
+
+    { Ignore the second of two consecutive flushes: }
+    if (len = 0) and (s^.z_err = Z_BUF_ERROR) then s^.z_err := Z_OK;
+
+    { deflate has finished flushing only when it hasn't used up
+      all the available space in the output buffer: }
+
+    done := (s^.stream.avail_out <> 0) or (s^.z_err = Z_STREAM_END);
+    if (s^.z_err <> Z_OK) and (s^.z_err <> Z_STREAM_END) then break;
+
+  end; {WHILE}
+
+  if (s^.z_err = Z_STREAM_END) then do_flush:=Z_OK else do_flush:=s^.z_err;
+end;
+
+{ GZFLUSH ===================================================================
+
+  Flushes all pending output into the compressed file.
+  The parameter flush is as in the zdeflate() function.
+
+  The return value is the zlib error number (see function gzerror below).
+  gzflush returns Z_OK if the flush parameter is Z_FINISH and all output
+  could be flushed.
+
+  gzflush should be called only when strictly necessary because it can
+  degrade compression.
+
+============================================================================}
+
+function gzflush (f:gzfile; flush:int) : int;
+var
+  err : int;
+  s   : gz_streamp;
+begin
+  s := gz_streamp(f);
+  err := do_flush (f, flush);
+
+  if (err <> 0) then begin
+    gzflush := err;
+    exit;
+  end;
+
+  if (s^.z_err = Z_STREAM_END) then gzflush := Z_OK else gzflush := s^.z_err;
+end;
+
+{$ENDIF} (* NO DEFLATE *)
+
+
+{ GZREWIND ==================================================================
+
+  Rewinds input file.
+
+============================================================================}
+
+function gzrewind (f:gzFile) : int;
+var
+  s:gz_streamp;
+begin
+  s := gz_streamp(f);
+
+  if (s = NIL) or (s^.mode <> 'r') then begin
+    gzrewind := -1;
+    exit;
+  end;
+
+  s^.z_err := Z_OK;
+  s^.z_eof := false;
+  s^.stream.avail_in := 0;
+  s^.stream.next_in := s^.inbuf;
+
+  if (s^.startpos = 0) then begin { not a compressed file }
+    {$I-}
+    seek (s^.gzfile, 0);
+    {$I+}
+    gzrewind := 0;
+    exit;
+  end;
+
+  inflateReset(s^.stream);
+  {$I-}
+  seek (s^.gzfile, s^.startpos);
+  {$I+}
+  gzrewind := int(IOResult);
+  exit;
+end;
+
+
+{ GZSEEK ====================================================================
+
+  Sets the starting position for the next gzread or gzwrite on the given
+  compressed file. The offset represents a number of bytes from the beginning
+  of the uncompressed stream.
+
+  gzseek returns the resulting offset, or -1 in case of error.
+  SEEK_END is not implemented, returns error.
+  In this version of the library, gzseek can be extremely slow.
+
+============================================================================}
+
+function gzseek (f:gzfile; offset:z_off_t; whence:int) : z_off_t;
+var
+  s : gz_streamp;
+  size : uInt;
+begin
+  s := gz_streamp(f);
+
+  if (s = NIL) or (whence = SEEK_END) or (s^.z_err = Z_ERRNO)
+  or (s^.z_err = Z_DATA_ERROR) then begin
+    gzseek := z_off_t(-1);
+    exit;
+  end;
+
+  if (s^.mode = 'w') then begin
+{$IFDEF NO_DEFLATE}
+    gzseek := z_off_t(-1);
+    exit;
+{$ELSE}
+    if (whence = SEEK_SET) then dec(offset, s^.stream.total_out);
+    if (offset < 0) then begin;
+      gzseek := z_off_t(-1);
+      exit;
+    end;
+
+    { At this point, offset is the number of zero bytes to write. }
+    if (s^.inbuf = Z_NULL) then begin
+      GetMem (s^.inbuf, Z_BUFSIZE);
+      zmemzero(s^.inbuf, Z_BUFSIZE);
+    end;
+
+    while (offset > 0) do begin
+      size := Z_BUFSIZE;
+      if (offset < Z_BUFSIZE) then size := uInt(offset);
+
+      size := gzwrite(f, s^.inbuf, size);
+      if (size = 0) then begin
+        gzseek := z_off_t(-1);
+        exit;
+      end;
+
+      dec (offset,size);
+    end;
+
+    gzseek := z_off_t(s^.stream.total_in);
+    exit;
+{$ENDIF}
+  end;
+  { Rest of function is for reading only }
+
+  { compute absolute position }
+  if (whence = SEEK_CUR) then inc (offset, s^.stream.total_out);
+  if (offset < 0) then begin
+    gzseek := z_off_t(-1);
+    exit;
+  end;
+
+  if (s^.transparent = true) then begin
+    s^.stream.avail_in := 0;
+    s^.stream.next_in := s^.inbuf;
+    {$I-}
+    seek (s^.gzfile, offset);
+    {$I+}
+    if (IOResult <> 0) then begin
+      gzseek := z_off_t(-1);
+      exit;
+    end;
+
+    s^.stream.total_in := uLong(offset);
+    s^.stream.total_out := uLong(offset);
+    gzseek := z_off_t(offset);
+    exit;
+  end;
+
+  { For a negative seek, rewind and use positive seek }
+  if (uLong(offset) >= s^.stream.total_out)
+    then dec (offset, s^.stream.total_out)
+    else if (gzrewind(f) <> 0) then begin
+      gzseek := z_off_t(-1);
+      exit;
+  end;
+  { offset is now the number of bytes to skip. }
+
+  if (offset <> 0) and (s^.outbuf = Z_NULL)
+  then GetMem (s^.outbuf, Z_BUFSIZE);
+
+  while (offset > 0) do begin
+    size := Z_BUFSIZE;
+    if (offset < Z_BUFSIZE) then size := int(offset);
+
+    size := gzread (f, s^.outbuf, size);
+    if (size <= 0) then begin
+      gzseek := z_off_t(-1);
+      exit;
+    end;
+    dec(offset, size);
+  end;
+
+  gzseek := z_off_t(s^.stream.total_out);
+end;
+
+
+{ GZTELL ====================================================================
+
+  Returns the starting position for the next gzread or gzwrite on the
+  given compressed file. This position represents a number of bytes in the
+  uncompressed data stream.
+
+============================================================================}
+
+function gztell (f:gzfile) : z_off_t;
+begin
+  gztell := gzseek (f, 0, SEEK_CUR);
+end;
+
+
+{ GZEOF =====================================================================
+
+  Returns TRUE when EOF has previously been detected reading the given
+  input stream, otherwise FALSE.
+
+============================================================================}
+
+function gzeof (f:gzfile) : boolean;
+var
+  s:gz_streamp;
+begin
+  s := gz_streamp(f);
+
+  if (s=NIL) or (s^.mode<>'r') then
+    gzeof := false
+  else
+    gzeof := s^.z_eof;
+end;
+
+
+{ PUTLONG ===================================================================
+
+  Outputs a Longint in LSB order to the given file
+
+============================================================================}
+
+procedure putLong (var f:file; x:uLong);
+var
+  n : int;
+  c : byte;
+begin
+  for n:=0 to 3 do begin
+    c := x and $FF;
+    blockwrite (f, c, 1);
+    x := x shr 8;
+  end;
+end;
+
+
+{ GZCLOSE ===================================================================
+
+  Flushes all pending output if necessary, closes the compressed file
+  and deallocates all the (de)compression state.
+
+  The return value is the zlib error number (see function gzerror below).
+
+============================================================================}
+
+function gzclose (f:gzFile) : int;
+var
+  err : int;
+  s   : gz_streamp;
+begin
+  s := gz_streamp(f);
+  if (s = NIL) then begin
+    gzclose := Z_STREAM_ERROR;
+    exit;
+  end;
+
+  if (s^.mode = 'w') then begin
+{$IFDEF NO_DEFLATE}
+    gzclose := Z_STREAM_ERROR;
+    exit;
+{$ELSE}
+    err := do_flush (f, Z_FINISH);
+    if (err <> Z_OK) then begin
+      gzclose := destroy (gz_streamp(f));
+      exit;
+    end;
+
+    putLong (s^.gzfile, s^.crc);
+    putLong (s^.gzfile, s^.stream.total_in);
+{$ENDIF}
+  end;
+
+  gzclose := destroy (gz_streamp(f));
+end;
+
+
+{ GZERROR ===================================================================
+
+  Returns the error message for the last error which occured on the
+   given compressed file. errnum is set to zlib error number. If an
+   error occured in the file system and not in the compression library,
+   errnum is set to Z_ERRNO and the application may consult errno
+   to get the exact error code.
+
+============================================================================}
+
+function gzerror (f:gzfile; var errnum:int) : string;
+var
+ m : string;
+ s : gz_streamp;
+begin
+  s := gz_streamp(f);
+  if (s = NIL) then begin
+    errnum := Z_STREAM_ERROR;
+    gzerror := zError(Z_STREAM_ERROR);
+    end;
+
+  errnum := s^.z_err;
+  if (errnum = Z_OK) then begin
+    gzerror := zError(Z_OK);
+    exit;
+  end;
+
+  m := s^.stream.msg;
+  if (errnum = Z_ERRNO) then m := '';
+  if (m = '') then m := zError(s^.z_err);
+
+  s^.msg := s^.path+': '+m;
+  gzerror := s^.msg;
+end;
+
+end.

+ 954 - 0
packages/base/paszlib/infblock.pas

@@ -0,0 +1,954 @@
+Unit InfBlock;
+
+{ infblock.h and
+  infblock.c -- interpret and process block types to last block
+  Copyright (C) 1995-1998 Mark Adler
+
+  Pascal tranlastion
+  Copyright (C) 1998 by Jacques Nomssi Nzali
+  For conditions of distribution and use, see copyright notice in readme.txt
+}
+
+interface
+{$ifdef fpc}
+{$goto on}
+{$endif}
+
+{$I zconf.inc}
+
+uses
+  {$IFDEF STRUTILS_DEBUG}
+  strutils,
+  {$ENDIF}
+  zutil, zbase;
+
+function inflate_blocks_new(var z : z_stream;
+                            c : check_func;  { check function }
+                            w : uInt     { window size }
+                            ) : pInflate_blocks_state;
+
+function inflate_blocks (var s : inflate_blocks_state;
+                         var z : z_stream;
+                         r : int             { initial return code }
+                         ) : int;
+
+procedure inflate_blocks_reset (var s : inflate_blocks_state;
+                                var z : z_stream;
+                                c : puLong); { check value on output }
+
+
+function inflate_blocks_free(s : pInflate_blocks_state;
+                             var z : z_stream) : int;
+
+procedure inflate_set_dictionary(var s : inflate_blocks_state;
+                                 const d : array of byte;  { dictionary }
+                                 n : uInt);         { dictionary length }
+
+function inflate_blocks_sync_point(var s : inflate_blocks_state) : int;
+
+implementation
+
+uses
+  infcodes, inftrees, infutil;
+
+{ Tables for deflate from PKZIP's appnote.txt. }
+Const
+  border : Array [0..18] Of Word  { Order of the bit length code lengths }
+    = (16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15);
+
+{ Notes beyond the 1.93a appnote.txt:
+
+   1. Distance pointers never point before the beginning of the output
+      stream.
+   2. Distance pointers can point back across blocks, up to 32k away.
+   3. There is an implied maximum of 7 bits for the bit length table and
+      15 bits for the actual data.
+   4. If only one code exists, then it is encoded using one bit.  (Zero
+      would be more efficient, but perhaps a little confusing.)  If two
+      codes exist, they are coded using one bit each (0 and 1).
+   5. There is no way of sending zero distance codes--a dummy must be
+      sent if there are none.  (History: a pre 2.0 version of PKZIP would
+      store blocks with no distance codes, but this was discovered to be
+      too harsh a criterion.)  Valid only for 1.93a.  2.04c does allow
+      zero distance codes, which is sent as one code of zero bits in
+      length.
+   6. There are up to 286 literal/length codes.  Code 256 represents the
+      end-of-block.  Note however that the static length tree defines
+      288 codes just to fill out the Huffman codes.  Codes 286 and 287
+      cannot be used though, since there is no length base or extra bits
+      defined for them.  Similarily, there are up to 30 distance codes.
+      However, static trees define 32 codes (all 5 bits) to fill out the
+      Huffman codes, but the last two had better not show up in the data.
+   7. Unzip can check dynamic Huffman blocks for complete code sets.
+      The exception is that a single code would not be complete (see #4).
+   8. The five bits following the block type is really the number of
+      literal codes sent minus 257.
+   9. Length codes 8,16,16 are interpreted as 13 length codes of 8 bits
+      (1+6+6).  Therefore, to output three times the length, you output
+      three codes (1+1+1), whereas to output four times the same length,
+      you only need two codes (1+3).  Hmm.
+  10. In the tree reconstruction algorithm, Code = Code + Increment
+      only if BitLength(i) is not zero.  (Pretty obvious.)
+  11. Correction: 4 Bits: # of Bit Length codes - 4     (4 - 19)
+  12. Note: length code 284 can represent 227-258, but length code 285
+      really is 258.  The last length deserves its own, short code
+      since it gets used a lot in very redundant files.  The length
+      258 is special since 258 - 3 (the min match length) is 255.
+  13. The literal/length and distance code bit lengths are read as a
+      single stream of lengths.  It is possible (and advantageous) for
+      a repeat code (16, 17, or 18) to go across the boundary between
+      the two sets of lengths. }
+
+
+procedure inflate_blocks_reset (var s : inflate_blocks_state;
+                                var z : z_stream;
+                                c : puLong); { check value on output }
+begin
+  if (c <> Z_NULL) then
+    c^ := s.check;
+  if (s.mode = BTREE) or (s.mode = DTREE) then
+    ZFREE(z, s.sub.trees.blens);
+  if (s.mode = CODES) then
+    inflate_codes_free(s.sub.decode.codes, z);
+
+  s.mode := ZTYPE;
+  s.bitk := 0;
+  s.bitb := 0;
+
+  s.write := s.window;
+  s.read := s.window;
+  if Assigned(s.checkfn) then
+  begin
+    s.check := s.checkfn(uLong(0), pBytef(NIL), 0);
+    z.adler := s.check;
+  end;
+  {$IFDEF STRUTILS_DEBUG}
+  Tracev('inflate:   blocks reset');
+  {$ENDIF}
+end;
+
+
+function inflate_blocks_new(var z : z_stream;
+                            c : check_func;  { check function }
+                            w : uInt         { window size }
+                            ) : pInflate_blocks_state;
+var
+  s : pInflate_blocks_state;
+begin
+  s := pInflate_blocks_state( ZALLOC(z,1, sizeof(inflate_blocks_state)) );
+  if (s = Z_NULL) then
+  begin
+    inflate_blocks_new := s;
+    exit;
+  end;
+  s^.hufts := huft_ptr( ZALLOC(z, sizeof(inflate_huft), MANY) );
+
+  if (s^.hufts = Z_NULL) then
+  begin
+    ZFREE(z, s);
+    inflate_blocks_new := Z_NULL;
+    exit;
+  end;
+
+  s^.window := pBytef( ZALLOC(z, 1, w) );
+  if (s^.window = Z_NULL) then
+  begin
+    ZFREE(z, s^.hufts);
+    ZFREE(z, s);
+    inflate_blocks_new := Z_NULL;
+    exit;
+  end;
+  s^.zend := s^.window;
+  Inc(s^.zend, w);
+  s^.checkfn := c;
+  s^.mode := ZTYPE;
+  {$IFDEF STRUTILS_DEBUG}
+  Tracev('inflate:   blocks allocated');
+  {$ENDIF}
+  inflate_blocks_reset(s^, z, Z_NULL);
+  inflate_blocks_new := s;
+end;
+
+
+function inflate_blocks (var s : inflate_blocks_state;
+                         var z : z_stream;
+                         r : int) : int;           { initial return code }
+label
+  start_btree, start_dtree,
+  start_blkdone, start_dry,
+  start_codes;
+
+var
+  t : uInt;               { temporary storage }
+  b : uLong;              { bit buffer }
+  k : uInt;               { bits in bit buffer }
+  p : pBytef;             { input data pointer }
+  n : uInt;               { bytes available there }
+  q : pBytef;             { output window write pointer }
+  m : uInt;               { bytes to end of window or read pointer }
+{ fixed code blocks }
+var
+  bl, bd : uInt;
+  tl, td : pInflate_huft;
+var
+  h : pInflate_huft;
+  i, j, c : uInt;
+var
+  cs : pInflate_codes_state;
+begin
+  { copy input/output information to locals }
+  p := z.next_in;
+  n := z.avail_in;
+  b := s.bitb;
+  k := s.bitk;
+  q := s.write;
+  if ptr2int(q) < ptr2int(s.read) then
+    m := uInt(ptr2int(s.read)-ptr2int(q)-1)
+  else
+    m := uInt(ptr2int(s.zend)-ptr2int(q));
+
+{ decompress an inflated block }
+
+
+  { process input based on current state }
+  while True do
+  Case s.mode of
+    ZTYPE:
+      begin
+        {NEEDBITS(3);}
+        while (k < 3) do
+        begin
+          {NEEDBYTE;}
+          if (n <> 0) then
+            r :=Z_OK
+          else
+          begin
+            {UPDATE}
+            s.bitb := b;
+            s.bitk := k;
+            z.avail_in := n;
+            Inc(z.total_in, ptr2int(p)-ptr2int(z.next_in));
+            z.next_in := p;
+            s.write := q;
+            inflate_blocks := inflate_flush(s,z,r);
+            exit;
+          end;
+          Dec(n);
+          b := b or (uLong(p^) shl k);
+          Inc(p);
+          Inc(k, 8);
+        end;
+
+        t := uInt(b) and 7;
+        s.last := boolean(t and 1);
+        case (t shr 1) of
+          0:                         { stored }
+            begin
+              {$IFDEF STRUTILS_DEBUG}
+              if s.last then
+                Tracev('inflate:     stored block (last)')
+              else
+                Tracev('inflate:     stored block');
+              {$ENDIF}
+              {DUMPBITS(3);}
+              b := b shr 3;
+              Dec(k, 3);
+
+              t := k and 7;                  { go to byte boundary }
+              {DUMPBITS(t);}
+              b := b shr t;
+              Dec(k, t);
+
+              s.mode := LENS;                { get length of stored block }
+            end;
+          1:                         { fixed }
+            begin
+              begin
+                {$IFDEF STRUTILS_DEBUG}
+                if s.last then
+                  Tracev('inflate:     fixed codes blocks (last)')
+                else
+                  Tracev('inflate:     fixed codes blocks');
+                {$ENDIF}
+                inflate_trees_fixed(bl, bd, tl, td, z);
+                s.sub.decode.codes := inflate_codes_new(bl, bd, tl, td, z);
+                if (s.sub.decode.codes = Z_NULL) then
+                begin
+                  r := Z_MEM_ERROR;
+                  { update pointers and return }
+                  s.bitb := b;
+                  s.bitk := k;
+                  z.avail_in := n;
+                  Inc(z.total_in, ptr2int(p) - ptr2int(z.next_in));
+                  z.next_in := p;
+                  s.write := q;
+                  inflate_blocks := inflate_flush(s,z,r);
+                  exit;
+                end;
+              end;
+              {DUMPBITS(3);}
+              b := b shr 3;
+              Dec(k, 3);
+
+              s.mode := CODES;
+            end;
+          2:                         { dynamic }
+            begin
+              {$IFDEF STRUTILS_DEBUG}
+              if s.last then
+                Tracev('inflate:     dynamic codes block (last)')
+              else
+                Tracev('inflate:     dynamic codes block');
+              {$ENDIF}
+              {DUMPBITS(3);}
+              b := b shr 3;
+              Dec(k, 3);
+
+              s.mode := TABLE;
+            end;
+          3:
+            begin                   { illegal }
+              {DUMPBITS(3);}
+              b := b shr 3;
+              Dec(k, 3);
+
+              s.mode := BLKBAD;
+              z.msg := 'invalid block type';
+              r := Z_DATA_ERROR;
+              { update pointers and return }
+              s.bitb := b;
+              s.bitk := k;
+              z.avail_in := n;
+              Inc(z.total_in, ptr2int(p) - ptr2int(z.next_in));
+              z.next_in := p;
+              s.write := q;
+              inflate_blocks := inflate_flush(s,z,r);
+              exit;
+            end;
+        end;
+      end;
+    LENS:
+      begin
+        {NEEDBITS(32);}
+        while (k < 32) do
+        begin
+          {NEEDBYTE;}
+          if (n <> 0) then
+            r :=Z_OK
+          else
+          begin
+            {UPDATE}
+            s.bitb := b;
+            s.bitk := k;
+            z.avail_in := n;
+            Inc(z.total_in, ptr2int(p)-ptr2int(z.next_in));
+            z.next_in := p;
+            s.write := q;
+            inflate_blocks := inflate_flush(s,z,r);
+            exit;
+          end;
+          Dec(n);
+          b := b or (uLong(p^) shl k);
+          Inc(p);
+          Inc(k, 8);
+        end;
+
+        if (((not b) shr 16) and $ffff) <> (b and $ffff) then
+        begin
+          s.mode := BLKBAD;
+          z.msg := 'invalid stored block lengths';
+          r := Z_DATA_ERROR;
+          { update pointers and return }
+          s.bitb := b;
+          s.bitk := k;
+          z.avail_in := n;
+          Inc(z.total_in, ptr2int(p) - ptr2int(z.next_in));
+          z.next_in := p;
+          s.write := q;
+          inflate_blocks := inflate_flush(s,z,r);
+          exit;
+        end;
+        s.sub.left := uInt(b) and $ffff;
+        k := 0;
+        b := 0;                      { dump bits }
+        {$IFDEF STRUTILS_DEBUG}
+        Tracev('inflate:       stored length '+IntToStr(s.sub.left));
+        {$ENDIF}
+        if s.sub.left <> 0 then
+          s.mode := STORED
+        else
+          if s.last then
+            s.mode := DRY
+          else
+            s.mode := ZTYPE;
+      end;
+    STORED:
+      begin
+        if (n = 0) then
+        begin
+          { update pointers and return }
+          s.bitb := b;
+          s.bitk := k;
+          z.avail_in := n;
+          Inc(z.total_in, ptr2int(p) - ptr2int(z.next_in));
+          z.next_in := p;
+          s.write := q;
+          inflate_blocks := inflate_flush(s,z,r);
+          exit;
+        end;
+        {NEEDOUT}
+        if (m = 0) then
+        begin
+          {WRAP}
+          if (q = s.zend) and (s.read <> s.window) then
+          begin
+            q := s.window;
+            if ptr2int(q) < ptr2int(s.read) then
+              m := uInt(ptr2int(s.read)-ptr2int(q)-1)
+            else
+              m := uInt(ptr2int(s.zend)-ptr2int(q));
+          end;
+
+          if (m = 0) then
+          begin
+            {FLUSH}
+            s.write := q;
+            r := inflate_flush(s,z,r);
+            q := s.write;
+            if ptr2int(q) < ptr2int(s.read) then
+              m := uInt(ptr2int(s.read)-ptr2int(q)-1)
+            else
+              m := uInt(ptr2int(s.zend)-ptr2int(q));
+
+            {WRAP}
+            if (q = s.zend) and (s.read <> s.window) then
+            begin
+              q := s.window;
+              if ptr2int(q) < ptr2int(s.read) then
+                m := uInt(ptr2int(s.read)-ptr2int(q)-1)
+              else
+                m := uInt(ptr2int(s.zend)-ptr2int(q));
+            end;
+
+            if (m = 0) then
+            begin
+              {UPDATE}
+              s.bitb := b;
+              s.bitk := k;
+              z.avail_in := n;
+              Inc(z.total_in, ptr2int(p)-ptr2int(z.next_in));
+              z.next_in := p;
+              s.write := q;
+              inflate_blocks := inflate_flush(s,z,r);
+              exit;
+            end;
+          end;
+        end;
+        r := Z_OK;
+
+        t := s.sub.left;
+        if (t > n) then
+          t := n;
+        if (t > m) then
+          t := m;
+        zmemcpy(q, p, t);
+        Inc(p, t);  Dec(n, t);
+        Inc(q, t);  Dec(m, t);
+        Dec(s.sub.left, t);
+        if (s.sub.left = 0) then
+        begin
+          {$IFDEF STRUTILS_DEBUG}
+          if (ptr2int(q) >= ptr2int(s.read)) then
+            Tracev('inflate:       stored end '+
+                IntToStr(z.total_out + ptr2int(q) - ptr2int(s.read)) + ' total out')
+          else
+            Tracev('inflate:       stored end '+
+                    IntToStr(z.total_out + ptr2int(s.zend) - ptr2int(s.read) +
+                    ptr2int(q) - ptr2int(s.window)) +  ' total out');
+          {$ENDIF}
+          if s.last then
+            s.mode := DRY
+          else
+            s.mode := ZTYPE;
+        end;
+      end;
+    TABLE:
+      begin
+        {NEEDBITS(14);}
+        while (k < 14) do
+        begin
+          {NEEDBYTE;}
+          if (n <> 0) then
+            r :=Z_OK
+          else
+          begin
+            {UPDATE}
+            s.bitb := b;
+            s.bitk := k;
+            z.avail_in := n;
+            Inc(z.total_in, ptr2int(p)-ptr2int(z.next_in));
+            z.next_in := p;
+            s.write := q;
+            inflate_blocks := inflate_flush(s,z,r);
+            exit;
+          end;
+          Dec(n);
+          b := b or (uLong(p^) shl k);
+          Inc(p);
+          Inc(k, 8);
+        end;
+
+        t := uInt(b) and $3fff;
+        s.sub.trees.table := t;
+  {$ifndef PKZIP_BUG_WORKAROUND}
+        if ((t and $1f) > 29) or (((t shr 5) and $1f) > 29) then
+        begin
+          s.mode := BLKBAD;
+          z.msg := 'too many length or distance symbols';
+          r := Z_DATA_ERROR;
+          { update pointers and return }
+          s.bitb := b;
+          s.bitk := k;
+          z.avail_in := n;
+          Inc(z.total_in, ptr2int(p) - ptr2int(z.next_in));
+          z.next_in := p;
+          s.write := q;
+          inflate_blocks := inflate_flush(s,z,r);
+          exit;
+        end;
+  {$endif}
+        t := 258 + (t and $1f) + ((t shr 5) and $1f);
+        s.sub.trees.blens := puIntArray( ZALLOC(z, t, sizeof(uInt)) );
+        if (s.sub.trees.blens = Z_NULL) then
+        begin
+          r := Z_MEM_ERROR;
+          { update pointers and return }
+          s.bitb := b;
+          s.bitk := k;
+          z.avail_in := n;
+          Inc(z.total_in, ptr2int(p) - ptr2int(z.next_in));
+          z.next_in := p;
+          s.write := q;
+          inflate_blocks := inflate_flush(s,z,r);
+          exit;
+        end;
+        {DUMPBITS(14);}
+        b := b shr 14;
+        Dec(k, 14);
+
+        s.sub.trees.index := 0;
+        {$IFDEF STRUTILS_DEBUG}
+        Tracev('inflate:       table sizes ok');
+        {$ENDIF}
+        s.mode := BTREE;
+        { fall trough case is handled by the while }
+        { try GOTO for speed - Nomssi }
+        goto start_btree;
+      end;
+    BTREE:
+      begin
+        start_btree:
+        while (s.sub.trees.index < 4 + (s.sub.trees.table shr 10)) do
+        begin
+          {NEEDBITS(3);}
+          while (k < 3) do
+          begin
+            {NEEDBYTE;}
+            if (n <> 0) then
+              r :=Z_OK
+            else
+            begin
+              {UPDATE}
+              s.bitb := b;
+              s.bitk := k;
+              z.avail_in := n;
+              Inc(z.total_in, ptr2int(p)-ptr2int(z.next_in));
+              z.next_in := p;
+              s.write := q;
+              inflate_blocks := inflate_flush(s,z,r);
+              exit;
+            end;
+            Dec(n);
+            b := b or (uLong(p^) shl k);
+            Inc(p);
+            Inc(k, 8);
+          end;
+
+          s.sub.trees.blens^[border[s.sub.trees.index]] := uInt(b) and 7;
+          Inc(s.sub.trees.index);
+          {DUMPBITS(3);}
+          b := b shr 3;
+          Dec(k, 3);
+        end;
+        while (s.sub.trees.index < 19) do
+        begin
+          s.sub.trees.blens^[border[s.sub.trees.index]] := 0;
+          Inc(s.sub.trees.index);
+        end;
+        s.sub.trees.bb := 7;
+        t := inflate_trees_bits(s.sub.trees.blens^, s.sub.trees.bb,
+                                s.sub.trees.tb, s.hufts^, z);
+        if (t <> Z_OK) then
+        begin
+          ZFREE(z, s.sub.trees.blens);
+          r := t;
+          if (r = Z_DATA_ERROR) then
+            s.mode := BLKBAD;
+          { update pointers and return }
+          s.bitb := b;
+          s.bitk := k;
+          z.avail_in := n;
+          Inc(z.total_in, ptr2int(p) - ptr2int(z.next_in));
+          z.next_in := p;
+          s.write := q;
+          inflate_blocks := inflate_flush(s,z,r);
+          exit;
+        end;
+        s.sub.trees.index := 0;
+        {$IFDEF STRUTILS_DEBUG}
+        Tracev('inflate:       bits tree ok');
+        {$ENDIF}
+        s.mode := DTREE;
+        { fall through again }
+        goto start_dtree;
+      end;
+    DTREE:
+      begin
+        start_dtree:
+        while TRUE do
+        begin
+          t := s.sub.trees.table;
+          if not (s.sub.trees.index < 258 +
+                                     (t and $1f) + ((t shr 5) and $1f)) then
+            break;
+          t := s.sub.trees.bb;
+          {NEEDBITS(t);}
+          while (k < t) do
+          begin
+            {NEEDBYTE;}
+            if (n <> 0) then
+              r :=Z_OK
+            else
+            begin
+              {UPDATE}
+              s.bitb := b;
+              s.bitk := k;
+              z.avail_in := n;
+              Inc(z.total_in, ptr2int(p)-ptr2int(z.next_in));
+              z.next_in := p;
+              s.write := q;
+              inflate_blocks := inflate_flush(s,z,r);
+              exit;
+            end;
+            Dec(n);
+            b := b or (uLong(p^) shl k);
+            Inc(p);
+            Inc(k, 8);
+          end;
+
+          h := s.sub.trees.tb;
+          Inc(h, uInt(b) and inflate_mask[t]);
+          t := h^.Bits;
+          c := h^.Base;
+
+          if (c < 16) then
+          begin
+            {DUMPBITS(t);}
+            b := b shr t;
+            Dec(k, t);
+
+            s.sub.trees.blens^[s.sub.trees.index] := c;
+            Inc(s.sub.trees.index);
+          end
+          else { c = 16..18 }
+          begin
+            if c = 18 then
+            begin
+              i := 7;
+              j := 11;
+            end
+            else
+            begin
+              i := c - 14;
+              j := 3;
+            end;
+            {NEEDBITS(t + i);}
+            while (k < t + i) do
+            begin
+              {NEEDBYTE;}
+              if (n <> 0) then
+                r :=Z_OK
+              else
+              begin
+                {UPDATE}
+                s.bitb := b;
+                s.bitk := k;
+                z.avail_in := n;
+                Inc(z.total_in, ptr2int(p)-ptr2int(z.next_in));
+                z.next_in := p;
+                s.write := q;
+                inflate_blocks := inflate_flush(s,z,r);
+                exit;
+              end;
+              Dec(n);
+              b := b or (uLong(p^) shl k);
+              Inc(p);
+              Inc(k, 8);
+            end;
+
+            {DUMPBITS(t);}
+            b := b shr t;
+            Dec(k, t);
+
+            Inc(j, uInt(b) and inflate_mask[i]);
+            {DUMPBITS(i);}
+            b := b shr i;
+            Dec(k, i);
+
+            i := s.sub.trees.index;
+            t := s.sub.trees.table;
+            if (i + j > 258 + (t and $1f) + ((t shr 5) and $1f)) or
+               ((c = 16) and (i < 1)) then
+            begin
+              ZFREE(z, s.sub.trees.blens);
+              s.mode := BLKBAD;
+              z.msg := 'invalid bit length repeat';
+              r := Z_DATA_ERROR;
+              { update pointers and return }
+              s.bitb := b;
+              s.bitk := k;
+              z.avail_in := n;
+              Inc(z.total_in, ptr2int(p) - ptr2int(z.next_in));
+              z.next_in := p;
+              s.write := q;
+              inflate_blocks := inflate_flush(s,z,r);
+              exit;
+            end;
+            if c = 16 then
+              c := s.sub.trees.blens^[i - 1]
+            else
+              c := 0;
+            repeat
+              s.sub.trees.blens^[i] := c;
+              Inc(i);
+              Dec(j);
+            until (j=0);
+            s.sub.trees.index := i;
+          end;
+        end; { while }
+        s.sub.trees.tb := Z_NULL;
+        begin
+          bl := 9;         { must be <= 9 for lookahead assumptions }
+          bd := 6;         { must be <= 9 for lookahead assumptions }
+          t := s.sub.trees.table;
+          t := inflate_trees_dynamic(257 + (t and $1f),
+                  1 + ((t shr 5) and $1f),
+                  s.sub.trees.blens^, bl, bd, tl, td, s.hufts^, z);
+          ZFREE(z, s.sub.trees.blens);
+          if (t <> Z_OK) then
+          begin
+            if (t = uInt(Z_DATA_ERROR)) then
+              s.mode := BLKBAD;
+            r := t;
+            { update pointers and return }
+            s.bitb := b;
+            s.bitk := k;
+            z.avail_in := n;
+            Inc(z.total_in, ptr2int(p) - ptr2int(z.next_in));
+            z.next_in := p;
+            s.write := q;
+            inflate_blocks := inflate_flush(s,z,r);
+            exit;
+          end;
+          {$IFDEF STRUTILS_DEBUG}
+          Tracev('inflate:       trees ok');
+          {$ENDIF}
+          { c renamed to cs }
+          cs := inflate_codes_new(bl, bd, tl, td, z);
+          if (cs = Z_NULL) then
+          begin
+            r := Z_MEM_ERROR;
+            { update pointers and return }
+            s.bitb := b;
+            s.bitk := k;
+            z.avail_in := n;
+            Inc(z.total_in, ptr2int(p) - ptr2int(z.next_in));
+            z.next_in := p;
+            s.write := q;
+            inflate_blocks := inflate_flush(s,z,r);
+            exit;
+          end;
+          s.sub.decode.codes := cs;
+        end;
+        s.mode := CODES;
+        { yet another falltrough }
+        goto start_codes;
+      end;
+    CODES:
+      begin
+        start_codes:
+        { update pointers }
+        s.bitb := b;
+        s.bitk := k;
+        z.avail_in := n;
+        Inc(z.total_in, ptr2int(p) - ptr2int(z.next_in));
+        z.next_in := p;
+        s.write := q;
+
+        r := inflate_codes(s, z, r);
+        if (r <> Z_STREAM_END) then
+        begin
+          inflate_blocks := inflate_flush(s, z, r);
+          exit;
+        end;
+        r := Z_OK;
+        inflate_codes_free(s.sub.decode.codes, z);
+        { load local pointers }
+        p := z.next_in;
+        n := z.avail_in;
+        b := s.bitb;
+        k := s.bitk;
+        q := s.write;
+        if ptr2int(q) < ptr2int(s.read) then
+          m := uInt(ptr2int(s.read)-ptr2int(q)-1)
+        else
+          m := uInt(ptr2int(s.zend)-ptr2int(q));
+        {$IFDEF STRUTILS_DEBUG}
+        if (ptr2int(q) >= ptr2int(s.read)) then
+          Tracev('inflate:       codes end '+
+              IntToStr(z.total_out + ptr2int(q) - ptr2int(s.read)) + ' total out')
+        else
+          Tracev('inflate:       codes end '+
+                  IntToStr(z.total_out + ptr2int(s.zend) - ptr2int(s.read) +
+                  ptr2int(q) - ptr2int(s.window)) +  ' total out');
+        {$ENDIF}
+        if (not s.last) then
+        begin
+          s.mode := ZTYPE;
+          continue; { break for switch statement in C-code }
+        end;
+        {$ifndef patch112}
+        if (k > 7) then           { return unused byte, if any }
+        begin
+          {$IFDEF STRUTILS_DEBUG}
+          Assert(k < 16, 'inflate_codes grabbed too many bytes');
+          {$ENDIF}
+          Dec(k, 8);
+          Inc(n);
+          Dec(p);                    { can always return one }
+        end;
+        {$endif}
+        s.mode := DRY;
+        { another falltrough }
+        goto start_dry;
+      end;
+    DRY:
+      begin
+        start_dry:
+        {FLUSH}
+        s.write := q;
+        r := inflate_flush(s,z,r);
+        q := s.write;
+
+        { not needed anymore, we are done:
+        if ptr2int(q) < ptr2int(s.read) then
+          m := uInt(ptr2int(s.read)-ptr2int(q)-1)
+        else
+          m := uInt(ptr2int(s.zend)-ptr2int(q));
+        }
+
+        if (s.read <> s.write) then
+        begin
+          { update pointers and return }
+          s.bitb := b;
+          s.bitk := k;
+          z.avail_in := n;
+          Inc(z.total_in, ptr2int(p) - ptr2int(z.next_in));
+          z.next_in := p;
+          s.write := q;
+          inflate_blocks := inflate_flush(s,z,r);
+          exit;
+        end;
+        s.mode := BLKDONE;
+        goto start_blkdone;
+      end;
+    BLKDONE:
+      begin
+        start_blkdone:
+        r := Z_STREAM_END;
+        { update pointers and return }
+        s.bitb := b;
+        s.bitk := k;
+        z.avail_in := n;
+        Inc(z.total_in, ptr2int(p) - ptr2int(z.next_in));
+        z.next_in := p;
+        s.write := q;
+        inflate_blocks := inflate_flush(s,z,r);
+        exit;
+      end;
+    BLKBAD:
+      begin
+        r := Z_DATA_ERROR;
+        { update pointers and return }
+        s.bitb := b;
+        s.bitk := k;
+        z.avail_in := n;
+        Inc(z.total_in, ptr2int(p) - ptr2int(z.next_in));
+        z.next_in := p;
+        s.write := q;
+        inflate_blocks := inflate_flush(s,z,r);
+        exit;
+      end;
+    else
+    begin
+      r := Z_STREAM_ERROR;
+      { update pointers and return }
+      s.bitb := b;
+      s.bitk := k;
+      z.avail_in := n;
+      Inc(z.total_in, ptr2int(p) - ptr2int(z.next_in));
+      z.next_in := p;
+      s.write := q;
+      inflate_blocks := inflate_flush(s,z,r);
+      exit;
+    end;
+  end; { Case s.mode of }
+
+end;
+
+
+function inflate_blocks_free(s : pInflate_blocks_state;
+                             var z : z_stream) : int;
+begin
+  inflate_blocks_reset(s^, z, Z_NULL);
+  ZFREE(z, s^.window);
+  ZFREE(z, s^.hufts);
+  ZFREE(z, s);
+  {$IFDEF STRUTILS_DEBUG}
+  Trace('inflate:   blocks freed');
+  {$ENDIF}
+  inflate_blocks_free := Z_OK;
+end;
+
+
+procedure inflate_set_dictionary(var s : inflate_blocks_state;
+                                 const d : array of byte; { dictionary }
+                                 n : uInt);         { dictionary length }
+begin
+  zmemcpy(s.window, pBytef(@d), n);
+  s.write := s.window;
+  Inc(s.write, n);
+  s.read := s.write;
+end;
+
+
+{ Returns true if inflate is currently at the end of a block generated
+  by Z_SYNC_FLUSH or Z_FULL_FLUSH.
+  IN assertion: s <> Z_NULL }
+
+function inflate_blocks_sync_point(var s : inflate_blocks_state) : int;
+begin
+  inflate_blocks_sync_point := int(s.mode = LENS);
+end;
+
+end.

+ 576 - 0
packages/base/paszlib/infcodes.pas

@@ -0,0 +1,576 @@
+Unit InfCodes;
+
+{ infcodes.c -- process literals and length/distance pairs
+  Copyright (C) 1995-1998 Mark Adler
+
+  Pascal tranlastion
+  Copyright (C) 1998 by Jacques Nomssi Nzali
+  For conditions of distribution and use, see copyright notice in readme.txt
+}
+
+interface
+
+{$I zconf.inc}
+
+uses
+  {$IFDEF STRUTILS_DEBUG}
+  strutils,
+  {$ENDIF}
+  zutil, zbase;
+
+function inflate_codes_new (bl : uInt;
+                            bd : uInt;
+                            tl : pInflate_huft;
+                            td : pInflate_huft;
+                            var z : z_stream): pInflate_codes_state;
+
+function inflate_codes(var s : inflate_blocks_state;
+                       var z : z_stream;
+                       r : int) : int;
+
+procedure inflate_codes_free(c : pInflate_codes_state;
+                             var z : z_stream);
+
+implementation
+
+uses
+  infutil, inffast;
+
+
+function inflate_codes_new (bl : uInt;
+                            bd : uInt;
+                            tl : pInflate_huft;
+                            td : pInflate_huft;
+                            var z : z_stream): pInflate_codes_state;
+var
+ c : pInflate_codes_state;
+begin
+  c := pInflate_codes_state( ZALLOC(z,1,sizeof(inflate_codes_state)) );
+  if (c <> Z_NULL) then
+  begin
+    c^.mode := START;
+    c^.lbits := Byte(bl);
+    c^.dbits := Byte(bd);
+    c^.ltree := tl;
+    c^.dtree := td;
+    {$IFDEF STRUTILS_DEBUG}
+    Tracev('inflate:       codes new');
+    {$ENDIF}
+  end;
+  inflate_codes_new := c;
+end;
+
+
+function inflate_codes(var s : inflate_blocks_state;
+                       var z : z_stream;
+                       r : int) : int;
+var
+  j : uInt;               { temporary storage }
+  t : pInflate_huft;      { temporary pointer }
+  e : uInt;               { extra bits or operation }
+  b : uLong;              { bit buffer }
+  k : uInt;               { bits in bit buffer }
+  p : pBytef;             { input data pointer }
+  n : uInt;               { bytes available there }
+  q : pBytef;             { output window write pointer }
+  m : uInt;               { bytes to end of window or read pointer }
+  f : pBytef;             { pointer to copy strings from }
+var
+  c : pInflate_codes_state;
+begin
+  c := s.sub.decode.codes;  { codes state }
+
+  { copy input/output information to locals }
+  p := z.next_in;
+  n := z.avail_in;
+  b := s.bitb;
+  k := s.bitk;
+  q := s.write;
+  if ptr2int(q) < ptr2int(s.read) then
+    m := uInt(ptr2int(s.read)-ptr2int(q)-1)
+  else
+    m := uInt(ptr2int(s.zend)-ptr2int(q));
+
+  { process input and output based on current state }
+  while True do
+  case (c^.mode) of
+    { waiting for "i:"=input, "o:"=output, "x:"=nothing }
+  START:         { x: set up for LEN }
+    begin
+{$ifndef SLOW}
+      if (m >= 258) and (n >= 10) then
+      begin
+        {UPDATE}
+        s.bitb := b;
+        s.bitk := k;
+        z.avail_in := n;
+        Inc(z.total_in, ptr2int(p)-ptr2int(z.next_in));
+        z.next_in := p;
+        s.write := q;
+
+        r := inflate_fast(c^.lbits, c^.dbits, c^.ltree, c^.dtree, s, z);
+        {LOAD}
+        p := z.next_in;
+        n := z.avail_in;
+        b := s.bitb;
+        k := s.bitk;
+        q := s.write;
+        if ptr2int(q) < ptr2int(s.read) then
+          m := uInt(ptr2int(s.read)-ptr2int(q)-1)
+        else
+          m := uInt(ptr2int(s.zend)-ptr2int(q));
+
+        if (r <> Z_OK) then
+        begin
+          if (r = Z_STREAM_END) then
+            c^.mode := WASH
+          else
+            c^.mode := BADCODE;
+          continue;    { break for switch-statement in C }
+        end;
+      end;
+{$endif} { not SLOW }
+      c^.sub.code.need := c^.lbits;
+      c^.sub.code.tree := c^.ltree;
+      c^.mode := LEN;  { falltrough }
+    end;
+  LEN:           { i: get length/literal/eob next }
+    begin
+      j := c^.sub.code.need;
+      {NEEDBITS(j);}
+      while (k < j) do
+      begin
+        {NEEDBYTE;}
+        if (n <> 0) then
+          r :=Z_OK
+        else
+        begin
+          {UPDATE}
+          s.bitb := b;
+          s.bitk := k;
+          z.avail_in := n;
+          Inc(z.total_in, ptr2int(p)-ptr2int(z.next_in));
+          z.next_in := p;
+          s.write := q;
+          inflate_codes := inflate_flush(s,z,r);
+          exit;
+        end;
+        Dec(n);
+        b := b or (uLong(p^) shl k);
+        Inc(p);
+        Inc(k, 8);
+      end;
+      t := c^.sub.code.tree;
+      Inc(t, uInt(b) and inflate_mask[j]);
+      {DUMPBITS(t^.bits);}
+      b := b shr t^.bits;
+      Dec(k, t^.bits);
+
+      e := uInt(t^.exop);
+      if (e = 0) then            { literal }
+      begin
+        c^.sub.lit := t^.base;
+       {$IFDEF STRUTILS_DEBUG}
+        if (t^.base >= $20) and (t^.base < $7f) then
+          Tracevv('inflate:         literal '+char(t^.base))
+        else
+          Tracevv('inflate:         literal '+IntToStr(t^.base));
+        {$ENDIF}
+        c^.mode := LIT;
+        continue;  { break switch statement }
+      end;
+      if (e and 16 <> 0) then            { length }
+      begin
+        c^.sub.copy.get := e and 15;
+        c^.len := t^.base;
+        c^.mode := LENEXT;
+        continue;         { break C-switch statement }
+      end;
+      if (e and 64 = 0) then             { next table }
+      begin
+        c^.sub.code.need := e;
+        c^.sub.code.tree := @huft_ptr(t)^[t^.base];
+        continue;         { break C-switch statement }
+      end;
+      if (e and 32 <> 0) then            { end of block }
+      begin
+        {$IFDEF STRUTILS_DEBUG}
+        Tracevv('inflate:         end of block');
+        {$ENDIF}
+        c^.mode := WASH;
+        continue;         { break C-switch statement }
+      end;
+      c^.mode := BADCODE;        { invalid code }
+      z.msg := 'invalid literal/length code';
+      r := Z_DATA_ERROR;
+      {UPDATE}
+      s.bitb := b;
+      s.bitk := k;
+      z.avail_in := n;
+      Inc(z.total_in, ptr2int(p)-ptr2int(z.next_in));
+      z.next_in := p;
+      s.write := q;
+      inflate_codes := inflate_flush(s,z,r);
+      exit;
+    end;
+  LENEXT:        { i: getting length extra (have base) }
+    begin
+      j := c^.sub.copy.get;
+      {NEEDBITS(j);}
+      while (k < j) do
+      begin
+        {NEEDBYTE;}
+        if (n <> 0) then
+          r :=Z_OK
+        else
+        begin
+          {UPDATE}
+          s.bitb := b;
+          s.bitk := k;
+          z.avail_in := n;
+          Inc(z.total_in, ptr2int(p)-ptr2int(z.next_in));
+          z.next_in := p;
+          s.write := q;
+          inflate_codes := inflate_flush(s,z,r);
+          exit;
+        end;
+        Dec(n);
+        b := b or (uLong(p^) shl k);
+        Inc(p);
+        Inc(k, 8);
+      end;
+      Inc(c^.len, uInt(b and inflate_mask[j]));
+      {DUMPBITS(j);}
+      b := b shr j;
+      Dec(k, j);
+
+      c^.sub.code.need := c^.dbits;
+      c^.sub.code.tree := c^.dtree;
+      {$IFDEF STRUTILS_DEBUG}
+      Tracevv('inflate:         length '+IntToStr(c^.len));
+      {$ENDIF}
+      c^.mode := DIST;
+      { falltrough }
+    end;
+  DIST:          { i: get distance next }
+    begin
+      j := c^.sub.code.need;
+      {NEEDBITS(j);}
+      while (k < j) do
+      begin
+        {NEEDBYTE;}
+        if (n <> 0) then
+          r :=Z_OK
+        else
+        begin
+          {UPDATE}
+          s.bitb := b;
+          s.bitk := k;
+          z.avail_in := n;
+          Inc(z.total_in, ptr2int(p)-ptr2int(z.next_in));
+          z.next_in := p;
+          s.write := q;
+          inflate_codes := inflate_flush(s,z,r);
+          exit;
+        end;
+        Dec(n);
+        b := b or (uLong(p^) shl k);
+        Inc(p);
+        Inc(k, 8);
+      end;
+      t := @huft_ptr(c^.sub.code.tree)^[uInt(b) and inflate_mask[j]];
+      {DUMPBITS(t^.bits);}
+      b := b shr t^.bits;
+      Dec(k, t^.bits);
+
+      e := uInt(t^.exop);
+      if (e and 16 <> 0) then            { distance }
+      begin
+        c^.sub.copy.get := e and 15;
+        c^.sub.copy.dist := t^.base;
+        c^.mode := DISTEXT;
+        continue;     { break C-switch statement }
+      end;
+      if (e and 64 = 0) then     { next table }
+      begin
+        c^.sub.code.need := e;
+        c^.sub.code.tree := @huft_ptr(t)^[t^.base];
+        continue;     { break C-switch statement }
+      end;
+      c^.mode := BADCODE;        { invalid code }
+      z.msg := 'invalid distance code';
+      r := Z_DATA_ERROR;
+      {UPDATE}
+      s.bitb := b;
+      s.bitk := k;
+      z.avail_in := n;
+      Inc(z.total_in, ptr2int(p)-ptr2int(z.next_in));
+      z.next_in := p;
+      s.write := q;
+      inflate_codes := inflate_flush(s,z,r);
+      exit;
+    end;
+  DISTEXT:       { i: getting distance extra }
+    begin
+      j := c^.sub.copy.get;
+      {NEEDBITS(j);}
+      while (k < j) do
+      begin
+        {NEEDBYTE;}
+        if (n <> 0) then
+          r :=Z_OK
+        else
+        begin
+          {UPDATE}
+          s.bitb := b;
+          s.bitk := k;
+          z.avail_in := n;
+          Inc(z.total_in, ptr2int(p)-ptr2int(z.next_in));
+          z.next_in := p;
+          s.write := q;
+          inflate_codes := inflate_flush(s,z,r);
+          exit;
+        end;
+        Dec(n);
+        b := b or (uLong(p^) shl k);
+        Inc(p);
+        Inc(k, 8);
+      end;
+      Inc(c^.sub.copy.dist, uInt(b) and inflate_mask[j]);
+      {DUMPBITS(j);}
+      b := b shr j;
+      Dec(k, j);
+      {$IFDEF STRUTILS_DEBUG}
+      Tracevv('inflate:         distance '+ IntToStr(c^.sub.copy.dist));
+      {$ENDIF}
+      c^.mode := COPY;
+      { falltrough }
+    end;
+  COPY:          { o: copying bytes in window, waiting for space }
+    begin
+      f := q;
+      Dec(f, c^.sub.copy.dist);
+      if (uInt(ptr2int(q) - ptr2int(s.window)) < c^.sub.copy.dist) then
+      begin
+        f := s.zend;
+        Dec(f, c^.sub.copy.dist - uInt(ptr2int(q) - ptr2int(s.window)));
+      end;
+
+      while (c^.len <> 0) do
+      begin
+        {NEEDOUT}
+        if (m = 0) then
+        begin
+          {WRAP}
+          if (q = s.zend) and (s.read <> s.window) then
+          begin
+            q := s.window;
+            if ptr2int(q) < ptr2int(s.read) then
+              m := uInt(ptr2int(s.read)-ptr2int(q)-1)
+            else
+              m := uInt(ptr2int(s.zend)-ptr2int(q));
+          end;
+
+          if (m = 0) then
+          begin
+            {FLUSH}
+            s.write := q;
+            r := inflate_flush(s,z,r);
+            q := s.write;
+            if ptr2int(q) < ptr2int(s.read) then
+              m := uInt(ptr2int(s.read)-ptr2int(q)-1)
+            else
+              m := uInt(ptr2int(s.zend)-ptr2int(q));
+
+            {WRAP}
+            if (q = s.zend) and (s.read <> s.window) then
+            begin
+              q := s.window;
+              if ptr2int(q) < ptr2int(s.read) then
+                m := uInt(ptr2int(s.read)-ptr2int(q)-1)
+              else
+                m := uInt(ptr2int(s.zend)-ptr2int(q));
+            end;
+
+            if (m = 0) then
+            begin
+              {UPDATE}
+              s.bitb := b;
+              s.bitk := k;
+              z.avail_in := n;
+              Inc(z.total_in, ptr2int(p)-ptr2int(z.next_in));
+              z.next_in := p;
+              s.write := q;
+              inflate_codes := inflate_flush(s,z,r);
+              exit;
+            end;
+          end;
+        end;
+        r := Z_OK;
+
+        {OUTBYTE( *f++)}
+        q^ := f^;
+        Inc(q);
+        Inc(f);
+        Dec(m);
+
+        if (f = s.zend) then
+          f := s.window;
+        Dec(c^.len);
+      end;
+      c^.mode := START;
+      { C-switch break; not needed }
+    end;
+  LIT:           { o: got literal, waiting for output space }
+    begin
+      {NEEDOUT}
+      if (m = 0) then
+      begin
+        {WRAP}
+        if (q = s.zend) and (s.read <> s.window) then
+        begin
+          q := s.window;
+          if ptr2int(q) < ptr2int(s.read) then
+            m := uInt(ptr2int(s.read)-ptr2int(q)-1)
+          else
+            m := uInt(ptr2int(s.zend)-ptr2int(q));
+        end;
+
+        if (m = 0) then
+        begin
+          {FLUSH}
+          s.write := q;
+          r := inflate_flush(s,z,r);
+          q := s.write;
+          if ptr2int(q) < ptr2int(s.read) then
+            m := uInt(ptr2int(s.read)-ptr2int(q)-1)
+          else
+            m := uInt(ptr2int(s.zend)-ptr2int(q));
+
+          {WRAP}
+          if (q = s.zend) and (s.read <> s.window) then
+          begin
+            q := s.window;
+            if ptr2int(q) < ptr2int(s.read) then
+              m := uInt(ptr2int(s.read)-ptr2int(q)-1)
+            else
+              m := uInt(ptr2int(s.zend)-ptr2int(q));
+          end;
+
+          if (m = 0) then
+          begin
+            {UPDATE}
+            s.bitb := b;
+            s.bitk := k;
+            z.avail_in := n;
+            Inc(z.total_in, ptr2int(p)-ptr2int(z.next_in));
+            z.next_in := p;
+            s.write := q;
+            inflate_codes := inflate_flush(s,z,r);
+            exit;
+          end;
+        end;
+      end;
+      r := Z_OK;
+
+      {OUTBYTE(c^.sub.lit);}
+      q^ := c^.sub.lit;
+      Inc(q);
+      Dec(m);
+
+      c^.mode := START;
+      {break;}
+    end;
+  WASH:          { o: got eob, possibly more output }
+    begin
+      {$ifdef patch112}
+      if (k > 7) then           { return unused byte, if any }
+      begin
+        {$IFDEF STRUTILS_DEBUG}
+        Assert(k < 16, 'inflate_codes grabbed too many bytes');
+        {$ENDIF}
+        Dec(k, 8);
+        Inc(n);
+        Dec(p);                    { can always return one }
+      end;
+      {$endif}
+      {FLUSH}
+      s.write := q;
+      r := inflate_flush(s,z,r);
+      q := s.write;
+      if ptr2int(q) < ptr2int(s.read) then
+        m := uInt(ptr2int(s.read)-ptr2int(q)-1)
+      else
+        m := uInt(ptr2int(s.zend)-ptr2int(q));
+
+      if (s.read <> s.write) then
+      begin
+        {UPDATE}
+        s.bitb := b;
+        s.bitk := k;
+        z.avail_in := n;
+        Inc(z.total_in, ptr2int(p)-ptr2int(z.next_in));
+        z.next_in := p;
+        s.write := q;
+        inflate_codes := inflate_flush(s,z,r);
+        exit;
+      end;
+      c^.mode := ZEND;
+      { falltrough }
+    end;
+
+  ZEND:
+    begin
+      r := Z_STREAM_END;
+      {UPDATE}
+      s.bitb := b;
+      s.bitk := k;
+      z.avail_in := n;
+      Inc(z.total_in, ptr2int(p)-ptr2int(z.next_in));
+      z.next_in := p;
+      s.write := q;
+      inflate_codes := inflate_flush(s,z,r);
+      exit;
+    end;
+  BADCODE:       { x: got error }
+    begin
+      r := Z_DATA_ERROR;
+      {UPDATE}
+      s.bitb := b;
+      s.bitk := k;
+      z.avail_in := n;
+      Inc(z.total_in, ptr2int(p)-ptr2int(z.next_in));
+      z.next_in := p;
+      s.write := q;
+      inflate_codes := inflate_flush(s,z,r);
+      exit;
+    end;
+  else
+    begin
+      r := Z_STREAM_ERROR;
+      {UPDATE}
+      s.bitb := b;
+      s.bitk := k;
+      z.avail_in := n;
+      Inc(z.total_in, ptr2int(p)-ptr2int(z.next_in));
+      z.next_in := p;
+      s.write := q;
+      inflate_codes := inflate_flush(s,z,r);
+      exit;
+    end;
+  end;
+{NEED_DUMMY_RETURN - Delphi2+ dumb compilers complain without this }
+  inflate_codes := Z_STREAM_ERROR;
+end;
+
+
+procedure inflate_codes_free(c : pInflate_codes_state;
+                             var z : z_stream);
+begin
+  ZFREE(z, c);
+  {$IFDEF STRUTILS_DEBUG}
+  Tracev('inflate:       codes free');
+  {$ENDIF}
+end;
+
+end.

+ 318 - 0
packages/base/paszlib/inffast.pas

@@ -0,0 +1,318 @@
+Unit InfFast;
+
+{
+  inffast.h and
+  inffast.c -- process literals and length/distance pairs fast
+  Copyright (C) 1995-1998 Mark Adler
+
+  Pascal tranlastion
+  Copyright (C) 1998 by Jacques Nomssi Nzali
+  For conditions of distribution and use, see copyright notice in readme.txt
+}
+
+
+interface
+
+{$I zconf.inc}
+
+uses
+  {$ifdef STRUTILS_DEBUG}
+  strutils,
+  {$ENDIF}
+  zutil, zbase;
+
+function inflate_fast( bl : uInt;
+                       bd : uInt;
+                       tl : pInflate_huft;
+                       td : pInflate_huft;
+                      var s : inflate_blocks_state;
+                      var z : z_stream) : int;
+
+
+implementation
+
+uses
+  infutil;
+
+
+{ Called with number of bytes left to write in window at least 258
+  (the maximum string length) and number of input bytes available
+  at least ten.  The ten bytes are six bytes for the longest length/
+  distance pair plus four bytes for overloading the bit buffer. }
+
+function inflate_fast( bl : uInt;
+                       bd : uInt;
+                       tl : pInflate_huft;
+                       td : pInflate_huft;
+                      var s : inflate_blocks_state;
+                      var z : z_stream) : int;
+
+var
+  t : pInflate_huft;      { temporary pointer }
+  e : uInt;               { extra bits or operation }
+  b : uLong;              { bit buffer }
+  k : uInt;               { bits in bit buffer }
+  p : pBytef;             { input data pointer }
+  n : uInt;               { bytes available there }
+  q : pBytef;             { output window write pointer }
+  m : uInt;               { bytes to end of window or read pointer }
+  ml : uInt;              { mask for literal/length tree }
+  md : uInt;              { mask for distance tree }
+  c : uInt;               { bytes to copy }
+  d : uInt;               { distance back to copy from }
+  r : pBytef;             { copy source pointer }
+begin
+  { load input, output, bit values (macro LOAD) }
+  p := z.next_in;
+  n := z.avail_in;
+  b := s.bitb;
+  k := s.bitk;
+  q := s.write;
+  if ptr2int(q) < ptr2int(s.read) then
+    m := uInt(ptr2int(s.read)-ptr2int(q)-1)
+  else
+    m := uInt(ptr2int(s.zend)-ptr2int(q));
+
+  { initialize masks }
+  ml := inflate_mask[bl];
+  md := inflate_mask[bd];
+
+  { do until not enough input or output space for fast loop }
+  repeat                      { assume called with (m >= 258) and (n >= 10) }
+    { get literal/length code }
+    {GRABBITS(20);}             { max bits for literal/length code }
+    while (k < 20) do
+    begin
+      Dec(n);
+      b := b or (uLong(p^) shl k);
+      Inc(p);
+      Inc(k, 8);
+    end;
+
+    t := @(huft_ptr(tl)^[uInt(b) and ml]);
+
+    e := t^.exop;
+    if (e = 0) then
+    begin
+      {DUMPBITS(t^.bits);}
+      b := b shr t^.bits;
+      Dec(k, t^.bits);
+     {$IFDEF STRUTILS_DEBUG}
+      if (t^.base >= $20) and (t^.base < $7f) then
+        Tracevv('inflate:         * literal '+char(t^.base))
+      else
+        Tracevv('inflate:         * literal '+ IntToStr(t^.base));
+      {$ENDIF}
+      q^ := Byte(t^.base);
+      Inc(q);
+      Dec(m);
+      continue;
+    end;
+    repeat
+      {DUMPBITS(t^.bits);}
+      b := b shr t^.bits;
+      Dec(k, t^.bits);
+
+      if (e and 16 <> 0) then
+      begin
+        { get extra bits for length }
+        e := e and 15;
+        c := t^.base + (uInt(b) and inflate_mask[e]);
+        {DUMPBITS(e);}
+        b := b shr e;
+        Dec(k, e);
+        {$IFDEF STRUTILS_DEBUG}
+        Tracevv('inflate:         * length ' + IntToStr(c));
+        {$ENDIF}
+        { decode distance base of block to copy }
+        {GRABBITS(15);}           { max bits for distance code }
+        while (k < 15) do
+        begin
+          Dec(n);
+          b := b or (uLong(p^) shl k);
+          Inc(p);
+          Inc(k, 8);
+        end;
+
+        t := @huft_ptr(td)^[uInt(b) and md];
+        e := t^.exop;
+        repeat
+          {DUMPBITS(t^.bits);}
+          b := b shr t^.bits;
+          Dec(k, t^.bits);
+
+          if (e and 16 <> 0) then
+          begin
+            { get extra bits to add to distance base }
+            e := e and 15;
+            {GRABBITS(e);}         { get extra bits (up to 13) }
+            while (k < e) do
+            begin
+              Dec(n);
+              b := b or (uLong(p^) shl k);
+              Inc(p);
+              Inc(k, 8);
+            end;
+
+            d := t^.base + (uInt(b) and inflate_mask[e]);
+            {DUMPBITS(e);}
+            b := b shr e;
+            Dec(k, e);
+
+            {$IFDEF STRUTILS_DEBUG}
+            Tracevv('inflate:         * distance '+IntToStr(d));
+            {$ENDIF}
+            { do the copy }
+            Dec(m, c);
+            if (uInt(ptr2int(q) - ptr2int(s.window)) >= d) then     { offset before dest }
+            begin                                  {  just copy }
+              r := q;
+              Dec(r, d);
+              q^ := r^;  Inc(q); Inc(r); Dec(c); { minimum count is three, }
+              q^ := r^;  Inc(q); Inc(r); Dec(c); { so unroll loop a little }
+            end
+            else                        { else offset after destination }
+            begin
+              e := d - uInt(ptr2int(q) - ptr2int(s.window)); { bytes from offset to end }
+              r := s.zend;
+              Dec(r, e);                  { pointer to offset }
+              if (c > e) then             { if source crosses, }
+              begin
+                Dec(c, e);                { copy to end of window }
+                repeat
+                  q^ := r^;
+                  Inc(q);
+                  Inc(r);
+                  Dec(e);
+                until (e=0);
+                r := s.window;           { copy rest from start of window }
+              end;
+            end;
+            repeat                       { copy all or what's left }
+              q^ := r^;
+              Inc(q);
+              Inc(r);
+              Dec(c);
+            until (c = 0);
+            break;
+          end
+          else
+            if (e and 64 = 0) then
+            begin
+              Inc(t, t^.base + (uInt(b) and inflate_mask[e]));
+              e := t^.exop;
+            end
+          else
+          begin
+            z.msg := 'invalid distance code';
+            {UNGRAB}
+            c := z.avail_in-n;
+            if (k shr 3) < c then
+              c := k shr 3;
+            Inc(n, c);
+            Dec(p, c);
+            Dec(k, c shl 3);
+            {UPDATE}
+            s.bitb := b;
+            s.bitk := k;
+            z.avail_in := n;
+            Inc(z.total_in, ptr2int(p)-ptr2int(z.next_in));
+            z.next_in := p;
+            s.write := q;
+
+            inflate_fast := Z_DATA_ERROR;
+            exit;
+          end;
+        until FALSE;
+        break;
+      end;
+      if (e and 64 = 0) then
+      begin
+         {t += t->base;
+          e = (t += ((uInt)b & inflate_mask[e]))->exop;}
+
+        Inc(t, t^.base + (uInt(b) and inflate_mask[e]));
+        e := t^.exop;
+        if (e = 0) then
+        begin
+          {DUMPBITS(t^.bits);}
+          b := b shr t^.bits;
+          Dec(k, t^.bits);
+
+         {$IFDEF STRUTILS_DEBUG}
+          if (t^.base >= $20) and (t^.base < $7f) then
+            Tracevv('inflate:         * literal '+char(t^.base))
+          else
+            Tracevv('inflate:         * literal '+IntToStr(t^.base));
+          {$ENDIF}
+          q^ := Byte(t^.base);
+          Inc(q);
+          Dec(m);
+          break;
+        end;
+      end
+      else
+        if (e and 32 <> 0) then
+        begin
+          {$IFDEF STRUTILS_DEBUG}
+          Tracevv('inflate:         * end of block');
+          {$ENDIF}
+          {UNGRAB}
+          c := z.avail_in-n;
+          if (k shr 3) < c then
+            c := k shr 3;
+          Inc(n, c);
+          Dec(p, c);
+          Dec(k, c shl 3);
+          {UPDATE}
+          s.bitb := b;
+          s.bitk := k;
+          z.avail_in := n;
+          Inc(z.total_in, ptr2int(p)-ptr2int(z.next_in));
+          z.next_in := p;
+          s.write := q;
+          inflate_fast := Z_STREAM_END;
+          exit;
+        end
+        else
+        begin
+          z.msg := 'invalid literal/length code';
+          {UNGRAB}
+          c := z.avail_in-n;
+          if (k shr 3) < c then
+            c := k shr 3;
+          Inc(n, c);
+          Dec(p, c);
+          Dec(k, c shl 3);
+          {UPDATE}
+          s.bitb := b;
+          s.bitk := k;
+          z.avail_in := n;
+          Inc(z.total_in, ptr2int(p)-ptr2int(z.next_in));
+          z.next_in := p;
+          s.write := q;
+          inflate_fast := Z_DATA_ERROR;
+          exit;
+        end;
+    until FALSE;
+  until (m < 258) or (n < 10);
+
+  { not enough input or output--restore pointers and return }
+  {UNGRAB}
+  c := z.avail_in-n;
+  if (k shr 3) < c then
+    c := k shr 3;
+  Inc(n, c);
+  Dec(p, c);
+  Dec(k, c shl 3);
+  {UPDATE}
+  s.bitb := b;
+  s.bitk := k;
+  z.avail_in := n;
+  Inc(z.total_in, ptr2int(p)-ptr2int(z.next_in));
+  z.next_in := p;
+  s.write := q;
+  inflate_fast := Z_OK;
+end;
+
+end.

+ 780 - 0
packages/base/paszlib/inftrees.pas

@@ -0,0 +1,780 @@
+Unit InfTrees;
+
+{ inftrees.h -- header to use inftrees.c
+  inftrees.c -- generate Huffman trees for efficient decoding
+  Copyright (C) 1995-1998 Mark Adler
+
+  WARNING: this file should *not* be used by applications. It is
+   part of the implementation of the compression library and is
+   subject to change.
+
+  Pascal tranlastion
+  Copyright (C) 1998 by Jacques Nomssi Nzali
+  For conditions of distribution and use, see copyright notice in readme.txt
+}
+
+interface
+
+{$I zconf.inc}
+
+uses
+  zutil, zbase;
+
+
+{ Maximum size of dynamic tree.  The maximum found in a long but non-
+  exhaustive search was 1004 huft structures (850 for length/literals
+  and 154 for distances, the latter actually the result of an
+  exhaustive search).  The actual maximum is not known, but the
+  value below is more than safe. }
+const
+  MANY = 1440;
+
+
+{$ifdef DEBUG}
+var
+  inflate_hufts : uInt;
+{$endif}
+
+function inflate_trees_bits(
+  var c : array of uIntf;  { 19 code lengths }
+  var bb : uIntf;          { bits tree desired/actual depth }
+  var tb : pinflate_huft;  { bits tree result }
+  var hp : array of Inflate_huft;      { space for trees }
+  var z : z_stream         { for messages }
+    ) : int;
+
+function inflate_trees_dynamic(
+    nl : uInt;                    { number of literal/length codes }
+    nd : uInt;                    { number of distance codes }
+    var c : Array of uIntf;           { that many (total) code lengths }
+    var bl : uIntf;               { literal desired/actual bit depth }
+    var bd : uIntf;               { distance desired/actual bit depth }
+var tl : pInflate_huft;           { literal/length tree result }
+var td : pInflate_huft;           { distance tree result }
+var hp : array of Inflate_huft;   { space for trees }
+var z : z_stream                  { for messages }
+     ) : int;
+
+function inflate_trees_fixed (
+    var bl : uIntf;               { literal desired/actual bit depth }
+    var bd : uIntf;               { distance desired/actual bit depth }
+    var tl : pInflate_huft;       { literal/length tree result }
+    var td : pInflate_huft;       { distance tree result }
+    var z : z_stream              { for memory allocation }
+     ) : int;
+
+
+implementation
+
+const
+ inflate_copyright = 'inflate 1.1.2 Copyright 1995-1998 Mark Adler';
+
+{
+  If you use the zlib library in a product, an acknowledgment is welcome
+  in the documentation of your product. If for some reason you cannot
+  include such an acknowledgment, I would appreciate that you keep this
+  copyright string in the executable of your product.
+}
+
+
+const
+{ Tables for deflate from PKZIP's appnote.txt. }
+  cplens : Array [0..30] Of uInt  { Copy lengths for literal codes 257..285 }
+     = (3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31,
+        35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0);
+        { actually lengths - 2; also see note #13 above about 258 }
+
+  invalid_code = 112;
+
+  cplext : Array [0..30] Of uInt  { Extra bits for literal codes 257..285 }
+     = (0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2,
+        3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0, invalid_code, invalid_code);
+
+  cpdist : Array [0..29] Of uInt { Copy offsets for distance codes 0..29 }
+     = (1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,
+        257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,
+        8193, 12289, 16385, 24577);
+
+  cpdext : Array [0..29] Of uInt { Extra bits for distance codes }
+     = (0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6,
+        7, 7, 8, 8, 9, 9, 10, 10, 11, 11,
+        12, 12, 13, 13);
+
+{  Huffman code decoding is performed using a multi-level table lookup.
+   The fastest way to decode is to simply build a lookup table whose
+   size is determined by the longest code.  However, the time it takes
+   to build this table can also be a factor if the data being decoded
+   is not very long.  The most common codes are necessarily the
+   shortest codes, so those codes dominate the decoding time, and hence
+   the speed.  The idea is you can have a shorter table that decodes the
+   shorter, more probable codes, and then point to subsidiary tables for
+   the longer codes.  The time it costs to decode the longer codes is
+   then traded against the time it takes to make longer tables.
+
+   This results of this trade are in the variables lbits and dbits
+   below.  lbits is the number of bits the first level table for literal/
+   length codes can decode in one step, and dbits is the same thing for
+   the distance codes.  Subsequent tables are also less than or equal to
+   those sizes.  These values may be adjusted either when all of the
+   codes are shorter than that, in which case the longest code length in
+   bits is used, or when the shortest code is *longer* than the requested
+   table size, in which case the length of the shortest code in bits is
+   used.
+
+   There are two different values for the two tables, since they code a
+   different number of possibilities each.  The literal/length table
+   codes 286 possible values, or in a flat code, a little over eight
+   bits.  The distance table codes 30 possible values, or a little less
+   than five bits, flat.  The optimum values for speed end up being
+   about one bit more than those, so lbits is 8+1 and dbits is 5+1.
+   The optimum values may differ though from machine to machine, and
+   possibly even between compilers.  Your mileage may vary. }
+
+
+{ If BMAX needs to be larger than 16, then h and x[] should be uLong. }
+const
+  BMAX = 15;         { maximum bit length of any code }
+
+{$DEFINE USE_PTR}
+
+function huft_build(
+var b : array of uIntf;    { code lengths in bits (all assumed <= BMAX) }
+    n : uInt;              { number of codes (assumed <= N_MAX) }
+    s : uInt;              { number of simple-valued codes (0..s-1) }
+const d : array of uIntf;  { list of base values for non-simple codes }
+{ array of word }
+const e : array of uIntf;  { list of extra bits for non-simple codes }
+{ array of byte }
+  t : ppInflate_huft;     { result: starting table }
+var m : uIntf;             { maximum lookup bits, returns actual }
+var hp : array of inflate_huft;  { space for trees }
+var hn : uInt;             { hufts used in space }
+var v : array of uIntf     { working area: values in order of bit length }
+   ) : int;
+{ Given a list of code lengths and a maximum table size, make a set of
+  tables to decode that set of codes.  Return Z_OK on success, Z_BUF_ERROR
+  if the given code set is incomplete (the tables are still built in this
+  case), Z_DATA_ERROR if the input is invalid (an over-subscribed set of
+  lengths), or Z_MEM_ERROR if not enough memory. }
+Var
+  a : uInt;                     { counter for codes of length k }
+  c : Array [0..BMAX] Of uInt;  { bit length count table }
+  f : uInt;                     { i repeats in table every f entries }
+  g : int;                      { maximum code length }
+  h : int;                      { table level }
+  i : uInt;  {register}         { counter, current code }
+  j : uInt;  {register}         { counter }
+  k : Int;   {register}         { number of bits in current code }
+  l : int;                      { bits per table (returned in m) }
+  mask : uInt;                  { (1 shl w) - 1, to avoid cc -O bug on HP }
+  p : ^uIntf; {register}        { pointer into c[], b[], or v[] }
+  q : pInflate_huft;            { points to current table }
+  r : inflate_huft;             { table entry for structure assignment }
+  u : Array [0..BMAX-1] Of pInflate_huft; { table stack }
+  w : int;   {register}         { bits before this table = (l*h) }
+  x : Array [0..BMAX] Of uInt;  { bit offsets, then code stack }
+  {$IFDEF USE_PTR}
+  xp : puIntf;                  { pointer into x }
+  {$ELSE}
+  xp : uInt;
+  {$ENDIF}
+  y : int;                      { number of dummy codes added }
+  z : uInt;                     { number of entries in current table }
+Begin
+  { Generate counts for each bit length }
+  FillChar(c,SizeOf(c),0) ;     { clear c[] }
+
+  for i := 0 to n-1 do
+    Inc (c[b[i]]);              { assume all entries <= BMAX }
+
+  If (c[0] = n) Then            { null input--all zero length codes }
+  Begin
+    t^ := pInflate_huft(NIL);
+    m := 0 ;
+    huft_build := Z_OK ;
+    Exit;
+  End ;
+
+  { Find minimum and maximum length, bound [m] by those }
+  l := m;
+  for j:=1 To BMAX do
+    if (c[j] <> 0) then
+      break;
+  k := j ;                      { minimum code length }
+  if (uInt(l) < j) then
+    l := j;
+  for i := BMAX downto 1 do
+    if (c[i] <> 0) then
+      break ;
+  g := i ;                      { maximum code length }
+  if (uInt(l) > i) then
+     l := i;
+  m := l;
+
+  { Adjust last length count to fill out codes, if needed }
+  y := 1 shl j ;
+  while (j < i) do
+  begin
+    Dec(y, c[j]) ;
+    if (y < 0) then
+    begin
+      huft_build := Z_DATA_ERROR;   { bad input: more codes than bits }
+      exit;
+    end ;
+    Inc(j) ;
+    y := y shl 1
+  end;
+  Dec (y, c[i]) ;
+  if (y < 0) then
+  begin
+    huft_build := Z_DATA_ERROR;     { bad input: more codes than bits }
+    exit;
+  end;
+  Inc(c[i], y);
+
+  { Generate starting offsets into the value table FOR each length }
+  {$IFDEF USE_PTR}
+  x[1] := 0;
+  j := 0;
+
+  p := @c[1];
+  xp := @x[2];
+
+  dec(i);               { note that i = g from above }
+  WHILE (i > 0) DO
+  BEGIN
+    inc(j, p^);
+    xp^ := j;
+    inc(p);
+    inc(xp);
+    dec(i);
+  END;
+  {$ELSE}
+  x[1] := 0;
+  j := 0 ;
+  for i := 1 to g do
+  begin
+    x[i] := j;
+    Inc(j, c[i]);
+  end;
+  {$ENDIF}
+
+  { Make a table of values in order of bit lengths }
+  for i := 0 to n-1 do
+  begin
+    j := b[i];
+    if (j <> 0) then
+    begin
+      v[ x[j] ] := i;
+      Inc(x[j]);
+    end;
+  end;
+  n := x[g];                     { set n to length of v }
+
+  { Generate the Huffman codes and for each, make the table entries }
+  i := 0 ;
+  x[0] := 0 ;                   { first Huffman code is zero }
+  p := Addr(v) ;                { grab values in bit order }
+  h := -1 ;                     { no tables yet--level -1 }
+  w := -l ;                     { bits decoded = (l*h) }
+
+  u[0] := pInflate_huft(NIL);   { just to keep compilers happy }
+  q := pInflate_huft(NIL);      { ditto }
+  z := 0 ;                      { ditto }
+
+  { go through the bit lengths (k already is bits in shortest code) }
+  while (k <= g) Do
+  begin
+    a := c[k] ;
+    while (a<>0) Do
+    begin
+      Dec (a) ;
+      { here i is the Huffman code of length k bits for value p^ }
+      { make tables up to required level }
+      while (k > w + l) do
+      begin
+
+        Inc (h) ;
+        Inc (w, l);              { add bits already decoded }
+                                 { previous table always l bits }
+        { compute minimum size table less than or equal to l bits }
+
+        { table size upper limit }
+        z := g - w;
+        If (z > uInt(l)) Then
+          z := l;
+
+        { try a k-w bit table }
+        j := k - w;
+        f := 1 shl j;
+        if (f > a+1) Then        { too few codes for k-w bit table }
+        begin
+          Dec(f, a+1);           { deduct codes from patterns left }
+          {$IFDEF USE_PTR}
+          xp := Addr(c[k]);
+
+          if (j < z) then
+          begin
+            Inc(j);
+            while (j < z) do
+            begin                { try smaller tables up to z bits }
+              f := f shl 1;
+              Inc (xp) ;
+              If (f <= xp^) Then
+                break;           { enough codes to use up j bits }
+              Dec(f, xp^);       { else deduct codes from patterns }
+              Inc(j);
+            end;
+          end;
+          {$ELSE}
+          xp := k;
+
+          if (j < z) then
+          begin
+            Inc (j) ;
+            While (j < z) Do
+            begin                 { try smaller tables up to z bits }
+              f := f * 2;
+              Inc (xp) ;
+              if (f <= c[xp]) then
+                Break ;           { enough codes to use up j bits }
+              Dec (f, c[xp]) ;      { else deduct codes from patterns }
+              Inc (j);
+            end;
+          end;
+          {$ENDIF}
+        end;
+
+        z := 1 shl j;            { table entries for j-bit table }
+
+        { allocate new table }
+        if (hn + z > MANY) then { (note: doesn't matter for fixed) }
+        begin
+          huft_build := Z_MEM_ERROR;     { not enough memory }
+          exit;
+        end;
+
+        q := @hp[hn];
+        u[h] := q;
+        Inc(hn, z);
+
+        { connect to last table, if there is one }
+        if (h <> 0) then
+        begin
+          x[h] := i;             { save pattern for backing up }
+          r.bits := Byte(l);     { bits to dump before this table }
+          r.exop := Byte(j);     { bits in this table }
+          j := i shr (w - l);
+          {r.base := uInt( q - u[h-1] -j);}   { offset to this table }
+          r.base := (ptr2int(q) - ptr2int(u[h-1]) ) div sizeof(q^) - j;
+          huft_Ptr(u[h-1])^[j] := r;  { connect to last table }
+        end
+        else
+          t^ := q;               { first table is returned result }
+      end;
+
+      { set up table entry in r }
+      r.bits := Byte(k - w);
+
+      { C-code: if (p >= v + n) - see ZUTIL.PAS for comments }
+
+      if ptr2int(p)>=ptr2int(@(v[n])) then  { also works under DPMI ?? }
+        r.exop := 128 + 64                  { out of values--invalid code }
+      else
+        if (p^ < s) then
+        begin
+          if (p^ < 256) then     { 256 is end-of-block code }
+            r.exop := 0
+          Else
+            r.exop := 32 + 64;   { EOB_code; }
+          r.base := p^;          { simple code is just the value }
+          Inc(p);
+        end
+        Else
+        begin
+          r.exop := Byte(e[p^-s] + 16 + 64);  { non-simple--look up in lists }
+          r.base := d[p^-s];
+          Inc (p);
+        end ;
+
+      { fill code-like entries with r }
+      f := 1 shl (k - w);
+      j := i shr w;
+      while (j < z) do
+      begin
+        huft_Ptr(q)^[j] := r;
+        Inc(j, f);
+      end;
+
+      { backwards increment the k-bit code i }
+      j := 1 shl (k-1) ;
+      while (i and j) <> 0 do
+      begin
+        i := i xor j;         { bitwise exclusive or }
+        j := j shr 1
+      end ;
+      i := i xor j;
+
+      { backup over finished tables }
+      mask := (1 shl w) - 1;   { needed on HP, cc -O bug }
+      while ((i and mask) <> x[h]) do
+      begin
+        Dec(h);                { don't need to update q }
+        Dec(w, l);
+        mask := (1 shl w) - 1;
+      end;
+
+    end;
+
+    Inc(k);
+  end;
+
+  { Return Z_BUF_ERROR if we were given an incomplete table }
+  if (y <> 0) And (g <> 1) then
+    huft_build := Z_BUF_ERROR
+  else
+    huft_build := Z_OK;
+end; { huft_build}
+
+
+function inflate_trees_bits(
+  var c : array of uIntf;  { 19 code lengths }
+  var bb : uIntf;          { bits tree desired/actual depth }
+  var tb : pinflate_huft;  { bits tree result }
+  var hp : array of Inflate_huft;      { space for trees }
+  var z : z_stream         { for messages }
+    ) : int;
+var
+  r : int;
+  hn : uInt;          { hufts used in space }
+  v : PuIntArray;     { work area for huft_build }
+begin
+  hn := 0;
+  v := PuIntArray( ZALLOC(z, 19, sizeof(uInt)) );
+  if (v = Z_NULL) then
+  begin
+    inflate_trees_bits := Z_MEM_ERROR;
+    exit;
+  end;
+
+  r := huft_build(c, 19, 19, cplens, cplext,
+                             {puIntf(Z_NULL), puIntf(Z_NULL),}
+                  @tb, bb, hp, hn, v^);
+  if (r = Z_DATA_ERROR) then
+    z.msg := 'oversubscribed dynamic bit lengths tree'
+  else
+    if (r = Z_BUF_ERROR) or (bb = 0) then
+    begin
+      z.msg := 'incomplete dynamic bit lengths tree';
+      r := Z_DATA_ERROR;
+    end;
+  ZFREE(z, v);
+  inflate_trees_bits := r;
+end;
+
+
+function inflate_trees_dynamic(
+    nl : uInt;                    { number of literal/length codes }
+    nd : uInt;                    { number of distance codes }
+    var c : Array of uIntf;           { that many (total) code lengths }
+    var bl : uIntf;          { literal desired/actual bit depth }
+    var bd : uIntf;          { distance desired/actual bit depth }
+var tl : pInflate_huft;           { literal/length tree result }
+var td : pInflate_huft;           { distance tree result }
+var hp : array of Inflate_huft;   { space for trees }
+var z : z_stream                  { for messages }
+     ) : int;
+var
+  r : int;
+  hn : uInt;          { hufts used in space }
+  v : PuIntArray;     { work area for huft_build }
+begin
+  hn := 0;
+  { allocate work area }
+  v := PuIntArray( ZALLOC(z, 288, sizeof(uInt)) );
+  if (v = Z_NULL) then
+  begin
+    inflate_trees_dynamic := Z_MEM_ERROR;
+    exit;
+  end;
+
+  { build literal/length tree }
+  r := huft_build(c, nl, 257, cplens, cplext, @tl, bl, hp, hn, v^);
+  if (r <> Z_OK) or (bl = 0) then
+  begin
+    if (r = Z_DATA_ERROR) then
+      z.msg := 'oversubscribed literal/length tree'
+    else
+      if (r <> Z_MEM_ERROR) then
+      begin
+        z.msg := 'incomplete literal/length tree';
+        r := Z_DATA_ERROR;
+      end;
+
+    ZFREE(z, v);
+    inflate_trees_dynamic := r;
+    exit;
+  end;
+
+  { build distance tree }
+  r := huft_build(puIntArray(@c[nl])^, nd, 0,
+                  cpdist, cpdext, @td, bd, hp, hn, v^);
+  if (r <> Z_OK) or ((bd = 0) and (nl > 257)) then
+  begin
+    if (r = Z_DATA_ERROR) then
+      z.msg := 'oversubscribed literal/length tree'
+    else
+      if (r = Z_BUF_ERROR) then
+      begin
+{$ifdef PKZIP_BUG_WORKAROUND}
+        r := Z_OK;
+      end;
+{$else}
+        z.msg := 'incomplete literal/length tree';
+        r := Z_DATA_ERROR;
+      end
+      else
+        if (r <> Z_MEM_ERROR) then
+        begin
+          z.msg := 'empty distance tree with lengths';
+          r := Z_DATA_ERROR;
+        end;
+    ZFREE(z, v);
+    inflate_trees_dynamic := r;
+    exit;
+{$endif}
+  end;
+
+  { done }
+  ZFREE(z, v);
+  inflate_trees_dynamic := Z_OK;
+end;
+
+{$UNDEF BUILDFIXED}
+
+{ build fixed tables only once--keep them here }
+{$IFNDEF BUILDFIXED}
+{ locals }
+const
+  fixed_built : Boolean = false;
+  FIXEDH = 544;      { number of hufts used by fixed tables }
+var
+  fixed_mem : array[0..FIXEDH-1] of inflate_huft;
+  fixed_bl : uInt;
+  fixed_bd : uInt;
+  fixed_tl : pInflate_huft;
+  fixed_td : pInflate_huft;
+
+{$ELSE}
+
+{ inffixed.h -- table for decoding fixed codes }
+
+{local}
+const
+  fixed_bl = uInt(9);
+{local}
+const
+  fixed_bd = uInt(5);
+{local}
+const
+  fixed_tl : array [0..288-1] of inflate_huft = (
+    Exop,             { number of extra bits or operation }
+    bits : Byte;      { number of bits in this code or subcode }
+    {pad : uInt;}       { pad structure to a power of 2 (4 bytes for }
+                      {  16-bit, 8 bytes for 32-bit int's) }
+    base : uInt;      { literal, length base, or distance base }
+                      { or table offset }
+
+    ((96,7),256), ((0,8),80), ((0,8),16), ((84,8),115), ((82,7),31),
+    ((0,8),112), ((0,8),48), ((0,9),192), ((80,7),10), ((0,8),96),
+    ((0,8),32), ((0,9),160), ((0,8),0), ((0,8),128), ((0,8),64),
+    ((0,9),224), ((80,7),6), ((0,8),88), ((0,8),24), ((0,9),144),
+    ((83,7),59), ((0,8),120), ((0,8),56), ((0,9),208), ((81,7),17),
+    ((0,8),104), ((0,8),40), ((0,9),176), ((0,8),8), ((0,8),136),
+    ((0,8),72), ((0,9),240), ((80,7),4), ((0,8),84), ((0,8),20),
+    ((85,8),227), ((83,7),43), ((0,8),116), ((0,8),52), ((0,9),200),
+    ((81,7),13), ((0,8),100), ((0,8),36), ((0,9),168), ((0,8),4),
+    ((0,8),132), ((0,8),68), ((0,9),232), ((80,7),8), ((0,8),92),
+    ((0,8),28), ((0,9),152), ((84,7),83), ((0,8),124), ((0,8),60),
+    ((0,9),216), ((82,7),23), ((0,8),108), ((0,8),44), ((0,9),184),
+    ((0,8),12), ((0,8),140), ((0,8),76), ((0,9),248), ((80,7),3),
+    ((0,8),82), ((0,8),18), ((85,8),163), ((83,7),35), ((0,8),114),
+    ((0,8),50), ((0,9),196), ((81,7),11), ((0,8),98), ((0,8),34),
+    ((0,9),164), ((0,8),2), ((0,8),130), ((0,8),66), ((0,9),228),
+    ((80,7),7), ((0,8),90), ((0,8),26), ((0,9),148), ((84,7),67),
+    ((0,8),122), ((0,8),58), ((0,9),212), ((82,7),19), ((0,8),106),
+    ((0,8),42), ((0,9),180), ((0,8),10), ((0,8),138), ((0,8),74),
+    ((0,9),244), ((80,7),5), ((0,8),86), ((0,8),22), ((192,8),0),
+    ((83,7),51), ((0,8),118), ((0,8),54), ((0,9),204), ((81,7),15),
+    ((0,8),102), ((0,8),38), ((0,9),172), ((0,8),6), ((0,8),134),
+    ((0,8),70), ((0,9),236), ((80,7),9), ((0,8),94), ((0,8),30),
+    ((0,9),156), ((84,7),99), ((0,8),126), ((0,8),62), ((0,9),220),
+    ((82,7),27), ((0,8),110), ((0,8),46), ((0,9),188), ((0,8),14),
+    ((0,8),142), ((0,8),78), ((0,9),252), ((96,7),256), ((0,8),81),
+    ((0,8),17), ((85,8),131), ((82,7),31), ((0,8),113), ((0,8),49),
+    ((0,9),194), ((80,7),10), ((0,8),97), ((0,8),33), ((0,9),162),
+    ((0,8),1), ((0,8),129), ((0,8),65), ((0,9),226), ((80,7),6),
+    ((0,8),89), ((0,8),25), ((0,9),146), ((83,7),59), ((0,8),121),
+    ((0,8),57), ((0,9),210), ((81,7),17), ((0,8),105), ((0,8),41),
+    ((0,9),178), ((0,8),9), ((0,8),137), ((0,8),73), ((0,9),242),
+    ((80,7),4), ((0,8),85), ((0,8),21), ((80,8),258), ((83,7),43),
+    ((0,8),117), ((0,8),53), ((0,9),202), ((81,7),13), ((0,8),101),
+    ((0,8),37), ((0,9),170), ((0,8),5), ((0,8),133), ((0,8),69),
+    ((0,9),234), ((80,7),8), ((0,8),93), ((0,8),29), ((0,9),154),
+    ((84,7),83), ((0,8),125), ((0,8),61), ((0,9),218), ((82,7),23),
+    ((0,8),109), ((0,8),45), ((0,9),186), ((0,8),13), ((0,8),141),
+    ((0,8),77), ((0,9),250), ((80,7),3), ((0,8),83), ((0,8),19),
+    ((85,8),195), ((83,7),35), ((0,8),115), ((0,8),51), ((0,9),198),
+    ((81,7),11), ((0,8),99), ((0,8),35), ((0,9),166), ((0,8),3),
+    ((0,8),131), ((0,8),67), ((0,9),230), ((80,7),7), ((0,8),91),
+    ((0,8),27), ((0,9),150), ((84,7),67), ((0,8),123), ((0,8),59),
+    ((0,9),214), ((82,7),19), ((0,8),107), ((0,8),43), ((0,9),182),
+    ((0,8),11), ((0,8),139), ((0,8),75), ((0,9),246), ((80,7),5),
+    ((0,8),87), ((0,8),23), ((192,8),0), ((83,7),51), ((0,8),119),
+    ((0,8),55), ((0,9),206), ((81,7),15), ((0,8),103), ((0,8),39),
+    ((0,9),174), ((0,8),7), ((0,8),135), ((0,8),71), ((0,9),238),
+    ((80,7),9), ((0,8),95), ((0,8),31), ((0,9),158), ((84,7),99),
+    ((0,8),127), ((0,8),63), ((0,9),222), ((82,7),27), ((0,8),111),
+    ((0,8),47), ((0,9),190), ((0,8),15), ((0,8),143), ((0,8),79),
+    ((0,9),254), ((96,7),256), ((0,8),80), ((0,8),16), ((84,8),115),
+    ((82,7),31), ((0,8),112), ((0,8),48), ((0,9),193), ((80,7),10),
+    ((0,8),96), ((0,8),32), ((0,9),161), ((0,8),0), ((0,8),128),
+    ((0,8),64), ((0,9),225), ((80,7),6), ((0,8),88), ((0,8),24),
+    ((0,9),145), ((83,7),59), ((0,8),120), ((0,8),56), ((0,9),209),
+    ((81,7),17), ((0,8),104), ((0,8),40), ((0,9),177), ((0,8),8),
+    ((0,8),136), ((0,8),72), ((0,9),241), ((80,7),4), ((0,8),84),
+    ((0,8),20), ((85,8),227), ((83,7),43), ((0,8),116), ((0,8),52),
+    ((0,9),201), ((81,7),13), ((0,8),100), ((0,8),36), ((0,9),169),
+    ((0,8),4), ((0,8),132), ((0,8),68), ((0,9),233), ((80,7),8),
+    ((0,8),92), ((0,8),28), ((0,9),153), ((84,7),83), ((0,8),124),
+    ((0,8),60), ((0,9),217), ((82,7),23), ((0,8),108), ((0,8),44),
+    ((0,9),185), ((0,8),12), ((0,8),140), ((0,8),76), ((0,9),249),
+    ((80,7),3), ((0,8),82), ((0,8),18), ((85,8),163), ((83,7),35),
+    ((0,8),114), ((0,8),50), ((0,9),197), ((81,7),11), ((0,8),98),
+    ((0,8),34), ((0,9),165), ((0,8),2), ((0,8),130), ((0,8),66),
+    ((0,9),229), ((80,7),7), ((0,8),90), ((0,8),26), ((0,9),149),
+    ((84,7),67), ((0,8),122), ((0,8),58), ((0,9),213), ((82,7),19),
+    ((0,8),106), ((0,8),42), ((0,9),181), ((0,8),10), ((0,8),138),
+    ((0,8),74), ((0,9),245), ((80,7),5), ((0,8),86), ((0,8),22),
+    ((192,8),0), ((83,7),51), ((0,8),118), ((0,8),54), ((0,9),205),
+    ((81,7),15), ((0,8),102), ((0,8),38), ((0,9),173), ((0,8),6),
+    ((0,8),134), ((0,8),70), ((0,9),237), ((80,7),9), ((0,8),94),
+    ((0,8),30), ((0,9),157), ((84,7),99), ((0,8),126), ((0,8),62),
+    ((0,9),221), ((82,7),27), ((0,8),110), ((0,8),46), ((0,9),189),
+    ((0,8),14), ((0,8),142), ((0,8),78), ((0,9),253), ((96,7),256),
+    ((0,8),81), ((0,8),17), ((85,8),131), ((82,7),31), ((0,8),113),
+    ((0,8),49), ((0,9),195), ((80,7),10), ((0,8),97), ((0,8),33),
+    ((0,9),163), ((0,8),1), ((0,8),129), ((0,8),65), ((0,9),227),
+    ((80,7),6), ((0,8),89), ((0,8),25), ((0,9),147), ((83,7),59),
+    ((0,8),121), ((0,8),57), ((0,9),211), ((81,7),17), ((0,8),105),
+    ((0,8),41), ((0,9),179), ((0,8),9), ((0,8),137), ((0,8),73),
+    ((0,9),243), ((80,7),4), ((0,8),85), ((0,8),21), ((80,8),258),
+    ((83,7),43), ((0,8),117), ((0,8),53), ((0,9),203), ((81,7),13),
+    ((0,8),101), ((0,8),37), ((0,9),171), ((0,8),5), ((0,8),133),
+    ((0,8),69), ((0,9),235), ((80,7),8), ((0,8),93), ((0,8),29),
+    ((0,9),155), ((84,7),83), ((0,8),125), ((0,8),61), ((0,9),219),
+    ((82,7),23), ((0,8),109), ((0,8),45), ((0,9),187), ((0,8),13),
+    ((0,8),141), ((0,8),77), ((0,9),251), ((80,7),3), ((0,8),83),
+    ((0,8),19), ((85,8),195), ((83,7),35), ((0,8),115), ((0,8),51),
+    ((0,9),199), ((81,7),11), ((0,8),99), ((0,8),35), ((0,9),167),
+    ((0,8),3), ((0,8),131), ((0,8),67), ((0,9),231), ((80,7),7),
+    ((0,8),91), ((0,8),27), ((0,9),151), ((84,7),67), ((0,8),123),
+    ((0,8),59), ((0,9),215), ((82,7),19), ((0,8),107), ((0,8),43),
+    ((0,9),183), ((0,8),11), ((0,8),139), ((0,8),75), ((0,9),247),
+    ((80,7),5), ((0,8),87), ((0,8),23), ((192,8),0), ((83,7),51),
+    ((0,8),119), ((0,8),55), ((0,9),207), ((81,7),15), ((0,8),103),
+    ((0,8),39), ((0,9),175), ((0,8),7), ((0,8),135), ((0,8),71),
+    ((0,9),239), ((80,7),9), ((0,8),95), ((0,8),31), ((0,9),159),
+    ((84,7),99), ((0,8),127), ((0,8),63), ((0,9),223), ((82,7),27),
+    ((0,8),111), ((0,8),47), ((0,9),191), ((0,8),15), ((0,8),143),
+    ((0,8),79), ((0,9),255)
+  );
+
+{local}
+const
+  fixed_td : array[0..32-1] of inflate_huft = (
+(Exop:80;bits:5;base:1),      (Exop:87;bits:5;base:257),   (Exop:83;bits:5;base:17),
+(Exop:91;bits:5;base:4097),   (Exop:81;bits:5;base),       (Exop:89;bits:5;base:1025),
+(Exop:85;bits:5;base:65),     (Exop:93;bits:5;base:16385), (Exop:80;bits:5;base:3),
+(Exop:88;bits:5;base:513),    (Exop:84;bits:5;base:33),    (Exop:92;bits:5;base:8193),
+(Exop:82;bits:5;base:9),      (Exop:90;bits:5;base:2049),  (Exop:86;bits:5;base:129),
+(Exop:192;bits:5;base:24577), (Exop:80;bits:5;base:2),     (Exop:87;bits:5;base:385),
+(Exop:83;bits:5;base:25),     (Exop:91;bits:5;base:6145),  (Exop:81;bits:5;base:7),
+(Exop:89;bits:5;base:1537),   (Exop:85;bits:5;base:97),    (Exop:93;bits:5;base:24577),
+(Exop:80;bits:5;base:4),      (Exop:88;bits:5;base:769),   (Exop:84;bits:5;base:49),
+(Exop:92;bits:5;base:12289),  (Exop:82;bits:5;base:13),    (Exop:90;bits:5;base:3073),
+(Exop:86;bits:5;base:193),    (Exop:192;bits:5;base:24577)
+  );
+{$ENDIF}
+
+function inflate_trees_fixed(
+var bl : uIntf;              { literal desired/actual bit depth }
+var bd : uIntf;              { distance desired/actual bit depth }
+var tl : pInflate_huft;      { literal/length tree result }
+var td : pInflate_huft;      { distance tree result }
+var  z : z_stream            { for memory allocation }
+      ) : int;
+type
+  pFixed_table = ^fixed_table;
+  fixed_table = array[0..288-1] of uIntf;
+var
+  k : int;                   { temporary variable }
+  c : pFixed_table;          { length list for huft_build }
+  v : PuIntArray;            { work area for huft_build }
+var
+  f : uInt;                  { number of hufts used in fixed_mem }
+begin
+  { build fixed tables if not already (multiple overlapped executions ok) }
+  if not fixed_built then
+  begin
+    f := 0;
+
+    { allocate memory }
+    c := pFixed_table( ZALLOC(z, 288, sizeof(uInt)) );
+    if (c = Z_NULL) then
+    begin
+      inflate_trees_fixed := Z_MEM_ERROR;
+      exit;
+    end;
+    v := PuIntArray( ZALLOC(z, 288, sizeof(uInt)) );
+    if (v = Z_NULL) then
+    begin
+      ZFREE(z, c);
+      inflate_trees_fixed := Z_MEM_ERROR;
+      exit;
+    end;
+
+    { literal table }
+    for k := 0 to Pred(144) do
+      c^[k] := 8;
+    for k := 144 to Pred(256) do
+      c^[k] := 9;
+    for k := 256 to Pred(280) do
+      c^[k] := 7;
+    for k := 280 to Pred(288) do
+      c^[k] := 8;
+    fixed_bl := 9;
+    huft_build(c^, 288, 257, cplens, cplext, @fixed_tl, fixed_bl,
+               fixed_mem, f, v^);
+
+    { distance table }
+    for k := 0 to Pred(30) do
+      c^[k] := 5;
+    fixed_bd := 5;
+    huft_build(c^, 30, 0, cpdist, cpdext, @fixed_td, fixed_bd,
+               fixed_mem, f, v^);
+
+    { done }
+    ZFREE(z, v);
+    ZFREE(z, c);
+    fixed_built := True;
+  end;
+  bl := fixed_bl;
+  bd := fixed_bd;
+  tl := fixed_tl;
+  td := fixed_td;
+  inflate_trees_fixed := Z_OK;
+end; { inflate_trees_fixed }
+
+
+end.

+ 222 - 0
packages/base/paszlib/infutil.pas

@@ -0,0 +1,222 @@
+Unit infutil;
+
+{ types and macros common to blocks and codes
+  Copyright (C) 1995-1998 Mark Adler
+
+   WARNING: this file should *not* be used by applications. It is
+   part of the implementation of the compression library and is
+   subject to change.
+
+  Pascal tranlastion
+  Copyright (C) 1998 by Jacques Nomssi Nzali
+  For conditions of distribution and use, see copyright notice in readme.txt
+}
+
+interface
+
+{$I zconf.inc}
+
+uses
+  zutil, zbase;
+
+{ copy as much as possible from the sliding window to the output area }
+function inflate_flush(var s : inflate_blocks_state;
+                       var z : z_stream;
+                       r : int) : int;
+
+{ And'ing with mask[n] masks the lower n bits }
+const
+  inflate_mask : array[0..17-1] of uInt = (
+    $0000,
+    $0001, $0003, $0007, $000f, $001f, $003f, $007f, $00ff,
+    $01ff, $03ff, $07ff, $0fff, $1fff, $3fff, $7fff, $ffff);
+
+{procedure GRABBITS(j : int);}
+{procedure DUMPBITS(j : int);}
+{procedure NEEDBITS(j : int);}
+
+implementation
+
+{ macros for bit input with no checking and for returning unused bytes }
+procedure GRABBITS(j : int);
+begin
+  {while (k < j) do
+  begin
+    Dec(z^.avail_in);
+    Inc(z^.total_in);
+    b := b or (uLong(z^.next_in^) shl k);
+    Inc(z^.next_in);
+    Inc(k, 8);
+  end;}
+end;
+
+procedure DUMPBITS(j : int);
+begin
+  {b := b shr j;
+  Dec(k, j);}
+end;
+
+procedure NEEDBITS(j : int);
+begin
+ (*
+          while (k < j) do
+          begin
+            {NEEDBYTE;}
+            if (n <> 0) then
+              r :=Z_OK
+            else
+            begin
+              {UPDATE}
+              s.bitb := b;
+              s.bitk := k;
+              z.avail_in := n;
+              Inc(z.total_in, LongInt(p)-LongInt(z.next_in));
+              z.next_in := p;
+              s.write := q;
+              result := inflate_flush(s,z,r);
+              exit;
+            end;
+            Dec(n);
+            b := b or (uLong(p^) shl k);
+            Inc(p);
+            Inc(k, 8);
+          end;
+ *)
+end;
+
+procedure NEEDOUT;
+begin
+ (*
+  if (m = 0) then
+  begin
+    {WRAP}
+    if (q = s.zend) and (s.read <> s.window) then
+    begin
+      q := s.window;
+      if LongInt(q) < LongInt(s.read) then
+        m := uInt(LongInt(s.read)-LongInt(q)-1)
+      else
+        m := uInt(LongInt(s.zend)-LongInt(q));
+    end;
+
+    if (m = 0) then
+    begin
+      {FLUSH}
+      s.write := q;
+      r := inflate_flush(s,z,r);
+      q := s.write;
+      if LongInt(q) < LongInt(s.read) then
+        m := uInt(LongInt(s.read)-LongInt(q)-1)
+      else
+        m := uInt(LongInt(s.zend)-LongInt(q));
+
+      {WRAP}
+      if (q = s.zend) and (s.read <> s.window) then
+      begin
+        q := s.window;
+        if LongInt(q) < LongInt(s.read) then
+          m := uInt(LongInt(s.read)-LongInt(q)-1)
+        else
+          m := uInt(LongInt(s.zend)-LongInt(q));
+      end;
+
+      if (m = 0) then
+      begin
+        {UPDATE}
+        s.bitb := b;
+        s.bitk := k;
+        z.avail_in := n;
+        Inc(z.total_in, LongInt(p)-LongInt(z.next_in));
+        z.next_in := p;
+        s.write := q;
+        result := inflate_flush(s,z,r);
+        exit;
+      end;
+    end;
+  end;
+  r := Z_OK;
+ *)
+end;
+
+{ copy as much as possible from the sliding window to the output area }
+function inflate_flush(var s : inflate_blocks_state;
+                       var z : z_stream;
+                       r : int) : int;
+var
+  n : uInt;
+  p : pBytef;
+  q : pBytef;
+begin
+  { local copies of source and destination pointers }
+  p := z.next_out;
+  q := s.read;
+
+  { compute number of bytes to copy as far as end of window }
+  if ptr2int(q) <= ptr2int(s.write) then
+    n := uInt(ptr2int(s.write) - ptr2int(q))
+  else
+    n := uInt(ptr2int(s.zend) - ptr2int(q));
+  if (n > z.avail_out) then
+    n := z.avail_out;
+  if (n <> 0) and (r = Z_BUF_ERROR) then
+    r := Z_OK;
+
+  { update counters }
+  Dec(z.avail_out, n);
+  Inc(z.total_out, n);
+
+
+  { update check information }
+  if Assigned(s.checkfn) then
+  begin
+    s.check := s.checkfn(s.check, q, n);
+    z.adler := s.check;
+  end;
+
+  { copy as far as end of window }
+  zmemcpy(p, q, n);
+  Inc(p, n);
+  Inc(q, n);
+
+  { see if more to copy at beginning of window }
+  if (q = s.zend) then
+  begin
+    { wrap pointers }
+    q := s.window;
+    if (s.write = s.zend) then
+      s.write := s.window;
+
+    { compute bytes to copy }
+    n := uInt(ptr2int(s.write) - ptr2int(q));
+    if (n > z.avail_out) then
+      n := z.avail_out;
+    if (n <> 0) and (r = Z_BUF_ERROR) then
+      r := Z_OK;
+
+    { update counters }
+    Dec( z.avail_out, n);
+    Inc( z.total_out, n);
+
+    { update check information }
+    if Assigned(s.checkfn) then
+    begin
+      s.check := s.checkfn(s.check, q, n);
+      z.adler := s.check;
+    end;
+
+    { copy }
+    zmemcpy(p, q, n);
+    Inc(p, n);
+    Inc(q, n);
+  end;
+
+
+  { update pointers }
+  z.next_out := p;
+  s.read := q;
+
+  { done }
+  inflate_flush := r;
+end;
+
+end.

+ 251 - 0
packages/base/paszlib/minigzip.pas

@@ -0,0 +1,251 @@
+program minigzip;
+
+{
+ minigzip.c -- simulate gzip using the zlib compression library
+ Copyright (C) 1995-1998 Jean-loup Gailly.
+
+ minigzip is a minimal implementation of the gzip utility. This is
+ only an example of using zlib and isn't meant to replace the
+ full-featured gzip. No attempt is made to deal with file systems
+ limiting names to 14 or 8+3 characters, etc... Error checking is
+ very limited. So use minigzip only for testing; use gzip for the
+ real thing. On MSDOS, use only on file names without extension
+ or in pipe mode.
+
+  Pascal tranlastion based on code contributed by Francisco Javier Crespo
+  Copyright (C) 1998 by Jacques Nomssi Nzali
+  For conditions of distribution and use, see copyright notice in readme.txt
+}
+
+uses
+  {$IFDEF VER80}
+  WinCrt,
+  {$ENDIF}
+  gzio, zutil;
+
+const
+  BUFLEN       = 16384 ;
+  GZ_SUFFIX    = '.gz' ;
+
+{$DEFINE MAXSEF_64K}
+
+var
+  buf  : packed array [0..BUFLEN-1] of byte; { Global uses BSS instead of stack }
+  prog : string;
+
+{ ERROR =====================================================================
+
+  Display error message and exit
+
+============================================================================}
+
+procedure error (msg:string);
+begin
+  writeln (prog,': ',msg);
+  halt(1);
+end;
+
+
+{ GZ_COMPRESS ===============================================================
+
+  Compress input to output then close both files
+
+============================================================================}
+
+procedure gz_compress (var infile:file; outfile:gzFile);
+var
+  len   : uInt;
+  ioerr : integer;
+  err   : int;
+begin
+
+  while true do begin
+
+    {$I-}
+    blockread (infile, buf, BUFLEN, len);
+    {$I+}
+    ioerr := IOResult;
+    if (ioerr <> 0) then begin
+      writeln ('read error: ',ioerr);
+      halt(1);
+    end;
+
+    if (len = 0) then break;
+
+    if (gzwrite (outfile, @buf, len) <> len)
+      then error (gzerror (outfile, err));
+
+  end; {WHILE}
+
+  close (infile);
+  if (gzclose (outfile) <> 0{Z_OK})
+    then error ('gzclose error');
+end;
+
+
+{ GZ_UNCOMPRESS =============================================================
+
+  Uncompress input to output then close both files
+
+============================================================================}
+
+procedure gz_uncompress (infile:gzFile; var outfile:file);
+var
+  len     : int;
+  written : uInt;
+  ioerr   : integer;
+  err     : int;
+begin
+  while true do begin
+
+    len := gzread (infile, @buf, BUFLEN);
+    if (len < 0)
+      then error (gzerror (infile, err));
+    if (len = 0)
+      then break;
+
+    {$I-}
+    blockwrite (outfile, buf, len, written);
+    {$I+}
+    if (written <> len)
+      then error ('write error');
+
+  end; {WHILE}
+
+  {$I-}
+  close (outfile);
+  {$I+}
+  ioerr := IOResult;
+  if (ioerr <> 0) then begin
+    writeln ('close error: ',ioerr);
+    halt(1);
+  end;
+
+  if (gzclose (infile) <> 0{Z_OK})
+    then error ('gzclose error');
+end;
+
+
+{ FILE_COMPRESS =============================================================
+
+  Compress the given file:
+  create a corresponding .gz file and remove the original
+
+============================================================================}
+
+procedure file_compress (filename:string; mode:string);
+var
+  infile  : file;
+  outfile : gzFile;
+  ioerr   : integer;
+  outname : string;
+begin
+  Assign (infile, filename);
+  {$I-}
+  Reset (infile,1);
+  {$I+}
+  ioerr := IOResult;
+  if (ioerr <> 0) then begin
+    writeln ('open error: ',ioerr);
+    halt(1);
+  end;
+
+  outname := filename + GZ_SUFFIX;
+  outfile := gzopen (outname, mode);
+
+  if (outfile = NIL) then begin
+    writeln (prog,': can''t gzopen ',outname);
+    halt(1);
+  end;
+
+  gz_compress(infile, outfile);
+  erase (infile);
+end;
+
+
+{ FILE_UNCOMPRESS ===========================================================
+
+  Uncompress the given file and remove the original
+
+============================================================================}
+
+procedure file_uncompress (filename:string);
+var
+  inname  : string;
+  outname : string;
+  infile  : gzFile;
+  outfile : file;
+  ioerr   : integer;
+  len     : integer;
+begin
+  len := Length(filename);
+
+  if (copy(filename,len-2,3) = GZ_SUFFIX) then begin
+    inname := filename;
+    outname := copy(filename,0,len-3);
+  end
+  else begin
+    inname := filename + GZ_SUFFIX;
+    outname := filename;
+  end;
+
+  infile := gzopen (inname, 'r');
+  if (infile = NIL) then begin
+    writeln (prog,': can''t gzopen ',inname);
+    halt(1);
+  end;
+
+  Assign (outfile, outname);
+  {$I-}
+  Rewrite (outfile,1);
+  {$I+}
+  ioerr := IOResult;
+  if (ioerr <> 0) then begin
+    writeln ('open error: ',ioerr);
+    halt(1);
+  end;
+
+  gz_uncompress (infile, outfile);
+
+{ erase (infile); }
+end;
+
+
+{ MINIGZIP =================================================================}
+
+var
+
+  uncompr : boolean;
+  outmode : string[20];
+  i       : integer;
+  option  : string;
+
+begin
+  uncompr := false;
+  outmode := 'w6 ';
+  prog := ParamStr(0);
+
+  if (ParamCount = 0) then begin
+    writeln ('Error: STDIO/STDOUT not supported yet');
+    writeln;
+    writeln ('Usage:  minigzip [-d] [-f] [-h] [-1 to -9] <file>');
+    writeln ('  -d : decompress');
+    writeln ('  -f : compress with Z_FILTERED');
+    writeln ('  -h : compress with Z_HUFFMAN_ONLY');
+    writeln ('  -1 to -9 : compression level');
+    exit;
+  end;
+
+  for i:=1 to ParamCount do begin
+    option := ParamStr(i);
+    if (option = '-d') then uncompr := true;
+    if (option = '-f') then outmode[3] := 'f';
+    if (option = '-h') then outmode[3] := 'h';
+    if (option[1] = '-') and (option[2] >= '1') and (option[2] <= '9')
+      then outmode[2] := option[2];
+  end;
+
+  if (uncompr = true)
+    then file_uncompress (ParamStr(ParamCount))
+    else file_compress (ParamStr(ParamCount), outmode);
+end.

+ 332 - 0
packages/base/paszlib/paszlib.pas

@@ -0,0 +1,332 @@
+unit paszlib;
+
+interface
+
+uses
+  zbase;
+
+const
+  ZLIB_VERSION = '1.1.2';
+
+type
+  { Compatibility types }
+  PByte   = ^Byte;
+  Uint    = Cardinal;
+  Ulong   = Cardinal;
+  Ulongf  = ULong;
+  Pulongf = ^Ulongf;
+  z_off_t = longint;
+
+  TAllocfunc = function (opaque:pointer; items:uInt; size:uInt):pointer;
+  TFreeFunc = procedure (opaque:pointer; address:pointer);
+
+  TInternalState = record
+    end;
+  PInternalState = ^TInternalstate;
+
+  TZStream = z_stream;
+  PZstream = ^TZStream;
+
+  gzFile = pointer;
+
+
+const
+  Z_NO_FLUSH = 0;
+
+  Z_PARTIAL_FLUSH = 1;
+  Z_SYNC_FLUSH = 2;
+  Z_FULL_FLUSH = 3;
+  Z_FINISH = 4;
+
+  Z_OK = 0;
+  Z_STREAM_END = 1;
+  Z_NEED_DICT = 2;
+  Z_ERRNO = -(1);
+  Z_STREAM_ERROR = -(2);
+  Z_DATA_ERROR = -(3);
+  Z_MEM_ERROR = -(4);
+  Z_BUF_ERROR = -(5);
+  Z_VERSION_ERROR = -(6);
+
+  Z_NO_COMPRESSION = 0;
+  Z_BEST_SPEED = 1;
+  Z_BEST_COMPRESSION = 9;
+  Z_DEFAULT_COMPRESSION = -(1);
+
+  Z_FILTERED = 1;
+  Z_HUFFMAN_ONLY = 2;
+  Z_DEFAULT_STRATEGY = 0;
+
+  Z_BINARY = 0;
+  Z_ASCII = 1;
+  Z_UNKNOWN = 2;
+
+  Z_DEFLATED = 8;
+
+  Z_NULL = 0;
+
+function zlibVersion:string;
+function deflate(var strm:TZstream; flush:longint):longint;
+function deflateEnd(var strm:TZstream):longint;
+function inflate(var strm:TZstream; flush:longint):longint;
+function inflateEnd(var strm:TZstream):longint;
+function deflateSetDictionary(var strm:TZstream;dictionary : pchar; dictLength:uInt):longint;
+function deflateCopy(var dest,source:TZstream):longint;
+function deflateReset(var strm:TZstream):longint;
+function deflateParams(var strm:TZstream; level:longint; strategy:longint):longint;
+function inflateSetDictionary(var strm:TZStream;dictionary : pchar; dictLength:uInt):longint;
+function inflateSync(var strm:TZStream):longint;
+function inflateReset(var strm:TZStream):longint;
+function compress(dest:pchar;destLen:uLongf; source : pchar; sourceLen:uLong):longint;
+function compress2(dest:pchar;destLen:uLongf; source : pchar; sourceLen:uLong; level:longint):longint;
+function uncompress(dest:pchar;destLen:uLongf; source : pchar; sourceLen:uLong):longint;
+function gzopen(path:pchar; mode:pchar):gzFile;
+function gzsetparams(Thefile:gzFile; level:longint; strategy:longint):longint;
+function gzread(thefile:gzFile; buf : pointer; len:cardinal):longint;
+function gzwrite(thefile:gzFile; buf: pointer; len:cardinal):longint;
+function gzputs(thefile:gzFile; s:pchar):longint;
+function gzgets(thefile:gzFile; buf:pchar; len:longint):pchar;
+function gzputc(thefile:gzFile; c:char):longint;
+function gzgetc(thefile:gzFile):char;
+function gzflush(thefile:gzFile; flush:longint):longint;
+function gzseek(thefile:gzFile; offset:z_off_t; whence:longint):z_off_t;
+function gzrewind(thefile:gzFile):longint;
+function gztell(thefile:gzFile):z_off_t;
+function gzeof(thefile:gzFile):longbool;
+function gzclose(thefile:gzFile):longint;
+function gzerror(thefile:gzFile; var errnum:longint):string;
+function adler32(theadler:uLong;buf : pchar; len:uInt):uLong;
+function crc32(thecrc:uLong;buf : pchar; len:uInt):uLong;
+function deflateInit_(var strm:TZStream; level:longint; version:pchar; stream_size:longint):longint;
+function inflateInit_(var strm:TZStream; version:pchar; stream_size:longint):longint;
+function deflateInit2_(var strm:TZStream; level:longint; method:longint; windowBits:longint; memLevel:longint;strategy:longint; version:pchar; stream_size:longint):longint;
+function inflateInit2_(var strm:TZStream; windowBits:longint; version:pchar; stream_size:longint):longint;
+function deflateInit(var strm:TZStream;level : longint) : longint;
+function inflateInit(var strm:TZStream) : longint;
+function deflateInit2(var strm:TZStream;level,method,windowBits,memLevel,strategy : longint) : longint;
+function inflateInit2(var strm:TZStream; windowBits : longint) : longint;
+function zError(err:longint):string;
+function inflateSyncPoint(z:PZstream):longint;
+function get_crc_table:pointer;
+
+implementation
+
+uses
+  zutil,zdeflate,zinflate,zcompres,zuncompr,gzio,adler,gzcrc;
+
+function zlibVersion:string;
+begin
+  zlibversion:=zbase.zlibversion;
+end;
+
+function deflate(var strm:TZstream; flush:longint):longint;
+begin
+  deflate:=zdeflate.deflate(strm,flush);
+end;
+
+function deflateEnd(var strm:TZstream):longint;
+begin
+  deflateEnd:=zdeflate.deflateEnd(strm);
+end;
+
+function inflate(var strm:TZstream; flush:longint):longint;
+begin
+  inflate:=zinflate.inflate(strm,flush);
+end;
+
+function inflateEnd(var strm:TZstream):longint;
+begin
+  inflateEnd:=zinflate.inflateEnd(strm);
+end;
+
+function deflateSetDictionary(var strm:TZstream;dictionary : pchar; dictLength:uInt):longint;
+begin
+  deflateSetDictionary:=zdeflate.deflateSetDictionary(strm,pbytef(dictionary),dictlength);
+end;
+
+function deflateCopy(var dest,source:TZstream):longint;
+begin
+  deflateCopy:=zdeflate.deflateCopy(@dest,@source);
+end;
+
+function deflateReset(var strm:TZstream):longint;
+begin
+  deflateReset:=zdeflate.deflateReset(strm);
+end;
+
+function deflateParams(var strm:TZstream; level:longint; strategy:longint):longint;
+begin
+  deflateParams:=zdeflate.deflateParams(strm,level,strategy);
+end;
+
+function inflateSetDictionary(var strm:TZStream;dictionary : pchar; dictLength:uInt):longint;
+begin
+  inflateSetDictionary:=zinflate.inflateSetDictionary(strm,pbytef(dictionary),dictlength);
+end;
+
+function inflateSync(var strm:TZStream):longint;
+begin
+  inflateSync:=zinflate.inflateSync(strm);
+end;
+
+function inflateReset(var strm:TZStream):longint;
+begin
+  inflateReset:=zinflate.inflateReset(strm);
+end;
+
+function compress(dest:pchar;destLen:uLongf; source : pchar; sourceLen:uLong):longint;
+begin
+  compress:=zcompres.compress(pbytef(dest),destlen,pbytef(source),sourcelen);
+end;
+
+function compress2(dest:pchar;destLen:uLongf; source : pchar; sourceLen:uLong; level:longint):longint;
+begin
+  compress2:=zcompres.compress2(pbytef(dest),destlen,pbytef(source),sourcelen,level);
+end;
+
+function uncompress(dest:pchar;destLen:uLongf; source : pchar; sourceLen:uLong):longint;
+begin
+  uncompress:=zuncompr.uncompress(pbytef(dest),destlen,pbytef(source),sourcelen);
+end;
+
+function gzopen(path:pchar; mode:pchar):gzFile;
+begin
+  gzopen:=gzio.gzopen(path,mode);
+end;
+
+function gzsetparams(Thefile:gzFile; level:longint; strategy:longint):longint;
+begin
+  gzsetparams:=gzio.gzsetparams(thefile,level,strategy);
+end;
+
+function gzread(thefile:gzFile; buf : pointer; len:cardinal):longint;
+begin
+  gzread:=gzio.gzread(thefile,buf,len);
+end;
+
+function gzwrite(thefile:gzFile; buf: pointer; len:cardinal):longint;
+begin
+  gzwrite:=gzio.gzwrite(thefile,buf,len);
+end;
+
+function gzputs(thefile:gzFile; s:pchar):longint;
+begin
+  gzputs:=gzio.gzputs(thefile,s);
+end;
+
+function gzgets(thefile:gzFile; buf:pchar; len:longint):pchar;
+begin
+  gzgets:=gzio.gzgets(thefile,buf,len);
+end;
+
+function gzputc(thefile:gzFile; c:char):longint;
+begin
+  gzputc:=gzio.gzputc(thefile,c);
+end;
+
+function gzgetc(thefile:gzFile):char;
+begin
+  gzgetc:=chr(gzio.gzgetc(thefile));
+end;
+
+function gzflush(thefile:gzFile; flush:longint):longint;
+begin
+  gzflush:=gzio.gzflush(thefile,flush);
+end;
+
+function gzseek(thefile:gzFile; offset:z_off_t; whence:longint):z_off_t;
+begin
+  gzseek:=gzio.gzseek(thefile,offset,whence);
+end;
+
+function gzrewind(thefile:gzFile):longint;
+begin
+  gzrewind:=gzio.gzrewind(thefile);
+end;
+
+function gztell(thefile:gzFile):z_off_t;
+begin
+  gztell:=gzio.gztell(thefile);
+end;
+
+function gzeof(thefile:gzFile):longbool;
+begin
+  gzeof:=gzio.gzeof(thefile);
+end;
+
+function gzclose(thefile:gzFile):longint;
+begin
+  gzclose:=gzio.gzclose(thefile);
+end;
+
+function gzerror(thefile:gzFile; var errnum:longint):string;
+begin
+  gzerror:=gzio.gzerror(thefile,errnum);
+end;
+
+function adler32(theadler:uLong;buf : pchar; len:uInt):uLong;
+begin
+  adler32:=adler.adler32(theadler,pbytef(buf),len);
+end;
+
+function crc32(thecrc:uLong;buf : pchar; len:uInt):uLong;
+begin
+  crc32:=gzcrc.crc32(thecrc,pbytef(buf),len);
+end;
+
+function deflateInit_(var strm:TZStream; level:longint; version:pchar; stream_size:longint):longint;
+begin
+  deflateInit_:=zdeflate.deflateInit_(@strm,level,version,stream_size);
+end;
+
+function inflateInit_(var strm:TZStream; version:pchar; stream_size:longint):longint;
+begin
+  inflateInit_:=zinflate.inflateInit_(@strm,version,stream_size);
+end;
+
+function deflateInit2_(var strm:TZStream; level:longint; method:longint; windowBits:longint; memLevel:longint;strategy:longint; version:pchar; stream_size:longint):longint;
+begin
+  deflateInit2_:=zdeflate.deflateInit2_(strm,level,method,windowBits,memlevel,strategy,version,stream_size);
+end;
+
+function inflateInit2_(var strm:TZStream; windowBits:longint; version:pchar; stream_size:longint):longint;
+begin
+  inflateInit2_:=zinflate.inflateInit2_(strm,windowBits,version,stream_size);
+end;
+
+function deflateInit(var strm:TZStream;level : longint) : longint;
+begin
+  deflateInit:=zdeflate.deflateInit(strm,level);
+end;
+
+function inflateInit(var strm:TZStream) : longint;
+begin
+  inflateInit:=zinflate.inflateInit(strm);
+end;
+
+function deflateInit2(var strm:TZStream;level,method,windowBits,memLevel,strategy : longint) : longint;
+begin
+  deflateInit2:=zdeflate.deflateInit2(strm,level,method,windowbits,memlevel,strategy);
+end;
+
+function inflateInit2(var strm:TZStream; windowBits : longint) : longint;
+begin
+  inflateInit2:=zinflate.inflateInit2_(strm,windowBits,ZLIB_VERSION,sizeof(TZStream));
+end;
+
+function zError(err:longint):string;
+begin
+  zerror:=zbase.zerror(err);
+end;
+
+function inflateSyncPoint(z:PZstream):longint;
+begin
+  inflateSyncPoint:=zinflate.inflateSyncPoint(z^);
+end;
+
+function get_crc_table:pointer;
+begin
+  get_crc_table:=gzcrc.get_crc_table;
+end;
+
+end.

+ 118 - 0
packages/base/paszlib/readme.txt

@@ -0,0 +1,118 @@
+_____________________________________________________________________________
+
+PASZLIB 1.0                                                   May 11th, 1998
+
+Based on the zlib 1.1.2, a general purpose data compression library.
+
+Copyright (C) 1998 by NOMSSI NZALI Jacques H. C. 
+[kn&n DES]         See "Legal issues" for conditions of distribution and use.
+_____________________________________________________________________________
+
+
+Introduction
+============
+
+The 'zlib' compression library provides in-memory compression and
+decompression functions, including integrity checks of the uncompressed
+data.  This version of the library supports only one compression method
+(deflation) but other algorithms will be added later and will have the same
+stream interface.
+
+Compression can be done in a single step if the buffers are large
+enough (for example if an input file is mmap'ed), or can be done by
+repeated calls of the compression function.  In the latter case, the
+application must provide more input and/or consume the output
+(providing more output space) before each call.
+
+The default memory requirements for deflate are 256K plus a few kilobytes
+for small objects. The default memory requirements for inflate are 32K
+plus a few kilobytes for small objects.
+
+Change Log
+==========
+
+May 7th 1999   - Some changes for FPC
+                 deflateCopy() has new parameters
+                 trees.pas - record constant definition
+June 17th 1998 - Applied official 1.1.2 patch. 
+		 Memcheck turned off by default.
+                 zutil.pas patch for Delphi 1 memory allocation corrected.
+                 dzlib.txt file added.
+                 compress2() is now exported
+
+June 25th 1998 - fixed a conversion bug: in inftrees.pas, ZFREE(z, v) was
+                 missing in line 574;
+
+File list
+=========
+
+Here is a road map to the files in the Paszlib distribution.
+
+readme.txt      Introduction, Documentation
+dzlib.txt       Changes to Delphi sources for Paszlib stream classes 
+
+include file
+
+zconf.inc       Configuration declarations.
+
+Pascal source code files:
+
+adler.pas      compute the Adler-32 checksum of a data stream
+crc.pas        compute the CRC-32 of a data stream
+gzio.pas       IO on .gz files
+infblock.pas   interpret and process block types to last block
+infcodes.pas   process literals and length/distance pairs
+inffast.pas    process literals and length/distance pairs fast
+inftrees.pas   generate Huffman trees for efficient decoding
+infutil.pas    types and macros common to blocks and codes
+minigzip.pas   simulate gzip using the zlib compression library
+strutils.pas   string utilities
+trees.pas      output deflated data using Huffman coding
+zcompres.pas   compress a memory buffer
+zdeflate.pas   compress data using the deflation algorithm
+zinflate.pas   zlib interface to inflate modules
+zlib.pas       zlib data structures. read the comments there!
+zuncompr.pas   decompress a memory buffer
+zutil.pas
+
+Test applications
+
+example.pas    usage example of the zlib compression library
+minigzip.pas   simulate gzip using the zlib compression library
+
+Legal issues
+============
+
+Copyright (C) 1998 by Jacques Nomssi Nzali
+
+  This software is provided 'as-is', without any express or implied
+  warranty.  In no event will the author be held liable for any damages
+  arising from the use of this software.
+
+  Permission is granted to anyone to use this software for any purpose,
+  including commercial applications, and to alter it and redistribute it
+  freely, subject to the following restrictions:
+
+  1. The origin of this software must not be misrepresented; you must not
+     claim that you wrote the original software. If you use this software
+     in a product, an acknowledgment in the product documentation would be
+     appreciated but is not required.
+  2. Altered source versions must be plainly marked as such, and must not be
+     misrepresented as being the original software.
+  3. This notice may not be removed or altered from any source distribution.
+
+
+Archive Locations:
+==================
+
+Check the Paszlib home page with links
+
+      http://www.tu-chemnitz.de/~nomssi/paszlib.html
+
+The data format used by the zlib library is described by RFCs (Request for
+Comments) 1950 to 1952 in the files ftp://ds.internic.net/rfc/rfc1950.txt
+(zlib format), rfc1951.txt (deflate format) and rfc1952.txt (gzip format).
+These documents are also available in other formats from
+ftp://ftp.uu.net/graphics/png/documents/zlib/zdoc-index.html.
+_____________________________________________________________________________
+Jacques Nomssi Nzali <mailto:[email protected]> May 7th, 1999

+ 2257 - 0
packages/base/paszlib/trees.pas

@@ -0,0 +1,2257 @@
+Unit trees;
+
+{$T-}
+{$define ORG_DEBUG}
+{
+  trees.c -- output deflated data using Huffman coding
+  Copyright (C) 1995-1998 Jean-loup Gailly
+
+  Pascal tranlastion
+  Copyright (C) 1998 by Jacques Nomssi Nzali
+  For conditions of distribution and use, see copyright notice in readme.txt
+}
+
+{
+ *  ALGORITHM
+ *
+ *      The "deflation" process uses several Huffman trees. The more
+ *      common source values are represented by shorter bit sequences.
+ *
+ *      Each code tree is stored in a compressed form which is itself
+ * a Huffman encoding of the lengths of all the code strings (in
+ * ascending order by source values).  The actual code strings are
+ * reconstructed from the lengths in the inflate process, as described
+ * in the deflate specification.
+ *
+ *  REFERENCES
+ *
+ *      Deutsch, L.P.,"'Deflate' Compressed Data Format Specification".
+ *      Available in ftp.uu.net:/pub/archiving/zip/doc/deflate-1.1.doc
+ *
+ *      Storer, James A.
+ *          Data Compression:  Methods and Theory, pp. 49-50.
+ *          Computer Science Press, 1988.  ISBN 0-7167-8156-5.
+ *
+ *      Sedgewick, R.
+ *          Algorithms, p290.
+ *          Addison-Wesley, 1983. ISBN 0-201-06672-6.
+ }
+
+interface
+
+{$I zconf.inc}
+
+uses
+  zutil, zbase;
+
+{ ===========================================================================
+  Internal compression state. }
+
+const
+  LENGTH_CODES = 29;
+{ number of length codes, not counting the special END_BLOCK code }
+
+  LITERALS = 256;
+{ number of literal bytes 0..255 }
+
+  L_CODES = (LITERALS+1+LENGTH_CODES);
+{ number of Literal or Length codes, including the END_BLOCK code }
+
+  D_CODES = 30;
+{ number of distance codes }
+
+  BL_CODES = 19;
+{ number of codes used to transfer the bit lengths }
+
+  HEAP_SIZE = (2*L_CODES+1);
+{ maximum heap size }
+
+  MAX_BITS = 15;
+{ All codes must not exceed MAX_BITS bits }
+
+const
+  INIT_STATE =  42;
+  BUSY_STATE =  113;
+  FINISH_STATE = 666;
+{ Stream status }
+
+
+{ Data structure describing a single value and its code string. }
+type
+  ct_data_ptr = ^ct_data;
+  ct_data = record
+    fc : record
+      case byte of
+      0:(freq : ush);       { frequency count }
+      1:(code : ush);       { bit string }
+    end;
+    dl : record
+      case byte of
+      0:(dad : ush);        { father node in Huffman tree }
+      1:(len : ush);        { length of bit string }
+    end;
+  end;
+
+{ Freq = fc.freq
+ Code = fc.code
+ Dad = dl.dad
+ Len = dl.len }
+
+type
+  ltree_type = array[0..HEAP_SIZE-1] of ct_data;    { literal and length tree }
+  dtree_type = array[0..2*D_CODES+1-1] of ct_data;  { distance tree }
+  htree_type = array[0..2*BL_CODES+1-1] of ct_data;  { Huffman tree for bit lengths }
+  { generic tree type }
+  tree_type = array[0..(MaxInt div SizeOf(ct_data))-1] of ct_data;
+
+  tree_ptr = ^tree_type;
+  ltree_ptr = ^ltree_type;
+  dtree_ptr = ^dtree_type;
+  htree_ptr = ^htree_type;
+
+
+type
+  static_tree_desc_ptr = ^static_tree_desc;
+  static_tree_desc =
+         record
+    {const} static_tree : tree_ptr;     { static tree or NIL }
+    {const} extra_bits : pzIntfArray;   { extra bits for each code or NIL }
+            extra_base : int;           { base index for extra_bits }
+            elems : int;                { max number of elements in the tree }
+            max_length : int;           { max bit length for the codes }
+          end;
+
+  tree_desc_ptr = ^tree_desc;
+  tree_desc = record
+    dyn_tree : tree_ptr;    { the dynamic tree }
+    max_code : int;            { largest code with non zero frequency }
+    stat_desc : static_tree_desc_ptr; { the corresponding static tree }
+  end;
+
+type
+  Pos = ush;
+  Posf = Pos; {FAR}
+  IPos = uInt;
+
+  pPosf = ^Posf;
+
+  zPosfArray = array[0..(MaxInt div SizeOf(Posf))-1] of Posf;
+  pzPosfArray = ^zPosfArray;
+
+{ A Pos is an index in the character window. We use short instead of int to
+  save space in the various tables. IPos is used only for parameter passing.}
+
+type
+  deflate_state_ptr = ^deflate_state;
+  deflate_state = record
+    strm : z_streamp;          { pointer back to this zlib stream }
+    status : int;              { as the name implies }
+    pending_buf : pzByteArray; { output still pending }
+    pending_buf_size : ulg;    { size of pending_buf }
+    pending_out : pBytef;      { next pending byte to output to the stream }
+    pending : int;             { nb of bytes in the pending buffer }
+    noheader : int;            { suppress zlib header and adler32 }
+    data_type : Byte;          { UNKNOWN, BINARY or ASCII }
+    method : Byte;             { STORED (for zip only) or DEFLATED }
+    last_flush : int;          { value of flush param for previous deflate call }
+
+                { used by deflate.pas: }
+
+    w_size : uInt;             { LZ77 window size (32K by default) }
+    w_bits : uInt;             { log2(w_size)  (8..16) }
+    w_mask : uInt;             { w_size - 1 }
+
+    window : pzByteArray;
+    { Sliding window. Input bytes are read into the second half of the window,
+      and move to the first half later to keep a dictionary of at least wSize
+      bytes. With this organization, matches are limited to a distance of
+      wSize-MAX_MATCH bytes, but this ensures that IO is always
+      performed with a length multiple of the block size. Also, it limits
+      the window size to 64K, which is quite useful on MSDOS.
+      To do: use the user input buffer as sliding window. }
+
+    window_size : ulg;
+    { Actual size of window: 2*wSize, except when the user input buffer
+      is directly used as sliding window. }
+
+    prev : pzPosfArray;
+    { Link to older string with same hash index. To limit the size of this
+      array to 64K, this link is maintained only for the last 32K strings.
+      An index in this array is thus a window index modulo 32K. }
+
+    head : pzPosfArray;    { Heads of the hash chains or NIL. }
+
+    ins_h : uInt;          { hash index of string to be inserted }
+    hash_size : uInt;      { number of elements in hash table }
+    hash_bits : uInt;      { log2(hash_size) }
+    hash_mask : uInt;      { hash_size-1 }
+
+    hash_shift : uInt;
+    { Number of bits by which ins_h must be shifted at each input
+      step. It must be such that after MIN_MATCH steps, the oldest
+      byte no longer takes part in the hash key, that is:
+        hash_shift * MIN_MATCH >= hash_bits     }
+
+    block_start : long;
+    { Window position at the beginning of the current output block. Gets
+      negative when the window is moved backwards. }
+
+    match_length : uInt;           { length of best match }
+    prev_match : IPos;             { previous match }
+    match_available : boolean;     { set if previous match exists }
+    strstart : uInt;               { start of string to insert }
+    match_start : uInt;            { start of matching string }
+    lookahead : uInt;              { number of valid bytes ahead in window }
+
+    prev_length : uInt;
+    { Length of the best match at previous step. Matches not greater than this
+      are discarded. This is used in the lazy match evaluation. }
+
+    max_chain_length : uInt;
+    { To speed up deflation, hash chains are never searched beyond this
+      length.  A higher limit improves compression ratio but degrades the
+      speed. }
+
+    { moved to the end because Borland Pascal won't accept the following:
+    max_lazy_match : uInt;
+    max_insert_length : uInt absolute max_lazy_match;
+    }
+
+    level : int;    { compression level (1..9) }
+    strategy : int; { favor or force Huffman coding}
+
+    good_match : uInt;
+    { Use a faster search when the previous match is longer than this }
+
+    nice_match : int; { Stop searching when current match exceeds this }
+
+                { used by trees.pas: }
+    { Didn't use ct_data typedef below to supress compiler warning }
+    dyn_ltree : ltree_type;    { literal and length tree }
+    dyn_dtree : dtree_type;  { distance tree }
+    bl_tree : htree_type;   { Huffman tree for bit lengths }
+
+    l_desc : tree_desc;                { desc. for literal tree }
+    d_desc : tree_desc;                { desc. for distance tree }
+    bl_desc : tree_desc;               { desc. for bit length tree }
+
+    bl_count : array[0..MAX_BITS+1-1] of ush;
+    { number of codes at each bit length for an optimal tree }
+
+    heap : array[0..2*L_CODES+1-1] of int; { heap used to build the Huffman trees }
+    heap_len : int;                   { number of elements in the heap }
+    heap_max : int;                   { element of largest frequency }
+    { The sons of heap[n] are heap[2*n] and heap[2*n+1]. heap[0] is not used.
+      The same heap array is used to build all trees. }
+
+    depth : array[0..2*L_CODES+1-1] of uch;
+    { Depth of each subtree used as tie breaker for trees of equal frequency }
+
+
+    l_buf : puchfArray;       { buffer for literals or lengths }
+
+    lit_bufsize : uInt;
+    { Size of match buffer for literals/lengths.  There are 4 reasons for
+      limiting lit_bufsize to 64K:
+        - frequencies can be kept in 16 bit counters
+        - if compression is not successful for the first block, all input
+          data is still in the window so we can still emit a stored block even
+          when input comes from standard input.  (This can also be done for
+          all blocks if lit_bufsize is not greater than 32K.)
+        - if compression is not successful for a file smaller than 64K, we can
+          even emit a stored file instead of a stored block (saving 5 bytes).
+          This is applicable only for zip (not gzip or zlib).
+        - creating new Huffman trees less frequently may not provide fast
+          adaptation to changes in the input data statistics. (Take for
+          example a binary file with poorly compressible code followed by
+          a highly compressible string table.) Smaller buffer sizes give
+          fast adaptation but have of course the overhead of transmitting
+          trees more frequently.
+        - I can't count above 4 }
+
+
+    last_lit : uInt;      { running index in l_buf }
+
+    d_buf : pushfArray;
+    { Buffer for distances. To simplify the code, d_buf and l_buf have
+      the same number of elements. To use different lengths, an extra flag
+      array would be necessary. }
+
+    opt_len : ulg;        { bit length of current block with optimal trees }
+    static_len : ulg;     { bit length of current block with static trees }
+    compressed_len : ulg; { total bit length of compressed file }
+    matches : uInt;       { number of string matches in current block }
+    last_eob_len : int;   { bit length of EOB code for last block }
+
+{$ifdef DEBUG}
+    bits_sent : ulg;    { bit length of the compressed data }
+{$endif}
+
+    bi_buf : ush;
+    { Output buffer. bits are inserted starting at the bottom (least
+      significant bits). }
+
+    bi_valid : int;
+    { Number of valid bits in bi_buf.  All bits above the last valid bit
+      are always zero. }
+
+    case byte of
+    0:(max_lazy_match : uInt);
+    { Attempt to find a better match only when the current match is strictly
+      smaller than this value. This mechanism is used only for compression
+      levels >= 4. }
+
+    1:(max_insert_length : uInt);
+    { Insert new strings in the hash table only if the match length is not
+      greater than this length. This saves time but degrades compression.
+      max_insert_length is used only for compression levels <= 3. }
+  end;
+
+procedure _tr_init (var s : deflate_state);
+
+function _tr_tally (var s : deflate_state;
+                    dist : unsigned;
+                    lc : unsigned) : boolean;
+
+function _tr_flush_block (var s : deflate_state;
+                          buf : pcharf;
+                          stored_len : ulg;
+                          eof : boolean) : ulg;
+
+procedure _tr_align(var s : deflate_state);
+
+procedure _tr_stored_block(var s : deflate_state;
+                           buf : pcharf;
+                           stored_len : ulg;
+                           eof : boolean);
+
+implementation
+
+{ #define GEN_TREES_H }
+
+{$ifndef GEN_TREES_H}
+{ header created automatically with -DGEN_TREES_H }
+
+const
+  DIST_CODE_LEN = 512; { see definition of array dist_code below }
+
+{ The static literal tree. Since the bit lengths are imposed, there is no
+  need for the L_CODES extra codes used during heap construction. However
+  The codes 286 and 287 are needed to build a canonical tree (see _tr_init
+  below). }
+const
+  static_ltree : array[0..L_CODES+2-1] of ct_data = (
+{ fc:(freq, code) dl:(dad,len) }
+(fc:(freq: 12);dl:(len: 8)), (fc:(freq:140);dl:(len: 8)), (fc:(freq: 76);dl:(len: 8)),
+(fc:(freq:204);dl:(len: 8)), (fc:(freq: 44);dl:(len: 8)), (fc:(freq:172);dl:(len: 8)),
+(fc:(freq:108);dl:(len: 8)), (fc:(freq:236);dl:(len: 8)), (fc:(freq: 28);dl:(len: 8)),
+(fc:(freq:156);dl:(len: 8)), (fc:(freq: 92);dl:(len: 8)), (fc:(freq:220);dl:(len: 8)),
+(fc:(freq: 60);dl:(len: 8)), (fc:(freq:188);dl:(len: 8)), (fc:(freq:124);dl:(len: 8)),
+(fc:(freq:252);dl:(len: 8)), (fc:(freq:  2);dl:(len: 8)), (fc:(freq:130);dl:(len: 8)),
+(fc:(freq: 66);dl:(len: 8)), (fc:(freq:194);dl:(len: 8)), (fc:(freq: 34);dl:(len: 8)),
+(fc:(freq:162);dl:(len: 8)), (fc:(freq: 98);dl:(len: 8)), (fc:(freq:226);dl:(len: 8)),
+(fc:(freq: 18);dl:(len: 8)), (fc:(freq:146);dl:(len: 8)), (fc:(freq: 82);dl:(len: 8)),
+(fc:(freq:210);dl:(len: 8)), (fc:(freq: 50);dl:(len: 8)), (fc:(freq:178);dl:(len: 8)),
+(fc:(freq:114);dl:(len: 8)), (fc:(freq:242);dl:(len: 8)), (fc:(freq: 10);dl:(len: 8)),
+(fc:(freq:138);dl:(len: 8)), (fc:(freq: 74);dl:(len: 8)), (fc:(freq:202);dl:(len: 8)),
+(fc:(freq: 42);dl:(len: 8)), (fc:(freq:170);dl:(len: 8)), (fc:(freq:106);dl:(len: 8)),
+(fc:(freq:234);dl:(len: 8)), (fc:(freq: 26);dl:(len: 8)), (fc:(freq:154);dl:(len: 8)),
+(fc:(freq: 90);dl:(len: 8)), (fc:(freq:218);dl:(len: 8)), (fc:(freq: 58);dl:(len: 8)),
+(fc:(freq:186);dl:(len: 8)), (fc:(freq:122);dl:(len: 8)), (fc:(freq:250);dl:(len: 8)),
+(fc:(freq:  6);dl:(len: 8)), (fc:(freq:134);dl:(len: 8)), (fc:(freq: 70);dl:(len: 8)),
+(fc:(freq:198);dl:(len: 8)), (fc:(freq: 38);dl:(len: 8)), (fc:(freq:166);dl:(len: 8)),
+(fc:(freq:102);dl:(len: 8)), (fc:(freq:230);dl:(len: 8)), (fc:(freq: 22);dl:(len: 8)),
+(fc:(freq:150);dl:(len: 8)), (fc:(freq: 86);dl:(len: 8)), (fc:(freq:214);dl:(len: 8)),
+(fc:(freq: 54);dl:(len: 8)), (fc:(freq:182);dl:(len: 8)), (fc:(freq:118);dl:(len: 8)),
+(fc:(freq:246);dl:(len: 8)), (fc:(freq: 14);dl:(len: 8)), (fc:(freq:142);dl:(len: 8)),
+(fc:(freq: 78);dl:(len: 8)), (fc:(freq:206);dl:(len: 8)), (fc:(freq: 46);dl:(len: 8)),
+(fc:(freq:174);dl:(len: 8)), (fc:(freq:110);dl:(len: 8)), (fc:(freq:238);dl:(len: 8)),
+(fc:(freq: 30);dl:(len: 8)), (fc:(freq:158);dl:(len: 8)), (fc:(freq: 94);dl:(len: 8)),
+(fc:(freq:222);dl:(len: 8)), (fc:(freq: 62);dl:(len: 8)), (fc:(freq:190);dl:(len: 8)),
+(fc:(freq:126);dl:(len: 8)), (fc:(freq:254);dl:(len: 8)), (fc:(freq:  1);dl:(len: 8)),
+(fc:(freq:129);dl:(len: 8)), (fc:(freq: 65);dl:(len: 8)), (fc:(freq:193);dl:(len: 8)),
+(fc:(freq: 33);dl:(len: 8)), (fc:(freq:161);dl:(len: 8)), (fc:(freq: 97);dl:(len: 8)),
+(fc:(freq:225);dl:(len: 8)), (fc:(freq: 17);dl:(len: 8)), (fc:(freq:145);dl:(len: 8)),
+(fc:(freq: 81);dl:(len: 8)), (fc:(freq:209);dl:(len: 8)), (fc:(freq: 49);dl:(len: 8)),
+(fc:(freq:177);dl:(len: 8)), (fc:(freq:113);dl:(len: 8)), (fc:(freq:241);dl:(len: 8)),
+(fc:(freq:  9);dl:(len: 8)), (fc:(freq:137);dl:(len: 8)), (fc:(freq: 73);dl:(len: 8)),
+(fc:(freq:201);dl:(len: 8)), (fc:(freq: 41);dl:(len: 8)), (fc:(freq:169);dl:(len: 8)),
+(fc:(freq:105);dl:(len: 8)), (fc:(freq:233);dl:(len: 8)), (fc:(freq: 25);dl:(len: 8)),
+(fc:(freq:153);dl:(len: 8)), (fc:(freq: 89);dl:(len: 8)), (fc:(freq:217);dl:(len: 8)),
+(fc:(freq: 57);dl:(len: 8)), (fc:(freq:185);dl:(len: 8)), (fc:(freq:121);dl:(len: 8)),
+(fc:(freq:249);dl:(len: 8)), (fc:(freq:  5);dl:(len: 8)), (fc:(freq:133);dl:(len: 8)),
+(fc:(freq: 69);dl:(len: 8)), (fc:(freq:197);dl:(len: 8)), (fc:(freq: 37);dl:(len: 8)),
+(fc:(freq:165);dl:(len: 8)), (fc:(freq:101);dl:(len: 8)), (fc:(freq:229);dl:(len: 8)),
+(fc:(freq: 21);dl:(len: 8)), (fc:(freq:149);dl:(len: 8)), (fc:(freq: 85);dl:(len: 8)),
+(fc:(freq:213);dl:(len: 8)), (fc:(freq: 53);dl:(len: 8)), (fc:(freq:181);dl:(len: 8)),
+(fc:(freq:117);dl:(len: 8)), (fc:(freq:245);dl:(len: 8)), (fc:(freq: 13);dl:(len: 8)),
+(fc:(freq:141);dl:(len: 8)), (fc:(freq: 77);dl:(len: 8)), (fc:(freq:205);dl:(len: 8)),
+(fc:(freq: 45);dl:(len: 8)), (fc:(freq:173);dl:(len: 8)), (fc:(freq:109);dl:(len: 8)),
+(fc:(freq:237);dl:(len: 8)), (fc:(freq: 29);dl:(len: 8)), (fc:(freq:157);dl:(len: 8)),
+(fc:(freq: 93);dl:(len: 8)), (fc:(freq:221);dl:(len: 8)), (fc:(freq: 61);dl:(len: 8)),
+(fc:(freq:189);dl:(len: 8)), (fc:(freq:125);dl:(len: 8)), (fc:(freq:253);dl:(len: 8)),
+(fc:(freq: 19);dl:(len: 9)), (fc:(freq:275);dl:(len: 9)), (fc:(freq:147);dl:(len: 9)),
+(fc:(freq:403);dl:(len: 9)), (fc:(freq: 83);dl:(len: 9)), (fc:(freq:339);dl:(len: 9)),
+(fc:(freq:211);dl:(len: 9)), (fc:(freq:467);dl:(len: 9)), (fc:(freq: 51);dl:(len: 9)),
+(fc:(freq:307);dl:(len: 9)), (fc:(freq:179);dl:(len: 9)), (fc:(freq:435);dl:(len: 9)),
+(fc:(freq:115);dl:(len: 9)), (fc:(freq:371);dl:(len: 9)), (fc:(freq:243);dl:(len: 9)),
+(fc:(freq:499);dl:(len: 9)), (fc:(freq: 11);dl:(len: 9)), (fc:(freq:267);dl:(len: 9)),
+(fc:(freq:139);dl:(len: 9)), (fc:(freq:395);dl:(len: 9)), (fc:(freq: 75);dl:(len: 9)),
+(fc:(freq:331);dl:(len: 9)), (fc:(freq:203);dl:(len: 9)), (fc:(freq:459);dl:(len: 9)),
+(fc:(freq: 43);dl:(len: 9)), (fc:(freq:299);dl:(len: 9)), (fc:(freq:171);dl:(len: 9)),
+(fc:(freq:427);dl:(len: 9)), (fc:(freq:107);dl:(len: 9)), (fc:(freq:363);dl:(len: 9)),
+(fc:(freq:235);dl:(len: 9)), (fc:(freq:491);dl:(len: 9)), (fc:(freq: 27);dl:(len: 9)),
+(fc:(freq:283);dl:(len: 9)), (fc:(freq:155);dl:(len: 9)), (fc:(freq:411);dl:(len: 9)),
+(fc:(freq: 91);dl:(len: 9)), (fc:(freq:347);dl:(len: 9)), (fc:(freq:219);dl:(len: 9)),
+(fc:(freq:475);dl:(len: 9)), (fc:(freq: 59);dl:(len: 9)), (fc:(freq:315);dl:(len: 9)),
+(fc:(freq:187);dl:(len: 9)), (fc:(freq:443);dl:(len: 9)), (fc:(freq:123);dl:(len: 9)),
+(fc:(freq:379);dl:(len: 9)), (fc:(freq:251);dl:(len: 9)), (fc:(freq:507);dl:(len: 9)),
+(fc:(freq:  7);dl:(len: 9)), (fc:(freq:263);dl:(len: 9)), (fc:(freq:135);dl:(len: 9)),
+(fc:(freq:391);dl:(len: 9)), (fc:(freq: 71);dl:(len: 9)), (fc:(freq:327);dl:(len: 9)),
+(fc:(freq:199);dl:(len: 9)), (fc:(freq:455);dl:(len: 9)), (fc:(freq: 39);dl:(len: 9)),
+(fc:(freq:295);dl:(len: 9)), (fc:(freq:167);dl:(len: 9)), (fc:(freq:423);dl:(len: 9)),
+(fc:(freq:103);dl:(len: 9)), (fc:(freq:359);dl:(len: 9)), (fc:(freq:231);dl:(len: 9)),
+(fc:(freq:487);dl:(len: 9)), (fc:(freq: 23);dl:(len: 9)), (fc:(freq:279);dl:(len: 9)),
+(fc:(freq:151);dl:(len: 9)), (fc:(freq:407);dl:(len: 9)), (fc:(freq: 87);dl:(len: 9)),
+(fc:(freq:343);dl:(len: 9)), (fc:(freq:215);dl:(len: 9)), (fc:(freq:471);dl:(len: 9)),
+(fc:(freq: 55);dl:(len: 9)), (fc:(freq:311);dl:(len: 9)), (fc:(freq:183);dl:(len: 9)),
+(fc:(freq:439);dl:(len: 9)), (fc:(freq:119);dl:(len: 9)), (fc:(freq:375);dl:(len: 9)),
+(fc:(freq:247);dl:(len: 9)), (fc:(freq:503);dl:(len: 9)), (fc:(freq: 15);dl:(len: 9)),
+(fc:(freq:271);dl:(len: 9)), (fc:(freq:143);dl:(len: 9)), (fc:(freq:399);dl:(len: 9)),
+(fc:(freq: 79);dl:(len: 9)), (fc:(freq:335);dl:(len: 9)), (fc:(freq:207);dl:(len: 9)),
+(fc:(freq:463);dl:(len: 9)), (fc:(freq: 47);dl:(len: 9)), (fc:(freq:303);dl:(len: 9)),
+(fc:(freq:175);dl:(len: 9)), (fc:(freq:431);dl:(len: 9)), (fc:(freq:111);dl:(len: 9)),
+(fc:(freq:367);dl:(len: 9)), (fc:(freq:239);dl:(len: 9)), (fc:(freq:495);dl:(len: 9)),
+(fc:(freq: 31);dl:(len: 9)), (fc:(freq:287);dl:(len: 9)), (fc:(freq:159);dl:(len: 9)),
+(fc:(freq:415);dl:(len: 9)), (fc:(freq: 95);dl:(len: 9)), (fc:(freq:351);dl:(len: 9)),
+(fc:(freq:223);dl:(len: 9)), (fc:(freq:479);dl:(len: 9)), (fc:(freq: 63);dl:(len: 9)),
+(fc:(freq:319);dl:(len: 9)), (fc:(freq:191);dl:(len: 9)), (fc:(freq:447);dl:(len: 9)),
+(fc:(freq:127);dl:(len: 9)), (fc:(freq:383);dl:(len: 9)), (fc:(freq:255);dl:(len: 9)),
+(fc:(freq:511);dl:(len: 9)), (fc:(freq:  0);dl:(len: 7)), (fc:(freq: 64);dl:(len: 7)),
+(fc:(freq: 32);dl:(len: 7)), (fc:(freq: 96);dl:(len: 7)), (fc:(freq: 16);dl:(len: 7)),
+(fc:(freq: 80);dl:(len: 7)), (fc:(freq: 48);dl:(len: 7)), (fc:(freq:112);dl:(len: 7)),
+(fc:(freq:  8);dl:(len: 7)), (fc:(freq: 72);dl:(len: 7)), (fc:(freq: 40);dl:(len: 7)),
+(fc:(freq:104);dl:(len: 7)), (fc:(freq: 24);dl:(len: 7)), (fc:(freq: 88);dl:(len: 7)),
+(fc:(freq: 56);dl:(len: 7)), (fc:(freq:120);dl:(len: 7)), (fc:(freq:  4);dl:(len: 7)),
+(fc:(freq: 68);dl:(len: 7)), (fc:(freq: 36);dl:(len: 7)), (fc:(freq:100);dl:(len: 7)),
+(fc:(freq: 20);dl:(len: 7)), (fc:(freq: 84);dl:(len: 7)), (fc:(freq: 52);dl:(len: 7)),
+(fc:(freq:116);dl:(len: 7)), (fc:(freq:  3);dl:(len: 8)), (fc:(freq:131);dl:(len: 8)),
+(fc:(freq: 67);dl:(len: 8)), (fc:(freq:195);dl:(len: 8)), (fc:(freq: 35);dl:(len: 8)),
+(fc:(freq:163);dl:(len: 8)), (fc:(freq: 99);dl:(len: 8)), (fc:(freq:227);dl:(len: 8))
+);
+
+
+{ The static distance tree. (Actually a trivial tree since all lens use
+  5 bits.) }
+  static_dtree : array[0..D_CODES-1] of ct_data = (
+(fc:(freq: 0); dl:(len:5)), (fc:(freq:16); dl:(len:5)), (fc:(freq: 8); dl:(len:5)),
+(fc:(freq:24); dl:(len:5)), (fc:(freq: 4); dl:(len:5)), (fc:(freq:20); dl:(len:5)),
+(fc:(freq:12); dl:(len:5)), (fc:(freq:28); dl:(len:5)), (fc:(freq: 2); dl:(len:5)),
+(fc:(freq:18); dl:(len:5)), (fc:(freq:10); dl:(len:5)), (fc:(freq:26); dl:(len:5)),
+(fc:(freq: 6); dl:(len:5)), (fc:(freq:22); dl:(len:5)), (fc:(freq:14); dl:(len:5)),
+(fc:(freq:30); dl:(len:5)), (fc:(freq: 1); dl:(len:5)), (fc:(freq:17); dl:(len:5)),
+(fc:(freq: 9); dl:(len:5)), (fc:(freq:25); dl:(len:5)), (fc:(freq: 5); dl:(len:5)),
+(fc:(freq:21); dl:(len:5)), (fc:(freq:13); dl:(len:5)), (fc:(freq:29); dl:(len:5)),
+(fc:(freq: 3); dl:(len:5)), (fc:(freq:19); dl:(len:5)), (fc:(freq:11); dl:(len:5)),
+(fc:(freq:27); dl:(len:5)), (fc:(freq: 7); dl:(len:5)), (fc:(freq:23); dl:(len:5))
+);
+
+{ Distance codes. The first 256 values correspond to the distances
+  3 .. 258, the last 256 values correspond to the top 8 bits of
+  the 15 bit distances. }
+  _dist_code : array[0..DIST_CODE_LEN-1] of uch = (
+ 0,  1,  2,  3,  4,  4,  5,  5,  6,  6,  6,  6,  7,  7,  7,  7,  8,  8,  8,  8,
+ 8,  8,  8,  8,  9,  9,  9,  9,  9,  9,  9,  9, 10, 10, 10, 10, 10, 10, 10, 10,
+10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
+11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
+12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 13, 13, 13, 13,
+13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
+13, 13, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
+14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
+14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
+14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15, 15,
+15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
+15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
+15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,  0,  0, 16, 17,
+18, 18, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 22, 22, 22, 22, 22, 22, 22, 22,
+23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
+24, 24, 24, 24, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
+26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26,
+26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27,
+27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
+27, 27, 27, 27, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
+28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
+28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
+28, 28, 28, 28, 28, 28, 28, 28, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
+29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
+29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
+29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29
+);
+
+{ length code for each normalized match length (0 == MIN_MATCH) }
+  _length_code : array[0..MAX_MATCH-MIN_MATCH+1-1] of uch = (
+ 0,  1,  2,  3,  4,  5,  6,  7,  8,  8,  9,  9, 10, 10, 11, 11, 12, 12, 12, 12,
+13, 13, 13, 13, 14, 14, 14, 14, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 16, 16,
+17, 17, 17, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18, 18, 19, 19, 19, 19,
+19, 19, 19, 19, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
+21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 22, 22, 22, 22,
+22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 23, 23, 23, 23, 23, 23, 23, 23,
+23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
+24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
+25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
+25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 26, 26, 26, 26, 26, 26, 26, 26,
+26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26,
+26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
+27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 28
+);
+
+
+{ First normalized length for each code (0 = MIN_MATCH) }
+  base_length : array[0..LENGTH_CODES-1] of int = (
+0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 12, 14, 16, 20, 24, 28, 32, 40, 48, 56,
+64, 80, 96, 112, 128, 160, 192, 224, 0
+);
+
+
+{ First normalized distance for each code (0 = distance of 1) }
+  base_dist : array[0..D_CODES-1] of int = (
+    0,     1,     2,     3,     4,     6,     8,    12,    16,    24,
+   32,    48,    64,    96,   128,   192,   256,   384,   512,   768,
+ 1024,  1536,  2048,  3072,  4096,  6144,  8192, 12288, 16384, 24576
+);
+{$endif}
+
+{ Output a byte on the stream.
+  IN assertion: there is enough room in pending_buf.
+macro put_byte(s, c)
+begin
+  s^.pending_buf^[s^.pending] := (c);
+  Inc(s^.pending);
+end
+}
+
+const
+  MIN_LOOKAHEAD = (MAX_MATCH+MIN_MATCH+1);
+{ Minimum amount of lookahead, except at the end of the input file.
+  See deflate.c for comments about the MIN_MATCH+1. }
+
+{macro d_code(dist)
+   if (dist) < 256 then
+     := _dist_code[dist]
+   else
+     := _dist_code[256+((dist) shr 7)]);
+  Mapping from a distance to a distance code. dist is the distance - 1 and
+  must not have side effects. _dist_code[256] and _dist_code[257] are never
+  used. }
+
+{$ifndef ORG_DEBUG}
+{ Inline versions of _tr_tally for speed: }
+
+#if defined(GEN_TREES_H) || !defined(STDC)
+  extern uch _length_code[];
+  extern uch _dist_code[];
+#else
+  extern const uch _length_code[];
+  extern const uch _dist_code[];
+#endif
+
+macro _tr_tally_lit(s, c, flush)
+var
+  cc : uch;
+begin
+    cc := (c);
+    s^.d_buf[s^.last_lit] := 0;
+    s^.l_buf[s^.last_lit] := cc;
+    Inc(s^.last_lit);
+    Inc(s^.dyn_ltree[cc].fc.Freq);
+    flush := (s^.last_lit = s^.lit_bufsize-1);
+end;
+
+macro _tr_tally_dist(s, distance, length, flush) \
+var
+  len : uch;
+  dist : ush;
+begin
+    len := (length);
+    dist := (distance);
+    s^.d_buf[s^.last_lit] := dist;
+    s^.l_buf[s^.last_lit] = len;
+    Inc(s^.last_lit);
+    Dec(dist);
+    Inc(s^.dyn_ltree[_length_code[len]+LITERALS+1].fc.Freq);
+    Inc(s^.dyn_dtree[d_code(dist)].Freq);
+    flush := (s^.last_lit = s^.lit_bufsize-1);
+end;
+
+{$endif}
+
+{ ===========================================================================
+  Constants }
+
+const
+  MAX_BL_BITS = 7;
+{ Bit length codes must not exceed MAX_BL_BITS bits }
+
+const
+  END_BLOCK = 256;
+{ end of block literal code }
+
+const
+  REP_3_6 = 16;
+{ repeat previous bit length 3-6 times (2 bits of repeat count) }
+
+const
+  REPZ_3_10 = 17;
+{ repeat a zero length 3-10 times  (3 bits of repeat count) }
+
+const
+  REPZ_11_138 = 18;
+{ repeat a zero length 11-138 times  (7 bits of repeat count) }
+
+{local}
+const
+  extra_lbits : array[0..LENGTH_CODES-1] of int
+    { extra bits for each length code }
+   = (0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0);
+
+{local}
+const
+  extra_dbits : array[0..D_CODES-1] of int
+    { extra bits for each distance code }
+   = (0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13);
+
+{local}
+const
+  extra_blbits : array[0..BL_CODES-1] of int { extra bits for each bit length code }
+   = (0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7);
+
+{local}
+const
+  bl_order : array[0..BL_CODES-1] of uch
+   = (16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15);
+{ The lengths of the bit length codes are sent in order of decreasing
+  probability, to avoid transmitting the lengths for unused bit length codes.
+ }
+
+const
+  Buf_size = (8 * 2*sizeof(char));
+{ Number of bits used within bi_buf. (bi_buf might be implemented on
+  more than 16 bits on some systems.) }
+
+{ ===========================================================================
+  Local data. These are initialized only once. }
+
+
+{$ifdef GEN_TREES_H)}
+{ non ANSI compilers may not accept trees.h }
+
+const
+  DIST_CODE_LEN = 512; { see definition of array dist_code below }
+
+{local}
+var
+  static_ltree : array[0..L_CODES+2-1] of ct_data;
+{ The static literal tree. Since the bit lengths are imposed, there is no
+  need for the L_CODES extra codes used during heap construction. However
+  The codes 286 and 287 are needed to build a canonical tree (see _tr_init
+  below). }
+
+{local}
+  static_dtree : array[0..D_CODES-1] of ct_data;
+{ The static distance tree. (Actually a trivial tree since all codes use
+  5 bits.) }
+
+  _dist_code : array[0..DIST_CODE_LEN-1] of uch;
+{ Distance codes. The first 256 values correspond to the distances
+  3 .. 258, the last 256 values correspond to the top 8 bits of
+  the 15 bit distances. }
+
+  _length_code : array[0..MAX_MATCH-MIN_MATCH+1-1] of uch;
+{ length code for each normalized match length (0 == MIN_MATCH) }
+
+{local}
+  base_length : array[0..LENGTH_CODES-1] of int;
+{ First normalized length for each code (0 = MIN_MATCH) }
+
+{local}
+  base_dist : array[0..D_CODES-1] of int;
+{ First normalized distance for each code (0 = distance of 1) }
+
+{$endif} { GEN_TREES_H }
+
+{local}
+const
+  static_l_desc :  static_tree_desc  =
+      (static_tree: {tree_ptr}(@(static_ltree));  { pointer to array of ct_data }
+       extra_bits: {pzIntfArray}(@(extra_lbits)); { pointer to array of int }
+       extra_base: LITERALS+1;
+       elems: L_CODES;
+       max_length: MAX_BITS);
+
+{local}
+const
+  static_d_desc : static_tree_desc  =
+      (static_tree: {tree_ptr}(@(static_dtree));
+       extra_bits: {pzIntfArray}(@(extra_dbits));
+       extra_base : 0;
+       elems: D_CODES;
+       max_length: MAX_BITS);
+
+{local}
+const
+  static_bl_desc : static_tree_desc =
+      (static_tree: {tree_ptr}(NIL);
+       extra_bits: {pzIntfArray}@(extra_blbits);
+       extra_base : 0;
+       elems: BL_CODES;
+       max_length: MAX_BL_BITS);
+
+(* ===========================================================================
+  Local (static) routines in this file. }
+
+procedure tr_static_init;
+procedure init_block(var deflate_state);
+procedure pqdownheap(var s : deflate_state;
+                     var tree : ct_data;
+                     k : int);
+procedure gen_bitlen(var s : deflate_state;
+                     var desc : tree_desc);
+procedure gen_codes(var tree : ct_data;
+                    max_code : int;
+                    bl_count : pushf);
+procedure build_tree(var s : deflate_state;
+                     var desc : tree_desc);
+procedure scan_tree(var s : deflate_state;
+                    var tree : ct_data;
+                    max_code : int);
+procedure send_tree(var s : deflate_state;
+                    var tree : ct_data;
+                    max_code : int);
+function build_bl_tree(var deflate_state) : int;
+procedure send_all_trees(var deflate_state;
+                         lcodes : int;
+                         dcodes : int;
+                         blcodes : int);
+procedure compress_block(var s : deflate_state;
+                         var ltree : ct_data;
+                         var dtree : ct_data);
+procedure set_data_type(var s : deflate_state);
+function bi_reverse(value : unsigned;
+                    length : int) : unsigned;
+procedure bi_windup(var deflate_state);
+procedure bi_flush(var deflate_state);
+procedure copy_block(var deflate_state;
+                     buf : pcharf;
+                     len : unsigned;
+                     header : int);
+*)
+
+{$ifdef GEN_TREES_H}
+{local}
+procedure gen_trees_header;
+{$endif}
+
+(*
+{ ===========================================================================
+  Output a short LSB first on the stream.
+  IN assertion: there is enough room in pendingBuf. }
+
+macro put_short(s, w)
+begin
+    {put_byte(s, (uch)((w) & 0xff));}
+    s.pending_buf^[s.pending] := uch((w) and $ff);
+    Inc(s.pending);
+
+    {put_byte(s, (uch)((ush)(w) >> 8));}
+    s.pending_buf^[s.pending] := uch(ush(w) shr 8);;
+    Inc(s.pending);
+end
+*)
+
+{$ifdef DEBUG}
+Function IntToStr(value : LongInt) : string;
+{ Convert any integer type to a string }
+var
+  s : string[20];
+begin
+  Str(value:0, s);
+  IntToStr := S;
+end;
+{$endif}
+
+{ ===========================================================================
+  Send a value on a given number of bits.
+  IN assertion: length <= 16 and value fits in length bits. }
+
+{$ifdef ORG_DEBUG}
+
+{local}
+procedure send_bits(var s : deflate_state;
+                    value : int;   { value to send }
+                    length : int); { number of bits }
+begin
+  {$ifdef DEBUG}
+  Tracevv(' l '+IntToStr(length)+ ' v '+IntToStr(value));
+  Assert((length > 0) and (length <= 15), 'invalid length');
+  Inc(s.bits_sent, ulg(length));
+  {$ENDIF}
+
+  { If not enough room in bi_buf, use (valid) bits from bi_buf and
+    (16 - bi_valid) bits from value, leaving (width - (16-bi_valid))
+    unused bits in value. }
+  {$IFOPT Q+} {$Q-} {$DEFINE NoOverflowCheck} {$ENDIF}
+  {$IFOPT R+} {$R-} {$DEFINE NoRangeCheck} {$ENDIF}
+  if (s.bi_valid > int(Buf_size) - length) then
+  begin
+    s.bi_buf := s.bi_buf or int(value shl s.bi_valid);
+    {put_short(s, s.bi_buf);}
+    s.pending_buf^[s.pending] := uch(s.bi_buf and $ff);
+    Inc(s.pending);
+    s.pending_buf^[s.pending] := uch(ush(s.bi_buf) shr 8);;
+    Inc(s.pending);
+
+    s.bi_buf := ush(value) shr (Buf_size - s.bi_valid);
+    Inc(s.bi_valid, length - Buf_size);
+  end
+  else
+  begin
+    s.bi_buf := s.bi_buf or int(value shl s.bi_valid);
+    Inc(s.bi_valid, length);
+  end;
+  {$IFDEF NoOverflowCheck} {$Q+} {$UNDEF NoOverflowCheck} {$ENDIF}
+  {$IFDEF NoRangeCheck} {$Q+} {$UNDEF NoRangeCheck} {$ENDIF}
+end;
+
+{$else} { !DEBUG }
+
+
+macro send_code(s, c, tree)
+begin
+  send_bits(s, tree[c].Code, tree[c].Len);
+  { Send a code of the given tree. c and tree must not have side effects }
+end
+
+macro send_bits(s, value, length) \
+begin int len := length;\
+  if (s^.bi_valid > (int)Buf_size - len) begin\
+    int val := value;\
+    s^.bi_buf |= (val << s^.bi_valid);\
+    {put_short(s, s.bi_buf);}
+    s.pending_buf^[s.pending] := uch(s.bi_buf and $ff);
+    Inc(s.pending);
+    s.pending_buf^[s.pending] := uch(ush(s.bi_buf) shr 8);;
+    Inc(s.pending);
+
+    s^.bi_buf := (ush)val >> (Buf_size - s^.bi_valid);\
+    s^.bi_valid += len - Buf_size;\
+  end else begin\
+    s^.bi_buf |= (value) << s^.bi_valid;\
+    s^.bi_valid += len;\
+  end\
+end;
+{$endif} { DEBUG }
+
+{ ===========================================================================
+  Reverse the first len bits of a code, using straightforward code (a faster
+  method would use a table)
+  IN assertion: 1 <= len <= 15 }
+
+{local}
+function bi_reverse(code : unsigned;         { the value to invert }
+                    len : int) : unsigned;   { its bit length }
+
+var
+  res : unsigned; {register}
+begin
+  res := 0;
+  repeat
+    res := res or (code and 1);
+    code := code shr 1;
+    res := res shl 1;
+    Dec(len);
+  until (len <= 0);
+  bi_reverse := res shr 1;
+end;
+
+{ ===========================================================================
+  Generate the codes for a given tree and bit counts (which need not be
+  optimal).
+  IN assertion: the array bl_count contains the bit length statistics for
+  the given tree and the field len is set for all tree elements.
+  OUT assertion: the field code is set for all tree elements of non
+      zero code length. }
+
+{local}
+procedure gen_codes(tree : tree_ptr;  { the tree to decorate }
+                    max_code : int;   { largest code with non zero frequency }
+                    var bl_count : array of ushf);  { number of codes at each bit length }
+
+var
+  next_code : array[0..MAX_BITS+1-1] of ush; { next code value for each bit length }
+  code : ush;              { running code value }
+  bits : int;                  { bit index }
+  n : int;                     { code index }
+var
+  len : int;
+begin
+  code := 0;
+
+  { The distribution counts are first used to generate the code values
+    without bit reversal. }
+
+  for bits := 1 to MAX_BITS do
+  begin
+    code := ((code + bl_count[bits-1]) shl 1);
+    next_code[bits] := code;
+  end;
+  { Check that the bit counts in bl_count are consistent. The last code
+    must be all ones. }
+
+  {$IFDEF DEBUG}
+  Assert (code + bl_count[MAX_BITS]-1 = (1 shl MAX_BITS)-1,
+          'inconsistent bit counts');
+  Tracev(#13'gen_codes: max_code '+IntToStr(max_code));
+  {$ENDIF}
+
+  for n := 0 to max_code do
+  begin
+    len := tree^[n].dl.Len;
+    if (len = 0) then
+      continue;
+    { Now reverse the bits }
+    tree^[n].fc.Code := bi_reverse(next_code[len], len);
+    Inc(next_code[len]);
+    {$ifdef DEBUG}
+    if (n>31) and (n<128) then
+      Tracecv(tree <> tree_ptr(@static_ltree),
+       (^M'n #'+IntToStr(n)+' '+char(n)+' l '+IntToStr(len)+' c '+
+         IntToStr(tree^[n].fc.Code)+' ('+IntToStr(next_code[len]-1)+')'))
+    else
+      Tracecv(tree <> tree_ptr(@static_ltree),
+      (^M'n #'+IntToStr(n)+'   l '+IntToStr(len)+' c '+
+         IntToStr(tree^[n].fc.Code)+' ('+IntToStr(next_code[len]-1)+')'));
+    {$ENDIF}
+  end;
+end;
+
+{ ===========================================================================
+  Genererate the file trees.h describing the static trees. }
+{$ifdef GEN_TREES_H}
+
+macro SEPARATOR(i, last, width)
+  if (i) = (last) then
+    ( ^M');'^M^M
+  else    \
+    if (i) mod (width) = (width)-1 then
+       ','^M
+     else
+       ', '
+
+procedure gen_trees_header;
+var
+  header : system.text;
+  i : int;
+begin
+  system.assign(header, 'trees.inc');
+  {$I-}
+  ReWrite(header);
+  {$I+}
+  Assert (IOresult <> 0, 'Can''t open trees.h');
+  WriteLn(header,
+    '{ header created automatically with -DGEN_TREES_H }'^M);
+
+  WriteLn(header, 'local const ct_data static_ltree[L_CODES+2] := (');
+  for i := 0 to L_CODES+2-1 do
+  begin
+    WriteLn(header, '((%3u),(%3u))%s', static_ltree[i].Code,
+                static_ltree[i].Len, SEPARATOR(i, L_CODES+1, 5));
+  end;
+
+  WriteLn(header, 'local const ct_data static_dtree[D_CODES] := (');
+  for i := 0 to D_CODES-1 do
+  begin
+    WriteLn(header, '((%2u),(%2u))%s', static_dtree[i].Code,
+                static_dtree[i].Len, SEPARATOR(i, D_CODES-1, 5));
+  end;
+
+  WriteLn(header, 'const uch _dist_code[DIST_CODE_LEN] := (');
+  for i := 0 to DIST_CODE_LEN-1 do
+  begin
+    WriteLn(header, '%2u%s', _dist_code[i],
+                SEPARATOR(i, DIST_CODE_LEN-1, 20));
+  end;
+
+  WriteLn(header, 'const uch _length_code[MAX_MATCH-MIN_MATCH+1]= (');
+  for i := 0 to MAX_MATCH-MIN_MATCH+1-1 do
+  begin
+    WriteLn(header, '%2u%s', _length_code[i],
+                SEPARATOR(i, MAX_MATCH-MIN_MATCH, 20));
+  end;
+
+  WriteLn(header, 'local const int base_length[LENGTH_CODES] := (');
+  for i := 0 to LENGTH_CODES-1 do
+  begin
+    WriteLn(header, '%1u%s', base_length[i],
+                SEPARATOR(i, LENGTH_CODES-1, 20));
+  end;
+
+  WriteLn(header, 'local const int base_dist[D_CODES] := (');
+  for i := 0 to D_CODES-1 do
+  begin
+    WriteLn(header, '%5u%s', base_dist[i],
+                SEPARATOR(i, D_CODES-1, 10));
+  end;
+
+  close(header);
+end;
+{$endif} { GEN_TREES_H }
+
+
+{ ===========================================================================
+  Initialize the various 'constant' tables. }
+
+{local}
+procedure tr_static_init;
+
+{$ifdef GEN_TREES_H}
+const
+  static_init_done : boolean = FALSE;
+var
+  n : int;        { iterates over tree elements }
+  bits : int;     { bit counter }
+  length : int;   { length value }
+  code : int;     { code value }
+  dist : int;     { distance index }
+  bl_count : array[0..MAX_BITS+1-1] of ush;
+    { number of codes at each bit length for an optimal tree }
+begin
+    if (static_init_done) then
+      exit;
+
+    { Initialize the mapping length (0..255) -> length code (0..28) }
+    length := 0;
+    for code := 0 to LENGTH_CODES-1-1 do
+    begin
+      base_length[code] := length;
+      for n := 0 to (1 shl extra_lbits[code])-1 do
+      begin
+        _length_code[length] := uch(code);
+        Inc(length);
+      end;
+    end;
+    Assert (length = 256, 'tr_static_init: length <> 256');
+    { Note that the length 255 (match length 258) can be represented
+      in two different ways: code 284 + 5 bits or code 285, so we
+      overwrite length_code[255] to use the best encoding: }
+
+    _length_code[length-1] := uch(code);
+
+    { Initialize the mapping dist (0..32K) -> dist code (0..29) }
+    dist := 0;
+    for code := 0 to 16-1 do
+    begin
+      base_dist[code] := dist;
+      for n := 0 to (1 shl extra_dbits[code])-1 do
+      begin
+        _dist_code[dist] := uch(code);
+        Inc(dist);
+      end;
+    end;
+    Assert (dist = 256, 'tr_static_init: dist <> 256');
+    dist := dist shr 7; { from now on, all distances are divided by 128 }
+    for code := 16 to D_CODES-1 do
+    begin
+      base_dist[code] := dist shl 7;
+      for n := 0 to (1 shl (extra_dbits[code]-7))-1 do
+      begin
+        _dist_code[256 + dist] := uch(code);
+        Inc(dist);
+      end;
+    end;
+    Assert (dist = 256, 'tr_static_init: 256+dist <> 512');
+
+    { Construct the codes of the static literal tree }
+    for bits := 0 to MAX_BITS do
+      bl_count[bits] := 0;
+    n := 0;
+    while (n <= 143) do
+    begin
+      static_ltree[n].dl.Len := 8;
+      Inc(n);
+      Inc(bl_count[8]);
+    end;
+    while (n <= 255) do
+    begin
+      static_ltree[n].dl.Len := 9;
+      Inc(n);
+      Inc(bl_count[9]);
+    end;
+    while (n <= 279) do
+    begin
+      static_ltree[n].dl.Len := 7;
+      Inc(n);
+      Inc(bl_count[7]);
+    end;
+    while (n <= 287) do
+    begin
+      static_ltree[n].dl.Len := 8;
+      Inc(n);
+      Inc(bl_count[8]);
+    end;
+
+    { Codes 286 and 287 do not exist, but we must include them in the
+      tree construction to get a canonical Huffman tree (longest code
+      all ones)  }
+
+    gen_codes(tree_ptr(@static_ltree), L_CODES+1, bl_count);
+
+    { The static distance tree is trivial: }
+    for n := 0 to D_CODES-1 do
+    begin
+      static_dtree[n].dl.Len := 5;
+      static_dtree[n].fc.Code := bi_reverse(unsigned(n), 5);
+    end;
+    static_init_done := TRUE;
+
+    gen_trees_header;  { save to include file }
+{$else}
+begin
+{$endif} { GEN_TREES_H) }
+end;
+
+{ ===========================================================================
+  Initialize a new block. }
+{local}
+
+procedure init_block(var s : deflate_state);
+var
+  n : int; { iterates over tree elements }
+begin
+  { Initialize the trees. }
+  for n := 0 to L_CODES-1 do
+    s.dyn_ltree[n].fc.Freq := 0;
+  for n := 0 to D_CODES-1 do
+    s.dyn_dtree[n].fc.Freq := 0;
+  for n := 0 to BL_CODES-1 do
+    s.bl_tree[n].fc.Freq := 0;
+
+  s.dyn_ltree[END_BLOCK].fc.Freq := 1;
+  s.static_len := Long(0);
+  s.opt_len := Long(0);
+  s.matches := 0;
+  s.last_lit := 0;
+end;
+
+const
+  SMALLEST = 1;
+{ Index within the heap array of least frequent node in the Huffman tree }
+
+{ ===========================================================================
+  Initialize the tree data structures for a new zlib stream. }
+procedure _tr_init(var s : deflate_state);
+begin
+  tr_static_init;
+
+  s.compressed_len := Long(0);
+
+  s.l_desc.dyn_tree := tree_ptr(@s.dyn_ltree);
+  s.l_desc.stat_desc := @static_l_desc;
+
+  s.d_desc.dyn_tree := tree_ptr(@s.dyn_dtree);
+  s.d_desc.stat_desc := @static_d_desc;
+
+  s.bl_desc.dyn_tree := tree_ptr(@s.bl_tree);
+  s.bl_desc.stat_desc := @static_bl_desc;
+
+  s.bi_buf := 0;
+  s.bi_valid := 0;
+  s.last_eob_len := 8; { enough lookahead for inflate }
+{$ifdef DEBUG}
+  s.bits_sent := Long(0);
+{$endif}
+
+  { Initialize the first block of the first file: }
+  init_block(s);
+end;
+
+{ ===========================================================================
+  Remove the smallest element from the heap and recreate the heap with
+  one less element. Updates heap and heap_len.
+
+macro pqremove(s, tree, top)
+begin
+    top := s.heap[SMALLEST];
+    s.heap[SMALLEST] := s.heap[s.heap_len];
+    Dec(s.heap_len);
+    pqdownheap(s, tree, SMALLEST);
+end
+}
+
+{ ===========================================================================
+  Compares to subtrees, using the tree depth as tie breaker when
+  the subtrees have equal frequency. This minimizes the worst case length.
+
+macro smaller(tree, n, m, depth)
+   ( (tree[n].Freq < tree[m].Freq) or
+     ((tree[n].Freq = tree[m].Freq) and (depth[n] <= depth[m])) )
+}
+
+{ ===========================================================================
+  Restore the heap property by moving down the tree starting at node k,
+  exchanging a node with the smallest of its two sons if necessary, stopping
+  when the heap property is re-established (each father smaller than its
+  two sons). }
+{local}
+
+procedure pqdownheap(var s : deflate_state;
+                     var tree : tree_type;   { the tree to restore }
+                     k : int);          { node to move down }
+var
+  v : int;
+  j : int;
+begin
+  v := s.heap[k];
+  j := k shl 1;  { left son of k }
+  while (j <= s.heap_len) do
+  begin
+    { Set j to the smallest of the two sons: }
+    if (j < s.heap_len) and
+       {smaller(tree, s.heap[j+1], s.heap[j], s.depth)}
+      ( (tree[s.heap[j+1]].fc.Freq < tree[s.heap[j]].fc.Freq) or
+        ((tree[s.heap[j+1]].fc.Freq = tree[s.heap[j]].fc.Freq) and
+         (s.depth[s.heap[j+1]] <= s.depth[s.heap[j]])) ) then
+    begin
+      Inc(j);
+    end;
+    { Exit if v is smaller than both sons }
+    if {(smaller(tree, v, s.heap[j], s.depth))}
+     ( (tree[v].fc.Freq < tree[s.heap[j]].fc.Freq) or
+       ((tree[v].fc.Freq = tree[s.heap[j]].fc.Freq) and
+        (s.depth[v] <= s.depth[s.heap[j]])) ) then
+      break;
+    { Exchange v with the smallest son }
+    s.heap[k] := s.heap[j];
+    k := j;
+
+    { And continue down the tree, setting j to the left son of k }
+    j := j shl 1;
+  end;
+  s.heap[k] := v;
+end;
+
+{ ===========================================================================
+  Compute the optimal bit lengths for a tree and update the total bit length
+  for the current block.
+  IN assertion: the fields freq and dad are set, heap[heap_max] and
+     above are the tree nodes sorted by increasing frequency.
+  OUT assertions: the field len is set to the optimal bit length, the
+      array bl_count contains the frequencies for each bit length.
+      The length opt_len is updated; static_len is also updated if stree is
+      not null. }
+
+{local}
+procedure gen_bitlen(var s : deflate_state;
+                     var desc : tree_desc);   { the tree descriptor }
+var
+  tree : tree_ptr;
+  max_code : int;
+  stree : tree_ptr; {const}
+  extra : pzIntfArray; {const}
+  base : int;
+  max_length : int;
+  h : int;              { heap index }
+  n, m : int;           { iterate over the tree elements }
+  bits : int;           { bit length }
+  xbits : int;          { extra bits }
+  f : ush;              { frequency }
+  overflow : int;   { number of elements with bit length too large }
+begin
+  tree := desc.dyn_tree;
+  max_code := desc.max_code;
+  stree := desc.stat_desc^.static_tree;
+  extra := desc.stat_desc^.extra_bits;
+  base := desc.stat_desc^.extra_base;
+  max_length := desc.stat_desc^.max_length;
+  overflow := 0;
+
+  for bits := 0 to MAX_BITS do
+    s.bl_count[bits] := 0;
+
+  { In a first pass, compute the optimal bit lengths (which may
+    overflow in the case of the bit length tree). }
+
+  tree^[s.heap[s.heap_max]].dl.Len := 0; { root of the heap }
+
+  for h := s.heap_max+1 to HEAP_SIZE-1 do
+  begin
+    n := s.heap[h];
+    bits := tree^[tree^[n].dl.Dad].dl.Len + 1;
+    if (bits > max_length) then
+    begin
+      bits := max_length;
+      Inc(overflow);
+    end;
+    tree^[n].dl.Len := ush(bits);
+    { We overwrite tree[n].dl.Dad which is no longer needed }
+
+    if (n > max_code) then
+      continue; { not a leaf node }
+
+    Inc(s.bl_count[bits]);
+    xbits := 0;
+    if (n >= base) then
+      xbits := extra^[n-base];
+    f := tree^[n].fc.Freq;
+    Inc(s.opt_len, ulg(f) * (bits + xbits));
+    if (stree <> NIL) then
+      Inc(s.static_len, ulg(f) * (stree^[n].dl.Len + xbits));
+  end;
+  if (overflow = 0) then
+    exit;
+  {$ifdef DEBUG}
+  Tracev(^M'bit length overflow');
+  {$endif}
+  { This happens for example on obj2 and pic of the Calgary corpus }
+
+  { Find the first bit length which could increase: }
+  repeat
+    bits := max_length-1;
+    while (s.bl_count[bits] = 0) do
+      Dec(bits);
+    Dec(s.bl_count[bits]);      { move one leaf down the tree }
+    Inc(s.bl_count[bits+1], 2); { move one overflow item as its brother }
+    Dec(s.bl_count[max_length]);
+    { The brother of the overflow item also moves one step up,
+      but this does not affect bl_count[max_length] }
+
+    Dec(overflow, 2);
+  until (overflow <= 0);
+
+  { Now recompute all bit lengths, scanning in increasing frequency.
+    h is still equal to HEAP_SIZE. (It is simpler to reconstruct all
+    lengths instead of fixing only the wrong ones. This idea is taken
+    from 'ar' written by Haruhiko Okumura.) }
+  h := HEAP_SIZE;  { Delphi3: compiler warning w/o this }
+  for bits := max_length downto 1 do
+  begin
+    n := s.bl_count[bits];
+    while (n <> 0) do
+    begin
+      Dec(h);
+      m := s.heap[h];
+      if (m > max_code) then
+        continue;
+      if (tree^[m].dl.Len <> unsigned(bits)) then
+      begin
+        {$ifdef DEBUG}
+        Trace('code '+IntToStr(m)+' bits '+IntToStr(tree^[m].dl.Len)
+              +'.'+IntToStr(bits));
+        {$ENDIF}
+        Inc(s.opt_len, (long(bits) - long(tree^[m].dl.Len))
+                        * long(tree^[m].fc.Freq) );
+        tree^[m].dl.Len := ush(bits);
+      end;
+      Dec(n);
+    end;
+  end;
+end;
+
+{ ===========================================================================
+  Construct one Huffman tree and assigns the code bit strings and lengths.
+  Update the total bit length for the current block.
+  IN assertion: the field freq is set for all tree elements.
+  OUT assertions: the fields len and code are set to the optimal bit length
+      and corresponding code. The length opt_len is updated; static_len is
+      also updated if stree is not null. The field max_code is set. }
+
+{local}
+procedure build_tree(var s : deflate_state;
+                     var desc : tree_desc); { the tree descriptor }
+
+var
+  tree : tree_ptr;
+  stree : tree_ptr; {const}
+  elems : int;
+  n, m : int;          { iterate over heap elements }
+  max_code : int;      { largest code with non zero frequency }
+  node : int;          { new node being created }
+begin
+  tree := desc.dyn_tree;
+  stree := desc.stat_desc^.static_tree;
+  elems := desc.stat_desc^.elems;
+  max_code := -1;
+
+  { Construct the initial heap, with least frequent element in
+    heap[SMALLEST]. The sons of heap[n] are heap[2*n] and heap[2*n+1].
+    heap[0] is not used. }
+  s.heap_len := 0;
+  s.heap_max := HEAP_SIZE;
+
+  for n := 0 to elems-1 do
+  begin
+    if (tree^[n].fc.Freq <> 0) then
+    begin
+      max_code := n;
+      Inc(s.heap_len);
+      s.heap[s.heap_len] := n;
+      s.depth[n] := 0;
+    end
+    else
+    begin
+      tree^[n].dl.Len := 0;
+    end;
+  end;
+
+  { The pkzip format requires that at least one distance code exists,
+    and that at least one bit should be sent even if there is only one
+    possible code. So to avoid special checks later on we force at least
+    two codes of non zero frequency. }
+
+  while (s.heap_len < 2) do
+  begin
+    Inc(s.heap_len);
+    if (max_code < 2) then
+    begin
+      Inc(max_code);
+      s.heap[s.heap_len] := max_code;
+      node := max_code;
+    end
+    else
+    begin
+      s.heap[s.heap_len] := 0;
+      node := 0;
+    end;
+    tree^[node].fc.Freq := 1;
+    s.depth[node] := 0;
+    Dec(s.opt_len);
+    if (stree <> NIL) then
+      Dec(s.static_len, stree^[node].dl.Len);
+    { node is 0 or 1 so it does not have extra bits }
+  end;
+  desc.max_code := max_code;
+
+  { The elements heap[heap_len/2+1 .. heap_len] are leaves of the tree,
+    establish sub-heaps of increasing lengths: }
+
+  for n := s.heap_len div 2 downto 1 do
+    pqdownheap(s, tree^, n);
+
+  { Construct the Huffman tree by repeatedly combining the least two
+    frequent nodes. }
+
+  node := elems;              { next internal node of the tree }
+  repeat
+    {pqremove(s, tree, n);}  { n := node of least frequency }
+    n := s.heap[SMALLEST];
+    s.heap[SMALLEST] := s.heap[s.heap_len];
+    Dec(s.heap_len);
+    pqdownheap(s, tree^, SMALLEST);
+
+    m := s.heap[SMALLEST]; { m := node of next least frequency }
+
+    Dec(s.heap_max);
+    s.heap[s.heap_max] := n; { keep the nodes sorted by frequency }
+    Dec(s.heap_max);
+    s.heap[s.heap_max] := m;
+
+    { Create a new node father of n and m }
+    tree^[node].fc.Freq := tree^[n].fc.Freq + tree^[m].fc.Freq;
+    { maximum }
+    if (s.depth[n] >= s.depth[m]) then
+      s.depth[node] := uch (s.depth[n] + 1)
+    else
+      s.depth[node] := uch (s.depth[m] + 1);
+
+    tree^[m].dl.Dad := ush(node);
+    tree^[n].dl.Dad := ush(node);
+{$ifdef DUMP_BL_TREE}
+    if (tree = tree_ptr(@s.bl_tree)) then
+    begin
+      WriteLn(#13'node ',node,'(',tree^[node].fc.Freq,') sons ',n,
+              '(',tree^[n].fc.Freq,') ', m, '(',tree^[m].fc.Freq,')');
+    end;
+{$endif}
+    { and insert the new node in the heap }
+    s.heap[SMALLEST] := node;
+    Inc(node);
+    pqdownheap(s, tree^, SMALLEST);
+
+  until (s.heap_len < 2);
+
+  Dec(s.heap_max);
+  s.heap[s.heap_max] := s.heap[SMALLEST];
+
+  { At this point, the fields freq and dad are set. We can now
+    generate the bit lengths. }
+
+  gen_bitlen(s, desc);
+
+  { The field len is now set, we can generate the bit codes }
+  gen_codes (tree, max_code, s.bl_count);
+end;
+
+{ ===========================================================================
+  Scan a literal or distance tree to determine the frequencies of the codes
+  in the bit length tree. }
+
+{local}
+procedure scan_tree(var s : deflate_state;
+                    var tree : array of ct_data;    { the tree to be scanned }
+                    max_code : int);    { and its largest code of non zero frequency }
+var
+  n : int;                 { iterates over all tree elements }
+  prevlen : int;           { last emitted length }
+  curlen : int;            { length of current code }
+  nextlen : int;           { length of next code }
+  count : int;             { repeat count of the current code }
+  max_count : int;         { max repeat count }
+  min_count : int;         { min repeat count }
+begin
+  prevlen := -1;
+  nextlen := tree[0].dl.Len;
+  count := 0;
+  max_count := 7;
+  min_count := 4;
+
+  if (nextlen = 0) then
+  begin
+    max_count := 138;
+    min_count := 3;
+  end;
+  tree[max_code+1].dl.Len := ush($ffff); { guard }
+
+  for n := 0 to max_code do
+  begin
+    curlen := nextlen;
+    nextlen := tree[n+1].dl.Len;
+    Inc(count);
+    if (count < max_count) and (curlen = nextlen) then
+      continue
+    else
+      if (count < min_count) then
+        Inc(s.bl_tree[curlen].fc.Freq, count)
+      else
+        if (curlen <> 0) then
+        begin
+          if (curlen <> prevlen) then
+            Inc(s.bl_tree[curlen].fc.Freq);
+          Inc(s.bl_tree[REP_3_6].fc.Freq);
+        end
+        else
+          if (count <= 10) then
+            Inc(s.bl_tree[REPZ_3_10].fc.Freq)
+          else
+            Inc(s.bl_tree[REPZ_11_138].fc.Freq);
+
+    count := 0;
+    prevlen := curlen;
+    if (nextlen = 0) then
+    begin
+      max_count := 138;
+      min_count := 3;
+    end
+    else
+      if (curlen = nextlen) then
+      begin
+        max_count := 6;
+        min_count := 3;
+      end
+      else
+      begin
+        max_count := 7;
+        min_count := 4;
+      end;
+  end;
+end;
+
+{ ===========================================================================
+  Send a literal or distance tree in compressed form, using the codes in
+  bl_tree. }
+
+{local}
+procedure send_tree(var s : deflate_state;
+                    var tree : array of ct_data;    { the tree to be scanned }
+                    max_code : int);    { and its largest code of non zero frequency }
+
+var
+  n : int;                { iterates over all tree elements }
+  prevlen : int;          { last emitted length }
+  curlen : int;           { length of current code }
+  nextlen : int;          { length of next code }
+  count : int;            { repeat count of the current code }
+  max_count : int;        { max repeat count }
+  min_count : int;        { min repeat count }
+begin
+  prevlen := -1;
+  nextlen := tree[0].dl.Len;
+  count := 0;
+  max_count := 7;
+  min_count := 4;
+
+  { tree[max_code+1].dl.Len := -1; }  { guard already set }
+  if (nextlen = 0) then
+  begin
+    max_count := 138;
+    min_count := 3;
+  end;
+
+  for n := 0 to max_code do
+  begin
+    curlen := nextlen;
+    nextlen := tree[n+1].dl.Len;
+    Inc(count);
+    if (count < max_count) and (curlen = nextlen) then
+      continue
+    else
+      if (count < min_count) then
+      begin
+        repeat
+          {$ifdef DEBUG}
+          Tracevvv(#13'cd '+IntToStr(curlen));
+          {$ENDIF}
+          send_bits(s, s.bl_tree[curlen].fc.Code, s.bl_tree[curlen].dl.Len);
+          Dec(count);
+        until (count = 0);
+      end
+      else
+        if (curlen <> 0) then
+        begin
+          if (curlen <> prevlen) then
+          begin
+            {$ifdef DEBUG}
+            Tracevvv(#13'cd '+IntToStr(curlen));
+            {$ENDIF}
+            send_bits(s, s.bl_tree[curlen].fc.Code, s.bl_tree[curlen].dl.Len);
+            Dec(count);
+          end;
+          {$IFDEF DEBUG}
+          Assert((count >= 3) and (count <= 6), ' 3_6?');
+          {$ENDIF}
+          {$ifdef DEBUG}
+          Tracevvv(#13'cd '+IntToStr(REP_3_6));
+          {$ENDIF}
+          send_bits(s, s.bl_tree[REP_3_6].fc.Code, s.bl_tree[REP_3_6].dl.Len);
+          send_bits(s, count-3, 2);
+        end
+        else
+          if (count <= 10) then
+          begin
+            {$ifdef DEBUG}
+            Tracevvv(#13'cd '+IntToStr(REPZ_3_10));
+            {$ENDIF}
+            send_bits(s, s.bl_tree[REPZ_3_10].fc.Code, s.bl_tree[REPZ_3_10].dl.Len);
+            send_bits(s, count-3, 3);
+          end
+          else
+          begin
+            {$ifdef DEBUG}
+            Tracevvv(#13'cd '+IntToStr(REPZ_11_138));
+            {$ENDIF}
+            send_bits(s, s.bl_tree[REPZ_11_138].fc.Code, s.bl_tree[REPZ_11_138].dl.Len);
+            send_bits(s, count-11, 7);
+          end;
+    count := 0;
+    prevlen := curlen;
+    if (nextlen = 0) then
+    begin
+      max_count := 138;
+      min_count := 3;
+    end
+    else
+      if (curlen = nextlen) then
+      begin
+        max_count := 6;
+        min_count := 3;
+      end
+      else
+      begin
+        max_count := 7;
+        min_count := 4;
+      end;
+  end;
+end;
+
+{ ===========================================================================
+  Construct the Huffman tree for the bit lengths and return the index in
+  bl_order of the last bit length code to send. }
+
+{local}
+function build_bl_tree(var s : deflate_state) : int;
+var
+  max_blindex : int;  { index of last bit length code of non zero freq }
+begin
+  { Determine the bit length frequencies for literal and distance trees }
+  scan_tree(s, s.dyn_ltree, s.l_desc.max_code);
+  scan_tree(s, s.dyn_dtree, s.d_desc.max_code);
+
+  { Build the bit length tree: }
+  build_tree(s, s.bl_desc);
+  { opt_len now includes the length of the tree representations, except
+    the lengths of the bit lengths codes and the 5+5+4 bits for the counts. }
+
+  { Determine the number of bit length codes to send. The pkzip format
+    requires that at least 4 bit length codes be sent. (appnote.txt says
+    3 but the actual value used is 4.) }
+
+  for max_blindex := BL_CODES-1 downto 3 do
+  begin
+    if (s.bl_tree[bl_order[max_blindex]].dl.Len <> 0) then
+      break;
+  end;
+  { Update opt_len to include the bit length tree and counts }
+  Inc(s.opt_len, 3*(max_blindex+1) + 5+5+4);
+  {$ifdef DEBUG}
+  Tracev(^M'dyn trees: dyn %ld, stat %ld {s.opt_len, s.static_len}');
+  {$ENDIF}
+
+  build_bl_tree := max_blindex;
+end;
+
+{ ===========================================================================
+  Send the header for a block using dynamic Huffman trees: the counts, the
+  lengths of the bit length codes, the literal tree and the distance tree.
+  IN assertion: lcodes >= 257, dcodes >= 1, blcodes >= 4. }
+
+{local}
+procedure send_all_trees(var s : deflate_state;
+                         lcodes : int;
+                         dcodes : int;
+                         blcodes : int); { number of codes for each tree }
+var
+  rank : int;                    { index in bl_order }
+begin
+  {$IFDEF DEBUG}
+  Assert ((lcodes >= 257) and (dcodes >= 1) and (blcodes >= 4),
+          'not enough codes');
+  Assert ((lcodes <= L_CODES) and (dcodes <= D_CODES)
+          and (blcodes <= BL_CODES), 'too many codes');
+  Tracev(^M'bl counts: ');
+  {$ENDIF}
+  send_bits(s, lcodes-257, 5); { not +255 as stated in appnote.txt }
+  send_bits(s, dcodes-1,   5);
+  send_bits(s, blcodes-4,  4); { not -3 as stated in appnote.txt }
+  for rank := 0 to blcodes-1 do
+  begin
+    {$ifdef DEBUG}
+    Tracev(^M'bl code '+IntToStr(bl_order[rank]));
+    {$ENDIF}
+    send_bits(s, s.bl_tree[bl_order[rank]].dl.Len, 3);
+  end;
+  {$ifdef DEBUG}
+  Tracev(^M'bl tree: sent '+IntToStr(s.bits_sent));
+  {$ENDIF}
+
+  send_tree(s, s.dyn_ltree, lcodes-1); { literal tree }
+  {$ifdef DEBUG}
+  Tracev(^M'lit tree: sent '+IntToStr(s.bits_sent));
+  {$ENDIF}
+
+  send_tree(s, s.dyn_dtree, dcodes-1); { distance tree }
+  {$ifdef DEBUG}
+  Tracev(^M'dist tree: sent '+IntToStr(s.bits_sent));
+  {$ENDIF}
+end;
+
+{ ===========================================================================
+  Flush the bit buffer and align the output on a byte boundary }
+
+{local}
+procedure bi_windup(var s : deflate_state);
+begin
+  if (s.bi_valid > 8) then
+  begin
+    {put_short(s, s.bi_buf);}
+    s.pending_buf^[s.pending] := uch(s.bi_buf and $ff);
+    Inc(s.pending);
+    s.pending_buf^[s.pending] := uch(ush(s.bi_buf) shr 8);;
+    Inc(s.pending);
+  end
+  else
+    if (s.bi_valid > 0) then
+    begin
+      {put_byte(s, (Byte)s^.bi_buf);}
+      s.pending_buf^[s.pending] := Byte(s.bi_buf);
+      Inc(s.pending);
+    end;
+  s.bi_buf := 0;
+  s.bi_valid := 0;
+{$ifdef DEBUG}
+  s.bits_sent := (s.bits_sent+7) and (not 7);
+{$endif}
+end;
+
+{ ===========================================================================
+  Copy a stored block, storing first the length and its
+  one's complement if requested. }
+
+{local}
+procedure copy_block(var s : deflate_state;
+                     buf : pcharf;      { the input data }
+                     len : unsigned;    { its length }
+                     header : boolean); { true if block header must be written }
+begin
+  bi_windup(s);        { align on byte boundary }
+  s.last_eob_len := 8; { enough lookahead for inflate }
+
+  if (header) then
+  begin
+    {put_short(s, (ush)len);}
+    s.pending_buf^[s.pending] := uch(ush(len) and $ff);
+    Inc(s.pending);
+    s.pending_buf^[s.pending] := uch(ush(len) shr 8);;
+    Inc(s.pending);
+    {put_short(s, (ush)~len);}
+    s.pending_buf^[s.pending] := uch(ush(not len) and $ff);
+    Inc(s.pending);
+    s.pending_buf^[s.pending] := uch(ush(not len) shr 8);;
+    Inc(s.pending);
+
+{$ifdef DEBUG}
+    Inc(s.bits_sent, 2*16);
+{$endif}
+  end;
+{$ifdef DEBUG}
+  Inc(s.bits_sent, ulg(len shl 3));
+{$endif}
+  while (len <> 0) do
+  begin
+    Dec(len);
+    {put_byte(s, *buf++);}
+    s.pending_buf^[s.pending] := buf^;
+    Inc(buf);
+    Inc(s.pending);
+  end;
+end;
+
+
+{ ===========================================================================
+  Send a stored block }
+
+procedure _tr_stored_block(var s : deflate_state;
+                           buf : pcharf;     { input block }
+                           stored_len : ulg; { length of input block }
+                           eof : boolean);   { true if this is the last block for a file }
+
+begin
+  send_bits(s, (STORED_BLOCK shl 1)+ord(eof), 3);  { send block type }
+  s.compressed_len := (s.compressed_len + 3 + 7) and ulg(not Long(7));
+  Inc(s.compressed_len, (stored_len + 4) shl 3);
+
+  copy_block(s, buf, unsigned(stored_len), TRUE); { with header }
+end;
+
+{ ===========================================================================
+  Flush the bit buffer, keeping at most 7 bits in it. }
+
+{local}
+procedure bi_flush(var s : deflate_state);
+begin
+  if (s.bi_valid = 16) then
+  begin
+    {put_short(s, s.bi_buf);}
+    s.pending_buf^[s.pending] := uch(s.bi_buf and $ff);
+    Inc(s.pending);
+    s.pending_buf^[s.pending] := uch(ush(s.bi_buf) shr 8);;
+    Inc(s.pending);
+
+    s.bi_buf := 0;
+    s.bi_valid := 0;
+  end
+  else
+   if (s.bi_valid >= 8) then
+   begin
+     {put_byte(s, (Byte)s^.bi_buf);}
+     s.pending_buf^[s.pending] := Byte(s.bi_buf);
+     Inc(s.pending);
+
+     s.bi_buf := s.bi_buf shr 8;
+     Dec(s.bi_valid, 8);
+   end;
+end;
+
+
+{ ===========================================================================
+  Send one empty static block to give enough lookahead for inflate.
+  This takes 10 bits, of which 7 may remain in the bit buffer.
+  The current inflate code requires 9 bits of lookahead. If the
+  last two codes for the previous block (real code plus EOB) were coded
+  on 5 bits or less, inflate may have only 5+3 bits of lookahead to decode
+  the last real code. In this case we send two empty static blocks instead
+  of one. (There are no problems if the previous block is stored or fixed.)
+  To simplify the code, we assume the worst case of last real code encoded
+  on one bit only. }
+
+procedure _tr_align(var s : deflate_state);
+begin
+  send_bits(s, STATIC_TREES shl 1, 3);
+  {$ifdef DEBUG}
+  Tracevvv(#13'cd '+IntToStr(END_BLOCK));
+  {$ENDIF}
+  send_bits(s, static_ltree[END_BLOCK].fc.Code, static_ltree[END_BLOCK].dl.Len);
+  Inc(s.compressed_len, Long(10)); { 3 for block type, 7 for EOB }
+  bi_flush(s);
+  { Of the 10 bits for the empty block, we have already sent
+    (10 - bi_valid) bits. The lookahead for the last real code (before
+    the EOB of the previous block) was thus at least one plus the length
+    of the EOB plus what we have just sent of the empty static block. }
+  if (1 + s.last_eob_len + 10 - s.bi_valid < 9) then
+  begin
+    send_bits(s, STATIC_TREES shl 1, 3);
+    {$ifdef DEBUG}
+    Tracevvv(#13'cd '+IntToStr(END_BLOCK));
+    {$ENDIF}
+    send_bits(s, static_ltree[END_BLOCK].fc.Code, static_ltree[END_BLOCK].dl.Len);
+    Inc(s.compressed_len, Long(10));
+    bi_flush(s);
+  end;
+  s.last_eob_len := 7;
+end;
+
+{ ===========================================================================
+  Set the data type to ASCII or BINARY, using a crude approximation:
+  binary if more than 20% of the bytes are <= 6 or >= 128, ascii otherwise.
+  IN assertion: the fields freq of dyn_ltree are set and the total of all
+  frequencies does not exceed 64K (to fit in an int on 16 bit machines). }
+
+{local}
+procedure set_data_type(var s : deflate_state);
+var
+  n : int;
+  ascii_freq : unsigned;
+  bin_freq : unsigned;
+begin
+  n := 0;
+  ascii_freq := 0;
+  bin_freq := 0;
+
+  while (n < 7) do
+  begin
+    Inc(bin_freq, s.dyn_ltree[n].fc.Freq);
+    Inc(n);
+  end;
+  while (n < 128) do
+  begin
+    Inc(ascii_freq, s.dyn_ltree[n].fc.Freq);
+    Inc(n);
+  end;
+  while (n < LITERALS) do
+  begin
+    Inc(bin_freq, s.dyn_ltree[n].fc.Freq);
+    Inc(n);
+  end;
+  if (bin_freq > (ascii_freq shr 2)) then
+    s.data_type := Byte(Z_BINARY)
+  else
+    s.data_type := Byte(Z_ASCII);
+end;
+
+{ ===========================================================================
+  Send the block data compressed using the given Huffman trees }
+
+{local}
+procedure compress_block(var s : deflate_state;
+                         var ltree : array of ct_data;   { literal tree }
+                         var dtree : array of ct_data);  { distance tree }
+var
+  dist : unsigned;      { distance of matched string }
+  lc : int;             { match length or unmatched char (if dist == 0) }
+  lx : unsigned;        { running index in l_buf }
+  code : unsigned;      { the code to send }
+  extra : int;          { number of extra bits to send }
+begin
+  lx := 0;
+  if (s.last_lit <> 0) then
+  repeat
+    dist := s.d_buf^[lx];
+    lc := s.l_buf^[lx];
+    Inc(lx);
+    if (dist = 0) then
+    begin
+      { send a literal byte }
+      {$ifdef DEBUG}
+      Tracevvv(#13'cd '+IntToStr(lc));
+      Tracecv((lc > 31) and (lc < 128), ' '+char(lc)+' ');
+      {$ENDIF}
+      send_bits(s, ltree[lc].fc.Code, ltree[lc].dl.Len);
+    end
+    else
+    begin
+      { Here, lc is the match length - MIN_MATCH }
+      code := _length_code[lc];
+      { send the length code }
+      {$ifdef DEBUG}
+      Tracevvv(#13'cd '+IntToStr(code+LITERALS+1));
+      {$ENDIF}
+      send_bits(s, ltree[code+LITERALS+1].fc.Code, ltree[code+LITERALS+1].dl.Len);
+      extra := extra_lbits[code];
+      if (extra <> 0) then
+      begin
+        Dec(lc, base_length[code]);
+        send_bits(s, lc, extra);       { send the extra length bits }
+      end;
+      Dec(dist); { dist is now the match distance - 1 }
+      {code := d_code(dist);}
+      if (dist < 256) then
+        code := _dist_code[dist]
+      else
+        code := _dist_code[256+(dist shr 7)];
+
+      {$IFDEF DEBUG}
+      Assert (code < D_CODES, 'bad d_code');
+      {$ENDIF}
+
+      { send the distance code }
+      {$ifdef DEBUG}
+      Tracevvv(#13'cd '+IntToStr(code));
+      {$ENDIF}
+      send_bits(s, dtree[code].fc.Code, dtree[code].dl.Len);
+      extra := extra_dbits[code];
+      if (extra <> 0) then
+      begin
+        Dec(dist, base_dist[code]);
+        send_bits(s, dist, extra);   { send the extra distance bits }
+      end;
+    end; { literal or match pair ? }
+
+    { Check that the overlay between pending_buf and d_buf+l_buf is ok: }
+    {$IFDEF DEBUG}
+    Assert(s.pending < s.lit_bufsize + 2*lx, 'pendingBuf overflow');
+    {$ENDIF}
+  until (lx >= s.last_lit);
+
+  {$ifdef DEBUG}
+  Tracevvv(#13'cd '+IntToStr(END_BLOCK));
+  {$ENDIF}
+  send_bits(s, ltree[END_BLOCK].fc.Code, ltree[END_BLOCK].dl.Len);
+  s.last_eob_len := ltree[END_BLOCK].dl.Len;
+end;
+
+
+{ ===========================================================================
+  Determine the best encoding for the current block: dynamic trees, static
+  trees or store, and output the encoded block to the zip file. This function
+  returns the total compressed length for the file so far. }
+
+function _tr_flush_block (var s : deflate_state;
+         buf : pcharf;         { input block, or NULL if too old }
+         stored_len : ulg;     { length of input block }
+         eof : boolean) : ulg; { true if this is the last block for a file }
+var
+  opt_lenb, static_lenb : ulg; { opt_len and static_len in bytes }
+  max_blindex : int;  { index of last bit length code of non zero freq }
+begin
+  max_blindex := 0;
+
+  { Build the Huffman trees unless a stored block is forced }
+  if (s.level > 0) then
+  begin
+    { Check if the file is ascii or binary }
+    if (s.data_type = Z_UNKNOWN) then
+      set_data_type(s);
+
+    { Construct the literal and distance trees }
+    build_tree(s, s.l_desc);
+    {$ifdef DEBUG}
+    Tracev(^M'lit data: dyn %ld, stat %ld {s.opt_len, s.static_len}');
+    {$ENDIF}
+
+    build_tree(s, s.d_desc);
+    {$ifdef DEBUG}
+    Tracev(^M'dist data: dyn %ld, stat %ld {s.opt_len, s.static_len}');
+    {$ENDIF}
+    { At this point, opt_len and static_len are the total bit lengths of
+      the compressed block data, excluding the tree representations. }
+
+    { Build the bit length tree for the above two trees, and get the index
+      in bl_order of the last bit length code to send. }
+    max_blindex := build_bl_tree(s);
+
+    { Determine the best encoding. Compute first the block length in bytes}
+    opt_lenb := (s.opt_len+3+7) shr 3;
+    static_lenb := (s.static_len+3+7) shr 3;
+
+    {$ifdef DEBUG}
+    Tracev(^M'opt %lu(%lu) stat %lu(%lu) stored %lu lit %u '+
+            '{opt_lenb, s.opt_len, static_lenb, s.static_len, stored_len,'+
+            's.last_lit}');
+    {$ENDIF}
+
+    if (static_lenb <= opt_lenb) then
+      opt_lenb := static_lenb;
+
+  end
+  else
+  begin
+    {$IFDEF DEBUG}
+    Assert(buf <> pcharf(NIL), 'lost buf');
+    {$ENDIF}
+    static_lenb := stored_len + 5;
+    opt_lenb := static_lenb;        { force a stored block }
+  end;
+
+  { If compression failed and this is the first and last block,
+    and if the .zip file can be seeked (to rewrite the local header),
+    the whole file is transformed into a stored file:  }
+
+{$ifdef STORED_FILE_OK}
+{$ifdef FORCE_STORED_FILE}
+  if eof and (s.compressed_len = Long(0)) then
+  begin { force stored file }
+{$else}
+  if (stored_len <= opt_lenb) and eof and (s.compressed_len=Long(0))
+     and seekable()) do
+  begin
+{$endif}
+    { Since LIT_BUFSIZE <= 2*WSIZE, the input data must be there: }
+    if (buf = pcharf(0)) then
+      error ('block vanished');
+
+    copy_block(buf, unsigned(stored_len), 0); { without header }
+    s.compressed_len := stored_len shl 3;
+    s.method := STORED;
+  end
+  else
+{$endif} { STORED_FILE_OK }
+
+{$ifdef FORCE_STORED}
+  if (buf <> pchar(0)) then
+  begin { force stored block }
+{$else}
+  if (stored_len+4 <= opt_lenb) and (buf <> pcharf(0)) then
+  begin
+                     { 4: two words for the lengths }
+{$endif}
+    { The test buf <> NULL is only necessary if LIT_BUFSIZE > WSIZE.
+      Otherwise we can't have processed more than WSIZE input bytes since
+      the last block flush, because compression would have been
+      successful. If LIT_BUFSIZE <= WSIZE, it is never too late to
+      transform a block into a stored block. }
+
+    _tr_stored_block(s, buf, stored_len, eof);
+
+{$ifdef FORCE_STATIC}
+  end
+  else
+    if (static_lenb >= 0) then
+    begin { force static trees }
+{$else}
+  end
+  else
+    if (static_lenb = opt_lenb) then
+    begin
+{$endif}
+      send_bits(s, (STATIC_TREES shl 1)+ord(eof), 3);
+      compress_block(s, static_ltree, static_dtree);
+      Inc(s.compressed_len, 3 + s.static_len);
+    end
+    else
+    begin
+      send_bits(s, (DYN_TREES shl 1)+ord(eof), 3);
+      send_all_trees(s, s.l_desc.max_code+1, s.d_desc.max_code+1,
+                     max_blindex+1);
+      compress_block(s, s.dyn_ltree, s.dyn_dtree);
+      Inc(s.compressed_len, 3 + s.opt_len);
+    end;
+  {$ifdef DEBUG}
+  Assert (s.compressed_len = s.bits_sent, 'bad compressed size');
+  {$ENDIF}
+  init_block(s);
+
+  if (eof) then
+  begin
+    bi_windup(s);
+    Inc(s.compressed_len, 7);  { align on byte boundary }
+  end;
+  {$ifdef DEBUG}
+  Tracev(#13'comprlen %lu(%lu) {s.compressed_len shr 3,'+
+         's.compressed_len-7*ord(eof)}');
+  {$ENDIF}
+
+  _tr_flush_block := s.compressed_len shr 3;
+end;
+
+
+{ ===========================================================================
+  Save the match info and tally the frequency counts. Return true if
+  the current block must be flushed. }
+
+function _tr_tally (var s : deflate_state;
+   dist : unsigned;          { distance of matched string }
+   lc : unsigned) : boolean; { match length-MIN_MATCH or unmatched char (if dist=0) }
+var
+  {$IFDEF DEBUG}
+  MAX_DIST : ush;
+  {$ENDIF}
+  code : ush;
+{$ifdef TRUNCATE_BLOCK}
+var
+  out_length : ulg;
+  in_length : ulg;
+  dcode : int;
+{$endif}
+begin
+  s.d_buf^[s.last_lit] := ush(dist);
+  s.l_buf^[s.last_lit] := uch(lc);
+  Inc(s.last_lit);
+  if (dist = 0) then
+  begin
+    { lc is the unmatched char }
+    Inc(s.dyn_ltree[lc].fc.Freq);
+  end
+  else
+  begin
+    Inc(s.matches);
+    { Here, lc is the match length - MIN_MATCH }
+    Dec(dist);             { dist := match distance - 1 }
+
+    {macro d_code(dist)}
+    if (dist) < 256 then
+      code := _dist_code[dist]
+    else
+      code := _dist_code[256+(dist shr 7)];
+    {$IFDEF DEBUG}
+{macro  MAX_DIST(s) <=> ((s)^.w_size-MIN_LOOKAHEAD)
+   In order to simplify the code, particularly on 16 bit machines, match
+   distances are limited to MAX_DIST instead of WSIZE. }
+    MAX_DIST := ush(s.w_size-MIN_LOOKAHEAD);
+    Assert((dist < ush(MAX_DIST)) and
+           (ush(lc) <= ush(MAX_MATCH-MIN_MATCH)) and
+           (ush(code) < ush(D_CODES)),  '_tr_tally: bad match');
+    {$ENDIF}
+    Inc(s.dyn_ltree[_length_code[lc]+LITERALS+1].fc.Freq);
+    {s.dyn_dtree[d_code(dist)].Freq++;}
+    Inc(s.dyn_dtree[code].fc.Freq);
+  end;
+
+{$ifdef TRUNCATE_BLOCK}
+  { Try to guess if it is profitable to stop the current block here }
+  if (s.last_lit and $1fff = 0) and (s.level > 2) then
+  begin
+    { Compute an upper bound for the compressed length }
+    out_length := ulg(s.last_lit)*Long(8);
+    in_length := ulg(long(s.strstart) - s.block_start);
+    for dcode := 0 to D_CODES-1 do
+    begin
+      Inc(out_length, ulg(s.dyn_dtree[dcode].fc.Freq *
+            (Long(5)+extra_dbits[dcode])) );
+    end;
+    out_length := out_length shr 3;
+    {$ifdef DEBUG}
+    Tracev(^M'last_lit %u, in %ld, out ~%ld(%ld%%) ');
+          { s.last_lit, in_length, out_length,
+           Long(100) - out_length*Long(100) div in_length)); }
+    {$ENDIF}
+    if (s.matches < s.last_lit div 2) and (out_length < in_length div 2) then
+    begin
+      _tr_tally := TRUE;
+      exit;
+    end;
+  end;
+{$endif}
+  _tr_tally := (s.last_lit = s.lit_bufsize-1);
+  { We avoid equality with lit_bufsize because of wraparound at 64K
+    on 16 bit machines and because stored blocks are restricted to
+    64K-1 bytes. }
+end;
+
+end.

+ 515 - 0
packages/base/paszlib/zbase.pas

@@ -0,0 +1,515 @@
+Unit Zbase;
+
+
+{ Original:
+   zlib.h -- interface of the 'zlib' general purpose compression library
+  version 1.1.0, Feb 24th, 1998
+
+  Copyright (C) 1995-1998 Jean-loup Gailly and Mark Adler
+
+  This software is provided 'as-is', without any express or implied
+  warranty.  In no event will the authors be held liable for any damages
+  arising from the use of this software.
+
+  Permission is granted to anyone to use this software for any purpose,
+  including commercial applications, and to alter it and redistribute it
+  freely, subject to the following restrictions:
+
+  1. The origin of this software must not be misrepresented; you must not
+     claim that you wrote the original software. If you use this software
+     in a product, an acknowledgment in the product documentation would be
+     appreciated but is not required.
+  2. Altered source versions must be plainly marked as such, and must not be
+     misrepresented as being the original software.
+  3. This notice may not be removed or altered from any source distribution.
+
+  Jean-loup Gailly        Mark Adler
+  [email protected]          [email protected]
+
+
+  The data format used by the zlib library is described by RFCs (Request for
+  Comments) 1950 to 1952 in the files ftp://ds.internic.net/rfc/rfc1950.txt
+  (zlib format), rfc1951.txt (deflate format) and rfc1952.txt (gzip format).
+
+
+  Pascal tranlastion
+  Copyright (C) 1998 by Jacques Nomssi Nzali
+  For conditions of distribution and use, see copyright notice in readme.txt
+}
+
+interface
+
+{$I zconf.inc}
+
+uses
+  zutil;
+
+{ zconf.h -- configuration of the zlib compression library }
+{ zutil.c -- target dependent utility functions for the compression library }
+
+{ The 'zlib' compression library provides in-memory compression and
+  decompression functions, including integrity checks of the uncompressed
+  data.  This version of the library supports only one compression method
+  (deflation) but other algorithms will be added later and will have the same
+  stream interface.
+
+     Compression can be done in a single step if the buffers are large
+  enough (for example if an input file is mmap'ed), or can be done by
+  repeated calls of the compression function.  In the latter case, the
+  application must provide more input and/or consume the output
+  (providing more output space) before each call.
+
+     The library also supports reading and writing files in gzip (.gz) format
+  with an interface similar to that of stdio.
+
+     The library does not install any signal handler. The decoder checks
+  the consistency of the compressed data, so the library should never
+  crash even in case of corrupted input. }
+
+
+
+{ Compile with -DMAXSEG_64K if the alloc function cannot allocate more
+  than 64k bytes at a time (needed on systems with 16-bit int). }
+
+{ Maximum value for memLevel in deflateInit2 }
+{$ifdef MAXSEG_64K}
+const
+  MAX_MEM_LEVEL = 8;
+  DEF_MEM_LEVEL = MAX_MEM_LEVEL;  { default memLevel }
+{$else}
+const
+  MAX_MEM_LEVEL = 9;
+  DEF_MEM_LEVEL = 8; { if MAX_MEM_LEVEL > 8 }
+{$endif}
+
+{ Maximum value for windowBits in deflateInit2 and inflateInit2 }
+const
+  MAX_WBITS = 15; { 32K LZ77 window }
+{ default windowBits for decompression. MAX_WBITS is for compression only }
+const
+  DEF_WBITS = MAX_WBITS;
+
+{ The memory requirements for deflate are (in bytes):
+            1 shl (windowBits+2)   +  1 shl (memLevel+9)
+ that is: 128K for windowBits=15  +  128K for memLevel = 8  (default values)
+ plus a few kilobytes for small objects. For example, if you want to reduce
+ the default memory requirements from 256K to 128K, compile with
+     DMAX_WBITS=14 DMAX_MEM_LEVEL=7
+ Of course this will generally degrade compression (there's no free lunch).
+
+ The memory requirements for inflate are (in bytes) 1 shl windowBits
+ that is, 32K for windowBits=15 (default value) plus a few kilobytes
+ for small objects. }
+
+
+{ Huffman code lookup table entry--this entry is four bytes for machines
+  that have 16-bit pointers (e.g. PC's in the small or medium model). }
+
+type
+  pInflate_huft = ^inflate_huft;
+  inflate_huft = Record
+    Exop,             { number of extra bits or operation }
+    bits : Byte;      { number of bits in this code or subcode }
+    {pad : uInt;}       { pad structure to a power of 2 (4 bytes for }
+                      {  16-bit, 8 bytes for 32-bit int's) }
+    base : uInt;      { literal, length base, or distance base }
+                      { or table offset }
+  End;
+
+type
+  huft_field = Array[0..(MaxInt div SizeOf(inflate_huft))-1] of inflate_huft;
+  huft_ptr = ^huft_field;
+type
+  ppInflate_huft = ^pInflate_huft;
+
+type
+  inflate_codes_mode = ( { waiting for "i:"=input, "o:"=output, "x:"=nothing }
+        START,    { x: set up for LEN }
+        LEN,      { i: get length/literal/eob next }
+        LENEXT,   { i: getting length extra (have base) }
+        DIST,     { i: get distance next }
+        DISTEXT,  { i: getting distance extra }
+        COPY,     { o: copying bytes in window, waiting for space }
+        LIT,      { o: got literal, waiting for output space }
+        WASH,     { o: got eob, possibly still output waiting }
+        ZEND,     { x: got eob and all data flushed }
+        BADCODE); { x: got error }
+
+{ inflate codes private state }
+type
+  pInflate_codes_state = ^inflate_codes_state;
+  inflate_codes_state = record
+
+    mode : inflate_codes_mode;        { current inflate_codes mode }
+
+    { mode dependent information }
+    len : uInt;
+    sub : record                      { submode }
+      Case Byte of
+      0:(code : record                { if LEN or DIST, where in tree }
+          tree : pInflate_huft;       { pointer into tree }
+          need : uInt;                { bits needed }
+         end);
+      1:(lit : uInt);                 { if LIT, literal }
+      2:(copy: record                 { if EXT or COPY, where and how much }
+           get : uInt;                { bits to get for extra }
+           dist : uInt;               { distance back to copy from }
+         end);
+    end;
+
+    { mode independent information }
+    lbits : Byte;                     { ltree bits decoded per branch }
+    dbits : Byte;                     { dtree bits decoder per branch }
+    ltree : pInflate_huft;            { literal/length/eob tree }
+    dtree : pInflate_huft;            { distance tree }
+  end;
+
+type
+  check_func = function(check : uLong;
+                        buf : pBytef;
+                        {const buf : array of byte;}
+                        len : uInt) : uLong;
+type
+  inflate_block_mode =
+     (ZTYPE,    { get type bits (3, including end bit) }
+      LENS,     { get lengths for stored }
+      STORED,   { processing stored block }
+      TABLE,    { get table lengths }
+      BTREE,    { get bit lengths tree for a dynamic block }
+      DTREE,    { get length, distance trees for a dynamic block }
+      CODES,    { processing fixed or dynamic block }
+      DRY,      { output remaining window bytes }
+      BLKDONE,  { finished last block, done }
+      BLKBAD);  { got a data error--stuck here }
+
+type
+  pInflate_blocks_state = ^inflate_blocks_state;
+
+{ inflate blocks semi-private state }
+  inflate_blocks_state = record
+
+    mode : inflate_block_mode;     { current inflate_block mode }
+
+    { mode dependent information }
+    sub : record                  { submode }
+    case Byte of
+    0:(left : uInt);              { if STORED, bytes left to copy }
+    1:(trees : record             { if DTREE, decoding info for trees }
+        table : uInt;               { table lengths (14 bits) }
+        index : uInt;               { index into blens (or border) }
+        blens : PuIntArray;         { bit lengths of codes }
+        bb : uInt;                  { bit length tree depth }
+        tb : pInflate_huft;         { bit length decoding tree }
+      end);
+    2:(decode : record            { if CODES, current state }
+        tl : pInflate_huft;
+        td : pInflate_huft;         { trees to free }
+        codes : pInflate_codes_state;
+      end);
+    end;
+    last : boolean;               { true if this block is the last block }
+
+    { mode independent information }
+    bitk : uInt;            { bits in bit buffer }
+    bitb : uLong;           { bit buffer }
+    hufts : huft_ptr; {pInflate_huft;}  { single malloc for tree space }
+    window : pBytef;        { sliding window }
+    zend : pBytef;          { one byte after sliding window }
+    read : pBytef;          { window read pointer }
+    write : pBytef;         { window write pointer }
+    checkfn : check_func;   { check function }
+    check : uLong;          { check on output }
+  end;
+
+type
+  inflate_mode = (
+      METHOD,   { waiting for method byte }
+      FLAG,     { waiting for flag byte }
+      DICT4,    { four dictionary check bytes to go }
+      DICT3,    { three dictionary check bytes to go }
+      DICT2,    { two dictionary check bytes to go }
+      DICT1,    { one dictionary check byte to go }
+      DICT0,    { waiting for inflateSetDictionary }
+      BLOCKS,   { decompressing blocks }
+      CHECK4,   { four check bytes to go }
+      CHECK3,   { three check bytes to go }
+      CHECK2,   { two check bytes to go }
+      CHECK1,   { one check byte to go }
+      DONE,     { finished check, done }
+      BAD);     { got an error--stay here }
+
+{ inflate private state }
+type
+  pInternal_state = ^internal_state; { or point to a deflate_state record }
+  internal_state = record
+
+     mode : inflate_mode;  { current inflate mode }
+
+     { mode dependent information }
+     sub : record          { submode }
+       case byte of
+       0:(method : uInt);  { if FLAGS, method byte }
+       1:(check : record   { if CHECK, check values to compare }
+           was : uLong;        { computed check value }
+           need : uLong;       { stream check value }
+          end);
+       2:(marker : uInt);  { if BAD, inflateSync's marker bytes count }
+     end;
+
+     { mode independent information }
+     nowrap : boolean;      { flag for no wrapper }
+     wbits : uInt;          { log2(window size)  (8..15, defaults to 15) }
+     blocks : pInflate_blocks_state;    { current inflate_blocks state }
+   end;
+
+type
+  alloc_func = function(opaque : voidpf; items : uInt; size : uInt) : voidpf;
+  free_func = procedure(opaque : voidpf; address : voidpf);
+
+type
+  z_streamp = ^z_stream;
+  z_stream = record
+    next_in : pBytef;     { next input byte }
+    avail_in : uInt;      { number of bytes available at next_in }
+    total_in : uLong;     { total nb of input bytes read so far }
+
+    next_out : pBytef;    { next output byte should be put there }
+    avail_out : uInt;     { remaining free space at next_out }
+    total_out : uLong;    { total nb of bytes output so far }
+
+    msg : string;         { last error message, '' if no error }
+    state : pInternal_state; { not visible by applications }
+
+    zalloc : alloc_func;  { used to allocate the internal state }
+    zfree : free_func;    { used to free the internal state }
+    opaque : voidpf;      { private data object passed to zalloc and zfree }
+
+    data_type : int;      { best guess about the data type: ascii or binary }
+    adler : uLong;        { adler32 value of the uncompressed data }
+    reserved : uLong;     { reserved for future use }
+  end;
+{$ifdef fpc}
+  TZStream = z_stream;
+  PZStream = ^TZStream;
+{$endif}
+
+{  The application must update next_in and avail_in when avail_in has
+   dropped to zero. It must update next_out and avail_out when avail_out
+   has dropped to zero. The application must initialize zalloc, zfree and
+   opaque before calling the init function. All other fields are set by the
+   compression library and must not be updated by the application.
+
+   The opaque value provided by the application will be passed as the first
+   parameter for calls of zalloc and zfree. This can be useful for custom
+   memory management. The compression library attaches no meaning to the
+   opaque value.
+
+   zalloc must return Z_NULL if there is not enough memory for the object.
+   On 16-bit systems, the functions zalloc and zfree must be able to allocate
+   exactly 65536 bytes, but will not be required to allocate more than this
+   if the symbol MAXSEG_64K is defined (see zconf.h). WARNING: On MSDOS,
+   pointers returned by zalloc for objects of exactly 65536 bytes *must*
+   have their offset normalized to zero. The default allocation function
+   provided by this library ensures this (see zutil.c). To reduce memory
+   requirements and avoid any allocation of 64K objects, at the expense of
+   compression ratio, compile the library with -DMAX_WBITS=14 (see zconf.h).
+
+   The fields total_in and total_out can be used for statistics or
+   progress reports. After compression, total_in holds the total size of
+   the uncompressed data and may be saved for use in the decompressor
+   (particularly if the decompressor wants to decompress everything in
+   a single step). }
+
+const  { constants }
+   Z_NO_FLUSH      = 0;
+   Z_PARTIAL_FLUSH = 1;
+   Z_SYNC_FLUSH    = 2;
+   Z_FULL_FLUSH    = 3;
+   Z_FINISH        = 4;
+{ Allowed flush values; see deflate() below for details }
+
+   Z_OK            = 0;
+   Z_STREAM_END    = 1;
+   Z_NEED_DICT     = 2;
+   Z_ERRNO         = (-1);
+   Z_STREAM_ERROR  = (-2);
+   Z_DATA_ERROR    = (-3);
+   Z_MEM_ERROR     = (-4);
+   Z_BUF_ERROR     = (-5);
+   Z_VERSION_ERROR = (-6);
+{ Return codes for the compression/decompression functions. Negative
+  values are errors, positive values are used for special but normal events.}
+
+   Z_NO_COMPRESSION         = 0;
+   Z_BEST_SPEED             = 1;
+   Z_BEST_COMPRESSION       = 9;
+   Z_DEFAULT_COMPRESSION    = (-1);
+{ compression levels }
+
+   Z_FILTERED            = 1;
+   Z_HUFFMAN_ONLY        = 2;
+   Z_DEFAULT_STRATEGY    = 0;
+{ compression strategy; see deflateInit2() below for details }
+
+   Z_BINARY   = 0;
+   Z_ASCII    = 1;
+   Z_UNKNOWN  = 2;
+{ Possible values of the data_type field }
+
+   Z_DEFLATED   = 8;
+{ The deflate compression method (the only one supported in this version) }
+
+   Z_NULL  = NIL;  { for initializing zalloc, zfree, opaque }
+
+  {$IFDEF GZIO}
+var
+  errno : int;
+  {$ENDIF}
+
+        { common constants }
+
+
+{ The three kinds of block type }
+const
+  STORED_BLOCK = 0;
+  STATIC_TREES = 1;
+  DYN_TREES = 2;
+{ The minimum and maximum match lengths }
+const
+  MIN_MATCH = 3;
+{$ifdef MAX_MATCH_IS_258}
+  MAX_MATCH = 258;
+{$else}
+  MAX_MATCH = ??;    { deliberate syntax error }
+{$endif}
+
+const
+  PRESET_DICT = $20; { preset dictionary flag in zlib header }
+
+
+  {$IFDEF DEBUG}
+  procedure Assert(cond : boolean; msg : string);
+  {$ENDIF}
+
+  procedure Trace(x : string);
+  procedure Tracev(x : string);
+  procedure Tracevv(x : string);
+  procedure Tracevvv(x : string);
+  procedure Tracec(c : boolean; x : string);
+  procedure Tracecv(c : boolean; x : string);
+
+function zlibVersion : string;
+{ The application can compare zlibVersion and ZLIB_VERSION for consistency.
+  If the first character differs, the library code actually used is
+  not compatible with the zlib.h header file used by the application.
+  This check is automatically made by deflateInit and inflateInit. }
+
+function zError(err : int) : string;
+
+function ZALLOC (var strm : z_stream; items : uInt; size : uInt) : voidpf;
+
+procedure ZFREE (var strm : z_stream; ptr : voidpf);
+
+procedure TRY_FREE (var strm : z_stream; ptr : voidpf);
+
+const
+  ZLIB_VERSION : string[10] = '1.1.2';
+
+const
+  z_errbase = Z_NEED_DICT;
+  z_errmsg : Array[0..9] of string[21] = { indexed by 2-zlib_error }
+           ('need dictionary',     { Z_NEED_DICT       2  }
+            'stream end',          { Z_STREAM_END      1  }
+            '',                    { Z_OK              0  }
+            'file error',          { Z_ERRNO         (-1) }
+            'stream error',        { Z_STREAM_ERROR  (-2) }
+            'data error',          { Z_DATA_ERROR    (-3) }
+            'insufficient memory', { Z_MEM_ERROR     (-4) }
+            'buffer error',        { Z_BUF_ERROR     (-5) }
+            'incompatible version',{ Z_VERSION_ERROR (-6) }
+            '');
+const
+  z_verbose : int = 1;
+
+{$IFDEF DEBUG}
+procedure z_error (m : string);
+{$ENDIF}
+
+implementation
+
+function zError(err : int) : string;
+begin
+  zError := z_errmsg[Z_NEED_DICT-err];
+end;
+
+function zlibVersion : string;
+begin
+  zlibVersion := ZLIB_VERSION;
+end;
+
+procedure z_error (m : string);
+begin
+  WriteLn(output, m);
+  Write('Zlib - Halt...');
+  ReadLn;
+  Halt(1);
+end;
+
+procedure Assert(cond : boolean; msg : string);
+begin
+  if not cond then
+    z_error(msg);
+end;
+
+procedure Trace(x : string);
+begin
+  WriteLn(x);
+end;
+
+procedure Tracev(x : string);
+begin
+ if (z_verbose>0) then
+   WriteLn(x);
+end;
+
+procedure Tracevv(x : string);
+begin
+  if (z_verbose>1) then
+    WriteLn(x);
+end;
+
+procedure Tracevvv(x : string);
+begin
+  if (z_verbose>2) then
+    WriteLn(x);
+end;
+
+procedure Tracec(c : boolean; x : string);
+begin
+  if (z_verbose>0) and (c) then
+    WriteLn(x);
+end;
+
+procedure Tracecv(c : boolean; x : string);
+begin
+  if (z_verbose>1) and c then
+    WriteLn(x);
+end;
+
+function ZALLOC (var strm : z_stream; items : uInt; size : uInt) : voidpf;
+begin
+  ZALLOC := strm.zalloc(strm.opaque, items, size);
+end;
+
+procedure ZFREE (var strm : z_stream; ptr : voidpf);
+begin
+  strm.zfree(strm.opaque, ptr);
+end;
+
+procedure TRY_FREE (var strm : z_stream; ptr : voidpf);
+begin
+  {if @strm <> Z_NULL then}
+    strm.zfree(strm.opaque, ptr);
+end;
+
+end.

+ 122 - 0
packages/base/paszlib/zcompres.pas

@@ -0,0 +1,122 @@
+Unit zCompres;
+
+{ compress.c -- compress a memory buffer
+  Copyright (C) 1995-1998 Jean-loup Gailly.
+
+  Pascal tranlastion
+  Copyright (C) 1998 by Jacques Nomssi Nzali
+  For conditions of distribution and use, see copyright notice in readme.txt
+}
+
+interface
+
+{$I zconf.inc}
+
+uses
+  zutil, zbase, zDeflate;
+
+                        { utility functions }
+
+{EXPORT}
+function compress (dest : pBytef;
+                   var destLen : uLong;
+                   source : pBytef;
+                   sourceLen : uLong) : int;
+
+ { Compresses the source buffer into the destination buffer.  sourceLen is
+   the byte length of the source buffer. Upon entry, destLen is the total
+   size of the destination buffer, which must be at least 0.1% larger than
+   sourceLen plus 12 bytes. Upon exit, destLen is the actual size of the
+   compressed buffer.
+     This function can be used to compress a whole file at once if the
+   input file is mmap'ed.
+     compress returns Z_OK if success, Z_MEM_ERROR if there was not
+   enough memory, Z_BUF_ERROR if there was not enough room in the output
+   buffer. }
+
+{EXPORT}
+function compress2 (dest : pBytef;
+                    var destLen : uLong;
+                    source : pBytef;
+                    sourceLen : uLong;
+                    level : int) : int;
+{  Compresses the source buffer into the destination buffer. The level
+   parameter has the same meaning as in deflateInit.  sourceLen is the byte
+   length of the source buffer. Upon entry, destLen is the total size of the
+   destination buffer, which must be at least 0.1% larger than sourceLen plus
+   12 bytes. Upon exit, destLen is the actual size of the compressed buffer.
+
+   compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
+   memory, Z_BUF_ERROR if there was not enough room in the output buffer,
+   Z_STREAM_ERROR if the level parameter is invalid. }
+
+implementation
+
+{ ===========================================================================
+}
+function compress2 (dest : pBytef;
+                    var destLen : uLong;
+                    source : pbytef;
+                    sourceLen : uLong;
+                    level : int) : int;
+var
+  stream : z_stream;
+  err : int;
+begin
+  stream.next_in := source;
+  stream.avail_in := uInt(sourceLen);
+{$ifdef MAXSEG_64K}
+  { Check for source > 64K on 16-bit machine: }
+  if (uLong(stream.avail_in) <> sourceLen) then
+  begin
+    compress2 := Z_BUF_ERROR;
+    exit;
+  end;
+{$endif}
+  stream.next_out := dest;
+  stream.avail_out := uInt(destLen);
+  if (uLong(stream.avail_out) <> destLen) then
+  begin
+    compress2 := Z_BUF_ERROR;
+    exit;
+  end;
+
+  stream.zalloc := NIL;       { alloc_func(0); }
+  stream.zfree := NIL;        { free_func(0); }
+  stream.opaque := NIL;       { voidpf(0); }
+
+  err := deflateInit(stream, level);
+  if (err <> Z_OK) then
+  begin
+    compress2 := err;
+    exit;
+  end;
+
+  err := deflate(stream, Z_FINISH);
+  if (err <> Z_STREAM_END) then
+  begin
+    deflateEnd(stream);
+    if err = Z_OK then
+      compress2 := Z_BUF_ERROR
+    else
+      compress2 := err;
+    exit;
+  end;
+  destLen := stream.total_out;
+
+  err := deflateEnd(stream);
+  compress2 := err;
+end;
+
+{ ===========================================================================
+ }
+function compress (dest : pBytef;
+                   var destLen : uLong;
+                   source : pBytef;
+                   sourceLen : uLong) : int;
+begin
+  compress := compress2(dest, destLen, source, sourceLen, Z_DEFAULT_COMPRESSION);
+end;
+
+
+end.

+ 33 - 0
packages/base/paszlib/zconf.inc

@@ -0,0 +1,33 @@
+{ -------------------------------------------------------------------- }
+
+{$DEFINE MAX_MATCH_IS_258}
+
+{ Compile with -DMAXSEG_64K if the alloc function cannot allocate more
+  than 64k bytes at a time (needed on systems with 16-bit int). }
+
+{- $DEFINE MAXSEG_64K}
+{$IFNDEF WIN32}
+  {$DEFINE UNALIGNED_OK}  { requires SizeOf(ush) = 2 ! }
+{$ENDIF}
+
+{$UNDEF DYNAMIC_CRC_TABLE}
+{$UNDEF FASTEST}
+{$define patch112}        { apply patch from the zlib home page }
+{ -------------------------------------------------------------------- }
+{$IFDEF FPC}
+ {$DEFINE Use32}
+ {$UNDEF DPMI}
+ {$UNDEF MSDOS}
+ {$UNDEF UNALIGNED_OK}  { requires SizeOf(ush) = 2 ! }
+ {$UNDEF MAXSEG_64K}
+{$ENDIF}
+
+{
+  $Log$
+  Revision 1.1  2002-01-29 17:54:56  peter
+    * splitted to base and extra
+
+  Revision 1.2  2000/07/13 11:33:30  michael
+  + removed logs
+ 
+}

+ 2144 - 0
packages/base/paszlib/zdeflate.pas

@@ -0,0 +1,2144 @@
+Unit zDeflate;
+
+{$ifdef fpc}
+{$goto on}
+{$endif}
+
+{ Orginal: deflate.h -- internal compression state
+           deflate.c -- compress data using the deflation algorithm
+  Copyright (C) 1995-1996 Jean-loup Gailly.
+
+  Pascal tranlastion
+  Copyright (C) 1998 by Jacques Nomssi Nzali
+  For conditions of distribution and use, see copyright notice in readme.txt
+}
+
+
+{  ALGORITHM
+
+       The "deflation" process depends on being able to identify portions
+       of the input text which are identical to earlier input (within a
+       sliding window trailing behind the input currently being processed).
+
+       The most straightforward technique turns out to be the fastest for
+       most input files: try all possible matches and select the longest.
+       The key feature of this algorithm is that insertions into the string
+       dictionary are very simple and thus fast, and deletions are avoided
+       completely. Insertions are performed at each input character, whereas
+       string matches are performed only when the previous match ends. So it
+       is preferable to spend more time in matches to allow very fast string
+       insertions and avoid deletions. The matching algorithm for small
+       strings is inspired from that of Rabin & Karp. A brute force approach
+       is used to find longer strings when a small match has been found.
+       A similar algorithm is used in comic (by Jan-Mark Wams) and freeze
+       (by Leonid Broukhis).
+          A previous version of this file used a more sophisticated algorithm
+       (by Fiala and Greene) which is guaranteed to run in linear amortized
+       time, but has a larger average cost, uses more memory and is patented.
+       However the F&G algorithm may be faster for some highly redundant
+       files if the parameter max_chain_length (described below) is too large.
+
+   ACKNOWLEDGEMENTS
+
+       The idea of lazy evaluation of matches is due to Jan-Mark Wams, and
+       I found it in 'freeze' written by Leonid Broukhis.
+       Thanks to many people for bug reports and testing.
+
+   REFERENCES
+
+       Deutsch, L.P.,"'Deflate' Compressed Data Format Specification".
+       Available in ftp.uu.net:/pub/archiving/zip/doc/deflate-1.1.doc
+
+       A description of the Rabin and Karp algorithm is given in the book
+          "Algorithms" by R. Sedgewick, Addison-Wesley, p252.
+
+       Fiala,E.R., and Greene,D.H.
+          Data Compression with Finite Windows, Comm.ACM, 32,4 (1989) 490-595}
+
+{ $Id$ }
+
+interface
+
+{$I zconf.inc}
+
+uses
+  zutil, zbase;
+
+
+function deflateInit_(strm : z_streamp;
+                      level : int;
+                      const version : string;
+                      stream_size : int) : int;
+
+
+function deflateInit (var strm : z_stream; level : int) : int;
+
+{  Initializes the internal stream state for compression. The fields
+   zalloc, zfree and opaque must be initialized before by the caller.
+   If zalloc and zfree are set to Z_NULL, deflateInit updates them to
+   use default allocation functions.
+
+     The compression level must be Z_DEFAULT_COMPRESSION, or between 0 and 9:
+   1 gives best speed, 9 gives best compression, 0 gives no compression at
+   all (the input data is simply copied a block at a time).
+   Z_DEFAULT_COMPRESSION requests a default compromise between speed and
+   compression (currently equivalent to level 6).
+
+     deflateInit returns Z_OK if success, Z_MEM_ERROR if there was not
+   enough memory, Z_STREAM_ERROR if level is not a valid compression level,
+   Z_VERSION_ERROR if the zlib library version (zlib_version) is incompatible
+   with the version assumed by the caller (ZLIB_VERSION).
+   msg is set to null if there is no error message.  deflateInit does not
+   perform any compression: this will be done by deflate(). }
+
+
+{EXPORT}
+function deflate (var strm : z_stream; flush : int) : int;
+
+{ Performs one or both of the following actions:
+
+  - Compress more input starting at next_in and update next_in and avail_in
+    accordingly. If not all input can be processed (because there is not
+    enough room in the output buffer), next_in and avail_in are updated and
+    processing will resume at this point for the next call of deflate().
+
+  - Provide more output starting at next_out and update next_out and avail_out
+    accordingly. This action is forced if the parameter flush is non zero.
+    Forcing flush frequently degrades the compression ratio, so this parameter
+    should be set only when necessary (in interactive applications).
+    Some output may be provided even if flush is not set.
+
+  Before the call of deflate(), the application should ensure that at least
+  one of the actions is possible, by providing more input and/or consuming
+  more output, and updating avail_in or avail_out accordingly; avail_out
+  should never be zero before the call. The application can consume the
+  compressed output when it wants, for example when the output buffer is full
+  (avail_out == 0), or after each call of deflate(). If deflate returns Z_OK
+  and with zero avail_out, it must be called again after making room in the
+  output buffer because there might be more output pending.
+
+    If the parameter flush is set to Z_PARTIAL_FLUSH, the current compression
+  block is terminated and flushed to the output buffer so that the
+  decompressor can get all input data available so far. For method 9, a future
+  variant on method 8, the current block will be flushed but not terminated.
+  Z_SYNC_FLUSH has the same effect as partial flush except that the compressed
+  output is byte aligned (the compressor can clear its internal bit buffer)
+  and the current block is always terminated; this can be useful if the
+  compressor has to be restarted from scratch after an interruption (in which
+  case the internal state of the compressor may be lost).
+    If flush is set to Z_FULL_FLUSH, the compression block is terminated, a
+  special marker is output and the compression dictionary is discarded; this
+  is useful to allow the decompressor to synchronize if one compressed block
+  has been damaged (see inflateSync below).  Flushing degrades compression and
+  so should be used only when necessary.  Using Z_FULL_FLUSH too often can
+  seriously degrade the compression. If deflate returns with avail_out == 0,
+  this function must be called again with the same value of the flush
+  parameter and more output space (updated avail_out), until the flush is
+  complete (deflate returns with non-zero avail_out).
+
+    If the parameter flush is set to Z_FINISH, all pending input is processed,
+  all pending output is flushed and deflate returns with Z_STREAM_END if there
+  was enough output space; if deflate returns with Z_OK, this function must be
+  called again with Z_FINISH and more output space (updated avail_out) but no
+  more input data, until it returns with Z_STREAM_END or an error. After
+  deflate has returned Z_STREAM_END, the only possible operations on the
+  stream are deflateReset or deflateEnd.
+
+    Z_FINISH can be used immediately after deflateInit if all the compression
+  is to be done in a single step. In this case, avail_out must be at least
+  0.1% larger than avail_in plus 12 bytes.  If deflate does not return
+  Z_STREAM_END, then it must be called again as described above.
+
+    deflate() may update data_type if it can make a good guess about
+  the input data type (Z_ASCII or Z_BINARY). In doubt, the data is considered
+  binary. This field is only for information purposes and does not affect
+  the compression algorithm in any manner.
+
+    deflate() returns Z_OK if some progress has been made (more input
+  processed or more output produced), Z_STREAM_END if all input has been
+  consumed and all output has been produced (only when flush is set to
+  Z_FINISH), Z_STREAM_ERROR if the stream state was inconsistent (for example
+  if next_in or next_out was NULL), Z_BUF_ERROR if no progress is possible. }
+
+
+function deflateEnd (var strm : z_stream) : int;
+
+{     All dynamically allocated data structures for this stream are freed.
+   This function discards any unprocessed input and does not flush any
+   pending output.
+
+     deflateEnd returns Z_OK if success, Z_STREAM_ERROR if the
+   stream state was inconsistent, Z_DATA_ERROR if the stream was freed
+   prematurely (some input or output was discarded). In the error case,
+   msg may be set but then points to a static string (which must not be
+   deallocated). }
+
+
+
+
+                        { Advanced functions }
+
+{ The following functions are needed only in some special applications. }
+
+function deflateInit2_(var strm : z_stream;
+                       level : int;
+                       method : int;
+                       windowBits : int;
+                       memLevel : int;
+                       strategy : int;
+                       const version : string;
+                       stream_size : int) : int;
+
+{EXPORT}
+function deflateInit2 (var strm : z_stream;
+                       level : int;
+                       method : int;
+                       windowBits : int;
+                       memLevel : int;
+                       strategy : int) : int;
+
+{  This is another version of deflateInit with more compression options. The
+   fields next_in, zalloc, zfree and opaque must be initialized before by
+   the caller.
+
+     The method parameter is the compression method. It must be Z_DEFLATED in
+   this version of the library. (Method 9 will allow a 64K history buffer and
+   partial block flushes.)
+
+     The windowBits parameter is the base two logarithm of the window size
+   (the size of the history buffer).  It should be in the range 8..15 for this
+   version of the library (the value 16 will be allowed for method 9). Larger
+   values of this parameter result in better compression at the expense of
+   memory usage. The default value is 15 if deflateInit is used instead.
+
+     The memLevel parameter specifies how much memory should be allocated
+   for the internal compression state. memLevel=1 uses minimum memory but
+   is slow and reduces compression ratio; memLevel=9 uses maximum memory
+   for optimal speed. The default value is 8. See zconf.h for total memory
+   usage as a function of windowBits and memLevel.
+
+     The strategy parameter is used to tune the compression algorithm. Use the
+   value Z_DEFAULT_STRATEGY for normal data, Z_FILTERED for data produced by a
+   filter (or predictor), or Z_HUFFMAN_ONLY to force Huffman encoding only (no
+   string match).  Filtered data consists mostly of small values with a
+   somewhat random distribution. In this case, the compression algorithm is
+   tuned to compress them better. The effect of Z_FILTERED is to force more
+   Huffman coding and less string matching; it is somewhat intermediate
+   between Z_DEFAULT and Z_HUFFMAN_ONLY. The strategy parameter only affects
+   the compression ratio but not the correctness of the compressed output even
+   if it is not set appropriately.
+
+     If next_in is not null, the library will use this buffer to hold also
+   some history information; the buffer must either hold the entire input
+   data, or have at least 1<<(windowBits+1) bytes and be writable. If next_in
+   is null, the library will allocate its own history buffer (and leave next_in
+   null). next_out need not be provided here but must be provided by the
+   application for the next call of deflate().
+
+     If the history buffer is provided by the application, next_in must
+   must never be changed by the application since the compressor maintains
+   information inside this buffer from call to call; the application
+   must provide more input only by increasing avail_in. next_in is always
+   reset by the library in this case.
+
+      deflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was
+   not enough memory, Z_STREAM_ERROR if a parameter is invalid (such as
+   an invalid method). msg is set to null if there is no error message.
+   deflateInit2 does not perform any compression: this will be done by
+   deflate(). }
+
+
+{EXPORT}
+function deflateSetDictionary (var strm : z_stream;
+                               dictionary : pBytef; {const bytes}
+                               dictLength : uint) : int;
+
+{    Initializes the compression dictionary (history buffer) from the given
+   byte sequence without producing any compressed output. This function must
+   be called immediately after deflateInit or deflateInit2, before any call
+   of deflate. The compressor and decompressor must use exactly the same
+   dictionary (see inflateSetDictionary).
+     The dictionary should consist of strings (byte sequences) that are likely
+   to be encountered later in the data to be compressed, with the most commonly
+   used strings preferably put towards the end of the dictionary. Using a
+   dictionary is most useful when the data to be compressed is short and
+   can be predicted with good accuracy; the data can then be compressed better
+   than with the default empty dictionary. In this version of the library,
+   only the last 32K bytes of the dictionary are used.
+     Upon return of this function, strm->adler is set to the Adler32 value
+   of the dictionary; the decompressor may later use this value to determine
+   which dictionary has been used by the compressor. (The Adler32 value
+   applies to the whole dictionary even if only a subset of the dictionary is
+   actually used by the compressor.)
+
+     deflateSetDictionary returns Z_OK if success, or Z_STREAM_ERROR if a
+   parameter is invalid (such as NULL dictionary) or the stream state
+   is inconsistent (for example if deflate has already been called for this
+   stream). deflateSetDictionary does not perform any compression: this will
+   be done by deflate(). }
+
+{EXPORT}
+function deflateCopy (dest : z_streamp;
+                      source : z_streamp) : int;
+
+{  Sets the destination stream as a complete copy of the source stream.  If
+   the source stream is using an application-supplied history buffer, a new
+   buffer is allocated for the destination stream.  The compressed output
+   buffer is always application-supplied. It's the responsibility of the
+   application to provide the correct values of next_out and avail_out for the
+   next call of deflate.
+
+     This function can be useful when several compression strategies will be
+   tried, for example when there are several ways of pre-processing the input
+   data with a filter. The streams that will be discarded should then be freed
+   by calling deflateEnd.  Note that deflateCopy duplicates the internal
+   compression state which can be quite large, so this strategy is slow and
+   can consume lots of memory.
+
+     deflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not
+   enough memory, Z_STREAM_ERROR if the source stream state was inconsistent
+   (such as zalloc being NULL). msg is left unchanged in both source and
+   destination. }
+
+{EXPORT}
+function deflateReset (var strm : z_stream) : int;
+
+{   This function is equivalent to deflateEnd followed by deflateInit,
+   but does not free and reallocate all the internal compression state.
+   The stream will keep the same compression level and any other attributes
+   that may have been set by deflateInit2.
+
+      deflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source
+   stream state was inconsistent (such as zalloc or state being NIL). }
+
+
+{EXPORT}
+function deflateParams (var strm : z_stream; level : int; strategy : int) : int;
+
+{    Dynamically update the compression level and compression strategy.
+   This can be used to switch between compression and straight copy of
+   the input data, or to switch to a different kind of input data requiring
+   a different strategy. If the compression level is changed, the input
+   available so far is compressed with the old level (and may be flushed);
+   the new level will take effect only at the next call of deflate().
+
+     Before the call of deflateParams, the stream state must be set as for
+   a call of deflate(), since the currently available input may have to
+   be compressed and flushed. In particular, strm->avail_out must be non-zero.
+
+     deflateParams returns Z_OK if success, Z_STREAM_ERROR if the source
+   stream state was inconsistent or if a parameter was invalid, Z_BUF_ERROR
+   if strm->avail_out was zero. }
+
+
+const
+   deflate_copyright : string = ' deflate 1.1.2 Copyright 1995-1998 Jean-loup Gailly ';
+
+{ If you use the zlib library in a product, an acknowledgment is welcome
+  in the documentation of your product. If for some reason you cannot
+  include such an acknowledgment, I would appreciate that you keep this
+  copyright string in the executable of your product. }
+
+implementation
+
+uses
+  trees, adler;
+
+{  ===========================================================================
+   Function prototypes. }
+
+type
+   block_state = (
+    need_more,      { block not completed, need more input or more output }
+    block_done,     { block flush performed }
+    finish_started, { finish started, need only more output at next deflate }
+    finish_done);   { finish done, accept no more input or output }
+
+{ Compression function. Returns the block state after the call. }
+type
+  compress_func = function(var s : deflate_state; flush : int) : block_state;
+
+{local}
+procedure fill_window(var s : deflate_state); forward;
+{local}
+function deflate_stored(var s : deflate_state; flush : int) : block_state;{$ifndef fpc}far;{$endif} forward;
+{local}
+function deflate_fast(var s : deflate_state; flush : int) : block_state;{$ifndef fpc}far;{$endif} forward;
+{local}
+function deflate_slow(var s : deflate_state; flush : int) : block_state;{$ifndef fpc}far;{$endif} forward;
+{local}
+procedure lm_init(var s : deflate_state); forward;
+
+{local}
+procedure putShortMSB(var s : deflate_state; b : uInt); forward;
+{local}
+procedure  flush_pending (var strm : z_stream); forward;
+{local}
+function read_buf(strm : z_streamp;
+                  buf : pBytef;
+                  size : unsigned) : int; forward;
+{$ifdef ASMV}
+procedure match_init; { asm code initialization }
+function longest_match(var deflate_state; cur_match : IPos) : uInt; forward;
+{$else}
+{local}
+function longest_match(var s : deflate_state; cur_match : IPos) : uInt;
+  forward;
+{$endif}
+
+{$ifdef DEBUG}
+{local}
+procedure check_match(var s : deflate_state;
+                      start, match : IPos;
+                      length : int); forward;
+{$endif}
+
+{  ==========================================================================
+  local data }
+
+const
+  ZNIL = 0;
+{ Tail of hash chains }
+
+const
+  TOO_FAR = 4096;
+{ Matches of length 3 are discarded if their distance exceeds TOO_FAR }
+
+const
+  MIN_LOOKAHEAD = (MAX_MATCH+MIN_MATCH+1);
+{ Minimum amount of lookahead, except at the end of the input file.
+  See deflate.c for comments about the MIN_MATCH+1. }
+
+{macro MAX_DIST(var s : deflate_state) : uInt;
+begin
+  MAX_DIST := (s.w_size - MIN_LOOKAHEAD);
+end;
+  In order to simplify the code, particularly on 16 bit machines, match
+  distances are limited to MAX_DIST instead of WSIZE. }
+
+
+{ Values for max_lazy_match, good_match and max_chain_length, depending on
+  the desired pack level (0..9). The values given below have been tuned to
+  exclude worst case performance for pathological files. Better values may be
+  found for specific files. }
+
+type
+  config = record
+   good_length : ush; { reduce lazy search above this match length }
+   max_lazy : ush;    { do not perform lazy search above this match length }
+   nice_length : ush; { quit search above this match length }
+   max_chain : ush;
+   func : compress_func;
+  end;
+
+{local}
+const
+  configuration_table : array[0..10-1] of config = (
+{      good lazy nice chain }
+{0} (good_length:0;  max_lazy:0;   nice_length:0;   max_chain:0;    func:@deflate_stored),  { store only }
+{1} (good_length:4;  max_lazy:4;   nice_length:8;   max_chain:4;    func:@deflate_fast), { maximum speed, no lazy matches }
+{2} (good_length:4;  max_lazy:5;   nice_length:16;  max_chain:8;    func:@deflate_fast),
+{3} (good_length:4;  max_lazy:6;   nice_length:32;  max_chain:32;   func:@deflate_fast),
+
+{4} (good_length:4;  max_lazy:4;   nice_length:16;  max_chain:16;   func:@deflate_slow),  { lazy matches }
+{5} (good_length:8;  max_lazy:16;  nice_length:32;  max_chain:32;   func:@deflate_slow),
+{6} (good_length:8;  max_lazy:16;  nice_length:128; max_chain:128;  func:@deflate_slow),
+{7} (good_length:8;  max_lazy:32;  nice_length:128; max_chain:256;  func:@deflate_slow),
+{8} (good_length:32; max_lazy:128; nice_length:258; max_chain:1024; func:@deflate_slow),
+{9} (good_length:32; max_lazy:258; nice_length:258; max_chain:4096; func:@deflate_slow)); { maximum compression }
+
+{ Note: the deflate() code requires max_lazy >= MIN_MATCH and max_chain >= 4
+  For deflate_fast() (levels <= 3) good is ignored and lazy has a different
+  meaning. }
+
+const
+  EQUAL = 0;
+{ result of memcmp for equal strings }
+
+{ ==========================================================================
+  Update a hash value with the given input byte
+  IN  assertion: all calls to to UPDATE_HASH are made with consecutive
+     input characters, so that a running hash key can be computed from the
+     previous key instead of complete recalculation each time.
+
+macro UPDATE_HASH(s,h,c)
+   h := (( (h) shl s^.hash_shift) xor (c)) and s^.hash_mask;
+}
+
+{ ===========================================================================
+  Insert string str in the dictionary and set match_head to the previous head
+  of the hash chain (the most recent string with same hash key). Return
+  the previous length of the hash chain.
+  If this file is compiled with -DFASTEST, the compression level is forced
+  to 1, and no hash chains are maintained.
+  IN  assertion: all calls to to INSERT_STRING are made with consecutive
+     input characters and the first MIN_MATCH bytes of str are valid
+     (except for the last MIN_MATCH-1 bytes of the input file). }
+
+procedure INSERT_STRING(var s : deflate_state;
+                        str : uInt;
+                        var match_head : IPos);
+begin
+{$ifdef FASTEST}
+   {UPDATE_HASH(s, s.ins_h, s.window[(str) + (MIN_MATCH-1)])}
+    s.ins_h := ((s.ins_h shl s.hash_shift) xor
+                 (s.window^[(str) + (MIN_MATCH-1)])) and s.hash_mask;
+    match_head := s.head[s.ins_h]
+    s.head[s.ins_h] := Pos(str);
+{$else}
+   {UPDATE_HASH(s, s.ins_h, s.window[(str) + (MIN_MATCH-1)])}
+    s.ins_h := ((s.ins_h shl s.hash_shift) xor
+                 (s.window^[(str) + (MIN_MATCH-1)])) and s.hash_mask;
+
+    match_head := s.head^[s.ins_h];
+    s.prev^[(str) and s.w_mask] := match_head;
+    s.head^[s.ins_h] := Pos(str);
+{$endif}
+end;
+
+{  =========================================================================
+  Initialize the hash table (avoiding 64K overflow for 16 bit systems).
+  prev[] will be initialized on the fly.
+
+macro CLEAR_HASH(s)
+    s^.head[s^.hash_size-1] := ZNIL;
+    zmemzero(pBytef(s^.head), unsigned(s^.hash_size-1)*sizeof(s^.head^[0]));
+}
+
+{  ======================================================================== }
+
+function deflateInit2_(var strm : z_stream;
+                       level : int;
+                       method : int;
+                       windowBits : int;
+                       memLevel : int;
+                       strategy : int;
+                       const version : string;
+                       stream_size : int) : int;
+var
+  s : deflate_state_ptr;
+  noheader : int;
+
+  overlay : pushfArray;
+  { We overlay pending_buf and d_buf+l_buf. This works since the average
+    output size for (length,distance) codes is <= 24 bits. }
+begin
+  noheader := 0;
+  if (version  =  '') or (version[1] <> ZLIB_VERSION[1]) or
+     (stream_size <> sizeof(z_stream)) then
+  begin
+    deflateInit2_ := Z_VERSION_ERROR;
+    exit;
+  end;
+  {
+  if (strm = Z_NULL) then
+  begin
+    deflateInit2_ := Z_STREAM_ERROR;
+    exit;
+  end;
+  }
+  { SetLength(strm.msg, 255); }
+  strm.msg := '';
+  if not Assigned(strm.zalloc) then
+  begin
+{$ifdef fpc}
+    strm.zalloc := @zcalloc;
+{$else}
+    strm.zalloc := zcalloc;
+{$endif}
+    strm.opaque := voidpf(0);
+  end;
+  if not Assigned(strm.zfree) then
+{$ifdef fpc}
+    strm.zfree := @zcfree;
+{$else}
+    strm.zfree := zcfree;
+{$endif}
+  if (level  =  Z_DEFAULT_COMPRESSION) then
+    level := 6;
+{$ifdef FASTEST}
+    level := 1;
+{$endif}
+
+  if (windowBits < 0) then { undocumented feature: suppress zlib header }
+  begin
+    noheader := 1;
+    windowBits := -windowBits;
+  end;
+  if (memLevel < 1) or (memLevel > MAX_MEM_LEVEL) or (method <> Z_DEFLATED)
+    or (windowBits < 8) or (windowBits > 15) or (level < 0)
+    or (level > 9) or (strategy < 0) or (strategy > Z_HUFFMAN_ONLY) then
+  begin
+    deflateInit2_ := Z_STREAM_ERROR;
+    exit;
+  end;
+
+  s := deflate_state_ptr (ZALLOC(strm, 1, sizeof(deflate_state)));
+  if (s = Z_NULL) then
+  begin
+    deflateInit2_ := Z_MEM_ERROR;
+    exit;
+  end;
+  strm.state := pInternal_state(s);
+  s^.strm := @strm;
+
+  s^.noheader := noheader;
+  s^.w_bits := windowBits;
+  s^.w_size := 1 shl s^.w_bits;
+  s^.w_mask := s^.w_size - 1;
+
+  s^.hash_bits := memLevel + 7;
+  s^.hash_size := 1 shl s^.hash_bits;
+  s^.hash_mask := s^.hash_size - 1;
+  s^.hash_shift :=  ((s^.hash_bits+MIN_MATCH-1) div MIN_MATCH);
+
+  s^.window := pzByteArray (ZALLOC(strm, s^.w_size, 2*sizeof(Byte)));
+  s^.prev   := pzPosfArray (ZALLOC(strm, s^.w_size, sizeof(Pos)));
+  s^.head   := pzPosfArray (ZALLOC(strm, s^.hash_size, sizeof(Pos)));
+
+  s^.lit_bufsize := 1 shl (memLevel + 6); { 16K elements by default }
+
+  overlay := pushfArray (ZALLOC(strm, s^.lit_bufsize, sizeof(ush)+2));
+  s^.pending_buf := pzByteArray (overlay);
+  s^.pending_buf_size := ulg(s^.lit_bufsize) * (sizeof(ush)+Long(2));
+
+  if (s^.window = Z_NULL) or (s^.prev = Z_NULL) or (s^.head = Z_NULL)
+   or (s^.pending_buf = Z_NULL) then
+  begin
+    {ERR_MSG(Z_MEM_ERROR);}
+    strm.msg := z_errmsg[z_errbase-Z_MEM_ERROR];
+    deflateEnd (strm);
+    deflateInit2_ := Z_MEM_ERROR;
+    exit;
+  end;
+  s^.d_buf := pushfArray( @overlay^[s^.lit_bufsize div sizeof(ush)] );
+  s^.l_buf := puchfArray( @s^.pending_buf^[(1+sizeof(ush))*s^.lit_bufsize] );
+
+  s^.level := level;
+  s^.strategy := strategy;
+  s^.method := Byte(method);
+
+  deflateInit2_ := deflateReset(strm);
+end;
+
+{  ========================================================================= }
+
+function deflateInit2(var strm : z_stream;
+                      level : int;
+                      method : int;
+                      windowBits : int;
+                      memLevel : int;
+                      strategy : int) : int;
+{ a macro }
+begin
+  deflateInit2 := deflateInit2_(strm, level, method, windowBits,
+                   memLevel, strategy, ZLIB_VERSION, sizeof(z_stream));
+end;
+
+{  ========================================================================= }
+
+function deflateInit_(strm : z_streamp;
+                      level : int;
+                      const version : string;
+                      stream_size : int) : int;
+begin
+  if (strm = Z_NULL) then
+    deflateInit_ := Z_STREAM_ERROR
+  else
+    deflateInit_ := deflateInit2_(strm^, level, Z_DEFLATED, MAX_WBITS,
+                   DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY, version, stream_size);
+  { To do: ignore strm^.next_in if we use it as window }
+end;
+
+{  ========================================================================= }
+
+function deflateInit(var strm : z_stream; level : int) : int;
+{ deflateInit is a macro to allow checking the zlib version
+  and the compiler's view of z_stream: }
+begin
+  deflateInit := deflateInit2_(strm, level, Z_DEFLATED, MAX_WBITS,
+         DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY, ZLIB_VERSION, sizeof(z_stream));
+end;
+
+{  ======================================================================== }
+function deflateSetDictionary (var strm : z_stream;
+                               dictionary : pBytef;
+                               dictLength : uInt) : int;
+var
+  s : deflate_state_ptr;
+  length : uInt;
+  n : uInt;
+  hash_head : IPos;
+var
+  MAX_DIST : uInt;  {macro}
+begin
+  length := dictLength;
+  hash_head := 0;
+
+  if {(@strm  =  Z_NULL) or}
+     (strm.state  =  Z_NULL) or (dictionary  =  Z_NULL)
+    or (deflate_state_ptr(strm.state)^.status <> INIT_STATE) then
+  begin
+    deflateSetDictionary := Z_STREAM_ERROR;
+    exit;
+  end;
+
+  s := deflate_state_ptr(strm.state);
+  strm.adler := adler32(strm.adler, dictionary, dictLength);
+
+  if (length < MIN_MATCH) then
+  begin
+    deflateSetDictionary := Z_OK;
+    exit;
+  end;
+  MAX_DIST := (s^.w_size - MIN_LOOKAHEAD);
+  if (length > MAX_DIST) then
+  begin
+    length := MAX_DIST;
+{$ifndef USE_DICT_HEAD}
+    Inc(dictionary, dictLength - length);  { use the tail of the dictionary }
+{$endif}
+  end;
+
+  zmemcpy( pBytef(s^.window), dictionary, length);
+  s^.strstart := length;
+  s^.block_start := long(length);
+
+  { Insert all strings in the hash table (except for the last two bytes).
+    s^.lookahead stays null, so s^.ins_h will be recomputed at the next
+    call of fill_window. }
+
+  s^.ins_h := s^.window^[0];
+  {UPDATE_HASH(s, s^.ins_h, s^.window[1]);}
+  s^.ins_h := ((s^.ins_h shl s^.hash_shift) xor (s^.window^[1]))
+              and s^.hash_mask;
+
+  for n := 0 to length - MIN_MATCH do
+  begin
+    INSERT_STRING(s^, n, hash_head);
+  end;
+  {if (hash_head <> 0) then
+    hash_head := 0;  - to make compiler happy }
+  deflateSetDictionary := Z_OK;
+end;
+
+{  ======================================================================== }
+function deflateReset (var strm : z_stream) : int;
+var
+  s : deflate_state_ptr;
+begin
+  if {(@strm = Z_NULL) or}
+   (strm.state = Z_NULL)
+   or (not Assigned(strm.zalloc)) or (not Assigned(strm.zfree)) then
+  begin
+    deflateReset := Z_STREAM_ERROR;
+    exit;
+  end;
+
+  strm.total_out := 0;
+  strm.total_in := 0;
+  strm.msg := '';      { use zfree if we ever allocate msg dynamically }
+  strm.data_type := Z_UNKNOWN;
+
+  s := deflate_state_ptr(strm.state);
+  s^.pending := 0;
+  s^.pending_out := pBytef(s^.pending_buf);
+
+  if (s^.noheader < 0) then
+  begin
+    s^.noheader := 0; { was set to -1 by deflate(..., Z_FINISH); }
+  end;
+  if s^.noheader <> 0 then
+    s^.status := BUSY_STATE
+  else
+    s^.status := INIT_STATE;
+  strm.adler := 1;
+  s^.last_flush := Z_NO_FLUSH;
+
+  _tr_init(s^);
+  lm_init(s^);
+
+  deflateReset := Z_OK;
+end;
+
+{  ======================================================================== }
+function deflateParams(var strm : z_stream;
+                       level : int;
+                       strategy : int) : int;
+var
+  s : deflate_state_ptr;
+  func : compress_func;
+  err : int;
+begin
+  err := Z_OK;
+  if {(@strm  =  Z_NULL) or} (strm.state  =  Z_NULL) then
+  begin
+    deflateParams := Z_STREAM_ERROR;
+    exit;
+  end;
+
+  s := deflate_state_ptr(strm.state);
+
+  if (level = Z_DEFAULT_COMPRESSION) then
+  begin
+    level := 6;
+  end;
+  if (level < 0) or (level > 9) or (strategy < 0)
+  or (strategy > Z_HUFFMAN_ONLY) then
+  begin
+    deflateParams := Z_STREAM_ERROR;
+    exit;
+  end;
+  func := configuration_table[s^.level].func;
+
+  if (@func <> @configuration_table[level].func)
+    and (strm.total_in <> 0) then
+  begin
+      { Flush the last buffer: }
+      err := deflate(strm, Z_PARTIAL_FLUSH);
+  end;
+  if (s^.level <> level) then
+  begin
+    s^.level := level;
+    s^.max_lazy_match   := configuration_table[level].max_lazy;
+    s^.good_match       := configuration_table[level].good_length;
+    s^.nice_match       := configuration_table[level].nice_length;
+    s^.max_chain_length := configuration_table[level].max_chain;
+  end;
+  s^.strategy := strategy;
+  deflateParams := err;
+end;
+
+{ =========================================================================
+  Put a short in the pending buffer. The 16-bit value is put in MSB order.
+  IN assertion: the stream state is correct and there is enough room in
+  pending_buf. }
+
+{local}
+procedure putShortMSB (var s : deflate_state; b : uInt);
+begin
+  s.pending_buf^[s.pending] := Byte(b shr 8);
+  Inc(s.pending);
+  s.pending_buf^[s.pending] := Byte(b and $ff);
+  Inc(s.pending);
+end;
+
+{ =========================================================================
+  Flush as much pending output as possible. All deflate() output goes
+  through this function so some applications may wish to modify it
+  to avoid allocating a large strm^.next_out buffer and copying into it.
+  (See also read_buf()). }
+
+{local}
+procedure flush_pending(var strm : z_stream);
+var
+  len : unsigned;
+  s : deflate_state_ptr;
+begin
+  s := deflate_state_ptr(strm.state);
+  len := s^.pending;
+
+  if (len > strm.avail_out) then
+    len := strm.avail_out;
+  if (len = 0) then
+    exit;
+
+  zmemcpy(strm.next_out, s^.pending_out, len);
+  Inc(strm.next_out, len);
+  Inc(s^.pending_out, len);
+  Inc(strm.total_out, len);
+  Dec(strm.avail_out, len);
+  Dec(s^.pending, len);
+  if (s^.pending = 0) then
+  begin
+    s^.pending_out := pBytef(s^.pending_buf);
+  end;
+end;
+
+{ ========================================================================= }
+function deflate (var strm : z_stream; flush : int) : int;
+var
+  old_flush : int; { value of flush param for previous deflate call }
+  s : deflate_state_ptr;
+var
+  header : uInt;
+  level_flags : uInt;
+var
+  bstate : block_state;
+begin
+  if {(@strm = Z_NULL) or} (strm.state = Z_NULL)
+    or (flush > Z_FINISH) or (flush < 0) then
+  begin
+    deflate := Z_STREAM_ERROR;
+    exit;
+  end;
+  s := deflate_state_ptr(strm.state);
+
+  if (strm.next_out = Z_NULL) or
+     ((strm.next_in = Z_NULL) and (strm.avail_in <> 0)) or
+     ((s^.status = FINISH_STATE) and (flush <> Z_FINISH)) then
+  begin
+    {ERR_RETURN(strm^, Z_STREAM_ERROR);}
+    strm.msg := z_errmsg[z_errbase - Z_STREAM_ERROR];
+    deflate := Z_STREAM_ERROR;
+    exit;
+  end;
+  if (strm.avail_out = 0) then
+  begin
+    {ERR_RETURN(strm^, Z_BUF_ERROR);}
+    strm.msg := z_errmsg[z_errbase - Z_BUF_ERROR];
+    deflate := Z_BUF_ERROR;
+    exit;
+  end;
+
+  s^.strm := @strm; { just in case }
+  old_flush := s^.last_flush;
+  s^.last_flush := flush;
+
+  { Write the zlib header }
+  if (s^.status = INIT_STATE) then
+  begin
+
+    header := (Z_DEFLATED + ((s^.w_bits-8) shl 4)) shl 8;
+    level_flags := (s^.level-1) shr 1;
+
+    if (level_flags > 3) then
+      level_flags := 3;
+    header := header or (level_flags shl 6);
+    if (s^.strstart <> 0) then
+      header := header or PRESET_DICT;
+    Inc(header, 31 - (header mod 31));
+
+    s^.status := BUSY_STATE;
+    putShortMSB(s^, header);
+
+    { Save the adler32 of the preset dictionary: }
+    if (s^.strstart <> 0) then
+    begin
+      putShortMSB(s^, uInt(strm.adler shr 16));
+      putShortMSB(s^, uInt(strm.adler and $ffff));
+    end;
+    strm.adler := long(1);
+  end;
+
+  { Flush as much pending output as possible }
+  if (s^.pending <> 0) then
+  begin
+    flush_pending(strm);
+    if (strm.avail_out = 0) then
+    begin
+      { Since avail_out is 0, deflate will be called again with
+        more output space, but possibly with both pending and
+        avail_in equal to zero. There won't be anything to do,
+        but this is not an error situation so make sure we
+        return OK instead of BUF_ERROR at next call of deflate: }
+
+      s^.last_flush := -1;
+      deflate := Z_OK;
+      exit;
+    end;
+
+  { Make sure there is something to do and avoid duplicate consecutive
+    flushes. For repeated and useless calls with Z_FINISH, we keep
+    returning Z_STREAM_END instead of Z_BUFF_ERROR. }
+
+  end
+  else
+    if (strm.avail_in = 0) and (flush <= old_flush)
+      and (flush <> Z_FINISH) then
+    begin
+      {ERR_RETURN(strm^, Z_BUF_ERROR);}
+      strm.msg := z_errmsg[z_errbase - Z_BUF_ERROR];
+      deflate := Z_BUF_ERROR;
+      exit;
+    end;
+
+  { User must not provide more input after the first FINISH: }
+  if (s^.status = FINISH_STATE) and (strm.avail_in <> 0) then
+  begin
+    {ERR_RETURN(strm^, Z_BUF_ERROR);}
+    strm.msg := z_errmsg[z_errbase - Z_BUF_ERROR];
+    deflate := Z_BUF_ERROR;
+    exit;
+  end;
+
+  { Start a new block or continue the current one. }
+  if (strm.avail_in <> 0) or (s^.lookahead <> 0)
+    or ((flush <> Z_NO_FLUSH) and (s^.status <> FINISH_STATE)) then
+  begin
+    bstate := configuration_table[s^.level].func(s^, flush);
+
+    if (bstate = finish_started) or (bstate = finish_done) then
+      s^.status := FINISH_STATE;
+
+    if (bstate = need_more) or (bstate = finish_started) then
+    begin
+      if (strm.avail_out = 0) then
+        s^.last_flush := -1; { avoid BUF_ERROR next call, see above }
+
+      deflate := Z_OK;
+      exit;
+      { If flush != Z_NO_FLUSH && avail_out == 0, the next call
+        of deflate should use the same flush parameter to make sure
+        that the flush is complete. So we don't have to output an
+        empty block here, this will be done at next call. This also
+        ensures that for a very small output buffer, we emit at most
+         one empty block. }
+    end;
+    if (bstate = block_done) then
+    begin
+      if (flush = Z_PARTIAL_FLUSH) then
+        _tr_align(s^)
+      else
+      begin  { FULL_FLUSH or SYNC_FLUSH }
+        _tr_stored_block(s^, pcharf(NIL), Long(0), FALSE);
+        { For a full flush, this empty block will be recognized
+          as a special marker by inflate_sync(). }
+
+        if (flush = Z_FULL_FLUSH) then
+        begin
+          {macro CLEAR_HASH(s);}             { forget history }
+          s^.head^[s^.hash_size-1] := ZNIL;
+          zmemzero(pBytef(s^.head), unsigned(s^.hash_size-1)*sizeof(s^.head^[0]));
+        end;
+      end;
+
+      flush_pending(strm);
+      if (strm.avail_out = 0) then
+      begin
+        s^.last_flush := -1; { avoid BUF_ERROR at next call, see above }
+        deflate := Z_OK;
+        exit;
+      end;
+
+    end;
+  end;
+  {$IFDEF DEBUG}
+  Assert(strm.avail_out > 0, 'bug2');
+  {$ENDIF}
+  if (flush <> Z_FINISH) then
+  begin
+    deflate := Z_OK;
+    exit;
+  end;
+
+  if (s^.noheader <> 0) then
+  begin
+    deflate := Z_STREAM_END;
+    exit;
+  end;
+
+  { Write the zlib trailer (adler32) }
+  putShortMSB(s^, uInt(strm.adler shr 16));
+  putShortMSB(s^, uInt(strm.adler and $ffff));
+  flush_pending(strm);
+  { If avail_out is zero, the application will call deflate again
+    to flush the rest. }
+
+  s^.noheader := -1; { write the trailer only once! }
+  if s^.pending <> 0 then
+    deflate := Z_OK
+  else
+    deflate := Z_STREAM_END;
+end;
+
+{ ========================================================================= }
+function deflateEnd (var strm : z_stream) : int;
+var
+  status : int;
+  s : deflate_state_ptr;
+begin
+  if {(@strm = Z_NULL) or} (strm.state = Z_NULL) then
+  begin
+    deflateEnd := Z_STREAM_ERROR;
+    exit;
+  end;
+
+  s := deflate_state_ptr(strm.state);
+  status := s^.status;
+  if (status <> INIT_STATE) and (status <> BUSY_STATE) and
+     (status <> FINISH_STATE) then
+  begin
+    deflateEnd := Z_STREAM_ERROR;
+    exit;
+  end;
+
+  { Deallocate in reverse order of allocations: }
+  TRY_FREE(strm, s^.pending_buf);
+  TRY_FREE(strm, s^.head);
+  TRY_FREE(strm, s^.prev);
+  TRY_FREE(strm, s^.window);
+
+  ZFREE(strm, s);
+  strm.state := Z_NULL;
+
+  if status = BUSY_STATE then
+    deflateEnd := Z_DATA_ERROR
+  else
+    deflateEnd := Z_OK;
+end;
+
+{ =========================================================================
+  Copy the source state to the destination state.
+  To simplify the source, this is not supported for 16-bit MSDOS (which
+  doesn't have enough memory anyway to duplicate compression states). }
+
+
+{ ========================================================================= }
+function deflateCopy (dest, source : z_streamp) : int;
+{$ifndef MAXSEG_64K}
+var
+  ds : deflate_state_ptr;
+  ss : deflate_state_ptr;
+  overlay : pushfArray;
+{$endif}
+begin
+{$ifdef MAXSEG_64K}
+  deflateCopy := Z_STREAM_ERROR;
+  exit;
+{$else}
+
+  if (source = Z_NULL) or (dest = Z_NULL) or (source^.state = Z_NULL) then
+  begin
+    deflateCopy := Z_STREAM_ERROR;
+    exit;
+  end;
+  ss := deflate_state_ptr(source^.state);
+  dest^ := source^;
+
+  ds := deflate_state_ptr( ZALLOC(dest^, 1, sizeof(deflate_state)) );
+  if (ds = Z_NULL) then
+  begin
+    deflateCopy := Z_MEM_ERROR;
+    exit;
+  end;
+  dest^.state := pInternal_state(ds);
+  ds^ := ss^;
+  ds^.strm := dest;
+
+  ds^.window := pzByteArray ( ZALLOC(dest^, ds^.w_size, 2*sizeof(Byte)) );
+  ds^.prev   := pzPosfArray ( ZALLOC(dest^, ds^.w_size, sizeof(Pos)) );
+  ds^.head   := pzPosfArray ( ZALLOC(dest^, ds^.hash_size, sizeof(Pos)) );
+  overlay := pushfArray ( ZALLOC(dest^, ds^.lit_bufsize, sizeof(ush)+2) );
+  ds^.pending_buf := pzByteArray ( overlay );
+
+  if (ds^.window = Z_NULL) or (ds^.prev = Z_NULL) or (ds^.head = Z_NULL)
+     or (ds^.pending_buf = Z_NULL) then
+  begin
+    deflateEnd (dest^);
+    deflateCopy := Z_MEM_ERROR;
+    exit;
+  end;
+  { following zmemcpy do not work for 16-bit MSDOS }
+  zmemcpy(pBytef(ds^.window), pBytef(ss^.window), ds^.w_size * 2 * sizeof(Byte));
+  zmemcpy(pBytef(ds^.prev), pBytef(ss^.prev), ds^.w_size * sizeof(Pos));
+  zmemcpy(pBytef(ds^.head), pBytef(ss^.head), ds^.hash_size * sizeof(Pos));
+  zmemcpy(pBytef(ds^.pending_buf), pBytef(ss^.pending_buf), uInt(ds^.pending_buf_size));
+
+  ds^.pending_out := @ds^.pending_buf^[ptr2int(ss^.pending_out) - ptr2int(ss^.pending_buf)];
+  ds^.d_buf := pushfArray (@overlay^[ds^.lit_bufsize div sizeof(ush)] );
+  ds^.l_buf := puchfArray (@ds^.pending_buf^[(1+sizeof(ush))*ds^.lit_bufsize]);
+
+  ds^.l_desc.dyn_tree := tree_ptr(@ds^.dyn_ltree);
+  ds^.d_desc.dyn_tree := tree_ptr(@ds^.dyn_dtree);
+  ds^.bl_desc.dyn_tree := tree_ptr(@ds^.bl_tree);
+
+  deflateCopy := Z_OK;
+{$endif}
+end;
+
+
+{ ===========================================================================
+  Read a new buffer from the current input stream, update the adler32
+  and total number of bytes read.  All deflate() input goes through
+  this function so some applications may wish to modify it to avoid
+  allocating a large strm^.next_in buffer and copying from it.
+  (See also flush_pending()). }
+
+{local}
+function read_buf(strm : z_streamp; buf : pBytef; size : unsigned) : int;
+var
+  len : unsigned;
+begin
+  len := strm^.avail_in;
+
+  if (len > size) then
+    len := size;
+  if (len = 0) then
+  begin
+    read_buf := 0;
+    exit;
+  end;
+
+  Dec(strm^.avail_in, len);
+
+  if deflate_state_ptr(strm^.state)^.noheader = 0 then
+  begin
+    strm^.adler := adler32(strm^.adler, strm^.next_in, len);
+  end;
+  zmemcpy(buf, strm^.next_in, len);
+  Inc(strm^.next_in, len);
+  Inc(strm^.total_in, len);
+
+  read_buf := int(len);
+end;
+
+{ ===========================================================================
+  Initialize the "longest match" routines for a new zlib stream }
+
+{local}
+procedure lm_init (var s : deflate_state);
+begin
+  s.window_size := ulg( uLong(2)*s.w_size);
+
+  {macro CLEAR_HASH(s);}
+  s.head^[s.hash_size-1] := ZNIL;
+  zmemzero(pBytef(s.head), unsigned(s.hash_size-1)*sizeof(s.head^[0]));
+
+  { Set the default configuration parameters: }
+
+  s.max_lazy_match   := configuration_table[s.level].max_lazy;
+  s.good_match       := configuration_table[s.level].good_length;
+  s.nice_match       := configuration_table[s.level].nice_length;
+  s.max_chain_length := configuration_table[s.level].max_chain;
+
+  s.strstart := 0;
+  s.block_start := long(0);
+  s.lookahead := 0;
+  s.prev_length := MIN_MATCH-1;
+  s.match_length := MIN_MATCH-1;
+  s.match_available := FALSE;
+  s.ins_h := 0;
+{$ifdef ASMV}
+  match_init; { initialize the asm code }
+{$endif}
+end;
+
+{ ===========================================================================
+  Set match_start to the longest match starting at the given string and
+  return its length. Matches shorter or equal to prev_length are discarded,
+  in which case the result is equal to prev_length and match_start is
+  garbage.
+  IN assertions: cur_match is the head of the hash chain for the current
+    string (strstart) and its distance is <= MAX_DIST, and prev_length >= 1
+  OUT assertion: the match length is not greater than s^.lookahead. }
+
+
+{$ifndef ASMV}
+{ For 80x86 and 680x0, an optimized version will be provided in match.asm or
+  match.S. The code will be functionally equivalent. }
+
+{$ifndef FASTEST}
+
+{local}
+function longest_match(var s : deflate_state;
+                       cur_match : IPos  { current match }
+                       ) : uInt;
+label
+  nextstep;
+var
+  chain_length : unsigned;    { max hash chain length }
+  {register} scan : pBytef;   { current string }
+  {register} match : pBytef;  { matched string }
+  {register} len : int;       { length of current match }
+  best_len : int;             { best match length so far }
+  nice_match : int;           { stop if match long enough }
+  limit : IPos;
+
+  prev : pzPosfArray;
+  wmask : uInt;
+{$ifdef UNALIGNED_OK}
+  {register} strend : pBytef;
+  {register} scan_start : ush;
+  {register} scan_end : ush;
+{$else}
+  {register} strend : pBytef;
+  {register} scan_end1 : Byte;
+  {register} scan_end : Byte;
+{$endif}
+var
+  MAX_DIST : uInt;
+begin
+  chain_length := s.max_chain_length; { max hash chain length }
+  scan := @(s.window^[s.strstart]);
+  best_len := s.prev_length;              { best match length so far }
+  nice_match := s.nice_match;             { stop if match long enough }
+
+
+  MAX_DIST := s.w_size - MIN_LOOKAHEAD;
+{In order to simplify the code, particularly on 16 bit machines, match
+distances are limited to MAX_DIST instead of WSIZE. }
+
+  if s.strstart > IPos(MAX_DIST) then
+    limit := s.strstart - IPos(MAX_DIST)
+  else
+    limit := ZNIL;
+  { Stop when cur_match becomes <= limit. To simplify the code,
+    we prevent matches with the string of window index 0. }
+
+  prev := s.prev;
+  wmask := s.w_mask;
+
+{$ifdef UNALIGNED_OK}
+  { Compare two bytes at a time. Note: this is not always beneficial.
+    Try with and without -DUNALIGNED_OK to check. }
+
+  strend := pBytef(@(s.window^[s.strstart + MAX_MATCH - 1]));
+  scan_start := pushf(scan)^;
+  scan_end   := pushfArray(scan)^[best_len-1];   { fix }
+{$else}
+  strend := pBytef(@(s.window^[s.strstart + MAX_MATCH]));
+  {$IFOPT R+} {$R-} {$DEFINE NoRangeCheck} {$ENDIF}
+  scan_end1  := pzByteArray(scan)^[best_len-1];
+  {$IFDEF NoRangeCheck} {$R+} {$UNDEF NoRangeCheck} {$ENDIF}
+  scan_end   := pzByteArray(scan)^[best_len];
+{$endif}
+
+    { The code is optimized for HASH_BITS >= 8 and MAX_MATCH-2 multiple of 16.
+      It is easy to get rid of this optimization if necessary. }
+    {$IFDEF DEBUG}
+    Assert((s.hash_bits >= 8) and (MAX_MATCH = 258), 'Code too clever');
+    {$ENDIF}
+    { Do not waste too much time if we already have a good match: }
+    if (s.prev_length >= s.good_match) then
+    begin
+      chain_length := chain_length shr 2;
+    end;
+
+    { Do not look for matches beyond the end of the input. This is necessary
+      to make deflate deterministic. }
+
+    if (uInt(nice_match) > s.lookahead) then
+      nice_match := s.lookahead;
+    {$IFDEF DEBUG}
+    Assert(ulg(s.strstart) <= s.window_size-MIN_LOOKAHEAD, 'need lookahead');
+    {$ENDIF}
+    repeat
+        {$IFDEF DEBUG}
+        Assert(cur_match < s.strstart, 'no future');
+        {$ENDIF}
+        match := @(s.window^[cur_match]);
+
+        { Skip to next match if the match length cannot increase
+          or if the match length is less than 2: }
+
+{$undef DO_UNALIGNED_OK}
+{$ifdef UNALIGNED_OK}
+  {$ifdef MAX_MATCH_IS_258}
+    {$define DO_UNALIGNED_OK}
+  {$endif}
+{$endif}
+
+{$ifdef DO_UNALIGNED_OK}
+        { This code assumes sizeof(unsigned short) = 2. Do not use
+          UNALIGNED_OK if your compiler uses a different size. }
+  {$IFOPT R+} {$R-} {$DEFINE NoRangeCheck} {$ENDIF}
+        if (pushfArray(match)^[best_len-1] <> scan_end) or
+           (pushf(match)^ <> scan_start) then
+          goto nextstep; {continue;}
+  {$IFDEF NoRangeCheck} {$R+} {$UNDEF NoRangeCheck} {$ENDIF}
+
+        { It is not necessary to compare scan[2] and match[2] since they are
+          always equal when the other bytes match, given that the hash keys
+          are equal and that HASH_BITS >= 8. Compare 2 bytes at a time at
+          strstart+3, +5, ... up to strstart+257. We check for insufficient
+          lookahead only every 4th comparison; the 128th check will be made
+          at strstart+257. If MAX_MATCH-2 is not a multiple of 8, it is
+          necessary to put more guard bytes at the end of the window, or
+          to check more often for insufficient lookahead. }
+        {$IFDEF DEBUG}
+        Assert(pzByteArray(scan)^[2] = pzByteArray(match)^[2], 'scan[2]?');
+        {$ENDIF}
+        Inc(scan);
+        Inc(match);
+
+        repeat
+          Inc(scan,2); Inc(match,2); if (pushf(scan)^<>pushf(match)^) then break;
+          Inc(scan,2); Inc(match,2); if (pushf(scan)^<>pushf(match)^) then break;
+          Inc(scan,2); Inc(match,2); if (pushf(scan)^<>pushf(match)^) then break;
+          Inc(scan,2); Inc(match,2); if (pushf(scan)^<>pushf(match)^) then break;
+        until (ptr2int(scan) >= ptr2int(strend));
+        { The funny "do while" generates better code on most compilers }
+
+        { Here, scan <= window+strstart+257 }
+        {$IFDEF DEBUG}
+        Assert(ptr2int(scan) <=
+               ptr2int(@(s.window^[unsigned(s.window_size-1)])),
+               'wild scan');
+        {$ENDIF}
+        if (scan^ = match^) then
+          Inc(scan);
+
+        len := (MAX_MATCH - 1) - int(ptr2int(strend)-ptr2int(scan));
+        scan := strend;
+        Dec(scan, (MAX_MATCH-1));
+
+{$else} { UNALIGNED_OK }
+
+  {$IFOPT R+} {$R-} {$DEFINE NoRangeCheck} {$ENDIF}
+        if (pzByteArray(match)^[best_len]   <> scan_end) or
+           (pzByteArray(match)^[best_len-1] <> scan_end1) or
+           (match^ <> scan^) then
+          goto nextstep; {continue;}
+  {$IFDEF NoRangeCheck} {$R+} {$UNDEF NoRangeCheck} {$ENDIF}
+        Inc(match);
+        if (match^ <> pzByteArray(scan)^[1]) then
+          goto nextstep; {continue;}
+
+        { The check at best_len-1 can be removed because it will be made
+          again later. (This heuristic is not always a win.)
+          It is not necessary to compare scan[2] and match[2] since they
+          are always equal when the other bytes match, given that
+          the hash keys are equal and that HASH_BITS >= 8. }
+
+        Inc(scan, 2);
+        Inc(match);
+        {$IFDEF DEBUG}
+        Assert( scan^ = match^, 'match[2]?');
+        {$ENDIF}
+        { We check for insufficient lookahead only every 8th comparison;
+          the 256th check will be made at strstart+258. }
+
+        repeat
+          Inc(scan); Inc(match); if (scan^ <> match^) then break;
+          Inc(scan); Inc(match); if (scan^ <> match^) then break;
+          Inc(scan); Inc(match); if (scan^ <> match^) then break;
+          Inc(scan); Inc(match); if (scan^ <> match^) then break;
+          Inc(scan); Inc(match); if (scan^ <> match^) then break;
+          Inc(scan); Inc(match); if (scan^ <> match^) then break;
+          Inc(scan); Inc(match); if (scan^ <> match^) then break;
+          Inc(scan); Inc(match); if (scan^ <> match^) then break;
+        until (ptr2int(scan) >= ptr2int(strend));
+
+        {$IFDEF DEBUG}
+        Assert(ptr2int(scan) <=
+               ptr2int(@(s.window^[unsigned(s.window_size-1)])),
+               'wild scan');
+        {$ENDIF}
+
+        len := MAX_MATCH - int(ptr2int(strend) - ptr2int(scan));
+        scan := strend;
+        Dec(scan, MAX_MATCH);
+
+{$endif} { UNALIGNED_OK }
+
+        if (len > best_len) then
+        begin
+            s.match_start := cur_match;
+            best_len := len;
+            if (len >= nice_match) then
+              break;
+  {$IFOPT R+} {$R-} {$DEFINE NoRangeCheck} {$ENDIF}
+{$ifdef UNALIGNED_OK}
+            scan_end   := pzByteArray(scan)^[best_len-1];
+{$else}
+            scan_end1  := pzByteArray(scan)^[best_len-1];
+            scan_end   := pzByteArray(scan)^[best_len];
+{$endif}
+  {$IFDEF NoRangeCheck} {$R+} {$UNDEF NoRangeCheck} {$ENDIF}
+        end;
+    nextstep:
+      cur_match := prev^[cur_match and wmask];
+      Dec(chain_length);
+    until (cur_match <= limit) or (chain_length = 0);
+
+    if (uInt(best_len) <= s.lookahead) then
+      longest_match := uInt(best_len)
+    else
+      longest_match := s.lookahead;
+end;
+{$endif} { ASMV }
+
+{$else} { FASTEST }
+{ ---------------------------------------------------------------------------
+  Optimized version for level = 1 only }
+
+{local}
+function longest_match(var s : deflate_state;
+                       cur_match : IPos  { current match }
+                       ) : uInt;
+var
+  {register} scan : pBytef;   { current string }
+  {register} match : pBytef;  { matched string }
+  {register} len : int;       { length of current match }
+  {register} strend : pBytef;
+begin
+  scan := @s.window^[s.strstart];
+  strend := @s.window^[s.strstart + MAX_MATCH];
+
+
+    { The code is optimized for HASH_BITS >= 8 and MAX_MATCH-2 multiple of 16.
+      It is easy to get rid of this optimization if necessary. }
+    {$IFDEF DEBUG}
+    Assert((s.hash_bits >= 8) and (MAX_MATCH = 258), 'Code too clever');
+
+    Assert(ulg(s.strstart) <= s.window_size-MIN_LOOKAHEAD, 'need lookahead');
+
+    Assert(cur_match < s.strstart, 'no future');
+    {$ENDIF}
+    match := s.window + cur_match;
+
+    { Return failure if the match length is less than 2: }
+
+    if (match[0] <> scan[0]) or (match[1] <> scan[1]) then
+    begin
+      longest_match := MIN_MATCH-1;
+      exit;
+    end;
+
+    { The check at best_len-1 can be removed because it will be made
+      again later. (This heuristic is not always a win.)
+      It is not necessary to compare scan[2] and match[2] since they
+      are always equal when the other bytes match, given that
+      the hash keys are equal and that HASH_BITS >= 8. }
+
+    scan += 2, match += 2;
+    Assert(scan^ = match^, 'match[2]?');
+
+    { We check for insufficient lookahead only every 8th comparison;
+      the 256th check will be made at strstart+258. }
+
+    repeat
+      Inc(scan); Inc(match); if scan^<>match^ then break;
+      Inc(scan); Inc(match); if scan^<>match^ then break;
+      Inc(scan); Inc(match); if scan^<>match^ then break;
+      Inc(scan); Inc(match); if scan^<>match^ then break;
+      Inc(scan); Inc(match); if scan^<>match^ then break;
+      Inc(scan); Inc(match); if scan^<>match^ then break;
+      Inc(scan); Inc(match); if scan^<>match^ then break;
+      Inc(scan); Inc(match); if scan^<>match^ then break;
+    until (ptr2int(scan) >= ptr2int(strend));
+
+    Assert(scan <= s.window+unsigned(s.window_size-1), 'wild scan');
+
+    len := MAX_MATCH - int(strend - scan);
+
+    if (len < MIN_MATCH) then
+    begin
+      return := MIN_MATCH - 1;
+      exit;
+    end;
+
+    s.match_start := cur_match;
+    if len <= s.lookahead then
+      longest_match := len
+    else
+      longest_match := s.lookahead;
+end;
+{$endif} { FASTEST }
+
+{$ifdef DEBUG}
+{ ===========================================================================
+  Check that the match at match_start is indeed a match. }
+
+{local}
+procedure check_match(var s : deflate_state;
+                      start, match : IPos;
+                      length : int);
+begin
+  exit;
+  { check that the match is indeed a match }
+  if (zmemcmp(pBytef(@s.window^[match]),
+              pBytef(@s.window^[start]), length) <> EQUAL) then
+  begin
+    WriteLn(' start ',start,', match ',match ,' length ', length);
+    repeat
+      Write(char(s.window^[match]), char(s.window^[start]));
+      Inc(match);
+      Inc(start);
+      Dec(length);
+    Until (length = 0);
+    z_error('invalid match');
+  end;
+  if (z_verbose > 1) then
+  begin
+    Write('\\[',start-match,',',length,']');
+    repeat
+       Write(char(s.window^[start]));
+       Inc(start);
+       Dec(length);
+    Until (length = 0);
+  end;
+end;
+{$endif}
+
+{ ===========================================================================
+  Fill the window when the lookahead becomes insufficient.
+  Updates strstart and lookahead.
+
+  IN assertion: lookahead < MIN_LOOKAHEAD
+  OUT assertions: strstart <= window_size-MIN_LOOKAHEAD
+     At least one byte has been read, or avail_in = 0; reads are
+     performed for at least two bytes (required for the zip translate_eol
+     option -- not supported here). }
+
+{local}
+procedure fill_window(var s : deflate_state);
+var
+  {register} n, m : unsigned;
+  {register} p : pPosf;
+  more : unsigned;    { Amount of free space at the end of the window. }
+  wsize : uInt;
+begin
+   wsize := s.w_size;
+   repeat
+     more := unsigned(s.window_size -ulg(s.lookahead) -ulg(s.strstart));
+
+     { Deal with !@#$% 64K limit: }
+     if (more = 0) and (s.strstart = 0) and (s.lookahead = 0) then
+       more := wsize
+     else
+     if (more = unsigned(-1)) then
+     begin
+       { Very unlikely, but possible on 16 bit machine if strstart = 0
+         and lookahead = 1 (input done one byte at time) }
+       Dec(more);
+
+       { If the window is almost full and there is insufficient lookahead,
+         move the upper half to the lower one to make room in the upper half.}
+     end
+     else
+       if (s.strstart >= wsize+ {MAX_DIST}wsize-MIN_LOOKAHEAD) then
+       begin
+         zmemcpy( pBytef(s.window), pBytef(@(s.window^[wsize])),
+                 unsigned(wsize));
+         Dec(s.match_start, wsize);
+         Dec(s.strstart, wsize); { we now have strstart >= MAX_DIST }
+         Dec(s.block_start, long(wsize));
+
+         { Slide the hash table (could be avoided with 32 bit values
+           at the expense of memory usage). We slide even when level = 0
+           to keep the hash table consistent if we switch back to level > 0
+           later. (Using level 0 permanently is not an optimal usage of
+           zlib, so we don't care about this pathological case.) }
+
+         n := s.hash_size;
+         p := @s.head^[n];
+         repeat
+           Dec(p);
+           m := p^;
+           if (m >= wsize) then
+             p^ := Pos(m-wsize)
+           else
+             p^ := Pos(ZNIL);
+           Dec(n);
+         Until (n=0);
+
+         n := wsize;
+{$ifndef FASTEST}
+         p := @s.prev^[n];
+         repeat
+           Dec(p);
+           m := p^;
+           if (m >= wsize) then
+             p^ := Pos(m-wsize)
+           else
+             p^:= Pos(ZNIL);
+             { If n is not on any hash chain, prev^[n] is garbage but
+               its value will never be used. }
+           Dec(n);
+         Until (n=0);
+{$endif}
+         Inc(more, wsize);
+     end;
+     if (s.strm^.avail_in = 0) then
+       exit;
+
+     {* If there was no sliding:
+      *    strstart <= WSIZE+MAX_DIST-1 && lookahead <= MIN_LOOKAHEAD - 1 &&
+      *    more == window_size - lookahead - strstart
+      * => more >= window_size - (MIN_LOOKAHEAD-1 + WSIZE + MAX_DIST-1)
+      * => more >= window_size - 2*WSIZE + 2
+      * In the BIG_MEM or MMAP case (not yet supported),
+      *   window_size == input_size + MIN_LOOKAHEAD  &&
+      *   strstart + s->lookahead <= input_size => more >= MIN_LOOKAHEAD.
+      * Otherwise, window_size == 2*WSIZE so more >= 2.
+      * If there was sliding, more >= WSIZE. So in all cases, more >= 2. }
+
+     {$IFDEF DEBUG}
+     Assert(more >= 2, 'more < 2');
+     {$ENDIF}
+
+     n := read_buf(s.strm, pBytef(@(s.window^[s.strstart + s.lookahead])),
+                  more);
+     Inc(s.lookahead, n);
+
+     { Initialize the hash value now that we have some input: }
+     if (s.lookahead >= MIN_MATCH) then
+     begin
+       s.ins_h := s.window^[s.strstart];
+       {UPDATE_HASH(s, s.ins_h, s.window[s.strstart+1]);}
+       s.ins_h := ((s.ins_h shl s.hash_shift) xor s.window^[s.strstart+1])
+                     and s.hash_mask;
+{$ifdef MIN_MATCH <> 3}
+       Call UPDATE_HASH() MIN_MATCH-3 more times
+{$endif}
+     end;
+     { If the whole input has less than MIN_MATCH bytes, ins_h is garbage,
+       but this is not important since only literal bytes will be emitted. }
+
+   until (s.lookahead >= MIN_LOOKAHEAD) or (s.strm^.avail_in = 0);
+end;
+
+{ ===========================================================================
+  Flush the current block, with given end-of-file flag.
+  IN assertion: strstart is set to the end of the current match. }
+
+procedure FLUSH_BLOCK_ONLY(var s : deflate_state; eof : boolean); {macro}
+begin
+  if (s.block_start >= Long(0)) then
+    _tr_flush_block(s, pcharf(@s.window^[unsigned(s.block_start)]),
+                    ulg(long(s.strstart) - s.block_start), eof)
+  else
+    _tr_flush_block(s, pcharf(Z_NULL),
+                    ulg(long(s.strstart) - s.block_start), eof);
+
+  s.block_start := s.strstart;
+  flush_pending(s.strm^);
+  {$IFDEF DEBUG}
+  Tracev('[FLUSH]');
+  {$ENDIF}
+end;
+
+{ Same but force premature exit if necessary.
+macro FLUSH_BLOCK(var s : deflate_state; eof : boolean) : boolean;
+var
+  result : block_state;
+begin
+ FLUSH_BLOCK_ONLY(s, eof);
+ if (s.strm^.avail_out = 0) then
+ begin
+   if eof then
+     result := finish_started
+   else
+     result := need_more;
+   exit;
+ end;
+end;
+}
+
+{ ===========================================================================
+  Copy without compression as much as possible from the input stream, return
+  the current block state.
+  This function does not insert new strings in the dictionary since
+  uncompressible data is probably not useful. This function is used
+  only for the level=0 compression option.
+  NOTE: this function should be optimized to avoid extra copying from
+  window to pending_buf. }
+
+
+{local}
+function deflate_stored(var s : deflate_state; flush : int) : block_state;
+{ Stored blocks are limited to 0xffff bytes, pending_buf is limited
+  to pending_buf_size, and each stored block has a 5 byte header: }
+var
+  max_block_size : ulg;
+  max_start : ulg;
+begin
+  max_block_size := $ffff;
+  if (max_block_size > s.pending_buf_size - 5) then
+    max_block_size := s.pending_buf_size - 5;
+
+  { Copy as much as possible from input to output: }
+  while TRUE do
+  begin
+    { Fill the window as much as possible: }
+    if (s.lookahead <= 1) then
+    begin
+      {$IFDEF DEBUG}
+      Assert( (s.strstart < s.w_size + {MAX_DIST}s.w_size-MIN_LOOKAHEAD) or
+              (s.block_start >= long(s.w_size)), 'slide too late');
+      {$ENDIF}
+      fill_window(s);
+      if (s.lookahead = 0) and (flush = Z_NO_FLUSH) then
+      begin
+        deflate_stored := need_more;
+        exit;
+      end;
+
+      if (s.lookahead = 0) then
+        break; { flush the current block }
+    end;
+    {$IFDEF DEBUG}
+    Assert(s.block_start >= long(0), 'block gone');
+    {$ENDIF}
+    Inc(s.strstart, s.lookahead);
+    s.lookahead := 0;
+
+    { Emit a stored block if pending_buf will be full: }
+    max_start := s.block_start + max_block_size;
+    if (s.strstart = 0) or (ulg(s.strstart) >= max_start) then
+    begin
+      { strstart = 0 is possible when wraparound on 16-bit machine }
+      s.lookahead := uInt(s.strstart - max_start);
+      s.strstart := uInt(max_start);
+      {FLUSH_BLOCK(s, FALSE);}
+      FLUSH_BLOCK_ONLY(s, FALSE);
+      if (s.strm^.avail_out = 0) then
+      begin
+        deflate_stored := need_more;
+        exit;
+      end;
+    end;
+
+    { Flush if we may have to slide, otherwise block_start may become
+      negative and the data will be gone: }
+
+    if (s.strstart - uInt(s.block_start) >= {MAX_DIST}
+        s.w_size-MIN_LOOKAHEAD) then
+    begin
+      {FLUSH_BLOCK(s, FALSE);}
+      FLUSH_BLOCK_ONLY(s, FALSE);
+      if (s.strm^.avail_out = 0) then
+      begin
+        deflate_stored := need_more;
+        exit;
+      end;
+    end;
+  end;
+
+  {FLUSH_BLOCK(s, flush = Z_FINISH);}
+  FLUSH_BLOCK_ONLY(s, flush = Z_FINISH);
+  if (s.strm^.avail_out = 0) then
+  begin
+    if flush = Z_FINISH then
+      deflate_stored := finish_started
+    else
+      deflate_stored := need_more;
+    exit;
+  end;
+
+  if flush = Z_FINISH then
+    deflate_stored := finish_done
+  else
+    deflate_stored := block_done;
+end;
+
+{ ===========================================================================
+  Compress as much as possible from the input stream, return the current
+  block state.
+  This function does not perform lazy evaluation of matches and inserts
+  new strings in the dictionary only for unmatched strings or for short
+  matches. It is used only for the fast compression options. }
+
+{local}
+function deflate_fast(var s : deflate_state; flush : int) : block_state;
+var
+  hash_head : IPos;     { head of the hash chain }
+  bflush : boolean;     { set if current block must be flushed }
+begin
+  hash_head := ZNIL;
+  while TRUE do
+  begin
+  { Make sure that we always have enough lookahead, except
+    at the end of the input file. We need MAX_MATCH bytes
+    for the next match, plus MIN_MATCH bytes to insert the
+    string following the next match. }
+
+    if (s.lookahead < MIN_LOOKAHEAD) then
+    begin
+      fill_window(s);
+      if (s.lookahead < MIN_LOOKAHEAD) and (flush = Z_NO_FLUSH) then
+      begin
+        deflate_fast := need_more;
+        exit;
+      end;
+
+      if (s.lookahead = 0) then
+        break; { flush the current block }
+    end;
+
+
+    { Insert the string window[strstart .. strstart+2] in the
+      dictionary, and set hash_head to the head of the hash chain: }
+
+    if (s.lookahead >= MIN_MATCH) then
+    begin
+      INSERT_STRING(s, s.strstart, hash_head);
+    end;
+
+    { Find the longest match, discarding those <= prev_length.
+      At this point we have always match_length < MIN_MATCH }
+    if (hash_head <> ZNIL) and
+       (s.strstart - hash_head <= (s.w_size-MIN_LOOKAHEAD){MAX_DIST}) then
+    begin
+      { To simplify the code, we prevent matches with the string
+        of window index 0 (in particular we have to avoid a match
+        of the string with itself at the start of the input file). }
+      if (s.strategy <> Z_HUFFMAN_ONLY) then
+      begin
+        s.match_length := longest_match (s, hash_head);
+      end;
+      { longest_match() sets match_start }
+    end;
+    if (s.match_length >= MIN_MATCH) then
+    begin
+      {$IFDEF DEBUG}
+      check_match(s, s.strstart, s.match_start, s.match_length);
+      {$ENDIF}
+
+      {_tr_tally_dist(s, s.strstart - s.match_start,
+                        s.match_length - MIN_MATCH, bflush);}
+      bflush := _tr_tally(s, s.strstart - s.match_start,
+                        s.match_length - MIN_MATCH);
+
+      Dec(s.lookahead, s.match_length);
+
+      { Insert new strings in the hash table only if the match length
+        is not too large. This saves time but degrades compression. }
+
+{$ifndef FASTEST}
+      if (s.match_length <= s.max_insert_length)
+       and (s.lookahead >= MIN_MATCH) then
+      begin
+        Dec(s.match_length); { string at strstart already in hash table }
+        repeat
+          Inc(s.strstart);
+          INSERT_STRING(s, s.strstart, hash_head);
+          { strstart never exceeds WSIZE-MAX_MATCH, so there are
+            always MIN_MATCH bytes ahead. }
+          Dec(s.match_length);
+        until (s.match_length = 0);
+        Inc(s.strstart);
+      end
+      else
+{$endif}
+
+      begin
+        Inc(s.strstart, s.match_length);
+        s.match_length := 0;
+        s.ins_h := s.window^[s.strstart];
+        {UPDATE_HASH(s, s.ins_h, s.window[s.strstart+1]);}
+        s.ins_h := (( s.ins_h shl s.hash_shift) xor
+                     s.window^[s.strstart+1]) and s.hash_mask;
+if MIN_MATCH <> 3 then   { the linker removes this }
+begin
+          {Call UPDATE_HASH() MIN_MATCH-3 more times}
+end;
+
+        { If lookahead < MIN_MATCH, ins_h is garbage, but it does not
+          matter since it will be recomputed at next deflate call. }
+
+      end;
+    end
+    else
+    begin
+      { No match, output a literal byte }
+      {$IFDEF DEBUG}
+      Tracevv(char(s.window^[s.strstart]));
+      {$ENDIF}
+      {_tr_tally_lit (s, 0, s.window^[s.strstart], bflush);}
+      bflush := _tr_tally (s, 0, s.window^[s.strstart]);
+
+      Dec(s.lookahead);
+      Inc(s.strstart);
+    end;
+    if bflush then
+    begin  {FLUSH_BLOCK(s, FALSE);}
+      FLUSH_BLOCK_ONLY(s, FALSE);
+      if (s.strm^.avail_out = 0) then
+      begin
+        deflate_fast := need_more;
+        exit;
+      end;
+    end;
+  end;
+  {FLUSH_BLOCK(s, flush = Z_FINISH);}
+  FLUSH_BLOCK_ONLY(s, flush = Z_FINISH);
+  if (s.strm^.avail_out = 0) then
+  begin
+    if flush = Z_FINISH then
+      deflate_fast := finish_started
+    else
+      deflate_fast := need_more;
+    exit;
+  end;
+
+  if flush = Z_FINISH then
+    deflate_fast := finish_done
+  else
+    deflate_fast := block_done;
+end;
+
+{ ===========================================================================
+  Same as above, but achieves better compression. We use a lazy
+  evaluation for matches: a match is finally adopted only if there is
+  no better match at the next window position. }
+
+{local}
+function deflate_slow(var s : deflate_state; flush : int) : block_state;
+var
+  hash_head : IPos;       { head of hash chain }
+  bflush : boolean;       { set if current block must be flushed }
+var
+  max_insert : uInt;
+begin
+  hash_head := ZNIL;
+
+  { Process the input block. }
+  while TRUE do
+  begin
+    { Make sure that we always have enough lookahead, except
+      at the end of the input file. We need MAX_MATCH bytes
+      for the next match, plus MIN_MATCH bytes to insert the
+      string following the next match. }
+
+    if (s.lookahead < MIN_LOOKAHEAD) then
+    begin
+      fill_window(s);
+      if (s.lookahead < MIN_LOOKAHEAD) and (flush = Z_NO_FLUSH) then
+      begin
+        deflate_slow := need_more;
+        exit;
+      end;
+
+      if (s.lookahead = 0) then
+        break; { flush the current block }
+    end;
+
+    { Insert the string window[strstart .. strstart+2] in the
+      dictionary, and set hash_head to the head of the hash chain: }
+
+    if (s.lookahead >= MIN_MATCH) then
+    begin
+      INSERT_STRING(s, s.strstart, hash_head);
+    end;
+
+    { Find the longest match, discarding those <= prev_length. }
+
+    s.prev_length := s.match_length;
+    s.prev_match := s.match_start;
+    s.match_length := MIN_MATCH-1;
+
+    if (hash_head <> ZNIL) and (s.prev_length < s.max_lazy_match) and
+       (s.strstart - hash_head <= {MAX_DIST}(s.w_size-MIN_LOOKAHEAD)) then
+    begin
+        { To simplify the code, we prevent matches with the string
+          of window index 0 (in particular we have to avoid a match
+          of the string with itself at the start of the input file). }
+
+        if (s.strategy <> Z_HUFFMAN_ONLY) then
+        begin
+          s.match_length := longest_match (s, hash_head);
+        end;
+        { longest_match() sets match_start }
+
+        if (s.match_length <= 5) and ((s.strategy = Z_FILTERED) or
+             ((s.match_length = MIN_MATCH) and
+              (s.strstart - s.match_start > TOO_FAR))) then
+        begin
+            { If prev_match is also MIN_MATCH, match_start is garbage
+              but we will ignore the current match anyway. }
+
+            s.match_length := MIN_MATCH-1;
+        end;
+    end;
+    { If there was a match at the previous step and the current
+      match is not better, output the previous match: }
+
+    if (s.prev_length >= MIN_MATCH)
+      and (s.match_length <= s.prev_length) then
+    begin
+      max_insert := s.strstart + s.lookahead - MIN_MATCH;
+      { Do not insert strings in hash table beyond this. }
+      {$ifdef DEBUG}
+      check_match(s, s.strstart-1, s.prev_match, s.prev_length);
+      {$endif}
+
+      {_tr_tally_dist(s, s->strstart -1 - s->prev_match,
+                        s->prev_length - MIN_MATCH, bflush);}
+      bflush := _tr_tally(s, s.strstart -1 - s.prev_match,
+                           s.prev_length - MIN_MATCH);
+
+      { Insert in hash table all strings up to the end of the match.
+        strstart-1 and strstart are already inserted. If there is not
+        enough lookahead, the last two strings are not inserted in
+        the hash table. }
+
+      Dec(s.lookahead, s.prev_length-1);
+      Dec(s.prev_length, 2);
+      repeat
+        Inc(s.strstart);
+        if (s.strstart <= max_insert) then
+        begin
+          INSERT_STRING(s, s.strstart, hash_head);
+        end;
+        Dec(s.prev_length);
+      until (s.prev_length = 0);
+      s.match_available := FALSE;
+      s.match_length := MIN_MATCH-1;
+      Inc(s.strstart);
+
+      if (bflush) then  {FLUSH_BLOCK(s, FALSE);}
+      begin
+        FLUSH_BLOCK_ONLY(s, FALSE);
+        if (s.strm^.avail_out = 0) then
+        begin
+          deflate_slow := need_more;
+          exit;
+        end;
+      end;
+    end
+    else
+      if (s.match_available) then
+      begin
+        { If there was no match at the previous position, output a
+          single literal. If there was a match but the current match
+          is longer, truncate the previous match to a single literal. }
+        {$IFDEF DEBUG}
+        Tracevv(char(s.window^[s.strstart-1]));
+        {$ENDIF}
+        bflush := _tr_tally (s, 0, s.window^[s.strstart-1]);
+
+        if bflush then
+        begin
+          FLUSH_BLOCK_ONLY(s, FALSE);
+        end;
+        Inc(s.strstart);
+        Dec(s.lookahead);
+        if (s.strm^.avail_out = 0) then
+        begin
+          deflate_slow := need_more;
+          exit;
+        end;
+      end
+      else
+      begin
+        { There is no previous match to compare with, wait for
+          the next step to decide. }
+
+        s.match_available := TRUE;
+        Inc(s.strstart);
+        Dec(s.lookahead);
+      end;
+  end;
+
+  {$IFDEF DEBUG}
+  Assert (flush <> Z_NO_FLUSH, 'no flush?');
+  {$ENDIF}
+  if (s.match_available) then
+  begin
+    {$IFDEF DEBUG}
+    Tracevv(char(s.window^[s.strstart-1]));
+    bflush :=
+    {$ENDIF}
+      _tr_tally (s, 0, s.window^[s.strstart-1]);
+    s.match_available := FALSE;
+  end;
+  {FLUSH_BLOCK(s, flush = Z_FINISH);}
+  FLUSH_BLOCK_ONLY(s, flush = Z_FINISH);
+  if (s.strm^.avail_out = 0) then
+  begin
+    if flush = Z_FINISH then
+      deflate_slow := finish_started
+    else
+      deflate_slow := need_more;
+    exit;
+  end;
+  if flush = Z_FINISH then
+    deflate_slow := finish_done
+  else
+    deflate_slow := block_done;
+end;
+
+end.

+ 746 - 0
packages/base/paszlib/zinflate.pas

@@ -0,0 +1,746 @@
+Unit  zInflate;
+
+{  inflate.c -- zlib interface to inflate modules
+   Copyright (C) 1995-1998 Mark Adler
+
+  Pascal tranlastion
+  Copyright (C) 1998 by Jacques Nomssi Nzali
+  For conditions of distribution and use, see copyright notice in readme.txt
+}
+
+interface
+
+{$I zconf.inc}
+
+uses
+  zutil, zbase, infblock, infutil;
+
+function inflateInit(var z : z_stream) : int;
+
+{    Initializes the internal stream state for decompression. The fields
+   zalloc, zfree and opaque must be initialized before by the caller.  If
+   zalloc and zfree are set to Z_NULL, inflateInit updates them to use default
+   allocation functions.
+
+     inflateInit returns Z_OK if success, Z_MEM_ERROR if there was not
+   enough memory, Z_VERSION_ERROR if the zlib library version is incompatible
+   with the version assumed by the caller.  msg is set to null if there is no
+   error message. inflateInit does not perform any decompression: this will be
+   done by inflate(). }
+
+
+
+function inflateInit_(z : z_streamp;
+                      const version : string;
+                      stream_size : int) : int;
+
+
+function inflateInit2_(var z: z_stream;
+                       w : int;
+                       const version : string;
+                       stream_size : int) : int;
+{
+     This is another version of inflateInit with an extra parameter. The
+   fields next_in, avail_in, zalloc, zfree and opaque must be initialized
+   before by the caller.
+
+     The windowBits parameter is the base two logarithm of the maximum window
+   size (the size of the history buffer).  It should be in the range 8..15 for
+   this version of the library. The default value is 15 if inflateInit is used
+   instead. If a compressed stream with a larger window size is given as
+   input, inflate() will return with the error code Z_DATA_ERROR instead of
+   trying to allocate a larger window.
+
+      inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
+   memory, Z_STREAM_ERROR if a parameter is invalid (such as a negative
+   memLevel). msg is set to null if there is no error message.  inflateInit2
+   does not perform any decompression apart from reading the zlib header if
+   present: this will be done by inflate(). (So next_in and avail_in may be
+   modified, but next_out and avail_out are unchanged.)
+}
+
+
+
+function inflateEnd(var z : z_stream) : int;
+
+{
+   All dynamically allocated data structures for this stream are freed.
+   This function discards any unprocessed input and does not flush any
+   pending output.
+
+     inflateEnd returns Z_OK if success, Z_STREAM_ERROR if the stream state
+   was inconsistent. In the error case, msg may be set but then points to a
+   static string (which must not be deallocated).
+}
+
+function inflateReset(var z : z_stream) : int;
+
+{
+   This function is equivalent to inflateEnd followed by inflateInit,
+   but does not free and reallocate all the internal decompression state.
+   The stream will keep attributes that may have been set by inflateInit2.
+
+      inflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source
+   stream state was inconsistent (such as zalloc or state being NULL).
+}
+
+
+function inflate(var z : z_stream;
+                 f : int) : int;
+{
+  inflate decompresses as much data as possible, and stops when the input
+  buffer becomes empty or the output buffer becomes full. It may introduce
+  some output latency (reading input without producing any output)
+  except when forced to flush.
+
+  The detailed semantics are as follows. inflate performs one or both of the
+  following actions:
+
+  - Decompress more input starting at next_in and update next_in and avail_in
+    accordingly. If not all input can be processed (because there is not
+    enough room in the output buffer), next_in is updated and processing
+    will resume at this point for the next call of inflate().
+
+  - Provide more output starting at next_out and update next_out and avail_out
+    accordingly.  inflate() provides as much output as possible, until there
+    is no more input data or no more space in the output buffer (see below
+    about the flush parameter).
+
+  Before the call of inflate(), the application should ensure that at least
+  one of the actions is possible, by providing more input and/or consuming
+  more output, and updating the next_* and avail_* values accordingly.
+  The application can consume the uncompressed output when it wants, for
+  example when the output buffer is full (avail_out == 0), or after each
+  call of inflate(). If inflate returns Z_OK and with zero avail_out, it
+  must be called again after making room in the output buffer because there
+  might be more output pending.
+
+    If the parameter flush is set to Z_SYNC_FLUSH, inflate flushes as much
+  output as possible to the output buffer. The flushing behavior of inflate is
+  not specified for values of the flush parameter other than Z_SYNC_FLUSH
+  and Z_FINISH, but the current implementation actually flushes as much output
+  as possible anyway.
+
+    inflate() should normally be called until it returns Z_STREAM_END or an
+  error. However if all decompression is to be performed in a single step
+  (a single call of inflate), the parameter flush should be set to
+  Z_FINISH. In this case all pending input is processed and all pending
+  output is flushed; avail_out must be large enough to hold all the
+  uncompressed data. (The size of the uncompressed data may have been saved
+  by the compressor for this purpose.) The next operation on this stream must
+  be inflateEnd to deallocate the decompression state. The use of Z_FINISH
+  is never required, but can be used to inform inflate that a faster routine
+  may be used for the single inflate() call.
+
+     If a preset dictionary is needed at this point (see inflateSetDictionary
+  below), inflate sets strm-adler to the adler32 checksum of the
+  dictionary chosen by the compressor and returns Z_NEED_DICT; otherwise
+  it sets strm->adler to the adler32 checksum of all output produced
+  so far (that is, total_out bytes) and returns Z_OK, Z_STREAM_END or
+  an error code as described below. At the end of the stream, inflate()
+  checks that its computed adler32 checksum is equal to that saved by the
+  compressor and returns Z_STREAM_END only if the checksum is correct.
+
+    inflate() returns Z_OK if some progress has been made (more input processed
+  or more output produced), Z_STREAM_END if the end of the compressed data has
+  been reached and all uncompressed output has been produced, Z_NEED_DICT if a
+  preset dictionary is needed at this point, Z_DATA_ERROR if the input data was
+  corrupted (input stream not conforming to the zlib format or incorrect
+  adler32 checksum), Z_STREAM_ERROR if the stream structure was inconsistent
+  (for example if next_in or next_out was NULL), Z_MEM_ERROR if there was not
+  enough memory, Z_BUF_ERROR if no progress is possible or if there was not
+  enough room in the output buffer when Z_FINISH is used. In the Z_DATA_ERROR
+  case, the application may then call inflateSync to look for a good
+  compression block.
+}
+
+
+function inflateSetDictionary(var z : z_stream;
+                              dictionary : pBytef; {const array of byte}
+                              dictLength : uInt) : int;
+
+{
+     Initializes the decompression dictionary from the given uncompressed byte
+   sequence. This function must be called immediately after a call of inflate
+   if this call returned Z_NEED_DICT. The dictionary chosen by the compressor
+   can be determined from the Adler32 value returned by this call of
+   inflate. The compressor and decompressor must use exactly the same
+   dictionary (see deflateSetDictionary).
+
+     inflateSetDictionary returns Z_OK if success, Z_STREAM_ERROR if a
+   parameter is invalid (such as NULL dictionary) or the stream state is
+   inconsistent, Z_DATA_ERROR if the given dictionary doesn't match the
+   expected one (incorrect Adler32 value). inflateSetDictionary does not
+   perform any decompression: this will be done by subsequent calls of
+   inflate().
+}
+
+function inflateSync(var z : z_stream) : int;
+
+{
+  Skips invalid compressed data until a full flush point (see above the
+  description of deflate with Z_FULL_FLUSH) can be found, or until all
+  available input is skipped. No output is provided.
+
+    inflateSync returns Z_OK if a full flush point has been found, Z_BUF_ERROR
+  if no more input was provided, Z_DATA_ERROR if no flush point has been found,
+  or Z_STREAM_ERROR if the stream structure was inconsistent. In the success
+  case, the application may save the current current value of total_in which
+  indicates where valid compressed data was found. In the error case, the
+  application may repeatedly call inflateSync, providing more input each time,
+  until success or end of the input data.
+}
+
+
+function inflateSyncPoint(var z : z_stream) : int;
+
+
+implementation
+
+uses
+  adler;
+
+function inflateReset(var z : z_stream) : int;
+begin
+  if (z.state = Z_NULL) then
+  begin
+    inflateReset :=  Z_STREAM_ERROR;
+    exit;
+  end;
+  z.total_out := 0;
+  z.total_in := 0;
+  z.msg := '';
+  if z.state^.nowrap then
+    z.state^.mode := BLOCKS
+  else
+    z.state^.mode := METHOD;
+  inflate_blocks_reset(z.state^.blocks^, z, Z_NULL);
+  {$IFDEF DEBUG}
+  Tracev('inflate: reset');
+  {$ENDIF}
+  inflateReset :=  Z_OK;
+end;
+
+
+function inflateEnd(var z : z_stream) : int;
+begin
+  if (z.state = Z_NULL) or not Assigned(z.zfree) then
+  begin
+    inflateEnd :=  Z_STREAM_ERROR;
+    exit;
+  end;
+  if (z.state^.blocks <> Z_NULL) then
+    inflate_blocks_free(z.state^.blocks, z);
+  ZFREE(z, z.state);
+  z.state := Z_NULL;
+  {$IFDEF DEBUG}
+  Tracev('inflate: end');
+  {$ENDIF}
+  inflateEnd :=  Z_OK;
+end;
+
+
+function inflateInit2_(var z: z_stream;
+                       w : int;
+                       const version : string;
+                       stream_size : int) : int;
+begin
+  if (version = '') or (version[1] <> ZLIB_VERSION[1]) or
+      (stream_size <> sizeof(z_stream)) then
+  begin
+    inflateInit2_ := Z_VERSION_ERROR;
+    exit;
+  end;
+  { initialize state }
+  { SetLength(strm.msg, 255); }
+  z.msg := '';
+{$ifdef fpc}
+  if not Assigned(z.zalloc) then
+  begin
+    z.zalloc := @zcalloc;
+    z.opaque := voidpf(0);
+  end;
+  if not Assigned(z.zfree) then
+    z.zfree := @zcfree;
+{$else}
+  if not Assigned(z.zalloc) then
+  begin
+    z.zalloc := zcalloc;
+    z.opaque := voidpf(0);
+  end;
+  if not Assigned(z.zfree) then
+    z.zfree := zcfree;
+{$endif}
+  z.state := pInternal_state( ZALLOC(z,1,sizeof(internal_state)) );
+  if (z.state = Z_NULL) then
+  begin
+    inflateInit2_ := Z_MEM_ERROR;
+    exit;
+  end;
+
+  z.state^.blocks := Z_NULL;
+
+  { handle undocumented nowrap option (no zlib header or check) }
+  z.state^.nowrap := FALSE;
+  if (w < 0) then
+  begin
+    w := - w;
+    z.state^.nowrap := TRUE;
+  end;
+
+  { set window size }
+  if (w < 8) or (w > 15) then
+  begin
+    inflateEnd(z);
+    inflateInit2_ := Z_STREAM_ERROR;
+    exit;
+  end;
+  z.state^.wbits := uInt(w);
+
+  { create inflate_blocks state }
+  if z.state^.nowrap then
+    z.state^.blocks := inflate_blocks_new(z, NIL, uInt(1) shl w)
+  else
+{$ifdef fpc}
+    z.state^.blocks := inflate_blocks_new(z, @adler32, uInt(1) shl w);
+{$else}
+    z.state^.blocks := inflate_blocks_new(z, adler32, uInt(1) shl w);
+{$endif}
+  if (z.state^.blocks = Z_NULL) then
+  begin
+    inflateEnd(z);
+    inflateInit2_ := Z_MEM_ERROR;
+    exit;
+  end;
+  {$IFDEF DEBUG}
+  Tracev('inflate: allocated');
+  {$ENDIF}
+  { reset state }
+  inflateReset(z);
+  inflateInit2_ :=  Z_OK;
+end;
+
+function inflateInit(var z : z_stream) : int;
+{ inflateInit is a macro to allow checking the zlib version
+  and the compiler's view of z_stream:
+  }
+begin
+  inflateInit := inflateInit2_(z, DEF_WBITS, ZLIB_VERSION, sizeof(z_stream));
+end;
+
+function inflateInit_(z : z_streamp;
+                      const version : string;
+                      stream_size : int) : int;
+begin
+  { initialize state }
+  if (z = Z_NULL) then
+    inflateInit_ := Z_STREAM_ERROR
+  else
+    inflateInit_ := inflateInit2_(z^, DEF_WBITS, version, stream_size);
+end;
+
+function inflate(var z : z_stream;
+                 f : int) : int;
+var
+  r : int;
+  b : uInt;
+begin
+  if (z.state = Z_NULL) or (z.next_in = Z_NULL) then
+  begin
+    inflate := Z_STREAM_ERROR;
+    exit;
+  end;
+  if f = Z_FINISH then
+    f := Z_BUF_ERROR
+  else
+    f := Z_OK;
+  r := Z_BUF_ERROR;
+  while True do
+  case (z.state^.mode) of
+    BLOCKS:
+      begin
+        r := inflate_blocks(z.state^.blocks^, z, r);
+        if (r = Z_DATA_ERROR) then
+        begin
+          z.state^.mode := BAD;
+          z.state^.sub.marker := 0;       { can try inflateSync }
+          continue;            { break C-switch }
+        end;
+        if (r = Z_OK) then
+          r := f;
+        if (r <> Z_STREAM_END) then
+        begin
+          inflate := r;
+          exit;
+        end;
+        r := f;
+        inflate_blocks_reset(z.state^.blocks^, z, @z.state^.sub.check.was);
+        if (z.state^.nowrap) then
+        begin
+          z.state^.mode := DONE;
+          continue;            { break C-switch }
+        end;
+        z.state^.mode := CHECK4;  { falltrough }
+      end;
+    CHECK4:
+      begin
+        {NEEDBYTE}
+        if (z.avail_in = 0) then
+        begin
+          inflate := r;
+          exit;
+        end;
+        r := f;
+
+        {z.state^.sub.check.need := uLong(NEXTBYTE(z)) shl 24;}
+        Dec(z.avail_in);
+        Inc(z.total_in);
+        z.state^.sub.check.need := uLong(z.next_in^) shl 24;
+        Inc(z.next_in);
+
+        z.state^.mode := CHECK3;   { falltrough }
+      end;
+    CHECK3:
+      begin
+        {NEEDBYTE}
+        if (z.avail_in = 0) then
+        begin
+          inflate := r;
+          exit;
+        end;
+        r := f;
+        {Inc( z.state^.sub.check.need, uLong(NEXTBYTE(z)) shl 16);}
+        Dec(z.avail_in);
+        Inc(z.total_in);
+        Inc(z.state^.sub.check.need, uLong(z.next_in^) shl 16);
+        Inc(z.next_in);
+
+        z.state^.mode := CHECK2;   { falltrough }
+      end;
+    CHECK2:
+      begin
+        {NEEDBYTE}
+        if (z.avail_in = 0) then
+        begin
+          inflate := r;
+          exit;
+        end;
+        r := f;
+
+        {Inc( z.state^.sub.check.need, uLong(NEXTBYTE(z)) shl 8);}
+        Dec(z.avail_in);
+        Inc(z.total_in);
+        Inc(z.state^.sub.check.need, uLong(z.next_in^) shl 8);
+        Inc(z.next_in);
+
+        z.state^.mode := CHECK1;   { falltrough }
+      end;
+    CHECK1:
+      begin
+        {NEEDBYTE}
+        if (z.avail_in = 0) then
+        begin
+          inflate := r;
+          exit;
+        end;
+        r := f;
+        {Inc( z.state^.sub.check.need, uLong(NEXTBYTE(z)) );}
+        Dec(z.avail_in);
+        Inc(z.total_in);
+        Inc(z.state^.sub.check.need, uLong(z.next_in^) );
+        Inc(z.next_in);
+
+
+        if (z.state^.sub.check.was <> z.state^.sub.check.need) then
+        begin
+          z.state^.mode := BAD;
+          z.msg := 'incorrect data check';
+          z.state^.sub.marker := 5;       { can't try inflateSync }
+          continue;           { break C-switch }
+        end;
+        {$IFDEF DEBUG}
+        Tracev('inflate: zlib check ok');
+        {$ENDIF}
+        z.state^.mode := DONE; { falltrough }
+      end;
+    DONE:
+      begin
+        inflate := Z_STREAM_END;
+        exit;
+      end;
+    METHOD:
+      begin
+        {NEEDBYTE}
+        if (z.avail_in = 0) then
+        begin
+          inflate := r;
+          exit;
+        end;
+        r := f; {}
+
+        {z.state^.sub.method := NEXTBYTE(z);}
+        Dec(z.avail_in);
+        Inc(z.total_in);
+        z.state^.sub.method := z.next_in^;
+        Inc(z.next_in);
+
+        if ((z.state^.sub.method and $0f) <> Z_DEFLATED) then
+        begin
+          z.state^.mode := BAD;
+          z.msg := 'unknown compression method';
+          z.state^.sub.marker := 5;       { can't try inflateSync }
+          continue;  { break C-switch }
+        end;
+        if ((z.state^.sub.method shr 4) + 8 > z.state^.wbits) then
+        begin
+          z.state^.mode := BAD;
+          z.msg := 'invalid window size';
+          z.state^.sub.marker := 5;       { can't try inflateSync }
+          continue; { break C-switch }
+        end;
+        z.state^.mode := FLAG;
+        { fall trough }
+      end;
+    FLAG:
+      begin
+        {NEEDBYTE}
+        if (z.avail_in = 0) then
+        begin
+          inflate := r;
+          exit;
+        end;
+        r := f; {}
+        {b := NEXTBYTE(z);}
+        Dec(z.avail_in);
+        Inc(z.total_in);
+        b := z.next_in^;
+        Inc(z.next_in);
+
+        if (((z.state^.sub.method shl 8) + b) mod 31) <> 0 then {% mod ?}
+        begin
+          z.state^.mode := BAD;
+          z.msg := 'incorrect header check';
+          z.state^.sub.marker := 5;       { can't try inflateSync }
+          continue;      { break C-switch }
+        end;
+        {$IFDEF DEBUG}
+        Tracev('inflate: zlib header ok');
+        {$ENDIF}
+        if ((b and PRESET_DICT) = 0) then
+        begin
+          z.state^.mode := BLOCKS;
+          continue;      { break C-switch }
+        end;
+        z.state^.mode := DICT4;
+        { falltrough }
+      end;
+    DICT4:
+      begin
+        if (z.avail_in = 0) then
+        begin
+          inflate := r;
+          exit;
+        end;
+        r := f;
+
+        {z.state^.sub.check.need := uLong(NEXTBYTE(z)) shl 24;}
+        Dec(z.avail_in);
+        Inc(z.total_in);
+        z.state^.sub.check.need :=  uLong(z.next_in^) shl 24;
+        Inc(z.next_in);
+
+        z.state^.mode := DICT3;        { falltrough }
+      end;
+    DICT3:
+      begin
+        if (z.avail_in = 0) then
+        begin
+          inflate := r;
+          exit;
+        end;
+        r := f;
+        {Inc(z.state^.sub.check.need, uLong(NEXTBYTE(z)) shl 16);}
+        Dec(z.avail_in);
+        Inc(z.total_in);
+        Inc(z.state^.sub.check.need, uLong(z.next_in^) shl 16);
+        Inc(z.next_in);
+
+        z.state^.mode := DICT2;        { falltrough }
+      end;
+    DICT2:
+      begin
+        if (z.avail_in = 0) then
+        begin
+          inflate := r;
+          exit;
+        end;
+        r := f;
+
+        {Inc(z.state^.sub.check.need, uLong(NEXTBYTE(z)) shl 8);}
+        Dec(z.avail_in);
+        Inc(z.total_in);
+        Inc(z.state^.sub.check.need, uLong(z.next_in^) shl 8);
+        Inc(z.next_in);
+
+        z.state^.mode := DICT1;        { falltrough }
+      end;
+    DICT1:
+      begin
+        if (z.avail_in = 0) then
+        begin
+          inflate := r;
+          exit;
+        end;
+        { r := f;    ---  wird niemals benutzt }
+        {Inc(z.state^.sub.check.need, uLong(NEXTBYTE(z)) );}
+        Dec(z.avail_in);
+        Inc(z.total_in);
+        Inc(z.state^.sub.check.need, uLong(z.next_in^) );
+        Inc(z.next_in);
+
+        z.adler := z.state^.sub.check.need;
+        z.state^.mode := DICT0;
+        inflate := Z_NEED_DICT;
+        exit;
+      end;
+    DICT0:
+      begin
+        z.state^.mode := BAD;
+        z.msg := 'need dictionary';
+        z.state^.sub.marker := 0;         { can try inflateSync }
+        inflate := Z_STREAM_ERROR;
+        exit;
+      end;
+    BAD:
+      begin
+        inflate := Z_DATA_ERROR;
+        exit;
+      end;
+    else
+      begin
+        inflate := Z_STREAM_ERROR;
+        exit;
+      end;
+  end;
+{$ifdef NEED_DUMMY_result}
+  result := Z_STREAM_ERROR;  { Some dumb compilers complain without this }
+{$endif}
+end;
+
+function inflateSetDictionary(var z : z_stream;
+                              dictionary : pBytef; {const array of byte}
+                              dictLength : uInt) : int;
+var
+  length : uInt;
+begin
+  length := dictLength;
+
+  if (z.state = Z_NULL) or (z.state^.mode <> DICT0) then
+  begin
+    inflateSetDictionary := Z_STREAM_ERROR;
+    exit;
+  end;
+  if (adler32(Long(1), dictionary, dictLength) <> z.adler) then
+  begin
+    inflateSetDictionary := Z_DATA_ERROR;
+    exit;
+  end;
+  z.adler := Long(1);
+
+  if (length >= (uInt(1) shl z.state^.wbits)) then
+  begin
+    length := (1 shl z.state^.wbits)-1;
+    Inc( dictionary, dictLength - length);
+  end;
+  inflate_set_dictionary(z.state^.blocks^, dictionary^, length);
+  z.state^.mode := BLOCKS;
+  inflateSetDictionary := Z_OK;
+end;
+
+
+function inflateSync(var z : z_stream) : int;
+const
+  mark : packed array[0..3] of byte = (0, 0, $ff, $ff);
+var
+  n : uInt;       { number of bytes to look at }
+  p : pBytef;     { pointer to bytes }
+  m : uInt;       { number of marker bytes found in a row }
+  r, w : uLong;   { temporaries to save total_in and total_out }
+begin
+  { set up }
+  if (z.state = Z_NULL) then
+  begin
+    inflateSync := Z_STREAM_ERROR;
+    exit;
+  end;
+  if (z.state^.mode <> BAD) then
+  begin
+    z.state^.mode := BAD;
+    z.state^.sub.marker := 0;
+  end;
+  n := z.avail_in;
+  if (n = 0) then
+  begin
+    inflateSync := Z_BUF_ERROR;
+    exit;
+  end;
+  p := z.next_in;
+  m := z.state^.sub.marker;
+
+  { search }
+  while (n <> 0) and (m < 4) do
+  begin
+    if (p^ = mark[m]) then
+      Inc(m)
+    else
+      if (p^ <> 0) then
+        m := 0
+      else
+        m := 4 - m;
+    Inc(p);
+    Dec(n);
+  end;
+
+  { restore }
+  Inc(z.total_in, ptr2int(p) - ptr2int(z.next_in));
+  z.next_in := p;
+  z.avail_in := n;
+  z.state^.sub.marker := m;
+
+
+  { return no joy or set up to restart on a new block }
+  if (m <> 4) then
+  begin
+    inflateSync := Z_DATA_ERROR;
+    exit;
+  end;
+  r := z.total_in;
+  w := z.total_out;
+  inflateReset(z);
+  z.total_in := r;
+  z.total_out := w;
+  z.state^.mode := BLOCKS;
+  inflateSync := Z_OK;
+end;
+
+
+{
+  returns true if inflate is currently at the end of a block generated
+  by Z_SYNC_FLUSH or Z_FULL_FLUSH. This function is used by one PPP
+  implementation to provide an additional safety check. PPP uses Z_SYNC_FLUSH
+  but removes the length bytes of the resulting empty stored block. When
+  decompressing, PPP checks that at the end of input packet, inflate is
+  waiting for these length bytes.
+}
+
+function inflateSyncPoint(var z : z_stream) : int;
+begin
+  if (z.state = Z_NULL) or (z.state^.blocks = Z_NULL) then
+  begin
+    inflateSyncPoint := Z_STREAM_ERROR;
+    exit;
+  end;
+  inflateSyncPoint := inflate_blocks_sync_point(z.state^.blocks^);
+end;
+
+end.

+ 92 - 0
packages/base/paszlib/zuncompr.pas

@@ -0,0 +1,92 @@
+Unit zUnCompr;
+
+{ uncompr.c -- decompress a memory buffer
+  Copyright (C) 1995-1998 Jean-loup Gailly.
+
+  Pascal tranlastion
+  Copyright (C) 1998 by Jacques Nomssi Nzali
+  For conditions of distribution and use, see copyright notice in readme.txt
+}
+
+interface
+
+{$I zconf.inc}
+
+uses
+  zutil, zbase, zInflate;
+
+{ ===========================================================================
+     Decompresses the source buffer into the destination buffer.  sourceLen is
+   the byte length of the source buffer. Upon entry, destLen is the total
+   size of the destination buffer, which must be large enough to hold the
+   entire uncompressed data. (The size of the uncompressed data must have
+   been saved previously by the compressor and transmitted to the decompressor
+   by some mechanism outside the scope of this compression library.)
+   Upon exit, destLen is the actual size of the compressed buffer.
+     This function can be used to decompress a whole file at once if the
+   input file is mmap'ed.
+
+     uncompress returns Z_OK if success, Z_MEM_ERROR if there was not
+   enough memory, Z_BUF_ERROR if there was not enough room in the output
+   buffer, or Z_DATA_ERROR if the input data was corrupted.
+}
+
+function uncompress (dest : pBytef;
+                     var destLen : uLong;
+                     source : pBytef;
+                     sourceLen : uLong) : int;
+
+implementation
+
+function uncompress (dest : pBytef;
+                     var destLen : uLong;
+                     source : pBytef;
+                     sourceLen : uLong) : int;
+var
+  stream : z_stream;
+  err : int;
+begin
+  stream.next_in := source;
+  stream.avail_in := uInt(sourceLen);
+  { Check for source > 64K on 16-bit machine: }
+  if (uLong(stream.avail_in) <> sourceLen) then
+  begin
+    uncompress := Z_BUF_ERROR;
+    exit;
+  end;
+
+  stream.next_out := dest;
+  stream.avail_out := uInt(destLen);
+  if (uLong(stream.avail_out) <> destLen) then
+  begin
+    uncompress := Z_BUF_ERROR;
+    exit;
+  end;
+
+  stream.zalloc := NIL;       { alloc_func(0); }
+  stream.zfree := NIL;        { free_func(0); }
+
+  err := inflateInit(stream);
+  if (err <> Z_OK) then
+  begin
+    uncompress := err;
+    exit;
+  end;
+
+  err := inflate(stream, Z_FINISH);
+  if (err <> Z_STREAM_END) then
+  begin
+    inflateEnd(stream);
+    if err = Z_OK then
+      uncompress := Z_BUF_ERROR
+    else
+      uncompress := err;
+    exit;
+  end;
+  destLen := stream.total_out;
+
+  err := inflateEnd(stream);
+  uncompress := err;
+end;
+
+end.

+ 519 - 0
packages/base/paszlib/zutil.pas

@@ -0,0 +1,519 @@
+Unit ZUtil;
+
+{
+  Copyright (C) 1998 by Jacques Nomssi Nzali
+  For conditions of distribution and use, see copyright notice in readme.txt
+}
+
+interface
+
+{$I zconf.inc}
+
+{ Type declarations }
+
+type
+  {Byte   = usigned char;  8 bits}
+  Bytef  = byte;
+  charf  = byte;
+
+{$IFDEF FPC}
+  int    = longint;
+{$ELSE}
+  int    = integer;
+{$ENDIF}
+
+  intf   = int;
+{$IFDEF FPC}
+  uInt = Cardinal;     { 16 bits or more }
+{$ELSE}
+  {$IFDEF MSDOS}
+    uInt   = Word;
+  {$ENDIF}
+{$ENDIF}
+  uIntf  = uInt;
+
+  Long   = longint;
+{$ifdef FPC}
+  uLong  = Cardinal;
+{$else}
+  uLong  = LongInt;      { 32 bits or more }
+{$endif}
+  uLongf = uLong;
+
+  voidp  = pointer;
+  voidpf = voidp;
+  pBytef = ^Bytef;
+  pIntf  = ^intf;
+  puIntf = ^uIntf;
+  puLong = ^uLongf;
+
+  ptr2int = uInt;
+{ a pointer to integer casting is used to do pointer arithmetic.
+  ptr2int must be an integer type and sizeof(ptr2int) must be less
+  than sizeof(pointer) - Nomssi }
+
+type
+  zByteArray = array[0..(MaxInt div SizeOf(Bytef))-1] of Bytef;
+  pzByteArray = ^zByteArray;
+type
+  zIntfArray = array[0..(MaxInt div SizeOf(Intf))-1] of Intf;
+  pzIntfArray = ^zIntfArray;
+type
+  zuIntArray = array[0..(MaxInt div SizeOf(uInt))-1] of uInt;
+  PuIntArray = ^zuIntArray;
+
+{ Type declarations - only for deflate }
+
+type
+  uch  = Byte;
+  uchf = uch; { FAR }
+  ush  = Word;
+  ushf = ush;
+  ulg  = LongInt;
+
+  unsigned = uInt;
+
+  pcharf = ^charf;
+  puchf = ^uchf;
+  pushf = ^ushf;
+
+type
+  zuchfArray = zByteArray;
+  puchfArray = ^zuchfArray;
+type
+  zushfArray = array[0..(MaxInt div SizeOf(ushf))-1] of ushf;
+  pushfArray = ^zushfArray;
+
+procedure zmemcpy(destp : pBytef; sourcep : pBytef; len : uInt);
+function zmemcmp(s1p, s2p : pBytef; len : uInt) : int;
+procedure zmemzero(destp : pBytef; len : uInt);
+procedure zcfree(opaque : voidpf; ptr : voidpf);
+function zcalloc (opaque : voidpf; items : uInt; size : uInt) : voidpf;
+
+implementation
+
+{$ifdef ver80}
+  {$define Delphi16}
+{$endif}
+{$ifdef ver70}
+  {$define HugeMem}
+{$endif}
+{$ifdef ver60}
+  {$define HugeMem}
+{$endif}
+
+{$IFDEF CALLDOS}
+uses
+  WinDos;
+{$ENDIF}
+{$IFDEF Delphi16}
+uses
+  WinTypes,
+  WinProcs;
+{$ENDIF}
+{$IFNDEF FPC}
+  {$IFDEF DPMI}
+  uses
+    WinAPI;
+  {$ENDIF}
+{$ENDIF}
+
+{$IFDEF CALLDOS}
+{ reduce your application memory footprint with $M before using this }
+function dosAlloc (Size : Longint) : Pointer;
+var
+  regs: TRegisters;
+begin
+  regs.bx := (Size + 15) div 16; { number of 16-bytes-paragraphs }
+  regs.ah := $48;                { Allocate memory block }
+  msdos(regs);
+  if regs.Flags and FCarry <> 0 then
+    DosAlloc := NIL
+  else
+    DosAlloc := Ptr(regs.ax, 0);
+end;
+
+
+function dosFree(P : pointer) : boolean;
+var
+  regs: TRegisters;
+begin
+  dosFree := FALSE;
+  regs.bx := Seg(P^);             { segment }
+  if Ofs(P) <> 0 then
+    exit;
+  regs.ah := $49;                { Free memory block }
+  msdos(regs);
+  dosFree := (regs.Flags and FCarry = 0);
+end;
+{$ENDIF}
+
+type
+  LH = record
+    L, H : word;
+  end;
+
+{$IFDEF HugeMem}
+  {$define HEAP_LIST}
+{$endif}
+
+{$IFDEF HEAP_LIST} {--- to avoid Mark and Release --- }
+const
+  MaxAllocEntries = 50;
+type
+  TMemRec = record
+    orgvalue,
+    value : pointer;
+    size: longint;
+  end;
+const
+  allocatedCount : 0..MaxAllocEntries = 0;
+var
+  allocatedList : array[0..MaxAllocEntries-1] of TMemRec;
+
+ function NewAllocation(ptr0, ptr : pointer; memsize : longint) : boolean;
+ begin
+   if (allocatedCount < MaxAllocEntries) and (ptr0 <> NIL) then
+   begin
+     with allocatedList[allocatedCount] do
+     begin
+       orgvalue := ptr0;
+       value := ptr;
+       size := memsize;
+     end;
+     Inc(allocatedCount);  { we don't check for duplicate }
+     NewAllocation := TRUE;
+   end
+   else
+     NewAllocation := FALSE;
+ end;
+{$ENDIF}
+
+{$IFDEF HugeMem}
+
+{ The code below is extremely version specific to the TP 6/7 heap manager!!}
+type
+  PFreeRec = ^TFreeRec;
+  TFreeRec = record
+    next: PFreeRec;
+    size: Pointer;
+  end;
+type
+  HugePtr = voidpf;
+
+
+ procedure IncPtr(var p:pointer;count:word);
+ { Increments pointer }
+ begin
+   inc(LH(p).L,count);
+   if LH(p).L < count then
+     inc(LH(p).H,SelectorInc);  { $1000 }
+ end;
+
+ procedure DecPtr(var p:pointer;count:word);
+ { decrements pointer }
+ begin
+   if count > LH(p).L then
+     dec(LH(p).H,SelectorInc);
+   dec(LH(p).L,Count);
+ end;
+
+ procedure IncPtrLong(var p:pointer;count:longint);
+ { Increments pointer; assumes count > 0 }
+ begin
+   inc(LH(p).H,SelectorInc*LH(count).H);
+   inc(LH(p).L,LH(Count).L);
+   if LH(p).L < LH(count).L then
+     inc(LH(p).H,SelectorInc);
+ end;
+
+ procedure DecPtrLong(var p:pointer;count:longint);
+ { Decrements pointer; assumes count > 0 }
+ begin
+   if LH(count).L > LH(p).L then
+     dec(LH(p).H,SelectorInc);
+   dec(LH(p).L,LH(Count).L);
+   dec(LH(p).H,SelectorInc*LH(Count).H);
+ end;
+ { The next section is for real mode only }
+
+function Normalized(p : pointer)  : pointer;
+var
+  count : word;
+begin
+  count := LH(p).L and $FFF0;
+  Normalized := Ptr(LH(p).H + (count shr 4), LH(p).L and $F);
+end;
+
+procedure FreeHuge(var p:HugePtr; size : longint);
+const
+  blocksize = $FFF0;
+var
+  block : word;
+begin
+  while size > 0 do
+  begin
+    { block := minimum(size, blocksize); }
+    if size > blocksize then
+      block := blocksize
+    else
+      block := size;
+
+    dec(size,block);
+    freemem(p,block);
+    IncPtr(p,block);    { we may get ptr($xxxx, $fff8) and 31 bytes left }
+    p := Normalized(p); { to free, so we must normalize }
+  end;
+end;
+
+function FreeMemHuge(ptr : pointer) : boolean;
+var
+  i : integer; { -1..MaxAllocEntries }
+begin
+  FreeMemHuge := FALSE;
+  i := allocatedCount - 1;
+  while (i >= 0) do
+  begin
+    if (ptr = allocatedList[i].value) then
+    begin
+      with allocatedList[i] do
+        FreeHuge(orgvalue, size);
+
+      Move(allocatedList[i+1], allocatedList[i],
+           SizeOf(TMemRec)*(allocatedCount - 1 - i));
+      Dec(allocatedCount);
+      FreeMemHuge := TRUE;
+      break;
+    end;
+    Dec(i);
+  end;
+end;
+
+procedure GetMemHuge(var p:HugePtr;memsize:Longint);
+const
+  blocksize = $FFF0;
+var
+  size : longint;
+  prev,free : PFreeRec;
+  save,temp : pointer;
+  block : word;
+begin
+  p := NIL;
+  { Handle the easy cases first }
+  if memsize > maxavail then
+    exit
+  else
+    if memsize <= blocksize then
+    begin
+      getmem(p, memsize);
+      if not NewAllocation(p, p, memsize) then
+      begin
+        FreeMem(p, memsize);
+        p := NIL;
+      end;
+    end
+    else
+    begin
+      size := memsize + 15;
+
+      { Find the block that has enough space }
+      prev := PFreeRec(@freeList);
+      free := prev^.next;
+      while (free <> heapptr) and (ptr2int(free^.size) < size) do
+      begin
+        prev := free;
+        free := prev^.next;
+      end;
+
+      { Now free points to a region with enough space; make it the first one and
+        multiple allocations will be contiguous. }
+
+      save := freelist;
+      freelist := free;
+      { In TP 6, this works; check against other heap managers }
+      while size > 0 do
+      begin
+        { block := minimum(size, blocksize); }
+        if size > blocksize then
+          block := blocksize
+        else
+          block := size;
+        dec(size,block);
+        getmem(temp,block);
+      end;
+
+      { We've got what we want now; just sort things out and restore the
+        free list to normal }
+
+      p := free;
+      if prev^.next <> freelist then
+      begin
+        prev^.next := freelist;
+        freelist := save;
+      end;
+
+      if (p <> NIL) then
+      begin
+        { return pointer with 0 offset }
+        temp := p;
+        if Ofs(p^)<>0 Then
+          p := Ptr(Seg(p^)+1,0);  { hack }
+        if not NewAllocation(temp, p, memsize + 15) then
+        begin
+          FreeHuge(temp, size);
+          p := NIL;
+        end;
+      end;
+
+    end;
+end;
+
+{$ENDIF}
+
+procedure zmemcpy(destp : pBytef; sourcep : pBytef; len : uInt);
+begin
+  Move(sourcep^, destp^, len);
+end;
+
+function zmemcmp(s1p, s2p : pBytef; len : uInt) : int;
+var
+  j : uInt;
+  source,
+  dest : pBytef;
+begin
+  source := s1p;
+  dest := s2p;
+  for j := 0 to pred(len) do
+  begin
+    if (source^ <> dest^) then
+    begin
+      zmemcmp := 2*Ord(source^ > dest^)-1;
+      exit;
+    end;
+    Inc(source);
+    Inc(dest);
+  end;
+  zmemcmp := 0;
+end;
+
+procedure zmemzero(destp : pBytef; len : uInt);
+begin
+  FillChar(destp^, len, 0);
+end;
+
+procedure zcfree(opaque : voidpf; ptr : voidpf);
+{$ifdef Delphi16}
+var
+  Handle : THandle;
+{$endif}
+begin
+  {$IFDEF DPMI}
+  {h :=} GlobalFreePtr(ptr);
+  {$ELSE}
+    {$IFDEF CALL_DOS}
+    dosFree(ptr);
+    {$ELSE}
+      {$ifdef HugeMem}
+      FreeMemHuge(ptr);
+      {$else}
+        {$ifdef Delphi16}
+        Handle := GlobalHandle(LH(ptr).H); { HiWord(LongInt(ptr)) }
+        GlobalUnLock(Handle);
+        GlobalFree(Handle);
+        {$else}
+          FreeMem(ptr);  { Delphi 2,3,4 }
+        {$endif}
+      {$endif}
+    {$ENDIF}
+  {$ENDIF}
+end;
+
+function zcalloc (opaque : voidpf; items : uInt; size : uInt) : voidpf;
+var
+  p : voidpf;
+  memsize : LongInt;
+{$ifdef Delphi16}
+  handle : THandle;
+{$endif}
+begin
+  memsize := Long(items) * size;
+  {$IFDEF DPMI}
+  p := GlobalAllocPtr(gmem_moveable, memsize);
+  {$ELSE}
+    {$IFDEF CALLDOS}
+    p := dosAlloc(memsize);
+    {$ELSE}
+      {$ifdef HugeMem}
+      GetMemHuge(p, memsize);
+      {$else}
+        {$ifdef Delphi16}
+        Handle := GlobalAlloc(HeapAllocFlags, memsize);
+        p := GlobalLock(Handle);
+        {$else}
+          GetMem(p, memsize);  { Delphi: p := AllocMem(memsize); }
+        {$endif}
+      {$endif}
+    {$ENDIF}
+  {$ENDIF}
+  zcalloc := p;
+end;
+
+
+end.
+
+
+{ edited from a SWAG posting:
+
+In Turbo Pascal 6, the heap is the memory allocated when using the Procedures 'New' and
+'GetMem'. The heap starts at the address location pointed to by 'Heaporg' and
+grows to higher addresses as more memory is allocated. The top of the heap,
+the first address of allocatable memory space above the allocated memory
+space, is pointed to by 'HeapPtr'.
+
+Memory is deallocated by the Procedures 'Dispose' and 'FreeMem'. As memory
+blocks are deallocated more memory becomes available, but..... When a block
+of memory, which is not the top-most block in the heap is deallocated, a gap
+in the heap will appear. to keep track of these gaps Turbo Pascal maintains
+a so called free list.
+
+The Function 'MaxAvail' holds the size of the largest contiguous free block
+_in_ the heap. The Function 'MemAvail' holds the sum of all free blocks in
+the heap.
+
+TP6.0 keeps track of the free blocks by writing a 'free list Record' to the
+first eight Bytes of the freed memory block! A (TP6.0) free-list Record
+contains two four Byte Pointers of which the first one points to the next
+free memory block, the second Pointer is not a Real Pointer but contains the
+size of the memory block.
+
+Summary
+
+TP6.0 maintains a linked list with block sizes and Pointers to the _next_
+free block. An extra heap Variable 'Heapend' designate the end of the heap.
+When 'HeapPtr' and 'FreeList' have the same value, the free list is empty.
+
+
+                     TP6.0     Heapend
+                ÚÄÄÄÄÄÄÄÄÄ¿ <ÄÄÄÄ
+                ³         ³
+                ³         ³
+                ³         ³
+                ³         ³
+                ³         ³
+                ³         ³
+                ³         ³
+                ³         ³  HeapPtr
+             ÚÄ>ÃÄÄÄÄÄÄÄÄÄ´ <ÄÄÄÄ
+             ³  ³         ³
+             ³  ÃÄÄÄÄÄÄÄÄÄ´
+             ÀÄij  Free   ³
+             ÚÄ>ÃÄÄÄÄÄÄÄÄÄ´
+             ³  ³         ³
+             ³  ÃÄÄÄÄÄÄÄÄÄ´
+             ÀÄij  Free   ³  FreeList
+                ÃÄÄÄÄÄÄÄÄÄ´ <ÄÄÄÄ
+                ³         ³  Heaporg
+                ÃÄÄÄÄÄÄÄÄÄ´ <ÄÄÄÄ
+
+
+}

+ 1254 - 0
packages/base/postgres/Makefile

@@ -0,0 +1,1254 @@
+#
+# Don't edit, this file is generated by FPCMake Version 1.1 [2002/01/29]
+#
+default: all
+MAKEFILETARGETS=linux go32v2 win32 os2 freebsd beos netbsd amiga atari sunos qnx
+override PATH:=$(subst \,/,$(PATH))
+ifeq ($(findstring ;,$(PATH)),)
+inUnix=1
+SEARCHPATH:=$(filter-out .,$(subst :, ,$(PATH)))
+else
+SEARCHPATH:=$(subst ;, ,$(PATH))
+endif
+PWD:=$(strip $(wildcard $(addsuffix /pwd.exe,$(SEARCHPATH))))
+ifeq ($(PWD),)
+PWD:=$(strip $(wildcard $(addsuffix /pwd,$(SEARCHPATH))))
+ifeq ($(PWD),)
+$(error You need the GNU utils package to use this Makefile)
+else
+PWD:=$(firstword $(PWD))
+SRCEXEEXT=
+endif
+else
+PWD:=$(firstword $(PWD))
+SRCEXEEXT=.exe
+endif
+ifndef inUnix
+ifeq ($(OS),Windows_NT)
+inWinNT=1
+else
+ifdef OS2_SHELL
+inOS2=1
+endif
+endif
+else
+ifneq ($(findstring cygwin,$(MACHTYPE)),)
+inCygWin=1
+endif
+endif
+ifeq ($(OS_TARGET),freebsd)
+BSDhier=1
+endif
+ifeq ($(OS_TARGET),netbsd)
+BSDhier=1
+endif
+ifdef inUnix
+BATCHEXT=.sh
+else
+ifdef inOS2
+BATCHEXT=.cmd
+else
+BATCHEXT=.bat
+endif
+endif
+ifdef inUnix
+PATHSEP=/
+else
+PATHSEP:=$(subst /,\,/)
+endif
+ifdef PWD
+BASEDIR:=$(subst \,/,$(shell $(PWD)))
+ifdef inCygWin
+ifneq ($(findstring /cygdrive/,$(BASEDIR)),)
+BASENODIR:=$(patsubst /cygdrive%,%,$(BASEDIR))
+BASEDRIVE:=$(firstword $(subst /, ,$(BASENODIR)))
+BASEDIR:=$(subst /cygdrive/$(BASEDRIVE)/,$(BASEDRIVE):/,$(BASEDIR))
+endif
+endif
+else
+BASEDIR=.
+endif
+override DEFAULT_FPCDIR=../../..
+ifndef FPC
+ifdef PP
+FPC=$(PP)
+endif
+endif
+ifndef FPC
+FPCPROG:=$(strip $(wildcard $(addsuffix /fpc$(SRCEXEEXT),$(SEARCHPATH))))
+ifneq ($(FPCPROG),)
+FPCPROG:=$(firstword $(FPCPROG))
+FPC:=$(shell $(FPCPROG) -PB)
+ifneq ($(findstring Error,$(FPC)),)
+override FPC=ppc386
+endif
+else
+override FPC=ppc386
+endif
+endif
+override FPC:=$(subst $(SRCEXEEXT),,$(FPC))
+override FPC:=$(subst \,/,$(FPC))$(SRCEXEEXT)
+ifndef FPC_VERSION
+FPC_VERSION:=$(shell $(FPC) -iV)
+endif
+export FPC FPC_VERSION
+ifeq ($(findstring 1.0.,$(FPC_VERSION)),)
+COMPILERINFO:=$(shell $(FPC) -iSP -iTP -iSO -iTO)
+ifndef CPU_SOURCE
+CPU_SOURCE:=$(word 1,$(COMPILERINFO))
+endif
+ifndef CPU_TARGET
+CPU_TARGET:=$(word 2,$(COMPILERINFO))
+endif
+ifndef OS_SOURCE
+OS_SOURCE:=$(word 3,$(COMPILERINFO))
+endif
+ifndef OS_TARGET
+OS_TARGET:=$(word 4,$(COMPILERINFO))
+endif
+else
+ifndef CPU_SOURCE
+CPU_SOURCE:=$(shell $(FPC) -iSP)
+endif
+ifndef CPU_TARGET
+CPU_TARGET:=$(shell $(FPC) -iTP)
+endif
+ifndef OS_SOURCE
+OS_SOURCE:=$(shell $(FPC) -iSO)
+endif
+ifndef OS_TARGET
+OS_TARGET:=$(shell $(FPC) -iTO)
+endif
+endif
+FULL_TARGET=$(CPU_TARGET)-$(OS_TARGET)
+FULL_SOURCE=$(CPU_SOURCE)-$(OS_SOURCE)
+ifneq ($(FULL_TARGET),$(FULL_SOURCE))
+CROSSCOMPILE=1
+endif
+ifeq ($(findstring makefile,$(MAKECMDGOALS)),)
+ifeq ($(findstring $(OS_TARGET),$(MAKEFILETARGETS)),)
+$(error The Makefile doesn't support target $(OS_TARGET), please run fpcmake first)
+endif
+endif
+export OS_TARGET OS_SOURCE CPU_TARGET CPU_SOURCE FULL_TARGET FULL_SOURCE CROSSCOMPILE
+ifdef FPCDIR
+override FPCDIR:=$(subst \,/,$(FPCDIR))
+ifeq ($(wildcard $(addprefix $(FPCDIR)/,rtl units)),)
+override FPCDIR=wrong
+endif
+else
+override FPCDIR=wrong
+endif
+ifdef DEFAULT_FPCDIR
+ifeq ($(FPCDIR),wrong)
+override FPCDIR:=$(subst \,/,$(DEFAULT_FPCDIR))
+ifeq ($(wildcard $(addprefix $(FPCDIR)/,rtl units)),)
+override FPCDIR=wrong
+endif
+endif
+endif
+ifeq ($(FPCDIR),wrong)
+ifdef inUnix
+override FPCDIR=/usr/local/lib/fpc/$(FPC_VERSION)
+ifeq ($(wildcard $(FPCDIR)/units),)
+override FPCDIR=/usr/lib/fpc/$(FPC_VERSION)
+endif
+else
+override FPCDIR:=$(subst /$(FPC),,$(firstword $(strip $(wildcard $(addsuffix /$(FPC),$(SEARCHPATH))))))
+override FPCDIR:=$(FPCDIR)/..
+ifeq ($(wildcard $(addprefix $(FPCDIR)/,rtl units)),)
+override FPCDIR:=$(FPCDIR)/..
+ifeq ($(wildcard $(addprefix $(FPCDIR)/,rtl units)),)
+override FPCDIR=c:/pp
+endif
+endif
+endif
+endif
+ifndef CROSSDIR
+CROSSDIR:=$(FPCDIR)/cross/$(FULL_TARGET)
+endif
+ifndef CROSSTARGETDIR
+CROSSTARGETDIR=$(CROSSDIR)/$(FULL_TARGET)
+endif
+ifdef CROSSCOMPILE
+UNITSDIR:=$(wildcard $(CROSSTARGETDIR)/units)
+ifeq ($(UNITSDIR),)
+UNITSDIR:=$(wildcard $(FPCDIR)/units/$(OS_TARGET))
+endif
+else
+UNITSDIR:=$(wildcard $(FPCDIR)/units/$(OS_TARGET))
+endif
+PACKAGESDIR:=$(wildcard $(FPCDIR) $(FPCDIR)/packages/base $(FPCDIR)/packages/extra)
+override PACKAGE_NAME=postgres
+override PACKAGE_VERSION=1.0.6
+override TARGET_UNITS+=dllist postgres
+override TARGET_EXAMPLES+=testpg1 testpg2
+override INSTALL_FPCPACKAGE=y
+ifdef REQUIRE_UNITSDIR
+override UNITSDIR+=$(REQUIRE_UNITSDIR)
+endif
+ifdef REQUIRE_PACKAGESDIR
+override PACKAGESDIR+=$(REQUIRE_PACKAGESDIR)
+endif
+ifdef ZIPINSTALL
+ifeq ($(OS_TARGET),linux)
+UNIXINSTALLDIR=1
+endif
+ifeq ($(OS_TARGET),freebsd)
+UNIXINSTALLDIR=1
+endif
+ifeq ($(OS_TARGET),netbsd)
+UNIXINSTALLDIR=1
+endif
+ifeq ($(OS_TARGET),sunos)
+UNIXINSTALLDIR=1
+endif
+else
+ifeq ($(OS_SOURCE),linux)
+UNIXINSTALLDIR=1
+endif
+ifeq ($(OS_SOURCE),freebsd)
+UNIXINSTALLDIR=1
+endif
+ifeq ($(OS_SOURCE),netbsd)
+UNIXINSTALLDIR=1
+endif
+ifeq ($(OS_TARGET),sunos)
+UNIXINSTALLDIR=1
+endif
+endif
+ifndef INSTALL_PREFIX
+ifdef PREFIX
+INSTALL_PREFIX=$(PREFIX)
+endif
+endif
+ifndef INSTALL_PREFIX
+ifdef UNIXINSTALLDIR
+INSTALL_PREFIX=/usr/local
+else
+ifdef INSTALL_FPCPACKAGE
+INSTALL_BASEDIR:=/pp
+else
+INSTALL_BASEDIR:=/$(PACKAGE_NAME)
+endif
+endif
+endif
+export INSTALL_PREFIX
+ifndef DIST_DESTDIR
+DIST_DESTDIR:=$(BASEDIR)
+endif
+export DIST_DESTDIR
+ifndef INSTALL_BASEDIR
+ifdef UNIXINSTALLDIR
+ifdef INSTALL_FPCPACKAGE
+INSTALL_BASEDIR:=$(INSTALL_PREFIX)/lib/fpc/$(FPC_VERSION)
+else
+INSTALL_BASEDIR:=$(INSTALL_PREFIX)/lib/$(PACKAGE_NAME)
+endif
+else
+INSTALL_BASEDIR:=$(INSTALL_PREFIX)
+endif
+endif
+ifndef INSTALL_BINDIR
+ifdef UNIXINSTALLDIR
+INSTALL_BINDIR:=$(INSTALL_PREFIX)/bin
+else
+INSTALL_BINDIR:=$(INSTALL_BASEDIR)/bin
+ifdef INSTALL_FPCPACKAGE
+INSTALL_BINDIR:=$(INSTALL_BINDIR)/$(OS_TARGET)
+endif
+endif
+endif
+ifndef INSTALL_UNITDIR
+ifdef CROSSCOMPILE
+INSTALL_UNITDIR:=$(INSTALL_BASEDIR)/cross/$(FULL_TARGET)/units
+else
+INSTALL_UNITDIR:=$(INSTALL_BASEDIR)/units/$(OS_TARGET)
+endif
+ifdef INSTALL_FPCPACKAGE
+ifdef PACKAGE_NAME
+INSTALL_UNITDIR:=$(INSTALL_UNITDIR)/$(PACKAGE_NAME)
+endif
+endif
+endif
+ifndef INSTALL_LIBDIR
+ifdef UNIXINSTALLDIR
+INSTALL_LIBDIR:=$(INSTALL_PREFIX)/lib
+else
+INSTALL_LIBDIR:=$(INSTALL_UNITDIR)
+endif
+endif
+ifndef INSTALL_SOURCEDIR
+ifdef UNIXINSTALLDIR
+ifdef INSTALL_FPCPACKAGE
+ifdef BSDhier
+INSTALL_SOURCEDIR:=$(INSTALL_PREFIX)/share/src/fpc-$(FPC_VERSION)/$(PACKAGE_NAME)
+else
+INSTALL_SOURCEDIR:=$(INSTALL_PREFIX)/src/fpc-$(FPC_VERSION)/$(PACKAGE_NAME)
+endif
+else
+ifdef BSDhier
+INSTALL_SOURCEDIR:=$(INSTALL_PREFIX)/share/src/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
+else
+INSTALL_SOURCEDIR:=$(INSTALL_PREFIX)/src/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
+endif
+endif
+else
+ifdef INSTALL_FPCPACKAGE
+INSTALL_SOURCEDIR:=$(INSTALL_BASEDIR)/source/$(PACKAGE_NAME)
+else
+INSTALL_SOURCEDIRL:=$(INSTALL_BASEDIR)/source
+endif
+endif
+endif
+ifndef INSTALL_DOCDIR
+ifdef UNIXINSTALLDIR
+ifdef INSTALL_FPCPACKAGE
+ifdef BSDhier
+INSTALL_DOCDIR:=$(INSTALL_PREFIX)/share/doc/fpc-$(FPC_VERSION)/$(PACKAGE_NAME)
+else
+INSTALL_DOCDIR:=$(INSTALL_PREFIX)/doc/fpc-$(FPC_VERSION)/$(PACKAGE_NAME)
+endif
+else
+ifdef BSDhier
+INSTALL_DOCDIR:=$(INSTALL_PREFIX)/share/doc/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
+else
+INSTALL_DOCDIR:=$(INSTALL_PREFIX)/doc/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
+endif
+endif
+else
+ifdef INSTALL_FPCPACKAGE
+INSTALL_DOCDIR:=$(INSTALL_BASEDIR)/doc/$(PACKAGE_NAME)
+else
+INSTALL_DOCDIR:=$(INSTALL_BASEDIR)/doc
+endif
+endif
+endif
+ifndef INSTALL_EXAMPLEDIR
+ifdef UNIXINSTALLDIR
+ifdef INSTALL_FPCPACKAGE
+ifdef BSDhier
+INSTALL_EXAMPLEDIR:=$(INSTALL_PREFIX)/share/examples/fpc-$(FPC_VERSION)/$(PACKAGE_NAME)
+else
+INSTALL_EXAMPLEDIR:=$(INSTALL_PREFIX)/doc/fpc-$(FPC_VERSION)/examples/$(PACKAGE_NAME)
+endif
+else
+ifdef BSDhier
+INSTALL_EXAMPLEDIR:=$(INSTALL_PREFIX)/share/examples/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
+else
+INSTALL_EXAMPLEDIR:=$(INSTALL_PREFIX)/doc/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
+endif
+endif
+else
+ifdef INSTALL_FPCPACKAGE
+INSTALL_EXAMPLEDIR:=$(INSTALL_BASEDIR)/examples/$(PACKAGE_NAME)
+else
+INSTALL_EXAMPLEDIR:=$(INSTALL_BASEDIR)/examples
+endif
+endif
+endif
+ifndef INSTALL_DATADIR
+INSTALL_DATADIR=$(INSTALL_BASEDIR)
+endif
+ifdef CROSSCOMPILE
+ifndef CROSSBINDIR
+CROSSBINDIR:=$(wildcard $(CROSSTARGETDIR)/bin/$(FULL_SOURCE))
+ifeq ($(CROSSBINDIR),)
+CROSSBINDIR:=$(wildcard $(INSTALL_BASEDIR)/cross/$(FULL_TARGET)/bin/$(FULL_SOURCE))
+endif
+endif
+else
+CROSSBINDIR=
+endif
+ifdef inUnix
+ifndef GCCLIBDIR
+GCCLIBDIR:=$(shell dirname `(gcc -v 2>&1)| head -n 1| awk '{ print $$4 } '`)
+endif
+ifeq ($(OS_TARGET),linux)
+ifndef OTHERLIBDIR
+OTHERLIBDIR:=$(shell grep -v "^\#" /etc/ld.so.conf | awk '{ ORS=" "; print $1 }')
+endif
+endif
+ifeq ($(OS_TARGET),netbsd)
+OTHERLIBDIR+=/usr/pkg/lib
+endif
+export GCCLIBDIR OTHERLIB
+endif
+LOADEREXT=.as
+EXEEXT=.exe
+PPLEXT=.ppl
+PPUEXT=.ppu
+OEXT=.o
+ASMEXT=.s
+SMARTEXT=.sl
+STATICLIBEXT=.a
+SHAREDLIBEXT=.so
+STATICLIBPREFIX=libp
+RSTEXT=.rst
+FPCMADE=fpcmade
+ifeq ($(OS_TARGET),go32v1)
+PPUEXT=.pp1
+OEXT=.o1
+ASMEXT=.s1
+SMARTEXT=.sl1
+STATICLIBEXT=.a1
+SHAREDLIBEXT=.so1
+STATICLIBPREFIX=
+FPCMADE=fpcmade.v1
+PACKAGESUFFIX=v1
+endif
+ifeq ($(OS_TARGET),go32v2)
+STATICLIBPREFIX=
+FPCMADE=fpcmade.dos
+ZIPSUFFIX=go32
+endif
+ifeq ($(OS_TARGET),linux)
+EXEEXT=
+HASSHAREDLIB=1
+FPCMADE=fpcmade.lnx
+ZIPSUFFIX=linux
+endif
+ifeq ($(OS_TARGET),freebsd)
+EXEEXT=
+HASSHAREDLIB=1
+FPCMADE=fpcmade.freebsd
+ZIPSUFFIX=freebsd
+endif
+ifeq ($(OS_TARGET),netbsd)
+EXEEXT=
+HASSHAREDLIB=1
+FPCMADE=fpcmade.netbsd
+ZIPSUFFIX=netbsd
+endif
+ifeq ($(OS_TARGET),win32)
+PPUEXT=.ppw
+OEXT=.ow
+ASMEXT=.sw
+SMARTEXT=.slw
+STATICLIBEXT=.aw
+SHAREDLIBEXT=.dll
+FPCMADE=fpcmade.w32
+ZIPSUFFIX=w32
+endif
+ifeq ($(OS_TARGET),os2)
+PPUEXT=.ppo
+ASMEXT=.so2
+OEXT=.oo2
+AOUTEXT=.out
+SMARTEXT=.so
+STATICLIBEXT=.ao2
+SHAREDLIBEXT=.dll
+FPCMADE=fpcmade.os2
+ZIPSUFFIX=emx
+endif
+ifeq ($(OS_TARGET),amiga)
+EXEEXT=
+PPUEXT=.ppa
+ASMEXT=.asm
+OEXT=.o
+SMARTEXT=.sl
+STATICLIBEXT=.a
+SHAREDLIBEXT=.library
+FPCMADE=fpcmade.amg
+endif
+ifeq ($(OS_TARGET),atari)
+PPUEXT=.ppt
+ASMEXT=.s
+OEXT=.o
+SMARTEXT=.sl
+STATICLIBEXT=.a
+EXEEXT=.ttp
+FPCMADE=fpcmade.ata
+endif
+ifeq ($(OS_TARGET),beos)
+PPUEXT=.ppu
+ASMEXT=.s
+OEXT=.o
+SMARTEXT=.sl
+STATICLIBEXT=.a
+EXEEXT=
+FPCMADE=fpcmade.be
+ZIPSUFFIX=be
+endif
+ifeq ($(OS_TARGET),sunos)
+PPUEXT=.ppu
+ASMEXT=.s
+OEXT=.o
+SMARTEXT=.sl
+STATICLIBEXT=.a
+EXEEXT=
+FPCMADE=fpcmade.sun
+ZIPSUFFIX=sun
+endif
+ifeq ($(OS_TARGET),qnx)
+PPUEXT=.ppu
+ASMEXT=.s
+OEXT=.o
+SMARTEXT=.sl
+STATICLIBEXT=.a
+EXEEXT=
+FPCMADE=fpcmade.qnx
+ZIPSUFFIX=qnx
+endif
+ifndef ECHO
+ECHO:=$(strip $(wildcard $(addsuffix /gecho$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(ECHO),)
+ECHO:=$(strip $(wildcard $(addsuffix /echo$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(ECHO),)
+ECHO=
+else
+ECHO:=$(firstword $(ECHO))
+endif
+else
+ECHO:=$(firstword $(ECHO))
+endif
+endif
+export ECHO
+ifndef DATE
+DATE:=$(strip $(wildcard $(addsuffix /gdate$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(DATE),)
+DATE:=$(strip $(wildcard $(addsuffix /date$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(DATE),)
+DATE=
+else
+DATE:=$(firstword $(DATE))
+endif
+else
+DATE:=$(firstword $(DATE))
+endif
+endif
+export DATE
+ifndef GINSTALL
+GINSTALL:=$(strip $(wildcard $(addsuffix /ginstall$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(GINSTALL),)
+GINSTALL:=$(strip $(wildcard $(addsuffix /install$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(GINSTALL),)
+GINSTALL=
+else
+GINSTALL:=$(firstword $(GINSTALL))
+endif
+else
+GINSTALL:=$(firstword $(GINSTALL))
+endif
+endif
+export GINSTALL
+ifndef CPPROG
+CPPROG:=$(strip $(wildcard $(addsuffix /cp$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(CPPROG),)
+CPPROG=
+else
+CPPROG:=$(firstword $(CPPROG))
+endif
+endif
+export CPPROG
+ifndef RMPROG
+RMPROG:=$(strip $(wildcard $(addsuffix /rm$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(RMPROG),)
+RMPROG=
+else
+RMPROG:=$(firstword $(RMPROG))
+endif
+endif
+export RMPROG
+ifndef MVPROG
+MVPROG:=$(strip $(wildcard $(addsuffix /mv$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(MVPROG),)
+MVPROG=
+else
+MVPROG:=$(firstword $(MVPROG))
+endif
+endif
+export MVPROG
+ifndef ECHOREDIR
+ECHOREDIR:=$(subst /,$(PATHSEP),$(ECHO))
+endif
+ifndef COPY
+COPY:=$(CPPROG) -fp
+endif
+ifndef COPYTREE
+COPYTREE:=$(CPPROG) -rfp
+endif
+ifndef MOVE
+MOVE:=$(MVPROG) -f
+endif
+ifndef DEL
+DEL:=$(RMPROG) -f
+endif
+ifndef DELTREE
+DELTREE:=$(RMPROG) -rf
+endif
+ifndef INSTALL
+ifdef inUnix
+INSTALL:=$(GINSTALL) -c -m 644
+else
+INSTALL:=$(COPY)
+endif
+endif
+ifndef INSTALLEXE
+ifdef inUnix
+INSTALLEXE:=$(GINSTALL) -c -m 755
+else
+INSTALLEXE:=$(COPY)
+endif
+endif
+ifndef MKDIR
+MKDIR:=$(GINSTALL) -m 755 -d
+endif
+export ECHOREDIR COPY COPYTREE MOVE DEL DELTREE INSTALL INSTALLEXE MKDIR
+ifndef PPUMOVE
+PPUMOVE:=$(strip $(wildcard $(addsuffix /ppumove$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(PPUMOVE),)
+PPUMOVE=
+else
+PPUMOVE:=$(firstword $(PPUMOVE))
+endif
+endif
+export PPUMOVE
+ifndef FPCMAKE
+FPCMAKE:=$(strip $(wildcard $(addsuffix /fpcmake$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(FPCMAKE),)
+FPCMAKE=
+else
+FPCMAKE:=$(firstword $(FPCMAKE))
+endif
+endif
+export FPCMAKE
+ifndef ZIPPROG
+ZIPPROG:=$(strip $(wildcard $(addsuffix /zip$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(ZIPPROG),)
+ZIPPROG=
+else
+ZIPPROG:=$(firstword $(ZIPPROG))
+endif
+endif
+export ZIPPROG
+ifndef TARPROG
+TARPROG:=$(strip $(wildcard $(addsuffix /tar$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(TARPROG),)
+TARPROG=
+else
+TARPROG:=$(firstword $(TARPROG))
+endif
+endif
+export TARPROG
+ASNAME=as
+LDNAME=ld
+ARNAME=ar
+RCNAME=rc
+ifeq ($(OS_TARGET),win32)
+ASNAME=asw
+LDNAME=ldw
+ARNAME=arw
+endif
+ifndef ASPROG
+ifdef CROSSBINDIR
+ASPROG=$(CROSSBINDIR)/$(ASNAME)$(SRCEXEEXT)
+else
+ASPROG=$(ASNAME)
+endif
+endif
+ifndef LDPROG
+ifdef CROSSBINDIR
+LDPROG=$(CROSSBINDIR)/$(LDNAME)$(SRCEXEEXT)
+else
+LDPROG=$(LDNAME)
+endif
+endif
+ifndef RCPROG
+ifdef CROSSBINDIR
+RCPROG=$(CROSSBINDIR)/$(RCNAME)$(SRCEXEEXT)
+else
+RCPROG=$(RCNAME)
+endif
+endif
+ifndef ARPROG
+ifdef CROSSBINDIR
+ARPROG=$(CROSSBINDIR)/$(ARNAME)$(SRCEXEEXT)
+else
+ARPROG=$(ARNAME)
+endif
+endif
+AS=$(ASPROG)
+LD=$(LDPROG)
+RC=$(RCPROG)
+AR=$(ARPROG)
+PPAS=ppas$(BATCHEXT)
+ifdef inUnix
+LDCONFIG=ldconfig
+else
+LDCONFIG=
+endif
+ifdef DATE
+DATESTR:=$(shell $(DATE) +%Y%m%d)
+else
+DATESTR=
+endif
+ifndef UPXPROG
+ifeq ($(OS_TARGET),go32v2)
+UPXPROG:=1
+endif
+ifeq ($(OS_TARGET),win32)
+UPXPROG:=1
+endif
+ifdef UPXPROG
+UPXPROG:=$(strip $(wildcard $(addsuffix /upx$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(UPXPROG),)
+UPXPROG=
+else
+UPXPROG:=$(firstword $(UPXPROG))
+endif
+else
+UPXPROG=
+endif
+endif
+export UPXPROG
+ZIPOPT=-9
+ZIPEXT=.zip
+ifeq ($(USETAR),bz2)
+TAROPT=vI
+TAREXT=.tar.bz2
+else
+TAROPT=vz
+TAREXT=.tar.gz
+endif
+override REQUIRE_PACKAGES=rtl 
+ifeq ($(OS_TARGET),linux)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(OS_TARGET),go32v2)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(OS_TARGET),win32)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(OS_TARGET),os2)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(OS_TARGET),freebsd)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(OS_TARGET),beos)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(OS_TARGET),netbsd)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(OS_TARGET),amiga)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(OS_TARGET),atari)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(OS_TARGET),sunos)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(OS_TARGET),qnx)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifdef REQUIRE_PACKAGES_RTL
+PACKAGEDIR_RTL:=$(firstword $(subst /Makefile.fpc,,$(strip $(wildcard $(addsuffix /rtl/$(OS_TARGET)/Makefile.fpc,$(PACKAGESDIR))))))
+ifneq ($(PACKAGEDIR_RTL),)
+ifneq ($(wildcard $(PACKAGEDIR_RTL)/$(OS_TARGET)),)
+UNITDIR_RTL=$(PACKAGEDIR_RTL)/$(OS_TARGET)
+else
+UNITDIR_RTL=$(PACKAGEDIR_RTL)
+endif
+else
+PACKAGEDIR_RTL=
+UNITDIR_RTL:=$(subst /Package.fpc,,$(strip $(wildcard $(addsuffix /rtl/Package.fpc,$(UNITSDIR)))))
+ifneq ($(UNITDIR_RTL),)
+UNITDIR_RTL:=$(firstword $(UNITDIR_RTL))
+else
+UNITDIR_RTL=
+endif
+endif
+ifdef UNITDIR_RTL
+override COMPILER_UNITDIR+=$(UNITDIR_RTL)
+endif
+endif
+ifndef NOCPUDEF
+override FPCOPTDEF=$(CPU_TARGET)
+endif
+ifneq ($(OS_TARGET),$(OS_SOURCE))
+override FPCOPT+=-T$(OS_TARGET)
+endif
+ifdef UNITDIR
+override FPCOPT+=$(addprefix -Fu,$(UNITDIR))
+endif
+ifdef LIBDIR
+override FPCOPT+=$(addprefix -Fl,$(LIBDIR))
+endif
+ifdef OBJDIR
+override FPCOPT+=$(addprefix -Fo,$(OBJDIR))
+endif
+ifdef INCDIR
+override FPCOPT+=$(addprefix -Fi,$(INCDIR))
+endif
+ifdef LINKSMART
+override FPCOPT+=-XX
+endif
+ifdef CREATESMART
+override FPCOPT+=-CX
+endif
+ifdef DEBUG
+override FPCOPT+=-gl
+override FPCOPTDEF+=DEBUG
+endif
+ifdef RELEASE
+ifeq ($(CPU_TARGET),i386)
+FPCCPUOPT:=-OG2p3
+else
+FPCCPUOPT:=
+endif
+override FPCOPT+=-Xs $(FPCCPUOPT) -n
+override FPCOPTDEF+=RELEASE
+endif
+ifdef STRIP
+override FPCOPT+=-Xs
+endif
+ifdef OPTIMIZE
+ifeq ($(CPU_TARGET),i386)
+override FPCOPT+=-OG2p3
+endif
+endif
+ifdef VERBOSE
+override FPCOPT+=-vwni
+endif
+ifdef COMPILER_OPTIONS
+override FPCOPT+=$(COMPILER_OPTIONS)
+endif
+ifdef COMPILER_UNITDIR
+override FPCOPT+=$(addprefix -Fu,$(COMPILER_UNITDIR))
+endif
+ifdef COMPILER_LIBRARYDIR
+override FPCOPT+=$(addprefix -Fl,$(COMPILER_LIBRARYDIR))
+endif
+ifdef COMPILER_OBJECTDIR
+override FPCOPT+=$(addprefix -Fo,$(COMPILER_OBJECTDIR))
+endif
+ifdef COMPILER_INCLUDEDIR
+override FPCOPT+=$(addprefix -Fi,$(COMPILER_INCLUDEDIR))
+endif
+ifdef CROSSBINDIR
+override FPCOPT+=-FD$(CROSSBINDIR)
+endif
+ifdef COMPILER_TARGETDIR
+override FPCOPT+=-FE$(COMPILER_TARGETDIR)
+ifeq ($(COMPILER_TARGETDIR),.)
+override TARGETDIRPREFIX=
+else
+override TARGETDIRPREFIX=$(COMPILER_TARGETDIR)/
+endif
+endif
+ifdef COMPILER_UNITTARGETDIR
+override FPCOPT+=-FU$(COMPILER_UNITTARGETDIR)
+ifeq ($(COMPILER_UNITTARGETDIR),.)
+override UNITTARGETDIRPREFIX=
+else
+override UNITTARGETDIRPREFIX=$(COMPILER_UNITTARGETDIR)/
+endif
+else
+ifdef COMPILER_TARGETDIR
+override COMPILER_UNITTARGETDIR=$(COMPILER_TARGETDIR)
+override UNITTARGETDIRPREFIX=$(TARGETDIRPREFIX)
+endif
+endif
+ifdef GCCLIBDIR
+override FPCOPT+=-Fl$(GCCLIBDIR)
+endif
+ifdef OTHERLIBDIR
+override FPCOPT+=$(addprefix -Fl,$(OTHERLIBDIR))
+endif
+ifdef OPT
+override FPCOPT+=$(OPT)
+endif
+ifdef FPCOPTDEF
+override FPCOPT+=$(addprefix -d,$(FPCOPTDEF))
+endif
+ifdef CFGFILE
+override FPCOPT+=@$(CFGFILE)
+endif
+ifdef USEENV
+override FPCEXTCMD:=$(FPCOPT)
+override FPCOPT:=!FPCEXTCMD
+export FPCEXTCMD
+endif
+override COMPILER:=$(FPC) $(FPCOPT)
+ifeq (,$(findstring -s ,$(COMPILER)))
+EXECPPAS=
+else
+ifeq ($(OS_SOURCE),$(OS_TARGET))
+EXECPPAS:=@$(PPAS)
+endif
+endif
+.PHONY: fpc_units
+ifdef TARGET_UNITS
+override ALLTARGET+=fpc_units
+override UNITPPUFILES=$(addsuffix $(PPUEXT),$(TARGET_UNITS))
+override IMPLICITUNITPPUFILES=$(addsuffix $(PPUEXT),$(TARGET_IMPLICITUNITS))
+override INSTALLPPUFILES+=$(UNITPPUFILES) $(IMPLICITUNITPPUFILES)
+override CLEANPPUFILES+=$(UNITPPUFILES) $(IMPLICITUNITPPUFILES)
+endif
+fpc_units: $(UNITPPUFILES)
+ifdef TARGET_RSTS
+override RSTFILES=$(addsuffix $(RSTEXT),$(TARGET_RSTS))
+override CLEANRSTFILES+=$(RSTFILES)
+endif
+.PHONY: fpc_examples
+ifdef TARGET_EXAMPLES
+HASEXAMPLES=1
+override EXAMPLESOURCEFILES:=$(wildcard $(addsuffix .pp,$(TARGET_EXAMPLES)) $(addsuffix .pas,$(TARGET_EXAMPLES)))
+override EXAMPLEFILES:=$(addsuffix $(EXEEXT),$(TARGET_EXAMPLES))
+override EXAMPLEOFILES:=$(addsuffix $(OEXT),$(TARGET_EXAMPLES)) $(addprefix $(STATICLIBPREFIX),$(addsuffix $(STATICLIBEXT),$(TARGET_EXAMPLES)))
+override CLEANEXEFILES+=$(EXAMPLEFILES) $(EXAMPLEOFILES)
+ifeq ($(OS_TARGET),os2)
+override CLEANEXEFILES+=$(addsuffix $(AOUTEXT),$(TARGET_EXAMPLES))
+endif
+endif
+ifdef TARGET_EXAMPLEDIRS
+HASEXAMPLES=1
+endif
+fpc_examples: all $(EXAMPLEFILES) $(addsuffix _all,$(TARGET_EXAMPLEDIRS))
+.PHONY: fpc_all fpc_smart fpc_debug fpc_release
+$(FPCMADE): $(ALLTARGET)
+	@$(ECHOREDIR) Compiled > $(FPCMADE)
+fpc_all: $(FPCMADE)
+fpc_smart:
+	$(MAKE) all LINKSMART=1 CREATESMART=1
+fpc_debug:
+	$(MAKE) all DEBUG=1
+fpc_release:
+	$(MAKE) all RELEASE=1
+.SUFFIXES: $(EXEEXT) $(PPUEXT) $(OEXT) .pas .pp .rc .res
+%$(PPUEXT): %.pp
+	$(COMPILER) $<
+	$(EXECPPAS)
+%$(PPUEXT): %.pas
+	$(COMPILER) $<
+	$(EXECPPAS)
+%$(EXEEXT): %.pp
+	$(COMPILER) $<
+	$(EXECPPAS)
+%$(EXEEXT): %.pas
+	$(COMPILER) $<
+	$(EXECPPAS)
+%.res: %.rc
+	windres -i $< -o $@
+vpath %.pp $(COMPILER_SOURCEDIR) $(COMPILER_INCLUDEDIR)
+vpath %.pas $(COMPILER_SOURCEDIR) $(COMPILER_INCLUDEDIR)
+vpath %$(PPUEXT) $(COMPILER_UNITTARGETDIR)
+.PHONY: fpc_install fpc_sourceinstall fpc_exampleinstall
+ifdef INSTALL_UNITS
+override INSTALLPPUFILES+=$(addsuffix $(PPUEXT),$(INSTALL_UNITS))
+endif
+ifdef INSTALL_BUILDUNIT
+override INSTALLPPUFILES:=$(filter-out $(INSTALL_BUILDUNIT),$(INSTALLPPUFILES))
+endif
+ifdef INSTALLPPUFILES
+override INSTALLPPULINKFILES:=$(subst $(PPUEXT),$(OEXT),$(INSTALLPPUFILES)) $(addprefix $(STATICLIBPREFIX),$(subst $(PPUEXT),$(STATICLIBEXT),$(INSTALLPPUFILES)))
+override INSTALLPPUFILES:=$(addprefix $(UNITTARGETDIRPREFIX),$(INSTALLPPUFILES))
+override INSTALLPPULINKFILES:=$(wildcard $(addprefix $(UNITTARGETDIRPREFIX),$(INSTALLPPULINKFILES)))
+override INSTALL_CREATEPACKAGEFPC=1
+endif
+ifdef INSTALLEXEFILES
+override INSTALLEXEFILES:=$(addprefix $(TARGETDIRPREFIX),$(INSTALLEXEFILES))
+endif
+fpc_install: all $(INSTALLTARGET)
+ifdef INSTALLEXEFILES
+	$(MKDIR) $(INSTALL_BINDIR)
+ifdef UPXPROG
+	-$(UPXPROG) $(INSTALLEXEFILES)
+endif
+	$(INSTALLEXE) $(INSTALLEXEFILES) $(INSTALL_BINDIR)
+endif
+ifdef INSTALL_CREATEPACKAGEFPC
+ifdef FPCMAKE
+ifdef PACKAGE_VERSION
+ifneq ($(wildcard Makefile.fpc),)
+	$(FPCMAKE) -p -T$(OS_TARGET) Makefile.fpc
+	$(MKDIR) $(INSTALL_UNITDIR)
+	$(INSTALL) Package.fpc $(INSTALL_UNITDIR)
+endif
+endif
+endif
+endif
+ifdef INSTALLPPUFILES
+	$(MKDIR) $(INSTALL_UNITDIR)
+	$(INSTALL) $(INSTALLPPUFILES) $(INSTALL_UNITDIR)
+ifneq ($(INSTALLPPULINKFILES),)
+	$(INSTALL) $(INSTALLPPULINKFILES) $(INSTALL_UNITDIR)
+endif
+ifneq ($(wildcard $(LIB_FULLNAME)),)
+	$(MKDIR) $(INSTALL_LIBDIR)
+	$(INSTALL) $(LIB_FULLNAME) $(INSTALL_LIBDIR)
+ifdef inUnix
+	ln -sf $(LIB_FULLNAME) $(INSTALL_LIBDIR)/$(LIB_NAME)
+endif
+endif
+endif
+ifdef INSTALL_FILES
+	$(MKDIR) $(INSTALL_DATADIR)
+	$(INSTALL) $(INSTALL_FILES) $(INSTALL_DATADIR)
+endif
+fpc_sourceinstall: distclean
+	$(MKDIR) $(INSTALL_SOURCEDIR)
+	$(COPYTREE) $(BASEDIR) $(INSTALL_SOURCEDIR)
+fpc_exampleinstall: $(addsuffix _distclean,$(TARGET_EXAMPLEDIRS))
+ifdef HASEXAMPLES
+	$(MKDIR) $(INSTALL_EXAMPLEDIR)
+endif
+ifdef EXAMPLESOURCEFILES
+	$(COPY) $(EXAMPLESOURCEFILES) $(INSTALL_EXAMPLEDIR)
+endif
+ifdef TARGET_EXAMPLEDIRS
+	$(COPYTREE) $(addsuffix /*,$(TARGET_EXAMPLEDIRS)) $(INSTALL_EXAMPLEDIR)
+endif
+.PHONY: fpc_distinstall
+fpc_distinstall: install exampleinstall
+.PHONY: fpc_zipinstall fpc_zipsourceinstall fpc_zipexampleinstall
+ifndef PACKDIR
+ifndef inUnix
+PACKDIR=$(BASEDIR)/../fpc-pack
+else
+PACKDIR=/tmp/fpc-pack
+endif
+endif
+ifndef ZIPNAME
+ifdef DIST_ZIPNAME
+ZIPNAME=$(DIST_ZIPNAME)
+else
+ZIPNAME=$(ZIPPREFIX)$(PACKAGE_NAME)$(ZIPSUFFIX)
+endif
+endif
+ifndef ZIPTARGET
+ifdef DIST_ZIPTARGET
+ZIPTARGET=DIST_ZIPTARGET
+else
+ZIPTARGET=install
+endif
+endif
+ifndef USEZIP
+ifdef inUnix
+USETAR=1
+endif
+endif
+ifndef inUnix
+USEZIPWRAPPER=1
+endif
+ifdef USEZIPWRAPPER
+ZIPPATHSEP=$(PATHSEP)
+ZIPWRAPPER=$(subst /,$(PATHSEP),$(DIST_DESTDIR)/fpczip$(BATCHEXT))
+else
+ZIPPATHSEP=/
+endif
+ZIPCMD_CDPACK:=cd $(subst /,$(ZIPPATHSEP),$(PACKDIR))
+ZIPCMD_CDBASE:=cd $(subst /,$(ZIPPATHSEP),$(BASEDIR))
+ifdef USETAR
+ZIPDESTFILE:=$(DIST_DESTDIR)/$(ZIPNAME)$(TAREXT)
+ZIPCMD_ZIP:=$(TARPROG) cf$(TAROPT) $(ZIPDESTFILE) *
+else
+ZIPDESTFILE:=$(DIST_DESTDIR)/$(ZIPNAME)$(ZIPEXT)
+ZIPCMD_ZIP:=$(subst /,$(ZIPPATHSEP),$(ZIPPROG)) -Dr $(ZIPOPT) $(ZIPDESTFILE) *
+endif
+fpc_zipinstall:
+	$(MAKE) $(ZIPTARGET) INSTALL_PREFIX=$(PACKDIR) ZIPINSTALL=1
+	$(MKDIR) $(DIST_DESTDIR)
+	$(DEL) $(ZIPDESTFILE)
+ifdef USEZIPWRAPPER
+ifneq ($(ECHOREDIR),echo)
+	$(ECHOREDIR) -e "$(subst \,\\,$(ZIPCMD_CDPACK))" > $(ZIPWRAPPER)
+	$(ECHOREDIR) -e "$(subst \,\\,$(ZIPCMD_ZIP))" >> $(ZIPWRAPPER)
+	$(ECHOREDIR) -e "$(subst \,\\,$(ZIPCMD_CDBASE))" >> $(ZIPWRAPPER)
+else
+	echo $(ZIPCMD_CDPACK) > $(ZIPWRAPPER)
+	echo $(ZIPCMD_ZIP) >> $(ZIPWRAPPER)
+	echo $(ZIPCMD_CDBASE) >> $(ZIPWRAPPER)
+endif
+ifdef inUnix
+	/bin/sh $(ZIPWRAPPER)
+else
+	$(ZIPWRAPPER)
+endif
+	$(DEL) $(ZIPWRAPPER)
+else
+	$(ZIPCMD_CDPACK) ; $(ZIPCMD_ZIP) ; $(ZIPCMD_CDBASE)
+endif
+	$(DELTREE) $(PACKDIR)
+fpc_zipsourceinstall:
+	$(MAKE) fpc_zipinstall ZIPTARGET=sourceinstall ZIPSUFFIX=src
+fpc_zipexampleinstall:
+ifdef HASEXAMPLES
+	$(MAKE) fpc_zipinstall ZIPTARGET=exampleinstall ZIPSUFFIX=exm
+endif
+fpc_zipdistinstall:
+	$(MAKE) fpc_zipinstall ZIPTARGET=distinstall
+.PHONY: fpc_clean fpc_cleanall fpc_distclean
+ifdef EXEFILES
+override CLEANEXEFILES:=$(addprefix $(TARGETDIRPREFIX),$(CLEANEXEFILES))
+endif
+ifdef CLEAN_UNITS
+override CLEANPPUFILES+=$(addsuffix $(PPUEXT),$(CLEAN_UNITS))
+endif
+ifdef CLEANPPUFILES
+override CLEANPPULINKFILES:=$(subst $(PPUEXT),$(OEXT),$(CLEANPPUFILES)) $(addprefix $(STATICLIBPREFIX),$(subst $(PPUEXT),$(STATICLIBEXT),$(CLEANPPUFILES)))
+override CLEANPPUFILES:=$(addprefix $(UNITTARGETDIRPREFIX),$(CLEANPPUFILES))
+override CLEANPPULINKFILES:=$(wildcard $(addprefix $(UNITTARGETDIRPREFIX),$(CLEANPPULINKFILES)))
+endif
+fpc_clean: $(CLEANTARGET)
+ifdef CLEANEXEFILES
+	-$(DEL) $(CLEANEXEFILES)
+endif
+ifdef CLEANPPUFILES
+	-$(DEL) $(CLEANPPUFILES)
+endif
+ifneq ($(CLEANPPULINKFILES),)
+	-$(DEL) $(CLEANPPULINKFILES)
+endif
+ifdef CLEANRSTFILES
+	-$(DEL) $(addprefix $(UNITTARGETDIRPREFIX),$(CLEANRSTFILES))
+endif
+ifdef CLEAN_FILES
+	-$(DEL) $(CLEAN_FILES)
+endif
+ifdef LIB_NAME
+	-$(DEL) $(LIB_NAME) $(LIB_FULLNAME)
+endif
+	-$(DEL) $(FPCMADE) Package.fpc $(PPAS) script.res link.res $(FPCEXTFILE) $(REDIRFILE)
+fpc_distclean: clean
+ifdef COMPILER_UNITTARGETDIR
+TARGETDIRCLEAN=fpc_clean
+endif
+fpc_cleanall: $(CLEANTARGET) $(TARGETDIRCLEAN)
+ifdef CLEANEXEFILES
+	-$(DEL) $(CLEANEXEFILES)
+endif
+	-$(DEL) *$(OEXT) *$(PPUEXT) *$(RSTEXT) *$(ASMEXT) *$(STATICLIBEXT) *$(SHAREDLIBEXT) *$(PPLEXT)
+	-$(DELTREE) *$(SMARTEXT)
+	-$(DEL) $(FPCMADE) Package.fpc $(PPAS) script.res link.res $(FPCEXTFILE) $(REDIRFILE)
+ifdef AOUTEXT
+	-$(DEL) *$(AOUTEXT)
+endif
+.PHONY: fpc_baseinfo
+override INFORULES+=fpc_baseinfo
+fpc_baseinfo:
+	@$(ECHO)
+	@$(ECHO)  == Package info ==
+	@$(ECHO)  Package Name..... $(PACKAGE_NAME)
+	@$(ECHO)  Package Version.. $(PACKAGE_VERSION)
+	@$(ECHO)
+	@$(ECHO)  == Configuration info ==
+	@$(ECHO)
+	@$(ECHO)  FPC.......... $(FPC)
+	@$(ECHO)  FPC Version.. $(FPC_VERSION)
+	@$(ECHO)  Source CPU... $(CPU_SOURCE)
+	@$(ECHO)  Target CPU... $(CPU_TARGET)
+	@$(ECHO)  Source OS.... $(OS_SOURCE)
+	@$(ECHO)  Target OS.... $(OS_TARGET)
+	@$(ECHO)  Full Target.. $(FULL_SOURCE)
+	@$(ECHO)  Full Source.. $(FULL_TARGET)
+	@$(ECHO)
+	@$(ECHO)  == Directory info ==
+	@$(ECHO)
+	@$(ECHO)  Required pkgs... $(REQUIRE_PACKAGES)
+	@$(ECHO)
+	@$(ECHO)  Basedir......... $(BASEDIR)
+	@$(ECHO)  FPCDir.......... $(FPCDIR)
+	@$(ECHO)  CrossBinDir..... $(CROSSBINDIR)
+	@$(ECHO)  UnitsDir........ $(UNITSDIR)
+	@$(ECHO)  PackagesDir..... $(PACKAGESDIR)
+	@$(ECHO)
+	@$(ECHO)  GCC library..... $(GCCLIBDIR)
+	@$(ECHO)  Other library... $(OTHERLIBDIR)
+	@$(ECHO)
+	@$(ECHO)  == Tools info ==
+	@$(ECHO)
+	@$(ECHO)  As........ $(AS)
+	@$(ECHO)  Ld........ $(LD)
+	@$(ECHO)  Ar........ $(AR)
+	@$(ECHO)  Rc........ $(RC)
+	@$(ECHO)
+	@$(ECHO)  Mv........ $(MVPROG)
+	@$(ECHO)  Cp........ $(CPPROG)
+	@$(ECHO)  Rm........ $(RMPROG)
+	@$(ECHO)  GInstall.. $(GINSTALL)
+	@$(ECHO)  Echo...... $(ECHO)
+	@$(ECHO)  Date...... $(DATE)
+	@$(ECHO)  FPCMake... $(FPCMAKE)
+	@$(ECHO)  PPUMove... $(PPUMOVE)
+	@$(ECHO)  Upx....... $(UPXPROG)
+	@$(ECHO)  Zip....... $(ZIPPROG)
+	@$(ECHO)
+	@$(ECHO)  == Object info ==
+	@$(ECHO)
+	@$(ECHO)  Target Loaders........ $(TARGET_LOADERS)
+	@$(ECHO)  Target Units.......... $(TARGET_UNITS)
+	@$(ECHO)  Target Implicit Units. $(TARGET_IMPLICITUNITS)
+	@$(ECHO)  Target Programs....... $(TARGET_PROGRAMS)
+	@$(ECHO)  Target Dirs........... $(TARGET_DIRS)
+	@$(ECHO)  Target Examples....... $(TARGET_EXAMPLES)
+	@$(ECHO)  Target ExampleDirs.... $(TARGET_EXAMPLEDIRS)
+	@$(ECHO)
+	@$(ECHO)  Clean Units......... $(CLEAN_UNITS)
+	@$(ECHO)  Clean Files......... $(CLEAN_FILES)
+	@$(ECHO)
+	@$(ECHO)  Install Units....... $(INSTALL_UNITS)
+	@$(ECHO)  Install Files....... $(INSTALL_FILES)
+	@$(ECHO)
+	@$(ECHO)  == Install info ==
+	@$(ECHO)
+	@$(ECHO)  DateStr.............. $(DATESTR)
+	@$(ECHO)  ZipPrefix............ $(ZIPPREFIX)
+	@$(ECHO)  ZipSuffix............ $(ZIPSUFFIX)
+	@$(ECHO)  Install FPC Package.. $(INSTALL_FPCPACKAGE)
+	@$(ECHO)
+	@$(ECHO)  Install base dir..... $(INSTALL_BASEDIR)
+	@$(ECHO)  Install binary dir... $(INSTALL_BINDIR)
+	@$(ECHO)  Install library dir.. $(INSTALL_LIBDIR)
+	@$(ECHO)  Install units dir.... $(INSTALL_UNITDIR)
+	@$(ECHO)  Install source dir... $(INSTALL_SOURCEDIR)
+	@$(ECHO)  Install doc dir...... $(INSTALL_DOCDIR)
+	@$(ECHO)  Install example dir.. $(INSTALL_EXAMPLEDIR)
+	@$(ECHO)  Install data dir..... $(INSTALL_DATADIR)
+	@$(ECHO)
+	@$(ECHO)  Dist destination dir. $(DIST_DESTDIR)
+	@$(ECHO)  Dist zip name........ $(DIST_ZIPNAME)
+	@$(ECHO)
+.PHONY: fpc_info
+fpc_info: $(INFORULES)
+.PHONY: fpc_makefile fpc_makefiles fpc_makefile_sub1 fpc_makefile_sub2 \
+	fpc_makefile_dirs
+fpc_makefile:
+	$(FPCMAKE) -w -T$(OS_TARGET) Makefile.fpc
+fpc_makefile_sub1:
+ifdef TARGET_DIRS
+	$(FPCMAKE) -w -T$(OS_TARGET) $(addsuffix /Makefile.fpc,$(TARGET_DIRS))
+endif
+ifdef TARGET_EXAMPLEDIRS
+	$(FPCMAKE) -w -T$(OS_TARGET) $(addsuffix /Makefile.fpc,$(TARGET_EXAMPLEDIRS))
+endif
+fpc_makefile_sub2: $(addsuffix _makefile_dirs,$(TARGET_DIRS) $(TARGET_EXAMPLEDIRS))
+fpc_makefile_dirs: fpc_makefile_sub1 fpc_makefile_sub2
+fpc_makefiles: fpc_makefile fpc_makefile_dirs
+all: fpc_all
+debug: fpc_debug
+smart: fpc_smart
+release: fpc_release
+examples: fpc_examples
+shared:
+install: fpc_install
+sourceinstall: fpc_sourceinstall
+exampleinstall: fpc_exampleinstall
+distinstall: fpc_distinstall
+zipinstall: fpc_zipinstall
+zipsourceinstall: fpc_zipsourceinstall
+zipexampleinstall: fpc_zipexampleinstall
+zipdistinstall: fpc_zipdistinstall
+clean: fpc_clean
+distclean: fpc_distclean
+cleanall: fpc_cleanall
+info: fpc_info
+makefiles: fpc_makefiles
+.PHONY: all debug smart release examples shared install sourceinstall exampleinstall distinstall zipinstall zipsourceinstall zipexampleinstall zipdistinstall clean distclean cleanall info makefiles
+ifneq ($(wildcard fpcmake.loc),)
+include fpcmake.loc
+endif

+ 20 - 0
packages/base/postgres/Makefile.fpc

@@ -0,0 +1,20 @@
+#
+#   Makefile.fpc for Postgres bindings
+#
+
+[package]
+name=postgres
+version=1.0.6
+
+[target]
+units=dllist postgres
+examples=testpg1 testpg2
+
+[require]
+libc=y
+
+[install]
+fpcpackage=y
+
+[default]
+fpcdir=../../..

+ 21 - 0
packages/base/postgres/README

@@ -0,0 +1,21 @@
+This is the PostGresSQL interface of Free Pascal.
+
+It has been tested with versions 6.2.xxx and 6.3.xxx of PostGreSQL.
+You need at least compiler version 0.99.8 to compile this.
+
+To Compile
+- You must know where the PostGreSQL libraries (libpq) are.
+- You must set the variable OLD in the makefile to 'yes', if your
+  postgresql version is 6.2.xxx or earlier.
+
+Both these things must be set in the Makefile. After that a simple 'make'
+and 'make install' should compile and install everything.
+
+You can test with 'make test', but this supposes that there is a 'testdb'
+database available. If not, you must run
+  mkdb databasename
+  testdb databasename
+  rmdb databasename
+manually. You need create permission on the database for this to work.
+
+Michael.

+ 86 - 0
packages/base/postgres/dllist.pp

@@ -0,0 +1,86 @@
+unit dllist;
+
+interface
+
+{$linklib pq}
+
+{ Pointers to basic pascal types, inserted by h2pas conversion program.}
+Type
+  PLongint  = ^Longint;
+  PByte     = ^Byte;
+  PWord     = ^Word;
+  PINteger  = ^Integer;
+  PCardinal = ^Cardinal;
+  PReal     = ^Real;
+  PDouble   = ^Double;
+
+{ next element }
+{ previous element }
+{ value of the element }
+{ what list this element is in }
+
+type
+   { Pointer types } 
+   PDllist= ^TDllist;
+   PDlelem= ^TDlelem;
+
+   TDlelem = record
+        dle_next : PDlelem;
+        dle_prev : PDlElem;
+        dle_val : pointer;
+        dle_list : PDllist;
+     end;
+
+   TDllist = record
+        dll_head : PDlelem;
+        dll_tail : PDlelem;
+     end;
+
+function  DLNewList:PDllist; cdecl;
+procedure DLFreeList(_para1:PDllist); cdecl;
+function  DLNewElem(val : pointer) :PDlelem; cdecl;
+procedure DLFreeElem(_para1:PDlelem); cdecl;
+function  DLGetHead(_para1:PDllist):PDlelem; cdecl;
+function  DLGetTail(_para1:PDllist):PDlelem; cdecl;
+function  DLRemTail(l:PDllist):PDlelem; cdecl;
+function  DLGetPred(_para1:PDlelem):PDlelem; cdecl;
+function  DLGetSucc(_para1:PDlelem):PDlelem; cdecl;
+procedure DLRemove(_para1:PDlelem); cdecl;
+procedure DLAddHead(list:PDllist; node:PDlelem);cdecl;
+procedure DLAddTail(list:PDllist; node:PDlelem);cdecl;
+function  DLRemHead(list:PDllist):PDlelem;cdecl;
+
+{ Macro translated }
+Function  DLE_VAL(elem : PDlelem) : pointer; 
+
+implementation
+
+
+function  DLNewList:PDllist;cdecl; external;
+procedure DLFreeList(_para1:PDllist);cdecl; external;
+function  DLNewElem(val : pointer) :PDlelem;cdecl;external;
+procedure DLFreeElem(_para1:PDlelem);cdecl; external;
+function  DLGetHead(_para1:PDllist):PDlelem;cdecl; external;
+function  DLGetTail(_para1:PDllist):PDlelem;cdecl; external;
+function  DLRemTail(l:PDllist):PDlelem;cdecl; external;
+function  DLGetPred(_para1:PDlelem):PDlelem;cdecl; external;
+function  DLGetSucc(_para1:PDlelem):PDlelem;cdecl; external;
+procedure DLRemove(_para1:PDlelem);cdecl; external;
+procedure DLAddHead(list:PDllist; node:PDlelem);cdecl; external;
+procedure DLAddTail(list:PDllist; node:PDlelem);cdecl; external;
+function  DLRemHead(list:PDllist):PDlelem;cdecl; external;
+
+Function DLE_VAL(elem : PDlelem) : pointer;
+begin
+  DLE_VAL:=elem^.dle_val
+end;
+
+end.
+  $Log$
+  Revision 1.1  2002-01-29 17:54:56  peter
+    * splitted to base and extra
+
+  Revision 1.2  2000/07/13 11:33:30  michael
+  + removed logs
+ 
+}

+ 26 - 0
packages/base/postgres/mkdb

@@ -0,0 +1,26 @@
+#!/bin/sh
+#
+# Script to create a table 'email' and to fill it with data.
+# The script accepts an optional argument : 
+# A database to connect to. (default 'testdb')
+echo -n "Creating and filling table email in database ${1-testdb}..."
+psql ${1-testdb} << EOF >/dev/null 2>&1
+create table email ( 
+id int4,
+name text,
+email text);
+insert into email values (1,'Michael Van Canneyt','[email protected]');
+insert into email values (2,'Florian Klaempfl','[email protected]');
+insert into email values (3,'Carl-Eric Codere','[email protected]');
+insert into email values (4,'Daniel Mantione','[email protected]');
+insert into email values (5,'Pierre Muller','[email protected]');
+insert into email values (6,'Jonas Maebe','[email protected]');
+insert into email values (7,'Peter Vreman','[email protected]');
+insert into email values (8,'Gerry Dubois','[email protected]');
+EOF
+if [ ! $? = 0 ]; then
+  echo "Failed."
+else
+  echo "Done."
+fi
+# Ready

+ 340 - 0
packages/base/postgres/postgres.pp

@@ -0,0 +1,340 @@
+unit postgres;
+
+interface
+
+uses dllist;
+
+{$linklib pq}
+{$linklib c}
+
+{ Not always needed. If you have problems linking, try to add this  }
+{ $linklib crypt}
+
+{ $include "libpq/pqcomm.h"}
+
+
+Type
+   Oid = cardinal;
+   MsgType = Cardinal;
+   PLongint = ^Longint;
+   TSockAddr = Array [1..112] of byte; { Testded using C version sizeof() }
+     
+Const
+   NAMEDATALEN = 32;
+   OIDNAMELEN = 36;
+
+Type  
+   TFILE = Longint;
+   PFIle = ^TFILE; 
+
+type
+   TConnStatusType = (CONNECTION_OK,CONNECTION_BAD);
+   PConnStatusType= ^TConnStatusType;
+
+   TExecStatusType = (PGRES_EMPTY_QUERY,PGRES_COMMAND_OK,PGRES_TUPLES_OK,
+     PGRES_COPY_OUT,
+     PGRES_COPY_IN,
+     PGRES_BAD_RESPONSE,
+     PGRES_NONFATAL_ERROR,
+     PGRES_FATAL_ERROR
+     );
+   PExecStatusType= ^TExecStatusType;
+{
+	extern const char  pgresStatus[];
+}
+
+const
+   ERROR_MSG_LENGTH = 4096;
+   COMMAND_LENGTH = 20;
+   REMARK_LENGTH = 80;
+   PORTAL_NAME_LENGTH = 16;
+
+type
+   TPQArgBlock = record
+        len : longint;
+        isint : longint;
+        u : record
+            case longint of
+               0 : ( ptr:Plongint );
+               1 : ( integer:longint );
+          end;
+     end;
+   PPQArgBlock= ^TPQArgBlock;
+
+   TPGresAttDesc = record
+        name : Pchar;
+        adtid : Oid;
+        adtsize : integer;
+     end;
+   PPGresAttDesc= ^TPGresAttDesc;
+   PPPGresAttDesc= ^PPGresAttDesc;
+
+const
+   NULL_LEN = -1;
+
+type
+   TPGresAttValue = record
+        len : longint;
+        value : Pchar;
+     end;
+   PPGresAttValue= ^TPGresAttValue;
+   PPPGresAttValue= ^PPGresAttValue;
+
+   TPGnotify = record
+        relname : array[0..(NAMEDATALEN)-1] of char;
+        be_pid : longint;
+     end;
+   PPGnotify= ^TPGnotify;
+
+   TPGlobjfuncs = record
+        fn_lo_open : Oid;
+        fn_lo_close : Oid;
+        fn_lo_creat : Oid;
+        fn_lo_unlink : Oid;
+        fn_lo_lseek : Oid;
+        fn_lo_tell : Oid;
+        fn_lo_read : Oid;
+        fn_lo_write : Oid;
+     end;
+   PPGlobjfuncs= ^TPGlobjfuncs;
+
+   TPGconn = record
+        pghost : Pchar;
+        pgtty : Pchar;
+        pgport : Pchar;
+        pgoptions : Pchar;
+        dbName : Pchar;
+        status : TConnStatusType;
+        errorMessage : array[0..(ERROR_MSG_LENGTH)-1] of char;
+        Pfin : PFILE;
+        Pfout : PFILE;
+        Pfdebug : PFILE;
+        sock : longint;
+        laddr : TSockAddr;
+        raddr : TSockAddr;
+        salt : array[0..(2)-1] of char;
+        asyncNotifyWaiting : longint;
+        notifyList : PDllist;
+        pguser : Pchar;
+        pgpass : Pchar;
+        lobjfuncs : PPGlobjfuncs;
+     end;
+   PPGconn= ^TPGconn;
+
+const
+   CMDSTATUS_LEN = 40;
+
+type
+   TPGresult = record
+        ntups : longint;
+        numAttributes : longint;
+        attDescs : PPGresAttDesc;
+        tuples : PPPGresAttValue;
+        tupArrSize : longint;
+        resultStatus : TExecStatusType;
+        cmdStatus : array[0..(CMDSTATUS_LEN)-1] of char;
+        binary : longint;
+        conn : PPGconn;
+     end;
+   PPGresult= ^TPGresult;
+
+   pqbool = char;
+
+   TPQprintopt = record
+        header : pqbool;
+        align : pqbool;
+        standard : pqbool;
+        html3 : pqbool;
+        expanded : pqbool;
+        pager : pqbool;
+        fieldSep : Pchar;
+        tableOpt : Pchar;
+        caption : Pchar;
+     end;
+   PPQprintopt= ^TPQprintopt;
+
+
+   TPQconninfoOption = Record
+      keyword   : pchar;
+      environ   : pchar;
+      compiled  : pchar;
+      val       : pchar;
+      Thelabel  : pchar;
+      dispchar  : pchar;
+      dispsize  : longint;
+   end;
+   PPQconninfoOption = ^TPQconninfoOption; 
+
+
+Function  PQconnectdb(conninfo:Pchar):PPGconn; cdecl;
+Function  PQconndefaults:PPQconninfoOption; cdecl;
+Function  PQsetdbLogin(pghost,pgport,pgoptions,pgtty,dbName,login,pwd : pchar):PPGConn; cdecl;
+{$ifdef PGSQL6_2_1}
+Function  PQsetdb(pghost,pgport,pgoptions,pgtty,dbName : pchar):PPGConn; cdecl;
+{$else}
+Function  PQsetdb(pghost,pgport,pgoptions,pgtty,dbName : pchar):PPGConn;
+{$endif}
+procedure PQfinish(conn:PPGconn); cdecl;
+procedure PQreset(conn:PPGconn); cdecl;
+Function  PQdb(conn:PPGconn):Pchar; cdecl;
+Function  PQuser(conn:PPGconn):Pchar; cdecl;
+Function  PQhost(conn:PPGconn):Pchar; cdecl;
+Function  PQoptions(conn:PPGconn):Pchar; cdecl;
+Function  PQport(conn:PPGconn):Pchar; cdecl;
+Function  PQtty(conn:PPGconn):Pchar; cdecl;
+Function  PQstatus(conn:PPGconn):TConnStatusType; cdecl;
+Function  PQerrorMessage(conn:PPGconn):Pchar; cdecl;
+procedure PQtrace(conn:PPGconn; debug_port:PFILE); cdecl;
+procedure PQuntrace(conn:PPGconn); cdecl;
+Function  PQexec(conn:PPGconn; query:Pchar):PPGresult; cdecl;
+Function  PQgetline(conn:PPGconn; str:Pchar; len:longint):longint; cdecl;
+Function  PQendcopy(conn:PPGconn):longint; cdecl;
+Function  PQputline(conn:PPGconn; str:Pchar) : longint; cdecl;
+Function  PQresultStatus(res:PPGresult):TExecStatusType; cdecl;
+Function  PQntuples(res:PPGresult):longint; cdecl;
+Function  PQnfields(res:PPGresult):longint; cdecl;
+Function  PQfname(res:PPGresult; field_num:longint):Pchar; cdecl;
+Function  PQfnumber(res:PPGresult; field_name:Pchar):longint; cdecl;
+Function  PQftype(res:PPGresult; field_num:longint):Oid; cdecl;
+Function  PQfsize(res:PPGresult; field_num:longint):integer; cdecl;
+Function  PQcmdStatus(res:PPGresult):Pchar; cdecl;
+
+Function  PQoidStatus(res : PPGresult) : pchar; cdecl;
+Function  PQcmdTuples(res : PPGresult) : pchar; cdecl;
+
+Function  PQgetvalue(res:PPGresult; tup_num:longint; field_num:longint):Pchar; cdecl;
+Function  PQgetlength(res:PPGresult; tup_num:longint; field_num:longint):longint; cdecl;
+Function  PQgetisnull(res:PPGresult; tup_num:longint; field_num:longint):longint; cdecl;
+procedure PQclear(res:PPGresult);cdecl;
+procedure PQdisplayTuples(res:PPGresult; fp:PFILE; fillAlign:longint; fieldSep:Pchar; printHeader:longint; quiet:longint);cdecl;
+procedure PQprintTuples(res:PPGresult; fout:PFILE; printAttName:longint; terseOutput:longint; width:longint);cdecl;
+procedure PQprint(fout:PFILE; res:PPGresult; ps:PPQprintOpt);cdecl;
+Function  PQnotifies(conn:PPGconn):PPGnotify; cdecl;
+Function  PQfn(conn:PPGconn; fnid:longint; result_buf:Plongint; result_len:Plongint; result_is_int:longint; args:PPQArgBlock; nargs:longint):PPGresult; cdecl;
+Function  fe_getauthsvc(PQerrormsg:Pchar):MsgType; cdecl;
+procedure fe_setauthsvc(name:Pchar; PQerrormsg:Pchar);cdecl;
+Function  fe_getauthname(PQerrormsg:Pchar):Pchar; cdecl;
+Function  pqGets(s:Pchar; maxlen:longint; stream:PFILE; debug:PFILE):longint; cdecl;
+Function  pqGetnchar(s:Pchar; maxlen:longint; stream:PFILE; debug:PFILE):longint; cdecl;
+Function  pqPutnchar(s:Pchar; maxlen:longint; stream:PFILE; debug:PFILE):longint; cdecl;
+Function  pqPuts(s:Pchar; stream:PFILE; debug:PFILE):longint; cdecl;
+Function  pqGetc(stream:PFILE; debug:PFILE):longint; cdecl;
+Function  pqGetInt(result:Plongint; bytes:longint; stream:PFILE; debug:PFILE):longint; cdecl;
+Function  pqPutInt(n:longint; bytes:longint; stream:PFILE; debug:PFILE):longint; cdecl;
+procedure pqFlush(stream:PFILE; debug:PFILE);cdecl;
+Function  lo_open(conn:PPGconn; lobjId:Oid; mode:longint):longint; cdecl;
+Function  lo_close(conn:PPGconn; fd:longint):longint; cdecl;
+Function  lo_read(conn:PPGconn; fd:longint; buf:Pchar; len:longint):longint; cdecl;
+Function  lo_write(conn:PPGconn; fd:longint; buf:Pchar; len:longint):longint; cdecl;
+Function  lo_lseek(conn:PPGconn; fd:longint; offset:longint; whence:longint):longint; cdecl;
+Function  lo_creat(conn:PPGconn; mode:longint):Oid; cdecl;
+Function  lo_tell(conn:PPGconn; fd:longint):longint; cdecl;
+Function  lo_unlink(conn:PPGconn; lobjId:Oid):longint; cdecl;
+Function  lo_import(conn:PPGconn; filename:Pchar):Oid; cdecl;
+Function  lo_export(conn:PPGconn; lobjId:Oid; filename:Pchar):longint; cdecl;
+
+const
+   MAX_MESSAGE_LEN = 8193;
+   BYTELEN = 8;
+   MAX_FIELDS = 512;
+   DefaultHost     : pchar = 'localhost';
+   DefaultTty      : pchar = '';
+   DefaultOption   : pchar = '';
+   DefaultAuthtype : pchar = '';
+   DefaultPassword : pchar = '';
+
+type
+   TTUPLE = pointer;
+   PTUPLE = ^TTUPLE;
+
+implementation
+
+
+  function  PQconnectdb(conninfo:Pchar):PPGconn;cdecl; external;
+  function  PQconndefaults:PPQconninfoOption;cdecl; external;
+  function  PQsetdbLogin(pghost,pgport,pgoptions,pgtty,dbName,login,pwd : pchar):PPGConn;cdecl;external;
+  procedure PQfinish(conn:PPGconn);cdecl; external;
+  procedure PQreset(conn:PPGconn);cdecl; external;
+  function  PQdb(conn:PPGconn):Pchar;cdecl; external;
+  function  PQuser(conn:PPGconn):Pchar;cdecl; external;
+  function  PQhost(conn:PPGconn):Pchar;cdecl; external;
+  function  PQoptions(conn:PPGconn):Pchar;cdecl; external;
+  function  PQport(conn:PPGconn):Pchar;cdecl; external;
+  function  PQtty(conn:PPGconn):Pchar;cdecl; external;
+  function  PQstatus(conn:PPGconn):TConnStatusType;cdecl; external;
+  function  PQerrorMessage(conn:PPGconn):Pchar;cdecl; external;
+  procedure PQtrace(conn:PPGconn; debug_port:PFILE);cdecl; external;
+  procedure PQuntrace(conn:PPGconn);cdecl; external;
+  function  PQexec(conn:PPGconn; query:Pchar):PPGresult;cdecl; external;
+  function  PQgetline(conn:PPGconn; str:Pchar; len:longint):longint;cdecl; external;
+  function  PQendcopy(conn:PPGconn):longint;cdecl; external;
+  function PQputline(conn:PPGconn; str:Pchar) : longint;cdecl; external;
+  function  PQresultStatus(res:PPGresult):TExecStatusType;cdecl; external;
+  function  PQntuples(res:PPGresult):longint;cdecl; external;
+  function  PQnfields(res:PPGresult):longint;cdecl; external;
+  function  PQfname(res:PPGresult; field_num:longint):Pchar;cdecl; external;
+  function  PQfnumber(res:PPGresult; field_name:Pchar):longint;cdecl; external;
+  function  PQftype(res:PPGresult; field_num:longint):Oid;cdecl; external;
+  function  PQfsize(res:PPGresult; field_num:longint):integer;cdecl; external;
+  function  PQcmdStatus(res:PPGresult):Pchar;cdecl; external;
+  function  PQgetvalue(res:PPGresult; tup_num:longint; field_num:longint):Pchar;cdecl; external;
+  function  PQgetlength(res:PPGresult; tup_num:longint; field_num:longint):longint;cdecl; external;
+  function  PQgetisnull(res:PPGresult; tup_num:longint; field_num:longint):longint;cdecl; external;
+  procedure PQclear(res:PPGresult);cdecl; external;
+  procedure PQdisplayTuples(res:PPGresult; fp:PFILE; fillAlign:longint; fieldSep:Pchar; printHeader:longint; quiet:longint);cdecl; external;
+  procedure PQprintTuples(res:PPGresult; fout:PFILE; printAttName:longint; terseOutput:longint; width:longint);cdecl; external;
+  procedure PQprint(fout:PFILE; res:PPGresult; ps:PPQprintOpt);cdecl; external;
+  function  PQnotifies(conn:PPGconn):PPGnotify;cdecl; external;
+  function  PQfn(conn:PPGconn; fnid:longint; result_buf:Plongint; result_len:Plongint; result_is_int:longint; args:PPQArgBlock; nargs:longint):PPGresult;cdecl; external;
+  function  fe_getauthsvc(PQerrormsg:Pchar):MsgType;cdecl; external;
+  procedure fe_setauthsvc(name:Pchar; PQerrormsg:Pchar);cdecl; external;
+  function  fe_getauthname(PQerrormsg:Pchar):Pchar;cdecl; external;
+  function  pqGets(s:Pchar; maxlen:longint; stream:PFILE; debug:PFILE):longint;cdecl; external;
+  function  pqGetnchar(s:Pchar; maxlen:longint; stream:PFILE; debug:PFILE):longint;cdecl; external;
+  function  pqPutnchar(s:Pchar; maxlen:longint; stream:PFILE; debug:PFILE):longint;cdecl; external;
+  function  pqPuts(s:Pchar; stream:PFILE; debug:PFILE):longint;cdecl; external;
+  function  pqGetc(stream:PFILE; debug:PFILE):longint;cdecl; external;
+  function  pqGetInt(result:Plongint; bytes:longint; stream:PFILE; debug:PFILE):longint;cdecl; external;
+  function  pqPutInt(n:longint; bytes:longint; stream:PFILE; debug:PFILE):longint;cdecl; external;
+  procedure pqFlush(stream:PFILE; debug:PFILE);cdecl; external;
+  function  PQoidStatus(res : PPGresult) : pchar;cdecl;external;
+  function  PQcmdTuples(res : PPGresult) : pchar;cdecl;external;
+  function  lo_open(conn:PPGconn; lobjId:Oid; mode:longint):longint; cdecl; external;
+  function  lo_close(conn:PPGconn; fd:longint):longint; cdecl; external;
+  function  lo_read(conn:PPGconn; fd:longint; buf:Pchar; len:longint):longint; cdecl; external;
+  function  lo_write(conn:PPGconn; fd:longint; buf:Pchar; len:longint):longint; cdecl; external;
+  function  lo_lseek(conn:PPGconn; fd:longint; offset:longint; whence:longint):longint; cdecl; external;
+  function  lo_creat(conn:PPGconn; mode:longint):Oid;cdecl;external;
+  function  lo_tell(conn:PPGconn; fd:longint):longint; cdecl; external;
+  function  lo_unlink(conn:PPGconn; lobjId:Oid):longint; cdecl; external;
+  function  lo_import(conn:PPGconn; filename:Pchar):Oid;cdecl;external;
+  function  lo_export(conn:PPGconn; lobjId:Oid; filename:Pchar):longint; cdecl; external;
+
+{ Define helper functions }
+
+{
+  In version 6.2.xxx, PGsetdb is a function in libpq.
+  in version 6.3.xxx, PGsetdb is a macro, pointing to setdblogin !!
+}
+
+{$ifdef PGSQL6_2_1}
+Function  PQsetdb(pghost,pgport,pgoptions,pgtty,dbName : pchar):PPGConn; cdecl;external;
+{$else}
+function PQsetdb(pghost,pgport,pgoptions,pgtty,dbName : pchar):PPGConn;
+
+begin
+ PQsetdb:=PQsetdbLogin(pghost,pgport,pgoptions,pgtty,dbName,nil,nil);
+end;
+{$endif}
+
+end.  $Log$
+end.  Revision 1.1  2002-01-29 17:54:56  peter
+end.    * splitted to base and extra
+end.
+end.  Revision 1.3  2001/05/03 21:35:09  peter
+end.    * Makefile fixes
+end.
+end.  Revision 1.2  2000/07/13 11:33:30  michael
+end.  + removed logs
+end. 
+}

+ 16 - 0
packages/base/postgres/rmdb

@@ -0,0 +1,16 @@
+#!/bin/sh
+#
+# Small script to remove the demo database again.
+# This script accepts 1 (optional) argument : 
+# a database you can connect to. Default is 'testdb'
+# 
+echo -n "Removing table email from db ${1-testdb}..." 
+psql ${1-testdb} << EOF >/dev/null 2>&1
+drop table email;
+EOF
+if [ ! $? = 0 ]; then
+  echo "Failed."
+else
+  echo "Done."
+fi
+# Ready

+ 113 - 0
packages/base/postgres/testpg1.pp

@@ -0,0 +1,113 @@
+Program testpg;
+
+{ Demo program to test pascal connection with postgres database }
+{ Translated from the testlibpq example program of PostGreSQL   }
+
+Uses postgres,strings;
+
+
+Procedure exit_nicely(Conn : PPGconn);
+
+begin
+  PQfinish(conn);
+  halt(1);
+end;
+
+
+Var
+  pghost,pgport,pgoptions,pgtty,dbname : Pchar;
+  nFields,i,j : longint;
+  conn : PPGConn;
+  res : PPGresult;
+
+begin
+  pghost := NiL;        { host name of the backend server }
+  pgport := NiL;        { port of the backend server }
+  pgoptions := NiL;     { special options to start up the backend server }
+  pgtty := NiL;         { debugging tty for the backend server }
+  dbName := 'template1';
+
+  { make a connection to the database }
+  conn := PQsetdb(pghost, pgport, pgoptions, pgtty, dbName);
+
+  { check to see that the backend connection was successfully made }
+  if (PQstatus(conn) = CONNECTION_BAD) then
+    begin
+    Writeln (stderr, 'Connection to database ',dbname,' failed.');
+    Writeln (stderr, PQerrorMessage(conn));
+    exit_nicely(conn);
+    end;
+
+
+  { start a transaction block }
+  res := PQexec(conn, 'BEGIN');
+  if (PQresultStatus(res) <> PGRES_COMMAND_OK) then
+    begin
+    Writeln (stderr, 'BEGIN command failed');
+    PQclear(res);
+    exit_nicely(conn);
+    end;
+
+  {
+   * should PQclear PGresult whenever it is no longer needed to avoid
+   * memory leaks
+   }
+  PQclear(res);
+
+  {
+   * fetch instances from the pg_database, the system catalog of
+   * databases
+   }
+  res := PQexec(conn, 'DECLARE myportal CURSOR FOR select * from pg_database');
+  if (PQresultStatus(res) <> PGRES_COMMAND_OK) then
+    begin
+    Writeln (stderr, 'DECLARE CURSOR command failed');
+    PQclear(res);
+    exit_nicely(conn);
+    end;
+  PQclear(res);
+
+  res := PQexec(conn, 'FETCH ALL in myportal');
+  if (PQresultStatus(res) <> PGRES_TUPLES_OK) then
+    begin
+    Writeln (stderr, 'FETCH ALL command didn''t return tuples properly');
+    PQclear(res);
+    exit_nicely(conn);
+    end;
+
+  { first, print out the attribute names }
+  nFields := PQnfields(res);
+  for i := 0 to nFields-1 do
+    Write (PQfname(res, i),space (15-strlen(PQfname(res, i))) );
+  writeln;
+  writeln;
+
+  { next, print out the instances }
+  for i := 0 to PQntuples(res)-1 do
+    begin
+    for j := 0 to nFields-1 do
+      write(PQgetvalue(res, i, j),space (15-strlen(PQgetvalue(res, i,j))));
+    writeln;
+    end;
+
+  PQclear(res);
+
+  { close the portal }
+  res := PQexec(conn, 'CLOSE myportal');
+  PQclear(res);
+
+  { end the transaction }
+  res := PQexec(conn, 'END');
+  PQclear(res);
+
+  { close the connection to the database and cleanup }
+  PQfinish(conn);
+
+end.  $Log$
+end.  Revision 1.1  2002-01-29 17:54:56  peter
+end.    * splitted to base and extra
+end.
+end.  Revision 1.2  2000/07/13 11:33:30  michael
+end.  + removed logs
+end. 
+}

+ 85 - 0
packages/base/postgres/testpg2.pp

@@ -0,0 +1,85 @@
+Program testpg;
+
+{ Demo program to test pascal connection with postgres database }
+{ Translated from the testlibpq example program of PostGreSQL   }
+
+Uses postgres,strings;
+
+
+Procedure exit_nicely(Conn : PPGconn);
+
+begin
+  PQfinish(conn);
+  halt(1);
+end;
+
+
+Var
+  pghost,pgport,pgoptions,pgtty,dbname : Pchar;
+  nFields,i : longint;
+  conn : PPGConn;
+  res : PPGresult;
+  dummy : string;
+
+begin
+  pghost := NiL;        { host name of the backend server }
+  pgport := NiL;        { port of the backend server }
+  pgoptions := NiL;     { special options to start up the backend server }
+  pgtty := NiL;         { debugging tty for the backend server }
+  if paramcount=1 then
+    begin
+    dummy:=paramstr(1)+#0;
+    dbname:=@dummy[1];
+    end
+  else
+    dbName := 'testdb';
+
+  { make a connection to the database }
+  conn := PQsetdb(pghost, pgport, pgoptions, pgtty, dbName);
+
+  { check to see that the backend connection was successfully made }
+  if (PQstatus(conn) = CONNECTION_BAD) then
+    begin
+    Writeln (stderr, 'Connection to database ',dbname,' failed.');
+    Writeln (stderr, PQerrorMessage(conn));
+    exit_nicely(conn);
+    end;
+
+  res := PQexec(conn, 'select * from email');
+  if (PQresultStatus(res) <> PGRES_TUPLES_OK) then
+    begin
+    Writeln (stderr, 'select command failed.');
+    PQclear(res);
+    exit_nicely(conn);
+    end;
+
+
+  { first, print out the attribute names }
+  nFields := PQnfields(res);
+  Write ('|',PQfname(res, 0),space (4-strlen(PQfname(res, 0))) );
+  Write ('|',PQfname(res, 1),space (20-strlen(PQfname(res, 1))) );
+  Write ('|',PQfname(res, 2),space (40-strlen(PQfname(res, 2))) );
+  writeln ('|');
+  writeln ('+----+--------------------+----------------------------------------+');
+
+  { next, print out the instances }
+  for i := 0 to PQntuples(res)-1 do
+    begin
+    write('|',PQgetvalue(res, i, 0),space (4-strlen(PQgetvalue(res, i,0))));
+    write('|',PQgetvalue(res, i, 1),space (20-strlen(PQgetvalue(res, i,1))));
+    write('|',PQgetvalue(res, i, 2),space (40-strlen(PQgetvalue(res, i,2))));
+    writeln ('|');
+    end;
+
+  PQclear(res);
+
+  { close the connection to the database and cleanup }
+  PQfinish(conn);
+end.  $Log$
+end.  Revision 1.1  2002-01-29 17:54:56  peter
+end.    * splitted to base and extra
+end.
+end.  Revision 1.2  2000/07/13 11:33:30  michael
+end.  + removed logs
+end. 
+}

+ 1235 - 0
packages/base/regexpr/Makefile

@@ -0,0 +1,1235 @@
+#
+# Don't edit, this file is generated by FPCMake Version 1.1 [2002/01/29]
+#
+default: all
+MAKEFILETARGETS=linux go32v2 win32 os2 freebsd beos netbsd amiga atari sunos qnx
+override PATH:=$(subst \,/,$(PATH))
+ifeq ($(findstring ;,$(PATH)),)
+inUnix=1
+SEARCHPATH:=$(filter-out .,$(subst :, ,$(PATH)))
+else
+SEARCHPATH:=$(subst ;, ,$(PATH))
+endif
+PWD:=$(strip $(wildcard $(addsuffix /pwd.exe,$(SEARCHPATH))))
+ifeq ($(PWD),)
+PWD:=$(strip $(wildcard $(addsuffix /pwd,$(SEARCHPATH))))
+ifeq ($(PWD),)
+$(error You need the GNU utils package to use this Makefile)
+else
+PWD:=$(firstword $(PWD))
+SRCEXEEXT=
+endif
+else
+PWD:=$(firstword $(PWD))
+SRCEXEEXT=.exe
+endif
+ifndef inUnix
+ifeq ($(OS),Windows_NT)
+inWinNT=1
+else
+ifdef OS2_SHELL
+inOS2=1
+endif
+endif
+else
+ifneq ($(findstring cygwin,$(MACHTYPE)),)
+inCygWin=1
+endif
+endif
+ifeq ($(OS_TARGET),freebsd)
+BSDhier=1
+endif
+ifeq ($(OS_TARGET),netbsd)
+BSDhier=1
+endif
+ifdef inUnix
+BATCHEXT=.sh
+else
+ifdef inOS2
+BATCHEXT=.cmd
+else
+BATCHEXT=.bat
+endif
+endif
+ifdef inUnix
+PATHSEP=/
+else
+PATHSEP:=$(subst /,\,/)
+endif
+ifdef PWD
+BASEDIR:=$(subst \,/,$(shell $(PWD)))
+ifdef inCygWin
+ifneq ($(findstring /cygdrive/,$(BASEDIR)),)
+BASENODIR:=$(patsubst /cygdrive%,%,$(BASEDIR))
+BASEDRIVE:=$(firstword $(subst /, ,$(BASENODIR)))
+BASEDIR:=$(subst /cygdrive/$(BASEDRIVE)/,$(BASEDRIVE):/,$(BASEDIR))
+endif
+endif
+else
+BASEDIR=.
+endif
+override DEFAULT_FPCDIR=../../..
+ifndef FPC
+ifdef PP
+FPC=$(PP)
+endif
+endif
+ifndef FPC
+FPCPROG:=$(strip $(wildcard $(addsuffix /fpc$(SRCEXEEXT),$(SEARCHPATH))))
+ifneq ($(FPCPROG),)
+FPCPROG:=$(firstword $(FPCPROG))
+FPC:=$(shell $(FPCPROG) -PB)
+ifneq ($(findstring Error,$(FPC)),)
+override FPC=ppc386
+endif
+else
+override FPC=ppc386
+endif
+endif
+override FPC:=$(subst $(SRCEXEEXT),,$(FPC))
+override FPC:=$(subst \,/,$(FPC))$(SRCEXEEXT)
+ifndef FPC_VERSION
+FPC_VERSION:=$(shell $(FPC) -iV)
+endif
+export FPC FPC_VERSION
+ifeq ($(findstring 1.0.,$(FPC_VERSION)),)
+COMPILERINFO:=$(shell $(FPC) -iSP -iTP -iSO -iTO)
+ifndef CPU_SOURCE
+CPU_SOURCE:=$(word 1,$(COMPILERINFO))
+endif
+ifndef CPU_TARGET
+CPU_TARGET:=$(word 2,$(COMPILERINFO))
+endif
+ifndef OS_SOURCE
+OS_SOURCE:=$(word 3,$(COMPILERINFO))
+endif
+ifndef OS_TARGET
+OS_TARGET:=$(word 4,$(COMPILERINFO))
+endif
+else
+ifndef CPU_SOURCE
+CPU_SOURCE:=$(shell $(FPC) -iSP)
+endif
+ifndef CPU_TARGET
+CPU_TARGET:=$(shell $(FPC) -iTP)
+endif
+ifndef OS_SOURCE
+OS_SOURCE:=$(shell $(FPC) -iSO)
+endif
+ifndef OS_TARGET
+OS_TARGET:=$(shell $(FPC) -iTO)
+endif
+endif
+FULL_TARGET=$(CPU_TARGET)-$(OS_TARGET)
+FULL_SOURCE=$(CPU_SOURCE)-$(OS_SOURCE)
+ifneq ($(FULL_TARGET),$(FULL_SOURCE))
+CROSSCOMPILE=1
+endif
+ifeq ($(findstring makefile,$(MAKECMDGOALS)),)
+ifeq ($(findstring $(OS_TARGET),$(MAKEFILETARGETS)),)
+$(error The Makefile doesn't support target $(OS_TARGET), please run fpcmake first)
+endif
+endif
+export OS_TARGET OS_SOURCE CPU_TARGET CPU_SOURCE FULL_TARGET FULL_SOURCE CROSSCOMPILE
+ifdef FPCDIR
+override FPCDIR:=$(subst \,/,$(FPCDIR))
+ifeq ($(wildcard $(addprefix $(FPCDIR)/,rtl units)),)
+override FPCDIR=wrong
+endif
+else
+override FPCDIR=wrong
+endif
+ifdef DEFAULT_FPCDIR
+ifeq ($(FPCDIR),wrong)
+override FPCDIR:=$(subst \,/,$(DEFAULT_FPCDIR))
+ifeq ($(wildcard $(addprefix $(FPCDIR)/,rtl units)),)
+override FPCDIR=wrong
+endif
+endif
+endif
+ifeq ($(FPCDIR),wrong)
+ifdef inUnix
+override FPCDIR=/usr/local/lib/fpc/$(FPC_VERSION)
+ifeq ($(wildcard $(FPCDIR)/units),)
+override FPCDIR=/usr/lib/fpc/$(FPC_VERSION)
+endif
+else
+override FPCDIR:=$(subst /$(FPC),,$(firstword $(strip $(wildcard $(addsuffix /$(FPC),$(SEARCHPATH))))))
+override FPCDIR:=$(FPCDIR)/..
+ifeq ($(wildcard $(addprefix $(FPCDIR)/,rtl units)),)
+override FPCDIR:=$(FPCDIR)/..
+ifeq ($(wildcard $(addprefix $(FPCDIR)/,rtl units)),)
+override FPCDIR=c:/pp
+endif
+endif
+endif
+endif
+ifndef CROSSDIR
+CROSSDIR:=$(FPCDIR)/cross/$(FULL_TARGET)
+endif
+ifndef CROSSTARGETDIR
+CROSSTARGETDIR=$(CROSSDIR)/$(FULL_TARGET)
+endif
+ifdef CROSSCOMPILE
+UNITSDIR:=$(wildcard $(CROSSTARGETDIR)/units)
+ifeq ($(UNITSDIR),)
+UNITSDIR:=$(wildcard $(FPCDIR)/units/$(OS_TARGET))
+endif
+else
+UNITSDIR:=$(wildcard $(FPCDIR)/units/$(OS_TARGET))
+endif
+PACKAGESDIR:=$(wildcard $(FPCDIR) $(FPCDIR)/packages/base $(FPCDIR)/packages/extra)
+override PACKAGE_NAME=regexpr
+override PACKAGE_VERSION=1.0.6
+override TARGET_UNITS+=regexpr
+override TARGET_EXAMPLES+=testreg1
+override INSTALL_FPCPACKAGE=y
+override COMPILER_OPTIONS+=-S2
+ifdef REQUIRE_UNITSDIR
+override UNITSDIR+=$(REQUIRE_UNITSDIR)
+endif
+ifdef REQUIRE_PACKAGESDIR
+override PACKAGESDIR+=$(REQUIRE_PACKAGESDIR)
+endif
+ifdef ZIPINSTALL
+ifeq ($(OS_TARGET),linux)
+UNIXINSTALLDIR=1
+endif
+ifeq ($(OS_TARGET),freebsd)
+UNIXINSTALLDIR=1
+endif
+ifeq ($(OS_TARGET),netbsd)
+UNIXINSTALLDIR=1
+endif
+ifeq ($(OS_TARGET),sunos)
+UNIXINSTALLDIR=1
+endif
+else
+ifeq ($(OS_SOURCE),linux)
+UNIXINSTALLDIR=1
+endif
+ifeq ($(OS_SOURCE),freebsd)
+UNIXINSTALLDIR=1
+endif
+ifeq ($(OS_SOURCE),netbsd)
+UNIXINSTALLDIR=1
+endif
+ifeq ($(OS_TARGET),sunos)
+UNIXINSTALLDIR=1
+endif
+endif
+ifndef INSTALL_PREFIX
+ifdef PREFIX
+INSTALL_PREFIX=$(PREFIX)
+endif
+endif
+ifndef INSTALL_PREFIX
+ifdef UNIXINSTALLDIR
+INSTALL_PREFIX=/usr/local
+else
+ifdef INSTALL_FPCPACKAGE
+INSTALL_BASEDIR:=/pp
+else
+INSTALL_BASEDIR:=/$(PACKAGE_NAME)
+endif
+endif
+endif
+export INSTALL_PREFIX
+ifndef DIST_DESTDIR
+DIST_DESTDIR:=$(BASEDIR)
+endif
+export DIST_DESTDIR
+ifndef INSTALL_BASEDIR
+ifdef UNIXINSTALLDIR
+ifdef INSTALL_FPCPACKAGE
+INSTALL_BASEDIR:=$(INSTALL_PREFIX)/lib/fpc/$(FPC_VERSION)
+else
+INSTALL_BASEDIR:=$(INSTALL_PREFIX)/lib/$(PACKAGE_NAME)
+endif
+else
+INSTALL_BASEDIR:=$(INSTALL_PREFIX)
+endif
+endif
+ifndef INSTALL_BINDIR
+ifdef UNIXINSTALLDIR
+INSTALL_BINDIR:=$(INSTALL_PREFIX)/bin
+else
+INSTALL_BINDIR:=$(INSTALL_BASEDIR)/bin
+ifdef INSTALL_FPCPACKAGE
+INSTALL_BINDIR:=$(INSTALL_BINDIR)/$(OS_TARGET)
+endif
+endif
+endif
+ifndef INSTALL_UNITDIR
+ifdef CROSSCOMPILE
+INSTALL_UNITDIR:=$(INSTALL_BASEDIR)/cross/$(FULL_TARGET)/units
+else
+INSTALL_UNITDIR:=$(INSTALL_BASEDIR)/units/$(OS_TARGET)
+endif
+ifdef INSTALL_FPCPACKAGE
+ifdef PACKAGE_NAME
+INSTALL_UNITDIR:=$(INSTALL_UNITDIR)/$(PACKAGE_NAME)
+endif
+endif
+endif
+ifndef INSTALL_LIBDIR
+ifdef UNIXINSTALLDIR
+INSTALL_LIBDIR:=$(INSTALL_PREFIX)/lib
+else
+INSTALL_LIBDIR:=$(INSTALL_UNITDIR)
+endif
+endif
+ifndef INSTALL_SOURCEDIR
+ifdef UNIXINSTALLDIR
+ifdef INSTALL_FPCPACKAGE
+ifdef BSDhier
+INSTALL_SOURCEDIR:=$(INSTALL_PREFIX)/share/src/fpc-$(FPC_VERSION)/$(PACKAGE_NAME)
+else
+INSTALL_SOURCEDIR:=$(INSTALL_PREFIX)/src/fpc-$(FPC_VERSION)/$(PACKAGE_NAME)
+endif
+else
+ifdef BSDhier
+INSTALL_SOURCEDIR:=$(INSTALL_PREFIX)/share/src/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
+else
+INSTALL_SOURCEDIR:=$(INSTALL_PREFIX)/src/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
+endif
+endif
+else
+ifdef INSTALL_FPCPACKAGE
+INSTALL_SOURCEDIR:=$(INSTALL_BASEDIR)/source/$(PACKAGE_NAME)
+else
+INSTALL_SOURCEDIRL:=$(INSTALL_BASEDIR)/source
+endif
+endif
+endif
+ifndef INSTALL_DOCDIR
+ifdef UNIXINSTALLDIR
+ifdef INSTALL_FPCPACKAGE
+ifdef BSDhier
+INSTALL_DOCDIR:=$(INSTALL_PREFIX)/share/doc/fpc-$(FPC_VERSION)/$(PACKAGE_NAME)
+else
+INSTALL_DOCDIR:=$(INSTALL_PREFIX)/doc/fpc-$(FPC_VERSION)/$(PACKAGE_NAME)
+endif
+else
+ifdef BSDhier
+INSTALL_DOCDIR:=$(INSTALL_PREFIX)/share/doc/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
+else
+INSTALL_DOCDIR:=$(INSTALL_PREFIX)/doc/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
+endif
+endif
+else
+ifdef INSTALL_FPCPACKAGE
+INSTALL_DOCDIR:=$(INSTALL_BASEDIR)/doc/$(PACKAGE_NAME)
+else
+INSTALL_DOCDIR:=$(INSTALL_BASEDIR)/doc
+endif
+endif
+endif
+ifndef INSTALL_EXAMPLEDIR
+ifdef UNIXINSTALLDIR
+ifdef INSTALL_FPCPACKAGE
+ifdef BSDhier
+INSTALL_EXAMPLEDIR:=$(INSTALL_PREFIX)/share/examples/fpc-$(FPC_VERSION)/$(PACKAGE_NAME)
+else
+INSTALL_EXAMPLEDIR:=$(INSTALL_PREFIX)/doc/fpc-$(FPC_VERSION)/examples/$(PACKAGE_NAME)
+endif
+else
+ifdef BSDhier
+INSTALL_EXAMPLEDIR:=$(INSTALL_PREFIX)/share/examples/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
+else
+INSTALL_EXAMPLEDIR:=$(INSTALL_PREFIX)/doc/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
+endif
+endif
+else
+ifdef INSTALL_FPCPACKAGE
+INSTALL_EXAMPLEDIR:=$(INSTALL_BASEDIR)/examples/$(PACKAGE_NAME)
+else
+INSTALL_EXAMPLEDIR:=$(INSTALL_BASEDIR)/examples
+endif
+endif
+endif
+ifndef INSTALL_DATADIR
+INSTALL_DATADIR=$(INSTALL_BASEDIR)
+endif
+ifdef CROSSCOMPILE
+ifndef CROSSBINDIR
+CROSSBINDIR:=$(wildcard $(CROSSTARGETDIR)/bin/$(FULL_SOURCE))
+ifeq ($(CROSSBINDIR),)
+CROSSBINDIR:=$(wildcard $(INSTALL_BASEDIR)/cross/$(FULL_TARGET)/bin/$(FULL_SOURCE))
+endif
+endif
+else
+CROSSBINDIR=
+endif
+LOADEREXT=.as
+EXEEXT=.exe
+PPLEXT=.ppl
+PPUEXT=.ppu
+OEXT=.o
+ASMEXT=.s
+SMARTEXT=.sl
+STATICLIBEXT=.a
+SHAREDLIBEXT=.so
+STATICLIBPREFIX=libp
+RSTEXT=.rst
+FPCMADE=fpcmade
+ifeq ($(OS_TARGET),go32v1)
+PPUEXT=.pp1
+OEXT=.o1
+ASMEXT=.s1
+SMARTEXT=.sl1
+STATICLIBEXT=.a1
+SHAREDLIBEXT=.so1
+STATICLIBPREFIX=
+FPCMADE=fpcmade.v1
+PACKAGESUFFIX=v1
+endif
+ifeq ($(OS_TARGET),go32v2)
+STATICLIBPREFIX=
+FPCMADE=fpcmade.dos
+ZIPSUFFIX=go32
+endif
+ifeq ($(OS_TARGET),linux)
+EXEEXT=
+HASSHAREDLIB=1
+FPCMADE=fpcmade.lnx
+ZIPSUFFIX=linux
+endif
+ifeq ($(OS_TARGET),freebsd)
+EXEEXT=
+HASSHAREDLIB=1
+FPCMADE=fpcmade.freebsd
+ZIPSUFFIX=freebsd
+endif
+ifeq ($(OS_TARGET),netbsd)
+EXEEXT=
+HASSHAREDLIB=1
+FPCMADE=fpcmade.netbsd
+ZIPSUFFIX=netbsd
+endif
+ifeq ($(OS_TARGET),win32)
+PPUEXT=.ppw
+OEXT=.ow
+ASMEXT=.sw
+SMARTEXT=.slw
+STATICLIBEXT=.aw
+SHAREDLIBEXT=.dll
+FPCMADE=fpcmade.w32
+ZIPSUFFIX=w32
+endif
+ifeq ($(OS_TARGET),os2)
+PPUEXT=.ppo
+ASMEXT=.so2
+OEXT=.oo2
+AOUTEXT=.out
+SMARTEXT=.so
+STATICLIBEXT=.ao2
+SHAREDLIBEXT=.dll
+FPCMADE=fpcmade.os2
+ZIPSUFFIX=emx
+endif
+ifeq ($(OS_TARGET),amiga)
+EXEEXT=
+PPUEXT=.ppa
+ASMEXT=.asm
+OEXT=.o
+SMARTEXT=.sl
+STATICLIBEXT=.a
+SHAREDLIBEXT=.library
+FPCMADE=fpcmade.amg
+endif
+ifeq ($(OS_TARGET),atari)
+PPUEXT=.ppt
+ASMEXT=.s
+OEXT=.o
+SMARTEXT=.sl
+STATICLIBEXT=.a
+EXEEXT=.ttp
+FPCMADE=fpcmade.ata
+endif
+ifeq ($(OS_TARGET),beos)
+PPUEXT=.ppu
+ASMEXT=.s
+OEXT=.o
+SMARTEXT=.sl
+STATICLIBEXT=.a
+EXEEXT=
+FPCMADE=fpcmade.be
+ZIPSUFFIX=be
+endif
+ifeq ($(OS_TARGET),sunos)
+PPUEXT=.ppu
+ASMEXT=.s
+OEXT=.o
+SMARTEXT=.sl
+STATICLIBEXT=.a
+EXEEXT=
+FPCMADE=fpcmade.sun
+ZIPSUFFIX=sun
+endif
+ifeq ($(OS_TARGET),qnx)
+PPUEXT=.ppu
+ASMEXT=.s
+OEXT=.o
+SMARTEXT=.sl
+STATICLIBEXT=.a
+EXEEXT=
+FPCMADE=fpcmade.qnx
+ZIPSUFFIX=qnx
+endif
+ifndef ECHO
+ECHO:=$(strip $(wildcard $(addsuffix /gecho$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(ECHO),)
+ECHO:=$(strip $(wildcard $(addsuffix /echo$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(ECHO),)
+ECHO=
+else
+ECHO:=$(firstword $(ECHO))
+endif
+else
+ECHO:=$(firstword $(ECHO))
+endif
+endif
+export ECHO
+ifndef DATE
+DATE:=$(strip $(wildcard $(addsuffix /gdate$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(DATE),)
+DATE:=$(strip $(wildcard $(addsuffix /date$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(DATE),)
+DATE=
+else
+DATE:=$(firstword $(DATE))
+endif
+else
+DATE:=$(firstword $(DATE))
+endif
+endif
+export DATE
+ifndef GINSTALL
+GINSTALL:=$(strip $(wildcard $(addsuffix /ginstall$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(GINSTALL),)
+GINSTALL:=$(strip $(wildcard $(addsuffix /install$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(GINSTALL),)
+GINSTALL=
+else
+GINSTALL:=$(firstword $(GINSTALL))
+endif
+else
+GINSTALL:=$(firstword $(GINSTALL))
+endif
+endif
+export GINSTALL
+ifndef CPPROG
+CPPROG:=$(strip $(wildcard $(addsuffix /cp$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(CPPROG),)
+CPPROG=
+else
+CPPROG:=$(firstword $(CPPROG))
+endif
+endif
+export CPPROG
+ifndef RMPROG
+RMPROG:=$(strip $(wildcard $(addsuffix /rm$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(RMPROG),)
+RMPROG=
+else
+RMPROG:=$(firstword $(RMPROG))
+endif
+endif
+export RMPROG
+ifndef MVPROG
+MVPROG:=$(strip $(wildcard $(addsuffix /mv$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(MVPROG),)
+MVPROG=
+else
+MVPROG:=$(firstword $(MVPROG))
+endif
+endif
+export MVPROG
+ifndef ECHOREDIR
+ECHOREDIR:=$(subst /,$(PATHSEP),$(ECHO))
+endif
+ifndef COPY
+COPY:=$(CPPROG) -fp
+endif
+ifndef COPYTREE
+COPYTREE:=$(CPPROG) -rfp
+endif
+ifndef MOVE
+MOVE:=$(MVPROG) -f
+endif
+ifndef DEL
+DEL:=$(RMPROG) -f
+endif
+ifndef DELTREE
+DELTREE:=$(RMPROG) -rf
+endif
+ifndef INSTALL
+ifdef inUnix
+INSTALL:=$(GINSTALL) -c -m 644
+else
+INSTALL:=$(COPY)
+endif
+endif
+ifndef INSTALLEXE
+ifdef inUnix
+INSTALLEXE:=$(GINSTALL) -c -m 755
+else
+INSTALLEXE:=$(COPY)
+endif
+endif
+ifndef MKDIR
+MKDIR:=$(GINSTALL) -m 755 -d
+endif
+export ECHOREDIR COPY COPYTREE MOVE DEL DELTREE INSTALL INSTALLEXE MKDIR
+ifndef PPUMOVE
+PPUMOVE:=$(strip $(wildcard $(addsuffix /ppumove$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(PPUMOVE),)
+PPUMOVE=
+else
+PPUMOVE:=$(firstword $(PPUMOVE))
+endif
+endif
+export PPUMOVE
+ifndef FPCMAKE
+FPCMAKE:=$(strip $(wildcard $(addsuffix /fpcmake$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(FPCMAKE),)
+FPCMAKE=
+else
+FPCMAKE:=$(firstword $(FPCMAKE))
+endif
+endif
+export FPCMAKE
+ifndef ZIPPROG
+ZIPPROG:=$(strip $(wildcard $(addsuffix /zip$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(ZIPPROG),)
+ZIPPROG=
+else
+ZIPPROG:=$(firstword $(ZIPPROG))
+endif
+endif
+export ZIPPROG
+ifndef TARPROG
+TARPROG:=$(strip $(wildcard $(addsuffix /tar$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(TARPROG),)
+TARPROG=
+else
+TARPROG:=$(firstword $(TARPROG))
+endif
+endif
+export TARPROG
+ASNAME=as
+LDNAME=ld
+ARNAME=ar
+RCNAME=rc
+ifeq ($(OS_TARGET),win32)
+ASNAME=asw
+LDNAME=ldw
+ARNAME=arw
+endif
+ifndef ASPROG
+ifdef CROSSBINDIR
+ASPROG=$(CROSSBINDIR)/$(ASNAME)$(SRCEXEEXT)
+else
+ASPROG=$(ASNAME)
+endif
+endif
+ifndef LDPROG
+ifdef CROSSBINDIR
+LDPROG=$(CROSSBINDIR)/$(LDNAME)$(SRCEXEEXT)
+else
+LDPROG=$(LDNAME)
+endif
+endif
+ifndef RCPROG
+ifdef CROSSBINDIR
+RCPROG=$(CROSSBINDIR)/$(RCNAME)$(SRCEXEEXT)
+else
+RCPROG=$(RCNAME)
+endif
+endif
+ifndef ARPROG
+ifdef CROSSBINDIR
+ARPROG=$(CROSSBINDIR)/$(ARNAME)$(SRCEXEEXT)
+else
+ARPROG=$(ARNAME)
+endif
+endif
+AS=$(ASPROG)
+LD=$(LDPROG)
+RC=$(RCPROG)
+AR=$(ARPROG)
+PPAS=ppas$(BATCHEXT)
+ifdef inUnix
+LDCONFIG=ldconfig
+else
+LDCONFIG=
+endif
+ifdef DATE
+DATESTR:=$(shell $(DATE) +%Y%m%d)
+else
+DATESTR=
+endif
+ifndef UPXPROG
+ifeq ($(OS_TARGET),go32v2)
+UPXPROG:=1
+endif
+ifeq ($(OS_TARGET),win32)
+UPXPROG:=1
+endif
+ifdef UPXPROG
+UPXPROG:=$(strip $(wildcard $(addsuffix /upx$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(UPXPROG),)
+UPXPROG=
+else
+UPXPROG:=$(firstword $(UPXPROG))
+endif
+else
+UPXPROG=
+endif
+endif
+export UPXPROG
+ZIPOPT=-9
+ZIPEXT=.zip
+ifeq ($(USETAR),bz2)
+TAROPT=vI
+TAREXT=.tar.bz2
+else
+TAROPT=vz
+TAREXT=.tar.gz
+endif
+override REQUIRE_PACKAGES=rtl 
+ifeq ($(OS_TARGET),linux)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(OS_TARGET),go32v2)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(OS_TARGET),win32)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(OS_TARGET),os2)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(OS_TARGET),freebsd)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(OS_TARGET),beos)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(OS_TARGET),netbsd)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(OS_TARGET),amiga)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(OS_TARGET),atari)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(OS_TARGET),sunos)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(OS_TARGET),qnx)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifdef REQUIRE_PACKAGES_RTL
+PACKAGEDIR_RTL:=$(firstword $(subst /Makefile.fpc,,$(strip $(wildcard $(addsuffix /rtl/$(OS_TARGET)/Makefile.fpc,$(PACKAGESDIR))))))
+ifneq ($(PACKAGEDIR_RTL),)
+ifneq ($(wildcard $(PACKAGEDIR_RTL)/$(OS_TARGET)),)
+UNITDIR_RTL=$(PACKAGEDIR_RTL)/$(OS_TARGET)
+else
+UNITDIR_RTL=$(PACKAGEDIR_RTL)
+endif
+else
+PACKAGEDIR_RTL=
+UNITDIR_RTL:=$(subst /Package.fpc,,$(strip $(wildcard $(addsuffix /rtl/Package.fpc,$(UNITSDIR)))))
+ifneq ($(UNITDIR_RTL),)
+UNITDIR_RTL:=$(firstword $(UNITDIR_RTL))
+else
+UNITDIR_RTL=
+endif
+endif
+ifdef UNITDIR_RTL
+override COMPILER_UNITDIR+=$(UNITDIR_RTL)
+endif
+endif
+ifndef NOCPUDEF
+override FPCOPTDEF=$(CPU_TARGET)
+endif
+ifneq ($(OS_TARGET),$(OS_SOURCE))
+override FPCOPT+=-T$(OS_TARGET)
+endif
+ifdef UNITDIR
+override FPCOPT+=$(addprefix -Fu,$(UNITDIR))
+endif
+ifdef LIBDIR
+override FPCOPT+=$(addprefix -Fl,$(LIBDIR))
+endif
+ifdef OBJDIR
+override FPCOPT+=$(addprefix -Fo,$(OBJDIR))
+endif
+ifdef INCDIR
+override FPCOPT+=$(addprefix -Fi,$(INCDIR))
+endif
+ifdef LINKSMART
+override FPCOPT+=-XX
+endif
+ifdef CREATESMART
+override FPCOPT+=-CX
+endif
+ifdef DEBUG
+override FPCOPT+=-gl
+override FPCOPTDEF+=DEBUG
+endif
+ifdef RELEASE
+ifeq ($(CPU_TARGET),i386)
+FPCCPUOPT:=-OG2p3
+else
+FPCCPUOPT:=
+endif
+override FPCOPT+=-Xs $(FPCCPUOPT) -n
+override FPCOPTDEF+=RELEASE
+endif
+ifdef STRIP
+override FPCOPT+=-Xs
+endif
+ifdef OPTIMIZE
+ifeq ($(CPU_TARGET),i386)
+override FPCOPT+=-OG2p3
+endif
+endif
+ifdef VERBOSE
+override FPCOPT+=-vwni
+endif
+ifdef COMPILER_OPTIONS
+override FPCOPT+=$(COMPILER_OPTIONS)
+endif
+ifdef COMPILER_UNITDIR
+override FPCOPT+=$(addprefix -Fu,$(COMPILER_UNITDIR))
+endif
+ifdef COMPILER_LIBRARYDIR
+override FPCOPT+=$(addprefix -Fl,$(COMPILER_LIBRARYDIR))
+endif
+ifdef COMPILER_OBJECTDIR
+override FPCOPT+=$(addprefix -Fo,$(COMPILER_OBJECTDIR))
+endif
+ifdef COMPILER_INCLUDEDIR
+override FPCOPT+=$(addprefix -Fi,$(COMPILER_INCLUDEDIR))
+endif
+ifdef CROSSBINDIR
+override FPCOPT+=-FD$(CROSSBINDIR)
+endif
+ifdef COMPILER_TARGETDIR
+override FPCOPT+=-FE$(COMPILER_TARGETDIR)
+ifeq ($(COMPILER_TARGETDIR),.)
+override TARGETDIRPREFIX=
+else
+override TARGETDIRPREFIX=$(COMPILER_TARGETDIR)/
+endif
+endif
+ifdef COMPILER_UNITTARGETDIR
+override FPCOPT+=-FU$(COMPILER_UNITTARGETDIR)
+ifeq ($(COMPILER_UNITTARGETDIR),.)
+override UNITTARGETDIRPREFIX=
+else
+override UNITTARGETDIRPREFIX=$(COMPILER_UNITTARGETDIR)/
+endif
+else
+ifdef COMPILER_TARGETDIR
+override COMPILER_UNITTARGETDIR=$(COMPILER_TARGETDIR)
+override UNITTARGETDIRPREFIX=$(TARGETDIRPREFIX)
+endif
+endif
+ifdef OPT
+override FPCOPT+=$(OPT)
+endif
+ifdef FPCOPTDEF
+override FPCOPT+=$(addprefix -d,$(FPCOPTDEF))
+endif
+ifdef CFGFILE
+override FPCOPT+=@$(CFGFILE)
+endif
+ifdef USEENV
+override FPCEXTCMD:=$(FPCOPT)
+override FPCOPT:=!FPCEXTCMD
+export FPCEXTCMD
+endif
+override COMPILER:=$(FPC) $(FPCOPT)
+ifeq (,$(findstring -s ,$(COMPILER)))
+EXECPPAS=
+else
+ifeq ($(OS_SOURCE),$(OS_TARGET))
+EXECPPAS:=@$(PPAS)
+endif
+endif
+.PHONY: fpc_units
+ifdef TARGET_UNITS
+override ALLTARGET+=fpc_units
+override UNITPPUFILES=$(addsuffix $(PPUEXT),$(TARGET_UNITS))
+override IMPLICITUNITPPUFILES=$(addsuffix $(PPUEXT),$(TARGET_IMPLICITUNITS))
+override INSTALLPPUFILES+=$(UNITPPUFILES) $(IMPLICITUNITPPUFILES)
+override CLEANPPUFILES+=$(UNITPPUFILES) $(IMPLICITUNITPPUFILES)
+endif
+fpc_units: $(UNITPPUFILES)
+ifdef TARGET_RSTS
+override RSTFILES=$(addsuffix $(RSTEXT),$(TARGET_RSTS))
+override CLEANRSTFILES+=$(RSTFILES)
+endif
+.PHONY: fpc_examples
+ifdef TARGET_EXAMPLES
+HASEXAMPLES=1
+override EXAMPLESOURCEFILES:=$(wildcard $(addsuffix .pp,$(TARGET_EXAMPLES)) $(addsuffix .pas,$(TARGET_EXAMPLES)))
+override EXAMPLEFILES:=$(addsuffix $(EXEEXT),$(TARGET_EXAMPLES))
+override EXAMPLEOFILES:=$(addsuffix $(OEXT),$(TARGET_EXAMPLES)) $(addprefix $(STATICLIBPREFIX),$(addsuffix $(STATICLIBEXT),$(TARGET_EXAMPLES)))
+override CLEANEXEFILES+=$(EXAMPLEFILES) $(EXAMPLEOFILES)
+ifeq ($(OS_TARGET),os2)
+override CLEANEXEFILES+=$(addsuffix $(AOUTEXT),$(TARGET_EXAMPLES))
+endif
+endif
+ifdef TARGET_EXAMPLEDIRS
+HASEXAMPLES=1
+endif
+fpc_examples: all $(EXAMPLEFILES) $(addsuffix _all,$(TARGET_EXAMPLEDIRS))
+.PHONY: fpc_all fpc_smart fpc_debug fpc_release
+$(FPCMADE): $(ALLTARGET)
+	@$(ECHOREDIR) Compiled > $(FPCMADE)
+fpc_all: $(FPCMADE)
+fpc_smart:
+	$(MAKE) all LINKSMART=1 CREATESMART=1
+fpc_debug:
+	$(MAKE) all DEBUG=1
+fpc_release:
+	$(MAKE) all RELEASE=1
+.SUFFIXES: $(EXEEXT) $(PPUEXT) $(OEXT) .pas .pp .rc .res
+%$(PPUEXT): %.pp
+	$(COMPILER) $<
+	$(EXECPPAS)
+%$(PPUEXT): %.pas
+	$(COMPILER) $<
+	$(EXECPPAS)
+%$(EXEEXT): %.pp
+	$(COMPILER) $<
+	$(EXECPPAS)
+%$(EXEEXT): %.pas
+	$(COMPILER) $<
+	$(EXECPPAS)
+%.res: %.rc
+	windres -i $< -o $@
+vpath %.pp $(COMPILER_SOURCEDIR) $(COMPILER_INCLUDEDIR)
+vpath %.pas $(COMPILER_SOURCEDIR) $(COMPILER_INCLUDEDIR)
+vpath %$(PPUEXT) $(COMPILER_UNITTARGETDIR)
+.PHONY: fpc_install fpc_sourceinstall fpc_exampleinstall
+ifdef INSTALL_UNITS
+override INSTALLPPUFILES+=$(addsuffix $(PPUEXT),$(INSTALL_UNITS))
+endif
+ifdef INSTALL_BUILDUNIT
+override INSTALLPPUFILES:=$(filter-out $(INSTALL_BUILDUNIT),$(INSTALLPPUFILES))
+endif
+ifdef INSTALLPPUFILES
+override INSTALLPPULINKFILES:=$(subst $(PPUEXT),$(OEXT),$(INSTALLPPUFILES)) $(addprefix $(STATICLIBPREFIX),$(subst $(PPUEXT),$(STATICLIBEXT),$(INSTALLPPUFILES)))
+override INSTALLPPUFILES:=$(addprefix $(UNITTARGETDIRPREFIX),$(INSTALLPPUFILES))
+override INSTALLPPULINKFILES:=$(wildcard $(addprefix $(UNITTARGETDIRPREFIX),$(INSTALLPPULINKFILES)))
+override INSTALL_CREATEPACKAGEFPC=1
+endif
+ifdef INSTALLEXEFILES
+override INSTALLEXEFILES:=$(addprefix $(TARGETDIRPREFIX),$(INSTALLEXEFILES))
+endif
+fpc_install: all $(INSTALLTARGET)
+ifdef INSTALLEXEFILES
+	$(MKDIR) $(INSTALL_BINDIR)
+ifdef UPXPROG
+	-$(UPXPROG) $(INSTALLEXEFILES)
+endif
+	$(INSTALLEXE) $(INSTALLEXEFILES) $(INSTALL_BINDIR)
+endif
+ifdef INSTALL_CREATEPACKAGEFPC
+ifdef FPCMAKE
+ifdef PACKAGE_VERSION
+ifneq ($(wildcard Makefile.fpc),)
+	$(FPCMAKE) -p -T$(OS_TARGET) Makefile.fpc
+	$(MKDIR) $(INSTALL_UNITDIR)
+	$(INSTALL) Package.fpc $(INSTALL_UNITDIR)
+endif
+endif
+endif
+endif
+ifdef INSTALLPPUFILES
+	$(MKDIR) $(INSTALL_UNITDIR)
+	$(INSTALL) $(INSTALLPPUFILES) $(INSTALL_UNITDIR)
+ifneq ($(INSTALLPPULINKFILES),)
+	$(INSTALL) $(INSTALLPPULINKFILES) $(INSTALL_UNITDIR)
+endif
+ifneq ($(wildcard $(LIB_FULLNAME)),)
+	$(MKDIR) $(INSTALL_LIBDIR)
+	$(INSTALL) $(LIB_FULLNAME) $(INSTALL_LIBDIR)
+ifdef inUnix
+	ln -sf $(LIB_FULLNAME) $(INSTALL_LIBDIR)/$(LIB_NAME)
+endif
+endif
+endif
+ifdef INSTALL_FILES
+	$(MKDIR) $(INSTALL_DATADIR)
+	$(INSTALL) $(INSTALL_FILES) $(INSTALL_DATADIR)
+endif
+fpc_sourceinstall: distclean
+	$(MKDIR) $(INSTALL_SOURCEDIR)
+	$(COPYTREE) $(BASEDIR) $(INSTALL_SOURCEDIR)
+fpc_exampleinstall: $(addsuffix _distclean,$(TARGET_EXAMPLEDIRS))
+ifdef HASEXAMPLES
+	$(MKDIR) $(INSTALL_EXAMPLEDIR)
+endif
+ifdef EXAMPLESOURCEFILES
+	$(COPY) $(EXAMPLESOURCEFILES) $(INSTALL_EXAMPLEDIR)
+endif
+ifdef TARGET_EXAMPLEDIRS
+	$(COPYTREE) $(addsuffix /*,$(TARGET_EXAMPLEDIRS)) $(INSTALL_EXAMPLEDIR)
+endif
+.PHONY: fpc_distinstall
+fpc_distinstall: install exampleinstall
+.PHONY: fpc_zipinstall fpc_zipsourceinstall fpc_zipexampleinstall
+ifndef PACKDIR
+ifndef inUnix
+PACKDIR=$(BASEDIR)/../fpc-pack
+else
+PACKDIR=/tmp/fpc-pack
+endif
+endif
+ifndef ZIPNAME
+ifdef DIST_ZIPNAME
+ZIPNAME=$(DIST_ZIPNAME)
+else
+ZIPNAME=$(ZIPPREFIX)$(PACKAGE_NAME)$(ZIPSUFFIX)
+endif
+endif
+ifndef ZIPTARGET
+ifdef DIST_ZIPTARGET
+ZIPTARGET=DIST_ZIPTARGET
+else
+ZIPTARGET=install
+endif
+endif
+ifndef USEZIP
+ifdef inUnix
+USETAR=1
+endif
+endif
+ifndef inUnix
+USEZIPWRAPPER=1
+endif
+ifdef USEZIPWRAPPER
+ZIPPATHSEP=$(PATHSEP)
+ZIPWRAPPER=$(subst /,$(PATHSEP),$(DIST_DESTDIR)/fpczip$(BATCHEXT))
+else
+ZIPPATHSEP=/
+endif
+ZIPCMD_CDPACK:=cd $(subst /,$(ZIPPATHSEP),$(PACKDIR))
+ZIPCMD_CDBASE:=cd $(subst /,$(ZIPPATHSEP),$(BASEDIR))
+ifdef USETAR
+ZIPDESTFILE:=$(DIST_DESTDIR)/$(ZIPNAME)$(TAREXT)
+ZIPCMD_ZIP:=$(TARPROG) cf$(TAROPT) $(ZIPDESTFILE) *
+else
+ZIPDESTFILE:=$(DIST_DESTDIR)/$(ZIPNAME)$(ZIPEXT)
+ZIPCMD_ZIP:=$(subst /,$(ZIPPATHSEP),$(ZIPPROG)) -Dr $(ZIPOPT) $(ZIPDESTFILE) *
+endif
+fpc_zipinstall:
+	$(MAKE) $(ZIPTARGET) INSTALL_PREFIX=$(PACKDIR) ZIPINSTALL=1
+	$(MKDIR) $(DIST_DESTDIR)
+	$(DEL) $(ZIPDESTFILE)
+ifdef USEZIPWRAPPER
+ifneq ($(ECHOREDIR),echo)
+	$(ECHOREDIR) -e "$(subst \,\\,$(ZIPCMD_CDPACK))" > $(ZIPWRAPPER)
+	$(ECHOREDIR) -e "$(subst \,\\,$(ZIPCMD_ZIP))" >> $(ZIPWRAPPER)
+	$(ECHOREDIR) -e "$(subst \,\\,$(ZIPCMD_CDBASE))" >> $(ZIPWRAPPER)
+else
+	echo $(ZIPCMD_CDPACK) > $(ZIPWRAPPER)
+	echo $(ZIPCMD_ZIP) >> $(ZIPWRAPPER)
+	echo $(ZIPCMD_CDBASE) >> $(ZIPWRAPPER)
+endif
+ifdef inUnix
+	/bin/sh $(ZIPWRAPPER)
+else
+	$(ZIPWRAPPER)
+endif
+	$(DEL) $(ZIPWRAPPER)
+else
+	$(ZIPCMD_CDPACK) ; $(ZIPCMD_ZIP) ; $(ZIPCMD_CDBASE)
+endif
+	$(DELTREE) $(PACKDIR)
+fpc_zipsourceinstall:
+	$(MAKE) fpc_zipinstall ZIPTARGET=sourceinstall ZIPSUFFIX=src
+fpc_zipexampleinstall:
+ifdef HASEXAMPLES
+	$(MAKE) fpc_zipinstall ZIPTARGET=exampleinstall ZIPSUFFIX=exm
+endif
+fpc_zipdistinstall:
+	$(MAKE) fpc_zipinstall ZIPTARGET=distinstall
+.PHONY: fpc_clean fpc_cleanall fpc_distclean
+ifdef EXEFILES
+override CLEANEXEFILES:=$(addprefix $(TARGETDIRPREFIX),$(CLEANEXEFILES))
+endif
+ifdef CLEAN_UNITS
+override CLEANPPUFILES+=$(addsuffix $(PPUEXT),$(CLEAN_UNITS))
+endif
+ifdef CLEANPPUFILES
+override CLEANPPULINKFILES:=$(subst $(PPUEXT),$(OEXT),$(CLEANPPUFILES)) $(addprefix $(STATICLIBPREFIX),$(subst $(PPUEXT),$(STATICLIBEXT),$(CLEANPPUFILES)))
+override CLEANPPUFILES:=$(addprefix $(UNITTARGETDIRPREFIX),$(CLEANPPUFILES))
+override CLEANPPULINKFILES:=$(wildcard $(addprefix $(UNITTARGETDIRPREFIX),$(CLEANPPULINKFILES)))
+endif
+fpc_clean: $(CLEANTARGET)
+ifdef CLEANEXEFILES
+	-$(DEL) $(CLEANEXEFILES)
+endif
+ifdef CLEANPPUFILES
+	-$(DEL) $(CLEANPPUFILES)
+endif
+ifneq ($(CLEANPPULINKFILES),)
+	-$(DEL) $(CLEANPPULINKFILES)
+endif
+ifdef CLEANRSTFILES
+	-$(DEL) $(addprefix $(UNITTARGETDIRPREFIX),$(CLEANRSTFILES))
+endif
+ifdef CLEAN_FILES
+	-$(DEL) $(CLEAN_FILES)
+endif
+ifdef LIB_NAME
+	-$(DEL) $(LIB_NAME) $(LIB_FULLNAME)
+endif
+	-$(DEL) $(FPCMADE) Package.fpc $(PPAS) script.res link.res $(FPCEXTFILE) $(REDIRFILE)
+fpc_distclean: clean
+ifdef COMPILER_UNITTARGETDIR
+TARGETDIRCLEAN=fpc_clean
+endif
+fpc_cleanall: $(CLEANTARGET) $(TARGETDIRCLEAN)
+ifdef CLEANEXEFILES
+	-$(DEL) $(CLEANEXEFILES)
+endif
+	-$(DEL) *$(OEXT) *$(PPUEXT) *$(RSTEXT) *$(ASMEXT) *$(STATICLIBEXT) *$(SHAREDLIBEXT) *$(PPLEXT)
+	-$(DELTREE) *$(SMARTEXT)
+	-$(DEL) $(FPCMADE) Package.fpc $(PPAS) script.res link.res $(FPCEXTFILE) $(REDIRFILE)
+ifdef AOUTEXT
+	-$(DEL) *$(AOUTEXT)
+endif
+.PHONY: fpc_baseinfo
+override INFORULES+=fpc_baseinfo
+fpc_baseinfo:
+	@$(ECHO)
+	@$(ECHO)  == Package info ==
+	@$(ECHO)  Package Name..... $(PACKAGE_NAME)
+	@$(ECHO)  Package Version.. $(PACKAGE_VERSION)
+	@$(ECHO)
+	@$(ECHO)  == Configuration info ==
+	@$(ECHO)
+	@$(ECHO)  FPC.......... $(FPC)
+	@$(ECHO)  FPC Version.. $(FPC_VERSION)
+	@$(ECHO)  Source CPU... $(CPU_SOURCE)
+	@$(ECHO)  Target CPU... $(CPU_TARGET)
+	@$(ECHO)  Source OS.... $(OS_SOURCE)
+	@$(ECHO)  Target OS.... $(OS_TARGET)
+	@$(ECHO)  Full Target.. $(FULL_SOURCE)
+	@$(ECHO)  Full Source.. $(FULL_TARGET)
+	@$(ECHO)
+	@$(ECHO)  == Directory info ==
+	@$(ECHO)
+	@$(ECHO)  Required pkgs... $(REQUIRE_PACKAGES)
+	@$(ECHO)
+	@$(ECHO)  Basedir......... $(BASEDIR)
+	@$(ECHO)  FPCDir.......... $(FPCDIR)
+	@$(ECHO)  CrossBinDir..... $(CROSSBINDIR)
+	@$(ECHO)  UnitsDir........ $(UNITSDIR)
+	@$(ECHO)  PackagesDir..... $(PACKAGESDIR)
+	@$(ECHO)
+	@$(ECHO)  GCC library..... $(GCCLIBDIR)
+	@$(ECHO)  Other library... $(OTHERLIBDIR)
+	@$(ECHO)
+	@$(ECHO)  == Tools info ==
+	@$(ECHO)
+	@$(ECHO)  As........ $(AS)
+	@$(ECHO)  Ld........ $(LD)
+	@$(ECHO)  Ar........ $(AR)
+	@$(ECHO)  Rc........ $(RC)
+	@$(ECHO)
+	@$(ECHO)  Mv........ $(MVPROG)
+	@$(ECHO)  Cp........ $(CPPROG)
+	@$(ECHO)  Rm........ $(RMPROG)
+	@$(ECHO)  GInstall.. $(GINSTALL)
+	@$(ECHO)  Echo...... $(ECHO)
+	@$(ECHO)  Date...... $(DATE)
+	@$(ECHO)  FPCMake... $(FPCMAKE)
+	@$(ECHO)  PPUMove... $(PPUMOVE)
+	@$(ECHO)  Upx....... $(UPXPROG)
+	@$(ECHO)  Zip....... $(ZIPPROG)
+	@$(ECHO)
+	@$(ECHO)  == Object info ==
+	@$(ECHO)
+	@$(ECHO)  Target Loaders........ $(TARGET_LOADERS)
+	@$(ECHO)  Target Units.......... $(TARGET_UNITS)
+	@$(ECHO)  Target Implicit Units. $(TARGET_IMPLICITUNITS)
+	@$(ECHO)  Target Programs....... $(TARGET_PROGRAMS)
+	@$(ECHO)  Target Dirs........... $(TARGET_DIRS)
+	@$(ECHO)  Target Examples....... $(TARGET_EXAMPLES)
+	@$(ECHO)  Target ExampleDirs.... $(TARGET_EXAMPLEDIRS)
+	@$(ECHO)
+	@$(ECHO)  Clean Units......... $(CLEAN_UNITS)
+	@$(ECHO)  Clean Files......... $(CLEAN_FILES)
+	@$(ECHO)
+	@$(ECHO)  Install Units....... $(INSTALL_UNITS)
+	@$(ECHO)  Install Files....... $(INSTALL_FILES)
+	@$(ECHO)
+	@$(ECHO)  == Install info ==
+	@$(ECHO)
+	@$(ECHO)  DateStr.............. $(DATESTR)
+	@$(ECHO)  ZipPrefix............ $(ZIPPREFIX)
+	@$(ECHO)  ZipSuffix............ $(ZIPSUFFIX)
+	@$(ECHO)  Install FPC Package.. $(INSTALL_FPCPACKAGE)
+	@$(ECHO)
+	@$(ECHO)  Install base dir..... $(INSTALL_BASEDIR)
+	@$(ECHO)  Install binary dir... $(INSTALL_BINDIR)
+	@$(ECHO)  Install library dir.. $(INSTALL_LIBDIR)
+	@$(ECHO)  Install units dir.... $(INSTALL_UNITDIR)
+	@$(ECHO)  Install source dir... $(INSTALL_SOURCEDIR)
+	@$(ECHO)  Install doc dir...... $(INSTALL_DOCDIR)
+	@$(ECHO)  Install example dir.. $(INSTALL_EXAMPLEDIR)
+	@$(ECHO)  Install data dir..... $(INSTALL_DATADIR)
+	@$(ECHO)
+	@$(ECHO)  Dist destination dir. $(DIST_DESTDIR)
+	@$(ECHO)  Dist zip name........ $(DIST_ZIPNAME)
+	@$(ECHO)
+.PHONY: fpc_info
+fpc_info: $(INFORULES)
+.PHONY: fpc_makefile fpc_makefiles fpc_makefile_sub1 fpc_makefile_sub2 \
+	fpc_makefile_dirs
+fpc_makefile:
+	$(FPCMAKE) -w -T$(OS_TARGET) Makefile.fpc
+fpc_makefile_sub1:
+ifdef TARGET_DIRS
+	$(FPCMAKE) -w -T$(OS_TARGET) $(addsuffix /Makefile.fpc,$(TARGET_DIRS))
+endif
+ifdef TARGET_EXAMPLEDIRS
+	$(FPCMAKE) -w -T$(OS_TARGET) $(addsuffix /Makefile.fpc,$(TARGET_EXAMPLEDIRS))
+endif
+fpc_makefile_sub2: $(addsuffix _makefile_dirs,$(TARGET_DIRS) $(TARGET_EXAMPLEDIRS))
+fpc_makefile_dirs: fpc_makefile_sub1 fpc_makefile_sub2
+fpc_makefiles: fpc_makefile fpc_makefile_dirs
+all: fpc_all
+debug: fpc_debug
+smart: fpc_smart
+release: fpc_release
+examples: fpc_examples
+shared:
+install: fpc_install
+sourceinstall: fpc_sourceinstall
+exampleinstall: fpc_exampleinstall
+distinstall: fpc_distinstall
+zipinstall: fpc_zipinstall
+zipsourceinstall: fpc_zipsourceinstall
+zipexampleinstall: fpc_zipexampleinstall
+zipdistinstall: fpc_zipdistinstall
+clean: fpc_clean
+distclean: fpc_distclean
+cleanall: fpc_cleanall
+info: fpc_info
+makefiles: fpc_makefiles
+.PHONY: all debug smart release examples shared install sourceinstall exampleinstall distinstall zipinstall zipsourceinstall zipexampleinstall zipdistinstall clean distclean cleanall info makefiles
+ifneq ($(wildcard fpcmake.loc),)
+include fpcmake.loc
+endif

+ 20 - 0
packages/base/regexpr/Makefile.fpc

@@ -0,0 +1,20 @@
+#
+#   Makefile.fpc for RegExpr
+#
+
+[package]
+name=regexpr
+version=1.0.6
+
+[target]
+units=regexpr
+examples=testreg1
+
+[compiler]
+options=-S2
+
+[install]
+fpcpackage=y
+
+[default]
+fpcdir=../../..

+ 610 - 0
packages/base/regexpr/regexpr.pp

@@ -0,0 +1,610 @@
+{
+    $Id$
+    This file is part of the Free Pascal run time library.
+    Copyright (c) 2000 by Florian Klaempfl
+
+    This unit implements basic regular expression support
+
+    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.
+
+ **********************************************************************}
+{ $define DEBUG}
+{
+  TODO:
+     - correct backtracking, for example in (...)*
+     - | support
+     - getting substrings and using substrings with \1 etc.
+     - test ^  and $
+     - newline handling in DOS?
+     - locals dependend upper/lowercase routines
+     - extend the interface
+}
+
+{$mode objfpc}
+
+unit regexpr;
+
+  interface
+
+    { the following declarions are only in the interface because }
+    { some procedures return pregexprentry but programs which   }
+    { use this unit shouldn't access this data structures        }
+    type
+       tcharset = set of char;
+       tregexprentrytype = (ret_charset,ret_or,ret_startpattern,
+          ret_endpattern,ret_illegalend,ret_backtrace,ret_startline,
+          ret_endline);
+
+       pregexprentry = ^tregexprentry;
+       tregexprentry = record
+          next,nextdestroy : pregexprentry;
+          case typ : tregexprentrytype of
+             ret_charset : (chars : tcharset;
+                            elsepath : pregexprentry);
+             ret_or : (alternative : pregexprentry);
+       end;
+
+       tregexprflag = (ref_singleline,ref_multiline,ref_caseinsensitive);
+       tregexprflags = set of tregexprflag;
+
+       TRegExprEngine = record
+          Data : pregexprentry;
+          DestroyList : pregexprentry;
+          Flags : TRegExprFlags;
+       end;
+
+     const
+        cs_allchars : tcharset = [#0..#255];
+        cs_wordchars : tcharset = ['A'..'Z','a'..'z','_','0'..'9'];
+        cs_newline : tcharset = [#10];
+        cs_digits : tcharset = ['0'..'9'];
+        cs_whitespace : tcharset = [' ',#9];
+
+     var
+        { these are initilized in the init section of the unit }
+        cs_nonwordchars : tcharset;
+        cs_nondigits : tcharset;
+        cs_nonwhitespace : tcharset;
+
+     { the following procedures can be used by units basing }
+     { on the regexpr unit                                  }
+     function GenerateRegExprEngine(regexpr : pchar;flags : tregexprflags) : TRegExprEngine;
+
+     procedure DestroyRegExprEngine(var regexpr : TRegExprEngine);
+
+     function RegExprPos(regexprengine : TRegExprEngine;p : pchar;var index,len : longint) : boolean;
+
+  implementation
+
+{$ifdef DEBUG}
+     procedure writecharset(c : tcharset);
+
+       var
+          b : byte;
+
+       begin
+          for b:=0 to 255 do
+            if chr(b) in c then
+              write(chr(b));
+          writeln;
+       end;
+{$endif DEBUG}
+
+     function GenerateRegExprEngine(regexpr : pchar;flags : tregexprflags) : TRegExprEngine;
+
+       var
+          first : pregexprentry;
+
+       procedure doregister(p : pregexprentry);
+
+         begin
+            p^.nextdestroy:=first;
+            if not(assigned(first)) then
+              first:=p;
+         end;
+
+       var
+          currentpos : pchar;
+          error : boolean;
+
+       function readchars : tcharset;
+
+         var
+            c1 : char;
+
+         begin
+            readchars:=[];
+            case currentpos^ of
+               #0:
+                  exit;
+               '.':
+                  begin
+                     inc(currentpos);
+                     readchars:=cs_allchars-cs_newline;
+                  end;
+               '\':
+                  begin
+                     inc(currentpos);
+                     case currentpos^ of
+                        #0:
+                          begin
+                             error:=true;
+                             exit;
+                          end;
+                        't':
+                           begin
+                              inc(currentpos);
+                              readchars:=[#9];
+                           end;
+                        'n':
+                           begin
+                              inc(currentpos);
+                              readchars:=[#10];
+                           end;
+                        'r':
+                           begin
+                              inc(currentpos);
+                              readchars:=[#13];
+                           end;
+                        'd':
+                          begin
+                             inc(currentpos);
+                             readchars:=cs_digits;
+                          end;
+                        'D':
+                          begin
+                             inc(currentpos);
+                             readchars:=cs_nondigits;
+                          end;
+                        's':
+                          begin
+                             inc(currentpos);
+                             readchars:=cs_whitespace;
+                          end;
+                        'S':
+                          begin
+                             inc(currentpos);
+                             readchars:=cs_nonwhitespace;
+                          end;
+                        'w':
+                           begin
+                              inc(currentpos);
+                              readchars:=cs_wordchars;
+                           end;
+                        'W':
+                           begin
+                              inc(currentpos);
+                              readchars:=cs_nonwordchars;
+                           end;
+                         else
+                           begin
+                              error:=true;
+                              exit;
+                           end;
+                     end;
+                  end;
+               else
+                 begin
+                    if ref_caseinsensitive in flags then
+                       c1:=upcase(currentpos^)
+                    else
+                       c1:=currentpos^;
+
+                    inc(currentpos);
+                    if currentpos^='-' then
+                      begin
+                         inc(currentpos);
+                         if currentpos^=#0 then
+                           begin
+                              error:=true;
+                              exit;
+                           end;
+                         if ref_caseinsensitive in flags then
+                           readchars:=[c1..upcase(currentpos^)]
+                         else
+                           readchars:=[c1..currentpos^];
+                         inc(currentpos);
+                      end
+                    else
+                      readchars:=[c1];
+                 end;
+            end;
+         end;
+
+
+       function readcharset : tcharset;
+
+         begin
+            readcharset:=[];
+            case currentpos^ of
+               #0:
+                  exit;
+               '[':
+                  begin
+                     inc(currentpos);
+                     while currentpos^<>']' do
+                       begin
+                          if currentpos^='^' then
+                            begin
+                               inc(currentpos);
+                               readcharset:=readcharset+(cs_allchars-readchars);
+                            end
+                          else
+                            readcharset:=readcharset+readchars;
+                          if error or (currentpos^=#0) then
+                            begin
+                               error:=true;
+                               exit;
+                            end;
+                       end;
+                     inc(currentpos);
+                  end;
+               '^':
+                  begin
+                     inc(currentpos);
+                     readcharset:=cs_allchars-readchars;
+                  end;
+               else
+                  readcharset:=readchars;
+            end;
+         end;
+
+       function parseregexpr(next,elsepath : pregexprentry) : pregexprentry;
+
+         var
+            hp,hp2,ep : pregexprentry;
+            cs : tcharset;
+            chaining : ^pregexprentry;
+
+         begin
+            chaining:=nil;
+            parseregexpr:=nil;
+            if error then
+              exit;
+            { this dummy allows us to redirect the elsepath later }
+            new(ep);
+            doregister(ep);
+            ep^.typ:=ret_charset;
+            ep^.chars:=[];
+            ep^.elsepath:=elsepath;
+            elsepath:=ep;
+            while true do
+              begin
+                 if error then
+                   exit;
+                 case currentpos^ of
+                    '(':
+                       begin
+                          inc(currentpos);
+                          new(hp2);
+                          doregister(hp2);
+                          hp2^.typ:=ret_charset;
+                          hp2^.chars:=[];
+                          hp2^.elsepath:=next;
+                          hp:=parseregexpr(hp2,ep);
+                          if assigned(chaining) then
+                            chaining^:=hp
+                          else
+                            parseregexpr:=hp;
+                          chaining:=@hp2^.elsepath;
+                          if currentpos^<>')' then
+                            begin
+                               error:=true;
+                               exit;
+                            end;
+                          inc(currentpos);
+                       end;
+                    '|':
+                       begin
+{$ifdef DEBUG}
+                          writeln('Creating backtrace entry');
+{$endif DEBUG}
+                          inc(currentpos);
+                          if currentpos^=#0 then
+                            begin
+                               error:=true;
+                               exit;
+                            end;
+                          new(hp);
+                          doregister(hp);
+                          hp^.typ:=ret_backtrace;
+                          // hp^.elsepath:=parseregexpr(elsepath);
+                          hp^.next:=@parseregexpr;
+                          parseregexpr:=hp;
+                          exit;
+                       end;
+                    ')':
+                       exit;
+                    '^':
+                       begin
+                          inc(currentpos);
+                          new(hp);
+                          doregister(hp);
+                          hp^.typ:=ret_startline;
+                          hp^.elsepath:=ep;
+                          // hp^.next:=parseregexpr(ep);
+                       end;
+                    '$':
+                       begin
+                          inc(currentpos);
+                          new(hp);
+                          doregister(hp);
+                          hp^.typ:=ret_endline;
+                          hp^.elsepath:=ep;
+                          // hp^.next:=parseregexpr(ep);
+                       end;
+                    #0:
+                       exit;
+                    else
+                      begin
+                         cs:=readcharset;
+                         if error then
+                           exit;
+                         case currentpos^ of
+                            '*':
+                               begin
+                                  inc(currentpos);
+                                  new(hp);
+                                  doregister(hp);
+                                  hp^.typ:=ret_charset;
+                                  hp^.chars:=cs;
+                                  hp^.elsepath:=next;
+                                  hp^.next:=hp;
+                                  if assigned(chaining) then
+                                    chaining^:=hp
+                                  else
+                                    parseregexpr:=hp;
+                                  chaining:=@hp^.elsepath;
+                               end;
+                            '+':
+                               begin
+                                  inc(currentpos);
+                                  new(hp);
+                                  new(hp2);
+                                  doregister(hp);
+                                  doregister(hp2);
+                                  hp^.typ:=ret_charset;
+                                  hp2^.typ:=ret_charset;
+                                  hp^.chars:=cs;
+                                  hp2^.chars:=cs;
+                                  hp^.elsepath:=elsepath;
+                                  hp^.next:=hp2;
+                                  hp2^.elsepath:=next;
+                                  hp2^.next:=hp2;
+                                  if assigned(chaining) then
+                                    chaining^:=hp
+                                  else
+                                    parseregexpr:=hp;
+                                  chaining:=@hp2^.elsepath;
+                               end;
+                            '?':
+                               begin
+                                  inc(currentpos);
+                                  new(hp);
+                                  { this is a dummy }
+                                  new(hp2);
+                                  doregister(hp);
+                                  doregister(hp2);
+                                  hp^.typ:=ret_charset;
+                                  hp^.chars:=cs;
+                                  hp^.next:=hp2;
+                                  hp^.elsepath:=hp2;
+                                  hp2^.typ:=ret_charset;
+                                  hp2^.chars:=[];
+                                  hp2^.elsepath:=next;
+                                  if assigned(chaining) then
+                                    chaining^:=hp
+                                  else
+                                    parseregexpr:=hp;
+                                  chaining:=@hp2^.elsepath;
+                               end;
+                            else
+                               begin
+                                  new(hp);
+                                  doregister(hp);
+                                  hp^.typ:=ret_charset;
+                                  hp^.chars:=cs;
+                                  hp^.elsepath:=elsepath;
+                                  hp^.next:=next;
+                                  if assigned(chaining) then
+                                    chaining^:=hp
+                                  else
+                                    parseregexpr:=hp;
+                                  chaining:=@hp^.next;
+                               end;
+                         end;
+                      end;
+                 end;
+              end;
+         end;
+
+       var
+          endp : pregexprentry;
+
+       begin
+          GenerateRegExprEngine.Data:=nil;
+          GenerateRegExprEngine.DestroyList:=nil;
+          if regexpr=nil then
+            exit;
+          first:=nil;
+          if (ref_singleline in flags) and (ref_multiline in flags) then
+            exit;
+          currentpos:=regexpr;
+          new(endp);
+          doregister(endp);
+          endp^.typ:=ret_illegalend;
+          GenerateRegExprEngine.flags:=flags;
+          GenerateRegExprEngine.Data:=parseregexpr(nil,endp);
+          GenerateRegExprEngine.DestroyList:=first;
+          if error or (currentpos^<>#0) then
+            DestroyRegExprEngine(Result);
+       end;
+
+    procedure DestroyRegExprEngine(var regexpr : TRegExprEngine);
+
+       var
+          hp : pregexprentry;
+
+       begin
+          hp:=regexpr.DestroyList;
+          while assigned(hp) do
+            begin
+               regexpr.DestroyList:=hp^.nextdestroy;
+               dispose(hp);
+               hp:=regexpr.DestroyList;
+            end;
+          regexpr.Data:=nil;
+          regexpr.DestroyList:=nil;
+       end;
+
+     function RegExprPos(regexprengine : TRegExprEngine;p : pchar;var index,len : longint) : boolean;
+
+       var
+          lastpos : pchar;
+
+       function dosearch(regexpr : pregexprentry;pos : pchar) : boolean;
+
+         begin
+            dosearch:=false;
+            while true do
+              begin
+	         {$IFDEF Debug}
+                 writeln(byte(regexpr^.typ));
+		 {$ENDIF Debug}
+                 case regexpr^.typ of
+                    ret_endline:
+                      begin
+                         if ref_multiline in regexprengine.flags then
+                           begin
+                              if ((pos+1)^ in [#10,#0]) then
+                                regexpr:=regexpr^.next
+                              else
+                                regexpr:=regexpr^.elsepath;
+                           end
+                         else
+                           begin
+                              if (pos+1)^=#0 then
+                                regexpr:=regexpr^.next
+                              else
+                                regexpr:=regexpr^.elsepath;
+                           end;
+                      end;
+                    ret_startline:
+                      begin
+                         if ref_multiline in regexprengine.flags then
+                           begin
+                              if (pos=p) or ((pos-1)^=#10) then
+                                regexpr:=regexpr^.next
+                              else
+                                regexpr:=regexpr^.elsepath;
+                           end
+                         else
+                           begin
+                              if pos=p then
+                                regexpr:=regexpr^.next
+                              else
+                                regexpr:=regexpr^.elsepath;
+                           end;
+                      end;
+                    ret_charset:
+                      begin
+                         if (pos^ in regexpr^.chars) or
+                           ((ref_caseinsensitive in regexprengine.flags) and
+                            (upcase(pos^) in regexpr^.chars)) then
+                           begin
+{$ifdef DEBUG}
+                              writeln('Found matching: ',pos^);
+{$endif DEBUG}
+                              regexpr:=regexpr^.next;
+                              inc(pos);
+                           end
+                         else
+                           begin
+{$ifdef DEBUG}
+                              writeln('Found unmatching: ',pos^);
+{$endif DEBUG}
+                              regexpr:=regexpr^.elsepath;
+                           end;
+                      end;
+                    ret_backtrace:
+                      begin
+{$ifdef DEBUG}
+                         writeln('Starting backtrace');
+{$endif DEBUG}
+                         if dosearch(regexpr^.next,pos) then
+                           begin
+                              dosearch:=true;
+                              exit;
+                           end
+                         else if dosearch(regexpr^.elsepath,pos) then
+                           begin
+                              dosearch:=true;
+                              exit;
+                           end
+                         else
+                           exit;
+                      end;
+                 end;
+                 lastpos:=pos;
+                 if regexpr=nil then
+                   begin
+                      dosearch:=true;
+                      exit;
+                   end;
+                 if regexpr^.typ=ret_illegalend then
+                   exit;
+                 if pos^=#0 then
+                   exit;
+              end;
+         end;
+
+       begin
+          RegExprPos:=false;
+          index:=0;
+          len:=0;
+          if regexprengine.Data=nil then
+            exit;
+          while p^<>#0 do
+            begin
+               if dosearch(regexprengine.Data,p) then
+                 begin
+                    len:=lastpos-p;
+                    RegExprPos:=true;
+                    exit;
+                 end
+               else
+                 begin
+                    inc(p);
+                    inc(index);
+                 end;
+            end;
+          index:=-1;
+       end;
+
+begin
+   cs_nonwordchars:=cs_allchars-cs_wordchars;
+   cs_nondigits:=cs_allchars-cs_digits;
+   cs_nonwhitespace:=cs_allchars-cs_whitespace;
+end.
+{
+  $Log$
+  Revision 1.1  2002-01-29 17:54:56  peter
+    * splitted to base and extra
+
+  Revision 1.4  2002/01/22 13:13:14  pierre
+   + add mode objfpc to avoid problems if compiling from IDE dir
+
+  Revision 1.3  2000/07/30 14:58:04  sg
+  * Added modifications by Markus Kaemmerer:
+    - Unit now compiles with Delphi
+    - Removed debug output when not compiled with -dDEBUG
+
+  Revision 1.2  2000/07/13 11:33:31  michael
+  + removed logs
+ 
+}

+ 147 - 0
packages/base/regexpr/testreg1.pp

@@ -0,0 +1,147 @@
+program testreg1;
+uses
+   regexpr;
+
+var
+   r : tregexprengine;
+   index,len : longint;
+
+procedure do_error(i : longint);
+
+  begin
+     writeln('error near ',i,' index: ',index,' len: ',len);
+     halt(1);
+  end;
+
+begin
+   writeln('*** Testing unit regexpr ***');
+
+   { basic tests }
+
+   r:=GenerateRegExprEngine('[A-Z]',[]);
+   if not(RegExprPos(r,'234578923457823659GHJK38',index,len)) or
+     (index<>18) or (len<>1) then
+     do_error(1000);
+   DestroyregExprEngine(r);
+
+   r:=GenerateRegExprEngine('[A-Z]*',[]);
+   if not(RegExprPos(r,'234578923457823659ARTZU38',index,len)) or
+   { is this result correct ??? }
+     (index<>0) or (len<>0) then
+     do_error(1002);
+   DestroyregExprEngine(r);
+
+   r:=GenerateRegExprEngine('[A-Z]+',[]);
+   if not(RegExprPos(r,'234578923457823659ARTZU38',index,len)) or
+     (index<>18) or (len<>5) then
+     do_error(1003);
+   DestroyregExprEngine(r);
+
+   r:=GenerateRegExprEngine('[A-Z][A-Z]*',[]);
+   if not(RegExprPos(r,'234578923457823659ARTZU38',index,len)) or
+     (index<>18) or (len<>5) then
+     do_error(1004);
+   DestroyregExprEngine(r);
+
+   r:=GenerateRegExprEngine('[A-Z][A-Z]?',[]);
+   if not(RegExprPos(r,'234578923457823659ARTZU38',index,len)) or
+     (index<>18) or (len<>2) then
+     do_error(1005);
+   DestroyregExprEngine(r);
+
+   r:=GenerateRegExprEngine('[^\d]+',[]);
+   if not(RegExprPos(r,'234578923457823659ARTZU38',index,len)) or
+     (index<>18) or (len<>5) then
+     do_error(1006);
+   DestroyregExprEngine(r);
+
+   { test chaining }
+
+   r:=GenerateRegExprEngine('[A-Z][A-Z]?[A-Z]',[]);
+   if not(RegExprPos(r,'234578923457823659ARTZU38',index,len)) or
+     (index<>18) or (len<>3) then
+     do_error(1007);
+   DestroyregExprEngine(r);
+
+   r:=GenerateRegExprEngine('[A-Z][A-Z]*[0-9]',[]);
+   if not(RegExprPos(r,'234578923457823659ARTZU38',index,len)) or
+     (index<>18) or (len<>6) then
+     do_error(1008);
+   DestroyregExprEngine(r);
+
+   r:=GenerateRegExprEngine('[A-Z]+[0-9]',[]);
+   if not(RegExprPos(r,'234578923457823659ARTZU38',index,len)) or
+     (index<>18) or (len<>6) then
+     do_error(1009);
+   DestroyregExprEngine(r);
+
+   { case insensitive: }
+
+   r:=GenerateRegExprEngine('[A-Z]',[ref_caseinsensitive]);
+   if not(RegExprPos(r,'234578923457823659a38',index,len)) or
+     (index<>18) or (len<>1) then
+     do_error(1100);
+   DestroyregExprEngine(r);
+
+   { case insensitive: }
+   r:=GenerateRegExprEngine('[a-z]',[ref_caseinsensitive]);
+   if not(RegExprPos(r,'234578923457823659A38',index,len)) or
+     (index<>18) or (len<>1) then
+     do_error(1101);
+   DestroyregExprEngine(r);
+
+   { with parenthsis }
+   r:=GenerateRegExprEngine('(foo)1234',[]);
+   if not(RegExprPos(r,'1234   foo1234XXXX',index,len)) or
+     (index<>7) or (len<>7) then
+     do_error(1200);
+   DestroyregExprEngine(r);
+
+   r:=GenerateRegExprEngine('(((foo)))1234',[]);
+   if not(RegExprPos(r,'1234   foo1234XXXX',index,len)) or
+     (index<>7) or (len<>7) then
+     do_error(1201);
+   DestroyregExprEngine(r);
+
+   r:=GenerateRegExprEngine('(foo)(1234)',[]);
+   if not(RegExprPos(r,'1234   foo1234XXXX',index,len)) or
+     (index<>7) or (len<>7) then
+     do_error(1202);
+   DestroyregExprEngine(r);
+
+   { test real backtracking }
+
+   r:=GenerateRegExprEngine('nofoo|foo',[]);
+   if not(RegExprPos(r,'1234   foo1234XXXX',index,len)) or
+     (index<>7) or (len<>3) then
+     do_error(1300);
+   DestroyregExprEngine(r);
+
+   {
+   r:=GenerateRegExprEngine('(nofoo|foo)1234',[]);
+   if not(RegExprPos(r,'1234   nofoo1234XXXX',index,len)) or
+     (index<>8) or (len<>9) then
+     do_error(1008);
+   DestroyregExprEngine(r);
+
+   r:=GenerateRegExprEngine('(nofoo|foo|anotherfoo)1234',[]);
+   if not(RegExprPos(r,'1234   nofoo1234XXXX',index,len)) or
+     (index<>8) or (len<>9) then
+     do_error(1009);
+   DestroyregExprEngine(r);
+
+   r:=GenerateRegExprEngine('nofoo1234|foo1234',[]);
+   if (r.data=nil) or not(RegExprPos(r,'1234   foo1234XXXX',index,len)) or
+     (index<>7) or (len<>7) then
+     do_error(1010);
+   DestroyregExprEngine(r);
+   }
+   writeln('*** Testing unit regexpr was successful ***');
+end.  $Log$
+end.  Revision 1.1  2002-01-29 17:54:57  peter
+end.    * splitted to base and extra
+end.
+end.  Revision 1.2  2000/07/13 11:33:31  michael
+end.  + removed logs
+end. 
+}

+ 1839 - 0
packages/extra/Makefile

@@ -0,0 +1,1839 @@
+#
+# Don't edit, this file is generated by FPCMake Version 1.1 [2002/01/29]
+#
+default: all
+MAKEFILETARGETS=linux go32v2 win32 os2 freebsd beos netbsd amiga atari sunos qnx
+override PATH:=$(subst \,/,$(PATH))
+ifeq ($(findstring ;,$(PATH)),)
+inUnix=1
+SEARCHPATH:=$(filter-out .,$(subst :, ,$(PATH)))
+else
+SEARCHPATH:=$(subst ;, ,$(PATH))
+endif
+PWD:=$(strip $(wildcard $(addsuffix /pwd.exe,$(SEARCHPATH))))
+ifeq ($(PWD),)
+PWD:=$(strip $(wildcard $(addsuffix /pwd,$(SEARCHPATH))))
+ifeq ($(PWD),)
+$(error You need the GNU utils package to use this Makefile)
+else
+PWD:=$(firstword $(PWD))
+SRCEXEEXT=
+endif
+else
+PWD:=$(firstword $(PWD))
+SRCEXEEXT=.exe
+endif
+ifndef inUnix
+ifeq ($(OS),Windows_NT)
+inWinNT=1
+else
+ifdef OS2_SHELL
+inOS2=1
+endif
+endif
+else
+ifneq ($(findstring cygwin,$(MACHTYPE)),)
+inCygWin=1
+endif
+endif
+ifeq ($(OS_TARGET),freebsd)
+BSDhier=1
+endif
+ifeq ($(OS_TARGET),netbsd)
+BSDhier=1
+endif
+ifdef inUnix
+BATCHEXT=.sh
+else
+ifdef inOS2
+BATCHEXT=.cmd
+else
+BATCHEXT=.bat
+endif
+endif
+ifdef inUnix
+PATHSEP=/
+else
+PATHSEP:=$(subst /,\,/)
+endif
+ifdef PWD
+BASEDIR:=$(subst \,/,$(shell $(PWD)))
+ifdef inCygWin
+ifneq ($(findstring /cygdrive/,$(BASEDIR)),)
+BASENODIR:=$(patsubst /cygdrive%,%,$(BASEDIR))
+BASEDRIVE:=$(firstword $(subst /, ,$(BASENODIR)))
+BASEDIR:=$(subst /cygdrive/$(BASEDRIVE)/,$(BASEDRIVE):/,$(BASEDIR))
+endif
+endif
+else
+BASEDIR=.
+endif
+override DEFAULT_FPCDIR=../..
+ifndef FPC
+ifdef PP
+FPC=$(PP)
+endif
+endif
+ifndef FPC
+FPCPROG:=$(strip $(wildcard $(addsuffix /fpc$(SRCEXEEXT),$(SEARCHPATH))))
+ifneq ($(FPCPROG),)
+FPCPROG:=$(firstword $(FPCPROG))
+FPC:=$(shell $(FPCPROG) -PB)
+ifneq ($(findstring Error,$(FPC)),)
+override FPC=ppc386
+endif
+else
+override FPC=ppc386
+endif
+endif
+override FPC:=$(subst $(SRCEXEEXT),,$(FPC))
+override FPC:=$(subst \,/,$(FPC))$(SRCEXEEXT)
+ifndef FPC_VERSION
+FPC_VERSION:=$(shell $(FPC) -iV)
+endif
+export FPC FPC_VERSION
+ifeq ($(findstring 1.0.,$(FPC_VERSION)),)
+COMPILERINFO:=$(shell $(FPC) -iSP -iTP -iSO -iTO)
+ifndef CPU_SOURCE
+CPU_SOURCE:=$(word 1,$(COMPILERINFO))
+endif
+ifndef CPU_TARGET
+CPU_TARGET:=$(word 2,$(COMPILERINFO))
+endif
+ifndef OS_SOURCE
+OS_SOURCE:=$(word 3,$(COMPILERINFO))
+endif
+ifndef OS_TARGET
+OS_TARGET:=$(word 4,$(COMPILERINFO))
+endif
+else
+ifndef CPU_SOURCE
+CPU_SOURCE:=$(shell $(FPC) -iSP)
+endif
+ifndef CPU_TARGET
+CPU_TARGET:=$(shell $(FPC) -iTP)
+endif
+ifndef OS_SOURCE
+OS_SOURCE:=$(shell $(FPC) -iSO)
+endif
+ifndef OS_TARGET
+OS_TARGET:=$(shell $(FPC) -iTO)
+endif
+endif
+FULL_TARGET=$(CPU_TARGET)-$(OS_TARGET)
+FULL_SOURCE=$(CPU_SOURCE)-$(OS_SOURCE)
+ifneq ($(FULL_TARGET),$(FULL_SOURCE))
+CROSSCOMPILE=1
+endif
+ifeq ($(findstring makefile,$(MAKECMDGOALS)),)
+ifeq ($(findstring $(OS_TARGET),$(MAKEFILETARGETS)),)
+$(error The Makefile doesn't support target $(OS_TARGET), please run fpcmake first)
+endif
+endif
+export OS_TARGET OS_SOURCE CPU_TARGET CPU_SOURCE FULL_TARGET FULL_SOURCE CROSSCOMPILE
+ifdef FPCDIR
+override FPCDIR:=$(subst \,/,$(FPCDIR))
+ifeq ($(wildcard $(addprefix $(FPCDIR)/,rtl units)),)
+override FPCDIR=wrong
+endif
+else
+override FPCDIR=wrong
+endif
+ifdef DEFAULT_FPCDIR
+ifeq ($(FPCDIR),wrong)
+override FPCDIR:=$(subst \,/,$(DEFAULT_FPCDIR))
+ifeq ($(wildcard $(addprefix $(FPCDIR)/,rtl units)),)
+override FPCDIR=wrong
+endif
+endif
+endif
+ifeq ($(FPCDIR),wrong)
+ifdef inUnix
+override FPCDIR=/usr/local/lib/fpc/$(FPC_VERSION)
+ifeq ($(wildcard $(FPCDIR)/units),)
+override FPCDIR=/usr/lib/fpc/$(FPC_VERSION)
+endif
+else
+override FPCDIR:=$(subst /$(FPC),,$(firstword $(strip $(wildcard $(addsuffix /$(FPC),$(SEARCHPATH))))))
+override FPCDIR:=$(FPCDIR)/..
+ifeq ($(wildcard $(addprefix $(FPCDIR)/,rtl units)),)
+override FPCDIR:=$(FPCDIR)/..
+ifeq ($(wildcard $(addprefix $(FPCDIR)/,rtl units)),)
+override FPCDIR=c:/pp
+endif
+endif
+endif
+endif
+ifndef CROSSDIR
+CROSSDIR:=$(FPCDIR)/cross/$(FULL_TARGET)
+endif
+ifndef CROSSTARGETDIR
+CROSSTARGETDIR=$(CROSSDIR)/$(FULL_TARGET)
+endif
+ifdef CROSSCOMPILE
+UNITSDIR:=$(wildcard $(CROSSTARGETDIR)/units)
+ifeq ($(UNITSDIR),)
+UNITSDIR:=$(wildcard $(FPCDIR)/units/$(OS_TARGET))
+endif
+else
+UNITSDIR:=$(wildcard $(FPCDIR)/units/$(OS_TARGET))
+endif
+PACKAGESDIR:=$(wildcard $(FPCDIR) $(FPCDIR)/packages/base $(FPCDIR)/packages/extra)
+override TARGET_DIRS+=unzip
+ifeq ($(OS_TARGET),linux)
+override TARGET_DIRS+=uncgi fpasync x11 opengl gtk syslog forms svgalib ggi libpng libgd utmp cmem bfd zlib gdbm
+endif
+ifeq ($(OS_TARGET),go32v2)
+override TARGET_DIRS+=uncgi
+endif
+ifeq ($(OS_TARGET),win32)
+override TARGET_DIRS+=uncgi opengl gtk zlib mmsystem
+endif
+ifeq ($(OS_TARGET),os2)
+override TARGET_DIRS+=uncgi
+endif
+ifeq ($(OS_TARGET),freebsd)
+override TARGET_DIRS+=uncgi fpasync x11 opengl gtk syslog forms svgalib ggi libpng libgd utmp cmem bfd zlib gdbm
+endif
+ifeq ($(OS_TARGET),netbsd)
+override TARGET_DIRS+=uncgi fpasync x11 opengl gtk syslog forms svgalib ggi libpng libgd utmp cmem bfd zlib gdbm
+endif
+override INSTALL_FPCPACKAGE=y
+ifdef REQUIRE_UNITSDIR
+override UNITSDIR+=$(REQUIRE_UNITSDIR)
+endif
+ifdef REQUIRE_PACKAGESDIR
+override PACKAGESDIR+=$(REQUIRE_PACKAGESDIR)
+endif
+ifdef ZIPINSTALL
+ifeq ($(OS_TARGET),linux)
+UNIXINSTALLDIR=1
+endif
+ifeq ($(OS_TARGET),freebsd)
+UNIXINSTALLDIR=1
+endif
+ifeq ($(OS_TARGET),netbsd)
+UNIXINSTALLDIR=1
+endif
+ifeq ($(OS_TARGET),sunos)
+UNIXINSTALLDIR=1
+endif
+else
+ifeq ($(OS_SOURCE),linux)
+UNIXINSTALLDIR=1
+endif
+ifeq ($(OS_SOURCE),freebsd)
+UNIXINSTALLDIR=1
+endif
+ifeq ($(OS_SOURCE),netbsd)
+UNIXINSTALLDIR=1
+endif
+ifeq ($(OS_TARGET),sunos)
+UNIXINSTALLDIR=1
+endif
+endif
+ifndef INSTALL_PREFIX
+ifdef PREFIX
+INSTALL_PREFIX=$(PREFIX)
+endif
+endif
+ifndef INSTALL_PREFIX
+ifdef UNIXINSTALLDIR
+INSTALL_PREFIX=/usr/local
+else
+ifdef INSTALL_FPCPACKAGE
+INSTALL_BASEDIR:=/pp
+else
+INSTALL_BASEDIR:=/$(PACKAGE_NAME)
+endif
+endif
+endif
+export INSTALL_PREFIX
+ifndef DIST_DESTDIR
+DIST_DESTDIR:=$(BASEDIR)
+endif
+export DIST_DESTDIR
+ifndef INSTALL_BASEDIR
+ifdef UNIXINSTALLDIR
+ifdef INSTALL_FPCPACKAGE
+INSTALL_BASEDIR:=$(INSTALL_PREFIX)/lib/fpc/$(FPC_VERSION)
+else
+INSTALL_BASEDIR:=$(INSTALL_PREFIX)/lib/$(PACKAGE_NAME)
+endif
+else
+INSTALL_BASEDIR:=$(INSTALL_PREFIX)
+endif
+endif
+ifndef INSTALL_BINDIR
+ifdef UNIXINSTALLDIR
+INSTALL_BINDIR:=$(INSTALL_PREFIX)/bin
+else
+INSTALL_BINDIR:=$(INSTALL_BASEDIR)/bin
+ifdef INSTALL_FPCPACKAGE
+INSTALL_BINDIR:=$(INSTALL_BINDIR)/$(OS_TARGET)
+endif
+endif
+endif
+ifndef INSTALL_UNITDIR
+ifdef CROSSCOMPILE
+INSTALL_UNITDIR:=$(INSTALL_BASEDIR)/cross/$(FULL_TARGET)/units
+else
+INSTALL_UNITDIR:=$(INSTALL_BASEDIR)/units/$(OS_TARGET)
+endif
+ifdef INSTALL_FPCPACKAGE
+ifdef PACKAGE_NAME
+INSTALL_UNITDIR:=$(INSTALL_UNITDIR)/$(PACKAGE_NAME)
+endif
+endif
+endif
+ifndef INSTALL_LIBDIR
+ifdef UNIXINSTALLDIR
+INSTALL_LIBDIR:=$(INSTALL_PREFIX)/lib
+else
+INSTALL_LIBDIR:=$(INSTALL_UNITDIR)
+endif
+endif
+ifndef INSTALL_SOURCEDIR
+ifdef UNIXINSTALLDIR
+ifdef INSTALL_FPCPACKAGE
+ifdef BSDhier
+INSTALL_SOURCEDIR:=$(INSTALL_PREFIX)/share/src/fpc-$(FPC_VERSION)/$(PACKAGE_NAME)
+else
+INSTALL_SOURCEDIR:=$(INSTALL_PREFIX)/src/fpc-$(FPC_VERSION)/$(PACKAGE_NAME)
+endif
+else
+ifdef BSDhier
+INSTALL_SOURCEDIR:=$(INSTALL_PREFIX)/share/src/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
+else
+INSTALL_SOURCEDIR:=$(INSTALL_PREFIX)/src/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
+endif
+endif
+else
+ifdef INSTALL_FPCPACKAGE
+INSTALL_SOURCEDIR:=$(INSTALL_BASEDIR)/source/$(PACKAGE_NAME)
+else
+INSTALL_SOURCEDIRL:=$(INSTALL_BASEDIR)/source
+endif
+endif
+endif
+ifndef INSTALL_DOCDIR
+ifdef UNIXINSTALLDIR
+ifdef INSTALL_FPCPACKAGE
+ifdef BSDhier
+INSTALL_DOCDIR:=$(INSTALL_PREFIX)/share/doc/fpc-$(FPC_VERSION)/$(PACKAGE_NAME)
+else
+INSTALL_DOCDIR:=$(INSTALL_PREFIX)/doc/fpc-$(FPC_VERSION)/$(PACKAGE_NAME)
+endif
+else
+ifdef BSDhier
+INSTALL_DOCDIR:=$(INSTALL_PREFIX)/share/doc/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
+else
+INSTALL_DOCDIR:=$(INSTALL_PREFIX)/doc/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
+endif
+endif
+else
+ifdef INSTALL_FPCPACKAGE
+INSTALL_DOCDIR:=$(INSTALL_BASEDIR)/doc/$(PACKAGE_NAME)
+else
+INSTALL_DOCDIR:=$(INSTALL_BASEDIR)/doc
+endif
+endif
+endif
+ifndef INSTALL_EXAMPLEDIR
+ifdef UNIXINSTALLDIR
+ifdef INSTALL_FPCPACKAGE
+ifdef BSDhier
+INSTALL_EXAMPLEDIR:=$(INSTALL_PREFIX)/share/examples/fpc-$(FPC_VERSION)/$(PACKAGE_NAME)
+else
+INSTALL_EXAMPLEDIR:=$(INSTALL_PREFIX)/doc/fpc-$(FPC_VERSION)/examples/$(PACKAGE_NAME)
+endif
+else
+ifdef BSDhier
+INSTALL_EXAMPLEDIR:=$(INSTALL_PREFIX)/share/examples/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
+else
+INSTALL_EXAMPLEDIR:=$(INSTALL_PREFIX)/doc/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
+endif
+endif
+else
+ifdef INSTALL_FPCPACKAGE
+INSTALL_EXAMPLEDIR:=$(INSTALL_BASEDIR)/examples/$(PACKAGE_NAME)
+else
+INSTALL_EXAMPLEDIR:=$(INSTALL_BASEDIR)/examples
+endif
+endif
+endif
+ifndef INSTALL_DATADIR
+INSTALL_DATADIR=$(INSTALL_BASEDIR)
+endif
+ifdef CROSSCOMPILE
+ifndef CROSSBINDIR
+CROSSBINDIR:=$(wildcard $(CROSSTARGETDIR)/bin/$(FULL_SOURCE))
+ifeq ($(CROSSBINDIR),)
+CROSSBINDIR:=$(wildcard $(INSTALL_BASEDIR)/cross/$(FULL_TARGET)/bin/$(FULL_SOURCE))
+endif
+endif
+else
+CROSSBINDIR=
+endif
+LOADEREXT=.as
+EXEEXT=.exe
+PPLEXT=.ppl
+PPUEXT=.ppu
+OEXT=.o
+ASMEXT=.s
+SMARTEXT=.sl
+STATICLIBEXT=.a
+SHAREDLIBEXT=.so
+STATICLIBPREFIX=libp
+RSTEXT=.rst
+FPCMADE=fpcmade
+ifeq ($(OS_TARGET),go32v1)
+PPUEXT=.pp1
+OEXT=.o1
+ASMEXT=.s1
+SMARTEXT=.sl1
+STATICLIBEXT=.a1
+SHAREDLIBEXT=.so1
+STATICLIBPREFIX=
+FPCMADE=fpcmade.v1
+PACKAGESUFFIX=v1
+endif
+ifeq ($(OS_TARGET),go32v2)
+STATICLIBPREFIX=
+FPCMADE=fpcmade.dos
+ZIPSUFFIX=go32
+endif
+ifeq ($(OS_TARGET),linux)
+EXEEXT=
+HASSHAREDLIB=1
+FPCMADE=fpcmade.lnx
+ZIPSUFFIX=linux
+endif
+ifeq ($(OS_TARGET),freebsd)
+EXEEXT=
+HASSHAREDLIB=1
+FPCMADE=fpcmade.freebsd
+ZIPSUFFIX=freebsd
+endif
+ifeq ($(OS_TARGET),netbsd)
+EXEEXT=
+HASSHAREDLIB=1
+FPCMADE=fpcmade.netbsd
+ZIPSUFFIX=netbsd
+endif
+ifeq ($(OS_TARGET),win32)
+PPUEXT=.ppw
+OEXT=.ow
+ASMEXT=.sw
+SMARTEXT=.slw
+STATICLIBEXT=.aw
+SHAREDLIBEXT=.dll
+FPCMADE=fpcmade.w32
+ZIPSUFFIX=w32
+endif
+ifeq ($(OS_TARGET),os2)
+PPUEXT=.ppo
+ASMEXT=.so2
+OEXT=.oo2
+AOUTEXT=.out
+SMARTEXT=.so
+STATICLIBEXT=.ao2
+SHAREDLIBEXT=.dll
+FPCMADE=fpcmade.os2
+ZIPSUFFIX=emx
+endif
+ifeq ($(OS_TARGET),amiga)
+EXEEXT=
+PPUEXT=.ppa
+ASMEXT=.asm
+OEXT=.o
+SMARTEXT=.sl
+STATICLIBEXT=.a
+SHAREDLIBEXT=.library
+FPCMADE=fpcmade.amg
+endif
+ifeq ($(OS_TARGET),atari)
+PPUEXT=.ppt
+ASMEXT=.s
+OEXT=.o
+SMARTEXT=.sl
+STATICLIBEXT=.a
+EXEEXT=.ttp
+FPCMADE=fpcmade.ata
+endif
+ifeq ($(OS_TARGET),beos)
+PPUEXT=.ppu
+ASMEXT=.s
+OEXT=.o
+SMARTEXT=.sl
+STATICLIBEXT=.a
+EXEEXT=
+FPCMADE=fpcmade.be
+ZIPSUFFIX=be
+endif
+ifeq ($(OS_TARGET),sunos)
+PPUEXT=.ppu
+ASMEXT=.s
+OEXT=.o
+SMARTEXT=.sl
+STATICLIBEXT=.a
+EXEEXT=
+FPCMADE=fpcmade.sun
+ZIPSUFFIX=sun
+endif
+ifeq ($(OS_TARGET),qnx)
+PPUEXT=.ppu
+ASMEXT=.s
+OEXT=.o
+SMARTEXT=.sl
+STATICLIBEXT=.a
+EXEEXT=
+FPCMADE=fpcmade.qnx
+ZIPSUFFIX=qnx
+endif
+ifndef ECHO
+ECHO:=$(strip $(wildcard $(addsuffix /gecho$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(ECHO),)
+ECHO:=$(strip $(wildcard $(addsuffix /echo$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(ECHO),)
+ECHO=
+else
+ECHO:=$(firstword $(ECHO))
+endif
+else
+ECHO:=$(firstword $(ECHO))
+endif
+endif
+export ECHO
+ifndef DATE
+DATE:=$(strip $(wildcard $(addsuffix /gdate$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(DATE),)
+DATE:=$(strip $(wildcard $(addsuffix /date$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(DATE),)
+DATE=
+else
+DATE:=$(firstword $(DATE))
+endif
+else
+DATE:=$(firstword $(DATE))
+endif
+endif
+export DATE
+ifndef GINSTALL
+GINSTALL:=$(strip $(wildcard $(addsuffix /ginstall$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(GINSTALL),)
+GINSTALL:=$(strip $(wildcard $(addsuffix /install$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(GINSTALL),)
+GINSTALL=
+else
+GINSTALL:=$(firstword $(GINSTALL))
+endif
+else
+GINSTALL:=$(firstword $(GINSTALL))
+endif
+endif
+export GINSTALL
+ifndef CPPROG
+CPPROG:=$(strip $(wildcard $(addsuffix /cp$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(CPPROG),)
+CPPROG=
+else
+CPPROG:=$(firstword $(CPPROG))
+endif
+endif
+export CPPROG
+ifndef RMPROG
+RMPROG:=$(strip $(wildcard $(addsuffix /rm$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(RMPROG),)
+RMPROG=
+else
+RMPROG:=$(firstword $(RMPROG))
+endif
+endif
+export RMPROG
+ifndef MVPROG
+MVPROG:=$(strip $(wildcard $(addsuffix /mv$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(MVPROG),)
+MVPROG=
+else
+MVPROG:=$(firstword $(MVPROG))
+endif
+endif
+export MVPROG
+ifndef ECHOREDIR
+ECHOREDIR:=$(subst /,$(PATHSEP),$(ECHO))
+endif
+ifndef COPY
+COPY:=$(CPPROG) -fp
+endif
+ifndef COPYTREE
+COPYTREE:=$(CPPROG) -rfp
+endif
+ifndef MOVE
+MOVE:=$(MVPROG) -f
+endif
+ifndef DEL
+DEL:=$(RMPROG) -f
+endif
+ifndef DELTREE
+DELTREE:=$(RMPROG) -rf
+endif
+ifndef INSTALL
+ifdef inUnix
+INSTALL:=$(GINSTALL) -c -m 644
+else
+INSTALL:=$(COPY)
+endif
+endif
+ifndef INSTALLEXE
+ifdef inUnix
+INSTALLEXE:=$(GINSTALL) -c -m 755
+else
+INSTALLEXE:=$(COPY)
+endif
+endif
+ifndef MKDIR
+MKDIR:=$(GINSTALL) -m 755 -d
+endif
+export ECHOREDIR COPY COPYTREE MOVE DEL DELTREE INSTALL INSTALLEXE MKDIR
+ifndef PPUMOVE
+PPUMOVE:=$(strip $(wildcard $(addsuffix /ppumove$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(PPUMOVE),)
+PPUMOVE=
+else
+PPUMOVE:=$(firstword $(PPUMOVE))
+endif
+endif
+export PPUMOVE
+ifndef FPCMAKE
+FPCMAKE:=$(strip $(wildcard $(addsuffix /fpcmake$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(FPCMAKE),)
+FPCMAKE=
+else
+FPCMAKE:=$(firstword $(FPCMAKE))
+endif
+endif
+export FPCMAKE
+ifndef ZIPPROG
+ZIPPROG:=$(strip $(wildcard $(addsuffix /zip$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(ZIPPROG),)
+ZIPPROG=
+else
+ZIPPROG:=$(firstword $(ZIPPROG))
+endif
+endif
+export ZIPPROG
+ifndef TARPROG
+TARPROG:=$(strip $(wildcard $(addsuffix /tar$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(TARPROG),)
+TARPROG=
+else
+TARPROG:=$(firstword $(TARPROG))
+endif
+endif
+export TARPROG
+ASNAME=as
+LDNAME=ld
+ARNAME=ar
+RCNAME=rc
+ifeq ($(OS_TARGET),win32)
+ASNAME=asw
+LDNAME=ldw
+ARNAME=arw
+endif
+ifndef ASPROG
+ifdef CROSSBINDIR
+ASPROG=$(CROSSBINDIR)/$(ASNAME)$(SRCEXEEXT)
+else
+ASPROG=$(ASNAME)
+endif
+endif
+ifndef LDPROG
+ifdef CROSSBINDIR
+LDPROG=$(CROSSBINDIR)/$(LDNAME)$(SRCEXEEXT)
+else
+LDPROG=$(LDNAME)
+endif
+endif
+ifndef RCPROG
+ifdef CROSSBINDIR
+RCPROG=$(CROSSBINDIR)/$(RCNAME)$(SRCEXEEXT)
+else
+RCPROG=$(RCNAME)
+endif
+endif
+ifndef ARPROG
+ifdef CROSSBINDIR
+ARPROG=$(CROSSBINDIR)/$(ARNAME)$(SRCEXEEXT)
+else
+ARPROG=$(ARNAME)
+endif
+endif
+AS=$(ASPROG)
+LD=$(LDPROG)
+RC=$(RCPROG)
+AR=$(ARPROG)
+PPAS=ppas$(BATCHEXT)
+ifdef inUnix
+LDCONFIG=ldconfig
+else
+LDCONFIG=
+endif
+ifdef DATE
+DATESTR:=$(shell $(DATE) +%Y%m%d)
+else
+DATESTR=
+endif
+ifndef UPXPROG
+ifeq ($(OS_TARGET),go32v2)
+UPXPROG:=1
+endif
+ifeq ($(OS_TARGET),win32)
+UPXPROG:=1
+endif
+ifdef UPXPROG
+UPXPROG:=$(strip $(wildcard $(addsuffix /upx$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(UPXPROG),)
+UPXPROG=
+else
+UPXPROG:=$(firstword $(UPXPROG))
+endif
+else
+UPXPROG=
+endif
+endif
+export UPXPROG
+ZIPOPT=-9
+ZIPEXT=.zip
+ifeq ($(USETAR),bz2)
+TAROPT=vI
+TAREXT=.tar.bz2
+else
+TAROPT=vz
+TAREXT=.tar.gz
+endif
+ifndef NOCPUDEF
+override FPCOPTDEF=$(CPU_TARGET)
+endif
+ifneq ($(OS_TARGET),$(OS_SOURCE))
+override FPCOPT+=-T$(OS_TARGET)
+endif
+ifdef UNITDIR
+override FPCOPT+=$(addprefix -Fu,$(UNITDIR))
+endif
+ifdef LIBDIR
+override FPCOPT+=$(addprefix -Fl,$(LIBDIR))
+endif
+ifdef OBJDIR
+override FPCOPT+=$(addprefix -Fo,$(OBJDIR))
+endif
+ifdef INCDIR
+override FPCOPT+=$(addprefix -Fi,$(INCDIR))
+endif
+ifdef LINKSMART
+override FPCOPT+=-XX
+endif
+ifdef CREATESMART
+override FPCOPT+=-CX
+endif
+ifdef DEBUG
+override FPCOPT+=-gl
+override FPCOPTDEF+=DEBUG
+endif
+ifdef RELEASE
+ifeq ($(CPU_TARGET),i386)
+FPCCPUOPT:=-OG2p3
+else
+FPCCPUOPT:=
+endif
+override FPCOPT+=-Xs $(FPCCPUOPT) -n
+override FPCOPTDEF+=RELEASE
+endif
+ifdef STRIP
+override FPCOPT+=-Xs
+endif
+ifdef OPTIMIZE
+ifeq ($(CPU_TARGET),i386)
+override FPCOPT+=-OG2p3
+endif
+endif
+ifdef VERBOSE
+override FPCOPT+=-vwni
+endif
+ifdef COMPILER_OPTIONS
+override FPCOPT+=$(COMPILER_OPTIONS)
+endif
+ifdef COMPILER_UNITDIR
+override FPCOPT+=$(addprefix -Fu,$(COMPILER_UNITDIR))
+endif
+ifdef COMPILER_LIBRARYDIR
+override FPCOPT+=$(addprefix -Fl,$(COMPILER_LIBRARYDIR))
+endif
+ifdef COMPILER_OBJECTDIR
+override FPCOPT+=$(addprefix -Fo,$(COMPILER_OBJECTDIR))
+endif
+ifdef COMPILER_INCLUDEDIR
+override FPCOPT+=$(addprefix -Fi,$(COMPILER_INCLUDEDIR))
+endif
+ifdef CROSSBINDIR
+override FPCOPT+=-FD$(CROSSBINDIR)
+endif
+ifdef COMPILER_TARGETDIR
+override FPCOPT+=-FE$(COMPILER_TARGETDIR)
+ifeq ($(COMPILER_TARGETDIR),.)
+override TARGETDIRPREFIX=
+else
+override TARGETDIRPREFIX=$(COMPILER_TARGETDIR)/
+endif
+endif
+ifdef COMPILER_UNITTARGETDIR
+override FPCOPT+=-FU$(COMPILER_UNITTARGETDIR)
+ifeq ($(COMPILER_UNITTARGETDIR),.)
+override UNITTARGETDIRPREFIX=
+else
+override UNITTARGETDIRPREFIX=$(COMPILER_UNITTARGETDIR)/
+endif
+else
+ifdef COMPILER_TARGETDIR
+override COMPILER_UNITTARGETDIR=$(COMPILER_TARGETDIR)
+override UNITTARGETDIRPREFIX=$(TARGETDIRPREFIX)
+endif
+endif
+ifdef OPT
+override FPCOPT+=$(OPT)
+endif
+ifdef FPCOPTDEF
+override FPCOPT+=$(addprefix -d,$(FPCOPTDEF))
+endif
+ifdef CFGFILE
+override FPCOPT+=@$(CFGFILE)
+endif
+ifdef USEENV
+override FPCEXTCMD:=$(FPCOPT)
+override FPCOPT:=!FPCEXTCMD
+export FPCEXTCMD
+endif
+override COMPILER:=$(FPC) $(FPCOPT)
+ifeq (,$(findstring -s ,$(COMPILER)))
+EXECPPAS=
+else
+ifeq ($(OS_SOURCE),$(OS_TARGET))
+EXECPPAS:=@$(PPAS)
+endif
+endif
+ifdef TARGET_RSTS
+override RSTFILES=$(addsuffix $(RSTEXT),$(TARGET_RSTS))
+override CLEANRSTFILES+=$(RSTFILES)
+endif
+.PHONY: fpc_clean fpc_cleanall fpc_distclean
+ifdef EXEFILES
+override CLEANEXEFILES:=$(addprefix $(TARGETDIRPREFIX),$(CLEANEXEFILES))
+endif
+ifdef CLEAN_UNITS
+override CLEANPPUFILES+=$(addsuffix $(PPUEXT),$(CLEAN_UNITS))
+endif
+ifdef CLEANPPUFILES
+override CLEANPPULINKFILES:=$(subst $(PPUEXT),$(OEXT),$(CLEANPPUFILES)) $(addprefix $(STATICLIBPREFIX),$(subst $(PPUEXT),$(STATICLIBEXT),$(CLEANPPUFILES)))
+override CLEANPPUFILES:=$(addprefix $(UNITTARGETDIRPREFIX),$(CLEANPPUFILES))
+override CLEANPPULINKFILES:=$(wildcard $(addprefix $(UNITTARGETDIRPREFIX),$(CLEANPPULINKFILES)))
+endif
+fpc_clean: $(CLEANTARGET)
+ifdef CLEANEXEFILES
+	-$(DEL) $(CLEANEXEFILES)
+endif
+ifdef CLEANPPUFILES
+	-$(DEL) $(CLEANPPUFILES)
+endif
+ifneq ($(CLEANPPULINKFILES),)
+	-$(DEL) $(CLEANPPULINKFILES)
+endif
+ifdef CLEANRSTFILES
+	-$(DEL) $(addprefix $(UNITTARGETDIRPREFIX),$(CLEANRSTFILES))
+endif
+ifdef CLEAN_FILES
+	-$(DEL) $(CLEAN_FILES)
+endif
+ifdef LIB_NAME
+	-$(DEL) $(LIB_NAME) $(LIB_FULLNAME)
+endif
+	-$(DEL) $(FPCMADE) Package.fpc $(PPAS) script.res link.res $(FPCEXTFILE) $(REDIRFILE)
+fpc_distclean: clean
+ifdef COMPILER_UNITTARGETDIR
+TARGETDIRCLEAN=fpc_clean
+endif
+fpc_cleanall: $(CLEANTARGET) $(TARGETDIRCLEAN)
+ifdef CLEANEXEFILES
+	-$(DEL) $(CLEANEXEFILES)
+endif
+	-$(DEL) *$(OEXT) *$(PPUEXT) *$(RSTEXT) *$(ASMEXT) *$(STATICLIBEXT) *$(SHAREDLIBEXT) *$(PPLEXT)
+	-$(DELTREE) *$(SMARTEXT)
+	-$(DEL) $(FPCMADE) Package.fpc $(PPAS) script.res link.res $(FPCEXTFILE) $(REDIRFILE)
+ifdef AOUTEXT
+	-$(DEL) *$(AOUTEXT)
+endif
+.PHONY: fpc_baseinfo
+override INFORULES+=fpc_baseinfo
+fpc_baseinfo:
+	@$(ECHO)
+	@$(ECHO)  == Package info ==
+	@$(ECHO)  Package Name..... $(PACKAGE_NAME)
+	@$(ECHO)  Package Version.. $(PACKAGE_VERSION)
+	@$(ECHO)
+	@$(ECHO)  == Configuration info ==
+	@$(ECHO)
+	@$(ECHO)  FPC.......... $(FPC)
+	@$(ECHO)  FPC Version.. $(FPC_VERSION)
+	@$(ECHO)  Source CPU... $(CPU_SOURCE)
+	@$(ECHO)  Target CPU... $(CPU_TARGET)
+	@$(ECHO)  Source OS.... $(OS_SOURCE)
+	@$(ECHO)  Target OS.... $(OS_TARGET)
+	@$(ECHO)  Full Target.. $(FULL_SOURCE)
+	@$(ECHO)  Full Source.. $(FULL_TARGET)
+	@$(ECHO)
+	@$(ECHO)  == Directory info ==
+	@$(ECHO)
+	@$(ECHO)  Required pkgs... $(REQUIRE_PACKAGES)
+	@$(ECHO)
+	@$(ECHO)  Basedir......... $(BASEDIR)
+	@$(ECHO)  FPCDir.......... $(FPCDIR)
+	@$(ECHO)  CrossBinDir..... $(CROSSBINDIR)
+	@$(ECHO)  UnitsDir........ $(UNITSDIR)
+	@$(ECHO)  PackagesDir..... $(PACKAGESDIR)
+	@$(ECHO)
+	@$(ECHO)  GCC library..... $(GCCLIBDIR)
+	@$(ECHO)  Other library... $(OTHERLIBDIR)
+	@$(ECHO)
+	@$(ECHO)  == Tools info ==
+	@$(ECHO)
+	@$(ECHO)  As........ $(AS)
+	@$(ECHO)  Ld........ $(LD)
+	@$(ECHO)  Ar........ $(AR)
+	@$(ECHO)  Rc........ $(RC)
+	@$(ECHO)
+	@$(ECHO)  Mv........ $(MVPROG)
+	@$(ECHO)  Cp........ $(CPPROG)
+	@$(ECHO)  Rm........ $(RMPROG)
+	@$(ECHO)  GInstall.. $(GINSTALL)
+	@$(ECHO)  Echo...... $(ECHO)
+	@$(ECHO)  Date...... $(DATE)
+	@$(ECHO)  FPCMake... $(FPCMAKE)
+	@$(ECHO)  PPUMove... $(PPUMOVE)
+	@$(ECHO)  Upx....... $(UPXPROG)
+	@$(ECHO)  Zip....... $(ZIPPROG)
+	@$(ECHO)
+	@$(ECHO)  == Object info ==
+	@$(ECHO)
+	@$(ECHO)  Target Loaders........ $(TARGET_LOADERS)
+	@$(ECHO)  Target Units.......... $(TARGET_UNITS)
+	@$(ECHO)  Target Implicit Units. $(TARGET_IMPLICITUNITS)
+	@$(ECHO)  Target Programs....... $(TARGET_PROGRAMS)
+	@$(ECHO)  Target Dirs........... $(TARGET_DIRS)
+	@$(ECHO)  Target Examples....... $(TARGET_EXAMPLES)
+	@$(ECHO)  Target ExampleDirs.... $(TARGET_EXAMPLEDIRS)
+	@$(ECHO)
+	@$(ECHO)  Clean Units......... $(CLEAN_UNITS)
+	@$(ECHO)  Clean Files......... $(CLEAN_FILES)
+	@$(ECHO)
+	@$(ECHO)  Install Units....... $(INSTALL_UNITS)
+	@$(ECHO)  Install Files....... $(INSTALL_FILES)
+	@$(ECHO)
+	@$(ECHO)  == Install info ==
+	@$(ECHO)
+	@$(ECHO)  DateStr.............. $(DATESTR)
+	@$(ECHO)  ZipPrefix............ $(ZIPPREFIX)
+	@$(ECHO)  ZipSuffix............ $(ZIPSUFFIX)
+	@$(ECHO)  Install FPC Package.. $(INSTALL_FPCPACKAGE)
+	@$(ECHO)
+	@$(ECHO)  Install base dir..... $(INSTALL_BASEDIR)
+	@$(ECHO)  Install binary dir... $(INSTALL_BINDIR)
+	@$(ECHO)  Install library dir.. $(INSTALL_LIBDIR)
+	@$(ECHO)  Install units dir.... $(INSTALL_UNITDIR)
+	@$(ECHO)  Install source dir... $(INSTALL_SOURCEDIR)
+	@$(ECHO)  Install doc dir...... $(INSTALL_DOCDIR)
+	@$(ECHO)  Install example dir.. $(INSTALL_EXAMPLEDIR)
+	@$(ECHO)  Install data dir..... $(INSTALL_DATADIR)
+	@$(ECHO)
+	@$(ECHO)  Dist destination dir. $(DIST_DESTDIR)
+	@$(ECHO)  Dist zip name........ $(DIST_ZIPNAME)
+	@$(ECHO)
+.PHONY: fpc_info
+fpc_info: $(INFORULES)
+.PHONY: fpc_makefile fpc_makefiles fpc_makefile_sub1 fpc_makefile_sub2 \
+	fpc_makefile_dirs
+fpc_makefile:
+	$(FPCMAKE) -w -T$(OS_TARGET) Makefile.fpc
+fpc_makefile_sub1:
+ifdef TARGET_DIRS
+	$(FPCMAKE) -w -T$(OS_TARGET) $(addsuffix /Makefile.fpc,$(TARGET_DIRS))
+endif
+ifdef TARGET_EXAMPLEDIRS
+	$(FPCMAKE) -w -T$(OS_TARGET) $(addsuffix /Makefile.fpc,$(TARGET_EXAMPLEDIRS))
+endif
+fpc_makefile_sub2: $(addsuffix _makefile_dirs,$(TARGET_DIRS) $(TARGET_EXAMPLEDIRS))
+fpc_makefile_dirs: fpc_makefile_sub1 fpc_makefile_sub2
+fpc_makefiles: fpc_makefile fpc_makefile_dirs
+TARGET_DIRS_UNZIP=1
+ifeq ($(OS_TARGET),linux)
+TARGET_DIRS_UNCGI=1
+TARGET_DIRS_FPASYNC=1
+TARGET_DIRS_X11=1
+TARGET_DIRS_OPENGL=1
+TARGET_DIRS_GTK=1
+TARGET_DIRS_SYSLOG=1
+TARGET_DIRS_FORMS=1
+TARGET_DIRS_SVGALIB=1
+TARGET_DIRS_GGI=1
+TARGET_DIRS_LIBPNG=1
+TARGET_DIRS_LIBGD=1
+TARGET_DIRS_UTMP=1
+TARGET_DIRS_CMEM=1
+TARGET_DIRS_BFD=1
+TARGET_DIRS_ZLIB=1
+TARGET_DIRS_GDBM=1
+endif
+ifeq ($(OS_TARGET),go32v2)
+TARGET_DIRS_UNCGI=1
+endif
+ifeq ($(OS_TARGET),win32)
+TARGET_DIRS_UNCGI=1
+TARGET_DIRS_OPENGL=1
+TARGET_DIRS_GTK=1
+TARGET_DIRS_ZLIB=1
+TARGET_DIRS_MMSYSTEM=1
+endif
+ifeq ($(OS_TARGET),os2)
+TARGET_DIRS_UNCGI=1
+endif
+ifeq ($(OS_TARGET),freebsd)
+TARGET_DIRS_UNCGI=1
+TARGET_DIRS_FPASYNC=1
+TARGET_DIRS_X11=1
+TARGET_DIRS_OPENGL=1
+TARGET_DIRS_GTK=1
+TARGET_DIRS_SYSLOG=1
+TARGET_DIRS_FORMS=1
+TARGET_DIRS_SVGALIB=1
+TARGET_DIRS_GGI=1
+TARGET_DIRS_LIBPNG=1
+TARGET_DIRS_LIBGD=1
+TARGET_DIRS_UTMP=1
+TARGET_DIRS_CMEM=1
+TARGET_DIRS_BFD=1
+TARGET_DIRS_ZLIB=1
+TARGET_DIRS_GDBM=1
+endif
+ifeq ($(OS_TARGET),netbsd)
+TARGET_DIRS_UNCGI=1
+TARGET_DIRS_FPASYNC=1
+TARGET_DIRS_X11=1
+TARGET_DIRS_OPENGL=1
+TARGET_DIRS_GTK=1
+TARGET_DIRS_SYSLOG=1
+TARGET_DIRS_FORMS=1
+TARGET_DIRS_SVGALIB=1
+TARGET_DIRS_GGI=1
+TARGET_DIRS_LIBPNG=1
+TARGET_DIRS_LIBGD=1
+TARGET_DIRS_UTMP=1
+TARGET_DIRS_CMEM=1
+TARGET_DIRS_BFD=1
+TARGET_DIRS_ZLIB=1
+TARGET_DIRS_GDBM=1
+endif
+ifdef TARGET_DIRS_UNZIP
+unzip_all:
+	$(MAKE) -C unzip all
+unzip_debug:
+	$(MAKE) -C unzip debug
+unzip_smart:
+	$(MAKE) -C unzip smart
+unzip_release:
+	$(MAKE) -C unzip release
+unzip_examples:
+	$(MAKE) -C unzip examples
+unzip_shared:
+	$(MAKE) -C unzip shared
+unzip_install:
+	$(MAKE) -C unzip install
+unzip_sourceinstall:
+	$(MAKE) -C unzip sourceinstall
+unzip_exampleinstall:
+	$(MAKE) -C unzip exampleinstall
+unzip_distinstall:
+	$(MAKE) -C unzip distinstall
+unzip_zipinstall:
+	$(MAKE) -C unzip zipinstall
+unzip_zipsourceinstall:
+	$(MAKE) -C unzip zipsourceinstall
+unzip_zipexampleinstall:
+	$(MAKE) -C unzip zipexampleinstall
+unzip_zipdistinstall:
+	$(MAKE) -C unzip zipdistinstall
+unzip_clean:
+	$(MAKE) -C unzip clean
+unzip_distclean:
+	$(MAKE) -C unzip distclean
+unzip_cleanall:
+	$(MAKE) -C unzip cleanall
+unzip_info:
+	$(MAKE) -C unzip info
+unzip_makefiles:
+	$(MAKE) -C unzip makefiles
+unzip:
+	$(MAKE) -C unzip all
+.PHONY: unzip_all unzip_debug unzip_smart unzip_release unzip_examples unzip_shared unzip_install unzip_sourceinstall unzip_exampleinstall unzip_distinstall unzip_zipinstall unzip_zipsourceinstall unzip_zipexampleinstall unzip_zipdistinstall unzip_clean unzip_distclean unzip_cleanall unzip_info unzip_makefiles unzip
+endif
+ifdef TARGET_DIRS_UNCGI
+uncgi_all:
+	$(MAKE) -C uncgi all
+uncgi_debug:
+	$(MAKE) -C uncgi debug
+uncgi_smart:
+	$(MAKE) -C uncgi smart
+uncgi_release:
+	$(MAKE) -C uncgi release
+uncgi_examples:
+	$(MAKE) -C uncgi examples
+uncgi_shared:
+	$(MAKE) -C uncgi shared
+uncgi_install:
+	$(MAKE) -C uncgi install
+uncgi_sourceinstall:
+	$(MAKE) -C uncgi sourceinstall
+uncgi_exampleinstall:
+	$(MAKE) -C uncgi exampleinstall
+uncgi_distinstall:
+	$(MAKE) -C uncgi distinstall
+uncgi_zipinstall:
+	$(MAKE) -C uncgi zipinstall
+uncgi_zipsourceinstall:
+	$(MAKE) -C uncgi zipsourceinstall
+uncgi_zipexampleinstall:
+	$(MAKE) -C uncgi zipexampleinstall
+uncgi_zipdistinstall:
+	$(MAKE) -C uncgi zipdistinstall
+uncgi_clean:
+	$(MAKE) -C uncgi clean
+uncgi_distclean:
+	$(MAKE) -C uncgi distclean
+uncgi_cleanall:
+	$(MAKE) -C uncgi cleanall
+uncgi_info:
+	$(MAKE) -C uncgi info
+uncgi_makefiles:
+	$(MAKE) -C uncgi makefiles
+uncgi:
+	$(MAKE) -C uncgi all
+.PHONY: uncgi_all uncgi_debug uncgi_smart uncgi_release uncgi_examples uncgi_shared uncgi_install uncgi_sourceinstall uncgi_exampleinstall uncgi_distinstall uncgi_zipinstall uncgi_zipsourceinstall uncgi_zipexampleinstall uncgi_zipdistinstall uncgi_clean uncgi_distclean uncgi_cleanall uncgi_info uncgi_makefiles uncgi
+endif
+ifdef TARGET_DIRS_FPASYNC
+fpasync_all:
+	$(MAKE) -C fpasync all
+fpasync_debug:
+	$(MAKE) -C fpasync debug
+fpasync_smart:
+	$(MAKE) -C fpasync smart
+fpasync_release:
+	$(MAKE) -C fpasync release
+fpasync_examples:
+	$(MAKE) -C fpasync examples
+fpasync_shared:
+	$(MAKE) -C fpasync shared
+fpasync_install:
+	$(MAKE) -C fpasync install
+fpasync_sourceinstall:
+	$(MAKE) -C fpasync sourceinstall
+fpasync_exampleinstall:
+	$(MAKE) -C fpasync exampleinstall
+fpasync_distinstall:
+	$(MAKE) -C fpasync distinstall
+fpasync_zipinstall:
+	$(MAKE) -C fpasync zipinstall
+fpasync_zipsourceinstall:
+	$(MAKE) -C fpasync zipsourceinstall
+fpasync_zipexampleinstall:
+	$(MAKE) -C fpasync zipexampleinstall
+fpasync_zipdistinstall:
+	$(MAKE) -C fpasync zipdistinstall
+fpasync_clean:
+	$(MAKE) -C fpasync clean
+fpasync_distclean:
+	$(MAKE) -C fpasync distclean
+fpasync_cleanall:
+	$(MAKE) -C fpasync cleanall
+fpasync_info:
+	$(MAKE) -C fpasync info
+fpasync_makefiles:
+	$(MAKE) -C fpasync makefiles
+fpasync:
+	$(MAKE) -C fpasync all
+.PHONY: fpasync_all fpasync_debug fpasync_smart fpasync_release fpasync_examples fpasync_shared fpasync_install fpasync_sourceinstall fpasync_exampleinstall fpasync_distinstall fpasync_zipinstall fpasync_zipsourceinstall fpasync_zipexampleinstall fpasync_zipdistinstall fpasync_clean fpasync_distclean fpasync_cleanall fpasync_info fpasync_makefiles fpasync
+endif
+ifdef TARGET_DIRS_X11
+x11_all:
+	$(MAKE) -C x11 all
+x11_debug:
+	$(MAKE) -C x11 debug
+x11_smart:
+	$(MAKE) -C x11 smart
+x11_release:
+	$(MAKE) -C x11 release
+x11_examples:
+	$(MAKE) -C x11 examples
+x11_shared:
+	$(MAKE) -C x11 shared
+x11_install:
+	$(MAKE) -C x11 install
+x11_sourceinstall:
+	$(MAKE) -C x11 sourceinstall
+x11_exampleinstall:
+	$(MAKE) -C x11 exampleinstall
+x11_distinstall:
+	$(MAKE) -C x11 distinstall
+x11_zipinstall:
+	$(MAKE) -C x11 zipinstall
+x11_zipsourceinstall:
+	$(MAKE) -C x11 zipsourceinstall
+x11_zipexampleinstall:
+	$(MAKE) -C x11 zipexampleinstall
+x11_zipdistinstall:
+	$(MAKE) -C x11 zipdistinstall
+x11_clean:
+	$(MAKE) -C x11 clean
+x11_distclean:
+	$(MAKE) -C x11 distclean
+x11_cleanall:
+	$(MAKE) -C x11 cleanall
+x11_info:
+	$(MAKE) -C x11 info
+x11_makefiles:
+	$(MAKE) -C x11 makefiles
+x11:
+	$(MAKE) -C x11 all
+.PHONY: x11_all x11_debug x11_smart x11_release x11_examples x11_shared x11_install x11_sourceinstall x11_exampleinstall x11_distinstall x11_zipinstall x11_zipsourceinstall x11_zipexampleinstall x11_zipdistinstall x11_clean x11_distclean x11_cleanall x11_info x11_makefiles x11
+endif
+ifdef TARGET_DIRS_OPENGL
+opengl_all:
+	$(MAKE) -C opengl all
+opengl_debug:
+	$(MAKE) -C opengl debug
+opengl_smart:
+	$(MAKE) -C opengl smart
+opengl_release:
+	$(MAKE) -C opengl release
+opengl_examples:
+	$(MAKE) -C opengl examples
+opengl_shared:
+	$(MAKE) -C opengl shared
+opengl_install:
+	$(MAKE) -C opengl install
+opengl_sourceinstall:
+	$(MAKE) -C opengl sourceinstall
+opengl_exampleinstall:
+	$(MAKE) -C opengl exampleinstall
+opengl_distinstall:
+	$(MAKE) -C opengl distinstall
+opengl_zipinstall:
+	$(MAKE) -C opengl zipinstall
+opengl_zipsourceinstall:
+	$(MAKE) -C opengl zipsourceinstall
+opengl_zipexampleinstall:
+	$(MAKE) -C opengl zipexampleinstall
+opengl_zipdistinstall:
+	$(MAKE) -C opengl zipdistinstall
+opengl_clean:
+	$(MAKE) -C opengl clean
+opengl_distclean:
+	$(MAKE) -C opengl distclean
+opengl_cleanall:
+	$(MAKE) -C opengl cleanall
+opengl_info:
+	$(MAKE) -C opengl info
+opengl_makefiles:
+	$(MAKE) -C opengl makefiles
+opengl:
+	$(MAKE) -C opengl all
+.PHONY: opengl_all opengl_debug opengl_smart opengl_release opengl_examples opengl_shared opengl_install opengl_sourceinstall opengl_exampleinstall opengl_distinstall opengl_zipinstall opengl_zipsourceinstall opengl_zipexampleinstall opengl_zipdistinstall opengl_clean opengl_distclean opengl_cleanall opengl_info opengl_makefiles opengl
+endif
+ifdef TARGET_DIRS_GTK
+gtk_all:
+	$(MAKE) -C gtk all
+gtk_debug:
+	$(MAKE) -C gtk debug
+gtk_smart:
+	$(MAKE) -C gtk smart
+gtk_release:
+	$(MAKE) -C gtk release
+gtk_examples:
+	$(MAKE) -C gtk examples
+gtk_shared:
+	$(MAKE) -C gtk shared
+gtk_install:
+	$(MAKE) -C gtk install
+gtk_sourceinstall:
+	$(MAKE) -C gtk sourceinstall
+gtk_exampleinstall:
+	$(MAKE) -C gtk exampleinstall
+gtk_distinstall:
+	$(MAKE) -C gtk distinstall
+gtk_zipinstall:
+	$(MAKE) -C gtk zipinstall
+gtk_zipsourceinstall:
+	$(MAKE) -C gtk zipsourceinstall
+gtk_zipexampleinstall:
+	$(MAKE) -C gtk zipexampleinstall
+gtk_zipdistinstall:
+	$(MAKE) -C gtk zipdistinstall
+gtk_clean:
+	$(MAKE) -C gtk clean
+gtk_distclean:
+	$(MAKE) -C gtk distclean
+gtk_cleanall:
+	$(MAKE) -C gtk cleanall
+gtk_info:
+	$(MAKE) -C gtk info
+gtk_makefiles:
+	$(MAKE) -C gtk makefiles
+gtk:
+	$(MAKE) -C gtk all
+.PHONY: gtk_all gtk_debug gtk_smart gtk_release gtk_examples gtk_shared gtk_install gtk_sourceinstall gtk_exampleinstall gtk_distinstall gtk_zipinstall gtk_zipsourceinstall gtk_zipexampleinstall gtk_zipdistinstall gtk_clean gtk_distclean gtk_cleanall gtk_info gtk_makefiles gtk
+endif
+ifdef TARGET_DIRS_SYSLOG
+syslog_all:
+	$(MAKE) -C syslog all
+syslog_debug:
+	$(MAKE) -C syslog debug
+syslog_smart:
+	$(MAKE) -C syslog smart
+syslog_release:
+	$(MAKE) -C syslog release
+syslog_examples:
+	$(MAKE) -C syslog examples
+syslog_shared:
+	$(MAKE) -C syslog shared
+syslog_install:
+	$(MAKE) -C syslog install
+syslog_sourceinstall:
+	$(MAKE) -C syslog sourceinstall
+syslog_exampleinstall:
+	$(MAKE) -C syslog exampleinstall
+syslog_distinstall:
+	$(MAKE) -C syslog distinstall
+syslog_zipinstall:
+	$(MAKE) -C syslog zipinstall
+syslog_zipsourceinstall:
+	$(MAKE) -C syslog zipsourceinstall
+syslog_zipexampleinstall:
+	$(MAKE) -C syslog zipexampleinstall
+syslog_zipdistinstall:
+	$(MAKE) -C syslog zipdistinstall
+syslog_clean:
+	$(MAKE) -C syslog clean
+syslog_distclean:
+	$(MAKE) -C syslog distclean
+syslog_cleanall:
+	$(MAKE) -C syslog cleanall
+syslog_info:
+	$(MAKE) -C syslog info
+syslog_makefiles:
+	$(MAKE) -C syslog makefiles
+syslog:
+	$(MAKE) -C syslog all
+.PHONY: syslog_all syslog_debug syslog_smart syslog_release syslog_examples syslog_shared syslog_install syslog_sourceinstall syslog_exampleinstall syslog_distinstall syslog_zipinstall syslog_zipsourceinstall syslog_zipexampleinstall syslog_zipdistinstall syslog_clean syslog_distclean syslog_cleanall syslog_info syslog_makefiles syslog
+endif
+ifdef TARGET_DIRS_FORMS
+forms_all:
+	$(MAKE) -C forms all
+forms_debug:
+	$(MAKE) -C forms debug
+forms_smart:
+	$(MAKE) -C forms smart
+forms_release:
+	$(MAKE) -C forms release
+forms_examples:
+	$(MAKE) -C forms examples
+forms_shared:
+	$(MAKE) -C forms shared
+forms_install:
+	$(MAKE) -C forms install
+forms_sourceinstall:
+	$(MAKE) -C forms sourceinstall
+forms_exampleinstall:
+	$(MAKE) -C forms exampleinstall
+forms_distinstall:
+	$(MAKE) -C forms distinstall
+forms_zipinstall:
+	$(MAKE) -C forms zipinstall
+forms_zipsourceinstall:
+	$(MAKE) -C forms zipsourceinstall
+forms_zipexampleinstall:
+	$(MAKE) -C forms zipexampleinstall
+forms_zipdistinstall:
+	$(MAKE) -C forms zipdistinstall
+forms_clean:
+	$(MAKE) -C forms clean
+forms_distclean:
+	$(MAKE) -C forms distclean
+forms_cleanall:
+	$(MAKE) -C forms cleanall
+forms_info:
+	$(MAKE) -C forms info
+forms_makefiles:
+	$(MAKE) -C forms makefiles
+forms:
+	$(MAKE) -C forms all
+.PHONY: forms_all forms_debug forms_smart forms_release forms_examples forms_shared forms_install forms_sourceinstall forms_exampleinstall forms_distinstall forms_zipinstall forms_zipsourceinstall forms_zipexampleinstall forms_zipdistinstall forms_clean forms_distclean forms_cleanall forms_info forms_makefiles forms
+endif
+ifdef TARGET_DIRS_SVGALIB
+svgalib_all:
+	$(MAKE) -C svgalib all
+svgalib_debug:
+	$(MAKE) -C svgalib debug
+svgalib_smart:
+	$(MAKE) -C svgalib smart
+svgalib_release:
+	$(MAKE) -C svgalib release
+svgalib_examples:
+	$(MAKE) -C svgalib examples
+svgalib_shared:
+	$(MAKE) -C svgalib shared
+svgalib_install:
+	$(MAKE) -C svgalib install
+svgalib_sourceinstall:
+	$(MAKE) -C svgalib sourceinstall
+svgalib_exampleinstall:
+	$(MAKE) -C svgalib exampleinstall
+svgalib_distinstall:
+	$(MAKE) -C svgalib distinstall
+svgalib_zipinstall:
+	$(MAKE) -C svgalib zipinstall
+svgalib_zipsourceinstall:
+	$(MAKE) -C svgalib zipsourceinstall
+svgalib_zipexampleinstall:
+	$(MAKE) -C svgalib zipexampleinstall
+svgalib_zipdistinstall:
+	$(MAKE) -C svgalib zipdistinstall
+svgalib_clean:
+	$(MAKE) -C svgalib clean
+svgalib_distclean:
+	$(MAKE) -C svgalib distclean
+svgalib_cleanall:
+	$(MAKE) -C svgalib cleanall
+svgalib_info:
+	$(MAKE) -C svgalib info
+svgalib_makefiles:
+	$(MAKE) -C svgalib makefiles
+svgalib:
+	$(MAKE) -C svgalib all
+.PHONY: svgalib_all svgalib_debug svgalib_smart svgalib_release svgalib_examples svgalib_shared svgalib_install svgalib_sourceinstall svgalib_exampleinstall svgalib_distinstall svgalib_zipinstall svgalib_zipsourceinstall svgalib_zipexampleinstall svgalib_zipdistinstall svgalib_clean svgalib_distclean svgalib_cleanall svgalib_info svgalib_makefiles svgalib
+endif
+ifdef TARGET_DIRS_GGI
+ggi_all:
+	$(MAKE) -C ggi all
+ggi_debug:
+	$(MAKE) -C ggi debug
+ggi_smart:
+	$(MAKE) -C ggi smart
+ggi_release:
+	$(MAKE) -C ggi release
+ggi_examples:
+	$(MAKE) -C ggi examples
+ggi_shared:
+	$(MAKE) -C ggi shared
+ggi_install:
+	$(MAKE) -C ggi install
+ggi_sourceinstall:
+	$(MAKE) -C ggi sourceinstall
+ggi_exampleinstall:
+	$(MAKE) -C ggi exampleinstall
+ggi_distinstall:
+	$(MAKE) -C ggi distinstall
+ggi_zipinstall:
+	$(MAKE) -C ggi zipinstall
+ggi_zipsourceinstall:
+	$(MAKE) -C ggi zipsourceinstall
+ggi_zipexampleinstall:
+	$(MAKE) -C ggi zipexampleinstall
+ggi_zipdistinstall:
+	$(MAKE) -C ggi zipdistinstall
+ggi_clean:
+	$(MAKE) -C ggi clean
+ggi_distclean:
+	$(MAKE) -C ggi distclean
+ggi_cleanall:
+	$(MAKE) -C ggi cleanall
+ggi_info:
+	$(MAKE) -C ggi info
+ggi_makefiles:
+	$(MAKE) -C ggi makefiles
+ggi:
+	$(MAKE) -C ggi all
+.PHONY: ggi_all ggi_debug ggi_smart ggi_release ggi_examples ggi_shared ggi_install ggi_sourceinstall ggi_exampleinstall ggi_distinstall ggi_zipinstall ggi_zipsourceinstall ggi_zipexampleinstall ggi_zipdistinstall ggi_clean ggi_distclean ggi_cleanall ggi_info ggi_makefiles ggi
+endif
+ifdef TARGET_DIRS_LIBPNG
+libpng_all:
+	$(MAKE) -C libpng all
+libpng_debug:
+	$(MAKE) -C libpng debug
+libpng_smart:
+	$(MAKE) -C libpng smart
+libpng_release:
+	$(MAKE) -C libpng release
+libpng_examples:
+	$(MAKE) -C libpng examples
+libpng_shared:
+	$(MAKE) -C libpng shared
+libpng_install:
+	$(MAKE) -C libpng install
+libpng_sourceinstall:
+	$(MAKE) -C libpng sourceinstall
+libpng_exampleinstall:
+	$(MAKE) -C libpng exampleinstall
+libpng_distinstall:
+	$(MAKE) -C libpng distinstall
+libpng_zipinstall:
+	$(MAKE) -C libpng zipinstall
+libpng_zipsourceinstall:
+	$(MAKE) -C libpng zipsourceinstall
+libpng_zipexampleinstall:
+	$(MAKE) -C libpng zipexampleinstall
+libpng_zipdistinstall:
+	$(MAKE) -C libpng zipdistinstall
+libpng_clean:
+	$(MAKE) -C libpng clean
+libpng_distclean:
+	$(MAKE) -C libpng distclean
+libpng_cleanall:
+	$(MAKE) -C libpng cleanall
+libpng_info:
+	$(MAKE) -C libpng info
+libpng_makefiles:
+	$(MAKE) -C libpng makefiles
+libpng:
+	$(MAKE) -C libpng all
+.PHONY: libpng_all libpng_debug libpng_smart libpng_release libpng_examples libpng_shared libpng_install libpng_sourceinstall libpng_exampleinstall libpng_distinstall libpng_zipinstall libpng_zipsourceinstall libpng_zipexampleinstall libpng_zipdistinstall libpng_clean libpng_distclean libpng_cleanall libpng_info libpng_makefiles libpng
+endif
+ifdef TARGET_DIRS_LIBGD
+libgd_all:
+	$(MAKE) -C libgd all
+libgd_debug:
+	$(MAKE) -C libgd debug
+libgd_smart:
+	$(MAKE) -C libgd smart
+libgd_release:
+	$(MAKE) -C libgd release
+libgd_examples:
+	$(MAKE) -C libgd examples
+libgd_shared:
+	$(MAKE) -C libgd shared
+libgd_install:
+	$(MAKE) -C libgd install
+libgd_sourceinstall:
+	$(MAKE) -C libgd sourceinstall
+libgd_exampleinstall:
+	$(MAKE) -C libgd exampleinstall
+libgd_distinstall:
+	$(MAKE) -C libgd distinstall
+libgd_zipinstall:
+	$(MAKE) -C libgd zipinstall
+libgd_zipsourceinstall:
+	$(MAKE) -C libgd zipsourceinstall
+libgd_zipexampleinstall:
+	$(MAKE) -C libgd zipexampleinstall
+libgd_zipdistinstall:
+	$(MAKE) -C libgd zipdistinstall
+libgd_clean:
+	$(MAKE) -C libgd clean
+libgd_distclean:
+	$(MAKE) -C libgd distclean
+libgd_cleanall:
+	$(MAKE) -C libgd cleanall
+libgd_info:
+	$(MAKE) -C libgd info
+libgd_makefiles:
+	$(MAKE) -C libgd makefiles
+libgd:
+	$(MAKE) -C libgd all
+.PHONY: libgd_all libgd_debug libgd_smart libgd_release libgd_examples libgd_shared libgd_install libgd_sourceinstall libgd_exampleinstall libgd_distinstall libgd_zipinstall libgd_zipsourceinstall libgd_zipexampleinstall libgd_zipdistinstall libgd_clean libgd_distclean libgd_cleanall libgd_info libgd_makefiles libgd
+endif
+ifdef TARGET_DIRS_UTMP
+utmp_all:
+	$(MAKE) -C utmp all
+utmp_debug:
+	$(MAKE) -C utmp debug
+utmp_smart:
+	$(MAKE) -C utmp smart
+utmp_release:
+	$(MAKE) -C utmp release
+utmp_examples:
+	$(MAKE) -C utmp examples
+utmp_shared:
+	$(MAKE) -C utmp shared
+utmp_install:
+	$(MAKE) -C utmp install
+utmp_sourceinstall:
+	$(MAKE) -C utmp sourceinstall
+utmp_exampleinstall:
+	$(MAKE) -C utmp exampleinstall
+utmp_distinstall:
+	$(MAKE) -C utmp distinstall
+utmp_zipinstall:
+	$(MAKE) -C utmp zipinstall
+utmp_zipsourceinstall:
+	$(MAKE) -C utmp zipsourceinstall
+utmp_zipexampleinstall:
+	$(MAKE) -C utmp zipexampleinstall
+utmp_zipdistinstall:
+	$(MAKE) -C utmp zipdistinstall
+utmp_clean:
+	$(MAKE) -C utmp clean
+utmp_distclean:
+	$(MAKE) -C utmp distclean
+utmp_cleanall:
+	$(MAKE) -C utmp cleanall
+utmp_info:
+	$(MAKE) -C utmp info
+utmp_makefiles:
+	$(MAKE) -C utmp makefiles
+utmp:
+	$(MAKE) -C utmp all
+.PHONY: utmp_all utmp_debug utmp_smart utmp_release utmp_examples utmp_shared utmp_install utmp_sourceinstall utmp_exampleinstall utmp_distinstall utmp_zipinstall utmp_zipsourceinstall utmp_zipexampleinstall utmp_zipdistinstall utmp_clean utmp_distclean utmp_cleanall utmp_info utmp_makefiles utmp
+endif
+ifdef TARGET_DIRS_CMEM
+cmem_all:
+	$(MAKE) -C cmem all
+cmem_debug:
+	$(MAKE) -C cmem debug
+cmem_smart:
+	$(MAKE) -C cmem smart
+cmem_release:
+	$(MAKE) -C cmem release
+cmem_examples:
+	$(MAKE) -C cmem examples
+cmem_shared:
+	$(MAKE) -C cmem shared
+cmem_install:
+	$(MAKE) -C cmem install
+cmem_sourceinstall:
+	$(MAKE) -C cmem sourceinstall
+cmem_exampleinstall:
+	$(MAKE) -C cmem exampleinstall
+cmem_distinstall:
+	$(MAKE) -C cmem distinstall
+cmem_zipinstall:
+	$(MAKE) -C cmem zipinstall
+cmem_zipsourceinstall:
+	$(MAKE) -C cmem zipsourceinstall
+cmem_zipexampleinstall:
+	$(MAKE) -C cmem zipexampleinstall
+cmem_zipdistinstall:
+	$(MAKE) -C cmem zipdistinstall
+cmem_clean:
+	$(MAKE) -C cmem clean
+cmem_distclean:
+	$(MAKE) -C cmem distclean
+cmem_cleanall:
+	$(MAKE) -C cmem cleanall
+cmem_info:
+	$(MAKE) -C cmem info
+cmem_makefiles:
+	$(MAKE) -C cmem makefiles
+cmem:
+	$(MAKE) -C cmem all
+.PHONY: cmem_all cmem_debug cmem_smart cmem_release cmem_examples cmem_shared cmem_install cmem_sourceinstall cmem_exampleinstall cmem_distinstall cmem_zipinstall cmem_zipsourceinstall cmem_zipexampleinstall cmem_zipdistinstall cmem_clean cmem_distclean cmem_cleanall cmem_info cmem_makefiles cmem
+endif
+ifdef TARGET_DIRS_BFD
+bfd_all:
+	$(MAKE) -C bfd all
+bfd_debug:
+	$(MAKE) -C bfd debug
+bfd_smart:
+	$(MAKE) -C bfd smart
+bfd_release:
+	$(MAKE) -C bfd release
+bfd_examples:
+	$(MAKE) -C bfd examples
+bfd_shared:
+	$(MAKE) -C bfd shared
+bfd_install:
+	$(MAKE) -C bfd install
+bfd_sourceinstall:
+	$(MAKE) -C bfd sourceinstall
+bfd_exampleinstall:
+	$(MAKE) -C bfd exampleinstall
+bfd_distinstall:
+	$(MAKE) -C bfd distinstall
+bfd_zipinstall:
+	$(MAKE) -C bfd zipinstall
+bfd_zipsourceinstall:
+	$(MAKE) -C bfd zipsourceinstall
+bfd_zipexampleinstall:
+	$(MAKE) -C bfd zipexampleinstall
+bfd_zipdistinstall:
+	$(MAKE) -C bfd zipdistinstall
+bfd_clean:
+	$(MAKE) -C bfd clean
+bfd_distclean:
+	$(MAKE) -C bfd distclean
+bfd_cleanall:
+	$(MAKE) -C bfd cleanall
+bfd_info:
+	$(MAKE) -C bfd info
+bfd_makefiles:
+	$(MAKE) -C bfd makefiles
+bfd:
+	$(MAKE) -C bfd all
+.PHONY: bfd_all bfd_debug bfd_smart bfd_release bfd_examples bfd_shared bfd_install bfd_sourceinstall bfd_exampleinstall bfd_distinstall bfd_zipinstall bfd_zipsourceinstall bfd_zipexampleinstall bfd_zipdistinstall bfd_clean bfd_distclean bfd_cleanall bfd_info bfd_makefiles bfd
+endif
+ifdef TARGET_DIRS_ZLIB
+zlib_all:
+	$(MAKE) -C zlib all
+zlib_debug:
+	$(MAKE) -C zlib debug
+zlib_smart:
+	$(MAKE) -C zlib smart
+zlib_release:
+	$(MAKE) -C zlib release
+zlib_examples:
+	$(MAKE) -C zlib examples
+zlib_shared:
+	$(MAKE) -C zlib shared
+zlib_install:
+	$(MAKE) -C zlib install
+zlib_sourceinstall:
+	$(MAKE) -C zlib sourceinstall
+zlib_exampleinstall:
+	$(MAKE) -C zlib exampleinstall
+zlib_distinstall:
+	$(MAKE) -C zlib distinstall
+zlib_zipinstall:
+	$(MAKE) -C zlib zipinstall
+zlib_zipsourceinstall:
+	$(MAKE) -C zlib zipsourceinstall
+zlib_zipexampleinstall:
+	$(MAKE) -C zlib zipexampleinstall
+zlib_zipdistinstall:
+	$(MAKE) -C zlib zipdistinstall
+zlib_clean:
+	$(MAKE) -C zlib clean
+zlib_distclean:
+	$(MAKE) -C zlib distclean
+zlib_cleanall:
+	$(MAKE) -C zlib cleanall
+zlib_info:
+	$(MAKE) -C zlib info
+zlib_makefiles:
+	$(MAKE) -C zlib makefiles
+zlib:
+	$(MAKE) -C zlib all
+.PHONY: zlib_all zlib_debug zlib_smart zlib_release zlib_examples zlib_shared zlib_install zlib_sourceinstall zlib_exampleinstall zlib_distinstall zlib_zipinstall zlib_zipsourceinstall zlib_zipexampleinstall zlib_zipdistinstall zlib_clean zlib_distclean zlib_cleanall zlib_info zlib_makefiles zlib
+endif
+ifdef TARGET_DIRS_GDBM
+gdbm_all:
+	$(MAKE) -C gdbm all
+gdbm_debug:
+	$(MAKE) -C gdbm debug
+gdbm_smart:
+	$(MAKE) -C gdbm smart
+gdbm_release:
+	$(MAKE) -C gdbm release
+gdbm_examples:
+	$(MAKE) -C gdbm examples
+gdbm_shared:
+	$(MAKE) -C gdbm shared
+gdbm_install:
+	$(MAKE) -C gdbm install
+gdbm_sourceinstall:
+	$(MAKE) -C gdbm sourceinstall
+gdbm_exampleinstall:
+	$(MAKE) -C gdbm exampleinstall
+gdbm_distinstall:
+	$(MAKE) -C gdbm distinstall
+gdbm_zipinstall:
+	$(MAKE) -C gdbm zipinstall
+gdbm_zipsourceinstall:
+	$(MAKE) -C gdbm zipsourceinstall
+gdbm_zipexampleinstall:
+	$(MAKE) -C gdbm zipexampleinstall
+gdbm_zipdistinstall:
+	$(MAKE) -C gdbm zipdistinstall
+gdbm_clean:
+	$(MAKE) -C gdbm clean
+gdbm_distclean:
+	$(MAKE) -C gdbm distclean
+gdbm_cleanall:
+	$(MAKE) -C gdbm cleanall
+gdbm_info:
+	$(MAKE) -C gdbm info
+gdbm_makefiles:
+	$(MAKE) -C gdbm makefiles
+gdbm:
+	$(MAKE) -C gdbm all
+.PHONY: gdbm_all gdbm_debug gdbm_smart gdbm_release gdbm_examples gdbm_shared gdbm_install gdbm_sourceinstall gdbm_exampleinstall gdbm_distinstall gdbm_zipinstall gdbm_zipsourceinstall gdbm_zipexampleinstall gdbm_zipdistinstall gdbm_clean gdbm_distclean gdbm_cleanall gdbm_info gdbm_makefiles gdbm
+endif
+ifdef TARGET_DIRS_MMSYSTEM
+mmsystem_all:
+	$(MAKE) -C mmsystem all
+mmsystem_debug:
+	$(MAKE) -C mmsystem debug
+mmsystem_smart:
+	$(MAKE) -C mmsystem smart
+mmsystem_release:
+	$(MAKE) -C mmsystem release
+mmsystem_examples:
+	$(MAKE) -C mmsystem examples
+mmsystem_shared:
+	$(MAKE) -C mmsystem shared
+mmsystem_install:
+	$(MAKE) -C mmsystem install
+mmsystem_sourceinstall:
+	$(MAKE) -C mmsystem sourceinstall
+mmsystem_exampleinstall:
+	$(MAKE) -C mmsystem exampleinstall
+mmsystem_distinstall:
+	$(MAKE) -C mmsystem distinstall
+mmsystem_zipinstall:
+	$(MAKE) -C mmsystem zipinstall
+mmsystem_zipsourceinstall:
+	$(MAKE) -C mmsystem zipsourceinstall
+mmsystem_zipexampleinstall:
+	$(MAKE) -C mmsystem zipexampleinstall
+mmsystem_zipdistinstall:
+	$(MAKE) -C mmsystem zipdistinstall
+mmsystem_clean:
+	$(MAKE) -C mmsystem clean
+mmsystem_distclean:
+	$(MAKE) -C mmsystem distclean
+mmsystem_cleanall:
+	$(MAKE) -C mmsystem cleanall
+mmsystem_info:
+	$(MAKE) -C mmsystem info
+mmsystem_makefiles:
+	$(MAKE) -C mmsystem makefiles
+mmsystem:
+	$(MAKE) -C mmsystem all
+.PHONY: mmsystem_all mmsystem_debug mmsystem_smart mmsystem_release mmsystem_examples mmsystem_shared mmsystem_install mmsystem_sourceinstall mmsystem_exampleinstall mmsystem_distinstall mmsystem_zipinstall mmsystem_zipsourceinstall mmsystem_zipexampleinstall mmsystem_zipdistinstall mmsystem_clean mmsystem_distclean mmsystem_cleanall mmsystem_info mmsystem_makefiles mmsystem
+endif
+all: $(addsuffix _all,$(TARGET_DIRS))
+debug: $(addsuffix _debug,$(TARGET_DIRS))
+smart: $(addsuffix _smart,$(TARGET_DIRS))
+release: $(addsuffix _release,$(TARGET_DIRS))
+examples: $(addsuffix _examples,$(TARGET_DIRS))
+shared: $(addsuffix _shared,$(TARGET_DIRS))
+install: $(addsuffix _install,$(TARGET_DIRS))
+sourceinstall: $(addsuffix _sourceinstall,$(TARGET_DIRS))
+exampleinstall: $(addsuffix _exampleinstall,$(TARGET_DIRS))
+distinstall: $(addsuffix _distinstall,$(TARGET_DIRS))
+zipinstall: $(addsuffix _zipinstall,$(TARGET_DIRS))
+zipsourceinstall: $(addsuffix _zipsourceinstall,$(TARGET_DIRS))
+zipexampleinstall: $(addsuffix _zipexampleinstall,$(TARGET_DIRS))
+zipdistinstall: $(addsuffix _zipdistinstall,$(TARGET_DIRS))
+clean: $(addsuffix _clean,$(TARGET_DIRS))
+distclean: $(addsuffix _distclean,$(TARGET_DIRS))
+cleanall: $(addsuffix _cleanall,$(TARGET_DIRS))
+info: fpc_info
+makefiles: fpc_makefiles $(addsuffix _makefiles,$(TARGET_DIRS))
+.PHONY: all debug smart release examples shared install sourceinstall exampleinstall distinstall zipinstall zipsourceinstall zipexampleinstall zipdistinstall clean distclean cleanall info makefiles
+ifneq ($(wildcard fpcmake.loc),)
+include fpcmake.loc
+endif

+ 28 - 0
packages/extra/Makefile.fpc

@@ -0,0 +1,28 @@
+#
+#   Makefile.fpc for Free Pascal Packages
+#
+
+[target]
+dirs=unzip
+dirs_linux=uncgi fpasync \
+           x11 opengl gtk syslog \
+           forms svgalib ggi libpng libgd \
+           utmp cmem bfd zlib gdbm
+dirs_netbsd=uncgi fpasync \
+            x11 opengl gtk syslog \
+            forms svgalib ggi libpng libgd \
+            utmp cmem bfd zlib gdbm
+dirs_freebsd=uncgi fpasync \
+             x11 opengl gtk syslog \
+             forms svgalib ggi libpng libgd \
+             utmp cmem bfd zlib gdbm
+dirs_win32=uncgi opengl gtk \
+           zlib mmsystem
+dirs_os2=uncgi
+dirs_go32v2=uncgi
+
+[install]
+fpcpackage=y
+
+[default]
+fpcdir=../..

+ 1218 - 0
packages/extra/bfd/Makefile

@@ -0,0 +1,1218 @@
+#
+# Don't edit, this file is generated by FPCMake Version 1.1 [2002/01/29]
+#
+default: all
+MAKEFILETARGETS=linux go32v2 win32 os2 freebsd beos netbsd amiga atari sunos qnx
+override PATH:=$(subst \,/,$(PATH))
+ifeq ($(findstring ;,$(PATH)),)
+inUnix=1
+SEARCHPATH:=$(filter-out .,$(subst :, ,$(PATH)))
+else
+SEARCHPATH:=$(subst ;, ,$(PATH))
+endif
+PWD:=$(strip $(wildcard $(addsuffix /pwd.exe,$(SEARCHPATH))))
+ifeq ($(PWD),)
+PWD:=$(strip $(wildcard $(addsuffix /pwd,$(SEARCHPATH))))
+ifeq ($(PWD),)
+$(error You need the GNU utils package to use this Makefile)
+else
+PWD:=$(firstword $(PWD))
+SRCEXEEXT=
+endif
+else
+PWD:=$(firstword $(PWD))
+SRCEXEEXT=.exe
+endif
+ifndef inUnix
+ifeq ($(OS),Windows_NT)
+inWinNT=1
+else
+ifdef OS2_SHELL
+inOS2=1
+endif
+endif
+else
+ifneq ($(findstring cygwin,$(MACHTYPE)),)
+inCygWin=1
+endif
+endif
+ifeq ($(OS_TARGET),freebsd)
+BSDhier=1
+endif
+ifeq ($(OS_TARGET),netbsd)
+BSDhier=1
+endif
+ifdef inUnix
+BATCHEXT=.sh
+else
+ifdef inOS2
+BATCHEXT=.cmd
+else
+BATCHEXT=.bat
+endif
+endif
+ifdef inUnix
+PATHSEP=/
+else
+PATHSEP:=$(subst /,\,/)
+endif
+ifdef PWD
+BASEDIR:=$(subst \,/,$(shell $(PWD)))
+ifdef inCygWin
+ifneq ($(findstring /cygdrive/,$(BASEDIR)),)
+BASENODIR:=$(patsubst /cygdrive%,%,$(BASEDIR))
+BASEDRIVE:=$(firstword $(subst /, ,$(BASENODIR)))
+BASEDIR:=$(subst /cygdrive/$(BASEDRIVE)/,$(BASEDRIVE):/,$(BASEDIR))
+endif
+endif
+else
+BASEDIR=.
+endif
+override DEFAULT_FPCDIR=../../..
+ifndef FPC
+ifdef PP
+FPC=$(PP)
+endif
+endif
+ifndef FPC
+FPCPROG:=$(strip $(wildcard $(addsuffix /fpc$(SRCEXEEXT),$(SEARCHPATH))))
+ifneq ($(FPCPROG),)
+FPCPROG:=$(firstword $(FPCPROG))
+FPC:=$(shell $(FPCPROG) -PB)
+ifneq ($(findstring Error,$(FPC)),)
+override FPC=ppc386
+endif
+else
+override FPC=ppc386
+endif
+endif
+override FPC:=$(subst $(SRCEXEEXT),,$(FPC))
+override FPC:=$(subst \,/,$(FPC))$(SRCEXEEXT)
+ifndef FPC_VERSION
+FPC_VERSION:=$(shell $(FPC) -iV)
+endif
+export FPC FPC_VERSION
+ifeq ($(findstring 1.0.,$(FPC_VERSION)),)
+COMPILERINFO:=$(shell $(FPC) -iSP -iTP -iSO -iTO)
+ifndef CPU_SOURCE
+CPU_SOURCE:=$(word 1,$(COMPILERINFO))
+endif
+ifndef CPU_TARGET
+CPU_TARGET:=$(word 2,$(COMPILERINFO))
+endif
+ifndef OS_SOURCE
+OS_SOURCE:=$(word 3,$(COMPILERINFO))
+endif
+ifndef OS_TARGET
+OS_TARGET:=$(word 4,$(COMPILERINFO))
+endif
+else
+ifndef CPU_SOURCE
+CPU_SOURCE:=$(shell $(FPC) -iSP)
+endif
+ifndef CPU_TARGET
+CPU_TARGET:=$(shell $(FPC) -iTP)
+endif
+ifndef OS_SOURCE
+OS_SOURCE:=$(shell $(FPC) -iSO)
+endif
+ifndef OS_TARGET
+OS_TARGET:=$(shell $(FPC) -iTO)
+endif
+endif
+FULL_TARGET=$(CPU_TARGET)-$(OS_TARGET)
+FULL_SOURCE=$(CPU_SOURCE)-$(OS_SOURCE)
+ifneq ($(FULL_TARGET),$(FULL_SOURCE))
+CROSSCOMPILE=1
+endif
+ifeq ($(findstring makefile,$(MAKECMDGOALS)),)
+ifeq ($(findstring $(OS_TARGET),$(MAKEFILETARGETS)),)
+$(error The Makefile doesn't support target $(OS_TARGET), please run fpcmake first)
+endif
+endif
+export OS_TARGET OS_SOURCE CPU_TARGET CPU_SOURCE FULL_TARGET FULL_SOURCE CROSSCOMPILE
+ifdef FPCDIR
+override FPCDIR:=$(subst \,/,$(FPCDIR))
+ifeq ($(wildcard $(addprefix $(FPCDIR)/,rtl units)),)
+override FPCDIR=wrong
+endif
+else
+override FPCDIR=wrong
+endif
+ifdef DEFAULT_FPCDIR
+ifeq ($(FPCDIR),wrong)
+override FPCDIR:=$(subst \,/,$(DEFAULT_FPCDIR))
+ifeq ($(wildcard $(addprefix $(FPCDIR)/,rtl units)),)
+override FPCDIR=wrong
+endif
+endif
+endif
+ifeq ($(FPCDIR),wrong)
+ifdef inUnix
+override FPCDIR=/usr/local/lib/fpc/$(FPC_VERSION)
+ifeq ($(wildcard $(FPCDIR)/units),)
+override FPCDIR=/usr/lib/fpc/$(FPC_VERSION)
+endif
+else
+override FPCDIR:=$(subst /$(FPC),,$(firstword $(strip $(wildcard $(addsuffix /$(FPC),$(SEARCHPATH))))))
+override FPCDIR:=$(FPCDIR)/..
+ifeq ($(wildcard $(addprefix $(FPCDIR)/,rtl units)),)
+override FPCDIR:=$(FPCDIR)/..
+ifeq ($(wildcard $(addprefix $(FPCDIR)/,rtl units)),)
+override FPCDIR=c:/pp
+endif
+endif
+endif
+endif
+ifndef CROSSDIR
+CROSSDIR:=$(FPCDIR)/cross/$(FULL_TARGET)
+endif
+ifndef CROSSTARGETDIR
+CROSSTARGETDIR=$(CROSSDIR)/$(FULL_TARGET)
+endif
+ifdef CROSSCOMPILE
+UNITSDIR:=$(wildcard $(CROSSTARGETDIR)/units)
+ifeq ($(UNITSDIR),)
+UNITSDIR:=$(wildcard $(FPCDIR)/units/$(OS_TARGET))
+endif
+else
+UNITSDIR:=$(wildcard $(FPCDIR)/units/$(OS_TARGET))
+endif
+PACKAGESDIR:=$(wildcard $(FPCDIR) $(FPCDIR)/packages/base $(FPCDIR)/packages/extra)
+override PACKAGE_NAME=bfd
+override PACKAGE_VERSION=1.0.6
+override TARGET_UNITS+=bfd
+override INSTALL_FPCPACKAGE=y
+ifdef REQUIRE_UNITSDIR
+override UNITSDIR+=$(REQUIRE_UNITSDIR)
+endif
+ifdef REQUIRE_PACKAGESDIR
+override PACKAGESDIR+=$(REQUIRE_PACKAGESDIR)
+endif
+ifdef ZIPINSTALL
+ifeq ($(OS_TARGET),linux)
+UNIXINSTALLDIR=1
+endif
+ifeq ($(OS_TARGET),freebsd)
+UNIXINSTALLDIR=1
+endif
+ifeq ($(OS_TARGET),netbsd)
+UNIXINSTALLDIR=1
+endif
+ifeq ($(OS_TARGET),sunos)
+UNIXINSTALLDIR=1
+endif
+else
+ifeq ($(OS_SOURCE),linux)
+UNIXINSTALLDIR=1
+endif
+ifeq ($(OS_SOURCE),freebsd)
+UNIXINSTALLDIR=1
+endif
+ifeq ($(OS_SOURCE),netbsd)
+UNIXINSTALLDIR=1
+endif
+ifeq ($(OS_TARGET),sunos)
+UNIXINSTALLDIR=1
+endif
+endif
+ifndef INSTALL_PREFIX
+ifdef PREFIX
+INSTALL_PREFIX=$(PREFIX)
+endif
+endif
+ifndef INSTALL_PREFIX
+ifdef UNIXINSTALLDIR
+INSTALL_PREFIX=/usr/local
+else
+ifdef INSTALL_FPCPACKAGE
+INSTALL_BASEDIR:=/pp
+else
+INSTALL_BASEDIR:=/$(PACKAGE_NAME)
+endif
+endif
+endif
+export INSTALL_PREFIX
+ifndef DIST_DESTDIR
+DIST_DESTDIR:=$(BASEDIR)
+endif
+export DIST_DESTDIR
+ifndef INSTALL_BASEDIR
+ifdef UNIXINSTALLDIR
+ifdef INSTALL_FPCPACKAGE
+INSTALL_BASEDIR:=$(INSTALL_PREFIX)/lib/fpc/$(FPC_VERSION)
+else
+INSTALL_BASEDIR:=$(INSTALL_PREFIX)/lib/$(PACKAGE_NAME)
+endif
+else
+INSTALL_BASEDIR:=$(INSTALL_PREFIX)
+endif
+endif
+ifndef INSTALL_BINDIR
+ifdef UNIXINSTALLDIR
+INSTALL_BINDIR:=$(INSTALL_PREFIX)/bin
+else
+INSTALL_BINDIR:=$(INSTALL_BASEDIR)/bin
+ifdef INSTALL_FPCPACKAGE
+INSTALL_BINDIR:=$(INSTALL_BINDIR)/$(OS_TARGET)
+endif
+endif
+endif
+ifndef INSTALL_UNITDIR
+ifdef CROSSCOMPILE
+INSTALL_UNITDIR:=$(INSTALL_BASEDIR)/cross/$(FULL_TARGET)/units
+else
+INSTALL_UNITDIR:=$(INSTALL_BASEDIR)/units/$(OS_TARGET)
+endif
+ifdef INSTALL_FPCPACKAGE
+ifdef PACKAGE_NAME
+INSTALL_UNITDIR:=$(INSTALL_UNITDIR)/$(PACKAGE_NAME)
+endif
+endif
+endif
+ifndef INSTALL_LIBDIR
+ifdef UNIXINSTALLDIR
+INSTALL_LIBDIR:=$(INSTALL_PREFIX)/lib
+else
+INSTALL_LIBDIR:=$(INSTALL_UNITDIR)
+endif
+endif
+ifndef INSTALL_SOURCEDIR
+ifdef UNIXINSTALLDIR
+ifdef INSTALL_FPCPACKAGE
+ifdef BSDhier
+INSTALL_SOURCEDIR:=$(INSTALL_PREFIX)/share/src/fpc-$(FPC_VERSION)/$(PACKAGE_NAME)
+else
+INSTALL_SOURCEDIR:=$(INSTALL_PREFIX)/src/fpc-$(FPC_VERSION)/$(PACKAGE_NAME)
+endif
+else
+ifdef BSDhier
+INSTALL_SOURCEDIR:=$(INSTALL_PREFIX)/share/src/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
+else
+INSTALL_SOURCEDIR:=$(INSTALL_PREFIX)/src/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
+endif
+endif
+else
+ifdef INSTALL_FPCPACKAGE
+INSTALL_SOURCEDIR:=$(INSTALL_BASEDIR)/source/$(PACKAGE_NAME)
+else
+INSTALL_SOURCEDIRL:=$(INSTALL_BASEDIR)/source
+endif
+endif
+endif
+ifndef INSTALL_DOCDIR
+ifdef UNIXINSTALLDIR
+ifdef INSTALL_FPCPACKAGE
+ifdef BSDhier
+INSTALL_DOCDIR:=$(INSTALL_PREFIX)/share/doc/fpc-$(FPC_VERSION)/$(PACKAGE_NAME)
+else
+INSTALL_DOCDIR:=$(INSTALL_PREFIX)/doc/fpc-$(FPC_VERSION)/$(PACKAGE_NAME)
+endif
+else
+ifdef BSDhier
+INSTALL_DOCDIR:=$(INSTALL_PREFIX)/share/doc/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
+else
+INSTALL_DOCDIR:=$(INSTALL_PREFIX)/doc/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
+endif
+endif
+else
+ifdef INSTALL_FPCPACKAGE
+INSTALL_DOCDIR:=$(INSTALL_BASEDIR)/doc/$(PACKAGE_NAME)
+else
+INSTALL_DOCDIR:=$(INSTALL_BASEDIR)/doc
+endif
+endif
+endif
+ifndef INSTALL_EXAMPLEDIR
+ifdef UNIXINSTALLDIR
+ifdef INSTALL_FPCPACKAGE
+ifdef BSDhier
+INSTALL_EXAMPLEDIR:=$(INSTALL_PREFIX)/share/examples/fpc-$(FPC_VERSION)/$(PACKAGE_NAME)
+else
+INSTALL_EXAMPLEDIR:=$(INSTALL_PREFIX)/doc/fpc-$(FPC_VERSION)/examples/$(PACKAGE_NAME)
+endif
+else
+ifdef BSDhier
+INSTALL_EXAMPLEDIR:=$(INSTALL_PREFIX)/share/examples/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
+else
+INSTALL_EXAMPLEDIR:=$(INSTALL_PREFIX)/doc/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
+endif
+endif
+else
+ifdef INSTALL_FPCPACKAGE
+INSTALL_EXAMPLEDIR:=$(INSTALL_BASEDIR)/examples/$(PACKAGE_NAME)
+else
+INSTALL_EXAMPLEDIR:=$(INSTALL_BASEDIR)/examples
+endif
+endif
+endif
+ifndef INSTALL_DATADIR
+INSTALL_DATADIR=$(INSTALL_BASEDIR)
+endif
+ifdef CROSSCOMPILE
+ifndef CROSSBINDIR
+CROSSBINDIR:=$(wildcard $(CROSSTARGETDIR)/bin/$(FULL_SOURCE))
+ifeq ($(CROSSBINDIR),)
+CROSSBINDIR:=$(wildcard $(INSTALL_BASEDIR)/cross/$(FULL_TARGET)/bin/$(FULL_SOURCE))
+endif
+endif
+else
+CROSSBINDIR=
+endif
+LOADEREXT=.as
+EXEEXT=.exe
+PPLEXT=.ppl
+PPUEXT=.ppu
+OEXT=.o
+ASMEXT=.s
+SMARTEXT=.sl
+STATICLIBEXT=.a
+SHAREDLIBEXT=.so
+STATICLIBPREFIX=libp
+RSTEXT=.rst
+FPCMADE=fpcmade
+ifeq ($(OS_TARGET),go32v1)
+PPUEXT=.pp1
+OEXT=.o1
+ASMEXT=.s1
+SMARTEXT=.sl1
+STATICLIBEXT=.a1
+SHAREDLIBEXT=.so1
+STATICLIBPREFIX=
+FPCMADE=fpcmade.v1
+PACKAGESUFFIX=v1
+endif
+ifeq ($(OS_TARGET),go32v2)
+STATICLIBPREFIX=
+FPCMADE=fpcmade.dos
+ZIPSUFFIX=go32
+endif
+ifeq ($(OS_TARGET),linux)
+EXEEXT=
+HASSHAREDLIB=1
+FPCMADE=fpcmade.lnx
+ZIPSUFFIX=linux
+endif
+ifeq ($(OS_TARGET),freebsd)
+EXEEXT=
+HASSHAREDLIB=1
+FPCMADE=fpcmade.freebsd
+ZIPSUFFIX=freebsd
+endif
+ifeq ($(OS_TARGET),netbsd)
+EXEEXT=
+HASSHAREDLIB=1
+FPCMADE=fpcmade.netbsd
+ZIPSUFFIX=netbsd
+endif
+ifeq ($(OS_TARGET),win32)
+PPUEXT=.ppw
+OEXT=.ow
+ASMEXT=.sw
+SMARTEXT=.slw
+STATICLIBEXT=.aw
+SHAREDLIBEXT=.dll
+FPCMADE=fpcmade.w32
+ZIPSUFFIX=w32
+endif
+ifeq ($(OS_TARGET),os2)
+PPUEXT=.ppo
+ASMEXT=.so2
+OEXT=.oo2
+AOUTEXT=.out
+SMARTEXT=.so
+STATICLIBEXT=.ao2
+SHAREDLIBEXT=.dll
+FPCMADE=fpcmade.os2
+ZIPSUFFIX=emx
+endif
+ifeq ($(OS_TARGET),amiga)
+EXEEXT=
+PPUEXT=.ppa
+ASMEXT=.asm
+OEXT=.o
+SMARTEXT=.sl
+STATICLIBEXT=.a
+SHAREDLIBEXT=.library
+FPCMADE=fpcmade.amg
+endif
+ifeq ($(OS_TARGET),atari)
+PPUEXT=.ppt
+ASMEXT=.s
+OEXT=.o
+SMARTEXT=.sl
+STATICLIBEXT=.a
+EXEEXT=.ttp
+FPCMADE=fpcmade.ata
+endif
+ifeq ($(OS_TARGET),beos)
+PPUEXT=.ppu
+ASMEXT=.s
+OEXT=.o
+SMARTEXT=.sl
+STATICLIBEXT=.a
+EXEEXT=
+FPCMADE=fpcmade.be
+ZIPSUFFIX=be
+endif
+ifeq ($(OS_TARGET),sunos)
+PPUEXT=.ppu
+ASMEXT=.s
+OEXT=.o
+SMARTEXT=.sl
+STATICLIBEXT=.a
+EXEEXT=
+FPCMADE=fpcmade.sun
+ZIPSUFFIX=sun
+endif
+ifeq ($(OS_TARGET),qnx)
+PPUEXT=.ppu
+ASMEXT=.s
+OEXT=.o
+SMARTEXT=.sl
+STATICLIBEXT=.a
+EXEEXT=
+FPCMADE=fpcmade.qnx
+ZIPSUFFIX=qnx
+endif
+ifndef ECHO
+ECHO:=$(strip $(wildcard $(addsuffix /gecho$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(ECHO),)
+ECHO:=$(strip $(wildcard $(addsuffix /echo$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(ECHO),)
+ECHO=
+else
+ECHO:=$(firstword $(ECHO))
+endif
+else
+ECHO:=$(firstword $(ECHO))
+endif
+endif
+export ECHO
+ifndef DATE
+DATE:=$(strip $(wildcard $(addsuffix /gdate$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(DATE),)
+DATE:=$(strip $(wildcard $(addsuffix /date$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(DATE),)
+DATE=
+else
+DATE:=$(firstword $(DATE))
+endif
+else
+DATE:=$(firstword $(DATE))
+endif
+endif
+export DATE
+ifndef GINSTALL
+GINSTALL:=$(strip $(wildcard $(addsuffix /ginstall$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(GINSTALL),)
+GINSTALL:=$(strip $(wildcard $(addsuffix /install$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(GINSTALL),)
+GINSTALL=
+else
+GINSTALL:=$(firstword $(GINSTALL))
+endif
+else
+GINSTALL:=$(firstword $(GINSTALL))
+endif
+endif
+export GINSTALL
+ifndef CPPROG
+CPPROG:=$(strip $(wildcard $(addsuffix /cp$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(CPPROG),)
+CPPROG=
+else
+CPPROG:=$(firstword $(CPPROG))
+endif
+endif
+export CPPROG
+ifndef RMPROG
+RMPROG:=$(strip $(wildcard $(addsuffix /rm$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(RMPROG),)
+RMPROG=
+else
+RMPROG:=$(firstword $(RMPROG))
+endif
+endif
+export RMPROG
+ifndef MVPROG
+MVPROG:=$(strip $(wildcard $(addsuffix /mv$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(MVPROG),)
+MVPROG=
+else
+MVPROG:=$(firstword $(MVPROG))
+endif
+endif
+export MVPROG
+ifndef ECHOREDIR
+ECHOREDIR:=$(subst /,$(PATHSEP),$(ECHO))
+endif
+ifndef COPY
+COPY:=$(CPPROG) -fp
+endif
+ifndef COPYTREE
+COPYTREE:=$(CPPROG) -rfp
+endif
+ifndef MOVE
+MOVE:=$(MVPROG) -f
+endif
+ifndef DEL
+DEL:=$(RMPROG) -f
+endif
+ifndef DELTREE
+DELTREE:=$(RMPROG) -rf
+endif
+ifndef INSTALL
+ifdef inUnix
+INSTALL:=$(GINSTALL) -c -m 644
+else
+INSTALL:=$(COPY)
+endif
+endif
+ifndef INSTALLEXE
+ifdef inUnix
+INSTALLEXE:=$(GINSTALL) -c -m 755
+else
+INSTALLEXE:=$(COPY)
+endif
+endif
+ifndef MKDIR
+MKDIR:=$(GINSTALL) -m 755 -d
+endif
+export ECHOREDIR COPY COPYTREE MOVE DEL DELTREE INSTALL INSTALLEXE MKDIR
+ifndef PPUMOVE
+PPUMOVE:=$(strip $(wildcard $(addsuffix /ppumove$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(PPUMOVE),)
+PPUMOVE=
+else
+PPUMOVE:=$(firstword $(PPUMOVE))
+endif
+endif
+export PPUMOVE
+ifndef FPCMAKE
+FPCMAKE:=$(strip $(wildcard $(addsuffix /fpcmake$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(FPCMAKE),)
+FPCMAKE=
+else
+FPCMAKE:=$(firstword $(FPCMAKE))
+endif
+endif
+export FPCMAKE
+ifndef ZIPPROG
+ZIPPROG:=$(strip $(wildcard $(addsuffix /zip$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(ZIPPROG),)
+ZIPPROG=
+else
+ZIPPROG:=$(firstword $(ZIPPROG))
+endif
+endif
+export ZIPPROG
+ifndef TARPROG
+TARPROG:=$(strip $(wildcard $(addsuffix /tar$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(TARPROG),)
+TARPROG=
+else
+TARPROG:=$(firstword $(TARPROG))
+endif
+endif
+export TARPROG
+ASNAME=as
+LDNAME=ld
+ARNAME=ar
+RCNAME=rc
+ifeq ($(OS_TARGET),win32)
+ASNAME=asw
+LDNAME=ldw
+ARNAME=arw
+endif
+ifndef ASPROG
+ifdef CROSSBINDIR
+ASPROG=$(CROSSBINDIR)/$(ASNAME)$(SRCEXEEXT)
+else
+ASPROG=$(ASNAME)
+endif
+endif
+ifndef LDPROG
+ifdef CROSSBINDIR
+LDPROG=$(CROSSBINDIR)/$(LDNAME)$(SRCEXEEXT)
+else
+LDPROG=$(LDNAME)
+endif
+endif
+ifndef RCPROG
+ifdef CROSSBINDIR
+RCPROG=$(CROSSBINDIR)/$(RCNAME)$(SRCEXEEXT)
+else
+RCPROG=$(RCNAME)
+endif
+endif
+ifndef ARPROG
+ifdef CROSSBINDIR
+ARPROG=$(CROSSBINDIR)/$(ARNAME)$(SRCEXEEXT)
+else
+ARPROG=$(ARNAME)
+endif
+endif
+AS=$(ASPROG)
+LD=$(LDPROG)
+RC=$(RCPROG)
+AR=$(ARPROG)
+PPAS=ppas$(BATCHEXT)
+ifdef inUnix
+LDCONFIG=ldconfig
+else
+LDCONFIG=
+endif
+ifdef DATE
+DATESTR:=$(shell $(DATE) +%Y%m%d)
+else
+DATESTR=
+endif
+ifndef UPXPROG
+ifeq ($(OS_TARGET),go32v2)
+UPXPROG:=1
+endif
+ifeq ($(OS_TARGET),win32)
+UPXPROG:=1
+endif
+ifdef UPXPROG
+UPXPROG:=$(strip $(wildcard $(addsuffix /upx$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(UPXPROG),)
+UPXPROG=
+else
+UPXPROG:=$(firstword $(UPXPROG))
+endif
+else
+UPXPROG=
+endif
+endif
+export UPXPROG
+ZIPOPT=-9
+ZIPEXT=.zip
+ifeq ($(USETAR),bz2)
+TAROPT=vI
+TAREXT=.tar.bz2
+else
+TAROPT=vz
+TAREXT=.tar.gz
+endif
+override REQUIRE_PACKAGES=rtl 
+ifeq ($(OS_TARGET),linux)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(OS_TARGET),go32v2)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(OS_TARGET),win32)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(OS_TARGET),os2)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(OS_TARGET),freebsd)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(OS_TARGET),beos)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(OS_TARGET),netbsd)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(OS_TARGET),amiga)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(OS_TARGET),atari)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(OS_TARGET),sunos)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(OS_TARGET),qnx)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifdef REQUIRE_PACKAGES_RTL
+PACKAGEDIR_RTL:=$(firstword $(subst /Makefile.fpc,,$(strip $(wildcard $(addsuffix /rtl/$(OS_TARGET)/Makefile.fpc,$(PACKAGESDIR))))))
+ifneq ($(PACKAGEDIR_RTL),)
+ifneq ($(wildcard $(PACKAGEDIR_RTL)/$(OS_TARGET)),)
+UNITDIR_RTL=$(PACKAGEDIR_RTL)/$(OS_TARGET)
+else
+UNITDIR_RTL=$(PACKAGEDIR_RTL)
+endif
+else
+PACKAGEDIR_RTL=
+UNITDIR_RTL:=$(subst /Package.fpc,,$(strip $(wildcard $(addsuffix /rtl/Package.fpc,$(UNITSDIR)))))
+ifneq ($(UNITDIR_RTL),)
+UNITDIR_RTL:=$(firstword $(UNITDIR_RTL))
+else
+UNITDIR_RTL=
+endif
+endif
+ifdef UNITDIR_RTL
+override COMPILER_UNITDIR+=$(UNITDIR_RTL)
+endif
+endif
+ifndef NOCPUDEF
+override FPCOPTDEF=$(CPU_TARGET)
+endif
+ifneq ($(OS_TARGET),$(OS_SOURCE))
+override FPCOPT+=-T$(OS_TARGET)
+endif
+ifdef UNITDIR
+override FPCOPT+=$(addprefix -Fu,$(UNITDIR))
+endif
+ifdef LIBDIR
+override FPCOPT+=$(addprefix -Fl,$(LIBDIR))
+endif
+ifdef OBJDIR
+override FPCOPT+=$(addprefix -Fo,$(OBJDIR))
+endif
+ifdef INCDIR
+override FPCOPT+=$(addprefix -Fi,$(INCDIR))
+endif
+ifdef LINKSMART
+override FPCOPT+=-XX
+endif
+ifdef CREATESMART
+override FPCOPT+=-CX
+endif
+ifdef DEBUG
+override FPCOPT+=-gl
+override FPCOPTDEF+=DEBUG
+endif
+ifdef RELEASE
+ifeq ($(CPU_TARGET),i386)
+FPCCPUOPT:=-OG2p3
+else
+FPCCPUOPT:=
+endif
+override FPCOPT+=-Xs $(FPCCPUOPT) -n
+override FPCOPTDEF+=RELEASE
+endif
+ifdef STRIP
+override FPCOPT+=-Xs
+endif
+ifdef OPTIMIZE
+ifeq ($(CPU_TARGET),i386)
+override FPCOPT+=-OG2p3
+endif
+endif
+ifdef VERBOSE
+override FPCOPT+=-vwni
+endif
+ifdef COMPILER_OPTIONS
+override FPCOPT+=$(COMPILER_OPTIONS)
+endif
+ifdef COMPILER_UNITDIR
+override FPCOPT+=$(addprefix -Fu,$(COMPILER_UNITDIR))
+endif
+ifdef COMPILER_LIBRARYDIR
+override FPCOPT+=$(addprefix -Fl,$(COMPILER_LIBRARYDIR))
+endif
+ifdef COMPILER_OBJECTDIR
+override FPCOPT+=$(addprefix -Fo,$(COMPILER_OBJECTDIR))
+endif
+ifdef COMPILER_INCLUDEDIR
+override FPCOPT+=$(addprefix -Fi,$(COMPILER_INCLUDEDIR))
+endif
+ifdef CROSSBINDIR
+override FPCOPT+=-FD$(CROSSBINDIR)
+endif
+ifdef COMPILER_TARGETDIR
+override FPCOPT+=-FE$(COMPILER_TARGETDIR)
+ifeq ($(COMPILER_TARGETDIR),.)
+override TARGETDIRPREFIX=
+else
+override TARGETDIRPREFIX=$(COMPILER_TARGETDIR)/
+endif
+endif
+ifdef COMPILER_UNITTARGETDIR
+override FPCOPT+=-FU$(COMPILER_UNITTARGETDIR)
+ifeq ($(COMPILER_UNITTARGETDIR),.)
+override UNITTARGETDIRPREFIX=
+else
+override UNITTARGETDIRPREFIX=$(COMPILER_UNITTARGETDIR)/
+endif
+else
+ifdef COMPILER_TARGETDIR
+override COMPILER_UNITTARGETDIR=$(COMPILER_TARGETDIR)
+override UNITTARGETDIRPREFIX=$(TARGETDIRPREFIX)
+endif
+endif
+ifdef OPT
+override FPCOPT+=$(OPT)
+endif
+ifdef FPCOPTDEF
+override FPCOPT+=$(addprefix -d,$(FPCOPTDEF))
+endif
+ifdef CFGFILE
+override FPCOPT+=@$(CFGFILE)
+endif
+ifdef USEENV
+override FPCEXTCMD:=$(FPCOPT)
+override FPCOPT:=!FPCEXTCMD
+export FPCEXTCMD
+endif
+override COMPILER:=$(FPC) $(FPCOPT)
+ifeq (,$(findstring -s ,$(COMPILER)))
+EXECPPAS=
+else
+ifeq ($(OS_SOURCE),$(OS_TARGET))
+EXECPPAS:=@$(PPAS)
+endif
+endif
+.PHONY: fpc_units
+ifdef TARGET_UNITS
+override ALLTARGET+=fpc_units
+override UNITPPUFILES=$(addsuffix $(PPUEXT),$(TARGET_UNITS))
+override IMPLICITUNITPPUFILES=$(addsuffix $(PPUEXT),$(TARGET_IMPLICITUNITS))
+override INSTALLPPUFILES+=$(UNITPPUFILES) $(IMPLICITUNITPPUFILES)
+override CLEANPPUFILES+=$(UNITPPUFILES) $(IMPLICITUNITPPUFILES)
+endif
+fpc_units: $(UNITPPUFILES)
+ifdef TARGET_RSTS
+override RSTFILES=$(addsuffix $(RSTEXT),$(TARGET_RSTS))
+override CLEANRSTFILES+=$(RSTFILES)
+endif
+.PHONY: fpc_all fpc_smart fpc_debug fpc_release
+$(FPCMADE): $(ALLTARGET)
+	@$(ECHOREDIR) Compiled > $(FPCMADE)
+fpc_all: $(FPCMADE)
+fpc_smart:
+	$(MAKE) all LINKSMART=1 CREATESMART=1
+fpc_debug:
+	$(MAKE) all DEBUG=1
+fpc_release:
+	$(MAKE) all RELEASE=1
+.SUFFIXES: $(EXEEXT) $(PPUEXT) $(OEXT) .pas .pp .rc .res
+%$(PPUEXT): %.pp
+	$(COMPILER) $<
+	$(EXECPPAS)
+%$(PPUEXT): %.pas
+	$(COMPILER) $<
+	$(EXECPPAS)
+%$(EXEEXT): %.pp
+	$(COMPILER) $<
+	$(EXECPPAS)
+%$(EXEEXT): %.pas
+	$(COMPILER) $<
+	$(EXECPPAS)
+%.res: %.rc
+	windres -i $< -o $@
+vpath %.pp $(COMPILER_SOURCEDIR) $(COMPILER_INCLUDEDIR)
+vpath %.pas $(COMPILER_SOURCEDIR) $(COMPILER_INCLUDEDIR)
+vpath %$(PPUEXT) $(COMPILER_UNITTARGETDIR)
+.PHONY: fpc_install fpc_sourceinstall fpc_exampleinstall
+ifdef INSTALL_UNITS
+override INSTALLPPUFILES+=$(addsuffix $(PPUEXT),$(INSTALL_UNITS))
+endif
+ifdef INSTALL_BUILDUNIT
+override INSTALLPPUFILES:=$(filter-out $(INSTALL_BUILDUNIT),$(INSTALLPPUFILES))
+endif
+ifdef INSTALLPPUFILES
+override INSTALLPPULINKFILES:=$(subst $(PPUEXT),$(OEXT),$(INSTALLPPUFILES)) $(addprefix $(STATICLIBPREFIX),$(subst $(PPUEXT),$(STATICLIBEXT),$(INSTALLPPUFILES)))
+override INSTALLPPUFILES:=$(addprefix $(UNITTARGETDIRPREFIX),$(INSTALLPPUFILES))
+override INSTALLPPULINKFILES:=$(wildcard $(addprefix $(UNITTARGETDIRPREFIX),$(INSTALLPPULINKFILES)))
+override INSTALL_CREATEPACKAGEFPC=1
+endif
+ifdef INSTALLEXEFILES
+override INSTALLEXEFILES:=$(addprefix $(TARGETDIRPREFIX),$(INSTALLEXEFILES))
+endif
+fpc_install: all $(INSTALLTARGET)
+ifdef INSTALLEXEFILES
+	$(MKDIR) $(INSTALL_BINDIR)
+ifdef UPXPROG
+	-$(UPXPROG) $(INSTALLEXEFILES)
+endif
+	$(INSTALLEXE) $(INSTALLEXEFILES) $(INSTALL_BINDIR)
+endif
+ifdef INSTALL_CREATEPACKAGEFPC
+ifdef FPCMAKE
+ifdef PACKAGE_VERSION
+ifneq ($(wildcard Makefile.fpc),)
+	$(FPCMAKE) -p -T$(OS_TARGET) Makefile.fpc
+	$(MKDIR) $(INSTALL_UNITDIR)
+	$(INSTALL) Package.fpc $(INSTALL_UNITDIR)
+endif
+endif
+endif
+endif
+ifdef INSTALLPPUFILES
+	$(MKDIR) $(INSTALL_UNITDIR)
+	$(INSTALL) $(INSTALLPPUFILES) $(INSTALL_UNITDIR)
+ifneq ($(INSTALLPPULINKFILES),)
+	$(INSTALL) $(INSTALLPPULINKFILES) $(INSTALL_UNITDIR)
+endif
+ifneq ($(wildcard $(LIB_FULLNAME)),)
+	$(MKDIR) $(INSTALL_LIBDIR)
+	$(INSTALL) $(LIB_FULLNAME) $(INSTALL_LIBDIR)
+ifdef inUnix
+	ln -sf $(LIB_FULLNAME) $(INSTALL_LIBDIR)/$(LIB_NAME)
+endif
+endif
+endif
+ifdef INSTALL_FILES
+	$(MKDIR) $(INSTALL_DATADIR)
+	$(INSTALL) $(INSTALL_FILES) $(INSTALL_DATADIR)
+endif
+fpc_sourceinstall: distclean
+	$(MKDIR) $(INSTALL_SOURCEDIR)
+	$(COPYTREE) $(BASEDIR) $(INSTALL_SOURCEDIR)
+fpc_exampleinstall: $(addsuffix _distclean,$(TARGET_EXAMPLEDIRS))
+ifdef HASEXAMPLES
+	$(MKDIR) $(INSTALL_EXAMPLEDIR)
+endif
+ifdef EXAMPLESOURCEFILES
+	$(COPY) $(EXAMPLESOURCEFILES) $(INSTALL_EXAMPLEDIR)
+endif
+ifdef TARGET_EXAMPLEDIRS
+	$(COPYTREE) $(addsuffix /*,$(TARGET_EXAMPLEDIRS)) $(INSTALL_EXAMPLEDIR)
+endif
+.PHONY: fpc_distinstall
+fpc_distinstall: install exampleinstall
+.PHONY: fpc_zipinstall fpc_zipsourceinstall fpc_zipexampleinstall
+ifndef PACKDIR
+ifndef inUnix
+PACKDIR=$(BASEDIR)/../fpc-pack
+else
+PACKDIR=/tmp/fpc-pack
+endif
+endif
+ifndef ZIPNAME
+ifdef DIST_ZIPNAME
+ZIPNAME=$(DIST_ZIPNAME)
+else
+ZIPNAME=$(ZIPPREFIX)$(PACKAGE_NAME)$(ZIPSUFFIX)
+endif
+endif
+ifndef ZIPTARGET
+ifdef DIST_ZIPTARGET
+ZIPTARGET=DIST_ZIPTARGET
+else
+ZIPTARGET=install
+endif
+endif
+ifndef USEZIP
+ifdef inUnix
+USETAR=1
+endif
+endif
+ifndef inUnix
+USEZIPWRAPPER=1
+endif
+ifdef USEZIPWRAPPER
+ZIPPATHSEP=$(PATHSEP)
+ZIPWRAPPER=$(subst /,$(PATHSEP),$(DIST_DESTDIR)/fpczip$(BATCHEXT))
+else
+ZIPPATHSEP=/
+endif
+ZIPCMD_CDPACK:=cd $(subst /,$(ZIPPATHSEP),$(PACKDIR))
+ZIPCMD_CDBASE:=cd $(subst /,$(ZIPPATHSEP),$(BASEDIR))
+ifdef USETAR
+ZIPDESTFILE:=$(DIST_DESTDIR)/$(ZIPNAME)$(TAREXT)
+ZIPCMD_ZIP:=$(TARPROG) cf$(TAROPT) $(ZIPDESTFILE) *
+else
+ZIPDESTFILE:=$(DIST_DESTDIR)/$(ZIPNAME)$(ZIPEXT)
+ZIPCMD_ZIP:=$(subst /,$(ZIPPATHSEP),$(ZIPPROG)) -Dr $(ZIPOPT) $(ZIPDESTFILE) *
+endif
+fpc_zipinstall:
+	$(MAKE) $(ZIPTARGET) INSTALL_PREFIX=$(PACKDIR) ZIPINSTALL=1
+	$(MKDIR) $(DIST_DESTDIR)
+	$(DEL) $(ZIPDESTFILE)
+ifdef USEZIPWRAPPER
+ifneq ($(ECHOREDIR),echo)
+	$(ECHOREDIR) -e "$(subst \,\\,$(ZIPCMD_CDPACK))" > $(ZIPWRAPPER)
+	$(ECHOREDIR) -e "$(subst \,\\,$(ZIPCMD_ZIP))" >> $(ZIPWRAPPER)
+	$(ECHOREDIR) -e "$(subst \,\\,$(ZIPCMD_CDBASE))" >> $(ZIPWRAPPER)
+else
+	echo $(ZIPCMD_CDPACK) > $(ZIPWRAPPER)
+	echo $(ZIPCMD_ZIP) >> $(ZIPWRAPPER)
+	echo $(ZIPCMD_CDBASE) >> $(ZIPWRAPPER)
+endif
+ifdef inUnix
+	/bin/sh $(ZIPWRAPPER)
+else
+	$(ZIPWRAPPER)
+endif
+	$(DEL) $(ZIPWRAPPER)
+else
+	$(ZIPCMD_CDPACK) ; $(ZIPCMD_ZIP) ; $(ZIPCMD_CDBASE)
+endif
+	$(DELTREE) $(PACKDIR)
+fpc_zipsourceinstall:
+	$(MAKE) fpc_zipinstall ZIPTARGET=sourceinstall ZIPSUFFIX=src
+fpc_zipexampleinstall:
+ifdef HASEXAMPLES
+	$(MAKE) fpc_zipinstall ZIPTARGET=exampleinstall ZIPSUFFIX=exm
+endif
+fpc_zipdistinstall:
+	$(MAKE) fpc_zipinstall ZIPTARGET=distinstall
+.PHONY: fpc_clean fpc_cleanall fpc_distclean
+ifdef EXEFILES
+override CLEANEXEFILES:=$(addprefix $(TARGETDIRPREFIX),$(CLEANEXEFILES))
+endif
+ifdef CLEAN_UNITS
+override CLEANPPUFILES+=$(addsuffix $(PPUEXT),$(CLEAN_UNITS))
+endif
+ifdef CLEANPPUFILES
+override CLEANPPULINKFILES:=$(subst $(PPUEXT),$(OEXT),$(CLEANPPUFILES)) $(addprefix $(STATICLIBPREFIX),$(subst $(PPUEXT),$(STATICLIBEXT),$(CLEANPPUFILES)))
+override CLEANPPUFILES:=$(addprefix $(UNITTARGETDIRPREFIX),$(CLEANPPUFILES))
+override CLEANPPULINKFILES:=$(wildcard $(addprefix $(UNITTARGETDIRPREFIX),$(CLEANPPULINKFILES)))
+endif
+fpc_clean: $(CLEANTARGET)
+ifdef CLEANEXEFILES
+	-$(DEL) $(CLEANEXEFILES)
+endif
+ifdef CLEANPPUFILES
+	-$(DEL) $(CLEANPPUFILES)
+endif
+ifneq ($(CLEANPPULINKFILES),)
+	-$(DEL) $(CLEANPPULINKFILES)
+endif
+ifdef CLEANRSTFILES
+	-$(DEL) $(addprefix $(UNITTARGETDIRPREFIX),$(CLEANRSTFILES))
+endif
+ifdef CLEAN_FILES
+	-$(DEL) $(CLEAN_FILES)
+endif
+ifdef LIB_NAME
+	-$(DEL) $(LIB_NAME) $(LIB_FULLNAME)
+endif
+	-$(DEL) $(FPCMADE) Package.fpc $(PPAS) script.res link.res $(FPCEXTFILE) $(REDIRFILE)
+fpc_distclean: clean
+ifdef COMPILER_UNITTARGETDIR
+TARGETDIRCLEAN=fpc_clean
+endif
+fpc_cleanall: $(CLEANTARGET) $(TARGETDIRCLEAN)
+ifdef CLEANEXEFILES
+	-$(DEL) $(CLEANEXEFILES)
+endif
+	-$(DEL) *$(OEXT) *$(PPUEXT) *$(RSTEXT) *$(ASMEXT) *$(STATICLIBEXT) *$(SHAREDLIBEXT) *$(PPLEXT)
+	-$(DELTREE) *$(SMARTEXT)
+	-$(DEL) $(FPCMADE) Package.fpc $(PPAS) script.res link.res $(FPCEXTFILE) $(REDIRFILE)
+ifdef AOUTEXT
+	-$(DEL) *$(AOUTEXT)
+endif
+.PHONY: fpc_baseinfo
+override INFORULES+=fpc_baseinfo
+fpc_baseinfo:
+	@$(ECHO)
+	@$(ECHO)  == Package info ==
+	@$(ECHO)  Package Name..... $(PACKAGE_NAME)
+	@$(ECHO)  Package Version.. $(PACKAGE_VERSION)
+	@$(ECHO)
+	@$(ECHO)  == Configuration info ==
+	@$(ECHO)
+	@$(ECHO)  FPC.......... $(FPC)
+	@$(ECHO)  FPC Version.. $(FPC_VERSION)
+	@$(ECHO)  Source CPU... $(CPU_SOURCE)
+	@$(ECHO)  Target CPU... $(CPU_TARGET)
+	@$(ECHO)  Source OS.... $(OS_SOURCE)
+	@$(ECHO)  Target OS.... $(OS_TARGET)
+	@$(ECHO)  Full Target.. $(FULL_SOURCE)
+	@$(ECHO)  Full Source.. $(FULL_TARGET)
+	@$(ECHO)
+	@$(ECHO)  == Directory info ==
+	@$(ECHO)
+	@$(ECHO)  Required pkgs... $(REQUIRE_PACKAGES)
+	@$(ECHO)
+	@$(ECHO)  Basedir......... $(BASEDIR)
+	@$(ECHO)  FPCDir.......... $(FPCDIR)
+	@$(ECHO)  CrossBinDir..... $(CROSSBINDIR)
+	@$(ECHO)  UnitsDir........ $(UNITSDIR)
+	@$(ECHO)  PackagesDir..... $(PACKAGESDIR)
+	@$(ECHO)
+	@$(ECHO)  GCC library..... $(GCCLIBDIR)
+	@$(ECHO)  Other library... $(OTHERLIBDIR)
+	@$(ECHO)
+	@$(ECHO)  == Tools info ==
+	@$(ECHO)
+	@$(ECHO)  As........ $(AS)
+	@$(ECHO)  Ld........ $(LD)
+	@$(ECHO)  Ar........ $(AR)
+	@$(ECHO)  Rc........ $(RC)
+	@$(ECHO)
+	@$(ECHO)  Mv........ $(MVPROG)
+	@$(ECHO)  Cp........ $(CPPROG)
+	@$(ECHO)  Rm........ $(RMPROG)
+	@$(ECHO)  GInstall.. $(GINSTALL)
+	@$(ECHO)  Echo...... $(ECHO)
+	@$(ECHO)  Date...... $(DATE)
+	@$(ECHO)  FPCMake... $(FPCMAKE)
+	@$(ECHO)  PPUMove... $(PPUMOVE)
+	@$(ECHO)  Upx....... $(UPXPROG)
+	@$(ECHO)  Zip....... $(ZIPPROG)
+	@$(ECHO)
+	@$(ECHO)  == Object info ==
+	@$(ECHO)
+	@$(ECHO)  Target Loaders........ $(TARGET_LOADERS)
+	@$(ECHO)  Target Units.......... $(TARGET_UNITS)
+	@$(ECHO)  Target Implicit Units. $(TARGET_IMPLICITUNITS)
+	@$(ECHO)  Target Programs....... $(TARGET_PROGRAMS)
+	@$(ECHO)  Target Dirs........... $(TARGET_DIRS)
+	@$(ECHO)  Target Examples....... $(TARGET_EXAMPLES)
+	@$(ECHO)  Target ExampleDirs.... $(TARGET_EXAMPLEDIRS)
+	@$(ECHO)
+	@$(ECHO)  Clean Units......... $(CLEAN_UNITS)
+	@$(ECHO)  Clean Files......... $(CLEAN_FILES)
+	@$(ECHO)
+	@$(ECHO)  Install Units....... $(INSTALL_UNITS)
+	@$(ECHO)  Install Files....... $(INSTALL_FILES)
+	@$(ECHO)
+	@$(ECHO)  == Install info ==
+	@$(ECHO)
+	@$(ECHO)  DateStr.............. $(DATESTR)
+	@$(ECHO)  ZipPrefix............ $(ZIPPREFIX)
+	@$(ECHO)  ZipSuffix............ $(ZIPSUFFIX)
+	@$(ECHO)  Install FPC Package.. $(INSTALL_FPCPACKAGE)
+	@$(ECHO)
+	@$(ECHO)  Install base dir..... $(INSTALL_BASEDIR)
+	@$(ECHO)  Install binary dir... $(INSTALL_BINDIR)
+	@$(ECHO)  Install library dir.. $(INSTALL_LIBDIR)
+	@$(ECHO)  Install units dir.... $(INSTALL_UNITDIR)
+	@$(ECHO)  Install source dir... $(INSTALL_SOURCEDIR)
+	@$(ECHO)  Install doc dir...... $(INSTALL_DOCDIR)
+	@$(ECHO)  Install example dir.. $(INSTALL_EXAMPLEDIR)
+	@$(ECHO)  Install data dir..... $(INSTALL_DATADIR)
+	@$(ECHO)
+	@$(ECHO)  Dist destination dir. $(DIST_DESTDIR)
+	@$(ECHO)  Dist zip name........ $(DIST_ZIPNAME)
+	@$(ECHO)
+.PHONY: fpc_info
+fpc_info: $(INFORULES)
+.PHONY: fpc_makefile fpc_makefiles fpc_makefile_sub1 fpc_makefile_sub2 \
+	fpc_makefile_dirs
+fpc_makefile:
+	$(FPCMAKE) -w -T$(OS_TARGET) Makefile.fpc
+fpc_makefile_sub1:
+ifdef TARGET_DIRS
+	$(FPCMAKE) -w -T$(OS_TARGET) $(addsuffix /Makefile.fpc,$(TARGET_DIRS))
+endif
+ifdef TARGET_EXAMPLEDIRS
+	$(FPCMAKE) -w -T$(OS_TARGET) $(addsuffix /Makefile.fpc,$(TARGET_EXAMPLEDIRS))
+endif
+fpc_makefile_sub2: $(addsuffix _makefile_dirs,$(TARGET_DIRS) $(TARGET_EXAMPLEDIRS))
+fpc_makefile_dirs: fpc_makefile_sub1 fpc_makefile_sub2
+fpc_makefiles: fpc_makefile fpc_makefile_dirs
+all: fpc_all
+debug: fpc_debug
+smart: fpc_smart
+release: fpc_release
+examples:
+shared:
+install: fpc_install
+sourceinstall: fpc_sourceinstall
+exampleinstall: fpc_exampleinstall
+distinstall: fpc_distinstall
+zipinstall: fpc_zipinstall
+zipsourceinstall: fpc_zipsourceinstall
+zipexampleinstall: fpc_zipexampleinstall
+zipdistinstall: fpc_zipdistinstall
+clean: fpc_clean
+distclean: fpc_distclean
+cleanall: fpc_cleanall
+info: fpc_info
+makefiles: fpc_makefiles
+.PHONY: all debug smart release examples shared install sourceinstall exampleinstall distinstall zipinstall zipsourceinstall zipexampleinstall zipdistinstall clean distclean cleanall info makefiles
+ifneq ($(wildcard fpcmake.loc),)
+include fpcmake.loc
+endif

+ 20 - 0
packages/extra/bfd/Makefile.fpc

@@ -0,0 +1,20 @@
+#
+#   Makefile.fpc for BFD library
+#
+
+[package]
+name=bfd
+version=1.0.6
+
+[target]
+units=bfd
+examples=
+
+[require]
+package=rtl
+
+[install]
+fpcpackage=y
+
+[default]
+fpcdir=../../..

+ 3065 - 0
packages/extra/bfd/bfd.pas

@@ -0,0 +1,3065 @@
+unit BFD;
+
+{$mode Delphi}
+interface
+
+{
+  Object Pascal Translation of bfd.h,
+  used in the Binary File Descriptor library
+  found in the GNU Binutils
+
+  This translation itself is in the public domain, but don't ignore
+  the copyright of the BFD lib itself (see 'original comments' below)
+
+  History:
+  07.08.2001: [email protected] (UT) (started translation)
+    - the structs, defines and functions are separated to different
+      blocks to have one large type block (since type forwards are not
+      possible across different type blocks)
+    - Maybe some comments were removed or are at wrong places: while
+      the codelines were sorted I did not check everything
+    - I did a lot of Search and Replace, so don't wonder if comments 
+      were changed a bit, too.
+    - I renamed bfd to TBFD and a few other minor changes to keep the 
+      namespace a bit cleaner
+
+}
+
+{
+  Original comments and copyrights:
+}
+
+(* Main header file for the bfd library -- portable access to object files.
+   Copyright 1990, 91, 92, 93, 94, 95, 96, 97, 98, 99, 2000
+   Free Software Foundation, Inc.
+   Contributed by Cygnus Support.
+
+** NOTE: bfd.h and bfd-in2.h are GENERATED files.  Don't change them;
+** instead, change bfd-in.h or the other BFD source files processed to
+** generate these files.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+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.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  *)
+
+(* bfd.h -- The only header file required by users of the bfd library
+
+The bfd.h file is generated from bfd-in.h and various .c files; if you
+change it, your changes will probably be lost.
+
+All the prototypes and definitions following the comment "THE FOLLOWING
+IS EXTRACTED FROM THE SOURCE" are extracted from the source files for
+BFD.  If you change it, someone oneday will extract it from the source
+again, and your changes will be lost.  To save yourself from this bind,
+change the definitions in the source in the bfd directory.  Type "make
+docs" and then "make headers" in that directory, and magically this file
+will change to reflect your changes.
+
+If you don't have the tools to perform the extraction, then you are
+safe from someone on your system trampling over your header files.
+You should still maintain the equivalence between the source and this
+file though; every change you make to the .c file should be reflected
+here.  *)
+
+{UT: these settings create matching records: }
+{$packrecords 4}
+{$ifndef ver1_0}
+{$ALIGN 4}
+{$endif}
+{$MINENUMSIZE 4}
+
+
+{$ifdef ver1_0}
+Type
+ PBoolean     = ^Boolean;
+ PLongWord    = ^LongWord;
+{$endif}  
+
+const
+  BFD_VERSION   = '2.10.91';
+  BFD_ARCH_SIZE = 32;
+
+type
+(* forward declaration *)
+  PBFD = ^TBFD;
+  PPsymbol_cache_entry = ^Psymbol_cache_entry;
+  Psymbol_cache_entry = ^symbol_cache_entry;
+  PSec = ^sec;
+  PPSec = ^PSec;
+  Pbfd_target = ^bfd_target;
+  Pbfd_arch_info = ^bfd_arch_info;
+  PPreloc_cache_entry = ^Preloc_cache_entry;
+  Preloc_cache_entry = ^reloc_cache_entry;
+  Palent = ^alent;
+  Pbfd_comdat_info = ^bfd_comdat_info;
+  Prelent_chain = ^relent_chain;
+  Pbfd_window = ^bfd_window;
+  Pasymbol = ^asymbol;
+  Pbfd_size_type = ^bfd_size_type;
+  Porl = ^orl;
+  Psymbol_info = ^symbol_info;
+  PParelent = ^Parelent;
+  Parelent = ^arelent;
+  Pasection = ^asection;
+  PPreloc_howto = ^Preloc_howto;
+  Preloc_howto = ^reloc_howto;
+
+  Pbfd_link_info = pointer; //^bfd_link_info;
+  Pbfd_link_hash_table = pointer; //^bfd_link_hash_table;
+
+(* A pointer to a position in a file.  *)
+  file_ptr = LongInt;
+
+(* Represent a target address.  Also used as a generic unsigned type
+   which is guaranteed to be big enough to hold any arithmetic types
+   we need to deal with.  *)
+  bfd_vma = LongWord;
+
+(* A generic signed type which is guaranteed to be big enough to hold any
+   arithmetic types we need to deal with.  Can be assumed to be compatible
+   with bfd_vma in the same way that signed and LongWords are compatible
+   (as parameters, in assignment, etc).  *)
+  bfd_signed_vma = LongInt;
+
+  symvalue = LongWord;
+  bfd_size_type = LongWord;
+
+  flagword = LongWord;	(* 32 bits of flags *)
+
+  pppchar = ^ppchar;
+  Pbfd_byte = ^bfd_byte;
+  bfd_byte = Byte;
+  bfd_boolean = LongBool;
+
+(** File formats *)
+(* MvdV: FPC 1.0 doesn't support the construct below, but the first ordinal
+is in practice already 0 *)
+
+  bfd_format = (
+    bfd_unknown {$ifndef ver1_0}= 0{$endif},  (* file format is unknown *)
+    bfd_object,	    (* linker/assember/compiler output *)
+    bfd_archive,    (* object archive file *)
+    bfd_core	    (* core dump *)
+    //UT: to use this enum in arrays the following is not needed:
+    //bfd_type_end  (* marks the end; don't use it! *)
+  );
+
+(* symbols and relocation *)
+
+(* A count of carsyms (canonical archive symbols).  *)
+  symindex = LongWord;
+
+(* A canonical archive symbol.  *)
+(* This is a type pun with struct ranlib on purpose! *)
+  carsym = record
+    name: pchar;
+    file_offset: file_ptr;  (* look here to find the file *)
+  end;	   		    (* to make these you call a carsymogen *)
+
+(* Used in generating armaps (archive tables of contents).
+   Perhaps just a forward definition would do? *)
+  orl = record 			(* output ranlib *)
+    name:    ppchar;		(* symbol name *)
+    pos:     file_ptr;		(* TBFD* or file position *)
+    nameidx: integer;		(* index into string table *)
+  end;
+
+(* Linenumber stuff *)
+  lineno_cache_entry = record
+    line_number: LongWord;	(* Linenumber from start of function*)
+    u: record
+      case integer of
+        0: (sym:    Psymbol_cache_entry); (* Function name *)
+        1: (offset: LongWord);	          (* Offset into section *)
+      end;
+  end;
+  alent = lineno_cache_entry;
+
+  Pstat = pointer; // todo?
+
+  bfd_print_symbol = (
+    bfd_print_symbol_name,
+    bfd_print_symbol_more,
+    bfd_print_symbol_all
+  );
+
+(* Information about a symbol that nm needs.  *)
+
+  symbol_info = record
+    value:     symvalue;
+    typ:       ShortInt;
+    name:      pchar;    (* Symbol name.  *)
+    stab_type: Byte;     (* Stab type.  *)
+    stab_other:ShortInt; (* Stab other.  *)
+    stab_desc: SmallInt; (* Stab desc.  *)
+    stab_name: pchar;    (* String for stab type.  *)
+  end;
+
+(* Hash table routines.  There is no way to free up a hash table.  *)
+
+(* An element in the hash table.  Most uses will actually use a larger
+   structure, and an instance of this will be the first field.  *)
+
+   Pbfd_hash_entry = ^bfd_hash_entry;
+   bfd_hash_entry = record
+     (* Next entry for this hash code.  *)
+     next: Pbfd_hash_entry;
+     (* String being hashed.  *)
+     strng: pchar;
+     (* Hash code.  This is the full hash code, not the index into the
+        table.  *)
+     hash: LongWord;
+   end;
+
+(* A hash table.  *)
+  Pbfd_hash_table = ^bfd_hash_table;
+
+  bfd_hash_table_newfunc = function( entry: Pbfd_hash_entry;
+    table: Pbfd_hash_table; v: pchar): Pbfd_hash_entry;
+
+  bfd_hash_table = record
+    (* The hash array.  *)
+    table: ^Pbfd_hash_entry;
+    (* The number of slots in the hash table.  *)
+    size: LongWord ;
+    (* A function used to create new elements in the hash table.  The
+       first entry is itself a pointer to an element.  When this
+       function is first invoked, this pointer will be NULL.  However,
+       having the pointer permits a hierarchy of method functions to be
+       built each of which calls the function in the superclass.  Thus
+       each function should be written to allocate a new block of memory
+       only if the argument is NULL.  *)
+    newfunc: bfd_hash_table_newfunc;
+     (* An objalloc for this hash table.  This is a struct objalloc *,
+       but we use pointer to avoid requiring the inclusion of objalloc.h.  *)
+    memory: pointer;
+  end;
+
+  Pbfd_window_internal = pointer;
+
+  bfd_window = record
+    (* What the user asked for.  *)
+    data: pointer;
+    size: bfd_size_type;
+    (* The actual window used by BFD.  Small user-requested read-only
+       regions sharing a page may share a single window into the object
+       file.  Read-write versions shouldn't until I've fixed things to
+       keep track of which portions have been claimed by the
+       application; don't want to give the same region back when the
+       application wants two writable copies!  *)
+    i: Pbfd_window_internal;
+  end;
+
+  Pbfd_link_needed_lists = ^bfd_link_needed_lists;
+  bfd_link_needed_lists = record
+    next: Pbfd_link_needed_lists;
+    by: PBFD;
+    name: pchar;
+  end;
+
+  bfd_direction = (no_direction  {$ifndef ver1_0}= 0{$endif},
+                   read_direction {$ifndef ver1_0}= 1{$endif},
+                   write_direction {$ifndef ver1_0}= 2{$endif},
+                   both_direction   {$ifndef ver1_0}= 3{$endif});
+
+  TBFD = record
+    (* The filename the application opened the BFD with.  *)
+     filename: pchar;
+
+    (* A pointer to the target jump table.             *)
+    xvec: Pbfd_target;
+
+    (* To avoid dragging too many header files into every file that
+       includes `<<bfd.h>>', IOSTREAM has been declared as a "ShortInt
+       *", and MTIME as a "LongInt".  Their correct types, to which they
+       are cast when used, are "FILE *" and "time_t".    The iostream
+       is the result of an fopen on the filename.  However, if the
+       BFD_IN_MEMORY flag is set, then iostream is actually a pointer
+       to a bfd_in_memory struct.  *)
+    iostream: pointer ;
+
+    (* Is the file descriptor being cached?  That is, can it be closed as
+       needed, and re-opened when accessed later?  *)
+
+    cacheable: bfd_boolean ;
+
+    (* Marks whether there was a default target specified when the
+       BFD was opened. This is used to select which matching algorithm
+       to use to choose the back end. *)
+
+    target_defaulted: bfd_boolean ;
+
+    (* The caching routines use these to maintain a
+       least-recently-used list of BFDs *)
+
+    lru_prev, lru_next: PBFD;
+
+    (* When a file is closed by the caching routines, BFD retains
+       state information on the file here: *)
+
+    where: file_ptr;
+
+    (* and here: (``once'' means at least once) *)
+
+    opened_once: bfd_boolean;
+
+    (* Set if we have a locally maintained mtime value, rather than
+       getting it from the file each time: *)
+
+    mtime_set: bfd_boolean;
+
+    (* File modified time, if mtime_set is true: *)
+
+    mtime: LongInt;
+
+    (* Reserved for an unimplemented file locking extension.*)
+
+    ifd: integer ;
+
+    (* The format which belongs to the BFD. (object, core, etc.) *)
+
+    format: bfd_format;
+
+    (* The direction the BFD was opened with*)
+
+    direction: bfd_direction;
+
+    (* Format_specific flags*)
+
+    flags: flagword;
+
+    (* Currently my_archive is tested before adding origin to
+       anything. I believe that this can become always an add of
+       origin, with origin set to 0 for non archive files.   *)
+
+    origin: file_ptr;
+
+    (* Remember when output has begun, to stop strange things
+       from happening. *)
+    output_has_begun: bfd_boolean ;
+
+    (* Pointer to linked list of sections*)
+    sections: Psec;
+
+    (* The number of sections *)
+    section_count: LongWord ;
+
+    (* Stuff only useful for object files:
+       The start address. *)
+    start_address: bfd_vma ;
+
+    (* Used for input and output*)
+    symcount: LongWord ;
+
+    (* Symbol table for output BFD (with symcount entries) *)
+    outsymbols: PPsymbol_cache_entry;
+
+    (* Pointer to structure which contains architecture information*)
+    arch_info: Pbfd_arch_info;
+
+    (* Stuff only useful for archives:*)
+    arelt_data: pointer ;
+    my_archive: PBFD ;     (* The containing archive BFD.  *)
+    next: PBFD ;           (* The next BFD in the archive.  *)
+    archive_head: PBFD ;   (* The first BFD in the archive.  *)
+    has_armap: bfd_boolean ;
+
+    (* A chain of BFD structures involved in a link.  *)
+    link_next: PBFD ;
+
+    (* A field used by _bfd_generic_link_add_archive_symbols.  This will
+       be used only for archive elements.  *)
+    archive_pass: integer ;
+
+    (* Used by the back end to hold private data. *)
+
+    tdata: record
+    case integer of
+    { TODO: (?)
+      struct aout_data_struct *aout_data;
+      struct artdata *aout_ar_data;
+      struct _oasys_data *oasys_obj_data;
+      struct _oasys_ar_data *oasys_ar_data;
+      struct coff_tdata *coff_obj_data;
+      struct pe_tdata *pe_obj_data;
+      struct xcoff_tdata *xcoff_obj_data;
+      struct ecoff_tdata *ecoff_obj_data;
+      struct ieee_data_struct *ieee_data;
+      struct ieee_ar_data_struct *ieee_ar_data;
+      struct srec_data_struct *srec_data;
+      struct ihex_data_struct *ihex_data;
+      struct tekhex_data_struct *tekhex_data;
+      struct elf_obj_tdata *elf_obj_data;
+      struct nlm_obj_tdata *nlm_obj_data;
+      struct bout_data_struct *bout_data;
+      struct sun_core_struct *sun_core_data;
+      struct sco5_core_struct *sco5_core_data;
+      struct trad_core_struct *trad_core_data;
+      struct som_data_struct *som_data;
+      struct hpux_core_struct *hpux_core_data;
+      struct hppabsd_core_struct *hppabsd_core_data;
+      struct sgi_core_struct *sgi_core_data;
+      struct lynx_core_struct *lynx_core_data;
+      struct osf_core_struct *osf_core_data;
+      struct cisco_core_struct *cisco_core_data;
+      struct versados_data_struct *versados_data;
+      struct netbsd_core_struct *netbsd_core_data;}
+      -1:(any: pointer);
+    end;
+
+    (* Used by the application to hold private data*)
+    usrdata: pointer ;
+
+  (* Where all the allocated stuff under this BFD goes.  This is a
+     struct objalloc *, but we use pointer to avoid requiring the inclusion of
+     objalloc.h.  *)
+    memory: pointer ;
+  end; { TBFD }
+
+  symbol_cache_entry = record
+       (* A pointer to the BFD which owns the symbol. This information
+          is necessary so that a back end can work out what additional
+          information (invisible to the application writer) is carried
+          with the symbol.
+
+          This field is *almost* redundant, since you can use section->owner
+          instead, except that some symbols point to the global sections
+          bfd_{abs,com,und}_section.  This could be fixed by making
+          these globals be per-bfd (or per-target-flavor).  FIXME. *)
+
+    the_bfd: PBFD; (* Use bfd_asymbol_bfd(sym) to access this field. *)
+
+       (* The text of the symbol. The name is left alone, and not copied; the
+          application may not alter it. *)
+    name: pchar;
+
+       (* The value of the symbol.  This really should be a union of a
+          numeric value with a pointer, since some flags indicate that
+          a pointer to another symbol is stored here.  *)
+    value: symvalue;
+
+    flags: flagword;
+
+       (* A pointer to the section to which this symbol is
+          relative.  This will always be non NULL, there are special
+          sections for undefined and absolute symbols.  *)
+    section: Psec;
+
+    (* Back end special data.  *)
+     udata: record
+     case bfd_boolean of
+       false: (p: pointer);
+       true:  (i: bfd_vma);
+     end;
+  end; { symbol_cache_entry }
+  asymbol = symbol_cache_entry;
+
+  Pbfd_link_order = pointer; // todo?
+
+  sec = record
+    (* The name of the section; the name isn't a copy, the pointer is
+     the same as that passed to bfd_make_section.  *)
+    name: pchar;
+
+    (* A unique sequence number.  *)
+    id: integer;
+
+    (* Which section is it; 0..nth.  *)
+    index: integer;
+
+    (* The next section in the list belonging to the BFD, or NULL.  *)
+    next: Psec ;
+
+    (* The field flags contains attributes of the section. Some
+       flags are read in from the object file, and some are
+       synthesized from other information.  *)
+    flags: flagword;
+
+    (* Some internal packed bfd_boolean fields.  *)
+
+    { UT: I replaced this bitfield with a Pascal 'set'!
+      the code was
+        user_set_vma: LongWord : 1;
+        reloc_done: LongWord : 1;
+        linker_mark: LongWord : 1;
+        gc_mark: LongWord : 1;
+        segment_mark: LongWord : 1; }
+    bitfield: set of (
+      user_set_vma, (* See the vma field.  *)
+      reloc_done,   (* Whether relocations have been processed.  *)
+      linker_mark,  (* A mark flag used by some of the linker backends.  *)
+      gc_mark,      (* A mark flag used by some linker backends for garbage collection.  *)
+      segment_mark  (* Used by the ELF code to mark sections which have been allocated to segments.  *)
+    );
+    (* End of internal packed bfd_boolean fields.  *)
+
+    (*  The virtual memory address of the section - where it will be
+        at run time.  The symbols are relocated against this.  The
+        user_set_vma flag is maintained by bfd; if it's not set, the
+        backend can assign addresses (for example, in <<a.out>>, where
+        the default address for <<.data>> is dependent on the specific
+        target and various flags).  *)
+    vma: bfd_vma;
+
+    (*  The load address of the section - where it would be in a
+        rom image; really only used for writing section header
+        information. *)
+    lma: bfd_vma;
+
+    (* The size of the section in octets, as it will be output.
+       Contains a value even if the section has no contents (e.g., the
+       size of <<.bss>>).  This will be filled in after relocation.  *)
+    _cooked_size: bfd_size_type;
+
+    (* The original size on disk of the section, in octets.  Normally this
+       value is the same as the size, but if some relaxing has
+       been done, then this value will be bigger.  *)
+    _raw_size: bfd_size_type;
+
+    (* If this section is going to be output, then this value is the
+       offset in *bytes* into the output section of the first byte in the
+       input section (byte ==> smallest addressable unit on the
+       target).  In most cases, if this was going to start at the
+       100th octet (8-bit quantity) in the output section, this value
+       would be 100.  However, if the target byte size is 16 bits
+       (bfd_octets_per_byte is "2"), this value would be 50.  *)
+    output_offset: bfd_vma;
+
+    (* The output section through which to map on output.  *)
+    output_section: Psec ;
+
+    (* The alignment requirement of the section, as an exponent of 2 -
+       e.g., 3 aligns to 2^3 (or 8).  *)
+    alignment_power: LongWord;
+
+    (* If an input section, a pointer to a vector of relocation
+       records for the data in this section.  *)
+    relocation: Preloc_cache_entry;
+
+    (* If an output section, a pointer to a vector of pointers to
+       relocation records for the data in this section.  *)
+    orelocation: PPreloc_cache_entry;
+
+    (* The number of relocation records in one of the above  *)
+    reloc_count: LongWord;
+
+    (* Information below is back end specific - and not always used
+       or updated.  *)
+
+    (* File position of section data.  *)
+    filepos: file_ptr;
+
+    (* File position of relocation info.  *)
+    rel_filepos: file_ptr;
+
+    (* File position of line data.  *)
+    line_filepos: file_ptr;
+
+    (* Pointer to data for applications.  *)
+    userdata: pointer;
+
+    (* If the SEC_IN_MEMORY flag is set, this points to the actual
+       contents.  *)
+    contents: PByte;
+
+    (* Attached line number information.  *)
+    lineno: Palent;
+
+    (* Number of line number records.  *)
+    lineno_count: LongWord;
+
+    (* Optional information about a COMDAT entry; NULL if not COMDAT.  *)
+    comdat: Pbfd_comdat_info;
+
+    (* Points to the kept section if this section is a link-once section,
+       and is discarded.  *)
+    kept_section: Psec;
+
+    (* When a section is being output, this value changes as more
+       linenumbers are written out.  *)
+    moving_line_filepos: file_ptr;
+
+    (* What the section number is in the target world.  *)
+    target_index: integer;
+
+    used_by_bfd: pointer;
+
+    (* If this is a constructor section then here is a list of the
+       relocations created to relocate items within it.  *)
+    constructor_chain: Prelent_chain;
+
+    (* The BFD which owns the section.  *)
+    owner: PBFD;
+
+    (* A symbol which points at this section only *)
+    symbol: Psymbol_cache_entry;
+    symbol_ptr_ptr: PPsymbol_cache_entry;
+
+    link_order_head: Pbfd_link_order;
+    link_order_tail: Pbfd_link_order;
+  end; { sec }
+  asection = sec;
+
+  bfd_flavour = (
+    bfd_target_unknown_flavour,
+    bfd_target_aout_flavour,
+    bfd_target_coff_flavour,
+    bfd_target_ecoff_flavour,
+    bfd_target_xcoff_flavour,
+    bfd_target_elf_flavour,
+    bfd_target_ieee_flavour,
+    bfd_target_nlm_flavour,
+    bfd_target_oasys_flavour,
+    bfd_target_tekhex_flavour,
+    bfd_target_srec_flavour,
+    bfd_target_ihex_flavour,
+    bfd_target_som_flavour,
+    bfd_target_os9k_flavour,
+    bfd_target_versados_flavour,
+    bfd_target_msdos_flavour,
+    bfd_target_ovax_flavour,
+    bfd_target_evax_flavour
+  ); { bfd_flavour }
+
+  bfd_endian = ( BFD_ENDIAN_BIG, BFD_ENDIAN_LITTLE, BFD_ENDIAN_UNKNOWN );
+
+  bfd_reloc_code_real = (
+    _dummy_first_bfd_reloc_code_real,
+
+    (* Basic absolute relocations of N bits. *)
+    BFD_RELOC_64,
+    BFD_RELOC_32,
+    BFD_RELOC_26,
+    BFD_RELOC_24,
+    BFD_RELOC_16,
+    BFD_RELOC_14,
+    BFD_RELOC_8,
+
+  (* PC-relative relocations.  Sometimes these are relative to the address
+  of the relocation itself; sometimes they are relative to the start of
+  the section containing the relocation.  It depends on the specific target.
+
+  The 24-bit relocation is used in some Intel 960 configurations. *)
+    BFD_RELOC_64_PCREL,
+    BFD_RELOC_32_PCREL,
+    BFD_RELOC_24_PCREL,
+    BFD_RELOC_16_PCREL,
+    BFD_RELOC_12_PCREL,
+    BFD_RELOC_8_PCREL,
+
+  (* For ELF. *)
+    BFD_RELOC_32_GOT_PCREL,
+    BFD_RELOC_16_GOT_PCREL,
+    BFD_RELOC_8_GOT_PCREL,
+    BFD_RELOC_32_GOTOFF,
+    BFD_RELOC_16_GOTOFF,
+    BFD_RELOC_LO16_GOTOFF,
+    BFD_RELOC_HI16_GOTOFF,
+    BFD_RELOC_HI16_S_GOTOFF,
+    BFD_RELOC_8_GOTOFF,
+    BFD_RELOC_32_PLT_PCREL,
+    BFD_RELOC_24_PLT_PCREL,
+    BFD_RELOC_16_PLT_PCREL,
+    BFD_RELOC_8_PLT_PCREL,
+    BFD_RELOC_32_PLTOFF,
+    BFD_RELOC_16_PLTOFF,
+    BFD_RELOC_LO16_PLTOFF,
+    BFD_RELOC_HI16_PLTOFF,
+    BFD_RELOC_HI16_S_PLTOFF,
+    BFD_RELOC_8_PLTOFF,
+
+  (* Relocations used by 68K ELF. *)
+    BFD_RELOC_68K_GLOB_DAT,
+    BFD_RELOC_68K_JMP_SLOT,
+    BFD_RELOC_68K_RELATIVE,
+
+  (* Linkage-table relative. *)
+    BFD_RELOC_32_BASEREL,
+    BFD_RELOC_16_BASEREL,
+    BFD_RELOC_LO16_BASEREL,
+    BFD_RELOC_HI16_BASEREL,
+    BFD_RELOC_HI16_S_BASEREL,
+    BFD_RELOC_8_BASEREL,
+    BFD_RELOC_RVA,
+
+  (* Absolute 8-bit relocation, but used to form an address like $FFnn. *)
+    BFD_RELOC_8_FFnn,
+
+  (* These PC-relative relocations are stored as word displacements --
+  i.e., byte displacements shifted right two bits.  The 30-bit word
+  displacement (<<32_PCREL_S2>> -- 32 bits, shifted 2) is used on the
+  SPARC.  (SPARC tools generally refer to this as <<WDISP30>>.)  The
+  signed 16-bit displacement is used on the MIPS, and the 23-bit
+  displacement is used on the Alpha. *)
+    BFD_RELOC_32_PCREL_S2,
+    BFD_RELOC_16_PCREL_S2,
+    BFD_RELOC_23_PCREL_S2,
+
+  (* High 22 bits and low 10 bits of 32-bit value, placed into lower bits of
+  the target word.  These are used on the SPARC. *)
+    BFD_RELOC_HI22,
+    BFD_RELOC_LO10,
+
+  (* For systems that allocate a Global Pointer register, these are
+  displacements off that register.  These relocation types are
+  handled specially, because the value the register will have is
+  decided relatively late. *)
+    BFD_RELOC_GPREL16,
+    BFD_RELOC_GPREL32,
+
+  (* Reloc types used for i960/b.out. *)
+    BFD_RELOC_I960_CALLJ,
+
+  (* SPARC ELF relocations.  There is probably some overlap with other
+  relocation types already defined. *)
+    BFD_RELOC_NONE,
+    BFD_RELOC_SPARC_WDISP22,
+    BFD_RELOC_SPARC22,
+    BFD_RELOC_SPARC13,
+    BFD_RELOC_SPARC_GOT10,
+    BFD_RELOC_SPARC_GOT13,
+    BFD_RELOC_SPARC_GOT22,
+    BFD_RELOC_SPARC_PC10,
+    BFD_RELOC_SPARC_PC22,
+    BFD_RELOC_SPARC_WPLT30,
+    BFD_RELOC_SPARC_COPY,
+    BFD_RELOC_SPARC_GLOB_DAT,
+    BFD_RELOC_SPARC_JMP_SLOT,
+    BFD_RELOC_SPARC_RELATIVE,
+    BFD_RELOC_SPARC_UA32,
+
+  (* I think these are specific to SPARC a.out (e.g., Sun 4). *)
+    BFD_RELOC_SPARC_BASE13,
+    BFD_RELOC_SPARC_BASE22,
+
+  (* SPARC64 relocations *)
+    BFD_RELOC_SPARC_10,
+    BFD_RELOC_SPARC_11,
+    BFD_RELOC_SPARC_OLO10,
+    BFD_RELOC_SPARC_HH22,
+    BFD_RELOC_SPARC_HM10,
+    BFD_RELOC_SPARC_LM22,
+    BFD_RELOC_SPARC_PC_HH22,
+    BFD_RELOC_SPARC_PC_HM10,
+    BFD_RELOC_SPARC_PC_LM22,
+    BFD_RELOC_SPARC_WDISP16,
+    BFD_RELOC_SPARC_WDISP19,
+    BFD_RELOC_SPARC_7,
+    BFD_RELOC_SPARC_6,
+    BFD_RELOC_SPARC_5,
+    BFD_RELOC_SPARC_PLT64,
+    BFD_RELOC_SPARC_HIX22,
+    BFD_RELOC_SPARC_LOX10,
+    BFD_RELOC_SPARC_H44,
+    BFD_RELOC_SPARC_M44,
+    BFD_RELOC_SPARC_L44,
+    BFD_RELOC_SPARC_REGISTER,
+
+  (* SPARC little endian relocation *)
+    BFD_RELOC_SPARC_REV32,
+
+  (* Alpha ECOFF and ELF relocations.  Some of these treat the symbol or
+  "addend" in some special way.
+  For GPDISP_HI16 ("gpdisp") relocations, the symbol is ignored when
+  writing; when reading, it will be the absolute section symbol.  The
+  addend is the displacement in bytes of the "lda" instruction from
+  the "ldah" instruction (which is at the address of this reloc). *)
+    BFD_RELOC_ALPHA_GPDISP_HI16,
+
+  (* For GPDISP_LO16 ("ignore") relocations, the symbol is handled as
+  with GPDISP_HI16 relocs.  The addend is ignored when writing the
+  relocations out, and is filled in with the file's GP value on
+  reading, for convenience. *)
+    BFD_RELOC_ALPHA_GPDISP_LO16,
+
+  (* The ELF GPDISP relocation is exactly the same as the GPDISP_HI16
+  relocation except that there is no accompanying GPDISP_LO16
+  relocation. *)
+    BFD_RELOC_ALPHA_GPDISP,
+
+  (* The Alpha LITERAL/LITUSE relocs are produced by a symbol reference;
+  the assembler turns it into a LDQ instruction to load the address of
+  the symbol, and then fills in a register in the real instruction.
+
+  The LITERAL reloc, at the LDQ instruction, refers to the .lita
+  section symbol.  The addend is ignored when writing, but is filled
+  in with the file's GP value on reading, for convenience, as with the
+  GPDISP_LO16 reloc.
+
+  The ELF_LITERAL reloc is somewhere between 16_GOTOFF and GPDISP_LO16.
+  It should refer to the symbol to be referenced, as with 16_GOTOFF,
+  but it generates output not based on the position within the .got
+  section, but relative to the GP value chosen for the file during the
+  final link stage.
+
+  The LITUSE reloc, on the instruction using the loaded address, gives
+  information to the linker that it might be able to use to optimize
+  away some literal section references.  The symbol is ignored (read
+  as the absolute section symbol), and the "addend" indicates the type
+  of instruction using the register:
+  1 - "memory" fmt insn
+  2 - byte-manipulation (byte offset reg)
+  3 - jsr (target of branch)
+
+  The GNU linker currently doesn't do any of this optimizing. *)
+    BFD_RELOC_ALPHA_LITERAL,
+    BFD_RELOC_ALPHA_ELF_LITERAL,
+    BFD_RELOC_ALPHA_LITUSE,
+
+  (* The BFD_RELOC_ALPHA_USER_* relocations are used by the assembler to
+  process the explicit !<reloc>!sequence relocations, and are mapped
+  into the normal relocations at the end of processing. *)
+    BFD_RELOC_ALPHA_USER_LITERAL,
+    BFD_RELOC_ALPHA_USER_LITUSE_BASE,
+    BFD_RELOC_ALPHA_USER_LITUSE_BYTOFF,
+    BFD_RELOC_ALPHA_USER_LITUSE_JSR,
+    BFD_RELOC_ALPHA_USER_GPDISP,
+    BFD_RELOC_ALPHA_USER_GPRELHIGH,
+    BFD_RELOC_ALPHA_USER_GPRELLOW,
+
+  (* The HINT relocation indicates a value that should be filled into the
+  "hint" field of a jmp/jsr/ret instruction, for possible branch-
+  prediction logic which may be provided on some processors. *)
+    BFD_RELOC_ALPHA_HINT,
+
+  (* The LINKAGE relocation outputs a linkage pair in the object file,
+  which is filled by the linker. *)
+    BFD_RELOC_ALPHA_LINKAGE,
+
+  (* The CODEADDR relocation outputs a STO_CA in the object file,
+  which is filled by the linker. *)
+    BFD_RELOC_ALPHA_CODEADDR,
+
+  (* Bits 27..2 of the relocation address shifted right 2 bits;
+  simple reloc otherwise. *)
+    BFD_RELOC_MIPS_JMP,
+
+  (* The MIPS16 jump instruction. *)
+    BFD_RELOC_MIPS16_JMP,
+
+  (* MIPS16 GP relative reloc. *)
+    BFD_RELOC_MIPS16_GPREL,
+
+  (* High 16 bits of 32-bit value; simple reloc. *)
+    BFD_RELOC_HI16,
+
+  (* High 16 bits of 32-bit value but the low 16 bits will be sign
+  extended and added to form the final result.  If the low 16
+  bits form a negative number, we need to add one to the high value
+  to compensate for the borrow when the low bits are added. *)
+    BFD_RELOC_HI16_S,
+
+  (* Low 16 bits. *)
+    BFD_RELOC_LO16,
+
+  (* Like BFD_RELOC_HI16_S, but PC relative. *)
+    BFD_RELOC_PCREL_HI16_S,
+
+  (* Like BFD_RELOC_LO16, but PC relative. *)
+    BFD_RELOC_PCREL_LO16,
+
+  (* Relocation relative to the global pointer. *)
+
+  (* Relocation against a MIPS literal section. *)
+    BFD_RELOC_MIPS_LITERAL,
+
+  (* MIPS ELF relocations. *)
+    BFD_RELOC_MIPS_GOT16,
+    BFD_RELOC_MIPS_CALL16,
+    BFD_RELOC_MIPS_GOT_HI16,
+    BFD_RELOC_MIPS_GOT_LO16,
+    BFD_RELOC_MIPS_CALL_HI16,
+    BFD_RELOC_MIPS_CALL_LO16,
+    BFD_RELOC_MIPS_SUB,
+    BFD_RELOC_MIPS_GOT_PAGE,
+    BFD_RELOC_MIPS_GOT_OFST,
+    BFD_RELOC_MIPS_GOT_DISP,
+
+  (* i386/elf relocations *)
+    BFD_RELOC_386_GOT32,
+    BFD_RELOC_386_PLT32,
+    BFD_RELOC_386_COPY,
+    BFD_RELOC_386_GLOB_DAT,
+    BFD_RELOC_386_JUMP_SLOT,
+    BFD_RELOC_386_RELATIVE,
+    BFD_RELOC_386_GOTOFF,
+    BFD_RELOC_386_GOTPC,
+
+  (* x86-64/elf relocations *)
+    BFD_RELOC_X86_64_GOT32,
+    BFD_RELOC_X86_64_PLT32,
+    BFD_RELOC_X86_64_COPY,
+    BFD_RELOC_X86_64_GLOB_DAT,
+    BFD_RELOC_X86_64_JUMP_SLOT,
+    BFD_RELOC_X86_64_RELATIVE,
+    BFD_RELOC_X86_64_GOTPCREL,
+    BFD_RELOC_X86_64_32S,
+
+  (* ns32k relocations *)
+    BFD_RELOC_NS32K_IMM_8,
+    BFD_RELOC_NS32K_IMM_16,
+    BFD_RELOC_NS32K_IMM_32,
+    BFD_RELOC_NS32K_IMM_8_PCREL,
+    BFD_RELOC_NS32K_IMM_16_PCREL,
+    BFD_RELOC_NS32K_IMM_32_PCREL,
+    BFD_RELOC_NS32K_DISP_8,
+    BFD_RELOC_NS32K_DISP_16,
+    BFD_RELOC_NS32K_DISP_32,
+    BFD_RELOC_NS32K_DISP_8_PCREL,
+    BFD_RELOC_NS32K_DISP_16_PCREL,
+    BFD_RELOC_NS32K_DISP_32_PCREL,
+
+  (* Picojava relocs.  Not all of these appear in object files. *)
+    BFD_RELOC_PJ_CODE_HI16,
+    BFD_RELOC_PJ_CODE_LO16,
+    BFD_RELOC_PJ_CODE_DIR16,
+    BFD_RELOC_PJ_CODE_DIR32,
+    BFD_RELOC_PJ_CODE_REL16,
+    BFD_RELOC_PJ_CODE_REL32,
+
+  (* Power(rs6000) and PowerPC relocations. *)
+    BFD_RELOC_PPC_B26,
+    BFD_RELOC_PPC_BA26,
+    BFD_RELOC_PPC_TOC16,
+    BFD_RELOC_PPC_B16,
+    BFD_RELOC_PPC_B16_BRTAKEN,
+    BFD_RELOC_PPC_B16_BRNTAKEN,
+    BFD_RELOC_PPC_BA16,
+    BFD_RELOC_PPC_BA16_BRTAKEN,
+    BFD_RELOC_PPC_BA16_BRNTAKEN,
+    BFD_RELOC_PPC_COPY,
+    BFD_RELOC_PPC_GLOB_DAT,
+    BFD_RELOC_PPC_JMP_SLOT,
+    BFD_RELOC_PPC_RELATIVE,
+    BFD_RELOC_PPC_LOCAL24PC,
+    BFD_RELOC_PPC_EMB_NADDR32,
+    BFD_RELOC_PPC_EMB_NADDR16,
+    BFD_RELOC_PPC_EMB_NADDR16_LO,
+    BFD_RELOC_PPC_EMB_NADDR16_HI,
+    BFD_RELOC_PPC_EMB_NADDR16_HA,
+    BFD_RELOC_PPC_EMB_SDAI16,
+    BFD_RELOC_PPC_EMB_SDA2I16,
+    BFD_RELOC_PPC_EMB_SDA2REL,
+    BFD_RELOC_PPC_EMB_SDA21,
+    BFD_RELOC_PPC_EMB_MRKREF,
+    BFD_RELOC_PPC_EMB_RELSEC16,
+    BFD_RELOC_PPC_EMB_RELST_LO,
+    BFD_RELOC_PPC_EMB_RELST_HI,
+    BFD_RELOC_PPC_EMB_RELST_HA,
+    BFD_RELOC_PPC_EMB_BIT_FLD,
+    BFD_RELOC_PPC_EMB_RELSDA,
+
+  (* IBM 370/390 relocations *)
+    BFD_RELOC_I370_D12,
+
+  (* The type of reloc used to build a contructor table - at the moment
+  probably a 32 bit wide absolute relocation, but the target can choose.
+  It generally does map to one of the other relocation types. *)
+    BFD_RELOC_CTOR,
+
+  (* ARM 26 bit pc-relative branch.  The lowest two bits must be zero and are
+  not stored in the instruction. *)
+    BFD_RELOC_ARM_PCREL_BRANCH,
+
+  (* ARM 26 bit pc-relative branch.  The lowest bit must be zero and is
+  not stored in the instruction.  The 2nd lowest bit comes from a 1 bit
+  field in the instruction. *)
+    BFD_RELOC_ARM_PCREL_BLX,
+
+  (* Thumb 22 bit pc-relative branch.  The lowest bit must be zero and is
+  not stored in the instruction.  The 2nd lowest bit comes from a 1 bit
+  field in the instruction. *)
+    BFD_RELOC_THUMB_PCREL_BLX,
+
+  (* These relocs are only used within the ARM assembler.  They are not
+  (at present) written to any object files. *)
+    BFD_RELOC_ARM_IMMEDIATE,
+    BFD_RELOC_ARM_ADRL_IMMEDIATE,
+    BFD_RELOC_ARM_OFFSET_IMM,
+    BFD_RELOC_ARM_SHIFT_IMM,
+    BFD_RELOC_ARM_SWI,
+    BFD_RELOC_ARM_MULTI,
+    BFD_RELOC_ARM_CP_OFF_IMM,
+    BFD_RELOC_ARM_ADR_IMM,
+    BFD_RELOC_ARM_LDR_IMM,
+    BFD_RELOC_ARM_LITERAL,
+    BFD_RELOC_ARM_IN_POOL,
+    BFD_RELOC_ARM_OFFSET_IMM8,
+    BFD_RELOC_ARM_HWLITERAL,
+    BFD_RELOC_ARM_THUMB_ADD,
+    BFD_RELOC_ARM_THUMB_IMM,
+    BFD_RELOC_ARM_THUMB_SHIFT,
+    BFD_RELOC_ARM_THUMB_OFFSET,
+    BFD_RELOC_ARM_GOT12,
+    BFD_RELOC_ARM_GOT32,
+    BFD_RELOC_ARM_JUMP_SLOT,
+    BFD_RELOC_ARM_COPY,
+    BFD_RELOC_ARM_GLOB_DAT,
+    BFD_RELOC_ARM_PLT32,
+    BFD_RELOC_ARM_RELATIVE,
+    BFD_RELOC_ARM_GOTOFF,
+    BFD_RELOC_ARM_GOTPC,
+
+  (* Hitachi SH relocs.  Not all of these appear in object files. *)
+    BFD_RELOC_SH_PCDISP8BY2,
+    BFD_RELOC_SH_PCDISP12BY2,
+    BFD_RELOC_SH_IMM4,
+    BFD_RELOC_SH_IMM4BY2,
+    BFD_RELOC_SH_IMM4BY4,
+    BFD_RELOC_SH_IMM8,
+    BFD_RELOC_SH_IMM8BY2,
+    BFD_RELOC_SH_IMM8BY4,
+    BFD_RELOC_SH_PCRELIMM8BY2,
+    BFD_RELOC_SH_PCRELIMM8BY4,
+    BFD_RELOC_SH_SWITCH16,
+    BFD_RELOC_SH_SWITCH32,
+    BFD_RELOC_SH_USES,
+    BFD_RELOC_SH_COUNT,
+    BFD_RELOC_SH_ALIGN,
+    BFD_RELOC_SH_CODE,
+    BFD_RELOC_SH_DATA,
+    BFD_RELOC_SH_LABEL,
+    BFD_RELOC_SH_LOOP_START,
+    BFD_RELOC_SH_LOOP_END,
+    BFD_RELOC_SH_COPY,
+    BFD_RELOC_SH_GLOB_DAT,
+    BFD_RELOC_SH_JMP_SLOT,
+    BFD_RELOC_SH_RELATIVE,
+    BFD_RELOC_SH_GOTPC,
+
+  (* Thumb 23-, 12- and 9-bit pc-relative branches.  The lowest bit must
+  be zero and is not stored in the instruction. *)
+    BFD_RELOC_THUMB_PCREL_BRANCH9,
+    BFD_RELOC_THUMB_PCREL_BRANCH12,
+    BFD_RELOC_THUMB_PCREL_BRANCH23,
+
+  (* ARC Cores relocs.
+  ARC 22 bit pc-relative branch.  The lowest two bits must be zero and are
+  not stored in the instruction.  The high 20 bits are installed in bits 26
+  through 7 of the instruction. *)
+    BFD_RELOC_ARC_B22_PCREL,
+
+  (* ARC 26 bit absolute branch.  The lowest two bits must be zero and are not
+  stored in the instruction.  The high 24 bits are installed in bits 23
+  through 0. *)
+    BFD_RELOC_ARC_B26,
+
+  (* Mitsubishi D10V relocs.
+  This is a 10-bit reloc with the right 2 bits
+  assumed to be 0. *)
+    BFD_RELOC_D10V_10_PCREL_R,
+
+  (* Mitsubishi D10V relocs.
+  This is a 10-bit reloc with the right 2 bits
+  assumed to be 0.  This is the same as the previous reloc
+  except it is in the left container, i.e.,
+  shifted left 15 bits. *)
+    BFD_RELOC_D10V_10_PCREL_L,
+
+  (* This is an 18-bit reloc with the right 2 bits
+  assumed to be 0. *)
+    BFD_RELOC_D10V_18,
+
+  (* This is an 18-bit reloc with the right 2 bits
+  assumed to be 0. *)
+    BFD_RELOC_D10V_18_PCREL,
+
+  (* Mitsubishi D30V relocs.
+  This is a 6-bit absolute reloc. *)
+    BFD_RELOC_D30V_6,
+
+  (* This is a 6-bit pc-relative reloc with
+  the right 3 bits assumed to be 0. *)
+    BFD_RELOC_D30V_9_PCREL,
+
+  (* This is a 6-bit pc-relative reloc with
+  the right 3 bits assumed to be 0. Same
+  as the previous reloc but on the right side
+  of the container. *)
+    BFD_RELOC_D30V_9_PCREL_R,
+
+  (* This is a 12-bit absolute reloc with the
+  right 3 bitsassumed to be 0. *)
+    BFD_RELOC_D30V_15,
+
+  (* This is a 12-bit pc-relative reloc with
+  the right 3 bits assumed to be 0. *)
+    BFD_RELOC_D30V_15_PCREL,
+
+  (* This is a 12-bit pc-relative reloc with
+  the right 3 bits assumed to be 0. Same
+  as the previous reloc but on the right side
+  of the container. *)
+    BFD_RELOC_D30V_15_PCREL_R,
+
+  (* This is an 18-bit absolute reloc with
+  the right 3 bits assumed to be 0. *)
+    BFD_RELOC_D30V_21,
+
+  (* This is an 18-bit pc-relative reloc with
+  the right 3 bits assumed to be 0. *)
+    BFD_RELOC_D30V_21_PCREL,
+
+  (* This is an 18-bit pc-relative reloc with
+  the right 3 bits assumed to be 0. Same
+  as the previous reloc but on the right side
+  of the container. *)
+    BFD_RELOC_D30V_21_PCREL_R,
+
+  (* This is a 32-bit absolute reloc. *)
+    BFD_RELOC_D30V_32,
+
+  (* This is a 32-bit pc-relative reloc. *)
+    BFD_RELOC_D30V_32_PCREL,
+
+  (* Mitsubishi M32R relocs.
+  This is a 24 bit absolute address. *)
+    BFD_RELOC_M32R_24,
+
+  (* This is a 10-bit pc-relative reloc with the right 2 bits assumed to be 0. *)
+    BFD_RELOC_M32R_10_PCREL,
+
+  (* This is an 18-bit reloc with the right 2 bits assumed to be 0. *)
+    BFD_RELOC_M32R_18_PCREL,
+
+  (* This is a 26-bit reloc with the right 2 bits assumed to be 0. *)
+    BFD_RELOC_M32R_26_PCREL,
+
+  (* This is a 16-bit reloc containing the high 16 bits of an address
+  used when the lower 16 bits are treated as unsigned. *)
+    BFD_RELOC_M32R_HI16_ULO,
+
+  (* This is a 16-bit reloc containing the high 16 bits of an address
+  used when the lower 16 bits are treated as signed. *)
+    BFD_RELOC_M32R_HI16_SLO,
+
+  (* This is a 16-bit reloc containing the lower 16 bits of an address. *)
+    BFD_RELOC_M32R_LO16,
+
+  (* This is a 16-bit reloc containing the small data area offset for use in
+  add3, load, and store instructions. *)
+    BFD_RELOC_M32R_SDA16,
+
+  (* This is a 9-bit reloc *)
+    BFD_RELOC_V850_9_PCREL,
+
+  (* This is a 22-bit reloc *)
+    BFD_RELOC_V850_22_PCREL,
+
+  (* This is a 16 bit offset from the SmallInt data area pointer. *)
+    BFD_RELOC_V850_SDA_16_16_OFFSET,
+
+  (* This is a 16 bit offset (of which only 15 bits are used) from the
+  SmallInt data area pointer. *)
+    BFD_RELOC_V850_SDA_15_16_OFFSET,
+
+  (* This is a 16 bit offset from the zero data area pointer. *)
+    BFD_RELOC_V850_ZDA_16_16_OFFSET,
+
+  (* This is a 16 bit offset (of which only 15 bits are used) from the
+  zero data area pointer. *)
+    BFD_RELOC_V850_ZDA_15_16_OFFSET,
+
+  (* This is an 8 bit offset (of which only 6 bits are used) from the
+  tiny data area pointer. *)
+    BFD_RELOC_V850_TDA_6_8_OFFSET,
+
+  (* This is an 8bit offset (of which only 7 bits are used) from the tiny
+  data area pointer. *)
+    BFD_RELOC_V850_TDA_7_8_OFFSET,
+
+  (* This is a 7 bit offset from the tiny data area pointer. *)
+    BFD_RELOC_V850_TDA_7_7_OFFSET,
+
+  (* This is a 16 bit offset from the tiny data area pointer. *)
+    BFD_RELOC_V850_TDA_16_16_OFFSET,
+
+  (* This is a 5 bit offset (of which only 4 bits are used) from the tiny
+  data area pointer. *)
+    BFD_RELOC_V850_TDA_4_5_OFFSET,
+
+  (* This is a 4 bit offset from the tiny data area pointer. *)
+    BFD_RELOC_V850_TDA_4_4_OFFSET,
+
+  (* This is a 16 bit offset from the SmallInt data area pointer, with the
+  bits placed non-contigously in the instruction. *)
+    BFD_RELOC_V850_SDA_16_16_SPLIT_OFFSET,
+
+  (* This is a 16 bit offset from the zero data area pointer, with the
+  bits placed non-contigously in the instruction. *)
+    BFD_RELOC_V850_ZDA_16_16_SPLIT_OFFSET,
+
+  (* This is a 6 bit offset from the call table base pointer. *)
+    BFD_RELOC_V850_CALLT_6_7_OFFSET,
+
+  (* This is a 16 bit offset from the call table base pointer. *)
+    BFD_RELOC_V850_CALLT_16_16_OFFSET,
+
+
+  (* This is a 32bit pcrel reloc for the mn10300, offset by two bytes in the
+  instruction. *)
+    BFD_RELOC_MN10300_32_PCREL,
+
+  (* This is a 16bit pcrel reloc for the mn10300, offset by two bytes in the
+  instruction. *)
+    BFD_RELOC_MN10300_16_PCREL,
+
+  (* This is a 8bit DP reloc for the tms320c30, where the most
+  significant 8 bits of a 24 bit word are placed into the least
+  significant 8 bits of the opcode. *)
+    BFD_RELOC_TIC30_LDP,
+
+  (* This is a 7bit reloc for the tms320c54x, where the least
+  significant 7 bits of a 16 bit word are placed into the least
+  significant 7 bits of the opcode. *)
+    BFD_RELOC_TIC54X_PARTLS7,
+
+  (* This is a 9bit DP reloc for the tms320c54x, where the most
+  significant 9 bits of a 16 bit word are placed into the least
+  significant 9 bits of the opcode. *)
+    BFD_RELOC_TIC54X_PARTMS9,
+
+  (* This is an extended address 23-bit reloc for the tms320c54x. *)
+    BFD_RELOC_TIC54X_23,
+
+  (* This is a 16-bit reloc for the tms320c54x, where the least
+  significant 16 bits of a 23-bit extended address are placed into
+  the opcode. *)
+    BFD_RELOC_TIC54X_16_OF_23,
+
+  (* This is a reloc for the tms320c54x, where the most
+  significant 7 bits of a 23-bit extended address are placed into
+  the opcode. *)
+    BFD_RELOC_TIC54X_MS7_OF_23,
+
+  (* This is a 48 bit reloc for the FR30 that stores 32 bits. *)
+    BFD_RELOC_FR30_48,
+
+  (* This is a 32 bit reloc for the FR30 that stores 20 bits split up into
+  two sections. *)
+    BFD_RELOC_FR30_20,
+
+  (* This is a 16 bit reloc for the FR30 that stores a 6 bit word offset in
+  4 bits. *)
+    BFD_RELOC_FR30_6_IN_4,
+
+  (* This is a 16 bit reloc for the FR30 that stores an 8 bit byte offset
+  into 8 bits. *)
+    BFD_RELOC_FR30_8_IN_8,
+
+  (* This is a 16 bit reloc for the FR30 that stores a 9 bit SmallInt offset
+  into 8 bits. *)
+    BFD_RELOC_FR30_9_IN_8,
+
+  (* This is a 16 bit reloc for the FR30 that stores a 10 bit word offset
+  into 8 bits. *)
+    BFD_RELOC_FR30_10_IN_8,
+
+  (* This is a 16 bit reloc for the FR30 that stores a 9 bit pc relative
+  SmallInt offset into 8 bits. *)
+    BFD_RELOC_FR30_9_PCREL,
+
+  (* This is a 16 bit reloc for the FR30 that stores a 12 bit pc relative
+  SmallInt offset into 11 bits. *)
+    BFD_RELOC_FR30_12_PCREL,
+
+  (* Motorola Mcore relocations. *)
+    BFD_RELOC_MCORE_PCREL_IMM8BY4,
+    BFD_RELOC_MCORE_PCREL_IMM11BY2,
+    BFD_RELOC_MCORE_PCREL_IMM4BY2,
+    BFD_RELOC_MCORE_PCREL_32,
+    BFD_RELOC_MCORE_PCREL_JSR_IMM11BY2,
+    BFD_RELOC_MCORE_RVA,
+
+  (* This is a 16 bit reloc for the AVR that stores 8 bit pc relative
+  SmallInt offset into 7 bits. *)
+    BFD_RELOC_AVR_7_PCREL,
+
+  (* This is a 16 bit reloc for the AVR that stores 13 bit pc relative
+  SmallInt offset into 12 bits. *)
+    BFD_RELOC_AVR_13_PCREL,
+
+  (* This is a 16 bit reloc for the AVR that stores 17 bit value (usually
+  program memory address) into 16 bits. *)
+    BFD_RELOC_AVR_16_PM,
+
+  (* This is a 16 bit reloc for the AVR that stores 8 bit value (usually
+  data memory address) into 8 bit immediate value of LDI insn. *)
+    BFD_RELOC_AVR_LO8_LDI,
+
+  (* This is a 16 bit reloc for the AVR that stores 8 bit value (high 8 bit
+  of data memory address) into 8 bit immediate value of LDI insn. *)
+    BFD_RELOC_AVR_HI8_LDI,
+
+  (* This is a 16 bit reloc for the AVR that stores 8 bit value (most high 8 bit
+  of program memory address) into 8 bit immediate value of LDI insn. *)
+    BFD_RELOC_AVR_HH8_LDI,
+
+  (* This is a 16 bit reloc for the AVR that stores negated 8 bit value
+  (usually data memory address) into 8 bit immediate value of SUBI insn. *)
+    BFD_RELOC_AVR_LO8_LDI_NEG,
+
+  (* This is a 16 bit reloc for the AVR that stores negated 8 bit value
+  (high 8 bit of data memory address) into 8 bit immediate value of
+  SUBI insn. *)
+    BFD_RELOC_AVR_HI8_LDI_NEG,
+
+  (* This is a 16 bit reloc for the AVR that stores negated 8 bit value
+  (most high 8 bit of program memory address) into 8 bit immediate value
+  of LDI or SUBI insn. *)
+    BFD_RELOC_AVR_HH8_LDI_NEG,
+
+  (* This is a 16 bit reloc for the AVR that stores 8 bit value (usually
+  command address) into 8 bit immediate value of LDI insn. *)
+    BFD_RELOC_AVR_LO8_LDI_PM,
+
+  (* This is a 16 bit reloc for the AVR that stores 8 bit value (high 8 bit
+  of command address) into 8 bit immediate value of LDI insn. *)
+    BFD_RELOC_AVR_HI8_LDI_PM,
+
+  (* This is a 16 bit reloc for the AVR that stores 8 bit value (most high 8 bit
+  of command address) into 8 bit immediate value of LDI insn. *)
+    BFD_RELOC_AVR_HH8_LDI_PM,
+
+  (* This is a 16 bit reloc for the AVR that stores negated 8 bit value
+  (usually command address) into 8 bit immediate value of SUBI insn. *)
+    BFD_RELOC_AVR_LO8_LDI_PM_NEG,
+
+  (* This is a 16 bit reloc for the AVR that stores negated 8 bit value
+  (high 8 bit of 16 bit command address) into 8 bit immediate value
+  of SUBI insn. *)
+    BFD_RELOC_AVR_HI8_LDI_PM_NEG,
+
+  (* This is a 16 bit reloc for the AVR that stores negated 8 bit value
+  (high 6 bit of 22 bit command address) into 8 bit immediate
+  value of SUBI insn. *)
+    BFD_RELOC_AVR_HH8_LDI_PM_NEG,
+
+  (* This is a 32 bit reloc for the AVR that stores 23 bit value
+  into 22 bits. *)
+    BFD_RELOC_AVR_CALL,
+
+  (* These two relocations are used by the linker to determine which of
+  the entries in a C++ virtual function table are actually used.  When
+  the --gc-sections option is given, the linker will zero out the entries
+  that are not used, so that the code for those functions need not be
+  included in the output.
+
+  VTABLE_INHERIT is a zero-space relocation used to describe to the
+  linker the inheritence tree of a C++ virtual function table.  The
+  relocation's symbol should be the parent class' vtable, and the
+  relocation should be located at the child vtable.
+
+  VTABLE_ENTRY is a zero-space relocation that describes the use of a
+  virtual function table entry.  The reloc's symbol should refer to the
+  table of the class mentioned in the code.  Off of that base, an offset
+  describes the entry that is being used.  For Rela hosts, this offset
+  is stored in the reloc's addend.  For Rel hosts, we are forced to put
+  this offset in the reloc's section offset. *)
+    BFD_RELOC_VTABLE_INHERIT,
+    BFD_RELOC_VTABLE_ENTRY,
+
+  (* Intel IA64 Relocations. *)
+    BFD_RELOC_IA64_IMM14,
+    BFD_RELOC_IA64_IMM22,
+    BFD_RELOC_IA64_IMM64,
+    BFD_RELOC_IA64_DIR32MSB,
+    BFD_RELOC_IA64_DIR32LSB,
+    BFD_RELOC_IA64_DIR64MSB,
+    BFD_RELOC_IA64_DIR64LSB,
+    BFD_RELOC_IA64_GPREL22,
+    BFD_RELOC_IA64_GPREL64I,
+    BFD_RELOC_IA64_GPREL32MSB,
+    BFD_RELOC_IA64_GPREL32LSB,
+    BFD_RELOC_IA64_GPREL64MSB,
+    BFD_RELOC_IA64_GPREL64LSB,
+    BFD_RELOC_IA64_LTOFF22,
+    BFD_RELOC_IA64_LTOFF64I,
+    BFD_RELOC_IA64_PLTOFF22,
+    BFD_RELOC_IA64_PLTOFF64I,
+    BFD_RELOC_IA64_PLTOFF64MSB,
+    BFD_RELOC_IA64_PLTOFF64LSB,
+    BFD_RELOC_IA64_FPTR64I,
+    BFD_RELOC_IA64_FPTR32MSB,
+    BFD_RELOC_IA64_FPTR32LSB,
+    BFD_RELOC_IA64_FPTR64MSB,
+    BFD_RELOC_IA64_FPTR64LSB,
+    BFD_RELOC_IA64_PCREL21B,
+    BFD_RELOC_IA64_PCREL21BI,
+    BFD_RELOC_IA64_PCREL21M,
+    BFD_RELOC_IA64_PCREL21F,
+    BFD_RELOC_IA64_PCREL22,
+    BFD_RELOC_IA64_PCREL60B,
+    BFD_RELOC_IA64_PCREL64I,
+    BFD_RELOC_IA64_PCREL32MSB,
+    BFD_RELOC_IA64_PCREL32LSB,
+    BFD_RELOC_IA64_PCREL64MSB,
+    BFD_RELOC_IA64_PCREL64LSB,
+    BFD_RELOC_IA64_LTOFF_FPTR22,
+    BFD_RELOC_IA64_LTOFF_FPTR64I,
+    BFD_RELOC_IA64_LTOFF_FPTR64MSB,
+    BFD_RELOC_IA64_LTOFF_FPTR64LSB,
+    BFD_RELOC_IA64_SEGREL32MSB,
+    BFD_RELOC_IA64_SEGREL32LSB,
+    BFD_RELOC_IA64_SEGREL64MSB,
+    BFD_RELOC_IA64_SEGREL64LSB,
+    BFD_RELOC_IA64_SECREL32MSB,
+    BFD_RELOC_IA64_SECREL32LSB,
+    BFD_RELOC_IA64_SECREL64MSB,
+    BFD_RELOC_IA64_SECREL64LSB,
+    BFD_RELOC_IA64_REL32MSB,
+    BFD_RELOC_IA64_REL32LSB,
+    BFD_RELOC_IA64_REL64MSB,
+    BFD_RELOC_IA64_REL64LSB,
+    BFD_RELOC_IA64_LTV32MSB,
+    BFD_RELOC_IA64_LTV32LSB,
+    BFD_RELOC_IA64_LTV64MSB,
+    BFD_RELOC_IA64_LTV64LSB,
+    BFD_RELOC_IA64_IPLTMSB,
+    BFD_RELOC_IA64_IPLTLSB,
+    BFD_RELOC_IA64_COPY,
+    BFD_RELOC_IA64_TPREL22,
+    BFD_RELOC_IA64_TPREL64MSB,
+    BFD_RELOC_IA64_TPREL64LSB,
+    BFD_RELOC_IA64_LTOFF_TP22,
+    BFD_RELOC_IA64_LTOFF22X,
+    BFD_RELOC_IA64_LDXMOV,
+
+  (* Motorola 68HC11 reloc.
+  This is the 8 bits high part of an absolute address. *)
+    BFD_RELOC_M68HC11_HI8,
+
+  (* Motorola 68HC11 reloc.
+  This is the 8 bits low part of an absolute address. *)
+    BFD_RELOC_M68HC11_LO8,
+
+  (* Motorola 68HC11 reloc.
+  This is the 3 bits of a value. *)
+    BFD_RELOC_M68HC11_3B,
+
+  (* These relocs are only used within the CRIS assembler.  They are not
+  (at present) written to any object files. *)
+    BFD_RELOC_CRIS_BDISP8,
+    BFD_RELOC_CRIS_UNSIGNED_5,
+    BFD_RELOC_CRIS_SIGNED_6,
+    BFD_RELOC_CRIS_UNSIGNED_6,
+    BFD_RELOC_CRIS_UNSIGNED_4,
+
+  (* Intel i860 Relocations. *)
+    BFD_RELOC_860_COPY,
+    BFD_RELOC_860_GLOB_DAT,
+    BFD_RELOC_860_JUMP_SLOT,
+    BFD_RELOC_860_RELATIVE,
+    BFD_RELOC_860_PC26,
+    BFD_RELOC_860_PLT26,
+    BFD_RELOC_860_PC16,
+    BFD_RELOC_860_LOW0,
+    BFD_RELOC_860_SPLIT0,
+    BFD_RELOC_860_LOW1,
+    BFD_RELOC_860_SPLIT1,
+    BFD_RELOC_860_LOW2,
+    BFD_RELOC_860_SPLIT2,
+    BFD_RELOC_860_LOW3,
+    BFD_RELOC_860_LOGOT0,
+    BFD_RELOC_860_SPGOT0,
+    BFD_RELOC_860_LOGOT1,
+    BFD_RELOC_860_SPGOT1,
+    BFD_RELOC_860_LOGOTOFF0,
+    BFD_RELOC_860_SPGOTOFF0,
+    BFD_RELOC_860_LOGOTOFF1,
+    BFD_RELOC_860_SPGOTOFF1,
+    BFD_RELOC_860_LOGOTOFF2,
+    BFD_RELOC_860_LOGOTOFF3,
+    BFD_RELOC_860_LOPC,
+    BFD_RELOC_860_HIGHADJ,
+    BFD_RELOC_860_HAGOT,
+    BFD_RELOC_860_HAGOTOFF,
+    BFD_RELOC_860_HAPC,
+    BFD_RELOC_860_HIGH,
+    BFD_RELOC_860_HIGOT,
+    BFD_RELOC_860_HIGOTOFF,
+    BFD_RELOC_UNUSED
+  ); { bfd_reloc_code_real }
+
+  bfd_architecture = (
+    bfd_arch_unknown,   (* File arch not known *)
+    bfd_arch_obscure,   (* Arch known, not one of these *)
+    bfd_arch_m68k,      (* Motorola 68xxx *)
+    bfd_arch_vax,       (* DEC Vax *)
+    bfd_arch_i960,      (* Intel 960 *)
+      (* The order of the following is important.
+         lower number indicates a machine type that
+         only accepts a subset of the instructions
+         available to machines with higher numbers.
+         The exception is the "ca", which is
+         incompatible with all other machines except
+         "core". *)
+
+    bfd_arch_a29k,      (* AMD 29000 *)
+    bfd_arch_sparc,     (* SPARC *)
+  (* The difference between v8plus and v9 is that v9 is a true 64 bit env.  *)
+  (* Nonzero if MACH has the v9 instruction set.  *)
+    bfd_arch_mips,      (* MIPS Rxxxx *)
+    bfd_arch_i386,      (* Intel 386 *)
+    bfd_arch_we32k,     (* AT&T WE32xxx *)
+    bfd_arch_tahoe,     (* CCI/Harris Tahoe *)
+    bfd_arch_i860,      (* Intel 860 *)
+    bfd_arch_i370,      (* IBM 360/370 Mainframes *)
+    bfd_arch_romp,      (* IBM ROMP PC/RT *)
+    bfd_arch_alliant,   (* Alliant *)
+    bfd_arch_convex,    (* Convex *)
+    bfd_arch_m88k,      (* Motorola 88xxx *)
+    bfd_arch_pyramid,   (* Pyramid Technology *)
+    bfd_arch_h8300,     (* Hitachi H8/300 *)
+    bfd_arch_powerpc,   (* PowerPC *)
+    bfd_arch_rs6000,    (* IBM RS/6000 *)
+    bfd_arch_hppa,      (* HP PA RISC *)
+    bfd_arch_d10v,      (* Mitsubishi D10V *)
+    bfd_arch_d30v,      (* Mitsubishi D30V *)
+    bfd_arch_m68hc11,   (* Motorola 68HC11 *)
+    bfd_arch_m68hc12,   (* Motorola 68HC12 *)
+    bfd_arch_z8k,       (* Zilog Z8000 *)
+    bfd_arch_h8500,     (* Hitachi H8/500 *)
+    bfd_arch_sh,        (* Hitachi SH *)
+    bfd_arch_alpha,     (* Dec Alpha *)
+    bfd_arch_arm,       (* Advanced Risc Machines ARM *)
+    bfd_arch_ns32k,     (* National Semiconductors ns32000 *)
+    bfd_arch_w65,       (* WDC 65816 *)
+    bfd_arch_tic30,     (* Texas Instruments TMS320C30 *)
+    bfd_arch_tic54x,    (* Texas Instruments TMS320C54X *)
+    bfd_arch_tic80,     (* TI TMS320c80 (MVP) *)
+    bfd_arch_v850,      (* NEC V850 *)
+    bfd_arch_arc,       (* ARC Cores *)
+    bfd_arch_m32r,      (* Mitsubishi M32R/D *)
+    bfd_arch_mn10200,   (* Matsushita MN10200 *)
+    bfd_arch_mn10300,   (* Matsushita MN10300 *)
+    bfd_arch_fr30,
+    bfd_arch_mcore,
+    bfd_arch_ia64,      (* HP/Intel ia64 *)
+    bfd_arch_pj,
+    bfd_arch_avr,       (* Atmel AVR microcontrollers *)
+    bfd_arch_cris,      (* Axis CRIS *)
+    bfd_arch_last
+  ); { bfd_architecture }
+
+  check_format_proc    = function (a:PBFD):pbfd_target;cdecl;
+  set_format_proc      = function (a:PBFD):bfd_boolean;cdecl;
+  write_contents_proc = function (a:PBFD):bfd_boolean;cdecl;
+
+  bfd_target = record
+    name: pchar;
+    flavour: bfd_flavour;
+    byteorder: bfd_endian;
+    header_byteorder: bfd_endian;
+    object_flags: flagword;
+    section_flags: flagword;
+    symbol_leading_char: ShortInt;
+    ar_pad_char: ShortInt;
+    ar_max_namelen: Word;
+    bfd_getx64:           function (const Pbfd_byte): bfd_vma; cdecl;
+    bfd_getx_signed_64:   function (const Pbfd_byte):bfd_signed_vma; cdecl;
+    bfd_putx64:           procedure(a: bfd_vma; b: Pbfd_byte); cdecl;
+    bfd_getx32:           function (const Pbfd_byte):bfd_vma; cdecl;
+    bfd_getx_signed_32:   function (const Pbfd_byte):bfd_signed_vma; cdecl;
+    bfd_putx32:           procedure(a: bfd_vma; b: Pbfd_byte); cdecl;
+    bfd_getx16:           function (const Pbfd_byte):bfd_vma; cdecl;
+    bfd_getx_signed_16:   function (const Pbfd_byte):bfd_signed_vma; cdecl;
+    bfd_putx16:           procedure(a: bfd_vma; b: Pbfd_byte); cdecl;
+    bfd_h_getx64:         function (const Pbfd_byte):bfd_vma; cdecl;
+    bfd_h_getx_signed_64: function (const Pbfd_byte):bfd_signed_vma; cdecl;
+    bfd_h_putx64:         procedure(a: bfd_vma; b: Pbfd_byte); cdecl;
+    bfd_h_getx32:         function (const Pbfd_byte):bfd_vma; cdecl;
+    bfd_h_getx_signed_32: function (const Pbfd_byte):bfd_signed_vma; cdecl;
+    bfd_h_putx32:         procedure(a: bfd_vma; b: Pbfd_byte); cdecl;
+    bfd_h_getx16:         function (const Pbfd_byte):bfd_vma; cdecl;
+    bfd_h_getx_signed_16: function (const Pbfd_byte):bfd_signed_vma; cdecl;
+    bfd_h_putx16:         procedure(a: bfd_vma; b: Pbfd_byte); cdecl;
+    _bfd_check_format:   array [bfd_format] of check_format_proc;
+    _bfd_set_format:     array [bfd_format] of set_format_proc;
+    _bfd_write_contents: array [bfd_format] of write_contents_proc;
+
+    (* Generic entry points.  *)
+
+    (* Called when the BFD is being closed to do any necessary cleanup.  *)
+    _close_and_cleanup:     function(a: PBFD  ):bfd_boolean;cdecl;
+    (* Ask the BFD to free all cached information.  *)
+    _bfd_free_cached_info:  function(a: PBFD  ):bfd_boolean;cdecl;
+    (* Called when a new section is created.  *)
+    _new_section_hook:      function(a: PBFD; b: PSec):bfd_boolean;cdecl;
+    (* Read the contents of a section.  *)
+    _bfd_get_section_contents:  function(a: PBFD; b: PSec; c: pointer; d: file_ptr; e: bfd_size_type):bfd_boolean;cdecl;
+    _bfd_get_section_contents_in_window: function(a: PBFD; b: PSec; c: Pbfd_window; d:file_ptr; e: bfd_size_type):bfd_boolean;cdecl;
+
+    (* Entry points to copy private data.  *)
+
+    (* Called to copy BFD general private data from one object file
+       to another.  *)
+    _bfd_copy_private_bfd_data:  function(a: PBFD; b: PBFD  ):bfd_boolean;cdecl;
+    (* Called to merge BFD general private data from one object file
+       to a common output file when linking.  *)
+    _bfd_merge_private_bfd_data:  function(a: PBFD; b: PBFD  ):bfd_boolean;cdecl;
+    (* Called to copy BFD private section data from one object file
+       to another.  *)
+    _bfd_copy_private_section_data: function(a: PBFD; b:PSec; c: PBFD; d: PSec):bfd_boolean;cdecl;
+    (* Called to copy BFD private symbol data from one symbol
+       to another.  *)
+    _bfd_copy_private_symbol_data: function(a: PBFD; b: Pasymbol; c: PBFD; d: Pasymbol):bfd_boolean;cdecl;
+    (* Called to set private backend flags *)
+    _bfd_set_private_flags: function(a: PBFD; b:flagword):bfd_boolean; cdecl;
+
+    (* Called to print private BFD data *)
+    _bfd_print_private_bfd_data: function(a: PBFD; b: pointer):bfd_boolean; cdecl;
+
+    (* Core file entry points.  *)
+
+    (* Archive entry points.  *)
+
+    _bfd_slurp_armap: function(a: PBFD):bfd_boolean;cdecl;
+    _bfd_slurp_extended_name_table: function(a: PBFD  ):bfd_boolean;cdecl;
+    _bfd_construct_extended_name_table: function(a: PBFD; b: Ppchar; c: Pbfd_size_type; d: Ppchar):bfd_boolean;cdecl;
+    _bfd_truncate_arname: procedure (a: PBFD; b: pchar; c: pchar);cdecl;
+    write_armap: function(arch: PBFD; elength: LongWord; map: Porl; orl_count: LongWord; stridx: integer):bfd_boolean;cdecl;
+    _bfd_read_ar_hdr_fn: function(a: PBFD  ):pointer;cdecl;
+    openr_next_archived_file: function(arch: PBFD; prev: PBFD):PBFD;cdecl;
+
+
+    _bfd_get_elt_at_index: function(a: PBFD; b: symindex):PBFD;cdecl;
+    _bfd_stat_arch_elt: function(a: PBFD; b: Pstat ):integer;cdecl;
+    _bfd_update_armap_timestamp: function(a: PBFD  ):bfd_boolean;cdecl;
+
+    (* Entry points used for symbols.  *)
+
+    _bfd_get_symtab_upper_bound: function(a: PBFD  ):LongInt;cdecl;
+    _bfd_canonicalize_symtab: function(a: PBFD; b: PPsymbol_cache_entry):LongInt;cdecl;
+
+
+    _bfd_make_empty_symbol: function(a: PBFD  ): PPsymbol_cache_entry;cdecl;
+
+    _bfd_print_symbol: procedure(a: PBFD; b: pointer; c: Psymbol_cache_entry; d: bfd_print_symbol);cdecl;
+    _bfd_get_symbol_info: procedure (a: PBFD; b: Psymbol_cache_entry; c:Psymbol_info);cdecl;
+    _bfd_is_local_label_name: function(a: PBFD; b: pchar):bfd_boolean;cdecl;
+
+    _get_lineno: function( a: PBFD; b: Psymbol_cache_entry):Palent;cdecl;
+    _bfd_find_nearest_line: function(abfd: PBFD; section: Psec; symbols: PPsymbol_cache_entry; offset: bfd_vma; fil: pchar; func: Ppchar;  lin: PLongWord):bfd_boolean;cdecl;
+   (* Back-door to allow format-aware applications to create debug symbols
+      while using BFD for everything else.  Currently used by the assembler
+      when creating COFF files.  *)
+    _bfd_make_debug_symbol: function( abfd: PBFD ; ptr: pointer; size: LongWord ):Pasymbol;cdecl;
+    _read_minisymbols:   function(a: PBFD; b: bfd_boolean; c: PPointer; d: PLongWord):LongInt;cdecl;
+    _minisymbol_to_symbol: function(a: PBFD; b:bfd_boolean; c: pointer; d: Pasymbol):Pasymbol;cdecl;
+
+    (* Routines for relocs.  *)
+
+    _get_reloc_upper_bound: function(a: PBFD; b: PSec):LongInt;cdecl;
+    _bfd_canonicalize_reloc: function(a: PBFD; b: PSec;c: PParelent; d: PPsymbol_cache_entry ):LongInt;cdecl;
+    (* See documentation on reloc types.  *)
+
+    reloc_type_lookup: function(abfd: PBFD ; code: bfd_reloc_code_real): PPreloc_howto;cdecl;
+
+    (* Routines used when writing an object file.  *)
+
+    _bfd_set_arch_mach: function( a: PBFD; b:bfd_architecture; c:LongWord): bfd_boolean;cdecl;
+
+    _bfd_set_section_contents: function(a: PBFD; b: PSec; c: pointer; d: file_ptr; e: bfd_size_type):bfd_boolean;cdecl;
+
+    (* Routines used by the linker.  *)
+
+    _bfd_sizeof_headers: function(a: PBFD ; b: bfd_boolean):integer;cdecl;
+    _bfd_get_relocated_section_contents: function(a: PBFD ; b: Pbfd_link_info; c: Pbfd_link_order; data: Pbfd_byte; relocateable: bfd_boolean; ce: PPsymbol_cache_entry):Pbfd_byte;cdecl;
+
+    _bfd_relax_section: function(a: PBFD ; b: Psec; c: Pbfd_link_info; again: Pboolean):bfd_boolean;cdecl;
+
+    (* Create a hash table for the linker.  Different backends store
+       different information in this table.  *)
+    _bfd_link_hash_table_create: function( a: PBFD  ):Pbfd_link_hash_table;cdecl;
+
+    (* Add symbols from this object file into the hash table.  *)
+    _bfd_link_add_symbols: function(a: PBFD ; b: Pbfd_link_info):bfd_boolean;cdecl;
+
+    (* Do a link based on the link_order structures attached to each
+       section of the BFD.  *)
+    _bfd_final_link: function(a: PBFD; b: Pbfd_link_info):bfd_boolean;cdecl;
+
+    (* Should this section be split up into smaller pieces during linking.  *)
+    _bfd_link_split_section: function(a: PBFD; b: Psec):bfd_boolean;cdecl;
+
+    (* Remove sections that are not referenced from the output.  *)
+    _bfd_gc_sections: function(a: PBFD ; b: Pbfd_link_info):bfd_boolean;cdecl;
+
+    (* Routines to handle dynamic symbols and relocs.  *)
+
+    (* Get the amount of memory required to hold the dynamic symbols. *)
+    _bfd_get_dynamic_symtab_upper_bound: function(a: PBFD  ):LongInt;cdecl;
+    (* Read in the dynamic symbols.  *)
+    _bfd_canonicalize_dynamic_symtab: function(a: PBFD ; b: PPsymbol_cache_entry):LongInt;cdecl;
+    (* Get the amount of memory required to hold the dynamic relocs.  *)
+    _bfd_get_dynamic_reloc_upper_bound: function(a: PBFD  ):LongInt;cdecl;
+    (* Read in the dynamic relocs.  *)
+    _bfd_canonicalize_dynamic_reloc: function(a: PBFD ; b: PParelent; c: PPsymbol_cache_entry):LongInt;cdecl;
+
+    (* Opposite endian version of this target.  *)
+    alternative_target: Pbfd_target;
+
+    backend_data: pointer;
+  end; { bfd_target }
+
+  complain_overflow = (
+       (* Do not complain on overflow. *)
+    complain_overflow_dont,
+
+       (* Complain if the bitfield overflows, whether it is considered
+          as signed or unsigned. *)
+    complain_overflow_bitfield,
+
+       (* Complain if the value overflows when considered as signed
+          number. *)
+    complain_overflow_signed,
+
+       (* Complain if the value overflows when considered as an
+          unsigned number. *)
+    complain_overflow_unsigned
+  ); { complain_overflow }
+
+  bfd_reloc_status = (
+         (* No errors detected *)
+    bfd_reloc_ok,
+
+         (* The relocation was performed, but there was an overflow. *)
+    bfd_reloc_overflow,
+
+         (* The address to relocate was not within the section supplied. *)
+    bfd_reloc_outofrange,
+
+         (* Used by special functions *)
+    bfd_reloc_continue,
+
+         (* Unsupported relocation size requested. *)
+    bfd_reloc_notsupported,
+
+         (* Unused *)
+    bfd_reloc_other,
+
+         (* The symbol to relocate against was undefined. *)
+    bfd_reloc_undefined,
+
+         (* The relocation was performed, but may not be ok - presently
+            generated only when linking i960 coff files with i960 b.out
+            symbols.  If this type is returned, the error_message argument
+            to bfd_perform_relocation will be set.  *)
+    bfd_reloc_dangerous
+  ); { bfd_reloc_status }
+
+
+  reloc_howto = record
+         (*  The type field has mainly a documentary use - the back end can
+             do what it wants with it, though normally the back end's
+             external idea of what a reloc number is stored
+             in this field. For example, a PC relative word relocation
+             in a coff environment has the type 023 - because that's
+             what the outside world calls a R_PCRWORD reloc. *)
+    typ: LongWord;
+
+         (*  The value the final relocation is shifted right by. This drops
+             unwanted data from the relocation.  *)
+    rightshift: LongWord;
+
+         (*  The size of the item to be relocated.  This is *not* a
+             power-of-two measure.  To get the number of bytes operated
+             on by a type of relocation, use bfd_get_reloc_size.  *)
+    size: integer;
+
+         (*  The number of bits in the item to be relocated.  This is used
+             when doing overflow checking.  *)
+    bitsize: LongWord;
+
+         (*  Notes that the relocation is relative to the location in the
+             data section of the addend. The relocation function will
+             subtract from the relocation value the address of the location
+             being relocated. *)
+    pc_relative: bfd_boolean;
+
+         (*  The bit position of the reloc value in the destination.
+             The relocated value is left shifted by this amount. *)
+    bitpos: LongWord;
+
+         (* What type of overflow error should be checked for when
+            relocating. *)
+    complain_on_overflow: complain_overflow;
+
+         (* If this field is non null, then the supplied function is
+            called rather than the normal function. This allows really
+            strange relocation methods to be accomodated (e.g., i960 callj
+            instructions). *)
+    special_function: function( abfd: PBFD;
+                                reloc_entry: Parelent;
+                                symbol: Psymbol_cache_entry;
+                                data: pointer;
+                                input_section: Pasection;
+                                output_bfd: PBFD;
+                                error_message: ppchar):  bfd_reloc_status;cdecl;
+
+         (* The textual name of the relocation type. *)
+    name: pchar;
+
+         (* Some formats record a relocation addend in the section contents
+            rather than with the relocation.  For ELF formats this is the
+            distinction between USE_REL and USE_RELA (though the code checks
+            for USE_REL == 1/0).  The value of this field is TRUE if the
+            addend is recorded with the section contents; when performing a
+            partial link (ld -r) the section contents (the data) will be
+            modified.  The value of this field is FALSE if addends are
+            recorded with the relocation (in arelent.addend); when performing
+            a partial link the relocation will be modified.
+            All relocations for all ELF USE_RELA targets should set this field
+            to FALSE (values of TRUE should be looked on with suspicion).
+            However, the converse is not true: not all relocations of all ELF
+            USE_REL targets set this field to TRUE.  Why this is so is peculiar
+            to each particular target.  For relocs that aren't used in partial
+            links (e.g. GOT stuff) it doesn't matter what this is set to.  *)
+    partial_inplace: bfd_boolean;
+
+         (* The src_mask selects which parts of the read in data
+            are to be used in the relocation sum.  E.g., if this was an 8 bit
+            byte of data which we read and relocated, this would be
+            $000000ff. When we have relocs which have an addend, such as
+            sun4 extended relocs, the value in the offset part of a
+            relocating field is garbage so we never use it. In this case
+            the mask would be $00000000. *)
+    src_mask: bfd_vma;
+
+         (* The dst_mask selects which parts of the instruction are replaced
+            into the instruction. In most cases src_mask == dst_mask,
+            except in the above special case, where dst_mask would be
+            $000000ff, and src_mask would be $00000000.   *)
+    dst_mask: bfd_vma;
+
+         (* When some formats create PC relative instructions, they leave
+            the value of the pc of the place being relocated in the offset
+            slot of the instruction, so that a PC relative relocation can
+            be made just by adding in an ordinary offset (e.g., sun3 a.out).
+            Some formats leave the displacement part of an instruction
+            empty (e.g., m88k bcs); this flag signals the fact.*)
+    pcrel_offset: bfd_boolean;
+
+  end; { reloc_howto }
+
+  bfd_arch_info = record
+    bits_per_word: integer;
+    bits_per_address: integer;
+    bits_per_byte: integer;
+    arch: bfd_architecture;
+    mach: LongWord;
+    arch_name: pchar;
+    printable_name: pchar;
+    section_align_power: LongWord;
+    (* True if this is the default machine for the architecture.  *)
+    the_default: bfd_boolean;
+
+    compatible: function(a: Pbfd_arch_info; b: Pbfd_arch_info):Pbfd_arch_info;cdecl;
+    scan: function(a: Pbfd_arch_info; b: pchar): bfd_boolean;cdecl;
+
+    next: Pbfd_arch_info;
+  end; { bfd_arch_info }
+
+  reloc_cache_entry = record
+         (* A pointer into the canonical table of pointers  *)
+    sym_ptr_ptr: Psymbol_cache_entry;
+
+         (* offset in section *)
+    address: bfd_size_type;
+
+         (* addend for relocation value *)
+    addend: bfd_vma;
+
+         (* Pointer to how to perform the required relocation *)
+    howto: reloc_howto;
+  end; { reloc_cache_entry }
+  arelent = reloc_cache_entry;
+
+
+(* This structure is used for a comdat section, as in PE.  A comdat
+   section is associated with a particular symbol.  When the linker
+   sees a comdat section, it keeps only one of the sections with a
+   given name and associated with a given symbol.  *)
+
+   bfd_comdat_info = record
+    (* The name of the symbol associated with a comdat section.  *)
+      name: pchar;
+
+    (* The local symbol table index of the symbol associated with a
+       comdat section.  This is only meaningful to the object file format
+       specific code; it is not an index into the list returned by
+       bfd_canonicalize_symtab.  *)
+    symbol: LongInt;
+  end; { bfd_comdat_info }
+
+  relent_chain = record
+    relent: arelent;
+    next: Prelent_chain;
+  end;
+  arelent_chain = relent_chain;
+
+  bfd_error = (
+    bfd_error_no_error {$ifndef Ver1_0} = 0 {$endif},
+    bfd_error_system_call,
+    bfd_error_invalid_target,
+    bfd_error_wrong_format,
+    bfd_error_invalid_operation,
+    bfd_error_no_memory,
+    bfd_error_no_symbols,
+    bfd_error_no_armap,
+    bfd_error_no_more_archived_files,
+    bfd_error_malformed_archive,
+    bfd_error_file_not_recognized,
+    bfd_error_file_ambiguously_recognized,
+    bfd_error_no_contents,
+    bfd_error_nonrepresentable_section,
+    bfd_error_no_debug_section,
+    bfd_error_bad_value,
+    bfd_error_file_truncated,
+    bfd_error_file_too_big,
+    bfd_error_invalid_error_code
+  ); { bfd_error }
+
+const
+  BFD_NO_MORE_SYMBOLS: symindex = not symindex(0);
+
+  bfd_mach_m68000 = 1;
+  bfd_mach_m68008 = 2;
+  bfd_mach_m68010 = 3;
+  bfd_mach_m68020 = 4;
+  bfd_mach_m68030 = 5;
+  bfd_mach_m68040 = 6;
+  bfd_mach_m68060 = 7;
+  bfd_mach_cpu32  = 8;
+  bfd_mach_i960_core      = 1;
+  bfd_mach_i960_ka_sa     = 2;
+  bfd_mach_i960_kb_sb     = 3;
+  bfd_mach_i960_mc        = 4;
+  bfd_mach_i960_xa        = 5;
+  bfd_mach_i960_ca        = 6;
+  bfd_mach_i960_jx        = 7;
+  bfd_mach_i960_hx        = 8;
+  bfd_mach_sparc                 = 1;
+  bfd_mach_sparc_sparclet        = 2;
+  bfd_mach_sparc_sparclite       = 3;
+  bfd_mach_sparc_v8plus          = 4;
+  bfd_mach_sparc_v8plusa         = 5 (* with ultrasparc add'ns *);
+  bfd_mach_sparc_sparclite_le    = 6;
+  bfd_mach_sparc_v9              = 7;
+  bfd_mach_sparc_v9a             = 8 (* with ultrasparc add'ns *);
+  bfd_mach_sparc_v8plusb         = 9 (* with cheetah add'ns *);
+  bfd_mach_sparc_v9b             = 10 (* with cheetah add'ns *);
+  bfd_mach_mips3000              = 3000;
+  bfd_mach_mips3900              = 3900;
+  bfd_mach_mips4000              = 4000;
+  bfd_mach_mips4010              = 4010;
+  bfd_mach_mips4100              = 4100;
+  bfd_mach_mips4111              = 4111;
+  bfd_mach_mips4300              = 4300;
+  bfd_mach_mips4400              = 4400;
+  bfd_mach_mips4600              = 4600;
+  bfd_mach_mips4650              = 4650;
+  bfd_mach_mips5000              = 5000;
+  bfd_mach_mips6000              = 6000;
+  bfd_mach_mips8000              = 8000;
+  bfd_mach_mips10000             = 10000;
+  bfd_mach_mips16                = 16;
+  bfd_mach_mips32                = 32;
+  bfd_mach_mips32_4k             = 3204113 (* 32, 04, octal 'K' *);
+  bfd_mach_mips5                 = 5;
+  bfd_mach_mips64                = 64;
+  bfd_mach_mips_sb1              = 12310201 (* octal 'SB', 01 *);
+  bfd_mach_i386_i386 = 0;
+  bfd_mach_i386_i8086 = 1;
+  bfd_mach_i386_i386_intel_syntax = 2;
+  bfd_mach_x86_64 = 3;
+  bfd_mach_x86_64_intel_syntax = 4;
+  bfd_mach_h8300   = 1;
+  bfd_mach_h8300h  = 2;
+  bfd_mach_h8300s  = 3;
+  bfd_mach_ppc           = 0;
+  bfd_mach_ppc_403       = 403;
+  bfd_mach_ppc_403gc     = 4030;
+  bfd_mach_ppc_505       = 505;
+  bfd_mach_ppc_601       = 601;
+  bfd_mach_ppc_602       = 602;
+  bfd_mach_ppc_603       = 603;
+  bfd_mach_ppc_ec603e    = 6031;
+  bfd_mach_ppc_604       = 604;
+  bfd_mach_ppc_620       = 620;
+  bfd_mach_ppc_630       = 630;
+  bfd_mach_ppc_750       = 750;
+  bfd_mach_ppc_860       = 860;
+  bfd_mach_ppc_a35       = 35;
+  bfd_mach_ppc_rs64ii    = 642;
+  bfd_mach_ppc_rs64iii   = 643;
+  bfd_mach_ppc_7400      = 7400;
+  bfd_mach_rs6k          = 0;
+  bfd_mach_rs6k_rs1      = 6001;
+  bfd_mach_rs6k_rsc      = 6003;
+  bfd_mach_rs6k_rs2      = 6002;
+  bfd_mach_d10v          = 0;
+  bfd_mach_d10v_ts2      = 2;
+  bfd_mach_d10v_ts3      = 3;
+  bfd_mach_z8001         = 1;
+  bfd_mach_z8002         = 2;
+  bfd_mach_sh            = 0;
+  bfd_mach_sh2        = $20;
+  bfd_mach_sh_dsp     = $2d;
+  bfd_mach_sh3        = $30;
+  bfd_mach_sh3_dsp    = $3d;
+  bfd_mach_sh3e       = $3e;
+  bfd_mach_sh4        = $40;
+  bfd_mach_alpha_ev4  = $10;
+  bfd_mach_alpha_ev5  = $20;
+  bfd_mach_alpha_ev6  = $30;
+  bfd_mach_arm_2         = 1;
+  bfd_mach_arm_2a        = 2;
+  bfd_mach_arm_3         = 3;
+  bfd_mach_arm_3M        = 4;
+  bfd_mach_arm_4         = 5;
+  bfd_mach_arm_4T        = 6;
+  bfd_mach_arm_5         = 7;
+  bfd_mach_arm_5T        = 8;
+  bfd_mach_arm_5TE       = 9;
+  bfd_mach_arm_XScale    = 10;
+  bfd_mach_v850          = 0;
+  bfd_mach_v850e         = ord('E');
+  bfd_mach_v850ea        = ord('A');
+  bfd_mach_arc_5         = 0;
+  bfd_mach_arc_6         = 1;
+  bfd_mach_arc_7         = 2;
+  bfd_mach_arc_8         = 3;
+  bfd_mach_m32r          = 0 (* backwards compatibility *);
+  bfd_mach_m32rx         = ord('x');
+  bfd_mach_mn10300       = 300;
+  bfd_mach_am33          = 330;
+  bfd_mach_fr30          = $46523330;
+  bfd_mach_ia64_elf64    = 0;
+  bfd_mach_ia64_elf32    = 1;
+  bfd_mach_avr1          = 1;
+  bfd_mach_avr2          = 2;
+  bfd_mach_avr3          = 3;
+  bfd_mach_avr4          = 4;
+  bfd_mach_avr5          = 5;
+
+
+  BFD_RELOC_SPARC_64 = BFD_RELOC_64;
+  BFD_RELOC_SPARC_DISP64 = BFD_RELOC_64_PCREL;
+  BFD_RELOC_MIPS_GPREL = BFD_RELOC_GPREL16;
+  BFD_RELOC_MIPS_GPREL32 = BFD_RELOC_GPREL32;
+
+
+  SEC_NO_FLAGS   = $000;
+
+  (* Tells the OS to allocate space for this section when loading.
+     This is clear for a section containing debug information only.  *)
+  SEC_ALLOC      = $001;
+
+  (* Tells the OS to load the section from the file when loading.
+     This is clear for a .bss section.  *)
+  SEC_LOAD       = $002;
+
+  (* The section contains data still to be relocated, so there is
+     some relocation information too.  *)
+  SEC_RELOC      = $004;
+
+{  (* Obsolete ? *)
+  SEC_BALIGN     = $008;
+}
+
+  (* A signal to the OS that the section contains read only data.  *)
+  SEC_READONLY   = $010;
+
+  (* The section contains code only.  *)
+  SEC_CODE       = $020;
+
+  (* The section contains data only.  *)
+  SEC_DATA       = $040;
+
+  (* The section will reside in ROM.  *)
+  SEC_ROM        = $080;
+
+  (* The section contains constructor information. This section
+     type is used by the linker to create lists of constructors and
+     destructors used by <<g++>>. When a back end sees a symbol
+     which should be used in a constructor list, it creates a new
+     section for the type of name (e.g., <<__CTOR_LIST__>>), attaches
+     the symbol to it, and builds a relocation. To build the lists
+     of constructors, all the linker has to do is catenate all the
+     sections called <<__CTOR_LIST__>> and relocate the data
+     contained within - exactly the operations it would peform on
+     standard data.  *)
+  SEC_CONSTRUCTOR = $100;
+
+  (* The section is a constructor, and should be placed at the
+     end of the text, data, or bss section(?).  *)
+  SEC_CONSTRUCTOR_TEXT = $1100;
+  SEC_CONSTRUCTOR_DATA = $2100;
+  SEC_CONSTRUCTOR_BSS  = $3100;
+
+  (* The section has contents - a data section could be
+     <<SEC_ALLOC>> | <<SEC_HAS_CONTENTS>>; a debug section could be
+     <<SEC_HAS_CONTENTS>>  *)
+  SEC_HAS_CONTENTS = $200;
+
+  (* An instruction to the linker to not output the section
+     even if it has information which would normally be written.  *)
+  SEC_NEVER_LOAD = $400;
+
+  (* The section is a COFF shared library section.  This flag is
+     only for the linker.  If this type of section appears in
+     the input file, the linker must copy it to the output file
+     without changing the vma or size.  FIXME: Although this
+     was originally intended to be general, it really is COFF
+     specific (and the flag was renamed to indicate this).  It
+     might be cleaner to have some more general mechanism to
+     allow the back end to control what the linker does with
+     sections.  *)
+  SEC_COFF_SHARED_LIBRARY = $800;
+
+  (* The section has GOT references.  This flag is only for the
+     linker, and is currently only used by the elf32-1 back end.
+     It will be set if global offset table references were detected
+     in this section, which indicate to the linker that the section
+     contains PIC code, and must be handled specially when doing a
+     static link.  *)
+  SEC_HAS_GOT_REF = $4000;
+
+  (* The section contains common symbols (symbols may be defined
+     multiple times, the value of a symbol is the amount of
+     space it requires, and the largest symbol value is the one
+     used).  Most targets have exactly one of these (which we
+     translate to bfd_com_section_ptr), but ECOFF has two.  *)
+  SEC_IS_COMMON = $8000;
+
+  (* The section contains only debugging information.  For
+     example, this is set for ELF .debug and .stab sections.
+     strip tests this flag to see if a section can be
+     discarded.  *)
+  SEC_DEBUGGING = $10000;
+
+  (* The contents of this section are held in memory pointed to
+     by the contents field.  This is checked by bfd_get_section_contents,
+     and the data is retrieved from memory if appropriate.  *)
+  SEC_IN_MEMORY = $20000;
+
+  (* The contents of this section are to be excluded by the
+     linker for executable and shared objects unless those
+     objects are to be further relocated.  *)
+  SEC_EXCLUDE = $40000;
+
+  (* The contents of this section are to be sorted by the
+     based on the address specified in the associated symbol
+     table.  *)
+  SEC_SORT_ENTRIES = $80000;
+
+  (* When linking, duplicate sections of the same name should be
+     discarded, rather than being combined into a single section as
+     is usually done.  This is similar to how common symbols are
+     handled.  See SEC_LINK_DUPLICATES below.  *)
+  SEC_LINK_ONCE = $100000;
+
+  (* If SEC_LINK_ONCE is set, this bitfield describes how the linker
+     should handle duplicate sections.  *)
+  SEC_LINK_DUPLICATES = $600000;
+
+  (* This value for SEC_LINK_DUPLICATES means that duplicate
+     sections with the same name should simply be discarded.  *)
+  SEC_LINK_DUPLICATES_DISCARD = $0;
+
+  (* This value for SEC_LINK_DUPLICATES means that the linker
+     should warn if there are any duplicate sections, although
+     it should still only link one copy.  *)
+  SEC_LINK_DUPLICATES_ONE_ONLY = $200000;
+
+  (* This value for SEC_LINK_DUPLICATES means that the linker
+     should warn if any duplicate sections are a different size.  *)
+  SEC_LINK_DUPLICATES_SAME_SIZE = $400000;
+
+  (* This value for SEC_LINK_DUPLICATES means that the linker
+     should warn if any duplicate sections contain different
+     contents.  *)
+  SEC_LINK_DUPLICATES_SAME_CONTENTS = $600000;
+
+  (* This section was created by the linker as part of dynamic
+     relocation or other arcane processing.  It is skipped when
+     going through the first-pass output, trusting that someone
+     else up the line will take care of it later.  *)
+  SEC_LINKER_CREATED = $800000;
+
+  (* This section should not be subject to garbage collection.  *)
+  SEC_KEEP = $1000000;
+
+  (* This section contains "SmallInt" data, and should be placed
+     "near" the GP.  *)
+  SEC_SMALL_DATA = $2000000;
+
+  (* This section contains data which may be shared with other
+     executables or shared objects.  *)
+  SEC_SHARED = $4000000;
+
+  (* When a section with this flag is being linked, then if the size of
+     the input section is less than a page, it should not cross a page
+     boundary.  If the size of the input section is one page or more, it
+     should be aligned on a page boundary.  *)
+  SEC_BLOCK = $8000000;
+
+  (* Conditionally link this section; do not link if there are no
+     references found to any symbol in the section.  *)
+  SEC_CLINK = $10000000;
+
+  (*  End of section flags.  *)
+
+
+ (* Attributes of a symbol: *)
+
+  BSF_NO_FLAGS    = $00;
+
+       (* The symbol has local scope; <<static>> in <<C>>. The value
+          is the offset into the section of the data. *)
+  BSF_LOCAL      = $01;
+
+       (* The symbol has global scope; initialized data in <<C>>. The
+          value is the offset into the section of the data. *)
+  BSF_GLOBAL     = $02;
+
+       (* The symbol has global scope and is exported. The value is
+          the offset into the section of the data. *)
+  BSF_EXPORT     = BSF_GLOBAL (* no real difference *);
+
+       (* A normal C symbol would be one of:
+          <<BSF_LOCAL>>, <<BSF_FORT_COMM>>,  <<BSF_UNDEFINED>> or
+          <<BSF_GLOBAL>> *)
+
+       (* The symbol is a debugging record. The value has an arbitary
+          meaning, unless BSF_DEBUGGING_RELOC is also set.  *)
+  BSF_DEBUGGING  = $08;
+
+       (* The symbol denotes a function entry point.  Used in ELF,
+          perhaps others someday.  *)
+  BSF_FUNCTION    = $10;
+
+       (* Used by the linker. *)
+  BSF_KEEP        = $20;
+  BSF_KEEP_G      = $40;
+
+       (* A weak global symbol, overridable without warnings by
+          a regular global symbol of the same name.  *)
+  BSF_WEAK        = $80;
+
+       (* This symbol was created to point to a section, e.g. ELF's
+          STT_SECTION symbols.  *)
+  BSF_SECTION_SYM = $100;
+
+       (* The symbol used to be a common symbol, but now it is
+          allocated. *)
+  BSF_OLD_COMMON  = $200;
+
+       (* The default value for common data. *)
+  BFD_FORT_COMM_DEFAULT_VALUE = 0;
+
+       (* In some files the type of a symbol sometimes alters its
+          location in an output file - ie in coff a <<ISFCN>> symbol
+          which is also <<C_EXT>> symbol appears where it was
+          declared and not at the end of a section.  This bit is set
+          by the target BFD part to convey this information. *)
+
+  BSF_NOT_AT_END    = $400;
+
+       (* Signal that the symbol is the label of constructor section. *)
+  BSF_CONSTRUCTOR   = $800;
+
+       (* Signal that the symbol is a warning symbol.  The name is a
+          warning.  The name of the next symbol is the one to warn about;
+          if a reference is made to a symbol with the same name as the next
+          symbol, a warning is issued by the linker. *)
+  BSF_WARNING       = $1000;
+
+       (* Signal that the symbol is indirect.  This symbol is an indirect
+          pointer to the symbol with the same name as the next symbol. *)
+  BSF_INDIRECT      = $2000;
+
+       (* BSF_FILE marks symbols that contain a file name.  This is used
+          for ELF STT_FILE symbols.  *)
+  BSF_FILE          = $4000;
+
+       (* Symbol is from dynamic linking information.  *)
+  BSF_DYNAMIC       = $8000;
+
+       (* The symbol denotes a data object.  Used in ELF, and perhaps
+          others someday.  *)
+  BSF_OBJECT        = $10000;
+
+       (* This symbol is a debugging symbol.  The value is the offset
+          into the section of the data.  BSF_DEBUGGING should be set
+          as well.  *)
+  BSF_DEBUGGING_RELOC = $20000;
+
+
+(* User program access to BFD facilities *)
+
+(* Direct I/O routines, for programs which know more about the object
+   file than BFD does.  Use higher level routines if possible.  *)
+
+function bfd_read  (var data; size: bfd_size_type; nitems: bfd_size_type; abfd: PBFD): bfd_size_type;cdecl;
+function bfd_write (const data; size: bfd_size_type; nitems: bfd_size_type; abfd: PBFD): bfd_size_type;cdecl;
+function bfd_seek  (abfd: PBFD; fp: file_ptr; direction: integer): integer;cdecl;
+function bfd_tell  (abfd: PBFD): LongInt;cdecl;
+function bfd_flush (abfd: PBFD): integer;cdecl;
+function bfd_stat  (abfd: PBFD; a: Pstat): integer;cdecl;
+
+(* Cast from const pchar to pchar so that caller can assign to
+   a pchar without a warning.  *)
+
+function bfd_get_filename(abfd: PBFD): pchar;
+
+function bfd_record_phdr(abfd: PBFD; a: LongWord; b: bfd_boolean; c: flagword; d: bfd_boolean; e: bfd_vma;
+	   f: bfd_boolean; g: bfd_boolean; h: LongWord; i: PPsec):bfd_boolean;cdecl;
+
+(* Byte swapping routines.  *)
+
+function bfd_getb64	    (const val):bfd_vma;cdecl;
+function bfd_getl64	    (const val):bfd_vma;cdecl;
+function bfd_getb_signed_64 (const val):bfd_signed_vma;cdecl;
+function bfd_getl_signed_64 (const val):bfd_signed_vma;cdecl;
+function bfd_getb32	    (const val):bfd_vma;cdecl;
+function bfd_getl32	    (const val):bfd_vma;cdecl;
+function bfd_getb_signed_32 (const val):bfd_signed_vma;cdecl;
+function bfd_getl_signed_32 (const val):bfd_signed_vma;cdecl;
+function bfd_getb16	    (const val):bfd_vma;cdecl;
+function bfd_getl16	    (const val):bfd_vma;cdecl;
+function bfd_getb_signed_16 (const val):bfd_signed_vma;cdecl;
+function bfd_getl_signed_16 (const val):bfd_signed_vma;cdecl;
+procedure bfd_putb64(vma: bfd_vma; var val);cdecl;
+procedure bfd_putl64(vma: bfd_vma; var val);cdecl;
+procedure bfd_putb32(vma: bfd_vma; var val);cdecl;
+procedure bfd_putl32(vma: bfd_vma; var val);cdecl;
+procedure bfd_putb16(vma: bfd_vma; var val);cdecl;
+procedure bfd_putl16(vma: bfd_vma; var val);cdecl;
+
+(* Byte swapping routines which take size and endiannes as arguments.  *)
+
+function  bfd_get_bits (a: Pbfd_byte; b:integer; c: bfd_boolean): bfd_vma;cdecl;
+procedure bfd_put_bits (a: bfd_vma; b:Pbfd_byte; c:integer; d:bfd_boolean);cdecl;
+
+(* Externally visible ECOFF routines.  *)
+
+type
+  Pecoff_debug_info  = pointer;
+  Pecoff_debug_swap  = pointer;
+
+function bfd_ecoff_get_gp_value(abfd: PBFD ):bfd_vma;cdecl;
+function bfd_ecoff_set_gp_value(abfd: PBFD; gp_value: bfd_vma):bfd_boolean ;cdecl;
+function bfd_ecoff_set_regmasks(abfd: PBFD; gprmask: LongWord; fprmask: LongWord;cprmask: PLongWord):bfd_boolean;cdecl;
+function bfd_ecoff_debug_init(output_bfd: PBFD; output_debug: Pecoff_debug_info; output_swap: Pecoff_debug_swap; li: Pbfd_link_info):pointer;cdecl;
+procedure bfd_ecoff_debug_free(handle: pointer; output_bfd: PBFD; output_debug: Pecoff_debug_info; output_swap: Pecoff_debug_swap;li: Pbfd_link_info);cdecl;
+function bfd_ecoff_debug_accumulate(
+           handle: pointer; output_bfd: PBFD; output_debug: Pecoff_debug_info;
+	   output_swap: Pecoff_debug_swap;
+	   input_bfd: PBFD; input_debug: Pecoff_debug_info;
+	   input_swap: Pecoff_debug_swap;
+           li: Pbfd_link_info):bfd_boolean ;cdecl;
+
+(*todo: function bfd_ecoff_debug_accumulate_other(
+           pointer handle;
+           PBFD output_bfd;
+           Pecoff_debug_info output_debug;
+	   Pecoff_debug_swap output_swap;
+           PBFD input_bfd;
+	   li: Pbfd_link_info
+           ):bfd_boolean ;cdecl;
+*)
+
+(*todo: function bfd_ecoff_debug_externals(
+           PBFD abfd;
+           Pecoff_debug_info debug;
+	   Pecoff_debug_swap swap;
+	   bfd_boolean relocateable;
+	   bfd_boolean ( *get_extr) (struct symbol_cache_entry *;
+				struct ecoff_extr * );
+	   void ( *set_index) (struct symbol_cache_entry *;
+			      bfd_size_type)
+           ):bfd_boolean ;cdecl;
+*)
+
+(*todo: function bfd_ecoff_debug_one_external(
+           PBFD abfd,
+           Pecoff_debug_info debug,
+	   Pecoff_debug_swap swap,
+	   const ShortInt *name,
+           struct ecoff_extr *esym
+           ):bfd_boolean ;cdecl;
+*)
+
+(*todo: function bfd_ecoff_debug_size(
+           PBFD abfd,
+           Pecoff_debug_info debug,
+	   Pecoff_debug_swap swap
+           ):bfd_size_type;cdecl;
+*)
+
+(*todo: function bfd_ecoff_write_debug(
+           PBFD abfd,
+           Pecoff_debug_info debug,
+	   Pecoff_debug_swap swap,
+           file_ptr where
+           ):bfd_boolean;cdecl;
+*)
+
+(*todo: function bfd_ecoff_write_accumulated_debug(
+           pointer handle,
+           PBFD abfd,
+           Pecoff_debug_info debug,
+	   Pecoff_debug_swap swa,
+	   struct bfd_link_info *info, file_ptr where)
+           ):bfd_boolean;cdecl;
+*)
+
+(*todo: function bfd_mips_ecoff_create_embedded_relocs(
+           PBFD ,
+           struct bfd_link_info *,
+           struct sec *,
+           struct sec *,
+	   pchar*
+           ):bfd_boolean;cdecl;
+*)
+
+(* Externally visible ELF routines.  *)
+
+//todo:function bfd_elf32_record_link_assignment(PBFD ; struct bfd_link_info *; const pchar; bfd_boolean):bfd_boolean;cdecl;
+//todo:function bfd_elf64_record_link_assignment(PBFD ; struct bfd_link_info *; const pchar; bfd_boolean):bfd_boolean;cdecl;
+//todo:function bfd_link_needed_list *bfd_elf_get_needed_list(PBFD ; struct bfd_link_info *):struct;cdecl;
+//todo:function bfd_elf_get_bfd_needed_list(PBFD ; struct bfd_link_needed_list **):bfd_boolean;cdecl;
+//todo:function bfd_elf32_size_dynamic_sections (PBFD ; const pchar; const pchar; bfd_boolean; const pchar;	 const pchar const *; struct bfd_link_info *; struct sec **;	 struct bfd_elf_version_tree *):bfd_boolean;cdecl;
+//todo:function bfd_elf64_size_dynamic_sections (PBFD ; const pchar; const pchar; bfd_boolean; const pchar;	 const pchar const *; struct bfd_link_info *; struct sec **;	 struct bfd_elf_version_tree *):bfd_boolean;cdecl;
+//todo:function bfd_elf_set_dt_needed_name(PBFD ; const pchar):void;cdecl;
+//todo:function bfd_elf_set_dt_needed_soname(PBFD ; const pchar):void;cdecl;
+//todo:function const ShortInt *bfd_elf_get_dt_soname (PBFD );cdecl;
+//todo:function struct bfd_link_needed_list *bfd_elf_get_runpath_list (PBFD ; struct bfd_link_info *);cdecl;
+
+(* Return an upper bound on the number of bytes required to store a
+   copy of ABFD's program header table entries.  Return -1 if an error
+   occurs; bfd_get_error will return an appropriate code.  *)
+//todo:function bfd_get_elf_phdr_upper_bound(PBFD abfd):LongInt;cdecl;
+
+(* Copy ABFD's program header table entries to *PHDRS.  The entries
+   will be stored as an array of Elf_Internal_Phdr structures, as
+   defined in include/elf/internal.h.  To find out how large the
+   buffer needs to be, call bfd_get_elf_phdr_upper_bound.
+
+   Return the number of program header table entries read, or -1 if an
+   error occurs; bfd_get_error will return an appropriate code.  *)
+//todo:function bfd_get_elf_phdrs(PBFD abfd, void *phdrs):integer;cdecl;
+
+(* Return the arch_size field of an elf bfd, or -1 if not elf.  *)
+//todo:function bfd_get_arch_size(PBFD  ):integer;cdecl;
+
+(* Return true if address "naturally" sign extends, or -1 if not elf.  *)
+//todo:function bfd_get_sign_extend_vma(PBFD  ):integer;cdecl;
+
+//todo:function bfd_m68k_elf32_create_embedded_relocs(PBFD , struct bfd_link_info *, struct sec *, struct sec *,	   pchar*):bfd_boolean;cdecl;
+
+(* SunOS shared library support routines for the linker.  *)
+
+//todo:function *bfd_sunos_get_needed_list(PBFD , struct bfd_link_info *):bfd_link_needed_list;cdecl;
+//todo:function bfd_sunos_record_link_assignment(PBFD , struct bfd_link_info *, const pchar):bfd_boolean;cdecl;
+//todo:function bfd_sunos_size_dynamic_sections (PBFD , struct bfd_link_info *, struct sec **, struct sec **, struct sec **):bfd_boolean;cdecl;
+
+(* Linux shared library support routines for the linker.  *)
+
+//todo:function bfd_i386linux_size_dynamic_sections(PBFD , struct bfd_link_info *):bfd_boolean;cdecl;
+//todo:function bfd_m68klinux_size_dynamic_sections(PBFD , struct bfd_link_info *):bfd_boolean;cdecl;
+//todo:function bfd_sparclinux_size_dynamic_sections(PBFD , struct bfd_link_info *):bfd_boolean;cdecl;
+
+//todo:function bfd_init_window(bfd_window *):void;cdecl;
+//todo:function bfd_free_window(bfd_window *):void;cdecl;
+//todo:function bfd_get_file_window(PBFD , file_ptr, bfd_size_type, bfd_window *, bfd_boolean):bfd_boolean;cdecl;
+
+(* XCOFF support routines for the linker.  *)
+//todo:function bfd_boolean bfd_xcoff_link_record_set (PBFD , struct bfd_link_info *, struct bfd_link_hash_entry *,	   bfd_size_type));cdecl;
+//todo:function bfd_boolean bfd_xcoff_import_symbol (PBFD , struct bfd_link_info *, struct bfd_link_hash_entry *,	   bfd_vma, const pchar, const pchar, const pchar));cdecl;
+//todo:function bfd_boolean bfd_xcoff_export_symbol  (PBFD , struct bfd_link_info *, struct bfd_link_hash_entry *,	   bfd_boolean));cdecl;
+//todo:function bfd_boolean bfd_xcoff_link_count_reloc  (PBFD , struct bfd_link_info *, const pchar));cdecl;
+//todo:function bfd_boolean bfd_xcoff_record_link_assignment  (PBFD , struct bfd_link_info *, const pchar));cdecl;
+//todo:function bfd_boolean bfd_xcoff_size_dynamic_sections  (PBFD , struct bfd_link_info *, const pchar, const pchar,	   LongWord, LongWord, LongWord, bfd_boolean,	   integer, bfd_boolean, bfd_boolean, struct sec **));cdecl;
+
+(* Externally visible COFF routines.  *)
+
+//todo:function bfd_boolean bfd_coff_get_syment (PBFD , struct symbol_cache_entry *, struct internal_syment *));cdecl;
+//todo:function bfd_boolean bfd_coff_get_auxent (PBFD , struct symbol_cache_entry *, integer, union internal_auxent *));cdecl;
+//todo:function bfd_boolean bfd_coff_set_symbol_class (PBFD , struct symbol_cache_entry *, LongWord));cdecl;
+//todo:function bfd_boolean bfd_m68k_coff_create_embedded_relocs (PBFD , struct bfd_link_info *, struct sec *, struct sec *,	   pchar*));cdecl;
+
+(* ARM Interworking support.  Called from linker.  *)
+//todo:function bfd_boolean bfd_arm_allocate_interworking_sections (struct bfd_link_info *));cdecl;
+//todo:function bfd_boolean bfd_arm_process_before_allocation (PBFD , struct bfd_link_info *, integer));cdecl;
+//todo:function bfd_boolean bfd_arm_get_bfd_for_interworking  (PBFD , struct bfd_link_info *));cdecl;
+
+(* PE ARM Interworking support.  Called from linker.  *)
+//todo:function bfd_boolean bfd_arm_pe_allocate_interworking_sections  (struct bfd_link_info *));cdecl;
+//todo:function bfd_boolean bfd_arm_pe_process_before_allocation (PBFD , struct bfd_link_info *, integer));cdecl;
+//todo:function bfd_boolean bfd_arm_pe_get_bfd_for_interworking   (PBFD , struct bfd_link_info *));cdecl;
+
+(* ELF ARM Interworking support.  Called from linker.  *)
+//todo:function bfd_boolean bfd_elf32_arm_allocate_interworking_sections  (struct bfd_link_info *));cdecl;
+//todo:function bfd_boolean bfd_elf32_arm_process_before_allocation  (PBFD , struct bfd_link_info *, integer));cdecl;
+//todo:function bfd_boolean bfd_elf32_arm_get_bfd_for_interworking (PBFD , struct bfd_link_info *));cdecl;
+
+(* TI COFF load page support.  *)
+//todo:function void bfd_ticoff_set_section_load_page (struct sec *, integer));cdecl;
+//todo:function integer bfd_ticoff_get_section_load_page  (struct sec *));cdecl;
+
+(* And more from the source.  *)
+procedure bfd_init;cdecl;
+function bfd_openr( filename: pchar ;  target: pchar ):PBFD;cdecl;
+function bfd_fdopenr( filename: pchar ;  target: pchar ; fd: integer):PBFD;cdecl;
+function bfd_openstreamr(a: pchar; b: pchar; c: pointer):PBFD;cdecl;
+function bfd_openw( filename: pchar ;  target: pchar):PBFD;cdecl;
+function bfd_close(abfd: PBFD):bfd_boolean;cdecl;
+function bfd_close_all_done(abfd: PBFD  ):bfd_boolean;cdecl;
+function bfd_create( filename: pchar ; templ: PBFD):PBFD;cdecl;
+function bfd_make_writable(abfd: PBFD ):bfd_boolean;cdecl;
+function bfd_make_readable(abfd: PBFD ):bfd_boolean;cdecl;
+
+(* General purpose part of a symbol X;
+   target specific parts are in libcoff.h, libaout.h, etc.  *)
+
+//todo:#define bfd_get_section(x) ((x)->section)
+//todo:#define bfd_get_output_section(x) ((x)->section->output_section)
+//todo:#define bfd_set_section(x,y) ((x)->section) = (y)
+//todo:#define bfd_asymbol_base(x) ((x)->section->vma)
+//todo:#define bfd_asymbol_value(x) (bfd_asymbol_base(x) + (x)->value)
+//todo:#define bfd_asymbol_name(x) ((x)->name)
+(*Perhaps future: #define bfd_asymbol_bfd(x) ((x)->section->owner)*)
+//todo:#define bfd_asymbol_bfd(x) ((x)->the_bfd)
+//todo:#define bfd_asymbol_flavour(x) (bfd_asymbol_bfd(x)->xvec->flavour)
+
+//todo:#define	align_power(addr, align) ((addr) + ((1<<(align))-1)) & (-1 << (align)))
+//todo:#define bfd_get_section_name(bfd, ptr) ((ptr)->name + 0)
+//todo:#define bfd_get_section_vma(bfd, ptr) ((ptr)->vma + 0)
+//todo:#define bfd_get_section_alignment(bfd, ptr) ((ptr)->alignment_power + 0)
+//todo:#define bfd_section_name(bfd, ptr) ((ptr)->name)
+//todo:#define bfd_section_size(bfd, ptr) (bfd_get_section_size_before_reloc(ptr))
+//todo:#define bfd_section_vma(bfd, ptr) ((ptr)->vma)
+//todo:#define bfd_section_lma(bfd, ptr) ((ptr)->lma)
+//todo:#define bfd_section_alignment(bfd, ptr) ((ptr)->alignment_power)
+//todo:#define bfd_get_section_flags(bfd, ptr) ((ptr)->flags + 0)
+//todo:#define bfd_get_section_userdata(bfd, ptr) ((ptr)->userdata)
+//todo:#define bfd_is_com_section(ptr) (((ptr)->flags & SEC_IS_COMMON) != 0)
+//todo:#define bfd_set_section_vma(bfd, ptr, val) (((ptr)->vma = (ptr)->lma= (val)), ((ptr)->user_set_vma = (bfd_boolean)true), true)
+//todo:#define bfd_set_section_alignment(bfd, ptr, val) (((ptr)->alignment_power = (val)),true)
+//todo:#define bfd_set_section_userdata(bfd, ptr, val) (((ptr)->userdata = (val)),true)
+//todo:#define bfd_mach_sparc_v9_p(mach) ((mach) >= bfd_mach_sparc_v8plus && (mach) <= bfd_mach_sparc_v9b && (mach) != bfd_mach_sparc_sparclite_le)
+//todo:#define bfd_get_elt_at_index(b,i) BFD_SEND(b, _bfd_get_elt_at_index, (b,i))
+//todo:#define bfd_print_symbol(b,p,s,e) BFD_SEND(b, _bfd_print_symbol, (b,p,s,e))
+//todo:#define bfd_get_symbol_info(b,p,e) BFD_SEND(b, _bfd_get_symbol_info, (b,p,e))
+//todo:#define bfd_read_minisymbols(b, d, m, s)   BFD_SEND (b, _read_minisymbols, (b, d, m, s))
+//todo:#define bfd_minisymbol_to_symbol(b, d, m, f)   BFD_SEND (b, _minisymbol_to_symbol, (b, d, m, f))
+//todo:#define COFF_SWAP_TABLE (pointer) &bfd_coff_std_swap_table
+//todo:#define bfd_get_cacheable(abfd) ((abfd)->cacheable)
+//todo:#define bfd_get_format(abfd) ((abfd)->format)
+//todo:#define bfd_get_target(abfd) ((abfd)->xvec->name)
+//todo:#define bfd_get_flavour(abfd) ((abfd)->xvec->flavour)
+//todo:#define bfd_family_coff(abfd) (bfd_get_flavour (abfd) == bfd_target_coff_flavour || bfd_get_flavour (abfd) == bfd_target_xcoff_flavour)
+//todo:#define bfd_big_endian(abfd) ((abfd)->xvec->byteorder == BFD_ENDIAN_BIG)
+//todo:#define bfd_little_endian(abfd) ((abfd)->xvec->byteorder == BFD_ENDIAN_LITTLE)
+//todo:#define bfd_header_big_endian(abfd) ((abfd)->xvec->header_byteorder == BFD_ENDIAN_BIG)
+//todo:#define bfd_header_little_endian(abfd) ((abfd)->xvec->header_byteorder == BFD_ENDIAN_LITTLE)
+//todo:#define bfd_get_file_flags(abfd) ((abfd)->flags)
+//todo:#define bfd_applicable_file_flags(abfd) ((abfd)->xvec->object_flags)
+//todo:#define bfd_applicable_section_flags(abfd) ((abfd)->xvec->section_flags)
+//todo:#define bfd_my_archive(abfd) ((abfd)->my_archive)
+//todo:#define bfd_has_map(abfd) ((abfd)->has_armap)
+//todo:#define bfd_valid_reloc_types(abfd) ((abfd)->xvec->valid_reloc_types)
+//todo:#define bfd_usrdata(abfd) ((abfd)->usrdata)
+//todo:#define bfd_get_start_address(abfd) ((abfd)->start_address)
+//todo:#define bfd_get_symcount(abfd) ((abfd)->symcount)
+//todo:#define bfd_get_outsymbols(abfd) ((abfd)->outsymbols)
+//todo:#define bfd_count_sections(abfd) ((abfd)->section_count)
+//todo:#define bfd_get_symbol_leading_char(abfd) ((abfd)->xvec->symbol_leading_char)
+//todo:#define bfd_set_cacheable(abfd,bool) (((abfd)->cacheable = (bfd_boolean) (bool)), true)
+//todo:#define bfd_put_8(abfd, val, ptr)  ((void) (*((byte * ) (ptr)) = (Byte) (val)))
+//todo:#define bfd_put_signed_8  bfd_put_8
+//todo:#define bfd_get_8(abfd, ptr)  ( *(Byte * ) (ptr))
+//todo:#define bfd_get_signed_8(abfd, ptr)  (( *(byte * ) (ptr) ^ $80) - $80)
+
+//todo:#define bfd_put_16(abfd, val, ptr)  BFD_SEND(abfd, bfd_putx16, ((val),(ptr)))
+//todo:#define bfd_put_signed_16  bfd_put_16
+//todo:#define bfd_get_16(abfd, ptr)   BFD_SEND(abfd, bfd_getx16, (ptr))
+//todo:#define bfd_get_signed_16(abfd, ptr)  BFD_SEND (abfd, bfd_getx_signed_16, (ptr))
+
+//todo:#define bfd_put_32(abfd, val, ptr)    BFD_SEND(abfd, bfd_putx32, ((val),(ptr)))
+//todo:#define bfd_put_signed_32             bfd_put_32
+//todo:#define bfd_get_32(abfd, ptr)         BFD_SEND(abfd, bfd_getx32, (ptr))
+//todo:#define bfd_get_signed_32(abfd, ptr)  BFD_SEND(abfd, bfd_getx_signed_32, (ptr))
+
+//todo:#define bfd_put_64(abfd, val, ptr)   BFD_SEND(abfd, bfd_putx64, ((val), (ptr)))
+//todo:#define bfd_put_signed_64            bfd_put_64
+//todo:#define bfd_get_64(abfd, ptr)        BFD_SEND(abfd, bfd_getx64, (ptr))
+//todo:#define bfd_get_signed_64(abfd, ptr) BFD_SEND(abfd, bfd_getx_signed_64, (ptr))
+
+//todo:#define bfd_get(bits, abfd, ptr) ((bits) == 8 ? bfd_get_8 (abfd, ptr) : (bits) == 16 ? bfd_get_16 (abfd, ptr) : (bits) == 32 ? bfd_get_32 (abfd, ptr) : (bits) == 64 ? bfd_get_64 (abfd, ptr) : (abort (), (bfd_vma) - 1))
+//todo:#define bfd_put(bits, abfd, val, ptr) ((bits) == 8 ? bfd_put_8 (abfd, val, ptr) : (bits) == 16 ? bfd_put_16 (abfd, val, ptr) : (bits) == 32 ? bfd_put_32 (abfd, val, ptr) : (bits) == 64 ? bfd_put_64 (abfd, val, ptr) : (abort (), (void) 0))
+
+(* Byte swapping macros for file header data.  *)
+
+//todo:#define bfd_h_put_8(abfd, val, ptr)    bfd_put_8 (abfd, val, ptr)
+//todo:#define bfd_h_put_signed_8(abfd, val, ptr) bfd_put_8 (abfd, val, ptr)
+//todo:#define bfd_h_get_8(abfd, ptr)         bfd_get_8 (abfd, ptr)
+//todo:#define bfd_h_get_signed_8(abfd, ptr)  bfd_get_signed_8 (abfd, ptr)
+
+//todo:#define bfd_h_put_16(abfd, val, ptr)  BFD_SEND(abfd, bfd_h_putx16,(val,ptr))
+//todo:#define bfd_h_put_signed_16           bfd_h_put_16
+//todo:#define bfd_h_get_16(abfd, ptr)       BFD_SEND(abfd, bfd_h_getx16,(ptr))
+//todo:#define bfd_h_get_signed_16(abfd, ptr) BFD_SEND(abfd, bfd_h_getx_signed_16, (ptr))
+
+//todo:#define bfd_h_put_32(abfd, val, ptr)  BFD_SEND(abfd, bfd_h_putx32,(val,ptr))
+//todo:#define bfd_h_put_signed_32           bfd_h_put_32
+//todo:#define bfd_h_get_32(abfd, ptr)       BFD_SEND(abfd, bfd_h_getx32,(ptr))
+//todo:#define bfd_h_get_signed_32(abfd, ptr) BFD_SEND(abfd, bfd_h_getx_signed_32, (ptr))
+
+//todo:#define bfd_h_put_64(abfd, val, ptr) BFD_SEND(abfd, bfd_h_putx64,(val, ptr))
+//todo:#define bfd_h_put_signed_64          bfd_h_put_64
+//todo:#define bfd_h_get_64(abfd, ptr)      BFD_SEND(abfd, bfd_h_getx64,(ptr))
+//todo:#define bfd_h_get_signed_64(abfd, ptr) BFD_SEND(abfd, bfd_h_getx_signed_64, (ptr))
+
+(* These sections are global, and are managed by BFD.  The application
+   and target back end are not permitted to change the values in
+   these sections.  New code should use the section_ptr macros rather
+   than referring directly to the const sections.  The const sections
+   may eventually vanish.  *)
+const
+  BFD_ABS_SECTION_NAME = '*ABS*';
+  BFD_UND_SECTION_NAME = '*UND*';
+  BFD_COM_SECTION_NAME = '*COM*';
+  BFD_IND_SECTION_NAME = '*IND*';
+
+(* the absolute section *)
+//todo:_BFD_IMPORT function const asection bfd_abs_section;
+//todo:#define bfd_abs_section_ptr ((asection *) &bfd_abs_section)
+//todo:#define bfd_is_abs_section(sec) ((sec) == bfd_abs_section_ptr)
+(* Pointer to the undefined section *)
+//todo:_BFD_IMPORT function const asection bfd_und_section;
+//todo:#define bfd_und_section_ptr ((asection *) &bfd_und_section)
+//todo:#define bfd_is_und_section(sec) ((sec) == bfd_und_section_ptr)
+(* Pointer to the common section *)
+//todo:_BFD_IMPORT function const asection bfd_com_section;
+//todo:#define bfd_com_section_ptr ((asection *) &bfd_com_section)
+(* Pointer to the indirect section *)
+//todo:_BFD_IMPORT function const asection bfd_ind_section;
+//todo:#define bfd_ind_section_ptr ((asection *) &bfd_ind_section)
+//todo:#define bfd_is_ind_section(sec) ((sec) == bfd_ind_section_ptr)
+
+//todo:function const struct symbol_cache_entry * const bfd_abs_symbol;
+//todo:function const struct symbol_cache_entry * const bfd_com_symbol;
+//todo:function const struct symbol_cache_entry * const bfd_und_symbol;
+//todo:function const struct symbol_cache_entry * const bfd_ind_symbol;
+//todo:#define bfd_get_section_size_before_reloc(section) ((section)->reloc_done ? (abort (), (bfd_size_type) 1) : (section)->_raw_size)
+//todo:#define bfd_get_section_size_after_reloc(section)    ((section)->reloc_done ? (section)->_cooked_size : (abort (), (bfd_size_type) 1))
+//todo:asection * bfd_get_section_by_name (PBFD abfd, const ShortInt *name));
+
+//todo:pchar bfd_get_unique_section_name (PBFD abfd, const ShortInt *templat,  integer *count));
+
+//todo:asection * bfd_make_section_old_way (PBFD abfd, const ShortInt *name));
+
+//todo:asection * bfd_make_section_anyway (PBFD abfd, const ShortInt *name));
+
+//todo:asection * bfd_make_section (PBFD , const ShortInt *name));
+
+//todo:bfd_boolean bfd_set_section_flags (PBFD abfd, asection *sec, flagword flags));
+
+type
+  bfd_map_over_sections_proc = procedure( abfd: PBFD; sect: Pasection; obj: pointer ); cdecl;
+
+procedure bfd_map_over_sections( abfd: PBFD; func: bfd_map_over_sections_proc; obj: pointer ); cdecl;
+
+//todo:bfd_boolean bfd_set_section_size (PBFD abfd, asection *sec, bfd_size_type val));
+
+//todo:bfd_boolean bfd_set_section_contents (PBFD abfd, asection *section, pointer data, file_ptr offset,  bfd_size_type count));
+
+function bfd_get_section_contents(abfd: PBFD; section: Pasection; location: pointer; offset: file_ptr; count: bfd_size_type): bfd_boolean; cdecl;
+
+//todo:bfd_boolean bfd_copy_private_section_data (PBFD ibfd, asection *isec, PBFD obfd, asection *osec));
+
+//todo:#define bfd_copy_private_section_data(ibfd, isection, obfd, osection)   BFD_SEND (obfd, _bfd_copy_private_section_data,   (ibfd, isection, obfd, osection))
+//todo:void _bfd_strip_section_from_output (struct bfd_link_info *info, asection *section));
+
+
+//todo:const pchar bfd_printable_name (PBFD abfd));
+
+//todo:const bfd_arch_info_type * bfd_scan_arch (const ShortInt *string));
+
+//todo:const pchar* bfd_arch_list (void));
+
+//todo:const bfd_arch_info_type * bfd_arch_get_compatible ( const PBFD abfd, const PBFD bbfd));
+
+//todo:void bfd_set_arch_info (PBFD abfd, const bfd_arch_info_type *arg));
+
+function bfd_get_arch( abfd: PBFD ): bfd_architecture; cdecl;
+
+function bfd_get_mach( abfd: PBFD ): LongWord; cdecl;
+
+//todo:LongWord bfd_arch_bits_per_byte (PBFD abfd));
+
+//todo:LongWord bfd_arch_bits_per_address (PBFD abfd));
+
+//todo:const bfd_arch_info_type * bfd_get_arch_info (PBFD abfd));
+
+//todo:const bfd_arch_info_type * bfd_lookup_arch  (enum bfd_architecture arch, LongWord machine));
+
+function bfd_printable_arch_mach(arch: bfd_architecture; machine: LongWord): pchar;
+
+//todo:LongWord bfd_octets_per_byte (PBFD abfd));
+//todo:LongWord bfd_arch_mach_octets_per_byte (enum bfd_architecture arch, LongWord machine));
+
+//todo:#define HOWTO(C, R,S,B, P, BI, O, SF, NAME, INPLACE, MASKSRC, MASKDST, PC)  {(unsigned)C,R,S,B, P, BI, O,SF,NAME,INPLACE,MASKSRC,MASKDST,PC}
+//todo:#define NEWHOWTO( FUNCTION, NAME,SIZE,REL,IN) HOWTO(0,0,SIZE,0,REL,0,complain_overflow_dont,FUNCTION, NAME,false,0,0,IN)
+//todo:#define EMPTY_HOWTO(C) HOWTO((C),0,0,0,false,0,complain_overflow_dont,NULL,NULL,false,0,0,false)
+
+//Todo:#define HOWTO_PREPARE(relocation, symbol){ if (symbol != (asymbol * )NULL) { if (bfd_is_com_section (symbol->section)) {relocation = 0;}else{ relocation = symbol->value;}}}
+
+//todo:LongWord bfd_get_reloc_size  (reloc_howto_type *));
+
+{todo:
+  relent_chain = record
+    arelent relent;
+    struct relent_chain *next;
+  end;
+  arelent_chain = relent_chaing;
+}
+
+//todo:bfd_reloc_status_type bfd_check_overflow (enum complain_overflow how, LongWord bitsize, LongWord rightshift, LongWord addrsize,  bfd_vma relocation));
+
+//todo:bfd_reloc_status_type bfd_perform_relocation (PBFD abfd,  arelent *reloc_entry, pointer data, asection *input_section, PBFD output_bfd, pchar*error_message));
+
+//todo:bfd_reloc_status_type bfd_install_relocation (PBFD abfd, arelent *reloc_entry, pointer data, bfd_vma data_start, asection *input_section,  pchar*error_message));
+
+//todo:typedef enum bfd_reloc_code_real bfd_reloc_code_real_type;
+
+//todo:reloc_howto_type * bfd_reloc_type_lookup  (PBFD abfd, bfd_reloc_code_real_type code));
+
+//todo:const pchar bfd_get_reloc_code_name  (bfd_reloc_code_real_type code));
+
+//todo:#define bfd_get_symtab_upper_bound(abfd)  BFD_SEND (abfd, _bfd_get_symtab_upper_bound, (abfd))
+//todo:bfd_boolean bfd_is_local_label (PBFD abfd, asymbol *sym));
+
+//todo:bfd_boolean bfd_is_local_label_name (PBFD abfd, const ShortInt *name));
+
+//todo:#define bfd_is_local_label_name(abfd, name)  BFD_SEND (abfd, _bfd_is_local_label_name, (abfd, name))
+//todo:#define bfd_canonicalize_symtab(abfd, location) BFD_SEND (abfd, _bfd_canonicalize_symtab, (abfd, location))
+//todo:bfd_boolean bfd_set_symtab  (PBFD abfd, asymbol **location, LongWord count));
+
+//todo:void bfd_print_symbol_vandf (pointer file, asymbol *symbol));
+
+//todo:#define bfd_make_empty_symbol(abfd)  BFD_SEND (abfd, _bfd_make_empty_symbol, (abfd))
+//todo:#define bfd_make_debug_symbol(abfd,ptr,size) BFD_SEND (abfd, _bfd_make_debug_symbol, (abfd, ptr, size))
+//todo:integer bfd_decode_symclass (asymbol *symbol));
+
+//todo:bfd_boolean bfd_is_undefined_symclass  (integer symclass));
+
+//todo:void bfd_symbol_info (asymbol *symbol, symbol_info *ret));
+
+//todo:bfd_boolean bfd_copy_private_symbol_data (PBFD ibfd, asymbol *isym, PBFD obfd, asymbol *osym));
+
+//todo:#define bfd_copy_private_symbol_data(ibfd, isymbol, obfd, osymbol)  BFD_SEND (obfd, _bfd_copy_private_symbol_data, (ibfd, isymbol, obfd, osymbol))
+
+
+function bfd_get_error: bfd_error; cdecl;
+
+//todo:void bfd_set_error  (bfd_error error_tag));
+
+function bfd_errmsg( error_tag: bfd_error ): pchar; cdecl;
+
+//todo:void bfd_perror  ( ShortInt *message));
+
+type
+  bfd_error_handler_type = procedure( a: pchar { VARARGS! } ); cdecl;
+
+function bfd_set_error_handler( handler: bfd_error_handler_type ):bfd_error_handler_type; cdecl;
+
+//todo:void bfd_set_error_program_name  (const pchar));
+
+//todo:bfd_error_handler_type bfd_get_error_handler  (void));
+
+//todo:LongInt bfd_get_reloc_upper_bound (PBFD abfd, asection *sect));
+
+//todo:LongInt bfd_canonicalize_reloc (PBFD abfd, asection *sec, arelent **loc, asymbol **syms));
+
+//todo:void bfd_set_reloc (PBFD abfd, asection *sec, arelent **rel, LongWord count) );
+
+//todo:bfd_boolean bfd_set_file_flags (PBFD abfd, flagword flags));
+
+//todo:integer bfd_get_arch_size  (PBFD abfd));
+
+//todo:integer bfd_get_sign_extend_vma  (PBFD abfd));
+
+//todo:bfd_boolean bfd_set_start_address (PBFD abfd, bfd_vma vma));
+
+//todo:LongInt bfd_get_mtime (PBFD abfd));
+
+//todo:LongInt bfd_get_size (PBFD abfd));
+
+//todo:integer bfd_get_gp_size (PBFD abfd));
+
+//todo:void bfd_set_gp_size (PBFD abfd, integer i));
+
+//todo:bfd_vma bfd_scan_vma ( ShortInt *string,  pchar*end, integer base));
+
+//todo:bfd_boolean bfd_copy_private_bfd_data (PBFD ibfd, PBFD obfd));
+
+//todo: #define bfd_copy_private_bfd_data(ibfd, obfd)      BFD_SEND (obfd, _bfd_copy_private_bfd_data,                (ibfd, obfd))
+//todo:bfd_boolean bfd_merge_private_bfd_data (PBFD ibfd, PBFD obfd));
+
+//todo:#define bfd_merge_private_bfd_data(ibfd, obfd)   BFD_SEND (obfd, _bfd_merge_private_bfd_data,(ibfd, obfd))
+//todo:bfd_boolean bfd_set_private_flags (PBFD abfd, flagword flags));
+
+//todo:#define bfd_set_private_flags(abfd, flags) BFD_SEND (abfd, _bfd_set_private_flags, (abfd, flags))
+//todo:#define bfd_sizeof_headers(abfd, reloc)  BFD_SEND (abfd, _bfd_sizeof_headers, (abfd, reloc))
+
+//todo:#define bfd_find_nearest_line(abfd, sec, syms, off, file, func, line) BFD_SEND (abfd, _bfd_find_nearest_line,  (abfd, sec, syms, off, file, func, line))
+
+       (* Do these three do anything useful at all, for any back end?  *)
+//todo:#define bfd_debug_info_start(abfd)       BFD_SEND (abfd, _bfd_debug_info_start, (abfd))
+
+//todo:#define bfd_debug_info_end(abfd)         BFD_SEND (abfd, _bfd_debug_info_end, (abfd))
+
+//todo:#define bfd_debug_info_accumulate(abfd, section)         BFD_SEND (abfd, _bfd_debug_info_accumulate, (abfd, section))
+
+
+//todo:#define bfd_stat_arch_elt(abfd, stat)       BFD_SEND (abfd, _bfd_stat_arch_elt,(abfd, stat))
+
+//todo:#define bfd_update_armap_timestamp(abfd)    BFD_SEND (abfd, _bfd_update_armap_timestamp, (abfd))
+
+//todo:#define bfd_set_arch_mach(abfd, arch, mach) BFD_SEND ( abfd, _bfd_set_arch_mach, (abfd, arch, mach))
+
+//todo:#define bfd_relax_section(abfd, section, link_info, again)        BFD_SEND (abfd, _bfd_relax_section, (abfd, section, link_info, again))
+
+//todo:#define bfd_gc_sections(abfd, link_info)    BFD_SEND (abfd, _bfd_gc_sections, (abfd, link_info))
+
+//todo:#define bfd_link_hash_table_create(abfd)    BFD_SEND (abfd, _bfd_link_hash_table_create, (abfd))
+
+//todo:#define bfd_link_add_symbols(abfd, info)    BFD_SEND (abfd, _bfd_link_add_symbols, (abfd, info))
+
+//todo:#define bfd_final_link(abfd, info)          BFD_SEND (abfd, _bfd_final_link, (abfd, info))
+
+//todo:#define bfd_free_cached_info(abfd)          BFD_SEND (abfd, _bfd_free_cached_info, (abfd))
+
+//todo:#define bfd_get_dynamic_symtab_upper_bound(abfd) BFD_SEND (abfd, _bfd_get_dynamic_symtab_upper_bound, (abfd))
+
+//todo:#define bfd_print_private_bfd_data(abfd, file)   BFD_SEND (abfd, _bfd_print_private_bfd_data, (abfd, file))
+
+//todo:#define bfd_canonicalize_dynamic_symtab(abfd, asymbols) BFD_SEND (abfd, _bfd_canonicalize_dynamic_symtab, (abfd, asymbols))
+
+//todo:#define bfd_get_dynamic_reloc_upper_bound(abfd)         BFD_SEND (abfd, _bfd_get_dynamic_reloc_upper_bound, (abfd))
+
+//todo:#define bfd_canonicalize_dynamic_reloc(abfd, arels, asyms) BFD_SEND (abfd, _bfd_canonicalize_dynamic_reloc, (abfd, arels, asyms))
+
+//todo:function Pbfd_byte bfd_get_relocated_section_contents (PBFD , struct bfd_link_info *, struct bfd_link_order *, Pbfd_byte , bfd_boolean, asymbol **));cdecl;
+//todo:symindex bfd_get_next_mapent (PBFD abfd, symindex previous, carsym **sym));cdecl;
+//todo:bfd_boolean bfd_set_archive_head (PBFD output, PBFD new_head));cdecl;
+//todo:PBFD bfd_openr_next_archived_file (PBFD archive, PBFD previous));cdecl;
+//todo:pchar bfd_core_file_failing_command (PBFD abfd));cdecl;
+//todo:integer bfd_core_file_failing_signal (PBFD abfd));cdecl;
+//todo:bfd_boolean core_file_matches_executable_p (PBFD core_bfd, PBFD exec_bfd));cdecl;
+
+//todo:#define BFD_SEND(bfd, message, arglist)    (( *((bfd)->xvec->message)) arglist)
+//todo:#define BFD_SEND_FMT(bfd, message, arglist)(((bfd)->xvec->message[(integer) ((bfd)->format)]) arglist)
+
+//todo:bfd_boolean bfd_set_default_target  (const ShortInt *name));cdecl;
+//todo:const bfd_target * bfd_find_target ( ShortInt *target_name, PBFD abfd));cdecl;
+//todo:const pchar* bfd_target_list (void));cdecl;
+//todo:const bfd_target * bfd_search_for_target  (integer ( * search_func) (const bfd_target *, void * ), void * ));cdecl;
+
+function bfd_check_format(abfd: PBFD; format: bfd_format): bfd_boolean;cdecl;
+function bfd_check_format_matches(abfd: PBFD; format: bfd_format; matching: pppchar): bfd_boolean;cdecl;
+//todo:bfd_boolean bfd_set_format (PBFD abfd, bfd_format format));cdecl;
+//todo:pchar bfd_format_string (bfd_format format));cdecl;
+
+(* Values that may appear in the flags field of a BFD.  These also
+   appear in the object_flags field of the bfd_target structure, where
+   they indicate the set of flags used by that backend (not all flags
+   are meaningful for all object file formats) (FIXME: at the moment,
+   the object_flags values have mostly just been copied from backend
+   to another, and are not necessarily correct).  *)
+
+(* No flags.  *)
+const
+  BFD_NO_FLAGS 	= $00;
+
+(* BFD contains relocation entries.  *)
+  HAS_RELOC   	= $01;
+
+(* BFD is directly executable.  *)
+  EXEC_P      	= $02;
+
+(* BFD has line number information (basically used for F_LNNO in a
+   COFF header).  *)
+  HAS_LINENO  	= $04;
+
+(* BFD has debugging information.  *)
+  HAS_DEBUG   	= $08;
+
+(* BFD has symbols.  *)
+  HAS_SYMS    	= $10;
+
+(* BFD has local symbols (basically used for F_LSYMS in a COFF
+   header).  *)
+  HAS_LOCALS  	= $20;
+
+(* BFD is a dynamic object.  *)
+  DYNAMIC     	= $40;
+
+(* Text section is write protected (if D_PAGED is not set, this is
+   like an a.out NMAGIC file) (the linker sets this by default, but
+   clears it for -r or -N).  *)
+  WP_TEXT     	= $80;
+
+(* BFD is dynamically paged (this is like an a.out ZMAGIC file) (the
+   linker sets this by default, but clears it for -r or -n or -N).  *)
+  D_PAGED     	= $100;
+
+(* BFD is relaxable (this means that bfd_relax_section may be able to
+   do something) (sometimes bfd_relax_section can do something even if
+   this is not set).  *)
+  BFD_IS_RELAXABLE = $200;
+
+(* This may be set before writing out a BFD to request using a
+   traditional format.  For example, this is used to request that when
+   writing out an a.out object the symbols not be hashed to eliminate
+   duplicates.  *)
+  BFD_TRADITIONAL_FORMAT = $400;
+
+(* This flag indicates that the BFD contents are actually cached in
+   memory.  If this is set, iostream points to a bfd_in_memory struct.  *)
+  BFD_IN_MEMORY = $800;
+
+(* Get the name of a stabs type code.  *)
+
+function bfd_get_stab_name(a:integer):pchar;cdecl;
+
+(* Initialize a hash table.  *)
+//todo:function bfd_boolean bfd_hash_table_init  (struct bfd_hash_table *,   struct bfd_hash_entry *( * ) (struct bfd_hash_entry *, struct bfd_hash_table *, const pchar)));cdecl;
+
+(* Initialize a hash table specifying a size.  *)
+//todo:function bfd_boolean bfd_hash_table_init_n (struct bfd_hash_table *, struct bfd_hash_entry *( * ) (struct bfd_hash_entry *,  struct bfd_hash_table *, const pchar),  LongWord size));cdecl;
+
+(* Free up a hash table.  *)
+//todo:function void bfd_hash_table_free (struct bfd_hash_table *));cdecl;
+
+(* Look up a string in a hash table.  If CREATE is true, a new entry
+   will be created for this string if one does not already exist.  The
+   COPY argument must be true if this routine should copy the string
+   into newly allocated memory when adding an entry.  *)
+//todo:function struct bfd_hash_entry *bfd_hash_lookup (struct bfd_hash_table *, const pchar, bfd_boolean create,  bfd_boolean copy));cdecl;
+
+(* Replace an entry in a hash table.  *)
+//todo:function void bfd_hash_replace (struct bfd_hash_table *, struct bfd_hash_entry *old, struct bfd_hash_entry *nw));cdecl;
+
+(* Base method for creating a hash table entry.  *)
+//todo:function struct bfd_hash_entry *bfd_hash_newfunc (struct bfd_hash_entry *, struct bfd_hash_table *,  const pchar));cdecl;
+
+(* Grab some space for a hash table entry.  *)
+//todo:function pointer bfd_hash_allocate (struct bfd_hash_table *, LongWord));cdecl;
+
+(* Traverse a hash table in a random order, calling a function on each
+   element.  If the function returns false, the traversal stops.  The
+   INFO argument is passed to the function.  *)
+//todo:function void bfd_hash_traverse (struct bfd_hash_table *,  bfd_boolean ( * ) (struct bfd_hash_entry *, pointer), pointer info));cdecl;
+
+(* Print a bfd_vma x on stream s.  *)
+//todo:#define fprintf_vma(s,x) fprintf (s, "%08lx", x)
+//todo:#define sprintf_vma(s,x) sprintf (s, "%08lx", x)
+
+//todo:#define printf_vma(x) fprintf_vma(stdout,x)
+
+implementation
+
+const
+  LIB_NAME = 'libbfd-'+BFD_VERSION+'.dll';
+
+function bfd_read;  external LIB_NAME;
+function bfd_write; external LIB_NAME;
+function bfd_seek;  external LIB_NAME;
+function bfd_tell;  external LIB_NAME;
+function bfd_flush; external LIB_NAME;
+function bfd_stat;  external LIB_NAME;
+
+function bfd_record_phdr; external LIB_NAME;
+function bfd_getb64; external LIB_NAME;
+function bfd_getl64; external LIB_NAME;
+function bfd_getb_signed_64; external LIB_NAME;
+function bfd_getl_signed_64; external LIB_NAME;
+function bfd_getb32; external LIB_NAME;
+function bfd_getl32; external LIB_NAME;
+function bfd_getb_signed_32; external LIB_NAME;
+function bfd_getl_signed_32; external LIB_NAME;
+function bfd_getb16; external LIB_NAME;
+function bfd_getl16; external LIB_NAME;
+function bfd_getb_signed_16; external LIB_NAME;
+function bfd_getl_signed_16; external LIB_NAME;
+procedure bfd_putb64; external LIB_NAME;
+procedure bfd_putl64; external LIB_NAME;
+procedure bfd_putb32; external LIB_NAME;
+procedure bfd_putl32; external LIB_NAME;
+procedure bfd_putb16; external LIB_NAME;
+procedure bfd_putl16; external LIB_NAME;
+function bfd_get_bits; external LIB_NAME;
+procedure bfd_put_bits; external LIB_NAME;
+function bfd_ecoff_get_gp_value; external LIB_NAME;
+function bfd_ecoff_set_gp_value; external LIB_NAME;
+function bfd_ecoff_set_regmasks; external LIB_NAME;
+function bfd_ecoff_debug_init; external LIB_NAME;
+procedure bfd_ecoff_debug_free; external LIB_NAME;
+function bfd_ecoff_debug_accumulate; external LIB_NAME;
+function bfd_get_stab_name; external LIB_NAME;
+
+function bfd_fdopenr; external LIB_NAME;
+function bfd_openstreamr; external LIB_NAME;
+function bfd_openw; external LIB_NAME;
+function bfd_close; external LIB_NAME;
+function bfd_close_all_done; external LIB_NAME;
+function bfd_create; external LIB_NAME;
+function bfd_make_writable; external LIB_NAME;
+function bfd_make_readable; external LIB_NAME;
+
+function bfd_set_error_handler; external LIB_NAME;
+
+// partly tested:
+procedure bfd_init; external LIB_NAME;
+function bfd_openr; external LIB_NAME;
+function bfd_check_format; external LIB_NAME;
+function bfd_check_format_matches; external LIB_NAME;
+
+function bfd_get_error; external LIB_NAME;
+function bfd_errmsg; external LIB_NAME;
+function bfd_printable_arch_mach; external LIB_NAME;
+function bfd_get_arch; external LIB_NAME;
+function bfd_get_mach; external LIB_NAME;
+
+procedure bfd_map_over_sections; external LIB_NAME;
+function bfd_get_section_contents; external LIB_NAME;
+
+// Makros:
+
+function bfd_get_filename(abfd: PBFD): pchar;
+begin
+  result:=abfd.filename;
+end;
+
+initialization
+  bfd_init;
+end.

+ 1234 - 0
packages/extra/cmem/Makefile

@@ -0,0 +1,1234 @@
+#
+# Don't edit, this file is generated by FPCMake Version 1.1 [2002/01/29]
+#
+default: all
+MAKEFILETARGETS=linux go32v2 win32 os2 freebsd beos netbsd amiga atari sunos qnx
+override PATH:=$(subst \,/,$(PATH))
+ifeq ($(findstring ;,$(PATH)),)
+inUnix=1
+SEARCHPATH:=$(filter-out .,$(subst :, ,$(PATH)))
+else
+SEARCHPATH:=$(subst ;, ,$(PATH))
+endif
+PWD:=$(strip $(wildcard $(addsuffix /pwd.exe,$(SEARCHPATH))))
+ifeq ($(PWD),)
+PWD:=$(strip $(wildcard $(addsuffix /pwd,$(SEARCHPATH))))
+ifeq ($(PWD),)
+$(error You need the GNU utils package to use this Makefile)
+else
+PWD:=$(firstword $(PWD))
+SRCEXEEXT=
+endif
+else
+PWD:=$(firstword $(PWD))
+SRCEXEEXT=.exe
+endif
+ifndef inUnix
+ifeq ($(OS),Windows_NT)
+inWinNT=1
+else
+ifdef OS2_SHELL
+inOS2=1
+endif
+endif
+else
+ifneq ($(findstring cygwin,$(MACHTYPE)),)
+inCygWin=1
+endif
+endif
+ifeq ($(OS_TARGET),freebsd)
+BSDhier=1
+endif
+ifeq ($(OS_TARGET),netbsd)
+BSDhier=1
+endif
+ifdef inUnix
+BATCHEXT=.sh
+else
+ifdef inOS2
+BATCHEXT=.cmd
+else
+BATCHEXT=.bat
+endif
+endif
+ifdef inUnix
+PATHSEP=/
+else
+PATHSEP:=$(subst /,\,/)
+endif
+ifdef PWD
+BASEDIR:=$(subst \,/,$(shell $(PWD)))
+ifdef inCygWin
+ifneq ($(findstring /cygdrive/,$(BASEDIR)),)
+BASENODIR:=$(patsubst /cygdrive%,%,$(BASEDIR))
+BASEDRIVE:=$(firstword $(subst /, ,$(BASENODIR)))
+BASEDIR:=$(subst /cygdrive/$(BASEDRIVE)/,$(BASEDRIVE):/,$(BASEDIR))
+endif
+endif
+else
+BASEDIR=.
+endif
+override DEFAULT_FPCDIR=../../..
+ifndef FPC
+ifdef PP
+FPC=$(PP)
+endif
+endif
+ifndef FPC
+FPCPROG:=$(strip $(wildcard $(addsuffix /fpc$(SRCEXEEXT),$(SEARCHPATH))))
+ifneq ($(FPCPROG),)
+FPCPROG:=$(firstword $(FPCPROG))
+FPC:=$(shell $(FPCPROG) -PB)
+ifneq ($(findstring Error,$(FPC)),)
+override FPC=ppc386
+endif
+else
+override FPC=ppc386
+endif
+endif
+override FPC:=$(subst $(SRCEXEEXT),,$(FPC))
+override FPC:=$(subst \,/,$(FPC))$(SRCEXEEXT)
+ifndef FPC_VERSION
+FPC_VERSION:=$(shell $(FPC) -iV)
+endif
+export FPC FPC_VERSION
+ifeq ($(findstring 1.0.,$(FPC_VERSION)),)
+COMPILERINFO:=$(shell $(FPC) -iSP -iTP -iSO -iTO)
+ifndef CPU_SOURCE
+CPU_SOURCE:=$(word 1,$(COMPILERINFO))
+endif
+ifndef CPU_TARGET
+CPU_TARGET:=$(word 2,$(COMPILERINFO))
+endif
+ifndef OS_SOURCE
+OS_SOURCE:=$(word 3,$(COMPILERINFO))
+endif
+ifndef OS_TARGET
+OS_TARGET:=$(word 4,$(COMPILERINFO))
+endif
+else
+ifndef CPU_SOURCE
+CPU_SOURCE:=$(shell $(FPC) -iSP)
+endif
+ifndef CPU_TARGET
+CPU_TARGET:=$(shell $(FPC) -iTP)
+endif
+ifndef OS_SOURCE
+OS_SOURCE:=$(shell $(FPC) -iSO)
+endif
+ifndef OS_TARGET
+OS_TARGET:=$(shell $(FPC) -iTO)
+endif
+endif
+FULL_TARGET=$(CPU_TARGET)-$(OS_TARGET)
+FULL_SOURCE=$(CPU_SOURCE)-$(OS_SOURCE)
+ifneq ($(FULL_TARGET),$(FULL_SOURCE))
+CROSSCOMPILE=1
+endif
+ifeq ($(findstring makefile,$(MAKECMDGOALS)),)
+ifeq ($(findstring $(OS_TARGET),$(MAKEFILETARGETS)),)
+$(error The Makefile doesn't support target $(OS_TARGET), please run fpcmake first)
+endif
+endif
+export OS_TARGET OS_SOURCE CPU_TARGET CPU_SOURCE FULL_TARGET FULL_SOURCE CROSSCOMPILE
+ifdef FPCDIR
+override FPCDIR:=$(subst \,/,$(FPCDIR))
+ifeq ($(wildcard $(addprefix $(FPCDIR)/,rtl units)),)
+override FPCDIR=wrong
+endif
+else
+override FPCDIR=wrong
+endif
+ifdef DEFAULT_FPCDIR
+ifeq ($(FPCDIR),wrong)
+override FPCDIR:=$(subst \,/,$(DEFAULT_FPCDIR))
+ifeq ($(wildcard $(addprefix $(FPCDIR)/,rtl units)),)
+override FPCDIR=wrong
+endif
+endif
+endif
+ifeq ($(FPCDIR),wrong)
+ifdef inUnix
+override FPCDIR=/usr/local/lib/fpc/$(FPC_VERSION)
+ifeq ($(wildcard $(FPCDIR)/units),)
+override FPCDIR=/usr/lib/fpc/$(FPC_VERSION)
+endif
+else
+override FPCDIR:=$(subst /$(FPC),,$(firstword $(strip $(wildcard $(addsuffix /$(FPC),$(SEARCHPATH))))))
+override FPCDIR:=$(FPCDIR)/..
+ifeq ($(wildcard $(addprefix $(FPCDIR)/,rtl units)),)
+override FPCDIR:=$(FPCDIR)/..
+ifeq ($(wildcard $(addprefix $(FPCDIR)/,rtl units)),)
+override FPCDIR=c:/pp
+endif
+endif
+endif
+endif
+ifndef CROSSDIR
+CROSSDIR:=$(FPCDIR)/cross/$(FULL_TARGET)
+endif
+ifndef CROSSTARGETDIR
+CROSSTARGETDIR=$(CROSSDIR)/$(FULL_TARGET)
+endif
+ifdef CROSSCOMPILE
+UNITSDIR:=$(wildcard $(CROSSTARGETDIR)/units)
+ifeq ($(UNITSDIR),)
+UNITSDIR:=$(wildcard $(FPCDIR)/units/$(OS_TARGET))
+endif
+else
+UNITSDIR:=$(wildcard $(FPCDIR)/units/$(OS_TARGET))
+endif
+PACKAGESDIR:=$(wildcard $(FPCDIR) $(FPCDIR)/packages/base $(FPCDIR)/packages/extra)
+override PACKAGE_NAME=cmem
+override PACKAGE_VERSION=1.0.6
+override TARGET_UNITS+=cmem
+override TARGET_EXAMPLES+=testcmem
+override INSTALL_FPCPACKAGE=y
+ifdef REQUIRE_UNITSDIR
+override UNITSDIR+=$(REQUIRE_UNITSDIR)
+endif
+ifdef REQUIRE_PACKAGESDIR
+override PACKAGESDIR+=$(REQUIRE_PACKAGESDIR)
+endif
+ifdef ZIPINSTALL
+ifeq ($(OS_TARGET),linux)
+UNIXINSTALLDIR=1
+endif
+ifeq ($(OS_TARGET),freebsd)
+UNIXINSTALLDIR=1
+endif
+ifeq ($(OS_TARGET),netbsd)
+UNIXINSTALLDIR=1
+endif
+ifeq ($(OS_TARGET),sunos)
+UNIXINSTALLDIR=1
+endif
+else
+ifeq ($(OS_SOURCE),linux)
+UNIXINSTALLDIR=1
+endif
+ifeq ($(OS_SOURCE),freebsd)
+UNIXINSTALLDIR=1
+endif
+ifeq ($(OS_SOURCE),netbsd)
+UNIXINSTALLDIR=1
+endif
+ifeq ($(OS_TARGET),sunos)
+UNIXINSTALLDIR=1
+endif
+endif
+ifndef INSTALL_PREFIX
+ifdef PREFIX
+INSTALL_PREFIX=$(PREFIX)
+endif
+endif
+ifndef INSTALL_PREFIX
+ifdef UNIXINSTALLDIR
+INSTALL_PREFIX=/usr/local
+else
+ifdef INSTALL_FPCPACKAGE
+INSTALL_BASEDIR:=/pp
+else
+INSTALL_BASEDIR:=/$(PACKAGE_NAME)
+endif
+endif
+endif
+export INSTALL_PREFIX
+ifndef DIST_DESTDIR
+DIST_DESTDIR:=$(BASEDIR)
+endif
+export DIST_DESTDIR
+ifndef INSTALL_BASEDIR
+ifdef UNIXINSTALLDIR
+ifdef INSTALL_FPCPACKAGE
+INSTALL_BASEDIR:=$(INSTALL_PREFIX)/lib/fpc/$(FPC_VERSION)
+else
+INSTALL_BASEDIR:=$(INSTALL_PREFIX)/lib/$(PACKAGE_NAME)
+endif
+else
+INSTALL_BASEDIR:=$(INSTALL_PREFIX)
+endif
+endif
+ifndef INSTALL_BINDIR
+ifdef UNIXINSTALLDIR
+INSTALL_BINDIR:=$(INSTALL_PREFIX)/bin
+else
+INSTALL_BINDIR:=$(INSTALL_BASEDIR)/bin
+ifdef INSTALL_FPCPACKAGE
+INSTALL_BINDIR:=$(INSTALL_BINDIR)/$(OS_TARGET)
+endif
+endif
+endif
+ifndef INSTALL_UNITDIR
+ifdef CROSSCOMPILE
+INSTALL_UNITDIR:=$(INSTALL_BASEDIR)/cross/$(FULL_TARGET)/units
+else
+INSTALL_UNITDIR:=$(INSTALL_BASEDIR)/units/$(OS_TARGET)
+endif
+ifdef INSTALL_FPCPACKAGE
+ifdef PACKAGE_NAME
+INSTALL_UNITDIR:=$(INSTALL_UNITDIR)/$(PACKAGE_NAME)
+endif
+endif
+endif
+ifndef INSTALL_LIBDIR
+ifdef UNIXINSTALLDIR
+INSTALL_LIBDIR:=$(INSTALL_PREFIX)/lib
+else
+INSTALL_LIBDIR:=$(INSTALL_UNITDIR)
+endif
+endif
+ifndef INSTALL_SOURCEDIR
+ifdef UNIXINSTALLDIR
+ifdef INSTALL_FPCPACKAGE
+ifdef BSDhier
+INSTALL_SOURCEDIR:=$(INSTALL_PREFIX)/share/src/fpc-$(FPC_VERSION)/$(PACKAGE_NAME)
+else
+INSTALL_SOURCEDIR:=$(INSTALL_PREFIX)/src/fpc-$(FPC_VERSION)/$(PACKAGE_NAME)
+endif
+else
+ifdef BSDhier
+INSTALL_SOURCEDIR:=$(INSTALL_PREFIX)/share/src/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
+else
+INSTALL_SOURCEDIR:=$(INSTALL_PREFIX)/src/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
+endif
+endif
+else
+ifdef INSTALL_FPCPACKAGE
+INSTALL_SOURCEDIR:=$(INSTALL_BASEDIR)/source/$(PACKAGE_NAME)
+else
+INSTALL_SOURCEDIRL:=$(INSTALL_BASEDIR)/source
+endif
+endif
+endif
+ifndef INSTALL_DOCDIR
+ifdef UNIXINSTALLDIR
+ifdef INSTALL_FPCPACKAGE
+ifdef BSDhier
+INSTALL_DOCDIR:=$(INSTALL_PREFIX)/share/doc/fpc-$(FPC_VERSION)/$(PACKAGE_NAME)
+else
+INSTALL_DOCDIR:=$(INSTALL_PREFIX)/doc/fpc-$(FPC_VERSION)/$(PACKAGE_NAME)
+endif
+else
+ifdef BSDhier
+INSTALL_DOCDIR:=$(INSTALL_PREFIX)/share/doc/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
+else
+INSTALL_DOCDIR:=$(INSTALL_PREFIX)/doc/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
+endif
+endif
+else
+ifdef INSTALL_FPCPACKAGE
+INSTALL_DOCDIR:=$(INSTALL_BASEDIR)/doc/$(PACKAGE_NAME)
+else
+INSTALL_DOCDIR:=$(INSTALL_BASEDIR)/doc
+endif
+endif
+endif
+ifndef INSTALL_EXAMPLEDIR
+ifdef UNIXINSTALLDIR
+ifdef INSTALL_FPCPACKAGE
+ifdef BSDhier
+INSTALL_EXAMPLEDIR:=$(INSTALL_PREFIX)/share/examples/fpc-$(FPC_VERSION)/$(PACKAGE_NAME)
+else
+INSTALL_EXAMPLEDIR:=$(INSTALL_PREFIX)/doc/fpc-$(FPC_VERSION)/examples/$(PACKAGE_NAME)
+endif
+else
+ifdef BSDhier
+INSTALL_EXAMPLEDIR:=$(INSTALL_PREFIX)/share/examples/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
+else
+INSTALL_EXAMPLEDIR:=$(INSTALL_PREFIX)/doc/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
+endif
+endif
+else
+ifdef INSTALL_FPCPACKAGE
+INSTALL_EXAMPLEDIR:=$(INSTALL_BASEDIR)/examples/$(PACKAGE_NAME)
+else
+INSTALL_EXAMPLEDIR:=$(INSTALL_BASEDIR)/examples
+endif
+endif
+endif
+ifndef INSTALL_DATADIR
+INSTALL_DATADIR=$(INSTALL_BASEDIR)
+endif
+ifdef CROSSCOMPILE
+ifndef CROSSBINDIR
+CROSSBINDIR:=$(wildcard $(CROSSTARGETDIR)/bin/$(FULL_SOURCE))
+ifeq ($(CROSSBINDIR),)
+CROSSBINDIR:=$(wildcard $(INSTALL_BASEDIR)/cross/$(FULL_TARGET)/bin/$(FULL_SOURCE))
+endif
+endif
+else
+CROSSBINDIR=
+endif
+LOADEREXT=.as
+EXEEXT=.exe
+PPLEXT=.ppl
+PPUEXT=.ppu
+OEXT=.o
+ASMEXT=.s
+SMARTEXT=.sl
+STATICLIBEXT=.a
+SHAREDLIBEXT=.so
+STATICLIBPREFIX=libp
+RSTEXT=.rst
+FPCMADE=fpcmade
+ifeq ($(OS_TARGET),go32v1)
+PPUEXT=.pp1
+OEXT=.o1
+ASMEXT=.s1
+SMARTEXT=.sl1
+STATICLIBEXT=.a1
+SHAREDLIBEXT=.so1
+STATICLIBPREFIX=
+FPCMADE=fpcmade.v1
+PACKAGESUFFIX=v1
+endif
+ifeq ($(OS_TARGET),go32v2)
+STATICLIBPREFIX=
+FPCMADE=fpcmade.dos
+ZIPSUFFIX=go32
+endif
+ifeq ($(OS_TARGET),linux)
+EXEEXT=
+HASSHAREDLIB=1
+FPCMADE=fpcmade.lnx
+ZIPSUFFIX=linux
+endif
+ifeq ($(OS_TARGET),freebsd)
+EXEEXT=
+HASSHAREDLIB=1
+FPCMADE=fpcmade.freebsd
+ZIPSUFFIX=freebsd
+endif
+ifeq ($(OS_TARGET),netbsd)
+EXEEXT=
+HASSHAREDLIB=1
+FPCMADE=fpcmade.netbsd
+ZIPSUFFIX=netbsd
+endif
+ifeq ($(OS_TARGET),win32)
+PPUEXT=.ppw
+OEXT=.ow
+ASMEXT=.sw
+SMARTEXT=.slw
+STATICLIBEXT=.aw
+SHAREDLIBEXT=.dll
+FPCMADE=fpcmade.w32
+ZIPSUFFIX=w32
+endif
+ifeq ($(OS_TARGET),os2)
+PPUEXT=.ppo
+ASMEXT=.so2
+OEXT=.oo2
+AOUTEXT=.out
+SMARTEXT=.so
+STATICLIBEXT=.ao2
+SHAREDLIBEXT=.dll
+FPCMADE=fpcmade.os2
+ZIPSUFFIX=emx
+endif
+ifeq ($(OS_TARGET),amiga)
+EXEEXT=
+PPUEXT=.ppa
+ASMEXT=.asm
+OEXT=.o
+SMARTEXT=.sl
+STATICLIBEXT=.a
+SHAREDLIBEXT=.library
+FPCMADE=fpcmade.amg
+endif
+ifeq ($(OS_TARGET),atari)
+PPUEXT=.ppt
+ASMEXT=.s
+OEXT=.o
+SMARTEXT=.sl
+STATICLIBEXT=.a
+EXEEXT=.ttp
+FPCMADE=fpcmade.ata
+endif
+ifeq ($(OS_TARGET),beos)
+PPUEXT=.ppu
+ASMEXT=.s
+OEXT=.o
+SMARTEXT=.sl
+STATICLIBEXT=.a
+EXEEXT=
+FPCMADE=fpcmade.be
+ZIPSUFFIX=be
+endif
+ifeq ($(OS_TARGET),sunos)
+PPUEXT=.ppu
+ASMEXT=.s
+OEXT=.o
+SMARTEXT=.sl
+STATICLIBEXT=.a
+EXEEXT=
+FPCMADE=fpcmade.sun
+ZIPSUFFIX=sun
+endif
+ifeq ($(OS_TARGET),qnx)
+PPUEXT=.ppu
+ASMEXT=.s
+OEXT=.o
+SMARTEXT=.sl
+STATICLIBEXT=.a
+EXEEXT=
+FPCMADE=fpcmade.qnx
+ZIPSUFFIX=qnx
+endif
+ifndef ECHO
+ECHO:=$(strip $(wildcard $(addsuffix /gecho$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(ECHO),)
+ECHO:=$(strip $(wildcard $(addsuffix /echo$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(ECHO),)
+ECHO=
+else
+ECHO:=$(firstword $(ECHO))
+endif
+else
+ECHO:=$(firstword $(ECHO))
+endif
+endif
+export ECHO
+ifndef DATE
+DATE:=$(strip $(wildcard $(addsuffix /gdate$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(DATE),)
+DATE:=$(strip $(wildcard $(addsuffix /date$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(DATE),)
+DATE=
+else
+DATE:=$(firstword $(DATE))
+endif
+else
+DATE:=$(firstword $(DATE))
+endif
+endif
+export DATE
+ifndef GINSTALL
+GINSTALL:=$(strip $(wildcard $(addsuffix /ginstall$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(GINSTALL),)
+GINSTALL:=$(strip $(wildcard $(addsuffix /install$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(GINSTALL),)
+GINSTALL=
+else
+GINSTALL:=$(firstword $(GINSTALL))
+endif
+else
+GINSTALL:=$(firstword $(GINSTALL))
+endif
+endif
+export GINSTALL
+ifndef CPPROG
+CPPROG:=$(strip $(wildcard $(addsuffix /cp$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(CPPROG),)
+CPPROG=
+else
+CPPROG:=$(firstword $(CPPROG))
+endif
+endif
+export CPPROG
+ifndef RMPROG
+RMPROG:=$(strip $(wildcard $(addsuffix /rm$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(RMPROG),)
+RMPROG=
+else
+RMPROG:=$(firstword $(RMPROG))
+endif
+endif
+export RMPROG
+ifndef MVPROG
+MVPROG:=$(strip $(wildcard $(addsuffix /mv$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(MVPROG),)
+MVPROG=
+else
+MVPROG:=$(firstword $(MVPROG))
+endif
+endif
+export MVPROG
+ifndef ECHOREDIR
+ECHOREDIR:=$(subst /,$(PATHSEP),$(ECHO))
+endif
+ifndef COPY
+COPY:=$(CPPROG) -fp
+endif
+ifndef COPYTREE
+COPYTREE:=$(CPPROG) -rfp
+endif
+ifndef MOVE
+MOVE:=$(MVPROG) -f
+endif
+ifndef DEL
+DEL:=$(RMPROG) -f
+endif
+ifndef DELTREE
+DELTREE:=$(RMPROG) -rf
+endif
+ifndef INSTALL
+ifdef inUnix
+INSTALL:=$(GINSTALL) -c -m 644
+else
+INSTALL:=$(COPY)
+endif
+endif
+ifndef INSTALLEXE
+ifdef inUnix
+INSTALLEXE:=$(GINSTALL) -c -m 755
+else
+INSTALLEXE:=$(COPY)
+endif
+endif
+ifndef MKDIR
+MKDIR:=$(GINSTALL) -m 755 -d
+endif
+export ECHOREDIR COPY COPYTREE MOVE DEL DELTREE INSTALL INSTALLEXE MKDIR
+ifndef PPUMOVE
+PPUMOVE:=$(strip $(wildcard $(addsuffix /ppumove$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(PPUMOVE),)
+PPUMOVE=
+else
+PPUMOVE:=$(firstword $(PPUMOVE))
+endif
+endif
+export PPUMOVE
+ifndef FPCMAKE
+FPCMAKE:=$(strip $(wildcard $(addsuffix /fpcmake$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(FPCMAKE),)
+FPCMAKE=
+else
+FPCMAKE:=$(firstword $(FPCMAKE))
+endif
+endif
+export FPCMAKE
+ifndef ZIPPROG
+ZIPPROG:=$(strip $(wildcard $(addsuffix /zip$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(ZIPPROG),)
+ZIPPROG=
+else
+ZIPPROG:=$(firstword $(ZIPPROG))
+endif
+endif
+export ZIPPROG
+ifndef TARPROG
+TARPROG:=$(strip $(wildcard $(addsuffix /tar$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(TARPROG),)
+TARPROG=
+else
+TARPROG:=$(firstword $(TARPROG))
+endif
+endif
+export TARPROG
+ASNAME=as
+LDNAME=ld
+ARNAME=ar
+RCNAME=rc
+ifeq ($(OS_TARGET),win32)
+ASNAME=asw
+LDNAME=ldw
+ARNAME=arw
+endif
+ifndef ASPROG
+ifdef CROSSBINDIR
+ASPROG=$(CROSSBINDIR)/$(ASNAME)$(SRCEXEEXT)
+else
+ASPROG=$(ASNAME)
+endif
+endif
+ifndef LDPROG
+ifdef CROSSBINDIR
+LDPROG=$(CROSSBINDIR)/$(LDNAME)$(SRCEXEEXT)
+else
+LDPROG=$(LDNAME)
+endif
+endif
+ifndef RCPROG
+ifdef CROSSBINDIR
+RCPROG=$(CROSSBINDIR)/$(RCNAME)$(SRCEXEEXT)
+else
+RCPROG=$(RCNAME)
+endif
+endif
+ifndef ARPROG
+ifdef CROSSBINDIR
+ARPROG=$(CROSSBINDIR)/$(ARNAME)$(SRCEXEEXT)
+else
+ARPROG=$(ARNAME)
+endif
+endif
+AS=$(ASPROG)
+LD=$(LDPROG)
+RC=$(RCPROG)
+AR=$(ARPROG)
+PPAS=ppas$(BATCHEXT)
+ifdef inUnix
+LDCONFIG=ldconfig
+else
+LDCONFIG=
+endif
+ifdef DATE
+DATESTR:=$(shell $(DATE) +%Y%m%d)
+else
+DATESTR=
+endif
+ifndef UPXPROG
+ifeq ($(OS_TARGET),go32v2)
+UPXPROG:=1
+endif
+ifeq ($(OS_TARGET),win32)
+UPXPROG:=1
+endif
+ifdef UPXPROG
+UPXPROG:=$(strip $(wildcard $(addsuffix /upx$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(UPXPROG),)
+UPXPROG=
+else
+UPXPROG:=$(firstword $(UPXPROG))
+endif
+else
+UPXPROG=
+endif
+endif
+export UPXPROG
+ZIPOPT=-9
+ZIPEXT=.zip
+ifeq ($(USETAR),bz2)
+TAROPT=vI
+TAREXT=.tar.bz2
+else
+TAROPT=vz
+TAREXT=.tar.gz
+endif
+override REQUIRE_PACKAGES=rtl 
+ifeq ($(OS_TARGET),linux)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(OS_TARGET),go32v2)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(OS_TARGET),win32)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(OS_TARGET),os2)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(OS_TARGET),freebsd)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(OS_TARGET),beos)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(OS_TARGET),netbsd)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(OS_TARGET),amiga)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(OS_TARGET),atari)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(OS_TARGET),sunos)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(OS_TARGET),qnx)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifdef REQUIRE_PACKAGES_RTL
+PACKAGEDIR_RTL:=$(firstword $(subst /Makefile.fpc,,$(strip $(wildcard $(addsuffix /rtl/$(OS_TARGET)/Makefile.fpc,$(PACKAGESDIR))))))
+ifneq ($(PACKAGEDIR_RTL),)
+ifneq ($(wildcard $(PACKAGEDIR_RTL)/$(OS_TARGET)),)
+UNITDIR_RTL=$(PACKAGEDIR_RTL)/$(OS_TARGET)
+else
+UNITDIR_RTL=$(PACKAGEDIR_RTL)
+endif
+else
+PACKAGEDIR_RTL=
+UNITDIR_RTL:=$(subst /Package.fpc,,$(strip $(wildcard $(addsuffix /rtl/Package.fpc,$(UNITSDIR)))))
+ifneq ($(UNITDIR_RTL),)
+UNITDIR_RTL:=$(firstword $(UNITDIR_RTL))
+else
+UNITDIR_RTL=
+endif
+endif
+ifdef UNITDIR_RTL
+override COMPILER_UNITDIR+=$(UNITDIR_RTL)
+endif
+endif
+ifndef NOCPUDEF
+override FPCOPTDEF=$(CPU_TARGET)
+endif
+ifneq ($(OS_TARGET),$(OS_SOURCE))
+override FPCOPT+=-T$(OS_TARGET)
+endif
+ifdef UNITDIR
+override FPCOPT+=$(addprefix -Fu,$(UNITDIR))
+endif
+ifdef LIBDIR
+override FPCOPT+=$(addprefix -Fl,$(LIBDIR))
+endif
+ifdef OBJDIR
+override FPCOPT+=$(addprefix -Fo,$(OBJDIR))
+endif
+ifdef INCDIR
+override FPCOPT+=$(addprefix -Fi,$(INCDIR))
+endif
+ifdef LINKSMART
+override FPCOPT+=-XX
+endif
+ifdef CREATESMART
+override FPCOPT+=-CX
+endif
+ifdef DEBUG
+override FPCOPT+=-gl
+override FPCOPTDEF+=DEBUG
+endif
+ifdef RELEASE
+ifeq ($(CPU_TARGET),i386)
+FPCCPUOPT:=-OG2p3
+else
+FPCCPUOPT:=
+endif
+override FPCOPT+=-Xs $(FPCCPUOPT) -n
+override FPCOPTDEF+=RELEASE
+endif
+ifdef STRIP
+override FPCOPT+=-Xs
+endif
+ifdef OPTIMIZE
+ifeq ($(CPU_TARGET),i386)
+override FPCOPT+=-OG2p3
+endif
+endif
+ifdef VERBOSE
+override FPCOPT+=-vwni
+endif
+ifdef COMPILER_OPTIONS
+override FPCOPT+=$(COMPILER_OPTIONS)
+endif
+ifdef COMPILER_UNITDIR
+override FPCOPT+=$(addprefix -Fu,$(COMPILER_UNITDIR))
+endif
+ifdef COMPILER_LIBRARYDIR
+override FPCOPT+=$(addprefix -Fl,$(COMPILER_LIBRARYDIR))
+endif
+ifdef COMPILER_OBJECTDIR
+override FPCOPT+=$(addprefix -Fo,$(COMPILER_OBJECTDIR))
+endif
+ifdef COMPILER_INCLUDEDIR
+override FPCOPT+=$(addprefix -Fi,$(COMPILER_INCLUDEDIR))
+endif
+ifdef CROSSBINDIR
+override FPCOPT+=-FD$(CROSSBINDIR)
+endif
+ifdef COMPILER_TARGETDIR
+override FPCOPT+=-FE$(COMPILER_TARGETDIR)
+ifeq ($(COMPILER_TARGETDIR),.)
+override TARGETDIRPREFIX=
+else
+override TARGETDIRPREFIX=$(COMPILER_TARGETDIR)/
+endif
+endif
+ifdef COMPILER_UNITTARGETDIR
+override FPCOPT+=-FU$(COMPILER_UNITTARGETDIR)
+ifeq ($(COMPILER_UNITTARGETDIR),.)
+override UNITTARGETDIRPREFIX=
+else
+override UNITTARGETDIRPREFIX=$(COMPILER_UNITTARGETDIR)/
+endif
+else
+ifdef COMPILER_TARGETDIR
+override COMPILER_UNITTARGETDIR=$(COMPILER_TARGETDIR)
+override UNITTARGETDIRPREFIX=$(TARGETDIRPREFIX)
+endif
+endif
+ifdef OPT
+override FPCOPT+=$(OPT)
+endif
+ifdef FPCOPTDEF
+override FPCOPT+=$(addprefix -d,$(FPCOPTDEF))
+endif
+ifdef CFGFILE
+override FPCOPT+=@$(CFGFILE)
+endif
+ifdef USEENV
+override FPCEXTCMD:=$(FPCOPT)
+override FPCOPT:=!FPCEXTCMD
+export FPCEXTCMD
+endif
+override COMPILER:=$(FPC) $(FPCOPT)
+ifeq (,$(findstring -s ,$(COMPILER)))
+EXECPPAS=
+else
+ifeq ($(OS_SOURCE),$(OS_TARGET))
+EXECPPAS:=@$(PPAS)
+endif
+endif
+.PHONY: fpc_units
+ifdef TARGET_UNITS
+override ALLTARGET+=fpc_units
+override UNITPPUFILES=$(addsuffix $(PPUEXT),$(TARGET_UNITS))
+override IMPLICITUNITPPUFILES=$(addsuffix $(PPUEXT),$(TARGET_IMPLICITUNITS))
+override INSTALLPPUFILES+=$(UNITPPUFILES) $(IMPLICITUNITPPUFILES)
+override CLEANPPUFILES+=$(UNITPPUFILES) $(IMPLICITUNITPPUFILES)
+endif
+fpc_units: $(UNITPPUFILES)
+ifdef TARGET_RSTS
+override RSTFILES=$(addsuffix $(RSTEXT),$(TARGET_RSTS))
+override CLEANRSTFILES+=$(RSTFILES)
+endif
+.PHONY: fpc_examples
+ifdef TARGET_EXAMPLES
+HASEXAMPLES=1
+override EXAMPLESOURCEFILES:=$(wildcard $(addsuffix .pp,$(TARGET_EXAMPLES)) $(addsuffix .pas,$(TARGET_EXAMPLES)))
+override EXAMPLEFILES:=$(addsuffix $(EXEEXT),$(TARGET_EXAMPLES))
+override EXAMPLEOFILES:=$(addsuffix $(OEXT),$(TARGET_EXAMPLES)) $(addprefix $(STATICLIBPREFIX),$(addsuffix $(STATICLIBEXT),$(TARGET_EXAMPLES)))
+override CLEANEXEFILES+=$(EXAMPLEFILES) $(EXAMPLEOFILES)
+ifeq ($(OS_TARGET),os2)
+override CLEANEXEFILES+=$(addsuffix $(AOUTEXT),$(TARGET_EXAMPLES))
+endif
+endif
+ifdef TARGET_EXAMPLEDIRS
+HASEXAMPLES=1
+endif
+fpc_examples: all $(EXAMPLEFILES) $(addsuffix _all,$(TARGET_EXAMPLEDIRS))
+.PHONY: fpc_all fpc_smart fpc_debug fpc_release
+$(FPCMADE): $(ALLTARGET)
+	@$(ECHOREDIR) Compiled > $(FPCMADE)
+fpc_all: $(FPCMADE)
+fpc_smart:
+	$(MAKE) all LINKSMART=1 CREATESMART=1
+fpc_debug:
+	$(MAKE) all DEBUG=1
+fpc_release:
+	$(MAKE) all RELEASE=1
+.SUFFIXES: $(EXEEXT) $(PPUEXT) $(OEXT) .pas .pp .rc .res
+%$(PPUEXT): %.pp
+	$(COMPILER) $<
+	$(EXECPPAS)
+%$(PPUEXT): %.pas
+	$(COMPILER) $<
+	$(EXECPPAS)
+%$(EXEEXT): %.pp
+	$(COMPILER) $<
+	$(EXECPPAS)
+%$(EXEEXT): %.pas
+	$(COMPILER) $<
+	$(EXECPPAS)
+%.res: %.rc
+	windres -i $< -o $@
+vpath %.pp $(COMPILER_SOURCEDIR) $(COMPILER_INCLUDEDIR)
+vpath %.pas $(COMPILER_SOURCEDIR) $(COMPILER_INCLUDEDIR)
+vpath %$(PPUEXT) $(COMPILER_UNITTARGETDIR)
+.PHONY: fpc_install fpc_sourceinstall fpc_exampleinstall
+ifdef INSTALL_UNITS
+override INSTALLPPUFILES+=$(addsuffix $(PPUEXT),$(INSTALL_UNITS))
+endif
+ifdef INSTALL_BUILDUNIT
+override INSTALLPPUFILES:=$(filter-out $(INSTALL_BUILDUNIT),$(INSTALLPPUFILES))
+endif
+ifdef INSTALLPPUFILES
+override INSTALLPPULINKFILES:=$(subst $(PPUEXT),$(OEXT),$(INSTALLPPUFILES)) $(addprefix $(STATICLIBPREFIX),$(subst $(PPUEXT),$(STATICLIBEXT),$(INSTALLPPUFILES)))
+override INSTALLPPUFILES:=$(addprefix $(UNITTARGETDIRPREFIX),$(INSTALLPPUFILES))
+override INSTALLPPULINKFILES:=$(wildcard $(addprefix $(UNITTARGETDIRPREFIX),$(INSTALLPPULINKFILES)))
+override INSTALL_CREATEPACKAGEFPC=1
+endif
+ifdef INSTALLEXEFILES
+override INSTALLEXEFILES:=$(addprefix $(TARGETDIRPREFIX),$(INSTALLEXEFILES))
+endif
+fpc_install: all $(INSTALLTARGET)
+ifdef INSTALLEXEFILES
+	$(MKDIR) $(INSTALL_BINDIR)
+ifdef UPXPROG
+	-$(UPXPROG) $(INSTALLEXEFILES)
+endif
+	$(INSTALLEXE) $(INSTALLEXEFILES) $(INSTALL_BINDIR)
+endif
+ifdef INSTALL_CREATEPACKAGEFPC
+ifdef FPCMAKE
+ifdef PACKAGE_VERSION
+ifneq ($(wildcard Makefile.fpc),)
+	$(FPCMAKE) -p -T$(OS_TARGET) Makefile.fpc
+	$(MKDIR) $(INSTALL_UNITDIR)
+	$(INSTALL) Package.fpc $(INSTALL_UNITDIR)
+endif
+endif
+endif
+endif
+ifdef INSTALLPPUFILES
+	$(MKDIR) $(INSTALL_UNITDIR)
+	$(INSTALL) $(INSTALLPPUFILES) $(INSTALL_UNITDIR)
+ifneq ($(INSTALLPPULINKFILES),)
+	$(INSTALL) $(INSTALLPPULINKFILES) $(INSTALL_UNITDIR)
+endif
+ifneq ($(wildcard $(LIB_FULLNAME)),)
+	$(MKDIR) $(INSTALL_LIBDIR)
+	$(INSTALL) $(LIB_FULLNAME) $(INSTALL_LIBDIR)
+ifdef inUnix
+	ln -sf $(LIB_FULLNAME) $(INSTALL_LIBDIR)/$(LIB_NAME)
+endif
+endif
+endif
+ifdef INSTALL_FILES
+	$(MKDIR) $(INSTALL_DATADIR)
+	$(INSTALL) $(INSTALL_FILES) $(INSTALL_DATADIR)
+endif
+fpc_sourceinstall: distclean
+	$(MKDIR) $(INSTALL_SOURCEDIR)
+	$(COPYTREE) $(BASEDIR) $(INSTALL_SOURCEDIR)
+fpc_exampleinstall: $(addsuffix _distclean,$(TARGET_EXAMPLEDIRS))
+ifdef HASEXAMPLES
+	$(MKDIR) $(INSTALL_EXAMPLEDIR)
+endif
+ifdef EXAMPLESOURCEFILES
+	$(COPY) $(EXAMPLESOURCEFILES) $(INSTALL_EXAMPLEDIR)
+endif
+ifdef TARGET_EXAMPLEDIRS
+	$(COPYTREE) $(addsuffix /*,$(TARGET_EXAMPLEDIRS)) $(INSTALL_EXAMPLEDIR)
+endif
+.PHONY: fpc_distinstall
+fpc_distinstall: install exampleinstall
+.PHONY: fpc_zipinstall fpc_zipsourceinstall fpc_zipexampleinstall
+ifndef PACKDIR
+ifndef inUnix
+PACKDIR=$(BASEDIR)/../fpc-pack
+else
+PACKDIR=/tmp/fpc-pack
+endif
+endif
+ifndef ZIPNAME
+ifdef DIST_ZIPNAME
+ZIPNAME=$(DIST_ZIPNAME)
+else
+ZIPNAME=$(ZIPPREFIX)$(PACKAGE_NAME)$(ZIPSUFFIX)
+endif
+endif
+ifndef ZIPTARGET
+ifdef DIST_ZIPTARGET
+ZIPTARGET=DIST_ZIPTARGET
+else
+ZIPTARGET=install
+endif
+endif
+ifndef USEZIP
+ifdef inUnix
+USETAR=1
+endif
+endif
+ifndef inUnix
+USEZIPWRAPPER=1
+endif
+ifdef USEZIPWRAPPER
+ZIPPATHSEP=$(PATHSEP)
+ZIPWRAPPER=$(subst /,$(PATHSEP),$(DIST_DESTDIR)/fpczip$(BATCHEXT))
+else
+ZIPPATHSEP=/
+endif
+ZIPCMD_CDPACK:=cd $(subst /,$(ZIPPATHSEP),$(PACKDIR))
+ZIPCMD_CDBASE:=cd $(subst /,$(ZIPPATHSEP),$(BASEDIR))
+ifdef USETAR
+ZIPDESTFILE:=$(DIST_DESTDIR)/$(ZIPNAME)$(TAREXT)
+ZIPCMD_ZIP:=$(TARPROG) cf$(TAROPT) $(ZIPDESTFILE) *
+else
+ZIPDESTFILE:=$(DIST_DESTDIR)/$(ZIPNAME)$(ZIPEXT)
+ZIPCMD_ZIP:=$(subst /,$(ZIPPATHSEP),$(ZIPPROG)) -Dr $(ZIPOPT) $(ZIPDESTFILE) *
+endif
+fpc_zipinstall:
+	$(MAKE) $(ZIPTARGET) INSTALL_PREFIX=$(PACKDIR) ZIPINSTALL=1
+	$(MKDIR) $(DIST_DESTDIR)
+	$(DEL) $(ZIPDESTFILE)
+ifdef USEZIPWRAPPER
+ifneq ($(ECHOREDIR),echo)
+	$(ECHOREDIR) -e "$(subst \,\\,$(ZIPCMD_CDPACK))" > $(ZIPWRAPPER)
+	$(ECHOREDIR) -e "$(subst \,\\,$(ZIPCMD_ZIP))" >> $(ZIPWRAPPER)
+	$(ECHOREDIR) -e "$(subst \,\\,$(ZIPCMD_CDBASE))" >> $(ZIPWRAPPER)
+else
+	echo $(ZIPCMD_CDPACK) > $(ZIPWRAPPER)
+	echo $(ZIPCMD_ZIP) >> $(ZIPWRAPPER)
+	echo $(ZIPCMD_CDBASE) >> $(ZIPWRAPPER)
+endif
+ifdef inUnix
+	/bin/sh $(ZIPWRAPPER)
+else
+	$(ZIPWRAPPER)
+endif
+	$(DEL) $(ZIPWRAPPER)
+else
+	$(ZIPCMD_CDPACK) ; $(ZIPCMD_ZIP) ; $(ZIPCMD_CDBASE)
+endif
+	$(DELTREE) $(PACKDIR)
+fpc_zipsourceinstall:
+	$(MAKE) fpc_zipinstall ZIPTARGET=sourceinstall ZIPSUFFIX=src
+fpc_zipexampleinstall:
+ifdef HASEXAMPLES
+	$(MAKE) fpc_zipinstall ZIPTARGET=exampleinstall ZIPSUFFIX=exm
+endif
+fpc_zipdistinstall:
+	$(MAKE) fpc_zipinstall ZIPTARGET=distinstall
+.PHONY: fpc_clean fpc_cleanall fpc_distclean
+ifdef EXEFILES
+override CLEANEXEFILES:=$(addprefix $(TARGETDIRPREFIX),$(CLEANEXEFILES))
+endif
+ifdef CLEAN_UNITS
+override CLEANPPUFILES+=$(addsuffix $(PPUEXT),$(CLEAN_UNITS))
+endif
+ifdef CLEANPPUFILES
+override CLEANPPULINKFILES:=$(subst $(PPUEXT),$(OEXT),$(CLEANPPUFILES)) $(addprefix $(STATICLIBPREFIX),$(subst $(PPUEXT),$(STATICLIBEXT),$(CLEANPPUFILES)))
+override CLEANPPUFILES:=$(addprefix $(UNITTARGETDIRPREFIX),$(CLEANPPUFILES))
+override CLEANPPULINKFILES:=$(wildcard $(addprefix $(UNITTARGETDIRPREFIX),$(CLEANPPULINKFILES)))
+endif
+fpc_clean: $(CLEANTARGET)
+ifdef CLEANEXEFILES
+	-$(DEL) $(CLEANEXEFILES)
+endif
+ifdef CLEANPPUFILES
+	-$(DEL) $(CLEANPPUFILES)
+endif
+ifneq ($(CLEANPPULINKFILES),)
+	-$(DEL) $(CLEANPPULINKFILES)
+endif
+ifdef CLEANRSTFILES
+	-$(DEL) $(addprefix $(UNITTARGETDIRPREFIX),$(CLEANRSTFILES))
+endif
+ifdef CLEAN_FILES
+	-$(DEL) $(CLEAN_FILES)
+endif
+ifdef LIB_NAME
+	-$(DEL) $(LIB_NAME) $(LIB_FULLNAME)
+endif
+	-$(DEL) $(FPCMADE) Package.fpc $(PPAS) script.res link.res $(FPCEXTFILE) $(REDIRFILE)
+fpc_distclean: clean
+ifdef COMPILER_UNITTARGETDIR
+TARGETDIRCLEAN=fpc_clean
+endif
+fpc_cleanall: $(CLEANTARGET) $(TARGETDIRCLEAN)
+ifdef CLEANEXEFILES
+	-$(DEL) $(CLEANEXEFILES)
+endif
+	-$(DEL) *$(OEXT) *$(PPUEXT) *$(RSTEXT) *$(ASMEXT) *$(STATICLIBEXT) *$(SHAREDLIBEXT) *$(PPLEXT)
+	-$(DELTREE) *$(SMARTEXT)
+	-$(DEL) $(FPCMADE) Package.fpc $(PPAS) script.res link.res $(FPCEXTFILE) $(REDIRFILE)
+ifdef AOUTEXT
+	-$(DEL) *$(AOUTEXT)
+endif
+.PHONY: fpc_baseinfo
+override INFORULES+=fpc_baseinfo
+fpc_baseinfo:
+	@$(ECHO)
+	@$(ECHO)  == Package info ==
+	@$(ECHO)  Package Name..... $(PACKAGE_NAME)
+	@$(ECHO)  Package Version.. $(PACKAGE_VERSION)
+	@$(ECHO)
+	@$(ECHO)  == Configuration info ==
+	@$(ECHO)
+	@$(ECHO)  FPC.......... $(FPC)
+	@$(ECHO)  FPC Version.. $(FPC_VERSION)
+	@$(ECHO)  Source CPU... $(CPU_SOURCE)
+	@$(ECHO)  Target CPU... $(CPU_TARGET)
+	@$(ECHO)  Source OS.... $(OS_SOURCE)
+	@$(ECHO)  Target OS.... $(OS_TARGET)
+	@$(ECHO)  Full Target.. $(FULL_SOURCE)
+	@$(ECHO)  Full Source.. $(FULL_TARGET)
+	@$(ECHO)
+	@$(ECHO)  == Directory info ==
+	@$(ECHO)
+	@$(ECHO)  Required pkgs... $(REQUIRE_PACKAGES)
+	@$(ECHO)
+	@$(ECHO)  Basedir......... $(BASEDIR)
+	@$(ECHO)  FPCDir.......... $(FPCDIR)
+	@$(ECHO)  CrossBinDir..... $(CROSSBINDIR)
+	@$(ECHO)  UnitsDir........ $(UNITSDIR)
+	@$(ECHO)  PackagesDir..... $(PACKAGESDIR)
+	@$(ECHO)
+	@$(ECHO)  GCC library..... $(GCCLIBDIR)
+	@$(ECHO)  Other library... $(OTHERLIBDIR)
+	@$(ECHO)
+	@$(ECHO)  == Tools info ==
+	@$(ECHO)
+	@$(ECHO)  As........ $(AS)
+	@$(ECHO)  Ld........ $(LD)
+	@$(ECHO)  Ar........ $(AR)
+	@$(ECHO)  Rc........ $(RC)
+	@$(ECHO)
+	@$(ECHO)  Mv........ $(MVPROG)
+	@$(ECHO)  Cp........ $(CPPROG)
+	@$(ECHO)  Rm........ $(RMPROG)
+	@$(ECHO)  GInstall.. $(GINSTALL)
+	@$(ECHO)  Echo...... $(ECHO)
+	@$(ECHO)  Date...... $(DATE)
+	@$(ECHO)  FPCMake... $(FPCMAKE)
+	@$(ECHO)  PPUMove... $(PPUMOVE)
+	@$(ECHO)  Upx....... $(UPXPROG)
+	@$(ECHO)  Zip....... $(ZIPPROG)
+	@$(ECHO)
+	@$(ECHO)  == Object info ==
+	@$(ECHO)
+	@$(ECHO)  Target Loaders........ $(TARGET_LOADERS)
+	@$(ECHO)  Target Units.......... $(TARGET_UNITS)
+	@$(ECHO)  Target Implicit Units. $(TARGET_IMPLICITUNITS)
+	@$(ECHO)  Target Programs....... $(TARGET_PROGRAMS)
+	@$(ECHO)  Target Dirs........... $(TARGET_DIRS)
+	@$(ECHO)  Target Examples....... $(TARGET_EXAMPLES)
+	@$(ECHO)  Target ExampleDirs.... $(TARGET_EXAMPLEDIRS)
+	@$(ECHO)
+	@$(ECHO)  Clean Units......... $(CLEAN_UNITS)
+	@$(ECHO)  Clean Files......... $(CLEAN_FILES)
+	@$(ECHO)
+	@$(ECHO)  Install Units....... $(INSTALL_UNITS)
+	@$(ECHO)  Install Files....... $(INSTALL_FILES)
+	@$(ECHO)
+	@$(ECHO)  == Install info ==
+	@$(ECHO)
+	@$(ECHO)  DateStr.............. $(DATESTR)
+	@$(ECHO)  ZipPrefix............ $(ZIPPREFIX)
+	@$(ECHO)  ZipSuffix............ $(ZIPSUFFIX)
+	@$(ECHO)  Install FPC Package.. $(INSTALL_FPCPACKAGE)
+	@$(ECHO)
+	@$(ECHO)  Install base dir..... $(INSTALL_BASEDIR)
+	@$(ECHO)  Install binary dir... $(INSTALL_BINDIR)
+	@$(ECHO)  Install library dir.. $(INSTALL_LIBDIR)
+	@$(ECHO)  Install units dir.... $(INSTALL_UNITDIR)
+	@$(ECHO)  Install source dir... $(INSTALL_SOURCEDIR)
+	@$(ECHO)  Install doc dir...... $(INSTALL_DOCDIR)
+	@$(ECHO)  Install example dir.. $(INSTALL_EXAMPLEDIR)
+	@$(ECHO)  Install data dir..... $(INSTALL_DATADIR)
+	@$(ECHO)
+	@$(ECHO)  Dist destination dir. $(DIST_DESTDIR)
+	@$(ECHO)  Dist zip name........ $(DIST_ZIPNAME)
+	@$(ECHO)
+.PHONY: fpc_info
+fpc_info: $(INFORULES)
+.PHONY: fpc_makefile fpc_makefiles fpc_makefile_sub1 fpc_makefile_sub2 \
+	fpc_makefile_dirs
+fpc_makefile:
+	$(FPCMAKE) -w -T$(OS_TARGET) Makefile.fpc
+fpc_makefile_sub1:
+ifdef TARGET_DIRS
+	$(FPCMAKE) -w -T$(OS_TARGET) $(addsuffix /Makefile.fpc,$(TARGET_DIRS))
+endif
+ifdef TARGET_EXAMPLEDIRS
+	$(FPCMAKE) -w -T$(OS_TARGET) $(addsuffix /Makefile.fpc,$(TARGET_EXAMPLEDIRS))
+endif
+fpc_makefile_sub2: $(addsuffix _makefile_dirs,$(TARGET_DIRS) $(TARGET_EXAMPLEDIRS))
+fpc_makefile_dirs: fpc_makefile_sub1 fpc_makefile_sub2
+fpc_makefiles: fpc_makefile fpc_makefile_dirs
+all: fpc_all
+debug: fpc_debug
+smart: fpc_smart
+release: fpc_release
+examples: fpc_examples
+shared:
+install: fpc_install
+sourceinstall: fpc_sourceinstall
+exampleinstall: fpc_exampleinstall
+distinstall: fpc_distinstall
+zipinstall: fpc_zipinstall
+zipsourceinstall: fpc_zipsourceinstall
+zipexampleinstall: fpc_zipexampleinstall
+zipdistinstall: fpc_zipdistinstall
+clean: fpc_clean
+distclean: fpc_distclean
+cleanall: fpc_cleanall
+info: fpc_info
+makefiles: fpc_makefiles
+.PHONY: all debug smart release examples shared install sourceinstall exampleinstall distinstall zipinstall zipsourceinstall zipexampleinstall zipdistinstall clean distclean cleanall info makefiles
+ifneq ($(wildcard fpcmake.loc),)
+include fpcmake.loc
+endif

+ 17 - 0
packages/extra/cmem/Makefile.fpc

@@ -0,0 +1,17 @@
+#
+#   Makefile.fpc for C Memory Manager
+#
+
+[package]
+name=cmem
+version=1.0.6
+
+[target]
+units=cmem
+examples=testcmem
+
+[install]
+fpcpackage=y
+
+[default]
+fpcdir=../../..

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