ocaml makedirs: fix race condition
ocaml: fix for flock() being released when an unrelated FD is closed

Caused by multiple builds in the same process which refer to the same inode
python: check whether a target still needs building after acquiring its build lock