]> git.lyx.org Git - lyx.git/blob - src/support/Package.cpp
Add -roundtrip argument to tex2lyx for tex->lyx->tex roundtrip testing.
[lyx.git] / src / support / Package.cpp
1 // -*- C++ -*-
2 /**
3  * \file package.cpp
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Angus Leeming
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #include <config.h>
13
14 #include "support/Package.h"
15
16 #include "support/debug.h"
17 #include "support/environment.h"
18 #include "support/ExceptionMessage.h"
19 #include "support/filetools.h"
20 #include "support/gettext.h"
21 #include "support/lassert.h"
22 #include "support/lstrings.h"
23 #include "support/os.h"
24
25 #if defined (USE_WINDOWS_PACKAGING)
26 # include "support/os_win32.h"
27 #endif
28
29
30 #include <list>
31
32 #if !defined (USE_WINDOWS_PACKAGING) && \
33     !defined (USE_MACOSX_PACKAGING) && \
34     !defined (USE_POSIX_PACKAGING)
35 #error USE_FOO_PACKAGING must be defined for FOO = WINDOWS, MACOSX or POSIX.
36 #endif
37
38 #if defined (USE_MACOSX_PACKAGING)
39 # include <CoreServices/CoreServices.h> // FSFindFolder, FSRefMakePath
40 #endif
41
42 using namespace std;
43
44 namespace lyx {
45 namespace support {
46
47 namespace {
48
49 Package package_;
50 bool initialised_ = false;
51
52 } // namespace anon
53
54
55 void init_package(string const & command_line_arg0,
56                   string const & command_line_system_support_dir,
57                   string const & command_line_user_support_dir,
58                   exe_build_dir_to_top_build_dir top_build_dir_location)
59 {
60         package_ = Package(command_line_arg0,
61                            command_line_system_support_dir,
62                            command_line_user_support_dir,
63                            top_build_dir_location);
64         initialised_ = true;
65 }
66
67
68 Package const & package()
69 {
70         LASSERT(initialised_, /**/);
71         return package_;
72 }
73
74
75 namespace {
76
77 FileName const abs_path_from_binary_name(string const & exe);
78
79 void buildDirs(FileName const & abs_binary,
80         exe_build_dir_to_top_build_dir top_build_dir_location,
81         FileName &, FileName &);
82
83 FileName const get_document_dir(FileName const & home_dir);
84
85 FileName const get_home_dir();
86
87 FileName const get_locale_dir(FileName const & system_support_dir);
88
89 FileName const get_system_support_dir(FileName const & abs_binary,
90                                     string const & command_line_system_support_dir);
91
92 FileName const get_default_user_support_dir(FileName const & home_dir);
93
94 bool userSupportDir(FileName const & default_user_support_dir,
95                      string const & command_line_user_support_dir, FileName & result);
96
97
98 string const & with_version_suffix();
99
100 } // namespace anon
101
102
103 Package::Package(string const & command_line_arg0,
104                  string const & command_line_system_support_dir,
105                  string const & command_line_user_support_dir,
106                  exe_build_dir_to_top_build_dir top_build_dir_location)
107         : explicit_user_support_dir_(false)
108 {
109         home_dir_ = get_home_dir();
110         // Specification of temp_dir_ may be reset by LyXRC,
111         // but the default is fixed for a given OS.
112         system_temp_dir_ = FileName::tempPath();
113         temp_dir_ = system_temp_dir_;
114         document_dir_ = get_document_dir(home_dir_);
115
116         FileName const abs_binary = abs_path_from_binary_name(command_line_arg0);
117         binary_dir_ = FileName(onlyPath(abs_binary.absFileName()));
118
119         // Is LyX being run in-place from the build tree?
120         buildDirs(abs_binary, top_build_dir_location,
121                 build_support_dir_, system_support_dir_);
122
123         if (build_support_dir_.empty())
124                 system_support_dir_ =
125                         get_system_support_dir(abs_binary,
126                                                command_line_system_support_dir);
127
128         // The LyX executable is one level above binary_dir_ if we are running
129         // tex2lyx in place. Otherwise it is in binary_dir_.
130         string abs_lyx_dir;
131         if (build_support_dir_.empty() ||
132             top_build_dir_location == top_build_dir_is_one_level_up)
133                 abs_lyx_dir = binary_dir_.absFileName();
134         else {
135                 FileName fn(addPath(binary_dir_.absFileName(), "../"));
136                 abs_lyx_dir = fn.realPath();
137         }
138         // The LyX executable may have a package suffix if we are not running
139         // in place.
140         if (build_support_dir_.empty())
141                 lyx_binary_ = FileName(addName(abs_lyx_dir,
142                                                "lyx" + string(PROGRAM_SUFFIX)));
143         else
144                 lyx_binary_ = FileName(addName(abs_lyx_dir, "lyx"));
145
146         locale_dir_ = get_locale_dir(system_support_dir_);
147
148         FileName const default_user_support_dir =
149                 get_default_user_support_dir(home_dir_);
150
151         explicit_user_support_dir_ = userSupportDir(default_user_support_dir,
152                                      command_line_user_support_dir, user_support_dir_);
153
154         FileName const configure_script(addName(system_support().absFileName(), "configure.py"));
155         configure_command_ = os::python() + ' ' +
156                         quoteName(configure_script.toFilesystemEncoding(), quote_python) +
157                         with_version_suffix();
158
159         LYXERR(Debug::INIT, "<package>\n"
160                 << "\tbinary_dir " << binary_dir().absFileName() << '\n'
161                 << "\tsystem_support " << system_support().absFileName() << '\n'
162                 << "\tbuild_support " << build_support().absFileName() << '\n'
163                 << "\tuser_support " << user_support().absFileName() << '\n'
164                 << "\tlocale_dir " << locale_dir().absFileName() << '\n'
165                 << "\tdocument_dir " << document_dir().absFileName() << '\n'
166                 << "\ttemp_dir " << temp_dir().absFileName() << '\n'
167                 << "\thome_dir " << home_dir().absFileName() << '\n'
168                 << "</package>\n");
169 }
170
171
172 void Package::set_temp_dir(FileName const & temp_dir) const
173 {
174         if (temp_dir.empty())
175                 temp_dir_ = system_temp_dir_;
176         else
177                 temp_dir_ = temp_dir;
178 }
179
180
181 namespace {
182
183 // These next functions contain the stuff that is substituted at
184 // configuration-time.
185 FileName const hardcoded_localedir()
186 {
187         // FIXME UNICODE
188         // The build system needs to make sure that this is in utf8 encoding.
189         return FileName(LYX_ABS_INSTALLED_LOCALEDIR);
190 }
191
192
193 FileName const hardcoded_system_support_dir()
194 {
195         // FIXME UNICODE
196         // The build system needs to make sure that this is in utf8 encoding.
197         return FileName(LYX_ABS_INSTALLED_DATADIR);
198 }
199
200
201 string const & with_version_suffix()
202 {
203         static string const program_suffix = PROGRAM_SUFFIX;
204         static string const with_version_suffix =
205                 " --with-version-suffix=" PROGRAM_SUFFIX;
206         return program_suffix.empty() ? program_suffix : with_version_suffix;
207 }
208
209 } // namespace anon
210
211
212 FileName const & Package::top_srcdir()
213 {
214         // FIXME UNICODE
215         // The build system needs to make sure that this is in utf8 encoding.
216         static FileName const dir(LYX_ABS_TOP_SRCDIR);
217         return dir;
218 }
219
220
221 namespace {
222
223 bool check_command_line_dir(string const & dir,
224                             string const & file,
225                             string const & command_line_switch);
226
227 FileName const extract_env_var_dir(string const & env_var);
228
229 bool check_env_var_dir(FileName const & dir,
230                        string const & env_var);
231
232 bool check_env_var_dir(FileName const & dir,
233                        string const & file,
234                        string const & env_var);
235
236 string const relative_locale_dir();
237
238 string const relative_system_support_dir();
239
240
241 /**
242  * Convert \p name to internal path and strip a trailing slash, since it
243  * comes from user input (commandline or environment).
244  * \p name is encoded in utf8.
245  */
246 string const fix_dir_name(string const & name)
247 {
248         return rtrim(os::internal_path(name), "/");
249 }
250
251
252 FileName buildSupportDir(string const & binary_dir,
253                       exe_build_dir_to_top_build_dir top_build_dir_location)
254 {
255         string indirection;
256         switch (top_build_dir_location) {
257         case top_build_dir_is_one_level_up:
258                 indirection = "../lib";
259                 break;
260         case top_build_dir_is_two_levels_up:
261                 indirection = "../../lib";
262                 break;
263         }
264         return FileName(addPath(binary_dir, indirection));
265 }
266
267
268 void buildDirs(FileName const & abs_binary,
269   exe_build_dir_to_top_build_dir top_build_dir_location,
270         FileName & build_support_dir, FileName & system_support_dir)
271 {
272         string const check_text = "Checking whether LyX is run in place...";
273
274         // We're looking for "Makefile" in a directory
275         //   binary_dir/../lib
276         // We're also looking for "chkconfig.ltx" in a directory
277         //   top_srcdir()/lib
278         // If both are found, then we're running LyX in-place.
279
280         // Note that the name of the lyx binary may be a symbolic link.
281         // If that is the case, then we follow the links too.
282         FileName binary = abs_binary;
283         while (true) {
284                 // Try and find "lyxrc.defaults".
285                 string binary_dir = onlyPath(binary.absFileName());
286                 build_support_dir = buildSupportDir(binary_dir, top_build_dir_location);
287                 if (!fileSearch(build_support_dir.absFileName(), "Makefile").empty()) {
288                         // Try and find "chkconfig.ltx".
289                         system_support_dir =
290                                 FileName(addPath(Package::top_srcdir().absFileName(), "lib"));
291
292                         if (!fileSearch(system_support_dir.absFileName(), "chkconfig.ltx").empty()) {
293                                 LYXERR(Debug::INIT, check_text << " yes");
294                                 return;
295                         }
296                 }
297
298                 // Check whether binary is a symbolic link.
299                 // If so, resolve it and repeat the exercise.
300                 if (!binary.isSymLink())
301                         break;
302
303                 FileName link;
304                 if (readLink(binary, link)) {
305                         binary = link;
306                 } else {
307                         // Unable to resolve the link.
308                         break;
309                 }
310         }
311
312         LYXERR(Debug::INIT, check_text << " no");
313         system_support_dir = FileName();
314         build_support_dir = FileName();
315 }
316
317
318 // Specification of document_dir_ may be reset by LyXRC,
319 // but the default is fixed for a given OS.
320 FileName const get_document_dir(FileName const & home_dir)
321 {
322 #if defined (USE_WINDOWS_PACKAGING)
323         (void)home_dir; // Silence warning about unused variable.
324         os::GetFolderPath win32_folder_path;
325         return FileName(win32_folder_path(os::GetFolderPath::PERSONAL));
326 #else // Posix-like.
327         return home_dir;
328 #endif
329 }
330
331
332 // The specification of home_dir_ is fixed for a given OS.
333 // A typical example on Windows: "C:/Documents and Settings/USERNAME"
334 // and on a Posix-like machine: "/home/USERNAME".
335 FileName const get_home_dir()
336 {
337 #if defined (USE_WINDOWS_PACKAGING)
338         string const home_dir = getEnv("USERPROFILE");
339 #else // Posix-like.
340         string const home_dir = getEnv("HOME");
341 #endif
342
343         return FileName(fix_dir_name(home_dir));
344 }
345
346
347 // Several sources are probed to ascertain the locale directory.
348 // The only requirement is that the result is indeed a directory.
349 FileName const get_locale_dir(FileName const & system_support_dir)
350 {
351         // 1. Use the "LYX_LOCALEDIR" environment variable.
352         FileName const path_env = extract_env_var_dir("LYX_LOCALEDIR");
353         if (!path_env.empty() && check_env_var_dir(path_env, "LYX_LOCALEDIR"))
354                 return path_env;
355
356         // 2. Search for system_support_dir / <relative locale dir>
357         // The <relative locale dir> is OS-dependent. (On Unix, it will
358         // be "../locale/".)
359         FileName path(addPath(system_support_dir.absFileName(),
360                 relative_locale_dir()));
361
362         if (path.exists() && path.isDirectory())
363                 return path;
364
365         // 3. Fall back to the hard-coded LOCALEDIR.
366         path = hardcoded_localedir();
367         if (path.exists() && path.isDirectory())
368                 return path;
369
370         return FileName();
371 }
372
373
374 // Extracts the absolute path from the foo of "-sysdir foo" or "-userdir foo"
375 FileName const abs_path_from_command_line(string const & command_line)
376 {
377         if (command_line.empty())
378                 return FileName();
379
380         string const str_path = fix_dir_name(command_line);
381         return makeAbsPath(str_path);
382 }
383
384
385 // Does the grunt work for abs_path_from_binary_name()
386 FileName const get_binary_path(string const & exe)
387 {
388 #if defined (USE_WINDOWS_PACKAGING)
389         // The executable may have been invoked either with or
390         // without the .exe extension.
391         // Ensure that it is present.
392         string const as_internal_path = os::internal_path(exe);
393         string const exe_path = suffixIs(as_internal_path, ".exe") ?
394                 as_internal_path : as_internal_path + ".exe";
395 #else
396         string const exe_path = os::internal_path(exe);
397 #endif
398         if (FileName::isAbsolute(exe_path))
399                 return FileName(exe_path);
400
401         // Two possibilities present themselves.
402         // 1. The binary is relative to the CWD.
403         FileName const abs_exe_path = makeAbsPath(exe_path);
404         if (abs_exe_path.exists())
405                 return abs_exe_path;
406
407         // 2. exe must be the name of the binary only and it
408         // can be found on the PATH.
409         string const exe_name = onlyFileName(exe_path);
410         if (exe_name != exe_path)
411                 return FileName();
412
413         vector<string> const path = getEnvPath("PATH");
414         vector<string>::const_iterator it = path.begin();
415         vector<string>::const_iterator const end = path.end();
416         for (; it != end; ++it) {
417                 // This will do nothing if *it is already absolute.
418                 string const exe_dir = makeAbsPath(*it).absFileName();
419
420                 FileName const exe_path(addName(exe_dir, exe_name));
421                 if (exe_path.exists())
422                         return exe_path;
423         }
424
425         // Didn't find anything.
426         return FileName();
427 }
428
429
430 // Extracts the absolute path to the binary name received as argv[0].
431 FileName const abs_path_from_binary_name(string const & exe)
432 {
433         FileName const abs_binary = get_binary_path(exe);
434         if (abs_binary.empty()) {
435                 // FIXME UNICODE
436                 throw ExceptionMessage(ErrorException,
437                         _("LyX binary not found"),
438                         bformat(_("Unable to determine the path to the LyX binary from the command line %1$s"),
439                                 from_utf8(exe)));
440         }
441         return abs_binary;
442 }
443
444
445 // A plethora of directories is searched to ascertain the system
446 // lyxdir which is defined as the first directory to contain
447 // "chkconfig.ltx".
448 FileName const
449 get_system_support_dir(FileName const & abs_binary,
450                   string const & command_line_system_support_dir)
451 {
452         string const chkconfig_ltx = "chkconfig.ltx";
453
454         // searched_dirs is used for diagnostic purposes only in the case
455         // that "chkconfig.ltx" is not found.
456         list<FileName> searched_dirs;
457
458         // 1. Use the -sysdir command line parameter.
459         FileName path = abs_path_from_command_line(command_line_system_support_dir);
460         if (!path.empty()) {
461                 searched_dirs.push_back(path);
462                 if (check_command_line_dir(path.absFileName(), chkconfig_ltx, "-sysdir"))
463                         return path;
464         }
465
466         // 2. Use the "LYX_DIR_${major}${minor}x" environment variable.
467         path = extract_env_var_dir(LYX_DIR_VER);
468         if (!path.empty()) {
469                 searched_dirs.push_back(path);
470                 if (check_env_var_dir(path, chkconfig_ltx, LYX_DIR_VER))
471                         return path;
472         }
473
474         // 3. Search relative to the lyx binary.
475         // We're looking for "chkconfig.ltx" in a directory
476         //   OnlyPath(abs_binary) / <relative dir> / PACKAGE /
477         // PACKAGE is hardcoded in config.h. Eg "lyx" or "lyx-1.3.6cvs".
478         // <relative dir> is OS-dependent; on Unix, it will be "../share/".
479         string const relative_lyxdir = relative_system_support_dir();
480
481         // One subtlety to be aware of. The name of the lyx binary may be
482         // a symbolic link. If that is the case, then we follow the links too.
483         FileName binary = abs_binary;
484         while (true) {
485                 // Try and find "chkconfig.ltx".
486                 string const binary_dir = onlyPath(binary.absFileName());
487
488                 FileName const lyxdir(addPath(binary_dir, relative_lyxdir));
489                 searched_dirs.push_back(lyxdir);
490
491                 if (!fileSearch(lyxdir.absFileName(), chkconfig_ltx).empty()) {
492                         // Success! "chkconfig.ltx" has been found.
493                         return lyxdir;
494                 }
495
496                 // Check whether binary is a symbolic link.
497                 // If so, resolve it and repeat the exercise.
498                 if (!binary.isSymLink())
499                         break;
500
501                 FileName link;
502                 if (readLink(binary, link)) {
503                         binary = link;
504                 } else {
505                         // Unable to resolve the link.
506                         break;
507                 }
508         }
509
510         // 4. Repeat the exercise on the directory itself.
511         FileName binary_dir(onlyPath(abs_binary.absFileName()));
512         while (true) {
513                 // This time test whether the directory is a symbolic link
514                 // *before* looking for "chkconfig.ltx".
515                 // (We've looked relative to the original already.)
516                 if (!binary.isSymLink())
517                         break;
518
519                 FileName link;
520                 if (readLink(binary_dir, link)) {
521                         binary_dir = link;
522                 } else {
523                         // Unable to resolve the link.
524                         break;
525                 }
526
527                 // Try and find "chkconfig.ltx".
528                 FileName const lyxdir(addPath(binary_dir.absFileName(),
529                         relative_lyxdir));
530                 searched_dirs.push_back(lyxdir);
531
532                 if (!fileSearch(lyxdir.absFileName(), chkconfig_ltx).empty()) {
533                         // Success! "chkconfig.ltx" has been found.
534                         return lyxdir;
535                 }
536         }
537
538         // 5. In desparation, try the hard-coded system support dir.
539         path = hardcoded_system_support_dir();
540         if (!fileSearch(path.absFileName(), chkconfig_ltx).empty())
541                 return path;
542
543         // Everything has failed :-(
544         // So inform the user and exit.
545         string searched_dirs_str;
546         typedef list<FileName>::const_iterator iterator;
547         iterator const begin = searched_dirs.begin();
548         iterator const end = searched_dirs.end();
549         for (iterator it = begin; it != end; ++it) {
550                 if (it != begin)
551                         searched_dirs_str += "\n\t";
552                 searched_dirs_str += it->absFileName();
553         }
554
555         // FIXME UNICODE
556         throw ExceptionMessage(ErrorException, _("No system directory"),
557                 bformat(_("Unable to determine the system directory "
558                                 "having searched\n"
559                                 "\t%1$s\n"
560                                 "Use the '-sysdir' command line parameter or "
561                                 "set the environment variable\n%2$s "
562                                 "to the LyX system directory containing the "
563                                 "file `chkconfig.ltx'."),
564                           from_utf8(searched_dirs_str), from_ascii(LYX_DIR_VER)));
565
566         // Keep the compiler happy.
567         return FileName();
568 }
569
570
571 // Returns the absolute path to the user lyxdir, together with a flag
572 // indicating whether this directory was specified explicitly (as -userdir
573 // or through an environment variable) or whether it was deduced.
574 bool userSupportDir(FileName const & default_user_support_dir,
575         string const & command_line_user_support_dir, FileName & result)
576 {
577         // 1. Use the -userdir command line parameter.
578         result = abs_path_from_command_line(command_line_user_support_dir);
579         if (!result.empty())
580                 return true;
581
582         // 2. Use the LYX_USERDIR_${major}${minor}x environment variable.
583         result = extract_env_var_dir(LYX_USERDIR_VER);
584         if (!result.empty())
585                 return true;
586
587         // 3. Use the OS-dependent default_user_support_dir
588         result = default_user_support_dir;
589         return false;
590 }
591
592
593 // $HOME/.lyx on POSIX but on Win32 it will be something like
594 // "C:/Documents and Settings/USERNAME/Application Data/LyX"
595 FileName const get_default_user_support_dir(FileName const & home_dir)
596 {
597 #if defined (USE_WINDOWS_PACKAGING)
598         (void)home_dir; // Silence warning about unused variable.
599
600         os::GetFolderPath win32_folder_path;
601         return FileName(addPath(win32_folder_path(os::GetFolderPath::APPDATA), PACKAGE));
602
603 #elif defined (USE_MACOSX_PACKAGING)
604         (void)home_dir; // Silence warning about unused variable.
605
606         FSRef fsref;
607         OSErr const error_code =
608                 FSFindFolder(kUserDomain, kApplicationSupportFolderType,
609                              kDontCreateFolder, &fsref);
610         if (error_code != 0)
611                 return FileName();
612
613         // FSRefMakePath returns the result in utf8
614         char store[PATH_MAX + 1];
615         OSStatus const status_code =
616                 FSRefMakePath(&fsref,
617                               reinterpret_cast<UInt8*>(store), PATH_MAX);
618         if (status_code != 0)
619                 return FileName();
620
621         return FileName(addPath(reinterpret_cast<char const *>(store), PACKAGE));
622
623 #else // USE_POSIX_PACKAGING
624         return FileName(addPath(home_dir.absFileName(), string(".") + PACKAGE));
625 #endif
626 }
627
628
629 // Check that directory @c dir contains @c file.
630 // Else emit an error message about an invalid @c command_line_switch.
631 bool check_command_line_dir(string const & dir,
632                             string const & file,
633                             string const & command_line_switch)
634 {
635         FileName const abs_path = fileSearch(dir, file);
636         if (abs_path.empty()) {
637                 // FIXME UNICODE
638                 throw ExceptionMessage(ErrorException, _("File not found"), bformat(
639                         _("Invalid %1$s switch.\nDirectory %2$s does not contain %3$s."),
640                         from_utf8(command_line_switch), from_utf8(dir),
641                         from_utf8(file)));
642         }
643
644         return !abs_path.empty();
645 }
646
647
648 // The environment variable @c env_var expands to a (single) file path.
649 FileName const extract_env_var_dir(string const & env_var)
650 {
651         string const dir = fix_dir_name(getEnv(env_var));
652         return dir.empty() ? FileName() : makeAbsPath(dir);
653 }
654
655
656 // Check that directory @c dir contains @c file.
657 // Else emit a warning about an invalid @c env_var.
658 bool check_env_var_dir(FileName const & dir,
659                        string const & file,
660                        string const & env_var)
661 {
662         FileName const abs_path = fileSearch(dir.absFileName(), file);
663         if (abs_path.empty()) {
664                 // FIXME UNICODE
665                 throw ExceptionMessage(WarningException, _("File not found"), bformat(
666                         _("Invalid %1$s environment variable.\n"
667                                 "Directory %2$s does not contain %3$s."),
668                         from_utf8(env_var), from_utf8(dir.absFileName()),
669                         from_utf8(file)));
670         }
671
672         return !abs_path.empty();
673 }
674
675
676 // Check that directory @c dir is indeed a directory.
677 // Else emit a warning about an invalid @c env_var.
678 bool check_env_var_dir(FileName const & dir,
679                        string const & env_var)
680 {
681         bool const success = dir.exists() && dir.isDirectory();
682
683         if (!success) {
684                 // Put this string on a single line so that the gettext
685                 // search mechanism in po/Makefile.in.in will register
686                 // Package.cpp.in as a file containing strings that need
687                 // translation.
688                 // FIXME UNICODE
689                 docstring const fmt =
690                         _("Invalid %1$s environment variable.\n%2$s is not a directory.");
691
692                 throw ExceptionMessage(WarningException, _("Directory not found"), bformat(
693                         fmt, from_utf8(env_var), from_utf8(dir.absFileName())));
694         }
695
696         return success;
697 }
698
699
700 // The locale directory relative to the LyX system directory.
701 string const relative_locale_dir()
702 {
703 #if defined (USE_WINDOWS_PACKAGING) || defined (USE_MACOSX_PACKAGING)
704         return "locale/";
705 #else
706         return "../locale/";
707 #endif
708 }
709
710
711 // The system lyxdir is relative to the directory containing the LyX binary.
712 string const relative_system_support_dir()
713 {
714         string result;
715
716 #if defined (USE_WINDOWS_PACKAGING) || defined (USE_MACOSX_PACKAGING)
717         result = "../Resources/";
718 #else // Posix-like.
719         result = addPath("../share/", PACKAGE);
720 #endif
721
722         return result;
723 }
724
725 } // namespace anon
726
727 } // namespace support
728 } // namespace lyx