+#ifdef WINDOWS
+ char const *delim = "/\\";
+#else
+ char delim = '/';
+#endif
+ if (!getenv("REMAKE_SOCKET"))
+ {
+ std::string path = argv0;
+
+ size_t found = path.find_last_of(delim);
+ if (found != std::string::npos)
+ {
+ path = path.substr(0, found);
+ std::cout << "Entering directory `" << path << "'" << std::endl;
+ if (chdir(path.c_str()))
+ {
+ perror("Failed to change working directory");
+ exit(EXIT_FAILURE);
+ }
+ }
+ }
+