Browse Source

* LibUSB headers from Anton Kavalenka (Bug ID 31095)

git-svn-id: trunk@35599 -
michael 8 years ago
parent
commit
5ca540f3c7

+ 4 - 0
.gitattributes

@@ -5836,6 +5836,10 @@ packages/libtar/Makefile svneol=native#text/plain
 packages/libtar/Makefile.fpc svneol=native#text/plain
 packages/libtar/fpmake.pp svneol=native#text/plain
 packages/libtar/src/libtar.pp svneol=native#text/plain
+packages/libusb/Makefile svneol=native#text/plain
+packages/libusb/Makefile.fpc svneol=native#text/plain
+packages/libusb/fpmake.pp svneol=native#text/plain
+packages/libusb/src/libusb.pp svneol=native#text/plain
 packages/libvlc/Makefile svneol=native#text/plain
 packages/libvlc/Makefile.fpc svneol=native#text/plain
 packages/libvlc/example/testvlc.lpi svneol=native#text/plain

+ 1 - 0
packages/fpmake_add.inc

@@ -68,6 +68,7 @@
   add_libpng(ADirectory+IncludeTrailingPathDelimiter('libpng'));
   add_librsvg(ADirectory+IncludeTrailingPathDelimiter('librsvg'));
   add_libsee(ADirectory+IncludeTrailingPathDelimiter('libsee'));
+  add_libusb(ADirectory+IncludeTrailingPathDelimiter('libusb'));
   add_libtar(ADirectory+IncludeTrailingPathDelimiter('libtar'));
   add_libvlc(ADirectory+IncludeTrailingPathDelimiter('libvlc'));
   add_libxml(ADirectory+IncludeTrailingPathDelimiter('libxml'));

+ 6 - 0
packages/fpmake_proc.inc

@@ -392,6 +392,12 @@ begin
 {$include libsee/fpmake.pp}
 end;
 
+procedure add_libusb(const ADirectory: string);
+begin
+  with Installer do
+{$include libusb/fpmake.pp}
+end;
+
 procedure add_libtar(const ADirectory: string);
 begin
   with Installer do

+ 1926 - 0
packages/libusb/Makefile

@@ -0,0 +1,1926 @@
+#
+# Don't edit, this file is generated by FPCMake Version 2.0.0 [2016-11-06 rev 34805]
+#
+default: all
+MAKEFILETARGETS=i386-linux i386-win32 m68k-linux powerpc-linux sparc-linux x86_64-linux x86_64-win64 arm-linux powerpc64-linux armeb-linux mips-linux mipsel-linux aarch64-linux
+BSDs = freebsd netbsd openbsd darwin dragonfly
+UNIXs = linux $(BSDs) solaris qnx haiku aix
+LIMIT83fs = go32v2 os2 emx watcom msdos win16
+OSNeedsComspecToRunBatch = go32v2 watcom
+FORCE:
+.PHONY: FORCE
+override PATH:=$(patsubst %/,%,$(subst \,/,$(PATH)))
+ifneq ($(findstring darwin,$(OSTYPE)),)
+inUnix=1 #darwin
+SEARCHPATH:=$(filter-out .,$(subst :, ,$(PATH)))
+else
+ifeq ($(findstring ;,$(PATH)),)
+inUnix=1
+SEARCHPATH:=$(filter-out .,$(subst :, ,$(PATH)))
+else
+SEARCHPATH:=$(subst ;, ,$(PATH))
+endif
+endif
+SEARCHPATH+=$(patsubst %/,%,$(subst \,/,$(dir $(MAKE))))
+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 cygdrive,$(PATH)),)
+inCygWin=1
+endif
+endif
+ifdef inUnix
+SRCBATCHEXT=.sh
+else
+ifdef inOS2
+SRCBATCHEXT=.cmd
+else
+SRCBATCHEXT=.bat
+endif
+endif
+ifdef COMSPEC
+ifneq ($(findstring $(OS_SOURCE),$(OSNeedsComspecToRunBatch)),)
+ifndef RUNBATCH
+RUNBATCH=$(COMSPEC) /C
+endif
+endif
+endif
+ifdef inUnix
+PATHSEP=/
+else
+PATHSEP:=$(subst /,\,/)
+ifdef inCygWin
+PATHSEP=/
+endif
+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
+ifdef inOS2
+ifndef ECHO
+ECHO:=$(strip $(wildcard $(addsuffix /gecho$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(ECHO),)
+ECHO:=$(strip $(wildcard $(addsuffix /echo$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(ECHO),)
+ECHO=echo
+else
+ECHO:=$(firstword $(ECHO))
+endif
+else
+ECHO:=$(firstword $(ECHO))
+endif
+endif
+export ECHO
+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))
+ifneq ($(CPU_TARGET),)
+FPC:=$(shell $(FPCPROG) -P$(CPU_TARGET) -PB)
+else
+FPC:=$(shell $(FPCPROG) -PB)
+endif
+ifneq ($(findstring Error,$(FPC)),)
+override FPC=$(firstword $(strip $(wildcard $(addsuffix /ppc386$(SRCEXEEXT),$(SEARCHPATH)))))
+else
+ifeq ($(strip $(wildcard $(FPC))),)
+FPC:=$(firstword $(FPCPROG))
+endif
+endif
+else
+override FPC=$(firstword $(strip $(wildcard $(addsuffix /ppc386$(SRCEXEEXT),$(SEARCHPATH)))))
+endif
+endif
+override FPC:=$(subst $(SRCEXEEXT),,$(FPC))
+override FPC:=$(subst \,/,$(FPC))$(SRCEXEEXT)
+FOUNDFPC:=$(strip $(wildcard $(FPC)))
+ifeq ($(FOUNDFPC),)
+FOUNDFPC=$(strip $(wildcard $(addsuffix /$(FPC),$(SEARCHPATH))))
+ifeq ($(FOUNDFPC),)
+$(error Compiler $(FPC) not found)
+endif
+endif
+ifndef FPC_COMPILERINFO
+FPC_COMPILERINFO:=$(shell $(FPC) -iVSPTPSOTO)
+endif
+ifndef FPC_VERSION
+FPC_VERSION:=$(word 1,$(FPC_COMPILERINFO))
+endif
+export FPC FPC_VERSION FPC_COMPILERINFO
+unexport CHECKDEPEND ALLDEPENDENCIES
+ifndef CPU_TARGET
+ifdef CPU_TARGET_DEFAULT
+CPU_TARGET=$(CPU_TARGET_DEFAULT)
+endif
+endif
+ifndef OS_TARGET
+ifdef OS_TARGET_DEFAULT
+OS_TARGET=$(OS_TARGET_DEFAULT)
+endif
+endif
+ifndef CPU_SOURCE
+CPU_SOURCE:=$(word 2,$(FPC_COMPILERINFO))
+endif
+ifndef CPU_TARGET
+CPU_TARGET:=$(word 3,$(FPC_COMPILERINFO))
+endif
+ifndef OS_SOURCE
+OS_SOURCE:=$(word 4,$(FPC_COMPILERINFO))
+endif
+ifndef OS_TARGET
+OS_TARGET:=$(word 5,$(FPC_COMPILERINFO))
+endif
+FULL_TARGET=$(CPU_TARGET)-$(OS_TARGET)
+FULL_SOURCE=$(CPU_SOURCE)-$(OS_SOURCE)
+ifeq ($(CPU_TARGET),armeb)
+ARCH=arm
+override FPCOPT+=-Cb
+else
+ifeq ($(CPU_TARGET),armel)
+ARCH=arm
+override FPCOPT+=-CaEABI
+else
+ARCH=$(CPU_TARGET)
+endif
+endif
+ifeq ($(FULL_TARGET),arm-embedded)
+ifeq ($(SUBARCH),)
+$(error When compiling for arm-embedded, a sub-architecture (e.g. SUBARCH=armv4t or SUBARCH=armv7m) must be defined)
+endif
+override FPCOPT+=-Cp$(SUBARCH)
+endif
+ifeq ($(FULL_TARGET),avr-embedded)
+ifeq ($(SUBARCH),)
+$(error When compiling for avr-embedded, a sub-architecture (e.g. SUBARCH=avr25 or SUBARCH=avr35) must be defined)
+endif
+override FPCOPT+=-Cp$(SUBARCH)
+endif
+ifeq ($(FULL_TARGET),mipsel-embedded)
+ifeq ($(SUBARCH),)
+$(error When compiling for mipsel-embedded, a sub-architecture (e.g. SUBARCH=pic32mx) must be defined)
+endif
+override FPCOPT+=-Cp$(SUBARCH)
+endif
+ifneq ($(findstring $(OS_SOURCE),$(LIMIT83fs)),)
+TARGETSUFFIX=$(OS_TARGET)
+SOURCESUFFIX=$(OS_SOURCE)
+else
+ifneq ($(findstring $(OS_TARGET),$(LIMIT83fs)),)
+TARGETSUFFIX=$(OS_TARGET)
+else
+TARGETSUFFIX=$(FULL_TARGET)
+endif
+SOURCESUFFIX=$(FULL_SOURCE)
+endif
+ifneq ($(FULL_TARGET),$(FULL_SOURCE))
+CROSSCOMPILE=1
+endif
+ifeq ($(findstring makefile,$(MAKECMDGOALS)),)
+ifeq ($(findstring $(FULL_TARGET),$(MAKEFILETARGETS)),)
+$(error The Makefile doesn't support target $(FULL_TARGET), please run fpcmake first)
+endif
+endif
+ifneq ($(findstring $(OS_TARGET),$(BSDs)),)
+BSDhier=1
+endif
+ifeq ($(OS_TARGET),linux)
+linuxHier=1
+endif
+ifndef CROSSCOMPILE
+BUILDFULLNATIVE=1
+export BUILDFULLNATIVE
+endif
+ifdef BUILDFULLNATIVE
+BUILDNATIVE=1
+export BUILDNATIVE
+endif
+export OS_TARGET OS_SOURCE ARCH CPU_TARGET CPU_SOURCE FULL_TARGET FULL_SOURCE TARGETSUFFIX SOURCESUFFIX 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:=$(BASEDIR)
+ifeq ($(wildcard $(addprefix $(FPCDIR)/,rtl units)),)
+override FPCDIR=c:/pp
+endif
+endif
+endif
+endif
+endif
+ifndef CROSSBINDIR
+CROSSBINDIR:=$(wildcard $(FPCDIR)/bin/$(TARGETSUFFIX))
+endif
+ifneq ($(findstring $(OS_TARGET),darwin iphonesim),)
+ifeq ($(OS_SOURCE),darwin)
+DARWIN2DARWIN=1
+endif
+endif
+ifndef BINUTILSPREFIX
+ifndef CROSSBINDIR
+ifdef CROSSCOMPILE
+ifneq ($(OS_TARGET),msdos)
+ifndef DARWIN2DARWIN
+ifneq ($(CPU_TARGET),jvm)
+BINUTILSPREFIX=$(CPU_TARGET)-$(OS_TARGET)-
+ifeq ($(OS_TARGET),android)
+ifeq ($(CPU_TARGET),arm)
+BINUTILSPREFIX=arm-linux-androideabi-
+else
+ifeq ($(CPU_TARGET),i386)
+BINUTILSPREFIX=i686-linux-android-
+else
+ifeq ($(CPU_TARGET),mipsel)
+BINUTILSPREFIX=mipsel-linux-android-
+endif
+endif
+endif
+endif
+endif
+endif
+else
+BINUTILSPREFIX=$(OS_TARGET)-
+endif
+endif
+endif
+endif
+UNITSDIR:=$(wildcard $(FPCDIR)/units/$(TARGETSUFFIX))
+ifeq ($(UNITSDIR),)
+UNITSDIR:=$(wildcard $(FPCDIR)/units/$(OS_TARGET))
+endif
+PACKAGESDIR:=$(wildcard $(FPCDIR) $(FPCDIR)/packages $(FPCDIR)/packages/base $(FPCDIR)/packages/extra)
+ifndef FPCFPMAKE
+ifdef CROSSCOMPILE
+ifeq ($(strip $(wildcard $(addsuffix /compiler/ppc$(SRCEXEEXT),$(FPCDIR)))),)
+FPCPROG:=$(strip $(wildcard $(addsuffix /fpc$(SRCEXEEXT),$(SEARCHPATH))))
+ifneq ($(FPCPROG),)
+FPCPROG:=$(firstword $(FPCPROG))
+FPCFPMAKE:=$(shell $(FPCPROG) -PB)
+ifeq ($(strip $(wildcard $(FPCFPMAKE))),)
+FPCFPMAKE:=$(firstword $(FPCPROG))
+endif
+else
+override FPCFPMAKE=$(firstword $(strip $(wildcard $(addsuffix /ppc386$(SRCEXEEXT),$(SEARCHPATH)))))
+endif
+else
+FPCFPMAKE=$(strip $(wildcard $(addsuffix /compiler/ppc$(SRCEXEEXT),$(FPCDIR))))
+FPMAKE_SKIP_CONFIG=-n
+export FPCFPMAKE
+export FPMAKE_SKIP_CONFIG
+endif
+else
+FPMAKE_SKIP_CONFIG=-n
+FPCFPMAKE=$(FPC)
+endif
+endif
+override PACKAGE_NAME=libusb
+override PACKAGE_VERSION=3.1.1
+FPMAKE_BIN_CLEAN=$(wildcard ./fpmake$(SRCEXEEXT))
+ifdef OS_TARGET
+FPC_TARGETOPT+=--os=$(OS_TARGET)
+endif
+ifdef CPU_TARGET
+FPC_TARGETOPT+=--cpu=$(CPU_TARGET)
+endif
+LOCALFPMAKE=./fpmake$(SRCEXEEXT)
+override INSTALL_FPCPACKAGE=y
+ifdef REQUIRE_UNITSDIR
+override UNITSDIR+=$(REQUIRE_UNITSDIR)
+endif
+ifdef REQUIRE_PACKAGESDIR
+override PACKAGESDIR+=$(REQUIRE_PACKAGESDIR)
+endif
+ifdef ZIPINSTALL
+ifneq ($(findstring $(OS_TARGET),$(UNIXs)),)
+UNIXHier=1
+endif
+else
+ifneq ($(findstring $(OS_SOURCE),$(UNIXs)),)
+UNIXHier=1
+endif
+endif
+ifndef INSTALL_PREFIX
+ifdef PREFIX
+INSTALL_PREFIX=$(PREFIX)
+endif
+endif
+ifndef INSTALL_PREFIX
+ifdef UNIXHier
+INSTALL_PREFIX=/usr/local
+else
+ifdef INSTALL_FPCPACKAGE
+INSTALL_BASEDIR:=/pp
+else
+INSTALL_BASEDIR:=/$(PACKAGE_NAME)
+endif
+endif
+endif
+export INSTALL_PREFIX
+ifdef INSTALL_FPCSUBDIR
+export INSTALL_FPCSUBDIR
+endif
+ifndef DIST_DESTDIR
+DIST_DESTDIR:=$(BASEDIR)
+endif
+export DIST_DESTDIR
+ifndef COMPILER_UNITTARGETDIR
+ifdef PACKAGEDIR_MAIN
+COMPILER_UNITTARGETDIR=$(PACKAGEDIR_MAIN)/units/$(TARGETSUFFIX)
+else
+COMPILER_UNITTARGETDIR=units/$(TARGETSUFFIX)
+endif
+endif
+ifndef COMPILER_TARGETDIR
+COMPILER_TARGETDIR=.
+endif
+ifndef INSTALL_BASEDIR
+ifdef UNIXHier
+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 UNIXHier
+INSTALL_BINDIR:=$(INSTALL_PREFIX)/bin
+else
+INSTALL_BINDIR:=$(INSTALL_BASEDIR)/bin
+ifdef INSTALL_FPCPACKAGE
+ifdef CROSSCOMPILE
+ifdef CROSSINSTALL
+INSTALL_BINDIR:=$(INSTALL_BINDIR)/$(SOURCESUFFIX)
+else
+INSTALL_BINDIR:=$(INSTALL_BINDIR)/$(TARGETSUFFIX)
+endif
+else
+INSTALL_BINDIR:=$(INSTALL_BINDIR)/$(TARGETSUFFIX)
+endif
+endif
+endif
+endif
+ifndef INSTALL_UNITDIR
+INSTALL_UNITDIR:=$(INSTALL_BASEDIR)/units/$(TARGETSUFFIX)
+ifdef INSTALL_FPCPACKAGE
+ifdef PACKAGE_NAME
+INSTALL_UNITDIR:=$(INSTALL_UNITDIR)/$(PACKAGE_NAME)
+endif
+endif
+endif
+ifndef INSTALL_LIBDIR
+ifdef UNIXHier
+INSTALL_LIBDIR:=$(INSTALL_PREFIX)/lib
+else
+INSTALL_LIBDIR:=$(INSTALL_UNITDIR)
+endif
+endif
+ifndef INSTALL_SOURCEDIR
+ifdef UNIXHier
+ifdef BSDhier
+SRCPREFIXDIR=share/src
+else
+ifdef linuxHier
+SRCPREFIXDIR=share/src
+else
+SRCPREFIXDIR=src
+endif
+endif
+ifdef INSTALL_FPCPACKAGE
+ifdef INSTALL_FPCSUBDIR
+INSTALL_SOURCEDIR:=$(INSTALL_PREFIX)/$(SRCPREFIXDIR)/fpc-$(FPC_VERSION)/$(INSTALL_FPCSUBDIR)/$(PACKAGE_NAME)
+else
+INSTALL_SOURCEDIR:=$(INSTALL_PREFIX)/$(SRCPREFIXDIR)/fpc-$(FPC_VERSION)/$(PACKAGE_NAME)
+endif
+else
+INSTALL_SOURCEDIR:=$(INSTALL_PREFIX)/$(SRCPREFIXDIR)/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
+endif
+else
+ifdef INSTALL_FPCPACKAGE
+ifdef INSTALL_FPCSUBDIR
+INSTALL_SOURCEDIR:=$(INSTALL_BASEDIR)/source/$(INSTALL_FPCSUBDIR)/$(PACKAGE_NAME)
+else
+INSTALL_SOURCEDIR:=$(INSTALL_BASEDIR)/source/$(PACKAGE_NAME)
+endif
+else
+INSTALL_SOURCEDIR:=$(INSTALL_BASEDIR)/source
+endif
+endif
+endif
+ifndef INSTALL_DOCDIR
+ifdef UNIXHier
+ifdef BSDhier
+DOCPREFIXDIR=share/doc
+else
+ifdef linuxHier
+DOCPREFIXDIR=share/doc
+else
+DOCPREFIXDIR=doc
+endif
+endif
+ifdef INSTALL_FPCPACKAGE
+INSTALL_DOCDIR:=$(INSTALL_PREFIX)/$(DOCPREFIXDIR)/fpc-$(FPC_VERSION)/$(PACKAGE_NAME)
+else
+INSTALL_DOCDIR:=$(INSTALL_PREFIX)/$(DOCPREFIXDIR)/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
+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 UNIXHier
+ifdef INSTALL_FPCPACKAGE
+ifdef BSDhier
+INSTALL_EXAMPLEDIR:=$(INSTALL_PREFIX)/share/examples/fpc-$(FPC_VERSION)/$(PACKAGE_NAME)
+else
+ifdef linuxHier
+INSTALL_EXAMPLEDIR:=$(INSTALL_DOCDIR)/examples
+else
+INSTALL_EXAMPLEDIR:=$(INSTALL_PREFIX)/doc/fpc-$(FPC_VERSION)/examples/$(PACKAGE_NAME)
+endif
+endif
+else
+ifdef BSDhier
+INSTALL_EXAMPLEDIR:=$(INSTALL_PREFIX)/share/examples/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
+else
+ifdef linuxHier
+INSTALL_EXAMPLEDIR:=$(INSTALL_DOCDIR)/examples/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
+else
+INSTALL_EXAMPLEDIR:=$(INSTALL_PREFIX)/doc/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
+endif
+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
+ifndef INSTALL_SHAREDDIR
+INSTALL_SHAREDDIR=$(INSTALL_PREFIX)/lib
+endif
+ifdef CROSSCOMPILE
+ifndef CROSSBINDIR
+CROSSBINDIR:=$(wildcard $(CROSSTARGETDIR)/bin/$(SOURCESUFFIX))
+ifeq ($(CROSSBINDIR),)
+CROSSBINDIR:=$(wildcard $(INSTALL_BASEDIR)/cross/$(TARGETSUFFIX)/bin/$(FULL_SOURCE))
+endif
+endif
+else
+CROSSBINDIR=
+endif
+BATCHEXT=.bat
+LOADEREXT=.as
+EXEEXT=.exe
+PPLEXT=.ppl
+PPUEXT=.ppu
+OEXT=.o
+ASMEXT=.s
+SMARTEXT=.sl
+STATICLIBEXT=.a
+SHAREDLIBEXT=.so
+SHAREDLIBPREFIX=libfp
+STATICLIBPREFIX=libp
+IMPORTLIBPREFIX=libimp
+RSTEXT=.rst
+EXEDBGEXT=.dbg
+ifeq ($(OS_TARGET),go32v1)
+STATICLIBPREFIX=
+SHORTSUFFIX=v1
+endif
+ifeq ($(OS_TARGET),go32v2)
+STATICLIBPREFIX=
+SHORTSUFFIX=dos
+IMPORTLIBPREFIX=
+endif
+ifeq ($(OS_TARGET),watcom)
+STATICLIBPREFIX=
+OEXT=.obj
+ASMEXT=.asm
+SHAREDLIBEXT=.dll
+SHORTSUFFIX=wat
+IMPORTLIBPREFIX=
+endif
+ifneq ($(CPU_TARGET),jvm)
+ifeq ($(OS_TARGET),android)
+BATCHEXT=.sh
+EXEEXT=
+HASSHAREDLIB=1
+SHORTSUFFIX=lnx
+endif
+endif
+ifeq ($(OS_TARGET),linux)
+BATCHEXT=.sh
+EXEEXT=
+HASSHAREDLIB=1
+SHORTSUFFIX=lnx
+endif
+ifeq ($(OS_TARGET),dragonfly)
+BATCHEXT=.sh
+EXEEXT=
+HASSHAREDLIB=1
+SHORTSUFFIX=df
+endif
+ifeq ($(OS_TARGET),freebsd)
+BATCHEXT=.sh
+EXEEXT=
+HASSHAREDLIB=1
+SHORTSUFFIX=fbs
+endif
+ifeq ($(OS_TARGET),netbsd)
+BATCHEXT=.sh
+EXEEXT=
+HASSHAREDLIB=1
+SHORTSUFFIX=nbs
+endif
+ifeq ($(OS_TARGET),openbsd)
+BATCHEXT=.sh
+EXEEXT=
+HASSHAREDLIB=1
+SHORTSUFFIX=obs
+endif
+ifeq ($(OS_TARGET),win32)
+SHAREDLIBEXT=.dll
+SHORTSUFFIX=w32
+endif
+ifeq ($(OS_TARGET),os2)
+BATCHEXT=.cmd
+AOUTEXT=.out
+STATICLIBPREFIX=
+SHAREDLIBEXT=.dll
+SHORTSUFFIX=os2
+ECHO=echo
+IMPORTLIBPREFIX=
+endif
+ifeq ($(OS_TARGET),emx)
+BATCHEXT=.cmd
+AOUTEXT=.out
+STATICLIBPREFIX=
+SHAREDLIBEXT=.dll
+SHORTSUFFIX=emx
+ECHO=echo
+IMPORTLIBPREFIX=
+endif
+ifeq ($(OS_TARGET),amiga)
+EXEEXT=
+SHAREDLIBEXT=.library
+SHORTSUFFIX=amg
+endif
+ifeq ($(OS_TARGET),aros)
+EXEEXT=
+SHAREDLIBEXT=.library
+SHORTSUFFIX=aros
+endif
+ifeq ($(OS_TARGET),morphos)
+EXEEXT=
+SHAREDLIBEXT=.library
+SHORTSUFFIX=mos
+endif
+ifeq ($(OS_TARGET),atari)
+EXEEXT=.ttp
+SHORTSUFFIX=ata
+endif
+ifeq ($(OS_TARGET),beos)
+BATCHEXT=.sh
+EXEEXT=
+SHORTSUFFIX=be
+endif
+ifeq ($(OS_TARGET),haiku)
+BATCHEXT=.sh
+EXEEXT=
+SHORTSUFFIX=hai
+endif
+ifeq ($(OS_TARGET),solaris)
+BATCHEXT=.sh
+EXEEXT=
+SHORTSUFFIX=sun
+endif
+ifeq ($(OS_TARGET),qnx)
+BATCHEXT=.sh
+EXEEXT=
+SHORTSUFFIX=qnx
+endif
+ifeq ($(OS_TARGET),netware)
+EXEEXT=.nlm
+STATICLIBPREFIX=
+SHORTSUFFIX=nw
+IMPORTLIBPREFIX=imp
+endif
+ifeq ($(OS_TARGET),netwlibc)
+EXEEXT=.nlm
+STATICLIBPREFIX=
+SHORTSUFFIX=nwl
+IMPORTLIBPREFIX=imp
+endif
+ifeq ($(OS_TARGET),macos)
+BATCHEXT=
+EXEEXT=
+DEBUGSYMEXT=.xcoff
+SHORTSUFFIX=mac
+IMPORTLIBPREFIX=imp
+endif
+ifneq ($(findstring $(OS_TARGET),darwin iphonesim),)
+BATCHEXT=.sh
+EXEEXT=
+HASSHAREDLIB=1
+SHORTSUFFIX=dwn
+EXEDBGEXT=.dSYM
+endif
+ifeq ($(OS_TARGET),gba)
+EXEEXT=.gba
+SHAREDLIBEXT=.so
+SHORTSUFFIX=gba
+endif
+ifeq ($(OS_TARGET),symbian)
+SHAREDLIBEXT=.dll
+SHORTSUFFIX=symbian
+endif
+ifeq ($(OS_TARGET),NativeNT)
+SHAREDLIBEXT=.dll
+SHORTSUFFIX=nativent
+endif
+ifeq ($(OS_TARGET),wii)
+EXEEXT=.dol
+SHAREDLIBEXT=.so
+SHORTSUFFIX=wii
+endif
+ifeq ($(OS_TARGET),aix)
+BATCHEXT=.sh
+EXEEXT=
+SHORTSUFFIX=aix
+endif
+ifeq ($(OS_TARGET),java)
+OEXT=.class
+ASMEXT=.j
+SHAREDLIBEXT=.jar
+SHORTSUFFIX=java
+endif
+ifeq ($(CPU_TARGET),jvm)
+ifeq ($(OS_TARGET),android)
+OEXT=.class
+ASMEXT=.j
+SHAREDLIBEXT=.jar
+SHORTSUFFIX=android
+endif
+endif
+ifeq ($(OS_TARGET),msdos)
+STATICLIBPREFIX=
+STATICLIBEXT=.a
+SHORTSUFFIX=d16
+endif
+ifeq ($(OS_TARGET),embedded)
+ifeq ($(CPU_TARGET),i8086)
+STATICLIBPREFIX=
+STATICLIBEXT=.a
+else
+EXEEXT=.bin
+endif
+SHORTSUFFIX=emb
+endif
+ifeq ($(OS_TARGET),win16)
+STATICLIBPREFIX=
+STATICLIBEXT=.a
+SHAREDLIBEXT=.dll
+SHORTSUFFIX=w16
+endif
+ifneq ($(findstring $(OS_SOURCE),$(LIMIT83fs)),)
+FPCMADE=fpcmade.$(SHORTSUFFIX)
+ZIPSUFFIX=$(SHORTSUFFIX)
+ZIPCROSSPREFIX=
+ZIPSOURCESUFFIX=src
+ZIPEXAMPLESUFFIX=exm
+else
+FPCMADE=fpcmade.$(TARGETSUFFIX)
+ZIPSOURCESUFFIX=.source
+ZIPEXAMPLESUFFIX=.examples
+ifdef CROSSCOMPILE
+ZIPSUFFIX=.$(SOURCESUFFIX)
+ZIPCROSSPREFIX=$(TARGETSUFFIX)-
+else
+ZIPSUFFIX=.$(TARGETSUFFIX)
+ZIPCROSSPREFIX=
+endif
+endif
+ifndef ECHO
+ECHO:=$(strip $(wildcard $(addsuffix /gecho$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(ECHO),)
+ECHO:=$(strip $(wildcard $(addsuffix /echo$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(ECHO),)
+ECHO= __missing_command_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= __missing_command_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= __missing_command_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= __missing_command_CPPROG
+else
+CPPROG:=$(firstword $(CPPROG))
+endif
+endif
+export CPPROG
+ifndef RMPROG
+RMPROG:=$(strip $(wildcard $(addsuffix /rm$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(RMPROG),)
+RMPROG= __missing_command_RMPROG
+else
+RMPROG:=$(firstword $(RMPROG))
+endif
+endif
+export RMPROG
+ifndef MVPROG
+MVPROG:=$(strip $(wildcard $(addsuffix /mv$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(MVPROG),)
+MVPROG= __missing_command_MVPROG
+else
+MVPROG:=$(firstword $(MVPROG))
+endif
+endif
+export MVPROG
+ifndef MKDIRPROG
+MKDIRPROG:=$(strip $(wildcard $(addsuffix /gmkdir$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(MKDIRPROG),)
+MKDIRPROG:=$(strip $(wildcard $(addsuffix /mkdir$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(MKDIRPROG),)
+MKDIRPROG= __missing_command_MKDIRPROG
+else
+MKDIRPROG:=$(firstword $(MKDIRPROG))
+endif
+else
+MKDIRPROG:=$(firstword $(MKDIRPROG))
+endif
+endif
+export MKDIRPROG
+ifndef ECHOREDIR
+ifndef inUnix
+ECHOREDIR=echo
+else
+ECHOREDIR=$(ECHO)
+endif
+endif
+ifndef COPY
+COPY:=$(CPPROG) -fp
+endif
+ifndef COPYTREE
+COPYTREE:=$(CPPROG) -Rfp
+endif
+ifndef MKDIRTREE
+MKDIRTREE:=$(MKDIRPROG) -p
+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= __missing_command_PPUMOVE
+else
+PPUMOVE:=$(firstword $(PPUMOVE))
+endif
+endif
+export PPUMOVE
+ifndef FPCMAKE
+FPCMAKE:=$(strip $(wildcard $(addsuffix /fpcmake$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(FPCMAKE),)
+FPCMAKE= __missing_command_FPCMAKE
+else
+FPCMAKE:=$(firstword $(FPCMAKE))
+endif
+endif
+export FPCMAKE
+ifndef ZIPPROG
+ZIPPROG:=$(strip $(wildcard $(addsuffix /zip$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(ZIPPROG),)
+ZIPPROG= __missing_command_ZIPPROG
+else
+ZIPPROG:=$(firstword $(ZIPPROG))
+endif
+endif
+export ZIPPROG
+ifndef TARPROG
+TARPROG:=$(strip $(wildcard $(addsuffix /gtar$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(TARPROG),)
+TARPROG:=$(strip $(wildcard $(addsuffix /tar$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(TARPROG),)
+TARPROG= __missing_command_TARPROG
+else
+TARPROG:=$(firstword $(TARPROG))
+endif
+else
+TARPROG:=$(firstword $(TARPROG))
+endif
+endif
+export TARPROG
+ASNAME=$(BINUTILSPREFIX)as
+LDNAME=$(BINUTILSPREFIX)ld
+ARNAME=$(BINUTILSPREFIX)ar
+RCNAME=$(BINUTILSPREFIX)rc
+NASMNAME=$(BINUTILSPREFIX)nasm
+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
+ifndef NASMPROG
+ifdef CROSSBINDIR
+NASMPROG=$(CROSSBINDIR)/$(NASMNAME)$(SRCEXEEXT)
+else
+NASMPROG=$(NASMNAME)
+endif
+endif
+AS=$(ASPROG)
+LD=$(LDPROG)
+RC=$(RCPROG)
+AR=$(ARPROG)
+NASM=$(NASMPROG)
+ifdef inUnix
+PPAS=./ppas$(SRCBATCHEXT)
+else
+PPAS=ppas$(SRCBATCHEXT)
+endif
+ifdef inUnix
+LDCONFIG=ldconfig
+else
+LDCONFIG=
+endif
+ifdef DATE
+DATESTR:=$(shell $(DATE) +%Y%m%d)
+else
+DATESTR=
+endif
+ZIPOPT=-9
+ZIPEXT=.zip
+ifeq ($(USETAR),bz2)
+TAROPT=vj
+TAREXT=.tar.bz2
+else
+TAROPT=vz
+TAREXT=.tar.gz
+endif
+override REQUIRE_PACKAGES=rtl fpmkunit
+ifeq ($(FULL_TARGET),i386-linux)
+REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_PASZLIB=1
+REQUIRE_PACKAGES_FCL-PROCESS=1
+REQUIRE_PACKAGES_HASH=1
+REQUIRE_PACKAGES_LIBTAR=1
+REQUIRE_PACKAGES_FPMKUNIT=1
+endif
+ifeq ($(FULL_TARGET),i386-win32)
+REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_PASZLIB=1
+REQUIRE_PACKAGES_FCL-PROCESS=1
+REQUIRE_PACKAGES_HASH=1
+REQUIRE_PACKAGES_LIBTAR=1
+REQUIRE_PACKAGES_FPMKUNIT=1
+endif
+ifeq ($(FULL_TARGET),m68k-linux)
+REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_PASZLIB=1
+REQUIRE_PACKAGES_FCL-PROCESS=1
+REQUIRE_PACKAGES_HASH=1
+REQUIRE_PACKAGES_LIBTAR=1
+REQUIRE_PACKAGES_FPMKUNIT=1
+endif
+ifeq ($(FULL_TARGET),powerpc-linux)
+REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_PASZLIB=1
+REQUIRE_PACKAGES_FCL-PROCESS=1
+REQUIRE_PACKAGES_HASH=1
+REQUIRE_PACKAGES_LIBTAR=1
+REQUIRE_PACKAGES_FPMKUNIT=1
+endif
+ifeq ($(FULL_TARGET),sparc-linux)
+REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_PASZLIB=1
+REQUIRE_PACKAGES_FCL-PROCESS=1
+REQUIRE_PACKAGES_HASH=1
+REQUIRE_PACKAGES_LIBTAR=1
+REQUIRE_PACKAGES_FPMKUNIT=1
+endif
+ifeq ($(FULL_TARGET),x86_64-linux)
+REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_PASZLIB=1
+REQUIRE_PACKAGES_FCL-PROCESS=1
+REQUIRE_PACKAGES_HASH=1
+REQUIRE_PACKAGES_LIBTAR=1
+REQUIRE_PACKAGES_FPMKUNIT=1
+endif
+ifeq ($(FULL_TARGET),x86_64-win64)
+REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_PASZLIB=1
+REQUIRE_PACKAGES_FCL-PROCESS=1
+REQUIRE_PACKAGES_HASH=1
+REQUIRE_PACKAGES_LIBTAR=1
+REQUIRE_PACKAGES_FPMKUNIT=1
+endif
+ifeq ($(FULL_TARGET),arm-linux)
+REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_PASZLIB=1
+REQUIRE_PACKAGES_FCL-PROCESS=1
+REQUIRE_PACKAGES_HASH=1
+REQUIRE_PACKAGES_LIBTAR=1
+REQUIRE_PACKAGES_FPMKUNIT=1
+endif
+ifeq ($(FULL_TARGET),powerpc64-linux)
+REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_PASZLIB=1
+REQUIRE_PACKAGES_FCL-PROCESS=1
+REQUIRE_PACKAGES_HASH=1
+REQUIRE_PACKAGES_LIBTAR=1
+REQUIRE_PACKAGES_FPMKUNIT=1
+endif
+ifeq ($(FULL_TARGET),armeb-linux)
+REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_PASZLIB=1
+REQUIRE_PACKAGES_FCL-PROCESS=1
+REQUIRE_PACKAGES_HASH=1
+REQUIRE_PACKAGES_LIBTAR=1
+REQUIRE_PACKAGES_FPMKUNIT=1
+endif
+ifeq ($(FULL_TARGET),mips-linux)
+REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_PASZLIB=1
+REQUIRE_PACKAGES_FCL-PROCESS=1
+REQUIRE_PACKAGES_HASH=1
+REQUIRE_PACKAGES_LIBTAR=1
+REQUIRE_PACKAGES_FPMKUNIT=1
+endif
+ifeq ($(FULL_TARGET),mipsel-linux)
+REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_PASZLIB=1
+REQUIRE_PACKAGES_FCL-PROCESS=1
+REQUIRE_PACKAGES_HASH=1
+REQUIRE_PACKAGES_LIBTAR=1
+REQUIRE_PACKAGES_FPMKUNIT=1
+endif
+ifeq ($(FULL_TARGET),aarch64-linux)
+REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_PASZLIB=1
+REQUIRE_PACKAGES_FCL-PROCESS=1
+REQUIRE_PACKAGES_HASH=1
+REQUIRE_PACKAGES_LIBTAR=1
+REQUIRE_PACKAGES_FPMKUNIT=1
+endif
+ifdef REQUIRE_PACKAGES_RTL
+PACKAGEDIR_RTL:=$(firstword $(subst /Makefile.fpc,,$(strip $(wildcard $(addsuffix /rtl/Makefile.fpc,$(PACKAGESDIR))))))
+ifneq ($(PACKAGEDIR_RTL),)
+ifneq ($(wildcard $(PACKAGEDIR_RTL)/units/$(TARGETSUFFIX)),)
+UNITDIR_RTL=$(PACKAGEDIR_RTL)/units/$(TARGETSUFFIX)
+else
+UNITDIR_RTL=$(PACKAGEDIR_RTL)
+endif
+ifneq ($(wildcard $(PACKAGEDIR_RTL)/units/$(SOURCESUFFIX)),)
+UNITDIR_FPMAKE_RTL=$(PACKAGEDIR_RTL)/units/$(SOURCESUFFIX)
+else
+ifneq ($(wildcard $(PACKAGEDIR_RTL)/units_bs/$(SOURCESUFFIX)),)
+UNITDIR_FPMAKE_RTL=$(PACKAGEDIR_RTL)/units_bs/$(SOURCESUFFIX)
+else
+UNITDIR_FPMAKE_RTL=$(PACKAGEDIR_RTL)
+endif
+endif
+ifdef CHECKDEPEND
+$(PACKAGEDIR_RTL)/$(OS_TARGET)/$(FPCMADE):
+	$(MAKE) -C $(PACKAGEDIR_RTL)/$(OS_TARGET) $(FPCMADE)
+override ALLDEPENDENCIES+=$(PACKAGEDIR_RTL)/$(OS_TARGET)/$(FPCMADE)
+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
+ifdef UNITDIR_FPMAKE_RTL
+override COMPILER_FPMAKE_UNITDIR+=$(UNITDIR_FPMAKE_RTL)
+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)/units/$(TARGETSUFFIX)),)
+UNITDIR_PASZLIB=$(PACKAGEDIR_PASZLIB)/units/$(TARGETSUFFIX)
+else
+UNITDIR_PASZLIB=$(PACKAGEDIR_PASZLIB)
+endif
+ifneq ($(wildcard $(PACKAGEDIR_PASZLIB)/units/$(SOURCESUFFIX)),)
+UNITDIR_FPMAKE_PASZLIB=$(PACKAGEDIR_PASZLIB)/units/$(SOURCESUFFIX)
+else
+ifneq ($(wildcard $(PACKAGEDIR_PASZLIB)/units_bs/$(SOURCESUFFIX)),)
+UNITDIR_FPMAKE_PASZLIB=$(PACKAGEDIR_PASZLIB)/units_bs/$(SOURCESUFFIX)
+else
+UNITDIR_FPMAKE_PASZLIB=$(PACKAGEDIR_PASZLIB)
+endif
+endif
+ifdef CHECKDEPEND
+$(PACKAGEDIR_PASZLIB)/$(FPCMADE):
+	$(MAKE) -C $(PACKAGEDIR_PASZLIB) $(FPCMADE)
+override ALLDEPENDENCIES+=$(PACKAGEDIR_PASZLIB)/$(FPCMADE)
+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
+ifdef UNITDIR_FPMAKE_PASZLIB
+override COMPILER_FPMAKE_UNITDIR+=$(UNITDIR_FPMAKE_PASZLIB)
+endif
+endif
+ifdef REQUIRE_PACKAGES_FCL-PROCESS
+PACKAGEDIR_FCL-PROCESS:=$(firstword $(subst /Makefile.fpc,,$(strip $(wildcard $(addsuffix /fcl-process/Makefile.fpc,$(PACKAGESDIR))))))
+ifneq ($(PACKAGEDIR_FCL-PROCESS),)
+ifneq ($(wildcard $(PACKAGEDIR_FCL-PROCESS)/units/$(TARGETSUFFIX)),)
+UNITDIR_FCL-PROCESS=$(PACKAGEDIR_FCL-PROCESS)/units/$(TARGETSUFFIX)
+else
+UNITDIR_FCL-PROCESS=$(PACKAGEDIR_FCL-PROCESS)
+endif
+ifneq ($(wildcard $(PACKAGEDIR_FCL-PROCESS)/units/$(SOURCESUFFIX)),)
+UNITDIR_FPMAKE_FCL-PROCESS=$(PACKAGEDIR_FCL-PROCESS)/units/$(SOURCESUFFIX)
+else
+ifneq ($(wildcard $(PACKAGEDIR_FCL-PROCESS)/units_bs/$(SOURCESUFFIX)),)
+UNITDIR_FPMAKE_FCL-PROCESS=$(PACKAGEDIR_FCL-PROCESS)/units_bs/$(SOURCESUFFIX)
+else
+UNITDIR_FPMAKE_FCL-PROCESS=$(PACKAGEDIR_FCL-PROCESS)
+endif
+endif
+ifdef CHECKDEPEND
+$(PACKAGEDIR_FCL-PROCESS)/$(FPCMADE):
+	$(MAKE) -C $(PACKAGEDIR_FCL-PROCESS) $(FPCMADE)
+override ALLDEPENDENCIES+=$(PACKAGEDIR_FCL-PROCESS)/$(FPCMADE)
+endif
+else
+PACKAGEDIR_FCL-PROCESS=
+UNITDIR_FCL-PROCESS:=$(subst /Package.fpc,,$(strip $(wildcard $(addsuffix /fcl-process/Package.fpc,$(UNITSDIR)))))
+ifneq ($(UNITDIR_FCL-PROCESS),)
+UNITDIR_FCL-PROCESS:=$(firstword $(UNITDIR_FCL-PROCESS))
+else
+UNITDIR_FCL-PROCESS=
+endif
+endif
+ifdef UNITDIR_FCL-PROCESS
+override COMPILER_UNITDIR+=$(UNITDIR_FCL-PROCESS)
+endif
+ifdef UNITDIR_FPMAKE_FCL-PROCESS
+override COMPILER_FPMAKE_UNITDIR+=$(UNITDIR_FPMAKE_FCL-PROCESS)
+endif
+endif
+ifdef REQUIRE_PACKAGES_HASH
+PACKAGEDIR_HASH:=$(firstword $(subst /Makefile.fpc,,$(strip $(wildcard $(addsuffix /hash/Makefile.fpc,$(PACKAGESDIR))))))
+ifneq ($(PACKAGEDIR_HASH),)
+ifneq ($(wildcard $(PACKAGEDIR_HASH)/units/$(TARGETSUFFIX)),)
+UNITDIR_HASH=$(PACKAGEDIR_HASH)/units/$(TARGETSUFFIX)
+else
+UNITDIR_HASH=$(PACKAGEDIR_HASH)
+endif
+ifneq ($(wildcard $(PACKAGEDIR_HASH)/units/$(SOURCESUFFIX)),)
+UNITDIR_FPMAKE_HASH=$(PACKAGEDIR_HASH)/units/$(SOURCESUFFIX)
+else
+ifneq ($(wildcard $(PACKAGEDIR_HASH)/units_bs/$(SOURCESUFFIX)),)
+UNITDIR_FPMAKE_HASH=$(PACKAGEDIR_HASH)/units_bs/$(SOURCESUFFIX)
+else
+UNITDIR_FPMAKE_HASH=$(PACKAGEDIR_HASH)
+endif
+endif
+ifdef CHECKDEPEND
+$(PACKAGEDIR_HASH)/$(FPCMADE):
+	$(MAKE) -C $(PACKAGEDIR_HASH) $(FPCMADE)
+override ALLDEPENDENCIES+=$(PACKAGEDIR_HASH)/$(FPCMADE)
+endif
+else
+PACKAGEDIR_HASH=
+UNITDIR_HASH:=$(subst /Package.fpc,,$(strip $(wildcard $(addsuffix /hash/Package.fpc,$(UNITSDIR)))))
+ifneq ($(UNITDIR_HASH),)
+UNITDIR_HASH:=$(firstword $(UNITDIR_HASH))
+else
+UNITDIR_HASH=
+endif
+endif
+ifdef UNITDIR_HASH
+override COMPILER_UNITDIR+=$(UNITDIR_HASH)
+endif
+ifdef UNITDIR_FPMAKE_HASH
+override COMPILER_FPMAKE_UNITDIR+=$(UNITDIR_FPMAKE_HASH)
+endif
+endif
+ifdef REQUIRE_PACKAGES_LIBTAR
+PACKAGEDIR_LIBTAR:=$(firstword $(subst /Makefile.fpc,,$(strip $(wildcard $(addsuffix /libtar/Makefile.fpc,$(PACKAGESDIR))))))
+ifneq ($(PACKAGEDIR_LIBTAR),)
+ifneq ($(wildcard $(PACKAGEDIR_LIBTAR)/units/$(TARGETSUFFIX)),)
+UNITDIR_LIBTAR=$(PACKAGEDIR_LIBTAR)/units/$(TARGETSUFFIX)
+else
+UNITDIR_LIBTAR=$(PACKAGEDIR_LIBTAR)
+endif
+ifneq ($(wildcard $(PACKAGEDIR_LIBTAR)/units/$(SOURCESUFFIX)),)
+UNITDIR_FPMAKE_LIBTAR=$(PACKAGEDIR_LIBTAR)/units/$(SOURCESUFFIX)
+else
+ifneq ($(wildcard $(PACKAGEDIR_LIBTAR)/units_bs/$(SOURCESUFFIX)),)
+UNITDIR_FPMAKE_LIBTAR=$(PACKAGEDIR_LIBTAR)/units_bs/$(SOURCESUFFIX)
+else
+UNITDIR_FPMAKE_LIBTAR=$(PACKAGEDIR_LIBTAR)
+endif
+endif
+ifdef CHECKDEPEND
+$(PACKAGEDIR_LIBTAR)/$(FPCMADE):
+	$(MAKE) -C $(PACKAGEDIR_LIBTAR) $(FPCMADE)
+override ALLDEPENDENCIES+=$(PACKAGEDIR_LIBTAR)/$(FPCMADE)
+endif
+else
+PACKAGEDIR_LIBTAR=
+UNITDIR_LIBTAR:=$(subst /Package.fpc,,$(strip $(wildcard $(addsuffix /libtar/Package.fpc,$(UNITSDIR)))))
+ifneq ($(UNITDIR_LIBTAR),)
+UNITDIR_LIBTAR:=$(firstword $(UNITDIR_LIBTAR))
+else
+UNITDIR_LIBTAR=
+endif
+endif
+ifdef UNITDIR_LIBTAR
+override COMPILER_UNITDIR+=$(UNITDIR_LIBTAR)
+endif
+ifdef UNITDIR_FPMAKE_LIBTAR
+override COMPILER_FPMAKE_UNITDIR+=$(UNITDIR_FPMAKE_LIBTAR)
+endif
+endif
+ifdef REQUIRE_PACKAGES_FPMKUNIT
+PACKAGEDIR_FPMKUNIT:=$(firstword $(subst /Makefile.fpc,,$(strip $(wildcard $(addsuffix /fpmkunit/Makefile.fpc,$(PACKAGESDIR))))))
+ifneq ($(PACKAGEDIR_FPMKUNIT),)
+ifneq ($(wildcard $(PACKAGEDIR_FPMKUNIT)/units/$(TARGETSUFFIX)),)
+UNITDIR_FPMKUNIT=$(PACKAGEDIR_FPMKUNIT)/units/$(TARGETSUFFIX)
+else
+UNITDIR_FPMKUNIT=$(PACKAGEDIR_FPMKUNIT)
+endif
+ifneq ($(wildcard $(PACKAGEDIR_FPMKUNIT)/units/$(SOURCESUFFIX)),)
+UNITDIR_FPMAKE_FPMKUNIT=$(PACKAGEDIR_FPMKUNIT)/units/$(SOURCESUFFIX)
+else
+ifneq ($(wildcard $(PACKAGEDIR_FPMKUNIT)/units_bs/$(SOURCESUFFIX)),)
+UNITDIR_FPMAKE_FPMKUNIT=$(PACKAGEDIR_FPMKUNIT)/units_bs/$(SOURCESUFFIX)
+else
+UNITDIR_FPMAKE_FPMKUNIT=$(PACKAGEDIR_FPMKUNIT)
+endif
+endif
+ifdef CHECKDEPEND
+$(PACKAGEDIR_FPMKUNIT)/$(FPCMADE):
+	$(MAKE) -C $(PACKAGEDIR_FPMKUNIT) $(FPCMADE)
+override ALLDEPENDENCIES+=$(PACKAGEDIR_FPMKUNIT)/$(FPCMADE)
+endif
+else
+PACKAGEDIR_FPMKUNIT=
+UNITDIR_FPMKUNIT:=$(subst /Package.fpc,,$(strip $(wildcard $(addsuffix /fpmkunit/Package.fpc,$(UNITSDIR)))))
+ifneq ($(UNITDIR_FPMKUNIT),)
+UNITDIR_FPMKUNIT:=$(firstword $(UNITDIR_FPMKUNIT))
+else
+UNITDIR_FPMKUNIT=
+endif
+endif
+ifdef UNITDIR_FPMKUNIT
+override COMPILER_UNITDIR+=$(UNITDIR_FPMKUNIT)
+endif
+ifdef UNITDIR_FPMAKE_FPMKUNIT
+override COMPILER_FPMAKE_UNITDIR+=$(UNITDIR_FPMAKE_FPMKUNIT)
+endif
+endif
+ifndef NOCPUDEF
+override FPCOPTDEF=$(ARCH)
+endif
+ifneq ($(OS_TARGET),$(OS_SOURCE))
+override FPCOPT+=-T$(OS_TARGET)
+endif
+ifneq ($(CPU_TARGET),$(CPU_SOURCE))
+override FPCOPT+=-P$(ARCH)
+endif
+ifeq ($(OS_SOURCE),openbsd)
+override FPCOPT+=-FD$(NEW_BINUTILS_PATH)
+override FPCMAKEOPT+=-FD$(NEW_BINUTILS_PATH)
+override FPMAKE_BUILD_OPT+=-FD$(NEW_BINUTILS_PATH)
+endif
+ifndef CROSSBOOTSTRAP
+ifneq ($(BINUTILSPREFIX),)
+override FPCOPT+=-XP$(BINUTILSPREFIX)
+endif
+ifneq ($(BINUTILSPREFIX),)
+override FPCOPT+=-Xr$(RLINKPATH)
+endif
+endif
+ifndef CROSSCOMPILE
+ifneq ($(BINUTILSPREFIX),)
+override FPCMAKEOPT+=-XP$(BINUTILSPREFIX)
+override FPMAKE_BUILD_OPT+=-XP$(BINUTILSPREFIX)
+endif
+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
+ifneq ($(findstring 2.0.,$(FPC_VERSION)),)
+ifeq ($(CPU_TARGET),i386)
+FPCCPUOPT:=-OG2p3
+endif
+ifeq ($(CPU_TARGET),powerpc)
+FPCCPUOPT:=-O1r
+endif
+else
+FPCCPUOPT:=-O2
+endif
+override FPCOPT+=-Ur -Xs $(FPCCPUOPT) -n
+override FPCOPTDEF+=RELEASE
+endif
+ifdef STRIP
+override FPCOPT+=-Xs
+endif
+ifdef OPTIMIZE
+override FPCOPT+=-O2
+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 CREATESHARED
+override FPCOPT+=-Cg
+endif
+ifneq ($(findstring $(OS_TARGET),dragonfly freebsd openbsd netbsd linux solaris),)
+ifneq ($(findstring $(CPU_TARGET),x86_64 mips mipsel),)
+override FPCOPT+=-Cg
+endif
+endif
+ifdef LINKSHARED
+endif
+ifdef OPT
+override FPCOPT+=$(OPT)
+endif
+ifdef FPMAKEBUILDOPT
+override FPMAKE_BUILD_OPT+=$(FPMAKEBUILDOPT)
+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 AFULL_TARGET=$(CPU_TARGET)-$(OS_TARGET)
+override AFULL_SOURCE=$(CPU_SOURCE)-$(OS_SOURCE)
+ifneq ($(AFULL_TARGET),$(AFULL_SOURCE))
+override ACROSSCOMPILE=1
+endif
+ifdef ACROSSCOMPILE
+override FPCOPT+=$(CROSSOPT)
+endif
+override COMPILER:=$(strip $(FPC) $(FPCOPT))
+ifneq (,$(findstring -sh ,$(COMPILER)))
+UseEXECPPAS=1
+endif
+ifneq (,$(findstring -s ,$(COMPILER)))
+ifeq ($(FULL_SOURCE),$(FULL_TARGET))
+UseEXECPPAS=1
+endif
+endif
+ifneq ($(UseEXECPPAS),1)
+EXECPPAS=
+else
+ifdef RUNBATCH
+EXECPPAS:=@$(RUNBATCH) $(PPAS)
+else
+EXECPPAS:=@$(PPAS)
+endif
+endif
+ifdef TARGET_RSTS
+override RSTFILES=$(addsuffix $(RSTEXT),$(TARGET_RSTS))
+override CLEANRSTFILES+=$(RSTFILES)
+endif
+.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)$(PPUEXT),$(INSTALLPPUFILES))
+endif
+ifdef INSTALLPPUFILES
+override INSTALLPPULINKFILES:=$(subst $(PPUEXT),$(OEXT),$(INSTALLPPUFILES)) $(addprefix $(STATICLIBPREFIX),$(subst $(PPUEXT),$(STATICLIBEXT),$(INSTALLPPUFILES))) $(addprefix $(IMPORTLIBPREFIX),$(subst $(PPUEXT),$(STATICLIBEXT),$(INSTALLPPUFILES)))
+ifneq ($(UNITTARGETDIRPREFIX),)
+override INSTALLPPUFILES:=$(addprefix $(UNITTARGETDIRPREFIX),$(notdir $(INSTALLPPUFILES)))
+override INSTALLPPULINKFILES:=$(wildcard $(addprefix $(UNITTARGETDIRPREFIX),$(notdir $(INSTALLPPULINKFILES))))
+endif
+override INSTALL_CREATEPACKAGEFPC=1
+endif
+ifdef INSTALLEXEFILES
+ifneq ($(TARGETDIRPREFIX),)
+override INSTALLEXEFILES:=$(addprefix $(TARGETDIRPREFIX),$(notdir $(INSTALLEXEFILES)))
+endif
+endif
+fpc_install: all $(INSTALLTARGET)
+ifdef INSTALLEXEFILES
+	$(MKDIR) $(INSTALL_BINDIR)
+	$(INSTALLEXE) $(INSTALLEXEFILES) $(INSTALL_BINDIR)
+endif
+ifdef INSTALL_CREATEPACKAGEFPC
+ifdef FPCMAKE
+ifdef PACKAGE_VERSION
+ifneq ($(wildcard Makefile.fpc),)
+	$(FPCMAKE) -p -T$(CPU_TARGET)-$(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: $(EXAMPLEINSTALLTARGET) $(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=$(PACKAGE_NAME)
+endif
+endif
+ifndef FULLZIPNAME
+FULLZIPNAME=$(ZIPCROSSPREFIX)$(ZIPPREFIX)$(ZIPNAME)$(ZIPSUFFIX)
+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$(SRCBATCHEXT))
+else
+ZIPPATHSEP=/
+endif
+ZIPCMD_CDPACK:=cd $(subst /,$(ZIPPATHSEP),$(PACKDIR))
+ZIPCMD_CDBASE:=cd $(subst /,$(ZIPPATHSEP),$(BASEDIR))
+ifdef USETAR
+ZIPDESTFILE:=$(DIST_DESTDIR)/$(FULLZIPNAME)$(TAREXT)
+ZIPCMD_ZIP:=$(TARPROG) c$(TAROPT)f $(ZIPDESTFILE) *
+else
+ZIPDESTFILE:=$(DIST_DESTDIR)/$(FULLZIPNAME)$(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
+ifdef RUNBATCH
+	$(RUNBATCH) $(ZIPWRAPPER)
+else
+	$(ZIPWRAPPER)
+endif
+endif
+	$(DEL) $(ZIPWRAPPER)
+else
+	$(ZIPCMD_CDPACK) ; $(ZIPCMD_ZIP) ; $(ZIPCMD_CDBASE)
+endif
+	$(DELTREE) $(PACKDIR)
+fpc_zipsourceinstall:
+	$(MAKE) fpc_zipinstall ZIPTARGET=sourceinstall ZIPSUFFIX=$(ZIPSOURCESUFFIX)
+fpc_zipexampleinstall:
+ifdef HASEXAMPLES
+	$(MAKE) fpc_zipinstall ZIPTARGET=exampleinstall ZIPSUFFIX=$(ZIPEXAMPLESUFFIX)
+endif
+fpc_zipdistinstall:
+	$(MAKE) fpc_zipinstall ZIPTARGET=distinstall
+.PHONY: fpc_clean fpc_cleanall fpc_distclean
+ifdef EXEFILES
+override CLEANEXEFILES:=$(addprefix $(TARGETDIRPREFIX),$(CLEANEXEFILES))
+override CLEANEXEDBGFILES:=$(addprefix $(TARGETDIRPREFIX),$(CLEANEXEDBGFILES))
+endif
+ifdef CLEAN_PROGRAMS
+override CLEANEXEFILES+=$(addprefix $(TARGETDIRPREFIX),$(addsuffix $(EXEEXT), $(CLEAN_PROGRAMS)))
+override CLEANEXEDBGFILES+=$(addprefix $(TARGETDIRPREFIX),$(addsuffix $(EXEDBGEXT), $(CLEAN_PROGRAMS)))
+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))) $(addprefix $(IMPORTLIBPREFIX),$(subst $(PPUEXT),$(STATICLIBEXT),$(CLEANPPUFILES)))
+ifdef DEBUGSYMEXT
+override CLEANPPULINKFILES+=$(subst $(PPUEXT),$(DEBUGSYMEXT),$(CLEANPPUFILES))
+endif
+override CLEANPPUFILES:=$(addprefix $(UNITTARGETDIRPREFIX),$(CLEANPPUFILES))
+override CLEANPPULINKFILES:=$(wildcard $(addprefix $(UNITTARGETDIRPREFIX),$(CLEANPPULINKFILES)))
+endif
+fpc_clean: $(CLEANTARGET)
+ifdef CLEANEXEFILES
+	-$(DEL) $(CLEANEXEFILES)
+endif
+ifdef CLEANEXEDBGFILES
+	-$(DELTREE) $(CLEANEXEDBGFILES)
+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)
+	-$(DEL) *$(ASMEXT) *_ppas$(BATCHEXT)
+fpc_cleanall: $(CLEANTARGET)
+ifdef CLEANEXEFILES
+	-$(DEL) $(CLEANEXEFILES)
+endif
+ifdef COMPILER_UNITTARGETDIR
+ifdef CLEANPPUFILES
+	-$(DEL) $(CLEANPPUFILES)
+endif
+ifneq ($(CLEANPPULINKFILES),)
+	-$(DEL) $(CLEANPPULINKFILES)
+endif
+ifdef CLEANRSTFILES
+	-$(DEL) $(addprefix $(UNITTARGETDIRPREFIX),$(CLEANRSTFILES))
+endif
+endif
+ifdef CLEAN_FILES
+	-$(DEL) $(CLEAN_FILES)
+endif
+	-$(DELTREE) units
+	-$(DEL) *$(OEXT) *$(PPUEXT) *$(RSTEXT) *$(ASMEXT) *$(STATICLIBEXT) *$(SHAREDLIBEXT) *$(PPLEXT)
+ifneq ($(PPUEXT),.ppu)
+	-$(DEL) *.o *.ppu *.a
+endif
+	-$(DELTREE) *$(SMARTEXT)
+	-$(DEL) fpcmade.* Package.fpc $(PPAS) script.res link.res $(FPCEXTFILE) $(REDIRFILE)
+	-$(DEL) *_ppas$(BATCHEXT)
+ifdef AOUTEXT
+	-$(DEL) *$(AOUTEXT)
+endif
+ifdef DEBUGSYMEXT
+	-$(DEL) *$(DEBUGSYMEXT)
+endif
+ifdef LOCALFPMAKEBIN
+	-$(DEL) $(LOCALFPMAKEBIN)
+	-$(DEL) $(FPMAKEBINOBJ)
+endif
+fpc_distclean: cleanall
+.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 Source.. $(FULL_SOURCE)
+	@$(ECHO)  Full Target.. $(FULL_TARGET)
+	@$(ECHO)  SourceSuffix. $(SOURCESUFFIX)
+	@$(ECHO)  TargetSuffix. $(TARGETSUFFIX)
+	@$(ECHO)  FPC fpmake... $(FPCFPMAKE)
+	@$(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)  Shell..... $(SHELL)
+	@$(ECHO)  Date...... $(DATE)
+	@$(ECHO)  FPCMake... $(FPCMAKE)
+	@$(ECHO)  PPUMove... $(PPUMOVE)
+	@$(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)  ZipName.............. $(ZIPNAME)
+	@$(ECHO)  ZipPrefix............ $(ZIPPREFIX)
+	@$(ECHO)  ZipCrossPrefix....... $(ZIPCROSSPREFIX)
+	@$(ECHO)  ZipSuffix............ $(ZIPSUFFIX)
+	@$(ECHO)  FullZipName.......... $(FULLZIPNAME)
+	@$(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
+units:
+examples:
+shared:
+sourceinstall: fpc_sourceinstall
+exampleinstall: fpc_exampleinstall
+zipexampleinstall: fpc_zipexampleinstall
+info: fpc_info
+makefiles: fpc_makefiles
+.PHONY: units examples shared sourceinstall exampleinstall zipexampleinstall info makefiles
+ifneq ($(wildcard fpcmake.loc),)
+include fpcmake.loc
+endif
+override FPCOPT:=$(filter-out -FU%,$(FPCOPT))
+override FPCOPT:=$(filter-out -FE%,$(FPCOPT))
+override FPCOPT:=$(filter-out $(addprefix -Fu,$(COMPILER_UNITDIR)),$(FPCOPT))# Compose general fpmake-parameters
+ifdef FPMAKEOPT
+FPMAKE_OPT+=$(FPMAKEOPT)
+endif
+FPMAKE_OPT+=--localunitdir=../..
+FPMAKE_OPT+=--globalunitdir=..
+FPMAKE_OPT+=$(FPC_TARGETOPT)
+FPMAKE_OPT+=$(addprefix -o ,$(FPCOPT))
+FPMAKE_OPT+=--compiler=$(FPC)
+FPMAKE_OPT+=-bu
+.NOTPARALLEL:
+fpmake$(SRCEXEEXT): fpmake.pp
+	$(FPCFPMAKE) fpmake.pp $(FPMAKE_SKIP_CONFIG) $(addprefix -Fu,$(COMPILER_FPMAKE_UNITDIR)) $(FPCMAKEOPT) $(OPT)
+all:	fpmake$(SRCEXEEXT)
+	$(LOCALFPMAKE) compile $(FPMAKE_OPT)
+smart:	fpmake$(SRCEXEEXT)
+	$(LOCALFPMAKE) compile $(FPMAKE_OPT) -o -XX -o -CX
+release:	fpmake$(SRCEXEEXT)
+	$(LOCALFPMAKE) compile $(FPMAKE_OPT) -o -dRELEASE
+debug:	fpmake$(SRCEXEEXT)
+	$(LOCALFPMAKE) compile $(FPMAKE_OPT) -o -dDEBUG
+ifeq ($(FPMAKE_BIN_CLEAN),)
+clean:
+else
+clean:
+	$(FPMAKE_BIN_CLEAN) clean $(FPMAKE_OPT)
+endif
+ifeq ($(FPMAKE_BIN_CLEAN),)
+distclean:	$(addsuffix _distclean,$(TARGET_DIRS)) fpc_cleanall
+else
+distclean:
+ifdef inUnix
+	{ $(FPMAKE_BIN_CLEAN) distclean $(FPMAKE_OPT); if [ $$? != "0" ]; then { echo Something wrong with fpmake exectable. Remove the executable and call make recursively to recover.; $(DEL) $(FPMAKE_BIN_CLEAN); $(MAKE) fpc_cleanall; }; fi;  }
+else
+	$(FPMAKE_BIN_CLEAN) distclean $(FPMAKE_OPT)
+endif
+	-$(DEL) $(LOCALFPMAKE)
+endif
+cleanall: distclean
+install:	fpmake$(SRCEXEEXT)
+ifdef UNIXHier
+	$(LOCALFPMAKE) install $(FPMAKE_OPT) --prefix=$(INSTALL_PREFIX) --baseinstalldir=$(INSTALL_LIBDIR)/fpc/$(FPC_VERSION) --unitinstalldir=$(INSTALL_UNITDIR)
+else
+	$(LOCALFPMAKE) install $(FPMAKE_OPT) --prefix=$(INSTALL_BASEDIR) --baseinstalldir=$(INSTALL_BASEDIR) --unitinstalldir=$(INSTALL_UNITDIR)
+endif
+distinstall:	fpmake$(SRCEXEEXT)
+ifdef UNIXHier
+	$(LOCALFPMAKE) install $(FPMAKE_OPT) --prefix=$(INSTALL_PREFIX) --baseinstalldir=$(INSTALL_LIBDIR)/fpc/$(FPC_VERSION) --unitinstalldir=$(INSTALL_UNITDIR) -ie -fsp 0
+else
+	$(LOCALFPMAKE) install $(FPMAKE_OPT) --prefix=$(INSTALL_BASEDIR) --baseinstalldir=$(INSTALL_BASEDIR) --unitinstalldir=$(INSTALL_UNITDIR) -ie -fsp 0
+endif
+zipinstall:	fpmake$(SRCEXEEXT)
+	$(LOCALFPMAKE) zipinstall $(FPMAKE_OPT) --zipprefix=$(DIST_DESTDIR)/$(ZIPPREFIX)
+zipdistinstall:	fpmake$(SRCEXEEXT)
+	$(LOCALFPMAKE) zipinstall $(FPMAKE_OPT) --zipprefix=$(DIST_DESTDIR)/$(ZIPPREFIX) -ie -fsp 0
+zipsourceinstall:	fpmake$(SRCEXEEXT)
+ifdef UNIXHier
+	$(LOCALFPMAKE) archive $(FPMAKE_OPT) --zipprefix=$(DIST_DESTDIR)/$(ZIPPREFIX) --prefix=share/src/fpc-\$$\(PACKAGEVERSION\)/$(INSTALL_FPCSUBDIR)/\$$\(PACKAGEDIRECTORY\)
+else
+	$(LOCALFPMAKE) archive $(FPMAKE_OPT) --zipprefix=$(DIST_DESTDIR)/$(ZIPPREFIX) --prefix=source\\$(INSTALL_FPCSUBDIR)\\\$$\(PACKAGEDIRECTORY\)
+endif

+ 102 - 0
packages/libusb/Makefile.fpc

@@ -0,0 +1,102 @@
+#
+#   Makefile.fpc for running fpmake
+#
+
+[package]
+name=libusb
+version=3.1.1
+
+[require]
+packages=rtl fpmkunit
+
+[install]
+fpcpackage=y
+
+[default]
+fpcdir=../..
+
+[prerules]
+FPMAKE_BIN_CLEAN=$(wildcard ./fpmake$(SRCEXEEXT))
+ifdef OS_TARGET
+FPC_TARGETOPT+=--os=$(OS_TARGET)
+endif
+ifdef CPU_TARGET
+FPC_TARGETOPT+=--cpu=$(CPU_TARGET)
+endif
+LOCALFPMAKE=./fpmake$(SRCEXEEXT)
+
+[rules]
+# Do not pass the Makefile's unit and binary target locations. Fpmake uses it's own.
+override FPCOPT:=$(filter-out -FU%,$(FPCOPT))
+override FPCOPT:=$(filter-out -FE%,$(FPCOPT))
+# Do not pass the package-unitdirectories. Fpmake adds those and this way they don't apear in the .fpm
+override FPCOPT:=$(filter-out $(addprefix -Fu,$(COMPILER_UNITDIR)),$(FPCOPT))# Compose general fpmake-parameters
+# Compose general fpmake-parameters
+ifdef FPMAKEOPT
+FPMAKE_OPT+=$(FPMAKEOPT)
+endif
+FPMAKE_OPT+=--localunitdir=../..
+FPMAKE_OPT+=--globalunitdir=..
+FPMAKE_OPT+=$(FPC_TARGETOPT)
+FPMAKE_OPT+=$(addprefix -o ,$(FPCOPT))
+FPMAKE_OPT+=--compiler=$(FPC)
+FPMAKE_OPT+=-bu
+.NOTPARALLEL:
+
+fpmake$(SRCEXEEXT): fpmake.pp
+	$(FPCFPMAKE) fpmake.pp $(FPMAKE_SKIP_CONFIG) $(addprefix -Fu,$(COMPILER_FPMAKE_UNITDIR)) $(FPCMAKEOPT) $(OPT)
+all:	fpmake$(SRCEXEEXT)
+	$(LOCALFPMAKE) compile $(FPMAKE_OPT)
+smart:	fpmake$(SRCEXEEXT)
+	$(LOCALFPMAKE) compile $(FPMAKE_OPT) -o -XX -o -CX
+release:	fpmake$(SRCEXEEXT)
+	$(LOCALFPMAKE) compile $(FPMAKE_OPT) -o -dRELEASE
+debug:	fpmake$(SRCEXEEXT)
+	$(LOCALFPMAKE) compile $(FPMAKE_OPT) -o -dDEBUG
+# If no fpmake exists and (dist)clean is called, do not try to build fpmake, it will
+# most often fail because the dependencies are cleared.
+# In case of a clean, simply do nothing
+ifeq ($(FPMAKE_BIN_CLEAN),)
+clean:
+else
+clean:
+	$(FPMAKE_BIN_CLEAN) clean $(FPMAKE_OPT)
+endif
+# In case of a distclean, perform an 'old'-style distclean. This to avoid problems
+# when the package is compiled using fpcmake prior to running this clean using fpmake
+ifeq ($(FPMAKE_BIN_CLEAN),)
+distclean:	$(addsuffix _distclean,$(TARGET_DIRS)) fpc_cleanall
+else
+distclean:
+ifdef inUnix
+        { $(FPMAKE_BIN_CLEAN) distclean $(FPMAKE_OPT); if [ $$? != "0" ]; then { echo Something wrong with fpmake exectable. Remove the executable and call make recursively to recover.; $(DEL) $(FPMAKE_BIN_CLEAN); $(MAKE) fpc_cleanall; }; fi;  }
+else
+        $(FPMAKE_BIN_CLEAN) distclean $(FPMAKE_OPT)
+endif
+	-$(DEL) $(LOCALFPMAKE)
+endif
+cleanall: distclean
+install:	fpmake$(SRCEXEEXT)
+ifdef UNIXHier
+	$(LOCALFPMAKE) install $(FPMAKE_OPT) --prefix=$(INSTALL_PREFIX) --baseinstalldir=$(INSTALL_LIBDIR)/fpc/$(FPC_VERSION) --unitinstalldir=$(INSTALL_UNITDIR)
+else
+	$(LOCALFPMAKE) install $(FPMAKE_OPT) --prefix=$(INSTALL_BASEDIR) --baseinstalldir=$(INSTALL_BASEDIR) --unitinstalldir=$(INSTALL_UNITDIR)
+endif
+# distinstall also installs the example-sources and omits the location of the source-
+# files from the fpunits.cfg files.
+distinstall:	fpmake$(SRCEXEEXT)
+ifdef UNIXHier
+	$(LOCALFPMAKE) install $(FPMAKE_OPT) --prefix=$(INSTALL_PREFIX) --baseinstalldir=$(INSTALL_LIBDIR)/fpc/$(FPC_VERSION) --unitinstalldir=$(INSTALL_UNITDIR) -ie -fsp 0
+else
+	$(LOCALFPMAKE) install $(FPMAKE_OPT) --prefix=$(INSTALL_BASEDIR) --baseinstalldir=$(INSTALL_BASEDIR) --unitinstalldir=$(INSTALL_UNITDIR) -ie -fsp 0
+endif
+zipinstall:	fpmake$(SRCEXEEXT)
+	$(LOCALFPMAKE) zipinstall $(FPMAKE_OPT) --zipprefix=$(DIST_DESTDIR)/$(ZIPPREFIX)
+zipdistinstall:	fpmake$(SRCEXEEXT)
+	$(LOCALFPMAKE) zipinstall $(FPMAKE_OPT) --zipprefix=$(DIST_DESTDIR)/$(ZIPPREFIX) -ie -fsp 0
+zipsourceinstall:	fpmake$(SRCEXEEXT)
+ifdef UNIXHier
+	$(LOCALFPMAKE) archive $(FPMAKE_OPT) --zipprefix=$(DIST_DESTDIR)/$(ZIPPREFIX) --prefix=share/src/fpc-\$$\(PACKAGEVERSION\)/$(INSTALL_FPCSUBDIR)/\$$\(PACKAGEDIRECTORY\)
+else
+	$(LOCALFPMAKE) archive $(FPMAKE_OPT) --zipprefix=$(DIST_DESTDIR)/$(ZIPPREFIX) --prefix=source\\$(INSTALL_FPCSUBDIR)\\\$$\(PACKAGEDIRECTORY\)
+endif

+ 34 - 0
packages/libusb/fpmake.pp

@@ -0,0 +1,34 @@
+{$ifndef ALLPACKAGES}
+{$mode objfpc}{$H+}
+program fpmake;
+
+uses fpmkunit;
+
+Var
+  P : TPackage;
+  T : TTarget;
+begin
+  With Installer do
+    begin
+{$endif ALLPACKAGES}
+
+    P:=AddPackage('libusb');
+{$ifdef ALLPACKAGES}
+    P.Directory:=ADirectory;
+{$endif ALLPACKAGES}
+    P.Version:='3.1.1';
+    P.Description := 'Headers for the libusb library e)';
+    P.NeedLibC:= true;  // true for headers that indirectly link to libc?
+    P.OSes := [linux,win32];
+
+    P.SourcePath.Add('src');
+    P.IncludePath.Add('src');
+
+    T:=P.Targets.AddUnit('libusb.pp');
+
+
+{$ifndef ALLPACKAGES}
+    Run;
+    end;
+end.
+{$endif ALLPACKAGES}

+ 2125 - 0
packages/libusb/src/libusb.pp

@@ -0,0 +1,2125 @@
+unit libusb;
+
+{$IFDEF FPC}
+{$mode objfpc}
+{$PACKRECORDS C}
+{$ENDIF}
+
+interface
+{$ifdef MSWINDOWS}
+uses windows;
+{$else}
+uses ctypes,sockets,unixtype;
+{$endif}
+
+
+
+
+  {
+   * Public libusb header file
+   * Copyright © 2001 Johannes Erdfelt <[email protected]>
+   * Copyright © 2007-2008 Daniel Drake <[email protected]>
+   * Copyright © 2012 Pete Batard <[email protected]>
+   * Copyright © 2012 Nathan Hjelm <[email protected]>
+   * For more information, please visit: http://libusb.info
+   *
+   * This library is free software; you can redistribute it and/or
+   * modify it under the terms of the GNU Lesser General Public
+   * License as published by the Free Software Foundation; either
+   * version 2.1 of the License, or (at your option) any later version.
+   *
+   * This library 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
+   * Lesser General Public License for more details.
+   *
+   * You should have received a copy of the GNU Lesser General Public
+   * License along with this library; if not, write to the Free Software
+   * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+    }
+{$ifndef LIBUSB_H}
+{$define LIBUSB_H}  
+{$ifdef MSWINDOWS}
+
+{$ifdef WIN64}
+  type
+    ssize_t = int64;
+{$else}
+  type
+    ssize_t = longint;
+{$endif  WIN64}
+
+{$else}
+  type
+    ssize_t = ptrint;
+{$endif MSWINDOWS}
+
+
+  type
+    puint8_t = ^uint8_t;
+    uint8_t = byte;
+
+    uint16_t = word;
+
+    uint32_t = dword;
+
+{* \def LIBUSB_CALL
+ * \ingroup misc
+ * libusb's Windows calling convention.
+ *
+ * Under Windows, the selection of available compilers and configurations
+ * means that, unlike other platforms, there is not <em>one true calling
+ * convention</em> (calling convention: the manner in which parameters are
+ * passed to functions in the generated assembly code).
+ *
+ * Matching the Windows API itself, libusb uses the WINAPI convention (which
+ * translates to the <tt>stdcall</tt> convention) and guarantees that the
+ * library is compiled in this way. The public header file also includes
+ * appropriate annotations so that your own software will use the right
+ * convention, even if another convention is being used by default within
+ * your codebase.
+ *
+ * The one consideration that you must apply in your software is to mark
+ * all functions which you use as libusb callbacks with this LIBUSB_CALL
+ * annotation, so that they too get compiled for the correct calling
+ * convention.
+ *
+ * On non-Windows operating systems, this macro is defined as nothing. This
+ * means that you can apply it to your code without worrying about
+ * cross-platform compatibility.
+  }
+{ LIBUSB_CALL must be defined on both definition and declaration of libusb
+ * functions. You'd think that declaration would be enough, but cygwin will
+ * complain about conflicting types unless both are marked this way.
+ * The placement of this macro is important too; it must appear after the
+ * return type, before the function name. See internal documentation for
+ * API_EXPORTED.
+  }
+{$macro on}
+
+{$ifdef MSWINDOWS}
+ 
+const libusb1='libusb-1.0.dll';
+{$define LIBUSB_CALL := WINAPI;external libusb1; }
+{$else}
+const libusb1='libusb-1.0.so';
+{$define LIBUSB_CALL := cdecl }
+{$endif}
+
+{* \def LIBUSB_API_VERSION
+ * \ingroup misc
+ * libusb's API version.
+ *
+ * Since version 1.0.13, to help with feature detection, libusb defines
+ * a LIBUSB_API_VERSION macro that gets increased every time there is a
+ * significant change to the API, such as the introduction of a new call,
+ * the definition of a new macro/enum member, or any other element that
+ * libusb applications may want to detect at compilation time.
+ *
+ * The macro is typically used in an application as follows:
+ * \code
+ * #if defined(LIBUSB_API_VERSION) && (LIBUSB_API_VERSION >= 0x01001234)
+ * // Use one of the newer features from the libusb API
+ * #endif
+ * \endcode
+ *
+ * Internally, LIBUSB_API_VERSION is defined as follows:
+ * (libusb major << 24) | (libusb minor << 16) | (16 bit incremental)
+  }
+
+    const
+      LIBUSB_API_VERSION = $01000104;      
+    { The following is kept for compatibility, but will be deprecated in the future  }
+      LIBUSBX_API_VERSION = LIBUSB_API_VERSION;      
+{ C++ extern C conditionnal removed }
+{*
+ * \ingroup misc
+ * Convert a 16-bit value from host-endian to little-endian format. On
+ * little endian systems, this function does nothing. On big endian systems,
+ * the bytes are swapped.
+ * \param x the host-endian value to convert
+ * \returns the value in little-endian byte order
+  }
+
+function libusb_cpu_to_le16(const x:uint16_t):uint16_t;
+
+
+    {* \def libusb_le16_to_cpu
+     * \ingroup misc
+     * Convert a 16-bit value from little-endian to host-endian format. On
+     * little endian systems, this function does nothing. On big endian systems,
+     * the bytes are swapped.
+     * \param x the little-endian value to convert
+     * \returns the value in host-endian byte order
+      }
+
+function libusb_le16_to_cpu(const x:uint16_t):uint16_t;
+
+{ standard USB stuff  }
+{* \ingroup desc
+ * Device and/or Interface Class codes  }
+type
+  libusb_class_code = (
+  {* In the context of a \ref libusb_device_descriptor "device descriptor",
+    	 * this bDeviceClass value indicates that each interface specifies its
+    	 * own class information and all interfaces operate independently.
+    	  }
+    LIBUSB_CLASS_PER_INTERFACE = 0,
+    {* Audio class  }
+    LIBUSB_CLASS_AUDIO = 1,
+    {* Communications class  }
+    LIBUSB_CLASS_COMM = 2,
+    {* Human Interface Device class  }
+    LIBUSB_CLASS_HID = 3,
+    {* Physical  }
+    LIBUSB_CLASS_PHYSICAL = 5,
+    {* Printer class  }
+    LIBUSB_CLASS_PRINTER = 7,
+    {* Image class  } { legacy name from libusb-0.1 usb.h  }
+    LIBUSB_CLASS_PTP = 6,LIBUSB_CLASS_IMAGE = 6,
+    {* Mass storage class  }
+    LIBUSB_CLASS_MASS_STORAGE = 8,
+    {* Hub class  }
+    LIBUSB_CLASS_HUB = 9,
+    {* Data class  }
+    LIBUSB_CLASS_DATA = 10,
+    {* Smart Card  }
+    LIBUSB_CLASS_SMART_CARD = $0b,
+    {* Content Security  }
+    LIBUSB_CLASS_CONTENT_SECURITY = $0d,
+    {* Video  }
+    LIBUSB_CLASS_VIDEO = $0e,
+    {* Personal Healthcare  }
+    LIBUSB_CLASS_PERSONAL_HEALTHCARE = $0f,
+    {* Diagnostic Device  }
+    LIBUSB_CLASS_DIAGNOSTIC_DEVICE = $dc,
+    {* Wireless class  }
+    LIBUSB_CLASS_WIRELESS = $e0,
+    {* Application class  }
+    LIBUSB_CLASS_APPLICATION = $fe,
+    {* Class is vendor-specific  }
+    LIBUSB_CLASS_VENDOR_SPEC = $ff);
+
+    {* \ingroup desc
+     * Descriptor types as defined by the USB specification.  }
+      libusb_descriptor_type = (
+        {* Device descriptor. See libusb_device_descriptor.  }
+        LIBUSB_DT_DEVICE = $01,
+        {* Configuration descriptor. See libusb_config_descriptor.  }
+        LIBUSB_DT_CONFIG = $02,
+        {* String descriptor  }
+        LIBUSB_DT_STRING = $03,
+        {* Interface descriptor. See libusb_interface_descriptor.  }
+        LIBUSB_DT_INTERFACE = $04,
+        {* Endpoint descriptor. See libusb_endpoint_descriptor.  }
+        LIBUSB_DT_ENDPOINT = $05,
+        {* BOS descriptor  }
+        LIBUSB_DT_BOS = $0f,
+        {* Device Capability descriptor  }
+        LIBUSB_DT_DEVICE_CAPABILITY = $10,
+        {* HID descriptor  }
+        LIBUSB_DT_HID = $21,
+        {* HID report descriptor  }
+        LIBUSB_DT_REPORT = $22,
+        {* Physical descriptor  }
+        LIBUSB_DT_PHYSICAL = $23,
+        {* Hub descriptor  }
+        LIBUSB_DT_HUB = $29,
+        {* SuperSpeed Hub descriptor  }
+        LIBUSB_DT_SUPERSPEED_HUB = $2a,
+        {* SuperSpeed Endpoint Companion descriptor  }
+        LIBUSB_DT_SS_ENDPOINT_COMPANION = $30
+        );
+
+    { Descriptor sizes per descriptor type  }
+
+    const
+      LIBUSB_DT_DEVICE_SIZE = 18;      
+      LIBUSB_DT_CONFIG_SIZE = 9;      
+      LIBUSB_DT_INTERFACE_SIZE = 9;      
+      LIBUSB_DT_ENDPOINT_SIZE = 7;      
+    { Audio extension  }
+      LIBUSB_DT_ENDPOINT_AUDIO_SIZE = 9;      
+      LIBUSB_DT_HUB_NONVAR_SIZE = 7;      
+      LIBUSB_DT_SS_ENDPOINT_COMPANION_SIZE = 6;      
+      LIBUSB_DT_BOS_SIZE = 5;      
+      LIBUSB_DT_DEVICE_CAPABILITY_SIZE = 3;      
+    { BOS descriptor sizes  }
+      LIBUSB_BT_USB_2_0_EXTENSION_SIZE = 7;      
+      LIBUSB_BT_SS_USB_DEVICE_CAPABILITY_SIZE = 10;      
+      LIBUSB_BT_CONTAINER_ID_SIZE = 20;      
+    { We unwrap the BOS => define its max size  }
+
+    { was #define dname def_expr }
+
+    { was #define dname def_expr }
+
+const LIBUSB_DT_BOS_MAX_SIZE =
+              ((LIBUSB_DT_BOS_SIZE) +
+               (LIBUSB_BT_USB_2_0_EXTENSION_SIZE) +
+					     (LIBUSB_BT_SS_USB_DEVICE_CAPABILITY_SIZE) +
+               (LIBUSB_BT_CONTAINER_ID_SIZE));
+
+{ in bEndpointAddress  }
+const
+  LIBUSB_ENDPOINT_ADDRESS_MASK = $0f;
+  LIBUSB_ENDPOINT_DIR_MASK = $80;
+
+{* \ingroup desc
+ * Endpoint direction. Values for bit 7 of the
+ * \ref libusb_endpoint_descriptor::bEndpointAddress "endpoint address" scheme.
+  }
+type
+  libusb_endpoint_direction = (
+    {* In: device-to-host  }
+    LIBUSB_ENDPOINT_IN = $80,
+    {* Out: host-to-device  }
+    LIBUSB_ENDPOINT_OUT = $00
+    );
+
+  { in bmAttributes  }
+
+const
+  LIBUSB_TRANSFER_TYPE_MASK = $03;
+
+{* \ingroup desc
+ * Endpoint transfer type. Values for bits 0:1 of the
+ * \ref libusb_endpoint_descriptor::bmAttributes "endpoint attributes" field.
+  }
+type
+  libusb_transfer_type = (
+    {* Control endpoint  }
+    LIBUSB_TRANSFER_TYPE_CONTROL = 0,
+    {* Isochronous endpoint  }
+    LIBUSB_TRANSFER_TYPE_ISOCHRONOUS = 1,
+    {* Bulk endpoint  }
+    LIBUSB_TRANSFER_TYPE_BULK = 2,
+    {* Interrupt endpoint  }
+    LIBUSB_TRANSFER_TYPE_INTERRUPT = 3,
+    {* Stream endpoint  }
+    LIBUSB_TRANSFER_TYPE_BULK_STREAM = 4
+    );
+
+  {* \ingroup misc
+  * Standard requests, as defined in table 9-5 of the USB 3.0 specifications  }
+  libusb_standard_request = (
+    {* Request status of the specific recipient  }
+    LIBUSB_REQUEST_GET_STATUS = $00,
+    {* Clear or disable a specific feature  }
+    LIBUSB_REQUEST_CLEAR_FEATURE = $01,
+    { 0x02 is reserved  }
+    {* Set or enable a specific feature  }
+    LIBUSB_REQUEST_SET_FEATURE = $03,
+    { 0x04 is reserved  }
+    {* Set device address for all future accesses  }
+    LIBUSB_REQUEST_SET_ADDRESS = $05,
+    {* Get the specified descriptor  }
+    LIBUSB_REQUEST_GET_DESCRIPTOR = $06,
+    {* Used to update existing descriptors or add new descriptors  }
+    LIBUSB_REQUEST_SET_DESCRIPTOR = $07,
+    {* Get the current device configuration value  }
+    LIBUSB_REQUEST_GET_CONFIGURATION = $08,
+    {* Set device configuration  }
+    LIBUSB_REQUEST_SET_CONFIGURATION = $09,
+    {* Return the selected alternate setting for the specified interface  }
+    LIBUSB_REQUEST_GET_INTERFACE = $0A,
+    {* Select an alternate interface for the specified interface  }
+    LIBUSB_REQUEST_SET_INTERFACE = $0B,
+    {* Set then report an endpoint's synchronization frame  }
+    LIBUSB_REQUEST_SYNCH_FRAME = $0C,
+    {* Sets both the U1 and U2 Exit Latency  }
+    LIBUSB_REQUEST_SET_SEL = $30,
+    {* Delay from the time a host transmits a packet to the time it is
+     * received by the device.  }
+    LIBUSB_SET_ISOCH_DELAY = $31);
+
+{* \ingroup misc
+ * Request type bits of the
+ * \ref libusb_control_setup::bmRequestType "bmRequestType" field in control
+ * transfers.  }
+  libusb_request_type = (
+    {* Standard  }
+    LIBUSB_REQUEST_TYPE_STANDARD = $00 shl 5,
+    {* Class  }
+    LIBUSB_REQUEST_TYPE_CLASS = $01 shl 5,
+    {* Vendor  }
+    LIBUSB_REQUEST_TYPE_VENDOR = $02 shl 5,
+    {* Reserved  }
+    LIBUSB_REQUEST_TYPE_RESERVED = $03 shl 5
+    );
+
+{* \ingroup misc
+ * Recipient bits of the
+ * \ref libusb_control_setup::bmRequestType "bmRequestType" field in control
+ * transfers. Values 4 through 31 are reserved.  }
+  libusb_request_recipient = (
+    {* Device  }
+    LIBUSB_RECIPIENT_DEVICE = $00,
+    {* Interface  }
+    LIBUSB_RECIPIENT_INTERFACE = $01,
+    {* Endpoint  }
+    LIBUSB_RECIPIENT_ENDPOINT = $02,
+    {* Other  }
+    LIBUSB_RECIPIENT_OTHER = $03
+    );
+
+
+const
+  LIBUSB_ISO_SYNC_TYPE_MASK = $0C;
+  {* \ingroup desc
+   * Synchronization type for isochronous endpoints. Values for bits 2:3 of the
+   * \ref libusb_endpoint_descriptor::bmAttributes "bmAttributes" field in
+   * libusb_endpoint_descriptor.
+    }
+type
+  libusb_iso_sync_type = (
+    {* No synchronization  }
+    LIBUSB_ISO_SYNC_TYPE_NONE = 0,
+    {* Asynchronous  }
+    LIBUSB_ISO_SYNC_TYPE_ASYNC = 1,
+    {* Adaptive  }
+    LIBUSB_ISO_SYNC_TYPE_ADAPTIVE = 2,
+    {* Synchronous  }
+    LIBUSB_ISO_SYNC_TYPE_SYNC = 3);
+
+
+const
+  LIBUSB_ISO_USAGE_TYPE_MASK = $30;
+  {* \ingroup desc
+   * Usage type for isochronous endpoints. Values for bits 4:5 of the
+   * \ref libusb_endpoint_descriptor::bmAttributes "bmAttributes" field in
+   * libusb_endpoint_descriptor.
+    }
+type
+  libusb_iso_usage_type = (
+    {* Data endpoint  }
+    LIBUSB_ISO_USAGE_TYPE_DATA = 0,
+    {* Feedback endpoint  }
+    LIBUSB_ISO_USAGE_TYPE_FEEDBACK = 1,
+    {* Implicit feedback Data endpoint  }
+    LIBUSB_ISO_USAGE_TYPE_IMPLICIT = 2
+    );
+
+  {* \ingroup desc
+   * A structure representing the standard USB device descriptor. This
+   * descriptor is documented in section 9.6.1 of the USB 3.0 specification.
+   * All multiple-byte fields are represented in host-endian format.
+    }
+  {* Size of this descriptor (in bytes)  }
+  {* Descriptor type. Will have value
+  	 * \ref libusb_descriptor_type::LIBUSB_DT_DEVICE LIBUSB_DT_DEVICE in this
+  	 * context.  }
+  {* USB specification release number in binary-coded decimal. A value of
+  	 * 0x0200 indicates USB 2.0, 0x0110 indicates USB 1.1, etc.  }
+  {* USB-IF class code for the device. See \ref libusb_class_code.  }
+  {* USB-IF subclass code for the device, qualified by the bDeviceClass
+  	 * value  }
+  {* USB-IF protocol code for the device, qualified by the bDeviceClass and
+  	 * bDeviceSubClass values  }
+  {* Maximum packet size for endpoint 0  }
+  {* USB-IF vendor ID  }
+  {* USB-IF product ID  }
+  {* Device release number in binary-coded decimal  }
+  {* Index of string descriptor describing manufacturer  }
+  {* Index of string descriptor describing product  }
+  {* Index of string descriptor containing device serial number  }
+  {* Number of possible configurations  }
+    libusb_device_descriptor = record
+        bLength : uint8_t;
+        bDescriptorType : uint8_t;
+        bcdUSB : uint16_t;
+        bDeviceClass : uint8_t;
+        bDeviceSubClass : uint8_t;
+        bDeviceProtocol : uint8_t;
+        bMaxPacketSize0 : uint8_t;
+        idVendor : uint16_t;
+        idProduct : uint16_t;
+        bcdDevice : uint16_t;
+        iManufacturer : uint8_t;
+        iProduct : uint8_t;
+        iSerialNumber : uint8_t;
+        bNumConfigurations : uint8_t;
+      end;
+
+  {* \ingroup desc
+   * A structure representing the standard USB endpoint descriptor. This
+   * descriptor is documented in section 9.6.6 of the USB 3.0 specification.
+   * All multiple-byte fields are represented in host-endian format.
+    }
+  {* Size of this descriptor (in bytes)  }
+  {* Descriptor type. Will have value
+  	 * \ref libusb_descriptor_type::LIBUSB_DT_ENDPOINT LIBUSB_DT_ENDPOINT in
+  	 * this context.  }
+  {* The address of the endpoint described by this descriptor. Bits 0:3 are
+  	 * the endpoint number. Bits 4:6 are reserved. Bit 7 indicates direction,
+  	 * see \ref libusb_endpoint_direction.
+  	  }
+  {* Attributes which apply to the endpoint when it is configured using
+  	 * the bConfigurationValue. Bits 0:1 determine the transfer type and
+  	 * correspond to \ref libusb_transfer_type. Bits 2:3 are only used for
+  	 * isochronous endpoints and correspond to \ref libusb_iso_sync_type.
+  	 * Bits 4:5 are also only used for isochronous endpoints and correspond to
+  	 * \ref libusb_iso_usage_type. Bits 6:7 are reserved.
+  	  }
+  {* Maximum packet size this endpoint is capable of sending/receiving.  }
+  {* Interval for polling endpoint for data transfers.  }
+  {* For audio devices only: the rate at which synchronization feedback
+  	 * is provided.  }
+  {* For audio devices only: the address if the synch endpoint  }
+  {* Extra descriptors. If libusb encounters unknown endpoint descriptors,
+  	 * it will store them here, should you wish to parse them.  }
+(* Const before type ignored *)
+  {* Length of the extra descriptors, in bytes.  }
+  	plibusb_endpoint_descriptor = ^libusb_endpoint_descriptor;
+    libusb_endpoint_descriptor = record
+        bLength : uint8_t;
+        bDescriptorType : uint8_t;
+        bEndpointAddress : uint8_t;
+        bmAttributes : uint8_t;
+        wMaxPacketSize : uint16_t;
+        bInterval : uint8_t;
+        bRefresh : uint8_t;
+        bSynchAddress : uint8_t;
+        extra : ^byte;
+        extra_length : longint;
+      end;
+
+  {* \ingroup desc
+   * A structure representing the standard USB interface descriptor. This
+   * descriptor is documented in section 9.6.5 of the USB 3.0 specification.
+   * All multiple-byte fields are represented in host-endian format.
+    }
+  {* Size of this descriptor (in bytes)  }
+  {* Descriptor type. Will have value
+  	 * \ref libusb_descriptor_type::LIBUSB_DT_INTERFACE LIBUSB_DT_INTERFACE
+  	 * in this context.  }
+  {* Number of this interface  }
+  {* Value used to select this alternate setting for this interface  }
+  {* Number of endpoints used by this interface (excluding the control
+  	 * endpoint).  }
+  {* USB-IF class code for this interface. See \ref libusb_class_code.  }
+  {* USB-IF subclass code for this interface, qualified by the
+  	 * bInterfaceClass value  }
+  {* USB-IF protocol code for this interface, qualified by the
+  	 * bInterfaceClass and bInterfaceSubClass values  }
+  {* Index of string descriptor describing this interface  }
+  {* Array of endpoint descriptors. This length of this array is determined
+  	 * by the bNumEndpoints field.  }
+(* Const before type ignored *)
+  {* Extra descriptors. If libusb encounters unknown interface descriptors,
+  	 * it will store them here, should you wish to parse them.  }
+(* Const before type ignored *)
+  {* Length of the extra descriptors, in bytes.  }
+    libusb_interface_descriptor = record
+        bLength : uint8_t;
+        bDescriptorType : uint8_t;
+        bInterfaceNumber : uint8_t;
+        bAlternateSetting : uint8_t;
+        bNumEndpoints : uint8_t;
+        bInterfaceClass : uint8_t;
+        bInterfaceSubClass : uint8_t;
+        bInterfaceProtocol : uint8_t;
+        iInterface : uint8_t;
+        endpoint : ^libusb_endpoint_descriptor;
+        extra : ^byte;
+        extra_length : longint;
+      end;
+
+  {* \ingroup desc
+   * A collection of alternate settings for a particular USB interface.
+    }
+  {* Array of interface descriptors. The length of this array is determined
+  	 * by the num_altsetting field.  }
+(* Const before type ignored *)
+  {* The number of alternate settings that belong to this interface  }
+    libusb_interface = record
+        altsetting : ^libusb_interface_descriptor;
+        num_altsetting : longint;
+      end;
+
+  {* \ingroup desc
+   * A structure representing the standard USB configuration descriptor. This
+   * descriptor is documented in section 9.6.3 of the USB 3.0 specification.
+   * All multiple-byte fields are represented in host-endian format.
+    }
+  {* Size of this descriptor (in bytes)  }
+  {* Descriptor type. Will have value
+  	 * \ref libusb_descriptor_type::LIBUSB_DT_CONFIG LIBUSB_DT_CONFIG
+  	 * in this context.  }
+  {* Total length of data returned for this configuration  }
+  {* Number of interfaces supported by this configuration  }
+  {* Identifier value for this configuration  }
+  {* Index of string descriptor describing this configuration  }
+  {* Configuration characteristics  }
+  {* Maximum power consumption of the USB device from this bus in this
+  	 * configuration when the device is fully operation. Expressed in units
+  	 * of 2 mA when the device is operating in high-speed mode and in units
+  	 * of 8 mA when the device is operating in super-speed mode.  }
+  {* Array of interfaces supported by this configuration. The length of
+  	 * this array is determined by the bNumInterfaces field.  }
+(* Const before type ignored *)
+  {* Extra descriptors. If libusb encounters unknown configuration
+  	 * descriptors, it will store them here, should you wish to parse them.  }
+(* Const before type ignored *)
+  {* Length of the extra descriptors, in bytes.  }
+    plibusb_config_descriptor=^libusb_config_descriptor;
+    libusb_config_descriptor = record
+        bLength : uint8_t;
+        bDescriptorType : uint8_t;
+        wTotalLength : uint16_t;
+        bNumInterfaces : uint8_t;
+        bConfigurationValue : uint8_t;
+        iConfiguration : uint8_t;
+        bmAttributes : uint8_t;
+        MaxPower : uint8_t;
+        interface_ : ^libusb_interface;
+        extra : ^byte;
+        extra_length : longint;
+      end;
+
+  {* \ingroup desc
+   * A structure representing the superspeed endpoint companion
+   * descriptor. This descriptor is documented in section 9.6.7 of
+   * the USB 3.0 specification. All multiple-byte fields are represented in
+   * host-endian format.
+    }
+  {* Size of this descriptor (in bytes)  }
+  {* Descriptor type. Will have value
+  	 * \ref libusb_descriptor_type::LIBUSB_DT_SS_ENDPOINT_COMPANION in
+  	 * this context.  }
+  {* The maximum number of packets the endpoint can send or
+  	 *  recieve as part of a burst.  }
+  {* In bulk EP:	bits 4:0 represents the	maximum	number of
+  	 *  streams the	EP supports. In	isochronous EP:	bits 1:0
+  	 *  represents the Mult	- a zero based value that determines
+  	 *  the	maximum	number of packets within a service interval   }
+  {* The	total number of bytes this EP will transfer every
+  	 *  service interval. valid only for periodic EPs.  }
+    plibusb_ss_endpoint_companion_descriptor = ^libusb_ss_endpoint_companion_descriptor;
+    libusb_ss_endpoint_companion_descriptor = record
+        bLength : uint8_t;
+        bDescriptorType : uint8_t;
+        bMaxBurst : uint8_t;
+        bmAttributes : uint8_t;
+        wBytesPerInterval : uint16_t;
+      end;
+
+  {* \ingroup desc
+   * A generic representation of a BOS Device Capability descriptor. It is
+   * advised to check bDevCapabilityType and call the matching
+   * libusb_get_*_descriptor function to get a structure fully matching the type.
+    }
+  {* Size of this descriptor (in bytes)  }
+  {* Descriptor type. Will have value
+  	 * \ref libusb_descriptor_type::LIBUSB_DT_DEVICE_CAPABILITY
+  	 * LIBUSB_DT_DEVICE_CAPABILITY in this context.  }
+  {* Device Capability type  }
+  {* Device Capability data (bLength - 3 bytes)  }
+
+  type
+    plibusb_bos_dev_capability_descriptor = ^libusb_bos_dev_capability_descriptor;
+    libusb_bos_dev_capability_descriptor = record
+        bLength : uint8_t;
+        bDescriptorType : uint8_t;
+        bDevCapabilityType : uint8_t;
+        dev_capability_data : array[0..0] of uint8_t;
+      end;
+
+  {* \ingroup desc
+   * A structure representing the Binary Device Object Store (BOS) descriptor.
+   * This descriptor is documented in section 9.6.2 of the USB 3.0 specification.
+   * All multiple-byte fields are represented in host-endian format.
+    }
+  {* Size of this descriptor (in bytes)  }
+  {* Descriptor type. Will have value
+  	 * \ref libusb_descriptor_type::LIBUSB_DT_BOS LIBUSB_DT_BOS
+  	 * in this context.  }
+  {* Length of this descriptor and all of its sub descriptors  }
+  {* The number of separate device capability descriptors in
+  	 * the BOS  }
+  {* bNumDeviceCap Device Capability Descriptors  }
+
+  type
+    plibusb_bos_descriptor = ^libusb_bos_descriptor;
+    libusb_bos_descriptor = record
+        bLength : uint8_t;
+        bDescriptorType : uint8_t;
+        wTotalLength : uint16_t;
+        bNumDeviceCaps : uint8_t;
+        dev_capability : array[0..0] of ^libusb_bos_dev_capability_descriptor;
+      end;
+
+  {* \ingroup desc
+   * A structure representing the USB 2.0 Extension descriptor
+   * This descriptor is documented in section 9.6.2.1 of the USB 3.0 specification.
+   * All multiple-byte fields are represented in host-endian format.
+    }
+  {* Size of this descriptor (in bytes)  }
+  {* Descriptor type. Will have value
+  	 * \ref libusb_descriptor_type::LIBUSB_DT_DEVICE_CAPABILITY
+  	 * LIBUSB_DT_DEVICE_CAPABILITY in this context.  }
+  {* Capability type. Will have value
+  	 * \ref libusb_capability_type::LIBUSB_BT_USB_2_0_EXTENSION
+  	 * LIBUSB_BT_USB_2_0_EXTENSION in this context.  }
+  {* Bitmap encoding of supported device level features.
+  	 * A value of one in a bit location indicates a feature is
+  	 * supported; a value of zero indicates it is not supported.
+  	 * See \ref libusb_usb_2_0_extension_attributes.  }
+    plibusb_usb_2_0_extension_descriptor = ^libusb_usb_2_0_extension_descriptor;
+    libusb_usb_2_0_extension_descriptor = record
+        bLength : uint8_t;
+        bDescriptorType : uint8_t;
+        bDevCapabilityType : uint8_t;
+        bmAttributes : uint32_t;
+      end;
+
+  {* \ingroup desc
+   * A structure representing the SuperSpeed USB Device Capability descriptor
+   * This descriptor is documented in section 9.6.2.2 of the USB 3.0 specification.
+   * All multiple-byte fields are represented in host-endian format.
+    }
+  {* Size of this descriptor (in bytes)  }
+  {* Descriptor type. Will have value
+  	 * \ref libusb_descriptor_type::LIBUSB_DT_DEVICE_CAPABILITY
+  	 * LIBUSB_DT_DEVICE_CAPABILITY in this context.  }
+  {* Capability type. Will have value
+  	 * \ref libusb_capability_type::LIBUSB_BT_SS_USB_DEVICE_CAPABILITY
+  	 * LIBUSB_BT_SS_USB_DEVICE_CAPABILITY in this context.  }
+  {* Bitmap encoding of supported device level features.
+  	 * A value of one in a bit location indicates a feature is
+  	 * supported; a value of zero indicates it is not supported.
+  	 * See \ref libusb_ss_usb_device_capability_attributes.  }
+  {* Bitmap encoding of the speed supported by this device when
+  	 * operating in SuperSpeed mode. See \ref libusb_supported_speed.  }
+  {* The lowest speed at which all the functionality supported
+  	 * by the device is available to the user. For example if the
+  	 * device supports all its functionality when connected at
+  	 * full speed and above then it sets this value to 1.  }
+  {* U1 Device Exit Latency.  }
+  {* U2 Device Exit Latency.  }
+  	plibusb_ss_usb_device_capability_descriptor = ^libusb_ss_usb_device_capability_descriptor;
+    libusb_ss_usb_device_capability_descriptor = record
+        bLength : uint8_t;
+        bDescriptorType : uint8_t;
+        bDevCapabilityType : uint8_t;
+        bmAttributes : uint8_t;
+        wSpeedSupported : uint16_t;
+        bFunctionalitySupport : uint8_t;
+        bU1DevExitLat : uint8_t;
+        bU2DevExitLat : uint16_t;
+      end;
+
+  {* \ingroup desc
+   * A structure representing the Container ID descriptor.
+   * This descriptor is documented in section 9.6.2.3 of the USB 3.0 specification.
+   * All multiple-byte fields, except UUIDs, are represented in host-endian format.
+    }
+  {* Size of this descriptor (in bytes)  }
+  {* Descriptor type. Will have value
+  	 * \ref libusb_descriptor_type::LIBUSB_DT_DEVICE_CAPABILITY
+  	 * LIBUSB_DT_DEVICE_CAPABILITY in this context.  }
+  {* Capability type. Will have value
+  	 * \ref libusb_capability_type::LIBUSB_BT_CONTAINER_ID
+  	 * LIBUSB_BT_CONTAINER_ID in this context.  }
+  {* Reserved field  }
+  {* 128 bit UUID  }
+  	plibusb_container_id_descriptor = ^libusb_container_id_descriptor;
+    libusb_container_id_descriptor = record
+        bLength : uint8_t;
+        bDescriptorType : uint8_t;
+        bDevCapabilityType : uint8_t;
+        bReserved : uint8_t;
+        ContainerID : array[0..15] of uint8_t;
+      end;
+
+  {* \ingroup asyncio
+   * Setup packet for control transfers.  }
+  {* Request type. Bits 0:4 determine recipient, see
+  	 * \ref libusb_request_recipient. Bits 5:6 determine type, see
+  	 * \ref libusb_request_type. Bit 7 determines data transfer direction, see
+  	 * \ref libusb_endpoint_direction.
+  	  }
+  {* Request. If the type bits of bmRequestType are equal to
+  	 * \ref libusb_request_type::LIBUSB_REQUEST_TYPE_STANDARD
+  	 * "LIBUSB_REQUEST_TYPE_STANDARD" then this field refers to
+  	 * \ref libusb_standard_request. For other cases, use of this field is
+  	 * application-specific.  }
+  {* Value. Varies according to request  }
+  {* Index. Varies according to request, typically used to pass an index
+  	 * or offset  }
+  {* Number of bytes to transfer  }
+  	plibusb_control_setup = ^libusb_control_setup;
+    libusb_control_setup = record
+        bmRequestType : uint8_t;
+        bRequest : uint8_t;
+        wValue : uint16_t;
+        wIndex : uint16_t;
+        wLength : uint16_t;
+      end;
+
+    const LIBUSB_CONTROL_SETUP_SIZE = sizeof(libusb_control_setup);
+
+type
+    { libusb  }
+      plibusb_context = ^libusb_context;
+      libusb_context = record
+          {undefined structure}
+        end;
+
+      plibusb_device=^libusb_device;
+      libusb_device = record
+          {undefined structure}
+        end;
+
+      plibusb_device_handle=^libusb_device_handle;
+      libusb_device_handle = record
+          {undefined structure}
+        end;
+
+    {* \ingroup lib
+     * Structure providing the version of the libusb runtime
+      }
+
+
+
+(* Const before type ignored *)
+
+(* Const before type ignored *)
+
+(* Const before type ignored *)
+
+(* Const before type ignored *)
+
+(* Const before type ignored *)
+       plibusb_version = ^libusb_version;
+       libusb_version = record
+          {* Library major version.  }
+          major : uint16_t;
+          {* Library minor version.  }
+          minor : uint16_t;
+          {* Library micro version.  }
+          micro : uint16_t;
+          {* Library nano version.  }
+          nano : uint16_t;
+          {* Library release candidate suffix string, e.g. "-rc4".  }
+          rc : ^ansichar;
+          {* For ABI compatibility only.  }
+          describe : ^ansichar;
+        end;
+
+{* \ingroup lib
+ * Structure representing a libusb session. The concept of individual libusb
+ * sessions allows for your program to use two libraries (or dynamically
+ * load two modules) which both independently use libusb. This will prevent
+ * interference between the individual libusb users - for example
+ * libusb_set_debug() will not affect the other user of the library, and
+ * libusb_exit() will not destroy resources that the other user is still
+ * using.
+ *
+ * Sessions are created by libusb_init() and destroyed through libusb_exit().
+ * If your application is guaranteed to only ever include a single libusb
+ * user (i.e. you), you do not have to worry about contexts: pass NULL in
+ * every function call where a context is required. The default context
+ * will be used.
+ *
+ * For more information, see \ref contexts.
+  }
+{* \ingroup dev
+ * Structure representing a USB device detected on the system. This is an
+ * opaque type for which you are only ever provided with a pointer, usually
+ * originating from libusb_get_device_list().
+ *
+ * Certain operations can be performed on a device, but in order to do any
+ * I/O you will have to first obtain a device handle using libusb_open().
+ *
+ * Devices are reference counted with libusb_ref_device() and
+ * libusb_unref_device(), and are freed when the reference count reaches 0.
+ * New devices presented by libusb_get_device_list() have a reference count of
+ * 1, and libusb_free_device_list() can optionally decrease the reference count
+ * on all devices in the list. libusb_open() adds another reference which is
+ * later destroyed by libusb_close().
+  }
+{* \ingroup dev
+ * Structure representing a handle on a USB device. This is an opaque type for
+ * which you are only ever provided with a pointer, usually originating from
+ * libusb_open().
+ *
+ * A device handle is used to perform I/O and other operations. When finished
+ * with a device handle, you should call libusb_close().
+  }
+{* \ingroup dev
+ * Speed codes. Indicates the speed at which the device is operating.
+  }
+  libusb_speed = (
+    {* The OS doesn't report or know the device speed.  }
+    LIBUSB_SPEED_UNKNOWN = 0,
+    {* The device is operating at low speed (1.5MBit/s).  }
+    LIBUSB_SPEED_LOW = 1,
+    {* The device is operating at full speed (12MBit/s).  }
+    LIBUSB_SPEED_FULL = 2,
+    {* The device is operating at high speed (480MBit/s).  }
+    LIBUSB_SPEED_HIGH = 3,
+    {* The device is operating at super speed (5000MBit/s).  }
+    LIBUSB_SPEED_SUPER = 4);
+
+{* \ingroup dev
+ * Supported speeds (wSpeedSupported) bitfield. Indicates what
+ * speeds the device supports.
+  }
+  libusb_supported_speed = (
+    {* Low speed operation supported (1.5MBit/s).  }
+    LIBUSB_LOW_SPEED_OPERATION = 1,
+    {* Full speed operation supported (12MBit/s).  }
+    LIBUSB_FULL_SPEED_OPERATION = 2,
+    {* High speed operation supported (480MBit/s).  }
+    LIBUSB_HIGH_SPEED_OPERATION = 4,
+    {* Superspeed operation supported (5000MBit/s).  }
+    LIBUSB_SUPER_SPEED_OPERATION = 8
+    );
+
+{* \ingroup dev
+ * Masks for the bits of the
+ * \ref libusb_usb_2_0_extension_descriptor::bmAttributes "bmAttributes" field
+ * of the USB 2.0 Extension descriptor.
+  }
+    {* Supports Link Power Management (LPM)  }
+    libusb_usb_2_0_extension_attributes = (LIBUSB_BM_LPM_SUPPORT = 2);
+
+{* \ingroup dev
+ * Masks for the bits of the
+ * \ref libusb_ss_usb_device_capability_descriptor::bmAttributes "bmAttributes" field
+ * field of the SuperSpeed USB Device Capability descriptor.
+  }
+    {* Supports Latency Tolerance Messages (LTM)  }
+    libusb_ss_usb_device_capability_attributes = (LIBUSB_BM_LTM_SUPPORT = 2);
+
+{* \ingroup dev
+ * USB capability types
+  }
+  libusb_bos_type = (
+    {* Wireless USB device capability  }
+    LIBUSB_BT_WIRELESS_USB_DEVICE_CAPABILITY = 1,
+    {* USB 2.0 extensions  }
+    LIBUSB_BT_USB_2_0_EXTENSION = 2,
+    {* SuperSpeed USB device capability  }
+    LIBUSB_BT_SS_USB_DEVICE_CAPABILITY = 3,
+    {* Container ID type  }
+    LIBUSB_BT_CONTAINER_ID = 4);
+
+{* \ingroup misc
+ * Error codes. Most libusb functions return 0 on success or one of these
+ * codes on failure.
+ * You can call libusb_error_name() to retrieve a string representation of an
+ * error code or libusb_strerror() to get an end-user suitable description of
+ * an error code.
+  }
+{ NB: Remember to update LIBUSB_ERROR_COUNT below as well as the
+     message strings in strerror.c when adding new error codes here.  }
+  libusb_error = (
+    {* Success (no error)  }
+    LIBUSB_SUCCESS = 0,
+    {* Input/output error  }
+    LIBUSB_ERROR_IO = -(1),
+    {* Invalid parameter  }
+    LIBUSB_ERROR_INVALID_PARAM = -(2),
+    {* Access denied (insufficient permissions)  }
+    LIBUSB_ERROR_ACCESS = -(3),
+    {* No such device (it may have been disconnected)  }
+    LIBUSB_ERROR_NO_DEVICE = -(4),
+    {* Entity not found  }
+    LIBUSB_ERROR_NOT_FOUND = -(5),
+    {* Resource busy  }
+    LIBUSB_ERROR_BUSY = -(6),
+    {* Operation timed out  }
+    LIBUSB_ERROR_TIMEOUT = -(7),
+    {* Overflow  }
+    LIBUSB_ERROR_OVERFLOW = -(8),
+    {* Pipe error  }
+    LIBUSB_ERROR_PIPE = -(9),
+    {* System call interrupted (perhaps due to signal)  }
+    LIBUSB_ERROR_INTERRUPTED = -(10),
+    {* Insufficient memory  }
+    LIBUSB_ERROR_NO_MEM = -(11),
+    {* Operation not supported or unimplemented on this platform  }
+    LIBUSB_ERROR_NOT_SUPPORTED = -(12),
+    {* Other error  }
+    LIBUSB_ERROR_OTHER = -(99)
+    );
+
+{ Total number of error codes in enum libusb_error  }
+const
+    LIBUSB_ERROR_COUNT = 14;
+
+    {* \ingroup asyncio
+     * Transfer status codes  }
+
+
+
+
+
+type
+  libusb_transfer_status = (
+   {* Transfer completed without error. Note that this does not indicate
+    	 * that the entire amount of requested data was transferred.  }
+    LIBUSB_TRANSFER_COMPLETED,
+    {* Transfer failed  }
+    LIBUSB_TRANSFER_ERROR,
+    {* Transfer timed out  }
+    LIBUSB_TRANSFER_TIMED_OUT,
+    {* Transfer was cancelled  }
+    LIBUSB_TRANSFER_CANCELLED,
+    {* For bulk/interrupt endpoints: halt condition detected (endpoint
+    	 * stalled). For control endpoints: control request not supported.  }
+    LIBUSB_TRANSFER_STALL,
+    {* Device was disconnected  }
+    LIBUSB_TRANSFER_NO_DEVICE,
+    {* Device sent more data than requested  }
+    LIBUSB_TRANSFER_OVERFLOW);
+
+  { NB! Remember to update libusb_error_name()
+  	   when adding new status codes here.  }
+
+
+{* \ingroup asyncio
+ * libusb_transfer.flags values  }
+  libusb_transfer_flags = (
+    {* Report short frames as errors  }
+    LIBUSB_TRANSFER_SHORT_NOT_OK = 1 shl 0,
+    {* Automatically free() transfer buffer during libusb_free_transfer()  }
+    LIBUSB_TRANSFER_FREE_BUFFER = 1 shl 1,
+    {* Automatically call libusb_free_transfer() after callback returns.
+     * If this flag is set, it is illegal to call libusb_free_transfer()
+     * from your transfer callback, as this will result in a double-free
+     * when this flag is acted upon.  }
+    LIBUSB_TRANSFER_FREE_TRANSFER = 1 shl 2,
+    {* Terminate transfers that are a multiple of the endpoint's
+     * wMaxPacketSize with an extra zero length packet. This is useful
+     * when a device protocol mandates that each logical request is
+     * terminated by an incomplete packet (i.e. the logical requests are
+     * not separated by other means).
+     *
+     * This flag only affects host-to-device transfers to bulk and interrupt
+     * endpoints. In other situations, it is ignored.
+     *
+     * This flag only affects transfers with a length that is a multiple of
+     * the endpoint's wMaxPacketSize. On transfers of other lengths, this
+     * flag has no effect. Therefore, if you are working with a device that
+     * needs a ZLP whenever the end of the logical request falls on a packet
+     * boundary, then it is sensible to set this flag on <em>every</em>
+     * transfer (you do not have to worry about only setting it on transfers
+     * that end on the boundary).
+     *
+     * This flag is currently only supported on Linux.
+     * On other systems, libusb_submit_transfer() will return
+     * LIBUSB_ERROR_NOT_SUPPORTED for every transfer where this flag is set.
+     *
+     * Available since libusb-1.0.9.
+      }
+    LIBUSB_TRANSFER_ADD_ZERO_PACKET = 1 shl 3
+    );
+
+{* \ingroup asyncio
+ * Isochronous packet descriptor.  }
+{* Length of data to request in this packet  }
+{* Amount of data that was actually transferred  }
+{* Status code for this packet  }
+  libusb_iso_packet_descriptor = record
+      length : dword;
+      actual_length : dword;
+      status : libusb_transfer_status;
+    end;
+  {* \ingroup asyncio
+        * Asynchronous transfer callback function type. When submitting asynchronous
+        * transfers, you pass a pointer to a callback function of this type via the
+        * \ref libusb_transfer::callback "callback" member of the libusb_transfer
+        * structure. libusb will call this function later, when the transfer has
+        * completed or failed. See \ref asyncio for more information.
+        * \param transfer The libusb_transfer struct the callback function is being
+        * notified about.
+         }
+         plibusb_transfer=^libusb_transfer;
+
+       libusb_transfer_cb_fn = procedure (transfer:plibusb_transfer);LIBUSB_CALL;
+
+    {* \ingroup asyncio
+     * The generic USB transfer structure. The user populates this structure and
+     * then submits it in order to request a transfer. After the transfer has
+     * completed, the library populates the transfer with the results and passes
+     * it back to the user.
+      }
+    {* Handle of the device that this transfer will be submitted to  }
+    {* A bitwise OR combination of \ref libusb_transfer_flags.  }
+    {* Address of the endpoint where this transfer will be sent.  }
+    {* Type of the endpoint from \ref libusb_transfer_type  }
+    {* Timeout for this transfer in millseconds. A value of 0 indicates no
+    	 * timeout.  }
+    {* The status of the transfer. Read-only, and only for use within
+    	 * transfer callback function.
+    	 *
+    	 * If this is an isochronous transfer, this field may read COMPLETED even
+    	 * if there were errors in the frames. Use the
+    	 * \ref libusb_iso_packet_descriptor::status "status" field in each packet
+    	 * to determine if errors occurred.  }
+    {* Length of the data buffer  }
+    {* Actual length of data that was transferred. Read-only, and only for
+    	 * use within transfer callback function. Not valid for isochronous
+    	 * endpoint transfers.  }
+    {* Callback function. This will be invoked when the transfer completes,
+    	 * fails, or is cancelled.  }
+    {* User context data to pass to the callback function.  }
+    {* Data buffer  }
+    {* Number of isochronous packets. Only used for I/O with isochronous
+    	 * endpoints.  }
+    {* Isochronous packet descriptors, for isochronous transfers only.  }
+
+      libusb_transfer = record
+          dev_handle : ^libusb_device_handle;
+          flags : uint8_t;
+          endpoint : byte;
+          _type : byte;
+          timeout : dword;
+          status : libusb_transfer_status;
+          length : longint;
+          actual_length : longint;
+          callback : libusb_transfer_cb_fn;
+          user_data : pointer;
+          buffer : ^byte;
+          num_iso_packets : longint;
+          iso_packet_desc : array[0..0] of libusb_iso_packet_descriptor;
+        end;
+
+
+
+
+{* \ingroup misc
+ * Capabilities supported by an instance of libusb on the current running
+ * platform. Test if the loaded library supports a given capability by calling
+ * \ref libusb_has_capability().
+  }
+  libusb_capability = (
+    {* The libusb_has_capability() API is available.  }
+    LIBUSB_CAP_HAS_CAPABILITY = $0000,
+    {* Hotplug support is available on this platform.  }
+    LIBUSB_CAP_HAS_HOTPLUG = $0001,
+    {* The library can access HID devices without requiring user intervention.
+     * Note that before being able to actually access an HID device, you may
+     * still have to call additional libusb functions such as
+     * \ref libusb_detach_kernel_driver().  }
+    LIBUSB_CAP_HAS_HID_ACCESS = $0100,
+    {* The library supports detaching of the default USB driver, using
+     * \ref libusb_detach_kernel_driver(), if one is set by the OS kernel  }
+    LIBUSB_CAP_SUPPORTS_DETACH_KERNEL_DRIVER = $0101
+    );
+
+{* \ingroup lib
+ *  Log message levels.
+ *  - LIBUSB_LOG_LEVEL_NONE (0)    : no messages ever printed by the library (default)
+ *  - LIBUSB_LOG_LEVEL_ERROR (1)   : error messages are printed to stderr
+ *  - LIBUSB_LOG_LEVEL_WARNING (2) : warning and error messages are printed to stderr
+ *  - LIBUSB_LOG_LEVEL_INFO (3)    : informational messages are printed to stdout, warning
+ *    and error messages are printed to stderr
+ *  - LIBUSB_LOG_LEVEL_DEBUG (4)   : debug and informational messages are printed to stdout,
+ *    warnings and errors to stderr
+  }
+  libusb_log_level = (
+    LIBUSB_LOG_LEVEL_NONE = 0,
+    LIBUSB_LOG_LEVEL_ERROR,
+    LIBUSB_LOG_LEVEL_WARNING,
+    LIBUSB_LOG_LEVEL_INFO,
+    LIBUSB_LOG_LEVEL_DEBUG);
+
+
+function libusb_init(var ctx:plibusb_context):integer;LIBUSB_CALL;external libusb1;
+
+procedure libusb_exit(ctx:plibusb_context);LIBUSB_CALL;external libusb1;
+procedure libusb_set_debug(ctc:plibusb_context;level:integer);LIBUSB_CALL;external libusb1;
+
+function libusb_get_version():libusb_version;LIBUSB_CALL;external libusb1;
+function libusb_has_capability(capability:uint32_t):integer;LIBUSB_CALL;external libusb1;
+
+function libusb_error_name(errcode:integer):pansichar;LIBUSB_CALL;external libusb1;
+
+function libusb_setlocale(const locale:pansichar):integer;LIBUSB_CALL;external libusb1;
+
+function libusb_strerror(errcode:libusb_error):pansichar;LIBUSB_CALL;external libusb1;
+function libusb_get_device_list(ctx:plibusb_context;var list:plibusb_device):ssize_t;LIBUSB_CALL;external libusb1;
+procedure libusb_free_device_list(list:plibusb_device;unref_devices:integer);LIBUSB_CALL;external libusb1;
+function libusb_ref_device(dev:plibusb_device):plibusb_device;LIBUSB_CALL;external libusb1;
+procedure libusb_unref_device(dev:plibusb_device);LIBUSB_CALL;external libusb1;
+function libusb_get_configuration(dev:plibusb_device_handle;
+	config:pinteger):integer;LIBUSB_CALL;external libusb1;
+function libusb_get_device_descriptor(dev:plibusb_device;
+	var desc:libusb_device_descriptor):integer;LIBUSB_CALL;external libusb1;
+function libusb_get_active_config_descriptor(dev:plibusb_device;
+	var config:plibusb_config_descriptor):integer;LIBUSB_CALL;external libusb1;
+function libusb_get_config_descriptor(dev:plibusb_device;
+	config_index:uint8_t ; var config:plibusb_config_descriptor):integer;LIBUSB_CALL;external libusb1;
+
+function libusb_get_config_descriptor_by_value(dev:plibusb_device;
+	bConfigurationValue:uint8_t;var config:plibusb_config_descriptor):integer;LIBUSB_CALL;external libusb1;
+
+procedure libusb_free_config_descriptor(config:plibusb_config_descriptor);LIBUSB_CALL;external libusb1;
+
+function  libusb_get_ss_endpoint_companion_descriptor(
+	ctx:plibusb_context;
+	endpoint:plibusb_endpoint_descriptor;
+	var ep_comp:plibusb_ss_endpoint_companion_descriptor):integer;LIBUSB_CALL;external libusb1;
+
+procedure libusb_free_ss_endpoint_companion_descriptor(
+	ep_comp:plibusb_ss_endpoint_companion_descriptor);LIBUSB_CALL;external libusb1;
+
+function libusb_get_bos_descriptor(
+  handle:plibusb_device_handle;
+	var bos:plibusb_bos_descriptor):integer;LIBUSB_CALL;external libusb1;
+
+procedure libusb_free_bos_descriptor(bos:plibusb_bos_descriptor);LIBUSB_CALL;external libusb1;
+
+function libusb_get_usb_2_0_extension_descriptor(
+	ctx:plibusb_context;
+	dev_cap:plibusb_bos_dev_capability_descriptor;
+	var usb_2_0_extension:plibusb_usb_2_0_extension_descriptor):integer;LIBUSB_CALL;external libusb1;
+
+procedure libusb_free_usb_2_0_extension_descriptor(
+	usb_2_0_extension:plibusb_usb_2_0_extension_descriptor);LIBUSB_CALL;external libusb1;
+
+
+function libusb_get_ss_usb_device_capability_descriptor(
+	ctx:plibusb_context;
+	dev_cap:plibusb_bos_dev_capability_descriptor;
+	var ss_usb_device_cap:plibusb_ss_usb_device_capability_descriptor):integer;LIBUSB_CALL;external libusb1;
+
+procedure libusb_free_ss_usb_device_capability_descriptor(
+	ss_usb_device_cap:plibusb_ss_usb_device_capability_descriptor);LIBUSB_CALL;external libusb1;
+
+function libusb_get_container_id_descriptor(
+  ctx:plibusb_context;
+	dev_cap:plibusb_bos_dev_capability_descriptor;
+	var container_id:plibusb_container_id_descriptor):integer;LIBUSB_CALL;external libusb1;
+
+procedure libusb_free_container_id_descriptor(
+	container_id:plibusb_container_id_descriptor);LIBUSB_CALL;external libusb1;
+
+function libusb_get_bus_number(dev:plibusb_device):uint8_t;LIBUSB_CALL;external libusb1;
+function libusb_get_port_number(dev:plibusb_device):uint8_t;LIBUSB_CALL;external libusb1;
+
+function libusb_get_port_numbers(
+  	dev:plibusb_device;
+    port_numbers:puint8_t;
+    port_numbers_len:integer):integer;LIBUSB_CALL;external libusb1;
+
+function libusb_get_port_path(
+    ctx:plibusb_context;
+    dev:plibusb_device;
+    path:puint8_t;
+    path_length:uint8_t):integer;LIBUSB_CALL;external libusb1;
+
+function libusb_get_parent(dev:plibusb_device):plibusb_device;LIBUSB_CALL;external libusb1;
+
+function libusb_get_device_address(dev:plibusb_device):uint8_t;LIBUSB_CALL;external libusb1;
+
+function libusb_get_device_speed(dev:plibusb_device):integer;LIBUSB_CALL;external libusb1;
+
+function libusb_get_max_packet_size(
+    dev:plibusb_device;
+		endpoint:uint8_t):integer;LIBUSB_CALL;external libusb1;
+
+function libusb_get_max_iso_packet_size(
+    dev:plibusb_device;
+		endpoint:uint8_t):integer;LIBUSB_CALL;external libusb1;
+
+function libusb_open(
+    dev:plibusb_device;
+    var handle:plibusb_device_handle):integer;LIBUSB_CALL;external libusb1;
+
+procedure libusb_close(dev_handle:plibusb_device_handle);LIBUSB_CALL;external libusb1;
+
+function libusb_get_device(dev_handle:plibusb_device_handle):plibusb_device;LIBUSB_CALL;external libusb1;
+
+function libusb_set_configuration(
+    dev:plibusb_device_handle;
+		configuration:integer):integer;LIBUSB_CALL;external libusb1;
+
+function libusb_claim_interface(
+    dev:plibusb_device_handle;
+		interface_number:integer):integer;LIBUSB_CALL;external libusb1;
+
+function libusb_release_interface(
+    dev:plibusb_device_handle;
+		interface_number:integer):integer;LIBUSB_CALL;external libusb1;
+
+function libusb_open_device_with_vid_pid(
+		ctx:plibusb_context;
+    vendor_id:uint16_t;
+    product_id:uint16_t):plibusb_device_handle;LIBUSB_CALL ;external libusb1;
+
+function libusb_set_interface_alt_setting(
+    dev:plibusb_device_handle;
+		interface_number:integer;
+    alternate_setting:integer):integer;LIBUSB_CALL;external libusb1;
+
+function libusb_clear_halt(
+    dev:plibusb_device_handle;
+		endpoint:uint8_t):integer;LIBUSB_CALL;external libusb1;
+
+function libusb_reset_device(dev:plibusb_device_handle):integer;LIBUSB_CALL;external libusb1;
+
+function libusb_alloc_streams(
+    dev:plibusb_device_handle;
+		num_streams:uint32_t;
+    endpoints:puint8_t;
+    num_endpoints:integer):integer;LIBUSB_CALL;external libusb1;
+
+function libusb_free_streams(
+    dev:plibusb_device_handle;
+		endpoints:puint8_t;
+    num_endpoints:integer):integer;LIBUSB_CALL;external libusb1;
+
+function libusb_kernel_driver_active(
+    dev:plibusb_device_handle;
+		interface_number:integer):integer;LIBUSB_CALL;external libusb1;
+
+function libusb_detach_kernel_driver(
+    dev:plibusb_device_handle;
+		interface_number:integer):integer;LIBUSB_CALL;external libusb1;
+
+function libusb_attach_kernel_driver(
+    dev:plibusb_device_handle;
+		interface_number:integer):integer;LIBUSB_CALL;external libusb1;
+
+function libusb_set_auto_detach_kernel_driver(
+    dev:plibusb_device_handle;
+		enable:integer):integer;LIBUSB_CALL;external libusb1;
+
+{ async I/O  }
+{* \ingroup asyncio
+ * Get the data section of a control transfer. This convenience function is here
+ * to remind you that the data does not start until 8 bytes into the actual
+ * buffer, as the setup packet comes first.
+ *
+ * Calling this function only makes sense from a transfer callback function,
+ * or situations where you have already allocated a suitably sized buffer at
+ * transfer->buffer.
+ *
+ * \param transfer a transfer
+ * \returns pointer to the first byte of the data section
+  }
+
+function  libusb_control_transfer_get_data(
+	transfer:plibusb_transfer):puint8_t;inline;
+
+
+
+{* \ingroup asyncio
+ * Get the control setup packet of a control transfer. This convenience
+ * function is here to remind you that the control setup occupies the first
+ * 8 bytes of the transfer data buffer.
+ *
+ * Calling this function only makes sense from a transfer callback function,
+ * or situations where you have already allocated a suitably sized buffer at
+ * transfer->buffer.
+ *
+ * \param transfer a transfer
+ * \returns a casted pointer to the start of the transfer data buffer
+  }
+
+function libusb_control_transfer_get_setup(
+  transfer:plibusb_transfer):plibusb_control_setup;
+
+
+{* \ingroup asyncio
+ * Helper function to populate the setup packet (first 8 bytes of the data
+ * buffer) for a control transfer. The wIndex, wValue and wLength values should
+ * be given in host-endian byte order.
+ *
+ * \param buffer buffer to output the setup packet into
+ * This pointer must be aligned to at least 2 bytes boundary.
+ * \param bmRequestType see the
+ * \ref libusb_control_setup::bmRequestType "bmRequestType" field of
+ * \ref libusb_control_setup
+ * \param bRequest see the
+ * \ref libusb_control_setup::bRequest "bRequest" field of
+ * \ref libusb_control_setup
+ * \param wValue see the
+ * \ref libusb_control_setup::wValue "wValue" field of
+ * \ref libusb_control_setup
+ * \param wIndex see the
+ * \ref libusb_control_setup::wIndex "wIndex" field of
+ * \ref libusb_control_setup
+ * \param wLength see the
+ * \ref libusb_control_setup::wLength "wLength" field of
+ * \ref libusb_control_setup
+  }
+
+procedure libusb_fill_control_setup(
+  buffer:puint8_t;
+  bmRequestType:uint8_t;
+  bRequest: uint8_t;
+  wValue:uint16_t;
+  wIndex:uint16_t;
+  wLength:uint16_t);
+
+function libusb_alloc_transfer(iso_packets:integer):plibusb_transfer;LIBUSB_CALL;external libusb1;
+function libusb_submit_transfer(transfer:plibusb_transfer):integer;LIBUSB_CALL;external libusb1;
+function libusb_cancel_transfer(transfer:plibusb_transfer):integer;LIBUSB_CALL;external libusb1;
+procedure libusb_free_transfer(transfer:plibusb_transfer);LIBUSB_CALL;external libusb1;
+procedure libusb_transfer_set_stream_id(
+		transfer:plibusb_transfer;stream_id:uint32_t);LIBUSB_CALL;external libusb1;
+function libusb_transfer_get_stream_id(
+		transfer:plibusb_transfer):uint32_t;LIBUSB_CALL;external libusb1;
+
+
+{* \ingroup asyncio
+ * Helper function to populate the required \ref libusb_transfer fields
+ * for a control transfer.
+ *
+ * If you pass a transfer buffer to this function, the first 8 bytes will
+ * be interpreted as a control setup packet, and the wLength field will be
+ * used to automatically populate the \ref libusb_transfer::length "length"
+ * field of the transfer. Therefore the recommended approach is:
+ * -# Allocate a suitably sized data buffer (including space for control setup)
+ * -# Call libusb_fill_control_setup()
+ * -# If this is a host-to-device transfer with a data stage, put the data
+ *    in place after the setup packet
+ * -# Call this function
+ * -# Call libusb_submit_transfer()
+ *
+ * It is also legal to pass a NULL buffer to this function, in which case this
+ * function will not attempt to populate the length field. Remember that you
+ * must then populate the buffer and length fields later.
+ *
+ * \param transfer the transfer to populate
+ * \param dev_handle handle of the device that will handle the transfer
+ * \param buffer data buffer. If provided, this function will interpret the
+ * first 8 bytes as a setup packet and infer the transfer length from that.
+ * This pointer must be aligned to at least 2 bytes boundary.
+ * \param callback callback function to be invoked on transfer completion
+ * \param user_data user data to pass to callback function
+ * \param timeout timeout for the transfer in milliseconds
+  }
+
+procedure libusb_fill_control_transfer(
+  transfer:plibusb_transfer;
+  dev_handle:plibusb_device_handle;
+  buffer:puint8_t;
+  callback:libusb_transfer_cb_fn;
+  user_data:pointer;
+  timeout:cardinal);
+
+
+{* \ingroup asyncio
+ * Helper function to populate the required \ref libusb_transfer fields
+ * for a bulk transfer.
+ *
+ * \param transfer the transfer to populate
+ * \param dev_handle handle of the device that will handle the transfer
+ * \param endpoint address of the endpoint where this transfer will be sent
+ * \param buffer data buffer
+ * \param length length of data buffer
+ * \param callback callback function to be invoked on transfer completion
+ * \param user_data user data to pass to callback function
+ * \param timeout timeout for the transfer in milliseconds
+  }
+
+procedure libusb_fill_bulk_transfer(
+  transfer:plibusb_transfer;
+  dev_handle:plibusb_device_handle;
+  endpoint:uint8_t;
+  buffer:puint8_t;
+  length:integer;
+  callback:libusb_transfer_cb_fn;
+  user_data:pointer;
+  timeout:cardinal);
+
+
+{* \ingroup asyncio
+ * Helper function to populate the required \ref libusb_transfer fields
+ * for a bulk transfer using bulk streams.
+ *
+ * Since version 1.0.19, \ref LIBUSB_API_VERSION >= 0x01000103
+ *
+ * \param transfer the transfer to populate
+ * \param dev_handle handle of the device that will handle the transfer
+ * \param endpoint address of the endpoint where this transfer will be sent
+ * \param stream_id bulk stream id for this transfer
+ * \param buffer data buffer
+ * \param length length of data buffer
+ * \param callback callback function to be invoked on transfer completion
+ * \param user_data user data to pass to callback function
+ * \param timeout timeout for the transfer in milliseconds
+  }
+
+procedure libusb_fill_bulk_stream_transfer(
+  transfer:plibusb_transfer;
+  dev_handle:plibusb_device_handle;
+  endpoint:uint8_t;
+  stream_id:uint32_t;
+  buffer:puint8_t;
+  length:integer;
+  callback:libusb_transfer_cb_fn;
+  user_data:pointer;
+  timeout:cardinal);
+
+
+{* \ingroup asyncio
+ * Helper function to populate the required \ref libusb_transfer fields
+ * for an interrupt transfer.
+ *
+ * \param transfer the transfer to populate
+ * \param dev_handle handle of the device that will handle the transfer
+ * \param endpoint address of the endpoint where this transfer will be sent
+ * \param buffer data buffer
+ * \param length length of data buffer
+ * \param callback callback function to be invoked on transfer completion
+ * \param user_data user data to pass to callback function
+ * \param timeout timeout for the transfer in milliseconds
+  }
+
+procedure libusb_fill_interrupt_transfer(
+  transfer:plibusb_transfer;
+  dev_handle:plibusb_device_handle;
+  endpoint:uint8_t;
+  buffer:puint8_t;
+  length:integer;
+  callback:libusb_transfer_cb_fn;
+  user_data:pointer;
+  timeout:cardinal);
+
+
+{* \ingroup asyncio
+ * Helper function to populate the required \ref libusb_transfer fields
+ * for an isochronous transfer.
+ *
+ * \param transfer the transfer to populate
+ * \param dev_handle handle of the device that will handle the transfer
+ * \param endpoint address of the endpoint where this transfer will be sent
+ * \param buffer data buffer
+ * \param length length of data buffer
+ * \param num_iso_packets the number of isochronous packets
+ * \param callback callback function to be invoked on transfer completion
+ * \param user_data user data to pass to callback function
+ * \param timeout timeout for the transfer in milliseconds
+  }
+
+procedure libusb_fill_iso_transfer(transfer:plibusb_transfer;
+  dev_handle:plibusb_device_handle;
+  endpoint:uint8_t;
+  buffer:puint8_t;
+  length:integer;
+  num_iso_packets:integer;
+  callback:libusb_transfer_cb_fn;
+  user_data:pointer;
+  timeout:cardinal);
+
+
+{* \ingroup asyncio
+ * Convenience function to set the length of all packets in an isochronous
+ * transfer, based on the num_iso_packets field in the transfer structure.
+ *
+ * \param transfer a transfer
+ * \param length the length to set in each isochronous packet descriptor
+ * \see libusb_get_max_packet_size()
+  }
+
+procedure libusb_set_iso_packet_lengths(
+  transfer:plibusb_transfer;
+  length:cardinal);
+
+
+{* \ingroup asyncio
+ * Convenience function to locate the position of an isochronous packet
+ * within the buffer of an isochronous transfer.
+ *
+ * This is a thorough function which loops through all preceding packets,
+ * accumulating their lengths to find the position of the specified packet.
+ * Typically you will assign equal lengths to each packet in the transfer,
+ * and hence the above method is sub-optimal. You may wish to use
+ * libusb_get_iso_packet_buffer_simple() instead.
+ *
+ * \param transfer a transfer
+ * \param packet the packet to return the address of
+ * \returns the base address of the packet buffer inside the transfer buffer,
+ * or NULL if the packet does not exist.
+ * \see libusb_get_iso_packet_buffer_simple()
+  }
+
+function libusb_get_iso_packet_buffer(
+  	transfer:plibusb_transfer;
+    packet:cardinal):puint8_t;
+
+
+{* \ingroup asyncio
+ * Convenience function to locate the position of an isochronous packet
+ * within the buffer of an isochronous transfer, for transfers where each
+ * packet is of identical size.
+ *
+ * This function relies on the assumption that every packet within the transfer
+ * is of identical size to the first packet. Calculating the location of
+ * the packet buffer is then just a simple calculation:
+ * <tt>buffer + (packet_size * packet)</tt>
+ *
+ * Do not use this function on transfers other than those that have identical
+ * packet lengths for each packet.
+ *
+ * \param transfer a transfer
+ * \param packet the packet to return the address of
+ * \returns the base address of the packet buffer inside the transfer buffer,
+ * or NULL if the packet does not exist.
+ * \see libusb_get_iso_packet_buffer()
+  }
+
+function libusb_get_iso_packet_buffer_simple(
+  	transfer:plibusb_transfer;
+    packet:cardinal):puint8_t;
+
+
+{ sync I/O  }
+
+function libusb_control_transfer(
+    dev_handle:plibusb_device_handle;
+		request_type:uint8_t;
+    bRequest:uint8_t;
+    wValue:uint16_t;
+    wIndex:uint16_t;
+		data:puint8_t;
+    wLength:uint16_t;
+    timeout:cardinal):integer;LIBUSB_CALL;external libusb1;
+
+function libusb_bulk_transfer(
+    dev_handle:plibusb_device_handle;
+		endpoint:uint8_t;
+    data:puint8_t;
+    length:integer;
+		var actual_length:integer;
+    timeout:cardinal):integer;LIBUSB_CALL;external libusb1;
+
+function libusb_interrupt_transfer(
+    dev_handle:plibusb_device_handle;
+		endpoint:uint8_t;
+    data:puint8_t;
+    length:integer;
+		var actual_length:integer;
+    timeout:cardinal):integer;LIBUSB_CALL;external libusb1;
+
+{* \ingroup desc
+ * Retrieve a descriptor from the default control pipe.
+ * This is a convenience function which formulates the appropriate control
+ * message to retrieve the descriptor.
+ *
+ * \param dev a device handle
+ * \param desc_type the descriptor type, see \ref libusb_descriptor_type
+ * \param desc_index the index of the descriptor to retrieve
+ * \param data output buffer for descriptor
+ * \param length size of data buffer
+ * \returns number of bytes returned in data, or LIBUSB_ERROR code on failure
+  }
+
+function libusb_get_descriptor(
+    dev:plibusb_device_handle;
+  	desc_type:uint8_t;
+    desc_index:uint8_t;
+    data:puint8_t;
+    length:integer):integer;
+
+
+{* \ingroup desc
+ * Retrieve a descriptor from a device.
+ * This is a convenience function which formulates the appropriate control
+ * message to retrieve the descriptor. The string returned is Unicode, as
+ * detailed in the USB specifications.
+ *
+ * \param dev a device handle
+ * \param desc_index the index of the descriptor to retrieve
+ * \param langid the language ID for the string descriptor
+ * \param data output buffer for descriptor
+ * \param length size of data buffer
+ * \returns number of bytes returned in data, or LIBUSB_ERROR code on failure
+ * \see libusb_get_string_descriptor_ascii()
+  }
+
+function libusb_get_string_descriptor(
+    dev:plibusb_device_handle;
+  	desc_index:uint8_t;
+    langid:uint16_t;
+    data:puint8_t;
+    length:integer):integer; { wrapper function }
+
+function libusb_get_string_descriptor_ascii(
+    dev:plibusb_device_handle;
+		desc_index:uint8_t;
+    data:puint8_t;
+    length:integer):integer;LIBUSB_CALL;external libusb1;
+
+(* polling and timeouts *)
+
+function libusb_try_lock_events(ctx:plibusb_context):integer;LIBUSB_CALL;external libusb1;
+procedure libusb_lock_events(ctx:plibusb_context);LIBUSB_CALL;external libusb1;
+procedure libusb_unlock_events(ctx:plibusb_context);LIBUSB_CALL;external libusb1;
+function libusb_event_handling_ok(ctx:plibusb_context):integer;LIBUSB_CALL;external libusb1;
+function libusb_event_handler_active(ctx:plibusb_context):integer;LIBUSB_CALL;external libusb1;
+procedure libusb_lock_event_waiters(ctx:plibusb_context);LIBUSB_CALL;external libusb1;
+procedure libusb_unlock_event_waiters(ctx:plibusb_context);LIBUSB_CALL;external libusb1;
+function libusb_wait_for_event(ctx:plibusb_context; tv:ptimeval):integer;LIBUSB_CALL;external libusb1;
+
+function libusb_handle_events_timeout(ctx:plibusb_context;
+	 tv:ptimeval):integer;LIBUSB_CALL;external libusb1;
+function libusb_handle_events_timeout_completed(ctx:plibusb_context;
+		tv:ptimeval;var completed:integer):integer;LIBUSB_CALL;external libusb1;
+function libusb_handle_events(ctx:plibusb_context):integer;LIBUSB_CALL;external libusb1;
+function libusb_handle_events_completed(ctx:plibusb_context; var completed:integer):integer;LIBUSB_CALL;external libusb1;
+function libusb_handle_events_locked(ctx:plibusb_context;
+		tv:ptimeval):integer;LIBUSB_CALL;external libusb1;
+function libusb_pollfds_handle_timeouts(ctx:plibusb_context):integer;LIBUSB_CALL;external libusb1;
+function libusb_get_next_timeout(ctx:plibusb_context;
+		tv:ptimeval):integer;LIBUSB_CALL;external libusb1;
+
+
+{* \ingroup poll
+ * File descriptor for polling
+  }
+{* Numeric file descriptor  }
+{* Event flags to poll for from <poll.h>. POLLIN indicates that you
+   * should monitor this file descriptor for becoming ready to read from,
+   * and POLLOUT indicates that you should monitor this file descriptor for
+   * nonblocking write readiness.  }
+
+type
+  plibusb_pollfd = ^libusb_pollfd;
+  libusb_pollfd = record
+      fd : longint;
+      events : smallint;
+    end;
+
+{* \ingroup poll
+ * Callback function, invoked when a new file descriptor should be added
+ * to the set of file descriptors monitored for events.
+ * \param fd the new file descriptor
+ * \param events events to monitor for, see \ref libusb_pollfd for a
+ * description
+ * \param user_data User data pointer specified in
+ * libusb_set_pollfd_notifiers() call
+ * \see libusb_set_pollfd_notifiers()
+  }
+
+type
+  libusb_pollfd_added_cb = procedure(
+      fd:integer;
+      events:smallint;
+  		user_data:pointer);LIBUSB_CALL;
+
+
+{* \ingroup poll
+ * Callback function, invoked when a file descriptor should be removed from
+ * the set of file descriptors being monitored for events. After returning
+ * from this callback, do not use that file descriptor again.
+ * \param fd the file descriptor to stop monitoring
+ * \param user_data User data pointer specified in
+ * libusb_set_pollfd_notifiers() call
+ * \see libusb_set_pollfd_notifiers()
+  }
+
+type
+  libusb_pollfd_removed_cb = procedure(
+      fd:integer;
+      user_data:pointer);LIBUSB_CALL;
+
+  libusb_get_pollfds = function(
+			ctx:plibusb_context):plibusb_pollfd;LIBUSB_CALL;
+
+  libusb_set_pollfd_notifiers = procedure (
+      ctx:plibusb_context;
+			added_cb:libusb_pollfd_added_cb;
+      removed_cb:libusb_pollfd_removed_cb;
+			user_data:pointer);LIBUSB_CALL;
+
+
+
+{* \ingroup hotplug
+ * Callback handle.
+ *
+ * Callbacks handles are generated by libusb_hotplug_register_callback()
+ * and can be used to deregister callbacks. Callback handles are unique
+ * per libusb_context and it is safe to call libusb_hotplug_deregister_callback()
+ * on an already deregisted callback.
+ *
+ * Since version 1.0.16, \ref LIBUSB_API_VERSION >= 0x01000102
+ *
+ * For more information, see \ref hotplug.
+  }
+
+  libusb_hotplug_callback_handle = longint;
+{* \ingroup hotplug
+ *
+ * Since version 1.0.16, \ref LIBUSB_API_VERSION >= 0x01000102
+ *
+ * Flags for hotplug events  }
+{* Default value when not using any flags.  }
+{* Arm the callback and fire it for all matching currently attached devices.  }
+
+  libusb_hotplug_flag = (LIBUSB_HOTPLUG_NO_FLAGS = 0, LIBUSB_HOTPLUG_ENUMERATE = 1
+    );
+{* \ingroup hotplug
+ *
+ * Since version 1.0.16, \ref LIBUSB_API_VERSION >= 0x01000102
+ *
+ * Hotplug events  }
+{* A device has been plugged in and is ready to use  }
+{* A device has left and is no longer available.
+   * It is the user's responsibility to call libusb_close on any handle associated with a disconnected device.
+   * It is safe to call libusb_get_device_descriptor on a device that has left  }
+
+  libusb_hotplug_event = (LIBUSB_HOTPLUG_EVENT_DEVICE_ARRIVED = $01,
+    LIBUSB_HOTPLUG_EVENT_DEVICE_LEFT = $02
+    );
+{* \ingroup hotplug
+ * Wildcard matching for hotplug events  }
+
+const
+  LIBUSB_HOTPLUG_MATCH_ANY = -(1);
+
+{* \ingroup hotplug
+ * Hotplug callback function type. When requesting hotplug event notifications,
+ * you pass a pointer to a callback function of this type.
+ *
+ * This callback may be called by an internal event thread and as such it is
+ * recommended the callback do minimal processing before returning.
+ *
+ * libusb will call this function later, when a matching event had happened on
+ * a matching device. See \ref hotplug for more information.
+ *
+ * It is safe to call either libusb_hotplug_register_callback() or
+ * libusb_hotplug_deregister_callback() from within a callback function.
+ *
+ * Since version 1.0.16, \ref LIBUSB_API_VERSION >= 0x01000102
+ *
+ * \param ctx            context of this notification
+ * \param device         libusb_device this event occurred on
+ * \param event          event that occurred
+ * \param user_data      user data provided when this callback was registered
+ * \returns bool whether this callback is finished processing events.
+ *                       returning 1 will cause this callback to be deregistered
+  }
+
+type
+  libusb_hotplug_callback_fn = function(
+      	ctx:plibusb_context;
+				device:plibusb_device;
+				event:libusb_hotplug_event;
+				user_data:pointer):integer;LIBUSB_CALL;
+
+{* \ingroup hotplug
+ * Register a hotplug callback function
+ *
+ * Register a callback with the libusb_context. The callback will fire
+ * when a matching event occurs on a matching device. The callback is
+ * armed until either it is deregistered with libusb_hotplug_deregister_callback()
+ * or the supplied callback returns 1 to indicate it is finished processing events.
+ *
+ * If the \ref LIBUSB_HOTPLUG_ENUMERATE is passed the callback will be
+ * called with a \ref LIBUSB_HOTPLUG_EVENT_DEVICE_ARRIVED for all devices
+ * already plugged into the machine. Note that libusb modifies its internal
+ * device list from a separate thread, while calling hotplug callbacks from
+ * libusb_handle_events(), so it is possible for a device to already be present
+ * on, or removed from, its internal device list, while the hotplug callbacks
+ * still need to be dispatched. This means that when using \ref
+ * LIBUSB_HOTPLUG_ENUMERATE, your callback may be called twice for the arrival
+ * of the same device, once from libusb_hotplug_register_callback() and once
+ * from libusb_handle_events(); and/or your callback may be called for the
+ * removal of a device for which an arrived call was never made.
+ *
+ * Since version 1.0.16, \ref LIBUSB_API_VERSION >= 0x01000102
+ *
+ * \param[in] ctx context to register this callback with
+ * \param[in] events bitwise or of events that will trigger this callback. See \ref
+ *            libusb_hotplug_event
+ * \param[in] flags hotplug callback flags. See \ref libusb_hotplug_flag
+ * \param[in] vendor_id the vendor id to match or \ref LIBUSB_HOTPLUG_MATCH_ANY
+ * \param[in] product_id the product id to match or \ref LIBUSB_HOTPLUG_MATCH_ANY
+ * \param[in] dev_class the device class to match or \ref LIBUSB_HOTPLUG_MATCH_ANY
+ * \param[in] cb_fn the function to be invoked on a matching event/device
+ * \param[in] user_data user data to pass to the callback function
+ * \param[out] handle pointer to store the handle of the allocated callback (can be NULL)
+ * \returns LIBUSB_SUCCESS on success LIBUSB_ERROR code on failure
+  }
+
+	function libusb_hotplug_register_callback(
+        ctx:plibusb_context;
+  			events:libusb_hotplug_event;
+  			flags:libusb_hotplug_flag;
+  			vendor_id:integer;
+        product_id:integer;
+  			dev_class:integer;
+  			cb_fn:libusb_hotplug_callback_fn;
+  			user_data:pointer;
+  			var handle:libusb_hotplug_callback_handle):integer;LIBUSB_CALL;external libusb1;
+
+
+{* \ingroup hotplug
+ * Deregisters a hotplug callback.
+ *
+ * Deregister a callback from a libusb_context. This function is safe to call from within
+ * a hotplug callback.
+ *
+ * Since version 1.0.16, \ref LIBUSB_API_VERSION >= 0x01000102
+ *
+ * \param[in] ctx context this callback is registered with
+ * \param[in] handle the handle of the callback to deregister
+  }
+  procedure libusb_hotplug_deregister_callback(
+        ctx:plibusb_context;
+  			handle:libusb_hotplug_callback_handle);LIBUSB_CALL;external libusb1;
+
+
+{$endif}
+
+
+implementation
+
+
+
+function libusb_cpu_to_le16(const x:uint16_t):uint16_t;inline;
+type
+  w_union=record
+  case byte of
+  0:(b8:array[0..1] of uint8_t);
+  1:(b16:uint16_t);
+  end;
+var
+  _tmp:w_union;
+begin
+  _tmp.b8[1] := uint8_t (x shl 8);
+  _tmp.b8[0] := uint8_t (x and $ff);
+  Result:=_tmp.b16;
+end;
+
+function libusb_le16_to_cpu(const x:uint16_t):uint16_t;inline;
+begin
+  Result:=libusb_cpu_to_le16(x);
+end;
+
+function  libusb_control_transfer_get_data(
+	transfer:plibusb_transfer):puint8_t;inline;
+begin
+	result := pointer(transfer^.buffer) + LIBUSB_CONTROL_SETUP_SIZE;
+end;
+
+function libusb_control_transfer_get_setup(
+  transfer:plibusb_transfer):plibusb_control_setup;inline;
+begin
+  Result:= plibusb_control_setup(transfer^.buffer);
+end;
+
+
+procedure libusb_fill_control_setup(
+  buffer:puint8_t;
+  bmRequestType:uint8_t;
+  bRequest: uint8_t;
+  wValue:uint16_t;
+  wIndex:uint16_t;
+  wLength:uint16_t);inline;
+var setup:plibusb_control_setup;
+begin
+  setup := plibusb_control_setup(buffer);
+  setup^.bmRequestType := bmRequestType;
+  setup^.bRequest := bRequest;
+  setup^.wValue := libusb_cpu_to_le16(wValue);
+  setup^.wIndex := libusb_cpu_to_le16(wIndex);
+  setup^.wLength := libusb_cpu_to_le16(wLength);
+end;
+
+procedure libusb_fill_control_transfer(
+  transfer:plibusb_transfer;
+  dev_handle:plibusb_device_handle;
+  buffer:puint8_t;
+  callback:libusb_transfer_cb_fn;
+  user_data:pointer;
+  timeout:cardinal);inline;
+var
+  setup:plibusb_control_setup;
+begin
+  setup := plibusb_control_setup(buffer);
+  transfer^.dev_handle := dev_handle;
+  transfer^.endpoint := 0;
+  transfer^._type := byte(LIBUSB_TRANSFER_TYPE_CONTROL);
+  transfer^.timeout := timeout;
+  transfer^.buffer := buffer;
+  if (setup<>nil) then
+  	transfer^.length := (LIBUSB_CONTROL_SETUP_SIZE
+  		+ libusb_le16_to_cpu(setup^.wLength));
+  transfer^.user_data := user_data;
+  transfer^.callback := callback;
+end;
+
+procedure libusb_fill_bulk_transfer(
+  transfer:plibusb_transfer;
+  dev_handle:plibusb_device_handle;
+  endpoint:uint8_t;
+  buffer:puint8_t;
+  length:integer;
+  callback:libusb_transfer_cb_fn;
+  user_data:pointer;
+  timeout:cardinal);inline;
+begin
+  transfer^.dev_handle := dev_handle;
+  transfer^.endpoint := endpoint;
+  transfer^._type := byte(LIBUSB_TRANSFER_TYPE_BULK);
+  transfer^.timeout := timeout;
+  transfer^.buffer := buffer;
+  transfer^.length := length;
+  transfer^.user_data := user_data;
+  transfer^.callback := callback;
+end;
+
+procedure libusb_fill_bulk_stream_transfer(
+  transfer:plibusb_transfer;
+  dev_handle:plibusb_device_handle;
+  endpoint:uint8_t;
+  stream_id:uint32_t;
+  buffer:puint8_t;
+  length:integer;
+  callback:libusb_transfer_cb_fn;
+  user_data:pointer;
+  timeout:cardinal);inline;
+begin
+  libusb_fill_bulk_transfer(transfer, dev_handle, endpoint, buffer,
+  				length, callback, user_data, timeout);
+  transfer^._type := byte(LIBUSB_TRANSFER_TYPE_BULK_STREAM);
+  libusb_transfer_set_stream_id(transfer, stream_id);
+end;
+
+procedure libusb_fill_interrupt_transfer(
+  transfer:plibusb_transfer;
+  dev_handle:plibusb_device_handle;
+  endpoint:uint8_t;
+  buffer:puint8_t;
+  length:integer;
+  callback:libusb_transfer_cb_fn;
+  user_data:pointer;
+  timeout:cardinal);inline;
+begin
+  transfer^.dev_handle := dev_handle;
+  transfer^.endpoint := endpoint;
+  transfer^._type := byte(LIBUSB_TRANSFER_TYPE_INTERRUPT);
+  transfer^.timeout := timeout;
+  transfer^.buffer := buffer;
+  transfer^.length := length;
+  transfer^.user_data := user_data;
+  transfer^.callback := callback;
+end;
+
+procedure libusb_fill_iso_transfer(transfer:plibusb_transfer;
+  dev_handle:plibusb_device_handle;
+  endpoint:uint8_t;
+  buffer:puint8_t;
+  length:integer;
+  num_iso_packets:integer;
+  callback:libusb_transfer_cb_fn;
+  user_data:pointer;
+  timeout:cardinal);inline;
+begin
+  transfer^.dev_handle := dev_handle;
+  transfer^.endpoint := endpoint;
+  transfer^._type := byte(LIBUSB_TRANSFER_TYPE_ISOCHRONOUS);
+  transfer^.timeout := timeout;
+  transfer^.buffer := buffer;
+  transfer^.length := length;
+  transfer^.num_iso_packets := num_iso_packets;
+  transfer^.user_data := user_data;
+  transfer^.callback := callback;
+end;
+
+procedure libusb_set_iso_packet_lengths(
+  transfer:plibusb_transfer;
+  length:cardinal);inline;
+var
+  i:integer;
+begin
+  for i := 0 to transfer^.num_iso_packets-1 do
+  	transfer^.iso_packet_desc[i].length := length;
+end;
+
+function libusb_get_iso_packet_buffer(
+  	transfer:plibusb_transfer;
+    packet:cardinal):puint8_t;inline;
+var
+  i:integer;
+  offset:size_t;
+  _packet:integer;
+begin
+  (* oops..slight bug in the API. packet is an unsigned int, but we use
+   * signed integers almost everywhere else. range-check and convert to
+   * signed to avoid compiler warnings. FIXME for libusb-2. *)
+  if (packet > MaxInt) then
+  begin
+    Result:=nil;
+  	exit;;
+  end;
+
+  _packet := integer(packet);
+
+  if (_packet >= transfer^.num_iso_packets) then
+  begin
+    Result:=nil;
+  	exit;;
+  end;
+
+  for i := 0 to _packet-1 do
+  	offset := offset + transfer^.iso_packet_desc[i].length;
+
+  Result := pointer(transfer^.buffer) + offset;
+end;
+
+
+function libusb_get_iso_packet_buffer_simple(
+  	transfer:plibusb_transfer;
+    packet:cardinal):puint8_t;inline;
+var
+  _packet:integer;
+begin
+  (* oops..slight bug in the API. packet is an unsigned int, but we use
+   * signed integers almost everywhere else. range-check and convert to
+   * signed to avoid compiler warnings. FIXME for libusb-2. *)
+  if (packet > MaxInt) then
+  begin
+    Result:=nil;
+  	exit;;
+  end;
+
+  _packet := integer(packet);
+
+  if (_packet >= transfer^.num_iso_packets) then
+  begin
+    Result:=nil;
+  	exit;;
+  end;
+
+  Result := pointer(transfer^.buffer) + integer(transfer^.iso_packet_desc[0].length * _packet);
+end;
+
+
+function libusb_get_descriptor(
+    dev:plibusb_device_handle;
+  	desc_type:uint8_t;
+    desc_index:uint8_t;
+    data:puint8_t;
+    length:integer):integer;
+begin
+  Result := libusb_control_transfer(dev, byte(LIBUSB_ENDPOINT_IN),
+  	byte(LIBUSB_REQUEST_GET_DESCRIPTOR), uint16_t( (desc_type shl 8) or desc_index),
+  	0, data, uint16_t(length), 1000);
+end;
+
+
+function libusb_get_string_descriptor(
+    dev:plibusb_device_handle;
+  	desc_index:uint8_t;
+    langid:uint16_t;
+    data:puint8_t;
+    length:integer):integer;
+begin
+  result:= libusb_control_transfer(dev, byte(LIBUSB_ENDPOINT_IN),
+  	byte(LIBUSB_REQUEST_GET_DESCRIPTOR), uint16_t((byte(LIBUSB_DT_STRING) shl 8) or desc_index),
+  	langid, data, uint16_t (length), 1000);
+end;
+
+
+end.