Generate tmp/main dynamically