Removed --enable-relocation option; modified installation directories business a bit

master
Yevgen Muntyan 2006-12-12 22:54:49 -06:00
parent f662c28634
commit ce2565cb45
13 changed files with 202 additions and 177 deletions

View File

@ -11,9 +11,6 @@ configure has the following medit-specific options:
--enable-debug enable debug options (default = NO) --enable-debug enable debug options (default = NO)
--enable-all-warnings enable lot of compiler warnings (default = NO) --enable-all-warnings enable lot of compiler warnings (default = NO)
--enable-relocation do not hardcode data directories (default = NO)
This option seems to be working, but it's useful only for custom binary
distributions.
--with-xml whether to use libxml2 (default = YES) --with-xml whether to use libxml2 (default = YES)
This option is useful only for development, to test how medit works in absense This option is useful only for development, to test how medit works in absense

View File

@ -14,7 +14,6 @@ m4files = \
m4/moo-progs.m4 \ m4/moo-progs.m4 \
m4/moo-pygtk.m4 \ m4/moo-pygtk.m4 \
m4/moo-python.m4 \ m4/moo-python.m4 \
m4/moo-reloc.m4 \
m4/moo-version.m4 \ m4/moo-version.m4 \
m4/moo-xdgmime.m4 \ m4/moo-xdgmime.m4 \
m4/moo-xml.m4 m4/moo-xml.m4

View File

@ -2,8 +2,6 @@
# MOO_AC_SET_DIRS(base) # MOO_AC_SET_DIRS(base)
# #
AC_DEFUN([MOO_AC_SET_DIRS],[ AC_DEFUN([MOO_AC_SET_DIRS],[
AC_REQUIRE([MOO_AC_RELOC])
MOO_PACKAGE_NAME=$1 MOO_PACKAGE_NAME=$1
AC_SUBST(MOO_PACKAGE_NAME) AC_SUBST(MOO_PACKAGE_NAME)
AC_DEFINE([MOO_PACKAGE_NAME], "$1", [package name]) AC_DEFINE([MOO_PACKAGE_NAME], "$1", [package name])
@ -14,7 +12,11 @@ AC_DEFUN([MOO_AC_SET_DIRS],[
MOO_LIB_DIR="${libdir}/$1" MOO_LIB_DIR="${libdir}/$1"
AC_SUBST(MOO_LIB_DIR) AC_SUBST(MOO_LIB_DIR)
MOO_LOCALE_DIR="${datadir}/locale" MOO_PLUGINS_DIR="${MOO_LIB_DIR}/plugins"
AC_SUBST(MOO_PLUGINS_DIR)
# copied from po/Makefile.in.in
MOO_LOCALE_DIR="${prefix}/${DATADIRNAME}/locale"
AC_SUBST(MOO_LOCALE_DIR) AC_SUBST(MOO_LOCALE_DIR)
MOO_TEXT_LANG_FILES_DIR="${MOO_DATA_DIR}/language-specs" MOO_TEXT_LANG_FILES_DIR="${MOO_DATA_DIR}/language-specs"

View File

@ -1,27 +0,0 @@
##############################################################################
# MOO_AC_RELOC()
#
AC_DEFUN([MOO_AC_RELOC],[
AC_REQUIRE([MOO_AC_CHECK_OS])
if test "x$MOO_OS_MINGW" = "xyes"; then
MOO_ENABLE_RELOCATION="yes"
else
MOO_ENABLE_RELOCATION="no"
fi
AC_ARG_ENABLE(relocation,
AC_HELP_STRING([--enable-relocation],[do not hardcode data directories (default = NO)]),[
if test "x$enableval" = "xyes"; then
MOO_ENABLE_RELOCATION="yes"
else
MOO_ENABLE_RELOCATION="no"
fi
])
AM_CONDITIONAL(MOO_ENABLE_RELOCATION, test $MOO_ENABLE_RELOCATION = "yes")
if test "x$MOO_ENABLE_RELOCATION" = "xyes"; then
AC_DEFINE(MOO_ENABLE_RELOCATION, 1, [enable relocation])
fi
])

View File

@ -555,7 +555,7 @@ push_appdir_to_path (void)
const char *path; const char *path;
char *new_path; char *new_path;
appdir = moo_get_app_dir (); appdir = moo_win32_get_app_dir ();
g_return_if_fail (appdir != NULL); g_return_if_fail (appdir != NULL);
path = g_getenv ("Path"); path = g_getenv ("Path");

View File

@ -222,7 +222,7 @@ push_appdir_to_path (void)
const char *path; const char *path;
char *new_path; char *new_path;
appdir = moo_get_app_dir (); appdir = moo_win32_get_app_dir ();
g_return_if_fail (appdir != NULL); g_return_if_fail (appdir != NULL);
path = g_getenv ("Path"); path = g_getenv ("Path");

View File

@ -14,7 +14,7 @@
<gtk-cvs> <gtk-cvs>
<build_dir>/home/muntyan/projects/gtk/build/moo</build_dir> <build_dir>/home/muntyan/projects/gtk/build/moo</build_dir>
<configure> <configure>
<args>--enable-debug --enable-all-warnings --prefix=$PREFIX --with-fam</args> <args>--enable-debug --enable-all-warnings --prefix=$PREFIX --with-fam --with-mooterm</args>
<vars> <vars>
<var name="CFLAGS">-g</var> <var name="CFLAGS">-g</var>
</vars> </vars>

View File

@ -6,7 +6,9 @@ datadir=@datadir@
libdir=@libdir@ libdir=@libdir@
langfilesdir=@MOO_TEXT_LANG_FILES_DIR@ langfilesdir=@MOO_TEXT_LANG_FILES_DIR@
pluginsdir=@MOO_LIB_DIR@/plugins pluginsdir=@MOO_PLUGINS_DIR@
moolibdir=@MOO_LIB_DIR@
moodatadir=@MOO_DATA_DIR@
Name: moo Name: moo
Description: A text editor and terminal emulator library Description: A text editor and terminal emulator library

View File

@ -112,7 +112,7 @@ MOO_MODULE_INIT_FUNC_DECL
} }
#ifdef __WIN32__ #ifdef __WIN32__
dlldir = moo_get_dll_dir (MOO_PYTHON_MODULE_DLL_NAME); dlldir = moo_win32_get_dll_dir (MOO_PYTHON_MODULE_DLL_NAME);
#endif #endif
if (dlldir && !sys_path_add_dir (dlldir)) if (dlldir && !sys_path_add_dir (dlldir))

View File

@ -1,7 +1,7 @@
SUBDIRS = pyproject SUBDIRS = pyproject
moopython_pluginsdir = $(MOO_LIB_DIR)/plugins moopython_pluginsdir = ${MOO_PLUGINS_DIR}
moopython_plugins_libdir = $(MOO_LIB_DIR)/plugins/lib moopython_plugins_libdir = ${MOO_PLUGINS_DIR}/lib
ini_in_in_files = \ ini_in_in_files = \
terminal.ini.desktop.in.in \ terminal.ini.desktop.in.in \

View File

@ -5,11 +5,11 @@ ini_in_files = $(ini_in_in_files:.ini.desktop.in.in=.ini.desktop.in)
ini_files = $(ini_in_files:.ini.desktop.in=.ini) ini_files = $(ini_in_files:.ini.desktop.in=.ini)
CLEANFILES = $(ini_files) $(ini_in_files) CLEANFILES = $(ini_files) $(ini_in_files)
inidir = $(MOO_LIB_DIR)/plugins inidir = ${MOO_PLUGINS_DIR}
ini_DATA = \ ini_DATA = \
$(ini_files) $(ini_files)
plugindir = $(MOO_LIB_DIR)/plugins/project plugindir = $(inidir)/project
nobase_plugin_DATA = \ nobase_plugin_DATA = \
project-plugin.py \ project-plugin.py \
mprj/__init__.py \ mprj/__init__.py \

View File

@ -53,18 +53,23 @@ G_WIN32_DLLMAIN_FOR_DLL_NAME(static, libmoo_dll_name)
const char * const char *
_moo_get_locale_dir (void) _moo_get_locale_dir (void)
{ {
static char *dir = NULL; G_LOCK_DEFINE_STATIC (moo_locale_dir);
static char *moo_locale_dir = NULL;
if (!dir) G_LOCK (moo_locale_dir);
if (!moo_locale_dir)
{ {
char *tmp; char *tmp;
tmp = g_win32_get_package_installation_subdirectory (NULL, libmoo_dll_name, tmp = g_win32_get_package_installation_subdirectory (NULL, libmoo_dll_name,
"lib\\locale"); "lib\\locale");
dir = g_win32_locale_filename_from_utf8 (tmp); moo_locale_dir = g_win32_locale_filename_from_utf8 (tmp);
g_free (tmp); g_free (tmp);
} }
return dir; G_UNLOCK (moo_locale_dir);
return moo_locale_dir;
} }
#endif #endif
@ -1169,39 +1174,48 @@ _moo_menu_item_set_label (GtkWidget *item,
const char * const char *
_moo_get_pid_string (void) _moo_get_pid_string (void)
{ {
static char *string; G_LOCK_DEFINE_STATIC (moo_pid_string);
static char *moo_pid_string;
if (!string) G_LOCK (moo_pid_string);
if (!moo_pid_string)
{ {
#ifdef __WIN32__ #ifdef __WIN32__
#ifdef __GNUC__ #ifdef __GNUC__
#warning "Implement _moo_get_pid_string()" #warning "Implement _moo_get_pid_string()"
#endif #endif
string = g_strdup (""); moo_pid_string = g_strdup ("");
#else #else
string = g_strdup_printf ("%d", getpid ()); moo_pid_string = g_strdup_printf ("%d", getpid ());
#endif #endif
} }
return string; G_UNLOCK (moo_pid_string);
return moo_pid_string;
} }
#ifdef __WIN32__ #ifdef __WIN32__
char * char *
moo_get_app_dir (void) moo_win32_get_app_dir (void)
{ {
static char *appdir; static char *moo_app_dir;
G_LOCK_DEFINE_STATIC(moo_app_dir);
if (!appdir) G_LOCK (moo_app_dir);
appdir = moo_get_dll_dir (NULL);
return g_strdup (appdir); if (!moo_app_dir)
moo_app_dir = moo_win32_get_dll_dir (NULL);
G_UNLOCK (moo_app_dir);
return g_strdup (moo_app_dir);
} }
char * char *
moo_get_dll_dir (const char *dll) moo_win32_get_dll_dir (const char *dll)
{ {
char *dir; char *dir;
char *dllname = NULL; char *dllname = NULL;
@ -1237,43 +1251,9 @@ moo_get_dll_dir (const char *dll)
return dir; return dir;
} }
#else
char *
moo_get_app_dir (void)
{
g_return_val_if_reached (g_strdup ("."));
}
char *
moo_get_dll_dir (G_GNUC_UNUSED const char *dll)
{
g_return_val_if_reached (g_strdup ("."));
}
#endif #endif
static char *
moo_get_data_dir (G_GNUC_UNUSED MooDataDirType type)
{
#ifdef __WIN32__
return moo_get_app_dir ();
#elif !defined(MOO_ENABLE_RELOCATION)
switch (type)
{
case MOO_DATA_SHARE:
return g_strdup (MOO_DATA_DIR);
case MOO_DATA_LIB:
return g_strdup (MOO_LIB_DIR);
}
g_return_val_if_reached (NULL);
#else
return NULL;
#endif
}
static const char * static const char *
moo_get_prgname (void) moo_get_prgname (void)
{ {
@ -1339,106 +1319,177 @@ cmp_dirs (const char *dir1,
} }
static GSList *
add_dir_list_from_env (GSList *list,
const char *var)
{
char **dirs, **p;
#ifdef __WIN32__
dirs = g_strsplit (var, ";", 0);
p = moo_filenames_from_locale (dirs);
g_strfreev (dirs);
dirs = p;
#else
dirs = g_strsplit (var, ":", 0);
#endif
for (p = dirs; p && *p; ++p)
list = g_slist_prepend (list, *p);
g_free (dirs);
return list;
}
#ifdef __WIN32__
static GSList *
add_win32_data_dirs_for_dll (GSList *list,
const char *subdir_name,
const char *dllname)
{
char *dlldir, *datadir;
dlldir = moo_win32_get_dll_dir (dllname);
if (g_str_has_suffix (dlldir, "\\"))
{
char *tmp = g_strndup (dlldir, strlen(dlldir) - 1);
g_free (dlldir);
dlldir = tmp;
}
if (g_str_has_suffix (dlldir, "bin") ||
g_str_has_suffix (dlldir, "lib"))
{
char *tmp = g_path_get_dirname (dlldir);
datadir = g_build_filename (tmp, subdir_name, NULL);
g_free (tmp);
}
else
{
datadir = g_strdup (dlldir);
}
g_free (dlldir);
list = g_slist_prepend (list, datadir);
return list;
}
static GSList *
add_win32_data_dirs (GSList *list,
const char *prefix)
{
char *subdir;
subdir = g_strdup_printf ("%s\\" MOO_PACKAGE_NAME, prefix);
list = add_win32_data_dirs_for_dll (list, subdir, libmoo_dll_name);
list = add_win32_data_dirs_for_dll (list, subdir, NULL);
g_free (subdir);
return list;
}
#endif
char ** char **
moo_get_data_dirs (MooDataDirType type, moo_get_data_dirs (MooDataDirType type,
guint *n_dirs) guint *n_dirs)
{ {
const char *env[2]; static char **moo_data_dirs[2];
GPtrArray *dirs; static guint n_data_dirs[2];
GSList *list = NULL; G_LOCK_DEFINE_STATIC(moo_data_dirs);
guint i;
char *d;
dirs = g_ptr_array_sized_new (3); g_return_val_if_fail (type < 2, NULL);
env[0] = g_getenv ("MOO_APP_DIRS");
env[1] = type == MOO_DATA_SHARE ? g_getenv ("MOO_DATA_DIRS") : g_getenv ("MOO_LIB_DIRS");
for (i = 0; i < 2; ++i) G_LOCK (moo_data_dirs);
if (!moo_data_dirs[type])
{ {
const char *var = env[i]; const char *env[2];
char **env_dirs, **p; GPtrArray *dirs;
GSList *list = NULL;
guint i;
if (!var || !*var) dirs = g_ptr_array_new ();
continue;
#ifdef __WIN32__ env[0] = g_getenv ("MOO_APP_DIRS");
env_dirs = g_strsplit (var, ";", 0); env[1] = type == MOO_DATA_SHARE ? g_getenv ("MOO_DATA_DIRS") : g_getenv ("MOO_LIB_DIRS");
p = moo_filenames_from_locale (env_dirs);
g_strfreev (env_dirs);
env_dirs = p;
#else
env_dirs = g_strsplit (var, ":", 0);
#endif
for (p = env_dirs; p && *p; ++p) /* environment variables override everything */
if (env[0] || env[1])
{ {
if (**p) if (env[1])
list = g_slist_prepend (list, *p); list = add_dir_list_from_env (list, env[1]);
else else
g_free (*p); list = add_dir_list_from_env (list, env[0]);
} }
g_free (env_dirs);
}
if ((d = moo_get_data_dir (type)))
list = g_slist_prepend (list, d);
#ifdef __WIN32__
d = NULL;
switch (type)
{
case MOO_DATA_SHARE:
d = g_win32_get_package_installation_subdirectory (NULL, libmoo_dll_name,
"share\\" MOO_PACKAGE_NAME);
break;
case MOO_DATA_LIB:
d = g_win32_get_package_installation_subdirectory (NULL, libmoo_dll_name,
"lib\\" MOO_PACKAGE_NAME);
break;
}
if (d)
list = g_slist_prepend (list, d);
#endif
list = g_slist_prepend (list, moo_get_user_data_dir ());
list = g_slist_reverse (list);
while (list)
{
gboolean found = FALSE;
if (!list->data)
{
list = g_slist_delete_link (list, list);
continue;
}
for (i = 0; i < dirs->len; ++i)
{
if (cmp_dirs (list->data, dirs->pdata[i]))
{
found = TRUE;
break;
}
}
if (!found)
g_ptr_array_add (dirs, list->data);
else else
g_free (list->data); {
#ifdef __WIN32__
list = add_win32_data_dirs (list, type == MOO_DATA_SHARE ? "share" : "lib");
#else
if (type == MOO_DATA_SHARE)
{
const char* const *p;
const char* const *sys_dirs;
list = g_slist_delete_link (list, list); sys_dirs = g_get_system_data_dirs ();
for (p = sys_dirs; p && *p; ++p)
list = g_slist_prepend (list, g_strdup (*p));
list = g_slist_prepend (list, g_strdup (MOO_DATA_DIR));
}
else
{
list = g_slist_prepend (list, g_strdup (MOO_LIB_DIR));
}
#endif
}
list = g_slist_prepend (list, moo_get_user_data_dir ());
list = g_slist_reverse (list);
while (list)
{
gboolean found = FALSE;
char *path;
path = list->data;
list = g_slist_delete_link (list, list);
if (!path || !path[0])
{
g_free (path);
continue;
}
for (i = 0; i < dirs->len; ++i)
{
if (cmp_dirs (path, dirs->pdata[i]))
{
found = TRUE;
break;
}
}
if (!found)
g_ptr_array_add (dirs, path);
else
g_free (path);
}
g_ptr_array_add (dirs, NULL);
n_data_dirs[type] = dirs->len - 1;
moo_data_dirs[type] = (char**) g_ptr_array_free (dirs, FALSE);
} }
G_UNLOCK (moo_data_dirs);
if (n_dirs) if (n_dirs)
*n_dirs = dirs->len; *n_dirs = n_data_dirs[type];
g_ptr_array_add (dirs, NULL); return g_strdupv (moo_data_dirs[type]);
return (char**) g_ptr_array_free (dirs, FALSE);
} }

View File

@ -63,9 +63,10 @@ typedef enum {
GType moo_data_dir_type_get_type (void) G_GNUC_CONST; GType moo_data_dir_type_get_type (void) G_GNUC_CONST;
/* application directory on win32 */ #ifdef __WIN32__
char *moo_get_app_dir (void); char *moo_win32_get_app_dir (void);
char *moo_get_dll_dir (const char *dll); char *moo_win32_get_dll_dir (const char *dll);
#endif
/* ~/.appname */ /* ~/.appname */
gboolean moo_make_user_data_dir (const char *path); gboolean moo_make_user_data_dir (const char *path);