mirror of
https://github.com/gryf/wmaker.git
synced 2025-12-19 12:28:22 +01:00
As reported in Debian bug #922284 [1]: As evident from the prefix, GNUSTEP_USER_ROOT is a GNUstep variable and Window Maker should not set it. Furthemore, it has been deprecated for 12 years already. As of gnustep-make/2.7.0-4 the GNUstep build system is configured in strict v2 mode which makes it impossible to compile GNUstep software. In a terminal started from a Window Maker session: yavor@aneto:/tmp/gorm.app-1.2.24$ make This is gnustep-make 2.7.0. Type 'make print-gnustep-make-help' for help. Running in gnustep-make version 2 strict mode. rm -f InterfaceBuilder; \ ln -s GormLib InterfaceBuilder /usr/share/GNUstep/Makefiles/config-noarch.make:121: *** GNUSTEP_USER_ROOT is obsolete. Stop. It is also impossible to build gnustep-make from pristine upstream source: yavor@aneto:/tmp$ wget -q ftp://ftp.gnustep.org/pub/gnustep/core/gnustep-make-2.7.0.tar.gz yavor@aneto:/tmp$ tar xzf gnustep-make-2.7.0.tar.gz yavor@aneto:/tmp$ cd gnustep-make-2.7.0/ yavor@aneto:/tmp/gnustep-make-2.7.0$ ./configure ... yavor@aneto:/tmp/gnustep-make-2.7.0$ make config-noarch.make:121: *** GNUSTEP_USER_ROOT is obsolete. Stop. Note that the majority of GNUstep users use Window Maker as their window manager and many of them build GNUstep software from source, mostly because of the GNUstep Objective-C runtime which depends on Clang (Debian packages use GCC and the GCC/GNU runtime). Our solution is to replace the GNUSTEP_USER_ROOT environment variable with our own environment variable, WMAKER_USER_ROOT. This is documented in NEWS. [1] https://bugs.debian.org/922284
207 lines
4.4 KiB
C
207 lines
4.4 KiB
C
|
|
#include <unistd.h>
|
|
#include <X11/Xlocale.h>
|
|
|
|
#include "WINGsP.h"
|
|
#include "wconfig.h"
|
|
#include "userdefaults.h"
|
|
|
|
|
|
struct W_Application WMApplication;
|
|
|
|
char *_WINGS_progname = NULL;
|
|
|
|
Bool W_ApplicationInitialized(void)
|
|
{
|
|
return _WINGS_progname != NULL;
|
|
}
|
|
|
|
void WMInitializeApplication(const char *applicationName, int *argc, char **argv)
|
|
{
|
|
int i;
|
|
|
|
assert(argc != NULL);
|
|
assert(argv != NULL);
|
|
assert(applicationName != NULL);
|
|
|
|
setlocale(LC_ALL, "");
|
|
|
|
#ifdef I18N
|
|
if (getenv("NLSPATH"))
|
|
bindtextdomain("WINGs", getenv("NLSPATH"));
|
|
else
|
|
bindtextdomain("WINGs", LOCALEDIR);
|
|
bind_textdomain_codeset("WINGs", "UTF-8");
|
|
#endif
|
|
|
|
_WINGS_progname = argv[0];
|
|
|
|
WMApplication.applicationName = wstrdup(applicationName);
|
|
WMApplication.argc = *argc;
|
|
|
|
WMApplication.argv = wmalloc((*argc + 1) * sizeof(char *));
|
|
for (i = 0; i < *argc; i++) {
|
|
WMApplication.argv[i] = wstrdup(argv[i]);
|
|
}
|
|
WMApplication.argv[i] = NULL;
|
|
|
|
/* initialize notification center */
|
|
W_InitNotificationCenter();
|
|
}
|
|
|
|
void WMReleaseApplication(void) {
|
|
int i;
|
|
|
|
/*
|
|
* We save the configuration on exit, this used to be handled
|
|
* through an 'atexit' registered function but if application
|
|
* properly calls WMReleaseApplication then the info to that
|
|
* will have been freed by us.
|
|
*/
|
|
w_save_defaults_changes();
|
|
|
|
W_ReleaseNotificationCenter();
|
|
|
|
if (WMApplication.applicationName) {
|
|
wfree(WMApplication.applicationName);
|
|
WMApplication.applicationName = NULL;
|
|
}
|
|
|
|
if (WMApplication.argv) {
|
|
for (i = 0; i < WMApplication.argc; i++)
|
|
wfree(WMApplication.argv[i]);
|
|
|
|
wfree(WMApplication.argv);
|
|
WMApplication.argv = NULL;
|
|
}
|
|
}
|
|
|
|
void WMSetResourcePath(const char *path)
|
|
{
|
|
if (WMApplication.resourcePath)
|
|
wfree(WMApplication.resourcePath);
|
|
WMApplication.resourcePath = wstrdup(path);
|
|
}
|
|
|
|
char *WMGetApplicationName()
|
|
{
|
|
return WMApplication.applicationName;
|
|
}
|
|
|
|
static char *checkFile(const char *path, const char *folder, const char *ext, const char *resource)
|
|
{
|
|
char *ret;
|
|
int extralen;
|
|
size_t slen;
|
|
|
|
if (!path || !resource)
|
|
return NULL;
|
|
|
|
extralen = (ext ? strlen(ext) + 1 : 0) + (folder ? strlen(folder) + 1 : 0) + 1;
|
|
slen = strlen(path) + strlen(resource) + 1 + extralen;
|
|
ret = wmalloc(slen);
|
|
|
|
if (wstrlcpy(ret, path, slen) >= slen)
|
|
goto error;
|
|
|
|
if (folder &&
|
|
(wstrlcat(ret, "/", slen) >= slen ||
|
|
wstrlcat(ret, folder, slen) >= slen))
|
|
goto error;
|
|
|
|
if (ext &&
|
|
(wstrlcat(ret, "/", slen) >= slen ||
|
|
wstrlcat(ret, ext, slen) >= slen))
|
|
goto error;
|
|
|
|
if (wstrlcat(ret, "/", slen) >= slen ||
|
|
wstrlcat(ret, resource, slen) >= slen)
|
|
goto error;
|
|
|
|
if (access(ret, F_OK) != 0)
|
|
goto error;
|
|
|
|
return ret;
|
|
|
|
error:
|
|
if (ret)
|
|
wfree(ret);
|
|
return NULL;
|
|
}
|
|
|
|
char *WMPathForResourceOfType(const char *resource, const char *ext)
|
|
{
|
|
char *path, *appdir;
|
|
size_t slen;
|
|
|
|
path = appdir = NULL;
|
|
|
|
/*
|
|
* Paths are searched in this order:
|
|
* - resourcePath/ext
|
|
* - dirname(argv[0])/ext
|
|
* - WMAKER_USER_ROOT/Applications/ApplicationName.app/ext
|
|
* - ~/GNUstep/Applications/ApplicationName.app/ext
|
|
* - GNUSTEP_LOCAL_ROOT/Applications/ApplicationName.app/ext
|
|
* - /usr/local/GNUstep/Applications/ApplicationName.app/ext
|
|
* - GNUSTEP_SYSTEM_ROOT/Applications/ApplicationName.app/ext
|
|
* - /usr/GNUstep/Applications/ApplicationName.app/ext
|
|
*/
|
|
|
|
if (WMApplication.resourcePath) {
|
|
path = checkFile(WMApplication.resourcePath, NULL, ext, resource);
|
|
if (path)
|
|
goto out;
|
|
}
|
|
|
|
if (WMApplication.argv[0]) {
|
|
char *ptr_slash;
|
|
|
|
ptr_slash = strrchr(WMApplication.argv[0], '/');
|
|
if (ptr_slash != NULL) {
|
|
char tmp[ptr_slash - WMApplication.argv[0] + 1];
|
|
|
|
strncpy(tmp, WMApplication.argv[0], sizeof(tmp)-1);
|
|
tmp[sizeof(tmp) - 1] = '\0';
|
|
|
|
path = checkFile(tmp, NULL, ext, resource);
|
|
if (path)
|
|
goto out;
|
|
}
|
|
}
|
|
|
|
slen = strlen(WMApplication.applicationName) + sizeof("Applications/.app");
|
|
appdir = wmalloc(slen);
|
|
if (snprintf(appdir, slen, "Applications/%s.app", WMApplication.applicationName) >= slen)
|
|
goto out;
|
|
|
|
path = checkFile(getenv("WMAKER_USER_ROOT"), appdir, ext, resource);
|
|
if (path)
|
|
goto out;
|
|
|
|
path = checkFile(wusergnusteppath(), appdir, ext, resource);
|
|
if (path)
|
|
goto out;
|
|
|
|
path = checkFile(getenv("GNUSTEP_LOCAL_ROOT"), appdir, ext, resource);
|
|
if (path)
|
|
goto out;
|
|
|
|
path = checkFile("/usr/local/GNUstep", appdir, ext, resource);
|
|
if (path)
|
|
goto out;
|
|
|
|
path = checkFile(getenv("GNUSTEP_SYSTEM_ROOT"), appdir, ext, resource);
|
|
if (path)
|
|
goto out;
|
|
|
|
path = checkFile("/usr/GNUstep", appdir, ext, resource); /* falls through */
|
|
|
|
out:
|
|
if (appdir)
|
|
wfree(appdir);
|
|
|
|
return path;
|
|
|
|
}
|