+ // Check whether binary is a symbolic link.
+ // If so, resolve it and repeat the exercise.
+ if (!fs::symbolic_link_exists(binary))
+ break;
+
+ string link;
+ if (LyXReadLink(binary, link, true)) {
+ binary = link;
+ } else {
+ // Unable to resolve the link.
+ break;
+ }
+ }
+
+ // 4. Repeat the exercise on the directory itself.
+ string binary_dir = OnlyPath(abs_binary);
+ while (true) {
+ // This time test whether the directory is a symbolic link
+ // *before* looking for "chkconfig.ltx".
+ // (We've looked relative to the original already.)
+ if (!fs::symbolic_link_exists(binary))
+ break;
+
+ string link;
+ if (LyXReadLink(binary_dir, link, true)) {
+ binary_dir = link;
+ } else {
+ // Unable to resolve the link.
+ break;
+ }
+
+ // Try and find "chkconfig.ltx".
+ string const lyxdir =
+ NormalizePath(AddPath(binary_dir, relative_lyxdir));
+ searched_dirs.push_back(lyxdir);
+
+ if (!FileSearch(lyxdir, chkconfig_ltx).empty()) {
+ // Success! "chkconfig.ltx" has been found.
+ return lyxdir;
+ }