[fpc-devel] Adapting MakeFile to make subfolders for targets with sub architectures

Christo christo.crause at gmail.com
Sun Jul 22 10:31:12 CEST 2018


I'm trying to change the build process for target AVR so that different sub architectures end up
in different subfolders.  At the moment the default behaviour is that e.g. the RTL object files
are saved to ./rtl/units/avr-embedded, regardless of the subarch specified.  This means that if
one rebuild the RTL for AVR with a different subarch, the previous subarch unit files (system,
strings charset etc.) are overwritten.

Since I'm not familiar with makefile syntax or the general build process for FPC I would like a
review of my approach described below.

I've modified the fpcmake.ini file to take the subarch (and ABI if specified; according to
Florian's svn branch target-subdir) into account. The following two new variables are set
according to the SUBARCH and ABI (at the moment for AVR only for testing purposes):

SUBARCH_ABI_SUFFIX=
FILESUFFIX=
ifeq ($(FULL_TARGET),avr-embedded)
ifneq ($(SUBARCH),)
ifneq ($(ABI),)
SUBARCH_ABI_SUFFIX=/$(SUBARCH)/$(ABI)
FILESUFFIX=.$(SUBARCH).$(ABI)
else
SUBARCH_ABI_SUFFIX=/$(SUBARCH)
FILESUFFIX=.$(SUBARCH)
endif
endif
endif

The following variables are passed either via -Fu or -FU to compile instructions and hence where
modified:
UNITSDIR:=$(wildcard $(FPCDIR)/units/$(TARGETSUFFIX)$(SUBARCH_ABI_SUFFIX))
COMPILER_UNITTARGETDIR=$(PACKAGEDIR_MAIN)/units/$(TARGETSUFFIX)$(SUBARCH_ABI_SUFFIX)

Update install dirs:
INSTALL_BINDIR:=$(INSTALL_BINDIR)/$(TARGETSUFFIX)$(SUBARCH_ABI_SUFFIX)
INSTALL_UNITDIR:=$(INSTALL_BASEDIR)/units/$(TARGETSUFFIX)$(SUBARCH_ABI_SUFFIX)

Update file name/extension variables:
ZIPSUFFIX=.$(TARGETSUFFIX)$(FILESUFFIX)

This works if I make crossall for AVR and creates the cross compiler, builds the rtl and moves
the compiled units into the correct folder /rtl/units/avr-embedded/avrxx. There is a problem
compiling the package rtl-extra, since the makefile/fpmake system in that folder overrides the
inherited makefile variables.  For now I've disabled target embedded for that package and then
the build process for AVR completes without further issues.  

So further questions:
1. I would like to know how to tweak the makefile/fpmake settings for this package to also use
the modified subdirs as defined in the default makefile template.
2. How do I test the install and zipinstall targets, I never use them.
3. Is this more or less a feasible route to achieve this behaviour?

Regards,
Christo



More information about the fpc-devel mailing list