fix to use GNU Make embedded functions instead of shell code

and add some comments