1
0
mirror of https://github.com/gryf/wmaker.git synced 2025-12-18 12:00:31 +01:00

configure: Add option to specify global defaults directory.

Previously, this was only (partially) possible by redefining the macro
GLOBAL_DEFAULTS_SUBDIR.  This told Window Maker to look for the global
config files in a particular subdirectory of SYSCONFDIR.

However:
* This is undocumented.
* GLOBAL_DEFAULTS_SUBDIR is ignored when installing the config files.  They
  are always installed to SYSCONFDIR/WindowMaker.

To solve these issues, we add a "--with-defsdatadir" option to configure
which allows a user to specify the global defaults directory.
This commit is contained in:
Doug Torrance
2017-03-10 02:39:31 -05:00
committed by Carlos R. Mafra
parent ac92f1a844
commit 6fa1c0c009
7 changed files with 24 additions and 24 deletions

View File

@@ -21,8 +21,8 @@ config-paths.h: Makefile
@echo '/* where shared data is stored */' >> $@
@echo '#define PKGDATADIR "$(datadir)/WindowMaker"' >> $@
@echo '' >> $@
@echo '/* where the configuration is stored */' >> $@
@echo '#define SYSCONFDIR "$(sysconfdir)"' >> $@
@echo '/* where the global defaults are stored */' >> $@
@echo '#define DEFSDATADIR "$(defsdatadir)"' >> $@
ACLOCAL_AMFLAGS = -I m4

View File

@@ -103,17 +103,14 @@ char *wdefaultspathfordomain(const char *domain)
}
/* XXX: doesn't quite belong to *user*defaults.c */
#ifndef GLOBAL_DEFAULTS_SUBDIR
#define GLOBAL_DEFAULTS_SUBDIR "WindowMaker"
#endif
char *wglobaldefaultspathfordomain(const char *domain)
{
char *t = NULL;
size_t len;
len = strlen( SYSCONFDIR ) + strlen( GLOBAL_DEFAULTS_SUBDIR ) + strlen(domain) + 3;
len = strlen(DEFSDATADIR) + strlen(domain) + 2;
t = wmalloc(len);
snprintf(t, len, "%s/%s/%s", SYSCONFDIR, GLOBAL_DEFAULTS_SUBDIR, domain);
snprintf(t, len, "%s/%s", DEFSDATADIR, domain);
return t;
}

View File

@@ -1,6 +1,3 @@
defsdatadir = $(sysconfdir)/WindowMaker
defsdata_DATA = WMRootMenu WMWindowAttributes WindowMaker WMState WMGLOBAL
wpexecbindir = @wprefs_bindir@

View File

@@ -867,6 +867,21 @@ AS_IF([test "x$with_gnustepdir" = "x"],
AC_SUBST([wprefs_datadir])dnl
AC_SUBST([wprefs_bindir])dnl
dnl Support for DEFSDATADIR option
dnl ============================
AC_ARG_WITH([defsdatadir],
[AS_HELP_STRING([--with-defsdatadir=PATH], [specify where global defaults are located [SYSCONFDIR/WindowMaker]])],
[AS_CASE([$withval],
[yes|no], [AC_MSG_ERROR([bad value '$withval' for --with-defsdatadir, expected a path]) ],
[/*], [], dnl Absolute path, ok
[\$*], [], dnl Assumes it starts with a reference to $prefix or a similar variable, ok
[AC_MSG_ERROR([bad path '$withval' for defsdatadir, expecting an absolute path])])],
[with_defsdatadir=""])
AS_IF([test "x$with_defsdatadir" != "x"],
[defsdatadir="$with_defsdatadir"],
[defsdatadir='${sysconfdir}/WindowMaker'])
AC_SUBST([defsdatadir])dnl
dnl Enable User Defined Menu thing
dnl ==============================

View File

@@ -67,11 +67,6 @@
#define MAX_SHORTCUT_LENGTH 32
#ifndef GLOBAL_DEFAULTS_SUBDIR
#define GLOBAL_DEFAULTS_SUBDIR "WindowMaker"
#endif
typedef struct _WDefaultEntry WDefaultEntry;
typedef int (WDECallbackConvert) (WScreen *scr, WDefaultEntry *entry, WMPropList *plvalue, void *addr, void **tdata);
typedef int (WDECallbackUpdate) (WScreen *scr, WDefaultEntry *entry, void *tdata, void *extra_data);
@@ -879,7 +874,7 @@ static WMPropList *readGlobalDomain(const char *domainName, Bool requireDictiona
char path[PATH_MAX];
struct stat stbuf;
snprintf(path, sizeof(path), "%s/%s/%s", SYSCONFDIR, GLOBAL_DEFAULTS_SUBDIR, domainName);
snprintf(path, sizeof(path), "%s/%s", DEFSDATADIR, domainName);
if (stat(path, &stbuf) >= 0) {
globalDict = WMReadPropListFromFile(path);
if (globalDict && requireDictionary && !WMIsPLDictionary(globalDict)) {
@@ -929,7 +924,7 @@ void wDefaultsMergeGlobalMenus(WDDomain * menuDomain)
return;
#ifdef GLOBAL_PREAMBLE_MENU_FILE
submenu = WMReadPropListFromFile(SYSCONFDIR "/" GLOBAL_DEFAULTS_SUBDIR "/" GLOBAL_PREAMBLE_MENU_FILE);
submenu = WMReadPropListFromFile(DEFSDATADIR "/" GLOBAL_PREAMBLE_MENU_FILE);
if (submenu && !WMIsPLArray(submenu)) {
wwarning(_("invalid global menu file %s"), GLOBAL_PREAMBLE_MENU_FILE);
@@ -943,7 +938,7 @@ void wDefaultsMergeGlobalMenus(WDDomain * menuDomain)
#endif
#ifdef GLOBAL_EPILOGUE_MENU_FILE
submenu = WMReadPropListFromFile(SYSCONFDIR "/" GLOBAL_DEFAULTS_SUBDIR "/" GLOBAL_EPILOGUE_MENU_FILE);
submenu = WMReadPropListFromFile(DEFSDATADIR "/" GLOBAL_EPILOGUE_MENU_FILE);
if (submenu && !WMIsPLArray(submenu)) {
wwarning(_("invalid global menu file %s"), GLOBAL_EPILOGUE_MENU_FILE);

View File

@@ -59,10 +59,6 @@
#include <WINGs/WUtil.h>
#ifndef GLOBAL_DEFAULTS_SUBDIR
#define GLOBAL_DEFAULTS_SUBDIR "WindowMaker"
#endif
/****** Global Variables ******/
struct wmaker_global_variables w_global;
@@ -662,7 +658,7 @@ static int real_main(int argc, char **argv)
printf("Window Maker %s\n", VERSION);
exit(0);
} else if (strcmp(argv[i], "--global_defaults_path") == 0) {
printf("%s/%s\n", SYSCONFDIR, GLOBAL_DEFAULTS_SUBDIR);
printf("%s\n", DEFSDATADIR);
exit(0);
} else if (strcmp(argv[i], "-locale") == 0 || strcmp(argv[i], "--locale") == 0) {
i++;

View File

@@ -1017,7 +1017,7 @@ Bool UpdateDomainFile(WDDomain * domain)
dict = domain->dictionary;
if (WMIsPLDictionary(domain->dictionary)) {
/* retrieve global system dictionary */
snprintf(path, sizeof(path), "%s/WindowMaker/%s", SYSCONFDIR, domain->domain_name);
snprintf(path, sizeof(path), "%s/%s", DEFSDATADIR, domain->domain_name);
if (stat(path, &stbuf) >= 0) {
shared_dict = WMReadPropListFromFile(path);
if (shared_dict) {