introduce PLUGINDIR in config.mk which is used to determine the default look up path for plugins

This commit is contained in:
Sebastian Ramacher 2011-10-08 23:42:41 +02:00
parent b693b8735b
commit 9498b54fbc
2 changed files with 15 additions and 11 deletions

View file

@ -7,6 +7,8 @@ VERSION = 0.0.8.1
PREFIX ?= /usr PREFIX ?= /usr
MANPREFIX ?= ${PREFIX}/share/man MANPREFIX ?= ${PREFIX}/share/man
DESKTOPPREFIX ?= ${PREFIX}/share/applications DESKTOPPREFIX ?= ${PREFIX}/share/applications
# list of : seperated values
PLUGINDIR ?= ${PREFIX}/lib/zathura
# libs # libs
@ -26,7 +28,7 @@ INCS = ${GIRARA_INC} ${GTK_INC} $(SQLITE_INC)
LIBS = ${GIRARA_LIB} ${GTK_LIB} $(SQLITE_LIB) $(DL_LIB) -lpthread -lm LIBS = ${GIRARA_LIB} ${GTK_LIB} $(SQLITE_LIB) $(DL_LIB) -lpthread -lm
# flags # flags
CFLAGS += -std=c99 -pedantic -Wall -Wno-format-zero-length -Wextra $(INCS) CFLAGS += -std=c99 -pedantic -Wall -Wno-format-zero-length -Wextra $(INCS) -DZATHURA_PLUGINDIR=\"${PLUGINDIR}\"
# debug # debug
DFLAGS ?= -g DFLAGS ?= -g

View file

@ -52,7 +52,7 @@ zathura_init(int argc, char* argv[])
} }
g_option_context_free(context); g_option_context_free(context);
zathura_t* zathura = malloc(sizeof(zathura_t)); zathura_t* zathura = g_malloc0(sizeof(zathura_t));
if (zathura == NULL) { if (zathura == NULL) {
return NULL; return NULL;
@ -98,9 +98,13 @@ zathura_init(int argc, char* argv[])
} }
g_strfreev(paths); g_strfreev(paths);
} else { } else {
/* XXX: this shouldn't be hard coded! */ #ifdef ZATHURA_PLUGINDIR
girara_list_append(zathura->plugins.path, g_strdup("/usr/local/lib/zathura")); gchar** paths = g_strsplit(ZATHURA_PLUGINDIR, ":", 0);
girara_list_append(zathura->plugins.path, g_strdup("/usr/lib/zathura")); for (unsigned int i = 0; paths[i] != '\0'; ++i) {
girara_list_append(zathura->plugins.path, g_strdup(paths[i]));
}
g_strfreev(paths);
#endif
} }
/* UI */ /* UI */
@ -134,7 +138,7 @@ zathura_init(int argc, char* argv[])
/* load local configuration files */ /* load local configuration files */
char* configuration_file = g_build_filename(zathura->config.config_dir, ZATHURA_RC, NULL); char* configuration_file = g_build_filename(zathura->config.config_dir, ZATHURA_RC, NULL);
config_load_file(zathura, configuration_file); config_load_file(zathura, configuration_file);
free(configuration_file); g_free(configuration_file);
/* initialize girara */ /* initialize girara */
zathura->ui.session->gtk.embed = embed; zathura->ui.session->gtk.embed = embed;
@ -232,13 +236,10 @@ error_free:
g_object_unref(zathura->ui.page_view); g_object_unref(zathura->ui.page_view);
} }
girara_session_destroy(zathura->ui.session);
girara_list_free(zathura->bookmarks.bookmarks);
zathura_db_free(zathura->database);
error_out: error_out:
free(zathura); zathura_free(zathura);
return NULL; return NULL;
} }
@ -279,7 +280,7 @@ zathura_free(zathura_t* zathura)
g_free(zathura->config.config_dir); g_free(zathura->config.config_dir);
g_free(zathura->config.data_dir); g_free(zathura->config.data_dir);
free(zathura); g_free(zathura);
} }
gboolean gboolean
@ -550,3 +551,4 @@ int main(int argc, char* argv[])
return 0; return 0;
} }