Assuming that the FPC sources were available, could it build a cross compiler as needed?
MarkMLl
This would be great in principle, but requires quite a bit of work to ensure a working cross compiler with bin tools ready to use. Fpcupdeluxe already do this well, so perhaps this tool could scan for available cross compiler's and give a warning or note if it is missing.
It's easy, IMHO, to add an AVR cross compiler in an official Lazarus/FPC installation on Windows. The easiest way ( for me ) is the following which does not require to change compiler binaries, sources dir, etc in the start "Configure Lazarus IDE" popup window but it will not
use have the latest changes/fixes from main.
It's a ~10 minute work with
two 2 clones,
1 copy 2 copies, 1 build and 1 edit
process :
Lets assume that you're installed the
lazarus-2.2.2-fpc-3.2.2-win32.
(
I installed Lazarus to "G:\Programming\dimitris\tools\laz-2.2.2_fpc-3.2.2" directory, replace it with your Lazarus installation directory )
1st step, getting the sources and binariesYou need to
add use the
same version fpc sources for the AVR cross compiler as your lazarus fpc installation has. In this example you'll need the fpc sources with tag release_3_2_2 .
Open a command prompt, go to "G:\Programming\dimitris\tools\laz-2.2.2_fpc-3.2.2\fpc\3.2.2\" directory and clone the fpc release_3_2_2 tag :
[/list]
G:\Programming\dimitris\tools\laz-2.2.2_fpc-3.2.2\fpc\3.2.2>git clone --depth 1 --branch release_3_2_2 https://gitlab.com/freepascal.org/fpc/source.git release_3_2_2
Also clone the fpc binaries to get the windows avr binutils ( I choose to clone it inside the lazarus installation but you can clone it everywhere you want .) :
G:\Programming\dimitris\tools\laz-2.2.2_fpc-3.2.2\fpc\3.2.2>git clone https://gitlab.com/freepascal.org/fpc/binaries.git fpc_binaries
Copy the avr-embedded-* ( ar, as, ld, nm, objcopy, objdump, strip ) binaries from the "<WhereYouCloneTheFPCBinaries>\fpc_binaries\i386-win32\" directory to "G:\Programming\dimitris\tools\laz-2.2.2_fpc-3.2.2\fpc\3.2.2\bin\i386-win32" directory.
2nd step, build the cross compiler and supported AVR mcu's rtlGo to the "G:\Programming\dimitris\tools\laz-2.2.2_fpc-3.2.2\fpc\3.2.2\release_3_2_2\" direcvtory and build the AVR cross compiler with the following command for i.e. atmega328p the subarch is avr5 (
list of subarchitectures ) ( again this is my preferred way ) :
(
I installed Lazarus to "G:\Programming\dimitris\tools\laz-2.2.2_fpc-3.2.2" directory, replace it with your Lazarus installation directory )
G:\Programming\dimitris\tools\laz-2.2.2_fpc-3.2.2\fpc\3.2.2\bin\i386-win32\make.exe clean crossall crossinstall CPU_TARGET=avr OS_TARGET=embedded SUBARCH=avr5 INSTALL_PREFIX=G:\Programming\dimitris\tools\laz-2.2.2_fpc-3.2.2\fpc\3.2.2 CROSSOPT="-g- -O3 -CX -XX -Xs" CROSSBINDIR=G:\Programming\dimitris\tools\laz-2.2.2_fpc-3.2.2\fpc\3.2.2\bin\i386-win32 BINUTILSPREFIX=avr-embedded- STRIP=1
( Addition after Mathias post )
AFAIU, the fpc 3.2.2 AVR cross compiler doesn't support the avr1, avr2, avrtiny and avrxmega3 subarchs so build everything else using this command ( executed in the same directory as above ) :
(
I installed Lazarus to "G:\Programming\dimitris\tools\laz-2.2.2_fpc-3.2.2" directory, replace it with your Lazarus installation directory )
FOR %I IN (avr25 avr35 avr4 avr5 avr51 avr6) DO rmdir /s /q G:\Programming\dimitris\tools\laz-2.2.2_fpc-3.2.2\fpc\3.2.2\units\avr-embedded\%I & mkdir G:\Programming\dimitris\tools\laz-2.2.2_fpc-3.2.2\fpc\3.2.2\units\avr-embedded\%I & G:\Programming\dimitris\tools\laz-2.2.2_fpc-3.2.2\fpc\3.2.2\bin\i386-win32\make.exe crossall crossinstall CPU_TARGET=avr OS_TARGET=embedded SUBARCH=%I INSTALL_PREFIX=G:\Programming\dimitris\tools\laz-2.2.2_fpc-3.2.2\fpc\3.2.2 CROSSOPT="-g- -O3 -CX -XX -Xs" CROSSBINDIR=G:\Programming\dimitris\tools\laz-2.2.2_fpc-3.2.2\fpc\3.2.2\bin\i386-win32 BINUTILSPREFIX=avr-embedded- STRIP=1 & move G:\Programming\dimitris\tools\laz-2.2.2_fpc-3.2.2\fpc\3.2.2\units\avr-embedded\rtl G:\Programming\dimitris\tools\laz-2.2.2_fpc-3.2.2\fpc\3.2.2\units\avr-embedded\%I & move G:\Programming\dimitris\tools\laz-2.2.2_fpc-3.2.2\fpc\3.2.2\units\avr-embedded\rtl-extra G:\Programming\dimitris\tools\laz-2.2.2_fpc-3.2.2\fpc\3.2.2\units\avr-embedded\%I
3rd step, configure the paths( Removed after Mathias post )
(
I installed Lazarus to "G:\Programming\dimitris\tools\laz-2.2.2_fpc-3.2.2" directory, replace it with your Lazarus installation directory )
Final, edit the G:\Programming\dimitris\tools\laz-2.2.2_fpc-3.2.2\fpc\3.2.2\bin\i386-win32\fpc.cfg and change the units searchpath part from :
# searchpath for units and other system dependent things
-FuG:\Programming\dimitris\tools\laz-2.2.2_fpc-3.2.2\fpc\3.2.2/units/$fpctarget
-FuG:\Programming\dimitris\tools\laz-2.2.2_fpc-3.2.2\fpc\3.2.2/units/$fpctarget/*
-FuG:\Programming\dimitris\tools\laz-2.2.2_fpc-3.2.2\fpc\3.2.2/units/$fpctarget/rtl
to :
#ifdef embedded
-FuG:\Programming\dimitris\tools\laz-2.2.2_fpc-3.2.2\fpc\$FPCVERSION/units/$fpctarget/$fpcsubarch
-FuG:\Programming\dimitris\tools\laz-2.2.2_fpc-3.2.2\fpc\$FPCVERSION/units/$fpctarget/$fpcsubarch/*
-FuG:\Programming\dimitris\tools\laz-2.2.2_fpc-3.2.2\fpc\$FPCVERSION/units/$fpctarget/$fpcsubarch/rtl
#else
# searchpath for units and other system dependent things
-FuG:\Programming\dimitris\tools\laz-2.2.2_fpc-3.2.2\fpc\$FPCVERSION/units/$fpctarget
-FuG:\Programming\dimitris\tools\laz-2.2.2_fpc-3.2.2\fpc\$FPCVERSION/units/$fpctarget/*
-FuG:\Programming\dimitris\tools\laz-2.2.2_fpc-3.2.2\fpc\$FPCVERSION/units/$fpctarget/rtl
#endif
All and all, a 10 minute process to add an AVR cross compiler to an official Lazarus installation on Windows.
As I mentioned, a drawback of this process is that a lot of fixes, newer functionality etc, sometimes they don't go in the releases but they're remain in main.
PS: I'm leaving more advanced installation / setups ( debug units, release stripped units, build for smaller or for fastest units ) for other time or to anyone who wants to do it ......
regards,