I've had an old Windows setup, where during building Android application with Android.mk
file it successfully run shell commands like
$(shell cp $(LOCAL_SRC_FILES) $(TARGET_OUT)/somefile.txt)
Unfortunately on a fresh installation of Windows 11 and Android Studio, the cp
command doesn't work. It doesn't produce any error, it doesn't abort the building process. It just silently doesn't copy the designated files to the designated locations. I tried to print the source/destination arguments of the command, and they seem correct.
Is there any other way to copy files from code of Android.mk?
GNU make doesn't use the shell you invoked it with (if it did that, everyone who used a different shell would not be able to use your makefile).
On POSIX systems like Linux and MacOS, it uses /bin/sh
. On Windows, by default (but this can be modified when GNU make is compiled) GNU make will first look for sh
on your PATH and if it's not found, it will use cmd.exe
.
GNU Make will never use Powershell on Windows (unless you specifically tell it to by setting the SHELL
makefile variable).
Unfortunately you have not provided enough information for us to help you: you need to give us the context of where the $(shell ...)
appears. Is it sitting by itself in the makefile, as you have it? I'm quite sure that's not the case. So, it must be in a recipe, and to understand the behavior we'd need to see the recipe.
The $(shell ...)
function is generally not something you want to use in a recipe. A recipe is already running in a shell so it's redundant, and it has weird behaviors that you wouldn't expect. The way $(shell ...)
works is that it runs the command and expands to the stdout. It doesn't display the stdout. Also, failures in $(shell ...)
are not considered a failure of the recipe: the exit code is ignored.