wouldn't `if [ "$(shell basename $(2))" =  "$(BUILD_APP_NAME)" -o "$(BUILD_APP_NAME)" = "*" ]` works?

Also, we're using only makefile variables here, maybe a ifdef could be used instead (not sure this is better, your choice)