MEGA2560 Bootloader compile problems

I am trying to compile a bootloader for a custom board. I need to move the LED from D13 to D37. This is the only change. I am trying to compile the bootloader found in the Arduino directory at:
C:\Engineering\Arduino\hardware\arduino\avr\bootloaders\stk500v2
I copied over the Make.exe from the latest AVR Studio into the BL directory.

When executing Make atmega2560, I get the following errors:

C:\Engineering\Arduino\hardware\arduino\avr\bootloaders\stk500v2>make mega2560
The system cannot find the path specified.
ECHO is off.
-------- begin --------
avr-gcc (GCC) 5.4.0
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

-f was unexpected at this time.
Makefile:428: recipe for target 'sizebefore' failed
make: *** [sizebefore] Error 255

It says it can’t find a path. I don’t know what path it is looking for.

The section in the makefile which does the heavy lifting is:
############################################################

Jul 6, 2010 Adding 2560 support

mega2560: MCU = atmega2560
mega2560: F_CPU = 16000000
mega2560: BOOTLOADER_ADDRESS = 3E000
mega2560: CFLAGS += -D_MEGA_BOARD_
mega2560: begin gccversion sizebefore build sizeafter end
mv $(TARGET).hex stk500boot_v2_mega2560.hex

If I remove the sizebefore and sizeafter and run make, I get this error:

C:\Engineering\Arduino\hardware\arduino\avr\bootloaders\stk500v2>make mega2560
The system cannot find the path specified.
ECHO is off.
-------- begin --------
avr-gcc (GCC) 5.4.0
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

ECHO is off.
Compiling: stk500boot.c
avr-gcc -c -mmcu=atmega2560 -I. -gdwarf-2 -DF_CPU=16000000UL -Os -funsigned-cha
r -funsigned-bitfields -fpack-struct -fshort-enums -fno-jump-tables -Wall -Wstri
ct-prototypes -Wa,-adhlns=stk500boot.lst -std=gnu99 -D_MEGA_BOARD_ -MD -MP -MF
.dep/stk500boot.o.d stk500boot.c -o stk500boot.o
stk500boot.c:2119:1: fatal error: opening dependency file .dep/stk500boot.o.d: N
o such file or directory
}
^
compilation terminated.
Makefile:539: recipe for target ‘stk500boot.o’ failed
make: *** [stk500boot.o] Error 1

This is the stock source code, unmodified.

So, I either need to find out why I can’t compile, or have some kind person compile it with the LED changes and send it to me.

My advice is to put your efforts towards modifying and compiling the optiboot bootloader. Optiboot now supports the ATmega2560. Unlike the stk500v2 bootloader, optiboot is fairly actively developed and maintained so I think you'll have a much better chance of getting it to compile without heroic measures:

In addition, optiboot fits in the minimum 1 kB boot section of the ATmega2560. Compare that to the massive stk500v2 bootloader that requires the maximum 8 kB. This means you free up 7 kB of flash memory on your ATmega2560 just by switching to Optiboot.

The popular MegaCore uses optiboot bootloaders for the ATmega2560. You might find the files contained in the MegaCore repository or the authors optiboot repository to be useful:

I was able to compile it without issue on linux. I was not able to make it compile on windows.

This was a while ago - I forget whether I had to use 1.0.6 or could use a modern version of the IDE on linux, or whether I only had to go back to 1.0.6 for compiling optiboot on windows (which does work).

(as an irrelevant aside - you can make the mega2560 bootloader compile to a much smaller size by removing the "monitor" feature which nobody uses - I once did that, and then into the extra space after it, fit a second bootloader (chipboot) behind it, and modified the mega2560 bootloader to jump to that if the reset was caused by the WDT, so from within the code, they could reset into the other bootloader, which ran on a different serial port with a different protocol. That was fun).