Makefile: more careful to remove directory write permission

Also restore write permission before re-installing.