* Added the ability to add fpmake as a target in a Makefile.fpc file. This way

there is no special need anymore for complete scripts in the Makefile.fpc
   to call fpmake. And it is now possible to combine other targets with a
   fpmake-target.

git-svn-id: trunk@31240 -
This commit is contained in:
joost 2015-07-28 09:52:19 +00:00
parent d014572b8e
commit a67a35c498
5 changed files with 478 additions and 246 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1282,6 +1282,7 @@ endif
ifeq ($(OS_SOURCE),openbsd)
override FPCOPT+=-FD$(NEW_BINUTILS_PATH)
override FPCMAKEOPT+=-FD$(NEW_BINUTILS_PATH)
override FPMAKE_BUILD_OPT+=-FD$(NEW_BINUTILS_PATH)
endif
ifndef CROSSBOOTSTRAP
@ -1299,6 +1300,7 @@ endif
ifndef CROSSCOMPILE
ifneq ($(BINUTILSPREFIX),)
override FPCMAKEOPT+=-XP$(BINUTILSPREFIX)
override FPMAKE_BUILD_OPT+=-XP$(BINUTILSPREFIX)
endif
endif
@ -1445,6 +1447,11 @@ ifdef OPT
override FPCOPT+=$(OPT)
endif
# Override options to compile the fpmake-binary with command-line options provided in FPMAKEBUILDOPT
ifdef FPMAKEBUILDOPT
override FPMAKE_BUILD_OPT+=$(FPMAKEBUILDOPT)
endif
# Add defines from FPCOPTDEF to FPCOPT
ifdef FPCOPTDEF
override FPCOPT+=$(addprefix -d,$(FPCOPTDEF))
@ -1814,7 +1821,7 @@ fpc_sourceinstall: distclean
$(MKDIR) $(INSTALL_SOURCEDIR)
$(COPYTREE) $(BASEDIR)/* $(INSTALL_SOURCEDIR)
fpc_exampleinstall: $(addsuffix _distclean,$(TARGET_EXAMPLEDIRS))
fpc_exampleinstall: $(EXAMPLEINSTALLTARGET) $(addsuffix _distclean,$(TARGET_EXAMPLEDIRS))
ifdef HASEXAMPLES
$(MKDIR) $(INSTALL_EXAMPLEDIR)
endif
@ -2036,6 +2043,10 @@ endif
ifdef DEBUGSYMEXT
-$(DEL) *$(DEBUGSYMEXT)
endif
ifdef LOCALFPMAKEBIN
-$(DEL) $(LOCALFPMAKEBIN)
-$(DEL) $(FPMAKEBINOBJ)
endif
fpc_distclean: cleanall
@ -2262,3 +2273,91 @@ lclinfo:
@$(ECHO) LCL Unit dir......... $(LCLUNITDIR)
@$(ECHO) LCL Component dir.... $(LCLCOMPONENTDIR)
@$(ECHO)
[fpmakeprerules]
#####################################################################
# fpmake prerules
#####################################################################
FPMAKEBIN=fpmake$(SRCEXEEXT)
FPMAKEBINOBJ=fpmake$(OEXT)
LOCALFPMAKEBIN=.$(PATHSEP)$(FPMAKEBIN)
# Convert the OS_TARGET and CPU_TARGET options to fpmake's --os and --cpu parameters
ifdef OS_TARGET
FPC_TARGETOPT+=--os=$(OS_TARGET)
endif
ifdef CPU_TARGET
FPC_TARGETOPT+=--cpu=$(CPU_TARGET)
endif
# Get the location of the bootstrap-fpmkunit units
PACKAGEDIR_FPMKUNIT:=$(firstword $(subst /Makefile.fpc,,$(strip $(wildcard $(addsuffix /fpmkunit/Makefile.fpc,$(PACKAGESDIR))))))
ifneq ($(PACKAGEDIR_FPMKUNIT),)
UNITDIR_FPMAKE_FPMKUNIT=$(PACKAGEDIR_FPMKUNIT)/units_bs/$(SOURCESUFFIX)
override COMPILER_FPMAKE_UNITDIR=$(UNITDIR_FPMAKE_FPMKUNIT)
FPMKUNIT_SRC=$(PACKAGEDIR_FPMKUNIT)/src/fpmkunit.pp
FPMKUNIT_PPU=$(UNITDIR_FPMAKE_FPMKUNIT)/fpmkunit.ppu
endif
ifdef FPMAKE_SKIP_CONFIG
override FPMAKE_BUILD_OPT+=$(FPMAKE_SKIP_CONFIG)
endif
[fpmakerules]
#####################################################################
# fpmake rules
#####################################################################
.PHONY: fpc_fpmake fpc_fpmake_clean fpc_fpmake_install fpc_fpmake_exampleinstall
# Do not pass the Makefile's unit and binary target locations. fpmake uses it's own.
override FPCOPT:=$(filter-out -FU%,$(FPCOPT))
override FPCOPT:=$(filter-out -FE%,$(FPCOPT))
# Compose general fpmake-parameters
ifdef FPMAKEOPT
FPMAKE_OPT+=$(FPMAKEOPT)
endif
FPMAKE_OPT+=--localunitdir=$(FPCDIR)
FPMAKE_OPT+=--globalunitdir=$(FPCDIR)/packages
FPMAKE_OPT+=$(FPC_TARGETOPT)
FPMAKE_OPT+=$(addprefix -o ,$(FPCOPT))
FPMAKE_OPT+=--compiler=$(FPC)
FPMAKE_OPT+=-bu
FPMAKE_INSTALL_OPT+=--unitinstalldir=$(INSTALL_UNITDIR)
ifdef UNIXHier
FPMAKE_INSTALL_OPT+=--prefix=$(INSTALL_PREFIX)
FPMAKE_INSTALL_OPT+=--baseinstalldir=$(INSTALL_LIBDIR)/fpc/$(FPC_VERSION)
else
FPMAKE_INSTALL_OPT+=--prefix=$(INSTALL_BASEDIR)
endif
override ALLTARGET+=fpc_fpmake
override INSTALLTARGET+=fpc_fpmake_install
override EXAMPLEINSTALLTARGET+=fpc_fpmake_exampleinstall
# If no fpmake exists and (dist)clean is called, do not try to build fpmake, it will
# most often fail because the dependencies are cleared.
# In case of a clean, simply do nothing
ifneq ($(wildcard $(LOCALFPMAKEBIN)),)
override CLEANTARGET+=fpc_fpmake_clean
endif
$(FPMKUNIT_PPU): $(FPMKUNIT_SRC)
$(MAKE) -C $(PACKAGEDIR_FPMKUNIT) bootstrap $(addprefix OPT=,$(FPMAKE_BUILD_OPT))
$(FPMAKEBIN): fpmake.pp $(FPMKUNIT_PPU)
$(FPCFPMAKE) fpmake.pp $(addprefix -Fu,$(COMPILER_FPMAKE_UNITDIR)) $(FPMAKE_BUILD_OPT)
fpc_fpmake: $(FPMAKEBIN)
$(LOCALFPMAKEBIN) compile $(FPMAKE_OPT)
fpc_fpmake_clean: $(FPMAKEBIN)
$(LOCALFPMAKEBIN) clean $(FPMAKE_OPT)
fpc_fpmake_install: $(FPMAKEBIN)
$(LOCALFPMAKEBIN) install $(FPMAKE_OPT) $(FPMAKE_INSTALL_OPT)
# This is not completely valid. Exampleinstall should only install the examples, while
# fpmake -ie installs everything, including the examples. This also means that on
# a distinstall fpmake install wil be called twice.
fpc_fpmake_exampleinstall: $(FPMAKEBIN)
$(LOCALFPMAKEBIN) install -ie $(FPMAKE_OPT) $(FPMAKE_INSTALL_OPT)

View File

@ -1130,6 +1130,9 @@ implementation
begin
ReqList:=TStringList.Create;
ReqSec:=TFPCMakeSection(FSections['require']);
{ Building fpmake itself always requires the rtl }
if HasTargetVariable('target_fpmake') then
ReqList.Add('rtl');
if assigned(ReqSec) then
AddReqSec(c,t,ReqSec);
GetTargetRequires:=ReqList;

View File

@ -25,7 +25,8 @@ interface
sec_units,sec_exes,sec_loaders,sec_examples,sec_rsts,
sec_compile,sec_install,
sec_distinstall,sec_zipinstall,sec_clean,sec_shared,
sec_command,sec_exts,sec_dirs,sec_tools,sec_info,sec_makefile
sec_command,sec_exts,sec_dirs,sec_tools,sec_info,sec_makefile,
sec_fpmake
);
trules=(
@ -63,6 +64,9 @@ interface
type
{ TMakefileWriter }
TMakefileWriter=class
private
FFileName : string;
@ -693,9 +697,14 @@ implementation
inc(SkippedSecs);
FHasSection[sec_loaders]:=false;
end;
{ if all 4 sections are not available we can skip also the
if (not FInput.HasTargetVariable('target_fpmake')) then
begin
inc(SkippedSecs);
FHasSection[sec_fpmake]:=false;
end;
{ if all 5 sections are not available we can skip also the
generic compile rules }
if SkippedSecs=4 then
if SkippedSecs=5 then
begin
FHasSection[sec_shared]:=false;
FHasSection[sec_compile]:=false;
@ -769,6 +778,8 @@ implementation
{ prerules section }
if assigned(FInput['prerules']) then
AddStrings(TFPCMakeSection(FInput['prerules']).List);
if FHasSection[sec_fpmake] then
AddIniSection('fpmakeprerules');
{ Default }
AddVariable('default_dir');
{ Targets }
@ -780,6 +791,7 @@ implementation
AddTargetVariable('target_rsts');
AddTargetVariable('target_examples');
AddTargetVariable('target_exampledirs');
AddTargetVariable('target_fpmake');
{ Clean }
AddTargetVariable('clean_units');
AddTargetVariable('clean_files');
@ -830,6 +842,8 @@ implementation
AddIniSection('command_libc');
AddIniSection('command_end');
{ compile }
if FHasSection[sec_fpmake] then
AddIniSection('fpmakerules');
if FHasSection[sec_loaders] then
AddIniSection('loaderrules');
if FHasSection[sec_units] then

View File

@ -1 +1 @@
'2015-05-20 rev 30890'
'2015-06-28 rev 31167'