Fix recursion error when build target name contain trailing slash (Close #252)