michael 24 лет назад
Родитель
Сommit
323b0581a1
5 измененных файлов с 1837 добавлено и 0 удалено
  1. 1306 0
      packages/libgd/Makefile
  2. 10 0
      packages/libgd/Makefile.fpc
  3. 30 0
      packages/libgd/README
  4. 409 0
      packages/libgd/gd.pp
  5. 82 0
      packages/libgd/gdtest.pp

+ 1306 - 0
packages/libgd/Makefile

@@ -0,0 +1,1306 @@
+#
+# Makefile generated by fpcmake v1.00 [2001/03/07]
+#
+
+defaultrule: all
+
+#####################################################################
+# Autodetect OS (Linux or Dos or Windows NT or OS/2)
+# define inUnix when running under Unix (Linux,FreeBSD)
+# define inWinNT when running under WinNT
+# define inOS2 when running under OS/2
+#####################################################################
+
+# We need only / in the path
+override PATH:=$(subst \,/,$(PATH))
+
+# Search for PWD and determine also if we are under linux
+PWD:=$(strip $(wildcard $(addsuffix /pwd.exe,$(subst ;, ,$(PATH)))))
+ifeq ($(PWD),)
+PWD:=$(strip $(wildcard $(addsuffix /pwd,$(subst :, ,$(PATH)))))
+ifeq ($(PWD),)
+nopwd:
+	@echo You need the GNU utils package to use this Makefile!
+	@echo Get ftp://ftp.freepascal.org/pub/fpc/dist/go32v2/utilgo32.zip
+	@exit
+else
+inUnix=1
+PWD:=$(firstword $(PWD))
+endif
+else
+PWD:=$(firstword $(PWD))
+endif
+
+# Detect NT - NT sets OS to Windows_NT
+# Detect OS/2 - OS/2 has OS2_SHELL defined
+ifndef inUnix
+ifeq ($(OS),Windows_NT)
+inWinNT=1
+else
+ifdef OS2_SHELL
+inOS2=1
+endif
+endif
+endif
+
+# The extension of executables
+ifdef inUnix
+SRCEXEEXT=
+else
+SRCEXEEXT=.exe
+endif
+
+# The extension of batch files / scripts
+ifdef inUnix
+BATCHEXT=.sh
+else
+ifdef inOS2
+BATCHEXT=.cmd
+else
+BATCHEXT=.bat
+endif
+endif
+
+# Path Separator, the subst trick is necessary for the \ that can't exists
+# at the end of a line
+ifdef inUnix
+PATHSEP=/
+else
+PATHSEP=$(subst /,\,/)
+endif
+
+# The path which is searched separated by spaces
+ifdef inUnix
+SEARCHPATH=$(subst :, ,$(PATH))
+else
+SEARCHPATH=$(subst ;, ,$(PATH))
+endif
+
+# Base dir
+ifdef PWD
+BASEDIR:=$(shell $(PWD))
+else
+BASEDIR=.
+endif
+
+#####################################################################
+# FPC version/target Detection
+#####################################################################
+
+# What compiler to use ?
+ifndef FPC
+# Compatibility with old makefiles
+ifdef PP
+FPC=$(PP)
+else
+FPC=ppc386
+endif
+endif
+override FPC:=$(subst $(SRCEXEEXT),,$(FPC))
+override FPC:=$(subst \,/,$(FPC))$(SRCEXEEXT)
+
+# Target OS
+ifndef OS_TARGET
+OS_TARGET:=$(shell $(FPC) -iTO)
+endif
+
+# Source OS
+ifndef OS_SOURCE
+OS_SOURCE:=$(shell $(FPC) -iSO)
+endif
+
+# Target CPU
+ifndef CPU_TARGET
+CPU_TARGET:=$(shell $(FPC) -iTP)
+endif
+
+# Source CPU
+ifndef CPU_SOURCE
+CPU_SOURCE:=$(shell $(FPC) -iSP)
+endif
+
+# FPC version
+ifndef FPC_VERSION
+FPC_VERSION:=$(shell $(FPC) -iV)
+endif
+
+export FPC OS_TARGET OS_SOURCE CPU_TARGET CPU_SOURCE FPC_VERSION
+
+#####################################################################
+# FPCDIR Setting
+#####################################################################
+
+# Test FPCDIR to look if the RTL dir exists
+ifdef FPCDIR
+override FPCDIR:=$(subst \,/,$(FPCDIR))
+ifeq ($(wildcard $(FPCDIR)/rtl),)
+ifeq ($(wildcard $(FPCDIR)/units),)
+override FPCDIR=wrong
+endif
+endif
+else
+override FPCDIR=wrong
+endif
+
+# Default FPCDIR
+ifeq ($(FPCDIR),wrong)
+override FPCDIR=../..
+ifeq ($(wildcard $(FPCDIR)/rtl),)
+ifeq ($(wildcard $(FPCDIR)/units),)
+override FPCDIR=wrong
+endif
+endif
+endif
+
+# Detect FPCDIR
+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 $(FPCDIR)/rtl),)
+ifeq ($(wildcard $(FPCDIR)/units),)
+override FPCDIR:=$(FPCDIR)/..
+ifeq ($(wildcard $(FPCDIR)/rtl),)
+ifeq ($(wildcard $(FPCDIR)/units),)
+override FPCDIR=c:/pp
+endif
+endif
+endif
+endif
+endif
+endif
+
+ifndef PACKAGESDIR
+PACKAGESDIR=$(FPCDIR)/packages
+endif
+ifndef TOOLKITSDIR
+TOOLKITSDIR=
+endif
+ifndef COMPONENTSDIR
+COMPONENTSDIR=
+endif
+
+# Create units dir
+ifneq ($(FPCDIR),.)
+UNITSDIR=$(FPCDIR)/units/$(OS_TARGET)
+endif
+
+#####################################################################
+# User Settings
+#####################################################################
+
+
+# Targets
+
+override UNITOBJECTS+=gd
+override EXAMPLEOBJECTS+=gdtest
+
+# Clean
+
+
+# Install
+
+ZIPTARGET=install
+
+# Defaults
+
+
+# Directories
+
+
+# Packages
+
+override PACKAGES+=rtl
+
+# Libraries
+
+
+# Info
+
+INFOTARGET=fpc_infocfg fpc_infoobjects fpc_infoinstall 
+
+#####################################################################
+# Shell tools
+#####################################################################
+
+# echo
+ifndef ECHO
+ECHO:=$(strip $(wildcard $(addsuffix /gecho$(EXEEXT),$(SEARCHPATH))))
+ifeq ($(ECHO),)
+ECHO:=$(strip $(wildcard $(addsuffix /echo$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(ECHO),)
+ECHO:=echo
+ECHOE:=echo
+else
+ECHO:=$(firstword $(ECHO))
+ECHOE=$(ECHO) -E
+endif
+else
+ECHO:=$(firstword $(ECHO))
+ECHOE=$(ECHO) -E
+endif
+endif
+
+# To copy pograms
+ifndef COPY
+COPY:=cp -fp
+endif
+
+# Copy a whole tree
+ifndef COPYTREE
+COPYTREE:=cp -rfp
+endif
+
+# To move pograms
+ifndef MOVE
+MOVE:=mv -f
+endif
+
+# Check delete program
+ifndef DEL
+DEL:=rm -f
+endif
+
+# Check deltree program
+ifndef DELTREE
+DELTREE:=rm -rf
+endif
+
+# To install files
+ifndef INSTALL
+ifdef inUnix
+INSTALL:=install -c -m 644
+else
+INSTALL:=$(COPY)
+endif
+endif
+
+# To install programs
+ifndef INSTALLEXE
+ifdef inUnix
+INSTALLEXE:=install -c -m 755
+else
+INSTALLEXE:=$(COPY)
+endif
+endif
+
+# To make a directory.
+ifndef MKDIR
+ifdef inUnix
+MKDIR:=install -m 755 -d
+else
+MKDIR:=ginstall -m 755 -d
+endif
+endif
+
+export ECHO ECHOE COPY COPYTREE MOVE DEL DELTREE INSTALL INSTALLEXE MKDIR
+
+#####################################################################
+# Default Tools
+#####################################################################
+
+# assembler, redefine it if cross compiling
+ifndef AS
+AS=as
+endif
+
+# linker, but probably not used
+ifndef LD
+LD=ld
+endif
+
+# Resource compiler
+ifndef RC
+RC=rc
+endif
+
+# ppas.bat / ppas.sh
+PPAS=ppas$(BATCHEXT)
+
+# ldconfig to rebuild .so cache
+ifdef inUnix
+LDCONFIG=ldconfig
+else
+LDCONFIG=
+endif
+
+# ppumove
+ifndef PPUMOVE
+PPUMOVE:=$(strip $(wildcard $(addsuffix /ppumove$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(PPUMOVE),)
+PPUMOVE=
+else
+PPUMOVE:=$(firstword $(PPUMOVE))
+endif
+endif
+export PPUMOVE
+
+# ppufiles
+ifndef PPUFILES
+PPUFILES:=$(strip $(wildcard $(addsuffix /ppufiles$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(PPUFILES),)
+PPUFILES=
+else
+PPUFILES:=$(firstword $(PPUFILES))
+endif
+endif
+export PPUFILES
+
+# Look if UPX is found for go32v2 and win32. We can't use $UPX becuase
+# upx uses that one itself (PFV)
+ifndef UPXPROG
+ifeq ($(OS_TARGET),go32v2)
+UPXPROG:=1
+endif
+ifeq ($(OS_TARGET),win32)
+UPXPROG:=1
+endif
+ifdef UPXPROG
+UPXPROG:=$(strip $(wildcard $(addsuffix /upx$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(UPXPROG),)
+UPXPROG=
+else
+UPXPROG:=$(firstword $(UPXPROG))
+endif
+else
+UPXPROG=
+endif
+endif
+export UPXPROG
+
+# ZipProg, you can't use Zip as the var name (PFV)
+ifndef ZIPPROG
+ZIPPROG:=$(strip $(wildcard $(addsuffix /zip$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(ZIPPROG),)
+ZIPPROG=
+else
+ZIPPROG:=$(firstword $(ZIPPROG))
+endif
+endif
+export ZIPPROG
+
+ZIPOPT=-9
+ZIPEXT=.zip
+
+# Tar
+ifndef TARPROG
+TARPROG:=$(strip $(wildcard $(addsuffix /tar$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(TARPROG),)
+TARPROG=
+else
+TARPROG:=$(firstword $(TARPROG))
+endif
+endif
+export TARPROG
+
+ifeq ($(USETAR),bz2)
+TAROPT=vI
+TAREXT=.tar.bz2
+else
+TAROPT=vz
+TAREXT=.tar.gz
+endif
+
+#####################################################################
+# Default extensions
+#####################################################################
+
+# Default needed extensions (Go32v2,Linux)
+LOADEREXT=.as
+EXEEXT=.exe
+PPLEXT=.ppl
+PPUEXT=.ppu
+OEXT=.o
+ASMEXT=.s
+SMARTEXT=.sl
+STATICLIBEXT=.a
+SHAREDLIBEXT=.so
+RSTEXT=.rst
+FPCMADE=fpcmade
+
+# Go32v1
+ifeq ($(OS_TARGET),go32v1)
+PPUEXT=.pp1
+OEXT=.o1
+ASMEXT=.s1
+SMARTEXT=.sl1
+STATICLIBEXT=.a1
+SHAREDLIBEXT=.so1
+FPCMADE=fpcmade.v1
+endif
+
+# Go32v2
+ifeq ($(OS_TARGET),go32v2)
+FPCMADE=fpcmade.dos
+endif
+
+# Linux
+ifeq ($(OS_TARGET),linux)
+EXEEXT=
+HASSHAREDLIB=1
+FPCMADE=fpcmade.lnx
+endif
+
+# Linux
+ifeq ($(OS_TARGET),freebsd)
+EXEEXT=
+HASSHAREDLIB=1
+FPCMADE=fpcmade.freebsd
+endif
+
+# Win32
+ifeq ($(OS_TARGET),win32)
+PPUEXT=.ppw
+OEXT=.ow
+ASMEXT=.sw
+SMARTEXT=.slw
+STATICLIBEXT=.aw
+SHAREDLIBEXT=.dll
+FPCMADE=fpcmade.w32
+endif
+
+# OS/2
+ifeq ($(OS_TARGET),os2)
+PPUEXT=.ppo
+ASMEXT=.so2
+OEXT=.oo2
+SMARTEXT=.so
+STATICLIBEXT=.ao2
+SHAREDLIBEXT=.dll
+FPCMADE=fpcmade.os2
+endif
+
+# library prefix
+LIBPREFIX=lib
+ifeq ($(OS_TARGET),go32v2)
+LIBPREFIX=
+endif
+ifeq ($(OS_TARGET),go32v1)
+LIBPREFIX=
+endif
+
+# determine which .pas extension is used
+ifndef PASEXT
+ifdef EXEOBJECTS
+override TESTPAS:=$(strip $(wildcard $(addsuffix .pas,$(firstword $(EXEOBJECTS)))))
+else
+override TESTPAS:=$(strip $(wildcard $(addsuffix .pas,$(firstword $(UNITOBJECTS)))))
+endif
+ifeq ($(TESTPAS),)
+PASEXT=.pp
+else
+PASEXT=.pas
+endif
+endif
+
+
+# Check if the dirs really exists, else turn it off
+ifeq ($(wildcard $(UNITSDIR)),)
+UNITSDIR=
+endif
+ifeq ($(wildcard $(TOOLKITSDIR)),)
+TOOLKITSDIR=
+endif
+ifeq ($(wildcard $(PACKAGESDIR)),)
+PACKAGESDIR=
+endif
+ifeq ($(wildcard $(COMPONENTSDIR)),)
+COMPONENTSDIR=
+endif
+
+
+# PACKAGESDIR packages
+
+PACKAGERTL=1
+
+ifdef PACKAGERTL
+ifneq ($(wildcard $(FPCDIR)/rtl),)
+ifneq ($(wildcard $(FPCDIR)/rtl/$(OS_TARGET)),)
+PACKAGEDIR_RTL=$(FPCDIR)/rtl/$(OS_TARGET)
+else
+PACKAGEDIR_RTL=$(FPCDIR)/rtl
+endif
+ifeq ($(wildcard $(PACKAGEDIR_RTL)/$(FPCMADE)),)
+override COMPILEPACKAGES+=package_rtl
+package_rtl:
+	$(MAKE) -C $(PACKAGEDIR_RTL) all
+endif
+UNITDIR_RTL=$(PACKAGEDIR_RTL)
+else
+PACKAGEDIR_RTL=
+ifneq ($(wildcard $(UNITSDIR)/rtl),)
+ifneq ($(wildcard $(UNITSDIR)/rtl/$(OS_TARGET)),)
+UNITDIR_RTL=$(UNITSDIR)/rtl/$(OS_TARGET)
+else
+UNITDIR_RTL=$(UNITSDIR)/rtl
+endif
+else
+UNITDIR_RTL=
+endif
+endif
+ifdef UNITDIR_RTL
+override NEEDUNITDIR+=$(UNITDIR_RTL)
+endif
+endif
+
+
+#####################################################################
+# Default Directories
+#####################################################################
+
+# Linux and freebsd use unix dirs with /usr/bin, /usr/lib
+# When zipping use the target as default, when normal install then
+# use the source os as default
+ifdef ZIPNAME
+# Zipinstall
+ifeq ($(OS_TARGET),linux)
+UNIXINSTALLDIR=1
+endif
+ifeq ($(OS_TARGET),freebsd)
+UNIXINSTALLDIR=1
+endif
+else
+# Normal install
+ifeq ($(OS_SOURCE),linux)
+UNIXINSTALLDIR=1
+endif
+ifeq ($(OS_SOURCE),freebsd)
+UNIXINSTALLDIR=1
+endif
+endif
+
+# set the prefix directory where to install everything
+ifndef PREFIXINSTALLDIR
+ifdef UNIXINSTALLDIR
+PREFIXINSTALLDIR=/usr
+else
+PREFIXINSTALLDIR=/pp
+endif
+endif
+export PREFIXINSTALLDIR
+
+# Where to place the resulting zip files
+ifndef DESTZIPDIR
+DESTZIPDIR:=$(BASEDIR)
+endif
+export DESTZIPDIR
+
+#####################################################################
+# Install Directories
+#####################################################################
+
+# set the base directory where to install everything
+ifndef BASEINSTALLDIR
+ifdef UNIXINSTALLDIR
+BASEINSTALLDIR=$(PREFIXINSTALLDIR)/lib/fpc/$(FPC_VERSION)
+else
+BASEINSTALLDIR=$(PREFIXINSTALLDIR)
+endif
+endif
+
+# set the directory where to install the binaries
+ifndef BININSTALLDIR
+ifdef UNIXINSTALLDIR
+BININSTALLDIR=$(PREFIXINSTALLDIR)/bin
+else
+BININSTALLDIR=$(BASEINSTALLDIR)/bin/$(OS_TARGET)
+endif
+endif
+
+# set the directory where to install the units.
+ifndef UNITINSTALLDIR
+UNITINSTALLDIR=$(BASEINSTALLDIR)/units/$(OS_TARGET)
+ifdef UNITSUBDIR
+UNITINSTALLDIR:=$(UNITINSTALLDIR)/$(UNITSUBDIR)
+endif
+endif
+
+# Where to install shared libraries
+ifndef LIBINSTALLDIR
+ifdef UNIXINSTALLDIR
+LIBINSTALLDIR=$(PREFIXINSTALLDIR)/lib
+else
+LIBINSTALLDIR=$(UNITINSTALLDIR)
+endif
+endif
+
+# Where the source files will be stored
+ifndef SOURCEINSTALLDIR
+ifdef UNIXINSTALLDIR
+SOURCEINSTALLDIR=$(PREFIXINSTALLDIR)/src/fpc-$(FPC_VERSION)
+else
+SOURCEINSTALLDIR=$(BASEINSTALLDIR)/source
+endif
+ifdef SOURCESUBDIR
+SOURCEINSTALLDIR:=$(SOURCEINSTALLDIR)/$(SOURCESUBDIR)
+endif
+endif
+
+# Where the doc files will be stored
+ifndef DOCINSTALLDIR
+ifdef UNIXINSTALLDIR
+DOCINSTALLDIR=$(PREFIXINSTALLDIR)/doc/fpc-$(FPC_VERSION)
+else
+DOCINSTALLDIR=$(BASEINSTALLDIR)/doc
+endif
+endif
+
+# Where to install the examples, under linux we use the doc dir
+# because the copytree command will create a subdir itself
+ifndef EXAMPLEINSTALLDIR
+ifdef UNIXINSTALLDIR
+EXAMPLEINSTALLDIR=$(DOCINSTALLDIR)/examples
+else
+EXAMPLEINSTALLDIR=$(BASEINSTALLDIR)/examples
+endif
+ifdef EXAMPLESUBDIR
+EXAMPLEINSTALLDIR:=$(EXAMPLEINSTALLDIR)/$(EXAMPLESUBDIR)
+endif
+endif
+
+# Where the some extra (data)files will be stored
+ifndef DATAINSTALLDIR
+DATAINSTALLDIR=$(BASEINSTALLDIR)
+endif
+
+#####################################################################
+# Redirection
+#####################################################################
+
+ifndef REDIRFILE
+REDIRFILE=log
+endif
+
+ifdef REDIR
+ifndef inUnix
+override FPC=redir -eo $(FPC)
+endif
+# set the verbosity to max
+override FPCOPT+=-va
+override REDIR:= >> $(REDIRFILE)
+endif
+
+
+#####################################################################
+# Compiler Command Line
+#####################################################################
+
+# Load commandline OPTDEF and add FPC_CPU define
+override FPCOPTDEF:=-d$(CPU_TARGET)
+
+# Load commandline OPT and add target and unit dir to be sure
+ifneq ($(OS_TARGET),$(OS_SOURCE))
+override FPCOPT+=-T$(OS_TARGET)
+endif
+
+# User dirs should be first, so they are looked at first
+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
+
+# Smartlinking
+ifdef LINKSMART
+override FPCOPT+=-XX
+endif
+
+# Smartlinking creation
+ifdef CREATESMART
+override FPCOPT+=-CX
+endif
+
+# Debug
+ifdef DEBUG
+override FPCOPT+=-gl -dDEBUG
+endif
+
+# Release mode (strip, optimize and don't load ppc386.cfg)
+# 0.99.12b has a bug in the optimizer so don't use it by default
+ifdef RELEASE
+ifeq ($(FPC_VERSION),0.99.12)
+override FPCOPT+=-Xs -OGp3 -n
+else
+override FPCOPT+=-Xs -OG2p3 -n
+endif
+endif
+
+# Strip
+ifdef STRIP
+override FPCOPT+=-Xs
+endif
+
+# Optimizer
+ifdef OPTIMIZE
+override FPCOPT+=-OG2p3
+endif
+
+# Verbose settings (warning,note,info)
+ifdef VERBOSE
+override FPCOPT+=-vwni
+endif
+
+ifdef NEEDUNITDIR
+override FPCOPT+=$(addprefix -Fu,$(NEEDUNITDIR))
+endif
+
+ifdef UNITSDIR
+override FPCOPT+=-Fu$(UNITSDIR)
+endif
+
+# Target dirs and the prefix to use for clean/install
+ifdef TARGETDIR
+override FPCOPT+=-FE$(TARGETDIR)
+ifeq ($(TARGETDIR),.)
+override TARGETDIRPREFIX=
+else
+override TARGETDIRPREFIX=$(TARGETDIR)/
+endif
+endif
+ifdef UNITTARGETDIR
+override FPCOPT+=-FU$(UNITTARGETDIR)
+ifeq ($(UNITTARGETDIR),.)
+override UNITTARGETDIRPREFIX=
+else
+override UNITTARGETDIRPREFIX=$(TARGETDIR)/
+endif
+else
+ifdef TARGETDIR
+override UNITTARGETDIR=$(TARGETDIR)
+override UNITTARGETDIRPREFIX=$(TARGETDIRPREFIX)
+endif
+endif
+
+# Add commandline options last so they can override
+ifdef OPT
+override FPCOPT+=$(OPT)
+endif
+
+# Add defines from FPCOPTDEF to FPCOPT
+ifdef FPCOPTDEF
+override FPCOPT+=$(FPCOPTDEF)
+endif
+
+# Error file ?
+ifdef ERRORFILE
+override FPCOPT+=-Fr$(ERRORFILE)
+endif
+
+# Was a config file specified ?
+ifdef CFGFILE
+override FPCOPT+=@$(CFGFILE)
+endif
+
+# For win32 the options are passed using the environment FPCEXTCMD
+ifeq ($(OS_SOURCE),win32)
+override FPCEXTCMD:=$(FPCOPT)
+override FPCOPT:=!FPCEXTCMD
+export FPCEXTCMD
+endif
+
+# Compiler commandline
+override COMPILER:=$(FPC) $(FPCOPT)
+
+# also call ppas if with command option -s
+# but only if the OS_SOURCE and OS_TARGE are equal
+ifeq (,$(findstring -s ,$(COMPILER)))
+EXECPPAS=
+else
+ifeq ($(OS_SOURCE),$(OS_TARGET))
+EXECPPAS:=@$(PPAS)
+endif
+endif
+
+#####################################################################
+# Standard rules
+#####################################################################
+
+all: fpc_all
+
+debug: fpc_debug
+
+examples: fpc_examples
+
+test: fpc_test
+
+smart: fpc_smart
+
+shared: fpc_shared
+
+showinstall: fpc_showinstall
+
+install: fpc_install
+
+sourceinstall: fpc_sourceinstall
+
+exampleinstall: fpc_exampleinstall
+
+zipinstall: fpc_zipinstall
+
+zipsourceinstall: fpc_zipsourceinstall
+
+zipexampleinstall: fpc_zipexampleinstall
+
+clean: fpc_clean
+
+distclean: fpc_distclean
+
+cleanall: fpc_cleanall
+
+info: fpc_info
+
+.PHONY:  all debug examples test smart shared showinstall install sourceinstall exampleinstall zipinstall zipsourceinstall zipexampleinstall clean distclean cleanall info
+
+#####################################################################
+# Units
+#####################################################################
+
+.PHONY: fpc_units
+
+override ALLTARGET+=fpc_units
+
+override UNITPPUFILES=$(addsuffix $(PPUEXT),$(UNITOBJECTS))
+override INSTALLPPUFILES+=$(UNITPPUFILES)
+override CLEANPPUFILES+=$(UNITPPUFILES)
+
+fpc_units: $(UNITPPUFILES)
+
+#####################################################################
+# Examples
+#####################################################################
+
+.PHONY: fpc_examples fpc_test
+
+ifdef EXAMPLEOBJECTS
+override EXAMPLESOURCEFILES:=$(addsuffix $(PASEXT),$(EXAMPLEOBJECTS))
+override EXAMPLEFILES:=$(addsuffix $(EXEEXT),$(EXAMPLEOBJECTS))
+override EXAMPLEOFILES:=$(addsuffix $(OEXT),$(EXAMPLEOBJECTS)) $(addprefix $(LIBPREFIX),$(addsuffix $(STATICLIBEXT),$(EXAMPLEOBJECTS)))
+
+override CLEANEXEFILES+=$(EXAMPLEFILES) $(EXAMPLEOFILES)
+endif
+
+fpc_examples: all $(EXAMPLEFILES) $(addsuffix _all,$(EXAMPLEDIROBJECTS))
+
+fpc_test: examples
+
+#####################################################################
+# General compile rules
+#####################################################################
+
+.PHONY: fpc_packages fpc_all fpc_debug
+
+$(FPCMADE): $(ALLTARGET)
+	@$(ECHO) Compiled > $(FPCMADE)
+
+fpc_packages: $(COMPILEPACKAGES)
+
+fpc_all: fpc_packages $(FPCMADE)
+
+fpc_debug:
+	$(MAKE) all DEBUG=1
+
+# Search paths for .ppu if targetdir is set
+ifdef UNITTARGETDIR
+vpath %$(PPUEXT) $(UNITTARGETDIR)
+endif
+
+# General compile rules, available for both possible PASEXT
+
+.SUFFIXES: $(EXEEXT) $(PPUEXT) $(OEXT) .pas .pp
+
+%$(PPUEXT): %.pp
+	$(COMPILER) $< $(REDIR)
+	$(EXECPPAS)
+
+%$(PPUEXT): %.pas
+	$(COMPILER) $< $(REDIR)
+	$(EXECPPAS)
+
+%$(EXEEXT): %.pp
+	$(COMPILER) $< $(REDIR)
+	$(EXECPPAS)
+
+%$(EXEEXT): %.pas
+	$(COMPILER) $< $(REDIR)
+	$(EXECPPAS)
+
+#####################################################################
+# Library
+#####################################################################
+
+.PHONY: fpc_smart fpc_shared
+
+ifdef LIBVERSION
+LIBFULLNAME=$(LIBNAME).$(LIBVERSION)
+else
+LIBFULLNAME=$(LIBNAME)
+endif
+
+# Default sharedlib units are all unit objects
+ifndef SHAREDLIBUNITOBJECTS
+SHAREDLIBUNITOBJECTS:=$(UNITOBJECTS)
+endif
+
+fpc_smart:
+	$(MAKE) all LINKSMART=1 CREATESMART=1
+
+fpc_shared: all
+ifdef HASSHAREDLIB
+ifndef LIBNAME
+	@$(ECHO) "LIBNAME not set"
+else
+	$(PPUMOVE) $(SHAREDLIBUNITOBJECTS) -o$(LIBFULLNAME)
+endif
+else
+	@$(ECHO) "Shared Libraries not supported"
+endif
+
+#####################################################################
+# Install rules
+#####################################################################
+
+.PHONY: fpc_showinstall fpc_install
+
+ifdef EXTRAINSTALLUNITS
+override INSTALLPPUFILES+=$(addsuffix $(PPUEXT),$(EXTRAINSTALLUNITS))
+endif
+
+ifdef INSTALLPPUFILES
+ifdef PPUFILES
+override INSTALLPPUFILES:=$(addprefix $(UNITTARGETDIRPREFIX),$(INSTALLPPUFILES))
+override INSTALLPPULINKFILES:=$(addprefix $(UNITTARGETDIRPREFIX),$(shell $(PPUFILES) -S -O $(INSTALLPPUFILES)))
+else
+override INSTALLPPULINKFILES:=$(subst $(PPUEXT),$(OEXT),$(INSTALLPPUFILES)) $(addprefix $(LIBPREFIX),$(subst $(PPUEXT),$(STATICLIBEXT),$(INSTALLPPUFILES)))
+override INSTALLPPUFILES:=$(addprefix $(UNITTARGETDIRPREFIX),$(INSTALLPPUFILES))
+override INSTALLPPULINKFILES:=$(wildcard $(addprefix $(UNITTARGETDIRPREFIX),$(INSTALLPPULINKFILES)))
+endif
+endif
+
+ifdef INSTALLEXEFILES
+override INSTALLEXEFILES:=$(addprefix $(TARGETDIRPREFIX),$(INSTALLEXEFILES))
+endif
+
+fpc_showinstall: $(SHOWINSTALLTARGET)
+ifdef INSTALLEXEFILES
+	@$(ECHO) -e $(addprefix "\n"$(BININSTALLDIR)/,$(INSTALLEXEFILES))
+endif
+ifdef INSTALLPPUFILES
+	@$(ECHO) -e $(addprefix "\n"$(UNITINSTALLDIR)/,$(INSTALLPPUFILES))
+ifneq ($(INSTALLPPULINKFILES),)
+	@$(ECHO) -e $(addprefix "\n"$(UNITINSTALLDIR)/,$(INSTALLPPULINKFILES))
+endif
+ifneq ($(wildcard $(LIBFULLNAME)),)
+	@$(ECHO) $(LIBINSTALLDIR)/$(LIBFULLNAME)
+ifdef HASSHAREDLIB
+	@$(ECHO) $(LIBINSTALLDIR)/$(LIBNAME)
+endif
+endif
+endif
+ifdef EXTRAINSTALLFILES
+	@$(ECHO) -e $(addprefix "\n"$(DATAINSTALLDIR)/,$(EXTRAINSTALLFILES))
+endif
+
+fpc_install: $(INSTALLTARGET)
+# Create UnitInstallFiles
+ifdef INSTALLEXEFILES
+	$(MKDIR) $(BININSTALLDIR)
+# Compress the exes if upx is defined
+ifdef UPXPROG
+	-$(UPXPROG) $(INSTALLEXEFILES)
+endif
+	$(INSTALLEXE) $(INSTALLEXEFILES) $(BININSTALLDIR)
+endif
+ifdef INSTALLPPUFILES
+	$(MKDIR) $(UNITINSTALLDIR)
+	$(INSTALL) $(INSTALLPPUFILES) $(UNITINSTALLDIR)
+ifneq ($(INSTALLPPULINKFILES),)
+	$(INSTALL) $(INSTALLPPULINKFILES) $(UNITINSTALLDIR)
+endif
+ifneq ($(wildcard $(LIBFULLNAME)),)
+	$(MKDIR) $(LIBINSTALLDIR)
+	$(INSTALL) $(LIBFULLNAME) $(LIBINSTALLDIR)
+ifdef inUnix
+	ln -sf $(LIBFULLNAME) $(LIBINSTALLDIR)/$(LIBNAME)
+endif
+endif
+endif
+ifdef EXTRAINSTALLFILES
+	$(MKDIR) $(DATAINSTALLDIR)
+	$(INSTALL) $(EXTRAINSTALLFILES) $(DATAINSTALLDIR)
+endif
+
+#####################################################################
+# SourceInstall rules
+#####################################################################
+
+.PHONY: fpc_sourceinstall
+
+ifndef SOURCETOPDIR
+SOURCETOPDIR=$(BASEDIR)
+endif
+
+fpc_sourceinstall: clean
+	$(MKDIR) $(SOURCEINSTALLDIR)
+	$(COPYTREE) $(SOURCETOPDIR) $(SOURCEINSTALLDIR)
+
+#####################################################################
+# exampleinstall rules
+#####################################################################
+
+.PHONY: fpc_exampleinstall
+
+fpc_exampleinstall: $(addsuffix _clean,$(EXAMPLEDIROBJECTS))
+ifdef EXAMPLESOURCEFILES
+	$(MKDIR) $(EXAMPLEINSTALLDIR)
+	$(COPY) $(EXAMPLESOURCEFILES) $(EXAMPLEINSTALLDIR)
+endif
+ifdef EXAMPLEDIROBJECTS
+ifndef EXAMPLESOURCEFILES
+	$(MKDIR) $(EXAMPLEINSTALLDIR)
+endif
+	$(COPYTREE) $(addsuffix /*,$(EXAMPLEDIROBJECTS)) $(EXAMPLEINSTALLDIR)
+endif
+
+#####################################################################
+# Zip
+#####################################################################
+
+.PHONY: fpc_zipinstall
+
+# Create suffix to add
+ifndef PACKAGESUFFIX
+PACKAGESUFFIX=$(OS_TARGET)
+ifeq ($(OS_TARGET),go32v2)
+PACKAGESUFFIX=go32
+endif
+ifeq ($(OS_TARGET),win32)
+PACKAGESUFFIX=w32
+endif
+ifeq ($(OS_TARGET),os2)
+PACKAGESUFFIX=emx
+endif
+endif
+
+# Temporary path to pack a file
+ifndef PACKDIR
+ifndef inUnix
+PACKDIR=$(BASEDIR)/../pack_tmp
+else
+PACKDIR=/tmp/fpc-pack
+endif
+endif
+
+# Maybe create default zipname from packagename
+ifndef ZIPNAME
+ifdef PACKAGENAME
+ZIPNAME=$(PACKAGEPREFIX)$(PACKAGENAME)$(PACKAGESUFFIX)
+endif
+endif
+
+# Use tar by default under linux
+ifndef USEZIP
+ifdef inUnix
+USETAR=1
+endif
+endif
+
+# Use a wrapper script by default for OS/2
+ifdef inOS2
+USEZIPWRAPPER=1
+endif
+
+# Create commands to create the zip/tar file
+ZIPWRAPPER=$(DESTZIPDIR)/fpczip$(BATCHEXT)
+ZIPCMD_CDPACK:=cd $(subst /,$(PATHSEP),$(PACKDIR))
+ZIPCMD_CDBASE:=cd $(subst /,$(PATHSEP),$(BASEDIR))
+ifdef USETAR
+ZIPDESTFILE:=$(DESTZIPDIR)/$(ZIPNAME)$(TAREXT)
+ZIPCMD_ZIP:=$(TARPROG) cf$(TAROPT) $(ZIPDESTFILE) *
+else
+ZIPDESTFILE:=$(DESTZIPDIR)/$(ZIPNAME)$(ZIPEXT)
+ZIPCMD_ZIP:=$(subst /,$(PATHSEP),$(ZIPPROG)) -Dr $(ZIPOPT) $(ZIPDESTFILE) *
+endif
+
+fpc_zipinstall:
+ifndef ZIPNAME
+	@$(ECHO) "Please specify ZIPNAME!"
+	@exit 1
+else
+	$(MAKE) $(ZIPTARGET) PREFIXINSTALLDIR=$(PACKDIR)
+	$(DEL) $(ZIPDESTFILE)
+ifdef USEZIPWRAPPER
+ifneq ($(ECHO),echo)
+	$(ECHO) "$(ZIPCMD_CDPACK)" > $(ZIPWRAPPER)
+	$(ECHO) "$(ZIPCMD_ZIP)" >> $(ZIPWRAPPER)
+	$(ECHO) "$(ZIPCMD_CDBASE)" >> $(ZIPWRAPPER)
+else
+	$(ECHO) $(ZIPCMD_CDPACK) > $(ZIPWRAPPER)
+	$(ECHO) $(ZIPCMD_ZIP) >> $(ZIPWRAPPER)
+	$(ECHO) $(ZIPCMD_CDBASE) >> $(ZIPWRAPPER)
+endif
+ifdef inUnix
+	/bin/sh $(ZIPWRAPPER)
+else
+	$(ZIPWRAPPER)
+endif
+	$(DEL) $(ZIPWRAPPER)
+else
+	$(ZIPCMD_CDPACK) ; $(ZIPCMD_ZIP) ; $(ZIPCMD_CDBASE)
+endif
+	$(DELTREE) $(PACKDIR)
+endif
+
+.PHONY:  fpc_zipsourceinstall
+
+fpc_zipsourceinstall:
+	$(MAKE) fpc_zipinstall ZIPTARGET=sourceinstall PACKAGESUFFIX=src
+
+.PHONY:  fpc_zipexampleinstall
+
+fpc_zipexampleinstall:
+	$(MAKE) fpc_zipinstall ZIPTARGET=exampleinstall PACKAGESUFFIX=exm
+
+#####################################################################
+# Clean rules
+#####################################################################
+
+.PHONY: fpc_clean fpc_cleanall fpc_distclean
+
+ifdef EXEFILES
+override CLEANEXEFILES:=$(addprefix $(TARGETDIRPREFIX),$(CLEANEXEFILES))
+endif
+
+ifdef EXTRACLEANUNITS
+override CLEANPPUFILES+=$(addsuffix $(PPUEXT),$(EXTRACLEANUNITS))
+endif
+
+ifdef CLEANPPUFILES
+override CLEANPPUFILES:=$(addprefix $(UNITTARGETDIRPREFIX),$(CLEANPPUFILES))
+# Get the .o and .a files created for the units
+ifdef PPUFILES
+CLEANPPULINKFILES:=$(shell $(PPUFILES) $(CLEANPPUFILES))
+else
+CLEANPPULINKFILES:=$(wildcard $(subst $(PPUEXT),$(OEXT),$(CLEANPPUFILES)) $(addprefix $(LIBPREFIX),$(subst $(PPUEXT),$(STATICLIBEXT),$(CLEANPPUFILES))))
+endif
+override CLEANPPULINKFILES:=$(addprefix $(UNITTARGETDIRPREFIX),$(CLEANPPULINKFILES))
+endif
+
+fpc_clean: $(CLEANTARGET)
+ifdef CLEANEXEFILES
+	-$(DEL) $(CLEANEXEFILES)
+endif
+ifdef CLEANPPUFILES
+	-$(DEL) $(CLEANPPUFILES)
+endif
+ifneq ($(CLEANPPULINKFILES),)
+	-$(DEL) $(CLEANPPULINKFILES)
+endif
+ifdef CLEANRSTFILES
+	-$(DEL) $(addprefix $(UNITTARGETDIRPREFIX),$(CLEANRSTFILES))
+endif
+ifdef EXTRACLEANFILES
+	-$(DEL) $(EXTRACLEANFILES)
+endif
+ifdef LIBNAME
+	-$(DEL) $(LIBNAME) $(LIBFULLNAME)
+endif
+	-$(DEL) $(FPCMADE) $(PPAS) link.res $(FPCEXTFILE) $(REDIRFILE)
+
+fpc_distclean: fpc_clean
+
+# Also run clean first if targetdir is set. Unittargetdir is always
+# set if targetdir or unittargetdir is specified
+ifdef UNITTARGETDIR
+TARGETDIRCLEAN=fpc_clean
+endif
+
+fpc_cleanall: $(CLEANTARGET) $(TARGETDIRCLEAN)
+ifdef CLEANEXEFILES
+	-$(DEL) $(CLEANEXEFILES)
+endif
+	-$(DEL) *$(OEXT) *$(PPUEXT) *$(RSTEXT) *$(ASMEXT) *$(STATICLIBEXT) *$(SHAREDLIBEXT) *$(PPLEXT)
+	-$(DELTREE) *$(SMARTEXT)
+	-$(DEL) $(FPCMADE) $(PPAS) link.res $(FPCEXTFILE) $(REDIRFILE)
+
+#####################################################################
+# Info rules
+#####################################################################
+
+.PHONY: fpc_info fpc_cfginfo fpc_objectinfo fpc_toolsinfo fpc_installinfo \
+	fpc_dirinfo
+
+fpc_info: $(INFOTARGET)
+
+fpc_infocfg:
+	@$(ECHO)
+	@$(ECHO)  == Configuration info ==
+	@$(ECHO)
+	@$(ECHO)  FPC....... $(FPC)
+	@$(ECHO)  Version... $(FPC_VERSION)
+	@$(ECHO)  CPU....... $(CPU_TARGET)
+	@$(ECHO)  Source.... $(OS_SOURCE)
+	@$(ECHO)  Target.... $(OS_TARGET)
+	@$(ECHO)
+
+fpc_infoobjects:
+	@$(ECHO)
+	@$(ECHO)  == Object info ==
+	@$(ECHO)
+	@$(ECHO)  LoaderObjects..... $(LOADEROBJECTS)
+	@$(ECHO)  UnitObjects....... $(UNITOBJECTS)
+	@$(ECHO)  ExeObjects........ $(EXEOBJECTS)
+	@$(ECHO)
+	@$(ECHO)  ExtraCleanUnits... $(EXTRACLEANUNITS)
+	@$(ECHO)  ExtraCleanFiles... $(EXTRACLEANFILES)
+	@$(ECHO)
+	@$(ECHO)  ExtraInstallUnits. $(EXTRAINSTALLUNITS)
+	@$(ECHO)  ExtraInstallFiles. $(EXTRAINSTALLFILES)
+	@$(ECHO)
+
+fpc_infoinstall:
+	@$(ECHO)
+	@$(ECHO)  == Install info ==
+	@$(ECHO)
+ifdef DATE
+	@$(ECHO)  DateStr.............. $(DATESTR)
+endif
+ifdef PACKAGEPREFIX
+	@$(ECHO)  PackagePrefix........ $(PACKAGEPREFIX)
+endif
+ifdef PACKAGENAME
+	@$(ECHO)  PackageName.......... $(PACKAGENAME)
+endif
+	@$(ECHO)  PackageSuffix........ $(PACKAGESUFFIX)
+	@$(ECHO)
+	@$(ECHO)  BaseInstallDir....... $(BASEINSTALLDIR)
+	@$(ECHO)  BinInstallDir........ $(BININSTALLDIR)
+	@$(ECHO)  LibInstallDir........ $(LIBINSTALLDIR)
+	@$(ECHO)  UnitInstallDir....... $(UNITINSTALLDIR)
+	@$(ECHO)  SourceInstallDir..... $(SOURCEINSTALLDIR)
+	@$(ECHO)  DocInstallDir........ $(DOCINSTALLDIR)
+	@$(ECHO)  DataInstallDir....... $(DATAINSTALLDIR)
+	@$(ECHO)
+	@$(ECHO)  DestZipDir........... $(DESTZIPDIR)
+	@$(ECHO)  ZipName.............. $(ZIPNAME)
+	@$(ECHO)
+
+#####################################################################
+# Local Makefile
+#####################################################################
+
+ifneq ($(wildcard fpcmake.loc),)
+include fpcmake.loc
+endif
+

+ 10 - 0
packages/libgd/Makefile.fpc

@@ -0,0 +1,10 @@
+#
+#   Makefile.fpc for ZLib (LibC version)
+#
+
+[targets]
+units=gd
+examples=gdtest
+
+[dirs]
+fpcdir=../..

+ 30 - 0
packages/libgd/README

@@ -0,0 +1,30 @@
+This is the interface unit for the gd library, version 1.8.4.
+The gd library is a library to produce graphics files (jpeg,png and wbmp)
+
+The gd unit is a straight translation of the library headers.
+It has some additional calls which make it more pascal like:
+
+{overloaded pascal functions}
+function fopen(a,b:string):pFile;
+procedure gdImageChar(im:gdImagePtr; f:gdFontPtr; x:longint; y:longint; c:char; color:longint);
+procedure gdImageCharUp(im:gdImagePtr; f:gdFontPtr; x:longint; y:longint; c:char; color:longint); 
+procedure gdImageString(im:gdImagePtr; f:gdFontPtr; x:longint; y:longint; s:string;  color:longint); 
+procedure gdImageStringUp(im:gdImagePtr; f:gdFontPtr; x:longint; y:longint; s:string; color:longint); 
+procedure gdImageString16(im:gdImagePtr; f:gdFontPtr; x:longint; y:longint; s:string; color:longint); 
+procedure gdImageStringUp16(im:gdImagePtr; f:gdFontPtr; x:longint; y:longint; s:string; color:longint); 
+{$ifdef hasttf}
+function  gdImageStringTTF(im:PgdImage; brect:Plongint; fg:longint; fontlist:string; ptsize:double; angle:double; x:longint; y:longint; astring:string): string;
+function  gdImageStringFT(im:PgdImage; brect:Plongint; fg:longint; fontlist:string; ptsize:double; angle:double; x:longint; y:longint; astring:string):string;
+{$endif}
+
+These functions will work with both ansistrings and shortstrings; The unit
+can be compiled in both the {$H+} as the {$H-} state.
+
+The hasttf define should be defined for libraries which have TTF2 lib 
+support compiled in.
+
+The example is adapted from the example of the gd unit by Mike Bradbery.
+It shows how to use the pascal-like functions in the gd unit instead of the
+raw C like functions which use pchars.
+
+Michael.

+ 409 - 0
packages/libgd/gd.pp

@@ -0,0 +1,409 @@
+{
+    $Id$
+    This file is part of the Free Pascal run time library.
+    Copyright (c) 1999-2000 by Michael Van Canneyt, member of 
+    the Free Pascal development team
+
+    This file implements an interface to the gd library.
+    
+    See the file COPYING.FPC, included in this distribution,
+    for details about the copyright.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ **********************************************************************}
+unit gd;
+
+  interface
+  
+{$linklib c}
+{$linklib m}
+{$linklib png}
+{$linklib gd}
+{$ifdef hasttf}
+{$linklib ttf}
+{$endif hasttf}
+
+{$PACKRECORDS C}
+
+const
+
+  libgd = 'gd';
+  libc = 'c';
+  
+  GD_H = 1;
+  DEFAULT_FONTPATH = '/usr/share/fonts/truetype';
+  PATHSEPARATOR = ':';
+  gdMaxColors = 256;
+
+type
+  PByte = ^Byte;
+  PPByte = ^PByte; 
+  PVoid = Pointer;
+  PFile = Pointer;
+  
+  PGDIMAGESTRUCT = ^gdImage;
+  gdImage = record
+    pixels : PPbyte;
+    sx : longint;
+    sy : longint;
+    colorsTotal : longint;
+    red : array[0..(gdMaxColors)-1] of longint;
+    green : array[0..(gdMaxColors)-1] of longint;
+    blue : array[0..(gdMaxColors)-1] of longint;
+    open : array[0..(gdMaxColors)-1] of longint;
+    transparent : longint;
+    polyInts : Plongint;
+    polyAllocated : longint;
+    brush : PgdImageStruct;
+    tile : PgdImageStruct;
+    brushColorMap : array[0..(gdMaxColors)-1] of longint;
+    tileColorMap : array[0..(gdMaxColors)-1] of longint;
+    styleLength : longint;
+    stylePos : longint;
+    style : Plongint;
+    interlace : longint;
+  end;
+
+  gdImageStruct = gdImage;
+  pgdImage = ^gdImage;
+  gdImagePtr = PgdImage;
+
+  gdFont = record
+       nchars : longint;
+       offset : longint;
+       w : longint;
+       h : longint;
+       data : Pchar;
+    end;
+  pgdFont = ^gdFont;
+  gdFontPtr = PgdFont;
+
+var
+  gdFontLarge      : gdFontPtr;external name 'gdFontLarge';
+  gdFontSmall      : gdFontPtr;external name 'gdFontSmall';
+  gdFontGiant      : gdFontPtr;external name 'gdFontGiant';
+  gdFontMediumBold : gdFontPtr;external name 'gdFontMediumBold';
+  gdFontTiny       : gdFontPtr;external name 'gdFontTiny';
+
+const
+  gdDashSize = 4;
+  gdStyled = -(2);
+  gdBrushed = -(3);
+  gdStyledBrushed = -(4);
+  gdTiled = -(5);
+  gdTransparent = -(6);
+
+type
+
+  gdSource = record
+    source : function (context:Pointer; buffer:Pchar; len:longint):longint;cdecl;
+    context : pointer;
+    end;
+  pgdSource = ^gdSource;
+  gdSourcePtr = PgdSource;
+
+  gdSink = record
+    sink : function (context:Pvoid; buffer:Pchar; len:longint):longint;cdecl;
+    context : pointer;
+  end;
+  pgdSink = ^gdSink;
+  gdSinkPtr = PgdSink;
+
+  gdPoint = record
+    x : longint;
+    y : longint;
+  end;
+  pgdPoint = ^gdPoint;
+  gdPointPtr = PgdPoint;
+
+  pgdIOCtx = ^gdIOCtx;
+  gdIOCtx = record
+    getC : function (_para1:PgdIOCtx):longint;cdecl;
+    getBuf : function (_para1:PgdIOCtx; _para2:pointer; _para3:longint):longint;
+    putC : procedure (_para1:PgdIOCtx; _para2:longint);
+    putBuf : function (_para1:PgdIOCtx; _para2:pointer; _para3:longint):longint;
+    seek : function (_para1:PgdIOCtx; _para2:longint):longint;
+    tell : function (_para1:PgdIOCtx):longint;
+    free : procedure (_para1:PgdIOCtx);
+  end;
+  GDIOCTXPTR = pgdIOCtx;
+  
+{ Translated from gd_io.h}
+function fopen(a,b:pchar):pFile; cdecl;external libc;
+procedure fclose(a:pFile); cdecl;external libc;
+
+procedure Putword(w:longint; ctx:PgdIOCtx); cdecl; external libgd;
+procedure Putchar(c:longint; ctx:PgdIOCtx); cdecl; external libgd;
+procedure gdPutC(c:byte; ctx:PgdIOCtx); cdecl; external libgd;
+function gdPutBuf(_para1:pointer; _para2:longint; _para3:PgdIOCtx):longint; cdecl; external libgd;
+procedure gdPutWord(w:longint; ctx:PgdIOCtx); cdecl; external libgd;
+procedure gdPutInt(w:longint; ctx:PgdIOCtx); cdecl; external libgd;
+function gdGetC(ctx:PgdIOCtx):longint; cdecl; external libgd;
+function gdGetBuf(_para1:pointer; _para2:longint; _para3:PgdIOCtx):longint; cdecl; external libgd;
+function gdGetByte(result:Plongint; ctx:PgdIOCtx):longint; cdecl; external libgd;
+function gdGetWord(result:Plongint; ctx:PgdIOCtx):longint; cdecl; external libgd;
+function gdGetInt(result:Plongint; ctx:PgdIOCtx):longint; cdecl; external libgd;
+function gdSeek(ctx:PgdIOCtx; _para2:longint):longint; cdecl; external libgd;
+function gdTell(ctx:PgdIOCtx):longint; cdecl; external libgd;
+
+function gdImageCreate(sx:longint; sy:longint):gdImagePtr; cdecl; external libgd;
+function gdImageCreateFromPng(fd:PFILE):gdImagePtr; cdecl; external libgd;
+function gdImageCreateFromPngCtx(inIO:gdIOCtxPtr):gdImagePtr; cdecl; external libgd;
+function gdImageCreateFromWBMP(inFile:PFILE):gdImagePtr; cdecl; external libgd;
+function gdImageCreateFromWBMPCtx(infile:PgdIOCtx):gdImagePtr; cdecl; external libgd;
+function gdImageCreateFromJpeg(infile:PFILE):gdImagePtr; cdecl; external libgd;
+function gdImageCreateFromJpegCtx(infile:PgdIOCtx):gdImagePtr; cdecl; external libgd;
+function gdImageCreateFromPngSource(infile:gdSourcePtr):gdImagePtr; cdecl; external libgd;
+function gdImageCreateFromGd(infile:PFILE):gdImagePtr; cdecl; external libgd;
+function gdImageCreateFromGdCtx(infile:gdIOCtxPtr):gdImagePtr; cdecl; external libgd;
+function gdImageCreateFromGd2(infile:PFILE):gdImagePtr; cdecl; external libgd;
+function gdImageCreateFromGd2Ctx(infile:gdIOCtxPtr):gdImagePtr; cdecl; external libgd;
+function gdImageCreateFromGd2Part(infile:PFILE; srcx:longint; srcy:longint; w:longint; h:longint):gdImagePtr; cdecl; external libgd;
+function gdImageCreateFromGd2PartCtx(infile:gdIOCtxPtr; srcx:longint; srcy:longint; w:longint; h:longint):gdImagePtr; cdecl; external libgd;
+function gdImageCreateFromXbm(fd:PFILE):gdImagePtr; cdecl; external libgd;
+procedure gdImageDestroy(im:gdImagePtr); cdecl; external libgd;
+procedure gdImageSetPixel(im:gdImagePtr; x:longint; y:longint; color:longint); cdecl; external libgd;
+function gdImageGetPixel(im:gdImagePtr; x:longint; y:longint):longint; cdecl; external libgd;
+procedure gdImageLine(im:gdImagePtr; x1:longint; y1:longint; x2:longint; y2:longint;  color:longint); cdecl; external libgd;
+procedure gdImageDashedLine(im:gdImagePtr; x1:longint; y1:longint; x2:longint; y2:longint;               color:longint); cdecl; external libgd;
+procedure gdImageRectangle(im:gdImagePtr; x1:longint; y1:longint; x2:longint; y2:longint;              color:longint); cdecl; external libgd;
+procedure gdImageFilledRectangle(im:gdImagePtr; x1:longint; y1:longint; x2:longint; y2:longint;               color:longint); cdecl; external libgd;
+function gdImageBoundsSafe(im:gdImagePtr; x:longint; y:longint):longint; cdecl; external libgd;
+procedure gdImageChar(im:gdImagePtr; f:gdFontPtr; x:longint; y:longint; c:longint; color:longint); cdecl; external libgd;
+procedure gdImageCharUp(im:gdImagePtr; f:gdFontPtr; x:longint; y:longint; c:longint; color:longint); cdecl; external libgd;
+procedure gdImageString(im:gdImagePtr; f:gdFontPtr; x:longint; y:longint; s:Pbyte;  color:longint); cdecl; external libgd;
+procedure gdImageStringUp(im:gdImagePtr; f:gdFontPtr; x:longint; y:longint; s:Pbyte; color:longint); cdecl; external libgd;
+procedure gdImageString16(im:gdImagePtr; f:gdFontPtr; x:longint; y:longint; s:Pword; color:longint); cdecl; external libgd;
+procedure gdImageStringUp16(im:gdImagePtr; f:gdFontPtr; x:longint; y:longint; s:Pword; color:longint); cdecl; external libgd;
+{$ifdef HasTTF}
+function gdImageStringTTF(im:PgdImage; brect:Plongint; fg:longint; fontlist:Pchar; ptsize:double; angle:double; x:longint; y:longint; astring:Pchar):Pchar; cdecl; external libgd;
+function gdImageStringFT(im:PgdImage; brect:Plongint; fg:longint; fontlist:Pchar; ptsize:double; angle:double; x:longint; y:longint; astring:Pchar):Pchar; cdecl; external libgd;
+{$endif hasTTF}
+procedure gdImagePolygon(im:gdImagePtr; p:gdPointPtr; n:longint; c:longint); cdecl; external libgd;
+procedure gdImageFilledPolygon(im:gdImagePtr; p:gdPointPtr; n:longint; c:longint); cdecl; external libgd;
+function gdImageColorAllocate(im:gdImagePtr; r:longint; g:longint; b:longint):longint; cdecl; external libgd;
+function gdImageColorClosest(im:gdImagePtr; r:longint; g:longint; b:longint):longint; cdecl; external libgd;
+function gdImageColorExact(im:gdImagePtr; r:longint; g:longint; b:longint):longint; cdecl; external libgd;
+function gdImageColorResolve(im:gdImagePtr; r:longint; g:longint; b:longint):longint; cdecl; external libgd;
+procedure gdImageColorDeallocate(im:gdImagePtr; color:longint); cdecl; external libgd;
+procedure gdImageColorTransparent(im:gdImagePtr; color:longint); cdecl; external libgd;
+procedure gdImagePaletteCopy(dst:gdImagePtr; src:gdImagePtr); cdecl; external libgd;
+procedure gdImagePng(im:gdImagePtr; out:PFILE); cdecl; external libgd;
+procedure gdImagePngCtx(im:gdImagePtr; out:PgdIOCtx); cdecl; external libgd;
+procedure gdImageWBMP(image:gdImagePtr; fg:longint; out:PFILE); cdecl; external libgd;
+procedure gdImageWBMPCtx(image:gdImagePtr; fg:longint; out:PgdIOCtx); cdecl; external libgd;
+procedure gdFree(m:Pvoid); cdecl; external libgd;
+function gdImageWBMPPtr(im:gdImagePtr; size:Plongint; fg:longint):pointer; cdecl; external libgd;
+procedure gdImageJpeg(im:gdImagePtr; out:PFILE; quality:longint); cdecl; external libgd;
+procedure gdImageJpegCtx(im:gdImagePtr; out:PgdIOCtx; quality:longint); cdecl; external libgd;
+function gdImageJpegPtr(im:gdImagePtr; size:Plongint; quality:longint):pointer; cdecl; external libgd;
+procedure gdImagePngToSink(im:gdImagePtr; out:gdSinkPtr); cdecl; external libgd;
+procedure gdImageGd(im:gdImagePtr; out:PFILE); cdecl; external libgd;
+procedure gdImageGd2(im:gdImagePtr; out:PFILE; cs:longint; fmt:longint); cdecl; external libgd;
+function gdImagePngPtr(im:gdImagePtr; size:Plongint):pointer; cdecl; external libgd;
+function gdImageGdPtr(im:gdImagePtr; size:Plongint):pointer; cdecl; external libgd;
+function gdImageGd2Ptr(im:gdImagePtr; cs:longint; fmt:longint; size:Plongint):pointer; cdecl; external libgd;
+procedure gdImageArc(im:gdImagePtr; cx:longint; cy:longint; w:longint; h:longint;  s:longint; e:longint; color:longint); cdecl; external libgd;
+procedure gdImageFillToBorder(im:gdImagePtr; x:longint; y:longint; border:longint; color:longint); cdecl; external libgd;
+procedure gdImageFill(im:gdImagePtr; x:longint; y:longint; color:longint); cdecl; external libgd;
+procedure gdImageCopy(dst:gdImagePtr; src:gdImagePtr; dstX:longint; dstY:longint; srcX:longint;             srcY:longint; w:longint; h:longint); cdecl; external libgd;
+procedure gdImageCopyMerge(dst:gdImagePtr; src:gdImagePtr; dstX:longint; dstY:longint; srcX:longint;              srcY:longint; w:longint; h:longint; pct:longint); cdecl; external libgd;
+procedure gdImageCopyMergeGray(dst:gdImagePtr; src:gdImagePtr; dstX:longint; dstY:longint; srcX:longint;              srcY:longint; w:longint; h:longint; pct:longint); cdecl; external libgd;
+procedure gdImageCopyResized(dst:gdImagePtr; src:gdImagePtr; dstX:longint; dstY:longint; srcX:longint;               srcY:longint; dstW:longint; dstH:longint; srcW:longint; srcH:longint); cdecl; external libgd;
+procedure gdImageSetBrush(im:gdImagePtr; brush:gdImagePtr); cdecl; external libgd;
+procedure gdImageSetTile(im:gdImagePtr; tile:gdImagePtr); cdecl; external libgd;
+procedure gdImageSetStyle(im:gdImagePtr; style:Plongint; noOfPixels:longint); cdecl; external libgd;
+procedure gdImageInterlace(im:gdImagePtr; interlaceArg:longint); cdecl; external libgd;
+  
+{ Translated macros }
+function gdImageSX(im : pgdimage) : longint;
+function gdImageSY(im : pgdimage) : longint;
+function gdImageColorsTotal(im : pgdimage) : longint;
+function gdImageRed(im : pgdimage; c : longint): longint;
+function gdImageGreen(im : pgdimage; c : longint): longint;
+function gdImageBlue(im : pgdimage; c : longint): longint;
+function gdImageGetTransparent(im : pgdimage) : longint;
+function gdImageGetInterlaced(im : pgdimage) : longint;
+
+function gdNewFileCtx(_para1:PFILE):PgdIOCtx; cdecl; external libgd;
+function gdNewDynamicCtx(_para1:longint; _para2:pointer):PgdIOCtx; cdecl; external libgd;
+function gdNewSSCtx(infile:gdSourcePtr; out:gdSinkPtr):PgdIOCtx; cdecl; external libgd;
+function gdDPExtractData(ctx:pointer; size:Plongint):pointer; cdecl; external libgd;
+
+{overloaded pascal functions}
+function fopen(a,b:string):pFile;
+procedure gdImageChar(im:gdImagePtr; f:gdFontPtr; x:longint; y:longint; c:char; color:longint);
+procedure gdImageCharUp(im:gdImagePtr; f:gdFontPtr; x:longint; y:longint; c:char; color:longint); 
+procedure gdImageString(im:gdImagePtr; f:gdFontPtr; x:longint; y:longint; s:string;  color:longint); 
+procedure gdImageStringUp(im:gdImagePtr; f:gdFontPtr; x:longint; y:longint; s:string; color:longint); 
+procedure gdImageString16(im:gdImagePtr; f:gdFontPtr; x:longint; y:longint; s:string; color:longint); 
+procedure gdImageStringUp16(im:gdImagePtr; f:gdFontPtr; x:longint; y:longint; s:string; color:longint); 
+{$ifdef hasttf}
+function  gdImageStringTTF(im:PgdImage; brect:Plongint; fg:longint; fontlist:string; ptsize:double; angle:double; x:longint; y:longint; astring:string): string;
+function  gdImageStringFT(im:PgdImage; brect:Plongint; fg:longint; fontlist:string; ptsize:double; angle:double; x:longint; y:longint; astring:string):string;
+{$endif}
+
+
+const
+  GD2_CHUNKSIZE = 128;
+  GD2_CHUNKSIZE_MIN = 64;
+  GD2_CHUNKSIZE_MAX = 4096;
+  GD2_VERS = 1;
+  GD2_ID = 'gd2';
+  GD2_FMT_RAW = 1;
+  GD2_FMT_COMPRESSED = 2;
+
+function gdImageCompare(im1:gdImagePtr; im2:gdImagePtr):longint;cdecl; external libgd;
+  
+const
+  GD_CMP_IMAGE = 1;
+  GD_CMP_NUM_COLORS = 2;
+  GD_CMP_COLOR = 4;
+  GD_CMP_SIZE_X = 8;
+  GD_CMP_SIZE_Y = 16;
+  GD_CMP_TRANSPARENT = 32;
+  GD_CMP_BACKGROUND = 64;
+  GD_CMP_INTERLACE = 128;
+  GD_RESOLUTION = 96;
+
+implementation
+
+  function gdImageSX(im : pgdimage) : longint;
+    begin
+       gdImageSX:=im^.sx;
+    end;
+  function gdImageSY(im : pgdimage) : longint;
+    begin
+       gdImageSY:=im^.sy;
+    end;
+  function gdImageColorsTotal(im : pgdimage) : longint;
+    begin
+       gdImageColorsTotal:=im^.colorsTotal;
+    end;
+  function gdImageGetTransparent(im : pgdimage) : longint;
+    begin
+       gdImageGetTransparent:=im^.transparent;
+    end;
+  function gdImageGetInterlaced(im : pgdimage) : longint;
+    begin
+       gdImageGetInterlaced:=im^.interlace;
+    end;
+    
+  function gdImageRed(im : pgdimage; c : longint): longint;
+  
+  begin
+    gdImageRed:=im^.red[c];
+  end;
+
+  function gdImageGreen(im : pgdimage; c : longint): longint;
+  
+  begin
+    gdImageGreen := im^.green[c];
+  end;
+  
+  function gdImageBlue(im : pgdimage; c : longint): longint;
+
+  begin
+    gdImageBlue := im^.blue[c];
+  end;
+
+function fopen(a,b:string):pFile;
+
+begin
+{$ifopt h+}
+  fopen:=fopen(pchar(a),pchar(b));
+{$else}
+  a:=a+#0;  
+  b:=b+#0;
+  fopen:=fopen(@a[1],@b[1]);
+{$endif}
+end;
+
+procedure gdImageChar(im:gdImagePtr; f:gdFontPtr; x:longint; y:longint; c:char; color:longint);
+
+begin
+  gdimagechar(im,f,x,y,ord(c),color);
+end;
+
+procedure gdImageCharUp(im:gdImagePtr; f:gdFontPtr; x:longint; y:longint; c:char; color:longint);
+
+begin
+  gdimagecharup(im,f,x,y,ord(c),color);
+end;
+
+procedure gdImageString(im:gdImagePtr; f:gdFontPtr; x:longint; y:longint; s:string;  color:longint);
+
+begin
+{$ifopt h+}
+  gdImageString(im,f,x,y,pbyte(pchar(s)),color);
+{$else}
+  s:=s+#0;
+  gdImageString(im,f,x,y,@s[1],color);
+{$endif}  
+end;
+
+procedure gdImageStringUp(im:gdImagePtr; f:gdFontPtr; x:longint; y:longint; s:string; color:longint);
+
+begin
+{$ifopt h+} 
+  gdImageStringUp(im,f,x,y,pbyte(pchar(s)),color);
+{$else}
+  s:=s+#0;
+  gdImageStringUp(im,f,x,y,pbyte(@s[1]),color);
+{$endif}  
+end;
+
+procedure gdImageString16(im:gdImagePtr; f:gdFontPtr; x:longint; y:longint; s:string; color:longint);
+
+begin
+{$ifopt h+}
+  gdImageString16(im,f,x,y,pword(pchar(s)),color);
+{$else}
+  s:=s+#0;
+  gdImageString16(im,f,x,y,pword(@s[1]),color);
+{$endif}  
+end;
+
+procedure gdImageStringUp16(im:gdImagePtr; f:gdFontPtr; x:longint; y:longint; s:string; color:longint);
+
+begin
+{$ifopt h+}
+  gdImageStringUp16(im,f,x,y,pword(pchar(s)),color);
+{$else}  
+  s:=s+#0;
+  gdImageStringUp16(im,f,x,y,pword(@s[1]),color);
+{$endif}  
+end;
+
+{$ifdef hasttf}
+
+function gdImageStringTTF(im:PgdImage; brect:Plongint; fg:longint; fontlist:string; ptsize:double; angle:double; x:longint; y:longint; astring:string): string;
+
+begin
+{$ifopt h+}  
+  gdImageStringTTF:=strpas(gdImageStringTTF(im,brect,fg,pchar(fontlist),ptsize,angle,x,y,pchar(astring)));
+{$else}  
+  fontlist:=fornlist+#0;
+  astring:=astring+#0;
+  gdImageStringTTF:=strpas(gdImageStringTTF(im,brect,fg,@fontlist[1],ptsize,angle,x,y,@astring[1]));
+{$endif}
+end;
+
+function gdImageStringFT(im:PgdImage; brect:Plongint; fg:longint; fontlist:string; ptsize:double; angle:double; x:longint; y:longint; astring:string):string;
+
+begin
+{$ifopt h+}
+  gdImageStringFT:=strpas(gdImageStringFT(im,brect,fg,pchar(fontlist),ptsize,angle,x,y,pchar(astring)));
+{$else}
+  fontlist:=fornlist+#0;
+  astring:=astring+#0;
+  gdImageStringFT:=strpas(gdImageStringFT(im,brect,fg,@fontlist[1],ptsize,angle,x,y,@astring[1]));
+    
+{$endif}  
+end;
+{$endif}
+
+end.

+ 82 - 0
packages/libgd/gdtest.pp

@@ -0,0 +1,82 @@
+{ Author   : Mike Bradbery 
+  Copyright: 2000 Mike Bradbery and others, see file "forum.txt" }
+
+program gdtest;
+
+uses gd;
+
+var 
+  f:pFile;
+  black,white:integer;
+  red,green,blue:integer;
+  im:gdImagePtr;
+  s1,s2:string;
+  points:array[0..2] of gdpoint;
+  x : longint;
+  styleDotted: array[0..1] of longint;
+  styleDashed: array[0..5] of longint;
+  top,bottom,left,right : longint;
+
+Begin
+  left := 60;
+  top := 30;
+  right := 580;
+  bottom := 300;
+  im:=gdImageCreate(600,390);
+  black:=gdImageColorAllocate(im,0,0,0);
+  white:=gdImageColorAllocate(im,255,255,255);
+  red:=gdImageColorAllocate(im,255,0,0);
+  green:=gdImageColorAllocate(im,0,255,0);
+  blue:=gdImageColorAllocate(im,0,0,255);
+  styleDotted[0] := red;
+  styleDotted[1] := gdTransparent;
+
+  styleDashed[0] := white;
+  styleDashed[1] := white;
+  styleDashed[2] := white;
+  styleDashed[3] := gdTransparent;
+  styleDashed[4] := gdTransparent;
+  styleDashed[5] := gdTransparent;
+  gdImageSetStyle(im,@styleDashed[0],6 );
+
+  {box around the lot}
+  gdImageRectangle(im,0,0,599,389,white);
+
+  {main title}
+  s1:='The Test Graph Title.';
+  gdImageString(im, gdFontLarge,{im^.w}600  div 2 - ((length(s1)-1)*gdFontLarge^.w div 2),2{gdFontLarge^.h}, s1, white);
+  gdImageLine(im,600  div 2 - ((length(s1)-1)*gdFontLarge^.w div 2),gdFontLarge^.h+3,600  div 2 + ((length(s1)-1)*gdFontLarge^.w div 2),gdFontLarge^.h+3,white);
+
+  {box around the legend.}
+  gdImageRectangle(im,100,350,500,370,white);
+  s1:='The Legend.';
+  gdImageString(im, gdFontLarge, 100+2, 350+2, s1, white);
+
+  s1:='The Y axis Title.';
+  gdImageStringUp(im, gdFontLarge, Left-5-gdFontLarge^.h-gdFontLarge^.w*2, top+(bottom-top) div 2+((length(s1)-1) * gdFontLarge^.w div 2),s1, white);
+  // gdImageStringUp(im, gdFontLarge, 2, 50, @s1[1], white);
+  s1:='The X axis Title.';
+  gdImageString(im, gdFontLarge, left+(right-left) div 2-((length(s1)-1)*gdFontLarge^.w div 2),Bottom + 5 +gdFontLarge^.h,s1,white);
+
+  {axis}
+  gdImageLine(im,left,top,left,bottom,white);
+  gdImageLine(im,left,bottom,right,bottom,white);
+
+  { the origin is 30,360}
+  for x:=0 to 10 do
+  begin
+    str(x,s1);
+    gdImageLine(im,left+(x*(right-left) div 10) ,bottom,left+(x*(right-left) div 10) ,bottom+3,white);
+    gdImageLine(im, left+(x*(right-left) div 10), bottom, left+(x*(right-left) div 10), top, gdStyled);
+    gdImageString(im, gdFontLarge, left+(x*(right-left) div 10) - ((length(s1)-1)*gdFontLarge^.w div 2),bottom+5, s1, white);
+    gdImageLine(im,left,bottom-(x*(bottom-top) div 10),left-3,bottom-(x*(bottom-top) div 10),white);
+    gdImageLine(im, left, bottom-(x*(bottom-top) div 10), right, bottom-(x*(bottom-top) div 10), gdStyled);
+    gdImageString(im, gdFontLarge,left-5-((length(s1)-1)*gdFontLarge^.w),bottom-(x*(bottom-top) div 10)-gdFontLarge^.h div 2, s1, white);
+  end;
+  f:=fopen(paramstr(1),'wb');
+  if (f=nil) then 
+    writeln('Help, the file pointer is nil');
+  gdImagePng(im,f);
+  fclose(f);
+  gdImageDestroy(im);
+End.