Arducopter build error

I have forked Ardupilot and followed the build instructions and is using Ubuntu 20.04 on Windows10 to build the firmware. After some problems the whole build process works OK until the final stages where I get these messages:
[654/657] Linking build/omnibusf4/bin/arducopter
[655/657] Generating bin/arducopter.bin
[656/657] Generating bin/arducopter.hex
[657/657] apj_gen build/omnibusf4/bin/arducopter.bin
/usr/bin/env: ‘python\r’: No such file or directory

Waf: Leaving directory `/mnt/d/Users/Public/Documents/Github/ardupilot/build/omnibusf4’
Build failed
-> task in ‘bin/arducopter’ failed (exit status 127):
{task 140254450530000: build_intel_hex arducopter.bin,omnibusf4_bl.bin -> arducopter.hex}
(run with -v to display more information)

I had the error !‘python\r’: No such file or directory’ also for the waf script file but there I could solve it by converting the script to a Unix file so the problem might be same but I cannot figure out how to solve it here.

Three files (arducopter, arducopter.apj and arducopter.bin) have been stored in the bin directory so it seems to be just some ending stages that fail.

Any idea how to solve this problem?

I think you may have let line-ending coversion happen when you checked
things out. Assuming my thinking is correct,
Tools/scripts/ probably has a \r\n on the first line
rather than just a \n in your checked out tree.

That was spot on. After converting the make file to Unix format it all worked fine.
I am not using Github so much that I have experienced this conversion before.
Many thanks for your help.