I appear to have fixed the problem, though I don't entirely understand why the solution worked. What I did was create a new folder, cut the bmx file that wouldn't compile into it, then renamed the folder to the relevant module name. I did this using the Ubuntu file manager and it now compiles my modules quite happily.
As I said, I don't know why this worked - the folder has exactly the same owner and permissions that I just set on the other one (and I have no doubt I did that correctly). All I can imagine is perhaps there was some other difference with the folder, possibly as a result of me using samba to copy it across from my Windows computer? That doesn't explain why all the other folders were unaffected though. Anyway, thank you both as I don't think I would have stumbled upon the solution otherwise.
As I said, I don't know why this worked - the folder has exactly the same owner and permissions that I just set on the other one (and I have no doubt I did that correctly). All I can imagine is perhaps there was some other difference with the folder, possibly as a result of me using samba to copy it across from my Windows computer? That doesn't explain why all the other folders were unaffected though. Anyway, thank you both as I don't think I would have stumbled upon the solution otherwise.