MG: added find declaration (not useful yet)

git-svn-id: trunk@531 -
This commit is contained in:
lazarus 2001-12-15 22:57:20 +00:00
parent 8bb59a9320
commit 1ac246b52e
6 changed files with 406 additions and 424 deletions

View File

@ -1,5 +1,5 @@
# #
# Don't edit, this file is generated by FPCMake Version 1.1 [2001/11/09] # Don't edit, this file is generated by fpcmake v1.99.0 [2001/08/15]
# #
default: all default: all
override PATH:=$(subst \,/,$(PATH)) override PATH:=$(subst \,/,$(PATH))
@ -34,7 +34,7 @@ inOS2=1
endif endif
endif endif
else else
ifneq ($(findstring cygwin,$(MACHTYPE)),) ifneq ($(findstring cygwin,$(MACH_TYPE)),)
inCygWin=1 inCygWin=1
endif endif
endif endif
@ -54,57 +54,34 @@ PATHSEP:=$(subst /,\,/)
endif endif
ifdef PWD ifdef PWD
BASEDIR:=$(subst \,/,$(shell $(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 else
BASEDIR=. BASEDIR=.
endif endif
ifndef FPC ifndef FPC
ifdef PP ifdef PP
FPC=$(PP) FPC=$(PP)
endif
endif
ifndef FPC
FPCPROG:=$(strip $(wildcard $(addsuffix /fpc$(SRCEXEEXT),$(SEARCHPATH))))
ifneq ($(FPCPROG),)
FPCPROG:=$(firstword $(FPCPROG))
FPC:=$(shell $(FPCPROG) -PB)
ifneq ($(findstring Error,$(FPC)),)
override FPC=ppc386
endif
else else
override FPC=ppc386 FPC=ppc386
endif endif
endif endif
override FPC:=$(subst $(SRCEXEEXT),,$(FPC)) override FPC:=$(subst $(SRCEXEEXT),,$(FPC))
override FPC:=$(subst \,/,$(FPC))$(SRCEXEEXT) override FPC:=$(subst \,/,$(FPC))$(SRCEXEEXT)
ifndef FPC_VERSION
FPC_VERSION:=$(shell $(FPC) -iV)
endif
export FPC FPC_VERSION
ifndef CPU_TARGET
CPU_TARGET:=$(shell $(FPC) -iTP)
endif
ifndef CPU_SOURCE
CPU_SOURCE:=$(shell $(FPC) -iSP)
endif
ifndef OS_TARGET ifndef OS_TARGET
OS_TARGET:=$(shell $(FPC) -iTO) OS_TARGET:=$(shell $(FPC) -iTO)
endif endif
ifndef OS_SOURCE ifndef OS_SOURCE
OS_SOURCE:=$(shell $(FPC) -iSO) OS_SOURCE:=$(shell $(FPC) -iSO)
endif endif
FULL_TARGET=$(CPU_TARGET)-$(OS_TARGET) ifndef CPU_TARGET
FULL_SOURCE=$(CPU_SOURCE)-$(OS_SOURCE) CPU_TARGET:=$(shell $(FPC) -iTP)
ifneq ($(FULL_TARGET),$(FULL_SOURCE))
CROSSCOMPILE=1
endif endif
export OS_TARGET OS_SOURCE CPU_TARGET CPU_SOURCE FULL_TARGET FULL_SOURCE CROSSCOMPILE ifndef CPU_SOURCE
CPU_SOURCE:=$(shell $(FPC) -iSP)
endif
ifndef FPC_VERSION
FPC_VERSION:=$(shell $(FPC) -iV)
endif
export FPC OS_TARGET OS_SOURCE CPU_TARGET CPU_SOURCE FPC_VERSION
ifdef FPCDIR ifdef FPCDIR
override FPCDIR:=$(subst \,/,$(FPCDIR)) override FPCDIR:=$(subst \,/,$(FPCDIR))
ifeq ($(wildcard $(addprefix $(FPCDIR)/,rtl units)),) ifeq ($(wildcard $(addprefix $(FPCDIR)/,rtl units)),)
@ -130,299 +107,15 @@ endif
endif endif
endif endif
endif endif
ifndef CROSSDIR
CROSSDIR:=$(FPCDIR)/cross/$(FULL_TARGET)
endif
ifndef CROSSTARGETDIR
CROSSTARGETDIR=$(CROSSDIR)/$(FULL_TARGET)
endif
ifdef CROSSCOMPILE
UNITSDIR:=$(wildcard $(CROSSTARGETDIR)/units)
ifeq ($(UNITSDIR),)
UNITSDIR:=$(wildcard $(FPCDIR)/units/$(OS_TARGET)) UNITSDIR:=$(wildcard $(FPCDIR)/units/$(OS_TARGET))
endif
else
UNITSDIR:=$(wildcard $(FPCDIR)/units/$(OS_TARGET))
endif
PACKAGESDIR:=$(wildcard $(FPCDIR) $(FPCDIR)/packages) PACKAGESDIR:=$(wildcard $(FPCDIR) $(FPCDIR)/packages)
override PACKAGE_NAME=lazarus override PACKAGE_NAME=lazarus
override PACKAGE_VERSION=0.8a override PACKAGE_VERSION=0.8a
override TARGET_UNITS+=avl_tree basiccodetools codecache codetoolmanager sourcelog customcodetool pascalparsertool finddeclarationtool stdcodetools methodjumptool eventcodetool codecompletiontool codeatom codetree definetemplates expreval keywordfunclists linkscanner sourcechanger memcheck override TARGET_UNITS+=avl_tree basiccodetools codecache codetoolmanager sourcelog customcodetool pascalparsertool finddeclarationtool stdcodetools methodjumptool eventcodetool codecompletiontool codeatom codetree definetemplates expreval keywordfunclists linkscanner sourcechanger memcheck fileprocs
override DIST_ZIPNAME=lazarus.codetools.$(ZIPSUFFIX) override DIST_ZIPNAME=lazarus.codetools.$(ZIPSUFFIX)
override COMPILER_OPTIONS+=-gl override COMPILER_OPTIONS+=-gl
override COMPILER_UNITDIR+=. $(COMPILER_UNITTARGETDIR) override COMPILER_UNITDIR+=. $(COMPILER_UNITTARGETDIR)
override COMPILER_UNITTARGETDIR+=../units override COMPILER_UNITTARGETDIR+=../units
ifdef REQUIRE_UNITSDIR
override UNITSDIR+=$(REQUIRE_UNITSDIR)
endif
ifdef REQUIRE_PACKAGESDIR
override PACKAGESDIR+=$(REQUIRE_PACKAGESDIR)
endif
ifdef ZIPINSTALL
ifeq ($(OS_TARGET),linux)
UNIXINSTALLDIR=1
endif
ifeq ($(OS_TARGET),freebsd)
UNIXINSTALLDIR=1
endif
ifeq ($(OS_TARGET),netbsd)
UNIXINSTALLDIR=1
endif
else
ifeq ($(OS_SOURCE),linux)
UNIXINSTALLDIR=1
endif
ifeq ($(OS_SOURCE),freebsd)
UNIXINSTALLDIR=1
endif
ifeq ($(OS_SOURCE),netbsd)
UNIXINSTALLDIR=1
endif
endif
ifndef INSTALL_PREFIX
ifdef UNIXINSTALLDIR
INSTALL_PREFIX=/usr/local
else
ifdef INSTALL_FPCPACKAGE
INSTALL_BASEDIR:=/pp
else
INSTALL_BASEDIR:=/$(PACKAGE_NAME)
endif
endif
endif
export INSTALL_PREFIX
ifndef DIST_DESTDIR
DIST_DESTDIR:=$(BASEDIR)
endif
export DIST_DESTDIR
ifndef INSTALL_BASEDIR
ifdef UNIXINSTALLDIR
ifdef INSTALL_FPCPACKAGE
INSTALL_BASEDIR:=$(INSTALL_PREFIX)/lib/fpc/$(FPC_VERSION)
else
INSTALL_BASEDIR:=$(INSTALL_PREFIX)/lib/$(PACKAGE_NAME)
endif
else
INSTALL_BASEDIR:=$(INSTALL_PREFIX)
endif
endif
ifndef INSTALL_BINDIR
ifdef UNIXINSTALLDIR
INSTALL_BINDIR:=$(INSTALL_PREFIX)/bin
else
INSTALL_BINDIR:=$(INSTALL_BASEDIR)/bin
ifdef INSTALL_FPCPACKAGE
INSTALL_BINDIR:=$(INSTALL_BINDIR)/$(OS_TARGET)
endif
endif
endif
ifndef INSTALL_UNITDIR
ifdef CROSSCOMPILE
INSTALL_UNITDIR:=$(INSTALL_BASEDIR)/cross/$(FULL_TARGET)/units
else
INSTALL_UNITDIR:=$(INSTALL_BASEDIR)/units/$(OS_TARGET)
endif
ifdef INSTALL_FPCPACKAGE
ifdef PACKAGE_NAME
INSTALL_UNITDIR:=$(INSTALL_UNITDIR)/$(PACKAGE_NAME)
endif
endif
endif
ifndef INSTALL_LIBDIR
ifdef UNIXINSTALLDIR
INSTALL_LIBDIR:=$(INSTALL_PREFIX)/lib
else
INSTALL_LIBDIR:=$(INSTALL_UNITDIR)
endif
endif
ifndef INSTALL_SOURCEDIR
ifdef UNIXINSTALLDIR
ifdef INSTALL_FPCPACKAGE
INSTALL_SOURCEDIR:=$(INSTALL_PREFIX)/src/fpc-$(FPC_VERSION)/$(PACKAGE_NAME)
else
INSTALL_SOURCEDIR:=$(INSTALL_PREFIX)/src/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
endif
else
ifdef INSTALL_FPCPACKAGE
INSTALL_SOURCEDIR:=$(INSTALL_BASEDIR)/source/$(PACKAGE_NAME)
else
INSTALL_SOURCEDIRL:=$(INSTALL_BASEDIR)/source
endif
endif
endif
ifndef INSTALL_DOCDIR
ifdef UNIXINSTALLDIR
ifdef INSTALL_FPCPACKAGE
INSTALL_DOCDIR:=$(INSTALL_PREFIX)/doc/fpc-$(FPC_VERSION)/$(PACKAGE_NAME)
else
INSTALL_DOCDIR:=$(INSTALL_PREFIX)/doc/$(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 UNIXINSTALLDIR
ifdef INSTALL_FPCPACKAGE
INSTALL_EXAMPLEDIR:=$(INSTALL_PREFIX)/doc/fpc-$(FPC_VERSION)/examples/$(PACKAGE_NAME)
else
INSTALL_EXAMPLEDIR:=$(INSTALL_PREFIX)/doc/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
endif
else
ifdef INSTALL_FPCPACKAGE
INSTALL_EXAMPLEDIR:=$(INSTALL_BASEDIR)/examples/$(PACKAGE_NAME)
else
INSTALL_EXAMPLEDIR:=$(INSTALL_BASEDIR)/examples
endif
endif
endif
ifndef INSTALL_DATADIR
INSTALL_DATADIR=$(INSTALL_BASEDIR)
endif
ifdef CROSSCOMPILE
ifndef CROSSBINDIR
CROSSBINDIR:=$(wildcard $(CROSSTARGETDIR)/bin/$(FULL_SOURCE))
ifeq ($(CROSSBINDIR),)
CROSSBINDIR:=$(wildcard $(INSTALL_BASEDIR)/cross/$(FULL_TARGET)/bin/$(FULL_SOURCE))
endif
endif
else
CROSSBINDIR=
endif
ifdef inUnix
ifndef GCCLIBDIR
GCCLIBDIR:=$(shell dirname `(gcc -v 2>&1)| head -n 1| awk '{ print $$4 } '`)
endif
ifeq ($(OS_TARGET),linux)
ifndef OTHERLIBDIR
OTHERLIBDIR:=$(shell grep -v "^\#" /etc/ld.so.conf | awk '{ ORS=" "; print $1 }')
endif
endif
ifeq ($(OS_TARGET),netbsd)
OTHERLIBDIR+=/usr/pkg/lib
endif
export GCCLIBDIR OTHERLIB
endif
LOADEREXT=.as
EXEEXT=.exe
PPLEXT=.ppl
PPUEXT=.ppu
OEXT=.o
ASMEXT=.s
SMARTEXT=.sl
STATICLIBEXT=.a
SHAREDLIBEXT=.so
STATICLIBPREFIX=libp
RSTEXT=.rst
FPCMADE=fpcmade
ifeq ($(OS_TARGET),go32v1)
PPUEXT=.pp1
OEXT=.o1
ASMEXT=.s1
SMARTEXT=.sl1
STATICLIBEXT=.a1
SHAREDLIBEXT=.so1
STATICLIBPREFIX=
FPCMADE=fpcmade.v1
PACKAGESUFFIX=v1
endif
ifeq ($(OS_TARGET),go32v2)
STATICLIBPREFIX=
FPCMADE=fpcmade.dos
ZIPSUFFIX=go32
endif
ifeq ($(OS_TARGET),linux)
EXEEXT=
HASSHAREDLIB=1
FPCMADE=fpcmade.lnx
ZIPSUFFIX=linux
endif
ifeq ($(OS_TARGET),freebsd)
EXEEXT=
HASSHAREDLIB=1
FPCMADE=fpcmade.freebsd
ZIPSUFFIX=freebsd
endif
ifeq ($(OS_TARGET),netbsd)
EXEEXT=
HASSHAREDLIB=1
FPCMADE=fpcmade.netbsd
ZIPSUFFIX=netbsd
endif
ifeq ($(OS_TARGET),win32)
PPUEXT=.ppw
OEXT=.ow
ASMEXT=.sw
SMARTEXT=.slw
STATICLIBEXT=.aw
SHAREDLIBEXT=.dll
FPCMADE=fpcmade.w32
ZIPSUFFIX=w32
endif
ifeq ($(OS_TARGET),os2)
PPUEXT=.ppo
ASMEXT=.so2
OEXT=.oo2
AOUTEXT=.out
SMARTEXT=.so
STATICLIBEXT=.ao2
SHAREDLIBEXT=.dll
FPCMADE=fpcmade.os2
ZIPSUFFIX=emx
endif
ifeq ($(OS_TARGET),amiga)
EXEEXT=
PPUEXT=.ppa
ASMEXT=.asm
OEXT=.o
SMARTEXT=.sl
STATICLIBEXT=.a
SHAREDLIBEXT=.library
FPCMADE=fpcmade.amg
endif
ifeq ($(OS_TARGET),atari)
PPUEXT=.ppt
ASMEXT=.s
OEXT=.o
SMARTEXT=.sl
STATICLIBEXT=.a
EXEEXT=.ttp
FPCMADE=fpcmade.ata
endif
ifeq ($(OS_TARGET),beos)
PPUEXT=.ppu
ASMEXT=.s
OEXT=.o
SMARTEXT=.sl
STATICLIBEXT=.a
EXEEXT=
FPCMADE=fpcmade.be
ZIPSUFFIX=be
endif
ifeq ($(OS_TARGET),sunos)
PPUEXT=.ppu
ASMEXT=.s
OEXT=.o
SMARTEXT=.sl
STATICLIBEXT=.a
EXEEXT=
FPCMADE=fpcmade.sun
ZIPSUFFIX=sun
endif
ifeq ($(OS_TARGET),qnx)
PPUEXT=.ppu
ASMEXT=.s
OEXT=.o
SMARTEXT=.sl
STATICLIBEXT=.a
EXEEXT=
FPCMADE=fpcmade.qnx
ZIPSUFFIX=qnx
endif
ifndef ECHO ifndef ECHO
ECHO:=$(strip $(wildcard $(addsuffix /gecho$(SRCEXEEXT),$(SEARCHPATH)))) ECHO:=$(strip $(wildcard $(addsuffix /gecho$(SRCEXEEXT),$(SEARCHPATH))))
ifeq ($(ECHO),) ifeq ($(ECHO),)
@ -564,47 +257,15 @@ TARPROG:=$(firstword $(TARPROG))
endif endif
endif endif
export TARPROG export TARPROG
ASNAME=as ifndef AS
LDNAME=ld AS=as
ARNAME=ar
RCNAME=rc
ifeq ($(OS_TARGET),win32)
ASNAME=asw
LDNAME=ldw
ARNAME=arw
endif endif
ifndef ASPROG ifndef LD
ifdef CROSSBINDIR LD=ld
ASPROG=$(CROSSBINDIR)/$(ASNAME)$(SRCEXEEXT)
else
ASPROG=$(ASNAME)
endif endif
ifndef RC
RC=rc
endif endif
ifndef LDPROG
ifdef CROSSBINDIR
LDPROG=$(CROSSBINDIR)/$(LDNAME)$(SRCEXEEXT)
else
LDPROG=$(LDNAME)
endif
endif
ifndef RCPROG
ifdef CROSSBINDIR
RCPROG=$(CROSSBINDIR)/$(RCNAME)$(SRCEXEEXT)
else
RCPROG=$(RCNAME)
endif
endif
ifndef ARPROG
ifdef CROSSBINDIR
ARPROG=$(CROSSBINDIR)/$(ARNAME)$(SRCEXEEXT)
else
ARPROG=$(ARNAME)
endif
endif
AS=$(ASPROG)
LD=$(LDPROG)
RC=$(RCPROG)
AR=$(ARPROG)
PPAS=ppas$(BATCHEXT) PPAS=ppas$(BATCHEXT)
ifdef inUnix ifdef inUnix
LDCONFIG=ldconfig LDCONFIG=ldconfig
@ -644,6 +305,197 @@ else
TAROPT=vz TAROPT=vz
TAREXT=.tar.gz TAREXT=.tar.gz
endif endif
LOADEREXT=.as
EXEEXT=.exe
PPLEXT=.ppl
PPUEXT=.ppu
OEXT=.o
ASMEXT=.s
SMARTEXT=.sl
STATICLIBEXT=.a
SHAREDLIBEXT=.so
STATICLIBPREFIX=libp
RSTEXT=.rst
FPCMADE=fpcmade
ifeq ($(OS_TARGET),go32v1)
PPUEXT=.pp1
OEXT=.o1
ASMEXT=.s1
SMARTEXT=.sl1
STATICLIBEXT=.a1
SHAREDLIBEXT=.so1
STATICLIBPREFIX=
FPCMADE=fpcmade.v1
PACKAGESUFFIX=v1
endif
ifeq ($(OS_TARGET),go32v2)
STATICLIBPREFIX=
FPCMADE=fpcmade.dos
ZIPSUFFIX=go32
endif
ifeq ($(OS_TARGET),linux)
EXEEXT=
HASSHAREDLIB=1
FPCMADE=fpcmade.lnx
ZIPSUFFIX=linux
endif
ifeq ($(OS_TARGET),freebsd)
EXEEXT=
HASSHAREDLIB=1
FPCMADE=fpcmade.freebsd
ZIPSUFFIX=freebsd
endif
ifeq ($(OS_TARGET),win32)
PPUEXT=.ppw
OEXT=.ow
ASMEXT=.sw
SMARTEXT=.slw
STATICLIBEXT=.aw
SHAREDLIBEXT=.dll
FPCMADE=fpcmade.w32
ZIPSUFFIX=w32
endif
ifeq ($(OS_TARGET),os2)
PPUEXT=.ppo
ASMEXT=.so2
OEXT=.oo2
AOUTEXT=.out
SMARTEXT=.so
STATICLIBEXT=.ao2
SHAREDLIBEXT=.dll
FPCMADE=fpcmade.os2
ZIPSUFFIX=emx
endif
ifdef REQUIRE_UNITSDIR
override UNITSDIR+=$(REQUIRE_UNITSDIR)
endif
ifdef REQUIRE_PACKAGESDIR
override PACKAGESDIR+=$(REQUIRE_PACKAGESDIR)
endif
ifdef ZIPINSTALL
ifeq ($(OS_TARGET),linux)
UNIXINSTALLDIR=1
endif
ifeq ($(OS_TARGET),freebsd)
UNIXINSTALLDIR=1
endif
else
ifeq ($(OS_SOURCE),linux)
UNIXINSTALLDIR=1
endif
ifeq ($(OS_SOURCE),freebsd)
UNIXINSTALLDIR=1
endif
endif
ifndef INSTALL_PREFIX
ifdef UNIXINSTALLDIR
INSTALL_PREFIX=/usr/local
else
ifdef INSTALL_FPCPACKAGE
INSTALL_BASEDIR:=/pp
else
INSTALL_BASEDIR:=/$(PACKAGE_NAME)
endif
endif
endif
export INSTALL_PREFIX
ifndef DIST_DESTDIR
DIST_DESTDIR:=$(BASEDIR)
endif
export DIST_DESTDIR
ifndef INSTALL_BASEDIR
ifdef UNIXINSTALLDIR
ifdef INSTALL_FPCPACKAGE
INSTALL_BASEDIR:=$(INSTALL_PREFIX)/lib/fpc/$(FPC_VERSION)
else
INSTALL_BASEDIR:=$(INSTALL_PREFIX)/lib/$(PACKAGE_NAME)
endif
else
INSTALL_BASEDIR:=$(INSTALL_PREFIX)
endif
endif
ifndef INSTALL_BINDIR
ifdef UNIXINSTALLDIR
INSTALL_BINDIR:=$(INSTALL_PREFIX)/bin
else
INSTALL_BINDIR:=$(INSTALL_BASEDIR)/bin
ifdef INSTALL_FPCPACKAGE
INSTALL_BINDIR:=$(INSTALL_BINDIR)/$(OS_TARGET)
endif
endif
endif
ifndef INSTALL_UNITDIR
INSTALL_UNITDIR:=$(INSTALL_BASEDIR)/units/$(OS_TARGET)
ifdef INSTALL_FPCPACKAGE
ifdef PACKAGE_NAME
INSTALL_UNITDIR:=$(INSTALL_UNITDIR)/$(PACKAGE_NAME)
endif
endif
endif
ifndef INSTALL_LIBDIR
ifdef UNIXINSTALLDIR
INSTALL_LIBDIR:=$(INSTALL_PREFIX)/lib
else
INSTALL_LIBDIR:=$(INSTALL_UNITDIR)
endif
endif
ifndef INSTALL_SOURCEDIR
ifdef UNIXINSTALLDIR
ifdef INSTALL_FPCPACKAGE
INSTALL_SOURCEDIR:=$(INSTALL_PREFIX)/src/fpc-$(FPC_VERSION)/$(PACKAGE_NAME)
else
INSTALL_SOURCEDIR:=$(INSTALL_PREFIX)/src/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
endif
else
ifdef INSTALL_FPCPACKAGE
INSTALL_SOURCEDIR:=$(INSTALL_BASEDIR)/source/$(PACKAGE_NAME)
else
INSTALL_SOURCEDIRL:=$(INSTALL_BASEDIR)/source
endif
endif
endif
ifndef INSTALL_DOCDIR
ifdef UNIXINSTALLDIR
ifdef INSTALL_FPCPACKAGE
INSTALL_DOCDIR:=$(INSTALL_PREFIX)/doc/fpc-$(FPC_VERSION)/$(PACKAGE_NAME)
else
INSTALL_DOCDIR:=$(INSTALL_PREFIX)/doc/$(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 UNIXINSTALLDIR
ifdef INSTALL_FPCPACKAGE
INSTALL_EXAMPLEDIR:=$(INSTALL_PREFIX)/doc/fpc-$(FPC_VERSION)/examples/$(PACKAGE_NAME)
else
INSTALL_EXAMPLEDIR:=$(INSTALL_PREFIX)/doc/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
endif
else
ifdef INSTALL_FPCPACKAGE
INSTALL_EXAMPLEDIR:=$(INSTALL_BASEDIR)/examples/$(PACKAGE_NAME)
else
INSTALL_EXAMPLEDIR:=$(INSTALL_BASEDIR)/examples
endif
endif
endif
ifndef INSTALL_DATADIR
INSTALL_DATADIR=$(INSTALL_BASEDIR)
endif
ifdef inUnix
ifndef GCCLIBDIR
GCCLIBDIR:=$(shell dirname `(gcc -v 2>&1)| head -n 1| awk '{ print $$4 } '`)
endif
ifndef OTHERLIBDIR
OTHERLIBDIR:=$(shell grep -v "^\#" /etc/ld.so.conf | awk '{ ORS=" "; print $1 }')
endif
export GCCLIBDIR OTHERLIB
endif
ifeq ($(OS_TARGET),linux) ifeq ($(OS_TARGET),linux)
REQUIRE_PACKAGES_RTL=1 REQUIRE_PACKAGES_RTL=1
REQUIRE_PACKAGES_PASZLIB=1 REQUIRE_PACKAGES_PASZLIB=1
@ -682,22 +534,6 @@ REQUIRE_PACKAGES_RTL=1
REQUIRE_PACKAGES_PASZLIB=1 REQUIRE_PACKAGES_PASZLIB=1
REQUIRE_PACKAGES_FCL=1 REQUIRE_PACKAGES_FCL=1
endif endif
ifeq ($(OS_TARGET),netbsd)
REQUIRE_PACKAGES_RTL=1
REQUIRE_PACKAGES_PASZLIB=1
REQUIRE_PACKAGES_INET=1
REQUIRE_PACKAGES_FCL=1
endif
ifeq ($(OS_TARGET),amiga)
REQUIRE_PACKAGES_RTL=1
REQUIRE_PACKAGES_PASZLIB=1
REQUIRE_PACKAGES_FCL=1
endif
ifeq ($(OS_TARGET),atari)
REQUIRE_PACKAGES_RTL=1
REQUIRE_PACKAGES_PASZLIB=1
REQUIRE_PACKAGES_FCL=1
endif
ifdef REQUIRE_PACKAGES_RTL ifdef REQUIRE_PACKAGES_RTL
PACKAGEDIR_RTL:=$(subst /Makefile.fpc,,$(strip $(wildcard $(addsuffix /rtl/Makefile.fpc,$(PACKAGESDIR))))) PACKAGEDIR_RTL:=$(subst /Makefile.fpc,,$(strip $(wildcard $(addsuffix /rtl/Makefile.fpc,$(PACKAGESDIR)))))
ifneq ($(PACKAGEDIR_RTL),) ifneq ($(PACKAGEDIR_RTL),)
@ -861,9 +697,7 @@ override COMPILER_UNITDIR+=$(UNITDIR_IBASE)
endif endif
endif endif
.PHONY: package_rtl package_paszlib package_inet package_fcl package_mysql package_ibase .PHONY: package_rtl package_paszlib package_inet package_fcl package_mysql package_ibase
ifndef NOCPUDEF
override FPCOPTDEF=$(CPU_TARGET) override FPCOPTDEF=$(CPU_TARGET)
endif
ifneq ($(OS_TARGET),$(OS_SOURCE)) ifneq ($(OS_TARGET),$(OS_SOURCE))
override FPCOPT+=-T$(OS_TARGET) override FPCOPT+=-T$(OS_TARGET)
endif endif
@ -890,22 +724,15 @@ override FPCOPT+=-gl
override FPCOPTDEF+=DEBUG override FPCOPTDEF+=DEBUG
endif endif
ifdef RELEASE ifdef RELEASE
ifeq ($(CPU_TARGET),i386) override FPCOPT+=-Xs -OG2p3 -n
FPCCPUOPT:=-OG2p3
else
FPCCPUOPT:=
endif
override FPCOPT+=-Xs $(FPCCPUOPT) -n
override FPCOPTDEF+=RELEASE override FPCOPTDEF+=RELEASE
endif endif
ifdef STRIP ifdef STRIP
override FPCOPT+=-Xs override FPCOPT+=-Xs
endif endif
ifdef OPTIMIZE ifdef OPTIMIZE
ifeq ($(CPU_TARGET),i386)
override FPCOPT+=-OG2p3 override FPCOPT+=-OG2p3
endif endif
endif
ifdef VERBOSE ifdef VERBOSE
override FPCOPT+=-vwni override FPCOPT+=-vwni
endif endif
@ -924,9 +751,6 @@ endif
ifdef COMPILER_INCLUDEDIR ifdef COMPILER_INCLUDEDIR
override FPCOPT+=$(addprefix -Fi,$(COMPILER_INCLUDEDIR)) override FPCOPT+=$(addprefix -Fi,$(COMPILER_INCLUDEDIR))
endif endif
ifdef CROSSBINDIR
override FPCOPT+=-FD$(CROSSBINDIR)
endif
ifdef COMPILER_TARGETDIR ifdef COMPILER_TARGETDIR
override FPCOPT+=-FE$(COMPILER_TARGETDIR) override FPCOPT+=-FE$(COMPILER_TARGETDIR)
ifeq ($(COMPILER_TARGETDIR),.) ifeq ($(COMPILER_TARGETDIR),.)
@ -940,7 +764,7 @@ override FPCOPT+=-FU$(COMPILER_UNITTARGETDIR)
ifeq ($(COMPILER_UNITTARGETDIR),.) ifeq ($(COMPILER_UNITTARGETDIR),.)
override UNITTARGETDIRPREFIX= override UNITTARGETDIRPREFIX=
else else
override UNITTARGETDIRPREFIX=$(COMPILER_UNITTARGETDIR)/ override UNITTARGETDIRPREFIX=$(COMPILER_TARGETDIR)/
endif endif
else else
ifdef COMPILER_TARGETDIR ifdef COMPILER_TARGETDIR
@ -1021,12 +845,11 @@ ifdef INSTALLPPUFILES
override INSTALLPPULINKFILES:=$(subst $(PPUEXT),$(OEXT),$(INSTALLPPUFILES)) $(addprefix $(STATICLIBPREFIX),$(subst $(PPUEXT),$(STATICLIBEXT),$(INSTALLPPUFILES))) override INSTALLPPULINKFILES:=$(subst $(PPUEXT),$(OEXT),$(INSTALLPPUFILES)) $(addprefix $(STATICLIBPREFIX),$(subst $(PPUEXT),$(STATICLIBEXT),$(INSTALLPPUFILES)))
override INSTALLPPUFILES:=$(addprefix $(UNITTARGETDIRPREFIX),$(INSTALLPPUFILES)) override INSTALLPPUFILES:=$(addprefix $(UNITTARGETDIRPREFIX),$(INSTALLPPUFILES))
override INSTALLPPULINKFILES:=$(wildcard $(addprefix $(UNITTARGETDIRPREFIX),$(INSTALLPPULINKFILES))) override INSTALLPPULINKFILES:=$(wildcard $(addprefix $(UNITTARGETDIRPREFIX),$(INSTALLPPULINKFILES)))
override INSTALL_CREATEPACKAGEFPC=1
endif endif
ifdef INSTALLEXEFILES ifdef INSTALLEXEFILES
override INSTALLEXEFILES:=$(addprefix $(TARGETDIRPREFIX),$(INSTALLEXEFILES)) override INSTALLEXEFILES:=$(addprefix $(TARGETDIRPREFIX),$(INSTALLEXEFILES))
endif endif
fpc_install: all $(INSTALLTARGET) fpc_install: $(INSTALLTARGET)
ifdef INSTALLEXEFILES ifdef INSTALLEXEFILES
$(MKDIR) $(INSTALL_BINDIR) $(MKDIR) $(INSTALL_BINDIR)
ifdef UPXPROG ifdef UPXPROG
@ -1034,17 +857,6 @@ ifdef UPXPROG
endif endif
$(INSTALLEXE) $(INSTALLEXEFILES) $(INSTALL_BINDIR) $(INSTALLEXE) $(INSTALLEXEFILES) $(INSTALL_BINDIR)
endif endif
ifdef INSTALL_CREATEPACKAGEFPC
ifdef FPCMAKE
ifdef PACKAGE_VERSION
ifneq ($(wildcard Makefile.fpc),)
$(FPCMAKE) -p -T$(OS_TARGET) Makefile.fpc
$(MKDIR) $(INSTALL_UNITDIR)
$(INSTALL) Package.fpc $(INSTALL_UNITDIR)
endif
endif
endif
endif
ifdef INSTALLPPUFILES ifdef INSTALLPPUFILES
$(MKDIR) $(INSTALL_UNITDIR) $(MKDIR) $(INSTALL_UNITDIR)
$(INSTALL) $(INSTALLPPUFILES) $(INSTALL_UNITDIR) $(INSTALL) $(INSTALLPPUFILES) $(INSTALL_UNITDIR)
@ -1125,7 +937,6 @@ ZIPCMD_ZIP:=$(subst /,$(ZIPPATHSEP),$(ZIPPROG)) -Dr $(ZIPOPT) $(ZIPDESTFILE) *
endif endif
fpc_zipinstall: fpc_zipinstall:
$(MAKE) $(ZIPTARGET) INSTALL_PREFIX=$(PACKDIR) ZIPINSTALL=1 $(MAKE) $(ZIPTARGET) INSTALL_PREFIX=$(PACKDIR) ZIPINSTALL=1
$(MKDIR) $(DIST_DESTDIR)
$(DEL) $(ZIPDESTFILE) $(DEL) $(ZIPDESTFILE)
ifdef USEZIPWRAPPER ifdef USEZIPWRAPPER
ifneq ($(ECHOREDIR),echo) ifneq ($(ECHOREDIR),echo)
@ -1186,7 +997,7 @@ endif
ifdef LIB_NAME ifdef LIB_NAME
-$(DEL) $(LIB_NAME) $(LIB_FULLNAME) -$(DEL) $(LIB_NAME) $(LIB_FULLNAME)
endif endif
-$(DEL) $(FPCMADE) Package.fpc $(PPAS) script.res link.res $(FPCEXTFILE) $(REDIRFILE) -$(DEL) $(FPCMADE) $(PPAS) link.res $(FPCEXTFILE) $(REDIRFILE)
fpc_distclean: clean fpc_distclean: clean
ifdef COMPILER_UNITTARGETDIR ifdef COMPILER_UNITTARGETDIR
TARGETDIRCLEAN=fpc_clean TARGETDIRCLEAN=fpc_clean
@ -1216,14 +1027,11 @@ fpc_info:
@$(ECHO) Target CPU... $(CPU_TARGET) @$(ECHO) Target CPU... $(CPU_TARGET)
@$(ECHO) Source OS.... $(OS_SOURCE) @$(ECHO) Source OS.... $(OS_SOURCE)
@$(ECHO) Target OS.... $(OS_TARGET) @$(ECHO) Target OS.... $(OS_TARGET)
@$(ECHO) Full Target.. $(FULL_SOURCE)
@$(ECHO) Full Source.. $(FULL_TARGET)
@$(ECHO) @$(ECHO)
@$(ECHO) == Directory info == @$(ECHO) == Directory info ==
@$(ECHO) @$(ECHO)
@$(ECHO) Basedir......... $(BASEDIR) @$(ECHO) Basedir......... $(BASEDIR)
@$(ECHO) FPCDir.......... $(FPCDIR) @$(ECHO) FPCDir.......... $(FPCDIR)
@$(ECHO) CrossBinDir..... $(CROSSBINDIR)
@$(ECHO) UnitsDir........ $(UNITSDIR) @$(ECHO) UnitsDir........ $(UNITSDIR)
@$(ECHO) PackagesDir..... $(PACKAGESDIR) @$(ECHO) PackagesDir..... $(PACKAGESDIR)
@$(ECHO) @$(ECHO)
@ -1232,11 +1040,7 @@ fpc_info:
@$(ECHO) @$(ECHO)
@$(ECHO) == Tools info == @$(ECHO) == Tools info ==
@$(ECHO) @$(ECHO)
@$(ECHO) As........ $(AS) @$(ECHO) Pwd....... $(PWD)
@$(ECHO) Ld........ $(LD)
@$(ECHO) Ar........ $(AR)
@$(ECHO) Rc........ $(RC)
@$(ECHO)
@$(ECHO) Mv........ $(MVPROG) @$(ECHO) Mv........ $(MVPROG)
@$(ECHO) Cp........ $(CPPROG) @$(ECHO) Cp........ $(CPPROG)
@$(ECHO) Rm........ $(RMPROG) @$(ECHO) Rm........ $(RMPROG)

View File

@ -13,7 +13,7 @@ units=avl_tree basiccodetools codecache codetoolmanager sourcelog \
customcodetool pascalparsertool finddeclarationtool stdcodetools \ customcodetool pascalparsertool finddeclarationtool stdcodetools \
methodjumptool eventcodetool codecompletiontool codeatom codetree \ methodjumptool eventcodetool codecompletiontool codeatom codetree \
definetemplates expreval keywordfunclists linkscanner sourcechanger \ definetemplates expreval keywordfunclists linkscanner sourcechanger \
memcheck memcheck fileprocs
[default] [default]

View File

@ -18,7 +18,7 @@ uses
CodeToolManager, CustomCodeTool, PascalParserTool, FindDeclarationTool, CodeToolManager, CustomCodeTool, PascalParserTool, FindDeclarationTool,
StdCodeTools, MethodJumpTool, EventCodeTool, CodeCompletionTool, LinkScanner, StdCodeTools, MethodJumpTool, EventCodeTool, CodeCompletionTool, LinkScanner,
BasicCodeTools, CodeTree, CodeAtom, SourceChanger, CodeCache, BasicCodeTools, CodeTree, CodeAtom, SourceChanger, CodeCache,
KeywordFuncLists, SourceLog, ExprEval, AVL_Tree, DefineTemplates; KeywordFuncLists, SourceLog, ExprEval, DefineTemplates, FileProcs, AVL_Tree;
implementation implementation
@ -28,6 +28,9 @@ end.
{ ============================================================================= { =============================================================================
$Log$ $Log$
Revision 1.5 2001/12/15 22:57:19 lazarus
MG: added find declaration (not useful yet)
Revision 1.4 2001/12/12 21:11:29 lazarus Revision 1.4 2001/12/12 21:11:29 lazarus
MG: started finddeclarationtool MG: started finddeclarationtool

View File

@ -140,6 +140,11 @@ type
var NewCode: TCodeBuffer; var NewCode: TCodeBuffer;
var NewX, NewY, NewTopLine: integer): boolean; var NewX, NewY, NewTopLine: integer): boolean;
// find declaration
function FindDeclaration(Code: TCodeBuffer; X,Y: integer;
var NewCode: TCodeBuffer;
var NewX, NewY, NewTopLine: integer): boolean;
// functions for events in the object inspector // functions for events in the object inspector
procedure GetCompatibleMethods(Code: TCodeBuffer; const AClassName: string; procedure GetCompatibleMethods(Code: TCodeBuffer; const AClassName: string;
TypeData: PTypeData; Proc: TGetStringProc); TypeData: PTypeData; Proc: TGetStringProc);
@ -496,7 +501,6 @@ begin
writeln('TCodeToolManager.JumpToMethod A ',Code.Filename,' x=',x,' y=',y); writeln('TCodeToolManager.JumpToMethod A ',Code.Filename,' x=',x,' y=',y);
{$ENDIF} {$ENDIF}
if not InitCodeTool(Code) then exit; if not InitCodeTool(Code) then exit;
// use MethodJumpingCodeTool
CursorPos.X:=X; CursorPos.X:=X;
CursorPos.Y:=Y; CursorPos.Y:=Y;
CursorPos.Code:=Code; CursorPos.Code:=Code;
@ -518,6 +522,39 @@ writeln('TCodeToolManager.JumpToMethod END ');
{$ENDIF} {$ENDIF}
end; end;
function TCodeToolManager.FindDeclaration(Code: TCodeBuffer; X,Y: integer;
var NewCode: TCodeBuffer;
var NewX, NewY, NewTopLine: integer): boolean;
var
CursorPos: TCodeXYPosition;
NewPos: TCodeXYPosition;
begin
Result:=false;
{$IFDEF CTDEBUG}
writeln('TCodeToolManager.FindDeclaration A ',Code.Filename,' x=',x,' y=',y);
{$ENDIF}
if not InitCodeTool(Code) then exit;
CursorPos.X:=X;
CursorPos.Y:=Y;
CursorPos.Code:=Code;
{$IFDEF CTDEBUG}
writeln('TCodeToolManager.FindDeclaration B ',FCodeTool.Scanner<>nil);
{$ENDIF}
try
Result:=FCodeTool.FindDeclaration(CursorPos,NewPos,NewTopLine);
if Result then begin
NewX:=NewPos.X;
NewY:=NewPos.Y;
NewCode:=NewPos.Code;
end;
except
on e: Exception do Result:=HandleException(e);
end;
{$IFDEF CTDEBUG}
writeln('TCodeToolManager.FindDeclaration END ');
{$ENDIF}
end;
procedure TCodeToolManager.GetCompatibleMethods(Code: TCodeBuffer; procedure TCodeToolManager.GetCompatibleMethods(Code: TCodeBuffer;
const AClassName: string; TypeData: PTypeData; Proc: TGetStringProc); const AClassName: string; TypeData: PTypeData; Proc: TGetStringProc);
begin begin

View File

@ -22,9 +22,10 @@
Abstract: Abstract:
This unit is a support unit for the code tools. It manages compilation This unit is a support unit for the code tools. It manages compilation
information which is not stored in the source, like Makefile information and information, which is not stored in the source, like Makefile information
compiler command line options. This information is needed to successfully and compiler command line options. This information is needed to
find the right units, include files, predefined variables, etc.. successfully find the right units, include files, predefined variables,
etc..
The information is stored in a TDefineTree, which contains nodes of type The information is stored in a TDefineTree, which contains nodes of type
TDefineTemplate. Each TDefineTemplate is a tree of defines, undefines, TDefineTemplate. Each TDefineTemplate is a tree of defines, undefines,

View File

@ -41,9 +41,10 @@ uses
{$ENDIF} {$ENDIF}
Classes, SysUtils, CodeTree, CodeAtom, CustomCodeTool, SourceLog, Classes, SysUtils, CodeTree, CodeAtom, CustomCodeTool, SourceLog,
KeywordFuncLists, BasicCodeTools, LinkScanner, CodeCache, AVL_Tree, TypInfo, KeywordFuncLists, BasicCodeTools, LinkScanner, CodeCache, AVL_Tree, TypInfo,
PascalParserTool; PascalParserTool, FileProcs, DefineTemplates;
type type
// searchpath delimiter is semicolon
TOnGetSearchPath = function(Sender: TObject): string; TOnGetSearchPath = function(Sender: TObject): string;
TFindDeclarationTool = class(TPascalParserTool) TFindDeclarationTool = class(TPascalParserTool)
@ -55,7 +56,8 @@ type
public public
function FindDeclaration(CursorPos: TCodeXYPosition; function FindDeclaration(CursorPos: TCodeXYPosition;
var NewPos: TCodeXYPosition; var NewTopLine: integer): boolean; var NewPos: TCodeXYPosition; var NewTopLine: integer): boolean;
function FindUnit(const AnUnitName, AnUnitInFilename: string): TCodeBuffer; function FindUnitSource(const AnUnitName,
AnUnitInFilename: string): TCodeBuffer;
property OnGetUnitSourceSearchPath: TOnGetSearchPath property OnGetUnitSourceSearchPath: TOnGetSearchPath
read FOnGetUnitSourceSearchPath write FOnGetUnitSourceSearchPath; read FOnGetUnitSourceSearchPath write FOnGetUnitSourceSearchPath;
end; end;
@ -86,6 +88,9 @@ writeln('TFindDeclarationTool.FindDeclaration B');
r:=CaretToCleanPos(CursorPos, CleanCursorPos); r:=CaretToCleanPos(CursorPos, CleanCursorPos);
if (r<>0) and (r<>-1) then if (r<>0) and (r<>-1) then
RaiseException('Cursor outside of code'); RaiseException('Cursor outside of code');
{$IFDEF CTDEBUG}
writeln('TFindDeclarationTool.FindDeclaration C CleanCursorPos=',CleanCursorPos);
{$ENDIF}
// find CodeTreeNode at cursor // find CodeTreeNode at cursor
CursorNode:=FindDeepestNodeAtPos(CleanCursorPos); CursorNode:=FindDeepestNodeAtPos(CleanCursorPos);
if CursorNode=nil then if CursorNode=nil then
@ -110,6 +115,9 @@ writeln('TFindDeclarationTool.FindDeclarationInUsesSection A');
{$ENDIF} {$ENDIF}
// reparse uses section // reparse uses section
MoveCursorToNodeStart(UsesNode); MoveCursorToNodeStart(UsesNode);
ReadNextAtom;
if not UpAtomIs('USES') then
RaiseException('syntax error: expected uses, but '+GetAtom+' found');
repeat repeat
ReadNextAtom; // read name ReadNextAtom; // read name
if CurPos.StartPos>CleanPos then break; if CurPos.StartPos>CleanPos then break;
@ -135,7 +143,7 @@ writeln('TFindDeclarationTool.FindDeclarationInUsesSection A');
UnitInFilePos.EndPos-UnitInFilePos.StartPos) UnitInFilePos.EndPos-UnitInFilePos.StartPos)
else else
UnitInFilename:=''; UnitInFilename:='';
NewPos.Code:=FindUnit(UnitName,UnitInFilename); NewPos.Code:=FindUnitSource(UnitName,UnitInFilename);
if NewPos.Code=nil then if NewPos.Code=nil then
RaiseException('unit not found: '+UnitName); RaiseException('unit not found: '+UnitName);
NewPos.X:=1; NewPos.X:=1;
@ -154,15 +162,144 @@ writeln('TFindDeclarationTool.FindDeclarationInUsesSection END cursor not on uni
{$ENDIF} {$ENDIF}
end; end;
function TFindDeclarationTool.FindUnit(const AnUnitName, function TFindDeclarationTool.FindUnitSource(const AnUnitName,
AnUnitInFilename: string): TCodeBuffer; AnUnitInFilename: string): TCodeBuffer;
function LoadFile(const ExpandedFilename: string;
var NewCode: TCodeBuffer): boolean;
begin
NewCode:=TCodeBuffer(Scanner.OnLoadSource(Self,ExpandedFilename));
Result:=NewCode<>nil;
end;
function SearchUnitFileInDir(const ADir, AnUnitName: string): TCodeBuffer;
var APath: string;
begin
APath:=ADir;
if (APath<>'') and (APath[length(APath)]<>OSDirSeparator) then
APath:=APath+OSDirSeparator;
{$IFNDEF win32}
if LoadFile(ADir+lowercase(AnUnitName)+'.pp',Result) then exit;
if LoadFile(ADir+lowercase(AnUnitName)+'.pas',Result) then exit;
{$ENDIF}
if LoadFile(ADir+AnUnitName+'.pp',Result) then exit;
if LoadFile(ADir+AnUnitName+'.pas',Result) then exit;
Result:=nil;
end;
function SearchUnitFileInPath(const APath, TheUnitName: string): TCodeBuffer;
var PathStart, PathEnd: integer;
begin
PathStart:=1;
while PathStart<=length(APath) do begin
PathEnd:=PathStart;
while (PathEnd<=length(APath)) and (APath[PathEnd]<>';') do inc(PathEnd);
if PathEnd>PathStart then begin
Result:=SearchUnitFileInDir(copy(APath,PathStart,PathEnd-PathStart),
TheUnitName);
if Result<>nil then exit;
end;
PathStart:=PathEnd+1;
end;
Result:=nil;
end;
function SearchFileInPath(const APath, RelativeFilename: string): TCodeBuffer;
var PathStart, PathEnd: integer;
ADir: string;
begin
PathStart:=1;
while PathStart<=length(APath) do begin
PathEnd:=PathStart;
while (PathEnd<=length(APath)) and (APath[PathEnd]<>';') do inc(PathEnd);
if PathEnd>PathStart then begin
ADir:=copy(APath,PathStart,PathEnd-PathStart);
if (ADir<>'') and (ADir[length(ADir)]<>OSDirSeparator) then
ADir:=ADir+OSDirSeparator;
if LoadFile(ADir+RelativeFilename,Result) then exit;
end;
PathStart:=PathEnd+1;
end;
Result:=nil;
end;
function SearchUnitInUnitLinks(const TheUnitName: string): TCodeBuffer;
var UnitLinks, CurFilename: string;
UnitLinkStart, UnitLinkEnd: integer;
begin
Result:=nil;
UnitLinks:=Scanner.Values['$('+ExternalMacroStart+'UnitLinks)'];
UnitLinkStart:=1;
while UnitLinkStart<=length(UnitLinks) do begin
UnitLinkEnd:=UnitLinkStart;
while (UnitLinkEnd<=length(UnitLinks)) and (UnitLinks[UnitLinkEnd]<>' ')
do
inc(UnitLinkEnd);
if UnitLinkEnd>UnitLinkStart then begin
if AnsiCompareText(TheUnitName,
copy(UnitLinks,UnitLinkStart,UnitLinkEnd-UnitLinkStart))=0
then begin
// unit found -> parse filename
UnitLinkStart:=UnitLinkEnd+1;
UnitLinkEnd:=UnitLinkStart;
while (UnitLinkEnd<=length(UnitLinks))
and (UnitLinks[UnitLinkEnd]<>#13) do
inc(UnitLinkEnd);
if UnitLinkEnd>UnitLinkStart then begin
CurFilename:=copy(UnitLinks,UnitLinkStart,UnitLinkEnd-UnitLinkStart);
LoadFile(CurFilename,Result);
exit;
end;
end;
end else
break;
UnitLinkStart:=UnitLinkEnd+1;
end;
end;
var CurDir, UnitSrcSearchPath: string;
MainCodeIsVirtual: boolean;
begin begin
{$IFDEF CTDEBUG} {$IFDEF CTDEBUG}
writeln('TFindDeclarationTool.FindUnit A AnUnitName=',AnUnitName,' AnUnitInFilename=',AnUnitInFilename); writeln('TFindDeclarationTool.FindUnit A AnUnitName=',AnUnitName,' AnUnitInFilename=',AnUnitInFilename);
{$ENDIF} {$ENDIF}
Result:=nil; Result:=nil;
if (AnUnitName='') or (Scanner=nil) or (Scanner.MainCode=nil)
or (not (TObject(Scanner.MainCode) is TCodeBuffer))
or (Scanner.OnLoadSource=nil) then
exit;
if Assigned(OnGetUnitSourceSearchPath) then
UnitSrcSearchPath:=OnGetUnitSourceSearchPath(Self)
else
UnitSrcSearchPath:=Scanner.Values['$('+ExternalMacroStart+'SrcPath)'];
if AnUnitInFilename<>'' then begin
// unitname in 'filename'
if FilenameIsAbsolute(AnUnitInFilename) then begin
Result:=TCodeBuffer(Scanner.OnLoadSource(Self,AnUnitInFilename));
end else begin
// search AnUnitInFilename in searchpath
Result:=SearchFileInPath(UnitSrcSearchPath,AnUnitInFilename);
end;
end else begin
// normal unit name -> search as the compiler would search
// first search in current directory (= where the maincode is)
MainCodeIsVirtual:=TCodeBuffer(Scanner.MainCode).IsVirtual;
if not MainCodeIsVirtual then begin
CurDir:=ExtractFilePath(TCodeBuffer(Scanner.MainCode).Filename);
end else begin
CurDir:='';
end;
Result:=SearchUnitFileInDir(CurDir,AnUnitName);
if Result=nil then begin
// search in search path
Result:=SearchUnitFileInPath(UnitSrcSearchPath,AnUnitName);
if Result=nil then begin
// search in FPC source directory
Result:=SearchUnitInUnitLinks(AnUnitName);
end;
end;
end;
end; end;
end. end.