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