So let's try this with your make rule. The lines starting with a "+" character are the actual commands being executed by the shell:
% make SHELL='sh -x' test3.abc echo '#!/bin/bash' > test3.abc + echo '#!/bin/bash' echo "echo test3.abc $# ' [' $@ ']'>> test3.log" >> test3.abc + echo 'echo test3.abc 0 '\'' ['\'' '\'']'\''>> test3.log' echo "echo I am a test script >> test3.log" >> test3.abc + echo 'echo I am a test script >> test3.log' (to get snarky) I saw the problem before. The issue is that the $#/$@ expands inside make (when test.abc: is executed and not in the shell script. I can do this if I put the script into the appropriate directory and take creation out of Makefile.am. I know this. I just wish there was another way.