* cross compiling support

This commit is contained in:
peter 2001-10-14 21:38:31 +00:00
parent 1cd2fed3d8
commit b5f61f6d89
4 changed files with 923 additions and 778 deletions

File diff suppressed because it is too large Load Diff

View File

@ -94,7 +94,7 @@ endif
[fpcdetect]
#####################################################################
# FPC version/target Detection
# FPC Binary and Version Detection
#####################################################################
# Compatibility with old makefiles
@ -119,6 +119,17 @@ endif
override FPC:=$(subst $(SRCEXEEXT),,$(FPC))
override FPC:=$(subst \,/,$(FPC))$(SRCEXEEXT)
# FPC version
ifndef FPC_VERSION
FPC_VERSION:=$(shell $(FPC) -iV)
endif
export FPC FPC_VERSION
#####################################################################
# FPC Target Detection
#####################################################################
# Target CPU
ifndef CPU_TARGET
CPU_TARGET:=$(shell $(FPC) -iTP)
@ -139,12 +150,15 @@ ifndef OS_SOURCE
OS_SOURCE:=$(shell $(FPC) -iSO)
endif
# FPC version
ifndef FPC_VERSION
FPC_VERSION:=$(shell $(FPC) -iV)
# Full name of the target, including CPU and OS
FULL_TARGET=$(CPU_TARGET)-$(OS_TARGET)
FULL_SOURCE=$(CPU_SOURCE)-$(OS_SOURCE)
ifneq ($(FULL_TARGET),$(FULL_SOURCE))
CROSSCOMPILE=1
endif
export FPC OS_TARGET OS_SOURCE CPU_TARGET CPU_SOURCE FPC_VERSION
export OS_TARGET OS_SOURCE CPU_TARGET CPU_SOURCE FULL_TARGET FULL_SOURCE CROSSCOMPILE
[fpcdircheckenv]
@ -183,8 +197,15 @@ endif
endif
endif
# Units dir
# Units dir, when cross compiling try first the
ifdef CROSSCOMPILE
UNITSDIR:=$(wildcard $(FPCDIR)/cross/$(FULL_TARGET)/units)
ifeq ($(UNITSDIR),)
UNITSDIR:=$(wildcard $(FPCDIR)/units/$(OS_TARGET))
endif
else
UNITSDIR:=$(wildcard $(FPCDIR)/units/$(OS_TARGET))
endif
# Packages dir
PACKAGESDIR:=$(wildcard $(FPCDIR) $(FPCDIR)/packages)
@ -251,75 +272,215 @@ endif
export ECHOREDIR COPY COPYTREE MOVE DEL DELTREE INSTALL INSTALLEXE MKDIR
[defaulttools]
[defaultdirs]
#####################################################################
# Default Tools
# Default Directories
#####################################################################
# assembler, redefine it if cross compiling
ifndef AS
AS=as
# Units dir
ifdef REQUIRE_UNITSDIR
override UNITSDIR+=$(REQUIRE_UNITSDIR)
endif
# linker, but probably not used
ifndef LD
LD=ld
# Units dir
ifdef REQUIRE_PACKAGESDIR
override PACKAGESDIR+=$(REQUIRE_PACKAGESDIR)
endif
# Resource compiler
ifndef RC
RC=rc
# Linux, netbsd 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 ZIPINSTALL
# Zipinstall
ifeq ($(OS_TARGET),linux)
UNIXINSTALLDIR=1
endif
ifeq ($(OS_TARGET),freebsd)
UNIXINSTALLDIR=1
endif
ifeq ($(OS_TARGET),netbsd)
UNIXINSTALLDIR=1
endif
else
# Normal install
ifeq ($(OS_SOURCE),linux)
UNIXINSTALLDIR=1
endif
ifeq ($(OS_SOURCE),freebsd)
UNIXINSTALLDIR=1
endif
ifeq ($(OS_SOURCE),netbsd)
UNIXINSTALLDIR=1
endif
endif
# ppas.bat / ppas.sh
PPAS=ppas$(BATCHEXT)
# set the prefix directory where to install everything
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
# ldconfig to rebuild .so cache
# Where to place the resulting zip files
ifndef DIST_DESTDIR
DIST_DESTDIR:=$(BASEDIR)
endif
export DIST_DESTDIR
#####################################################################
# Install Directories
#####################################################################
# set the base directory where to install everything
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
# set the directory where to install the binaries
ifndef INSTALL_BINDIR
ifdef UNIXINSTALLDIR
INSTALL_BINDIR:=$(INSTALL_PREFIX)/bin
else
INSTALL_BINDIR:=$(INSTALL_BASEDIR)/bin
# for FPC packages install the binaries under their os target subdir
ifdef INSTALL_FPCPACKAGE
INSTALL_BINDIR:=$(INSTALL_BINDIR)/$(OS_TARGET)
endif
endif
endif
# set the directory where to install the units.
ifndef INSTALL_UNITDIR
# If cross compiling install in the cross compile directory
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
# Where to install shared libraries
ifndef INSTALL_LIBDIR
ifdef UNIXINSTALLDIR
INSTALL_LIBDIR:=$(INSTALL_PREFIX)/lib
else
INSTALL_LIBDIR:=$(INSTALL_UNITDIR)
endif
endif
# Where the source files will be stored
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
# Where the doc files will be stored
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
# Where to install the examples, under linux we use the doc dir
# because the copytree command will create a subdir itself
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
# Where the some extra (data)files will be stored
ifndef INSTALL_DATADIR
INSTALL_DATADIR=$(INSTALL_BASEDIR)
endif
#####################################################################
# Cross compile dirs
#####################################################################
ifdef CROSSCOMPILE
# Directory where the cross compile tools are stored.
# First check if they are available in FPCDIR. If no targets/ subdir
# is found use the targets/ subdir in INSTALL_BASEDIR.
ifndef CROSSBINDIR
CROSSBINDIR:=$(wildcard $(FPCDIR)/cross/$(FULL_TARGET)/bin/$(FULL_SOURCE))
ifeq ($(CROSSBINDIR),)
CROSSBINDIR:=$(wildcard $(INSTALL_BASEDIR)/cross/$(FULL_TARGET)/bin/$(FULL_SOURCE))
endif
endif
else
CROSSBINDIR=
endif
[dirlibc]
# On linux, try to find where libgcc.a is.
ifdef inUnix
LDCONFIG=ldconfig
else
LDCONFIG=
ifndef GCCLIBDIR
GCCLIBDIR:=$(shell dirname `(gcc -v 2>&1)| head -n 1| awk '{ print $$4 } '`)
endif
ifdef DATE
DATESTR:=$(shell $(DATE) +%Y%m%d)
else
DATESTR=
endif
# 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=
ifeq ($(OS_TARGET),linux)
ifndef OTHERLIBDIR
OTHERLIBDIR:=$(shell grep -v "^\#" /etc/ld.so.conf | awk '{ ORS=" "; print $1 }')
endif
endif
export UPXPROG
# Zip options
ZIPOPT=-9
ZIPEXT=.zip
# Tar options
ifeq ($(USETAR),bz2)
TAROPT=vI
TAREXT=.tar.bz2
else
TAROPT=vz
TAREXT=.tar.gz
ifeq ($(OS_TARGET),netbsd)
OTHERLIBDIR+=/usr/pkg/lib
endif
export GCCLIBDIR OTHERLIB
endif
@ -472,193 +633,92 @@ ZIPSUFFIX=qnx
endif
[defaultdirs]
[defaulttools]
#####################################################################
# Default Directories
# Default Tools
#####################################################################
# Units dir
ifdef REQUIRE_UNITSDIR
override UNITSDIR+=$(REQUIRE_UNITSDIR)
endif
# Units dir
ifdef REQUIRE_PACKAGESDIR
override PACKAGESDIR+=$(REQUIRE_PACKAGESDIR)
endif
# Linux, netbsd 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 ZIPINSTALL
# Zipinstall
ifeq ($(OS_TARGET),linux)
UNIXINSTALLDIR=1
endif
ifeq ($(OS_TARGET),freebsd)
UNIXINSTALLDIR=1
endif
ifeq ($(OS_TARGET),netbsd)
UNIXINSTALLDIR=1
endif
# assembler, redefine it if cross compiling
ifndef ASPROG
ifdef CROSSBINDIR
ASPROG=$(CROSSBINDIR)/as$(SRCEXEEXT)
else
# Normal install
ifeq ($(OS_SOURCE),linux)
UNIXINSTALLDIR=1
endif
ifeq ($(OS_SOURCE),freebsd)
UNIXINSTALLDIR=1
endif
ifeq ($(OS_SOURCE),netbsd)
UNIXINSTALLDIR=1
ASPROG=as
endif
endif
# set the prefix directory where to install everything
ifndef INSTALL_PREFIX
ifdef UNIXINSTALLDIR
INSTALL_PREFIX=/usr/local
# linker, but probably not used
ifndef LDPROG
ifdef CROSSBINDIR
LDPROG=$(CROSSBINDIR)/ld$(SRCEXEEXT)
else
ifdef INSTALL_FPCPACKAGE
INSTALL_BASEDIR:=/pp
else
INSTALL_BASEDIR:=/$(PACKAGE_NAME)
endif
endif
endif
export INSTALL_PREFIX
# Where to place the resulting zip files
ifndef DIST_DESTDIR
DIST_DESTDIR:=$(BASEDIR)
endif
export DIST_DESTDIR
#####################################################################
# Install Directories
#####################################################################
# set the base directory where to install everything
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)
LDPROG=ld
endif
endif
# set the directory where to install the binaries
ifndef INSTALL_BINDIR
ifdef UNIXINSTALLDIR
INSTALL_BINDIR:=$(INSTALL_PREFIX)/bin
# Resource compiler
ifndef RCPROG
ifdef CROSSBINDIR
RCPROG=$(CROSSBINDIR)/rc$(SRCEXEEXT)
else
INSTALL_BINDIR:=$(INSTALL_BASEDIR)/bin
# for FPC packages install the binaries under their os target subdir
ifdef INSTALL_FPCPACKAGE
INSTALL_BINDIR:=$(INSTALL_BINDIR)/$(OS_TARGET)
endif
RCPROG=rc
endif
endif
# set the directory where to install the units.
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
# Override defaults
AS=$(ASPROG)
LD=$(LDPROG)
RC=$(RCPROG)
# Where to install shared libraries
ifndef INSTALL_LIBDIR
ifdef UNIXINSTALLDIR
INSTALL_LIBDIR:=$(INSTALL_PREFIX)/lib
else
INSTALL_LIBDIR:=$(INSTALL_UNITDIR)
endif
endif
# ppas.bat / ppas.sh
PPAS=ppas$(BATCHEXT)
# Where the source files will be stored
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
# Where the doc files will be stored
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
# Where to install the examples, under linux we use the doc dir
# because the copytree command will create a subdir itself
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
# Where the some extra (data)files will be stored
ifndef INSTALL_DATADIR
INSTALL_DATADIR=$(INSTALL_BASEDIR)
endif
[dirlibc]
# On linux, try to find where libgcc.a is.
# ldconfig to rebuild .so cache
ifdef inUnix
ifndef GCCLIBDIR
GCCLIBDIR:=$(shell dirname `(gcc -v 2>&1)| head -n 1| awk '{ print $$4 } '`)
LDCONFIG=ldconfig
else
LDCONFIG=
endif
ifeq ($(OS_TARGET),linux)
ifndef OTHERLIBDIR
OTHERLIBDIR:=$(shell grep -v "^\#" /etc/ld.so.conf | awk '{ ORS=" "; print $1 }')
ifdef DATE
DATESTR:=$(shell $(DATE) +%Y%m%d)
else
DATESTR=
endif
# 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
ifeq ($(OS_TARGET),netbsd)
OTHERLIBDIR+=/usr/pkg/lib
endif
export GCCLIBDIR OTHERLIB
export UPXPROG
# Zip options
ZIPOPT=-9
ZIPEXT=.zip
# Tar options
ifeq ($(USETAR),bz2)
TAROPT=vI
TAREXT=.tar.bz2
else
TAROPT=vz
TAREXT=.tar.gz
endif
@ -753,6 +813,11 @@ ifdef COMPILER_INCLUDEDIR
override FPCOPT+=$(addprefix -Fi,$(COMPILER_INCLUDEDIR))
endif
# Cross compiler utils
ifdef CROSSBINDIR
override FPCOPT+=-FD$(CROSSBINDIR)
endif
# Target dirs and the prefix to use for clean/install
ifdef COMPILER_TARGETDIR
override FPCOPT+=-FE$(COMPILER_TARGETDIR)
@ -1281,11 +1346,14 @@ fpc_info:
@$(ECHO) Target CPU... $(CPU_TARGET)
@$(ECHO) Source OS.... $(OS_SOURCE)
@$(ECHO) Target OS.... $(OS_TARGET)
@$(ECHO) Full Target.. $(FULL_SOURCE)
@$(ECHO) Full Source.. $(FULL_TARGET)
@$(ECHO)
@$(ECHO) == Directory info ==
@$(ECHO)
@$(ECHO) Basedir......... $(BASEDIR)
@$(ECHO) FPCDir.......... $(FPCDIR)
@$(ECHO) CrossBinDir..... $(CROSSBINDIR)
@$(ECHO) UnitsDir........ $(UNITSDIR)
@$(ECHO) PackagesDir..... $(PACKAGESDIR)
@$(ECHO)

View File

@ -524,6 +524,7 @@ implementation
CurrSec : TFPCMakeSection;
begin
try
CurrSec:=nil;
SLInput:=TStringList.Create;
if assigned(FStream) then
SLInput.LoadFromStream(FStream)
@ -543,7 +544,7 @@ implementation
begin
j:=pos(']',s);
if j=0 then
raise Exception.Create(Format(s_err_section_start,[FFileName,i]));
raise Exception.Create(Format(s_err_section_start,[FFileName,i+1]));
SecName:=Copy(s,2,j-2);
CurrSec:=TFPCMakeSection(FSections[SecName]);
if CurrSec=nil then
@ -552,7 +553,7 @@ implementation
else
begin
if CurrSec=nil then
raise Exception.Create(Format(s_err_no_section,[FFileName,i]));
raise Exception.Create(Format(s_err_no_section,[FFileName,i+1]));
{ Insert string without spaces stripped }
CurrSec.AddLine(SLInput[i]);
end;
@ -1330,7 +1331,10 @@ implementation
end.
{
$Log$
Revision 1.14 2001-09-29 19:47:50 carl
Revision 1.15 2001-10-14 21:38:32 peter
* cross compiling support
Revision 1.14 2001/09/29 19:47:50 carl
* make it work for BeOS
Revision 1.13 2001/08/22 20:45:19 peter

View File

@ -817,13 +817,13 @@ implementation
AddTargetVariable('compiler_librarydir');
AddTargetVariable('compiler_targetdir');
AddTargetVariable('compiler_unittargetdir');
{ Add default tools }
AddDefaultTools;
{ default dirs/tools/extensions }
AddIniSection('extensions');
{ default Dirs and extensions }
AddIniSection('defaultdirs');
if FInput.CheckLibcRequire then
AddIniSection('dirlibc');
AddIniSection('extensions');
{ Add default tools }
AddDefaultTools;
{ Required packages }
AddRequiredPackages;
{ commandline }
@ -879,7 +879,10 @@ implementation
end.
{
$Log$
Revision 1.17 2001-09-11 11:04:51 pierre
Revision 1.18 2001-10-14 21:38:33 peter
* cross compiling support
Revision 1.17 2001/09/11 11:04:51 pierre
* handle default cpu and target without override, use require section for override
Revision 1.16 2001/08/22 20:45:19 peter