Use $(dir ) in Makefile when possible

Thanks @twpayne!