1 /* PSPPIRE - a graphical user interface for PSPP.
2 Copyright (C) 2020 Free Software Foundation
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */
19 #if !ENABLE_RELOCATABLE || !defined(__APPLE__)
22 pre_initialisation (int *argc, char **argv)
32 pre_initialisation (int *argc, char **argv)
34 /* remove MacOS session identifier from the command line args */
36 for (gint i = 0; i < *argc; i++)
38 if (!g_str_has_prefix (argv[i], "-psn_"))
40 argv[newargc] = argv[i];
46 argv[newargc] = NULL; /* glib expects NULL terminated array */
50 const char * progname = argv[0];
52 /* helper to set environment variables for pspp to be relocatable.
53 * Due to the latest changes it is not recommended to set it in the shell
56 gchar resolved_path[PATH_MAX];
57 /* on some OSX installations open file limit is 256 and GIMP needs more */
59 limit.rlim_cur = 10000;
60 limit.rlim_max = 10000;
61 setrlimit (RLIMIT_NOFILE, &limit);
62 if (realpath (progname, resolved_path))
66 gchar res_dir[PATH_MAX];
69 app_dir = g_path_get_dirname (resolved_path);
70 g_snprintf (tmp, sizeof(tmp), "%s/../../Resources", app_dir);
71 if (realpath (tmp, res_dir) && !stat (res_dir,&sb) && S_ISDIR (sb.st_mode))
72 g_print ("pspp is started as MacOS application\n");
77 g_snprintf (tmp, sizeof(tmp), "%s/lib/gtk-3.0/3.0.0", res_dir);
78 g_setenv ("GTK_PATH", tmp, TRUE);
79 g_snprintf (tmp, sizeof(tmp), "%s/etc/gtk-3.0/gtk.immodules", res_dir);
80 g_setenv ("GTK_IM_MODULE_FILE", tmp, TRUE);
81 g_snprintf (tmp, sizeof(tmp), "%s/lib/gegl-0.4", res_dir);
82 g_setenv ("GEGL_PATH", tmp, TRUE);
83 g_snprintf (tmp, sizeof(tmp), "%s/lib/babl-0.1", res_dir);
84 g_setenv ("BABL_PATH", tmp, TRUE);
85 g_snprintf (tmp, sizeof(tmp), "%s/lib/gdk-pixbuf-2.0/2.10.0/loaders.cache", res_dir);
86 g_setenv ("GDK_PIXBUF_MODULE_FILE", tmp, TRUE);
87 g_snprintf (tmp, sizeof(tmp), "%s/etc/fonts", res_dir);
88 g_setenv ("FONTCONFIG_PATH", tmp, TRUE);
89 g_snprintf (tmp, sizeof(tmp), "%s/lib/gio/modules", res_dir);
90 g_setenv ("GIO_MODULE_DIR", tmp, TRUE);
91 g_snprintf (tmp, sizeof(tmp), "%s/etc/xdg", res_dir);
92 g_setenv ("XDG_CONFIG_DIRS", tmp, TRUE);
93 g_snprintf (tmp, sizeof(tmp), "%s/share", res_dir);
94 g_setenv ("XDG_DATA_DIRS", tmp, TRUE);
96 if (g_getenv ("HOME")!=NULL)
98 g_snprintf (tmp, sizeof(tmp),
99 "%s/Library/Application Support/pspp/1.3/cache",
101 g_setenv ("XDG_CACHE_HOME", tmp, TRUE);